iq-line-form-builder-renderer 1.2.26 → 1.2.28
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.
- package/dist/form-renderer.es.js +5918 -5656
- package/dist/form-renderer.umd.js +19 -19
- package/dist/page/LcNcRouteOutlet.d.ts +20 -0
- package/dist/page/LcNcRouteOutlet.d.ts.map +1 -0
- package/dist/page/StudioPageHost.d.ts.map +1 -1
- package/dist/page/http.d.ts.map +1 -1
- package/dist/page/index.d.ts +2 -0
- package/dist/page/index.d.ts.map +1 -1
- package/dist/page/types/page.d.ts +3 -0
- package/dist/page/types/page.d.ts.map +1 -1
- package/dist/page/utils/normalizePageApiResponse.d.ts +10 -0
- package/dist/page/utils/normalizePageApiResponse.d.ts.map +1 -0
- package/dist/renderer/host/bootstrapRendererHost.d.ts +12 -0
- package/dist/renderer/host/bootstrapRendererHost.d.ts.map +1 -0
- package/dist/renderer/host/createHostPageNavigateHandler.d.ts +11 -0
- package/dist/renderer/host/createHostPageNavigateHandler.d.ts.map +1 -0
- package/dist/renderer/host/createHostWorkflowHandlers.d.ts +16 -0
- package/dist/renderer/host/createHostWorkflowHandlers.d.ts.map +1 -0
- package/dist/renderer/host/formWorkflowBaseUrl.d.ts +9 -0
- package/dist/renderer/host/formWorkflowBaseUrl.d.ts.map +1 -0
- package/dist/renderer/host/isLcNcEnabled.d.ts +5 -0
- package/dist/renderer/host/isLcNcEnabled.d.ts.map +1 -0
- package/dist/renderer/host/isPageNotFoundError.d.ts +3 -0
- package/dist/renderer/host/isPageNotFoundError.d.ts.map +1 -0
- package/dist/renderer/index.d.ts +11 -1
- package/dist/renderer/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
(function(ue,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("react"),require("react/jsx-runtime"),require("react-router-dom"),require("react-dom"),require("sonner"),require("@tanstack/react-query")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime","react-router-dom","react-dom","sonner","@tanstack/react-query"],w):(ue=typeof globalThis<"u"?globalThis:ue||self,w(ue.FormBuilderRenderer={},ue.React,ue.jsxRuntime,ue.ReactRouterDOM,ue.ReactDOM,ue.Sonner,ue.ReactQuery))})(this,(function(ue,w,d,ja,Id,at,kn){"use strict";function Md(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const b=Md(w),Wi=Md(Id),za="iq-fbr",Hn="95px";function Ri(e){return!e||typeof e.columns!="number"?null:{rows:e.rows??8,columns:e.columns,verticalSpacing:e.verticalSpacing||e.spacing||"16px",horizontalSpacing:e.horizontalSpacing||e.spacing||"16px",rowHeight:Hn}}function Ki(e,t){if(t!=null&&t!==void 0)return t;const r=e.config;if(r?.grid&&typeof r.grid.rows=="number"&&typeof r.grid.columns=="number")return{rows:r.grid.rows,columns:r.grid.columns,verticalSpacing:r.grid.verticalSpacing??r.grid.spacing,horizontalSpacing:r.grid.horizontalSpacing??r.grid.spacing,rowHeight:r.grid.rowHeight,spacing:r.grid.spacing};const n=r?.layout!=null&&typeof r.layout=="object"?r.layout:null;if(n&&typeof n.rows=="number"&&typeof n.columns=="number")return{rows:n.rows,columns:n.columns,verticalSpacing:n.verticalSpacing??n.spacing,horizontalSpacing:n.horizontalSpacing??n.spacing,rowHeight:n.rowHeight,spacing:n.spacing};const o=e.layout;if(o!=null&&typeof o=="object"&&typeof o.rows=="number"&&typeof o.columns=="number"){const i=o;return{rows:i.rows,columns:i.columns,verticalSpacing:i.verticalSpacing??i.spacing,horizontalSpacing:i.horizontalSpacing??i.spacing,rowHeight:i.rowHeight,spacing:i.spacing}}return null}function Ld(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(r=Ld(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function Dd(){for(var e,t,r=0,n="",o=arguments.length;r<o;r++)(e=arguments[r])&&(t=Ld(e))&&(n&&(n+=" "),n+=t);return n}const nv=(e,t)=>{const r=new Array(e.length+t.length);for(let n=0;n<e.length;n++)r[n]=e[n];for(let n=0;n<t.length;n++)r[e.length+n]=t[n];return r},ov=(e,t)=>({classGroupId:e,validator:t}),Bd=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),Gi="-",$d=[],iv="arbitrary..",sv=e=>{const t=lv(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:s=>{if(s.startsWith("[")&&s.endsWith("]"))return av(s);const a=s.split(Gi),c=a[0]===""&&a.length>1?1:0;return jd(a,c,t)},getConflictingClassGroupIds:(s,a)=>{if(a){const c=n[s],u=r[s];return c?u?nv(u,c):c:u||$d}return r[s]||$d}}},jd=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const o=e[t],i=r.nextPart.get(o);if(i){const u=jd(e,t+1,i);if(u)return u}const s=r.validators;if(s===null)return;const a=t===0?e.join(Gi):e.slice(t).join(Gi),c=s.length;for(let u=0;u<c;u++){const f=s[u];if(f.validator(a))return f.classGroupId}},av=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),r=t.indexOf(":"),n=t.slice(0,r);return n?iv+n:void 0})(),lv=e=>{const{theme:t,classGroups:r}=e;return cv(r,t)},cv=(e,t)=>{const r=Bd();for(const n in e){const o=e[n];Ua(o,r,n,t)}return r},Ua=(e,t,r,n)=>{const o=e.length;for(let i=0;i<o;i++){const s=e[i];dv(s,t,r,n)}},dv=(e,t,r,n)=>{if(typeof e=="string"){uv(e,t,r);return}if(typeof e=="function"){fv(e,t,r,n);return}pv(e,t,r,n)},uv=(e,t,r)=>{const n=e===""?t:zd(t,e);n.classGroupId=r},fv=(e,t,r,n)=>{if(mv(e)){Ua(e(n),t,r,n);return}t.validators===null&&(t.validators=[]),t.validators.push(ov(r,e))},pv=(e,t,r,n)=>{const o=Object.entries(e),i=o.length;for(let s=0;s<i;s++){const[a,c]=o[s];Ua(c,zd(t,a),r,n)}},zd=(e,t)=>{let r=e;const n=t.split(Gi),o=n.length;for(let i=0;i<o;i++){const s=n[i];let a=r.nextPart.get(s);a||(a=Bd(),r.nextPart.set(s,a)),r=a}return r},mv=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,hv=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=Object.create(null),n=Object.create(null);const o=(i,s)=>{r[i]=s,t++,t>e&&(t=0,n=r,r=Object.create(null))};return{get(i){let s=r[i];if(s!==void 0)return s;if((s=n[i])!==void 0)return o(i,s),s},set(i,s){i in r?r[i]=s:o(i,s)}}},Va="!",Ud=":",gv=[],Vd=(e,t,r,n,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:n,isExternal:o}),yv=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=o=>{const i=[];let s=0,a=0,c=0,u;const f=o.length;for(let h=0;h<f;h++){const y=o[h];if(s===0&&a===0){if(y===Ud){i.push(o.slice(c,h)),c=h+1;continue}if(y==="/"){u=h;continue}}y==="["?s++:y==="]"?s--:y==="("?a++:y===")"&&a--}const l=i.length===0?o:o.slice(c);let p=l,g=!1;l.endsWith(Va)?(p=l.slice(0,-1),g=!0):l.startsWith(Va)&&(p=l.slice(1),g=!0);const m=u&&u>c?u-c:void 0;return Vd(i,g,p,m)};if(t){const o=t+Ud,i=n;n=s=>s.startsWith(o)?i(s.slice(o.length)):Vd(gv,!1,s,void 0,!0)}if(r){const o=n;n=i=>r({className:i,parseClassName:o})}return n},bv=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((r,n)=>{t.set(r,1e6+n)}),r=>{const n=[];let o=[];for(let i=0;i<r.length;i++){const s=r[i],a=s[0]==="[",c=t.has(s);a||c?(o.length>0&&(o.sort(),n.push(...o),o=[]),n.push(s)):o.push(s)}return o.length>0&&(o.sort(),n.push(...o)),n}},vv=e=>({cache:hv(e.cacheSize),parseClassName:yv(e),sortModifiers:bv(e),...sv(e)}),wv=/\s+/,Sv=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:o,sortModifiers:i}=t,s=[],a=e.trim().split(wv);let c="";for(let u=a.length-1;u>=0;u-=1){const f=a[u],{isExternal:l,modifiers:p,hasImportantModifier:g,baseClassName:m,maybePostfixModifierPosition:h}=r(f);if(l){c=f+(c.length>0?" "+c:c);continue}let y=!!h,S=n(y?m.substring(0,h):m);if(!S){if(!y){c=f+(c.length>0?" "+c:c);continue}if(S=n(m),!S){c=f+(c.length>0?" "+c:c);continue}y=!1}const v=p.length===0?"":p.length===1?p[0]:i(p).join(":"),A=g?v+Va:v,x=A+S;if(s.indexOf(x)>-1)continue;s.push(x);const F=o(S,y);for(let N=0;N<F.length;++N){const k=F[N];s.push(A+k)}c=f+(c.length>0?" "+c:c)}return c},xv=(...e)=>{let t=0,r,n,o="";for(;t<e.length;)(r=e[t++])&&(n=Hd(r))&&(o&&(o+=" "),o+=n);return o},Hd=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=Hd(e[n]))&&(r&&(r+=" "),r+=t);return r},Av=(e,...t)=>{let r,n,o,i;const s=c=>{const u=t.reduce((f,l)=>l(f),e());return r=vv(u),n=r.cache.get,o=r.cache.set,i=a,a(c)},a=c=>{const u=n(c);if(u)return u;const f=Sv(c,r);return o(c,f),f};return i=s,(...c)=>i(xv(...c))},Cv=[],Kt=e=>{const t=r=>r[e]||Cv;return t.isThemeGetter=!0,t},Wd=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Rd=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Ev=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Nv=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,kv=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,_v=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Tv=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Fv=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,_n=e=>Ev.test(e),tt=e=>!!e&&!Number.isNaN(Number(e)),Tn=e=>!!e&&Number.isInteger(Number(e)),Ha=e=>e.endsWith("%")&&tt(e.slice(0,-1)),pn=e=>Nv.test(e),Kd=()=>!0,Pv=e=>kv.test(e)&&!_v.test(e),Wa=()=>!1,Ov=e=>Tv.test(e),Iv=e=>Fv.test(e),Mv=e=>!Te(e)&&!Pe(e),Lv=e=>Fn(e,Qd,Wa),Te=e=>Wd.test(e),Wn=e=>Fn(e,Zd,Pv),Gd=e=>Fn(e,Hv,tt),Dv=e=>Fn(e,tu,Kd),Bv=e=>Fn(e,eu,Wa),qd=e=>Fn(e,Xd,Wa),$v=e=>Fn(e,Jd,Iv),qi=e=>Fn(e,ru,Ov),Pe=e=>Rd.test(e),Yo=e=>Rn(e,Zd),jv=e=>Rn(e,eu),Yd=e=>Rn(e,Xd),zv=e=>Rn(e,Qd),Uv=e=>Rn(e,Jd),Yi=e=>Rn(e,ru,!0),Vv=e=>Rn(e,tu,!0),Fn=(e,t,r)=>{const n=Wd.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},Rn=(e,t,r=!1)=>{const n=Rd.exec(e);return n?n[1]?t(n[1]):r:!1},Xd=e=>e==="position"||e==="percentage",Jd=e=>e==="image"||e==="url",Qd=e=>e==="length"||e==="size"||e==="bg-size",Zd=e=>e==="length",Hv=e=>e==="number",eu=e=>e==="family-name",tu=e=>e==="number"||e==="weight",ru=e=>e==="shadow",Wv=Av(()=>{const e=Kt("color"),t=Kt("font"),r=Kt("text"),n=Kt("font-weight"),o=Kt("tracking"),i=Kt("leading"),s=Kt("breakpoint"),a=Kt("container"),c=Kt("spacing"),u=Kt("radius"),f=Kt("shadow"),l=Kt("inset-shadow"),p=Kt("text-shadow"),g=Kt("drop-shadow"),m=Kt("blur"),h=Kt("perspective"),y=Kt("aspect"),S=Kt("ease"),v=Kt("animate"),A=()=>["auto","avoid","all","avoid-page","page","left","right","column"],x=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],F=()=>[...x(),Pe,Te],N=()=>["auto","hidden","clip","visible","scroll"],k=()=>["auto","contain","none"],T=()=>[Pe,Te,c],P=()=>[_n,"full","auto",...T()],E=()=>[Tn,"none","subgrid",Pe,Te],C=()=>["auto",{span:["full",Tn,Pe,Te]},Tn,Pe,Te],I=()=>[Tn,"auto",Pe,Te],W=()=>["auto","min","max","fr",Pe,Te],M=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],U=()=>["start","end","center","stretch","center-safe","end-safe"],V=()=>["auto",...T()],X=()=>[_n,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...T()],B=()=>[_n,"screen","full","dvw","lvw","svw","min","max","fit",...T()],L=()=>[_n,"screen","full","lh","dvh","lvh","svh","min","max","fit",...T()],D=()=>[e,Pe,Te],K=()=>[...x(),Yd,qd,{position:[Pe,Te]}],ae=()=>["no-repeat",{repeat:["","x","y","space","round"]}],j=()=>["auto","cover","contain",zv,Lv,{size:[Pe,Te]}],z=()=>[Ha,Yo,Wn],le=()=>["","none","full",u,Pe,Te],ie=()=>["",tt,Yo,Wn],G=()=>["solid","dashed","dotted","double"],ee=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Ae=()=>[tt,Ha,Yd,qd],te=()=>["","none",m,Pe,Te],oe=()=>["none",tt,Pe,Te],me=()=>["none",tt,Pe,Te],Me=()=>[tt,Pe,Te],De=()=>[_n,"full",...T()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[pn],breakpoint:[pn],color:[Kd],container:[pn],"drop-shadow":[pn],ease:["in","out","in-out"],font:[Mv],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[pn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[pn],shadow:[pn],spacing:["px",tt],text:[pn],"text-shadow":[pn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",_n,Te,Pe,y]}],container:["container"],columns:[{columns:[tt,Te,Pe,a]}],"break-after":[{"break-after":A()}],"break-before":[{"break-before":A()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:F()}],overflow:[{overflow:N()}],"overflow-x":[{"overflow-x":N()}],"overflow-y":[{"overflow-y":N()}],overscroll:[{overscroll:k()}],"overscroll-x":[{"overscroll-x":k()}],"overscroll-y":[{"overscroll-y":k()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:P()}],"inset-x":[{"inset-x":P()}],"inset-y":[{"inset-y":P()}],start:[{"inset-s":P(),start:P()}],end:[{"inset-e":P(),end:P()}],"inset-bs":[{"inset-bs":P()}],"inset-be":[{"inset-be":P()}],top:[{top:P()}],right:[{right:P()}],bottom:[{bottom:P()}],left:[{left:P()}],visibility:["visible","invisible","collapse"],z:[{z:[Tn,"auto",Pe,Te]}],basis:[{basis:[_n,"full","auto",a,...T()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[tt,_n,"auto","initial","none",Te]}],grow:[{grow:["",tt,Pe,Te]}],shrink:[{shrink:["",tt,Pe,Te]}],order:[{order:[Tn,"first","last","none",Pe,Te]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:C()}],"col-start":[{"col-start":I()}],"col-end":[{"col-end":I()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:C()}],"row-start":[{"row-start":I()}],"row-end":[{"row-end":I()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":W()}],"auto-rows":[{"auto-rows":W()}],gap:[{gap:T()}],"gap-x":[{"gap-x":T()}],"gap-y":[{"gap-y":T()}],"justify-content":[{justify:[...M(),"normal"]}],"justify-items":[{"justify-items":[...U(),"normal"]}],"justify-self":[{"justify-self":["auto",...U()]}],"align-content":[{content:["normal",...M()]}],"align-items":[{items:[...U(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...U(),{baseline:["","last"]}]}],"place-content":[{"place-content":M()}],"place-items":[{"place-items":[...U(),"baseline"]}],"place-self":[{"place-self":["auto",...U()]}],p:[{p:T()}],px:[{px:T()}],py:[{py:T()}],ps:[{ps:T()}],pe:[{pe:T()}],pbs:[{pbs:T()}],pbe:[{pbe:T()}],pt:[{pt:T()}],pr:[{pr:T()}],pb:[{pb:T()}],pl:[{pl:T()}],m:[{m:V()}],mx:[{mx:V()}],my:[{my:V()}],ms:[{ms:V()}],me:[{me:V()}],mbs:[{mbs:V()}],mbe:[{mbe:V()}],mt:[{mt:V()}],mr:[{mr:V()}],mb:[{mb:V()}],ml:[{ml:V()}],"space-x":[{"space-x":T()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":T()}],"space-y-reverse":["space-y-reverse"],size:[{size:X()}],"inline-size":[{inline:["auto",...B()]}],"min-inline-size":[{"min-inline":["auto",...B()]}],"max-inline-size":[{"max-inline":["none",...B()]}],"block-size":[{block:["auto",...L()]}],"min-block-size":[{"min-block":["auto",...L()]}],"max-block-size":[{"max-block":["none",...L()]}],w:[{w:[a,"screen",...X()]}],"min-w":[{"min-w":[a,"screen","none",...X()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[s]},...X()]}],h:[{h:["screen","lh",...X()]}],"min-h":[{"min-h":["screen","lh","none",...X()]}],"max-h":[{"max-h":["screen","lh",...X()]}],"font-size":[{text:["base",r,Yo,Wn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,Vv,Dv]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ha,Te]}],"font-family":[{font:[jv,Bv,t]}],"font-features":[{"font-features":[Te]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,Pe,Te]}],"line-clamp":[{"line-clamp":[tt,"none",Pe,Gd]}],leading:[{leading:[i,...T()]}],"list-image":[{"list-image":["none",Pe,Te]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Pe,Te]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:D()}],"text-color":[{text:D()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...G(),"wavy"]}],"text-decoration-thickness":[{decoration:[tt,"from-font","auto",Pe,Wn]}],"text-decoration-color":[{decoration:D()}],"underline-offset":[{"underline-offset":[tt,"auto",Pe,Te]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:T()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Pe,Te]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Pe,Te]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:K()}],"bg-repeat":[{bg:ae()}],"bg-size":[{bg:j()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Tn,Pe,Te],radial:["",Pe,Te],conic:[Tn,Pe,Te]},Uv,$v]}],"bg-color":[{bg:D()}],"gradient-from-pos":[{from:z()}],"gradient-via-pos":[{via:z()}],"gradient-to-pos":[{to:z()}],"gradient-from":[{from:D()}],"gradient-via":[{via:D()}],"gradient-to":[{to:D()}],rounded:[{rounded:le()}],"rounded-s":[{"rounded-s":le()}],"rounded-e":[{"rounded-e":le()}],"rounded-t":[{"rounded-t":le()}],"rounded-r":[{"rounded-r":le()}],"rounded-b":[{"rounded-b":le()}],"rounded-l":[{"rounded-l":le()}],"rounded-ss":[{"rounded-ss":le()}],"rounded-se":[{"rounded-se":le()}],"rounded-ee":[{"rounded-ee":le()}],"rounded-es":[{"rounded-es":le()}],"rounded-tl":[{"rounded-tl":le()}],"rounded-tr":[{"rounded-tr":le()}],"rounded-br":[{"rounded-br":le()}],"rounded-bl":[{"rounded-bl":le()}],"border-w":[{border:ie()}],"border-w-x":[{"border-x":ie()}],"border-w-y":[{"border-y":ie()}],"border-w-s":[{"border-s":ie()}],"border-w-e":[{"border-e":ie()}],"border-w-bs":[{"border-bs":ie()}],"border-w-be":[{"border-be":ie()}],"border-w-t":[{"border-t":ie()}],"border-w-r":[{"border-r":ie()}],"border-w-b":[{"border-b":ie()}],"border-w-l":[{"border-l":ie()}],"divide-x":[{"divide-x":ie()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ie()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...G(),"hidden","none"]}],"divide-style":[{divide:[...G(),"hidden","none"]}],"border-color":[{border:D()}],"border-color-x":[{"border-x":D()}],"border-color-y":[{"border-y":D()}],"border-color-s":[{"border-s":D()}],"border-color-e":[{"border-e":D()}],"border-color-bs":[{"border-bs":D()}],"border-color-be":[{"border-be":D()}],"border-color-t":[{"border-t":D()}],"border-color-r":[{"border-r":D()}],"border-color-b":[{"border-b":D()}],"border-color-l":[{"border-l":D()}],"divide-color":[{divide:D()}],"outline-style":[{outline:[...G(),"none","hidden"]}],"outline-offset":[{"outline-offset":[tt,Pe,Te]}],"outline-w":[{outline:["",tt,Yo,Wn]}],"outline-color":[{outline:D()}],shadow:[{shadow:["","none",f,Yi,qi]}],"shadow-color":[{shadow:D()}],"inset-shadow":[{"inset-shadow":["none",l,Yi,qi]}],"inset-shadow-color":[{"inset-shadow":D()}],"ring-w":[{ring:ie()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:D()}],"ring-offset-w":[{"ring-offset":[tt,Wn]}],"ring-offset-color":[{"ring-offset":D()}],"inset-ring-w":[{"inset-ring":ie()}],"inset-ring-color":[{"inset-ring":D()}],"text-shadow":[{"text-shadow":["none",p,Yi,qi]}],"text-shadow-color":[{"text-shadow":D()}],opacity:[{opacity:[tt,Pe,Te]}],"mix-blend":[{"mix-blend":[...ee(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ee()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[tt]}],"mask-image-linear-from-pos":[{"mask-linear-from":Ae()}],"mask-image-linear-to-pos":[{"mask-linear-to":Ae()}],"mask-image-linear-from-color":[{"mask-linear-from":D()}],"mask-image-linear-to-color":[{"mask-linear-to":D()}],"mask-image-t-from-pos":[{"mask-t-from":Ae()}],"mask-image-t-to-pos":[{"mask-t-to":Ae()}],"mask-image-t-from-color":[{"mask-t-from":D()}],"mask-image-t-to-color":[{"mask-t-to":D()}],"mask-image-r-from-pos":[{"mask-r-from":Ae()}],"mask-image-r-to-pos":[{"mask-r-to":Ae()}],"mask-image-r-from-color":[{"mask-r-from":D()}],"mask-image-r-to-color":[{"mask-r-to":D()}],"mask-image-b-from-pos":[{"mask-b-from":Ae()}],"mask-image-b-to-pos":[{"mask-b-to":Ae()}],"mask-image-b-from-color":[{"mask-b-from":D()}],"mask-image-b-to-color":[{"mask-b-to":D()}],"mask-image-l-from-pos":[{"mask-l-from":Ae()}],"mask-image-l-to-pos":[{"mask-l-to":Ae()}],"mask-image-l-from-color":[{"mask-l-from":D()}],"mask-image-l-to-color":[{"mask-l-to":D()}],"mask-image-x-from-pos":[{"mask-x-from":Ae()}],"mask-image-x-to-pos":[{"mask-x-to":Ae()}],"mask-image-x-from-color":[{"mask-x-from":D()}],"mask-image-x-to-color":[{"mask-x-to":D()}],"mask-image-y-from-pos":[{"mask-y-from":Ae()}],"mask-image-y-to-pos":[{"mask-y-to":Ae()}],"mask-image-y-from-color":[{"mask-y-from":D()}],"mask-image-y-to-color":[{"mask-y-to":D()}],"mask-image-radial":[{"mask-radial":[Pe,Te]}],"mask-image-radial-from-pos":[{"mask-radial-from":Ae()}],"mask-image-radial-to-pos":[{"mask-radial-to":Ae()}],"mask-image-radial-from-color":[{"mask-radial-from":D()}],"mask-image-radial-to-color":[{"mask-radial-to":D()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":x()}],"mask-image-conic-pos":[{"mask-conic":[tt]}],"mask-image-conic-from-pos":[{"mask-conic-from":Ae()}],"mask-image-conic-to-pos":[{"mask-conic-to":Ae()}],"mask-image-conic-from-color":[{"mask-conic-from":D()}],"mask-image-conic-to-color":[{"mask-conic-to":D()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:K()}],"mask-repeat":[{mask:ae()}],"mask-size":[{mask:j()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Pe,Te]}],filter:[{filter:["","none",Pe,Te]}],blur:[{blur:te()}],brightness:[{brightness:[tt,Pe,Te]}],contrast:[{contrast:[tt,Pe,Te]}],"drop-shadow":[{"drop-shadow":["","none",g,Yi,qi]}],"drop-shadow-color":[{"drop-shadow":D()}],grayscale:[{grayscale:["",tt,Pe,Te]}],"hue-rotate":[{"hue-rotate":[tt,Pe,Te]}],invert:[{invert:["",tt,Pe,Te]}],saturate:[{saturate:[tt,Pe,Te]}],sepia:[{sepia:["",tt,Pe,Te]}],"backdrop-filter":[{"backdrop-filter":["","none",Pe,Te]}],"backdrop-blur":[{"backdrop-blur":te()}],"backdrop-brightness":[{"backdrop-brightness":[tt,Pe,Te]}],"backdrop-contrast":[{"backdrop-contrast":[tt,Pe,Te]}],"backdrop-grayscale":[{"backdrop-grayscale":["",tt,Pe,Te]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[tt,Pe,Te]}],"backdrop-invert":[{"backdrop-invert":["",tt,Pe,Te]}],"backdrop-opacity":[{"backdrop-opacity":[tt,Pe,Te]}],"backdrop-saturate":[{"backdrop-saturate":[tt,Pe,Te]}],"backdrop-sepia":[{"backdrop-sepia":["",tt,Pe,Te]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":T()}],"border-spacing-x":[{"border-spacing-x":T()}],"border-spacing-y":[{"border-spacing-y":T()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Pe,Te]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[tt,"initial",Pe,Te]}],ease:[{ease:["linear","initial",S,Pe,Te]}],delay:[{delay:[tt,Pe,Te]}],animate:[{animate:["none",v,Pe,Te]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[h,Pe,Te]}],"perspective-origin":[{"perspective-origin":F()}],rotate:[{rotate:oe()}],"rotate-x":[{"rotate-x":oe()}],"rotate-y":[{"rotate-y":oe()}],"rotate-z":[{"rotate-z":oe()}],scale:[{scale:me()}],"scale-x":[{"scale-x":me()}],"scale-y":[{"scale-y":me()}],"scale-z":[{"scale-z":me()}],"scale-3d":["scale-3d"],skew:[{skew:Me()}],"skew-x":[{"skew-x":Me()}],"skew-y":[{"skew-y":Me()}],transform:[{transform:[Pe,Te,"","none","gpu","cpu"]}],"transform-origin":[{origin:F()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:De()}],"translate-x":[{"translate-x":De()}],"translate-y":[{"translate-y":De()}],"translate-z":[{"translate-z":De()}],"translate-none":["translate-none"],accent:[{accent:D()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:D()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Pe,Te]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":T()}],"scroll-mx":[{"scroll-mx":T()}],"scroll-my":[{"scroll-my":T()}],"scroll-ms":[{"scroll-ms":T()}],"scroll-me":[{"scroll-me":T()}],"scroll-mbs":[{"scroll-mbs":T()}],"scroll-mbe":[{"scroll-mbe":T()}],"scroll-mt":[{"scroll-mt":T()}],"scroll-mr":[{"scroll-mr":T()}],"scroll-mb":[{"scroll-mb":T()}],"scroll-ml":[{"scroll-ml":T()}],"scroll-p":[{"scroll-p":T()}],"scroll-px":[{"scroll-px":T()}],"scroll-py":[{"scroll-py":T()}],"scroll-ps":[{"scroll-ps":T()}],"scroll-pe":[{"scroll-pe":T()}],"scroll-pbs":[{"scroll-pbs":T()}],"scroll-pbe":[{"scroll-pbe":T()}],"scroll-pt":[{"scroll-pt":T()}],"scroll-pr":[{"scroll-pr":T()}],"scroll-pb":[{"scroll-pb":T()}],"scroll-pl":[{"scroll-pl":T()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Pe,Te]}],fill:[{fill:["none",...D()]}],"stroke-w":[{stroke:[tt,Yo,Wn,Gd]}],stroke:[{stroke:["none",...D()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}});function H(...e){return Wv(Dd(e))}const Rv=["richtext","multiselect","radio","checkboxgroup","signature"],Kv=3;function Xo(e){const t=e.position.rowSpan??1;if(e.type==="billingGrid"||e.type==="table")return Math.max(1,t);if(e.type==="file"||e.type==="camera"||e.type==="photoChoice"||e.type==="textarea")return Math.max(t,1);if(e.type==="status")return Math.max(t,4);if(e.type==="selectablelist")return Math.max(Kv,t);if(e.type==="radio"||e.type==="checkboxgroup"){const r=e.properties?.options;return(Array.isArray(r)?r.length:0)<=2?1:Math.max(t,2)}return Rv.includes(e.type)?Math.max(t,2):t}function nu(e,t){if(e.type==="table"||e.type==="billingGrid"){const i=e.position.columnSpan??t??1;return t!=null?Math.min(i,t):i}if(e.type!=="radio"&&e.type!=="checkboxgroup"){const i=e.position.columnSpan??1;return t!=null?Math.min(i,t):i}const r=e.properties?.options,n=Array.isArray(r)?r.length:0,o=Math.max(1,Math.ceil(n/2));return t!=null?Math.min(o,t):o}function uo(e){const t=e?.size??"md",r=e?.variant??"default";return H(t==="sm"?"h-8 text-sm":t==="lg"?"min-h-12 text-lg py-2":"h-10 md:text-sm",r==="filled"?"border-transparent bg-muted shadow-none":r==="outlined"?"border-2 bg-transparent":"")}function ou(e){const t=e?.size??"md",r=e?.variant??"default";return H(t==="sm"?"min-h-[48px] text-sm":t==="lg"?"min-h-[72px] text-lg":"min-h-[56px]",r==="filled"?"border-transparent bg-muted shadow-none":r==="outlined"?"border-2 bg-transparent":"")}function Gv(e){switch(e){case"left":return"flex flex-row items-start gap-4";case"right":return"flex flex-row-reverse items-start gap-4";case"center":return"flex flex-col items-center text-center w-full";case"floating":return"relative flex flex-col gap-2 w-full min-w-0";default:return"flex flex-col gap-2 w-full min-w-0"}}function qv(e,t){const r=t?"text-destructive":"";switch(e){case"left":return`shrink-0 w-32 pt-2 text-right text-sm font-medium ${r}`;case"right":return`shrink-0 w-32 pt-2 text-left text-sm font-medium ${r}`;case"center":return`w-full text-center text-sm font-medium ${r}`;case"floating":return`absolute left-3 top-2 z-[1] origin-[0] -translate-y-4 scale-75 bg-background px-1 text-sm ${r}`;default:return`text-sm font-medium ${r}`}}function Yv(e){switch(e){case"left":case"right":return"flex-1 min-w-0 min-h-0 flex flex-col";case"center":return"w-full max-w-full flex flex-col flex-1 min-h-0";case"floating":return"flex flex-col flex-1 min-h-0 w-full pt-4";default:return"flex flex-col flex-1 min-h-0 w-full min-w-0"}}function Xi(e){return!e||e.widthMode==="full"?100:typeof e.widthPercent=="number"&&!Number.isNaN(e.widthPercent)?Math.min(100,Math.max(1,Math.round(e.widthPercent))):(e.widthMode==="percent",100)}function Ra(e){const t=Xi(e);return{width:t>=100?"100%":`${t}%`,maxWidth:"100%"}}function Xv(e){return Ra(e)}function Ka(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t==="start"||t==="center"||t==="end"||t==="stretch"?t:null}function Ga(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t==="start"||t==="center"||t==="end"?t:null}function Fr(e){if(!e)return"start";const t=Ka(e.horizontalAlign);if(t)return t;const r=Ka(e.contentAlign);if(r)return r;const n=Ka(e.cellAlign);return n||"start"}function Jo(e){if(e?.verticalAlign!=null)return e.verticalAlign;const t=e?.cellJustify;return t==="center"?"center":t==="end"?"end":t==="stretch"?"stretch":t==="start"?"start":"stretch"}function Ji(e){switch(e){case"center":return"items-center";case"end":return"items-end";case"stretch":return"items-stretch";default:return"items-start"}}function qa(e){switch(e){case"center":return"justify-center";case"end":return"justify-end";case"stretch":return"justify-stretch";default:return"justify-start"}}function Qo(e){const t=Ga(e.appearance?.contentVerticalAlign);if(t!==null)switch(t){case"center":return"justify-center";case"end":return"justify-end";default:return"justify-start"}return qa(Ya(e))}const Jv=Qo;function Qi(e){if(e.type==="billingGrid"||e.type==="table"||Xo(e)>1)return!0;const t=Ga(e.appearance?.contentVerticalAlign);if(t==="center"||t==="end")return!1;if(t==="start")return!0;const r=Ya(e);return r!=="center"&&r!=="end"}function iu(e){const t=e[0];if(!t)return Xa(void 0);if(e.length===1)return Xa(t);const r=Fr(t.appearance);return H("flex flex-col min-h-0 h-full w-full",Ji(r),"justify-start")}function su(e){const t=Fr(e),r=Jo(e);return H("flex flex-col min-h-0 h-full w-full",Ji(t),qa(r))}function au(e){if(Xi(e)>=100)return"";const r=Fr(e);return r==="center"?"mx-auto":r==="end"?"ml-auto":""}function lu(e){if(Xi(e)>=100)return"w-full";const r=Fr(e);return r==="center"||r==="end"?"min-w-0":r==="stretch"?"min-w-0 self-stretch":"min-w-0 self-start"}function cu(e){return e?e.widthMode==="full"||e.widthMode==="percent"||typeof e.widthPercent=="number"&&!Number.isNaN(e.widthPercent):!1}function fo(e){return(e.type==="button"||e.type==="editButton")&&!cu(e.appearance)}function du(e){return fo(e)?Fr(e.appearance)==="stretch"?{width:"100%",maxWidth:"100%",minWidth:0}:{width:"auto",maxWidth:"100%"}:Ra(e.appearance)}function uu(e){return du(e)}function fu(e){if(fo(e))switch(Fr(e.appearance)){case"center":return"self-center";case"end":return"self-end";case"stretch":return"self-stretch";default:return"self-start"}return lu(e.appearance)}function pu(e){return e?e.verticalAlign!=null||e.cellJustify!=null:!1}function Ya(e){return e.type!=="button"&&e.type!=="editButton"||pu(e.appearance)?Jo(e.appearance):"start"}function Xa(e){if(!e)return su(void 0);const t=Fr(e.appearance);return H("flex flex-col min-h-0 h-full w-full",Ji(t),Qo(e))}function Qv(e,t){const r={};e!==void 0&&(r.cellAlign=e),t!==void 0&&(r.cellJustify=t);const o=e===void 0&&t===void 0?void 0:r;return H(Ji(Fr(o)),qa(Jo(o)))}const Ja=w.createContext({gridStretch:!1});function Zo(){return w.useContext(Ja)}const mu=e=>{let t;const r=new Set,n=(u,f)=>{const l=typeof u=="function"?u(t):u;if(!Object.is(l,t)){const p=t;t=f??(typeof l!="object"||l===null)?l:Object.assign({},t,l),r.forEach(g=>g(t,p))}},o=()=>t,a={setState:n,getState:o,getInitialState:()=>c,subscribe:u=>(r.add(u),()=>r.delete(u))},c=t=e(n,o,a);return a},Zv=(e=>e?mu(e):mu),ew=e=>e;function Qa(e,t=ew){const r=w.useSyncExternalStore(e.subscribe,w.useCallback(()=>t(e.getState()),[e,t]),w.useCallback(()=>t(e.getInitialState()),[e,t]));return w.useDebugValue(r),r}const hu=e=>{const t=Zv(e),r=n=>Qa(t,n);return Object.assign(r,t),r},gu=(e=>e?hu(e):hu),tw=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,rw=/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/,nw=/^\+?[\d\s-()]{10,}$/,ow={required:e=>e==null?!1:typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.length>0:typeof e=="boolean"?e===!0:!0,minLength:(e,t)=>{if(typeof e!="string")return!0;const r=t.value;return e.length>=r},maxLength:(e,t)=>{if(typeof e!="string")return!0;const r=t.value;return e.length<=r},min:(e,t)=>{if(typeof e!="number")return!0;const r=t.value;return e>=r},max:(e,t)=>{if(typeof e!="number")return!0;const r=t.value;return e<=r},pattern:(e,t)=>{if(typeof e!="string")return!0;const r=t.value,n=t.params?.flags||"";return new RegExp(r,n).test(e)},email:e=>typeof e!="string"||!e?!0:tw.test(e),url:e=>typeof e!="string"||!e?!0:rw.test(e),phone:e=>typeof e!="string"||!e?!0:nw.test(e),date:e=>{if(!e)return!0;const t=new Date(e);return!isNaN(t.getTime())},dateRange:(e,t)=>{if(!e)return!0;const r=new Date(e);if(isNaN(r.getTime()))return!1;const n=t.value,o=new Date;if(o.setHours(0,0,0,0),n.min){const i=n.min==="today"?o:new Date(n.min);if(r<i)return!1}if(n.max){const i=n.max==="today"?o:new Date(n.max);if(r>i)return!1}return!0},fileSize:(e,t)=>{if(!e)return!0;const r=t.value;return e instanceof File?e.size<=r:Array.isArray(e)?e.every(n=>n.size<=r):!0},fileType:(e,t)=>{if(!e)return!0;const r=t.value,n={"text/csv":[".csv"],"application/vnd.ms-excel":[".xls"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":[".xlsx"],"application/pdf":[".pdf"],"image/png":[".png"],"image/jpeg":[".jpg",".jpeg"],"image/gif":[".gif"],"image/webp":[".webp"]},o=i=>r.some(s=>{if(s.endsWith("/*")){const u=s.replace("/*","");if(i.type.startsWith(u))return!0}else if(i.type===s)return!0;const a=i.name.toLowerCase(),c=n[s];return c?c.some(u=>a.endsWith(u)):s.startsWith(".")?a.endsWith(s.toLowerCase()):!1});return e instanceof File?o(e):Array.isArray(e)?e.every(i=>o(i)):!0},allowLetters:(e,t)=>typeof e!="string"||!e||t.value?!0:!/[a-zA-Z]/.test(e),allowNumbers:(e,t)=>typeof e!="string"||!e||t.value?!0:!/[0-9]/.test(e),allowSpecialChars:(e,t)=>typeof e!="string"||!e||t.value?!0:!/[^a-zA-Z0-9\s]/.test(e),minLetters:(e,t)=>{if(typeof e!="string"||!e)return!0;const r=t.value;return(e.match(/[a-zA-Z]/g)||[]).length>=r},maxLetters:(e,t)=>{if(typeof e!="string"||!e)return!0;const r=t.value;return(e.match(/[a-zA-Z]/g)||[]).length<=r},minNumbers:(e,t)=>{if(typeof e!="string"||!e)return!0;const r=t.value;return(e.match(/[0-9]/g)||[]).length>=r},maxNumbers:(e,t)=>{if(typeof e!="string"||!e)return!0;const r=t.value;return(e.match(/[0-9]/g)||[]).length<=r},minSpecialChars:(e,t)=>{if(typeof e!="string"||!e)return!0;const r=t.value;return(e.match(/[^a-zA-Z0-9\s]/g)||[]).length>=r},maxSpecialChars:(e,t)=>{if(typeof e!="string"||!e)return!0;const r=t.value;return(e.match(/[^a-zA-Z0-9\s]/g)||[]).length<=r},custom:(e,t,r)=>!0,async:()=>!0};function rn(e,t,r={}){const n=ow[t.type];if(!n)return!0;const o=n(e,t,r);return o===!1?t.message||iw(t):typeof o=="string"?o:!0}function iw(e){return{required:"This field is required",minLength:`Must be at least ${e.value} characters`,maxLength:`Must be at most ${e.value} characters`,min:`Must be at least ${e.value}`,max:`Must be at most ${e.value}`,pattern:"Invalid format",email:"Please enter a valid email address",url:"Please enter a valid URL",phone:"Please enter a valid phone number",date:"Please enter a valid date",dateRange:"Date is out of allowed range",fileSize:`File size must be less than ${sw(e.value)}`,fileType:"File type is not allowed",allowLetters:"Letters are not allowed in this field",allowNumbers:"Numbers are not allowed in this field",allowSpecialChars:"Special characters are not allowed in this field",minLetters:`Must contain at least ${e.value} letters`,maxLetters:`Must contain at most ${e.value} letters`,minNumbers:`Must contain at least ${e.value} numbers`,maxNumbers:`Must contain at most ${e.value} numbers`,minSpecialChars:`Must contain at least ${e.value} special characters`,maxSpecialChars:`Must contain at most ${e.value} special characters`,custom:"Validation failed",async:"Validation failed"}[e.type]||"Invalid value"}function sw(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}const aw=10;function Zi(e){const t=e.properties;return t?.maxFiles!=null&&t.maxFiles>0?Math.floor(t.maxFiles):t?.multiple===!0?aw:1}function yu(e){return typeof e=="object"&&e!==null&&"url"in e&&typeof e.url=="string"&&e.url.length>0}function bu(e){try{return e.split("?")[0].split("/").filter(Boolean).pop()||e}catch{return e}}function es(e){if(e==null)return[];if(typeof e=="string")return e.startsWith("http")?[{url:e,name:bu(e)}]:[];if(e instanceof File)return[e];if(Array.isArray(e)){const t=[];for(const r of e)r instanceof File?t.push(r):typeof r=="string"&&r.startsWith("http")?t.push({url:r,name:bu(r)}):yu(r)&&t.push(r);return t}return yu(e)?[e]:[]}function lw(e,t){return e.slice(0,t)}function Za(e,t){const r=lw(e,t);return r.length===0?null:t===1?r[0]??null:r}function cw(e){return es(e).length}function dw(e){return e==="file"||e==="camera"||e==="photoChoice"}function el(e,t){if(!dw(e.type))return;const r=Zi(e);if(cw(t)>r)return`Maximum ${r} file(s) allowed`}const uw=4,fw=2,pw=10;function vu(e){const t=e.properties?.otpLength??e.metadata?.otpLength,r=typeof t=="number"?t:Number(t);return Number.isFinite(r)?Math.min(pw,Math.max(fw,Math.round(r))):uw}function mw(e,t){const r=String(e??"").replace(/\s/g,"").slice(0,t).split("");for(;r.length<t;)r.push("");return r}function hw(e){return e.join("").replace(/\s/g,"")}function tl(e,t){if(e.type!=="otp")return;const r=String(t??"").trim();if(!r)return;const n=vu(e);if(r.length!==n)return`Please enter a ${n}-digit OTP`}class ts{static functions={SUM:(...t)=>t.flat().filter(n=>typeof n=="number").reduce((n,o)=>n+o,0),AVG:(...t)=>{const r=t.flat().filter(n=>typeof n=="number");return r.length===0?0:r.reduce((n,o)=>n+o,0)/r.length},MIN:(...t)=>{const r=t.flat().filter(n=>typeof n=="number");return r.length>0?Math.min(...r):0},MAX:(...t)=>{const r=t.flat().filter(n=>typeof n=="number");return r.length>0?Math.max(...r):0},ROUND:(t,r=0)=>{const n=Number(t);if(isNaN(n))return 0;const o=Math.pow(10,Number(r));return Math.round(n*o)/o},FLOOR:t=>Math.floor(Number(t)||0),CEIL:t=>Math.ceil(Number(t)||0),ABS:t=>Math.abs(Number(t)||0),CONCAT:(...t)=>t.map(String).join(""),UPPER:t=>String(t).toUpperCase(),LOWER:t=>String(t).toLowerCase(),TRIM:t=>String(t).trim(),LEN:t=>String(t).length,SUBSTR:(t,r,n)=>{const o=String(t),i=Number(r),s=n!==void 0?Number(n):void 0;return o.substring(i,s!==void 0?i+s:void 0)},IF:(t,r,n)=>t?r:n,IFEMPTY:(t,r)=>t==null||t===""?r:t,ISNUMBER:t=>typeof t=="number"&&!isNaN(t),ISEMPTY:t=>t==null?!0:typeof t=="string"?t.trim()==="":Array.isArray(t)?t.length===0:!1,TODAY:()=>new Date().toISOString().split("T")[0],NOW:()=>new Date().toISOString(),YEAR:t=>{const r=new Date(t);return isNaN(r.getTime())?null:r.getFullYear()},MONTH:t=>{const r=new Date(t);return isNaN(r.getTime())?null:r.getMonth()+1},DAY:t=>{const r=new Date(t);return isNaN(r.getTime())?null:r.getDate()},DATEDIFF:(t,r,n="days")=>{const o=new Date(t),i=new Date(r);if(isNaN(o.getTime())||isNaN(i.getTime()))return null;const a=(i.getTime()-o.getTime())/(1e3*60*60*24);switch(n){case"years":return a/365;case"months":return a/30;case"weeks":return a/7;case"hours":return a*24;case"minutes":return a*24*60;default:return a}},COUNT:t=>Array.isArray(t)?t.length:t?1:0,FIRST:t=>Array.isArray(t)?t[0]:t,LAST:t=>Array.isArray(t)?t[t.length-1]:t,SUMFIELD:(...t)=>{const r=t[0],n=t[1];return!Array.isArray(r)||typeof n!="string"?0:r.reduce((o,i)=>{if(typeof i=="object"&&i!==null){const s=i[n];return o+(Number(s)||0)}return o},0)}};calculate(t,r){try{const{fields:n,currentValue:o,previousValue:i}=r,s={...n};for(const l in s){const p=s[l];(p==null||p==="")&&(s[l]="")}const a={fields:s,currentValue:o,previousValue:i,...ts.functions},c=Object.keys(a),u=Object.values(a),f=new Function(...c,`return ${t}`)(...u);if(f==null)return"";if(typeof f=="string"){if(f.includes("undefined"))return"";const l=f.trim();return l===""||/^\s+$/.test(f)?"":l}return f}catch{return""}}calculateAll(t,r){const n={...r};for(const o of t){const i={fields:n,currentValue:n[o.field],previousValue:r[o.field]},s=this.calculate(o.formula,i);n[o.field]=s===null?"":s}return n}validateFormula(t){try{return new Function("fields",`return ${t}`),{valid:!0}}catch(r){return{valid:!1,error:r instanceof Error?r.message:"Invalid formula"}}}getAvailableFunctions(){return[{name:"SUM",description:"Sum of values"},{name:"AVG",description:"Average of values"},{name:"MIN",description:"Minimum value"},{name:"MAX",description:"Maximum value"},{name:"ROUND",description:"Round to decimal places"},{name:"IF",description:"Conditional value"},{name:"CONCAT",description:"Concatenate strings"},{name:"TODAY",description:"Current date"},{name:"DATEDIFF",description:"Difference between dates"},{name:"COUNT",description:"Count of items"},{name:"SUMFIELD",description:"Sum field in array"}]}}const wu=new ts;function Su(e){if(e==null||e==="")return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:rs(e);if(typeof e=="string"){const t=e.trim();if(!t)return null;const r=t.match(/^(\d{4})-(\d{2})-(\d{2})/);if(r){const o=new Date(Number(r[1]),Number(r[2])-1,Number(r[3]));return Number.isNaN(o.getTime())?null:o}const n=new Date(t);return Number.isNaN(n.getTime())?null:rs(n)}return null}function rs(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function gw(e,t=new Date){const r=rs(e),n=rs(t);if(n<r)return{years:0,months:0,days:0};let o=n.getFullYear()-r.getFullYear(),i=n.getMonth()-r.getMonth(),s=n.getDate()-r.getDate();if(s<0){i-=1;const a=new Date(n.getFullYear(),n.getMonth(),0).getDate();s+=a}return i<0&&(o-=1,i+=12),{years:Math.max(0,o),months:Math.max(0,i),days:Math.max(0,s)}}function rl(e){if(e.type!=="number")return;const t=e.properties?.deriveFromDate;if(!(!t?.sourceFieldName||!t.part))return t}function Pr(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(0,t):e}function nl(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(t):null}function yw(e,t){const r=nl(e);return r?`${t.sourceFieldName}${r}`:t.sourceFieldName}function xu(e,t,r){const n=nl(t);if(n)return[`${e}${n}`];const o=new Set([e]),i=`${e}__addmore__`;for(const s of Object.keys(r))(s===e||s.startsWith(i))&&o.add(s);return[...o]}function bw(e,t,r){const n=r?yw(r,e):e.sourceFieldName,o=Su(t[n]);if(!o)return null;const i=e.referenceDate==="today"||e.referenceDate==null?new Date:Su(t[e.referenceDate])??new Date;return gw(o,i)[e.part]}function Au(e,t){const r=rl(e);return r?Pr(r.sourceFieldName)===Pr(t):!1}function ol(e,t,r,n){const o={...t},i=n?Pr(n):void 0;for(const s of e){if(s.type!=="number")continue;const a=rl(s);if(!a||!s.name||i&&Pr(a.sourceFieldName)!==i)continue;const c=n??a.sourceFieldName,u=xu(s.name,c,o);for(const f of u){if(r.has(f))continue;const l=bw(a,o,f);o[f]=l}}return o}function vw(e,t,r,n){const o={...t},i=Pr(n);for(const s of e){if(!Au(s,i)||!s.name)continue;const a=xu(s.name,n,o);for(const c of a)r.delete(c),o[c]=null}return o}function Cu(e,t){const r=Pr(t);return e.some(n=>Au(n,r))}function Eu(e){if(e.apidata&&typeof e.apidata=="object")return e.apidata;if(e.metadata)try{const t=typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata;if(t.apiEndpoint||t.apiKey||t.valueSource==="api")return{apiKey:t.apiKey,valueSource:t.valueSource,apiEndpoint:t.apiEndpoint,apiAutoDetect:t.apiAutoDetect,apiLabelField:t.apiLabelField,apiValueField:t.apiValueField,apiMethod:t.apiMethod,apiRealtime:t.apiRealtime,apiQueryParams:t.apiQueryParams,apiClientFilter:t.apiClientFilter}}catch{}return null}function il(e,t,r,n){let o=sl(e,r);return n&&(o=Kn(o,t,r)),o}function sl(e,t){return e.replace(/\{(?:ctx:|\@)(\w+)\}/g,(r,n)=>t?.[n]!==void 0&&t[n]!==null?String(t[n]):r)}function Kn(e,t,r){let n=e.replace(/\{(?:ctx:|\@)(\w+)\}/g,(o,i)=>r?.[i]!==void 0&&r[i]!==null?String(r[i]):o);return n=n.replace(/\{(\w+)\}/g,(o,i)=>{if(o.includes("ctx:")||o.includes("@"))return o;let s=t[i];if(s==null||s===""){const a=Object.keys(t).find(c=>c.toLowerCase()===i.toLowerCase());a&&(s=t[a])}return s!=null&&s!==""?String(s):o}),n}function po(e,t){const r=e.match(/\{(\w+)\}/g)||[],n=[];t?.custom&&t.custom.forEach(({value:i})=>{if(i){const s=i.match(/\{(\w+)\}/g)||[];n.push(...s.filter(a=>!a.includes("ctx:")&&!a.includes("@")))}});const o=r.filter(i=>!i.includes("ctx:")&&!i.includes("@"));return new Set([...o.map(i=>i.replace(/[{}]/g,"")),...n.map(i=>i.replace(/[{}]/g,""))])}function ww(e,t){const r=e[t];return r==null||r===""}function ns(e){const{apiEndpoint:t,apiMethod:r="GET",apiQueryParams:n={},formValues:o,submissionContext:i,apiRealtime:s,additionalRequiredFieldNames:a=[],excludeFormFieldNames:c=[]}=e,u=(r||"GET").toLowerCase(),f=po(t,n),l=new Set((c||[]).filter(v=>typeof v=="string"&&v.length>0)),p=new Set((a||[]).filter(v=>typeof v=="string"&&v.length>0)),g=new Set([...f,...p]);let m=!1;for(const v of g){const A=!!(s&&f.has(v)),x=p.has(v);if((A||x)&&ww(o,v)){m=!0;break}}if(m)return{blocked:!0,url:t,postBodyBase:null};let h=t;const y=t.match(/\{(\w+)\}/g)||[];if(h=sl(h,i),s&&(h=Kn(h,o,i)),n&&Object.keys(n).length>0){const v=n,A=[];if(v.limit){let x=v.limit;s&&(x=Kn(x,o,i)),A.push(`_limit=${encodeURIComponent(x)}`)}if(v.page){let x=v.page;s&&(x=Kn(x,o,i)),A.push(`page=${encodeURIComponent(x)}`)}if(v.sort){let x=v.sort;s&&(x=Kn(x,o,i)),A.push(`sort=${encodeURIComponent(x)}`)}if(v.orderBy){let x=v.orderBy;s&&(x=Kn(x,o,i)),A.push(`orderBy=${encodeURIComponent(x)}`)}if(v.custom?.length&&v.custom.forEach(({key:x,value:F})=>{if(!x||!F)return;let N=sl(F,i);s&&(N=Kn(N,o,i)),N.match(/\{[^}]+\}/)?N.match(/\{(?!ctx:|\@)(\w+)\}/g)||A.push(`${encodeURIComponent(x)}=`):A.push(`${encodeURIComponent(x)}=${encodeURIComponent(N)}`)}),A.length>0){const x=h.includes("?")?"&":"?";h=`${h}${x}${A.join("&")}`}}if(s&&Object.keys(o).length>0&&u==="get"){const v=N=>N.replace(/\{/g,"").replace(/\}/g,""),A=[];for(const N of n.custom||[])if(N.value){const k=N.value.match(/\{(\w+)\}/g)||[];A.push(...k.map(v))}const x=new Set([...y.map(v),...A]),F={};Object.keys(o).forEach(N=>{!x.has(N)&&!l.has(N)&&(F[N]=o[N])}),Object.keys(F).length>0&&(h=`${h}${h.includes("?")?"&":"?"}${new URLSearchParams(F).toString()}`)}let S=null;if(["post","put","patch"].includes(u))if(s&&Object.keys(o).length>0){S={...o};for(const v of l)delete S[v]}else{S={...o||{}};for(const v of l)delete S[v]}return{blocked:!1,url:h,postBodyBase:S}}const Sw=new Set(["select","multiselect","asyncsearch"]);function xw(e){return e?.type==="multiselect"?[]:""}function Nu(e){if(!Sw.has(e.type))return[];const t=e.properties??{},r=Eu(e),n=new Set,o=r?.apiClientFilter?.matchField?.trim()||t.apiClientFilter?.matchField?.trim();o&&n.add(o);const i=[...Array.isArray(t.dependentFields)?t.dependentFields:[],...Array.isArray(r?.dependentFields)?r.dependentFields:[]];for(const u of i)typeof u=="string"&&u.trim()&&n.add(u.trim());const s=r?.apiEndpoint||t.apiEndpoint,a=r?.apiRealtime??t.apiRealtime,c=r?.apiQueryParams||t.apiQueryParams;if(s&&a)for(const u of po(s,c))n.add(u);return[...n]}function Aw(e,t){const r=Pr(t);return Nu(e).some(n=>Pr(n)===r)}function Cw(e,t){const r=Pr(t);return e.some(n=>Aw(n,r))}function Ew(e){const t=new Map;for(const r of e){const n=r.name;if(n)for(const o of Nu(r)){const i=Pr(o),s=t.get(i)??new Set;s.add(n),t.set(i,s)}}return t}function Nw(e,t,r){const n=nl(t);if(n)return[`${e}${n}`];const o=new Set([e]),i=`${e}__addmore__`;for(const s of Object.keys(r))(s===e||s.startsWith(i))&&o.add(s);return[...o]}function kw(e,t){return e===t?!0:Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((r,n)=>r===t[n]):!1}function _w(e,t,r){const n=Ew(e),o=Pr(r),i=new Set,s=[o];for(;s.length>0;){const u=s.shift(),f=n.get(u);if(f)for(const l of f)i.has(l)||(i.add(l),s.push(l))}const a={...t},c=[];for(const u of i){const f=e.find(p=>p.name===u),l=xw(f);for(const p of Nw(u,r,a))kw(a[p],l)||c.push(p),a[p]=l}return{values:a,clearedKeys:c}}function al(e,t){const r=t instanceof Set?t:new Set(t);if(e.size!==r.size)return!1;for(const n of e)if(!r.has(n))return!1;return!0}function ku(){return gu((e,t)=>({schema:null,values:{},initialValues:{},errors:{},touched:{},isValidating:!1,isSubmitting:!1,submitCount:0,isValid:!0,currentStep:0,totalSteps:1,completedSteps:new Set,visibleFields:new Set,enabledFields:new Set,requiredFields:new Set,readOnlyFields:new Set,editableFields:new Set,formDisabled:!1,derivedFieldDirty:new Set,draftId:null,setSchema:(r,n)=>{const o=t(),i=o.schema!=null&&o.schema.id===r.id,s=n?.forceReset===!0,a={},c=new Set,u=new Set,f=new Set;r.fields.forEach(x=>{const F=x.name||x.key||x.id;F&&(x.defaultValue!==void 0&&(x.type==="multiselect"?a[F]=Array.isArray(x.defaultValue)?x.defaultValue:x.defaultValue!=null&&x.defaultValue!==""?[String(x.defaultValue)]:[]:a[F]=x.defaultValue),x.hidden||c.add(F),x.disabled||u.add(F),x.validation?.some(N=>N.type==="required")&&f.add(F))});const l=r.steps?.length||1,p=typeof n?.initialStepIndex=="number",g=p?Math.max(0,Math.min(n.initialStepIndex,Math.max(0,l-1))):0,m=new Set;for(let x=0;x<g;x++)m.add(x);const h=[];r.fields.forEach(x=>{const F=x.properties;F?.valueSource==="calculated"&&F?.formula&&h.push({field:x.name,formula:F.formula})});const y=h.length>0?wu.calculateAll(h,a):{},S=ol(r.fields,{...a,...y},new Set),A=i&&!(s||p)?{...S,...o.values}:S;e({schema:r,values:A,initialValues:S,errors:{},touched:{},currentStep:g,totalSteps:l,completedSteps:m,visibleFields:c,enabledFields:u,requiredFields:f,readOnlyFields:new Set,editableFields:new Set,formDisabled:!1,derivedFieldDirty:s||!i?new Set:o.derivedFieldDirty,isValid:!0,draftId:null})},setFieldValue:(r,n,o)=>{const i=t(),s=i.schema,a=o?.source??"user";let c=new Set(i.derivedFieldDirty);const u=i.values[r];let f={...i.values,[r]:n},l=[];if(s){const p=Pr(r),g=s.fields.find(S=>S.name===p);a==="user"&&g&&rl(g)&&c.add(r);const m=n==null||n===""||Array.isArray(n)&&n.length===0;if(Cu(s.fields,r)&&m?f=vw(s.fields,f,c,r):Cu(s.fields,r)&&(f=ol(s.fields,f,c,r)),a==="user"&&u!==n&&!(Array.isArray(u)&&Array.isArray(n)&&u.length===n.length&&u.every((S,v)=>S===n[v]))&&Cw(s.fields,r)){const S=_w(s.fields,f,r);f=S.values,l=S.clearedKeys}const y=[];s.fields.forEach(S=>{const v=S.properties;v?.valueSource==="calculated"&&v?.formula&&(v.formulaSteps??[]).some(x=>x.type==="field"&&x.fieldName===r)&&y.push({field:S.name,formula:v.formula})}),y.length>0&&(f={...f,...wu.calculateAll(y,f)})}e({values:f,derivedFieldDirty:c}),l.length>0&&e(p=>{const g={...p.errors};for(const m of l)delete g[m];return Object.keys(g).length===Object.keys(p.errors).length?p:{errors:g}}),s?.config.validateOnChange?t().validateField(r):e(p=>{const g={...p.errors};return delete g[r],{errors:g}})},setFieldTouched:(r,n=!0)=>{e(i=>({touched:{...i.touched,[r]:n}}));const o=t().schema;n&&o?.config.validateOnBlur&&t().validateField(r)},setFieldError:(r,n)=>{e(o=>{const i=!!o.errors[r];if(!n&&!i||n&&o.errors[r]===n)return o;const s={...o.errors};return n?s[r]=n:delete s[r],{errors:s,isValid:Object.keys(s).length===0}})},setValues:r=>{const n=t(),o=n.schema;if(!o){e({values:r});return}const i=ol(o.fields,r,n.derivedFieldDirty);e({values:i})},setErrors:r=>e({errors:r,isValid:Object.keys(r).length===0}),resetForm:()=>{const{initialValues:r}=t();e({values:{...r},errors:{},touched:{},currentStep:0,completedSteps:new Set,derivedFieldDirty:new Set,isValid:!0,submitCount:0})},clearForm:()=>{e({schema:null,values:{},initialValues:{},errors:{},touched:{},currentStep:0,totalSteps:1,completedSteps:new Set,visibleFields:new Set,enabledFields:new Set,requiredFields:new Set,readOnlyFields:new Set,editableFields:new Set,formDisabled:!1,derivedFieldDirty:new Set,isValid:!0,submitCount:0,draftId:null})},validateField:async r=>{const{schema:n,values:o}=t();if(!n)return;const i=n.fields.find(a=>a.name===r);if(!i)return;e({isValidating:!0});let s;if(i.validation)for(const a of i.validation){const c=rn(o[r],a,o);if(typeof c=="string"){s=c;break}}if(!s){const a=el(i,o[r]);a&&(s=a)}return!s&&i.type==="otp"&&(s=tl(i,o[r])),e(a=>{const c={...a.errors};return s?c[r]=s:delete c[r],{errors:c,isValid:Object.keys(c).length===0,isValidating:!1}}),s},validateForm:async()=>{const{schema:r,values:n,visibleFields:o,requiredFields:i}=t();if(!r)return!1;e({isValidating:!0});const s={};for(const a of r.fields)if(o.has(a.name)){if(a.validation)for(const c of a.validation){if(c.type==="required"&&!i.has(a.name))continue;const u=rn(n[a.name],c,n);if(typeof u=="string"){s[a.name]=u;break}}if(!s[a.name]){const c=el(a,n[a.name]);c&&(s[a.name]=c)}if(!s[a.name]){const c=tl(a,n[a.name]);c&&(s[a.name]=c)}}return e({errors:s,isValid:Object.keys(s).length===0,isValidating:!1}),Object.keys(s).length===0},validateStep:async r=>{const{schema:n,values:o,visibleFields:i}=t();if(!n?.steps)return!0;const s=n.steps[r];if(!s)return!0;e({isValidating:!0});const a={};for(const c of s.fields){const u=n.fields.find(f=>f.name===c);if(!(!u||!i.has(u.name))){if(u.validation)for(const f of u.validation){const l=rn(o[u.name],f,o);if(typeof l=="string"){a[u.name]=l;break}}if(!a[u.name]){const f=el(u,o[u.name]);f&&(a[u.name]=f)}if(!a[u.name]){const f=tl(u,o[u.name]);f&&(a[u.name]=f)}}}return e(c=>({errors:{...c.errors,...a},isValid:Object.keys(a).length===0,isValidating:!1})),Object.keys(a).length===0},nextStep:async()=>{const{currentStep:r,totalSteps:n,schema:o}=t();return o?.steps?.[r]?.validation==="onNext"&&!await t().validateStep(r)?!1:r<n-1?(e(s=>({currentStep:r+1,completedSteps:new Set([...s.completedSteps,r])})),!0):!1},prevStep:()=>{const{currentStep:r}=t();r>0&&e({currentStep:r-1})},goToStep:r=>{const{totalSteps:n,completedSteps:o,currentStep:i}=t();r>=0&&r<n&&(r<=i||o.has(r-1))&&e({currentStep:r})},setSubmitting:r=>e({isSubmitting:r}),incrementSubmitCount:()=>e(r=>({submitCount:r.submitCount+1})),updateVisibility:r=>{e(n=>{const o=new Set(r);return al(n.visibleFields,o)?n:{visibleFields:o}})},updateEnabled:r=>{e(n=>{const o=new Set(r);return al(n.enabledFields,o)?n:{enabledFields:o}})},updateRequired:r=>{e(n=>{const o=new Set(r);return al(n.requiredFields,o)?n:{requiredFields:o}})},updateReadOnly:r=>e({readOnlyFields:new Set(r)}),updateEditable:r=>e({editableFields:new Set(r)}),updateFormDisabled:r=>e({formDisabled:r}),saveDraft:()=>{const{schema:r,values:n}=t();if(!r)return;const o=`formsmith_draft_${r.id}`;try{localStorage.setItem(o,JSON.stringify({values:n,savedAt:new Date().toISOString()})),e({draftId:o})}catch{}},loadDraft:()=>{const{schema:r}=t();if(!r)return!1;const n=`formsmith_draft_${r.id}`;try{const o=localStorage.getItem(n);if(o){const{values:i}=JSON.parse(o);return e({values:i,draftId:n}),!0}}catch{}return!1},clearDraft:()=>{const{schema:r,draftId:n}=t();if(!r)return;const o=n||`formsmith_draft_${r.id}`;try{localStorage.removeItem(o),e({draftId:null})}catch{}}}))}const Gn=ku();function Tw(e=Gn){return e.getState()}const _u=w.createContext(null),ll=({children:e})=>{const t=w.useRef(null);return t.current||(t.current=ku()),d.jsx(_u.Provider,{value:t.current,children:e})};function os(){return w.useContext(_u)??Gn}function Or(e){const t=os();return e?Qa(t,e):Qa(t)}function Tu({schema:e,initialValues:t,onSubmit:r,onChange:n,workflowStepId:o,initialStepIndex:i}){const{values:s,errors:a,touched:c,isValidating:u,isSubmitting:f,submitCount:l,isValid:p,currentStep:g,totalSteps:m,completedSteps:h,visibleFields:y,enabledFields:S,requiredFields:v,setSchema:A,setFieldValue:x,setFieldTouched:F,setFieldError:N,setValues:k,resetForm:T,validateField:P,validateForm:E,validateStep:C,nextStep:I,prevStep:W,goToStep:M,setSubmitting:U,incrementSubmitCount:V,saveDraft:X,loadDraft:B,clearDraft:L}=Or(),D=os(),K=w.useRef(null);w.useLayoutEffect(()=>{if(A(e,{forceReset:!!o||typeof i=="number",initialStepIndex:i}),t&&Object.keys(t).length>0){const ne=D.getState().values;k({...ne,...t});try{K.current=JSON.stringify(t)}catch{K.current=null}}else K.current=null},[e.id,o,i]),w.useLayoutEffect(()=>{if(!t||Object.keys(t).length===0)return;let ne;try{ne=JSON.stringify(t)}catch{return}if(ne===K.current)return;const ge=D.getState().values;k({...ge,...t}),K.current=ne},[t,k]);const ae=w.useCallback((ne,ge)=>{const Se={...s,[ne]:ge};x(ne,ge),n?.(Se,ne)},[x,n,s]),j=w.useCallback(async ne=>{if(ne?.preventDefault(),V(),!await E())return{success:!1,errors:Object.entries(a).map(([Se,yt])=>({field:Se,rule:"validation",message:yt}))};if(!r)return{success:!0};U(!0);try{const Se=await r(s);return Se.success&&L(),Se}catch(Se){return{success:!1,message:Se instanceof Error?Se.message:"Submission failed"}}finally{U(!1)}},[E,r,s,a,V,U,L]),z=w.useCallback(ne=>({value:s[ne],error:a[ne],touched:c[ne]||!1,isVisible:y.has(ne),isEnabled:S.has(ne),isRequired:v.has(ne)}),[s,a,c,y,S,v]),le=w.useMemo(()=>{if(!e.steps||e.steps.length===0)return e.fields;const ne=e.steps[g];return ne?e.fields.filter(ge=>ne.fields.includes(ge.name)):[]},[e,g]),ie=g===0,G=g===m-1,ee=w.useCallback(ne=>h.has(ne),[h]),Ae=w.useMemo(()=>m<=1?100:Math.round(h.size/m*100),[h.size,m]),te=w.useCallback(ne=>y.has(ne),[y]),oe=w.useCallback(ne=>S.has(ne),[S]),me=w.useCallback(ne=>v.has(ne),[v]),Me=w.useMemo(()=>Object.entries(a).filter(([ne])=>y.has(ne)),[a,y]),De=Me.length>0;return{values:s,errors:a,touched:c,isValidating:u,isSubmitting:f,submitCount:l,isValid:p,hasErrors:De,visibleErrors:Me,currentStep:g,totalSteps:m,completedSteps:h,currentStepFields:le,isFirstStep:ie,isLastStep:G,isStepCompleted:ee,progress:Ae,setFieldValue:ae,setFieldTouched:F,setFieldError:N,setValues:k,validateField:P,getFieldState:z,shouldShowField:te,isFieldEnabled:oe,isFieldRequired:me,handleSubmit:j,resetForm:T,validateForm:E,validateStep:C,nextStep:I,prevStep:W,goToStep:M,saveDraft:X,loadDraft:B,clearDraft:L}}function Fu(e){return"logic"in e&&"conditions"in e}function ei(e){if(e==null||typeof e!="object")return!1;const t=e;if(t.status==="error")return!1;if(t.status==="success"||t.status==="COMPLETED")return!0;const r=t.code;return typeof r=="number"&&r>=200&&r<300||t.data!=null&&t.status!=="error"}function Pu(e,t){if(e==null||typeof t!="string"||t.trim()==="")return;const r=t.replace(/\[(\d+)\]/g,".$1").split(".").filter(Boolean);let n=e;for(const o of r){if(n==null||typeof n!="object")return;n=n[o]}return n}function We(e,t){if(e==null||typeof t!="string"||t.trim()==="")return;let r=Pu(e,t);if(r===void 0&&t.includes(".")){const n=t.split(".");if(n.length>=2){const o=n[0],i=n.slice(1).join("."),s=Pu(e,o);Array.isArray(s)&&s.length>0&&(r=We(s[0],i))}}return r}const Fw=new Set(["section","group","columns","divider","header","sectionHeading","spacer","textLabel","addmore","customizeSections"]);function Pw(e){return e===!0||e==="true"?!0:e===!1||e==="false"?!1:e}function Ow(e,t){if(e==null||typeof t.path!="string"||!t.path.trim())return!1;const r=We(e,t.path),n=Pw(t.value);switch(t.operator){case"equals":return r===n;case"notEquals":return r!==n;case"contains":return typeof r=="string"?r.includes(String(n)):Array.isArray(r)?r.includes(n):!1;case"notContains":return typeof r=="string"?!r.includes(String(n)):Array.isArray(r)?!r.includes(n):!0;case"startsWith":return typeof r=="string"&&r.startsWith(String(n));case"endsWith":return typeof r=="string"&&r.endsWith(String(n));case"greaterThan":return Number(r)>Number(n);case"lessThan":return Number(r)<Number(n);case"greaterThanOrEqual":return Number(r)>=Number(n);case"lessThanOrEqual":return Number(r)<=Number(n);case"isEmpty":return r==null?!0:typeof r=="string"?r.trim()==="":Array.isArray(r)?r.length===0:typeof r=="object"&&r!==null?Object.keys(r).length===0:!1;case"isNotEmpty":return r==null?!1:typeof r=="string"?r.trim()!=="":Array.isArray(r)?r.length>0:typeof r=="object"&&r!==null?Object.keys(r).length>0:!1;case"isTrue":return r===!0;case"isFalse":return r===!1;case"isNull":return r==null;case"isNotNull":return r!=null;case"in":return Array.isArray(n)?n.includes(r):!1;case"notIn":return Array.isArray(n)?!n.includes(r):!0;case"between":if(Array.isArray(n)&&n.length===2){const o=Number(r);return o>=Number(n[0])&&o<=Number(n[1])}return!1;case"regex":try{return new RegExp(String(n)).test(String(r??""))}catch{return!1}default:return!1}}function Iw(e,t,r){return e?e==="__allFields__"?t.filter(n=>!Fw.has(n.type)).map(n=>r(n)).filter(Boolean):e==="__allButtons__"?t.filter(n=>n.type==="button"||n.type==="editButton").map(n=>r(n)).filter(Boolean):[e]:[]}function Ou(e){return String(e||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"").replace(/_+/g,"_")}function Iu(e,t){const r=Ou(e)||"row",n=Ou(t)||"cell";return`${r}_${n}`}function Mw(e){return e.kind==="static"?e.row.id:e.block.id}function Lw(e,t){let r=e,n=2;for(;t.has(r);)r=`${e}_${n}`,n+=1;return t.add(r),r}function Mu(e,t,r,n){const o=e.cellKey?.trim();if(o)return n.add(o),e;const i=Iu(t,r),s=Lw(i,n);return{...e,cellKey:s}}function Lu(e){const t=new Set,r=(e.rowSlots??[]).map(n=>{if(n.kind==="static"){const s=n.row.id,a={};for(const[c,u]of Object.entries(n.row.cells))a[c]=Mu(u,s,c,t);return{...n,row:{...n.row,cells:a}}}const o=n.block.id,i={};for(const[s,a]of Object.entries(n.block.cells))i[s]=Mu(a,o,s,t);return{...n,block:{...n.block,cells:i}}});return{...e,rowSlots:r}}function Du(e){const t=new Map;for(const r of e.rowSlots??[]){const n=Mw(r),o=r.kind,i=r.kind==="static"?r.row.cells:r.block.cells;for(const[s,a]of Object.entries(i)){const c=a.cellKey?.trim()||Iu(n,s);t.set(c,{slotId:n,rowKind:o,columnKey:s})}}return t}function Dw(e,t,r){return t.rowKind==="static"?e.find(n=>n.slotId===t.slotId&&n.rowKind==="static"):r?.slotId===t.slotId&&r.rowKind==="dynamic"?r:e.find(n=>n.slotId===t.slotId&&n.rowKind==="dynamic")}function Bu(e,t,r,n,o){const i=r?.trim();if(!i)return 0;const a=Du(e).get(i);if(a){if(o?.slotId&&a.slotId!==o.slotId||o?.rowKind&&a.rowKind!==o.rowKind)return 0;const c=Dw(t,a,n);return c?cl(c.values[a.columnKey]):0}if(n&&i in n.values)return cl(n.values[i]);if(o?.slotId){const c=t.find(u=>u.slotId===o.slotId&&(!o.rowKind||u.rowKind===o.rowKind));if(c&&i in c.values)return cl(c.values[i])}return 0}function cl(e){if(typeof e=="number"&&!Number.isNaN(e))return e;const t=Number(e);return Number.isNaN(t)?0:t}const $u="__fieldRef:",ju="__billingCell:";function Bw(e){const t={kind:"static",staticValue:"",fieldName:"",billingFieldName:"",cellKey:""};if(e==null)return t;const r=String(e);if(r.startsWith($u))return{...t,kind:"field",fieldName:r.slice($u.length)};if(r.startsWith(ju)){const n=r.slice(ju.length),o=n.indexOf("|");return o>=0?{...t,kind:"billingCell",billingFieldName:n.slice(0,o),cellKey:n.slice(o+1)}:{...t,kind:"billingCell",cellKey:n}}if(r.startsWith("field:"))return{...t,kind:"field",fieldName:r.slice(6)};if(r.startsWith("billing:")){const n=r.slice(8),o=n.indexOf("|");return o>=0?{...t,kind:"billingCell",billingFieldName:n.slice(0,o),cellKey:n.slice(o+1)}:{...t,kind:"billingCell",cellKey:n}}return{...t,kind:"static",staticValue:r}}function dl(e){return e.name||e.key||e.id}function $w(e,t){const r=t.find(n=>n.id===e||n.name===e||n.key===e);return r?dl(r):e}function jw(e,t,r,n){const o=t.trim();if(!o)return;const i=n.filter(a=>a.type==="billingGrid"),s=e?.trim()?i.filter(a=>dl(a)===e||a.name===e||a.id===e):i;for(const a of s){const c=Lu(a.properties??{}),u=r[dl(a)];if(!u?.rows?.length)continue;const l=Du(c).get(o);if(!l)continue;const p=u.rows.find(g=>l.rowKind==="static"?g.slotId===l.slotId&&g.rowKind==="static":g.slotId===l.slotId&&g.rowKind==="dynamic");if(p)return p.values[l.columnKey]}}function zw(e,t,r){const n=Bw(e);if(n.kind==="field"){const o=$w(n.fieldName,r);return t[o]}return n.kind==="billingCell"?jw(n.billingFieldName,n.cellKey,t,r):n.staticValue}function zu(e,t){if(e===t)return!0;if(e==null||t===void 0||t===null)return!1;const r=Number(e),n=Number(t);return!Number.isNaN(r)&&!Number.isNaN(n)&&String(e).trim()!==""&&String(t).trim()!==""?r===n:String(e).trim()===String(t).trim()}const Uu="__buttonResponse:";function Uw({fields:e,values:t,buttonResponses:r,prepopulateResponse:n=null,prepopulateResponseRules:o}){const{updateVisibility:i,updateEnabled:s,updateRequired:a,updateReadOnly:c,updateEditable:u,updateFormDisabled:f}=Or(),l=w.useCallback(N=>N.name||N.key||N.id,[]),p=w.useCallback((N,k)=>{if(!N)return l(k);const T=e.find(P=>P.id===N||P.name===N||P.key===N);return T?l(T):N},[e,l]),g=w.useCallback(N=>{const k=e.find(T=>T.id===N||T.name===N||T.key===N);return k?l(k):N},[e,l]),m=w.useCallback(N=>{const{field:k,operator:T,value:P}=N;if(typeof k=="string"&&k.startsWith(Uu)){const W=k.slice(Uu.length),M=r?.[W],U=ei(M);return P==="success"?U:P==="failure"?M!=null&&!U:!1}const E=g(k),C=t[E],I=zw(P,t,e);switch(T){case"equals":return zu(C,I);case"notEquals":return!zu(C,I);case"contains":return typeof C=="string"?C.includes(String(I)):Array.isArray(C)?C.includes(I):!1;case"notContains":return typeof C=="string"?!C.includes(String(I)):Array.isArray(C)?!C.includes(I):!0;case"startsWith":return typeof C=="string"&&C.startsWith(String(I));case"endsWith":return typeof C=="string"&&C.endsWith(String(I));case"greaterThan":return Number(C)>Number(I);case"lessThan":return Number(C)<Number(I);case"greaterThanOrEqual":return Number(C)>=Number(I);case"lessThanOrEqual":return Number(C)<=Number(I);case"isEmpty":return C==null?!0:C instanceof File?!1:typeof C=="string"?C.trim()==="":Array.isArray(C)?(C.length>0&&C[0]instanceof File,C.length===0):typeof C=="object"&&C!==null?Object.keys(C).length===0:!1;case"isNotEmpty":return C==null?!1:C instanceof File?!0:typeof C=="string"?C.trim()!=="":Array.isArray(C)?(C.length>0&&C[0]instanceof File,C.length>0):typeof C=="object"&&C!==null?Object.keys(C).length>0:!1;case"isTrue":return C===!0;case"isFalse":return C===!1;case"isNull":return C==null;case"isNotNull":return C!=null;case"in":return Array.isArray(I)?I.includes(C):!1;case"notIn":return Array.isArray(I)?!I.includes(C):!0;case"between":if(Array.isArray(I)&&I.length===2){const W=Number(C);return W>=Number(I[0])&&W<=Number(I[1])}return!1;case"regex":try{return new RegExp(String(I)).test(String(C))}catch{return!1}default:return!0}},[t,g,r,e]),h=w.useCallback(N=>{const k=N.conditions.map(T=>Fu(T)?h(T):m(T));return N.logic==="and"?k.every(Boolean):k.some(Boolean)},[m]),y=w.useCallback(N=>Fu(N)?h(N):m(N),[m,h]),S=w.useCallback(()=>{const N=new Set,k=new Set,T=new Set,P=new Set,E=new Set;e.forEach(M=>{const U=l(M);M.hidden||N.add(U),M.disabled||k.add(U),M.validation?.some(V=>V.type==="required")&&T.add(U)});let C=!1;if(n!=null&&o?.length)for(const M of o){if(!Ow(n,M.when))continue;const{action:U,target:V}=M.then;if(U==="disableForm")C=!0;else if(U==="enableForm")C=!1;else{const X=Iw(V,e,l);for(const B of X)switch(U){case"disable":k.delete(B);break;case"enable":k.add(B);break;case"hide":N.delete(B);break;case"show":N.add(B);break;case"readOnly":P.add(B),E.delete(B);break;case"editable":E.add(B),P.delete(B);break}}}e.forEach(M=>{M.conditions&&M.conditions.forEach(U=>{(y(U.when)?U.then:U.else||[]).forEach(B=>{switch(B.action){case"disableForm":C=!0;break;case"enableForm":C=!1;break;default:{const L=p(B.target,M);switch(B.action){case"show":N.add(L);break;case"hide":N.delete(L);break;case"enable":k.add(L);break;case"disable":k.delete(L);break;case"require":T.add(L);break;case"unrequire":T.delete(L);break}break}}})})});const I=M=>e.filter(U=>U.type!=="editButton"&&(U.name||U.key||U.id)).map(U=>l(U)),W=()=>e.filter(M=>M.type==="button").map(M=>l(M));return e.forEach(M=>{if(M.type!=="editButton")return;const U=l(M);if(!ei(r?.[U]))return;const V=M.properties;V?.rules&&V.rules.length>0?V.rules.forEach(X=>{const B=[];X.allFields&&B.push(...I(M.id)),X.allButtons&&B.push(...W()),X.fieldNames?.length&&X.fieldNames.forEach(L=>{const D=e.find(K=>l(K)===L||K.id===L||K.name===L);B.push(D?l(D):L)}),X.buttonNames?.length&&B.push(...X.buttonNames),B.forEach(L=>{switch(X.action){case"enable":k.add(L),P.delete(L);break;case"disable":k.delete(L);break;case"show":N.add(L);break;case"hide":N.delete(L);break;case"readOnly":P.add(L);break;case"editable":E.add(L);break}})}):((V?.enableFieldNames??[]).forEach(X=>k.add(X)),(V?.disableFieldNames??[]).forEach(X=>k.delete(X)),(V?.showFieldNames??[]).forEach(X=>N.add(X)),(V?.hideFieldNames??[]).forEach(X=>N.delete(X)))}),{visible:Array.from(N),enabled:Array.from(k),required:Array.from(T),readOnly:Array.from(P),editable:Array.from(E),formDisabled:C}},[e,y,l,p,t,r,n,o]),v=w.useMemo(()=>S(),[S]);w.useLayoutEffect(()=>{i(v.visible),s(v.enabled),a(v.required),c(v.readOnly??[]),u(v.editable??[]),f(v.formDisabled??!1)},[v,i,s,a,c,u,f]);const A=w.useCallback(N=>v.visible.includes(N),[v.visible]),x=w.useCallback(N=>v.enabled.includes(N),[v.enabled]),F=w.useCallback(N=>v.required.includes(N),[v.required]);return{evaluateCondition:y,evaluateExpression:m,evaluateGroup:h,isFieldVisible:A,isFieldEnabled:x,isFieldRequired:F,visibleFields:v.visible,enabledFields:v.enabled,requiredFields:v.required}}function mn({className:e,type:t,...r}){return d.jsx("input",{type:t,"data-slot":"input",className:H("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground text-foreground dark:bg-secondary dark:border-input border-input flex h-9 w-full min-w-0 rounded-md border bg-background px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...r})}function Vu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function qn(...e){return t=>{let r=!1;const n=e.map(o=>{const i=Vu(o,t);return!r&&typeof i=="function"&&(r=!0),i});if(r)return()=>{for(let o=0;o<n.length;o++){const i=n[o];typeof i=="function"?i():Vu(e[o],null)}}}}function qe(...e){return b.useCallback(qn(...e),e)}var Vw=Symbol.for("react.lazy"),is=b[" use ".trim().toString()];function Hw(e){return typeof e=="object"&&e!==null&&"then"in e}function Hu(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Vw&&"_payload"in e&&Hw(e._payload)}function ul(e){const t=Ww(e),r=b.forwardRef((n,o)=>{let{children:i,...s}=n;Hu(i)&&typeof is=="function"&&(i=is(i._payload));const a=b.Children.toArray(i),c=a.find(Kw);if(c){const u=c.props.children,f=a.map(l=>l===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:l);return d.jsx(t,{...s,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,f):null})}return d.jsx(t,{...s,ref:o,children:i})});return r.displayName=`${e}.Slot`,r}var Wu=ul("Slot");function Ww(e){const t=b.forwardRef((r,n)=>{let{children:o,...i}=r;if(Hu(o)&&typeof is=="function"&&(o=is(o._payload)),b.isValidElement(o)){const s=qw(o),a=Gw(i,o.props);return o.type!==b.Fragment&&(a.ref=n?qn(n,s):s),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Rw=Symbol("radix.slottable");function Kw(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Rw}function Gw(e,t){const r={...t};for(const n in t){const o=e[n],i=t[n];/^on[A-Z]/.test(n)?o&&i?r[n]=(...a)=>{const c=i(...a);return o(...a),c}:o&&(r[n]=o):n==="style"?r[n]={...o,...i}:n==="className"&&(r[n]=[o,i].filter(Boolean).join(" "))}return{...e,...r}}function qw(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var Yw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Xw=Yw.reduce((e,t)=>{const r=ul(`Primitive.${t}`),n=b.forwardRef((o,i)=>{const{asChild:s,...a}=o,c=s?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(c,{...a,ref:i})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),Jw="Label",Ru=b.forwardRef((e,t)=>d.jsx(Xw.label,{...e,ref:t,onMouseDown:r=>{r.target.closest("button, input, select, textarea")||(e.onMouseDown?.(r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));Ru.displayName=Jw;var Qw=Ru;function Pn({className:e,...t}){return d.jsx(Qw,{"data-slot":"label",className:H("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50 mb-2",e),...t})}function ft(e){return`formsmith-field-${e.id}`}function ss(e){return`formsmith-label-${e.id}`}function ti(e){return`formsmith-desc-${e.id}`}function ri(e){return`formsmith-error-${e.id}`}function Lt(e,t){const r=[];return e.description&&r.push(ti(e)),t&&r.push(ri(e)),r.length>0?r.join(" "):void 0}function Xt(e){return e?!0:void 0}const Zw={body:{fontSize:"0.875rem",lineHeight:"1.25rem",fontWeight:400},heading:{fontSize:"1.125rem",lineHeight:"1.5rem",fontWeight:600},label:{fontSize:"0.875rem",lineHeight:"1.25rem",fontWeight:500},caption:{fontSize:"0.75rem",lineHeight:"1rem",fontWeight:400,color:"var(--muted-foreground)"}};function On(e){return e.ui?.cellStyle}function eS(e){const t=e.ui;if(!t)return;const r=t.fontToken?Zw[t.fontToken]:void 0;if(!(!r&&!t.wrapperStyle))return{...r,...t.wrapperStyle}}function tS(e){return e.type==="button"||e.type==="editButton"}const At=({field:e,error:t,isRequired:r,children:n,className:o,hideLabel:i})=>{const{gridStretch:s}=Zo(),a=s&&Qi(e),c=!(i??e.appearance?.hideLabel)&&e.label,u=e.appearance?.labelPlacement||"top",f=eS(e),l=e.appearance?.minWidth!=null||e.appearance?.minHeight!=null?{...e.appearance.minWidth!=null?{minWidth:e.appearance.minWidth}:{},...e.appearance.minHeight!=null?{minHeight:e.appearance.minHeight}:{}}:void 0,p=e.appearance?.className,g=uu(e),m=fo(e),h=tS(e),y=Fr(e.appearance);return d.jsx("div",{className:H(Gv(u),u!=="floating"&&"space-y-2",a&&!h&&"flex-1 min-h-0 h-full",s&&h&&"w-full shrink-0 self-start",p,o),style:f,"data-field-appearance":u,children:d.jsxs("div",{className:H("flex flex-col min-w-0",au(e.appearance),fu(e),a&&!h&&"flex-1 min-h-0",s&&h&&"shrink-0"),style:g,children:[c&&d.jsxs(Pn,{id:ss(e),htmlFor:ft(e),style:e.ui?.labelStyle,className:H(qv(u,!!t)),children:[e.label,r&&d.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),d.jsxs("div",{className:H(Yv(u),h&&s&&"min-h-min !grow-0 !shrink-0 basis-auto",m&&y!=="stretch"&&"items-start",h&&y==="stretch"&&"items-start w-full [&_button]:w-full",!h&&y==="stretch"&&"items-stretch",a&&!h&&"flex-1 min-h-0",o?.includes("flex")&&u==="top"&&"flex flex-col min-h-0"),style:l,children:[n,d.jsxs("div",{className:H("mt-1.5 min-h-[18px]",u==="center"&&"text-center",o?.includes("flex")&&"shrink-0"),children:[e.description&&!t&&d.jsx("p",{id:ti(e),className:"text-xs text-muted-foreground",style:e.ui?.descriptionStyle,children:e.description}),t&&d.jsx("p",{id:ri(e),className:"text-xs text-destructive",role:"alert",children:typeof t=="string"?t:String(t||"An error occurred")})]})]})]})})},as=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:c})=>{const u=e.properties,f=w.useCallback(l=>{r(l.target.value)},[r]);return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsx(mn,{id:ft(e),type:"text",value:t||"",onChange:f,onBlur:n,placeholder:e.placeholder,disabled:i||e.disabled,readOnly:s||e.readOnly,minLength:u?.minLength,maxLength:u?.maxLength,pattern:u?.pattern,autoComplete:u?.autoComplete,inputMode:u?.inputMode,"aria-describedby":Lt(e,!!o),"aria-invalid":Xt(!!o),"aria-required":a,className:H(uo(e.appearance),o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})})},fl=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:c})=>{const u=e.properties,f=u?.precision!=null||u?.step!=null&&!Number.isInteger(u.step),l=w.useCallback(g=>{const m=u?.allowNegative!==!1,h=g.target.value,y=f?h.replace(m?/[^\d.-]/g:/[^\d.]/g,""):h.replace(m?/[^\d-]/g:/\D/g,"");if(y===""){r(null);return}const S=parseFloat(y);isNaN(S)||r(S)},[r,u?.allowNegative,f]),p=w.useCallback(g=>{(g.key==="ArrowUp"||g.key==="ArrowDown"||g.key==="PageUp"||g.key==="PageDown")&&g.preventDefault()},[]);return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"relative",children:[u?.prefix&&d.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:u.prefix}),d.jsx(mn,{id:ft(e),type:"text",inputMode:f?"decimal":"numeric",autoComplete:"off",value:t??"",onChange:l,onKeyDown:p,onBlur:n,placeholder:e.placeholder,disabled:i||e.disabled,readOnly:s||e.readOnly,"aria-describedby":Lt(e,!!o),"aria-invalid":Xt(!!o),"aria-required":a,className:H(uo(e.appearance),o&&"border-destructive focus-visible:ring-destructive",u?.prefix&&"pl-8",u?.suffix&&"pr-8",e.appearance?.className)}),u?.suffix&&d.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:u.suffix})]})})};const rS=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),nS=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,n)=>n?n.toUpperCase():r.toLowerCase()),Ku=e=>{const t=nS(e);return t.charAt(0).toUpperCase()+t.slice(1)},Gu=(...e)=>e.filter((t,r,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===r).join(" ").trim(),oS=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var iS={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const sS=w.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:o="",children:i,iconNode:s,...a},c)=>w.createElement("svg",{ref:c,...iS,width:t,height:t,stroke:e,strokeWidth:n?Number(r)*24/Number(t):r,className:Gu("lucide",o),...!i&&!oS(a)&&{"aria-hidden":"true"},...a},[...s.map(([u,f])=>w.createElement(u,f)),...Array.isArray(i)?i:[i]]));const Gt=(e,t)=>{const r=w.forwardRef(({className:n,...o},i)=>w.createElement(sS,{ref:i,iconNode:t,className:Gu(`lucide-${rS(Ku(e))}`,`lucide-${e}`,n),...o}));return r.displayName=Ku(e),r};const aS=Gt("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);const ls=Gt("camera",[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);const cs=Gt("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const ni=Gt("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const qu=Gt("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const lS=Gt("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);const cS=Gt("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const Yu=Gt("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const Xu=Gt("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ju=Gt("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const mo=Gt("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const dS=Gt("mail",[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]);const uS=Gt("phone",[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]]);const Qu=Gt("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const fS=Gt("sliders-horizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);const Zu=Gt("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);const oi=Gt("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);const ds=Gt("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const ii=Gt("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),ef=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:c})=>{const u=w.useCallback(f=>{r(f.target.value)},[r]);return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"relative",children:[d.jsx(dS,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),d.jsx(mn,{id:ft(e),type:"email",value:t||"",onChange:u,onBlur:n,placeholder:e.placeholder||"email@example.com",disabled:i||e.disabled,readOnly:s||e.readOnly,autoComplete:"email",inputMode:"email","aria-describedby":Lt(e,!!o),"aria-invalid":Xt(!!o),"aria-required":a,className:H(uo(e.appearance),"pl-10",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]})})},tf=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:c})=>{const u=w.useCallback(f=>{const l=f.target.value.replace(/[^\d\s+\-()]/g,"");r(l)},[r]);return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"relative",children:[d.jsx(uS,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),d.jsx(mn,{id:ft(e),type:"tel",value:t||"",onChange:u,onBlur:n,placeholder:e.placeholder||"+91 12345 67890",disabled:i||e.disabled,readOnly:s||e.readOnly,autoComplete:"tel",inputMode:"tel","aria-describedby":Lt(e,!!o),"aria-invalid":Xt(!!o),"aria-required":a,className:H(uo(e.appearance),"pl-10",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]})})};function rf(e,t){return function(){return e.apply(t,arguments)}}const{toString:pS}=Object.prototype,{getPrototypeOf:pl}=Object,{iterator:us,toStringTag:nf}=Symbol,fs=(e=>t=>{const r=pS.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),Wr=e=>(e=e.toLowerCase(),t=>fs(t)===e),ps=e=>t=>typeof t===e,{isArray:ho}=Array,go=ps("undefined");function si(e){return e!==null&&!go(e)&&e.constructor!==null&&!go(e.constructor)&&mr(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const of=Wr("ArrayBuffer");function mS(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&of(e.buffer),t}const hS=ps("string"),mr=ps("function"),sf=ps("number"),ai=e=>e!==null&&typeof e=="object",gS=e=>e===!0||e===!1,ms=e=>{if(fs(e)!=="object")return!1;const t=pl(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(nf in e)&&!(us in e)},yS=e=>{if(!ai(e)||si(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},bS=Wr("Date"),vS=Wr("File"),wS=e=>!!(e&&typeof e.uri<"u"),SS=e=>e&&typeof e.getParts<"u",xS=Wr("Blob"),AS=Wr("FileList"),CS=e=>ai(e)&&mr(e.pipe);function ES(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const af=ES(),lf=typeof af.FormData<"u"?af.FormData:void 0,NS=e=>{let t;return e&&(lf&&e instanceof lf||mr(e.append)&&((t=fs(e))==="formdata"||t==="object"&&mr(e.toString)&&e.toString()==="[object FormData]"))},kS=Wr("URLSearchParams"),[_S,TS,FS,PS]=["ReadableStream","Request","Response","Headers"].map(Wr),OS=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function li(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,o;if(typeof e!="object"&&(e=[e]),ho(e))for(n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else{if(si(e))return;const i=r?Object.getOwnPropertyNames(e):Object.keys(e),s=i.length;let a;for(n=0;n<s;n++)a=i[n],t.call(null,e[a],a,e)}}function cf(e,t){if(si(e))return null;t=t.toLowerCase();const r=Object.keys(e);let n=r.length,o;for(;n-- >0;)if(o=r[n],t===o.toLowerCase())return o;return null}const Yn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,df=e=>!go(e)&&e!==Yn;function ml(){const{caseless:e,skipUndefined:t}=df(this)&&this||{},r={},n=(o,i)=>{if(i==="__proto__"||i==="constructor"||i==="prototype")return;const s=e&&cf(r,i)||i;ms(r[s])&&ms(o)?r[s]=ml(r[s],o):ms(o)?r[s]=ml({},o):ho(o)?r[s]=o.slice():(!t||!go(o))&&(r[s]=o)};for(let o=0,i=arguments.length;o<i;o++)arguments[o]&&li(arguments[o],n);return r}const IS=(e,t,r,{allOwnKeys:n}={})=>(li(t,(o,i)=>{r&&mr(o)?Object.defineProperty(e,i,{value:rf(o,r),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,i,{value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:n}),e),MS=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),LS=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},DS=(e,t,r,n)=>{let o,i,s;const a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),i=o.length;i-- >0;)s=o[i],(!n||n(s,e,t))&&!a[s]&&(t[s]=e[s],a[s]=!0);e=r!==!1&&pl(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},BS=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return n!==-1&&n===r},$S=e=>{if(!e)return null;if(ho(e))return e;let t=e.length;if(!sf(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},jS=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&pl(Uint8Array)),zS=(e,t)=>{const n=(e&&e[us]).call(e);let o;for(;(o=n.next())&&!o.done;){const i=o.value;t.call(e,i[0],i[1])}},US=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},VS=Wr("HTMLFormElement"),HS=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,o){return n.toUpperCase()+o}),uf=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),WS=Wr("RegExp"),ff=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};li(r,(o,i)=>{let s;(s=t(o,i,e))!==!1&&(n[i]=s||o)}),Object.defineProperties(e,n)},RS=e=>{ff(e,(t,r)=>{if(mr(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=e[r];if(mr(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},KS=(e,t)=>{const r={},n=o=>{o.forEach(i=>{r[i]=!0})};return ho(e)?n(e):n(String(e).split(t)),r},GS=()=>{},qS=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function YS(e){return!!(e&&mr(e.append)&&e[nf]==="FormData"&&e[us])}const XS=e=>{const t=new Array(10),r=(n,o)=>{if(ai(n)){if(t.indexOf(n)>=0)return;if(si(n))return n;if(!("toJSON"in n)){t[o]=n;const i=ho(n)?[]:{};return li(n,(s,a)=>{const c=r(s,o+1);!go(c)&&(i[a]=c)}),t[o]=void 0,i}}return n};return r(e,0)},JS=Wr("AsyncFunction"),QS=e=>e&&(ai(e)||mr(e))&&mr(e.then)&&mr(e.catch),pf=((e,t)=>e?setImmediate:t?((r,n)=>(Yn.addEventListener("message",({source:o,data:i})=>{o===Yn&&i===r&&n.length&&n.shift()()},!1),o=>{n.push(o),Yn.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",mr(Yn.postMessage)),ZS=typeof queueMicrotask<"u"?queueMicrotask.bind(Yn):typeof process<"u"&&process.nextTick||pf,Y={isArray:ho,isArrayBuffer:of,isBuffer:si,isFormData:NS,isArrayBufferView:mS,isString:hS,isNumber:sf,isBoolean:gS,isObject:ai,isPlainObject:ms,isEmptyObject:yS,isReadableStream:_S,isRequest:TS,isResponse:FS,isHeaders:PS,isUndefined:go,isDate:bS,isFile:vS,isReactNativeBlob:wS,isReactNative:SS,isBlob:xS,isRegExp:WS,isFunction:mr,isStream:CS,isURLSearchParams:kS,isTypedArray:jS,isFileList:AS,forEach:li,merge:ml,extend:IS,trim:OS,stripBOM:MS,inherits:LS,toFlatObject:DS,kindOf:fs,kindOfTest:Wr,endsWith:BS,toArray:$S,forEachEntry:zS,matchAll:US,isHTMLForm:VS,hasOwnProperty:uf,hasOwnProp:uf,reduceDescriptors:ff,freezeMethods:RS,toObjectSet:KS,toCamelCase:HS,noop:GS,toFiniteNumber:qS,findKey:cf,global:Yn,isContextDefined:df,isSpecCompliantForm:YS,toJSONObject:XS,isAsyncFn:JS,isThenable:QS,setImmediate:pf,asap:ZS,isIterable:e=>e!=null&&mr(e[us])};let Ke=class tv extends Error{static from(t,r,n,o,i,s){const a=new tv(t.message,r||t.code,n,o,i);return a.cause=t,a.name=t.name,t.status!=null&&a.status==null&&(a.status=t.status),s&&Object.assign(a,s),a}constructor(t,r,n,o,i){super(t),Object.defineProperty(this,"message",{value:t,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,r&&(this.code=r),n&&(this.config=n),o&&(this.request=o),i&&(this.response=i,this.status=i.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Y.toJSONObject(this.config),code:this.code,status:this.status}}};Ke.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",Ke.ERR_BAD_OPTION="ERR_BAD_OPTION",Ke.ECONNABORTED="ECONNABORTED",Ke.ETIMEDOUT="ETIMEDOUT",Ke.ERR_NETWORK="ERR_NETWORK",Ke.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",Ke.ERR_DEPRECATED="ERR_DEPRECATED",Ke.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",Ke.ERR_BAD_REQUEST="ERR_BAD_REQUEST",Ke.ERR_CANCELED="ERR_CANCELED",Ke.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",Ke.ERR_INVALID_URL="ERR_INVALID_URL";const e0=null;function hl(e){return Y.isPlainObject(e)||Y.isArray(e)}function mf(e){return Y.endsWith(e,"[]")?e.slice(0,-2):e}function gl(e,t,r){return e?e.concat(t).map(function(o,i){return o=mf(o),!r&&i?"["+o+"]":o}).join(r?".":""):t}function t0(e){return Y.isArray(e)&&!e.some(hl)}const r0=Y.toFlatObject(Y,{},null,function(t){return/^is[A-Z]/.test(t)});function hs(e,t,r){if(!Y.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=Y.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,y){return!Y.isUndefined(y[h])});const n=r.metaTokens,o=r.visitor||f,i=r.dots,s=r.indexes,c=(r.Blob||typeof Blob<"u"&&Blob)&&Y.isSpecCompliantForm(t);if(!Y.isFunction(o))throw new TypeError("visitor must be a function");function u(m){if(m===null)return"";if(Y.isDate(m))return m.toISOString();if(Y.isBoolean(m))return m.toString();if(!c&&Y.isBlob(m))throw new Ke("Blob is not supported. Use a Buffer instead.");return Y.isArrayBuffer(m)||Y.isTypedArray(m)?c&&typeof Blob=="function"?new Blob([m]):Buffer.from(m):m}function f(m,h,y){let S=m;if(Y.isReactNative(t)&&Y.isReactNativeBlob(m))return t.append(gl(y,h,i),u(m)),!1;if(m&&!y&&typeof m=="object"){if(Y.endsWith(h,"{}"))h=n?h:h.slice(0,-2),m=JSON.stringify(m);else if(Y.isArray(m)&&t0(m)||(Y.isFileList(m)||Y.endsWith(h,"[]"))&&(S=Y.toArray(m)))return h=mf(h),S.forEach(function(A,x){!(Y.isUndefined(A)||A===null)&&t.append(s===!0?gl([h],x,i):s===null?h:h+"[]",u(A))}),!1}return hl(m)?!0:(t.append(gl(y,h,i),u(m)),!1)}const l=[],p=Object.assign(r0,{defaultVisitor:f,convertValue:u,isVisitable:hl});function g(m,h){if(!Y.isUndefined(m)){if(l.indexOf(m)!==-1)throw Error("Circular reference detected in "+h.join("."));l.push(m),Y.forEach(m,function(S,v){(!(Y.isUndefined(S)||S===null)&&o.call(t,S,Y.isString(v)?v.trim():v,h,p))===!0&&g(S,h?h.concat(v):[v])}),l.pop()}}if(!Y.isObject(e))throw new TypeError("data must be an object");return g(e),t}function hf(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function yl(e,t){this._pairs=[],e&&hs(e,this,t)}const gf=yl.prototype;gf.append=function(t,r){this._pairs.push([t,r])},gf.toString=function(t){const r=t?function(n){return t.call(this,n,hf)}:hf;return this._pairs.map(function(o){return r(o[0])+"="+r(o[1])},"").join("&")};function n0(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function yf(e,t,r){if(!t)return e;const n=r&&r.encode||n0,o=Y.isFunction(r)?{serialize:r}:r,i=o&&o.serialize;let s;if(i?s=i(t,o):s=Y.isURLSearchParams(t)?t.toString():new yl(t,o).toString(n),s){const a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class bf{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Y.forEach(this.handlers,function(n){n!==null&&t(n)})}}const bl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},o0={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:yl,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},vl=typeof window<"u"&&typeof document<"u",wl=typeof navigator=="object"&&navigator||void 0,i0=vl&&(!wl||["ReactNative","NativeScript","NS"].indexOf(wl.product)<0),s0=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",a0=vl&&window.location.href||"http://localhost",ir={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:vl,hasStandardBrowserEnv:i0,hasStandardBrowserWebWorkerEnv:s0,navigator:wl,origin:a0},Symbol.toStringTag,{value:"Module"})),...o0};function l0(e,t){return hs(e,new ir.classes.URLSearchParams,{visitor:function(r,n,o,i){return ir.isNode&&Y.isBuffer(r)?(this.append(n,r.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...t})}function c0(e){return Y.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function d0(e){const t={},r=Object.keys(e);let n;const o=r.length;let i;for(n=0;n<o;n++)i=r[n],t[i]=e[i];return t}function vf(e){function t(r,n,o,i){let s=r[i++];if(s==="__proto__")return!0;const a=Number.isFinite(+s),c=i>=r.length;return s=!s&&Y.isArray(o)?o.length:s,c?(Y.hasOwnProp(o,s)?o[s]=[o[s],n]:o[s]=n,!a):((!o[s]||!Y.isObject(o[s]))&&(o[s]=[]),t(r,n,o[s],i)&&Y.isArray(o[s])&&(o[s]=d0(o[s])),!a)}if(Y.isFormData(e)&&Y.isFunction(e.entries)){const r={};return Y.forEachEntry(e,(n,o)=>{t(c0(n),o,r,0)}),r}return null}function u0(e,t,r){if(Y.isString(e))try{return(t||JSON.parse)(e),Y.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}const ci={transitional:bl,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){const n=r.getContentType()||"",o=n.indexOf("application/json")>-1,i=Y.isObject(t);if(i&&Y.isHTMLForm(t)&&(t=new FormData(t)),Y.isFormData(t))return o?JSON.stringify(vf(t)):t;if(Y.isArrayBuffer(t)||Y.isBuffer(t)||Y.isStream(t)||Y.isFile(t)||Y.isBlob(t)||Y.isReadableStream(t))return t;if(Y.isArrayBufferView(t))return t.buffer;if(Y.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(i){if(n.indexOf("application/x-www-form-urlencoded")>-1)return l0(t,this.formSerializer).toString();if((a=Y.isFileList(t))||n.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return hs(a?{"files[]":t}:t,c&&new c,this.formSerializer)}}return i||o?(r.setContentType("application/json",!1),u0(t)):t}],transformResponse:[function(t){const r=this.transitional||ci.transitional,n=r&&r.forcedJSONParsing,o=this.responseType==="json";if(Y.isResponse(t)||Y.isReadableStream(t))return t;if(t&&Y.isString(t)&&(n&&!this.responseType||o)){const s=!(r&&r.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(s)throw a.name==="SyntaxError"?Ke.from(a,Ke.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ir.classes.FormData,Blob:ir.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Y.forEach(["delete","get","head","post","put","patch"],e=>{ci.headers[e]={}});const f0=Y.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),p0=e=>{const t={};let r,n,o;return e&&e.split(`
|
|
2
|
-
`).forEach(function(s){o=s.indexOf(":"),r=s.substring(0,o).trim().toLowerCase(),n=s.substring(o+1).trim(),!(!r||t[r]&&
|
|
3
|
-
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const n=new this(t);return r.forEach(o=>n.set(o)),n}static accessor(t){const n=(this[wf]=this[wf]={accessors:{}}).accessors,o=this.prototype;function i(s){const a=di(s);n[a]||(y0(o,s),n[a]=!0)}return Y.isArray(t)?t.forEach(i):i(t),this}};hr.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Y.reduceDescriptors(hr.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}}),Y.freezeMethods(hr);function xl(e,t){const r=this||ci,n=t||r,o=hr.from(n.headers);let i=n.data;return Y.forEach(e,function(a){i=a.call(r,i,o.normalize(),t?t.status:void 0)}),o.normalize(),i}function Sf(e){return!!(e&&e.__CANCEL__)}let ui=class extends Ke{constructor(t,r,n){super(t??"canceled",Ke.ERR_CANCELED,r,n),this.name="CanceledError",this.__CANCEL__=!0}};function xf(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new Ke("Request failed with status code "+r.status,[Ke.ERR_BAD_REQUEST,Ke.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function b0(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function v0(e,t){e=e||10;const r=new Array(e),n=new Array(e);let o=0,i=0,s;return t=t!==void 0?t:1e3,function(c){const u=Date.now(),f=n[i];s||(s=u),r[o]=c,n[o]=u;let l=i,p=0;for(;l!==o;)p+=r[l++],l=l%e;if(o=(o+1)%e,o===i&&(i=(i+1)%e),u-s<t)return;const g=f&&u-f;return g?Math.round(p*1e3/g):void 0}}function w0(e,t){let r=0,n=1e3/t,o,i;const s=(u,f=Date.now())=>{r=f,o=null,i&&(clearTimeout(i),i=null),e(...u)};return[(...u)=>{const f=Date.now(),l=f-r;l>=n?s(u,f):(o=u,i||(i=setTimeout(()=>{i=null,s(o)},n-l)))},()=>o&&s(o)]}const ys=(e,t,r=3)=>{let n=0;const o=v0(50,250);return w0(i=>{const s=i.loaded,a=i.lengthComputable?i.total:void 0,c=s-n,u=o(c),f=s<=a;n=s;const l={loaded:s,total:a,progress:a?s/a:void 0,bytes:c,rate:u||void 0,estimated:u&&a&&f?(a-s)/u:void 0,event:i,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(l)},r)},Af=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},Cf=e=>(...t)=>Y.asap(()=>e(...t)),S0=ir.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,ir.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(ir.origin),ir.navigator&&/(msie|trident)/i.test(ir.navigator.userAgent)):()=>!0,x0=ir.hasStandardBrowserEnv?{write(e,t,r,n,o,i,s){if(typeof document>"u")return;const a=[`${e}=${encodeURIComponent(t)}`];Y.isNumber(r)&&a.push(`expires=${new Date(r).toUTCString()}`),Y.isString(n)&&a.push(`path=${n}`),Y.isString(o)&&a.push(`domain=${o}`),i===!0&&a.push("secure"),Y.isString(s)&&a.push(`SameSite=${s}`),document.cookie=a.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function A0(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function C0(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Ef(e,t,r){let n=!A0(t);return e&&(n||r==!1)?C0(e,t):t}const Nf=e=>e instanceof hr?{...e}:e;function Xn(e,t){t=t||{};const r={};function n(u,f,l,p){return Y.isPlainObject(u)&&Y.isPlainObject(f)?Y.merge.call({caseless:p},u,f):Y.isPlainObject(f)?Y.merge({},f):Y.isArray(f)?f.slice():f}function o(u,f,l,p){if(Y.isUndefined(f)){if(!Y.isUndefined(u))return n(void 0,u,l,p)}else return n(u,f,l,p)}function i(u,f){if(!Y.isUndefined(f))return n(void 0,f)}function s(u,f){if(Y.isUndefined(f)){if(!Y.isUndefined(u))return n(void 0,u)}else return n(void 0,f)}function a(u,f,l){if(l in t)return n(u,f);if(l in e)return n(void 0,u)}const c={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(u,f,l)=>o(Nf(u),Nf(f),l,!0)};return Y.forEach(Object.keys({...e,...t}),function(f){if(f==="__proto__"||f==="constructor"||f==="prototype")return;const l=Y.hasOwnProp(c,f)?c[f]:o,p=l(e[f],t[f],f);Y.isUndefined(p)&&l!==a||(r[f]=p)}),r}const kf=e=>{const t=Xn({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:o,xsrfCookieName:i,headers:s,auth:a}=t;if(t.headers=s=hr.from(s),t.url=yf(Ef(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),Y.isFormData(r)){if(ir.hasStandardBrowserEnv||ir.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if(Y.isFunction(r.getHeaders)){const c=r.getHeaders(),u=["content-type","content-length"];Object.entries(c).forEach(([f,l])=>{u.includes(f.toLowerCase())&&s.set(f,l)})}}if(ir.hasStandardBrowserEnv&&(n&&Y.isFunction(n)&&(n=n(t)),n||n!==!1&&S0(t.url))){const c=o&&i&&x0.read(i);c&&s.set(o,c)}return t},E0=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(r,n){const o=kf(e);let i=o.data;const s=hr.from(o.headers).normalize();let{responseType:a,onUploadProgress:c,onDownloadProgress:u}=o,f,l,p,g,m;function h(){g&&g(),m&&m(),o.cancelToken&&o.cancelToken.unsubscribe(f),o.signal&&o.signal.removeEventListener("abort",f)}let y=new XMLHttpRequest;y.open(o.method.toUpperCase(),o.url,!0),y.timeout=o.timeout;function S(){if(!y)return;const A=hr.from("getAllResponseHeaders"in y&&y.getAllResponseHeaders()),F={data:!a||a==="text"||a==="json"?y.responseText:y.response,status:y.status,statusText:y.statusText,headers:A,config:e,request:y};xf(function(k){r(k),h()},function(k){n(k),h()},F),y=null}"onloadend"in y?y.onloadend=S:y.onreadystatechange=function(){!y||y.readyState!==4||y.status===0&&!(y.responseURL&&y.responseURL.indexOf("file:")===0)||setTimeout(S)},y.onabort=function(){y&&(n(new Ke("Request aborted",Ke.ECONNABORTED,e,y)),y=null)},y.onerror=function(x){const F=x&&x.message?x.message:"Network Error",N=new Ke(F,Ke.ERR_NETWORK,e,y);N.event=x||null,n(N),y=null},y.ontimeout=function(){let x=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const F=o.transitional||bl;o.timeoutErrorMessage&&(x=o.timeoutErrorMessage),n(new Ke(x,F.clarifyTimeoutError?Ke.ETIMEDOUT:Ke.ECONNABORTED,e,y)),y=null},i===void 0&&s.setContentType(null),"setRequestHeader"in y&&Y.forEach(s.toJSON(),function(x,F){y.setRequestHeader(F,x)}),Y.isUndefined(o.withCredentials)||(y.withCredentials=!!o.withCredentials),a&&a!=="json"&&(y.responseType=o.responseType),u&&([p,m]=ys(u,!0),y.addEventListener("progress",p)),c&&y.upload&&([l,g]=ys(c),y.upload.addEventListener("progress",l),y.upload.addEventListener("loadend",g)),(o.cancelToken||o.signal)&&(f=A=>{y&&(n(!A||A.type?new ui(null,e,y):A),y.abort(),y=null)},o.cancelToken&&o.cancelToken.subscribe(f),o.signal&&(o.signal.aborted?f():o.signal.addEventListener("abort",f)));const v=b0(o.url);if(v&&ir.protocols.indexOf(v)===-1){n(new Ke("Unsupported protocol "+v+":",Ke.ERR_BAD_REQUEST,e));return}y.send(i||null)})},N0=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,o;const i=function(u){if(!o){o=!0,a();const f=u instanceof Error?u:this.reason;n.abort(f instanceof Ke?f:new ui(f instanceof Error?f.message:f))}};let s=t&&setTimeout(()=>{s=null,i(new Ke(`timeout of ${t}ms exceeded`,Ke.ETIMEDOUT))},t);const a=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(i):u.removeEventListener("abort",i)}),e=null)};e.forEach(u=>u.addEventListener("abort",i));const{signal:c}=n;return c.unsubscribe=()=>Y.asap(a),c}},k0=function*(e,t){let r=e.byteLength;if(r<t){yield e;return}let n=0,o;for(;n<r;)o=n+t,yield e.slice(n,o),n=o},_0=async function*(e,t){for await(const r of T0(e))yield*k0(r,t)},T0=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},_f=(e,t,r,n)=>{const o=_0(e,t);let i=0,s,a=c=>{s||(s=!0,n&&n(c))};return new ReadableStream({async pull(c){try{const{done:u,value:f}=await o.next();if(u){a(),c.close();return}let l=f.byteLength;if(r){let p=i+=l;r(p)}c.enqueue(new Uint8Array(f))}catch(u){throw a(u),u}},cancel(c){return a(c),o.return()}},{highWaterMark:2})},Tf=64*1024,{isFunction:bs}=Y,F0=(({Request:e,Response:t})=>({Request:e,Response:t}))(Y.global),{ReadableStream:Ff,TextEncoder:Pf}=Y.global,Of=(e,...t)=>{try{return!!e(...t)}catch{return!1}},P0=e=>{e=Y.merge.call({skipUndefined:!0},F0,e);const{fetch:t,Request:r,Response:n}=e,o=t?bs(t):typeof fetch=="function",i=bs(r),s=bs(n);if(!o)return!1;const a=o&&bs(Ff),c=o&&(typeof Pf=="function"?(m=>h=>m.encode(h))(new Pf):async m=>new Uint8Array(await new r(m).arrayBuffer())),u=i&&a&&Of(()=>{let m=!1;const h=new Ff,y=new r(ir.origin,{body:h,method:"POST",get duplex(){return m=!0,"half"}}).headers.has("Content-Type");return h.cancel(),m&&!y}),f=s&&a&&Of(()=>Y.isReadableStream(new n("").body)),l={stream:f&&(m=>m.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(m=>{!l[m]&&(l[m]=(h,y)=>{let S=h&&h[m];if(S)return S.call(h);throw new Ke(`Response type '${m}' is not supported`,Ke.ERR_NOT_SUPPORT,y)})});const p=async m=>{if(m==null)return 0;if(Y.isBlob(m))return m.size;if(Y.isSpecCompliantForm(m))return(await new r(ir.origin,{method:"POST",body:m}).arrayBuffer()).byteLength;if(Y.isArrayBufferView(m)||Y.isArrayBuffer(m))return m.byteLength;if(Y.isURLSearchParams(m)&&(m=m+""),Y.isString(m))return(await c(m)).byteLength},g=async(m,h)=>{const y=Y.toFiniteNumber(m.getContentLength());return y??p(h)};return async m=>{let{url:h,method:y,data:S,signal:v,cancelToken:A,timeout:x,onDownloadProgress:F,onUploadProgress:N,responseType:k,headers:T,withCredentials:P="same-origin",fetchOptions:E}=kf(m),C=t||fetch;k=k?(k+"").toLowerCase():"text";let I=N0([v,A&&A.toAbortSignal()],x),W=null;const M=I&&I.unsubscribe&&(()=>{I.unsubscribe()});let U;try{if(N&&u&&y!=="get"&&y!=="head"&&(U=await g(T,S))!==0){let K=new r(h,{method:"POST",body:S,duplex:"half"}),ae;if(Y.isFormData(S)&&(ae=K.headers.get("content-type"))&&T.setContentType(ae),K.body){const[j,z]=Af(U,ys(Cf(N)));S=_f(K.body,Tf,j,z)}}Y.isString(P)||(P=P?"include":"omit");const V=i&&"credentials"in r.prototype,X={...E,signal:I,method:y.toUpperCase(),headers:T.normalize().toJSON(),body:S,duplex:"half",credentials:V?P:void 0};W=i&&new r(h,X);let B=await(i?C(W,E):C(h,X));const L=f&&(k==="stream"||k==="response");if(f&&(F||L&&M)){const K={};["status","statusText","headers"].forEach(le=>{K[le]=B[le]});const ae=Y.toFiniteNumber(B.headers.get("content-length")),[j,z]=F&&Af(ae,ys(Cf(F),!0))||[];B=new n(_f(B.body,Tf,j,()=>{z&&z(),M&&M()}),K)}k=k||"text";let D=await l[Y.findKey(l,k)||"text"](B,m);return!L&&M&&M(),await new Promise((K,ae)=>{xf(K,ae,{data:D,headers:hr.from(B.headers),status:B.status,statusText:B.statusText,config:m,request:W})})}catch(V){throw M&&M(),V&&V.name==="TypeError"&&/Load failed|fetch/i.test(V.message)?Object.assign(new Ke("Network Error",Ke.ERR_NETWORK,m,W,V&&V.response),{cause:V.cause||V}):Ke.from(V,V&&V.code,m,W,V&&V.response)}}},O0=new Map,If=e=>{let t=e&&e.env||{};const{fetch:r,Request:n,Response:o}=t,i=[n,o,r];let s=i.length,a=s,c,u,f=O0;for(;a--;)c=i[a],u=f.get(c),u===void 0&&f.set(c,u=a?new Map:P0(t)),f=u;return u};If();const Al={http:e0,xhr:E0,fetch:{get:If}};Y.forEach(Al,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Mf=e=>`- ${e}`,I0=e=>Y.isFunction(e)||e===null||e===!1;function M0(e,t){e=Y.isArray(e)?e:[e];const{length:r}=e;let n,o;const i={};for(let s=0;s<r;s++){n=e[s];let a;if(o=n,!I0(n)&&(o=Al[(a=String(n)).toLowerCase()],o===void 0))throw new Ke(`Unknown adapter '${a}'`);if(o&&(Y.isFunction(o)||(o=o.get(t))))break;i[a||"#"+s]=o}if(!o){const s=Object.entries(i).map(([c,u])=>`adapter ${c} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=r?s.length>1?`since :
|
|
4
|
-
`+s.map(
|
|
5
|
-
`):" "+
|
|
6
|
-
`+i):n.stack=i}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=Xn(this.defaults,r);const{transitional:n,paramsSerializer:o,headers:i}=r;n!==void 0&&ws.assertOptions(n,{silentJSONParsing:Ir.transitional(Ir.boolean),forcedJSONParsing:Ir.transitional(Ir.boolean),clarifyTimeoutError:Ir.transitional(Ir.boolean),legacyInterceptorReqResOrdering:Ir.transitional(Ir.boolean)},!1),o!=null&&(Y.isFunction(o)?r.paramsSerializer={serialize:o}:ws.assertOptions(o,{encode:Ir.function,serialize:Ir.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),ws.assertOptions(r,{baseUrl:Ir.spelling("baseURL"),withXsrfToken:Ir.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s=i&&Y.merge(i.common,i[r.method]);i&&Y.forEach(["delete","get","head","post","put","patch","common"],m=>{delete i[m]}),r.headers=hr.concat(s,i);const a=[];let c=!0;this.interceptors.request.forEach(function(h){if(typeof h.runWhen=="function"&&h.runWhen(r)===!1)return;c=c&&h.synchronous;const y=r.transitional||bl;y&&y.legacyInterceptorReqResOrdering?a.unshift(h.fulfilled,h.rejected):a.push(h.fulfilled,h.rejected)});const u=[];this.interceptors.response.forEach(function(h){u.push(h.fulfilled,h.rejected)});let f,l=0,p;if(!c){const m=[Df.bind(this),void 0];for(m.unshift(...a),m.push(...u),p=m.length,f=Promise.resolve(r);l<p;)f=f.then(m[l++],m[l++]);return f}p=a.length;let g=r;for(;l<p;){const m=a[l++],h=a[l++];try{g=m(g)}catch(y){h.call(this,y);break}}try{f=Df.call(this,g)}catch(m){return Promise.reject(m)}for(l=0,p=u.length;l<p;)f=f.then(u[l++],u[l++]);return f}getUri(t){t=Xn(this.defaults,t);const r=Ef(t.baseURL,t.url,t.allowAbsoluteUrls);return yf(r,t.params,t.paramsSerializer)}};Y.forEach(["delete","get","head","options"],function(t){Jn.prototype[t]=function(r,n){return this.request(Xn(n||{},{method:t,url:r,data:(n||{}).data}))}}),Y.forEach(["post","put","patch"],function(t){function r(n){return function(i,s,a){return this.request(Xn(a||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:s}))}}Jn.prototype[t]=r(),Jn.prototype[t+"Form"]=r(!0)});let D0=class rv{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});const n=this;this.promise.then(o=>{if(!n._listeners)return;let i=n._listeners.length;for(;i-- >0;)n._listeners[i](o);n._listeners=null}),this.promise.then=o=>{let i;const s=new Promise(a=>{n.subscribe(a),i=a}).then(o);return s.cancel=function(){n.unsubscribe(i)},s},t(function(i,s,a){n.reason||(n.reason=new ui(i,s,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new rv(function(o){t=o}),cancel:t}}};function B0(e){return function(r){return e.apply(null,r)}}function $0(e){return Y.isObject(e)&&e.isAxiosError===!0}const El={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(El).forEach(([e,t])=>{El[t]=e});function jf(e){const t=new Jn(e),r=rf(Jn.prototype.request,t);return Y.extend(r,Jn.prototype,t,{allOwnKeys:!0}),Y.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return jf(Xn(e,o))},r}const Ct=jf(ci);Ct.Axios=Jn,Ct.CanceledError=ui,Ct.CancelToken=D0,Ct.isCancel=Sf,Ct.VERSION=Bf,Ct.toFormData=hs,Ct.AxiosError=Ke,Ct.Cancel=Ct.CanceledError,Ct.all=function(t){return Promise.all(t)},Ct.spread=B0,Ct.isAxiosError=$0,Ct.mergeConfig=Xn,Ct.AxiosHeaders=hr,Ct.formToJSON=e=>vf(Y.isHTMLForm(e)?new FormData(e):e),Ct.getAdapter=Lf.getAdapter,Ct.HttpStatusCode=El,Ct.default=Ct;const{Axios:vM,AxiosError:j0,CanceledError:wM,isCancel:SM,CancelToken:xM,VERSION:AM,all:CM,Cancel:EM,isAxiosError:NM,spread:kM,toFormData:_M,AxiosHeaders:TM,HttpStatusCode:FM,formToJSON:PM,getAdapter:OM,mergeConfig:IM}=Ct;let zf=null;function z0(e){zf=e}function Uf(){return(zf?.()??"").replace(/\/+$/,"")}function Mr(e){const t=typeof e=="string"?e.trim():"";if(!t||/^https?:\/\//i.test(t))return t;const r=Uf();return r?t.startsWith("/")?`${r}${t}`:`${r}/${t}`:t}const Vf={};function nn(){const e=Vf?.VITE_CLIENT_ID?.trim()||Vf?.VITE_DEFAULT_CLIENT_ID?.trim()||null;return(typeof localStorage<"u"?localStorage.getItem("clientId"):null)||(typeof sessionStorage<"u"?sessionStorage.getItem("clientId"):null)||(typeof window<"u"?new URLSearchParams(window.location.search).get("clientId"):null)||e}function U0(e){return!e||typeof e!="object"?!1:e.userId!=null&&String(e.userId)!==""||e.userType!=null&&String(e.userType)!==""||e.role!=null&&String(e.role)!==""}function V0(e){if(!e||typeof e!="object")return;const t={};for(const[r,n]of Object.entries(e))n!==void 0&&n!==""&&(t[r]=n);return Object.keys(t).length>0?t:void 0}const Qn=gu(e=>({viewerContext:void 0,authHeaders:void 0,_setViewerContext:t=>e({viewerContext:U0(t)?t:void 0}),_setAuthHeaders:t=>e({authHeaders:V0(t)}),_reset:()=>e({viewerContext:void 0,authHeaders:void 0})}));function H0(e){Qn.getState()._setViewerContext(e)}function W0(e){Qn.getState()._setAuthHeaders(e)}function R0(){Qn.getState()._reset()}function Hf(){return Qn.getState().viewerContext}function fi(){return Qn.getState().authHeaders}const Wf={};let Rf=null;function K0(e){Rf=e}function G0(){return(Wf?.VITE_API_BASE_URL?.trim()||Wf?.VITE_API_URL?.trim()||"").replace(/\/$/,"")}const Jt=Ct.create({baseURL:G0()});Jt.interceptors.request.use(e=>{const t=nn();t&&(e.params={...e.params,clientId:t}),typeof FormData<"u"&&e.data instanceof FormData&&delete e.headers["Content-Type"];let r=Rf?.();if((!r||Object.keys(r).length===0)&&(r=fi()),r){const n=e.headers??{};for(const[o,i]of Object.entries(r))i!==void 0&&i!==""&&(n[o]=i);e.headers=n}return e});const q0=/^\{([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\}$/i;function Kf(e){const t=e.trim().match(q0);return t?t[1]:e}const Y0={applicantId:["id","applicant_id"],applicant_id:["id","applicantId"],id:["applicantId","applicant_id"]};function Rr(e,t,r,n,o,i){let s=e;if(o&&typeof e=="string"&&(s=s.replace(/\{resp:([^}]+)\}/g,(a,c)=>{const u=c.trim().split(".");if(u.length<2)return a;const f=u[0],l=u.slice(1).join("."),p=o[f];if(p==null)return a;const g=We(p,l);return g==null?a:String(g)}),s.includes("{documentId}")||s.includes("%7BdocumentId%7D"))){let a;for(const c of Object.values(o)){const u=We(c,"data.id")??We(c,"data.documentId");if(u!=null){a=String(u);break}}a&&(s=s.replace(/\{documentId\}/g,a).replace(/%7BdocumentId%7D/gi,a))}if(s.includes("{documentId}")||s.includes("%7BdocumentId%7D")){let a;const c=t?.documentId??(t&&We(t,"documentId")),u=n?.documentId??(n&&We(n,"documentId"));c!=null&&c!==""?a=String(c):u!=null&&u!==""&&(a=String(u)),a&&(s=s.replace(/\{documentId\}/g,a).replace(/%7BdocumentId%7D/gi,a))}return s=s.replace(/\{api:([^}]+)\}/g,(a,c)=>{const u=c.trim();if(i==null||u==="")return a;const f=We(i,u);return f==null?a:String(f)}),s=s.replace(/\{(?:ctx:|\@)(\w+)\}/g,(a,c)=>n&&n[c]!==void 0&&n[c]!==null?String(n[c]):a),s=s.replace(/\{(\w+)\}/g,(a,c)=>{if(a.includes("ctx:")||a.includes("@"))return a;const u=r[c];if(u!=null)return Kf(String(u));let f=t[c];if(f==null||f===""){const l=Object.keys(t).find(p=>p.toLowerCase()===c.toLowerCase());l&&(f=t[l])}if((f==null||f==="")&&(f=n?.[c]),f==null||f===""){const l=Y0[c];if(l)for(const p of l){const g=t[p]??n?.[p];if(g!=null&&g!==""){f=g;break}}}return f!=null&&f!==""?Kf(String(f)):a}),s}const X0=60,J0=3,Q0="Resend OTP in {seconds} sec · Attempts remaining: {attempts}",Z0="Resend OTP";function ex(e){const t=e.properties?.resend;return!t?.enabled||!t.resendApiEndpoint?.trim()?null:t}function Gf(e){const t=Number(e.cooldownSeconds);return!Number.isFinite(t)||t<0?X0:Math.round(t)}function qf(e){const t=Number(e.maxAttempts);return!Number.isFinite(t)||t<1?J0:Math.round(t)}function Yf(e,t,r){if(!t?.trim()||e==null)return r;const n=We(e,t.trim()),o=typeof n=="number"?n:Number(n);return!Number.isFinite(o)||o<0?r:Math.round(o)}function Xf(e,t,r){if(!t?.trim()||e==null)return r;const n=We(e,t.trim()),o=typeof n=="number"?n:Number(n);return!Number.isFinite(o)||o<0?r:Math.round(o)}function tx(e,t){const r=qf(e),n=Gf(e),o=e.initialAttemptsPath??"data.attempts_remaining",i=e.initialCooldownPath??"data.resend_cooldown_seconds";return{attemptsRemaining:Yf(t,o,r),secondsRemaining:Xf(t,i,n)}}function rx(e,t,r){qf(e);const n=Gf(e),o=e.attemptsResponsePath??"data.attempts_remaining",i=e.cooldownResponsePath??"data.resend_cooldown_seconds";return{attemptsRemaining:Yf(t,o,r),secondsRemaining:Xf(t,i,n)}}function nx(e,t,r,n){const o=e.resendLinkText?.trim()||Z0,i=!n&&t<=0&&r>0;return{seconds:Math.max(0,t),attempts:Math.max(0,r),resendText:o,resendEnabled:i}}function ox(e,t){const r=e.statusTemplate?.trim()||Q0,n=t.seconds>0?` in ${t.seconds} sec`:"",o=t.resendEnabled?t.resendText:t.seconds>0?`${t.resendText}${n}`:t.resendText;return r.replace(/\{seconds\}/g,String(t.seconds)).replace(/\{attempts\}/g,String(t.attempts)).replace(/\{resend\}/g,o)}async function ix(e,t={}){const r=e.resendApiEndpoint?.trim();if(!r)throw new Error("Resend API endpoint is not configured");const{formValues:n={},urlParams:o={},submissionContext:i,prepopulateResponse:s}=t,a=m=>Rr(m,n,o,i,void 0,s),c=(e.resendApiMethod??"POST").toUpperCase();let u=Mr(a(r));const f=e.resendApiQueryParams??[];if(f.length){const m=new URLSearchParams;f.forEach(({key:y,value:S})=>{y.trim()&&m.append(y,a(S))});const h=m.toString();h&&(u=`${u}${u.includes("?")?"&":"?"}${h}`)}const l={};let p=!1;(e.resendApiHeaders??[]).forEach(({key:m,value:h})=>{m.trim()&&(l[m]=a(h))});let g;c!=="GET"&&(e.resendApiBodyFields??[]).length&&(g={},e.resendApiBodyFields.forEach(({key:m,value:h})=>{m.trim()&&(g[m]=a(h))}),p=!0),p&&!l["Content-Type"]&&!l["content-type"]&&(l["Content-Type"]="application/json");try{return c==="GET"?(await Jt.get(u,{headers:Object.keys(l).length?l:void 0})).data:(await Jt.request({url:u,method:c,data:g??{},headers:Object.keys(l).length?l:void 0})).data}catch(m){const h=m,y=h.response?.status,S=typeof h.response?.data=="string"?h.response.data:h.message??"Request failed";throw new Error(y?`HTTP ${y}: ${S}`:String(S))}}function Kr(e){if(e instanceof Error){const t=e.message;if(t&&(t.includes("{")||t.includes("[")))try{const r=t.match(/\{[\s\S]*\}/);if(r){const n=JSON.parse(r[0]);return yo(n)}}catch{}if(e.response){const r=e.response;if(typeof r=="string")try{const n=JSON.parse(r);return yo(n)}catch{return r}else if(typeof r=="object")return yo(r)}return t}if(e instanceof j0)return e.response?.data?yo(e.response.data):e.message||"An unexpected error occurred";if(typeof e=="string")try{const t=JSON.parse(e);return yo(t)}catch{return e}return typeof e=="object"&&e!==null?yo(e):"An unexpected error occurred"}function yo(e){if(e?.display_message&&typeof e.display_message=="string")return e.display_message.trim();if(e?.errors&&Array.isArray(e.errors)){const t=e.errors.filter(r=>r&&typeof r=="string");if(t.length>0)return t.join(". ")}if(e?.error?.explanation&&Array.isArray(e.error.explanation)){const t=e.error.explanation.filter(r=>r&&typeof r=="string");if(t.length>0)return t.join(". ")}if(e?.explanation&&Array.isArray(e.explanation)){const t=e.explanation.filter(r=>r&&typeof r=="string");if(t.length>0)return t.join(". ")}if(e?.errors&&Array.isArray(e.errors)){const t=e.errors.filter(r=>r!=null&&String(r).trim());if(t.length>0)return t.map(r=>typeof r=="string"?r:r?.message||String(r)).join(". ")}return e?.message&&typeof e.message=="string"?e.message:e?.display_message&&typeof e.display_message=="string"?e.display_message:e?.error?.display_message&&typeof e.error.display_message=="string"?e.error.display_message:e?.error?.message&&typeof e.error.message=="string"?e.error.message:e?.error&&typeof e.error=="string"?e.error:"An unexpected error occurred"}const Jf=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:c,formValues:u={},urlParams:f={},submissionContext:l,prepopulateResponse:p})=>{const g=vu(e),m=e.properties?.numericOnly!==!1,h=ex(e),y=w.useRef([]),S=w.useMemo(()=>mw(t,g),[t,g]),v=w.useMemo(()=>h?tx(h,p):null,[h,p]),[A,x]=w.useState(()=>v?.secondsRemaining??0),[F,N]=w.useState(()=>v?.attemptsRemaining??0),[k,T]=w.useState(!1);w.useEffect(()=>{y.current=y.current.slice(0,g)},[g]),w.useEffect(()=>{v&&(x(v.secondsRemaining),N(v.attemptsRemaining))},[v]),w.useEffect(()=>{if(!h||A<=0)return;const D=window.setInterval(()=>{x(K=>K<=1?0:K-1)},1e3);return()=>window.clearInterval(D)},[h,A>0]);const P=w.useMemo(()=>h?nx(h,A,F,k):null,[h,A,F,k]),E=w.useMemo(()=>!h||!P?"":ox(h,P),[h,P]),C=w.useCallback(async()=>{if(!(!h||!P?.resendEnabled||k)){T(!0);try{const D=await ix(h,{formValues:u,urlParams:f,submissionContext:l,prepopulateResponse:p}),K=rx(h,D,F);N(K.attemptsRemaining),x(K.secondsRemaining),r(""),at.toast.success("OTP sent successfully.")}catch(D){at.toast.error(Kr(D))}finally{T(!1)}}},[h,P?.resendEnabled,k,u,f,l,p,F,r]),I=w.useCallback(D=>{r(hw(D))},[r]),W=w.useCallback(D=>{const K=y.current[D];K&&(K.focus(),K.select())},[]),M=w.useCallback((D,K=0)=>{const ae=m?D.replace(/\D/g,""):D.replace(/\s/g,"");if(!ae)return;const j=[...S];let z=K;for(let ie=0;ie<ae.length&&z<g;ie+=1)j[z]=ae[ie]??"",z+=1;I(j);const le=Math.min(z,g-1);requestAnimationFrame(()=>W(le))},[S,I,W,m,g]),U=w.useCallback((D,K)=>{if(s||i||e.readOnly||e.disabled)return;const ae=m?K.replace(/\D/g,""):K.slice(-1),j=[...S];j[D]=ae,I(j),ae&&D<g-1&&requestAnimationFrame(()=>W(D+1))},[S,i,I,e.disabled,e.readOnly,W,m,g,s]),V=w.useCallback((D,K)=>{if(K.key==="Backspace"&&!S[D]&&D>0){K.preventDefault();const ae=[...S];ae[D-1]="",I(ae),W(D-1);return}if(K.key==="ArrowLeft"&&D>0){K.preventDefault(),W(D-1);return}K.key==="ArrowRight"&&D<g-1&&(K.preventDefault(),W(D+1))},[S,I,W,g]),X=w.useCallback((D,K)=>{K.preventDefault();const ae=K.clipboardData.getData("text");M(ae,D)},[M]),B=ft(e),L=h?.resendLinkText?.trim()||"Resend OTP";return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"space-y-2",children:[d.jsx("div",{className:"flex flex-wrap items-center gap-2",role:"group","aria-labelledby":`${B}-label`,"aria-describedby":Lt(e,!!o),children:S.map((D,K)=>d.jsx(mn,{ref:ae=>{y.current[K]=ae},id:K===0?B:`${B}-${K}`,type:m?"tel":"text",inputMode:m?"numeric":"text",autoComplete:K===0?"one-time-code":"off",maxLength:1,value:D,onChange:ae=>U(K,ae.target.value),onKeyDown:ae=>V(K,ae),onPaste:ae=>X(K,ae),onBlur:K===g-1?n:void 0,disabled:i||e.disabled,readOnly:s||e.readOnly,"aria-label":`${e.label||e.name} digit ${K+1} of ${g}`,"aria-invalid":Xt(!!o),"aria-required":a,className:H(uo(e.appearance),"h-10 w-10 text-center text-base font-medium p-0",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)},`${e.id}-otp-${K}`))}),h&&P&&d.jsx("p",{className:"text-sm text-muted-foreground","aria-live":"polite",children:P.resendEnabled?d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:"text-primary underline-offset-4 hover:underline disabled:opacity-50",disabled:i||k,onClick:C,children:k?"Sending…":L}),d.jsx("span",{children:` · Attempts remaining: ${F}`})]}):d.jsx("span",{children:F<=0&&A<=0?"No attempts remaining.":E})})]})})};function sx({className:e,maxLength:t,showCharacterCount:r=!1,autoResize:n=!1,onChange:o,value:i,...s}){const a=b.useRef(null),[c,u]=b.useState(0),f=l=>{const p=l.target.value;u(p.length),n&&a.current&&(a.current.style.height="auto",a.current.style.height=`${a.current.scrollHeight}px`),o&&o(l)};return b.useEffect(()=>{i&&u(String(i).length)},[i]),d.jsxs("div",{className:"space-y-1",children:[d.jsx("textarea",{ref:a,"data-slot":"textarea",className:H("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",n&&"resize-none",e),maxLength:t,onChange:f,value:i,...s}),r&&d.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[d.jsxs("span",{children:[c," characters"]}),t&&d.jsxs("span",{children:[t-c," remaining"]})]})]})}const Qf=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:c})=>{const{gridStretch:u}=Zo(),f=u&&Qi(e),l=e.properties,p=w.useCallback(y=>{r(y.target.value)},[r]),g=(t||"").length,m=l?.maxLength,h=m&&m>0;return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:H("relative flex flex-col",f&&"flex-1 min-h-0"),children:[d.jsx(sx,{id:ft(e),value:t||"",onChange:p,onBlur:n,placeholder:e.placeholder,disabled:i||e.disabled,readOnly:s||e.readOnly,minLength:l?.minLength,maxLength:l?.maxLength,rows:2,"aria-describedby":Lt(e,!!o),"aria-invalid":Xt(!!o),"aria-required":a,className:H(ou(e.appearance),"resize-y",f&&"min-h-[120px] flex-1 flex-shrink-0",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)}),h&&d.jsxs("span",{className:"absolute bottom-2 right-2 text-xs text-muted-foreground",children:[g,"/",m]})]})})};function pi(e,[t,r]){return Math.min(r,Math.max(t,e))}function Ie(e,t,{checkForDefaultPrevented:r=!0}={}){return function(o){if(e?.(o),r===!1||!o.defaultPrevented)return t?.(o)}}function ax(e,t){const r=b.createContext(t),n=i=>{const{children:s,...a}=i,c=b.useMemo(()=>a,Object.values(a));return d.jsx(r.Provider,{value:c,children:s})};n.displayName=e+"Provider";function o(i){const s=b.useContext(r);if(s)return s;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[n,o]}function Sr(e,t=[]){let r=[];function n(i,s){const a=b.createContext(s),c=r.length;r=[...r,s];const u=l=>{const{scope:p,children:g,...m}=l,h=p?.[e]?.[c]||a,y=b.useMemo(()=>m,Object.values(m));return d.jsx(h.Provider,{value:y,children:g})};u.displayName=i+"Provider";function f(l,p){const g=p?.[e]?.[c]||a,m=b.useContext(g);if(m)return m;if(s!==void 0)return s;throw new Error(`\`${l}\` must be used within \`${i}\``)}return[u,f]}const o=()=>{const i=r.map(s=>b.createContext(s));return function(a){const c=a?.[e]||i;return b.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[n,lx(o,...t)]}function lx(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const n=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const s=n.reduce((a,{useScope:c,scopeName:u})=>{const l=c(i)[`__scope${u}`];return{...a,...l}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return r.scopeName=t.scopeName,r}function Zf(e){const t=cx(e),r=b.forwardRef((n,o)=>{const{children:i,...s}=n,a=b.Children.toArray(i),c=a.find(ux);if(c){const u=c.props.children,f=a.map(l=>l===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:l);return d.jsx(t,{...s,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,f):null})}return d.jsx(t,{...s,ref:o,children:i})});return r.displayName=`${e}.Slot`,r}function cx(e){const t=b.forwardRef((r,n)=>{const{children:o,...i}=r;if(b.isValidElement(o)){const s=px(o),a=fx(i,o.props);return o.type!==b.Fragment&&(a.ref=n?qn(n,s):s),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var dx=Symbol("radix.slottable");function ux(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===dx}function fx(e,t){const r={...t};for(const n in t){const o=e[n],i=t[n];/^on[A-Z]/.test(n)?o&&i?r[n]=(...a)=>{const c=i(...a);return o(...a),c}:o&&(r[n]=o):n==="style"?r[n]={...o,...i}:n==="className"&&(r[n]=[o,i].filter(Boolean).join(" "))}return{...e,...r}}function px(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function Nl(e){const t=e+"CollectionProvider",[r,n]=Sr(t),[o,i]=r(t,{collectionRef:{current:null},itemMap:new Map}),s=h=>{const{scope:y,children:S}=h,v=w.useRef(null),A=w.useRef(new Map).current;return d.jsx(o,{scope:y,itemMap:A,collectionRef:v,children:S})};s.displayName=t;const a=e+"CollectionSlot",c=Zf(a),u=w.forwardRef((h,y)=>{const{scope:S,children:v}=h,A=i(a,S),x=qe(y,A.collectionRef);return d.jsx(c,{ref:x,children:v})});u.displayName=a;const f=e+"CollectionItemSlot",l="data-radix-collection-item",p=Zf(f),g=w.forwardRef((h,y)=>{const{scope:S,children:v,...A}=h,x=w.useRef(null),F=qe(y,x),N=i(f,S);return w.useEffect(()=>(N.itemMap.set(x,{ref:x,...A}),()=>{N.itemMap.delete(x)})),d.jsx(p,{[l]:"",ref:F,children:v})});g.displayName=f;function m(h){const y=i(e+"CollectionConsumer",h);return w.useCallback(()=>{const v=y.collectionRef.current;if(!v)return[];const A=Array.from(v.querySelectorAll(`[${l}]`));return Array.from(y.itemMap.values()).sort((N,k)=>A.indexOf(N.ref.current)-A.indexOf(k.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:s,Slot:u,ItemSlot:g},m,n]}var mx=b.createContext(void 0);function bo(e){const t=b.useContext(mx);return e||t||"ltr"}function hx(e){const t=gx(e),r=b.forwardRef((n,o)=>{const{children:i,...s}=n,a=b.Children.toArray(i),c=a.find(bx);if(c){const u=c.props.children,f=a.map(l=>l===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:l);return d.jsx(t,{...s,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,f):null})}return d.jsx(t,{...s,ref:o,children:i})});return r.displayName=`${e}.Slot`,r}function gx(e){const t=b.forwardRef((r,n)=>{const{children:o,...i}=r;if(b.isValidElement(o)){const s=wx(o),a=vx(i,o.props);return o.type!==b.Fragment&&(a.ref=n?qn(n,s):s),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var yx=Symbol("radix.slottable");function bx(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===yx}function vx(e,t){const r={...t};for(const n in t){const o=e[n],i=t[n];/^on[A-Z]/.test(n)?o&&i?r[n]=(...a)=>{const c=i(...a);return o(...a),c}:o&&(r[n]=o):n==="style"?r[n]={...o,...i}:n==="className"&&(r[n]=[o,i].filter(Boolean).join(" "))}return{...e,...r}}function wx(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var Sx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],$e=Sx.reduce((e,t)=>{const r=hx(`Primitive.${t}`),n=b.forwardRef((o,i)=>{const{asChild:s,...a}=o,c=s?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(c,{...a,ref:i})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function xx(e,t){e&&Wi.flushSync(()=>e.dispatchEvent(t))}function dr(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),b.useMemo(()=>(...r)=>t.current?.(...r),[])}function Ax(e,t=globalThis?.document){const r=dr(e);b.useEffect(()=>{const n=o=>{o.key==="Escape"&&r(o)};return t.addEventListener("keydown",n,{capture:!0}),()=>t.removeEventListener("keydown",n,{capture:!0})},[r,t])}var Cx="DismissableLayer",kl="dismissableLayer.update",Ex="dismissableLayer.pointerDownOutside",Nx="dismissableLayer.focusOutside",ep,tp=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ss=b.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:s,onDismiss:a,...c}=e,u=b.useContext(tp),[f,l]=b.useState(null),p=f?.ownerDocument??globalThis?.document,[,g]=b.useState({}),m=qe(t,k=>l(k)),h=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),S=h.indexOf(y),v=f?h.indexOf(f):-1,A=u.layersWithOutsidePointerEventsDisabled.size>0,x=v>=S,F=Tx(k=>{const T=k.target,P=[...u.branches].some(E=>E.contains(T));!x||P||(o?.(k),s?.(k),k.defaultPrevented||a?.())},p),N=Fx(k=>{const T=k.target;[...u.branches].some(E=>E.contains(T))||(i?.(k),s?.(k),k.defaultPrevented||a?.())},p);return Ax(k=>{v===u.layers.size-1&&(n?.(k),!k.defaultPrevented&&a&&(k.preventDefault(),a()))},p),b.useEffect(()=>{if(f)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(ep=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(f)),u.layers.add(f),rp(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=ep)}},[f,p,r,u]),b.useEffect(()=>()=>{f&&(u.layers.delete(f),u.layersWithOutsidePointerEventsDisabled.delete(f),rp())},[f,u]),b.useEffect(()=>{const k=()=>g({});return document.addEventListener(kl,k),()=>document.removeEventListener(kl,k)},[]),d.jsx($e.div,{...c,ref:m,style:{pointerEvents:A?x?"auto":"none":void 0,...e.style},onFocusCapture:Ie(e.onFocusCapture,N.onFocusCapture),onBlurCapture:Ie(e.onBlurCapture,N.onBlurCapture),onPointerDownCapture:Ie(e.onPointerDownCapture,F.onPointerDownCapture)})});Ss.displayName=Cx;var kx="DismissableLayerBranch",_x=b.forwardRef((e,t)=>{const r=b.useContext(tp),n=b.useRef(null),o=qe(t,n);return b.useEffect(()=>{const i=n.current;if(i)return r.branches.add(i),()=>{r.branches.delete(i)}},[r.branches]),d.jsx($e.div,{...e,ref:o})});_x.displayName=kx;function Tx(e,t=globalThis?.document){const r=dr(e),n=b.useRef(!1),o=b.useRef(()=>{});return b.useEffect(()=>{const i=a=>{if(a.target&&!n.current){let c=function(){np(Ex,r,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}else t.removeEventListener("click",o.current);n.current=!1},s=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(s),t.removeEventListener("pointerdown",i),t.removeEventListener("click",o.current)}},[t,r]),{onPointerDownCapture:()=>n.current=!0}}function Fx(e,t=globalThis?.document){const r=dr(e),n=b.useRef(!1);return b.useEffect(()=>{const o=i=>{i.target&&!n.current&&np(Nx,r,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,r]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function rp(){const e=new CustomEvent(kl);document.dispatchEvent(e)}function np(e,t,r,{discrete:n}){const o=r.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&o.addEventListener(e,t,{once:!0}),n?xx(o,i):o.dispatchEvent(i)}var _l=0;function Tl(){b.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??op()),document.body.insertAdjacentElement("beforeend",e[1]??op()),_l++,()=>{_l===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),_l--}},[])}function op(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Fl="focusScope.autoFocusOnMount",Pl="focusScope.autoFocusOnUnmount",ip={bubbles:!1,cancelable:!0},Px="FocusScope",xs=b.forwardRef((e,t)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...s}=e,[a,c]=b.useState(null),u=dr(o),f=dr(i),l=b.useRef(null),p=qe(t,h=>c(h)),g=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(n){let h=function(A){if(g.paused||!a)return;const x=A.target;a.contains(x)?l.current=x:In(l.current,{select:!0})},y=function(A){if(g.paused||!a)return;const x=A.relatedTarget;x!==null&&(a.contains(x)||In(l.current,{select:!0}))},S=function(A){if(document.activeElement===document.body)for(const F of A)F.removedNodes.length>0&&In(a)};document.addEventListener("focusin",h),document.addEventListener("focusout",y);const v=new MutationObserver(S);return a&&v.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",h),document.removeEventListener("focusout",y),v.disconnect()}}},[n,a,g.paused]),b.useEffect(()=>{if(a){lp.add(g);const h=document.activeElement;if(!a.contains(h)){const S=new CustomEvent(Fl,ip);a.addEventListener(Fl,u),a.dispatchEvent(S),S.defaultPrevented||(Ox(Bx(sp(a)),{select:!0}),document.activeElement===h&&In(a))}return()=>{a.removeEventListener(Fl,u),setTimeout(()=>{const S=new CustomEvent(Pl,ip);a.addEventListener(Pl,f),a.dispatchEvent(S),S.defaultPrevented||In(h??document.body,{select:!0}),a.removeEventListener(Pl,f),lp.remove(g)},0)}}},[a,u,f,g]);const m=b.useCallback(h=>{if(!r&&!n||g.paused)return;const y=h.key==="Tab"&&!h.altKey&&!h.ctrlKey&&!h.metaKey,S=document.activeElement;if(y&&S){const v=h.currentTarget,[A,x]=Ix(v);A&&x?!h.shiftKey&&S===x?(h.preventDefault(),r&&In(A,{select:!0})):h.shiftKey&&S===A&&(h.preventDefault(),r&&In(x,{select:!0})):S===v&&h.preventDefault()}},[r,n,g.paused]);return d.jsx($e.div,{tabIndex:-1,...s,ref:p,onKeyDown:m})});xs.displayName=Px;function Ox(e,{select:t=!1}={}){const r=document.activeElement;for(const n of e)if(In(n,{select:t}),document.activeElement!==r)return}function Ix(e){const t=sp(e),r=ap(t,e),n=ap(t.reverse(),e);return[r,n]}function sp(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const o=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||o?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function ap(e,t){for(const r of e)if(!Mx(r,{upTo:t}))return r}function Mx(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Lx(e){return e instanceof HTMLInputElement&&"select"in e}function In(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&Lx(e)&&t&&e.select()}}var lp=Dx();function Dx(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=cp(e,t),e.unshift(t)},remove(t){e=cp(e,t),e[0]?.resume()}}}function cp(e,t){const r=[...e],n=r.indexOf(t);return n!==-1&&r.splice(n,1),r}function Bx(e){return e.filter(t=>t.tagName!=="A")}var tr=globalThis?.document?b.useLayoutEffect:()=>{},$x=b[" useId ".trim().toString()]||(()=>{}),jx=0;function hn(e){const[t,r]=b.useState($x());return tr(()=>{r(n=>n??String(jx++))},[e]),e||(t?`radix-${t}`:"")}const zx=["top","right","bottom","left"],Mn=Math.min,xr=Math.max,As=Math.round,Cs=Math.floor,on=e=>({x:e,y:e}),Ux={left:"right",right:"left",bottom:"top",top:"bottom"};function Ol(e,t,r){return xr(e,Mn(t,r))}function gn(e,t){return typeof e=="function"?e(t):e}function yn(e){return e.split("-")[0]}function vo(e){return e.split("-")[1]}function Il(e){return e==="x"?"y":"x"}function Ml(e){return e==="y"?"height":"width"}function sn(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Ll(e){return Il(sn(e))}function Vx(e,t,r){r===void 0&&(r=!1);const n=vo(e),o=Ll(e),i=Ml(o);let s=o==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(s=Es(s)),[s,Es(s)]}function Hx(e){const t=Es(e);return[Dl(e),t,Dl(t)]}function Dl(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const dp=["left","right"],up=["right","left"],Wx=["top","bottom"],Rx=["bottom","top"];function Kx(e,t,r){switch(e){case"top":case"bottom":return r?t?up:dp:t?dp:up;case"left":case"right":return t?Wx:Rx;default:return[]}}function Gx(e,t,r,n){const o=vo(e);let i=Kx(yn(e),r==="start",n);return o&&(i=i.map(s=>s+"-"+o),t&&(i=i.concat(i.map(Dl)))),i}function Es(e){const t=yn(e);return Ux[t]+e.slice(t.length)}function qx(e){return{top:0,right:0,bottom:0,left:0,...e}}function fp(e){return typeof e!="number"?qx(e):{top:e,right:e,bottom:e,left:e}}function Ns(e){const{x:t,y:r,width:n,height:o}=e;return{width:n,height:o,top:r,left:t,right:t+n,bottom:r+o,x:t,y:r}}function pp(e,t,r){let{reference:n,floating:o}=e;const i=sn(t),s=Ll(t),a=Ml(s),c=yn(t),u=i==="y",f=n.x+n.width/2-o.width/2,l=n.y+n.height/2-o.height/2,p=n[a]/2-o[a]/2;let g;switch(c){case"top":g={x:f,y:n.y-o.height};break;case"bottom":g={x:f,y:n.y+n.height};break;case"right":g={x:n.x+n.width,y:l};break;case"left":g={x:n.x-o.width,y:l};break;default:g={x:n.x,y:n.y}}switch(vo(t)){case"start":g[s]-=p*(r&&u?-1:1);break;case"end":g[s]+=p*(r&&u?-1:1);break}return g}async function Yx(e,t){var r;t===void 0&&(t={});const{x:n,y:o,platform:i,rects:s,elements:a,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:f="viewport",elementContext:l="floating",altBoundary:p=!1,padding:g=0}=gn(t,e),m=fp(g),y=a[p?l==="floating"?"reference":"floating":l],S=Ns(await i.getClippingRect({element:(r=await(i.isElement==null?void 0:i.isElement(y)))==null||r?y:y.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:u,rootBoundary:f,strategy:c})),v=l==="floating"?{x:n,y:o,width:s.floating.width,height:s.floating.height}:s.reference,A=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),x=await(i.isElement==null?void 0:i.isElement(A))?await(i.getScale==null?void 0:i.getScale(A))||{x:1,y:1}:{x:1,y:1},F=Ns(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:A,strategy:c}):v);return{top:(S.top-F.top+m.top)/x.y,bottom:(F.bottom-S.bottom+m.bottom)/x.y,left:(S.left-F.left+m.left)/x.x,right:(F.right-S.right+m.right)/x.x}}const Xx=50,Jx=async(e,t,r)=>{const{placement:n="bottom",strategy:o="absolute",middleware:i=[],platform:s}=r,a=s.detectOverflow?s:{...s,detectOverflow:Yx},c=await(s.isRTL==null?void 0:s.isRTL(t));let u=await s.getElementRects({reference:e,floating:t,strategy:o}),{x:f,y:l}=pp(u,n,c),p=n,g=0;const m={};for(let h=0;h<i.length;h++){const y=i[h];if(!y)continue;const{name:S,fn:v}=y,{x:A,y:x,data:F,reset:N}=await v({x:f,y:l,initialPlacement:n,placement:p,strategy:o,middlewareData:m,rects:u,platform:a,elements:{reference:e,floating:t}});f=A??f,l=x??l,m[S]={...m[S],...F},N&&g<Xx&&(g++,typeof N=="object"&&(N.placement&&(p=N.placement),N.rects&&(u=N.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:o}):N.rects),{x:f,y:l}=pp(u,p,c)),h=-1)}return{x:f,y:l,placement:p,strategy:o,middlewareData:m}},Qx=e=>({name:"arrow",options:e,async fn(t){const{x:r,y:n,placement:o,rects:i,platform:s,elements:a,middlewareData:c}=t,{element:u,padding:f=0}=gn(e,t)||{};if(u==null)return{};const l=fp(f),p={x:r,y:n},g=Ll(o),m=Ml(g),h=await s.getDimensions(u),y=g==="y",S=y?"top":"left",v=y?"bottom":"right",A=y?"clientHeight":"clientWidth",x=i.reference[m]+i.reference[g]-p[g]-i.floating[m],F=p[g]-i.reference[g],N=await(s.getOffsetParent==null?void 0:s.getOffsetParent(u));let k=N?N[A]:0;(!k||!await(s.isElement==null?void 0:s.isElement(N)))&&(k=a.floating[A]||i.floating[m]);const T=x/2-F/2,P=k/2-h[m]/2-1,E=Mn(l[S],P),C=Mn(l[v],P),I=E,W=k-h[m]-C,M=k/2-h[m]/2+T,U=Ol(I,M,W),V=!c.arrow&&vo(o)!=null&&M!==U&&i.reference[m]/2-(M<I?E:C)-h[m]/2<0,X=V?M<I?M-I:M-W:0;return{[g]:p[g]+X,data:{[g]:U,centerOffset:M-U-X,...V&&{alignmentOffset:X}},reset:V}}}),Zx=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var r,n;const{placement:o,middlewareData:i,rects:s,initialPlacement:a,platform:c,elements:u}=t,{mainAxis:f=!0,crossAxis:l=!0,fallbackPlacements:p,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:h=!0,...y}=gn(e,t);if((r=i.arrow)!=null&&r.alignmentOffset)return{};const S=yn(o),v=sn(a),A=yn(a)===a,x=await(c.isRTL==null?void 0:c.isRTL(u.floating)),F=p||(A||!h?[Es(a)]:Hx(a)),N=m!=="none";!p&&N&&F.push(...Gx(a,h,m,x));const k=[a,...F],T=await c.detectOverflow(t,y),P=[];let E=((n=i.flip)==null?void 0:n.overflows)||[];if(f&&P.push(T[S]),l){const M=Vx(o,s,x);P.push(T[M[0]],T[M[1]])}if(E=[...E,{placement:o,overflows:P}],!P.every(M=>M<=0)){var C,I;const M=(((C=i.flip)==null?void 0:C.index)||0)+1,U=k[M];if(U&&(!(l==="alignment"?v!==sn(U):!1)||E.every(B=>sn(B.placement)===v?B.overflows[0]>0:!0)))return{data:{index:M,overflows:E},reset:{placement:U}};let V=(I=E.filter(X=>X.overflows[0]<=0).sort((X,B)=>X.overflows[1]-B.overflows[1])[0])==null?void 0:I.placement;if(!V)switch(g){case"bestFit":{var W;const X=(W=E.filter(B=>{if(N){const L=sn(B.placement);return L===v||L==="y"}return!0}).map(B=>[B.placement,B.overflows.filter(L=>L>0).reduce((L,D)=>L+D,0)]).sort((B,L)=>B[1]-L[1])[0])==null?void 0:W[0];X&&(V=X);break}case"initialPlacement":V=a;break}if(o!==V)return{reset:{placement:V}}}return{}}}};function mp(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function hp(e){return zx.some(t=>e[t]>=0)}const eA=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:r,platform:n}=t,{strategy:o="referenceHidden",...i}=gn(e,t);switch(o){case"referenceHidden":{const s=await n.detectOverflow(t,{...i,elementContext:"reference"}),a=mp(s,r.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:hp(a)}}}case"escaped":{const s=await n.detectOverflow(t,{...i,altBoundary:!0}),a=mp(s,r.floating);return{data:{escapedOffsets:a,escaped:hp(a)}}}default:return{}}}}},gp=new Set(["left","top"]);async function tA(e,t){const{placement:r,platform:n,elements:o}=e,i=await(n.isRTL==null?void 0:n.isRTL(o.floating)),s=yn(r),a=vo(r),c=sn(r)==="y",u=gp.has(s)?-1:1,f=i&&c?-1:1,l=gn(t,e);let{mainAxis:p,crossAxis:g,alignmentAxis:m}=typeof l=="number"?{mainAxis:l,crossAxis:0,alignmentAxis:null}:{mainAxis:l.mainAxis||0,crossAxis:l.crossAxis||0,alignmentAxis:l.alignmentAxis};return a&&typeof m=="number"&&(g=a==="end"?m*-1:m),c?{x:g*f,y:p*u}:{x:p*u,y:g*f}}const rA=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var r,n;const{x:o,y:i,placement:s,middlewareData:a}=t,c=await tA(t,e);return s===((r=a.offset)==null?void 0:r.placement)&&(n=a.arrow)!=null&&n.alignmentOffset?{}:{x:o+c.x,y:i+c.y,data:{...c,placement:s}}}}},nA=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:n,placement:o,platform:i}=t,{mainAxis:s=!0,crossAxis:a=!1,limiter:c={fn:S=>{let{x:v,y:A}=S;return{x:v,y:A}}},...u}=gn(e,t),f={x:r,y:n},l=await i.detectOverflow(t,u),p=sn(yn(o)),g=Il(p);let m=f[g],h=f[p];if(s){const S=g==="y"?"top":"left",v=g==="y"?"bottom":"right",A=m+l[S],x=m-l[v];m=Ol(A,m,x)}if(a){const S=p==="y"?"top":"left",v=p==="y"?"bottom":"right",A=h+l[S],x=h-l[v];h=Ol(A,h,x)}const y=c.fn({...t,[g]:m,[p]:h});return{...y,data:{x:y.x-r,y:y.y-n,enabled:{[g]:s,[p]:a}}}}}},oA=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:r,y:n,placement:o,rects:i,middlewareData:s}=t,{offset:a=0,mainAxis:c=!0,crossAxis:u=!0}=gn(e,t),f={x:r,y:n},l=sn(o),p=Il(l);let g=f[p],m=f[l];const h=gn(a,t),y=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){const A=p==="y"?"height":"width",x=i.reference[p]-i.floating[A]+y.mainAxis,F=i.reference[p]+i.reference[A]-y.mainAxis;g<x?g=x:g>F&&(g=F)}if(u){var S,v;const A=p==="y"?"width":"height",x=gp.has(yn(o)),F=i.reference[l]-i.floating[A]+(x&&((S=s.offset)==null?void 0:S[l])||0)+(x?0:y.crossAxis),N=i.reference[l]+i.reference[A]+(x?0:((v=s.offset)==null?void 0:v[l])||0)-(x?y.crossAxis:0);m<F?m=F:m>N&&(m=N)}return{[p]:g,[l]:m}}}},iA=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var r,n;const{placement:o,rects:i,platform:s,elements:a}=t,{apply:c=()=>{},...u}=gn(e,t),f=await s.detectOverflow(t,u),l=yn(o),p=vo(o),g=sn(o)==="y",{width:m,height:h}=i.floating;let y,S;l==="top"||l==="bottom"?(y=l,S=p===(await(s.isRTL==null?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(S=l,y=p==="end"?"top":"bottom");const v=h-f.top-f.bottom,A=m-f.left-f.right,x=Mn(h-f[y],v),F=Mn(m-f[S],A),N=!t.middlewareData.shift;let k=x,T=F;if((r=t.middlewareData.shift)!=null&&r.enabled.x&&(T=A),(n=t.middlewareData.shift)!=null&&n.enabled.y&&(k=v),N&&!p){const E=xr(f.left,0),C=xr(f.right,0),I=xr(f.top,0),W=xr(f.bottom,0);g?T=m-2*(E!==0||C!==0?E+C:xr(f.left,f.right)):k=h-2*(I!==0||W!==0?I+W:xr(f.top,f.bottom))}await c({...t,availableWidth:T,availableHeight:k});const P=await s.getDimensions(a.floating);return m!==P.width||h!==P.height?{reset:{rects:!0}}:{}}}};function ks(){return typeof window<"u"}function wo(e){return yp(e)?(e.nodeName||"").toLowerCase():"#document"}function Ar(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function an(e){var t;return(t=(yp(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function yp(e){return ks()?e instanceof Node||e instanceof Ar(e).Node:!1}function Gr(e){return ks()?e instanceof Element||e instanceof Ar(e).Element:!1}function bn(e){return ks()?e instanceof HTMLElement||e instanceof Ar(e).HTMLElement:!1}function bp(e){return!ks()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ar(e).ShadowRoot}function mi(e){const{overflow:t,overflowX:r,overflowY:n,display:o}=qr(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+r)&&o!=="inline"&&o!=="contents"}function sA(e){return/^(table|td|th)$/.test(wo(e))}function _s(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const aA=/transform|translate|scale|rotate|perspective|filter/,lA=/paint|layout|strict|content/,Zn=e=>!!e&&e!=="none";let Bl;function $l(e){const t=Gr(e)?qr(e):e;return Zn(t.transform)||Zn(t.translate)||Zn(t.scale)||Zn(t.rotate)||Zn(t.perspective)||!jl()&&(Zn(t.backdropFilter)||Zn(t.filter))||aA.test(t.willChange||"")||lA.test(t.contain||"")}function cA(e){let t=Ln(e);for(;bn(t)&&!So(t);){if($l(t))return t;if(_s(t))return null;t=Ln(t)}return null}function jl(){return Bl==null&&(Bl=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Bl}function So(e){return/^(html|body|#document)$/.test(wo(e))}function qr(e){return Ar(e).getComputedStyle(e)}function Ts(e){return Gr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ln(e){if(wo(e)==="html")return e;const t=e.assignedSlot||e.parentNode||bp(e)&&e.host||an(e);return bp(t)?t.host:t}function vp(e){const t=Ln(e);return So(t)?e.ownerDocument?e.ownerDocument.body:e.body:bn(t)&&mi(t)?t:vp(t)}function hi(e,t,r){var n;t===void 0&&(t=[]),r===void 0&&(r=!0);const o=vp(e),i=o===((n=e.ownerDocument)==null?void 0:n.body),s=Ar(o);if(i){const a=zl(s);return t.concat(s,s.visualViewport||[],mi(o)?o:[],a&&r?hi(a):[])}else return t.concat(o,hi(o,[],r))}function zl(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function wp(e){const t=qr(e);let r=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const o=bn(e),i=o?e.offsetWidth:r,s=o?e.offsetHeight:n,a=As(r)!==i||As(n)!==s;return a&&(r=i,n=s),{width:r,height:n,$:a}}function Ul(e){return Gr(e)?e:e.contextElement}function xo(e){const t=Ul(e);if(!bn(t))return on(1);const r=t.getBoundingClientRect(),{width:n,height:o,$:i}=wp(t);let s=(i?As(r.width):r.width)/n,a=(i?As(r.height):r.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}const dA=on(0);function Sp(e){const t=Ar(e);return!jl()||!t.visualViewport?dA:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function uA(e,t,r){return t===void 0&&(t=!1),!r||t&&r!==Ar(e)?!1:t}function eo(e,t,r,n){t===void 0&&(t=!1),r===void 0&&(r=!1);const o=e.getBoundingClientRect(),i=Ul(e);let s=on(1);t&&(n?Gr(n)&&(s=xo(n)):s=xo(e));const a=uA(i,r,n)?Sp(i):on(0);let c=(o.left+a.x)/s.x,u=(o.top+a.y)/s.y,f=o.width/s.x,l=o.height/s.y;if(i){const p=Ar(i),g=n&&Gr(n)?Ar(n):n;let m=p,h=zl(m);for(;h&&n&&g!==m;){const y=xo(h),S=h.getBoundingClientRect(),v=qr(h),A=S.left+(h.clientLeft+parseFloat(v.paddingLeft))*y.x,x=S.top+(h.clientTop+parseFloat(v.paddingTop))*y.y;c*=y.x,u*=y.y,f*=y.x,l*=y.y,c+=A,u+=x,m=Ar(h),h=zl(m)}}return Ns({width:f,height:l,x:c,y:u})}function Fs(e,t){const r=Ts(e).scrollLeft;return t?t.left+r:eo(an(e)).left+r}function xp(e,t){const r=e.getBoundingClientRect(),n=r.left+t.scrollLeft-Fs(e,r),o=r.top+t.scrollTop;return{x:n,y:o}}function fA(e){let{elements:t,rect:r,offsetParent:n,strategy:o}=e;const i=o==="fixed",s=an(n),a=t?_s(t.floating):!1;if(n===s||a&&i)return r;let c={scrollLeft:0,scrollTop:0},u=on(1);const f=on(0),l=bn(n);if((l||!l&&!i)&&((wo(n)!=="body"||mi(s))&&(c=Ts(n)),l)){const g=eo(n);u=xo(n),f.x=g.x+n.clientLeft,f.y=g.y+n.clientTop}const p=s&&!l&&!i?xp(s,c):on(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-c.scrollLeft*u.x+f.x+p.x,y:r.y*u.y-c.scrollTop*u.y+f.y+p.y}}function pA(e){return Array.from(e.getClientRects())}function mA(e){const t=an(e),r=Ts(e),n=e.ownerDocument.body,o=xr(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),i=xr(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let s=-r.scrollLeft+Fs(e);const a=-r.scrollTop;return qr(n).direction==="rtl"&&(s+=xr(t.clientWidth,n.clientWidth)-o),{width:o,height:i,x:s,y:a}}const Ap=25;function hA(e,t){const r=Ar(e),n=an(e),o=r.visualViewport;let i=n.clientWidth,s=n.clientHeight,a=0,c=0;if(o){i=o.width,s=o.height;const f=jl();(!f||f&&t==="fixed")&&(a=o.offsetLeft,c=o.offsetTop)}const u=Fs(n);if(u<=0){const f=n.ownerDocument,l=f.body,p=getComputedStyle(l),g=f.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,m=Math.abs(n.clientWidth-l.clientWidth-g);m<=Ap&&(i-=m)}else u<=Ap&&(i+=u);return{width:i,height:s,x:a,y:c}}function gA(e,t){const r=eo(e,!0,t==="fixed"),n=r.top+e.clientTop,o=r.left+e.clientLeft,i=bn(e)?xo(e):on(1),s=e.clientWidth*i.x,a=e.clientHeight*i.y,c=o*i.x,u=n*i.y;return{width:s,height:a,x:c,y:u}}function Cp(e,t,r){let n;if(t==="viewport")n=hA(e,r);else if(t==="document")n=mA(an(e));else if(Gr(t))n=gA(t,r);else{const o=Sp(e);n={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Ns(n)}function Ep(e,t){const r=Ln(e);return r===t||!Gr(r)||So(r)?!1:qr(r).position==="fixed"||Ep(r,t)}function yA(e,t){const r=t.get(e);if(r)return r;let n=hi(e,[],!1).filter(a=>Gr(a)&&wo(a)!=="body"),o=null;const i=qr(e).position==="fixed";let s=i?Ln(e):e;for(;Gr(s)&&!So(s);){const a=qr(s),c=$l(s);!c&&a.position==="fixed"&&(o=null),(i?!c&&!o:!c&&a.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||mi(s)&&!c&&Ep(e,s))?n=n.filter(f=>f!==s):o=a,s=Ln(s)}return t.set(e,n),n}function bA(e){let{element:t,boundary:r,rootBoundary:n,strategy:o}=e;const s=[...r==="clippingAncestors"?_s(t)?[]:yA(t,this._c):[].concat(r),n],a=Cp(t,s[0],o);let c=a.top,u=a.right,f=a.bottom,l=a.left;for(let p=1;p<s.length;p++){const g=Cp(t,s[p],o);c=xr(g.top,c),u=Mn(g.right,u),f=Mn(g.bottom,f),l=xr(g.left,l)}return{width:u-l,height:f-c,x:l,y:c}}function vA(e){const{width:t,height:r}=wp(e);return{width:t,height:r}}function wA(e,t,r){const n=bn(t),o=an(t),i=r==="fixed",s=eo(e,!0,i,t);let a={scrollLeft:0,scrollTop:0};const c=on(0);function u(){c.x=Fs(o)}if(n||!n&&!i)if((wo(t)!=="body"||mi(o))&&(a=Ts(t)),n){const g=eo(t,!0,i,t);c.x=g.x+t.clientLeft,c.y=g.y+t.clientTop}else o&&u();i&&!n&&o&&u();const f=o&&!n&&!i?xp(o,a):on(0),l=s.left+a.scrollLeft-c.x-f.x,p=s.top+a.scrollTop-c.y-f.y;return{x:l,y:p,width:s.width,height:s.height}}function Vl(e){return qr(e).position==="static"}function Np(e,t){if(!bn(e)||qr(e).position==="fixed")return null;if(t)return t(e);let r=e.offsetParent;return an(e)===r&&(r=r.ownerDocument.body),r}function kp(e,t){const r=Ar(e);if(_s(e))return r;if(!bn(e)){let o=Ln(e);for(;o&&!So(o);){if(Gr(o)&&!Vl(o))return o;o=Ln(o)}return r}let n=Np(e,t);for(;n&&sA(n)&&Vl(n);)n=Np(n,t);return n&&So(n)&&Vl(n)&&!$l(n)?r:n||cA(e)||r}const SA=async function(e){const t=this.getOffsetParent||kp,r=this.getDimensions,n=await r(e.floating);return{reference:wA(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function xA(e){return qr(e).direction==="rtl"}const AA={convertOffsetParentRelativeRectToViewportRelativeRect:fA,getDocumentElement:an,getClippingRect:bA,getOffsetParent:kp,getElementRects:SA,getClientRects:pA,getDimensions:vA,getScale:xo,isElement:Gr,isRTL:xA};function _p(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function CA(e,t){let r=null,n;const o=an(e);function i(){var a;clearTimeout(n),(a=r)==null||a.disconnect(),r=null}function s(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),i();const u=e.getBoundingClientRect(),{left:f,top:l,width:p,height:g}=u;if(a||t(),!p||!g)return;const m=Cs(l),h=Cs(o.clientWidth-(f+p)),y=Cs(o.clientHeight-(l+g)),S=Cs(f),A={rootMargin:-m+"px "+-h+"px "+-y+"px "+-S+"px",threshold:xr(0,Mn(1,c))||1};let x=!0;function F(N){const k=N[0].intersectionRatio;if(k!==c){if(!x)return s();k?s(!1,k):n=setTimeout(()=>{s(!1,1e-7)},1e3)}k===1&&!_p(u,e.getBoundingClientRect())&&s(),x=!1}try{r=new IntersectionObserver(F,{...A,root:o.ownerDocument})}catch{r=new IntersectionObserver(F,A)}r.observe(e)}return s(!0),i}function EA(e,t,r,n){n===void 0&&(n={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=n,u=Ul(e),f=o||i?[...u?hi(u):[],...t?hi(t):[]]:[];f.forEach(S=>{o&&S.addEventListener("scroll",r,{passive:!0}),i&&S.addEventListener("resize",r)});const l=u&&a?CA(u,r):null;let p=-1,g=null;s&&(g=new ResizeObserver(S=>{let[v]=S;v&&v.target===u&&g&&t&&(g.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var A;(A=g)==null||A.observe(t)})),r()}),u&&!c&&g.observe(u),t&&g.observe(t));let m,h=c?eo(e):null;c&&y();function y(){const S=eo(e);h&&!_p(h,S)&&r(),h=S,m=requestAnimationFrame(y)}return r(),()=>{var S;f.forEach(v=>{o&&v.removeEventListener("scroll",r),i&&v.removeEventListener("resize",r)}),l?.(),(S=g)==null||S.disconnect(),g=null,c&&cancelAnimationFrame(m)}}const NA=rA,kA=nA,_A=Zx,TA=iA,FA=eA,Tp=Qx,PA=oA,OA=(e,t,r)=>{const n=new Map,o={platform:AA,...r},i={...o.platform,_c:n};return Jx(e,t,{...o,platform:i})};var IA=typeof document<"u",MA=function(){},Ps=IA?w.useLayoutEffect:MA;function Os(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let r,n,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(r=e.length,r!==t.length)return!1;for(n=r;n--!==0;)if(!Os(e[n],t[n]))return!1;return!0}if(o=Object.keys(e),r=o.length,r!==Object.keys(t).length)return!1;for(n=r;n--!==0;)if(!{}.hasOwnProperty.call(t,o[n]))return!1;for(n=r;n--!==0;){const i=o[n];if(!(i==="_owner"&&e.$$typeof)&&!Os(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function Fp(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Pp(e,t){const r=Fp(e);return Math.round(t*r)/r}function Hl(e){const t=b.useRef(e);return Ps(()=>{t.current=e}),t}function LA(e){e===void 0&&(e={});const{placement:t="bottom",strategy:r="absolute",middleware:n=[],platform:o,elements:{reference:i,floating:s}={},transform:a=!0,whileElementsMounted:c,open:u}=e,[f,l]=b.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[p,g]=b.useState(n);Os(p,n)||g(n);const[m,h]=b.useState(null),[y,S]=b.useState(null),v=b.useCallback(B=>{B!==N.current&&(N.current=B,h(B))},[]),A=b.useCallback(B=>{B!==k.current&&(k.current=B,S(B))},[]),x=i||m,F=s||y,N=b.useRef(null),k=b.useRef(null),T=b.useRef(f),P=c!=null,E=Hl(c),C=Hl(o),I=Hl(u),W=b.useCallback(()=>{if(!N.current||!k.current)return;const B={placement:t,strategy:r,middleware:p};C.current&&(B.platform=C.current),OA(N.current,k.current,B).then(L=>{const D={...L,isPositioned:I.current!==!1};M.current&&!Os(T.current,D)&&(T.current=D,Wi.flushSync(()=>{l(D)}))})},[p,t,r,C,I]);Ps(()=>{u===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,l(B=>({...B,isPositioned:!1})))},[u]);const M=b.useRef(!1);Ps(()=>(M.current=!0,()=>{M.current=!1}),[]),Ps(()=>{if(x&&(N.current=x),F&&(k.current=F),x&&F){if(E.current)return E.current(x,F,W);W()}},[x,F,W,E,P]);const U=b.useMemo(()=>({reference:N,floating:k,setReference:v,setFloating:A}),[v,A]),V=b.useMemo(()=>({reference:x,floating:F}),[x,F]),X=b.useMemo(()=>{const B={position:r,left:0,top:0};if(!V.floating)return B;const L=Pp(V.floating,f.x),D=Pp(V.floating,f.y);return a?{...B,transform:"translate("+L+"px, "+D+"px)",...Fp(V.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:L,top:D}},[r,a,V.floating,f.x,f.y]);return b.useMemo(()=>({...f,update:W,refs:U,elements:V,floatingStyles:X}),[f,W,U,V,X])}const DA=e=>{function t(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:e,fn(r){const{element:n,padding:o}=typeof e=="function"?e(r):e;return n&&t(n)?n.current!=null?Tp({element:n.current,padding:o}).fn(r):{}:n?Tp({element:n,padding:o}).fn(r):{}}}},BA=(e,t)=>{const r=NA(e);return{name:r.name,fn:r.fn,options:[e,t]}},$A=(e,t)=>{const r=kA(e);return{name:r.name,fn:r.fn,options:[e,t]}},jA=(e,t)=>({fn:PA(e).fn,options:[e,t]}),zA=(e,t)=>{const r=_A(e);return{name:r.name,fn:r.fn,options:[e,t]}},UA=(e,t)=>{const r=TA(e);return{name:r.name,fn:r.fn,options:[e,t]}},VA=(e,t)=>{const r=FA(e);return{name:r.name,fn:r.fn,options:[e,t]}},HA=(e,t)=>{const r=DA(e);return{name:r.name,fn:r.fn,options:[e,t]}};var WA="Arrow",Op=b.forwardRef((e,t)=>{const{children:r,width:n=10,height:o=5,...i}=e;return d.jsx($e.svg,{...i,ref:t,width:n,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:d.jsx("polygon",{points:"0,0 30,0 15,10"})})});Op.displayName=WA;var RA=Op;function gi(e){const[t,r]=b.useState(void 0);return tr(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});const n=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let s,a;if("borderBoxSize"in i){const c=i.borderBoxSize,u=Array.isArray(c)?c[0]:c;s=u.inlineSize,a=u.blockSize}else s=e.offsetWidth,a=e.offsetHeight;r({width:s,height:a})});return n.observe(e,{box:"border-box"}),()=>n.unobserve(e)}else r(void 0)},[e]),t}var Wl="Popper",[Ip,Is]=Sr(Wl),[KA,Mp]=Ip(Wl),Lp=e=>{const{__scopePopper:t,children:r}=e,[n,o]=b.useState(null);return d.jsx(KA,{scope:t,anchor:n,onAnchorChange:o,children:r})};Lp.displayName=Wl;var Dp="PopperAnchor",Bp=b.forwardRef((e,t)=>{const{__scopePopper:r,virtualRef:n,...o}=e,i=Mp(Dp,r),s=b.useRef(null),a=qe(t,s),c=b.useRef(null);return b.useEffect(()=>{const u=c.current;c.current=n?.current||s.current,u!==c.current&&i.onAnchorChange(c.current)}),n?null:d.jsx($e.div,{...o,ref:a})});Bp.displayName=Dp;var Rl="PopperContent",[GA,qA]=Ip(Rl),$p=b.forwardRef((e,t)=>{const{__scopePopper:r,side:n="bottom",sideOffset:o=0,align:i="center",alignOffset:s=0,arrowPadding:a=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:f=0,sticky:l="partial",hideWhenDetached:p=!1,updatePositionStrategy:g="optimized",onPlaced:m,...h}=e,y=Mp(Rl,r),[S,v]=b.useState(null),A=qe(t,G=>v(G)),[x,F]=b.useState(null),N=gi(x),k=N?.width??0,T=N?.height??0,P=n+(i!=="center"?"-"+i:""),E=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},C=Array.isArray(u)?u:[u],I=C.length>0,W={padding:E,boundary:C.filter(XA),altBoundary:I},{refs:M,floatingStyles:U,placement:V,isPositioned:X,middlewareData:B}=LA({strategy:"fixed",placement:P,whileElementsMounted:(...G)=>EA(...G,{animationFrame:g==="always"}),elements:{reference:y.anchor},middleware:[BA({mainAxis:o+T,alignmentAxis:s}),c&&$A({mainAxis:!0,crossAxis:!1,limiter:l==="partial"?jA():void 0,...W}),c&&zA({...W}),UA({...W,apply:({elements:G,rects:ee,availableWidth:Ae,availableHeight:te})=>{const{width:oe,height:me}=ee.reference,Me=G.floating.style;Me.setProperty("--radix-popper-available-width",`${Ae}px`),Me.setProperty("--radix-popper-available-height",`${te}px`),Me.setProperty("--radix-popper-anchor-width",`${oe}px`),Me.setProperty("--radix-popper-anchor-height",`${me}px`)}}),x&&HA({element:x,padding:a}),JA({arrowWidth:k,arrowHeight:T}),p&&VA({strategy:"referenceHidden",...W})]}),[L,D]=Up(V),K=dr(m);tr(()=>{X&&K?.()},[X,K]);const ae=B.arrow?.x,j=B.arrow?.y,z=B.arrow?.centerOffset!==0,[le,ie]=b.useState();return tr(()=>{S&&ie(window.getComputedStyle(S).zIndex)},[S]),d.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...U,transform:X?U.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:le,"--radix-popper-transform-origin":[B.transformOrigin?.x,B.transformOrigin?.y].join(" "),...B.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:d.jsx(GA,{scope:r,placedSide:L,onArrowChange:F,arrowX:ae,arrowY:j,shouldHideArrow:z,children:d.jsx($e.div,{"data-side":L,"data-align":D,...h,ref:A,style:{...h.style,animation:X?void 0:"none"}})})})});$p.displayName=Rl;var jp="PopperArrow",YA={top:"bottom",right:"left",bottom:"top",left:"right"},zp=b.forwardRef(function(t,r){const{__scopePopper:n,...o}=t,i=qA(jp,n),s=YA[i.placedSide];return d.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:d.jsx(RA,{...o,ref:r,style:{...o.style,display:"block"}})})});zp.displayName=jp;function XA(e){return e!==null}var JA=e=>({name:"transformOrigin",options:e,fn(t){const{placement:r,rects:n,middlewareData:o}=t,s=o.arrow?.centerOffset!==0,a=s?0:e.arrowWidth,c=s?0:e.arrowHeight,[u,f]=Up(r),l={start:"0%",center:"50%",end:"100%"}[f],p=(o.arrow?.x??0)+a/2,g=(o.arrow?.y??0)+c/2;let m="",h="";return u==="bottom"?(m=s?l:`${p}px`,h=`${-c}px`):u==="top"?(m=s?l:`${p}px`,h=`${n.floating.height+c}px`):u==="right"?(m=`${-c}px`,h=s?l:`${g}px`):u==="left"&&(m=`${n.floating.width+c}px`,h=s?l:`${g}px`),{data:{x:m,y:h}}}});function Up(e){const[t,r="center"]=e.split("-");return[t,r]}var Vp=Lp,Kl=Bp,Hp=$p,Wp=zp,QA="Portal",Ms=b.forwardRef((e,t)=>{const{container:r,...n}=e,[o,i]=b.useState(!1);tr(()=>i(!0),[]);const s=r||o&&globalThis?.document?.body;return s?Id.createPortal(d.jsx($e.div,{...n,ref:t}),s):null});Ms.displayName=QA;function ZA(e){const t=eC(e),r=b.forwardRef((n,o)=>{const{children:i,...s}=n,a=b.Children.toArray(i),c=a.find(rC);if(c){const u=c.props.children,f=a.map(l=>l===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:l);return d.jsx(t,{...s,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,f):null})}return d.jsx(t,{...s,ref:o,children:i})});return r.displayName=`${e}.Slot`,r}function eC(e){const t=b.forwardRef((r,n)=>{const{children:o,...i}=r;if(b.isValidElement(o)){const s=oC(o),a=nC(i,o.props);return o.type!==b.Fragment&&(a.ref=n?qn(n,s):s),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var tC=Symbol("radix.slottable");function rC(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===tC}function nC(e,t){const r={...t};for(const n in t){const o=e[n],i=t[n];/^on[A-Z]/.test(n)?o&&i?r[n]=(...a)=>{const c=i(...a);return o(...a),c}:o&&(r[n]=o):n==="style"?r[n]={...o,...i}:n==="className"&&(r[n]=[o,i].filter(Boolean).join(" "))}return{...e,...r}}function oC(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var iC=b[" useInsertionEffect ".trim().toString()]||tr;function ln({prop:e,defaultProp:t,onChange:r=()=>{},caller:n}){const[o,i,s]=sC({defaultProp:t,onChange:r}),a=e!==void 0,c=a?e:o;{const f=b.useRef(e!==void 0);b.useEffect(()=>{const l=f.current;l!==a&&console.warn(`${n} is changing from ${l?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=a},[a,n])}const u=b.useCallback(f=>{if(a){const l=aC(f)?f(e):f;l!==e&&s.current?.(l)}else i(f)},[a,e,i,s]);return[c,u]}function sC({defaultProp:e,onChange:t}){const[r,n]=b.useState(e),o=b.useRef(r),i=b.useRef(t);return iC(()=>{i.current=t},[t]),b.useEffect(()=>{o.current!==r&&(i.current?.(r),o.current=r)},[r,o]),[r,n,i]}function aC(e){return typeof e=="function"}function yi(e){const t=b.useRef({value:e,previous:e});return b.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Rp=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),lC="VisuallyHidden",cC=b.forwardRef((e,t)=>d.jsx($e.span,{...e,ref:t,style:{...Rp,...e.style}}));cC.displayName=lC;var dC=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Ao=new WeakMap,Ls=new WeakMap,Ds={},Gl=0,Kp=function(e){return e&&(e.host||Kp(e.parentNode))},uC=function(e,t){return t.map(function(r){if(e.contains(r))return r;var n=Kp(r);return n&&e.contains(n)?n:(console.error("aria-hidden",r,"in not contained inside",e,". Doing nothing"),null)}).filter(function(r){return!!r})},fC=function(e,t,r,n){var o=uC(t,Array.isArray(e)?e:[e]);Ds[r]||(Ds[r]=new WeakMap);var i=Ds[r],s=[],a=new Set,c=new Set(o),u=function(l){!l||a.has(l)||(a.add(l),u(l.parentNode))};o.forEach(u);var f=function(l){!l||c.has(l)||Array.prototype.forEach.call(l.children,function(p){if(a.has(p))f(p);else try{var g=p.getAttribute(n),m=g!==null&&g!=="false",h=(Ao.get(p)||0)+1,y=(i.get(p)||0)+1;Ao.set(p,h),i.set(p,y),s.push(p),h===1&&m&&Ls.set(p,!0),y===1&&p.setAttribute(r,"true"),m||p.setAttribute(n,"true")}catch(S){console.error("aria-hidden: cannot operate on ",p,S)}})};return f(t),a.clear(),Gl++,function(){s.forEach(function(l){var p=Ao.get(l)-1,g=i.get(l)-1;Ao.set(l,p),i.set(l,g),p||(Ls.has(l)||l.removeAttribute(n),Ls.delete(l)),g||l.removeAttribute(r)}),Gl--,Gl||(Ao=new WeakMap,Ao=new WeakMap,Ls=new WeakMap,Ds={})}},ql=function(e,t,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(e)?e:[e]),o=dC(e);return o?(n.push.apply(n,Array.from(o.querySelectorAll("[aria-live], script"))),fC(n,o,r,"aria-hidden")):function(){return null}},cn=function(){return cn=Object.assign||function(t){for(var r,n=1,o=arguments.length;n<o;n++){r=arguments[n];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t},cn.apply(this,arguments)};function Gp(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]]);return r}function pC(e,t,r){if(r||arguments.length===2)for(var n=0,o=t.length,i;n<o;n++)(i||!(n in t))&&(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var Bs="right-scroll-bar-position",$s="width-before-scroll-bar",mC="with-scroll-bars-hidden",hC="--removed-body-scroll-bar-size";function Yl(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function gC(e,t){var r=w.useState(function(){return{value:e,callback:t,facade:{get current(){return r.value},set current(n){var o=r.value;o!==n&&(r.value=n,r.callback(n,o))}}}})[0];return r.callback=t,r.facade}var yC=typeof window<"u"?b.useLayoutEffect:b.useEffect,qp=new WeakMap;function bC(e,t){var r=gC(null,function(n){return e.forEach(function(o){return Yl(o,n)})});return yC(function(){var n=qp.get(r);if(n){var o=new Set(n),i=new Set(e),s=r.current;o.forEach(function(a){i.has(a)||Yl(a,null)}),i.forEach(function(a){o.has(a)||Yl(a,s)})}qp.set(r,e)},[e]),r}function vC(e){return e}function wC(e,t){t===void 0&&(t=vC);var r=[],n=!1,o={read:function(){if(n)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:e},useMedium:function(i){var s=t(i,n);return r.push(s),function(){r=r.filter(function(a){return a!==s})}},assignSyncMedium:function(i){for(n=!0;r.length;){var s=r;r=[],s.forEach(i)}r={push:function(a){return i(a)},filter:function(){return r}}},assignMedium:function(i){n=!0;var s=[];if(r.length){var a=r;r=[],a.forEach(i),s=r}var c=function(){var f=s;s=[],f.forEach(i)},u=function(){return Promise.resolve().then(c)};u(),r={push:function(f){s.push(f),u()},filter:function(f){return s=s.filter(f),r}}}};return o}function SC(e){e===void 0&&(e={});var t=wC(null);return t.options=cn({async:!0,ssr:!1},e),t}var Yp=function(e){var t=e.sideCar,r=Gp(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var n=t.read();if(!n)throw new Error("Sidecar medium not found");return b.createElement(n,cn({},r))};Yp.isSideCarExport=!0;function xC(e,t){return e.useMedium(t),Yp}var Xp=SC(),Xl=function(){},js=b.forwardRef(function(e,t){var r=b.useRef(null),n=b.useState({onScrollCapture:Xl,onWheelCapture:Xl,onTouchMoveCapture:Xl}),o=n[0],i=n[1],s=e.forwardProps,a=e.children,c=e.className,u=e.removeScrollBar,f=e.enabled,l=e.shards,p=e.sideCar,g=e.noRelative,m=e.noIsolation,h=e.inert,y=e.allowPinchZoom,S=e.as,v=S===void 0?"div":S,A=e.gapMode,x=Gp(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),F=p,N=bC([r,t]),k=cn(cn({},x),o);return b.createElement(b.Fragment,null,f&&b.createElement(F,{sideCar:Xp,removeScrollBar:u,shards:l,noRelative:g,noIsolation:m,inert:h,setCallbacks:i,allowPinchZoom:!!y,lockRef:r,gapMode:A}),s?b.cloneElement(b.Children.only(a),cn(cn({},k),{ref:N})):b.createElement(v,cn({},k,{className:c,ref:N}),a))});js.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},js.classNames={fullWidth:$s,zeroRight:Bs};var AC=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function CC(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=AC();return t&&e.setAttribute("nonce",t),e}function EC(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function NC(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var kC=function(){var e=0,t=null;return{add:function(r){e==0&&(t=CC())&&(EC(t,r),NC(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},_C=function(){var e=kC();return function(t,r){b.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&r])}},Jp=function(){var e=_C(),t=function(r){var n=r.styles,o=r.dynamic;return e(n,o),null};return t},TC={left:0,top:0,right:0,gap:0},Jl=function(e){return parseInt(e||"",10)||0},FC=function(e){var t=window.getComputedStyle(document.body),r=t[e==="padding"?"paddingLeft":"marginLeft"],n=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[Jl(r),Jl(n),Jl(o)]},PC=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return TC;var t=FC(e),r=document.documentElement.clientWidth,n=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,n-r+t[2]-t[0])}},OC=Jp(),Co="data-scroll-locked",IC=function(e,t,r,n){var o=e.left,i=e.top,s=e.right,a=e.gap;return r===void 0&&(r="margin"),`
|
|
7
|
-
.`.concat(
|
|
1
|
+
(function(ae,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("react"),require("react/jsx-runtime"),require("react-router-dom"),require("react-dom"),require("sonner"),require("@tanstack/react-query")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime","react-router-dom","react-dom","sonner","@tanstack/react-query"],w):(ae=typeof globalThis<"u"?globalThis:ae||self,w(ae.FormBuilderRenderer={},ae.React,ae.jsxRuntime,ae.ReactRouterDOM,ae.ReactDOM,ae.Sonner,ae.ReactQuery))})(this,(function(ae,w,d,Va,$d,at,mn){"use strict";function jd(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const b=jd(w),Gi=jd($d),Wa="iq-fbr",Wn="95px";function qi(e){return!e||typeof e.columns!="number"?null:{rows:e.rows??8,columns:e.columns,verticalSpacing:e.verticalSpacing||e.spacing||"16px",horizontalSpacing:e.horizontalSpacing||e.spacing||"16px",rowHeight:Wn}}function Yi(e,t){if(t!=null&&t!==void 0)return t;const r=e.config;if(r?.grid&&typeof r.grid.rows=="number"&&typeof r.grid.columns=="number")return{rows:r.grid.rows,columns:r.grid.columns,verticalSpacing:r.grid.verticalSpacing??r.grid.spacing,horizontalSpacing:r.grid.horizontalSpacing??r.grid.spacing,rowHeight:r.grid.rowHeight,spacing:r.grid.spacing};const n=r?.layout!=null&&typeof r.layout=="object"?r.layout:null;if(n&&typeof n.rows=="number"&&typeof n.columns=="number")return{rows:n.rows,columns:n.columns,verticalSpacing:n.verticalSpacing??n.spacing,horizontalSpacing:n.horizontalSpacing??n.spacing,rowHeight:n.rowHeight,spacing:n.spacing};const o=e.layout;if(o!=null&&typeof o=="object"&&typeof o.rows=="number"&&typeof o.columns=="number"){const i=o;return{rows:i.rows,columns:i.columns,verticalSpacing:i.verticalSpacing??i.spacing,horizontalSpacing:i.horizontalSpacing??i.spacing,rowHeight:i.rowHeight,spacing:i.spacing}}return null}function Hd(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(r=Hd(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function Ud(){for(var e,t,r=0,n="",o=arguments.length;r<o;r++)(e=arguments[r])&&(t=Hd(e))&&(n&&(n+=" "),n+=t);return n}const mv=(e,t)=>{const r=new Array(e.length+t.length);for(let n=0;n<e.length;n++)r[n]=e[n];for(let n=0;n<t.length;n++)r[e.length+n]=t[n];return r},hv=(e,t)=>({classGroupId:e,validator:t}),zd=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),Xi="-",Vd=[],gv="arbitrary..",yv=e=>{const t=vv(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:s=>{if(s.startsWith("[")&&s.endsWith("]"))return bv(s);const a=s.split(Xi),c=a[0]===""&&a.length>1?1:0;return Wd(a,c,t)},getConflictingClassGroupIds:(s,a)=>{if(a){const c=n[s],u=r[s];return c?u?mv(u,c):c:u||Vd}return r[s]||Vd}}},Wd=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const o=e[t],i=r.nextPart.get(o);if(i){const u=Wd(e,t+1,i);if(u)return u}const s=r.validators;if(s===null)return;const a=t===0?e.join(Xi):e.slice(t).join(Xi),c=s.length;for(let u=0;u<c;u++){const f=s[u];if(f.validator(a))return f.classGroupId}},bv=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),r=t.indexOf(":"),n=t.slice(0,r);return n?gv+n:void 0})(),vv=e=>{const{theme:t,classGroups:r}=e;return wv(r,t)},wv=(e,t)=>{const r=zd();for(const n in e){const o=e[n];Ra(o,r,n,t)}return r},Ra=(e,t,r,n)=>{const o=e.length;for(let i=0;i<o;i++){const s=e[i];Sv(s,t,r,n)}},Sv=(e,t,r,n)=>{if(typeof e=="string"){xv(e,t,r);return}if(typeof e=="function"){Av(e,t,r,n);return}Cv(e,t,r,n)},xv=(e,t,r)=>{const n=e===""?t:Rd(t,e);n.classGroupId=r},Av=(e,t,r,n)=>{if(Ev(e)){Ra(e(n),t,r,n);return}t.validators===null&&(t.validators=[]),t.validators.push(hv(r,e))},Cv=(e,t,r,n)=>{const o=Object.entries(e),i=o.length;for(let s=0;s<i;s++){const[a,c]=o[s];Ra(c,Rd(t,a),r,n)}},Rd=(e,t)=>{let r=e;const n=t.split(Xi),o=n.length;for(let i=0;i<o;i++){const s=n[i];let a=r.nextPart.get(s);a||(a=zd(),r.nextPart.set(s,a)),r=a}return r},Ev=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,kv=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=Object.create(null),n=Object.create(null);const o=(i,s)=>{r[i]=s,t++,t>e&&(t=0,n=r,r=Object.create(null))};return{get(i){let s=r[i];if(s!==void 0)return s;if((s=n[i])!==void 0)return o(i,s),s},set(i,s){i in r?r[i]=s:o(i,s)}}},Ka="!",Kd=":",Nv=[],Gd=(e,t,r,n,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:n,isExternal:o}),_v=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=o=>{const i=[];let s=0,a=0,c=0,u;const f=o.length;for(let h=0;h<f;h++){const y=o[h];if(s===0&&a===0){if(y===Kd){i.push(o.slice(c,h)),c=h+1;continue}if(y==="/"){u=h;continue}}y==="["?s++:y==="]"?s--:y==="("?a++:y===")"&&a--}const l=i.length===0?o:o.slice(c);let p=l,g=!1;l.endsWith(Ka)?(p=l.slice(0,-1),g=!0):l.startsWith(Ka)&&(p=l.slice(1),g=!0);const m=u&&u>c?u-c:void 0;return Gd(i,g,p,m)};if(t){const o=t+Kd,i=n;n=s=>s.startsWith(o)?i(s.slice(o.length)):Gd(Nv,!1,s,void 0,!0)}if(r){const o=n;n=i=>r({className:i,parseClassName:o})}return n},Tv=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((r,n)=>{t.set(r,1e6+n)}),r=>{const n=[];let o=[];for(let i=0;i<r.length;i++){const s=r[i],a=s[0]==="[",c=t.has(s);a||c?(o.length>0&&(o.sort(),n.push(...o),o=[]),n.push(s)):o.push(s)}return o.length>0&&(o.sort(),n.push(...o)),n}},Fv=e=>({cache:kv(e.cacheSize),parseClassName:_v(e),sortModifiers:Tv(e),...yv(e)}),Pv=/\s+/,Iv=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:o,sortModifiers:i}=t,s=[],a=e.trim().split(Pv);let c="";for(let u=a.length-1;u>=0;u-=1){const f=a[u],{isExternal:l,modifiers:p,hasImportantModifier:g,baseClassName:m,maybePostfixModifierPosition:h}=r(f);if(l){c=f+(c.length>0?" "+c:c);continue}let y=!!h,S=n(y?m.substring(0,h):m);if(!S){if(!y){c=f+(c.length>0?" "+c:c);continue}if(S=n(m),!S){c=f+(c.length>0?" "+c:c);continue}y=!1}const v=p.length===0?"":p.length===1?p[0]:i(p).join(":"),A=g?v+Ka:v,x=A+S;if(s.indexOf(x)>-1)continue;s.push(x);const F=o(S,y);for(let k=0;k<F.length;++k){const N=F[k];s.push(A+N)}c=f+(c.length>0?" "+c:c)}return c},Ov=(...e)=>{let t=0,r,n,o="";for(;t<e.length;)(r=e[t++])&&(n=qd(r))&&(o&&(o+=" "),o+=n);return o},qd=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=qd(e[n]))&&(r&&(r+=" "),r+=t);return r},Mv=(e,...t)=>{let r,n,o,i;const s=c=>{const u=t.reduce((f,l)=>l(f),e());return r=Fv(u),n=r.cache.get,o=r.cache.set,i=a,a(c)},a=c=>{const u=n(c);if(u)return u;const f=Iv(c,r);return o(c,f),f};return i=s,(...c)=>i(Ov(...c))},Lv=[],Kt=e=>{const t=r=>r[e]||Lv;return t.isThemeGetter=!0,t},Yd=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Xd=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Dv=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Bv=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,$v=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,jv=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Hv=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Uv=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,_n=e=>Dv.test(e),tt=e=>!!e&&!Number.isNaN(Number(e)),Tn=e=>!!e&&Number.isInteger(Number(e)),Ga=e=>e.endsWith("%")&&tt(e.slice(0,-1)),hn=e=>Bv.test(e),Jd=()=>!0,zv=e=>$v.test(e)&&!jv.test(e),qa=()=>!1,Vv=e=>Hv.test(e),Wv=e=>Uv.test(e),Rv=e=>!Te(e)&&!Pe(e),Kv=e=>Fn(e,nu,qa),Te=e=>Yd.test(e),Rn=e=>Fn(e,ou,zv),Qd=e=>Fn(e,ew,tt),Gv=e=>Fn(e,su,Jd),qv=e=>Fn(e,iu,qa),Zd=e=>Fn(e,tu,qa),Yv=e=>Fn(e,ru,Wv),Ji=e=>Fn(e,au,Vv),Pe=e=>Xd.test(e),Jo=e=>Kn(e,ou),Xv=e=>Kn(e,iu),eu=e=>Kn(e,tu),Jv=e=>Kn(e,nu),Qv=e=>Kn(e,ru),Qi=e=>Kn(e,au,!0),Zv=e=>Kn(e,su,!0),Fn=(e,t,r)=>{const n=Yd.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},Kn=(e,t,r=!1)=>{const n=Xd.exec(e);return n?n[1]?t(n[1]):r:!1},tu=e=>e==="position"||e==="percentage",ru=e=>e==="image"||e==="url",nu=e=>e==="length"||e==="size"||e==="bg-size",ou=e=>e==="length",ew=e=>e==="number",iu=e=>e==="family-name",su=e=>e==="number"||e==="weight",au=e=>e==="shadow",tw=Mv(()=>{const e=Kt("color"),t=Kt("font"),r=Kt("text"),n=Kt("font-weight"),o=Kt("tracking"),i=Kt("leading"),s=Kt("breakpoint"),a=Kt("container"),c=Kt("spacing"),u=Kt("radius"),f=Kt("shadow"),l=Kt("inset-shadow"),p=Kt("text-shadow"),g=Kt("drop-shadow"),m=Kt("blur"),h=Kt("perspective"),y=Kt("aspect"),S=Kt("ease"),v=Kt("animate"),A=()=>["auto","avoid","all","avoid-page","page","left","right","column"],x=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],F=()=>[...x(),Pe,Te],k=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto","contain","none"],T=()=>[Pe,Te,c],P=()=>[_n,"full","auto",...T()],E=()=>[Tn,"none","subgrid",Pe,Te],C=()=>["auto",{span:["full",Tn,Pe,Te]},Tn,Pe,Te],O=()=>[Tn,"auto",Pe,Te],W=()=>["auto","min","max","fr",Pe,Te],M=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],U=()=>["start","end","center","stretch","center-safe","end-safe"],z=()=>["auto",...T()],X=()=>[_n,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...T()],B=()=>[_n,"screen","full","dvw","lvw","svw","min","max","fit",...T()],L=()=>[_n,"screen","full","lh","dvh","lvh","svh","min","max","fit",...T()],D=()=>[e,Pe,Te],K=()=>[...x(),eu,Zd,{position:[Pe,Te]}],le=()=>["no-repeat",{repeat:["","x","y","space","round"]}],j=()=>["auto","cover","contain",Jv,Kv,{size:[Pe,Te]}],H=()=>[Ga,Jo,Rn],ce=()=>["","none","full",u,Pe,Te],ie=()=>["",tt,Jo,Rn],G=()=>["solid","dashed","dotted","double"],ee=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Ae=()=>[tt,Ga,eu,Zd],te=()=>["","none",m,Pe,Te],oe=()=>["none",tt,Pe,Te],me=()=>["none",tt,Pe,Te],Me=()=>[tt,Pe,Te],De=()=>[_n,"full",...T()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[hn],breakpoint:[hn],color:[Jd],container:[hn],"drop-shadow":[hn],ease:["in","out","in-out"],font:[Rv],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[hn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[hn],shadow:[hn],spacing:["px",tt],text:[hn],"text-shadow":[hn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",_n,Te,Pe,y]}],container:["container"],columns:[{columns:[tt,Te,Pe,a]}],"break-after":[{"break-after":A()}],"break-before":[{"break-before":A()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:F()}],overflow:[{overflow:k()}],"overflow-x":[{"overflow-x":k()}],"overflow-y":[{"overflow-y":k()}],overscroll:[{overscroll:N()}],"overscroll-x":[{"overscroll-x":N()}],"overscroll-y":[{"overscroll-y":N()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:P()}],"inset-x":[{"inset-x":P()}],"inset-y":[{"inset-y":P()}],start:[{"inset-s":P(),start:P()}],end:[{"inset-e":P(),end:P()}],"inset-bs":[{"inset-bs":P()}],"inset-be":[{"inset-be":P()}],top:[{top:P()}],right:[{right:P()}],bottom:[{bottom:P()}],left:[{left:P()}],visibility:["visible","invisible","collapse"],z:[{z:[Tn,"auto",Pe,Te]}],basis:[{basis:[_n,"full","auto",a,...T()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[tt,_n,"auto","initial","none",Te]}],grow:[{grow:["",tt,Pe,Te]}],shrink:[{shrink:["",tt,Pe,Te]}],order:[{order:[Tn,"first","last","none",Pe,Te]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:C()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:C()}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":W()}],"auto-rows":[{"auto-rows":W()}],gap:[{gap:T()}],"gap-x":[{"gap-x":T()}],"gap-y":[{"gap-y":T()}],"justify-content":[{justify:[...M(),"normal"]}],"justify-items":[{"justify-items":[...U(),"normal"]}],"justify-self":[{"justify-self":["auto",...U()]}],"align-content":[{content:["normal",...M()]}],"align-items":[{items:[...U(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...U(),{baseline:["","last"]}]}],"place-content":[{"place-content":M()}],"place-items":[{"place-items":[...U(),"baseline"]}],"place-self":[{"place-self":["auto",...U()]}],p:[{p:T()}],px:[{px:T()}],py:[{py:T()}],ps:[{ps:T()}],pe:[{pe:T()}],pbs:[{pbs:T()}],pbe:[{pbe:T()}],pt:[{pt:T()}],pr:[{pr:T()}],pb:[{pb:T()}],pl:[{pl:T()}],m:[{m:z()}],mx:[{mx:z()}],my:[{my:z()}],ms:[{ms:z()}],me:[{me:z()}],mbs:[{mbs:z()}],mbe:[{mbe:z()}],mt:[{mt:z()}],mr:[{mr:z()}],mb:[{mb:z()}],ml:[{ml:z()}],"space-x":[{"space-x":T()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":T()}],"space-y-reverse":["space-y-reverse"],size:[{size:X()}],"inline-size":[{inline:["auto",...B()]}],"min-inline-size":[{"min-inline":["auto",...B()]}],"max-inline-size":[{"max-inline":["none",...B()]}],"block-size":[{block:["auto",...L()]}],"min-block-size":[{"min-block":["auto",...L()]}],"max-block-size":[{"max-block":["none",...L()]}],w:[{w:[a,"screen",...X()]}],"min-w":[{"min-w":[a,"screen","none",...X()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[s]},...X()]}],h:[{h:["screen","lh",...X()]}],"min-h":[{"min-h":["screen","lh","none",...X()]}],"max-h":[{"max-h":["screen","lh",...X()]}],"font-size":[{text:["base",r,Jo,Rn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,Zv,Gv]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ga,Te]}],"font-family":[{font:[Xv,qv,t]}],"font-features":[{"font-features":[Te]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,Pe,Te]}],"line-clamp":[{"line-clamp":[tt,"none",Pe,Qd]}],leading:[{leading:[i,...T()]}],"list-image":[{"list-image":["none",Pe,Te]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Pe,Te]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:D()}],"text-color":[{text:D()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...G(),"wavy"]}],"text-decoration-thickness":[{decoration:[tt,"from-font","auto",Pe,Rn]}],"text-decoration-color":[{decoration:D()}],"underline-offset":[{"underline-offset":[tt,"auto",Pe,Te]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:T()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Pe,Te]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Pe,Te]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:K()}],"bg-repeat":[{bg:le()}],"bg-size":[{bg:j()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Tn,Pe,Te],radial:["",Pe,Te],conic:[Tn,Pe,Te]},Qv,Yv]}],"bg-color":[{bg:D()}],"gradient-from-pos":[{from:H()}],"gradient-via-pos":[{via:H()}],"gradient-to-pos":[{to:H()}],"gradient-from":[{from:D()}],"gradient-via":[{via:D()}],"gradient-to":[{to:D()}],rounded:[{rounded:ce()}],"rounded-s":[{"rounded-s":ce()}],"rounded-e":[{"rounded-e":ce()}],"rounded-t":[{"rounded-t":ce()}],"rounded-r":[{"rounded-r":ce()}],"rounded-b":[{"rounded-b":ce()}],"rounded-l":[{"rounded-l":ce()}],"rounded-ss":[{"rounded-ss":ce()}],"rounded-se":[{"rounded-se":ce()}],"rounded-ee":[{"rounded-ee":ce()}],"rounded-es":[{"rounded-es":ce()}],"rounded-tl":[{"rounded-tl":ce()}],"rounded-tr":[{"rounded-tr":ce()}],"rounded-br":[{"rounded-br":ce()}],"rounded-bl":[{"rounded-bl":ce()}],"border-w":[{border:ie()}],"border-w-x":[{"border-x":ie()}],"border-w-y":[{"border-y":ie()}],"border-w-s":[{"border-s":ie()}],"border-w-e":[{"border-e":ie()}],"border-w-bs":[{"border-bs":ie()}],"border-w-be":[{"border-be":ie()}],"border-w-t":[{"border-t":ie()}],"border-w-r":[{"border-r":ie()}],"border-w-b":[{"border-b":ie()}],"border-w-l":[{"border-l":ie()}],"divide-x":[{"divide-x":ie()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ie()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...G(),"hidden","none"]}],"divide-style":[{divide:[...G(),"hidden","none"]}],"border-color":[{border:D()}],"border-color-x":[{"border-x":D()}],"border-color-y":[{"border-y":D()}],"border-color-s":[{"border-s":D()}],"border-color-e":[{"border-e":D()}],"border-color-bs":[{"border-bs":D()}],"border-color-be":[{"border-be":D()}],"border-color-t":[{"border-t":D()}],"border-color-r":[{"border-r":D()}],"border-color-b":[{"border-b":D()}],"border-color-l":[{"border-l":D()}],"divide-color":[{divide:D()}],"outline-style":[{outline:[...G(),"none","hidden"]}],"outline-offset":[{"outline-offset":[tt,Pe,Te]}],"outline-w":[{outline:["",tt,Jo,Rn]}],"outline-color":[{outline:D()}],shadow:[{shadow:["","none",f,Qi,Ji]}],"shadow-color":[{shadow:D()}],"inset-shadow":[{"inset-shadow":["none",l,Qi,Ji]}],"inset-shadow-color":[{"inset-shadow":D()}],"ring-w":[{ring:ie()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:D()}],"ring-offset-w":[{"ring-offset":[tt,Rn]}],"ring-offset-color":[{"ring-offset":D()}],"inset-ring-w":[{"inset-ring":ie()}],"inset-ring-color":[{"inset-ring":D()}],"text-shadow":[{"text-shadow":["none",p,Qi,Ji]}],"text-shadow-color":[{"text-shadow":D()}],opacity:[{opacity:[tt,Pe,Te]}],"mix-blend":[{"mix-blend":[...ee(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ee()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[tt]}],"mask-image-linear-from-pos":[{"mask-linear-from":Ae()}],"mask-image-linear-to-pos":[{"mask-linear-to":Ae()}],"mask-image-linear-from-color":[{"mask-linear-from":D()}],"mask-image-linear-to-color":[{"mask-linear-to":D()}],"mask-image-t-from-pos":[{"mask-t-from":Ae()}],"mask-image-t-to-pos":[{"mask-t-to":Ae()}],"mask-image-t-from-color":[{"mask-t-from":D()}],"mask-image-t-to-color":[{"mask-t-to":D()}],"mask-image-r-from-pos":[{"mask-r-from":Ae()}],"mask-image-r-to-pos":[{"mask-r-to":Ae()}],"mask-image-r-from-color":[{"mask-r-from":D()}],"mask-image-r-to-color":[{"mask-r-to":D()}],"mask-image-b-from-pos":[{"mask-b-from":Ae()}],"mask-image-b-to-pos":[{"mask-b-to":Ae()}],"mask-image-b-from-color":[{"mask-b-from":D()}],"mask-image-b-to-color":[{"mask-b-to":D()}],"mask-image-l-from-pos":[{"mask-l-from":Ae()}],"mask-image-l-to-pos":[{"mask-l-to":Ae()}],"mask-image-l-from-color":[{"mask-l-from":D()}],"mask-image-l-to-color":[{"mask-l-to":D()}],"mask-image-x-from-pos":[{"mask-x-from":Ae()}],"mask-image-x-to-pos":[{"mask-x-to":Ae()}],"mask-image-x-from-color":[{"mask-x-from":D()}],"mask-image-x-to-color":[{"mask-x-to":D()}],"mask-image-y-from-pos":[{"mask-y-from":Ae()}],"mask-image-y-to-pos":[{"mask-y-to":Ae()}],"mask-image-y-from-color":[{"mask-y-from":D()}],"mask-image-y-to-color":[{"mask-y-to":D()}],"mask-image-radial":[{"mask-radial":[Pe,Te]}],"mask-image-radial-from-pos":[{"mask-radial-from":Ae()}],"mask-image-radial-to-pos":[{"mask-radial-to":Ae()}],"mask-image-radial-from-color":[{"mask-radial-from":D()}],"mask-image-radial-to-color":[{"mask-radial-to":D()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":x()}],"mask-image-conic-pos":[{"mask-conic":[tt]}],"mask-image-conic-from-pos":[{"mask-conic-from":Ae()}],"mask-image-conic-to-pos":[{"mask-conic-to":Ae()}],"mask-image-conic-from-color":[{"mask-conic-from":D()}],"mask-image-conic-to-color":[{"mask-conic-to":D()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:K()}],"mask-repeat":[{mask:le()}],"mask-size":[{mask:j()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Pe,Te]}],filter:[{filter:["","none",Pe,Te]}],blur:[{blur:te()}],brightness:[{brightness:[tt,Pe,Te]}],contrast:[{contrast:[tt,Pe,Te]}],"drop-shadow":[{"drop-shadow":["","none",g,Qi,Ji]}],"drop-shadow-color":[{"drop-shadow":D()}],grayscale:[{grayscale:["",tt,Pe,Te]}],"hue-rotate":[{"hue-rotate":[tt,Pe,Te]}],invert:[{invert:["",tt,Pe,Te]}],saturate:[{saturate:[tt,Pe,Te]}],sepia:[{sepia:["",tt,Pe,Te]}],"backdrop-filter":[{"backdrop-filter":["","none",Pe,Te]}],"backdrop-blur":[{"backdrop-blur":te()}],"backdrop-brightness":[{"backdrop-brightness":[tt,Pe,Te]}],"backdrop-contrast":[{"backdrop-contrast":[tt,Pe,Te]}],"backdrop-grayscale":[{"backdrop-grayscale":["",tt,Pe,Te]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[tt,Pe,Te]}],"backdrop-invert":[{"backdrop-invert":["",tt,Pe,Te]}],"backdrop-opacity":[{"backdrop-opacity":[tt,Pe,Te]}],"backdrop-saturate":[{"backdrop-saturate":[tt,Pe,Te]}],"backdrop-sepia":[{"backdrop-sepia":["",tt,Pe,Te]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":T()}],"border-spacing-x":[{"border-spacing-x":T()}],"border-spacing-y":[{"border-spacing-y":T()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Pe,Te]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[tt,"initial",Pe,Te]}],ease:[{ease:["linear","initial",S,Pe,Te]}],delay:[{delay:[tt,Pe,Te]}],animate:[{animate:["none",v,Pe,Te]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[h,Pe,Te]}],"perspective-origin":[{"perspective-origin":F()}],rotate:[{rotate:oe()}],"rotate-x":[{"rotate-x":oe()}],"rotate-y":[{"rotate-y":oe()}],"rotate-z":[{"rotate-z":oe()}],scale:[{scale:me()}],"scale-x":[{"scale-x":me()}],"scale-y":[{"scale-y":me()}],"scale-z":[{"scale-z":me()}],"scale-3d":["scale-3d"],skew:[{skew:Me()}],"skew-x":[{"skew-x":Me()}],"skew-y":[{"skew-y":Me()}],transform:[{transform:[Pe,Te,"","none","gpu","cpu"]}],"transform-origin":[{origin:F()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:De()}],"translate-x":[{"translate-x":De()}],"translate-y":[{"translate-y":De()}],"translate-z":[{"translate-z":De()}],"translate-none":["translate-none"],accent:[{accent:D()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:D()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Pe,Te]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":T()}],"scroll-mx":[{"scroll-mx":T()}],"scroll-my":[{"scroll-my":T()}],"scroll-ms":[{"scroll-ms":T()}],"scroll-me":[{"scroll-me":T()}],"scroll-mbs":[{"scroll-mbs":T()}],"scroll-mbe":[{"scroll-mbe":T()}],"scroll-mt":[{"scroll-mt":T()}],"scroll-mr":[{"scroll-mr":T()}],"scroll-mb":[{"scroll-mb":T()}],"scroll-ml":[{"scroll-ml":T()}],"scroll-p":[{"scroll-p":T()}],"scroll-px":[{"scroll-px":T()}],"scroll-py":[{"scroll-py":T()}],"scroll-ps":[{"scroll-ps":T()}],"scroll-pe":[{"scroll-pe":T()}],"scroll-pbs":[{"scroll-pbs":T()}],"scroll-pbe":[{"scroll-pbe":T()}],"scroll-pt":[{"scroll-pt":T()}],"scroll-pr":[{"scroll-pr":T()}],"scroll-pb":[{"scroll-pb":T()}],"scroll-pl":[{"scroll-pl":T()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Pe,Te]}],fill:[{fill:["none",...D()]}],"stroke-w":[{stroke:[tt,Jo,Rn,Qd]}],stroke:[{stroke:["none",...D()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}});function V(...e){return tw(Ud(e))}const rw=["richtext","multiselect","radio","checkboxgroup","signature"],nw=3;function Qo(e){const t=e.position.rowSpan??1;if(e.type==="billingGrid"||e.type==="table")return Math.max(1,t);if(e.type==="file"||e.type==="camera"||e.type==="photoChoice"||e.type==="textarea")return Math.max(t,1);if(e.type==="status")return Math.max(t,4);if(e.type==="selectablelist")return Math.max(nw,t);if(e.type==="radio"||e.type==="checkboxgroup"){const r=e.properties?.options;return(Array.isArray(r)?r.length:0)<=2?1:Math.max(t,2)}return rw.includes(e.type)?Math.max(t,2):t}function lu(e,t){if(e.type==="table"||e.type==="billingGrid"){const i=e.position.columnSpan??t??1;return t!=null?Math.min(i,t):i}if(e.type!=="radio"&&e.type!=="checkboxgroup"){const i=e.position.columnSpan??1;return t!=null?Math.min(i,t):i}const r=e.properties?.options,n=Array.isArray(r)?r.length:0,o=Math.max(1,Math.ceil(n/2));return t!=null?Math.min(o,t):o}function fo(e){const t=e?.size??"md",r=e?.variant??"default";return V(t==="sm"?"h-8 text-sm":t==="lg"?"min-h-12 text-lg py-2":"h-10 md:text-sm",r==="filled"?"border-transparent bg-muted shadow-none":r==="outlined"?"border-2 bg-transparent":"")}function cu(e){const t=e?.size??"md",r=e?.variant??"default";return V(t==="sm"?"min-h-[48px] text-sm":t==="lg"?"min-h-[72px] text-lg":"min-h-[56px]",r==="filled"?"border-transparent bg-muted shadow-none":r==="outlined"?"border-2 bg-transparent":"")}function ow(e){switch(e){case"left":return"flex flex-row items-start gap-4";case"right":return"flex flex-row-reverse items-start gap-4";case"center":return"flex flex-col items-center text-center w-full";case"floating":return"relative flex flex-col gap-2 w-full min-w-0";default:return"flex flex-col gap-2 w-full min-w-0"}}function iw(e,t){const r=t?"text-destructive":"";switch(e){case"left":return`shrink-0 w-32 pt-2 text-right text-sm font-medium ${r}`;case"right":return`shrink-0 w-32 pt-2 text-left text-sm font-medium ${r}`;case"center":return`w-full text-center text-sm font-medium ${r}`;case"floating":return`absolute left-3 top-2 z-[1] origin-[0] -translate-y-4 scale-75 bg-background px-1 text-sm ${r}`;default:return`text-sm font-medium ${r}`}}function sw(e){switch(e){case"left":case"right":return"flex-1 min-w-0 min-h-0 flex flex-col";case"center":return"w-full max-w-full flex flex-col flex-1 min-h-0";case"floating":return"flex flex-col flex-1 min-h-0 w-full pt-4";default:return"flex flex-col flex-1 min-h-0 w-full min-w-0"}}function Zi(e){return!e||e.widthMode==="full"?100:typeof e.widthPercent=="number"&&!Number.isNaN(e.widthPercent)?Math.min(100,Math.max(1,Math.round(e.widthPercent))):(e.widthMode==="percent",100)}function Ya(e){const t=Zi(e);return{width:t>=100?"100%":`${t}%`,maxWidth:"100%"}}function aw(e){return Ya(e)}function Xa(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t==="start"||t==="center"||t==="end"||t==="stretch"?t:null}function Ja(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t==="start"||t==="center"||t==="end"?t:null}function Fr(e){if(!e)return"start";const t=Xa(e.horizontalAlign);if(t)return t;const r=Xa(e.contentAlign);if(r)return r;const n=Xa(e.cellAlign);return n||"start"}function Zo(e){if(e?.verticalAlign!=null)return e.verticalAlign;const t=e?.cellJustify;return t==="center"?"center":t==="end"?"end":t==="stretch"?"stretch":t==="start"?"start":"stretch"}function es(e){switch(e){case"center":return"items-center";case"end":return"items-end";case"stretch":return"items-stretch";default:return"items-start"}}function Qa(e){switch(e){case"center":return"justify-center";case"end":return"justify-end";case"stretch":return"justify-stretch";default:return"justify-start"}}function ei(e){const t=Ja(e.appearance?.contentVerticalAlign);if(t!==null)switch(t){case"center":return"justify-center";case"end":return"justify-end";default:return"justify-start"}return Qa(Za(e))}const lw=ei;function ts(e){if(e.type==="billingGrid"||e.type==="table"||Qo(e)>1)return!0;const t=Ja(e.appearance?.contentVerticalAlign);if(t==="center"||t==="end")return!1;if(t==="start")return!0;const r=Za(e);return r!=="center"&&r!=="end"}function du(e){const t=e[0];if(!t)return el(void 0);if(e.length===1)return el(t);const r=Fr(t.appearance);return V("flex flex-col min-h-0 h-full w-full",es(r),"justify-start")}function uu(e){const t=Fr(e),r=Zo(e);return V("flex flex-col min-h-0 h-full w-full",es(t),Qa(r))}function fu(e){if(Zi(e)>=100)return"";const r=Fr(e);return r==="center"?"mx-auto":r==="end"?"ml-auto":""}function pu(e){if(Zi(e)>=100)return"w-full";const r=Fr(e);return r==="center"||r==="end"?"min-w-0":r==="stretch"?"min-w-0 self-stretch":"min-w-0 self-start"}function mu(e){return e?e.widthMode==="full"||e.widthMode==="percent"||typeof e.widthPercent=="number"&&!Number.isNaN(e.widthPercent):!1}function po(e){return(e.type==="button"||e.type==="editButton")&&!mu(e.appearance)}function hu(e){return po(e)?Fr(e.appearance)==="stretch"?{width:"100%",maxWidth:"100%",minWidth:0}:{width:"auto",maxWidth:"100%"}:Ya(e.appearance)}function gu(e){return hu(e)}function yu(e){if(po(e))switch(Fr(e.appearance)){case"center":return"self-center";case"end":return"self-end";case"stretch":return"self-stretch";default:return"self-start"}return pu(e.appearance)}function bu(e){return e?e.verticalAlign!=null||e.cellJustify!=null:!1}function Za(e){return e.type!=="button"&&e.type!=="editButton"||bu(e.appearance)?Zo(e.appearance):"start"}function el(e){if(!e)return uu(void 0);const t=Fr(e.appearance);return V("flex flex-col min-h-0 h-full w-full",es(t),ei(e))}function cw(e,t){const r={};e!==void 0&&(r.cellAlign=e),t!==void 0&&(r.cellJustify=t);const o=e===void 0&&t===void 0?void 0:r;return V(es(Fr(o)),Qa(Zo(o)))}const tl=w.createContext({gridStretch:!1});function ti(){return w.useContext(tl)}const vu=e=>{let t;const r=new Set,n=(u,f)=>{const l=typeof u=="function"?u(t):u;if(!Object.is(l,t)){const p=t;t=f??(typeof l!="object"||l===null)?l:Object.assign({},t,l),r.forEach(g=>g(t,p))}},o=()=>t,a={setState:n,getState:o,getInitialState:()=>c,subscribe:u=>(r.add(u),()=>r.delete(u))},c=t=e(n,o,a);return a},dw=(e=>e?vu(e):vu),uw=e=>e;function rl(e,t=uw){const r=w.useSyncExternalStore(e.subscribe,w.useCallback(()=>t(e.getState()),[e,t]),w.useCallback(()=>t(e.getInitialState()),[e,t]));return w.useDebugValue(r),r}const wu=e=>{const t=dw(e),r=n=>rl(t,n);return Object.assign(r,t),r},Su=(e=>e?wu(e):wu),fw=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,pw=/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/,mw=/^\+?[\d\s-()]{10,}$/,hw={required:e=>e==null?!1:typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.length>0:typeof e=="boolean"?e===!0:!0,minLength:(e,t)=>{if(typeof e!="string")return!0;const r=t.value;return e.length>=r},maxLength:(e,t)=>{if(typeof e!="string")return!0;const r=t.value;return e.length<=r},min:(e,t)=>{if(typeof e!="number")return!0;const r=t.value;return e>=r},max:(e,t)=>{if(typeof e!="number")return!0;const r=t.value;return e<=r},pattern:(e,t)=>{if(typeof e!="string")return!0;const r=t.value,n=t.params?.flags||"";return new RegExp(r,n).test(e)},email:e=>typeof e!="string"||!e?!0:fw.test(e),url:e=>typeof e!="string"||!e?!0:pw.test(e),phone:e=>typeof e!="string"||!e?!0:mw.test(e),date:e=>{if(!e)return!0;const t=new Date(e);return!isNaN(t.getTime())},dateRange:(e,t)=>{if(!e)return!0;const r=new Date(e);if(isNaN(r.getTime()))return!1;const n=t.value,o=new Date;if(o.setHours(0,0,0,0),n.min){const i=n.min==="today"?o:new Date(n.min);if(r<i)return!1}if(n.max){const i=n.max==="today"?o:new Date(n.max);if(r>i)return!1}return!0},fileSize:(e,t)=>{if(!e)return!0;const r=t.value;return e instanceof File?e.size<=r:Array.isArray(e)?e.every(n=>n.size<=r):!0},fileType:(e,t)=>{if(!e)return!0;const r=t.value,n={"text/csv":[".csv"],"application/vnd.ms-excel":[".xls"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":[".xlsx"],"application/pdf":[".pdf"],"image/png":[".png"],"image/jpeg":[".jpg",".jpeg"],"image/gif":[".gif"],"image/webp":[".webp"]},o=i=>r.some(s=>{if(s.endsWith("/*")){const u=s.replace("/*","");if(i.type.startsWith(u))return!0}else if(i.type===s)return!0;const a=i.name.toLowerCase(),c=n[s];return c?c.some(u=>a.endsWith(u)):s.startsWith(".")?a.endsWith(s.toLowerCase()):!1});return e instanceof File?o(e):Array.isArray(e)?e.every(i=>o(i)):!0},allowLetters:(e,t)=>typeof e!="string"||!e||t.value?!0:!/[a-zA-Z]/.test(e),allowNumbers:(e,t)=>typeof e!="string"||!e||t.value?!0:!/[0-9]/.test(e),allowSpecialChars:(e,t)=>typeof e!="string"||!e||t.value?!0:!/[^a-zA-Z0-9\s]/.test(e),minLetters:(e,t)=>{if(typeof e!="string"||!e)return!0;const r=t.value;return(e.match(/[a-zA-Z]/g)||[]).length>=r},maxLetters:(e,t)=>{if(typeof e!="string"||!e)return!0;const r=t.value;return(e.match(/[a-zA-Z]/g)||[]).length<=r},minNumbers:(e,t)=>{if(typeof e!="string"||!e)return!0;const r=t.value;return(e.match(/[0-9]/g)||[]).length>=r},maxNumbers:(e,t)=>{if(typeof e!="string"||!e)return!0;const r=t.value;return(e.match(/[0-9]/g)||[]).length<=r},minSpecialChars:(e,t)=>{if(typeof e!="string"||!e)return!0;const r=t.value;return(e.match(/[^a-zA-Z0-9\s]/g)||[]).length>=r},maxSpecialChars:(e,t)=>{if(typeof e!="string"||!e)return!0;const r=t.value;return(e.match(/[^a-zA-Z0-9\s]/g)||[]).length<=r},custom:(e,t,r)=>!0,async:()=>!0};function rn(e,t,r={}){const n=hw[t.type];if(!n)return!0;const o=n(e,t,r);return o===!1?t.message||gw(t):typeof o=="string"?o:!0}function gw(e){return{required:"This field is required",minLength:`Must be at least ${e.value} characters`,maxLength:`Must be at most ${e.value} characters`,min:`Must be at least ${e.value}`,max:`Must be at most ${e.value}`,pattern:"Invalid format",email:"Please enter a valid email address",url:"Please enter a valid URL",phone:"Please enter a valid phone number",date:"Please enter a valid date",dateRange:"Date is out of allowed range",fileSize:`File size must be less than ${yw(e.value)}`,fileType:"File type is not allowed",allowLetters:"Letters are not allowed in this field",allowNumbers:"Numbers are not allowed in this field",allowSpecialChars:"Special characters are not allowed in this field",minLetters:`Must contain at least ${e.value} letters`,maxLetters:`Must contain at most ${e.value} letters`,minNumbers:`Must contain at least ${e.value} numbers`,maxNumbers:`Must contain at most ${e.value} numbers`,minSpecialChars:`Must contain at least ${e.value} special characters`,maxSpecialChars:`Must contain at most ${e.value} special characters`,custom:"Validation failed",async:"Validation failed"}[e.type]||"Invalid value"}function yw(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}const bw=10;function rs(e){const t=e.properties;return t?.maxFiles!=null&&t.maxFiles>0?Math.floor(t.maxFiles):t?.multiple===!0?bw:1}function xu(e){return typeof e=="object"&&e!==null&&"url"in e&&typeof e.url=="string"&&e.url.length>0}function Au(e){try{return e.split("?")[0].split("/").filter(Boolean).pop()||e}catch{return e}}function ns(e){if(e==null)return[];if(typeof e=="string")return e.startsWith("http")?[{url:e,name:Au(e)}]:[];if(e instanceof File)return[e];if(Array.isArray(e)){const t=[];for(const r of e)r instanceof File?t.push(r):typeof r=="string"&&r.startsWith("http")?t.push({url:r,name:Au(r)}):xu(r)&&t.push(r);return t}return xu(e)?[e]:[]}function vw(e,t){return e.slice(0,t)}function nl(e,t){const r=vw(e,t);return r.length===0?null:t===1?r[0]??null:r}function ww(e){return ns(e).length}function Sw(e){return e==="file"||e==="camera"||e==="photoChoice"}function ol(e,t){if(!Sw(e.type))return;const r=rs(e);if(ww(t)>r)return`Maximum ${r} file(s) allowed`}const xw=4,Aw=2,Cw=10;function Cu(e){const t=e.properties?.otpLength??e.metadata?.otpLength,r=typeof t=="number"?t:Number(t);return Number.isFinite(r)?Math.min(Cw,Math.max(Aw,Math.round(r))):xw}function Ew(e,t){const r=String(e??"").replace(/\s/g,"").slice(0,t).split("");for(;r.length<t;)r.push("");return r}function kw(e){return e.join("").replace(/\s/g,"")}function il(e,t){if(e.type!=="otp")return;const r=String(t??"").trim();if(!r)return;const n=Cu(e);if(r.length!==n)return`Please enter a ${n}-digit OTP`}class os{static functions={SUM:(...t)=>t.flat().filter(n=>typeof n=="number").reduce((n,o)=>n+o,0),AVG:(...t)=>{const r=t.flat().filter(n=>typeof n=="number");return r.length===0?0:r.reduce((n,o)=>n+o,0)/r.length},MIN:(...t)=>{const r=t.flat().filter(n=>typeof n=="number");return r.length>0?Math.min(...r):0},MAX:(...t)=>{const r=t.flat().filter(n=>typeof n=="number");return r.length>0?Math.max(...r):0},ROUND:(t,r=0)=>{const n=Number(t);if(isNaN(n))return 0;const o=Math.pow(10,Number(r));return Math.round(n*o)/o},FLOOR:t=>Math.floor(Number(t)||0),CEIL:t=>Math.ceil(Number(t)||0),ABS:t=>Math.abs(Number(t)||0),CONCAT:(...t)=>t.map(String).join(""),UPPER:t=>String(t).toUpperCase(),LOWER:t=>String(t).toLowerCase(),TRIM:t=>String(t).trim(),LEN:t=>String(t).length,SUBSTR:(t,r,n)=>{const o=String(t),i=Number(r),s=n!==void 0?Number(n):void 0;return o.substring(i,s!==void 0?i+s:void 0)},IF:(t,r,n)=>t?r:n,IFEMPTY:(t,r)=>t==null||t===""?r:t,ISNUMBER:t=>typeof t=="number"&&!isNaN(t),ISEMPTY:t=>t==null?!0:typeof t=="string"?t.trim()==="":Array.isArray(t)?t.length===0:!1,TODAY:()=>new Date().toISOString().split("T")[0],NOW:()=>new Date().toISOString(),YEAR:t=>{const r=new Date(t);return isNaN(r.getTime())?null:r.getFullYear()},MONTH:t=>{const r=new Date(t);return isNaN(r.getTime())?null:r.getMonth()+1},DAY:t=>{const r=new Date(t);return isNaN(r.getTime())?null:r.getDate()},DATEDIFF:(t,r,n="days")=>{const o=new Date(t),i=new Date(r);if(isNaN(o.getTime())||isNaN(i.getTime()))return null;const a=(i.getTime()-o.getTime())/(1e3*60*60*24);switch(n){case"years":return a/365;case"months":return a/30;case"weeks":return a/7;case"hours":return a*24;case"minutes":return a*24*60;default:return a}},COUNT:t=>Array.isArray(t)?t.length:t?1:0,FIRST:t=>Array.isArray(t)?t[0]:t,LAST:t=>Array.isArray(t)?t[t.length-1]:t,SUMFIELD:(...t)=>{const r=t[0],n=t[1];return!Array.isArray(r)||typeof n!="string"?0:r.reduce((o,i)=>{if(typeof i=="object"&&i!==null){const s=i[n];return o+(Number(s)||0)}return o},0)}};calculate(t,r){try{const{fields:n,currentValue:o,previousValue:i}=r,s={...n};for(const l in s){const p=s[l];(p==null||p==="")&&(s[l]="")}const a={fields:s,currentValue:o,previousValue:i,...os.functions},c=Object.keys(a),u=Object.values(a),f=new Function(...c,`return ${t}`)(...u);if(f==null)return"";if(typeof f=="string"){if(f.includes("undefined"))return"";const l=f.trim();return l===""||/^\s+$/.test(f)?"":l}return f}catch{return""}}calculateAll(t,r){const n={...r};for(const o of t){const i={fields:n,currentValue:n[o.field],previousValue:r[o.field]},s=this.calculate(o.formula,i);n[o.field]=s===null?"":s}return n}validateFormula(t){try{return new Function("fields",`return ${t}`),{valid:!0}}catch(r){return{valid:!1,error:r instanceof Error?r.message:"Invalid formula"}}}getAvailableFunctions(){return[{name:"SUM",description:"Sum of values"},{name:"AVG",description:"Average of values"},{name:"MIN",description:"Minimum value"},{name:"MAX",description:"Maximum value"},{name:"ROUND",description:"Round to decimal places"},{name:"IF",description:"Conditional value"},{name:"CONCAT",description:"Concatenate strings"},{name:"TODAY",description:"Current date"},{name:"DATEDIFF",description:"Difference between dates"},{name:"COUNT",description:"Count of items"},{name:"SUMFIELD",description:"Sum field in array"}]}}const Eu=new os;function ku(e){if(e==null||e==="")return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:is(e);if(typeof e=="string"){const t=e.trim();if(!t)return null;const r=t.match(/^(\d{4})-(\d{2})-(\d{2})/);if(r){const o=new Date(Number(r[1]),Number(r[2])-1,Number(r[3]));return Number.isNaN(o.getTime())?null:o}const n=new Date(t);return Number.isNaN(n.getTime())?null:is(n)}return null}function is(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function Nw(e,t=new Date){const r=is(e),n=is(t);if(n<r)return{years:0,months:0,days:0};let o=n.getFullYear()-r.getFullYear(),i=n.getMonth()-r.getMonth(),s=n.getDate()-r.getDate();if(s<0){i-=1;const a=new Date(n.getFullYear(),n.getMonth(),0).getDate();s+=a}return i<0&&(o-=1,i+=12),{years:Math.max(0,o),months:Math.max(0,i),days:Math.max(0,s)}}function sl(e){if(e.type!=="number")return;const t=e.properties?.deriveFromDate;if(!(!t?.sourceFieldName||!t.part))return t}function Pr(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(0,t):e}function al(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(t):null}function _w(e,t){const r=al(e);return r?`${t.sourceFieldName}${r}`:t.sourceFieldName}function Nu(e,t,r){const n=al(t);if(n)return[`${e}${n}`];const o=new Set([e]),i=`${e}__addmore__`;for(const s of Object.keys(r))(s===e||s.startsWith(i))&&o.add(s);return[...o]}function Tw(e,t,r){const n=r?_w(r,e):e.sourceFieldName,o=ku(t[n]);if(!o)return null;const i=e.referenceDate==="today"||e.referenceDate==null?new Date:ku(t[e.referenceDate])??new Date;return Nw(o,i)[e.part]}function _u(e,t){const r=sl(e);return r?Pr(r.sourceFieldName)===Pr(t):!1}function ll(e,t,r,n){const o={...t},i=n?Pr(n):void 0;for(const s of e){if(s.type!=="number")continue;const a=sl(s);if(!a||!s.name||i&&Pr(a.sourceFieldName)!==i)continue;const c=n??a.sourceFieldName,u=Nu(s.name,c,o);for(const f of u){if(r.has(f))continue;const l=Tw(a,o,f);o[f]=l}}return o}function Fw(e,t,r,n){const o={...t},i=Pr(n);for(const s of e){if(!_u(s,i)||!s.name)continue;const a=Nu(s.name,n,o);for(const c of a)r.delete(c),o[c]=null}return o}function Tu(e,t){const r=Pr(t);return e.some(n=>_u(n,r))}function Fu(e){if(e.apidata&&typeof e.apidata=="object")return e.apidata;if(e.metadata)try{const t=typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata;if(t.apiEndpoint||t.apiKey||t.valueSource==="api")return{apiKey:t.apiKey,valueSource:t.valueSource,apiEndpoint:t.apiEndpoint,apiAutoDetect:t.apiAutoDetect,apiLabelField:t.apiLabelField,apiValueField:t.apiValueField,apiMethod:t.apiMethod,apiRealtime:t.apiRealtime,apiQueryParams:t.apiQueryParams,apiClientFilter:t.apiClientFilter}}catch{}return null}function cl(e,t,r,n){let o=dl(e,r);return n&&(o=Gn(o,t,r)),o}function dl(e,t){return e.replace(/\{(?:ctx:|\@)(\w+)\}/g,(r,n)=>t?.[n]!==void 0&&t[n]!==null?String(t[n]):r)}function Gn(e,t,r){let n=e.replace(/\{(?:ctx:|\@)(\w+)\}/g,(o,i)=>r?.[i]!==void 0&&r[i]!==null?String(r[i]):o);return n=n.replace(/\{(\w+)\}/g,(o,i)=>{if(o.includes("ctx:")||o.includes("@"))return o;let s=t[i];if(s==null||s===""){const a=Object.keys(t).find(c=>c.toLowerCase()===i.toLowerCase());a&&(s=t[a])}return s!=null&&s!==""?String(s):o}),n}function mo(e,t){const r=e.match(/\{(\w+)\}/g)||[],n=[];t?.custom&&t.custom.forEach(({value:i})=>{if(i){const s=i.match(/\{(\w+)\}/g)||[];n.push(...s.filter(a=>!a.includes("ctx:")&&!a.includes("@")))}});const o=r.filter(i=>!i.includes("ctx:")&&!i.includes("@"));return new Set([...o.map(i=>i.replace(/[{}]/g,"")),...n.map(i=>i.replace(/[{}]/g,""))])}function Pw(e,t){const r=e[t];return r==null||r===""}function ss(e){const{apiEndpoint:t,apiMethod:r="GET",apiQueryParams:n={},formValues:o,submissionContext:i,apiRealtime:s,additionalRequiredFieldNames:a=[],excludeFormFieldNames:c=[]}=e,u=(r||"GET").toLowerCase(),f=mo(t,n),l=new Set((c||[]).filter(v=>typeof v=="string"&&v.length>0)),p=new Set((a||[]).filter(v=>typeof v=="string"&&v.length>0)),g=new Set([...f,...p]);let m=!1;for(const v of g){const A=!!(s&&f.has(v)),x=p.has(v);if((A||x)&&Pw(o,v)){m=!0;break}}if(m)return{blocked:!0,url:t,postBodyBase:null};let h=t;const y=t.match(/\{(\w+)\}/g)||[];if(h=dl(h,i),s&&(h=Gn(h,o,i)),n&&Object.keys(n).length>0){const v=n,A=[];if(v.limit){let x=v.limit;s&&(x=Gn(x,o,i)),A.push(`_limit=${encodeURIComponent(x)}`)}if(v.page){let x=v.page;s&&(x=Gn(x,o,i)),A.push(`page=${encodeURIComponent(x)}`)}if(v.sort){let x=v.sort;s&&(x=Gn(x,o,i)),A.push(`sort=${encodeURIComponent(x)}`)}if(v.orderBy){let x=v.orderBy;s&&(x=Gn(x,o,i)),A.push(`orderBy=${encodeURIComponent(x)}`)}if(v.custom?.length&&v.custom.forEach(({key:x,value:F})=>{if(!x||!F)return;let k=dl(F,i);s&&(k=Gn(k,o,i)),k.match(/\{[^}]+\}/)?k.match(/\{(?!ctx:|\@)(\w+)\}/g)||A.push(`${encodeURIComponent(x)}=`):A.push(`${encodeURIComponent(x)}=${encodeURIComponent(k)}`)}),A.length>0){const x=h.includes("?")?"&":"?";h=`${h}${x}${A.join("&")}`}}if(s&&Object.keys(o).length>0&&u==="get"){const v=k=>k.replace(/\{/g,"").replace(/\}/g,""),A=[];for(const k of n.custom||[])if(k.value){const N=k.value.match(/\{(\w+)\}/g)||[];A.push(...N.map(v))}const x=new Set([...y.map(v),...A]),F={};Object.keys(o).forEach(k=>{!x.has(k)&&!l.has(k)&&(F[k]=o[k])}),Object.keys(F).length>0&&(h=`${h}${h.includes("?")?"&":"?"}${new URLSearchParams(F).toString()}`)}let S=null;if(["post","put","patch"].includes(u))if(s&&Object.keys(o).length>0){S={...o};for(const v of l)delete S[v]}else{S={...o||{}};for(const v of l)delete S[v]}return{blocked:!1,url:h,postBodyBase:S}}const Iw=new Set(["select","multiselect","asyncsearch"]);function Ow(e){return e?.type==="multiselect"?[]:""}function Pu(e){if(!Iw.has(e.type))return[];const t=e.properties??{},r=Fu(e),n=new Set,o=r?.apiClientFilter?.matchField?.trim()||t.apiClientFilter?.matchField?.trim();o&&n.add(o);const i=[...Array.isArray(t.dependentFields)?t.dependentFields:[],...Array.isArray(r?.dependentFields)?r.dependentFields:[]];for(const u of i)typeof u=="string"&&u.trim()&&n.add(u.trim());const s=r?.apiEndpoint||t.apiEndpoint,a=r?.apiRealtime??t.apiRealtime,c=r?.apiQueryParams||t.apiQueryParams;if(s&&a)for(const u of mo(s,c))n.add(u);return[...n]}function Mw(e,t){const r=Pr(t);return Pu(e).some(n=>Pr(n)===r)}function Lw(e,t){const r=Pr(t);return e.some(n=>Mw(n,r))}function Dw(e){const t=new Map;for(const r of e){const n=r.name;if(n)for(const o of Pu(r)){const i=Pr(o),s=t.get(i)??new Set;s.add(n),t.set(i,s)}}return t}function Bw(e,t,r){const n=al(t);if(n)return[`${e}${n}`];const o=new Set([e]),i=`${e}__addmore__`;for(const s of Object.keys(r))(s===e||s.startsWith(i))&&o.add(s);return[...o]}function $w(e,t){return e===t?!0:Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((r,n)=>r===t[n]):!1}function jw(e,t,r){const n=Dw(e),o=Pr(r),i=new Set,s=[o];for(;s.length>0;){const u=s.shift(),f=n.get(u);if(f)for(const l of f)i.has(l)||(i.add(l),s.push(l))}const a={...t},c=[];for(const u of i){const f=e.find(p=>p.name===u),l=Ow(f);for(const p of Bw(u,r,a))$w(a[p],l)||c.push(p),a[p]=l}return{values:a,clearedKeys:c}}function ul(e,t){const r=t instanceof Set?t:new Set(t);if(e.size!==r.size)return!1;for(const n of e)if(!r.has(n))return!1;return!0}function Iu(){return Su((e,t)=>({schema:null,values:{},initialValues:{},errors:{},touched:{},isValidating:!1,isSubmitting:!1,submitCount:0,isValid:!0,currentStep:0,totalSteps:1,completedSteps:new Set,visibleFields:new Set,enabledFields:new Set,requiredFields:new Set,readOnlyFields:new Set,editableFields:new Set,formDisabled:!1,derivedFieldDirty:new Set,draftId:null,setSchema:(r,n)=>{const o=t(),i=o.schema!=null&&o.schema.id===r.id,s=n?.forceReset===!0,a={},c=new Set,u=new Set,f=new Set;r.fields.forEach(x=>{const F=x.name||x.key||x.id;F&&(x.defaultValue!==void 0&&(x.type==="multiselect"?a[F]=Array.isArray(x.defaultValue)?x.defaultValue:x.defaultValue!=null&&x.defaultValue!==""?[String(x.defaultValue)]:[]:a[F]=x.defaultValue),x.hidden||c.add(F),x.disabled||u.add(F),x.validation?.some(k=>k.type==="required")&&f.add(F))});const l=r.steps?.length||1,p=typeof n?.initialStepIndex=="number",g=p?Math.max(0,Math.min(n.initialStepIndex,Math.max(0,l-1))):0,m=new Set;for(let x=0;x<g;x++)m.add(x);const h=[];r.fields.forEach(x=>{const F=x.properties;F?.valueSource==="calculated"&&F?.formula&&h.push({field:x.name,formula:F.formula})});const y=h.length>0?Eu.calculateAll(h,a):{},S=ll(r.fields,{...a,...y},new Set),A=i&&!(s||p)?{...S,...o.values}:S;e({schema:r,values:A,initialValues:S,errors:{},touched:{},currentStep:g,totalSteps:l,completedSteps:m,visibleFields:c,enabledFields:u,requiredFields:f,readOnlyFields:new Set,editableFields:new Set,formDisabled:!1,derivedFieldDirty:s||!i?new Set:o.derivedFieldDirty,isValid:!0,draftId:null})},setFieldValue:(r,n,o)=>{const i=t(),s=i.schema,a=o?.source??"user";let c=new Set(i.derivedFieldDirty);const u=i.values[r];let f={...i.values,[r]:n},l=[];if(s){const p=Pr(r),g=s.fields.find(S=>S.name===p);a==="user"&&g&&sl(g)&&c.add(r);const m=n==null||n===""||Array.isArray(n)&&n.length===0;if(Tu(s.fields,r)&&m?f=Fw(s.fields,f,c,r):Tu(s.fields,r)&&(f=ll(s.fields,f,c,r)),a==="user"&&u!==n&&!(Array.isArray(u)&&Array.isArray(n)&&u.length===n.length&&u.every((S,v)=>S===n[v]))&&Lw(s.fields,r)){const S=jw(s.fields,f,r);f=S.values,l=S.clearedKeys}const y=[];s.fields.forEach(S=>{const v=S.properties;v?.valueSource==="calculated"&&v?.formula&&(v.formulaSteps??[]).some(x=>x.type==="field"&&x.fieldName===r)&&y.push({field:S.name,formula:v.formula})}),y.length>0&&(f={...f,...Eu.calculateAll(y,f)})}e({values:f,derivedFieldDirty:c}),l.length>0&&e(p=>{const g={...p.errors};for(const m of l)delete g[m];return Object.keys(g).length===Object.keys(p.errors).length?p:{errors:g}}),s?.config.validateOnChange?t().validateField(r):e(p=>{const g={...p.errors};return delete g[r],{errors:g}})},setFieldTouched:(r,n=!0)=>{e(i=>({touched:{...i.touched,[r]:n}}));const o=t().schema;n&&o?.config.validateOnBlur&&t().validateField(r)},setFieldError:(r,n)=>{e(o=>{const i=!!o.errors[r];if(!n&&!i||n&&o.errors[r]===n)return o;const s={...o.errors};return n?s[r]=n:delete s[r],{errors:s,isValid:Object.keys(s).length===0}})},setValues:r=>{const n=t(),o=n.schema;if(!o){e({values:r});return}const i=ll(o.fields,r,n.derivedFieldDirty);e({values:i})},setErrors:r=>e({errors:r,isValid:Object.keys(r).length===0}),resetForm:()=>{const{initialValues:r}=t();e({values:{...r},errors:{},touched:{},currentStep:0,completedSteps:new Set,derivedFieldDirty:new Set,isValid:!0,submitCount:0})},clearForm:()=>{e({schema:null,values:{},initialValues:{},errors:{},touched:{},currentStep:0,totalSteps:1,completedSteps:new Set,visibleFields:new Set,enabledFields:new Set,requiredFields:new Set,readOnlyFields:new Set,editableFields:new Set,formDisabled:!1,derivedFieldDirty:new Set,isValid:!0,submitCount:0,draftId:null})},validateField:async r=>{const{schema:n,values:o}=t();if(!n)return;const i=n.fields.find(a=>a.name===r);if(!i)return;e({isValidating:!0});let s;if(i.validation)for(const a of i.validation){const c=rn(o[r],a,o);if(typeof c=="string"){s=c;break}}if(!s){const a=ol(i,o[r]);a&&(s=a)}return!s&&i.type==="otp"&&(s=il(i,o[r])),e(a=>{const c={...a.errors};return s?c[r]=s:delete c[r],{errors:c,isValid:Object.keys(c).length===0,isValidating:!1}}),s},validateForm:async()=>{const{schema:r,values:n,visibleFields:o,requiredFields:i}=t();if(!r)return!1;e({isValidating:!0});const s={};for(const a of r.fields)if(o.has(a.name)){if(a.validation)for(const c of a.validation){if(c.type==="required"&&!i.has(a.name))continue;const u=rn(n[a.name],c,n);if(typeof u=="string"){s[a.name]=u;break}}if(!s[a.name]){const c=ol(a,n[a.name]);c&&(s[a.name]=c)}if(!s[a.name]){const c=il(a,n[a.name]);c&&(s[a.name]=c)}}return e({errors:s,isValid:Object.keys(s).length===0,isValidating:!1}),Object.keys(s).length===0},validateStep:async r=>{const{schema:n,values:o,visibleFields:i}=t();if(!n?.steps)return!0;const s=n.steps[r];if(!s)return!0;e({isValidating:!0});const a={};for(const c of s.fields){const u=n.fields.find(f=>f.name===c);if(!(!u||!i.has(u.name))){if(u.validation)for(const f of u.validation){const l=rn(o[u.name],f,o);if(typeof l=="string"){a[u.name]=l;break}}if(!a[u.name]){const f=ol(u,o[u.name]);f&&(a[u.name]=f)}if(!a[u.name]){const f=il(u,o[u.name]);f&&(a[u.name]=f)}}}return e(c=>({errors:{...c.errors,...a},isValid:Object.keys(a).length===0,isValidating:!1})),Object.keys(a).length===0},nextStep:async()=>{const{currentStep:r,totalSteps:n,schema:o}=t();return o?.steps?.[r]?.validation==="onNext"&&!await t().validateStep(r)?!1:r<n-1?(e(s=>({currentStep:r+1,completedSteps:new Set([...s.completedSteps,r])})),!0):!1},prevStep:()=>{const{currentStep:r}=t();r>0&&e({currentStep:r-1})},goToStep:r=>{const{totalSteps:n,completedSteps:o,currentStep:i}=t();r>=0&&r<n&&(r<=i||o.has(r-1))&&e({currentStep:r})},setSubmitting:r=>e({isSubmitting:r}),incrementSubmitCount:()=>e(r=>({submitCount:r.submitCount+1})),updateVisibility:r=>{e(n=>{const o=new Set(r);return ul(n.visibleFields,o)?n:{visibleFields:o}})},updateEnabled:r=>{e(n=>{const o=new Set(r);return ul(n.enabledFields,o)?n:{enabledFields:o}})},updateRequired:r=>{e(n=>{const o=new Set(r);return ul(n.requiredFields,o)?n:{requiredFields:o}})},updateReadOnly:r=>e({readOnlyFields:new Set(r)}),updateEditable:r=>e({editableFields:new Set(r)}),updateFormDisabled:r=>e({formDisabled:r}),saveDraft:()=>{const{schema:r,values:n}=t();if(!r)return;const o=`formsmith_draft_${r.id}`;try{localStorage.setItem(o,JSON.stringify({values:n,savedAt:new Date().toISOString()})),e({draftId:o})}catch{}},loadDraft:()=>{const{schema:r}=t();if(!r)return!1;const n=`formsmith_draft_${r.id}`;try{const o=localStorage.getItem(n);if(o){const{values:i}=JSON.parse(o);return e({values:i,draftId:n}),!0}}catch{}return!1},clearDraft:()=>{const{schema:r,draftId:n}=t();if(!r)return;const o=n||`formsmith_draft_${r.id}`;try{localStorage.removeItem(o),e({draftId:null})}catch{}}}))}const qn=Iu();function Hw(e=qn){return e.getState()}const Ou=w.createContext(null),fl=({children:e})=>{const t=w.useRef(null);return t.current||(t.current=Iu()),d.jsx(Ou.Provider,{value:t.current,children:e})};function as(){return w.useContext(Ou)??qn}function Ir(e){const t=as();return e?rl(t,e):rl(t)}function Mu({schema:e,initialValues:t,onSubmit:r,onChange:n,workflowStepId:o,initialStepIndex:i}){const{values:s,errors:a,touched:c,isValidating:u,isSubmitting:f,submitCount:l,isValid:p,currentStep:g,totalSteps:m,completedSteps:h,visibleFields:y,enabledFields:S,requiredFields:v,setSchema:A,setFieldValue:x,setFieldTouched:F,setFieldError:k,setValues:N,resetForm:T,validateField:P,validateForm:E,validateStep:C,nextStep:O,prevStep:W,goToStep:M,setSubmitting:U,incrementSubmitCount:z,saveDraft:X,loadDraft:B,clearDraft:L}=Ir(),D=as(),K=w.useRef(null);w.useLayoutEffect(()=>{if(A(e,{forceReset:!!o||typeof i=="number",initialStepIndex:i}),t&&Object.keys(t).length>0){const ne=D.getState().values;N({...ne,...t});try{K.current=JSON.stringify(t)}catch{K.current=null}}else K.current=null},[e.id,o,i]),w.useLayoutEffect(()=>{if(!t||Object.keys(t).length===0)return;let ne;try{ne=JSON.stringify(t)}catch{return}if(ne===K.current)return;const ge=D.getState().values;N({...ge,...t}),K.current=ne},[t,N]);const le=w.useCallback((ne,ge)=>{const Se={...s,[ne]:ge};x(ne,ge),n?.(Se,ne)},[x,n,s]),j=w.useCallback(async ne=>{if(ne?.preventDefault(),z(),!await E())return{success:!1,errors:Object.entries(a).map(([Se,yt])=>({field:Se,rule:"validation",message:yt}))};if(!r)return{success:!0};U(!0);try{const Se=await r(s);return Se.success&&L(),Se}catch(Se){return{success:!1,message:Se instanceof Error?Se.message:"Submission failed"}}finally{U(!1)}},[E,r,s,a,z,U,L]),H=w.useCallback(ne=>({value:s[ne],error:a[ne],touched:c[ne]||!1,isVisible:y.has(ne),isEnabled:S.has(ne),isRequired:v.has(ne)}),[s,a,c,y,S,v]),ce=w.useMemo(()=>{if(!e.steps||e.steps.length===0)return e.fields;const ne=e.steps[g];return ne?e.fields.filter(ge=>ne.fields.includes(ge.name)):[]},[e,g]),ie=g===0,G=g===m-1,ee=w.useCallback(ne=>h.has(ne),[h]),Ae=w.useMemo(()=>m<=1?100:Math.round(h.size/m*100),[h.size,m]),te=w.useCallback(ne=>y.has(ne),[y]),oe=w.useCallback(ne=>S.has(ne),[S]),me=w.useCallback(ne=>v.has(ne),[v]),Me=w.useMemo(()=>Object.entries(a).filter(([ne])=>y.has(ne)),[a,y]),De=Me.length>0;return{values:s,errors:a,touched:c,isValidating:u,isSubmitting:f,submitCount:l,isValid:p,hasErrors:De,visibleErrors:Me,currentStep:g,totalSteps:m,completedSteps:h,currentStepFields:ce,isFirstStep:ie,isLastStep:G,isStepCompleted:ee,progress:Ae,setFieldValue:le,setFieldTouched:F,setFieldError:k,setValues:N,validateField:P,getFieldState:H,shouldShowField:te,isFieldEnabled:oe,isFieldRequired:me,handleSubmit:j,resetForm:T,validateForm:E,validateStep:C,nextStep:O,prevStep:W,goToStep:M,saveDraft:X,loadDraft:B,clearDraft:L}}function Lu(e){return"logic"in e&&"conditions"in e}function ri(e){if(e==null||typeof e!="object")return!1;const t=e;if(t.status==="error")return!1;if(t.status==="success"||t.status==="COMPLETED")return!0;const r=t.code;return typeof r=="number"&&r>=200&&r<300||t.data!=null&&t.status!=="error"}function Du(e,t){if(e==null||typeof t!="string"||t.trim()==="")return;const r=t.replace(/\[(\d+)\]/g,".$1").split(".").filter(Boolean);let n=e;for(const o of r){if(n==null||typeof n!="object")return;n=n[o]}return n}function We(e,t){if(e==null||typeof t!="string"||t.trim()==="")return;let r=Du(e,t);if(r===void 0&&t.includes(".")){const n=t.split(".");if(n.length>=2){const o=n[0],i=n.slice(1).join("."),s=Du(e,o);Array.isArray(s)&&s.length>0&&(r=We(s[0],i))}}return r}const Uw=new Set(["section","group","columns","divider","header","sectionHeading","spacer","textLabel","addmore","customizeSections"]);function zw(e){return e===!0||e==="true"?!0:e===!1||e==="false"?!1:e}function Vw(e,t){if(e==null||typeof t.path!="string"||!t.path.trim())return!1;const r=We(e,t.path),n=zw(t.value);switch(t.operator){case"equals":return r===n;case"notEquals":return r!==n;case"contains":return typeof r=="string"?r.includes(String(n)):Array.isArray(r)?r.includes(n):!1;case"notContains":return typeof r=="string"?!r.includes(String(n)):Array.isArray(r)?!r.includes(n):!0;case"startsWith":return typeof r=="string"&&r.startsWith(String(n));case"endsWith":return typeof r=="string"&&r.endsWith(String(n));case"greaterThan":return Number(r)>Number(n);case"lessThan":return Number(r)<Number(n);case"greaterThanOrEqual":return Number(r)>=Number(n);case"lessThanOrEqual":return Number(r)<=Number(n);case"isEmpty":return r==null?!0:typeof r=="string"?r.trim()==="":Array.isArray(r)?r.length===0:typeof r=="object"&&r!==null?Object.keys(r).length===0:!1;case"isNotEmpty":return r==null?!1:typeof r=="string"?r.trim()!=="":Array.isArray(r)?r.length>0:typeof r=="object"&&r!==null?Object.keys(r).length>0:!1;case"isTrue":return r===!0;case"isFalse":return r===!1;case"isNull":return r==null;case"isNotNull":return r!=null;case"in":return Array.isArray(n)?n.includes(r):!1;case"notIn":return Array.isArray(n)?!n.includes(r):!0;case"between":if(Array.isArray(n)&&n.length===2){const o=Number(r);return o>=Number(n[0])&&o<=Number(n[1])}return!1;case"regex":try{return new RegExp(String(n)).test(String(r??""))}catch{return!1}default:return!1}}function Ww(e,t,r){return e?e==="__allFields__"?t.filter(n=>!Uw.has(n.type)).map(n=>r(n)).filter(Boolean):e==="__allButtons__"?t.filter(n=>n.type==="button"||n.type==="editButton").map(n=>r(n)).filter(Boolean):[e]:[]}function Bu(e){return String(e||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"").replace(/_+/g,"_")}function $u(e,t){const r=Bu(e)||"row",n=Bu(t)||"cell";return`${r}_${n}`}function Rw(e){return e.kind==="static"?e.row.id:e.block.id}function Kw(e,t){let r=e,n=2;for(;t.has(r);)r=`${e}_${n}`,n+=1;return t.add(r),r}function ju(e,t,r,n){const o=e.cellKey?.trim();if(o)return n.add(o),e;const i=$u(t,r),s=Kw(i,n);return{...e,cellKey:s}}function Hu(e){const t=new Set,r=(e.rowSlots??[]).map(n=>{if(n.kind==="static"){const s=n.row.id,a={};for(const[c,u]of Object.entries(n.row.cells))a[c]=ju(u,s,c,t);return{...n,row:{...n.row,cells:a}}}const o=n.block.id,i={};for(const[s,a]of Object.entries(n.block.cells))i[s]=ju(a,o,s,t);return{...n,block:{...n.block,cells:i}}});return{...e,rowSlots:r}}function Uu(e){const t=new Map;for(const r of e.rowSlots??[]){const n=Rw(r),o=r.kind,i=r.kind==="static"?r.row.cells:r.block.cells;for(const[s,a]of Object.entries(i)){const c=a.cellKey?.trim()||$u(n,s);t.set(c,{slotId:n,rowKind:o,columnKey:s})}}return t}function Gw(e,t,r){return t.rowKind==="static"?e.find(n=>n.slotId===t.slotId&&n.rowKind==="static"):r?.slotId===t.slotId&&r.rowKind==="dynamic"?r:e.find(n=>n.slotId===t.slotId&&n.rowKind==="dynamic")}function zu(e,t,r,n,o){const i=r?.trim();if(!i)return 0;const a=Uu(e).get(i);if(a){if(o?.slotId&&a.slotId!==o.slotId||o?.rowKind&&a.rowKind!==o.rowKind)return 0;const c=Gw(t,a,n);return c?pl(c.values[a.columnKey]):0}if(n&&i in n.values)return pl(n.values[i]);if(o?.slotId){const c=t.find(u=>u.slotId===o.slotId&&(!o.rowKind||u.rowKind===o.rowKind));if(c&&i in c.values)return pl(c.values[i])}return 0}function pl(e){if(typeof e=="number"&&!Number.isNaN(e))return e;const t=Number(e);return Number.isNaN(t)?0:t}const Vu="__fieldRef:",Wu="__billingCell:";function qw(e){const t={kind:"static",staticValue:"",fieldName:"",billingFieldName:"",cellKey:""};if(e==null)return t;const r=String(e);if(r.startsWith(Vu))return{...t,kind:"field",fieldName:r.slice(Vu.length)};if(r.startsWith(Wu)){const n=r.slice(Wu.length),o=n.indexOf("|");return o>=0?{...t,kind:"billingCell",billingFieldName:n.slice(0,o),cellKey:n.slice(o+1)}:{...t,kind:"billingCell",cellKey:n}}if(r.startsWith("field:"))return{...t,kind:"field",fieldName:r.slice(6)};if(r.startsWith("billing:")){const n=r.slice(8),o=n.indexOf("|");return o>=0?{...t,kind:"billingCell",billingFieldName:n.slice(0,o),cellKey:n.slice(o+1)}:{...t,kind:"billingCell",cellKey:n}}return{...t,kind:"static",staticValue:r}}function ml(e){return e.name||e.key||e.id}function Yw(e,t){const r=t.find(n=>n.id===e||n.name===e||n.key===e);return r?ml(r):e}function Xw(e,t,r,n){const o=t.trim();if(!o)return;const i=n.filter(a=>a.type==="billingGrid"),s=e?.trim()?i.filter(a=>ml(a)===e||a.name===e||a.id===e):i;for(const a of s){const c=Hu(a.properties??{}),u=r[ml(a)];if(!u?.rows?.length)continue;const l=Uu(c).get(o);if(!l)continue;const p=u.rows.find(g=>l.rowKind==="static"?g.slotId===l.slotId&&g.rowKind==="static":g.slotId===l.slotId&&g.rowKind==="dynamic");if(p)return p.values[l.columnKey]}}function Jw(e,t,r){const n=qw(e);if(n.kind==="field"){const o=Yw(n.fieldName,r);return t[o]}return n.kind==="billingCell"?Xw(n.billingFieldName,n.cellKey,t,r):n.staticValue}function Ru(e,t){if(e===t)return!0;if(e==null||t===void 0||t===null)return!1;const r=Number(e),n=Number(t);return!Number.isNaN(r)&&!Number.isNaN(n)&&String(e).trim()!==""&&String(t).trim()!==""?r===n:String(e).trim()===String(t).trim()}const Ku="__buttonResponse:";function Qw({fields:e,values:t,buttonResponses:r,prepopulateResponse:n=null,prepopulateResponseRules:o}){const{updateVisibility:i,updateEnabled:s,updateRequired:a,updateReadOnly:c,updateEditable:u,updateFormDisabled:f}=Ir(),l=w.useCallback(k=>k.name||k.key||k.id,[]),p=w.useCallback((k,N)=>{if(!k)return l(N);const T=e.find(P=>P.id===k||P.name===k||P.key===k);return T?l(T):k},[e,l]),g=w.useCallback(k=>{const N=e.find(T=>T.id===k||T.name===k||T.key===k);return N?l(N):k},[e,l]),m=w.useCallback(k=>{const{field:N,operator:T,value:P}=k;if(typeof N=="string"&&N.startsWith(Ku)){const W=N.slice(Ku.length),M=r?.[W],U=ri(M);return P==="success"?U:P==="failure"?M!=null&&!U:!1}const E=g(N),C=t[E],O=Jw(P,t,e);switch(T){case"equals":return Ru(C,O);case"notEquals":return!Ru(C,O);case"contains":return typeof C=="string"?C.includes(String(O)):Array.isArray(C)?C.includes(O):!1;case"notContains":return typeof C=="string"?!C.includes(String(O)):Array.isArray(C)?!C.includes(O):!0;case"startsWith":return typeof C=="string"&&C.startsWith(String(O));case"endsWith":return typeof C=="string"&&C.endsWith(String(O));case"greaterThan":return Number(C)>Number(O);case"lessThan":return Number(C)<Number(O);case"greaterThanOrEqual":return Number(C)>=Number(O);case"lessThanOrEqual":return Number(C)<=Number(O);case"isEmpty":return C==null?!0:C instanceof File?!1:typeof C=="string"?C.trim()==="":Array.isArray(C)?(C.length>0&&C[0]instanceof File,C.length===0):typeof C=="object"&&C!==null?Object.keys(C).length===0:!1;case"isNotEmpty":return C==null?!1:C instanceof File?!0:typeof C=="string"?C.trim()!=="":Array.isArray(C)?(C.length>0&&C[0]instanceof File,C.length>0):typeof C=="object"&&C!==null?Object.keys(C).length>0:!1;case"isTrue":return C===!0;case"isFalse":return C===!1;case"isNull":return C==null;case"isNotNull":return C!=null;case"in":return Array.isArray(O)?O.includes(C):!1;case"notIn":return Array.isArray(O)?!O.includes(C):!0;case"between":if(Array.isArray(O)&&O.length===2){const W=Number(C);return W>=Number(O[0])&&W<=Number(O[1])}return!1;case"regex":try{return new RegExp(String(O)).test(String(C))}catch{return!1}default:return!0}},[t,g,r,e]),h=w.useCallback(k=>{const N=k.conditions.map(T=>Lu(T)?h(T):m(T));return k.logic==="and"?N.every(Boolean):N.some(Boolean)},[m]),y=w.useCallback(k=>Lu(k)?h(k):m(k),[m,h]),S=w.useCallback(()=>{const k=new Set,N=new Set,T=new Set,P=new Set,E=new Set;e.forEach(M=>{const U=l(M);M.hidden||k.add(U),M.disabled||N.add(U),M.validation?.some(z=>z.type==="required")&&T.add(U)});let C=!1;if(n!=null&&o?.length)for(const M of o){if(!Vw(n,M.when))continue;const{action:U,target:z}=M.then;if(U==="disableForm")C=!0;else if(U==="enableForm")C=!1;else{const X=Ww(z,e,l);for(const B of X)switch(U){case"disable":N.delete(B);break;case"enable":N.add(B);break;case"hide":k.delete(B);break;case"show":k.add(B);break;case"readOnly":P.add(B),E.delete(B);break;case"editable":E.add(B),P.delete(B);break}}}e.forEach(M=>{M.conditions&&M.conditions.forEach(U=>{(y(U.when)?U.then:U.else||[]).forEach(B=>{switch(B.action){case"disableForm":C=!0;break;case"enableForm":C=!1;break;default:{const L=p(B.target,M);switch(B.action){case"show":k.add(L);break;case"hide":k.delete(L);break;case"enable":N.add(L);break;case"disable":N.delete(L);break;case"require":T.add(L);break;case"unrequire":T.delete(L);break}break}}})})});const O=M=>e.filter(U=>U.type!=="editButton"&&(U.name||U.key||U.id)).map(U=>l(U)),W=()=>e.filter(M=>M.type==="button").map(M=>l(M));return e.forEach(M=>{if(M.type!=="editButton")return;const U=l(M);if(!ri(r?.[U]))return;const z=M.properties;z?.rules&&z.rules.length>0?z.rules.forEach(X=>{const B=[];X.allFields&&B.push(...O(M.id)),X.allButtons&&B.push(...W()),X.fieldNames?.length&&X.fieldNames.forEach(L=>{const D=e.find(K=>l(K)===L||K.id===L||K.name===L);B.push(D?l(D):L)}),X.buttonNames?.length&&B.push(...X.buttonNames),B.forEach(L=>{switch(X.action){case"enable":N.add(L),P.delete(L);break;case"disable":N.delete(L);break;case"show":k.add(L);break;case"hide":k.delete(L);break;case"readOnly":P.add(L);break;case"editable":E.add(L);break}})}):((z?.enableFieldNames??[]).forEach(X=>N.add(X)),(z?.disableFieldNames??[]).forEach(X=>N.delete(X)),(z?.showFieldNames??[]).forEach(X=>k.add(X)),(z?.hideFieldNames??[]).forEach(X=>k.delete(X)))}),{visible:Array.from(k),enabled:Array.from(N),required:Array.from(T),readOnly:Array.from(P),editable:Array.from(E),formDisabled:C}},[e,y,l,p,t,r,n,o]),v=w.useMemo(()=>S(),[S]);w.useLayoutEffect(()=>{i(v.visible),s(v.enabled),a(v.required),c(v.readOnly??[]),u(v.editable??[]),f(v.formDisabled??!1)},[v,i,s,a,c,u,f]);const A=w.useCallback(k=>v.visible.includes(k),[v.visible]),x=w.useCallback(k=>v.enabled.includes(k),[v.enabled]),F=w.useCallback(k=>v.required.includes(k),[v.required]);return{evaluateCondition:y,evaluateExpression:m,evaluateGroup:h,isFieldVisible:A,isFieldEnabled:x,isFieldRequired:F,visibleFields:v.visible,enabledFields:v.enabled,requiredFields:v.required}}function gn({className:e,type:t,...r}){return d.jsx("input",{type:t,"data-slot":"input",className:V("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground text-foreground dark:bg-secondary dark:border-input border-input flex h-9 w-full min-w-0 rounded-md border bg-background px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...r})}function Gu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Yn(...e){return t=>{let r=!1;const n=e.map(o=>{const i=Gu(o,t);return!r&&typeof i=="function"&&(r=!0),i});if(r)return()=>{for(let o=0;o<n.length;o++){const i=n[o];typeof i=="function"?i():Gu(e[o],null)}}}}function qe(...e){return b.useCallback(Yn(...e),e)}var Zw=Symbol.for("react.lazy"),ls=b[" use ".trim().toString()];function eS(e){return typeof e=="object"&&e!==null&&"then"in e}function qu(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Zw&&"_payload"in e&&eS(e._payload)}function hl(e){const t=tS(e),r=b.forwardRef((n,o)=>{let{children:i,...s}=n;qu(i)&&typeof ls=="function"&&(i=ls(i._payload));const a=b.Children.toArray(i),c=a.find(nS);if(c){const u=c.props.children,f=a.map(l=>l===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:l);return d.jsx(t,{...s,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,f):null})}return d.jsx(t,{...s,ref:o,children:i})});return r.displayName=`${e}.Slot`,r}var Yu=hl("Slot");function tS(e){const t=b.forwardRef((r,n)=>{let{children:o,...i}=r;if(qu(o)&&typeof ls=="function"&&(o=ls(o._payload)),b.isValidElement(o)){const s=iS(o),a=oS(i,o.props);return o.type!==b.Fragment&&(a.ref=n?Yn(n,s):s),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var rS=Symbol("radix.slottable");function nS(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===rS}function oS(e,t){const r={...t};for(const n in t){const o=e[n],i=t[n];/^on[A-Z]/.test(n)?o&&i?r[n]=(...a)=>{const c=i(...a);return o(...a),c}:o&&(r[n]=o):n==="style"?r[n]={...o,...i}:n==="className"&&(r[n]=[o,i].filter(Boolean).join(" "))}return{...e,...r}}function iS(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var sS=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],aS=sS.reduce((e,t)=>{const r=hl(`Primitive.${t}`),n=b.forwardRef((o,i)=>{const{asChild:s,...a}=o,c=s?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(c,{...a,ref:i})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),lS="Label",Xu=b.forwardRef((e,t)=>d.jsx(aS.label,{...e,ref:t,onMouseDown:r=>{r.target.closest("button, input, select, textarea")||(e.onMouseDown?.(r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));Xu.displayName=lS;var cS=Xu;function Pn({className:e,...t}){return d.jsx(cS,{"data-slot":"label",className:V("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50 mb-2",e),...t})}function ft(e){return`formsmith-field-${e.id}`}function cs(e){return`formsmith-label-${e.id}`}function ni(e){return`formsmith-desc-${e.id}`}function oi(e){return`formsmith-error-${e.id}`}function Lt(e,t){const r=[];return e.description&&r.push(ni(e)),t&&r.push(oi(e)),r.length>0?r.join(" "):void 0}function Jt(e){return e?!0:void 0}const dS={body:{fontSize:"0.875rem",lineHeight:"1.25rem",fontWeight:400},heading:{fontSize:"1.125rem",lineHeight:"1.5rem",fontWeight:600},label:{fontSize:"0.875rem",lineHeight:"1.25rem",fontWeight:500},caption:{fontSize:"0.75rem",lineHeight:"1rem",fontWeight:400,color:"var(--muted-foreground)"}};function In(e){return e.ui?.cellStyle}function uS(e){const t=e.ui;if(!t)return;const r=t.fontToken?dS[t.fontToken]:void 0;if(!(!r&&!t.wrapperStyle))return{...r,...t.wrapperStyle}}function fS(e){return e.type==="button"||e.type==="editButton"}const Ct=({field:e,error:t,isRequired:r,children:n,className:o,hideLabel:i})=>{const{gridStretch:s}=ti(),a=s&&ts(e),c=!(i??e.appearance?.hideLabel)&&e.label,u=e.appearance?.labelPlacement||"top",f=uS(e),l=e.appearance?.minWidth!=null||e.appearance?.minHeight!=null?{...e.appearance.minWidth!=null?{minWidth:e.appearance.minWidth}:{},...e.appearance.minHeight!=null?{minHeight:e.appearance.minHeight}:{}}:void 0,p=e.appearance?.className,g=gu(e),m=po(e),h=fS(e),y=Fr(e.appearance);return d.jsx("div",{className:V(ow(u),u!=="floating"&&"space-y-2",a&&!h&&"flex-1 min-h-0 h-full",s&&h&&"w-full shrink-0 self-start",p,o),style:f,"data-field-appearance":u,children:d.jsxs("div",{className:V("flex flex-col min-w-0",fu(e.appearance),yu(e),a&&!h&&"flex-1 min-h-0",s&&h&&"shrink-0"),style:g,children:[c&&d.jsxs(Pn,{id:cs(e),htmlFor:ft(e),style:e.ui?.labelStyle,className:V(iw(u,!!t)),children:[e.label,r&&d.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),d.jsxs("div",{className:V(sw(u),h&&s&&"min-h-min !grow-0 !shrink-0 basis-auto",m&&y!=="stretch"&&"items-start",h&&y==="stretch"&&"items-start w-full [&_button]:w-full",!h&&y==="stretch"&&"items-stretch",a&&!h&&"flex-1 min-h-0",o?.includes("flex")&&u==="top"&&"flex flex-col min-h-0"),style:l,children:[n,d.jsxs("div",{className:V("mt-1.5 min-h-[18px]",u==="center"&&"text-center",o?.includes("flex")&&"shrink-0"),children:[e.description&&!t&&d.jsx("p",{id:ni(e),className:"text-xs text-muted-foreground",style:e.ui?.descriptionStyle,children:e.description}),t&&d.jsx("p",{id:oi(e),className:"text-xs text-destructive",role:"alert",children:typeof t=="string"?t:String(t||"An error occurred")})]})]})]})})},ds=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:c})=>{const u=e.properties,f=w.useCallback(l=>{r(l.target.value)},[r]);return d.jsx(Ct,{field:e,error:o,isRequired:a,className:c,children:d.jsx(gn,{id:ft(e),type:"text",value:t||"",onChange:f,onBlur:n,placeholder:e.placeholder,disabled:i||e.disabled,readOnly:s||e.readOnly,minLength:u?.minLength,maxLength:u?.maxLength,pattern:u?.pattern,autoComplete:u?.autoComplete,inputMode:u?.inputMode,"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:V(fo(e.appearance),o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})})},gl=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:c})=>{const u=e.properties,f=u?.precision!=null||u?.step!=null&&!Number.isInteger(u.step),l=w.useCallback(g=>{const m=u?.allowNegative!==!1,h=g.target.value,y=f?h.replace(m?/[^\d.-]/g:/[^\d.]/g,""):h.replace(m?/[^\d-]/g:/\D/g,"");if(y===""){r(null);return}const S=parseFloat(y);isNaN(S)||r(S)},[r,u?.allowNegative,f]),p=w.useCallback(g=>{(g.key==="ArrowUp"||g.key==="ArrowDown"||g.key==="PageUp"||g.key==="PageDown")&&g.preventDefault()},[]);return d.jsx(Ct,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"relative",children:[u?.prefix&&d.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:u.prefix}),d.jsx(gn,{id:ft(e),type:"text",inputMode:f?"decimal":"numeric",autoComplete:"off",value:t??"",onChange:l,onKeyDown:p,onBlur:n,placeholder:e.placeholder,disabled:i||e.disabled,readOnly:s||e.readOnly,"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:V(fo(e.appearance),o&&"border-destructive focus-visible:ring-destructive",u?.prefix&&"pl-8",u?.suffix&&"pr-8",e.appearance?.className)}),u?.suffix&&d.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:u.suffix})]})})};const pS=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),mS=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,n)=>n?n.toUpperCase():r.toLowerCase()),Ju=e=>{const t=mS(e);return t.charAt(0).toUpperCase()+t.slice(1)},Qu=(...e)=>e.filter((t,r,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===r).join(" ").trim(),hS=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var gS={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const yS=w.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:o="",children:i,iconNode:s,...a},c)=>w.createElement("svg",{ref:c,...gS,width:t,height:t,stroke:e,strokeWidth:n?Number(r)*24/Number(t):r,className:Qu("lucide",o),...!i&&!hS(a)&&{"aria-hidden":"true"},...a},[...s.map(([u,f])=>w.createElement(u,f)),...Array.isArray(i)?i:[i]]));const Gt=(e,t)=>{const r=w.forwardRef(({className:n,...o},i)=>w.createElement(yS,{ref:i,iconNode:t,className:Qu(`lucide-${pS(Ju(e))}`,`lucide-${e}`,n),...o}));return r.displayName=Ju(e),r};const bS=Gt("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);const us=Gt("camera",[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);const fs=Gt("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const ii=Gt("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const Zu=Gt("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const vS=Gt("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);const wS=Gt("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const ef=Gt("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const tf=Gt("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const rf=Gt("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const ho=Gt("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const SS=Gt("mail",[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]);const xS=Gt("phone",[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]]);const nf=Gt("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const AS=Gt("sliders-horizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);const of=Gt("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);const si=Gt("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);const ps=Gt("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const ai=Gt("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),sf=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:c})=>{const u=w.useCallback(f=>{r(f.target.value)},[r]);return d.jsx(Ct,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"relative",children:[d.jsx(SS,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),d.jsx(gn,{id:ft(e),type:"email",value:t||"",onChange:u,onBlur:n,placeholder:e.placeholder||"email@example.com",disabled:i||e.disabled,readOnly:s||e.readOnly,autoComplete:"email",inputMode:"email","aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:V(fo(e.appearance),"pl-10",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]})})},af=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:c})=>{const u=w.useCallback(f=>{const l=f.target.value.replace(/[^\d\s+\-()]/g,"");r(l)},[r]);return d.jsx(Ct,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"relative",children:[d.jsx(xS,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),d.jsx(gn,{id:ft(e),type:"tel",value:t||"",onChange:u,onBlur:n,placeholder:e.placeholder||"+91 12345 67890",disabled:i||e.disabled,readOnly:s||e.readOnly,autoComplete:"tel",inputMode:"tel","aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:V(fo(e.appearance),"pl-10",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]})})};function lf(e,t){return function(){return e.apply(t,arguments)}}const{toString:CS}=Object.prototype,{getPrototypeOf:yl}=Object,{iterator:ms,toStringTag:cf}=Symbol,hs=(e=>t=>{const r=CS.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),Wr=e=>(e=e.toLowerCase(),t=>hs(t)===e),gs=e=>t=>typeof t===e,{isArray:go}=Array,yo=gs("undefined");function li(e){return e!==null&&!yo(e)&&e.constructor!==null&&!yo(e.constructor)&&mr(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const df=Wr("ArrayBuffer");function ES(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&df(e.buffer),t}const kS=gs("string"),mr=gs("function"),uf=gs("number"),ci=e=>e!==null&&typeof e=="object",NS=e=>e===!0||e===!1,ys=e=>{if(hs(e)!=="object")return!1;const t=yl(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(cf in e)&&!(ms in e)},_S=e=>{if(!ci(e)||li(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},TS=Wr("Date"),FS=Wr("File"),PS=e=>!!(e&&typeof e.uri<"u"),IS=e=>e&&typeof e.getParts<"u",OS=Wr("Blob"),MS=Wr("FileList"),LS=e=>ci(e)&&mr(e.pipe);function DS(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const ff=DS(),pf=typeof ff.FormData<"u"?ff.FormData:void 0,BS=e=>{let t;return e&&(pf&&e instanceof pf||mr(e.append)&&((t=hs(e))==="formdata"||t==="object"&&mr(e.toString)&&e.toString()==="[object FormData]"))},$S=Wr("URLSearchParams"),[jS,HS,US,zS]=["ReadableStream","Request","Response","Headers"].map(Wr),VS=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function di(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,o;if(typeof e!="object"&&(e=[e]),go(e))for(n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else{if(li(e))return;const i=r?Object.getOwnPropertyNames(e):Object.keys(e),s=i.length;let a;for(n=0;n<s;n++)a=i[n],t.call(null,e[a],a,e)}}function mf(e,t){if(li(e))return null;t=t.toLowerCase();const r=Object.keys(e);let n=r.length,o;for(;n-- >0;)if(o=r[n],t===o.toLowerCase())return o;return null}const Xn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,hf=e=>!yo(e)&&e!==Xn;function bl(){const{caseless:e,skipUndefined:t}=hf(this)&&this||{},r={},n=(o,i)=>{if(i==="__proto__"||i==="constructor"||i==="prototype")return;const s=e&&mf(r,i)||i;ys(r[s])&&ys(o)?r[s]=bl(r[s],o):ys(o)?r[s]=bl({},o):go(o)?r[s]=o.slice():(!t||!yo(o))&&(r[s]=o)};for(let o=0,i=arguments.length;o<i;o++)arguments[o]&&di(arguments[o],n);return r}const WS=(e,t,r,{allOwnKeys:n}={})=>(di(t,(o,i)=>{r&&mr(o)?Object.defineProperty(e,i,{value:lf(o,r),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,i,{value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:n}),e),RS=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),KS=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},GS=(e,t,r,n)=>{let o,i,s;const a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),i=o.length;i-- >0;)s=o[i],(!n||n(s,e,t))&&!a[s]&&(t[s]=e[s],a[s]=!0);e=r!==!1&&yl(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},qS=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return n!==-1&&n===r},YS=e=>{if(!e)return null;if(go(e))return e;let t=e.length;if(!uf(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},XS=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&yl(Uint8Array)),JS=(e,t)=>{const n=(e&&e[ms]).call(e);let o;for(;(o=n.next())&&!o.done;){const i=o.value;t.call(e,i[0],i[1])}},QS=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},ZS=Wr("HTMLFormElement"),e0=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,o){return n.toUpperCase()+o}),gf=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),t0=Wr("RegExp"),yf=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};di(r,(o,i)=>{let s;(s=t(o,i,e))!==!1&&(n[i]=s||o)}),Object.defineProperties(e,n)},r0=e=>{yf(e,(t,r)=>{if(mr(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=e[r];if(mr(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},n0=(e,t)=>{const r={},n=o=>{o.forEach(i=>{r[i]=!0})};return go(e)?n(e):n(String(e).split(t)),r},o0=()=>{},i0=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function s0(e){return!!(e&&mr(e.append)&&e[cf]==="FormData"&&e[ms])}const a0=e=>{const t=new Array(10),r=(n,o)=>{if(ci(n)){if(t.indexOf(n)>=0)return;if(li(n))return n;if(!("toJSON"in n)){t[o]=n;const i=go(n)?[]:{};return di(n,(s,a)=>{const c=r(s,o+1);!yo(c)&&(i[a]=c)}),t[o]=void 0,i}}return n};return r(e,0)},l0=Wr("AsyncFunction"),c0=e=>e&&(ci(e)||mr(e))&&mr(e.then)&&mr(e.catch),bf=((e,t)=>e?setImmediate:t?((r,n)=>(Xn.addEventListener("message",({source:o,data:i})=>{o===Xn&&i===r&&n.length&&n.shift()()},!1),o=>{n.push(o),Xn.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",mr(Xn.postMessage)),d0=typeof queueMicrotask<"u"?queueMicrotask.bind(Xn):typeof process<"u"&&process.nextTick||bf,Y={isArray:go,isArrayBuffer:df,isBuffer:li,isFormData:BS,isArrayBufferView:ES,isString:kS,isNumber:uf,isBoolean:NS,isObject:ci,isPlainObject:ys,isEmptyObject:_S,isReadableStream:jS,isRequest:HS,isResponse:US,isHeaders:zS,isUndefined:yo,isDate:TS,isFile:FS,isReactNativeBlob:PS,isReactNative:IS,isBlob:OS,isRegExp:t0,isFunction:mr,isStream:LS,isURLSearchParams:$S,isTypedArray:XS,isFileList:MS,forEach:di,merge:bl,extend:WS,trim:VS,stripBOM:RS,inherits:KS,toFlatObject:GS,kindOf:hs,kindOfTest:Wr,endsWith:qS,toArray:YS,forEachEntry:JS,matchAll:QS,isHTMLForm:ZS,hasOwnProperty:gf,hasOwnProp:gf,reduceDescriptors:yf,freezeMethods:r0,toObjectSet:n0,toCamelCase:e0,noop:o0,toFiniteNumber:i0,findKey:mf,global:Xn,isContextDefined:hf,isSpecCompliantForm:s0,toJSONObject:a0,isAsyncFn:l0,isThenable:c0,setImmediate:bf,asap:d0,isIterable:e=>e!=null&&mr(e[ms])};let Ke=class fv extends Error{static from(t,r,n,o,i,s){const a=new fv(t.message,r||t.code,n,o,i);return a.cause=t,a.name=t.name,t.status!=null&&a.status==null&&(a.status=t.status),s&&Object.assign(a,s),a}constructor(t,r,n,o,i){super(t),Object.defineProperty(this,"message",{value:t,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,r&&(this.code=r),n&&(this.config=n),o&&(this.request=o),i&&(this.response=i,this.status=i.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Y.toJSONObject(this.config),code:this.code,status:this.status}}};Ke.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",Ke.ERR_BAD_OPTION="ERR_BAD_OPTION",Ke.ECONNABORTED="ECONNABORTED",Ke.ETIMEDOUT="ETIMEDOUT",Ke.ERR_NETWORK="ERR_NETWORK",Ke.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",Ke.ERR_DEPRECATED="ERR_DEPRECATED",Ke.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",Ke.ERR_BAD_REQUEST="ERR_BAD_REQUEST",Ke.ERR_CANCELED="ERR_CANCELED",Ke.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",Ke.ERR_INVALID_URL="ERR_INVALID_URL";const u0=null;function vl(e){return Y.isPlainObject(e)||Y.isArray(e)}function vf(e){return Y.endsWith(e,"[]")?e.slice(0,-2):e}function wl(e,t,r){return e?e.concat(t).map(function(o,i){return o=vf(o),!r&&i?"["+o+"]":o}).join(r?".":""):t}function f0(e){return Y.isArray(e)&&!e.some(vl)}const p0=Y.toFlatObject(Y,{},null,function(t){return/^is[A-Z]/.test(t)});function bs(e,t,r){if(!Y.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=Y.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,y){return!Y.isUndefined(y[h])});const n=r.metaTokens,o=r.visitor||f,i=r.dots,s=r.indexes,c=(r.Blob||typeof Blob<"u"&&Blob)&&Y.isSpecCompliantForm(t);if(!Y.isFunction(o))throw new TypeError("visitor must be a function");function u(m){if(m===null)return"";if(Y.isDate(m))return m.toISOString();if(Y.isBoolean(m))return m.toString();if(!c&&Y.isBlob(m))throw new Ke("Blob is not supported. Use a Buffer instead.");return Y.isArrayBuffer(m)||Y.isTypedArray(m)?c&&typeof Blob=="function"?new Blob([m]):Buffer.from(m):m}function f(m,h,y){let S=m;if(Y.isReactNative(t)&&Y.isReactNativeBlob(m))return t.append(wl(y,h,i),u(m)),!1;if(m&&!y&&typeof m=="object"){if(Y.endsWith(h,"{}"))h=n?h:h.slice(0,-2),m=JSON.stringify(m);else if(Y.isArray(m)&&f0(m)||(Y.isFileList(m)||Y.endsWith(h,"[]"))&&(S=Y.toArray(m)))return h=vf(h),S.forEach(function(A,x){!(Y.isUndefined(A)||A===null)&&t.append(s===!0?wl([h],x,i):s===null?h:h+"[]",u(A))}),!1}return vl(m)?!0:(t.append(wl(y,h,i),u(m)),!1)}const l=[],p=Object.assign(p0,{defaultVisitor:f,convertValue:u,isVisitable:vl});function g(m,h){if(!Y.isUndefined(m)){if(l.indexOf(m)!==-1)throw Error("Circular reference detected in "+h.join("."));l.push(m),Y.forEach(m,function(S,v){(!(Y.isUndefined(S)||S===null)&&o.call(t,S,Y.isString(v)?v.trim():v,h,p))===!0&&g(S,h?h.concat(v):[v])}),l.pop()}}if(!Y.isObject(e))throw new TypeError("data must be an object");return g(e),t}function wf(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function Sl(e,t){this._pairs=[],e&&bs(e,this,t)}const Sf=Sl.prototype;Sf.append=function(t,r){this._pairs.push([t,r])},Sf.toString=function(t){const r=t?function(n){return t.call(this,n,wf)}:wf;return this._pairs.map(function(o){return r(o[0])+"="+r(o[1])},"").join("&")};function m0(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function xf(e,t,r){if(!t)return e;const n=r&&r.encode||m0,o=Y.isFunction(r)?{serialize:r}:r,i=o&&o.serialize;let s;if(i?s=i(t,o):s=Y.isURLSearchParams(t)?t.toString():new Sl(t,o).toString(n),s){const a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Af{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Y.forEach(this.handlers,function(n){n!==null&&t(n)})}}const xl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},h0={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Sl,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Al=typeof window<"u"&&typeof document<"u",Cl=typeof navigator=="object"&&navigator||void 0,g0=Al&&(!Cl||["ReactNative","NativeScript","NS"].indexOf(Cl.product)<0),y0=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",b0=Al&&window.location.href||"http://localhost",ir={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Al,hasStandardBrowserEnv:g0,hasStandardBrowserWebWorkerEnv:y0,navigator:Cl,origin:b0},Symbol.toStringTag,{value:"Module"})),...h0};function v0(e,t){return bs(e,new ir.classes.URLSearchParams,{visitor:function(r,n,o,i){return ir.isNode&&Y.isBuffer(r)?(this.append(n,r.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...t})}function w0(e){return Y.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function S0(e){const t={},r=Object.keys(e);let n;const o=r.length;let i;for(n=0;n<o;n++)i=r[n],t[i]=e[i];return t}function Cf(e){function t(r,n,o,i){let s=r[i++];if(s==="__proto__")return!0;const a=Number.isFinite(+s),c=i>=r.length;return s=!s&&Y.isArray(o)?o.length:s,c?(Y.hasOwnProp(o,s)?o[s]=[o[s],n]:o[s]=n,!a):((!o[s]||!Y.isObject(o[s]))&&(o[s]=[]),t(r,n,o[s],i)&&Y.isArray(o[s])&&(o[s]=S0(o[s])),!a)}if(Y.isFormData(e)&&Y.isFunction(e.entries)){const r={};return Y.forEachEntry(e,(n,o)=>{t(w0(n),o,r,0)}),r}return null}function x0(e,t,r){if(Y.isString(e))try{return(t||JSON.parse)(e),Y.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}const ui={transitional:xl,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){const n=r.getContentType()||"",o=n.indexOf("application/json")>-1,i=Y.isObject(t);if(i&&Y.isHTMLForm(t)&&(t=new FormData(t)),Y.isFormData(t))return o?JSON.stringify(Cf(t)):t;if(Y.isArrayBuffer(t)||Y.isBuffer(t)||Y.isStream(t)||Y.isFile(t)||Y.isBlob(t)||Y.isReadableStream(t))return t;if(Y.isArrayBufferView(t))return t.buffer;if(Y.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(i){if(n.indexOf("application/x-www-form-urlencoded")>-1)return v0(t,this.formSerializer).toString();if((a=Y.isFileList(t))||n.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return bs(a?{"files[]":t}:t,c&&new c,this.formSerializer)}}return i||o?(r.setContentType("application/json",!1),x0(t)):t}],transformResponse:[function(t){const r=this.transitional||ui.transitional,n=r&&r.forcedJSONParsing,o=this.responseType==="json";if(Y.isResponse(t)||Y.isReadableStream(t))return t;if(t&&Y.isString(t)&&(n&&!this.responseType||o)){const s=!(r&&r.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(s)throw a.name==="SyntaxError"?Ke.from(a,Ke.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ir.classes.FormData,Blob:ir.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Y.forEach(["delete","get","head","post","put","patch"],e=>{ui.headers[e]={}});const A0=Y.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),C0=e=>{const t={};let r,n,o;return e&&e.split(`
|
|
2
|
+
`).forEach(function(s){o=s.indexOf(":"),r=s.substring(0,o).trim().toLowerCase(),n=s.substring(o+1).trim(),!(!r||t[r]&&A0[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t},Ef=Symbol("internals");function fi(e){return e&&String(e).trim().toLowerCase()}function vs(e){return e===!1||e==null?e:Y.isArray(e)?e.map(vs):String(e).replace(/[\r\n]+$/,"")}function E0(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}const k0=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function El(e,t,r,n,o){if(Y.isFunction(n))return n.call(this,t,r);if(o&&(t=r),!!Y.isString(t)){if(Y.isString(n))return t.indexOf(n)!==-1;if(Y.isRegExp(n))return n.test(t)}}function N0(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function _0(e,t){const r=Y.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(o,i,s){return this[n].call(this,t,o,i,s)},configurable:!0})})}let hr=class{constructor(t){t&&this.set(t)}set(t,r,n){const o=this;function i(a,c,u){const f=fi(c);if(!f)throw new Error("header name must be a non-empty string");const l=Y.findKey(o,f);(!l||o[l]===void 0||u===!0||u===void 0&&o[l]!==!1)&&(o[l||c]=vs(a))}const s=(a,c)=>Y.forEach(a,(u,f)=>i(u,f,c));if(Y.isPlainObject(t)||t instanceof this.constructor)s(t,r);else if(Y.isString(t)&&(t=t.trim())&&!k0(t))s(C0(t),r);else if(Y.isObject(t)&&Y.isIterable(t)){let a={},c,u;for(const f of t){if(!Y.isArray(f))throw TypeError("Object iterator must return a key-value pair");a[u=f[0]]=(c=a[u])?Y.isArray(c)?[...c,f[1]]:[c,f[1]]:f[1]}s(a,r)}else t!=null&&i(r,t,n);return this}get(t,r){if(t=fi(t),t){const n=Y.findKey(this,t);if(n){const o=this[n];if(!r)return o;if(r===!0)return E0(o);if(Y.isFunction(r))return r.call(this,o,n);if(Y.isRegExp(r))return r.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=fi(t),t){const n=Y.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||El(this,this[n],n,r)))}return!1}delete(t,r){const n=this;let o=!1;function i(s){if(s=fi(s),s){const a=Y.findKey(n,s);a&&(!r||El(n,n[a],a,r))&&(delete n[a],o=!0)}}return Y.isArray(t)?t.forEach(i):i(t),o}clear(t){const r=Object.keys(this);let n=r.length,o=!1;for(;n--;){const i=r[n];(!t||El(this,this[i],i,t,!0))&&(delete this[i],o=!0)}return o}normalize(t){const r=this,n={};return Y.forEach(this,(o,i)=>{const s=Y.findKey(n,i);if(s){r[s]=vs(o),delete r[i];return}const a=t?N0(i):String(i).trim();a!==i&&delete r[i],r[a]=vs(o),n[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return Y.forEach(this,(n,o)=>{n!=null&&n!==!1&&(r[o]=t&&Y.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
|
|
3
|
+
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const n=new this(t);return r.forEach(o=>n.set(o)),n}static accessor(t){const n=(this[Ef]=this[Ef]={accessors:{}}).accessors,o=this.prototype;function i(s){const a=fi(s);n[a]||(_0(o,s),n[a]=!0)}return Y.isArray(t)?t.forEach(i):i(t),this}};hr.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Y.reduceDescriptors(hr.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}}),Y.freezeMethods(hr);function kl(e,t){const r=this||ui,n=t||r,o=hr.from(n.headers);let i=n.data;return Y.forEach(e,function(a){i=a.call(r,i,o.normalize(),t?t.status:void 0)}),o.normalize(),i}function kf(e){return!!(e&&e.__CANCEL__)}let pi=class extends Ke{constructor(t,r,n){super(t??"canceled",Ke.ERR_CANCELED,r,n),this.name="CanceledError",this.__CANCEL__=!0}};function Nf(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new Ke("Request failed with status code "+r.status,[Ke.ERR_BAD_REQUEST,Ke.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function T0(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function F0(e,t){e=e||10;const r=new Array(e),n=new Array(e);let o=0,i=0,s;return t=t!==void 0?t:1e3,function(c){const u=Date.now(),f=n[i];s||(s=u),r[o]=c,n[o]=u;let l=i,p=0;for(;l!==o;)p+=r[l++],l=l%e;if(o=(o+1)%e,o===i&&(i=(i+1)%e),u-s<t)return;const g=f&&u-f;return g?Math.round(p*1e3/g):void 0}}function P0(e,t){let r=0,n=1e3/t,o,i;const s=(u,f=Date.now())=>{r=f,o=null,i&&(clearTimeout(i),i=null),e(...u)};return[(...u)=>{const f=Date.now(),l=f-r;l>=n?s(u,f):(o=u,i||(i=setTimeout(()=>{i=null,s(o)},n-l)))},()=>o&&s(o)]}const ws=(e,t,r=3)=>{let n=0;const o=F0(50,250);return P0(i=>{const s=i.loaded,a=i.lengthComputable?i.total:void 0,c=s-n,u=o(c),f=s<=a;n=s;const l={loaded:s,total:a,progress:a?s/a:void 0,bytes:c,rate:u||void 0,estimated:u&&a&&f?(a-s)/u:void 0,event:i,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(l)},r)},_f=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},Tf=e=>(...t)=>Y.asap(()=>e(...t)),I0=ir.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,ir.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(ir.origin),ir.navigator&&/(msie|trident)/i.test(ir.navigator.userAgent)):()=>!0,O0=ir.hasStandardBrowserEnv?{write(e,t,r,n,o,i,s){if(typeof document>"u")return;const a=[`${e}=${encodeURIComponent(t)}`];Y.isNumber(r)&&a.push(`expires=${new Date(r).toUTCString()}`),Y.isString(n)&&a.push(`path=${n}`),Y.isString(o)&&a.push(`domain=${o}`),i===!0&&a.push("secure"),Y.isString(s)&&a.push(`SameSite=${s}`),document.cookie=a.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function M0(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function L0(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Ff(e,t,r){let n=!M0(t);return e&&(n||r==!1)?L0(e,t):t}const Pf=e=>e instanceof hr?{...e}:e;function Jn(e,t){t=t||{};const r={};function n(u,f,l,p){return Y.isPlainObject(u)&&Y.isPlainObject(f)?Y.merge.call({caseless:p},u,f):Y.isPlainObject(f)?Y.merge({},f):Y.isArray(f)?f.slice():f}function o(u,f,l,p){if(Y.isUndefined(f)){if(!Y.isUndefined(u))return n(void 0,u,l,p)}else return n(u,f,l,p)}function i(u,f){if(!Y.isUndefined(f))return n(void 0,f)}function s(u,f){if(Y.isUndefined(f)){if(!Y.isUndefined(u))return n(void 0,u)}else return n(void 0,f)}function a(u,f,l){if(l in t)return n(u,f);if(l in e)return n(void 0,u)}const c={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(u,f,l)=>o(Pf(u),Pf(f),l,!0)};return Y.forEach(Object.keys({...e,...t}),function(f){if(f==="__proto__"||f==="constructor"||f==="prototype")return;const l=Y.hasOwnProp(c,f)?c[f]:o,p=l(e[f],t[f],f);Y.isUndefined(p)&&l!==a||(r[f]=p)}),r}const If=e=>{const t=Jn({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:o,xsrfCookieName:i,headers:s,auth:a}=t;if(t.headers=s=hr.from(s),t.url=xf(Ff(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),Y.isFormData(r)){if(ir.hasStandardBrowserEnv||ir.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if(Y.isFunction(r.getHeaders)){const c=r.getHeaders(),u=["content-type","content-length"];Object.entries(c).forEach(([f,l])=>{u.includes(f.toLowerCase())&&s.set(f,l)})}}if(ir.hasStandardBrowserEnv&&(n&&Y.isFunction(n)&&(n=n(t)),n||n!==!1&&I0(t.url))){const c=o&&i&&O0.read(i);c&&s.set(o,c)}return t},D0=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(r,n){const o=If(e);let i=o.data;const s=hr.from(o.headers).normalize();let{responseType:a,onUploadProgress:c,onDownloadProgress:u}=o,f,l,p,g,m;function h(){g&&g(),m&&m(),o.cancelToken&&o.cancelToken.unsubscribe(f),o.signal&&o.signal.removeEventListener("abort",f)}let y=new XMLHttpRequest;y.open(o.method.toUpperCase(),o.url,!0),y.timeout=o.timeout;function S(){if(!y)return;const A=hr.from("getAllResponseHeaders"in y&&y.getAllResponseHeaders()),F={data:!a||a==="text"||a==="json"?y.responseText:y.response,status:y.status,statusText:y.statusText,headers:A,config:e,request:y};Nf(function(N){r(N),h()},function(N){n(N),h()},F),y=null}"onloadend"in y?y.onloadend=S:y.onreadystatechange=function(){!y||y.readyState!==4||y.status===0&&!(y.responseURL&&y.responseURL.indexOf("file:")===0)||setTimeout(S)},y.onabort=function(){y&&(n(new Ke("Request aborted",Ke.ECONNABORTED,e,y)),y=null)},y.onerror=function(x){const F=x&&x.message?x.message:"Network Error",k=new Ke(F,Ke.ERR_NETWORK,e,y);k.event=x||null,n(k),y=null},y.ontimeout=function(){let x=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const F=o.transitional||xl;o.timeoutErrorMessage&&(x=o.timeoutErrorMessage),n(new Ke(x,F.clarifyTimeoutError?Ke.ETIMEDOUT:Ke.ECONNABORTED,e,y)),y=null},i===void 0&&s.setContentType(null),"setRequestHeader"in y&&Y.forEach(s.toJSON(),function(x,F){y.setRequestHeader(F,x)}),Y.isUndefined(o.withCredentials)||(y.withCredentials=!!o.withCredentials),a&&a!=="json"&&(y.responseType=o.responseType),u&&([p,m]=ws(u,!0),y.addEventListener("progress",p)),c&&y.upload&&([l,g]=ws(c),y.upload.addEventListener("progress",l),y.upload.addEventListener("loadend",g)),(o.cancelToken||o.signal)&&(f=A=>{y&&(n(!A||A.type?new pi(null,e,y):A),y.abort(),y=null)},o.cancelToken&&o.cancelToken.subscribe(f),o.signal&&(o.signal.aborted?f():o.signal.addEventListener("abort",f)));const v=T0(o.url);if(v&&ir.protocols.indexOf(v)===-1){n(new Ke("Unsupported protocol "+v+":",Ke.ERR_BAD_REQUEST,e));return}y.send(i||null)})},B0=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,o;const i=function(u){if(!o){o=!0,a();const f=u instanceof Error?u:this.reason;n.abort(f instanceof Ke?f:new pi(f instanceof Error?f.message:f))}};let s=t&&setTimeout(()=>{s=null,i(new Ke(`timeout of ${t}ms exceeded`,Ke.ETIMEDOUT))},t);const a=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(i):u.removeEventListener("abort",i)}),e=null)};e.forEach(u=>u.addEventListener("abort",i));const{signal:c}=n;return c.unsubscribe=()=>Y.asap(a),c}},$0=function*(e,t){let r=e.byteLength;if(r<t){yield e;return}let n=0,o;for(;n<r;)o=n+t,yield e.slice(n,o),n=o},j0=async function*(e,t){for await(const r of H0(e))yield*$0(r,t)},H0=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},Of=(e,t,r,n)=>{const o=j0(e,t);let i=0,s,a=c=>{s||(s=!0,n&&n(c))};return new ReadableStream({async pull(c){try{const{done:u,value:f}=await o.next();if(u){a(),c.close();return}let l=f.byteLength;if(r){let p=i+=l;r(p)}c.enqueue(new Uint8Array(f))}catch(u){throw a(u),u}},cancel(c){return a(c),o.return()}},{highWaterMark:2})},Mf=64*1024,{isFunction:Ss}=Y,U0=(({Request:e,Response:t})=>({Request:e,Response:t}))(Y.global),{ReadableStream:Lf,TextEncoder:Df}=Y.global,Bf=(e,...t)=>{try{return!!e(...t)}catch{return!1}},z0=e=>{e=Y.merge.call({skipUndefined:!0},U0,e);const{fetch:t,Request:r,Response:n}=e,o=t?Ss(t):typeof fetch=="function",i=Ss(r),s=Ss(n);if(!o)return!1;const a=o&&Ss(Lf),c=o&&(typeof Df=="function"?(m=>h=>m.encode(h))(new Df):async m=>new Uint8Array(await new r(m).arrayBuffer())),u=i&&a&&Bf(()=>{let m=!1;const h=new Lf,y=new r(ir.origin,{body:h,method:"POST",get duplex(){return m=!0,"half"}}).headers.has("Content-Type");return h.cancel(),m&&!y}),f=s&&a&&Bf(()=>Y.isReadableStream(new n("").body)),l={stream:f&&(m=>m.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(m=>{!l[m]&&(l[m]=(h,y)=>{let S=h&&h[m];if(S)return S.call(h);throw new Ke(`Response type '${m}' is not supported`,Ke.ERR_NOT_SUPPORT,y)})});const p=async m=>{if(m==null)return 0;if(Y.isBlob(m))return m.size;if(Y.isSpecCompliantForm(m))return(await new r(ir.origin,{method:"POST",body:m}).arrayBuffer()).byteLength;if(Y.isArrayBufferView(m)||Y.isArrayBuffer(m))return m.byteLength;if(Y.isURLSearchParams(m)&&(m=m+""),Y.isString(m))return(await c(m)).byteLength},g=async(m,h)=>{const y=Y.toFiniteNumber(m.getContentLength());return y??p(h)};return async m=>{let{url:h,method:y,data:S,signal:v,cancelToken:A,timeout:x,onDownloadProgress:F,onUploadProgress:k,responseType:N,headers:T,withCredentials:P="same-origin",fetchOptions:E}=If(m),C=t||fetch;N=N?(N+"").toLowerCase():"text";let O=B0([v,A&&A.toAbortSignal()],x),W=null;const M=O&&O.unsubscribe&&(()=>{O.unsubscribe()});let U;try{if(k&&u&&y!=="get"&&y!=="head"&&(U=await g(T,S))!==0){let K=new r(h,{method:"POST",body:S,duplex:"half"}),le;if(Y.isFormData(S)&&(le=K.headers.get("content-type"))&&T.setContentType(le),K.body){const[j,H]=_f(U,ws(Tf(k)));S=Of(K.body,Mf,j,H)}}Y.isString(P)||(P=P?"include":"omit");const z=i&&"credentials"in r.prototype,X={...E,signal:O,method:y.toUpperCase(),headers:T.normalize().toJSON(),body:S,duplex:"half",credentials:z?P:void 0};W=i&&new r(h,X);let B=await(i?C(W,E):C(h,X));const L=f&&(N==="stream"||N==="response");if(f&&(F||L&&M)){const K={};["status","statusText","headers"].forEach(ce=>{K[ce]=B[ce]});const le=Y.toFiniteNumber(B.headers.get("content-length")),[j,H]=F&&_f(le,ws(Tf(F),!0))||[];B=new n(Of(B.body,Mf,j,()=>{H&&H(),M&&M()}),K)}N=N||"text";let D=await l[Y.findKey(l,N)||"text"](B,m);return!L&&M&&M(),await new Promise((K,le)=>{Nf(K,le,{data:D,headers:hr.from(B.headers),status:B.status,statusText:B.statusText,config:m,request:W})})}catch(z){throw M&&M(),z&&z.name==="TypeError"&&/Load failed|fetch/i.test(z.message)?Object.assign(new Ke("Network Error",Ke.ERR_NETWORK,m,W,z&&z.response),{cause:z.cause||z}):Ke.from(z,z&&z.code,m,W,z&&z.response)}}},V0=new Map,$f=e=>{let t=e&&e.env||{};const{fetch:r,Request:n,Response:o}=t,i=[n,o,r];let s=i.length,a=s,c,u,f=V0;for(;a--;)c=i[a],u=f.get(c),u===void 0&&f.set(c,u=a?new Map:z0(t)),f=u;return u};$f();const Nl={http:u0,xhr:D0,fetch:{get:$f}};Y.forEach(Nl,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const jf=e=>`- ${e}`,W0=e=>Y.isFunction(e)||e===null||e===!1;function R0(e,t){e=Y.isArray(e)?e:[e];const{length:r}=e;let n,o;const i={};for(let s=0;s<r;s++){n=e[s];let a;if(o=n,!W0(n)&&(o=Nl[(a=String(n)).toLowerCase()],o===void 0))throw new Ke(`Unknown adapter '${a}'`);if(o&&(Y.isFunction(o)||(o=o.get(t))))break;i[a||"#"+s]=o}if(!o){const s=Object.entries(i).map(([c,u])=>`adapter ${c} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=r?s.length>1?`since :
|
|
4
|
+
`+s.map(jf).join(`
|
|
5
|
+
`):" "+jf(s[0]):"as no adapter specified";throw new Ke("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o}const Hf={getAdapter:R0,adapters:Nl};function _l(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new pi(null,e)}function Uf(e){return _l(e),e.headers=hr.from(e.headers),e.data=kl.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Hf.getAdapter(e.adapter||ui.adapter,e)(e).then(function(n){return _l(e),n.data=kl.call(e,e.transformResponse,n),n.headers=hr.from(n.headers),n},function(n){return kf(n)||(_l(e),n&&n.response&&(n.response.data=kl.call(e,e.transformResponse,n.response),n.response.headers=hr.from(n.response.headers))),Promise.reject(n)})}const zf="1.14.0",xs={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{xs[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const Vf={};xs.transitional=function(t,r,n){function o(i,s){return"[Axios v"+zf+"] Transitional option '"+i+"'"+s+(n?". "+n:"")}return(i,s,a)=>{if(t===!1)throw new Ke(o(s," has been removed"+(r?" in "+r:"")),Ke.ERR_DEPRECATED);return r&&!Vf[s]&&(Vf[s]=!0,console.warn(o(s," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(i,s,a):!0}},xs.spelling=function(t){return(r,n)=>(console.warn(`${n} is likely a misspelling of ${t}`),!0)};function K0(e,t,r){if(typeof e!="object")throw new Ke("options must be an object",Ke.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let o=n.length;for(;o-- >0;){const i=n[o],s=t[i];if(s){const a=e[i],c=a===void 0||s(a,i,e);if(c!==!0)throw new Ke("option "+i+" must be "+c,Ke.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new Ke("Unknown option "+i,Ke.ERR_BAD_OPTION)}}const As={assertOptions:K0,validators:xs},Or=As.validators;let Qn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Af,response:new Af}}async request(t,r){try{return await this._request(t,r)}catch(n){if(n instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const i=o.stack?o.stack.replace(/^.+\n/,""):"";try{n.stack?i&&!String(n.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(n.stack+=`
|
|
6
|
+
`+i):n.stack=i}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=Jn(this.defaults,r);const{transitional:n,paramsSerializer:o,headers:i}=r;n!==void 0&&As.assertOptions(n,{silentJSONParsing:Or.transitional(Or.boolean),forcedJSONParsing:Or.transitional(Or.boolean),clarifyTimeoutError:Or.transitional(Or.boolean),legacyInterceptorReqResOrdering:Or.transitional(Or.boolean)},!1),o!=null&&(Y.isFunction(o)?r.paramsSerializer={serialize:o}:As.assertOptions(o,{encode:Or.function,serialize:Or.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),As.assertOptions(r,{baseUrl:Or.spelling("baseURL"),withXsrfToken:Or.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s=i&&Y.merge(i.common,i[r.method]);i&&Y.forEach(["delete","get","head","post","put","patch","common"],m=>{delete i[m]}),r.headers=hr.concat(s,i);const a=[];let c=!0;this.interceptors.request.forEach(function(h){if(typeof h.runWhen=="function"&&h.runWhen(r)===!1)return;c=c&&h.synchronous;const y=r.transitional||xl;y&&y.legacyInterceptorReqResOrdering?a.unshift(h.fulfilled,h.rejected):a.push(h.fulfilled,h.rejected)});const u=[];this.interceptors.response.forEach(function(h){u.push(h.fulfilled,h.rejected)});let f,l=0,p;if(!c){const m=[Uf.bind(this),void 0];for(m.unshift(...a),m.push(...u),p=m.length,f=Promise.resolve(r);l<p;)f=f.then(m[l++],m[l++]);return f}p=a.length;let g=r;for(;l<p;){const m=a[l++],h=a[l++];try{g=m(g)}catch(y){h.call(this,y);break}}try{f=Uf.call(this,g)}catch(m){return Promise.reject(m)}for(l=0,p=u.length;l<p;)f=f.then(u[l++],u[l++]);return f}getUri(t){t=Jn(this.defaults,t);const r=Ff(t.baseURL,t.url,t.allowAbsoluteUrls);return xf(r,t.params,t.paramsSerializer)}};Y.forEach(["delete","get","head","options"],function(t){Qn.prototype[t]=function(r,n){return this.request(Jn(n||{},{method:t,url:r,data:(n||{}).data}))}}),Y.forEach(["post","put","patch"],function(t){function r(n){return function(i,s,a){return this.request(Jn(a||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:s}))}}Qn.prototype[t]=r(),Qn.prototype[t+"Form"]=r(!0)});let G0=class pv{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});const n=this;this.promise.then(o=>{if(!n._listeners)return;let i=n._listeners.length;for(;i-- >0;)n._listeners[i](o);n._listeners=null}),this.promise.then=o=>{let i;const s=new Promise(a=>{n.subscribe(a),i=a}).then(o);return s.cancel=function(){n.unsubscribe(i)},s},t(function(i,s,a){n.reason||(n.reason=new pi(i,s,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new pv(function(o){t=o}),cancel:t}}};function q0(e){return function(r){return e.apply(null,r)}}function Y0(e){return Y.isObject(e)&&e.isAxiosError===!0}const Tl={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Tl).forEach(([e,t])=>{Tl[t]=e});function Wf(e){const t=new Qn(e),r=lf(Qn.prototype.request,t);return Y.extend(r,Qn.prototype,t,{allOwnKeys:!0}),Y.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return Wf(Jn(e,o))},r}const At=Wf(ui);At.Axios=Qn,At.CanceledError=pi,At.CancelToken=G0,At.isCancel=kf,At.VERSION=zf,At.toFormData=bs,At.AxiosError=Ke,At.Cancel=At.CanceledError,At.all=function(t){return Promise.all(t)},At.spread=q0,At.isAxiosError=Y0,At.mergeConfig=Jn,At.AxiosHeaders=hr,At.formToJSON=e=>Cf(Y.isHTMLForm(e)?new FormData(e):e),At.getAdapter=Hf.getAdapter,At.HttpStatusCode=Tl,At.default=At;const{Axios:$M,AxiosError:X0,CanceledError:jM,isCancel:HM,CancelToken:UM,VERSION:zM,all:VM,Cancel:WM,isAxiosError:RM,spread:KM,toFormData:GM,AxiosHeaders:qM,HttpStatusCode:YM,formToJSON:XM,getAdapter:JM,mergeConfig:QM}=At;let Rf=null;function Kf(e){Rf=e}function Gf(){return(Rf?.()??"").replace(/\/+$/,"")}function Mr(e){const t=typeof e=="string"?e.trim():"";if(!t||/^https?:\/\//i.test(t))return t;const r=Gf();return r?t.startsWith("/")?`${r}${t}`:`${r}/${t}`:t}const qf={};function nn(){const e=qf?.VITE_CLIENT_ID?.trim()||qf?.VITE_DEFAULT_CLIENT_ID?.trim()||null;return(typeof localStorage<"u"?localStorage.getItem("clientId"):null)||(typeof sessionStorage<"u"?sessionStorage.getItem("clientId"):null)||(typeof window<"u"?new URLSearchParams(window.location.search).get("clientId"):null)||e}function J0(e){return!e||typeof e!="object"?!1:e.userId!=null&&String(e.userId)!==""||e.userType!=null&&String(e.userType)!==""||e.role!=null&&String(e.role)!==""}function Q0(e){if(!e||typeof e!="object")return;const t={};for(const[r,n]of Object.entries(e))n!==void 0&&n!==""&&(t[r]=n);return Object.keys(t).length>0?t:void 0}const Zn=Su(e=>({viewerContext:void 0,authHeaders:void 0,_setViewerContext:t=>e({viewerContext:J0(t)?t:void 0}),_setAuthHeaders:t=>e({authHeaders:Q0(t)}),_reset:()=>e({viewerContext:void 0,authHeaders:void 0})}));function Z0(e){Zn.getState()._setViewerContext(e)}function ex(e){Zn.getState()._setAuthHeaders(e)}function tx(){Zn.getState()._reset()}function Yf(){return Zn.getState().viewerContext}function mi(){return Zn.getState().authHeaders}const Xf={};let Jf=null;function Qf(e){Jf=e}function rx(){return(Xf?.VITE_API_BASE_URL?.trim()||Xf?.VITE_API_URL?.trim()||"").replace(/\/$/,"")}const qt=At.create({baseURL:rx()});qt.interceptors.request.use(e=>{const t=nn();t&&(e.params={...e.params,clientId:t}),typeof FormData<"u"&&e.data instanceof FormData&&delete e.headers["Content-Type"];let r=Jf?.();if((!r||Object.keys(r).length===0)&&(r=mi()),r){const n=e.headers??{};for(const[o,i]of Object.entries(r))i!==void 0&&i!==""&&(n[o]=i);e.headers=n}return e});const nx=/^\{([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\}$/i;function Zf(e){const t=e.trim().match(nx);return t?t[1]:e}const ox={applicantId:["id","applicant_id"],applicant_id:["id","applicantId"],id:["applicantId","applicant_id"]};function Rr(e,t,r,n,o,i){let s=e;if(o&&typeof e=="string"&&(s=s.replace(/\{resp:([^}]+)\}/g,(a,c)=>{const u=c.trim().split(".");if(u.length<2)return a;const f=u[0],l=u.slice(1).join("."),p=o[f];if(p==null)return a;const g=We(p,l);return g==null?a:String(g)}),s.includes("{documentId}")||s.includes("%7BdocumentId%7D"))){let a;for(const c of Object.values(o)){const u=We(c,"data.id")??We(c,"data.documentId");if(u!=null){a=String(u);break}}a&&(s=s.replace(/\{documentId\}/g,a).replace(/%7BdocumentId%7D/gi,a))}if(s.includes("{documentId}")||s.includes("%7BdocumentId%7D")){let a;const c=t?.documentId??(t&&We(t,"documentId")),u=n?.documentId??(n&&We(n,"documentId"));c!=null&&c!==""?a=String(c):u!=null&&u!==""&&(a=String(u)),a&&(s=s.replace(/\{documentId\}/g,a).replace(/%7BdocumentId%7D/gi,a))}return s=s.replace(/\{api:([^}]+)\}/g,(a,c)=>{const u=c.trim();if(i==null||u==="")return a;const f=We(i,u);return f==null?a:String(f)}),s=s.replace(/\{(?:ctx:|\@)(\w+)\}/g,(a,c)=>n&&n[c]!==void 0&&n[c]!==null?String(n[c]):a),s=s.replace(/\{(\w+)\}/g,(a,c)=>{if(a.includes("ctx:")||a.includes("@"))return a;const u=r[c];if(u!=null)return Zf(String(u));let f=t[c];if(f==null||f===""){const l=Object.keys(t).find(p=>p.toLowerCase()===c.toLowerCase());l&&(f=t[l])}if((f==null||f==="")&&(f=n?.[c]),f==null||f===""){const l=ox[c];if(l)for(const p of l){const g=t[p]??n?.[p];if(g!=null&&g!==""){f=g;break}}}return f!=null&&f!==""?Zf(String(f)):a}),s}const ix=60,sx=3,ax="Resend OTP in {seconds} sec · Attempts remaining: {attempts}",lx="Resend OTP";function cx(e){const t=e.properties?.resend;return!t?.enabled||!t.resendApiEndpoint?.trim()?null:t}function ep(e){const t=Number(e.cooldownSeconds);return!Number.isFinite(t)||t<0?ix:Math.round(t)}function tp(e){const t=Number(e.maxAttempts);return!Number.isFinite(t)||t<1?sx:Math.round(t)}function rp(e,t,r){if(!t?.trim()||e==null)return r;const n=We(e,t.trim()),o=typeof n=="number"?n:Number(n);return!Number.isFinite(o)||o<0?r:Math.round(o)}function np(e,t,r){if(!t?.trim()||e==null)return r;const n=We(e,t.trim()),o=typeof n=="number"?n:Number(n);return!Number.isFinite(o)||o<0?r:Math.round(o)}function dx(e,t){const r=tp(e),n=ep(e),o=e.initialAttemptsPath??"data.attempts_remaining",i=e.initialCooldownPath??"data.resend_cooldown_seconds";return{attemptsRemaining:rp(t,o,r),secondsRemaining:np(t,i,n)}}function ux(e,t,r){tp(e);const n=ep(e),o=e.attemptsResponsePath??"data.attempts_remaining",i=e.cooldownResponsePath??"data.resend_cooldown_seconds";return{attemptsRemaining:rp(t,o,r),secondsRemaining:np(t,i,n)}}function fx(e,t,r,n){const o=e.resendLinkText?.trim()||lx,i=!n&&t<=0&&r>0;return{seconds:Math.max(0,t),attempts:Math.max(0,r),resendText:o,resendEnabled:i}}function px(e,t){const r=e.statusTemplate?.trim()||ax,n=t.seconds>0?` in ${t.seconds} sec`:"",o=t.resendEnabled?t.resendText:t.seconds>0?`${t.resendText}${n}`:t.resendText;return r.replace(/\{seconds\}/g,String(t.seconds)).replace(/\{attempts\}/g,String(t.attempts)).replace(/\{resend\}/g,o)}async function mx(e,t={}){const r=e.resendApiEndpoint?.trim();if(!r)throw new Error("Resend API endpoint is not configured");const{formValues:n={},urlParams:o={},submissionContext:i,prepopulateResponse:s}=t,a=m=>Rr(m,n,o,i,void 0,s),c=(e.resendApiMethod??"POST").toUpperCase();let u=Mr(a(r));const f=e.resendApiQueryParams??[];if(f.length){const m=new URLSearchParams;f.forEach(({key:y,value:S})=>{y.trim()&&m.append(y,a(S))});const h=m.toString();h&&(u=`${u}${u.includes("?")?"&":"?"}${h}`)}const l={};let p=!1;(e.resendApiHeaders??[]).forEach(({key:m,value:h})=>{m.trim()&&(l[m]=a(h))});let g;c!=="GET"&&(e.resendApiBodyFields??[]).length&&(g={},e.resendApiBodyFields.forEach(({key:m,value:h})=>{m.trim()&&(g[m]=a(h))}),p=!0),p&&!l["Content-Type"]&&!l["content-type"]&&(l["Content-Type"]="application/json");try{return c==="GET"?(await qt.get(u,{headers:Object.keys(l).length?l:void 0})).data:(await qt.request({url:u,method:c,data:g??{},headers:Object.keys(l).length?l:void 0})).data}catch(m){const h=m,y=h.response?.status,S=typeof h.response?.data=="string"?h.response.data:h.message??"Request failed";throw new Error(y?`HTTP ${y}: ${S}`:String(S))}}function Kr(e){if(e instanceof Error){const t=e.message;if(t&&(t.includes("{")||t.includes("[")))try{const r=t.match(/\{[\s\S]*\}/);if(r){const n=JSON.parse(r[0]);return bo(n)}}catch{}if(e.response){const r=e.response;if(typeof r=="string")try{const n=JSON.parse(r);return bo(n)}catch{return r}else if(typeof r=="object")return bo(r)}return t}if(e instanceof X0)return e.response?.data?bo(e.response.data):e.message||"An unexpected error occurred";if(typeof e=="string")try{const t=JSON.parse(e);return bo(t)}catch{return e}return typeof e=="object"&&e!==null?bo(e):"An unexpected error occurred"}function bo(e){if(e?.display_message&&typeof e.display_message=="string")return e.display_message.trim();if(e?.errors&&Array.isArray(e.errors)){const t=e.errors.filter(r=>r&&typeof r=="string");if(t.length>0)return t.join(". ")}if(e?.error?.explanation&&Array.isArray(e.error.explanation)){const t=e.error.explanation.filter(r=>r&&typeof r=="string");if(t.length>0)return t.join(". ")}if(e?.explanation&&Array.isArray(e.explanation)){const t=e.explanation.filter(r=>r&&typeof r=="string");if(t.length>0)return t.join(". ")}if(e?.errors&&Array.isArray(e.errors)){const t=e.errors.filter(r=>r!=null&&String(r).trim());if(t.length>0)return t.map(r=>typeof r=="string"?r:r?.message||String(r)).join(". ")}return e?.message&&typeof e.message=="string"?e.message:e?.display_message&&typeof e.display_message=="string"?e.display_message:e?.error?.display_message&&typeof e.error.display_message=="string"?e.error.display_message:e?.error?.message&&typeof e.error.message=="string"?e.error.message:e?.error&&typeof e.error=="string"?e.error:"An unexpected error occurred"}const op=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:c,formValues:u={},urlParams:f={},submissionContext:l,prepopulateResponse:p})=>{const g=Cu(e),m=e.properties?.numericOnly!==!1,h=cx(e),y=w.useRef([]),S=w.useMemo(()=>Ew(t,g),[t,g]),v=w.useMemo(()=>h?dx(h,p):null,[h,p]),[A,x]=w.useState(()=>v?.secondsRemaining??0),[F,k]=w.useState(()=>v?.attemptsRemaining??0),[N,T]=w.useState(!1);w.useEffect(()=>{y.current=y.current.slice(0,g)},[g]),w.useEffect(()=>{v&&(x(v.secondsRemaining),k(v.attemptsRemaining))},[v]),w.useEffect(()=>{if(!h||A<=0)return;const D=window.setInterval(()=>{x(K=>K<=1?0:K-1)},1e3);return()=>window.clearInterval(D)},[h,A>0]);const P=w.useMemo(()=>h?fx(h,A,F,N):null,[h,A,F,N]),E=w.useMemo(()=>!h||!P?"":px(h,P),[h,P]),C=w.useCallback(async()=>{if(!(!h||!P?.resendEnabled||N)){T(!0);try{const D=await mx(h,{formValues:u,urlParams:f,submissionContext:l,prepopulateResponse:p}),K=ux(h,D,F);k(K.attemptsRemaining),x(K.secondsRemaining),r(""),at.toast.success("OTP sent successfully.")}catch(D){at.toast.error(Kr(D))}finally{T(!1)}}},[h,P?.resendEnabled,N,u,f,l,p,F,r]),O=w.useCallback(D=>{r(kw(D))},[r]),W=w.useCallback(D=>{const K=y.current[D];K&&(K.focus(),K.select())},[]),M=w.useCallback((D,K=0)=>{const le=m?D.replace(/\D/g,""):D.replace(/\s/g,"");if(!le)return;const j=[...S];let H=K;for(let ie=0;ie<le.length&&H<g;ie+=1)j[H]=le[ie]??"",H+=1;O(j);const ce=Math.min(H,g-1);requestAnimationFrame(()=>W(ce))},[S,O,W,m,g]),U=w.useCallback((D,K)=>{if(s||i||e.readOnly||e.disabled)return;const le=m?K.replace(/\D/g,""):K.slice(-1),j=[...S];j[D]=le,O(j),le&&D<g-1&&requestAnimationFrame(()=>W(D+1))},[S,i,O,e.disabled,e.readOnly,W,m,g,s]),z=w.useCallback((D,K)=>{if(K.key==="Backspace"&&!S[D]&&D>0){K.preventDefault();const le=[...S];le[D-1]="",O(le),W(D-1);return}if(K.key==="ArrowLeft"&&D>0){K.preventDefault(),W(D-1);return}K.key==="ArrowRight"&&D<g-1&&(K.preventDefault(),W(D+1))},[S,O,W,g]),X=w.useCallback((D,K)=>{K.preventDefault();const le=K.clipboardData.getData("text");M(le,D)},[M]),B=ft(e),L=h?.resendLinkText?.trim()||"Resend OTP";return d.jsx(Ct,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"space-y-2",children:[d.jsx("div",{className:"flex flex-wrap items-center gap-2",role:"group","aria-labelledby":`${B}-label`,"aria-describedby":Lt(e,!!o),children:S.map((D,K)=>d.jsx(gn,{ref:le=>{y.current[K]=le},id:K===0?B:`${B}-${K}`,type:m?"tel":"text",inputMode:m?"numeric":"text",autoComplete:K===0?"one-time-code":"off",maxLength:1,value:D,onChange:le=>U(K,le.target.value),onKeyDown:le=>z(K,le),onPaste:le=>X(K,le),onBlur:K===g-1?n:void 0,disabled:i||e.disabled,readOnly:s||e.readOnly,"aria-label":`${e.label||e.name} digit ${K+1} of ${g}`,"aria-invalid":Jt(!!o),"aria-required":a,className:V(fo(e.appearance),"h-10 w-10 text-center text-base font-medium p-0",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)},`${e.id}-otp-${K}`))}),h&&P&&d.jsx("p",{className:"text-sm text-muted-foreground","aria-live":"polite",children:P.resendEnabled?d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:"text-primary underline-offset-4 hover:underline disabled:opacity-50",disabled:i||N,onClick:C,children:N?"Sending…":L}),d.jsx("span",{children:` · Attempts remaining: ${F}`})]}):d.jsx("span",{children:F<=0&&A<=0?"No attempts remaining.":E})})]})})};function hx({className:e,maxLength:t,showCharacterCount:r=!1,autoResize:n=!1,onChange:o,value:i,...s}){const a=b.useRef(null),[c,u]=b.useState(0),f=l=>{const p=l.target.value;u(p.length),n&&a.current&&(a.current.style.height="auto",a.current.style.height=`${a.current.scrollHeight}px`),o&&o(l)};return b.useEffect(()=>{i&&u(String(i).length)},[i]),d.jsxs("div",{className:"space-y-1",children:[d.jsx("textarea",{ref:a,"data-slot":"textarea",className:V("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",n&&"resize-none",e),maxLength:t,onChange:f,value:i,...s}),r&&d.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[d.jsxs("span",{children:[c," characters"]}),t&&d.jsxs("span",{children:[t-c," remaining"]})]})]})}const ip=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:c})=>{const{gridStretch:u}=ti(),f=u&&ts(e),l=e.properties,p=w.useCallback(y=>{r(y.target.value)},[r]),g=(t||"").length,m=l?.maxLength,h=m&&m>0;return d.jsx(Ct,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:V("relative flex flex-col",f&&"flex-1 min-h-0"),children:[d.jsx(hx,{id:ft(e),value:t||"",onChange:p,onBlur:n,placeholder:e.placeholder,disabled:i||e.disabled,readOnly:s||e.readOnly,minLength:l?.minLength,maxLength:l?.maxLength,rows:2,"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:V(cu(e.appearance),"resize-y",f&&"min-h-[120px] flex-1 flex-shrink-0",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)}),h&&d.jsxs("span",{className:"absolute bottom-2 right-2 text-xs text-muted-foreground",children:[g,"/",m]})]})})};function hi(e,[t,r]){return Math.min(r,Math.max(t,e))}function Oe(e,t,{checkForDefaultPrevented:r=!0}={}){return function(o){if(e?.(o),r===!1||!o.defaultPrevented)return t?.(o)}}function gx(e,t){const r=b.createContext(t),n=i=>{const{children:s,...a}=i,c=b.useMemo(()=>a,Object.values(a));return d.jsx(r.Provider,{value:c,children:s})};n.displayName=e+"Provider";function o(i){const s=b.useContext(r);if(s)return s;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[n,o]}function Sr(e,t=[]){let r=[];function n(i,s){const a=b.createContext(s),c=r.length;r=[...r,s];const u=l=>{const{scope:p,children:g,...m}=l,h=p?.[e]?.[c]||a,y=b.useMemo(()=>m,Object.values(m));return d.jsx(h.Provider,{value:y,children:g})};u.displayName=i+"Provider";function f(l,p){const g=p?.[e]?.[c]||a,m=b.useContext(g);if(m)return m;if(s!==void 0)return s;throw new Error(`\`${l}\` must be used within \`${i}\``)}return[u,f]}const o=()=>{const i=r.map(s=>b.createContext(s));return function(a){const c=a?.[e]||i;return b.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[n,yx(o,...t)]}function yx(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const n=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const s=n.reduce((a,{useScope:c,scopeName:u})=>{const l=c(i)[`__scope${u}`];return{...a,...l}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return r.scopeName=t.scopeName,r}function sp(e){const t=bx(e),r=b.forwardRef((n,o)=>{const{children:i,...s}=n,a=b.Children.toArray(i),c=a.find(wx);if(c){const u=c.props.children,f=a.map(l=>l===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:l);return d.jsx(t,{...s,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,f):null})}return d.jsx(t,{...s,ref:o,children:i})});return r.displayName=`${e}.Slot`,r}function bx(e){const t=b.forwardRef((r,n)=>{const{children:o,...i}=r;if(b.isValidElement(o)){const s=xx(o),a=Sx(i,o.props);return o.type!==b.Fragment&&(a.ref=n?Yn(n,s):s),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var vx=Symbol("radix.slottable");function wx(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===vx}function Sx(e,t){const r={...t};for(const n in t){const o=e[n],i=t[n];/^on[A-Z]/.test(n)?o&&i?r[n]=(...a)=>{const c=i(...a);return o(...a),c}:o&&(r[n]=o):n==="style"?r[n]={...o,...i}:n==="className"&&(r[n]=[o,i].filter(Boolean).join(" "))}return{...e,...r}}function xx(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function Fl(e){const t=e+"CollectionProvider",[r,n]=Sr(t),[o,i]=r(t,{collectionRef:{current:null},itemMap:new Map}),s=h=>{const{scope:y,children:S}=h,v=w.useRef(null),A=w.useRef(new Map).current;return d.jsx(o,{scope:y,itemMap:A,collectionRef:v,children:S})};s.displayName=t;const a=e+"CollectionSlot",c=sp(a),u=w.forwardRef((h,y)=>{const{scope:S,children:v}=h,A=i(a,S),x=qe(y,A.collectionRef);return d.jsx(c,{ref:x,children:v})});u.displayName=a;const f=e+"CollectionItemSlot",l="data-radix-collection-item",p=sp(f),g=w.forwardRef((h,y)=>{const{scope:S,children:v,...A}=h,x=w.useRef(null),F=qe(y,x),k=i(f,S);return w.useEffect(()=>(k.itemMap.set(x,{ref:x,...A}),()=>{k.itemMap.delete(x)})),d.jsx(p,{[l]:"",ref:F,children:v})});g.displayName=f;function m(h){const y=i(e+"CollectionConsumer",h);return w.useCallback(()=>{const v=y.collectionRef.current;if(!v)return[];const A=Array.from(v.querySelectorAll(`[${l}]`));return Array.from(y.itemMap.values()).sort((k,N)=>A.indexOf(k.ref.current)-A.indexOf(N.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:s,Slot:u,ItemSlot:g},m,n]}var Ax=b.createContext(void 0);function vo(e){const t=b.useContext(Ax);return e||t||"ltr"}function Cx(e){const t=Ex(e),r=b.forwardRef((n,o)=>{const{children:i,...s}=n,a=b.Children.toArray(i),c=a.find(Nx);if(c){const u=c.props.children,f=a.map(l=>l===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:l);return d.jsx(t,{...s,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,f):null})}return d.jsx(t,{...s,ref:o,children:i})});return r.displayName=`${e}.Slot`,r}function Ex(e){const t=b.forwardRef((r,n)=>{const{children:o,...i}=r;if(b.isValidElement(o)){const s=Tx(o),a=_x(i,o.props);return o.type!==b.Fragment&&(a.ref=n?Yn(n,s):s),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var kx=Symbol("radix.slottable");function Nx(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===kx}function _x(e,t){const r={...t};for(const n in t){const o=e[n],i=t[n];/^on[A-Z]/.test(n)?o&&i?r[n]=(...a)=>{const c=i(...a);return o(...a),c}:o&&(r[n]=o):n==="style"?r[n]={...o,...i}:n==="className"&&(r[n]=[o,i].filter(Boolean).join(" "))}return{...e,...r}}function Tx(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var Fx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],$e=Fx.reduce((e,t)=>{const r=Cx(`Primitive.${t}`),n=b.forwardRef((o,i)=>{const{asChild:s,...a}=o,c=s?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(c,{...a,ref:i})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function Px(e,t){e&&Gi.flushSync(()=>e.dispatchEvent(t))}function dr(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),b.useMemo(()=>(...r)=>t.current?.(...r),[])}function Ix(e,t=globalThis?.document){const r=dr(e);b.useEffect(()=>{const n=o=>{o.key==="Escape"&&r(o)};return t.addEventListener("keydown",n,{capture:!0}),()=>t.removeEventListener("keydown",n,{capture:!0})},[r,t])}var Ox="DismissableLayer",Pl="dismissableLayer.update",Mx="dismissableLayer.pointerDownOutside",Lx="dismissableLayer.focusOutside",ap,lp=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Cs=b.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:s,onDismiss:a,...c}=e,u=b.useContext(lp),[f,l]=b.useState(null),p=f?.ownerDocument??globalThis?.document,[,g]=b.useState({}),m=qe(t,N=>l(N)),h=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),S=h.indexOf(y),v=f?h.indexOf(f):-1,A=u.layersWithOutsidePointerEventsDisabled.size>0,x=v>=S,F=$x(N=>{const T=N.target,P=[...u.branches].some(E=>E.contains(T));!x||P||(o?.(N),s?.(N),N.defaultPrevented||a?.())},p),k=jx(N=>{const T=N.target;[...u.branches].some(E=>E.contains(T))||(i?.(N),s?.(N),N.defaultPrevented||a?.())},p);return Ix(N=>{v===u.layers.size-1&&(n?.(N),!N.defaultPrevented&&a&&(N.preventDefault(),a()))},p),b.useEffect(()=>{if(f)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(ap=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(f)),u.layers.add(f),cp(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=ap)}},[f,p,r,u]),b.useEffect(()=>()=>{f&&(u.layers.delete(f),u.layersWithOutsidePointerEventsDisabled.delete(f),cp())},[f,u]),b.useEffect(()=>{const N=()=>g({});return document.addEventListener(Pl,N),()=>document.removeEventListener(Pl,N)},[]),d.jsx($e.div,{...c,ref:m,style:{pointerEvents:A?x?"auto":"none":void 0,...e.style},onFocusCapture:Oe(e.onFocusCapture,k.onFocusCapture),onBlurCapture:Oe(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:Oe(e.onPointerDownCapture,F.onPointerDownCapture)})});Cs.displayName=Ox;var Dx="DismissableLayerBranch",Bx=b.forwardRef((e,t)=>{const r=b.useContext(lp),n=b.useRef(null),o=qe(t,n);return b.useEffect(()=>{const i=n.current;if(i)return r.branches.add(i),()=>{r.branches.delete(i)}},[r.branches]),d.jsx($e.div,{...e,ref:o})});Bx.displayName=Dx;function $x(e,t=globalThis?.document){const r=dr(e),n=b.useRef(!1),o=b.useRef(()=>{});return b.useEffect(()=>{const i=a=>{if(a.target&&!n.current){let c=function(){dp(Mx,r,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}else t.removeEventListener("click",o.current);n.current=!1},s=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(s),t.removeEventListener("pointerdown",i),t.removeEventListener("click",o.current)}},[t,r]),{onPointerDownCapture:()=>n.current=!0}}function jx(e,t=globalThis?.document){const r=dr(e),n=b.useRef(!1);return b.useEffect(()=>{const o=i=>{i.target&&!n.current&&dp(Lx,r,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,r]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function cp(){const e=new CustomEvent(Pl);document.dispatchEvent(e)}function dp(e,t,r,{discrete:n}){const o=r.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&o.addEventListener(e,t,{once:!0}),n?Px(o,i):o.dispatchEvent(i)}var Il=0;function Ol(){b.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??up()),document.body.insertAdjacentElement("beforeend",e[1]??up()),Il++,()=>{Il===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Il--}},[])}function up(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Ml="focusScope.autoFocusOnMount",Ll="focusScope.autoFocusOnUnmount",fp={bubbles:!1,cancelable:!0},Hx="FocusScope",Es=b.forwardRef((e,t)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...s}=e,[a,c]=b.useState(null),u=dr(o),f=dr(i),l=b.useRef(null),p=qe(t,h=>c(h)),g=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(n){let h=function(A){if(g.paused||!a)return;const x=A.target;a.contains(x)?l.current=x:On(l.current,{select:!0})},y=function(A){if(g.paused||!a)return;const x=A.relatedTarget;x!==null&&(a.contains(x)||On(l.current,{select:!0}))},S=function(A){if(document.activeElement===document.body)for(const F of A)F.removedNodes.length>0&&On(a)};document.addEventListener("focusin",h),document.addEventListener("focusout",y);const v=new MutationObserver(S);return a&&v.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",h),document.removeEventListener("focusout",y),v.disconnect()}}},[n,a,g.paused]),b.useEffect(()=>{if(a){hp.add(g);const h=document.activeElement;if(!a.contains(h)){const S=new CustomEvent(Ml,fp);a.addEventListener(Ml,u),a.dispatchEvent(S),S.defaultPrevented||(Ux(Kx(pp(a)),{select:!0}),document.activeElement===h&&On(a))}return()=>{a.removeEventListener(Ml,u),setTimeout(()=>{const S=new CustomEvent(Ll,fp);a.addEventListener(Ll,f),a.dispatchEvent(S),S.defaultPrevented||On(h??document.body,{select:!0}),a.removeEventListener(Ll,f),hp.remove(g)},0)}}},[a,u,f,g]);const m=b.useCallback(h=>{if(!r&&!n||g.paused)return;const y=h.key==="Tab"&&!h.altKey&&!h.ctrlKey&&!h.metaKey,S=document.activeElement;if(y&&S){const v=h.currentTarget,[A,x]=zx(v);A&&x?!h.shiftKey&&S===x?(h.preventDefault(),r&&On(A,{select:!0})):h.shiftKey&&S===A&&(h.preventDefault(),r&&On(x,{select:!0})):S===v&&h.preventDefault()}},[r,n,g.paused]);return d.jsx($e.div,{tabIndex:-1,...s,ref:p,onKeyDown:m})});Es.displayName=Hx;function Ux(e,{select:t=!1}={}){const r=document.activeElement;for(const n of e)if(On(n,{select:t}),document.activeElement!==r)return}function zx(e){const t=pp(e),r=mp(t,e),n=mp(t.reverse(),e);return[r,n]}function pp(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const o=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||o?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function mp(e,t){for(const r of e)if(!Vx(r,{upTo:t}))return r}function Vx(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Wx(e){return e instanceof HTMLInputElement&&"select"in e}function On(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&Wx(e)&&t&&e.select()}}var hp=Rx();function Rx(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=gp(e,t),e.unshift(t)},remove(t){e=gp(e,t),e[0]?.resume()}}}function gp(e,t){const r=[...e],n=r.indexOf(t);return n!==-1&&r.splice(n,1),r}function Kx(e){return e.filter(t=>t.tagName!=="A")}var tr=globalThis?.document?b.useLayoutEffect:()=>{},Gx=b[" useId ".trim().toString()]||(()=>{}),qx=0;function yn(e){const[t,r]=b.useState(Gx());return tr(()=>{r(n=>n??String(qx++))},[e]),e||(t?`radix-${t}`:"")}const Yx=["top","right","bottom","left"],Mn=Math.min,xr=Math.max,ks=Math.round,Ns=Math.floor,on=e=>({x:e,y:e}),Xx={left:"right",right:"left",bottom:"top",top:"bottom"};function Dl(e,t,r){return xr(e,Mn(t,r))}function bn(e,t){return typeof e=="function"?e(t):e}function vn(e){return e.split("-")[0]}function wo(e){return e.split("-")[1]}function Bl(e){return e==="x"?"y":"x"}function $l(e){return e==="y"?"height":"width"}function sn(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function jl(e){return Bl(sn(e))}function Jx(e,t,r){r===void 0&&(r=!1);const n=wo(e),o=jl(e),i=$l(o);let s=o==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(s=_s(s)),[s,_s(s)]}function Qx(e){const t=_s(e);return[Hl(e),t,Hl(t)]}function Hl(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const yp=["left","right"],bp=["right","left"],Zx=["top","bottom"],eA=["bottom","top"];function tA(e,t,r){switch(e){case"top":case"bottom":return r?t?bp:yp:t?yp:bp;case"left":case"right":return t?Zx:eA;default:return[]}}function rA(e,t,r,n){const o=wo(e);let i=tA(vn(e),r==="start",n);return o&&(i=i.map(s=>s+"-"+o),t&&(i=i.concat(i.map(Hl)))),i}function _s(e){const t=vn(e);return Xx[t]+e.slice(t.length)}function nA(e){return{top:0,right:0,bottom:0,left:0,...e}}function vp(e){return typeof e!="number"?nA(e):{top:e,right:e,bottom:e,left:e}}function Ts(e){const{x:t,y:r,width:n,height:o}=e;return{width:n,height:o,top:r,left:t,right:t+n,bottom:r+o,x:t,y:r}}function wp(e,t,r){let{reference:n,floating:o}=e;const i=sn(t),s=jl(t),a=$l(s),c=vn(t),u=i==="y",f=n.x+n.width/2-o.width/2,l=n.y+n.height/2-o.height/2,p=n[a]/2-o[a]/2;let g;switch(c){case"top":g={x:f,y:n.y-o.height};break;case"bottom":g={x:f,y:n.y+n.height};break;case"right":g={x:n.x+n.width,y:l};break;case"left":g={x:n.x-o.width,y:l};break;default:g={x:n.x,y:n.y}}switch(wo(t)){case"start":g[s]-=p*(r&&u?-1:1);break;case"end":g[s]+=p*(r&&u?-1:1);break}return g}async function oA(e,t){var r;t===void 0&&(t={});const{x:n,y:o,platform:i,rects:s,elements:a,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:f="viewport",elementContext:l="floating",altBoundary:p=!1,padding:g=0}=bn(t,e),m=vp(g),y=a[p?l==="floating"?"reference":"floating":l],S=Ts(await i.getClippingRect({element:(r=await(i.isElement==null?void 0:i.isElement(y)))==null||r?y:y.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:u,rootBoundary:f,strategy:c})),v=l==="floating"?{x:n,y:o,width:s.floating.width,height:s.floating.height}:s.reference,A=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),x=await(i.isElement==null?void 0:i.isElement(A))?await(i.getScale==null?void 0:i.getScale(A))||{x:1,y:1}:{x:1,y:1},F=Ts(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:A,strategy:c}):v);return{top:(S.top-F.top+m.top)/x.y,bottom:(F.bottom-S.bottom+m.bottom)/x.y,left:(S.left-F.left+m.left)/x.x,right:(F.right-S.right+m.right)/x.x}}const iA=50,sA=async(e,t,r)=>{const{placement:n="bottom",strategy:o="absolute",middleware:i=[],platform:s}=r,a=s.detectOverflow?s:{...s,detectOverflow:oA},c=await(s.isRTL==null?void 0:s.isRTL(t));let u=await s.getElementRects({reference:e,floating:t,strategy:o}),{x:f,y:l}=wp(u,n,c),p=n,g=0;const m={};for(let h=0;h<i.length;h++){const y=i[h];if(!y)continue;const{name:S,fn:v}=y,{x:A,y:x,data:F,reset:k}=await v({x:f,y:l,initialPlacement:n,placement:p,strategy:o,middlewareData:m,rects:u,platform:a,elements:{reference:e,floating:t}});f=A??f,l=x??l,m[S]={...m[S],...F},k&&g<iA&&(g++,typeof k=="object"&&(k.placement&&(p=k.placement),k.rects&&(u=k.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:o}):k.rects),{x:f,y:l}=wp(u,p,c)),h=-1)}return{x:f,y:l,placement:p,strategy:o,middlewareData:m}},aA=e=>({name:"arrow",options:e,async fn(t){const{x:r,y:n,placement:o,rects:i,platform:s,elements:a,middlewareData:c}=t,{element:u,padding:f=0}=bn(e,t)||{};if(u==null)return{};const l=vp(f),p={x:r,y:n},g=jl(o),m=$l(g),h=await s.getDimensions(u),y=g==="y",S=y?"top":"left",v=y?"bottom":"right",A=y?"clientHeight":"clientWidth",x=i.reference[m]+i.reference[g]-p[g]-i.floating[m],F=p[g]-i.reference[g],k=await(s.getOffsetParent==null?void 0:s.getOffsetParent(u));let N=k?k[A]:0;(!N||!await(s.isElement==null?void 0:s.isElement(k)))&&(N=a.floating[A]||i.floating[m]);const T=x/2-F/2,P=N/2-h[m]/2-1,E=Mn(l[S],P),C=Mn(l[v],P),O=E,W=N-h[m]-C,M=N/2-h[m]/2+T,U=Dl(O,M,W),z=!c.arrow&&wo(o)!=null&&M!==U&&i.reference[m]/2-(M<O?E:C)-h[m]/2<0,X=z?M<O?M-O:M-W:0;return{[g]:p[g]+X,data:{[g]:U,centerOffset:M-U-X,...z&&{alignmentOffset:X}},reset:z}}}),lA=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var r,n;const{placement:o,middlewareData:i,rects:s,initialPlacement:a,platform:c,elements:u}=t,{mainAxis:f=!0,crossAxis:l=!0,fallbackPlacements:p,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:h=!0,...y}=bn(e,t);if((r=i.arrow)!=null&&r.alignmentOffset)return{};const S=vn(o),v=sn(a),A=vn(a)===a,x=await(c.isRTL==null?void 0:c.isRTL(u.floating)),F=p||(A||!h?[_s(a)]:Qx(a)),k=m!=="none";!p&&k&&F.push(...rA(a,h,m,x));const N=[a,...F],T=await c.detectOverflow(t,y),P=[];let E=((n=i.flip)==null?void 0:n.overflows)||[];if(f&&P.push(T[S]),l){const M=Jx(o,s,x);P.push(T[M[0]],T[M[1]])}if(E=[...E,{placement:o,overflows:P}],!P.every(M=>M<=0)){var C,O;const M=(((C=i.flip)==null?void 0:C.index)||0)+1,U=N[M];if(U&&(!(l==="alignment"?v!==sn(U):!1)||E.every(B=>sn(B.placement)===v?B.overflows[0]>0:!0)))return{data:{index:M,overflows:E},reset:{placement:U}};let z=(O=E.filter(X=>X.overflows[0]<=0).sort((X,B)=>X.overflows[1]-B.overflows[1])[0])==null?void 0:O.placement;if(!z)switch(g){case"bestFit":{var W;const X=(W=E.filter(B=>{if(k){const L=sn(B.placement);return L===v||L==="y"}return!0}).map(B=>[B.placement,B.overflows.filter(L=>L>0).reduce((L,D)=>L+D,0)]).sort((B,L)=>B[1]-L[1])[0])==null?void 0:W[0];X&&(z=X);break}case"initialPlacement":z=a;break}if(o!==z)return{reset:{placement:z}}}return{}}}};function Sp(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function xp(e){return Yx.some(t=>e[t]>=0)}const cA=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:r,platform:n}=t,{strategy:o="referenceHidden",...i}=bn(e,t);switch(o){case"referenceHidden":{const s=await n.detectOverflow(t,{...i,elementContext:"reference"}),a=Sp(s,r.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:xp(a)}}}case"escaped":{const s=await n.detectOverflow(t,{...i,altBoundary:!0}),a=Sp(s,r.floating);return{data:{escapedOffsets:a,escaped:xp(a)}}}default:return{}}}}},Ap=new Set(["left","top"]);async function dA(e,t){const{placement:r,platform:n,elements:o}=e,i=await(n.isRTL==null?void 0:n.isRTL(o.floating)),s=vn(r),a=wo(r),c=sn(r)==="y",u=Ap.has(s)?-1:1,f=i&&c?-1:1,l=bn(t,e);let{mainAxis:p,crossAxis:g,alignmentAxis:m}=typeof l=="number"?{mainAxis:l,crossAxis:0,alignmentAxis:null}:{mainAxis:l.mainAxis||0,crossAxis:l.crossAxis||0,alignmentAxis:l.alignmentAxis};return a&&typeof m=="number"&&(g=a==="end"?m*-1:m),c?{x:g*f,y:p*u}:{x:p*u,y:g*f}}const uA=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var r,n;const{x:o,y:i,placement:s,middlewareData:a}=t,c=await dA(t,e);return s===((r=a.offset)==null?void 0:r.placement)&&(n=a.arrow)!=null&&n.alignmentOffset?{}:{x:o+c.x,y:i+c.y,data:{...c,placement:s}}}}},fA=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:n,placement:o,platform:i}=t,{mainAxis:s=!0,crossAxis:a=!1,limiter:c={fn:S=>{let{x:v,y:A}=S;return{x:v,y:A}}},...u}=bn(e,t),f={x:r,y:n},l=await i.detectOverflow(t,u),p=sn(vn(o)),g=Bl(p);let m=f[g],h=f[p];if(s){const S=g==="y"?"top":"left",v=g==="y"?"bottom":"right",A=m+l[S],x=m-l[v];m=Dl(A,m,x)}if(a){const S=p==="y"?"top":"left",v=p==="y"?"bottom":"right",A=h+l[S],x=h-l[v];h=Dl(A,h,x)}const y=c.fn({...t,[g]:m,[p]:h});return{...y,data:{x:y.x-r,y:y.y-n,enabled:{[g]:s,[p]:a}}}}}},pA=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:r,y:n,placement:o,rects:i,middlewareData:s}=t,{offset:a=0,mainAxis:c=!0,crossAxis:u=!0}=bn(e,t),f={x:r,y:n},l=sn(o),p=Bl(l);let g=f[p],m=f[l];const h=bn(a,t),y=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){const A=p==="y"?"height":"width",x=i.reference[p]-i.floating[A]+y.mainAxis,F=i.reference[p]+i.reference[A]-y.mainAxis;g<x?g=x:g>F&&(g=F)}if(u){var S,v;const A=p==="y"?"width":"height",x=Ap.has(vn(o)),F=i.reference[l]-i.floating[A]+(x&&((S=s.offset)==null?void 0:S[l])||0)+(x?0:y.crossAxis),k=i.reference[l]+i.reference[A]+(x?0:((v=s.offset)==null?void 0:v[l])||0)-(x?y.crossAxis:0);m<F?m=F:m>k&&(m=k)}return{[p]:g,[l]:m}}}},mA=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var r,n;const{placement:o,rects:i,platform:s,elements:a}=t,{apply:c=()=>{},...u}=bn(e,t),f=await s.detectOverflow(t,u),l=vn(o),p=wo(o),g=sn(o)==="y",{width:m,height:h}=i.floating;let y,S;l==="top"||l==="bottom"?(y=l,S=p===(await(s.isRTL==null?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(S=l,y=p==="end"?"top":"bottom");const v=h-f.top-f.bottom,A=m-f.left-f.right,x=Mn(h-f[y],v),F=Mn(m-f[S],A),k=!t.middlewareData.shift;let N=x,T=F;if((r=t.middlewareData.shift)!=null&&r.enabled.x&&(T=A),(n=t.middlewareData.shift)!=null&&n.enabled.y&&(N=v),k&&!p){const E=xr(f.left,0),C=xr(f.right,0),O=xr(f.top,0),W=xr(f.bottom,0);g?T=m-2*(E!==0||C!==0?E+C:xr(f.left,f.right)):N=h-2*(O!==0||W!==0?O+W:xr(f.top,f.bottom))}await c({...t,availableWidth:T,availableHeight:N});const P=await s.getDimensions(a.floating);return m!==P.width||h!==P.height?{reset:{rects:!0}}:{}}}};function Fs(){return typeof window<"u"}function So(e){return Cp(e)?(e.nodeName||"").toLowerCase():"#document"}function Ar(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function an(e){var t;return(t=(Cp(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Cp(e){return Fs()?e instanceof Node||e instanceof Ar(e).Node:!1}function Gr(e){return Fs()?e instanceof Element||e instanceof Ar(e).Element:!1}function wn(e){return Fs()?e instanceof HTMLElement||e instanceof Ar(e).HTMLElement:!1}function Ep(e){return!Fs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ar(e).ShadowRoot}function gi(e){const{overflow:t,overflowX:r,overflowY:n,display:o}=qr(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+r)&&o!=="inline"&&o!=="contents"}function hA(e){return/^(table|td|th)$/.test(So(e))}function Ps(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const gA=/transform|translate|scale|rotate|perspective|filter/,yA=/paint|layout|strict|content/,eo=e=>!!e&&e!=="none";let Ul;function zl(e){const t=Gr(e)?qr(e):e;return eo(t.transform)||eo(t.translate)||eo(t.scale)||eo(t.rotate)||eo(t.perspective)||!Vl()&&(eo(t.backdropFilter)||eo(t.filter))||gA.test(t.willChange||"")||yA.test(t.contain||"")}function bA(e){let t=Ln(e);for(;wn(t)&&!xo(t);){if(zl(t))return t;if(Ps(t))return null;t=Ln(t)}return null}function Vl(){return Ul==null&&(Ul=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Ul}function xo(e){return/^(html|body|#document)$/.test(So(e))}function qr(e){return Ar(e).getComputedStyle(e)}function Is(e){return Gr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ln(e){if(So(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Ep(e)&&e.host||an(e);return Ep(t)?t.host:t}function kp(e){const t=Ln(e);return xo(t)?e.ownerDocument?e.ownerDocument.body:e.body:wn(t)&&gi(t)?t:kp(t)}function yi(e,t,r){var n;t===void 0&&(t=[]),r===void 0&&(r=!0);const o=kp(e),i=o===((n=e.ownerDocument)==null?void 0:n.body),s=Ar(o);if(i){const a=Wl(s);return t.concat(s,s.visualViewport||[],gi(o)?o:[],a&&r?yi(a):[])}else return t.concat(o,yi(o,[],r))}function Wl(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Np(e){const t=qr(e);let r=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const o=wn(e),i=o?e.offsetWidth:r,s=o?e.offsetHeight:n,a=ks(r)!==i||ks(n)!==s;return a&&(r=i,n=s),{width:r,height:n,$:a}}function Rl(e){return Gr(e)?e:e.contextElement}function Ao(e){const t=Rl(e);if(!wn(t))return on(1);const r=t.getBoundingClientRect(),{width:n,height:o,$:i}=Np(t);let s=(i?ks(r.width):r.width)/n,a=(i?ks(r.height):r.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}const vA=on(0);function _p(e){const t=Ar(e);return!Vl()||!t.visualViewport?vA:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function wA(e,t,r){return t===void 0&&(t=!1),!r||t&&r!==Ar(e)?!1:t}function to(e,t,r,n){t===void 0&&(t=!1),r===void 0&&(r=!1);const o=e.getBoundingClientRect(),i=Rl(e);let s=on(1);t&&(n?Gr(n)&&(s=Ao(n)):s=Ao(e));const a=wA(i,r,n)?_p(i):on(0);let c=(o.left+a.x)/s.x,u=(o.top+a.y)/s.y,f=o.width/s.x,l=o.height/s.y;if(i){const p=Ar(i),g=n&&Gr(n)?Ar(n):n;let m=p,h=Wl(m);for(;h&&n&&g!==m;){const y=Ao(h),S=h.getBoundingClientRect(),v=qr(h),A=S.left+(h.clientLeft+parseFloat(v.paddingLeft))*y.x,x=S.top+(h.clientTop+parseFloat(v.paddingTop))*y.y;c*=y.x,u*=y.y,f*=y.x,l*=y.y,c+=A,u+=x,m=Ar(h),h=Wl(m)}}return Ts({width:f,height:l,x:c,y:u})}function Os(e,t){const r=Is(e).scrollLeft;return t?t.left+r:to(an(e)).left+r}function Tp(e,t){const r=e.getBoundingClientRect(),n=r.left+t.scrollLeft-Os(e,r),o=r.top+t.scrollTop;return{x:n,y:o}}function SA(e){let{elements:t,rect:r,offsetParent:n,strategy:o}=e;const i=o==="fixed",s=an(n),a=t?Ps(t.floating):!1;if(n===s||a&&i)return r;let c={scrollLeft:0,scrollTop:0},u=on(1);const f=on(0),l=wn(n);if((l||!l&&!i)&&((So(n)!=="body"||gi(s))&&(c=Is(n)),l)){const g=to(n);u=Ao(n),f.x=g.x+n.clientLeft,f.y=g.y+n.clientTop}const p=s&&!l&&!i?Tp(s,c):on(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-c.scrollLeft*u.x+f.x+p.x,y:r.y*u.y-c.scrollTop*u.y+f.y+p.y}}function xA(e){return Array.from(e.getClientRects())}function AA(e){const t=an(e),r=Is(e),n=e.ownerDocument.body,o=xr(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),i=xr(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let s=-r.scrollLeft+Os(e);const a=-r.scrollTop;return qr(n).direction==="rtl"&&(s+=xr(t.clientWidth,n.clientWidth)-o),{width:o,height:i,x:s,y:a}}const Fp=25;function CA(e,t){const r=Ar(e),n=an(e),o=r.visualViewport;let i=n.clientWidth,s=n.clientHeight,a=0,c=0;if(o){i=o.width,s=o.height;const f=Vl();(!f||f&&t==="fixed")&&(a=o.offsetLeft,c=o.offsetTop)}const u=Os(n);if(u<=0){const f=n.ownerDocument,l=f.body,p=getComputedStyle(l),g=f.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,m=Math.abs(n.clientWidth-l.clientWidth-g);m<=Fp&&(i-=m)}else u<=Fp&&(i+=u);return{width:i,height:s,x:a,y:c}}function EA(e,t){const r=to(e,!0,t==="fixed"),n=r.top+e.clientTop,o=r.left+e.clientLeft,i=wn(e)?Ao(e):on(1),s=e.clientWidth*i.x,a=e.clientHeight*i.y,c=o*i.x,u=n*i.y;return{width:s,height:a,x:c,y:u}}function Pp(e,t,r){let n;if(t==="viewport")n=CA(e,r);else if(t==="document")n=AA(an(e));else if(Gr(t))n=EA(t,r);else{const o=_p(e);n={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Ts(n)}function Ip(e,t){const r=Ln(e);return r===t||!Gr(r)||xo(r)?!1:qr(r).position==="fixed"||Ip(r,t)}function kA(e,t){const r=t.get(e);if(r)return r;let n=yi(e,[],!1).filter(a=>Gr(a)&&So(a)!=="body"),o=null;const i=qr(e).position==="fixed";let s=i?Ln(e):e;for(;Gr(s)&&!xo(s);){const a=qr(s),c=zl(s);!c&&a.position==="fixed"&&(o=null),(i?!c&&!o:!c&&a.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||gi(s)&&!c&&Ip(e,s))?n=n.filter(f=>f!==s):o=a,s=Ln(s)}return t.set(e,n),n}function NA(e){let{element:t,boundary:r,rootBoundary:n,strategy:o}=e;const s=[...r==="clippingAncestors"?Ps(t)?[]:kA(t,this._c):[].concat(r),n],a=Pp(t,s[0],o);let c=a.top,u=a.right,f=a.bottom,l=a.left;for(let p=1;p<s.length;p++){const g=Pp(t,s[p],o);c=xr(g.top,c),u=Mn(g.right,u),f=Mn(g.bottom,f),l=xr(g.left,l)}return{width:u-l,height:f-c,x:l,y:c}}function _A(e){const{width:t,height:r}=Np(e);return{width:t,height:r}}function TA(e,t,r){const n=wn(t),o=an(t),i=r==="fixed",s=to(e,!0,i,t);let a={scrollLeft:0,scrollTop:0};const c=on(0);function u(){c.x=Os(o)}if(n||!n&&!i)if((So(t)!=="body"||gi(o))&&(a=Is(t)),n){const g=to(t,!0,i,t);c.x=g.x+t.clientLeft,c.y=g.y+t.clientTop}else o&&u();i&&!n&&o&&u();const f=o&&!n&&!i?Tp(o,a):on(0),l=s.left+a.scrollLeft-c.x-f.x,p=s.top+a.scrollTop-c.y-f.y;return{x:l,y:p,width:s.width,height:s.height}}function Kl(e){return qr(e).position==="static"}function Op(e,t){if(!wn(e)||qr(e).position==="fixed")return null;if(t)return t(e);let r=e.offsetParent;return an(e)===r&&(r=r.ownerDocument.body),r}function Mp(e,t){const r=Ar(e);if(Ps(e))return r;if(!wn(e)){let o=Ln(e);for(;o&&!xo(o);){if(Gr(o)&&!Kl(o))return o;o=Ln(o)}return r}let n=Op(e,t);for(;n&&hA(n)&&Kl(n);)n=Op(n,t);return n&&xo(n)&&Kl(n)&&!zl(n)?r:n||bA(e)||r}const FA=async function(e){const t=this.getOffsetParent||Mp,r=this.getDimensions,n=await r(e.floating);return{reference:TA(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function PA(e){return qr(e).direction==="rtl"}const IA={convertOffsetParentRelativeRectToViewportRelativeRect:SA,getDocumentElement:an,getClippingRect:NA,getOffsetParent:Mp,getElementRects:FA,getClientRects:xA,getDimensions:_A,getScale:Ao,isElement:Gr,isRTL:PA};function Lp(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function OA(e,t){let r=null,n;const o=an(e);function i(){var a;clearTimeout(n),(a=r)==null||a.disconnect(),r=null}function s(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),i();const u=e.getBoundingClientRect(),{left:f,top:l,width:p,height:g}=u;if(a||t(),!p||!g)return;const m=Ns(l),h=Ns(o.clientWidth-(f+p)),y=Ns(o.clientHeight-(l+g)),S=Ns(f),A={rootMargin:-m+"px "+-h+"px "+-y+"px "+-S+"px",threshold:xr(0,Mn(1,c))||1};let x=!0;function F(k){const N=k[0].intersectionRatio;if(N!==c){if(!x)return s();N?s(!1,N):n=setTimeout(()=>{s(!1,1e-7)},1e3)}N===1&&!Lp(u,e.getBoundingClientRect())&&s(),x=!1}try{r=new IntersectionObserver(F,{...A,root:o.ownerDocument})}catch{r=new IntersectionObserver(F,A)}r.observe(e)}return s(!0),i}function MA(e,t,r,n){n===void 0&&(n={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=n,u=Rl(e),f=o||i?[...u?yi(u):[],...t?yi(t):[]]:[];f.forEach(S=>{o&&S.addEventListener("scroll",r,{passive:!0}),i&&S.addEventListener("resize",r)});const l=u&&a?OA(u,r):null;let p=-1,g=null;s&&(g=new ResizeObserver(S=>{let[v]=S;v&&v.target===u&&g&&t&&(g.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var A;(A=g)==null||A.observe(t)})),r()}),u&&!c&&g.observe(u),t&&g.observe(t));let m,h=c?to(e):null;c&&y();function y(){const S=to(e);h&&!Lp(h,S)&&r(),h=S,m=requestAnimationFrame(y)}return r(),()=>{var S;f.forEach(v=>{o&&v.removeEventListener("scroll",r),i&&v.removeEventListener("resize",r)}),l?.(),(S=g)==null||S.disconnect(),g=null,c&&cancelAnimationFrame(m)}}const LA=uA,DA=fA,BA=lA,$A=mA,jA=cA,Dp=aA,HA=pA,UA=(e,t,r)=>{const n=new Map,o={platform:IA,...r},i={...o.platform,_c:n};return sA(e,t,{...o,platform:i})};var zA=typeof document<"u",VA=function(){},Ms=zA?w.useLayoutEffect:VA;function Ls(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let r,n,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(r=e.length,r!==t.length)return!1;for(n=r;n--!==0;)if(!Ls(e[n],t[n]))return!1;return!0}if(o=Object.keys(e),r=o.length,r!==Object.keys(t).length)return!1;for(n=r;n--!==0;)if(!{}.hasOwnProperty.call(t,o[n]))return!1;for(n=r;n--!==0;){const i=o[n];if(!(i==="_owner"&&e.$$typeof)&&!Ls(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function Bp(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function $p(e,t){const r=Bp(e);return Math.round(t*r)/r}function Gl(e){const t=b.useRef(e);return Ms(()=>{t.current=e}),t}function WA(e){e===void 0&&(e={});const{placement:t="bottom",strategy:r="absolute",middleware:n=[],platform:o,elements:{reference:i,floating:s}={},transform:a=!0,whileElementsMounted:c,open:u}=e,[f,l]=b.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[p,g]=b.useState(n);Ls(p,n)||g(n);const[m,h]=b.useState(null),[y,S]=b.useState(null),v=b.useCallback(B=>{B!==k.current&&(k.current=B,h(B))},[]),A=b.useCallback(B=>{B!==N.current&&(N.current=B,S(B))},[]),x=i||m,F=s||y,k=b.useRef(null),N=b.useRef(null),T=b.useRef(f),P=c!=null,E=Gl(c),C=Gl(o),O=Gl(u),W=b.useCallback(()=>{if(!k.current||!N.current)return;const B={placement:t,strategy:r,middleware:p};C.current&&(B.platform=C.current),UA(k.current,N.current,B).then(L=>{const D={...L,isPositioned:O.current!==!1};M.current&&!Ls(T.current,D)&&(T.current=D,Gi.flushSync(()=>{l(D)}))})},[p,t,r,C,O]);Ms(()=>{u===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,l(B=>({...B,isPositioned:!1})))},[u]);const M=b.useRef(!1);Ms(()=>(M.current=!0,()=>{M.current=!1}),[]),Ms(()=>{if(x&&(k.current=x),F&&(N.current=F),x&&F){if(E.current)return E.current(x,F,W);W()}},[x,F,W,E,P]);const U=b.useMemo(()=>({reference:k,floating:N,setReference:v,setFloating:A}),[v,A]),z=b.useMemo(()=>({reference:x,floating:F}),[x,F]),X=b.useMemo(()=>{const B={position:r,left:0,top:0};if(!z.floating)return B;const L=$p(z.floating,f.x),D=$p(z.floating,f.y);return a?{...B,transform:"translate("+L+"px, "+D+"px)",...Bp(z.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:L,top:D}},[r,a,z.floating,f.x,f.y]);return b.useMemo(()=>({...f,update:W,refs:U,elements:z,floatingStyles:X}),[f,W,U,z,X])}const RA=e=>{function t(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:e,fn(r){const{element:n,padding:o}=typeof e=="function"?e(r):e;return n&&t(n)?n.current!=null?Dp({element:n.current,padding:o}).fn(r):{}:n?Dp({element:n,padding:o}).fn(r):{}}}},KA=(e,t)=>{const r=LA(e);return{name:r.name,fn:r.fn,options:[e,t]}},GA=(e,t)=>{const r=DA(e);return{name:r.name,fn:r.fn,options:[e,t]}},qA=(e,t)=>({fn:HA(e).fn,options:[e,t]}),YA=(e,t)=>{const r=BA(e);return{name:r.name,fn:r.fn,options:[e,t]}},XA=(e,t)=>{const r=$A(e);return{name:r.name,fn:r.fn,options:[e,t]}},JA=(e,t)=>{const r=jA(e);return{name:r.name,fn:r.fn,options:[e,t]}},QA=(e,t)=>{const r=RA(e);return{name:r.name,fn:r.fn,options:[e,t]}};var ZA="Arrow",jp=b.forwardRef((e,t)=>{const{children:r,width:n=10,height:o=5,...i}=e;return d.jsx($e.svg,{...i,ref:t,width:n,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:d.jsx("polygon",{points:"0,0 30,0 15,10"})})});jp.displayName=ZA;var eC=jp;function bi(e){const[t,r]=b.useState(void 0);return tr(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});const n=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let s,a;if("borderBoxSize"in i){const c=i.borderBoxSize,u=Array.isArray(c)?c[0]:c;s=u.inlineSize,a=u.blockSize}else s=e.offsetWidth,a=e.offsetHeight;r({width:s,height:a})});return n.observe(e,{box:"border-box"}),()=>n.unobserve(e)}else r(void 0)},[e]),t}var ql="Popper",[Hp,Ds]=Sr(ql),[tC,Up]=Hp(ql),zp=e=>{const{__scopePopper:t,children:r}=e,[n,o]=b.useState(null);return d.jsx(tC,{scope:t,anchor:n,onAnchorChange:o,children:r})};zp.displayName=ql;var Vp="PopperAnchor",Wp=b.forwardRef((e,t)=>{const{__scopePopper:r,virtualRef:n,...o}=e,i=Up(Vp,r),s=b.useRef(null),a=qe(t,s),c=b.useRef(null);return b.useEffect(()=>{const u=c.current;c.current=n?.current||s.current,u!==c.current&&i.onAnchorChange(c.current)}),n?null:d.jsx($e.div,{...o,ref:a})});Wp.displayName=Vp;var Yl="PopperContent",[rC,nC]=Hp(Yl),Rp=b.forwardRef((e,t)=>{const{__scopePopper:r,side:n="bottom",sideOffset:o=0,align:i="center",alignOffset:s=0,arrowPadding:a=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:f=0,sticky:l="partial",hideWhenDetached:p=!1,updatePositionStrategy:g="optimized",onPlaced:m,...h}=e,y=Up(Yl,r),[S,v]=b.useState(null),A=qe(t,G=>v(G)),[x,F]=b.useState(null),k=bi(x),N=k?.width??0,T=k?.height??0,P=n+(i!=="center"?"-"+i:""),E=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},C=Array.isArray(u)?u:[u],O=C.length>0,W={padding:E,boundary:C.filter(iC),altBoundary:O},{refs:M,floatingStyles:U,placement:z,isPositioned:X,middlewareData:B}=WA({strategy:"fixed",placement:P,whileElementsMounted:(...G)=>MA(...G,{animationFrame:g==="always"}),elements:{reference:y.anchor},middleware:[KA({mainAxis:o+T,alignmentAxis:s}),c&&GA({mainAxis:!0,crossAxis:!1,limiter:l==="partial"?qA():void 0,...W}),c&&YA({...W}),XA({...W,apply:({elements:G,rects:ee,availableWidth:Ae,availableHeight:te})=>{const{width:oe,height:me}=ee.reference,Me=G.floating.style;Me.setProperty("--radix-popper-available-width",`${Ae}px`),Me.setProperty("--radix-popper-available-height",`${te}px`),Me.setProperty("--radix-popper-anchor-width",`${oe}px`),Me.setProperty("--radix-popper-anchor-height",`${me}px`)}}),x&&QA({element:x,padding:a}),sC({arrowWidth:N,arrowHeight:T}),p&&JA({strategy:"referenceHidden",...W})]}),[L,D]=qp(z),K=dr(m);tr(()=>{X&&K?.()},[X,K]);const le=B.arrow?.x,j=B.arrow?.y,H=B.arrow?.centerOffset!==0,[ce,ie]=b.useState();return tr(()=>{S&&ie(window.getComputedStyle(S).zIndex)},[S]),d.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...U,transform:X?U.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ce,"--radix-popper-transform-origin":[B.transformOrigin?.x,B.transformOrigin?.y].join(" "),...B.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:d.jsx(rC,{scope:r,placedSide:L,onArrowChange:F,arrowX:le,arrowY:j,shouldHideArrow:H,children:d.jsx($e.div,{"data-side":L,"data-align":D,...h,ref:A,style:{...h.style,animation:X?void 0:"none"}})})})});Rp.displayName=Yl;var Kp="PopperArrow",oC={top:"bottom",right:"left",bottom:"top",left:"right"},Gp=b.forwardRef(function(t,r){const{__scopePopper:n,...o}=t,i=nC(Kp,n),s=oC[i.placedSide];return d.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:d.jsx(eC,{...o,ref:r,style:{...o.style,display:"block"}})})});Gp.displayName=Kp;function iC(e){return e!==null}var sC=e=>({name:"transformOrigin",options:e,fn(t){const{placement:r,rects:n,middlewareData:o}=t,s=o.arrow?.centerOffset!==0,a=s?0:e.arrowWidth,c=s?0:e.arrowHeight,[u,f]=qp(r),l={start:"0%",center:"50%",end:"100%"}[f],p=(o.arrow?.x??0)+a/2,g=(o.arrow?.y??0)+c/2;let m="",h="";return u==="bottom"?(m=s?l:`${p}px`,h=`${-c}px`):u==="top"?(m=s?l:`${p}px`,h=`${n.floating.height+c}px`):u==="right"?(m=`${-c}px`,h=s?l:`${g}px`):u==="left"&&(m=`${n.floating.width+c}px`,h=s?l:`${g}px`),{data:{x:m,y:h}}}});function qp(e){const[t,r="center"]=e.split("-");return[t,r]}var Yp=zp,Xl=Wp,Xp=Rp,Jp=Gp,aC="Portal",Bs=b.forwardRef((e,t)=>{const{container:r,...n}=e,[o,i]=b.useState(!1);tr(()=>i(!0),[]);const s=r||o&&globalThis?.document?.body;return s?$d.createPortal(d.jsx($e.div,{...n,ref:t}),s):null});Bs.displayName=aC;function lC(e){const t=cC(e),r=b.forwardRef((n,o)=>{const{children:i,...s}=n,a=b.Children.toArray(i),c=a.find(uC);if(c){const u=c.props.children,f=a.map(l=>l===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:l);return d.jsx(t,{...s,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,f):null})}return d.jsx(t,{...s,ref:o,children:i})});return r.displayName=`${e}.Slot`,r}function cC(e){const t=b.forwardRef((r,n)=>{const{children:o,...i}=r;if(b.isValidElement(o)){const s=pC(o),a=fC(i,o.props);return o.type!==b.Fragment&&(a.ref=n?Yn(n,s):s),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var dC=Symbol("radix.slottable");function uC(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===dC}function fC(e,t){const r={...t};for(const n in t){const o=e[n],i=t[n];/^on[A-Z]/.test(n)?o&&i?r[n]=(...a)=>{const c=i(...a);return o(...a),c}:o&&(r[n]=o):n==="style"?r[n]={...o,...i}:n==="className"&&(r[n]=[o,i].filter(Boolean).join(" "))}return{...e,...r}}function pC(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var mC=b[" useInsertionEffect ".trim().toString()]||tr;function ln({prop:e,defaultProp:t,onChange:r=()=>{},caller:n}){const[o,i,s]=hC({defaultProp:t,onChange:r}),a=e!==void 0,c=a?e:o;{const f=b.useRef(e!==void 0);b.useEffect(()=>{const l=f.current;l!==a&&console.warn(`${n} is changing from ${l?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=a},[a,n])}const u=b.useCallback(f=>{if(a){const l=gC(f)?f(e):f;l!==e&&s.current?.(l)}else i(f)},[a,e,i,s]);return[c,u]}function hC({defaultProp:e,onChange:t}){const[r,n]=b.useState(e),o=b.useRef(r),i=b.useRef(t);return mC(()=>{i.current=t},[t]),b.useEffect(()=>{o.current!==r&&(i.current?.(r),o.current=r)},[r,o]),[r,n,i]}function gC(e){return typeof e=="function"}function vi(e){const t=b.useRef({value:e,previous:e});return b.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Qp=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),yC="VisuallyHidden",bC=b.forwardRef((e,t)=>d.jsx($e.span,{...e,ref:t,style:{...Qp,...e.style}}));bC.displayName=yC;var vC=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Co=new WeakMap,$s=new WeakMap,js={},Jl=0,Zp=function(e){return e&&(e.host||Zp(e.parentNode))},wC=function(e,t){return t.map(function(r){if(e.contains(r))return r;var n=Zp(r);return n&&e.contains(n)?n:(console.error("aria-hidden",r,"in not contained inside",e,". Doing nothing"),null)}).filter(function(r){return!!r})},SC=function(e,t,r,n){var o=wC(t,Array.isArray(e)?e:[e]);js[r]||(js[r]=new WeakMap);var i=js[r],s=[],a=new Set,c=new Set(o),u=function(l){!l||a.has(l)||(a.add(l),u(l.parentNode))};o.forEach(u);var f=function(l){!l||c.has(l)||Array.prototype.forEach.call(l.children,function(p){if(a.has(p))f(p);else try{var g=p.getAttribute(n),m=g!==null&&g!=="false",h=(Co.get(p)||0)+1,y=(i.get(p)||0)+1;Co.set(p,h),i.set(p,y),s.push(p),h===1&&m&&$s.set(p,!0),y===1&&p.setAttribute(r,"true"),m||p.setAttribute(n,"true")}catch(S){console.error("aria-hidden: cannot operate on ",p,S)}})};return f(t),a.clear(),Jl++,function(){s.forEach(function(l){var p=Co.get(l)-1,g=i.get(l)-1;Co.set(l,p),i.set(l,g),p||($s.has(l)||l.removeAttribute(n),$s.delete(l)),g||l.removeAttribute(r)}),Jl--,Jl||(Co=new WeakMap,Co=new WeakMap,$s=new WeakMap,js={})}},Ql=function(e,t,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(e)?e:[e]),o=vC(e);return o?(n.push.apply(n,Array.from(o.querySelectorAll("[aria-live], script"))),SC(n,o,r,"aria-hidden")):function(){return null}},cn=function(){return cn=Object.assign||function(t){for(var r,n=1,o=arguments.length;n<o;n++){r=arguments[n];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t},cn.apply(this,arguments)};function em(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]]);return r}function xC(e,t,r){if(r||arguments.length===2)for(var n=0,o=t.length,i;n<o;n++)(i||!(n in t))&&(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var Hs="right-scroll-bar-position",Us="width-before-scroll-bar",AC="with-scroll-bars-hidden",CC="--removed-body-scroll-bar-size";function Zl(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function EC(e,t){var r=w.useState(function(){return{value:e,callback:t,facade:{get current(){return r.value},set current(n){var o=r.value;o!==n&&(r.value=n,r.callback(n,o))}}}})[0];return r.callback=t,r.facade}var kC=typeof window<"u"?b.useLayoutEffect:b.useEffect,tm=new WeakMap;function NC(e,t){var r=EC(null,function(n){return e.forEach(function(o){return Zl(o,n)})});return kC(function(){var n=tm.get(r);if(n){var o=new Set(n),i=new Set(e),s=r.current;o.forEach(function(a){i.has(a)||Zl(a,null)}),i.forEach(function(a){o.has(a)||Zl(a,s)})}tm.set(r,e)},[e]),r}function _C(e){return e}function TC(e,t){t===void 0&&(t=_C);var r=[],n=!1,o={read:function(){if(n)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:e},useMedium:function(i){var s=t(i,n);return r.push(s),function(){r=r.filter(function(a){return a!==s})}},assignSyncMedium:function(i){for(n=!0;r.length;){var s=r;r=[],s.forEach(i)}r={push:function(a){return i(a)},filter:function(){return r}}},assignMedium:function(i){n=!0;var s=[];if(r.length){var a=r;r=[],a.forEach(i),s=r}var c=function(){var f=s;s=[],f.forEach(i)},u=function(){return Promise.resolve().then(c)};u(),r={push:function(f){s.push(f),u()},filter:function(f){return s=s.filter(f),r}}}};return o}function FC(e){e===void 0&&(e={});var t=TC(null);return t.options=cn({async:!0,ssr:!1},e),t}var rm=function(e){var t=e.sideCar,r=em(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var n=t.read();if(!n)throw new Error("Sidecar medium not found");return b.createElement(n,cn({},r))};rm.isSideCarExport=!0;function PC(e,t){return e.useMedium(t),rm}var nm=FC(),ec=function(){},zs=b.forwardRef(function(e,t){var r=b.useRef(null),n=b.useState({onScrollCapture:ec,onWheelCapture:ec,onTouchMoveCapture:ec}),o=n[0],i=n[1],s=e.forwardProps,a=e.children,c=e.className,u=e.removeScrollBar,f=e.enabled,l=e.shards,p=e.sideCar,g=e.noRelative,m=e.noIsolation,h=e.inert,y=e.allowPinchZoom,S=e.as,v=S===void 0?"div":S,A=e.gapMode,x=em(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),F=p,k=NC([r,t]),N=cn(cn({},x),o);return b.createElement(b.Fragment,null,f&&b.createElement(F,{sideCar:nm,removeScrollBar:u,shards:l,noRelative:g,noIsolation:m,inert:h,setCallbacks:i,allowPinchZoom:!!y,lockRef:r,gapMode:A}),s?b.cloneElement(b.Children.only(a),cn(cn({},N),{ref:k})):b.createElement(v,cn({},N,{className:c,ref:k}),a))});zs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},zs.classNames={fullWidth:Us,zeroRight:Hs};var IC=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function OC(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=IC();return t&&e.setAttribute("nonce",t),e}function MC(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function LC(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var DC=function(){var e=0,t=null;return{add:function(r){e==0&&(t=OC())&&(MC(t,r),LC(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},BC=function(){var e=DC();return function(t,r){b.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&r])}},om=function(){var e=BC(),t=function(r){var n=r.styles,o=r.dynamic;return e(n,o),null};return t},$C={left:0,top:0,right:0,gap:0},tc=function(e){return parseInt(e||"",10)||0},jC=function(e){var t=window.getComputedStyle(document.body),r=t[e==="padding"?"paddingLeft":"marginLeft"],n=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[tc(r),tc(n),tc(o)]},HC=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return $C;var t=jC(e),r=document.documentElement.clientWidth,n=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,n-r+t[2]-t[0])}},UC=om(),Eo="data-scroll-locked",zC=function(e,t,r,n){var o=e.left,i=e.top,s=e.right,a=e.gap;return r===void 0&&(r="margin"),`
|
|
7
|
+
.`.concat(AC,` {
|
|
8
8
|
overflow: hidden `).concat(n,`;
|
|
9
9
|
padding-right: `).concat(a,"px ").concat(n,`;
|
|
10
10
|
}
|
|
11
|
-
body[`).concat(
|
|
11
|
+
body[`).concat(Eo,`] {
|
|
12
12
|
overflow: hidden `).concat(n,`;
|
|
13
13
|
overscroll-behavior: contain;
|
|
14
14
|
`).concat([t&&"position: relative ".concat(n,";"),r==="margin"&&`
|
|
@@ -21,32 +21,32 @@
|
|
|
21
21
|
`),r==="padding"&&"padding-right: ".concat(a,"px ").concat(n,";")].filter(Boolean).join(""),`
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
.`).concat(
|
|
24
|
+
.`).concat(Hs,` {
|
|
25
25
|
right: `).concat(a,"px ").concat(n,`;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
.`).concat(
|
|
28
|
+
.`).concat(Us,` {
|
|
29
29
|
margin-right: `).concat(a,"px ").concat(n,`;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
.`).concat(
|
|
32
|
+
.`).concat(Hs," .").concat(Hs,` {
|
|
33
33
|
right: 0 `).concat(n,`;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
.`).concat(
|
|
36
|
+
.`).concat(Us," .").concat(Us,` {
|
|
37
37
|
margin-right: 0 `).concat(n,`;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
body[`).concat(
|
|
41
|
-
`).concat(
|
|
40
|
+
body[`).concat(Eo,`] {
|
|
41
|
+
`).concat(CC,": ").concat(a,`px;
|
|
42
42
|
}
|
|
43
|
-
`)},
|
|
43
|
+
`)},im=function(){var e=parseInt(document.body.getAttribute(Eo)||"0",10);return isFinite(e)?e:0},VC=function(){b.useEffect(function(){return document.body.setAttribute(Eo,(im()+1).toString()),function(){var e=im()-1;e<=0?document.body.removeAttribute(Eo):document.body.setAttribute(Eo,e.toString())}},[])},WC=function(e){var t=e.noRelative,r=e.noImportant,n=e.gapMode,o=n===void 0?"margin":n;VC();var i=b.useMemo(function(){return HC(o)},[o]);return b.createElement(UC,{styles:zC(i,!t,o,r?"":"!important")})},rc=!1;if(typeof window<"u")try{var Vs=Object.defineProperty({},"passive",{get:function(){return rc=!0,!0}});window.addEventListener("test",Vs,Vs),window.removeEventListener("test",Vs,Vs)}catch{rc=!1}var ko=rc?{passive:!1}:!1,RC=function(e){return e.tagName==="TEXTAREA"},sm=function(e,t){if(!(e instanceof Element))return!1;var r=window.getComputedStyle(e);return r[t]!=="hidden"&&!(r.overflowY===r.overflowX&&!RC(e)&&r[t]==="visible")},KC=function(e){return sm(e,"overflowY")},GC=function(e){return sm(e,"overflowX")},am=function(e,t){var r=t.ownerDocument,n=t;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var o=lm(e,n);if(o){var i=cm(e,n),s=i[1],a=i[2];if(s>a)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},qC=function(e){var t=e.scrollTop,r=e.scrollHeight,n=e.clientHeight;return[t,r,n]},YC=function(e){var t=e.scrollLeft,r=e.scrollWidth,n=e.clientWidth;return[t,r,n]},lm=function(e,t){return e==="v"?KC(t):GC(t)},cm=function(e,t){return e==="v"?qC(t):YC(t)},XC=function(e,t){return e==="h"&&t==="rtl"?-1:1},JC=function(e,t,r,n,o){var i=XC(e,window.getComputedStyle(t).direction),s=i*n,a=r.target,c=t.contains(a),u=!1,f=s>0,l=0,p=0;do{if(!a)break;var g=cm(e,a),m=g[0],h=g[1],y=g[2],S=h-y-i*m;(m||S)&&lm(e,a)&&(l+=S,p+=m);var v=a.parentNode;a=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!c&&a!==document.body||c&&(t.contains(a)||t===a));return(f&&Math.abs(l)<1||!f&&Math.abs(p)<1)&&(u=!0),u},Ws=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},dm=function(e){return[e.deltaX,e.deltaY]},um=function(e){return e&&"current"in e?e.current:e},QC=function(e,t){return e[0]===t[0]&&e[1]===t[1]},ZC=function(e){return`
|
|
44
44
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
45
45
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
46
|
-
`)},RC=0,No=[];function KC(e){var t=b.useRef([]),r=b.useRef([0,0]),n=b.useRef(),o=b.useState(RC++)[0],i=b.useState(Jp)[0],s=b.useRef(e);b.useEffect(function(){s.current=e},[e]),b.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var h=pC([e.lockRef.current],(e.shards||[]).map(om),!0).filter(Boolean);return h.forEach(function(y){return y.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),h.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=b.useCallback(function(h,y){if("touches"in h&&h.touches.length===2||h.type==="wheel"&&h.ctrlKey)return!s.current.allowPinchZoom;var S=Us(h),v=r.current,A="deltaX"in h?h.deltaX:v[0]-S[0],x="deltaY"in h?h.deltaY:v[1]-S[1],F,N=h.target,k=Math.abs(A)>Math.abs(x)?"h":"v";if("touches"in h&&k==="h"&&N.type==="range")return!1;var T=window.getSelection(),P=T&&T.anchorNode,E=P?P===N||P.contains(N):!1;if(E)return!1;var C=em(k,N);if(!C)return!0;if(C?F=k:(F=k==="v"?"h":"v",C=em(k,N)),!C)return!1;if(!n.current&&"changedTouches"in h&&(A||x)&&(n.current=F),!F)return!0;var I=n.current||F;return VC(I,y,h,I==="h"?A:x)},[]),c=b.useCallback(function(h){var y=h;if(!(!No.length||No[No.length-1]!==i)){var S="deltaY"in y?nm(y):Us(y),v=t.current.filter(function(F){return F.name===y.type&&(F.target===y.target||y.target===F.shadowParent)&&HC(F.delta,S)})[0];if(v&&v.should){y.cancelable&&y.preventDefault();return}if(!v){var A=(s.current.shards||[]).map(om).filter(Boolean).filter(function(F){return F.contains(y.target)}),x=A.length>0?a(y,A[0]):!s.current.noIsolation;x&&y.cancelable&&y.preventDefault()}}},[]),u=b.useCallback(function(h,y,S,v){var A={name:h,delta:y,target:S,should:v,shadowParent:GC(S)};t.current.push(A),setTimeout(function(){t.current=t.current.filter(function(x){return x!==A})},1)},[]),f=b.useCallback(function(h){r.current=Us(h),n.current=void 0},[]),l=b.useCallback(function(h){u(h.type,nm(h),h.target,a(h,e.lockRef.current))},[]),p=b.useCallback(function(h){u(h.type,Us(h),h.target,a(h,e.lockRef.current))},[]);b.useEffect(function(){return No.push(i),e.setCallbacks({onScrollCapture:l,onWheelCapture:l,onTouchMoveCapture:p}),document.addEventListener("wheel",c,Eo),document.addEventListener("touchmove",c,Eo),document.addEventListener("touchstart",f,Eo),function(){No=No.filter(function(h){return h!==i}),document.removeEventListener("wheel",c,Eo),document.removeEventListener("touchmove",c,Eo),document.removeEventListener("touchstart",f,Eo)}},[]);var g=e.removeScrollBar,m=e.inert;return b.createElement(b.Fragment,null,m?b.createElement(i,{styles:WC(o)}):null,g?b.createElement(LC,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function GC(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const qC=xC(Xp,KC);var Vs=b.forwardRef(function(e,t){return b.createElement(js,cn({},e,{ref:t,sideCar:qC}))});Vs.classNames=js.classNames;var YC=[" ","Enter","ArrowUp","ArrowDown"],XC=[" ","Enter"],to="Select",[Hs,Ws,JC]=Nl(to),[ko]=Sr(to,[JC,Is]),Rs=Is(),[QC,Dn]=ko(to),[ZC,eE]=ko(to),im=e=>{const{__scopeSelect:t,children:r,open:n,defaultOpen:o,onOpenChange:i,value:s,defaultValue:a,onValueChange:c,dir:u,name:f,autoComplete:l,disabled:p,required:g,form:m}=e,h=Rs(t),[y,S]=b.useState(null),[v,A]=b.useState(null),[x,F]=b.useState(!1),N=bo(u),[k,T]=ln({prop:n,defaultProp:o??!1,onChange:i,caller:to}),[P,E]=ln({prop:s,defaultProp:a,onChange:c,caller:to}),C=b.useRef(null),I=y?m||!!y.closest("form"):!0,[W,M]=b.useState(new Set),U=Array.from(W).map(V=>V.props.value).join(";");return d.jsx(Vp,{...h,children:d.jsxs(QC,{required:g,scope:t,trigger:y,onTriggerChange:S,valueNode:v,onValueNodeChange:A,valueNodeHasChildren:x,onValueNodeHasChildrenChange:F,contentId:hn(),value:P,onValueChange:E,open:k,onOpenChange:T,dir:N,triggerPointerDownPosRef:C,disabled:p,children:[d.jsx(Hs.Provider,{scope:t,children:d.jsx(ZC,{scope:e.__scopeSelect,onNativeOptionAdd:b.useCallback(V=>{M(X=>new Set(X).add(V))},[]),onNativeOptionRemove:b.useCallback(V=>{M(X=>{const B=new Set(X);return B.delete(V),B})},[]),children:r})}),I?d.jsxs(km,{"aria-hidden":!0,required:g,tabIndex:-1,name:f,autoComplete:l,value:P,onChange:V=>E(V.target.value),disabled:p,form:m,children:[P===void 0?d.jsx("option",{value:""}):null,Array.from(W)]},U):null]})})};im.displayName=to;var sm="SelectTrigger",am=b.forwardRef((e,t)=>{const{__scopeSelect:r,disabled:n=!1,...o}=e,i=Rs(r),s=Dn(sm,r),a=s.disabled||n,c=qe(t,s.onTriggerChange),u=Ws(r),f=b.useRef("touch"),[l,p,g]=Tm(h=>{const y=u().filter(A=>!A.disabled),S=y.find(A=>A.value===s.value),v=Fm(y,h,S);v!==void 0&&s.onValueChange(v.value)}),m=h=>{a||(s.onOpenChange(!0),g()),h&&(s.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})};return d.jsx(Kl,{asChild:!0,...i,children:d.jsx($e.button,{type:"button",role:"combobox","aria-controls":s.contentId,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":"none",dir:s.dir,"data-state":s.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":_m(s.value)?"":void 0,...o,ref:c,onClick:Ie(o.onClick,h=>{h.currentTarget.focus(),f.current!=="mouse"&&m(h)}),onPointerDown:Ie(o.onPointerDown,h=>{f.current=h.pointerType;const y=h.target;y.hasPointerCapture(h.pointerId)&&y.releasePointerCapture(h.pointerId),h.button===0&&h.ctrlKey===!1&&h.pointerType==="mouse"&&(m(h),h.preventDefault())}),onKeyDown:Ie(o.onKeyDown,h=>{const y=l.current!=="";!(h.ctrlKey||h.altKey||h.metaKey)&&h.key.length===1&&p(h.key),!(y&&h.key===" ")&&YC.includes(h.key)&&(m(),h.preventDefault())})})})});am.displayName=sm;var lm="SelectValue",cm=b.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,style:o,children:i,placeholder:s="",...a}=e,c=Dn(lm,r),{onValueNodeHasChildrenChange:u}=c,f=i!==void 0,l=qe(t,c.onValueNodeChange);return tr(()=>{u(f)},[u,f]),d.jsx($e.span,{...a,ref:l,style:{pointerEvents:"none"},children:_m(c.value)?d.jsx(d.Fragment,{children:s}):i})});cm.displayName=lm;var tE="SelectIcon",dm=b.forwardRef((e,t)=>{const{__scopeSelect:r,children:n,...o}=e;return d.jsx($e.span,{"aria-hidden":!0,...o,ref:t,children:n||"▼"})});dm.displayName=tE;var rE="SelectPortal",um=e=>d.jsx(Ms,{asChild:!0,...e});um.displayName=rE;var ro="SelectContent",fm=b.forwardRef((e,t)=>{const r=Dn(ro,e.__scopeSelect),[n,o]=b.useState();if(tr(()=>{o(new DocumentFragment)},[]),!r.open){const i=n;return i?Wi.createPortal(d.jsx(pm,{scope:e.__scopeSelect,children:d.jsx(Hs.Slot,{scope:e.__scopeSelect,children:d.jsx("div",{children:e.children})})}),i):null}return d.jsx(mm,{...e,ref:t})});fm.displayName=ro;var Yr=10,[pm,Bn]=ko(ro),nE="SelectContentImpl",oE=ZA("SelectContent.RemoveScroll"),mm=b.forwardRef((e,t)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:i,onPointerDownOutside:s,side:a,sideOffset:c,align:u,alignOffset:f,arrowPadding:l,collisionBoundary:p,collisionPadding:g,sticky:m,hideWhenDetached:h,avoidCollisions:y,...S}=e,v=Dn(ro,r),[A,x]=b.useState(null),[F,N]=b.useState(null),k=qe(t,G=>x(G)),[T,P]=b.useState(null),[E,C]=b.useState(null),I=Ws(r),[W,M]=b.useState(!1),U=b.useRef(!1);b.useEffect(()=>{if(A)return ql(A)},[A]),Tl();const V=b.useCallback(G=>{const[ee,...Ae]=I().map(me=>me.ref.current),[te]=Ae.slice(-1),oe=document.activeElement;for(const me of G)if(me===oe||(me?.scrollIntoView({block:"nearest"}),me===ee&&F&&(F.scrollTop=0),me===te&&F&&(F.scrollTop=F.scrollHeight),me?.focus(),document.activeElement!==oe))return},[I,F]),X=b.useCallback(()=>V([T,A]),[V,T,A]);b.useEffect(()=>{W&&X()},[W,X]);const{onOpenChange:B,triggerPointerDownPosRef:L}=v;b.useEffect(()=>{if(A){let G={x:0,y:0};const ee=te=>{G={x:Math.abs(Math.round(te.pageX)-(L.current?.x??0)),y:Math.abs(Math.round(te.pageY)-(L.current?.y??0))}},Ae=te=>{G.x<=10&&G.y<=10?te.preventDefault():A.contains(te.target)||B(!1),document.removeEventListener("pointermove",ee),L.current=null};return L.current!==null&&(document.addEventListener("pointermove",ee),document.addEventListener("pointerup",Ae,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ee),document.removeEventListener("pointerup",Ae,{capture:!0})}}},[A,B,L]),b.useEffect(()=>{const G=()=>B(!1);return window.addEventListener("blur",G),window.addEventListener("resize",G),()=>{window.removeEventListener("blur",G),window.removeEventListener("resize",G)}},[B]);const[D,K]=Tm(G=>{const ee=I().filter(oe=>!oe.disabled),Ae=ee.find(oe=>oe.ref.current===document.activeElement),te=Fm(ee,G,Ae);te&&setTimeout(()=>te.ref.current.focus())}),ae=b.useCallback((G,ee,Ae)=>{const te=!U.current&&!Ae;(v.value!==void 0&&v.value===ee||te)&&(P(G),te&&(U.current=!0))},[v.value]),j=b.useCallback(()=>A?.focus(),[A]),z=b.useCallback((G,ee,Ae)=>{const te=!U.current&&!Ae;(v.value!==void 0&&v.value===ee||te)&&C(G)},[v.value]),le=n==="popper"?Zl:hm,ie=le===Zl?{side:a,sideOffset:c,align:u,alignOffset:f,arrowPadding:l,collisionBoundary:p,collisionPadding:g,sticky:m,hideWhenDetached:h,avoidCollisions:y}:{};return d.jsx(pm,{scope:r,content:A,viewport:F,onViewportChange:N,itemRefCallback:ae,selectedItem:T,onItemLeave:j,itemTextRefCallback:z,focusSelectedItem:X,selectedItemText:E,position:n,isPositioned:W,searchRef:D,children:d.jsx(Vs,{as:oE,allowPinchZoom:!0,children:d.jsx(xs,{asChild:!0,trapped:v.open,onMountAutoFocus:G=>{G.preventDefault()},onUnmountAutoFocus:Ie(o,G=>{v.trigger?.focus({preventScroll:!0}),G.preventDefault()}),children:d.jsx(Ss,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:G=>G.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:d.jsx(le,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:G=>G.preventDefault(),...S,...ie,onPlaced:()=>M(!0),ref:k,style:{display:"flex",flexDirection:"column",outline:"none",...S.style},onKeyDown:Ie(S.onKeyDown,G=>{const ee=G.ctrlKey||G.altKey||G.metaKey;if(G.key==="Tab"&&G.preventDefault(),!ee&&G.key.length===1&&K(G.key),["ArrowUp","ArrowDown","Home","End"].includes(G.key)){let te=I().filter(oe=>!oe.disabled).map(oe=>oe.ref.current);if(["ArrowUp","End"].includes(G.key)&&(te=te.slice().reverse()),["ArrowUp","ArrowDown"].includes(G.key)){const oe=G.target,me=te.indexOf(oe);te=te.slice(me+1)}setTimeout(()=>V(te)),G.preventDefault()}})})})})})})});mm.displayName=nE;var iE="SelectItemAlignedPosition",hm=b.forwardRef((e,t)=>{const{__scopeSelect:r,onPlaced:n,...o}=e,i=Dn(ro,r),s=Bn(ro,r),[a,c]=b.useState(null),[u,f]=b.useState(null),l=qe(t,k=>f(k)),p=Ws(r),g=b.useRef(!1),m=b.useRef(!0),{viewport:h,selectedItem:y,selectedItemText:S,focusSelectedItem:v}=s,A=b.useCallback(()=>{if(i.trigger&&i.valueNode&&a&&u&&h&&y&&S){const k=i.trigger.getBoundingClientRect(),T=u.getBoundingClientRect(),P=i.valueNode.getBoundingClientRect(),E=S.getBoundingClientRect();if(i.dir!=="rtl"){const oe=E.left-T.left,me=P.left-oe,Me=k.left-me,De=k.width+Me,ne=Math.max(De,T.width),ge=window.innerWidth-Yr,Se=pi(me,[Yr,Math.max(Yr,ge-ne)]);a.style.minWidth=De+"px",a.style.left=Se+"px"}else{const oe=T.right-E.right,me=window.innerWidth-P.right-oe,Me=window.innerWidth-k.right-me,De=k.width+Me,ne=Math.max(De,T.width),ge=window.innerWidth-Yr,Se=pi(me,[Yr,Math.max(Yr,ge-ne)]);a.style.minWidth=De+"px",a.style.right=Se+"px"}const C=p(),I=window.innerHeight-Yr*2,W=h.scrollHeight,M=window.getComputedStyle(u),U=parseInt(M.borderTopWidth,10),V=parseInt(M.paddingTop,10),X=parseInt(M.borderBottomWidth,10),B=parseInt(M.paddingBottom,10),L=U+V+W+B+X,D=Math.min(y.offsetHeight*5,L),K=window.getComputedStyle(h),ae=parseInt(K.paddingTop,10),j=parseInt(K.paddingBottom,10),z=k.top+k.height/2-Yr,le=I-z,ie=y.offsetHeight/2,G=y.offsetTop+ie,ee=U+V+G,Ae=L-ee;if(ee<=z){const oe=C.length>0&&y===C[C.length-1].ref.current;a.style.bottom="0px";const me=u.clientHeight-h.offsetTop-h.offsetHeight,Me=Math.max(le,ie+(oe?j:0)+me+X),De=ee+Me;a.style.height=De+"px"}else{const oe=C.length>0&&y===C[0].ref.current;a.style.top="0px";const Me=Math.max(z,U+h.offsetTop+(oe?ae:0)+ie)+Ae;a.style.height=Me+"px",h.scrollTop=ee-z+h.offsetTop}a.style.margin=`${Yr}px 0`,a.style.minHeight=D+"px",a.style.maxHeight=I+"px",n?.(),requestAnimationFrame(()=>g.current=!0)}},[p,i.trigger,i.valueNode,a,u,h,y,S,i.dir,n]);tr(()=>A(),[A]);const[x,F]=b.useState();tr(()=>{u&&F(window.getComputedStyle(u).zIndex)},[u]);const N=b.useCallback(k=>{k&&m.current===!0&&(A(),v?.(),m.current=!1)},[A,v]);return d.jsx(aE,{scope:r,contentWrapper:a,shouldExpandOnScrollRef:g,onScrollButtonChange:N,children:d.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:x},children:d.jsx($e.div,{...o,ref:l,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});hm.displayName=iE;var sE="SelectPopperPosition",Zl=b.forwardRef((e,t)=>{const{__scopeSelect:r,align:n="start",collisionPadding:o=Yr,...i}=e,s=Rs(r);return d.jsx(Hp,{...s,...i,ref:t,align:n,collisionPadding:o,style:{boxSizing:"border-box",...i.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Zl.displayName=sE;var[aE,ec]=ko(ro,{}),tc="SelectViewport",gm=b.forwardRef((e,t)=>{const{__scopeSelect:r,nonce:n,...o}=e,i=Bn(tc,r),s=ec(tc,r),a=qe(t,i.onViewportChange),c=b.useRef(0);return d.jsxs(d.Fragment,{children:[d.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),d.jsx(Hs.Slot,{scope:r,children:d.jsx($e.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Ie(o.onScroll,u=>{const f=u.currentTarget,{contentWrapper:l,shouldExpandOnScrollRef:p}=s;if(p?.current&&l){const g=Math.abs(c.current-f.scrollTop);if(g>0){const m=window.innerHeight-Yr*2,h=parseFloat(l.style.minHeight),y=parseFloat(l.style.height),S=Math.max(h,y);if(S<m){const v=S+g,A=Math.min(m,v),x=v-A;l.style.height=A+"px",l.style.bottom==="0px"&&(f.scrollTop=x>0?x:0,l.style.justifyContent="flex-end")}}}c.current=f.scrollTop})})})]})});gm.displayName=tc;var ym="SelectGroup",[lE,cE]=ko(ym),dE=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=hn();return d.jsx(lE,{scope:r,id:o,children:d.jsx($e.div,{role:"group","aria-labelledby":o,...n,ref:t})})});dE.displayName=ym;var bm="SelectLabel",uE=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=cE(bm,r);return d.jsx($e.div,{id:o.id,...n,ref:t})});uE.displayName=bm;var Ks="SelectItem",[fE,vm]=ko(Ks),wm=b.forwardRef((e,t)=>{const{__scopeSelect:r,value:n,disabled:o=!1,textValue:i,...s}=e,a=Dn(Ks,r),c=Bn(Ks,r),u=a.value===n,[f,l]=b.useState(i??""),[p,g]=b.useState(!1),m=qe(t,v=>c.itemRefCallback?.(v,n,o)),h=hn(),y=b.useRef("touch"),S=()=>{o||(a.onValueChange(n),a.onOpenChange(!1))};if(n==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return d.jsx(fE,{scope:r,value:n,disabled:o,textId:h,isSelected:u,onItemTextChange:b.useCallback(v=>{l(A=>A||(v?.textContent??"").trim())},[]),children:d.jsx(Hs.ItemSlot,{scope:r,value:n,disabled:o,textValue:f,children:d.jsx($e.div,{role:"option","aria-labelledby":h,"data-highlighted":p?"":void 0,"aria-selected":u&&p,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...s,ref:m,onFocus:Ie(s.onFocus,()=>g(!0)),onBlur:Ie(s.onBlur,()=>g(!1)),onClick:Ie(s.onClick,()=>{y.current!=="mouse"&&S()}),onPointerUp:Ie(s.onPointerUp,()=>{y.current==="mouse"&&S()}),onPointerDown:Ie(s.onPointerDown,v=>{y.current=v.pointerType}),onPointerMove:Ie(s.onPointerMove,v=>{y.current=v.pointerType,o?c.onItemLeave?.():y.current==="mouse"&&v.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ie(s.onPointerLeave,v=>{v.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:Ie(s.onKeyDown,v=>{c.searchRef?.current!==""&&v.key===" "||(XC.includes(v.key)&&S(),v.key===" "&&v.preventDefault())})})})})});wm.displayName=Ks;var bi="SelectItemText",Sm=b.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,style:o,...i}=e,s=Dn(bi,r),a=Bn(bi,r),c=vm(bi,r),u=eE(bi,r),[f,l]=b.useState(null),p=qe(t,S=>l(S),c.onItemTextChange,S=>a.itemTextRefCallback?.(S,c.value,c.disabled)),g=f?.textContent,m=b.useMemo(()=>d.jsx("option",{value:c.value,disabled:c.disabled,children:g},c.value),[c.disabled,c.value,g]),{onNativeOptionAdd:h,onNativeOptionRemove:y}=u;return tr(()=>(h(m),()=>y(m)),[h,y,m]),d.jsxs(d.Fragment,{children:[d.jsx($e.span,{id:c.textId,...i,ref:p}),c.isSelected&&s.valueNode&&!s.valueNodeHasChildren?Wi.createPortal(i.children,s.valueNode):null]})});Sm.displayName=bi;var xm="SelectItemIndicator",Am=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return vm(xm,r).isSelected?d.jsx($e.span,{"aria-hidden":!0,...n,ref:t}):null});Am.displayName=xm;var rc="SelectScrollUpButton",Cm=b.forwardRef((e,t)=>{const r=Bn(rc,e.__scopeSelect),n=ec(rc,e.__scopeSelect),[o,i]=b.useState(!1),s=qe(t,n.onScrollButtonChange);return tr(()=>{if(r.viewport&&r.isPositioned){let a=function(){const u=c.scrollTop>0;i(u)};const c=r.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[r.viewport,r.isPositioned]),o?d.jsx(Nm,{...e,ref:s,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=r;a&&c&&(a.scrollTop=a.scrollTop-c.offsetHeight)}}):null});Cm.displayName=rc;var nc="SelectScrollDownButton",Em=b.forwardRef((e,t)=>{const r=Bn(nc,e.__scopeSelect),n=ec(nc,e.__scopeSelect),[o,i]=b.useState(!1),s=qe(t,n.onScrollButtonChange);return tr(()=>{if(r.viewport&&r.isPositioned){let a=function(){const u=c.scrollHeight-c.clientHeight,f=Math.ceil(c.scrollTop)<u;i(f)};const c=r.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[r.viewport,r.isPositioned]),o?d.jsx(Nm,{...e,ref:s,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=r;a&&c&&(a.scrollTop=a.scrollTop+c.offsetHeight)}}):null});Em.displayName=nc;var Nm=b.forwardRef((e,t)=>{const{__scopeSelect:r,onAutoScroll:n,...o}=e,i=Bn("SelectScrollButton",r),s=b.useRef(null),a=Ws(r),c=b.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return b.useEffect(()=>()=>c(),[c]),tr(()=>{a().find(f=>f.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[a]),d.jsx($e.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:Ie(o.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(n,50))}),onPointerMove:Ie(o.onPointerMove,()=>{i.onItemLeave?.(),s.current===null&&(s.current=window.setInterval(n,50))}),onPointerLeave:Ie(o.onPointerLeave,()=>{c()})})}),pE="SelectSeparator",mE=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return d.jsx($e.div,{"aria-hidden":!0,...n,ref:t})});mE.displayName=pE;var oc="SelectArrow",hE=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=Rs(r),i=Dn(oc,r),s=Bn(oc,r);return i.open&&s.position==="popper"?d.jsx(Wp,{...o,...n,ref:t}):null});hE.displayName=oc;var gE="SelectBubbleInput",km=b.forwardRef(({__scopeSelect:e,value:t,...r},n)=>{const o=b.useRef(null),i=qe(n,o),s=yi(t);return b.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(c,"value").set;if(s!==t&&f){const l=new Event("change",{bubbles:!0});f.call(a,t),a.dispatchEvent(l)}},[s,t]),d.jsx($e.select,{...r,style:{...Rp,...r.style},ref:i,defaultValue:t})});km.displayName=gE;function _m(e){return e===""||e===void 0}function Tm(e){const t=dr(e),r=b.useRef(""),n=b.useRef(0),o=b.useCallback(s=>{const a=r.current+s;t(a),(function c(u){r.current=u,window.clearTimeout(n.current),u!==""&&(n.current=window.setTimeout(()=>c(""),1e3))})(a)},[t]),i=b.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,o,i]}function Fm(e,t,r){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,i=r?e.indexOf(r):-1;let s=yE(e,Math.max(i,0));o.length===1&&(s=s.filter(u=>u!==r));const c=s.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return c!==r?c:void 0}function yE(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var bE=im,vE=am,wE=cm,SE=dm,xE=um,AE=fm,CE=gm,EE=wm,NE=Sm,kE=Am,_E=Cm,TE=Em;function FE({...e}){return d.jsx(bE,{"data-slot":"select",...e})}function PE({className:e,...t}){return d.jsx(wE,{"data-slot":"select-value",className:H("truncate min-w-0",e),...t})}function OE({className:e,size:t="default",children:r,...n}){const o=e?.includes("w-full");return d.jsxs(vE,{"data-slot":"select-trigger","data-size":t,className:H("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] cursor-pointer disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",o&&"min-w-0",e),...n,children:[r,d.jsx(SE,{asChild:!0,children:d.jsx(ni,{className:"size-4 opacity-50"})})]})}function IE({className:e,children:t,position:r="popper",...n}){return d.jsx(xE,{children:d.jsxs(AE,{"data-slot":"select-content",className:H("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:r,...n,children:[d.jsx(ME,{}),d.jsx(CE,{className:H("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),d.jsx(LE,{})]})})}function ic({className:e,children:t,...r}){return d.jsxs(EE,{"data-slot":"select-item",className:H("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-pointer items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...r,children:[d.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:d.jsx(kE,{children:d.jsx(cs,{className:"size-4"})})}),d.jsx(NE,{className:"truncate",children:t})]})}function ME({className:e,...t}){return d.jsx(_E,{"data-slot":"select-scroll-up-button",className:H("flex cursor-default items-center justify-center py-1",e),...t,children:d.jsx(lS,{className:"size-4"})})}function LE({className:e,...t}){return d.jsx(TE,{"data-slot":"select-scroll-down-button",className:H("flex cursor-default items-center justify-center py-1",e),...t,children:d.jsx(ni,{className:"size-4"})})}function jt(e,t){if(!t||t.trim()===""||e==null)return;const r=t.split(".").filter(Boolean);let n=e;for(const o of r){if(n==null)return;n=n[o]}return n}function Pm(e){const t={array:[],pathPrefixToStrip:""};function r(a,c){if(a===null||typeof a!="object")return null;if(Array.isArray(a)&&a.length>0)return{array:a,fullPath:c};const u=Object.keys(a);for(const f of u){const l=a[f],p=c?`${c}.${f}`:f;if(Array.isArray(l)&&l.length>0)return{array:l,fullPath:p};if(l!==null&&typeof l=="object"){const g=r(l,p);if(g)return g}}return null}const n=r(e,"");if(!n)return t;const{array:o,fullPath:i}=n,s=i?`data.${i}.`:"";return{array:o,pathPrefixToStrip:s}}function DE(e){return e.length>=4&&Array.isArray(e[3])&&e[3].length===0}function BE(e,t,r){if(typeof e=="string"||typeof e=="number"||typeof e=="boolean"){const i=String(e);return{label:i,value:i,disabled:!1}}if(e==null)return{label:"",value:"",disabled:!0};if(typeof e!="object"||Array.isArray(e)){const i=Array.isArray(e)?"":String(e);return{label:i,value:i,disabled:!1}}let n,o;if(t){const i=t.includes(".")?jt(e,t):e[t];n=String(i!==void 0?i:e.label??e.name??e.title??e.text??e.username??e.email??e.value??e.id??"")}else n=String(e.label??e.name??e.title??e.text??e.username??e.email??e.value??e.id??"");if(r){const i=r.includes(".")?jt(e,r):e[r];o=String(i!==void 0?i:e.value??e.id??e.key??e.email??e.username??e.label??e.name??"")}else o=String(e.value??e.id??e.key??e.email??e.username??e.label??e.name??"");return{label:String(n??""),value:String(o??""),disabled:!!e.disabled}}function vi(e,t,r){if(!e)return[];if(Array.isArray(e)){if(e.length===0)return[];if(DE(e))return[];const n=e.filter(o=>o!=null);return n.length===0?[]:n.every(o=>typeof o=="string")?n.map(o=>({label:o,value:o,disabled:!1})):n.map(o=>BE(o,t,r))}if(typeof e=="object"){const{array:n,pathPrefixToStrip:o}=Pm(e);if(Array.isArray(n)&&n.length>0){const i=c=>!c||!c.trim()||!o?c:c.startsWith(o)?c.substring(o.length).replace(/^\.+/,"")||void 0:c,s=i(t),a=i(r);return vi(n,s,a)}}return[]}function $E(e){return!Array.isArray(e)||e.length===0?[]:e.filter(t=>t!=null).map((t,r)=>{if(typeof t=="string")return{label:t,value:t};if(typeof t=="object"&&t!==null){const n=t.label||t.value||String(t),o=t.value||t.label||String(t);return!n&&!o?{label:`Option ${r+1}`,value:String(r)}:{label:String(n),value:String(o),disabled:t.disabled||!1}}return{label:String(t),value:String(t)}})}function jE(e){return Array.isArray(e)&&e.length>=4&&Array.isArray(e[3])&&e[3].length>0&&Array.isArray(e[3][0])}function zE(e,t,r){if(!e)return[];try{const o=new URL(e).searchParams.get(t);return o?o.split(r).map(i=>i.trim()).filter(Boolean):[]}catch{const n=e.indexOf("?");if(n<0)return[];const o=e.slice(n+1);try{const s=new URLSearchParams(o).get(t);return s?s.split(r).map(a=>a.trim()).filter(Boolean):[]}catch{return[]}}}function Om(e){const{response:t,sourceUrl:r,rowsIndex:n,rowsPath:o,columns:i,columnsQueryParam:s="sf",columnsQueryParamSeparator:a=","}=e;let c;if(o&&o.trim()?c=jt(t,o):typeof n=="number"?c=t?.[n]:c=t,!Array.isArray(c)||c.length===0)return[];const u=c.filter(p=>Array.isArray(p));if(u.length===0)return Array.isArray(c[0])?[]:null;if(!Array.isArray(u[0]))return null;const f=zE(r,s,a),l=f.length>0?f:Array.isArray(i)&&i.length>0?i:[];return u.map(p=>{const g={};return(l.length>0?l:Array.from({length:p.length},(h,y)=>`col${y}`)).forEach((h,y)=>{g[h]=p[y]}),g})}function UE(e){const{rows:t,apiLabelField:r,apiLabelFields:n,apiLabelSeparator:o,apiValueField:i}=e;if(!Array.isArray(t)||t.length===0)return[];const s=t.filter(l=>l!=null&&typeof l=="object"&&!Array.isArray(l));if(s.length===0)return[];const a=Array.isArray(n)?n.filter(Boolean):[],c=o??" - ",u=l=>{if(r){const p=r.includes(".")?jt(l,r):l?.[r];if(p!=null&&String(p).trim()!=="")return String(p)}return String(l?.label??l?.name??l?.title??l?.text??l?.username??l?.email??l?.value??l?.id??l)},f=(l,p)=>{if(i){const g=i.includes(".")?jt(l,i):l?.[i];if(g!=null)return String(g)}return String(l?.value??l?.id??l?.key??l?.email??l?.username??l?.label??l?.name??p??l)};return s.map(l=>{let p="";a.length>0&&(p=a.map(h=>jt(l,h)).filter(h=>h!=null&&String(h).trim()!=="").map(h=>String(h)).join(c)),p||(p=u(l));const g=f(l,p);return{label:typeof p=="string"?p:String(p??""),value:typeof g=="string"?g:String(g??""),disabled:!!l?.disabled}})}function Im(e){return e!=null&&!Array.isArray(e)&&(typeof e=="string"||typeof e=="number"||typeof e=="boolean")}function VE(e,t){const{array:r,pathPrefixToStrip:n}=Pm(e);if(!Array.isArray(r)||r.length===0)return null;const o=new Set([t]);n&&t.startsWith(n)&&o.add(t.slice(n.length).replace(/^\.+/,""));const i=t.match(/^data\.data\.(.+)$/);i?.[1]&&o.add(i[1]);const s=r[0];for(const a of o){if(!a)continue;const c=a.includes(".")?jt(s,a):s?.[a];if(Im(c))return String(c)}return null}function HE(e,t,r){if(e==null)return null;const n=t?.trim(),o=r?.trim()||n;if(!n&&!o)return null;if(n){const s=jt(e,n);if(Im(s))return String(s);const a=VE(e,n);if(a!=null)return a}const i=vi(e,o,n||o);if(i.length>0){const s=i[0].value;if(s!=null&&String(s).trim()!=="")return String(s)}return null}function WE(e){if(e?.token!=null&&String(e.token).trim()!=="")return String(e.token);const t=fi(),r=t?.Authorization??t?.authorization;if(r?.trim()){const n=r.match(/^Bearer\s+(.+)$/i);return n?n[1]:r}}function Mm(e,t){const r=WE(t);if(!r)return e;let n=e.replace(/\{token\}/g,r);return n=n.replace(/\{authorization\}/gi,()=>r.startsWith("Bearer ")?r:`Bearer ${r}`),n}function vn(e,t){const r={},{formValues:n={},submissionContext:o,apiRealtime:i}=t;for(const{key:s,value:a}of e??[]){const c=s?.trim();if(!c||a==null)continue;let u=il(String(a),n,o,i);u=Mm(u,o),r[c]=u}return r}const RE=new Set(["authorization"]);function KE(e){return RE.has(e.trim().toLowerCase())}function wi(e){return(e??[]).filter(t=>!KE(t.key))}function Si(e){if(!e?.length)return null;const t=e.find(r=>r.key.toLowerCase()==="authorization");if(t?.value?.trim()){const r=t.value.trim();if(r.toLowerCase().startsWith("basic ")){const n=r.slice(6).trim();if(n.includes("{")||n.includes("}")){const o=n.split(":");if(o.length>=2)return{type:"basic",username:o[0].trim(),password:o.slice(1).join(":").trim()}}try{const o=atob(n),i=o.indexOf(":");if(i>=0)return{type:"basic",username:o.slice(0,i),password:o.slice(i+1)}}catch{return{type:"basic",username:"",password:""}}}return r.toLowerCase().startsWith("bearer ")?{type:"bearer",token:r.slice(7).trim()}:{type:"bearer",token:r}}return null}function GE(e){return!e||e.type==="none"?{type:"none"}:e.type==="bearer"?{type:"bearer",token:e.token?.trim()??""}:e.type==="apiKey"?{type:"apiKey",headerName:e.headerName?.trim()||"X-API-Key",apiKey:e.apiKey?.trim()??""}:{type:"basic",username:e.username?.trim()??"",password:e.password?.trim()??""}}function Gs(e,t){const{formValues:r={},submissionContext:n,urlParams:o={},apiRealtime:i}=t;let s=Rr(e,r,o,n);return s=Mm(s,n),i!==void 0&&(s=il(s,r,n,i)),s}function xi(e,t={}){const r=GE(e),n={};if(r.type==="bearer"){const o=r.token??"";if(!o.trim())return n;const i=Gs(o,t).trim();return i&&(n.Authorization=i.toLowerCase().startsWith("bearer ")?i:`Bearer ${i}`),n}if(r.type==="apiKey"){const o=r.apiKey??"";return o.trim()&&(n[r.headerName||"X-API-Key"]=Gs(o,t)),n}if(r.type==="basic"){const o=r.username??"",i=r.password??"";if(!o.trim()&&!i.trim())return n;const s=Gs(o,t),a=Gs(i,t);n.Authorization=`Basic ${btoa(`${s}:${a}`)}`}return n}function qE(e,t={}){const r=e.apiAuth??Si(e.apiHeaders)??{type:"none"},n=xi(r,t);return Object.assign(n,vn(wi(e.apiHeaders),t)),n}function Lm({field:e,formValues:t={},submissionContext:r}){const n=e.properties,o=n?.apiEndpoint?{apiEndpoint:n.apiEndpoint,apiMethod:n.apiMethod,apiKey:n.apiKey,apiRealtime:n.apiRealtime,apiAutoDetect:n.apiAutoDetect,apiLabelField:n.apiLabelField,apiValueField:n.apiValueField,apiQueryParams:n.apiQueryParams,apiClientFilter:n.apiClientFilter,apiHeaders:n.apiHeaders,apiBodyFields:n.apiBodyFields,apiAuth:n.apiAuth,valueSource:n.valueSource,optionsSource:n.optionsSource}:null,i=e.apidata||null,s=o||i,[a,c]=w.useState([]),[u,f]=w.useState([]),[l,p]=w.useState([]),[g,m]=w.useState(!1),[h,y]=w.useState(null),S=!!(s?.apiEndpoint&&(s?.valueSource==="api"||s?.optionsSource==="api"||n?.valueSource==="api"||n?.optionsSource==="api")),v=e.options||n?.options||[],A=w.useMemo(()=>$E(Array.isArray(v)?v:[]),[v]),x=w.useMemo(()=>{const E=s?.apiEndpoint||n?.apiEndpoint||"",C=s?.apiQueryParams||n?.apiQueryParams;return po(E,C)},[s?.apiEndpoint,n?.apiEndpoint,s?.apiQueryParams,n?.apiQueryParams]),F=w.useMemo(()=>{const E=new Set;for(const I of n?.dependentFields??[])typeof I=="string"&&I.trim()&&E.add(I.trim());const C=s?.apiClientFilter?.matchField?.trim()||n?.apiClientFilter?.matchField?.trim();return C&&E.add(C),[...E]},[n?.dependentFields,s?.apiClientFilter?.matchField,n?.apiClientFilter?.matchField]),N=w.useMemo(()=>{const E=new Set([...x,...F]);if(E.size===0)return null;const C={};return E.forEach(I=>{C[I]=t[I]}),JSON.stringify(C)},[x,F,t]),k=w.useMemo(()=>JSON.stringify(r||{}),[r]),T=w.useMemo(()=>{const E=new Set;e.name?.trim()&&E.add(e.name.trim());const C=e.key;return typeof C=="string"&&C.trim()&&E.add(C.trim()),[...E]},[e.name,e.key]);return w.useEffect(()=>{const E=s?.apiEndpoint;if(!S||!E){c([]);return}let C=!1;return(async()=>{a.length===0&&m(!0),y(null);try{const M=s?.apiMethod||n?.apiMethod||"GET",U=s?.apiRealtime||n?.apiRealtime,V=s?.apiQueryParams||n?.apiQueryParams||{},X=ns({apiEndpoint:E,apiMethod:M,apiQueryParams:V,formValues:t,submissionContext:r,apiRealtime:U,additionalRequiredFieldNames:F,excludeFormFieldNames:T});if(X.blocked){C||(c([]),m(!1));return}const B={"Content-Type":"application/json"},L=s?.apiKey||n?.apiKey;L&&(B["X-CSCAPI-KEY"]=L);const D=s?.apiAuth??n?.apiAuth??i?.apiAuth??Si(s?.apiHeaders??n?.apiHeaders??i?.apiHeaders)??{type:"none"},K=xi(D,{formValues:t,submissionContext:r,apiRealtime:U});Object.assign(B,K);const ae=s?.apiHeaders??n?.apiHeaders??i?.apiHeaders,j=s?.apiBodyFields??n?.apiBodyFields??i?.apiBodyFields,z=vn(wi(ae),{formValues:t,submissionContext:r,apiRealtime:U});Object.assign(B,z);const le=vn(j,{formValues:t,submissionContext:r,apiRealtime:U}),ie={method:M.toLowerCase(),url:Mr(X.url),headers:B};(X.postBodyBase!=null||Object.keys(le).length>0)&&(ie.data={...X.postBodyBase??{},...le});const G=await Ct(ie),ee=s?.apiLabelField||n?.apiLabelField,Ae=s?.apiValueField||n?.apiValueField,te=G.data;let oe=[];Array.isArray(te)?oe=te:te?.data&&(Array.isArray(te.data)?oe=te.data:te.data?.data&&Array.isArray(te.data.data)?oe=te.data.data:te.data.districts?oe=te.data.districts:te.data.states?oe=te.data.states:te.data.cities&&(oe=te.data.cities)),p(oe);const me=vi(G.data,ee,Ae);f(me);const Me=s?.apiClientFilter||n?.apiClientFilter;let De=me;if(Me?.filterField&&Me?.matchField){const ne=t[Me.matchField];ne!=null?De=me.filter(ge=>{const Se=oe.find(Nt=>String(jt(Nt,Ae||"code"))===String(ge.value));if(!Se)return!1;const yt=jt(Se,Me.filterField);return String(yt)===String(ne)}):De=[]}C||c(De)}catch(M){if(C)return;let U="Failed to load options";if(M.response){const V=M.response.data;M.response.status===404?U="API endpoint not found.":M.response.status===401?U="Authentication failed.":typeof V=="string"?U=V:V&&typeof V=="object"&&(U=V.error||V.message||V.detail||U)}else M.message&&(U=String(M.message));y(U),a.length===0&&c([])}finally{C||m(!1)}})(),()=>{C=!0}},[S,s?.apiEndpoint,s?.apiMethod,n?.apiEndpoint,n?.apiMethod,N,F,T,k]),w.useEffect(()=>{const E=s?.apiClientFilter||n?.apiClientFilter;if(!S||!E||l.length===0)return;const C=t[E.matchField],I=s?.apiValueField||n?.apiValueField;if(C==null){c([]);return}const W=u.filter(M=>{const U=l.find(X=>String(jt(X,I||"code"))===String(M.value));if(!U)return!1;const V=jt(U,E.filterField);return String(V)===String(C)});c(W)},[S,s?.apiClientFilter?.matchField,n?.apiClientFilter?.matchField,s?.apiClientFilter?.filterField,n?.apiClientFilter?.filterField,s?.apiValueField,n?.apiValueField,t[s?.apiClientFilter?.matchField||n?.apiClientFilter?.matchField||""],u,l]),{options:S?a:A,isLoadingOptions:g,optionsError:h}}const Dm=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a,formValues:c={},submissionContext:u,excludedOptionValues:f,isPrepopulateTarget:l=!1})=>{const p=e.properties,g=p?.apiEndpoint?{apiEndpoint:p.apiEndpoint,valueSource:p.valueSource,optionsSource:p.optionsSource}:null,m=e.apidata||null,h=g||m,y=!!(h?.apiEndpoint&&(h?.valueSource==="api"||h?.optionsSource==="api"||p?.valueSource==="api"||p?.optionsSource==="api")),{options:S,isLoadingOptions:v,optionsError:A}=Lm({field:e,formValues:c,submissionContext:u}),x=f?.length?new Set(f.map(String)):null,F=x?S.filter(D=>!x.has(String(D.value??D.label??""))):S,N="__clear__",k=t!=null&&String(t).trim()!=="",T=k?F.some(D=>String(D.value??D.label??"")===String(t)):!1,P=w.useMemo(()=>{if(!k||T)return F;const D=String(t);return[{label:D,value:D},...F]},[F,k,T,t]),E=k?String(t):void 0,C=`${ft(e)}-${E??"empty"}`,I=w.useCallback(D=>{r(D===N?"":D),n?.()},[r,n]),W=e.appearance?.size||"md",M={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},U=e.placeholder||"Select an option",V=p?.apiClientFilter?.matchField?.trim()||h?.apiClientFilter?.matchField?.trim(),X=y&&V&&(c[V]===void 0||c[V]===null||c[V]===""),B=v?"Loading options...":X?`Select ${V} first`:f?.length?"No available options":y?"No options available from API":"No options available";return y&&l&&v?d.jsx(At,{field:e,error:o||A||void 0,isRequired:s,className:a,children:d.jsxs("div",{role:"status","aria-label":"Loading options",className:H("flex items-center justify-center gap-2 w-full min-w-0 rounded-md border border-input bg-muted/50 text-muted-foreground",M[W],e.appearance?.className),children:[d.jsx(mo,{className:"h-4 w-4 animate-spin shrink-0"}),d.jsx("span",{className:"truncate",children:"Loading..."})]})}):d.jsx(At,{field:e,error:o||A||void 0,isRequired:s,className:a,children:d.jsxs(FE,{value:E,onValueChange:I,disabled:i||e.disabled||v&&F.length===0,children:[d.jsx(OE,{id:ft(e),"aria-describedby":Lt(e,!!o||!!A),"aria-invalid":Xt(!!o||!!A),"aria-required":s,className:H("w-full min-w-0",M[W],o&&"border-destructive focus-visible:ring-destructive",A&&"border-destructive focus-visible:ring-destructive",e.appearance?.className),children:d.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[v&&d.jsx(mo,{className:"h-4 w-4 animate-spin text-muted-foreground shrink-0"}),F.length===0&&f?.length&&!k?d.jsx("span",{className:"text-muted-foreground truncate",children:"No available options"}):k?d.jsx(PE,{placeholder:U}):d.jsx("span",{className:"text-muted-foreground truncate",children:U})]})}),d.jsx(IE,{children:P.length===0?d.jsx(ic,{value:"__no_options__",disabled:!0,children:B}):d.jsxs(d.Fragment,{children:[k?d.jsx(ic,{value:N,children:U}):null,P.map((D,K)=>{const ae=String(D.value??D.label??K);if(ae===N)return null;const j=D.label||D.value||String(D);return d.jsx(ic,{value:ae,disabled:D.disabled||!1,children:j},ae)})]})})]},C)})},Bm=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,$m=Dd,jm=(e,t)=>r=>{var n;if(t?.variants==null)return $m(e,r?.class,r?.className);const{variants:o,defaultVariants:i}=t,s=Object.keys(o).map(u=>{const f=r?.[u],l=i?.[u];if(f===null)return null;const p=Bm(f)||Bm(l);return o[u][p]}),a=r&&Object.entries(r).reduce((u,f)=>{let[l,p]=f;return p===void 0||(u[l]=p),u},{}),c=t==null||(n=t.compoundVariants)===null||n===void 0?void 0:n.reduce((u,f)=>{let{class:l,className:p,...g}=f;return Object.entries(g).every(m=>{let[h,y]=m;return Array.isArray(y)?y.includes({...i,...a}[h]):{...i,...a}[h]===y})?[...u,l,p]:u},[]);return $m(e,s,c,r?.class,r?.className)},YE=jm("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all cursor-pointer disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function Qt({className:e,variant:t,size:r,asChild:n=!1,...o}){const i=n?Wu:"button";return d.jsx(i,{"data-slot":"button",className:H(YE({variant:t,size:r,className:e})),...o})}function XE(e,t){return b.useReducer((r,n)=>t[r][n]??r,e)}var Cr=e=>{const{present:t,children:r}=e,n=JE(t),o=typeof r=="function"?r({present:n.isPresent}):b.Children.only(r),i=qe(n.ref,QE(o));return typeof r=="function"||n.isPresent?b.cloneElement(o,{ref:i}):null};Cr.displayName="Presence";function JE(e){const[t,r]=b.useState(),n=b.useRef(null),o=b.useRef(e),i=b.useRef("none"),s=e?"mounted":"unmounted",[a,c]=XE(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{const u=qs(n.current);i.current=a==="mounted"?u:"none"},[a]),tr(()=>{const u=n.current,f=o.current;if(f!==e){const p=i.current,g=qs(u);e?c("MOUNT"):g==="none"||u?.display==="none"?c("UNMOUNT"):c(f&&p!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),tr(()=>{if(t){let u;const f=t.ownerDocument.defaultView??window,l=g=>{const h=qs(n.current).includes(CSS.escape(g.animationName));if(g.target===t&&h&&(c("ANIMATION_END"),!o.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",u=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},p=g=>{g.target===t&&(i.current=qs(n.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",l),t.addEventListener("animationend",l),()=>{f.clearTimeout(u),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",l),t.removeEventListener("animationend",l)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:b.useCallback(u=>{n.current=u?getComputedStyle(u):null,r(u)},[])}}function qs(e){return e?.animationName||"none"}function QE(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function ZE(e){const t=eN(e),r=b.forwardRef((n,o)=>{const{children:i,...s}=n,a=b.Children.toArray(i),c=a.find(rN);if(c){const u=c.props.children,f=a.map(l=>l===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:l);return d.jsx(t,{...s,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,f):null})}return d.jsx(t,{...s,ref:o,children:i})});return r.displayName=`${e}.Slot`,r}function eN(e){const t=b.forwardRef((r,n)=>{const{children:o,...i}=r;if(b.isValidElement(o)){const s=oN(o),a=nN(i,o.props);return o.type!==b.Fragment&&(a.ref=n?qn(n,s):s),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var tN=Symbol("radix.slottable");function rN(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===tN}function nN(e,t){const r={...t};for(const n in t){const o=e[n],i=t[n];/^on[A-Z]/.test(n)?o&&i?r[n]=(...a)=>{const c=i(...a);return o(...a),c}:o&&(r[n]=o):n==="style"?r[n]={...o,...i}:n==="className"&&(r[n]=[o,i].filter(Boolean).join(" "))}return{...e,...r}}function oN(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var Ys="Popover",[zm]=Sr(Ys,[Is]),Ai=Is(),[iN,$n]=zm(Ys),Um=e=>{const{__scopePopover:t,children:r,open:n,defaultOpen:o,onOpenChange:i,modal:s=!1}=e,a=Ai(t),c=b.useRef(null),[u,f]=b.useState(!1),[l,p]=ln({prop:n,defaultProp:o??!1,onChange:i,caller:Ys});return d.jsx(Vp,{...a,children:d.jsx(iN,{scope:t,contentId:hn(),triggerRef:c,open:l,onOpenChange:p,onOpenToggle:b.useCallback(()=>p(g=>!g),[p]),hasCustomAnchor:u,onCustomAnchorAdd:b.useCallback(()=>f(!0),[]),onCustomAnchorRemove:b.useCallback(()=>f(!1),[]),modal:s,children:r})})};Um.displayName=Ys;var Vm="PopoverAnchor",Hm=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=$n(Vm,r),i=Ai(r),{onCustomAnchorAdd:s,onCustomAnchorRemove:a}=o;return b.useEffect(()=>(s(),()=>a()),[s,a]),d.jsx(Kl,{...i,...n,ref:t})});Hm.displayName=Vm;var Wm="PopoverTrigger",Rm=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=$n(Wm,r),i=Ai(r),s=qe(t,o.triggerRef),a=d.jsx($e.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Xm(o.open),...n,ref:s,onClick:Ie(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:d.jsx(Kl,{asChild:!0,...i,children:a})});Rm.displayName=Wm;var sc="PopoverPortal",[sN,aN]=zm(sc,{forceMount:void 0}),Km=e=>{const{__scopePopover:t,forceMount:r,children:n,container:o}=e,i=$n(sc,t);return d.jsx(sN,{scope:t,forceMount:r,children:d.jsx(Cr,{present:r||i.open,children:d.jsx(Ms,{asChild:!0,container:o,children:n})})})};Km.displayName=sc;var _o="PopoverContent",Gm=b.forwardRef((e,t)=>{const r=aN(_o,e.__scopePopover),{forceMount:n=r.forceMount,...o}=e,i=$n(_o,e.__scopePopover);return d.jsx(Cr,{present:n||i.open,children:i.modal?d.jsx(cN,{...o,ref:t}):d.jsx(dN,{...o,ref:t})})});Gm.displayName=_o;var lN=ZE("PopoverContent.RemoveScroll"),cN=b.forwardRef((e,t)=>{const r=$n(_o,e.__scopePopover),n=b.useRef(null),o=qe(t,n),i=b.useRef(!1);return b.useEffect(()=>{const s=n.current;if(s)return ql(s)},[]),d.jsx(Vs,{as:lN,allowPinchZoom:!0,children:d.jsx(qm,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ie(e.onCloseAutoFocus,s=>{s.preventDefault(),i.current||r.triggerRef.current?.focus()}),onPointerDownOutside:Ie(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,c=a.button===0&&a.ctrlKey===!0,u=a.button===2||c;i.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:Ie(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})})}),dN=b.forwardRef((e,t)=>{const r=$n(_o,e.__scopePopover),n=b.useRef(!1),o=b.useRef(!1);return d.jsx(qm,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(n.current||r.triggerRef.current?.focus(),i.preventDefault()),n.current=!1,o.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(n.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=i.target;r.triggerRef.current?.contains(s)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),qm=b.forwardRef((e,t)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:s,onEscapeKeyDown:a,onPointerDownOutside:c,onFocusOutside:u,onInteractOutside:f,...l}=e,p=$n(_o,r),g=Ai(r);return Tl(),d.jsx(xs,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:i,children:d.jsx(Ss,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:f,onEscapeKeyDown:a,onPointerDownOutside:c,onFocusOutside:u,onDismiss:()=>p.onOpenChange(!1),children:d.jsx(Hp,{"data-state":Xm(p.open),role:"dialog",id:p.contentId,...g,...l,ref:t,style:{...l.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),Ym="PopoverClose",uN=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=$n(Ym,r);return d.jsx($e.button,{type:"button",...n,ref:t,onClick:Ie(e.onClick,()=>o.onOpenChange(!1))})});uN.displayName=Ym;var fN="PopoverArrow",pN=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=Ai(r);return d.jsx(Wp,{...o,...n,ref:t})});pN.displayName=fN;function Xm(e){return e?"open":"closed"}var mN=Um,hN=Hm,gN=Rm,yN=Km,bN=Gm;function ac({...e}){return d.jsx(mN,{"data-slot":"popover",...e})}function Jm({...e}){return d.jsx(gN,{"data-slot":"popover-trigger",...e})}function lc({className:e,align:t="center",sideOffset:r=4,...n}){return d.jsx(yN,{children:d.jsx(bN,{"data-slot":"popover-content",align:t,sideOffset:r,className:H("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden pointer-events-auto",e),...n})})}function vN({...e}){return d.jsx(hN,{"data-slot":"popover-anchor",...e})}function Qm(e){return JSON.stringify(e).slice(1,-1)}function Zm(e){const t=e.asyncSearchValueObjectKeys;return Array.isArray(t)?t.map(r=>typeof r=="string"?r.trim():"").filter(Boolean):[]}function wN(e){return e.asyncSearchValueMode==="object"&&Zm(e).length>0}function SN(e,t){const r={};for(const n of t){const o=n.trim();if(!o)continue;const i=jt(e,o);i==null||typeof i=="object"?r[o]="":r[o]=String(i)}return r}function xN(e,t){const r=t.mode??"debounce",n=Math.max(0,t.intervalMs??300),[o,i]=w.useState(()=>r==="throttle"?e:""),s=w.useRef(0),a=w.useRef(void 0);return w.useEffect(()=>{if(e===""){a.current&&clearTimeout(a.current),i("");return}if(r==="debounce"){const f=setTimeout(()=>i(e),n);return()=>clearTimeout(f)}const c=Date.now(),u=c-s.current;return u>=n?(s.current=c,i(e),()=>{a.current&&clearTimeout(a.current)}):(a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{s.current=Date.now(),i(e),a.current=void 0},n-u),()=>{a.current&&clearTimeout(a.current)})},[e,r,n]),o}function cc(e,t){if(e==null||e==="")return"";if(t&&typeof e=="object"&&!Array.isArray(e)){const r=e,o=Object.keys(r).sort().map(i=>[i,r[i]??""]);return`O:${JSON.stringify(o)}`}return typeof e=="string"?`S:${e}`:""}function dc(e,t){return e==null||e===""?!0:t&&typeof e=="object"&&!Array.isArray(e)?Object.keys(e).length===0:!1}function AN(e,t,r){return t.trim()!==""?!0:e==null||e===""?!1:r&&typeof e=="object"&&!Array.isArray(e)?Object.keys(e).length>0:typeof e=="string"&&e.length>0}function CN(e){if(Ct.isAxiosError(e)){const t=e.response?.status,r=e.response?.data;if(t===404)return"Search endpoint not found.";if(t===401)return"Authentication failed.";if(r&&typeof r=="object"){const n=r,o=n.error??n.message??n.detail??n.explanation;if(typeof o=="string")return o}if(typeof r=="string")return r;if(t)return`Request failed (${t})`}return e instanceof Error?e.message:"Search failed"}function EN(e){if(e==null)return[];if(Array.isArray(e))return e;const t=e;if(!t?.data)return[];const r=t.data;return Array.isArray(r)?r:r?.data&&Array.isArray(r.data)?r.data:Array.isArray(r?.districts)?r.districts:Array.isArray(r?.states)?r.states:Array.isArray(r?.cities)?r.cities:[]}function eh(e,t){return typeof t=="number"&&t>0?e.slice(0,t):e}function uc(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.label=="string"&&t.value!==null&&t.value!==void 0}const th=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:c,formValues:u={},submissionContext:f})=>{const l=e.properties||{},p=wN(l),g=l.apiEndpoint?.trim()||"",m=l.apiRealtime===!0,h=(l.apiMethod||"GET").toUpperCase()==="POST"?"POST":"GET",y=l.searchInBody===!0,S=h==="POST"||h==="GET"&&y,v=l.searchStrategy??l.searchSchedule??"debounce",A=l.searchIntervalMs??l.intervalMs??300,x=l.minQueryLength??0,F=l.maxResults,N=l.searchQueryParam||"q",k=l.clearable!==!1,T=u,[P,E]=w.useState(()=>dc(t,p)?"":p&&typeof t=="object"&&t!==null&&!Array.isArray(t)?l.initialDisplayLabel||"":l.initialDisplayLabel||String(t)),[C,I]=w.useState(!1),[W,M]=w.useState([]),[U,V]=w.useState([]),[X,B]=w.useState([]),[L,D]=w.useState(!1),[K,ae]=w.useState(null),[j,z]=w.useState(-1),le=w.useRef(cc(t,p)),ie=w.useRef(dc(t,p)?"":p&&typeof t=="object"&&t!==null&&!Array.isArray(t)?l.initialDisplayLabel||"":l.initialDisplayLabel||String(t??"")),G=w.useRef(void 0),ee=w.useRef(0),Ae=w.useRef(null),te=xN(P,{mode:v,intervalMs:A}),oe=w.useMemo(()=>W.filter(uc),[W]);w.useEffect(()=>{if(oe.length===0){j!==-1&&z(-1);return}(j<0||j>=oe.length)&&z(0)},[j,oe.length]);const me=w.useMemo(()=>{const J=po(g,l.apiQueryParams),$=new Set(J);for(const fe of l.dependentFields||[])fe&&$.add(fe);return $},[g,l.apiQueryParams,l.dependentFields]),Me=w.useMemo(()=>{if(me.size===0)return null;const J={};return me.forEach($=>{J[$]=T[$]}),JSON.stringify(J)},[me,T]),De=w.useMemo(()=>JSON.stringify(u),[u]),ne=w.useMemo(()=>JSON.stringify(f||{}),[f]);w.useEffect(()=>{const J=cc(t,p);if(J===le.current)return;if(le.current=J,dc(t,p)){ie.current="",E(""),M([]),V([]),B([]),ae(null),I(!1);return}const $=l.initialDisplayLabel||(!p&&typeof t=="string"?t:"");ie.current=$,E($)},[t,l.initialDisplayLabel,p]),w.useEffect(()=>{if(!g){M([]),V([]),B([]),D(!1);return}if(s||i||e.disabled){M([]),V([]),B([]),D(!1);return}const J=te;if(J.length<x){M([]),V([]),B([]),D(!1),ae(null);return}const $=ns({apiEndpoint:g,apiMethod:h,apiQueryParams:l.apiQueryParams,formValues:T,submissionContext:f,apiRealtime:m,additionalRequiredFieldNames:l.dependentFields});if($.blocked){M([]),V([]),B([]),D(!1),ae(null);return}Ae.current?.abort();const fe=new AbortController;Ae.current=fe;const Ve=++ee.current;return(async()=>{D(!0),ae(null);const ze=Mr($.url),st={};S&&(st["Content-Type"]="application/json"),l.apiKey&&(st["X-CSCAPI-KEY"]=l.apiKey);const ht=l.apiAuth??Si(l.apiHeaders)??{type:"none"},lt=xi(ht,{formValues:T,submissionContext:f,apiRealtime:m});Object.assign(st,lt);const ct=vn(wi(l.apiHeaders),{formValues:T,submissionContext:f,apiRealtime:m});Object.assign(st,ct);const nt=vn(l.apiBodyFields,{formValues:T,submissionContext:f,apiRealtime:m});try{let ot;if(!S)ot=(await Jt.get(ze,{params:{[N]:J},signal:fe.signal,headers:Object.keys(st).length?st:void 0})).data;else{let Bt={};$.postBodyBase&&Object.keys($.postBodyBase).length>0?Bt={...$.postBodyBase}:m&&Object.keys(T).length>0&&(Bt={...T}),Bt={...Bt,...nt};let Ht=Bt;if(l.searchBodyTemplate?.trim()){let Jr=l.searchBodyTemplate.replace(/\{\{query\}\}/g,()=>Qm(J)).replace(/\{query\}/g,()=>Qm(J));Jr=il(Jr,T,f,m);const qt=JSON.parse(Jr);Ht={...Bt,...qt}}else Ht={...Bt,[N]:J};ot=(await Jt.post(ze,Ht,{signal:fe.signal,headers:Object.keys(st).length?st:void 0})).data}if(Ve!==ee.current)return;const ar=l.apiResultsFormat,vt=l.apiResultsConfig,er=ar==="clinicaltables_v3",Je=jE(ot),Ye=er||ar===void 0&&Je,nr=ar==="tuple_array";let br=null;Ye?br=Om({response:ot,sourceUrl:ze,rowsIndex:vt?.rowsIndex??3,rowsPath:vt?.rowsPath,columns:vt?.columns,columnsQueryParam:vt?.columnsQueryParam??"sf",columnsQueryParamSeparator:vt?.columnsQueryParamSeparator??","}):nr&&(br=Om({response:ot,sourceUrl:ze,rowsIndex:vt?.rowsIndex,rowsPath:vt?.rowsPath,columns:vt?.columns,columnsQueryParam:vt?.columnsQueryParam,columnsQueryParamSeparator:vt?.columnsQueryParamSeparator}));const vr=EN(ot),kt=br!==null,Nr=br&&Array.isArray(br)?br:Array.isArray(vr)&&vr.every(Bt=>Bt&&typeof Bt=="object"&&!Array.isArray(Bt))?vr:null;B(Nr??vr);const lr=Array.isArray(l.apiLabelFields)&&l.apiLabelFields.length>0,xn=Nr&&(kt||lr)?UE({rows:Nr,apiLabelField:l.apiLabelField,apiLabelFields:l.apiLabelFields,apiLabelSeparator:l.apiLabelSeparator,apiValueField:l.apiValueField}):vi(ot,l.apiLabelField,l.apiValueField);V(xn);const un=l.apiClientFilter;let $r=xn;if(un?.filterField&&un?.matchField){const Bt=T[un.matchField];if(Bt!=null){const Ht=l.apiValueField;$r=xn.filter(wr=>{const qt=(Nr??vr).find(Un=>String(jt(Un,Ht||"code"))===String(wr.value));if(!qt)return!1;const cr=jt(qt,un.filterField);return String(cr)===String(Bt)})}else $r=[]}const zn=eh($r,F).filter(uc);M(zn),z(zn.length>0?0:-1)}catch(ot){if(Ct.isCancel(ot)||ot?.code==="ERR_CANCELED"||Ve!==ee.current)return;M([]),V([]),B([]),ae(CN(ot)),z(-1)}finally{Ve===ee.current&&D(!1)}})(),()=>{fe.abort()}},[te,g,h,y,S,N,x,F,l.apiKey,l.searchBodyTemplate,l.apiLabelField,l.apiLabelFields,l.apiLabelSeparator,l.apiValueField,l.apiQueryParams,l.apiClientFilter,l.apiResultsFormat,l.apiResultsConfig,l.dependentFields,m,T,f,s,i,e.disabled,Me,De,ne]),w.useEffect(()=>{const J=l.apiClientFilter;if(!J||X.length===0||U.length===0)return;const $=T[J.matchField],fe=l.apiValueField;if($==null){M([]);return}const Ve=U.filter(ze=>{const st=X.find(lt=>String(jt(lt,fe||"code"))===String(ze.value));if(!st)return!1;const ht=jt(st,J.filterField);return String(ht)===String($)}),Fe=eh(Ve,F).filter(uc);M(Fe),z(Fe.length>0?0:-1)},[l.apiClientFilter,l.apiValueField,T,F,U,X]);const ge=i||e.disabled,Se=s||e.readOnly,yt=w.useCallback(J=>{const $=J.target.value;Se||ge||(le.current&&ie.current&&$!==ie.current&&(le.current="",ie.current="",r(p?null:"")),E($),I(!0),z(-1))},[ge,Se,p,r]),Nt=w.useCallback(J=>{const $=typeof J?.label=="string"?J.label:String(J?.value??""),fe=l.apiValueField||"code";if(p){const Ve=Zm(l),Fe=X.find(ze=>String(jt(ze,fe))===String(J.value));if(Fe&&typeof Fe=="object"&&!Array.isArray(Fe)&&Ve.length>0){const ze=SN(Fe,Ve);le.current=cc(ze,!0),ie.current=$,r(ze),E($)}else le.current=`S:${String(J.value)}`,ie.current=$,r(String(J.value)),E($)}else le.current=`S:${String(J.value)}`,ie.current=$,r(String(J.value)),E($);G.current&&clearTimeout(G.current),I(!1),z(-1),n?.()},[p,n,r,l,X]),Ut=w.useCallback(J=>{J.preventDefault(),J.stopPropagation(),!(ge||Se)&&(le.current="",ie.current="",r(p?null:""),E(""),M([]),V([]),B([]),ae(null),I(!1),n?.())},[ge,Se,p,r,n]),Ot=w.useMemo(()=>C&&!Se&&(L||!!K||oe.length>0||te.length>=x&&!L),[C,Se,L,K,oe.length,te,x]),Er=w.useCallback(J=>{if(!(Se||ge))if(J.key==="ArrowDown")J.preventDefault(),I(!0),z($=>oe.length===0?-1:($+1)%oe.length);else if(J.key==="ArrowUp")J.preventDefault(),I(!0),z($=>oe.length===0?-1:$<=0?oe.length-1:$-1);else if(J.key==="Enter"){const $=j>=0?oe[j]:void 0;Ot&&$&&!$.disabled&&(J.preventDefault(),Nt($))}else J.key==="Escape"&&I(!1)},[ge,Se,j,Ot,oe,Nt]),Dt=e.appearance?.size||"md",sr={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},Vt=ft(e),he=Lt(e,!!(o||K)),we=te.length>=x&&!L&&!K&&oe.length===0;return d.jsx(At,{field:e,error:o||K||void 0,isRequired:a,className:c,children:d.jsxs(ac,{open:Ot,onOpenChange:J=>{J||I(!1)},children:[d.jsx(vN,{asChild:!0,children:d.jsxs("div",{className:"relative flex w-full min-w-0 items-center gap-1",children:[d.jsx(mn,{id:Vt,role:"combobox","aria-expanded":Ot,"aria-autocomplete":"list","aria-controls":Ot?`${Vt}-listbox`:void 0,"aria-activedescendant":j>=0?`${Vt}-opt-${j}`:void 0,value:P,onChange:yt,onKeyDown:Er,onFocus:()=>{G.current&&clearTimeout(G.current),!Se&&!ge&&I(!0)},onBlur:()=>{G.current=setTimeout(()=>{I(!1),n?.()},150)},placeholder:e.placeholder||"Search…",disabled:ge,readOnly:Se,"aria-describedby":he,"aria-invalid":Xt(!!(o||K)),"aria-required":a,className:H("pr-20",sr[Dt],(o||K)&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)}),d.jsxs("div",{className:"pointer-events-none absolute right-1 top-1/2 flex -translate-y-1/2 items-center gap-0.5",children:[L&&d.jsx(mo,{className:"pointer-events-none h-4 w-4 animate-spin text-muted-foreground"}),k&&AN(t,P,p)&&!ge&&!Se&&d.jsx(Qt,{type:"button",variant:"ghost",size:"icon",className:"pointer-events-auto h-8 w-8 shrink-0",onMouseDown:J=>J.preventDefault(),onClick:Ut,"aria-label":"Clear",children:d.jsx(ii,{className:"h-4 w-4"})})]})]})}),d.jsx(lc,{className:"p-0 w-[var(--radix-popover-trigger-width)] min-w-[12rem] overflow-hidden",align:"start",onOpenAutoFocus:J=>J.preventDefault(),onCloseAutoFocus:J=>J.preventDefault(),children:d.jsx("div",{id:`${Vt}-listbox`,role:"listbox",children:K?d.jsx("div",{className:"px-3 py-2 text-sm text-destructive",children:K}):L?d.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-sm text-muted-foreground",children:[d.jsx(mo,{className:"h-4 w-4 animate-spin shrink-0"}),"Loading…"]}):we?d.jsx("ul",{className:"py-1","aria-label":"Search results",children:d.jsx("li",{role:"option","aria-disabled":!0,className:"cursor-default select-none px-3 py-2 text-sm text-muted-foreground",onMouseDown:J=>J.preventDefault(),children:"No results found"})}):d.jsx("ul",{className:"max-h-60 overflow-y-auto overscroll-contain py-1","aria-label":"Search results",children:oe.map((J,$)=>d.jsx("li",{id:`${Vt}-opt-${$}`,role:"option","aria-selected":j===$,className:H(J.disabled?"cursor-not-allowed opacity-60":"cursor-pointer","px-3 py-2 text-sm",j===$&&"bg-accent text-accent-foreground"),onMouseEnter:()=>z($),onMouseDown:fe=>fe.preventDefault(),onClick:()=>{J.disabled||Nt(J)},children:J.label},`${J.value}-${$}`))})})})]})})};var Xs="Checkbox",[NN]=Sr(Xs),[kN,fc]=NN(Xs);function _N(e){const{__scopeCheckbox:t,checked:r,children:n,defaultChecked:o,disabled:i,form:s,name:a,onCheckedChange:c,required:u,value:f="on",internal_do_not_use_render:l}=e,[p,g]=ln({prop:r,defaultProp:o??!1,onChange:c,caller:Xs}),[m,h]=b.useState(null),[y,S]=b.useState(null),v=b.useRef(!1),A=m?!!s||!!m.closest("form"):!0,x={checked:p,disabled:i,setChecked:g,control:m,setControl:h,name:a,form:s,value:f,hasConsumerStoppedPropagationRef:v,required:u,defaultChecked:jn(o)?!1:o,isFormControl:A,bubbleInput:y,setBubbleInput:S};return d.jsx(kN,{scope:t,...x,children:TN(l)?l(x):n})}var rh="CheckboxTrigger",nh=b.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:r,...n},o)=>{const{control:i,value:s,disabled:a,checked:c,required:u,setControl:f,setChecked:l,hasConsumerStoppedPropagationRef:p,isFormControl:g,bubbleInput:m}=fc(rh,e),h=qe(o,f),y=b.useRef(c);return b.useEffect(()=>{const S=i?.form;if(S){const v=()=>l(y.current);return S.addEventListener("reset",v),()=>S.removeEventListener("reset",v)}},[i,l]),d.jsx($e.button,{type:"button",role:"checkbox","aria-checked":jn(c)?"mixed":c,"aria-required":u,"data-state":ch(c),"data-disabled":a?"":void 0,disabled:a,value:s,...n,ref:h,onKeyDown:Ie(t,S=>{S.key==="Enter"&&S.preventDefault()}),onClick:Ie(r,S=>{l(v=>jn(v)?!0:!v),m&&g&&(p.current=S.isPropagationStopped(),p.current||S.stopPropagation())})})});nh.displayName=rh;var oh=b.forwardRef((e,t)=>{const{__scopeCheckbox:r,name:n,checked:o,defaultChecked:i,required:s,disabled:a,value:c,onCheckedChange:u,form:f,...l}=e;return d.jsx(_N,{__scopeCheckbox:r,checked:o,defaultChecked:i,disabled:a,required:s,onCheckedChange:u,name:n,form:f,value:c,internal_do_not_use_render:({isFormControl:p})=>d.jsxs(d.Fragment,{children:[d.jsx(nh,{...l,ref:t,__scopeCheckbox:r}),p&&d.jsx(lh,{__scopeCheckbox:r})]})})});oh.displayName=Xs;var ih="CheckboxIndicator",sh=b.forwardRef((e,t)=>{const{__scopeCheckbox:r,forceMount:n,...o}=e,i=fc(ih,r);return d.jsx(Cr,{present:n||jn(i.checked)||i.checked===!0,children:d.jsx($e.span,{"data-state":ch(i.checked),"data-disabled":i.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});sh.displayName=ih;var ah="CheckboxBubbleInput",lh=b.forwardRef(({__scopeCheckbox:e,...t},r)=>{const{control:n,hasConsumerStoppedPropagationRef:o,checked:i,defaultChecked:s,required:a,disabled:c,name:u,value:f,form:l,bubbleInput:p,setBubbleInput:g}=fc(ah,e),m=qe(r,g),h=yi(i),y=gi(n);b.useEffect(()=>{const v=p;if(!v)return;const A=window.HTMLInputElement.prototype,F=Object.getOwnPropertyDescriptor(A,"checked").set,N=!o.current;if(h!==i&&F){const k=new Event("click",{bubbles:N});v.indeterminate=jn(i),F.call(v,jn(i)?!1:i),v.dispatchEvent(k)}},[p,h,i,o]);const S=b.useRef(jn(i)?!1:i);return d.jsx($e.input,{type:"checkbox","aria-hidden":!0,defaultChecked:s??S.current,required:a,disabled:c,name:u,value:f,form:l,...t,tabIndex:-1,ref:m,style:{...t.style,...y,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});lh.displayName=ah;function TN(e){return typeof e=="function"}function jn(e){return e==="indeterminate"}function ch(e){return jn(e)?"indeterminate":e?"checked":"unchecked"}function Js({className:e,...t}){return d.jsx(oh,{"data-slot":"checkbox",className:H("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:d.jsx(sh,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:d.jsx(cs,{className:"size-3.5"})})})}const FN=jm("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-destructive-foreground [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",warning:"border-transparent bg-orange-500 text-white [a&]:hover:bg-orange-600 focus-visible:ring-orange-500/20",success:"border-transparent bg-green-500 text-white [a&]:hover:bg-green-600 focus-visible:ring-green-500/20",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function PN({className:e,variant:t,asChild:r=!1,...n}){const o=r?Wu:"span";return d.jsx(o,{"data-slot":"badge",className:H(FN({variant:t}),e),...n})}function ON(e,t){return b.useReducer((r,n)=>t[r][n]??r,e)}var pc="ScrollArea",[dh]=Sr(pc),[IN,Lr]=dh(pc),uh=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,type:n="hover",dir:o,scrollHideDelay:i=600,...s}=e,[a,c]=b.useState(null),[u,f]=b.useState(null),[l,p]=b.useState(null),[g,m]=b.useState(null),[h,y]=b.useState(null),[S,v]=b.useState(0),[A,x]=b.useState(0),[F,N]=b.useState(!1),[k,T]=b.useState(!1),P=qe(t,C=>c(C)),E=bo(o);return d.jsx(IN,{scope:r,type:n,dir:E,scrollHideDelay:i,scrollArea:a,viewport:u,onViewportChange:f,content:l,onContentChange:p,scrollbarX:g,onScrollbarXChange:m,scrollbarXEnabled:F,onScrollbarXEnabledChange:N,scrollbarY:h,onScrollbarYChange:y,scrollbarYEnabled:k,onScrollbarYEnabledChange:T,onCornerWidthChange:v,onCornerHeightChange:x,children:d.jsx($e.div,{dir:E,...s,ref:P,style:{position:"relative","--radix-scroll-area-corner-width":S+"px","--radix-scroll-area-corner-height":A+"px",...e.style}})})});uh.displayName=pc;var fh="ScrollAreaViewport",ph=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,children:n,nonce:o,...i}=e,s=Lr(fh,r),a=b.useRef(null),c=qe(t,a,s.onViewportChange);return d.jsxs(d.Fragment,{children:[d.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),d.jsx($e.div,{"data-radix-scroll-area-viewport":"",...i,ref:c,style:{overflowX:s.scrollbarXEnabled?"scroll":"hidden",overflowY:s.scrollbarYEnabled?"scroll":"hidden",...e.style},children:d.jsx("div",{ref:s.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});ph.displayName=fh;var dn="ScrollAreaScrollbar",mh=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Lr(dn,e.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:s}=o,a=e.orientation==="horizontal";return b.useEffect(()=>(a?i(!0):s(!0),()=>{a?i(!1):s(!1)}),[a,i,s]),o.type==="hover"?d.jsx(MN,{...n,ref:t,forceMount:r}):o.type==="scroll"?d.jsx(LN,{...n,ref:t,forceMount:r}):o.type==="auto"?d.jsx(hh,{...n,ref:t,forceMount:r}):o.type==="always"?d.jsx(mc,{...n,ref:t}):null});mh.displayName=dn;var MN=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Lr(dn,e.__scopeScrollArea),[i,s]=b.useState(!1);return b.useEffect(()=>{const a=o.scrollArea;let c=0;if(a){const u=()=>{window.clearTimeout(c),s(!0)},f=()=>{c=window.setTimeout(()=>s(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",f),()=>{window.clearTimeout(c),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",f)}}},[o.scrollArea,o.scrollHideDelay]),d.jsx(Cr,{present:r||i,children:d.jsx(hh,{"data-state":i?"visible":"hidden",...n,ref:t})})}),LN=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Lr(dn,e.__scopeScrollArea),i=e.orientation==="horizontal",s=ta(()=>c("SCROLL_END"),100),[a,c]=ON("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return b.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>c("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,c]),b.useEffect(()=>{const u=o.viewport,f=i?"scrollLeft":"scrollTop";if(u){let l=u[f];const p=()=>{const g=u[f];l!==g&&(c("SCROLL"),s()),l=g};return u.addEventListener("scroll",p),()=>u.removeEventListener("scroll",p)}},[o.viewport,i,c,s]),d.jsx(Cr,{present:r||a!=="hidden",children:d.jsx(mc,{"data-state":a==="hidden"?"hidden":"visible",...n,ref:t,onPointerEnter:Ie(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:Ie(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),hh=b.forwardRef((e,t)=>{const r=Lr(dn,e.__scopeScrollArea),{forceMount:n,...o}=e,[i,s]=b.useState(!1),a=e.orientation==="horizontal",c=ta(()=>{if(r.viewport){const u=r.viewport.offsetWidth<r.viewport.scrollWidth,f=r.viewport.offsetHeight<r.viewport.scrollHeight;s(a?u:f)}},10);return To(r.viewport,c),To(r.content,c),d.jsx(Cr,{present:n||i,children:d.jsx(mc,{"data-state":i?"visible":"hidden",...o,ref:t})})}),mc=b.forwardRef((e,t)=>{const{orientation:r="vertical",...n}=e,o=Lr(dn,e.__scopeScrollArea),i=b.useRef(null),s=b.useRef(0),[a,c]=b.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=wh(a.viewport,a.content),f={...n,sizes:a,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:p=>i.current=p,onThumbPointerUp:()=>s.current=0,onThumbPointerDown:p=>s.current=p};function l(p,g){return UN(p,s.current,a,g)}return r==="horizontal"?d.jsx(DN,{...f,ref:t,onThumbPositionChange:()=>{if(o.viewport&&i.current){const p=o.viewport.scrollLeft,g=Sh(p,a,o.dir);i.current.style.transform=`translate3d(${g}px, 0, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollLeft=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollLeft=l(p,o.dir))}}):r==="vertical"?d.jsx(BN,{...f,ref:t,onThumbPositionChange:()=>{if(o.viewport&&i.current){const p=o.viewport.scrollTop,g=Sh(p,a);i.current.style.transform=`translate3d(0, ${g}px, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollTop=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollTop=l(p))}}):null}),DN=b.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...o}=e,i=Lr(dn,e.__scopeScrollArea),[s,a]=b.useState(),c=b.useRef(null),u=qe(t,c,i.onScrollbarXChange);return b.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),d.jsx(yh,{"data-orientation":"horizontal",...o,ref:u,sizes:r,style:{bottom:0,left:i.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:i.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":ea(r)+"px",...e.style},onThumbPointerDown:f=>e.onThumbPointerDown(f.x),onDragScroll:f=>e.onDragScroll(f.x),onWheelScroll:(f,l)=>{if(i.viewport){const p=i.viewport.scrollLeft+f.deltaX;e.onWheelScroll(p),Ah(p,l)&&f.preventDefault()}},onResize:()=>{c.current&&i.viewport&&s&&n({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Zs(s.paddingLeft),paddingEnd:Zs(s.paddingRight)}})}})}),BN=b.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...o}=e,i=Lr(dn,e.__scopeScrollArea),[s,a]=b.useState(),c=b.useRef(null),u=qe(t,c,i.onScrollbarYChange);return b.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),d.jsx(yh,{"data-orientation":"vertical",...o,ref:u,sizes:r,style:{top:0,right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":ea(r)+"px",...e.style},onThumbPointerDown:f=>e.onThumbPointerDown(f.y),onDragScroll:f=>e.onDragScroll(f.y),onWheelScroll:(f,l)=>{if(i.viewport){const p=i.viewport.scrollTop+f.deltaY;e.onWheelScroll(p),Ah(p,l)&&f.preventDefault()}},onResize:()=>{c.current&&i.viewport&&s&&n({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Zs(s.paddingTop),paddingEnd:Zs(s.paddingBottom)}})}})}),[$N,gh]=dh(dn),yh=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:o,onThumbChange:i,onThumbPointerUp:s,onThumbPointerDown:a,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:f,onResize:l,...p}=e,g=Lr(dn,r),[m,h]=b.useState(null),y=qe(t,P=>h(P)),S=b.useRef(null),v=b.useRef(""),A=g.viewport,x=n.content-n.viewport,F=dr(f),N=dr(c),k=ta(l,10);function T(P){if(S.current){const E=P.clientX-S.current.left,C=P.clientY-S.current.top;u({x:E,y:C})}}return b.useEffect(()=>{const P=E=>{const C=E.target;m?.contains(C)&&F(E,x)};return document.addEventListener("wheel",P,{passive:!1}),()=>document.removeEventListener("wheel",P,{passive:!1})},[A,m,x,F]),b.useEffect(N,[n,N]),To(m,k),To(g.content,k),d.jsx($N,{scope:r,scrollbar:m,hasThumb:o,onThumbChange:dr(i),onThumbPointerUp:dr(s),onThumbPositionChange:N,onThumbPointerDown:dr(a),children:d.jsx($e.div,{...p,ref:y,style:{position:"absolute",...p.style},onPointerDown:Ie(e.onPointerDown,P=>{P.button===0&&(P.target.setPointerCapture(P.pointerId),S.current=m.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",g.viewport&&(g.viewport.style.scrollBehavior="auto"),T(P))}),onPointerMove:Ie(e.onPointerMove,T),onPointerUp:Ie(e.onPointerUp,P=>{const E=P.target;E.hasPointerCapture(P.pointerId)&&E.releasePointerCapture(P.pointerId),document.body.style.webkitUserSelect=v.current,g.viewport&&(g.viewport.style.scrollBehavior=""),S.current=null})})})}),Qs="ScrollAreaThumb",bh=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=gh(Qs,e.__scopeScrollArea);return d.jsx(Cr,{present:r||o.hasThumb,children:d.jsx(jN,{ref:t,...n})})}),jN=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,style:n,...o}=e,i=Lr(Qs,r),s=gh(Qs,r),{onThumbPositionChange:a}=s,c=qe(t,l=>s.onThumbChange(l)),u=b.useRef(void 0),f=ta(()=>{u.current&&(u.current(),u.current=void 0)},100);return b.useEffect(()=>{const l=i.viewport;if(l){const p=()=>{if(f(),!u.current){const g=VN(l,a);u.current=g,a()}};return a(),l.addEventListener("scroll",p),()=>l.removeEventListener("scroll",p)}},[i.viewport,f,a]),d.jsx($e.div,{"data-state":s.hasThumb?"visible":"hidden",...o,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:Ie(e.onPointerDownCapture,l=>{const g=l.target.getBoundingClientRect(),m=l.clientX-g.left,h=l.clientY-g.top;s.onThumbPointerDown({x:m,y:h})}),onPointerUp:Ie(e.onPointerUp,s.onThumbPointerUp)})});bh.displayName=Qs;var hc="ScrollAreaCorner",vh=b.forwardRef((e,t)=>{const r=Lr(hc,e.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?d.jsx(zN,{...e,ref:t}):null});vh.displayName=hc;var zN=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,...n}=e,o=Lr(hc,r),[i,s]=b.useState(0),[a,c]=b.useState(0),u=!!(i&&a);return To(o.scrollbarX,()=>{const f=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(f),c(f)}),To(o.scrollbarY,()=>{const f=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(f),s(f)}),u?d.jsx($e.div,{...n,ref:t,style:{width:i,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Zs(e){return e?parseInt(e,10):0}function wh(e,t){const r=e/t;return isNaN(r)?0:r}function ea(e){const t=wh(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,n=(e.scrollbar.size-r)*t;return Math.max(n,18)}function UN(e,t,r,n="ltr"){const o=ea(r),i=o/2,s=t||i,a=o-s,c=r.scrollbar.paddingStart+s,u=r.scrollbar.size-r.scrollbar.paddingEnd-a,f=r.content-r.viewport,l=n==="ltr"?[0,f]:[f*-1,0];return xh([c,u],l)(e)}function Sh(e,t,r="ltr"){const n=ea(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,i=t.scrollbar.size-o,s=t.content-t.viewport,a=i-n,c=r==="ltr"?[0,s]:[s*-1,0],u=pi(e,c);return xh([0,s],[0,a])(u)}function xh(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const n=(t[1]-t[0])/(e[1]-e[0]);return t[0]+n*(r-e[0])}}function Ah(e,t){return e>0&&e<t}var VN=(e,t=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},n=0;return(function o(){const i={left:e.scrollLeft,top:e.scrollTop},s=r.left!==i.left,a=r.top!==i.top;(s||a)&&t(),r=i,n=window.requestAnimationFrame(o)})(),()=>window.cancelAnimationFrame(n)};function ta(e,t){const r=dr(e),n=b.useRef(0);return b.useEffect(()=>()=>window.clearTimeout(n.current),[]),b.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,t)},[r,t])}function To(e,t){const r=dr(t);tr(()=>{let n=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(n),n=window.requestAnimationFrame(r)});return o.observe(e),()=>{window.cancelAnimationFrame(n),o.unobserve(e)}}},[e,r])}var HN=uh,WN=ph,RN=vh;function KN({className:e,children:t,...r}){return d.jsxs(HN,{"data-slot":"scroll-area",className:H("relative",e),...r,children:[d.jsx(WN,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:t}),d.jsx(GN,{}),d.jsx(RN,{})]})}function GN({className:e,orientation:t="vertical",...r}){return d.jsx(mh,{"data-slot":"scroll-area-scrollbar",orientation:t,className:H("flex touch-none p-px transition-colors select-none",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",e),...r,children:d.jsx(bh,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const Ch=({field:e,value:t=[],onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a,formValues:c={},submissionContext:u,excludedOptionValues:f})=>{const{options:l,isLoadingOptions:p,optionsError:g}=Lm({field:e,formValues:c,submissionContext:u}),m=f?.length?new Set(f.map(String)):null,h=m?l.filter(k=>!m.has(String(k.value??k.label??""))):l,y=Array.isArray(t)?t:[],S=y.map(k=>h.find(T=>String(T.value)===String(k))).filter(Boolean),v=w.useCallback(k=>{const T=y.includes(k)?y.filter(P=>P!==k):[...y,k];r(T),n?.()},[y,r,n]),A=w.useCallback(k=>{r(y.filter(T=>T!==k)),n?.()},[y,r,n]),x=e.appearance?.size||"md",F={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},N=S.length>0?`${S.length} selected`:h.length===0&&f?.length?"No available options":e.placeholder||"Select options";return d.jsxs(At,{field:e,error:o||g||void 0,isRequired:s,className:a,children:[d.jsxs(ac,{children:[d.jsx(Jm,{asChild:!0,children:d.jsxs(Qt,{type:"button",variant:"outline",role:"combobox","aria-expanded":void 0,"aria-haspopup":"listbox","aria-multiselectable":"true","aria-describedby":Lt(e,!!o||!!g),"aria-invalid":Xt(!!o||!!g),"aria-required":s,id:ft(e),disabled:i||e.disabled||p,className:H("w-full min-w-0 justify-between font-normal",F[x],o&&"border-destructive focus-visible:ring-destructive",g&&"border-destructive focus-visible:ring-destructive",e.appearance?.className),children:[d.jsx("span",{className:"truncate",children:N}),d.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[p&&d.jsx(mo,{className:"h-4 w-4 animate-spin text-muted-foreground"}),d.jsx(ni,{className:"h-4 w-4 opacity-50"})]})]})}),d.jsx(lc,{className:"w-[var(--radix-popover-trigger-width)] p-0 overflow-hidden",align:"start",children:d.jsx(KN,{className:"h-60 overflow-hidden rounded-md",children:d.jsx("ul",{role:"listbox","aria-multiselectable":"true","aria-label":e.label||e.name||"Options",className:"p-1",children:h.length===0?d.jsx("li",{className:"px-2 py-3 text-sm text-muted-foreground text-center",children:p?"Loading options...":f?.length?"No available options":"No options available"}):h.map(k=>{const T=String(k.value||k.label),P=k.label||k.value||T,E=y.includes(T);return d.jsxs("li",{role:"option","aria-selected":E,className:"flex items-center gap-2 rounded-sm px-2 py-1.5 cursor-pointer hover:bg-accent focus:bg-accent outline-none",onClick:()=>!k.disabled&&v(T),onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),k.disabled||v(T))},children:[d.jsx(Js,{checked:E,disabled:k.disabled,onCheckedChange:()=>!k.disabled&&v(T),onClick:C=>C.stopPropagation(),"aria-hidden":!0,className:"pointer-events-none"}),d.jsx("span",{className:"flex-1 truncate text-sm",children:P})]},T)})})})})]}),S.length>0&&d.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",role:"list","aria-label":"Selected options",children:S.map(k=>{const T=String(k.value||k.label),P=k.label||k.value||T;return d.jsxs(PN,{variant:"secondary",className:"pl-2 pr-1 py-0.5 text-xs font-normal gap-1",children:[d.jsx("span",{className:"truncate max-w-[120px]",children:P}),d.jsx("button",{type:"button","aria-label":`Remove ${P}`,className:"rounded-full p-0.5 hover:bg-muted focus:outline-none focus:ring-2 focus:ring-ring",onClick:()=>A(T),tabIndex:-1,children:d.jsx(ii,{className:"h-3 w-3"})})]},T)})})]})},Eh=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a})=>{const c=w.useCallback(u=>{r(u===!0),n?.()},[r,n]);return d.jsxs("div",{className:H("space-y-2",a),children:[d.jsxs("div",{className:"flex items-start space-x-3",children:[d.jsx(Js,{id:ft(e),checked:t||!1,onCheckedChange:c,disabled:i||e.disabled,"aria-describedby":Lt(e,!!o),"aria-required":s,className:H(o&&"border-destructive")}),d.jsxs("div",{className:"grid gap-1.5 leading-none",children:[d.jsxs(Pn,{id:ss(e),htmlFor:ft(e),className:H("text-sm font-medium cursor-pointer",o&&"text-destructive"),children:[e.label,s&&d.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.description&&!o&&d.jsx("p",{id:ti(e),className:"text-xs text-muted-foreground",children:e.description})]})]}),o&&d.jsx("p",{id:ri(e),className:"text-xs text-destructive",role:"alert",children:o})]})};var ra="Switch",[qN]=Sr(ra),[YN,XN]=qN(ra),Nh=b.forwardRef((e,t)=>{const{__scopeSwitch:r,name:n,checked:o,defaultChecked:i,required:s,disabled:a,value:c="on",onCheckedChange:u,form:f,...l}=e,[p,g]=b.useState(null),m=qe(t,A=>g(A)),h=b.useRef(!1),y=p?f||!!p.closest("form"):!0,[S,v]=ln({prop:o,defaultProp:i??!1,onChange:u,caller:ra});return d.jsxs(YN,{scope:r,checked:S,disabled:a,children:[d.jsx($e.button,{type:"button",role:"switch","aria-checked":S,"aria-required":s,"data-state":Fh(S),"data-disabled":a?"":void 0,disabled:a,value:c,...l,ref:m,onClick:Ie(e.onClick,A=>{v(x=>!x),y&&(h.current=A.isPropagationStopped(),h.current||A.stopPropagation())})}),y&&d.jsx(Th,{control:p,bubbles:!h.current,name:n,value:c,checked:S,required:s,disabled:a,form:f,style:{transform:"translateX(-100%)"}})]})});Nh.displayName=ra;var kh="SwitchThumb",_h=b.forwardRef((e,t)=>{const{__scopeSwitch:r,...n}=e,o=XN(kh,r);return d.jsx($e.span,{"data-state":Fh(o.checked),"data-disabled":o.disabled?"":void 0,...n,ref:t})});_h.displayName=kh;var JN="SwitchBubbleInput",Th=b.forwardRef(({__scopeSwitch:e,control:t,checked:r,bubbles:n=!0,...o},i)=>{const s=b.useRef(null),a=qe(s,i),c=yi(r),u=gi(t);return b.useEffect(()=>{const f=s.current;if(!f)return;const l=window.HTMLInputElement.prototype,g=Object.getOwnPropertyDescriptor(l,"checked").set;if(c!==r&&g){const m=new Event("click",{bubbles:n});g.call(f,r),f.dispatchEvent(m)}},[c,r,n]),d.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Th.displayName=JN;function Fh(e){return e?"checked":"unchecked"}var QN=Nh,ZN=_h;function Ph({className:e,...t}){return d.jsx(QN,{"data-slot":"switch",className:H("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:d.jsx(ZN,{"data-slot":"switch-thumb",className:H("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}const ek=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a})=>{const c=e.properties;let u=null;if(e.metadata)try{u=typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata}catch{}const f=u?.onValue??c?.onValue??"On",l=u?.offValue??c?.offValue??"Off",p=u?.onText??c?.onText??f,g=u?.offText??c?.offText??l,m=w.useMemo(()=>{const y=t??e.defaultValue??l;return String(y)===String(f)},[t,e.defaultValue,l,f]),h=w.useCallback(y=>{r(y?f:l),n?.()},[r,n,f,l]);return d.jsxs("div",{className:H("space-y-2",a),children:[d.jsxs("div",{className:"space-y-2",children:[e.label&&d.jsxs(Pn,{id:ss(e),htmlFor:ft(e),className:H("text-sm font-medium block",o&&"text-destructive"),children:[e.label,s&&d.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.description&&!o&&d.jsx("p",{id:ti(e),className:"text-xs text-muted-foreground",children:e.description}),d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx(Ph,{id:ft(e),checked:m,onCheckedChange:h,disabled:i||e.disabled,"aria-describedby":Lt(e,!!o),"aria-required":s,className:H(o&&"opacity-50")}),d.jsx("span",{className:"text-sm text-foreground font-medium",children:m?p:g})]})]}),o&&d.jsx("p",{id:ri(e),className:"text-xs text-destructive",role:"alert",children:o})]})};var gc="rovingFocusGroup.onEntryFocus",tk={bubbles:!1,cancelable:!0},Ci="RovingFocusGroup",[yc,Oh,rk]=Nl(Ci),[nk,na]=Sr(Ci,[rk]),[ok,ik]=nk(Ci),Ih=b.forwardRef((e,t)=>d.jsx(yc.Provider,{scope:e.__scopeRovingFocusGroup,children:d.jsx(yc.Slot,{scope:e.__scopeRovingFocusGroup,children:d.jsx(sk,{...e,ref:t})})}));Ih.displayName=Ci;var sk=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:f=!1,...l}=e,p=b.useRef(null),g=qe(t,p),m=bo(i),[h,y]=ln({prop:s,defaultProp:a??null,onChange:c,caller:Ci}),[S,v]=b.useState(!1),A=dr(u),x=Oh(r),F=b.useRef(!1),[N,k]=b.useState(0);return b.useEffect(()=>{const T=p.current;if(T)return T.addEventListener(gc,A),()=>T.removeEventListener(gc,A)},[A]),d.jsx(ok,{scope:r,orientation:n,dir:m,loop:o,currentTabStopId:h,onItemFocus:b.useCallback(T=>y(T),[y]),onItemShiftTab:b.useCallback(()=>v(!0),[]),onFocusableItemAdd:b.useCallback(()=>k(T=>T+1),[]),onFocusableItemRemove:b.useCallback(()=>k(T=>T-1),[]),children:d.jsx($e.div,{tabIndex:S||N===0?-1:0,"data-orientation":n,...l,ref:g,style:{outline:"none",...e.style},onMouseDown:Ie(e.onMouseDown,()=>{F.current=!0}),onFocus:Ie(e.onFocus,T=>{const P=!F.current;if(T.target===T.currentTarget&&P&&!S){const E=new CustomEvent(gc,tk);if(T.currentTarget.dispatchEvent(E),!E.defaultPrevented){const C=x().filter(V=>V.focusable),I=C.find(V=>V.active),W=C.find(V=>V.id===h),U=[I,W,...C].filter(Boolean).map(V=>V.ref.current);Dh(U,f)}}F.current=!1}),onBlur:Ie(e.onBlur,()=>v(!1))})})}),Mh="RovingFocusGroupItem",Lh=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:o=!1,tabStopId:i,children:s,...a}=e,c=hn(),u=i||c,f=ik(Mh,r),l=f.currentTabStopId===u,p=Oh(r),{onFocusableItemAdd:g,onFocusableItemRemove:m,currentTabStopId:h}=f;return b.useEffect(()=>{if(n)return g(),()=>m()},[n,g,m]),d.jsx(yc.ItemSlot,{scope:r,id:u,focusable:n,active:o,children:d.jsx($e.span,{tabIndex:l?0:-1,"data-orientation":f.orientation,...a,ref:t,onMouseDown:Ie(e.onMouseDown,y=>{n?f.onItemFocus(u):y.preventDefault()}),onFocus:Ie(e.onFocus,()=>f.onItemFocus(u)),onKeyDown:Ie(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){f.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const S=ck(y,f.orientation,f.dir);if(S!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let A=p().filter(x=>x.focusable).map(x=>x.ref.current);if(S==="last")A.reverse();else if(S==="prev"||S==="next"){S==="prev"&&A.reverse();const x=A.indexOf(y.currentTarget);A=f.loop?dk(A,x+1):A.slice(x+1)}setTimeout(()=>Dh(A))}}),children:typeof s=="function"?s({isCurrentTabStop:l,hasTabStop:h!=null}):s})})});Lh.displayName=Mh;var ak={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function lk(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function ck(e,t,r){const n=lk(e.key,r);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return ak[n]}function Dh(e,t=!1){const r=document.activeElement;for(const n of e)if(n===r||(n.focus({preventScroll:t}),document.activeElement!==r))return}function dk(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var Bh=Ih,$h=Lh,bc="Radio",[uk,jh]=Sr(bc),[fk,pk]=uk(bc),zh=b.forwardRef((e,t)=>{const{__scopeRadio:r,name:n,checked:o=!1,required:i,disabled:s,value:a="on",onCheck:c,form:u,...f}=e,[l,p]=b.useState(null),g=qe(t,y=>p(y)),m=b.useRef(!1),h=l?u||!!l.closest("form"):!0;return d.jsxs(fk,{scope:r,checked:o,disabled:s,children:[d.jsx($e.button,{type:"button",role:"radio","aria-checked":o,"data-state":Wh(o),"data-disabled":s?"":void 0,disabled:s,value:a,...f,ref:g,onClick:Ie(e.onClick,y=>{o||c?.(),h&&(m.current=y.isPropagationStopped(),m.current||y.stopPropagation())})}),h&&d.jsx(Hh,{control:l,bubbles:!m.current,name:n,value:a,checked:o,required:i,disabled:s,form:u,style:{transform:"translateX(-100%)"}})]})});zh.displayName=bc;var Uh="RadioIndicator",Vh=b.forwardRef((e,t)=>{const{__scopeRadio:r,forceMount:n,...o}=e,i=pk(Uh,r);return d.jsx(Cr,{present:n||i.checked,children:d.jsx($e.span,{"data-state":Wh(i.checked),"data-disabled":i.disabled?"":void 0,...o,ref:t})})});Vh.displayName=Uh;var mk="RadioBubbleInput",Hh=b.forwardRef(({__scopeRadio:e,control:t,checked:r,bubbles:n=!0,...o},i)=>{const s=b.useRef(null),a=qe(s,i),c=yi(r),u=gi(t);return b.useEffect(()=>{const f=s.current;if(!f)return;const l=window.HTMLInputElement.prototype,g=Object.getOwnPropertyDescriptor(l,"checked").set;if(c!==r&&g){const m=new Event("click",{bubbles:n});g.call(f,r),f.dispatchEvent(m)}},[c,r,n]),d.jsx($e.input,{type:"radio","aria-hidden":!0,defaultChecked:r,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Hh.displayName=mk;function Wh(e){return e?"checked":"unchecked"}var hk=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],oa="RadioGroup",[gk]=Sr(oa,[na,jh]),Rh=na(),Kh=jh(),[yk,bk]=gk(oa),Gh=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,name:n,defaultValue:o,value:i,required:s=!1,disabled:a=!1,orientation:c,dir:u,loop:f=!0,onValueChange:l,...p}=e,g=Rh(r),m=bo(u),[h,y]=ln({prop:i,defaultProp:o??null,onChange:l,caller:oa});return d.jsx(yk,{scope:r,name:n,required:s,disabled:a,value:h,onValueChange:y,children:d.jsx(Bh,{asChild:!0,...g,orientation:c,dir:m,loop:f,children:d.jsx($e.div,{role:"radiogroup","aria-required":s,"aria-orientation":c,"data-disabled":a?"":void 0,dir:m,...p,ref:t})})})});Gh.displayName=oa;var qh="RadioGroupItem",Yh=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,disabled:n,...o}=e,i=bk(qh,r),s=i.disabled||n,a=Rh(r),c=Kh(r),u=b.useRef(null),f=qe(t,u),l=i.value===o.value,p=b.useRef(!1);return b.useEffect(()=>{const g=h=>{hk.includes(h.key)&&(p.current=!0)},m=()=>p.current=!1;return document.addEventListener("keydown",g),document.addEventListener("keyup",m),()=>{document.removeEventListener("keydown",g),document.removeEventListener("keyup",m)}},[]),d.jsx($h,{asChild:!0,...a,focusable:!s,active:l,children:d.jsx(zh,{disabled:s,required:i.required,checked:l,...c,...o,name:i.name,ref:f,onCheck:()=>i.onValueChange(o.value),onKeyDown:Ie(g=>{g.key==="Enter"&&g.preventDefault()}),onFocus:Ie(o.onFocus,()=>{p.current&&u.current?.click()})})})});Yh.displayName=qh;var vk="RadioGroupIndicator",Xh=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,...n}=e,o=Kh(r);return d.jsx(Vh,{...o,...n,ref:t})});Xh.displayName=vk;var wk=Gh,Sk=Yh,xk=Xh;function Ak({className:e,...t}){return d.jsx(wk,{"data-slot":"radio-group",className:H("grid gap-3",e),...t})}function Ck({className:e,...t}){return d.jsx(Sk,{"data-slot":"radio-group-item",className:H("border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:d.jsx(xk,{"data-slot":"radio-group-indicator",className:"relative flex items-center justify-center",children:d.jsx(Yu,{className:"fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2"})})})}const Jh=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a,excludedOptionValues:c})=>{const u=e.properties,f=Array.isArray(u?.options)&&u.options.length>0?u.options:Array.isArray(e.options)?e.options:[],l=c?.length?new Set(c.map(String)):null,p=l?f.filter(m=>!l.has(String(m.value??m.label??""))):f,g=w.useCallback(m=>{r(m),n?.()},[r,n]);return d.jsx(At,{field:e,error:o,isRequired:s,className:a,children:d.jsx(Ak,{value:t||"",onValueChange:g,disabled:i||e.disabled||p.length===0,className:"flex flex-col space-y-2","aria-required":s,children:p.length===0?d.jsx("p",{className:"text-sm text-muted-foreground py-1",children:"No available options"}):p.map(m=>d.jsxs("div",{className:"flex items-center space-x-3",children:[d.jsx(Ck,{id:`${ft(e)}-${m.value}`,value:m.value,disabled:m.disabled,className:H(o&&"border-destructive")}),d.jsxs(Pn,{htmlFor:`${ft(e)}-${m.value}`,className:H("text-sm font-normal cursor-pointer",m.disabled&&"text-muted-foreground cursor-not-allowed"),children:[m.label,m.description&&d.jsx("span",{className:"block text-xs text-muted-foreground",children:m.description})]})]},m.value))})})},Qh=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:c})=>{const u=e.properties,f=w.useCallback(x=>{r(x.target.value)},[r]),l=x=>{if(x)return x==="today"?new Date().toISOString().split("T")[0]:x},p=l(u?.minDate),g=l(u?.maxDate),h=(()=>{switch(e.type){case"time":return"time";case"datetime":return"datetime-local";case"daterange":return"date";default:return"date"}})(),y=e.appearance?.size||"md",S={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},v=e.appearance?.labelPlacement||"top",A=!e.appearance?.hideLabel&&e.label;return d.jsxs("div",{className:H("space-y-2 w-fit",v==="left"&&"flex items-start gap-4",c),children:[A&&d.jsxs(Pn,{id:ss(e),htmlFor:ft(e),className:H("text-sm font-medium",v==="left"&&"w-32 pt-2 text-right",o&&"text-destructive"),children:[e.label,a&&d.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),d.jsxs("div",{className:"w-fit",children:[d.jsxs("div",{className:"relative w-fit max-w-full",children:[d.jsx(aS,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"}),d.jsx(mn,{id:ft(e),type:h,value:t||"",onChange:f,onBlur:n,disabled:i||e.disabled,readOnly:s||e.readOnly,min:p,max:g,"aria-describedby":Lt(e,!!o),"aria-invalid":Xt(!!o),"aria-required":a,className:H(S[y],"pl-10 w-fit",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]}),e.description&&!o&&d.jsx("p",{id:ti(e),className:"mt-1.5 text-xs text-muted-foreground",children:e.description}),o&&d.jsx("p",{id:ri(e),className:"mt-1.5 text-xs text-destructive",role:"alert",children:o})]})]})};function Fo(e){if(e===0)return"0 Bytes";const t=1024,r=["Bytes","KB","MB","GB"],n=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,n)).toFixed(2))+" "+r[n]}function vc(e,t){return e===1&&t===1}const Zh=/\.(jpg|jpeg|png|gif|webp|bmp|svg)(\?|$)/i;function wc(e){return e.type.startsWith("image/")?!0:Zh.test(e.name)}function ia(e){try{const t=e.split("?")[0];return Zh.test(t)}catch{return!1}}function Sc({items:e,maxFiles:t,disabled:r,objectUrls:n,failedUrlKeys:o,onImageUrlError:i,onRemove:s,onOpenUrl:a,resolveOpenUrl:c,addSlot:u,className:f}){const l=w.useCallback(p=>{try{return p.split("?")[0].split("/").filter(Boolean).pop()||p}catch{return p}},[]);return d.jsxs("div",{"data-file-like-strip":!0,"data-remove-in-dropzone":!0,className:H("relative w-full h-full flex items-center gap-1 min-h-0 overflow-x-auto",f),children:[e.map((p,g)=>{const m=p instanceof File,h=!m&&p&&"url"in p?p:null,y=h?.url??"",S=`${g}-${y}`,v=h&&o.has(y),A=m?n[g]??null:h&&ia(y)&&!v?y:null,x=m&&wc(p)&&!!A||!!h&&ia(y)&&!v&&!!A,F=m?p.name:h?h.name??l(y):"",N=c?.(g,p),k=h&&y||N||"",T=!!a&&!!k;return d.jsxs("div",{className:"relative h-[56px] w-[56px] min-w-[56px] flex-shrink-0 rounded overflow-hidden border border-border/60 bg-muted/30",children:[x&&A?d.jsx("img",{src:A,alt:"",className:"absolute inset-0 h-full w-full object-cover",onError:()=>{h&&i(y)}}):d.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-muted/40",children:d.jsx(Ju,{className:"h-7 w-7 text-muted-foreground","aria-hidden":!0})}),d.jsxs("div",{className:"absolute top-0.5 right-0.5 z-10 flex items-center gap-0.5",children:[T&&d.jsx("button",{type:"button",onClick:P=>{P.preventDefault(),P.stopPropagation(),a(k)},disabled:r,className:"inline-flex h-5 w-5 items-center justify-center rounded bg-background/90 text-foreground hover:bg-background focus:outline-none focus:ring-2 focus:ring-primary","aria-label":"Open file",title:"Open file",children:d.jsx(Xu,{className:"h-3 w-3","aria-hidden":!0})}),d.jsx("button",{type:"button",onClick:P=>{P.preventDefault(),P.stopPropagation(),s(g)},disabled:r,className:"inline-flex h-5 w-5 items-center justify-center rounded bg-background/90 text-destructive hover:bg-background focus:outline-none focus:ring-2 focus:ring-destructive","aria-label":"Remove file",title:"Remove file",children:d.jsx(ii,{className:"h-3 w-3","aria-hidden":!0})})]}),!x&&F&&d.jsx("span",{className:"sr-only",children:F})]},S+(m?p.name+p.size:""))}),u]})}function xc(e){const[t,r]=w.useState([]);return w.useEffect(()=>{const n=e.map(o=>o instanceof File&&wc(o)?URL.createObjectURL(o):null);return r(n),()=>{n.forEach(o=>{o&&URL.revokeObjectURL(o)})}},[e]),t}function Ac({item:e,objectUrl:t,failedUrlKeys:r,onImageUrlError:n,onRemove:o,onOpenUrl:i,openTarget:s,disabled:a}){const c=w.useCallback(v=>{try{return v.split("?")[0].split("/").filter(Boolean).pop()||v}catch{return v}},[]),u=e instanceof File,f=!u&&e&&"url"in e?e:null,l=f?.url??"",p=f&&r.has(l),g=u?t:f&&ia(l)&&!p?l:null,m=u&&wc(e)&&!!g||!!f&&ia(l)&&!p&&!!g,h=u?e.name:f?f.name??c(l):"",y=(s?.trim()||l||"").trim(),S=!!i&&!!y;return d.jsxs("div",{"data-file-like-full-bleed":!0,"data-remove-in-dropzone":!0,className:"relative h-full w-full min-h-[58px] min-w-0 flex items-center justify-center",children:[m&&g?d.jsx("img",{src:g,alt:"",className:"absolute inset-0 h-full w-full rounded object-cover",onError:()=>{f&&n(l)}}):d.jsx("div",{className:"absolute inset-0 flex items-center justify-center rounded bg-muted/40",children:d.jsx(Ju,{className:"h-8 w-8 text-muted-foreground","aria-hidden":!0})}),d.jsxs("div",{className:"absolute top-1 right-1 z-10 flex items-center gap-1",children:[S&&y&&d.jsx("button",{type:"button",onClick:v=>{v.preventDefault(),v.stopPropagation(),i(y)},disabled:a,className:"inline-flex h-6 w-6 items-center justify-center rounded bg-background/85 text-foreground hover:bg-background focus:outline-none focus:ring-2 focus:ring-primary","aria-label":"Open file",title:"Open file",children:d.jsx(Xu,{className:"h-3.5 w-3.5","aria-hidden":!0})}),d.jsx("button",{type:"button",onClick:v=>{v.preventDefault(),v.stopPropagation(),o()},disabled:a,className:"inline-flex h-6 w-6 items-center justify-center rounded bg-background/85 text-destructive hover:bg-background focus:outline-none focus:ring-2 focus:ring-destructive","aria-label":"Remove file",title:"Remove file",children:d.jsx(ii,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),!m&&h&&d.jsx("p",{className:"sr-only",children:h})]})}const Ek=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a,buttonResponses:c})=>{const{gridStretch:u}=Zo(),f=u&&Qi(e),l=e.properties,p=w.useRef(null),[g,m]=w.useState(!1),[h,y]=w.useState(),[S,v]=w.useState(()=>new Set),[A,x]=w.useState(0),F=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,N=Zi(e),k=w.useMemo(()=>es(t),[t]),[T,P]=w.useState(null);w.useEffect(()=>{P(null)},[t,A]);const E=T??k,C=xc(E),I=e.validation?.find(ne=>ne.type==="fileSize"),W=e.validation?.find(ne=>ne.type==="fileType"),M=I?.value?I.value:l?.maxSize??F?.maxSize??10*1024*1024,U=W?.value?W.value:l?.accept??F?.accept??[],V=Array.isArray(U)?U.join(","):"",X=()=>{E.length>=N||p.current?.click()},B=w.useCallback(ne=>{if(I){const ge=rn(ne,I);if(ge!==!0)return typeof ge=="string"?ge:"File size exceeds the maximum allowed size"}else if(ne.size>M)return`File size must be less than ${Fo(M)}`;if(W){const ge=rn(ne,W);if(ge!==!0)return typeof ge=="string"?ge:"File type is not allowed"}return null},[I,W,M]),L=w.useCallback(ne=>{const ge=Za(ne,N);r(ge),n?.()},[r,n,N]),D=w.useCallback(ne=>{y(void 0);const ge=Array.from(ne),Se=[...E];let yt=null;for(const Nt of ge){if(Se.length>=N)break;const Ut=B(Nt);if(Ut){yt||(yt=Ut);continue}Se.push(Nt)}if(yt&&Se.length===E.length){y(yt);return}yt&&y(yt),P(Se),L(Se)},[E,N,B,L]),K=w.useCallback(ne=>{const ge=ne.target.files;ge&&ge.length>0&&D(ge),p.current&&(p.current.value="")},[D]),ae=w.useCallback(ne=>{if(i)return;const ge=E.filter((Se,yt)=>yt!==ne);x(Se=>Se+1),P(ge),L(ge)},[i,E,L]),j=ne=>{ne.preventDefault(),m(!0)},z=()=>{m(!1)},le=ne=>{ne.preventDefault(),m(!1),ne.dataTransfer.files?.length&&D(ne.dataTransfer.files)},ie=o||h,G=[];(I||M)&&G.push(`Max size: ${Fo(M)}`),W&&U.length>0&&G.push(`Allowed types: ${U.join(", ")}`),N>1&&G.push(`Up to ${N} files`);const ee=e.appearance?.hideLabel??!1,Ae=w.useMemo(()=>{if(!c)return null;const ne=Object.values(c);for(let ge=ne.length-1;ge>=0;ge-=1){const Se=ne[ge],yt=typeof Se?.status=="string"?Se.status.toLowerCase():null;if(yt&&yt!=="success")continue;const Nt=Se?.code;if(typeof Nt=="number"&&(Nt<200||Nt>=300))continue;const Ut=Se?.data,Ot=Ut?.file_url||Ut?.fileUrl||Se?.file_url||Se?.fileUrl;if(typeof Ot=="string"&&Ot.trim())return Ot}return null},[c]),te=w.useCallback(ne=>{window.open(ne,"_blank","noopener,noreferrer")},[]),oe=w.useCallback(ne=>{v(ge=>new Set(ge).add(ne))},[]),me=E.length===0,Me=E.length<N,De=vc(N,E.length);return d.jsx(At,{field:e,error:ie,isRequired:s,className:H(a,"!space-y-0"),hideLabel:ee,children:d.jsx("div",{className:H("min-h-[70px] min-w-0 w-full flex flex-col",f?"flex-1 h-full":"h-[70px]"),children:d.jsxs("div",{onClick:ne=>{ne.target.closest("[data-remove-in-dropzone]")||ne.target.closest("[data-no-open-picker]")||X()},onDragOver:j,onDragLeave:z,onDrop:le,className:H("border-2 border-dashed rounded-lg p-1.5 text-center cursor-pointer transition-colors flex-1 min-h-0 flex flex-col items-center justify-center","hover:border-primary hover:bg-primary/5",g&&"border-primary bg-primary/10",ie&&"border-destructive",i&&"opacity-50 cursor-not-allowed",!Me&&E.length>0&&"cursor-default"),children:[d.jsx("input",{ref:p,id:ft(e),type:"file",accept:V,multiple:N>1,onChange:K,disabled:i||e.disabled||!Me,className:"hidden","aria-describedby":Lt(e,!!ie),"aria-invalid":Xt(!!ie),"aria-required":s}),me?d.jsxs(d.Fragment,{children:[d.jsx(ds,{className:"mx-auto h-5 w-5 text-muted-foreground flex-shrink-0"}),d.jsx("p",{className:"text-[11px] text-muted-foreground leading-tight line-clamp-1",children:"Drag & drop or click"}),G.length>0&&d.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-1",children:G.join(" • ")})]}):De?d.jsx(Ac,{item:E[0],objectUrl:C[0]??null,failedUrlKeys:S,onImageUrlError:oe,onRemove:()=>ae(0),onOpenUrl:te,openTarget:E[0]instanceof File?Ae:void 0,disabled:i||e.disabled}):d.jsx(Sc,{items:E,maxFiles:N,disabled:i,objectUrls:C,failedUrlKeys:S,onImageUrlError:oe,onRemove:ae,resolveOpenUrl:(ne,ge)=>ge instanceof File&&E.length===1&&Ae?.trim()?Ae.trim():null,onOpenUrl:ne=>{ne?.trim()&&te(ne.trim())},addSlot:Me?d.jsxs("button",{type:"button","data-no-open-picker":!0,onClick:ne=>{ne.stopPropagation(),p.current?.click()},disabled:i||e.disabled,className:"h-[56px] w-[56px] min-w-[56px] flex-shrink-0 rounded border border-dashed border-muted-foreground/40 flex flex-col items-center justify-center text-muted-foreground hover:border-primary hover:bg-primary/5 text-[10px] leading-tight px-0.5",children:[d.jsx(ds,{className:"h-4 w-4 mb-0.5","aria-hidden":!0}),"Add"]}):void 0})]})})})};function Nk(e){const t=kk(e),r=b.forwardRef((n,o)=>{const{children:i,...s}=n,a=b.Children.toArray(i),c=a.find(Tk);if(c){const u=c.props.children,f=a.map(l=>l===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:l);return d.jsx(t,{...s,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,f):null})}return d.jsx(t,{...s,ref:o,children:i})});return r.displayName=`${e}.Slot`,r}function kk(e){const t=b.forwardRef((r,n)=>{const{children:o,...i}=r;if(b.isValidElement(o)){const s=Pk(o),a=Fk(i,o.props);return o.type!==b.Fragment&&(a.ref=n?qn(n,s):s),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var _k=Symbol("radix.slottable");function Tk(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===_k}function Fk(e,t){const r={...t};for(const n in t){const o=e[n],i=t[n];/^on[A-Z]/.test(n)?o&&i?r[n]=(...a)=>{const c=i(...a);return o(...a),c}:o&&(r[n]=o):n==="style"?r[n]={...o,...i}:n==="className"&&(r[n]=[o,i].filter(Boolean).join(" "))}return{...e,...r}}function Pk(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var sa="Dialog",[eg]=Sr(sa),[Ok,Xr]=eg(sa),tg=e=>{const{__scopeDialog:t,children:r,open:n,defaultOpen:o,onOpenChange:i,modal:s=!0}=e,a=b.useRef(null),c=b.useRef(null),[u,f]=ln({prop:n,defaultProp:o??!1,onChange:i,caller:sa});return d.jsx(Ok,{scope:t,triggerRef:a,contentRef:c,contentId:hn(),titleId:hn(),descriptionId:hn(),open:u,onOpenChange:f,onOpenToggle:b.useCallback(()=>f(l=>!l),[f]),modal:s,children:r})};tg.displayName=sa;var rg="DialogTrigger",Ik=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Xr(rg,r),i=qe(t,o.triggerRef);return d.jsx($e.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Nc(o.open),...n,ref:i,onClick:Ie(e.onClick,o.onOpenToggle)})});Ik.displayName=rg;var Cc="DialogPortal",[Mk,ng]=eg(Cc,{forceMount:void 0}),og=e=>{const{__scopeDialog:t,forceMount:r,children:n,container:o}=e,i=Xr(Cc,t);return d.jsx(Mk,{scope:t,forceMount:r,children:b.Children.map(n,s=>d.jsx(Cr,{present:r||i.open,children:d.jsx(Ms,{asChild:!0,container:o,children:s})}))})};og.displayName=Cc;var aa="DialogOverlay",ig=b.forwardRef((e,t)=>{const r=ng(aa,e.__scopeDialog),{forceMount:n=r.forceMount,...o}=e,i=Xr(aa,e.__scopeDialog);return i.modal?d.jsx(Cr,{present:n||i.open,children:d.jsx(Dk,{...o,ref:t})}):null});ig.displayName=aa;var Lk=Nk("DialogOverlay.RemoveScroll"),Dk=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Xr(aa,r);return d.jsx(Vs,{as:Lk,allowPinchZoom:!0,shards:[o.contentRef],children:d.jsx($e.div,{"data-state":Nc(o.open),...n,ref:t,style:{pointerEvents:"auto",...n.style}})})}),no="DialogContent",sg=b.forwardRef((e,t)=>{const r=ng(no,e.__scopeDialog),{forceMount:n=r.forceMount,...o}=e,i=Xr(no,e.__scopeDialog);return d.jsx(Cr,{present:n||i.open,children:i.modal?d.jsx(Bk,{...o,ref:t}):d.jsx($k,{...o,ref:t})})});sg.displayName=no;var Bk=b.forwardRef((e,t)=>{const r=Xr(no,e.__scopeDialog),n=b.useRef(null),o=qe(t,r.contentRef,n);return b.useEffect(()=>{const i=n.current;if(i)return ql(i)},[]),d.jsx(ag,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ie(e.onCloseAutoFocus,i=>{i.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:Ie(e.onPointerDownOutside,i=>{const s=i.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&i.preventDefault()}),onFocusOutside:Ie(e.onFocusOutside,i=>i.preventDefault())})}),$k=b.forwardRef((e,t)=>{const r=Xr(no,e.__scopeDialog),n=b.useRef(!1),o=b.useRef(!1);return d.jsx(ag,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(n.current||r.triggerRef.current?.focus(),i.preventDefault()),n.current=!1,o.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(n.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=i.target;r.triggerRef.current?.contains(s)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),ag=b.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:i,...s}=e,a=Xr(no,r),c=b.useRef(null),u=qe(t,c);return Tl(),d.jsxs(d.Fragment,{children:[d.jsx(xs,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:i,children:d.jsx(Ss,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Nc(a.open),...s,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),d.jsxs(d.Fragment,{children:[d.jsx(zk,{titleId:a.titleId}),d.jsx(Vk,{contentRef:c,descriptionId:a.descriptionId})]})]})}),Ec="DialogTitle",lg=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Xr(Ec,r);return d.jsx($e.h2,{id:o.titleId,...n,ref:t})});lg.displayName=Ec;var cg="DialogDescription",jk=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Xr(cg,r);return d.jsx($e.p,{id:o.descriptionId,...n,ref:t})});jk.displayName=cg;var dg="DialogClose",ug=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Xr(dg,r);return d.jsx($e.button,{type:"button",...n,ref:t,onClick:Ie(e.onClick,()=>o.onOpenChange(!1))})});ug.displayName=dg;function Nc(e){return e?"open":"closed"}var fg="DialogTitleWarning",[MM,pg]=ax(fg,{contentName:no,titleName:Ec,docsSlug:"dialog"}),zk=({titleId:e})=>{const t=pg(fg),r=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
46
|
+
`)},eE=0,No=[];function tE(e){var t=b.useRef([]),r=b.useRef([0,0]),n=b.useRef(),o=b.useState(eE++)[0],i=b.useState(om)[0],s=b.useRef(e);b.useEffect(function(){s.current=e},[e]),b.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var h=xC([e.lockRef.current],(e.shards||[]).map(um),!0).filter(Boolean);return h.forEach(function(y){return y.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),h.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=b.useCallback(function(h,y){if("touches"in h&&h.touches.length===2||h.type==="wheel"&&h.ctrlKey)return!s.current.allowPinchZoom;var S=Ws(h),v=r.current,A="deltaX"in h?h.deltaX:v[0]-S[0],x="deltaY"in h?h.deltaY:v[1]-S[1],F,k=h.target,N=Math.abs(A)>Math.abs(x)?"h":"v";if("touches"in h&&N==="h"&&k.type==="range")return!1;var T=window.getSelection(),P=T&&T.anchorNode,E=P?P===k||P.contains(k):!1;if(E)return!1;var C=am(N,k);if(!C)return!0;if(C?F=N:(F=N==="v"?"h":"v",C=am(N,k)),!C)return!1;if(!n.current&&"changedTouches"in h&&(A||x)&&(n.current=F),!F)return!0;var O=n.current||F;return JC(O,y,h,O==="h"?A:x)},[]),c=b.useCallback(function(h){var y=h;if(!(!No.length||No[No.length-1]!==i)){var S="deltaY"in y?dm(y):Ws(y),v=t.current.filter(function(F){return F.name===y.type&&(F.target===y.target||y.target===F.shadowParent)&&QC(F.delta,S)})[0];if(v&&v.should){y.cancelable&&y.preventDefault();return}if(!v){var A=(s.current.shards||[]).map(um).filter(Boolean).filter(function(F){return F.contains(y.target)}),x=A.length>0?a(y,A[0]):!s.current.noIsolation;x&&y.cancelable&&y.preventDefault()}}},[]),u=b.useCallback(function(h,y,S,v){var A={name:h,delta:y,target:S,should:v,shadowParent:rE(S)};t.current.push(A),setTimeout(function(){t.current=t.current.filter(function(x){return x!==A})},1)},[]),f=b.useCallback(function(h){r.current=Ws(h),n.current=void 0},[]),l=b.useCallback(function(h){u(h.type,dm(h),h.target,a(h,e.lockRef.current))},[]),p=b.useCallback(function(h){u(h.type,Ws(h),h.target,a(h,e.lockRef.current))},[]);b.useEffect(function(){return No.push(i),e.setCallbacks({onScrollCapture:l,onWheelCapture:l,onTouchMoveCapture:p}),document.addEventListener("wheel",c,ko),document.addEventListener("touchmove",c,ko),document.addEventListener("touchstart",f,ko),function(){No=No.filter(function(h){return h!==i}),document.removeEventListener("wheel",c,ko),document.removeEventListener("touchmove",c,ko),document.removeEventListener("touchstart",f,ko)}},[]);var g=e.removeScrollBar,m=e.inert;return b.createElement(b.Fragment,null,m?b.createElement(i,{styles:ZC(o)}):null,g?b.createElement(WC,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function rE(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const nE=PC(nm,tE);var Rs=b.forwardRef(function(e,t){return b.createElement(zs,cn({},e,{ref:t,sideCar:nE}))});Rs.classNames=zs.classNames;var oE=[" ","Enter","ArrowUp","ArrowDown"],iE=[" ","Enter"],ro="Select",[Ks,Gs,sE]=Fl(ro),[_o]=Sr(ro,[sE,Ds]),qs=Ds(),[aE,Dn]=_o(ro),[lE,cE]=_o(ro),fm=e=>{const{__scopeSelect:t,children:r,open:n,defaultOpen:o,onOpenChange:i,value:s,defaultValue:a,onValueChange:c,dir:u,name:f,autoComplete:l,disabled:p,required:g,form:m}=e,h=qs(t),[y,S]=b.useState(null),[v,A]=b.useState(null),[x,F]=b.useState(!1),k=vo(u),[N,T]=ln({prop:n,defaultProp:o??!1,onChange:i,caller:ro}),[P,E]=ln({prop:s,defaultProp:a,onChange:c,caller:ro}),C=b.useRef(null),O=y?m||!!y.closest("form"):!0,[W,M]=b.useState(new Set),U=Array.from(W).map(z=>z.props.value).join(";");return d.jsx(Yp,{...h,children:d.jsxs(aE,{required:g,scope:t,trigger:y,onTriggerChange:S,valueNode:v,onValueNodeChange:A,valueNodeHasChildren:x,onValueNodeHasChildrenChange:F,contentId:yn(),value:P,onValueChange:E,open:N,onOpenChange:T,dir:k,triggerPointerDownPosRef:C,disabled:p,children:[d.jsx(Ks.Provider,{scope:t,children:d.jsx(lE,{scope:e.__scopeSelect,onNativeOptionAdd:b.useCallback(z=>{M(X=>new Set(X).add(z))},[]),onNativeOptionRemove:b.useCallback(z=>{M(X=>{const B=new Set(X);return B.delete(z),B})},[]),children:r})}),O?d.jsxs(Mm,{"aria-hidden":!0,required:g,tabIndex:-1,name:f,autoComplete:l,value:P,onChange:z=>E(z.target.value),disabled:p,form:m,children:[P===void 0?d.jsx("option",{value:""}):null,Array.from(W)]},U):null]})})};fm.displayName=ro;var pm="SelectTrigger",mm=b.forwardRef((e,t)=>{const{__scopeSelect:r,disabled:n=!1,...o}=e,i=qs(r),s=Dn(pm,r),a=s.disabled||n,c=qe(t,s.onTriggerChange),u=Gs(r),f=b.useRef("touch"),[l,p,g]=Dm(h=>{const y=u().filter(A=>!A.disabled),S=y.find(A=>A.value===s.value),v=Bm(y,h,S);v!==void 0&&s.onValueChange(v.value)}),m=h=>{a||(s.onOpenChange(!0),g()),h&&(s.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})};return d.jsx(Xl,{asChild:!0,...i,children:d.jsx($e.button,{type:"button",role:"combobox","aria-controls":s.contentId,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":"none",dir:s.dir,"data-state":s.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":Lm(s.value)?"":void 0,...o,ref:c,onClick:Oe(o.onClick,h=>{h.currentTarget.focus(),f.current!=="mouse"&&m(h)}),onPointerDown:Oe(o.onPointerDown,h=>{f.current=h.pointerType;const y=h.target;y.hasPointerCapture(h.pointerId)&&y.releasePointerCapture(h.pointerId),h.button===0&&h.ctrlKey===!1&&h.pointerType==="mouse"&&(m(h),h.preventDefault())}),onKeyDown:Oe(o.onKeyDown,h=>{const y=l.current!=="";!(h.ctrlKey||h.altKey||h.metaKey)&&h.key.length===1&&p(h.key),!(y&&h.key===" ")&&oE.includes(h.key)&&(m(),h.preventDefault())})})})});mm.displayName=pm;var hm="SelectValue",gm=b.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,style:o,children:i,placeholder:s="",...a}=e,c=Dn(hm,r),{onValueNodeHasChildrenChange:u}=c,f=i!==void 0,l=qe(t,c.onValueNodeChange);return tr(()=>{u(f)},[u,f]),d.jsx($e.span,{...a,ref:l,style:{pointerEvents:"none"},children:Lm(c.value)?d.jsx(d.Fragment,{children:s}):i})});gm.displayName=hm;var dE="SelectIcon",ym=b.forwardRef((e,t)=>{const{__scopeSelect:r,children:n,...o}=e;return d.jsx($e.span,{"aria-hidden":!0,...o,ref:t,children:n||"▼"})});ym.displayName=dE;var uE="SelectPortal",bm=e=>d.jsx(Bs,{asChild:!0,...e});bm.displayName=uE;var no="SelectContent",vm=b.forwardRef((e,t)=>{const r=Dn(no,e.__scopeSelect),[n,o]=b.useState();if(tr(()=>{o(new DocumentFragment)},[]),!r.open){const i=n;return i?Gi.createPortal(d.jsx(wm,{scope:e.__scopeSelect,children:d.jsx(Ks.Slot,{scope:e.__scopeSelect,children:d.jsx("div",{children:e.children})})}),i):null}return d.jsx(Sm,{...e,ref:t})});vm.displayName=no;var Yr=10,[wm,Bn]=_o(no),fE="SelectContentImpl",pE=lC("SelectContent.RemoveScroll"),Sm=b.forwardRef((e,t)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:i,onPointerDownOutside:s,side:a,sideOffset:c,align:u,alignOffset:f,arrowPadding:l,collisionBoundary:p,collisionPadding:g,sticky:m,hideWhenDetached:h,avoidCollisions:y,...S}=e,v=Dn(no,r),[A,x]=b.useState(null),[F,k]=b.useState(null),N=qe(t,G=>x(G)),[T,P]=b.useState(null),[E,C]=b.useState(null),O=Gs(r),[W,M]=b.useState(!1),U=b.useRef(!1);b.useEffect(()=>{if(A)return Ql(A)},[A]),Ol();const z=b.useCallback(G=>{const[ee,...Ae]=O().map(me=>me.ref.current),[te]=Ae.slice(-1),oe=document.activeElement;for(const me of G)if(me===oe||(me?.scrollIntoView({block:"nearest"}),me===ee&&F&&(F.scrollTop=0),me===te&&F&&(F.scrollTop=F.scrollHeight),me?.focus(),document.activeElement!==oe))return},[O,F]),X=b.useCallback(()=>z([T,A]),[z,T,A]);b.useEffect(()=>{W&&X()},[W,X]);const{onOpenChange:B,triggerPointerDownPosRef:L}=v;b.useEffect(()=>{if(A){let G={x:0,y:0};const ee=te=>{G={x:Math.abs(Math.round(te.pageX)-(L.current?.x??0)),y:Math.abs(Math.round(te.pageY)-(L.current?.y??0))}},Ae=te=>{G.x<=10&&G.y<=10?te.preventDefault():A.contains(te.target)||B(!1),document.removeEventListener("pointermove",ee),L.current=null};return L.current!==null&&(document.addEventListener("pointermove",ee),document.addEventListener("pointerup",Ae,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ee),document.removeEventListener("pointerup",Ae,{capture:!0})}}},[A,B,L]),b.useEffect(()=>{const G=()=>B(!1);return window.addEventListener("blur",G),window.addEventListener("resize",G),()=>{window.removeEventListener("blur",G),window.removeEventListener("resize",G)}},[B]);const[D,K]=Dm(G=>{const ee=O().filter(oe=>!oe.disabled),Ae=ee.find(oe=>oe.ref.current===document.activeElement),te=Bm(ee,G,Ae);te&&setTimeout(()=>te.ref.current.focus())}),le=b.useCallback((G,ee,Ae)=>{const te=!U.current&&!Ae;(v.value!==void 0&&v.value===ee||te)&&(P(G),te&&(U.current=!0))},[v.value]),j=b.useCallback(()=>A?.focus(),[A]),H=b.useCallback((G,ee,Ae)=>{const te=!U.current&&!Ae;(v.value!==void 0&&v.value===ee||te)&&C(G)},[v.value]),ce=n==="popper"?nc:xm,ie=ce===nc?{side:a,sideOffset:c,align:u,alignOffset:f,arrowPadding:l,collisionBoundary:p,collisionPadding:g,sticky:m,hideWhenDetached:h,avoidCollisions:y}:{};return d.jsx(wm,{scope:r,content:A,viewport:F,onViewportChange:k,itemRefCallback:le,selectedItem:T,onItemLeave:j,itemTextRefCallback:H,focusSelectedItem:X,selectedItemText:E,position:n,isPositioned:W,searchRef:D,children:d.jsx(Rs,{as:pE,allowPinchZoom:!0,children:d.jsx(Es,{asChild:!0,trapped:v.open,onMountAutoFocus:G=>{G.preventDefault()},onUnmountAutoFocus:Oe(o,G=>{v.trigger?.focus({preventScroll:!0}),G.preventDefault()}),children:d.jsx(Cs,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:G=>G.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:d.jsx(ce,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:G=>G.preventDefault(),...S,...ie,onPlaced:()=>M(!0),ref:N,style:{display:"flex",flexDirection:"column",outline:"none",...S.style},onKeyDown:Oe(S.onKeyDown,G=>{const ee=G.ctrlKey||G.altKey||G.metaKey;if(G.key==="Tab"&&G.preventDefault(),!ee&&G.key.length===1&&K(G.key),["ArrowUp","ArrowDown","Home","End"].includes(G.key)){let te=O().filter(oe=>!oe.disabled).map(oe=>oe.ref.current);if(["ArrowUp","End"].includes(G.key)&&(te=te.slice().reverse()),["ArrowUp","ArrowDown"].includes(G.key)){const oe=G.target,me=te.indexOf(oe);te=te.slice(me+1)}setTimeout(()=>z(te)),G.preventDefault()}})})})})})})});Sm.displayName=fE;var mE="SelectItemAlignedPosition",xm=b.forwardRef((e,t)=>{const{__scopeSelect:r,onPlaced:n,...o}=e,i=Dn(no,r),s=Bn(no,r),[a,c]=b.useState(null),[u,f]=b.useState(null),l=qe(t,N=>f(N)),p=Gs(r),g=b.useRef(!1),m=b.useRef(!0),{viewport:h,selectedItem:y,selectedItemText:S,focusSelectedItem:v}=s,A=b.useCallback(()=>{if(i.trigger&&i.valueNode&&a&&u&&h&&y&&S){const N=i.trigger.getBoundingClientRect(),T=u.getBoundingClientRect(),P=i.valueNode.getBoundingClientRect(),E=S.getBoundingClientRect();if(i.dir!=="rtl"){const oe=E.left-T.left,me=P.left-oe,Me=N.left-me,De=N.width+Me,ne=Math.max(De,T.width),ge=window.innerWidth-Yr,Se=hi(me,[Yr,Math.max(Yr,ge-ne)]);a.style.minWidth=De+"px",a.style.left=Se+"px"}else{const oe=T.right-E.right,me=window.innerWidth-P.right-oe,Me=window.innerWidth-N.right-me,De=N.width+Me,ne=Math.max(De,T.width),ge=window.innerWidth-Yr,Se=hi(me,[Yr,Math.max(Yr,ge-ne)]);a.style.minWidth=De+"px",a.style.right=Se+"px"}const C=p(),O=window.innerHeight-Yr*2,W=h.scrollHeight,M=window.getComputedStyle(u),U=parseInt(M.borderTopWidth,10),z=parseInt(M.paddingTop,10),X=parseInt(M.borderBottomWidth,10),B=parseInt(M.paddingBottom,10),L=U+z+W+B+X,D=Math.min(y.offsetHeight*5,L),K=window.getComputedStyle(h),le=parseInt(K.paddingTop,10),j=parseInt(K.paddingBottom,10),H=N.top+N.height/2-Yr,ce=O-H,ie=y.offsetHeight/2,G=y.offsetTop+ie,ee=U+z+G,Ae=L-ee;if(ee<=H){const oe=C.length>0&&y===C[C.length-1].ref.current;a.style.bottom="0px";const me=u.clientHeight-h.offsetTop-h.offsetHeight,Me=Math.max(ce,ie+(oe?j:0)+me+X),De=ee+Me;a.style.height=De+"px"}else{const oe=C.length>0&&y===C[0].ref.current;a.style.top="0px";const Me=Math.max(H,U+h.offsetTop+(oe?le:0)+ie)+Ae;a.style.height=Me+"px",h.scrollTop=ee-H+h.offsetTop}a.style.margin=`${Yr}px 0`,a.style.minHeight=D+"px",a.style.maxHeight=O+"px",n?.(),requestAnimationFrame(()=>g.current=!0)}},[p,i.trigger,i.valueNode,a,u,h,y,S,i.dir,n]);tr(()=>A(),[A]);const[x,F]=b.useState();tr(()=>{u&&F(window.getComputedStyle(u).zIndex)},[u]);const k=b.useCallback(N=>{N&&m.current===!0&&(A(),v?.(),m.current=!1)},[A,v]);return d.jsx(gE,{scope:r,contentWrapper:a,shouldExpandOnScrollRef:g,onScrollButtonChange:k,children:d.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:x},children:d.jsx($e.div,{...o,ref:l,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});xm.displayName=mE;var hE="SelectPopperPosition",nc=b.forwardRef((e,t)=>{const{__scopeSelect:r,align:n="start",collisionPadding:o=Yr,...i}=e,s=qs(r);return d.jsx(Xp,{...s,...i,ref:t,align:n,collisionPadding:o,style:{boxSizing:"border-box",...i.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});nc.displayName=hE;var[gE,oc]=_o(no,{}),ic="SelectViewport",Am=b.forwardRef((e,t)=>{const{__scopeSelect:r,nonce:n,...o}=e,i=Bn(ic,r),s=oc(ic,r),a=qe(t,i.onViewportChange),c=b.useRef(0);return d.jsxs(d.Fragment,{children:[d.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),d.jsx(Ks.Slot,{scope:r,children:d.jsx($e.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Oe(o.onScroll,u=>{const f=u.currentTarget,{contentWrapper:l,shouldExpandOnScrollRef:p}=s;if(p?.current&&l){const g=Math.abs(c.current-f.scrollTop);if(g>0){const m=window.innerHeight-Yr*2,h=parseFloat(l.style.minHeight),y=parseFloat(l.style.height),S=Math.max(h,y);if(S<m){const v=S+g,A=Math.min(m,v),x=v-A;l.style.height=A+"px",l.style.bottom==="0px"&&(f.scrollTop=x>0?x:0,l.style.justifyContent="flex-end")}}}c.current=f.scrollTop})})})]})});Am.displayName=ic;var Cm="SelectGroup",[yE,bE]=_o(Cm),vE=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=yn();return d.jsx(yE,{scope:r,id:o,children:d.jsx($e.div,{role:"group","aria-labelledby":o,...n,ref:t})})});vE.displayName=Cm;var Em="SelectLabel",wE=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=bE(Em,r);return d.jsx($e.div,{id:o.id,...n,ref:t})});wE.displayName=Em;var Ys="SelectItem",[SE,km]=_o(Ys),Nm=b.forwardRef((e,t)=>{const{__scopeSelect:r,value:n,disabled:o=!1,textValue:i,...s}=e,a=Dn(Ys,r),c=Bn(Ys,r),u=a.value===n,[f,l]=b.useState(i??""),[p,g]=b.useState(!1),m=qe(t,v=>c.itemRefCallback?.(v,n,o)),h=yn(),y=b.useRef("touch"),S=()=>{o||(a.onValueChange(n),a.onOpenChange(!1))};if(n==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return d.jsx(SE,{scope:r,value:n,disabled:o,textId:h,isSelected:u,onItemTextChange:b.useCallback(v=>{l(A=>A||(v?.textContent??"").trim())},[]),children:d.jsx(Ks.ItemSlot,{scope:r,value:n,disabled:o,textValue:f,children:d.jsx($e.div,{role:"option","aria-labelledby":h,"data-highlighted":p?"":void 0,"aria-selected":u&&p,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...s,ref:m,onFocus:Oe(s.onFocus,()=>g(!0)),onBlur:Oe(s.onBlur,()=>g(!1)),onClick:Oe(s.onClick,()=>{y.current!=="mouse"&&S()}),onPointerUp:Oe(s.onPointerUp,()=>{y.current==="mouse"&&S()}),onPointerDown:Oe(s.onPointerDown,v=>{y.current=v.pointerType}),onPointerMove:Oe(s.onPointerMove,v=>{y.current=v.pointerType,o?c.onItemLeave?.():y.current==="mouse"&&v.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Oe(s.onPointerLeave,v=>{v.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:Oe(s.onKeyDown,v=>{c.searchRef?.current!==""&&v.key===" "||(iE.includes(v.key)&&S(),v.key===" "&&v.preventDefault())})})})})});Nm.displayName=Ys;var wi="SelectItemText",_m=b.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,style:o,...i}=e,s=Dn(wi,r),a=Bn(wi,r),c=km(wi,r),u=cE(wi,r),[f,l]=b.useState(null),p=qe(t,S=>l(S),c.onItemTextChange,S=>a.itemTextRefCallback?.(S,c.value,c.disabled)),g=f?.textContent,m=b.useMemo(()=>d.jsx("option",{value:c.value,disabled:c.disabled,children:g},c.value),[c.disabled,c.value,g]),{onNativeOptionAdd:h,onNativeOptionRemove:y}=u;return tr(()=>(h(m),()=>y(m)),[h,y,m]),d.jsxs(d.Fragment,{children:[d.jsx($e.span,{id:c.textId,...i,ref:p}),c.isSelected&&s.valueNode&&!s.valueNodeHasChildren?Gi.createPortal(i.children,s.valueNode):null]})});_m.displayName=wi;var Tm="SelectItemIndicator",Fm=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return km(Tm,r).isSelected?d.jsx($e.span,{"aria-hidden":!0,...n,ref:t}):null});Fm.displayName=Tm;var sc="SelectScrollUpButton",Pm=b.forwardRef((e,t)=>{const r=Bn(sc,e.__scopeSelect),n=oc(sc,e.__scopeSelect),[o,i]=b.useState(!1),s=qe(t,n.onScrollButtonChange);return tr(()=>{if(r.viewport&&r.isPositioned){let a=function(){const u=c.scrollTop>0;i(u)};const c=r.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[r.viewport,r.isPositioned]),o?d.jsx(Om,{...e,ref:s,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=r;a&&c&&(a.scrollTop=a.scrollTop-c.offsetHeight)}}):null});Pm.displayName=sc;var ac="SelectScrollDownButton",Im=b.forwardRef((e,t)=>{const r=Bn(ac,e.__scopeSelect),n=oc(ac,e.__scopeSelect),[o,i]=b.useState(!1),s=qe(t,n.onScrollButtonChange);return tr(()=>{if(r.viewport&&r.isPositioned){let a=function(){const u=c.scrollHeight-c.clientHeight,f=Math.ceil(c.scrollTop)<u;i(f)};const c=r.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[r.viewport,r.isPositioned]),o?d.jsx(Om,{...e,ref:s,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=r;a&&c&&(a.scrollTop=a.scrollTop+c.offsetHeight)}}):null});Im.displayName=ac;var Om=b.forwardRef((e,t)=>{const{__scopeSelect:r,onAutoScroll:n,...o}=e,i=Bn("SelectScrollButton",r),s=b.useRef(null),a=Gs(r),c=b.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return b.useEffect(()=>()=>c(),[c]),tr(()=>{a().find(f=>f.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[a]),d.jsx($e.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:Oe(o.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(n,50))}),onPointerMove:Oe(o.onPointerMove,()=>{i.onItemLeave?.(),s.current===null&&(s.current=window.setInterval(n,50))}),onPointerLeave:Oe(o.onPointerLeave,()=>{c()})})}),xE="SelectSeparator",AE=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return d.jsx($e.div,{"aria-hidden":!0,...n,ref:t})});AE.displayName=xE;var lc="SelectArrow",CE=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=qs(r),i=Dn(lc,r),s=Bn(lc,r);return i.open&&s.position==="popper"?d.jsx(Jp,{...o,...n,ref:t}):null});CE.displayName=lc;var EE="SelectBubbleInput",Mm=b.forwardRef(({__scopeSelect:e,value:t,...r},n)=>{const o=b.useRef(null),i=qe(n,o),s=vi(t);return b.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(c,"value").set;if(s!==t&&f){const l=new Event("change",{bubbles:!0});f.call(a,t),a.dispatchEvent(l)}},[s,t]),d.jsx($e.select,{...r,style:{...Qp,...r.style},ref:i,defaultValue:t})});Mm.displayName=EE;function Lm(e){return e===""||e===void 0}function Dm(e){const t=dr(e),r=b.useRef(""),n=b.useRef(0),o=b.useCallback(s=>{const a=r.current+s;t(a),(function c(u){r.current=u,window.clearTimeout(n.current),u!==""&&(n.current=window.setTimeout(()=>c(""),1e3))})(a)},[t]),i=b.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,o,i]}function Bm(e,t,r){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,i=r?e.indexOf(r):-1;let s=kE(e,Math.max(i,0));o.length===1&&(s=s.filter(u=>u!==r));const c=s.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return c!==r?c:void 0}function kE(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var NE=fm,_E=mm,TE=gm,FE=ym,PE=bm,IE=vm,OE=Am,ME=Nm,LE=_m,DE=Fm,BE=Pm,$E=Im;function jE({...e}){return d.jsx(NE,{"data-slot":"select",...e})}function HE({className:e,...t}){return d.jsx(TE,{"data-slot":"select-value",className:V("truncate min-w-0",e),...t})}function UE({className:e,size:t="default",children:r,...n}){const o=e?.includes("w-full");return d.jsxs(_E,{"data-slot":"select-trigger","data-size":t,className:V("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] cursor-pointer disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",o&&"min-w-0",e),...n,children:[r,d.jsx(FE,{asChild:!0,children:d.jsx(ii,{className:"size-4 opacity-50"})})]})}function zE({className:e,children:t,position:r="popper",...n}){return d.jsx(PE,{children:d.jsxs(IE,{"data-slot":"select-content",className:V("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:r,...n,children:[d.jsx(VE,{}),d.jsx(OE,{className:V("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),d.jsx(WE,{})]})})}function cc({className:e,children:t,...r}){return d.jsxs(ME,{"data-slot":"select-item",className:V("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-pointer items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...r,children:[d.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:d.jsx(DE,{children:d.jsx(fs,{className:"size-4"})})}),d.jsx(LE,{className:"truncate",children:t})]})}function VE({className:e,...t}){return d.jsx(BE,{"data-slot":"select-scroll-up-button",className:V("flex cursor-default items-center justify-center py-1",e),...t,children:d.jsx(vS,{className:"size-4"})})}function WE({className:e,...t}){return d.jsx($E,{"data-slot":"select-scroll-down-button",className:V("flex cursor-default items-center justify-center py-1",e),...t,children:d.jsx(ii,{className:"size-4"})})}function jt(e,t){if(!t||t.trim()===""||e==null)return;const r=t.split(".").filter(Boolean);let n=e;for(const o of r){if(n==null)return;n=n[o]}return n}function $m(e){const t={array:[],pathPrefixToStrip:""};function r(a,c){if(a===null||typeof a!="object")return null;if(Array.isArray(a)&&a.length>0)return{array:a,fullPath:c};const u=Object.keys(a);for(const f of u){const l=a[f],p=c?`${c}.${f}`:f;if(Array.isArray(l)&&l.length>0)return{array:l,fullPath:p};if(l!==null&&typeof l=="object"){const g=r(l,p);if(g)return g}}return null}const n=r(e,"");if(!n)return t;const{array:o,fullPath:i}=n,s=i?`data.${i}.`:"";return{array:o,pathPrefixToStrip:s}}function RE(e){return e.length>=4&&Array.isArray(e[3])&&e[3].length===0}function KE(e,t,r){if(typeof e=="string"||typeof e=="number"||typeof e=="boolean"){const i=String(e);return{label:i,value:i,disabled:!1}}if(e==null)return{label:"",value:"",disabled:!0};if(typeof e!="object"||Array.isArray(e)){const i=Array.isArray(e)?"":String(e);return{label:i,value:i,disabled:!1}}let n,o;if(t){const i=t.includes(".")?jt(e,t):e[t];n=String(i!==void 0?i:e.label??e.name??e.title??e.text??e.username??e.email??e.value??e.id??"")}else n=String(e.label??e.name??e.title??e.text??e.username??e.email??e.value??e.id??"");if(r){const i=r.includes(".")?jt(e,r):e[r];o=String(i!==void 0?i:e.value??e.id??e.key??e.email??e.username??e.label??e.name??"")}else o=String(e.value??e.id??e.key??e.email??e.username??e.label??e.name??"");return{label:String(n??""),value:String(o??""),disabled:!!e.disabled}}function Si(e,t,r){if(!e)return[];if(Array.isArray(e)){if(e.length===0)return[];if(RE(e))return[];const n=e.filter(o=>o!=null);return n.length===0?[]:n.every(o=>typeof o=="string")?n.map(o=>({label:o,value:o,disabled:!1})):n.map(o=>KE(o,t,r))}if(typeof e=="object"){const{array:n,pathPrefixToStrip:o}=$m(e);if(Array.isArray(n)&&n.length>0){const i=c=>!c||!c.trim()||!o?c:c.startsWith(o)?c.substring(o.length).replace(/^\.+/,"")||void 0:c,s=i(t),a=i(r);return Si(n,s,a)}}return[]}function GE(e){return!Array.isArray(e)||e.length===0?[]:e.filter(t=>t!=null).map((t,r)=>{if(typeof t=="string")return{label:t,value:t};if(typeof t=="object"&&t!==null){const n=t.label||t.value||String(t),o=t.value||t.label||String(t);return!n&&!o?{label:`Option ${r+1}`,value:String(r)}:{label:String(n),value:String(o),disabled:t.disabled||!1}}return{label:String(t),value:String(t)}})}function qE(e){return Array.isArray(e)&&e.length>=4&&Array.isArray(e[3])&&e[3].length>0&&Array.isArray(e[3][0])}function YE(e,t,r){if(!e)return[];try{const o=new URL(e).searchParams.get(t);return o?o.split(r).map(i=>i.trim()).filter(Boolean):[]}catch{const n=e.indexOf("?");if(n<0)return[];const o=e.slice(n+1);try{const s=new URLSearchParams(o).get(t);return s?s.split(r).map(a=>a.trim()).filter(Boolean):[]}catch{return[]}}}function jm(e){const{response:t,sourceUrl:r,rowsIndex:n,rowsPath:o,columns:i,columnsQueryParam:s="sf",columnsQueryParamSeparator:a=","}=e;let c;if(o&&o.trim()?c=jt(t,o):typeof n=="number"?c=t?.[n]:c=t,!Array.isArray(c)||c.length===0)return[];const u=c.filter(p=>Array.isArray(p));if(u.length===0)return Array.isArray(c[0])?[]:null;if(!Array.isArray(u[0]))return null;const f=YE(r,s,a),l=f.length>0?f:Array.isArray(i)&&i.length>0?i:[];return u.map(p=>{const g={};return(l.length>0?l:Array.from({length:p.length},(h,y)=>`col${y}`)).forEach((h,y)=>{g[h]=p[y]}),g})}function XE(e){const{rows:t,apiLabelField:r,apiLabelFields:n,apiLabelSeparator:o,apiValueField:i}=e;if(!Array.isArray(t)||t.length===0)return[];const s=t.filter(l=>l!=null&&typeof l=="object"&&!Array.isArray(l));if(s.length===0)return[];const a=Array.isArray(n)?n.filter(Boolean):[],c=o??" - ",u=l=>{if(r){const p=r.includes(".")?jt(l,r):l?.[r];if(p!=null&&String(p).trim()!=="")return String(p)}return String(l?.label??l?.name??l?.title??l?.text??l?.username??l?.email??l?.value??l?.id??l)},f=(l,p)=>{if(i){const g=i.includes(".")?jt(l,i):l?.[i];if(g!=null)return String(g)}return String(l?.value??l?.id??l?.key??l?.email??l?.username??l?.label??l?.name??p??l)};return s.map(l=>{let p="";a.length>0&&(p=a.map(h=>jt(l,h)).filter(h=>h!=null&&String(h).trim()!=="").map(h=>String(h)).join(c)),p||(p=u(l));const g=f(l,p);return{label:typeof p=="string"?p:String(p??""),value:typeof g=="string"?g:String(g??""),disabled:!!l?.disabled}})}function Hm(e){return e!=null&&!Array.isArray(e)&&(typeof e=="string"||typeof e=="number"||typeof e=="boolean")}function JE(e,t){const{array:r,pathPrefixToStrip:n}=$m(e);if(!Array.isArray(r)||r.length===0)return null;const o=new Set([t]);n&&t.startsWith(n)&&o.add(t.slice(n.length).replace(/^\.+/,""));const i=t.match(/^data\.data\.(.+)$/);i?.[1]&&o.add(i[1]);const s=r[0];for(const a of o){if(!a)continue;const c=a.includes(".")?jt(s,a):s?.[a];if(Hm(c))return String(c)}return null}function QE(e,t,r){if(e==null)return null;const n=t?.trim(),o=r?.trim()||n;if(!n&&!o)return null;if(n){const s=jt(e,n);if(Hm(s))return String(s);const a=JE(e,n);if(a!=null)return a}const i=Si(e,o,n||o);if(i.length>0){const s=i[0].value;if(s!=null&&String(s).trim()!=="")return String(s)}return null}function ZE(e){if(e?.token!=null&&String(e.token).trim()!=="")return String(e.token);const t=mi(),r=t?.Authorization??t?.authorization;if(r?.trim()){const n=r.match(/^Bearer\s+(.+)$/i);return n?n[1]:r}}function Um(e,t){const r=ZE(t);if(!r)return e;let n=e.replace(/\{token\}/g,r);return n=n.replace(/\{authorization\}/gi,()=>r.startsWith("Bearer ")?r:`Bearer ${r}`),n}function Sn(e,t){const r={},{formValues:n={},submissionContext:o,apiRealtime:i}=t;for(const{key:s,value:a}of e??[]){const c=s?.trim();if(!c||a==null)continue;let u=cl(String(a),n,o,i);u=Um(u,o),r[c]=u}return r}const ek=new Set(["authorization"]);function tk(e){return ek.has(e.trim().toLowerCase())}function xi(e){return(e??[]).filter(t=>!tk(t.key))}function Ai(e){if(!e?.length)return null;const t=e.find(r=>r.key.toLowerCase()==="authorization");if(t?.value?.trim()){const r=t.value.trim();if(r.toLowerCase().startsWith("basic ")){const n=r.slice(6).trim();if(n.includes("{")||n.includes("}")){const o=n.split(":");if(o.length>=2)return{type:"basic",username:o[0].trim(),password:o.slice(1).join(":").trim()}}try{const o=atob(n),i=o.indexOf(":");if(i>=0)return{type:"basic",username:o.slice(0,i),password:o.slice(i+1)}}catch{return{type:"basic",username:"",password:""}}}return r.toLowerCase().startsWith("bearer ")?{type:"bearer",token:r.slice(7).trim()}:{type:"bearer",token:r}}return null}function rk(e){return!e||e.type==="none"?{type:"none"}:e.type==="bearer"?{type:"bearer",token:e.token?.trim()??""}:e.type==="apiKey"?{type:"apiKey",headerName:e.headerName?.trim()||"X-API-Key",apiKey:e.apiKey?.trim()??""}:{type:"basic",username:e.username?.trim()??"",password:e.password?.trim()??""}}function Xs(e,t){const{formValues:r={},submissionContext:n,urlParams:o={},apiRealtime:i}=t;let s=Rr(e,r,o,n);return s=Um(s,n),i!==void 0&&(s=cl(s,r,n,i)),s}function Ci(e,t={}){const r=rk(e),n={};if(r.type==="bearer"){const o=r.token??"";if(!o.trim())return n;const i=Xs(o,t).trim();return i&&(n.Authorization=i.toLowerCase().startsWith("bearer ")?i:`Bearer ${i}`),n}if(r.type==="apiKey"){const o=r.apiKey??"";return o.trim()&&(n[r.headerName||"X-API-Key"]=Xs(o,t)),n}if(r.type==="basic"){const o=r.username??"",i=r.password??"";if(!o.trim()&&!i.trim())return n;const s=Xs(o,t),a=Xs(i,t);n.Authorization=`Basic ${btoa(`${s}:${a}`)}`}return n}function nk(e,t={}){const r=e.apiAuth??Ai(e.apiHeaders)??{type:"none"},n=Ci(r,t);return Object.assign(n,Sn(xi(e.apiHeaders),t)),n}function zm({field:e,formValues:t={},submissionContext:r}){const n=e.properties,o=n?.apiEndpoint?{apiEndpoint:n.apiEndpoint,apiMethod:n.apiMethod,apiKey:n.apiKey,apiRealtime:n.apiRealtime,apiAutoDetect:n.apiAutoDetect,apiLabelField:n.apiLabelField,apiValueField:n.apiValueField,apiQueryParams:n.apiQueryParams,apiClientFilter:n.apiClientFilter,apiHeaders:n.apiHeaders,apiBodyFields:n.apiBodyFields,apiAuth:n.apiAuth,valueSource:n.valueSource,optionsSource:n.optionsSource}:null,i=e.apidata||null,s=o||i,[a,c]=w.useState([]),[u,f]=w.useState([]),[l,p]=w.useState([]),[g,m]=w.useState(!1),[h,y]=w.useState(null),S=!!(s?.apiEndpoint&&(s?.valueSource==="api"||s?.optionsSource==="api"||n?.valueSource==="api"||n?.optionsSource==="api")),v=e.options||n?.options||[],A=w.useMemo(()=>GE(Array.isArray(v)?v:[]),[v]),x=w.useMemo(()=>{const E=s?.apiEndpoint||n?.apiEndpoint||"",C=s?.apiQueryParams||n?.apiQueryParams;return mo(E,C)},[s?.apiEndpoint,n?.apiEndpoint,s?.apiQueryParams,n?.apiQueryParams]),F=w.useMemo(()=>{const E=new Set;for(const O of n?.dependentFields??[])typeof O=="string"&&O.trim()&&E.add(O.trim());const C=s?.apiClientFilter?.matchField?.trim()||n?.apiClientFilter?.matchField?.trim();return C&&E.add(C),[...E]},[n?.dependentFields,s?.apiClientFilter?.matchField,n?.apiClientFilter?.matchField]),k=w.useMemo(()=>{const E=new Set([...x,...F]);if(E.size===0)return null;const C={};return E.forEach(O=>{C[O]=t[O]}),JSON.stringify(C)},[x,F,t]),N=w.useMemo(()=>JSON.stringify(r||{}),[r]),T=w.useMemo(()=>{const E=new Set;e.name?.trim()&&E.add(e.name.trim());const C=e.key;return typeof C=="string"&&C.trim()&&E.add(C.trim()),[...E]},[e.name,e.key]);return w.useEffect(()=>{const E=s?.apiEndpoint;if(!S||!E){c([]);return}let C=!1;return(async()=>{a.length===0&&m(!0),y(null);try{const M=s?.apiMethod||n?.apiMethod||"GET",U=s?.apiRealtime||n?.apiRealtime,z=s?.apiQueryParams||n?.apiQueryParams||{},X=ss({apiEndpoint:E,apiMethod:M,apiQueryParams:z,formValues:t,submissionContext:r,apiRealtime:U,additionalRequiredFieldNames:F,excludeFormFieldNames:T});if(X.blocked){C||(c([]),m(!1));return}const B={"Content-Type":"application/json"},L=s?.apiKey||n?.apiKey;L&&(B["X-CSCAPI-KEY"]=L);const D=s?.apiAuth??n?.apiAuth??i?.apiAuth??Ai(s?.apiHeaders??n?.apiHeaders??i?.apiHeaders)??{type:"none"},K=Ci(D,{formValues:t,submissionContext:r,apiRealtime:U});Object.assign(B,K);const le=s?.apiHeaders??n?.apiHeaders??i?.apiHeaders,j=s?.apiBodyFields??n?.apiBodyFields??i?.apiBodyFields,H=Sn(xi(le),{formValues:t,submissionContext:r,apiRealtime:U});Object.assign(B,H);const ce=Sn(j,{formValues:t,submissionContext:r,apiRealtime:U}),ie={method:M.toLowerCase(),url:Mr(X.url),headers:B};(X.postBodyBase!=null||Object.keys(ce).length>0)&&(ie.data={...X.postBodyBase??{},...ce});const G=await At(ie),ee=s?.apiLabelField||n?.apiLabelField,Ae=s?.apiValueField||n?.apiValueField,te=G.data;let oe=[];Array.isArray(te)?oe=te:te?.data&&(Array.isArray(te.data)?oe=te.data:te.data?.data&&Array.isArray(te.data.data)?oe=te.data.data:te.data.districts?oe=te.data.districts:te.data.states?oe=te.data.states:te.data.cities&&(oe=te.data.cities)),p(oe);const me=Si(G.data,ee,Ae);f(me);const Me=s?.apiClientFilter||n?.apiClientFilter;let De=me;if(Me?.filterField&&Me?.matchField){const ne=t[Me.matchField];ne!=null?De=me.filter(ge=>{const Se=oe.find(kt=>String(jt(kt,Ae||"code"))===String(ge.value));if(!Se)return!1;const yt=jt(Se,Me.filterField);return String(yt)===String(ne)}):De=[]}C||c(De)}catch(M){if(C)return;let U="Failed to load options";if(M.response){const z=M.response.data;M.response.status===404?U="API endpoint not found.":M.response.status===401?U="Authentication failed.":typeof z=="string"?U=z:z&&typeof z=="object"&&(U=z.error||z.message||z.detail||U)}else M.message&&(U=String(M.message));y(U),a.length===0&&c([])}finally{C||m(!1)}})(),()=>{C=!0}},[S,s?.apiEndpoint,s?.apiMethod,n?.apiEndpoint,n?.apiMethod,k,F,T,N]),w.useEffect(()=>{const E=s?.apiClientFilter||n?.apiClientFilter;if(!S||!E||l.length===0)return;const C=t[E.matchField],O=s?.apiValueField||n?.apiValueField;if(C==null){c([]);return}const W=u.filter(M=>{const U=l.find(X=>String(jt(X,O||"code"))===String(M.value));if(!U)return!1;const z=jt(U,E.filterField);return String(z)===String(C)});c(W)},[S,s?.apiClientFilter?.matchField,n?.apiClientFilter?.matchField,s?.apiClientFilter?.filterField,n?.apiClientFilter?.filterField,s?.apiValueField,n?.apiValueField,t[s?.apiClientFilter?.matchField||n?.apiClientFilter?.matchField||""],u,l]),{options:S?a:A,isLoadingOptions:g,optionsError:h}}const Vm=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a,formValues:c={},submissionContext:u,excludedOptionValues:f,isPrepopulateTarget:l=!1})=>{const p=e.properties,g=p?.apiEndpoint?{apiEndpoint:p.apiEndpoint,valueSource:p.valueSource,optionsSource:p.optionsSource}:null,m=e.apidata||null,h=g||m,y=!!(h?.apiEndpoint&&(h?.valueSource==="api"||h?.optionsSource==="api"||p?.valueSource==="api"||p?.optionsSource==="api")),{options:S,isLoadingOptions:v,optionsError:A}=zm({field:e,formValues:c,submissionContext:u}),x=f?.length?new Set(f.map(String)):null,F=x?S.filter(D=>!x.has(String(D.value??D.label??""))):S,k="__clear__",N=t!=null&&String(t).trim()!=="",T=N?F.some(D=>String(D.value??D.label??"")===String(t)):!1,P=w.useMemo(()=>{if(!N||T)return F;const D=String(t);return[{label:D,value:D},...F]},[F,N,T,t]),E=N?String(t):void 0,C=`${ft(e)}-${E??"empty"}`,O=w.useCallback(D=>{r(D===k?"":D),n?.()},[r,n]),W=e.appearance?.size||"md",M={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},U=e.placeholder||"Select an option",z=p?.apiClientFilter?.matchField?.trim()||h?.apiClientFilter?.matchField?.trim(),X=y&&z&&(c[z]===void 0||c[z]===null||c[z]===""),B=v?"Loading options...":X?`Select ${z} first`:f?.length?"No available options":y?"No options available from API":"No options available";return y&&l&&v?d.jsx(Ct,{field:e,error:o||A||void 0,isRequired:s,className:a,children:d.jsxs("div",{role:"status","aria-label":"Loading options",className:V("flex items-center justify-center gap-2 w-full min-w-0 rounded-md border border-input bg-muted/50 text-muted-foreground",M[W],e.appearance?.className),children:[d.jsx(ho,{className:"h-4 w-4 animate-spin shrink-0"}),d.jsx("span",{className:"truncate",children:"Loading..."})]})}):d.jsx(Ct,{field:e,error:o||A||void 0,isRequired:s,className:a,children:d.jsxs(jE,{value:E,onValueChange:O,disabled:i||e.disabled||v&&F.length===0,children:[d.jsx(UE,{id:ft(e),"aria-describedby":Lt(e,!!o||!!A),"aria-invalid":Jt(!!o||!!A),"aria-required":s,className:V("w-full min-w-0",M[W],o&&"border-destructive focus-visible:ring-destructive",A&&"border-destructive focus-visible:ring-destructive",e.appearance?.className),children:d.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[v&&d.jsx(ho,{className:"h-4 w-4 animate-spin text-muted-foreground shrink-0"}),F.length===0&&f?.length&&!N?d.jsx("span",{className:"text-muted-foreground truncate",children:"No available options"}):N?d.jsx(HE,{placeholder:U}):d.jsx("span",{className:"text-muted-foreground truncate",children:U})]})}),d.jsx(zE,{children:P.length===0?d.jsx(cc,{value:"__no_options__",disabled:!0,children:B}):d.jsxs(d.Fragment,{children:[N?d.jsx(cc,{value:k,children:U}):null,P.map((D,K)=>{const le=String(D.value??D.label??K);if(le===k)return null;const j=D.label||D.value||String(D);return d.jsx(cc,{value:le,disabled:D.disabled||!1,children:j},le)})]})})]},C)})},Wm=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Rm=Ud,Km=(e,t)=>r=>{var n;if(t?.variants==null)return Rm(e,r?.class,r?.className);const{variants:o,defaultVariants:i}=t,s=Object.keys(o).map(u=>{const f=r?.[u],l=i?.[u];if(f===null)return null;const p=Wm(f)||Wm(l);return o[u][p]}),a=r&&Object.entries(r).reduce((u,f)=>{let[l,p]=f;return p===void 0||(u[l]=p),u},{}),c=t==null||(n=t.compoundVariants)===null||n===void 0?void 0:n.reduce((u,f)=>{let{class:l,className:p,...g}=f;return Object.entries(g).every(m=>{let[h,y]=m;return Array.isArray(y)?y.includes({...i,...a}[h]):{...i,...a}[h]===y})?[...u,l,p]:u},[]);return Rm(e,s,c,r?.class,r?.className)},ok=Km("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all cursor-pointer disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function Qt({className:e,variant:t,size:r,asChild:n=!1,...o}){const i=n?Yu:"button";return d.jsx(i,{"data-slot":"button",className:V(ok({variant:t,size:r,className:e})),...o})}function ik(e,t){return b.useReducer((r,n)=>t[r][n]??r,e)}var Cr=e=>{const{present:t,children:r}=e,n=sk(t),o=typeof r=="function"?r({present:n.isPresent}):b.Children.only(r),i=qe(n.ref,ak(o));return typeof r=="function"||n.isPresent?b.cloneElement(o,{ref:i}):null};Cr.displayName="Presence";function sk(e){const[t,r]=b.useState(),n=b.useRef(null),o=b.useRef(e),i=b.useRef("none"),s=e?"mounted":"unmounted",[a,c]=ik(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{const u=Js(n.current);i.current=a==="mounted"?u:"none"},[a]),tr(()=>{const u=n.current,f=o.current;if(f!==e){const p=i.current,g=Js(u);e?c("MOUNT"):g==="none"||u?.display==="none"?c("UNMOUNT"):c(f&&p!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),tr(()=>{if(t){let u;const f=t.ownerDocument.defaultView??window,l=g=>{const h=Js(n.current).includes(CSS.escape(g.animationName));if(g.target===t&&h&&(c("ANIMATION_END"),!o.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",u=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},p=g=>{g.target===t&&(i.current=Js(n.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",l),t.addEventListener("animationend",l),()=>{f.clearTimeout(u),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",l),t.removeEventListener("animationend",l)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:b.useCallback(u=>{n.current=u?getComputedStyle(u):null,r(u)},[])}}function Js(e){return e?.animationName||"none"}function ak(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function lk(e){const t=ck(e),r=b.forwardRef((n,o)=>{const{children:i,...s}=n,a=b.Children.toArray(i),c=a.find(uk);if(c){const u=c.props.children,f=a.map(l=>l===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:l);return d.jsx(t,{...s,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,f):null})}return d.jsx(t,{...s,ref:o,children:i})});return r.displayName=`${e}.Slot`,r}function ck(e){const t=b.forwardRef((r,n)=>{const{children:o,...i}=r;if(b.isValidElement(o)){const s=pk(o),a=fk(i,o.props);return o.type!==b.Fragment&&(a.ref=n?Yn(n,s):s),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var dk=Symbol("radix.slottable");function uk(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===dk}function fk(e,t){const r={...t};for(const n in t){const o=e[n],i=t[n];/^on[A-Z]/.test(n)?o&&i?r[n]=(...a)=>{const c=i(...a);return o(...a),c}:o&&(r[n]=o):n==="style"?r[n]={...o,...i}:n==="className"&&(r[n]=[o,i].filter(Boolean).join(" "))}return{...e,...r}}function pk(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var Qs="Popover",[Gm]=Sr(Qs,[Ds]),Ei=Ds(),[mk,$n]=Gm(Qs),qm=e=>{const{__scopePopover:t,children:r,open:n,defaultOpen:o,onOpenChange:i,modal:s=!1}=e,a=Ei(t),c=b.useRef(null),[u,f]=b.useState(!1),[l,p]=ln({prop:n,defaultProp:o??!1,onChange:i,caller:Qs});return d.jsx(Yp,{...a,children:d.jsx(mk,{scope:t,contentId:yn(),triggerRef:c,open:l,onOpenChange:p,onOpenToggle:b.useCallback(()=>p(g=>!g),[p]),hasCustomAnchor:u,onCustomAnchorAdd:b.useCallback(()=>f(!0),[]),onCustomAnchorRemove:b.useCallback(()=>f(!1),[]),modal:s,children:r})})};qm.displayName=Qs;var Ym="PopoverAnchor",Xm=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=$n(Ym,r),i=Ei(r),{onCustomAnchorAdd:s,onCustomAnchorRemove:a}=o;return b.useEffect(()=>(s(),()=>a()),[s,a]),d.jsx(Xl,{...i,...n,ref:t})});Xm.displayName=Ym;var Jm="PopoverTrigger",Qm=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=$n(Jm,r),i=Ei(r),s=qe(t,o.triggerRef),a=d.jsx($e.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":nh(o.open),...n,ref:s,onClick:Oe(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:d.jsx(Xl,{asChild:!0,...i,children:a})});Qm.displayName=Jm;var dc="PopoverPortal",[hk,gk]=Gm(dc,{forceMount:void 0}),Zm=e=>{const{__scopePopover:t,forceMount:r,children:n,container:o}=e,i=$n(dc,t);return d.jsx(hk,{scope:t,forceMount:r,children:d.jsx(Cr,{present:r||i.open,children:d.jsx(Bs,{asChild:!0,container:o,children:n})})})};Zm.displayName=dc;var To="PopoverContent",eh=b.forwardRef((e,t)=>{const r=gk(To,e.__scopePopover),{forceMount:n=r.forceMount,...o}=e,i=$n(To,e.__scopePopover);return d.jsx(Cr,{present:n||i.open,children:i.modal?d.jsx(bk,{...o,ref:t}):d.jsx(vk,{...o,ref:t})})});eh.displayName=To;var yk=lk("PopoverContent.RemoveScroll"),bk=b.forwardRef((e,t)=>{const r=$n(To,e.__scopePopover),n=b.useRef(null),o=qe(t,n),i=b.useRef(!1);return b.useEffect(()=>{const s=n.current;if(s)return Ql(s)},[]),d.jsx(Rs,{as:yk,allowPinchZoom:!0,children:d.jsx(th,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Oe(e.onCloseAutoFocus,s=>{s.preventDefault(),i.current||r.triggerRef.current?.focus()}),onPointerDownOutside:Oe(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,c=a.button===0&&a.ctrlKey===!0,u=a.button===2||c;i.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:Oe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})})}),vk=b.forwardRef((e,t)=>{const r=$n(To,e.__scopePopover),n=b.useRef(!1),o=b.useRef(!1);return d.jsx(th,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(n.current||r.triggerRef.current?.focus(),i.preventDefault()),n.current=!1,o.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(n.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=i.target;r.triggerRef.current?.contains(s)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),th=b.forwardRef((e,t)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:s,onEscapeKeyDown:a,onPointerDownOutside:c,onFocusOutside:u,onInteractOutside:f,...l}=e,p=$n(To,r),g=Ei(r);return Ol(),d.jsx(Es,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:i,children:d.jsx(Cs,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:f,onEscapeKeyDown:a,onPointerDownOutside:c,onFocusOutside:u,onDismiss:()=>p.onOpenChange(!1),children:d.jsx(Xp,{"data-state":nh(p.open),role:"dialog",id:p.contentId,...g,...l,ref:t,style:{...l.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),rh="PopoverClose",wk=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=$n(rh,r);return d.jsx($e.button,{type:"button",...n,ref:t,onClick:Oe(e.onClick,()=>o.onOpenChange(!1))})});wk.displayName=rh;var Sk="PopoverArrow",xk=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=Ei(r);return d.jsx(Jp,{...o,...n,ref:t})});xk.displayName=Sk;function nh(e){return e?"open":"closed"}var Ak=qm,Ck=Xm,Ek=Qm,kk=Zm,Nk=eh;function uc({...e}){return d.jsx(Ak,{"data-slot":"popover",...e})}function oh({...e}){return d.jsx(Ek,{"data-slot":"popover-trigger",...e})}function fc({className:e,align:t="center",sideOffset:r=4,...n}){return d.jsx(kk,{children:d.jsx(Nk,{"data-slot":"popover-content",align:t,sideOffset:r,className:V("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden pointer-events-auto",e),...n})})}function _k({...e}){return d.jsx(Ck,{"data-slot":"popover-anchor",...e})}function ih(e){return JSON.stringify(e).slice(1,-1)}function sh(e){const t=e.asyncSearchValueObjectKeys;return Array.isArray(t)?t.map(r=>typeof r=="string"?r.trim():"").filter(Boolean):[]}function Tk(e){return e.asyncSearchValueMode==="object"&&sh(e).length>0}function Fk(e,t){const r={};for(const n of t){const o=n.trim();if(!o)continue;const i=jt(e,o);i==null||typeof i=="object"?r[o]="":r[o]=String(i)}return r}function Pk(e,t){const r=t.mode??"debounce",n=Math.max(0,t.intervalMs??300),[o,i]=w.useState(()=>r==="throttle"?e:""),s=w.useRef(0),a=w.useRef(void 0);return w.useEffect(()=>{if(e===""){a.current&&clearTimeout(a.current),i("");return}if(r==="debounce"){const f=setTimeout(()=>i(e),n);return()=>clearTimeout(f)}const c=Date.now(),u=c-s.current;return u>=n?(s.current=c,i(e),()=>{a.current&&clearTimeout(a.current)}):(a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{s.current=Date.now(),i(e),a.current=void 0},n-u),()=>{a.current&&clearTimeout(a.current)})},[e,r,n]),o}function pc(e,t){if(e==null||e==="")return"";if(t&&typeof e=="object"&&!Array.isArray(e)){const r=e,o=Object.keys(r).sort().map(i=>[i,r[i]??""]);return`O:${JSON.stringify(o)}`}return typeof e=="string"?`S:${e}`:""}function mc(e,t){return e==null||e===""?!0:t&&typeof e=="object"&&!Array.isArray(e)?Object.keys(e).length===0:!1}function Ik(e,t,r){return t.trim()!==""?!0:e==null||e===""?!1:r&&typeof e=="object"&&!Array.isArray(e)?Object.keys(e).length>0:typeof e=="string"&&e.length>0}function Ok(e){if(At.isAxiosError(e)){const t=e.response?.status,r=e.response?.data;if(t===404)return"Search endpoint not found.";if(t===401)return"Authentication failed.";if(r&&typeof r=="object"){const n=r,o=n.error??n.message??n.detail??n.explanation;if(typeof o=="string")return o}if(typeof r=="string")return r;if(t)return`Request failed (${t})`}return e instanceof Error?e.message:"Search failed"}function Mk(e){if(e==null)return[];if(Array.isArray(e))return e;const t=e;if(!t?.data)return[];const r=t.data;return Array.isArray(r)?r:r?.data&&Array.isArray(r.data)?r.data:Array.isArray(r?.districts)?r.districts:Array.isArray(r?.states)?r.states:Array.isArray(r?.cities)?r.cities:[]}function ah(e,t){return typeof t=="number"&&t>0?e.slice(0,t):e}function hc(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.label=="string"&&t.value!==null&&t.value!==void 0}const lh=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:c,formValues:u={},submissionContext:f})=>{const l=e.properties||{},p=Tk(l),g=l.apiEndpoint?.trim()||"",m=l.apiRealtime===!0,h=(l.apiMethod||"GET").toUpperCase()==="POST"?"POST":"GET",y=l.searchInBody===!0,S=h==="POST"||h==="GET"&&y,v=l.searchStrategy??l.searchSchedule??"debounce",A=l.searchIntervalMs??l.intervalMs??300,x=l.minQueryLength??0,F=l.maxResults,k=l.searchQueryParam||"q",N=l.clearable!==!1,T=u,[P,E]=w.useState(()=>mc(t,p)?"":p&&typeof t=="object"&&t!==null&&!Array.isArray(t)?l.initialDisplayLabel||"":l.initialDisplayLabel||String(t)),[C,O]=w.useState(!1),[W,M]=w.useState([]),[U,z]=w.useState([]),[X,B]=w.useState([]),[L,D]=w.useState(!1),[K,le]=w.useState(null),[j,H]=w.useState(-1),ce=w.useRef(pc(t,p)),ie=w.useRef(mc(t,p)?"":p&&typeof t=="object"&&t!==null&&!Array.isArray(t)?l.initialDisplayLabel||"":l.initialDisplayLabel||String(t??"")),G=w.useRef(void 0),ee=w.useRef(0),Ae=w.useRef(null),te=Pk(P,{mode:v,intervalMs:A}),oe=w.useMemo(()=>W.filter(hc),[W]);w.useEffect(()=>{if(oe.length===0){j!==-1&&H(-1);return}(j<0||j>=oe.length)&&H(0)},[j,oe.length]);const me=w.useMemo(()=>{const J=mo(g,l.apiQueryParams),$=new Set(J);for(const fe of l.dependentFields||[])fe&&$.add(fe);return $},[g,l.apiQueryParams,l.dependentFields]),Me=w.useMemo(()=>{if(me.size===0)return null;const J={};return me.forEach($=>{J[$]=T[$]}),JSON.stringify(J)},[me,T]),De=w.useMemo(()=>JSON.stringify(u),[u]),ne=w.useMemo(()=>JSON.stringify(f||{}),[f]);w.useEffect(()=>{const J=pc(t,p);if(J===ce.current)return;if(ce.current=J,mc(t,p)){ie.current="",E(""),M([]),z([]),B([]),le(null),O(!1);return}const $=l.initialDisplayLabel||(!p&&typeof t=="string"?t:"");ie.current=$,E($)},[t,l.initialDisplayLabel,p]),w.useEffect(()=>{if(!g){M([]),z([]),B([]),D(!1);return}if(s||i||e.disabled){M([]),z([]),B([]),D(!1);return}const J=te;if(J.length<x){M([]),z([]),B([]),D(!1),le(null);return}const $=ss({apiEndpoint:g,apiMethod:h,apiQueryParams:l.apiQueryParams,formValues:T,submissionContext:f,apiRealtime:m,additionalRequiredFieldNames:l.dependentFields});if($.blocked){M([]),z([]),B([]),D(!1),le(null);return}Ae.current?.abort();const fe=new AbortController;Ae.current=fe;const ze=++ee.current;return(async()=>{D(!0),le(null);const He=Mr($.url),st={};S&&(st["Content-Type"]="application/json"),l.apiKey&&(st["X-CSCAPI-KEY"]=l.apiKey);const ht=l.apiAuth??Ai(l.apiHeaders)??{type:"none"},lt=Ci(ht,{formValues:T,submissionContext:f,apiRealtime:m});Object.assign(st,lt);const ct=Sn(xi(l.apiHeaders),{formValues:T,submissionContext:f,apiRealtime:m});Object.assign(st,ct);const nt=Sn(l.apiBodyFields,{formValues:T,submissionContext:f,apiRealtime:m});try{let ot;if(!S)ot=(await qt.get(He,{params:{[k]:J},signal:fe.signal,headers:Object.keys(st).length?st:void 0})).data;else{let Bt={};$.postBodyBase&&Object.keys($.postBodyBase).length>0?Bt={...$.postBodyBase}:m&&Object.keys(T).length>0&&(Bt={...T}),Bt={...Bt,...nt};let Vt=Bt;if(l.searchBodyTemplate?.trim()){let Jr=l.searchBodyTemplate.replace(/\{\{query\}\}/g,()=>ih(J)).replace(/\{query\}/g,()=>ih(J));Jr=cl(Jr,T,f,m);const Yt=JSON.parse(Jr);Vt={...Bt,...Yt}}else Vt={...Bt,[k]:J};ot=(await qt.post(He,Vt,{signal:fe.signal,headers:Object.keys(st).length?st:void 0})).data}if(ze!==ee.current)return;const ar=l.apiResultsFormat,vt=l.apiResultsConfig,er=ar==="clinicaltables_v3",Je=qE(ot),Ye=er||ar===void 0&&Je,nr=ar==="tuple_array";let br=null;Ye?br=jm({response:ot,sourceUrl:He,rowsIndex:vt?.rowsIndex??3,rowsPath:vt?.rowsPath,columns:vt?.columns,columnsQueryParam:vt?.columnsQueryParam??"sf",columnsQueryParamSeparator:vt?.columnsQueryParamSeparator??","}):nr&&(br=jm({response:ot,sourceUrl:He,rowsIndex:vt?.rowsIndex,rowsPath:vt?.rowsPath,columns:vt?.columns,columnsQueryParam:vt?.columnsQueryParam,columnsQueryParamSeparator:vt?.columnsQueryParamSeparator}));const vr=Mk(ot),Nt=br!==null,kr=br&&Array.isArray(br)?br:Array.isArray(vr)&&vr.every(Bt=>Bt&&typeof Bt=="object"&&!Array.isArray(Bt))?vr:null;B(kr??vr);const lr=Array.isArray(l.apiLabelFields)&&l.apiLabelFields.length>0,An=kr&&(Nt||lr)?XE({rows:kr,apiLabelField:l.apiLabelField,apiLabelFields:l.apiLabelFields,apiLabelSeparator:l.apiLabelSeparator,apiValueField:l.apiValueField}):Si(ot,l.apiLabelField,l.apiValueField);z(An);const fn=l.apiClientFilter;let $r=An;if(fn?.filterField&&fn?.matchField){const Bt=T[fn.matchField];if(Bt!=null){const Vt=l.apiValueField;$r=An.filter(wr=>{const Yt=(kr??vr).find(zn=>String(jt(zn,Vt||"code"))===String(wr.value));if(!Yt)return!1;const cr=jt(Yt,fn.filterField);return String(cr)===String(Bt)})}else $r=[]}const Un=ah($r,F).filter(hc);M(Un),H(Un.length>0?0:-1)}catch(ot){if(At.isCancel(ot)||ot?.code==="ERR_CANCELED"||ze!==ee.current)return;M([]),z([]),B([]),le(Ok(ot)),H(-1)}finally{ze===ee.current&&D(!1)}})(),()=>{fe.abort()}},[te,g,h,y,S,k,x,F,l.apiKey,l.searchBodyTemplate,l.apiLabelField,l.apiLabelFields,l.apiLabelSeparator,l.apiValueField,l.apiQueryParams,l.apiClientFilter,l.apiResultsFormat,l.apiResultsConfig,l.dependentFields,m,T,f,s,i,e.disabled,Me,De,ne]),w.useEffect(()=>{const J=l.apiClientFilter;if(!J||X.length===0||U.length===0)return;const $=T[J.matchField],fe=l.apiValueField;if($==null){M([]);return}const ze=U.filter(He=>{const st=X.find(lt=>String(jt(lt,fe||"code"))===String(He.value));if(!st)return!1;const ht=jt(st,J.filterField);return String(ht)===String($)}),Fe=ah(ze,F).filter(hc);M(Fe),H(Fe.length>0?0:-1)},[l.apiClientFilter,l.apiValueField,T,F,U,X]);const ge=i||e.disabled,Se=s||e.readOnly,yt=w.useCallback(J=>{const $=J.target.value;Se||ge||(ce.current&&ie.current&&$!==ie.current&&(ce.current="",ie.current="",r(p?null:"")),E($),O(!0),H(-1))},[ge,Se,p,r]),kt=w.useCallback(J=>{const $=typeof J?.label=="string"?J.label:String(J?.value??""),fe=l.apiValueField||"code";if(p){const ze=sh(l),Fe=X.find(He=>String(jt(He,fe))===String(J.value));if(Fe&&typeof Fe=="object"&&!Array.isArray(Fe)&&ze.length>0){const He=Fk(Fe,ze);ce.current=pc(He,!0),ie.current=$,r(He),E($)}else ce.current=`S:${String(J.value)}`,ie.current=$,r(String(J.value)),E($)}else ce.current=`S:${String(J.value)}`,ie.current=$,r(String(J.value)),E($);G.current&&clearTimeout(G.current),O(!1),H(-1),n?.()},[p,n,r,l,X]),Ut=w.useCallback(J=>{J.preventDefault(),J.stopPropagation(),!(ge||Se)&&(ce.current="",ie.current="",r(p?null:""),E(""),M([]),z([]),B([]),le(null),O(!1),n?.())},[ge,Se,p,r,n]),It=w.useMemo(()=>C&&!Se&&(L||!!K||oe.length>0||te.length>=x&&!L),[C,Se,L,K,oe.length,te,x]),Er=w.useCallback(J=>{if(!(Se||ge))if(J.key==="ArrowDown")J.preventDefault(),O(!0),H($=>oe.length===0?-1:($+1)%oe.length);else if(J.key==="ArrowUp")J.preventDefault(),O(!0),H($=>oe.length===0?-1:$<=0?oe.length-1:$-1);else if(J.key==="Enter"){const $=j>=0?oe[j]:void 0;It&&$&&!$.disabled&&(J.preventDefault(),kt($))}else J.key==="Escape"&&O(!1)},[ge,Se,j,It,oe,kt]),Dt=e.appearance?.size||"md",sr={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},zt=ft(e),he=Lt(e,!!(o||K)),we=te.length>=x&&!L&&!K&&oe.length===0;return d.jsx(Ct,{field:e,error:o||K||void 0,isRequired:a,className:c,children:d.jsxs(uc,{open:It,onOpenChange:J=>{J||O(!1)},children:[d.jsx(_k,{asChild:!0,children:d.jsxs("div",{className:"relative flex w-full min-w-0 items-center gap-1",children:[d.jsx(gn,{id:zt,role:"combobox","aria-expanded":It,"aria-autocomplete":"list","aria-controls":It?`${zt}-listbox`:void 0,"aria-activedescendant":j>=0?`${zt}-opt-${j}`:void 0,value:P,onChange:yt,onKeyDown:Er,onFocus:()=>{G.current&&clearTimeout(G.current),!Se&&!ge&&O(!0)},onBlur:()=>{G.current=setTimeout(()=>{O(!1),n?.()},150)},placeholder:e.placeholder||"Search…",disabled:ge,readOnly:Se,"aria-describedby":he,"aria-invalid":Jt(!!(o||K)),"aria-required":a,className:V("pr-20",sr[Dt],(o||K)&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)}),d.jsxs("div",{className:"pointer-events-none absolute right-1 top-1/2 flex -translate-y-1/2 items-center gap-0.5",children:[L&&d.jsx(ho,{className:"pointer-events-none h-4 w-4 animate-spin text-muted-foreground"}),N&&Ik(t,P,p)&&!ge&&!Se&&d.jsx(Qt,{type:"button",variant:"ghost",size:"icon",className:"pointer-events-auto h-8 w-8 shrink-0",onMouseDown:J=>J.preventDefault(),onClick:Ut,"aria-label":"Clear",children:d.jsx(ai,{className:"h-4 w-4"})})]})]})}),d.jsx(fc,{className:"p-0 w-[var(--radix-popover-trigger-width)] min-w-[12rem] overflow-hidden",align:"start",onOpenAutoFocus:J=>J.preventDefault(),onCloseAutoFocus:J=>J.preventDefault(),children:d.jsx("div",{id:`${zt}-listbox`,role:"listbox",children:K?d.jsx("div",{className:"px-3 py-2 text-sm text-destructive",children:K}):L?d.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-sm text-muted-foreground",children:[d.jsx(ho,{className:"h-4 w-4 animate-spin shrink-0"}),"Loading…"]}):we?d.jsx("ul",{className:"py-1","aria-label":"Search results",children:d.jsx("li",{role:"option","aria-disabled":!0,className:"cursor-default select-none px-3 py-2 text-sm text-muted-foreground",onMouseDown:J=>J.preventDefault(),children:"No results found"})}):d.jsx("ul",{className:"max-h-60 overflow-y-auto overscroll-contain py-1","aria-label":"Search results",children:oe.map((J,$)=>d.jsx("li",{id:`${zt}-opt-${$}`,role:"option","aria-selected":j===$,className:V(J.disabled?"cursor-not-allowed opacity-60":"cursor-pointer","px-3 py-2 text-sm",j===$&&"bg-accent text-accent-foreground"),onMouseEnter:()=>H($),onMouseDown:fe=>fe.preventDefault(),onClick:()=>{J.disabled||kt(J)},children:J.label},`${J.value}-${$}`))})})})]})})};var Zs="Checkbox",[Lk]=Sr(Zs),[Dk,gc]=Lk(Zs);function Bk(e){const{__scopeCheckbox:t,checked:r,children:n,defaultChecked:o,disabled:i,form:s,name:a,onCheckedChange:c,required:u,value:f="on",internal_do_not_use_render:l}=e,[p,g]=ln({prop:r,defaultProp:o??!1,onChange:c,caller:Zs}),[m,h]=b.useState(null),[y,S]=b.useState(null),v=b.useRef(!1),A=m?!!s||!!m.closest("form"):!0,x={checked:p,disabled:i,setChecked:g,control:m,setControl:h,name:a,form:s,value:f,hasConsumerStoppedPropagationRef:v,required:u,defaultChecked:jn(o)?!1:o,isFormControl:A,bubbleInput:y,setBubbleInput:S};return d.jsx(Dk,{scope:t,...x,children:$k(l)?l(x):n})}var ch="CheckboxTrigger",dh=b.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:r,...n},o)=>{const{control:i,value:s,disabled:a,checked:c,required:u,setControl:f,setChecked:l,hasConsumerStoppedPropagationRef:p,isFormControl:g,bubbleInput:m}=gc(ch,e),h=qe(o,f),y=b.useRef(c);return b.useEffect(()=>{const S=i?.form;if(S){const v=()=>l(y.current);return S.addEventListener("reset",v),()=>S.removeEventListener("reset",v)}},[i,l]),d.jsx($e.button,{type:"button",role:"checkbox","aria-checked":jn(c)?"mixed":c,"aria-required":u,"data-state":gh(c),"data-disabled":a?"":void 0,disabled:a,value:s,...n,ref:h,onKeyDown:Oe(t,S=>{S.key==="Enter"&&S.preventDefault()}),onClick:Oe(r,S=>{l(v=>jn(v)?!0:!v),m&&g&&(p.current=S.isPropagationStopped(),p.current||S.stopPropagation())})})});dh.displayName=ch;var uh=b.forwardRef((e,t)=>{const{__scopeCheckbox:r,name:n,checked:o,defaultChecked:i,required:s,disabled:a,value:c,onCheckedChange:u,form:f,...l}=e;return d.jsx(Bk,{__scopeCheckbox:r,checked:o,defaultChecked:i,disabled:a,required:s,onCheckedChange:u,name:n,form:f,value:c,internal_do_not_use_render:({isFormControl:p})=>d.jsxs(d.Fragment,{children:[d.jsx(dh,{...l,ref:t,__scopeCheckbox:r}),p&&d.jsx(hh,{__scopeCheckbox:r})]})})});uh.displayName=Zs;var fh="CheckboxIndicator",ph=b.forwardRef((e,t)=>{const{__scopeCheckbox:r,forceMount:n,...o}=e,i=gc(fh,r);return d.jsx(Cr,{present:n||jn(i.checked)||i.checked===!0,children:d.jsx($e.span,{"data-state":gh(i.checked),"data-disabled":i.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});ph.displayName=fh;var mh="CheckboxBubbleInput",hh=b.forwardRef(({__scopeCheckbox:e,...t},r)=>{const{control:n,hasConsumerStoppedPropagationRef:o,checked:i,defaultChecked:s,required:a,disabled:c,name:u,value:f,form:l,bubbleInput:p,setBubbleInput:g}=gc(mh,e),m=qe(r,g),h=vi(i),y=bi(n);b.useEffect(()=>{const v=p;if(!v)return;const A=window.HTMLInputElement.prototype,F=Object.getOwnPropertyDescriptor(A,"checked").set,k=!o.current;if(h!==i&&F){const N=new Event("click",{bubbles:k});v.indeterminate=jn(i),F.call(v,jn(i)?!1:i),v.dispatchEvent(N)}},[p,h,i,o]);const S=b.useRef(jn(i)?!1:i);return d.jsx($e.input,{type:"checkbox","aria-hidden":!0,defaultChecked:s??S.current,required:a,disabled:c,name:u,value:f,form:l,...t,tabIndex:-1,ref:m,style:{...t.style,...y,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});hh.displayName=mh;function $k(e){return typeof e=="function"}function jn(e){return e==="indeterminate"}function gh(e){return jn(e)?"indeterminate":e?"checked":"unchecked"}function ea({className:e,...t}){return d.jsx(uh,{"data-slot":"checkbox",className:V("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:d.jsx(ph,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:d.jsx(fs,{className:"size-3.5"})})})}const jk=Km("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-destructive-foreground [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",warning:"border-transparent bg-orange-500 text-white [a&]:hover:bg-orange-600 focus-visible:ring-orange-500/20",success:"border-transparent bg-green-500 text-white [a&]:hover:bg-green-600 focus-visible:ring-green-500/20",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function Hk({className:e,variant:t,asChild:r=!1,...n}){const o=r?Yu:"span";return d.jsx(o,{"data-slot":"badge",className:V(jk({variant:t}),e),...n})}function Uk(e,t){return b.useReducer((r,n)=>t[r][n]??r,e)}var yc="ScrollArea",[yh]=Sr(yc),[zk,Lr]=yh(yc),bh=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,type:n="hover",dir:o,scrollHideDelay:i=600,...s}=e,[a,c]=b.useState(null),[u,f]=b.useState(null),[l,p]=b.useState(null),[g,m]=b.useState(null),[h,y]=b.useState(null),[S,v]=b.useState(0),[A,x]=b.useState(0),[F,k]=b.useState(!1),[N,T]=b.useState(!1),P=qe(t,C=>c(C)),E=vo(o);return d.jsx(zk,{scope:r,type:n,dir:E,scrollHideDelay:i,scrollArea:a,viewport:u,onViewportChange:f,content:l,onContentChange:p,scrollbarX:g,onScrollbarXChange:m,scrollbarXEnabled:F,onScrollbarXEnabledChange:k,scrollbarY:h,onScrollbarYChange:y,scrollbarYEnabled:N,onScrollbarYEnabledChange:T,onCornerWidthChange:v,onCornerHeightChange:x,children:d.jsx($e.div,{dir:E,...s,ref:P,style:{position:"relative","--radix-scroll-area-corner-width":S+"px","--radix-scroll-area-corner-height":A+"px",...e.style}})})});bh.displayName=yc;var vh="ScrollAreaViewport",wh=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,children:n,nonce:o,...i}=e,s=Lr(vh,r),a=b.useRef(null),c=qe(t,a,s.onViewportChange);return d.jsxs(d.Fragment,{children:[d.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),d.jsx($e.div,{"data-radix-scroll-area-viewport":"",...i,ref:c,style:{overflowX:s.scrollbarXEnabled?"scroll":"hidden",overflowY:s.scrollbarYEnabled?"scroll":"hidden",...e.style},children:d.jsx("div",{ref:s.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});wh.displayName=vh;var dn="ScrollAreaScrollbar",Sh=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Lr(dn,e.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:s}=o,a=e.orientation==="horizontal";return b.useEffect(()=>(a?i(!0):s(!0),()=>{a?i(!1):s(!1)}),[a,i,s]),o.type==="hover"?d.jsx(Vk,{...n,ref:t,forceMount:r}):o.type==="scroll"?d.jsx(Wk,{...n,ref:t,forceMount:r}):o.type==="auto"?d.jsx(xh,{...n,ref:t,forceMount:r}):o.type==="always"?d.jsx(bc,{...n,ref:t}):null});Sh.displayName=dn;var Vk=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Lr(dn,e.__scopeScrollArea),[i,s]=b.useState(!1);return b.useEffect(()=>{const a=o.scrollArea;let c=0;if(a){const u=()=>{window.clearTimeout(c),s(!0)},f=()=>{c=window.setTimeout(()=>s(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",f),()=>{window.clearTimeout(c),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",f)}}},[o.scrollArea,o.scrollHideDelay]),d.jsx(Cr,{present:r||i,children:d.jsx(xh,{"data-state":i?"visible":"hidden",...n,ref:t})})}),Wk=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Lr(dn,e.__scopeScrollArea),i=e.orientation==="horizontal",s=oa(()=>c("SCROLL_END"),100),[a,c]=Uk("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return b.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>c("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,c]),b.useEffect(()=>{const u=o.viewport,f=i?"scrollLeft":"scrollTop";if(u){let l=u[f];const p=()=>{const g=u[f];l!==g&&(c("SCROLL"),s()),l=g};return u.addEventListener("scroll",p),()=>u.removeEventListener("scroll",p)}},[o.viewport,i,c,s]),d.jsx(Cr,{present:r||a!=="hidden",children:d.jsx(bc,{"data-state":a==="hidden"?"hidden":"visible",...n,ref:t,onPointerEnter:Oe(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:Oe(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),xh=b.forwardRef((e,t)=>{const r=Lr(dn,e.__scopeScrollArea),{forceMount:n,...o}=e,[i,s]=b.useState(!1),a=e.orientation==="horizontal",c=oa(()=>{if(r.viewport){const u=r.viewport.offsetWidth<r.viewport.scrollWidth,f=r.viewport.offsetHeight<r.viewport.scrollHeight;s(a?u:f)}},10);return Fo(r.viewport,c),Fo(r.content,c),d.jsx(Cr,{present:n||i,children:d.jsx(bc,{"data-state":i?"visible":"hidden",...o,ref:t})})}),bc=b.forwardRef((e,t)=>{const{orientation:r="vertical",...n}=e,o=Lr(dn,e.__scopeScrollArea),i=b.useRef(null),s=b.useRef(0),[a,c]=b.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=Nh(a.viewport,a.content),f={...n,sizes:a,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:p=>i.current=p,onThumbPointerUp:()=>s.current=0,onThumbPointerDown:p=>s.current=p};function l(p,g){return Xk(p,s.current,a,g)}return r==="horizontal"?d.jsx(Rk,{...f,ref:t,onThumbPositionChange:()=>{if(o.viewport&&i.current){const p=o.viewport.scrollLeft,g=_h(p,a,o.dir);i.current.style.transform=`translate3d(${g}px, 0, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollLeft=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollLeft=l(p,o.dir))}}):r==="vertical"?d.jsx(Kk,{...f,ref:t,onThumbPositionChange:()=>{if(o.viewport&&i.current){const p=o.viewport.scrollTop,g=_h(p,a);i.current.style.transform=`translate3d(0, ${g}px, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollTop=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollTop=l(p))}}):null}),Rk=b.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...o}=e,i=Lr(dn,e.__scopeScrollArea),[s,a]=b.useState(),c=b.useRef(null),u=qe(t,c,i.onScrollbarXChange);return b.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),d.jsx(Ch,{"data-orientation":"horizontal",...o,ref:u,sizes:r,style:{bottom:0,left:i.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:i.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":na(r)+"px",...e.style},onThumbPointerDown:f=>e.onThumbPointerDown(f.x),onDragScroll:f=>e.onDragScroll(f.x),onWheelScroll:(f,l)=>{if(i.viewport){const p=i.viewport.scrollLeft+f.deltaX;e.onWheelScroll(p),Fh(p,l)&&f.preventDefault()}},onResize:()=>{c.current&&i.viewport&&s&&n({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:ra(s.paddingLeft),paddingEnd:ra(s.paddingRight)}})}})}),Kk=b.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...o}=e,i=Lr(dn,e.__scopeScrollArea),[s,a]=b.useState(),c=b.useRef(null),u=qe(t,c,i.onScrollbarYChange);return b.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),d.jsx(Ch,{"data-orientation":"vertical",...o,ref:u,sizes:r,style:{top:0,right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":na(r)+"px",...e.style},onThumbPointerDown:f=>e.onThumbPointerDown(f.y),onDragScroll:f=>e.onDragScroll(f.y),onWheelScroll:(f,l)=>{if(i.viewport){const p=i.viewport.scrollTop+f.deltaY;e.onWheelScroll(p),Fh(p,l)&&f.preventDefault()}},onResize:()=>{c.current&&i.viewport&&s&&n({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:ra(s.paddingTop),paddingEnd:ra(s.paddingBottom)}})}})}),[Gk,Ah]=yh(dn),Ch=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:o,onThumbChange:i,onThumbPointerUp:s,onThumbPointerDown:a,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:f,onResize:l,...p}=e,g=Lr(dn,r),[m,h]=b.useState(null),y=qe(t,P=>h(P)),S=b.useRef(null),v=b.useRef(""),A=g.viewport,x=n.content-n.viewport,F=dr(f),k=dr(c),N=oa(l,10);function T(P){if(S.current){const E=P.clientX-S.current.left,C=P.clientY-S.current.top;u({x:E,y:C})}}return b.useEffect(()=>{const P=E=>{const C=E.target;m?.contains(C)&&F(E,x)};return document.addEventListener("wheel",P,{passive:!1}),()=>document.removeEventListener("wheel",P,{passive:!1})},[A,m,x,F]),b.useEffect(k,[n,k]),Fo(m,N),Fo(g.content,N),d.jsx(Gk,{scope:r,scrollbar:m,hasThumb:o,onThumbChange:dr(i),onThumbPointerUp:dr(s),onThumbPositionChange:k,onThumbPointerDown:dr(a),children:d.jsx($e.div,{...p,ref:y,style:{position:"absolute",...p.style},onPointerDown:Oe(e.onPointerDown,P=>{P.button===0&&(P.target.setPointerCapture(P.pointerId),S.current=m.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",g.viewport&&(g.viewport.style.scrollBehavior="auto"),T(P))}),onPointerMove:Oe(e.onPointerMove,T),onPointerUp:Oe(e.onPointerUp,P=>{const E=P.target;E.hasPointerCapture(P.pointerId)&&E.releasePointerCapture(P.pointerId),document.body.style.webkitUserSelect=v.current,g.viewport&&(g.viewport.style.scrollBehavior=""),S.current=null})})})}),ta="ScrollAreaThumb",Eh=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Ah(ta,e.__scopeScrollArea);return d.jsx(Cr,{present:r||o.hasThumb,children:d.jsx(qk,{ref:t,...n})})}),qk=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,style:n,...o}=e,i=Lr(ta,r),s=Ah(ta,r),{onThumbPositionChange:a}=s,c=qe(t,l=>s.onThumbChange(l)),u=b.useRef(void 0),f=oa(()=>{u.current&&(u.current(),u.current=void 0)},100);return b.useEffect(()=>{const l=i.viewport;if(l){const p=()=>{if(f(),!u.current){const g=Jk(l,a);u.current=g,a()}};return a(),l.addEventListener("scroll",p),()=>l.removeEventListener("scroll",p)}},[i.viewport,f,a]),d.jsx($e.div,{"data-state":s.hasThumb?"visible":"hidden",...o,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:Oe(e.onPointerDownCapture,l=>{const g=l.target.getBoundingClientRect(),m=l.clientX-g.left,h=l.clientY-g.top;s.onThumbPointerDown({x:m,y:h})}),onPointerUp:Oe(e.onPointerUp,s.onThumbPointerUp)})});Eh.displayName=ta;var vc="ScrollAreaCorner",kh=b.forwardRef((e,t)=>{const r=Lr(vc,e.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?d.jsx(Yk,{...e,ref:t}):null});kh.displayName=vc;var Yk=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,...n}=e,o=Lr(vc,r),[i,s]=b.useState(0),[a,c]=b.useState(0),u=!!(i&&a);return Fo(o.scrollbarX,()=>{const f=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(f),c(f)}),Fo(o.scrollbarY,()=>{const f=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(f),s(f)}),u?d.jsx($e.div,{...n,ref:t,style:{width:i,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function ra(e){return e?parseInt(e,10):0}function Nh(e,t){const r=e/t;return isNaN(r)?0:r}function na(e){const t=Nh(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,n=(e.scrollbar.size-r)*t;return Math.max(n,18)}function Xk(e,t,r,n="ltr"){const o=na(r),i=o/2,s=t||i,a=o-s,c=r.scrollbar.paddingStart+s,u=r.scrollbar.size-r.scrollbar.paddingEnd-a,f=r.content-r.viewport,l=n==="ltr"?[0,f]:[f*-1,0];return Th([c,u],l)(e)}function _h(e,t,r="ltr"){const n=na(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,i=t.scrollbar.size-o,s=t.content-t.viewport,a=i-n,c=r==="ltr"?[0,s]:[s*-1,0],u=hi(e,c);return Th([0,s],[0,a])(u)}function Th(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const n=(t[1]-t[0])/(e[1]-e[0]);return t[0]+n*(r-e[0])}}function Fh(e,t){return e>0&&e<t}var Jk=(e,t=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},n=0;return(function o(){const i={left:e.scrollLeft,top:e.scrollTop},s=r.left!==i.left,a=r.top!==i.top;(s||a)&&t(),r=i,n=window.requestAnimationFrame(o)})(),()=>window.cancelAnimationFrame(n)};function oa(e,t){const r=dr(e),n=b.useRef(0);return b.useEffect(()=>()=>window.clearTimeout(n.current),[]),b.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,t)},[r,t])}function Fo(e,t){const r=dr(t);tr(()=>{let n=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(n),n=window.requestAnimationFrame(r)});return o.observe(e),()=>{window.cancelAnimationFrame(n),o.unobserve(e)}}},[e,r])}var Qk=bh,Zk=wh,eN=kh;function tN({className:e,children:t,...r}){return d.jsxs(Qk,{"data-slot":"scroll-area",className:V("relative",e),...r,children:[d.jsx(Zk,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:t}),d.jsx(rN,{}),d.jsx(eN,{})]})}function rN({className:e,orientation:t="vertical",...r}){return d.jsx(Sh,{"data-slot":"scroll-area-scrollbar",orientation:t,className:V("flex touch-none p-px transition-colors select-none",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",e),...r,children:d.jsx(Eh,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const Ph=({field:e,value:t=[],onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a,formValues:c={},submissionContext:u,excludedOptionValues:f})=>{const{options:l,isLoadingOptions:p,optionsError:g}=zm({field:e,formValues:c,submissionContext:u}),m=f?.length?new Set(f.map(String)):null,h=m?l.filter(N=>!m.has(String(N.value??N.label??""))):l,y=Array.isArray(t)?t:[],S=y.map(N=>h.find(T=>String(T.value)===String(N))).filter(Boolean),v=w.useCallback(N=>{const T=y.includes(N)?y.filter(P=>P!==N):[...y,N];r(T),n?.()},[y,r,n]),A=w.useCallback(N=>{r(y.filter(T=>T!==N)),n?.()},[y,r,n]),x=e.appearance?.size||"md",F={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},k=S.length>0?`${S.length} selected`:h.length===0&&f?.length?"No available options":e.placeholder||"Select options";return d.jsxs(Ct,{field:e,error:o||g||void 0,isRequired:s,className:a,children:[d.jsxs(uc,{children:[d.jsx(oh,{asChild:!0,children:d.jsxs(Qt,{type:"button",variant:"outline",role:"combobox","aria-expanded":void 0,"aria-haspopup":"listbox","aria-multiselectable":"true","aria-describedby":Lt(e,!!o||!!g),"aria-invalid":Jt(!!o||!!g),"aria-required":s,id:ft(e),disabled:i||e.disabled||p,className:V("w-full min-w-0 justify-between font-normal",F[x],o&&"border-destructive focus-visible:ring-destructive",g&&"border-destructive focus-visible:ring-destructive",e.appearance?.className),children:[d.jsx("span",{className:"truncate",children:k}),d.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[p&&d.jsx(ho,{className:"h-4 w-4 animate-spin text-muted-foreground"}),d.jsx(ii,{className:"h-4 w-4 opacity-50"})]})]})}),d.jsx(fc,{className:"w-[var(--radix-popover-trigger-width)] p-0 overflow-hidden",align:"start",children:d.jsx(tN,{className:"h-60 overflow-hidden rounded-md",children:d.jsx("ul",{role:"listbox","aria-multiselectable":"true","aria-label":e.label||e.name||"Options",className:"p-1",children:h.length===0?d.jsx("li",{className:"px-2 py-3 text-sm text-muted-foreground text-center",children:p?"Loading options...":f?.length?"No available options":"No options available"}):h.map(N=>{const T=String(N.value||N.label),P=N.label||N.value||T,E=y.includes(T);return d.jsxs("li",{role:"option","aria-selected":E,className:"flex items-center gap-2 rounded-sm px-2 py-1.5 cursor-pointer hover:bg-accent focus:bg-accent outline-none",onClick:()=>!N.disabled&&v(T),onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),N.disabled||v(T))},children:[d.jsx(ea,{checked:E,disabled:N.disabled,onCheckedChange:()=>!N.disabled&&v(T),onClick:C=>C.stopPropagation(),"aria-hidden":!0,className:"pointer-events-none"}),d.jsx("span",{className:"flex-1 truncate text-sm",children:P})]},T)})})})})]}),S.length>0&&d.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",role:"list","aria-label":"Selected options",children:S.map(N=>{const T=String(N.value||N.label),P=N.label||N.value||T;return d.jsxs(Hk,{variant:"secondary",className:"pl-2 pr-1 py-0.5 text-xs font-normal gap-1",children:[d.jsx("span",{className:"truncate max-w-[120px]",children:P}),d.jsx("button",{type:"button","aria-label":`Remove ${P}`,className:"rounded-full p-0.5 hover:bg-muted focus:outline-none focus:ring-2 focus:ring-ring",onClick:()=>A(T),tabIndex:-1,children:d.jsx(ai,{className:"h-3 w-3"})})]},T)})})]})},Ih=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a})=>{const c=w.useCallback(u=>{r(u===!0),n?.()},[r,n]);return d.jsxs("div",{className:V("space-y-2",a),children:[d.jsxs("div",{className:"flex items-start space-x-3",children:[d.jsx(ea,{id:ft(e),checked:t||!1,onCheckedChange:c,disabled:i||e.disabled,"aria-describedby":Lt(e,!!o),"aria-required":s,className:V(o&&"border-destructive")}),d.jsxs("div",{className:"grid gap-1.5 leading-none",children:[d.jsxs(Pn,{id:cs(e),htmlFor:ft(e),className:V("text-sm font-medium cursor-pointer",o&&"text-destructive"),children:[e.label,s&&d.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.description&&!o&&d.jsx("p",{id:ni(e),className:"text-xs text-muted-foreground",children:e.description})]})]}),o&&d.jsx("p",{id:oi(e),className:"text-xs text-destructive",role:"alert",children:o})]})};var ia="Switch",[nN]=Sr(ia),[oN,iN]=nN(ia),Oh=b.forwardRef((e,t)=>{const{__scopeSwitch:r,name:n,checked:o,defaultChecked:i,required:s,disabled:a,value:c="on",onCheckedChange:u,form:f,...l}=e,[p,g]=b.useState(null),m=qe(t,A=>g(A)),h=b.useRef(!1),y=p?f||!!p.closest("form"):!0,[S,v]=ln({prop:o,defaultProp:i??!1,onChange:u,caller:ia});return d.jsxs(oN,{scope:r,checked:S,disabled:a,children:[d.jsx($e.button,{type:"button",role:"switch","aria-checked":S,"aria-required":s,"data-state":Bh(S),"data-disabled":a?"":void 0,disabled:a,value:c,...l,ref:m,onClick:Oe(e.onClick,A=>{v(x=>!x),y&&(h.current=A.isPropagationStopped(),h.current||A.stopPropagation())})}),y&&d.jsx(Dh,{control:p,bubbles:!h.current,name:n,value:c,checked:S,required:s,disabled:a,form:f,style:{transform:"translateX(-100%)"}})]})});Oh.displayName=ia;var Mh="SwitchThumb",Lh=b.forwardRef((e,t)=>{const{__scopeSwitch:r,...n}=e,o=iN(Mh,r);return d.jsx($e.span,{"data-state":Bh(o.checked),"data-disabled":o.disabled?"":void 0,...n,ref:t})});Lh.displayName=Mh;var sN="SwitchBubbleInput",Dh=b.forwardRef(({__scopeSwitch:e,control:t,checked:r,bubbles:n=!0,...o},i)=>{const s=b.useRef(null),a=qe(s,i),c=vi(r),u=bi(t);return b.useEffect(()=>{const f=s.current;if(!f)return;const l=window.HTMLInputElement.prototype,g=Object.getOwnPropertyDescriptor(l,"checked").set;if(c!==r&&g){const m=new Event("click",{bubbles:n});g.call(f,r),f.dispatchEvent(m)}},[c,r,n]),d.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Dh.displayName=sN;function Bh(e){return e?"checked":"unchecked"}var aN=Oh,lN=Lh;function $h({className:e,...t}){return d.jsx(aN,{"data-slot":"switch",className:V("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:d.jsx(lN,{"data-slot":"switch-thumb",className:V("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}const cN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a})=>{const c=e.properties;let u=null;if(e.metadata)try{u=typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata}catch{}const f=u?.onValue??c?.onValue??"On",l=u?.offValue??c?.offValue??"Off",p=u?.onText??c?.onText??f,g=u?.offText??c?.offText??l,m=w.useMemo(()=>{const y=t??e.defaultValue??l;return String(y)===String(f)},[t,e.defaultValue,l,f]),h=w.useCallback(y=>{r(y?f:l),n?.()},[r,n,f,l]);return d.jsxs("div",{className:V("space-y-2",a),children:[d.jsxs("div",{className:"space-y-2",children:[e.label&&d.jsxs(Pn,{id:cs(e),htmlFor:ft(e),className:V("text-sm font-medium block",o&&"text-destructive"),children:[e.label,s&&d.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.description&&!o&&d.jsx("p",{id:ni(e),className:"text-xs text-muted-foreground",children:e.description}),d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx($h,{id:ft(e),checked:m,onCheckedChange:h,disabled:i||e.disabled,"aria-describedby":Lt(e,!!o),"aria-required":s,className:V(o&&"opacity-50")}),d.jsx("span",{className:"text-sm text-foreground font-medium",children:m?p:g})]})]}),o&&d.jsx("p",{id:oi(e),className:"text-xs text-destructive",role:"alert",children:o})]})};var wc="rovingFocusGroup.onEntryFocus",dN={bubbles:!1,cancelable:!0},ki="RovingFocusGroup",[Sc,jh,uN]=Fl(ki),[fN,sa]=Sr(ki,[uN]),[pN,mN]=fN(ki),Hh=b.forwardRef((e,t)=>d.jsx(Sc.Provider,{scope:e.__scopeRovingFocusGroup,children:d.jsx(Sc.Slot,{scope:e.__scopeRovingFocusGroup,children:d.jsx(hN,{...e,ref:t})})}));Hh.displayName=ki;var hN=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:f=!1,...l}=e,p=b.useRef(null),g=qe(t,p),m=vo(i),[h,y]=ln({prop:s,defaultProp:a??null,onChange:c,caller:ki}),[S,v]=b.useState(!1),A=dr(u),x=jh(r),F=b.useRef(!1),[k,N]=b.useState(0);return b.useEffect(()=>{const T=p.current;if(T)return T.addEventListener(wc,A),()=>T.removeEventListener(wc,A)},[A]),d.jsx(pN,{scope:r,orientation:n,dir:m,loop:o,currentTabStopId:h,onItemFocus:b.useCallback(T=>y(T),[y]),onItemShiftTab:b.useCallback(()=>v(!0),[]),onFocusableItemAdd:b.useCallback(()=>N(T=>T+1),[]),onFocusableItemRemove:b.useCallback(()=>N(T=>T-1),[]),children:d.jsx($e.div,{tabIndex:S||k===0?-1:0,"data-orientation":n,...l,ref:g,style:{outline:"none",...e.style},onMouseDown:Oe(e.onMouseDown,()=>{F.current=!0}),onFocus:Oe(e.onFocus,T=>{const P=!F.current;if(T.target===T.currentTarget&&P&&!S){const E=new CustomEvent(wc,dN);if(T.currentTarget.dispatchEvent(E),!E.defaultPrevented){const C=x().filter(z=>z.focusable),O=C.find(z=>z.active),W=C.find(z=>z.id===h),U=[O,W,...C].filter(Boolean).map(z=>z.ref.current);Vh(U,f)}}F.current=!1}),onBlur:Oe(e.onBlur,()=>v(!1))})})}),Uh="RovingFocusGroupItem",zh=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:o=!1,tabStopId:i,children:s,...a}=e,c=yn(),u=i||c,f=mN(Uh,r),l=f.currentTabStopId===u,p=jh(r),{onFocusableItemAdd:g,onFocusableItemRemove:m,currentTabStopId:h}=f;return b.useEffect(()=>{if(n)return g(),()=>m()},[n,g,m]),d.jsx(Sc.ItemSlot,{scope:r,id:u,focusable:n,active:o,children:d.jsx($e.span,{tabIndex:l?0:-1,"data-orientation":f.orientation,...a,ref:t,onMouseDown:Oe(e.onMouseDown,y=>{n?f.onItemFocus(u):y.preventDefault()}),onFocus:Oe(e.onFocus,()=>f.onItemFocus(u)),onKeyDown:Oe(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){f.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const S=bN(y,f.orientation,f.dir);if(S!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let A=p().filter(x=>x.focusable).map(x=>x.ref.current);if(S==="last")A.reverse();else if(S==="prev"||S==="next"){S==="prev"&&A.reverse();const x=A.indexOf(y.currentTarget);A=f.loop?vN(A,x+1):A.slice(x+1)}setTimeout(()=>Vh(A))}}),children:typeof s=="function"?s({isCurrentTabStop:l,hasTabStop:h!=null}):s})})});zh.displayName=Uh;var gN={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function yN(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function bN(e,t,r){const n=yN(e.key,r);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return gN[n]}function Vh(e,t=!1){const r=document.activeElement;for(const n of e)if(n===r||(n.focus({preventScroll:t}),document.activeElement!==r))return}function vN(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var Wh=Hh,Rh=zh,xc="Radio",[wN,Kh]=Sr(xc),[SN,xN]=wN(xc),Gh=b.forwardRef((e,t)=>{const{__scopeRadio:r,name:n,checked:o=!1,required:i,disabled:s,value:a="on",onCheck:c,form:u,...f}=e,[l,p]=b.useState(null),g=qe(t,y=>p(y)),m=b.useRef(!1),h=l?u||!!l.closest("form"):!0;return d.jsxs(SN,{scope:r,checked:o,disabled:s,children:[d.jsx($e.button,{type:"button",role:"radio","aria-checked":o,"data-state":Jh(o),"data-disabled":s?"":void 0,disabled:s,value:a,...f,ref:g,onClick:Oe(e.onClick,y=>{o||c?.(),h&&(m.current=y.isPropagationStopped(),m.current||y.stopPropagation())})}),h&&d.jsx(Xh,{control:l,bubbles:!m.current,name:n,value:a,checked:o,required:i,disabled:s,form:u,style:{transform:"translateX(-100%)"}})]})});Gh.displayName=xc;var qh="RadioIndicator",Yh=b.forwardRef((e,t)=>{const{__scopeRadio:r,forceMount:n,...o}=e,i=xN(qh,r);return d.jsx(Cr,{present:n||i.checked,children:d.jsx($e.span,{"data-state":Jh(i.checked),"data-disabled":i.disabled?"":void 0,...o,ref:t})})});Yh.displayName=qh;var AN="RadioBubbleInput",Xh=b.forwardRef(({__scopeRadio:e,control:t,checked:r,bubbles:n=!0,...o},i)=>{const s=b.useRef(null),a=qe(s,i),c=vi(r),u=bi(t);return b.useEffect(()=>{const f=s.current;if(!f)return;const l=window.HTMLInputElement.prototype,g=Object.getOwnPropertyDescriptor(l,"checked").set;if(c!==r&&g){const m=new Event("click",{bubbles:n});g.call(f,r),f.dispatchEvent(m)}},[c,r,n]),d.jsx($e.input,{type:"radio","aria-hidden":!0,defaultChecked:r,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Xh.displayName=AN;function Jh(e){return e?"checked":"unchecked"}var CN=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],aa="RadioGroup",[EN]=Sr(aa,[sa,Kh]),Qh=sa(),Zh=Kh(),[kN,NN]=EN(aa),eg=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,name:n,defaultValue:o,value:i,required:s=!1,disabled:a=!1,orientation:c,dir:u,loop:f=!0,onValueChange:l,...p}=e,g=Qh(r),m=vo(u),[h,y]=ln({prop:i,defaultProp:o??null,onChange:l,caller:aa});return d.jsx(kN,{scope:r,name:n,required:s,disabled:a,value:h,onValueChange:y,children:d.jsx(Wh,{asChild:!0,...g,orientation:c,dir:m,loop:f,children:d.jsx($e.div,{role:"radiogroup","aria-required":s,"aria-orientation":c,"data-disabled":a?"":void 0,dir:m,...p,ref:t})})})});eg.displayName=aa;var tg="RadioGroupItem",rg=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,disabled:n,...o}=e,i=NN(tg,r),s=i.disabled||n,a=Qh(r),c=Zh(r),u=b.useRef(null),f=qe(t,u),l=i.value===o.value,p=b.useRef(!1);return b.useEffect(()=>{const g=h=>{CN.includes(h.key)&&(p.current=!0)},m=()=>p.current=!1;return document.addEventListener("keydown",g),document.addEventListener("keyup",m),()=>{document.removeEventListener("keydown",g),document.removeEventListener("keyup",m)}},[]),d.jsx(Rh,{asChild:!0,...a,focusable:!s,active:l,children:d.jsx(Gh,{disabled:s,required:i.required,checked:l,...c,...o,name:i.name,ref:f,onCheck:()=>i.onValueChange(o.value),onKeyDown:Oe(g=>{g.key==="Enter"&&g.preventDefault()}),onFocus:Oe(o.onFocus,()=>{p.current&&u.current?.click()})})})});rg.displayName=tg;var _N="RadioGroupIndicator",ng=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,...n}=e,o=Zh(r);return d.jsx(Yh,{...o,...n,ref:t})});ng.displayName=_N;var TN=eg,FN=rg,PN=ng;function IN({className:e,...t}){return d.jsx(TN,{"data-slot":"radio-group",className:V("grid gap-3",e),...t})}function ON({className:e,...t}){return d.jsx(FN,{"data-slot":"radio-group-item",className:V("border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:d.jsx(PN,{"data-slot":"radio-group-indicator",className:"relative flex items-center justify-center",children:d.jsx(ef,{className:"fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2"})})})}const og=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a,excludedOptionValues:c})=>{const u=e.properties,f=Array.isArray(u?.options)&&u.options.length>0?u.options:Array.isArray(e.options)?e.options:[],l=c?.length?new Set(c.map(String)):null,p=l?f.filter(m=>!l.has(String(m.value??m.label??""))):f,g=w.useCallback(m=>{r(m),n?.()},[r,n]);return d.jsx(Ct,{field:e,error:o,isRequired:s,className:a,children:d.jsx(IN,{value:t||"",onValueChange:g,disabled:i||e.disabled||p.length===0,className:"flex flex-col space-y-2","aria-required":s,children:p.length===0?d.jsx("p",{className:"text-sm text-muted-foreground py-1",children:"No available options"}):p.map(m=>d.jsxs("div",{className:"flex items-center space-x-3",children:[d.jsx(ON,{id:`${ft(e)}-${m.value}`,value:m.value,disabled:m.disabled,className:V(o&&"border-destructive")}),d.jsxs(Pn,{htmlFor:`${ft(e)}-${m.value}`,className:V("text-sm font-normal cursor-pointer",m.disabled&&"text-muted-foreground cursor-not-allowed"),children:[m.label,m.description&&d.jsx("span",{className:"block text-xs text-muted-foreground",children:m.description})]})]},m.value))})})},ig=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:c})=>{const u=e.properties,f=w.useCallback(x=>{r(x.target.value)},[r]),l=x=>{if(x)return x==="today"?new Date().toISOString().split("T")[0]:x},p=l(u?.minDate),g=l(u?.maxDate),h=(()=>{switch(e.type){case"time":return"time";case"datetime":return"datetime-local";case"daterange":return"date";default:return"date"}})(),y=e.appearance?.size||"md",S={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},v=e.appearance?.labelPlacement||"top",A=!e.appearance?.hideLabel&&e.label;return d.jsxs("div",{className:V("space-y-2 w-fit",v==="left"&&"flex items-start gap-4",c),children:[A&&d.jsxs(Pn,{id:cs(e),htmlFor:ft(e),className:V("text-sm font-medium",v==="left"&&"w-32 pt-2 text-right",o&&"text-destructive"),children:[e.label,a&&d.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),d.jsxs("div",{className:"w-fit",children:[d.jsxs("div",{className:"relative w-fit max-w-full",children:[d.jsx(bS,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"}),d.jsx(gn,{id:ft(e),type:h,value:t||"",onChange:f,onBlur:n,disabled:i||e.disabled,readOnly:s||e.readOnly,min:p,max:g,"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:V(S[y],"pl-10 w-fit",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]}),e.description&&!o&&d.jsx("p",{id:ni(e),className:"mt-1.5 text-xs text-muted-foreground",children:e.description}),o&&d.jsx("p",{id:oi(e),className:"mt-1.5 text-xs text-destructive",role:"alert",children:o})]})]})};function Po(e){if(e===0)return"0 Bytes";const t=1024,r=["Bytes","KB","MB","GB"],n=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,n)).toFixed(2))+" "+r[n]}function Ac(e,t){return e===1&&t===1}const sg=/\.(jpg|jpeg|png|gif|webp|bmp|svg)(\?|$)/i;function Cc(e){return e.type.startsWith("image/")?!0:sg.test(e.name)}function la(e){try{const t=e.split("?")[0];return sg.test(t)}catch{return!1}}function Ec({items:e,maxFiles:t,disabled:r,objectUrls:n,failedUrlKeys:o,onImageUrlError:i,onRemove:s,onOpenUrl:a,resolveOpenUrl:c,addSlot:u,className:f}){const l=w.useCallback(p=>{try{return p.split("?")[0].split("/").filter(Boolean).pop()||p}catch{return p}},[]);return d.jsxs("div",{"data-file-like-strip":!0,"data-remove-in-dropzone":!0,className:V("relative w-full h-full flex items-center gap-1 min-h-0 overflow-x-auto",f),children:[e.map((p,g)=>{const m=p instanceof File,h=!m&&p&&"url"in p?p:null,y=h?.url??"",S=`${g}-${y}`,v=h&&o.has(y),A=m?n[g]??null:h&&la(y)&&!v?y:null,x=m&&Cc(p)&&!!A||!!h&&la(y)&&!v&&!!A,F=m?p.name:h?h.name??l(y):"",k=c?.(g,p),N=h&&y||k||"",T=!!a&&!!N;return d.jsxs("div",{className:"relative h-[56px] w-[56px] min-w-[56px] flex-shrink-0 rounded overflow-hidden border border-border/60 bg-muted/30",children:[x&&A?d.jsx("img",{src:A,alt:"",className:"absolute inset-0 h-full w-full object-cover",onError:()=>{h&&i(y)}}):d.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-muted/40",children:d.jsx(rf,{className:"h-7 w-7 text-muted-foreground","aria-hidden":!0})}),d.jsxs("div",{className:"absolute top-0.5 right-0.5 z-10 flex items-center gap-0.5",children:[T&&d.jsx("button",{type:"button",onClick:P=>{P.preventDefault(),P.stopPropagation(),a(N)},disabled:r,className:"inline-flex h-5 w-5 items-center justify-center rounded bg-background/90 text-foreground hover:bg-background focus:outline-none focus:ring-2 focus:ring-primary","aria-label":"Open file",title:"Open file",children:d.jsx(tf,{className:"h-3 w-3","aria-hidden":!0})}),d.jsx("button",{type:"button",onClick:P=>{P.preventDefault(),P.stopPropagation(),s(g)},disabled:r,className:"inline-flex h-5 w-5 items-center justify-center rounded bg-background/90 text-destructive hover:bg-background focus:outline-none focus:ring-2 focus:ring-destructive","aria-label":"Remove file",title:"Remove file",children:d.jsx(ai,{className:"h-3 w-3","aria-hidden":!0})})]}),!x&&F&&d.jsx("span",{className:"sr-only",children:F})]},S+(m?p.name+p.size:""))}),u]})}function kc(e){const[t,r]=w.useState([]);return w.useEffect(()=>{const n=e.map(o=>o instanceof File&&Cc(o)?URL.createObjectURL(o):null);return r(n),()=>{n.forEach(o=>{o&&URL.revokeObjectURL(o)})}},[e]),t}function Nc({item:e,objectUrl:t,failedUrlKeys:r,onImageUrlError:n,onRemove:o,onOpenUrl:i,openTarget:s,disabled:a}){const c=w.useCallback(v=>{try{return v.split("?")[0].split("/").filter(Boolean).pop()||v}catch{return v}},[]),u=e instanceof File,f=!u&&e&&"url"in e?e:null,l=f?.url??"",p=f&&r.has(l),g=u?t:f&&la(l)&&!p?l:null,m=u&&Cc(e)&&!!g||!!f&&la(l)&&!p&&!!g,h=u?e.name:f?f.name??c(l):"",y=(s?.trim()||l||"").trim(),S=!!i&&!!y;return d.jsxs("div",{"data-file-like-full-bleed":!0,"data-remove-in-dropzone":!0,className:"relative h-full w-full min-h-[58px] min-w-0 flex items-center justify-center",children:[m&&g?d.jsx("img",{src:g,alt:"",className:"absolute inset-0 h-full w-full rounded object-cover",onError:()=>{f&&n(l)}}):d.jsx("div",{className:"absolute inset-0 flex items-center justify-center rounded bg-muted/40",children:d.jsx(rf,{className:"h-8 w-8 text-muted-foreground","aria-hidden":!0})}),d.jsxs("div",{className:"absolute top-1 right-1 z-10 flex items-center gap-1",children:[S&&y&&d.jsx("button",{type:"button",onClick:v=>{v.preventDefault(),v.stopPropagation(),i(y)},disabled:a,className:"inline-flex h-6 w-6 items-center justify-center rounded bg-background/85 text-foreground hover:bg-background focus:outline-none focus:ring-2 focus:ring-primary","aria-label":"Open file",title:"Open file",children:d.jsx(tf,{className:"h-3.5 w-3.5","aria-hidden":!0})}),d.jsx("button",{type:"button",onClick:v=>{v.preventDefault(),v.stopPropagation(),o()},disabled:a,className:"inline-flex h-6 w-6 items-center justify-center rounded bg-background/85 text-destructive hover:bg-background focus:outline-none focus:ring-2 focus:ring-destructive","aria-label":"Remove file",title:"Remove file",children:d.jsx(ai,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),!m&&h&&d.jsx("p",{className:"sr-only",children:h})]})}const MN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a,buttonResponses:c})=>{const{gridStretch:u}=ti(),f=u&&ts(e),l=e.properties,p=w.useRef(null),[g,m]=w.useState(!1),[h,y]=w.useState(),[S,v]=w.useState(()=>new Set),[A,x]=w.useState(0),F=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,k=rs(e),N=w.useMemo(()=>ns(t),[t]),[T,P]=w.useState(null);w.useEffect(()=>{P(null)},[t,A]);const E=T??N,C=kc(E),O=e.validation?.find(ne=>ne.type==="fileSize"),W=e.validation?.find(ne=>ne.type==="fileType"),M=O?.value?O.value:l?.maxSize??F?.maxSize??10*1024*1024,U=W?.value?W.value:l?.accept??F?.accept??[],z=Array.isArray(U)?U.join(","):"",X=()=>{E.length>=k||p.current?.click()},B=w.useCallback(ne=>{if(O){const ge=rn(ne,O);if(ge!==!0)return typeof ge=="string"?ge:"File size exceeds the maximum allowed size"}else if(ne.size>M)return`File size must be less than ${Po(M)}`;if(W){const ge=rn(ne,W);if(ge!==!0)return typeof ge=="string"?ge:"File type is not allowed"}return null},[O,W,M]),L=w.useCallback(ne=>{const ge=nl(ne,k);r(ge),n?.()},[r,n,k]),D=w.useCallback(ne=>{y(void 0);const ge=Array.from(ne),Se=[...E];let yt=null;for(const kt of ge){if(Se.length>=k)break;const Ut=B(kt);if(Ut){yt||(yt=Ut);continue}Se.push(kt)}if(yt&&Se.length===E.length){y(yt);return}yt&&y(yt),P(Se),L(Se)},[E,k,B,L]),K=w.useCallback(ne=>{const ge=ne.target.files;ge&&ge.length>0&&D(ge),p.current&&(p.current.value="")},[D]),le=w.useCallback(ne=>{if(i)return;const ge=E.filter((Se,yt)=>yt!==ne);x(Se=>Se+1),P(ge),L(ge)},[i,E,L]),j=ne=>{ne.preventDefault(),m(!0)},H=()=>{m(!1)},ce=ne=>{ne.preventDefault(),m(!1),ne.dataTransfer.files?.length&&D(ne.dataTransfer.files)},ie=o||h,G=[];(O||M)&&G.push(`Max size: ${Po(M)}`),W&&U.length>0&&G.push(`Allowed types: ${U.join(", ")}`),k>1&&G.push(`Up to ${k} files`);const ee=e.appearance?.hideLabel??!1,Ae=w.useMemo(()=>{if(!c)return null;const ne=Object.values(c);for(let ge=ne.length-1;ge>=0;ge-=1){const Se=ne[ge],yt=typeof Se?.status=="string"?Se.status.toLowerCase():null;if(yt&&yt!=="success")continue;const kt=Se?.code;if(typeof kt=="number"&&(kt<200||kt>=300))continue;const Ut=Se?.data,It=Ut?.file_url||Ut?.fileUrl||Se?.file_url||Se?.fileUrl;if(typeof It=="string"&&It.trim())return It}return null},[c]),te=w.useCallback(ne=>{window.open(ne,"_blank","noopener,noreferrer")},[]),oe=w.useCallback(ne=>{v(ge=>new Set(ge).add(ne))},[]),me=E.length===0,Me=E.length<k,De=Ac(k,E.length);return d.jsx(Ct,{field:e,error:ie,isRequired:s,className:V(a,"!space-y-0"),hideLabel:ee,children:d.jsx("div",{className:V("min-h-[70px] min-w-0 w-full flex flex-col",f?"flex-1 h-full":"h-[70px]"),children:d.jsxs("div",{onClick:ne=>{ne.target.closest("[data-remove-in-dropzone]")||ne.target.closest("[data-no-open-picker]")||X()},onDragOver:j,onDragLeave:H,onDrop:ce,className:V("border-2 border-dashed rounded-lg p-1.5 text-center cursor-pointer transition-colors flex-1 min-h-0 flex flex-col items-center justify-center","hover:border-primary hover:bg-primary/5",g&&"border-primary bg-primary/10",ie&&"border-destructive",i&&"opacity-50 cursor-not-allowed",!Me&&E.length>0&&"cursor-default"),children:[d.jsx("input",{ref:p,id:ft(e),type:"file",accept:z,multiple:k>1,onChange:K,disabled:i||e.disabled||!Me,className:"hidden","aria-describedby":Lt(e,!!ie),"aria-invalid":Jt(!!ie),"aria-required":s}),me?d.jsxs(d.Fragment,{children:[d.jsx(ps,{className:"mx-auto h-5 w-5 text-muted-foreground flex-shrink-0"}),d.jsx("p",{className:"text-[11px] text-muted-foreground leading-tight line-clamp-1",children:"Drag & drop or click"}),G.length>0&&d.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-1",children:G.join(" • ")})]}):De?d.jsx(Nc,{item:E[0],objectUrl:C[0]??null,failedUrlKeys:S,onImageUrlError:oe,onRemove:()=>le(0),onOpenUrl:te,openTarget:E[0]instanceof File?Ae:void 0,disabled:i||e.disabled}):d.jsx(Ec,{items:E,maxFiles:k,disabled:i,objectUrls:C,failedUrlKeys:S,onImageUrlError:oe,onRemove:le,resolveOpenUrl:(ne,ge)=>ge instanceof File&&E.length===1&&Ae?.trim()?Ae.trim():null,onOpenUrl:ne=>{ne?.trim()&&te(ne.trim())},addSlot:Me?d.jsxs("button",{type:"button","data-no-open-picker":!0,onClick:ne=>{ne.stopPropagation(),p.current?.click()},disabled:i||e.disabled,className:"h-[56px] w-[56px] min-w-[56px] flex-shrink-0 rounded border border-dashed border-muted-foreground/40 flex flex-col items-center justify-center text-muted-foreground hover:border-primary hover:bg-primary/5 text-[10px] leading-tight px-0.5",children:[d.jsx(ps,{className:"h-4 w-4 mb-0.5","aria-hidden":!0}),"Add"]}):void 0})]})})})};function LN(e){const t=DN(e),r=b.forwardRef((n,o)=>{const{children:i,...s}=n,a=b.Children.toArray(i),c=a.find($N);if(c){const u=c.props.children,f=a.map(l=>l===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:l);return d.jsx(t,{...s,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,f):null})}return d.jsx(t,{...s,ref:o,children:i})});return r.displayName=`${e}.Slot`,r}function DN(e){const t=b.forwardRef((r,n)=>{const{children:o,...i}=r;if(b.isValidElement(o)){const s=HN(o),a=jN(i,o.props);return o.type!==b.Fragment&&(a.ref=n?Yn(n,s):s),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var BN=Symbol("radix.slottable");function $N(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===BN}function jN(e,t){const r={...t};for(const n in t){const o=e[n],i=t[n];/^on[A-Z]/.test(n)?o&&i?r[n]=(...a)=>{const c=i(...a);return o(...a),c}:o&&(r[n]=o):n==="style"?r[n]={...o,...i}:n==="className"&&(r[n]=[o,i].filter(Boolean).join(" "))}return{...e,...r}}function HN(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var ca="Dialog",[ag]=Sr(ca),[UN,Xr]=ag(ca),lg=e=>{const{__scopeDialog:t,children:r,open:n,defaultOpen:o,onOpenChange:i,modal:s=!0}=e,a=b.useRef(null),c=b.useRef(null),[u,f]=ln({prop:n,defaultProp:o??!1,onChange:i,caller:ca});return d.jsx(UN,{scope:t,triggerRef:a,contentRef:c,contentId:yn(),titleId:yn(),descriptionId:yn(),open:u,onOpenChange:f,onOpenToggle:b.useCallback(()=>f(l=>!l),[f]),modal:s,children:r})};lg.displayName=ca;var cg="DialogTrigger",zN=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Xr(cg,r),i=qe(t,o.triggerRef);return d.jsx($e.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Fc(o.open),...n,ref:i,onClick:Oe(e.onClick,o.onOpenToggle)})});zN.displayName=cg;var _c="DialogPortal",[VN,dg]=ag(_c,{forceMount:void 0}),ug=e=>{const{__scopeDialog:t,forceMount:r,children:n,container:o}=e,i=Xr(_c,t);return d.jsx(VN,{scope:t,forceMount:r,children:b.Children.map(n,s=>d.jsx(Cr,{present:r||i.open,children:d.jsx(Bs,{asChild:!0,container:o,children:s})}))})};ug.displayName=_c;var da="DialogOverlay",fg=b.forwardRef((e,t)=>{const r=dg(da,e.__scopeDialog),{forceMount:n=r.forceMount,...o}=e,i=Xr(da,e.__scopeDialog);return i.modal?d.jsx(Cr,{present:n||i.open,children:d.jsx(RN,{...o,ref:t})}):null});fg.displayName=da;var WN=LN("DialogOverlay.RemoveScroll"),RN=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Xr(da,r);return d.jsx(Rs,{as:WN,allowPinchZoom:!0,shards:[o.contentRef],children:d.jsx($e.div,{"data-state":Fc(o.open),...n,ref:t,style:{pointerEvents:"auto",...n.style}})})}),oo="DialogContent",pg=b.forwardRef((e,t)=>{const r=dg(oo,e.__scopeDialog),{forceMount:n=r.forceMount,...o}=e,i=Xr(oo,e.__scopeDialog);return d.jsx(Cr,{present:n||i.open,children:i.modal?d.jsx(KN,{...o,ref:t}):d.jsx(GN,{...o,ref:t})})});pg.displayName=oo;var KN=b.forwardRef((e,t)=>{const r=Xr(oo,e.__scopeDialog),n=b.useRef(null),o=qe(t,r.contentRef,n);return b.useEffect(()=>{const i=n.current;if(i)return Ql(i)},[]),d.jsx(mg,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Oe(e.onCloseAutoFocus,i=>{i.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:Oe(e.onPointerDownOutside,i=>{const s=i.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&i.preventDefault()}),onFocusOutside:Oe(e.onFocusOutside,i=>i.preventDefault())})}),GN=b.forwardRef((e,t)=>{const r=Xr(oo,e.__scopeDialog),n=b.useRef(!1),o=b.useRef(!1);return d.jsx(mg,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(n.current||r.triggerRef.current?.focus(),i.preventDefault()),n.current=!1,o.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(n.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=i.target;r.triggerRef.current?.contains(s)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),mg=b.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:i,...s}=e,a=Xr(oo,r),c=b.useRef(null),u=qe(t,c);return Ol(),d.jsxs(d.Fragment,{children:[d.jsx(Es,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:i,children:d.jsx(Cs,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Fc(a.open),...s,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),d.jsxs(d.Fragment,{children:[d.jsx(YN,{titleId:a.titleId}),d.jsx(JN,{contentRef:c,descriptionId:a.descriptionId})]})]})}),Tc="DialogTitle",hg=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Xr(Tc,r);return d.jsx($e.h2,{id:o.titleId,...n,ref:t})});hg.displayName=Tc;var gg="DialogDescription",qN=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Xr(gg,r);return d.jsx($e.p,{id:o.descriptionId,...n,ref:t})});qN.displayName=gg;var yg="DialogClose",bg=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Xr(yg,r);return d.jsx($e.button,{type:"button",...n,ref:t,onClick:Oe(e.onClick,()=>o.onOpenChange(!1))})});bg.displayName=yg;function Fc(e){return e?"open":"closed"}var vg="DialogTitleWarning",[ZM,wg]=gx(vg,{contentName:oo,titleName:Tc,docsSlug:"dialog"}),YN=({titleId:e})=>{const t=wg(vg),r=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
47
47
|
|
|
48
48
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
49
49
|
|
|
50
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return b.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},Uk="DialogDescriptionWarning",Vk=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${pg(Uk).contentName}}.`;return b.useEffect(()=>{const o=e.current?.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},Hk=tg,Wk=og,Rk=ig,Kk=sg,Gk=lg,qk=ug;function mg({...e}){return d.jsx(Hk,{"data-slot":"dialog",...e})}function Yk({...e}){return d.jsx(Wk,{"data-slot":"dialog-portal",...e})}function Xk({className:e,...t}){return d.jsx(Rk,{"data-slot":"dialog-overlay",className:H("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function hg({className:e,children:t,showCloseButton:r=!0,...n}){return d.jsxs(Yk,{"data-slot":"dialog-portal",children:[d.jsx(Xk,{}),d.jsxs(Kk,{"data-slot":"dialog-content",className:H("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...n,children:[t,r&&d.jsxs(qk,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[d.jsx(ii,{}),d.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function gg({className:e,...t}){return d.jsx("div",{"data-slot":"dialog-header",className:H("flex flex-col gap-2 text-center sm:text-left",e),...t})}function Jk({className:e,...t}){return d.jsx("div",{"data-slot":"dialog-footer",className:H("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function yg({className:e,...t}){return d.jsx(Gk,{"data-slot":"dialog-title",className:H("text-lg leading-none font-semibold",e),...t})}async function Qk(){const e={width:{ideal:1280},height:{ideal:720}},t=[{facingMode:{ideal:"environment"},...e},{facingMode:{ideal:"user"},...e},{...e},{}];let r;for(const n of t)try{return await navigator.mediaDevices.getUserMedia({video:Object.keys(n).length>0?n:!0,audio:!1})}catch(o){r=o}throw r instanceof Error?r:new Error("Could not access camera")}function bg(e){const t=()=>e.play();t().catch(()=>{requestAnimationFrame(()=>{t().catch(()=>{const r=()=>{t().catch(()=>{})};e.addEventListener("loadedmetadata",r,{once:!0}),e.addEventListener("canplay",r,{once:!0})})})})}const vg=({open:e,onOpenChange:t,onCaptured:r,validateFile:n,accept:o,disabled:i,onValidationMessage:s})=>{const a=w.useRef(null),c=w.useRef(null),u=w.useRef(null),f=w.useRef(null),[l,p]=w.useState(null),[g,m]=w.useState(!1),h=w.useCallback(()=>{a.current&&(a.current.srcObject=null)},[]),y=w.useCallback(()=>{u.current&&(u.current.getTracks().forEach(N=>N.stop()),u.current=null),h()},[h]);w.useEffect(()=>{if(!e){y(),p(null),m(!1);return}if(i)return;let N=!1;return p(null),m(!0),Qk().then(k=>{if(N){k.getTracks().forEach(T=>T.stop());return}u.current=k,m(!1)}).catch(k=>{if(N)return;m(!1);const T=k instanceof Error?k.message:"Could not access camera";p(T)}),()=>{N=!0,u.current&&(u.current.getTracks().forEach(k=>k.stop()),u.current=null),h()}},[e,i,y,h]);const S=w.useCallback(N=>{a.current=N,N&&u.current&&e&&!l&&!g&&(N.srcObject=u.current,bg(N))},[e,l,g]);w.useLayoutEffect(()=>{if(!e||l||g||!u.current)return;let N=!1,k=0;const T=()=>{if(N)return;const E=a.current;!E||!u.current||(E.srcObject=u.current,bg(E))};T();const P=requestAnimationFrame(()=>{T(),k=requestAnimationFrame(T)});return()=>{N=!0,cancelAnimationFrame(P),cancelAnimationFrame(k),h()}},[e,l,g,h]);const v=w.useCallback(()=>{y(),p(null),m(!1),t(!1),f.current&&(f.current.value="")},[y,t]),A=w.useCallback(()=>{const N=a.current,k=c.current;if(!N||!k||!u.current||N.readyState<2)return;const T=N.videoWidth,P=N.videoHeight;if(T===0||P===0)return;k.width=T,k.height=P;const E=k.getContext("2d");E&&(E.drawImage(N,0,0),k.toBlob(C=>{if(!C)return;const I=new File([C],`camera-capture-${Date.now()}.jpg`,{type:"image/jpeg",lastModified:Date.now()}),W=n(I);if(W){s?.(W);return}s?.(void 0),r(I),v()},"image/jpeg",.92))},[r,n,v,s]),x=w.useCallback(N=>{const k=N.target.files?.[0];if(!k)return;const T=n(k);if(T){s?.(T);return}s?.(void 0),r(k),v(),f.current&&(f.current.value="")},[r,n,v,s]),F=typeof navigator<"u"&&typeof navigator.mediaDevices?.getUserMedia=="function";return d.jsxs(d.Fragment,{children:[d.jsx("input",{ref:f,type:"file",accept:o,capture:"user",onChange:x,className:"hidden","aria-hidden":!0}),d.jsx("canvas",{ref:c,className:"hidden","aria-hidden":!0}),d.jsx(mg,{open:e,onOpenChange:N=>{N||v()},children:d.jsxs(hg,{className:"sm:max-w-md",showCloseButton:!0,onPointerDownOutside:N=>N.preventDefault(),children:[d.jsx(gg,{children:d.jsx(yg,{children:"Take a photo"})}),l?d.jsxs("div",{className:"space-y-3 py-2",children:[d.jsx("p",{className:"text-sm text-destructive",children:l}),F&&d.jsx("p",{className:"text-xs text-muted-foreground",children:"You can choose an image from your device instead."}),d.jsx(Qt,{type:"button",variant:"outline",className:"w-full",onClick:()=>f.current?.click(),children:"Choose from device"})]}):g?d.jsx("p",{className:"text-sm text-muted-foreground py-6 text-center",children:"Opening camera…"}):d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"relative rounded-lg overflow-hidden bg-black aspect-video",children:d.jsx("video",{ref:S,playsInline:!0,muted:!0,className:"w-full h-full object-cover"})}),d.jsxs(Jk,{className:"gap-2 sm:gap-0",children:[d.jsx(Qt,{type:"button",variant:"outline",onClick:v,children:"Cancel"}),d.jsx(Qt,{type:"button",onClick:A,children:"Capture photo"})]})]})]})})]})},Zk=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a})=>{const c=e.properties,[u,f]=w.useState(),[l,p]=w.useState(!1),[g,m]=w.useState(()=>new Set),[h,y]=w.useState("none"),S=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,v=e.validation?.find(j=>j.type==="fileSize"),A=e.validation?.find(j=>j.type==="fileType"),x=v?.value!=null?v.value:c?.maxSize??S?.maxSize??5*1024*1024,F=A?.value!=null?A.value:c?.accept??S?.accept??["image/*"],N=F.join(",")||"image/*",k=Zi(e),T=w.useCallback(j=>{if(v){const z=rn(j,v);if(z!==!0)return typeof z=="string"?z:"File size exceeds the maximum allowed size"}else if(j.size>x)return`File size must be less than ${Fo(x)}`;if(A){const z=rn(j,A);if(z!==!0)return typeof z=="string"?z:"File type is not allowed"}return null},[v,A,x]),P=w.useMemo(()=>es(t),[t]),E=xc(P),C=w.useCallback(j=>{const z=Za(j,k);r(z),n?.()},[r,n,k]),I=w.useCallback(j=>{const z=T(j);if(z){f(z);return}f(void 0);const le=[...P];le.length>=k||(le.push(j),C(le),y("none"))},[P,k,T,C]),W=w.useCallback(j=>{const z=P.filter((le,ie)=>ie!==j);C(z)},[P,C]),M=w.useCallback(()=>{i||P.length>=k||(f(void 0),y("camera"),p(!0))},[i,P.length,k]),U=w.useCallback(j=>{p(j),j||y("none")},[]),V=o||u,X=e.appearance?.hideLabel??!1,B=[];(v||x)&&B.push(`Max size: ${Fo(x)}`),A&&F.length>0&&B.push(`Allowed: ${F.join(", ")}`),k>1&&B.push(`Up to ${k} photos`);const L=w.useCallback(j=>{window.open(j,"_blank","noopener,noreferrer")},[]),D=P.length===0,K=P.length<k,ae=vc(k,P.length);return d.jsxs(At,{field:e,error:V,isRequired:s,className:H(a,"!space-y-0"),hideLabel:X,children:[d.jsx("div",{className:"h-[70px] min-h-[70px] min-w-0 w-full flex flex-col",children:d.jsx("div",{role:"button",tabIndex:i||!K?-1:0,id:ft(e),onClick:j=>{i||j.target.closest("[data-remove-in-dropzone]")||j.target.closest("[data-no-open-picker]")||P.length>=k||M()},onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),!i&&K&&M())},className:H("border-2 border-dashed rounded-lg p-1.5 text-center cursor-pointer transition-colors flex-1 min-h-0 flex flex-col items-center justify-center","hover:border-primary hover:bg-primary/5",V&&"border-destructive",i&&"opacity-50 cursor-not-allowed",l&&h==="camera"&&"opacity-70 pointer-events-none",!K&&P.length>0&&"cursor-default"),"aria-describedby":Lt(e,!!V),"aria-invalid":Xt(!!V),"aria-required":s,children:D?d.jsxs(d.Fragment,{children:[d.jsx(ls,{className:"mx-auto h-5 w-5 text-muted-foreground flex-shrink-0"}),d.jsx("p",{className:"text-[11px] text-muted-foreground leading-tight line-clamp-1",children:l?"Opening camera…":"Click to open camera"}),B.length>0&&d.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-1",children:B.join(" • ")})]}):ae?d.jsx(Ac,{item:P[0],objectUrl:E[0]??null,failedUrlKeys:g,onImageUrlError:j=>m(z=>new Set(z).add(j)),onRemove:()=>W(0),onOpenUrl:L,disabled:i}):d.jsx(Sc,{items:P,maxFiles:k,disabled:i,objectUrls:E,failedUrlKeys:g,onImageUrlError:j=>m(z=>new Set(z).add(j)),onRemove:W,onOpenUrl:L,addSlot:K?d.jsxs("button",{type:"button","data-no-open-picker":!0,onClick:j=>{j.stopPropagation(),M()},disabled:i,className:"h-[56px] w-[56px] min-w-[56px] flex-shrink-0 rounded border border-dashed border-muted-foreground/40 flex flex-col items-center justify-center text-muted-foreground hover:border-primary hover:bg-primary/5 text-[10px] leading-tight px-0.5",children:[d.jsx(ls,{className:"h-4 w-4 mb-0.5","aria-hidden":!0}),"Add"]}):void 0})})}),d.jsx(vg,{open:l,onOpenChange:U,onCaptured:I,validateFile:T,accept:N,disabled:i,onValidationMessage:f})]})},e_=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a,buttonResponses:c})=>{const u=e.properties,f=w.useRef(null),[l,p]=w.useState(),[g,m]=w.useState(!1),[h,y]=w.useState(()=>new Set),[S,v]=w.useState("none"),A=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,x=e.validation?.find(te=>te.type==="fileSize"),F=e.validation?.find(te=>te.type==="fileType"),N=x?.value?x.value:u?.maxSize??A?.maxSize??5*1024*1024,k=F?.value?F.value:u?.accept??A?.accept??["image/*"],T=Array.isArray(k)?k.join(","):"image/*",P=Zi(e),E=w.useCallback(te=>{if(x){const oe=rn(te,x);if(oe!==!0)return typeof oe=="string"?oe:"File size exceeds the maximum allowed size"}else if(te.size>N)return`File size must be less than ${Fo(N)}`;if(F){const oe=rn(te,F);if(oe!==!0)return typeof oe=="string"?oe:"File type is not allowed"}return null},[x,F,N]),C=w.useMemo(()=>es(t),[t]),I=xc(C),W=w.useCallback(te=>{const oe=Za(te,P);r(oe),n?.()},[r,n,P]),M=w.useCallback(te=>{p(void 0);const oe=Array.from(te),me=[...C];let Me=null;for(const De of oe){if(me.length>=P)break;const ne=E(De);if(ne){Me||(Me=ne);continue}me.push(De)}if(Me&&me.length===C.length){p(Me);return}Me&&p(Me),W(me),v("none")},[C,P,E,W]),U=w.useCallback(te=>{const oe=te.target.files;oe&&oe.length>0&&M(oe),f.current&&(f.current.value="")},[M]),V=w.useCallback(te=>{W(C.filter((oe,me)=>me!==te))},[C,W]),X=w.useCallback(()=>{i||C.length>=P||g||(p(void 0),v("file"),f.current?.click())},[i,C.length,P,g]),B=w.useCallback(()=>{i||C.length>=P||(p(void 0),v("camera"),m(!0))},[i,C.length,P]),L=w.useCallback(te=>{const oe=E(te);if(oe){p(oe);return}p(void 0);const me=[...C];me.length>=P||(me.push(te),W(me),v("none"))},[C,P,E,W]),D=w.useCallback(te=>{m(te),te||v("none")},[]),K=o||l,ae=e.appearance?.hideLabel??!1,j=[];(x||N)&&j.push(`Max size: ${Fo(N)}`),F&&k.length>0&&j.push(`Allowed: ${k.join(", ")}`),P>1&&j.push(`Up to ${P} photos`);const z=w.useMemo(()=>{if(!c)return null;const te=Object.values(c);for(let oe=te.length-1;oe>=0;oe-=1){const me=te[oe],Me=typeof me?.status=="string"?me.status.toLowerCase():null;if(Me&&Me!=="success")continue;const De=me?.code;if(typeof De=="number"&&(De<200||De>=300))continue;const ne=me?.data,ge=ne?.file_url||ne?.fileUrl||me?.file_url||me?.fileUrl;if(typeof ge=="string"&&ge.trim())return ge.trim()}return null},[c]),le=w.useCallback(te=>{window.open(te,"_blank","noopener,noreferrer")},[]),ie=C.length===0,G=C.length<P,ee=vc(P,C.length),Ae=G&&!g?d.jsxs("div",{"data-no-open-picker":!0,className:"h-[56px] w-[56px] min-w-[56px] flex-shrink-0 rounded border border-dashed border-muted-foreground/40 flex flex-col items-center justify-center gap-0.5 text-muted-foreground",children:[d.jsx("button",{type:"button",disabled:i,onClick:te=>{te.stopPropagation(),X()},className:"flex flex-1 w-full items-center justify-center hover:bg-primary/10 rounded-t","aria-label":"Upload file",title:"Upload",children:d.jsx(ds,{className:"h-4 w-4","aria-hidden":!0})}),d.jsx("button",{type:"button",disabled:i,onClick:te=>{te.stopPropagation(),B()},className:"flex flex-1 w-full items-center justify-center hover:bg-primary/10 rounded-b border-t border-border/50","aria-label":"Open camera",title:"Camera",children:d.jsx(ls,{className:"h-4 w-4","aria-hidden":!0})})]}):void 0;return d.jsxs(At,{field:e,error:K,isRequired:s,className:H(a,"!space-y-0"),hideLabel:ae,children:[d.jsx("div",{className:"h-[70px] min-h-[70px] min-w-0 w-full flex flex-col",children:d.jsxs("div",{className:H("border-2 border-dashed rounded-lg p-1.5 transition-colors flex-1 min-h-0 flex flex-col items-center justify-center","hover:border-primary hover:bg-primary/5",K&&"border-destructive",i&&"opacity-50"),children:[d.jsx("input",{ref:f,id:ft(e),type:"file",accept:T,multiple:P>1,onChange:U,disabled:i||e.disabled||g||!G,className:"hidden","aria-describedby":Lt(e,!!K),"aria-invalid":Xt(!!K),"aria-required":s}),ie?d.jsxs("div",{className:"flex flex-col items-center justify-center gap-1 w-full pointer-events-auto",children:[d.jsxs("div",{className:"flex items-center justify-center gap-3",children:[d.jsxs("button",{type:"button",disabled:i||g,onClick:X,className:H("inline-flex flex-col items-center gap-0.5 text-[11px] text-muted-foreground hover:text-foreground",i&&"pointer-events-none"),children:[d.jsx(ds,{className:"h-5 w-5","aria-hidden":!0}),d.jsx("span",{children:"Upload"})]}),d.jsxs("button",{type:"button",disabled:i,onClick:B,className:H("inline-flex flex-col items-center gap-0.5 text-[11px] text-muted-foreground hover:text-foreground",i&&"pointer-events-none",g&&"opacity-70"),children:[d.jsx(ls,{className:"h-5 w-5","aria-hidden":!0}),d.jsx("span",{children:"Camera"})]})]}),j.length>0&&d.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-2 text-center px-1",children:j.join(" • ")})]}):ee?d.jsx(Ac,{item:C[0],objectUrl:I[0]??null,failedUrlKeys:h,onImageUrlError:te=>y(oe=>new Set(oe).add(te)),onRemove:()=>V(0),onOpenUrl:le,openTarget:C[0]instanceof File?z:void 0,disabled:i||e.disabled}):d.jsx(Sc,{items:C,maxFiles:P,disabled:i,objectUrls:I,failedUrlKeys:h,onImageUrlError:te=>y(oe=>new Set(oe).add(te)),onRemove:V,resolveOpenUrl:(te,oe)=>oe instanceof File&&C.length===1&&z?z:null,onOpenUrl:te=>{te?.trim()&&le(te.trim())},addSlot:Ae})]})}),d.jsx(vg,{open:g,onOpenChange:D,onCaptured:L,validateFile:E,accept:T,disabled:i,onValidationMessage:p})]})};function t_(e){if(e==null||typeof e!="object")return;const t=e;if(typeof t.message=="string"&&t.message.trim())return t.message.trim();if(typeof t.display_message=="string"&&t.display_message.trim())return t.display_message.trim();if(t.data&&typeof t.data=="object"){const r=t.data;if(typeof r.message=="string"&&r.message.trim())return r.message.trim();if(typeof r.success_message=="string"&&r.success_message.trim())return r.success_message.trim();if(typeof r.display_message=="string"&&r.display_message.trim())return r.display_message.trim()}if(typeof t.success_message=="string"&&t.success_message.trim())return t.success_message.trim()}function wg(e,t){try{const r=t_(e);at.toast.success(r&&r.trim()?r:t)}catch{at.toast.success(t)}}function la(e,t,r){try{const n=r(e);at.toast.error(n&&n.trim()?n:t)}catch{at.toast.error(t)}}function r_(e){const t=e.headers,r=["X-Message","X-Success-Message","X-Toast-Message","X-Success-Msg"];for(const n of r){const o=t.get(n);if(o&&typeof o=="string"&&o.trim())return o.trim()}}const ca="This field is required";function Sg(e,t){if(!t?.length)return e;const r=t.find(n=>n.name===e);return r?.label&&r.label.trim()||e}function da(e,t){if(!e)return"Please complete the required fields.";if(Array.isArray(e)){const i=e.map(s=>{const a=s.message||ca;if(t?.length&&s.field){const c=Sg(s.field,t);return a===ca?`${c} is required`:`${c}: ${a}`}return a}).filter(s=>typeof s=="string"&&s.length>0);return i.length===0?"Please complete the required fields.":i.length===1?i[0]:`${i[0]} (and ${i.length-1} more)`}const n=Object.entries(e).map(([o,i])=>{const s=i?.trim()||ca;if(t?.length){const a=Sg(o,t);return s===ca?`${a} is required`:`${a}: ${s}`}return s}).filter(o=>typeof o=="string"&&o.length>0);return n.length===0?"Please complete the required fields.":n.length===1?n[0]:`${n[0]} (and ${n.length-1} more)`}function xg(e){if(e==null||typeof e!="object")return!1;const t=e;if(t.status==="error")return!0;const r=t.code;return typeof r=="number"&&(r<200||r>=300)}function n_(e){return!xg(e)}function o_(e,t,r){if(!t||!n_(e))return;const n=t.fieldMapping;if(n&&Object.keys(n).length>0)for(const[i,s]of Object.entries(n)){if(!i.trim()||!s?.trim())continue;const a=We(e,s.trim());a!=null&&r.setFieldValue(i.trim(),a)}const o=t.contextMapping;if(o&&Object.keys(o).length>0&&r.onContextUpdate){const i={};for(const[s,a]of Object.entries(o)){if(!s.trim()||!a?.trim())continue;const c=We(e,a.trim());c!=null&&(i[s.trim()]=c)}Object.keys(i).length>0&&r.onContextUpdate(i)}}function i_(e=Gn){const{totalSteps:t,currentStep:r}=e.getState();return t>1&&r<t-1}async function kc(e,t=Gn){const r=await t.getState().nextStep();if(!r)try{const n=t.getState(),o=n.errors;Object.keys(o).length>0?at.toast.error(da(o,e)||"Please fix the errors before continuing."):n.totalSteps<=1||n.currentStep>=n.totalSteps-1?at.toast.error("You are already on the last page."):at.toast.error("Please fix the errors before continuing.")}catch{at.toast.error("Please fix the errors before continuing.")}return r}function s_(e=Gn){e.getState().prevStep()}const a_=3;function Po(e){if(typeof e=="number"&&!Number.isNaN(e))return e}function Oo(e,t){const r=e&&typeof e=="object"&&!Array.isArray(e)?e:void 0;return Po(r?.cellSlot)??Po(r?.stackSlot)??Po(r?.cellSlotIndex)??Po(r?.slotIndex)??Po(t?.cellSlotIndex)??Po(t?.stackSlot)}function Ei(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:void 0;if(t?.sharedCellLayout==="row"||t?.sharedCellLayout==="stack")return t.sharedCellLayout;if(t?.stackDirection==="horizontal")return"row";if(t?.stackDirection==="vertical")return"stack"}function ua(e){const t=typeof e.position?.order=="number"?e.position.order:-1,r=typeof e.position?.column=="number"?e.position.column:1,n=e.position?.cellGroupId??"_";return`${t}:${r}:${n}`}function _c(e){return[...e].sort((t,r)=>{const n=Oo(t.position),o=Oo(r.position);return typeof n=="number"&&typeof o=="number"&&n!==o?n-o:String(t.id).localeCompare(String(r.id))})}function Ni(e,t){if(e.length===0)return{rowSpan:1,columnSpan:1};let r=1,n=1;for(const o of e)r=Math.max(r,Xo(o)),n=Math.max(n,nu(o,t));return{rowSpan:r,columnSpan:n}}function Ag(e){const t=_c(e);for(const r of t){const n=Ei(r.position);if(n)return n}return t.length>=2?"row":"stack"}function Cg(e){return _c(e).slice(0,a_)}function l_(e,t){const r=new Map;for(const n of e){if(!t(n)||typeof n.position?.order!="number")continue;const o=ua(n),i=r.get(o)??[];i.push(n),r.set(o,i)}return Array.from(r.values()).map(n=>Cg(n))}function Eg(e,t,r,n){const o=r.filter(a=>n(a)&&typeof a.position?.order=="number"&&a.position.order===e&&(a.position.column??1)===t+1);if(o.length===0)return[];const i=new Map;for(const a of o){const c=ua(a),u=i.get(c)??[];u.push(a),i.set(c,u)}const s=[...i.values()][0]??[];return Cg(s)}function c_(e,t,r,n){const o=r[0],i=o.position?.order,s=o.position?.column??1;if(typeof i!="number")return!1;const{rowSpan:a,columnSpan:c}=Ni(r,n),u=e===i&&t===s-1,f=e>=i&&e<i+a,l=t>=s-1&&t<s-1+c;return f&&l&&!u}function d_(e,t,r){const n=new Set(r??[]);for(const o of e){const i=o[0]?.position?.order??0,{rowSpan:s}=Ni(o,t);for(let a=i;a<i+s;a++)n.add(a)}return n}function u_(e){const t=[...e].sort((n,o)=>n-o),r=new Map;return t.forEach((n,o)=>r.set(n,o)),{originalToDisplay:r,displayRowCount:Math.max(t.length,1),sortedOriginalRows:t}}function f_(e,t,r){const n=r.get(e);if(n===void 0)return;let o=0;for(let i=e;i<e+t&&r.has(i);i++)o++;return`${n+1} / span ${Math.max(o,1)}`}function gr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Io(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(r=>Io(r));if(!gr(e))return e;const t={};for(const[r,n]of Object.entries(e))t[r]=Io(n);return t}function Ng(e,...t){const r={...e};for(const n of t)if(!(!n||!gr(n)))for(const[o,i]of Object.entries(n)){const s=r[o];gr(i)&&gr(s)?r[o]=Ng(s,i):r[o]=i}return r}function oo(e){return gr(e)?e:{}}function ki(e){if(e==null)return{};if(typeof e=="string"){const t=e.trim();if(!t)return{};try{const r=JSON.parse(t);return gr(r)?Io(r):{}}catch{return{}}}return gr(e)?Io(e):{}}function kg(e){const t=e.apidata;return gr(t)&&Object.keys(t).length>0}function p_(e){if(typeof e.metadata=="string"&&e.metadata.trim()!==""||typeof e.metadata=="object"&&e.metadata!==null&&!Array.isArray(e.metadata)&&Object.keys(e.metadata).length>0||kg(e))return!0;const t=e.fieldKey,r=e.fieldType,n=e.name,o=e.type;return!!(t&&(!n||String(n).trim()==="")||r&&(!o||String(o).trim()==="")||t&&n&&t!==n||r&&o&&r!==o||!n&&e.key&&typeof e.key=="string")}const _g=["hideLabel","contentAlign","contentVerticalAlign","labelPlacement","widthPercent","widthMode","className","verticalAlign","horizontalAlign","cellAlign","cellJustify","size","variant","minWidth","minHeight"];function m_(e,t){const r=e.appearance,n=gr(r)&&Object.keys(r).length>0?Io(r):{},o=oo(t.appearance),i={...n};for(const[s,a]of Object.entries(o))s!=="heightPercent"&&i[s]===void 0&&(i[s]=Io(a));for(const s of _g)i[s]===void 0&&t[s]!==void 0&&(i[s]=t[s]);return delete i.heightPercent,Object.keys(i).length>0?i:void 0}function h_(e,t){const r=oo(e.position),n=ki(e.metadata),o=oo(e.layout),i=typeof r.order=="number"&&!Number.isNaN(r.order)?r.order:typeof e.positionOrder=="number"?e.positionOrder:typeof e.order=="number"?e.order:typeof e.positionRow=="number"?e.positionRow:t,s=typeof r.column=="number"&&!Number.isNaN(r.column)?r.column:typeof e.positionColumn=="number"?e.positionColumn:1,a=typeof r.columnSpan=="number"&&!Number.isNaN(r.columnSpan)?r.columnSpan:typeof e.positionWidth=="number"?e.positionWidth:1,c=typeof r.rowSpan=="number"&&!Number.isNaN(r.rowSpan)?r.rowSpan:typeof e.positionRowSpan=="number"?e.positionRowSpan:1,u={order:i,column:s,columnSpan:a,rowSpan:c},f=r.cellGroupId??o.cellGroupId,l=Oo(r,{cellSlotIndex:e.cellSlotIndex??o.cellSlotIndex,stackSlot:n.stackSlot??o.stackSlot}),p=Ei(r)??Ei(o)??(n.stackDirection==="horizontal"||o.stackDirection==="horizontal"?"row":n.stackDirection==="vertical"||o.stackDirection==="vertical"?"stack":void 0);return typeof f=="string"&&(u.cellGroupId=f),typeof l=="number"&&(u.cellSlot=l),(p==="row"||p==="stack")&&(u.sharedCellLayout=p),u}function g_(e,t){const r=e,n=ki(r.metadata),o=oo(r.apidata),i=oo(r.properties),s=Ng({},n,o,i),a=(r.name!=null&&String(r.name).trim()!==""?r.name:void 0)??(typeof r.fieldKey=="string"?r.fieldKey:void 0)??(typeof r.key=="string"?r.key:void 0),c=(r.type!=null&&String(r.type).trim()!==""?r.type:void 0)??(typeof r.fieldType=="string"?r.fieldType:void 0),u=m_(r,n),f=h_(r,t),l={...r};return l.properties=s,a!==void 0&&(l.name=a),c!==void 0&&(l.type=c),u!==void 0?l.appearance=u:(!gr(r.appearance)||Object.keys(r.appearance).length===0)&&delete l.appearance,l.position=f,gr(l.appearance)&&delete l.appearance.heightPercent,l}function y_(e,t){if(!e||typeof e!="object")return!0;const r=e,n=ki(r.metadata),o=Object.keys(n).length===0&&!(typeof r.metadata=="string"&&r.metadata.trim()!==""),i=!kg(r);if(p_(r)||!o||!i)return!1;const s=r.position;return!(!(gr(s)&&typeof s.order=="number"&&!Number.isNaN(s.order))&&(typeof r.positionRow=="number"||typeof r.positionColumn=="number"||typeof r.positionWidth=="number"||typeof r.positionRowSpan=="number"||typeof r.positionOrder=="number")||gr(n.appearance)||_g.some(u=>n[u]!==void 0&&(r.appearance==null||gr(r.appearance)&&r.appearance[u]===void 0))||b_(r))}function b_(e){const t=oo(e.position),r=oo(e.layout),n=ki(e.metadata);return(typeof e.cellSlotIndex=="number"||typeof t.stackSlot=="number"||typeof t.cellSlot=="number"||typeof t.cellSlotIndex=="number"||typeof n.stackSlot=="number"||typeof r.stackSlot=="number")&&typeof t.cellSlot!="number"||(t.stackDirection==="horizontal"||t.stackDirection==="vertical"||n.stackDirection==="horizontal"||n.stackDirection==="vertical"||r.stackDirection==="horizontal"||r.stackDirection==="vertical")&&t.sharedCellLayout!=="row"&&t.sharedCellLayout!=="stack"}function fa(e){if(e==null||typeof e!="object")return e;const t=e.fields;if(!Array.isArray(t))return e;let r=!1;const n=t.map((o,i)=>{if(y_(o))return o;const s=g_(o,i);return s!==o&&(r=!0),s});return r?{...e,fields:n}:e}function v_(e){return fa(e)}function w_(e){const t=e.steps;if(!Array.isArray(t)||t.length<2)return;const r=[];for(const n of t){if(!n||typeof n!="object")continue;const o=n,i=typeof o.id=="string"&&o.id.trim()?o.id.trim():void 0,s=typeof o.name=="string"&&o.name.trim()?o.name.trim():void 0,a=Array.isArray(o.fields)?o.fields.filter(c=>typeof c=="string"&&c.trim()!==""):[];!i||!s||r.push({id:i,name:s,...typeof o.description=="string"&&o.description.trim()?{description:o.description.trim()}:{},fields:a,validation:o.validation==="onSubmit"?"onSubmit":"onNext"})}return r.length>=2?r:void 0}function Tc(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function Tg(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}function Fg(e,t){const r=e.form;if(!r)throw new Error("workflowStateToFormSchema requires workflowState.form to be set");const n=r.fields.filter(l=>l!=null&&l!==void 0).map((l,p)=>{if(!l||typeof l!="object")return null;const g={...l};if(l.fieldType&&!g.type&&(g.type=l.fieldType),l.fieldKey&&!g.key&&!g.name&&(g.key=l.fieldKey,g.name=l.fieldKey),typeof l.positionOrder=="number"&&!isNaN(l.positionOrder)?g.order=l.positionOrder:g.order=p,(typeof g.order!="number"||isNaN(g.order))&&(g.order=p),l.options&&typeof l.options=="string")try{g.options=JSON.parse(l.options)}catch{}if(l.metadata&&typeof l.metadata=="string")try{g.metadata=JSON.parse(l.metadata)}catch{}return g}).filter(l=>l!=null).sort((l,p)=>{const g=typeof l.order=="number"?l.order:0,m=typeof p.order=="number"?p.order:0;return g-m});n.forEach((l,p)=>{(!l||typeof l.order!="number"||isNaN(l.order))&&(l.order=p)});let o=r.layout;if(o){const l={...o};if(l.breakpoints&&typeof l.breakpoints=="string")try{l.breakpoints=JSON.parse(l.breakpoints)}catch{}if(l.responsiveConfig&&typeof l.responsiveConfig=="string")try{l.responsiveConfig=JSON.parse(l.responsiveConfig)}catch{}o=l}const i=n.filter(l=>l!=null&&typeof l=="object"&&typeof l.order=="number"&&!isNaN(l.order));let s={};const a=r.config;if(a!=null)if(typeof a=="string")try{s=JSON.parse(a)}catch{}else typeof a=="object"&&a!==null&&(s={...a});const c=l=>{let p={...l};if(l.conditionExpression&&typeof l.conditionExpression=="string")try{p={...l,conditionExpression:JSON.parse(l.conditionExpression)}}catch{}if(p.targetFieldId){const g=i.find(m=>m._id===p.targetFieldId||m.id===p.targetFieldId||m.fieldKey===p.targetFieldId);if(g){const m=g.key||g.fieldKey||g.name,h=g._id||g.id||p.targetFieldId;p.targetFieldKey=m,p.targetField=m,p.targetFieldById=h}}return p},u=w_(r),f={id:r._id,name:r.name,description:r.description??"",version:r.version,status:r.status,fields:i.map((l,p)=>{const g=l,m=typeof l.metadata=="object"&&l.metadata!==null?l.metadata:{},h=m.hidden===!0||l.hidden===!0,y={id:l._id||l.id||l.fieldKey,type:l.type||l.fieldType,label:l.label,key:l.key||l.fieldKey||l.name,name:l.name||l.fieldKey||l.key};if(h&&(y.hidden=!0),y.id||(y.id=y.key||y.name),y.key||(y.key=y.id||y.name),y.name||(y.name=y.key||y.id),l.isRequired!==void 0&&(y.required=l.isRequired),l.placeholder&&(y.placeholder=l.placeholder),l.options&&Array.isArray(l.options)&&(y.options=l.options),l.apidata&&(y.apidata=l.apidata),g.appearance&&typeof g.appearance=="object"&&!Array.isArray(g.appearance)&&Object.keys(g.appearance).length>0&&(y.appearance=Tc(g.appearance)),g.ui!==void 0&&(y.ui=Tc(g.ui)),g.visibility!==void 0&&(y.visibility=Tc(g.visibility)),m.disabled!==void 0&&(y.disabled=m.disabled),m.readOnly!==void 0&&(y.readOnly=m.readOnly),m.hideLabel!==void 0&&(y.hideLabel=m.hideLabel,y.properties||(y.properties={}),y.properties.hideLabel=m.hideLabel,y.appearance||(y.appearance={}),y.appearance.hideLabel=m.hideLabel),(l.type==="file"||l.fieldType==="file"||l.type==="camera"||l.fieldType==="camera"||l.type==="photoChoice"||l.fieldType==="photoChoice")&&l.validationRules){const E=l.validationRules,C={...m};if(E.fileSize!==void 0&&(C.maxSize=E.fileSize),E.fileType&&Array.isArray(E.fileType)){const I=[];E.fileType.forEach(W=>{const M=W.startsWith(".")?W:`.${W}`;I.push(M),M===".csv"?I.push("text/csv"):M===".xls"?I.push("application/vnd.ms-excel"):M===".xlsx"&&I.push("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")}),C.accept=I}y.metadata=C,C.maxSize!==void 0&&(y.maxSize=C.maxSize),C.accept!==void 0&&(y.accept=C.accept)}else if(m&&Object.keys(m).length>0){if(y.metadata=m,(l.type==="toggle"||l.fieldType==="toggle")&&(m.onValue!==void 0&&(y.onValue=m.onValue),m.offValue!==void 0&&(y.offValue=m.offValue),m.onText!==void 0&&(y.onText=m.onText),m.offText!==void 0&&(y.offText=m.offText)),(l.type==="button"||l.fieldType==="button")&&m.action==="download"&&m.downloadApiEndpoint&&typeof m.downloadApiEndpoint=="string"){let E=m.downloadApiEndpoint;E=E.replace(/\{ctx:([^}]+)\}/g,(C,I)=>{const W=t[I];return W!==void 0?String(W):C}),m.downloadApiEndpoint=E,y.metadata=m,y.downloadApiEndpoint=E}if((l.type==="button"||l.fieldType==="button")&&m.action==="submit"){const E=y.properties||{};m.submitAction!==void 0&&(E.submitAction=m.submitAction),m.submitApiMethod!==void 0&&(E.submitApiMethod=m.submitApiMethod),m.apiBodyStructure!==void 0&&(E.apiBodyStructure=m.apiBodyStructure),m.apiBodyFieldsOnly!==void 0&&(E.apiBodyFieldsOnly=m.apiBodyFieldsOnly),m.apiBodyFieldsOnlyFormat!==void 0&&(E.apiBodyFieldsOnlyFormat=m.apiBodyFieldsOnlyFormat),m.apiBodyFields!==void 0&&(E.apiBodyFields=m.apiBodyFields),m.buttonText!==void 0&&(E.buttonText=m.buttonText),m.action!==void 0&&(E.action=m.action),m.variant!==void 0&&(E.variant=m.variant),m.hideLabel!==void 0&&(E.hideLabel=m.hideLabel),l.apidata&&typeof l.apidata=="object"&&l.apidata.apiEndpoint&&(E.apiEndpoint=l.apidata.apiEndpoint),y.properties=E}if((l.type==="button"||l.fieldType==="button")&&(m.action==="upload"||m.action==="custom")){const E=y.properties||{};m.action!==void 0&&(E.action=m.action),m.buttonText!==void 0&&(E.buttonText=m.buttonText),m.variant!==void 0&&(E.variant=m.variant),m.hideLabel!==void 0&&(E.hideLabel=m.hideLabel),m.uploadAction!==void 0&&(E.uploadAction=m.uploadAction),m.uploadApiEndpoint!==void 0&&(E.uploadApiEndpoint=m.uploadApiEndpoint),m.uploadApiMethod!==void 0&&(E.uploadApiMethod=m.uploadApiMethod),m.apiBodyStructure!==void 0&&(E.apiBodyStructure=m.apiBodyStructure),m.apiBodyFieldsOnly!==void 0&&(E.apiBodyFieldsOnly=m.apiBodyFieldsOnly),m.apiBodyFieldsOnlyFormat!==void 0&&(E.apiBodyFieldsOnlyFormat=m.apiBodyFieldsOnlyFormat),m.apiFieldMapping!==void 0&&(E.apiFieldMapping=m.apiFieldMapping),m.apiQueryParams!==void 0&&(E.apiQueryParams=m.apiQueryParams),m.apiBodyFields!==void 0&&(E.apiBodyFields=m.apiBodyFields),m.apiHeaders!==void 0&&(E.apiHeaders=m.apiHeaders),y.properties=E}if(l.type==="status"||l.fieldType==="status"){const E=y.properties||{};if(m.source!==void 0&&(E.source=m.source),m.statuses!==void 0&&(E.statuses=m.statuses),m.dataPath!==void 0&&(E.dataPath=m.dataPath),m.showStatusText!==void 0&&(E.showStatusText=m.showStatusText),m.statusTextPath!==void 0&&(E.statusTextPath=m.statusTextPath),m.showCurrentIndicator!==void 0&&(E.showCurrentIndicator=m.showCurrentIndicator),l.apidata&&typeof l.apidata=="object"&&l.apidata.apiEndpoint){let C=l.apidata.apiEndpoint;C=C.replace(/\{ctx:([^}]+)\}/g,(I,W)=>{const M=t[W];return M!==void 0?String(M):I}),E.apiEndpoint=C,E.source===void 0&&(E.source="api")}l.apidata?.apiMethod!==void 0&&(E.apiMethod=l.apidata.apiMethod),y.properties=E}if(l.type==="addmore"||l.fieldType==="addmore"){const E=y.properties||{};m.linkedFieldNames!==void 0&&(E.linkedFieldNames=m.linkedFieldNames),m.linkedSectionIds!==void 0&&(E.linkedSectionIds=m.linkedSectionIds),m.linkedFieldAllowDuplicate!==void 0&&(E.linkedFieldAllowDuplicate=m.linkedFieldAllowDuplicate),m.buttonText!==void 0&&(E.buttonText=m.buttonText),m.variant!==void 0&&(E.variant=m.variant),m.size!==void 0&&(E.size=m.size),m.hideLabel!==void 0&&(E.hideLabel=m.hideLabel),y.properties=E}if(l.type==="selectablelist"||l.fieldType==="selectablelist"){const E=y.properties||{};m.submitFieldMapping!==void 0&&(E.submitFieldMapping=m.submitFieldMapping),m.displayFields!==void 0&&(E.displayFields=m.displayFields),m.displayFieldsSeparator!==void 0&&(E.displayFieldsSeparator=m.displayFieldsSeparator),m.dataSourceContextKey!==void 0&&(E.dataSourceContextKey=m.dataSourceContextKey),m.showSelectAll!==void 0&&(E.showSelectAll=m.showSelectAll),m.selectAllByDefault!==void 0&&(E.selectAllByDefault=m.selectAllByDefault),y.properties=E}}l.validationRules&&l.type!=="file"&&l.fieldType!=="file"&&l.type!=="camera"&&l.fieldType!=="camera"&&l.type!=="photoChoice"&&l.fieldType!=="photoChoice"&&l.type!=="status"&&l.fieldType!=="status"&&(y.validationRules=l.validationRules),typeof l.order=="number"&&(y.order=l.order);const S=l,v=Tg(S.position),A=l.metadata&&typeof l.metadata=="object"&&!Array.isArray(l.metadata)?l.metadata:{},x=Tg(S.layout),N={order:typeof S.positionOrder=="number"?S.positionOrder:l.order??p,column:typeof v.column=="number"?v.column:typeof S.positionColumn=="number"?S.positionColumn:1,columnSpan:typeof v.columnSpan=="number"?v.columnSpan:typeof v.width=="number"?v.width:typeof S.positionWidth=="number"?S.positionWidth:1,rowSpan:typeof v.rowSpan=="number"?v.rowSpan:typeof S.positionRowSpan=="number"?S.positionRowSpan:1},k=Oo(v,{cellSlotIndex:S.cellSlotIndex??x.cellSlotIndex,stackSlot:A.stackSlot??x.stackSlot});typeof k=="number"&&(N.cellSlot=k);const T=v.cellGroupId??x.cellGroupId;typeof T=="string"&&(N.cellGroupId=T);const P=Ei(v)??Ei(x)??(A.stackDirection==="horizontal"||x.stackDirection==="horizontal"?"row":A.stackDirection==="vertical"||x.stackDirection==="vertical"?"stack":void 0);return(P==="row"||P==="stack")&&(N.sharedCellLayout=P),y.position=N,l.conditions&&Array.isArray(l.conditions)&&(y.conditions=l.conditions),y}).filter(l=>l!=null).sort((l,p)=>{const g=typeof l.order=="number"?l.order:0,m=typeof p.order=="number"?p.order:0;return g-m}),config:{...s,layout:o,...r.rules&&r.rules.length>0&&{rules:r.rules.map(c)},...r.clientMapping&&Object.keys(r.clientMapping).length>0&&{clientMapping:r.clientMapping}},...r.rules&&r.rules.length>0&&{rules:r.rules.map(c)},createdAt:"",updatedAt:"",moduleId:"",...u?{steps:u}:{}};return fa(f)}function wn({className:e,size:t="md",text:r="Loading...",fullScreen:n=!1}){const o={sm:"h-6 w-6",md:"h-12 w-12",lg:"h-16 w-16"},i=d.jsxs("div",{className:"text-center",children:[d.jsx("div",{className:H("animate-spin rounded-full border-b-2 border-blue-600 mx-auto mb-4",o[t],e)}),r&&d.jsx("p",{className:"text-gray-600",children:r})]});return n?d.jsx("div",{className:"min-h-screen bg-gradient-to-br from-blue-50 via-white to-indigo-50 flex items-center justify-center",children:i}):i}function S_(e,t){if(!e?.url)return;let r=e.url;if(r.startsWith("http://")||r.startsWith("https://"))try{const i=new URL(r);r=i.pathname+i.search}catch{}const n=t?.()??{},o={...e.headers||{},"Content-Type":"application/json",...n};return{...e,url:r,headers:o}}const Pg=({open:e,onOpenChange:t,title:r,mode:n,loading:o=!1,workflowState:i,formSchema:s,formDefinitionId:a,submissionContext:c={},onWorkflowSubmitResult:u,getAuthHeaders:f})=>{const l=w.useMemo(()=>{if(n==="form"&&s)return s;if(n==="workflow"&&i?.form){const g=Object.fromEntries(Object.entries(c).map(([y,S])=>[y,S==null?"":String(S)])),m=Fg(i,g),h=S_(i.BFF_submit_api,f);return h?{...m,status:"published",BFF_submit_api:h}:m}return null},[n,s,i,c,f]),p=i?.step_blocked_message;return d.jsx(mg,{open:e,onOpenChange:t,children:d.jsxs(hg,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[r?d.jsx(gg,{children:d.jsx(yg,{children:r})}):null,d.jsxs("div",{className:"relative min-h-[12rem]",children:[o&&d.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/60 rounded-md",children:d.jsx(wn,{})}),p&&d.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:p}),l?d.jsx(ll,{children:d.jsx(Di,{schema:l,submissionContext:c,onWorkflowSubmitResult:u,onClose:()=>t(!1),workflowStepId:i?.current_step_id,omitRootWrapper:!0})}):a&&n==="form"?d.jsx(ll,{children:d.jsx(Di,{formId:a,submissionContext:c,onClose:()=>t(!1),omitRootWrapper:!0})}):!o&&d.jsx("p",{className:"text-sm text-muted-foreground",children:n==="workflow"?"No form available for this step.":"Form could not be loaded."})]})]})})},Og=w.createContext(null);function Ig(){return w.useContext(Og)}function Fc(e,t){if(!e?.length||!t)return{};const r={};return e.forEach(n=>{t[n]!==void 0&&(r[n]=t[n])}),r}const Mg=({handlers:e,moduleId:t,submissionContext:r={},getAuthHeaders:n,onParentWorkflowSubmitResult:o,children:i})=>{const[s,a]=w.useState(!1),[c,u]=w.useState(),[f,l]=w.useState("workflow"),[p,g]=w.useState(null),[m,h]=w.useState(null),[y,S]=w.useState(),[v,A]=w.useState({}),[x,F]=w.useState(!1),N=w.useMemo(()=>({...r,...v}),[r,v]),k=w.useCallback(()=>{a(!1),g(null),h(null),S(void 0),A({})},[]),T=w.useCallback(async(W,M)=>{if(!W.workflowId?.trim())throw new Error("workflowId is required for openWorkflowModal");const U=Fc(W.passFields,M);F(!0),u(W.modalTitle),l("workflow"),A(U);try{const V=await e.getWorkflowStateById({workflowId:W.workflowId.trim(),moduleId:t,entryStepId:W.entryStepId?.trim()||void 0,passContext:U});g(V),h(null),S(void 0),a(!0)}finally{F(!1)}},[e,t]),P=w.useCallback(async(W,M)=>{if(!W.formDefinitionId?.trim())throw new Error("formDefinitionId is required for openFormModal");const U=Fc(W.passFields,M);F(!0),u(W.modalTitle),l("form"),A(U),g(null);try{if(e.getFormSchemaById){const V=await e.getFormSchemaById(W.formDefinitionId.trim());h(V),S(void 0)}else h(null),S(W.formDefinitionId.trim());a(!0)}finally{F(!1)}},[e]),E=w.useCallback(async(W,M)=>{const U=M?.workflowId?.trim()||p?.workflow_id||"";if(!U||!W?.trim())throw new Error("workflowId and targetStepId are required for gotoStep");const V={...v,...Fc(void 0,M?.formValues)};F(!0);try{const X=await e.navigateWorkflowStep({workflowId:U,moduleId:t,targetStepId:W.trim(),passContext:V});s?(g(X),l("workflow"),h(null),S(void 0)):o?.(X)}finally{F(!1)}},[e,t,v,s,p?.workflow_id,o]),C=w.useCallback(async W=>{o?.(W);const M=p?.workflow_id;if(M)try{const U=await e.getWorkflowStateById({workflowId:M,moduleId:t,passContext:v});g(U)}catch{}},[e,t,v,o,p?.workflow_id]),I=w.useMemo(()=>({isModalActive:s,openWorkflowModal:T,openFormModal:P,navigateToStep:E}),[s,T,P,E]);return d.jsxs(Og.Provider,{value:I,children:[i,d.jsx(Pg,{open:s,onOpenChange:W=>{W||k()},title:c,mode:f,loading:x,workflowState:p,formSchema:m,formDefinitionId:y,submissionContext:N,onWorkflowSubmitResult:C,getAuthHeaders:n})]})};function Pc(e,t){if(!t?.length)return e;const r=new Map;for(const o of t){const i=o.name||o.key||o.id;i&&r.set(i,o)}const n={};for(const[o,i]of Object.entries(e)){const s=r.get(o);if(s?.type==="selectablelist"&&Array.isArray(i)&&i.length>0){const a=s.properties,c=s.metadata,u=typeof c=="object"&&c!==null?c:null,f=a?.submitFieldMapping??u?.submitFieldMapping;if(f&&typeof f=="object"&&Object.keys(f).length>0){const l=i.map(p=>{if(p==null||typeof p!="object")return p;const g={};for(const[m,h]of Object.entries(f))m!=null&&m!==""&&h!=null&&h!==""&&(g[m]=We(p,h));return g});n[o]=l;continue}}n[o]=i}return n}function pa(e){return!!(e instanceof File||Array.isArray(e)&&e.length>0&&e[0]instanceof File)}function x_(e){return Object.values(e).some(t=>pa(t))}function A_(e,t){const r=new FormData;let n=!1;return Object.entries(e).forEach(([o,i])=>{const s=t?.[o]||o;i instanceof File?(r.append(s,i),n=!0):Array.isArray(i)&&i.length>0&&i[0]instanceof File?(i.forEach(a=>{r.append(s,a)}),n=!0):i!=null&&(typeof i=="object"?r.append(s,JSON.stringify(i)):r.append(s,String(i)))}),n?r:null}function C_(e,t,r){const n={};let o=!1;return Object.entries(e).forEach(([i,s])=>{const a=t?.[i]||i;if(pa(s)){n[a]=s,o=!0;return}const c=r?.[i]||"string";let u=s;if(c==="number"){const f=Number(s);u=isNaN(f)?s:f}else c==="boolean"?u=s==="true"||s===!0||s==="1"||s===1:c==="date"?u=String(s):s!=null?u=typeof s=="object"?s:String(s):u="";n[a]=u}),{transformed:n,hasFiles:o}}const Lg=Object.freeze(Object.defineProperty({__proto__:null,hasFileValues:x_,isFileValue:pa,prepareFormDataWithFiles:A_,transformFormValuesWithFiles:C_},Symbol.toStringTag,{value:"Module"}));function E_(e){if(!e||typeof e!="object")return;const t=e;return(t.mode==="nested_by_section"?"nested_by_section":"flat")==="flat"?{mode:"flat"}:{mode:"nested_by_section",includeUnassignedAtRoot:t.includeUnassignedAtRoot!==!1}}function N_(e){if(!Array.isArray(e))return;const t=[];for(const r of e){if(!r||typeof r!="object")continue;const n=r,o=typeof n.id=="string"&&n.id.trim()?n.id.trim():"",i=typeof n.name=="string"&&n.name.trim()?n.name.trim():"";if(!o||!i)continue;const s=Array.isArray(n.fieldNames)?[...new Set(n.fieldNames.filter(u=>typeof u=="string"&&u.trim().length>0).map(u=>u.trim()))]:[],a=typeof n.payloadKey=="string"&&n.payloadKey.trim()?n.payloadKey.trim():void 0;let c;if(n.fieldPayloadKeys&&typeof n.fieldPayloadKeys=="object"&&!Array.isArray(n.fieldPayloadKeys)){c={};for(const[u,f]of Object.entries(n.fieldPayloadKeys))typeof f=="string"&&f.trim()&&(c[u]=f.trim());Object.keys(c).length===0&&(c=void 0)}t.push({id:o,name:i,fieldNames:s,...n.showBorder===!0?{showBorder:!0}:{},...n.collapsible===!0?{collapsible:!0}:{},...n.defaultCollapsed===!0?{defaultCollapsed:!0}:{},...a?{payloadKey:a}:{},...c?{fieldPayloadKeys:c}:{},...n.heading&&typeof n.heading=="object"?{heading:n.heading}:{}})}return t.length>0?t:void 0}function Oc(e){return e?.mode==="nested_by_section"}function ma(e,t){return!Oc(t)||!e?.length?!1:e.some(r=>!!r.payloadKey?.trim())}function Mo(e){const t=e.payloadKey?.trim();return t||null}function Lo(e,t){return t.fieldPayloadKeys?.[e]?.trim()||e}function k_(e,t){if(t?.length)return t.find(r=>r.fieldNames.includes(e))}function __(e,t){const r={...e};if(!t?.length)return r;for(const n of t){const o=Mo(n);if(!o)continue;const i=e[o];if(i==null||typeof i!="object"||Array.isArray(i))continue;const s=i;for(const a of n.fieldNames){const c=Lo(a,n);c in s?r[a]=s[c]:a in s&&(r[a]=s[a])}}return r}function Dg(e,t,r){if(e in r)return r[e];const n=Mo(t);if(!n)return;const o=r[n];if(o==null||typeof o!="object"||Array.isArray(o))return;const i=o,s=Lo(e,t);if(s in i)return i[s];if(e in i)return i[e]}function T_(e,t){if(e in t)return t[e]}function Ic(e,t,r,n){if(!Oc(r)||!t?.length)return{...e};const o=new Set([]),i=r?.includeUnassignedAtRoot!==!1,s=new Set,a={};for(const c of t){const u=Mo(c);if(!u)continue;const f={};for(const l of c.fieldNames){if(o.has(l)||!(l in e))continue;s.add(l);const p=Lo(l,c);f[p]=e[l]}Object.keys(f).length>0&&(a[u]=f)}if(i)for(const[c,u]of Object.entries(e))o.has(c)||s.has(c)||(a[c]=u);return a}function Bg(e){return e.apiBodyFieldsOnly?(e.submitPayloadSectionIds?.length??0)>0||(e.submitPayloadRootFields?.length??0)>0:!1}function F_(e,t,r){const n=new Set(r.sectionIds??[]),o=new Set(r.rootFieldNames??[]),i={};if(t?.length&&n.size>0)for(const s of t){if(!n.has(s.id))continue;const a=Mo(s);if(a){const c={};for(const u of s.fieldNames){const f=Dg(u,s,e);f!==void 0&&(c[Lo(u,s)]=f)}Object.keys(c).length>0&&(i[a]=c)}else for(const c of s.fieldNames){const u=Dg(c,s,e);u!==void 0&&(i[c]=u)}}for(const s of o){const a=T_(s,e);a!==void 0&&(i[s]=a)}return i}function $g(e,t){return ma(t.formSections,t.submitPayload)?Ic(e,t.formSections,t.submitPayload):t.apiBodyStructure==="flat"?{...e}:{...t.rootExtras??{},data:{...e}}}function P_(e,t,r,n){const o=n.bodyMapping?.[t]??t;if(ma(n.formSections,n.submitPayload)){const s=k_(t,n.formSections),a=s?Mo(s):null;if(a&&s){const c=e[a]!=null&&typeof e[a]=="object"&&!Array.isArray(e[a])?e[a]:{},u=Lo(t,s);c[u]=r,e[a]=c;return}e[o]=r;return}if(n.apiBodyStructure==="flat"){e[o]=r;return}const i=e.data!=null&&typeof e.data=="object"&&!Array.isArray(e.data)?e.data:{};i[o]=r,e.data=i}function O_(e,t,r){const n={...e??{}};if(!Oc(r)||!t?.length)return n;for(const o of t){const i=Mo(o);if(i)for(const s of o.fieldNames){if(n[s]?.trim())continue;const a=Lo(s,o);n[s]=`${i}.${a}`}}return n}function I_(e,t){return $g(e,{apiBodyStructure:t.apiBodyStructure,formSections:t.formSections,submitPayload:t.submitPayload})}function M_(e,t,r){return{apiAuth:e?.apiAuth??t?.apiAuth??r?.apiAuth,apiHeaders:e?.apiHeaders??t?.apiHeaders??r?.apiHeaders}}function jg(e){e.user_id!==void 0&&e.user_id!==null&&(e.context_user_id=e.context_user_id??e.user_id,delete e.user_id);const t=e.data;if(t!=null&&typeof t=="object"&&!Array.isArray(t)&&t.user_id!==void 0&&t.user_id!==null){const r=t;r.context_user_id=r.context_user_id??r.user_id,delete r.user_id}}function L_(e){if(typeof e!="string")return e;const t=e.trim();if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]"))try{return JSON.parse(t)}catch{return e}return e}function Mc(e,t,r){if(!t?.length)return jg(e),e;for(const{key:n,value:o}of t){const i=n?.trim();if(!i||o==null)continue;const s=i==="user_id"?"context_user_id":i;e[s]=L_(r(String(o)))}return jg(e),e}async function D_(e){const{buttonConfig:t,formSections:r,submitPayload:n,allFields:o,resolveCustomBodyValue:i}=e,s=t.apiBodyFields,a=!!t.apiBodyFieldsOnly,c=o?.length?Pc(e.formValues,o):e.formValues,f=a&&Bg(t)?__(c,r):c,l=e.transformValues??(async h=>{const{transformFormValuesWithFiles:y}=await Promise.resolve().then(()=>Lg),S={...t.apiFieldTypes??{}};o?.length&&o.forEach(A=>{const x=A.name||A.key;x&&(A.type==="terms"||A.type==="checkbox")&&(S[x]="boolean")});const{transformed:v}=y(h,t.apiFieldMapping,S);return{transformed:v}}),{transformed:p}=await l(f);if(a){if(Bg(t)){const y=F_(p,r,{sectionIds:t.submitPayloadSectionIds,rootFieldNames:t.submitPayloadRootFields});return Mc(y,s,i)}return s?.length?Mc({},s,i):{}}let g=$g(p,{apiBodyStructure:t.apiBodyStructure,formSections:r,submitPayload:n});const m=t.apiFieldMapping;if(!ma(r,n)&&m){const h={};Object.keys(g).forEach(y=>{h[m[y]||y]=g[y]}),g=h}return Mc(g,s,i)}function B_(e){return e==="null"?null:e==="true"?!0:e==="false"?!1:e}function $_(e){const t=e,r=typeof t?.status=="string"?t.status.toLowerCase():null;if(r&&r!=="success")return!1;const n=t?.code;return!(typeof n=="number"&&(n<200||n>=300))}function j_(e,t){if(!t)return[];const r=e.trim().split(".");if(r.length<2)return[];const n=r[0],o=r.slice(1).join("."),i=[];return Object.entries(t).forEach(([s,a])=>{const c=s===n,u=s.startsWith(`${n}__addmore__`);if(!c&&!u||!$_(a))return;const f=We(a,o);f==null||f===""||i.push(f)}),i}function Lc(e,t,r,n){const o=M_(e,t,r);return qE(o,{formValues:n.formValues,urlParams:n.urlParams,submissionContext:n.submissionContext})}function zg(e,t,r){Object.entries(t).forEach(([n,o])=>{n.toLowerCase()==="content-type"&&r instanceof FormData||(e[n]=o)})}function Dc(e,t,r,n,o,i){const s=e.trim().match(/^\{respAll:([^}]+)\}$/);if(s){const u=(s[1]||"").trim(),f=u.split("."),l=f.length>=2?f.slice(1).join("."):"";return(l==="data.id"||l==="data.documentId")&&n?.document_ids!=null&&Array.isArray(n.document_ids)?n.document_ids:j_(u,o)}const a=e.trim().match(/^\{(\w+)\}$/);if(a){const u=a[1],f=t[u];if(f!==void 0)return f;const l=Object.keys(t).find(p=>p.toLowerCase()===u.toLowerCase());if(l)return t[l]}const c=Rr(e,t,r,n,o,i);return B_(String(c))}const z_=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:c,onClick:u,onSubmit:f,onReset:l,onCancel:p,isSubmitting:g=!1,formValues:m={},submissionContext:h,bffSubmitApi:y,onBffSubmitResult:S,extraSubmitPayload:v,buttonResponses:A,onButtonApiResponse:x,onValidateForm:F,getValidationErrors:N,allFields:k,onSubmittingChange:T,scopedFormValues:P,scopedFieldNameMap:E,prepopulateResponse:C=null,formSections:I,submitPayload:W})=>{const{gridStretch:M}=Zo(),U=Ig(),V=os(),[X,B]=w.useState(!1),L=e.properties,D=ja.useParams(),K=w.useMemo(()=>({...h,...v}),[h,v]),ae=w.useMemo(()=>{if(!P||!E||Object.keys(E).length===0)return m;const he={};return Object.entries(P).forEach(([we,J])=>{const $=E[we]||we;$!==e.name&&(he[$]=J)}),he},[P,E,m,e.name]),z=(()=>{try{const he=e.metadata;if(typeof he=="string")return JSON.parse(he);if(he&&typeof he=="object")return he}catch{}return null})(),le=e.apidata??null,ie=L?.submitAction??z?.submitAction,G=L?.apiEndpoint??e.apidata?.apiEndpoint??z?.apiEndpoint;let ee=L?.action||z?.action;!ee&&e.type==="button"&&(ee="submit");const Ae=L?.variant||"default",te=L?.size||"default",oe=L?.hideLabel??e.appearance?.hideLabel??!1,me=L?.buttonText||e.label||"Button",Me=L?.closeOnCancel??!0,De=async()=>{if(P&&E&&Object.keys(E).length>0||!F)return!0;const he=await F();if(!he&&N)try{const we=N();at.toast.error(da(we,k??void 0)||"Please fix the errors before submitting.")}catch{at.toast.error("Please fix the errors before submitting.")}return he},ne=async he=>{he.preventDefault();const we=ee==="submit"?"submit":ee;if(ee==="next"){await kc(k??void 0,V);return}if(ee==="prev"){s_(V);return}if(ee==="saveAndNext"){if(!(L?.uploadApiEndpoint||z?.uploadApiEndpoint||e.uploadApiEndpoint)?.trim()){at.toast.error("API endpoint is not configured for Save & Next.");return}if(!await De())return;B(!0);try{const $=await yt();x?.(e.name,$),xg($)||wg($,"Saved successfully."),await kc(k??void 0,V)}catch($){x?.(e.name,{status:"error",code:$?.response?.code??$?.response?.status??null,message:Kr($)}),la($,"Failed to save. Please check the API endpoint and try again.",Kr)}finally{B(!1)}return}if(ee==="openWorkflowModal"){const J=L?.workflowId??z?.workflowId;if(!U){at.toast.error("Workflow modal is not configured for this form.");return}if(!J?.trim()){at.toast.error("Workflow is not configured for this button.");return}B(!0);try{await U.openWorkflowModal({workflowId:J.trim(),entryStepId:L?.entryStepId??z?.entryStepId,modalTitle:L?.modalTitle??z?.modalTitle??e.label,passFields:L?.passFields??z?.passFields},ae)}catch($){at.toast.error(Kr($))}finally{B(!1)}return}if(ee==="openFormModal"){const J=L?.formDefinitionId??z?.formDefinitionId;if(!U){at.toast.error("Form modal is not configured for this form.");return}if(!J?.trim()){at.toast.error("Form is not configured for this button.");return}B(!0);try{await U.openFormModal({formDefinitionId:J.trim(),modalTitle:L?.modalTitle??z?.modalTitle??e.label,passFields:L?.passFields??z?.passFields},ae)}catch($){at.toast.error(Kr($))}finally{B(!1)}return}if(ee==="gotoStep"){const J=L?.targetStepId??z?.targetStepId;if(!U){at.toast.error("Step navigation is not configured for this form.");return}if(!J?.trim()){at.toast.error("Target step is not configured for this button.");return}const $=L?.workflowId??z?.workflowId??y?.payload?.workflow_id;B(!0);try{await U.navigateToStep(J.trim(),{workflowId:typeof $=="string"?$:void 0,formValues:ae})}catch(fe){at.toast.error(Kr(fe))}finally{B(!1)}return}if(we==="submit"){if(i_(V)){await kc(k??void 0,V);return}if(y?.url){if(!await De())return;B(!0),T?.(!0);try{const J=await Se(),$=(J?.message??J?.display_message??"Form submitted successfully!").trim();at.toast.success($||"Form submitted successfully!");const fe=J!=null&&typeof J=="object"?J:{status:"success",...J!=null?{data:J}:{}};x?.(e.name,fe)}catch(J){const $=Kr(J);at.toast.error($)}finally{B(!1),T?.(!1)}return}if(f){if(!await De())return;B(!0),T?.(!0);try{await f(),x?.(e.name,{status:"success"})}finally{B(!1),T?.(!1)}return}at.toast.error("Submit not configured. BFF submit API is required for submit buttons.");return}else if(ee==="reset"&&l)l();else if(ee==="cancel")Me?p&&p():l&&l();else if(ee==="download"){const J=L?.downloadApiEndpoint||z?.downloadApiEndpoint||e.downloadApiEndpoint,$=L?.downloadApiMethod||z?.downloadApiMethod||e.downloadApiMethod;if(J){B(!0);try{const fe=$||"GET",Ve=Mr(Rr(J,ae,D,K,A,C??void 0)),Fe={method:fe,headers:{}};fe!=="GET"&&fe!=="DELETE"&&(Fe.headers={"Content-Type":"application/json"}),zg(Fe.headers,Lc(L,z,le,{formValues:ae,urlParams:D,submissionContext:K}));const ze=await fetch(Ve,Fe);if(!ze.ok)throw new Error(`Download failed: ${ze.statusText}`);const st=await ze.blob(),ht=window.URL.createObjectURL(st),lt=document.createElement("a");lt.href=ht;const ct=ze.headers.get("Content-Disposition");let nt="download";if(ct){const ot=ct.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);ot&&ot[1]&&(nt=ot[1].replace(/['"]/g,""))}lt.download=nt,document.body.appendChild(lt),lt.click(),document.body.removeChild(lt),window.URL.revokeObjectURL(ht);try{const ot=r_(ze);at.toast.success(ot&&ot.trim()?ot:"Download started.")}catch{at.toast.success("Download started.")}}catch(fe){la(fe,"Failed to download file. Please check the API endpoint and try again.",Kr)}finally{B(!1)}}else at.toast.error("Download endpoint is not configured")}else if(ee==="upload"||ee==="custom"){const J=ee==="custom",$=J?"api":L?.uploadAction||z?.uploadAction||"database";if($==="database")if(f){B(!0);try{await f(he)}catch(fe){throw fe}finally{B(!1)}}else at.toast.error("Form submit handler is not available");else if($==="api"){const fe=L?.uploadApiEndpoint||z?.uploadApiEndpoint||e.uploadApiEndpoint;if(L?.uploadApiMethod||z?.uploadApiMethod||e.uploadApiMethod,fe){if(!await De())return;B(!0);try{const Ve=await yt();x?.(e.name,Ve),wg(Ve,J?"Custom API call completed successfully!":"Upload completed successfully!")}catch(Ve){x?.(e.name,{status:"error",code:Ve?.response?.code??Ve?.response?.status??null,message:Kr(Ve)}),la(Ve,J?"Failed to call custom API. Please check the API endpoint and try again.":"Failed to upload. Please check the API endpoint and try again.",Kr)}finally{B(!1)}}else at.toast.error(J?"Custom API endpoint is not configured":"Upload endpoint is not configured")}else $==="custom"&&at.toast.info("Custom upload handler is not implemented")}else u?u():r&&t!==void 0&&r(t||"");n?.()},ge=async()=>{if(!ie||ie!=="api"||!G)return null;const he=L?.apiBodyFields??z?.apiBodyFields,we=L?.apiBodyFieldsOnly??z?.apiBodyFieldsOnly??!1,J=L?.apiFieldMapping??z?.apiFieldMapping,$=L?.apiFieldTypes??z?.apiFieldTypes,fe=L?.apiBodyStructure??z?.apiBodyStructure;return D_({formValues:ae,buttonConfig:{apiBodyFieldsOnly:we,apiBodyFields:he,apiBodyStructure:fe,apiFieldMapping:J,apiFieldTypes:$,submitPayloadSectionIds:L?.submitPayloadSectionIds??z?.submitPayloadSectionIds,submitPayloadRootFields:L?.submitPayloadRootFields??z?.submitPayloadRootFields},formSections:I,submitPayload:W,allFields:k,resolveCustomBodyValue:Ve=>Dc(Ve,ae,D,K,A,C??void 0)})},Se=async()=>{if(!y||!y.url)throw new Error("BFF submit API configuration is missing");const he=k?.length?Pc(m,k):m,we={};Object.keys(he).forEach(Je=>{const ut=e.name===Je&&e.type==="button",Ye=Je.toLowerCase().includes("button");!ut&&!Ye&&(we[Je]=he[Je])});const J=Object.keys(we).filter(Je=>pa(we[Je]));J.forEach(Je=>{we[Je]=""});const $=Ic(we,I,W),fe={workflow_id:y.payload?.workflow_id||"",current_step_id:y.payload?.current_step_id||"",form_data:$},Ve=y.payload?.context_user_id??y.payload?.user_id;Ve!=null&&String(Ve).trim()!==""&&(fe.context_user_id=String(Ve).trim());const Fe=["workflow_id","current_step_id","form_data","submit_body","submit_api_endpoint","submit_api_method"];if(h&&typeof h=="object"&&Object.entries(h).forEach(([Je,ut])=>{if(ut==null||Fe.includes(Je))return;const Ye=Je==="user_id"?"context_user_id":Je;fe[Ye]=fe[Ye]??ut}),v&&typeof v=="object"&&Object.entries(v).forEach(([Je,ut])=>{if(ut==null||Fe.includes(Je))return;const Ye=Je==="user_id"?"context_user_id":Je;fe[Ye]=fe[Ye]??ut}),ie==="api"&&G){let Je=Rr(G,ae,D,K,A,C??void 0);Je=Je.replace(/\{([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\}/gi,"$1"),Je=Mr(Je),fe.submit_api_endpoint=Je,fe.submit_api_method=L?.submitApiMethod||z?.submitApiMethod||"POST";const ut=Lc(L,z,le,{formValues:ae,urlParams:D,submissionContext:K});Object.keys(ut).length>0&&(fe.submit_api_headers=ut);try{const Ye=await ge();if(Ye){const nr=L?.apiBodyStructure??z?.apiBodyStructure,br=L?.apiFieldMapping??z?.apiFieldMapping;J.forEach(vr=>{const kt=we[vr]!==void 0&&typeof we[vr]=="string"?we[vr]:"";P_(Ye,vr,kt,{apiBodyStructure:nr,bodyMapping:br,formSections:I,submitPayload:W})}),fe.submit_body=Ye}}catch{}}const ze=(y.method||"POST").toUpperCase(),st=J.length>0,ht=fe.submit_api_endpoint??G??"",lt=typeof ht=="string"?ht.toLowerCase():"",ct=lt.includes("/upload")||lt.includes("/payments")||lt.includes("/bulk-upload"),nt=st&&ct;let ot;const ar={...y.headers||{}};if(nt){const Je=new FormData;Je.append("payload",JSON.stringify(fe));for(const ut of J){const Ye=he[ut],nr=L?.apiFieldMapping?.[ut]??ut;Ye instanceof File?Je.append(nr,Ye):Array.isArray(Ye)&&Ye.length>0&&Ye[0]instanceof File&&Ye.forEach(br=>Je.append(nr,br))}ot=Je,delete ar["content-type"],delete ar["Content-Type"]}else ar["Content-Type"]="application/json",ot=JSON.stringify(fe);const vt=await fetch(y.url,{method:ze,headers:ar,body:ot});if(!vt.ok){let Je;const ut=await vt.text();try{Je=JSON.parse(ut)}catch{Je={message:ut}}const Ye=new Error(`BFF submission failed: ${vt.status}`);throw Ye.response=Je,Ye}const er=await vt.json();return S?.(er),f&&await f(),er},yt=async()=>{const he=L?.uploadApiEndpoint||z?.uploadApiEndpoint;if(!he)throw new Error("Upload API endpoint is not configured");if(!L)throw new Error("Button properties are not configured");const we=(L.uploadApiMethod||"POST").toUpperCase(),J=Mr(Rr(he,ae,D,K,A,C??void 0)),$=L.apiBodyFieldsOnly??z?.apiBodyFieldsOnly??!1,fe=L.apiBodyFieldsOnlyFormat??z?.apiBodyFieldsOnlyFormat??"json";let Ve={},Fe;const ze={};if($&&L.apiBodyFields&&L.apiBodyFields.length>0)if(L.apiBodyFields.forEach(({key:lt,value:ct})=>{Ve[lt]=Dc(ct,ae,D,K,A,C??void 0)}),fe==="multipart"){const lt=new FormData;Object.entries(Ve).forEach(([ct,nt])=>{if(nt instanceof File){lt.append(ct,nt);return}if(Array.isArray(nt)&&nt.length>0&&nt[0]instanceof File){nt.forEach(ot=>lt.append(ct,ot));return}nt!=null&<.append(ct,typeof nt=="object"?JSON.stringify(nt):String(nt))}),Fe=lt}else Fe=JSON.stringify(Ve),ze["Content-Type"]="application/json";else{const lt=ae,{transformFormValuesWithFiles:ct,prepareFormDataWithFiles:nt,hasFileValues:ot}=await Promise.resolve().then(()=>Lg),{transformed:ar,hasFiles:vt}=ct(lt,L.apiFieldMapping,L.apiFieldTypes),er=L.apiBodyStructure??z?.apiBodyStructure??"nested",Je=L.apiFieldMapping??z?.apiFieldMapping;if(Ve=I_(ar,{apiBodyStructure:er,formSections:I,submitPayload:W}),!ma(I,W)&&Je){const ut={};Object.keys(Ve).forEach(Ye=>{const nr=Je[Ye]||Ye;ut[nr]=Ve[Ye]}),Ve=ut}if(L.apiBodyFields&&L.apiBodyFields.forEach(({key:ut,value:Ye})=>{Ve[ut]=Dc(Ye,ae,D,K,A,C??void 0)}),vt||ot(Ve)){const ut=nt(Ve,L.apiFieldMapping);ut?Fe=ut:(Fe=JSON.stringify(Ve),ze["Content-Type"]="application/json")}else Fe=JSON.stringify(Ve),ze["Content-Type"]="application/json"}zg(ze,Lc(L,z,le,{formValues:ae,urlParams:D,submissionContext:K}),Fe);let st=J;if(L.apiQueryParams&&L.apiQueryParams.length>0){const lt=new URLSearchParams;L.apiQueryParams.forEach(({key:ct,value:nt})=>{const ot=Rr(nt,ae,D,K,A,C??void 0);lt.append(ct,ot)}),st=`${J}?${lt.toString()}`}const ht=await fetch(st,{method:we,headers:ze,body:we!=="GET"?Fe:void 0});if(!ht.ok){let lt;const ct=await ht.text();try{lt=JSON.parse(ct)}catch{lt={message:ct}}const nt=new Error(`Upload failed: ${ht.status}`);throw nt.response=lt,nt}try{return await ht.json()}catch{return{}}},Nt=ee==="submit"?"submit":ee,Ot=Nt==="submit"?"button":Nt==="submit"?"submit":Nt==="reset"?"reset":"button",Er=i||e.disabled||s||e.readOnly||X||Nt==="submit"&&g,Dt=me,sr=fo(e),Vt=Fr(e.appearance)==="stretch";return d.jsx(At,{field:e,error:o,isRequired:a,className:c,hideLabel:oe,children:d.jsx("div",{className:H(M&&!sr&&"flex w-full min-w-0 flex-col",M&&sr&&"min-w-0 shrink-0"),children:d.jsxs(Qt,{id:ft(e),type:Ot,variant:Ae,size:te,disabled:Er,onClick:ne,className:H(e.appearance?.className,M&&!sr&&"w-full min-w-0 shrink-0",M&&sr&&!Vt&&"inline-flex w-auto max-w-full shrink-0",M&&sr&&Vt&&"inline-flex w-full min-w-0 max-w-full shrink-0"),children:[X&&d.jsx("span",{className:"inline-block h-4 w-4 shrink-0 animate-spin rounded-full border-2 border-current border-t-transparent mr-2","aria-hidden":!0}),Dt]})})})},U_=({field:e,disabled:t,readOnly:r,isRequired:n,className:o,buttonResponses:i,onButtonApiResponse:s})=>{const a=e.properties,c=a?.buttonText??e.label??"Edit",u=a?.variant??"outline",f=a?.size??"default",l=a?.hideLabel??e.appearance?.hideLabel??!1,p=e.name||e.key||e.id,g=ei(i?.[p]),m=t||e.disabled||r||e.readOnly||g,h=y=>{y.preventDefault(),!m&&s?.(p,{status:"success"})};return d.jsx(At,{field:e,error:void 0,isRequired:n,className:o,hideLabel:l,children:d.jsx(Qt,{id:ft(e),type:"button",variant:u,size:f,disabled:m,onClick:h,className:H(e.appearance?.className,(!fo(e)||Fr(e.appearance)==="stretch")&&"w-full min-w-0"),children:c})})},V_=({field:e,error:t,disabled:r,readOnly:n,isRequired:o,className:i,onAddMore:s})=>{const a=e.properties||{},c=a.variant||"outline",u=a.size||"default",f=a.buttonText||e.label||"Add More",l=a.hideLabel??e.appearance?.hideLabel??!1,p=r||n||e.disabled||e.readOnly;return d.jsx(At,{field:e,error:t,isRequired:o,className:i,hideLabel:l,children:d.jsxs(Qt,{id:ft(e),type:"button",variant:c,size:u,disabled:!!p,onClick:s,className:H("w-fit",e.appearance?.className),children:[d.jsx(Qu,{className:"h-4 w-4 mr-1"}),f]})})},Ug=w.createContext(null);function H_({value:e,children:t}){return d.jsx(Ug.Provider,{value:e,children:t})}function W_(){return w.useContext(Ug)}function Vg(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(0,t):e}function _i(e){return e.name||e.key||e.id}function Bc(e){return e.filter(t=>!t.parentId&&t.type==="sectionHeading"&&_i(t))}function R_(e){if(e.type!=="sectionHeading")return[];const t=e.properties||{};return Array.isArray(t.linkedFieldNames)?t.linkedFieldNames.filter(r=>typeof r=="string"&&r.trim().length>0):[]}function K_(e){const t=new Map;for(const r of Bc(e)){const n=_i(r);for(const o of R_(r))t.set(o,n)}return t}function G_(e,t){const r=t.properties||{},n=Array.isArray(r.sectionHeadingNames)?r.sectionHeadingNames.filter(s=>typeof s=="string"&&s.trim()):[],o=Bc(e);if(n.length===0)return o;const i=new Set(n);return o.filter(s=>i.has(_i(s)))}function q_(e){const t={};for(const r of Bc(e))t[_i(r)]=!0;for(const r of e){if(r.type!=="customizeSections")continue;const n=r.properties||{};for(const o of n.defaultHiddenSectionNames??[])typeof o=="string"&&o.trim()&&(t[o.trim()]=!1)}return t}function Hg(e,t,r,n){if(!e||t==="customizeSections")return!0;const o=Vg(e),i=t==="sectionHeading"?o:n.get(o);return i?r[i]!==!1:!0}const Y_=({field:e,error:t,disabled:r,readOnly:n,isRequired:o,className:i,designMode:s=!1})=>{const a=W_(),c=e.properties||{},u=c.variant||"outline",f=c.size||"default",l=c.buttonText||e.label||"Customise sections",p=c.menuTitle||"VISIBLE SECTIONS",g=c.hideLabel??e.appearance?.hideLabel??!1,m=r||n||e.disabled||e.readOnly,h=w.useMemo(()=>a?.allFields?.length?G_(a.allFields,e):[],[a?.allFields,e]);return d.jsx(At,{field:e,error:t,isRequired:o,className:i,hideLabel:g,children:d.jsxs(ac,{children:[d.jsx(Jm,{asChild:!0,children:d.jsxs(Qt,{id:ft(e),type:"button",variant:u,size:f,disabled:!!m,className:H("w-fit gap-2",e.appearance?.className),children:[d.jsx(fS,{className:"h-4 w-4"}),l]})}),d.jsxs(lc,{align:"end",className:"w-64 p-0",children:[d.jsx("div",{className:"px-3 py-2 border-b",children:d.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:p})}),d.jsx("div",{className:"max-h-64 overflow-auto p-2 space-y-1",children:h.length===0?d.jsx("p",{className:"text-xs text-muted-foreground px-1 py-2",children:"No section headings on this form."}):h.map(y=>{const S=_i(y),v=y.label||S,A=s||!a?!0:a.visibility[S]!==!1;return d.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md px-1 py-1.5 hover:bg-muted/50",children:[d.jsx(Pn,{htmlFor:`ui-section-${e.id}-${S}`,className:"text-xs font-normal truncate",children:v}),d.jsx(Ph,{id:`ui-section-${e.id}-${S}`,checked:A,disabled:s||!a||!!m,onCheckedChange:x=>{!a||s||a.setSectionVisible(S,!!x)}})]},y.id)})})]})]})})},X_=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:c})=>{const u=e.properties,f=u?.max||5,l=u?.icon||"star",p=h=>{i||s||e.disabled||e.readOnly||(r(h),n?.())},g=h=>{},m=h=>{const y=t>=h+1,S=H("transition-colors cursor-pointer",y?"fill-yellow-400 text-yellow-400":"text-muted-foreground",(i||s||e.disabled||e.readOnly)&&"cursor-not-allowed opacity-50",!(i||s||e.disabled||e.readOnly)&&"hover:text-yellow-400");return l==="star"?d.jsx(Zu,{className:H(S,"h-6 w-6"),onClick:()=>p(h+1),onMouseEnter:()=>g()},h):d.jsx(Zu,{className:H(S,"h-6 w-6"),onClick:()=>p(h+1),onMouseEnter:()=>g()},h)};return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{id:ft(e),className:"flex items-center gap-1",role:"radiogroup","aria-label":e.label,"aria-describedby":Lt(e,!!o),"aria-invalid":Xt(!!o),"aria-required":a,children:[Array.from({length:f},(h,y)=>m(y)),u?.showValue!==!1&&d.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:t>0?t:""})]})})};var Wg=["PageUp","PageDown"],Rg=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Kg={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Do="Slider",[$c,J_,Q_]=Nl(Do),[Gg]=Sr(Do,[Q_]),[Z_,ha]=Gg(Do),qg=b.forwardRef((e,t)=>{const{name:r,min:n=0,max:o=100,step:i=1,orientation:s="horizontal",disabled:a=!1,minStepsBetweenThumbs:c=0,defaultValue:u=[n],value:f,onValueChange:l=()=>{},onValueCommit:p=()=>{},inverted:g=!1,form:m,...h}=e,y=b.useRef(new Set),S=b.useRef(0),A=s==="horizontal"?eT:tT,[x=[],F]=ln({prop:f,defaultProp:u,onChange:C=>{[...y.current][S.current]?.focus(),l(C)}}),N=b.useRef(x);function k(C){const I=sT(x,C);E(C,I)}function T(C){E(C,S.current)}function P(){const C=N.current[S.current];x[S.current]!==C&&p(x)}function E(C,I,{commit:W}={commit:!1}){const M=dT(i),U=uT(Math.round((C-n)/i)*i+n,M),V=pi(U,[n,o]);F((X=[])=>{const B=oT(X,V,I);if(cT(B,c*i)){S.current=B.indexOf(V);const L=String(B)!==String(X);return L&&W&&p(B),L?B:X}else return X})}return d.jsx(Z_,{scope:e.__scopeSlider,name:r,disabled:a,min:n,max:o,valueIndexToChangeRef:S,thumbs:y.current,values:x,orientation:s,form:m,children:d.jsx($c.Provider,{scope:e.__scopeSlider,children:d.jsx($c.Slot,{scope:e.__scopeSlider,children:d.jsx(A,{"aria-disabled":a,"data-disabled":a?"":void 0,...h,ref:t,onPointerDown:Ie(h.onPointerDown,()=>{a||(N.current=x)}),min:n,max:o,inverted:g,onSlideStart:a?void 0:k,onSlideMove:a?void 0:T,onSlideEnd:a?void 0:P,onHomeKeyDown:()=>!a&&E(n,0,{commit:!0}),onEndKeyDown:()=>!a&&E(o,x.length-1,{commit:!0}),onStepKeyDown:({event:C,direction:I})=>{if(!a){const U=Wg.includes(C.key)||C.shiftKey&&Rg.includes(C.key)?10:1,V=S.current,X=x[V],B=i*U*I;E(X+B,V,{commit:!0})}}})})})})});qg.displayName=Do;var[Yg,Xg]=Gg(Do,{startEdge:"left",endEdge:"right",size:"width",direction:1}),eT=b.forwardRef((e,t)=>{const{min:r,max:n,dir:o,inverted:i,onSlideStart:s,onSlideMove:a,onSlideEnd:c,onStepKeyDown:u,...f}=e,[l,p]=b.useState(null),g=qe(t,A=>p(A)),m=b.useRef(void 0),h=bo(o),y=h==="ltr",S=y&&!i||!y&&i;function v(A){const x=m.current||l.getBoundingClientRect(),F=[0,x.width],k=Uc(F,S?[r,n]:[n,r]);return m.current=x,k(A-x.left)}return d.jsx(Yg,{scope:e.__scopeSlider,startEdge:S?"left":"right",endEdge:S?"right":"left",direction:S?1:-1,size:"width",children:d.jsx(Jg,{dir:h,"data-orientation":"horizontal",...f,ref:g,style:{...f.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:A=>{const x=v(A.clientX);s?.(x)},onSlideMove:A=>{const x=v(A.clientX);a?.(x)},onSlideEnd:()=>{m.current=void 0,c?.()},onStepKeyDown:A=>{const F=Kg[S?"from-left":"from-right"].includes(A.key);u?.({event:A,direction:F?-1:1})}})})}),tT=b.forwardRef((e,t)=>{const{min:r,max:n,inverted:o,onSlideStart:i,onSlideMove:s,onSlideEnd:a,onStepKeyDown:c,...u}=e,f=b.useRef(null),l=qe(t,f),p=b.useRef(void 0),g=!o;function m(h){const y=p.current||f.current.getBoundingClientRect(),S=[0,y.height],A=Uc(S,g?[n,r]:[r,n]);return p.current=y,A(h-y.top)}return d.jsx(Yg,{scope:e.__scopeSlider,startEdge:g?"bottom":"top",endEdge:g?"top":"bottom",size:"height",direction:g?1:-1,children:d.jsx(Jg,{"data-orientation":"vertical",...u,ref:l,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:h=>{const y=m(h.clientY);i?.(y)},onSlideMove:h=>{const y=m(h.clientY);s?.(y)},onSlideEnd:()=>{p.current=void 0,a?.()},onStepKeyDown:h=>{const S=Kg[g?"from-bottom":"from-top"].includes(h.key);c?.({event:h,direction:S?-1:1})}})})}),Jg=b.forwardRef((e,t)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:o,onSlideEnd:i,onHomeKeyDown:s,onEndKeyDown:a,onStepKeyDown:c,...u}=e,f=ha(Do,r);return d.jsx($e.span,{...u,ref:t,onKeyDown:Ie(e.onKeyDown,l=>{l.key==="Home"?(s(l),l.preventDefault()):l.key==="End"?(a(l),l.preventDefault()):Wg.concat(Rg).includes(l.key)&&(c(l),l.preventDefault())}),onPointerDown:Ie(e.onPointerDown,l=>{const p=l.target;p.setPointerCapture(l.pointerId),l.preventDefault(),f.thumbs.has(p)?p.focus():n(l)}),onPointerMove:Ie(e.onPointerMove,l=>{l.target.hasPointerCapture(l.pointerId)&&o(l)}),onPointerUp:Ie(e.onPointerUp,l=>{const p=l.target;p.hasPointerCapture(l.pointerId)&&(p.releasePointerCapture(l.pointerId),i(l))})})}),Qg="SliderTrack",Zg=b.forwardRef((e,t)=>{const{__scopeSlider:r,...n}=e,o=ha(Qg,r);return d.jsx($e.span,{"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation,...n,ref:t})});Zg.displayName=Qg;var jc="SliderRange",ey=b.forwardRef((e,t)=>{const{__scopeSlider:r,...n}=e,o=ha(jc,r),i=Xg(jc,r),s=b.useRef(null),a=qe(t,s),c=o.values.length,u=o.values.map(p=>ny(p,o.min,o.max)),f=c>1?Math.min(...u):0,l=100-Math.max(...u);return d.jsx($e.span,{"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,...n,ref:a,style:{...e.style,[i.startEdge]:f+"%",[i.endEdge]:l+"%"}})});ey.displayName=jc;var zc="SliderThumb",ty=b.forwardRef((e,t)=>{const r=J_(e.__scopeSlider),[n,o]=b.useState(null),i=qe(t,a=>o(a)),s=b.useMemo(()=>n?r().findIndex(a=>a.ref.current===n):-1,[r,n]);return d.jsx(rT,{...e,ref:i,index:s})}),rT=b.forwardRef((e,t)=>{const{__scopeSlider:r,index:n,name:o,...i}=e,s=ha(zc,r),a=Xg(zc,r),[c,u]=b.useState(null),f=qe(t,v=>u(v)),l=c?s.form||!!c.closest("form"):!0,p=gi(c),g=s.values[n],m=g===void 0?0:ny(g,s.min,s.max),h=iT(n,s.values.length),y=p?.[a.size],S=y?aT(y,m,a.direction):0;return b.useEffect(()=>{if(c)return s.thumbs.add(c),()=>{s.thumbs.delete(c)}},[c,s.thumbs]),d.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${m}% + ${S}px)`},children:[d.jsx($c.ItemSlot,{scope:e.__scopeSlider,children:d.jsx($e.span,{role:"slider","aria-label":e["aria-label"]||h,"aria-valuemin":s.min,"aria-valuenow":g,"aria-valuemax":s.max,"aria-orientation":s.orientation,"data-orientation":s.orientation,"data-disabled":s.disabled?"":void 0,tabIndex:s.disabled?void 0:0,...i,ref:f,style:g===void 0?{display:"none"}:e.style,onFocus:Ie(e.onFocus,()=>{s.valueIndexToChangeRef.current=n})})}),l&&d.jsx(ry,{name:o??(s.name?s.name+(s.values.length>1?"[]":""):void 0),form:s.form,value:g},n)]})});ty.displayName=zc;var nT="RadioBubbleInput",ry=b.forwardRef(({__scopeSlider:e,value:t,...r},n)=>{const o=b.useRef(null),i=qe(o,n),s=yi(t);return b.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"value").set;if(s!==t&&f){const l=new Event("input",{bubbles:!0});f.call(a,t),a.dispatchEvent(l)}},[s,t]),d.jsx($e.input,{style:{display:"none"},...r,ref:i,defaultValue:t})});ry.displayName=nT;function oT(e=[],t,r){const n=[...e];return n[r]=t,n.sort((o,i)=>o-i)}function ny(e,t,r){const i=100/(r-t)*(e-t);return pi(i,[0,100])}function iT(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function sT(e,t){if(e.length===1)return 0;const r=e.map(o=>Math.abs(o-t)),n=Math.min(...r);return r.indexOf(n)}function aT(e,t,r){const n=e/2,i=Uc([0,50],[0,n]);return(n-i(t)*r)*r}function lT(e){return e.slice(0,-1).map((t,r)=>e[r+1]-t)}function cT(e,t){if(t>0){const r=lT(e);return Math.min(...r)>=t}return!0}function Uc(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const n=(t[1]-t[0])/(e[1]-e[0]);return t[0]+n*(r-e[0])}}function dT(e){return(String(e).split(".")[1]||"").length}function uT(e,t){const r=Math.pow(10,t);return Math.round(e*r)/r}var fT=qg,pT=Zg,mT=ey,hT=ty;function gT({className:e,defaultValue:t,value:r,min:n=0,max:o=100,...i}){const s=b.useMemo(()=>Array.isArray(r)?r:Array.isArray(t)?t:[n,o],[r,t,n,o]);return d.jsxs(fT,{"data-slot":"slider",defaultValue:t,value:r,min:n,max:o,className:H("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",e),...i,children:[d.jsx(pT,{"data-slot":"slider-track",className:H("bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"),children:d.jsx(mT,{"data-slot":"slider-range",className:H("bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")})}),Array.from({length:s.length},(a,c)=>d.jsx(hT,{"data-slot":"slider-thumb",className:"border-primary bg-background ring-ring/50 block size-4 shrink-0 rounded-full border shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"},c))]})}const yT=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:c})=>{const u=e.properties,f=u?.min??0,l=u?.max??100,p=u?.step??1,g=u?.showValue!==!1,m=u?.marks||[],h=S=>{i||s||e.disabled||e.readOnly||(r(S[0]??f),n?.())},y=t??f;return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[g&&d.jsx("span",{className:"text-sm font-medium",children:y}),!g&&d.jsx("span",{className:"text-sm text-muted-foreground",children:f}),!g&&d.jsx("span",{className:"text-sm text-muted-foreground",children:l})]}),d.jsx(gT,{id:ft(e),value:[y],onValueChange:h,min:f,max:l,step:p,disabled:i||e.disabled||s||e.readOnly,className:H("w-full",o&&"border-destructive",e.appearance?.className),"aria-describedby":Lt(e,!!o),"aria-invalid":Xt(!!o),"aria-required":a}),m.length>0&&d.jsx("div",{className:"flex justify-between text-xs text-muted-foreground",children:m.map((S,v)=>d.jsx("span",{className:"text-center",children:S.label},v))})]})})},bT=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:c})=>{const u=w.useRef(null),[f,l]=w.useState(!1),p=i||e.disabled||s||e.readOnly,g=w.useCallback(S=>{if(p)return;l(!0);const v=u.current;if(!v)return;const A=v.getContext("2d");if(!A)return;const x=v.getBoundingClientRect(),F="touches"in S?S.touches[0].clientX-x.left:S.clientX-x.left,N="touches"in S?S.touches[0].clientY-x.top:S.clientY-x.top;A.beginPath(),A.moveTo(F,N)},[p]),m=w.useCallback(S=>{if(!f||p)return;const v=u.current;if(!v)return;const A=v.getContext("2d");if(!A)return;const x=v.getBoundingClientRect(),F="touches"in S?S.touches[0].clientX-x.left:S.clientX-x.left,N="touches"in S?S.touches[0].clientY-x.top:S.clientY-x.top;A.lineWidth=2,A.lineCap="round",A.strokeStyle="#000",A.lineTo(F,N),A.stroke(),A.beginPath(),A.moveTo(F,N)},[f,p]),h=w.useCallback(()=>{if(!f)return;l(!1);const S=u.current;if(!S)return;const v=S.toDataURL();r(v),n?.()},[f,r,n]),y=w.useCallback(()=>{const S=u.current;if(!S||p)return;const v=S.getContext("2d");v&&(v.clearRect(0,0,S.width,S.height),r(null),n?.())},[p,r,n]);return w.useEffect(()=>{const S=u.current;if(S&&(S.width=S.offsetWidth,S.height=200,t)){const v=new Image;v.onload=()=>{const A=S.getContext("2d");A&&A.drawImage(v,0,0)},v.src=t}},[t]),d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"space-y-2",children:[d.jsx("div",{className:H("border-2 border-dashed rounded-lg overflow-hidden",o&&"border-destructive",p&&"opacity-50 cursor-not-allowed"),children:d.jsx("canvas",{ref:u,id:ft(e),className:"w-full cursor-crosshair touch-none",onMouseDown:g,onMouseMove:m,onMouseUp:h,onMouseLeave:h,onTouchStart:g,onTouchMove:m,onTouchEnd:h,"aria-describedby":Lt(e,!!o),"aria-invalid":Xt(!!o),"aria-required":a,style:{height:"200px"}})}),!p&&d.jsx("div",{className:"flex justify-end",children:d.jsxs(Qt,{type:"button",variant:"outline",size:"sm",onClick:y,className:"text-xs",children:[d.jsx(oi,{className:"h-3 w-3 mr-1"}),"Clear"]})})]})})},vT=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:c,hideRowControls:u=!1,formValues:f,submissionContext:l})=>{const p=e.properties,g=p?.columns||[],m=p?.minRows||1,h=p?.maxRows||10,y=!u&&p?.allowAddRow!==!1,S=!u&&p?.allowDeleteRow!==!1,v=i===!1&&s===!1?!1:i||e.disabled||s||e.readOnly,A=t||[],x=y&&A.length<h,F=S&&A.length>m,N=w.useCallback(()=>{if(!x||v)return;const M={};g.forEach(U=>{M[U.name]=U.defaultValue??""}),r([...A,M]),n?.()},[A,g,x,v,r,n]),k=w.useCallback(M=>{if(!F||v)return;const U=A.filter((V,X)=>X!==M);r(U),n?.()},[A,F,v,r,n]),T=w.useCallback((M,U,V)=>{if(v)return;const X=[...A];X[M]||(X[M]={}),X[M][U]=V,r(X),n?.()},[A,v,r,n]);if(w.useEffect(()=>{if(A.length<m){const M=m-A.length,U=[];for(let V=0;V<M;V++){const X={};g.forEach(B=>{X[B.name]=B.defaultValue??""}),U.push(X)}r([...A,...U])}},[m,g,r,A.length]),g.length===0)return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsx("div",{className:"p-4 border rounded-md bg-muted/50 text-sm text-muted-foreground",children:"No columns defined for this table field"})});const P=Math.max(1,e.position?.rowSpan??1),E=Math.max(1,e.position?.columnSpan??1),C=Math.max(A.length,1),I=P>=3?"py-4":P>=2?"py-3":"py-2.5",W=E>=3?"px-4":E>=2?"px-3":"px-4";return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{id:ft(e),className:H("flex h-full min-h-0 w-full min-w-0 flex-1 flex-col border rounded-lg overflow-hidden shadow-sm bg-background",o&&"border-destructive",v&&"opacity-50"),"aria-describedby":Lt(e,!!o),"aria-invalid":Xt(!!o),"aria-required":a,children:[d.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:d.jsxs("table",{className:"w-full h-full min-h-full border-collapse text-sm table-fixed",style:p?.minWidth?{minWidth:p.minWidth}:void 0,children:[d.jsx("thead",{children:d.jsxs("tr",{className:"border-b border-border bg-muted/60",children:[g.map(M=>d.jsxs("th",{className:H(W,I,"text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground whitespace-nowrap"),children:[M.label,a&&M.validation?.some(U=>U.type==="required")&&d.jsx("span",{className:"text-destructive ml-1",children:"*"})]},M.id)),S&&d.jsx("th",{className:"w-12"})]})}),d.jsx("tbody",{className:"h-full",children:A.length===0?d.jsx("tr",{children:d.jsx("td",{colSpan:g.length+(S?1:0),className:H(W,"py-8 text-center text-sm text-muted-foreground"),children:u?"No rows to display.":'No rows added yet. Click "Add Row" to get started.'})}):A.map((M,U)=>{const V=A[U],X=V&&typeof V=="object"&&!Array.isArray(V)?{...f??{},...V}:f;return d.jsxs("tr",{className:"border-b border-border/50 hover:bg-muted/30 transition-colors last:border-b-0",style:{height:`${100/C}%`},children:[g.map(B=>{const L={...B,name:`${e.name}_${U}_${B.name}`,appearance:{...B.appearance,hideLabel:!0}},D=B.name??"",K=M[D]!==void 0?M[D]:D&&Object.keys(M).find(G=>G.toLowerCase()===D.toLowerCase())?M[Object.keys(M).find(G=>G.toLowerCase()===D.toLowerCase())]:void 0,ae=!!B.readOnly,j=G=>{if(G==null)return"";if(Array.isArray(G))return G.map(ee=>typeof ee=="object"&&ee!==null&&"name"in ee?String(ee.name??ee):String(ee)).join(", ");if(typeof G=="object"&&G!==null&&!(G instanceof Date)){const ee=G;return typeof ee.name=="string"&&typeof ee.code=="string"?`${ee.code} ${ee.name}`.trim():typeof ee.name=="string"?ee.name:typeof ee.code=="string"?ee.code:String(ee.name??ee.code??G)}return String(G)},z=G=>typeof G=="object"&&G!==null&&!Array.isArray(G)?j(G):String(G??""),le=B.name?.toLowerCase()==="type"||B.label?.toLowerCase()==="type";if(ae){const G=j(K);return d.jsx("td",{className:"px-4 py-2.5 align-middle first:pl-6 last:pr-6",children:d.jsx("div",{className:"min-w-[120px] text-sm text-foreground",children:le&&G?d.jsx("span",{className:"inline-flex items-center rounded-full bg-primary/10 text-primary px-2.5 py-0.5 text-xs font-medium",children:G}):d.jsx("span",{className:"py-1 block",children:G})})},B.id)}const ie=()=>{switch(B.type){case"text":case"password":case"url":return d.jsx(as,{field:L,value:z(K),onChange:G=>T(U,B.name,G),disabled:v,readOnly:v,className:"w-full"});case"number":return d.jsx(fl,{field:L,value:K??null,onChange:G=>T(U,B.name,G),disabled:v,readOnly:v,className:"w-full"});case"email":return d.jsx(ef,{field:L,value:z(K),onChange:G=>T(U,B.name,G),disabled:v,readOnly:v,className:"w-full"});case"phone":case"aadhaar":return d.jsx(tf,{field:L,value:z(K),onChange:G=>T(U,B.name,G),disabled:v,readOnly:v,className:"w-full"});case"otp":return d.jsx(Jf,{field:L,value:z(K),onChange:G=>T(U,B.name,G),disabled:v,readOnly:v,className:"w-full"});case"textarea":return d.jsx(Qf,{field:L,value:z(K),onChange:G=>T(U,B.name,G),disabled:v,readOnly:v,className:"w-full"});case"select":return d.jsx(Dm,{field:L,value:typeof K=="string"?K:z(K),onChange:G=>T(U,B.name,G),disabled:v,className:"w-full",formValues:X,submissionContext:l});case"multiselect":{const G=Array.isArray(K)?K:K!=null&&K!==""?[String(K)]:[];return d.jsx(Ch,{field:L,value:G,onChange:ee=>T(U,B.name,ee),disabled:v,className:"w-full",formValues:X,submissionContext:l})}case"asyncsearch":return d.jsx(th,{field:L,value:K,onChange:G=>T(U,B.name,G),disabled:v,readOnly:v,className:"w-full",formValues:X,submissionContext:l});case"checkbox":return d.jsx(Eh,{field:L,value:K||!1,onChange:G=>T(U,B.name,G),disabled:v,className:"w-full"});case"radio":case"checkboxgroup":return d.jsx(Jh,{field:L,value:typeof K=="string"?K:z(K),onChange:G=>T(U,B.name,G),disabled:v,className:"w-full"});case"date":case"time":case"datetime":case"daterange":return d.jsx(Qh,{field:L,value:typeof K=="string"?K:z(K),onChange:G=>T(U,B.name,G),disabled:v,readOnly:v,className:"w-full"});default:return d.jsx(as,{field:L,value:z(K),onChange:G=>T(U,B.name,G),disabled:v,readOnly:v,className:"w-full"})}};return d.jsx("td",{className:"px-4 py-2.5 align-middle first:pl-6 last:pr-6",children:d.jsx("div",{className:"min-w-[160px] w-full [&_input]:min-w-[10rem] [&_input]:overflow-visible [&_textarea]:min-h-[2.5rem]",children:ie()})},B.id)}),S&&d.jsx("td",{className:"px-2 py-2",children:d.jsx(Qt,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>k(U),disabled:!F||v,children:d.jsx(oi,{className:"h-4 w-4"})})})]},U)})})]})}),x&&d.jsx("div",{className:"shrink-0 p-3 border-t bg-muted/30",children:d.jsxs(Qt,{type:"button",variant:"outline",size:"sm",onClick:N,disabled:v,className:"w-full",children:[d.jsx(Qu,{className:"h-4 w-4 mr-2"}),"Add Row"]})})]})})},wT="h-8 min-h-8 rounded-md border border-input bg-background px-2 text-sm shadow-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30",ST="flex min-h-8 w-full items-center gap-0.5 rounded-md border border-input bg-background px-2 focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/30",xT="h-8 min-w-[2ch] max-w-full flex-1 border-0 bg-transparent px-0 shadow-none focus-visible:ring-0",AT="align-top max-w-0 whitespace-normal break-words",Ti="block min-w-0 break-words";function oy(e,t,r){const n=r?.emptyDisplay??"—";if(e==null||e==="")return n;const o=t?.format??"text",i=typeof e=="number"?e:Number(e);switch(o){case"currency":return Number.isNaN(i)?n:`${r?.currencySymbol??"₹"}${i.toLocaleString("en-IN",{minimumFractionDigits:0,maximumFractionDigits:2})}`;case"percent":return Number.isNaN(i)?n:`${i}%`;case"number":return Number.isNaN(i)?n:String(i);default:return String(e)}}function CT(e){const t=e.replace(/[^\d.-]/g,"");if(t===""||t==="-"||t===".")return null;const r=parseFloat(t);return Number.isNaN(r)?null:r}function ET(e){if(e==null||e==="")return"";const t=typeof e=="number"?e:Number(e);return Number.isNaN(t)?"":String(t)}function iy(e,t){return oy(e,{format:"currency"},t)}function Fi(e){return e==null||e===""}function sy(e){return e.mode??"editable"}function NT(e,t){return e.kind==="currency"||e.kind==="input"&&e.inputType==="number"?!0:t?.format==="currency"||t?.format==="number"||t?.format==="percent"}function ay(e,t,r){if(e!==void 0){if(e==="")return"";if(NT(t,r)){const n=Number(e);return Number.isNaN(n)?e:n}return e}}function Vc(e,t){if(!(!e||!("defaultValue"in e)||e.defaultValue===void 0))return ay(e.defaultValue,e,t)}function Hc(e,t,r){if(!t||!Fi(e))return e;if(t.kind==="currency"&&sy(t)==="static"&&t.value!==void 0)return ay(t.value,t,r);const n=Vc(t,r);return n!==void 0?n:e}function kT(e,t,r){const n={...t};for(const[o,i]of Object.entries(e)){const s=r.find(c=>c.key===o);if(!Fi(n[o]))continue;const a=Hc(n[o],i,s);(!Fi(a)||i&&"defaultValue"in i&&i.defaultValue==="")&&(n[o]=a)}return n}function ga(e,t,r){if(!Fi(e))return e;const n=Vc(t,r);return n!==void 0?n:e}const _T=new Set(["all_items_summary","invoice_discount","grand_total"]);function TT(e,t){switch(t){case"dynamic":return e.filter(r=>r.rowKind==="dynamic");case"static":return e.filter(r=>r.rowKind==="static");case"all":return e;case"data":return e.filter(r=>r.rowKind==="dynamic"||r.rowKind==="static"&&!_T.has(r.slotId));default:return e}}function FT(e){if(typeof e=="number"&&!Number.isNaN(e))return e;const t=Number(e);return Number.isNaN(t)?0:t}function PT(e,t,r){const n=e.rowSlots.find(o=>o.kind==="static"?o.row.id===t.slotId:o.kind==="dynamic"&&o.block.id===t.slotId);if(n)return n.kind==="static"?n.row.cells[r]:n.block.cells[r]}function OT(e,t,r,n){const o=f=>Bu(n,t,f,r),i=(f,l)=>Bu(n,t,l,r,{slotId:f,rowKind:"static"}),s=(f,l="all")=>TT(t,l).reduce((p,g)=>p+FT(g.values[f]),0),a={...ts.functions,cell:o,cellInRow:i,SUM:s},c=Object.keys(a),u=Object.values(a);try{const f=new Function(...c,`return (${e});`)(...u);return f==null||typeof f=="number"&&Number.isNaN(f)?null:f}catch{return null}}function IT(e,t){return e.length!==t.length?!1:e.every((r,n)=>{const o=t[n];return r.slotId===o.slotId&&r.rowInstanceId===o.rowInstanceId&&JSON.stringify(r.values)===JSON.stringify(o.values)})}function MT(e,t){const r=t.rows.map(n=>({...n,values:{...n.values}}));for(const n of r)for(const o of e.columns){const i=PT(e,n,o.key);if(i?.kind==="formula"){const s=OT(i.expression,r,n,e),a=e.columns.find(c=>c.key===o.key);n.values[o.key]=Fi(s)?Vc(i,a)??s:s}}return{rows:r}}function Bo(e,t,r=8){let n={rows:t.rows.map(o=>({...o,values:{...o.values}}))};for(let o=0;o<r;o++){const i=MT(e,n);if(IT(i.rows,n.rows))return i;n=i}return n}function LT(e,t,r,n,o,i){const s=t.rows.map(a=>a.rowInstanceId!==r||a.slotId!==n?a:{...a,values:{...a.values,[o]:i}});return Bo(e,{rows:s})}function ly(e,t,r=[]){return t.map((n,o)=>{const i=typeof n=="object"&&n!==null?n:{},s=e.rowIdField&&i[e.rowIdField]!=null?String(i[e.rowIdField]):String(o),a={};for(const[u,f]of Object.entries(e.cells)){const l=r.find(p=>p.key===u);(f.kind==="api"&&f.path||f.kind==="currency"&&f.mode==="api"&&f.path)&&(a[u]=ga(We(i,f.path),f,l))}const c=a.service??a.tariff_type;return{slotId:e.id,rowKind:"dynamic",rowInstanceId:s,label:typeof c=="string"?c:void 0,values:a}})}function Wc(e,t,r){const n=[];for(const o of e.rowSlots)if(o.kind==="static"){const i=t.get(o.row.id);i&&n.push(i)}else n.push(...r.get(o.block.id)??[]);return n}function Rc(e,t){const r=new Map,n=new Map;for(const o of e.rowSlots)if(o.kind==="static"){const i=t?.rows.find(s=>s.slotId===o.row.id&&s.rowKind==="static");r.set(o.row.id,{slotId:o.row.id,rowKind:"static",rowInstanceId:o.row.id,label:o.row.label,values:kT(o.row.cells,i?.values?{...i.values}:{},e.columns)})}else{const i=t?.rows.filter(s=>s.slotId===o.block.id&&s.rowKind==="dynamic")??[];n.set(o.block.id,i.map(s=>({...s,values:{...s.values}})))}return{rows:Wc(e,r,n)}}function DT(e,t,r,n){const o=Rc(e,n),i=e.rowSlots.find(c=>c.kind==="dynamic"&&c.block.id===t);if(!i||i.kind!=="dynamic")return Bo(e,o);const s=new Map,a=new Map;for(const c of e.rowSlots)if(c.kind==="static"){const u=o.rows.find(f=>f.slotId===c.row.id&&f.rowKind==="static");u&&s.set(c.row.id,{...u,values:{...u.values}})}else{const u=c.block.id===t?ly(c.block,r,e.columns):o.rows.filter(f=>f.slotId===c.block.id&&f.rowKind==="dynamic");a.set(c.block.id,u.map(f=>({...f,values:{...f.values}})))}return Bo(e,{rows:Wc(e,s,a)})}function cy(e,t,r){const n=Rc(e,r);if(t==null||typeof t!="object"||Array.isArray(t))return Bo(e,n);const o=t,i=new Map,s=new Map;for(const a of e.rowSlots)if(a.kind==="static"){const u={...n.rows.find(l=>l.slotId===a.row.id&&l.rowKind==="static")?.values??{}},f=o[a.row.id]??o;for(const[l,p]of Object.entries(a.row.cells)){const g=e.columns.find(m=>m.key===l);(p.kind==="api"&&p.path||p.kind==="currency"&&p.mode==="api"&&p.path)&&(u[l]=ga(We(f,p.path),p,g))}i.set(a.row.id,{slotId:a.row.id,rowKind:"static",rowInstanceId:a.row.id,label:a.row.label,values:u})}else{const c=a.block.apiArrayPath??a.block.id,u=We(o,c);s.set(a.block.id,Array.isArray(u)?ly(a.block,u,e.columns):[])}return Bo(e,{rows:Wc(e,i,s)})}function dy(e){if(!e)return"";const t=[];switch(e.fontSize){case"xs":t.push("text-xs");break;case"sm":t.push("text-sm");break;case"base":t.push("text-base");break;case"lg":t.push("text-lg");break;case"xl":t.push("text-xl");break}return e.bold?t.push("font-bold"):e.fontSize&&t.push("font-medium"),e.italic&&t.push("italic"),e.underline&&t.push("underline"),t.join(" ")}function BT(e){const t=e?.color?.trim();return t?{color:t}:{}}function Kc(e){return{className:dy(e),style:BT(e)}}function $T(e){return e?!!(e.fontSize||e.bold||e.italic||e.underline||e.color?.trim()):!1}function jT(e,t){if(!e&&!t)return;const r={...e,...t};return $T(r)?r:void 0}function zT(e,t){const r=e?.kind==="label"?jT(t,e.cellStyle):e?.cellStyle;return Kc(r)}function Gc(e){return e==="center"?"text-center":e==="right"?"text-right":"text-left"}function uy(e,t){return e?.align?e.align:t?.align??"left"}function fy(e){const t=e.properties,r=t?.apiEndpoint?{apiEndpoint:t.apiEndpoint,apiMethod:t.apiMethod,apiKey:t.apiKey,apiRealtime:t.apiRealtime,apiQueryParams:t.apiQueryParams,apiHeaders:t.apiHeaders,apiBodyFields:t.apiBodyFields,apiAuth:t.apiAuth,valueSource:t.valueSource,dependentFields:t.dependentFields,apiResponsePath:t.apiResponsePath}:null,n=e.apidata||null;return r||n}function py(e){if(e.type!=="billingGrid")return!1;const t=fy(e),r=e.properties;return!!(t?.apiEndpoint&&(t?.valueSource==="api"||r?.valueSource==="api"))}function UT(e,t,r){let n=e;if(r?.trim()&&(n=We(e,r.trim())),n==null)return null;if(Array.isArray(n)){const o=t.rowSlots.find(i=>i.kind==="dynamic");return o?.kind==="dynamic"?{[o.block.apiArrayPath?.trim()||o.block.id]:n}:null}return typeof n=="object"?n:null}function ya(e){return JSON.stringify(e?.rows??[])}function VT({field:e,properties:t,formValues:r={},submissionContext:n,value:o,onChange:i}){const s=py(e),a=fy(e),[c,u]=w.useState(!1),[f,l]=w.useState(null),p=w.useRef(""),g=w.useRef(o);g.current=o;const m=w.useMemo(()=>{const x=a?.apiEndpoint||"",F=a?.apiQueryParams;return po(x,F)},[a?.apiEndpoint,a?.apiQueryParams]),h=w.useMemo(()=>{const x=new Set;for(const F of a?.dependentFields??[])typeof F=="string"&&F.trim()&&x.add(F.trim());return[...x]},[a?.dependentFields]),y=w.useMemo(()=>{const x=new Set([...m,...h]);if(x.size===0)return null;const F={};return x.forEach(N=>{F[N]=r[N]}),JSON.stringify(F)},[m,h,r]),S=w.useMemo(()=>JSON.stringify(n||{}),[n]),v=w.useMemo(()=>{const x=new Set;e.name?.trim()&&x.add(e.name.trim());const F=e.key;return typeof F=="string"&&F.trim()&&x.add(F.trim()),[...x]},[e.name,e.key]),A=w.useMemo(()=>JSON.stringify({rowSlots:t.rowSlots,columns:t.columns}),[t.rowSlots,t.columns]);return w.useEffect(()=>{const x=a?.apiEndpoint;if(!s||!x)return;let F=!1;const N=T=>{if(F)return;const P=ya(T),E=ya(g.current);P!==E&&p.current!==P&&(p.current=P,i(T))};return(async()=>{u(!0),l(null);try{const T=a?.apiMethod||"GET",P=a?.apiRealtime,E=ns({apiEndpoint:x,apiMethod:T,apiQueryParams:a?.apiQueryParams||{},formValues:r,submissionContext:n,apiRealtime:P,additionalRequiredFieldNames:h,excludeFormFieldNames:v});if(E.blocked){F||u(!1);return}const C={"Content-Type":"application/json"};a?.apiKey&&(C["X-CSCAPI-KEY"]=a.apiKey);const I=a?.apiAuth??Si(a?.apiHeaders)??{type:"none"};Object.assign(C,xi(I,{formValues:r,submissionContext:n,apiRealtime:P})),Object.assign(C,vn(wi(a?.apiHeaders),{formValues:r,submissionContext:n,apiRealtime:P}));const W=vn(a?.apiBodyFields,{formValues:r,submissionContext:n,apiRealtime:P}),M={method:T.toLowerCase(),url:Mr(E.url),headers:C};(E.postBodyBase!=null||Object.keys(W).length>0)&&(M.data={...E.postBodyBase??{},...W});const U=await Ct(M),V=UT(U.data,t,a?.apiResponsePath);if(!V){F||l("API response could not be mapped to billing grid rows.");return}const X=cy(t,V,g.current);N(X)}catch(T){if(F)return;let P="Failed to load billing data";const E=T;if(E.response){const C=E.response.data;if(E.response.status===404)P="API endpoint not found.";else if(E.response.status===401)P="Authentication failed.";else if(typeof C=="string")P=C;else if(C&&typeof C=="object"){const I=C;P=I.error||I.message||I.detail||P}}else E.message&&(P=String(E.message));l(P)}finally{F||u(!1)}})(),()=>{F=!0}},[s,a?.apiEndpoint,a?.apiMethod,a?.apiResponsePath,y,h,v,S,A]),{isLoading:c,error:f}}function HT(e,t,r){return e.rowSlots.find(n=>r==="static"?n.kind==="static"&&n.row.id===t:n.kind==="dynamic"&&n.block.id===t)}function my(e,t,r,n){const o=e.rowSlots.find(i=>r==="static"?i.kind==="static"&&i.row.id===t:i.kind==="dynamic"&&i.block.id===t);if(o)return o.kind==="static"?o.row.cells[n]:o.block.cells[n]}const WT=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:c,formValues:u,submissionContext:f})=>{const l=e.properties??{},p=l.columns??[],g=l.currencySymbol??"₹",m=l.emptyDisplay??"—",h=i||s,y=py(e),{isLoading:S}=VT({field:e,properties:l,formValues:u,submissionContext:f,value:t,onChange:r}),v=w.useMemo(()=>{const C=Rc(l,t);return Bo(l,C)},[l,t]),A=w.useRef("");w.useEffect(()=>{const C=ya(v),I=ya(t);C===I||C===A.current||(A.current=C,r(v))},[v,t,r]),w.useEffect(()=>{!t?.rows?.length&&v.rows.length&&!y&&r(v)},[t,v,r,y]);const x=w.useCallback((C,I,W,M,U)=>{if(h)return;const V=U==="number"?CT(M):M===""?null:M,X=LT(l,v,C,I,W,V);r(X)},[h,v,r,l]),F=(C,I,W,M,U,V)=>{const X=p.find(z=>z.key===U),B=my(l,C,I,U),L=Gc(uy(B,X)),D=Hc(V,B,X),K=HT(l,C,I),ae=K?.kind==="static"?K.row.labelStyle:K?.kind==="dynamic"?K.block.labelStyle:void 0,j=zT(B,ae);if(B?.kind==="label")return d.jsx("span",{className:H(Ti,j.className||"font-medium",L,!j.style.color&&"text-foreground"),style:j.style,children:M??m});if(B?.kind==="input"&&!h){const z=D==null||D===""?"":String(D);return d.jsx(mn,{type:"text",inputMode:B.inputType==="number"?"decimal":"text",value:z,onChange:le=>x(W,C,U,le.target.value,B.inputType),onBlur:n,className:H(wT,"w-full min-w-0",L,j.className),style:j.style,disabled:h})}if(B?.kind==="currency"){const z=sy(B);if(z==="static"){const ie=B.value!==void 0&&B.value!==""?Hc(null,{...B,mode:"static"},X):D;return d.jsx("span",{className:H(Ti,"tabular-nums",L,j.className),style:j.style,children:iy(ie,{currencySymbol:g,emptyDisplay:m})})}if(z==="api"||h)return d.jsx("span",{className:H(Ti,"tabular-nums",L,j.className),style:j.style,children:iy(D,{currencySymbol:g,emptyDisplay:m})});const le=ET(D);return d.jsxs("div",{className:H(ST,L==="text-center"&&"justify-center",L==="text-right"&&"justify-end",L==="text-left"&&"justify-start",j.className),style:j.style,children:[d.jsx("span",{className:"shrink-0 tabular-nums",children:g}),d.jsx(mn,{type:"text",inputMode:"decimal",value:le,onChange:ie=>x(W,C,U,ie.target.value,"number"),onBlur:n,className:xT,disabled:h})]})}return B?.kind==="static"?d.jsx("span",{className:H(Ti,L,j.className,!j.style.color&&"text-muted-foreground"),style:j.style,children:B.value}):d.jsx("span",{className:H(Ti,L,j.className),style:j.style,children:oy(D,X,{currencySymbol:g,emptyDisplay:m})})},N=l.gridTitle?.trim()??"",k=Math.max(1,e.position?.rowSpan??1),T=Math.max(1,e.position?.columnSpan??1),P=k>=3?"py-4":k>=2?"py-3":"py-2",E=T>=3?"px-4":T>=2?"px-3":"px-2";return p.length===0?d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsx("div",{className:"p-4 border rounded-md bg-muted/50 text-sm text-muted-foreground",children:"No columns defined for this billing grid"})}):d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{id:ft(e),className:H("relative flex h-full min-h-0 w-full min-w-0 max-w-full flex-1 flex-col border rounded-lg overflow-hidden shadow-sm bg-background",o&&"border-destructive",h&&"opacity-70"),"aria-describedby":Lt(e,!!o),"aria-invalid":Xt(!!o),"aria-required":a,children:[S&&d.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/60",children:d.jsx(mo,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),N?d.jsx("div",{className:H("shrink-0 px-4 py-2 border-b bg-muted/40",dy(l.gridTitleStyle)||"text-muted-foreground"),style:Kc(l.gridTitleStyle).style,children:N}):null,d.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:d.jsxs("table",{className:"w-full h-full min-h-full border-collapse text-sm table-fixed",style:l.minWidth?{minWidth:l.minWidth}:void 0,children:[d.jsx("thead",{children:d.jsx("tr",{className:"border-b border-border bg-muted/60",children:p.map(C=>{const I=Kc(C.headerStyle);return d.jsx("th",{className:H(E,P,"text-xs uppercase tracking-wider whitespace-nowrap",Gc(C.align),I.className||"font-semibold text-muted-foreground"),style:I.style,children:C.label},C.id)})})}),d.jsx("tbody",{className:"h-full",children:v.rows.length===0?d.jsx("tr",{children:d.jsx("td",{colSpan:p.length,className:H(E,"py-8 text-center text-sm text-muted-foreground"),children:"No billing rows configured"})}):v.rows.map(C=>d.jsx("tr",{className:"border-b border-border/60",children:p.map(I=>{const W=my(l,C.slotId,C.rowKind,I.key),M=uy(W,I);return d.jsx("td",{className:H(E,P,AT,Gc(M)),children:F(C.slotId,C.rowKind,C.rowInstanceId,C.label,I.key,C.values[I.key])},I.id)})},`${C.slotId}-${C.rowInstanceId}`))})]})})]})})};function qc(e,t,r){return cy(e,t,r)}const RT=({field:e,value:t,error:r,disabled:n,isRequired:o,className:i,formValues:s={},submissionContext:a,extraSubmitPayload:c,skipApiCall:u=!1,prepopulateResponse:f=null})=>{const l=e.properties||{},p=l.source??"manual",g=Array.isArray(l.statuses)?l.statuses:[],m=(l.dataPath||"data").trim(),h=l.showStatusText===!0,y=(l.statusTextPath||"data.admissionStatus").trim(),S=l.showCurrentIndicator!==!1,[v,A]=w.useState(null),[x,F]=w.useState(!1),[N,k]=w.useState(null),T=ja.useParams(),P=w.useRef(s),E=w.useRef(a),C=w.useRef(c),I=w.useRef(T);P.current=s,E.current=a,C.current=c,I.current=T;const W=w.useCallback(async()=>{const B=l.apiEndpoint?.trim();if(!B){k("Status API endpoint is not configured");return}F(!0),k(null);try{const L=E.current,D=C.current,K=L!=null&&typeof L=="object"?{...L,...D||{}}:D||{},ae=Mr(Rr(B,P.current,I.current,K,void 0,f??void 0)),j=(l.apiMethod||"GET").toUpperCase(),z=await fetch(ae,{method:j,headers:j==="POST"?{"Content-Type":"application/json"}:void 0});if(!z.ok)throw new Error(`HTTP ${z.status}`);const le=await z.json(),ie=m?We(le,m):le;A(ie&&typeof ie=="object"?ie:{})}catch(L){k(L instanceof Error?L.message:"Failed to load status"),A(null)}finally{F(!1)}},[l.apiEndpoint,l.apiMethod,m,f]);w.useEffect(()=>{p==="api"&&!u&&W()},[p,u,W]);const M=p==="api"?v:t&&typeof t=="object"?(m?We(t,m):null)??t:null,U=h&&y&&M?String(We(M,y)??We({data:M},y)??""):"",V=B=>{if(!M||typeof M!="object")return!1;const L=M[B];return L===!0||L==="true"||L===1};let X=!1;return d.jsx(At,{field:e,error:r||N||void 0,isRequired:o,className:H(i,"!space-y-0 h-full min-h-0 flex flex-col"),children:d.jsxs("div",{className:"rounded-lg border bg-card p-4 h-full min-h-0 flex flex-col",children:[x&&d.jsx("div",{className:"text-sm text-muted-foreground py-2",children:"Loading status..."}),h&&U&&!x&&d.jsx("p",{className:"text-sm text-muted-foreground mb-3 shrink-0","data-status-text":!0,children:U}),!x&&d.jsx("ul",{className:"flex-1 min-h-0 flex flex-col gap-y-8 overflow-y-auto pr-1 py-1",children:g.map(B=>{const L=V(B.key),D=S&&L&&!X;return D&&(X=!0),d.jsxs("li",{className:H("flex items-center gap-3 text-sm",L?"text-foreground":"text-muted-foreground"),children:[L?d.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-green-600 text-white","aria-hidden":!0,children:d.jsx(cs,{className:"h-3 w-3"})}):d.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full border-2 border-muted-foreground/40 bg-muted/50","aria-hidden":!0,children:d.jsx(Yu,{className:"h-2.5 w-2.5 text-muted-foreground/60"})}),d.jsx("span",{className:"flex-1 min-w-0",children:B.label}),D&&d.jsx("span",{className:"shrink-0 text-xs font-medium text-primary",children:"Current"})]},B.key)})}),!x&&g.length===0&&d.jsx("p",{className:"text-sm text-muted-foreground",children:"No statuses configured."})]})})};function Yc(e,t){if(!t||!e)return;const r=t.split(".");let n=e;for(const o of r){if(n==null||typeof n!="object")return;n=n[o]}return n}function $o(e,t){if(t){const r=Yc(e,t);if(r!=null)return String(r)}return e.email!=null?String(e.email):e.personal_email!=null?String(e.personal_email):e.id!=null?String(e.id):JSON.stringify(e)}function KT(e,t,r,n){if(r?.length){const i=n??" | ",s=r.map(a=>Yc(e,a)).filter(a=>a!=null).map(a=>String(a));if(s.length)return s.join(i)}if(t){const i=Yc(e,t);if(i!=null)return String(i)}if(e.name!=null&&e.email!=null)return`${e.name} <${e.email}>`;if(e.name!=null)return String(e.name);if(e.email!=null)return String(e.email);const o=e.personal_email;return o!=null?String(o):JSON.stringify(e)}const GT=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a,submissionContext:c})=>{const u=e.properties||{},{dataSourceContextKey:f,labelField:l="name",valueField:p="email",displayFields:g,displayFieldsSeparator:m=" | ",showSelectAll:h=!0,selectAllByDefault:y=!0}=u;console.log("[SelectableList] Step 1: render",{fieldName:e.name,valueIsArray:Array.isArray(t),valueLength:Array.isArray(t)?t.length:0,valueSample:Array.isArray(t)&&t.length>0?t.slice(0,2):t,submissionContextKeys:c?Object.keys(c):[],dataSourceContextKey:f,contextKeyValue:c&&f?c[f]:void 0});const S=w.useMemo(()=>{if(!f||!c)return[];const C=c[f];return Array.isArray(C)?C:[]},[f,c]);console.log("[SelectableList] Step 2: contextList from submissionContext",{fieldName:e.name,contextListLength:S.length,contextListSample:S.length>0?S.slice(0,2):[]});const[v,A]=w.useState(()=>S.length>0?S:Array.isArray(t)?t:[]);w.useEffect(()=>{if(S.length>0){console.log("[SelectableList] Step 3: sync fullList from context",{fieldName:e.name,contextListLength:S.length}),A(S);return}Array.isArray(t)&&t.length>0&&A(C=>{const I=C.length===0||t.length>C.length?t:C;return console.log("[SelectableList] Step 3: sync fullList from value",{fieldName:e.name,valueLength:t.length,prevLength:C.length,nextLength:I.length}),I})},[S,t]);const x=w.useMemo(()=>{const C=Array.isArray(t)?t:[];return new Set(C.map(W=>$o(W,p)))},[t,p]),F=v.length>0&&v.every(C=>x.has($o(C,p))),N=v.some(C=>x.has($o(C,p))),k=w.useCallback((C,I)=>{const W=$o(C,p),M=Array.isArray(t)?t:[];I?x.has(W)||r([...M,C]):r(M.filter(U=>$o(U,p)!==W)),n?.()},[t,p,x,r,n]),T=w.useCallback(C=>{r(C===!0?[...v]:[]),n?.()},[v,r,n]),P=v.length>0?v:Array.isArray(t)?t:[],E=i||e.disabled;return console.log("[SelectableList] Data in list",{fieldName:e.name,listLength:P.length,listSource:v.length>0?"fullList":"value",valueLength:Array.isArray(t)?t.length:0,fullListLength:v.length,listData:P.length>0?P:[],listDataFirstThree:P.length>0?P.slice(0,3):[]}),d.jsx("div",{className:H("relative z-10 flex flex-col min-h-0 h-full w-full",P.length>0&&"min-h-[14rem]",a),children:d.jsx(At,{field:e,error:o,isRequired:s,className:H("flex-1 min-h-0 flex flex-col",P.length>0&&"min-h-[14rem]"),children:d.jsx("div",{className:H("flex-1 min-h-0 flex flex-col",P.length>0&&"min-h-[14rem]"),children:d.jsxs("div",{className:H("flex-1 min-h-0 flex flex-col",P.length>0&&"overflow-visible"),children:[d.jsxs("div",{role:"listbox","aria-multiselectable":!0,className:H("border rounded-md divide-y overflow-y-auto overflow-x-hidden bg-muted/30 overscroll-contain touch-pan-y pb-3 pr-3 z-20 relative",P.length>0?"flex-1 min-h-0":"min-h-0"),children:[h&&P.length>0&&d.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-3 py-2 sticky top-0 bg-background border-b z-10 shrink-0",children:[d.jsx(Js,{id:`${ft(e)}-select-all`,checked:F?!0:N?"indeterminate":!1,onCheckedChange:T,disabled:E,"aria-label":"Select all"}),d.jsxs(Pn,{htmlFor:`${ft(e)}-select-all`,className:"text-sm font-medium cursor-pointer",children:["Select all (",P.length,")"]}),d.jsxs("div",{className:"flex gap-1 ml-auto",children:[d.jsx(Qt,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs",disabled:E||F,onClick:()=>{r([...v]),n?.()},children:"Select all"}),d.jsx(Qt,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs",disabled:E||!N,onClick:()=>{r([]),n?.()},children:"Unselect all"})]})]}),P.length===0?d.jsx("p",{className:"px-3 py-4 text-sm text-muted-foreground",children:"No items to display."}):d.jsx(d.Fragment,{children:P.map((C,I)=>{const W=$o(C,p),M=x.has(W),U=`${ft(e)}-${I}-${W}`;return d.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 min-h-[2.5rem] hover:bg-muted/50 shrink-0",role:"row",children:[d.jsx(Js,{id:U,checked:M,onCheckedChange:V=>k(C,V===!0),disabled:E,"aria-describedby":Lt(e,!!o)}),d.jsx(Pn,{htmlFor:U,className:"text-sm cursor-pointer flex-1 truncate",children:KT(C,l,g,m)})]},W)})})]}),P.length>0&&x.size===0&&d.jsxs("p",{className:"flex items-center gap-1.5 mt-2 text-sm text-amber-600 dark:text-amber-500 shrink-0",role:"status",children:[d.jsx(cS,{className:"h-4 w-4 shrink-0"}),"Please select at least one item."]})]})})})})},hy=({field:e,children:t,className:r})=>{const n=e.properties,o=n?.collapsible??!1,i=n?.defaultCollapsed??!1,s=n?.columns??1,[a,c]=w.useState(i),u=()=>{o&&c(!a)},f={1:"grid-cols-1",2:"grid-cols-1 md:grid-cols-2",3:"grid-cols-1 md:grid-cols-2 lg:grid-cols-3",4:"grid-cols-1 md:grid-cols-2 lg:grid-cols-4"};return d.jsxs("div",{className:H("border rounded-lg bg-card",r),children:[d.jsxs("div",{className:H("flex items-center gap-2 px-4 py-3 border-b bg-muted/50",o&&"cursor-pointer hover:bg-muted/70 transition-colors"),onClick:u,children:[o&&d.jsx("span",{className:"text-muted-foreground",children:a?d.jsx(qu,{className:"h-4 w-4"}):d.jsx(ni,{className:"h-4 w-4"})}),d.jsx("h3",{className:"font-medium text-sm",children:e.label}),e.description&&d.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:e.description})]}),!a&&d.jsx("div",{className:H("p-4 grid gap-4",f[s]),children:t})]})};var qT=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],YT=qT.reduce((e,t)=>{const r=ul(`Primitive.${t}`),n=b.forwardRef((o,i)=>{const{asChild:s,...a}=o,c=s?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(c,{...a,ref:i})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),XT="Separator",gy="horizontal",JT=["horizontal","vertical"],yy=b.forwardRef((e,t)=>{const{decorative:r,orientation:n=gy,...o}=e,i=QT(n)?n:gy,a=r?{role:"none"}:{"aria-orientation":i==="vertical"?i:void 0,role:"separator"};return d.jsx(YT.div,{"data-orientation":i,...a,...o,ref:t})});yy.displayName=XT;function QT(e){return JT.includes(e)}var ZT=yy;function Xc({className:e,orientation:t="horizontal",decorative:r=!0,...n}){return d.jsx(ZT,{"data-slot":"separator",decorative:r,orientation:t,className:H("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",e),...n})}const eF=({field:e,className:t})=>d.jsx("div",{className:H("py-2",t),children:d.jsx(Xc,{})}),tF={h1:"text-3xl font-bold",h2:"text-2xl font-bold",h3:"text-xl font-semibold",h4:"text-lg font-semibold",h5:"text-base font-medium",h6:"text-sm font-medium"},rF=({field:e,className:t})=>{const r=e.properties,n=r?.headingLevel??"h3",o=r?.showHorizontalLine??!0,i=tF[n],s=n;return d.jsxs("div",{className:H("w-full min-w-0 space-y-1",t),children:[d.jsx(s,{className:H("m-0 text-foreground",i),children:e.label||"Header"}),e.description&&d.jsx("p",{className:"text-sm text-muted-foreground",children:e.description}),o&&d.jsx(Xc,{className:"w-full"})]})},nF={"top-left":"justify-start","top-center":"justify-center","top-right":"justify-end","middle-left":"justify-start",center:"justify-center","middle-right":"justify-end","bottom-left":"justify-start","bottom-center":"justify-center","bottom-right":"justify-end"},oF={h1:"text-3xl font-bold",h2:"text-2xl font-bold",h3:"text-xl font-semibold",h4:"text-lg font-semibold",h5:"text-base font-medium",h6:"text-sm font-medium"},iF=({field:e,className:t})=>{const r=e.properties,n=r?.position??"top-left",o=r?.headingLevel??"h3",i=r?.showHorizontalLine??!0,s=nF[n],a=oF[o],c=o;return d.jsxs("div",{className:H("w-full min-w-0 space-y-2",t),children:[d.jsx("div",{className:H("flex w-full",s),children:d.jsx(c,{className:H("m-0 text-foreground",a),children:e.label||"Section Heading"})}),i&&d.jsx(Xc,{className:"w-full"})]})},sF=({field:e,className:t})=>{const r=e.appearance?.size||"md",n={sm:"h-4",md:"h-8",lg:"h-12"};return d.jsx("div",{className:H(n[r],t),"aria-hidden":"true"})};function by(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function aF(e){if(Array.isArray(e))return e}function lF(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,o,i,s,a=[],c=!0,u=!1;try{if(i=(r=r.call(e)).next,t!==0)for(;!(c=(n=i.call(r)).done)&&(a.push(n.value),a.length!==t);c=!0);}catch(f){u=!0,o=f}finally{try{if(!c&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(u)throw o}}return a}}function cF(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
51
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function dF(e,t){return aF(e)||lF(e,t)||uF(e,t)||cF()}function uF(e,t){if(e){if(typeof e=="string")return by(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?by(e,t):void 0}}const vy=Object.entries,wy=Object.setPrototypeOf,fF=Object.isFrozen,pF=Object.getPrototypeOf,mF=Object.getOwnPropertyDescriptor;let ur=Object.freeze,Dr=Object.seal,jo=Object.create,Sy=typeof Reflect<"u"&&Reflect,Jc=Sy.apply,Qc=Sy.construct;ur||(ur=function(t){return t}),Dr||(Dr=function(t){return t}),Jc||(Jc=function(t,r){for(var n=arguments.length,o=new Array(n>2?n-2:0),i=2;i<n;i++)o[i-2]=arguments[i];return t.apply(r,o)}),Qc||(Qc=function(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];return new t(...n)});const zo=zt(Array.prototype.forEach),hF=zt(Array.prototype.lastIndexOf),xy=zt(Array.prototype.pop),Uo=zt(Array.prototype.push),gF=zt(Array.prototype.splice),fr=Array.isArray,Pi=zt(String.prototype.toLowerCase),Zc=zt(String.prototype.toString),Ay=zt(String.prototype.match),Vo=zt(String.prototype.replace),Cy=zt(String.prototype.indexOf),yF=zt(String.prototype.trim),bF=zt(Number.prototype.toString),vF=zt(Boolean.prototype.toString),Ey=typeof BigInt>"u"?null:zt(BigInt.prototype.toString),Ny=typeof Symbol>"u"?null:zt(Symbol.prototype.toString),Mt=zt(Object.prototype.hasOwnProperty),Oi=zt(Object.prototype.toString),rr=zt(RegExp.prototype.test),ba=wF(TypeError);function zt(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];return Jc(e,t,n)}}function wF(e){return function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return Qc(e,r)}}function Ze(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Pi;if(wy&&wy(e,null),!fr(t))return e;let n=t.length;for(;n--;){let o=t[n];if(typeof o=="string"){const i=r(o);i!==o&&(fF(t)||(t[n]=i),o=i)}e[o]=!0}return e}function SF(e){for(let t=0;t<e.length;t++)Mt(e,t)||(e[t]=null);return e}function yr(e){const t=jo(null);for(const n of vy(e)){var r=dF(n,2);const o=r[0],i=r[1];Mt(e,o)&&(fr(i)?t[o]=SF(i):i&&typeof i=="object"&&i.constructor===Object?t[o]=yr(i):t[o]=i)}return t}function xF(e){switch(typeof e){case"string":return e;case"number":return bF(e);case"boolean":return vF(e);case"bigint":return Ey?Ey(e):"0";case"symbol":return Ny?Ny(e):"Symbol()";case"undefined":return Oi(e);case"function":case"object":{if(e===null)return Oi(e);const t=e,r=io(t,"toString");if(typeof r=="function"){const n=r(t);return typeof n=="string"?n:Oi(n)}return Oi(e)}default:return Oi(e)}}function io(e,t){for(;e!==null;){const n=mF(e,t);if(n){if(n.get)return zt(n.get);if(typeof n.value=="function")return zt(n.value)}e=pF(e)}function r(){return null}return r}function AF(e){try{return rr(e,""),!0}catch{return!1}}const ky=ur(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),ed=ur(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),td=ur(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),CF=ur(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),rd=ur(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),EF=ur(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),_y=ur(["#text"]),Ty=ur(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),nd=ur(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Fy=ur(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),va=ur(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),NF=Dr(/{{[\w\W]*|^[\w\W]*}}/g),kF=Dr(/<%[\w\W]*|^[\w\W]*%>/g),_F=Dr(/\${[\w\W]*/g),TF=Dr(/^data-[\-\w.\u00B7-\uFFFF]+$/),FF=Dr(/^aria-[\-\w]+$/),Py=Dr(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),PF=Dr(/^(?:\w+script|data):/i),OF=Dr(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),IF=Dr(/^html$/i),MF=Dr(/^[a-z][.\w]*(-[.\w]+)+$/i),Ho={element:1,text:3,progressingInstruction:7,comment:8,document:9},LF=function(){return typeof window>"u"?null:window},DF=function(t,r){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let n=null;const o="data-tt-policy-suffix";r&&r.hasAttribute(o)&&(n=r.getAttribute(o));const i="dompurify"+(n?"#"+n:"");try{return t.createPolicy(i,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},Oy=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Iy(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:LF();const t=ke=>Iy(ke);if(t.version="3.4.5",t.removed=[],!e||!e.document||e.document.nodeType!==Ho.document||!e.Element)return t.isSupported=!1,t;let r=e.document;const n=r,o=n.currentScript,i=e.DocumentFragment,s=e.HTMLTemplateElement,a=e.Node,c=e.Element,u=e.NodeFilter,f=e.NamedNodeMap,l=f===void 0?e.NamedNodeMap||e.MozNamedAttrMap:f,p=e.HTMLFormElement,g=e.DOMParser,m=e.trustedTypes,h=c.prototype,y=io(h,"cloneNode"),S=io(h,"remove"),v=io(h,"nextSibling"),A=io(h,"childNodes"),x=io(h,"parentNode"),F=a&&a.prototype?io(a.prototype,"nodeType"):null;if(typeof s=="function"){const ke=r.createElement("template");ke.content&&ke.content.ownerDocument&&(r=ke.content.ownerDocument)}let N,k="";const T=r,P=T.implementation,E=T.createNodeIterator,C=T.createDocumentFragment,I=T.getElementsByTagName,W=n.importNode;let M=Oy();t.isSupported=typeof vy=="function"&&typeof x=="function"&&P&&P.createHTMLDocument!==void 0;const U=NF,V=kF,X=_F,B=TF,L=FF,D=PF,K=OF,ae=MF;let j=Py,z=null;const le=Ze({},[...ky,...ed,...td,...rd,..._y]);let ie=null;const G=Ze({},[...Ty,...nd,...Fy,...va]);let ee=Object.seal(jo(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ae=null,te=null;const oe=Object.seal(jo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let me=!0,Me=!0,De=!1,ne=!0,ge=!1,Se=!0,yt=!1,Nt=!1,Ut=!1,Ot=!1,Er=!1,Dt=!1,sr=!0,Vt=!1;const he="user-content-";let we=!0,J=!1,$={},fe=null;const Ve=Ze({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Fe=null;const ze=Ze({},["audio","video","img","source","image","track"]);let st=null;const ht=Ze({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),lt="http://www.w3.org/1998/Math/MathML",ct="http://www.w3.org/2000/svg",nt="http://www.w3.org/1999/xhtml";let ot=nt,ar=!1,vt=null;const er=Ze({},[lt,ct,nt],Zc);let Je=Ze({},["mi","mo","mn","ms","mtext"]),ut=Ze({},["annotation-xml"]);const Ye=Ze({},["title","style","font","a","script"]);let nr=null;const br=["application/xhtml+xml","text/html"],vr="text/html";let kt=null,Nr=null;const lr=r.createElement("form"),xn=function(O){return O instanceof RegExp||O instanceof Function},un=function(){let O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Nr&&Nr===O)return;(!O||typeof O!="object")&&(O={}),O=yr(O),nr=br.indexOf(O.PARSER_MEDIA_TYPE)===-1?vr:O.PARSER_MEDIA_TYPE,kt=nr==="application/xhtml+xml"?Zc:Pi,z=Mt(O,"ALLOWED_TAGS")&&fr(O.ALLOWED_TAGS)?Ze({},O.ALLOWED_TAGS,kt):le,ie=Mt(O,"ALLOWED_ATTR")&&fr(O.ALLOWED_ATTR)?Ze({},O.ALLOWED_ATTR,kt):G,vt=Mt(O,"ALLOWED_NAMESPACES")&&fr(O.ALLOWED_NAMESPACES)?Ze({},O.ALLOWED_NAMESPACES,Zc):er,st=Mt(O,"ADD_URI_SAFE_ATTR")&&fr(O.ADD_URI_SAFE_ATTR)?Ze(yr(ht),O.ADD_URI_SAFE_ATTR,kt):ht,Fe=Mt(O,"ADD_DATA_URI_TAGS")&&fr(O.ADD_DATA_URI_TAGS)?Ze(yr(ze),O.ADD_DATA_URI_TAGS,kt):ze,fe=Mt(O,"FORBID_CONTENTS")&&fr(O.FORBID_CONTENTS)?Ze({},O.FORBID_CONTENTS,kt):Ve,Ae=Mt(O,"FORBID_TAGS")&&fr(O.FORBID_TAGS)?Ze({},O.FORBID_TAGS,kt):yr({}),te=Mt(O,"FORBID_ATTR")&&fr(O.FORBID_ATTR)?Ze({},O.FORBID_ATTR,kt):yr({}),$=Mt(O,"USE_PROFILES")?O.USE_PROFILES&&typeof O.USE_PROFILES=="object"?yr(O.USE_PROFILES):O.USE_PROFILES:!1,me=O.ALLOW_ARIA_ATTR!==!1,Me=O.ALLOW_DATA_ATTR!==!1,De=O.ALLOW_UNKNOWN_PROTOCOLS||!1,ne=O.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ge=O.SAFE_FOR_TEMPLATES||!1,Se=O.SAFE_FOR_XML!==!1,yt=O.WHOLE_DOCUMENT||!1,Ot=O.RETURN_DOM||!1,Er=O.RETURN_DOM_FRAGMENT||!1,Dt=O.RETURN_TRUSTED_TYPE||!1,Ut=O.FORCE_BODY||!1,sr=O.SANITIZE_DOM!==!1,Vt=O.SANITIZE_NAMED_PROPS||!1,we=O.KEEP_CONTENT!==!1,J=O.IN_PLACE||!1,j=AF(O.ALLOWED_URI_REGEXP)?O.ALLOWED_URI_REGEXP:Py,ot=typeof O.NAMESPACE=="string"?O.NAMESPACE:nt,Je=Mt(O,"MATHML_TEXT_INTEGRATION_POINTS")&&O.MATHML_TEXT_INTEGRATION_POINTS&&typeof O.MATHML_TEXT_INTEGRATION_POINTS=="object"?yr(O.MATHML_TEXT_INTEGRATION_POINTS):Ze({},["mi","mo","mn","ms","mtext"]),ut=Mt(O,"HTML_INTEGRATION_POINTS")&&O.HTML_INTEGRATION_POINTS&&typeof O.HTML_INTEGRATION_POINTS=="object"?yr(O.HTML_INTEGRATION_POINTS):Ze({},["annotation-xml"]);const re=Mt(O,"CUSTOM_ELEMENT_HANDLING")&&O.CUSTOM_ELEMENT_HANDLING&&typeof O.CUSTOM_ELEMENT_HANDLING=="object"?yr(O.CUSTOM_ELEMENT_HANDLING):jo(null);if(ee=jo(null),Mt(re,"tagNameCheck")&&xn(re.tagNameCheck)&&(ee.tagNameCheck=re.tagNameCheck),Mt(re,"attributeNameCheck")&&xn(re.attributeNameCheck)&&(ee.attributeNameCheck=re.attributeNameCheck),Mt(re,"allowCustomizedBuiltInElements")&&typeof re.allowCustomizedBuiltInElements=="boolean"&&(ee.allowCustomizedBuiltInElements=re.allowCustomizedBuiltInElements),ge&&(Me=!1),Er&&(Ot=!0),$&&(z=Ze({},_y),ie=jo(null),$.html===!0&&(Ze(z,ky),Ze(ie,Ty)),$.svg===!0&&(Ze(z,ed),Ze(ie,nd),Ze(ie,va)),$.svgFilters===!0&&(Ze(z,td),Ze(ie,nd),Ze(ie,va)),$.mathMl===!0&&(Ze(z,rd),Ze(ie,Fy),Ze(ie,va))),oe.tagCheck=null,oe.attributeCheck=null,Mt(O,"ADD_TAGS")&&(typeof O.ADD_TAGS=="function"?oe.tagCheck=O.ADD_TAGS:fr(O.ADD_TAGS)&&(z===le&&(z=yr(z)),Ze(z,O.ADD_TAGS,kt))),Mt(O,"ADD_ATTR")&&(typeof O.ADD_ATTR=="function"?oe.attributeCheck=O.ADD_ATTR:fr(O.ADD_ATTR)&&(ie===G&&(ie=yr(ie)),Ze(ie,O.ADD_ATTR,kt))),Mt(O,"ADD_URI_SAFE_ATTR")&&fr(O.ADD_URI_SAFE_ATTR)&&Ze(st,O.ADD_URI_SAFE_ATTR,kt),Mt(O,"FORBID_CONTENTS")&&fr(O.FORBID_CONTENTS)&&(fe===Ve&&(fe=yr(fe)),Ze(fe,O.FORBID_CONTENTS,kt)),Mt(O,"ADD_FORBID_CONTENTS")&&fr(O.ADD_FORBID_CONTENTS)&&(fe===Ve&&(fe=yr(fe)),Ze(fe,O.ADD_FORBID_CONTENTS,kt)),we&&(z["#text"]=!0),yt&&Ze(z,["html","head","body"]),z.table&&(Ze(z,["tbody"]),delete Ae.tbody),O.TRUSTED_TYPES_POLICY){if(typeof O.TRUSTED_TYPES_POLICY.createHTML!="function")throw ba('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof O.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ba('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');N=O.TRUSTED_TYPES_POLICY,k=N.createHTML("")}else N===void 0&&(N=DF(m,o)),N!==null&&typeof k=="string"&&(k=N.createHTML(""));ur&&ur(O),Nr=O},$r=Ze({},[...ed,...td,...CF]),zn=Ze({},[...rd,...EF]),Bt=function(O){let re=x(O);(!re||!re.tagName)&&(re={namespaceURI:ot,tagName:"template"});const ve=Pi(O.tagName),rt=Pi(re.tagName);return vt[O.namespaceURI]?O.namespaceURI===ct?re.namespaceURI===nt?ve==="svg":re.namespaceURI===lt?ve==="svg"&&(rt==="annotation-xml"||Je[rt]):!!$r[ve]:O.namespaceURI===lt?re.namespaceURI===nt?ve==="math":re.namespaceURI===ct?ve==="math"&&ut[rt]:!!zn[ve]:O.namespaceURI===nt?re.namespaceURI===ct&&!ut[rt]||re.namespaceURI===lt&&!Je[rt]?!1:!zn[ve]&&(Ye[ve]||!$r[ve]):!!(nr==="application/xhtml+xml"&&vt[O.namespaceURI]):!1},Ht=function(O){Uo(t.removed,{element:O});try{x(O).removeChild(O)}catch{S(O)}},wr=function(O,re){try{Uo(t.removed,{attribute:re.getAttributeNode(O),from:re})}catch{Uo(t.removed,{attribute:null,from:re})}if(re.removeAttribute(O),O==="is")if(Ot||Er)try{Ht(re)}catch{}else try{re.setAttribute(O,"")}catch{}},Jr=function(O){let re=null,ve=null;if(Ut)O="<remove></remove>"+O;else{const St=Ay(O,/^[\r\n\t ]+/);ve=St&&St[0]}nr==="application/xhtml+xml"&&ot===nt&&(O='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+O+"</body></html>");const rt=N?N.createHTML(O):O;if(ot===nt)try{re=new g().parseFromString(rt,nr)}catch{}if(!re||!re.documentElement){re=P.createDocument(ot,"template",null);try{re.documentElement.innerHTML=ar?k:rt}catch{}}const wt=re.body||re.documentElement;return O&&ve&&wt.insertBefore(r.createTextNode(ve),wt.childNodes[0]||null),ot===nt?I.call(re,yt?"html":"body")[0]:yt?re.documentElement:wt},qt=function(O){return E.call(O.ownerDocument||O,O,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},cr=function(O){O.normalize();const re=E.call(O.ownerDocument||O,O,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null);let ve=re.nextNode();for(;ve;){let rt=ve.data;zo([U,V,X],wt=>{rt=Vo(rt,wt," ")}),ve.data=rt,ve=re.nextNode()}},Un=function(O){return O instanceof p&&(typeof O.nodeName!="string"||typeof O.textContent!="string"||typeof O.removeChild!="function"||!(O.attributes instanceof l)||typeof O.removeAttribute!="function"||typeof O.setAttribute!="function"||typeof O.namespaceURI!="string"||typeof O.insertBefore!="function"||typeof O.hasChildNodes!="function")},zi=function(O){if(!F||typeof O!="object"||O===null)return!1;try{return typeof F(O)=="number"}catch{return!1}};function _t(ke,O,re){zo(ke,ve=>{ve.call(t,O,re,Nr)})}const Ui=function(O){let re=null;if(_t(M.beforeSanitizeElements,O,null),Un(O))return Ht(O),!0;const ve=kt(O.nodeName);if(_t(M.uponSanitizeElement,O,{tagName:ve,allowedTags:z}),Se&&O.hasChildNodes()&&!zi(O.firstElementChild)&&rr(/<[/\w!]/g,O.innerHTML)&&rr(/<[/\w!]/g,O.textContent)||Se&&O.namespaceURI===nt&&ve==="style"&&zi(O.firstElementChild)||O.nodeType===Ho.progressingInstruction||Se&&O.nodeType===Ho.comment&&rr(/<[/\w]/g,O.data))return Ht(O),!0;if(Ae[ve]||!(oe.tagCheck instanceof Function&&oe.tagCheck(ve))&&!z[ve]){if(!Ae[ve]&&jr(ve)&&(ee.tagNameCheck instanceof RegExp&&rr(ee.tagNameCheck,ve)||ee.tagNameCheck instanceof Function&&ee.tagNameCheck(ve)))return!1;if(we&&!fe[ve]){const rt=x(O)||O.parentNode,wt=A(O)||O.childNodes;if(wt&&rt){const St=wt.length;for(let Wt=St-1;Wt>=0;--Wt){const Et=y(wt[Wt],!0);rt.insertBefore(Et,v(O))}}}return Ht(O),!0}return O instanceof c&&!Bt(O)||(ve==="noscript"||ve==="noembed"||ve==="noframes")&&rr(/<\/no(script|embed|frames)/i,O.innerHTML)?(Ht(O),!0):(ge&&O.nodeType===Ho.text&&(re=O.textContent,zo([U,V,X],rt=>{re=Vo(re,rt," ")}),O.textContent!==re&&(Uo(t.removed,{element:O.cloneNode()}),O.textContent=re)),_t(M.afterSanitizeElements,O,null),!1)},kr=function(O,re,ve){if(te[re]||sr&&(re==="id"||re==="name")&&(ve in r||ve in lr))return!1;const rt=ie[re]||oe.attributeCheck instanceof Function&&oe.attributeCheck(re,O);if(!(Me&&!te[re]&&rr(B,re))){if(!(me&&rr(L,re))){if(!rt||te[re]){if(!(jr(O)&&(ee.tagNameCheck instanceof RegExp&&rr(ee.tagNameCheck,O)||ee.tagNameCheck instanceof Function&&ee.tagNameCheck(O))&&(ee.attributeNameCheck instanceof RegExp&&rr(ee.attributeNameCheck,re)||ee.attributeNameCheck instanceof Function&&ee.attributeNameCheck(re,O))||re==="is"&&ee.allowCustomizedBuiltInElements&&(ee.tagNameCheck instanceof RegExp&&rr(ee.tagNameCheck,ve)||ee.tagNameCheck instanceof Function&&ee.tagNameCheck(ve))))return!1}else if(!st[re]){if(!rr(j,Vo(ve,K,""))){if(!((re==="src"||re==="xlink:href"||re==="href")&&O!=="script"&&Cy(ve,"data:")===0&&Fe[O])){if(!(De&&!rr(D,Vo(ve,K,"")))){if(ve)return!1}}}}}}return!0},Qr=Ze({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),jr=function(O){return!Qr[Pi(O)]&&rr(ae,O)},zr=function(O){_t(M.beforeSanitizeAttributes,O,null);const re=O.attributes;if(!re||Un(O))return;const ve={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ie,forceKeepAttr:void 0};let rt=re.length;for(;rt--;){const wt=re[rt],St=wt.name,Wt=wt.namespaceURI,Et=wt.value,Ur=kt(St),Ro=Et;let It=St==="value"?Ro:yF(Ro);if(ve.attrName=Ur,ve.attrValue=It,ve.keepAttr=!0,ve.forceKeepAttr=void 0,_t(M.uponSanitizeAttribute,O,ve),It=ve.attrValue,Vt&&(Ur==="id"||Ur==="name")&&Cy(It,he)!==0&&(wr(St,O),It=he+It),Se&&rr(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,It)){wr(St,O);continue}if(Ur==="attributename"&&Ay(It,"href")){wr(St,O);continue}if(ve.forceKeepAttr)continue;if(!ve.keepAttr){wr(St,O);continue}if(!ne&&rr(/\/>/i,It)){wr(St,O);continue}ge&&zo([U,V,X],An=>{It=Vo(It,An," ")});const fn=kt(O.nodeName);if(!kr(fn,Ur,It)){wr(St,O);continue}if(N&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!Wt)switch(m.getAttributeType(fn,Ur)){case"TrustedHTML":{It=N.createHTML(It);break}case"TrustedScriptURL":{It=N.createScriptURL(It);break}}if(It!==Ro)try{Wt?O.setAttributeNS(Wt,St,It):O.setAttribute(St,It),Un(O)?Ht(O):xy(t.removed)}catch{wr(St,O)}}_t(M.afterSanitizeAttributes,O,null)},_r=function(O){let re=null;const ve=qt(O);for(_t(M.beforeSanitizeShadowDOM,O,null);re=ve.nextNode();)_t(M.uponSanitizeShadowNode,re,null),Ui(re),zr(re),re.content instanceof i&&_r(re.content);_t(M.afterSanitizeShadowDOM,O,null)},Yt=function(O){if(O.nodeType===Ho.element&&O.shadowRoot instanceof i){const rt=O.shadowRoot;Yt(rt),_r(rt)}const re=O.childNodes;if(!re)return;const ve=[];zo(re,rt=>{Uo(ve,rt)});for(const rt of ve)Yt(rt)};return t.sanitize=function(ke){let O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},re=null,ve=null,rt=null,wt=null;if(ar=!ke,ar&&(ke="<!-->"),typeof ke!="string"&&!zi(ke)&&(ke=xF(ke),typeof ke!="string"))throw ba("dirty is not a string, aborting");if(!t.isSupported)return ke;if(Nt||un(O),t.removed=[],typeof ke=="string"&&(J=!1),J){const Et=ke.nodeName;if(typeof Et=="string"){const Ur=kt(Et);if(!z[Ur]||Ae[Ur])throw ba("root node is forbidden and cannot be sanitized in-place")}Yt(ke)}else if(zi(ke))re=Jr("<!---->"),ve=re.ownerDocument.importNode(ke,!0),ve.nodeType===Ho.element&&ve.nodeName==="BODY"||ve.nodeName==="HTML"?re=ve:re.appendChild(ve),Yt(ve);else{if(!Ot&&!ge&&!yt&&ke.indexOf("<")===-1)return N&&Dt?N.createHTML(ke):ke;if(re=Jr(ke),!re)return Ot?null:Dt?k:""}re&&Ut&&Ht(re.firstChild);const St=qt(J?ke:re);for(;rt=St.nextNode();)Ui(rt),zr(rt),rt.content instanceof i&&_r(rt.content);if(J)return ge&&cr(ke),ke;if(Ot){if(ge&&cr(re),Er)for(wt=C.call(re.ownerDocument);re.firstChild;)wt.appendChild(re.firstChild);else wt=re;return(ie.shadowroot||ie.shadowrootmode)&&(wt=W.call(n,wt,!0)),wt}let Wt=yt?re.outerHTML:re.innerHTML;return yt&&z["!doctype"]&&re.ownerDocument&&re.ownerDocument.doctype&&re.ownerDocument.doctype.name&&rr(IF,re.ownerDocument.doctype.name)&&(Wt="<!DOCTYPE "+re.ownerDocument.doctype.name+`>
|
|
52
|
-
`+Wt),ge&&zo([U,V,X],Et=>{Wt=Vo(Wt,Et," ")}),N&&Dt?N.createHTML(Wt):Wt},t.setConfig=function(){let ke=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};un(ke),Nt=!0},t.clearConfig=function(){Nr=null,Nt=!1},t.isValidAttribute=function(ke,O,re){Nr||un({});const ve=kt(ke),rt=kt(O);return kr(ve,rt,re)},t.addHook=function(ke,O){typeof O=="function"&&Uo(M[ke],O)},t.removeHook=function(ke,O){if(O!==void 0){const re=hF(M[ke],O);return re===-1?void 0:gF(M[ke],re,1)[0]}return xy(M[ke])},t.removeHooks=function(ke){M[ke]=[]},t.removeAllHooks=function(){M=Oy()},t}var BF=Iy();const $F=["a","b","br","div","em","h1","h2","h3","h4","h5","h6","i","img","li","ol","p","span","strong","table","tbody","td","th","thead","tr","u","ul"],jF=["href","target","rel","src","alt","title","class","style","colspan","rowspan"];function zF(e){return e?BF.sanitize(e,{ALLOWED_TAGS:[...$F],ALLOWED_ATTR:[...jF],ALLOW_DATA_ATTR:!1}):""}function UF(e,t,r=!1){return e.includes("{labelapi:")?e.replace(/\{labelapi:([^}]+)\}/g,(n,o)=>{const i=o.trim();if(i===""||t==null)return r?"":n;const s=We(t,i);return s==null?r?"":n:String(s)}):e}function VF(e){return e&&e.replace(/\{api:[^}]*\}/gi,"").replace(/\{labelapi:[^}]*\}/gi,"").replace(/\{resp:[^}]*\}/gi,"").replace(/\{(?:ctx:|@)\w+\}/gi,"").replace(/\{documentId\}/gi,"").replace(/\{(\w+)\}/g,"")}const My={sm:"text-sm",md:"text-base",lg:"text-lg"},Ly={h1:"text-4xl font-bold tracking-tight",h2:"text-3xl font-semibold tracking-tight",h3:"text-2xl font-semibold",h4:"text-xl font-semibold",h5:"text-lg font-medium",h6:"text-base font-medium"},Dy={normal:"font-normal",medium:"font-medium",bold:"font-bold"},wa={left:"text-left",center:"text-center",right:"text-right",justify:"text-justify"};function so(e){return e.properties??{}}function HF(e){const t=so(e);return t.textContent!==void 0?t.textContent:e.label??""}function WF(e){return so(e).textContent===void 0||e.appearance?.hideLabel?!1:!!e.label?.trim()}function RF(e){return e?.contentLayout==="paragraph"?"paragraph":"single"}function od(e,t={}){const{formValues:r={},urlParams:n={},submissionContext:o,buttonResponses:i,prepopulateResponse:s,labelApiResponse:a}=t,c=Rr(e,r,n,o,i,s),u=UF(c,a,!0);return VF(u)}const KF=/\{api:[^}]+\}/,GF=/\{labelapi:[^}]+\}/;function id(e){return KF.test(e)}function sd(e){return GF.test(e)}function qF(e){const t=e.captionTemplate??"",r=e.descriptionTemplate??"",n=id(e.bodyTemplate)||id(t)||id(r),o=sd(e.bodyTemplate)||sd(t)||sd(r);return!!(n&&e.prepopulateLoading||o&&e.labelApiConfigPresent&&(e.labelApiLoading||e.labelApiResponse===void 0&&e.labelApiError==null))}function By(e,t){const r=t??so(e),n=r.variant??"body",o=e.appearance?.size??"md",i=My[o]??My.md,s=r.fontWeight??"medium";return n!=="body"?H("m-0 text-foreground",Ly[n]??Ly.h3,r.fontWeight&&Dy[r.fontWeight],r.italic&&"italic",r.underline&&"underline",r.textAlign&&wa[r.textAlign]):H("m-0 text-foreground",i,Dy[s],r.italic&&"italic",r.underline&&"underline",r.textAlign&&wa[r.textAlign])}function YF(e,t){const r=(t??so(e)).variant??"body";return r==="body"?"p":r}function ad(e){const t=[];let r=0,n="";const o=()=>{n&&(t.push({type:"text",value:n}),n="")},i=(s,a,c)=>{if(!e.startsWith(s,r))return!1;const u=e.indexOf(a,r+s.length);if(u===-1)return!1;o();const f=e.slice(r+s.length,u);return t.push({type:c,children:ad(f)}),r=u+a.length,!0};for(;r<e.length;){if(e[r]==="\\"&&r+1<e.length){n+=e[r+1],r+=2;continue}i("**","**","bold")||i("__","__","underline")||i("*","*","italic")||i("_","_","italic")||(n+=e[r],r+=1)}return o(),t}function XF(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function $y(e){return e.map(t=>{if(t.type==="text")return XF(t.value);const r=$y(t.children);return t.type==="bold"?`<strong class="font-bold">${r}</strong>`:t.type==="italic"?`<em class="italic">${r}</em>`:`<u class="underline">${r}</u>`}).join("")}function JF(e){return e?$y(ad(e)):""}function QF(e,t){return e?t==="markdown-lite"?JF(e):e:""}function jy(e,t){return e.map((r,n)=>{const o=`${t}-${n}`;if(r.type==="text")return r.value?w.createElement(w.Fragment,{key:o},r.value):null;const i=jy(r.children,o);return r.type==="bold"?w.createElement("strong",{key:o,className:"font-bold"},i):r.type==="italic"?w.createElement("em",{key:o,className:"italic"},i):w.createElement("u",{key:o,className:"underline"},i)})}function zy(e,t){if(!e)return null;if(t!=="markdown-lite")return e;const r=ad(e);return r.length===1&&r[0]?.type==="text"?r[0].value:jy(r,"tl")}const ZF="text-label-html prose prose-sm max-w-none [&_p]:m-0 [&_p+p]:mt-2 [&_ul]:my-1 [&_ol]:my-1";function Uy(e,t){if(!e)return null;const{field:r,asDescription:n=!1}=t,o=t.textProps??so(r),i=t.contentLayout??RF(o),s=o.inlineFormat??"none";if(i==="paragraph"){const c=zF(QF(e,s));if(!c)return null;const u=n?H("m-0 text-sm",o.descriptionMuted!==!1?"text-muted-foreground":"text-foreground",o.textAlign&&wa[o.textAlign]):H(By(r,o),ZF);return w.createElement("div",{className:u,dangerouslySetInnerHTML:{__html:c}})}if(n)return w.createElement("p",{className:H("mt-0.5 text-sm",o.descriptionMuted!==!1?"text-muted-foreground":"text-foreground",o.textAlign&&wa[o.textAlign])},zy(e,s));const a=YF(r,o);return w.createElement(a,{className:By(r,o)},zy(e,s))}function eP(e){const t=e.labelApiEndpoint?.trim();return!e.labelApiEnabled||!t?null:{labelApiEndpoint:t,labelApiMethod:e.labelApiMethod??"GET",labelApiQueryParams:e.labelApiQueryParams,labelApiHeaders:e.labelApiHeaders,labelApiBodyFields:e.labelApiBodyFields}}async function tP(e,t={}){const{formValues:r={},urlParams:n={},submissionContext:o}=t,i=l=>Rr(l,r,n,o),s=(e.labelApiMethod??"GET").toUpperCase();let a=Mr(i(e.labelApiEndpoint));const c=e.labelApiQueryParams??[];if(c.length){const l=new URLSearchParams;c.forEach(({key:g,value:m})=>{g.trim()&&l.append(g,i(m))});const p=l.toString();p&&(a=`${a}${a.includes("?")?"&":"?"}${p}`)}const u={"Content-Type":"application/json"};(e.labelApiHeaders??[]).forEach(({key:l,value:p})=>{l.trim()&&(u[l]=i(p))});let f;s==="POST"&&(e.labelApiBodyFields??[]).length&&(f={},e.labelApiBodyFields.forEach(({key:l,value:p})=>{l.trim()&&(f[l]=i(p))}));try{return s==="POST"?(await Jt.post(a,f??{},{headers:Object.keys(u).length?u:void 0})).data:(await Jt.get(a,{headers:Object.keys(u).length?u:void 0})).data}catch(l){const p=l,g=p.response?.status,m=typeof p.response?.data=="string"?p.response.data:p.message??"Request failed";throw new Error(g?`HTTP ${g}: ${m}`:String(m))}}const rP=({field:e,className:t,formValues:r,urlParams:n,submissionContext:o,buttonResponses:i,prepopulateResponse:s,prepopulateLoading:a=!1})=>{const c=so(e),u=w.useMemo(()=>eP(so(e)),[e.properties]),[f,l]=w.useState(void 0),[p,g]=w.useState(!1),[m,h]=w.useState(null),y=w.useMemo(()=>u?JSON.stringify({endpoint:u.labelApiEndpoint,method:u.labelApiMethod,query:u.labelApiQueryParams,headers:u.labelApiHeaders,body:u.labelApiBodyFields}):"",[u]),S=w.useCallback(async()=>{if(!u){l(void 0),h(null),g(!1);return}g(!0),h(null);try{const I=await tP(u,{formValues:r??{},urlParams:n??{},submissionContext:o});l(I)}catch(I){l(void 0),h(I instanceof Error?I.message:"Failed to load label API")}finally{g(!1)}},[u,r,n,o]);w.useEffect(()=>{y&&S()},[y,S]);const v=c.textAlign==="center"?"items-center":c.textAlign==="right"?"items-end":c.textAlign==="justify"?"items-stretch":"items-start",A=HF(e),x=WF(e),F=x&&e.label?e.label:"",N=e.description??"",k=qF({bodyTemplate:A,captionTemplate:F,descriptionTemplate:N,prepopulateLoading:a,labelApiConfigPresent:u!=null,labelApiLoading:p,labelApiResponse:f,labelApiError:m}),T={formValues:r??{},urlParams:n??{},submissionContext:o,buttonResponses:i,prepopulateResponse:s,labelApiResponse:f},P=A?od(A,T):"",E=x&&e.label?od(e.label,T):"",C=N?od(N,T):"";return d.jsx("div",{className:H("w-full min-w-0 h-full min-h-[95px] flex flex-col justify-center py-0.5",v,t),children:k?d.jsx("p",{className:"text-sm text-muted-foreground m-0",children:"Loading…"}):d.jsxs(d.Fragment,{children:[m&&u?d.jsx("p",{className:"text-[10px] text-destructive mb-0.5",title:m,children:"Label API failed"}):null,E?d.jsx("div",{className:"text-sm font-medium text-foreground mb-1 w-full",children:E}):null,P?Uy(P,{field:e,textProps:c}):null,C?Uy(C,{field:e,textProps:c,asDescription:!0}):null]})})},ld=({legend:e,children:t,className:r,collapsible:n=!1,defaultCollapsed:o=!1,headerActions:i,onCollapsedChange:s})=>{const[a,c]=w.useState(o),u=w.useId(),f=l=>{l.stopPropagation(),n&&c(p=>{const g=!p;return s?.(g),g})};return d.jsxs("fieldset",{className:H("min-w-0 rounded-lg border bg-card p-4",r),"data-form-renderer":"config-section-border",children:[n?d.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2 border-b border-border pb-2",children:[d.jsxs("button",{type:"button",className:H("flex min-w-0 flex-1 items-center gap-2 text-left text-sm font-medium text-foreground","cursor-pointer rounded-sm hover:bg-muted/70 transition-colors focus:outline-none focus:ring-2 focus:ring-ring"),"aria-expanded":!a,"aria-controls":u,onClick:f,children:[d.jsx("span",{className:"shrink-0 text-muted-foreground","aria-hidden":!0,children:a?d.jsx(qu,{className:"h-4 w-4"}):d.jsx(ni,{className:"h-4 w-4"})}),d.jsx("span",{className:"truncate",children:e})]}),i!=null?d.jsx("div",{className:"shrink-0",children:i}):null]}):d.jsx("legend",{className:"px-1 text-sm font-medium text-foreground",children:e}),!a&&d.jsxs("div",{id:u,className:"space-y-3",children:[!n&&i!=null?d.jsx("div",{className:"flex justify-end",children:i}):null,t]})]})};function Vy(e){const t=e.properties,r=t?.apiEndpoint?{apiEndpoint:t.apiEndpoint,apiMethod:t.apiMethod,apiKey:t.apiKey,apiRealtime:t.apiRealtime,apiAutoDetect:t.apiAutoDetect,apiLabelField:t.apiLabelField,apiValueField:t.apiValueField,apiQueryParams:t.apiQueryParams,apiClientFilter:t.apiClientFilter,apiHeaders:t.apiHeaders,apiBodyFields:t.apiBodyFields,apiAuth:t.apiAuth,valueSource:t.valueSource,dependentFields:t.dependentFields}:null,n=e.apidata||null;return r||n}function cd(e){const t=Vy(e),r=e.properties;return!!(t?.apiEndpoint&&(t?.valueSource==="api"||r?.valueSource==="api"))}function Hy({field:e,formValues:t={},submissionContext:r,value:n,onChange:o,clearWhenBlocked:i=!0}){const s=e.properties,a=Vy(e),c=cd(e),[u,f]=w.useState(!1),[l,p]=w.useState(null),g=w.useRef(null),m=w.useRef(n);m.current=n;const h=w.useMemo(()=>{const F=a?.apiEndpoint||s?.apiEndpoint||"",N=a?.apiQueryParams||s?.apiQueryParams;return po(F,N)},[a?.apiEndpoint,s?.apiEndpoint,a?.apiQueryParams,s?.apiQueryParams]),y=w.useMemo(()=>{const F=new Set;for(const k of s?.dependentFields??a?.dependentFields??[])typeof k=="string"&&k.trim()&&F.add(k.trim());const N=a?.apiClientFilter?.matchField?.trim()||s?.apiClientFilter?.matchField?.trim();return N&&F.add(N),[...F]},[s?.dependentFields,a?.dependentFields,a?.apiClientFilter?.matchField,s?.apiClientFilter?.matchField]),S=w.useMemo(()=>{const F=new Set([...h,...y]);if(F.size===0)return null;const N={};return F.forEach(k=>{N[k]=t[k]}),JSON.stringify(N)},[h,y,t]),v=w.useMemo(()=>JSON.stringify(r||{}),[r]),A=w.useMemo(()=>{const F=new Set;e.name?.trim()&&F.add(e.name.trim());const N=e.key;return typeof N=="string"&&N.trim()&&F.add(N.trim()),[...F]},[e.name,e.key]),x=e.type==="number"?null:"";return w.useEffect(()=>{const F=a?.apiEndpoint;if(!c||!F)return;let N=!1;const k=P=>{if(N)return;const E=m.current;if(P==null||P.trim()===""){i&&E!==x&&E!==void 0&&(g.current=null,o(x));return}if(e.type==="number"){const C=Number(P),I=Number.isFinite(C)?C:null;E!==I&&g.current!==P&&(g.current=P,o(I));return}String(E??"")!==P&&g.current!==P&&(g.current=P,o(P))};return(async()=>{f(!0),p(null);try{const P=a?.apiMethod||s?.apiMethod||"GET",E=a?.apiRealtime||s?.apiRealtime,C=a?.apiQueryParams||s?.apiQueryParams||{},I=ns({apiEndpoint:F,apiMethod:P,apiQueryParams:C,formValues:t,submissionContext:r,apiRealtime:E,additionalRequiredFieldNames:y,excludeFormFieldNames:A});if(I.blocked){N||(f(!1),i&&k(null));return}const W={"Content-Type":"application/json"},M=a?.apiKey||s?.apiKey;M&&(W["X-CSCAPI-KEY"]=M);const U=e.apidata,V=a?.apiAuth??s?.apiAuth??U?.apiAuth??Si(a?.apiHeaders??s?.apiHeaders??U?.apiHeaders)??{type:"none"},X=xi(V,{formValues:t,submissionContext:r,apiRealtime:E});Object.assign(W,X);const B=a?.apiHeaders??s?.apiHeaders??U?.apiHeaders,L=a?.apiBodyFields??s?.apiBodyFields??U?.apiBodyFields,D=vn(wi(B),{formValues:t,submissionContext:r,apiRealtime:E});Object.assign(W,D);const K=vn(L,{formValues:t,submissionContext:r,apiRealtime:E}),ae={method:P.toLowerCase(),url:Mr(I.url),headers:W};(I.postBodyBase!=null||Object.keys(K).length>0)&&(ae.data={...I.postBodyBase??{},...K});const j=await Ct(ae),z=a?.apiLabelField||s?.apiLabelField,le=a?.apiValueField||s?.apiValueField,ie=a?.apiClientFilter||s?.apiClientFilter;let G=HE(j.data,le,z);if(ie?.filterField&&ie?.matchField&&G!=null){const ee=t[ie.matchField];if(ee==null)G=null;else{const Ae=vi(j.data,z,le),te=Array.isArray(j.data)?j.data:j.data?.data?.data&&Array.isArray(j.data.data.data)?j.data.data.data:j.data?.data&&Array.isArray(j.data.data)?j.data.data:[],oe=Ae.filter(me=>{const Me=te.find(ne=>String(jt(ne,le||"code"))===String(me.value));if(!Me)return!1;const De=jt(Me,ie.filterField);return String(De)===String(ee)});G=oe.length>0?oe[0].value:null}}N||k(G)}catch(P){if(N)return;let E="Failed to load value";const C=P;if(C.response){const I=C.response.data;if(C.response.status===404)E="API endpoint not found.";else if(C.response.status===401)E="Authentication failed.";else if(typeof I=="string")E=I;else if(I&&typeof I=="object"){const W=I;E=W.error||W.message||W.detail||E}}else C.message&&(E=String(C.message));p(E)}finally{N||f(!1)}})(),()=>{N=!0}},[c,a?.apiEndpoint,a?.apiMethod,a?.apiValueField,a?.apiLabelField,s?.apiEndpoint,s?.apiMethod,s?.apiValueField,s?.apiLabelField,S,y,A,v,e.type,i,x]),{isLoading:u,error:l}}const nP=({field:e,value:t,onChange:r,formValues:n,submissionContext:o,disabled:i,readOnly:s,...a})=>{const{isLoading:c}=Hy({field:e,formValues:n,submissionContext:o,value:t,onChange:r});return d.jsx(as,{field:e,value:t||"",onChange:r,disabled:i||c,readOnly:s||c,...a})},oP=({field:e,value:t,onChange:r,formValues:n,submissionContext:o,disabled:i,readOnly:s,...a})=>{const{isLoading:c}=Hy({field:e,formValues:n,submissionContext:o,value:t,onChange:r});return d.jsx(fl,{field:e,value:t??null,onChange:r,disabled:i||c,readOnly:s||c,...a})},Sn=({field:e,value:t,error:r,onChange:n,onBlur:o,disabled:i,readOnly:s,isRequired:a,className:c,formValues:u={},submissionContext:f,onSubmit:l,onReset:p,onCancel:g,isSubmitting:m,bffSubmitApi:h,onBffSubmitResult:y,extraSubmitPayload:S,buttonResponses:v,onButtonApiResponse:A,onValidateForm:x,getValidationErrors:F,allFields:N,onSubmittingChange:k,onAddMore:T,scopedFormValues:P,scopedFieldNameMap:E,excludedOptionValues:C,prepopulateMappedFieldNames:I,fieldValueKey:W,hideTableRowControls:M=!1,urlParams:U={},prepopulateResponse:V=null,prepopulateLoading:X=!1,formSections:B,submitPayload:L})=>{switch(e.type){case"divider":return d.jsx(eF,{field:e,className:c});case"header":return d.jsx(rF,{field:e,className:c});case"sectionHeading":return d.jsx(iF,{field:e,className:c});case"spacer":return d.jsx(sF,{field:e,className:c});case"textLabel":return d.jsx(rP,{field:e,className:c,formValues:u,urlParams:U,submissionContext:f,buttonResponses:v,prepopulateResponse:V??void 0,prepopulateLoading:X});case"status":return d.jsx(RT,{field:e,value:t??null,error:r,disabled:i,isRequired:a,className:c,formValues:u,submissionContext:f,extraSubmitPayload:S,prepopulateResponse:V})}switch(e.type){case"text":case"password":case"url":return e.type==="text"&&cd(e)?d.jsx(nP,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c,formValues:u,submissionContext:f}):d.jsx(as,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c});case"number":return cd(e)?d.jsx(oP,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c,formValues:u,submissionContext:f}):d.jsx(fl,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c});case"email":return d.jsx(ef,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c});case"phone":case"aadhaar":return d.jsx(tf,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c});case"otp":return d.jsx(Jf,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c,formValues:u,urlParams:U,submissionContext:{...typeof f=="object"&&f!==null?f:{},...S??{}},prepopulateResponse:V});case"textarea":case"richtext":return d.jsx(Qf,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c});case"select":{const D=W??e.name??e.key??e.id,K=!!(D&&I?.has(D));return d.jsx(Dm,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:c,formValues:u,submissionContext:f,excludedOptionValues:C,isPrepopulateTarget:K})}case"multiselect":{const D=Array.isArray(t)?t:t!=null&&t!==""?[String(t)]:[];return d.jsx(Ch,{field:e,value:D,onChange:K=>n(K),onBlur:o,error:r,disabled:i,isRequired:a,className:c,formValues:u,submissionContext:f,excludedOptionValues:C})}case"asyncsearch":return d.jsx(th,{field:e,value:t,onChange:D=>n(D),onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c,formValues:u,submissionContext:f});case"checkbox":case"terms":return d.jsx(Eh,{field:e,value:t||!1,onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:c});case"toggle":return d.jsx(ek,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:c});case"radio":case"checkboxgroup":return d.jsx(Jh,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:c,excludedOptionValues:C});case"selectablelist":{const D=Array.isArray(t)?t:[];return console.log("[SelectableList] FieldRenderer: passing to SelectableListField",{fieldName:e.name,value:D,valueLength:D.length,submissionContextKeys:f?Object.keys(f):[]}),d.jsx(GT,{field:e,value:D,onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:c,submissionContext:f})}case"date":case"time":case"datetime":case"daterange":return d.jsx(Qh,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c});case"file":return d.jsx(Ek,{field:e,value:t,onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:c,buttonResponses:v});case"camera":return d.jsx(Zk,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:c});case"photoChoice":return d.jsx(e_,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:c,buttonResponses:v});case"signature":return d.jsx(bT,{field:e,value:t||null,onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c});case"rating":return d.jsx(X_,{field:e,value:t||0,onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c});case"slider":return d.jsx(yT,{field:e,value:t||0,onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c});case"table":return d.jsx(vT,{field:e,value:t||[],onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c,hideRowControls:M,formValues:u,submissionContext:f});case"billingGrid":return d.jsx(WT,{field:e,value:t||{rows:[]},onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c,formValues:u,submissionContext:f});case"button":return d.jsx(z_,{field:e,value:t,onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c,onSubmit:l,onReset:p,onCancel:g,isSubmitting:m,formValues:u,submissionContext:f,buttonResponses:v,onButtonApiResponse:A,bffSubmitApi:h,onBffSubmitResult:y,extraSubmitPayload:S,onValidateForm:x,getValidationErrors:F,allFields:N,onSubmittingChange:k,scopedFormValues:P,scopedFieldNameMap:E,prepopulateResponse:V,formSections:B,submitPayload:L});case"editButton":return d.jsx(U_,{field:e,disabled:i,readOnly:s,isRequired:a,className:c,buttonResponses:v,onButtonApiResponse:A});case"addmore":return d.jsx(V_,{field:e,error:r,disabled:i,readOnly:s,isRequired:a,className:c,onAddMore:()=>T?.(e)});case"customizeSections":return d.jsx(Y_,{field:e,error:r,disabled:i,readOnly:s,isRequired:a,className:c});default:return d.jsx("div",{className:"p-3 border rounded-md bg-muted/50",children:d.jsxs("p",{className:"text-sm text-muted-foreground",children:["Unsupported field type: ",e.type]})})}};function Ii(e){if(!e)return e;const t={...e};return e._id&&!e.id&&(t.id=e._id),delete t._id,t.formDefinitionId&&typeof t.formDefinitionId=="object"&&(t.formDefinitionId=t.formDefinitionId._id||t.formDefinitionId.id||t.formDefinitionId),t}function Wy(e){return Array.isArray(e)?e.map(Ii):[]}function iP(e){const t=!!e.standalone_form;if(!e.moduleId&&!t)throw new Error(`Form response missing required field: moduleId. Form ID: ${e._id||e.id}. Please ensure the backend returns moduleId when fetching forms.`);if(!e._id&&!e.id)throw new Error("Form response missing required field: id. Please ensure the backend returns _id or id when fetching forms.");let r;e.moduleId&&(typeof e.moduleId=="object"&&e.moduleId._id?r=Ii(e.moduleId):r=e.moduleId);const n=e.isDefault??!1;if(!n&&!e.tenantId&&!t)throw new Error(`Form response missing required field: tenantId. Form ID: ${e._id||e.id}. Please ensure the backend returns tenantId when fetching non-default forms.`);return{id:e._id||e.id,name:e.name,description:e.description||"",version:e.version??1,status:e.status||"draft",category:e.category||"",createdAt:e.createdAt||new Date().toISOString(),updatedAt:e.updatedAt||e.createdAt||new Date().toISOString(),createdBy:e.createdBy||"",isActive:e.isActive??!0,isDefault:n,...r!==void 0&&{moduleId:r},tenantId:e.tenantId||void 0,featureId:e.featureId,config:e.config??void 0,standalone_form:t}}class sP{basePath="/api/form-builder/forms";async getForRendering(t,r){if(!nn())throw new Error("Client ID is required");const o=r!==void 0?`${this.basePath}/${t}/render?version=${r}`:`${this.basePath}/${t}/render`,i=await Jt.get(o),s=i.data?.data||i.data,a=s?.BFF_submit_api||s?.bff_submit_api||i.data?.BFF_submit_api||i.data?.bff_submit_api,c=s.form||s,u=!!(c.standalone_form??s.form?.standalone_form);if(!c.moduleId&&!s.form?.moduleId&&!u)throw new Error(`Form response missing required field: moduleId. Form ID: ${t}. Please ensure the backend returns moduleId in the form response.`);if(!(c.isDefault??s.form?.isDefault??!1)&&!c.tenantId&&!s.form?.tenantId&&!u)throw new Error(`Form response missing required field: tenantId. Form ID: ${t}. Please ensure the backend returns tenantId for non-default forms.`);s.form?.moduleId&&!c.moduleId&&(c.moduleId=s.form.moduleId),s.form?.tenantId&&!c.tenantId&&(c.tenantId=s.form.tenantId),s.form?.isDefault!==void 0&&c.isDefault===void 0&&(c.isDefault=s.form.isDefault);const l=iP(c);s.form?.moduleId&&(typeof s.form.moduleId=="object"&&s.form.moduleId._id?l.moduleId=Ii(s.form.moduleId):typeof s.form.moduleId=="string"&&(l.moduleId=s.form.moduleId));const p=Wy(s.fields||[]),g=s.layout?Ii(s.layout):null,m=Wy(s.rules||[]),h=s.module?Ii(s.module):void 0,y=s.clientMapping||s.clientOverrides;return{form:l,fields:p,layout:g,rules:m,module:h,clientMapping:y,clientOverrides:y,BFF_submit_api:a||void 0}}}const aP=new sP,lP={submitAction:"database",autoSave:!0,autoSaveInterval:30,showProgressBar:!0,allowDraft:!0,validateOnChange:!1,validateOnBlur:!0,showFieldErrors:"inline",layout:"default",submitButtonText:"Submit",resetButtonText:"Reset",showReset:!1,successMessage:"Form submitted successfully!",errorMessage:"An error occurred. Please try again."},cP=300;function dP(){return{...lP}}function uP(e){if(!e||typeof e!="object")return;const t=e,r=t.user_type??t.visibleToUserType??"",n=t.user_role??t.visibleToUserRole??"",o=Array.isArray(t.users)?t.users:Array.isArray(t.visibleToUserIds)?t.visibleToUserIds:[];if(!(r!=null&&r!==""||n!=null&&n!==""||o.length>0))return;const s={};return r!=null&&r!==""&&(s.visibleToUserType=r),n!=null&&n!==""&&(s.visibleToUserRole=n),o.length>0&&(s.visibleToUserIds=o),s}function fP(e){const t=dP();if(!e||typeof e!="object")return t;const r=e;return{...t,submitAction:r.submitAction||t.submitAction,apiEndpoint:r.apiEndpoint,dbTable:r.dbTable,emailTo:r.emailTo,workflowTrigger:r.workflowTrigger,workflowSubmissionConfig:r.workflowSubmissionConfig,prepopulateApi:r.prepopulateApi,prepopulateResponseRules:r.prepopulateResponseRules??void 0,sections:N_(r.sections),submitPayload:E_(r.submitPayload),autoSave:r.autoSave,autoSaveInterval:r.autoSaveInterval,showProgressBar:r.showProgressBar,allowDraft:r.allowDraft,validateOnChange:r.validateOnChange,validateOnBlur:r.validateOnBlur,showFieldErrors:r.showFieldErrors,layout:r.layout,submitButtonText:r.submitButtonText,resetButtonText:r.resetButtonText,showReset:r.showReset,successMessage:r.successMessage,successRedirect:r.successRedirect,errorMessage:r.errorMessage}}function Mi(e,t,r,n){const o=t.map(l=>{let p=[],g={};try{l.options&&(p=JSON.parse(l.options)),l.metadata&&(g=JSON.parse(l.metadata))}catch{}const m=Eu(l);m&&Object.assign(g,m),p.length>0&&(g.options=p);const h=[];if(l.validationRequired&&h.push({type:"required",message:"This field is required"}),l.validationMinLength!==null&&l.validationMinLength!==void 0&&h.push({type:"minLength",value:l.validationMinLength,message:`Minimum length is ${l.validationMinLength}`}),l.validationMaxLength!==null&&l.validationMaxLength!==void 0&&h.push({type:"maxLength",value:l.validationMaxLength,message:`Maximum length is ${l.validationMaxLength}`}),l.validationPattern&&h.push({type:"pattern",value:l.validationPattern,message:"Invalid format"}),l.validationRules&&typeof l.validationRules=="object"){const j=l.validationRules;if(j.required===!0&&!h.some(z=>z.type==="required")&&h.push({type:"required",message:"This field is required"}),j.allowLetters!==void 0&&h.push({type:"allowLetters",value:j.allowLetters}),j.allowNumbers!==void 0&&h.push({type:"allowNumbers",value:j.allowNumbers}),j.allowSpecialChars!==void 0&&h.push({type:"allowSpecialChars",value:j.allowSpecialChars}),j.minLetters!==void 0&&typeof j.minLetters=="number"&&h.push({type:"minLetters",value:j.minLetters}),j.maxLetters!==void 0&&typeof j.maxLetters=="number"&&h.push({type:"maxLetters",value:j.maxLetters}),j.minNumbers!==void 0&&typeof j.minNumbers=="number"&&h.push({type:"minNumbers",value:j.minNumbers}),j.maxNumbers!==void 0&&typeof j.maxNumbers=="number"&&h.push({type:"maxNumbers",value:j.maxNumbers}),j.minSpecialChars!==void 0&&typeof j.minSpecialChars=="number"&&h.push({type:"minSpecialChars",value:j.minSpecialChars}),j.maxSpecialChars!==void 0&&typeof j.maxSpecialChars=="number"&&h.push({type:"maxSpecialChars",value:j.maxSpecialChars}),j.fileSize!==void 0&&typeof j.fileSize=="number"){const z=j.fileSize/1048576;h.push({type:"fileSize",value:j.fileSize,message:`File size must be less than ${z.toFixed(2)} MB`})}if(j.fileType!==void 0){const z=Array.isArray(j.fileType)?j.fileType:typeof j.fileType=="string"?j.fileType.split(",").map(le=>le.trim()).filter(Boolean):[];z.length>0&&h.push({type:"fileType",value:z,message:"File type is not allowed"})}}const y=[],S=new Set;n.filter(j=>{const z=typeof j.targetFieldId=="object"?j.targetFieldId.id||j.targetFieldId._id:j.targetFieldId;return!!(z===l.id||z===l._id||z&&l.fieldKey&&z===l.fieldKey)}).forEach(j=>{try{const z=JSON.parse(j.conditionExpression);!z.id&&j.id&&(z.id=j.id);const le=typeof j.targetFieldId=="object"?j.targetFieldId?.id||j.targetFieldId?._id:j.targetFieldId;z.action&&(!z.then||!Array.isArray(z.then)||z.then.length===0)&&(z.then=[{action:z.action,...le&&{target:le}}]),(!z.then||!Array.isArray(z.then)||z.then.length===0)&&j.action&&(z.then=[{action:j.action,...le&&{target:le}}]),z.then&&Array.isArray(z.then)&&le&&(z.then=z.then.map(G=>!G.target&&le?{...G,target:le}:G));const ie=j.conditionExpression||JSON.stringify(z);if(S.has(ie))return;S.add(ie),y.push(z)}catch{}});const A=l.disabled===!0||g?.disabled===!0||!1;let x=l.readOnly===!0||g?.readOnly===!0||!1;const F=l.hidden===!0||g?.hidden===!0||!1;(g?.valueSource==="calculated"||g?.formula)&&(x=!0);const{disabled:N,readOnly:k,hidden:T,...P}=g,E={};P.hideLabel!==void 0&&(E.hideLabel=P.hideLabel),P.labelPosition!==void 0&&(E.labelPlacement=P.labelPosition),P.size!==void 0&&(E.size=P.size),P.customClass!==void 0&&(E.className=P.customClass);const{labelPosition:C,size:I,customClass:W,visibility:M,...U}=P,V=Object.keys(U).length>0?U:void 0,X=Object.keys(E).length>0?E:void 0,B=l.visibility??g?.visibility??M;let L=uP(B);if(B&&!L){const j=B;(j.visibleToUserType!=null||j.visibleToUserRole!=null||Array.isArray(j.visibleToUserTypes)&&j.visibleToUserTypes.length>0||Array.isArray(j.visibleToUserRoles)&&j.visibleToUserRoles.length>0||Array.isArray(j.visibleToUserIds)&&j.visibleToUserIds.length>0||Array.isArray(j.hiddenFromUserIds)&&j.hiddenFromUserIds.length>0)&&(L={visibleToUserType:j.visibleToUserType??(Array.isArray(j.visibleToUserTypes)?j.visibleToUserTypes[0]:void 0),visibleToUserRole:j.visibleToUserRole??(Array.isArray(j.visibleToUserRoles)?j.visibleToUserRoles[0]:void 0),visibleToUserIds:j.visibleToUserIds,hiddenFromUserIds:j.hiddenFromUserIds})}const D=g?.columnName,ae=!!l.parentFieldId&&typeof D=="string"?D:l.fieldKey;return{id:l.id,type:l.fieldType,name:ae,label:l.label,description:l.helpText||void 0,placeholder:l.placeholder||void 0,defaultValue:l.defaultValue||void 0,position:{order:typeof l.positionOrder=="number"?l.positionOrder:l.positionRow??0,column:typeof l.positionColumn=="number"?l.positionColumn:1,columnSpan:typeof l.positionWidth=="number"?l.positionWidth:1},parentId:void 0,appearance:X,validation:h.length>0?h:void 0,conditions:y.length>0?y:void 0,properties:V,visibility:L&&(L.visibleToUserType!=null||L.visibleToUserRole!=null||Array.isArray(L.visibleToUserIds)&&L.visibleToUserIds.length>0||Array.isArray(L.hiddenFromUserIds)&&L.hiddenFromUserIds.length>0)?L:void 0,disabled:A,readOnly:x,hidden:F}});o.forEach((l,p)=>{if(l.visibility){const g=t[p];console.log("[backendToFormSchema] field with visibility",{fieldKey:g?.fieldKey??l.name,name:l.name,type:l.type,parentFieldId:g?.parentFieldId,visibility:l.visibility})}});const i=t;for(let l=0;l<o.length;l++){const p=i[l]?.parentFieldId;if(p){const g=o.find(h=>h.id===p||h.type==="table"&&h.name===p||h.type==="table"&&i[l].fieldKey?.startsWith?.(h.name+"_column_")),m=o[l];if(g&&g.type==="table"&&m){const h=g.properties||{};Array.isArray(h.columns)||(h.columns=[]),h.columns.push(m),g.properties=h}}}const s=o.filter((l,p)=>!i[p]?.parentFieldId);for(const l of s)if(l.type==="table"&&l.properties&&Array.isArray(l.properties.columns)){const p=l.properties.columns;for(const g of p){const m=g.properties?.columnName;typeof m=="string"&&(g.name=m)}p.sort((g,m)=>(g.position?.order??0)-(m.position?.order??0)||(g.position?.column??0)-(m.position?.column??0))}let a;const c=e.config;if(console.log("[Prepopulate] backendToFormSchema config",{formId:e.id,hasRawConfig:c!=null,rawConfigType:typeof c,rawConfigPreview:c!=null?typeof c=="string"?c.slice(0,300):JSON.stringify(c).slice(0,300):null}),c!=null)try{const l=typeof c=="string"?JSON.parse(c):c;l&&typeof l=="object"?a=fP(l):a={submitAction:"database",layout:"default",autoSave:!0,validateOnChange:!0,showFieldErrors:"inline"}}catch{a={submitAction:"database",layout:"default",autoSave:!0,validateOnChange:!0,showFieldErrors:"inline"}}else a={submitAction:"database",layout:"default",autoSave:!0,validateOnChange:!0,showFieldErrors:"inline"};const u=Ri(r);u&&(a={...a,grid:u});const f=typeof e.moduleId=="string"?e.moduleId:e.moduleId?.id;return{id:e.id,name:e.name,description:e.description,version:e.version,status:e.status,config:a,fields:s,createdAt:e.createdAt,updatedAt:e.updatedAt,createdBy:e.createdBy,category:e.category,...f?{moduleId:f}:{},standalone_form:e.standalone_form,tenantId:e.tenantId,featureId:e.featureId,isDefault:e.isDefault}}const pP=new Set(["PENDING_PAYMENT","PAYMENT_PENDING","AWAITING_PAYMENT","PAID","PAYMENT_COMPLETED","PAYMENT_FAILED","REFUNDED","AUTHORIZED","CAPTURED","PARTIALLY_PAID"].map(e=>e.toUpperCase()));function dd(e){return typeof e=="string"&&e.trim()!==""}function ud(e){if(e==null||typeof e!="object"||Array.isArray(e))return!1;const t=e;if(t.payment_type!=null&&t.payment_type!==""||t.payment_mode!=null&&t.payment_mode!==""||t.transaction_id!=null&&String(t.transaction_id).trim()!==""||t.payment_status!=null&&String(t.payment_status).trim()!==""||typeof t.amount=="number"||dd(t.amount)||typeof t.total_amount=="number"||dd(t.total_amount)||dd(t.currency)||t.gateway!=null&&String(t.gateway).trim()!==""||t.razorpay_order_id!=null&&String(t.razorpay_order_id).trim()!==""||t.stripe_payment_intent!=null&&String(t.stripe_payment_intent).trim()!=="")return!0;const r=t.status;return!!(typeof r=="string"&&pP.has(r.trim().toUpperCase()))}function mP(e){const t=We(e,"data.items");if(!Array.isArray(t)||t.length===0)return;const r=t[0];if(r==null||typeof r!="object")return;const n=r;if(!(n.id===void 0||n.id===null||n.id===""))return{item:n,id:n.id}}function hP(e,t){const r=mP(e);if(!r)return;const n=We(e,"data"),o=n!=null&&typeof n=="object"&&!Array.isArray(n)?n:void 0;if(t?.treatFirstItemIdAsPaymentId===!0||ud(r.item)||o!=null&&ud(o))return r.id}function gP(e){const t=e.properties,r=e.metadata;return[t?.uploadApiEndpoint,t?.apiEndpoint,r?.uploadApiEndpoint,r?.apiEndpoint].filter(o=>typeof o=="string"&&o.length>0)}function yP(e){return gP(e).some(t=>t.toLowerCase().includes("payment"))}function bP(e){const t=e.properties,r=e.metadata;return!!(t?.mergeSuccessDataIdAsPaymentId||r?.mergeSuccessDataIdAsPaymentId)}function vP(e,t){if(t?.type!=="button"||!ei(e))return;const r=We(e,"data.id");if(r==null||String(r).trim()==="")return;const n=We(e,"data");if(bP(t)||n!=null&&typeof n=="object"&&!Array.isArray(n)&&ud(n)||yP(t))return r}const wP=new Set(["section","group","columns","divider","header","sectionHeading","spacer","addmore","textLabel","customizeSections"]);function SP(e,t){if(!e.length||!t?.length)return[];const r=new Map(t.map(o=>[o.id,o])),n=[];for(const o of e){const i=r.get(o);if(i?.fieldNames?.length)for(const s of i.fieldNames)s&&!n.includes(s)&&n.push(s)}return n}function xP(e,t){const r=e.properties,n=Array.isArray(r?.linkedFieldNames)?r.linkedFieldNames:[],o=SP(Array.isArray(r?.linkedSectionIds)?r.linkedSectionIds:[],t),i=new Set,s=[];for(const a of[...n,...o])!a||i.has(a)||(i.add(a),s.push(a));return s}function Ry(e,t){const r=e.properties,n=Array.isArray(r?.linkedSectionIds)?r.linkedSectionIds:[];if(!n.length||!t?.length)return[];const o=new Map(t.map(i=>[i.id,i]));return n.map(i=>o.get(i)).filter(i=>!!i)}function AP(e,t){return Ry(e,t).find(r=>r.heading?.enabled)}function Ky(e,t){const r=e.template??"";return(e.mode??"increment")==="fixed"?r:r.replace(/\{n\}/g,String(t+1))}function Gy(e,t,r,n){const o=xP(e,r);if(o.length===0)return[];const i=new Set(o);return t.filter(s=>{const a=n(s);return!a||s.id===e.id||wP.has(s.type)?!1:i.has(a)})}function CP(e,t,r){if(e.type!=="sectionHeading"||!t?.length)return;const n=r(e);if(n)for(const o of t){const i=o.heading;if(i?.enabled&&i.headingFieldName===n)return i}}function fd(e){return[...e].sort((t,r)=>{const n=t.position?.order??0,o=r.position?.order??0;if(n!==o)return n-o;const i=t.position?.column??1,s=r.position?.column??1;return i-s})}function EP(e,t,r){if(!e?.length)return[];const n=e.filter(s=>s.showBorder===!0);if(n.length===0)return[];const o=new Map;for(const s of t){const a=r(s);a&&o.set(a,s)}const i=[];for(const s of n){const a=s.fieldNames.map(u=>o.get(u)).filter(u=>!!u);if(a.length===0)continue;const c=fd(a).map(u=>r(u)).filter(Boolean);i.push({section:s,fieldNames:c})}return i}function Li(e,t=0){return e.heading?.enabled?Ky(e.heading,t):e.name}function qy(e,t,r){if(e.type!=="sectionHeading")return!1;const n=t.heading;return!n?.enabled||!n.headingFieldName?!1:r(e)===n.headingFieldName}function NP(e,t){const r=typeof e.position?.order=="number"?e.position.order:0,n=(e.position?.column??1)-1,o=Xo(e),i=nu(e,t);return{row:r,col:n,rowEnd:r+o-1,colEnd:n+i-1}}function pd(e,t){let r=1/0,n=-1/0,o=1/0,i=-1/0;for(const s of e){const{row:a,col:c,rowEnd:u,colEnd:f}=NP(s,t);r=Math.min(r,a),n=Math.max(n,u),o=Math.min(o,c),i=Math.max(i,f)}return Number.isFinite(r)?{minRow:r,maxRow:n,minCol:o,maxCol:i,rowSpan:n-r+1,colSpan:i-o+1}:null}function kP(e,t,r,n){const o=e.map(f=>t.find(l=>n(l)===f)).filter(f=>!!f&&typeof f.position?.order=="number");if(o.length===0)return null;const i=pd(o,r);if(!i)return null;const s=o.filter(f=>f.type!=="sectionHeading"),a=s.length>0?s:o,c=Math.min(...a.map(f=>f.position?.order??0)),u=Math.max(1,...a.map(f=>(f.position?.order??c)-c+Xo(f)));return{minRow:i.minRow,maxRow:i.maxRow,minCol:i.minCol,maxCol:i.maxCol,blockHeight:u}}function _P(e,t){return e.maxRow+1+t*e.blockHeight}function TP(e,t,r,n){const o=new Map;for(const a of t){const c=r(a);c&&o.set(c,a)}const i=new Map,s=new Set;for(const a of e){const c=a.fieldNames.map(v=>o.get(v)).filter(v=>!!v);if(c.length===0)continue;const u=c.filter(v=>!qy(v,a.section,r)),f=pd(c,n);if(!f)continue;const{minRow:l,minCol:p,rowSpan:g,colSpan:m}=f,h=`${l}-${p}`;if(i.has(h))continue;const y=new Set;let S=!1;for(let v=l;v<=l+g-1;v++){for(let A=p;A<=p+m-1;A++){const x=`${v}-${A}`;if(s.has(x)){S=!0;break}y.add(x)}if(S)break}if(!S){for(const v of y)s.add(v);i.set(h,{anchorRow:l,anchorCol:p,rowSpan:g,colSpan:m,run:a,legend:Li(a.section,0),renderFields:u.length>0?u:c})}}return{anchorsByOrigin:i,coveredCells:s}}function FP(e,t,r,n,o,i,s){const a=new Set(s),c=new Map;for(const u of e){const f=Yy(u.linkedFields.map(p=>i(p)).filter(Boolean),t),l=f?.section;l?.fieldNames?.length?l.fieldNames:u.templateFieldNames,u.blockIds.forEach((p,g)=>{const m=r.filter(k=>k.id.endsWith(`__${p}`));if(m.length===0||!f)return;const h=pd(m,o);if(!h)return;const{minRow:y,minCol:S,rowSpan:v,colSpan:A}=h,x=`${y}-${S}`;for(let k=y;k<=y+v-1;k++)for(let T=S;T<=S+A-1;T++)a.add(`${k}-${T}`);const F=f,N=Li(l,g+1);c.set(x,{anchorRow:y,anchorCol:S,rowSpan:v,colSpan:A,run:F,legend:N,renderFields:fd(m),addMoreMeta:{addMoreFieldName:u.addMoreFieldName,blockId:p,blockIndex:g}})})}return{anchorsByOrigin:c,coveredCells:a}}function PP(e,t,r,n){const o=`${e}-${t}`;return r.has(o)?!n.get(o):!1}function OP(e,t,r){for(const n of r.values())if(e>=n.anchorRow&&e<n.anchorRow+n.rowSpan&&t>=n.anchorCol&&t<n.anchorCol+n.colSpan)return n}function IP(e,t,r,n){return!(!n||r.run.section.collapsible!==!0||e===r.anchorRow&&t===r.anchorCol)}function MP(e,t,r){const n=new Set;for(const o of e.values())if(t(o))for(let i=o.anchorRow+1;i<o.anchorRow+o.rowSpan;i++)r(i,o)||n.add(i);return n}function LP(e,t,r){const n=o=>r.has(o)?"minmax(0, auto)":`minmax(${t}, auto)`;return Array.from({length:e},(o,i)=>n(i)).join(" ")}function DP(e,t){return new Map([...e,...t])}function BP(e,t,r){if(t.length===0)return e.map(s=>({kind:"field",field:s}));const n=new Map;for(const s of t)for(const a of s.fieldNames)n.set(a,s);const o=[];let i=0;for(;i<e.length;){const s=e[i],a=r(s),c=a?n.get(a):void 0;if(!c){o.push({kind:"field",field:s}),i+=1;continue}const u=[],f=new Set(c.fieldNames);for(;i<e.length;){const p=r(e[i]);if(!p||!f.has(p))break;const g=e[i];qy(g,c.section,r)||u.push(g),i+=1}if(u.length===0)continue;const l=o[o.length-1];l?.kind==="border"&&l.run.section.id===c.section.id?l.fields.push(...u):o.push({kind:"border",run:c,fields:u})}return o}function Yy(e,t){if(!t?.length)return;const r=new Set(e);for(const n of t){if(n.showBorder!==!0)continue;const o=n.fieldNames.filter(i=>r.has(i));if(o.length>0)return{section:n,fieldNames:o}}}const $P=({steps:e,currentStep:t,completedSteps:r,onStepClick:n,className:o})=>d.jsx("div",{className:H("mb-8",o),children:d.jsx("nav",{"aria-label":"Progress",children:d.jsx("ol",{className:"flex items-center",children:e.map((i,s)=>{const a=r.has(s),c=t===s,u=n&&(a||s===t+1||s<=t);return d.jsxs("li",{className:H("relative",s!==e.length-1&&"pr-8 sm:pr-20 flex-1"),children:[s!==e.length-1&&d.jsx("div",{className:H("absolute top-4 left-8 -right-8 sm:left-12 sm:-right-12 h-0.5",a?"bg-primary":"bg-border"),"aria-hidden":"true"}),d.jsx("button",{type:"button",onClick:()=>u&&n?.(s),disabled:!u,className:H("relative flex h-8 w-8 items-center justify-center rounded-full text-sm font-medium","transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2",a&&"bg-primary text-primary-foreground",c&&!a&&"border-2 border-primary text-primary",!a&&!c&&"border-2 border-border text-muted-foreground",u&&"cursor-pointer hover:bg-primary/10",!u&&"cursor-default"),"aria-current":c?"step":void 0,children:a?d.jsx(cs,{className:"h-4 w-4"}):d.jsx("span",{children:s+1})}),d.jsxs("div",{className:"mt-2",children:[d.jsx("span",{className:H("text-sm font-medium",c&&"text-primary",!c&&!a&&"text-muted-foreground"),children:i.name}),i.description&&d.jsx("p",{className:"text-xs text-muted-foreground hidden sm:block",children:i.description})]})]},i.id)})})})}),jP=2*6e4,Xy=50;class zP{map=new Map;ttlMs;constructor(t){this.ttlMs=t}get(t){const r=this.map.get(t);if(!r)return null;const o=Date.now()-r.storedAtMs>this.ttlMs;return{value:r.value,isStale:o}}set(t,r){this.map.set(t,{value:r,storedAtMs:Date.now()}),this.enforceMax()}delete(t){this.map.delete(t)}clear(){this.map.clear()}enforceMax(){if(this.map.size<=Xy)return;const t=Array.from(this.map.entries());t.sort((n,o)=>n[1].storedAtMs-o[1].storedAtMs),t.slice(0,Math.max(0,this.map.size-Xy)).forEach(([n])=>this.map.delete(n))}}function UP(e){return(e??"").trim()||"default"}function Jy(e){const t=UP(e.scope),r=String(e.formId??"").trim(),n=e.version===void 0||e.version===null?"latest":String(e.version).trim();return`form-render:${t}:${r}:${n}`}const Qy=new zP(jP);function Zy(e){const t=Jy(e),r=Qy.get(t);return r?{value:r.value,isStale:r.isStale}:null}function eb(e,t){const r=Jy(e);Qy.set(r,t)}function tb(e){const t={};for(const[n,o]of Object.entries(e)){if(o==null){t[n]=o;continue}if(Array.isArray(o)){t[n]=o;continue}if(typeof o=="object"&&!(o instanceof Date)){const i=o;typeof i.name=="string"&&typeof i.code=="string"?t[n]=`${i.code} ${i.name}`.trim():typeof i.name=="string"?t[n]=i.name:typeof i.code=="string"?t[n]=i.code:typeof i.short_code=="string"?t[n]=i.short_code:t[n]=i.name??i.code??"";continue}t[n]=o}const r=t.time_slot??e.time_slot;return typeof r=="string"&&r.includes(" - ")&&(t.start=r.split(" - ")[0].trim()),t}const Di=({schema:e,formId:t,initialValues:r,onSubmit:n,onChange:o,onValidationError:i,onClose:s,mode:a="fill",className:c,children:u,gridLayout:f,unstyled:l=!1,submissionContext:p,onWorkflowSubmitResult:g,initialExtraSubmitPayload:m,onExtraSubmitPayloadChange:h,workflowStepId:y,initialStepIndex:S,viewerContext:v,getViewerContext:A,hideTableRowControls:x=!1,themeVars:F,dark:N=!1,omitRootWrapper:k=!1,moduleId:T,workflowModalHandlers:P,getAuthHeaders:E})=>{const C=Qn(_=>_.viewerContext),I=w.useMemo(()=>{if(v!==void 0)return v;const _=A?.();return _!==void 0?_:C},[v,A,C]),[W,M]=w.useState(e||null),[U,V]=w.useState(!!t&&!e),[X,B]=w.useState(null),L=e?.BFF_submit_api??X,[D,K]=w.useState(!1),[ae,j]=w.useState({}),[z,le]=w.useState({}),[ie,G]=w.useState({}),[ee,Ae]=w.useState({}),[te,oe]=w.useState({}),[me,Me]=w.useState(null),De=ja.useParams(),ne=Or(_=>_.setValues),ge=Or(_=>_.setSubmitting),Se=Or(_=>_.formDisabled),yt=Or(_=>_.visibleFields),Nt=Or(_=>_.requiredFields),Ut=Or(_=>_.updateVisibility),Ot=Or(_=>_.updateRequired),Er=Or(_=>_.setFieldError),Dt=os(),sr=w.useRef(!1),Vt=w.useRef(void 0),he=w.useMemo(()=>{if(!e)return null;const _=e;if(_.form&&Array.isArray(_.form.fields))try{return Mi(_.form,_.form.fields,_.form.layout||null,_.form.rules||[])}catch{return e}if(Array.isArray(_.fields)&&_.fields.some(R=>typeof R.metadata=="string"&&R.metadata.startsWith("{")||R.fieldType&&!R.type))try{const R={id:_.id||_._id||"temp",name:_.name||"Form",version:_.version??1,status:_.status||"draft",createdAt:_.createdAt||new Date().toISOString(),updatedAt:_.updatedAt||new Date().toISOString(),createdBy:_.createdBy||"system",category:_.category||"",moduleId:_.moduleId,tenantId:_.tenantId,featureId:_.featureId,isDefault:_.isDefault||!1};return Mi(R,_.fields,_.layout||null,_.rules||[])}catch{return e}return e},[e]);w.useEffect(()=>{if(e){const _=e;_.BFF_submit_api&&B(_.BFF_submit_api)}},[e]);const we=w.useMemo(()=>{const _=he||W,q=_?fa(_):null;if(!q)return null;const R=q.layout,Z=q.rules,Q=q.clientMapping,ce=(Array.isArray(q.fields)?q.fields:[]).map(Le=>{let Be={...Le};if(Le.validationRules&&typeof Le.validationRules=="object"&&!Le.validation){const de=Le.validationRules,_e=[];de.required===!0&&_e.push({type:"required",message:"This field is required"}),de.minLength!==void 0&&typeof de.minLength=="number"&&_e.push({type:"minLength",value:de.minLength,message:`Minimum length is ${de.minLength}`}),de.maxLength!==void 0&&typeof de.maxLength=="number"&&_e.push({type:"maxLength",value:de.maxLength,message:`Maximum length is ${de.maxLength}`}),de.pattern&&typeof de.pattern=="string"&&_e.push({type:"pattern",value:de.pattern,message:"Invalid format"}),de.allowLetters!==void 0&&_e.push({type:"allowLetters",value:de.allowLetters}),de.allowNumbers!==void 0&&_e.push({type:"allowNumbers",value:de.allowNumbers}),de.allowSpecialChars!==void 0&&_e.push({type:"allowSpecialChars",value:de.allowSpecialChars}),_e.length>0&&(Be={...Be,validation:_e})}const Ee=Le.required===!0||Le.isRequired===!0,Ne=Array.isArray(Be.validation)&&Be.validation.some(de=>de.type==="required");if(Ee&&!Ne){const de={type:"required",message:"This field is required"},_e=Array.isArray(Be.validation)?Be.validation:[];Be={...Be,validation:[..._e,de]}}if(Le.apidata&&typeof Le.apidata=="object"){const de=Le.apidata,_e=Be.properties||{},xe=(Be.type||Le.fieldType)==="status",pt={};!_e.apiAuth&&de.apiAuth&&(pt.apiAuth=de.apiAuth),(!_e.apiHeaders||_e.apiHeaders.length===0)&&Array.isArray(de.apiHeaders)&&de.apiHeaders.length>0&&(pt.apiHeaders=de.apiHeaders),Object.keys(pt).length>0&&(Be={...Be,properties:{..._e,...pt}});const Tt=Be.properties||{};if(!Tt.apiEndpoint&&de.apiEndpoint){const xt={...Tt,apiEndpoint:de.apiEndpoint,apiMethod:de.apiMethod,apiKey:de.apiKey,apiRealtime:de.apiRealtime,apiAutoDetect:de.apiAutoDetect,apiLabelField:de.apiLabelField,apiValueField:de.apiValueField,apiQueryParams:de.apiQueryParams,apiClientFilter:de.apiClientFilter,apiHeaders:de.apiHeaders??Tt.apiHeaders,apiBodyFields:de.apiBodyFields,apiAuth:de.apiAuth??Tt.apiAuth,valueSource:de.valueSource||(de.apiEndpoint?"api":void 0),optionsSource:de.optionsSource||(de.apiEndpoint?"api":void 0),dependentFields:de.dependentFields,apiResponsePath:de.apiResponsePath};xe&&(xt.source=_e.source??"api",_e.statuses!==void 0&&(xt.statuses=_e.statuses),_e.dataPath!==void 0&&(xt.dataPath=_e.dataPath),_e.showStatusText!==void 0&&(xt.showStatusText=_e.showStatusText),_e.statusTextPath!==void 0&&(xt.statusTextPath=_e.statusTextPath),_e.showCurrentIndicator!==void 0&&(xt.showCurrentIndicator=_e.showCurrentIndicator)),Be={...Be,properties:xt}}}const je=["select","multiselect","radio","checkboxgroup"],Qe=Be.type||Le.fieldType;if(je.includes(Qe)){const de=Le.options,_e=Be.properties?.options,xe=Array.isArray(_e)&&_e.length>0;if(Array.isArray(de)&&de.length>0&&!xe){const pt=Be.properties||{};Be={...Be,properties:{...pt,options:de}}}}return Be}),ye=q.config?.rules,Ce=Z&&Array.isArray(Z)?Z:ye&&Array.isArray(ye)?ye:[],Ue=Ce.length>0?ce.map(Le=>{if((Le.conditions&&Array.isArray(Le.conditions)?Le.conditions:[]).length>0)return Le;const Ee=Le.id??Le._id,Ne=Le.name||Le.key,je=Ce.filter(_e=>{const xe=typeof _e.targetFieldId=="object"?_e.targetFieldId?.id??_e.targetFieldId?._id:_e.targetFieldId;return xe?xe===Ee||xe===Ne||xe===Le.fieldKey:!1});if(je.length===0)return Le;const Qe=[],de=new Set;return je.forEach(_e=>{try{const xe=typeof _e.conditionExpression=="string"?JSON.parse(_e.conditionExpression):_e.conditionExpression;if(!xe||typeof xe!="object")return;!xe.id&&_e.id&&(xe.id=_e.id);const pt=typeof _e.targetFieldId=="object"?_e.targetFieldId?.id??_e.targetFieldId?._id:_e.targetFieldId;xe.action&&(!xe.then||!Array.isArray(xe.then)||xe.then.length===0)&&(xe.then=[{action:xe.action,...pt&&{target:pt}}]),(!xe.then||!Array.isArray(xe.then)||xe.then.length===0)&&_e.action&&(xe.then=[{action:_e.action,...pt&&{target:pt}}]),xe.then&&Array.isArray(xe.then)&&pt&&(xe.then=xe.then.map(xt=>!xt.target&&pt?{...xt,target:pt}:xt));const Tt=_e.conditionExpression??JSON.stringify(xe);if(de.has(Tt))return;de.add(Tt),Qe.push(xe)}catch{}}),Qe.length===0?Le:{...Le,conditions:Qe}}):ce;let Ge=q.config||{submitAction:"database",layout:"default",autoSave:!0,validateOnChange:!0,showFieldErrors:"inline"};return!Ge.layout&&R?typeof R=="object"&&R!==null?Ge.layout="default":typeof R=="string"&&["default","card","compact"].includes(R)?Ge.layout=R:Ge.layout="default":Ge.layout||(Ge.layout="default"),Z&&!Ge.rules&&(Ge.rules=Z),Q&&!Ge.clientMapping&&(Ge.clientMapping=Q),{...q,fields:Ue,config:Ge}},[he,W]);w.useEffect(()=>{he&&he!==W&&M(he)},[he]),w.useEffect(()=>{if(t&&!e){const _=(nn()??"").trim()||"default",q=Zy({scope:_,formId:t,version:"latest"});q?.value?.schema?(M(q.value.schema),q.value.bffSubmitApi&&B(q.value.bffSubmitApi),V(!1),q.isStale&&J({background:!0})):J({background:!1})}},[t,e]);const J=async({background:_})=>{if(!t)return;const q=t;_||V(!0);try{const R=await aP.getForRendering(t),Z=Mi(R.form,R.fields,R.layout,R.rules);if(q!==t)return;M(Z),R.BFF_submit_api&&B(R.BFF_submit_api);const Q=(nn()??"").trim()||"default";eb({scope:Q,formId:q,version:"latest"},{schema:Z,bffSubmitApi:R.BFF_submit_api})}catch{}finally{_||V(!1)}};if(U)return d.jsx("div",{className:"flex items-center justify-center py-12",children:d.jsx(wn,{})});if(!we)return d.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Form not found"});const $=we,fe=w.useMemo(()=>new Set(Object.keys($.config?.prepopulateApi?.fieldMapping??{})),[$.config?.prepopulateApi?.fieldMapping]),Ve=w.useCallback(async _=>{const q=$?.fields?.length?Pc(_,$.fields):_,R=Ic(q,$.config?.sections,$.config?.submitPayload);if(n){const Z=p?{...R,...p}:R;return n(Z)}return{success:!0}},[n,p,$?.fields,$.config?.sections,$.config?.submitPayload]),{values:Fe,errors:ze,touched:st,isSubmitting:ht,isValid:lt,submitCount:ct,totalSteps:nt,currentStepFields:ot,isLastStep:ar,setFieldValue:vt,setFieldTouched:er,handleSubmit:Je,validateForm:ut,resetForm:Ye,nextStep:nr,goToStep:br,currentStep:vr,completedSteps:kt,loadDraft:Nr}=Tu({schema:$,initialValues:r,onSubmit:Ve,onChange:o,workflowStepId:y,initialStepIndex:S}),{isFieldEnabled:lr,isFieldRequired:xn,isFieldVisible:un}=Uw({fields:$.fields,values:Fe,buttonResponses:z,prepopulateResponse:me,prepopulateResponseRules:$.config?.prepopulateResponseRules}),$r=un,zn=Or(_=>_.readOnlyFields),Bt=Or(_=>_.editableFields),Ht=w.useCallback(_=>zn.has(_),[zn]),wr=w.useCallback(_=>Bt.has(_),[Bt]);w.useEffect(()=>{$.config?.allowDraft&&a==="fill"&&Nr()},[$.id]),w.useEffect(()=>{Vt.current=$.id,sr.current=!1,j({}),G({}),Ae({}),oe({}),Me(null)},[$.id]),w.useEffect(()=>{const _=$.config?.prepopulateApi,q=!!(_?.fieldMapping&&Object.keys(_?.fieldMapping??{}).length>0),R=($.config?.prepopulateResponseRules?.length??0)>0;if(!_?.enabled||!_.apiEndpoint?.trim()||!q&&!R||sr.current)return;sr.current=!0;const Z=$.id;Vt.current=$.id;let Q=!1;return K(!0),(async()=>{try{const ce=Dt.getState().values,ye=typeof p=="object"&&p!==null?{...p,...m||{}}:m||{},Ce=se=>Rr(se,ce,De,ye);let Ue=Mr(Ce(_.apiEndpoint));if(_.apiQueryParams?.length){const se=new URLSearchParams;_.apiQueryParams.forEach(({key:Oe,value:be})=>se.append(Oe,Ce(be))),Ue=`${Ue}${Ue.includes("?")?"&":"?"}${se.toString()}`}const Ge={};_.apiHeaders?.forEach(({key:se,value:Oe})=>{se.trim()&&(Ge[se]=Ce(Oe))}),Ge["Content-Type"]=Ge["Content-Type"]??"application/json";let Rt;if(_.apiMethod==="POST"&&_.apiBodyFields?.length){const se={};_.apiBodyFields.forEach(({key:Oe,value:be})=>{Oe.trim()&&(se[Oe]=Ce(be))}),Rt=JSON.stringify(se)}const Le=await fetch(Ue,{method:_.apiMethod,headers:Ge,body:_.apiMethod==="POST"?Rt:void 0});if(!Le.ok){const se=await Le.text();throw new Error(se||`HTTP ${Le.status}`)}const Be=await Le.json(),Ee=se=>{try{return se.split("?")[0].split("/").filter(Boolean).pop()||se}catch{return se}},Ne=(se,Oe)=>{if(se==null)return null;const be=typeof se=="string"?se:se instanceof Date?se.toISOString():null;if(!be)return null;const Re=typeof se=="object"&&se instanceof Date?se:new Date(be);if(Number.isNaN(Re.getTime()))return null;const dt=mt=>String(mt).padStart(2,"0");if(Oe==="date")return be.length>=10&&be[4]==="-"&&be[7]==="-"?be.slice(0,10):Re.toISOString().slice(0,10);if(Oe==="time")return`${dt(Re.getHours())}:${dt(Re.getMinutes())}:${dt(Re.getSeconds())}`;if(Oe==="datetime"){const mt=Re.getFullYear(),Xe=Re.getMonth()+1,pe=Re.getDate(),gt=Re.getHours(),He=Re.getMinutes(),Ft=Re.getSeconds();return`${mt}-${dt(Xe)}-${dt(pe)}T${dt(gt)}:${dt(He)}:${dt(Ft)}`}return null},je=(se,Oe)=>{const be=$.fields.find(pe=>pe.name===se||pe.key===se);if(!be)return Oe;if((be.type==="file"||be.type==="camera"||be.type==="photoChoice")&&typeof Oe=="string"&&Oe.startsWith("http"))return{url:Oe,name:Ee(Oe)};if(be.type==="date"||be.type==="datetime"||be.type==="time"){const pe=Ne(Oe,be.type);if(pe!==null)return pe}if(be.type==="multiselect")return Array.isArray(Oe)?Oe.map(pe=>typeof pe=="string"?pe:String(pe)):typeof Oe=="string"?Oe.trim()===""?[]:Oe.includes(",")?Oe.split(",").map(pe=>pe.trim()).filter(Boolean):[Oe]:Oe!=null&&Oe!==""?[String(Oe)]:[];if(be.type!=="radio"&&be.type!=="select")return Oe;const Re=be.properties?.options??be.options;if(!Array.isArray(Re)||Re.length===0)return Oe;const dt=Re.map(pe=>pe.value);if(dt.includes(Oe))return Oe;const mt=String(Oe);if(dt.includes(mt))return mt;const Xe=Re.find(pe=>pe.value==Oe);return Xe?Xe.value:Oe},Qe=new Set($.fields.filter(se=>se.type==="table").map(se=>se.name||se.key)),de=new Set($.fields.filter(se=>se.type==="billingGrid").map(se=>se.name||se.key)),_e=se=>se.name||se.key||se.id,xe={},pt=[],Tt=[],xt=O_(_?.fieldMapping,$.config?.sections,$.config?.submitPayload);for(const[se,Oe]of Object.entries(xt)){if(!Oe?.trim()||se.startsWith("__"))continue;const be=We(Be,Oe),Re=se.indexOf(".");if(Re>0&&de.has(se.slice(0,Re))){const mt=se.slice(0,Re),Xe=se.slice(Re+1),gt=$.fields.find(He=>(He.name||He.key)===mt)?.properties;if(gt?.rowSlots?.length){const He=Xe.startsWith("__block__")?Xe.slice(9):Xe,Ft=xe[mt]??Dt.getState().values[mt];Array.isArray(be)?xe[mt]=DT(gt,He,be,Ft):be!=null&&(xe[mt]=qc(gt,be,Ft))}continue}if(Re>0&&Qe.has(se.slice(0,Re))){const mt=se.slice(0,Re),Xe=se.slice(Re+1);pt.push({tableName:mt,columnName:Xe,path:Oe});continue}if(de.has(se)&&be!==void 0&&be!==null&&typeof be=="object"){const Xe=$.fields.find(pe=>(pe.name||pe.key)===se)?.properties;if(Xe?.rowSlots?.length){if(Array.isArray(be)){const pe=Xe.rowSlots.find(gt=>gt.kind==="dynamic");if(pe&&pe.kind==="dynamic"){const gt=pe.block.apiArrayPath??"items";xe[se]=qc(Xe,{[gt]:be})}}else xe[se]=qc(Xe,be);continue}}if(Qe.has(se)&&Array.isArray(be)&&be.length>0&&typeof be[0]=="object"&&be[0]!==null){const Xe=$.fields.find(He=>(He.name||He.key)===se)?.properties?.columns||[],pe=be.map(tb),gt=He=>(He||"").toLowerCase().replace(/\s+/g,"_").trim();xe[se]=pe.map(He=>{const Ft={};for(const pr of Xe){const co=pr.name??"";Ft[co]=He[gt(co)]??He[co]}return Ft});continue}if(be!=null&&(xe[se]=je(se,be)),be==null)continue;let dt=be;if(Array.isArray(be)){const mt=$.fields.find(Xe=>_e(Xe)===se);if(mt?.type==="addmore"){Tt.push({addMoreFieldName:se,array:be});continue}if(mt?.type==="multiselect"){const Xe=_.multiselectArrayPropertyMap?.[se];Xe&&be.length>0&&be.some(pe=>pe!=null&&typeof pe=="object")&&(dt=be.map(pe=>pe!=null&&typeof pe=="object"&&Xe in pe?pe[Xe]:void 0).filter(pe=>pe!=null))}}xe[se]=je(se,dt)}const it={},bt={},or={};for(const{addMoreFieldName:se,array:Oe}of Tt){const be=$.fields.find(gt=>_e(gt)===se);if(!be||be.type!=="addmore")continue;const Re=Gy(be,$.fields,$.config?.sections,_e);if(Re.length===0)continue;const dt=_.addMoreFieldKeyMap?.[se],mt=Oe.length>0&&Oe[0]!=null&&typeof Oe[0]=="object"?Oe[0]:null;if(mt)for(const gt of Re){const He=_e(gt),Ft=dt&&dt[He]||He,pr=mt[Ft];pr!=null&&(xe[He]=je(He,pr))}const Xe=Oe.slice(1),pe=Xe.map((gt,He)=>`prepop_${se}_${He}_${Date.now()}`);pe.length>0&&(bt[se]=pe);for(let gt=0;gt<Xe.length;gt++){const He=Xe[gt];if(He==null||typeof He!="object")continue;const Ft=He,pr=Ft.id;pr!=null&&String(pr).trim()!==""&&(or[`${se}__${pe[gt]}`]=String(pr));for(const co of Re){const $a=_e(co),RI=dt&&dt[$a]||$a,Od=Ft[RI];if(Od==null)continue;const KI=`${$a}__addmore__${se}__${pe[gt]}`;it[KI]=je($a,Od)}}}Object.keys(bt).length>0&&G(se=>({...se,...bt})),Object.keys(or).length>0&&oe(se=>({...se,...or}));const Vr=se=>(se||"").toLowerCase().replace(/\s+/g,"_").trim(),en=[...new Set(pt.map(se=>se.tableName))];for(const se of en){if(Array.isArray(xe[se]))continue;const Oe=pt.find(pe=>pe.tableName===se);if(!Oe?.path?.includes("."))continue;const be=Oe.path.replace(/\.[^.]+$/,""),Re=We(Be,be);if(!Array.isArray(Re)||Re.length===0||typeof Re[0]!="object"||Re[0]===null)continue;const mt=$.fields.find(pe=>(pe.name||pe.key)===se)?.properties?.columns||[],Xe=Re.map(tb);xe[se]=Xe.map(pe=>{const gt={};for(const He of mt){const Ft=He.name??"",pr=Vr(Ft),co=pe[pr]??pe[Ft];gt[Ft]=co}return gt})}const Hr=(se,Oe)=>{const be=We(Be,se);if(Array.isArray(be))return be;if(be!=null)return[be];if(!se.includes("."))return[];const Re=se.replace(/\.[^.]+$/,""),dt=We(Be,Re);return!Array.isArray(dt)||dt.length===0||typeof dt[0]!="object"||dt[0]===null?[]:dt.map(mt=>{const Xe=mt[Oe];if(Xe!==null&&typeof Xe=="object"&&!Array.isArray(Xe)&&!(Xe instanceof Date)){const pe=Xe;return typeof pe.name=="string"&&typeof pe.code=="string"?`${pe.code} ${pe.name}`.trim():typeof pe.name=="string"?pe.name:typeof pe.code=="string"?pe.code:typeof pe.short_code=="string"?pe.short_code:pe.name??pe.code??""}return Xe})};for(const{tableName:se,columnName:Oe,path:be}of pt){const Re=Hr(be,Oe),mt=$.fields.find(He=>(He.name||He.key)===se)?.properties?.columns||[],Xe=mt.find(He=>(He.name||"").toLowerCase()===Oe.toLowerCase())?.name??Oe;let pe=Array.isArray(xe[se])?xe[se]:[];const gt=Math.max(pe.length,Re.length);if(gt>pe.length)for(pe=[...pe];pe.length<gt;){const He={};mt.forEach(Ft=>{He[Ft.name||""]=""}),pe.push(He)}else pe=pe.map(He=>({...He}));Re.forEach((He,Ft)=>{pe[Ft]&&(pe[Ft][Xe]=He)}),xe[se]=pe}if(Vt.current===Z){if(Object.keys(xe).length>0||Object.keys(it).length>0){const Ft={...Dt.getState().values,...xe,...it};ne(Ft)}const Oe=We(Be,"data.user_id"),be=We(Be,"data.items"),Re=We(Be,"data");let dt=Array.isArray(be)&&be.length>0&&be[0]!=null&&typeof be[0]=="object"&&be[0].id?be[0].id:void 0;dt===void 0&&Array.isArray(Re)&&Re.length>0&&Re[0]!=null&&typeof Re[0]=="object"&&Re[0].id&&(dt=Re[0].id),dt===void 0&&(dt=We(Be,"data.0.id"));const mt=hP(Be,{treatFirstItemIdAsPaymentId:_?.treatFirstItemIdAsPaymentId===!0}),Xe=We(Be,"data.id"),pe=We(Be,"data.batch_id"),gt=We(Be,"data.program_id"),He={};Oe!=null&&(He.context_user_id=Oe),dt!=null&&dt!==""&&(He.documentId=dt),Xe!=null&&String(Xe).trim()!==""&&(p?.id===void 0||p?.id===null)&&(He.id=Xe),pe!=null&&String(pe).trim()!==""&&((p?.admission_batch_id===void 0||p?.admission_batch_id===null)&&(He.admission_batch_id=pe),(p?.batch_id===void 0||p?.batch_id===null)&&(He.batch_id=pe)),gt!=null&&String(gt).trim()!==""&&(p?.program_id===void 0||p?.program_id===null)&&(He.program_id=gt),mt!=null&&String(mt).trim()!==""&&(p?.payment_id===void 0||p?.payment_id===null)&&(He.payment_id=mt),Object.keys(He).length>0&&j(Ft=>{const pr={...Ft,...He};return h?.(pr),pr}),Me(Be)}}catch(ce){Q||la(ce,"Prepopulate request failed.",Kr)}finally{K(!1)}})(),()=>{Q=!0}},[$.id,$.config?.prepopulateApi?.enabled,$.config?.prepopulateApi?.apiEndpoint,$.config?.prepopulateApi?.apiMethod,JSON.stringify($.config?.prepopulateApi?.fieldMapping),$.config?.prepopulateApi?.treatFirstItemIdAsPaymentId,p,m,De,ne,G]),w.useEffect(()=>{Object.keys(ze).length>0&&i?.(ze)},[ze,i]);const Jr=nt>1,qt=a==="view",cr=w.useCallback((_,q)=>qt||!!q&&!wr(_)||Ht(_)&&!wr(_),[qt,wr,Ht]),Un=$.fields.filter(_=>!_.parentId),_t=[...Jr?ot:Un.length>0?Un:$.fields].filter(_=>!(!_||typeof _!="object"||!_.name&&!_.key)).sort((_,q)=>{const R=typeof _.position?.order=="number"?_.position.order:typeof _.positionOrder=="number"?_.positionOrder:Number.MAX_SAFE_INTEGER,Z=typeof q.position?.order=="number"?q.position.order:typeof q.positionOrder=="number"?q.positionOrder:Number.MAX_SAFE_INTEGER;if(R!==Z)return R-Z;const Q=typeof _.position?.column=="number"?_.position.column:1,ce=typeof q.position?.column=="number"?q.position.column:1;return Q-ce}),Ui=w.useCallback(_=>{const q=Dt.getState().errors,R=Object.keys(q).find(Z=>_.includes(Z));R&&requestAnimationFrame(()=>{document.querySelector(`[data-field-name="${R}"]`)?.scrollIntoView({behavior:"smooth",block:"center"})})},[]),kr=async _=>{if(_?.preventDefault(),Jr&&!ar){if(!await nr())try{const Z=Dt.getState().errors;at.toast.error(da(Z,$.fields)||"Please fix the errors before continuing."),Ui(_t.map(Q=>Q.name||Q.key||Q.id).filter(Boolean))}catch{at.toast.error("Please fix the errors before continuing.")}return}const q=await Je(_);if(q&&q.success===!1&&q.errors?.length)try{const R=Dt.getState().errors;at.toast.error(da(R,$.fields)||"Submission failed. Please check the form."),Ui(_t.map(Z=>Z.name||Z.key||Z.id).filter(Boolean))}catch{at.toast.error("Submission failed. Please check the form.")}return q},Qr=w.useCallback(()=>{Ye(),s&&s()},[Ye,s]),jr=w.useCallback((_,q)=>{const R=$.fields.find(ce=>ce.type==="button"&&(ce.name===_||ce.key===_)),Z=R?.properties,Q=vP(q,R);Q!=null&&String(Q).trim()!==""&&(p?.payment_id===void 0||p?.payment_id===null)&&j(ce=>{const ye={...ce,payment_id:Q};return h?.(ye),ye}),R&&Z?.apiSuccessConfig&&o_(q,Z.apiSuccessConfig,{setFieldValue:(ce,ye)=>Dt.getState().setFieldValue(ce,ye),onContextUpdate:ce=>{j(ye=>{const Ce={...ye,...ce};return h?.(Ce),Ce})}}),le(ce=>{const ye={...ce,[_]:q};return!ei(q)||!(R?.type==="button"&&R.properties?.action==="submit")||$.fields.filter(Ge=>Ge.type==="editButton").map(Ge=>Ge.name).forEach(Ge=>delete ye[Ge]),ye})},[$.fields,p,h,Dt]),zr=w.useCallback(async()=>await ut(),[ut]),_r=w.useCallback(()=>Dt.getState().errors,[]),Yt=w.useMemo(()=>({...m||{},...ae}),[m,ae]),ke=w.useMemo(()=>({...typeof p=="object"&&p!==null?p:{},...Yt}),[p,Yt]),O=$.config?.layout??$.layout??"default",re=["default","card","compact"].includes(O)?O:"default",ve={default:"",card:"bg-card border rounded-lg shadow-sm p-6",compact:"space-y-2"},rt=w.useMemo(()=>{if(k)return;const _=$.config?.theme?.cssVariables;if(!(!_&&!F))return{..._??{},...F??{}}},[k,$.config?.theme?.cssVariables,F]),wt=w.useMemo(()=>Ki({config:$.config,layout:$.layout},f),[$.config,$.layout,f]),St=w.useMemo(()=>wt?{...wt,verticalSpacing:wt.verticalSpacing??wt.spacing??"16px",horizontalSpacing:wt.horizontalSpacing??wt.spacing??"16px",rowHeight:wt.rowHeight??Hn}:null,[wt]),Wt=St!==null;St?.rows;const Et=St?.columns??3,Ur=St?.verticalSpacing??St?.spacing??"16px",Ro=St?.horizontalSpacing??St?.spacing??"16px",It=St?.rowHeight??Hn,fn=w.useCallback(_=>{if(!I)return!0;const q=_.visibility;if(!q)return!0;const R=q.visibleToUserType??q.user_type,Z=q.visibleToUserRole??q.user_role,Q=Array.isArray(q.visibleToUserIds)?q.visibleToUserIds:Array.isArray(q.users)?q.users:[],ce=Array.isArray(q.hiddenFromUserIds)?q.hiddenFromUserIds:[];if(Array.isArray(ce)&&ce.length>0&&I.userId!=null&&ce.includes(I.userId))return!1;if(Q.length>0&&I.userId!=null&&Q.includes(I.userId))return!0;const ye=R!=null&&R!==""&&I.userType!=null&&I.userType!==R,Ce=Z!=null&&Z!==""&&I.role!=null&&I.role!==Z,Ue=Q.length>0&&(I.userId==null||!Q.includes(I.userId));return!(ye||Ce||Ue)},[I]),An=w.useMemo(()=>K_($.fields),[$.fields]),_d=w.useMemo(()=>q_($.fields),[$.fields]),[Ko,zb]=w.useState(_d);w.useEffect(()=>{zb(_d)},[$.id,_d]);const Ub=w.useCallback((_,q)=>{zb(R=>R[_]===q?R:{...R,[_]:q})},[]),zI=w.useMemo(()=>({visibility:Ko,setSectionVisible:Ub,fieldToHeading:An,allFields:$.fields}),[Ko,Ub,An,$.fields]),et=w.useCallback(_=>_.name||_.key||_.id,[]),Tr=_=>{if(!fn(_))return!1;const q=_.name||_.key||_.id;if(!Hg(q,_.type,Ko,An))return!1;const R=_.hidden===!0;return $r(q)||!R&&q},Vb=w.useCallback(_=>{const q=$.fields.find(Z=>et(Z)===_);if(q)return q.type;const R=Vg(_);return $.fields.find(Z=>et(Z)===R)?.type},[$.fields,et]),Na=w.useCallback(_=>Hg(_,Vb(_),Ko,An),[Ko,An,Vb]),Cn=w.useCallback(_=>Na(_)?xn(_):!1,[Na,xn]);w.useEffect(()=>{const{visibleFields:_,requiredFields:q,errors:R}=Dt.getState(),Z=new Set(_),Q=new Set(q),ce=[];for(const ye of $.fields){const Ce=et(ye);Ce&&(Na(Ce)||(Z.delete(Ce),Q.delete(Ce),R[Ce]&&ce.push(Ce)))}Ut(Array.from(Z)),Ot(Array.from(Q));for(const ye of ce)Er(ye,void 0)},[Ko,An,$.fields,$.id,et,Na,Ut,Ot,Er,yt,Nt]);const $t=$.config?.sections,ao=w.useCallback(_=>{const q=et(_);let R=_;if(_.type==="table"){const Q=_.properties?.columns;if(Array.isArray(Q)&&Q.length>0){const ce=Q.filter(ye=>fn(ye));R={..._,properties:{..._.properties,columns:ce}}}}const Z=CP(R,$t,et);return Z&&(R={...R,label:Ky(Z,0)}),{...R,disabled:!lr(q),readOnly:cr(q,!!R.readOnly)}},[fn,$t,et,lr,cr]),En=w.useCallback(_=>Gy(_,$.fields,$t,et),[$.fields,$t,et]),Zr=w.useCallback((_,q,R)=>`${_}__addmore__${q}__${R}`,[]),ka=w.useCallback((_,q)=>`${_}__${q??"base"}`,[]),_a=w.useCallback((_,q)=>{const R=ka(_.id,q);return ee[R]??_.defaultCollapsed??!1},[ee,ka]),Td=w.useCallback((_,q,R)=>{const Z=ka(_,q);Ae(Q=>Q[Z]===R?Q:{...Q,[Z]:R})},[ka]),Ta=w.useMemo(()=>{const _=[],q=$.fields.filter(R=>R.type==="addmore");for(const R of q){const Z=et(R),ce=En(R).find(Ge=>{if(Ge.type!=="button")return!1;const Rt=Ge.properties,Le=Ge.metadata;let Be=Rt?.action;if(!Be&&Le!=null)try{Be=(typeof Le=="string"?JSON.parse(Le):Le)?.action}catch{}return Be==="upload"||Be==="custom"});if(!ce)continue;const ye=et(ce),Ce=ie[Z]||[],Ue=We(z[ye],"data.id")??We(z[ye],"data.documentId")??ae.documentId;Ue!=null&&String(Ue).trim()!==""&&_.push(String(Ue));for(const Ge of Ce){const Rt=Zr(ye,Z,Ge),Le=We(z[Rt],"data.id")??We(z[Rt],"data.documentId"),Be=te[`${Z}__${Ge}`],Ee=Le??Be;Ee!=null&&String(Ee).trim()!==""&&_.push(String(Ee))}}return _},[$.fields,ie,z,te,ae.documentId,et,En,Zr]);w.useEffect(()=>{j(_=>{const q={..._,document_ids:Ta},R=_.document_ids;return Array.isArray(R)&&R.length===Ta.length&&Ta.every((Z,Q)=>R[Q]===Z)?_:q})},[Ta]);const Fa=w.useCallback((_,q,R,Z)=>{for(const Q of R){const ce=et(Q),ye=Zr(ce,_,q),Ce=Z[ye];if(Ce==null)continue;const Ue=Q.type;if(Ue==="file"||Ue==="camera"||Ue==="photoChoice"){if(typeof Ce=="object"&&Ce!==null&&("url"in Ce||"name"in Ce)||Array.isArray(Ce)&&Ce.length>0)return!0;continue}if(Array.isArray(Ce)){if(Ce.length>0)return!0;continue}if(typeof Ce=="string"&&Ce.trim()!==""||typeof Ce=="number"&&!Number.isNaN(Ce)||typeof Ce=="boolean"||typeof Ce=="object"&&Ce!==null&&Object.keys(Ce).length>0)return!0}return!1},[et,Zr]),lo=w.useCallback(_=>{const q=et(_);if(!q)return;if(En(_).length===0){at.toast.error("No linked fields configured for this Add More button.");return}const Z=`${Date.now()}_${Math.random().toString(36).slice(2,8)}`;G(Q=>({...Q,[q]:[...Q[q]||[],Z]}))},[et,En]),Pa=w.useCallback((_,q)=>{G(R=>{const Z=R[_]||[],Q=Z.filter(ce=>ce!==q);if(Q.length===Z.length)return R;if(Q.length===0){const ce={...R};return delete ce[_],ce}return{...R,[_]:Q}})},[]),Oa=w.useMemo(()=>_t.filter(_=>!_.parentId),[_t]),Vn=w.useMemo(()=>{const _=[];return _t.filter(R=>R.type==="addmore").sort((R,Z)=>{const Q=R.position?.order??0,ce=Z.position?.order??0;return Q-ce}).forEach(R=>{const Z=et(R),Q=R.position?.order??0,ce=ie[Z]||[],ye=En(R).sort((Ne,je)=>{const Qe=Ne.position?.order??0,de=je.position?.order??0;return Qe!==de?Qe-de:(Ne.position?.column??1)-(je.position?.column??1)});if(ye.length===0)return;const Ce=Ry(R,$t),Ue=Ce[0]?.fieldNames?.length?Ce[0].fieldNames:ye.map(Ne=>et(Ne)).filter(Boolean),Ge=kP(Ue,Oa,Et,et),Rt=Math.min(...ye.map(Ne=>Ne.position?.order??0)),Le=Math.max(1,...ye.map(Ne=>(Ne.position?.order??Rt)-Rt+Xo(Ne))),Be=Ge?.blockHeight??Le,Ee=ce.length*Be;_.push({addMoreFieldName:Z,baseOrder:Q,blockHeight:Be,blockIds:ce,linkedFields:ye,insertedRows:Ee,templateFieldNames:Ue,templateBounds:Ge})}),_},[_t,Oa,Et,et,ie,En,$t]),Vi=w.useMemo(()=>({}),[]),Ia=w.useMemo(()=>Vn.length===0?_t:_t.map(_=>{const q=_.position?.order??0,R=Vn.reduce((Z,Q)=>{const ce=Q.templateBounds?.maxRow??Q.baseOrder;return q>ce?Z+Q.insertedRows:Z},0);return R===0?_:{..._,position:{..._.position,order:q+R}}}),[_t,Vn]),Ma=w.useCallback(_=>{const q={};return Object.entries(z).forEach(([R,Z])=>{const Q=_[R];Q&&(q[Q]=Z)}),q},[z]),Go=w.useMemo(()=>{const _=[],q={};return Vn.forEach(R=>{const{addMoreFieldName:Z,blockIds:Q,linkedFields:ce,blockHeight:ye,templateBounds:Ce}=R,Ue=Math.min(...ce.map(Le=>Le.position?.order??0)),Rt=$.fields.find(Le=>et(Le)===Z&&Le.type==="addmore")?.properties;Q.forEach((Le,Be)=>{const Ee={},Ne={},je={},Qe=Ce?_P(Ce,Be):R.baseOrder+1+Be*ye,de=te[`${Z}__${Le}`];ce.forEach(xe=>{const pt=et(xe),Tt=Zr(pt,Z,Le),xt=(xe.position?.order??Ue)-Ue;if(Ee[Tt]=pt,Ne[Tt]=Fe[Tt],!(Rt?.linkedFieldAllowDuplicate?.[pt]??!0)&&(xe.type==="select"||xe.type==="radio"||xe.type==="multiselect")){const bt=[],or=Fe[pt];or!=null&&or!==""&&(Array.isArray(or)?bt.push(...or.map(en=>String(en))):bt.push(String(or))),Q.filter(en=>en!==Le).forEach(en=>{const Hr=Zr(pt,Z,en),tn=Fe[Hr];tn!=null&&tn!==""&&(Array.isArray(tn)?bt.push(...tn.map(se=>String(se))):bt.push(String(tn)))}),bt.length>0&&(je[Tt]=[...new Set(bt)])}_.push({...xe,id:`${xe.id}__${Le}`,name:Tt,position:{...xe.position,order:Qe+xt}})});const _e=Ma(Ee);Object.keys(Ee).forEach(xe=>{q[xe]={scopedFormValues:Ne,scopedFieldNameMap:Ee,scopedButtonResponses:_e,...de!=null&&{blockDocumentId:de},...je[xe]&&{excludedOptionValues:je[xe]}}})})}),{clonedFields:_,scopeByFieldName:q}},[Vn,te,et,Zr,Fe,Ma,$.fields]),Hi=w.useMemo(()=>[...Ia,...Go.clonedFields].sort((_,q)=>{const R=_.position?.order??0,Z=q.position?.order??0;if(R!==Z)return R-Z;const Q=_.position?.column??1,ce=q.position?.column??1;if(Q!==ce)return Q-ce;const ye=Oo(_.position)??0,Ce=Oo(q.position)??0;return ye!==Ce?ye-Ce:String(_.id).localeCompare(String(q.id))}),[Ia,Go.clonedFields]),qo=w.useMemo(()=>l_(Hi.filter(_=>!_.parentId),Tr),[Hi,Tr]),Fd=w.useCallback((_,q)=>qo.some(R=>c_(_,q,R,Et)),[qo,Et]);qo.length===0||Math.max(...qo.map(_=>(_[0]?.position?.order??0)+Ni(_,Et).rowSpan));const La=w.useMemo(()=>EP($t,fd(_t.filter(_=>!_.parentId)),et),[$t,_t,et]),{anchorsByOrigin:Hb,coveredCells:Wb}=w.useMemo(()=>TP(La,Ia,et,Et),[La,Ia,et,Et]),{anchorsByOrigin:Rb,coveredCells:Kb}=w.useMemo(()=>FP(Vn.map(_=>({addMoreFieldName:_.addMoreFieldName,blockIds:_.blockIds,linkedFields:_.linkedFields,templateFieldNames:_.templateFieldNames})),$t,Go.clonedFields,Oa,Et,et,Wb),[Vn,$t,Go.clonedFields,Oa,Et,et,Wb]),Nn=w.useMemo(()=>DP(Hb,Rb),[Hb,Rb]),Gb=w.useMemo(()=>Kb,[Kb]),qb=String(It).endsWith("px")?It:Hn,Yb=w.useCallback((_,q)=>{for(let R=0;R<Et;R++){if(R>=q.anchorCol&&R<q.anchorCol+q.colSpan)continue;if(Vi[`${_}-${R}`]||Nn.get(`${_}-${R}`)||Eg(_,R,Hi,Tr).length>0||Fd(_,R))return!0}return!1},[Et,Vi,Nn,Hi,Tr,Fd]),Xb=w.useMemo(()=>MP(Nn,_=>{const q=_.run.section;return q.collapsible?_a(q,_.addMoreMeta?.blockId):!1},Yb),[Nn,_a,Yb]),Jb=w.useMemo(()=>{const _=[];for(const q of Object.keys(Vi)){const R=Number(q.split("-")[0]);Number.isNaN(R)||_.push(R)}for(const q of Nn.values())if(q.renderFields.some(R=>Tr(R)))for(let R=q.anchorRow;R<q.anchorRow+q.rowSpan;R++)_.push(R);return d_(qo,Et,_)},[qo,Et,Vi,Nn,Tr]),{originalToDisplayRow:Da,displayRowCount:UI,sortedOccupiedRows:VI}=w.useMemo(()=>{const _=u_(Jb);return{originalToDisplayRow:_.originalToDisplay,displayRowCount:_.displayRowCount,sortedOccupiedRows:_.sortedOriginalRows}},[Jb]),Qb=Math.max(UI,1),Pd=w.useCallback((_,q=1)=>f_(_,q,Da),[Da]),Zb=w.useMemo(()=>{const _=new Set;for(const q of Xb){const R=Da.get(q);R!==void 0&&_.add(R)}return _},[Xb,Da]),HI=w.useMemo(()=>LP(Qb,qb,Zb),[Qb,qb,Zb]),WI=w.useMemo(()=>BP(_t.filter(_=>!_.parentId&&Tr(_)),La,et),[_t,La,et,Tr]),Ba=w.useCallback(_=>{if(Wt)return null;const q=et(_),R=ie[q]||[];if(R.length===0)return null;const Z=En(_);if(Z.length===0)return null;const Q=AP(_,$t),ce=Z.map(Ue=>et(Ue)).filter(Boolean),ye=Yy(ce,$t),Ce=(Ue,Ge,Rt,Le,Be,Ee,Ne)=>{const je=et(Ue),Qe=Zr(je,q,Ge),de=Ue.hidden===!0;if(!(fn(Ue)&&($r(je)||!de&&je)))return null;const xe={...Ue,id:`${Ue.id}__${Ge}`,name:Qe,disabled:!lr(je),readOnly:cr(je,!!Ue.readOnly)},Tt=_.properties?.linkedFieldAllowDuplicate?.[je]??!0;let xt;if(!Tt&&(Ue.type==="select"||Ue.type==="radio"||Ue.type==="multiselect")){const it=[],bt=Fe[je];bt!=null&&bt!==""&&(Array.isArray(bt)?it.push(...bt.map(Vr=>String(Vr))):it.push(String(bt))),R.filter(Vr=>Vr!==Ge).forEach(Vr=>{const en=Zr(je,q,Vr),Hr=Fe[en];Hr!=null&&Hr!==""&&(Array.isArray(Hr)?it.push(...Hr.map(tn=>String(tn))):it.push(String(Hr)))}),it.length>0&&(xt=[...new Set(it)])}return d.jsx("div",{"data-field-name":Qe,"data-form-renderer":"field-wrapper",children:d.jsx(Sn,{field:xe,value:Fe[Qe],error:st[Qe]||ct>0?ze[Qe]:void 0,onChange:it=>vt(Qe,it),onBlur:()=>er(Qe),disabled:Se||!lr(je)||qt,readOnly:cr(je,!!Ue.readOnly),isRequired:Cn(je),formValues:Fe,submissionContext:ke,prepopulateMappedFieldNames:fe,urlParams:De,prepopulateResponse:me,prepopulateLoading:D,formSections:$t,submitPayload:$.config?.submitPayload,fieldValueKey:Qe,buttonResponses:Ee,onButtonApiResponse:jr,onSubmit:kr,onReset:Ye,onCancel:Qr,isSubmitting:ht,bffSubmitApi:L,onBffSubmitResult:g,extraSubmitPayload:Ne,onValidateForm:zr,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,scopedFormValues:Be,scopedFieldNameMap:Le,excludedOptionValues:xt,hideTableRowControls:x})},xe.id)};return d.jsx("div",{className:"space-y-3 mt-3",children:R.map((Ue,Ge)=>{const Rt={},Le={};Z.forEach(xt=>{const it=et(xt),bt=Zr(it,q,Ue);Rt[bt]=it,Le[bt]=Fe[bt]});const Be=Ma(Rt),Ee=Fa(q,Ue,Z,Fe),Ne=Q?.heading!=null?Li(Q,Ge+1):null,je=te[`${q}__${Ue}`],Qe=je!=null?{...Yt,documentId:je}:Yt,de=Z.map(xt=>Ce(xt,Ue,Ge,Rt,Le,Be,Qe)).filter(Boolean),xe=ye?.section?.collapsible===!0,pt=d.jsx("button",{type:"button",className:"inline-flex shrink-0 rounded-md p-1.5 text-destructive hover:bg-destructive/10 focus:outline-none focus:ring-2 focus:ring-ring disabled:pointer-events-none disabled:opacity-40",disabled:Ee,title:Ee?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:xt=>{xt.preventDefault(),xt.stopPropagation(),Pa(q,Ue)},children:d.jsx(oi,{className:"h-5 w-5","aria-hidden":!0})}),Tt=d.jsxs(d.Fragment,{children:[!xe&&d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[Ne?d.jsx("p",{className:"text-sm font-medium text-foreground",children:Ne}):d.jsxs("p",{className:"text-xs text-muted-foreground",children:["Entry ",Ge+1]}),pt]}),de]});return d.jsx("div",{className:"rounded-md border p-3 space-y-3",children:ye?d.jsx(ld,{legend:ye.section.heading?.enabled?Li(ye.section,Ge+1):ye.section.name,collapsible:ye.section.collapsible,defaultCollapsed:ye.section.defaultCollapsed,headerActions:xe?pt:void 0,onCollapsedChange:xt=>Td(ye.section.id,Ue,xt),children:Tt}):Tt},`${_.id}-${Ue}`)})})},[Wt,ie,te,et,En,Zr,Fa,Fe,st,ct,ze,vt,er,lr,qt,Cn,ke,fe,jr,kr,Ye,Qr,ht,L,g,Yt,zr,_r,$.fields,ge,$r,fn,Ma,Pa,x,$t,De,me,D]),ev=d.jsx("div",{className:k?H("relative",c):H(za,N&&"dark",c),style:rt,"data-form-renderer":k?void 0:"root",children:d.jsxs("div",{className:"relative",children:[D&&d.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/60 rounded-md",children:d.jsx(wn,{})}),d.jsx("form",{onSubmit:kr,className:l?H("w-full min-w-0"):H("space-y-6 pb-[100px] w-full min-w-0",ve[re]),"data-form-renderer":"form","data-form-renderer-layout":Wt?"grid":"stack",children:d.jsxs(H_,{value:zI,children:[Jr&&$.steps&&d.jsx($P,{steps:$.steps,currentStep:vr,completedSteps:kt,onStepClick:br}),d.jsx(Ja.Provider,{value:{gridStretch:Wt},children:Wt?d.jsx("div",{className:l?"w-full min-w-0":"grid w-full min-w-0",style:{display:"grid",gridTemplateRows:HI,gridTemplateColumns:`repeat(${Et}, 1fr)`,rowGap:Ur,columnGap:Ro},"data-form-renderer":"grid",children:VI.map(_=>Array.from({length:Et},(q,R)=>{const Z=Pd(_);if(!Z)return null;if(Fd(_,R))return d.jsx("div",{className:"min-w-0 min-h-0",style:{gridRow:Z,gridColumn:R+1,visibility:"hidden",pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`empty-${_}-${R}`);if(PP(_,R,Gb,Nn)){const Ee=OP(_,R,Nn);return Ee&&IP(_,R,Ee,_a(Ee.run.section,Ee.addMoreMeta?.blockId))?null:d.jsx("div",{className:"min-w-0 min-h-0",style:{gridRow:Z,gridColumn:R+1,visibility:"hidden",pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`section-border-cover-${_}-${R}`)}const Q=Nn.get(`${_}-${R}`);if(Q){const Ee=Q.renderFields.filter(it=>Tr(it));if(Ee.length===0)return null;const Ne=Q.addMoreMeta,je=Ne!=null?Vn.find(it=>it.addMoreFieldName===Ne.addMoreFieldName)?.linkedFields??[]:[],Qe=Ne!=null?Fa(Ne.addMoreFieldName,Ne.blockId,je,Fe):!1,de=Q.run.section,_e=Ne?.blockId,xe=_a(de,_e),pt=de.collapsible&&xe?1:Q.rowSpan,Tt=Pd(Q.anchorRow,pt)??Z,xt=Ne!=null?d.jsx("button",{type:"button",className:H("inline-flex shrink-0 rounded-md p-1.5 text-destructive hover:bg-destructive/10 focus:outline-none focus:ring-2 focus:ring-ring disabled:pointer-events-none disabled:opacity-40",l&&"text-red-600 hover:bg-red-500/10"),disabled:Qe,title:Qe?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:it=>{it.preventDefault(),it.stopPropagation(),Pa(Ne.addMoreFieldName,Ne.blockId)},children:d.jsx(oi,{className:"h-5 w-5","aria-hidden":!0})}):void 0;return d.jsx("div",{className:H("min-h-0 min-w-0",!(de.collapsible&&xe)&&"self-stretch"),style:{gridRow:Tt,gridColumn:`${R+1} / span ${Q.colSpan}`},"data-form-renderer":"grid-cell","data-form-renderer-config-section-border-cell":!0,children:d.jsx(ld,{legend:Q.legend,className:de.collapsible&&xe?void 0:"h-full",collapsible:de.collapsible,defaultCollapsed:de.defaultCollapsed,headerActions:xt,onCollapsedChange:it=>Td(de.id,_e,it),children:d.jsx("div",{className:"grid w-full min-w-0",style:{gridTemplateColumns:`repeat(${Et}, 1fr)`,gridTemplateRows:`repeat(${Q.rowSpan}, minmax(${String(It).endsWith("px")?It:Hn}, auto))`,rowGap:Ur,columnGap:Ro},children:Ee.map(it=>{const bt=et(it),or=Go.scopeByFieldName[bt],Vr=or?.scopedFieldNameMap?.[bt]||bt,en=(it.position?.order??Q.anchorRow)-Q.anchorRow,Hr=it.position?.column??1,{rowSpan:tn,columnSpan:se}=Ni([it],Et),Oe=Ne!=null?te[`${Ne.addMoreFieldName}__${Ne.blockId}`]:void 0,be=Oe!=null?{...Yt,documentId:Oe}:Yt;return d.jsx("div",{"data-field-name":bt,"data-form-renderer":"field-wrapper",className:"min-h-0 min-w-0",style:{gridRow:`${en+1} / span ${tn}`,gridColumn:`${Hr} / span ${se}`,...On(it)},children:d.jsx(Sn,{field:ao(it),value:Fe[bt],error:st[bt]||ct>0?ze[bt]:void 0,onChange:Re=>vt(bt,Re),onBlur:()=>er(bt),disabled:(it.type==="table"||it.type==="billingGrid")&&a==="fill"?!1:Se||!lr(Vr)||qt,readOnly:(it.type==="table"||it.type==="billingGrid")&&a==="fill"?!1:cr(Vr,!!it.readOnly),isRequired:Cn(Vr),formValues:Fe,submissionContext:ke,prepopulateMappedFieldNames:fe,urlParams:De,prepopulateResponse:me,prepopulateLoading:D,formSections:$t,submitPayload:$.config?.submitPayload,fieldValueKey:bt,buttonResponses:or?.scopedButtonResponses??z,onButtonApiResponse:jr,onSubmit:kr,onReset:Ye,onCancel:Qr,isSubmitting:ht,bffSubmitApi:L,onBffSubmitResult:g,extraSubmitPayload:be,onValidateForm:zr,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:lo,scopedFormValues:or?.scopedFormValues,scopedFieldNameMap:or?.scopedFieldNameMap,excludedOptionValues:or?.excludedOptionValues,hideTableRowControls:x})},it.id)})})})},`section-border-${Q.run.section.id}-${_}-${R}-${Ne?.blockId??"base"}`)}const ce=Eg(_,R,Hi,Tr).filter(Ee=>!(et(Ee)?.includes("__addmore__")&&Gb.has(`${_}-${R}`)));if(ce.length===0){const Ee=Vi[`${_}-${R}`];if(Ee){const Ne=$.fields.find(de=>de.type==="addmore"&&et(de)===Ee.addMoreFieldName),je=Ne!=null?En(Ne):[],Qe=Fa(Ee.addMoreFieldName,Ee.blockId,je,Fe);return d.jsx("div",{className:"min-h-0 min-w-0 flex flex-col items-center justify-center",style:{gridRow:Z,gridColumn:R+1},"data-form-renderer":"grid-cell","data-form-renderer-add-more-remove":!0,children:d.jsx("button",{type:"button",className:H("inline-flex shrink-0 rounded-md p-1.5 text-destructive hover:bg-destructive/10 focus:outline-none focus:ring-2 focus:ring-ring disabled:pointer-events-none disabled:opacity-40",l&&"text-red-600 hover:bg-red-500/10"),disabled:Qe,title:Qe?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:de=>{de.preventDefault(),de.stopPropagation(),Pa(Ee.addMoreFieldName,Ee.blockId)},children:d.jsx(oi,{className:"h-5 w-5","aria-hidden":!0})})},`add-more-remove-${_}-${R}`)}return d.jsx("div",{className:"min-w-0",style:{pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`empty-${_}-${R}`)}const ye=ce[0],{rowSpan:Ce,columnSpan:Ue}=Ni(ce,Et),Ge=Pd(_,Ce)??Z;if(ce.length===1&&ye.type==="section"){const Ee=$.fields.filter(Ne=>Ne.parentId===ye.id&&Ne.position!=null).sort((Ne,je)=>{const Qe=typeof Ne.position?.order=="number"?Ne.position.order:0,de=typeof je.position?.order=="number"?je.position.order:0;return Qe-de});return d.jsx("div",{className:"min-w-0 min-h-0 w-full overflow-hidden flex flex-col h-full",style:{gridRow:Ge,gridColumn:`${R+1} / span ${Ue}`,...On(ye)},"data-form-renderer":"grid-cell",children:d.jsx(hy,{field:ye,children:Ee.map(Ne=>{const je=Ne.name||Ne.key||Ne.id,Qe=Ne.hidden===!0;return fn(Ne)&&($r(je)||!Qe&&je)?d.jsx("div",{"data-field-name":je,"data-form-renderer":"field-wrapper",children:d.jsx(Sn,{field:ao(Ne),value:Fe[je],error:st[je]||ct>0?ze[je]:void 0,onChange:_e=>vt(je,_e),onBlur:()=>er(je),disabled:Se||!lr(je)||qt,readOnly:cr(je,!!Ne.readOnly),isRequired:Cn(je),formValues:Fe,submissionContext:ke,prepopulateMappedFieldNames:fe,urlParams:De,prepopulateResponse:me,prepopulateLoading:D,formSections:$t,submitPayload:$.config?.submitPayload,fieldValueKey:je,buttonResponses:z,onButtonApiResponse:jr,onSubmit:kr,onReset:Ye,onCancel:Qr,isSubmitting:ht,bffSubmitApi:L,onBffSubmitResult:g,extraSubmitPayload:Yt,onValidateForm:zr,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:lo,hideTableRowControls:x})},Ne.id):null})})},ye.id)}const Rt=Ag(ce),Le=ce.some(Ee=>["file","camera","photoChoice","addmore","table","billingGrid"].includes(Ee.type)),Be=d.jsx("div",{className:H("flex min-h-0 w-full flex-1 gap-3",Rt==="row"?"flex-row items-stretch":"flex-col items-stretch"),children:ce.map(Ee=>{const Ne=Ee.name||Ee.key||Ee.id,je=Ee.type==="sectionHeading",Qe=Go.scopeByFieldName[Ne],de=Qe?.scopedFieldNameMap?.[Ne]||Ne,_e=Qe?.blockDocumentId!=null?{...Yt,documentId:Qe.blockDocumentId}:Yt,xe=Ee.appearance?.hideLabel??Ee.properties?.hideLabel??!1,pt=Ee.type==="table"||Ee.type==="billingGrid"?Ee.properties?.minWidth:void 0;return d.jsx("div",{"data-field-name":Ne,"data-form-renderer":"field-wrapper",className:H("flex min-h-0 min-w-0 flex-1 flex-col",Qo(Ee),je&&"items-center justify-center",xe&&"items-center"),style:{...pt?{minWidth:pt}:{},...On(Ee)},children:d.jsx(Sn,{field:ao(Ee),value:Fe[Ne],error:st[Ne]||ct>0?ze[Ne]:void 0,onChange:Tt=>vt(Ne,Tt),onBlur:()=>er(Ne),disabled:(Ee.type==="table"||Ee.type==="billingGrid")&&a==="fill"?!1:Se||!lr(de)||qt,readOnly:(Ee.type==="table"||Ee.type==="billingGrid")&&a==="fill"?!1:cr(de,!!Ee.readOnly),isRequired:Cn(de),formValues:Fe,submissionContext:ke,prepopulateMappedFieldNames:fe,urlParams:De,prepopulateResponse:me,prepopulateLoading:D,formSections:$t,submitPayload:$.config?.submitPayload,fieldValueKey:Ne,buttonResponses:Qe?.scopedButtonResponses??z,onButtonApiResponse:jr,onSubmit:kr,onReset:Ye,onCancel:Qr,isSubmitting:ht,bffSubmitApi:L,onBffSubmitResult:g,extraSubmitPayload:_e,onValidateForm:zr,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:lo,scopedFormValues:Qe?.scopedFormValues,scopedFieldNameMap:Qe?.scopedFieldNameMap,excludedOptionValues:Qe?.excludedOptionValues,hideTableRowControls:x})},Ee.id)})});return d.jsx("div",{className:H(iu(ce),"self-stretch",Le?"overflow-visible":"overflow-hidden"),style:{gridRow:Ge,gridColumn:`${R+1} / span ${Ue}`,...On(ce[0])},"data-form-renderer":"grid-cell","data-field-name":ce.map(Ee=>Ee.name||Ee.key||Ee.id).join(","),children:Be},ce.map(Ee=>Ee.id).join("-"))}))}):d.jsx("div",{className:l?"":"space-y-4","data-form-renderer":"stack",children:_t.map(_=>{if(!Tr(_))return null;const q=WI.find(Z=>Z.kind==="border"&&Z.fields.some(Q=>Q.id===_.id));if(q)return q.fields[0]?.id!==_.id?null:d.jsx(ld,{legend:Li(q.run.section,0),collapsible:q.run.section.collapsible,defaultCollapsed:q.run.section.defaultCollapsed,onCollapsedChange:Z=>Td(q.run.section.id,void 0,Z),children:q.fields.map(Z=>{const Q=et(Z);return!Q||!Tr(Z)?null:d.jsxs("div",{"data-field-name":Q,"data-form-renderer":"field-wrapper",style:On(Z),children:[d.jsx(Sn,{field:ao(Z),value:Fe[Q],error:st[Q]||ct>0?ze[Q]:void 0,onChange:ce=>vt(Q,ce),onBlur:()=>er(Q),disabled:(Z.type==="table"||Z.type==="billingGrid")&&a==="fill"?!1:Se||!lr(Q)||qt,readOnly:(Z.type==="table"||Z.type==="billingGrid")&&a==="fill"?!1:cr(Q,!!Z.readOnly),isRequired:Cn(Q),formValues:Fe,submissionContext:ke,prepopulateMappedFieldNames:fe,urlParams:De,prepopulateResponse:me,prepopulateLoading:D,formSections:$t,submitPayload:$.config?.submitPayload,fieldValueKey:Q,buttonResponses:z,onButtonApiResponse:jr,onSubmit:kr,onReset:Ye,onCancel:Qr,isSubmitting:ht,bffSubmitApi:L,onBffSubmitResult:g,extraSubmitPayload:Yt,onValidateForm:zr,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:lo,hideTableRowControls:x}),Z.type==="addmore"&&Ba(Z)]},Z.id)})},`stack-border-${q.run.section.id}-${_.id}`);if(!_.parentId){const Z=_t.filter(ce=>!ce.parentId&&Tr(ce)&&ua(ce)===ua(_)),Q=_c(Z).slice(0,2);if(Q.length>1&&Q[0].id!==_.id)return null;if(Q.length>1){const ce=Ag(Q);return d.jsx("div",{"data-form-renderer":"shared-cell-stack",className:H("flex w-full min-w-0 gap-3",ce==="row"?"flex-row items-stretch":"flex-col"),children:Q.map(ye=>{const Ce=ye.name||ye.key||ye.id;return d.jsxs("div",{"data-field-name":Ce,"data-form-renderer":"field-wrapper",className:H("min-w-0 flex-1 flex flex-col",Qo(ye)),style:On(ye),children:[d.jsx(Sn,{field:ao(ye),value:Fe[Ce],error:st[Ce]||ct>0?ze[Ce]:void 0,onChange:Ue=>vt(Ce,Ue),onBlur:()=>er(Ce),disabled:(ye.type==="table"||ye.type==="billingGrid")&&a==="fill"?!1:Se||!lr(Ce)||qt,readOnly:(ye.type==="table"||ye.type==="billingGrid")&&a==="fill"?!1:cr(Ce,!!ye.readOnly),isRequired:Cn(Ce),formValues:Fe,submissionContext:ke,prepopulateMappedFieldNames:fe,urlParams:De,prepopulateResponse:me,prepopulateLoading:D,formSections:$t,submitPayload:$.config?.submitPayload,fieldValueKey:Ce,buttonResponses:z,onButtonApiResponse:jr,onSubmit:kr,onReset:Ye,onCancel:Qr,isSubmitting:ht,bffSubmitApi:L,onBffSubmitResult:g,extraSubmitPayload:Yt,onValidateForm:zr,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:lo,hideTableRowControls:x}),ye.type==="addmore"&&Ba(ye)]},ye.id)})},Q.map(ye=>ye.id).join("-"))}}if(_.type==="section"){const Z=$.fields.filter(Q=>Q.parentId===_.id&&Q.position!=null).sort((Q,ce)=>{const ye=typeof Q.position?.order=="number"?Q.position.order:0,Ce=typeof ce.position?.order=="number"?ce.position.order:0;return ye-Ce});return d.jsx(hy,{field:_,children:Z.map(Q=>{const ce=Q.name||Q.key||Q.id,ye=Q.hidden===!0;return fn(Q)&&($r(ce)||!ye&&ce)?d.jsxs("div",{"data-field-name":ce,"data-form-renderer":"field-wrapper",style:On(Q),children:[d.jsx(Sn,{field:ao(Q),value:Fe[ce],error:st[ce]||ct>0?ze[ce]:void 0,onChange:Ue=>vt(ce,Ue),onBlur:()=>er(ce),disabled:Se||!lr(ce)||qt,readOnly:cr(ce,!!Q.readOnly),isRequired:Cn(ce),formValues:Fe,submissionContext:ke,prepopulateMappedFieldNames:fe,urlParams:De,prepopulateResponse:me,prepopulateLoading:D,formSections:$t,submitPayload:$.config?.submitPayload,fieldValueKey:ce,buttonResponses:z,onButtonApiResponse:jr,onSubmit:kr,onReset:Ye,onCancel:Qr,isSubmitting:ht,bffSubmitApi:L,onBffSubmitResult:g,extraSubmitPayload:Yt,onValidateForm:zr,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:lo,hideTableRowControls:x}),Q.type==="addmore"&&Ba(Q)]},Q.id):null})},_.id)}const R=_.name||_.key||_.id;return d.jsxs("div",{"data-field-name":R,"data-form-renderer":"field-wrapper",style:On(_),children:[d.jsx(Sn,{field:ao(_),value:Fe[R],error:st[R]||ct>0?ze[R]:void 0,onChange:Z=>vt(R,Z),onBlur:()=>er(R),disabled:(_.type==="table"||_.type==="billingGrid")&&a==="fill"?!1:Se||!lr(R)||qt,readOnly:(_.type==="table"||_.type==="billingGrid")&&a==="fill"?!1:cr(R,!!_.readOnly),isRequired:Cn(R),formValues:Fe,submissionContext:ke,prepopulateMappedFieldNames:fe,urlParams:De,prepopulateResponse:me,prepopulateLoading:D,formSections:$t,submitPayload:$.config?.submitPayload,fieldValueKey:R,buttonResponses:z,onButtonApiResponse:jr,onSubmit:kr,onReset:Ye,onCancel:Qr,isSubmitting:ht,bffSubmitApi:L,onBffSubmitResult:g,extraSubmitPayload:Yt,onValidateForm:zr,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:lo,hideTableRowControls:x}),_.type==="addmore"&&Ba(_)]},_.id)})})}),u]})})]})});return P?d.jsx(Mg,{handlers:P,moduleId:T??"",submissionContext:p,getAuthHeaders:E,onParentWorkflowSubmitResult:g,children:ev}):ev};var Sa="Tabs",[VP]=Sr(Sa,[na]),rb=na(),[HP,md]=VP(Sa),nb=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,onValueChange:o,defaultValue:i,orientation:s="horizontal",dir:a,activationMode:c="automatic",...u}=e,f=bo(a),[l,p]=ln({prop:n,onChange:o,defaultProp:i??"",caller:Sa});return d.jsx(HP,{scope:r,baseId:hn(),value:l,onValueChange:p,orientation:s,dir:f,activationMode:c,children:d.jsx($e.div,{dir:f,"data-orientation":s,...u,ref:t})})});nb.displayName=Sa;var ob="TabsList",ib=b.forwardRef((e,t)=>{const{__scopeTabs:r,loop:n=!0,...o}=e,i=md(ob,r),s=rb(r);return d.jsx(Bh,{asChild:!0,...s,orientation:i.orientation,dir:i.dir,loop:n,children:d.jsx($e.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});ib.displayName=ob;var sb="TabsTrigger",ab=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,disabled:o=!1,...i}=e,s=md(sb,r),a=rb(r),c=db(s.baseId,n),u=ub(s.baseId,n),f=n===s.value;return d.jsx($h,{asChild:!0,...a,focusable:!o,active:f,children:d.jsx($e.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":u,"data-state":f?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:c,...i,ref:t,onMouseDown:Ie(e.onMouseDown,l=>{!o&&l.button===0&&l.ctrlKey===!1?s.onValueChange(n):l.preventDefault()}),onKeyDown:Ie(e.onKeyDown,l=>{[" ","Enter"].includes(l.key)&&s.onValueChange(n)}),onFocus:Ie(e.onFocus,()=>{const l=s.activationMode!=="manual";!f&&!o&&l&&s.onValueChange(n)})})})});ab.displayName=sb;var lb="TabsContent",cb=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,forceMount:o,children:i,...s}=e,a=md(lb,r),c=db(a.baseId,n),u=ub(a.baseId,n),f=n===a.value,l=b.useRef(f);return b.useEffect(()=>{const p=requestAnimationFrame(()=>l.current=!1);return()=>cancelAnimationFrame(p)},[]),d.jsx(Cr,{present:o||f,children:({present:p})=>d.jsx($e.div,{"data-state":f?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":c,hidden:!p,id:u,tabIndex:0,...s,ref:t,style:{...e.style,animationDuration:l.current?"0s":void 0},children:p&&i})})});cb.displayName=lb;function db(e,t){return`${e}-trigger-${t}`}function ub(e,t){return`${e}-content-${t}`}var WP=nb,RP=ib,KP=ab,GP=cb;function fb({className:e,...t}){return d.jsx(WP,{"data-slot":"tabs",className:H("flex flex-col gap-2",e),...t})}function hd({className:e,...t}){return d.jsx(RP,{"data-slot":"tabs-list",className:H("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",e),...t})}function gd({className:e,...t}){return d.jsx(KP,{"data-slot":"tabs-trigger",className:H("data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...t})}function pb({className:e,...t}){return d.jsx(GP,{"data-slot":"tabs-content",className:H("flex-1 outline-none",e),...t})}const qP="w-full justify-start border-b rounded-none h-auto p-0 bg-transparent gap-0",YP="rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:shadow-none",XP=({steps:e,position:t,sidebarWidth:r,sticky:n=!0,stickyOffset:o="1rem",sidebarMaxHeight:i="calc(100vh - 6rem)"})=>{if(t==="top")return d.jsx(hd,{className:qP,"data-form-renderer":"workflow-tabs",children:e.map(c=>d.jsx(gd,{value:c.step_id,className:YP,"data-form-renderer":"workflow-tab",children:c.step_name},c.step_id))});const s=t==="left"||t==="right",a=s?{...r?{width:r,flexShrink:0}:{},...n?{top:o}:{},maxHeight:i}:void 0;return d.jsx(hd,{className:H("bg-transparent p-0 gap-0 rounded-none h-auto",s?H("flex flex-col items-stretch shrink-0 self-start z-10 bg-background overflow-y-auto",n&&"sticky",t==="left"?"border-r pr-2":"border-l pl-2",!r&&"w-56"):H("w-full justify-start",t==="bottom"?"border-t pt-0":"border-b")),style:a,"data-form-renderer":"workflow-tabs","data-form-renderer-nav-position":t,children:e.map(c=>d.jsx(gd,{value:c.step_id,className:H("rounded-none shadow-none data-[state=active]:shadow-none text-sm",s?H("justify-start w-full px-3 py-2.5 border-b-0",t==="left"?"border-l-2 border-transparent data-[state=active]:border-primary":"border-r-2 border-transparent data-[state=active]:border-primary"):H("border-b-2 border-transparent data-[state=active]:border-primary",t==="bottom"&&"border-t-2 border-b-0 data-[state=active]:border-t-primary")),"data-form-renderer":"workflow-tab",children:c.step_name},c.step_id))})},JP=new Set(["top","bottom","left","right"]),Bi={position:"top",sticky:!0,stickyOffset:"1rem",sidebarMaxHeight:"calc(100vh - 6rem)"};function mb(e){return typeof e=="string"&&JP.has(e)}function QP(...e){for(const t of e){const r=t?.ui_config?.stepsNavigation;if(r&&typeof r=="object")return r}}function yd(...e){for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function bd(e={},...t){const r=QP(...t),n=(e.position&&mb(e.position)?e.position:void 0)??(r?.position&&mb(r.position)?r.position:Bi.position),o=yd(e.sidebarWidth,r?.sidebarWidth),i=typeof e.sticky=="boolean"?e.sticky:typeof r?.sticky=="boolean"?r.sticky:Bi.sticky,s=yd(e.stickyOffset,r?.stickyOffset)??Bi.stickyOffset,a=yd(e.sidebarMaxHeight,r?.sidebarMaxHeight)??Bi.sidebarMaxHeight;return{position:n,sidebarWidth:o,sticky:i,stickyOffset:s,sidebarMaxHeight:a}}function ZP(e,...t){return bd({position:e},...t).position}function eO(e){return e==="left"||e==="right"}function Pt({className:e="",...t}){return d.jsx("div",{"data-slot":"skeleton","data-form-renderer":"skeleton",className:`animate-pulse rounded-md bg-neutral-200 dark:bg-neutral-700 ${e}`.trim(),...t})}function tO({className:e="",position:t="top"}){if(t==="left"||t==="right")return d.jsxs("div",{className:`flex gap-4 ${t==="right"?"flex-row-reverse":"flex-row"} ${e}`.trim(),"data-form-renderer":"workflow-steps-view-skeleton",children:[d.jsxs("div",{className:`flex w-56 shrink-0 flex-col gap-1 border-neutral-200 dark:border-neutral-700 py-1 ${t==="left"?"border-r pr-2":"border-l pl-2"}`,children:[d.jsx(Pt,{className:"h-10 w-full rounded-none"}),d.jsx(Pt,{className:"h-10 w-full rounded-none"}),d.jsx(Pt,{className:"h-10 w-full rounded-none"})]}),d.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-4 py-4",children:[d.jsx(Pt,{className:"h-4 w-32"}),d.jsx(Pt,{className:"h-10 w-full"}),d.jsx(Pt,{className:"h-4 w-40"}),d.jsx(Pt,{className:"h-10 w-full"}),d.jsx(Pt,{className:"h-24 w-full"})]})]});const n=d.jsxs("div",{className:`flex w-full gap-0 ${t==="bottom"?"border-t border-neutral-200 pt-0 dark:border-neutral-700":"border-b border-neutral-200 dark:border-neutral-700"}`,children:[d.jsx(Pt,{className:"h-10 w-24 rounded-none"}),d.jsx(Pt,{className:"h-10 w-28 rounded-none ml-1"}),d.jsx(Pt,{className:"h-10 w-20 rounded-none ml-1"})]}),o=d.jsxs("div",{className:"flex flex-col gap-4 py-4",children:[d.jsx(Pt,{className:"h-4 w-32"}),d.jsx(Pt,{className:"h-10 w-full"}),d.jsx(Pt,{className:"h-4 w-40"}),d.jsx(Pt,{className:"h-10 w-full"}),d.jsx(Pt,{className:"h-4 w-36"}),d.jsx(Pt,{className:"h-24 w-full"})]});return d.jsx("div",{className:`flex flex-col gap-4 ${e}`.trim(),"data-form-renderer":"workflow-steps-view-skeleton",children:t==="bottom"?d.jsxs(d.Fragment,{children:[o,n]}):d.jsxs(d.Fragment,{children:[n,d.jsx("div",{className:"mt-4",children:o})]})})}function rO(){return d.jsxs("div",{className:"flex flex-col gap-4 py-4","data-form-renderer":"form-loading-skeleton",children:[d.jsx(Pt,{className:"h-4 w-28"}),d.jsx(Pt,{className:"h-10 w-full"}),d.jsx(Pt,{className:"h-4 w-36"}),d.jsx(Pt,{className:"h-10 w-full"}),d.jsx(Pt,{className:"h-4 w-24"}),d.jsx(Pt,{className:"h-20 w-full"})]})}const nO=3e4,oO=10*6e4,iO=9e4,sO=15*6e4;function aO(e){return e!=null&&"on_success"in e&&e.on_success!=null}function lO(e,t){if(!t||typeof t!="object")return e;let r=e;return Object.entries(t).forEach(([n,o])=>{o!=null&&o!==""&&(r=r.replace(new RegExp(`\\{${n}\\}`,"g"),String(o)))}),r}const hb=({getWorkflowState:e,moduleId:t,tenantId:r,submissionContext:n,initialValues:o={},getAuthHeaders:i,onSuccess:s,bootstrapFeatureId:a,subjectUserId:c,viewStepId:u,clientId:f,className:l,onWorkflowSubmitResult:p,viewerContext:g,getViewerContext:m,dark:h=!1,themeVars:y,stepsNavigationPosition:S,stepsNavigationSidebarWidth:v,stepsNavigationSticky:A,stepsNavigationStickyOffset:x,stepsNavigationSidebarMaxHeight:F,workflowModalHandlers:N})=>{const k=kn.useQueryClient(),T=w.useMemo(()=>[c??"",u??"",f??""],[c,u,f]),P=w.useMemo(()=>({moduleId:t,tenantId:r,subjectUserId:c,viewStepId:u,clientId:f}),[t,r,c,u,f]),[E,C]=w.useState([]),[I,W]=w.useState(null),[M,U]=w.useState(null),[V,X]=w.useState(null),[B,L]=w.useState({}),D=w.useRef(null),K=w.useRef(null),ae=w.useRef(null),j=w.useRef(null),z=w.useMemo(()=>E&&Array.isArray(E)?E.filter(he=>he.feature_id):[],[E]),le=kn.useQuery({queryKey:["workflow-steps",t,a??"",r??"",T[0],T[1],T[2]],queryFn:()=>e({...P,featureId:a}),staleTime:nO,gcTime:oO}),ie=le.isPending,G=le.error?le.error instanceof Error?le.error.message:"Failed to load workflow steps":null;w.useEffect(()=>{const he=le.data;if(!he||E.length>0)return;const we=he.steps&&Array.isArray(he.steps)?he.steps:[];C(we);const J=we.filter($=>$.feature_id);if(J.length>0){const $=he.current_step_id,fe=$&&J.some(Ve=>Ve.step_id===$);W(fe?$:J[0].step_id)}},[le.data,E.length,a]);const ee=w.useMemo(()=>{if(!I)return;const he=E.find(J=>J.step_id===I),we=D.current===I;return he?.feature_id??(we?j.current:void 0)??void 0},[I,E]),Ae=kn.useQuery({queryKey:["workflow-step",t,ee??"",r??"",T[0],T[1],T[2]],queryFn:()=>e({...P,featureId:ee}),enabled:!!ee,staleTime:iO,gcTime:sO,refetchOnWindowFocus:!0,refetchOnReconnect:!0}),te=Ae.isPending,oe=Ae.error?Ae.error instanceof Error?Ae.error.message:"Failed to load form":null,me=w.useMemo(()=>bd({position:S,sidebarWidth:v,sticky:A,stickyOffset:x,sidebarMaxHeight:F},M,le.data),[S,v,A,x,F,M,le.data]),Me=me.position,De=eO(Me);w.useEffect(()=>{!Ae.data||D.current===I||(U(Ae.data),X(null),D.current=null,j.current=null)},[Ae.data,I]),w.useEffect(()=>{X(oe)},[oe]),w.useEffect(()=>{ee===void 0&&D.current!==I&&(U(null),X(null),D.current=null,j.current=null)},[ee,I]);const ne=w.useMemo(()=>{const he=M?.form;if(!he)return null;const we=(r??nn()??"").trim()||"default",J=Zy({scope:we,formId:he._id,version:he.version});return J?.value?J.value:Fg(M,n)},[M,n,r]),ge=w.useMemo(()=>{const he=M?.BFF_submit_api;if(!he?.url)return;let we=he.url;if(we.startsWith("http://")||we.startsWith("https://"))try{const fe=new URL(we);we=fe.pathname+fe.search}catch{}const J=i?.()??{},$={...he.headers||{},"Content-Type":"application/json",...J};return{...he,url:we,headers:$}},[M?.BFF_submit_api,i]),Se=w.useMemo(()=>ne?{...ne,status:"published",...ge&&{BFF_submit_api:ge}}:null,[ne,ge]);w.useEffect(()=>{if(!ne?.id)return;const he=(r??nn()??"").trim()||"default";eb({scope:he,formId:ne.id,version:ne.version},ne)},[ne,r]);const yt=w.useMemo(()=>{if(!ne)return null;const he=Ki({config:ne.config,layout:ne.layout},null);if(!he)return null;const we=he.rows,J=he.columns,$={verticalSpacing:he.verticalSpacing??he.spacing??"16px",horizontalSpacing:he.horizontalSpacing??he.spacing??"16px",rowHeight:he.rowHeight??Hn};let fe=1;if(Array.isArray(ne.fields))for(const Fe of ne.fields){const ze=Fe?.position,st=typeof ze?.order=="number"?ze.order:0,ht=typeof ze?.rowSpan=="number"?ze.rowSpan:1;fe=Math.max(fe,st+ht)}return{rows:Math.min(we,Math.max(1,fe)),columns:J,verticalSpacing:$.verticalSpacing,horizontalSpacing:$.horizontalSpacing,rowHeight:$.rowHeight}},[ne]),Nt=w.useMemo(()=>{const we=Se?.config?.theme?.cssVariables;if(!(!we&&!y))return{...we??{},...y??{}}},[Se?.config,y]),Ut=w.useCallback(()=>{k.invalidateQueries({queryKey:["workflow-steps",t]}),k.invalidateQueries({queryKey:["workflow-step",t]})},[k,t]),Ot=w.useCallback(he=>{if(aO(he)){const fe=he.on_success,Ve=fe?.action;if(Ve==="redirect"&&fe?.redirect_url){const Fe=lO(fe.redirect_url.trim(),n);window.location.href=Fe;return}if(Ve==="move"){const Fe=fe?.next_step_id,ze=fe?.next_step_form;if(Fe&&ze){D.current=null,j.current=null;const st=ze.featureId??fe?.next_step_form_id??ze._id;k.removeQueries({queryKey:["workflow-step",t,st,r??"",T[0],T[1],T[2]]}),Ut(),C(ht=>ht.some(ct=>ct.step_id===Fe)?ht:[...ht,{step_id:Fe,step_name:ze.name||"Next step",feature_id:st}]),U(null),W(Fe),s?.();return}return}if(Ve==="stay"){Ut(),s?.();return}}const we=he;we.steps&&Array.isArray(we.steps)&&C(we.steps);const J=(we.steps&&Array.isArray(we.steps)?we.steps:E).filter(fe=>fe.feature_id),$=we.current_step_id;$&&J.some(fe=>fe.step_id===$)?W($):J.length>0&&W(J[0].step_id),U(null),Ut(),s?.(),p?.(we)},[k,t,r,s,p,E,n,T,Ut]),Er=w.useCallback(async he=>M?.BFF_submit_api?(s?.(),{success:!0,message:"Saved successfully"}):{success:!1,message:"Submit not configured"},[M?.BFF_submit_api,s]),Dt=w.useCallback((he,we)=>{},[]),sr=w.useCallback(he=>{},[]);if(ie)return d.jsx(tO,{className:l,position:S??me.position});if(G)return d.jsx("div",{className:H("rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",l),children:G});if(z.length===0)return d.jsx("div",{className:H("py-12 text-center text-sm text-muted-foreground",l),children:"No workflow steps configured."});const Vt=M?.step_blocked_message;return d.jsx("div",{className:H(za,h&&"dark","flex flex-col gap-4",l),style:Nt,"data-form-renderer":"workflow-steps-view",children:d.jsxs(fb,{value:I??"",onValueChange:he=>W(he),className:H(Me!=="top"&&"gap-4",De&&"flex-row items-start",Me==="right"&&"flex-row-reverse",Me==="bottom"&&"flex-col-reverse"),orientation:De?"vertical":"horizontal",children:[d.jsx(XP,{steps:z,position:Me,sidebarWidth:me.sidebarWidth,sticky:me.sticky,stickyOffset:me.stickyOffset,sidebarMaxHeight:me.sidebarMaxHeight}),z.map(he=>d.jsx(pb,{value:he.step_id,className:H("outline-none",De?"mt-0 flex-1 min-w-0":"mt-4"),children:he.step_id!==I?null:te?d.jsx(rO,{}):V?d.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:V}):Vt&&!M?.form?d.jsx("div",{className:H("rounded-lg border border-amber-500/50 bg-amber-500/10 px-4 py-3 text-sm text-amber-800 dark:text-amber-200",l),"data-form-renderer":"workflow-step-blocked",children:Vt}):Se?.fields?.length?d.jsxs("div",{className:"py-4 [&_*]:box-border",children:[Vt?d.jsx("div",{className:H("mb-4 rounded-lg border border-amber-500/50 bg-amber-500/10 px-4 py-3 text-sm text-amber-800 dark:text-amber-200"),"data-form-renderer":"workflow-step-blocked",children:Vt}):null,(()=>{const we=K.current!==I||ae.current!==(Se?.id??null);if(I&&Se&&we){K.current=I,ae.current=Se.id??null;const J=Gn.getState();J.setSchema(Se,{forceReset:!0});const $=Gn.getState().values;J.setValues({...$,...o})}return null})(),d.jsx(Di,{schema:Se,gridLayout:yt,omitRootWrapper:!0,moduleId:t,workflowModalHandlers:N,getAuthHeaders:i,submissionContext:n,initialValues:o,workflowStepId:I??void 0,viewerContext:g,getViewerContext:m,onSubmit:Er,onChange:Dt,onValidationError:sr,onClose:()=>{},mode:"fill",unstyled:!0,onWorkflowSubmitResult:Ot,initialExtraSubmitPayload:Object.keys(B).length>0?B:void 0,onExtraSubmitPayloadChange:we=>{if(we&&typeof we=="object"){const J={};we.context_user_id!=null&&(J.context_user_id=we.context_user_id),we.id!=null&&(J.id=we.id),we.batch_id!=null&&(J.batch_id=we.batch_id),we.admission_batch_id!=null&&(J.admission_batch_id=we.admission_batch_id),we.program_id!=null&&(J.program_id=we.program_id),Object.keys(J).length>0&&L($=>({...$,...J}))}}},Se.id)]}):d.jsx("div",{className:"py-8 text-center text-sm text-muted-foreground",children:"No form schema available for this step."})},he.step_id))]})})},xa=new Map;function cO(e){if(e){xa.delete(e);return}xa.clear()}async function Aa(e,t,r){const n=xa.get(t);if(n!==void 0)return n;const o=e.replace(/\/$/,""),s=!!(await Jt.get(`${o}/${encodeURIComponent(t)}/meta`,{headers:r})).data?.standalone_workflow;return xa.set(t,s),s}function Ca(e){const t={...e.getAuthHeaders?.()??{}};return e.clientId&&(t["x-client-id"]=e.clientId),e.userId&&(t["x-user-id"]=e.userId),t}function vd(e,t){Object.entries(t).forEach(([r,n])=>{n&&e.set(r,n)})}function gb(e){const t=e.bffWorkflowsBasePath.replace(/\/$/,""),r=()=>Ca({getAuthHeaders:e.getAuthHeaders,clientId:e.clientId,userId:e.userId}),n=o=>o?.trim()||e.moduleId?.trim()||"";return{async getWorkflowStateById({workflowId:o,moduleId:i,entryStepId:s}){const a=o.trim(),c=r();if(await Aa(t,a,c)){const p=new URLSearchParams;e.clientId&&p.set("client_id",e.clientId),e.userId&&p.set("user_id",e.userId),vd(p,{entry_step_id:s});const g=p.toString();return(await Jt.get(`${t}/${encodeURIComponent(a)}/standalone-state${g?`?${g}`:""}`,{headers:c})).data}const f=new URLSearchParams;return f.set("module_id",n(i)),e.clientId&&f.set("client_id",e.clientId),e.userId&&f.set("user_id",e.userId),vd(f,{entry_step_id:s}),(await Jt.get(`${t}/${encodeURIComponent(a)}/state?${f.toString()}`,{headers:c})).data},async navigateWorkflowStep({workflowId:o,moduleId:i,targetStepId:s}){const a=o.trim(),c=r();if(await Aa(t,a,c))return(await Jt.post(`${t}/${encodeURIComponent(a)}/standalone-navigate-step`,{workflow_id:a,target_step_id:s},{headers:c})).data;const f=n(i);return(await Jt.post(`${t}/modules/${encodeURIComponent(f)}/navigate-step`,{workflow_id:a,target_step_id:s},{headers:c})).data}}}async function yb(e){const t=e.bffWorkflowsBasePath.replace(/\/$/,""),r=Ca({getAuthHeaders:e.getAuthHeaders,clientId:e.clientId,userId:e.subjectUserId});if(e.workflowId?.trim()){const s=e.workflowId.trim();if(await Aa(t,s,r)){const c=new URLSearchParams;e.clientId&&c.set("client_id",e.clientId),e.subjectUserId&&c.set("user_id",e.subjectUserId),vd(c,{step_id:e.viewStepId});const u=c.toString();return(await Jt.get(`${t}/${encodeURIComponent(s)}/standalone-state${u?`?${u}`:""}`,{headers:r})).data}}const n=new URLSearchParams;n.set("module_id",e.moduleId),e.featureId&&n.set("feature_id",e.featureId),e.tenantId&&n.set("tenant_id",e.tenantId),e.subjectUserId&&n.set("user_id",e.subjectUserId),e.viewStepId&&n.set("step_id",e.viewStepId),e.clientId&&n.set("client_id",e.clientId);const o=e.workflowId?.trim()?`${t}/${encodeURIComponent(e.workflowId.trim())}/state?${n.toString()}`:`${t}/modules/${encodeURIComponent(e.moduleId)}/state?${n.toString()}`;return(await Jt.get(o,{headers:r})).data}function dO(e){return typeof e=="object"&&e!==null&&"apiEndpoint"in e}function uO({formSchema:e}){const t=w.useMemo(()=>{if(!e)return[];const i=[];(!e.name||e.name.trim()==="")&&i.push({id:"form-name-required",type:"error",message:"Form name is required"});const s=new Set,a=new Set;e.fields.forEach((f,l)=>{const p=`field-${f.id}`;if(a.has(f.id)&&i.push({id:`${p}-duplicate-id`,type:"error",message:`Field "${f.label||f.name||`Field ${l+1}`}" has a duplicate ID`,fieldId:f.id}),a.add(f.id),f.name&&s.has(f.name)&&i.push({id:`${p}-duplicate-name`,type:"error",message:`Field "${f.label||f.name}" has a duplicate name: "${f.name}"`,fieldId:f.id}),f.name&&s.add(f.name),(!f.label||f.label.trim()==="")&&i.push({id:`${p}-missing-label`,type:"warning",message:`Field "${f.name||f.id}" is missing a label`,fieldId:f.id}),(!f.name||f.name.trim()==="")&&i.push({id:`${p}-missing-name`,type:"error",message:`Field "${f.label||f.id}" is missing a field name`,fieldId:f.id}),f.name&&!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(f.name)&&i.push({id:`${p}-invalid-name`,type:"error",message:`Field "${f.label||f.name}" has an invalid name. Use only letters, numbers, and underscores.`,fieldId:f.id}),["select","multiselect","radio","checkboxgroup"].includes(f.type)){const h=f.properties;(!h?.options||h.options.length===0)&&i.push({id:`${p}-no-options`,type:"warning",message:`Field "${f.label||f.name}" has no options defined`,fieldId:f.id})}f.parentId&&(e.fields.some(y=>y.id===f.parentId)||i.push({id:`${p}-orphaned`,type:"error",message:`Field "${f.label||f.name}" references a non-existent parent`,fieldId:f.id}));const m=(h,y)=>{if(y.has(h))return!0;y.add(h);const S=e.fields.find(v=>v.id===h);return S?.parentId?m(S.parentId,y):!1};f.parentId&&m(f.id,new Set)&&i.push({id:`${p}-circular-reference`,type:"error",message:`Field "${f.label||f.name}" has a circular parent reference`,fieldId:f.id})}),e.config.workflowTrigger?.workflowId&&(e.fields.some(l=>l.validation?.some(p=>p.type==="required"))||i.push({id:"workflow-no-required-fields",type:"info",message:"Form linked to workflow but has no required fields"}));const c=e.fields.filter(f=>!f.parentId),u=new Map;return c.forEach(f=>{const l=f.position.order;u.has(l)||u.set(l,[]),u.get(l).push(f)}),u.forEach((f,l)=>{f.length>3&&i.push({id:`row-${l}-too-many-fields`,type:"warning",message:`Row ${l+1} has ${f.length} fields (maximum recommended is 3)`})}),i},[e]),r=w.useMemo(()=>t.filter(i=>i.type==="error"),[t]),n=w.useMemo(()=>t.filter(i=>i.type==="warning"),[t]),o=w.useMemo(()=>r.length===0,[r]);return{issues:t,errors:r,warnings:n,isValid:o}}function fO({field:e,value:t,allValues:r,validateOnChange:n=!1,validateOnBlur:o=!0,debounceMs:i=cP}){const[s,a]=w.useState(),[c,u]=w.useState(!1),f=w.useRef(void 0),l=w.useRef(t),p=w.useCallback(async()=>{if(!e.validation||e.validation.length===0){a(void 0);return}u(!0);let S;for(const v of e.validation){const A=rn(t,v,r);if(typeof A=="string"){S=A;break}}return a(S),u(!1),S},[e.validation,t,r]),g=w.useCallback(()=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{p()},i)},[p,i]);w.useEffect(()=>(n&&l.current!==t&&g(),l.current=t,()=>{f.current&&clearTimeout(f.current)}),[t,n,g]);const m=w.useCallback(()=>{o&&p()},[o,p]),h=w.useCallback(()=>{a(void 0)},[]),y=w.useCallback(S=>{a(S)},[]);return{error:s,isValidating:c,validate:p,handleBlur:m,clearError:h,setCustomError:y}}const bb="—";function Zt(){return{kind:"static",value:bb}}function pO(){return Lu({currencySymbol:"₹",emptyDisplay:bb,columns:[{id:"col_tariff",key:"tariff_type",label:"Tariff type",format:"text",align:"left"},{id:"col_service",key:"service",label:"Service",format:"text",align:"left"},{id:"col_unit",key:"unit_price",label:"Unit price",format:"currency",align:"right"},{id:"col_disc_pct",key:"discount_pct",label:"Discount (%)",format:"percent",align:"right"},{id:"col_disc_amt",key:"discount_amount",label:"Discount (₹)",format:"currency",align:"right"},{id:"col_net",key:"net_price",label:"Net price",format:"currency",align:"right"},{id:"col_tax",key:"tax_pct",label:"Tax (%)",format:"percent",align:"right"},{id:"col_total",key:"total",label:"Total",format:"currency",align:"right"}],rowSlots:[{kind:"static",row:{id:"registration_fee",label:"Registration fee",cells:{tariff_type:{kind:"label"},service:Zt(),unit_price:{kind:"api",path:"unit_price"},discount_pct:{kind:"input",inputType:"number"},discount_amount:{kind:"formula",expression:"cell('unit_price') * cell('discount_pct') / 100"},net_price:{kind:"formula",expression:"cell('unit_price') - cell('discount_amount')"},tax_pct:{kind:"api",path:"tax_pct"},total:{kind:"formula",expression:"cell('net_price') * (1 + cell('tax_pct') / 100)"}}}},{kind:"dynamic",block:{id:"line_items",apiArrayPath:"items",rowIdField:"id",cells:{tariff_type:Zt(),service:{kind:"api",path:"service"},unit_price:{kind:"api",path:"unit_price"},discount_pct:Zt(),discount_amount:{kind:"formula",expression:"cell('unit_price') * cell('discount_pct') / 100"},net_price:{kind:"formula",expression:"cell('unit_price') - cell('discount_amount')"},tax_pct:{kind:"api",path:"tax_pct"},total:{kind:"formula",expression:"cell('net_price') * (1 + cell('tax_pct') / 100)"}}}},{kind:"static",row:{id:"all_items_summary",label:"All items summary",cells:{tariff_type:{kind:"label"},service:Zt(),unit_price:{kind:"formula",expression:"SUM('unit_price', 'data')"},discount_pct:Zt(),discount_amount:{kind:"formula",expression:"SUM('discount_amount', 'data')"},net_price:{kind:"formula",expression:"SUM('net_price', 'data')"},tax_pct:Zt(),total:{kind:"formula",expression:"SUM('total', 'data')"}}}},{kind:"static",row:{id:"invoice_discount",label:"Invoice discount",cells:{tariff_type:{kind:"label"},service:Zt(),unit_price:Zt(),discount_pct:Zt(),discount_amount:{kind:"input",inputType:"number"},net_price:Zt(),tax_pct:Zt(),total:Zt()}}},{kind:"static",row:{id:"grand_total",label:"Grand total",cells:{tariff_type:{kind:"label"},service:Zt(),unit_price:Zt(),discount_pct:Zt(),discount_amount:Zt(),net_price:Zt(),tax_pct:Zt(),total:{kind:"formula",expression:"SUM('total', 'data') - cellInRow('invoice_discount', 'discount_amount')"}}}}]})}const mO={text:{type:"text",label:"Text Input",icon:"Type",category:"input",description:"Single line text input",defaultProps:{label:"Text Field",name:"text_field",placeholder:"Enter text..."}},number:{type:"number",label:"Number Input",icon:"Hash",category:"input",description:"Numeric input with optional constraints",defaultProps:{label:"Number Field",name:"number_field",placeholder:"0",properties:{min:0,step:1}}},email:{type:"email",label:"Email",icon:"Mail",category:"input",description:"Email address input with validation",defaultProps:{label:"Email",name:"email_field",placeholder:"example@domain.com",validation:[{type:"email"}]}},phone:{type:"phone",label:"Phone",icon:"Phone",category:"input",description:"Phone number input",defaultProps:{label:"Phone Number",name:"phone_field",placeholder:"+91 12345 67890"}},otp:{type:"otp",label:"OTP",icon:"ShieldCheck",category:"input",description:"One-time password with separate digit boxes",defaultProps:{label:"OTP",name:"otp_field",properties:{otpLength:4,numericOnly:!0},validation:[{type:"required",message:"Please enter the OTP"}]}},password:{type:"password",label:"Password",icon:"Lock",category:"input",description:"Secure password input",defaultProps:{label:"Password",name:"password_field",placeholder:"••••••••"}},url:{type:"url",label:"URL",icon:"Link",category:"input",description:"URL input with validation",defaultProps:{label:"URL",name:"url_field",placeholder:"https://example.com",validation:[{type:"url"}]}},date:{type:"date",label:"Date",icon:"Calendar",category:"datetime",description:"Date picker",defaultProps:{label:"Date",name:"date_field",placeholder:"Select date"}},time:{type:"time",label:"Time",icon:"Clock",category:"datetime",description:"Time picker",defaultProps:{label:"Time",name:"time_field",placeholder:"Select time"}},datetime:{type:"datetime",label:"Date & Time",icon:"CalendarClock",category:"datetime",description:"Combined date and time picker",defaultProps:{label:"Date & Time",name:"datetime_field",placeholder:"Select date and time"}},daterange:{type:"daterange",label:"Date Range",icon:"CalendarRange",category:"datetime",description:"Select a range of dates",defaultProps:{label:"Date Range",name:"daterange_field",placeholder:"Select date range"}},select:{type:"select",label:"Dropdown",icon:"ChevronDown",category:"selection",description:"Single selection dropdown",defaultProps:{label:"Select",name:"select_field",placeholder:"Select an option",properties:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}],searchable:!0,clearable:!0}}},multiselect:{type:"multiselect",label:"Multi Select",icon:"ListChecks",category:"selection",description:"Multiple selection dropdown",defaultProps:{label:"Multi Select",name:"multiselect_field",placeholder:"Select options",properties:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}],searchable:!0}}},radio:{type:"radio",label:"Radio Group",icon:"CircleDot",category:"selection",description:"Single selection radio buttons",defaultProps:{label:"Radio Group",name:"radio_field",properties:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}]}}},checkbox:{type:"checkbox",label:"Checkbox",icon:"CheckSquare",category:"selection",description:"Single checkbox for boolean values",defaultProps:{label:"I agree to the terms",name:"checkbox_field"}},toggle:{type:"toggle",label:"Toggle",icon:"ToggleLeft",category:"selection",description:"Toggle switch with configurable text values",defaultProps:{label:"Toggle",name:"toggle_field",description:"Toggle to switch between states",properties:{onValue:"On",offValue:"Off"}}},checkboxgroup:{type:"checkboxgroup",label:"Checkbox Group",icon:"CheckSquare",category:"selection",description:"Multiple checkboxes for selecting multiple values",defaultProps:{label:"Checkbox Group",name:"checkboxgroup_field",properties:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}]}}},selectablelist:{type:"selectablelist",label:"Selectable List",icon:"ListChecks",category:"selection",description:"List from response or context; select all or specific items. Value = selected array.",defaultProps:{label:"Recipients",name:"recipients",properties:{dataSourceContextKey:"recipients",labelField:"name",valueField:"email",showSelectAll:!0,selectAllByDefault:!0}}},asyncsearch:{type:"asyncsearch",label:"Async Search",icon:"Search",category:"selection",description:"Typeahead search against an API; submitted value is the selected option value.",defaultProps:{label:"Search",name:"async_search",placeholder:"Type to search…",properties:{apiEndpoint:"/api/form-builder/search",apiMethod:"GET",searchQueryParam:"q",searchSchedule:"debounce",intervalMs:300,minQueryLength:0,clearable:!0}}},terms:{type:"terms",label:"Terms & Conditions",icon:"FileText",category:"special",description:"Terms and conditions confirmation checkbox",defaultProps:{label:"I confirm that the details are true to my knowledge",name:"terms_conditions",validation:[{type:"required"}]}},textarea:{type:"textarea",label:"Text Area",icon:"AlignLeft",category:"rich",description:"Multi-line text input",defaultProps:{label:"Text Area",name:"textarea_field",placeholder:"Enter your text here...",properties:{minLength:0,maxLength:1e3}}},richtext:{type:"richtext",label:"Rich Text",icon:"FileText",category:"rich",description:"Rich text editor with formatting",defaultProps:{label:"Rich Text",name:"richtext_field"}},file:{type:"file",label:"File Upload",icon:"Upload",category:"rich",description:"File upload with drag and drop",defaultProps:{label:"File Upload",name:"file_field",properties:{accept:["image/*","application/pdf"],maxSize:5*1024*1024}}},camera:{type:"camera",label:"Use camera",icon:"Camera",category:"rich",description:"Take a photo with your camera",defaultProps:{label:"Take photo",name:"camera_field",properties:{accept:["image/*"],maxSize:5*1024*1024,multiple:!1}}},photoChoice:{type:"photoChoice",label:"Photo (upload or camera)",icon:"ImagePlus",category:"rich",description:"Upload a file or capture with the camera",defaultProps:{label:"Photo",name:"photo_choice_field",properties:{accept:["image/*"],maxSize:5*1024*1024,maxFiles:1}}},signature:{type:"signature",label:"Signature",icon:"Pencil",category:"rich",description:"Digital signature capture",defaultProps:{label:"Signature",name:"signature_field"}},rating:{type:"rating",label:"Rating",icon:"Star",category:"rich",description:"Star rating input",defaultProps:{label:"Rating",name:"rating_field",properties:{max:5,allowHalf:!1,icon:"star"}}},slider:{type:"slider",label:"Slider",icon:"SlidersHorizontal",category:"rich",description:"Numeric slider input",defaultProps:{label:"Slider",name:"slider_field",properties:{min:0,max:100,step:1,showValue:!0}}},table:{type:"table",label:"Table",icon:"Table",category:"special",description:"Repeatable table rows",defaultProps:{label:"Table",name:"table_field",properties:{columns:[],minRows:1,maxRows:10,allowAddRow:!0,allowDeleteRow:!0}}},billingGrid:{type:"billingGrid",label:"Billing Grid",icon:"Receipt",category:"special",description:"Configurable billing/tariff grid with formulas and API line items",defaultProps:{label:"Billing",name:"billing",properties:pO()}},aadhaar:{type:"aadhaar",label:"Aadhaar",icon:"CreditCard",category:"special",description:"Indian Aadhaar number input",defaultProps:{label:"Aadhaar Number",name:"aadhaar_field",placeholder:"XXXX XXXX XXXX"}},section:{type:"section",label:"Section",icon:"LayoutPanelTop",category:"container",description:"Group fields in a collapsible section",defaultProps:{label:"Section",name:"section",properties:{collapsible:!0,defaultCollapsed:!1,columns:1}}},group:{type:"group",label:"Group",icon:"Group",category:"container",description:"Group fields without visual separator",defaultProps:{label:"Group",name:"group"}},columns:{type:"columns",label:"Columns",icon:"Columns",category:"container",description:"Multi-column layout",defaultProps:{label:"Columns",name:"columns",properties:{columns:2}}},divider:{type:"divider",label:"Divider",icon:"Minus",category:"visual",description:"Horizontal line separator",defaultProps:{label:"",name:"divider"}},header:{type:"header",label:"Header",icon:"Heading",category:"visual",description:"Section header text (full row, configurable size)",defaultProps:{label:"Header",name:"header",properties:{headingLevel:"h3",showHorizontalLine:!0}}},sectionHeading:{type:"sectionHeading",label:"Section Heading",icon:"Heading",category:"visual",description:"Heading inside a grid box with configurable position and size",defaultProps:{label:"Section Heading",name:"section_heading",properties:{position:"top-left",headingLevel:"h3",showHorizontalLine:!0}}},spacer:{type:"spacer",label:"Spacer",icon:"Space",category:"visual",description:"Empty space for padding",defaultProps:{label:"",name:"spacer"}},textLabel:{type:"textLabel",label:"Text Label",icon:"Tag",category:"visual",description:"Standalone label text (no input)",defaultProps:{label:"Label",name:"text_label"}},status:{type:"status",label:"Status",icon:"ListChecks",category:"visual",description:"Populate status from Status API; label + response key; true = completed",defaultProps:{label:"Admission Status",name:"status_field",properties:{source:"api",statuses:[{label:"Registered",key:"registered"},{label:"Form Submitted",key:"formSubmitted"},{label:"Documents Verification",key:"documentsVerification"},{label:"Photos Clicked",key:"photosClicked"},{label:"Fitness Verification",key:"fitnessVerification"},{label:"Payment Completed",key:"paymentCompleted"},{label:"Hostel Allotted",key:"hostelAllotted"},{label:"Admission Completed",key:"admissionCompleted"}],showStatusText:!1,statusTextPath:"admissionStatus",showCurrentIndicator:!0}}},button:{type:"button",label:"Button",icon:"MousePointerClick",category:"special",description:"Clickable button element",defaultProps:{label:"Button",name:"button_field",properties:{variant:"default",size:"default",action:"download"}}},editButton:{type:"editButton",label:"Edit Button",icon:"Pencil",category:"special",description:"Toggle edit mode: enable/disable or show/hide other fields and buttons (no API call)",defaultProps:{label:"Edit",name:"edit_button",properties:{buttonText:"Edit",variant:"outline",size:"default",hideLabel:!1,rules:[]}}},addmore:{type:"addmore",label:"Add More",icon:"Plus",category:"special",description:"Duplicate linked fields as a new runtime block",defaultProps:{label:"Add More",name:"addmore_field",properties:{linkedFieldNames:[],linkedSectionIds:[],variant:"outline",size:"default"}}},customizeSections:{type:"customizeSections",label:"Customise Sections",icon:"ListFilter",category:"special",description:"Show or hide UI sections defined by Section Heading fields",defaultProps:{label:"Customise Sections",name:"customize_sections",properties:{sectionHeadingNames:[],defaultHiddenSectionNames:[],variant:"outline",size:"default",buttonText:"Customise sections",menuTitle:"VISIBLE SECTIONS"}}}},vb={padding:"md",showBorder:!1};function wb(e,t){const r="full";return e?{padding:e.padding??vb.padding,maxWidth:e.maxWidth??r,showBorder:e.showBorder??vb.showBorder}:{padding:"md",maxWidth:r,showBorder:!1}}function hO(e){switch(e??"md"){case"none":return"";case"sm":return"p-3";case"lg":return"p-6 md:p-8";default:return"p-4 md:p-6"}}function gO(e,t){if(t==="full-bleed")return"w-full max-w-none";switch(e??"full"){case"full":return"w-full max-w-none";case"sm":return"mx-auto w-full max-w-screen-sm";case"md":return"mx-auto w-full max-w-screen-md";case"lg":return"mx-auto w-full max-w-screen-lg";case"xl":return"mx-auto w-full max-w-screen-xl";case"2xl":return"mx-auto w-full max-w-2xl";case"4xl":return"mx-auto w-full max-w-4xl";case"5xl":return"mx-auto w-full max-w-5xl";case"6xl":return"mx-auto w-full max-w-6xl";case"7xl":return"mx-auto w-full max-w-7xl";default:return"w-full max-w-none"}}function yO(e){switch(e){case"sidebar-main":return"grid grid-cols-1 gap-6 lg:grid-cols-[240px_1fr]";case"full-bleed":return"w-full";default:return"w-full"}}function bO(e){const t=wb(e.container,e.layout);return H(yO(e.layout),gO(t.maxWidth,e.layout),hO(t.padding),t.showBorder&&"rounded-lg border border-border")}const Ea=1;function vO(){return{version:Ea,layout:"stack",container:{padding:"md",maxWidth:"full",showBorder:!1},dataBindings:[],widgets:[],filterGroups:[]}}function Sb(e){return{...e,config:e.config??{},children:Array.isArray(e.children)?e.children.map(Sb):void 0}}function wO(e){return{version:Ea,layout:e.layout??"stack",container:wb(e.container,e.layout),meta:e.meta,dataBindings:Array.isArray(e.dataBindings)?e.dataBindings:[],dataApis:e.dataApis??{},prepopulateApi:e.prepopulateApi,widgets:Array.isArray(e.widgets)?e.widgets.map(Sb):[],filterGroups:Array.isArray(e.filterGroups)?e.filterGroups:[],eventHandlers:e.eventHandlers??[],navigation:e.navigation}}function SO(e){const t=e;return!t||typeof t!="object"?vO():(t.version!==Ea&&(t.version=Ea),wO(t))}const xb={};let Ab=null;function xO(e){Ab=e}function AO(){return(xb?.VITE_API_BASE_URL?.trim()||xb?.VITE_API_URL?.trim()||"").replace(/\/$/,"")}const $i=Ct.create({baseURL:AO()});$i.interceptors.request.use(e=>{const t=nn();t&&(e.params={...e.params,clientId:t}),typeof FormData<"u"&&e.data instanceof FormData&&delete e.headers["Content-Type"];let r=Ab?.();if((!r||Object.keys(r).length===0)&&(r=fi()),r){const n=e.headers??{};for(const[o,i]of Object.entries(r))i!==void 0&&i!==""&&(n[o]=i);e.headers=n}return e});async function Cb(e){const t=await $i.get("/api/page-builder/pages/resolve",{params:e}),r=t.data?.data??t.data;if(!r?.pageId)throw new Error("Page resolve failed: no pageId returned");return r}async function wd(e,t,r){const n=await $i.get(`/api/page-builder/pages/${e}/render`,{params:{clientId:t,...r!==void 0?{version:r}:{}}}),o=n.data?.data??n.data;if(!o?.schema)throw new Error("Page render failed: no schema returned");return o}async function Sd(e){const{clientId:t,api:r,context:n,filterState:o}=e,i=await $i.post(`/api/page-builder/clients/${t}/data-sources/execute`,{api:r,context:n,filterState:o});return i.data?.data??i.data}function CO(e,t){if(!t)return{};const r={};for(const[n,o]of Object.entries(t)){if(!o.trim())continue;const i=We(e,o);i!==void 0&&(r[n]=i)}return r}const xd=w.createContext(null);function EO(e,t){if(t.parentContext)return"idle";const r=e.prepopulateApi,n=String(t.clientIdProp??t.externalContext.clientId??"");return r?.enabled&&r.api?.path&&n?"loading":"idle"}function Eb(e,t){const r={};for(const n of e){let o;switch(n.source){case"route.param":o=n.param?t[n.param]:void 0;break;case"route.query":o=n.param?t[n.param]:void 0;break;case"context.user":o=n.param?t.user?.[n.param]:t.user;break;case"context.client":o=n.param?t.client?.[n.param]:t.client??t.clientId;break;case"context.tenant":o=n.param?t.tenant?.[n.param]:t.tenant??t.tenantId;break;case"static":o=n.value;break;case"widget.state":o=n.sample;break;default:o=void 0}o===void 0&&n.sample!==void 0&&(o=n.sample),o!==void 0&&(r[n.key]=o)}return r}function NO({schema:e,context:t={},clientId:r,nestingDepth:n=0,onAction:o,getWorkflowState:i,workflowModalHandlers:s,getAuthHeaders:a,parentContext:c,children:u}){const[f,l]=w.useState(()=>c?c.filterGroups:{}),p=w.useRef(f);p.current=f;const[g,m]=w.useState({}),[h,y]=w.useState(()=>EO(e,{parentContext:c,clientIdProp:r,externalContext:t})),S=w.useRef(null),v=String(r??t.clientId??c?.clientId??""),A=JSON.stringify(t);w.useEffect(()=>{if(c)return;const E=e.prepopulateApi;if(!E?.enabled||!E.api?.path||!v){m({}),y("idle"),S.current=null;return}const C=JSON.stringify({path:E.api.path,method:E.api.method,queryParams:E.api.queryParams,headers:E.api.headers,bodyFields:E.api.bodyFields,auth:E.api.auth,mapping:E.contextMapping,bindings:e.dataBindings,context:A});if(S.current===C)return;let I=!1;return S.current=C,y("loading"),(async()=>{try{const W=Eb(e.dataBindings??[],t),M={...t,...W},U=await Sd({clientId:v,api:E.api,context:M});if(I)return;const V=CO(U,E.contextMapping);m({...V,prepopulateResponse:U}),y("ready")}catch{I||(m({}),y("error"))}})(),()=>{I=!0,S.current=null}},[c,e.prepopulateApi,e.dataBindings,A,v]);const x=w.useMemo(()=>{if(c)return{...c.context,...t};const E=Eb(e.dataBindings??[],t);return{...t,...E,...g}},[c,t,e.dataBindings,g]),F=String(r??x.clientId??c?.clientId??""),N=w.useCallback((E,C,I)=>{l(W=>({...W,[E]:{...W[E]??{},[C]:I}}))},[]),k=w.useCallback(E=>p.current[E]??{},[]),T=w.useCallback((E,C,I,W)=>{(o??c?.onAction)?.({...E,sourceWidgetId:C,event:I,payload:W})},[o,c?.onAction]),P=w.useMemo(()=>({schema:e,context:x,clientId:F,prepopulateStatus:c?.prepopulateStatus??h,nestingDepth:n,onAction:o??c?.onAction,getWorkflowState:i??c?.getWorkflowState,workflowModalHandlers:s??c?.workflowModalHandlers,getAuthHeaders:a??c?.getAuthHeaders,filterGroups:f,setFilterValue:N,getFilterGroup:k,dispatchAction:T}),[e,x,F,h,n,o,c?.onAction,i,c?.getWorkflowState,s,c?.workflowModalHandlers,a,c?.getAuthHeaders,f,N,k,T]);return d.jsx(xd.Provider,{value:P,children:u})}function Br(){const e=w.useContext(xd);if(!e)throw new Error("usePageContext must be used within PageContextProvider");return e}function kO(){return w.useContext(xd)}const _O=5,Nb=1;function Wo(e){return Number.isFinite(e)?Math.min(_O,Math.max(Nb,Math.round(e))):Nb}function TO(e,t){const r=Wo(t),n=Array.from({length:r},()=>[]);return e.forEach((o,i)=>{const s=o.config,a=s.columnIndex!==void 0?Math.min(Math.max(0,s.columnIndex),r-1):i%r;n[a].push(o)}),n}function FO(e){return Number.isFinite(e)?Math.min(100,Math.max(0,Math.round(e))):0}function PO(e,t){const r=Math.max(1,t),n=Math.min(100,Math.max(0,Math.round(e))),o=Math.floor(n/r),i=n-o*r;return Array.from({length:r},(s,a)=>o+(a<i?1:0))}function kb(e){return PO(100,Wo(e))}function OO(e){const t=e.trim(),r=/^(\d+(?:\.\d+)?)\s*%?$/.exec(t);return r?FO(Number(r[1])):null}function _b(e,t){const r=Wo(t),n=[];for(let i=0;i<r;i++){const s=OO(e?.[i]??"");if(s===null)return kb(r);n.push(s)}return n.reduce((i,s)=>i+s,0)!==100?kb(r):n}function IO(e){return e==="sm"?"gap-2":e==="lg"?"gap-6":"gap-4"}function Tb(e,t){return _b(t,Wo(e)).map(n=>`minmax(0, ${n}fr)`).join(" ")}function MO(e){return e.length?e.map(t=>`minmax(0, ${t}fr)`).join(" "):"minmax(0, 1fr)"}function LO(e,t,r,n){const o=Wo(t),i=TO(e,o),s=_b(r,o);if(!(n?.collapseEmpty!==!1))return{columns:i,gridTemplate:Tb(o,r),sourceIndices:i.map((p,g)=>g)};const c=i.map((p,g)=>({colChildren:p,index:g,percent:s[g]??0})).filter(p=>p.colChildren.length>0);if(c.length===0||c.length===i.length)return{columns:i,gridTemplate:Tb(o,r),sourceIndices:i.map((p,g)=>g)};const u=c.reduce((p,g)=>p+g.percent,0),f=c.map(p=>u>0?Math.round(p.percent/u*100):Math.round(100/c.length)),l=100-f.reduce((p,g)=>p+g,0);return l!==0&&f.length>0&&(f[0]+=l),{columns:c.map(p=>p.colChildren),gridTemplate:MO(f),sourceIndices:c.map(p=>p.index)}}function Ad(e,t="solid"){return e?t==="dashed"?"rounded-md border border-dashed border-border":"rounded-md border border-border":""}function DO(e){return H(Ad(e.showBorder,e.borderStyle??"solid"),e.showBorder&&"p-3")}function BO(e){return H(Ad(e.showBorder,e.borderStyle??"solid"),e.showBorder&&"p-2")}function $O(e,t){return e.columnBorders?.[t]!==void 0?!!e.columnBorders[t]:!!e.showColumnBorders}function jO(e,t){const r=$O(e,t);return H(Ad(r,e.borderStyle??"dashed"),r&&"p-2")}function zO(e){if(e)return{minHeight:`${e}vh`}}function UO({widget:e,renderChildren:t}){const r=e.config,[n,o]=w.useState(r.defaultCollapsed??!1);return d.jsxs("section",{className:H("space-y-4",DO(r)),"data-widget-id":e.id,children:[r.heading&&d.jsx("div",{className:"flex items-center gap-2",children:r.collapsible?d.jsx("button",{type:"button",className:"text-left text-lg font-semibold hover:underline",onClick:()=>o(i=>!i),children:r.heading}):d.jsx("h2",{className:"text-lg font-semibold",children:r.heading})}),r.showDivider&&d.jsx("hr",{className:"border-border"}),!n&&e.children?.length?d.jsx("div",{className:"space-y-4",children:t?.(e.children)}):null]})}function VO({widget:e,renderChildren:t}){const r=e.config,n=Wo(r.columns??2),o=r.collapseEmptyColumns!==!1,i=LO(e.children??[],n,r.columnWidths,{collapseEmpty:o});return d.jsx("div",{className:H("grid w-full min-w-0 items-stretch",IO(r.gap),BO(r)),style:{gridTemplateColumns:i.gridTemplate,...zO(r.minHeightPercent)},"data-widget-id":e.id,children:i.columns.map((s,a)=>{const c=i.sourceIndices[a]??a;return d.jsx("div",{className:H("flex min-h-[inherit] min-w-0 flex-col space-y-4 overflow-hidden",jO(r,c)),children:t?.(s)},c)})})}function HO({widget:e,renderChildren:t}){const r=e.config,n=r.variant==="outline"?"border bg-background":r.variant==="elevated"?"border bg-background shadow-md":"border bg-card";return d.jsxs("div",{className:H("rounded-lg p-4",n),"data-widget-id":e.id,children:[(r.title||r.subtitle)&&d.jsxs("div",{className:"mb-4",children:[r.title&&d.jsx("h3",{className:"font-semibold",children:r.title}),r.subtitle&&d.jsx("p",{className:"text-sm text-muted-foreground",children:r.subtitle})]}),e.children?.length?d.jsx("div",{className:"space-y-4",children:t?.(e.children)}):null]})}function Fb(e,t){if(e.variable){const r=t[e.variable];return r!=null?String(r):e.fallback??e.text??""}return e.text??""}function WO({widget:e}){const t=e.config,{context:r}=Br(),n=Fb(t,r),o=t.level??2,i=t.align==="center"?"text-center":t.align==="right"?"text-right":"text-left",s=o===1?"text-3xl":o===2?"text-2xl":o===3?"text-xl":"text-lg";return d.jsx("div",{role:"heading","aria-level":o,className:H("font-semibold tracking-tight",s,i),"data-widget-id":e.id,children:n})}function RO({widget:e}){const t=e.config,{context:r}=Br(),n=Fb(t,r),o=t.preset==="caption"?"text-sm text-muted-foreground":t.preset==="small"?"text-xs text-muted-foreground":"text-base",i=t.align==="center"?"text-center":t.align==="right"?"text-right":"text-left";return d.jsx("p",{className:H(o,i),"data-widget-id":e.id,children:n})}function KO(e,t){return!e||typeof e!="string"?e:e.replace(/\{\{([^}]+)\}\}/g,(r,n)=>{const o=n.trim(),i=t[o];return i==null?"":String(i)})}function Pb(e,t){const r={...e};for(const[n,o]of Object.entries(r))typeof o=="string"&&(r[n]=KO(o,t));return r}function GO(e,t){return e.replace(/\{\{([^}]+)\}\}/g,(r,n)=>{const o=t[n.trim()];return o!=null?String(o):""})}function Ob(e,t,r,n){if(e.type==="navigate"){const o=GO(e.href,t);if(!o.trim())return;e.openIn==="new"?window.open(o,"_blank","noopener,noreferrer"):window.location.assign(o);return}if(e.type==="navigate_page"&&e.pageId){r({...e,params:e.params?Pb(e.params,t):void 0},n,"click");return}if(e.type==="workflow"&&e.workflowId){r(e,n,"click");return}r(e,n,"click")}function qO({widget:e}){const t=e.config,{context:r,dispatchAction:n}=Br();return d.jsx(Qt,{variant:t.variant??"default",size:t.size??"default","data-widget-id":e.id,onClick:()=>Ob(t.action,r,n,e.id),children:t.label})}const YO={start:"justify-start",center:"justify-center",end:"justify-end","space-between":"justify-between"},XO={sm:"gap-2",md:"gap-3",lg:"gap-4"};function JO({widget:e}){const t=e.config,{context:r,dispatchAction:n}=Br(),o=t.buttons??[];return d.jsx("div",{className:H("flex flex-wrap items-center",YO[t.align??"start"],XO[t.gap??"sm"],t.wrap===!1&&"flex-nowrap"),"data-widget-id":e.id,children:o.map(i=>d.jsx(Qt,{variant:i.variant??"outline",size:i.size??"default","data-widget-id":e.id,"data-button-id":i.id,onClick:()=>Ob(i.action,r,n,e.id),children:i.label},i.id))})}function QO(e){const t=e.prepopulateApi;return!!(t?.enabled&&t.api?.path)}function ZO(e,t){return e&&(t==="idle"||t==="loading")}function eI(e,t){return!e||t==="ready"||t==="error"}function tI(e,t){const r=We(e,t??"");return r===void 0?null:r}function Ib(e,t){if(e.mode==="pageApi"&&e.dataSourceRef)return t[e.dataSourceRef];if(e.mode==="api")return e.api}function Mb({widgetId:e,dataSource:t,enabled:r=!0,page:n,pageSize:o,search:i}){const{schema:s,context:a,clientId:c,getFilterGroup:u,prepopulateStatus:f}=Br(),l=w.useMemo(()=>t.filterGroupKey?u(t.filterGroupKey):{},[t.filterGroupKey,u]),p=t.mode==="context"&&QO(s),g=ZO(p,f),m=r&&(t.mode==="static"||(t.mode==="context"?eI(p,f):!!c)),h=w.useMemo(()=>["page-ds",e,t,a,l,n,o,i,f],[e,t,a,l,n,o,i,f]),y=kn.useQuery({queryKey:h,enabled:m,staleTime:Ib(t,s.dataApis??{})?.staleTimeMs??3e4,queryFn:async()=>{if(t.mode==="static")return t.staticData;if(t.mode==="context")return tI(a,t.contextPath);const S=Ib(t,s.dataApis??{});if(!S)throw new Error(`No API config for data source on widget ${e}`);const v={...a};if(t.requestBindings)for(const F of t.requestBindings){let N;F.source==="binding"?N=a[F.key]:F.source==="filter"&&(N=l[F.key]),N!==void 0&&(v[F.param]=N)}const x={...Pb(v,a),...n!==void 0?{page:n,pageSize:o,search:i}:{}};return Sd({clientId:c,api:S,context:x,filterState:l})}});return{...y,isLoading:y.isLoading||g,isPending:y.isPending||g,isFetching:y.isFetching||g}}function Cd(e,t){if(e==null)return"";if(!t||t.type==="none")return String(e);switch(t.type){case"number":{const r=Number(e);return Number.isNaN(r)?String(e):r.toFixed(t.decimals??0)}case"currency":{const r=Number(e);return Number.isNaN(r)?String(e):new Intl.NumberFormat(void 0,{style:"currency",currency:t.currency??"USD"}).format(r)}case"percent":{const r=Number(e);return Number.isNaN(r)?String(e):`${r.toFixed(t.decimals??0)}%`}case"date":{const r=new Date(String(e));return Number.isNaN(r.getTime())?String(e):r.toLocaleDateString(void 0,{...t.format?{}:{}})}case"template":return t.template.replace(/\{\{value\}\}/g,String(e));default:return String(e)}}function ji(e,t){const r=We(e,t.path);return r==null?t.fallback??r:t.formatter?Cd(r,t.formatter):r}function rI(e,t){if(!t)return{};const r={};for(const[n,o]of Object.entries(t))o in e&&(r[n]=e[o]);return r}const nI={default:"border bg-card",success:"border border-green-200 bg-green-50 text-green-900",warning:"border border-amber-200 bg-amber-50 text-amber-900",danger:"border border-red-200 bg-red-50 text-red-900"},oI={rectangle:"rounded-lg",square:"aspect-square rounded-lg",circle:"aspect-square rounded-full"},iI={sm:"p-2 text-xs",md:"p-4 text-sm",lg:"p-6 text-base"},Ed={sm:"text-lg",md:"text-2xl",lg:"text-3xl"},sI={sm:"gap-2",md:"gap-3",lg:"gap-4"};function aI({title:e,value:t,trend:r,variant:n="default",shape:o="rectangle",size:i="md",layout:s="vertical",isLoading:a,isError:c}){const u=s==="horizontal";return d.jsxs("div",{className:H(nI[n??"default"],oI[o??"rectangle"],iI[i??"md"],u&&"flex items-center justify-between gap-3"),children:[d.jsxs("div",{className:H(u&&"min-w-0"),children:[e&&d.jsx("p",{className:H("font-medium text-muted-foreground",u?"text-sm":""),children:e}),r!=null&&r!==""&&!u&&d.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:String(r)})]}),a?d.jsx(wn,{className:"my-2"}):c?d.jsx("p",{className:H("font-bold text-destructive",Ed[i??"md"]),children:"Error"}):d.jsx("p",{className:H("font-bold",u?Ed[i??"md"]:`mt-1 ${Ed[i??"md"]}`),children:String(t)}),u&&r!==null&&r!==void 0&&r!==""&&d.jsx("p",{className:"text-xs text-muted-foreground",children:String(r)})]})}function Lb({stat:e,widgetId:t}){const{data:r,isLoading:n,isError:o}=Mb({widgetId:t,dataSource:e.dataSource}),s=(()=>{if(n)return"";if(r==null)return e.valueMapping.fallback??"—";if(e.dataSource.mode==="context"){const c=r;return e.valueMapping.formatter?Cd(c,e.valueMapping.formatter):c}if(e.dataSource.mode==="static"){const c=e.valueMapping.path?.trim()||"value",u=ji(r,{...e.valueMapping,path:c});if(u!=null)return e.valueMapping.formatter?Cd(u,e.valueMapping.formatter):u;if(typeof r=="object"&&r!==null&&!Array.isArray(r)){const f=r;if(f.value!==void 0&&f.value!==null)return f.value}return e.valueMapping.fallback??"—"}return ji(r,e.valueMapping)})(),a=e.trendMapping&&r!==void 0&&e.dataSource.mode!=="context"?ji(r,e.trendMapping):e.trendMapping&&e.dataSource.mode==="context"&&e.trendMapping.path?ji({value:r},e.trendMapping):null;return d.jsx(aI,{title:e.title,value:s,trend:a,variant:e.variant,shape:e.shape,size:e.size,layout:e.layout,isLoading:n,isError:o})}function lI({widget:e}){const t=e.config;return d.jsx("div",{"data-widget-id":e.id,children:d.jsx(Lb,{stat:t,widgetId:e.id})})}function cI({stat:e,widgetId:t}){return d.jsx(Lb,{stat:e,widgetId:`${t}-${e.id}`})}function dI({widget:e}){const t=e.config,r=t.stats??[],n=t.columns??1,o=t.direction==="horizontal";return d.jsx("div",{"data-widget-id":e.id,className:H(o?"flex flex-wrap":"grid",!o&&n===1&&"grid-cols-1",!o&&n===2&&"grid-cols-2",!o&&n===3&&"grid-cols-3",!o&&n===4&&"grid-cols-4",sI[t.gap??"md"]),children:r.map(i=>d.jsx(cI,{stat:i,widgetId:e.id},i.id))})}function uI({widget:e}){const t=e.config,{setFilterValue:r}=Br(),[n,o]=w.useState("");return w.useEffect(()=>{const i=t.debounceMs??300,s=setTimeout(()=>{r(t.filterGroupKey,"search",n)},i);return()=>clearTimeout(s)},[n,t.debounceMs,t.filterGroupKey,r]),d.jsx("input",{type:"search",className:"flex h-9 w-full max-w-sm rounded-md border border-input bg-background px-3 py-1 text-sm shadow-xs",placeholder:t.placeholder??"Search…",value:n,onChange:i=>o(i.target.value),"data-widget-id":e.id})}function fI(e,t){if(!e)return[];const r=t?We(e,t):e;if(Array.isArray(r))return r;if(typeof r=="object"&&r!==null){const n=r;if(Array.isArray(n.items))return n.items;if(Array.isArray(n.data))return n.data}return[]}function pI({widget:e}){const t=e.config,{dispatchAction:r}=Br(),[n,o]=w.useState(1),[i,s]=w.useState(""),a=t.pagination?.pageSize??10,{data:c,isLoading:u,isError:f}=Mb({widgetId:e.id,dataSource:t.dataSource,page:n,pageSize:a,search:t.search?.enabled?i:void 0}),l=t.dataSource.mode==="pageApi"?void 0:t.dataSource.api?.itemsPath,p=fI(c,l??"data.items"),g=(m,h)=>{const y=t.dataSource.responseMapping.find(S=>S.target===h);return y?ji(m,y):We(m,h)??""};return d.jsxs("div",{className:"space-y-3","data-widget-id":e.id,children:[t.search?.enabled&&d.jsx("input",{type:"search",className:"flex h-9 w-full max-w-sm rounded-md border border-input bg-background px-3 py-1 text-sm",placeholder:t.search.placeholder??"Search…",value:i,onChange:m=>{s(m.target.value),o(1)}}),d.jsx("div",{className:"overflow-x-auto rounded-md border",children:d.jsxs("table",{className:"w-full text-sm",children:[d.jsx("thead",{children:d.jsx("tr",{className:"border-b bg-muted/50",children:t.columns.map(m=>d.jsx("th",{className:H("px-3 py-2 text-left font-medium",m.align==="center"&&"text-center",m.align==="right"&&"text-right"),style:m.width?{width:m.width}:void 0,children:m.header},m.id))})}),d.jsx("tbody",{children:u?d.jsx("tr",{children:d.jsx("td",{colSpan:t.columns.length,className:"px-3 py-8 text-center",children:d.jsx(wn,{})})}):f?d.jsx("tr",{children:d.jsx("td",{colSpan:t.columns.length,className:"px-3 py-8 text-center text-destructive",children:"Failed to load data"})}):p.length===0?d.jsx("tr",{children:d.jsx("td",{colSpan:t.columns.length,className:"px-3 py-8 text-center text-muted-foreground",children:t.emptyMessage??"No data"})}):p.map((m,h)=>d.jsx("tr",{className:"cursor-pointer border-b hover:bg-muted/30",onClick:()=>{r({type:"emit",eventName:"row_click",payload:{row:m}},e.id,"row_click")},children:t.columns.map(y=>d.jsx("td",{className:H("px-3 py-2",y.align==="center"&&"text-center",y.align==="right"&&"text-right"),children:String(g(m,y.field))},y.id))},h))})]})}),t.pagination?.enabled&&d.jsxs("div",{className:"flex items-center justify-between text-sm",children:[d.jsxs("span",{className:"text-muted-foreground",children:["Page ",n]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{type:"button",className:"rounded border px-2 py-1 disabled:opacity-50",disabled:n<=1,onClick:()=>o(m=>Math.max(1,m-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"rounded border px-2 py-1",disabled:p.length<a,onClick:()=>o(m=>m+1),children:"Next"})]})]})]})}const mI=75;function hI(e){return e??mI}function gI(e){return e?"rounded-md border border-border p-3":""}function Nd({scrollBehavior:e="page",maxHeightPercent:t,children:r,className:n}){if(e!=="contained")return n?d.jsx("div",{className:n,children:r}):d.jsx(d.Fragment,{children:r});const o=hI(t);return d.jsx("div",{className:H("min-w-0 overflow-y-auto overflow-x-hidden",n),style:{maxHeight:`${o}vh`},"data-form-embed-scroll":"contained",children:r})}const yI="/api/bff/workflows";function bI(e){const t=e.moduleId??e.module_id;return t!=null?String(t).trim():""}function Db(e){const t=Hf(),r=e.userId??e.user_id??t?.userId;return r!=null&&String(r).trim()!==""?String(r):void 0}function vI(e){const t=String(e.clientId??nn()??""),r=Db(e);return()=>Ca({getAuthHeaders:()=>fi()??{},clientId:t||void 0,userId:r})}function Bb(e,t){const r=bI(e);if(!r)return null;const n=t?.bffWorkflowsBasePath??yI,o=String(e.clientId??nn()??""),i=Db(e),s=vI(e),a=t?.workflowModalHandlers??gb({bffWorkflowsBasePath:n,moduleId:r,getAuthHeaders:s,clientId:o||void 0,userId:i});return{getWorkflowState:t?.getWorkflowState??(u=>yb({bffWorkflowsBasePath:n,moduleId:u.moduleId,featureId:u.featureId,tenantId:u.tenantId,subjectUserId:u.subjectUserId,viewStepId:u.viewStepId,clientId:u.clientId??(o||void 0),getAuthHeaders:s})),workflowModalHandlers:a,getAuthHeaders:s,moduleId:r}}function wI(e,t,r){return["embedded-form",e,t,r??"latest"]}async function SI(e,t){try{const r=await Jt.get(`/api/form-builder/form-layouts/form/${e}`,{params:{clientId:t}});let n=r.data?.data??r.data;for(;n&&typeof n=="object"&&!Array.isArray(n)&&n.data!=null&&typeof n.data=="object"&&!("rows"in n)&&!("columns"in n)&&!("formDefinitionId"in n);)n=n.data;return!n||typeof n!="object"||Array.isArray(n)||!("rows"in n)&&!("columns"in n)&&!("formDefinitionId"in n)?null:n}catch{return null}}async function xI(e,t,r){const n=r!==void 0?`/api/form-builder/forms/${e}/render?version=${r}`:`/api/form-builder/forms/${e}/render`,o=await Jt.get(n,{params:{clientId:t}}),s=o.data?.data??o.data,a=s.form??s,c=s.fields??a.fields??[];let u=s.layout??a.layout??null;(!u||typeof u.columns!="number")&&(u=await SI(e,t));const f=s.rules??a.rules??[],l=Mi(a,c,u,f),p=Ki({config:l.config,layout:l.layout},Ri(u))??Ri(u);return{schema:l,gridLayout:p}}const AI=300*1e3;function $b({formId:e,mode:t="fill",contextFieldMapping:r,pageContext:n,clientId:o,formVersion:i,scrollBehavior:s,maxHeightPercent:a,showBorder:c}){const u=kO(),{data:f,isLoading:l,isError:p,error:g}=kn.useQuery({queryKey:wI(e,o,i),queryFn:()=>xI(e,o,i),staleTime:AI}),m=w.useMemo(()=>rI(n,r),[n,r]),h=gI(c),y=typeof f?.schema?.moduleId=="string"?f.schema.moduleId.trim():"",S=u?.context.moduleId!=null?String(u.context.moduleId).trim():"",v=y||S||void 0,A=w.useMemo(()=>u?.workflowModalHandlers||!v?null:Bb({...n,clientId:o||n.clientId,moduleId:v}),[u?.workflowModalHandlers,v,n,o]),x=u?.workflowModalHandlers??A?.workflowModalHandlers,F=u?.getAuthHeaders??A?.getAuthHeaders;return l?d.jsx(Nd,{scrollBehavior:s,maxHeightPercent:a,className:h,children:d.jsx(wn,{})}):p?d.jsx(Nd,{scrollBehavior:s,maxHeightPercent:a,className:h,children:d.jsx("p",{className:"text-sm text-destructive",children:g instanceof Error?g.message:"Failed to load form"})}):f?.schema?d.jsx(Nd,{scrollBehavior:s,maxHeightPercent:a,className:h,children:d.jsx(Di,{schema:f.schema,mode:t,gridLayout:f.gridLayout,initialValues:m,submissionContext:n,moduleId:v,workflowModalHandlers:x,getAuthHeaders:F})}):null}function CI({widget:e}){const t=e.config,{context:r,clientId:n}=Br();return t.formId?d.jsx($b,{formId:t.formId,mode:t.mode??"fill",contextFieldMapping:t.contextFieldMapping,pageContext:r,clientId:n,scrollBehavior:t.scrollBehavior,maxHeightPercent:t.maxHeightPercent,showBorder:t.showBorder}):d.jsx("p",{className:"text-sm text-muted-foreground",children:"No form configured"})}function EI({widget:e}){const t=e.config,{context:r,getWorkflowState:n,workflowModalHandlers:o,clientId:i}=Br(),s=String(r.moduleId??"");if(!n)return d.jsxs("div",{className:"rounded-md border border-dashed p-4 text-sm text-muted-foreground","data-widget-id":e.id,children:["Workflow embed requires ",d.jsx("code",{className:"text-xs",children:"getWorkflowState"})," on PageRenderer. Workflow ID: ",t.workflowId]});if(!s)return d.jsx("p",{className:"text-sm text-destructive","data-widget-id":e.id,children:"moduleId required in page context for workflow embed"});const a={};if(t.contextVariableMapping)for(const[c,u]of Object.entries(t.contextVariableMapping)){const f=r[u];f!=null&&(a[c]=String(f))}return d.jsx(hb,{getWorkflowState:n,workflowModalHandlers:o,moduleId:s,tenantId:r.tenantId?String(r.tenantId):void 0,clientId:i||void 0,submissionContext:a})}function NI({widget:e}){const t=e.config,{schema:r,dispatchAction:n}=Br(),o=t.previousPage??r.navigation?.previousPage,i=t.nextPage??r.navigation?.nextPage,s=t.showPrevious!==!1&&!!o,a=t.showNext!==!1&&!!i,c=t.showBreadcrumbs&&r.navigation?.breadcrumbs?.length,u=t.align==="center"?"justify-center":t.align==="right"?"justify-end":t.align==="space-between"?"justify-between":"justify-start",f=l=>{n({type:"navigate_page",pageId:l.pageId},e.id,"click")};return d.jsxs("nav",{className:"space-y-3","data-widget-id":e.id,children:[c&&d.jsx("ol",{className:"flex flex-wrap items-center gap-1 text-sm text-muted-foreground",children:r.navigation.breadcrumbs.map((l,p)=>d.jsxs("li",{className:"flex items-center gap-1",children:[p>0&&d.jsx("span",{children:"/"}),l.href?d.jsx("a",{href:l.href,className:"hover:underline",children:l.label}):d.jsx("span",{children:l.label})]},p))}),d.jsxs("div",{className:H("flex items-center gap-2",u),children:[s&&o&&d.jsx(Qt,{variant:"outline",size:"sm",onClick:()=>f(o),children:o.label??"Previous"}),a&&i&&d.jsx(Qt,{variant:"default",size:"sm",onClick:()=>f(i),children:i.label??"Next"})]})]})}function kI(e,t){return e?.length?e.filter(r=>r.config.tabId===t):[]}const _I=1;function TI(e){switch(e){case"pills":return"bg-transparent gap-1 p-0 h-auto";case"underline":return"bg-transparent rounded-none border-b p-0 h-auto w-full justify-start gap-4";default:return""}}function FI(e){switch(e){case"pills":return"rounded-full data-[state=active]:bg-primary data-[state=active]:text-primary-foreground";case"underline":return"rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:shadow-none bg-transparent";default:return""}}function PI(e,t,r){return e?new Set(r?[r]:[]):new Set(t.map(n=>n.id))}function OI({tab:e,shouldRender:t,pageContext:r,clientId:n}){return t?e.formId?d.jsx($b,{formId:e.formId,mode:e.formMode??"fill",contextFieldMapping:e.contextFieldMapping,pageContext:r,clientId:n,scrollBehavior:e.scrollBehavior,maxHeightPercent:e.maxHeightPercent,showBorder:e.showBorder}):d.jsx("p",{className:"text-sm text-muted-foreground",children:"No form configured for this tab"}):null}function II({tab:e,shouldLoad:t,shouldRender:r,nestingDepth:n,pageContext:o,clientId:i,onAction:s,getWorkflowState:a}){const c=Br(),{data:u,isLoading:f,isError:l,error:p}=kn.useQuery({queryKey:["tab-page",e.pageId,e.pageVersion,i],enabled:t&&!!e.pageId,queryFn:async()=>wd(e.pageId,i,e.pageVersion)});return r?n>=_I?d.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm text-destructive",children:"Nested page tabs not supported"}):e.pageId?f?d.jsx(wn,{}):l?d.jsx("p",{className:"text-sm text-destructive",children:p instanceof Error?p.message:"Failed to load page"}):u?d.jsx(kd,{page:u,context:o,nestingDepth:n+1,inheritContext:!0,onAction:s,getWorkflowState:a,parentContext:c}):null:d.jsx("p",{className:"text-sm text-muted-foreground",children:"No page configured for this tab"}):null}function MI({tab:e,widgetChildren:t,renderChildren:r}){const n=kI(t,e.id);return n.length===0?d.jsx("p",{className:"text-sm text-muted-foreground py-4",children:"No widgets in this tab"}):d.jsx(d.Fragment,{children:r?.(n)})}function LI({widget:e,renderChildren:t}){const r=e.config,{context:n,clientId:o,nestingDepth:i,onAction:s,getWorkflowState:a}=Br(),c=r.tabs??[],u=r.defaultTabId??c[0]?.id??"",f=r.lazyLoad!==!1,[l,p]=w.useState(u),[g,m]=w.useState(()=>PI(f,c,u)),h=S=>{m(v=>new Set(v).add(S)),p(S)},y=w.useMemo(()=>!f,[f]);return c.length===0?d.jsx("p",{className:"text-sm text-muted-foreground","data-widget-id":e.id,children:"No tabs configured"}):d.jsxs(fb,{value:l,onValueChange:h,className:"w-full","data-widget-id":e.id,children:[d.jsx(hd,{className:H("mb-4",TI(r.variant)),children:c.map(S=>d.jsx(gd,{value:S.id,disabled:S.disabled,className:FI(r.variant),children:S.label},S.id))}),c.map(S=>{const v=g.has(S.id),A=y||v,x=y||v;return d.jsxs(pb,{value:S.id,forceMount:y||void 0,className:H("mt-0",y&&"data-[state=inactive]:hidden"),children:[S.contentType==="widgets"&&x&&d.jsx(MI,{tab:S,widgetChildren:e.children??[],renderChildren:t}),S.contentType==="form"&&d.jsx(OI,{tab:S,shouldRender:A,pageContext:n,clientId:o}),S.contentType==="page"&&d.jsx(II,{tab:S,shouldLoad:A,shouldRender:x,nestingDepth:i,pageContext:n,clientId:o,onAction:s,getWorkflowState:a})]},S.id)})]})}const DI={section:UO,columns:VO,card:HO,tab_group:LI,heading:WO,text:RO,button:qO,button_group:JO,stat_card:lI,stat_grid:dI,data_table:pI,search_filter:uI,form_embed:CI,workflow_embed:EI,page_nav:NI};function BI({widget:e}){return d.jsxs("div",{className:"rounded-md border border-dashed border-muted-foreground/40 bg-muted/20 p-3 text-sm text-muted-foreground","data-widget-id":e.id,"data-widget-type":e.type,children:["Unsupported widget: ",d.jsx("code",{className:"text-xs",children:e.type}),e.label&&d.jsxs("span",{className:"ml-1",children:["(",e.label,")"]})]})}function $I({widget:e,renderChildren:t}){const r=DI[e.type]??BI;return d.jsx(r,{widget:e,renderChildren:t})}function jb(e,t){return e.map(r=>d.jsx($I,{widget:r,renderChildren:t},r.id))}function kd({page:e,context:t={},onAction:r,chrome:n="none",className:o,nestingDepth:i=0,getWorkflowState:s,workflowModalHandlers:a,getAuthHeaders:c,inheritContext:u=!1,parentContext:f}){const l=w.useMemo(()=>SO(e.schema),[e.schema]),p=w.useMemo(()=>{const h=Bb(t,{getWorkflowState:s,workflowModalHandlers:a});return{getWorkflowState:s??h?.getWorkflowState,workflowModalHandlers:a??h?.workflowModalHandlers,getAuthHeaders:c??h?.getAuthHeaders}},[t,s,a,c]),g=h=>jb(h,g),m=d.jsxs("div",{className:H("studio-page-content min-h-0 min-w-0",bO(l),o),"data-page-id":e.id,"data-nesting-depth":i,children:[n==="minimal"&&l.meta?.title&&d.jsxs("header",{className:"mb-6 border-b pb-4",children:[d.jsx("h1",{className:"text-2xl font-semibold",children:l.meta.title}),l.meta.description&&d.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:l.meta.description})]}),d.jsx("div",{className:"space-y-6",children:jb(l.widgets,g)})]});return u&&f?m:d.jsx(NO,{schema:l,context:t,clientId:String(t.clientId??""),nestingDepth:i,onAction:r,getWorkflowState:p.getWorkflowState,workflowModalHandlers:p.workflowModalHandlers,getAuthHeaders:p.getAuthHeaders,parentContext:f,children:m})}function jI({clientId:e,tenantId:t,moduleId:r,featureId:n,pageId:o,routePath:i,routeParams:s={},isDefault:a,context:c={},version:u,chrome:f="none",onAction:l,getWorkflowState:p,workflowModalHandlers:g,getAuthHeaders:m}){const h=w.useMemo(()=>({...s,...c,clientId:e,tenantId:t,moduleId:r,featureId:n}),[s,c,e,t,r,n]),{data:y,isLoading:S,isError:v,error:A}=kn.useQuery({queryKey:["page-resolve",e,t,r,n,o,i,a,u],queryFn:()=>Cb({clientId:e,tenantId:t,moduleId:r,featureId:n,routePath:i,isDefault:a,version:u}),enabled:!o}),x=o??y?.pageId,F=u??y?.version,{data:N,isLoading:k,isError:T,error:P}=kn.useQuery({queryKey:["page-render",x,e,F],queryFn:()=>wd(x,e,F),enabled:!!x});return!o&&S?d.jsx("div",{className:"flex items-center justify-center p-12",children:d.jsx(wn,{})}):v?d.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm text-destructive",children:A instanceof Error?A.message:"Failed to resolve page"}):x?k?d.jsx("div",{className:"flex items-center justify-center p-12",children:d.jsx(wn,{})}):T||!N?d.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm text-destructive",children:P instanceof Error?P.message:"Failed to load page"}):d.jsx(kd,{page:N,context:h,chrome:f,nestingDepth:0,onAction:l,getWorkflowState:p,workflowModalHandlers:g,getAuthHeaders:m}):d.jsx("div",{className:"rounded-md border p-4 text-sm text-muted-foreground",children:"No page found for the given scope or route."})}ue.FIELD_TYPE_REGISTRY=mO,ue.FORM_RENDERER_GRID_ROW_HEIGHT_DEFAULT=Hn,ue.FORM_RENDERER_ROOT_CLASS=za,ue.FieldRenderer=Sn,ue.FormRenderer=Di,ue.PageRenderer=kd,ue.RendererFieldLayoutContext=Ja,ue.RendererStoreProvider=ll,ue.STEPS_NAV_RUNTIME_DEFAULTS=Bi,ue.StudioPageHost=jI,ue.WorkflowFormModal=Pg,ue.WorkflowModalProvider=Mg,ue.WorkflowStepsView=hb,ue.appearanceControlClasses=uo,ue.appearanceHasExplicitVerticalIntent=pu,ue.appearanceTextareaClasses=ou,ue.backendToFormSchema=Mi,ue.buildBffWorkflowAuthHeaders=Ca,ue.cellAlignmentClasses=Qv,ue.cellVerticalJustifyClassesForField=Jv,ue.clearWorkflowStandaloneCache=cO,ue.createBffWorkflowModalHandlers=gb,ue.effectiveWidthPercent=Xi,ue.executeDataSource=Sd,ue.fetchBffWorkflowState=yb,ue.fetchPageRender=wd,ue.fetchWorkflowStandaloneFlag=Aa,ue.fieldBlockBoxStyle=Xv,ue.fieldBlockBoxStyleForField=uu,ue.fieldBlockHorizontalPlacementClass=au,ue.fieldBlockHorizontalSelfClass=lu,ue.fieldBlockHorizontalSelfClassForField=fu,ue.fieldBlockWidthStyle=Ra,ue.fieldBlockWidthStyleForField=du,ue.fieldGridShellFillsCellVertically=Qi,ue.formBuilderHttp=Jt,ue.formLayoutRecordToGridConfig=Ri,ue.getBusinessApiOrigin=Uf,ue.getClientId=nn,ue.getRendererHostAuthHeaders=fi,ue.getRendererHostViewerContext=Hf,ue.getRendererStore=Tw,ue.gridCellFlexClasses=su,ue.gridCellFlexClassesForField=Xa,ue.gridCellOuterFlexClasses=iu,ue.hasExplicitFieldBlockWidth=cu,ue.isAsyncSearchFieldProperties=dO,ue.isIntrinsicWidthButtonField=fo,ue.normalizeWorkflowFormSchema=v_,ue.normalizeWorkflowFormToRendererSchema=fa,ue.pageBuilderHttp=$i,ue.parseContentVerticalAlign=Ga,ue.parseMetadataJson=ki,ue.resetRendererHostAuth=R0,ue.resolveBusinessApiUrl=Mr,ue.resolveFormGridLayout=Ki,ue.resolvePage=Cb,ue.resolveWorkflowStepsNavigationConfig=bd,ue.resolveWorkflowStepsNavigationPosition=ZP,ue.resolvedGridCellVerticalJustifyClasses=Qo,ue.resolvedHorizontalAlign=Fr,ue.resolvedVerticalAlign=Jo,ue.resolvedVerticalAlignForField=Ya,ue.setBusinessApiOrigin=z0,ue.setFormBuilderAuthProvider=K0,ue.setPageBuilderAuthProvider=xO,ue.setRendererHostAuthHeaders=W0,ue.setRendererHostViewerContext=H0,ue.useFieldValidation=fO,ue.useFormRenderer=Tu,ue.useFormValidation=uO,ue.useRendererFieldLayout=Zo,ue.useRendererHostAuthStore=Qn,ue.useWorkflowModal=Ig,Object.defineProperty(ue,Symbol.toStringTag,{value:"Module"})}));
|
|
50
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return b.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},XN="DialogDescriptionWarning",JN=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${wg(XN).contentName}}.`;return b.useEffect(()=>{const o=e.current?.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},QN=lg,ZN=ug,e_=fg,t_=pg,r_=hg,n_=bg;function Sg({...e}){return d.jsx(QN,{"data-slot":"dialog",...e})}function o_({...e}){return d.jsx(ZN,{"data-slot":"dialog-portal",...e})}function i_({className:e,...t}){return d.jsx(e_,{"data-slot":"dialog-overlay",className:V("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function xg({className:e,children:t,showCloseButton:r=!0,...n}){return d.jsxs(o_,{"data-slot":"dialog-portal",children:[d.jsx(i_,{}),d.jsxs(t_,{"data-slot":"dialog-content",className:V("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...n,children:[t,r&&d.jsxs(n_,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[d.jsx(ai,{}),d.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Ag({className:e,...t}){return d.jsx("div",{"data-slot":"dialog-header",className:V("flex flex-col gap-2 text-center sm:text-left",e),...t})}function s_({className:e,...t}){return d.jsx("div",{"data-slot":"dialog-footer",className:V("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function Cg({className:e,...t}){return d.jsx(r_,{"data-slot":"dialog-title",className:V("text-lg leading-none font-semibold",e),...t})}async function a_(){const e={width:{ideal:1280},height:{ideal:720}},t=[{facingMode:{ideal:"environment"},...e},{facingMode:{ideal:"user"},...e},{...e},{}];let r;for(const n of t)try{return await navigator.mediaDevices.getUserMedia({video:Object.keys(n).length>0?n:!0,audio:!1})}catch(o){r=o}throw r instanceof Error?r:new Error("Could not access camera")}function Eg(e){const t=()=>e.play();t().catch(()=>{requestAnimationFrame(()=>{t().catch(()=>{const r=()=>{t().catch(()=>{})};e.addEventListener("loadedmetadata",r,{once:!0}),e.addEventListener("canplay",r,{once:!0})})})})}const kg=({open:e,onOpenChange:t,onCaptured:r,validateFile:n,accept:o,disabled:i,onValidationMessage:s})=>{const a=w.useRef(null),c=w.useRef(null),u=w.useRef(null),f=w.useRef(null),[l,p]=w.useState(null),[g,m]=w.useState(!1),h=w.useCallback(()=>{a.current&&(a.current.srcObject=null)},[]),y=w.useCallback(()=>{u.current&&(u.current.getTracks().forEach(k=>k.stop()),u.current=null),h()},[h]);w.useEffect(()=>{if(!e){y(),p(null),m(!1);return}if(i)return;let k=!1;return p(null),m(!0),a_().then(N=>{if(k){N.getTracks().forEach(T=>T.stop());return}u.current=N,m(!1)}).catch(N=>{if(k)return;m(!1);const T=N instanceof Error?N.message:"Could not access camera";p(T)}),()=>{k=!0,u.current&&(u.current.getTracks().forEach(N=>N.stop()),u.current=null),h()}},[e,i,y,h]);const S=w.useCallback(k=>{a.current=k,k&&u.current&&e&&!l&&!g&&(k.srcObject=u.current,Eg(k))},[e,l,g]);w.useLayoutEffect(()=>{if(!e||l||g||!u.current)return;let k=!1,N=0;const T=()=>{if(k)return;const E=a.current;!E||!u.current||(E.srcObject=u.current,Eg(E))};T();const P=requestAnimationFrame(()=>{T(),N=requestAnimationFrame(T)});return()=>{k=!0,cancelAnimationFrame(P),cancelAnimationFrame(N),h()}},[e,l,g,h]);const v=w.useCallback(()=>{y(),p(null),m(!1),t(!1),f.current&&(f.current.value="")},[y,t]),A=w.useCallback(()=>{const k=a.current,N=c.current;if(!k||!N||!u.current||k.readyState<2)return;const T=k.videoWidth,P=k.videoHeight;if(T===0||P===0)return;N.width=T,N.height=P;const E=N.getContext("2d");E&&(E.drawImage(k,0,0),N.toBlob(C=>{if(!C)return;const O=new File([C],`camera-capture-${Date.now()}.jpg`,{type:"image/jpeg",lastModified:Date.now()}),W=n(O);if(W){s?.(W);return}s?.(void 0),r(O),v()},"image/jpeg",.92))},[r,n,v,s]),x=w.useCallback(k=>{const N=k.target.files?.[0];if(!N)return;const T=n(N);if(T){s?.(T);return}s?.(void 0),r(N),v(),f.current&&(f.current.value="")},[r,n,v,s]),F=typeof navigator<"u"&&typeof navigator.mediaDevices?.getUserMedia=="function";return d.jsxs(d.Fragment,{children:[d.jsx("input",{ref:f,type:"file",accept:o,capture:"user",onChange:x,className:"hidden","aria-hidden":!0}),d.jsx("canvas",{ref:c,className:"hidden","aria-hidden":!0}),d.jsx(Sg,{open:e,onOpenChange:k=>{k||v()},children:d.jsxs(xg,{className:"sm:max-w-md",showCloseButton:!0,onPointerDownOutside:k=>k.preventDefault(),children:[d.jsx(Ag,{children:d.jsx(Cg,{children:"Take a photo"})}),l?d.jsxs("div",{className:"space-y-3 py-2",children:[d.jsx("p",{className:"text-sm text-destructive",children:l}),F&&d.jsx("p",{className:"text-xs text-muted-foreground",children:"You can choose an image from your device instead."}),d.jsx(Qt,{type:"button",variant:"outline",className:"w-full",onClick:()=>f.current?.click(),children:"Choose from device"})]}):g?d.jsx("p",{className:"text-sm text-muted-foreground py-6 text-center",children:"Opening camera…"}):d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"relative rounded-lg overflow-hidden bg-black aspect-video",children:d.jsx("video",{ref:S,playsInline:!0,muted:!0,className:"w-full h-full object-cover"})}),d.jsxs(s_,{className:"gap-2 sm:gap-0",children:[d.jsx(Qt,{type:"button",variant:"outline",onClick:v,children:"Cancel"}),d.jsx(Qt,{type:"button",onClick:A,children:"Capture photo"})]})]})]})})]})},l_=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a})=>{const c=e.properties,[u,f]=w.useState(),[l,p]=w.useState(!1),[g,m]=w.useState(()=>new Set),[h,y]=w.useState("none"),S=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,v=e.validation?.find(j=>j.type==="fileSize"),A=e.validation?.find(j=>j.type==="fileType"),x=v?.value!=null?v.value:c?.maxSize??S?.maxSize??5*1024*1024,F=A?.value!=null?A.value:c?.accept??S?.accept??["image/*"],k=F.join(",")||"image/*",N=rs(e),T=w.useCallback(j=>{if(v){const H=rn(j,v);if(H!==!0)return typeof H=="string"?H:"File size exceeds the maximum allowed size"}else if(j.size>x)return`File size must be less than ${Po(x)}`;if(A){const H=rn(j,A);if(H!==!0)return typeof H=="string"?H:"File type is not allowed"}return null},[v,A,x]),P=w.useMemo(()=>ns(t),[t]),E=kc(P),C=w.useCallback(j=>{const H=nl(j,N);r(H),n?.()},[r,n,N]),O=w.useCallback(j=>{const H=T(j);if(H){f(H);return}f(void 0);const ce=[...P];ce.length>=N||(ce.push(j),C(ce),y("none"))},[P,N,T,C]),W=w.useCallback(j=>{const H=P.filter((ce,ie)=>ie!==j);C(H)},[P,C]),M=w.useCallback(()=>{i||P.length>=N||(f(void 0),y("camera"),p(!0))},[i,P.length,N]),U=w.useCallback(j=>{p(j),j||y("none")},[]),z=o||u,X=e.appearance?.hideLabel??!1,B=[];(v||x)&&B.push(`Max size: ${Po(x)}`),A&&F.length>0&&B.push(`Allowed: ${F.join(", ")}`),N>1&&B.push(`Up to ${N} photos`);const L=w.useCallback(j=>{window.open(j,"_blank","noopener,noreferrer")},[]),D=P.length===0,K=P.length<N,le=Ac(N,P.length);return d.jsxs(Ct,{field:e,error:z,isRequired:s,className:V(a,"!space-y-0"),hideLabel:X,children:[d.jsx("div",{className:"h-[70px] min-h-[70px] min-w-0 w-full flex flex-col",children:d.jsx("div",{role:"button",tabIndex:i||!K?-1:0,id:ft(e),onClick:j=>{i||j.target.closest("[data-remove-in-dropzone]")||j.target.closest("[data-no-open-picker]")||P.length>=N||M()},onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),!i&&K&&M())},className:V("border-2 border-dashed rounded-lg p-1.5 text-center cursor-pointer transition-colors flex-1 min-h-0 flex flex-col items-center justify-center","hover:border-primary hover:bg-primary/5",z&&"border-destructive",i&&"opacity-50 cursor-not-allowed",l&&h==="camera"&&"opacity-70 pointer-events-none",!K&&P.length>0&&"cursor-default"),"aria-describedby":Lt(e,!!z),"aria-invalid":Jt(!!z),"aria-required":s,children:D?d.jsxs(d.Fragment,{children:[d.jsx(us,{className:"mx-auto h-5 w-5 text-muted-foreground flex-shrink-0"}),d.jsx("p",{className:"text-[11px] text-muted-foreground leading-tight line-clamp-1",children:l?"Opening camera…":"Click to open camera"}),B.length>0&&d.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-1",children:B.join(" • ")})]}):le?d.jsx(Nc,{item:P[0],objectUrl:E[0]??null,failedUrlKeys:g,onImageUrlError:j=>m(H=>new Set(H).add(j)),onRemove:()=>W(0),onOpenUrl:L,disabled:i}):d.jsx(Ec,{items:P,maxFiles:N,disabled:i,objectUrls:E,failedUrlKeys:g,onImageUrlError:j=>m(H=>new Set(H).add(j)),onRemove:W,onOpenUrl:L,addSlot:K?d.jsxs("button",{type:"button","data-no-open-picker":!0,onClick:j=>{j.stopPropagation(),M()},disabled:i,className:"h-[56px] w-[56px] min-w-[56px] flex-shrink-0 rounded border border-dashed border-muted-foreground/40 flex flex-col items-center justify-center text-muted-foreground hover:border-primary hover:bg-primary/5 text-[10px] leading-tight px-0.5",children:[d.jsx(us,{className:"h-4 w-4 mb-0.5","aria-hidden":!0}),"Add"]}):void 0})})}),d.jsx(kg,{open:l,onOpenChange:U,onCaptured:O,validateFile:T,accept:k,disabled:i,onValidationMessage:f})]})},c_=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a,buttonResponses:c})=>{const u=e.properties,f=w.useRef(null),[l,p]=w.useState(),[g,m]=w.useState(!1),[h,y]=w.useState(()=>new Set),[S,v]=w.useState("none"),A=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,x=e.validation?.find(te=>te.type==="fileSize"),F=e.validation?.find(te=>te.type==="fileType"),k=x?.value?x.value:u?.maxSize??A?.maxSize??5*1024*1024,N=F?.value?F.value:u?.accept??A?.accept??["image/*"],T=Array.isArray(N)?N.join(","):"image/*",P=rs(e),E=w.useCallback(te=>{if(x){const oe=rn(te,x);if(oe!==!0)return typeof oe=="string"?oe:"File size exceeds the maximum allowed size"}else if(te.size>k)return`File size must be less than ${Po(k)}`;if(F){const oe=rn(te,F);if(oe!==!0)return typeof oe=="string"?oe:"File type is not allowed"}return null},[x,F,k]),C=w.useMemo(()=>ns(t),[t]),O=kc(C),W=w.useCallback(te=>{const oe=nl(te,P);r(oe),n?.()},[r,n,P]),M=w.useCallback(te=>{p(void 0);const oe=Array.from(te),me=[...C];let Me=null;for(const De of oe){if(me.length>=P)break;const ne=E(De);if(ne){Me||(Me=ne);continue}me.push(De)}if(Me&&me.length===C.length){p(Me);return}Me&&p(Me),W(me),v("none")},[C,P,E,W]),U=w.useCallback(te=>{const oe=te.target.files;oe&&oe.length>0&&M(oe),f.current&&(f.current.value="")},[M]),z=w.useCallback(te=>{W(C.filter((oe,me)=>me!==te))},[C,W]),X=w.useCallback(()=>{i||C.length>=P||g||(p(void 0),v("file"),f.current?.click())},[i,C.length,P,g]),B=w.useCallback(()=>{i||C.length>=P||(p(void 0),v("camera"),m(!0))},[i,C.length,P]),L=w.useCallback(te=>{const oe=E(te);if(oe){p(oe);return}p(void 0);const me=[...C];me.length>=P||(me.push(te),W(me),v("none"))},[C,P,E,W]),D=w.useCallback(te=>{m(te),te||v("none")},[]),K=o||l,le=e.appearance?.hideLabel??!1,j=[];(x||k)&&j.push(`Max size: ${Po(k)}`),F&&N.length>0&&j.push(`Allowed: ${N.join(", ")}`),P>1&&j.push(`Up to ${P} photos`);const H=w.useMemo(()=>{if(!c)return null;const te=Object.values(c);for(let oe=te.length-1;oe>=0;oe-=1){const me=te[oe],Me=typeof me?.status=="string"?me.status.toLowerCase():null;if(Me&&Me!=="success")continue;const De=me?.code;if(typeof De=="number"&&(De<200||De>=300))continue;const ne=me?.data,ge=ne?.file_url||ne?.fileUrl||me?.file_url||me?.fileUrl;if(typeof ge=="string"&&ge.trim())return ge.trim()}return null},[c]),ce=w.useCallback(te=>{window.open(te,"_blank","noopener,noreferrer")},[]),ie=C.length===0,G=C.length<P,ee=Ac(P,C.length),Ae=G&&!g?d.jsxs("div",{"data-no-open-picker":!0,className:"h-[56px] w-[56px] min-w-[56px] flex-shrink-0 rounded border border-dashed border-muted-foreground/40 flex flex-col items-center justify-center gap-0.5 text-muted-foreground",children:[d.jsx("button",{type:"button",disabled:i,onClick:te=>{te.stopPropagation(),X()},className:"flex flex-1 w-full items-center justify-center hover:bg-primary/10 rounded-t","aria-label":"Upload file",title:"Upload",children:d.jsx(ps,{className:"h-4 w-4","aria-hidden":!0})}),d.jsx("button",{type:"button",disabled:i,onClick:te=>{te.stopPropagation(),B()},className:"flex flex-1 w-full items-center justify-center hover:bg-primary/10 rounded-b border-t border-border/50","aria-label":"Open camera",title:"Camera",children:d.jsx(us,{className:"h-4 w-4","aria-hidden":!0})})]}):void 0;return d.jsxs(Ct,{field:e,error:K,isRequired:s,className:V(a,"!space-y-0"),hideLabel:le,children:[d.jsx("div",{className:"h-[70px] min-h-[70px] min-w-0 w-full flex flex-col",children:d.jsxs("div",{className:V("border-2 border-dashed rounded-lg p-1.5 transition-colors flex-1 min-h-0 flex flex-col items-center justify-center","hover:border-primary hover:bg-primary/5",K&&"border-destructive",i&&"opacity-50"),children:[d.jsx("input",{ref:f,id:ft(e),type:"file",accept:T,multiple:P>1,onChange:U,disabled:i||e.disabled||g||!G,className:"hidden","aria-describedby":Lt(e,!!K),"aria-invalid":Jt(!!K),"aria-required":s}),ie?d.jsxs("div",{className:"flex flex-col items-center justify-center gap-1 w-full pointer-events-auto",children:[d.jsxs("div",{className:"flex items-center justify-center gap-3",children:[d.jsxs("button",{type:"button",disabled:i||g,onClick:X,className:V("inline-flex flex-col items-center gap-0.5 text-[11px] text-muted-foreground hover:text-foreground",i&&"pointer-events-none"),children:[d.jsx(ps,{className:"h-5 w-5","aria-hidden":!0}),d.jsx("span",{children:"Upload"})]}),d.jsxs("button",{type:"button",disabled:i,onClick:B,className:V("inline-flex flex-col items-center gap-0.5 text-[11px] text-muted-foreground hover:text-foreground",i&&"pointer-events-none",g&&"opacity-70"),children:[d.jsx(us,{className:"h-5 w-5","aria-hidden":!0}),d.jsx("span",{children:"Camera"})]})]}),j.length>0&&d.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-2 text-center px-1",children:j.join(" • ")})]}):ee?d.jsx(Nc,{item:C[0],objectUrl:O[0]??null,failedUrlKeys:h,onImageUrlError:te=>y(oe=>new Set(oe).add(te)),onRemove:()=>z(0),onOpenUrl:ce,openTarget:C[0]instanceof File?H:void 0,disabled:i||e.disabled}):d.jsx(Ec,{items:C,maxFiles:P,disabled:i,objectUrls:O,failedUrlKeys:h,onImageUrlError:te=>y(oe=>new Set(oe).add(te)),onRemove:z,resolveOpenUrl:(te,oe)=>oe instanceof File&&C.length===1&&H?H:null,onOpenUrl:te=>{te?.trim()&&ce(te.trim())},addSlot:Ae})]})}),d.jsx(kg,{open:g,onOpenChange:D,onCaptured:L,validateFile:E,accept:T,disabled:i,onValidationMessage:p})]})};function d_(e){if(e==null||typeof e!="object")return;const t=e;if(typeof t.message=="string"&&t.message.trim())return t.message.trim();if(typeof t.display_message=="string"&&t.display_message.trim())return t.display_message.trim();if(t.data&&typeof t.data=="object"){const r=t.data;if(typeof r.message=="string"&&r.message.trim())return r.message.trim();if(typeof r.success_message=="string"&&r.success_message.trim())return r.success_message.trim();if(typeof r.display_message=="string"&&r.display_message.trim())return r.display_message.trim()}if(typeof t.success_message=="string"&&t.success_message.trim())return t.success_message.trim()}function Ng(e,t){try{const r=d_(e);at.toast.success(r&&r.trim()?r:t)}catch{at.toast.success(t)}}function ua(e,t,r){try{const n=r(e);at.toast.error(n&&n.trim()?n:t)}catch{at.toast.error(t)}}function u_(e){const t=e.headers,r=["X-Message","X-Success-Message","X-Toast-Message","X-Success-Msg"];for(const n of r){const o=t.get(n);if(o&&typeof o=="string"&&o.trim())return o.trim()}}const fa="This field is required";function _g(e,t){if(!t?.length)return e;const r=t.find(n=>n.name===e);return r?.label&&r.label.trim()||e}function pa(e,t){if(!e)return"Please complete the required fields.";if(Array.isArray(e)){const i=e.map(s=>{const a=s.message||fa;if(t?.length&&s.field){const c=_g(s.field,t);return a===fa?`${c} is required`:`${c}: ${a}`}return a}).filter(s=>typeof s=="string"&&s.length>0);return i.length===0?"Please complete the required fields.":i.length===1?i[0]:`${i[0]} (and ${i.length-1} more)`}const n=Object.entries(e).map(([o,i])=>{const s=i?.trim()||fa;if(t?.length){const a=_g(o,t);return s===fa?`${a} is required`:`${a}: ${s}`}return s}).filter(o=>typeof o=="string"&&o.length>0);return n.length===0?"Please complete the required fields.":n.length===1?n[0]:`${n[0]} (and ${n.length-1} more)`}function Tg(e){if(e==null||typeof e!="object")return!1;const t=e;if(t.status==="error")return!0;const r=t.code;return typeof r=="number"&&(r<200||r>=300)}function f_(e){return!Tg(e)}function p_(e,t,r){if(!t||!f_(e))return;const n=t.fieldMapping;if(n&&Object.keys(n).length>0)for(const[i,s]of Object.entries(n)){if(!i.trim()||!s?.trim())continue;const a=We(e,s.trim());a!=null&&r.setFieldValue(i.trim(),a)}const o=t.contextMapping;if(o&&Object.keys(o).length>0&&r.onContextUpdate){const i={};for(const[s,a]of Object.entries(o)){if(!s.trim()||!a?.trim())continue;const c=We(e,a.trim());c!=null&&(i[s.trim()]=c)}Object.keys(i).length>0&&r.onContextUpdate(i)}}function m_(e=qn){const{totalSteps:t,currentStep:r}=e.getState();return t>1&&r<t-1}async function Pc(e,t=qn){const r=await t.getState().nextStep();if(!r)try{const n=t.getState(),o=n.errors;Object.keys(o).length>0?at.toast.error(pa(o,e)||"Please fix the errors before continuing."):n.totalSteps<=1||n.currentStep>=n.totalSteps-1?at.toast.error("You are already on the last page."):at.toast.error("Please fix the errors before continuing.")}catch{at.toast.error("Please fix the errors before continuing.")}return r}function h_(e=qn){e.getState().prevStep()}const g_=3;function Io(e){if(typeof e=="number"&&!Number.isNaN(e))return e}function Oo(e,t){const r=e&&typeof e=="object"&&!Array.isArray(e)?e:void 0;return Io(r?.cellSlot)??Io(r?.stackSlot)??Io(r?.cellSlotIndex)??Io(r?.slotIndex)??Io(t?.cellSlotIndex)??Io(t?.stackSlot)}function Ni(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:void 0;if(t?.sharedCellLayout==="row"||t?.sharedCellLayout==="stack")return t.sharedCellLayout;if(t?.stackDirection==="horizontal")return"row";if(t?.stackDirection==="vertical")return"stack"}function ma(e){const t=typeof e.position?.order=="number"?e.position.order:-1,r=typeof e.position?.column=="number"?e.position.column:1,n=e.position?.cellGroupId??"_";return`${t}:${r}:${n}`}function Ic(e){return[...e].sort((t,r)=>{const n=Oo(t.position),o=Oo(r.position);return typeof n=="number"&&typeof o=="number"&&n!==o?n-o:String(t.id).localeCompare(String(r.id))})}function _i(e,t){if(e.length===0)return{rowSpan:1,columnSpan:1};let r=1,n=1;for(const o of e)r=Math.max(r,Qo(o)),n=Math.max(n,lu(o,t));return{rowSpan:r,columnSpan:n}}function Fg(e){const t=Ic(e);for(const r of t){const n=Ni(r.position);if(n)return n}return t.length>=2?"row":"stack"}function Pg(e){return Ic(e).slice(0,g_)}function y_(e,t){const r=new Map;for(const n of e){if(!t(n)||typeof n.position?.order!="number")continue;const o=ma(n),i=r.get(o)??[];i.push(n),r.set(o,i)}return Array.from(r.values()).map(n=>Pg(n))}function Ig(e,t,r,n){const o=r.filter(a=>n(a)&&typeof a.position?.order=="number"&&a.position.order===e&&(a.position.column??1)===t+1);if(o.length===0)return[];const i=new Map;for(const a of o){const c=ma(a),u=i.get(c)??[];u.push(a),i.set(c,u)}const s=[...i.values()][0]??[];return Pg(s)}function b_(e,t,r,n){const o=r[0],i=o.position?.order,s=o.position?.column??1;if(typeof i!="number")return!1;const{rowSpan:a,columnSpan:c}=_i(r,n),u=e===i&&t===s-1,f=e>=i&&e<i+a,l=t>=s-1&&t<s-1+c;return f&&l&&!u}function v_(e,t,r){const n=new Set(r??[]);for(const o of e){const i=o[0]?.position?.order??0,{rowSpan:s}=_i(o,t);for(let a=i;a<i+s;a++)n.add(a)}return n}function w_(e){const t=[...e].sort((n,o)=>n-o),r=new Map;return t.forEach((n,o)=>r.set(n,o)),{originalToDisplay:r,displayRowCount:Math.max(t.length,1),sortedOriginalRows:t}}function S_(e,t,r){const n=r.get(e);if(n===void 0)return;let o=0;for(let i=e;i<e+t&&r.has(i);i++)o++;return`${n+1} / span ${Math.max(o,1)}`}function gr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Mo(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(r=>Mo(r));if(!gr(e))return e;const t={};for(const[r,n]of Object.entries(e))t[r]=Mo(n);return t}function Og(e,...t){const r={...e};for(const n of t)if(!(!n||!gr(n)))for(const[o,i]of Object.entries(n)){const s=r[o];gr(i)&&gr(s)?r[o]=Og(s,i):r[o]=i}return r}function io(e){return gr(e)?e:{}}function Ti(e){if(e==null)return{};if(typeof e=="string"){const t=e.trim();if(!t)return{};try{const r=JSON.parse(t);return gr(r)?Mo(r):{}}catch{return{}}}return gr(e)?Mo(e):{}}function Mg(e){const t=e.apidata;return gr(t)&&Object.keys(t).length>0}function x_(e){if(typeof e.metadata=="string"&&e.metadata.trim()!==""||typeof e.metadata=="object"&&e.metadata!==null&&!Array.isArray(e.metadata)&&Object.keys(e.metadata).length>0||Mg(e))return!0;const t=e.fieldKey,r=e.fieldType,n=e.name,o=e.type;return!!(t&&(!n||String(n).trim()==="")||r&&(!o||String(o).trim()==="")||t&&n&&t!==n||r&&o&&r!==o||!n&&e.key&&typeof e.key=="string")}const Lg=["hideLabel","contentAlign","contentVerticalAlign","labelPlacement","widthPercent","widthMode","className","verticalAlign","horizontalAlign","cellAlign","cellJustify","size","variant","minWidth","minHeight"];function A_(e,t){const r=e.appearance,n=gr(r)&&Object.keys(r).length>0?Mo(r):{},o=io(t.appearance),i={...n};for(const[s,a]of Object.entries(o))s!=="heightPercent"&&i[s]===void 0&&(i[s]=Mo(a));for(const s of Lg)i[s]===void 0&&t[s]!==void 0&&(i[s]=t[s]);return delete i.heightPercent,Object.keys(i).length>0?i:void 0}function C_(e,t){const r=io(e.position),n=Ti(e.metadata),o=io(e.layout),i=typeof r.order=="number"&&!Number.isNaN(r.order)?r.order:typeof e.positionOrder=="number"?e.positionOrder:typeof e.order=="number"?e.order:typeof e.positionRow=="number"?e.positionRow:t,s=typeof r.column=="number"&&!Number.isNaN(r.column)?r.column:typeof e.positionColumn=="number"?e.positionColumn:1,a=typeof r.columnSpan=="number"&&!Number.isNaN(r.columnSpan)?r.columnSpan:typeof e.positionWidth=="number"?e.positionWidth:1,c=typeof r.rowSpan=="number"&&!Number.isNaN(r.rowSpan)?r.rowSpan:typeof e.positionRowSpan=="number"?e.positionRowSpan:1,u={order:i,column:s,columnSpan:a,rowSpan:c},f=r.cellGroupId??o.cellGroupId,l=Oo(r,{cellSlotIndex:e.cellSlotIndex??o.cellSlotIndex,stackSlot:n.stackSlot??o.stackSlot}),p=Ni(r)??Ni(o)??(n.stackDirection==="horizontal"||o.stackDirection==="horizontal"?"row":n.stackDirection==="vertical"||o.stackDirection==="vertical"?"stack":void 0);return typeof f=="string"&&(u.cellGroupId=f),typeof l=="number"&&(u.cellSlot=l),(p==="row"||p==="stack")&&(u.sharedCellLayout=p),u}function E_(e,t){const r=e,n=Ti(r.metadata),o=io(r.apidata),i=io(r.properties),s=Og({},n,o,i),a=(r.name!=null&&String(r.name).trim()!==""?r.name:void 0)??(typeof r.fieldKey=="string"?r.fieldKey:void 0)??(typeof r.key=="string"?r.key:void 0),c=(r.type!=null&&String(r.type).trim()!==""?r.type:void 0)??(typeof r.fieldType=="string"?r.fieldType:void 0),u=A_(r,n),f=C_(r,t),l={...r};return l.properties=s,a!==void 0&&(l.name=a),c!==void 0&&(l.type=c),u!==void 0?l.appearance=u:(!gr(r.appearance)||Object.keys(r.appearance).length===0)&&delete l.appearance,l.position=f,gr(l.appearance)&&delete l.appearance.heightPercent,l}function k_(e,t){if(!e||typeof e!="object")return!0;const r=e,n=Ti(r.metadata),o=Object.keys(n).length===0&&!(typeof r.metadata=="string"&&r.metadata.trim()!==""),i=!Mg(r);if(x_(r)||!o||!i)return!1;const s=r.position;return!(!(gr(s)&&typeof s.order=="number"&&!Number.isNaN(s.order))&&(typeof r.positionRow=="number"||typeof r.positionColumn=="number"||typeof r.positionWidth=="number"||typeof r.positionRowSpan=="number"||typeof r.positionOrder=="number")||gr(n.appearance)||Lg.some(u=>n[u]!==void 0&&(r.appearance==null||gr(r.appearance)&&r.appearance[u]===void 0))||N_(r))}function N_(e){const t=io(e.position),r=io(e.layout),n=Ti(e.metadata);return(typeof e.cellSlotIndex=="number"||typeof t.stackSlot=="number"||typeof t.cellSlot=="number"||typeof t.cellSlotIndex=="number"||typeof n.stackSlot=="number"||typeof r.stackSlot=="number")&&typeof t.cellSlot!="number"||(t.stackDirection==="horizontal"||t.stackDirection==="vertical"||n.stackDirection==="horizontal"||n.stackDirection==="vertical"||r.stackDirection==="horizontal"||r.stackDirection==="vertical")&&t.sharedCellLayout!=="row"&&t.sharedCellLayout!=="stack"}function ha(e){if(e==null||typeof e!="object")return e;const t=e.fields;if(!Array.isArray(t))return e;let r=!1;const n=t.map((o,i)=>{if(k_(o))return o;const s=E_(o,i);return s!==o&&(r=!0),s});return r?{...e,fields:n}:e}function __(e){return ha(e)}function T_(e){const t=e.steps;if(!Array.isArray(t)||t.length<2)return;const r=[];for(const n of t){if(!n||typeof n!="object")continue;const o=n,i=typeof o.id=="string"&&o.id.trim()?o.id.trim():void 0,s=typeof o.name=="string"&&o.name.trim()?o.name.trim():void 0,a=Array.isArray(o.fields)?o.fields.filter(c=>typeof c=="string"&&c.trim()!==""):[];!i||!s||r.push({id:i,name:s,...typeof o.description=="string"&&o.description.trim()?{description:o.description.trim()}:{},fields:a,validation:o.validation==="onSubmit"?"onSubmit":"onNext"})}return r.length>=2?r:void 0}function Oc(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function Dg(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}function Bg(e,t){const r=e.form;if(!r)throw new Error("workflowStateToFormSchema requires workflowState.form to be set");const n=r.fields.filter(l=>l!=null&&l!==void 0).map((l,p)=>{if(!l||typeof l!="object")return null;const g={...l};if(l.fieldType&&!g.type&&(g.type=l.fieldType),l.fieldKey&&!g.key&&!g.name&&(g.key=l.fieldKey,g.name=l.fieldKey),typeof l.positionOrder=="number"&&!isNaN(l.positionOrder)?g.order=l.positionOrder:g.order=p,(typeof g.order!="number"||isNaN(g.order))&&(g.order=p),l.options&&typeof l.options=="string")try{g.options=JSON.parse(l.options)}catch{}if(l.metadata&&typeof l.metadata=="string")try{g.metadata=JSON.parse(l.metadata)}catch{}return g}).filter(l=>l!=null).sort((l,p)=>{const g=typeof l.order=="number"?l.order:0,m=typeof p.order=="number"?p.order:0;return g-m});n.forEach((l,p)=>{(!l||typeof l.order!="number"||isNaN(l.order))&&(l.order=p)});let o=r.layout;if(o){const l={...o};if(l.breakpoints&&typeof l.breakpoints=="string")try{l.breakpoints=JSON.parse(l.breakpoints)}catch{}if(l.responsiveConfig&&typeof l.responsiveConfig=="string")try{l.responsiveConfig=JSON.parse(l.responsiveConfig)}catch{}o=l}const i=n.filter(l=>l!=null&&typeof l=="object"&&typeof l.order=="number"&&!isNaN(l.order));let s={};const a=r.config;if(a!=null)if(typeof a=="string")try{s=JSON.parse(a)}catch{}else typeof a=="object"&&a!==null&&(s={...a});const c=l=>{let p={...l};if(l.conditionExpression&&typeof l.conditionExpression=="string")try{p={...l,conditionExpression:JSON.parse(l.conditionExpression)}}catch{}if(p.targetFieldId){const g=i.find(m=>m._id===p.targetFieldId||m.id===p.targetFieldId||m.fieldKey===p.targetFieldId);if(g){const m=g.key||g.fieldKey||g.name,h=g._id||g.id||p.targetFieldId;p.targetFieldKey=m,p.targetField=m,p.targetFieldById=h}}return p},u=T_(r),f={id:r._id,name:r.name,description:r.description??"",version:r.version,status:r.status,fields:i.map((l,p)=>{const g=l,m=typeof l.metadata=="object"&&l.metadata!==null?l.metadata:{},h=m.hidden===!0||l.hidden===!0,y={id:l._id||l.id||l.fieldKey,type:l.type||l.fieldType,label:l.label,key:l.key||l.fieldKey||l.name,name:l.name||l.fieldKey||l.key};if(h&&(y.hidden=!0),y.id||(y.id=y.key||y.name),y.key||(y.key=y.id||y.name),y.name||(y.name=y.key||y.id),l.isRequired!==void 0&&(y.required=l.isRequired),l.placeholder&&(y.placeholder=l.placeholder),l.options&&Array.isArray(l.options)&&(y.options=l.options),l.apidata&&(y.apidata=l.apidata),g.appearance&&typeof g.appearance=="object"&&!Array.isArray(g.appearance)&&Object.keys(g.appearance).length>0&&(y.appearance=Oc(g.appearance)),g.ui!==void 0&&(y.ui=Oc(g.ui)),g.visibility!==void 0&&(y.visibility=Oc(g.visibility)),m.disabled!==void 0&&(y.disabled=m.disabled),m.readOnly!==void 0&&(y.readOnly=m.readOnly),m.hideLabel!==void 0&&(y.hideLabel=m.hideLabel,y.properties||(y.properties={}),y.properties.hideLabel=m.hideLabel,y.appearance||(y.appearance={}),y.appearance.hideLabel=m.hideLabel),(l.type==="file"||l.fieldType==="file"||l.type==="camera"||l.fieldType==="camera"||l.type==="photoChoice"||l.fieldType==="photoChoice")&&l.validationRules){const E=l.validationRules,C={...m};if(E.fileSize!==void 0&&(C.maxSize=E.fileSize),E.fileType&&Array.isArray(E.fileType)){const O=[];E.fileType.forEach(W=>{const M=W.startsWith(".")?W:`.${W}`;O.push(M),M===".csv"?O.push("text/csv"):M===".xls"?O.push("application/vnd.ms-excel"):M===".xlsx"&&O.push("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")}),C.accept=O}y.metadata=C,C.maxSize!==void 0&&(y.maxSize=C.maxSize),C.accept!==void 0&&(y.accept=C.accept)}else if(m&&Object.keys(m).length>0){if(y.metadata=m,(l.type==="toggle"||l.fieldType==="toggle")&&(m.onValue!==void 0&&(y.onValue=m.onValue),m.offValue!==void 0&&(y.offValue=m.offValue),m.onText!==void 0&&(y.onText=m.onText),m.offText!==void 0&&(y.offText=m.offText)),(l.type==="button"||l.fieldType==="button")&&m.action==="download"&&m.downloadApiEndpoint&&typeof m.downloadApiEndpoint=="string"){let E=m.downloadApiEndpoint;E=E.replace(/\{ctx:([^}]+)\}/g,(C,O)=>{const W=t[O];return W!==void 0?String(W):C}),m.downloadApiEndpoint=E,y.metadata=m,y.downloadApiEndpoint=E}if((l.type==="button"||l.fieldType==="button")&&m.action==="submit"){const E=y.properties||{};m.submitAction!==void 0&&(E.submitAction=m.submitAction),m.submitApiMethod!==void 0&&(E.submitApiMethod=m.submitApiMethod),m.apiBodyStructure!==void 0&&(E.apiBodyStructure=m.apiBodyStructure),m.apiBodyFieldsOnly!==void 0&&(E.apiBodyFieldsOnly=m.apiBodyFieldsOnly),m.apiBodyFieldsOnlyFormat!==void 0&&(E.apiBodyFieldsOnlyFormat=m.apiBodyFieldsOnlyFormat),m.apiBodyFields!==void 0&&(E.apiBodyFields=m.apiBodyFields),m.buttonText!==void 0&&(E.buttonText=m.buttonText),m.action!==void 0&&(E.action=m.action),m.variant!==void 0&&(E.variant=m.variant),m.hideLabel!==void 0&&(E.hideLabel=m.hideLabel),l.apidata&&typeof l.apidata=="object"&&l.apidata.apiEndpoint&&(E.apiEndpoint=l.apidata.apiEndpoint),y.properties=E}if((l.type==="button"||l.fieldType==="button")&&(m.action==="upload"||m.action==="custom")){const E=y.properties||{};m.action!==void 0&&(E.action=m.action),m.buttonText!==void 0&&(E.buttonText=m.buttonText),m.variant!==void 0&&(E.variant=m.variant),m.hideLabel!==void 0&&(E.hideLabel=m.hideLabel),m.uploadAction!==void 0&&(E.uploadAction=m.uploadAction),m.uploadApiEndpoint!==void 0&&(E.uploadApiEndpoint=m.uploadApiEndpoint),m.uploadApiMethod!==void 0&&(E.uploadApiMethod=m.uploadApiMethod),m.apiBodyStructure!==void 0&&(E.apiBodyStructure=m.apiBodyStructure),m.apiBodyFieldsOnly!==void 0&&(E.apiBodyFieldsOnly=m.apiBodyFieldsOnly),m.apiBodyFieldsOnlyFormat!==void 0&&(E.apiBodyFieldsOnlyFormat=m.apiBodyFieldsOnlyFormat),m.apiFieldMapping!==void 0&&(E.apiFieldMapping=m.apiFieldMapping),m.apiQueryParams!==void 0&&(E.apiQueryParams=m.apiQueryParams),m.apiBodyFields!==void 0&&(E.apiBodyFields=m.apiBodyFields),m.apiHeaders!==void 0&&(E.apiHeaders=m.apiHeaders),y.properties=E}if(l.type==="status"||l.fieldType==="status"){const E=y.properties||{};if(m.source!==void 0&&(E.source=m.source),m.statuses!==void 0&&(E.statuses=m.statuses),m.dataPath!==void 0&&(E.dataPath=m.dataPath),m.showStatusText!==void 0&&(E.showStatusText=m.showStatusText),m.statusTextPath!==void 0&&(E.statusTextPath=m.statusTextPath),m.showCurrentIndicator!==void 0&&(E.showCurrentIndicator=m.showCurrentIndicator),l.apidata&&typeof l.apidata=="object"&&l.apidata.apiEndpoint){let C=l.apidata.apiEndpoint;C=C.replace(/\{ctx:([^}]+)\}/g,(O,W)=>{const M=t[W];return M!==void 0?String(M):O}),E.apiEndpoint=C,E.source===void 0&&(E.source="api")}l.apidata?.apiMethod!==void 0&&(E.apiMethod=l.apidata.apiMethod),y.properties=E}if(l.type==="addmore"||l.fieldType==="addmore"){const E=y.properties||{};m.linkedFieldNames!==void 0&&(E.linkedFieldNames=m.linkedFieldNames),m.linkedSectionIds!==void 0&&(E.linkedSectionIds=m.linkedSectionIds),m.linkedFieldAllowDuplicate!==void 0&&(E.linkedFieldAllowDuplicate=m.linkedFieldAllowDuplicate),m.buttonText!==void 0&&(E.buttonText=m.buttonText),m.variant!==void 0&&(E.variant=m.variant),m.size!==void 0&&(E.size=m.size),m.hideLabel!==void 0&&(E.hideLabel=m.hideLabel),y.properties=E}if(l.type==="selectablelist"||l.fieldType==="selectablelist"){const E=y.properties||{};m.submitFieldMapping!==void 0&&(E.submitFieldMapping=m.submitFieldMapping),m.displayFields!==void 0&&(E.displayFields=m.displayFields),m.displayFieldsSeparator!==void 0&&(E.displayFieldsSeparator=m.displayFieldsSeparator),m.dataSourceContextKey!==void 0&&(E.dataSourceContextKey=m.dataSourceContextKey),m.showSelectAll!==void 0&&(E.showSelectAll=m.showSelectAll),m.selectAllByDefault!==void 0&&(E.selectAllByDefault=m.selectAllByDefault),y.properties=E}}l.validationRules&&l.type!=="file"&&l.fieldType!=="file"&&l.type!=="camera"&&l.fieldType!=="camera"&&l.type!=="photoChoice"&&l.fieldType!=="photoChoice"&&l.type!=="status"&&l.fieldType!=="status"&&(y.validationRules=l.validationRules),typeof l.order=="number"&&(y.order=l.order);const S=l,v=Dg(S.position),A=l.metadata&&typeof l.metadata=="object"&&!Array.isArray(l.metadata)?l.metadata:{},x=Dg(S.layout),k={order:typeof S.positionOrder=="number"?S.positionOrder:l.order??p,column:typeof v.column=="number"?v.column:typeof S.positionColumn=="number"?S.positionColumn:1,columnSpan:typeof v.columnSpan=="number"?v.columnSpan:typeof v.width=="number"?v.width:typeof S.positionWidth=="number"?S.positionWidth:1,rowSpan:typeof v.rowSpan=="number"?v.rowSpan:typeof S.positionRowSpan=="number"?S.positionRowSpan:1},N=Oo(v,{cellSlotIndex:S.cellSlotIndex??x.cellSlotIndex,stackSlot:A.stackSlot??x.stackSlot});typeof N=="number"&&(k.cellSlot=N);const T=v.cellGroupId??x.cellGroupId;typeof T=="string"&&(k.cellGroupId=T);const P=Ni(v)??Ni(x)??(A.stackDirection==="horizontal"||x.stackDirection==="horizontal"?"row":A.stackDirection==="vertical"||x.stackDirection==="vertical"?"stack":void 0);return(P==="row"||P==="stack")&&(k.sharedCellLayout=P),y.position=k,l.conditions&&Array.isArray(l.conditions)&&(y.conditions=l.conditions),y}).filter(l=>l!=null).sort((l,p)=>{const g=typeof l.order=="number"?l.order:0,m=typeof p.order=="number"?p.order:0;return g-m}),config:{...s,layout:o,...r.rules&&r.rules.length>0&&{rules:r.rules.map(c)},...r.clientMapping&&Object.keys(r.clientMapping).length>0&&{clientMapping:r.clientMapping}},...r.rules&&r.rules.length>0&&{rules:r.rules.map(c)},createdAt:"",updatedAt:"",moduleId:"",...u?{steps:u}:{}};return ha(f)}function un({className:e,size:t="md",text:r="Loading...",fullScreen:n=!1}){const o={sm:"h-6 w-6",md:"h-12 w-12",lg:"h-16 w-16"},i=d.jsxs("div",{className:"text-center",children:[d.jsx("div",{className:V("animate-spin rounded-full border-b-2 border-blue-600 mx-auto mb-4",o[t],e)}),r&&d.jsx("p",{className:"text-gray-600",children:r})]});return n?d.jsx("div",{className:"min-h-screen bg-gradient-to-br from-blue-50 via-white to-indigo-50 flex items-center justify-center",children:i}):i}function F_(e,t){if(!e?.url)return;let r=e.url;if(r.startsWith("http://")||r.startsWith("https://"))try{const i=new URL(r);r=i.pathname+i.search}catch{}const n=t?.()??{},o={...e.headers||{},"Content-Type":"application/json",...n};return{...e,url:r,headers:o}}const $g=({open:e,onOpenChange:t,title:r,mode:n,loading:o=!1,workflowState:i,formSchema:s,formDefinitionId:a,submissionContext:c={},onWorkflowSubmitResult:u,getAuthHeaders:f})=>{const l=w.useMemo(()=>{if(n==="form"&&s)return s;if(n==="workflow"&&i?.form){const g=Object.fromEntries(Object.entries(c).map(([y,S])=>[y,S==null?"":String(S)])),m=Bg(i,g),h=F_(i.BFF_submit_api,f);return h?{...m,status:"published",BFF_submit_api:h}:m}return null},[n,s,i,c,f]),p=i?.step_blocked_message;return d.jsx(Sg,{open:e,onOpenChange:t,children:d.jsxs(xg,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[r?d.jsx(Ag,{children:d.jsx(Cg,{children:r})}):null,d.jsxs("div",{className:"relative min-h-[12rem]",children:[o&&d.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/60 rounded-md",children:d.jsx(un,{})}),p&&d.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:p}),l?d.jsx(fl,{children:d.jsx($i,{schema:l,submissionContext:c,onWorkflowSubmitResult:u,onClose:()=>t(!1),workflowStepId:i?.current_step_id,omitRootWrapper:!0})}):a&&n==="form"?d.jsx(fl,{children:d.jsx($i,{formId:a,submissionContext:c,onClose:()=>t(!1),omitRootWrapper:!0})}):!o&&d.jsx("p",{className:"text-sm text-muted-foreground",children:n==="workflow"?"No form available for this step.":"Form could not be loaded."})]})]})})},jg=w.createContext(null);function Hg(){return w.useContext(jg)}function Mc(e,t){if(!e?.length||!t)return{};const r={};return e.forEach(n=>{t[n]!==void 0&&(r[n]=t[n])}),r}const Ug=({handlers:e,moduleId:t,submissionContext:r={},getAuthHeaders:n,onParentWorkflowSubmitResult:o,children:i})=>{const[s,a]=w.useState(!1),[c,u]=w.useState(),[f,l]=w.useState("workflow"),[p,g]=w.useState(null),[m,h]=w.useState(null),[y,S]=w.useState(),[v,A]=w.useState({}),[x,F]=w.useState(!1),k=w.useMemo(()=>({...r,...v}),[r,v]),N=w.useCallback(()=>{a(!1),g(null),h(null),S(void 0),A({})},[]),T=w.useCallback(async(W,M)=>{if(!W.workflowId?.trim())throw new Error("workflowId is required for openWorkflowModal");const U=Mc(W.passFields,M);F(!0),u(W.modalTitle),l("workflow"),A(U);try{const z=await e.getWorkflowStateById({workflowId:W.workflowId.trim(),moduleId:t,entryStepId:W.entryStepId?.trim()||void 0,passContext:U});g(z),h(null),S(void 0),a(!0)}finally{F(!1)}},[e,t]),P=w.useCallback(async(W,M)=>{if(!W.formDefinitionId?.trim())throw new Error("formDefinitionId is required for openFormModal");const U=Mc(W.passFields,M);F(!0),u(W.modalTitle),l("form"),A(U),g(null);try{if(e.getFormSchemaById){const z=await e.getFormSchemaById(W.formDefinitionId.trim());h(z),S(void 0)}else h(null),S(W.formDefinitionId.trim());a(!0)}finally{F(!1)}},[e]),E=w.useCallback(async(W,M)=>{const U=M?.workflowId?.trim()||p?.workflow_id||"";if(!U||!W?.trim())throw new Error("workflowId and targetStepId are required for gotoStep");const z={...v,...Mc(void 0,M?.formValues)};F(!0);try{const X=await e.navigateWorkflowStep({workflowId:U,moduleId:t,targetStepId:W.trim(),passContext:z});s?(g(X),l("workflow"),h(null),S(void 0)):o?.(X)}finally{F(!1)}},[e,t,v,s,p?.workflow_id,o]),C=w.useCallback(async W=>{o?.(W);const M=p?.workflow_id;if(M)try{const U=await e.getWorkflowStateById({workflowId:M,moduleId:t,passContext:v});g(U)}catch{}},[e,t,v,o,p?.workflow_id]),O=w.useMemo(()=>({isModalActive:s,openWorkflowModal:T,openFormModal:P,navigateToStep:E}),[s,T,P,E]);return d.jsxs(jg.Provider,{value:O,children:[i,d.jsx($g,{open:s,onOpenChange:W=>{W||N()},title:c,mode:f,loading:x,workflowState:p,formSchema:m,formDefinitionId:y,submissionContext:k,onWorkflowSubmitResult:C,getAuthHeaders:n})]})};function Lc(e,t){if(!t?.length)return e;const r=new Map;for(const o of t){const i=o.name||o.key||o.id;i&&r.set(i,o)}const n={};for(const[o,i]of Object.entries(e)){const s=r.get(o);if(s?.type==="selectablelist"&&Array.isArray(i)&&i.length>0){const a=s.properties,c=s.metadata,u=typeof c=="object"&&c!==null?c:null,f=a?.submitFieldMapping??u?.submitFieldMapping;if(f&&typeof f=="object"&&Object.keys(f).length>0){const l=i.map(p=>{if(p==null||typeof p!="object")return p;const g={};for(const[m,h]of Object.entries(f))m!=null&&m!==""&&h!=null&&h!==""&&(g[m]=We(p,h));return g});n[o]=l;continue}}n[o]=i}return n}function ga(e){return!!(e instanceof File||Array.isArray(e)&&e.length>0&&e[0]instanceof File)}function P_(e){return Object.values(e).some(t=>ga(t))}function I_(e,t){const r=new FormData;let n=!1;return Object.entries(e).forEach(([o,i])=>{const s=t?.[o]||o;i instanceof File?(r.append(s,i),n=!0):Array.isArray(i)&&i.length>0&&i[0]instanceof File?(i.forEach(a=>{r.append(s,a)}),n=!0):i!=null&&(typeof i=="object"?r.append(s,JSON.stringify(i)):r.append(s,String(i)))}),n?r:null}function O_(e,t,r){const n={};let o=!1;return Object.entries(e).forEach(([i,s])=>{const a=t?.[i]||i;if(ga(s)){n[a]=s,o=!0;return}const c=r?.[i]||"string";let u=s;if(c==="number"){const f=Number(s);u=isNaN(f)?s:f}else c==="boolean"?u=s==="true"||s===!0||s==="1"||s===1:c==="date"?u=String(s):s!=null?u=typeof s=="object"?s:String(s):u="";n[a]=u}),{transformed:n,hasFiles:o}}const zg=Object.freeze(Object.defineProperty({__proto__:null,hasFileValues:P_,isFileValue:ga,prepareFormDataWithFiles:I_,transformFormValuesWithFiles:O_},Symbol.toStringTag,{value:"Module"}));function M_(e){if(!e||typeof e!="object")return;const t=e;return(t.mode==="nested_by_section"?"nested_by_section":"flat")==="flat"?{mode:"flat"}:{mode:"nested_by_section",includeUnassignedAtRoot:t.includeUnassignedAtRoot!==!1}}function L_(e){if(!Array.isArray(e))return;const t=[];for(const r of e){if(!r||typeof r!="object")continue;const n=r,o=typeof n.id=="string"&&n.id.trim()?n.id.trim():"",i=typeof n.name=="string"&&n.name.trim()?n.name.trim():"";if(!o||!i)continue;const s=Array.isArray(n.fieldNames)?[...new Set(n.fieldNames.filter(u=>typeof u=="string"&&u.trim().length>0).map(u=>u.trim()))]:[],a=typeof n.payloadKey=="string"&&n.payloadKey.trim()?n.payloadKey.trim():void 0;let c;if(n.fieldPayloadKeys&&typeof n.fieldPayloadKeys=="object"&&!Array.isArray(n.fieldPayloadKeys)){c={};for(const[u,f]of Object.entries(n.fieldPayloadKeys))typeof f=="string"&&f.trim()&&(c[u]=f.trim());Object.keys(c).length===0&&(c=void 0)}t.push({id:o,name:i,fieldNames:s,...n.showBorder===!0?{showBorder:!0}:{},...n.collapsible===!0?{collapsible:!0}:{},...n.defaultCollapsed===!0?{defaultCollapsed:!0}:{},...a?{payloadKey:a}:{},...c?{fieldPayloadKeys:c}:{},...n.heading&&typeof n.heading=="object"?{heading:n.heading}:{}})}return t.length>0?t:void 0}function Dc(e){return e?.mode==="nested_by_section"}function ya(e,t){return!Dc(t)||!e?.length?!1:e.some(r=>!!r.payloadKey?.trim())}function Lo(e){const t=e.payloadKey?.trim();return t||null}function Do(e,t){return t.fieldPayloadKeys?.[e]?.trim()||e}function D_(e,t){if(t?.length)return t.find(r=>r.fieldNames.includes(e))}function B_(e,t){const r={...e};if(!t?.length)return r;for(const n of t){const o=Lo(n);if(!o)continue;const i=e[o];if(i==null||typeof i!="object"||Array.isArray(i))continue;const s=i;for(const a of n.fieldNames){const c=Do(a,n);c in s?r[a]=s[c]:a in s&&(r[a]=s[a])}}return r}function Vg(e,t,r){if(e in r)return r[e];const n=Lo(t);if(!n)return;const o=r[n];if(o==null||typeof o!="object"||Array.isArray(o))return;const i=o,s=Do(e,t);if(s in i)return i[s];if(e in i)return i[e]}function $_(e,t){if(e in t)return t[e]}function Bc(e,t,r,n){if(!Dc(r)||!t?.length)return{...e};const o=new Set([]),i=r?.includeUnassignedAtRoot!==!1,s=new Set,a={};for(const c of t){const u=Lo(c);if(!u)continue;const f={};for(const l of c.fieldNames){if(o.has(l)||!(l in e))continue;s.add(l);const p=Do(l,c);f[p]=e[l]}Object.keys(f).length>0&&(a[u]=f)}if(i)for(const[c,u]of Object.entries(e))o.has(c)||s.has(c)||(a[c]=u);return a}function Wg(e){return e.apiBodyFieldsOnly?(e.submitPayloadSectionIds?.length??0)>0||(e.submitPayloadRootFields?.length??0)>0:!1}function j_(e,t,r){const n=new Set(r.sectionIds??[]),o=new Set(r.rootFieldNames??[]),i={};if(t?.length&&n.size>0)for(const s of t){if(!n.has(s.id))continue;const a=Lo(s);if(a){const c={};for(const u of s.fieldNames){const f=Vg(u,s,e);f!==void 0&&(c[Do(u,s)]=f)}Object.keys(c).length>0&&(i[a]=c)}else for(const c of s.fieldNames){const u=Vg(c,s,e);u!==void 0&&(i[c]=u)}}for(const s of o){const a=$_(s,e);a!==void 0&&(i[s]=a)}return i}function Rg(e,t){return ya(t.formSections,t.submitPayload)?Bc(e,t.formSections,t.submitPayload):t.apiBodyStructure==="flat"?{...e}:{...t.rootExtras??{},data:{...e}}}function H_(e,t,r,n){const o=n.bodyMapping?.[t]??t;if(ya(n.formSections,n.submitPayload)){const s=D_(t,n.formSections),a=s?Lo(s):null;if(a&&s){const c=e[a]!=null&&typeof e[a]=="object"&&!Array.isArray(e[a])?e[a]:{},u=Do(t,s);c[u]=r,e[a]=c;return}e[o]=r;return}if(n.apiBodyStructure==="flat"){e[o]=r;return}const i=e.data!=null&&typeof e.data=="object"&&!Array.isArray(e.data)?e.data:{};i[o]=r,e.data=i}function U_(e,t,r){const n={...e??{}};if(!Dc(r)||!t?.length)return n;for(const o of t){const i=Lo(o);if(i)for(const s of o.fieldNames){if(n[s]?.trim())continue;const a=Do(s,o);n[s]=`${i}.${a}`}}return n}function z_(e,t){return Rg(e,{apiBodyStructure:t.apiBodyStructure,formSections:t.formSections,submitPayload:t.submitPayload})}function V_(e,t,r){return{apiAuth:e?.apiAuth??t?.apiAuth??r?.apiAuth,apiHeaders:e?.apiHeaders??t?.apiHeaders??r?.apiHeaders}}function Kg(e){e.user_id!==void 0&&e.user_id!==null&&(e.context_user_id=e.context_user_id??e.user_id,delete e.user_id);const t=e.data;if(t!=null&&typeof t=="object"&&!Array.isArray(t)&&t.user_id!==void 0&&t.user_id!==null){const r=t;r.context_user_id=r.context_user_id??r.user_id,delete r.user_id}}function W_(e){if(typeof e!="string")return e;const t=e.trim();if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]"))try{return JSON.parse(t)}catch{return e}return e}function $c(e,t,r){if(!t?.length)return Kg(e),e;for(const{key:n,value:o}of t){const i=n?.trim();if(!i||o==null)continue;const s=i==="user_id"?"context_user_id":i;e[s]=W_(r(String(o)))}return Kg(e),e}async function R_(e){const{buttonConfig:t,formSections:r,submitPayload:n,allFields:o,resolveCustomBodyValue:i}=e,s=t.apiBodyFields,a=!!t.apiBodyFieldsOnly,c=o?.length?Lc(e.formValues,o):e.formValues,f=a&&Wg(t)?B_(c,r):c,l=e.transformValues??(async h=>{const{transformFormValuesWithFiles:y}=await Promise.resolve().then(()=>zg),S={...t.apiFieldTypes??{}};o?.length&&o.forEach(A=>{const x=A.name||A.key;x&&(A.type==="terms"||A.type==="checkbox")&&(S[x]="boolean")});const{transformed:v}=y(h,t.apiFieldMapping,S);return{transformed:v}}),{transformed:p}=await l(f);if(a){if(Wg(t)){const y=j_(p,r,{sectionIds:t.submitPayloadSectionIds,rootFieldNames:t.submitPayloadRootFields});return $c(y,s,i)}return s?.length?$c({},s,i):{}}let g=Rg(p,{apiBodyStructure:t.apiBodyStructure,formSections:r,submitPayload:n});const m=t.apiFieldMapping;if(!ya(r,n)&&m){const h={};Object.keys(g).forEach(y=>{h[m[y]||y]=g[y]}),g=h}return $c(g,s,i)}function K_(e){return e==="null"?null:e==="true"?!0:e==="false"?!1:e}function G_(e){const t=e,r=typeof t?.status=="string"?t.status.toLowerCase():null;if(r&&r!=="success")return!1;const n=t?.code;return!(typeof n=="number"&&(n<200||n>=300))}function q_(e,t){if(!t)return[];const r=e.trim().split(".");if(r.length<2)return[];const n=r[0],o=r.slice(1).join("."),i=[];return Object.entries(t).forEach(([s,a])=>{const c=s===n,u=s.startsWith(`${n}__addmore__`);if(!c&&!u||!G_(a))return;const f=We(a,o);f==null||f===""||i.push(f)}),i}function jc(e,t,r,n){const o=V_(e,t,r);return nk(o,{formValues:n.formValues,urlParams:n.urlParams,submissionContext:n.submissionContext})}function Gg(e,t,r){Object.entries(t).forEach(([n,o])=>{n.toLowerCase()==="content-type"&&r instanceof FormData||(e[n]=o)})}function Hc(e,t,r,n,o,i){const s=e.trim().match(/^\{respAll:([^}]+)\}$/);if(s){const u=(s[1]||"").trim(),f=u.split("."),l=f.length>=2?f.slice(1).join("."):"";return(l==="data.id"||l==="data.documentId")&&n?.document_ids!=null&&Array.isArray(n.document_ids)?n.document_ids:q_(u,o)}const a=e.trim().match(/^\{(\w+)\}$/);if(a){const u=a[1],f=t[u];if(f!==void 0)return f;const l=Object.keys(t).find(p=>p.toLowerCase()===u.toLowerCase());if(l)return t[l]}const c=Rr(e,t,r,n,o,i);return K_(String(c))}const Y_=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:c,onClick:u,onSubmit:f,onReset:l,onCancel:p,isSubmitting:g=!1,formValues:m={},submissionContext:h,bffSubmitApi:y,onBffSubmitResult:S,extraSubmitPayload:v,buttonResponses:A,onButtonApiResponse:x,onValidateForm:F,getValidationErrors:k,allFields:N,onSubmittingChange:T,scopedFormValues:P,scopedFieldNameMap:E,prepopulateResponse:C=null,formSections:O,submitPayload:W})=>{const{gridStretch:M}=ti(),U=Hg(),z=as(),[X,B]=w.useState(!1),L=e.properties,D=Va.useParams(),K=w.useMemo(()=>({...h,...v}),[h,v]),le=w.useMemo(()=>{if(!P||!E||Object.keys(E).length===0)return m;const he={};return Object.entries(P).forEach(([we,J])=>{const $=E[we]||we;$!==e.name&&(he[$]=J)}),he},[P,E,m,e.name]),H=(()=>{try{const he=e.metadata;if(typeof he=="string")return JSON.parse(he);if(he&&typeof he=="object")return he}catch{}return null})(),ce=e.apidata??null,ie=L?.submitAction??H?.submitAction,G=L?.apiEndpoint??e.apidata?.apiEndpoint??H?.apiEndpoint;let ee=L?.action||H?.action;!ee&&e.type==="button"&&(ee="submit");const Ae=L?.variant||"default",te=L?.size||"default",oe=L?.hideLabel??e.appearance?.hideLabel??!1,me=L?.buttonText||e.label||"Button",Me=L?.closeOnCancel??!0,De=async()=>{if(P&&E&&Object.keys(E).length>0||!F)return!0;const he=await F();if(!he&&k)try{const we=k();at.toast.error(pa(we,N??void 0)||"Please fix the errors before submitting.")}catch{at.toast.error("Please fix the errors before submitting.")}return he},ne=async he=>{he.preventDefault();const we=ee==="submit"?"submit":ee;if(ee==="next"){await Pc(N??void 0,z);return}if(ee==="prev"){h_(z);return}if(ee==="saveAndNext"){if(!(L?.uploadApiEndpoint||H?.uploadApiEndpoint||e.uploadApiEndpoint)?.trim()){at.toast.error("API endpoint is not configured for Save & Next.");return}if(!await De())return;B(!0);try{const $=await yt();x?.(e.name,$),Tg($)||Ng($,"Saved successfully."),await Pc(N??void 0,z)}catch($){x?.(e.name,{status:"error",code:$?.response?.code??$?.response?.status??null,message:Kr($)}),ua($,"Failed to save. Please check the API endpoint and try again.",Kr)}finally{B(!1)}return}if(ee==="openWorkflowModal"){const J=L?.workflowId??H?.workflowId;if(!U){at.toast.error("Workflow modal is not configured for this form.");return}if(!J?.trim()){at.toast.error("Workflow is not configured for this button.");return}B(!0);try{await U.openWorkflowModal({workflowId:J.trim(),entryStepId:L?.entryStepId??H?.entryStepId,modalTitle:L?.modalTitle??H?.modalTitle??e.label,passFields:L?.passFields??H?.passFields},le)}catch($){at.toast.error(Kr($))}finally{B(!1)}return}if(ee==="openFormModal"){const J=L?.formDefinitionId??H?.formDefinitionId;if(!U){at.toast.error("Form modal is not configured for this form.");return}if(!J?.trim()){at.toast.error("Form is not configured for this button.");return}B(!0);try{await U.openFormModal({formDefinitionId:J.trim(),modalTitle:L?.modalTitle??H?.modalTitle??e.label,passFields:L?.passFields??H?.passFields},le)}catch($){at.toast.error(Kr($))}finally{B(!1)}return}if(ee==="gotoStep"){const J=L?.targetStepId??H?.targetStepId;if(!U){at.toast.error("Step navigation is not configured for this form.");return}if(!J?.trim()){at.toast.error("Target step is not configured for this button.");return}const $=L?.workflowId??H?.workflowId??y?.payload?.workflow_id;B(!0);try{await U.navigateToStep(J.trim(),{workflowId:typeof $=="string"?$:void 0,formValues:le})}catch(fe){at.toast.error(Kr(fe))}finally{B(!1)}return}if(we==="submit"){if(m_(z)){await Pc(N??void 0,z);return}if(y?.url){if(!await De())return;B(!0),T?.(!0);try{const J=await Se(),$=(J?.message??J?.display_message??"Form submitted successfully!").trim();at.toast.success($||"Form submitted successfully!");const fe=J!=null&&typeof J=="object"?J:{status:"success",...J!=null?{data:J}:{}};x?.(e.name,fe)}catch(J){const $=Kr(J);at.toast.error($)}finally{B(!1),T?.(!1)}return}if(f){if(!await De())return;B(!0),T?.(!0);try{await f(),x?.(e.name,{status:"success"})}finally{B(!1),T?.(!1)}return}at.toast.error("Submit not configured. BFF submit API is required for submit buttons.");return}else if(ee==="reset"&&l)l();else if(ee==="cancel")Me?p&&p():l&&l();else if(ee==="download"){const J=L?.downloadApiEndpoint||H?.downloadApiEndpoint||e.downloadApiEndpoint,$=L?.downloadApiMethod||H?.downloadApiMethod||e.downloadApiMethod;if(J){B(!0);try{const fe=$||"GET",ze=Mr(Rr(J,le,D,K,A,C??void 0)),Fe={method:fe,headers:{}};fe!=="GET"&&fe!=="DELETE"&&(Fe.headers={"Content-Type":"application/json"}),Gg(Fe.headers,jc(L,H,ce,{formValues:le,urlParams:D,submissionContext:K}));const He=await fetch(ze,Fe);if(!He.ok)throw new Error(`Download failed: ${He.statusText}`);const st=await He.blob(),ht=window.URL.createObjectURL(st),lt=document.createElement("a");lt.href=ht;const ct=He.headers.get("Content-Disposition");let nt="download";if(ct){const ot=ct.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);ot&&ot[1]&&(nt=ot[1].replace(/['"]/g,""))}lt.download=nt,document.body.appendChild(lt),lt.click(),document.body.removeChild(lt),window.URL.revokeObjectURL(ht);try{const ot=u_(He);at.toast.success(ot&&ot.trim()?ot:"Download started.")}catch{at.toast.success("Download started.")}}catch(fe){ua(fe,"Failed to download file. Please check the API endpoint and try again.",Kr)}finally{B(!1)}}else at.toast.error("Download endpoint is not configured")}else if(ee==="upload"||ee==="custom"){const J=ee==="custom",$=J?"api":L?.uploadAction||H?.uploadAction||"database";if($==="database")if(f){B(!0);try{await f(he)}catch(fe){throw fe}finally{B(!1)}}else at.toast.error("Form submit handler is not available");else if($==="api"){const fe=L?.uploadApiEndpoint||H?.uploadApiEndpoint||e.uploadApiEndpoint;if(L?.uploadApiMethod||H?.uploadApiMethod||e.uploadApiMethod,fe){if(!await De())return;B(!0);try{const ze=await yt();x?.(e.name,ze),Ng(ze,J?"Custom API call completed successfully!":"Upload completed successfully!")}catch(ze){x?.(e.name,{status:"error",code:ze?.response?.code??ze?.response?.status??null,message:Kr(ze)}),ua(ze,J?"Failed to call custom API. Please check the API endpoint and try again.":"Failed to upload. Please check the API endpoint and try again.",Kr)}finally{B(!1)}}else at.toast.error(J?"Custom API endpoint is not configured":"Upload endpoint is not configured")}else $==="custom"&&at.toast.info("Custom upload handler is not implemented")}else u?u():r&&t!==void 0&&r(t||"");n?.()},ge=async()=>{if(!ie||ie!=="api"||!G)return null;const he=L?.apiBodyFields??H?.apiBodyFields,we=L?.apiBodyFieldsOnly??H?.apiBodyFieldsOnly??!1,J=L?.apiFieldMapping??H?.apiFieldMapping,$=L?.apiFieldTypes??H?.apiFieldTypes,fe=L?.apiBodyStructure??H?.apiBodyStructure;return R_({formValues:le,buttonConfig:{apiBodyFieldsOnly:we,apiBodyFields:he,apiBodyStructure:fe,apiFieldMapping:J,apiFieldTypes:$,submitPayloadSectionIds:L?.submitPayloadSectionIds??H?.submitPayloadSectionIds,submitPayloadRootFields:L?.submitPayloadRootFields??H?.submitPayloadRootFields},formSections:O,submitPayload:W,allFields:N,resolveCustomBodyValue:ze=>Hc(ze,le,D,K,A,C??void 0)})},Se=async()=>{if(!y||!y.url)throw new Error("BFF submit API configuration is missing");const he=N?.length?Lc(m,N):m,we={};Object.keys(he).forEach(Je=>{const ut=e.name===Je&&e.type==="button",Ye=Je.toLowerCase().includes("button");!ut&&!Ye&&(we[Je]=he[Je])});const J=Object.keys(we).filter(Je=>ga(we[Je]));J.forEach(Je=>{we[Je]=""});const $=Bc(we,O,W),fe={workflow_id:y.payload?.workflow_id||"",current_step_id:y.payload?.current_step_id||"",form_data:$},ze=y.payload?.context_user_id??y.payload?.user_id;ze!=null&&String(ze).trim()!==""&&(fe.context_user_id=String(ze).trim());const Fe=["workflow_id","current_step_id","form_data","submit_body","submit_api_endpoint","submit_api_method"];if(h&&typeof h=="object"&&Object.entries(h).forEach(([Je,ut])=>{if(ut==null||Fe.includes(Je))return;const Ye=Je==="user_id"?"context_user_id":Je;fe[Ye]=fe[Ye]??ut}),v&&typeof v=="object"&&Object.entries(v).forEach(([Je,ut])=>{if(ut==null||Fe.includes(Je))return;const Ye=Je==="user_id"?"context_user_id":Je;fe[Ye]=fe[Ye]??ut}),ie==="api"&&G){let Je=Rr(G,le,D,K,A,C??void 0);Je=Je.replace(/\{([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\}/gi,"$1"),Je=Mr(Je),fe.submit_api_endpoint=Je,fe.submit_api_method=L?.submitApiMethod||H?.submitApiMethod||"POST";const ut=jc(L,H,ce,{formValues:le,urlParams:D,submissionContext:K});Object.keys(ut).length>0&&(fe.submit_api_headers=ut);try{const Ye=await ge();if(Ye){const nr=L?.apiBodyStructure??H?.apiBodyStructure,br=L?.apiFieldMapping??H?.apiFieldMapping;J.forEach(vr=>{const Nt=we[vr]!==void 0&&typeof we[vr]=="string"?we[vr]:"";H_(Ye,vr,Nt,{apiBodyStructure:nr,bodyMapping:br,formSections:O,submitPayload:W})}),fe.submit_body=Ye}}catch{}}const He=(y.method||"POST").toUpperCase(),st=J.length>0,ht=fe.submit_api_endpoint??G??"",lt=typeof ht=="string"?ht.toLowerCase():"",ct=lt.includes("/upload")||lt.includes("/payments")||lt.includes("/bulk-upload"),nt=st&&ct;let ot;const ar={...y.headers||{}};if(nt){const Je=new FormData;Je.append("payload",JSON.stringify(fe));for(const ut of J){const Ye=he[ut],nr=L?.apiFieldMapping?.[ut]??ut;Ye instanceof File?Je.append(nr,Ye):Array.isArray(Ye)&&Ye.length>0&&Ye[0]instanceof File&&Ye.forEach(br=>Je.append(nr,br))}ot=Je,delete ar["content-type"],delete ar["Content-Type"]}else ar["Content-Type"]="application/json",ot=JSON.stringify(fe);const vt=await fetch(y.url,{method:He,headers:ar,body:ot});if(!vt.ok){let Je;const ut=await vt.text();try{Je=JSON.parse(ut)}catch{Je={message:ut}}const Ye=new Error(`BFF submission failed: ${vt.status}`);throw Ye.response=Je,Ye}const er=await vt.json();return S?.(er),f&&await f(),er},yt=async()=>{const he=L?.uploadApiEndpoint||H?.uploadApiEndpoint;if(!he)throw new Error("Upload API endpoint is not configured");if(!L)throw new Error("Button properties are not configured");const we=(L.uploadApiMethod||"POST").toUpperCase(),J=Mr(Rr(he,le,D,K,A,C??void 0)),$=L.apiBodyFieldsOnly??H?.apiBodyFieldsOnly??!1,fe=L.apiBodyFieldsOnlyFormat??H?.apiBodyFieldsOnlyFormat??"json";let ze={},Fe;const He={};if($&&L.apiBodyFields&&L.apiBodyFields.length>0)if(L.apiBodyFields.forEach(({key:lt,value:ct})=>{ze[lt]=Hc(ct,le,D,K,A,C??void 0)}),fe==="multipart"){const lt=new FormData;Object.entries(ze).forEach(([ct,nt])=>{if(nt instanceof File){lt.append(ct,nt);return}if(Array.isArray(nt)&&nt.length>0&&nt[0]instanceof File){nt.forEach(ot=>lt.append(ct,ot));return}nt!=null&<.append(ct,typeof nt=="object"?JSON.stringify(nt):String(nt))}),Fe=lt}else Fe=JSON.stringify(ze),He["Content-Type"]="application/json";else{const lt=le,{transformFormValuesWithFiles:ct,prepareFormDataWithFiles:nt,hasFileValues:ot}=await Promise.resolve().then(()=>zg),{transformed:ar,hasFiles:vt}=ct(lt,L.apiFieldMapping,L.apiFieldTypes),er=L.apiBodyStructure??H?.apiBodyStructure??"nested",Je=L.apiFieldMapping??H?.apiFieldMapping;if(ze=z_(ar,{apiBodyStructure:er,formSections:O,submitPayload:W}),!ya(O,W)&&Je){const ut={};Object.keys(ze).forEach(Ye=>{const nr=Je[Ye]||Ye;ut[nr]=ze[Ye]}),ze=ut}if(L.apiBodyFields&&L.apiBodyFields.forEach(({key:ut,value:Ye})=>{ze[ut]=Hc(Ye,le,D,K,A,C??void 0)}),vt||ot(ze)){const ut=nt(ze,L.apiFieldMapping);ut?Fe=ut:(Fe=JSON.stringify(ze),He["Content-Type"]="application/json")}else Fe=JSON.stringify(ze),He["Content-Type"]="application/json"}Gg(He,jc(L,H,ce,{formValues:le,urlParams:D,submissionContext:K}),Fe);let st=J;if(L.apiQueryParams&&L.apiQueryParams.length>0){const lt=new URLSearchParams;L.apiQueryParams.forEach(({key:ct,value:nt})=>{const ot=Rr(nt,le,D,K,A,C??void 0);lt.append(ct,ot)}),st=`${J}?${lt.toString()}`}const ht=await fetch(st,{method:we,headers:He,body:we!=="GET"?Fe:void 0});if(!ht.ok){let lt;const ct=await ht.text();try{lt=JSON.parse(ct)}catch{lt={message:ct}}const nt=new Error(`Upload failed: ${ht.status}`);throw nt.response=lt,nt}try{return await ht.json()}catch{return{}}},kt=ee==="submit"?"submit":ee,It=kt==="submit"?"button":kt==="submit"?"submit":kt==="reset"?"reset":"button",Er=i||e.disabled||s||e.readOnly||X||kt==="submit"&&g,Dt=me,sr=po(e),zt=Fr(e.appearance)==="stretch";return d.jsx(Ct,{field:e,error:o,isRequired:a,className:c,hideLabel:oe,children:d.jsx("div",{className:V(M&&!sr&&"flex w-full min-w-0 flex-col",M&&sr&&"min-w-0 shrink-0"),children:d.jsxs(Qt,{id:ft(e),type:It,variant:Ae,size:te,disabled:Er,onClick:ne,className:V(e.appearance?.className,M&&!sr&&"w-full min-w-0 shrink-0",M&&sr&&!zt&&"inline-flex w-auto max-w-full shrink-0",M&&sr&&zt&&"inline-flex w-full min-w-0 max-w-full shrink-0"),children:[X&&d.jsx("span",{className:"inline-block h-4 w-4 shrink-0 animate-spin rounded-full border-2 border-current border-t-transparent mr-2","aria-hidden":!0}),Dt]})})})},X_=({field:e,disabled:t,readOnly:r,isRequired:n,className:o,buttonResponses:i,onButtonApiResponse:s})=>{const a=e.properties,c=a?.buttonText??e.label??"Edit",u=a?.variant??"outline",f=a?.size??"default",l=a?.hideLabel??e.appearance?.hideLabel??!1,p=e.name||e.key||e.id,g=ri(i?.[p]),m=t||e.disabled||r||e.readOnly||g,h=y=>{y.preventDefault(),!m&&s?.(p,{status:"success"})};return d.jsx(Ct,{field:e,error:void 0,isRequired:n,className:o,hideLabel:l,children:d.jsx(Qt,{id:ft(e),type:"button",variant:u,size:f,disabled:m,onClick:h,className:V(e.appearance?.className,(!po(e)||Fr(e.appearance)==="stretch")&&"w-full min-w-0"),children:c})})},J_=({field:e,error:t,disabled:r,readOnly:n,isRequired:o,className:i,onAddMore:s})=>{const a=e.properties||{},c=a.variant||"outline",u=a.size||"default",f=a.buttonText||e.label||"Add More",l=a.hideLabel??e.appearance?.hideLabel??!1,p=r||n||e.disabled||e.readOnly;return d.jsx(Ct,{field:e,error:t,isRequired:o,className:i,hideLabel:l,children:d.jsxs(Qt,{id:ft(e),type:"button",variant:c,size:u,disabled:!!p,onClick:s,className:V("w-fit",e.appearance?.className),children:[d.jsx(nf,{className:"h-4 w-4 mr-1"}),f]})})},qg=w.createContext(null);function Q_({value:e,children:t}){return d.jsx(qg.Provider,{value:e,children:t})}function Z_(){return w.useContext(qg)}function Yg(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(0,t):e}function Fi(e){return e.name||e.key||e.id}function Uc(e){return e.filter(t=>!t.parentId&&t.type==="sectionHeading"&&Fi(t))}function eT(e){if(e.type!=="sectionHeading")return[];const t=e.properties||{};return Array.isArray(t.linkedFieldNames)?t.linkedFieldNames.filter(r=>typeof r=="string"&&r.trim().length>0):[]}function tT(e){const t=new Map;for(const r of Uc(e)){const n=Fi(r);for(const o of eT(r))t.set(o,n)}return t}function rT(e,t){const r=t.properties||{},n=Array.isArray(r.sectionHeadingNames)?r.sectionHeadingNames.filter(s=>typeof s=="string"&&s.trim()):[],o=Uc(e);if(n.length===0)return o;const i=new Set(n);return o.filter(s=>i.has(Fi(s)))}function nT(e){const t={};for(const r of Uc(e))t[Fi(r)]=!0;for(const r of e){if(r.type!=="customizeSections")continue;const n=r.properties||{};for(const o of n.defaultHiddenSectionNames??[])typeof o=="string"&&o.trim()&&(t[o.trim()]=!1)}return t}function Xg(e,t,r,n){if(!e||t==="customizeSections")return!0;const o=Yg(e),i=t==="sectionHeading"?o:n.get(o);return i?r[i]!==!1:!0}const oT=({field:e,error:t,disabled:r,readOnly:n,isRequired:o,className:i,designMode:s=!1})=>{const a=Z_(),c=e.properties||{},u=c.variant||"outline",f=c.size||"default",l=c.buttonText||e.label||"Customise sections",p=c.menuTitle||"VISIBLE SECTIONS",g=c.hideLabel??e.appearance?.hideLabel??!1,m=r||n||e.disabled||e.readOnly,h=w.useMemo(()=>a?.allFields?.length?rT(a.allFields,e):[],[a?.allFields,e]);return d.jsx(Ct,{field:e,error:t,isRequired:o,className:i,hideLabel:g,children:d.jsxs(uc,{children:[d.jsx(oh,{asChild:!0,children:d.jsxs(Qt,{id:ft(e),type:"button",variant:u,size:f,disabled:!!m,className:V("w-fit gap-2",e.appearance?.className),children:[d.jsx(AS,{className:"h-4 w-4"}),l]})}),d.jsxs(fc,{align:"end",className:"w-64 p-0",children:[d.jsx("div",{className:"px-3 py-2 border-b",children:d.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:p})}),d.jsx("div",{className:"max-h-64 overflow-auto p-2 space-y-1",children:h.length===0?d.jsx("p",{className:"text-xs text-muted-foreground px-1 py-2",children:"No section headings on this form."}):h.map(y=>{const S=Fi(y),v=y.label||S,A=s||!a?!0:a.visibility[S]!==!1;return d.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md px-1 py-1.5 hover:bg-muted/50",children:[d.jsx(Pn,{htmlFor:`ui-section-${e.id}-${S}`,className:"text-xs font-normal truncate",children:v}),d.jsx($h,{id:`ui-section-${e.id}-${S}`,checked:A,disabled:s||!a||!!m,onCheckedChange:x=>{!a||s||a.setSectionVisible(S,!!x)}})]},y.id)})})]})]})})},iT=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:c})=>{const u=e.properties,f=u?.max||5,l=u?.icon||"star",p=h=>{i||s||e.disabled||e.readOnly||(r(h),n?.())},g=h=>{},m=h=>{const y=t>=h+1,S=V("transition-colors cursor-pointer",y?"fill-yellow-400 text-yellow-400":"text-muted-foreground",(i||s||e.disabled||e.readOnly)&&"cursor-not-allowed opacity-50",!(i||s||e.disabled||e.readOnly)&&"hover:text-yellow-400");return l==="star"?d.jsx(of,{className:V(S,"h-6 w-6"),onClick:()=>p(h+1),onMouseEnter:()=>g()},h):d.jsx(of,{className:V(S,"h-6 w-6"),onClick:()=>p(h+1),onMouseEnter:()=>g()},h)};return d.jsx(Ct,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{id:ft(e),className:"flex items-center gap-1",role:"radiogroup","aria-label":e.label,"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,children:[Array.from({length:f},(h,y)=>m(y)),u?.showValue!==!1&&d.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:t>0?t:""})]})})};var Jg=["PageUp","PageDown"],Qg=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Zg={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Bo="Slider",[zc,sT,aT]=Fl(Bo),[ey]=Sr(Bo,[aT]),[lT,ba]=ey(Bo),ty=b.forwardRef((e,t)=>{const{name:r,min:n=0,max:o=100,step:i=1,orientation:s="horizontal",disabled:a=!1,minStepsBetweenThumbs:c=0,defaultValue:u=[n],value:f,onValueChange:l=()=>{},onValueCommit:p=()=>{},inverted:g=!1,form:m,...h}=e,y=b.useRef(new Set),S=b.useRef(0),A=s==="horizontal"?cT:dT,[x=[],F]=ln({prop:f,defaultProp:u,onChange:C=>{[...y.current][S.current]?.focus(),l(C)}}),k=b.useRef(x);function N(C){const O=hT(x,C);E(C,O)}function T(C){E(C,S.current)}function P(){const C=k.current[S.current];x[S.current]!==C&&p(x)}function E(C,O,{commit:W}={commit:!1}){const M=vT(i),U=wT(Math.round((C-n)/i)*i+n,M),z=hi(U,[n,o]);F((X=[])=>{const B=pT(X,z,O);if(bT(B,c*i)){S.current=B.indexOf(z);const L=String(B)!==String(X);return L&&W&&p(B),L?B:X}else return X})}return d.jsx(lT,{scope:e.__scopeSlider,name:r,disabled:a,min:n,max:o,valueIndexToChangeRef:S,thumbs:y.current,values:x,orientation:s,form:m,children:d.jsx(zc.Provider,{scope:e.__scopeSlider,children:d.jsx(zc.Slot,{scope:e.__scopeSlider,children:d.jsx(A,{"aria-disabled":a,"data-disabled":a?"":void 0,...h,ref:t,onPointerDown:Oe(h.onPointerDown,()=>{a||(k.current=x)}),min:n,max:o,inverted:g,onSlideStart:a?void 0:N,onSlideMove:a?void 0:T,onSlideEnd:a?void 0:P,onHomeKeyDown:()=>!a&&E(n,0,{commit:!0}),onEndKeyDown:()=>!a&&E(o,x.length-1,{commit:!0}),onStepKeyDown:({event:C,direction:O})=>{if(!a){const U=Jg.includes(C.key)||C.shiftKey&&Qg.includes(C.key)?10:1,z=S.current,X=x[z],B=i*U*O;E(X+B,z,{commit:!0})}}})})})})});ty.displayName=Bo;var[ry,ny]=ey(Bo,{startEdge:"left",endEdge:"right",size:"width",direction:1}),cT=b.forwardRef((e,t)=>{const{min:r,max:n,dir:o,inverted:i,onSlideStart:s,onSlideMove:a,onSlideEnd:c,onStepKeyDown:u,...f}=e,[l,p]=b.useState(null),g=qe(t,A=>p(A)),m=b.useRef(void 0),h=vo(o),y=h==="ltr",S=y&&!i||!y&&i;function v(A){const x=m.current||l.getBoundingClientRect(),F=[0,x.width],N=Rc(F,S?[r,n]:[n,r]);return m.current=x,N(A-x.left)}return d.jsx(ry,{scope:e.__scopeSlider,startEdge:S?"left":"right",endEdge:S?"right":"left",direction:S?1:-1,size:"width",children:d.jsx(oy,{dir:h,"data-orientation":"horizontal",...f,ref:g,style:{...f.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:A=>{const x=v(A.clientX);s?.(x)},onSlideMove:A=>{const x=v(A.clientX);a?.(x)},onSlideEnd:()=>{m.current=void 0,c?.()},onStepKeyDown:A=>{const F=Zg[S?"from-left":"from-right"].includes(A.key);u?.({event:A,direction:F?-1:1})}})})}),dT=b.forwardRef((e,t)=>{const{min:r,max:n,inverted:o,onSlideStart:i,onSlideMove:s,onSlideEnd:a,onStepKeyDown:c,...u}=e,f=b.useRef(null),l=qe(t,f),p=b.useRef(void 0),g=!o;function m(h){const y=p.current||f.current.getBoundingClientRect(),S=[0,y.height],A=Rc(S,g?[n,r]:[r,n]);return p.current=y,A(h-y.top)}return d.jsx(ry,{scope:e.__scopeSlider,startEdge:g?"bottom":"top",endEdge:g?"top":"bottom",size:"height",direction:g?1:-1,children:d.jsx(oy,{"data-orientation":"vertical",...u,ref:l,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:h=>{const y=m(h.clientY);i?.(y)},onSlideMove:h=>{const y=m(h.clientY);s?.(y)},onSlideEnd:()=>{p.current=void 0,a?.()},onStepKeyDown:h=>{const S=Zg[g?"from-bottom":"from-top"].includes(h.key);c?.({event:h,direction:S?-1:1})}})})}),oy=b.forwardRef((e,t)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:o,onSlideEnd:i,onHomeKeyDown:s,onEndKeyDown:a,onStepKeyDown:c,...u}=e,f=ba(Bo,r);return d.jsx($e.span,{...u,ref:t,onKeyDown:Oe(e.onKeyDown,l=>{l.key==="Home"?(s(l),l.preventDefault()):l.key==="End"?(a(l),l.preventDefault()):Jg.concat(Qg).includes(l.key)&&(c(l),l.preventDefault())}),onPointerDown:Oe(e.onPointerDown,l=>{const p=l.target;p.setPointerCapture(l.pointerId),l.preventDefault(),f.thumbs.has(p)?p.focus():n(l)}),onPointerMove:Oe(e.onPointerMove,l=>{l.target.hasPointerCapture(l.pointerId)&&o(l)}),onPointerUp:Oe(e.onPointerUp,l=>{const p=l.target;p.hasPointerCapture(l.pointerId)&&(p.releasePointerCapture(l.pointerId),i(l))})})}),iy="SliderTrack",sy=b.forwardRef((e,t)=>{const{__scopeSlider:r,...n}=e,o=ba(iy,r);return d.jsx($e.span,{"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation,...n,ref:t})});sy.displayName=iy;var Vc="SliderRange",ay=b.forwardRef((e,t)=>{const{__scopeSlider:r,...n}=e,o=ba(Vc,r),i=ny(Vc,r),s=b.useRef(null),a=qe(t,s),c=o.values.length,u=o.values.map(p=>dy(p,o.min,o.max)),f=c>1?Math.min(...u):0,l=100-Math.max(...u);return d.jsx($e.span,{"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,...n,ref:a,style:{...e.style,[i.startEdge]:f+"%",[i.endEdge]:l+"%"}})});ay.displayName=Vc;var Wc="SliderThumb",ly=b.forwardRef((e,t)=>{const r=sT(e.__scopeSlider),[n,o]=b.useState(null),i=qe(t,a=>o(a)),s=b.useMemo(()=>n?r().findIndex(a=>a.ref.current===n):-1,[r,n]);return d.jsx(uT,{...e,ref:i,index:s})}),uT=b.forwardRef((e,t)=>{const{__scopeSlider:r,index:n,name:o,...i}=e,s=ba(Wc,r),a=ny(Wc,r),[c,u]=b.useState(null),f=qe(t,v=>u(v)),l=c?s.form||!!c.closest("form"):!0,p=bi(c),g=s.values[n],m=g===void 0?0:dy(g,s.min,s.max),h=mT(n,s.values.length),y=p?.[a.size],S=y?gT(y,m,a.direction):0;return b.useEffect(()=>{if(c)return s.thumbs.add(c),()=>{s.thumbs.delete(c)}},[c,s.thumbs]),d.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${m}% + ${S}px)`},children:[d.jsx(zc.ItemSlot,{scope:e.__scopeSlider,children:d.jsx($e.span,{role:"slider","aria-label":e["aria-label"]||h,"aria-valuemin":s.min,"aria-valuenow":g,"aria-valuemax":s.max,"aria-orientation":s.orientation,"data-orientation":s.orientation,"data-disabled":s.disabled?"":void 0,tabIndex:s.disabled?void 0:0,...i,ref:f,style:g===void 0?{display:"none"}:e.style,onFocus:Oe(e.onFocus,()=>{s.valueIndexToChangeRef.current=n})})}),l&&d.jsx(cy,{name:o??(s.name?s.name+(s.values.length>1?"[]":""):void 0),form:s.form,value:g},n)]})});ly.displayName=Wc;var fT="RadioBubbleInput",cy=b.forwardRef(({__scopeSlider:e,value:t,...r},n)=>{const o=b.useRef(null),i=qe(o,n),s=vi(t);return b.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"value").set;if(s!==t&&f){const l=new Event("input",{bubbles:!0});f.call(a,t),a.dispatchEvent(l)}},[s,t]),d.jsx($e.input,{style:{display:"none"},...r,ref:i,defaultValue:t})});cy.displayName=fT;function pT(e=[],t,r){const n=[...e];return n[r]=t,n.sort((o,i)=>o-i)}function dy(e,t,r){const i=100/(r-t)*(e-t);return hi(i,[0,100])}function mT(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function hT(e,t){if(e.length===1)return 0;const r=e.map(o=>Math.abs(o-t)),n=Math.min(...r);return r.indexOf(n)}function gT(e,t,r){const n=e/2,i=Rc([0,50],[0,n]);return(n-i(t)*r)*r}function yT(e){return e.slice(0,-1).map((t,r)=>e[r+1]-t)}function bT(e,t){if(t>0){const r=yT(e);return Math.min(...r)>=t}return!0}function Rc(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const n=(t[1]-t[0])/(e[1]-e[0]);return t[0]+n*(r-e[0])}}function vT(e){return(String(e).split(".")[1]||"").length}function wT(e,t){const r=Math.pow(10,t);return Math.round(e*r)/r}var ST=ty,xT=sy,AT=ay,CT=ly;function ET({className:e,defaultValue:t,value:r,min:n=0,max:o=100,...i}){const s=b.useMemo(()=>Array.isArray(r)?r:Array.isArray(t)?t:[n,o],[r,t,n,o]);return d.jsxs(ST,{"data-slot":"slider",defaultValue:t,value:r,min:n,max:o,className:V("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",e),...i,children:[d.jsx(xT,{"data-slot":"slider-track",className:V("bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"),children:d.jsx(AT,{"data-slot":"slider-range",className:V("bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")})}),Array.from({length:s.length},(a,c)=>d.jsx(CT,{"data-slot":"slider-thumb",className:"border-primary bg-background ring-ring/50 block size-4 shrink-0 rounded-full border shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"},c))]})}const kT=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:c})=>{const u=e.properties,f=u?.min??0,l=u?.max??100,p=u?.step??1,g=u?.showValue!==!1,m=u?.marks||[],h=S=>{i||s||e.disabled||e.readOnly||(r(S[0]??f),n?.())},y=t??f;return d.jsx(Ct,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[g&&d.jsx("span",{className:"text-sm font-medium",children:y}),!g&&d.jsx("span",{className:"text-sm text-muted-foreground",children:f}),!g&&d.jsx("span",{className:"text-sm text-muted-foreground",children:l})]}),d.jsx(ET,{id:ft(e),value:[y],onValueChange:h,min:f,max:l,step:p,disabled:i||e.disabled||s||e.readOnly,className:V("w-full",o&&"border-destructive",e.appearance?.className),"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a}),m.length>0&&d.jsx("div",{className:"flex justify-between text-xs text-muted-foreground",children:m.map((S,v)=>d.jsx("span",{className:"text-center",children:S.label},v))})]})})},NT=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:c})=>{const u=w.useRef(null),[f,l]=w.useState(!1),p=i||e.disabled||s||e.readOnly,g=w.useCallback(S=>{if(p)return;l(!0);const v=u.current;if(!v)return;const A=v.getContext("2d");if(!A)return;const x=v.getBoundingClientRect(),F="touches"in S?S.touches[0].clientX-x.left:S.clientX-x.left,k="touches"in S?S.touches[0].clientY-x.top:S.clientY-x.top;A.beginPath(),A.moveTo(F,k)},[p]),m=w.useCallback(S=>{if(!f||p)return;const v=u.current;if(!v)return;const A=v.getContext("2d");if(!A)return;const x=v.getBoundingClientRect(),F="touches"in S?S.touches[0].clientX-x.left:S.clientX-x.left,k="touches"in S?S.touches[0].clientY-x.top:S.clientY-x.top;A.lineWidth=2,A.lineCap="round",A.strokeStyle="#000",A.lineTo(F,k),A.stroke(),A.beginPath(),A.moveTo(F,k)},[f,p]),h=w.useCallback(()=>{if(!f)return;l(!1);const S=u.current;if(!S)return;const v=S.toDataURL();r(v),n?.()},[f,r,n]),y=w.useCallback(()=>{const S=u.current;if(!S||p)return;const v=S.getContext("2d");v&&(v.clearRect(0,0,S.width,S.height),r(null),n?.())},[p,r,n]);return w.useEffect(()=>{const S=u.current;if(S&&(S.width=S.offsetWidth,S.height=200,t)){const v=new Image;v.onload=()=>{const A=S.getContext("2d");A&&A.drawImage(v,0,0)},v.src=t}},[t]),d.jsx(Ct,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"space-y-2",children:[d.jsx("div",{className:V("border-2 border-dashed rounded-lg overflow-hidden",o&&"border-destructive",p&&"opacity-50 cursor-not-allowed"),children:d.jsx("canvas",{ref:u,id:ft(e),className:"w-full cursor-crosshair touch-none",onMouseDown:g,onMouseMove:m,onMouseUp:h,onMouseLeave:h,onTouchStart:g,onTouchMove:m,onTouchEnd:h,"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,style:{height:"200px"}})}),!p&&d.jsx("div",{className:"flex justify-end",children:d.jsxs(Qt,{type:"button",variant:"outline",size:"sm",onClick:y,className:"text-xs",children:[d.jsx(si,{className:"h-3 w-3 mr-1"}),"Clear"]})})]})})},_T=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:c,hideRowControls:u=!1,formValues:f,submissionContext:l})=>{const p=e.properties,g=p?.columns||[],m=p?.minRows||1,h=p?.maxRows||10,y=!u&&p?.allowAddRow!==!1,S=!u&&p?.allowDeleteRow!==!1,v=i===!1&&s===!1?!1:i||e.disabled||s||e.readOnly,A=t||[],x=y&&A.length<h,F=S&&A.length>m,k=w.useCallback(()=>{if(!x||v)return;const M={};g.forEach(U=>{M[U.name]=U.defaultValue??""}),r([...A,M]),n?.()},[A,g,x,v,r,n]),N=w.useCallback(M=>{if(!F||v)return;const U=A.filter((z,X)=>X!==M);r(U),n?.()},[A,F,v,r,n]),T=w.useCallback((M,U,z)=>{if(v)return;const X=[...A];X[M]||(X[M]={}),X[M][U]=z,r(X),n?.()},[A,v,r,n]);if(w.useEffect(()=>{if(A.length<m){const M=m-A.length,U=[];for(let z=0;z<M;z++){const X={};g.forEach(B=>{X[B.name]=B.defaultValue??""}),U.push(X)}r([...A,...U])}},[m,g,r,A.length]),g.length===0)return d.jsx(Ct,{field:e,error:o,isRequired:a,className:c,children:d.jsx("div",{className:"p-4 border rounded-md bg-muted/50 text-sm text-muted-foreground",children:"No columns defined for this table field"})});const P=Math.max(1,e.position?.rowSpan??1),E=Math.max(1,e.position?.columnSpan??1),C=Math.max(A.length,1),O=P>=3?"py-4":P>=2?"py-3":"py-2.5",W=E>=3?"px-4":E>=2?"px-3":"px-4";return d.jsx(Ct,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{id:ft(e),className:V("flex h-full min-h-0 w-full min-w-0 flex-1 flex-col border rounded-lg overflow-hidden shadow-sm bg-background",o&&"border-destructive",v&&"opacity-50"),"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,children:[d.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:d.jsxs("table",{className:"w-full h-full min-h-full border-collapse text-sm table-fixed",style:p?.minWidth?{minWidth:p.minWidth}:void 0,children:[d.jsx("thead",{children:d.jsxs("tr",{className:"border-b border-border bg-muted/60",children:[g.map(M=>d.jsxs("th",{className:V(W,O,"text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground whitespace-nowrap"),children:[M.label,a&&M.validation?.some(U=>U.type==="required")&&d.jsx("span",{className:"text-destructive ml-1",children:"*"})]},M.id)),S&&d.jsx("th",{className:"w-12"})]})}),d.jsx("tbody",{className:"h-full",children:A.length===0?d.jsx("tr",{children:d.jsx("td",{colSpan:g.length+(S?1:0),className:V(W,"py-8 text-center text-sm text-muted-foreground"),children:u?"No rows to display.":'No rows added yet. Click "Add Row" to get started.'})}):A.map((M,U)=>{const z=A[U],X=z&&typeof z=="object"&&!Array.isArray(z)?{...f??{},...z}:f;return d.jsxs("tr",{className:"border-b border-border/50 hover:bg-muted/30 transition-colors last:border-b-0",style:{height:`${100/C}%`},children:[g.map(B=>{const L={...B,name:`${e.name}_${U}_${B.name}`,appearance:{...B.appearance,hideLabel:!0}},D=B.name??"",K=M[D]!==void 0?M[D]:D&&Object.keys(M).find(G=>G.toLowerCase()===D.toLowerCase())?M[Object.keys(M).find(G=>G.toLowerCase()===D.toLowerCase())]:void 0,le=!!B.readOnly,j=G=>{if(G==null)return"";if(Array.isArray(G))return G.map(ee=>typeof ee=="object"&&ee!==null&&"name"in ee?String(ee.name??ee):String(ee)).join(", ");if(typeof G=="object"&&G!==null&&!(G instanceof Date)){const ee=G;return typeof ee.name=="string"&&typeof ee.code=="string"?`${ee.code} ${ee.name}`.trim():typeof ee.name=="string"?ee.name:typeof ee.code=="string"?ee.code:String(ee.name??ee.code??G)}return String(G)},H=G=>typeof G=="object"&&G!==null&&!Array.isArray(G)?j(G):String(G??""),ce=B.name?.toLowerCase()==="type"||B.label?.toLowerCase()==="type";if(le){const G=j(K);return d.jsx("td",{className:"px-4 py-2.5 align-middle first:pl-6 last:pr-6",children:d.jsx("div",{className:"min-w-[120px] text-sm text-foreground",children:ce&&G?d.jsx("span",{className:"inline-flex items-center rounded-full bg-primary/10 text-primary px-2.5 py-0.5 text-xs font-medium",children:G}):d.jsx("span",{className:"py-1 block",children:G})})},B.id)}const ie=()=>{switch(B.type){case"text":case"password":case"url":return d.jsx(ds,{field:L,value:H(K),onChange:G=>T(U,B.name,G),disabled:v,readOnly:v,className:"w-full"});case"number":return d.jsx(gl,{field:L,value:K??null,onChange:G=>T(U,B.name,G),disabled:v,readOnly:v,className:"w-full"});case"email":return d.jsx(sf,{field:L,value:H(K),onChange:G=>T(U,B.name,G),disabled:v,readOnly:v,className:"w-full"});case"phone":case"aadhaar":return d.jsx(af,{field:L,value:H(K),onChange:G=>T(U,B.name,G),disabled:v,readOnly:v,className:"w-full"});case"otp":return d.jsx(op,{field:L,value:H(K),onChange:G=>T(U,B.name,G),disabled:v,readOnly:v,className:"w-full"});case"textarea":return d.jsx(ip,{field:L,value:H(K),onChange:G=>T(U,B.name,G),disabled:v,readOnly:v,className:"w-full"});case"select":return d.jsx(Vm,{field:L,value:typeof K=="string"?K:H(K),onChange:G=>T(U,B.name,G),disabled:v,className:"w-full",formValues:X,submissionContext:l});case"multiselect":{const G=Array.isArray(K)?K:K!=null&&K!==""?[String(K)]:[];return d.jsx(Ph,{field:L,value:G,onChange:ee=>T(U,B.name,ee),disabled:v,className:"w-full",formValues:X,submissionContext:l})}case"asyncsearch":return d.jsx(lh,{field:L,value:K,onChange:G=>T(U,B.name,G),disabled:v,readOnly:v,className:"w-full",formValues:X,submissionContext:l});case"checkbox":return d.jsx(Ih,{field:L,value:K||!1,onChange:G=>T(U,B.name,G),disabled:v,className:"w-full"});case"radio":case"checkboxgroup":return d.jsx(og,{field:L,value:typeof K=="string"?K:H(K),onChange:G=>T(U,B.name,G),disabled:v,className:"w-full"});case"date":case"time":case"datetime":case"daterange":return d.jsx(ig,{field:L,value:typeof K=="string"?K:H(K),onChange:G=>T(U,B.name,G),disabled:v,readOnly:v,className:"w-full"});default:return d.jsx(ds,{field:L,value:H(K),onChange:G=>T(U,B.name,G),disabled:v,readOnly:v,className:"w-full"})}};return d.jsx("td",{className:"px-4 py-2.5 align-middle first:pl-6 last:pr-6",children:d.jsx("div",{className:"min-w-[160px] w-full [&_input]:min-w-[10rem] [&_input]:overflow-visible [&_textarea]:min-h-[2.5rem]",children:ie()})},B.id)}),S&&d.jsx("td",{className:"px-2 py-2",children:d.jsx(Qt,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>N(U),disabled:!F||v,children:d.jsx(si,{className:"h-4 w-4"})})})]},U)})})]})}),x&&d.jsx("div",{className:"shrink-0 p-3 border-t bg-muted/30",children:d.jsxs(Qt,{type:"button",variant:"outline",size:"sm",onClick:k,disabled:v,className:"w-full",children:[d.jsx(nf,{className:"h-4 w-4 mr-2"}),"Add Row"]})})]})})},TT="h-8 min-h-8 rounded-md border border-input bg-background px-2 text-sm shadow-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30",FT="flex min-h-8 w-full items-center gap-0.5 rounded-md border border-input bg-background px-2 focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/30",PT="h-8 min-w-[2ch] max-w-full flex-1 border-0 bg-transparent px-0 shadow-none focus-visible:ring-0",IT="align-top max-w-0 whitespace-normal break-words",Pi="block min-w-0 break-words";function uy(e,t,r){const n=r?.emptyDisplay??"—";if(e==null||e==="")return n;const o=t?.format??"text",i=typeof e=="number"?e:Number(e);switch(o){case"currency":return Number.isNaN(i)?n:`${r?.currencySymbol??"₹"}${i.toLocaleString("en-IN",{minimumFractionDigits:0,maximumFractionDigits:2})}`;case"percent":return Number.isNaN(i)?n:`${i}%`;case"number":return Number.isNaN(i)?n:String(i);default:return String(e)}}function OT(e){const t=e.replace(/[^\d.-]/g,"");if(t===""||t==="-"||t===".")return null;const r=parseFloat(t);return Number.isNaN(r)?null:r}function MT(e){if(e==null||e==="")return"";const t=typeof e=="number"?e:Number(e);return Number.isNaN(t)?"":String(t)}function fy(e,t){return uy(e,{format:"currency"},t)}function Ii(e){return e==null||e===""}function py(e){return e.mode??"editable"}function LT(e,t){return e.kind==="currency"||e.kind==="input"&&e.inputType==="number"?!0:t?.format==="currency"||t?.format==="number"||t?.format==="percent"}function my(e,t,r){if(e!==void 0){if(e==="")return"";if(LT(t,r)){const n=Number(e);return Number.isNaN(n)?e:n}return e}}function Kc(e,t){if(!(!e||!("defaultValue"in e)||e.defaultValue===void 0))return my(e.defaultValue,e,t)}function Gc(e,t,r){if(!t||!Ii(e))return e;if(t.kind==="currency"&&py(t)==="static"&&t.value!==void 0)return my(t.value,t,r);const n=Kc(t,r);return n!==void 0?n:e}function DT(e,t,r){const n={...t};for(const[o,i]of Object.entries(e)){const s=r.find(c=>c.key===o);if(!Ii(n[o]))continue;const a=Gc(n[o],i,s);(!Ii(a)||i&&"defaultValue"in i&&i.defaultValue==="")&&(n[o]=a)}return n}function va(e,t,r){if(!Ii(e))return e;const n=Kc(t,r);return n!==void 0?n:e}const BT=new Set(["all_items_summary","invoice_discount","grand_total"]);function $T(e,t){switch(t){case"dynamic":return e.filter(r=>r.rowKind==="dynamic");case"static":return e.filter(r=>r.rowKind==="static");case"all":return e;case"data":return e.filter(r=>r.rowKind==="dynamic"||r.rowKind==="static"&&!BT.has(r.slotId));default:return e}}function jT(e){if(typeof e=="number"&&!Number.isNaN(e))return e;const t=Number(e);return Number.isNaN(t)?0:t}function HT(e,t,r){const n=e.rowSlots.find(o=>o.kind==="static"?o.row.id===t.slotId:o.kind==="dynamic"&&o.block.id===t.slotId);if(n)return n.kind==="static"?n.row.cells[r]:n.block.cells[r]}function UT(e,t,r,n){const o=f=>zu(n,t,f,r),i=(f,l)=>zu(n,t,l,r,{slotId:f,rowKind:"static"}),s=(f,l="all")=>$T(t,l).reduce((p,g)=>p+jT(g.values[f]),0),a={...os.functions,cell:o,cellInRow:i,SUM:s},c=Object.keys(a),u=Object.values(a);try{const f=new Function(...c,`return (${e});`)(...u);return f==null||typeof f=="number"&&Number.isNaN(f)?null:f}catch{return null}}function zT(e,t){return e.length!==t.length?!1:e.every((r,n)=>{const o=t[n];return r.slotId===o.slotId&&r.rowInstanceId===o.rowInstanceId&&JSON.stringify(r.values)===JSON.stringify(o.values)})}function VT(e,t){const r=t.rows.map(n=>({...n,values:{...n.values}}));for(const n of r)for(const o of e.columns){const i=HT(e,n,o.key);if(i?.kind==="formula"){const s=UT(i.expression,r,n,e),a=e.columns.find(c=>c.key===o.key);n.values[o.key]=Ii(s)?Kc(i,a)??s:s}}return{rows:r}}function $o(e,t,r=8){let n={rows:t.rows.map(o=>({...o,values:{...o.values}}))};for(let o=0;o<r;o++){const i=VT(e,n);if(zT(i.rows,n.rows))return i;n=i}return n}function WT(e,t,r,n,o,i){const s=t.rows.map(a=>a.rowInstanceId!==r||a.slotId!==n?a:{...a,values:{...a.values,[o]:i}});return $o(e,{rows:s})}function hy(e,t,r=[]){return t.map((n,o)=>{const i=typeof n=="object"&&n!==null?n:{},s=e.rowIdField&&i[e.rowIdField]!=null?String(i[e.rowIdField]):String(o),a={};for(const[u,f]of Object.entries(e.cells)){const l=r.find(p=>p.key===u);(f.kind==="api"&&f.path||f.kind==="currency"&&f.mode==="api"&&f.path)&&(a[u]=va(We(i,f.path),f,l))}const c=a.service??a.tariff_type;return{slotId:e.id,rowKind:"dynamic",rowInstanceId:s,label:typeof c=="string"?c:void 0,values:a}})}function qc(e,t,r){const n=[];for(const o of e.rowSlots)if(o.kind==="static"){const i=t.get(o.row.id);i&&n.push(i)}else n.push(...r.get(o.block.id)??[]);return n}function Yc(e,t){const r=new Map,n=new Map;for(const o of e.rowSlots)if(o.kind==="static"){const i=t?.rows.find(s=>s.slotId===o.row.id&&s.rowKind==="static");r.set(o.row.id,{slotId:o.row.id,rowKind:"static",rowInstanceId:o.row.id,label:o.row.label,values:DT(o.row.cells,i?.values?{...i.values}:{},e.columns)})}else{const i=t?.rows.filter(s=>s.slotId===o.block.id&&s.rowKind==="dynamic")??[];n.set(o.block.id,i.map(s=>({...s,values:{...s.values}})))}return{rows:qc(e,r,n)}}function RT(e,t,r,n){const o=Yc(e,n),i=e.rowSlots.find(c=>c.kind==="dynamic"&&c.block.id===t);if(!i||i.kind!=="dynamic")return $o(e,o);const s=new Map,a=new Map;for(const c of e.rowSlots)if(c.kind==="static"){const u=o.rows.find(f=>f.slotId===c.row.id&&f.rowKind==="static");u&&s.set(c.row.id,{...u,values:{...u.values}})}else{const u=c.block.id===t?hy(c.block,r,e.columns):o.rows.filter(f=>f.slotId===c.block.id&&f.rowKind==="dynamic");a.set(c.block.id,u.map(f=>({...f,values:{...f.values}})))}return $o(e,{rows:qc(e,s,a)})}function gy(e,t,r){const n=Yc(e,r);if(t==null||typeof t!="object"||Array.isArray(t))return $o(e,n);const o=t,i=new Map,s=new Map;for(const a of e.rowSlots)if(a.kind==="static"){const u={...n.rows.find(l=>l.slotId===a.row.id&&l.rowKind==="static")?.values??{}},f=o[a.row.id]??o;for(const[l,p]of Object.entries(a.row.cells)){const g=e.columns.find(m=>m.key===l);(p.kind==="api"&&p.path||p.kind==="currency"&&p.mode==="api"&&p.path)&&(u[l]=va(We(f,p.path),p,g))}i.set(a.row.id,{slotId:a.row.id,rowKind:"static",rowInstanceId:a.row.id,label:a.row.label,values:u})}else{const c=a.block.apiArrayPath??a.block.id,u=We(o,c);s.set(a.block.id,Array.isArray(u)?hy(a.block,u,e.columns):[])}return $o(e,{rows:qc(e,i,s)})}function yy(e){if(!e)return"";const t=[];switch(e.fontSize){case"xs":t.push("text-xs");break;case"sm":t.push("text-sm");break;case"base":t.push("text-base");break;case"lg":t.push("text-lg");break;case"xl":t.push("text-xl");break}return e.bold?t.push("font-bold"):e.fontSize&&t.push("font-medium"),e.italic&&t.push("italic"),e.underline&&t.push("underline"),t.join(" ")}function KT(e){const t=e?.color?.trim();return t?{color:t}:{}}function Xc(e){return{className:yy(e),style:KT(e)}}function GT(e){return e?!!(e.fontSize||e.bold||e.italic||e.underline||e.color?.trim()):!1}function qT(e,t){if(!e&&!t)return;const r={...e,...t};return GT(r)?r:void 0}function YT(e,t){const r=e?.kind==="label"?qT(t,e.cellStyle):e?.cellStyle;return Xc(r)}function Jc(e){return e==="center"?"text-center":e==="right"?"text-right":"text-left"}function by(e,t){return e?.align?e.align:t?.align??"left"}function vy(e){const t=e.properties,r=t?.apiEndpoint?{apiEndpoint:t.apiEndpoint,apiMethod:t.apiMethod,apiKey:t.apiKey,apiRealtime:t.apiRealtime,apiQueryParams:t.apiQueryParams,apiHeaders:t.apiHeaders,apiBodyFields:t.apiBodyFields,apiAuth:t.apiAuth,valueSource:t.valueSource,dependentFields:t.dependentFields,apiResponsePath:t.apiResponsePath}:null,n=e.apidata||null;return r||n}function wy(e){if(e.type!=="billingGrid")return!1;const t=vy(e),r=e.properties;return!!(t?.apiEndpoint&&(t?.valueSource==="api"||r?.valueSource==="api"))}function XT(e,t,r){let n=e;if(r?.trim()&&(n=We(e,r.trim())),n==null)return null;if(Array.isArray(n)){const o=t.rowSlots.find(i=>i.kind==="dynamic");return o?.kind==="dynamic"?{[o.block.apiArrayPath?.trim()||o.block.id]:n}:null}return typeof n=="object"?n:null}function wa(e){return JSON.stringify(e?.rows??[])}function JT({field:e,properties:t,formValues:r={},submissionContext:n,value:o,onChange:i}){const s=wy(e),a=vy(e),[c,u]=w.useState(!1),[f,l]=w.useState(null),p=w.useRef(""),g=w.useRef(o);g.current=o;const m=w.useMemo(()=>{const x=a?.apiEndpoint||"",F=a?.apiQueryParams;return mo(x,F)},[a?.apiEndpoint,a?.apiQueryParams]),h=w.useMemo(()=>{const x=new Set;for(const F of a?.dependentFields??[])typeof F=="string"&&F.trim()&&x.add(F.trim());return[...x]},[a?.dependentFields]),y=w.useMemo(()=>{const x=new Set([...m,...h]);if(x.size===0)return null;const F={};return x.forEach(k=>{F[k]=r[k]}),JSON.stringify(F)},[m,h,r]),S=w.useMemo(()=>JSON.stringify(n||{}),[n]),v=w.useMemo(()=>{const x=new Set;e.name?.trim()&&x.add(e.name.trim());const F=e.key;return typeof F=="string"&&F.trim()&&x.add(F.trim()),[...x]},[e.name,e.key]),A=w.useMemo(()=>JSON.stringify({rowSlots:t.rowSlots,columns:t.columns}),[t.rowSlots,t.columns]);return w.useEffect(()=>{const x=a?.apiEndpoint;if(!s||!x)return;let F=!1;const k=T=>{if(F)return;const P=wa(T),E=wa(g.current);P!==E&&p.current!==P&&(p.current=P,i(T))};return(async()=>{u(!0),l(null);try{const T=a?.apiMethod||"GET",P=a?.apiRealtime,E=ss({apiEndpoint:x,apiMethod:T,apiQueryParams:a?.apiQueryParams||{},formValues:r,submissionContext:n,apiRealtime:P,additionalRequiredFieldNames:h,excludeFormFieldNames:v});if(E.blocked){F||u(!1);return}const C={"Content-Type":"application/json"};a?.apiKey&&(C["X-CSCAPI-KEY"]=a.apiKey);const O=a?.apiAuth??Ai(a?.apiHeaders)??{type:"none"};Object.assign(C,Ci(O,{formValues:r,submissionContext:n,apiRealtime:P})),Object.assign(C,Sn(xi(a?.apiHeaders),{formValues:r,submissionContext:n,apiRealtime:P}));const W=Sn(a?.apiBodyFields,{formValues:r,submissionContext:n,apiRealtime:P}),M={method:T.toLowerCase(),url:Mr(E.url),headers:C};(E.postBodyBase!=null||Object.keys(W).length>0)&&(M.data={...E.postBodyBase??{},...W});const U=await At(M),z=XT(U.data,t,a?.apiResponsePath);if(!z){F||l("API response could not be mapped to billing grid rows.");return}const X=gy(t,z,g.current);k(X)}catch(T){if(F)return;let P="Failed to load billing data";const E=T;if(E.response){const C=E.response.data;if(E.response.status===404)P="API endpoint not found.";else if(E.response.status===401)P="Authentication failed.";else if(typeof C=="string")P=C;else if(C&&typeof C=="object"){const O=C;P=O.error||O.message||O.detail||P}}else E.message&&(P=String(E.message));l(P)}finally{F||u(!1)}})(),()=>{F=!0}},[s,a?.apiEndpoint,a?.apiMethod,a?.apiResponsePath,y,h,v,S,A]),{isLoading:c,error:f}}function QT(e,t,r){return e.rowSlots.find(n=>r==="static"?n.kind==="static"&&n.row.id===t:n.kind==="dynamic"&&n.block.id===t)}function Sy(e,t,r,n){const o=e.rowSlots.find(i=>r==="static"?i.kind==="static"&&i.row.id===t:i.kind==="dynamic"&&i.block.id===t);if(o)return o.kind==="static"?o.row.cells[n]:o.block.cells[n]}const ZT=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:c,formValues:u,submissionContext:f})=>{const l=e.properties??{},p=l.columns??[],g=l.currencySymbol??"₹",m=l.emptyDisplay??"—",h=i||s,y=wy(e),{isLoading:S}=JT({field:e,properties:l,formValues:u,submissionContext:f,value:t,onChange:r}),v=w.useMemo(()=>{const C=Yc(l,t);return $o(l,C)},[l,t]),A=w.useRef("");w.useEffect(()=>{const C=wa(v),O=wa(t);C===O||C===A.current||(A.current=C,r(v))},[v,t,r]),w.useEffect(()=>{!t?.rows?.length&&v.rows.length&&!y&&r(v)},[t,v,r,y]);const x=w.useCallback((C,O,W,M,U)=>{if(h)return;const z=U==="number"?OT(M):M===""?null:M,X=WT(l,v,C,O,W,z);r(X)},[h,v,r,l]),F=(C,O,W,M,U,z)=>{const X=p.find(H=>H.key===U),B=Sy(l,C,O,U),L=Jc(by(B,X)),D=Gc(z,B,X),K=QT(l,C,O),le=K?.kind==="static"?K.row.labelStyle:K?.kind==="dynamic"?K.block.labelStyle:void 0,j=YT(B,le);if(B?.kind==="label")return d.jsx("span",{className:V(Pi,j.className||"font-medium",L,!j.style.color&&"text-foreground"),style:j.style,children:M??m});if(B?.kind==="input"&&!h){const H=D==null||D===""?"":String(D);return d.jsx(gn,{type:"text",inputMode:B.inputType==="number"?"decimal":"text",value:H,onChange:ce=>x(W,C,U,ce.target.value,B.inputType),onBlur:n,className:V(TT,"w-full min-w-0",L,j.className),style:j.style,disabled:h})}if(B?.kind==="currency"){const H=py(B);if(H==="static"){const ie=B.value!==void 0&&B.value!==""?Gc(null,{...B,mode:"static"},X):D;return d.jsx("span",{className:V(Pi,"tabular-nums",L,j.className),style:j.style,children:fy(ie,{currencySymbol:g,emptyDisplay:m})})}if(H==="api"||h)return d.jsx("span",{className:V(Pi,"tabular-nums",L,j.className),style:j.style,children:fy(D,{currencySymbol:g,emptyDisplay:m})});const ce=MT(D);return d.jsxs("div",{className:V(FT,L==="text-center"&&"justify-center",L==="text-right"&&"justify-end",L==="text-left"&&"justify-start",j.className),style:j.style,children:[d.jsx("span",{className:"shrink-0 tabular-nums",children:g}),d.jsx(gn,{type:"text",inputMode:"decimal",value:ce,onChange:ie=>x(W,C,U,ie.target.value,"number"),onBlur:n,className:PT,disabled:h})]})}return B?.kind==="static"?d.jsx("span",{className:V(Pi,L,j.className,!j.style.color&&"text-muted-foreground"),style:j.style,children:B.value}):d.jsx("span",{className:V(Pi,L,j.className),style:j.style,children:uy(D,X,{currencySymbol:g,emptyDisplay:m})})},k=l.gridTitle?.trim()??"",N=Math.max(1,e.position?.rowSpan??1),T=Math.max(1,e.position?.columnSpan??1),P=N>=3?"py-4":N>=2?"py-3":"py-2",E=T>=3?"px-4":T>=2?"px-3":"px-2";return p.length===0?d.jsx(Ct,{field:e,error:o,isRequired:a,className:c,children:d.jsx("div",{className:"p-4 border rounded-md bg-muted/50 text-sm text-muted-foreground",children:"No columns defined for this billing grid"})}):d.jsx(Ct,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{id:ft(e),className:V("relative flex h-full min-h-0 w-full min-w-0 max-w-full flex-1 flex-col border rounded-lg overflow-hidden shadow-sm bg-background",o&&"border-destructive",h&&"opacity-70"),"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,children:[S&&d.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/60",children:d.jsx(ho,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),k?d.jsx("div",{className:V("shrink-0 px-4 py-2 border-b bg-muted/40",yy(l.gridTitleStyle)||"text-muted-foreground"),style:Xc(l.gridTitleStyle).style,children:k}):null,d.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:d.jsxs("table",{className:"w-full h-full min-h-full border-collapse text-sm table-fixed",style:l.minWidth?{minWidth:l.minWidth}:void 0,children:[d.jsx("thead",{children:d.jsx("tr",{className:"border-b border-border bg-muted/60",children:p.map(C=>{const O=Xc(C.headerStyle);return d.jsx("th",{className:V(E,P,"text-xs uppercase tracking-wider whitespace-nowrap",Jc(C.align),O.className||"font-semibold text-muted-foreground"),style:O.style,children:C.label},C.id)})})}),d.jsx("tbody",{className:"h-full",children:v.rows.length===0?d.jsx("tr",{children:d.jsx("td",{colSpan:p.length,className:V(E,"py-8 text-center text-sm text-muted-foreground"),children:"No billing rows configured"})}):v.rows.map(C=>d.jsx("tr",{className:"border-b border-border/60",children:p.map(O=>{const W=Sy(l,C.slotId,C.rowKind,O.key),M=by(W,O);return d.jsx("td",{className:V(E,P,IT,Jc(M)),children:F(C.slotId,C.rowKind,C.rowInstanceId,C.label,O.key,C.values[O.key])},O.id)})},`${C.slotId}-${C.rowInstanceId}`))})]})})]})})};function Qc(e,t,r){return gy(e,t,r)}const eF=({field:e,value:t,error:r,disabled:n,isRequired:o,className:i,formValues:s={},submissionContext:a,extraSubmitPayload:c,skipApiCall:u=!1,prepopulateResponse:f=null})=>{const l=e.properties||{},p=l.source??"manual",g=Array.isArray(l.statuses)?l.statuses:[],m=(l.dataPath||"data").trim(),h=l.showStatusText===!0,y=(l.statusTextPath||"data.admissionStatus").trim(),S=l.showCurrentIndicator!==!1,[v,A]=w.useState(null),[x,F]=w.useState(!1),[k,N]=w.useState(null),T=Va.useParams(),P=w.useRef(s),E=w.useRef(a),C=w.useRef(c),O=w.useRef(T);P.current=s,E.current=a,C.current=c,O.current=T;const W=w.useCallback(async()=>{const B=l.apiEndpoint?.trim();if(!B){N("Status API endpoint is not configured");return}F(!0),N(null);try{const L=E.current,D=C.current,K=L!=null&&typeof L=="object"?{...L,...D||{}}:D||{},le=Mr(Rr(B,P.current,O.current,K,void 0,f??void 0)),j=(l.apiMethod||"GET").toUpperCase(),H=await fetch(le,{method:j,headers:j==="POST"?{"Content-Type":"application/json"}:void 0});if(!H.ok)throw new Error(`HTTP ${H.status}`);const ce=await H.json(),ie=m?We(ce,m):ce;A(ie&&typeof ie=="object"?ie:{})}catch(L){N(L instanceof Error?L.message:"Failed to load status"),A(null)}finally{F(!1)}},[l.apiEndpoint,l.apiMethod,m,f]);w.useEffect(()=>{p==="api"&&!u&&W()},[p,u,W]);const M=p==="api"?v:t&&typeof t=="object"?(m?We(t,m):null)??t:null,U=h&&y&&M?String(We(M,y)??We({data:M},y)??""):"",z=B=>{if(!M||typeof M!="object")return!1;const L=M[B];return L===!0||L==="true"||L===1};let X=!1;return d.jsx(Ct,{field:e,error:r||k||void 0,isRequired:o,className:V(i,"!space-y-0 h-full min-h-0 flex flex-col"),children:d.jsxs("div",{className:"rounded-lg border bg-card p-4 h-full min-h-0 flex flex-col",children:[x&&d.jsx("div",{className:"text-sm text-muted-foreground py-2",children:"Loading status..."}),h&&U&&!x&&d.jsx("p",{className:"text-sm text-muted-foreground mb-3 shrink-0","data-status-text":!0,children:U}),!x&&d.jsx("ul",{className:"flex-1 min-h-0 flex flex-col gap-y-8 overflow-y-auto pr-1 py-1",children:g.map(B=>{const L=z(B.key),D=S&&L&&!X;return D&&(X=!0),d.jsxs("li",{className:V("flex items-center gap-3 text-sm",L?"text-foreground":"text-muted-foreground"),children:[L?d.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-green-600 text-white","aria-hidden":!0,children:d.jsx(fs,{className:"h-3 w-3"})}):d.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full border-2 border-muted-foreground/40 bg-muted/50","aria-hidden":!0,children:d.jsx(ef,{className:"h-2.5 w-2.5 text-muted-foreground/60"})}),d.jsx("span",{className:"flex-1 min-w-0",children:B.label}),D&&d.jsx("span",{className:"shrink-0 text-xs font-medium text-primary",children:"Current"})]},B.key)})}),!x&&g.length===0&&d.jsx("p",{className:"text-sm text-muted-foreground",children:"No statuses configured."})]})})};function Zc(e,t){if(!t||!e)return;const r=t.split(".");let n=e;for(const o of r){if(n==null||typeof n!="object")return;n=n[o]}return n}function jo(e,t){if(t){const r=Zc(e,t);if(r!=null)return String(r)}return e.email!=null?String(e.email):e.personal_email!=null?String(e.personal_email):e.id!=null?String(e.id):JSON.stringify(e)}function tF(e,t,r,n){if(r?.length){const i=n??" | ",s=r.map(a=>Zc(e,a)).filter(a=>a!=null).map(a=>String(a));if(s.length)return s.join(i)}if(t){const i=Zc(e,t);if(i!=null)return String(i)}if(e.name!=null&&e.email!=null)return`${e.name} <${e.email}>`;if(e.name!=null)return String(e.name);if(e.email!=null)return String(e.email);const o=e.personal_email;return o!=null?String(o):JSON.stringify(e)}const rF=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a,submissionContext:c})=>{const u=e.properties||{},{dataSourceContextKey:f,labelField:l="name",valueField:p="email",displayFields:g,displayFieldsSeparator:m=" | ",showSelectAll:h=!0,selectAllByDefault:y=!0}=u;console.log("[SelectableList] Step 1: render",{fieldName:e.name,valueIsArray:Array.isArray(t),valueLength:Array.isArray(t)?t.length:0,valueSample:Array.isArray(t)&&t.length>0?t.slice(0,2):t,submissionContextKeys:c?Object.keys(c):[],dataSourceContextKey:f,contextKeyValue:c&&f?c[f]:void 0});const S=w.useMemo(()=>{if(!f||!c)return[];const C=c[f];return Array.isArray(C)?C:[]},[f,c]);console.log("[SelectableList] Step 2: contextList from submissionContext",{fieldName:e.name,contextListLength:S.length,contextListSample:S.length>0?S.slice(0,2):[]});const[v,A]=w.useState(()=>S.length>0?S:Array.isArray(t)?t:[]);w.useEffect(()=>{if(S.length>0){console.log("[SelectableList] Step 3: sync fullList from context",{fieldName:e.name,contextListLength:S.length}),A(S);return}Array.isArray(t)&&t.length>0&&A(C=>{const O=C.length===0||t.length>C.length?t:C;return console.log("[SelectableList] Step 3: sync fullList from value",{fieldName:e.name,valueLength:t.length,prevLength:C.length,nextLength:O.length}),O})},[S,t]);const x=w.useMemo(()=>{const C=Array.isArray(t)?t:[];return new Set(C.map(W=>jo(W,p)))},[t,p]),F=v.length>0&&v.every(C=>x.has(jo(C,p))),k=v.some(C=>x.has(jo(C,p))),N=w.useCallback((C,O)=>{const W=jo(C,p),M=Array.isArray(t)?t:[];O?x.has(W)||r([...M,C]):r(M.filter(U=>jo(U,p)!==W)),n?.()},[t,p,x,r,n]),T=w.useCallback(C=>{r(C===!0?[...v]:[]),n?.()},[v,r,n]),P=v.length>0?v:Array.isArray(t)?t:[],E=i||e.disabled;return console.log("[SelectableList] Data in list",{fieldName:e.name,listLength:P.length,listSource:v.length>0?"fullList":"value",valueLength:Array.isArray(t)?t.length:0,fullListLength:v.length,listData:P.length>0?P:[],listDataFirstThree:P.length>0?P.slice(0,3):[]}),d.jsx("div",{className:V("relative z-10 flex flex-col min-h-0 h-full w-full",P.length>0&&"min-h-[14rem]",a),children:d.jsx(Ct,{field:e,error:o,isRequired:s,className:V("flex-1 min-h-0 flex flex-col",P.length>0&&"min-h-[14rem]"),children:d.jsx("div",{className:V("flex-1 min-h-0 flex flex-col",P.length>0&&"min-h-[14rem]"),children:d.jsxs("div",{className:V("flex-1 min-h-0 flex flex-col",P.length>0&&"overflow-visible"),children:[d.jsxs("div",{role:"listbox","aria-multiselectable":!0,className:V("border rounded-md divide-y overflow-y-auto overflow-x-hidden bg-muted/30 overscroll-contain touch-pan-y pb-3 pr-3 z-20 relative",P.length>0?"flex-1 min-h-0":"min-h-0"),children:[h&&P.length>0&&d.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-3 py-2 sticky top-0 bg-background border-b z-10 shrink-0",children:[d.jsx(ea,{id:`${ft(e)}-select-all`,checked:F?!0:k?"indeterminate":!1,onCheckedChange:T,disabled:E,"aria-label":"Select all"}),d.jsxs(Pn,{htmlFor:`${ft(e)}-select-all`,className:"text-sm font-medium cursor-pointer",children:["Select all (",P.length,")"]}),d.jsxs("div",{className:"flex gap-1 ml-auto",children:[d.jsx(Qt,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs",disabled:E||F,onClick:()=>{r([...v]),n?.()},children:"Select all"}),d.jsx(Qt,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs",disabled:E||!k,onClick:()=>{r([]),n?.()},children:"Unselect all"})]})]}),P.length===0?d.jsx("p",{className:"px-3 py-4 text-sm text-muted-foreground",children:"No items to display."}):d.jsx(d.Fragment,{children:P.map((C,O)=>{const W=jo(C,p),M=x.has(W),U=`${ft(e)}-${O}-${W}`;return d.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 min-h-[2.5rem] hover:bg-muted/50 shrink-0",role:"row",children:[d.jsx(ea,{id:U,checked:M,onCheckedChange:z=>N(C,z===!0),disabled:E,"aria-describedby":Lt(e,!!o)}),d.jsx(Pn,{htmlFor:U,className:"text-sm cursor-pointer flex-1 truncate",children:tF(C,l,g,m)})]},W)})})]}),P.length>0&&x.size===0&&d.jsxs("p",{className:"flex items-center gap-1.5 mt-2 text-sm text-amber-600 dark:text-amber-500 shrink-0",role:"status",children:[d.jsx(wS,{className:"h-4 w-4 shrink-0"}),"Please select at least one item."]})]})})})})},xy=({field:e,children:t,className:r})=>{const n=e.properties,o=n?.collapsible??!1,i=n?.defaultCollapsed??!1,s=n?.columns??1,[a,c]=w.useState(i),u=()=>{o&&c(!a)},f={1:"grid-cols-1",2:"grid-cols-1 md:grid-cols-2",3:"grid-cols-1 md:grid-cols-2 lg:grid-cols-3",4:"grid-cols-1 md:grid-cols-2 lg:grid-cols-4"};return d.jsxs("div",{className:V("border rounded-lg bg-card",r),children:[d.jsxs("div",{className:V("flex items-center gap-2 px-4 py-3 border-b bg-muted/50",o&&"cursor-pointer hover:bg-muted/70 transition-colors"),onClick:u,children:[o&&d.jsx("span",{className:"text-muted-foreground",children:a?d.jsx(Zu,{className:"h-4 w-4"}):d.jsx(ii,{className:"h-4 w-4"})}),d.jsx("h3",{className:"font-medium text-sm",children:e.label}),e.description&&d.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:e.description})]}),!a&&d.jsx("div",{className:V("p-4 grid gap-4",f[s]),children:t})]})};var nF=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],oF=nF.reduce((e,t)=>{const r=hl(`Primitive.${t}`),n=b.forwardRef((o,i)=>{const{asChild:s,...a}=o,c=s?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(c,{...a,ref:i})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),iF="Separator",Ay="horizontal",sF=["horizontal","vertical"],Cy=b.forwardRef((e,t)=>{const{decorative:r,orientation:n=Ay,...o}=e,i=aF(n)?n:Ay,a=r?{role:"none"}:{"aria-orientation":i==="vertical"?i:void 0,role:"separator"};return d.jsx(oF.div,{"data-orientation":i,...a,...o,ref:t})});Cy.displayName=iF;function aF(e){return sF.includes(e)}var lF=Cy;function ed({className:e,orientation:t="horizontal",decorative:r=!0,...n}){return d.jsx(lF,{"data-slot":"separator",decorative:r,orientation:t,className:V("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",e),...n})}const cF=({field:e,className:t})=>d.jsx("div",{className:V("py-2",t),children:d.jsx(ed,{})}),dF={h1:"text-3xl font-bold",h2:"text-2xl font-bold",h3:"text-xl font-semibold",h4:"text-lg font-semibold",h5:"text-base font-medium",h6:"text-sm font-medium"},uF=({field:e,className:t})=>{const r=e.properties,n=r?.headingLevel??"h3",o=r?.showHorizontalLine??!0,i=dF[n],s=n;return d.jsxs("div",{className:V("w-full min-w-0 space-y-1",t),children:[d.jsx(s,{className:V("m-0 text-foreground",i),children:e.label||"Header"}),e.description&&d.jsx("p",{className:"text-sm text-muted-foreground",children:e.description}),o&&d.jsx(ed,{className:"w-full"})]})},fF={"top-left":"justify-start","top-center":"justify-center","top-right":"justify-end","middle-left":"justify-start",center:"justify-center","middle-right":"justify-end","bottom-left":"justify-start","bottom-center":"justify-center","bottom-right":"justify-end"},pF={h1:"text-3xl font-bold",h2:"text-2xl font-bold",h3:"text-xl font-semibold",h4:"text-lg font-semibold",h5:"text-base font-medium",h6:"text-sm font-medium"},mF=({field:e,className:t})=>{const r=e.properties,n=r?.position??"top-left",o=r?.headingLevel??"h3",i=r?.showHorizontalLine??!0,s=fF[n],a=pF[o],c=o;return d.jsxs("div",{className:V("w-full min-w-0 space-y-2",t),children:[d.jsx("div",{className:V("flex w-full",s),children:d.jsx(c,{className:V("m-0 text-foreground",a),children:e.label||"Section Heading"})}),i&&d.jsx(ed,{className:"w-full"})]})},hF=({field:e,className:t})=>{const r=e.appearance?.size||"md",n={sm:"h-4",md:"h-8",lg:"h-12"};return d.jsx("div",{className:V(n[r],t),"aria-hidden":"true"})};function Ey(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function gF(e){if(Array.isArray(e))return e}function yF(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,o,i,s,a=[],c=!0,u=!1;try{if(i=(r=r.call(e)).next,t!==0)for(;!(c=(n=i.call(r)).done)&&(a.push(n.value),a.length!==t);c=!0);}catch(f){u=!0,o=f}finally{try{if(!c&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(u)throw o}}return a}}function bF(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
51
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function vF(e,t){return gF(e)||yF(e,t)||wF(e,t)||bF()}function wF(e,t){if(e){if(typeof e=="string")return Ey(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ey(e,t):void 0}}const ky=Object.entries,Ny=Object.setPrototypeOf,SF=Object.isFrozen,xF=Object.getPrototypeOf,AF=Object.getOwnPropertyDescriptor;let ur=Object.freeze,Dr=Object.seal,Ho=Object.create,_y=typeof Reflect<"u"&&Reflect,td=_y.apply,rd=_y.construct;ur||(ur=function(t){return t}),Dr||(Dr=function(t){return t}),td||(td=function(t,r){for(var n=arguments.length,o=new Array(n>2?n-2:0),i=2;i<n;i++)o[i-2]=arguments[i];return t.apply(r,o)}),rd||(rd=function(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];return new t(...n)});const Uo=Ht(Array.prototype.forEach),CF=Ht(Array.prototype.lastIndexOf),Ty=Ht(Array.prototype.pop),zo=Ht(Array.prototype.push),EF=Ht(Array.prototype.splice),fr=Array.isArray,Oi=Ht(String.prototype.toLowerCase),nd=Ht(String.prototype.toString),Fy=Ht(String.prototype.match),Vo=Ht(String.prototype.replace),Py=Ht(String.prototype.indexOf),kF=Ht(String.prototype.trim),NF=Ht(Number.prototype.toString),_F=Ht(Boolean.prototype.toString),Iy=typeof BigInt>"u"?null:Ht(BigInt.prototype.toString),Oy=typeof Symbol>"u"?null:Ht(Symbol.prototype.toString),Mt=Ht(Object.prototype.hasOwnProperty),Mi=Ht(Object.prototype.toString),rr=Ht(RegExp.prototype.test),Sa=TF(TypeError);function Ht(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];return td(e,t,n)}}function TF(e){return function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return rd(e,r)}}function Ze(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Oi;if(Ny&&Ny(e,null),!fr(t))return e;let n=t.length;for(;n--;){let o=t[n];if(typeof o=="string"){const i=r(o);i!==o&&(SF(t)||(t[n]=i),o=i)}e[o]=!0}return e}function FF(e){for(let t=0;t<e.length;t++)Mt(e,t)||(e[t]=null);return e}function yr(e){const t=Ho(null);for(const n of ky(e)){var r=vF(n,2);const o=r[0],i=r[1];Mt(e,o)&&(fr(i)?t[o]=FF(i):i&&typeof i=="object"&&i.constructor===Object?t[o]=yr(i):t[o]=i)}return t}function PF(e){switch(typeof e){case"string":return e;case"number":return NF(e);case"boolean":return _F(e);case"bigint":return Iy?Iy(e):"0";case"symbol":return Oy?Oy(e):"Symbol()";case"undefined":return Mi(e);case"function":case"object":{if(e===null)return Mi(e);const t=e,r=so(t,"toString");if(typeof r=="function"){const n=r(t);return typeof n=="string"?n:Mi(n)}return Mi(e)}default:return Mi(e)}}function so(e,t){for(;e!==null;){const n=AF(e,t);if(n){if(n.get)return Ht(n.get);if(typeof n.value=="function")return Ht(n.value)}e=xF(e)}function r(){return null}return r}function IF(e){try{return rr(e,""),!0}catch{return!1}}const My=ur(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),od=ur(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),id=ur(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),OF=ur(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),sd=ur(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),MF=ur(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Ly=ur(["#text"]),Dy=ur(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),ad=ur(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),By=ur(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),xa=ur(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),LF=Dr(/{{[\w\W]*|^[\w\W]*}}/g),DF=Dr(/<%[\w\W]*|^[\w\W]*%>/g),BF=Dr(/\${[\w\W]*/g),$F=Dr(/^data-[\-\w.\u00B7-\uFFFF]+$/),jF=Dr(/^aria-[\-\w]+$/),$y=Dr(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),HF=Dr(/^(?:\w+script|data):/i),UF=Dr(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),zF=Dr(/^html$/i),VF=Dr(/^[a-z][.\w]*(-[.\w]+)+$/i),Wo={element:1,text:3,progressingInstruction:7,comment:8,document:9},WF=function(){return typeof window>"u"?null:window},RF=function(t,r){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let n=null;const o="data-tt-policy-suffix";r&&r.hasAttribute(o)&&(n=r.getAttribute(o));const i="dompurify"+(n?"#"+n:"");try{return t.createPolicy(i,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},jy=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Hy(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:WF();const t=Ne=>Hy(Ne);if(t.version="3.4.5",t.removed=[],!e||!e.document||e.document.nodeType!==Wo.document||!e.Element)return t.isSupported=!1,t;let r=e.document;const n=r,o=n.currentScript,i=e.DocumentFragment,s=e.HTMLTemplateElement,a=e.Node,c=e.Element,u=e.NodeFilter,f=e.NamedNodeMap,l=f===void 0?e.NamedNodeMap||e.MozNamedAttrMap:f,p=e.HTMLFormElement,g=e.DOMParser,m=e.trustedTypes,h=c.prototype,y=so(h,"cloneNode"),S=so(h,"remove"),v=so(h,"nextSibling"),A=so(h,"childNodes"),x=so(h,"parentNode"),F=a&&a.prototype?so(a.prototype,"nodeType"):null;if(typeof s=="function"){const Ne=r.createElement("template");Ne.content&&Ne.content.ownerDocument&&(r=Ne.content.ownerDocument)}let k,N="";const T=r,P=T.implementation,E=T.createNodeIterator,C=T.createDocumentFragment,O=T.getElementsByTagName,W=n.importNode;let M=jy();t.isSupported=typeof ky=="function"&&typeof x=="function"&&P&&P.createHTMLDocument!==void 0;const U=LF,z=DF,X=BF,B=$F,L=jF,D=HF,K=UF,le=VF;let j=$y,H=null;const ce=Ze({},[...My,...od,...id,...sd,...Ly]);let ie=null;const G=Ze({},[...Dy,...ad,...By,...xa]);let ee=Object.seal(Ho(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ae=null,te=null;const oe=Object.seal(Ho(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let me=!0,Me=!0,De=!1,ne=!0,ge=!1,Se=!0,yt=!1,kt=!1,Ut=!1,It=!1,Er=!1,Dt=!1,sr=!0,zt=!1;const he="user-content-";let we=!0,J=!1,$={},fe=null;const ze=Ze({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Fe=null;const He=Ze({},["audio","video","img","source","image","track"]);let st=null;const ht=Ze({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),lt="http://www.w3.org/1998/Math/MathML",ct="http://www.w3.org/2000/svg",nt="http://www.w3.org/1999/xhtml";let ot=nt,ar=!1,vt=null;const er=Ze({},[lt,ct,nt],nd);let Je=Ze({},["mi","mo","mn","ms","mtext"]),ut=Ze({},["annotation-xml"]);const Ye=Ze({},["title","style","font","a","script"]);let nr=null;const br=["application/xhtml+xml","text/html"],vr="text/html";let Nt=null,kr=null;const lr=r.createElement("form"),An=function(I){return I instanceof RegExp||I instanceof Function},fn=function(){let I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(kr&&kr===I)return;(!I||typeof I!="object")&&(I={}),I=yr(I),nr=br.indexOf(I.PARSER_MEDIA_TYPE)===-1?vr:I.PARSER_MEDIA_TYPE,Nt=nr==="application/xhtml+xml"?nd:Oi,H=Mt(I,"ALLOWED_TAGS")&&fr(I.ALLOWED_TAGS)?Ze({},I.ALLOWED_TAGS,Nt):ce,ie=Mt(I,"ALLOWED_ATTR")&&fr(I.ALLOWED_ATTR)?Ze({},I.ALLOWED_ATTR,Nt):G,vt=Mt(I,"ALLOWED_NAMESPACES")&&fr(I.ALLOWED_NAMESPACES)?Ze({},I.ALLOWED_NAMESPACES,nd):er,st=Mt(I,"ADD_URI_SAFE_ATTR")&&fr(I.ADD_URI_SAFE_ATTR)?Ze(yr(ht),I.ADD_URI_SAFE_ATTR,Nt):ht,Fe=Mt(I,"ADD_DATA_URI_TAGS")&&fr(I.ADD_DATA_URI_TAGS)?Ze(yr(He),I.ADD_DATA_URI_TAGS,Nt):He,fe=Mt(I,"FORBID_CONTENTS")&&fr(I.FORBID_CONTENTS)?Ze({},I.FORBID_CONTENTS,Nt):ze,Ae=Mt(I,"FORBID_TAGS")&&fr(I.FORBID_TAGS)?Ze({},I.FORBID_TAGS,Nt):yr({}),te=Mt(I,"FORBID_ATTR")&&fr(I.FORBID_ATTR)?Ze({},I.FORBID_ATTR,Nt):yr({}),$=Mt(I,"USE_PROFILES")?I.USE_PROFILES&&typeof I.USE_PROFILES=="object"?yr(I.USE_PROFILES):I.USE_PROFILES:!1,me=I.ALLOW_ARIA_ATTR!==!1,Me=I.ALLOW_DATA_ATTR!==!1,De=I.ALLOW_UNKNOWN_PROTOCOLS||!1,ne=I.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ge=I.SAFE_FOR_TEMPLATES||!1,Se=I.SAFE_FOR_XML!==!1,yt=I.WHOLE_DOCUMENT||!1,It=I.RETURN_DOM||!1,Er=I.RETURN_DOM_FRAGMENT||!1,Dt=I.RETURN_TRUSTED_TYPE||!1,Ut=I.FORCE_BODY||!1,sr=I.SANITIZE_DOM!==!1,zt=I.SANITIZE_NAMED_PROPS||!1,we=I.KEEP_CONTENT!==!1,J=I.IN_PLACE||!1,j=IF(I.ALLOWED_URI_REGEXP)?I.ALLOWED_URI_REGEXP:$y,ot=typeof I.NAMESPACE=="string"?I.NAMESPACE:nt,Je=Mt(I,"MATHML_TEXT_INTEGRATION_POINTS")&&I.MATHML_TEXT_INTEGRATION_POINTS&&typeof I.MATHML_TEXT_INTEGRATION_POINTS=="object"?yr(I.MATHML_TEXT_INTEGRATION_POINTS):Ze({},["mi","mo","mn","ms","mtext"]),ut=Mt(I,"HTML_INTEGRATION_POINTS")&&I.HTML_INTEGRATION_POINTS&&typeof I.HTML_INTEGRATION_POINTS=="object"?yr(I.HTML_INTEGRATION_POINTS):Ze({},["annotation-xml"]);const re=Mt(I,"CUSTOM_ELEMENT_HANDLING")&&I.CUSTOM_ELEMENT_HANDLING&&typeof I.CUSTOM_ELEMENT_HANDLING=="object"?yr(I.CUSTOM_ELEMENT_HANDLING):Ho(null);if(ee=Ho(null),Mt(re,"tagNameCheck")&&An(re.tagNameCheck)&&(ee.tagNameCheck=re.tagNameCheck),Mt(re,"attributeNameCheck")&&An(re.attributeNameCheck)&&(ee.attributeNameCheck=re.attributeNameCheck),Mt(re,"allowCustomizedBuiltInElements")&&typeof re.allowCustomizedBuiltInElements=="boolean"&&(ee.allowCustomizedBuiltInElements=re.allowCustomizedBuiltInElements),ge&&(Me=!1),Er&&(It=!0),$&&(H=Ze({},Ly),ie=Ho(null),$.html===!0&&(Ze(H,My),Ze(ie,Dy)),$.svg===!0&&(Ze(H,od),Ze(ie,ad),Ze(ie,xa)),$.svgFilters===!0&&(Ze(H,id),Ze(ie,ad),Ze(ie,xa)),$.mathMl===!0&&(Ze(H,sd),Ze(ie,By),Ze(ie,xa))),oe.tagCheck=null,oe.attributeCheck=null,Mt(I,"ADD_TAGS")&&(typeof I.ADD_TAGS=="function"?oe.tagCheck=I.ADD_TAGS:fr(I.ADD_TAGS)&&(H===ce&&(H=yr(H)),Ze(H,I.ADD_TAGS,Nt))),Mt(I,"ADD_ATTR")&&(typeof I.ADD_ATTR=="function"?oe.attributeCheck=I.ADD_ATTR:fr(I.ADD_ATTR)&&(ie===G&&(ie=yr(ie)),Ze(ie,I.ADD_ATTR,Nt))),Mt(I,"ADD_URI_SAFE_ATTR")&&fr(I.ADD_URI_SAFE_ATTR)&&Ze(st,I.ADD_URI_SAFE_ATTR,Nt),Mt(I,"FORBID_CONTENTS")&&fr(I.FORBID_CONTENTS)&&(fe===ze&&(fe=yr(fe)),Ze(fe,I.FORBID_CONTENTS,Nt)),Mt(I,"ADD_FORBID_CONTENTS")&&fr(I.ADD_FORBID_CONTENTS)&&(fe===ze&&(fe=yr(fe)),Ze(fe,I.ADD_FORBID_CONTENTS,Nt)),we&&(H["#text"]=!0),yt&&Ze(H,["html","head","body"]),H.table&&(Ze(H,["tbody"]),delete Ae.tbody),I.TRUSTED_TYPES_POLICY){if(typeof I.TRUSTED_TYPES_POLICY.createHTML!="function")throw Sa('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof I.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Sa('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');k=I.TRUSTED_TYPES_POLICY,N=k.createHTML("")}else k===void 0&&(k=RF(m,o)),k!==null&&typeof N=="string"&&(N=k.createHTML(""));ur&&ur(I),kr=I},$r=Ze({},[...od,...id,...OF]),Un=Ze({},[...sd,...MF]),Bt=function(I){let re=x(I);(!re||!re.tagName)&&(re={namespaceURI:ot,tagName:"template"});const ve=Oi(I.tagName),rt=Oi(re.tagName);return vt[I.namespaceURI]?I.namespaceURI===ct?re.namespaceURI===nt?ve==="svg":re.namespaceURI===lt?ve==="svg"&&(rt==="annotation-xml"||Je[rt]):!!$r[ve]:I.namespaceURI===lt?re.namespaceURI===nt?ve==="math":re.namespaceURI===ct?ve==="math"&&ut[rt]:!!Un[ve]:I.namespaceURI===nt?re.namespaceURI===ct&&!ut[rt]||re.namespaceURI===lt&&!Je[rt]?!1:!Un[ve]&&(Ye[ve]||!$r[ve]):!!(nr==="application/xhtml+xml"&&vt[I.namespaceURI]):!1},Vt=function(I){zo(t.removed,{element:I});try{x(I).removeChild(I)}catch{S(I)}},wr=function(I,re){try{zo(t.removed,{attribute:re.getAttributeNode(I),from:re})}catch{zo(t.removed,{attribute:null,from:re})}if(re.removeAttribute(I),I==="is")if(It||Er)try{Vt(re)}catch{}else try{re.setAttribute(I,"")}catch{}},Jr=function(I){let re=null,ve=null;if(Ut)I="<remove></remove>"+I;else{const St=Fy(I,/^[\r\n\t ]+/);ve=St&&St[0]}nr==="application/xhtml+xml"&&ot===nt&&(I='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+I+"</body></html>");const rt=k?k.createHTML(I):I;if(ot===nt)try{re=new g().parseFromString(rt,nr)}catch{}if(!re||!re.documentElement){re=P.createDocument(ot,"template",null);try{re.documentElement.innerHTML=ar?N:rt}catch{}}const wt=re.body||re.documentElement;return I&&ve&&wt.insertBefore(r.createTextNode(ve),wt.childNodes[0]||null),ot===nt?O.call(re,yt?"html":"body")[0]:yt?re.documentElement:wt},Yt=function(I){return E.call(I.ownerDocument||I,I,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},cr=function(I){I.normalize();const re=E.call(I.ownerDocument||I,I,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null);let ve=re.nextNode();for(;ve;){let rt=ve.data;Uo([U,z,X],wt=>{rt=Vo(rt,wt," ")}),ve.data=rt,ve=re.nextNode()}},zn=function(I){return I instanceof p&&(typeof I.nodeName!="string"||typeof I.textContent!="string"||typeof I.removeChild!="function"||!(I.attributes instanceof l)||typeof I.removeAttribute!="function"||typeof I.setAttribute!="function"||typeof I.namespaceURI!="string"||typeof I.insertBefore!="function"||typeof I.hasChildNodes!="function")},Vi=function(I){if(!F||typeof I!="object"||I===null)return!1;try{return typeof F(I)=="number"}catch{return!1}};function _t(Ne,I,re){Uo(Ne,ve=>{ve.call(t,I,re,kr)})}const Wi=function(I){let re=null;if(_t(M.beforeSanitizeElements,I,null),zn(I))return Vt(I),!0;const ve=Nt(I.nodeName);if(_t(M.uponSanitizeElement,I,{tagName:ve,allowedTags:H}),Se&&I.hasChildNodes()&&!Vi(I.firstElementChild)&&rr(/<[/\w!]/g,I.innerHTML)&&rr(/<[/\w!]/g,I.textContent)||Se&&I.namespaceURI===nt&&ve==="style"&&Vi(I.firstElementChild)||I.nodeType===Wo.progressingInstruction||Se&&I.nodeType===Wo.comment&&rr(/<[/\w]/g,I.data))return Vt(I),!0;if(Ae[ve]||!(oe.tagCheck instanceof Function&&oe.tagCheck(ve))&&!H[ve]){if(!Ae[ve]&&jr(ve)&&(ee.tagNameCheck instanceof RegExp&&rr(ee.tagNameCheck,ve)||ee.tagNameCheck instanceof Function&&ee.tagNameCheck(ve)))return!1;if(we&&!fe[ve]){const rt=x(I)||I.parentNode,wt=A(I)||I.childNodes;if(wt&&rt){const St=wt.length;for(let Wt=St-1;Wt>=0;--Wt){const Et=y(wt[Wt],!0);rt.insertBefore(Et,v(I))}}}return Vt(I),!0}return I instanceof c&&!Bt(I)||(ve==="noscript"||ve==="noembed"||ve==="noframes")&&rr(/<\/no(script|embed|frames)/i,I.innerHTML)?(Vt(I),!0):(ge&&I.nodeType===Wo.text&&(re=I.textContent,Uo([U,z,X],rt=>{re=Vo(re,rt," ")}),I.textContent!==re&&(zo(t.removed,{element:I.cloneNode()}),I.textContent=re)),_t(M.afterSanitizeElements,I,null),!1)},Nr=function(I,re,ve){if(te[re]||sr&&(re==="id"||re==="name")&&(ve in r||ve in lr))return!1;const rt=ie[re]||oe.attributeCheck instanceof Function&&oe.attributeCheck(re,I);if(!(Me&&!te[re]&&rr(B,re))){if(!(me&&rr(L,re))){if(!rt||te[re]){if(!(jr(I)&&(ee.tagNameCheck instanceof RegExp&&rr(ee.tagNameCheck,I)||ee.tagNameCheck instanceof Function&&ee.tagNameCheck(I))&&(ee.attributeNameCheck instanceof RegExp&&rr(ee.attributeNameCheck,re)||ee.attributeNameCheck instanceof Function&&ee.attributeNameCheck(re,I))||re==="is"&&ee.allowCustomizedBuiltInElements&&(ee.tagNameCheck instanceof RegExp&&rr(ee.tagNameCheck,ve)||ee.tagNameCheck instanceof Function&&ee.tagNameCheck(ve))))return!1}else if(!st[re]){if(!rr(j,Vo(ve,K,""))){if(!((re==="src"||re==="xlink:href"||re==="href")&&I!=="script"&&Py(ve,"data:")===0&&Fe[I])){if(!(De&&!rr(D,Vo(ve,K,"")))){if(ve)return!1}}}}}}return!0},Qr=Ze({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),jr=function(I){return!Qr[Oi(I)]&&rr(le,I)},Hr=function(I){_t(M.beforeSanitizeAttributes,I,null);const re=I.attributes;if(!re||zn(I))return;const ve={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ie,forceKeepAttr:void 0};let rt=re.length;for(;rt--;){const wt=re[rt],St=wt.name,Wt=wt.namespaceURI,Et=wt.value,Ur=Nt(St),Go=Et;let Ot=St==="value"?Go:kF(Go);if(ve.attrName=Ur,ve.attrValue=Ot,ve.keepAttr=!0,ve.forceKeepAttr=void 0,_t(M.uponSanitizeAttribute,I,ve),Ot=ve.attrValue,zt&&(Ur==="id"||Ur==="name")&&Py(Ot,he)!==0&&(wr(St,I),Ot=he+Ot),Se&&rr(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Ot)){wr(St,I);continue}if(Ur==="attributename"&&Fy(Ot,"href")){wr(St,I);continue}if(ve.forceKeepAttr)continue;if(!ve.keepAttr){wr(St,I);continue}if(!ne&&rr(/\/>/i,Ot)){wr(St,I);continue}ge&&Uo([U,z,X],Cn=>{Ot=Vo(Ot,Cn," ")});const pn=Nt(I.nodeName);if(!Nr(pn,Ur,Ot)){wr(St,I);continue}if(k&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!Wt)switch(m.getAttributeType(pn,Ur)){case"TrustedHTML":{Ot=k.createHTML(Ot);break}case"TrustedScriptURL":{Ot=k.createScriptURL(Ot);break}}if(Ot!==Go)try{Wt?I.setAttributeNS(Wt,St,Ot):I.setAttribute(St,Ot),zn(I)?Vt(I):Ty(t.removed)}catch{wr(St,I)}}_t(M.afterSanitizeAttributes,I,null)},_r=function(I){let re=null;const ve=Yt(I);for(_t(M.beforeSanitizeShadowDOM,I,null);re=ve.nextNode();)_t(M.uponSanitizeShadowNode,re,null),Wi(re),Hr(re),re.content instanceof i&&_r(re.content);_t(M.afterSanitizeShadowDOM,I,null)},Xt=function(I){if(I.nodeType===Wo.element&&I.shadowRoot instanceof i){const rt=I.shadowRoot;Xt(rt),_r(rt)}const re=I.childNodes;if(!re)return;const ve=[];Uo(re,rt=>{zo(ve,rt)});for(const rt of ve)Xt(rt)};return t.sanitize=function(Ne){let I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},re=null,ve=null,rt=null,wt=null;if(ar=!Ne,ar&&(Ne="<!-->"),typeof Ne!="string"&&!Vi(Ne)&&(Ne=PF(Ne),typeof Ne!="string"))throw Sa("dirty is not a string, aborting");if(!t.isSupported)return Ne;if(kt||fn(I),t.removed=[],typeof Ne=="string"&&(J=!1),J){const Et=Ne.nodeName;if(typeof Et=="string"){const Ur=Nt(Et);if(!H[Ur]||Ae[Ur])throw Sa("root node is forbidden and cannot be sanitized in-place")}Xt(Ne)}else if(Vi(Ne))re=Jr("<!---->"),ve=re.ownerDocument.importNode(Ne,!0),ve.nodeType===Wo.element&&ve.nodeName==="BODY"||ve.nodeName==="HTML"?re=ve:re.appendChild(ve),Xt(ve);else{if(!It&&!ge&&!yt&&Ne.indexOf("<")===-1)return k&&Dt?k.createHTML(Ne):Ne;if(re=Jr(Ne),!re)return It?null:Dt?N:""}re&&Ut&&Vt(re.firstChild);const St=Yt(J?Ne:re);for(;rt=St.nextNode();)Wi(rt),Hr(rt),rt.content instanceof i&&_r(rt.content);if(J)return ge&&cr(Ne),Ne;if(It){if(ge&&cr(re),Er)for(wt=C.call(re.ownerDocument);re.firstChild;)wt.appendChild(re.firstChild);else wt=re;return(ie.shadowroot||ie.shadowrootmode)&&(wt=W.call(n,wt,!0)),wt}let Wt=yt?re.outerHTML:re.innerHTML;return yt&&H["!doctype"]&&re.ownerDocument&&re.ownerDocument.doctype&&re.ownerDocument.doctype.name&&rr(zF,re.ownerDocument.doctype.name)&&(Wt="<!DOCTYPE "+re.ownerDocument.doctype.name+`>
|
|
52
|
+
`+Wt),ge&&Uo([U,z,X],Et=>{Wt=Vo(Wt,Et," ")}),k&&Dt?k.createHTML(Wt):Wt},t.setConfig=function(){let Ne=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};fn(Ne),kt=!0},t.clearConfig=function(){kr=null,kt=!1},t.isValidAttribute=function(Ne,I,re){kr||fn({});const ve=Nt(Ne),rt=Nt(I);return Nr(ve,rt,re)},t.addHook=function(Ne,I){typeof I=="function"&&zo(M[Ne],I)},t.removeHook=function(Ne,I){if(I!==void 0){const re=CF(M[Ne],I);return re===-1?void 0:EF(M[Ne],re,1)[0]}return Ty(M[Ne])},t.removeHooks=function(Ne){M[Ne]=[]},t.removeAllHooks=function(){M=jy()},t}var KF=Hy();const GF=["a","b","br","div","em","h1","h2","h3","h4","h5","h6","i","img","li","ol","p","span","strong","table","tbody","td","th","thead","tr","u","ul"],qF=["href","target","rel","src","alt","title","class","style","colspan","rowspan"];function YF(e){return e?KF.sanitize(e,{ALLOWED_TAGS:[...GF],ALLOWED_ATTR:[...qF],ALLOW_DATA_ATTR:!1}):""}function XF(e,t,r=!1){return e.includes("{labelapi:")?e.replace(/\{labelapi:([^}]+)\}/g,(n,o)=>{const i=o.trim();if(i===""||t==null)return r?"":n;const s=We(t,i);return s==null?r?"":n:String(s)}):e}function JF(e){return e&&e.replace(/\{api:[^}]*\}/gi,"").replace(/\{labelapi:[^}]*\}/gi,"").replace(/\{resp:[^}]*\}/gi,"").replace(/\{(?:ctx:|@)\w+\}/gi,"").replace(/\{documentId\}/gi,"").replace(/\{(\w+)\}/g,"")}const Uy={sm:"text-sm",md:"text-base",lg:"text-lg"},zy={h1:"text-4xl font-bold tracking-tight",h2:"text-3xl font-semibold tracking-tight",h3:"text-2xl font-semibold",h4:"text-xl font-semibold",h5:"text-lg font-medium",h6:"text-base font-medium"},Vy={normal:"font-normal",medium:"font-medium",bold:"font-bold"},Aa={left:"text-left",center:"text-center",right:"text-right",justify:"text-justify"};function ao(e){return e.properties??{}}function QF(e){const t=ao(e);return t.textContent!==void 0?t.textContent:e.label??""}function ZF(e){return ao(e).textContent===void 0||e.appearance?.hideLabel?!1:!!e.label?.trim()}function eP(e){return e?.contentLayout==="paragraph"?"paragraph":"single"}function ld(e,t={}){const{formValues:r={},urlParams:n={},submissionContext:o,buttonResponses:i,prepopulateResponse:s,labelApiResponse:a}=t,c=Rr(e,r,n,o,i,s),u=XF(c,a,!0);return JF(u)}const tP=/\{api:[^}]+\}/,rP=/\{labelapi:[^}]+\}/;function cd(e){return tP.test(e)}function dd(e){return rP.test(e)}function nP(e){const t=e.captionTemplate??"",r=e.descriptionTemplate??"",n=cd(e.bodyTemplate)||cd(t)||cd(r),o=dd(e.bodyTemplate)||dd(t)||dd(r);return!!(n&&e.prepopulateLoading||o&&e.labelApiConfigPresent&&(e.labelApiLoading||e.labelApiResponse===void 0&&e.labelApiError==null))}function Wy(e,t){const r=t??ao(e),n=r.variant??"body",o=e.appearance?.size??"md",i=Uy[o]??Uy.md,s=r.fontWeight??"medium";return n!=="body"?V("m-0 text-foreground",zy[n]??zy.h3,r.fontWeight&&Vy[r.fontWeight],r.italic&&"italic",r.underline&&"underline",r.textAlign&&Aa[r.textAlign]):V("m-0 text-foreground",i,Vy[s],r.italic&&"italic",r.underline&&"underline",r.textAlign&&Aa[r.textAlign])}function oP(e,t){const r=(t??ao(e)).variant??"body";return r==="body"?"p":r}function ud(e){const t=[];let r=0,n="";const o=()=>{n&&(t.push({type:"text",value:n}),n="")},i=(s,a,c)=>{if(!e.startsWith(s,r))return!1;const u=e.indexOf(a,r+s.length);if(u===-1)return!1;o();const f=e.slice(r+s.length,u);return t.push({type:c,children:ud(f)}),r=u+a.length,!0};for(;r<e.length;){if(e[r]==="\\"&&r+1<e.length){n+=e[r+1],r+=2;continue}i("**","**","bold")||i("__","__","underline")||i("*","*","italic")||i("_","_","italic")||(n+=e[r],r+=1)}return o(),t}function iP(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Ry(e){return e.map(t=>{if(t.type==="text")return iP(t.value);const r=Ry(t.children);return t.type==="bold"?`<strong class="font-bold">${r}</strong>`:t.type==="italic"?`<em class="italic">${r}</em>`:`<u class="underline">${r}</u>`}).join("")}function sP(e){return e?Ry(ud(e)):""}function aP(e,t){return e?t==="markdown-lite"?sP(e):e:""}function Ky(e,t){return e.map((r,n)=>{const o=`${t}-${n}`;if(r.type==="text")return r.value?w.createElement(w.Fragment,{key:o},r.value):null;const i=Ky(r.children,o);return r.type==="bold"?w.createElement("strong",{key:o,className:"font-bold"},i):r.type==="italic"?w.createElement("em",{key:o,className:"italic"},i):w.createElement("u",{key:o,className:"underline"},i)})}function Gy(e,t){if(!e)return null;if(t!=="markdown-lite")return e;const r=ud(e);return r.length===1&&r[0]?.type==="text"?r[0].value:Ky(r,"tl")}const lP="text-label-html prose prose-sm max-w-none [&_p]:m-0 [&_p+p]:mt-2 [&_ul]:my-1 [&_ol]:my-1";function qy(e,t){if(!e)return null;const{field:r,asDescription:n=!1}=t,o=t.textProps??ao(r),i=t.contentLayout??eP(o),s=o.inlineFormat??"none";if(i==="paragraph"){const c=YF(aP(e,s));if(!c)return null;const u=n?V("m-0 text-sm",o.descriptionMuted!==!1?"text-muted-foreground":"text-foreground",o.textAlign&&Aa[o.textAlign]):V(Wy(r,o),lP);return w.createElement("div",{className:u,dangerouslySetInnerHTML:{__html:c}})}if(n)return w.createElement("p",{className:V("mt-0.5 text-sm",o.descriptionMuted!==!1?"text-muted-foreground":"text-foreground",o.textAlign&&Aa[o.textAlign])},Gy(e,s));const a=oP(r,o);return w.createElement(a,{className:Wy(r,o)},Gy(e,s))}function cP(e){const t=e.labelApiEndpoint?.trim();return!e.labelApiEnabled||!t?null:{labelApiEndpoint:t,labelApiMethod:e.labelApiMethod??"GET",labelApiQueryParams:e.labelApiQueryParams,labelApiHeaders:e.labelApiHeaders,labelApiBodyFields:e.labelApiBodyFields}}async function dP(e,t={}){const{formValues:r={},urlParams:n={},submissionContext:o}=t,i=l=>Rr(l,r,n,o),s=(e.labelApiMethod??"GET").toUpperCase();let a=Mr(i(e.labelApiEndpoint));const c=e.labelApiQueryParams??[];if(c.length){const l=new URLSearchParams;c.forEach(({key:g,value:m})=>{g.trim()&&l.append(g,i(m))});const p=l.toString();p&&(a=`${a}${a.includes("?")?"&":"?"}${p}`)}const u={"Content-Type":"application/json"};(e.labelApiHeaders??[]).forEach(({key:l,value:p})=>{l.trim()&&(u[l]=i(p))});let f;s==="POST"&&(e.labelApiBodyFields??[]).length&&(f={},e.labelApiBodyFields.forEach(({key:l,value:p})=>{l.trim()&&(f[l]=i(p))}));try{return s==="POST"?(await qt.post(a,f??{},{headers:Object.keys(u).length?u:void 0})).data:(await qt.get(a,{headers:Object.keys(u).length?u:void 0})).data}catch(l){const p=l,g=p.response?.status,m=typeof p.response?.data=="string"?p.response.data:p.message??"Request failed";throw new Error(g?`HTTP ${g}: ${m}`:String(m))}}const uP=({field:e,className:t,formValues:r,urlParams:n,submissionContext:o,buttonResponses:i,prepopulateResponse:s,prepopulateLoading:a=!1})=>{const c=ao(e),u=w.useMemo(()=>cP(ao(e)),[e.properties]),[f,l]=w.useState(void 0),[p,g]=w.useState(!1),[m,h]=w.useState(null),y=w.useMemo(()=>u?JSON.stringify({endpoint:u.labelApiEndpoint,method:u.labelApiMethod,query:u.labelApiQueryParams,headers:u.labelApiHeaders,body:u.labelApiBodyFields}):"",[u]),S=w.useCallback(async()=>{if(!u){l(void 0),h(null),g(!1);return}g(!0),h(null);try{const O=await dP(u,{formValues:r??{},urlParams:n??{},submissionContext:o});l(O)}catch(O){l(void 0),h(O instanceof Error?O.message:"Failed to load label API")}finally{g(!1)}},[u,r,n,o]);w.useEffect(()=>{y&&S()},[y,S]);const v=c.textAlign==="center"?"items-center":c.textAlign==="right"?"items-end":c.textAlign==="justify"?"items-stretch":"items-start",A=QF(e),x=ZF(e),F=x&&e.label?e.label:"",k=e.description??"",N=nP({bodyTemplate:A,captionTemplate:F,descriptionTemplate:k,prepopulateLoading:a,labelApiConfigPresent:u!=null,labelApiLoading:p,labelApiResponse:f,labelApiError:m}),T={formValues:r??{},urlParams:n??{},submissionContext:o,buttonResponses:i,prepopulateResponse:s,labelApiResponse:f},P=A?ld(A,T):"",E=x&&e.label?ld(e.label,T):"",C=k?ld(k,T):"";return d.jsx("div",{className:V("w-full min-w-0 h-full min-h-[95px] flex flex-col justify-center py-0.5",v,t),children:N?d.jsx("p",{className:"text-sm text-muted-foreground m-0",children:"Loading…"}):d.jsxs(d.Fragment,{children:[m&&u?d.jsx("p",{className:"text-[10px] text-destructive mb-0.5",title:m,children:"Label API failed"}):null,E?d.jsx("div",{className:"text-sm font-medium text-foreground mb-1 w-full",children:E}):null,P?qy(P,{field:e,textProps:c}):null,C?qy(C,{field:e,textProps:c,asDescription:!0}):null]})})},fd=({legend:e,children:t,className:r,collapsible:n=!1,defaultCollapsed:o=!1,headerActions:i,onCollapsedChange:s})=>{const[a,c]=w.useState(o),u=w.useId(),f=l=>{l.stopPropagation(),n&&c(p=>{const g=!p;return s?.(g),g})};return d.jsxs("fieldset",{className:V("min-w-0 rounded-lg border bg-card p-4",r),"data-form-renderer":"config-section-border",children:[n?d.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2 border-b border-border pb-2",children:[d.jsxs("button",{type:"button",className:V("flex min-w-0 flex-1 items-center gap-2 text-left text-sm font-medium text-foreground","cursor-pointer rounded-sm hover:bg-muted/70 transition-colors focus:outline-none focus:ring-2 focus:ring-ring"),"aria-expanded":!a,"aria-controls":u,onClick:f,children:[d.jsx("span",{className:"shrink-0 text-muted-foreground","aria-hidden":!0,children:a?d.jsx(Zu,{className:"h-4 w-4"}):d.jsx(ii,{className:"h-4 w-4"})}),d.jsx("span",{className:"truncate",children:e})]}),i!=null?d.jsx("div",{className:"shrink-0",children:i}):null]}):d.jsx("legend",{className:"px-1 text-sm font-medium text-foreground",children:e}),!a&&d.jsxs("div",{id:u,className:"space-y-3",children:[!n&&i!=null?d.jsx("div",{className:"flex justify-end",children:i}):null,t]})]})};function Yy(e){const t=e.properties,r=t?.apiEndpoint?{apiEndpoint:t.apiEndpoint,apiMethod:t.apiMethod,apiKey:t.apiKey,apiRealtime:t.apiRealtime,apiAutoDetect:t.apiAutoDetect,apiLabelField:t.apiLabelField,apiValueField:t.apiValueField,apiQueryParams:t.apiQueryParams,apiClientFilter:t.apiClientFilter,apiHeaders:t.apiHeaders,apiBodyFields:t.apiBodyFields,apiAuth:t.apiAuth,valueSource:t.valueSource,dependentFields:t.dependentFields}:null,n=e.apidata||null;return r||n}function pd(e){const t=Yy(e),r=e.properties;return!!(t?.apiEndpoint&&(t?.valueSource==="api"||r?.valueSource==="api"))}function Xy({field:e,formValues:t={},submissionContext:r,value:n,onChange:o,clearWhenBlocked:i=!0}){const s=e.properties,a=Yy(e),c=pd(e),[u,f]=w.useState(!1),[l,p]=w.useState(null),g=w.useRef(null),m=w.useRef(n);m.current=n;const h=w.useMemo(()=>{const F=a?.apiEndpoint||s?.apiEndpoint||"",k=a?.apiQueryParams||s?.apiQueryParams;return mo(F,k)},[a?.apiEndpoint,s?.apiEndpoint,a?.apiQueryParams,s?.apiQueryParams]),y=w.useMemo(()=>{const F=new Set;for(const N of s?.dependentFields??a?.dependentFields??[])typeof N=="string"&&N.trim()&&F.add(N.trim());const k=a?.apiClientFilter?.matchField?.trim()||s?.apiClientFilter?.matchField?.trim();return k&&F.add(k),[...F]},[s?.dependentFields,a?.dependentFields,a?.apiClientFilter?.matchField,s?.apiClientFilter?.matchField]),S=w.useMemo(()=>{const F=new Set([...h,...y]);if(F.size===0)return null;const k={};return F.forEach(N=>{k[N]=t[N]}),JSON.stringify(k)},[h,y,t]),v=w.useMemo(()=>JSON.stringify(r||{}),[r]),A=w.useMemo(()=>{const F=new Set;e.name?.trim()&&F.add(e.name.trim());const k=e.key;return typeof k=="string"&&k.trim()&&F.add(k.trim()),[...F]},[e.name,e.key]),x=e.type==="number"?null:"";return w.useEffect(()=>{const F=a?.apiEndpoint;if(!c||!F)return;let k=!1;const N=P=>{if(k)return;const E=m.current;if(P==null||P.trim()===""){i&&E!==x&&E!==void 0&&(g.current=null,o(x));return}if(e.type==="number"){const C=Number(P),O=Number.isFinite(C)?C:null;E!==O&&g.current!==P&&(g.current=P,o(O));return}String(E??"")!==P&&g.current!==P&&(g.current=P,o(P))};return(async()=>{f(!0),p(null);try{const P=a?.apiMethod||s?.apiMethod||"GET",E=a?.apiRealtime||s?.apiRealtime,C=a?.apiQueryParams||s?.apiQueryParams||{},O=ss({apiEndpoint:F,apiMethod:P,apiQueryParams:C,formValues:t,submissionContext:r,apiRealtime:E,additionalRequiredFieldNames:y,excludeFormFieldNames:A});if(O.blocked){k||(f(!1),i&&N(null));return}const W={"Content-Type":"application/json"},M=a?.apiKey||s?.apiKey;M&&(W["X-CSCAPI-KEY"]=M);const U=e.apidata,z=a?.apiAuth??s?.apiAuth??U?.apiAuth??Ai(a?.apiHeaders??s?.apiHeaders??U?.apiHeaders)??{type:"none"},X=Ci(z,{formValues:t,submissionContext:r,apiRealtime:E});Object.assign(W,X);const B=a?.apiHeaders??s?.apiHeaders??U?.apiHeaders,L=a?.apiBodyFields??s?.apiBodyFields??U?.apiBodyFields,D=Sn(xi(B),{formValues:t,submissionContext:r,apiRealtime:E});Object.assign(W,D);const K=Sn(L,{formValues:t,submissionContext:r,apiRealtime:E}),le={method:P.toLowerCase(),url:Mr(O.url),headers:W};(O.postBodyBase!=null||Object.keys(K).length>0)&&(le.data={...O.postBodyBase??{},...K});const j=await At(le),H=a?.apiLabelField||s?.apiLabelField,ce=a?.apiValueField||s?.apiValueField,ie=a?.apiClientFilter||s?.apiClientFilter;let G=QE(j.data,ce,H);if(ie?.filterField&&ie?.matchField&&G!=null){const ee=t[ie.matchField];if(ee==null)G=null;else{const Ae=Si(j.data,H,ce),te=Array.isArray(j.data)?j.data:j.data?.data?.data&&Array.isArray(j.data.data.data)?j.data.data.data:j.data?.data&&Array.isArray(j.data.data)?j.data.data:[],oe=Ae.filter(me=>{const Me=te.find(ne=>String(jt(ne,ce||"code"))===String(me.value));if(!Me)return!1;const De=jt(Me,ie.filterField);return String(De)===String(ee)});G=oe.length>0?oe[0].value:null}}k||N(G)}catch(P){if(k)return;let E="Failed to load value";const C=P;if(C.response){const O=C.response.data;if(C.response.status===404)E="API endpoint not found.";else if(C.response.status===401)E="Authentication failed.";else if(typeof O=="string")E=O;else if(O&&typeof O=="object"){const W=O;E=W.error||W.message||W.detail||E}}else C.message&&(E=String(C.message));p(E)}finally{k||f(!1)}})(),()=>{k=!0}},[c,a?.apiEndpoint,a?.apiMethod,a?.apiValueField,a?.apiLabelField,s?.apiEndpoint,s?.apiMethod,s?.apiValueField,s?.apiLabelField,S,y,A,v,e.type,i,x]),{isLoading:u,error:l}}const fP=({field:e,value:t,onChange:r,formValues:n,submissionContext:o,disabled:i,readOnly:s,...a})=>{const{isLoading:c}=Xy({field:e,formValues:n,submissionContext:o,value:t,onChange:r});return d.jsx(ds,{field:e,value:t||"",onChange:r,disabled:i||c,readOnly:s||c,...a})},pP=({field:e,value:t,onChange:r,formValues:n,submissionContext:o,disabled:i,readOnly:s,...a})=>{const{isLoading:c}=Xy({field:e,formValues:n,submissionContext:o,value:t,onChange:r});return d.jsx(gl,{field:e,value:t??null,onChange:r,disabled:i||c,readOnly:s||c,...a})},xn=({field:e,value:t,error:r,onChange:n,onBlur:o,disabled:i,readOnly:s,isRequired:a,className:c,formValues:u={},submissionContext:f,onSubmit:l,onReset:p,onCancel:g,isSubmitting:m,bffSubmitApi:h,onBffSubmitResult:y,extraSubmitPayload:S,buttonResponses:v,onButtonApiResponse:A,onValidateForm:x,getValidationErrors:F,allFields:k,onSubmittingChange:N,onAddMore:T,scopedFormValues:P,scopedFieldNameMap:E,excludedOptionValues:C,prepopulateMappedFieldNames:O,fieldValueKey:W,hideTableRowControls:M=!1,urlParams:U={},prepopulateResponse:z=null,prepopulateLoading:X=!1,formSections:B,submitPayload:L})=>{switch(e.type){case"divider":return d.jsx(cF,{field:e,className:c});case"header":return d.jsx(uF,{field:e,className:c});case"sectionHeading":return d.jsx(mF,{field:e,className:c});case"spacer":return d.jsx(hF,{field:e,className:c});case"textLabel":return d.jsx(uP,{field:e,className:c,formValues:u,urlParams:U,submissionContext:f,buttonResponses:v,prepopulateResponse:z??void 0,prepopulateLoading:X});case"status":return d.jsx(eF,{field:e,value:t??null,error:r,disabled:i,isRequired:a,className:c,formValues:u,submissionContext:f,extraSubmitPayload:S,prepopulateResponse:z})}switch(e.type){case"text":case"password":case"url":return e.type==="text"&&pd(e)?d.jsx(fP,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c,formValues:u,submissionContext:f}):d.jsx(ds,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c});case"number":return pd(e)?d.jsx(pP,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c,formValues:u,submissionContext:f}):d.jsx(gl,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c});case"email":return d.jsx(sf,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c});case"phone":case"aadhaar":return d.jsx(af,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c});case"otp":return d.jsx(op,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c,formValues:u,urlParams:U,submissionContext:{...typeof f=="object"&&f!==null?f:{},...S??{}},prepopulateResponse:z});case"textarea":case"richtext":return d.jsx(ip,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c});case"select":{const D=W??e.name??e.key??e.id,K=!!(D&&O?.has(D));return d.jsx(Vm,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:c,formValues:u,submissionContext:f,excludedOptionValues:C,isPrepopulateTarget:K})}case"multiselect":{const D=Array.isArray(t)?t:t!=null&&t!==""?[String(t)]:[];return d.jsx(Ph,{field:e,value:D,onChange:K=>n(K),onBlur:o,error:r,disabled:i,isRequired:a,className:c,formValues:u,submissionContext:f,excludedOptionValues:C})}case"asyncsearch":return d.jsx(lh,{field:e,value:t,onChange:D=>n(D),onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c,formValues:u,submissionContext:f});case"checkbox":case"terms":return d.jsx(Ih,{field:e,value:t||!1,onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:c});case"toggle":return d.jsx(cN,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:c});case"radio":case"checkboxgroup":return d.jsx(og,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:c,excludedOptionValues:C});case"selectablelist":{const D=Array.isArray(t)?t:[];return console.log("[SelectableList] FieldRenderer: passing to SelectableListField",{fieldName:e.name,value:D,valueLength:D.length,submissionContextKeys:f?Object.keys(f):[]}),d.jsx(rF,{field:e,value:D,onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:c,submissionContext:f})}case"date":case"time":case"datetime":case"daterange":return d.jsx(ig,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c});case"file":return d.jsx(MN,{field:e,value:t,onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:c,buttonResponses:v});case"camera":return d.jsx(l_,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:c});case"photoChoice":return d.jsx(c_,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:c,buttonResponses:v});case"signature":return d.jsx(NT,{field:e,value:t||null,onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c});case"rating":return d.jsx(iT,{field:e,value:t||0,onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c});case"slider":return d.jsx(kT,{field:e,value:t||0,onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c});case"table":return d.jsx(_T,{field:e,value:t||[],onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c,hideRowControls:M,formValues:u,submissionContext:f});case"billingGrid":return d.jsx(ZT,{field:e,value:t||{rows:[]},onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c,formValues:u,submissionContext:f});case"button":return d.jsx(Y_,{field:e,value:t,onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:c,onSubmit:l,onReset:p,onCancel:g,isSubmitting:m,formValues:u,submissionContext:f,buttonResponses:v,onButtonApiResponse:A,bffSubmitApi:h,onBffSubmitResult:y,extraSubmitPayload:S,onValidateForm:x,getValidationErrors:F,allFields:k,onSubmittingChange:N,scopedFormValues:P,scopedFieldNameMap:E,prepopulateResponse:z,formSections:B,submitPayload:L});case"editButton":return d.jsx(X_,{field:e,disabled:i,readOnly:s,isRequired:a,className:c,buttonResponses:v,onButtonApiResponse:A});case"addmore":return d.jsx(J_,{field:e,error:r,disabled:i,readOnly:s,isRequired:a,className:c,onAddMore:()=>T?.(e)});case"customizeSections":return d.jsx(oT,{field:e,error:r,disabled:i,readOnly:s,isRequired:a,className:c});default:return d.jsx("div",{className:"p-3 border rounded-md bg-muted/50",children:d.jsxs("p",{className:"text-sm text-muted-foreground",children:["Unsupported field type: ",e.type]})})}};function Li(e){if(!e)return e;const t={...e};return e._id&&!e.id&&(t.id=e._id),delete t._id,t.formDefinitionId&&typeof t.formDefinitionId=="object"&&(t.formDefinitionId=t.formDefinitionId._id||t.formDefinitionId.id||t.formDefinitionId),t}function Jy(e){return Array.isArray(e)?e.map(Li):[]}function mP(e){const t=!!e.standalone_form;if(!e.moduleId&&!t)throw new Error(`Form response missing required field: moduleId. Form ID: ${e._id||e.id}. Please ensure the backend returns moduleId when fetching forms.`);if(!e._id&&!e.id)throw new Error("Form response missing required field: id. Please ensure the backend returns _id or id when fetching forms.");let r;e.moduleId&&(typeof e.moduleId=="object"&&e.moduleId._id?r=Li(e.moduleId):r=e.moduleId);const n=e.isDefault??!1;if(!n&&!e.tenantId&&!t)throw new Error(`Form response missing required field: tenantId. Form ID: ${e._id||e.id}. Please ensure the backend returns tenantId when fetching non-default forms.`);return{id:e._id||e.id,name:e.name,description:e.description||"",version:e.version??1,status:e.status||"draft",category:e.category||"",createdAt:e.createdAt||new Date().toISOString(),updatedAt:e.updatedAt||e.createdAt||new Date().toISOString(),createdBy:e.createdBy||"",isActive:e.isActive??!0,isDefault:n,...r!==void 0&&{moduleId:r},tenantId:e.tenantId||void 0,featureId:e.featureId,config:e.config??void 0,standalone_form:t}}class hP{basePath="/api/form-builder/forms";async getForRendering(t,r){if(!nn())throw new Error("Client ID is required");const o=r!==void 0?`${this.basePath}/${t}/render?version=${r}`:`${this.basePath}/${t}/render`,i=await qt.get(o),s=i.data?.data||i.data,a=s?.BFF_submit_api||s?.bff_submit_api||i.data?.BFF_submit_api||i.data?.bff_submit_api,c=s.form||s,u=!!(c.standalone_form??s.form?.standalone_form);if(!c.moduleId&&!s.form?.moduleId&&!u)throw new Error(`Form response missing required field: moduleId. Form ID: ${t}. Please ensure the backend returns moduleId in the form response.`);if(!(c.isDefault??s.form?.isDefault??!1)&&!c.tenantId&&!s.form?.tenantId&&!u)throw new Error(`Form response missing required field: tenantId. Form ID: ${t}. Please ensure the backend returns tenantId for non-default forms.`);s.form?.moduleId&&!c.moduleId&&(c.moduleId=s.form.moduleId),s.form?.tenantId&&!c.tenantId&&(c.tenantId=s.form.tenantId),s.form?.isDefault!==void 0&&c.isDefault===void 0&&(c.isDefault=s.form.isDefault);const l=mP(c);s.form?.moduleId&&(typeof s.form.moduleId=="object"&&s.form.moduleId._id?l.moduleId=Li(s.form.moduleId):typeof s.form.moduleId=="string"&&(l.moduleId=s.form.moduleId));const p=Jy(s.fields||[]),g=s.layout?Li(s.layout):null,m=Jy(s.rules||[]),h=s.module?Li(s.module):void 0,y=s.clientMapping||s.clientOverrides;return{form:l,fields:p,layout:g,rules:m,module:h,clientMapping:y,clientOverrides:y,BFF_submit_api:a||void 0}}}const gP=new hP,yP={submitAction:"database",autoSave:!0,autoSaveInterval:30,showProgressBar:!0,allowDraft:!0,validateOnChange:!1,validateOnBlur:!0,showFieldErrors:"inline",layout:"default",submitButtonText:"Submit",resetButtonText:"Reset",showReset:!1,successMessage:"Form submitted successfully!",errorMessage:"An error occurred. Please try again."},bP=300;function vP(){return{...yP}}function wP(e){if(!e||typeof e!="object")return;const t=e,r=t.user_type??t.visibleToUserType??"",n=t.user_role??t.visibleToUserRole??"",o=Array.isArray(t.users)?t.users:Array.isArray(t.visibleToUserIds)?t.visibleToUserIds:[];if(!(r!=null&&r!==""||n!=null&&n!==""||o.length>0))return;const s={};return r!=null&&r!==""&&(s.visibleToUserType=r),n!=null&&n!==""&&(s.visibleToUserRole=n),o.length>0&&(s.visibleToUserIds=o),s}function SP(e){const t=vP();if(!e||typeof e!="object")return t;const r=e;return{...t,submitAction:r.submitAction||t.submitAction,apiEndpoint:r.apiEndpoint,dbTable:r.dbTable,emailTo:r.emailTo,workflowTrigger:r.workflowTrigger,workflowSubmissionConfig:r.workflowSubmissionConfig,prepopulateApi:r.prepopulateApi,prepopulateResponseRules:r.prepopulateResponseRules??void 0,sections:L_(r.sections),submitPayload:M_(r.submitPayload),autoSave:r.autoSave,autoSaveInterval:r.autoSaveInterval,showProgressBar:r.showProgressBar,allowDraft:r.allowDraft,validateOnChange:r.validateOnChange,validateOnBlur:r.validateOnBlur,showFieldErrors:r.showFieldErrors,layout:r.layout,submitButtonText:r.submitButtonText,resetButtonText:r.resetButtonText,showReset:r.showReset,successMessage:r.successMessage,successRedirect:r.successRedirect,errorMessage:r.errorMessage}}function Di(e,t,r,n){const o=t.map(l=>{let p=[],g={};try{l.options&&(p=JSON.parse(l.options)),l.metadata&&(g=JSON.parse(l.metadata))}catch{}const m=Fu(l);m&&Object.assign(g,m),p.length>0&&(g.options=p);const h=[];if(l.validationRequired&&h.push({type:"required",message:"This field is required"}),l.validationMinLength!==null&&l.validationMinLength!==void 0&&h.push({type:"minLength",value:l.validationMinLength,message:`Minimum length is ${l.validationMinLength}`}),l.validationMaxLength!==null&&l.validationMaxLength!==void 0&&h.push({type:"maxLength",value:l.validationMaxLength,message:`Maximum length is ${l.validationMaxLength}`}),l.validationPattern&&h.push({type:"pattern",value:l.validationPattern,message:"Invalid format"}),l.validationRules&&typeof l.validationRules=="object"){const j=l.validationRules;if(j.required===!0&&!h.some(H=>H.type==="required")&&h.push({type:"required",message:"This field is required"}),j.allowLetters!==void 0&&h.push({type:"allowLetters",value:j.allowLetters}),j.allowNumbers!==void 0&&h.push({type:"allowNumbers",value:j.allowNumbers}),j.allowSpecialChars!==void 0&&h.push({type:"allowSpecialChars",value:j.allowSpecialChars}),j.minLetters!==void 0&&typeof j.minLetters=="number"&&h.push({type:"minLetters",value:j.minLetters}),j.maxLetters!==void 0&&typeof j.maxLetters=="number"&&h.push({type:"maxLetters",value:j.maxLetters}),j.minNumbers!==void 0&&typeof j.minNumbers=="number"&&h.push({type:"minNumbers",value:j.minNumbers}),j.maxNumbers!==void 0&&typeof j.maxNumbers=="number"&&h.push({type:"maxNumbers",value:j.maxNumbers}),j.minSpecialChars!==void 0&&typeof j.minSpecialChars=="number"&&h.push({type:"minSpecialChars",value:j.minSpecialChars}),j.maxSpecialChars!==void 0&&typeof j.maxSpecialChars=="number"&&h.push({type:"maxSpecialChars",value:j.maxSpecialChars}),j.fileSize!==void 0&&typeof j.fileSize=="number"){const H=j.fileSize/1048576;h.push({type:"fileSize",value:j.fileSize,message:`File size must be less than ${H.toFixed(2)} MB`})}if(j.fileType!==void 0){const H=Array.isArray(j.fileType)?j.fileType:typeof j.fileType=="string"?j.fileType.split(",").map(ce=>ce.trim()).filter(Boolean):[];H.length>0&&h.push({type:"fileType",value:H,message:"File type is not allowed"})}}const y=[],S=new Set;n.filter(j=>{const H=typeof j.targetFieldId=="object"?j.targetFieldId.id||j.targetFieldId._id:j.targetFieldId;return!!(H===l.id||H===l._id||H&&l.fieldKey&&H===l.fieldKey)}).forEach(j=>{try{const H=JSON.parse(j.conditionExpression);!H.id&&j.id&&(H.id=j.id);const ce=typeof j.targetFieldId=="object"?j.targetFieldId?.id||j.targetFieldId?._id:j.targetFieldId;H.action&&(!H.then||!Array.isArray(H.then)||H.then.length===0)&&(H.then=[{action:H.action,...ce&&{target:ce}}]),(!H.then||!Array.isArray(H.then)||H.then.length===0)&&j.action&&(H.then=[{action:j.action,...ce&&{target:ce}}]),H.then&&Array.isArray(H.then)&&ce&&(H.then=H.then.map(G=>!G.target&&ce?{...G,target:ce}:G));const ie=j.conditionExpression||JSON.stringify(H);if(S.has(ie))return;S.add(ie),y.push(H)}catch{}});const A=l.disabled===!0||g?.disabled===!0||!1;let x=l.readOnly===!0||g?.readOnly===!0||!1;const F=l.hidden===!0||g?.hidden===!0||!1;(g?.valueSource==="calculated"||g?.formula)&&(x=!0);const{disabled:k,readOnly:N,hidden:T,...P}=g,E={};P.hideLabel!==void 0&&(E.hideLabel=P.hideLabel),P.labelPosition!==void 0&&(E.labelPlacement=P.labelPosition),P.size!==void 0&&(E.size=P.size),P.customClass!==void 0&&(E.className=P.customClass);const{labelPosition:C,size:O,customClass:W,visibility:M,...U}=P,z=Object.keys(U).length>0?U:void 0,X=Object.keys(E).length>0?E:void 0,B=l.visibility??g?.visibility??M;let L=wP(B);if(B&&!L){const j=B;(j.visibleToUserType!=null||j.visibleToUserRole!=null||Array.isArray(j.visibleToUserTypes)&&j.visibleToUserTypes.length>0||Array.isArray(j.visibleToUserRoles)&&j.visibleToUserRoles.length>0||Array.isArray(j.visibleToUserIds)&&j.visibleToUserIds.length>0||Array.isArray(j.hiddenFromUserIds)&&j.hiddenFromUserIds.length>0)&&(L={visibleToUserType:j.visibleToUserType??(Array.isArray(j.visibleToUserTypes)?j.visibleToUserTypes[0]:void 0),visibleToUserRole:j.visibleToUserRole??(Array.isArray(j.visibleToUserRoles)?j.visibleToUserRoles[0]:void 0),visibleToUserIds:j.visibleToUserIds,hiddenFromUserIds:j.hiddenFromUserIds})}const D=g?.columnName,le=!!l.parentFieldId&&typeof D=="string"?D:l.fieldKey;return{id:l.id,type:l.fieldType,name:le,label:l.label,description:l.helpText||void 0,placeholder:l.placeholder||void 0,defaultValue:l.defaultValue||void 0,position:{order:typeof l.positionOrder=="number"?l.positionOrder:l.positionRow??0,column:typeof l.positionColumn=="number"?l.positionColumn:1,columnSpan:typeof l.positionWidth=="number"?l.positionWidth:1},parentId:void 0,appearance:X,validation:h.length>0?h:void 0,conditions:y.length>0?y:void 0,properties:z,visibility:L&&(L.visibleToUserType!=null||L.visibleToUserRole!=null||Array.isArray(L.visibleToUserIds)&&L.visibleToUserIds.length>0||Array.isArray(L.hiddenFromUserIds)&&L.hiddenFromUserIds.length>0)?L:void 0,disabled:A,readOnly:x,hidden:F}});o.forEach((l,p)=>{if(l.visibility){const g=t[p];console.log("[backendToFormSchema] field with visibility",{fieldKey:g?.fieldKey??l.name,name:l.name,type:l.type,parentFieldId:g?.parentFieldId,visibility:l.visibility})}});const i=t;for(let l=0;l<o.length;l++){const p=i[l]?.parentFieldId;if(p){const g=o.find(h=>h.id===p||h.type==="table"&&h.name===p||h.type==="table"&&i[l].fieldKey?.startsWith?.(h.name+"_column_")),m=o[l];if(g&&g.type==="table"&&m){const h=g.properties||{};Array.isArray(h.columns)||(h.columns=[]),h.columns.push(m),g.properties=h}}}const s=o.filter((l,p)=>!i[p]?.parentFieldId);for(const l of s)if(l.type==="table"&&l.properties&&Array.isArray(l.properties.columns)){const p=l.properties.columns;for(const g of p){const m=g.properties?.columnName;typeof m=="string"&&(g.name=m)}p.sort((g,m)=>(g.position?.order??0)-(m.position?.order??0)||(g.position?.column??0)-(m.position?.column??0))}let a;const c=e.config;if(console.log("[Prepopulate] backendToFormSchema config",{formId:e.id,hasRawConfig:c!=null,rawConfigType:typeof c,rawConfigPreview:c!=null?typeof c=="string"?c.slice(0,300):JSON.stringify(c).slice(0,300):null}),c!=null)try{const l=typeof c=="string"?JSON.parse(c):c;l&&typeof l=="object"?a=SP(l):a={submitAction:"database",layout:"default",autoSave:!0,validateOnChange:!0,showFieldErrors:"inline"}}catch{a={submitAction:"database",layout:"default",autoSave:!0,validateOnChange:!0,showFieldErrors:"inline"}}else a={submitAction:"database",layout:"default",autoSave:!0,validateOnChange:!0,showFieldErrors:"inline"};const u=qi(r);u&&(a={...a,grid:u});const f=typeof e.moduleId=="string"?e.moduleId:e.moduleId?.id;return{id:e.id,name:e.name,description:e.description,version:e.version,status:e.status,config:a,fields:s,createdAt:e.createdAt,updatedAt:e.updatedAt,createdBy:e.createdBy,category:e.category,...f?{moduleId:f}:{},standalone_form:e.standalone_form,tenantId:e.tenantId,featureId:e.featureId,isDefault:e.isDefault}}const xP=new Set(["PENDING_PAYMENT","PAYMENT_PENDING","AWAITING_PAYMENT","PAID","PAYMENT_COMPLETED","PAYMENT_FAILED","REFUNDED","AUTHORIZED","CAPTURED","PARTIALLY_PAID"].map(e=>e.toUpperCase()));function md(e){return typeof e=="string"&&e.trim()!==""}function hd(e){if(e==null||typeof e!="object"||Array.isArray(e))return!1;const t=e;if(t.payment_type!=null&&t.payment_type!==""||t.payment_mode!=null&&t.payment_mode!==""||t.transaction_id!=null&&String(t.transaction_id).trim()!==""||t.payment_status!=null&&String(t.payment_status).trim()!==""||typeof t.amount=="number"||md(t.amount)||typeof t.total_amount=="number"||md(t.total_amount)||md(t.currency)||t.gateway!=null&&String(t.gateway).trim()!==""||t.razorpay_order_id!=null&&String(t.razorpay_order_id).trim()!==""||t.stripe_payment_intent!=null&&String(t.stripe_payment_intent).trim()!=="")return!0;const r=t.status;return!!(typeof r=="string"&&xP.has(r.trim().toUpperCase()))}function AP(e){const t=We(e,"data.items");if(!Array.isArray(t)||t.length===0)return;const r=t[0];if(r==null||typeof r!="object")return;const n=r;if(!(n.id===void 0||n.id===null||n.id===""))return{item:n,id:n.id}}function CP(e,t){const r=AP(e);if(!r)return;const n=We(e,"data"),o=n!=null&&typeof n=="object"&&!Array.isArray(n)?n:void 0;if(t?.treatFirstItemIdAsPaymentId===!0||hd(r.item)||o!=null&&hd(o))return r.id}function EP(e){const t=e.properties,r=e.metadata;return[t?.uploadApiEndpoint,t?.apiEndpoint,r?.uploadApiEndpoint,r?.apiEndpoint].filter(o=>typeof o=="string"&&o.length>0)}function kP(e){return EP(e).some(t=>t.toLowerCase().includes("payment"))}function NP(e){const t=e.properties,r=e.metadata;return!!(t?.mergeSuccessDataIdAsPaymentId||r?.mergeSuccessDataIdAsPaymentId)}function _P(e,t){if(t?.type!=="button"||!ri(e))return;const r=We(e,"data.id");if(r==null||String(r).trim()==="")return;const n=We(e,"data");if(NP(t)||n!=null&&typeof n=="object"&&!Array.isArray(n)&&hd(n)||kP(t))return r}const TP=new Set(["section","group","columns","divider","header","sectionHeading","spacer","addmore","textLabel","customizeSections"]);function FP(e,t){if(!e.length||!t?.length)return[];const r=new Map(t.map(o=>[o.id,o])),n=[];for(const o of e){const i=r.get(o);if(i?.fieldNames?.length)for(const s of i.fieldNames)s&&!n.includes(s)&&n.push(s)}return n}function PP(e,t){const r=e.properties,n=Array.isArray(r?.linkedFieldNames)?r.linkedFieldNames:[],o=FP(Array.isArray(r?.linkedSectionIds)?r.linkedSectionIds:[],t),i=new Set,s=[];for(const a of[...n,...o])!a||i.has(a)||(i.add(a),s.push(a));return s}function Qy(e,t){const r=e.properties,n=Array.isArray(r?.linkedSectionIds)?r.linkedSectionIds:[];if(!n.length||!t?.length)return[];const o=new Map(t.map(i=>[i.id,i]));return n.map(i=>o.get(i)).filter(i=>!!i)}function IP(e,t){return Qy(e,t).find(r=>r.heading?.enabled)}function Zy(e,t){const r=e.template??"";return(e.mode??"increment")==="fixed"?r:r.replace(/\{n\}/g,String(t+1))}function eb(e,t,r,n){const o=PP(e,r);if(o.length===0)return[];const i=new Set(o);return t.filter(s=>{const a=n(s);return!a||s.id===e.id||TP.has(s.type)?!1:i.has(a)})}function OP(e,t,r){if(e.type!=="sectionHeading"||!t?.length)return;const n=r(e);if(n)for(const o of t){const i=o.heading;if(i?.enabled&&i.headingFieldName===n)return i}}function gd(e){return[...e].sort((t,r)=>{const n=t.position?.order??0,o=r.position?.order??0;if(n!==o)return n-o;const i=t.position?.column??1,s=r.position?.column??1;return i-s})}function MP(e,t,r){if(!e?.length)return[];const n=e.filter(s=>s.showBorder===!0);if(n.length===0)return[];const o=new Map;for(const s of t){const a=r(s);a&&o.set(a,s)}const i=[];for(const s of n){const a=s.fieldNames.map(u=>o.get(u)).filter(u=>!!u);if(a.length===0)continue;const c=gd(a).map(u=>r(u)).filter(Boolean);i.push({section:s,fieldNames:c})}return i}function Bi(e,t=0){return e.heading?.enabled?Zy(e.heading,t):e.name}function tb(e,t,r){if(e.type!=="sectionHeading")return!1;const n=t.heading;return!n?.enabled||!n.headingFieldName?!1:r(e)===n.headingFieldName}function LP(e,t){const r=typeof e.position?.order=="number"?e.position.order:0,n=(e.position?.column??1)-1,o=Qo(e),i=lu(e,t);return{row:r,col:n,rowEnd:r+o-1,colEnd:n+i-1}}function yd(e,t){let r=1/0,n=-1/0,o=1/0,i=-1/0;for(const s of e){const{row:a,col:c,rowEnd:u,colEnd:f}=LP(s,t);r=Math.min(r,a),n=Math.max(n,u),o=Math.min(o,c),i=Math.max(i,f)}return Number.isFinite(r)?{minRow:r,maxRow:n,minCol:o,maxCol:i,rowSpan:n-r+1,colSpan:i-o+1}:null}function DP(e,t,r,n){const o=e.map(f=>t.find(l=>n(l)===f)).filter(f=>!!f&&typeof f.position?.order=="number");if(o.length===0)return null;const i=yd(o,r);if(!i)return null;const s=o.filter(f=>f.type!=="sectionHeading"),a=s.length>0?s:o,c=Math.min(...a.map(f=>f.position?.order??0)),u=Math.max(1,...a.map(f=>(f.position?.order??c)-c+Qo(f)));return{minRow:i.minRow,maxRow:i.maxRow,minCol:i.minCol,maxCol:i.maxCol,blockHeight:u}}function BP(e,t){return e.maxRow+1+t*e.blockHeight}function $P(e,t,r,n){const o=new Map;for(const a of t){const c=r(a);c&&o.set(c,a)}const i=new Map,s=new Set;for(const a of e){const c=a.fieldNames.map(v=>o.get(v)).filter(v=>!!v);if(c.length===0)continue;const u=c.filter(v=>!tb(v,a.section,r)),f=yd(c,n);if(!f)continue;const{minRow:l,minCol:p,rowSpan:g,colSpan:m}=f,h=`${l}-${p}`;if(i.has(h))continue;const y=new Set;let S=!1;for(let v=l;v<=l+g-1;v++){for(let A=p;A<=p+m-1;A++){const x=`${v}-${A}`;if(s.has(x)){S=!0;break}y.add(x)}if(S)break}if(!S){for(const v of y)s.add(v);i.set(h,{anchorRow:l,anchorCol:p,rowSpan:g,colSpan:m,run:a,legend:Bi(a.section,0),renderFields:u.length>0?u:c})}}return{anchorsByOrigin:i,coveredCells:s}}function jP(e,t,r,n,o,i,s){const a=new Set(s),c=new Map;for(const u of e){const f=rb(u.linkedFields.map(p=>i(p)).filter(Boolean),t),l=f?.section;l?.fieldNames?.length?l.fieldNames:u.templateFieldNames,u.blockIds.forEach((p,g)=>{const m=r.filter(N=>N.id.endsWith(`__${p}`));if(m.length===0||!f)return;const h=yd(m,o);if(!h)return;const{minRow:y,minCol:S,rowSpan:v,colSpan:A}=h,x=`${y}-${S}`;for(let N=y;N<=y+v-1;N++)for(let T=S;T<=S+A-1;T++)a.add(`${N}-${T}`);const F=f,k=Bi(l,g+1);c.set(x,{anchorRow:y,anchorCol:S,rowSpan:v,colSpan:A,run:F,legend:k,renderFields:gd(m),addMoreMeta:{addMoreFieldName:u.addMoreFieldName,blockId:p,blockIndex:g}})})}return{anchorsByOrigin:c,coveredCells:a}}function HP(e,t,r,n){const o=`${e}-${t}`;return r.has(o)?!n.get(o):!1}function UP(e,t,r){for(const n of r.values())if(e>=n.anchorRow&&e<n.anchorRow+n.rowSpan&&t>=n.anchorCol&&t<n.anchorCol+n.colSpan)return n}function zP(e,t,r,n){return!(!n||r.run.section.collapsible!==!0||e===r.anchorRow&&t===r.anchorCol)}function VP(e,t,r){const n=new Set;for(const o of e.values())if(t(o))for(let i=o.anchorRow+1;i<o.anchorRow+o.rowSpan;i++)r(i,o)||n.add(i);return n}function WP(e,t,r){const n=o=>r.has(o)?"minmax(0, auto)":`minmax(${t}, auto)`;return Array.from({length:e},(o,i)=>n(i)).join(" ")}function RP(e,t){return new Map([...e,...t])}function KP(e,t,r){if(t.length===0)return e.map(s=>({kind:"field",field:s}));const n=new Map;for(const s of t)for(const a of s.fieldNames)n.set(a,s);const o=[];let i=0;for(;i<e.length;){const s=e[i],a=r(s),c=a?n.get(a):void 0;if(!c){o.push({kind:"field",field:s}),i+=1;continue}const u=[],f=new Set(c.fieldNames);for(;i<e.length;){const p=r(e[i]);if(!p||!f.has(p))break;const g=e[i];tb(g,c.section,r)||u.push(g),i+=1}if(u.length===0)continue;const l=o[o.length-1];l?.kind==="border"&&l.run.section.id===c.section.id?l.fields.push(...u):o.push({kind:"border",run:c,fields:u})}return o}function rb(e,t){if(!t?.length)return;const r=new Set(e);for(const n of t){if(n.showBorder!==!0)continue;const o=n.fieldNames.filter(i=>r.has(i));if(o.length>0)return{section:n,fieldNames:o}}}const GP=({steps:e,currentStep:t,completedSteps:r,onStepClick:n,className:o})=>d.jsx("div",{className:V("mb-8",o),children:d.jsx("nav",{"aria-label":"Progress",children:d.jsx("ol",{className:"flex items-center",children:e.map((i,s)=>{const a=r.has(s),c=t===s,u=n&&(a||s===t+1||s<=t);return d.jsxs("li",{className:V("relative",s!==e.length-1&&"pr-8 sm:pr-20 flex-1"),children:[s!==e.length-1&&d.jsx("div",{className:V("absolute top-4 left-8 -right-8 sm:left-12 sm:-right-12 h-0.5",a?"bg-primary":"bg-border"),"aria-hidden":"true"}),d.jsx("button",{type:"button",onClick:()=>u&&n?.(s),disabled:!u,className:V("relative flex h-8 w-8 items-center justify-center rounded-full text-sm font-medium","transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2",a&&"bg-primary text-primary-foreground",c&&!a&&"border-2 border-primary text-primary",!a&&!c&&"border-2 border-border text-muted-foreground",u&&"cursor-pointer hover:bg-primary/10",!u&&"cursor-default"),"aria-current":c?"step":void 0,children:a?d.jsx(fs,{className:"h-4 w-4"}):d.jsx("span",{children:s+1})}),d.jsxs("div",{className:"mt-2",children:[d.jsx("span",{className:V("text-sm font-medium",c&&"text-primary",!c&&!a&&"text-muted-foreground"),children:i.name}),i.description&&d.jsx("p",{className:"text-xs text-muted-foreground hidden sm:block",children:i.description})]})]},i.id)})})})}),qP=2*6e4,nb=50;class YP{map=new Map;ttlMs;constructor(t){this.ttlMs=t}get(t){const r=this.map.get(t);if(!r)return null;const o=Date.now()-r.storedAtMs>this.ttlMs;return{value:r.value,isStale:o}}set(t,r){this.map.set(t,{value:r,storedAtMs:Date.now()}),this.enforceMax()}delete(t){this.map.delete(t)}clear(){this.map.clear()}enforceMax(){if(this.map.size<=nb)return;const t=Array.from(this.map.entries());t.sort((n,o)=>n[1].storedAtMs-o[1].storedAtMs),t.slice(0,Math.max(0,this.map.size-nb)).forEach(([n])=>this.map.delete(n))}}function XP(e){return(e??"").trim()||"default"}function ob(e){const t=XP(e.scope),r=String(e.formId??"").trim(),n=e.version===void 0||e.version===null?"latest":String(e.version).trim();return`form-render:${t}:${r}:${n}`}const ib=new YP(qP);function sb(e){const t=ob(e),r=ib.get(t);return r?{value:r.value,isStale:r.isStale}:null}function ab(e,t){const r=ob(e);ib.set(r,t)}function lb(e){const t={};for(const[n,o]of Object.entries(e)){if(o==null){t[n]=o;continue}if(Array.isArray(o)){t[n]=o;continue}if(typeof o=="object"&&!(o instanceof Date)){const i=o;typeof i.name=="string"&&typeof i.code=="string"?t[n]=`${i.code} ${i.name}`.trim():typeof i.name=="string"?t[n]=i.name:typeof i.code=="string"?t[n]=i.code:typeof i.short_code=="string"?t[n]=i.short_code:t[n]=i.name??i.code??"";continue}t[n]=o}const r=t.time_slot??e.time_slot;return typeof r=="string"&&r.includes(" - ")&&(t.start=r.split(" - ")[0].trim()),t}const $i=({schema:e,formId:t,initialValues:r,onSubmit:n,onChange:o,onValidationError:i,onClose:s,mode:a="fill",className:c,children:u,gridLayout:f,unstyled:l=!1,submissionContext:p,onWorkflowSubmitResult:g,initialExtraSubmitPayload:m,onExtraSubmitPayloadChange:h,workflowStepId:y,initialStepIndex:S,viewerContext:v,getViewerContext:A,hideTableRowControls:x=!1,themeVars:F,dark:k=!1,omitRootWrapper:N=!1,moduleId:T,workflowModalHandlers:P,getAuthHeaders:E})=>{const C=Zn(_=>_.viewerContext),O=w.useMemo(()=>{if(v!==void 0)return v;const _=A?.();return _!==void 0?_:C},[v,A,C]),[W,M]=w.useState(e||null),[U,z]=w.useState(!!t&&!e),[X,B]=w.useState(null),L=e?.BFF_submit_api??X,[D,K]=w.useState(!1),[le,j]=w.useState({}),[H,ce]=w.useState({}),[ie,G]=w.useState({}),[ee,Ae]=w.useState({}),[te,oe]=w.useState({}),[me,Me]=w.useState(null),De=Va.useParams(),ne=Ir(_=>_.setValues),ge=Ir(_=>_.setSubmitting),Se=Ir(_=>_.formDisabled),yt=Ir(_=>_.visibleFields),kt=Ir(_=>_.requiredFields),Ut=Ir(_=>_.updateVisibility),It=Ir(_=>_.updateRequired),Er=Ir(_=>_.setFieldError),Dt=as(),sr=w.useRef(!1),zt=w.useRef(void 0),he=w.useMemo(()=>{if(!e)return null;const _=e;if(_.form&&Array.isArray(_.form.fields))try{return Di(_.form,_.form.fields,_.form.layout||null,_.form.rules||[])}catch{return e}if(Array.isArray(_.fields)&&_.fields.some(R=>typeof R.metadata=="string"&&R.metadata.startsWith("{")||R.fieldType&&!R.type))try{const R={id:_.id||_._id||"temp",name:_.name||"Form",version:_.version??1,status:_.status||"draft",createdAt:_.createdAt||new Date().toISOString(),updatedAt:_.updatedAt||new Date().toISOString(),createdBy:_.createdBy||"system",category:_.category||"",moduleId:_.moduleId,tenantId:_.tenantId,featureId:_.featureId,isDefault:_.isDefault||!1};return Di(R,_.fields,_.layout||null,_.rules||[])}catch{return e}return e},[e]);w.useEffect(()=>{if(e){const _=e;_.BFF_submit_api&&B(_.BFF_submit_api)}},[e]);const we=w.useMemo(()=>{const _=he||W,q=_?ha(_):null;if(!q)return null;const R=q.layout,Z=q.rules,Q=q.clientMapping,de=(Array.isArray(q.fields)?q.fields:[]).map(Le=>{let Be={...Le};if(Le.validationRules&&typeof Le.validationRules=="object"&&!Le.validation){const ue=Le.validationRules,_e=[];ue.required===!0&&_e.push({type:"required",message:"This field is required"}),ue.minLength!==void 0&&typeof ue.minLength=="number"&&_e.push({type:"minLength",value:ue.minLength,message:`Minimum length is ${ue.minLength}`}),ue.maxLength!==void 0&&typeof ue.maxLength=="number"&&_e.push({type:"maxLength",value:ue.maxLength,message:`Maximum length is ${ue.maxLength}`}),ue.pattern&&typeof ue.pattern=="string"&&_e.push({type:"pattern",value:ue.pattern,message:"Invalid format"}),ue.allowLetters!==void 0&&_e.push({type:"allowLetters",value:ue.allowLetters}),ue.allowNumbers!==void 0&&_e.push({type:"allowNumbers",value:ue.allowNumbers}),ue.allowSpecialChars!==void 0&&_e.push({type:"allowSpecialChars",value:ue.allowSpecialChars}),_e.length>0&&(Be={...Be,validation:_e})}const Ee=Le.required===!0||Le.isRequired===!0,ke=Array.isArray(Be.validation)&&Be.validation.some(ue=>ue.type==="required");if(Ee&&!ke){const ue={type:"required",message:"This field is required"},_e=Array.isArray(Be.validation)?Be.validation:[];Be={...Be,validation:[..._e,ue]}}if(Le.apidata&&typeof Le.apidata=="object"){const ue=Le.apidata,_e=Be.properties||{},xe=(Be.type||Le.fieldType)==="status",pt={};!_e.apiAuth&&ue.apiAuth&&(pt.apiAuth=ue.apiAuth),(!_e.apiHeaders||_e.apiHeaders.length===0)&&Array.isArray(ue.apiHeaders)&&ue.apiHeaders.length>0&&(pt.apiHeaders=ue.apiHeaders),Object.keys(pt).length>0&&(Be={...Be,properties:{..._e,...pt}});const Tt=Be.properties||{};if(!Tt.apiEndpoint&&ue.apiEndpoint){const xt={...Tt,apiEndpoint:ue.apiEndpoint,apiMethod:ue.apiMethod,apiKey:ue.apiKey,apiRealtime:ue.apiRealtime,apiAutoDetect:ue.apiAutoDetect,apiLabelField:ue.apiLabelField,apiValueField:ue.apiValueField,apiQueryParams:ue.apiQueryParams,apiClientFilter:ue.apiClientFilter,apiHeaders:ue.apiHeaders??Tt.apiHeaders,apiBodyFields:ue.apiBodyFields,apiAuth:ue.apiAuth??Tt.apiAuth,valueSource:ue.valueSource||(ue.apiEndpoint?"api":void 0),optionsSource:ue.optionsSource||(ue.apiEndpoint?"api":void 0),dependentFields:ue.dependentFields,apiResponsePath:ue.apiResponsePath};xe&&(xt.source=_e.source??"api",_e.statuses!==void 0&&(xt.statuses=_e.statuses),_e.dataPath!==void 0&&(xt.dataPath=_e.dataPath),_e.showStatusText!==void 0&&(xt.showStatusText=_e.showStatusText),_e.statusTextPath!==void 0&&(xt.statusTextPath=_e.statusTextPath),_e.showCurrentIndicator!==void 0&&(xt.showCurrentIndicator=_e.showCurrentIndicator)),Be={...Be,properties:xt}}}const je=["select","multiselect","radio","checkboxgroup"],Qe=Be.type||Le.fieldType;if(je.includes(Qe)){const ue=Le.options,_e=Be.properties?.options,xe=Array.isArray(_e)&&_e.length>0;if(Array.isArray(ue)&&ue.length>0&&!xe){const pt=Be.properties||{};Be={...Be,properties:{...pt,options:ue}}}}return Be}),ye=q.config?.rules,Ce=Z&&Array.isArray(Z)?Z:ye&&Array.isArray(ye)?ye:[],Ue=Ce.length>0?de.map(Le=>{if((Le.conditions&&Array.isArray(Le.conditions)?Le.conditions:[]).length>0)return Le;const Ee=Le.id??Le._id,ke=Le.name||Le.key,je=Ce.filter(_e=>{const xe=typeof _e.targetFieldId=="object"?_e.targetFieldId?.id??_e.targetFieldId?._id:_e.targetFieldId;return xe?xe===Ee||xe===ke||xe===Le.fieldKey:!1});if(je.length===0)return Le;const Qe=[],ue=new Set;return je.forEach(_e=>{try{const xe=typeof _e.conditionExpression=="string"?JSON.parse(_e.conditionExpression):_e.conditionExpression;if(!xe||typeof xe!="object")return;!xe.id&&_e.id&&(xe.id=_e.id);const pt=typeof _e.targetFieldId=="object"?_e.targetFieldId?.id??_e.targetFieldId?._id:_e.targetFieldId;xe.action&&(!xe.then||!Array.isArray(xe.then)||xe.then.length===0)&&(xe.then=[{action:xe.action,...pt&&{target:pt}}]),(!xe.then||!Array.isArray(xe.then)||xe.then.length===0)&&_e.action&&(xe.then=[{action:_e.action,...pt&&{target:pt}}]),xe.then&&Array.isArray(xe.then)&&pt&&(xe.then=xe.then.map(xt=>!xt.target&&pt?{...xt,target:pt}:xt));const Tt=_e.conditionExpression??JSON.stringify(xe);if(ue.has(Tt))return;ue.add(Tt),Qe.push(xe)}catch{}}),Qe.length===0?Le:{...Le,conditions:Qe}}):de;let Ge=q.config||{submitAction:"database",layout:"default",autoSave:!0,validateOnChange:!0,showFieldErrors:"inline"};return!Ge.layout&&R?typeof R=="object"&&R!==null?Ge.layout="default":typeof R=="string"&&["default","card","compact"].includes(R)?Ge.layout=R:Ge.layout="default":Ge.layout||(Ge.layout="default"),Z&&!Ge.rules&&(Ge.rules=Z),Q&&!Ge.clientMapping&&(Ge.clientMapping=Q),{...q,fields:Ue,config:Ge}},[he,W]);w.useEffect(()=>{he&&he!==W&&M(he)},[he]),w.useEffect(()=>{if(t&&!e){const _=(nn()??"").trim()||"default",q=sb({scope:_,formId:t,version:"latest"});q?.value?.schema?(M(q.value.schema),q.value.bffSubmitApi&&B(q.value.bffSubmitApi),z(!1),q.isStale&&J({background:!0})):J({background:!1})}},[t,e]);const J=async({background:_})=>{if(!t)return;const q=t;_||z(!0);try{const R=await gP.getForRendering(t),Z=Di(R.form,R.fields,R.layout,R.rules);if(q!==t)return;M(Z),R.BFF_submit_api&&B(R.BFF_submit_api);const Q=(nn()??"").trim()||"default";ab({scope:Q,formId:q,version:"latest"},{schema:Z,bffSubmitApi:R.BFF_submit_api})}catch{}finally{_||z(!1)}};if(U)return d.jsx("div",{className:"flex items-center justify-center py-12",children:d.jsx(un,{})});if(!we)return d.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Form not found"});const $=we,fe=w.useMemo(()=>new Set(Object.keys($.config?.prepopulateApi?.fieldMapping??{})),[$.config?.prepopulateApi?.fieldMapping]),ze=w.useCallback(async _=>{const q=$?.fields?.length?Lc(_,$.fields):_,R=Bc(q,$.config?.sections,$.config?.submitPayload);if(n){const Z=p?{...R,...p}:R;return n(Z)}return{success:!0}},[n,p,$?.fields,$.config?.sections,$.config?.submitPayload]),{values:Fe,errors:He,touched:st,isSubmitting:ht,isValid:lt,submitCount:ct,totalSteps:nt,currentStepFields:ot,isLastStep:ar,setFieldValue:vt,setFieldTouched:er,handleSubmit:Je,validateForm:ut,resetForm:Ye,nextStep:nr,goToStep:br,currentStep:vr,completedSteps:Nt,loadDraft:kr}=Mu({schema:$,initialValues:r,onSubmit:ze,onChange:o,workflowStepId:y,initialStepIndex:S}),{isFieldEnabled:lr,isFieldRequired:An,isFieldVisible:fn}=Qw({fields:$.fields,values:Fe,buttonResponses:H,prepopulateResponse:me,prepopulateResponseRules:$.config?.prepopulateResponseRules}),$r=fn,Un=Ir(_=>_.readOnlyFields),Bt=Ir(_=>_.editableFields),Vt=w.useCallback(_=>Un.has(_),[Un]),wr=w.useCallback(_=>Bt.has(_),[Bt]);w.useEffect(()=>{$.config?.allowDraft&&a==="fill"&&kr()},[$.id]),w.useEffect(()=>{zt.current=$.id,sr.current=!1,j({}),G({}),Ae({}),oe({}),Me(null)},[$.id]),w.useEffect(()=>{const _=$.config?.prepopulateApi,q=!!(_?.fieldMapping&&Object.keys(_?.fieldMapping??{}).length>0),R=($.config?.prepopulateResponseRules?.length??0)>0;if(!_?.enabled||!_.apiEndpoint?.trim()||!q&&!R||sr.current)return;sr.current=!0;const Z=$.id;zt.current=$.id;let Q=!1;return K(!0),(async()=>{try{const de=Dt.getState().values,ye=typeof p=="object"&&p!==null?{...p,...m||{}}:m||{},Ce=se=>Rr(se,de,De,ye);let Ue=Mr(Ce(_.apiEndpoint));if(_.apiQueryParams?.length){const se=new URLSearchParams;_.apiQueryParams.forEach(({key:Ie,value:be})=>se.append(Ie,Ce(be))),Ue=`${Ue}${Ue.includes("?")?"&":"?"}${se.toString()}`}const Ge={};_.apiHeaders?.forEach(({key:se,value:Ie})=>{se.trim()&&(Ge[se]=Ce(Ie))}),Ge["Content-Type"]=Ge["Content-Type"]??"application/json";let Rt;if(_.apiMethod==="POST"&&_.apiBodyFields?.length){const se={};_.apiBodyFields.forEach(({key:Ie,value:be})=>{Ie.trim()&&(se[Ie]=Ce(be))}),Rt=JSON.stringify(se)}const Le=await fetch(Ue,{method:_.apiMethod,headers:Ge,body:_.apiMethod==="POST"?Rt:void 0});if(!Le.ok){const se=await Le.text();throw new Error(se||`HTTP ${Le.status}`)}const Be=await Le.json(),Ee=se=>{try{return se.split("?")[0].split("/").filter(Boolean).pop()||se}catch{return se}},ke=(se,Ie)=>{if(se==null)return null;const be=typeof se=="string"?se:se instanceof Date?se.toISOString():null;if(!be)return null;const Re=typeof se=="object"&&se instanceof Date?se:new Date(be);if(Number.isNaN(Re.getTime()))return null;const dt=mt=>String(mt).padStart(2,"0");if(Ie==="date")return be.length>=10&&be[4]==="-"&&be[7]==="-"?be.slice(0,10):Re.toISOString().slice(0,10);if(Ie==="time")return`${dt(Re.getHours())}:${dt(Re.getMinutes())}:${dt(Re.getSeconds())}`;if(Ie==="datetime"){const mt=Re.getFullYear(),Xe=Re.getMonth()+1,pe=Re.getDate(),gt=Re.getHours(),Ve=Re.getMinutes(),Ft=Re.getSeconds();return`${mt}-${dt(Xe)}-${dt(pe)}T${dt(gt)}:${dt(Ve)}:${dt(Ft)}`}return null},je=(se,Ie)=>{const be=$.fields.find(pe=>pe.name===se||pe.key===se);if(!be)return Ie;if((be.type==="file"||be.type==="camera"||be.type==="photoChoice")&&typeof Ie=="string"&&Ie.startsWith("http"))return{url:Ie,name:Ee(Ie)};if(be.type==="date"||be.type==="datetime"||be.type==="time"){const pe=ke(Ie,be.type);if(pe!==null)return pe}if(be.type==="multiselect")return Array.isArray(Ie)?Ie.map(pe=>typeof pe=="string"?pe:String(pe)):typeof Ie=="string"?Ie.trim()===""?[]:Ie.includes(",")?Ie.split(",").map(pe=>pe.trim()).filter(Boolean):[Ie]:Ie!=null&&Ie!==""?[String(Ie)]:[];if(be.type!=="radio"&&be.type!=="select")return Ie;const Re=be.properties?.options??be.options;if(!Array.isArray(Re)||Re.length===0)return Ie;const dt=Re.map(pe=>pe.value);if(dt.includes(Ie))return Ie;const mt=String(Ie);if(dt.includes(mt))return mt;const Xe=Re.find(pe=>pe.value==Ie);return Xe?Xe.value:Ie},Qe=new Set($.fields.filter(se=>se.type==="table").map(se=>se.name||se.key)),ue=new Set($.fields.filter(se=>se.type==="billingGrid").map(se=>se.name||se.key)),_e=se=>se.name||se.key||se.id,xe={},pt=[],Tt=[],xt=U_(_?.fieldMapping,$.config?.sections,$.config?.submitPayload);for(const[se,Ie]of Object.entries(xt)){if(!Ie?.trim()||se.startsWith("__"))continue;const be=We(Be,Ie),Re=se.indexOf(".");if(Re>0&&ue.has(se.slice(0,Re))){const mt=se.slice(0,Re),Xe=se.slice(Re+1),gt=$.fields.find(Ve=>(Ve.name||Ve.key)===mt)?.properties;if(gt?.rowSlots?.length){const Ve=Xe.startsWith("__block__")?Xe.slice(9):Xe,Ft=xe[mt]??Dt.getState().values[mt];Array.isArray(be)?xe[mt]=RT(gt,Ve,be,Ft):be!=null&&(xe[mt]=Qc(gt,be,Ft))}continue}if(Re>0&&Qe.has(se.slice(0,Re))){const mt=se.slice(0,Re),Xe=se.slice(Re+1);pt.push({tableName:mt,columnName:Xe,path:Ie});continue}if(ue.has(se)&&be!==void 0&&be!==null&&typeof be=="object"){const Xe=$.fields.find(pe=>(pe.name||pe.key)===se)?.properties;if(Xe?.rowSlots?.length){if(Array.isArray(be)){const pe=Xe.rowSlots.find(gt=>gt.kind==="dynamic");if(pe&&pe.kind==="dynamic"){const gt=pe.block.apiArrayPath??"items";xe[se]=Qc(Xe,{[gt]:be})}}else xe[se]=Qc(Xe,be);continue}}if(Qe.has(se)&&Array.isArray(be)&&be.length>0&&typeof be[0]=="object"&&be[0]!==null){const Xe=$.fields.find(Ve=>(Ve.name||Ve.key)===se)?.properties?.columns||[],pe=be.map(lb),gt=Ve=>(Ve||"").toLowerCase().replace(/\s+/g,"_").trim();xe[se]=pe.map(Ve=>{const Ft={};for(const pr of Xe){const uo=pr.name??"";Ft[uo]=Ve[gt(uo)]??Ve[uo]}return Ft});continue}if(be!=null&&(xe[se]=je(se,be)),be==null)continue;let dt=be;if(Array.isArray(be)){const mt=$.fields.find(Xe=>_e(Xe)===se);if(mt?.type==="addmore"){Tt.push({addMoreFieldName:se,array:be});continue}if(mt?.type==="multiselect"){const Xe=_.multiselectArrayPropertyMap?.[se];Xe&&be.length>0&&be.some(pe=>pe!=null&&typeof pe=="object")&&(dt=be.map(pe=>pe!=null&&typeof pe=="object"&&Xe in pe?pe[Xe]:void 0).filter(pe=>pe!=null))}}xe[se]=je(se,dt)}const it={},bt={},or={};for(const{addMoreFieldName:se,array:Ie}of Tt){const be=$.fields.find(gt=>_e(gt)===se);if(!be||be.type!=="addmore")continue;const Re=eb(be,$.fields,$.config?.sections,_e);if(Re.length===0)continue;const dt=_.addMoreFieldKeyMap?.[se],mt=Ie.length>0&&Ie[0]!=null&&typeof Ie[0]=="object"?Ie[0]:null;if(mt)for(const gt of Re){const Ve=_e(gt),Ft=dt&&dt[Ve]||Ve,pr=mt[Ft];pr!=null&&(xe[Ve]=je(Ve,pr))}const Xe=Ie.slice(1),pe=Xe.map((gt,Ve)=>`prepop_${se}_${Ve}_${Date.now()}`);pe.length>0&&(bt[se]=pe);for(let gt=0;gt<Xe.length;gt++){const Ve=Xe[gt];if(Ve==null||typeof Ve!="object")continue;const Ft=Ve,pr=Ft.id;pr!=null&&String(pr).trim()!==""&&(or[`${se}__${pe[gt]}`]=String(pr));for(const uo of Re){const za=_e(uo),dM=dt&&dt[za]||za,Bd=Ft[dM];if(Bd==null)continue;const uM=`${za}__addmore__${se}__${pe[gt]}`;it[uM]=je(za,Bd)}}}Object.keys(bt).length>0&&G(se=>({...se,...bt})),Object.keys(or).length>0&&oe(se=>({...se,...or}));const zr=se=>(se||"").toLowerCase().replace(/\s+/g,"_").trim(),en=[...new Set(pt.map(se=>se.tableName))];for(const se of en){if(Array.isArray(xe[se]))continue;const Ie=pt.find(pe=>pe.tableName===se);if(!Ie?.path?.includes("."))continue;const be=Ie.path.replace(/\.[^.]+$/,""),Re=We(Be,be);if(!Array.isArray(Re)||Re.length===0||typeof Re[0]!="object"||Re[0]===null)continue;const mt=$.fields.find(pe=>(pe.name||pe.key)===se)?.properties?.columns||[],Xe=Re.map(lb);xe[se]=Xe.map(pe=>{const gt={};for(const Ve of mt){const Ft=Ve.name??"",pr=zr(Ft),uo=pe[pr]??pe[Ft];gt[Ft]=uo}return gt})}const Vr=(se,Ie)=>{const be=We(Be,se);if(Array.isArray(be))return be;if(be!=null)return[be];if(!se.includes("."))return[];const Re=se.replace(/\.[^.]+$/,""),dt=We(Be,Re);return!Array.isArray(dt)||dt.length===0||typeof dt[0]!="object"||dt[0]===null?[]:dt.map(mt=>{const Xe=mt[Ie];if(Xe!==null&&typeof Xe=="object"&&!Array.isArray(Xe)&&!(Xe instanceof Date)){const pe=Xe;return typeof pe.name=="string"&&typeof pe.code=="string"?`${pe.code} ${pe.name}`.trim():typeof pe.name=="string"?pe.name:typeof pe.code=="string"?pe.code:typeof pe.short_code=="string"?pe.short_code:pe.name??pe.code??""}return Xe})};for(const{tableName:se,columnName:Ie,path:be}of pt){const Re=Vr(be,Ie),mt=$.fields.find(Ve=>(Ve.name||Ve.key)===se)?.properties?.columns||[],Xe=mt.find(Ve=>(Ve.name||"").toLowerCase()===Ie.toLowerCase())?.name??Ie;let pe=Array.isArray(xe[se])?xe[se]:[];const gt=Math.max(pe.length,Re.length);if(gt>pe.length)for(pe=[...pe];pe.length<gt;){const Ve={};mt.forEach(Ft=>{Ve[Ft.name||""]=""}),pe.push(Ve)}else pe=pe.map(Ve=>({...Ve}));Re.forEach((Ve,Ft)=>{pe[Ft]&&(pe[Ft][Xe]=Ve)}),xe[se]=pe}if(zt.current===Z){if(Object.keys(xe).length>0||Object.keys(it).length>0){const Ft={...Dt.getState().values,...xe,...it};ne(Ft)}const Ie=We(Be,"data.user_id"),be=We(Be,"data.items"),Re=We(Be,"data");let dt=Array.isArray(be)&&be.length>0&&be[0]!=null&&typeof be[0]=="object"&&be[0].id?be[0].id:void 0;dt===void 0&&Array.isArray(Re)&&Re.length>0&&Re[0]!=null&&typeof Re[0]=="object"&&Re[0].id&&(dt=Re[0].id),dt===void 0&&(dt=We(Be,"data.0.id"));const mt=CP(Be,{treatFirstItemIdAsPaymentId:_?.treatFirstItemIdAsPaymentId===!0}),Xe=We(Be,"data.id"),pe=We(Be,"data.batch_id"),gt=We(Be,"data.program_id"),Ve={};Ie!=null&&(Ve.context_user_id=Ie),dt!=null&&dt!==""&&(Ve.documentId=dt),Xe!=null&&String(Xe).trim()!==""&&(p?.id===void 0||p?.id===null)&&(Ve.id=Xe),pe!=null&&String(pe).trim()!==""&&((p?.admission_batch_id===void 0||p?.admission_batch_id===null)&&(Ve.admission_batch_id=pe),(p?.batch_id===void 0||p?.batch_id===null)&&(Ve.batch_id=pe)),gt!=null&&String(gt).trim()!==""&&(p?.program_id===void 0||p?.program_id===null)&&(Ve.program_id=gt),mt!=null&&String(mt).trim()!==""&&(p?.payment_id===void 0||p?.payment_id===null)&&(Ve.payment_id=mt),Object.keys(Ve).length>0&&j(Ft=>{const pr={...Ft,...Ve};return h?.(pr),pr}),Me(Be)}}catch(de){Q||ua(de,"Prepopulate request failed.",Kr)}finally{K(!1)}})(),()=>{Q=!0}},[$.id,$.config?.prepopulateApi?.enabled,$.config?.prepopulateApi?.apiEndpoint,$.config?.prepopulateApi?.apiMethod,JSON.stringify($.config?.prepopulateApi?.fieldMapping),$.config?.prepopulateApi?.treatFirstItemIdAsPaymentId,p,m,De,ne,G]),w.useEffect(()=>{Object.keys(He).length>0&&i?.(He)},[He,i]);const Jr=nt>1,Yt=a==="view",cr=w.useCallback((_,q)=>Yt||!!q&&!wr(_)||Vt(_)&&!wr(_),[Yt,wr,Vt]),zn=$.fields.filter(_=>!_.parentId),_t=[...Jr?ot:zn.length>0?zn:$.fields].filter(_=>!(!_||typeof _!="object"||!_.name&&!_.key)).sort((_,q)=>{const R=typeof _.position?.order=="number"?_.position.order:typeof _.positionOrder=="number"?_.positionOrder:Number.MAX_SAFE_INTEGER,Z=typeof q.position?.order=="number"?q.position.order:typeof q.positionOrder=="number"?q.positionOrder:Number.MAX_SAFE_INTEGER;if(R!==Z)return R-Z;const Q=typeof _.position?.column=="number"?_.position.column:1,de=typeof q.position?.column=="number"?q.position.column:1;return Q-de}),Wi=w.useCallback(_=>{const q=Dt.getState().errors,R=Object.keys(q).find(Z=>_.includes(Z));R&&requestAnimationFrame(()=>{document.querySelector(`[data-field-name="${R}"]`)?.scrollIntoView({behavior:"smooth",block:"center"})})},[]),Nr=async _=>{if(_?.preventDefault(),Jr&&!ar){if(!await nr())try{const Z=Dt.getState().errors;at.toast.error(pa(Z,$.fields)||"Please fix the errors before continuing."),Wi(_t.map(Q=>Q.name||Q.key||Q.id).filter(Boolean))}catch{at.toast.error("Please fix the errors before continuing.")}return}const q=await Je(_);if(q&&q.success===!1&&q.errors?.length)try{const R=Dt.getState().errors;at.toast.error(pa(R,$.fields)||"Submission failed. Please check the form."),Wi(_t.map(Z=>Z.name||Z.key||Z.id).filter(Boolean))}catch{at.toast.error("Submission failed. Please check the form.")}return q},Qr=w.useCallback(()=>{Ye(),s&&s()},[Ye,s]),jr=w.useCallback((_,q)=>{const R=$.fields.find(de=>de.type==="button"&&(de.name===_||de.key===_)),Z=R?.properties,Q=_P(q,R);Q!=null&&String(Q).trim()!==""&&(p?.payment_id===void 0||p?.payment_id===null)&&j(de=>{const ye={...de,payment_id:Q};return h?.(ye),ye}),R&&Z?.apiSuccessConfig&&p_(q,Z.apiSuccessConfig,{setFieldValue:(de,ye)=>Dt.getState().setFieldValue(de,ye),onContextUpdate:de=>{j(ye=>{const Ce={...ye,...de};return h?.(Ce),Ce})}}),ce(de=>{const ye={...de,[_]:q};return!ri(q)||!(R?.type==="button"&&R.properties?.action==="submit")||$.fields.filter(Ge=>Ge.type==="editButton").map(Ge=>Ge.name).forEach(Ge=>delete ye[Ge]),ye})},[$.fields,p,h,Dt]),Hr=w.useCallback(async()=>await ut(),[ut]),_r=w.useCallback(()=>Dt.getState().errors,[]),Xt=w.useMemo(()=>({...m||{},...le}),[m,le]),Ne=w.useMemo(()=>({...typeof p=="object"&&p!==null?p:{},...Xt}),[p,Xt]),I=$.config?.layout??$.layout??"default",re=["default","card","compact"].includes(I)?I:"default",ve={default:"",card:"bg-card border rounded-lg shadow-sm p-6",compact:"space-y-2"},rt=w.useMemo(()=>{if(N)return;const _=$.config?.theme?.cssVariables;if(!(!_&&!F))return{..._??{},...F??{}}},[N,$.config?.theme?.cssVariables,F]),wt=w.useMemo(()=>Yi({config:$.config,layout:$.layout},f),[$.config,$.layout,f]),St=w.useMemo(()=>wt?{...wt,verticalSpacing:wt.verticalSpacing??wt.spacing??"16px",horizontalSpacing:wt.horizontalSpacing??wt.spacing??"16px",rowHeight:wt.rowHeight??Wn}:null,[wt]),Wt=St!==null;St?.rows;const Et=St?.columns??3,Ur=St?.verticalSpacing??St?.spacing??"16px",Go=St?.horizontalSpacing??St?.spacing??"16px",Ot=St?.rowHeight??Wn,pn=w.useCallback(_=>{if(!O)return!0;const q=_.visibility;if(!q)return!0;const R=q.visibleToUserType??q.user_type,Z=q.visibleToUserRole??q.user_role,Q=Array.isArray(q.visibleToUserIds)?q.visibleToUserIds:Array.isArray(q.users)?q.users:[],de=Array.isArray(q.hiddenFromUserIds)?q.hiddenFromUserIds:[];if(Array.isArray(de)&&de.length>0&&O.userId!=null&&de.includes(O.userId))return!1;if(Q.length>0&&O.userId!=null&&Q.includes(O.userId))return!0;const ye=R!=null&&R!==""&&O.userType!=null&&O.userType!==R,Ce=Z!=null&&Z!==""&&O.role!=null&&O.role!==Z,Ue=Q.length>0&&(O.userId==null||!Q.includes(O.userId));return!(ye||Ce||Ue)},[O]),Cn=w.useMemo(()=>tT($.fields),[$.fields]),Od=w.useMemo(()=>nT($.fields),[$.fields]),[qo,Jb]=w.useState(Od);w.useEffect(()=>{Jb(Od)},[$.id,Od]);const Qb=w.useCallback((_,q)=>{Jb(R=>R[_]===q?R:{...R,[_]:q})},[]),iM=w.useMemo(()=>({visibility:qo,setSectionVisible:Qb,fieldToHeading:Cn,allFields:$.fields}),[qo,Qb,Cn,$.fields]),et=w.useCallback(_=>_.name||_.key||_.id,[]),Tr=_=>{if(!pn(_))return!1;const q=_.name||_.key||_.id;if(!Xg(q,_.type,qo,Cn))return!1;const R=_.hidden===!0;return $r(q)||!R&&q},Zb=w.useCallback(_=>{const q=$.fields.find(Z=>et(Z)===_);if(q)return q.type;const R=Yg(_);return $.fields.find(Z=>et(Z)===R)?.type},[$.fields,et]),Fa=w.useCallback(_=>Xg(_,Zb(_),qo,Cn),[qo,Cn,Zb]),En=w.useCallback(_=>Fa(_)?An(_):!1,[Fa,An]);w.useEffect(()=>{const{visibleFields:_,requiredFields:q,errors:R}=Dt.getState(),Z=new Set(_),Q=new Set(q),de=[];for(const ye of $.fields){const Ce=et(ye);Ce&&(Fa(Ce)||(Z.delete(Ce),Q.delete(Ce),R[Ce]&&de.push(Ce)))}Ut(Array.from(Z)),It(Array.from(Q));for(const ye of de)Er(ye,void 0)},[qo,Cn,$.fields,$.id,et,Fa,Ut,It,Er,yt,kt]);const $t=$.config?.sections,lo=w.useCallback(_=>{const q=et(_);let R=_;if(_.type==="table"){const Q=_.properties?.columns;if(Array.isArray(Q)&&Q.length>0){const de=Q.filter(ye=>pn(ye));R={..._,properties:{..._.properties,columns:de}}}}const Z=OP(R,$t,et);return Z&&(R={...R,label:Zy(Z,0)}),{...R,disabled:!lr(q),readOnly:cr(q,!!R.readOnly)}},[pn,$t,et,lr,cr]),kn=w.useCallback(_=>eb(_,$.fields,$t,et),[$.fields,$t,et]),Zr=w.useCallback((_,q,R)=>`${_}__addmore__${q}__${R}`,[]),Pa=w.useCallback((_,q)=>`${_}__${q??"base"}`,[]),Ia=w.useCallback((_,q)=>{const R=Pa(_.id,q);return ee[R]??_.defaultCollapsed??!1},[ee,Pa]),Md=w.useCallback((_,q,R)=>{const Z=Pa(_,q);Ae(Q=>Q[Z]===R?Q:{...Q,[Z]:R})},[Pa]),Oa=w.useMemo(()=>{const _=[],q=$.fields.filter(R=>R.type==="addmore");for(const R of q){const Z=et(R),de=kn(R).find(Ge=>{if(Ge.type!=="button")return!1;const Rt=Ge.properties,Le=Ge.metadata;let Be=Rt?.action;if(!Be&&Le!=null)try{Be=(typeof Le=="string"?JSON.parse(Le):Le)?.action}catch{}return Be==="upload"||Be==="custom"});if(!de)continue;const ye=et(de),Ce=ie[Z]||[],Ue=We(H[ye],"data.id")??We(H[ye],"data.documentId")??le.documentId;Ue!=null&&String(Ue).trim()!==""&&_.push(String(Ue));for(const Ge of Ce){const Rt=Zr(ye,Z,Ge),Le=We(H[Rt],"data.id")??We(H[Rt],"data.documentId"),Be=te[`${Z}__${Ge}`],Ee=Le??Be;Ee!=null&&String(Ee).trim()!==""&&_.push(String(Ee))}}return _},[$.fields,ie,H,te,le.documentId,et,kn,Zr]);w.useEffect(()=>{j(_=>{const q={..._,document_ids:Oa},R=_.document_ids;return Array.isArray(R)&&R.length===Oa.length&&Oa.every((Z,Q)=>R[Q]===Z)?_:q})},[Oa]);const Ma=w.useCallback((_,q,R,Z)=>{for(const Q of R){const de=et(Q),ye=Zr(de,_,q),Ce=Z[ye];if(Ce==null)continue;const Ue=Q.type;if(Ue==="file"||Ue==="camera"||Ue==="photoChoice"){if(typeof Ce=="object"&&Ce!==null&&("url"in Ce||"name"in Ce)||Array.isArray(Ce)&&Ce.length>0)return!0;continue}if(Array.isArray(Ce)){if(Ce.length>0)return!0;continue}if(typeof Ce=="string"&&Ce.trim()!==""||typeof Ce=="number"&&!Number.isNaN(Ce)||typeof Ce=="boolean"||typeof Ce=="object"&&Ce!==null&&Object.keys(Ce).length>0)return!0}return!1},[et,Zr]),co=w.useCallback(_=>{const q=et(_);if(!q)return;if(kn(_).length===0){at.toast.error("No linked fields configured for this Add More button.");return}const Z=`${Date.now()}_${Math.random().toString(36).slice(2,8)}`;G(Q=>({...Q,[q]:[...Q[q]||[],Z]}))},[et,kn]),La=w.useCallback((_,q)=>{G(R=>{const Z=R[_]||[],Q=Z.filter(de=>de!==q);if(Q.length===Z.length)return R;if(Q.length===0){const de={...R};return delete de[_],de}return{...R,[_]:Q}})},[]),Da=w.useMemo(()=>_t.filter(_=>!_.parentId),[_t]),Vn=w.useMemo(()=>{const _=[];return _t.filter(R=>R.type==="addmore").sort((R,Z)=>{const Q=R.position?.order??0,de=Z.position?.order??0;return Q-de}).forEach(R=>{const Z=et(R),Q=R.position?.order??0,de=ie[Z]||[],ye=kn(R).sort((ke,je)=>{const Qe=ke.position?.order??0,ue=je.position?.order??0;return Qe!==ue?Qe-ue:(ke.position?.column??1)-(je.position?.column??1)});if(ye.length===0)return;const Ce=Qy(R,$t),Ue=Ce[0]?.fieldNames?.length?Ce[0].fieldNames:ye.map(ke=>et(ke)).filter(Boolean),Ge=DP(Ue,Da,Et,et),Rt=Math.min(...ye.map(ke=>ke.position?.order??0)),Le=Math.max(1,...ye.map(ke=>(ke.position?.order??Rt)-Rt+Qo(ke))),Be=Ge?.blockHeight??Le,Ee=de.length*Be;_.push({addMoreFieldName:Z,baseOrder:Q,blockHeight:Be,blockIds:de,linkedFields:ye,insertedRows:Ee,templateFieldNames:Ue,templateBounds:Ge})}),_},[_t,Da,Et,et,ie,kn,$t]),Ri=w.useMemo(()=>({}),[]),Ba=w.useMemo(()=>Vn.length===0?_t:_t.map(_=>{const q=_.position?.order??0,R=Vn.reduce((Z,Q)=>{const de=Q.templateBounds?.maxRow??Q.baseOrder;return q>de?Z+Q.insertedRows:Z},0);return R===0?_:{..._,position:{..._.position,order:q+R}}}),[_t,Vn]),$a=w.useCallback(_=>{const q={};return Object.entries(H).forEach(([R,Z])=>{const Q=_[R];Q&&(q[Q]=Z)}),q},[H]),Yo=w.useMemo(()=>{const _=[],q={};return Vn.forEach(R=>{const{addMoreFieldName:Z,blockIds:Q,linkedFields:de,blockHeight:ye,templateBounds:Ce}=R,Ue=Math.min(...de.map(Le=>Le.position?.order??0)),Rt=$.fields.find(Le=>et(Le)===Z&&Le.type==="addmore")?.properties;Q.forEach((Le,Be)=>{const Ee={},ke={},je={},Qe=Ce?BP(Ce,Be):R.baseOrder+1+Be*ye,ue=te[`${Z}__${Le}`];de.forEach(xe=>{const pt=et(xe),Tt=Zr(pt,Z,Le),xt=(xe.position?.order??Ue)-Ue;if(Ee[Tt]=pt,ke[Tt]=Fe[Tt],!(Rt?.linkedFieldAllowDuplicate?.[pt]??!0)&&(xe.type==="select"||xe.type==="radio"||xe.type==="multiselect")){const bt=[],or=Fe[pt];or!=null&&or!==""&&(Array.isArray(or)?bt.push(...or.map(en=>String(en))):bt.push(String(or))),Q.filter(en=>en!==Le).forEach(en=>{const Vr=Zr(pt,Z,en),tn=Fe[Vr];tn!=null&&tn!==""&&(Array.isArray(tn)?bt.push(...tn.map(se=>String(se))):bt.push(String(tn)))}),bt.length>0&&(je[Tt]=[...new Set(bt)])}_.push({...xe,id:`${xe.id}__${Le}`,name:Tt,position:{...xe.position,order:Qe+xt}})});const _e=$a(Ee);Object.keys(Ee).forEach(xe=>{q[xe]={scopedFormValues:ke,scopedFieldNameMap:Ee,scopedButtonResponses:_e,...ue!=null&&{blockDocumentId:ue},...je[xe]&&{excludedOptionValues:je[xe]}}})})}),{clonedFields:_,scopeByFieldName:q}},[Vn,te,et,Zr,Fe,$a,$.fields]),Ki=w.useMemo(()=>[...Ba,...Yo.clonedFields].sort((_,q)=>{const R=_.position?.order??0,Z=q.position?.order??0;if(R!==Z)return R-Z;const Q=_.position?.column??1,de=q.position?.column??1;if(Q!==de)return Q-de;const ye=Oo(_.position)??0,Ce=Oo(q.position)??0;return ye!==Ce?ye-Ce:String(_.id).localeCompare(String(q.id))}),[Ba,Yo.clonedFields]),Xo=w.useMemo(()=>y_(Ki.filter(_=>!_.parentId),Tr),[Ki,Tr]),Ld=w.useCallback((_,q)=>Xo.some(R=>b_(_,q,R,Et)),[Xo,Et]);Xo.length===0||Math.max(...Xo.map(_=>(_[0]?.position?.order??0)+_i(_,Et).rowSpan));const ja=w.useMemo(()=>MP($t,gd(_t.filter(_=>!_.parentId)),et),[$t,_t,et]),{anchorsByOrigin:ev,coveredCells:tv}=w.useMemo(()=>$P(ja,Ba,et,Et),[ja,Ba,et,Et]),{anchorsByOrigin:rv,coveredCells:nv}=w.useMemo(()=>jP(Vn.map(_=>({addMoreFieldName:_.addMoreFieldName,blockIds:_.blockIds,linkedFields:_.linkedFields,templateFieldNames:_.templateFieldNames})),$t,Yo.clonedFields,Da,Et,et,tv),[Vn,$t,Yo.clonedFields,Da,Et,et,tv]),Nn=w.useMemo(()=>RP(ev,rv),[ev,rv]),ov=w.useMemo(()=>nv,[nv]),iv=String(Ot).endsWith("px")?Ot:Wn,sv=w.useCallback((_,q)=>{for(let R=0;R<Et;R++){if(R>=q.anchorCol&&R<q.anchorCol+q.colSpan)continue;if(Ri[`${_}-${R}`]||Nn.get(`${_}-${R}`)||Ig(_,R,Ki,Tr).length>0||Ld(_,R))return!0}return!1},[Et,Ri,Nn,Ki,Tr,Ld]),av=w.useMemo(()=>VP(Nn,_=>{const q=_.run.section;return q.collapsible?Ia(q,_.addMoreMeta?.blockId):!1},sv),[Nn,Ia,sv]),lv=w.useMemo(()=>{const _=[];for(const q of Object.keys(Ri)){const R=Number(q.split("-")[0]);Number.isNaN(R)||_.push(R)}for(const q of Nn.values())if(q.renderFields.some(R=>Tr(R)))for(let R=q.anchorRow;R<q.anchorRow+q.rowSpan;R++)_.push(R);return v_(Xo,Et,_)},[Xo,Et,Ri,Nn,Tr]),{originalToDisplayRow:Ha,displayRowCount:sM,sortedOccupiedRows:aM}=w.useMemo(()=>{const _=w_(lv);return{originalToDisplayRow:_.originalToDisplay,displayRowCount:_.displayRowCount,sortedOccupiedRows:_.sortedOriginalRows}},[lv]),cv=Math.max(sM,1),Dd=w.useCallback((_,q=1)=>S_(_,q,Ha),[Ha]),dv=w.useMemo(()=>{const _=new Set;for(const q of av){const R=Ha.get(q);R!==void 0&&_.add(R)}return _},[av,Ha]),lM=w.useMemo(()=>WP(cv,iv,dv),[cv,iv,dv]),cM=w.useMemo(()=>KP(_t.filter(_=>!_.parentId&&Tr(_)),ja,et),[_t,ja,et,Tr]),Ua=w.useCallback(_=>{if(Wt)return null;const q=et(_),R=ie[q]||[];if(R.length===0)return null;const Z=kn(_);if(Z.length===0)return null;const Q=IP(_,$t),de=Z.map(Ue=>et(Ue)).filter(Boolean),ye=rb(de,$t),Ce=(Ue,Ge,Rt,Le,Be,Ee,ke)=>{const je=et(Ue),Qe=Zr(je,q,Ge),ue=Ue.hidden===!0;if(!(pn(Ue)&&($r(je)||!ue&&je)))return null;const xe={...Ue,id:`${Ue.id}__${Ge}`,name:Qe,disabled:!lr(je),readOnly:cr(je,!!Ue.readOnly)},Tt=_.properties?.linkedFieldAllowDuplicate?.[je]??!0;let xt;if(!Tt&&(Ue.type==="select"||Ue.type==="radio"||Ue.type==="multiselect")){const it=[],bt=Fe[je];bt!=null&&bt!==""&&(Array.isArray(bt)?it.push(...bt.map(zr=>String(zr))):it.push(String(bt))),R.filter(zr=>zr!==Ge).forEach(zr=>{const en=Zr(je,q,zr),Vr=Fe[en];Vr!=null&&Vr!==""&&(Array.isArray(Vr)?it.push(...Vr.map(tn=>String(tn))):it.push(String(Vr)))}),it.length>0&&(xt=[...new Set(it)])}return d.jsx("div",{"data-field-name":Qe,"data-form-renderer":"field-wrapper",children:d.jsx(xn,{field:xe,value:Fe[Qe],error:st[Qe]||ct>0?He[Qe]:void 0,onChange:it=>vt(Qe,it),onBlur:()=>er(Qe),disabled:Se||!lr(je)||Yt,readOnly:cr(je,!!Ue.readOnly),isRequired:En(je),formValues:Fe,submissionContext:Ne,prepopulateMappedFieldNames:fe,urlParams:De,prepopulateResponse:me,prepopulateLoading:D,formSections:$t,submitPayload:$.config?.submitPayload,fieldValueKey:Qe,buttonResponses:Ee,onButtonApiResponse:jr,onSubmit:Nr,onReset:Ye,onCancel:Qr,isSubmitting:ht,bffSubmitApi:L,onBffSubmitResult:g,extraSubmitPayload:ke,onValidateForm:Hr,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,scopedFormValues:Be,scopedFieldNameMap:Le,excludedOptionValues:xt,hideTableRowControls:x})},xe.id)};return d.jsx("div",{className:"space-y-3 mt-3",children:R.map((Ue,Ge)=>{const Rt={},Le={};Z.forEach(xt=>{const it=et(xt),bt=Zr(it,q,Ue);Rt[bt]=it,Le[bt]=Fe[bt]});const Be=$a(Rt),Ee=Ma(q,Ue,Z,Fe),ke=Q?.heading!=null?Bi(Q,Ge+1):null,je=te[`${q}__${Ue}`],Qe=je!=null?{...Xt,documentId:je}:Xt,ue=Z.map(xt=>Ce(xt,Ue,Ge,Rt,Le,Be,Qe)).filter(Boolean),xe=ye?.section?.collapsible===!0,pt=d.jsx("button",{type:"button",className:"inline-flex shrink-0 rounded-md p-1.5 text-destructive hover:bg-destructive/10 focus:outline-none focus:ring-2 focus:ring-ring disabled:pointer-events-none disabled:opacity-40",disabled:Ee,title:Ee?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:xt=>{xt.preventDefault(),xt.stopPropagation(),La(q,Ue)},children:d.jsx(si,{className:"h-5 w-5","aria-hidden":!0})}),Tt=d.jsxs(d.Fragment,{children:[!xe&&d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[ke?d.jsx("p",{className:"text-sm font-medium text-foreground",children:ke}):d.jsxs("p",{className:"text-xs text-muted-foreground",children:["Entry ",Ge+1]}),pt]}),ue]});return d.jsx("div",{className:"rounded-md border p-3 space-y-3",children:ye?d.jsx(fd,{legend:ye.section.heading?.enabled?Bi(ye.section,Ge+1):ye.section.name,collapsible:ye.section.collapsible,defaultCollapsed:ye.section.defaultCollapsed,headerActions:xe?pt:void 0,onCollapsedChange:xt=>Md(ye.section.id,Ue,xt),children:Tt}):Tt},`${_.id}-${Ue}`)})})},[Wt,ie,te,et,kn,Zr,Ma,Fe,st,ct,He,vt,er,lr,Yt,En,Ne,fe,jr,Nr,Ye,Qr,ht,L,g,Xt,Hr,_r,$.fields,ge,$r,pn,$a,La,x,$t,De,me,D]),uv=d.jsx("div",{className:N?V("relative",c):V(Wa,k&&"dark",c),style:rt,"data-form-renderer":N?void 0:"root",children:d.jsxs("div",{className:"relative",children:[D&&d.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/60 rounded-md",children:d.jsx(un,{})}),d.jsx("form",{onSubmit:Nr,className:l?V("w-full min-w-0"):V("space-y-6 pb-[100px] w-full min-w-0",ve[re]),"data-form-renderer":"form","data-form-renderer-layout":Wt?"grid":"stack",children:d.jsxs(Q_,{value:iM,children:[Jr&&$.steps&&d.jsx(GP,{steps:$.steps,currentStep:vr,completedSteps:Nt,onStepClick:br}),d.jsx(tl.Provider,{value:{gridStretch:Wt},children:Wt?d.jsx("div",{className:l?"w-full min-w-0":"grid w-full min-w-0",style:{display:"grid",gridTemplateRows:lM,gridTemplateColumns:`repeat(${Et}, 1fr)`,rowGap:Ur,columnGap:Go},"data-form-renderer":"grid",children:aM.map(_=>Array.from({length:Et},(q,R)=>{const Z=Dd(_);if(!Z)return null;if(Ld(_,R))return d.jsx("div",{className:"min-w-0 min-h-0",style:{gridRow:Z,gridColumn:R+1,visibility:"hidden",pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`empty-${_}-${R}`);if(HP(_,R,ov,Nn)){const Ee=UP(_,R,Nn);return Ee&&zP(_,R,Ee,Ia(Ee.run.section,Ee.addMoreMeta?.blockId))?null:d.jsx("div",{className:"min-w-0 min-h-0",style:{gridRow:Z,gridColumn:R+1,visibility:"hidden",pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`section-border-cover-${_}-${R}`)}const Q=Nn.get(`${_}-${R}`);if(Q){const Ee=Q.renderFields.filter(it=>Tr(it));if(Ee.length===0)return null;const ke=Q.addMoreMeta,je=ke!=null?Vn.find(it=>it.addMoreFieldName===ke.addMoreFieldName)?.linkedFields??[]:[],Qe=ke!=null?Ma(ke.addMoreFieldName,ke.blockId,je,Fe):!1,ue=Q.run.section,_e=ke?.blockId,xe=Ia(ue,_e),pt=ue.collapsible&&xe?1:Q.rowSpan,Tt=Dd(Q.anchorRow,pt)??Z,xt=ke!=null?d.jsx("button",{type:"button",className:V("inline-flex shrink-0 rounded-md p-1.5 text-destructive hover:bg-destructive/10 focus:outline-none focus:ring-2 focus:ring-ring disabled:pointer-events-none disabled:opacity-40",l&&"text-red-600 hover:bg-red-500/10"),disabled:Qe,title:Qe?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:it=>{it.preventDefault(),it.stopPropagation(),La(ke.addMoreFieldName,ke.blockId)},children:d.jsx(si,{className:"h-5 w-5","aria-hidden":!0})}):void 0;return d.jsx("div",{className:V("min-h-0 min-w-0",!(ue.collapsible&&xe)&&"self-stretch"),style:{gridRow:Tt,gridColumn:`${R+1} / span ${Q.colSpan}`},"data-form-renderer":"grid-cell","data-form-renderer-config-section-border-cell":!0,children:d.jsx(fd,{legend:Q.legend,className:ue.collapsible&&xe?void 0:"h-full",collapsible:ue.collapsible,defaultCollapsed:ue.defaultCollapsed,headerActions:xt,onCollapsedChange:it=>Md(ue.id,_e,it),children:d.jsx("div",{className:"grid w-full min-w-0",style:{gridTemplateColumns:`repeat(${Et}, 1fr)`,gridTemplateRows:`repeat(${Q.rowSpan}, minmax(${String(Ot).endsWith("px")?Ot:Wn}, auto))`,rowGap:Ur,columnGap:Go},children:Ee.map(it=>{const bt=et(it),or=Yo.scopeByFieldName[bt],zr=or?.scopedFieldNameMap?.[bt]||bt,en=(it.position?.order??Q.anchorRow)-Q.anchorRow,Vr=it.position?.column??1,{rowSpan:tn,columnSpan:se}=_i([it],Et),Ie=ke!=null?te[`${ke.addMoreFieldName}__${ke.blockId}`]:void 0,be=Ie!=null?{...Xt,documentId:Ie}:Xt;return d.jsx("div",{"data-field-name":bt,"data-form-renderer":"field-wrapper",className:"min-h-0 min-w-0",style:{gridRow:`${en+1} / span ${tn}`,gridColumn:`${Vr} / span ${se}`,...In(it)},children:d.jsx(xn,{field:lo(it),value:Fe[bt],error:st[bt]||ct>0?He[bt]:void 0,onChange:Re=>vt(bt,Re),onBlur:()=>er(bt),disabled:(it.type==="table"||it.type==="billingGrid")&&a==="fill"?!1:Se||!lr(zr)||Yt,readOnly:(it.type==="table"||it.type==="billingGrid")&&a==="fill"?!1:cr(zr,!!it.readOnly),isRequired:En(zr),formValues:Fe,submissionContext:Ne,prepopulateMappedFieldNames:fe,urlParams:De,prepopulateResponse:me,prepopulateLoading:D,formSections:$t,submitPayload:$.config?.submitPayload,fieldValueKey:bt,buttonResponses:or?.scopedButtonResponses??H,onButtonApiResponse:jr,onSubmit:Nr,onReset:Ye,onCancel:Qr,isSubmitting:ht,bffSubmitApi:L,onBffSubmitResult:g,extraSubmitPayload:be,onValidateForm:Hr,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:co,scopedFormValues:or?.scopedFormValues,scopedFieldNameMap:or?.scopedFieldNameMap,excludedOptionValues:or?.excludedOptionValues,hideTableRowControls:x})},it.id)})})})},`section-border-${Q.run.section.id}-${_}-${R}-${ke?.blockId??"base"}`)}const de=Ig(_,R,Ki,Tr).filter(Ee=>!(et(Ee)?.includes("__addmore__")&&ov.has(`${_}-${R}`)));if(de.length===0){const Ee=Ri[`${_}-${R}`];if(Ee){const ke=$.fields.find(ue=>ue.type==="addmore"&&et(ue)===Ee.addMoreFieldName),je=ke!=null?kn(ke):[],Qe=Ma(Ee.addMoreFieldName,Ee.blockId,je,Fe);return d.jsx("div",{className:"min-h-0 min-w-0 flex flex-col items-center justify-center",style:{gridRow:Z,gridColumn:R+1},"data-form-renderer":"grid-cell","data-form-renderer-add-more-remove":!0,children:d.jsx("button",{type:"button",className:V("inline-flex shrink-0 rounded-md p-1.5 text-destructive hover:bg-destructive/10 focus:outline-none focus:ring-2 focus:ring-ring disabled:pointer-events-none disabled:opacity-40",l&&"text-red-600 hover:bg-red-500/10"),disabled:Qe,title:Qe?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:ue=>{ue.preventDefault(),ue.stopPropagation(),La(Ee.addMoreFieldName,Ee.blockId)},children:d.jsx(si,{className:"h-5 w-5","aria-hidden":!0})})},`add-more-remove-${_}-${R}`)}return d.jsx("div",{className:"min-w-0",style:{pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`empty-${_}-${R}`)}const ye=de[0],{rowSpan:Ce,columnSpan:Ue}=_i(de,Et),Ge=Dd(_,Ce)??Z;if(de.length===1&&ye.type==="section"){const Ee=$.fields.filter(ke=>ke.parentId===ye.id&&ke.position!=null).sort((ke,je)=>{const Qe=typeof ke.position?.order=="number"?ke.position.order:0,ue=typeof je.position?.order=="number"?je.position.order:0;return Qe-ue});return d.jsx("div",{className:"min-w-0 min-h-0 w-full overflow-hidden flex flex-col h-full",style:{gridRow:Ge,gridColumn:`${R+1} / span ${Ue}`,...In(ye)},"data-form-renderer":"grid-cell",children:d.jsx(xy,{field:ye,children:Ee.map(ke=>{const je=ke.name||ke.key||ke.id,Qe=ke.hidden===!0;return pn(ke)&&($r(je)||!Qe&&je)?d.jsx("div",{"data-field-name":je,"data-form-renderer":"field-wrapper",children:d.jsx(xn,{field:lo(ke),value:Fe[je],error:st[je]||ct>0?He[je]:void 0,onChange:_e=>vt(je,_e),onBlur:()=>er(je),disabled:Se||!lr(je)||Yt,readOnly:cr(je,!!ke.readOnly),isRequired:En(je),formValues:Fe,submissionContext:Ne,prepopulateMappedFieldNames:fe,urlParams:De,prepopulateResponse:me,prepopulateLoading:D,formSections:$t,submitPayload:$.config?.submitPayload,fieldValueKey:je,buttonResponses:H,onButtonApiResponse:jr,onSubmit:Nr,onReset:Ye,onCancel:Qr,isSubmitting:ht,bffSubmitApi:L,onBffSubmitResult:g,extraSubmitPayload:Xt,onValidateForm:Hr,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:co,hideTableRowControls:x})},ke.id):null})})},ye.id)}const Rt=Fg(de),Le=de.some(Ee=>["file","camera","photoChoice","addmore","table","billingGrid"].includes(Ee.type)),Be=d.jsx("div",{className:V("flex min-h-0 w-full flex-1 gap-3",Rt==="row"?"flex-row items-stretch":"flex-col items-stretch"),children:de.map(Ee=>{const ke=Ee.name||Ee.key||Ee.id,je=Ee.type==="sectionHeading",Qe=Yo.scopeByFieldName[ke],ue=Qe?.scopedFieldNameMap?.[ke]||ke,_e=Qe?.blockDocumentId!=null?{...Xt,documentId:Qe.blockDocumentId}:Xt,xe=Ee.appearance?.hideLabel??Ee.properties?.hideLabel??!1,pt=Ee.type==="table"||Ee.type==="billingGrid"?Ee.properties?.minWidth:void 0;return d.jsx("div",{"data-field-name":ke,"data-form-renderer":"field-wrapper",className:V("flex min-h-0 min-w-0 flex-1 flex-col",ei(Ee),je&&"items-center justify-center",xe&&"items-center"),style:{...pt?{minWidth:pt}:{},...In(Ee)},children:d.jsx(xn,{field:lo(Ee),value:Fe[ke],error:st[ke]||ct>0?He[ke]:void 0,onChange:Tt=>vt(ke,Tt),onBlur:()=>er(ke),disabled:(Ee.type==="table"||Ee.type==="billingGrid")&&a==="fill"?!1:Se||!lr(ue)||Yt,readOnly:(Ee.type==="table"||Ee.type==="billingGrid")&&a==="fill"?!1:cr(ue,!!Ee.readOnly),isRequired:En(ue),formValues:Fe,submissionContext:Ne,prepopulateMappedFieldNames:fe,urlParams:De,prepopulateResponse:me,prepopulateLoading:D,formSections:$t,submitPayload:$.config?.submitPayload,fieldValueKey:ke,buttonResponses:Qe?.scopedButtonResponses??H,onButtonApiResponse:jr,onSubmit:Nr,onReset:Ye,onCancel:Qr,isSubmitting:ht,bffSubmitApi:L,onBffSubmitResult:g,extraSubmitPayload:_e,onValidateForm:Hr,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:co,scopedFormValues:Qe?.scopedFormValues,scopedFieldNameMap:Qe?.scopedFieldNameMap,excludedOptionValues:Qe?.excludedOptionValues,hideTableRowControls:x})},Ee.id)})});return d.jsx("div",{className:V(du(de),"self-stretch",Le?"overflow-visible":"overflow-hidden"),style:{gridRow:Ge,gridColumn:`${R+1} / span ${Ue}`,...In(de[0])},"data-form-renderer":"grid-cell","data-field-name":de.map(Ee=>Ee.name||Ee.key||Ee.id).join(","),children:Be},de.map(Ee=>Ee.id).join("-"))}))}):d.jsx("div",{className:l?"":"space-y-4","data-form-renderer":"stack",children:_t.map(_=>{if(!Tr(_))return null;const q=cM.find(Z=>Z.kind==="border"&&Z.fields.some(Q=>Q.id===_.id));if(q)return q.fields[0]?.id!==_.id?null:d.jsx(fd,{legend:Bi(q.run.section,0),collapsible:q.run.section.collapsible,defaultCollapsed:q.run.section.defaultCollapsed,onCollapsedChange:Z=>Md(q.run.section.id,void 0,Z),children:q.fields.map(Z=>{const Q=et(Z);return!Q||!Tr(Z)?null:d.jsxs("div",{"data-field-name":Q,"data-form-renderer":"field-wrapper",style:In(Z),children:[d.jsx(xn,{field:lo(Z),value:Fe[Q],error:st[Q]||ct>0?He[Q]:void 0,onChange:de=>vt(Q,de),onBlur:()=>er(Q),disabled:(Z.type==="table"||Z.type==="billingGrid")&&a==="fill"?!1:Se||!lr(Q)||Yt,readOnly:(Z.type==="table"||Z.type==="billingGrid")&&a==="fill"?!1:cr(Q,!!Z.readOnly),isRequired:En(Q),formValues:Fe,submissionContext:Ne,prepopulateMappedFieldNames:fe,urlParams:De,prepopulateResponse:me,prepopulateLoading:D,formSections:$t,submitPayload:$.config?.submitPayload,fieldValueKey:Q,buttonResponses:H,onButtonApiResponse:jr,onSubmit:Nr,onReset:Ye,onCancel:Qr,isSubmitting:ht,bffSubmitApi:L,onBffSubmitResult:g,extraSubmitPayload:Xt,onValidateForm:Hr,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:co,hideTableRowControls:x}),Z.type==="addmore"&&Ua(Z)]},Z.id)})},`stack-border-${q.run.section.id}-${_.id}`);if(!_.parentId){const Z=_t.filter(de=>!de.parentId&&Tr(de)&&ma(de)===ma(_)),Q=Ic(Z).slice(0,2);if(Q.length>1&&Q[0].id!==_.id)return null;if(Q.length>1){const de=Fg(Q);return d.jsx("div",{"data-form-renderer":"shared-cell-stack",className:V("flex w-full min-w-0 gap-3",de==="row"?"flex-row items-stretch":"flex-col"),children:Q.map(ye=>{const Ce=ye.name||ye.key||ye.id;return d.jsxs("div",{"data-field-name":Ce,"data-form-renderer":"field-wrapper",className:V("min-w-0 flex-1 flex flex-col",ei(ye)),style:In(ye),children:[d.jsx(xn,{field:lo(ye),value:Fe[Ce],error:st[Ce]||ct>0?He[Ce]:void 0,onChange:Ue=>vt(Ce,Ue),onBlur:()=>er(Ce),disabled:(ye.type==="table"||ye.type==="billingGrid")&&a==="fill"?!1:Se||!lr(Ce)||Yt,readOnly:(ye.type==="table"||ye.type==="billingGrid")&&a==="fill"?!1:cr(Ce,!!ye.readOnly),isRequired:En(Ce),formValues:Fe,submissionContext:Ne,prepopulateMappedFieldNames:fe,urlParams:De,prepopulateResponse:me,prepopulateLoading:D,formSections:$t,submitPayload:$.config?.submitPayload,fieldValueKey:Ce,buttonResponses:H,onButtonApiResponse:jr,onSubmit:Nr,onReset:Ye,onCancel:Qr,isSubmitting:ht,bffSubmitApi:L,onBffSubmitResult:g,extraSubmitPayload:Xt,onValidateForm:Hr,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:co,hideTableRowControls:x}),ye.type==="addmore"&&Ua(ye)]},ye.id)})},Q.map(ye=>ye.id).join("-"))}}if(_.type==="section"){const Z=$.fields.filter(Q=>Q.parentId===_.id&&Q.position!=null).sort((Q,de)=>{const ye=typeof Q.position?.order=="number"?Q.position.order:0,Ce=typeof de.position?.order=="number"?de.position.order:0;return ye-Ce});return d.jsx(xy,{field:_,children:Z.map(Q=>{const de=Q.name||Q.key||Q.id,ye=Q.hidden===!0;return pn(Q)&&($r(de)||!ye&&de)?d.jsxs("div",{"data-field-name":de,"data-form-renderer":"field-wrapper",style:In(Q),children:[d.jsx(xn,{field:lo(Q),value:Fe[de],error:st[de]||ct>0?He[de]:void 0,onChange:Ue=>vt(de,Ue),onBlur:()=>er(de),disabled:Se||!lr(de)||Yt,readOnly:cr(de,!!Q.readOnly),isRequired:En(de),formValues:Fe,submissionContext:Ne,prepopulateMappedFieldNames:fe,urlParams:De,prepopulateResponse:me,prepopulateLoading:D,formSections:$t,submitPayload:$.config?.submitPayload,fieldValueKey:de,buttonResponses:H,onButtonApiResponse:jr,onSubmit:Nr,onReset:Ye,onCancel:Qr,isSubmitting:ht,bffSubmitApi:L,onBffSubmitResult:g,extraSubmitPayload:Xt,onValidateForm:Hr,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:co,hideTableRowControls:x}),Q.type==="addmore"&&Ua(Q)]},Q.id):null})},_.id)}const R=_.name||_.key||_.id;return d.jsxs("div",{"data-field-name":R,"data-form-renderer":"field-wrapper",style:In(_),children:[d.jsx(xn,{field:lo(_),value:Fe[R],error:st[R]||ct>0?He[R]:void 0,onChange:Z=>vt(R,Z),onBlur:()=>er(R),disabled:(_.type==="table"||_.type==="billingGrid")&&a==="fill"?!1:Se||!lr(R)||Yt,readOnly:(_.type==="table"||_.type==="billingGrid")&&a==="fill"?!1:cr(R,!!_.readOnly),isRequired:En(R),formValues:Fe,submissionContext:Ne,prepopulateMappedFieldNames:fe,urlParams:De,prepopulateResponse:me,prepopulateLoading:D,formSections:$t,submitPayload:$.config?.submitPayload,fieldValueKey:R,buttonResponses:H,onButtonApiResponse:jr,onSubmit:Nr,onReset:Ye,onCancel:Qr,isSubmitting:ht,bffSubmitApi:L,onBffSubmitResult:g,extraSubmitPayload:Xt,onValidateForm:Hr,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:co,hideTableRowControls:x}),_.type==="addmore"&&Ua(_)]},_.id)})})}),u]})})]})});return P?d.jsx(Ug,{handlers:P,moduleId:T??"",submissionContext:p,getAuthHeaders:E,onParentWorkflowSubmitResult:g,children:uv}):uv};var Ca="Tabs",[JP]=Sr(Ca,[sa]),cb=sa(),[QP,bd]=JP(Ca),db=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,onValueChange:o,defaultValue:i,orientation:s="horizontal",dir:a,activationMode:c="automatic",...u}=e,f=vo(a),[l,p]=ln({prop:n,onChange:o,defaultProp:i??"",caller:Ca});return d.jsx(QP,{scope:r,baseId:yn(),value:l,onValueChange:p,orientation:s,dir:f,activationMode:c,children:d.jsx($e.div,{dir:f,"data-orientation":s,...u,ref:t})})});db.displayName=Ca;var ub="TabsList",fb=b.forwardRef((e,t)=>{const{__scopeTabs:r,loop:n=!0,...o}=e,i=bd(ub,r),s=cb(r);return d.jsx(Wh,{asChild:!0,...s,orientation:i.orientation,dir:i.dir,loop:n,children:d.jsx($e.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});fb.displayName=ub;var pb="TabsTrigger",mb=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,disabled:o=!1,...i}=e,s=bd(pb,r),a=cb(r),c=yb(s.baseId,n),u=bb(s.baseId,n),f=n===s.value;return d.jsx(Rh,{asChild:!0,...a,focusable:!o,active:f,children:d.jsx($e.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":u,"data-state":f?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:c,...i,ref:t,onMouseDown:Oe(e.onMouseDown,l=>{!o&&l.button===0&&l.ctrlKey===!1?s.onValueChange(n):l.preventDefault()}),onKeyDown:Oe(e.onKeyDown,l=>{[" ","Enter"].includes(l.key)&&s.onValueChange(n)}),onFocus:Oe(e.onFocus,()=>{const l=s.activationMode!=="manual";!f&&!o&&l&&s.onValueChange(n)})})})});mb.displayName=pb;var hb="TabsContent",gb=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,forceMount:o,children:i,...s}=e,a=bd(hb,r),c=yb(a.baseId,n),u=bb(a.baseId,n),f=n===a.value,l=b.useRef(f);return b.useEffect(()=>{const p=requestAnimationFrame(()=>l.current=!1);return()=>cancelAnimationFrame(p)},[]),d.jsx(Cr,{present:o||f,children:({present:p})=>d.jsx($e.div,{"data-state":f?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":c,hidden:!p,id:u,tabIndex:0,...s,ref:t,style:{...e.style,animationDuration:l.current?"0s":void 0},children:p&&i})})});gb.displayName=hb;function yb(e,t){return`${e}-trigger-${t}`}function bb(e,t){return`${e}-content-${t}`}var ZP=db,eI=fb,tI=mb,rI=gb;function vb({className:e,...t}){return d.jsx(ZP,{"data-slot":"tabs",className:V("flex flex-col gap-2",e),...t})}function vd({className:e,...t}){return d.jsx(eI,{"data-slot":"tabs-list",className:V("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",e),...t})}function wd({className:e,...t}){return d.jsx(tI,{"data-slot":"tabs-trigger",className:V("data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...t})}function wb({className:e,...t}){return d.jsx(rI,{"data-slot":"tabs-content",className:V("flex-1 outline-none",e),...t})}const nI="w-full justify-start border-b rounded-none h-auto p-0 bg-transparent gap-0",oI="rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:shadow-none",iI=({steps:e,position:t,sidebarWidth:r,sticky:n=!0,stickyOffset:o="1rem",sidebarMaxHeight:i="calc(100vh - 6rem)"})=>{if(t==="top")return d.jsx(vd,{className:nI,"data-form-renderer":"workflow-tabs",children:e.map(c=>d.jsx(wd,{value:c.step_id,className:oI,"data-form-renderer":"workflow-tab",children:c.step_name},c.step_id))});const s=t==="left"||t==="right",a=s?{...r?{width:r,flexShrink:0}:{},...n?{top:o}:{},maxHeight:i}:void 0;return d.jsx(vd,{className:V("bg-transparent p-0 gap-0 rounded-none h-auto",s?V("flex flex-col items-stretch shrink-0 self-start z-10 bg-background overflow-y-auto",n&&"sticky",t==="left"?"border-r pr-2":"border-l pl-2",!r&&"w-56"):V("w-full justify-start",t==="bottom"?"border-t pt-0":"border-b")),style:a,"data-form-renderer":"workflow-tabs","data-form-renderer-nav-position":t,children:e.map(c=>d.jsx(wd,{value:c.step_id,className:V("rounded-none shadow-none data-[state=active]:shadow-none text-sm",s?V("justify-start w-full px-3 py-2.5 border-b-0",t==="left"?"border-l-2 border-transparent data-[state=active]:border-primary":"border-r-2 border-transparent data-[state=active]:border-primary"):V("border-b-2 border-transparent data-[state=active]:border-primary",t==="bottom"&&"border-t-2 border-b-0 data-[state=active]:border-t-primary")),"data-form-renderer":"workflow-tab",children:c.step_name},c.step_id))})},sI=new Set(["top","bottom","left","right"]),ji={position:"top",sticky:!0,stickyOffset:"1rem",sidebarMaxHeight:"calc(100vh - 6rem)"};function Sb(e){return typeof e=="string"&&sI.has(e)}function aI(...e){for(const t of e){const r=t?.ui_config?.stepsNavigation;if(r&&typeof r=="object")return r}}function Sd(...e){for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function xd(e={},...t){const r=aI(...t),n=(e.position&&Sb(e.position)?e.position:void 0)??(r?.position&&Sb(r.position)?r.position:ji.position),o=Sd(e.sidebarWidth,r?.sidebarWidth),i=typeof e.sticky=="boolean"?e.sticky:typeof r?.sticky=="boolean"?r.sticky:ji.sticky,s=Sd(e.stickyOffset,r?.stickyOffset)??ji.stickyOffset,a=Sd(e.sidebarMaxHeight,r?.sidebarMaxHeight)??ji.sidebarMaxHeight;return{position:n,sidebarWidth:o,sticky:i,stickyOffset:s,sidebarMaxHeight:a}}function lI(e,...t){return xd({position:e},...t).position}function cI(e){return e==="left"||e==="right"}function Pt({className:e="",...t}){return d.jsx("div",{"data-slot":"skeleton","data-form-renderer":"skeleton",className:`animate-pulse rounded-md bg-neutral-200 dark:bg-neutral-700 ${e}`.trim(),...t})}function dI({className:e="",position:t="top"}){if(t==="left"||t==="right")return d.jsxs("div",{className:`flex gap-4 ${t==="right"?"flex-row-reverse":"flex-row"} ${e}`.trim(),"data-form-renderer":"workflow-steps-view-skeleton",children:[d.jsxs("div",{className:`flex w-56 shrink-0 flex-col gap-1 border-neutral-200 dark:border-neutral-700 py-1 ${t==="left"?"border-r pr-2":"border-l pl-2"}`,children:[d.jsx(Pt,{className:"h-10 w-full rounded-none"}),d.jsx(Pt,{className:"h-10 w-full rounded-none"}),d.jsx(Pt,{className:"h-10 w-full rounded-none"})]}),d.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-4 py-4",children:[d.jsx(Pt,{className:"h-4 w-32"}),d.jsx(Pt,{className:"h-10 w-full"}),d.jsx(Pt,{className:"h-4 w-40"}),d.jsx(Pt,{className:"h-10 w-full"}),d.jsx(Pt,{className:"h-24 w-full"})]})]});const n=d.jsxs("div",{className:`flex w-full gap-0 ${t==="bottom"?"border-t border-neutral-200 pt-0 dark:border-neutral-700":"border-b border-neutral-200 dark:border-neutral-700"}`,children:[d.jsx(Pt,{className:"h-10 w-24 rounded-none"}),d.jsx(Pt,{className:"h-10 w-28 rounded-none ml-1"}),d.jsx(Pt,{className:"h-10 w-20 rounded-none ml-1"})]}),o=d.jsxs("div",{className:"flex flex-col gap-4 py-4",children:[d.jsx(Pt,{className:"h-4 w-32"}),d.jsx(Pt,{className:"h-10 w-full"}),d.jsx(Pt,{className:"h-4 w-40"}),d.jsx(Pt,{className:"h-10 w-full"}),d.jsx(Pt,{className:"h-4 w-36"}),d.jsx(Pt,{className:"h-24 w-full"})]});return d.jsx("div",{className:`flex flex-col gap-4 ${e}`.trim(),"data-form-renderer":"workflow-steps-view-skeleton",children:t==="bottom"?d.jsxs(d.Fragment,{children:[o,n]}):d.jsxs(d.Fragment,{children:[n,d.jsx("div",{className:"mt-4",children:o})]})})}function uI(){return d.jsxs("div",{className:"flex flex-col gap-4 py-4","data-form-renderer":"form-loading-skeleton",children:[d.jsx(Pt,{className:"h-4 w-28"}),d.jsx(Pt,{className:"h-10 w-full"}),d.jsx(Pt,{className:"h-4 w-36"}),d.jsx(Pt,{className:"h-10 w-full"}),d.jsx(Pt,{className:"h-4 w-24"}),d.jsx(Pt,{className:"h-20 w-full"})]})}const fI=3e4,pI=10*6e4,mI=9e4,hI=15*6e4;function gI(e){return e!=null&&"on_success"in e&&e.on_success!=null}function yI(e,t){if(!t||typeof t!="object")return e;let r=e;return Object.entries(t).forEach(([n,o])=>{o!=null&&o!==""&&(r=r.replace(new RegExp(`\\{${n}\\}`,"g"),String(o)))}),r}const xb=({getWorkflowState:e,moduleId:t,tenantId:r,submissionContext:n,initialValues:o={},getAuthHeaders:i,onSuccess:s,bootstrapFeatureId:a,subjectUserId:c,viewStepId:u,clientId:f,className:l,onWorkflowSubmitResult:p,viewerContext:g,getViewerContext:m,dark:h=!1,themeVars:y,stepsNavigationPosition:S,stepsNavigationSidebarWidth:v,stepsNavigationSticky:A,stepsNavigationStickyOffset:x,stepsNavigationSidebarMaxHeight:F,workflowModalHandlers:k})=>{const N=mn.useQueryClient(),T=w.useMemo(()=>[c??"",u??"",f??""],[c,u,f]),P=w.useMemo(()=>({moduleId:t,tenantId:r,subjectUserId:c,viewStepId:u,clientId:f}),[t,r,c,u,f]),[E,C]=w.useState([]),[O,W]=w.useState(null),[M,U]=w.useState(null),[z,X]=w.useState(null),[B,L]=w.useState({}),D=w.useRef(null),K=w.useRef(null),le=w.useRef(null),j=w.useRef(null),H=w.useMemo(()=>E&&Array.isArray(E)?E.filter(he=>he.feature_id):[],[E]),ce=mn.useQuery({queryKey:["workflow-steps",t,a??"",r??"",T[0],T[1],T[2]],queryFn:()=>e({...P,featureId:a}),staleTime:fI,gcTime:pI}),ie=ce.isPending,G=ce.error?ce.error instanceof Error?ce.error.message:"Failed to load workflow steps":null;w.useEffect(()=>{const he=ce.data;if(!he||E.length>0)return;const we=he.steps&&Array.isArray(he.steps)?he.steps:[];C(we);const J=we.filter($=>$.feature_id);if(J.length>0){const $=he.current_step_id,fe=$&&J.some(ze=>ze.step_id===$);W(fe?$:J[0].step_id)}},[ce.data,E.length,a]);const ee=w.useMemo(()=>{if(!O)return;const he=E.find(J=>J.step_id===O),we=D.current===O;return he?.feature_id??(we?j.current:void 0)??void 0},[O,E]),Ae=mn.useQuery({queryKey:["workflow-step",t,ee??"",r??"",T[0],T[1],T[2]],queryFn:()=>e({...P,featureId:ee}),enabled:!!ee,staleTime:mI,gcTime:hI,refetchOnWindowFocus:!0,refetchOnReconnect:!0}),te=Ae.isPending,oe=Ae.error?Ae.error instanceof Error?Ae.error.message:"Failed to load form":null,me=w.useMemo(()=>xd({position:S,sidebarWidth:v,sticky:A,stickyOffset:x,sidebarMaxHeight:F},M,ce.data),[S,v,A,x,F,M,ce.data]),Me=me.position,De=cI(Me);w.useEffect(()=>{!Ae.data||D.current===O||(U(Ae.data),X(null),D.current=null,j.current=null)},[Ae.data,O]),w.useEffect(()=>{X(oe)},[oe]),w.useEffect(()=>{ee===void 0&&D.current!==O&&(U(null),X(null),D.current=null,j.current=null)},[ee,O]);const ne=w.useMemo(()=>{const he=M?.form;if(!he)return null;const we=(r??nn()??"").trim()||"default",J=sb({scope:we,formId:he._id,version:he.version});return J?.value?J.value:Bg(M,n)},[M,n,r]),ge=w.useMemo(()=>{const he=M?.BFF_submit_api;if(!he?.url)return;let we=he.url;if(we.startsWith("http://")||we.startsWith("https://"))try{const fe=new URL(we);we=fe.pathname+fe.search}catch{}const J=i?.()??{},$={...he.headers||{},"Content-Type":"application/json",...J};return{...he,url:we,headers:$}},[M?.BFF_submit_api,i]),Se=w.useMemo(()=>ne?{...ne,status:"published",...ge&&{BFF_submit_api:ge}}:null,[ne,ge]);w.useEffect(()=>{if(!ne?.id)return;const he=(r??nn()??"").trim()||"default";ab({scope:he,formId:ne.id,version:ne.version},ne)},[ne,r]);const yt=w.useMemo(()=>{if(!ne)return null;const he=Yi({config:ne.config,layout:ne.layout},null);if(!he)return null;const we=he.rows,J=he.columns,$={verticalSpacing:he.verticalSpacing??he.spacing??"16px",horizontalSpacing:he.horizontalSpacing??he.spacing??"16px",rowHeight:he.rowHeight??Wn};let fe=1;if(Array.isArray(ne.fields))for(const Fe of ne.fields){const He=Fe?.position,st=typeof He?.order=="number"?He.order:0,ht=typeof He?.rowSpan=="number"?He.rowSpan:1;fe=Math.max(fe,st+ht)}return{rows:Math.min(we,Math.max(1,fe)),columns:J,verticalSpacing:$.verticalSpacing,horizontalSpacing:$.horizontalSpacing,rowHeight:$.rowHeight}},[ne]),kt=w.useMemo(()=>{const we=Se?.config?.theme?.cssVariables;if(!(!we&&!y))return{...we??{},...y??{}}},[Se?.config,y]),Ut=w.useCallback(()=>{N.invalidateQueries({queryKey:["workflow-steps",t]}),N.invalidateQueries({queryKey:["workflow-step",t]})},[N,t]),It=w.useCallback(he=>{if(gI(he)){const fe=he.on_success,ze=fe?.action;if(ze==="redirect"&&fe?.redirect_url){const Fe=yI(fe.redirect_url.trim(),n);window.location.href=Fe;return}if(ze==="move"){const Fe=fe?.next_step_id,He=fe?.next_step_form;if(Fe&&He){D.current=null,j.current=null;const st=He.featureId??fe?.next_step_form_id??He._id;N.removeQueries({queryKey:["workflow-step",t,st,r??"",T[0],T[1],T[2]]}),Ut(),C(ht=>ht.some(ct=>ct.step_id===Fe)?ht:[...ht,{step_id:Fe,step_name:He.name||"Next step",feature_id:st}]),U(null),W(Fe),s?.();return}return}if(ze==="stay"){Ut(),s?.();return}}const we=he;we.steps&&Array.isArray(we.steps)&&C(we.steps);const J=(we.steps&&Array.isArray(we.steps)?we.steps:E).filter(fe=>fe.feature_id),$=we.current_step_id;$&&J.some(fe=>fe.step_id===$)?W($):J.length>0&&W(J[0].step_id),U(null),Ut(),s?.(),p?.(we)},[N,t,r,s,p,E,n,T,Ut]),Er=w.useCallback(async he=>M?.BFF_submit_api?(s?.(),{success:!0,message:"Saved successfully"}):{success:!1,message:"Submit not configured"},[M?.BFF_submit_api,s]),Dt=w.useCallback((he,we)=>{},[]),sr=w.useCallback(he=>{},[]);if(ie)return d.jsx(dI,{className:l,position:S??me.position});if(G)return d.jsx("div",{className:V("rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",l),children:G});if(H.length===0)return d.jsx("div",{className:V("py-12 text-center text-sm text-muted-foreground",l),children:"No workflow steps configured."});const zt=M?.step_blocked_message;return d.jsx("div",{className:V(Wa,h&&"dark","flex flex-col gap-4",l),style:kt,"data-form-renderer":"workflow-steps-view",children:d.jsxs(vb,{value:O??"",onValueChange:he=>W(he),className:V(Me!=="top"&&"gap-4",De&&"flex-row items-start",Me==="right"&&"flex-row-reverse",Me==="bottom"&&"flex-col-reverse"),orientation:De?"vertical":"horizontal",children:[d.jsx(iI,{steps:H,position:Me,sidebarWidth:me.sidebarWidth,sticky:me.sticky,stickyOffset:me.stickyOffset,sidebarMaxHeight:me.sidebarMaxHeight}),H.map(he=>d.jsx(wb,{value:he.step_id,className:V("outline-none",De?"mt-0 flex-1 min-w-0":"mt-4"),children:he.step_id!==O?null:te?d.jsx(uI,{}):z?d.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:z}):zt&&!M?.form?d.jsx("div",{className:V("rounded-lg border border-amber-500/50 bg-amber-500/10 px-4 py-3 text-sm text-amber-800 dark:text-amber-200",l),"data-form-renderer":"workflow-step-blocked",children:zt}):Se?.fields?.length?d.jsxs("div",{className:"py-4 [&_*]:box-border",children:[zt?d.jsx("div",{className:V("mb-4 rounded-lg border border-amber-500/50 bg-amber-500/10 px-4 py-3 text-sm text-amber-800 dark:text-amber-200"),"data-form-renderer":"workflow-step-blocked",children:zt}):null,(()=>{const we=K.current!==O||le.current!==(Se?.id??null);if(O&&Se&&we){K.current=O,le.current=Se.id??null;const J=qn.getState();J.setSchema(Se,{forceReset:!0});const $=qn.getState().values;J.setValues({...$,...o})}return null})(),d.jsx($i,{schema:Se,gridLayout:yt,omitRootWrapper:!0,moduleId:t,workflowModalHandlers:k,getAuthHeaders:i,submissionContext:n,initialValues:o,workflowStepId:O??void 0,viewerContext:g,getViewerContext:m,onSubmit:Er,onChange:Dt,onValidationError:sr,onClose:()=>{},mode:"fill",unstyled:!0,onWorkflowSubmitResult:It,initialExtraSubmitPayload:Object.keys(B).length>0?B:void 0,onExtraSubmitPayloadChange:we=>{if(we&&typeof we=="object"){const J={};we.context_user_id!=null&&(J.context_user_id=we.context_user_id),we.id!=null&&(J.id=we.id),we.batch_id!=null&&(J.batch_id=we.batch_id),we.admission_batch_id!=null&&(J.admission_batch_id=we.admission_batch_id),we.program_id!=null&&(J.program_id=we.program_id),Object.keys(J).length>0&&L($=>({...$,...J}))}}},Se.id)]}):d.jsx("div",{className:"py-8 text-center text-sm text-muted-foreground",children:"No form schema available for this step."})},he.step_id))]})})},Ea=new Map;function bI(e){if(e){Ea.delete(e);return}Ea.clear()}async function ka(e,t,r){const n=Ea.get(t);if(n!==void 0)return n;const o=e.replace(/\/$/,""),s=!!(await qt.get(`${o}/${encodeURIComponent(t)}/meta`,{headers:r})).data?.standalone_workflow;return Ea.set(t,s),s}function Na(e){const t={...e.getAuthHeaders?.()??{}};return e.clientId&&(t["x-client-id"]=e.clientId),e.userId&&(t["x-user-id"]=e.userId),t}function Ad(e,t){Object.entries(t).forEach(([r,n])=>{n&&e.set(r,n)})}function Ab(e){const t=e.bffWorkflowsBasePath.replace(/\/$/,""),r=()=>Na({getAuthHeaders:e.getAuthHeaders,clientId:e.clientId,userId:e.userId}),n=o=>o?.trim()||e.moduleId?.trim()||"";return{async getWorkflowStateById({workflowId:o,moduleId:i,entryStepId:s}){const a=o.trim(),c=r();if(await ka(t,a,c)){const p=new URLSearchParams;e.clientId&&p.set("client_id",e.clientId),e.userId&&p.set("user_id",e.userId),Ad(p,{entry_step_id:s});const g=p.toString();return(await qt.get(`${t}/${encodeURIComponent(a)}/standalone-state${g?`?${g}`:""}`,{headers:c})).data}const f=new URLSearchParams;return f.set("module_id",n(i)),e.clientId&&f.set("client_id",e.clientId),e.userId&&f.set("user_id",e.userId),Ad(f,{entry_step_id:s}),(await qt.get(`${t}/${encodeURIComponent(a)}/state?${f.toString()}`,{headers:c})).data},async navigateWorkflowStep({workflowId:o,moduleId:i,targetStepId:s}){const a=o.trim(),c=r();if(await ka(t,a,c))return(await qt.post(`${t}/${encodeURIComponent(a)}/standalone-navigate-step`,{workflow_id:a,target_step_id:s},{headers:c})).data;const f=n(i);return(await qt.post(`${t}/modules/${encodeURIComponent(f)}/navigate-step`,{workflow_id:a,target_step_id:s},{headers:c})).data}}}async function Cb(e){const t=e.bffWorkflowsBasePath.replace(/\/$/,""),r=Na({getAuthHeaders:e.getAuthHeaders,clientId:e.clientId,userId:e.subjectUserId});if(e.workflowId?.trim()){const s=e.workflowId.trim();if(await ka(t,s,r)){const c=new URLSearchParams;e.clientId&&c.set("client_id",e.clientId),e.subjectUserId&&c.set("user_id",e.subjectUserId),Ad(c,{step_id:e.viewStepId});const u=c.toString();return(await qt.get(`${t}/${encodeURIComponent(s)}/standalone-state${u?`?${u}`:""}`,{headers:r})).data}}const n=new URLSearchParams;n.set("module_id",e.moduleId),e.featureId&&n.set("feature_id",e.featureId),e.tenantId&&n.set("tenant_id",e.tenantId),e.subjectUserId&&n.set("user_id",e.subjectUserId),e.viewStepId&&n.set("step_id",e.viewStepId),e.clientId&&n.set("client_id",e.clientId);const o=e.workflowId?.trim()?`${t}/${encodeURIComponent(e.workflowId.trim())}/state?${n.toString()}`:`${t}/modules/${encodeURIComponent(e.moduleId)}/state?${n.toString()}`;return(await qt.get(o,{headers:r})).data}function vI(e){return typeof e=="object"&&e!==null&&"apiEndpoint"in e}function wI({formSchema:e}){const t=w.useMemo(()=>{if(!e)return[];const i=[];(!e.name||e.name.trim()==="")&&i.push({id:"form-name-required",type:"error",message:"Form name is required"});const s=new Set,a=new Set;e.fields.forEach((f,l)=>{const p=`field-${f.id}`;if(a.has(f.id)&&i.push({id:`${p}-duplicate-id`,type:"error",message:`Field "${f.label||f.name||`Field ${l+1}`}" has a duplicate ID`,fieldId:f.id}),a.add(f.id),f.name&&s.has(f.name)&&i.push({id:`${p}-duplicate-name`,type:"error",message:`Field "${f.label||f.name}" has a duplicate name: "${f.name}"`,fieldId:f.id}),f.name&&s.add(f.name),(!f.label||f.label.trim()==="")&&i.push({id:`${p}-missing-label`,type:"warning",message:`Field "${f.name||f.id}" is missing a label`,fieldId:f.id}),(!f.name||f.name.trim()==="")&&i.push({id:`${p}-missing-name`,type:"error",message:`Field "${f.label||f.id}" is missing a field name`,fieldId:f.id}),f.name&&!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(f.name)&&i.push({id:`${p}-invalid-name`,type:"error",message:`Field "${f.label||f.name}" has an invalid name. Use only letters, numbers, and underscores.`,fieldId:f.id}),["select","multiselect","radio","checkboxgroup"].includes(f.type)){const h=f.properties;(!h?.options||h.options.length===0)&&i.push({id:`${p}-no-options`,type:"warning",message:`Field "${f.label||f.name}" has no options defined`,fieldId:f.id})}f.parentId&&(e.fields.some(y=>y.id===f.parentId)||i.push({id:`${p}-orphaned`,type:"error",message:`Field "${f.label||f.name}" references a non-existent parent`,fieldId:f.id}));const m=(h,y)=>{if(y.has(h))return!0;y.add(h);const S=e.fields.find(v=>v.id===h);return S?.parentId?m(S.parentId,y):!1};f.parentId&&m(f.id,new Set)&&i.push({id:`${p}-circular-reference`,type:"error",message:`Field "${f.label||f.name}" has a circular parent reference`,fieldId:f.id})}),e.config.workflowTrigger?.workflowId&&(e.fields.some(l=>l.validation?.some(p=>p.type==="required"))||i.push({id:"workflow-no-required-fields",type:"info",message:"Form linked to workflow but has no required fields"}));const c=e.fields.filter(f=>!f.parentId),u=new Map;return c.forEach(f=>{const l=f.position.order;u.has(l)||u.set(l,[]),u.get(l).push(f)}),u.forEach((f,l)=>{f.length>3&&i.push({id:`row-${l}-too-many-fields`,type:"warning",message:`Row ${l+1} has ${f.length} fields (maximum recommended is 3)`})}),i},[e]),r=w.useMemo(()=>t.filter(i=>i.type==="error"),[t]),n=w.useMemo(()=>t.filter(i=>i.type==="warning"),[t]),o=w.useMemo(()=>r.length===0,[r]);return{issues:t,errors:r,warnings:n,isValid:o}}function SI({field:e,value:t,allValues:r,validateOnChange:n=!1,validateOnBlur:o=!0,debounceMs:i=bP}){const[s,a]=w.useState(),[c,u]=w.useState(!1),f=w.useRef(void 0),l=w.useRef(t),p=w.useCallback(async()=>{if(!e.validation||e.validation.length===0){a(void 0);return}u(!0);let S;for(const v of e.validation){const A=rn(t,v,r);if(typeof A=="string"){S=A;break}}return a(S),u(!1),S},[e.validation,t,r]),g=w.useCallback(()=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{p()},i)},[p,i]);w.useEffect(()=>(n&&l.current!==t&&g(),l.current=t,()=>{f.current&&clearTimeout(f.current)}),[t,n,g]);const m=w.useCallback(()=>{o&&p()},[o,p]),h=w.useCallback(()=>{a(void 0)},[]),y=w.useCallback(S=>{a(S)},[]);return{error:s,isValidating:c,validate:p,handleBlur:m,clearError:h,setCustomError:y}}const Eb="—";function Zt(){return{kind:"static",value:Eb}}function xI(){return Hu({currencySymbol:"₹",emptyDisplay:Eb,columns:[{id:"col_tariff",key:"tariff_type",label:"Tariff type",format:"text",align:"left"},{id:"col_service",key:"service",label:"Service",format:"text",align:"left"},{id:"col_unit",key:"unit_price",label:"Unit price",format:"currency",align:"right"},{id:"col_disc_pct",key:"discount_pct",label:"Discount (%)",format:"percent",align:"right"},{id:"col_disc_amt",key:"discount_amount",label:"Discount (₹)",format:"currency",align:"right"},{id:"col_net",key:"net_price",label:"Net price",format:"currency",align:"right"},{id:"col_tax",key:"tax_pct",label:"Tax (%)",format:"percent",align:"right"},{id:"col_total",key:"total",label:"Total",format:"currency",align:"right"}],rowSlots:[{kind:"static",row:{id:"registration_fee",label:"Registration fee",cells:{tariff_type:{kind:"label"},service:Zt(),unit_price:{kind:"api",path:"unit_price"},discount_pct:{kind:"input",inputType:"number"},discount_amount:{kind:"formula",expression:"cell('unit_price') * cell('discount_pct') / 100"},net_price:{kind:"formula",expression:"cell('unit_price') - cell('discount_amount')"},tax_pct:{kind:"api",path:"tax_pct"},total:{kind:"formula",expression:"cell('net_price') * (1 + cell('tax_pct') / 100)"}}}},{kind:"dynamic",block:{id:"line_items",apiArrayPath:"items",rowIdField:"id",cells:{tariff_type:Zt(),service:{kind:"api",path:"service"},unit_price:{kind:"api",path:"unit_price"},discount_pct:Zt(),discount_amount:{kind:"formula",expression:"cell('unit_price') * cell('discount_pct') / 100"},net_price:{kind:"formula",expression:"cell('unit_price') - cell('discount_amount')"},tax_pct:{kind:"api",path:"tax_pct"},total:{kind:"formula",expression:"cell('net_price') * (1 + cell('tax_pct') / 100)"}}}},{kind:"static",row:{id:"all_items_summary",label:"All items summary",cells:{tariff_type:{kind:"label"},service:Zt(),unit_price:{kind:"formula",expression:"SUM('unit_price', 'data')"},discount_pct:Zt(),discount_amount:{kind:"formula",expression:"SUM('discount_amount', 'data')"},net_price:{kind:"formula",expression:"SUM('net_price', 'data')"},tax_pct:Zt(),total:{kind:"formula",expression:"SUM('total', 'data')"}}}},{kind:"static",row:{id:"invoice_discount",label:"Invoice discount",cells:{tariff_type:{kind:"label"},service:Zt(),unit_price:Zt(),discount_pct:Zt(),discount_amount:{kind:"input",inputType:"number"},net_price:Zt(),tax_pct:Zt(),total:Zt()}}},{kind:"static",row:{id:"grand_total",label:"Grand total",cells:{tariff_type:{kind:"label"},service:Zt(),unit_price:Zt(),discount_pct:Zt(),discount_amount:Zt(),net_price:Zt(),tax_pct:Zt(),total:{kind:"formula",expression:"SUM('total', 'data') - cellInRow('invoice_discount', 'discount_amount')"}}}}]})}const AI={text:{type:"text",label:"Text Input",icon:"Type",category:"input",description:"Single line text input",defaultProps:{label:"Text Field",name:"text_field",placeholder:"Enter text..."}},number:{type:"number",label:"Number Input",icon:"Hash",category:"input",description:"Numeric input with optional constraints",defaultProps:{label:"Number Field",name:"number_field",placeholder:"0",properties:{min:0,step:1}}},email:{type:"email",label:"Email",icon:"Mail",category:"input",description:"Email address input with validation",defaultProps:{label:"Email",name:"email_field",placeholder:"example@domain.com",validation:[{type:"email"}]}},phone:{type:"phone",label:"Phone",icon:"Phone",category:"input",description:"Phone number input",defaultProps:{label:"Phone Number",name:"phone_field",placeholder:"+91 12345 67890"}},otp:{type:"otp",label:"OTP",icon:"ShieldCheck",category:"input",description:"One-time password with separate digit boxes",defaultProps:{label:"OTP",name:"otp_field",properties:{otpLength:4,numericOnly:!0},validation:[{type:"required",message:"Please enter the OTP"}]}},password:{type:"password",label:"Password",icon:"Lock",category:"input",description:"Secure password input",defaultProps:{label:"Password",name:"password_field",placeholder:"••••••••"}},url:{type:"url",label:"URL",icon:"Link",category:"input",description:"URL input with validation",defaultProps:{label:"URL",name:"url_field",placeholder:"https://example.com",validation:[{type:"url"}]}},date:{type:"date",label:"Date",icon:"Calendar",category:"datetime",description:"Date picker",defaultProps:{label:"Date",name:"date_field",placeholder:"Select date"}},time:{type:"time",label:"Time",icon:"Clock",category:"datetime",description:"Time picker",defaultProps:{label:"Time",name:"time_field",placeholder:"Select time"}},datetime:{type:"datetime",label:"Date & Time",icon:"CalendarClock",category:"datetime",description:"Combined date and time picker",defaultProps:{label:"Date & Time",name:"datetime_field",placeholder:"Select date and time"}},daterange:{type:"daterange",label:"Date Range",icon:"CalendarRange",category:"datetime",description:"Select a range of dates",defaultProps:{label:"Date Range",name:"daterange_field",placeholder:"Select date range"}},select:{type:"select",label:"Dropdown",icon:"ChevronDown",category:"selection",description:"Single selection dropdown",defaultProps:{label:"Select",name:"select_field",placeholder:"Select an option",properties:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}],searchable:!0,clearable:!0}}},multiselect:{type:"multiselect",label:"Multi Select",icon:"ListChecks",category:"selection",description:"Multiple selection dropdown",defaultProps:{label:"Multi Select",name:"multiselect_field",placeholder:"Select options",properties:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}],searchable:!0}}},radio:{type:"radio",label:"Radio Group",icon:"CircleDot",category:"selection",description:"Single selection radio buttons",defaultProps:{label:"Radio Group",name:"radio_field",properties:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}]}}},checkbox:{type:"checkbox",label:"Checkbox",icon:"CheckSquare",category:"selection",description:"Single checkbox for boolean values",defaultProps:{label:"I agree to the terms",name:"checkbox_field"}},toggle:{type:"toggle",label:"Toggle",icon:"ToggleLeft",category:"selection",description:"Toggle switch with configurable text values",defaultProps:{label:"Toggle",name:"toggle_field",description:"Toggle to switch between states",properties:{onValue:"On",offValue:"Off"}}},checkboxgroup:{type:"checkboxgroup",label:"Checkbox Group",icon:"CheckSquare",category:"selection",description:"Multiple checkboxes for selecting multiple values",defaultProps:{label:"Checkbox Group",name:"checkboxgroup_field",properties:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}]}}},selectablelist:{type:"selectablelist",label:"Selectable List",icon:"ListChecks",category:"selection",description:"List from response or context; select all or specific items. Value = selected array.",defaultProps:{label:"Recipients",name:"recipients",properties:{dataSourceContextKey:"recipients",labelField:"name",valueField:"email",showSelectAll:!0,selectAllByDefault:!0}}},asyncsearch:{type:"asyncsearch",label:"Async Search",icon:"Search",category:"selection",description:"Typeahead search against an API; submitted value is the selected option value.",defaultProps:{label:"Search",name:"async_search",placeholder:"Type to search…",properties:{apiEndpoint:"/api/form-builder/search",apiMethod:"GET",searchQueryParam:"q",searchSchedule:"debounce",intervalMs:300,minQueryLength:0,clearable:!0}}},terms:{type:"terms",label:"Terms & Conditions",icon:"FileText",category:"special",description:"Terms and conditions confirmation checkbox",defaultProps:{label:"I confirm that the details are true to my knowledge",name:"terms_conditions",validation:[{type:"required"}]}},textarea:{type:"textarea",label:"Text Area",icon:"AlignLeft",category:"rich",description:"Multi-line text input",defaultProps:{label:"Text Area",name:"textarea_field",placeholder:"Enter your text here...",properties:{minLength:0,maxLength:1e3}}},richtext:{type:"richtext",label:"Rich Text",icon:"FileText",category:"rich",description:"Rich text editor with formatting",defaultProps:{label:"Rich Text",name:"richtext_field"}},file:{type:"file",label:"File Upload",icon:"Upload",category:"rich",description:"File upload with drag and drop",defaultProps:{label:"File Upload",name:"file_field",properties:{accept:["image/*","application/pdf"],maxSize:5*1024*1024}}},camera:{type:"camera",label:"Use camera",icon:"Camera",category:"rich",description:"Take a photo with your camera",defaultProps:{label:"Take photo",name:"camera_field",properties:{accept:["image/*"],maxSize:5*1024*1024,multiple:!1}}},photoChoice:{type:"photoChoice",label:"Photo (upload or camera)",icon:"ImagePlus",category:"rich",description:"Upload a file or capture with the camera",defaultProps:{label:"Photo",name:"photo_choice_field",properties:{accept:["image/*"],maxSize:5*1024*1024,maxFiles:1}}},signature:{type:"signature",label:"Signature",icon:"Pencil",category:"rich",description:"Digital signature capture",defaultProps:{label:"Signature",name:"signature_field"}},rating:{type:"rating",label:"Rating",icon:"Star",category:"rich",description:"Star rating input",defaultProps:{label:"Rating",name:"rating_field",properties:{max:5,allowHalf:!1,icon:"star"}}},slider:{type:"slider",label:"Slider",icon:"SlidersHorizontal",category:"rich",description:"Numeric slider input",defaultProps:{label:"Slider",name:"slider_field",properties:{min:0,max:100,step:1,showValue:!0}}},table:{type:"table",label:"Table",icon:"Table",category:"special",description:"Repeatable table rows",defaultProps:{label:"Table",name:"table_field",properties:{columns:[],minRows:1,maxRows:10,allowAddRow:!0,allowDeleteRow:!0}}},billingGrid:{type:"billingGrid",label:"Billing Grid",icon:"Receipt",category:"special",description:"Configurable billing/tariff grid with formulas and API line items",defaultProps:{label:"Billing",name:"billing",properties:xI()}},aadhaar:{type:"aadhaar",label:"Aadhaar",icon:"CreditCard",category:"special",description:"Indian Aadhaar number input",defaultProps:{label:"Aadhaar Number",name:"aadhaar_field",placeholder:"XXXX XXXX XXXX"}},section:{type:"section",label:"Section",icon:"LayoutPanelTop",category:"container",description:"Group fields in a collapsible section",defaultProps:{label:"Section",name:"section",properties:{collapsible:!0,defaultCollapsed:!1,columns:1}}},group:{type:"group",label:"Group",icon:"Group",category:"container",description:"Group fields without visual separator",defaultProps:{label:"Group",name:"group"}},columns:{type:"columns",label:"Columns",icon:"Columns",category:"container",description:"Multi-column layout",defaultProps:{label:"Columns",name:"columns",properties:{columns:2}}},divider:{type:"divider",label:"Divider",icon:"Minus",category:"visual",description:"Horizontal line separator",defaultProps:{label:"",name:"divider"}},header:{type:"header",label:"Header",icon:"Heading",category:"visual",description:"Section header text (full row, configurable size)",defaultProps:{label:"Header",name:"header",properties:{headingLevel:"h3",showHorizontalLine:!0}}},sectionHeading:{type:"sectionHeading",label:"Section Heading",icon:"Heading",category:"visual",description:"Heading inside a grid box with configurable position and size",defaultProps:{label:"Section Heading",name:"section_heading",properties:{position:"top-left",headingLevel:"h3",showHorizontalLine:!0}}},spacer:{type:"spacer",label:"Spacer",icon:"Space",category:"visual",description:"Empty space for padding",defaultProps:{label:"",name:"spacer"}},textLabel:{type:"textLabel",label:"Text Label",icon:"Tag",category:"visual",description:"Standalone label text (no input)",defaultProps:{label:"Label",name:"text_label"}},status:{type:"status",label:"Status",icon:"ListChecks",category:"visual",description:"Populate status from Status API; label + response key; true = completed",defaultProps:{label:"Admission Status",name:"status_field",properties:{source:"api",statuses:[{label:"Registered",key:"registered"},{label:"Form Submitted",key:"formSubmitted"},{label:"Documents Verification",key:"documentsVerification"},{label:"Photos Clicked",key:"photosClicked"},{label:"Fitness Verification",key:"fitnessVerification"},{label:"Payment Completed",key:"paymentCompleted"},{label:"Hostel Allotted",key:"hostelAllotted"},{label:"Admission Completed",key:"admissionCompleted"}],showStatusText:!1,statusTextPath:"admissionStatus",showCurrentIndicator:!0}}},button:{type:"button",label:"Button",icon:"MousePointerClick",category:"special",description:"Clickable button element",defaultProps:{label:"Button",name:"button_field",properties:{variant:"default",size:"default",action:"download"}}},editButton:{type:"editButton",label:"Edit Button",icon:"Pencil",category:"special",description:"Toggle edit mode: enable/disable or show/hide other fields and buttons (no API call)",defaultProps:{label:"Edit",name:"edit_button",properties:{buttonText:"Edit",variant:"outline",size:"default",hideLabel:!1,rules:[]}}},addmore:{type:"addmore",label:"Add More",icon:"Plus",category:"special",description:"Duplicate linked fields as a new runtime block",defaultProps:{label:"Add More",name:"addmore_field",properties:{linkedFieldNames:[],linkedSectionIds:[],variant:"outline",size:"default"}}},customizeSections:{type:"customizeSections",label:"Customise Sections",icon:"ListFilter",category:"special",description:"Show or hide UI sections defined by Section Heading fields",defaultProps:{label:"Customise Sections",name:"customize_sections",properties:{sectionHeadingNames:[],defaultHiddenSectionNames:[],variant:"outline",size:"default",buttonText:"Customise sections",menuTitle:"VISIBLE SECTIONS"}}}},kb={padding:"md",showBorder:!1};function Nb(e,t){const r="full";return e?{padding:e.padding??kb.padding,maxWidth:e.maxWidth??r,showBorder:e.showBorder??kb.showBorder}:{padding:"md",maxWidth:r,showBorder:!1}}function CI(e){switch(e??"md"){case"none":return"";case"sm":return"p-3";case"lg":return"p-6 md:p-8";default:return"p-4 md:p-6"}}function EI(e,t){if(t==="full-bleed")return"w-full max-w-none";switch(e??"full"){case"full":return"w-full max-w-none";case"sm":return"mx-auto w-full max-w-screen-sm";case"md":return"mx-auto w-full max-w-screen-md";case"lg":return"mx-auto w-full max-w-screen-lg";case"xl":return"mx-auto w-full max-w-screen-xl";case"2xl":return"mx-auto w-full max-w-2xl";case"4xl":return"mx-auto w-full max-w-4xl";case"5xl":return"mx-auto w-full max-w-5xl";case"6xl":return"mx-auto w-full max-w-6xl";case"7xl":return"mx-auto w-full max-w-7xl";default:return"w-full max-w-none"}}function kI(e){switch(e){case"sidebar-main":return"grid grid-cols-1 gap-6 lg:grid-cols-[240px_1fr]";case"full-bleed":return"w-full";default:return"w-full"}}function NI(e){const t=Nb(e.container,e.layout);return V(kI(e.layout),EI(t.maxWidth,e.layout),CI(t.padding),t.showBorder&&"rounded-lg border border-border")}const _a=1;function _I(){return{version:_a,layout:"stack",container:{padding:"md",maxWidth:"full",showBorder:!1},dataBindings:[],widgets:[],filterGroups:[]}}function _b(e){return{...e,config:e.config??{},children:Array.isArray(e.children)?e.children.map(_b):void 0}}function TI(e){return{version:_a,layout:e.layout??"stack",container:Nb(e.container,e.layout),meta:e.meta,dataBindings:Array.isArray(e.dataBindings)?e.dataBindings:[],dataApis:e.dataApis??{},prepopulateApi:e.prepopulateApi,widgets:Array.isArray(e.widgets)?e.widgets.map(_b):[],filterGroups:Array.isArray(e.filterGroups)?e.filterGroups:[],eventHandlers:e.eventHandlers??[],navigation:e.navigation}}function FI(e){const t=e;return!t||typeof t!="object"?_I():(t.version!==_a&&(t.version=_a),TI(t))}function Hn(e){return e&&typeof e=="object"?e:void 0}function Tb(e){const t=Hn(e);if(!t)throw new Error("Page render failed: empty response");const r=t.schema;if(!r||typeof r!="object")throw new Error("Page render failed: schema missing");const n=typeof t.pageId=="string"&&t.pageId.trim()||typeof t.id=="string"&&t.id.trim()||(typeof Hn(t.page)?.id=="string"?String(Hn(t.page).id):"");if(!n)throw new Error("Page render failed: page id missing");const o=typeof t.version=="number"?t.version:0;return{id:n,version:o,route:t.route,schema:r,embeddedForms:t.embeddedForms}}function PI(e){const t=Hn(e);if(!t)throw new Error("Page resolve failed: empty response");const r=Hn(t.page),n=typeof t.pageId=="string"&&t.pageId.trim()||typeof r?.pageId=="string"&&r.pageId.trim()||(typeof Hn(r?.page)?.id=="string"?String(Hn(r.page).id):"");if(!n)throw new Error("Page resolve failed: pageId missing from response");const o=(typeof t.version=="number"?t.version:void 0)??(typeof r?.version=="number"?r.version:void 0)??0,i=r&&r.schema&&typeof r.schema=="object"?Tb(r):void 0,s=Hn(t.routeParams);return{pageId:n,version:o,...i?{renderPayload:i}:{},...s?{routeParams:s}:{}}}const Fb={};let Pb=null;function Ib(e){Pb=e}function II(){return(Fb?.VITE_API_BASE_URL?.trim()||Fb?.VITE_API_URL?.trim()||"").replace(/\/$/,"")}const Ro=At.create({baseURL:II()});Ro.interceptors.request.use(e=>{const t=nn();t&&(e.params={...e.params,clientId:t}),typeof FormData<"u"&&e.data instanceof FormData&&delete e.headers["Content-Type"];let r=Pb?.();if((!r||Object.keys(r).length===0)&&(r=mi()),r){const n=e.headers??{};for(const[o,i]of Object.entries(r))i!==void 0&&i!==""&&(n[o]=i);e.headers=n}return e});async function Hi(e){const t=await Ro.get("/api/page-builder/pages/resolve",{params:e}),r=t.data?.data??t.data;return PI(r)}async function Ui(e,t,r){const n=await Ro.get(`/api/page-builder/pages/${e}/render`,{params:{clientId:t,...r!==void 0?{version:r}:{}}}),o=n.data?.data??n.data;return Tb(o)}async function Cd(e){const{clientId:t,api:r,context:n,filterState:o}=e,i=await Ro.post(`/api/page-builder/clients/${t}/data-sources/execute`,{api:r,context:n,filterState:o});return i.data?.data??i.data}function OI(e,t){if(!t)return{};const r={};for(const[n,o]of Object.entries(t)){if(!o.trim())continue;const i=We(e,o);i!==void 0&&(r[n]=i)}return r}const Ed=w.createContext(null);function MI(e,t){if(t.parentContext)return"idle";const r=e.prepopulateApi,n=String(t.clientIdProp??t.externalContext.clientId??"");return r?.enabled&&r.api?.path&&n?"loading":"idle"}function Ob(e,t){const r={};for(const n of e){let o;switch(n.source){case"route.param":o=n.param?t[n.param]:void 0;break;case"route.query":o=n.param?t[n.param]:void 0;break;case"context.user":o=n.param?t.user?.[n.param]:t.user;break;case"context.client":o=n.param?t.client?.[n.param]:t.client??t.clientId;break;case"context.tenant":o=n.param?t.tenant?.[n.param]:t.tenant??t.tenantId;break;case"static":o=n.value;break;case"widget.state":o=n.sample;break;default:o=void 0}o===void 0&&n.sample!==void 0&&(o=n.sample),o!==void 0&&(r[n.key]=o)}return r}function LI({schema:e,context:t={},clientId:r,nestingDepth:n=0,onAction:o,getWorkflowState:i,workflowModalHandlers:s,getAuthHeaders:a,parentContext:c,children:u}){const[f,l]=w.useState(()=>c?c.filterGroups:{}),p=w.useRef(f);p.current=f;const[g,m]=w.useState({}),[h,y]=w.useState(()=>MI(e,{parentContext:c,clientIdProp:r,externalContext:t})),S=w.useRef(null),v=String(r??t.clientId??c?.clientId??""),A=JSON.stringify(t);w.useEffect(()=>{if(c)return;const E=e.prepopulateApi;if(!E?.enabled||!E.api?.path||!v){m({}),y("idle"),S.current=null;return}const C=JSON.stringify({path:E.api.path,method:E.api.method,queryParams:E.api.queryParams,headers:E.api.headers,bodyFields:E.api.bodyFields,auth:E.api.auth,mapping:E.contextMapping,bindings:e.dataBindings,context:A});if(S.current===C)return;let O=!1;return S.current=C,y("loading"),(async()=>{try{const W=Ob(e.dataBindings??[],t),M={...t,...W},U=await Cd({clientId:v,api:E.api,context:M});if(O)return;const z=OI(U,E.contextMapping);m({...z,prepopulateResponse:U}),y("ready")}catch{O||(m({}),y("error"))}})(),()=>{O=!0,S.current=null}},[c,e.prepopulateApi,e.dataBindings,A,v]);const x=w.useMemo(()=>{if(c)return{...c.context,...t};const E=Ob(e.dataBindings??[],t);return{...t,...E,...g}},[c,t,e.dataBindings,g]),F=String(r??x.clientId??c?.clientId??""),k=w.useCallback((E,C,O)=>{l(W=>({...W,[E]:{...W[E]??{},[C]:O}}))},[]),N=w.useCallback(E=>p.current[E]??{},[]),T=w.useCallback((E,C,O,W)=>{(o??c?.onAction)?.({...E,sourceWidgetId:C,event:O,payload:W})},[o,c?.onAction]),P=w.useMemo(()=>({schema:e,context:x,clientId:F,prepopulateStatus:c?.prepopulateStatus??h,nestingDepth:n,onAction:o??c?.onAction,getWorkflowState:i??c?.getWorkflowState,workflowModalHandlers:s??c?.workflowModalHandlers,getAuthHeaders:a??c?.getAuthHeaders,filterGroups:f,setFilterValue:k,getFilterGroup:N,dispatchAction:T}),[e,x,F,h,n,o,c?.onAction,i,c?.getWorkflowState,s,c?.workflowModalHandlers,a,c?.getAuthHeaders,f,k,N,T]);return d.jsx(Ed.Provider,{value:P,children:u})}function Br(){const e=w.useContext(Ed);if(!e)throw new Error("usePageContext must be used within PageContextProvider");return e}function DI(){return w.useContext(Ed)}const BI=5,Mb=1;function Ko(e){return Number.isFinite(e)?Math.min(BI,Math.max(Mb,Math.round(e))):Mb}function $I(e,t){const r=Ko(t),n=Array.from({length:r},()=>[]);return e.forEach((o,i)=>{const s=o.config,a=s.columnIndex!==void 0?Math.min(Math.max(0,s.columnIndex),r-1):i%r;n[a].push(o)}),n}function jI(e){return Number.isFinite(e)?Math.min(100,Math.max(0,Math.round(e))):0}function HI(e,t){const r=Math.max(1,t),n=Math.min(100,Math.max(0,Math.round(e))),o=Math.floor(n/r),i=n-o*r;return Array.from({length:r},(s,a)=>o+(a<i?1:0))}function Lb(e){return HI(100,Ko(e))}function UI(e){const t=e.trim(),r=/^(\d+(?:\.\d+)?)\s*%?$/.exec(t);return r?jI(Number(r[1])):null}function Db(e,t){const r=Ko(t),n=[];for(let i=0;i<r;i++){const s=UI(e?.[i]??"");if(s===null)return Lb(r);n.push(s)}return n.reduce((i,s)=>i+s,0)!==100?Lb(r):n}function zI(e){return e==="sm"?"gap-2":e==="lg"?"gap-6":"gap-4"}function Bb(e,t){return Db(t,Ko(e)).map(n=>`minmax(0, ${n}fr)`).join(" ")}function VI(e){return e.length?e.map(t=>`minmax(0, ${t}fr)`).join(" "):"minmax(0, 1fr)"}function WI(e,t,r,n){const o=Ko(t),i=$I(e,o),s=Db(r,o);if(!(n?.collapseEmpty!==!1))return{columns:i,gridTemplate:Bb(o,r),sourceIndices:i.map((p,g)=>g)};const c=i.map((p,g)=>({colChildren:p,index:g,percent:s[g]??0})).filter(p=>p.colChildren.length>0);if(c.length===0||c.length===i.length)return{columns:i,gridTemplate:Bb(o,r),sourceIndices:i.map((p,g)=>g)};const u=c.reduce((p,g)=>p+g.percent,0),f=c.map(p=>u>0?Math.round(p.percent/u*100):Math.round(100/c.length)),l=100-f.reduce((p,g)=>p+g,0);return l!==0&&f.length>0&&(f[0]+=l),{columns:c.map(p=>p.colChildren),gridTemplate:VI(f),sourceIndices:c.map(p=>p.index)}}function kd(e,t="solid"){return e?t==="dashed"?"rounded-md border border-dashed border-border":"rounded-md border border-border":""}function RI(e){return V(kd(e.showBorder,e.borderStyle??"solid"),e.showBorder&&"p-3")}function KI(e){return V(kd(e.showBorder,e.borderStyle??"solid"),e.showBorder&&"p-2")}function GI(e,t){return e.columnBorders?.[t]!==void 0?!!e.columnBorders[t]:!!e.showColumnBorders}function qI(e,t){const r=GI(e,t);return V(kd(r,e.borderStyle??"dashed"),r&&"p-2")}function YI(e){if(e)return{minHeight:`${e}vh`}}function XI({widget:e,renderChildren:t}){const r=e.config,[n,o]=w.useState(r.defaultCollapsed??!1);return d.jsxs("section",{className:V("space-y-4",RI(r)),"data-widget-id":e.id,children:[r.heading&&d.jsx("div",{className:"flex items-center gap-2",children:r.collapsible?d.jsx("button",{type:"button",className:"text-left text-lg font-semibold hover:underline",onClick:()=>o(i=>!i),children:r.heading}):d.jsx("h2",{className:"text-lg font-semibold",children:r.heading})}),r.showDivider&&d.jsx("hr",{className:"border-border"}),!n&&e.children?.length?d.jsx("div",{className:"space-y-4",children:t?.(e.children)}):null]})}function JI({widget:e,renderChildren:t}){const r=e.config,n=Ko(r.columns??2),o=r.collapseEmptyColumns!==!1,i=WI(e.children??[],n,r.columnWidths,{collapseEmpty:o});return d.jsx("div",{className:V("grid w-full min-w-0 items-stretch",zI(r.gap),KI(r)),style:{gridTemplateColumns:i.gridTemplate,...YI(r.minHeightPercent)},"data-widget-id":e.id,children:i.columns.map((s,a)=>{const c=i.sourceIndices[a]??a;return d.jsx("div",{className:V("flex min-h-[inherit] min-w-0 flex-col space-y-4 overflow-hidden",qI(r,c)),children:t?.(s)},c)})})}function QI({widget:e,renderChildren:t}){const r=e.config,n=r.variant==="outline"?"border bg-background":r.variant==="elevated"?"border bg-background shadow-md":"border bg-card";return d.jsxs("div",{className:V("rounded-lg p-4",n),"data-widget-id":e.id,children:[(r.title||r.subtitle)&&d.jsxs("div",{className:"mb-4",children:[r.title&&d.jsx("h3",{className:"font-semibold",children:r.title}),r.subtitle&&d.jsx("p",{className:"text-sm text-muted-foreground",children:r.subtitle})]}),e.children?.length?d.jsx("div",{className:"space-y-4",children:t?.(e.children)}):null]})}function $b(e,t){if(e.variable){const r=t[e.variable];return r!=null?String(r):e.fallback??e.text??""}return e.text??""}function ZI({widget:e}){const t=e.config,{context:r}=Br(),n=$b(t,r),o=t.level??2,i=t.align==="center"?"text-center":t.align==="right"?"text-right":"text-left",s=o===1?"text-3xl":o===2?"text-2xl":o===3?"text-xl":"text-lg";return d.jsx("div",{role:"heading","aria-level":o,className:V("font-semibold tracking-tight",s,i),"data-widget-id":e.id,children:n})}function eO({widget:e}){const t=e.config,{context:r}=Br(),n=$b(t,r),o=t.preset==="caption"?"text-sm text-muted-foreground":t.preset==="small"?"text-xs text-muted-foreground":"text-base",i=t.align==="center"?"text-center":t.align==="right"?"text-right":"text-left";return d.jsx("p",{className:V(o,i),"data-widget-id":e.id,children:n})}function tO(e,t){return!e||typeof e!="string"?e:e.replace(/\{\{([^}]+)\}\}/g,(r,n)=>{const o=n.trim(),i=t[o];return i==null?"":String(i)})}function Nd(e,t){const r={...e};for(const[n,o]of Object.entries(r))typeof o=="string"&&(r[n]=tO(o,t));return r}function rO(e,t){return e.replace(/\{\{([^}]+)\}\}/g,(r,n)=>{const o=t[n.trim()];return o!=null?String(o):""})}function jb(e,t,r,n){if(e.type==="navigate"){const o=rO(e.href,t);if(!o.trim())return;e.openIn==="new"?window.open(o,"_blank","noopener,noreferrer"):window.location.assign(o);return}if(e.type==="navigate_page"&&e.pageId){r({...e,params:e.params?Nd(e.params,t):void 0},n,"click");return}if(e.type==="workflow"&&e.workflowId){r(e,n,"click");return}r(e,n,"click")}function nO({widget:e}){const t=e.config,{context:r,dispatchAction:n}=Br();return d.jsx(Qt,{variant:t.variant??"default",size:t.size??"default","data-widget-id":e.id,onClick:()=>jb(t.action,r,n,e.id),children:t.label})}const oO={start:"justify-start",center:"justify-center",end:"justify-end","space-between":"justify-between"},iO={sm:"gap-2",md:"gap-3",lg:"gap-4"};function sO({widget:e}){const t=e.config,{context:r,dispatchAction:n}=Br(),o=t.buttons??[];return d.jsx("div",{className:V("flex flex-wrap items-center",oO[t.align??"start"],iO[t.gap??"sm"],t.wrap===!1&&"flex-nowrap"),"data-widget-id":e.id,children:o.map(i=>d.jsx(Qt,{variant:i.variant??"outline",size:i.size??"default","data-widget-id":e.id,"data-button-id":i.id,onClick:()=>jb(i.action,r,n,e.id),children:i.label},i.id))})}function aO(e){const t=e.prepopulateApi;return!!(t?.enabled&&t.api?.path)}function lO(e,t){return e&&(t==="idle"||t==="loading")}function cO(e,t){return!e||t==="ready"||t==="error"}function dO(e,t){const r=We(e,t??"");return r===void 0?null:r}function Hb(e,t){if(e.mode==="pageApi"&&e.dataSourceRef)return t[e.dataSourceRef];if(e.mode==="api")return e.api}function Ub({widgetId:e,dataSource:t,enabled:r=!0,page:n,pageSize:o,search:i}){const{schema:s,context:a,clientId:c,getFilterGroup:u,prepopulateStatus:f}=Br(),l=w.useMemo(()=>t.filterGroupKey?u(t.filterGroupKey):{},[t.filterGroupKey,u]),p=t.mode==="context"&&aO(s),g=lO(p,f),m=r&&(t.mode==="static"||(t.mode==="context"?cO(p,f):!!c)),h=w.useMemo(()=>["page-ds",e,t,a,l,n,o,i,f],[e,t,a,l,n,o,i,f]),y=mn.useQuery({queryKey:h,enabled:m,staleTime:Hb(t,s.dataApis??{})?.staleTimeMs??3e4,queryFn:async()=>{if(t.mode==="static")return t.staticData;if(t.mode==="context")return dO(a,t.contextPath);const S=Hb(t,s.dataApis??{});if(!S)throw new Error(`No API config for data source on widget ${e}`);const v={...a};if(t.requestBindings)for(const F of t.requestBindings){let k;F.source==="binding"?k=a[F.key]:F.source==="filter"&&(k=l[F.key]),k!==void 0&&(v[F.param]=k)}const x={...Nd(v,a),...n!==void 0?{page:n,pageSize:o,search:i}:{}};return Cd({clientId:c,api:S,context:x,filterState:l})}});return{...y,isLoading:y.isLoading||g,isPending:y.isPending||g,isFetching:y.isFetching||g}}function _d(e,t){if(e==null)return"";if(!t||t.type==="none")return String(e);switch(t.type){case"number":{const r=Number(e);return Number.isNaN(r)?String(e):r.toFixed(t.decimals??0)}case"currency":{const r=Number(e);return Number.isNaN(r)?String(e):new Intl.NumberFormat(void 0,{style:"currency",currency:t.currency??"USD"}).format(r)}case"percent":{const r=Number(e);return Number.isNaN(r)?String(e):`${r.toFixed(t.decimals??0)}%`}case"date":{const r=new Date(String(e));return Number.isNaN(r.getTime())?String(e):r.toLocaleDateString(void 0,{...t.format?{}:{}})}case"template":return t.template.replace(/\{\{value\}\}/g,String(e));default:return String(e)}}function zi(e,t){const r=We(e,t.path);return r==null?t.fallback??r:t.formatter?_d(r,t.formatter):r}function uO(e,t){if(!t)return{};const r={};for(const[n,o]of Object.entries(t))o in e&&(r[n]=e[o]);return r}const fO={default:"border bg-card",success:"border border-green-200 bg-green-50 text-green-900",warning:"border border-amber-200 bg-amber-50 text-amber-900",danger:"border border-red-200 bg-red-50 text-red-900"},pO={rectangle:"rounded-lg",square:"aspect-square rounded-lg",circle:"aspect-square rounded-full"},mO={sm:"p-2 text-xs",md:"p-4 text-sm",lg:"p-6 text-base"},Td={sm:"text-lg",md:"text-2xl",lg:"text-3xl"},hO={sm:"gap-2",md:"gap-3",lg:"gap-4"};function gO({title:e,value:t,trend:r,variant:n="default",shape:o="rectangle",size:i="md",layout:s="vertical",isLoading:a,isError:c}){const u=s==="horizontal";return d.jsxs("div",{className:V(fO[n??"default"],pO[o??"rectangle"],mO[i??"md"],u&&"flex items-center justify-between gap-3"),children:[d.jsxs("div",{className:V(u&&"min-w-0"),children:[e&&d.jsx("p",{className:V("font-medium text-muted-foreground",u?"text-sm":""),children:e}),r!=null&&r!==""&&!u&&d.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:String(r)})]}),a?d.jsx(un,{className:"my-2"}):c?d.jsx("p",{className:V("font-bold text-destructive",Td[i??"md"]),children:"Error"}):d.jsx("p",{className:V("font-bold",u?Td[i??"md"]:`mt-1 ${Td[i??"md"]}`),children:String(t)}),u&&r!==null&&r!==void 0&&r!==""&&d.jsx("p",{className:"text-xs text-muted-foreground",children:String(r)})]})}function zb({stat:e,widgetId:t}){const{data:r,isLoading:n,isError:o}=Ub({widgetId:t,dataSource:e.dataSource}),s=(()=>{if(n)return"";if(r==null)return e.valueMapping.fallback??"—";if(e.dataSource.mode==="context"){const c=r;return e.valueMapping.formatter?_d(c,e.valueMapping.formatter):c}if(e.dataSource.mode==="static"){const c=e.valueMapping.path?.trim()||"value",u=zi(r,{...e.valueMapping,path:c});if(u!=null)return e.valueMapping.formatter?_d(u,e.valueMapping.formatter):u;if(typeof r=="object"&&r!==null&&!Array.isArray(r)){const f=r;if(f.value!==void 0&&f.value!==null)return f.value}return e.valueMapping.fallback??"—"}return zi(r,e.valueMapping)})(),a=e.trendMapping&&r!==void 0&&e.dataSource.mode!=="context"?zi(r,e.trendMapping):e.trendMapping&&e.dataSource.mode==="context"&&e.trendMapping.path?zi({value:r},e.trendMapping):null;return d.jsx(gO,{title:e.title,value:s,trend:a,variant:e.variant,shape:e.shape,size:e.size,layout:e.layout,isLoading:n,isError:o})}function yO({widget:e}){const t=e.config;return d.jsx("div",{"data-widget-id":e.id,children:d.jsx(zb,{stat:t,widgetId:e.id})})}function bO({stat:e,widgetId:t}){return d.jsx(zb,{stat:e,widgetId:`${t}-${e.id}`})}function vO({widget:e}){const t=e.config,r=t.stats??[],n=t.columns??1,o=t.direction==="horizontal";return d.jsx("div",{"data-widget-id":e.id,className:V(o?"flex flex-wrap":"grid",!o&&n===1&&"grid-cols-1",!o&&n===2&&"grid-cols-2",!o&&n===3&&"grid-cols-3",!o&&n===4&&"grid-cols-4",hO[t.gap??"md"]),children:r.map(i=>d.jsx(bO,{stat:i,widgetId:e.id},i.id))})}function wO({widget:e}){const t=e.config,{setFilterValue:r}=Br(),[n,o]=w.useState("");return w.useEffect(()=>{const i=t.debounceMs??300,s=setTimeout(()=>{r(t.filterGroupKey,"search",n)},i);return()=>clearTimeout(s)},[n,t.debounceMs,t.filterGroupKey,r]),d.jsx("input",{type:"search",className:"flex h-9 w-full max-w-sm rounded-md border border-input bg-background px-3 py-1 text-sm shadow-xs",placeholder:t.placeholder??"Search…",value:n,onChange:i=>o(i.target.value),"data-widget-id":e.id})}function SO(e,t){if(!e)return[];const r=t?We(e,t):e;if(Array.isArray(r))return r;if(typeof r=="object"&&r!==null){const n=r;if(Array.isArray(n.items))return n.items;if(Array.isArray(n.data))return n.data}return[]}function xO({widget:e}){const t=e.config,{dispatchAction:r}=Br(),[n,o]=w.useState(1),[i,s]=w.useState(""),a=t.pagination?.pageSize??10,{data:c,isLoading:u,isError:f}=Ub({widgetId:e.id,dataSource:t.dataSource,page:n,pageSize:a,search:t.search?.enabled?i:void 0}),l=t.dataSource.mode==="pageApi"?void 0:t.dataSource.api?.itemsPath,p=SO(c,l??"data.items"),g=(m,h)=>{const y=t.dataSource.responseMapping.find(S=>S.target===h);return y?zi(m,y):We(m,h)??""};return d.jsxs("div",{className:"space-y-3","data-widget-id":e.id,children:[t.search?.enabled&&d.jsx("input",{type:"search",className:"flex h-9 w-full max-w-sm rounded-md border border-input bg-background px-3 py-1 text-sm",placeholder:t.search.placeholder??"Search…",value:i,onChange:m=>{s(m.target.value),o(1)}}),d.jsx("div",{className:"overflow-x-auto rounded-md border",children:d.jsxs("table",{className:"w-full text-sm",children:[d.jsx("thead",{children:d.jsx("tr",{className:"border-b bg-muted/50",children:t.columns.map(m=>d.jsx("th",{className:V("px-3 py-2 text-left font-medium",m.align==="center"&&"text-center",m.align==="right"&&"text-right"),style:m.width?{width:m.width}:void 0,children:m.header},m.id))})}),d.jsx("tbody",{children:u?d.jsx("tr",{children:d.jsx("td",{colSpan:t.columns.length,className:"px-3 py-8 text-center",children:d.jsx(un,{})})}):f?d.jsx("tr",{children:d.jsx("td",{colSpan:t.columns.length,className:"px-3 py-8 text-center text-destructive",children:"Failed to load data"})}):p.length===0?d.jsx("tr",{children:d.jsx("td",{colSpan:t.columns.length,className:"px-3 py-8 text-center text-muted-foreground",children:t.emptyMessage??"No data"})}):p.map((m,h)=>d.jsx("tr",{className:"cursor-pointer border-b hover:bg-muted/30",onClick:()=>{r({type:"emit",eventName:"row_click",payload:{row:m}},e.id,"row_click")},children:t.columns.map(y=>d.jsx("td",{className:V("px-3 py-2",y.align==="center"&&"text-center",y.align==="right"&&"text-right"),children:String(g(m,y.field))},y.id))},h))})]})}),t.pagination?.enabled&&d.jsxs("div",{className:"flex items-center justify-between text-sm",children:[d.jsxs("span",{className:"text-muted-foreground",children:["Page ",n]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{type:"button",className:"rounded border px-2 py-1 disabled:opacity-50",disabled:n<=1,onClick:()=>o(m=>Math.max(1,m-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"rounded border px-2 py-1",disabled:p.length<a,onClick:()=>o(m=>m+1),children:"Next"})]})]})]})}const AO=75;function CO(e){return e??AO}function EO(e){return e?"rounded-md border border-border p-3":""}function Fd({scrollBehavior:e="page",maxHeightPercent:t,children:r,className:n}){if(e!=="contained")return n?d.jsx("div",{className:n,children:r}):d.jsx(d.Fragment,{children:r});const o=CO(t);return d.jsx("div",{className:V("min-w-0 overflow-y-auto overflow-x-hidden",n),style:{maxHeight:`${o}vh`},"data-form-embed-scroll":"contained",children:r})}const Pd="/api/bff/workflows";function kO(e){const t=e.moduleId??e.module_id;return t!=null?String(t).trim():""}function Vb(e){const t=Yf(),r=e.userId??e.user_id??t?.userId;return r!=null&&String(r).trim()!==""?String(r):void 0}function NO(e){const t=String(e.clientId??nn()??""),r=Vb(e);return()=>Na({getAuthHeaders:()=>mi()??{},clientId:t||void 0,userId:r})}function Id(e,t){const r=kO(e);if(!r)return null;const n=t?.bffWorkflowsBasePath??Pd,o=String(e.clientId??nn()??""),i=Vb(e),s=NO(e),a=t?.workflowModalHandlers??Ab({bffWorkflowsBasePath:n,moduleId:r,getAuthHeaders:s,clientId:o||void 0,userId:i});return{getWorkflowState:t?.getWorkflowState??(u=>Cb({bffWorkflowsBasePath:n,moduleId:u.moduleId,featureId:u.featureId,tenantId:u.tenantId,subjectUserId:u.subjectUserId,viewStepId:u.viewStepId,clientId:u.clientId??(o||void 0),getAuthHeaders:s})),workflowModalHandlers:a,getAuthHeaders:s,moduleId:r}}function _O(e,t,r){return["embedded-form",e,t,r??"latest"]}async function TO(e,t){try{const r=await qt.get(`/api/form-builder/form-layouts/form/${e}`,{params:{clientId:t}});let n=r.data?.data??r.data;for(;n&&typeof n=="object"&&!Array.isArray(n)&&n.data!=null&&typeof n.data=="object"&&!("rows"in n)&&!("columns"in n)&&!("formDefinitionId"in n);)n=n.data;return!n||typeof n!="object"||Array.isArray(n)||!("rows"in n)&&!("columns"in n)&&!("formDefinitionId"in n)?null:n}catch{return null}}async function FO(e,t,r){const n=r!==void 0?`/api/form-builder/forms/${e}/render?version=${r}`:`/api/form-builder/forms/${e}/render`,o=await qt.get(n,{params:{clientId:t}}),s=o.data?.data??o.data,a=s.form??s,c=s.fields??a.fields??[];let u=s.layout??a.layout??null;(!u||typeof u.columns!="number")&&(u=await TO(e,t));const f=s.rules??a.rules??[],l=Di(a,c,u,f),p=Yi({config:l.config,layout:l.layout},qi(u))??qi(u);return{schema:l,gridLayout:p}}const PO=300*1e3;function Wb({formId:e,mode:t="fill",contextFieldMapping:r,pageContext:n,clientId:o,formVersion:i,scrollBehavior:s,maxHeightPercent:a,showBorder:c}){const u=DI(),{data:f,isLoading:l,isError:p,error:g}=mn.useQuery({queryKey:_O(e,o,i),queryFn:()=>FO(e,o,i),staleTime:PO}),m=w.useMemo(()=>uO(n,r),[n,r]),h=EO(c),y=typeof f?.schema?.moduleId=="string"?f.schema.moduleId.trim():"",S=u?.context.moduleId!=null?String(u.context.moduleId).trim():"",v=y||S||void 0,A=w.useMemo(()=>u?.workflowModalHandlers||!v?null:Id({...n,clientId:o||n.clientId,moduleId:v}),[u?.workflowModalHandlers,v,n,o]),x=u?.workflowModalHandlers??A?.workflowModalHandlers,F=u?.getAuthHeaders??A?.getAuthHeaders;return l?d.jsx(Fd,{scrollBehavior:s,maxHeightPercent:a,className:h,children:d.jsx(un,{})}):p?d.jsx(Fd,{scrollBehavior:s,maxHeightPercent:a,className:h,children:d.jsx("p",{className:"text-sm text-destructive",children:g instanceof Error?g.message:"Failed to load form"})}):f?.schema?d.jsx(Fd,{scrollBehavior:s,maxHeightPercent:a,className:h,children:d.jsx($i,{schema:f.schema,mode:t,gridLayout:f.gridLayout,initialValues:m,submissionContext:n,moduleId:v,workflowModalHandlers:x,getAuthHeaders:F})}):null}function IO({widget:e}){const t=e.config,{context:r,clientId:n}=Br();return t.formId?d.jsx(Wb,{formId:t.formId,mode:t.mode??"fill",contextFieldMapping:t.contextFieldMapping,pageContext:r,clientId:n,scrollBehavior:t.scrollBehavior,maxHeightPercent:t.maxHeightPercent,showBorder:t.showBorder}):d.jsx("p",{className:"text-sm text-muted-foreground",children:"No form configured"})}function OO({widget:e}){const t=e.config,{context:r,getWorkflowState:n,workflowModalHandlers:o,clientId:i}=Br(),s=String(r.moduleId??"");if(!n)return d.jsxs("div",{className:"rounded-md border border-dashed p-4 text-sm text-muted-foreground","data-widget-id":e.id,children:["Workflow embed requires ",d.jsx("code",{className:"text-xs",children:"getWorkflowState"})," on PageRenderer. Workflow ID: ",t.workflowId]});if(!s)return d.jsx("p",{className:"text-sm text-destructive","data-widget-id":e.id,children:"moduleId required in page context for workflow embed"});const a={};if(t.contextVariableMapping)for(const[c,u]of Object.entries(t.contextVariableMapping)){const f=r[u];f!=null&&(a[c]=String(f))}return d.jsx(xb,{getWorkflowState:n,workflowModalHandlers:o,moduleId:s,tenantId:r.tenantId?String(r.tenantId):void 0,clientId:i||void 0,submissionContext:a})}function MO({widget:e}){const t=e.config,{schema:r,dispatchAction:n}=Br(),o=t.previousPage??r.navigation?.previousPage,i=t.nextPage??r.navigation?.nextPage,s=t.showPrevious!==!1&&!!o,a=t.showNext!==!1&&!!i,c=t.showBreadcrumbs&&r.navigation?.breadcrumbs?.length,u=t.align==="center"?"justify-center":t.align==="right"?"justify-end":t.align==="space-between"?"justify-between":"justify-start",f=l=>{n({type:"navigate_page",pageId:l.pageId},e.id,"click")};return d.jsxs("nav",{className:"space-y-3","data-widget-id":e.id,children:[c&&d.jsx("ol",{className:"flex flex-wrap items-center gap-1 text-sm text-muted-foreground",children:r.navigation.breadcrumbs.map((l,p)=>d.jsxs("li",{className:"flex items-center gap-1",children:[p>0&&d.jsx("span",{children:"/"}),l.href?d.jsx("a",{href:l.href,className:"hover:underline",children:l.label}):d.jsx("span",{children:l.label})]},p))}),d.jsxs("div",{className:V("flex items-center gap-2",u),children:[s&&o&&d.jsx(Qt,{variant:"outline",size:"sm",onClick:()=>f(o),children:o.label??"Previous"}),a&&i&&d.jsx(Qt,{variant:"default",size:"sm",onClick:()=>f(i),children:i.label??"Next"})]})]})}function LO(e,t){return e?.length?e.filter(r=>r.config.tabId===t):[]}const DO=1;function BO(e){switch(e){case"pills":return"bg-transparent gap-1 p-0 h-auto";case"underline":return"bg-transparent rounded-none border-b p-0 h-auto w-full justify-start gap-4";default:return""}}function $O(e){switch(e){case"pills":return"rounded-full data-[state=active]:bg-primary data-[state=active]:text-primary-foreground";case"underline":return"rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:shadow-none bg-transparent";default:return""}}function jO(e,t,r){return e?new Set(r?[r]:[]):new Set(t.map(n=>n.id))}function HO({tab:e,shouldRender:t,pageContext:r,clientId:n}){return t?e.formId?d.jsx(Wb,{formId:e.formId,mode:e.formMode??"fill",contextFieldMapping:e.contextFieldMapping,pageContext:r,clientId:n,scrollBehavior:e.scrollBehavior,maxHeightPercent:e.maxHeightPercent,showBorder:e.showBorder}):d.jsx("p",{className:"text-sm text-muted-foreground",children:"No form configured for this tab"}):null}function UO({tab:e,shouldLoad:t,shouldRender:r,nestingDepth:n,pageContext:o,clientId:i,onAction:s,getWorkflowState:a}){const c=Br(),{data:u,isLoading:f,isError:l,error:p}=mn.useQuery({queryKey:["tab-page",e.pageId,e.pageVersion,i],enabled:t&&!!e.pageId,queryFn:async()=>Ui(e.pageId,i,e.pageVersion)});return r?n>=DO?d.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm text-destructive",children:"Nested page tabs not supported"}):e.pageId?f?d.jsx(un,{}):l?d.jsx("p",{className:"text-sm text-destructive",children:p instanceof Error?p.message:"Failed to load page"}):u?d.jsx(Ta,{page:u,context:o,nestingDepth:n+1,inheritContext:!0,onAction:s,getWorkflowState:a,parentContext:c}):null:d.jsx("p",{className:"text-sm text-muted-foreground",children:"No page configured for this tab"}):null}function zO({tab:e,widgetChildren:t,renderChildren:r}){const n=LO(t,e.id);return n.length===0?d.jsx("p",{className:"text-sm text-muted-foreground py-4",children:"No widgets in this tab"}):d.jsx(d.Fragment,{children:r?.(n)})}function VO({widget:e,renderChildren:t}){const r=e.config,{context:n,clientId:o,nestingDepth:i,onAction:s,getWorkflowState:a}=Br(),c=r.tabs??[],u=r.defaultTabId??c[0]?.id??"",f=r.lazyLoad!==!1,[l,p]=w.useState(u),[g,m]=w.useState(()=>jO(f,c,u)),h=S=>{m(v=>new Set(v).add(S)),p(S)},y=w.useMemo(()=>!f,[f]);return c.length===0?d.jsx("p",{className:"text-sm text-muted-foreground","data-widget-id":e.id,children:"No tabs configured"}):d.jsxs(vb,{value:l,onValueChange:h,className:"w-full","data-widget-id":e.id,children:[d.jsx(vd,{className:V("mb-4",BO(r.variant)),children:c.map(S=>d.jsx(wd,{value:S.id,disabled:S.disabled,className:$O(r.variant),children:S.label},S.id))}),c.map(S=>{const v=g.has(S.id),A=y||v,x=y||v;return d.jsxs(wb,{value:S.id,forceMount:y||void 0,className:V("mt-0",y&&"data-[state=inactive]:hidden"),children:[S.contentType==="widgets"&&x&&d.jsx(zO,{tab:S,widgetChildren:e.children??[],renderChildren:t}),S.contentType==="form"&&d.jsx(HO,{tab:S,shouldRender:A,pageContext:n,clientId:o}),S.contentType==="page"&&d.jsx(UO,{tab:S,shouldLoad:A,shouldRender:x,nestingDepth:i,pageContext:n,clientId:o,onAction:s,getWorkflowState:a})]},S.id)})]})}const WO={section:XI,columns:JI,card:QI,tab_group:VO,heading:ZI,text:eO,button:nO,button_group:sO,stat_card:yO,stat_grid:vO,data_table:xO,search_filter:wO,form_embed:IO,workflow_embed:OO,page_nav:MO};function RO({widget:e}){return d.jsxs("div",{className:"rounded-md border border-dashed border-muted-foreground/40 bg-muted/20 p-3 text-sm text-muted-foreground","data-widget-id":e.id,"data-widget-type":e.type,children:["Unsupported widget: ",d.jsx("code",{className:"text-xs",children:e.type}),e.label&&d.jsxs("span",{className:"ml-1",children:["(",e.label,")"]})]})}function KO({widget:e,renderChildren:t}){const r=WO[e.type]??RO;return d.jsx(r,{widget:e,renderChildren:t})}function Rb(e,t){return e.map(r=>d.jsx(KO,{widget:r,renderChildren:t},r.id))}function Ta({page:e,context:t={},onAction:r,chrome:n="none",className:o,nestingDepth:i=0,getWorkflowState:s,workflowModalHandlers:a,getAuthHeaders:c,inheritContext:u=!1,parentContext:f}){const l=w.useMemo(()=>FI(e.schema),[e.schema]),p=w.useMemo(()=>{const h=Id(t,{getWorkflowState:s,workflowModalHandlers:a});return{getWorkflowState:s??h?.getWorkflowState,workflowModalHandlers:a??h?.workflowModalHandlers,getAuthHeaders:c??h?.getAuthHeaders}},[t,s,a,c]),g=h=>Rb(h,g),m=d.jsxs("div",{className:V("studio-page-content min-h-0 min-w-0",NI(l),o),"data-page-id":e.id,"data-nesting-depth":i,children:[n==="minimal"&&l.meta?.title&&d.jsxs("header",{className:"mb-6 border-b pb-4",children:[d.jsx("h1",{className:"text-2xl font-semibold",children:l.meta.title}),l.meta.description&&d.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:l.meta.description})]}),d.jsx("div",{className:"space-y-6",children:Rb(l.widgets,g)})]});return u&&f?m:d.jsx(LI,{schema:l,context:t,clientId:String(t.clientId??""),nestingDepth:i,onAction:r,getWorkflowState:p.getWorkflowState,workflowModalHandlers:p.workflowModalHandlers,getAuthHeaders:p.getAuthHeaders,parentContext:f,children:m})}function GO({clientId:e,tenantId:t,moduleId:r,featureId:n,pageId:o,routePath:i,routeParams:s={},isDefault:a,context:c={},version:u,chrome:f="none",onAction:l,getWorkflowState:p,workflowModalHandlers:g,getAuthHeaders:m}){const h=w.useMemo(()=>({...s,...c,clientId:e,tenantId:t,moduleId:r,featureId:n}),[s,c,e,t,r,n]),{data:y,isLoading:S,isError:v,error:A}=mn.useQuery({queryKey:["page-resolve",e,t,r,n,o,i,a,u],queryFn:()=>Hi({clientId:e,tenantId:t,moduleId:r,featureId:n,routePath:i,isDefault:a,version:u}),enabled:!o}),x=o??y?.pageId,F=u??y?.version,k=y?.renderPayload,{data:N,isLoading:T,isError:P,error:E}=mn.useQuery({queryKey:["page-render",x,e,F,!!k],queryFn:()=>k??Ui(x,e,F),enabled:!!x&&(!!k||!S)});return!o&&S?d.jsx("div",{className:"flex items-center justify-center p-12",children:d.jsx(un,{})}):v?d.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm text-destructive",children:A instanceof Error?A.message:"Failed to resolve page"}):x?T?d.jsx("div",{className:"flex items-center justify-center p-12",children:d.jsx(un,{})}):P||!N?d.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm text-destructive",children:E instanceof Error?E.message:"Failed to load page"}):d.jsx(Ta,{page:N,context:h,chrome:f,nestingDepth:0,onAction:l,getWorkflowState:p,workflowModalHandlers:g,getAuthHeaders:m}):d.jsx("div",{className:"rounded-md border p-4 text-sm text-muted-foreground",children:"No page found for the given scope or route."})}function qO(e,t){return e.replace(/\{\{([^}]+)\}\}/g,(r,n)=>{const o=t[n.trim()];return o!=null?String(o):""})}function YO(e,t){if(!t)return e;let r=e;for(const[n,o]of Object.entries(t))r=r.replace(`:${n}`,encodeURIComponent(o)),r=r.replace(`{${n}}`,encodeURIComponent(o));return r}function Kb(e){const{clientId:t,tenantId:r,moduleId:n,featureId:o,onNavigate:i}=e;return async(s,a={})=>{if(s.type==="navigate_page"&&s.pageId){try{const c=await Hi({clientId:t,tenantId:r,moduleId:n,featureId:o,pageId:s.pageId}),f=(await Ui(c.pageId,t,c.version)).route?.path?.trim(),l=s.params?Nd(s.params,a):void 0;if(f){i(YO(f,l));return}}catch{}return}if(s.type==="navigate"&&s.href){const c=qO(s.href,a).trim();if(!c)return;if(s.openIn==="new"){window.open(c,"_blank","noopener,noreferrer");return}const u=c.split("?")[0]??c;if(u.startsWith("/")&&!u.startsWith("//")&&t)try{await Hi({clientId:t,tenantId:r,moduleId:n,featureId:o,routePath:u}),i(u);return}catch{}if(c.startsWith("http://")||c.startsWith("https://")||c.startsWith("/")){if(c.startsWith("/")&&i){i(c);return}window.location.assign(c)}}}}function Gb(e={}){const t={...e.context,...e.moduleId?{moduleId:e.moduleId}:{}},r=Id(t,{bffWorkflowsBasePath:e.bffWorkflowsBasePath??Pd});if(!r)return null;const n=e.getAuthHeaders??r.getAuthHeaders;return{getWorkflowState:r.getWorkflowState,workflowModalHandlers:r.workflowModalHandlers,getAuthHeaders:n}}function qb(e){const t=e.toLowerCase();return!!(t.includes("not found")||t.includes("no page found")||t.includes("page not found"))}function Yb(e){if(At.isAxiosError(e)){const t=e.response?.status;if(t===404||t===410)return!0;const r=e.response?.data,n=String(r?.message??r?.error??e.message??"");if(qb(n))return!0}return!!(e instanceof Error&&qb(e.message))}async function XO(e){try{const t=await Hi({clientId:e.clientId,tenantId:e.tenantId,moduleId:e.moduleId,featureId:e.featureId,routePath:e.routePath}),r=t.renderPayload??await Ui(t.pageId,e.clientId,t.version),n=e.moduleId;return{kind:"page",payload:r,moduleId:n}}catch(t){if(Yb(t))return{kind:"not_found"};throw t}}function JO({enabled:e=!0,routePath:t,routeParams:r={},clientId:n,tenantId:o,moduleId:i,featureId:s,context:a={},chrome:c="none",bffWorkflowsBasePath:u=Pd,getAuthHeaders:f,onNavigate:l,fallback:p}){const g=t.trim(),m=n.trim(),{data:h,isLoading:y,isError:S,error:v}=mn.useQuery({queryKey:["lc-nc-route",m,o,i,s,g,e],queryFn:()=>XO({clientId:m,tenantId:o,moduleId:i,featureId:s,routePath:g}),enabled:e&&!!m&&!!g,retry:!1,staleTime:3e4}),A=w.useMemo(()=>({...r,...a,clientId:m,...o?{tenantId:o}:{},...i?{moduleId:i}:{},...s?{featureId:s}:{}}),[r,a,m,o,i,s]),x=w.useMemo(()=>!h||h.kind!=="page"?null:Gb({bffWorkflowsBasePath:u,getAuthHeaders:f,moduleId:h.moduleId??i,context:A}),[h,u,f,i,A]),F=w.useCallback(k=>{Kb({clientId:m,tenantId:o,moduleId:i,featureId:s,onNavigate:l})(k,A)},[m,o,i,s,l,A]);return!e||!m||!g?d.jsx(d.Fragment,{children:p}):y?d.jsx("div",{className:"flex items-center justify-center p-12",children:d.jsx(un,{})}):S?d.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm text-destructive",children:v instanceof Error?v.message:"Failed to load page"}):!h||h.kind==="not_found"?d.jsx(d.Fragment,{children:p}):d.jsx(Ta,{page:h.payload,context:A,chrome:c,nestingDepth:0,onAction:F,getWorkflowState:x?.getWorkflowState,workflowModalHandlers:x?.workflowModalHandlers,getAuthHeaders:x?.getAuthHeaders??f})}function QO(e){const t=(e??"").trim().replace(/\/+$/,"");return t?t.startsWith("/")&&typeof window<"u"?`${window.location.origin}${t}`:t:""}function ZO(e={}){const t=QO(e.formWorkflowBuilderOrigin?.());if(t&&(qt.defaults.baseURL=t,Ro.defaults.baseURL=t),e.businessApiOrigin&&Kf(e.businessApiOrigin),e.getAuthHeaders){const r=()=>e.getAuthHeaders?.();Qf(r),Ib(r)}}const eM={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};function tM(e=eM){return(e.VITE_LC_NC??"").trim().toUpperCase()==="ON"}const rM={};function Xb(e){return(e?.()??rM?.VITE_FORM_WORKFLOW_BUILDER_URL?.trim()??"").replace(/\/+$/,"")}function nM(e,t){const r=typeof e=="string"?e.trim():"",n=t??Xb();if(!n||!r||/^https?:\/\//i.test(r))return e;try{const o=n.endsWith("/")?n:`${n}/`;return new URL(r,o).href}catch{return e}}function oM(e){const t=typeof e=="string"?e.trim():"";if(!t)return e;let r=t;for(;r.includes("/workflow-backend/workflow-backend");)r=r.replace(/\/workflow-backend\/workflow-backend/g,"/workflow-backend");return r}ae.FIELD_TYPE_REGISTRY=AI,ae.FORM_RENDERER_GRID_ROW_HEIGHT_DEFAULT=Wn,ae.FORM_RENDERER_ROOT_CLASS=Wa,ae.FieldRenderer=xn,ae.FormRenderer=$i,ae.LcNcRouteOutlet=JO,ae.PageRenderer=Ta,ae.RendererFieldLayoutContext=tl,ae.RendererStoreProvider=fl,ae.STEPS_NAV_RUNTIME_DEFAULTS=ji,ae.StudioPageHost=GO,ae.WorkflowFormModal=$g,ae.WorkflowModalProvider=Ug,ae.WorkflowStepsView=xb,ae.appearanceControlClasses=fo,ae.appearanceHasExplicitVerticalIntent=bu,ae.appearanceTextareaClasses=cu,ae.backendToFormSchema=Di,ae.bootstrapRendererHost=ZO,ae.buildBffWorkflowAuthHeaders=Na,ae.cellAlignmentClasses=cw,ae.cellVerticalJustifyClassesForField=lw,ae.clearWorkflowStandaloneCache=bI,ae.createBffWorkflowModalHandlers=Ab,ae.createHostPageNavigateHandler=Kb,ae.createHostWorkflowHandlers=Gb,ae.dedupeWorkflowBackendPathInUrl=oM,ae.effectiveWidthPercent=Zi,ae.executeDataSource=Cd,ae.fetchBffWorkflowState=Cb,ae.fetchPageRender=Ui,ae.fetchWorkflowStandaloneFlag=ka,ae.fieldBlockBoxStyle=aw,ae.fieldBlockBoxStyleForField=gu,ae.fieldBlockHorizontalPlacementClass=fu,ae.fieldBlockHorizontalSelfClass=pu,ae.fieldBlockHorizontalSelfClassForField=yu,ae.fieldBlockWidthStyle=Ya,ae.fieldBlockWidthStyleForField=hu,ae.fieldGridShellFillsCellVertically=ts,ae.formBuilderHttp=qt,ae.formLayoutRecordToGridConfig=qi,ae.getBusinessApiOrigin=Gf,ae.getClientId=nn,ae.getFormWorkflowBuilderBaseUrl=Xb,ae.getRendererHostAuthHeaders=mi,ae.getRendererHostViewerContext=Yf,ae.getRendererStore=Hw,ae.gridCellFlexClasses=uu,ae.gridCellFlexClassesForField=el,ae.gridCellOuterFlexClasses=du,ae.hasExplicitFieldBlockWidth=mu,ae.isAsyncSearchFieldProperties=vI,ae.isIntrinsicWidthButtonField=po,ae.isLcNcEnabled=tM,ae.isPageNotFoundError=Yb,ae.normalizeWorkflowFormSchema=__,ae.normalizeWorkflowFormToRendererSchema=ha,ae.pageBuilderHttp=Ro,ae.parseContentVerticalAlign=Ja,ae.parseMetadataJson=Ti,ae.resetRendererHostAuth=tx,ae.resolveBffSubmitApiUrlIfNeeded=nM,ae.resolveBusinessApiUrl=Mr,ae.resolveFormGridLayout=Yi,ae.resolvePage=Hi,ae.resolveWorkflowStepsNavigationConfig=xd,ae.resolveWorkflowStepsNavigationPosition=lI,ae.resolvedGridCellVerticalJustifyClasses=ei,ae.resolvedHorizontalAlign=Fr,ae.resolvedVerticalAlign=Zo,ae.resolvedVerticalAlignForField=Za,ae.setBusinessApiOrigin=Kf,ae.setFormBuilderAuthProvider=Qf,ae.setPageBuilderAuthProvider=Ib,ae.setRendererHostAuthHeaders=ex,ae.setRendererHostViewerContext=Z0,ae.useFieldValidation=SI,ae.useFormRenderer=Mu,ae.useFormValidation=wI,ae.useRendererFieldLayout=ti,ae.useRendererHostAuthStore=Zn,ae.useWorkflowModal=Hg,Object.defineProperty(ae,Symbol.toStringTag,{value:"Module"})}));
|