reactaform 1.1.1 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.md +10 -15
  2. package/dist/reactaform.cjs.js +6 -7
  3. package/dist/reactaform.es.js +1909 -2504
  4. package/package.json +83 -54
  5. package/dist/common-BD9zx3GT.js +0 -1
  6. package/dist/common-BxyjIoe1.js +0 -1
  7. package/dist/common-COyDhNL-.js +0 -1
  8. package/dist/common-hRFTL4KF.js +0 -1
  9. package/dist/components/LayoutComponents.d.ts +0 -76
  10. package/dist/components/PopupOptionMenu.d.ts +0 -15
  11. package/dist/components/ReactaForm.d.ts +0 -4
  12. package/dist/components/ReactaFormProvider.d.ts +0 -3
  13. package/dist/components/ReactaFormRenderer.d.ts +0 -13
  14. package/dist/components/Tooltip.d.ts +0 -8
  15. package/dist/components/VirtualizedFieldList.d.ts +0 -36
  16. package/dist/components/fields/CheckboxInput.d.ts +0 -9
  17. package/dist/components/fields/ColorInput.d.ts +0 -17
  18. package/dist/components/fields/DateInput.d.ts +0 -11
  19. package/dist/components/fields/DropdownInput.d.ts +0 -13
  20. package/dist/components/fields/EmailInput.d.ts +0 -5
  21. package/dist/components/fields/FileInput.d.ts +0 -5
  22. package/dist/components/fields/FloatArrayInput.d.ts +0 -5
  23. package/dist/components/fields/FloatInput.d.ts +0 -24
  24. package/dist/components/fields/ImageDisplay.d.ts +0 -17
  25. package/dist/components/fields/IntegerArrayInput.d.ts +0 -23
  26. package/dist/components/fields/IntegerInput.d.ts +0 -28
  27. package/dist/components/fields/MultiSelection.d.ts +0 -9
  28. package/dist/components/fields/MultilineTextInput.d.ts +0 -6
  29. package/dist/components/fields/NumericStepperInput.d.ts +0 -6
  30. package/dist/components/fields/PhoneInput.d.ts +0 -6
  31. package/dist/components/fields/RadioInput.d.ts +0 -13
  32. package/dist/components/fields/RatingInput.d.ts +0 -6
  33. package/dist/components/fields/Separator.d.ts +0 -20
  34. package/dist/components/fields/SliderInput.d.ts +0 -22
  35. package/dist/components/fields/SpinInput.d.ts +0 -6
  36. package/dist/components/fields/SwitchInput.d.ts +0 -13
  37. package/dist/components/fields/TextInput.d.ts +0 -6
  38. package/dist/components/fields/TimeInput.d.ts +0 -6
  39. package/dist/components/fields/UnitValueInput.d.ts +0 -5
  40. package/dist/components/fields/UrlInput.d.ts +0 -21
  41. package/dist/components/renderFields.d.ts +0 -4
  42. package/dist/core/fieldVisibility.d.ts +0 -25
  43. package/dist/core/index.d.ts +0 -19
  44. package/dist/core/reactaFormModel.d.ts +0 -38
  45. package/dist/core/reactaFormTypes.d.ts +0 -137
  46. package/dist/core/registries/baseRegistry.d.ts +0 -15
  47. package/dist/core/registries/componentRegistry.d.ts +0 -10
  48. package/dist/core/registries/index.d.ts +0 -7
  49. package/dist/core/registries/submissionHandlerRegistry.d.ts +0 -6
  50. package/dist/core/registries/validationHandlerRegistry.d.ts +0 -16
  51. package/dist/core/submitForm.d.ts +0 -12
  52. package/dist/core/validation.d.ts +0 -10
  53. package/dist/hooks/useDebouncedCallback.d.ts +0 -25
  54. package/dist/hooks/useReactaFormContext.d.ts +0 -4
  55. package/dist/utils/cssClasses.d.ts +0 -14
  56. package/dist/utils/definitionSerializers.d.ts +0 -62
  57. package/dist/utils/groupingHelpers.d.ts +0 -24
  58. package/dist/utils/index.d.ts +0 -11
  59. package/dist/utils/translationCache.d.ts +0 -43
  60. package/dist/utils/unitValueMapper.d.ts +0 -8
  61. /package/dist/{common-BQcVe8MY.mjs → common-BQcVe8MY.js} +0 -0
  62. /package/dist/{common-BnnwzTl2.mjs → common-BnnwzTl2.js} +0 -0
  63. /package/dist/{common-Bzz0clAC.mjs → common-Bzz0clAC.js} +0 -0
  64. /package/dist/{common-DLqVHgfX.mjs → common-DLqVHgfX.js} +0 -0
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),Fe=require("react-dom"),Ot=`/* ReactaForm CSS Custom Properties (CSS Variables) */\r
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),Ae=require("react-dom"),Er=require("react-window"),jr=`/* ReactaForm CSS Custom Properties (CSS Variables) */\r
2
2
  \r
3
3
  /* Default Light Theme */\r
4
4
  :root {\r
@@ -284,15 +284,14 @@
284
284
  \r
285
285
  \r
286
286
  }\r
287
- `;var ye={exports:{}},me={};var Be;function Mt(){if(Be)return me;Be=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(o,n,a){var i=null;if(a!==void 0&&(i=""+a),n.key!==void 0&&(i=""+n.key),"key"in n){a={};for(var c in n)c!=="key"&&(a[c]=n[c])}else a=n;return n=a.ref,{$$typeof:e,type:o,key:i,ref:n!==void 0?n:null,props:a}}return me.Fragment=t,me.jsx=r,me.jsxs=r,me}var de={};var He;function At(){return He||(He=1,process.env.NODE_ENV!=="production"&&(function(){function e(y){if(y==null)return null;if(typeof y=="function")return y.$$typeof===M?null:y.displayName||y.name||null;if(typeof y=="string")return y;switch(y){case x:return"Fragment";case C:return"Profiler";case v:return"StrictMode";case R:return"Suspense";case j:return"SuspenseList";case I:return"Activity"}if(typeof y=="object")switch(typeof y.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),y.$$typeof){case g:return"Portal";case O:return y.displayName||"Context";case k:return(y._context.displayName||"Context")+".Consumer";case w:var N=y.render;return y=y.displayName,y||(y=N.displayName||N.name||"",y=y!==""?"ForwardRef("+y+")":"ForwardRef"),y;case S:return N=y.displayName||null,N!==null?N:e(y.type)||"Memo";case E:N=y._payload,y=y._init;try{return e(y(N))}catch{}}return null}function t(y){return""+y}function r(y){try{t(y);var N=!1}catch{N=!0}if(N){N=console;var P=N.error,q=typeof Symbol=="function"&&Symbol.toStringTag&&y[Symbol.toStringTag]||y.constructor.name||"Object";return P.call(N,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",q),t(y)}}function o(y){if(y===x)return"<>";if(typeof y=="object"&&y!==null&&y.$$typeof===E)return"<...>";try{var N=e(y);return N?"<"+N+">":"<...>"}catch{return"<...>"}}function n(){var y=V.A;return y===null?null:y.getOwner()}function a(){return Error("react-stack-top-frame")}function i(y){if($.call(y,"key")){var N=Object.getOwnPropertyDescriptor(y,"key").get;if(N&&N.isReactWarning)return!1}return y.key!==void 0}function c(y,N){function P(){te||(te=!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)",N))}P.isReactWarning=!0,Object.defineProperty(y,"key",{get:P,configurable:!0})}function f(){var y=e(this.type);return K[y]||(K[y]=!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.")),y=this.props.ref,y!==void 0?y:null}function m(y,N,P,q,Z,ee){var H=P.ref;return y={$$typeof:h,type:y,key:N,props:P,_owner:q},(H!==void 0?H:null)!==null?Object.defineProperty(y,"ref",{enumerable:!1,get:f}):Object.defineProperty(y,"ref",{enumerable:!1,value:null}),y._store={},Object.defineProperty(y._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(y,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(y,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:Z}),Object.defineProperty(y,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:ee}),Object.freeze&&(Object.freeze(y.props),Object.freeze(y)),y}function l(y,N,P,q,Z,ee){var H=N.children;if(H!==void 0)if(q)if(L(H)){for(q=0;q<H.length;q++)d(H[q]);Object.freeze&&Object.freeze(H)}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 d(H);if($.call(N,"key")){H=e(y);var Q=Object.keys(N).filter(function(ie){return ie!=="key"});q=0<Q.length?"{key: someKey, "+Q.join(": ..., ")+": ...}":"{key: someKey}",F[H+q]||(Q=0<Q.length?"{"+Q.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
287
+ `;var he={exports:{}},ue={};var _e;function kr(){if(_e)return ue;_e=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function n(o,t,a){var l=null;if(a!==void 0&&(l=""+a),t.key!==void 0&&(l=""+t.key),"key"in t){a={};for(var c in t)c!=="key"&&(a[c]=t[c])}else a=t;return t=a.ref,{$$typeof:e,type:o,key:l,ref:t!==void 0?t:null,props:a}}return ue.Fragment=r,ue.jsx=n,ue.jsxs=n,ue}var fe={};var qe;function Nr(){return qe||(qe=1,process.env.NODE_ENV!=="production"&&(function(){function e(y){if(y==null)return null;if(typeof y=="function")return y.$$typeof===$?null:y.displayName||y.name||null;if(typeof y=="string")return y;switch(y){case x:return"Fragment";case C:return"Profiler";case v:return"StrictMode";case R:return"Suspense";case j:return"SuspenseList";case O:return"Activity"}if(typeof y=="object")switch(typeof y.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),y.$$typeof){case g:return"Portal";case I:return y.displayName||"Context";case N:return(y._context.displayName||"Context")+".Consumer";case S:var E=y.render;return y=y.displayName,y||(y=E.displayName||E.name||"",y=y!==""?"ForwardRef("+y+")":"ForwardRef"),y;case w:return E=y.displayName||null,E!==null?E:e(y.type)||"Memo";case k:E=y._payload,y=y._init;try{return e(y(E))}catch{}}return null}function r(y){return""+y}function n(y){try{r(y);var E=!1}catch{E=!0}if(E){E=console;var L=E.error,T=typeof Symbol=="function"&&Symbol.toStringTag&&y[Symbol.toStringTag]||y.constructor.name||"Object";return L.call(E,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",T),r(y)}}function o(y){if(y===x)return"<>";if(typeof y=="object"&&y!==null&&y.$$typeof===k)return"<...>";try{var E=e(y);return E?"<"+E+">":"<...>"}catch{return"<...>"}}function t(){var y=_.A;return y===null?null:y.getOwner()}function a(){return Error("react-stack-top-frame")}function l(y){if(U.call(y,"key")){var E=Object.getOwnPropertyDescriptor(y,"key").get;if(E&&E.isReactWarning)return!1}return y.key!==void 0}function c(y,E){function L(){Q||(Q=!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)",E))}L.isReactWarning=!0,Object.defineProperty(y,"key",{get:L,configurable:!0})}function m(){var y=e(this.type);return K[y]||(K[y]=!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.")),y=this.props.ref,y!==void 0?y:null}function d(y,E,L,T,J,re){var P=L.ref;return y={$$typeof:b,type:y,key:E,props:L,_owner:T},(P!==void 0?P:null)!==null?Object.defineProperty(y,"ref",{enumerable:!1,get:m}):Object.defineProperty(y,"ref",{enumerable:!1,value:null}),y._store={},Object.defineProperty(y._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(y,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(y,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:J}),Object.defineProperty(y,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:re}),Object.freeze&&(Object.freeze(y.props),Object.freeze(y)),y}function u(y,E,L,T,J,re){var P=E.children;if(P!==void 0)if(T)if(G(P)){for(T=0;T<P.length;T++)p(P[T]);Object.freeze&&Object.freeze(P)}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 p(P);if(U.call(E,"key")){P=e(y);var X=Object.keys(E).filter(function(pe){return pe!=="key"});T=0<X.length?"{key: someKey, "+X.join(": ..., ")+": ...}":"{key: someKey}",A[P+T]||(X=0<X.length?"{"+X.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
288
288
  let props = %s;
289
289
  <%s {...props} />
290
290
  React keys must be passed directly to JSX without using spread:
291
291
  let props = %s;
292
- <%s key={someKey} {...props} />`,q,H,Q,H),F[H+q]=!0)}if(H=null,P!==void 0&&(r(P),H=""+P),i(N)&&(r(N.key),H=""+N.key),"key"in N){P={};for(var le in N)le!=="key"&&(P[le]=N[le])}else P=N;return H&&c(P,typeof y=="function"?y.displayName||y.name||"Unknown":y),m(y,H,P,n(),Z,ee)}function d(y){u(y)?y._store&&(y._store.validated=1):typeof y=="object"&&y!==null&&y.$$typeof===E&&(y._payload.status==="fulfilled"?u(y._payload.value)&&y._payload.value._store&&(y._payload.value._store.validated=1):y._store&&(y._store.validated=1))}function u(y){return typeof y=="object"&&y!==null&&y.$$typeof===h}var p=s,h=Symbol.for("react.transitional.element"),g=Symbol.for("react.portal"),x=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),k=Symbol.for("react.consumer"),O=Symbol.for("react.context"),w=Symbol.for("react.forward_ref"),R=Symbol.for("react.suspense"),j=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),E=Symbol.for("react.lazy"),I=Symbol.for("react.activity"),M=Symbol.for("react.client.reference"),V=p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,$=Object.prototype.hasOwnProperty,L=Array.isArray,Y=console.createTask?console.createTask:function(){return null};p={react_stack_bottom_frame:function(y){return y()}};var te,K={},se=p.react_stack_bottom_frame.bind(p,a)(),D=Y(o(a)),F={};de.Fragment=x,de.jsx=function(y,N,P){var q=1e4>V.recentlyCreatedOwnerStacks++;return l(y,N,P,!1,q?Error("react-stack-top-frame"):se,q?Y(o(y)):D)},de.jsxs=function(y,N,P){var q=1e4>V.recentlyCreatedOwnerStacks++;return l(y,N,P,!0,q?Error("react-stack-top-frame"):se,q?Y(o(y)):D)}})()),de}var We;function Ft(){return We||(We=1,process.env.NODE_ENV==="production"?ye.exports=Mt():ye.exports=At()),ye.exports}var b=Ft();const tt=s.createContext(void 0),T=()=>{const e=s.useContext(tt);if(!e)throw new Error("❌ useReactaFormContext must be used within a <ReactaFormProvider>");return e};class we{map={};register(t,r){this.map[t]=r}get(t){return this.map[t]}has(t){return t in this.map}list(){return Object.keys(this.map)}entries(){return Object.entries(this.map)}values(){return Object.values(this.map)}size(){return Object.keys(this.map).length}unregister(t){return t in this.map?(delete this.map[t],!0):!1}clear(){this.map={}}registerAll(t){Array.isArray(t)?t.forEach(([r,o])=>this.register(r,o)):Object.entries(t).forEach(([r,o])=>this.register(r,o))}getOrDefault(t,r){return this.get(t)??r}}function rt(e,t=300,r){const o=s.useRef(void 0),n=s.useRef(e),a=s.useRef(null),i=s.useRef(!1);s.useEffect(()=>{n.current=e},[e]),s.useEffect(()=>()=>{o.current!==void 0&&(window.clearTimeout(o.current),o.current=void 0)},[]);const c=s.useCallback(()=>{o.current!==void 0&&(window.clearTimeout(o.current),o.current=void 0),a.current=null,i.current=!1},[]),f=s.useCallback(()=>{if(o.current!==void 0&&(window.clearTimeout(o.current),o.current=void 0),a.current)try{n.current(...a.current)}finally{a.current=null,i.current=!1}},[]);return{callback:s.useCallback((...l)=>{if(r?.leading===!0&&!i.current){i.current=!0,n.current(...l),window.clearTimeout(o.current),o.current=window.setTimeout(()=>{i.current=!1,o.current=void 0},t);return}a.current=l,window.clearTimeout(o.current),o.current=window.setTimeout(()=>{o.current=void 0,a.current&&(n.current(...a.current),a.current=null,i.current=!1)},t)},[t,r?.leading]),cancel:c,flush:f}}const A={field:"reactaform-field",label:"reactaform-label",input:"reactaform-input",textInput:"reactaform-input--text",inputNumber:"reactaform-input--number",inputSelect:"reactaform-select",rangeInput:"reactaform-input--range",button:"reactaform-button"},G=(...e)=>{const t=[];for(const r of e)r&&(typeof r=="string"?t.push(r):typeof r=="object"&&Object.entries(r).forEach(([o,n])=>{n&&t.push(o)}));return t.join(" ")},nt=({content:e,size:t="medium",animation:r=!0})=>{const{t:o,darkMode:n,formStyle:a,fieldStyle:i}=T(),[c,f]=s.useState(!1),[m,l]=s.useState({x:0,y:0}),[d,u]=s.useState(!1),p=s.useRef(null),h=s.useRef(null),g=s.useRef(null),x=s.useMemo(()=>{const O={icon:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"1.2em",height:"1.2em",fontSize:"0.9em",fontWeight:"bold",borderRadius:"50%",backgroundColor:n?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.06)",color:n?"#f0f0f0":"#333",border:`1px solid ${n?"rgba(255,255,255,0.2)":"rgba(0,0,0,0.1)"}`,cursor:"pointer",transition:r?"all 0.2s ease":void 0,marginLeft:"0.3em"},text:{...{small:{padding:"4px 8px",fontSize:"11px",maxWidth:"200px"},medium:{padding:"6px 10px",fontSize:"12px",maxWidth:"240px"},large:{padding:"8px 12px",fontSize:"13px",maxWidth:"280px"}}[t],position:"absolute",backgroundColor:`var(--reactaform-tooltip-color-bg, ${n?"rgba(45,45,45,0.95)":"rgba(60,60,60,0.92)"})`,color:`var(--reactaform-tooltip-color, ${n?"#f0f0f0":"#fff"})`,borderRadius:"6px",border:`1px solid ${n?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)"}`,boxShadow:n?"0 8px 16px rgba(0,0,0,0.4)":"0 6px 18px rgba(0,0,0,0.12)",zIndex:2147483647,opacity:0,visibility:"hidden",transition:r?"opacity 0.2s ease, visibility 0.2s ease":void 0,pointerEvents:"none",whiteSpace:"normal",wordBreak:"break-word",boxSizing:"border-box"},textVisible:{opacity:1,visibility:"visible"}},w=(j,S,E)=>{const M=j?.[S];return(E&&M?M[E]:void 0)??{}};return{icon:{...O.icon,...w(a,"tooltip","icon"),...w(i,"tooltip","icon")},text:{...O.text,...w(a,"tooltip","text"),...w(i,"tooltip","text")},textVisible:O.textVisible}},[n,t,r,a,i]);s.useEffect(()=>{if(c){const k=requestAnimationFrame(()=>u(!1)),O=requestAnimationFrame(()=>{if(p.current){const w=p.current.getBoundingClientRect(),R=8;g.current=w;const j=w.right+R,S=w.top;l({x:j,y:S}),u(!0)}});return()=>{cancelAnimationFrame(O),cancelAnimationFrame(k)}}else requestAnimationFrame(()=>u(!1))},[c]),s.useEffect(()=>{if(!d)return;const k=requestAnimationFrame(()=>{if(!h.current)return;const O=h.current.getBoundingClientRect(),w=8,R=typeof window<"u"?window.innerWidth:1024,j=typeof window<"u"?window.innerHeight:768;let S=m.x,E=m.y;const I=g.current;I&&(S=I.right+w,E=I.top+I.height/2-O.height/2+-4,S+O.width>R-w&&(S=I.left-w-O.width)),S+O.width>R-w&&(S=Math.max(w,R-O.width-w)),S<w&&(S=w),E+O.height>j-w&&(E=Math.max(w,j-O.height-w)),E<w&&(E=w),(S!==m.x||E!==m.y)&&l({x:S,y:E})});return()=>cancelAnimationFrame(k)},[d,m.x,m.y]);const v=typeof document<"u"?document.getElementById("popup-root"):null,C=b.jsx("div",{ref:h,style:{...x.text,transform:d?"translateY(0) scale(1)":"translateY(-4px) scale(0.98)",transition:"opacity 120ms ease, transform 120ms ease, visibility 120ms ease",width:240,...d?x.textVisible:{},top:m.y,left:m.x},"data-reactaform-theme":n?"dark":"light",children:o(e)});return b.jsxs(b.Fragment,{children:[b.jsx("span",{"data-testid":"tooltip-icon",ref:p,onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),style:{...x.icon},children:"?"}),c&&(v?Fe.createPortal(C,v):C)]})},ke=s.memo(({field:e,error:t,children:r,showLabel:o=!0})=>{const{t:n}=T(),a=e?.labelLayout==="column-center"?"center":"left";return b.jsxs("div",{className:`${A.field} column-layout`,style:{display:"flex",flexDirection:"column",gap:"var(--reactaform-label-gap, 4px)","--label-align":a},children:[o&&b.jsx("div",{style:{textAlign:a,width:"100%"},children:b.jsx("label",{className:A.label,htmlFor:e.name,style:{textAlign:a,width:"100%",minWidth:"unset",display:"block"},children:n(e.displayName)})}),b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--reactaform-inline-gap, 8px)",width:"100%"},children:[b.jsx("div",{style:{flex:1,minWidth:0,maxWidth:"100%"},children:b.jsx("div",{style:{width:"100%"},children:r})}),e.tooltip&&b.jsx(nt,{content:e.tooltip})]}),t&&b.jsx(ze,{children:t})]})});ke.displayName="ColumnFieldLayout";const ot=s.memo(({field:e,error:t,children:r,rightAlign:o=!1})=>{const{t:n}=T(),a=s.useMemo(()=>({display:"flex",flexDirection:"column",gap:0}),[]),i=s.useMemo(()=>({display:"flex",flexDirection:"row",alignItems:"center",gap:"3px"}),[]);return b.jsxs("div",{className:`${A.field} row-layout`,children:[b.jsx("label",{className:A.label,htmlFor:e.name,style:{textAlign:"left",justifyContent:"flex-start"},children:n(e.displayName)}),b.jsxs("div",{style:a,children:[b.jsxs("div",{style:i,children:[o?b.jsx("div",{style:{display:"flex",flex:1,justifyContent:"flex-end",alignItems:"center",gap:"var(--reactaform-inline-gap, 8px)"},children:r}):r,e.tooltip&&b.jsx(nt,{content:e.tooltip})]}),t&&b.jsx(ze,{children:t})]})]})});ot.displayName="RowFieldLayout";const W=({field:e,error:t,children:r,rightAlign:o=!1})=>e?.labelLayout==="column-left"||e?.labelLayout==="column-center"?b.jsx(ke,{field:e,error:t,showLabel:!0,children:r}):e?.type==="checkbox"||e?.type==="switch"?b.jsx(ke,{field:e,error:t,showLabel:!1,children:r}):b.jsx(ot,{field:e,error:t,rightAlign:o,children:r}),ze=s.memo(({children:e})=>{const t=s.useMemo(()=>({color:"var(--reactaform-error-color)",fontSize:"13px",marginTop:"4px",fontWeight:"var(--reactaform-font-weight)",display:"flex",flex:1,justifyContent:"flex-start",alignItems:"flex-start"}),[]);return b.jsx("div",{style:t,children:e})});ze.displayName="ErrorDiv";const at=s.memo(({name:e,onChange:t})=>{const{t:r}=T();return b.jsxs("div",{style:{marginBottom:16},children:[b.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 2fr",gap:12,alignItems:"center"},children:[b.jsx("label",{htmlFor:"instance-name-input",style:{margin:0,fontSize:"0.95em",fontWeight:500,color:"var(--reactaform-text-color, #333)"},children:r("Instance Name")}),b.jsx("input",{id:"instance-name-input",type:"text",value:e,onChange:o=>t(o.target.value),style:{width:"100%",padding:"var(--reactaform-input-padding, 8px 12px)",fontSize:"var(--reactaform-input-font-size, 14px)",border:"1px solid var(--reactaform-input-border, #ddd)",borderRadius:"var(--reactaform-border-radius, 4px)",backgroundColor:"var(--reactaform-input-bg, #fff)",color:"var(--reactaform-text-color, #333)",boxSizing:"border-box"},placeholder:r("Enter instance name")})]}),b.jsx("div",{style:{height:"1px",backgroundColor:"var(--reactaform-separator, #e6e6e6)",marginTop:12,marginBottom:12}})]})});at.displayName="InstanceName";class zt extends we{registerInCategory(t,r,o){this.get(t)||this.register(t,{});const n=this.get(t);n[r]=o}getFromCategory(t,r){return this.get(t)?.[r]}listFromCategory(t){return Object.keys(this.get(t)||{})}listCategories(){return this.list()}}const st=new we,it=new zt;function Vt(e,t){st.register(e,t)}function $t(e,t,r){it.registerInCategory(e,t,r)}function Tt(e,t){return it.getFromCategory(e,t)||null}function Pt(e){return st.get(e)||null}const Ce=new Map,Re=new Map;function U(e,t,r,o){if(t&&typeof t.validationHandlerName=="string"){const n=`${e}:${t.validationHandlerName}`;if(!Ce.has(n)){const i=Tt(e,t.validationHandlerName);Ce.set(n,i)}const a=Ce.get(n);if(a)return a(r,o)||null}return null}function ct(e,t,r){if(e&&typeof e.validationHandlerName=="string"){const o=e.validationHandlerName;if(!Re.has(o)){const a=Pt(o);Re.set(o,a)}const n=Re.get(o);if(n)return n(t,r)||null}return null}function ae(e){return typeof e=="object"&&e!==null}function Ve(e){if(!ae(e))return!1;const t=e;return typeof t.name=="string"&&typeof t.displayName=="string"}function lt(e){if(!ae(e))return!1;const t=e;return typeof t.name!="string"||typeof t.version!="string"||!Array.isArray(t.properties)?!1:t.properties.every(r=>Ve(r))}function Ie(e){try{return typeof File<"u"&&e instanceof File}catch{const t=ae(e)?e:void 0;return!!t&&typeof t.name=="string"&&typeof t.size=="number"}}function Dt(e,t,r={}){try{const{includeMetadata:o=!1,dateFormat:n="iso",fileHandling:a="metadata",prettify:i=!1,excludeFields:c=[],includeOnlyFields:f=[]}=r;if(!e||typeof e!="object")return{success:!1,error:"Instance must be a valid object"};const m=[],l=[],d={},p=(lt(t)||ae(t)&&Array.isArray(t.properties)?t.properties:[]).filter(Ve),h=new Map(p.map(x=>[x.name,x]));for(const[x,v]of Object.entries(e)){if(c.includes(x)){l.push(x);continue}if(f.length>0&&!f.includes(x)){l.push(x);continue}if(v===void 0)continue;const C=h.get(x);try{d[x]=Lt(v,C,{dateFormat:n,fileHandling:a})}catch(k){m.push(`Error serializing field '${x}': ${String(k)}`),d[x]=null}}return o&&(d._metadata={serializedAt:new Date().toISOString(),version:(ae(t)?t.version:void 0)||"1.0.0",fieldCount:Object.keys(d).length-1}),{success:!0,data:i?JSON.stringify(d,null,2):JSON.stringify(d),metadata:{fieldCount:Object.keys(d).length,excludedFields:l,warnings:m}}}catch(o){return{success:!1,error:`Serialization failed: ${o instanceof Error?o.message:"Unknown error"}`}}}function Lt(e,t,r={}){const{dateFormat:o="iso",fileHandling:n="metadata"}=r;if(e==null)return null;if(t)switch(t.type){case"date":case"datetime":case"date-time":return Ue(e,o);case"file":return Ye(e,n);case"int":case"integer":return typeof e=="string"?parseInt(e,10):e;case"float":case"number":return typeof e=="string"?parseFloat(e):e;case"boolean":return typeof e=="string"?e==="true":!!e;case"int-array":case"float-array":return Array.isArray(e)?e.map(a=>typeof a=="string"?Number(a):a):e;default:return e}return e instanceof Date?Ue(e,o):Ie(e)||Array.isArray(e)&&Ie(e[0])?Ye(e,n):e}function Ue(e,t){let r=null;if(e instanceof Date)r=e;else if(typeof e=="string"){const o=new Date(e);if(!isNaN(o.getTime()))r=o;else return e}else return e;switch(t){case"timestamp":return r.getTime();case"locale":return r.toLocaleString();case"iso":default:return r.toISOString()}}function Ye(e,t){return t==="skip"?null:Array.isArray(e)?e.map(r=>Je(r,t)):Je(e,t)}function Je(e,t){if(!Ie(e))return e;const r=e;return t==="metadata"?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified,_note:"Base64 encoding requires async implementation"}}function _t(e,t,r={}){try{const{strict:o=!1,validateTypes:n=!0,preserveUnknownFields:a=!0,dateFormat:i="auto"}=r;if(!e||typeof e!="string")return{success:!1,error:"Serialized data must be a non-empty string"};let c;try{c=JSON.parse(e)}catch(g){return{success:!1,error:`Invalid JSON: ${g instanceof Error?g.message:"Unknown parsing error"}`}}if(!c||typeof c!="object")return{success:!1,error:"Parsed data must be an object"};const f=[],m=[],l={},u=(lt(t)||ae(t)&&Array.isArray(t.properties)?t.properties:[]).filter(Ve),p=new Map(u.map(g=>[g.name,g]));for(const g of u){const x=g.name,v=c[x];if(v===void 0){o&&g.required&&m.push(`Required field '${x}' is missing`);continue}try{l[x]=qt(v,g,{validateTypes:n,dateFormat:i})}catch(C){const k=`Error deserializing field '${x}': ${String(C)}`;o?m.push(k):(f.push(k),l[x]=v)}}if(a)for(const[g,x]of Object.entries(c))!p.has(g)&&g!=="_metadata"&&(o&&f.push(`Unknown field '${g}' preserved`),l[g]=x);const h=m.length>0;return{success:!h,data:l,warnings:f.length>0?f:void 0,validationErrors:h?m:void 0}}catch(o){return{success:!1,error:`Deserialization failed: ${o instanceof Error?o.message:"Unknown error"}`}}}function qt(e,t,r={}){const{validateTypes:o=!0,dateFormat:n="auto"}=r;if(e==null)return e;try{switch(t.type){case"date":case"datetime":case"date-time":return Wt(e,n,o);case"int":case"integer":return Ne(e,o);case"float":case"number":return Oe(e,o);case"boolean":return Ut(e,o);case"int-array":return Ge(e,"integer",o);case"float-array":return Ge(e,"number",o);case"string":case"text":case"email":case"url":case"phone":return o?String(e):e;default:return e}}catch(a){if(o)throw new Error(`Type conversion failed: ${String(a)}`);return e}}function Bt(e,t={}){try{const{prettify:r=!0,includeMetadata:o=!0}=t;if(!e||typeof e!="object")return{success:!1,error:"Definition must be a valid object"};const n={...e};return o&&(n._metadata={serializedAt:new Date().toISOString(),version:n.version||"1.0.0",propertyCount:(Array.isArray(n.properties)?n.properties.length:0)||0}),{success:!0,data:r?JSON.stringify(n,null,2):JSON.stringify(n),metadata:{fieldCount:(Array.isArray(n.properties)?n.properties.length:0)||0,excludedFields:[],warnings:[]}}}catch(r){return{success:!1,error:`Definition serialization failed: ${r instanceof Error?r.message:"Unknown error"}`}}}function Ht(e,t={}){try{const{strict:r=!1,validateTypes:o=!0}=t;let n;if(typeof e=="string")try{n=JSON.parse(e)}catch(l){return{success:!1,error:`Invalid JSON for definition: ${l instanceof Error?l.message:"Unknown parsing error"}`}}else if(e&&typeof e=="object")n={...e};else return{success:!1,error:"Input must be a string or object"};const a=[],i=[],c=["name","version","displayName"];for(const l of c)if(!n[l])if(r)i.push(`Required field '${l}' is missing`);else switch(a.push(`Missing field '${l}', using default`),l){case"name":n.name="unnamed-definition";break;case"version":n.version="1.0.0";break;case"displayName":n.displayName=n.name||"Unnamed Definition";break}const f=Array.isArray(n.properties)?n.properties:null;f?n.properties=f.map((l,d)=>{const u=ae(l)?l:{},p={...u};if(!u.name){const h=`Property at index ${d} missing 'name'`;r?i.push(h):(a.push(`${h}, using 'field_${d}'`),p.name=`field_${d}`)}return u.displayName||(p.displayName=u.name||`Field ${d}`),u.type||(r&&o?i.push(`Property '${u.name||d}' missing 'type'`):(a.push(`Property '${u.name||d}' missing 'type', using 'string'`),p.type="string")),u.defaultValue===void 0&&(p.defaultValue=null),u.required===void 0&&(p.required=!1),p}):r?i.push("Properties must be an array"):(a.push("Properties not found or invalid, using empty array"),n.properties=[]);const m=i.length>0;return{success:!m,data:n,warnings:a.length>0?a:void 0,validationErrors:m?i:void 0}}catch(r){return{success:!1,error:`Definition deserialization failed: ${r instanceof Error?r.message:"Unknown error"}`}}}function Wt(e,t,r){if(e instanceof Date)return e;if(typeof e=="number"){const o=new Date(e);if(r&&isNaN(o.getTime()))throw new Error(`Invalid timestamp: ${e}`);return o}if(typeof e=="string"){const o=new Date(e);if(r&&isNaN(o.getTime()))throw new Error(`Invalid date string: ${e}`);return o}if(r)throw new Error(`Cannot convert ${typeof e} to Date`);return e}function Ne(e,t){if(typeof e=="number"&&Number.isInteger(e))return e;if(typeof e=="string"&&e.trim()!==""){const r=parseInt(e,10);if(t&&isNaN(r))throw new Error(`Cannot convert "${e}" to integer`);return r}if(t)throw new Error(`Cannot convert ${typeof e} to integer`);return e}function Oe(e,t){if(typeof e=="number")return e;if(typeof e=="string"&&e.trim()!==""){const r=parseFloat(e);if(t&&isNaN(r))throw new Error(`Cannot convert "${e}" to number`);return r}if(t)throw new Error(`Cannot convert ${typeof e} to number`);return e}function Ut(e,t){if(typeof e=="boolean")return e;if(typeof e=="string"){const r=e.toLowerCase();if(r==="true"||r==="1")return!0;if(r==="false"||r==="0")return!1;if(t)throw new Error(`Cannot convert "${e}" to boolean`)}if(typeof e=="number")return!!e;if(t)throw new Error(`Cannot convert ${typeof e} to boolean`);return e}function Ge(e,t,r){if(!Array.isArray(e)){if(typeof e=="string")return e.split(",").map(n=>n.trim()).filter(Boolean).map(n=>t==="integer"?Ne(n,r):Oe(n,r));if(r)throw new Error(`Expected array, got ${typeof e}`);return e}return e.map((o,n)=>{try{return t==="integer"?Ne(o,r):Oe(o,r)}catch(a){if(r)throw new Error(`Array element ${n}: ${a}`);return o}})}const Yt=(e,t)=>{const r=new Map;let o=null,n=null,a=0;for(const i of e){const c=i.group;if(!c){o=null,n=null;continue}if(c===o)t[i.name].group=n??c;else{if(!r.has(c))r.set(c,1),n=null,t[i.name].group=c;else{const f=r.get(c),m=`${c}(${f})`;r.set(c,f+1),n=m,t[i.name].group=m,a++}o=c}}return a},ut=(e,t={})=>{const{includeEmpty:r=!0}=t,o=[];let n=null,a=[],i=0;for(const f of e){const m=f.group||null;m!==n?((a.length>0||r)&&(a.length===0&&i++,o.push({name:n,fields:a})),n=m,a=[f]):a.push(f)}(a.length>0||r)&&(a.length===0&&i++,o.push({name:n,fields:a}));const c=Math.max(0,...o.map(f=>f.fields.length));return{groups:o,metadata:{totalGroups:o.length,emptyGroups:i,largestGroup:c}}},Ee=new Map,xe=new Map,oe=new Set,Me=new Map,Jt=async e=>{try{let t;switch(e.toLowerCase()){case"fr":t=(await Promise.resolve().then(()=>require("./common-BxyjIoe1.js"))).default;break;case"de":t=(await Promise.resolve().then(()=>require("./common-BD9zx3GT.js"))).default;break;case"es":t=(await Promise.resolve().then(()=>require("./common-hRFTL4KF.js"))).default;break;case"zh-cn":t=(await Promise.resolve().then(()=>require("./common-COyDhNL-.js"))).default;break;case"en":t={};break;default:t={}}return{success:!0,translations:t,fromCache:!1}}catch(t){return{success:!1,translations:{},error:`Failed to load common translations for ${e}: ${t}`}}},Gt=async e=>{if(!e)return{success:!1,translations:{},error:"Language is required"};const t=e.toLowerCase();if(t==="en")return{success:!0,translations:{},fromCache:!1};if(Ee.has(t))return{success:!0,translations:Ee.get(t)||{},fromCache:!0};const r=await Jt(t);return r.success&&(Ee.set(t,r.translations),Me.set(t,{loadedAt:new Date,size:Object.keys(r.translations).length,source:"common"})),r},Kt=async(e,t)=>{if(!e||!t)return{success:!1,translations:{},error:"Both language and localizeName are required"};const r=`${e.toLowerCase()}/${t}`;if(oe.has(r))return{success:!1,translations:{},error:"Previously failed to load",fromCache:!0};if(xe.has(r))return{success:!0,translations:xe.get(r)||{},fromCache:!0};try{let o=t;!t.includes("/")&&!t.includes(".")&&(o=`/locales/${e}/${t}.json`);const n=await fetch(o);if(!n.ok){const m=`HTTP ${n.status}: ${n.statusText}`;return n.status===404?(xe.set(r,{}),Me.set(r,{loadedAt:new Date,size:0,source:"user"}),{success:!0,translations:{},fromCache:!1}):(oe.add(r),{success:!1,translations:{},error:m})}const a=n.headers.get("content-type")||"";!a.includes("application/json")&&!a.includes("text/json")&&ft()&&console.warn(`Translation file at ${o} has unexpected content-type: ${a}`);const i=await n.text();if(!i){const m="Empty translation file";return oe.add(r),{success:!1,translations:{},error:m}}let c;try{c=JSON.parse(i)}catch(m){const l=`Invalid JSON in translation file: ${m instanceof Error?m.message:String(m)}`;return oe.add(r),{success:!1,translations:{},error:l}}if(!c||typeof c!="object"){const m="Invalid translation file format";return oe.add(r),{success:!1,translations:{},error:m}}const f=Object.fromEntries(Object.entries(c).map(([m,l])=>[m,typeof l=="string"?l:String(l)]));if(!f||typeof f!="object"){const m="Invalid translation file format";return oe.add(r),{success:!1,translations:{},error:m}}return xe.set(r,f),Me.set(r,{loadedAt:new Date,size:Object.keys(f).length,source:"user"}),{success:!0,translations:f,fromCache:!1}}catch(o){const n=`Failed to load user translations: ${o instanceof Error?o.message:"Unknown error"}`;return oe.add(r),{success:!1,translations:{},error:n}}};function ft(){try{if(typeof process<"u"&&process?.env?.NODE_ENV==="development")return!0}catch{}return!1}function Xt(e,t){return t.length===0?e:e.replace(/\{\{(\d+)\}\}/g,(r,o)=>{const n=parseInt(o,10)-1,a=t[n];if(a==null)return r;try{return String(a)}catch{return r}})}const Zt=(e,t,r)=>(o,...n)=>{let a=o,i=!1;return!o||typeof o!="string"?String(o||""):(e.toLowerCase()==="en"?(a=o,i=!0):Object.prototype.hasOwnProperty.call(r,o)?(a=r[o],i=!0):Object.prototype.hasOwnProperty.call(t,o)?(a=t[o],i=!0):a=o,a=Xt(a,n),!i&&ft()&&console.debug(`Missing translation for "${o}" in language "${e}"`),a)},$e={length:["m","cm","mm","km","in","ft","yd","mi"],area:["m^2","cm^2","mm^2","in^2","ft^2","yd^2"],volume:["L","m^3","cm^3","mL","in^3","ft^3","yd^3"],weight:["kg","g","mg","t","lb","oz"],time:["min","s","h","ms","d"],temperature:["C","F","K"],angle:["deg","rad","rev"]},Te={length:{m:"Meter (m)",mm:"Millimeter (mm)",cm:"Centimeter (cm)",km:"Kilometer (km)",in:"Inch (in)",ft:"Foot (ft)",yd:"Yard (yd)",mi:"Mile (mi)"},area:{"m^2":"Square meter (m^2)","mm^2":"Square millimeter (mm^2)","cm^2":"Square centimeter (cm^2)","in^2":"Square inch (in^2)","ft^2":"Square foot (ft^2)","yd^2":"Square yard (yd^2)"},volume:{L:"Liter (L)","cm^3":"Cubic centimeter (cm^3)","m^3":"Cubic meter (m^3)",mL:"Milliliter (mL)","in^3":"Cubic inch (in^3)","ft^3":"Cubic foot (ft^3)","yd^3":"Cubic yard (yd^3)"},weight:{kg:"Kilogram (kg)",g:"Gram (g)",mg:"Milligram (mg)",t:"Tonne (t)",lb:"Pound (lb)",oz:"Ounce (oz)"},time:{s:"Second (s)",min:"Minute (min)",h:"Hour (h)",ms:"Millisecond (ms)",d:"Day (d)",wk:"Week (wk)"},temperature:{C:"Celsius (C)",F:"Fahrenheit (F)",K:"Kelvin (K)"},angle:{deg:"Degree (deg)",rad:"Radian (rad)",rev:"Revolution (rev)"}},Pe={length:{mm:1e3,cm:100,m:1,km:.001,in:100/2.54,ft:100/(2.54*12),yd:100/(2.54*36),mi:1/1609.344},area:{"m^2":1,"mm^2":1e6,"cm^2":1e4,"km^2":1/1e6,"in^2":(100/2.54)**2,"ft^2":(100/(2.54*12))**2,"yd^2":(100/(2.54*36))**2},volume:{"cm^3":1e6,"m^3":1,L:1,mL:1e6,"in^3":(100/2.54)**3,"ft^3":(100/(2.54*12))**3,"yd^3":(100/(2.54*36))**3},weight:{mg:1e6,g:1e3,kg:1,t:.001,lb:1/.45359237,oz:1/.028349523125},time:{ms:1e3,s:1,min:1/60,h:1/3600,d:1/86400,wk:1/604800},temperature:{C:1,F:33.8,K:274.15},angle:{deg:1,rad:Math.PI/180,rev:1/360}},De={},Qt=new Set([...Object.keys($e),...Object.keys(Te),...Object.keys(Pe)]);for(const e of Qt){const t={},r=$e[e]??[],o=Te[e]??{},n=Pe[e]??{};for(const a of r){const i=o[a];t[a]={name:typeof i=="string"?i:String(a),shortName:a,factor:Object.prototype.hasOwnProperty.call(n,a)?n[a]:void 0}}for(const[a,i]of Object.entries(o))if(!t[a]){const c=typeof i=="string"?i:String(a);t[a]={name:c,shortName:a,factor:Object.prototype.hasOwnProperty.call(n,a)?n[a]:void 0}}for(const[a,i]of Object.entries(n))t[a]||(t[a]={name:String(a),shortName:String(a),factor:i});De[e]=t}const er=Object.freeze(Object.defineProperty({__proto__:null,dimensionUnitDisplayMap:Te,dimensionUnitsMap:$e,dimensonUnitFactorsMap:Pe,unitsByDimension:De},Symbol.toStringTag,{value:"Module"})),tr=({field:e,value:t,onChange:r,onError:o})=>{const{definitionName:n,t:a}=T(),i=s.useRef(o);s.useEffect(()=>{i.current=o},[o]),s.useEffect(()=>{const l=U(n,e,t??!1,a);i.current?.(l??null)},[t,e,n,a]);const c=l=>{const d=l.target.checked;r?.(d,null)},f=l=>{(l.key===" "||l.key==="Spacebar"||l.key==="Space"||l.key==="Enter")&&(l.preventDefault(),r?.(!t,null))},m=e.name;return b.jsx(W,{field:e,rightAlign:!1,children:b.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[b.jsx("label",{className:A.label,htmlFor:m,style:{textAlign:"left",justifyContent:"flex-start"},children:a(e.displayName)}),b.jsx("input",{id:m,"data-testid":"boolean-checkbox",type:"checkbox",checked:!!t,onChange:c,onKeyDown:f,"aria-checked":!!t,style:{cursor:"pointer",margin:"8px 0 8px 0",width:"1.2em",height:"1.2em",verticalAlign:"middle",color:"#FFFFFF",accentColor:"#0000FF",opacity:void 0}})]})})},Ke=[{label:"Black",value:"#000000"},{label:"White",value:"#ffffff"},{label:"Red",value:"#ff0000"},{label:"Green",value:"#008000"},{label:"Blue",value:"#0000ff"},{label:"Yellow",value:"#ffff00"},{label:"Cyan",value:"#00ffff"},{label:"Magenta",value:"#ff00ff"},{label:"Orange",value:"#ffa500"},{label:"Purple",value:"#800080"},{label:"Brown",value:"#a52a2a"},{label:"Gray",value:"#808080"},{label:"Light Gray",value:"#d3d3d3"},{label:"Pink",value:"#ffc0cb"}];function mt(e){return/^#([0-9A-F]{3}){1,2}$/i.test(e)}function rr(e){if(!mt(e))return null;const t=dt(e),r=parseInt(t.slice(1),16);return{r:r>>16&255,g:r>>8&255,b:r&255}}function dt(e){return e?(e=e.toLowerCase(),/^#([a-f0-9]){3}$/i.test(e)?"#"+e.slice(1).split("").map(t=>t+t).join(""):e):"#000000"}const nr=({field:e,value:t,onChange:r,onError:o})=>{const{t:n,definitionName:a}=T(),[i,c]=s.useState("#000000"),f=s.useRef(null),m=s.useRef(null),l=s.useRef(o);s.useEffect(()=>{l.current=o},[o]),s.useEffect(()=>{const v=t&&mt(t)?t:"#000000",C=dt(v);c(C)},[t]),s.useEffect(()=>{const v=U(a,e,t??"#000000",n);l.current?.(v??null)},[t,e,a,n]);const d=v=>{const C=v.target.value;c(C),r?.(C,null)},u=v=>{const C=v.target.value;c(C),r?.(C,null)},p=Ke.find(v=>v.value===i),{r:h,g,b:x}=rr(i)||{r:0,g:0,b:0};return b.jsx(W,{field:e,error:null,children:b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",width:"100%"},children:[b.jsxs("select",{ref:f,id:e.name,value:i,onChange:d,style:{minWidth:"120px",flex:1},className:G(A.input,A.inputSelect),children:[Ke.map(v=>b.jsx("option",{value:v.value,children:n(v.label)},v.value)),p?null:b.jsxs("option",{value:i,children:["(",h,", ",g,", ",x,")"]},i)]}),b.jsx("label",{style:{width:"2.5em",height:"1.8em",display:"inline-block",border:"1px solid #ccc",borderRadius:"4px",backgroundColor:i,cursor:"pointer",overflow:"hidden",flexShrink:0},children:b.jsx("input",{ref:m,type:"color",value:i,onChange:u,style:{opacity:0,width:"100%",height:"100%",border:"none",padding:0,cursor:"pointer"}})})]})})},pe=e=>{if(!e)return null;const t=new Date(e);return isNaN(t.getTime())?null:t},or=e=>{if(!e)return"";if(/^\d{4}-\d{2}-\d{2}$/.test(e))return pe(e)?e:"";const r=pe(e);if(r){const o=r.getFullYear(),n=String(r.getMonth()+1).padStart(2,"0"),a=String(r.getDate()).padStart(2,"0");return`${o}-${n}-${a}`}return""},ar=({field:e,value:t,onChange:r,onError:o})=>{const{t:n,definitionName:a}=T(),{name:i,required:c}=e,f=s.useRef(null),m=s.useRef(o);s.useEffect(()=>{m.current=o},[o]);const l=s.useCallback(u=>{if(!u||u.trim()==="")return c?n("Value required"):null;if(u){const h=pe(u);if(!h)return n("Invalid date format");if(e.minDate){const g=pe(e.minDate);if(g&&h.getTime()<g.getTime())return n("Date must be on or after {{1}}",e.minDate)}if(e.maxDate){const g=pe(e.maxDate);if(g&&h.getTime()>g.getTime())return n("Date must be on or before {{1}}",e.maxDate)}}return U(a,e,u,n)??null},[e,a,n,c]),d=u=>{const p=u.target.value,h=l(p);r?.(p,h)};return s.useEffect(()=>{const u=l(t);u!==f.current&&(f.current=u,m.current?.(u??null))},[t,l]),b.jsx(W,{field:e,error:l(t),children:b.jsx("input",{id:i,type:"date",value:or(t),onChange:d,className:G(A.input,A.textInput),...e.minDate?{min:e.minDate}:{},...e.maxDate?{max:e.maxDate}:{},"aria-invalid":!!l(t),"aria-describedby":l(t)?`${i}-error`:void 0})})},sr=({field:e,value:t,onChange:r,onError:o})=>{const{t:n,definitionName:a}=T(),i=s.useRef(null),c=s.useRef(o);s.useEffect(()=>{c.current=o},[o]);const f=s.useCallback(l=>l===""||l===null||l===void 0?n("Value required"):!e.options||e.options.length===0?null:e.options.some(u=>u.value===l)?U(a,e,l,n)??null:n("Invalid option selected"),[e,n,a]);s.useEffect(()=>{const l=t!=null?String(t):"",d=f(l);if(d&&e.options&&e.options.length>0){const u=String(e.options[0].value);i.current&&(i.current.value=u),r?.(u,null),c.current?.(null)}else i.current&&(i.current.value=l),c.current?.(d??null)},[t,f,r,e.options]);const m=l=>{const d=l.target.value,u=f(d);r?.(d,u)};return b.jsx(W,{field:e,error:f(String(t??"")),children:b.jsx("select",{defaultValue:String(t??""),ref:i,onChange:m,className:G(A.input,A.inputSelect),children:(e.options??[]).map(l=>b.jsx("option",{value:String(l.value),children:n(l.label)},String(l.value)))})})};function ir(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}const cr=({field:e,value:t,onChange:r,onError:o})=>{const{definitionName:n,t:a}=T(),i=s.useRef(null),c=s.useCallback(d=>{const u=d.trim();return u===""?e.required?a("Value required"):null:ir(u)?e.pattern&&!new RegExp(e.pattern).test(u)?a("Email does not match pattern: {{%1}}",{"%1":`${e.pattern}`}):U(n,e,d,a)??null:a("Must be valid email format")},[e,n,a]),f=d=>{const u=d.target.value,p=c(u);r?.(u,p)},m=s.useRef(null),l=s.useRef(o);return s.useEffect(()=>{l.current=o},[o]),s.useEffect(()=>{const d=t??"",u=c(d);i.current&&i.current.value!==String(d)&&(i.current.value=String(d)),u!==m.current&&(m.current=u,l.current?.(u??null))},[t,c]),b.jsx(W,{field:e,error:c(String(t??"")),children:b.jsx("input",{id:e.name,type:"email",defaultValue:String(t??""),ref:i,onChange:f,className:G(A.input,A.textInput)})})},lr=({field:e})=>{const{darkMode:t}=T(),{color:r=t?"#444444":"#CCCCCC",thickness:o=1,margin:n="8px 0"}=e;return b.jsx("div",{style:{width:"auto",height:"0",borderTop:`${o}px solid ${r}`,margin:n}})};function pt({pos:e,options:t,onClose:r,onClickOption:o}){const n=s.useRef(null),a=s.useRef(!1),i=typeof window<"u"?document.getElementById("popup-root")||document.body:null;if(s.useEffect(()=>{function p(h){a.current||h.target.dataset?.popupMenu==="item"||n.current&&h.target instanceof Node&&!n.current.contains(h.target)&&r()}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[r]),!i||t===void 0||t.length===0||!e||e.x==null||e.y==null)return null;const c=e.x,f=e.y,m=typeof window<"u"?window.innerWidth:1024,l=Math.max(0,m-160),d=Math.max(0,Math.min(c,l)),u=Math.max(0,f);return Fe.createPortal(b.jsx("div",{ref:n,onMouseDown:p=>{p.stopPropagation()},style:{position:"fixed",top:u,left:d,backgroundColor:"var(--reactaform-primary-bg, #fff)",border:"1px solid var(--reactaform-border-color, #ccc)",borderRadius:"var(--reactaform-border-radius, 4px)",boxShadow:"var(--reactaform-shadow, 0 2px 10px rgba(0,0,0,0.2))",zIndex:9999,minWidth:"var(--reactaform-menu-min-width, 150px)",pointerEvents:"auto"},children:t.map((p,h)=>b.jsx("div",{"data-popup-menu":"item",onMouseDown:g=>{g.stopPropagation(),a.current=!0},onClick:g=>{g.stopPropagation(),g.preventDefault(),o(p),r(),setTimeout(()=>{a.current=!1},100)},style:{padding:"var(--reactaform-menu-item-padding, 8px 12px)",cursor:"pointer",fontSize:"var(--reactaform-menu-item-font-size, 0.8em)",borderBottom:h<t.length-1?"1px solid var(--reactaform-border-light, #eee)":void 0,transition:"background-color 0.15s ease"},onMouseEnter:g=>{g.currentTarget.style.backgroundColor="var(--reactaform-hover-bg, #e0e0e0)"},onMouseLeave:g=>{g.currentTarget.style.backgroundColor="transparent"},children:p.label},p.label??h))}),i)}const ur=({field:e,value:t,onChange:r,onError:o})=>{const{t:n,definitionName:a}=T(),[i,c]=s.useState(!1),[f,m]=s.useState(null),[l,d]=s.useState([]),u=s.useRef(null),p=s.useRef(o);s.useEffect(()=>{p.current=o},[o]);const h=s.useCallback(C=>e.required&&(!C||Array.isArray(C)&&C.length===0)?n("Value required"):U(a,e,C,n)??null,[e,a,n]),g=s.useMemo(()=>h(t),[t,h]);s.useEffect(()=>{const C=h(t);r?.(t,C),p.current?.(C??null)},[t,h]);const x=C=>{const k=C.target.files;let O=null;k&&k.length>0&&(O=e.multiple?Array.from(k):k[0]);const w=h(O);r?.(O,w)},v=C=>{if(g)return;let k=null;try{k=C.currentTarget.getBoundingClientRect()}catch{k=null}const O=k&&typeof k.left=="number"?k.left:10,w=k&&typeof k.bottom=="number"?k.bottom:20;m({x:O,y:w});let R=[];Array.isArray(t)?R=t?t.map(j=>({label:j.name})):[]:R=t?[{label:t.name}]:[],R.length===0&&(R=[{label:n("No file selected")}]),d(R),c(j=>!j)};return b.jsx(W,{field:e,error:g,children:b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--reactaform-inline-gap, 8px)",width:"100%"},children:[b.jsx("input",{id:e.name,ref:u,type:"file",accept:e.accept,multiple:e.multiple,style:{width:0,height:0,opacity:0,position:"absolute",zIndex:-1},onChange:x}),b.jsx("label",{htmlFor:e.name,className:A.button,style:{width:"100%",height:"inherit",textAlign:"center"},children:e.multiple?n("Choose Files..."):n("Choose File...")}),b.jsx("button",{onClick:v,"aria-haspopup":!0,"aria-expanded":i,"aria-label":n("Show selected files"),className:A.button,style:{height:"inherit",display:"inline-block"},children:b.jsx("span",{children:"⋮"})}),i&&f&&l&&l.length>0&&b.jsx(pt,{pos:f,options:l,onClose:()=>{m(null),c(!1)},onClickOption:()=>{}})]})})},fr=/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/;function mr(e){return e.split(",").map(t=>t.trim()).every(t=>fr.test(t))}const dr=e=>!e||e.trim()===""?[]:e.split(",").map(t=>t.trim()).filter(Boolean).map(Number),pr=({field:e,value:t,onChange:r,onError:o})=>{const{t:n,definitionName:a}=T(),[i,c]=s.useState(Array.isArray(t)?t.join(", "):String(t??"")),f=s.useCallback(u=>{if(u.trim()==="")return e.required?n("Value required"):null;if(!mr(u))return n("Each value must be a valid float");const p=dr(u);if(e.minCount!==void 0&&p.length<e.minCount)return n("Minimum number of values: {{1}}",e.minCount);if(e.maxCount!==void 0&&p.length>e.maxCount)return n("Maximum number of values: {{1}}",e.maxCount);for(const g of p){if(e.min!==void 0&&(e.minInclusive?g<e.min:g<=e.min))return n("Each value must be {{1}} {{2}}",e.minInclusive?"≥":">",e.min);if(e.max!==void 0&&(e.maxInclusive?g>e.max:g>=e.max))return n("Each value must be {{1}} {{2}}",e.maxInclusive?"≤":"<",e.max)}return U(a,e,p,n)??null},[a,e,n]),m=u=>{const p=u.target.value,h=f(p);c(p),r?.(p,h)},l=s.useRef(null),d=s.useRef(o);return s.useEffect(()=>{d.current=o},[o]),s.useEffect(()=>{const u=Array.isArray(t)?t.join(", "):String(t??""),p=f(u);p!==l.current&&(l.current=p,d.current?.(p??null))},[t,e.required,f,n]),b.jsx(W,{field:e,error:f(i),children:b.jsx("input",{type:"text",value:i,onChange:m,className:G(A.input,A.textInput),style:{flex:1}})})},gr=/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/,hr=e=>{const t=Number.parseFloat(e);return Number.isNaN(t)?null:t},br=({field:e,value:t,onChange:r,onError:o})=>{const{t:n,definitionName:a}=T(),i=s.useRef(null),c=s.useCallback(d=>{if(d.trim()==="")return e.required?n("Value required"):null;if(!gr.test(d))return n("Must be a valid float");const u=hr(d);return u===null?n("Must be a valid float"):e.min!==void 0&&(e.minInclusive?u<e.min:u<=e.min)?n("Must be {{1}} {{2}}",e.minInclusive?"≥":">",e.min):e.max!==void 0&&(e.maxInclusive?u>e.max:u>=e.max)?n("Must be {{1}} {{2}}",e.maxInclusive?"≤":"<",e.max):U(a,e,u,n)??null},[e,a,n]),f=s.useRef(null),m=s.useRef(o);s.useEffect(()=>{m.current=o},[o]),s.useEffect(()=>{const d=String(t??""),u=c(d);u!==f.current&&(f.current=u,m.current?.(u??null)),i.current&&document.activeElement!==i.current&&(i.current.value=d)},[t,e,c,n]);const l=d=>{const u=d.target.value,p=c(u);r?.(u,p)};return b.jsx(W,{field:e,error:c(String(t??"")),children:b.jsx("input",{id:e.name,type:"text",defaultValue:String(t??""),ref:i,onChange:l,className:G(A.input,A.inputNumber)})})};function yr(){try{return"/"}catch{}try{if(typeof process<"u"&&process?.env?.PUBLIC_URL)return process.env.PUBLIC_URL}catch{}return"/"}const xr=({field:e,value:t})=>{const{language:r,t:o}=T(),n=e.alignment||"center",a={left:"flex-start",center:"center",right:"flex-end"},i=typeof t=="string"?t:"";let c=i&&i.trim()!==""?i:typeof e.defaultValue=="string"?e.defaultValue:"";c&&!c.startsWith("/")&&(c=`${yr()}${c}`);const f=e.localized?.split(";").map(x=>x.trim()),[m,l]=s.useState(c||""),d=s.useRef(c||null);if(s.useEffect(()=>{if(!c)return;const x=c.split("/"),v=x.pop(),C=v.lastIndexOf(".");if(C===-1)return;const k=v.substring(0,C),O=v.substring(C);let w=null;f?.includes(r)&&(w=`${k}_${r}${O}`);const R=new AbortController;if(w){const j=[...x,w].join("/");fetch(j,{method:"HEAD",signal:R.signal}).then(S=>{const E=S.ok?j:c;E!==d.current&&(d.current=E,l(E))}).catch(()=>{c!==d.current&&(d.current=c,l(c))})}else{const j=c;j!==d.current&&(d.current=j,requestAnimationFrame(()=>l(j)))}return()=>{R.abort()}},[c,r,f]),!m)return null;const{width:u,height:p}=e,h={},g={borderRadius:"8px",objectFit:"contain",boxShadow:"0 2px 6px rgba(0,0,0,0.1)",margin:"0 0 8px 0"};return u&&p?(h.width=u,h.height=p,g.width=`${u}px`,g.height=`${p}px`):u&&!p?(h.width=u,g.width=`${u}px`,g.height="auto"):!u&&p&&(h.height=p,g.width="auto",g.height=`${p}px`),b.jsx(W,{field:e,children:b.jsx("div",{"data-testid":"image-wrapper",style:{display:"flex",justifyContent:a[n]||"center",margin:"0 0"},children:b.jsx("img",{src:m,alt:o?.(e.displayName||"Image")||e.displayName||"Image",...h,style:g})})})};function vr(e){const t=/^-?\d+$/;return e.split(",").map(r=>r.trim()).every(r=>t.test(r))}const wr=({field:e,value:t,onChange:r,onError:o})=>{const{t:n,definitionName:a}=T(),i=",",[c,f]=s.useState(Array.isArray(t)?t.join(i+" "):String(t??"")),m=h=>!h||h.trim()===""?[]:h.split(i).map(g=>g.trim()).filter(Boolean).map(g=>Number(g)),l=s.useCallback(h=>{if(h.trim()==="")return e.required?n("Value required"):null;if(!vr(h))return n("Each value must be a valid integer");const g=m(h);if(e.minCount!==void 0&&g.length<e.minCount)return n("Minimum number of values: {{1}}",`${e.minCount}`);if(e.maxCount!==void 0&&g.length>e.maxCount)return n("Maximum number of values: {{1}}",`${e.maxCount}`);for(const v of g){if(e.min!==void 0&&(e.minInclusive?v<e.min:v<=e.min))return n("Each value must be {{1}} {{2}}",e.minInclusive?"≥":">",e.min);if(e.max!==void 0&&(e.maxInclusive?v>e.max:v>=e.max))return n("Each value must be {{1}} {{2}}",e.maxInclusive?"≤":"<",e.max)}return U(a,e,g,n)??null},[a,e,n]),d=h=>{const g=h.target.value,x=l(g);f(g),r?.(g,x)},u=s.useRef(null),p=s.useRef(o);return s.useEffect(()=>{p.current=o},[o]),s.useEffect(()=>{const h=Array.isArray(t)?t.join(i+" "):String(t??""),g=l(h);g!==u.current&&(u.current=g,p.current?.(g??null))},[t,e.required,l,n]),b.jsx(W,{field:e,error:l(c),children:b.jsx("input",{type:"text",value:c,onChange:d,className:G(A.input,A.textInput),style:{flex:1}})})};function Sr(e){return/^[-+]?\d*$/.test(e)}const Cr=({field:e,value:t,onChange:r,onError:o})=>{const{t:n,definitionName:a}=T(),i=s.useRef(null),c=s.useCallback(u=>{const p=parseInt(u,10);return Number.isNaN(p)?null:p},[]),f=s.useCallback(u=>{if(u.trim()==="")return e.required?n("Value required"):null;if(!Sr(u))return n("Must be a valid integer");const p=c(u);if(p===null)return n("Must be a valid integer");if(e.min!==void 0&&(e.minInclusive?p<e.min:p<=e.min))return n("Must be {{1}} {{2}}",e.minInclusive?"≥":">",e.min);if(e.max!==void 0&&(e.maxInclusive?p>e.max:p>=e.max))return n("Must be {{1}} {{2}}",e.maxInclusive?"≤":"<",e.max);if(e.step!==void 0){const g=Number(e.step);if(!Number.isInteger(g))return n("Invalid step value");if(p%g!==0)return n("Must be a multiple of {{1}}",g)}return U(a,e,p,n)??null},[e,a,n,c]),m=s.useRef(null),l=s.useRef(o);s.useEffect(()=>{l.current=o},[o]),s.useEffect(()=>{const u=String(t??""),p=f(u);p!==m.current&&(m.current=p,l.current?.(p??null)),i.current&&document.activeElement!==i.current&&(i.current.value=u)},[t,e,f,n]);const d=u=>{const p=u.target.value,h=f(p);r?.(p,h)};return b.jsx(W,{field:e,error:f(String(t??"")),children:b.jsx("input",{id:e.name,type:"text",defaultValue:String(t??""),ref:i,onChange:d,className:G(A.input,A.inputNumber)})})},Rr=({field:e,value:t,onChange:r,onError:o})=>{const{t:n,definitionName:a}=T(),i=e.minHeight??"80px",c=s.useRef(null),f=s.useRef(null),m=s.useRef(o);s.useEffect(()=>{m.current=o},[o]);const l=s.useCallback(p=>p.trim()===""?e.required?n("Value required"):null:e.minLength!==void 0&&p.length<e.minLength?n("Must be at least {{1}} characters",e.minLength):e.maxLength!==void 0&&p.length>e.maxLength?n("Must be at most {{1}} characters",e.maxLength):U(a,e,p,n),[e,a,n]),d=p=>{const h=p.target.value,g=l(h);r?.(h,g)};s.useEffect(()=>{const p=l(t);p!==f.current&&(f.current=p,m.current?.(p??null)),c.current&&c.current.value!==String(t??"")&&(c.current.value=String(t??""))},[t,l]);const u={defaultValue:String(t??""),ref:c,onChange:d,style:{resize:"vertical",minHeight:i,width:"100%",boxSizing:"border-box"},className:G(A.input,A.textInput)};return b.jsx(W,{field:e,error:l(t),children:b.jsx("textarea",{...u})})},Er=({field:e,value:t,onChange:r,onError:o})=>{const n=s.useRef(o);s.useEffect(()=>{n.current=o},[o]);const{t:a,darkMode:i,formStyle:c,fieldStyle:f,definitionName:m}=T(),l=(S,E,I)=>{if(!E)return{};const V=S?.[E];return(I&&V?V[I]:void 0)??{}},d=s.useRef(null),[u,p]=s.useState(!1),[h,g]=s.useState(null),x=s.useMemo(()=>e.options.map(S=>({value:S.value,label:a(S.label)})),[e.options,a]),v=s.useMemo(()=>{const S=Array.isArray(t)?t:[],E=new Set(x.map(I=>I.value));return S.filter(I=>E.has(I))},[t,x]),C=S=>{const E=Array.isArray(S)?S:[];return e.required&&E.length===0?a("Value required"):U(m,e,E,a)??null},k=()=>{if(!d.current)return;const S=d.current.getBoundingClientRect();g({x:S.left,y:S.bottom}),p(E=>!E)},O=S=>{const E=v.includes(S)?v.filter(M=>M!==S):[...v,S],I=C(E);n.current?.(I??null),r?.(E,I)},w=s.useMemo(()=>({height:"var(--reactaform-input-height, 2.5rem)",padding:"var(--reactaform-input-padding, 8px)",display:"flex",alignItems:"center",boxSizing:"border-box",cursor:"pointer",position:"relative",borderRadius:"var(--reactaform-border-radius, 4px)",border:"1px solid var(--reactaform-border-color, #ccc)",background:"var(--reactaform-secondary-bg, #fff)",color:"var(--reactaform-text-color, #000)",...l(c,"multiSelect","control"),...l(f,void 0,"control")}),[c,f]),R=s.useMemo(()=>({position:"absolute",right:"1.5em",top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",fontSize:"0.8em",color:"var(--reactaform-text-muted, #999)",padding:0,...l(c,"multiSelect","clearButton"),...l(f,void 0,"clearButton")}),[c,f]),j=s.useMemo(()=>({position:"absolute",right:"0.7em",top:"50%",transform:"translateY(-50%)",pointerEvents:"none",fontSize:"0.8em",color:"var(--reactaform-text-muted, #999)",...l(c,"multiSelect","arrow"),...l(f,void 0,"arrow")}),[c,f]);return b.jsxs("div",{children:[b.jsx(W,{field:e,error:null,children:b.jsx("div",{style:{width:"100%"},children:b.jsxs("div",{ref:d,className:"reactaform-multiselection-control",style:w,onClick:k,tabIndex:0,role:"button","aria-haspopup":"listbox","aria-expanded":u,onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),k())},children:[b.jsxs("span",{style:{flex:1,color:"var(--reactaform-text-muted, #888)"},children:[v.length," / ",x.length," selected"]}),v.length>0&&b.jsx("button",{type:"button","aria-label":"Clear selections",onClick:S=>{S.stopPropagation(),r?.([],null)},style:R,children:b.jsx("span",{style:R,"aria-hidden":!0,children:"✖"})}),b.jsx("span",{style:j,"aria-hidden":!0,children:"▼"})]})})}),u&&h&&b.jsx(jr,{position:h,options:x,selectedValues:v,onToggleOption:O,onClose:()=>p(!1),controlRef:d,darkMode:i})]})},jr=({position:e,options:t,selectedValues:r,onToggleOption:o,onClose:n,controlRef:a,darkMode:i})=>{const c=s.useRef(null),[f,m]=s.useState(-1),{formStyle:l,fieldStyle:d}=T(),u=(R,j,S)=>{if(!j)return{};const I=R?.[j];return(S&&I?I[S]:void 0)??{}},p=s.useMemo(()=>({maxHeight:200,overflowY:"auto",background:"var(--reactaform-secondary-bg, #fff)",border:"1px solid var(--reactaform-border-color, #ccc)",borderRadius:4,zIndex:2e3,boxShadow:"var(--reactaform-shadow, 0 2px 8px rgba(0,0,0,0.15))",pointerEvents:"auto",color:"var(--reactaform-text-color, #000)",fontSize:"var(--reactaform-popup-font-size, 0.875rem)",...u(l,"multiSelect","popup"),...u(d,void 0,"popup")}),[l,d]),h=s.useMemo(()=>({padding:"6px 8px",cursor:"pointer",display:"flex",alignItems:"center",background:"transparent",color:"var(--reactaform-text-color, #000)",...u(l,"multiSelect","option"),...u(d,void 0,"option")}),[l,d]);s.useEffect(()=>{const R=j=>{const S=j.target;!c.current?.contains(S)&&!a.current?.contains(S)&&n()};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[n,a]),s.useEffect(()=>{c.current&&t.length>0&&requestAnimationFrame(()=>m(R=>R===-1?0:R))},[t.length]),s.useEffect(()=>{if(!c.current||f<0)return;const R=c.current.querySelector(`#multi-opt-${f}`);R&&requestAnimationFrame(()=>R.focus())},[f]);const g=250,x=200,[v,C]=s.useState(null),[k,O]=s.useState(null);if(s.useEffect(()=>{if(typeof window>"u")return;const R=()=>{let E=e.x,I=e.y,M=g;const V=a?.current;if(V){const $=V.getBoundingClientRect();E=$.left,I=$.bottom,M=Math.max(80,Math.round($.width))}E=Math.min(E,window.innerWidth-M),I=Math.min(I,window.innerHeight-x),C({left:E,top:I}),O(M)};R(),window.addEventListener("scroll",R,!0),window.addEventListener("resize",R);let j=null;const S=a?.current;return typeof ResizeObserver<"u"&&S&&(j=new ResizeObserver(()=>R()),j.observe(S)),()=>{window.removeEventListener("scroll",R,!0),window.removeEventListener("resize",R),j&&S&&j.unobserve(S)}},[a,e.x,e.y]),typeof window>"u")return null;let w=document.getElementById("popup-root");return w||(w=document.createElement("div"),w.id="popup-root",document.body.appendChild(w)),Fe.createPortal(b.jsx("div",{ref:c,role:"listbox","aria-activedescendant":f>=0?`multi-opt-${f}`:void 0,style:{position:"absolute",top:v?v.top:e.y,left:v?v.left:e.x,width:k??g,...p},"data-reactaform-theme":i?"dark":"light",children:t.map((R,j)=>{const S=r.includes(R.value),E=i?"var(--reactaform-hover-bg, rgba(255,255,255,0.01))":"var(--reactaform-hover-bg, #eee)",I={...h,background:j===f?E:h.background};return b.jsxs("div",{id:`multi-opt-${j}`,onMouseDown:M=>{M.stopPropagation(),o(R.value)},onKeyDown:M=>{const V=t.length;switch(M.key){case"ArrowDown":M.preventDefault(),m($=>($+1)%V);break;case"ArrowUp":M.preventDefault(),m($=>($-1+V)%V);break;case"Home":M.preventDefault(),m(0);break;case"End":M.preventDefault(),m(V-1);break;case"Enter":case" ":M.preventDefault(),M.stopPropagation(),o(R.value);break;case"Escape":M.preventDefault(),n(),a?.current?.focus();break}},tabIndex:j===f?0:-1,role:"option","aria-selected":S,style:I,onMouseEnter:M=>{M.currentTarget.style.background=E,m(j)},onMouseLeave:M=>{M.currentTarget.style.background="transparent",m(V=>V===j?-1:V)},children:[b.jsx("input",{type:"checkbox",checked:S,readOnly:!0,style:{marginRight:8,width:"1.125em",height:"1.125em",verticalAlign:"middle",accentColor:i?"#10b981":"#22c55e",cursor:"pointer"}}),R.label]},R.value)})}),w)},kr=({field:e,value:t,onChange:r,onError:o})=>{const{t:n,definitionName:a}=T(),i=s.useRef(null),c=e.min??void 0,f=e.max??void 0,m=Math.max(1,Math.round(e.step??1)),l=s.useCallback(g=>isNaN(g)?n("Must be a valid integer"):Number.isInteger(g)?c!==void 0&&g<c?n("Must be �?{{1}}",c):f!==void 0&&g>f?n("Must be �?{{1}}",f):U(a,e,g,n)??null:n("Must be an integer"),[a,e,n,c,f]),d=s.useRef(null),u=s.useRef(o);s.useEffect(()=>{u.current=o},[o]),s.useEffect(()=>{if(document.activeElement===i.current)return;const x=String(t),v=l(t);i.current&&(i.current.value=x),v!==d.current&&(d.current=v,u.current?.(v??null))},[t,l]);const p=g=>{if(g.trim()==="")return e.required?n("Value required"):null;const v=Number(g);return l(v)},h=g=>{const x=g.target.value,v=g.target.valueAsNumber,C=p(x);r?.(v,C)};return b.jsx(W,{field:e,error:p(String(t??"")),children:b.jsx("input",{ref:i,id:e.name,type:"number",defaultValue:String(t??""),min:c,max:f,step:m,onChange:h,style:{width:"100%",height:"100%"},className:A.input})})},Ir=({field:e,value:t,onChange:r,onError:o})=>{const{t:n}=T(),a=s.useRef(null),{definitionName:i}=T(),c=s.useCallback(d=>{const u=String(d??"").trim();if(u==="")return e.required?n("Value required"):null;if(e.pattern)try{if(!new RegExp(e.pattern).test(u))return n("Phone number does not match pattern: {{1}}",`${e.pattern}`)}catch{}return U(i,e,u,n)},[i,e,n]),f=s.useRef(null),m=s.useRef(o);s.useEffect(()=>{m.current=o},[o]),s.useEffect(()=>{const d=String(t??""),u=c(d);a.current&&a.current.value!==String(d)&&(a.current.value=String(d)),u!==f.current&&(f.current=u,m.current?.(u??null))},[t,c]);const l=d=>{const u=d.target.value,p=u.trim();let h=null;if(p===""){h=e.required?n("Value required"):null,r?.(u,h);return}!h&&e.pattern&&!new RegExp(e.pattern).test(p)&&(h=n("Phone number does not match pattern: {{1}}",`${e.pattern}`)),r?.(u,h)};return b.jsx(W,{field:e,error:c(String(t??"")),children:b.jsx("input",{type:"tel",defaultValue:String(t??""),ref:a,onChange:l,className:G(A.input,A.textInput)})})},Nr=({field:e,value:t,onChange:r,onError:o})=>{const{t:n,definitionName:a}=T(),i=e.layout?.toLowerCase()==="horizontal"?"row":"column",c=s.useRef(null),f=s.useRef(o);s.useEffect(()=>{f.current=o},[o]);const m=s.useCallback(d=>d===""||d===null||d===void 0?n("Value required"):!e.options||e.options.length===0?null:e.options.some(p=>p.value===d)?U(a,e,d,n)??null:n("Invalid option selected"),[e,n,a]);s.useEffect(()=>{const d=t!=null?String(t):"",u=m(d);if(f.current?.(u??null),c.current){const p=Array.from(c.current.querySelectorAll("input[type=radio]"));if(u&&e.options&&e.options.length>0){const h=String(e.options[0].value);p.forEach(g=>g.checked=g.value===h),r?.(h,null)}else p.forEach(h=>h.checked=h.value===d)}},[t,m,r,e.options]);const l=d=>{const u=d.target.value,p=m(u);f.current?.(p??null),r?.(u,p)};return b.jsx(W,{field:e,error:m(String(t??"")),children:b.jsx("div",{style:{display:"flex",flexDirection:i,flexWrap:i==="row"?"wrap":"nowrap",gap:i==="row"?"12px":"4px",alignItems:i==="row"?"center":"flex-start",width:"100%"},ref:c,children:(e.options??[]).map(d=>b.jsxs("label",{style:{display:"flex",gap:"6px",alignItems:"center",whiteSpace:"nowrap"},children:[b.jsx("input",{type:"radio",name:e.name,value:String(d.value),defaultChecked:String(t??"")===String(d.value),onChange:l}),n(d.label)]},String(d.value)))})})},Or={display:"flex",gap:4},Mr={cursor:"pointer",fontSize:"1.5rem",lineHeight:1,display:"inline-block",marginRight:"0.25rem",userSelect:"none",transition:"color 0.12s ease"},Ar=({field:e,value:t,onChange:r,onError:o})=>{const{t:n,definitionName:a}=T(),[i,c]=s.useState(null),f=e.max||5,m=s.useCallback(h=>e.required&&h===0?n("Value required"):U(a,e,h,n)??null,[e,n,a]),l=s.useRef(null),d=s.useRef(o);s.useEffect(()=>{d.current=o},[o]),s.useEffect(()=>{let h=t||0;t<0&&(h=0),t>f&&(h=f);const g=m(h);g!==l.current&&(l.current=g,d.current?.(g??null))},[t,m,f]);const u=h=>{const g=m(h);r?.(h,g)},p=(()=>{let h=t||0;return h<0&&(h=0),h>f&&(h=f),h})();return b.jsx(W,{field:e,error:m(p),children:b.jsx("div",{style:Or,children:(()=>{const h=e.icon,g=h&&String(h).trim()?String(h):"★";return[...Array(f)].map((x,v)=>{const C=v<p,O=i!==null&&v<=i||C?"gold":"lightgray";return b.jsx("span",{onClick:()=>u(v+1),onMouseEnter:()=>c(v),onMouseLeave:()=>c(null),style:{...Mr,color:O},"aria-label":`Rating ${v+1}`,title:n(`${e.displayName} ${v+1}`),children:g},v)})})()})})},Fr=/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/;function zr(e){return Fr.test(e)}const Vr=({field:e,value:t,onChange:r,onError:o})=>{const{t:n,definitionName:a}=T(),i=s.useRef(null),c=s.useRef(null),f=s.useCallback(h=>{let g=null;if(h.trim()==="")return n("Value required");if(!zr(h))return n("Invalid number");const x=Number(h);return typeof e.min=="number"&&x<e.min?n("Value should be at least {{1}}",e.min):typeof e.max=="number"&&x>e.max?n("Value should be at most {{1}}",e.max):(g||(g=U(a,e,x,n)),g)},[a,e,n]),m=s.useRef(null),l=s.useRef(o);s.useEffect(()=>{l.current=o},[o]),s.useEffect(()=>{const h=String(t),g=f(h);c.current&&document.activeElement!==c.current&&(c.current.value=isNaN(Number(h))?String(e.min??0):String(Number(h))),i.current&&document.activeElement!==i.current&&(i.current.value=h),g!==m.current&&(m.current=g,l.current?.(g??null))},[t,f,e.min]);const d=e.min??0,u=e.max??100,p=h=>{const g=h.target.value,x=f(g);r?.(g,x)};return b.jsx(W,{field:e,error:f(String(t??"")),children:b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",width:"100%"},children:[b.jsx("input",{ref:c,type:"range",defaultValue:isNaN(Number(t))?String(d):String(Number(t)),onChange:p,min:d,max:u,style:{padding:"0px, 0px",flex:1},className:A.rangeInput}),b.jsx("input",{ref:i,type:"text",defaultValue:String(t??""),onChange:p,required:!0,style:{width:"40px",minWidth:"40px",height:"2.3em",textAlign:"center",flexShrink:0},className:G(A.input,A.textInput)})]})})},$r=({field:e,value:t,onChange:r,onError:o})=>{const{t:n,formStyle:a,fieldStyle:i,definitionName:c}=T(),f=a,m=i,l=(w,R,j)=>{if(!R)return{};const S=w?.[R];return(j&&S?S[j]:void 0)??{}},d=s.useMemo(()=>({display:"inline-block",position:"relative",width:44,height:24,...l(f,"switch","label"),...l(m,void 0,"label")}),[f,m]),u=s.useMemo(()=>({position:"absolute",opacity:0,top:0,left:0,width:"100%",height:"100%",margin:0,cursor:"pointer",pointerEvents:"none",...l(f,"switch","hiddenInput"),...l(m,void 0,"hiddenInput")}),[f,m]),p=s.useMemo(()=>({position:"absolute",cursor:"pointer",top:0,left:0,right:0,bottom:0,backgroundColor:"var(--reactaform-switch-off-bg, #ccc)",transition:"0.3s",borderRadius:24,borderWidth:2,borderStyle:"solid",borderColor:"transparent",...l(f,"switch","slider"),...l(m,void 0,"slider")}),[f,m]),h=s.useMemo(()=>({position:"absolute",height:16,width:16,left:2,bottom:2,backgroundColor:"white",transition:"0.3s",borderRadius:"50%",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.3)",...l(f,"switch","knob"),...l(m,void 0,"knob")}),[f,m]),g=!!t,x=s.useRef(null),v=s.useRef(o),C=s.useCallback(w=>w?U(c,e,w,n)??null:e.required?n("Value required"):null,[e,n,c]),k=()=>{const w=!g,R=C(w);r?.(w,R)};s.useEffect(()=>{v.current=o},[o]),s.useEffect(()=>{const w=C(g);w!==x.current&&(x.current=w,v.current?.(w??null))},[g,e,C]);const O=e.name;return b.jsx(W,{field:e,error:C(g),rightAlign:!1,children:b.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[b.jsx("label",{className:A.label,htmlFor:O,style:{textAlign:"left",justifyContent:"flex-start"},children:n(e.displayName)}),b.jsxs("label",{style:d,children:[b.jsx("input",{id:e.name,type:"checkbox",checked:g,readOnly:!0,"aria-label":n(e.displayName),style:u,tabIndex:-1}),b.jsx("span",{role:"switch","data-testid":"switch",tabIndex:0,"aria-checked":g,onClick:k,onKeyDown:w=>{(w.key===" "||w.key==="Spacebar"||w.key==="Space"||w.key==="Enter")&&(w.preventDefault(),k())},className:`reactaform-switch ${g?"active checked on":""} `,style:g?{...p,backgroundColor:"var(--reactaform-switch-on-bg, #22c55e)",borderColor:"var(--reactaform-switch-on-border, #16a34a)"}:p,children:b.jsx("span",{style:{...h,transform:g?"translateX(20px)":void 0}})})]})]})})},Xe=({field:e,value:t,onChange:r,onError:o})=>{const{t:n,definitionName:a}=T(),i=s.useRef(null),c=s.useRef(null),f=s.useRef(o);s.useEffect(()=>{f.current=o},[o]);const m=s.useMemo(()=>e.pattern?new RegExp(e.pattern):null,[e.pattern]),l=s.useCallback(u=>u.trim()===""?e.required?n("Value required"):null:e.minLength!==void 0&&u.length<e.minLength?n("Must be at least {{1}} characters",e.minLength):e.maxLength!==void 0&&u.length>e.maxLength?n("Must be at most {{1}} characters",e.maxLength):m&&!m.test(u)?n("Input does not match pattern: {{1}}",e.pattern):U(a,e,u,n),[e,a,n,m]),d=u=>{const p=u.target.value,h=l(p);r?.(p,h)};return s.useEffect(()=>{const u=l(t);i.current&&i.current.value!==String(t??"")&&(i.current.value=String(t??"")),u!==c.current&&(c.current=u,f.current?.(u??null))},[t,l]),b.jsx(W,{field:e,error:l(String(t??"")),children:b.jsx("input",{id:e.name,type:"text",defaultValue:String(t??""),ref:i,onChange:d,className:G(A.input,A.textInput)})})},Tr=({field:e,value:t,onChange:r,onError:o})=>{const{t:n,definitionName:a}=T(),i=s.useRef(null),c=s.useRef(o),f=e.includeSeconds??!0;s.useEffect(()=>{c.current=o},[o]);const m=s.useCallback(d=>{if(!d||d.trim()==="")return e.required||e.min||e.max?n("Value required"):null;const u=g=>{const x=g.split(":").map(C=>parseInt(C,10));if(x.some(C=>Number.isNaN(C)))return NaN;let v=0;if(x.length===3)v=x[0]*3600+x[1]*60+x[2];else if(x.length===2)v=x[0]*3600+x[1]*60;else if(x.length===1)v=x[0]*3600;else return NaN;return v},p=u(d);if(Number.isNaN(p))return n("Invalid time format");if(e.min&&typeof e.min=="string"){const g=u(e.min);if(!Number.isNaN(g)&&p<g)return n("Time must be on or after {{1}}",e.min)}if(e.max&&typeof e.max=="string"){const g=u(e.max);if(!Number.isNaN(g)&&p>g)return n("Time must be on or before {{1}}",e.max)}return U(a,e,d,n)??null},[e,a,n]),l=d=>{const u=d.target.value,p=m(u);r?.(u,p)};return s.useEffect(()=>{const d=m(t);d!==i.current&&(i.current=d,c.current?.(d??null))},[t,m]),b.jsx(W,{field:e,error:m(t),children:b.jsx("input",{id:e.name,type:"time",value:t,step:f?1:60,onChange:l,min:typeof e.min=="string"?e.min:void 0,max:typeof e.max=="string"?e.max:void 0,className:G(A.input,A.textInput)})})},he={};function Pr(e,t){if(e in he)return;const r=De[e]??{},o={},n={},a={};for(const[c,f]of Object.entries(r))typeof f.factor=="number"&&(o[c]=f.factor),n[c]=t(c),a[t(c)]=c;const i=Object.keys(r)[0]??"";he[e]={default:i,factors:o,labels:n,reverseLabels:a}}function Dr(e,t,r){if(e==="C"){if(t==="F")return r*(9/5)+32;if(t==="K")return r+273.15}else if(e==="F"){if(t==="C")return(r-32)*5/9;if(t==="K")return(r-32)*5/9+273.15}else if(e==="K"){if(t==="C")return r-273.15;if(t==="F")return(r-273.15)*9/5+32}return r}function Lr(e,t,r){if(!Number.isFinite(e))return[];if(r===he.temperature)return Object.keys(r.labels).map(a=>{const i=Dr(t,a,e);return Number.isFinite(i)?{label:`${i.toFixed(6)} ${a}`,value:i.toString(),unit:a}:{label:`${String(i)} ${a}`,value:String(i),unit:a}});const n=r.factors[t];return n===void 0?[]:Object.entries(r.factors).map(([a,i])=>{const c=e/n*i;return Number.isFinite(c)?{label:`${c.toFixed(6)} ${a}`,value:c.toString(),unit:a}:{label:`${String(c)} ${a}`,value:String(c),unit:a}})}function ve(e,t){return e in t.labels?e:t.reverseLabels&&t.reverseLabels[e]?t.reverseLabels[e]:null}const _r=/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/,qr=({unitFactors:e,field:t,value:r,onChange:o,onError:n})=>{const{t:a,definitionName:i}=T(),c=s.useRef(null),f=s.useRef(null),m=s.useRef(null),[l,d]=s.useState(null),[u,p]=s.useState(null),[h,g]=s.useState(!1),[x,v]=s.useState(null),[C,k]=s.useState([]),O=s.useCallback((D,F)=>{if(!D||D.trim()==="")return t.required?a("Value required"):null;if(!_r.test(D))return a("Must be a valid number");const y=U(i,t,[D,F],a);return y||null},[i,t,a]),w=e.reverseLabels!==void 0?e.reverseLabels:Object.fromEntries(Object.entries(e.labels).map(([D,F])=>[F,D]));s.useEffect(()=>{const D=String(r[0]);let F=r[1]??e.default;F=ve(F,e)||F;const y=document.activeElement;y===c.current||y===f.current||(c.current&&(c.current.value=D),f.current&&(f.current.value=F),m.current!==null&&(cancelAnimationFrame(m.current),m.current=null),m.current=requestAnimationFrame(()=>{m.current=null,d(null),p(null)}))},[r,e]),s.useEffect(()=>()=>{m.current!==null&&(cancelAnimationFrame(m.current),m.current=null)},[]);const R=s.useRef(null),j=s.useRef(n);s.useEffect(()=>{j.current=n},[n]),s.useEffect(()=>{const D=String(r[0]);let F=r[1]??e.default;F=ve(F,e)||F;const y=O(D,F);y!==R.current&&(R.current=y,j.current?.(y??null))},[r,e,O]);const S=(D,F,y)=>{const N=w[F]||F;o?.([D,N],y)},E=D=>{const F=D.target.value,y=f.current?f.current.value:e.default,N=O(F,y);d(F),S(F,y,N)},I=D=>{const F=D.target.value,y=c.current?c.current.value:String(r[0]??""),N=O(y,F);p(F),f.current&&(f.current.value=F),S(y,F,N)},M=D=>{const F=c.current?c.current.value:String(r[0]??""),y=parseFloat(F),N=f.current?f.current.value:e.default;if(O(F,N)||!F.trim()||!Number.isFinite(y))return;const q=D.currentTarget.getBoundingClientRect(),Z=q.left,ee=q.bottom;v({x:Z,y:ee});const H=Lr(y,N,e);if(H.length===0){k([]),g(!1);return}k(H),g(Q=>!Q)},V=D=>{const{value:F,unit:y}=D;g(!1),v(null),c.current&&(c.current.value=F),f.current&&(f.current.value=y),d(F),p(y);const N=O(F,y);S(F,y,N)},$=String(r[0]??""),L=ve(r[1]??e.default,e)||(r[1]??e.default),Y=l??$,K=!!O(Y,u??L)||!Y.trim(),se={width:"var(--reactaform-unit-btn-width, 2.5em)",height:"var(--reactaform-unit-btn-height, 2.5em)",padding:"var(--reactaform-unit-btn-padding, 0)",border:"none",borderRadius:"var(--reactaform-button-border-radius, var(--reactaform-border-radius, 0.25em))",backgroundColor:K?"var(--reactaform-button-disabled-bg, #cccccc)":"var(--reactaform-button-bg, var(--reactaform-success-color))",color:"var(--reactaform-button-text, #ffffff)",cursor:K?"var(--reactaform-button-disabled-cursor, not-allowed)":"pointer",opacity:K?+"var(--reactaform-button-disabled-opacity, 0.6)":1,display:"flex",alignItems:"center",justifyContent:"center"};return b.jsx(W,{field:t,error:O($,L),children:b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--reactaform-unit-gap, 8px)",width:"100%"},children:[b.jsx("input",{type:"text",ref:c,defaultValue:String(r[0]??""),onChange:E,style:{width:"var(--reactaform-unit-input-width, 100px)"},className:G(A.input,A.textInput)}),b.jsx("select",{ref:f,defaultValue:ve(r[1]??e.default,e)||(r[1]??e.default),onChange:I,className:G(A.input,A.inputSelect),children:Object.keys(e.labels).map(D=>b.jsx("option",{value:D,children:e.labels[D]??D},D))}),b.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[b.jsx("button",{onClick:M,"aria-disabled":K,disabled:K,style:se,className:A.button,children:b.jsx("span",{style:{fontSize:"var(--reactaform-unit-btn-icon-size, 1em)",lineHeight:"1",transform:"translateY(-1px)",pointerEvents:"none"},children:"⟷"})}),h&&C&&b.jsx(pt,{pos:x,options:C,onClose:()=>{v(null),g(!1)},onClickOption:V})]})]})})};function Br({field:e,value:t,onChange:r}){const{t:o}=T(),n=e.dimension;if(!n)return null;he[n]||Pr(n,o);const a=he[n];return a?b.jsx(qr,{unitFactors:a,field:e,value:t,onChange:r}):null}const Hr=/^(https?|ftp|file):\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|]$/i,Wr=e=>{try{return new URL(e),!0}catch{return!1}},Ur=({field:e,value:t,onChange:r,onError:o})=>{const{t:n,definitionName:a}=T(),i=s.useRef(null),c=s.useCallback(d=>{const u=d.trim();return u===""?e.required?n("Value required"):null:!Hr.test(u)&&!Wr(u)?n("Must be a valid URL"):U(a,e,u,n)??null},[a,e,n]),f=d=>{const u=d.target.value,p=c(u);r?.(u.trim(),p)},m=s.useRef(null),l=s.useRef(o);return s.useEffect(()=>{l.current=o},[o]),s.useEffect(()=>{const d=t??"",u=c(d);i.current&&i.current.value!==String(d)&&(i.current.value=String(d)),u!==m.current&&(m.current=u,l.current?.(u??null))},[t,c]),b.jsx(W,{field:e,error:c(String(t??"")),children:b.jsx("input",{id:e.name,type:"url",defaultValue:String(t??""),ref:i,onChange:f,style:{alignItems:"left"},className:G(A.input,A.textInput),placeholder:"https://example.com"})})},Ae=new we,Yr=new Set(["checkbox","switch","dropdown","radio","multi-selection","slider","stepper","color","rating"]),gt={checkbox:tr,color:nr,date:ar,dropdown:sr,email:cr,file:ur,float:br,"float-array":pr,image:xr,int:Cr,"int-array":wr,"multi-selection":Er,multiline:Rr,phone:Ir,radio:Nr,rating:Ar,separator:lr,slider:Vr,string:Xe,stepper:kr,switch:$r,text:Xe,time:Tr,unit:Br,url:Ur};function ht(e,t,r){if(!r&&e in gt){console.warn(`Can't Overwrite Base Component type "${e}".`);return}if(Yr.has(e)){Ae.register(e,t);return}const o=n=>{const{callback:i,cancel:c}=rt((...f)=>{const m=n.onChange;typeof m=="function"&&m(...f)},200);return s.useEffect(()=>()=>{c()},[c]),s.createElement(t,{...n,onChange:i})};Ae.register(e,o)}function Jr(e,t){ht(e,t,!1)}function Le(e){return Ae.get(e)}let Ze=!1;function bt(){Ze||(Object.entries(gt).forEach(([e,t])=>{ht(e,t,!0)}),Ze=!0)}const yt=new we;function xt(e,t){yt.register(e,t)}function Gr(e){return yt.get(e)}xt("Preset_AlertSubmitHandler",(e,t,r)=>{const o={name:t||"Unnamed Instance",version:e.version,definition:e.name,values:r},n=JSON.stringify(o,null,2);alert(n)});const vt=s.memo(({field:e,value:t,handleChange:r,handleError:o})=>{const n=Le(e.type),a=s.useCallback((c,f)=>r(e.name,c,f),[r,e.name]),i=s.useCallback(c=>o?.(e.name,c),[o,e.name]);return n?b.jsx(n,{field:e,value:t,onChange:a,onError:i}):null},(e,t)=>e.field===t.field&&e.value===t.value&&e.handleChange===t.handleChange&&e.handleError===t.handleError);vt.displayName="FieldWrapper";const wt=(e,t,r,o)=>b.jsx(vt,{field:e,value:t[e.name],handleChange:r,handleError:o},e.name),St=s.memo(({groupName:e,isOpen:t,fields:r,valuesMap:o,handleChange:n,handleError:a,toggleGroup:i,t:c})=>{const f=s.useCallback(()=>i(e),[i,e]),{formStyle:m,fieldStyle:l}=T(),d=s.useMemo(()=>({border:"1px solid var(--reactaform-border-color, #bbb)",padding:"var(--reactaform-fieldset-padding, 0.5em)",borderRadius:"var(--reactaform-border-radius, 4px)",marginBottom:"var(--reactaform-space, 8px)",...m?.fieldset||{},...l?.fieldset||{}}),[m,l]),u=s.useMemo(()=>({fontWeight:"bold",cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0 var(--reactaform-space, 8px)",color:"var(--reactaform-text-color, inherit)",...m?.legend||{},...l?.legend||{}}),[m,l]);return b.jsxs("fieldset",{style:d,children:[b.jsxs("legend",{onClick:f,style:u,children:[b.jsx("span",{children:c(e)}),b.jsx("span",{children:t?"▼":"▶"})]}),t&&r.map(p=>b.jsx("div",{children:wt(p,o,n,a)},p.name))]})});St.displayName="FieldGroup";const Kr=(e,t,r,o,n,a,i,c,f)=>{const m=t.slice(0,c).filter(p=>i[p.name]),d=ut(m).groups,u=[];return d.forEach(p=>{if(p.name){const h=e[p.name]??!0;u.push(b.jsx(St,{groupName:p.name,isOpen:h,fields:p.fields,valuesMap:r,handleChange:n,handleError:a,toggleGroup:f,t:o},p.name))}else p.fields.forEach(h=>u.push(b.jsx("div",{children:wt(h,r,n,a)},h.name)))}),u},be=typeof window<"u"?s.useLayoutEffect:s.useEffect;function Qe(e){if(e!==void 0)switch(typeof e){case"number":return e;case"string":{if(e.endsWith("px"))return parseFloat(e);break}}}function Xr({box:e,defaultHeight:t,defaultWidth:r,disabled:o,element:n,mode:a,style:i}){const{styleHeight:c,styleWidth:f}=s.useMemo(()=>({styleHeight:Qe(i?.height),styleWidth:Qe(i?.width)}),[i?.height,i?.width]),[m,l]=s.useState({height:t,width:r}),d=o||c!==void 0||a==="only-width"||c!==void 0&&f!==void 0;return be(()=>{if(n===null||d)return;const u=new ResizeObserver(p=>{for(const h of p){const{contentRect:g,target:x}=h;n===x&&l(v=>v.height===g.height&&v.width===g.width?v:{height:g.height,width:g.width})}});return u.observe(n,{box:e}),()=>{u?.unobserve(n)}},[e,d,n,c,f]),s.useMemo(()=>({height:c??m.height,width:f??m.width}),[m,c,f])}function Zr(e){const t=s.useRef(()=>{throw new Error("Cannot call during render.")});return be(()=>{t.current=e},[e]),s.useCallback(r=>t.current?.(r),[t])}function je({containerElement:e,direction:t,isRtl:r,scrollOffset:o}){return o}function ne(e,t="Assertion error"){if(!e)throw console.error(t),Error(t)}function ge(e,t){if(e===t)return!0;if(!!e!=!!t||(ne(e!==void 0),ne(t!==void 0),Object.keys(e).length!==Object.keys(t).length))return!1;for(const r in e)if(!Object.is(t[r],e[r]))return!1;return!0}function Ct({cachedBounds:e,itemCount:t,itemSize:r}){if(t===0)return 0;if(typeof r=="number")return t*r;{const o=e.get(e.size===0?0:e.size-1);ne(o!==void 0,"Unexpected bounds cache miss");const n=(o.scrollOffset+o.size)/e.size;return t*n}}function Qr({align:e,cachedBounds:t,index:r,itemCount:o,itemSize:n,containerScrollOffset:a,containerSize:i}){if(r<0||r>=o)throw RangeError(`Invalid index specified: ${r}`,{cause:`Index ${r} is not within the range of 0 - ${o-1}`});const c=Ct({cachedBounds:t,itemCount:o,itemSize:n}),f=t.get(r),m=Math.max(0,Math.min(c-i,f.scrollOffset)),l=Math.max(0,f.scrollOffset-i+f.size);switch(e==="smart"&&(a>=l&&a<=m?e="auto":e="center"),e){case"start":return m;case"end":return l;case"center":return f.scrollOffset<=i/2?0:f.scrollOffset+f.size/2>=c-i/2?c-i:f.scrollOffset+f.size/2-i/2;case"auto":default:return a>=l&&a<=m?a:a<l?l:m}}function et({cachedBounds:e,containerScrollOffset:t,containerSize:r,itemCount:o,overscanCount:n}){const a=o-1;let i=0,c=-1,f=0,m=-1,l=0;for(;l<a;){const d=e.get(l);if(d.scrollOffset+d.size>t)break;l++}for(i=l,f=Math.max(0,i-n);l<a;){const d=e.get(l);if(d.scrollOffset+d.size>=t+r)break;l++}return c=Math.min(a,l),m=Math.min(o-1,c+n),i<0&&(i=0,c=-1,f=0,m=-1),{startIndexVisible:i,stopIndexVisible:c,startIndexOverscan:f,stopIndexOverscan:m}}function en({itemCount:e,itemProps:t,itemSize:r}){const o=new Map;return{get(n){for(ne(n<e,`Invalid index ${n}`);o.size-1<n;){const i=o.size;let c;switch(typeof r){case"function":{c=r(i,t);break}case"number":{c=r;break}}if(i===0)o.set(i,{size:c,scrollOffset:0});else{const f=o.get(i-1);ne(f!==void 0,`Unexpected bounds cache miss for index ${n}`),o.set(i,{scrollOffset:f.scrollOffset+f.size,size:c})}}const a=o.get(n);return ne(a!==void 0,`Unexpected bounds cache miss for index ${n}`),a},set(n,a){o.set(n,a)},get size(){return o.size}}}function tn({itemCount:e,itemProps:t,itemSize:r}){return s.useMemo(()=>en({itemCount:e,itemProps:t,itemSize:r}),[e,t,r])}function rn({containerSize:e,itemSize:t}){let r;switch(typeof t){case"string":{ne(t.endsWith("%"),`Invalid item size: "${t}"; string values must be percentages (e.g. "100%")`),ne(e!==void 0,"Container size must be defined if a percentage item size is specified"),r=e*parseInt(t)/100;break}default:{r=t;break}}return r}function nn({containerElement:e,containerStyle:t,defaultContainerSize:r=0,direction:o,isRtl:n=!1,itemCount:a,itemProps:i,itemSize:c,onResize:f,overscanCount:m}){const[l,d]=s.useState({startIndexVisible:0,startIndexOverscan:0,stopIndexVisible:-1,stopIndexOverscan:-1}),{startIndexVisible:u,startIndexOverscan:p,stopIndexVisible:h,stopIndexOverscan:g}={startIndexVisible:Math.min(a-1,l.startIndexVisible),startIndexOverscan:Math.min(a-1,l.startIndexOverscan),stopIndexVisible:Math.min(a-1,l.stopIndexVisible),stopIndexOverscan:Math.min(a-1,l.stopIndexOverscan)},{height:x=r,width:v=r}=Xr({defaultHeight:r,defaultWidth:void 0,element:e,mode:"only-height",style:t}),C=s.useRef({height:0,width:0}),k=x,O=rn({containerSize:k,itemSize:c});s.useLayoutEffect(()=>{if(typeof f=="function"){const I=C.current;(I.height!==x||I.width!==v)&&(f({height:x,width:v},{...I}),I.height=x,I.width=v)}},[x,f,v]);const w=tn({itemCount:a,itemProps:i,itemSize:O}),R=s.useCallback(I=>w.get(I),[w]),j=s.useCallback(()=>Ct({cachedBounds:w,itemCount:a,itemSize:O}),[w,a,O]),S=s.useCallback(I=>{const M=je({containerElement:e,direction:o,isRtl:n,scrollOffset:I});return et({cachedBounds:w,containerScrollOffset:M,containerSize:k,itemCount:a,overscanCount:m})},[w,e,k,o,n,a,m]);be(()=>{const I=e?.scrollTop??0;d(S(I))},[e,o,S]),be(()=>{if(!e)return;const I=()=>{d(M=>{const{scrollLeft:V,scrollTop:$}=e,L=je({containerElement:e,direction:o,isRtl:n,scrollOffset:$}),Y=et({cachedBounds:w,containerScrollOffset:L,containerSize:k,itemCount:a,overscanCount:m});return ge(Y,M)?M:Y})};return e.addEventListener("scroll",I),()=>{e.removeEventListener("scroll",I)}},[w,e,k,o,a,m]);const E=Zr(({align:I="auto",containerScrollOffset:M,index:V})=>{let $=Qr({align:I,cachedBounds:w,containerScrollOffset:M,containerSize:k,index:V,itemCount:a,itemSize:O});if(e){if($=je({containerElement:e,direction:o,isRtl:n,scrollOffset:$}),typeof e.scrollTo!="function"){const L=S($);ge(l,L)||d(L)}return $}});return{getCellBounds:R,getEstimatedSize:j,scrollToIndex:E,startIndexOverscan:p,startIndexVisible:u,stopIndexOverscan:g,stopIndexVisible:h}}function on(e){return s.useMemo(()=>e,Object.values(e))}function an(e,t){const{ariaAttributes:r,style:o,...n}=e,{ariaAttributes:a,style:i,...c}=t;return ge(r,a)&&ge(o,i)&&ge(n,c)}function sn(e){return e!=null&&typeof e=="object"&&"getAverageRowHeight"in e&&typeof e.getAverageRowHeight=="function"}const cn="data-react-window-index";function ln({children:e,className:t,defaultHeight:r=0,listRef:o,onResize:n,onRowsRendered:a,overscanCount:i=3,rowComponent:c,rowCount:f,rowHeight:m,rowProps:l,tagName:d="div",style:u,...p}){const h=on(l),g=s.useMemo(()=>s.memo(c,an),[c]),[x,v]=s.useState(null),C=sn(m),k=s.useMemo(()=>C?$=>m.getRowHeight($)??m.getAverageRowHeight():m,[C,m]),{getCellBounds:O,getEstimatedSize:w,scrollToIndex:R,startIndexOverscan:j,startIndexVisible:S,stopIndexOverscan:E,stopIndexVisible:I}=nn({containerElement:x,containerStyle:u,defaultContainerSize:r,direction:"vertical",itemCount:f,itemProps:h,itemSize:k,onResize:n,overscanCount:i});s.useImperativeHandle(o,()=>({get element(){return x},scrollToRow({align:$="auto",behavior:L="auto",index:Y}){const te=R({align:$,containerScrollOffset:x?.scrollTop??0,index:Y});typeof x?.scrollTo=="function"&&x.scrollTo({behavior:L,top:te})}}),[x,R]),be(()=>{if(!x)return;const $=Array.from(x.children).filter((L,Y)=>{if(L.hasAttribute("aria-hidden"))return!1;const te=`${j+Y}`;return L.setAttribute(cn,te),!0});if(C)return m.observeRowElements($)},[x,C,m,j,E]),s.useEffect(()=>{j>=0&&E>=0&&a&&a({startIndex:S,stopIndex:I},{startIndex:j,stopIndex:E})},[a,j,S,E,I]);const M=s.useMemo(()=>{const $=[];if(f>0)for(let L=j;L<=E;L++){const Y=O(L);$.push(s.createElement(g,{...h,ariaAttributes:{"aria-posinset":L+1,"aria-setsize":f,role:"listitem"},key:L,index:L,style:{position:"absolute",left:0,transform:`translateY(${Y.scrollOffset}px)`,height:C?void 0:Y.size,width:"100%"}}))}return $},[g,O,C,f,h,j,E]),V=b.jsx("div",{"aria-hidden":!0,style:{height:w(),width:"100%",zIndex:-1}});return s.createElement(d,{role:"list",...p,className:t,ref:v,style:{position:"relative",maxHeight:"100%",flexGrow:1,overflowY:"auto",...u}},M,e,V)}const un=({fields:e,visibility:t,groupState:r,toggleGroup:o,t:n,renderField:a,containerHeight:i=600,estimatedFieldHeight:c=60})=>{const f=s.useRef(null),m=s.useMemo(()=>{const u=e.filter(g=>t[g.name]),p=ut(u),h=[];return p.groups.forEach(g=>{if(g.name){const x=r[g.name]??!0;h.push({type:"group-header",groupName:g.name,isOpen:x}),x&&g.fields.forEach(v=>{h.push({type:"field",field:v})})}else g.fields.forEach(x=>{h.push({type:"field",field:x})})}),h},[e,t,r]),l=u=>{const p=m[u];if(!p)return c;if(p.type==="group-header")return 50;const h=p.field?.type;return h==="multiline"?120:h==="separator"?30:h==="image"?200:c},d=s.useCallback(({index:u,style:p})=>{const h=m[u];return h?h.type==="group-header"&&h.groupName?b.jsx("div",{style:p,children:b.jsx("fieldset",{style:{border:"1px solid var(--reactaform-border-color, #bbb)",padding:"0",borderRadius:"var(--reactaform-border-radius, 4px)",marginBottom:"var(--reactaform-space, 8px)"},children:b.jsxs("legend",{onClick:()=>o(h.groupName),style:{fontWeight:"bold",cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0 var(--reactaform-space, 8px)",color:"var(--reactaform-text-color, inherit)"},children:[b.jsx("span",{children:n(h.groupName)}),b.jsx("span",{children:h.isOpen?"▼":"▶"})]})})}):h.type==="field"&&h.field?b.jsx("div",{style:p,children:a(h.field)},h.field.name):b.jsx("div",{style:p}):b.jsx("div",{style:p})},[m,o,a,n]);return m.length===0?b.jsx("div",{style:{padding:"var(--reactaform-space, 8px)",color:"var(--reactaform-text-muted, #666)"},children:n("No fields to display")}):b.jsx("div",{ref:f,children:b.jsx(ln,{defaultHeight:i,rowCount:m.length,rowHeight:l,rowComponent:d,rowProps:{}})})},fn=e=>{const t={};return e.forEach(r=>{t[r.name]=!1}),t},_e=(e,t,r,o)=>{const n=t[e];if(!n?.children)return;const a=r[e],i=a!=null?String(a):"";(n.children[i]||[]).forEach(f=>{o[f]=!0,_e(f,t,r,o)})},Rt=(e,t,r)=>{const o=t[e];o?.children&&Object.values(o.children).flat().forEach(n=>{r[n]=!1,Rt(n,t,r)})},mn=(e,t,r,o)=>{const n={...r};return e.forEach(a=>{(!a.parents||Object.keys(a.parents).length===0)&&(n[a.name]=!0,_e(a.name,o,t,n))}),n},dn=(e,t,r,o,n)=>{const a={...e};if(Rt(o,t,a),n!=null){const i=t[o];if(i?.children){const c=String(n);(i.children[c]||[]).forEach(m=>{a[m]=!0,_e(m,t,r,a)})}}return a};function pn(e,t,r,o,n){const a=Object.values(n).filter(Boolean);if(a.length>0)return{success:!1,message:o("Please fix validation errors before submitting."),errors:a};const i={...r},c=[];if(e&&Array.isArray(e.properties))for(const m of e.properties){const l=m.name,d=i[l];if(d==null)continue;const u=m.type;try{if((u==="int"||u==="number"||u==="float")&&typeof d=="string"){const p=Number(String(d).trim());isNaN(p)?c.push(o(`Invalid number format for field ${m.displayName||l}`)):i[l]=p}else if((u==="int-array"||u==="float-array")&&typeof d=="string"){const h=String(d).split(",").map(g=>g.trim()).filter(Boolean).map(g=>{const x=Number(g);return isNaN(x)?(c.push(o(`Invalid number "${g}" in array for field ${m.displayName||l}`)),0):x});c.length===0&&(i[l]=h)}}catch(p){c.push(o(`Error processing field ${m.displayName||l}: ${p}`))}}if(c.length>0)return{success:!1,message:o("Data transformation errors occurred."),errors:c};const f=ct(e,i,o);if(f&&f.length>0)return{success:!1,message:f.join(`
293
- `),errors:f};if(e&&typeof e.submitHandlerName=="string"){const m=Gr(e.submitHandlerName);if(m)try{const l=m(e,t?.name??null,i,o);if(l&&l.length>0)return{success:!1,message:o("Submission failed."),errors:Array.isArray(l)?l:[l]}}catch(l){return{success:!1,message:o("Submission handler error occurred."),errors:[String(l)]}}}return{success:!0,message:o("Form submitted successfully."),data:i}}const Et=({definition:e,instance:t,chunkSize:r=50,chunkDelay:o=50,enableVirtualization:n=!1,virtualizationThreshold:a=50,virtualContainerHeight:i=600,estimatedFieldHeight:c=60})=>{const{properties:f,displayName:m}=e,{t:l,formStyle:d,language:u}=T(),[p,h]=s.useState("en"),[g,x]=s.useState([]),[v,C]=s.useState({}),[k,O]=s.useState({}),[w,R]=s.useState({}),[j,S]=s.useState({}),[E,I]=s.useState({}),[M,V]=s.useState(null),[$,L]=s.useState(null),[Y,te]=s.useState(0),[K,se]=s.useState(!1),[D,F]=s.useState(!1),[y,N]=s.useState(t.name||""),P=s.useRef(t),q=s.useRef(!1);s.useEffect(()=>{const z=Object.fromEntries(f.map(B=>[B.name,{...B,children:{}}]));f.forEach(B=>{B.parents&&Object.entries(B.parents).forEach(([ue,Se])=>{const fe=z[ue];fe&&Se.forEach(Nt=>{fe.children||(fe.children={});const qe=String(Nt);fe.children[qe]=[...fe.children[qe]||[],B.name]})})}),Yt(f,z);const _=Object.values(z),J={};_.forEach(B=>{if(B.type==="unit"){const ue=typeof B.defaultValue=="number"?String(B.defaultValue):"",Se=typeof B.defaultUnit=="string"?B.defaultUnit:String(B.defaultUnit??"m");J[B.name]=[ue,Se]}else J[B.name]=B.defaultValue}),P.current=t,Object.keys(t.values).forEach(B=>{z[B]!==void 0&&(J[B]=t.values[B])});const X=fn(_),re={};_.forEach(B=>{B.group&&!(B.group in re)&&(re[B.group]=!0)});const ce=requestAnimationFrame(()=>{x(_),C(z),O(J),R(mn(_,J,X,z)),S(re),se(!0),N(t.name)});return()=>cancelAnimationFrame(ce)},[f,t,e]),s.useEffect(()=>{if(!K||Y>=g.length)return;const z=setTimeout(()=>{te(_=>Math.min(_+r,g.length))},o);return()=>clearTimeout(z)},[K,Y,g.length,r,o]);const Z=s.useCallback((z,_,J)=>{V(null),L(null),O(X=>{const re={...X,[z]:_},ce=v[z];return ce&&["checkbox","dropdown","multi-select","radio","switch"].includes(ce.type)&&R(ue=>dn(ue,v,re,z,String(_))),re}),I(X=>J?{...X,[z]:J}:Object.fromEntries(Object.entries(X).filter(([ce])=>ce!==z)))},[v,V,L]);s.useEffect(()=>{let z=0;return z=requestAnimationFrame(()=>{u!==p&&(h(u||"en"),V(null),L(null))}),()=>cancelAnimationFrame(z)},[u,p]),s.useEffect(()=>{let z=0;return z=requestAnimationFrame(()=>{if(q.current){q.current=!1,P.current=t,N(t.name||"");return}P.current=t,V(null),L(null),N(t.name||"")}),()=>cancelAnimationFrame(z)},[t,t.name]);const ee=s.useCallback((z,_)=>{I(J=>_?{...J,[z]:String(_)}:Object.fromEntries(Object.entries(J).filter(([re])=>re!==z)))},[]),H=()=>{q.current=!0;const z=P.current?.name;P.current.name=y;const _=pn(e,P.current,k,l,E),J=typeof _.message=="string"?_.message:String(_.message),X=Object.values(_.errors??{}).join(`
294
- `);V(X?J+`
295
- `+X:J),L(_.success),_.success||(P.current.name=z??P.current.name,N(z??""))},Q=z=>{S(_=>({..._,[z]:!_[z]}))},le=s.useCallback(z=>{const _=Le(z.type);return _?b.jsx("div",{children:b.jsx(_,{field:z,value:k[z.name],onChange:(J,X)=>Z(z.name,J,X),onError:J=>ee(z.name,J)})},z.name):null},[k,Z,ee]),ie=s.useMemo(()=>Object.values(E).some(Boolean),[E]),It=s.useMemo(()=>n?g.filter(_=>w[_.name]).length>=a:!1,[n,g,w,a]);return K?b.jsxs("div",{style:d.container,children:[m&&b.jsx("h2",{style:d.titleStyle,children:l(m)}),M&&b.jsxs("div",{role:"status",style:{marginBottom:12,padding:12,borderRadius:6,backgroundColor:$?"rgba(76, 175, 80, 0.12)":"rgba(225, 29, 72, 0.06)",border:`1px solid ${$?"rgba(76,175,80,0.3)":"rgba(225,29,72,0.12)"}`,color:$?"var(--reactaform-success-color, #4CAF50)":"var(--reactaform-error-color, #e11d48)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[b.jsx("div",{style:{whiteSpace:"pre-wrap",flex:1},children:M}),b.jsx("button",{onClick:()=>{V(null),L(null)},"aria-label":l("Dismiss"),style:{marginLeft:12,background:"transparent",border:"none",cursor:"pointer",color:"inherit",fontSize:16,lineHeight:1},children:"×"})]}),t&&b.jsx(at,{name:y,onChange:z=>{N(z),V(null),L(null)}}),It?b.jsx(un,{fields:g,valuesMap:k,visibility:w,groupState:j,handleChange:Z,handleError:ee,toggleGroup:Q,t:l,renderField:le,containerHeight:i,estimatedFieldHeight:c}):b.jsxs(b.Fragment,{children:[Kr(j,g,k,l,Z,ee,w,Y,Q),Y<g.length&&b.jsx("div",{style:{fontSize:"0.9em",color:"var(--reactaform-text-muted, #666)"}})]}),b.jsx("button",{onClick:H,disabled:ie,onMouseEnter:()=>F(!0),onMouseLeave:()=>F(!1),style:{padding:"var(--reactaform-button-padding, var(--reactaform-space) 12px)",backgroundColor:ie?"var(--reactaform-button-disabled-bg, #cccccc)":"var(--reactaform-button-bg, var(--reactaform-success-color))",color:"var(--reactaform-button-text, #ffffff)",border:"none",borderRadius:"4px",cursor:ie?"var(--reactaform-button-disabled-cursor, not-allowed)":"pointer",fontSize:"var(--reactaform-button-font-size, 14px)",fontWeight:"var(--reactaform-button-font-weight, 500)",boxShadow:"var(--reactaform-button-shadow, none)",marginTop:"var(--reactaform-button-margin-top, 0.5em)",transition:"opacity 0.2s ease",opacity:ie?"var(--reactaform-button-disabled-opacity, 0.6)":D?"var(--reactaform-button-hover-opacity, 0.9)":"1"},children:l("Submit")})]}):b.jsx("div",{children:"Initializing form..."})};bt();const gn=(e,t=!1)=>({container:{padding:"var(--reactaform-space-sm, 8px)",margin:"0 auto",backgroundColor:"transparent",borderRadius:0,color:"var(--reactaform-color-text)",fontFamily:e?.fontFamily||"var(--reactaform-font-family, system-ui, -apple-system, sans-serif)",boxSizing:"border-box",minHeight:e?.minHeight??"0",...e?.width?{width:e.width,overflowX:"auto"}:{maxWidth:"100%"},...e?.height?{height:e.height,overflowY:"auto"}:{}},buttonStyle:{padding:"var(--reactaform-space-sm, 8px) var(--reactaform-space-md, 16px)",backgroundColor:"var(--reactaform-color-primary)",color:"var(--reactaform-color-background)",border:"1px solid var(--reactaform-color-primary)",borderRadius:"var(--reactaform-border-radius, 6px)",cursor:"pointer",fontSize:e?.fontSize||"1rem",fontWeight:"600",transition:"all 0.2s ease",boxShadow:"var(--reactaform-shadow-small, 0 1px 3px rgba(0, 0, 0, 0.12))"},titleStyle:{marginBottom:"var(--reactaform-space-lg, 24px)",color:"var(--reactaform-color-text)",fontSize:typeof e?.fontSize=="number"?`${e.fontSize*1.5}px`:"1.5rem",fontWeight:"700",lineHeight:"1.2",textAlign:"left"}}),hn=(e,t=!1)=>{const r={color:"var(--reactaform-color-text)",fontFamily:e?.fontFamily||"var(--reactaform-font-family, inherit)",transition:"all 0.2s ease",outline:"none",width:"100%",boxSizing:"border-box"};return{container:{fontFamily:e?.fontFamily||"var(--reactaform-font-family, inherit)",fontSize:e?.fontSize||"var(--reactaform-font-size, 1rem)",width:"100%",maxWidth:e?.width||"100%",marginBottom:"var(--reactaform-space-md, 16px)"},label:{display:"block",marginBottom:"var(--reactaform-space-xs, 4px)",fontWeight:"500",color:"var(--reactaform-color-text)",fontSize:"var(--reactaform-font-size, 1rem)",fontFamily:e?.fontFamily||"var(--reactaform-font-family, inherit)"},input:r,textInput:r,optionInput:r,select:{...r,cursor:"pointer",backgroundRepeat:"no-repeat",backgroundPosition:"right 8px center",backgroundSize:"16px",paddingRight:"32px",backgroundImage:`url("data:image/svg+xml;utf8,<svg
292
+ <%s key={someKey} {...props} />`,T,P,X,P),A[P+T]=!0)}if(P=null,L!==void 0&&(n(L),P=""+L),l(E)&&(n(E.key),P=""+E.key),"key"in E){L={};for(var ie in E)ie!=="key"&&(L[ie]=E[ie])}else L=E;return P&&c(L,typeof y=="function"?y.displayName||y.name||"Unknown":y),d(y,P,L,t(),J,re)}function p(y){i(y)?y._store&&(y._store.validated=1):typeof y=="object"&&y!==null&&y.$$typeof===k&&(y._payload.status==="fulfilled"?i(y._payload.value)&&y._payload.value._store&&(y._payload.value._store.validated=1):y._store&&(y._store.validated=1))}function i(y){return typeof y=="object"&&y!==null&&y.$$typeof===b}var f=s,b=Symbol.for("react.transitional.element"),g=Symbol.for("react.portal"),x=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),I=Symbol.for("react.context"),S=Symbol.for("react.forward_ref"),R=Symbol.for("react.suspense"),j=Symbol.for("react.suspense_list"),w=Symbol.for("react.memo"),k=Symbol.for("react.lazy"),O=Symbol.for("react.activity"),$=Symbol.for("react.client.reference"),_=f.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,U=Object.prototype.hasOwnProperty,G=Array.isArray,ee=console.createTask?console.createTask:function(){return null};f={react_stack_bottom_frame:function(y){return y()}};var Q,K={},ae=f.react_stack_bottom_frame.bind(f,a)(),z=ee(o(a)),A={};fe.Fragment=x,fe.jsx=function(y,E,L){var T=1e4>_.recentlyCreatedOwnerStacks++;return u(y,E,L,!1,T?Error("react-stack-top-frame"):ae,T?ee(o(y)):z)},fe.jsxs=function(y,E,L){var T=1e4>_.recentlyCreatedOwnerStacks++;return u(y,E,L,!0,T?Error("react-stack-top-frame"):ae,T?ee(o(y)):z)}})()),fe}var Be;function Ir(){return Be||(Be=1,process.env.NODE_ENV==="production"?he.exports=kr():he.exports=Nr()),he.exports}var h=Ir();const xe=s.createContext(void 0),V=()=>{const e=s.useContext(xe);if(!e)throw new Error("❌ useReactaFormContext must be used within a <ReactaFormProvider>");return e};class ve{map={};register(r,n){this.map[r]=n}get(r){return this.map[r]}has(r){return r in this.map}list(){return Object.keys(this.map)}entries(){return Object.entries(this.map)}values(){return Object.values(this.map)}size(){return Object.keys(this.map).length}unregister(r){return r in this.map?(delete this.map[r],!0):!1}clear(){this.map={}}registerAll(r){Array.isArray(r)?r.forEach(([n,o])=>this.register(n,o)):Object.entries(r).forEach(([n,o])=>this.register(n,o))}getOrDefault(r,n){return this.get(r)??n}}function Xe(e,r=300,n){const o=s.useRef(void 0),t=s.useRef(e),a=s.useRef(null),l=s.useRef(!1);s.useEffect(()=>{t.current=e},[e]),s.useEffect(()=>()=>{o.current!==void 0&&(window.clearTimeout(o.current),o.current=void 0)},[]);const c=s.useCallback(()=>{o.current!==void 0&&(window.clearTimeout(o.current),o.current=void 0),a.current=null,l.current=!1},[]),m=s.useCallback(()=>{if(o.current!==void 0&&(window.clearTimeout(o.current),o.current=void 0),a.current)try{t.current(...a.current)}finally{a.current=null,l.current=!1}},[]);return{callback:s.useCallback((...u)=>{if(n?.leading===!0&&!l.current){l.current=!0,t.current(...u),window.clearTimeout(o.current),o.current=window.setTimeout(()=>{l.current=!1,o.current=void 0},r);return}a.current=u,window.clearTimeout(o.current),o.current=window.setTimeout(()=>{o.current=void 0,a.current&&(t.current(...a.current),a.current=null,l.current=!1)},r)},[r,n?.leading]),cancel:c,flush:m}}const F={field:"reactaform-field",label:"reactaform-label",input:"reactaform-input",textInput:"reactaform-input--text",inputNumber:"reactaform-input--number",inputSelect:"reactaform-select",rangeInput:"reactaform-input--range",button:"reactaform-button"},Y=(...e)=>{const r=[];for(const n of e)n&&(typeof n=="string"?r.push(n):typeof n=="object"&&Object.entries(n).forEach(([o,t])=>{t&&r.push(o)}));return r.join(" ")},Ze=({content:e,size:r="medium",animation:n=!0})=>{const{t:o,darkMode:t,formStyle:a,fieldStyle:l}=V(),[c,m]=s.useState(!1),[d,u]=s.useState({x:0,y:0}),[p,i]=s.useState(!1),f=s.useRef(null),b=s.useRef(null),g=s.useRef(null),x=s.useMemo(()=>{const I={icon:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"1.2em",height:"1.2em",fontSize:"0.9em",fontWeight:"bold",borderRadius:"50%",backgroundColor:t?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.06)",color:t?"#f0f0f0":"#333",border:`1px solid ${t?"rgba(255,255,255,0.2)":"rgba(0,0,0,0.1)"}`,cursor:"pointer",transition:n?"all 0.2s ease":void 0,marginLeft:"0.3em"},text:{...{small:{padding:"4px 8px",fontSize:"11px",maxWidth:"200px"},medium:{padding:"6px 10px",fontSize:"12px",maxWidth:"240px"},large:{padding:"8px 12px",fontSize:"13px",maxWidth:"280px"}}[r],position:"absolute",backgroundColor:`var(--reactaform-tooltip-color-bg, ${t?"rgba(45,45,45,0.95)":"rgba(60,60,60,0.92)"})`,color:`var(--reactaform-tooltip-color, ${t?"#f0f0f0":"#fff"})`,borderRadius:"6px",border:`1px solid ${t?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)"}`,boxShadow:t?"0 8px 16px rgba(0,0,0,0.4)":"0 6px 18px rgba(0,0,0,0.12)",zIndex:2147483647,opacity:0,visibility:"hidden",transition:n?"opacity 0.2s ease, visibility 0.2s ease":void 0,pointerEvents:"none",whiteSpace:"normal",wordBreak:"break-word",boxSizing:"border-box"},textVisible:{opacity:1,visibility:"visible"}},S=(j,w,k)=>{const $=j?.[w];return(k&&$?$[k]:void 0)??{}};return{icon:{...I.icon,...S(a,"tooltip","icon"),...S(l,"tooltip","icon")},text:{...I.text,...S(a,"tooltip","text"),...S(l,"tooltip","text")},textVisible:I.textVisible}},[t,r,n,a,l]);s.useEffect(()=>{if(c){const N=requestAnimationFrame(()=>i(!1)),I=requestAnimationFrame(()=>{if(f.current){const S=f.current.getBoundingClientRect(),R=8;g.current=S;const j=S.right+R,w=S.top;u({x:j,y:w}),i(!0)}});return()=>{cancelAnimationFrame(I),cancelAnimationFrame(N)}}else requestAnimationFrame(()=>i(!1))},[c]),s.useEffect(()=>{if(!p)return;const N=requestAnimationFrame(()=>{if(!b.current)return;const I=b.current.getBoundingClientRect(),S=8,R=typeof window<"u"?window.innerWidth:1024,j=typeof window<"u"?window.innerHeight:768;let w=d.x,k=d.y;const O=g.current;O&&(w=O.right+S,k=O.top+O.height/2-I.height/2+-4,w+I.width>R-S&&(w=O.left-S-I.width)),w+I.width>R-S&&(w=Math.max(S,R-I.width-S)),w<S&&(w=S),k+I.height>j-S&&(k=Math.max(S,j-I.height-S)),k<S&&(k=S),(w!==d.x||k!==d.y)&&u({x:w,y:k})});return()=>cancelAnimationFrame(N)},[p,d.x,d.y]);const v=typeof document<"u"?document.getElementById("popup-root"):null,C=h.jsx("div",{ref:b,style:{...x.text,transform:p?"translateY(0) scale(1)":"translateY(-4px) scale(0.98)",transition:"opacity 120ms ease, transform 120ms ease, visibility 120ms ease",width:240,...p?x.textVisible:{},top:d.y,left:d.x},"data-reactaform-theme":t?"dark":"light",children:o(e)});return h.jsxs(h.Fragment,{children:[h.jsx("span",{"data-testid":"tooltip-icon",ref:f,onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),style:{...x.icon},children:"?"}),c&&(v?Ae.createPortal(C,v):C)]})},Ee=s.memo(({field:e,error:r,children:n,showLabel:o=!0})=>{const{t}=V(),a=e?.labelLayout==="column-center"?"center":"left";return h.jsxs("div",{className:`${F.field} column-layout`,style:{display:"flex",flexDirection:"column",gap:"var(--reactaform-label-gap, 4px)","--label-align":a},children:[o&&h.jsx("div",{style:{textAlign:a,width:"100%"},children:h.jsx("label",{className:F.label,htmlFor:e.name,style:{textAlign:a,width:"100%",minWidth:"unset",display:"block"},children:t(e.displayName)})}),h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--reactaform-inline-gap, 8px)",width:"100%"},children:[h.jsx("div",{style:{flex:1,minWidth:0,maxWidth:"100%"},children:h.jsx("div",{style:{width:"100%"},children:n})}),e.tooltip&&h.jsx(Ze,{content:e.tooltip})]}),r&&h.jsx(Me,{children:r})]})});Ee.displayName="ColumnFieldLayout";const Qe=s.memo(({field:e,error:r,children:n,rightAlign:o=!1})=>{const{t}=V(),a=s.useMemo(()=>({display:"flex",flexDirection:"column",gap:0}),[]),l=s.useMemo(()=>({display:"flex",flexDirection:"row",alignItems:"center",gap:"3px"}),[]);return h.jsxs("div",{className:`${F.field} row-layout`,children:[h.jsx("label",{className:F.label,htmlFor:e.name,style:{textAlign:"left",justifyContent:"flex-start"},children:t(e.displayName)}),h.jsxs("div",{style:a,children:[h.jsxs("div",{style:l,children:[o?h.jsx("div",{style:{display:"flex",flex:1,justifyContent:"flex-end",alignItems:"center",gap:"var(--reactaform-inline-gap, 8px)"},children:n}):n,e.tooltip&&h.jsx(Ze,{content:e.tooltip})]}),r&&h.jsx(Me,{children:r})]})]})});Qe.displayName="RowFieldLayout";const B=({field:e,error:r,children:n,rightAlign:o=!1})=>e?.labelLayout==="column-left"||e?.labelLayout==="column-center"?h.jsx(Ee,{field:e,error:r,showLabel:!0,children:n}):e?.type==="checkbox"||e?.type==="switch"?h.jsx(Ee,{field:e,error:r,showLabel:!1,children:n}):h.jsx(Qe,{field:e,error:r,rightAlign:o,children:n}),Me=s.memo(({children:e})=>{const r=s.useMemo(()=>({color:"var(--reactaform-error-color)",fontSize:"13px",marginTop:"4px",fontWeight:"var(--reactaform-font-weight)",display:"flex",flex:1,justifyContent:"flex-start",alignItems:"flex-start"}),[]);return h.jsx("div",{style:r,children:e})});Me.displayName="ErrorDiv";const er=s.memo(({name:e,onChange:r})=>{const{t:n}=V();return h.jsxs("div",{style:{marginBottom:16},children:[h.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 2fr",gap:12,alignItems:"center"},children:[h.jsx("label",{htmlFor:"instance-name-input",style:{margin:0,fontSize:"0.95em",fontWeight:500,color:"var(--reactaform-text-color, #333)"},children:n("Instance Name")}),h.jsx("input",{id:"instance-name-input",type:"text",value:e,onChange:o=>r(o.target.value),style:{width:"100%",padding:"var(--reactaform-input-padding, 8px 12px)",fontSize:"var(--reactaform-input-font-size, 14px)",border:"1px solid var(--reactaform-input-border, #ddd)",borderRadius:"var(--reactaform-border-radius, 4px)",backgroundColor:"var(--reactaform-input-bg, #fff)",color:"var(--reactaform-text-color, #333)",boxSizing:"border-box"},placeholder:n("Enter instance name")})]}),h.jsx("div",{style:{height:"1px",backgroundColor:"var(--reactaform-separator, #e6e6e6)",marginTop:12,marginBottom:12}})]})});er.displayName="InstanceName";class Fr extends ve{registerInCategory(r,n,o){this.get(r)||this.register(r,{});const t=this.get(r);t[n]=o}getFromCategory(r,n){return this.get(r)?.[n]}listFromCategory(r){return Object.keys(this.get(r)||{})}listCategories(){return this.list()}}const rr=new ve,tr=new Fr;function Ar(e,r){rr.register(e,r)}function Mr(e,r,n){tr.registerInCategory(e,r,n)}function Or(e,r){return tr.getFromCategory(e,r)||null}function $r(e){return rr.get(e)||null}const Se=new Map,Ce=new Map;function H(e,r,n,o){if(r&&typeof r.validationHandlerName=="string"){const t=`${e}:${r.validationHandlerName}`;if(!Se.has(t)){const l=Or(e,r.validationHandlerName);Se.set(t,l)}const a=Se.get(t);if(a)return a(n,o)||null}return null}function nr(e,r,n){if(e&&typeof e.validationHandlerName=="string"){const o=e.validationHandlerName;if(!Ce.has(o)){const a=$r(o);Ce.set(o,a)}const t=Ce.get(o);if(t)return t(r,n)||null}return null}function oe(e){return typeof e=="object"&&e!==null}function Oe(e){if(!oe(e))return!1;const r=e;return typeof r.name=="string"&&typeof r.displayName=="string"}function or(e){if(!oe(e))return!1;const r=e;return typeof r.name!="string"||typeof r.version!="string"||!Array.isArray(r.properties)?!1:r.properties.every(n=>Oe(n))}function je(e){try{return typeof File<"u"&&e instanceof File}catch{const r=oe(e)?e:void 0;return!!r&&typeof r.name=="string"&&typeof r.size=="number"}}function Vr(e,r,n={}){try{const{includeMetadata:o=!1,dateFormat:t="iso",fileHandling:a="metadata",prettify:l=!1,excludeFields:c=[],includeOnlyFields:m=[]}=n;if(!e||typeof e!="object")return{success:!1,error:"Instance must be a valid object"};const d=[],u=[],p={},f=(or(r)||oe(r)&&Array.isArray(r.properties)?r.properties:[]).filter(Oe),b=new Map(f.map(x=>[x.name,x]));for(const[x,v]of Object.entries(e)){if(c.includes(x)){u.push(x);continue}if(m.length>0&&!m.includes(x)){u.push(x);continue}if(v===void 0)continue;const C=b.get(x);try{p[x]=zr(v,C,{dateFormat:t,fileHandling:a})}catch(N){d.push(`Error serializing field '${x}': ${String(N)}`),p[x]=null}}return o&&(p._metadata={serializedAt:new Date().toISOString(),version:(oe(r)?r.version:void 0)||"1.0.0",fieldCount:Object.keys(p).length-1}),{success:!0,data:l?JSON.stringify(p,null,2):JSON.stringify(p),metadata:{fieldCount:Object.keys(p).length,excludedFields:u,warnings:d}}}catch(o){return{success:!1,error:`Serialization failed: ${o instanceof Error?o.message:"Unknown error"}`}}}function zr(e,r,n={}){const{dateFormat:o="iso",fileHandling:t="metadata"}=n;if(e==null)return null;if(r)switch(r.type){case"date":case"datetime":case"date-time":return He(e,o);case"file":return Ue(e,t);case"int":case"integer":return typeof e=="string"?parseInt(e,10):e;case"float":case"number":return typeof e=="string"?parseFloat(e):e;case"boolean":return typeof e=="string"?e==="true":!!e;case"int-array":case"float-array":return Array.isArray(e)?e.map(a=>typeof a=="string"?Number(a):a):e;default:return e}return e instanceof Date?He(e,o):je(e)||Array.isArray(e)&&je(e[0])?Ue(e,t):e}function He(e,r){let n=null;if(e instanceof Date)n=e;else if(typeof e=="string"){const o=new Date(e);if(!isNaN(o.getTime()))n=o;else return e}else return e;switch(r){case"timestamp":return n.getTime();case"locale":return n.toLocaleString();case"iso":default:return n.toISOString()}}function Ue(e,r){return r==="skip"?null:Array.isArray(e)?e.map(n=>We(n,r)):We(e,r)}function We(e,r){if(!je(e))return e;const n=e;return r==="metadata"?{name:n.name,size:n.size,type:n.type,lastModified:n.lastModified}:{name:n.name,size:n.size,type:n.type,lastModified:n.lastModified,_note:"Base64 encoding requires async implementation"}}function Tr(e,r,n={}){try{const{strict:o=!1,validateTypes:t=!0,preserveUnknownFields:a=!0,dateFormat:l="auto"}=n;if(!e||typeof e!="string")return{success:!1,error:"Serialized data must be a non-empty string"};let c;try{c=JSON.parse(e)}catch(g){return{success:!1,error:`Invalid JSON: ${g instanceof Error?g.message:"Unknown parsing error"}`}}if(!c||typeof c!="object")return{success:!1,error:"Parsed data must be an object"};const m=[],d=[],u={},i=(or(r)||oe(r)&&Array.isArray(r.properties)?r.properties:[]).filter(Oe),f=new Map(i.map(g=>[g.name,g]));for(const g of i){const x=g.name,v=c[x];if(v===void 0){o&&g.required&&d.push(`Required field '${x}' is missing`);continue}try{u[x]=Dr(v,g,{validateTypes:t,dateFormat:l})}catch(C){const N=`Error deserializing field '${x}': ${String(C)}`;o?d.push(N):(m.push(N),u[x]=v)}}if(a)for(const[g,x]of Object.entries(c))!f.has(g)&&g!=="_metadata"&&(o&&m.push(`Unknown field '${g}' preserved`),u[g]=x);const b=d.length>0;return{success:!b,data:u,warnings:m.length>0?m:void 0,validationErrors:b?d:void 0}}catch(o){return{success:!1,error:`Deserialization failed: ${o instanceof Error?o.message:"Unknown error"}`}}}function Dr(e,r,n={}){const{validateTypes:o=!0,dateFormat:t="auto"}=n;if(e==null)return e;try{switch(r.type){case"date":case"datetime":case"date-time":return _r(e,t,o);case"int":case"integer":return ke(e,o);case"float":case"number":return Ne(e,o);case"boolean":return qr(e,o);case"int-array":return Ye(e,"integer",o);case"float-array":return Ye(e,"number",o);case"string":case"text":case"email":case"url":case"phone":return o?String(e):e;default:return e}}catch(a){if(o)throw new Error(`Type conversion failed: ${String(a)}`);return e}}function Lr(e,r={}){try{const{prettify:n=!0,includeMetadata:o=!0}=r;if(!e||typeof e!="object")return{success:!1,error:"Definition must be a valid object"};const t={...e};return o&&(t._metadata={serializedAt:new Date().toISOString(),version:t.version||"1.0.0",propertyCount:(Array.isArray(t.properties)?t.properties.length:0)||0}),{success:!0,data:n?JSON.stringify(t,null,2):JSON.stringify(t),metadata:{fieldCount:(Array.isArray(t.properties)?t.properties.length:0)||0,excludedFields:[],warnings:[]}}}catch(n){return{success:!1,error:`Definition serialization failed: ${n instanceof Error?n.message:"Unknown error"}`}}}function Pr(e,r={}){try{const{strict:n=!1,validateTypes:o=!0}=r;let t;if(typeof e=="string")try{t=JSON.parse(e)}catch(u){return{success:!1,error:`Invalid JSON for definition: ${u instanceof Error?u.message:"Unknown parsing error"}`}}else if(e&&typeof e=="object")t={...e};else return{success:!1,error:"Input must be a string or object"};const a=[],l=[],c=["name","version","displayName"];for(const u of c)if(!t[u])if(n)l.push(`Required field '${u}' is missing`);else switch(a.push(`Missing field '${u}', using default`),u){case"name":t.name="unnamed-definition";break;case"version":t.version="1.0.0";break;case"displayName":t.displayName=t.name||"Unnamed Definition";break}const m=Array.isArray(t.properties)?t.properties:null;m?t.properties=m.map((u,p)=>{const i=oe(u)?u:{},f={...i};if(!i.name){const b=`Property at index ${p} missing 'name'`;n?l.push(b):(a.push(`${b}, using 'field_${p}'`),f.name=`field_${p}`)}return i.displayName||(f.displayName=i.name||`Field ${p}`),i.type||(n&&o?l.push(`Property '${i.name||p}' missing 'type'`):(a.push(`Property '${i.name||p}' missing 'type', using 'string'`),f.type="string")),i.defaultValue===void 0&&(f.defaultValue=null),i.required===void 0&&(f.required=!1),f}):n?l.push("Properties must be an array"):(a.push("Properties not found or invalid, using empty array"),t.properties=[]);const d=l.length>0;return{success:!d,data:t,warnings:a.length>0?a:void 0,validationErrors:d?l:void 0}}catch(n){return{success:!1,error:`Definition deserialization failed: ${n instanceof Error?n.message:"Unknown error"}`}}}function _r(e,r,n){if(e instanceof Date)return e;if(typeof e=="number"){const o=new Date(e);if(n&&isNaN(o.getTime()))throw new Error(`Invalid timestamp: ${e}`);return o}if(typeof e=="string"){const o=new Date(e);if(n&&isNaN(o.getTime()))throw new Error(`Invalid date string: ${e}`);return o}if(n)throw new Error(`Cannot convert ${typeof e} to Date`);return e}function ke(e,r){if(typeof e=="number"&&Number.isInteger(e))return e;if(typeof e=="string"&&e.trim()!==""){const n=parseInt(e,10);if(r&&isNaN(n))throw new Error(`Cannot convert "${e}" to integer`);return n}if(r)throw new Error(`Cannot convert ${typeof e} to integer`);return e}function Ne(e,r){if(typeof e=="number")return e;if(typeof e=="string"&&e.trim()!==""){const n=parseFloat(e);if(r&&isNaN(n))throw new Error(`Cannot convert "${e}" to number`);return n}if(r)throw new Error(`Cannot convert ${typeof e} to number`);return e}function qr(e,r){if(typeof e=="boolean")return e;if(typeof e=="string"){const n=e.toLowerCase();if(n==="true"||n==="1")return!0;if(n==="false"||n==="0")return!1;if(r)throw new Error(`Cannot convert "${e}" to boolean`)}if(typeof e=="number")return!!e;if(r)throw new Error(`Cannot convert ${typeof e} to boolean`);return e}function Ye(e,r,n){if(!Array.isArray(e)){if(typeof e=="string")return e.split(",").map(t=>t.trim()).filter(Boolean).map(t=>r==="integer"?ke(t,n):Ne(t,n));if(n)throw new Error(`Expected array, got ${typeof e}`);return e}return e.map((o,t)=>{try{return r==="integer"?ke(o,n):Ne(o,n)}catch(a){if(n)throw new Error(`Array element ${t}: ${a}`);return o}})}const Br=(e,r)=>{const n=new Map;let o=null,t=null,a=0;for(const l of e){const c=l.group;if(!c){o=null,t=null;continue}if(c===o)r[l.name].group=t??c;else{if(!n.has(c))n.set(c,1),t=null,r[l.name].group=c;else{const m=n.get(c),d=`${c}(${m})`;n.set(c,m+1),t=d,r[l.name].group=d,a++}o=c}}return a},ar=(e,r={})=>{const{includeEmpty:n=!0}=r,o=[];let t=null,a=[],l=0;for(const m of e){const d=m.group||null;d!==t?((a.length>0||n)&&(a.length===0&&l++,o.push({name:t,fields:a})),t=d,a=[m]):a.push(m)}(a.length>0||n)&&(a.length===0&&l++,o.push({name:t,fields:a}));const c=Math.max(0,...o.map(m=>m.fields.length));return{groups:o,metadata:{totalGroups:o.length,emptyGroups:l,largestGroup:c}}},Re=new Map,be=new Map,ne=new Set,Ie=new Map,Hr=async e=>{try{let r;switch(e.toLowerCase()){case"fr":r=(await Promise.resolve().then(()=>require("./common-BxyjIoe1.cjs"))).default;break;case"de":r=(await Promise.resolve().then(()=>require("./common-BD9zx3GT.cjs"))).default;break;case"es":r=(await Promise.resolve().then(()=>require("./common-hRFTL4KF.cjs"))).default;break;case"zh-cn":r=(await Promise.resolve().then(()=>require("./common-COyDhNL-.cjs"))).default;break;case"en":r={};break;default:r={}}return{success:!0,translations:r,fromCache:!1}}catch(r){return{success:!1,translations:{},error:`Failed to load common translations for ${e}: ${r}`}}},Ur=async e=>{if(!e)return{success:!1,translations:{},error:"Language is required"};const r=e.toLowerCase();if(r==="en")return{success:!0,translations:{},fromCache:!1};if(Re.has(r))return{success:!0,translations:Re.get(r)||{},fromCache:!0};const n=await Hr(r);return n.success&&(Re.set(r,n.translations),Ie.set(r,{loadedAt:new Date,size:Object.keys(n.translations).length,source:"common"})),n},Wr=async(e,r)=>{if(!e||!r)return{success:!1,translations:{},error:"Both language and localizeName are required"};const n=`${e.toLowerCase()}/${r}`;if(ne.has(n))return{success:!1,translations:{},error:"Previously failed to load",fromCache:!0};if(be.has(n))return{success:!0,translations:be.get(n)||{},fromCache:!0};try{let o=r;!r.includes("/")&&!r.includes(".")&&(o=`/locales/${e}/${r}.json`);const t=await fetch(o);if(!t.ok){const d=`HTTP ${t.status}: ${t.statusText}`;return t.status===404?(be.set(n,{}),Ie.set(n,{loadedAt:new Date,size:0,source:"user"}),{success:!0,translations:{},fromCache:!1}):(ne.add(n),{success:!1,translations:{},error:d})}const a=t.headers.get("content-type")||"";!a.includes("application/json")&&!a.includes("text/json")&&sr()&&console.warn(`Translation file at ${o} has unexpected content-type: ${a}`);const l=await t.text();if(!l){const d="Empty translation file";return ne.add(n),{success:!1,translations:{},error:d}}let c;try{c=JSON.parse(l)}catch(d){const u=`Invalid JSON in translation file: ${d instanceof Error?d.message:String(d)}`;return ne.add(n),{success:!1,translations:{},error:u}}if(!c||typeof c!="object"){const d="Invalid translation file format";return ne.add(n),{success:!1,translations:{},error:d}}const m=Object.fromEntries(Object.entries(c).map(([d,u])=>[d,typeof u=="string"?u:String(u)]));if(!m||typeof m!="object"){const d="Invalid translation file format";return ne.add(n),{success:!1,translations:{},error:d}}return be.set(n,m),Ie.set(n,{loadedAt:new Date,size:Object.keys(m).length,source:"user"}),{success:!0,translations:m,fromCache:!1}}catch(o){const t=`Failed to load user translations: ${o instanceof Error?o.message:"Unknown error"}`;return ne.add(n),{success:!1,translations:{},error:t}}};function sr(){try{if(typeof process<"u"&&process?.env?.NODE_ENV==="development")return!0}catch{}return!1}function Yr(e,r){return r.length===0?e:e.replace(/\{\{(\d+)\}\}/g,(n,o)=>{const t=parseInt(o,10)-1,a=r[t];if(a==null)return n;try{return String(a)}catch{return n}})}const Jr=(e,r,n)=>(o,...t)=>{let a=o,l=!1;return!o||typeof o!="string"?String(o||""):(e.toLowerCase()==="en"?(a=o,l=!0):Object.prototype.hasOwnProperty.call(n,o)?(a=n[o],l=!0):Object.prototype.hasOwnProperty.call(r,o)?(a=r[o],l=!0):a=o,a=Yr(a,t),!l&&sr()&&console.debug(`Missing translation for "${o}" in language "${e}"`),a)},$e={length:["m","cm","mm","km","in","ft","yd","mi"],area:["m^2","cm^2","mm^2","in^2","ft^2","yd^2"],volume:["L","m^3","cm^3","mL","in^3","ft^3","yd^3"],weight:["kg","g","mg","t","lb","oz"],time:["min","s","h","ms","d"],temperature:["C","F","K"],angle:["deg","rad","rev"]},Ve={length:{m:"Meter (m)",mm:"Millimeter (mm)",cm:"Centimeter (cm)",km:"Kilometer (km)",in:"Inch (in)",ft:"Foot (ft)",yd:"Yard (yd)",mi:"Mile (mi)"},area:{"m^2":"Square meter (m^2)","mm^2":"Square millimeter (mm^2)","cm^2":"Square centimeter (cm^2)","in^2":"Square inch (in^2)","ft^2":"Square foot (ft^2)","yd^2":"Square yard (yd^2)"},volume:{L:"Liter (L)","cm^3":"Cubic centimeter (cm^3)","m^3":"Cubic meter (m^3)",mL:"Milliliter (mL)","in^3":"Cubic inch (in^3)","ft^3":"Cubic foot (ft^3)","yd^3":"Cubic yard (yd^3)"},weight:{kg:"Kilogram (kg)",g:"Gram (g)",mg:"Milligram (mg)",t:"Tonne (t)",lb:"Pound (lb)",oz:"Ounce (oz)"},time:{s:"Second (s)",min:"Minute (min)",h:"Hour (h)",ms:"Millisecond (ms)",d:"Day (d)",wk:"Week (wk)"},temperature:{C:"Celsius (C)",F:"Fahrenheit (F)",K:"Kelvin (K)"},angle:{deg:"Degree (deg)",rad:"Radian (rad)",rev:"Revolution (rev)"}},ze={length:{mm:1e3,cm:100,m:1,km:.001,in:100/2.54,ft:100/(2.54*12),yd:100/(2.54*36),mi:1/1609.344},area:{"m^2":1,"mm^2":1e6,"cm^2":1e4,"km^2":1/1e6,"in^2":(100/2.54)**2,"ft^2":(100/(2.54*12))**2,"yd^2":(100/(2.54*36))**2},volume:{"cm^3":1e6,"m^3":1,L:1,mL:1e6,"in^3":(100/2.54)**3,"ft^3":(100/(2.54*12))**3,"yd^3":(100/(2.54*36))**3},weight:{mg:1e6,g:1e3,kg:1,t:.001,lb:1/.45359237,oz:1/.028349523125},time:{ms:1e3,s:1,min:1/60,h:1/3600,d:1/86400,wk:1/604800},temperature:{C:1,F:33.8,K:274.15},angle:{deg:1,rad:Math.PI/180,rev:1/360}},Te={},Gr=new Set([...Object.keys($e),...Object.keys(Ve),...Object.keys(ze)]);for(const e of Gr){const r={},n=$e[e]??[],o=Ve[e]??{},t=ze[e]??{};for(const a of n){const l=o[a];r[a]={name:typeof l=="string"?l:String(a),shortName:a,factor:Object.prototype.hasOwnProperty.call(t,a)?t[a]:void 0}}for(const[a,l]of Object.entries(o))if(!r[a]){const c=typeof l=="string"?l:String(a);r[a]={name:c,shortName:a,factor:Object.prototype.hasOwnProperty.call(t,a)?t[a]:void 0}}for(const[a,l]of Object.entries(t))r[a]||(r[a]={name:String(a),shortName:String(a),factor:l});Te[e]=r}const Kr=Object.freeze(Object.defineProperty({__proto__:null,dimensionUnitDisplayMap:Ve,dimensionUnitsMap:$e,dimensonUnitFactorsMap:ze,unitsByDimension:Te},Symbol.toStringTag,{value:"Module"})),Xr=({field:e,value:r,onChange:n,onError:o})=>{const{definitionName:t,t:a}=V(),l=s.useRef(o);s.useEffect(()=>{l.current=o},[o]),s.useEffect(()=>{const u=H(t,e,r??!1,a);l.current?.(u??null)},[r,e,t,a]);const c=u=>{const p=u.target.checked;n?.(p,null)},m=u=>{(u.key===" "||u.key==="Spacebar"||u.key==="Space"||u.key==="Enter")&&(u.preventDefault(),n?.(!r,null))},d=e.name;return h.jsx(B,{field:e,rightAlign:!1,children:h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[h.jsx("label",{className:F.label,htmlFor:d,style:{textAlign:"left",justifyContent:"flex-start"},children:a(e.displayName)}),h.jsx("input",{id:d,"data-testid":"boolean-checkbox",type:"checkbox",checked:!!r,onChange:c,onKeyDown:m,"aria-checked":!!r,style:{cursor:"pointer",margin:"8px 0 8px 0",width:"1.2em",height:"1.2em",verticalAlign:"middle",color:"#FFFFFF",accentColor:"#0000FF",opacity:void 0}})]})})},Je=[{label:"Black",value:"#000000"},{label:"White",value:"#ffffff"},{label:"Red",value:"#ff0000"},{label:"Green",value:"#008000"},{label:"Blue",value:"#0000ff"},{label:"Yellow",value:"#ffff00"},{label:"Cyan",value:"#00ffff"},{label:"Magenta",value:"#ff00ff"},{label:"Orange",value:"#ffa500"},{label:"Purple",value:"#800080"},{label:"Brown",value:"#a52a2a"},{label:"Gray",value:"#808080"},{label:"Light Gray",value:"#d3d3d3"},{label:"Pink",value:"#ffc0cb"}];function ir(e){return/^#([0-9A-F]{3}){1,2}$/i.test(e)}function Zr(e){if(!ir(e))return null;const r=cr(e),n=parseInt(r.slice(1),16);return{r:n>>16&255,g:n>>8&255,b:n&255}}function cr(e){return e?(e=e.toLowerCase(),/^#([a-f0-9]){3}$/i.test(e)?"#"+e.slice(1).split("").map(r=>r+r).join(""):e):"#000000"}const Qr=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),[l,c]=s.useState("#000000"),m=s.useRef(null),d=s.useRef(null),u=s.useRef(o);s.useEffect(()=>{u.current=o},[o]),s.useEffect(()=>{const v=r&&ir(r)?r:"#000000",C=cr(v);c(C)},[r]),s.useEffect(()=>{const v=H(a,e,r??"#000000",t);u.current?.(v??null)},[r,e,a,t]);const p=v=>{const C=v.target.value;c(C),n?.(C,null)},i=v=>{const C=v.target.value;c(C),n?.(C,null)},f=Je.find(v=>v.value===l),{r:b,g,b:x}=Zr(l)||{r:0,g:0,b:0};return h.jsx(B,{field:e,error:null,children:h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",width:"100%"},children:[h.jsxs("select",{ref:m,id:e.name,value:l,onChange:p,style:{minWidth:"120px",flex:1},className:Y(F.input,F.inputSelect),children:[Je.map(v=>h.jsx("option",{value:v.value,children:t(v.label)},v.value)),f?null:h.jsxs("option",{value:l,children:["(",b,", ",g,", ",x,")"]},l)]}),h.jsx("label",{style:{width:"2.5em",height:"1.8em",display:"inline-block",border:"1px solid #ccc",borderRadius:"4px",backgroundColor:l,cursor:"pointer",overflow:"hidden",flexShrink:0},children:h.jsx("input",{ref:d,type:"color",value:l,onChange:i,style:{opacity:0,width:"100%",height:"100%",border:"none",padding:0,cursor:"pointer"}})})]})})},me=e=>{if(!e)return null;const r=new Date(e);return isNaN(r.getTime())?null:r},et=e=>{if(!e)return"";if(/^\d{4}-\d{2}-\d{2}$/.test(e))return me(e)?e:"";const n=me(e);if(n){const o=n.getFullYear(),t=String(n.getMonth()+1).padStart(2,"0"),a=String(n.getDate()).padStart(2,"0");return`${o}-${t}-${a}`}return""},rt=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),{name:l,required:c}=e,m=s.useRef(null),d=s.useRef(o);s.useEffect(()=>{d.current=o},[o]);const u=s.useCallback(i=>{if(!i||i.trim()==="")return c?t("Value required"):null;if(i){const b=me(i);if(!b)return t("Invalid date format");if(e.minDate){const g=me(e.minDate);if(g&&b.getTime()<g.getTime())return t("Date must be on or after {{1}}",e.minDate)}if(e.maxDate){const g=me(e.maxDate);if(g&&b.getTime()>g.getTime())return t("Date must be on or before {{1}}",e.maxDate)}}return H(a,e,i,t)??null},[e,a,t,c]),p=i=>{const f=i.target.value,b=u(f);n?.(f,b)};return s.useEffect(()=>{const i=u(r);i!==m.current&&(m.current=i,d.current?.(i??null))},[r,u]),h.jsx(B,{field:e,error:u(r),children:h.jsx("input",{id:l,type:"date",value:et(r),onChange:p,className:Y(F.input,F.textInput),...e.minDate?{min:e.minDate}:{},...e.maxDate?{max:e.maxDate}:{},"aria-invalid":!!u(r),"aria-describedby":u(r)?`${l}-error`:void 0})})},tt=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),l=s.useRef(null),c=s.useRef(o);s.useEffect(()=>{c.current=o},[o]);const m=s.useCallback(u=>u===""||u===null||u===void 0?t("Value required"):!e.options||e.options.length===0?null:e.options.some(i=>i.value===u)?H(a,e,u,t)??null:t("Invalid option selected"),[e,t,a]);s.useEffect(()=>{const u=r!=null?String(r):"",p=m(u);if(p&&e.options&&e.options.length>0){const i=String(e.options[0].value);l.current&&(l.current.value=i),n?.(i,null),c.current?.(null)}else l.current&&(l.current.value=u),c.current?.(p??null)},[r,m,n,e.options]);const d=u=>{const p=u.target.value,i=m(p);n?.(p,i)};return h.jsx(B,{field:e,error:m(String(r??"")),children:h.jsx("select",{defaultValue:String(r??""),ref:l,onChange:d,className:Y(F.input,F.inputSelect),children:(e.options??[]).map(u=>h.jsx("option",{value:String(u.value),children:t(u.label)},String(u.value)))})})};function nt(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}const ot=({field:e,value:r,onChange:n,onError:o})=>{const{definitionName:t,t:a}=V(),l=s.useRef(null),c=s.useCallback(p=>{const i=p.trim();return i===""?e.required?a("Value required"):null:nt(i)?e.pattern&&!new RegExp(e.pattern).test(i)?a("Email does not match pattern: {{%1}}",{"%1":`${e.pattern}`}):H(t,e,p,a)??null:a("Must be valid email format")},[e,t,a]),m=p=>{const i=p.target.value,f=c(i);n?.(i,f)},d=s.useRef(null),u=s.useRef(o);return s.useEffect(()=>{u.current=o},[o]),s.useEffect(()=>{const p=r??"",i=c(p);l.current&&l.current.value!==String(p)&&(l.current.value=String(p)),i!==d.current&&(d.current=i,u.current?.(i??null))},[r,c]),h.jsx(B,{field:e,error:c(String(r??"")),children:h.jsx("input",{id:e.name,type:"email",defaultValue:String(r??""),ref:l,onChange:m,className:Y(F.input,F.textInput)})})},at=({field:e})=>{const{darkMode:r}=V(),{color:n=r?"#444444":"#CCCCCC",thickness:o=1,margin:t="8px 0"}=e;return h.jsx("div",{style:{width:"auto",height:"0",borderTop:`${o}px solid ${n}`,margin:t}})};function lr({pos:e,options:r,onClose:n,onClickOption:o}){const t=s.useRef(null),a=s.useRef(!1),l=typeof window<"u"?document.getElementById("popup-root")||document.body:null;if(s.useEffect(()=>{function f(b){a.current||b.target.dataset?.popupMenu==="item"||t.current&&b.target instanceof Node&&!t.current.contains(b.target)&&n()}return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[n]),!l||r===void 0||r.length===0||!e||e.x==null||e.y==null)return null;const c=e.x,m=e.y,d=typeof window<"u"?window.innerWidth:1024,u=Math.max(0,d-160),p=Math.max(0,Math.min(c,u)),i=Math.max(0,m);return Ae.createPortal(h.jsx("div",{ref:t,onMouseDown:f=>{f.stopPropagation()},style:{position:"fixed",top:i,left:p,backgroundColor:"var(--reactaform-primary-bg, #fff)",border:"1px solid var(--reactaform-border-color, #ccc)",borderRadius:"var(--reactaform-border-radius, 4px)",boxShadow:"var(--reactaform-shadow, 0 2px 10px rgba(0,0,0,0.2))",zIndex:9999,minWidth:"var(--reactaform-menu-min-width, 150px)",pointerEvents:"auto"},children:r.map((f,b)=>h.jsx("div",{"data-popup-menu":"item",onMouseDown:g=>{g.stopPropagation(),a.current=!0},onClick:g=>{g.stopPropagation(),g.preventDefault(),o(f),n(),setTimeout(()=>{a.current=!1},100)},style:{padding:"var(--reactaform-menu-item-padding, 8px 12px)",cursor:"pointer",fontSize:"var(--reactaform-menu-item-font-size, 0.8em)",borderBottom:b<r.length-1?"1px solid var(--reactaform-border-light, #eee)":void 0,transition:"background-color 0.15s ease"},onMouseEnter:g=>{g.currentTarget.style.backgroundColor="var(--reactaform-hover-bg, #e0e0e0)"},onMouseLeave:g=>{g.currentTarget.style.backgroundColor="transparent"},children:f.label},f.label??b))}),l)}const st=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),[l,c]=s.useState(!1),[m,d]=s.useState(null),[u,p]=s.useState([]),i=s.useRef(null),f=s.useRef(o);s.useEffect(()=>{f.current=o},[o]);const b=s.useCallback(C=>e.required&&(!C||Array.isArray(C)&&C.length===0)?t("Value required"):H(a,e,C,t)??null,[e,a,t]),g=s.useMemo(()=>b(r),[r,b]);s.useEffect(()=>{const C=b(r);n?.(r,C),f.current?.(C??null)},[r,b]);const x=C=>{const N=C.target.files;let I=null;N&&N.length>0&&(I=e.multiple?Array.from(N):N[0]);const S=b(I);n?.(I,S)},v=C=>{if(g)return;let N=null;try{N=C.currentTarget.getBoundingClientRect()}catch{N=null}const I=N&&typeof N.left=="number"?N.left:10,S=N&&typeof N.bottom=="number"?N.bottom:20;d({x:I,y:S});let R=[];Array.isArray(r)?R=r?r.map(j=>({label:j.name})):[]:R=r?[{label:r.name}]:[],R.length===0&&(R=[{label:t("No file selected")}]),p(R),c(j=>!j)};return h.jsx(B,{field:e,error:g,children:h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--reactaform-inline-gap, 8px)",width:"100%"},children:[h.jsx("input",{id:e.name,ref:i,type:"file",accept:e.accept,multiple:e.multiple,style:{width:0,height:0,opacity:0,position:"absolute",zIndex:-1},onChange:x}),h.jsx("label",{htmlFor:e.name,className:F.button,style:{width:"100%",height:"inherit",textAlign:"center"},children:e.multiple?t("Choose Files..."):t("Choose File...")}),h.jsx("button",{onClick:v,"aria-haspopup":!0,"aria-expanded":l,"aria-label":t("Show selected files"),className:F.button,style:{height:"inherit",display:"inline-block"},children:h.jsx("span",{children:"⋮"})}),l&&m&&u&&u.length>0&&h.jsx(lr,{pos:m,options:u,onClose:()=>{d(null),c(!1)},onClickOption:()=>{}})]})})},it=/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/;function ct(e){return e.split(",").map(r=>r.trim()).every(r=>it.test(r))}const lt=e=>!e||e.trim()===""?[]:e.split(",").map(r=>r.trim()).filter(Boolean).map(Number),ut=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),[l,c]=s.useState(Array.isArray(r)?r.join(", "):String(r??"")),m=s.useCallback(i=>{if(i.trim()==="")return e.required?t("Value required"):null;if(!ct(i))return t("Each value must be a valid float");const f=lt(i);if(e.minCount!==void 0&&f.length<e.minCount)return t("Minimum number of values: {{1}}",e.minCount);if(e.maxCount!==void 0&&f.length>e.maxCount)return t("Maximum number of values: {{1}}",e.maxCount);for(const g of f){if(e.min!==void 0&&(e.minInclusive?g<e.min:g<=e.min))return t("Each value must be {{1}} {{2}}",e.minInclusive?"≥":">",e.min);if(e.max!==void 0&&(e.maxInclusive?g>e.max:g>=e.max))return t("Each value must be {{1}} {{2}}",e.maxInclusive?"≤":"<",e.max)}return H(a,e,f,t)??null},[a,e,t]),d=i=>{const f=i.target.value,b=m(f);c(f),n?.(f,b)},u=s.useRef(null),p=s.useRef(o);return s.useEffect(()=>{p.current=o},[o]),s.useEffect(()=>{const i=Array.isArray(r)?r.join(", "):String(r??""),f=m(i);f!==u.current&&(u.current=f,p.current?.(f??null))},[r,e.required,m,t]),h.jsx(B,{field:e,error:m(l),children:h.jsx("input",{type:"text",value:l,onChange:d,className:Y(F.input,F.textInput),style:{flex:1}})})},ft=/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/,mt=e=>{const r=Number.parseFloat(e);return Number.isNaN(r)?null:r},dt=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),l=s.useRef(null),c=s.useCallback(p=>{if(p.trim()==="")return e.required?t("Value required"):null;if(!ft.test(p))return t("Must be a valid float");const i=mt(p);return i===null?t("Must be a valid float"):e.min!==void 0&&(e.minInclusive?i<e.min:i<=e.min)?t("Must be {{1}} {{2}}",e.minInclusive?"≥":">",e.min):e.max!==void 0&&(e.maxInclusive?i>e.max:i>=e.max)?t("Must be {{1}} {{2}}",e.maxInclusive?"≤":"<",e.max):H(a,e,i,t)??null},[e,a,t]),m=s.useRef(null),d=s.useRef(o);s.useEffect(()=>{d.current=o},[o]),s.useEffect(()=>{const p=String(r??""),i=c(p);i!==m.current&&(m.current=i,d.current?.(i??null)),l.current&&document.activeElement!==l.current&&(l.current.value=p)},[r,e,c,t]);const u=p=>{const i=p.target.value,f=c(i);n?.(i,f)};return h.jsx(B,{field:e,error:c(String(r??"")),children:h.jsx("input",{id:e.name,type:"text",defaultValue:String(r??""),ref:l,onChange:u,className:Y(F.input,F.inputNumber)})})};function pt(){try{return"/"}catch{}try{if(typeof process<"u"&&process?.env?.PUBLIC_URL)return process.env.PUBLIC_URL}catch{}return"/"}const gt=({field:e,value:r})=>{const{language:n,t:o}=V(),t=e.alignment||"center",a={left:"flex-start",center:"center",right:"flex-end"},l=typeof r=="string"?r:"";let c=l&&l.trim()!==""?l:typeof e.defaultValue=="string"?e.defaultValue:"";c&&!c.startsWith("/")&&(c=`${pt()}${c}`);const m=e.localized?.split(";").map(x=>x.trim()),[d,u]=s.useState(c||""),p=s.useRef(c||null);if(s.useEffect(()=>{if(!c)return;const x=c.split("/"),v=x.pop(),C=v.lastIndexOf(".");if(C===-1)return;const N=v.substring(0,C),I=v.substring(C);let S=null;m?.includes(n)&&(S=`${N}_${n}${I}`);const R=new AbortController;if(S){const j=[...x,S].join("/");fetch(j,{method:"HEAD",signal:R.signal}).then(w=>{const k=w.ok?j:c;k!==p.current&&(p.current=k,u(k))}).catch(()=>{c!==p.current&&(p.current=c,u(c))})}else{const j=c;j!==p.current&&(p.current=j,requestAnimationFrame(()=>u(j)))}return()=>{R.abort()}},[c,n,m]),!d)return null;const{width:i,height:f}=e,b={},g={borderRadius:"8px",objectFit:"contain",boxShadow:"0 2px 6px rgba(0,0,0,0.1)",margin:"0 0 8px 0"};return i&&f?(b.width=i,b.height=f,g.width=`${i}px`,g.height=`${f}px`):i&&!f?(b.width=i,g.width=`${i}px`,g.height="auto"):!i&&f&&(b.height=f,g.width="auto",g.height=`${f}px`),h.jsx(B,{field:e,children:h.jsx("div",{"data-testid":"image-wrapper",style:{display:"flex",justifyContent:a[t]||"center",margin:"0 0"},children:h.jsx("img",{src:d,alt:o?.(e.displayName||"Image")||e.displayName||"Image",...b,style:g})})})};function ht(e){const r=/^-?\d+$/;return e.split(",").map(n=>n.trim()).every(n=>r.test(n))}const bt=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),l=",",[c,m]=s.useState(Array.isArray(r)?r.join(l+" "):String(r??"")),d=b=>!b||b.trim()===""?[]:b.split(l).map(g=>g.trim()).filter(Boolean).map(g=>Number(g)),u=s.useCallback(b=>{if(b.trim()==="")return e.required?t("Value required"):null;if(!ht(b))return t("Each value must be a valid integer");const g=d(b);if(e.minCount!==void 0&&g.length<e.minCount)return t("Minimum number of values: {{1}}",`${e.minCount}`);if(e.maxCount!==void 0&&g.length>e.maxCount)return t("Maximum number of values: {{1}}",`${e.maxCount}`);for(const v of g){if(e.min!==void 0&&(e.minInclusive?v<e.min:v<=e.min))return t("Each value must be {{1}} {{2}}",e.minInclusive?"≥":">",e.min);if(e.max!==void 0&&(e.maxInclusive?v>e.max:v>=e.max))return t("Each value must be {{1}} {{2}}",e.maxInclusive?"≤":"<",e.max)}return H(a,e,g,t)??null},[a,e,t]),p=b=>{const g=b.target.value,x=u(g);m(g),n?.(g,x)},i=s.useRef(null),f=s.useRef(o);return s.useEffect(()=>{f.current=o},[o]),s.useEffect(()=>{const b=Array.isArray(r)?r.join(l+" "):String(r??""),g=u(b);g!==i.current&&(i.current=g,f.current?.(g??null))},[r,e.required,u,t]),h.jsx(B,{field:e,error:u(c),children:h.jsx("input",{type:"text",value:c,onChange:p,className:Y(F.input,F.textInput),style:{flex:1}})})};function yt(e){return/^[-+]?\d*$/.test(e)}const xt=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),l=s.useRef(null),c=s.useCallback(i=>{const f=parseInt(i,10);return Number.isNaN(f)?null:f},[]),m=s.useCallback(i=>{if(i.trim()==="")return e.required?t("Value required"):null;if(!yt(i))return t("Must be a valid integer");const f=c(i);if(f===null)return t("Must be a valid integer");if(e.min!==void 0&&(e.minInclusive?f<e.min:f<=e.min))return t("Must be {{1}} {{2}}",e.minInclusive?"≥":">",e.min);if(e.max!==void 0&&(e.maxInclusive?f>e.max:f>=e.max))return t("Must be {{1}} {{2}}",e.maxInclusive?"≤":"<",e.max);if(e.step!==void 0){const g=Number(e.step);if(!Number.isInteger(g))return t("Invalid step value");if(f%g!==0)return t("Must be a multiple of {{1}}",g)}return H(a,e,f,t)??null},[e,a,t,c]),d=s.useRef(null),u=s.useRef(o);s.useEffect(()=>{u.current=o},[o]),s.useEffect(()=>{const i=String(r??""),f=m(i);f!==d.current&&(d.current=f,u.current?.(f??null)),l.current&&document.activeElement!==l.current&&(l.current.value=i)},[r,e,m,t]);const p=i=>{const f=i.target.value,b=m(f);n?.(f,b)};return h.jsx(B,{field:e,error:m(String(r??"")),children:h.jsx("input",{id:e.name,type:"text",defaultValue:String(r??""),ref:l,onChange:p,className:Y(F.input,F.inputNumber)})})},vt=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),l=e.minHeight??"80px",c=s.useRef(null),m=s.useRef(null),d=s.useRef(o);s.useEffect(()=>{d.current=o},[o]);const u=s.useCallback(f=>f.trim()===""?e.required?t("Value required"):null:e.minLength!==void 0&&f.length<e.minLength?t("Must be at least {{1}} characters",e.minLength):e.maxLength!==void 0&&f.length>e.maxLength?t("Must be at most {{1}} characters",e.maxLength):H(a,e,f,t),[e,a,t]),p=f=>{const b=f.target.value,g=u(b);n?.(b,g)};s.useEffect(()=>{const f=u(r);f!==m.current&&(m.current=f,d.current?.(f??null)),c.current&&c.current.value!==String(r??"")&&(c.current.value=String(r??""))},[r,u]);const i={defaultValue:String(r??""),ref:c,onChange:p,style:{resize:"vertical",minHeight:l,width:"100%",boxSizing:"border-box"},className:Y(F.input,F.textInput)};return h.jsx(B,{field:e,error:u(r),children:h.jsx("textarea",{...i})})},wt=({field:e,value:r,onChange:n,onError:o})=>{const t=s.useRef(o);s.useEffect(()=>{t.current=o},[o]);const{t:a,darkMode:l,formStyle:c,fieldStyle:m,definitionName:d}=V(),u=(w,k,O)=>{if(!k)return{};const _=w?.[k];return(O&&_?_[O]:void 0)??{}},p=s.useRef(null),[i,f]=s.useState(!1),[b,g]=s.useState(null),x=s.useMemo(()=>e.options.map(w=>({value:w.value,label:a(w.label)})),[e.options,a]),v=s.useMemo(()=>{const w=Array.isArray(r)?r:[],k=new Set(x.map(O=>O.value));return w.filter(O=>k.has(O))},[r,x]),C=w=>{const k=Array.isArray(w)?w:[];return e.required&&k.length===0?a("Value required"):H(d,e,k,a)??null},N=()=>{if(!p.current)return;const w=p.current.getBoundingClientRect();g({x:w.left,y:w.bottom}),f(k=>!k)},I=w=>{const k=v.includes(w)?v.filter($=>$!==w):[...v,w],O=C(k);t.current?.(O??null),n?.(k,O)},S=s.useMemo(()=>({height:"var(--reactaform-input-height, 2.5rem)",padding:"var(--reactaform-input-padding, 8px)",display:"flex",alignItems:"center",boxSizing:"border-box",cursor:"pointer",position:"relative",borderRadius:"var(--reactaform-border-radius, 4px)",border:"1px solid var(--reactaform-border-color, #ccc)",background:"var(--reactaform-secondary-bg, #fff)",color:"var(--reactaform-text-color, #000)",...u(c,"multiSelect","control"),...u(m,void 0,"control")}),[c,m]),R=s.useMemo(()=>({position:"absolute",right:"1.5em",top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",fontSize:"0.8em",color:"var(--reactaform-text-muted, #999)",padding:0,...u(c,"multiSelect","clearButton"),...u(m,void 0,"clearButton")}),[c,m]),j=s.useMemo(()=>({position:"absolute",right:"0.7em",top:"50%",transform:"translateY(-50%)",pointerEvents:"none",fontSize:"0.8em",color:"var(--reactaform-text-muted, #999)",...u(c,"multiSelect","arrow"),...u(m,void 0,"arrow")}),[c,m]);return h.jsxs("div",{children:[h.jsx(B,{field:e,error:null,children:h.jsx("div",{style:{width:"100%"},children:h.jsxs("div",{ref:p,className:"reactaform-multiselection-control",style:S,onClick:N,tabIndex:0,role:"button","aria-haspopup":"listbox","aria-expanded":i,onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),N())},children:[h.jsxs("span",{style:{flex:1,color:"var(--reactaform-text-muted, #888)"},children:[v.length," / ",x.length," selected"]}),v.length>0&&h.jsx("button",{type:"button","aria-label":"Clear selections",onClick:w=>{w.stopPropagation(),n?.([],null)},style:R,children:h.jsx("span",{style:R,"aria-hidden":!0,children:"✖"})}),h.jsx("span",{style:j,"aria-hidden":!0,children:"▼"})]})})}),i&&b&&h.jsx(St,{position:b,options:x,selectedValues:v,onToggleOption:I,onClose:()=>f(!1),controlRef:p,darkMode:l})]})},St=({position:e,options:r,selectedValues:n,onToggleOption:o,onClose:t,controlRef:a,darkMode:l})=>{const c=s.useRef(null),[m,d]=s.useState(-1),{formStyle:u,fieldStyle:p}=V(),i=(R,j,w)=>{if(!j)return{};const O=R?.[j];return(w&&O?O[w]:void 0)??{}},f=s.useMemo(()=>({maxHeight:200,overflowY:"auto",background:"var(--reactaform-secondary-bg, #fff)",border:"1px solid var(--reactaform-border-color, #ccc)",borderRadius:4,zIndex:2e3,boxShadow:"var(--reactaform-shadow, 0 2px 8px rgba(0,0,0,0.15))",pointerEvents:"auto",color:"var(--reactaform-text-color, #000)",fontSize:"var(--reactaform-popup-font-size, 0.875rem)",...i(u,"multiSelect","popup"),...i(p,void 0,"popup")}),[u,p]),b=s.useMemo(()=>({padding:"6px 8px",cursor:"pointer",display:"flex",alignItems:"center",background:"transparent",color:"var(--reactaform-text-color, #000)",...i(u,"multiSelect","option"),...i(p,void 0,"option")}),[u,p]);s.useEffect(()=>{const R=j=>{const w=j.target;!c.current?.contains(w)&&!a.current?.contains(w)&&t()};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[t,a]),s.useEffect(()=>{c.current&&r.length>0&&requestAnimationFrame(()=>d(R=>R===-1?0:R))},[r.length]),s.useEffect(()=>{if(!c.current||m<0)return;const R=c.current.querySelector(`#multi-opt-${m}`);R&&requestAnimationFrame(()=>R.focus())},[m]);const g=250,x=200,[v,C]=s.useState(null),[N,I]=s.useState(null);if(s.useEffect(()=>{if(typeof window>"u")return;const R=()=>{let k=e.x,O=e.y,$=g;const _=a?.current;if(_){const U=_.getBoundingClientRect();k=U.left,O=U.bottom,$=Math.max(80,Math.round(U.width))}k=Math.min(k,window.innerWidth-$),O=Math.min(O,window.innerHeight-x),C({left:k,top:O}),I($)};R(),window.addEventListener("scroll",R,!0),window.addEventListener("resize",R);let j=null;const w=a?.current;return typeof ResizeObserver<"u"&&w&&(j=new ResizeObserver(()=>R()),j.observe(w)),()=>{window.removeEventListener("scroll",R,!0),window.removeEventListener("resize",R),j&&w&&j.unobserve(w)}},[a,e.x,e.y]),typeof window>"u")return null;let S=document.getElementById("popup-root");return S||(S=document.createElement("div"),S.id="popup-root",document.body.appendChild(S)),Ae.createPortal(h.jsx("div",{ref:c,role:"listbox","aria-activedescendant":m>=0?`multi-opt-${m}`:void 0,style:{position:"absolute",top:v?v.top:e.y,left:v?v.left:e.x,width:N??g,...f},"data-reactaform-theme":l?"dark":"light",children:r.map((R,j)=>{const w=n.includes(R.value),k=l?"var(--reactaform-hover-bg, rgba(255,255,255,0.01))":"var(--reactaform-hover-bg, #eee)",O={...b,background:j===m?k:b.background};return h.jsxs("div",{id:`multi-opt-${j}`,onMouseDown:$=>{$.stopPropagation(),o(R.value)},onKeyDown:$=>{const _=r.length;switch($.key){case"ArrowDown":$.preventDefault(),d(U=>(U+1)%_);break;case"ArrowUp":$.preventDefault(),d(U=>(U-1+_)%_);break;case"Home":$.preventDefault(),d(0);break;case"End":$.preventDefault(),d(_-1);break;case"Enter":case" ":$.preventDefault(),$.stopPropagation(),o(R.value);break;case"Escape":$.preventDefault(),t(),a?.current?.focus();break}},tabIndex:j===m?0:-1,role:"option","aria-selected":w,style:O,onMouseEnter:$=>{$.currentTarget.style.background=k,d(j)},onMouseLeave:$=>{$.currentTarget.style.background="transparent",d(_=>_===j?-1:_)},children:[h.jsx("input",{type:"checkbox",checked:w,readOnly:!0,style:{marginRight:8,width:"1.125em",height:"1.125em",verticalAlign:"middle",accentColor:l?"#10b981":"#22c55e",cursor:"pointer"}}),R.label]},R.value)})}),S)},Ct=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),l=s.useRef(null),c=e.min??void 0,m=e.max??void 0,d=Math.max(1,Math.round(e.step??1)),u=s.useCallback(g=>isNaN(g)?t("Must be a valid integer"):Number.isInteger(g)?c!==void 0&&g<c?t("Must be �?{{1}}",c):m!==void 0&&g>m?t("Must be �?{{1}}",m):H(a,e,g,t)??null:t("Must be an integer"),[a,e,t,c,m]),p=s.useRef(null),i=s.useRef(o);s.useEffect(()=>{i.current=o},[o]),s.useEffect(()=>{if(document.activeElement===l.current)return;const x=String(r),v=u(r);l.current&&(l.current.value=x),v!==p.current&&(p.current=v,i.current?.(v??null))},[r,u]);const f=g=>{if(g.trim()==="")return e.required?t("Value required"):null;const v=Number(g);return u(v)},b=g=>{const x=g.target.value,v=g.target.valueAsNumber,C=f(x);n?.(v,C)};return h.jsx(B,{field:e,error:f(String(r??"")),children:h.jsx("input",{ref:l,id:e.name,type:"number",defaultValue:String(r??""),min:c,max:m,step:d,onChange:b,style:{width:"100%",height:"100%"},className:F.input})})},Rt=({field:e,value:r,onChange:n,onError:o})=>{const{t}=V(),a=s.useRef(null),{definitionName:l}=V(),c=s.useCallback(p=>{const i=String(p??"").trim();if(i==="")return e.required?t("Value required"):null;if(e.pattern)try{if(!new RegExp(e.pattern).test(i))return t("Phone number does not match pattern: {{1}}",`${e.pattern}`)}catch{}return H(l,e,i,t)},[l,e,t]),m=s.useRef(null),d=s.useRef(o);s.useEffect(()=>{d.current=o},[o]),s.useEffect(()=>{const p=String(r??""),i=c(p);a.current&&a.current.value!==String(p)&&(a.current.value=String(p)),i!==m.current&&(m.current=i,d.current?.(i??null))},[r,c]);const u=p=>{const i=p.target.value,f=i.trim();let b=null;if(f===""){b=e.required?t("Value required"):null,n?.(i,b);return}!b&&e.pattern&&!new RegExp(e.pattern).test(f)&&(b=t("Phone number does not match pattern: {{1}}",`${e.pattern}`)),n?.(i,b)};return h.jsx(B,{field:e,error:c(String(r??"")),children:h.jsx("input",{type:"tel",defaultValue:String(r??""),ref:a,onChange:u,className:Y(F.input,F.textInput)})})},Et=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),l=e.layout?.toLowerCase()==="horizontal"?"row":"column",c=s.useRef(null),m=s.useRef(o);s.useEffect(()=>{m.current=o},[o]);const d=s.useCallback(p=>p===""||p===null||p===void 0?t("Value required"):!e.options||e.options.length===0?null:e.options.some(f=>f.value===p)?H(a,e,p,t)??null:t("Invalid option selected"),[e,t,a]);s.useEffect(()=>{const p=r!=null?String(r):"",i=d(p);if(m.current?.(i??null),c.current){const f=Array.from(c.current.querySelectorAll("input[type=radio]"));if(i&&e.options&&e.options.length>0){const b=String(e.options[0].value);f.forEach(g=>g.checked=g.value===b),n?.(b,null)}else f.forEach(b=>b.checked=b.value===p)}},[r,d,n,e.options]);const u=p=>{const i=p.target.value,f=d(i);m.current?.(f??null),n?.(i,f)};return h.jsx(B,{field:e,error:d(String(r??"")),children:h.jsx("div",{style:{display:"flex",flexDirection:l,flexWrap:l==="row"?"wrap":"nowrap",gap:l==="row"?"12px":"4px",alignItems:l==="row"?"center":"flex-start",width:"100%"},ref:c,children:(e.options??[]).map(p=>h.jsxs("label",{style:{display:"flex",gap:"6px",alignItems:"center",whiteSpace:"nowrap"},children:[h.jsx("input",{type:"radio",name:e.name,value:String(p.value),defaultChecked:String(r??"")===String(p.value),onChange:u}),t(p.label)]},String(p.value)))})})},jt={display:"flex",gap:4},kt={cursor:"pointer",fontSize:"1.5rem",lineHeight:1,display:"inline-block",marginRight:"0.25rem",userSelect:"none",transition:"color 0.12s ease"},Nt=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),[l,c]=s.useState(null),m=e.max||5,d=s.useCallback(b=>e.required&&b===0?t("Value required"):H(a,e,b,t)??null,[e,t,a]),u=s.useRef(null),p=s.useRef(o);s.useEffect(()=>{p.current=o},[o]),s.useEffect(()=>{let b=r||0;r<0&&(b=0),r>m&&(b=m);const g=d(b);g!==u.current&&(u.current=g,p.current?.(g??null))},[r,d,m]);const i=b=>{const g=d(b);n?.(b,g)},f=(()=>{let b=r||0;return b<0&&(b=0),b>m&&(b=m),b})();return h.jsx(B,{field:e,error:d(f),children:h.jsx("div",{style:jt,children:(()=>{const b=e.icon,g=b&&String(b).trim()?String(b):"★";return[...Array(m)].map((x,v)=>{const C=v<f,I=l!==null&&v<=l||C?"gold":"lightgray";return h.jsx("span",{onClick:()=>i(v+1),onMouseEnter:()=>c(v),onMouseLeave:()=>c(null),style:{...kt,color:I},"aria-label":`Rating ${v+1}`,title:t(`${e.displayName} ${v+1}`),children:g},v)})})()})})},It=/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/;function Ft(e){return It.test(e)}const At=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),l=s.useRef(null),c=s.useRef(null),m=s.useCallback(b=>{let g=null;if(b.trim()==="")return t("Value required");if(!Ft(b))return t("Invalid number");const x=Number(b);return typeof e.min=="number"&&x<e.min?t("Value should be at least {{1}}",e.min):typeof e.max=="number"&&x>e.max?t("Value should be at most {{1}}",e.max):(g||(g=H(a,e,x,t)),g)},[a,e,t]),d=s.useRef(null),u=s.useRef(o);s.useEffect(()=>{u.current=o},[o]),s.useEffect(()=>{const b=String(r),g=m(b);c.current&&document.activeElement!==c.current&&(c.current.value=isNaN(Number(b))?String(e.min??0):String(Number(b))),l.current&&document.activeElement!==l.current&&(l.current.value=b),g!==d.current&&(d.current=g,u.current?.(g??null))},[r,m,e.min]);const p=e.min??0,i=e.max??100,f=b=>{const g=b.target.value,x=m(g);n?.(g,x)};return h.jsx(B,{field:e,error:m(String(r??"")),children:h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",width:"100%"},children:[h.jsx("input",{ref:c,type:"range",defaultValue:isNaN(Number(r))?String(p):String(Number(r)),onChange:f,min:p,max:i,style:{padding:"0px, 0px",flex:1},className:F.rangeInput}),h.jsx("input",{ref:l,type:"text",defaultValue:String(r??""),onChange:f,required:!0,style:{width:"40px",minWidth:"40px",height:"2.3em",textAlign:"center",flexShrink:0},className:Y(F.input,F.textInput)})]})})},Mt=({field:e,value:r,onChange:n,onError:o})=>{const{t,formStyle:a,fieldStyle:l,definitionName:c}=V(),m=a,d=l,u=(S,R,j)=>{if(!R)return{};const w=S?.[R];return(j&&w?w[j]:void 0)??{}},p=s.useMemo(()=>({display:"inline-block",position:"relative",width:44,height:24,...u(m,"switch","label"),...u(d,void 0,"label")}),[m,d]),i=s.useMemo(()=>({position:"absolute",opacity:0,top:0,left:0,width:"100%",height:"100%",margin:0,cursor:"pointer",pointerEvents:"none",...u(m,"switch","hiddenInput"),...u(d,void 0,"hiddenInput")}),[m,d]),f=s.useMemo(()=>({position:"absolute",cursor:"pointer",top:0,left:0,right:0,bottom:0,backgroundColor:"var(--reactaform-switch-off-bg, #ccc)",transition:"0.3s",borderRadius:24,borderWidth:2,borderStyle:"solid",borderColor:"transparent",...u(m,"switch","slider"),...u(d,void 0,"slider")}),[m,d]),b=s.useMemo(()=>({position:"absolute",height:16,width:16,left:2,bottom:2,backgroundColor:"white",transition:"0.3s",borderRadius:"50%",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.3)",...u(m,"switch","knob"),...u(d,void 0,"knob")}),[m,d]),g=!!r,x=s.useRef(null),v=s.useRef(o),C=s.useCallback(S=>S?H(c,e,S,t)??null:e.required?t("Value required"):null,[e,t,c]),N=()=>{const S=!g,R=C(S);n?.(S,R)};s.useEffect(()=>{v.current=o},[o]),s.useEffect(()=>{const S=C(g);S!==x.current&&(x.current=S,v.current?.(S??null))},[g,e,C]);const I=e.name;return h.jsx(B,{field:e,error:C(g),rightAlign:!1,children:h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[h.jsx("label",{className:F.label,htmlFor:I,style:{textAlign:"left",justifyContent:"flex-start"},children:t(e.displayName)}),h.jsxs("label",{style:p,children:[h.jsx("input",{id:e.name,type:"checkbox",checked:g,readOnly:!0,"aria-label":t(e.displayName),style:i,tabIndex:-1}),h.jsx("span",{role:"switch","data-testid":"switch",tabIndex:0,"aria-checked":g,onClick:N,onKeyDown:S=>{(S.key===" "||S.key==="Spacebar"||S.key==="Space"||S.key==="Enter")&&(S.preventDefault(),N())},className:`reactaform-switch ${g?"active checked on":""} `,style:g?{...f,backgroundColor:"var(--reactaform-switch-on-bg, #22c55e)",borderColor:"var(--reactaform-switch-on-border, #16a34a)"}:f,children:h.jsx("span",{style:{...b,transform:g?"translateX(20px)":void 0}})})]})]})})},Ge=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),l=s.useRef(null),c=s.useRef(null),m=s.useRef(o);s.useEffect(()=>{m.current=o},[o]);const d=s.useMemo(()=>e.pattern?new RegExp(e.pattern):null,[e.pattern]),u=s.useCallback(i=>i.trim()===""?e.required?t("Value required"):null:e.minLength!==void 0&&i.length<e.minLength?t("Must be at least {{1}} characters",e.minLength):e.maxLength!==void 0&&i.length>e.maxLength?t("Must be at most {{1}} characters",e.maxLength):d&&!d.test(i)?t("Input does not match pattern: {{1}}",e.pattern):H(a,e,i,t),[e,a,t,d]),p=i=>{const f=i.target.value,b=u(f);n?.(f,b)};return s.useEffect(()=>{const i=u(r);l.current&&l.current.value!==String(r??"")&&(l.current.value=String(r??"")),i!==c.current&&(c.current=i,m.current?.(i??null))},[r,u]),h.jsx(B,{field:e,error:u(String(r??"")),children:h.jsx("input",{id:e.name,type:"text",defaultValue:String(r??""),ref:l,onChange:p,className:Y(F.input,F.textInput)})})},Ot=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),l=s.useRef(null),c=s.useRef(o),m=e.includeSeconds??!0;s.useEffect(()=>{c.current=o},[o]);const d=s.useCallback(p=>{if(!p||p.trim()==="")return e.required||e.min||e.max?t("Value required"):null;const i=g=>{const x=g.split(":").map(C=>parseInt(C,10));if(x.some(C=>Number.isNaN(C)))return NaN;let v=0;if(x.length===3)v=x[0]*3600+x[1]*60+x[2];else if(x.length===2)v=x[0]*3600+x[1]*60;else if(x.length===1)v=x[0]*3600;else return NaN;return v},f=i(p);if(Number.isNaN(f))return t("Invalid time format");if(e.min&&typeof e.min=="string"){const g=i(e.min);if(!Number.isNaN(g)&&f<g)return t("Time must be on or after {{1}}",e.min)}if(e.max&&typeof e.max=="string"){const g=i(e.max);if(!Number.isNaN(g)&&f>g)return t("Time must be on or before {{1}}",e.max)}return H(a,e,p,t)??null},[e,a,t]),u=p=>{const i=p.target.value,f=d(i);n?.(i,f)};return s.useEffect(()=>{const p=d(r);p!==l.current&&(l.current=p,c.current?.(p??null))},[r,d]),h.jsx(B,{field:e,error:d(r),children:h.jsx("input",{id:e.name,type:"time",value:r,step:m?1:60,onChange:u,min:typeof e.min=="string"?e.min:void 0,max:typeof e.max=="string"?e.max:void 0,className:Y(F.input,F.textInput)})})},de={};function $t(e,r){if(e in de)return;const n=Te[e]??{},o={},t={},a={};for(const[c,m]of Object.entries(n))typeof m.factor=="number"&&(o[c]=m.factor),t[c]=r(c),a[r(c)]=c;const l=Object.keys(n)[0]??"";de[e]={default:l,factors:o,labels:t,reverseLabels:a}}function Vt(e,r,n){if(e==="C"){if(r==="F")return n*(9/5)+32;if(r==="K")return n+273.15}else if(e==="F"){if(r==="C")return(n-32)*5/9;if(r==="K")return(n-32)*5/9+273.15}else if(e==="K"){if(r==="C")return n-273.15;if(r==="F")return(n-273.15)*9/5+32}return n}function zt(e,r,n){if(!Number.isFinite(e))return[];if(n===de.temperature)return Object.keys(n.labels).map(a=>{const l=Vt(r,a,e);return Number.isFinite(l)?{label:`${l.toFixed(6)} ${a}`,value:l.toString(),unit:a}:{label:`${String(l)} ${a}`,value:String(l),unit:a}});const t=n.factors[r];return t===void 0?[]:Object.entries(n.factors).map(([a,l])=>{const c=e/t*l;return Number.isFinite(c)?{label:`${c.toFixed(6)} ${a}`,value:c.toString(),unit:a}:{label:`${String(c)} ${a}`,value:String(c),unit:a}})}function ye(e,r){return e in r.labels?e:r.reverseLabels&&r.reverseLabels[e]?r.reverseLabels[e]:null}const Tt=/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/,Dt=({unitFactors:e,field:r,value:n,onChange:o,onError:t})=>{const{t:a,definitionName:l}=V(),c=s.useRef(null),m=s.useRef(null),d=s.useRef(null),[u,p]=s.useState(null),[i,f]=s.useState(null),[b,g]=s.useState(!1),[x,v]=s.useState(null),[C,N]=s.useState([]),I=s.useCallback((z,A)=>{if(!z||z.trim()==="")return r.required?a("Value required"):null;if(!Tt.test(z))return a("Must be a valid number");const y=H(l,r,[z,A],a);return y||null},[l,r,a]),S=e.reverseLabels!==void 0?e.reverseLabels:Object.fromEntries(Object.entries(e.labels).map(([z,A])=>[A,z]));s.useEffect(()=>{const z=String(n[0]);let A=n[1]??e.default;A=ye(A,e)||A;const y=document.activeElement;y===c.current||y===m.current||(c.current&&(c.current.value=z),m.current&&(m.current.value=A),d.current!==null&&(cancelAnimationFrame(d.current),d.current=null),d.current=requestAnimationFrame(()=>{d.current=null,p(null),f(null)}))},[n,e]),s.useEffect(()=>()=>{d.current!==null&&(cancelAnimationFrame(d.current),d.current=null)},[]);const R=s.useRef(null),j=s.useRef(t);s.useEffect(()=>{j.current=t},[t]),s.useEffect(()=>{const z=String(n[0]);let A=n[1]??e.default;A=ye(A,e)||A;const y=I(z,A);y!==R.current&&(R.current=y,j.current?.(y??null))},[n,e,I]);const w=(z,A,y)=>{const E=S[A]||A;o?.([z,E],y)},k=z=>{const A=z.target.value,y=m.current?m.current.value:e.default,E=I(A,y);p(A),w(A,y,E)},O=z=>{const A=z.target.value,y=c.current?c.current.value:String(n[0]??""),E=I(y,A);f(A),m.current&&(m.current.value=A),w(y,A,E)},$=z=>{const A=c.current?c.current.value:String(n[0]??""),y=parseFloat(A),E=m.current?m.current.value:e.default;if(I(A,E)||!A.trim()||!Number.isFinite(y))return;const T=z.currentTarget.getBoundingClientRect(),J=T.left,re=T.bottom;v({x:J,y:re});const P=zt(y,E,e);if(P.length===0){N([]),g(!1);return}N(P),g(X=>!X)},_=z=>{const{value:A,unit:y}=z;g(!1),v(null),c.current&&(c.current.value=A),m.current&&(m.current.value=y),p(A),f(y);const E=I(A,y);w(A,y,E)},U=String(n[0]??""),G=ye(n[1]??e.default,e)||(n[1]??e.default),ee=u??U,K=!!I(ee,i??G)||!ee.trim(),ae={width:"var(--reactaform-unit-btn-width, 2.5em)",height:"var(--reactaform-unit-btn-height, 2.5em)",padding:"var(--reactaform-unit-btn-padding, 0)",border:"none",borderRadius:"var(--reactaform-button-border-radius, var(--reactaform-border-radius, 0.25em))",backgroundColor:K?"var(--reactaform-button-disabled-bg, #cccccc)":"var(--reactaform-button-bg, var(--reactaform-success-color))",color:"var(--reactaform-button-text, #ffffff)",cursor:K?"var(--reactaform-button-disabled-cursor, not-allowed)":"pointer",opacity:K?+"var(--reactaform-button-disabled-opacity, 0.6)":1,display:"flex",alignItems:"center",justifyContent:"center"};return h.jsx(B,{field:r,error:I(U,G),children:h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--reactaform-unit-gap, 8px)",width:"100%"},children:[h.jsx("input",{type:"text",ref:c,defaultValue:String(n[0]??""),onChange:k,style:{width:"var(--reactaform-unit-input-width, 100px)"},className:Y(F.input,F.textInput)}),h.jsx("select",{ref:m,defaultValue:ye(n[1]??e.default,e)||(n[1]??e.default),onChange:O,className:Y(F.input,F.inputSelect),children:Object.keys(e.labels).map(z=>h.jsx("option",{value:z,children:e.labels[z]??z},z))}),h.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[h.jsx("button",{onClick:$,"aria-disabled":K,disabled:K,style:ae,className:F.button,children:h.jsx("span",{style:{fontSize:"var(--reactaform-unit-btn-icon-size, 1em)",lineHeight:"1",transform:"translateY(-1px)",pointerEvents:"none"},children:"⟷"})}),b&&C&&h.jsx(lr,{pos:x,options:C,onClose:()=>{v(null),g(!1)},onClickOption:_})]})]})})};function Lt({field:e,value:r,onChange:n}){const{t:o}=V(),t=e.dimension;if(!t)return null;de[t]||$t(t,o);const a=de[t];return a?h.jsx(Dt,{unitFactors:a,field:e,value:r,onChange:n}):null}const Pt=/^(https?|ftp|file):\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|]$/i,_t=e=>{try{return new URL(e),!0}catch{return!1}},qt=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),l=s.useRef(null),c=s.useCallback(p=>{const i=p.trim();return i===""?e.required?t("Value required"):null:!Pt.test(i)&&!_t(i)?t("Must be a valid URL"):H(a,e,i,t)??null},[a,e,t]),m=p=>{const i=p.target.value,f=c(i);n?.(i.trim(),f)},d=s.useRef(null),u=s.useRef(o);return s.useEffect(()=>{u.current=o},[o]),s.useEffect(()=>{const p=r??"",i=c(p);l.current&&l.current.value!==String(p)&&(l.current.value=String(p)),i!==d.current&&(d.current=i,u.current?.(i??null))},[r,c]),h.jsx(B,{field:e,error:c(String(r??"")),children:h.jsx("input",{id:e.name,type:"url",defaultValue:String(r??""),ref:l,onChange:m,style:{alignItems:"left"},className:Y(F.input,F.textInput),placeholder:"https://example.com"})})},Fe=new ve,Bt=new Set(["checkbox","switch","dropdown","radio","multi-selection","slider","stepper","color","rating"]),ur={checkbox:Xr,color:Qr,date:rt,dropdown:tt,email:ot,file:st,float:dt,"float-array":ut,image:gt,int:xt,"int-array":bt,"multi-selection":wt,multiline:vt,phone:Rt,radio:Et,rating:Nt,separator:at,slider:At,string:Ge,stepper:Ct,switch:Mt,text:Ge,time:Ot,unit:Lt,url:qt};function fr(e,r,n){if(!n&&e in ur){console.warn(`Can't Overwrite Base Component type "${e}".`);return}if(Bt.has(e)){Fe.register(e,r);return}const o=t=>{const{callback:l,cancel:c}=Xe((...m)=>{const d=t.onChange;typeof d=="function"&&d(...m)},200);return s.useEffect(()=>()=>{c()},[c]),s.createElement(r,{...t,onChange:l})};Fe.register(e,o)}function Ht(e,r){fr(e,r,!1)}function De(e){return Fe.get(e)}let Ke=!1;function mr(){Ke||(Object.entries(ur).forEach(([e,r])=>{fr(e,r,!0)}),Ke=!0)}const dr=new ve;function pr(e,r){dr.register(e,r)}function Ut(e){return dr.get(e)}pr("Preset_AlertSubmitHandler",(e,r,n)=>{const o={name:r||"Unnamed Instance",version:e.version,definition:e.name,values:n},t=JSON.stringify(o,null,2);alert(t)});const gr=s.memo(({field:e,value:r,handleChange:n,handleError:o})=>{const t=De(e.type),a=s.useCallback((c,m)=>n(e.name,c,m),[n,e.name]),l=s.useCallback(c=>o?.(e.name,c),[o,e.name]);return t?h.jsx(t,{field:e,value:r,onChange:a,onError:l}):null},(e,r)=>e.field===r.field&&e.value===r.value&&e.handleChange===r.handleChange&&e.handleError===r.handleError);gr.displayName="FieldWrapper";const hr=(e,r,n,o)=>h.jsx(gr,{field:e,value:r[e.name],handleChange:n,handleError:o},e.name),br=s.memo(({groupName:e,isOpen:r,fields:n,valuesMap:o,handleChange:t,handleError:a,toggleGroup:l,t:c})=>{const m=s.useCallback(()=>l(e),[l,e]),{formStyle:d,fieldStyle:u}=V(),p=s.useMemo(()=>({border:"1px solid var(--reactaform-border-color, #bbb)",padding:"var(--reactaform-fieldset-padding, 0.5em)",borderRadius:"var(--reactaform-border-radius, 4px)",marginBottom:"var(--reactaform-space, 8px)",...d?.fieldset||{},...u?.fieldset||{}}),[d,u]),i=s.useMemo(()=>({fontWeight:"bold",cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0 var(--reactaform-space, 8px)",color:"var(--reactaform-text-color, inherit)",...d?.legend||{},...u?.legend||{}}),[d,u]);return h.jsxs("fieldset",{style:p,children:[h.jsxs("legend",{onClick:m,style:i,children:[h.jsx("span",{children:c(e)}),h.jsx("span",{children:r?"▼":"▶"})]}),r&&n.map(f=>h.jsx("div",{children:hr(f,o,t,a)},f.name))]})});br.displayName="FieldGroup";const Wt=(e,r,n,o,t,a,l,c,m)=>{const d=r.slice(0,c).filter(f=>l[f.name]),p=ar(d).groups,i=[];return p.forEach(f=>{if(f.name){const b=e[f.name]??!0;i.push(h.jsx(br,{groupName:f.name,isOpen:b,fields:f.fields,valuesMap:n,handleChange:t,handleError:a,toggleGroup:m,t:o},f.name))}else f.fields.forEach(b=>i.push(h.jsx("div",{children:hr(b,n,t,a)},b.name)))}),i},Yt=({fields:e,visibility:r,groupState:n,toggleGroup:o,t,renderField:a,containerHeight:l=600,estimatedFieldHeight:c=60})=>{const m=s.useRef(null),d=s.useMemo(()=>{const i=e.filter(g=>r[g.name]),f=ar(i),b=[];return f.groups.forEach(g=>{if(g.name){const x=n[g.name]??!0;b.push({type:"group-header",groupName:g.name,isOpen:x}),x&&g.fields.forEach(v=>{b.push({type:"field",field:v})})}else g.fields.forEach(x=>{b.push({type:"field",field:x})})}),b},[e,r,n]),u=i=>{const f=d[i];if(!f)return c;if(f.type==="group-header")return 50;const b=f.field?.type;return b==="multiline"?120:b==="separator"?30:b==="image"?200:c},p=s.useCallback(({index:i,style:f})=>{const b=d[i];return b?b.type==="group-header"&&b.groupName?h.jsx("div",{style:f,children:h.jsx("fieldset",{style:{border:"1px solid var(--reactaform-border-color, #bbb)",padding:"0",borderRadius:"var(--reactaform-border-radius, 4px)",marginBottom:"var(--reactaform-space, 8px)"},children:h.jsxs("legend",{onClick:()=>o(b.groupName),style:{fontWeight:"bold",cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0 var(--reactaform-space, 8px)",color:"var(--reactaform-text-color, inherit)"},children:[h.jsx("span",{children:t(b.groupName)}),h.jsx("span",{children:b.isOpen?"▼":"▶"})]})})}):b.type==="field"&&b.field?h.jsx("div",{style:f,children:a(b.field)},b.field.name):h.jsx("div",{style:f}):h.jsx("div",{style:f})},[d,o,a,t]);return d.length===0?h.jsx("div",{style:{padding:"var(--reactaform-space, 8px)",color:"var(--reactaform-text-muted, #666)"},children:t("No fields to display")}):h.jsx(Er.List,{listRef:m,defaultHeight:l,rowCount:d.length,rowHeight:u,rowComponent:p,rowProps:{}})},Jt=e=>{const r={};return e.forEach(n=>{r[n.name]=!1}),r},Le=(e,r,n,o)=>{const t=r[e];if(!t?.children)return;const a=n[e],l=a!=null?String(a):"";(t.children[l]||[]).forEach(m=>{o[m]=!0,Le(m,r,n,o)})},yr=(e,r,n)=>{const o=r[e];o?.children&&Object.values(o.children).flat().forEach(t=>{n[t]=!1,yr(t,r,n)})},Gt=(e,r,n,o)=>{const t={...n};return e.forEach(a=>{(!a.parents||Object.keys(a.parents).length===0)&&(t[a.name]=!0,Le(a.name,o,r,t))}),t},Kt=(e,r,n,o,t)=>{const a={...e};if(yr(o,r,a),t!=null){const l=r[o];if(l?.children){const c=String(t);(l.children[c]||[]).forEach(d=>{a[d]=!0,Le(d,r,n,a)})}}return a};function Xt(e,r,n,o,t){const a=Object.values(t).filter(Boolean);if(a.length>0)return{success:!1,message:o("Please fix validation errors before submitting."),errors:a};const l={...n},c=[];if(e&&Array.isArray(e.properties))for(const d of e.properties){const u=d.name,p=l[u];if(p==null)continue;const i=d.type;try{if((i==="int"||i==="number"||i==="float")&&typeof p=="string"){const f=Number(String(p).trim());isNaN(f)?c.push(o(`Invalid number format for field ${d.displayName||u}`)):l[u]=f}else if((i==="int-array"||i==="float-array")&&typeof p=="string"){const b=String(p).split(",").map(g=>g.trim()).filter(Boolean).map(g=>{const x=Number(g);return isNaN(x)?(c.push(o(`Invalid number "${g}" in array for field ${d.displayName||u}`)),0):x});c.length===0&&(l[u]=b)}}catch(f){c.push(o(`Error processing field ${d.displayName||u}: ${f}`))}}if(c.length>0)return{success:!1,message:o("Data transformation errors occurred."),errors:c};const m=nr(e,l,o);if(m&&m.length>0)return{success:!1,message:"Validation Fail",errors:m};if(e&&typeof e.submitHandlerName=="string"){const d=Ut(e.submitHandlerName);if(d)try{const u=d(e,r?.name??null,l,o);if(u&&u.length>0)return{success:!1,message:o("Submission failed."),errors:Array.isArray(u)?u:[u]}}catch(u){return{success:!1,message:o("Submission handler error occurred."),errors:[String(u)]}}}return{success:!0,message:o("Form submitted successfully."),data:l}}const xr=({definition:e,instance:r,chunkSize:n=50,chunkDelay:o=50,enableVirtualization:t=!1,virtualizationThreshold:a=50,virtualContainerHeight:l=600,estimatedFieldHeight:c=60})=>{const{properties:m,displayName:d}=e,u=V(),{t:p,formStyle:i,language:f}=u,b={...u,definitionName:e?.name??u.definitionName},[g,x]=s.useState("en"),[v,C]=s.useState([]),[N,I]=s.useState({}),[S,R]=s.useState({}),[j,w]=s.useState({}),[k,O]=s.useState({}),[$,_]=s.useState({}),[U,G]=s.useState(null),[ee,Q]=s.useState(null),[K,ae]=s.useState(0),[z,A]=s.useState(!1),[y,E]=s.useState(!1),[L,T]=s.useState(r.name||""),J=s.useRef(r),re=s.useRef(!1);s.useEffect(()=>{const M=Object.fromEntries(m.map(q=>[q.name,{...q,children:{}}]));m.forEach(q=>{q.parents&&Object.entries(q.parents).forEach(([ce,we])=>{const le=M[ce];le&&we.forEach(Rr=>{le.children||(le.children={});const Pe=String(Rr);le.children[Pe]=[...le.children[Pe]||[],q.name]})})}),Br(m,M);const D=Object.values(M),W={};D.forEach(q=>{if(q.type==="unit"){const ce=typeof q.defaultValue=="number"?String(q.defaultValue):"",we=typeof q.defaultUnit=="string"?q.defaultUnit:String(q.defaultUnit??"m");W[q.name]=[ce,we]}else W[q.name]=q.defaultValue}),J.current=r,Object.keys(r.values).forEach(q=>{M[q]!==void 0&&(W[q]=r.values[q])});const Z=Jt(D),te={};D.forEach(q=>{q.group&&!(q.group in te)&&(te[q.group]=!0)});const se=requestAnimationFrame(()=>{C(D),I(M),R(W),w(Gt(D,W,Z,M)),O(te),A(!0),T(r.name)});return()=>cancelAnimationFrame(se)},[m,r,e]),s.useEffect(()=>{if(!z||K>=v.length)return;const M=setTimeout(()=>{ae(D=>Math.min(D+n,v.length))},o);return()=>clearTimeout(M)},[z,K,v.length,n,o]);const P=s.useCallback((M,D,W)=>{G(null),Q(null),R(Z=>{const te={...Z,[M]:D},se=N[M];return se&&["checkbox","dropdown","multi-select","radio","switch"].includes(se.type)&&w(ce=>Kt(ce,N,te,M,String(D))),te}),_(Z=>W?{...Z,[M]:W}:Object.fromEntries(Object.entries(Z).filter(([se])=>se!==M)))},[N,G,Q]);s.useEffect(()=>{let M=0;return M=requestAnimationFrame(()=>{f!==g&&(x(f||"en"),G(null),Q(null))}),()=>cancelAnimationFrame(M)},[f,g]),s.useEffect(()=>{let M=0;return M=requestAnimationFrame(()=>{if(re.current){re.current=!1,J.current=r,T(r.name||"");return}J.current=r,G(null),Q(null),T(r.name||"")}),()=>cancelAnimationFrame(M)},[r,r.name]);const X=s.useCallback((M,D)=>{_(W=>D?{...W,[M]:String(D)}:Object.fromEntries(Object.entries(W).filter(([te])=>te!==M)))},[]),ie=()=>{re.current=!0;const M=J.current?.name;J.current.name=L;const D=Xt(e,J.current,S,p,$),W=typeof D.message=="string"?D.message:String(D.message),Z=Object.values(D.errors??{}).join(`
293
+ `);G(Z?W+`
294
+ `+Z:W),Q(D.success),D.success||(J.current.name=M??J.current.name,T(M??""))},pe=M=>{O(D=>({...D,[M]:!D[M]}))},Sr=s.useCallback(M=>{const D=De(M.type);return D?h.jsx("div",{children:h.jsx(D,{field:M,value:S[M.name],onChange:(W,Z)=>P(M.name,W,Z),onError:W=>X(M.name,W)})},M.name):null},[S,P,X]),ge=s.useMemo(()=>Object.values($).some(Boolean),[$]),Cr=s.useMemo(()=>t?v.filter(D=>j[D.name]).length>=a:!1,[t,v,j,a]);return z?h.jsx(xe.Provider,{value:b,children:h.jsxs("div",{style:i.container,children:[d&&h.jsx("h2",{style:i.titleStyle,children:p(d)}),U&&h.jsxs("div",{role:"status",style:{marginBottom:12,padding:12,borderRadius:6,backgroundColor:ee?"rgba(76, 175, 80, 0.12)":"rgba(225, 29, 72, 0.06)",border:`1px solid ${ee?"rgba(76,175,80,0.3)":"rgba(225,29,72,0.12)"}`,color:ee?"var(--reactaform-success-color, #4CAF50)":"var(--reactaform-error-color, #e11d48)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[h.jsx("div",{style:{whiteSpace:"pre-wrap",flex:1},children:U}),h.jsx("button",{onClick:()=>{G(null),Q(null)},"aria-label":p("Dismiss"),style:{marginLeft:12,background:"transparent",border:"none",cursor:"pointer",color:"inherit",fontSize:16,lineHeight:1},children:"×"})]}),r&&h.jsx(er,{name:L,onChange:M=>{T(M),G(null),Q(null)}}),Cr?h.jsx(Yt,{fields:v,valuesMap:S,visibility:j,groupState:k,handleChange:P,handleError:X,toggleGroup:pe,t:p,renderField:Sr,containerHeight:l,estimatedFieldHeight:c}):h.jsxs(h.Fragment,{children:[Wt(k,v,S,p,P,X,j,K,pe),K<v.length&&h.jsx("div",{style:{fontSize:"0.9em",color:"var(--reactaform-text-muted, #666)"}})]}),h.jsx("button",{onClick:ie,disabled:ge,onMouseEnter:()=>E(!0),onMouseLeave:()=>E(!1),style:{padding:"var(--reactaform-button-padding, var(--reactaform-space) 12px)",backgroundColor:ge?"var(--reactaform-button-disabled-bg, #cccccc)":"var(--reactaform-button-bg, var(--reactaform-success-color))",color:"var(--reactaform-button-text, #ffffff)",border:"none",borderRadius:"4px",cursor:ge?"var(--reactaform-button-disabled-cursor, not-allowed)":"pointer",fontSize:"var(--reactaform-button-font-size, 14px)",fontWeight:"var(--reactaform-button-font-weight, 500)",boxShadow:"var(--reactaform-button-shadow, none)",marginTop:"var(--reactaform-button-margin-top, 0.5em)",transition:"opacity 0.2s ease",opacity:ge?"var(--reactaform-button-disabled-opacity, 0.6)":y?"var(--reactaform-button-hover-opacity, 0.9)":"1"},children:p("Submit")})]})}):h.jsx(xe.Provider,{value:b,children:h.jsx("div",{children:"Initializing form..."})})};mr();const Zt=(e,r=!1)=>({container:{padding:"var(--reactaform-space-sm, 8px)",margin:"0 auto",backgroundColor:"transparent",borderRadius:0,color:"var(--reactaform-color-text)",fontFamily:e?.fontFamily||"var(--reactaform-font-family, system-ui, -apple-system, sans-serif)",boxSizing:"border-box",minHeight:e?.minHeight??"0",...e?.width?{width:e.width,overflowX:"auto"}:{maxWidth:"100%"},...e?.height?{height:e.height,overflowY:"auto"}:{}},buttonStyle:{padding:"var(--reactaform-space-sm, 8px) var(--reactaform-space-md, 16px)",backgroundColor:"var(--reactaform-color-primary)",color:"var(--reactaform-color-background)",border:"1px solid var(--reactaform-color-primary)",borderRadius:"var(--reactaform-border-radius, 6px)",cursor:"pointer",fontSize:e?.fontSize||"1rem",fontWeight:"600",transition:"all 0.2s ease",boxShadow:"var(--reactaform-shadow-small, 0 1px 3px rgba(0, 0, 0, 0.12))"},titleStyle:{marginBottom:"var(--reactaform-space-lg, 24px)",color:"var(--reactaform-color-text)",fontSize:typeof e?.fontSize=="number"?`${e.fontSize*1.5}px`:"1.5rem",fontWeight:"700",lineHeight:"1.2",textAlign:"left"}}),Qt=(e,r=!1)=>{const n={color:"var(--reactaform-color-text)",fontFamily:e?.fontFamily||"var(--reactaform-font-family, inherit)",transition:"all 0.2s ease",outline:"none",width:"100%",boxSizing:"border-box"};return{container:{fontFamily:e?.fontFamily||"var(--reactaform-font-family, inherit)",fontSize:e?.fontSize||"var(--reactaform-font-size, 1rem)",width:"100%",maxWidth:e?.width||"100%",marginBottom:"var(--reactaform-space-md, 16px)"},label:{display:"block",marginBottom:"var(--reactaform-space-xs, 4px)",fontWeight:"500",color:"var(--reactaform-color-text)",fontSize:"var(--reactaform-font-size, 1rem)",fontFamily:e?.fontFamily||"var(--reactaform-font-family, inherit)"},input:n,textInput:n,optionInput:n,select:{...n,cursor:"pointer",backgroundRepeat:"no-repeat",backgroundPosition:"right 8px center",backgroundSize:"16px",paddingRight:"32px",backgroundImage:`url("data:image/svg+xml;utf8,<svg
296
295
  xmlns='http://www.w3.org/2000/svg'
297
296
  viewBox='0 0 24 24'
298
297
  fill='none'
@@ -301,4 +300,4 @@ React keys must be passed directly to JSX without using spread:
301
300
  stroke-linecap='round'
302
301
  stroke-linejoin='round'>
303
302
  <polyline points='6,9 12,15 18,9'/>
304
- </svg>")`},textarea:{...r,minHeight:"80px",resize:"vertical",paddingTop:"var(--reactaform-space-sm, 8px)"},error:{color:"var(--reactaform-color-error)",fontSize:"0.875rem",marginTop:"var(--reactaform-space-xs, 4px)",display:"block"}}},jt=({children:e,defaultDefinitionName:t="",defaultStyle:r,defaultLanguage:o="en",defaultDarkMode:n=!1,defaultLocalizeName:a="",className:i="reactaform-container"})=>{const c=t,f=a,m=n,l=o,d=s.useMemo(()=>r??{},[r]),[u,p]=s.useState({}),[h,g]=s.useState({}),[x,v]=s.useState({}),[C,k]=s.useState({});s.useEffect(()=>{let S=!0;return(async()=>{if(l==="en"){S&&(p({}),g({}));return}try{const I=await Gt(l),M=I.success?I.translations:{};S&&p(M);const V=await Kt(l,f),$=V.success?V.translations:{};S&&g($)}catch{S&&(p({}),g({}))}})(),()=>{S=!1}},[l,f]),s.useEffect(()=>{k(gn(d,m)),v(hn(d,m))},[d,m]);const O=s.useMemo(()=>Zt(l,u,h),[l,u,h]),w=s.useCallback((S,...E)=>O(S,...E),[O]),R=s.useMemo(()=>({definitionName:c,language:l,darkMode:m,formStyle:C,fieldStyle:x,t:w}),[c,l,m,x,C,w]),j=d?.height?{height:"100%"}:void 0;return b.jsx(tt.Provider,{value:R,children:b.jsx("div",{"data-reactaform-theme":m?"dark":"light",className:i,style:j,children:e})})};function bn(e){if(!e||typeof e!="object")return"Definition must be an object";const t=e;if(!t.name||typeof t.name!="string")return"Definition must include a 'name' string";if(!t.version||typeof t.version!="string")return"Definition must include a 'version' string";if(t.properties!==void 0&&!Array.isArray(t.properties))return"'properties' must be an array if provided";if(Array.isArray(t.properties))for(let r=0;r<t.properties.length;r++){const o=t.properties[r];if(!o||typeof o!="object")return`Property at index ${r} must be an object`;if(!o.name||typeof o.name!="string")return`Property at index ${r} must have a string 'name'`;if(!o.type||typeof o.type!="string")return`Property '${o.name}' must have a string 'type'`}return null}async function yn(e,t={}){const{validateSchema:r=!0}=t;try{if(!e||typeof e!="string")return{success:!1,error:"jsonData must be a non-empty JSON string"};const o=e.trim();if(!o)return{success:!1,error:"jsonData is empty"};let n;try{n=JSON.parse(o)}catch(a){return{success:!1,error:`Invalid JSON format: ${a instanceof Error?a.message:"Unknown parsing error"}`}}if(r){const a=bn(n);if(a)return{success:!1,error:`Schema validation failed: ${a}`}}return{success:!0,definition:n}}catch(o){return{success:!1,error:`Unexpected error loading definition: ${o instanceof Error?o.message:"Unknown error"}`}}}function kt(e,t){try{if(!e)return{success:!1,error:"Definition is required"};if(!t||typeof t!="string")return{success:!1,error:"Instance name is required"};const r={name:t,definition:e.name??"unknown",version:e.version??"1.0.0",values:{}},o=e.properties||[];return Array.isArray(o)&&o.forEach(n=>{const a=n;a.defaultValue!==void 0&&(r.values[a.name]=a.defaultValue)}),{success:!0,instance:r}}catch(r){return{success:!1,error:`Error creating instance: ${r instanceof Error?r.message:"Unknown error"}`}}}function xn(e){try{if(!e)return{success:!1,error:"Instance data is required"};let t;if(typeof e=="string")try{t=JSON.parse(e)}catch(r){return{success:!1,error:`Invalid JSON format: ${r instanceof Error?r.message:"Unknown parsing error"}`}}else t=e;return typeof t!="object"||t===null?{success:!1,error:"Instance must be a valid object"}:{success:!0,instance:t}}catch(t){return{success:!1,error:`Error loading instance: ${t instanceof Error?t.message:"Unknown error"}`}}}bt();function vn(e){const[t,r]=s.useState(null);return s.useEffect(()=>{const o=document.querySelector("[data-reactaform-theme]");if(!o)return;const n=o.closest("[data-reactaform-theme]");if(!n)return;const a=()=>r(n.getAttribute("data-reactaform-theme"));a();const i=new MutationObserver(c=>{for(const f of c)f.type==="attributes"&&f.attributeName==="data-reactaform-theme"&&a()});return i.observe(n,{attributes:!0,attributeFilter:["data-reactaform-theme"]}),()=>i.disconnect()},[e]),t}const wn=({definitionData:e,instance:t,language:r,className:o,darkMode:n,style:a})=>{const i=s.useMemo(()=>{try{return typeof e=="string"?JSON.parse(e):e??null}catch{return null}},[e]),c={fontSize:"inherit",fontFamily:"inherit",...a},f=vn(),m=n??f==="dark",l=r??"en";if(s.useEffect(()=>{let u=document.getElementById("popup-root");u||(u=document.createElement("div"),u.id="popup-root",document.body.appendChild(u))},[]),!i)return b.jsx("div",{style:{color:"red"},children:"Error: No form definition provided."});let d=t;if(!d){const u=kt(i,i.name);if(!u.success||!u.instance)return b.jsx("div",{style:{color:"red"},children:"Error: Failed to create instance from definition."});d=u.instance}return b.jsx(jt,{defaultDefinitionName:i.name,defaultStyle:c,defaultLanguage:l,defaultDarkMode:m,defaultLocalizeName:i.localization||"",className:o,children:b.jsx(Et,{definition:i,instance:d})})};function Sn(){if(!(typeof document>"u")&&!document.getElementById("reactaform-styles"))try{const e=document.createElement("style");e.id="reactaform-styles",e.textContent=Ot,document.head.appendChild(e)}catch{}}Sn();exports.CSS_CLASSES=A;exports.ReactaForm=wn;exports.ReactaFormProvider=jt;exports.ReactaFormRenderer=Et;exports.StandardFieldLayout=W;exports.Units=er;exports.combineClasses=G;exports.createInstanceFromDefinition=kt;exports.deserializeDefinition=Ht;exports.deserializeInstance=_t;exports.getComponent=Le;exports.loadInstance=xn;exports.loadJsonDefinition=yn;exports.registerComponent=Jr;exports.registerFieldValidationHandler=$t;exports.registerFormValidationHandler=Vt;exports.registerSubmissionHandler=xt;exports.serializeDefinition=Bt;exports.serializeInstance=Dt;exports.useDebouncedCallback=rt;exports.useReactaFormContext=T;exports.validateFieldValue=U;exports.validateFormValues=ct;
303
+ </svg>")`},textarea:{...n,minHeight:"80px",resize:"vertical",paddingTop:"var(--reactaform-space-sm, 8px)"},error:{color:"var(--reactaform-color-error)",fontSize:"0.875rem",marginTop:"var(--reactaform-space-xs, 4px)",display:"block"}}},vr=({children:e,definitionName:r="",defaultStyle:n,defaultLanguage:o="en",defaultDarkMode:t=!1,defaultLocalizeName:a="",className:l="reactaform-container"})=>{const c=r,m=a,d=t,u=o,p=s.useMemo(()=>n??{},[n]),[i,f]=s.useState({}),[b,g]=s.useState({}),[x,v]=s.useState({}),[C,N]=s.useState({});s.useEffect(()=>{let w=!0;return(async()=>{if(u==="en"){w&&(f({}),g({}));return}try{const O=await Ur(u),$=O.success?O.translations:{};w&&f($);const _=await Wr(u,m),U=_.success?_.translations:{};w&&g(U)}catch{w&&(f({}),g({}))}})(),()=>{w=!1}},[u,m]),s.useEffect(()=>{N(Zt(p,d)),v(Qt(p,d))},[p,d]);const I=s.useMemo(()=>Jr(u,i,b),[u,i,b]),S=s.useCallback((w,...k)=>I(w,...k),[I]),R=s.useMemo(()=>({definitionName:c,language:u,darkMode:d,formStyle:C,fieldStyle:x,t:S}),[c,u,d,x,C,S]),j=p?.height?{height:"100%"}:void 0;return h.jsx(xe.Provider,{value:R,children:h.jsx("div",{"data-reactaform-theme":d?"dark":"light",className:l,style:j,children:e})})};function en(e){if(!e||typeof e!="object")return"Definition must be an object";const r=e;if(!r.name||typeof r.name!="string")return"Definition must include a 'name' string";if(!r.version||typeof r.version!="string")return"Definition must include a 'version' string";if(r.properties!==void 0&&!Array.isArray(r.properties))return"'properties' must be an array if provided";if(Array.isArray(r.properties))for(let n=0;n<r.properties.length;n++){const o=r.properties[n];if(!o||typeof o!="object")return`Property at index ${n} must be an object`;if(!o.name||typeof o.name!="string")return`Property at index ${n} must have a string 'name'`;if(!o.type||typeof o.type!="string")return`Property '${o.name}' must have a string 'type'`}return null}async function rn(e,r={}){const{validateSchema:n=!0}=r;try{if(!e||typeof e!="string")return{success:!1,error:"jsonData must be a non-empty JSON string"};const o=e.trim();if(!o)return{success:!1,error:"jsonData is empty"};let t;try{t=JSON.parse(o)}catch(a){return{success:!1,error:`Invalid JSON format: ${a instanceof Error?a.message:"Unknown parsing error"}`}}if(n){const a=en(t);if(a)return{success:!1,error:`Schema validation failed: ${a}`}}return{success:!0,definition:t}}catch(o){return{success:!1,error:`Unexpected error loading definition: ${o instanceof Error?o.message:"Unknown error"}`}}}function wr(e,r){try{if(!e)return{success:!1,error:"Definition is required"};if(!r||typeof r!="string")return{success:!1,error:"Instance name is required"};const n={name:r,definition:e.name??"unknown",version:e.version??"1.0.0",values:{}},o=e.properties||[];return Array.isArray(o)&&o.forEach(t=>{const a=t;a.defaultValue!==void 0&&(n.values[a.name]=a.defaultValue)}),{success:!0,instance:n}}catch(n){return{success:!1,error:`Error creating instance: ${n instanceof Error?n.message:"Unknown error"}`}}}function tn(e){try{if(!e)return{success:!1,error:"Instance data is required"};let r;if(typeof e=="string")try{r=JSON.parse(e)}catch(n){return{success:!1,error:`Invalid JSON format: ${n instanceof Error?n.message:"Unknown parsing error"}`}}else r=e;return typeof r!="object"||r===null?{success:!1,error:"Instance must be a valid object"}:{success:!0,instance:r}}catch(r){return{success:!1,error:`Error loading instance: ${r instanceof Error?r.message:"Unknown error"}`}}}mr();function nn(e){const[r,n]=s.useState(null);return s.useEffect(()=>{const o=document.querySelector("[data-reactaform-theme]");if(!o)return;const t=o.closest("[data-reactaform-theme]");if(!t)return;const a=()=>n(t.getAttribute("data-reactaform-theme"));a();const l=new MutationObserver(c=>{for(const m of c)m.type==="attributes"&&m.attributeName==="data-reactaform-theme"&&a()});return l.observe(t,{attributes:!0,attributeFilter:["data-reactaform-theme"]}),()=>l.disconnect()},[e]),r}const on=({definitionData:e,instance:r,language:n,className:o,darkMode:t,style:a})=>{const l=s.useMemo(()=>{try{return typeof e=="string"?JSON.parse(e):e??null}catch{return null}},[e]),c={fontSize:"inherit",fontFamily:"inherit",...a},m=nn(),d=t??m==="dark",u=n??"en";if(s.useEffect(()=>{let i=document.getElementById("popup-root");i||(i=document.createElement("div"),i.id="popup-root",document.body.appendChild(i))},[]),!l)return h.jsx("div",{style:{color:"red"},children:"Error: No form definition provided."});let p=r;if(!p){const i=wr(l,l.name);if(!i.success||!i.instance)return h.jsx("div",{style:{color:"red"},children:"Error: Failed to create instance from definition."});p=i.instance}return h.jsx(vr,{definitionName:l.name,defaultStyle:c,defaultLanguage:u,defaultDarkMode:d,defaultLocalizeName:l.localization||"",className:o,children:h.jsx(xr,{definition:l,instance:p})})};function an(){if(!(typeof document>"u")&&!document.getElementById("reactaform-styles"))try{const e=document.createElement("style");e.id="reactaform-styles",e.textContent=jr,document.head.appendChild(e)}catch{}}an();exports.CSS_CLASSES=F;exports.ReactaForm=on;exports.ReactaFormProvider=vr;exports.ReactaFormRenderer=xr;exports.StandardFieldLayout=B;exports.Units=Kr;exports.combineClasses=Y;exports.createInstanceFromDefinition=wr;exports.deserializeDefinition=Pr;exports.deserializeInstance=Tr;exports.getComponent=De;exports.loadInstance=tn;exports.loadJsonDefinition=rn;exports.registerComponent=Ht;exports.registerFieldValidationHandler=Mr;exports.registerFormValidationHandler=Ar;exports.registerSubmissionHandler=pr;exports.serializeDefinition=Lr;exports.serializeInstance=Vr;exports.useDebouncedCallback=Xe;exports.useReactaFormContext=V;exports.validateFieldValue=H;exports.validateFormValues=nr;