UNPKG

react-forminate

Version:

React.js + Typescript package that creates dynamic UI forms based on the JSON schema

32 lines 51.1 kB
"use strict";var Ft=Object.defineProperty;var Ct=(t,e,s)=>e in t?Ft(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var X=(t,e,s)=>Ct(t,typeof e!="symbol"?e+"":e,s);const a=require("react"),wt=["className","htmlFor","defaultValue","defaultChecked","onChange","onClick","onBlur","onFocus","onKeyDown","onKeyUp","onMouseEnter","onMouseLeave","onInput","onSubmit","onInvalid","children","key","ref","style","dangerouslySetInnerHTML","suppressContentEditableWarning","suppressHydrationWarning","role","tabIndex","aria-hidden","aria-label","aria-labelledby","aria-describedby","aria-live","aria-expanded","aria-checked","aria-disabled","aria-required","data-testid","data-*","name","type","value","placeholder","checked","disabled","readOnly","required","min","max","minLength","maxLength","pattern","step","multiple","accept","autoFocus","autoComplete","autoCorrect","spellCheck","form","formAction","formMethod","formNoValidate","formTarget","inputMode","list","rows","cols","id","title","hidden","dir","lang","contentEditable","draggable","accessKey","src","alt","width","height","poster","preload","controls","muted","loop","playsInline","href","target","download","rel","dangerouslySetInnerHTML"],Et={input:"input",textarea:"textarea",select:"select",button:"button",form:"form",div:"div",span:"span",label:"label",a:"a",img:"img",radio:"input",checkbox:"input",file:"input"},tt=["checkbox","multiSelect"],St=t=>{const e=[],r=t.toString().match(/(values|formValues|values\?)\.([a-zA-Z0-9_]+)/g);return r&&r.forEach(n=>{const c=n.split(".")[1];e.push(c)}),e},st=t=>typeof t=="function"?{fn:t,dependsOn:[...St(t)]}:t,Rt=(t,e={})=>{function s(c){const i=[];for(const l in c)typeof c[l]=="object"&&c[l]!==null&&Array.isArray(c[l]?.dependsOn)&&i.push(...c[l].dependsOn);return i}function r(c){for(const i of c){if(!i.fieldId)continue;const l=s(i);for(const m of l)e[m]||(e[m]=new Set),e[m].add(i.fieldId);Array.isArray(i.fields)&&r(i.fields)}}r(t);const n={};for(const c in e)n[c]=Array.from(e[c]);return n},rt={checkbox:[],number:"",tel:"",text:"",email:"",url:"",password:"",search:"",date:"",radio:"",select:"",textarea:"",gridview:[],container:{},spacer:"",group:[],file:{}};function Je(t){return t.type==="select"||t.type==="multiSelect"}function At(t,e,s=[]){const r=document.createElement(Et[t]||"div"),n=new Set;for(const i in r)n.add(i);wt?.forEach(i=>n.add(i));const c=i=>!s.includes(i)&&(n.has(i)||i.startsWith("data-")||i.startsWith("aria-"));return Object.fromEntries(Object.entries(e).filter(([i])=>c(i)))}const fe=(t,e=[],s={},r)=>{for(const n of e){if(n.fieldId===t)return n;if(n.fields&&n.fields.length>0){const c=fe(t,n.fields,s);if(c)return c}}return null},Ot=t=>{if(!t?.fields)return[];const e=new Set,s=[...t.fields];for(;s.length;){const r=s.pop();typeof r?.type=="string"&&(e.add(r.type),Array.isArray(r.fields)&&s.push(...r.fields))}return Array.from(e)},kt=t=>{if(typeof t=="number")return!0;if(typeof t=="string"){const e=t.trim();return!isNaN(e)&&!isNaN(parseFloat(e))}return!1},oe=class oe{constructor(){X(this,"cache",new Map)}static getInstance(){return oe.instance||(oe.instance=new oe),oe.instance}process(e,s={},r){const n=this.getCacheKey(e,s);if(this.cache.has(n))return this.cache.get(n);const c=this.processField(e,s,r);return this.cache.set(n,c),c}processAllFields(e,s,r){return e.map(n=>this.process(n,s,r))}processField(e,s,r){const n={fieldId:e.fieldId,values:s,fieldSchema:e,formSchema:r},c=us.processFieldProps(e,n);return e.fields&&e.fields.length>0&&(c.fields=e.fields.map(i=>this.processField(i,s,r))),c}getCacheKey(e,s){const n=this.getFieldDependencies(e).map(c=>`${c}:${JSON.stringify(s[c])}`).join("|");return`${e.fieldId}|${n}|${JSON.stringify(e)}`}getFieldDependencies(e){const s=new Set;return["label","required","disabled","visibility","options","requiredMessage","content"].forEach(n=>{const c=e[n],i=st(c);i&&typeof i=="object"&&"dependsOn"in i&&Array.isArray(i.dependsOn)&&i.dependsOn.forEach(l=>s.add(l))}),typeof e.visibility=="object"&&"dependsOn"in e.visibility&&e.visibility.dependsOn&&(Array.isArray(e.visibility.dependsOn)&&e.visibility.dependsOn.length?e.visibility.dependsOn.forEach(n=>{s.add(n)}):s.add(e.fieldId)),Array.from(s)}clearCache(){this.cache.clear()}clearCacheForField(e){Array.from(this.cache.keys()).filter(s=>s.startsWith(`${e}|`)).forEach(s=>this.cache.delete(s))}};X(oe,"instance");let he=oe;const nt=(t,e,s,r,n)=>{const{touchedFields:c,forceValidate:i,validateFieldsOnBlur:l}=s;if(l!==!1&&!i&&c&&!c[t.fieldId]||!it(t,s.values,n)||Nt(t,s.values,n))return!0;const m=tt.includes(t.type)&&Array.isArray(e)&&e.length===0;return(!e&&e!==0&&e!==!1||m)&&!r.required},ot=(t,e)=>{const s=[];return t.required&&s.push({type:"required",message:t.requiredMessage||"This field is required"}),t.validation?.length&&s.push(...t.validation.map(r=>r.type==="equalTo"&&typeof r.equalTo=="string"&&r.equalTo.startsWith("{{")?{...r,equalTo:e[r.equalTo.replace(/[{}]/g,"")]}:r)),s},jt=async(t,e,s,r,n,c,i=!1)=>{const l=fe(t,s.fields,r);if(!l)return;const m={values:r,touchedFields:c,forceValidate:i,validateFieldsOnBlur:s.options?.validateFieldsOnBlur},d=he.getInstance().process(l,r,s);if(nt(l,e,m,d,s)){n(p=>{const v={...p};return delete v[t],v});return}const u=ot(d,r);if(!u.length){n(p=>{const v={...p};return delete v[t],v});return}const{isValid:g,message:b}=await Re.validate(e,u,r);n(p=>{const v={...p};return g?delete v[t]:v[t]=b||"Invalid value",v})},Tt=async(t,e,s,r,n=!1)=>{const c={},i=he.getInstance(),l={values:e,touchedFields:r,forceValidate:n,validateFieldsOnBlur:t.options?.validateFieldsOnBlur},m=async d=>{let u=!0;for(const g of d){if(g.fields?.length){u=await m(g.fields)&&u;continue}const b=i.process(g,e,t),p=e[g.fieldId];if(nt(g,p,l,b,t))continue;const v=ot(b,e);if(!v.length)continue;const{isValid:S,message:j}=await Re.validate(p,v,e);S||(c[g.fieldId]=j||"Invalid value",u=!1)}return u};return await m(t.fields),s(c),Object.keys(c).length===0},it=(t,e,s)=>{const r=t.visibility;if(typeof r=="boolean")return r;if(typeof r>"u")return!0;if(typeof r=="function")return r({fieldId:t.fieldId,values:e,fieldSchema:t,formSchema:s});if(r&&typeof r=="object"&&"fn"in r)return r.fn({fieldId:t.fieldId,values:e,fieldSchema:t,formSchema:s});if(r&&typeof r=="object"&&"dependsOn"in r&&"condition"in r&&"value"in r){const{dependsOn:n,condition:c,value:i}=r,l=Array.isArray(n)?n.map(u=>e[u]):e[n];if(l==null)return!1;const m=(u,g)=>u==null||g===null||g===void 0?null:typeof u=="number"&&typeof g=="number"?u-g:u instanceof Date&&g instanceof Date?u.getTime()-g.getTime():String(u).localeCompare(String(g)),d=(u,g)=>{if(u===null)return!1;switch(g){case">":return u>0;case">=":return u>=0;case"<":return u<0;case"<=":return u<=0;default:return!1}};switch(c){case"equals":return Array.isArray(l)?l.some(u=>u===i):l===i;case"not_equals":return Array.isArray(l)?l.every(u=>u!==i):l!==i;case"greater_than":return Array.isArray(l)?l.some(u=>d(m(u,i),">")):d(m(l,i),">");case"greater_than_or_equal":return Array.isArray(l)?l.some(u=>d(m(u,i),">=")):d(m(l,i),">=");case"less_than":return Array.isArray(l)?l.some(u=>d(m(u,i),"<")):d(m(l,i),"<");case"less_than_or_equal":return Array.isArray(l)?l.some(u=>d(m(u,i),"<=")):d(m(l,i),"<=");case"contains":return l===""||i===""?!1:Array.isArray(l)?l.some(u=>Array.isArray(u)?u.includes(i):String(u).includes(String(i))):Array.isArray(l)?l.includes(i):String(l).includes(String(i));case"not_contains":return l===""||i===""?!0:Array.isArray(l)?l.every(u=>Array.isArray(u)?!u.includes(i):!String(u).includes(String(i))):Array.isArray(l)?!l.includes(i):!String(l).includes(String(i));case"in":return Array.isArray(i)?Array.isArray(l)?l.some(u=>i.includes(u)):i.includes(l):!1;case"not_in":return Array.isArray(i)?Array.isArray(l)?l.every(u=>!i.includes(u)):!i.includes(l):!0;default:return!1}}return!0},Nt=(t,e,s)=>typeof t.disabled=="boolean"?t.disabled:typeof t.disabled=="object"&&"fn"in t.disabled&&typeof t.disabled?.fn=="function"?t.disabled.fn({fieldId:t.fieldId,values:e||{},fieldSchema:t,formSchema:s}):!1;class U{isEmpty(e){return e==null||e===""}isString(e){return typeof e=="string"}isNumber(e){return typeof e=="number"||kt(e)}isArray(e){return Array.isArray(e)}isDate(e){return!isNaN(new Date(e).getTime())}createResponse(e,s){return{isValid:e,message:e?void 0:s}}}class _t extends U{validate(e,s){if(this.isEmpty(e))return this.createResponse(!0);const r={string:()=>this.isString(e),number:()=>this.isNumber(e),array:()=>this.isArray(e),date:()=>this.isDate(e)};return s.type&&r[s.type]&&!r[s.type]()?this.createResponse(!1,`Value must be a ${s.type}.`):this.createResponse(!0)}}class Vt extends U{constructor(){super(...arguments);X(this,"defaultSpecialChars",/[!@#$%^&*(),.?":{}|<>]/)}validate(s,r){if(this.isEmpty(s))return this.createResponse(!0);if(!this.isString(s))return this.createResponse(!1,"Value must be a string.");const n={minLength:r.minLength??8,requireUpperCase:r.requireUpperCase??!0,requireLowerCase:r.requireLowerCase??!0,requireNumber:r.requireNumber??!0,requireSpecialChar:r.requireSpecialChar??!0,specialChars:r.specialCharsPattern??this.defaultSpecialChars},c=typeof n.specialChars=="string"?new RegExp(n.specialChars):n.specialChars,i={length:s.length>=n.minLength,upperCase:!n.requireUpperCase||/[A-Z]/.test(s),lowerCase:!n.requireLowerCase||/[a-z]/.test(s),number:!n.requireNumber||/\d/.test(s),specialChar:!n.requireSpecialChar||c.test(s)};if(Object.values(i).every(Boolean))return this.createResponse(!0);const l=[!i.length&&`at least ${n.minLength} characters`,!i.upperCase&&"one uppercase letter",!i.lowerCase&&"one lowercase letter",!i.number&&"one number",!i.specialChar&&"one special character"].filter(Boolean);return this.createResponse(!1,r.message||`Password must contain ${l.join(", ")}.`)}}class qt extends U{validate(e,s,r){if(this.isEmpty(e))return this.createResponse(!0);const n=typeof s.equalTo=="function"?s.equalTo(r):s.equalTo;if(n===void 0)return this.createResponse(!0);const i=s.caseSensitive??!0?e===n:String(e).toLowerCase()===String(n).toLowerCase();return this.createResponse(i,s.message||"Values do not match.")}}class $t extends U{constructor(){super(...arguments);X(this,"emailRegex",/^[^\s@]+@[^\s@]+\.[^\s@]+$/)}validate(s,r){return this.isEmpty(s)?this.createResponse(!0):this.isString(s)?this.createResponse(this.emailRegex.test(s),r.message||"Invalid email format."):this.createResponse(!1,"Value must be a string.")}}class Mt extends U{constructor(){super(...arguments);X(this,"patterns",{ip:/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,ipPort:/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?):(\d{1,5})$/,absolute:/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([\/\w .-]*)*\/?$/,relative:/^([\/\w.-]+)+(\/)?(\?[\w.%-=&]*)?(#[\w-]*)?$/,protocolRelative:/^\/\/[\w.-]+\.[a-z]{2,}(\/.*)?$/,localhost:/^(https?:\/\/)?localhost(:\d+)?([\/\w.-]*)*\/?$/,ipUrl:/^(https?:\/\/)?(\d{1,3}\.){3}\d{1,3}(:\d+)?([\/\w.-]*)*\/?$/})}validate(s,r){if(this.isEmpty(s))return this.createResponse(!0);if(!this.isString(s))return this.createResponse(!1,"Value must be a string.");const n=s.trim();if(r.validateAs==="ip"||this.patterns.ip.test(n))return this.createResponse(this.patterns.ip.test(n),r.message||"Invalid IP address format (e.g., 192.168.1.1)");if(r.validateAs==="ipPort"||this.patterns.ipPort.test(n)){if(!this.patterns.ipPort.test(n))return this.createResponse(!1,r.message||"Invalid IP:Port format (e.g., 192.168.1.1:8080)");const u=parseInt(n.split(":")[1]);return u<1||u>65535?this.createResponse(!1,r.message||"Port must be between 1 and 65535"):this.createResponse(!0)}const c=this.patterns.absolute.test(n)||this.patterns.protocolRelative.test(n)||this.patterns.ipUrl.test(n),i=this.patterns.relative.test(n),l=n.startsWith("https://"),m=/^https?:\/\//i.test(n);if(r.requireAbsolute&&!c)return this.createResponse(!1,r.message||"Absolute URL with http:// or https:// is required.");if(r.requireHttps&&(!l||!m))return this.createResponse(!1,r.message||"HTTPS URL is required.");if(r.allowRelative===!1&&i)return this.createResponse(!1,r.message||"Relative paths are not allowed.");const d=c||i||this.patterns.localhost.test(n)||this.patterns.ipUrl.test(n);return this.createResponse(d,r.message||"Invalid URL format")}}class It extends U{validate(e,s){return this.isString(e)?s.pattern?this.createResponse(new RegExp(s.pattern).test(e),s.message||"Pattern validation failed."):this.createResponse(!0):this.createResponse(!1,"Value must be a string.")}}class Pt extends U{validate(e,s){if(!this.isString(e))return this.createResponse(!1,"Value must be a string.");const r={min:s.minLength!==void 0&&e.length>=s.minLength,max:s.maxLength!==void 0&&e.length<=s.maxLength};if((s.minLength===void 0||r.min)&&(s.maxLength===void 0||r.max))return this.createResponse(!0);const n=[s.minLength!==void 0&&!r.min&&`minimum ${s.minLength} characters`,s.maxLength!==void 0&&!r.max&&`maximum ${s.maxLength} characters`].filter(Boolean);return this.createResponse(!1,s.message||`Length must be ${n.join(" and ")}.`)}}class Dt extends U{validate(e,s){if(!this.isNumber(e))return this.createResponse(!1,"Value must be a number.");const r=typeof e=="string"?parseFloat(e):e,n={min:s.min!==void 0&&r>=s.min,max:s.max!==void 0&&r<=s.max};if((s.min===void 0||n.min)&&(s.max===void 0||n.max))return this.createResponse(!0);const c=[s.min!==void 0&&!n.min&&`minimum ${s.min}`,s.max!==void 0&&!n.max&&`maximum ${s.max}`].filter(Boolean);return this.createResponse(!1,s.message||`Value must be ${c.join(" and ")}.`)}}class Bt extends U{validate(e,s){const r=new Date(e);if(!this.isDate(r))return this.createResponse(!1,"Invalid date format.");const n={min:s.minDate!==void 0&&r>=new Date(s.minDate),max:s.maxDate!==void 0&&r<=new Date(s.maxDate)};if((s.minDate===void 0||n.min)&&(s.maxDate===void 0||n.max))return this.createResponse(!0);const c=[s.minDate!==void 0&&!n.min&&`after ${s.minDate}`,s.maxDate!==void 0&&!n.max&&`before ${s.maxDate}`].filter(Boolean);return this.createResponse(!1,s.message||`Date must be ${c.join(" and ")}.`)}}class Lt extends U{validate(e,s){if(!this.isArray(e))return this.createResponse(!1,"Value must be an array.");const r={min:s.minItems!==void 0&&e.length>=s.minItems,max:s.maxItems!==void 0&&e.length<=s.maxItems};if((s.minItems===void 0||r.min)&&(s.maxItems===void 0||r.max))return this.createResponse(!0);const n=[s.minItems!==void 0&&!r.min&&`minimum ${s.minItems} items`,s.maxItems!==void 0&&!r.max&&`maximum ${s.maxItems} items`].filter(Boolean);return this.createResponse(!1,s.message||`Array must contain ${n.join(" and ")}.`)}}class zt extends U{async validate(e,s){if(typeof s.custom!="function")return this.createResponse(!0);try{const r=s.custom(e),n=r instanceof Promise?await r:r;return this.createResponse(n,n?void 0:s.message||"Custom validation failed.")}catch(r){return console.error(r),this.createResponse(!1,"Validation error occurred")}}}class Ut extends U{validate(e){const s=!this.isEmpty(e)&&(!this.isArray(e)||e.length>0);return this.createResponse(s,"This field is required.")}}const ie=class ie{constructor(){X(this,"strategies",{});this.registerDefaultStrategies()}registerDefaultStrategies(){this.registerStrategy("type",new _t),this.registerStrategy("password",new Vt),this.registerStrategy("equalTo",new qt),this.registerStrategy("email",new $t),this.registerStrategy("url",new Mt),this.registerStrategy("pattern",new It),this.registerStrategy("length",new Pt),this.registerStrategy("number",new Dt),this.registerStrategy("date",new Bt),this.registerStrategy("array",new Lt),this.registerStrategy("custom",new zt),this.registerStrategy("required",new Ut)}determineRuleType(e){if(e.type)return e.type;const s={minLength:"length",maxLength:"length",min:"number",max:"number",minDate:"date",maxDate:"date",minItems:"array",maxItems:"array",pattern:"pattern",custom:"custom",equalTo:"equalTo",email:"email",url:"url",password:"password",required:"required"};for(const[r,n]of Object.entries(s))if(e[r]!==void 0)return n;return"type"}registerStrategy(e,s){this.strategies[e]=s}async validate(e,s,r){if(!s?.length)return{isValid:!0};for(const n of s){const c=this.determineRuleType(n),i=this.strategies[c];if(i){const l=await Promise.resolve(i.validate(e,n,r));if(!l.isValid)return l}}return{isValid:!0}}static getInstance(){return ie.instance||(ie.instance=new ie),ie.instance}};X(ie,"instance");let we=ie;const Re=we.getInstance();class Wt{constructor(){X(this,"subscribers",new Map)}subscribe(e,s){return this.subscribers.has(e)||this.subscribers.set(e,new Set),this.subscribers.get(e).add(s),()=>this.subscribers.get(e)?.delete(s)}notify(e){const s=this.subscribers.get(e);s&&s.forEach(r=>r())}unsubscribeAll(e){this.subscribers.delete(e)}clear(){this.subscribers.clear()}}const at=t=>{const[e,s]=a.useState({}),r=a.useRef({});return{dynamicOptions:e,fetchDynamicOptions:async(c,i={},l)=>{const d=fe(c,t.fields)?.dynamicOptions;if(!d||!d.endpoint)return;r.current[c]?.abort();const u=new AbortController;r.current[c]=u;let g=d.endpoint;g=g.replace(/\{\{(.*?)\}\}/g,(x,N)=>i[N]??"");const b=new URLSearchParams;if(d.params)for(const[x,N]of Object.entries(d.params)){const $=i[N];$!==void 0&&b.append(x,$)}const p=d.pagination,v=l?.page??1,S=l?.limit??p?.limit??10,j=p?.startPage??1;if((p?.pageMode??"page")==="skip"){const x=p?.skipKey||"skip",N=(v-j)*S;b.set(x,String(N))}else{const x=p?.pageKey||"page";b.set(x,String(v))}const _=p?.limitKey||"limit";b.set(_,String(S));const C=b.toString()?`${g}${g.includes("?")?"&":"?"}${b.toString()}`:g,E=async()=>{if(p?.maxPage&&v>p.maxPage)throw new Error("Max page limit reached");return(await fetch(C,{method:d.method||"GET",headers:d.headers||{},signal:u.signal})).json()};try{let x=await E().catch(()=>(console.warn(`[Retry] Failed fetching ${c}, retrying...`),E()));if(d.resultPath)for(const $ of d.resultPath.split("."))x=x?.[$];const N=d.transformResponse?d.transformResponse(x):x;s($=>({...$,[c]:N}))}catch(x){x.name==="AbortError"?console.log(`[Aborted] Fetch for ${c} was cancelled.`):console.error(`Failed to fetch dynamicOptions for ${c}`,x)}}}};var ve={exports:{}},de={};/**
 * @license React
 * react-jsx-runtime.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var Ge;function Yt(){if(Ge)return de;Ge=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function s(r,n,c){var i=null;if(c!==void 0&&(i=""+c),n.key!==void 0&&(i=""+n.key),"key"in n){c={};for(var l in n)l!=="key"&&(c[l]=n[l])}else c=n;return n=c.ref,{$$typeof:t,type:r,key:i,ref:n!==void 0?n:null,props:c}}return de.Fragment=e,de.jsx=s,de.jsxs=s,de}var me={};/**
 * @license React
 * react-jsx-runtime.development.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var Xe;function Ht(){return Xe||(Xe=1,process.env.NODE_ENV!=="production"&&function(){function t(o){if(o==null)return null;if(typeof o=="function")return o.$$typeof===T?null:o.displayName||o.name||null;if(typeof o=="string")return o;switch(o){case N:return"Fragment";case x:return"Portal";case D:return"Profiler";case $:return"StrictMode";case B:return"Suspense";case q:return"SuspenseList"}if(typeof o=="object")switch(typeof o.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),o.$$typeof){case W:return(o.displayName||"Context")+".Provider";case L:return(o._context.displayName||"Context")+".Consumer";case z:var f=o.render;return o=o.displayName,o||(o=f.displayName||f.name||"",o=o!==""?"ForwardRef("+o+")":"ForwardRef"),o;case k:return f=o.displayName||null,f!==null?f:t(o.type)||"Memo";case M:f=o._payload,o=o._init;try{return t(o(f))}catch{}}return null}function e(o){return""+o}function s(o){try{e(o);var f=!1}catch{f=!0}if(f){f=console;var h=f.error,A=typeof Symbol=="function"&&Symbol.toStringTag&&o[Symbol.toStringTag]||o.constructor.name||"Object";return h.call(f,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",A),e(o)}}function r(){}function n(){if(le===0){Me=console.log,Ie=console.info,Pe=console.warn,De=console.error,Be=console.group,Le=console.groupCollapsed,ze=console.groupEnd;var o={configurable:!0,enumerable:!0,value:r,writable:!0};Object.defineProperties(console,{info:o,log:o,warn:o,error:o,group:o,groupCollapsed:o,groupEnd:o})}le++}function c(){if(le--,le===0){var o={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:re({},o,{value:Me}),info:re({},o,{value:Ie}),warn:re({},o,{value:Pe}),error:re({},o,{value:De}),group:re({},o,{value:Be}),groupCollapsed:re({},o,{value:Le}),groupEnd:re({},o,{value:ze})})}0>le&&console.error("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}function i(o){if(xe===void 0)try{throw Error()}catch(h){var f=h.stack.trim().match(/\n( *(at )?)/);xe=f&&f[1]||"",Ue=-1<h.stack.indexOf(`
    at`)?" (<anonymous>)":-1<h.stack.indexOf("@")?"@unknown:0:0":""}return`
`+xe+o+Ue}function l(o,f){if(!o||Fe)return"";var h=Ce.get(o);if(h!==void 0)return h;Fe=!0,h=Error.prepareStackTrace,Error.prepareStackTrace=void 0;var A=null;A=O.H,O.H=null,n();try{var I={DetermineComponentFrameRoot:function(){try{if(f){var ee=function(){throw Error()};if(Object.defineProperty(ee.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ee,[])}catch(G){var ge=G}Reflect.construct(o,[],ee)}else{try{ee.call()}catch(G){ge=G}o.call(ee.prototype)}}else{try{throw Error()}catch(G){ge=G}(ee=o())&&typeof ee.catch=="function"&&ee.catch(function(){})}}catch(G){if(G&&ge&&typeof G.stack=="string")return[G.stack,ge.stack]}return[null,null]}};I.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var V=Object.getOwnPropertyDescriptor(I.DetermineComponentFrameRoot,"name");V&&V.configurable&&Object.defineProperty(I.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var F=I.DetermineComponentFrameRoot(),J=F[0],ae=F[1];if(J&&ae){var P=J.split(`
`),ne=ae.split(`
`);for(F=V=0;V<P.length&&!P[V].includes("DetermineComponentFrameRoot");)V++;for(;F<ne.length&&!ne[F].includes("DetermineComponentFrameRoot");)F++;if(V===P.length||F===ne.length)for(V=P.length-1,F=ne.length-1;1<=V&&0<=F&&P[V]!==ne[F];)F--;for(;1<=V&&0<=F;V--,F--)if(P[V]!==ne[F]){if(V!==1||F!==1)do if(V--,F--,0>F||P[V]!==ne[F]){var ue=`
`+P[V].replace(" at new "," at ");return o.displayName&&ue.includes("<anonymous>")&&(ue=ue.replace("<anonymous>",o.displayName)),typeof o=="function"&&Ce.set(o,ue),ue}while(1<=V&&0<=F);break}}}finally{Fe=!1,O.H=A,c(),Error.prepareStackTrace=h}return P=(P=o?o.displayName||o.name:"")?i(P):"",typeof o=="function"&&Ce.set(o,P),P}function m(o){if(o==null)return"";if(typeof o=="function"){var f=o.prototype;return l(o,!(!f||!f.isReactComponent))}if(typeof o=="string")return i(o);switch(o){case B:return i("Suspense");case q:return i("SuspenseList")}if(typeof o=="object")switch(o.$$typeof){case z:return o=l(o.render,!1),o;case k:return m(o.type);case M:f=o._payload,o=o._init;try{return m(o(f))}catch{}}return""}function d(){var o=O.A;return o===null?null:o.getOwner()}function u(o){if(K.call(o,"key")){var f=Object.getOwnPropertyDescriptor(o,"key").get;if(f&&f.isReactWarning)return!1}return o.key!==void 0}function g(o,f){function h(){We||(We=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",f))}h.isReactWarning=!0,Object.defineProperty(o,"key",{get:h,configurable:!0})}function b(){var o=t(this.type);return Ye[o]||(Ye[o]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),o=this.props.ref,o!==void 0?o:null}function p(o,f,h,A,I,V){return h=V.ref,o={$$typeof:E,type:o,key:f,props:V,_owner:I},(h!==void 0?h:null)!==null?Object.defineProperty(o,"ref",{enumerable:!1,get:b}):Object.defineProperty(o,"ref",{enumerable:!1,value:null}),o._store={},Object.defineProperty(o._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(o,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.freeze&&(Object.freeze(o.props),Object.freeze(o)),o}function v(o,f,h,A,I,V){if(typeof o=="string"||typeof o=="function"||o===N||o===D||o===$||o===B||o===q||o===Y||typeof o=="object"&&o!==null&&(o.$$typeof===M||o.$$typeof===k||o.$$typeof===W||o.$$typeof===L||o.$$typeof===z||o.$$typeof===bt||o.getModuleId!==void 0)){var F=f.children;if(F!==void 0)if(A)if(be(F)){for(A=0;A<F.length;A++)S(F[A],o);Object.freeze&&Object.freeze(F)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else S(F,o)}else F="",(o===void 0||typeof o=="object"&&o!==null&&Object.keys(o).length===0)&&(F+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."),o===null?A="null":be(o)?A="array":o!==void 0&&o.$$typeof===E?(A="<"+(t(o.type)||"Unknown")+" />",F=" Did you accidentally export a JSX literal instead of a component?"):A=typeof o,console.error("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",A,F);if(K.call(f,"key")){F=t(o);var J=Object.keys(f).filter(function(P){return P!=="key"});A=0<J.length?"{key: someKey, "+J.join(": ..., ")+": ...}":"{key: someKey}",He[F+A]||(J=0<J.length?"{"+J.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
  let props = %s;
  <%s {...props} />
React keys must be passed directly to JSX without using spread:
  let props = %s;
  <%s key={someKey} {...props} />`,A,F,J,F),He[F+A]=!0)}if(F=null,h!==void 0&&(s(h),F=""+h),u(f)&&(s(f.key),F=""+f.key),"key"in f){h={};for(var ae in f)ae!=="key"&&(h[ae]=f[ae])}else h=f;return F&&g(h,typeof o=="function"?o.displayName||o.name||"Unknown":o),p(o,F,V,I,d(),h)}function S(o,f){if(typeof o=="object"&&o&&o.$$typeof!==xt){if(be(o))for(var h=0;h<o.length;h++){var A=o[h];j(A)&&R(A,f)}else if(j(o))o._store&&(o._store.validated=1);else if(o===null||typeof o!="object"?h=null:(h=w&&o[w]||o["@@iterator"],h=typeof h=="function"?h:null),typeof h=="function"&&h!==o.entries&&(h=h.call(o),h!==o))for(;!(o=h.next()).done;)j(o.value)&&R(o.value,f)}}function j(o){return typeof o=="object"&&o!==null&&o.$$typeof===E}function R(o,f){if(o._store&&!o._store.validated&&o.key==null&&(o._store.validated=1,f=_(f),!Ke[f])){Ke[f]=!0;var h="";o&&o._owner!=null&&o._owner!==d()&&(h=null,typeof o._owner.tag=="number"?h=t(o._owner.type):typeof o._owner.name=="string"&&(h=o._owner.name),h=" It was passed a child from "+h+".");var A=O.getCurrentStack;O.getCurrentStack=function(){var I=m(o.type);return A&&(I+=A()||""),I},console.error('Each child in a list should have a unique "key" prop.%s%s See https://react.dev/link/warning-keys for more information.',f,h),O.getCurrentStack=A}}function _(o){var f="",h=d();return h&&(h=t(h.type))&&(f=`

Check the render method of \``+h+"`."),f||(o=t(o))&&(f=`

Check the top-level render call using <`+o+">."),f}var C=a,E=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),$=Symbol.for("react.strict_mode"),D=Symbol.for("react.profiler"),L=Symbol.for("react.consumer"),W=Symbol.for("react.context"),z=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),q=Symbol.for("react.suspense_list"),k=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),Y=Symbol.for("react.offscreen"),w=Symbol.iterator,T=Symbol.for("react.client.reference"),O=C.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,K=Object.prototype.hasOwnProperty,re=Object.assign,bt=Symbol.for("react.client.reference"),be=Array.isArray,le=0,Me,Ie,Pe,De,Be,Le,ze;r.__reactDisabledLog=!0;var xe,Ue,Fe=!1,Ce=new(typeof WeakMap=="function"?WeakMap:Map),xt=Symbol.for("react.client.reference"),We,Ye={},He={},Ke={};me.Fragment=N,me.jsx=function(o,f,h,A,I){return v(o,f,h,!1,A,I)},me.jsxs=function(o,f,h,A,I){return v(o,f,h,!0,A,I)}}()),me}var Ze;function Kt(){return Ze||(Ze=1,process.env.NODE_ENV==="production"?ve.exports=Yt():ve.exports=Ht()),ve.exports}var y=Kt();const Jt={text:()=>Promise.resolve().then(()=>require("./index-BaEho775.cjs")),email:()=>Promise.resolve().then(()=>require("./index-BaEho775.cjs")),select:()=>Promise.resolve().then(()=>require("./index-DYQos4p1.cjs")),group:()=>Promise.resolve().then(()=>require("./index-C_pwQNcm.cjs"))},Gt=async t=>{if(!(typeof window>"u")&&t.length!==0)try{const e=Array.from(new Set(t)),s=[];for(const r of e){const n=Jt[r];n&&s.push(n().catch(()=>null))}await Promise.all(s)}catch(e){process.env.NODE_ENV!=="production"&&console.warn("Field preloading failed:",e)}},Z=a.createContext({forms:{},registerForm:()=>{},unregisterForm:()=>{}}),Xt=()=>{const t=a.useContext(Z);if(!t)throw new Error("useFormReg must be used within a FormRegistryProvider");return t.forms},Ae=a.createContext(null),Oe=a.createContext({}),ke=a.createContext({}),je=a.createContext(null),pe=a.createContext(void 0),ct=({children:t,formSchema:e})=>{const{registerForm:s,unregisterForm:r}=a.useContext(Z),[n,c]=a.useState(()=>Ee(e.fields)),[i,l]=a.useState({}),[m,d]=a.useState({}),[u,g]=a.useState({}),b=a.useCallback(()=>{c(Ee(e.fields)),l({}),d({}),g({})},[e.fields]),p=(w,T)=>{c(O=>({...O,[w]:T}))},{dynamicOptions:v,fetchDynamicOptions:S}=at(e),j=a.useContext(pe),R=a.useMemo(()=>new Wt,[]),{options:_}=e,C=a.useCallback(async(w,T)=>{const O=fe(w,e.fields,T);if(!(!O||!Je(O)||!O.dynamicOptions)&&ds(O,T))try{await S(w,T),ms(O,T)}catch(K){console.error(`Failed to fetch options for ${w}`,K)}},[e.fields,S,n]),E=a.useMemo(()=>Rt(e.fields),[e.fields]);if(j)return y.jsx(y.Fragment,{children:t});a.useEffect(()=>{const w=Ot(e);requestIdleCallback(()=>{Gt(w)})},[e]);const x=a.useMemo(()=>(w,T)=>{d(O=>({...O,[w]:T}))},[]),N=a.useMemo(()=>(w,T)=>{g(O=>({...O,[w]:T}))},[]),$=mt(a.useCallback((w,T)=>{const O=E[w];O?.length&&O.forEach(K=>R.notify(K)),(_?.validateFieldsOnBlur===!1||u[w])&&L(w,T),E[w]&&E[w].forEach(async K=>{await C(K,n)})},[e,n]),500),D=a.useMemo(()=>(w,T)=>{p(w,T),$(w,T)},[$]),L=a.useMemo(()=>(w,T)=>{jt(w,T,e,n,l,m,!1)},[e,m,n]),W=a.useMemo(()=>async()=>await Tt(e,n,l,m,!0),[e,m,n]),z=a.useMemo(()=>w=>fe(w,e.fields,n),[e,n]),B=a.useMemo(()=>w=>it(w,n,e),[e,n]),q=a.useMemo(()=>({setValue:D,validateField:L,validateForm:W,setTouched:x,setBlurred:N,fetchDynamicOptions:S,getFieldSchema:z,shouldShowField:B,observer:R,resetForm:b}),[D,L,W,x,N,S,z,B,R,b]),k=a.useMemo(()=>({dynamicOptions:v,formSchema:e,formOptions:_,touched:m,blurred:u}),[v,e,_,m,u]);a.useEffect(()=>{const w=async T=>{for(const O of T)Je(O)&&O.dynamicOptions?.fetchOnInit&&await C(O.fieldId,n),O.fields?.length&&await w(O.fields)};w(e.fields)},[e.fields,C]);const M=a.useRef({}),Y=a.useMemo(()=>({...M.current,values:n,actions:q,errors:i,meta:k}),[n,q,i,k]);return a.useEffect(()=>(s(e.formId,Y),()=>{r(e.formId)}),[n,i]),y.jsx(Ae.Provider,{value:q,children:y.jsx(Oe.Provider,{value:n,children:y.jsx(ke.Provider,{value:i,children:y.jsx(je.Provider,{value:k,children:y.jsx(pe.Provider,{value:{values:n,errors:i,dynamicOptions:v,formSchema:e,observer:R,formOptions:_,touched:m,blurred:u,setTouched:x,setBlurred:N,setValue:D,validateField:L,validateForm:W,shouldShowField:B,fetchDynamicOptions:S,getFieldSchema:z,resetForm:b},children:t})})})})})},Zt=({children:t})=>{const[e,s]=a.useState({}),r=a.useCallback((c,i)=>{s(l=>({...l,[c]:i}))},[]),n=a.useCallback(c=>{s(i=>{const l={...i};return delete l[c],l})},[]);return y.jsx(Z.Provider,{value:{forms:e,registerForm:r,unregisterForm:n},children:t})},ye=t=>{if(t){const e=a.useContext(Z);if(!e)throw new Error("useFormValues must be used within a FormRegistryProvider");return e?.forms?.[t]?.values||{}}return a.useContext(Oe)},lt=(t,e)=>ye(e)[t],se=t=>{if(t){const e=a.useContext(Z);if(!e)throw new Error("useFormActions must be used within a FormRegistryProvider");return e?.forms?.[t]?.actions||{}}return a.useContext(Ae)},Te=t=>{if(t){const e=a.useContext(Z);if(!e)throw new Error("useFormErrors must be used within a FormRegistryProvider");return e?.forms?.[t]?.errors||{}}return a.useContext(ke)},Ne=(t,e)=>Te(e)[t]||"",Q=t=>{if(t){const e=a.useContext(Z);if(!e)throw new Error("useFormMeta must be used within a FormRegistryProvider");return e?.forms?.[t]?.meta||{}}return a.useContext(je)},_e=t=>{if(t){const r=a.useContext(Z)?.forms[t];if(r)return{values:r.values,errors:r.errors,dynamicOptions:r.meta.dynamicOptions,formSchema:r.meta.formSchema,observer:r.actions.observer,formOptions:r.meta.formOptions,touched:r.meta.touched,blurred:r.meta.blurred,setTouched:r.actions.setTouched,setBlurred:r.actions.setBlurred,setValue:r.actions.setValue,validateField:r.actions.validateField,validateForm:r.actions.validateForm,shouldShowField:r.actions.shouldShowField,fetchDynamicOptions:r.actions.fetchDynamicOptions,getFieldSchema:r.actions.getFieldSchema,resetForm:r.actions.resetForm}}const e=a.useContext(pe);if(!e)throw new Error("useForm must be used within a FormProvider");return e},Qt=t=>Q(t).touched,es=t=>Q(t).blurred,ts=t=>Q(t).formSchema,ss=t=>Q(t).formOptions,rs=t=>Q(t).dynamicOptions,ns=t=>se(t).observer,os=(t,e)=>se(e).getFieldSchema(t),is=(t,e)=>{const s=se(e),r=s.getFieldSchema(t);return r?s.shouldShowField(r):!1},as=t=>{const e=ye(),s=Te(),{setValue:r,validateField:n,setTouched:c,observer:i}=se(),{formSchema:l,dynamicOptions:m,formOptions:d={},touched:u}=Q(),[g,b]=a.useState(!1),p=t?.fieldId,v=a.useMemo(()=>e[p]||rt[t.type],[e]),S=s[p];a.useEffect(()=>{const x=i.subscribe(p,()=>{console.log(`[${p}] Observer triggered!`)});return()=>x()},[p,i]);const j=x=>{b(!0),t.events?.onCustomFocus&&t.events.onCustomFocus(x,p,e,t,l)},R=x=>{c(t.fieldId,!0),g&&d.validateFieldsOnBlur!==!1&&n(t.fieldId,e[t.fieldId]),t.events?.onCustomBlur&&t.events.onCustomBlur(x,p,e,t,l)},_=ht({fieldId:t.fieldId,type:t.type,value:v,...t.events,onCustomBlur:R,onCustomFocus:j,onCustomUpload:t.events?.onCustomUpload,onCustomChangeItems:t.events?.onCustomChangeItems,onCustomAddItems:t.events?.onCustomAddItems,onCustomRemoveItems:t.events?.onCustomRemoveItems,onCustomSearch:t.events?.onCustomSearch}),C=pt(t.type,t,u[p],!!S);S&&(C.className=`${C.className?`${C.className} `:""}field-validation-error`);const E=t.disabled||!1;return{fieldId:p,processedProps:t,fieldParams:C,fieldValue:v,values:e,fieldErrors:S,errors:s,formSchema:l,dynamicOptions:m,eventHandlers:_,isDisable:E,observer:i,isTouched:u[t.fieldId]||!1,hasBeenFocused:g,hasDefaultStyling:!t.disableDefaultStyling,setValue:r,validateField:n}},ut=()=>{const{values:t,errors:e,formSchema:s,formOptions:r,touched:n,blurred:c,setBlurred:i,setValue:l,getFieldSchema:m,setTouched:d,validateField:u}=_e();return{formOptions:r,touched:n,blurred:c,setValue:l,handleCustomEvent:(b,p,v,S)=>{if(b){const j=S??t[v],R=m(v);b(p,v,{...t,[v]:j},R,s,e)}},setTouched:d,setBlurred:i,validateField:u}},dt=t=>{const e=ye(),{formSchema:s}=Q(),r=he.getInstance();return a.useMemo(()=>r.process(t,e,s),[t,e,s])};function mt(t,e){const s=a.useRef(null),r=a.useRef(t);return a.useEffect(()=>{r.current=t},[t]),a.useEffect(()=>()=>{s.current&&clearTimeout(s.current)},[]),a.useCallback((...n)=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{r.current(...n)},e)},[e])}const ft=t=>{const e=Ne(t.fieldId),{shouldShowField:s}=se();let r;r=dt(t);const n=s(r);return{processedProps:r,fieldErrors:e,isVisible:n}},cs=t=>{const e=lt(t.fieldId),s=Ne(t.fieldId),{validateField:r,setTouched:n}=se(),{touched:c,blurred:i,formSchema:l,formOptions:m}=Q(),d=_e(),[u,g]=a.useState(!1),b=a.useMemo(()=>e??rt[t.type],[e,t.type]),p=a.useCallback(R=>{n(t.fieldId,!0),u&&m?.validateFieldsOnBlur!==!1&&r(t.fieldId,b),t.events?.onCustomBlur?.(R,t.fieldId,d.values,t,l)},[n,t,u,m?.validateFieldsOnBlur,r,b,d.values,l]),v=a.useCallback(R=>{g(!0),t.events?.onCustomFocus?.(R,t.fieldId,d.values,t,l)},[t,d.values,l]),S=ht({fieldId:t.fieldId,type:t.type,value:b,...t.events,onCustomBlur:p,onCustomFocus:v,onCustomUpload:t.events?.onCustomUpload,onCustomChangeItems:t.events?.onCustomChangeItems,onCustomAddItems:t.events?.onCustomAddItems,onCustomRemoveItems:t.events?.onCustomRemoveItems,onCustomSearch:t.events?.onCustomSearch}),j=a.useMemo(()=>{const R=pt(t.type,t,c[t.fieldId],!!s);return s&&(R.className=`${R.className||""} field-validation-error`),R},[t,c,s]);return a.useMemo(()=>({value:b,error:s,touched:c[t.fieldId],blurred:i[t.fieldId],props:t,fieldParams:j,eventHandlers:S,formContext:d}),[b,s,c,i,t,j,S,d])},ht=({fieldId:t,value:e,type:s,onCustomChange:r,onCustomClick:n,onCustomBlur:c,onCustomFocus:i,onCustomKeyDown:l,onCustomKeyUp:m,onCustomMouseDown:d,onCustomMouseEnter:u,onCustomMouseLeave:g,onCustomContextMenu:b,onCustomUpload:p,onCustomRemove:v,onCustomAddItems:S,onCustomChangeItems:j,onCustomRemoveItems:R,onCustomSearch:_})=>{const{setBlurred:C,setValue:E,handleCustomEvent:x,setTouched:N}=ut(),$=k=>{N(t,!0),x(i,k,t)},D=k=>{C(t,!0),c&&x(c,k,t)},L=k=>{const M=s==="number"?+k.target.value:k.target.value;let Y=M;if(tt.includes(s)){const w=k.target.checked,T=e||[];Y=w?[...T,M]:T.filter(K=>K!==M)}E(t,Y),x(r,k,t,Y)},W=k=>{const M=Array.from((k instanceof FileList,k));p&&p(M,t),E(t,M)},z=k=>{v&&v(k,t)},B=(k,M,Y)=>{_&&_(k||[],M||[],t,Y||"")},q=k=>M=>x(k,M,t,e);return{htmlHandlers:{onChange:L,onClick:q(n),onBlur:D,onFocus:$,onKeyDown:q(l),onKeyUp:q(m),onMouseDown:q(d),onMouseEnter:q(u),onMouseLeave:q(g),onContextMenu:q(b)},customHandlers:{onUpload:p?W:void 0,onRemove:v?z:void 0,onAddItems:q(S),onRemoveItems:q(R),onChangeItems:q(j),onSearch:_?B:void 0}}},ls=["required","options","labelClassName"],H=(t="input",e="text")=>({"data-testid":`${t}-${e}-field`,excludedProps:[...ls],htmlTagName:t}),Qe={text:{...H("input","text")},email:{...H("input","email")},password:{...H("input","password")},number:{...H("input","number")},tel:{...H("input","tel")},url:{...H("input","url")},search:{...H("input","search")},radio:{...H("input","radio")},checkbox:{...H("input","checkbox")},select:{...H("select","select")},file:{...H("input","file")}},pt=(t,e,s,r)=>{const n=Qe[t]||Qe.text;return n.htmlTagName?{...At(n.htmlTagName,e,n.excludedProps),id:e.fieldId||e.id||"","data-testid":n["data-testid"],"data-touched":s,"data-error":r}:{}};class us{static process(e,s){try{const r=st(e)||e;return this.isComputedValue(r)?r.fn(s):r}catch{return this.isComputedValue(e)?e.fn(s):e}}static isComputedValue(e){return e&&typeof e=="object"&&"fn"in e}static processFieldProps(e,s){const r={};for(const[n,c]of Object.entries(e))this.isProcessableProperty(n)?r[n]=this.process(c,s):r[n]=c;return r}static isProcessableProperty(e){return["label","required","disabled","visibility","className","options","placeholder","validation","requiredMessage","content"].includes(e)}}const Ee=(t,e={})=>(t.forEach(s=>{s._defaultValue!==void 0&&e[s.fieldId]===void 0&&(e[s.fieldId]=s._defaultValue),s.fields&&Ee(s.fields,e)}),e),yt=t=>t.dynamicOptions?(t.dynamicOptions._cache||(t.dynamicOptions._cache={}),t.dynamicOptions._cache):{},ds=(t,e)=>{const s=yt(t),r=t.dynamicOptions?.dependsOn,n=t.dynamicOptions?.cacheTime||3e4;return t.dynamicOptions?.forceRefresh?(t.dynamicOptions.forceRefresh=!1,!0):!!(!s.lastFetchTime||Date.now()-s.lastFetchTime>n||r&&(typeof r=="string"?[r]:r).some(l=>e[l]!==s.lastValues?.[l]))},ms=(t,e)=>{const s=yt(t),r=t.dynamicOptions?.dependsOn;if(s.lastFetchTime=Date.now(),r){const n=typeof r=="string"?[r]:r;s.lastValues=n.reduce((c,i)=>(c[i]=e[i],c),{})}},fs="_container_w0h6v_2",hs="_label_w0h6v_7",ps="_errorPlaceholder_w0h6v_12",ys="_errorMessage_w0h6v_13",gs="_description_w0h6v_26",vs="_requiredIndicator_w0h6v_33",ce={container:fs,label:hs,errorPlaceholder:ps,errorMessage:ys,description:gs,requiredIndicator:vs},Ve=a.memo(({id:t,label:e,required:s,error:r,className:n="",children:c,styles:i={},labelClassName:l="",labelStyles:m={},type:d,description:u,errorClassName:g="",errorStyles:b={},descriptionClassName:p="",descriptionStyles:v={},errorComponent:S,descriptionComponent:j,ariaDescribedby:R,ariaLabel:_,ariaDisabled:C,ariaInvalid:E,ariaRequired:x,ariaHidden:N,ariaLive:$,role:D,ariaLabelledby:L})=>{const W=a.useMemo(()=>d!=="radio"&&d!=="checkbox",[d]),z=a.useMemo(()=>`${t}-description`,[t]),B=a.useMemo(()=>`${t}-error`,[t]),q=a.useMemo(()=>({"aria-describedby":R,"aria-errormessage":r?B:void 0,"aria-invalid":E!==void 0?E:!!r,"aria-required":x!==void 0?x:s,"aria-disabled":C,"aria-label":_,"aria-hidden":N,"aria-live":$,"aria-labelledby":L}),[R,r,B,E,x,s,C,_,N,$,L]),k=a.useMemo(()=>r?S?y.jsx(S,{error:r}):y.jsx("span",{id:B,role:"alert",className:`${ce.errorMessage} ${g}`,style:b,children:r}):y.jsx("div",{className:ce.errorPlaceholder,"aria-hidden":"true"}),[r,S,B,g,b]),M=a.useMemo(()=>u?j?y.jsx(j,{description:u}):y.jsx("span",{id:z,className:`${ce.description} ${p}`,style:v,children:u}):null,[u,j,z,p,v]),Y=a.useMemo(()=>!e||d==="group"?null:y.jsxs("label",{...W?{htmlFor:t}:{},className:`${ce.label} ${l}`,style:m,children:[y.jsx("span",{children:e}),s&&y.jsx("span",{className:ce.requiredIndicator,"aria-hidden":"true",children:"*"})]}),[e,d,W,t,l,m,s]),w=a.useMemo(()=>a.isValidElement(c)?a.cloneElement(c,q):c,[c,q]),T=a.useMemo(()=>D||(d==="group"?"group":void 0),[D,d]);return y.jsxs("div",{className:`${ce.container} ${n}`,style:i,role:T,children:[Y,w,M,k]})});Ve.displayName="FieldWrapper";const bs=a.createContext({}),gt=!0;function xs({baseColor:t,highlightColor:e,width:s,height:r,borderRadius:n,circle:c,direction:i,duration:l,enableAnimation:m=gt,customHighlightBackground:d}){const u={};return i==="rtl"&&(u["--animation-direction"]="reverse"),typeof l=="number"&&(u["--animation-duration"]=`${l}s`),m||(u["--pseudo-element-display"]="none"),(typeof s=="string"||typeof s=="number")&&(u.width=s),(typeof r=="string"||typeof r=="number")&&(u.height=r),(typeof n=="string"||typeof n=="number")&&(u.borderRadius=n),c&&(u.borderRadius="50%"),typeof t<"u"&&(u["--base-color"]=t),typeof e<"u"&&(u["--highlight-color"]=e),typeof d=="string"&&(u["--custom-highlight-background"]=d),u}function te({count:t=1,wrapper:e,className:s,containerClassName:r,containerTestId:n,circle:c=!1,style:i,...l}){var m,d,u;const g=a.useContext(bs),b={...l};for(const[C,E]of Object.entries(l))typeof E>"u"&&delete b[C];const p={...g,...b,circle:c},v={...i,...xs(p)};let S="react-loading-skeleton";s&&(S+=` ${s}`);const j=(m=p.inline)!==null&&m!==void 0?m:!1,R=[],_=Math.ceil(t);for(let C=0;C<_;C++){let E=v;if(_>t&&C===_-1){const N=(d=E.width)!==null&&d!==void 0?d:"100%",$=t%1,D=typeof N=="number"?N*$:`calc(${N} * ${$})`;E={...E,width:D}}const x=a.createElement("span",{className:S,style:E,key:C},"‌");j?R.push(x):R.push(a.createElement(a.Fragment,{key:C},x,a.createElement("br",null)))}return a.createElement("span",{className:r,"data-testid":n,"aria-live":"polite","aria-busy":(u=p.enableAnimation)!==null&&u!==void 0?u:gt},e?R.map((C,E)=>a.createElement(e,{key:E},C)):R)}const Fs=({type:t="text",itemsCount:e=1,layout:s="column",height:r,width:n,baseOpacity:c=.2,containerClassName:i=""})=>{const l=()=>t==="checkbox"||t==="radio"?y.jsx("div",{className:`skeleton-options-container ${s}`,children:Array.from({length:e}).map((m,d)=>y.jsxs("div",{className:"skeleton-option-item",children:[y.jsx(te,{className:`skeleton-option-control ${t==="radio"?"radio":""}`,height:r||16,width:n||16,style:{opacity:c+.3}}),y.jsx(te,{className:"skeleton-option-label",height:10,width:80,style:{opacity:c}})]},d))}):t==="grid"?y.jsx("div",{className:"skeleton-grid-container",children:Array.from({length:e}).map((m,d)=>y.jsxs("div",{className:"skeleton-grid-item",children:[y.jsx(te,{className:"skeleton-grid-image",height:r||120,width:n||"100%",style:{opacity:c+.3}}),y.jsx(te,{className:"skeleton-grid-title",height:16,width:"80%",style:{opacity:c}}),y.jsx(te,{className:"skeleton-grid-subtitle",height:12,width:"60%",style:{opacity:c}})]},d))}):y.jsxs(y.Fragment,{children:[y.jsx(te,{className:"skeleton-label",height:10,width:"25%",style:{opacity:c}}),y.jsx(te,{className:`skeleton-field ${t==="textarea"?"skeleton-textarea":""}`,height:r||(t==="textarea"?100:40),width:n||"100%",style:{opacity:c+.3}}),y.jsx(te,{className:"skeleton-description",height:6,width:"40%",style:{opacity:c-.1}})]});return y.jsx("div",{className:`skeleton-container ${i}`,children:l()})},et=a.memo(Fs),qe={group:a.lazy(()=>Promise.resolve().then(()=>require("./index-C_pwQNcm.cjs"))),text:a.lazy(()=>Promise.resolve().then(()=>require("./index-BaEho775.cjs"))),number:a.lazy(()=>Promise.resolve().then(()=>require("./index-BaEho775.cjs"))),email:a.lazy(()=>Promise.resolve().then(()=>require("./index-BaEho775.cjs"))),tel:a.lazy(()=>Promise.resolve().then(()=>require("./index-BaEho775.cjs"))),url:a.lazy(()=>Promise.resolve().then(()=>require("./index-BaEho775.cjs"))),password:a.lazy(()=>Promise.resolve().then(()=>require("./index-BaEho775.cjs"))),search:a.lazy(()=>Promise.resolve().then(()=>require("./index-BaEho775.cjs"))),date:a.lazy(()=>Promise.resolve().then(()=>require("./index-CajAs3Es.cjs"))),select:a.lazy(()=>Promise.resolve().then(()=>require("./index-DYQos4p1.cjs"))),radio:a.lazy(()=>Promise.resolve().then(()=>require("./index-BL8EGhnt.cjs"))),checkbox:a.lazy(()=>Promise.resolve().then(()=>require("./index-2mnkMBh2.cjs"))),gridview:a.lazy(()=>Promise.resolve().then(()=>require("./index-CwlpYfEE.cjs"))),container:a.lazy(()=>Promise.resolve().then(()=>require("./index-DIFMy2mg.cjs"))),textarea:a.lazy(()=>Promise.resolve().then(()=>require("./index-BCrrIKRf.cjs"))),spacer:a.lazy(()=>Promise.resolve().then(()=>require("./index-Cp9nS39i.cjs"))),file:a.lazy(()=>Promise.resolve().then(()=>require("./index-5kwDIPMI.cjs"))),content:a.lazy(()=>Promise.resolve().then(()=>require("./index-9uUlxgtT.cjs"))),multiSelect:a.lazy(()=>Promise.resolve().then(()=>require("./index-DGP5vskW.cjs")))},Cs=(t,e)=>{qe[t]=e},vt=a.forwardRef((t,e)=>{const s=qe[t.type];return y.jsx(s,{...t,ref:e})});vt.displayName="FieldComponentWithRef";const $e=a.memo(({showSkeletonLoading:t=!0,skeleton:e,onLoadComplete:s,...r})=>{const{processedProps:n,fieldErrors:c,isVisible:i}=ft(r),l=a.useRef(!1),m=qe[r.type],d=a.useCallback(()=>{s&&!l.current&&(s(n.fieldId),l.current=!0)},[s,n.fieldId]);a.useEffect(()=>()=>{l.current=!1},[]),a.useEffect(()=>{(!m||!i)&&s&&!l.current&&(s(n.fieldId),l.current=!0)},[m,i,s,n.fieldId]);const u=a.useMemo(()=>{if(!t)return null;if(e)return e;if(r.type==="checkbox"||r.type==="radio"){const g=r;return y.jsx(et,{type:r.type,itemsCount:g?.options?.length||1,layout:g?.layout||"column"})}return y.jsx(et,{type:r.type})},[t,e,r.type,r?.options?.length,r?.layout]);return!m||!i?null:y.jsx(a.Suspense,{fallback:u,children:y.jsx(Ve,{id:n.fieldId,label:n.label,required:n.required,error:c,className:n.containerClassName,styles:n.containerStyles,labelClassName:n.labelClassName,labelStyles:n.labelStyles,type:n.type,description:n.description,ariaDescribedby:n.ariaDescribedby||n.description,ariaDisabled:n.ariaDisabled||n.disabled,ariaLabel:n.ariaLabel||n.label,errorClassName:n.errorClassName,errorStyles:n.errorStyles,descriptionClassName:n.descriptionClassName,descriptionStyles:n.descriptionStyles,errorComponent:n.errorComponent,descriptionComponent:n.descriptionComponent,children:y.jsx(vt,{...n,ref:d})})})},(t,e)=>t.fieldId===e.fieldId&&t.type===e.type&&t.label===e.label&&t.required===e.required&&t.disabled===e.disabled&&t.showSkeletonLoading===e.showSkeletonLoading&&t.skeleton===e.skeleton);$e.displayName="DynamicFormField";const ws=a.memo(()=>y.jsx("div",{className:"form-loading-spinner",children:y.jsx("div",{className:"spinner"})})),Se=a.memo(({formData:t,onSubmit:e,isLoading:s})=>{const r=ye(),{validateForm:n}=se(),[c,i]=a.useState(new Set),l=a.useRef(t);l.current=t;const{submit:m,loading:d,skeleton:u}=t.options||{},g=m?.component,b=d?.component,p=a.useMemo(()=>c.size>=t.fields.filter(C=>!C.visibility).length,[c,t.fields]),v=a.useCallback(C=>{i(E=>{if(E.has(C))return E;const x=new Set(E);return x.add(C),x})},[]),S=a.useCallback(async C=>{C.preventDefault();const E=await n(l.current);e?.(r,E)},[e,n,r]),j=a.useMemo(()=>d?.visible===!1||p?null:y.jsx("div",{className:"form-loading-overlay",children:b?a.isValidElement(b)?b:y.jsx(b,{}):y.jsx(ws,{})}),[d?.visible,p,b]),R=a.useMemo(()=>m?.visible===!1||!p?null:y.jsx("div",{className:"form-submit-container",children:g??y.jsx("div",{className:`submit-button-container ${m?.containerClassName||""}`,style:m?.containerStyles,children:y.jsx("button",{type:"submit",className:"submit-button",disabled:s,"aria-disabled":s,children:s?"Submitting...":m?.text||"Submit"})})}),[m,p,s,g]),_=a.useMemo(()=>t.fields.map(C=>y.jsx($e,{...C,skeleton:u?.component,showSkeletonLoading:u?.visible,onLoadComplete:v},C.fieldId)),[t.fields,u,v]);return y.jsxs("form",{onSubmit:S,role:"form","aria-busy":s||!p,"aria-live":"polite",className:`form-content ${p?"loaded":""}`,children:[!p&&y.jsx("div",{role:"status","aria-live":"polite",className:"sr-only",children:"Loading form fields..."}),s&&y.jsx("div",{role:"status","aria-live":"assertive",className:"sr-only",children:"Form is submitting..."}),j,y.jsx("div",{style:{opacity:p?1:0},children:_}),R]})});Se.displayName="FormContent";const Es=({formId:t,formData:e,onSubmit:s,isLoading:r=!1,customProvider:n})=>{const c=a.useContext(pe),i=n||ct;return c?y.jsx(Se,{formId:t,formData:e,onSubmit:s,isLoading:r}):y.jsx(i,{formSchema:e,formId:t,children:y.jsx(Se,{formId:t,formData:e,onSubmit:s,isLoading:r})})};exports.DynamicForm=Es;exports.DynamicFormField=$e;exports.FieldWrapper=Ve;exports.FormActionsContext=Ae;exports.FormContext=pe;exports.FormErrorsContext=ke;exports.FormMetaContext=je;exports.FormProvider=ct;exports.FormRegistryContext=Z;exports.FormRegistryProvider=Zt;exports.FormValuesContext=Oe;exports.jsxRuntimeExports=y;exports.registerField=Cs;exports.useDebouncedCallback=mt;exports.useDynamicField=ft;exports.useDynamicOptions=at;exports.useField=as;exports.useFieldEvents=ut;exports.useFieldProcessor=dt;exports.useForm=_e;exports.useFormActions=se;exports.useFormBlurred=es;exports.useFormDynamicOptions=rs;exports.useFormError=Ne;exports.useFormErrors=Te;exports.useFormFieldSchema=os;exports.useFormMeta=Q;exports.useFormObserver=ns;exports.useFormOptions=ss;exports.useFormReg=Xt;exports.useFormSchema=ts;exports.useFormTouched=Qt;exports.useFormValue=lt;exports.useFormValues=ye;exports.useOptimizedField=cs;exports.useShouldShowField=is;exports.validationEngine=Re;