iq-line-form-builder-renderer 1.2.13 → 1.2.14
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 +6585 -6376
- package/dist/form-renderer.umd.js +19 -19
- package/dist/pages/systemAdmin/modules/formbuilder/components/fields/BillingGridField.d.ts +3 -1
- package/dist/pages/systemAdmin/modules/formbuilder/components/fields/BillingGridField.d.ts.map +1 -1
- package/dist/pages/systemAdmin/modules/formbuilder/components/renderer/FieldRenderer.d.ts.map +1 -1
- package/dist/pages/systemAdmin/modules/formbuilder/components/renderer/FormRenderer.d.ts.map +1 -1
- package/dist/pages/systemAdmin/modules/formbuilder/hooks/useBillingGridApi.d.ts +20 -0
- package/dist/pages/systemAdmin/modules/formbuilder/hooks/useBillingGridApi.d.ts.map +1 -0
- package/dist/pages/systemAdmin/modules/formbuilder/types/field.d.ts +34 -0
- package/dist/pages/systemAdmin/modules/formbuilder/types/field.d.ts.map +1 -1
- package/dist/pages/systemAdmin/modules/formbuilder/utils/billingGridApiUtils.d.ts +25 -0
- package/dist/pages/systemAdmin/modules/formbuilder/utils/billingGridApiUtils.d.ts.map +1 -0
- package/dist/pages/systemAdmin/modules/formbuilder/utils/billingGridCalc.d.ts +2 -1
- package/dist/pages/systemAdmin/modules/formbuilder/utils/billingGridCalc.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
(function(be,S){typeof exports=="object"&&typeof module<"u"?S(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"],S):(be=typeof globalThis<"u"?globalThis:be||self,S(be.FormBuilderRenderer={},be.React,be.jsxRuntime,be.ReactRouterDOM,be.ReactDOM,be.Sonner,be.ReactQuery))})(this,(function(be,S,c,wa,nd,Bt,vn){"use strict";function od(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=od(S),ki=od(nd),Sa="iq-fbr",Dn="95px";function Ti(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:Dn}}function Fi(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 id(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=id(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function sd(){for(var e,t,r=0,n="",o=arguments.length;r<o;r++)(e=arguments[r])&&(t=id(e))&&(n&&(n+=" "),n+=t);return n}const Hy=(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},Wy=(e,t)=>({classGroupId:e,validator:t}),ad=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),Pi="-",ld=[],Ry="arbitrary..",Gy=e=>{const t=qy(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:s=>{if(s.startsWith("[")&&s.endsWith("]"))return Ky(s);const a=s.split(Pi),d=a[0]===""&&a.length>1?1:0;return cd(a,d,t)},getConflictingClassGroupIds:(s,a)=>{if(a){const d=n[s],u=r[s];return d?u?Hy(u,d):d:u||ld}return r[s]||ld}}},cd=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const o=e[t],i=r.nextPart.get(o);if(i){const u=cd(e,t+1,i);if(u)return u}const s=r.validators;if(s===null)return;const a=t===0?e.join(Pi):e.slice(t).join(Pi),d=s.length;for(let u=0;u<d;u++){const l=s[u];if(l.validator(a))return l.classGroupId}},Ky=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?Ry+n:void 0})(),qy=e=>{const{theme:t,classGroups:r}=e;return Yy(r,t)},Yy=(e,t)=>{const r=ad();for(const n in e){const o=e[n];xa(o,r,n,t)}return r},xa=(e,t,r,n)=>{const o=e.length;for(let i=0;i<o;i++){const s=e[i];Xy(s,t,r,n)}},Xy=(e,t,r,n)=>{if(typeof e=="string"){Jy(e,t,r);return}if(typeof e=="function"){Qy(e,t,r,n);return}Zy(e,t,r,n)},Jy=(e,t,r)=>{const n=e===""?t:dd(t,e);n.classGroupId=r},Qy=(e,t,r,n)=>{if(eb(e)){xa(e(n),t,r,n);return}t.validators===null&&(t.validators=[]),t.validators.push(Wy(r,e))},Zy=(e,t,r,n)=>{const o=Object.entries(e),i=o.length;for(let s=0;s<i;s++){const[a,d]=o[s];xa(d,dd(t,a),r,n)}},dd=(e,t)=>{let r=e;const n=t.split(Pi),o=n.length;for(let i=0;i<o;i++){const s=n[i];let a=r.nextPart.get(s);a||(a=ad(),r.nextPart.set(s,a)),r=a}return r},eb=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,tb=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)}}},Aa="!",ud=":",rb=[],fd=(e,t,r,n,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:n,isExternal:o}),nb=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=o=>{const i=[];let s=0,a=0,d=0,u;const l=o.length;for(let h=0;h<l;h++){const y=o[h];if(s===0&&a===0){if(y===ud){i.push(o.slice(d,h)),d=h+1;continue}if(y==="/"){u=h;continue}}y==="["?s++:y==="]"?s--:y==="("?a++:y===")"&&a--}const f=i.length===0?o:o.slice(d);let p=f,m=!1;f.endsWith(Aa)?(p=f.slice(0,-1),m=!0):f.startsWith(Aa)&&(p=f.slice(1),m=!0);const g=u&&u>d?u-d:void 0;return fd(i,m,p,g)};if(t){const o=t+ud,i=n;n=s=>s.startsWith(o)?i(s.slice(o.length)):fd(rb,!1,s,void 0,!0)}if(r){const o=n;n=i=>r({className:i,parseClassName:o})}return n},ob=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]==="[",d=t.has(s);a||d?(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}},ib=e=>({cache:tb(e.cacheSize),parseClassName:nb(e),sortModifiers:ob(e),...Gy(e)}),sb=/\s+/,ab=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:o,sortModifiers:i}=t,s=[],a=e.trim().split(sb);let d="";for(let u=a.length-1;u>=0;u-=1){const l=a[u],{isExternal:f,modifiers:p,hasImportantModifier:m,baseClassName:g,maybePostfixModifierPosition:h}=r(l);if(f){d=l+(d.length>0?" "+d:d);continue}let y=!!h,w=n(y?g.substring(0,h):g);if(!w){if(!y){d=l+(d.length>0?" "+d:d);continue}if(w=n(g),!w){d=l+(d.length>0?" "+d:d);continue}y=!1}const v=p.length===0?"":p.length===1?p[0]:i(p).join(":"),x=m?v+Aa:v,N=x+w;if(s.indexOf(N)>-1)continue;s.push(N);const P=o(w,y);for(let E=0;E<P.length;++E){const _=P[E];s.push(x+_)}d=l+(d.length>0?" "+d:d)}return d},lb=(...e)=>{let t=0,r,n,o="";for(;t<e.length;)(r=e[t++])&&(n=pd(r))&&(o&&(o+=" "),o+=n);return o},pd=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=pd(e[n]))&&(r&&(r+=" "),r+=t);return r},cb=(e,...t)=>{let r,n,o,i;const s=d=>{const u=t.reduce((l,f)=>f(l),e());return r=ib(u),n=r.cache.get,o=r.cache.set,i=a,a(d)},a=d=>{const u=n(d);if(u)return u;const l=ab(d,r);return o(d,l),l};return i=s,(...d)=>i(lb(...d))},db=[],Ht=e=>{const t=r=>r[e]||db;return t.isThemeGetter=!0,t},md=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,hd=/^\((?:(\w[\w-]*):)?(.+)\)$/i,ub=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,fb=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,pb=/\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$/,mb=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,hb=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,gb=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,wn=e=>ub.test(e),at=e=>!!e&&!Number.isNaN(Number(e)),Sn=e=>!!e&&Number.isInteger(Number(e)),Ca=e=>e.endsWith("%")&&at(e.slice(0,-1)),ln=e=>fb.test(e),gd=()=>!0,yb=e=>pb.test(e)&&!mb.test(e),Ea=()=>!1,bb=e=>hb.test(e),vb=e=>gb.test(e),wb=e=>!_e(e)&&!ke(e),Sb=e=>xn(e,xd,Ea),_e=e=>md.test(e),Bn=e=>xn(e,Ad,yb),yd=e=>xn(e,Tb,at),xb=e=>xn(e,Ed,gd),Ab=e=>xn(e,Cd,Ea),bd=e=>xn(e,wd,Ea),Cb=e=>xn(e,Sd,vb),Oi=e=>xn(e,Nd,bb),ke=e=>hd.test(e),Bo=e=>$n(e,Ad),Eb=e=>$n(e,Cd),vd=e=>$n(e,wd),Nb=e=>$n(e,xd),_b=e=>$n(e,Sd),Ii=e=>$n(e,Nd,!0),kb=e=>$n(e,Ed,!0),xn=(e,t,r)=>{const n=md.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},$n=(e,t,r=!1)=>{const n=hd.exec(e);return n?n[1]?t(n[1]):r:!1},wd=e=>e==="position"||e==="percentage",Sd=e=>e==="image"||e==="url",xd=e=>e==="length"||e==="size"||e==="bg-size",Ad=e=>e==="length",Tb=e=>e==="number",Cd=e=>e==="family-name",Ed=e=>e==="number"||e==="weight",Nd=e=>e==="shadow",Fb=cb(()=>{const e=Ht("color"),t=Ht("font"),r=Ht("text"),n=Ht("font-weight"),o=Ht("tracking"),i=Ht("leading"),s=Ht("breakpoint"),a=Ht("container"),d=Ht("spacing"),u=Ht("radius"),l=Ht("shadow"),f=Ht("inset-shadow"),p=Ht("text-shadow"),m=Ht("drop-shadow"),g=Ht("blur"),h=Ht("perspective"),y=Ht("aspect"),w=Ht("ease"),v=Ht("animate"),x=()=>["auto","avoid","all","avoid-page","page","left","right","column"],N=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],P=()=>[...N(),ke,_e],E=()=>["auto","hidden","clip","visible","scroll"],_=()=>["auto","contain","none"],C=()=>[ke,_e,d],A=()=>[wn,"full","auto",...C()],O=()=>[Sn,"none","subgrid",ke,_e],T=()=>["auto",{span:["full",Sn,ke,_e]},Sn,ke,_e],z=()=>[Sn,"auto",ke,_e],q=()=>["auto","min","max","fr",ke,_e],I=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],$=()=>["start","end","center","stretch","center-safe","end-safe"],M=()=>["auto",...C()],D=()=>[wn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...C()],L=()=>[wn,"screen","full","dvw","lvw","svw","min","max","fit",...C()],U=()=>[wn,"screen","full","lh","dvh","lvh","svh","min","max","fit",...C()],j=()=>[e,ke,_e],se=()=>[...N(),vd,bd,{position:[ke,_e]}],H=()=>["no-repeat",{repeat:["","x","y","space","round"]}],G=()=>["auto","cover","contain",Nb,Sb,{size:[ke,_e]}],ee=()=>[Ca,Bo,Bn],de=()=>["","none","full",u,ke,_e],ne=()=>["",at,Bo,Bn],K=()=>["solid","dashed","dotted","double"],re=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Te=()=>[at,Ca,vd,bd],Z=()=>["","none",g,ke,_e],te=()=>["none",at,ke,_e],he=()=>["none",at,ke,_e],le=()=>[at,ke,_e],Xe=()=>[wn,"full",...C()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ln],breakpoint:[ln],color:[gd],container:[ln],"drop-shadow":[ln],ease:["in","out","in-out"],font:[wb],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ln],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ln],shadow:[ln],spacing:["px",at],text:[ln],"text-shadow":[ln],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",wn,_e,ke,y]}],container:["container"],columns:[{columns:[at,_e,ke,a]}],"break-after":[{"break-after":x()}],"break-before":[{"break-before":x()}],"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:P()}],overflow:[{overflow:E()}],"overflow-x":[{"overflow-x":E()}],"overflow-y":[{"overflow-y":E()}],overscroll:[{overscroll:_()}],"overscroll-x":[{"overscroll-x":_()}],"overscroll-y":[{"overscroll-y":_()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:A()}],"inset-x":[{"inset-x":A()}],"inset-y":[{"inset-y":A()}],start:[{"inset-s":A(),start:A()}],end:[{"inset-e":A(),end:A()}],"inset-bs":[{"inset-bs":A()}],"inset-be":[{"inset-be":A()}],top:[{top:A()}],right:[{right:A()}],bottom:[{bottom:A()}],left:[{left:A()}],visibility:["visible","invisible","collapse"],z:[{z:[Sn,"auto",ke,_e]}],basis:[{basis:[wn,"full","auto",a,...C()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[at,wn,"auto","initial","none",_e]}],grow:[{grow:["",at,ke,_e]}],shrink:[{shrink:["",at,ke,_e]}],order:[{order:[Sn,"first","last","none",ke,_e]}],"grid-cols":[{"grid-cols":O()}],"col-start-end":[{col:T()}],"col-start":[{"col-start":z()}],"col-end":[{"col-end":z()}],"grid-rows":[{"grid-rows":O()}],"row-start-end":[{row:T()}],"row-start":[{"row-start":z()}],"row-end":[{"row-end":z()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":q()}],"auto-rows":[{"auto-rows":q()}],gap:[{gap:C()}],"gap-x":[{"gap-x":C()}],"gap-y":[{"gap-y":C()}],"justify-content":[{justify:[...I(),"normal"]}],"justify-items":[{"justify-items":[...$(),"normal"]}],"justify-self":[{"justify-self":["auto",...$()]}],"align-content":[{content:["normal",...I()]}],"align-items":[{items:[...$(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...$(),{baseline:["","last"]}]}],"place-content":[{"place-content":I()}],"place-items":[{"place-items":[...$(),"baseline"]}],"place-self":[{"place-self":["auto",...$()]}],p:[{p:C()}],px:[{px:C()}],py:[{py:C()}],ps:[{ps:C()}],pe:[{pe:C()}],pbs:[{pbs:C()}],pbe:[{pbe:C()}],pt:[{pt:C()}],pr:[{pr:C()}],pb:[{pb:C()}],pl:[{pl:C()}],m:[{m:M()}],mx:[{mx:M()}],my:[{my:M()}],ms:[{ms:M()}],me:[{me:M()}],mbs:[{mbs:M()}],mbe:[{mbe:M()}],mt:[{mt:M()}],mr:[{mr:M()}],mb:[{mb:M()}],ml:[{ml:M()}],"space-x":[{"space-x":C()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":C()}],"space-y-reverse":["space-y-reverse"],size:[{size:D()}],"inline-size":[{inline:["auto",...L()]}],"min-inline-size":[{"min-inline":["auto",...L()]}],"max-inline-size":[{"max-inline":["none",...L()]}],"block-size":[{block:["auto",...U()]}],"min-block-size":[{"min-block":["auto",...U()]}],"max-block-size":[{"max-block":["none",...U()]}],w:[{w:[a,"screen",...D()]}],"min-w":[{"min-w":[a,"screen","none",...D()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[s]},...D()]}],h:[{h:["screen","lh",...D()]}],"min-h":[{"min-h":["screen","lh","none",...D()]}],"max-h":[{"max-h":["screen","lh",...D()]}],"font-size":[{text:["base",r,Bo,Bn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,kb,xb]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ca,_e]}],"font-family":[{font:[Eb,Ab,t]}],"font-features":[{"font-features":[_e]}],"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,ke,_e]}],"line-clamp":[{"line-clamp":[at,"none",ke,yd]}],leading:[{leading:[i,...C()]}],"list-image":[{"list-image":["none",ke,_e]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ke,_e]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:j()}],"text-color":[{text:j()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...K(),"wavy"]}],"text-decoration-thickness":[{decoration:[at,"from-font","auto",ke,Bn]}],"text-decoration-color":[{decoration:j()}],"underline-offset":[{"underline-offset":[at,"auto",ke,_e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:C()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ke,_e]}],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",ke,_e]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:se()}],"bg-repeat":[{bg:H()}],"bg-size":[{bg:G()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Sn,ke,_e],radial:["",ke,_e],conic:[Sn,ke,_e]},_b,Cb]}],"bg-color":[{bg:j()}],"gradient-from-pos":[{from:ee()}],"gradient-via-pos":[{via:ee()}],"gradient-to-pos":[{to:ee()}],"gradient-from":[{from:j()}],"gradient-via":[{via:j()}],"gradient-to":[{to:j()}],rounded:[{rounded:de()}],"rounded-s":[{"rounded-s":de()}],"rounded-e":[{"rounded-e":de()}],"rounded-t":[{"rounded-t":de()}],"rounded-r":[{"rounded-r":de()}],"rounded-b":[{"rounded-b":de()}],"rounded-l":[{"rounded-l":de()}],"rounded-ss":[{"rounded-ss":de()}],"rounded-se":[{"rounded-se":de()}],"rounded-ee":[{"rounded-ee":de()}],"rounded-es":[{"rounded-es":de()}],"rounded-tl":[{"rounded-tl":de()}],"rounded-tr":[{"rounded-tr":de()}],"rounded-br":[{"rounded-br":de()}],"rounded-bl":[{"rounded-bl":de()}],"border-w":[{border:ne()}],"border-w-x":[{"border-x":ne()}],"border-w-y":[{"border-y":ne()}],"border-w-s":[{"border-s":ne()}],"border-w-e":[{"border-e":ne()}],"border-w-bs":[{"border-bs":ne()}],"border-w-be":[{"border-be":ne()}],"border-w-t":[{"border-t":ne()}],"border-w-r":[{"border-r":ne()}],"border-w-b":[{"border-b":ne()}],"border-w-l":[{"border-l":ne()}],"divide-x":[{"divide-x":ne()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ne()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...K(),"hidden","none"]}],"divide-style":[{divide:[...K(),"hidden","none"]}],"border-color":[{border:j()}],"border-color-x":[{"border-x":j()}],"border-color-y":[{"border-y":j()}],"border-color-s":[{"border-s":j()}],"border-color-e":[{"border-e":j()}],"border-color-bs":[{"border-bs":j()}],"border-color-be":[{"border-be":j()}],"border-color-t":[{"border-t":j()}],"border-color-r":[{"border-r":j()}],"border-color-b":[{"border-b":j()}],"border-color-l":[{"border-l":j()}],"divide-color":[{divide:j()}],"outline-style":[{outline:[...K(),"none","hidden"]}],"outline-offset":[{"outline-offset":[at,ke,_e]}],"outline-w":[{outline:["",at,Bo,Bn]}],"outline-color":[{outline:j()}],shadow:[{shadow:["","none",l,Ii,Oi]}],"shadow-color":[{shadow:j()}],"inset-shadow":[{"inset-shadow":["none",f,Ii,Oi]}],"inset-shadow-color":[{"inset-shadow":j()}],"ring-w":[{ring:ne()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:j()}],"ring-offset-w":[{"ring-offset":[at,Bn]}],"ring-offset-color":[{"ring-offset":j()}],"inset-ring-w":[{"inset-ring":ne()}],"inset-ring-color":[{"inset-ring":j()}],"text-shadow":[{"text-shadow":["none",p,Ii,Oi]}],"text-shadow-color":[{"text-shadow":j()}],opacity:[{opacity:[at,ke,_e]}],"mix-blend":[{"mix-blend":[...re(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":re()}],"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":[at]}],"mask-image-linear-from-pos":[{"mask-linear-from":Te()}],"mask-image-linear-to-pos":[{"mask-linear-to":Te()}],"mask-image-linear-from-color":[{"mask-linear-from":j()}],"mask-image-linear-to-color":[{"mask-linear-to":j()}],"mask-image-t-from-pos":[{"mask-t-from":Te()}],"mask-image-t-to-pos":[{"mask-t-to":Te()}],"mask-image-t-from-color":[{"mask-t-from":j()}],"mask-image-t-to-color":[{"mask-t-to":j()}],"mask-image-r-from-pos":[{"mask-r-from":Te()}],"mask-image-r-to-pos":[{"mask-r-to":Te()}],"mask-image-r-from-color":[{"mask-r-from":j()}],"mask-image-r-to-color":[{"mask-r-to":j()}],"mask-image-b-from-pos":[{"mask-b-from":Te()}],"mask-image-b-to-pos":[{"mask-b-to":Te()}],"mask-image-b-from-color":[{"mask-b-from":j()}],"mask-image-b-to-color":[{"mask-b-to":j()}],"mask-image-l-from-pos":[{"mask-l-from":Te()}],"mask-image-l-to-pos":[{"mask-l-to":Te()}],"mask-image-l-from-color":[{"mask-l-from":j()}],"mask-image-l-to-color":[{"mask-l-to":j()}],"mask-image-x-from-pos":[{"mask-x-from":Te()}],"mask-image-x-to-pos":[{"mask-x-to":Te()}],"mask-image-x-from-color":[{"mask-x-from":j()}],"mask-image-x-to-color":[{"mask-x-to":j()}],"mask-image-y-from-pos":[{"mask-y-from":Te()}],"mask-image-y-to-pos":[{"mask-y-to":Te()}],"mask-image-y-from-color":[{"mask-y-from":j()}],"mask-image-y-to-color":[{"mask-y-to":j()}],"mask-image-radial":[{"mask-radial":[ke,_e]}],"mask-image-radial-from-pos":[{"mask-radial-from":Te()}],"mask-image-radial-to-pos":[{"mask-radial-to":Te()}],"mask-image-radial-from-color":[{"mask-radial-from":j()}],"mask-image-radial-to-color":[{"mask-radial-to":j()}],"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":N()}],"mask-image-conic-pos":[{"mask-conic":[at]}],"mask-image-conic-from-pos":[{"mask-conic-from":Te()}],"mask-image-conic-to-pos":[{"mask-conic-to":Te()}],"mask-image-conic-from-color":[{"mask-conic-from":j()}],"mask-image-conic-to-color":[{"mask-conic-to":j()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:se()}],"mask-repeat":[{mask:H()}],"mask-size":[{mask:G()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ke,_e]}],filter:[{filter:["","none",ke,_e]}],blur:[{blur:Z()}],brightness:[{brightness:[at,ke,_e]}],contrast:[{contrast:[at,ke,_e]}],"drop-shadow":[{"drop-shadow":["","none",m,Ii,Oi]}],"drop-shadow-color":[{"drop-shadow":j()}],grayscale:[{grayscale:["",at,ke,_e]}],"hue-rotate":[{"hue-rotate":[at,ke,_e]}],invert:[{invert:["",at,ke,_e]}],saturate:[{saturate:[at,ke,_e]}],sepia:[{sepia:["",at,ke,_e]}],"backdrop-filter":[{"backdrop-filter":["","none",ke,_e]}],"backdrop-blur":[{"backdrop-blur":Z()}],"backdrop-brightness":[{"backdrop-brightness":[at,ke,_e]}],"backdrop-contrast":[{"backdrop-contrast":[at,ke,_e]}],"backdrop-grayscale":[{"backdrop-grayscale":["",at,ke,_e]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[at,ke,_e]}],"backdrop-invert":[{"backdrop-invert":["",at,ke,_e]}],"backdrop-opacity":[{"backdrop-opacity":[at,ke,_e]}],"backdrop-saturate":[{"backdrop-saturate":[at,ke,_e]}],"backdrop-sepia":[{"backdrop-sepia":["",at,ke,_e]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":C()}],"border-spacing-x":[{"border-spacing-x":C()}],"border-spacing-y":[{"border-spacing-y":C()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",ke,_e]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[at,"initial",ke,_e]}],ease:[{ease:["linear","initial",w,ke,_e]}],delay:[{delay:[at,ke,_e]}],animate:[{animate:["none",v,ke,_e]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[h,ke,_e]}],"perspective-origin":[{"perspective-origin":P()}],rotate:[{rotate:te()}],"rotate-x":[{"rotate-x":te()}],"rotate-y":[{"rotate-y":te()}],"rotate-z":[{"rotate-z":te()}],scale:[{scale:he()}],"scale-x":[{"scale-x":he()}],"scale-y":[{"scale-y":he()}],"scale-z":[{"scale-z":he()}],"scale-3d":["scale-3d"],skew:[{skew:le()}],"skew-x":[{"skew-x":le()}],"skew-y":[{"skew-y":le()}],transform:[{transform:[ke,_e,"","none","gpu","cpu"]}],"transform-origin":[{origin:P()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Xe()}],"translate-x":[{"translate-x":Xe()}],"translate-y":[{"translate-y":Xe()}],"translate-z":[{"translate-z":Xe()}],"translate-none":["translate-none"],accent:[{accent:j()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:j()}],"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",ke,_e]}],"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":C()}],"scroll-mx":[{"scroll-mx":C()}],"scroll-my":[{"scroll-my":C()}],"scroll-ms":[{"scroll-ms":C()}],"scroll-me":[{"scroll-me":C()}],"scroll-mbs":[{"scroll-mbs":C()}],"scroll-mbe":[{"scroll-mbe":C()}],"scroll-mt":[{"scroll-mt":C()}],"scroll-mr":[{"scroll-mr":C()}],"scroll-mb":[{"scroll-mb":C()}],"scroll-ml":[{"scroll-ml":C()}],"scroll-p":[{"scroll-p":C()}],"scroll-px":[{"scroll-px":C()}],"scroll-py":[{"scroll-py":C()}],"scroll-ps":[{"scroll-ps":C()}],"scroll-pe":[{"scroll-pe":C()}],"scroll-pbs":[{"scroll-pbs":C()}],"scroll-pbe":[{"scroll-pbe":C()}],"scroll-pt":[{"scroll-pt":C()}],"scroll-pr":[{"scroll-pr":C()}],"scroll-pb":[{"scroll-pb":C()}],"scroll-pl":[{"scroll-pl":C()}],"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",ke,_e]}],fill:[{fill:["none",...j()]}],"stroke-w":[{stroke:[at,Bo,Bn,yd]}],stroke:[{stroke:["none",...j()]}],"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 B(...e){return Fb(sd(e))}const Pb=["richtext","multiselect","radio","checkboxgroup","signature"],Ob=3;function $o(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(Ob,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 Pb.includes(e.type)?Math.max(t,2):t}function _d(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 jo(e){const t=e?.size??"md",r=e?.variant??"default";return B(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 kd(e){const t=e?.size??"md",r=e?.variant??"default";return B(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 Ib(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 Mb(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 Lb(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 Mi(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 Na(e){const t=Mi(e);return{width:t>=100?"100%":`${t}%`,maxWidth:"100%"}}function Db(e){return Na(e)}function _a(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t==="start"||t==="center"||t==="end"||t==="stretch"?t:null}function ka(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t==="start"||t==="center"||t==="end"?t:null}function Tr(e){if(!e)return"start";const t=_a(e.horizontalAlign);if(t)return t;const r=_a(e.contentAlign);if(r)return r;const n=_a(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 Li(e){switch(e){case"center":return"items-center";case"end":return"items-end";case"stretch":return"items-stretch";default:return"items-start"}}function Ta(e){switch(e){case"center":return"justify-center";case"end":return"justify-end";case"stretch":return"justify-stretch";default:return"justify-start"}}function Uo(e){const t=ka(e.appearance?.contentVerticalAlign);if(t!==null)switch(t){case"center":return"justify-center";case"end":return"justify-end";default:return"justify-start"}return Ta(Fa(e))}const Bb=Uo;function Di(e){if(e.type==="billingGrid"||e.type==="table"||$o(e)>1)return!0;const t=ka(e.appearance?.contentVerticalAlign);if(t==="center"||t==="end")return!1;if(t==="start")return!0;const r=Fa(e);return r!=="center"&&r!=="end"}function Td(e){const t=e[0];if(!t)return Pa(void 0);if(e.length===1)return Pa(t);const r=Tr(t.appearance);return B("flex flex-col min-h-0 h-full w-full",Li(r),"justify-start")}function Fd(e){const t=Tr(e),r=zo(e);return B("flex flex-col min-h-0 h-full w-full",Li(t),Ta(r))}function Pd(e){if(Mi(e)>=100)return"";const r=Tr(e);return r==="center"?"mx-auto":r==="end"?"ml-auto":""}function Od(e){if(Mi(e)>=100)return"w-full";const r=Tr(e);return r==="center"||r==="end"?"min-w-0":r==="stretch"?"min-w-0 self-stretch":"min-w-0 self-start"}function Id(e){return e?e.widthMode==="full"||e.widthMode==="percent"||typeof e.widthPercent=="number"&&!Number.isNaN(e.widthPercent):!1}function ro(e){return(e.type==="button"||e.type==="editButton")&&!Id(e.appearance)}function Md(e){return ro(e)?Tr(e.appearance)==="stretch"?{width:"100%",maxWidth:"100%",minWidth:0}:{width:"auto",maxWidth:"100%"}:Na(e.appearance)}function Ld(e){return Md(e)}function Dd(e){if(ro(e))switch(Tr(e.appearance)){case"center":return"self-center";case"end":return"self-end";case"stretch":return"self-stretch";default:return"self-start"}return Od(e.appearance)}function Bd(e){return e?e.verticalAlign!=null||e.cellJustify!=null:!1}function Fa(e){return e.type!=="button"&&e.type!=="editButton"||Bd(e.appearance)?zo(e.appearance):"start"}function Pa(e){if(!e)return Fd(void 0);const t=Tr(e.appearance);return B("flex flex-col min-h-0 h-full w-full",Li(t),Uo(e))}function $b(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 B(Li(Tr(o)),Ta(zo(o)))}const Oa=S.createContext({gridStretch:!1});function Vo(){return S.useContext(Oa)}const $d=e=>{let t;const r=new Set,n=(u,l)=>{const f=typeof u=="function"?u(t):u;if(!Object.is(f,t)){const p=t;t=l??(typeof f!="object"||f===null)?f:Object.assign({},t,f),r.forEach(m=>m(t,p))}},o=()=>t,a={setState:n,getState:o,getInitialState:()=>d,subscribe:u=>(r.add(u),()=>r.delete(u))},d=t=e(n,o,a);return a},jb=(e=>e?$d(e):$d),zb=e=>e;function Ub(e,t=zb){const r=S.useSyncExternalStore(e.subscribe,S.useCallback(()=>t(e.getState()),[e,t]),S.useCallback(()=>t(e.getInitialState()),[e,t]));return S.useDebugValue(r),r}const jd=e=>{const t=jb(e),r=n=>Ub(t,n);return Object.assign(r,t),r},zd=(e=>e?jd(e):jd),Vb=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Hb=/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/,Wb=/^\+?[\d\s-()]{10,}$/,Rb={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:Vb.test(e),url:e=>typeof e!="string"||!e?!0:Hb.test(e),phone:e=>typeof e!="string"||!e?!0:Wb.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(),d=n[s];return d?d.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 Xr(e,t,r={}){const n=Rb[t.type];if(!n)return!0;const o=n(e,t,r);return o===!1?t.message||Gb(t):typeof o=="string"?o:!0}function Gb(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 ${Kb(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 Kb(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}const qb=10;function Bi(e){const t=e.properties;return t?.maxFiles!=null&&t.maxFiles>0?Math.floor(t.maxFiles):t?.multiple===!0?qb:1}function Ud(e){return typeof e=="object"&&e!==null&&"url"in e&&typeof e.url=="string"&&e.url.length>0}function Vd(e){try{return e.split("?")[0].split("/").filter(Boolean).pop()||e}catch{return e}}function $i(e){if(e==null)return[];if(typeof e=="string")return e.startsWith("http")?[{url:e,name:Vd(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:Vd(r)}):Ud(r)&&t.push(r);return t}return Ud(e)?[e]:[]}function Yb(e,t){return e.slice(0,t)}function Ia(e,t){const r=Yb(e,t);return r.length===0?null:t===1?r[0]??null:r}function Xb(e){return $i(e).length}function Jb(e){return e==="file"||e==="camera"||e==="photoChoice"}function Ma(e,t){if(!Jb(e.type))return;const r=Bi(e);if(Xb(t)>r)return`Maximum ${r} file(s) allowed`}class ji{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 f in s){const p=s[f];(p==null||p==="")&&(s[f]="")}const a={fields:s,currentValue:o,previousValue:i,...ji.functions},d=Object.keys(a),u=Object.values(a),l=new Function(...d,`return ${t}`)(...u);if(l==null)return"";if(typeof l=="string"){if(l.includes("undefined"))return"";const f=l.trim();return f===""||/^\s+$/.test(l)?"":f}return l}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 Hd=new ji;function Wd(e){if(e==null||e==="")return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:zi(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:zi(n)}return null}function zi(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function Qb(e,t=new Date){const r=zi(e),n=zi(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 La(e){if(e.type!=="number")return;const t=e.properties?.deriveFromDate;if(!(!t?.sourceFieldName||!t.part))return t}function Fr(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(0,t):e}function Da(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(t):null}function Zb(e,t){const r=Da(e);return r?`${t.sourceFieldName}${r}`:t.sourceFieldName}function Rd(e,t,r){const n=Da(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 ev(e,t,r){const n=r?Zb(r,e):e.sourceFieldName,o=Wd(t[n]);if(!o)return null;const i=e.referenceDate==="today"||e.referenceDate==null?new Date:Wd(t[e.referenceDate])??new Date;return Qb(o,i)[e.part]}function Gd(e,t){const r=La(e);return r?Fr(r.sourceFieldName)===Fr(t):!1}function Ba(e,t,r,n){const o={...t},i=n?Fr(n):void 0;for(const s of e){if(s.type!=="number")continue;const a=La(s);if(!a||!s.name||i&&Fr(a.sourceFieldName)!==i)continue;const d=n??a.sourceFieldName,u=Rd(s.name,d,o);for(const l of u){if(r.has(l))continue;const f=ev(a,o,l);o[l]=f}}return o}function tv(e,t,r,n){const o={...t},i=Fr(n);for(const s of e){if(!Gd(s,i)||!s.name)continue;const a=Rd(s.name,n,o);for(const d of a)r.delete(d),o[d]=null}return o}function Kd(e,t){const r=Fr(t);return e.some(n=>Gd(n,r))}function qd(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 $a(e,t,r,n){let o=ja(e,r);return n&&(o=jn(o,t,r)),o}function ja(e,t){return e.replace(/\{(?:ctx:|\@)(\w+)\}/g,(r,n)=>t?.[n]!==void 0&&t[n]!==null?String(t[n]):r)}function jn(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(d=>d.toLowerCase()===i.toLowerCase());a&&(s=t[a])}return s!=null&&s!==""?String(s):o}),n}function Ho(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 rv(e,t){const r=e[t];return r==null||r===""}function za(e){const{apiEndpoint:t,apiMethod:r="GET",apiQueryParams:n={},formValues:o,submissionContext:i,apiRealtime:s,additionalRequiredFieldNames:a=[],excludeFormFieldNames:d=[]}=e,u=(r||"GET").toLowerCase(),l=Ho(t,n),f=new Set((d||[]).filter(v=>typeof v=="string"&&v.length>0)),p=new Set((a||[]).filter(v=>typeof v=="string"&&v.length>0)),m=new Set([...l,...p]);let g=!1;for(const v of m){const x=!!(s&&l.has(v)),N=p.has(v);if((x||N)&&rv(o,v)){g=!0;break}}if(g)return{blocked:!0,url:t,postBodyBase:null};let h=t;const y=t.match(/\{(\w+)\}/g)||[];if(h=ja(h,i),s&&(h=jn(h,o,i)),n&&Object.keys(n).length>0){const v=n,x=[];if(v.limit){let N=v.limit;s&&(N=jn(N,o,i)),x.push(`_limit=${encodeURIComponent(N)}`)}if(v.page){let N=v.page;s&&(N=jn(N,o,i)),x.push(`page=${encodeURIComponent(N)}`)}if(v.sort){let N=v.sort;s&&(N=jn(N,o,i)),x.push(`sort=${encodeURIComponent(N)}`)}if(v.orderBy){let N=v.orderBy;s&&(N=jn(N,o,i)),x.push(`orderBy=${encodeURIComponent(N)}`)}if(v.custom?.length&&v.custom.forEach(({key:N,value:P})=>{if(!N||!P)return;let E=ja(P,i);s&&(E=jn(E,o,i)),E.match(/\{[^}]+\}/)?E.match(/\{(?!ctx:|\@)(\w+)\}/g)||x.push(`${encodeURIComponent(N)}=`):x.push(`${encodeURIComponent(N)}=${encodeURIComponent(E)}`)}),x.length>0){const N=h.includes("?")?"&":"?";h=`${h}${N}${x.join("&")}`}}if(s&&Object.keys(o).length>0&&u==="get"){const v=E=>E.replace(/\{/g,"").replace(/\}/g,""),x=[];for(const E of n.custom||[])if(E.value){const _=E.value.match(/\{(\w+)\}/g)||[];x.push(..._.map(v))}const N=new Set([...y.map(v),...x]),P={};Object.keys(o).forEach(E=>{!N.has(E)&&!f.has(E)&&(P[E]=o[E])}),Object.keys(P).length>0&&(h=`${h}${h.includes("?")?"&":"?"}${new URLSearchParams(P).toString()}`)}let w=null;if(["post","put","patch"].includes(u))if(s&&Object.keys(o).length>0){w={...o};for(const v of f)delete w[v]}else{w={...o||{}};for(const v of f)delete w[v]}return{blocked:!1,url:h,postBodyBase:w}}const nv=new Set(["select","multiselect","asyncsearch"]);function ov(e){return e?.type==="multiselect"?[]:""}function Yd(e){if(!nv.has(e.type))return[];const t=e.properties??{},r=qd(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,d=r?.apiQueryParams||t.apiQueryParams;if(s&&a)for(const u of Ho(s,d))n.add(u);return[...n]}function iv(e,t){const r=Fr(t);return Yd(e).some(n=>Fr(n)===r)}function sv(e,t){const r=Fr(t);return e.some(n=>iv(n,r))}function av(e){const t=new Map;for(const r of e){const n=r.name;if(n)for(const o of Yd(r)){const i=Fr(o),s=t.get(i)??new Set;s.add(n),t.set(i,s)}}return t}function lv(e,t,r){const n=Da(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 cv(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 dv(e,t,r){const n=av(e),o=Fr(r),i=new Set,s=[o];for(;s.length>0;){const u=s.shift(),l=n.get(u);if(l)for(const f of l)i.has(f)||(i.add(f),s.push(f))}const a={...t},d=[];for(const u of i){const l=e.find(p=>p.name===u),f=ov(l);for(const p of lv(u,r,a))cv(a[p],f)||d.push(p),a[p]=f}return{values:a,clearedKeys:d}}function Ua(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}const Nt=zd((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={},d=new Set,u=new Set,l=new Set;r.fields.forEach(y=>{const w=y.name||y.key||y.id;w&&(y.defaultValue!==void 0&&(y.type==="multiselect"?a[w]=Array.isArray(y.defaultValue)?y.defaultValue:y.defaultValue!=null&&y.defaultValue!==""?[String(y.defaultValue)]:[]:a[w]=y.defaultValue),y.hidden||d.add(w),y.disabled||u.add(w),y.validation?.some(v=>v.type==="required")&&l.add(w))});const f=r.steps?.length||1,p=[];r.fields.forEach(y=>{const w=y.properties;w?.valueSource==="calculated"&&w?.formula&&p.push({field:y.name,formula:w.formula})});const m=p.length>0?Hd.calculateAll(p,a):{},g=Ba(r.fields,{...a,...m},new Set),h=i&&!s?{...g,...o.values}:g;e({schema:r,values:h,initialValues:g,errors:{},touched:{},currentStep:0,totalSteps:f,completedSteps:new Set,visibleFields:d,enabledFields:u,requiredFields:l,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 d=new Set(i.derivedFieldDirty);const u=i.values[r];let l={...i.values,[r]:n},f=[];if(s){const p=Fr(r),m=s.fields.find(w=>w.name===p);a==="user"&&m&&La(m)&&d.add(r);const g=n==null||n===""||Array.isArray(n)&&n.length===0;if(Kd(s.fields,r)&&g?l=tv(s.fields,l,d,r):Kd(s.fields,r)&&(l=Ba(s.fields,l,d,r)),a==="user"&&u!==n&&!(Array.isArray(u)&&Array.isArray(n)&&u.length===n.length&&u.every((w,v)=>w===n[v]))&&sv(s.fields,r)){const w=dv(s.fields,l,r);l=w.values,f=w.clearedKeys}const y=[];if(s.fields.forEach(w=>{const v=w.properties;v?.valueSource==="calculated"&&v?.formula&&(v.formulaSteps||[]).some(P=>P.type==="field"&&P.fieldName===r)&&y.push({field:w.name,formula:v.formula})}),y.length>0){const w=Hd.calculateAll(y,l);l={...l,...w}}}e({values:l,derivedFieldDirty:d}),f.length>0&&e(p=>{const m={...p.errors};for(const g of f)delete m[g];return Object.keys(m).length===Object.keys(p.errors).length?p:{errors:m}}),s?.config.validateOnChange?t().validateField(r):e(p=>{const m={...p.errors};return delete m[r],{errors:m}})},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=Ba(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 d=Xr(o[r],a,o);if(typeof d=="string"){s=d;break}}if(!s){const a=Ma(i,o[r]);a&&(s=a)}return e(a=>{const d={...a.errors};return s?d[r]=s:delete d[r],{errors:d,isValid:Object.keys(d).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 d of a.validation){if(d.type==="required"&&!i.has(a.name))continue;const u=Xr(n[a.name],d,n);if(typeof u=="string"){s[a.name]=u;break}}if(!s[a.name]){const d=Ma(a,n[a.name]);d&&(s[a.name]=d)}}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||!n.steps)return!0;const s=n.steps[r];if(!s)return!0;e({isValidating:!0});const a={};for(const d of s.fields){const u=n.fields.find(l=>l.name===d);if(u&&i.has(u.name)){if(u.validation)for(const l of u.validation){const f=Xr(o[u.name],l,o);if(typeof f=="string"){a[u.name]=f;break}}if(!a[u.name]){const l=Ma(u,o[u.name]);l&&(a[u.name]=l)}}}return e(d=>({errors:{...d.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 Ua(n.visibleFields,o)?n:{visibleFields:o}})},updateEnabled:r=>{e(n=>{const o=new Set(r);return Ua(n.enabledFields,o)?n:{enabledFields:o}})},updateRequired:r=>{e(n=>{const o=new Set(r);return Ua(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{}}}));function uv(){return Nt.getState()}function Xd({schema:e,initialValues:t,onSubmit:r,onChange:n,workflowStepId:o}){const{values:i,errors:s,touched:a,isValidating:d,isSubmitting:u,submitCount:l,isValid:f,currentStep:p,totalSteps:m,completedSteps:g,visibleFields:h,enabledFields:y,requiredFields:w,setSchema:v,setFieldValue:x,setFieldTouched:N,setFieldError:P,setValues:E,resetForm:_,validateField:C,validateForm:A,validateStep:O,nextStep:T,prevStep:z,goToStep:q,setSubmitting:I,incrementSubmitCount:$,saveDraft:M,loadDraft:D,clearDraft:L}=Nt(),U=S.useRef(null);S.useLayoutEffect(()=>{if(v(e,{forceReset:!!o}),t&&Object.keys(t).length>0){const le=Nt.getState().values;E({...le,...t});try{U.current=JSON.stringify(t)}catch{U.current=null}}else U.current=null},[e.id,o]),S.useLayoutEffect(()=>{if(!t||Object.keys(t).length===0)return;let le;try{le=JSON.stringify(t)}catch{return}if(le===U.current)return;const Xe=Nt.getState().values;E({...Xe,...t}),U.current=le},[t,E]);const j=S.useCallback((le,Xe)=>{const ge={...i,[le]:Xe};x(le,Xe),n?.(ge,le)},[x,n,i]),se=S.useCallback(async le=>{if(le?.preventDefault(),$(),!await A())return{success:!1,errors:Object.entries(s).map(([ge,Se])=>({field:ge,rule:"validation",message:Se}))};if(!r)return{success:!0};I(!0);try{const ge=await r(i);return ge.success&&L(),ge}catch(ge){return{success:!1,message:ge instanceof Error?ge.message:"Submission failed"}}finally{I(!1)}},[A,r,i,s,$,I,L]),H=S.useCallback(le=>({value:i[le],error:s[le],touched:a[le]||!1,isVisible:h.has(le),isEnabled:y.has(le),isRequired:w.has(le)}),[i,s,a,h,y,w]),G=S.useMemo(()=>{if(!e.steps||e.steps.length===0)return e.fields;const le=e.steps[p];return le?e.fields.filter(Xe=>le.fields.includes(Xe.name)):[]},[e,p]),ee=p===0,de=p===m-1,ne=S.useCallback(le=>g.has(le),[g]),K=S.useMemo(()=>m<=1?100:Math.round(g.size/m*100),[g.size,m]),re=S.useCallback(le=>h.has(le),[h]),Te=S.useCallback(le=>y.has(le),[y]),Z=S.useCallback(le=>w.has(le),[w]),te=S.useMemo(()=>Object.entries(s).filter(([le])=>h.has(le)),[s,h]),he=te.length>0;return{values:i,errors:s,touched:a,isValidating:d,isSubmitting:u,submitCount:l,isValid:f,hasErrors:he,visibleErrors:te,currentStep:p,totalSteps:m,completedSteps:g,currentStepFields:G,isFirstStep:ee,isLastStep:de,isStepCompleted:ne,progress:K,setFieldValue:j,setFieldTouched:N,setFieldError:P,setValues:E,validateField:C,getFieldState:H,shouldShowField:re,isFieldEnabled:Te,isFieldRequired:Z,handleSubmit:se,resetForm:_,validateForm:A,validateStep:O,nextStep:T,prevStep:z,goToStep:q,saveDraft:M,loadDraft:D,clearDraft:L}}function Jd(e){return"logic"in e&&"conditions"in e}function Wo(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 Qd(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 Qe(e,t){if(e==null||typeof t!="string"||t.trim()==="")return;let r=Qd(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=Qd(e,o);Array.isArray(s)&&s.length>0&&(r=Qe(s[0],i))}}return r}const fv=new Set(["section","group","columns","divider","header","sectionHeading","spacer","textLabel","addmore","customizeSections"]);function pv(e){return e===!0||e==="true"?!0:e===!1||e==="false"?!1:e}function mv(e,t){if(e==null||typeof t.path!="string"||!t.path.trim())return!1;const r=Qe(e,t.path),n=pv(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 hv(e,t,r){return e?e==="__allFields__"?t.filter(n=>!fv.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]:[]}const Zd="__buttonResponse:";function gv({fields:e,values:t,buttonResponses:r,prepopulateResponse:n=null,prepopulateResponseRules:o}){const{updateVisibility:i,updateEnabled:s,updateRequired:a,updateReadOnly:d,updateEditable:u,updateFormDisabled:l}=Nt(),f=S.useCallback(E=>E.name||E.key||E.id,[]),p=S.useCallback((E,_)=>{if(!E)return f(_);const C=e.find(A=>A.id===E||A.name===E||A.key===E);return C?f(C):E},[e,f]),m=S.useCallback(E=>{const _=e.find(C=>C.id===E||C.name===E||C.key===E);return _?f(_):E},[e,f]),g=S.useCallback(E=>{const{field:_,operator:C,value:A}=E;if(typeof _=="string"&&_.startsWith(Zd)){const z=_.slice(Zd.length),q=r?.[z],I=Wo(q);return A==="success"?I:A==="failure"?q!=null&&!I:!1}const O=m(_),T=t[O];switch(C){case"equals":return T===A;case"notEquals":return T!==A;case"contains":return typeof T=="string"?T.includes(String(A)):Array.isArray(T)?T.includes(A):!1;case"notContains":return typeof T=="string"?!T.includes(String(A)):Array.isArray(T)?!T.includes(A):!0;case"startsWith":return typeof T=="string"&&T.startsWith(String(A));case"endsWith":return typeof T=="string"&&T.endsWith(String(A));case"greaterThan":return Number(T)>Number(A);case"lessThan":return Number(T)<Number(A);case"greaterThanOrEqual":return Number(T)>=Number(A);case"lessThanOrEqual":return Number(T)<=Number(A);case"isEmpty":return T==null?!0:T instanceof File?!1:typeof T=="string"?T.trim()==="":Array.isArray(T)?(T.length>0&&T[0]instanceof File,T.length===0):typeof T=="object"&&T!==null?Object.keys(T).length===0:!1;case"isNotEmpty":return T==null?!1:T instanceof File?!0:typeof T=="string"?T.trim()!=="":Array.isArray(T)?(T.length>0&&T[0]instanceof File,T.length>0):typeof T=="object"&&T!==null?Object.keys(T).length>0:!1;case"isTrue":return T===!0;case"isFalse":return T===!1;case"isNull":return T==null;case"isNotNull":return T!=null;case"in":return Array.isArray(A)?A.includes(T):!1;case"notIn":return Array.isArray(A)?!A.includes(T):!0;case"between":if(Array.isArray(A)&&A.length===2){const z=Number(T);return z>=Number(A[0])&&z<=Number(A[1])}return!1;case"regex":try{return new RegExp(String(A)).test(String(T))}catch{return!1}default:return!0}},[t,m,r]),h=S.useCallback(E=>{const _=E.conditions.map(C=>Jd(C)?h(C):g(C));return E.logic==="and"?_.every(Boolean):_.some(Boolean)},[g]),y=S.useCallback(E=>Jd(E)?h(E):g(E),[g,h]),w=S.useCallback(()=>{const E=new Set,_=new Set,C=new Set,A=new Set,O=new Set;e.forEach(I=>{const $=f(I);I.hidden||E.add($),I.disabled||_.add($),I.validation?.some(M=>M.type==="required")&&C.add($)});let T=!1;if(n!=null&&o?.length)for(const I of o){if(!mv(n,I.when))continue;const{action:$,target:M}=I.then;if($==="disableForm")T=!0;else if($==="enableForm")T=!1;else{const D=hv(M,e,f);for(const L of D)switch($){case"disable":_.delete(L);break;case"enable":_.add(L);break;case"hide":E.delete(L);break;case"show":E.add(L);break;case"readOnly":A.add(L),O.delete(L);break;case"editable":O.add(L),A.delete(L);break}}}e.forEach(I=>{I.conditions&&I.conditions.forEach($=>{(y($.when)?$.then:$.else||[]).forEach(L=>{switch(L.action){case"disableForm":T=!0;break;case"enableForm":T=!1;break;default:{const U=p(L.target,I);switch(L.action){case"show":E.add(U);break;case"hide":E.delete(U);break;case"enable":_.add(U);break;case"disable":_.delete(U);break;case"require":C.add(U);break;case"unrequire":C.delete(U);break}break}}})})});const z=I=>e.filter($=>$.type!=="editButton"&&($.name||$.key||$.id)).map($=>f($)),q=()=>e.filter(I=>I.type==="button").map(I=>f(I));return e.forEach(I=>{if(I.type!=="editButton")return;const $=f(I);if(!Wo(r?.[$]))return;const M=I.properties;M?.rules&&M.rules.length>0?M.rules.forEach(D=>{const L=[];D.allFields&&L.push(...z(I.id)),D.allButtons&&L.push(...q()),D.fieldNames?.length&&D.fieldNames.forEach(U=>{const j=e.find(se=>f(se)===U||se.id===U||se.name===U);L.push(j?f(j):U)}),D.buttonNames?.length&&L.push(...D.buttonNames),L.forEach(U=>{switch(D.action){case"enable":_.add(U),A.delete(U);break;case"disable":_.delete(U);break;case"show":E.add(U);break;case"hide":E.delete(U);break;case"readOnly":A.add(U);break;case"editable":O.add(U);break}})}):((M?.enableFieldNames??[]).forEach(D=>_.add(D)),(M?.disableFieldNames??[]).forEach(D=>_.delete(D)),(M?.showFieldNames??[]).forEach(D=>E.add(D)),(M?.hideFieldNames??[]).forEach(D=>E.delete(D)))}),{visible:Array.from(E),enabled:Array.from(_),required:Array.from(C),readOnly:Array.from(A),editable:Array.from(O),formDisabled:T}},[e,y,f,p,t,r,n,o]),v=S.useMemo(()=>w(),[w]);S.useEffect(()=>{i(v.visible),s(v.enabled),a(v.required),d(v.readOnly??[]),u(v.editable??[]),l(v.formDisabled??!1)},[v,i,s,a,d,u,l]);const x=S.useCallback(E=>v.visible.includes(E),[v.visible]),N=S.useCallback(E=>v.enabled.includes(E),[v.enabled]),P=S.useCallback(E=>v.required.includes(E),[v.required]);return{evaluateCondition:y,evaluateExpression:g,evaluateGroup:h,isFieldVisible:x,isFieldEnabled:N,isFieldRequired:P,visibleFields:v.visible,enabledFields:v.enabled,requiredFields:v.required}}function An({className:e,type:t,...r}){return c.jsx("input",{type:t,"data-slot":"input",className:B("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 eu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function zn(...e){return t=>{let r=!1;const n=e.map(o=>{const i=eu(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():eu(e[o],null)}}}}function Ze(...e){return b.useCallback(zn(...e),e)}var yv=Symbol.for("react.lazy"),Ui=b[" use ".trim().toString()];function bv(e){return typeof e=="object"&&e!==null&&"then"in e}function tu(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===yv&&"_payload"in e&&bv(e._payload)}function Va(e){const t=vv(e),r=b.forwardRef((n,o)=>{let{children:i,...s}=n;tu(i)&&typeof Ui=="function"&&(i=Ui(i._payload));const a=b.Children.toArray(i),d=a.find(Sv);if(d){const u=d.props.children,l=a.map(f=>f===d?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:f);return c.jsx(t,{...s,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...s,ref:o,children:i})});return r.displayName=`${e}.Slot`,r}var ru=Va("Slot");function vv(e){const t=b.forwardRef((r,n)=>{let{children:o,...i}=r;if(tu(o)&&typeof Ui=="function"&&(o=Ui(o._payload)),b.isValidElement(o)){const s=Av(o),a=xv(i,o.props);return o.type!==b.Fragment&&(a.ref=n?zn(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 wv=Symbol("radix.slottable");function Sv(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===wv}function xv(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 d=i(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...i}:n==="className"&&(r[n]=[o,i].filter(Boolean).join(" "))}return{...e,...r}}function Av(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 Cv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ev=Cv.reduce((e,t)=>{const r=Va(`Primitive.${t}`),n=b.forwardRef((o,i)=>{const{asChild:s,...a}=o,d=s?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(d,{...a,ref:i})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),Nv="Label",nu=b.forwardRef((e,t)=>c.jsx(Ev.label,{...e,ref:t,onMouseDown:r=>{r.target.closest("button, input, select, textarea")||(e.onMouseDown?.(r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));nu.displayName=Nv;var _v=nu;function Cn({className:e,...t}){return c.jsx(_v,{"data-slot":"label",className:B("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 ht(e){return`formsmith-field-${e.id}`}function Vi(e){return`formsmith-label-${e.id}`}function Ro(e){return`formsmith-desc-${e.id}`}function Go(e){return`formsmith-error-${e.id}`}function $t(e,t){const r=[];return e.description&&r.push(Ro(e)),t&&r.push(Go(e)),r.length>0?r.join(" "):void 0}function Zt(e){return e?!0:void 0}const kv={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 En(e){return e.ui?.cellStyle}function Tv(e){const t=e.ui;if(!t)return;const r=t.fontToken?kv[t.fontToken]:void 0;if(!(!r&&!t.wrapperStyle))return{...r,...t.wrapperStyle}}function Fv(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}=Vo(),a=s&&Di(e),d=!(i??e.appearance?.hideLabel)&&e.label,u=e.appearance?.labelPlacement||"top",l=Tv(e),f=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,m=Ld(e),g=ro(e),h=Fv(e),y=Tr(e.appearance);return c.jsx("div",{className:B(Ib(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:l,"data-field-appearance":u,children:c.jsxs("div",{className:B("flex flex-col min-w-0",Pd(e.appearance),Dd(e),a&&!h&&"flex-1 min-h-0",s&&h&&"shrink-0"),style:m,children:[d&&c.jsxs(Cn,{id:Vi(e),htmlFor:ht(e),style:e.ui?.labelStyle,className:B(Mb(u,!!t)),children:[e.label,r&&c.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),c.jsxs("div",{className:B(Lb(u),h&&s&&"min-h-min !grow-0 !shrink-0 basis-auto",g&&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:f,children:[n,c.jsxs("div",{className:B("mt-1.5 min-h-[18px]",u==="center"&&"text-center",o?.includes("flex")&&"shrink-0"),children:[e.description&&!t&&c.jsx("p",{id:Ro(e),className:"text-xs text-muted-foreground",style:e.ui?.descriptionStyle,children:e.description}),t&&c.jsx("p",{id:Go(e),className:"text-xs text-destructive",role:"alert",children:typeof t=="string"?t:String(t||"An error occurred")})]})]})]})})},Hi=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:d})=>{const u=e.properties,l=S.useCallback(f=>{r(f.target.value)},[r]);return c.jsx(At,{field:e,error:o,isRequired:a,className:d,children:c.jsx(An,{id:ht(e),type:"text",value:t||"",onChange:l,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":$t(e,!!o),"aria-invalid":Zt(!!o),"aria-required":a,className:B(jo(e.appearance),o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})})},Ha=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:d})=>{const u=e.properties,l=u?.precision!=null||u?.step!=null&&!Number.isInteger(u.step),f=S.useCallback(m=>{const g=u?.allowNegative!==!1,h=m.target.value,y=l?h.replace(g?/[^\d.-]/g:/[^\d.]/g,""):h.replace(g?/[^\d-]/g:/\D/g,"");if(y===""){r(null);return}const w=parseFloat(y);isNaN(w)||r(w)},[r,u?.allowNegative,l]),p=S.useCallback(m=>{(m.key==="ArrowUp"||m.key==="ArrowDown"||m.key==="PageUp"||m.key==="PageDown")&&m.preventDefault()},[]);return c.jsx(At,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{className:"relative",children:[u?.prefix&&c.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:u.prefix}),c.jsx(An,{id:ht(e),type:"text",inputMode:l?"decimal":"numeric",autoComplete:"off",value:t??"",onChange:f,onKeyDown:p,onBlur:n,placeholder:e.placeholder,disabled:i||e.disabled,readOnly:s||e.readOnly,"aria-describedby":$t(e,!!o),"aria-invalid":Zt(!!o),"aria-required":a,className:B(jo(e.appearance),o&&"border-destructive focus-visible:ring-destructive",u?.prefix&&"pl-8",u?.suffix&&"pr-8",e.appearance?.className)}),u?.suffix&&c.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:u.suffix})]})})};const Pv=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Ov=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,n)=>n?n.toUpperCase():r.toLowerCase()),ou=e=>{const t=Ov(e);return t.charAt(0).toUpperCase()+t.slice(1)},iu=(...e)=>e.filter((t,r,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===r).join(" ").trim(),Iv=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Mv={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 Lv=S.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:o="",children:i,iconNode:s,...a},d)=>S.createElement("svg",{ref:d,...Mv,width:t,height:t,stroke:e,strokeWidth:n?Number(r)*24/Number(t):r,className:iu("lucide",o),...!i&&!Iv(a)&&{"aria-hidden":"true"},...a},[...s.map(([u,l])=>S.createElement(u,l)),...Array.isArray(i)?i:[i]]));const Wt=(e,t)=>{const r=S.forwardRef(({className:n,...o},i)=>S.createElement(Lv,{ref:i,iconNode:t,className:iu(`lucide-${Pv(ou(e))}`,`lucide-${e}`,n),...o}));return r.displayName=ou(e),r};const Dv=Wt("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 Wi=Wt("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 Ri=Wt("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Ko=Wt("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const su=Wt("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Bv=Wt("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);const $v=Wt("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 au=Wt("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const lu=Wt("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 cu=Wt("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 qo=Wt("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const jv=Wt("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 zv=Wt("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 du=Wt("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const Uv=Wt("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 uu=Wt("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 Yo=Wt("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 Gi=Wt("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 Xo=Wt("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),fu=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:d})=>{const u=S.useCallback(l=>{r(l.target.value)},[r]);return c.jsx(At,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{className:"relative",children:[c.jsx(jv,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),c.jsx(An,{id:ht(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":$t(e,!!o),"aria-invalid":Zt(!!o),"aria-required":a,className:B(jo(e.appearance),"pl-10",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]})})},pu=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:d})=>{const u=S.useCallback(l=>{const f=l.target.value.replace(/[^\d\s+\-()]/g,"");r(f)},[r]);return c.jsx(At,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{className:"relative",children:[c.jsx(zv,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),c.jsx(An,{id:ht(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":$t(e,!!o),"aria-invalid":Zt(!!o),"aria-required":a,className:B(jo(e.appearance),"pl-10",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]})})};function Vv({className:e,maxLength:t,showCharacterCount:r=!1,autoResize:n=!1,onChange:o,value:i,...s}){const a=b.useRef(null),[d,u]=b.useState(0),l=f=>{const p=f.target.value;u(p.length),n&&a.current&&(a.current.style.height="auto",a.current.style.height=`${a.current.scrollHeight}px`),o&&o(f)};return b.useEffect(()=>{i&&u(String(i).length)},[i]),c.jsxs("div",{className:"space-y-1",children:[c.jsx("textarea",{ref:a,"data-slot":"textarea",className:B("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:l,value:i,...s}),r&&c.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[c.jsxs("span",{children:[d," characters"]}),t&&c.jsxs("span",{children:[t-d," remaining"]})]})]})}const mu=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:d})=>{const{gridStretch:u}=Vo(),l=u&&Di(e),f=e.properties,p=S.useCallback(y=>{r(y.target.value)},[r]),m=(t||"").length,g=f?.maxLength,h=g&&g>0;return c.jsx(At,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{className:B("relative flex flex-col",l&&"flex-1 min-h-0"),children:[c.jsx(Vv,{id:ht(e),value:t||"",onChange:p,onBlur:n,placeholder:e.placeholder,disabled:i||e.disabled,readOnly:s||e.readOnly,minLength:f?.minLength,maxLength:f?.maxLength,rows:2,"aria-describedby":$t(e,!!o),"aria-invalid":Zt(!!o),"aria-required":a,className:B(kd(e.appearance),"resize-y",l&&"min-h-[120px] flex-1 flex-shrink-0",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)}),h&&c.jsxs("span",{className:"absolute bottom-2 right-2 text-xs text-muted-foreground",children:[m,"/",g]})]})})};function Jo(e,[t,r]){return Math.min(r,Math.max(t,e))}function Le(e,t,{checkForDefaultPrevented:r=!0}={}){return function(o){if(e?.(o),r===!1||!o.defaultPrevented)return t?.(o)}}function Hv(e,t){const r=b.createContext(t),n=i=>{const{children:s,...a}=i,d=b.useMemo(()=>a,Object.values(a));return c.jsx(r.Provider,{value:d,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 xr(e,t=[]){let r=[];function n(i,s){const a=b.createContext(s),d=r.length;r=[...r,s];const u=f=>{const{scope:p,children:m,...g}=f,h=p?.[e]?.[d]||a,y=b.useMemo(()=>g,Object.values(g));return c.jsx(h.Provider,{value:y,children:m})};u.displayName=i+"Provider";function l(f,p){const m=p?.[e]?.[d]||a,g=b.useContext(m);if(g)return g;if(s!==void 0)return s;throw new Error(`\`${f}\` must be used within \`${i}\``)}return[u,l]}const o=()=>{const i=r.map(s=>b.createContext(s));return function(a){const d=a?.[e]||i;return b.useMemo(()=>({[`__scope${e}`]:{...a,[e]:d}}),[a,d])}};return o.scopeName=e,[n,Wv(o,...t)]}function Wv(...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:d,scopeName:u})=>{const f=d(i)[`__scope${u}`];return{...a,...f}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return r.scopeName=t.scopeName,r}function hu(e){const t=Rv(e),r=b.forwardRef((n,o)=>{const{children:i,...s}=n,a=b.Children.toArray(i),d=a.find(Kv);if(d){const u=d.props.children,l=a.map(f=>f===d?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:f);return c.jsx(t,{...s,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...s,ref:o,children:i})});return r.displayName=`${e}.Slot`,r}function Rv(e){const t=b.forwardRef((r,n)=>{const{children:o,...i}=r;if(b.isValidElement(o)){const s=Yv(o),a=qv(i,o.props);return o.type!==b.Fragment&&(a.ref=n?zn(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 Gv=Symbol("radix.slottable");function Kv(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Gv}function qv(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 d=i(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...i}:n==="className"&&(r[n]=[o,i].filter(Boolean).join(" "))}return{...e,...r}}function Yv(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 Wa(e){const t=e+"CollectionProvider",[r,n]=xr(t),[o,i]=r(t,{collectionRef:{current:null},itemMap:new Map}),s=h=>{const{scope:y,children:w}=h,v=S.useRef(null),x=S.useRef(new Map).current;return c.jsx(o,{scope:y,itemMap:x,collectionRef:v,children:w})};s.displayName=t;const a=e+"CollectionSlot",d=hu(a),u=S.forwardRef((h,y)=>{const{scope:w,children:v}=h,x=i(a,w),N=Ze(y,x.collectionRef);return c.jsx(d,{ref:N,children:v})});u.displayName=a;const l=e+"CollectionItemSlot",f="data-radix-collection-item",p=hu(l),m=S.forwardRef((h,y)=>{const{scope:w,children:v,...x}=h,N=S.useRef(null),P=Ze(y,N),E=i(l,w);return S.useEffect(()=>(E.itemMap.set(N,{ref:N,...x}),()=>{E.itemMap.delete(N)})),c.jsx(p,{[f]:"",ref:P,children:v})});m.displayName=l;function g(h){const y=i(e+"CollectionConsumer",h);return S.useCallback(()=>{const v=y.collectionRef.current;if(!v)return[];const x=Array.from(v.querySelectorAll(`[${f}]`));return Array.from(y.itemMap.values()).sort((E,_)=>x.indexOf(E.ref.current)-x.indexOf(_.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:s,Slot:u,ItemSlot:m},g,n]}var Xv=b.createContext(void 0);function no(e){const t=b.useContext(Xv);return e||t||"ltr"}function Jv(e){const t=Qv(e),r=b.forwardRef((n,o)=>{const{children:i,...s}=n,a=b.Children.toArray(i),d=a.find(ew);if(d){const u=d.props.children,l=a.map(f=>f===d?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:f);return c.jsx(t,{...s,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...s,ref:o,children:i})});return r.displayName=`${e}.Slot`,r}function Qv(e){const t=b.forwardRef((r,n)=>{const{children:o,...i}=r;if(b.isValidElement(o)){const s=rw(o),a=tw(i,o.props);return o.type!==b.Fragment&&(a.ref=n?zn(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 Zv=Symbol("radix.slottable");function ew(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Zv}function tw(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 d=i(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...i}:n==="className"&&(r[n]=[o,i].filter(Boolean).join(" "))}return{...e,...r}}function rw(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 nw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],$e=nw.reduce((e,t)=>{const r=Jv(`Primitive.${t}`),n=b.forwardRef((o,i)=>{const{asChild:s,...a}=o,d=s?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(d,{...a,ref:i})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function ow(e,t){e&&ki.flushSync(()=>e.dispatchEvent(t))}function ar(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),b.useMemo(()=>(...r)=>t.current?.(...r),[])}function iw(e,t=globalThis?.document){const r=ar(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 sw="DismissableLayer",Ra="dismissableLayer.update",aw="dismissableLayer.pointerDownOutside",lw="dismissableLayer.focusOutside",gu,yu=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ki=b.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:s,onDismiss:a,...d}=e,u=b.useContext(yu),[l,f]=b.useState(null),p=l?.ownerDocument??globalThis?.document,[,m]=b.useState({}),g=Ze(t,_=>f(_)),h=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),w=h.indexOf(y),v=l?h.indexOf(l):-1,x=u.layersWithOutsidePointerEventsDisabled.size>0,N=v>=w,P=uw(_=>{const C=_.target,A=[...u.branches].some(O=>O.contains(C));!N||A||(o?.(_),s?.(_),_.defaultPrevented||a?.())},p),E=fw(_=>{const C=_.target;[...u.branches].some(O=>O.contains(C))||(i?.(_),s?.(_),_.defaultPrevented||a?.())},p);return iw(_=>{v===u.layers.size-1&&(n?.(_),!_.defaultPrevented&&a&&(_.preventDefault(),a()))},p),b.useEffect(()=>{if(l)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(gu=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(l)),u.layers.add(l),bu(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=gu)}},[l,p,r,u]),b.useEffect(()=>()=>{l&&(u.layers.delete(l),u.layersWithOutsidePointerEventsDisabled.delete(l),bu())},[l,u]),b.useEffect(()=>{const _=()=>m({});return document.addEventListener(Ra,_),()=>document.removeEventListener(Ra,_)},[]),c.jsx($e.div,{...d,ref:g,style:{pointerEvents:x?N?"auto":"none":void 0,...e.style},onFocusCapture:Le(e.onFocusCapture,E.onFocusCapture),onBlurCapture:Le(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:Le(e.onPointerDownCapture,P.onPointerDownCapture)})});Ki.displayName=sw;var cw="DismissableLayerBranch",dw=b.forwardRef((e,t)=>{const r=b.useContext(yu),n=b.useRef(null),o=Ze(t,n);return b.useEffect(()=>{const i=n.current;if(i)return r.branches.add(i),()=>{r.branches.delete(i)}},[r.branches]),c.jsx($e.div,{...e,ref:o})});dw.displayName=cw;function uw(e,t=globalThis?.document){const r=ar(e),n=b.useRef(!1),o=b.useRef(()=>{});return b.useEffect(()=>{const i=a=>{if(a.target&&!n.current){let d=function(){vu(aw,r,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=d,t.addEventListener("click",o.current,{once:!0})):d()}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 fw(e,t=globalThis?.document){const r=ar(e),n=b.useRef(!1);return b.useEffect(()=>{const o=i=>{i.target&&!n.current&&vu(lw,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 bu(){const e=new CustomEvent(Ra);document.dispatchEvent(e)}function vu(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?ow(o,i):o.dispatchEvent(i)}var Ga=0;function Ka(){b.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??wu()),document.body.insertAdjacentElement("beforeend",e[1]??wu()),Ga++,()=>{Ga===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Ga--}},[])}function wu(){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 qa="focusScope.autoFocusOnMount",Ya="focusScope.autoFocusOnUnmount",Su={bubbles:!1,cancelable:!0},pw="FocusScope",qi=b.forwardRef((e,t)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...s}=e,[a,d]=b.useState(null),u=ar(o),l=ar(i),f=b.useRef(null),p=Ze(t,h=>d(h)),m=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(n){let h=function(x){if(m.paused||!a)return;const N=x.target;a.contains(N)?f.current=N:Nn(f.current,{select:!0})},y=function(x){if(m.paused||!a)return;const N=x.relatedTarget;N!==null&&(a.contains(N)||Nn(f.current,{select:!0}))},w=function(x){if(document.activeElement===document.body)for(const P of x)P.removedNodes.length>0&&Nn(a)};document.addEventListener("focusin",h),document.addEventListener("focusout",y);const v=new MutationObserver(w);return a&&v.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",h),document.removeEventListener("focusout",y),v.disconnect()}}},[n,a,m.paused]),b.useEffect(()=>{if(a){Cu.add(m);const h=document.activeElement;if(!a.contains(h)){const w=new CustomEvent(qa,Su);a.addEventListener(qa,u),a.dispatchEvent(w),w.defaultPrevented||(mw(vw(xu(a)),{select:!0}),document.activeElement===h&&Nn(a))}return()=>{a.removeEventListener(qa,u),setTimeout(()=>{const w=new CustomEvent(Ya,Su);a.addEventListener(Ya,l),a.dispatchEvent(w),w.defaultPrevented||Nn(h??document.body,{select:!0}),a.removeEventListener(Ya,l),Cu.remove(m)},0)}}},[a,u,l,m]);const g=b.useCallback(h=>{if(!r&&!n||m.paused)return;const y=h.key==="Tab"&&!h.altKey&&!h.ctrlKey&&!h.metaKey,w=document.activeElement;if(y&&w){const v=h.currentTarget,[x,N]=hw(v);x&&N?!h.shiftKey&&w===N?(h.preventDefault(),r&&Nn(x,{select:!0})):h.shiftKey&&w===x&&(h.preventDefault(),r&&Nn(N,{select:!0})):w===v&&h.preventDefault()}},[r,n,m.paused]);return c.jsx($e.div,{tabIndex:-1,...s,ref:p,onKeyDown:g})});qi.displayName=pw;function mw(e,{select:t=!1}={}){const r=document.activeElement;for(const n of e)if(Nn(n,{select:t}),document.activeElement!==r)return}function hw(e){const t=xu(e),r=Au(t,e),n=Au(t.reverse(),e);return[r,n]}function xu(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 Au(e,t){for(const r of e)if(!gw(r,{upTo:t}))return r}function gw(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 yw(e){return e instanceof HTMLInputElement&&"select"in e}function Nn(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&yw(e)&&t&&e.select()}}var Cu=bw();function bw(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=Eu(e,t),e.unshift(t)},remove(t){e=Eu(e,t),e[0]?.resume()}}}function Eu(e,t){const r=[...e],n=r.indexOf(t);return n!==-1&&r.splice(n,1),r}function vw(e){return e.filter(t=>t.tagName!=="A")}var er=globalThis?.document?b.useLayoutEffect:()=>{},ww=b[" useId ".trim().toString()]||(()=>{}),Sw=0;function cn(e){const[t,r]=b.useState(ww());return er(()=>{r(n=>n??String(Sw++))},[e]),e||(t?`radix-${t}`:"")}const xw=["top","right","bottom","left"],_n=Math.min,Ar=Math.max,Yi=Math.round,Xi=Math.floor,Jr=e=>({x:e,y:e}),Aw={left:"right",right:"left",bottom:"top",top:"bottom"};function Xa(e,t,r){return Ar(e,_n(t,r))}function dn(e,t){return typeof e=="function"?e(t):e}function un(e){return e.split("-")[0]}function oo(e){return e.split("-")[1]}function Ja(e){return e==="x"?"y":"x"}function Qa(e){return e==="y"?"height":"width"}function Qr(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Za(e){return Ja(Qr(e))}function Cw(e,t,r){r===void 0&&(r=!1);const n=oo(e),o=Za(e),i=Qa(o);let s=o==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(s=Ji(s)),[s,Ji(s)]}function Ew(e){const t=Ji(e);return[el(e),t,el(t)]}function el(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Nu=["left","right"],_u=["right","left"],Nw=["top","bottom"],_w=["bottom","top"];function kw(e,t,r){switch(e){case"top":case"bottom":return r?t?_u:Nu:t?Nu:_u;case"left":case"right":return t?Nw:_w;default:return[]}}function Tw(e,t,r,n){const o=oo(e);let i=kw(un(e),r==="start",n);return o&&(i=i.map(s=>s+"-"+o),t&&(i=i.concat(i.map(el)))),i}function Ji(e){const t=un(e);return Aw[t]+e.slice(t.length)}function Fw(e){return{top:0,right:0,bottom:0,left:0,...e}}function ku(e){return typeof e!="number"?Fw(e):{top:e,right:e,bottom:e,left:e}}function Qi(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 Tu(e,t,r){let{reference:n,floating:o}=e;const i=Qr(t),s=Za(t),a=Qa(s),d=un(t),u=i==="y",l=n.x+n.width/2-o.width/2,f=n.y+n.height/2-o.height/2,p=n[a]/2-o[a]/2;let m;switch(d){case"top":m={x:l,y:n.y-o.height};break;case"bottom":m={x:l,y:n.y+n.height};break;case"right":m={x:n.x+n.width,y:f};break;case"left":m={x:n.x-o.width,y:f};break;default:m={x:n.x,y:n.y}}switch(oo(t)){case"start":m[s]-=p*(r&&u?-1:1);break;case"end":m[s]+=p*(r&&u?-1:1);break}return m}async function Pw(e,t){var r;t===void 0&&(t={});const{x:n,y:o,platform:i,rects:s,elements:a,strategy:d}=e,{boundary:u="clippingAncestors",rootBoundary:l="viewport",elementContext:f="floating",altBoundary:p=!1,padding:m=0}=dn(t,e),g=ku(m),y=a[p?f==="floating"?"reference":"floating":f],w=Qi(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:l,strategy:d})),v=f==="floating"?{x:n,y:o,width:s.floating.width,height:s.floating.height}:s.reference,x=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),N=await(i.isElement==null?void 0:i.isElement(x))?await(i.getScale==null?void 0:i.getScale(x))||{x:1,y:1}:{x:1,y:1},P=Qi(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:x,strategy:d}):v);return{top:(w.top-P.top+g.top)/N.y,bottom:(P.bottom-w.bottom+g.bottom)/N.y,left:(w.left-P.left+g.left)/N.x,right:(P.right-w.right+g.right)/N.x}}const Ow=50,Iw=async(e,t,r)=>{const{placement:n="bottom",strategy:o="absolute",middleware:i=[],platform:s}=r,a=s.detectOverflow?s:{...s,detectOverflow:Pw},d=await(s.isRTL==null?void 0:s.isRTL(t));let u=await s.getElementRects({reference:e,floating:t,strategy:o}),{x:l,y:f}=Tu(u,n,d),p=n,m=0;const g={};for(let h=0;h<i.length;h++){const y=i[h];if(!y)continue;const{name:w,fn:v}=y,{x,y:N,data:P,reset:E}=await v({x:l,y:f,initialPlacement:n,placement:p,strategy:o,middlewareData:g,rects:u,platform:a,elements:{reference:e,floating:t}});l=x??l,f=N??f,g[w]={...g[w],...P},E&&m<Ow&&(m++,typeof E=="object"&&(E.placement&&(p=E.placement),E.rects&&(u=E.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:o}):E.rects),{x:l,y:f}=Tu(u,p,d)),h=-1)}return{x:l,y:f,placement:p,strategy:o,middlewareData:g}},Mw=e=>({name:"arrow",options:e,async fn(t){const{x:r,y:n,placement:o,rects:i,platform:s,elements:a,middlewareData:d}=t,{element:u,padding:l=0}=dn(e,t)||{};if(u==null)return{};const f=ku(l),p={x:r,y:n},m=Za(o),g=Qa(m),h=await s.getDimensions(u),y=m==="y",w=y?"top":"left",v=y?"bottom":"right",x=y?"clientHeight":"clientWidth",N=i.reference[g]+i.reference[m]-p[m]-i.floating[g],P=p[m]-i.reference[m],E=await(s.getOffsetParent==null?void 0:s.getOffsetParent(u));let _=E?E[x]:0;(!_||!await(s.isElement==null?void 0:s.isElement(E)))&&(_=a.floating[x]||i.floating[g]);const C=N/2-P/2,A=_/2-h[g]/2-1,O=_n(f[w],A),T=_n(f[v],A),z=O,q=_-h[g]-T,I=_/2-h[g]/2+C,$=Xa(z,I,q),M=!d.arrow&&oo(o)!=null&&I!==$&&i.reference[g]/2-(I<z?O:T)-h[g]/2<0,D=M?I<z?I-z:I-q:0;return{[m]:p[m]+D,data:{[m]:$,centerOffset:I-$-D,...M&&{alignmentOffset:D}},reset:M}}}),Lw=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:d,elements:u}=t,{mainAxis:l=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:h=!0,...y}=dn(e,t);if((r=i.arrow)!=null&&r.alignmentOffset)return{};const w=un(o),v=Qr(a),x=un(a)===a,N=await(d.isRTL==null?void 0:d.isRTL(u.floating)),P=p||(x||!h?[Ji(a)]:Ew(a)),E=g!=="none";!p&&E&&P.push(...Tw(a,h,g,N));const _=[a,...P],C=await d.detectOverflow(t,y),A=[];let O=((n=i.flip)==null?void 0:n.overflows)||[];if(l&&A.push(C[w]),f){const I=Cw(o,s,N);A.push(C[I[0]],C[I[1]])}if(O=[...O,{placement:o,overflows:A}],!A.every(I=>I<=0)){var T,z;const I=(((T=i.flip)==null?void 0:T.index)||0)+1,$=_[I];if($&&(!(f==="alignment"?v!==Qr($):!1)||O.every(L=>Qr(L.placement)===v?L.overflows[0]>0:!0)))return{data:{index:I,overflows:O},reset:{placement:$}};let M=(z=O.filter(D=>D.overflows[0]<=0).sort((D,L)=>D.overflows[1]-L.overflows[1])[0])==null?void 0:z.placement;if(!M)switch(m){case"bestFit":{var q;const D=(q=O.filter(L=>{if(E){const U=Qr(L.placement);return U===v||U==="y"}return!0}).map(L=>[L.placement,L.overflows.filter(U=>U>0).reduce((U,j)=>U+j,0)]).sort((L,U)=>L[1]-U[1])[0])==null?void 0:q[0];D&&(M=D);break}case"initialPlacement":M=a;break}if(o!==M)return{reset:{placement:M}}}return{}}}};function Fu(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Pu(e){return xw.some(t=>e[t]>=0)}const Dw=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:r,platform:n}=t,{strategy:o="referenceHidden",...i}=dn(e,t);switch(o){case"referenceHidden":{const s=await n.detectOverflow(t,{...i,elementContext:"reference"}),a=Fu(s,r.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Pu(a)}}}case"escaped":{const s=await n.detectOverflow(t,{...i,altBoundary:!0}),a=Fu(s,r.floating);return{data:{escapedOffsets:a,escaped:Pu(a)}}}default:return{}}}}},Ou=new Set(["left","top"]);async function Bw(e,t){const{placement:r,platform:n,elements:o}=e,i=await(n.isRTL==null?void 0:n.isRTL(o.floating)),s=un(r),a=oo(r),d=Qr(r)==="y",u=Ou.has(s)?-1:1,l=i&&d?-1:1,f=dn(t,e);let{mainAxis:p,crossAxis:m,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof g=="number"&&(m=a==="end"?g*-1:g),d?{x:m*l,y:p*u}:{x:p*u,y:m*l}}const $w=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,d=await Bw(t,e);return s===((r=a.offset)==null?void 0:r.placement)&&(n=a.arrow)!=null&&n.alignmentOffset?{}:{x:o+d.x,y:i+d.y,data:{...d,placement:s}}}}},jw=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:d={fn:w=>{let{x:v,y:x}=w;return{x:v,y:x}}},...u}=dn(e,t),l={x:r,y:n},f=await i.detectOverflow(t,u),p=Qr(un(o)),m=Ja(p);let g=l[m],h=l[p];if(s){const w=m==="y"?"top":"left",v=m==="y"?"bottom":"right",x=g+f[w],N=g-f[v];g=Xa(x,g,N)}if(a){const w=p==="y"?"top":"left",v=p==="y"?"bottom":"right",x=h+f[w],N=h-f[v];h=Xa(x,h,N)}const y=d.fn({...t,[m]:g,[p]:h});return{...y,data:{x:y.x-r,y:y.y-n,enabled:{[m]:s,[p]:a}}}}}},zw=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:d=!0,crossAxis:u=!0}=dn(e,t),l={x:r,y:n},f=Qr(o),p=Ja(f);let m=l[p],g=l[f];const h=dn(a,t),y=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(d){const x=p==="y"?"height":"width",N=i.reference[p]-i.floating[x]+y.mainAxis,P=i.reference[p]+i.reference[x]-y.mainAxis;m<N?m=N:m>P&&(m=P)}if(u){var w,v;const x=p==="y"?"width":"height",N=Ou.has(un(o)),P=i.reference[f]-i.floating[x]+(N&&((w=s.offset)==null?void 0:w[f])||0)+(N?0:y.crossAxis),E=i.reference[f]+i.reference[x]+(N?0:((v=s.offset)==null?void 0:v[f])||0)-(N?y.crossAxis:0);g<P?g=P:g>E&&(g=E)}return{[p]:m,[f]:g}}}},Uw=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:d=()=>{},...u}=dn(e,t),l=await s.detectOverflow(t,u),f=un(o),p=oo(o),m=Qr(o)==="y",{width:g,height:h}=i.floating;let y,w;f==="top"||f==="bottom"?(y=f,w=p===(await(s.isRTL==null?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(w=f,y=p==="end"?"top":"bottom");const v=h-l.top-l.bottom,x=g-l.left-l.right,N=_n(h-l[y],v),P=_n(g-l[w],x),E=!t.middlewareData.shift;let _=N,C=P;if((r=t.middlewareData.shift)!=null&&r.enabled.x&&(C=x),(n=t.middlewareData.shift)!=null&&n.enabled.y&&(_=v),E&&!p){const O=Ar(l.left,0),T=Ar(l.right,0),z=Ar(l.top,0),q=Ar(l.bottom,0);m?C=g-2*(O!==0||T!==0?O+T:Ar(l.left,l.right)):_=h-2*(z!==0||q!==0?z+q:Ar(l.top,l.bottom))}await d({...t,availableWidth:C,availableHeight:_});const A=await s.getDimensions(a.floating);return g!==A.width||h!==A.height?{reset:{rects:!0}}:{}}}};function Zi(){return typeof window<"u"}function io(e){return Iu(e)?(e.nodeName||"").toLowerCase():"#document"}function Cr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Zr(e){var t;return(t=(Iu(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Iu(e){return Zi()?e instanceof Node||e instanceof Cr(e).Node:!1}function zr(e){return Zi()?e instanceof Element||e instanceof Cr(e).Element:!1}function fn(e){return Zi()?e instanceof HTMLElement||e instanceof Cr(e).HTMLElement:!1}function Mu(e){return!Zi()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Cr(e).ShadowRoot}function Qo(e){const{overflow:t,overflowX:r,overflowY:n,display:o}=Ur(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+r)&&o!=="inline"&&o!=="contents"}function Vw(e){return/^(table|td|th)$/.test(io(e))}function es(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Hw=/transform|translate|scale|rotate|perspective|filter/,Ww=/paint|layout|strict|content/,Un=e=>!!e&&e!=="none";let tl;function rl(e){const t=zr(e)?Ur(e):e;return Un(t.transform)||Un(t.translate)||Un(t.scale)||Un(t.rotate)||Un(t.perspective)||!nl()&&(Un(t.backdropFilter)||Un(t.filter))||Hw.test(t.willChange||"")||Ww.test(t.contain||"")}function Rw(e){let t=kn(e);for(;fn(t)&&!so(t);){if(rl(t))return t;if(es(t))return null;t=kn(t)}return null}function nl(){return tl==null&&(tl=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),tl}function so(e){return/^(html|body|#document)$/.test(io(e))}function Ur(e){return Cr(e).getComputedStyle(e)}function ts(e){return zr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function kn(e){if(io(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Mu(e)&&e.host||Zr(e);return Mu(t)?t.host:t}function Lu(e){const t=kn(e);return so(t)?e.ownerDocument?e.ownerDocument.body:e.body:fn(t)&&Qo(t)?t:Lu(t)}function Zo(e,t,r){var n;t===void 0&&(t=[]),r===void 0&&(r=!0);const o=Lu(e),i=o===((n=e.ownerDocument)==null?void 0:n.body),s=Cr(o);if(i){const a=ol(s);return t.concat(s,s.visualViewport||[],Qo(o)?o:[],a&&r?Zo(a):[])}else return t.concat(o,Zo(o,[],r))}function ol(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Du(e){const t=Ur(e);let r=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const o=fn(e),i=o?e.offsetWidth:r,s=o?e.offsetHeight:n,a=Yi(r)!==i||Yi(n)!==s;return a&&(r=i,n=s),{width:r,height:n,$:a}}function il(e){return zr(e)?e:e.contextElement}function ao(e){const t=il(e);if(!fn(t))return Jr(1);const r=t.getBoundingClientRect(),{width:n,height:o,$:i}=Du(t);let s=(i?Yi(r.width):r.width)/n,a=(i?Yi(r.height):r.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}const Gw=Jr(0);function Bu(e){const t=Cr(e);return!nl()||!t.visualViewport?Gw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Kw(e,t,r){return t===void 0&&(t=!1),!r||t&&r!==Cr(e)?!1:t}function Vn(e,t,r,n){t===void 0&&(t=!1),r===void 0&&(r=!1);const o=e.getBoundingClientRect(),i=il(e);let s=Jr(1);t&&(n?zr(n)&&(s=ao(n)):s=ao(e));const a=Kw(i,r,n)?Bu(i):Jr(0);let d=(o.left+a.x)/s.x,u=(o.top+a.y)/s.y,l=o.width/s.x,f=o.height/s.y;if(i){const p=Cr(i),m=n&&zr(n)?Cr(n):n;let g=p,h=ol(g);for(;h&&n&&m!==g;){const y=ao(h),w=h.getBoundingClientRect(),v=Ur(h),x=w.left+(h.clientLeft+parseFloat(v.paddingLeft))*y.x,N=w.top+(h.clientTop+parseFloat(v.paddingTop))*y.y;d*=y.x,u*=y.y,l*=y.x,f*=y.y,d+=x,u+=N,g=Cr(h),h=ol(g)}}return Qi({width:l,height:f,x:d,y:u})}function rs(e,t){const r=ts(e).scrollLeft;return t?t.left+r:Vn(Zr(e)).left+r}function $u(e,t){const r=e.getBoundingClientRect(),n=r.left+t.scrollLeft-rs(e,r),o=r.top+t.scrollTop;return{x:n,y:o}}function qw(e){let{elements:t,rect:r,offsetParent:n,strategy:o}=e;const i=o==="fixed",s=Zr(n),a=t?es(t.floating):!1;if(n===s||a&&i)return r;let d={scrollLeft:0,scrollTop:0},u=Jr(1);const l=Jr(0),f=fn(n);if((f||!f&&!i)&&((io(n)!=="body"||Qo(s))&&(d=ts(n)),f)){const m=Vn(n);u=ao(n),l.x=m.x+n.clientLeft,l.y=m.y+n.clientTop}const p=s&&!f&&!i?$u(s,d):Jr(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-d.scrollLeft*u.x+l.x+p.x,y:r.y*u.y-d.scrollTop*u.y+l.y+p.y}}function Yw(e){return Array.from(e.getClientRects())}function Xw(e){const t=Zr(e),r=ts(e),n=e.ownerDocument.body,o=Ar(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),i=Ar(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let s=-r.scrollLeft+rs(e);const a=-r.scrollTop;return Ur(n).direction==="rtl"&&(s+=Ar(t.clientWidth,n.clientWidth)-o),{width:o,height:i,x:s,y:a}}const ju=25;function Jw(e,t){const r=Cr(e),n=Zr(e),o=r.visualViewport;let i=n.clientWidth,s=n.clientHeight,a=0,d=0;if(o){i=o.width,s=o.height;const l=nl();(!l||l&&t==="fixed")&&(a=o.offsetLeft,d=o.offsetTop)}const u=rs(n);if(u<=0){const l=n.ownerDocument,f=l.body,p=getComputedStyle(f),m=l.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,g=Math.abs(n.clientWidth-f.clientWidth-m);g<=ju&&(i-=g)}else u<=ju&&(i+=u);return{width:i,height:s,x:a,y:d}}function Qw(e,t){const r=Vn(e,!0,t==="fixed"),n=r.top+e.clientTop,o=r.left+e.clientLeft,i=fn(e)?ao(e):Jr(1),s=e.clientWidth*i.x,a=e.clientHeight*i.y,d=o*i.x,u=n*i.y;return{width:s,height:a,x:d,y:u}}function zu(e,t,r){let n;if(t==="viewport")n=Jw(e,r);else if(t==="document")n=Xw(Zr(e));else if(zr(t))n=Qw(t,r);else{const o=Bu(e);n={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Qi(n)}function Uu(e,t){const r=kn(e);return r===t||!zr(r)||so(r)?!1:Ur(r).position==="fixed"||Uu(r,t)}function Zw(e,t){const r=t.get(e);if(r)return r;let n=Zo(e,[],!1).filter(a=>zr(a)&&io(a)!=="body"),o=null;const i=Ur(e).position==="fixed";let s=i?kn(e):e;for(;zr(s)&&!so(s);){const a=Ur(s),d=rl(s);!d&&a.position==="fixed"&&(o=null),(i?!d&&!o:!d&&a.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Qo(s)&&!d&&Uu(e,s))?n=n.filter(l=>l!==s):o=a,s=kn(s)}return t.set(e,n),n}function eS(e){let{element:t,boundary:r,rootBoundary:n,strategy:o}=e;const s=[...r==="clippingAncestors"?es(t)?[]:Zw(t,this._c):[].concat(r),n],a=zu(t,s[0],o);let d=a.top,u=a.right,l=a.bottom,f=a.left;for(let p=1;p<s.length;p++){const m=zu(t,s[p],o);d=Ar(m.top,d),u=_n(m.right,u),l=_n(m.bottom,l),f=Ar(m.left,f)}return{width:u-f,height:l-d,x:f,y:d}}function tS(e){const{width:t,height:r}=Du(e);return{width:t,height:r}}function rS(e,t,r){const n=fn(t),o=Zr(t),i=r==="fixed",s=Vn(e,!0,i,t);let a={scrollLeft:0,scrollTop:0};const d=Jr(0);function u(){d.x=rs(o)}if(n||!n&&!i)if((io(t)!=="body"||Qo(o))&&(a=ts(t)),n){const m=Vn(t,!0,i,t);d.x=m.x+t.clientLeft,d.y=m.y+t.clientTop}else o&&u();i&&!n&&o&&u();const l=o&&!n&&!i?$u(o,a):Jr(0),f=s.left+a.scrollLeft-d.x-l.x,p=s.top+a.scrollTop-d.y-l.y;return{x:f,y:p,width:s.width,height:s.height}}function sl(e){return Ur(e).position==="static"}function Vu(e,t){if(!fn(e)||Ur(e).position==="fixed")return null;if(t)return t(e);let r=e.offsetParent;return Zr(e)===r&&(r=r.ownerDocument.body),r}function Hu(e,t){const r=Cr(e);if(es(e))return r;if(!fn(e)){let o=kn(e);for(;o&&!so(o);){if(zr(o)&&!sl(o))return o;o=kn(o)}return r}let n=Vu(e,t);for(;n&&Vw(n)&&sl(n);)n=Vu(n,t);return n&&so(n)&&sl(n)&&!rl(n)?r:n||Rw(e)||r}const nS=async function(e){const t=this.getOffsetParent||Hu,r=this.getDimensions,n=await r(e.floating);return{reference:rS(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function oS(e){return Ur(e).direction==="rtl"}const iS={convertOffsetParentRelativeRectToViewportRelativeRect:qw,getDocumentElement:Zr,getClippingRect:eS,getOffsetParent:Hu,getElementRects:nS,getClientRects:Yw,getDimensions:tS,getScale:ao,isElement:zr,isRTL:oS};function Wu(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function sS(e,t){let r=null,n;const o=Zr(e);function i(){var a;clearTimeout(n),(a=r)==null||a.disconnect(),r=null}function s(a,d){a===void 0&&(a=!1),d===void 0&&(d=1),i();const u=e.getBoundingClientRect(),{left:l,top:f,width:p,height:m}=u;if(a||t(),!p||!m)return;const g=Xi(f),h=Xi(o.clientWidth-(l+p)),y=Xi(o.clientHeight-(f+m)),w=Xi(l),x={rootMargin:-g+"px "+-h+"px "+-y+"px "+-w+"px",threshold:Ar(0,_n(1,d))||1};let N=!0;function P(E){const _=E[0].intersectionRatio;if(_!==d){if(!N)return s();_?s(!1,_):n=setTimeout(()=>{s(!1,1e-7)},1e3)}_===1&&!Wu(u,e.getBoundingClientRect())&&s(),N=!1}try{r=new IntersectionObserver(P,{...x,root:o.ownerDocument})}catch{r=new IntersectionObserver(P,x)}r.observe(e)}return s(!0),i}function aS(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:d=!1}=n,u=il(e),l=o||i?[...u?Zo(u):[],...t?Zo(t):[]]:[];l.forEach(w=>{o&&w.addEventListener("scroll",r,{passive:!0}),i&&w.addEventListener("resize",r)});const f=u&&a?sS(u,r):null;let p=-1,m=null;s&&(m=new ResizeObserver(w=>{let[v]=w;v&&v.target===u&&m&&t&&(m.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var x;(x=m)==null||x.observe(t)})),r()}),u&&!d&&m.observe(u),t&&m.observe(t));let g,h=d?Vn(e):null;d&&y();function y(){const w=Vn(e);h&&!Wu(h,w)&&r(),h=w,g=requestAnimationFrame(y)}return r(),()=>{var w;l.forEach(v=>{o&&v.removeEventListener("scroll",r),i&&v.removeEventListener("resize",r)}),f?.(),(w=m)==null||w.disconnect(),m=null,d&&cancelAnimationFrame(g)}}const lS=$w,cS=jw,dS=Lw,uS=Uw,fS=Dw,Ru=Mw,pS=zw,mS=(e,t,r)=>{const n=new Map,o={platform:iS,...r},i={...o.platform,_c:n};return Iw(e,t,{...o,platform:i})};var hS=typeof document<"u",gS=function(){},ns=hS?S.useLayoutEffect:gS;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 Gu(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ku(e,t){const r=Gu(e);return Math.round(t*r)/r}function al(e){const t=b.useRef(e);return ns(()=>{t.current=e}),t}function yS(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:d,open:u}=e,[l,f]=b.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=b.useState(n);os(p,n)||m(n);const[g,h]=b.useState(null),[y,w]=b.useState(null),v=b.useCallback(L=>{L!==E.current&&(E.current=L,h(L))},[]),x=b.useCallback(L=>{L!==_.current&&(_.current=L,w(L))},[]),N=i||g,P=s||y,E=b.useRef(null),_=b.useRef(null),C=b.useRef(l),A=d!=null,O=al(d),T=al(o),z=al(u),q=b.useCallback(()=>{if(!E.current||!_.current)return;const L={placement:t,strategy:r,middleware:p};T.current&&(L.platform=T.current),mS(E.current,_.current,L).then(U=>{const j={...U,isPositioned:z.current!==!1};I.current&&!os(C.current,j)&&(C.current=j,ki.flushSync(()=>{f(j)}))})},[p,t,r,T,z]);ns(()=>{u===!1&&C.current.isPositioned&&(C.current.isPositioned=!1,f(L=>({...L,isPositioned:!1})))},[u]);const I=b.useRef(!1);ns(()=>(I.current=!0,()=>{I.current=!1}),[]),ns(()=>{if(N&&(E.current=N),P&&(_.current=P),N&&P){if(O.current)return O.current(N,P,q);q()}},[N,P,q,O,A]);const $=b.useMemo(()=>({reference:E,floating:_,setReference:v,setFloating:x}),[v,x]),M=b.useMemo(()=>({reference:N,floating:P}),[N,P]),D=b.useMemo(()=>{const L={position:r,left:0,top:0};if(!M.floating)return L;const U=Ku(M.floating,l.x),j=Ku(M.floating,l.y);return a?{...L,transform:"translate("+U+"px, "+j+"px)",...Gu(M.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:U,top:j}},[r,a,M.floating,l.x,l.y]);return b.useMemo(()=>({...l,update:q,refs:$,elements:M,floatingStyles:D}),[l,q,$,M,D])}const bS=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?Ru({element:n.current,padding:o}).fn(r):{}:n?Ru({element:n,padding:o}).fn(r):{}}}},vS=(e,t)=>{const r=lS(e);return{name:r.name,fn:r.fn,options:[e,t]}},wS=(e,t)=>{const r=cS(e);return{name:r.name,fn:r.fn,options:[e,t]}},SS=(e,t)=>({fn:pS(e).fn,options:[e,t]}),xS=(e,t)=>{const r=dS(e);return{name:r.name,fn:r.fn,options:[e,t]}},AS=(e,t)=>{const r=uS(e);return{name:r.name,fn:r.fn,options:[e,t]}},CS=(e,t)=>{const r=fS(e);return{name:r.name,fn:r.fn,options:[e,t]}},ES=(e,t)=>{const r=bS(e);return{name:r.name,fn:r.fn,options:[e,t]}};var NS="Arrow",qu=b.forwardRef((e,t)=>{const{children:r,width:n=10,height:o=5,...i}=e;return c.jsx($e.svg,{...i,ref:t,width:n,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:c.jsx("polygon",{points:"0,0 30,0 15,10"})})});qu.displayName=NS;var _S=qu;function ei(e){const[t,r]=b.useState(void 0);return er(()=>{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 d=i.borderBoxSize,u=Array.isArray(d)?d[0]:d;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 ll="Popper",[Yu,is]=xr(ll),[kS,Xu]=Yu(ll),Ju=e=>{const{__scopePopper:t,children:r}=e,[n,o]=b.useState(null);return c.jsx(kS,{scope:t,anchor:n,onAnchorChange:o,children:r})};Ju.displayName=ll;var Qu="PopperAnchor",Zu=b.forwardRef((e,t)=>{const{__scopePopper:r,virtualRef:n,...o}=e,i=Xu(Qu,r),s=b.useRef(null),a=Ze(t,s),d=b.useRef(null);return b.useEffect(()=>{const u=d.current;d.current=n?.current||s.current,u!==d.current&&i.onAnchorChange(d.current)}),n?null:c.jsx($e.div,{...o,ref:a})});Zu.displayName=Qu;var cl="PopperContent",[TS,FS]=Yu(cl),ef=b.forwardRef((e,t)=>{const{__scopePopper:r,side:n="bottom",sideOffset:o=0,align:i="center",alignOffset:s=0,arrowPadding:a=0,avoidCollisions:d=!0,collisionBoundary:u=[],collisionPadding:l=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:g,...h}=e,y=Xu(cl,r),[w,v]=b.useState(null),x=Ze(t,K=>v(K)),[N,P]=b.useState(null),E=ei(N),_=E?.width??0,C=E?.height??0,A=n+(i!=="center"?"-"+i:""),O=typeof l=="number"?l:{top:0,right:0,bottom:0,left:0,...l},T=Array.isArray(u)?u:[u],z=T.length>0,q={padding:O,boundary:T.filter(OS),altBoundary:z},{refs:I,floatingStyles:$,placement:M,isPositioned:D,middlewareData:L}=yS({strategy:"fixed",placement:A,whileElementsMounted:(...K)=>aS(...K,{animationFrame:m==="always"}),elements:{reference:y.anchor},middleware:[vS({mainAxis:o+C,alignmentAxis:s}),d&&wS({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?SS():void 0,...q}),d&&xS({...q}),AS({...q,apply:({elements:K,rects:re,availableWidth:Te,availableHeight:Z})=>{const{width:te,height:he}=re.reference,le=K.floating.style;le.setProperty("--radix-popper-available-width",`${Te}px`),le.setProperty("--radix-popper-available-height",`${Z}px`),le.setProperty("--radix-popper-anchor-width",`${te}px`),le.setProperty("--radix-popper-anchor-height",`${he}px`)}}),N&&ES({element:N,padding:a}),IS({arrowWidth:_,arrowHeight:C}),p&&CS({strategy:"referenceHidden",...q})]}),[U,j]=nf(M),se=ar(g);er(()=>{D&&se?.()},[D,se]);const H=L.arrow?.x,G=L.arrow?.y,ee=L.arrow?.centerOffset!==0,[de,ne]=b.useState();return er(()=>{w&&ne(window.getComputedStyle(w).zIndex)},[w]),c.jsx("div",{ref:I.setFloating,"data-radix-popper-content-wrapper":"",style:{...$,transform:D?$.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:de,"--radix-popper-transform-origin":[L.transformOrigin?.x,L.transformOrigin?.y].join(" "),...L.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(TS,{scope:r,placedSide:U,onArrowChange:P,arrowX:H,arrowY:G,shouldHideArrow:ee,children:c.jsx($e.div,{"data-side":U,"data-align":j,...h,ref:x,style:{...h.style,animation:D?void 0:"none"}})})})});ef.displayName=cl;var tf="PopperArrow",PS={top:"bottom",right:"left",bottom:"top",left:"right"},rf=b.forwardRef(function(t,r){const{__scopePopper:n,...o}=t,i=FS(tf,n),s=PS[i.placedSide];return c.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:c.jsx(_S,{...o,ref:r,style:{...o.style,display:"block"}})})});rf.displayName=tf;function OS(e){return e!==null}var IS=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,d=s?0:e.arrowHeight,[u,l]=nf(r),f={start:"0%",center:"50%",end:"100%"}[l],p=(o.arrow?.x??0)+a/2,m=(o.arrow?.y??0)+d/2;let g="",h="";return u==="bottom"?(g=s?f:`${p}px`,h=`${-d}px`):u==="top"?(g=s?f:`${p}px`,h=`${n.floating.height+d}px`):u==="right"?(g=`${-d}px`,h=s?f:`${m}px`):u==="left"&&(g=`${n.floating.width+d}px`,h=s?f:`${m}px`),{data:{x:g,y:h}}}});function nf(e){const[t,r="center"]=e.split("-");return[t,r]}var of=Ju,dl=Zu,sf=ef,af=rf,MS="Portal",ss=b.forwardRef((e,t)=>{const{container:r,...n}=e,[o,i]=b.useState(!1);er(()=>i(!0),[]);const s=r||o&&globalThis?.document?.body;return s?nd.createPortal(c.jsx($e.div,{...n,ref:t}),s):null});ss.displayName=MS;function LS(e){const t=DS(e),r=b.forwardRef((n,o)=>{const{children:i,...s}=n,a=b.Children.toArray(i),d=a.find($S);if(d){const u=d.props.children,l=a.map(f=>f===d?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:f);return c.jsx(t,{...s,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...s,ref:o,children:i})});return r.displayName=`${e}.Slot`,r}function DS(e){const t=b.forwardRef((r,n)=>{const{children:o,...i}=r;if(b.isValidElement(o)){const s=zS(o),a=jS(i,o.props);return o.type!==b.Fragment&&(a.ref=n?zn(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 BS=Symbol("radix.slottable");function $S(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===BS}function jS(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 d=i(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...i}:n==="className"&&(r[n]=[o,i].filter(Boolean).join(" "))}return{...e,...r}}function zS(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 US=b[" useInsertionEffect ".trim().toString()]||er;function en({prop:e,defaultProp:t,onChange:r=()=>{},caller:n}){const[o,i,s]=VS({defaultProp:t,onChange:r}),a=e!==void 0,d=a?e:o;{const l=b.useRef(e!==void 0);b.useEffect(()=>{const f=l.current;f!==a&&console.warn(`${n} is changing from ${f?"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.`),l.current=a},[a,n])}const u=b.useCallback(l=>{if(a){const f=HS(l)?l(e):l;f!==e&&s.current?.(f)}else i(l)},[a,e,i,s]);return[d,u]}function VS({defaultProp:e,onChange:t}){const[r,n]=b.useState(e),o=b.useRef(r),i=b.useRef(t);return US(()=>{i.current=t},[t]),b.useEffect(()=>{o.current!==r&&(i.current?.(r),o.current=r)},[r,o]),[r,n,i]}function HS(e){return typeof e=="function"}function ti(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 lf=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"}),WS="VisuallyHidden",RS=b.forwardRef((e,t)=>c.jsx($e.span,{...e,ref:t,style:{...lf,...e.style}}));RS.displayName=WS;var GS=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},lo=new WeakMap,as=new WeakMap,ls={},ul=0,cf=function(e){return e&&(e.host||cf(e.parentNode))},KS=function(e,t){return t.map(function(r){if(e.contains(r))return r;var n=cf(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})},qS=function(e,t,r,n){var o=KS(t,Array.isArray(e)?e:[e]);ls[r]||(ls[r]=new WeakMap);var i=ls[r],s=[],a=new Set,d=new Set(o),u=function(f){!f||a.has(f)||(a.add(f),u(f.parentNode))};o.forEach(u);var l=function(f){!f||d.has(f)||Array.prototype.forEach.call(f.children,function(p){if(a.has(p))l(p);else try{var m=p.getAttribute(n),g=m!==null&&m!=="false",h=(lo.get(p)||0)+1,y=(i.get(p)||0)+1;lo.set(p,h),i.set(p,y),s.push(p),h===1&&g&&as.set(p,!0),y===1&&p.setAttribute(r,"true"),g||p.setAttribute(n,"true")}catch(w){console.error("aria-hidden: cannot operate on ",p,w)}})};return l(t),a.clear(),ul++,function(){s.forEach(function(f){var p=lo.get(f)-1,m=i.get(f)-1;lo.set(f,p),i.set(f,m),p||(as.has(f)||f.removeAttribute(n),as.delete(f)),m||f.removeAttribute(r)}),ul--,ul||(lo=new WeakMap,lo=new WeakMap,as=new WeakMap,ls={})}},fl=function(e,t,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(e)?e:[e]),o=GS(e);return o?(n.push.apply(n,Array.from(o.querySelectorAll("[aria-live], script"))),qS(n,o,r,"aria-hidden")):function(){return null}},tn=function(){return tn=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},tn.apply(this,arguments)};function df(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 YS(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 cs="right-scroll-bar-position",ds="width-before-scroll-bar",XS="with-scroll-bars-hidden",JS="--removed-body-scroll-bar-size";function pl(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function QS(e,t){var r=S.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 ZS=typeof window<"u"?b.useLayoutEffect:b.useEffect,uf=new WeakMap;function ex(e,t){var r=QS(null,function(n){return e.forEach(function(o){return pl(o,n)})});return ZS(function(){var n=uf.get(r);if(n){var o=new Set(n),i=new Set(e),s=r.current;o.forEach(function(a){i.has(a)||pl(a,null)}),i.forEach(function(a){o.has(a)||pl(a,s)})}uf.set(r,e)},[e]),r}function tx(e){return e}function rx(e,t){t===void 0&&(t=tx);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 d=function(){var l=s;s=[],l.forEach(i)},u=function(){return Promise.resolve().then(d)};u(),r={push:function(l){s.push(l),u()},filter:function(l){return s=s.filter(l),r}}}};return o}function nx(e){e===void 0&&(e={});var t=rx(null);return t.options=tn({async:!0,ssr:!1},e),t}var ff=function(e){var t=e.sideCar,r=df(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,tn({},r))};ff.isSideCarExport=!0;function ox(e,t){return e.useMedium(t),ff}var pf=nx(),ml=function(){},us=b.forwardRef(function(e,t){var r=b.useRef(null),n=b.useState({onScrollCapture:ml,onWheelCapture:ml,onTouchMoveCapture:ml}),o=n[0],i=n[1],s=e.forwardProps,a=e.children,d=e.className,u=e.removeScrollBar,l=e.enabled,f=e.shards,p=e.sideCar,m=e.noRelative,g=e.noIsolation,h=e.inert,y=e.allowPinchZoom,w=e.as,v=w===void 0?"div":w,x=e.gapMode,N=df(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),P=p,E=ex([r,t]),_=tn(tn({},N),o);return b.createElement(b.Fragment,null,l&&b.createElement(P,{sideCar:pf,removeScrollBar:u,shards:f,noRelative:m,noIsolation:g,inert:h,setCallbacks:i,allowPinchZoom:!!y,lockRef:r,gapMode:x}),s?b.cloneElement(b.Children.only(a),tn(tn({},_),{ref:E})):b.createElement(v,tn({},_,{className:d,ref:E}),a))});us.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},us.classNames={fullWidth:ds,zeroRight:cs};var ix=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function sx(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=ix();return t&&e.setAttribute("nonce",t),e}function ax(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function lx(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var cx=function(){var e=0,t=null;return{add:function(r){e==0&&(t=sx())&&(ax(t,r),lx(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},dx=function(){var e=cx();return function(t,r){b.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&r])}},mf=function(){var e=dx(),t=function(r){var n=r.styles,o=r.dynamic;return e(n,o),null};return t},ux={left:0,top:0,right:0,gap:0},hl=function(e){return parseInt(e||"",10)||0},fx=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[hl(r),hl(n),hl(o)]},px=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return ux;var t=fx(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])}},mx=mf(),co="data-scroll-locked",hx=function(e,t,r,n){var o=e.left,i=e.top,s=e.right,a=e.gap;return r===void 0&&(r="margin"),`
|
|
2
|
-
.`.concat(
|
|
1
|
+
(function(be,S){typeof exports=="object"&&typeof module<"u"?S(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"],S):(be=typeof globalThis<"u"?globalThis:be||self,S(be.FormBuilderRenderer={},be.React,be.jsxRuntime,be.ReactRouterDOM,be.ReactDOM,be.Sonner,be.ReactQuery))})(this,(function(be,S,c,Ea,od,Bt,vn){"use strict";function id(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=id(S),_i=id(od),Na="iq-fbr",Bn="95px";function Ti(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:Bn}}function Fi(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 sd(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=sd(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function ad(){for(var e,t,r=0,n="",o=arguments.length;r<o;r++)(e=arguments[r])&&(t=sd(e))&&(n&&(n+=" "),n+=t);return n}const Ky=(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},qy=(e,t)=>({classGroupId:e,validator:t}),ld=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),Pi="-",cd=[],Yy="arbitrary..",Xy=e=>{const t=Qy(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:s=>{if(s.startsWith("[")&&s.endsWith("]"))return Jy(s);const a=s.split(Pi),d=a[0]===""&&a.length>1?1:0;return dd(a,d,t)},getConflictingClassGroupIds:(s,a)=>{if(a){const d=n[s],u=r[s];return d?u?Ky(u,d):d:u||cd}return r[s]||cd}}},dd=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const o=e[t],i=r.nextPart.get(o);if(i){const u=dd(e,t+1,i);if(u)return u}const s=r.validators;if(s===null)return;const a=t===0?e.join(Pi):e.slice(t).join(Pi),d=s.length;for(let u=0;u<d;u++){const l=s[u];if(l.validator(a))return l.classGroupId}},Jy=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?Yy+n:void 0})(),Qy=e=>{const{theme:t,classGroups:r}=e;return Zy(r,t)},Zy=(e,t)=>{const r=ld();for(const n in e){const o=e[n];ka(o,r,n,t)}return r},ka=(e,t,r,n)=>{const o=e.length;for(let i=0;i<o;i++){const s=e[i];eb(s,t,r,n)}},eb=(e,t,r,n)=>{if(typeof e=="string"){tb(e,t,r);return}if(typeof e=="function"){rb(e,t,r,n);return}nb(e,t,r,n)},tb=(e,t,r)=>{const n=e===""?t:ud(t,e);n.classGroupId=r},rb=(e,t,r,n)=>{if(ob(e)){ka(e(n),t,r,n);return}t.validators===null&&(t.validators=[]),t.validators.push(qy(r,e))},nb=(e,t,r,n)=>{const o=Object.entries(e),i=o.length;for(let s=0;s<i;s++){const[a,d]=o[s];ka(d,ud(t,a),r,n)}},ud=(e,t)=>{let r=e;const n=t.split(Pi),o=n.length;for(let i=0;i<o;i++){const s=n[i];let a=r.nextPart.get(s);a||(a=ld(),r.nextPart.set(s,a)),r=a}return r},ob=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,ib=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)}}},_a="!",fd=":",sb=[],pd=(e,t,r,n,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:n,isExternal:o}),ab=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=o=>{const i=[];let s=0,a=0,d=0,u;const l=o.length;for(let h=0;h<l;h++){const y=o[h];if(s===0&&a===0){if(y===fd){i.push(o.slice(d,h)),d=h+1;continue}if(y==="/"){u=h;continue}}y==="["?s++:y==="]"?s--:y==="("?a++:y===")"&&a--}const f=i.length===0?o:o.slice(d);let p=f,m=!1;f.endsWith(_a)?(p=f.slice(0,-1),m=!0):f.startsWith(_a)&&(p=f.slice(1),m=!0);const g=u&&u>d?u-d:void 0;return pd(i,m,p,g)};if(t){const o=t+fd,i=n;n=s=>s.startsWith(o)?i(s.slice(o.length)):pd(sb,!1,s,void 0,!0)}if(r){const o=n;n=i=>r({className:i,parseClassName:o})}return n},lb=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]==="[",d=t.has(s);a||d?(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}},cb=e=>({cache:ib(e.cacheSize),parseClassName:ab(e),sortModifiers:lb(e),...Xy(e)}),db=/\s+/,ub=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:o,sortModifiers:i}=t,s=[],a=e.trim().split(db);let d="";for(let u=a.length-1;u>=0;u-=1){const l=a[u],{isExternal:f,modifiers:p,hasImportantModifier:m,baseClassName:g,maybePostfixModifierPosition:h}=r(l);if(f){d=l+(d.length>0?" "+d:d);continue}let y=!!h,w=n(y?g.substring(0,h):g);if(!w){if(!y){d=l+(d.length>0?" "+d:d);continue}if(w=n(g),!w){d=l+(d.length>0?" "+d:d);continue}y=!1}const v=p.length===0?"":p.length===1?p[0]:i(p).join(":"),A=m?v+_a:v,C=A+w;if(s.indexOf(C)>-1)continue;s.push(C);const F=o(w,y);for(let E=0;E<F.length;++E){const T=F[E];s.push(A+T)}d=l+(d.length>0?" "+d:d)}return d},fb=(...e)=>{let t=0,r,n,o="";for(;t<e.length;)(r=e[t++])&&(n=md(r))&&(o&&(o+=" "),o+=n);return o},md=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=md(e[n]))&&(r&&(r+=" "),r+=t);return r},pb=(e,...t)=>{let r,n,o,i;const s=d=>{const u=t.reduce((l,f)=>f(l),e());return r=cb(u),n=r.cache.get,o=r.cache.set,i=a,a(d)},a=d=>{const u=n(d);if(u)return u;const l=ub(d,r);return o(d,l),l};return i=s,(...d)=>i(fb(...d))},mb=[],Ht=e=>{const t=r=>r[e]||mb;return t.isThemeGetter=!0,t},hd=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,gd=/^\((?:(\w[\w-]*):)?(.+)\)$/i,hb=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,gb=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,yb=/\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$/,bb=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,vb=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,wb=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,wn=e=>hb.test(e),at=e=>!!e&&!Number.isNaN(Number(e)),Sn=e=>!!e&&Number.isInteger(Number(e)),Ta=e=>e.endsWith("%")&&at(e.slice(0,-1)),ln=e=>gb.test(e),yd=()=>!0,Sb=e=>yb.test(e)&&!bb.test(e),Fa=()=>!1,xb=e=>vb.test(e),Ab=e=>wb.test(e),Cb=e=>!ke(e)&&!_e(e),Eb=e=>xn(e,Ad,Fa),ke=e=>hd.test(e),$n=e=>xn(e,Cd,Sb),bd=e=>xn(e,Ib,at),Nb=e=>xn(e,Nd,yd),kb=e=>xn(e,Ed,Fa),vd=e=>xn(e,Sd,Fa),_b=e=>xn(e,xd,Ab),Oi=e=>xn(e,kd,xb),_e=e=>gd.test(e),jo=e=>jn(e,Cd),Tb=e=>jn(e,Ed),wd=e=>jn(e,Sd),Fb=e=>jn(e,Ad),Pb=e=>jn(e,xd),Ii=e=>jn(e,kd,!0),Ob=e=>jn(e,Nd,!0),xn=(e,t,r)=>{const n=hd.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},jn=(e,t,r=!1)=>{const n=gd.exec(e);return n?n[1]?t(n[1]):r:!1},Sd=e=>e==="position"||e==="percentage",xd=e=>e==="image"||e==="url",Ad=e=>e==="length"||e==="size"||e==="bg-size",Cd=e=>e==="length",Ib=e=>e==="number",Ed=e=>e==="family-name",Nd=e=>e==="number"||e==="weight",kd=e=>e==="shadow",Mb=pb(()=>{const e=Ht("color"),t=Ht("font"),r=Ht("text"),n=Ht("font-weight"),o=Ht("tracking"),i=Ht("leading"),s=Ht("breakpoint"),a=Ht("container"),d=Ht("spacing"),u=Ht("radius"),l=Ht("shadow"),f=Ht("inset-shadow"),p=Ht("text-shadow"),m=Ht("drop-shadow"),g=Ht("blur"),h=Ht("perspective"),y=Ht("aspect"),w=Ht("ease"),v=Ht("animate"),A=()=>["auto","avoid","all","avoid-page","page","left","right","column"],C=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],F=()=>[...C(),_e,ke],E=()=>["auto","hidden","clip","visible","scroll"],T=()=>["auto","contain","none"],N=()=>[_e,ke,d],x=()=>[wn,"full","auto",...N()],O=()=>[Sn,"none","subgrid",_e,ke],k=()=>["auto",{span:["full",Sn,_e,ke]},Sn,_e,ke],D=()=>[Sn,"auto",_e,ke],R=()=>["auto","min","max","fr",_e,ke],I=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],z=()=>["start","end","center","stretch","center-safe","end-safe"],L=()=>["auto",...N()],B=()=>[wn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...N()],M=()=>[wn,"screen","full","dvw","lvw","svw","min","max","fit",...N()],V=()=>[wn,"screen","full","lh","dvh","lvh","svh","min","max","fit",...N()],$=()=>[e,_e,ke],ie=()=>[...C(),wd,vd,{position:[_e,ke]}],H=()=>["no-repeat",{repeat:["","x","y","space","round"]}],K=()=>["auto","cover","contain",Fb,Eb,{size:[_e,ke]}],X=()=>[Ta,jo,$n],le=()=>["","none","full",u,_e,ke],re=()=>["",at,jo,$n],q=()=>["solid","dashed","dotted","double"],ne=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Te=()=>[at,Ta,wd,vd],ee=()=>["","none",g,_e,ke],te=()=>["none",at,_e,ke],he=()=>["none",at,_e,ke],ce=()=>[at,_e,ke],Xe=()=>[wn,"full",...N()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ln],breakpoint:[ln],color:[yd],container:[ln],"drop-shadow":[ln],ease:["in","out","in-out"],font:[Cb],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ln],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ln],shadow:[ln],spacing:["px",at],text:[ln],"text-shadow":[ln],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",wn,ke,_e,y]}],container:["container"],columns:[{columns:[at,ke,_e,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:E()}],"overflow-x":[{"overflow-x":E()}],"overflow-y":[{"overflow-y":E()}],overscroll:[{overscroll:T()}],"overscroll-x":[{"overscroll-x":T()}],"overscroll-y":[{"overscroll-y":T()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:x()}],"inset-x":[{"inset-x":x()}],"inset-y":[{"inset-y":x()}],start:[{"inset-s":x(),start:x()}],end:[{"inset-e":x(),end:x()}],"inset-bs":[{"inset-bs":x()}],"inset-be":[{"inset-be":x()}],top:[{top:x()}],right:[{right:x()}],bottom:[{bottom:x()}],left:[{left:x()}],visibility:["visible","invisible","collapse"],z:[{z:[Sn,"auto",_e,ke]}],basis:[{basis:[wn,"full","auto",a,...N()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[at,wn,"auto","initial","none",ke]}],grow:[{grow:["",at,_e,ke]}],shrink:[{shrink:["",at,_e,ke]}],order:[{order:[Sn,"first","last","none",_e,ke]}],"grid-cols":[{"grid-cols":O()}],"col-start-end":[{col:k()}],"col-start":[{"col-start":D()}],"col-end":[{"col-end":D()}],"grid-rows":[{"grid-rows":O()}],"row-start-end":[{row:k()}],"row-start":[{"row-start":D()}],"row-end":[{"row-end":D()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":R()}],"auto-rows":[{"auto-rows":R()}],gap:[{gap:N()}],"gap-x":[{"gap-x":N()}],"gap-y":[{"gap-y":N()}],"justify-content":[{justify:[...I(),"normal"]}],"justify-items":[{"justify-items":[...z(),"normal"]}],"justify-self":[{"justify-self":["auto",...z()]}],"align-content":[{content:["normal",...I()]}],"align-items":[{items:[...z(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...z(),{baseline:["","last"]}]}],"place-content":[{"place-content":I()}],"place-items":[{"place-items":[...z(),"baseline"]}],"place-self":[{"place-self":["auto",...z()]}],p:[{p:N()}],px:[{px:N()}],py:[{py:N()}],ps:[{ps:N()}],pe:[{pe:N()}],pbs:[{pbs:N()}],pbe:[{pbe:N()}],pt:[{pt:N()}],pr:[{pr:N()}],pb:[{pb:N()}],pl:[{pl:N()}],m:[{m:L()}],mx:[{mx:L()}],my:[{my:L()}],ms:[{ms:L()}],me:[{me:L()}],mbs:[{mbs:L()}],mbe:[{mbe:L()}],mt:[{mt:L()}],mr:[{mr:L()}],mb:[{mb:L()}],ml:[{ml:L()}],"space-x":[{"space-x":N()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":N()}],"space-y-reverse":["space-y-reverse"],size:[{size:B()}],"inline-size":[{inline:["auto",...M()]}],"min-inline-size":[{"min-inline":["auto",...M()]}],"max-inline-size":[{"max-inline":["none",...M()]}],"block-size":[{block:["auto",...V()]}],"min-block-size":[{"min-block":["auto",...V()]}],"max-block-size":[{"max-block":["none",...V()]}],w:[{w:[a,"screen",...B()]}],"min-w":[{"min-w":[a,"screen","none",...B()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[s]},...B()]}],h:[{h:["screen","lh",...B()]}],"min-h":[{"min-h":["screen","lh","none",...B()]}],"max-h":[{"max-h":["screen","lh",...B()]}],"font-size":[{text:["base",r,jo,$n]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,Ob,Nb]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ta,ke]}],"font-family":[{font:[Tb,kb,t]}],"font-features":[{"font-features":[ke]}],"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,_e,ke]}],"line-clamp":[{"line-clamp":[at,"none",_e,bd]}],leading:[{leading:[i,...N()]}],"list-image":[{"list-image":["none",_e,ke]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",_e,ke]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:$()}],"text-color":[{text:$()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...q(),"wavy"]}],"text-decoration-thickness":[{decoration:[at,"from-font","auto",_e,$n]}],"text-decoration-color":[{decoration:$()}],"underline-offset":[{"underline-offset":[at,"auto",_e,ke]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:N()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",_e,ke]}],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",_e,ke]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:ie()}],"bg-repeat":[{bg:H()}],"bg-size":[{bg:K()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Sn,_e,ke],radial:["",_e,ke],conic:[Sn,_e,ke]},Pb,_b]}],"bg-color":[{bg:$()}],"gradient-from-pos":[{from:X()}],"gradient-via-pos":[{via:X()}],"gradient-to-pos":[{to:X()}],"gradient-from":[{from:$()}],"gradient-via":[{via:$()}],"gradient-to":[{to:$()}],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:re()}],"border-w-x":[{"border-x":re()}],"border-w-y":[{"border-y":re()}],"border-w-s":[{"border-s":re()}],"border-w-e":[{"border-e":re()}],"border-w-bs":[{"border-bs":re()}],"border-w-be":[{"border-be":re()}],"border-w-t":[{"border-t":re()}],"border-w-r":[{"border-r":re()}],"border-w-b":[{"border-b":re()}],"border-w-l":[{"border-l":re()}],"divide-x":[{"divide-x":re()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":re()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...q(),"hidden","none"]}],"divide-style":[{divide:[...q(),"hidden","none"]}],"border-color":[{border:$()}],"border-color-x":[{"border-x":$()}],"border-color-y":[{"border-y":$()}],"border-color-s":[{"border-s":$()}],"border-color-e":[{"border-e":$()}],"border-color-bs":[{"border-bs":$()}],"border-color-be":[{"border-be":$()}],"border-color-t":[{"border-t":$()}],"border-color-r":[{"border-r":$()}],"border-color-b":[{"border-b":$()}],"border-color-l":[{"border-l":$()}],"divide-color":[{divide:$()}],"outline-style":[{outline:[...q(),"none","hidden"]}],"outline-offset":[{"outline-offset":[at,_e,ke]}],"outline-w":[{outline:["",at,jo,$n]}],"outline-color":[{outline:$()}],shadow:[{shadow:["","none",l,Ii,Oi]}],"shadow-color":[{shadow:$()}],"inset-shadow":[{"inset-shadow":["none",f,Ii,Oi]}],"inset-shadow-color":[{"inset-shadow":$()}],"ring-w":[{ring:re()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:$()}],"ring-offset-w":[{"ring-offset":[at,$n]}],"ring-offset-color":[{"ring-offset":$()}],"inset-ring-w":[{"inset-ring":re()}],"inset-ring-color":[{"inset-ring":$()}],"text-shadow":[{"text-shadow":["none",p,Ii,Oi]}],"text-shadow-color":[{"text-shadow":$()}],opacity:[{opacity:[at,_e,ke]}],"mix-blend":[{"mix-blend":[...ne(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ne()}],"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":[at]}],"mask-image-linear-from-pos":[{"mask-linear-from":Te()}],"mask-image-linear-to-pos":[{"mask-linear-to":Te()}],"mask-image-linear-from-color":[{"mask-linear-from":$()}],"mask-image-linear-to-color":[{"mask-linear-to":$()}],"mask-image-t-from-pos":[{"mask-t-from":Te()}],"mask-image-t-to-pos":[{"mask-t-to":Te()}],"mask-image-t-from-color":[{"mask-t-from":$()}],"mask-image-t-to-color":[{"mask-t-to":$()}],"mask-image-r-from-pos":[{"mask-r-from":Te()}],"mask-image-r-to-pos":[{"mask-r-to":Te()}],"mask-image-r-from-color":[{"mask-r-from":$()}],"mask-image-r-to-color":[{"mask-r-to":$()}],"mask-image-b-from-pos":[{"mask-b-from":Te()}],"mask-image-b-to-pos":[{"mask-b-to":Te()}],"mask-image-b-from-color":[{"mask-b-from":$()}],"mask-image-b-to-color":[{"mask-b-to":$()}],"mask-image-l-from-pos":[{"mask-l-from":Te()}],"mask-image-l-to-pos":[{"mask-l-to":Te()}],"mask-image-l-from-color":[{"mask-l-from":$()}],"mask-image-l-to-color":[{"mask-l-to":$()}],"mask-image-x-from-pos":[{"mask-x-from":Te()}],"mask-image-x-to-pos":[{"mask-x-to":Te()}],"mask-image-x-from-color":[{"mask-x-from":$()}],"mask-image-x-to-color":[{"mask-x-to":$()}],"mask-image-y-from-pos":[{"mask-y-from":Te()}],"mask-image-y-to-pos":[{"mask-y-to":Te()}],"mask-image-y-from-color":[{"mask-y-from":$()}],"mask-image-y-to-color":[{"mask-y-to":$()}],"mask-image-radial":[{"mask-radial":[_e,ke]}],"mask-image-radial-from-pos":[{"mask-radial-from":Te()}],"mask-image-radial-to-pos":[{"mask-radial-to":Te()}],"mask-image-radial-from-color":[{"mask-radial-from":$()}],"mask-image-radial-to-color":[{"mask-radial-to":$()}],"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":C()}],"mask-image-conic-pos":[{"mask-conic":[at]}],"mask-image-conic-from-pos":[{"mask-conic-from":Te()}],"mask-image-conic-to-pos":[{"mask-conic-to":Te()}],"mask-image-conic-from-color":[{"mask-conic-from":$()}],"mask-image-conic-to-color":[{"mask-conic-to":$()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:ie()}],"mask-repeat":[{mask:H()}],"mask-size":[{mask:K()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",_e,ke]}],filter:[{filter:["","none",_e,ke]}],blur:[{blur:ee()}],brightness:[{brightness:[at,_e,ke]}],contrast:[{contrast:[at,_e,ke]}],"drop-shadow":[{"drop-shadow":["","none",m,Ii,Oi]}],"drop-shadow-color":[{"drop-shadow":$()}],grayscale:[{grayscale:["",at,_e,ke]}],"hue-rotate":[{"hue-rotate":[at,_e,ke]}],invert:[{invert:["",at,_e,ke]}],saturate:[{saturate:[at,_e,ke]}],sepia:[{sepia:["",at,_e,ke]}],"backdrop-filter":[{"backdrop-filter":["","none",_e,ke]}],"backdrop-blur":[{"backdrop-blur":ee()}],"backdrop-brightness":[{"backdrop-brightness":[at,_e,ke]}],"backdrop-contrast":[{"backdrop-contrast":[at,_e,ke]}],"backdrop-grayscale":[{"backdrop-grayscale":["",at,_e,ke]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[at,_e,ke]}],"backdrop-invert":[{"backdrop-invert":["",at,_e,ke]}],"backdrop-opacity":[{"backdrop-opacity":[at,_e,ke]}],"backdrop-saturate":[{"backdrop-saturate":[at,_e,ke]}],"backdrop-sepia":[{"backdrop-sepia":["",at,_e,ke]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":N()}],"border-spacing-x":[{"border-spacing-x":N()}],"border-spacing-y":[{"border-spacing-y":N()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",_e,ke]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[at,"initial",_e,ke]}],ease:[{ease:["linear","initial",w,_e,ke]}],delay:[{delay:[at,_e,ke]}],animate:[{animate:["none",v,_e,ke]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[h,_e,ke]}],"perspective-origin":[{"perspective-origin":F()}],rotate:[{rotate:te()}],"rotate-x":[{"rotate-x":te()}],"rotate-y":[{"rotate-y":te()}],"rotate-z":[{"rotate-z":te()}],scale:[{scale:he()}],"scale-x":[{"scale-x":he()}],"scale-y":[{"scale-y":he()}],"scale-z":[{"scale-z":he()}],"scale-3d":["scale-3d"],skew:[{skew:ce()}],"skew-x":[{"skew-x":ce()}],"skew-y":[{"skew-y":ce()}],transform:[{transform:[_e,ke,"","none","gpu","cpu"]}],"transform-origin":[{origin:F()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Xe()}],"translate-x":[{"translate-x":Xe()}],"translate-y":[{"translate-y":Xe()}],"translate-z":[{"translate-z":Xe()}],"translate-none":["translate-none"],accent:[{accent:$()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:$()}],"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",_e,ke]}],"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":N()}],"scroll-mx":[{"scroll-mx":N()}],"scroll-my":[{"scroll-my":N()}],"scroll-ms":[{"scroll-ms":N()}],"scroll-me":[{"scroll-me":N()}],"scroll-mbs":[{"scroll-mbs":N()}],"scroll-mbe":[{"scroll-mbe":N()}],"scroll-mt":[{"scroll-mt":N()}],"scroll-mr":[{"scroll-mr":N()}],"scroll-mb":[{"scroll-mb":N()}],"scroll-ml":[{"scroll-ml":N()}],"scroll-p":[{"scroll-p":N()}],"scroll-px":[{"scroll-px":N()}],"scroll-py":[{"scroll-py":N()}],"scroll-ps":[{"scroll-ps":N()}],"scroll-pe":[{"scroll-pe":N()}],"scroll-pbs":[{"scroll-pbs":N()}],"scroll-pbe":[{"scroll-pbe":N()}],"scroll-pt":[{"scroll-pt":N()}],"scroll-pr":[{"scroll-pr":N()}],"scroll-pb":[{"scroll-pb":N()}],"scroll-pl":[{"scroll-pl":N()}],"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",_e,ke]}],fill:[{fill:["none",...$()]}],"stroke-w":[{stroke:[at,jo,$n,bd]}],stroke:[{stroke:["none",...$()]}],"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 j(...e){return Mb(ad(e))}const Lb=["richtext","multiselect","radio","checkboxgroup","signature"],Db=3;function zo(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(Db,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 Lb.includes(e.type)?Math.max(t,2):t}function _d(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 j(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 Td(e){const t=e?.size??"md",r=e?.variant??"default";return j(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 Bb(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 $b(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 jb(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 Mi(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 Pa(e){const t=Mi(e);return{width:t>=100?"100%":`${t}%`,maxWidth:"100%"}}function zb(e){return Pa(e)}function Oa(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t==="start"||t==="center"||t==="end"||t==="stretch"?t:null}function Ia(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t==="start"||t==="center"||t==="end"?t:null}function Tr(e){if(!e)return"start";const t=Oa(e.horizontalAlign);if(t)return t;const r=Oa(e.contentAlign);if(r)return r;const n=Oa(e.cellAlign);return n||"start"}function Vo(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 Li(e){switch(e){case"center":return"items-center";case"end":return"items-end";case"stretch":return"items-stretch";default:return"items-start"}}function Ma(e){switch(e){case"center":return"justify-center";case"end":return"justify-end";case"stretch":return"justify-stretch";default:return"justify-start"}}function Ho(e){const t=Ia(e.appearance?.contentVerticalAlign);if(t!==null)switch(t){case"center":return"justify-center";case"end":return"justify-end";default:return"justify-start"}return Ma(La(e))}const Ub=Ho;function Di(e){if(e.type==="billingGrid"||e.type==="table"||zo(e)>1)return!0;const t=Ia(e.appearance?.contentVerticalAlign);if(t==="center"||t==="end")return!1;if(t==="start")return!0;const r=La(e);return r!=="center"&&r!=="end"}function Fd(e){const t=e[0];if(!t)return Da(void 0);if(e.length===1)return Da(t);const r=Tr(t.appearance);return j("flex flex-col min-h-0 h-full w-full",Li(r),"justify-start")}function Pd(e){const t=Tr(e),r=Vo(e);return j("flex flex-col min-h-0 h-full w-full",Li(t),Ma(r))}function Od(e){if(Mi(e)>=100)return"";const r=Tr(e);return r==="center"?"mx-auto":r==="end"?"ml-auto":""}function Id(e){if(Mi(e)>=100)return"w-full";const r=Tr(e);return r==="center"||r==="end"?"min-w-0":r==="stretch"?"min-w-0 self-stretch":"min-w-0 self-start"}function Md(e){return e?e.widthMode==="full"||e.widthMode==="percent"||typeof e.widthPercent=="number"&&!Number.isNaN(e.widthPercent):!1}function no(e){return(e.type==="button"||e.type==="editButton")&&!Md(e.appearance)}function Ld(e){return no(e)?Tr(e.appearance)==="stretch"?{width:"100%",maxWidth:"100%",minWidth:0}:{width:"auto",maxWidth:"100%"}:Pa(e.appearance)}function Dd(e){return Ld(e)}function Bd(e){if(no(e))switch(Tr(e.appearance)){case"center":return"self-center";case"end":return"self-end";case"stretch":return"self-stretch";default:return"self-start"}return Id(e.appearance)}function $d(e){return e?e.verticalAlign!=null||e.cellJustify!=null:!1}function La(e){return e.type!=="button"&&e.type!=="editButton"||$d(e.appearance)?Vo(e.appearance):"start"}function Da(e){if(!e)return Pd(void 0);const t=Tr(e.appearance);return j("flex flex-col min-h-0 h-full w-full",Li(t),Ho(e))}function Vb(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 j(Li(Tr(o)),Ma(Vo(o)))}const Ba=S.createContext({gridStretch:!1});function Wo(){return S.useContext(Ba)}const jd=e=>{let t;const r=new Set,n=(u,l)=>{const f=typeof u=="function"?u(t):u;if(!Object.is(f,t)){const p=t;t=l??(typeof f!="object"||f===null)?f:Object.assign({},t,f),r.forEach(m=>m(t,p))}},o=()=>t,a={setState:n,getState:o,getInitialState:()=>d,subscribe:u=>(r.add(u),()=>r.delete(u))},d=t=e(n,o,a);return a},Hb=(e=>e?jd(e):jd),Wb=e=>e;function Rb(e,t=Wb){const r=S.useSyncExternalStore(e.subscribe,S.useCallback(()=>t(e.getState()),[e,t]),S.useCallback(()=>t(e.getInitialState()),[e,t]));return S.useDebugValue(r),r}const zd=e=>{const t=Hb(e),r=n=>Rb(t,n);return Object.assign(r,t),r},Ud=(e=>e?zd(e):zd),Gb=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Kb=/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/,qb=/^\+?[\d\s-()]{10,}$/,Yb={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:Gb.test(e),url:e=>typeof e!="string"||!e?!0:Kb.test(e),phone:e=>typeof e!="string"||!e?!0:qb.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(),d=n[s];return d?d.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 Jr(e,t,r={}){const n=Yb[t.type];if(!n)return!0;const o=n(e,t,r);return o===!1?t.message||Xb(t):typeof o=="string"?o:!0}function Xb(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 ${Jb(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 Jb(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}const Qb=10;function Bi(e){const t=e.properties;return t?.maxFiles!=null&&t.maxFiles>0?Math.floor(t.maxFiles):t?.multiple===!0?Qb:1}function Vd(e){return typeof e=="object"&&e!==null&&"url"in e&&typeof e.url=="string"&&e.url.length>0}function Hd(e){try{return e.split("?")[0].split("/").filter(Boolean).pop()||e}catch{return e}}function $i(e){if(e==null)return[];if(typeof e=="string")return e.startsWith("http")?[{url:e,name:Hd(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:Hd(r)}):Vd(r)&&t.push(r);return t}return Vd(e)?[e]:[]}function Zb(e,t){return e.slice(0,t)}function $a(e,t){const r=Zb(e,t);return r.length===0?null:t===1?r[0]??null:r}function ev(e){return $i(e).length}function tv(e){return e==="file"||e==="camera"||e==="photoChoice"}function ja(e,t){if(!tv(e.type))return;const r=Bi(e);if(ev(t)>r)return`Maximum ${r} file(s) allowed`}class ji{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 f in s){const p=s[f];(p==null||p==="")&&(s[f]="")}const a={fields:s,currentValue:o,previousValue:i,...ji.functions},d=Object.keys(a),u=Object.values(a),l=new Function(...d,`return ${t}`)(...u);if(l==null)return"";if(typeof l=="string"){if(l.includes("undefined"))return"";const f=l.trim();return f===""||/^\s+$/.test(l)?"":f}return l}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 Wd=new ji;function Rd(e){if(e==null||e==="")return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:zi(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:zi(n)}return null}function zi(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function rv(e,t=new Date){const r=zi(e),n=zi(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 za(e){if(e.type!=="number")return;const t=e.properties?.deriveFromDate;if(!(!t?.sourceFieldName||!t.part))return t}function Fr(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(0,t):e}function Ua(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(t):null}function nv(e,t){const r=Ua(e);return r?`${t.sourceFieldName}${r}`:t.sourceFieldName}function Gd(e,t,r){const n=Ua(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 ov(e,t,r){const n=r?nv(r,e):e.sourceFieldName,o=Rd(t[n]);if(!o)return null;const i=e.referenceDate==="today"||e.referenceDate==null?new Date:Rd(t[e.referenceDate])??new Date;return rv(o,i)[e.part]}function Kd(e,t){const r=za(e);return r?Fr(r.sourceFieldName)===Fr(t):!1}function Va(e,t,r,n){const o={...t},i=n?Fr(n):void 0;for(const s of e){if(s.type!=="number")continue;const a=za(s);if(!a||!s.name||i&&Fr(a.sourceFieldName)!==i)continue;const d=n??a.sourceFieldName,u=Gd(s.name,d,o);for(const l of u){if(r.has(l))continue;const f=ov(a,o,l);o[l]=f}}return o}function iv(e,t,r,n){const o={...t},i=Fr(n);for(const s of e){if(!Kd(s,i)||!s.name)continue;const a=Gd(s.name,n,o);for(const d of a)r.delete(d),o[d]=null}return o}function qd(e,t){const r=Fr(t);return e.some(n=>Kd(n,r))}function Yd(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 Ha(e,t,r,n){let o=Wa(e,r);return n&&(o=zn(o,t,r)),o}function Wa(e,t){return e.replace(/\{(?:ctx:|\@)(\w+)\}/g,(r,n)=>t?.[n]!==void 0&&t[n]!==null?String(t[n]):r)}function zn(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(d=>d.toLowerCase()===i.toLowerCase());a&&(s=t[a])}return s!=null&&s!==""?String(s):o}),n}function oo(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 sv(e,t){const r=e[t];return r==null||r===""}function Ui(e){const{apiEndpoint:t,apiMethod:r="GET",apiQueryParams:n={},formValues:o,submissionContext:i,apiRealtime:s,additionalRequiredFieldNames:a=[],excludeFormFieldNames:d=[]}=e,u=(r||"GET").toLowerCase(),l=oo(t,n),f=new Set((d||[]).filter(v=>typeof v=="string"&&v.length>0)),p=new Set((a||[]).filter(v=>typeof v=="string"&&v.length>0)),m=new Set([...l,...p]);let g=!1;for(const v of m){const A=!!(s&&l.has(v)),C=p.has(v);if((A||C)&&sv(o,v)){g=!0;break}}if(g)return{blocked:!0,url:t,postBodyBase:null};let h=t;const y=t.match(/\{(\w+)\}/g)||[];if(h=Wa(h,i),s&&(h=zn(h,o,i)),n&&Object.keys(n).length>0){const v=n,A=[];if(v.limit){let C=v.limit;s&&(C=zn(C,o,i)),A.push(`_limit=${encodeURIComponent(C)}`)}if(v.page){let C=v.page;s&&(C=zn(C,o,i)),A.push(`page=${encodeURIComponent(C)}`)}if(v.sort){let C=v.sort;s&&(C=zn(C,o,i)),A.push(`sort=${encodeURIComponent(C)}`)}if(v.orderBy){let C=v.orderBy;s&&(C=zn(C,o,i)),A.push(`orderBy=${encodeURIComponent(C)}`)}if(v.custom?.length&&v.custom.forEach(({key:C,value:F})=>{if(!C||!F)return;let E=Wa(F,i);s&&(E=zn(E,o,i)),E.match(/\{[^}]+\}/)?E.match(/\{(?!ctx:|\@)(\w+)\}/g)||A.push(`${encodeURIComponent(C)}=`):A.push(`${encodeURIComponent(C)}=${encodeURIComponent(E)}`)}),A.length>0){const C=h.includes("?")?"&":"?";h=`${h}${C}${A.join("&")}`}}if(s&&Object.keys(o).length>0&&u==="get"){const v=E=>E.replace(/\{/g,"").replace(/\}/g,""),A=[];for(const E of n.custom||[])if(E.value){const T=E.value.match(/\{(\w+)\}/g)||[];A.push(...T.map(v))}const C=new Set([...y.map(v),...A]),F={};Object.keys(o).forEach(E=>{!C.has(E)&&!f.has(E)&&(F[E]=o[E])}),Object.keys(F).length>0&&(h=`${h}${h.includes("?")?"&":"?"}${new URLSearchParams(F).toString()}`)}let w=null;if(["post","put","patch"].includes(u))if(s&&Object.keys(o).length>0){w={...o};for(const v of f)delete w[v]}else{w={...o||{}};for(const v of f)delete w[v]}return{blocked:!1,url:h,postBodyBase:w}}const av=new Set(["select","multiselect","asyncsearch"]);function lv(e){return e?.type==="multiselect"?[]:""}function Xd(e){if(!av.has(e.type))return[];const t=e.properties??{},r=Yd(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,d=r?.apiQueryParams||t.apiQueryParams;if(s&&a)for(const u of oo(s,d))n.add(u);return[...n]}function cv(e,t){const r=Fr(t);return Xd(e).some(n=>Fr(n)===r)}function dv(e,t){const r=Fr(t);return e.some(n=>cv(n,r))}function uv(e){const t=new Map;for(const r of e){const n=r.name;if(n)for(const o of Xd(r)){const i=Fr(o),s=t.get(i)??new Set;s.add(n),t.set(i,s)}}return t}function fv(e,t,r){const n=Ua(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 pv(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 mv(e,t,r){const n=uv(e),o=Fr(r),i=new Set,s=[o];for(;s.length>0;){const u=s.shift(),l=n.get(u);if(l)for(const f of l)i.has(f)||(i.add(f),s.push(f))}const a={...t},d=[];for(const u of i){const l=e.find(p=>p.name===u),f=lv(l);for(const p of fv(u,r,a))pv(a[p],f)||d.push(p),a[p]=f}return{values:a,clearedKeys:d}}function Ra(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}const Nt=Ud((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={},d=new Set,u=new Set,l=new Set;r.fields.forEach(y=>{const w=y.name||y.key||y.id;w&&(y.defaultValue!==void 0&&(y.type==="multiselect"?a[w]=Array.isArray(y.defaultValue)?y.defaultValue:y.defaultValue!=null&&y.defaultValue!==""?[String(y.defaultValue)]:[]:a[w]=y.defaultValue),y.hidden||d.add(w),y.disabled||u.add(w),y.validation?.some(v=>v.type==="required")&&l.add(w))});const f=r.steps?.length||1,p=[];r.fields.forEach(y=>{const w=y.properties;w?.valueSource==="calculated"&&w?.formula&&p.push({field:y.name,formula:w.formula})});const m=p.length>0?Wd.calculateAll(p,a):{},g=Va(r.fields,{...a,...m},new Set),h=i&&!s?{...g,...o.values}:g;e({schema:r,values:h,initialValues:g,errors:{},touched:{},currentStep:0,totalSteps:f,completedSteps:new Set,visibleFields:d,enabledFields:u,requiredFields:l,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 d=new Set(i.derivedFieldDirty);const u=i.values[r];let l={...i.values,[r]:n},f=[];if(s){const p=Fr(r),m=s.fields.find(w=>w.name===p);a==="user"&&m&&za(m)&&d.add(r);const g=n==null||n===""||Array.isArray(n)&&n.length===0;if(qd(s.fields,r)&&g?l=iv(s.fields,l,d,r):qd(s.fields,r)&&(l=Va(s.fields,l,d,r)),a==="user"&&u!==n&&!(Array.isArray(u)&&Array.isArray(n)&&u.length===n.length&&u.every((w,v)=>w===n[v]))&&dv(s.fields,r)){const w=mv(s.fields,l,r);l=w.values,f=w.clearedKeys}const y=[];if(s.fields.forEach(w=>{const v=w.properties;v?.valueSource==="calculated"&&v?.formula&&(v.formulaSteps||[]).some(F=>F.type==="field"&&F.fieldName===r)&&y.push({field:w.name,formula:v.formula})}),y.length>0){const w=Wd.calculateAll(y,l);l={...l,...w}}}e({values:l,derivedFieldDirty:d}),f.length>0&&e(p=>{const m={...p.errors};for(const g of f)delete m[g];return Object.keys(m).length===Object.keys(p.errors).length?p:{errors:m}}),s?.config.validateOnChange?t().validateField(r):e(p=>{const m={...p.errors};return delete m[r],{errors:m}})},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=Va(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 d=Jr(o[r],a,o);if(typeof d=="string"){s=d;break}}if(!s){const a=ja(i,o[r]);a&&(s=a)}return e(a=>{const d={...a.errors};return s?d[r]=s:delete d[r],{errors:d,isValid:Object.keys(d).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 d of a.validation){if(d.type==="required"&&!i.has(a.name))continue;const u=Jr(n[a.name],d,n);if(typeof u=="string"){s[a.name]=u;break}}if(!s[a.name]){const d=ja(a,n[a.name]);d&&(s[a.name]=d)}}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||!n.steps)return!0;const s=n.steps[r];if(!s)return!0;e({isValidating:!0});const a={};for(const d of s.fields){const u=n.fields.find(l=>l.name===d);if(u&&i.has(u.name)){if(u.validation)for(const l of u.validation){const f=Jr(o[u.name],l,o);if(typeof f=="string"){a[u.name]=f;break}}if(!a[u.name]){const l=ja(u,o[u.name]);l&&(a[u.name]=l)}}}return e(d=>({errors:{...d.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 Ra(n.visibleFields,o)?n:{visibleFields:o}})},updateEnabled:r=>{e(n=>{const o=new Set(r);return Ra(n.enabledFields,o)?n:{enabledFields:o}})},updateRequired:r=>{e(n=>{const o=new Set(r);return Ra(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{}}}));function hv(){return Nt.getState()}function Jd({schema:e,initialValues:t,onSubmit:r,onChange:n,workflowStepId:o}){const{values:i,errors:s,touched:a,isValidating:d,isSubmitting:u,submitCount:l,isValid:f,currentStep:p,totalSteps:m,completedSteps:g,visibleFields:h,enabledFields:y,requiredFields:w,setSchema:v,setFieldValue:A,setFieldTouched:C,setFieldError:F,setValues:E,resetForm:T,validateField:N,validateForm:x,validateStep:O,nextStep:k,prevStep:D,goToStep:R,setSubmitting:I,incrementSubmitCount:z,saveDraft:L,loadDraft:B,clearDraft:M}=Nt(),V=S.useRef(null);S.useLayoutEffect(()=>{if(v(e,{forceReset:!!o}),t&&Object.keys(t).length>0){const ce=Nt.getState().values;E({...ce,...t});try{V.current=JSON.stringify(t)}catch{V.current=null}}else V.current=null},[e.id,o]),S.useLayoutEffect(()=>{if(!t||Object.keys(t).length===0)return;let ce;try{ce=JSON.stringify(t)}catch{return}if(ce===V.current)return;const Xe=Nt.getState().values;E({...Xe,...t}),V.current=ce},[t,E]);const $=S.useCallback((ce,Xe)=>{const ge={...i,[ce]:Xe};A(ce,Xe),n?.(ge,ce)},[A,n,i]),ie=S.useCallback(async ce=>{if(ce?.preventDefault(),z(),!await x())return{success:!1,errors:Object.entries(s).map(([ge,Se])=>({field:ge,rule:"validation",message:Se}))};if(!r)return{success:!0};I(!0);try{const ge=await r(i);return ge.success&&M(),ge}catch(ge){return{success:!1,message:ge instanceof Error?ge.message:"Submission failed"}}finally{I(!1)}},[x,r,i,s,z,I,M]),H=S.useCallback(ce=>({value:i[ce],error:s[ce],touched:a[ce]||!1,isVisible:h.has(ce),isEnabled:y.has(ce),isRequired:w.has(ce)}),[i,s,a,h,y,w]),K=S.useMemo(()=>{if(!e.steps||e.steps.length===0)return e.fields;const ce=e.steps[p];return ce?e.fields.filter(Xe=>ce.fields.includes(Xe.name)):[]},[e,p]),X=p===0,le=p===m-1,re=S.useCallback(ce=>g.has(ce),[g]),q=S.useMemo(()=>m<=1?100:Math.round(g.size/m*100),[g.size,m]),ne=S.useCallback(ce=>h.has(ce),[h]),Te=S.useCallback(ce=>y.has(ce),[y]),ee=S.useCallback(ce=>w.has(ce),[w]),te=S.useMemo(()=>Object.entries(s).filter(([ce])=>h.has(ce)),[s,h]),he=te.length>0;return{values:i,errors:s,touched:a,isValidating:d,isSubmitting:u,submitCount:l,isValid:f,hasErrors:he,visibleErrors:te,currentStep:p,totalSteps:m,completedSteps:g,currentStepFields:K,isFirstStep:X,isLastStep:le,isStepCompleted:re,progress:q,setFieldValue:$,setFieldTouched:C,setFieldError:F,setValues:E,validateField:N,getFieldState:H,shouldShowField:ne,isFieldEnabled:Te,isFieldRequired:ee,handleSubmit:ie,resetForm:T,validateForm:x,validateStep:O,nextStep:k,prevStep:D,goToStep:R,saveDraft:L,loadDraft:B,clearDraft:M}}function Qd(e){return"logic"in e&&"conditions"in e}function Ro(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 Zd(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 Qe(e,t){if(e==null||typeof t!="string"||t.trim()==="")return;let r=Zd(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=Zd(e,o);Array.isArray(s)&&s.length>0&&(r=Qe(s[0],i))}}return r}const gv=new Set(["section","group","columns","divider","header","sectionHeading","spacer","textLabel","addmore","customizeSections"]);function yv(e){return e===!0||e==="true"?!0:e===!1||e==="false"?!1:e}function bv(e,t){if(e==null||typeof t.path!="string"||!t.path.trim())return!1;const r=Qe(e,t.path),n=yv(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 vv(e,t,r){return e?e==="__allFields__"?t.filter(n=>!gv.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]:[]}const eu="__buttonResponse:";function wv({fields:e,values:t,buttonResponses:r,prepopulateResponse:n=null,prepopulateResponseRules:o}){const{updateVisibility:i,updateEnabled:s,updateRequired:a,updateReadOnly:d,updateEditable:u,updateFormDisabled:l}=Nt(),f=S.useCallback(E=>E.name||E.key||E.id,[]),p=S.useCallback((E,T)=>{if(!E)return f(T);const N=e.find(x=>x.id===E||x.name===E||x.key===E);return N?f(N):E},[e,f]),m=S.useCallback(E=>{const T=e.find(N=>N.id===E||N.name===E||N.key===E);return T?f(T):E},[e,f]),g=S.useCallback(E=>{const{field:T,operator:N,value:x}=E;if(typeof T=="string"&&T.startsWith(eu)){const D=T.slice(eu.length),R=r?.[D],I=Ro(R);return x==="success"?I:x==="failure"?R!=null&&!I:!1}const O=m(T),k=t[O];switch(N){case"equals":return k===x;case"notEquals":return k!==x;case"contains":return typeof k=="string"?k.includes(String(x)):Array.isArray(k)?k.includes(x):!1;case"notContains":return typeof k=="string"?!k.includes(String(x)):Array.isArray(k)?!k.includes(x):!0;case"startsWith":return typeof k=="string"&&k.startsWith(String(x));case"endsWith":return typeof k=="string"&&k.endsWith(String(x));case"greaterThan":return Number(k)>Number(x);case"lessThan":return Number(k)<Number(x);case"greaterThanOrEqual":return Number(k)>=Number(x);case"lessThanOrEqual":return Number(k)<=Number(x);case"isEmpty":return k==null?!0:k instanceof File?!1:typeof k=="string"?k.trim()==="":Array.isArray(k)?(k.length>0&&k[0]instanceof File,k.length===0):typeof k=="object"&&k!==null?Object.keys(k).length===0:!1;case"isNotEmpty":return k==null?!1:k instanceof File?!0:typeof k=="string"?k.trim()!=="":Array.isArray(k)?(k.length>0&&k[0]instanceof File,k.length>0):typeof k=="object"&&k!==null?Object.keys(k).length>0:!1;case"isTrue":return k===!0;case"isFalse":return k===!1;case"isNull":return k==null;case"isNotNull":return k!=null;case"in":return Array.isArray(x)?x.includes(k):!1;case"notIn":return Array.isArray(x)?!x.includes(k):!0;case"between":if(Array.isArray(x)&&x.length===2){const D=Number(k);return D>=Number(x[0])&&D<=Number(x[1])}return!1;case"regex":try{return new RegExp(String(x)).test(String(k))}catch{return!1}default:return!0}},[t,m,r]),h=S.useCallback(E=>{const T=E.conditions.map(N=>Qd(N)?h(N):g(N));return E.logic==="and"?T.every(Boolean):T.some(Boolean)},[g]),y=S.useCallback(E=>Qd(E)?h(E):g(E),[g,h]),w=S.useCallback(()=>{const E=new Set,T=new Set,N=new Set,x=new Set,O=new Set;e.forEach(I=>{const z=f(I);I.hidden||E.add(z),I.disabled||T.add(z),I.validation?.some(L=>L.type==="required")&&N.add(z)});let k=!1;if(n!=null&&o?.length)for(const I of o){if(!bv(n,I.when))continue;const{action:z,target:L}=I.then;if(z==="disableForm")k=!0;else if(z==="enableForm")k=!1;else{const B=vv(L,e,f);for(const M of B)switch(z){case"disable":T.delete(M);break;case"enable":T.add(M);break;case"hide":E.delete(M);break;case"show":E.add(M);break;case"readOnly":x.add(M),O.delete(M);break;case"editable":O.add(M),x.delete(M);break}}}e.forEach(I=>{I.conditions&&I.conditions.forEach(z=>{(y(z.when)?z.then:z.else||[]).forEach(M=>{switch(M.action){case"disableForm":k=!0;break;case"enableForm":k=!1;break;default:{const V=p(M.target,I);switch(M.action){case"show":E.add(V);break;case"hide":E.delete(V);break;case"enable":T.add(V);break;case"disable":T.delete(V);break;case"require":N.add(V);break;case"unrequire":N.delete(V);break}break}}})})});const D=I=>e.filter(z=>z.type!=="editButton"&&(z.name||z.key||z.id)).map(z=>f(z)),R=()=>e.filter(I=>I.type==="button").map(I=>f(I));return e.forEach(I=>{if(I.type!=="editButton")return;const z=f(I);if(!Ro(r?.[z]))return;const L=I.properties;L?.rules&&L.rules.length>0?L.rules.forEach(B=>{const M=[];B.allFields&&M.push(...D(I.id)),B.allButtons&&M.push(...R()),B.fieldNames?.length&&B.fieldNames.forEach(V=>{const $=e.find(ie=>f(ie)===V||ie.id===V||ie.name===V);M.push($?f($):V)}),B.buttonNames?.length&&M.push(...B.buttonNames),M.forEach(V=>{switch(B.action){case"enable":T.add(V),x.delete(V);break;case"disable":T.delete(V);break;case"show":E.add(V);break;case"hide":E.delete(V);break;case"readOnly":x.add(V);break;case"editable":O.add(V);break}})}):((L?.enableFieldNames??[]).forEach(B=>T.add(B)),(L?.disableFieldNames??[]).forEach(B=>T.delete(B)),(L?.showFieldNames??[]).forEach(B=>E.add(B)),(L?.hideFieldNames??[]).forEach(B=>E.delete(B)))}),{visible:Array.from(E),enabled:Array.from(T),required:Array.from(N),readOnly:Array.from(x),editable:Array.from(O),formDisabled:k}},[e,y,f,p,t,r,n,o]),v=S.useMemo(()=>w(),[w]);S.useEffect(()=>{i(v.visible),s(v.enabled),a(v.required),d(v.readOnly??[]),u(v.editable??[]),l(v.formDisabled??!1)},[v,i,s,a,d,u,l]);const A=S.useCallback(E=>v.visible.includes(E),[v.visible]),C=S.useCallback(E=>v.enabled.includes(E),[v.enabled]),F=S.useCallback(E=>v.required.includes(E),[v.required]);return{evaluateCondition:y,evaluateExpression:g,evaluateGroup:h,isFieldVisible:A,isFieldEnabled:C,isFieldRequired:F,visibleFields:v.visible,enabledFields:v.enabled,requiredFields:v.required}}function An({className:e,type:t,...r}){return c.jsx("input",{type:t,"data-slot":"input",className:j("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 tu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Un(...e){return t=>{let r=!1;const n=e.map(o=>{const i=tu(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():tu(e[o],null)}}}}function Ze(...e){return b.useCallback(Un(...e),e)}var Sv=Symbol.for("react.lazy"),Vi=b[" use ".trim().toString()];function xv(e){return typeof e=="object"&&e!==null&&"then"in e}function ru(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Sv&&"_payload"in e&&xv(e._payload)}function Ga(e){const t=Av(e),r=b.forwardRef((n,o)=>{let{children:i,...s}=n;ru(i)&&typeof Vi=="function"&&(i=Vi(i._payload));const a=b.Children.toArray(i),d=a.find(Ev);if(d){const u=d.props.children,l=a.map(f=>f===d?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:f);return c.jsx(t,{...s,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...s,ref:o,children:i})});return r.displayName=`${e}.Slot`,r}var nu=Ga("Slot");function Av(e){const t=b.forwardRef((r,n)=>{let{children:o,...i}=r;if(ru(o)&&typeof Vi=="function"&&(o=Vi(o._payload)),b.isValidElement(o)){const s=kv(o),a=Nv(i,o.props);return o.type!==b.Fragment&&(a.ref=n?Un(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 Cv=Symbol("radix.slottable");function Ev(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Cv}function Nv(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 d=i(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...i}:n==="className"&&(r[n]=[o,i].filter(Boolean).join(" "))}return{...e,...r}}function kv(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 _v=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Tv=_v.reduce((e,t)=>{const r=Ga(`Primitive.${t}`),n=b.forwardRef((o,i)=>{const{asChild:s,...a}=o,d=s?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(d,{...a,ref:i})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),Fv="Label",ou=b.forwardRef((e,t)=>c.jsx(Tv.label,{...e,ref:t,onMouseDown:r=>{r.target.closest("button, input, select, textarea")||(e.onMouseDown?.(r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));ou.displayName=Fv;var Pv=ou;function Cn({className:e,...t}){return c.jsx(Pv,{"data-slot":"label",className:j("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 ht(e){return`formsmith-field-${e.id}`}function Hi(e){return`formsmith-label-${e.id}`}function Go(e){return`formsmith-desc-${e.id}`}function Ko(e){return`formsmith-error-${e.id}`}function $t(e,t){const r=[];return e.description&&r.push(Go(e)),t&&r.push(Ko(e)),r.length>0?r.join(" "):void 0}function Zt(e){return e?!0:void 0}const Ov={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 En(e){return e.ui?.cellStyle}function Iv(e){const t=e.ui;if(!t)return;const r=t.fontToken?Ov[t.fontToken]:void 0;if(!(!r&&!t.wrapperStyle))return{...r,...t.wrapperStyle}}function Mv(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}=Wo(),a=s&&Di(e),d=!(i??e.appearance?.hideLabel)&&e.label,u=e.appearance?.labelPlacement||"top",l=Iv(e),f=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,m=Dd(e),g=no(e),h=Mv(e),y=Tr(e.appearance);return c.jsx("div",{className:j(Bb(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:l,"data-field-appearance":u,children:c.jsxs("div",{className:j("flex flex-col min-w-0",Od(e.appearance),Bd(e),a&&!h&&"flex-1 min-h-0",s&&h&&"shrink-0"),style:m,children:[d&&c.jsxs(Cn,{id:Hi(e),htmlFor:ht(e),style:e.ui?.labelStyle,className:j($b(u,!!t)),children:[e.label,r&&c.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),c.jsxs("div",{className:j(jb(u),h&&s&&"min-h-min !grow-0 !shrink-0 basis-auto",g&&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:f,children:[n,c.jsxs("div",{className:j("mt-1.5 min-h-[18px]",u==="center"&&"text-center",o?.includes("flex")&&"shrink-0"),children:[e.description&&!t&&c.jsx("p",{id:Go(e),className:"text-xs text-muted-foreground",style:e.ui?.descriptionStyle,children:e.description}),t&&c.jsx("p",{id:Ko(e),className:"text-xs text-destructive",role:"alert",children:typeof t=="string"?t:String(t||"An error occurred")})]})]})]})})},Wi=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:d})=>{const u=e.properties,l=S.useCallback(f=>{r(f.target.value)},[r]);return c.jsx(Ct,{field:e,error:o,isRequired:a,className:d,children:c.jsx(An,{id:ht(e),type:"text",value:t||"",onChange:l,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":$t(e,!!o),"aria-invalid":Zt(!!o),"aria-required":a,className:j(Uo(e.appearance),o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})})},Ka=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:d})=>{const u=e.properties,l=u?.precision!=null||u?.step!=null&&!Number.isInteger(u.step),f=S.useCallback(m=>{const g=u?.allowNegative!==!1,h=m.target.value,y=l?h.replace(g?/[^\d.-]/g:/[^\d.]/g,""):h.replace(g?/[^\d-]/g:/\D/g,"");if(y===""){r(null);return}const w=parseFloat(y);isNaN(w)||r(w)},[r,u?.allowNegative,l]),p=S.useCallback(m=>{(m.key==="ArrowUp"||m.key==="ArrowDown"||m.key==="PageUp"||m.key==="PageDown")&&m.preventDefault()},[]);return c.jsx(Ct,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{className:"relative",children:[u?.prefix&&c.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:u.prefix}),c.jsx(An,{id:ht(e),type:"text",inputMode:l?"decimal":"numeric",autoComplete:"off",value:t??"",onChange:f,onKeyDown:p,onBlur:n,placeholder:e.placeholder,disabled:i||e.disabled,readOnly:s||e.readOnly,"aria-describedby":$t(e,!!o),"aria-invalid":Zt(!!o),"aria-required":a,className:j(Uo(e.appearance),o&&"border-destructive focus-visible:ring-destructive",u?.prefix&&"pl-8",u?.suffix&&"pr-8",e.appearance?.className)}),u?.suffix&&c.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:u.suffix})]})})};const Lv=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Dv=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,n)=>n?n.toUpperCase():r.toLowerCase()),iu=e=>{const t=Dv(e);return t.charAt(0).toUpperCase()+t.slice(1)},su=(...e)=>e.filter((t,r,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===r).join(" ").trim(),Bv=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var $v={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 jv=S.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:o="",children:i,iconNode:s,...a},d)=>S.createElement("svg",{ref:d,...$v,width:t,height:t,stroke:e,strokeWidth:n?Number(r)*24/Number(t):r,className:su("lucide",o),...!i&&!Bv(a)&&{"aria-hidden":"true"},...a},[...s.map(([u,l])=>S.createElement(u,l)),...Array.isArray(i)?i:[i]]));const Wt=(e,t)=>{const r=S.forwardRef(({className:n,...o},i)=>S.createElement(jv,{ref:i,iconNode:t,className:su(`lucide-${Lv(iu(e))}`,`lucide-${e}`,n),...o}));return r.displayName=iu(e),r};const zv=Wt("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 Ri=Wt("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 Gi=Wt("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const qo=Wt("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const au=Wt("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Uv=Wt("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);const Vv=Wt("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 lu=Wt("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const cu=Wt("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 du=Wt("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 io=Wt("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const Hv=Wt("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 Wv=Wt("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 uu=Wt("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const Rv=Wt("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 fu=Wt("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 Yo=Wt("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 Ki=Wt("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 Xo=Wt("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),pu=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:d})=>{const u=S.useCallback(l=>{r(l.target.value)},[r]);return c.jsx(Ct,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{className:"relative",children:[c.jsx(Hv,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),c.jsx(An,{id:ht(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":$t(e,!!o),"aria-invalid":Zt(!!o),"aria-required":a,className:j(Uo(e.appearance),"pl-10",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]})})},mu=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:d})=>{const u=S.useCallback(l=>{const f=l.target.value.replace(/[^\d\s+\-()]/g,"");r(f)},[r]);return c.jsx(Ct,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{className:"relative",children:[c.jsx(Wv,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),c.jsx(An,{id:ht(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":$t(e,!!o),"aria-invalid":Zt(!!o),"aria-required":a,className:j(Uo(e.appearance),"pl-10",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]})})};function Gv({className:e,maxLength:t,showCharacterCount:r=!1,autoResize:n=!1,onChange:o,value:i,...s}){const a=b.useRef(null),[d,u]=b.useState(0),l=f=>{const p=f.target.value;u(p.length),n&&a.current&&(a.current.style.height="auto",a.current.style.height=`${a.current.scrollHeight}px`),o&&o(f)};return b.useEffect(()=>{i&&u(String(i).length)},[i]),c.jsxs("div",{className:"space-y-1",children:[c.jsx("textarea",{ref:a,"data-slot":"textarea",className:j("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:l,value:i,...s}),r&&c.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[c.jsxs("span",{children:[d," characters"]}),t&&c.jsxs("span",{children:[t-d," remaining"]})]})]})}const hu=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:d})=>{const{gridStretch:u}=Wo(),l=u&&Di(e),f=e.properties,p=S.useCallback(y=>{r(y.target.value)},[r]),m=(t||"").length,g=f?.maxLength,h=g&&g>0;return c.jsx(Ct,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{className:j("relative flex flex-col",l&&"flex-1 min-h-0"),children:[c.jsx(Gv,{id:ht(e),value:t||"",onChange:p,onBlur:n,placeholder:e.placeholder,disabled:i||e.disabled,readOnly:s||e.readOnly,minLength:f?.minLength,maxLength:f?.maxLength,rows:2,"aria-describedby":$t(e,!!o),"aria-invalid":Zt(!!o),"aria-required":a,className:j(Td(e.appearance),"resize-y",l&&"min-h-[120px] flex-1 flex-shrink-0",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)}),h&&c.jsxs("span",{className:"absolute bottom-2 right-2 text-xs text-muted-foreground",children:[m,"/",g]})]})})};function Jo(e,[t,r]){return Math.min(r,Math.max(t,e))}function Le(e,t,{checkForDefaultPrevented:r=!0}={}){return function(o){if(e?.(o),r===!1||!o.defaultPrevented)return t?.(o)}}function Kv(e,t){const r=b.createContext(t),n=i=>{const{children:s,...a}=i,d=b.useMemo(()=>a,Object.values(a));return c.jsx(r.Provider,{value:d,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 xr(e,t=[]){let r=[];function n(i,s){const a=b.createContext(s),d=r.length;r=[...r,s];const u=f=>{const{scope:p,children:m,...g}=f,h=p?.[e]?.[d]||a,y=b.useMemo(()=>g,Object.values(g));return c.jsx(h.Provider,{value:y,children:m})};u.displayName=i+"Provider";function l(f,p){const m=p?.[e]?.[d]||a,g=b.useContext(m);if(g)return g;if(s!==void 0)return s;throw new Error(`\`${f}\` must be used within \`${i}\``)}return[u,l]}const o=()=>{const i=r.map(s=>b.createContext(s));return function(a){const d=a?.[e]||i;return b.useMemo(()=>({[`__scope${e}`]:{...a,[e]:d}}),[a,d])}};return o.scopeName=e,[n,qv(o,...t)]}function qv(...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:d,scopeName:u})=>{const f=d(i)[`__scope${u}`];return{...a,...f}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return r.scopeName=t.scopeName,r}function gu(e){const t=Yv(e),r=b.forwardRef((n,o)=>{const{children:i,...s}=n,a=b.Children.toArray(i),d=a.find(Jv);if(d){const u=d.props.children,l=a.map(f=>f===d?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:f);return c.jsx(t,{...s,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...s,ref:o,children:i})});return r.displayName=`${e}.Slot`,r}function Yv(e){const t=b.forwardRef((r,n)=>{const{children:o,...i}=r;if(b.isValidElement(o)){const s=Zv(o),a=Qv(i,o.props);return o.type!==b.Fragment&&(a.ref=n?Un(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 Xv=Symbol("radix.slottable");function Jv(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Xv}function Qv(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 d=i(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...i}:n==="className"&&(r[n]=[o,i].filter(Boolean).join(" "))}return{...e,...r}}function Zv(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 qa(e){const t=e+"CollectionProvider",[r,n]=xr(t),[o,i]=r(t,{collectionRef:{current:null},itemMap:new Map}),s=h=>{const{scope:y,children:w}=h,v=S.useRef(null),A=S.useRef(new Map).current;return c.jsx(o,{scope:y,itemMap:A,collectionRef:v,children:w})};s.displayName=t;const a=e+"CollectionSlot",d=gu(a),u=S.forwardRef((h,y)=>{const{scope:w,children:v}=h,A=i(a,w),C=Ze(y,A.collectionRef);return c.jsx(d,{ref:C,children:v})});u.displayName=a;const l=e+"CollectionItemSlot",f="data-radix-collection-item",p=gu(l),m=S.forwardRef((h,y)=>{const{scope:w,children:v,...A}=h,C=S.useRef(null),F=Ze(y,C),E=i(l,w);return S.useEffect(()=>(E.itemMap.set(C,{ref:C,...A}),()=>{E.itemMap.delete(C)})),c.jsx(p,{[f]:"",ref:F,children:v})});m.displayName=l;function g(h){const y=i(e+"CollectionConsumer",h);return S.useCallback(()=>{const v=y.collectionRef.current;if(!v)return[];const A=Array.from(v.querySelectorAll(`[${f}]`));return Array.from(y.itemMap.values()).sort((E,T)=>A.indexOf(E.ref.current)-A.indexOf(T.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:s,Slot:u,ItemSlot:m},g,n]}var ew=b.createContext(void 0);function so(e){const t=b.useContext(ew);return e||t||"ltr"}function tw(e){const t=rw(e),r=b.forwardRef((n,o)=>{const{children:i,...s}=n,a=b.Children.toArray(i),d=a.find(ow);if(d){const u=d.props.children,l=a.map(f=>f===d?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:f);return c.jsx(t,{...s,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...s,ref:o,children:i})});return r.displayName=`${e}.Slot`,r}function rw(e){const t=b.forwardRef((r,n)=>{const{children:o,...i}=r;if(b.isValidElement(o)){const s=sw(o),a=iw(i,o.props);return o.type!==b.Fragment&&(a.ref=n?Un(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 nw=Symbol("radix.slottable");function ow(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===nw}function iw(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 d=i(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...i}:n==="className"&&(r[n]=[o,i].filter(Boolean).join(" "))}return{...e,...r}}function sw(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 aw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],$e=aw.reduce((e,t)=>{const r=tw(`Primitive.${t}`),n=b.forwardRef((o,i)=>{const{asChild:s,...a}=o,d=s?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(d,{...a,ref:i})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function lw(e,t){e&&_i.flushSync(()=>e.dispatchEvent(t))}function ar(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),b.useMemo(()=>(...r)=>t.current?.(...r),[])}function cw(e,t=globalThis?.document){const r=ar(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 dw="DismissableLayer",Ya="dismissableLayer.update",uw="dismissableLayer.pointerDownOutside",fw="dismissableLayer.focusOutside",yu,bu=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),qi=b.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:s,onDismiss:a,...d}=e,u=b.useContext(bu),[l,f]=b.useState(null),p=l?.ownerDocument??globalThis?.document,[,m]=b.useState({}),g=Ze(t,T=>f(T)),h=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),w=h.indexOf(y),v=l?h.indexOf(l):-1,A=u.layersWithOutsidePointerEventsDisabled.size>0,C=v>=w,F=hw(T=>{const N=T.target,x=[...u.branches].some(O=>O.contains(N));!C||x||(o?.(T),s?.(T),T.defaultPrevented||a?.())},p),E=gw(T=>{const N=T.target;[...u.branches].some(O=>O.contains(N))||(i?.(T),s?.(T),T.defaultPrevented||a?.())},p);return cw(T=>{v===u.layers.size-1&&(n?.(T),!T.defaultPrevented&&a&&(T.preventDefault(),a()))},p),b.useEffect(()=>{if(l)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(yu=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(l)),u.layers.add(l),vu(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=yu)}},[l,p,r,u]),b.useEffect(()=>()=>{l&&(u.layers.delete(l),u.layersWithOutsidePointerEventsDisabled.delete(l),vu())},[l,u]),b.useEffect(()=>{const T=()=>m({});return document.addEventListener(Ya,T),()=>document.removeEventListener(Ya,T)},[]),c.jsx($e.div,{...d,ref:g,style:{pointerEvents:A?C?"auto":"none":void 0,...e.style},onFocusCapture:Le(e.onFocusCapture,E.onFocusCapture),onBlurCapture:Le(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:Le(e.onPointerDownCapture,F.onPointerDownCapture)})});qi.displayName=dw;var pw="DismissableLayerBranch",mw=b.forwardRef((e,t)=>{const r=b.useContext(bu),n=b.useRef(null),o=Ze(t,n);return b.useEffect(()=>{const i=n.current;if(i)return r.branches.add(i),()=>{r.branches.delete(i)}},[r.branches]),c.jsx($e.div,{...e,ref:o})});mw.displayName=pw;function hw(e,t=globalThis?.document){const r=ar(e),n=b.useRef(!1),o=b.useRef(()=>{});return b.useEffect(()=>{const i=a=>{if(a.target&&!n.current){let d=function(){wu(uw,r,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=d,t.addEventListener("click",o.current,{once:!0})):d()}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 gw(e,t=globalThis?.document){const r=ar(e),n=b.useRef(!1);return b.useEffect(()=>{const o=i=>{i.target&&!n.current&&wu(fw,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 vu(){const e=new CustomEvent(Ya);document.dispatchEvent(e)}function wu(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?lw(o,i):o.dispatchEvent(i)}var Xa=0;function Ja(){b.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Su()),document.body.insertAdjacentElement("beforeend",e[1]??Su()),Xa++,()=>{Xa===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Xa--}},[])}function Su(){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 Qa="focusScope.autoFocusOnMount",Za="focusScope.autoFocusOnUnmount",xu={bubbles:!1,cancelable:!0},yw="FocusScope",Yi=b.forwardRef((e,t)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...s}=e,[a,d]=b.useState(null),u=ar(o),l=ar(i),f=b.useRef(null),p=Ze(t,h=>d(h)),m=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(n){let h=function(A){if(m.paused||!a)return;const C=A.target;a.contains(C)?f.current=C:Nn(f.current,{select:!0})},y=function(A){if(m.paused||!a)return;const C=A.relatedTarget;C!==null&&(a.contains(C)||Nn(f.current,{select:!0}))},w=function(A){if(document.activeElement===document.body)for(const F of A)F.removedNodes.length>0&&Nn(a)};document.addEventListener("focusin",h),document.addEventListener("focusout",y);const v=new MutationObserver(w);return a&&v.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",h),document.removeEventListener("focusout",y),v.disconnect()}}},[n,a,m.paused]),b.useEffect(()=>{if(a){Eu.add(m);const h=document.activeElement;if(!a.contains(h)){const w=new CustomEvent(Qa,xu);a.addEventListener(Qa,u),a.dispatchEvent(w),w.defaultPrevented||(bw(Aw(Au(a)),{select:!0}),document.activeElement===h&&Nn(a))}return()=>{a.removeEventListener(Qa,u),setTimeout(()=>{const w=new CustomEvent(Za,xu);a.addEventListener(Za,l),a.dispatchEvent(w),w.defaultPrevented||Nn(h??document.body,{select:!0}),a.removeEventListener(Za,l),Eu.remove(m)},0)}}},[a,u,l,m]);const g=b.useCallback(h=>{if(!r&&!n||m.paused)return;const y=h.key==="Tab"&&!h.altKey&&!h.ctrlKey&&!h.metaKey,w=document.activeElement;if(y&&w){const v=h.currentTarget,[A,C]=vw(v);A&&C?!h.shiftKey&&w===C?(h.preventDefault(),r&&Nn(A,{select:!0})):h.shiftKey&&w===A&&(h.preventDefault(),r&&Nn(C,{select:!0})):w===v&&h.preventDefault()}},[r,n,m.paused]);return c.jsx($e.div,{tabIndex:-1,...s,ref:p,onKeyDown:g})});Yi.displayName=yw;function bw(e,{select:t=!1}={}){const r=document.activeElement;for(const n of e)if(Nn(n,{select:t}),document.activeElement!==r)return}function vw(e){const t=Au(e),r=Cu(t,e),n=Cu(t.reverse(),e);return[r,n]}function Au(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 Cu(e,t){for(const r of e)if(!ww(r,{upTo:t}))return r}function ww(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 Sw(e){return e instanceof HTMLInputElement&&"select"in e}function Nn(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&Sw(e)&&t&&e.select()}}var Eu=xw();function xw(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=Nu(e,t),e.unshift(t)},remove(t){e=Nu(e,t),e[0]?.resume()}}}function Nu(e,t){const r=[...e],n=r.indexOf(t);return n!==-1&&r.splice(n,1),r}function Aw(e){return e.filter(t=>t.tagName!=="A")}var er=globalThis?.document?b.useLayoutEffect:()=>{},Cw=b[" useId ".trim().toString()]||(()=>{}),Ew=0;function cn(e){const[t,r]=b.useState(Cw());return er(()=>{r(n=>n??String(Ew++))},[e]),e||(t?`radix-${t}`:"")}const Nw=["top","right","bottom","left"],kn=Math.min,Ar=Math.max,Xi=Math.round,Ji=Math.floor,Qr=e=>({x:e,y:e}),kw={left:"right",right:"left",bottom:"top",top:"bottom"};function el(e,t,r){return Ar(e,kn(t,r))}function dn(e,t){return typeof e=="function"?e(t):e}function un(e){return e.split("-")[0]}function ao(e){return e.split("-")[1]}function tl(e){return e==="x"?"y":"x"}function rl(e){return e==="y"?"height":"width"}function Zr(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function nl(e){return tl(Zr(e))}function _w(e,t,r){r===void 0&&(r=!1);const n=ao(e),o=nl(e),i=rl(o);let s=o==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(s=Qi(s)),[s,Qi(s)]}function Tw(e){const t=Qi(e);return[ol(e),t,ol(t)]}function ol(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const ku=["left","right"],_u=["right","left"],Fw=["top","bottom"],Pw=["bottom","top"];function Ow(e,t,r){switch(e){case"top":case"bottom":return r?t?_u:ku:t?ku:_u;case"left":case"right":return t?Fw:Pw;default:return[]}}function Iw(e,t,r,n){const o=ao(e);let i=Ow(un(e),r==="start",n);return o&&(i=i.map(s=>s+"-"+o),t&&(i=i.concat(i.map(ol)))),i}function Qi(e){const t=un(e);return kw[t]+e.slice(t.length)}function Mw(e){return{top:0,right:0,bottom:0,left:0,...e}}function Tu(e){return typeof e!="number"?Mw(e):{top:e,right:e,bottom:e,left:e}}function Zi(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 Fu(e,t,r){let{reference:n,floating:o}=e;const i=Zr(t),s=nl(t),a=rl(s),d=un(t),u=i==="y",l=n.x+n.width/2-o.width/2,f=n.y+n.height/2-o.height/2,p=n[a]/2-o[a]/2;let m;switch(d){case"top":m={x:l,y:n.y-o.height};break;case"bottom":m={x:l,y:n.y+n.height};break;case"right":m={x:n.x+n.width,y:f};break;case"left":m={x:n.x-o.width,y:f};break;default:m={x:n.x,y:n.y}}switch(ao(t)){case"start":m[s]-=p*(r&&u?-1:1);break;case"end":m[s]+=p*(r&&u?-1:1);break}return m}async function Lw(e,t){var r;t===void 0&&(t={});const{x:n,y:o,platform:i,rects:s,elements:a,strategy:d}=e,{boundary:u="clippingAncestors",rootBoundary:l="viewport",elementContext:f="floating",altBoundary:p=!1,padding:m=0}=dn(t,e),g=Tu(m),y=a[p?f==="floating"?"reference":"floating":f],w=Zi(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:l,strategy:d})),v=f==="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)),C=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=Zi(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:A,strategy:d}):v);return{top:(w.top-F.top+g.top)/C.y,bottom:(F.bottom-w.bottom+g.bottom)/C.y,left:(w.left-F.left+g.left)/C.x,right:(F.right-w.right+g.right)/C.x}}const Dw=50,Bw=async(e,t,r)=>{const{placement:n="bottom",strategy:o="absolute",middleware:i=[],platform:s}=r,a=s.detectOverflow?s:{...s,detectOverflow:Lw},d=await(s.isRTL==null?void 0:s.isRTL(t));let u=await s.getElementRects({reference:e,floating:t,strategy:o}),{x:l,y:f}=Fu(u,n,d),p=n,m=0;const g={};for(let h=0;h<i.length;h++){const y=i[h];if(!y)continue;const{name:w,fn:v}=y,{x:A,y:C,data:F,reset:E}=await v({x:l,y:f,initialPlacement:n,placement:p,strategy:o,middlewareData:g,rects:u,platform:a,elements:{reference:e,floating:t}});l=A??l,f=C??f,g[w]={...g[w],...F},E&&m<Dw&&(m++,typeof E=="object"&&(E.placement&&(p=E.placement),E.rects&&(u=E.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:o}):E.rects),{x:l,y:f}=Fu(u,p,d)),h=-1)}return{x:l,y:f,placement:p,strategy:o,middlewareData:g}},$w=e=>({name:"arrow",options:e,async fn(t){const{x:r,y:n,placement:o,rects:i,platform:s,elements:a,middlewareData:d}=t,{element:u,padding:l=0}=dn(e,t)||{};if(u==null)return{};const f=Tu(l),p={x:r,y:n},m=nl(o),g=rl(m),h=await s.getDimensions(u),y=m==="y",w=y?"top":"left",v=y?"bottom":"right",A=y?"clientHeight":"clientWidth",C=i.reference[g]+i.reference[m]-p[m]-i.floating[g],F=p[m]-i.reference[m],E=await(s.getOffsetParent==null?void 0:s.getOffsetParent(u));let T=E?E[A]:0;(!T||!await(s.isElement==null?void 0:s.isElement(E)))&&(T=a.floating[A]||i.floating[g]);const N=C/2-F/2,x=T/2-h[g]/2-1,O=kn(f[w],x),k=kn(f[v],x),D=O,R=T-h[g]-k,I=T/2-h[g]/2+N,z=el(D,I,R),L=!d.arrow&&ao(o)!=null&&I!==z&&i.reference[g]/2-(I<D?O:k)-h[g]/2<0,B=L?I<D?I-D:I-R:0;return{[m]:p[m]+B,data:{[m]:z,centerOffset:I-z-B,...L&&{alignmentOffset:B}},reset:L}}}),jw=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:d,elements:u}=t,{mainAxis:l=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:h=!0,...y}=dn(e,t);if((r=i.arrow)!=null&&r.alignmentOffset)return{};const w=un(o),v=Zr(a),A=un(a)===a,C=await(d.isRTL==null?void 0:d.isRTL(u.floating)),F=p||(A||!h?[Qi(a)]:Tw(a)),E=g!=="none";!p&&E&&F.push(...Iw(a,h,g,C));const T=[a,...F],N=await d.detectOverflow(t,y),x=[];let O=((n=i.flip)==null?void 0:n.overflows)||[];if(l&&x.push(N[w]),f){const I=_w(o,s,C);x.push(N[I[0]],N[I[1]])}if(O=[...O,{placement:o,overflows:x}],!x.every(I=>I<=0)){var k,D;const I=(((k=i.flip)==null?void 0:k.index)||0)+1,z=T[I];if(z&&(!(f==="alignment"?v!==Zr(z):!1)||O.every(M=>Zr(M.placement)===v?M.overflows[0]>0:!0)))return{data:{index:I,overflows:O},reset:{placement:z}};let L=(D=O.filter(B=>B.overflows[0]<=0).sort((B,M)=>B.overflows[1]-M.overflows[1])[0])==null?void 0:D.placement;if(!L)switch(m){case"bestFit":{var R;const B=(R=O.filter(M=>{if(E){const V=Zr(M.placement);return V===v||V==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(V=>V>0).reduce((V,$)=>V+$,0)]).sort((M,V)=>M[1]-V[1])[0])==null?void 0:R[0];B&&(L=B);break}case"initialPlacement":L=a;break}if(o!==L)return{reset:{placement:L}}}return{}}}};function Pu(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Ou(e){return Nw.some(t=>e[t]>=0)}const zw=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:r,platform:n}=t,{strategy:o="referenceHidden",...i}=dn(e,t);switch(o){case"referenceHidden":{const s=await n.detectOverflow(t,{...i,elementContext:"reference"}),a=Pu(s,r.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Ou(a)}}}case"escaped":{const s=await n.detectOverflow(t,{...i,altBoundary:!0}),a=Pu(s,r.floating);return{data:{escapedOffsets:a,escaped:Ou(a)}}}default:return{}}}}},Iu=new Set(["left","top"]);async function Uw(e,t){const{placement:r,platform:n,elements:o}=e,i=await(n.isRTL==null?void 0:n.isRTL(o.floating)),s=un(r),a=ao(r),d=Zr(r)==="y",u=Iu.has(s)?-1:1,l=i&&d?-1:1,f=dn(t,e);let{mainAxis:p,crossAxis:m,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof g=="number"&&(m=a==="end"?g*-1:g),d?{x:m*l,y:p*u}:{x:p*u,y:m*l}}const Vw=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,d=await Uw(t,e);return s===((r=a.offset)==null?void 0:r.placement)&&(n=a.arrow)!=null&&n.alignmentOffset?{}:{x:o+d.x,y:i+d.y,data:{...d,placement:s}}}}},Hw=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:d={fn:w=>{let{x:v,y:A}=w;return{x:v,y:A}}},...u}=dn(e,t),l={x:r,y:n},f=await i.detectOverflow(t,u),p=Zr(un(o)),m=tl(p);let g=l[m],h=l[p];if(s){const w=m==="y"?"top":"left",v=m==="y"?"bottom":"right",A=g+f[w],C=g-f[v];g=el(A,g,C)}if(a){const w=p==="y"?"top":"left",v=p==="y"?"bottom":"right",A=h+f[w],C=h-f[v];h=el(A,h,C)}const y=d.fn({...t,[m]:g,[p]:h});return{...y,data:{x:y.x-r,y:y.y-n,enabled:{[m]:s,[p]:a}}}}}},Ww=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:d=!0,crossAxis:u=!0}=dn(e,t),l={x:r,y:n},f=Zr(o),p=tl(f);let m=l[p],g=l[f];const h=dn(a,t),y=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(d){const A=p==="y"?"height":"width",C=i.reference[p]-i.floating[A]+y.mainAxis,F=i.reference[p]+i.reference[A]-y.mainAxis;m<C?m=C:m>F&&(m=F)}if(u){var w,v;const A=p==="y"?"width":"height",C=Iu.has(un(o)),F=i.reference[f]-i.floating[A]+(C&&((w=s.offset)==null?void 0:w[f])||0)+(C?0:y.crossAxis),E=i.reference[f]+i.reference[A]+(C?0:((v=s.offset)==null?void 0:v[f])||0)-(C?y.crossAxis:0);g<F?g=F:g>E&&(g=E)}return{[p]:m,[f]:g}}}},Rw=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:d=()=>{},...u}=dn(e,t),l=await s.detectOverflow(t,u),f=un(o),p=ao(o),m=Zr(o)==="y",{width:g,height:h}=i.floating;let y,w;f==="top"||f==="bottom"?(y=f,w=p===(await(s.isRTL==null?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(w=f,y=p==="end"?"top":"bottom");const v=h-l.top-l.bottom,A=g-l.left-l.right,C=kn(h-l[y],v),F=kn(g-l[w],A),E=!t.middlewareData.shift;let T=C,N=F;if((r=t.middlewareData.shift)!=null&&r.enabled.x&&(N=A),(n=t.middlewareData.shift)!=null&&n.enabled.y&&(T=v),E&&!p){const O=Ar(l.left,0),k=Ar(l.right,0),D=Ar(l.top,0),R=Ar(l.bottom,0);m?N=g-2*(O!==0||k!==0?O+k:Ar(l.left,l.right)):T=h-2*(D!==0||R!==0?D+R:Ar(l.top,l.bottom))}await d({...t,availableWidth:N,availableHeight:T});const x=await s.getDimensions(a.floating);return g!==x.width||h!==x.height?{reset:{rects:!0}}:{}}}};function es(){return typeof window<"u"}function lo(e){return Mu(e)?(e.nodeName||"").toLowerCase():"#document"}function Cr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function en(e){var t;return(t=(Mu(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Mu(e){return es()?e instanceof Node||e instanceof Cr(e).Node:!1}function zr(e){return es()?e instanceof Element||e instanceof Cr(e).Element:!1}function fn(e){return es()?e instanceof HTMLElement||e instanceof Cr(e).HTMLElement:!1}function Lu(e){return!es()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Cr(e).ShadowRoot}function Qo(e){const{overflow:t,overflowX:r,overflowY:n,display:o}=Ur(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+r)&&o!=="inline"&&o!=="contents"}function Gw(e){return/^(table|td|th)$/.test(lo(e))}function ts(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Kw=/transform|translate|scale|rotate|perspective|filter/,qw=/paint|layout|strict|content/,Vn=e=>!!e&&e!=="none";let il;function sl(e){const t=zr(e)?Ur(e):e;return Vn(t.transform)||Vn(t.translate)||Vn(t.scale)||Vn(t.rotate)||Vn(t.perspective)||!al()&&(Vn(t.backdropFilter)||Vn(t.filter))||Kw.test(t.willChange||"")||qw.test(t.contain||"")}function Yw(e){let t=_n(e);for(;fn(t)&&!co(t);){if(sl(t))return t;if(ts(t))return null;t=_n(t)}return null}function al(){return il==null&&(il=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),il}function co(e){return/^(html|body|#document)$/.test(lo(e))}function Ur(e){return Cr(e).getComputedStyle(e)}function rs(e){return zr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function _n(e){if(lo(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Lu(e)&&e.host||en(e);return Lu(t)?t.host:t}function Du(e){const t=_n(e);return co(t)?e.ownerDocument?e.ownerDocument.body:e.body:fn(t)&&Qo(t)?t:Du(t)}function Zo(e,t,r){var n;t===void 0&&(t=[]),r===void 0&&(r=!0);const o=Du(e),i=o===((n=e.ownerDocument)==null?void 0:n.body),s=Cr(o);if(i){const a=ll(s);return t.concat(s,s.visualViewport||[],Qo(o)?o:[],a&&r?Zo(a):[])}else return t.concat(o,Zo(o,[],r))}function ll(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Bu(e){const t=Ur(e);let r=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const o=fn(e),i=o?e.offsetWidth:r,s=o?e.offsetHeight:n,a=Xi(r)!==i||Xi(n)!==s;return a&&(r=i,n=s),{width:r,height:n,$:a}}function cl(e){return zr(e)?e:e.contextElement}function uo(e){const t=cl(e);if(!fn(t))return Qr(1);const r=t.getBoundingClientRect(),{width:n,height:o,$:i}=Bu(t);let s=(i?Xi(r.width):r.width)/n,a=(i?Xi(r.height):r.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}const Xw=Qr(0);function $u(e){const t=Cr(e);return!al()||!t.visualViewport?Xw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Jw(e,t,r){return t===void 0&&(t=!1),!r||t&&r!==Cr(e)?!1:t}function Hn(e,t,r,n){t===void 0&&(t=!1),r===void 0&&(r=!1);const o=e.getBoundingClientRect(),i=cl(e);let s=Qr(1);t&&(n?zr(n)&&(s=uo(n)):s=uo(e));const a=Jw(i,r,n)?$u(i):Qr(0);let d=(o.left+a.x)/s.x,u=(o.top+a.y)/s.y,l=o.width/s.x,f=o.height/s.y;if(i){const p=Cr(i),m=n&&zr(n)?Cr(n):n;let g=p,h=ll(g);for(;h&&n&&m!==g;){const y=uo(h),w=h.getBoundingClientRect(),v=Ur(h),A=w.left+(h.clientLeft+parseFloat(v.paddingLeft))*y.x,C=w.top+(h.clientTop+parseFloat(v.paddingTop))*y.y;d*=y.x,u*=y.y,l*=y.x,f*=y.y,d+=A,u+=C,g=Cr(h),h=ll(g)}}return Zi({width:l,height:f,x:d,y:u})}function ns(e,t){const r=rs(e).scrollLeft;return t?t.left+r:Hn(en(e)).left+r}function ju(e,t){const r=e.getBoundingClientRect(),n=r.left+t.scrollLeft-ns(e,r),o=r.top+t.scrollTop;return{x:n,y:o}}function Qw(e){let{elements:t,rect:r,offsetParent:n,strategy:o}=e;const i=o==="fixed",s=en(n),a=t?ts(t.floating):!1;if(n===s||a&&i)return r;let d={scrollLeft:0,scrollTop:0},u=Qr(1);const l=Qr(0),f=fn(n);if((f||!f&&!i)&&((lo(n)!=="body"||Qo(s))&&(d=rs(n)),f)){const m=Hn(n);u=uo(n),l.x=m.x+n.clientLeft,l.y=m.y+n.clientTop}const p=s&&!f&&!i?ju(s,d):Qr(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-d.scrollLeft*u.x+l.x+p.x,y:r.y*u.y-d.scrollTop*u.y+l.y+p.y}}function Zw(e){return Array.from(e.getClientRects())}function eS(e){const t=en(e),r=rs(e),n=e.ownerDocument.body,o=Ar(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),i=Ar(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let s=-r.scrollLeft+ns(e);const a=-r.scrollTop;return Ur(n).direction==="rtl"&&(s+=Ar(t.clientWidth,n.clientWidth)-o),{width:o,height:i,x:s,y:a}}const zu=25;function tS(e,t){const r=Cr(e),n=en(e),o=r.visualViewport;let i=n.clientWidth,s=n.clientHeight,a=0,d=0;if(o){i=o.width,s=o.height;const l=al();(!l||l&&t==="fixed")&&(a=o.offsetLeft,d=o.offsetTop)}const u=ns(n);if(u<=0){const l=n.ownerDocument,f=l.body,p=getComputedStyle(f),m=l.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,g=Math.abs(n.clientWidth-f.clientWidth-m);g<=zu&&(i-=g)}else u<=zu&&(i+=u);return{width:i,height:s,x:a,y:d}}function rS(e,t){const r=Hn(e,!0,t==="fixed"),n=r.top+e.clientTop,o=r.left+e.clientLeft,i=fn(e)?uo(e):Qr(1),s=e.clientWidth*i.x,a=e.clientHeight*i.y,d=o*i.x,u=n*i.y;return{width:s,height:a,x:d,y:u}}function Uu(e,t,r){let n;if(t==="viewport")n=tS(e,r);else if(t==="document")n=eS(en(e));else if(zr(t))n=rS(t,r);else{const o=$u(e);n={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Zi(n)}function Vu(e,t){const r=_n(e);return r===t||!zr(r)||co(r)?!1:Ur(r).position==="fixed"||Vu(r,t)}function nS(e,t){const r=t.get(e);if(r)return r;let n=Zo(e,[],!1).filter(a=>zr(a)&&lo(a)!=="body"),o=null;const i=Ur(e).position==="fixed";let s=i?_n(e):e;for(;zr(s)&&!co(s);){const a=Ur(s),d=sl(s);!d&&a.position==="fixed"&&(o=null),(i?!d&&!o:!d&&a.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Qo(s)&&!d&&Vu(e,s))?n=n.filter(l=>l!==s):o=a,s=_n(s)}return t.set(e,n),n}function oS(e){let{element:t,boundary:r,rootBoundary:n,strategy:o}=e;const s=[...r==="clippingAncestors"?ts(t)?[]:nS(t,this._c):[].concat(r),n],a=Uu(t,s[0],o);let d=a.top,u=a.right,l=a.bottom,f=a.left;for(let p=1;p<s.length;p++){const m=Uu(t,s[p],o);d=Ar(m.top,d),u=kn(m.right,u),l=kn(m.bottom,l),f=Ar(m.left,f)}return{width:u-f,height:l-d,x:f,y:d}}function iS(e){const{width:t,height:r}=Bu(e);return{width:t,height:r}}function sS(e,t,r){const n=fn(t),o=en(t),i=r==="fixed",s=Hn(e,!0,i,t);let a={scrollLeft:0,scrollTop:0};const d=Qr(0);function u(){d.x=ns(o)}if(n||!n&&!i)if((lo(t)!=="body"||Qo(o))&&(a=rs(t)),n){const m=Hn(t,!0,i,t);d.x=m.x+t.clientLeft,d.y=m.y+t.clientTop}else o&&u();i&&!n&&o&&u();const l=o&&!n&&!i?ju(o,a):Qr(0),f=s.left+a.scrollLeft-d.x-l.x,p=s.top+a.scrollTop-d.y-l.y;return{x:f,y:p,width:s.width,height:s.height}}function dl(e){return Ur(e).position==="static"}function Hu(e,t){if(!fn(e)||Ur(e).position==="fixed")return null;if(t)return t(e);let r=e.offsetParent;return en(e)===r&&(r=r.ownerDocument.body),r}function Wu(e,t){const r=Cr(e);if(ts(e))return r;if(!fn(e)){let o=_n(e);for(;o&&!co(o);){if(zr(o)&&!dl(o))return o;o=_n(o)}return r}let n=Hu(e,t);for(;n&&Gw(n)&&dl(n);)n=Hu(n,t);return n&&co(n)&&dl(n)&&!sl(n)?r:n||Yw(e)||r}const aS=async function(e){const t=this.getOffsetParent||Wu,r=this.getDimensions,n=await r(e.floating);return{reference:sS(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function lS(e){return Ur(e).direction==="rtl"}const cS={convertOffsetParentRelativeRectToViewportRelativeRect:Qw,getDocumentElement:en,getClippingRect:oS,getOffsetParent:Wu,getElementRects:aS,getClientRects:Zw,getDimensions:iS,getScale:uo,isElement:zr,isRTL:lS};function Ru(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function dS(e,t){let r=null,n;const o=en(e);function i(){var a;clearTimeout(n),(a=r)==null||a.disconnect(),r=null}function s(a,d){a===void 0&&(a=!1),d===void 0&&(d=1),i();const u=e.getBoundingClientRect(),{left:l,top:f,width:p,height:m}=u;if(a||t(),!p||!m)return;const g=Ji(f),h=Ji(o.clientWidth-(l+p)),y=Ji(o.clientHeight-(f+m)),w=Ji(l),A={rootMargin:-g+"px "+-h+"px "+-y+"px "+-w+"px",threshold:Ar(0,kn(1,d))||1};let C=!0;function F(E){const T=E[0].intersectionRatio;if(T!==d){if(!C)return s();T?s(!1,T):n=setTimeout(()=>{s(!1,1e-7)},1e3)}T===1&&!Ru(u,e.getBoundingClientRect())&&s(),C=!1}try{r=new IntersectionObserver(F,{...A,root:o.ownerDocument})}catch{r=new IntersectionObserver(F,A)}r.observe(e)}return s(!0),i}function uS(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:d=!1}=n,u=cl(e),l=o||i?[...u?Zo(u):[],...t?Zo(t):[]]:[];l.forEach(w=>{o&&w.addEventListener("scroll",r,{passive:!0}),i&&w.addEventListener("resize",r)});const f=u&&a?dS(u,r):null;let p=-1,m=null;s&&(m=new ResizeObserver(w=>{let[v]=w;v&&v.target===u&&m&&t&&(m.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var A;(A=m)==null||A.observe(t)})),r()}),u&&!d&&m.observe(u),t&&m.observe(t));let g,h=d?Hn(e):null;d&&y();function y(){const w=Hn(e);h&&!Ru(h,w)&&r(),h=w,g=requestAnimationFrame(y)}return r(),()=>{var w;l.forEach(v=>{o&&v.removeEventListener("scroll",r),i&&v.removeEventListener("resize",r)}),f?.(),(w=m)==null||w.disconnect(),m=null,d&&cancelAnimationFrame(g)}}const fS=Vw,pS=Hw,mS=jw,hS=Rw,gS=zw,Gu=$w,yS=Ww,bS=(e,t,r)=>{const n=new Map,o={platform:cS,...r},i={...o.platform,_c:n};return Bw(e,t,{...o,platform:i})};var vS=typeof document<"u",wS=function(){},os=vS?S.useLayoutEffect:wS;function is(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(!is(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)&&!is(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function Ku(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function qu(e,t){const r=Ku(e);return Math.round(t*r)/r}function ul(e){const t=b.useRef(e);return os(()=>{t.current=e}),t}function SS(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:d,open:u}=e,[l,f]=b.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=b.useState(n);is(p,n)||m(n);const[g,h]=b.useState(null),[y,w]=b.useState(null),v=b.useCallback(M=>{M!==E.current&&(E.current=M,h(M))},[]),A=b.useCallback(M=>{M!==T.current&&(T.current=M,w(M))},[]),C=i||g,F=s||y,E=b.useRef(null),T=b.useRef(null),N=b.useRef(l),x=d!=null,O=ul(d),k=ul(o),D=ul(u),R=b.useCallback(()=>{if(!E.current||!T.current)return;const M={placement:t,strategy:r,middleware:p};k.current&&(M.platform=k.current),bS(E.current,T.current,M).then(V=>{const $={...V,isPositioned:D.current!==!1};I.current&&!is(N.current,$)&&(N.current=$,_i.flushSync(()=>{f($)}))})},[p,t,r,k,D]);os(()=>{u===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,f(M=>({...M,isPositioned:!1})))},[u]);const I=b.useRef(!1);os(()=>(I.current=!0,()=>{I.current=!1}),[]),os(()=>{if(C&&(E.current=C),F&&(T.current=F),C&&F){if(O.current)return O.current(C,F,R);R()}},[C,F,R,O,x]);const z=b.useMemo(()=>({reference:E,floating:T,setReference:v,setFloating:A}),[v,A]),L=b.useMemo(()=>({reference:C,floating:F}),[C,F]),B=b.useMemo(()=>{const M={position:r,left:0,top:0};if(!L.floating)return M;const V=qu(L.floating,l.x),$=qu(L.floating,l.y);return a?{...M,transform:"translate("+V+"px, "+$+"px)",...Ku(L.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:V,top:$}},[r,a,L.floating,l.x,l.y]);return b.useMemo(()=>({...l,update:R,refs:z,elements:L,floatingStyles:B}),[l,R,z,L,B])}const xS=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?Gu({element:n.current,padding:o}).fn(r):{}:n?Gu({element:n,padding:o}).fn(r):{}}}},AS=(e,t)=>{const r=fS(e);return{name:r.name,fn:r.fn,options:[e,t]}},CS=(e,t)=>{const r=pS(e);return{name:r.name,fn:r.fn,options:[e,t]}},ES=(e,t)=>({fn:yS(e).fn,options:[e,t]}),NS=(e,t)=>{const r=mS(e);return{name:r.name,fn:r.fn,options:[e,t]}},kS=(e,t)=>{const r=hS(e);return{name:r.name,fn:r.fn,options:[e,t]}},_S=(e,t)=>{const r=gS(e);return{name:r.name,fn:r.fn,options:[e,t]}},TS=(e,t)=>{const r=xS(e);return{name:r.name,fn:r.fn,options:[e,t]}};var FS="Arrow",Yu=b.forwardRef((e,t)=>{const{children:r,width:n=10,height:o=5,...i}=e;return c.jsx($e.svg,{...i,ref:t,width:n,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:c.jsx("polygon",{points:"0,0 30,0 15,10"})})});Yu.displayName=FS;var PS=Yu;function ei(e){const[t,r]=b.useState(void 0);return er(()=>{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 d=i.borderBoxSize,u=Array.isArray(d)?d[0]:d;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 fl="Popper",[Xu,ss]=xr(fl),[OS,Ju]=Xu(fl),Qu=e=>{const{__scopePopper:t,children:r}=e,[n,o]=b.useState(null);return c.jsx(OS,{scope:t,anchor:n,onAnchorChange:o,children:r})};Qu.displayName=fl;var Zu="PopperAnchor",ef=b.forwardRef((e,t)=>{const{__scopePopper:r,virtualRef:n,...o}=e,i=Ju(Zu,r),s=b.useRef(null),a=Ze(t,s),d=b.useRef(null);return b.useEffect(()=>{const u=d.current;d.current=n?.current||s.current,u!==d.current&&i.onAnchorChange(d.current)}),n?null:c.jsx($e.div,{...o,ref:a})});ef.displayName=Zu;var pl="PopperContent",[IS,MS]=Xu(pl),tf=b.forwardRef((e,t)=>{const{__scopePopper:r,side:n="bottom",sideOffset:o=0,align:i="center",alignOffset:s=0,arrowPadding:a=0,avoidCollisions:d=!0,collisionBoundary:u=[],collisionPadding:l=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:g,...h}=e,y=Ju(pl,r),[w,v]=b.useState(null),A=Ze(t,q=>v(q)),[C,F]=b.useState(null),E=ei(C),T=E?.width??0,N=E?.height??0,x=n+(i!=="center"?"-"+i:""),O=typeof l=="number"?l:{top:0,right:0,bottom:0,left:0,...l},k=Array.isArray(u)?u:[u],D=k.length>0,R={padding:O,boundary:k.filter(DS),altBoundary:D},{refs:I,floatingStyles:z,placement:L,isPositioned:B,middlewareData:M}=SS({strategy:"fixed",placement:x,whileElementsMounted:(...q)=>uS(...q,{animationFrame:m==="always"}),elements:{reference:y.anchor},middleware:[AS({mainAxis:o+N,alignmentAxis:s}),d&&CS({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?ES():void 0,...R}),d&&NS({...R}),kS({...R,apply:({elements:q,rects:ne,availableWidth:Te,availableHeight:ee})=>{const{width:te,height:he}=ne.reference,ce=q.floating.style;ce.setProperty("--radix-popper-available-width",`${Te}px`),ce.setProperty("--radix-popper-available-height",`${ee}px`),ce.setProperty("--radix-popper-anchor-width",`${te}px`),ce.setProperty("--radix-popper-anchor-height",`${he}px`)}}),C&&TS({element:C,padding:a}),BS({arrowWidth:T,arrowHeight:N}),p&&_S({strategy:"referenceHidden",...R})]}),[V,$]=of(L),ie=ar(g);er(()=>{B&&ie?.()},[B,ie]);const H=M.arrow?.x,K=M.arrow?.y,X=M.arrow?.centerOffset!==0,[le,re]=b.useState();return er(()=>{w&&re(window.getComputedStyle(w).zIndex)},[w]),c.jsx("div",{ref:I.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:B?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:le,"--radix-popper-transform-origin":[M.transformOrigin?.x,M.transformOrigin?.y].join(" "),...M.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(IS,{scope:r,placedSide:V,onArrowChange:F,arrowX:H,arrowY:K,shouldHideArrow:X,children:c.jsx($e.div,{"data-side":V,"data-align":$,...h,ref:A,style:{...h.style,animation:B?void 0:"none"}})})})});tf.displayName=pl;var rf="PopperArrow",LS={top:"bottom",right:"left",bottom:"top",left:"right"},nf=b.forwardRef(function(t,r){const{__scopePopper:n,...o}=t,i=MS(rf,n),s=LS[i.placedSide];return c.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:c.jsx(PS,{...o,ref:r,style:{...o.style,display:"block"}})})});nf.displayName=rf;function DS(e){return e!==null}var BS=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,d=s?0:e.arrowHeight,[u,l]=of(r),f={start:"0%",center:"50%",end:"100%"}[l],p=(o.arrow?.x??0)+a/2,m=(o.arrow?.y??0)+d/2;let g="",h="";return u==="bottom"?(g=s?f:`${p}px`,h=`${-d}px`):u==="top"?(g=s?f:`${p}px`,h=`${n.floating.height+d}px`):u==="right"?(g=`${-d}px`,h=s?f:`${m}px`):u==="left"&&(g=`${n.floating.width+d}px`,h=s?f:`${m}px`),{data:{x:g,y:h}}}});function of(e){const[t,r="center"]=e.split("-");return[t,r]}var sf=Qu,ml=ef,af=tf,lf=nf,$S="Portal",as=b.forwardRef((e,t)=>{const{container:r,...n}=e,[o,i]=b.useState(!1);er(()=>i(!0),[]);const s=r||o&&globalThis?.document?.body;return s?od.createPortal(c.jsx($e.div,{...n,ref:t}),s):null});as.displayName=$S;function jS(e){const t=zS(e),r=b.forwardRef((n,o)=>{const{children:i,...s}=n,a=b.Children.toArray(i),d=a.find(VS);if(d){const u=d.props.children,l=a.map(f=>f===d?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:f);return c.jsx(t,{...s,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...s,ref:o,children:i})});return r.displayName=`${e}.Slot`,r}function zS(e){const t=b.forwardRef((r,n)=>{const{children:o,...i}=r;if(b.isValidElement(o)){const s=WS(o),a=HS(i,o.props);return o.type!==b.Fragment&&(a.ref=n?Un(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 US=Symbol("radix.slottable");function VS(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===US}function HS(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 d=i(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...i}:n==="className"&&(r[n]=[o,i].filter(Boolean).join(" "))}return{...e,...r}}function WS(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 RS=b[" useInsertionEffect ".trim().toString()]||er;function tn({prop:e,defaultProp:t,onChange:r=()=>{},caller:n}){const[o,i,s]=GS({defaultProp:t,onChange:r}),a=e!==void 0,d=a?e:o;{const l=b.useRef(e!==void 0);b.useEffect(()=>{const f=l.current;f!==a&&console.warn(`${n} is changing from ${f?"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.`),l.current=a},[a,n])}const u=b.useCallback(l=>{if(a){const f=KS(l)?l(e):l;f!==e&&s.current?.(f)}else i(l)},[a,e,i,s]);return[d,u]}function GS({defaultProp:e,onChange:t}){const[r,n]=b.useState(e),o=b.useRef(r),i=b.useRef(t);return RS(()=>{i.current=t},[t]),b.useEffect(()=>{o.current!==r&&(i.current?.(r),o.current=r)},[r,o]),[r,n,i]}function KS(e){return typeof e=="function"}function ti(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 cf=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"}),qS="VisuallyHidden",YS=b.forwardRef((e,t)=>c.jsx($e.span,{...e,ref:t,style:{...cf,...e.style}}));YS.displayName=qS;var XS=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},fo=new WeakMap,ls=new WeakMap,cs={},hl=0,df=function(e){return e&&(e.host||df(e.parentNode))},JS=function(e,t){return t.map(function(r){if(e.contains(r))return r;var n=df(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})},QS=function(e,t,r,n){var o=JS(t,Array.isArray(e)?e:[e]);cs[r]||(cs[r]=new WeakMap);var i=cs[r],s=[],a=new Set,d=new Set(o),u=function(f){!f||a.has(f)||(a.add(f),u(f.parentNode))};o.forEach(u);var l=function(f){!f||d.has(f)||Array.prototype.forEach.call(f.children,function(p){if(a.has(p))l(p);else try{var m=p.getAttribute(n),g=m!==null&&m!=="false",h=(fo.get(p)||0)+1,y=(i.get(p)||0)+1;fo.set(p,h),i.set(p,y),s.push(p),h===1&&g&&ls.set(p,!0),y===1&&p.setAttribute(r,"true"),g||p.setAttribute(n,"true")}catch(w){console.error("aria-hidden: cannot operate on ",p,w)}})};return l(t),a.clear(),hl++,function(){s.forEach(function(f){var p=fo.get(f)-1,m=i.get(f)-1;fo.set(f,p),i.set(f,m),p||(ls.has(f)||f.removeAttribute(n),ls.delete(f)),m||f.removeAttribute(r)}),hl--,hl||(fo=new WeakMap,fo=new WeakMap,ls=new WeakMap,cs={})}},gl=function(e,t,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(e)?e:[e]),o=XS(e);return o?(n.push.apply(n,Array.from(o.querySelectorAll("[aria-live], script"))),QS(n,o,r,"aria-hidden")):function(){return null}},rn=function(){return rn=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},rn.apply(this,arguments)};function uf(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 ZS(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 ds="right-scroll-bar-position",us="width-before-scroll-bar",ex="with-scroll-bars-hidden",tx="--removed-body-scroll-bar-size";function yl(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function rx(e,t){var r=S.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 nx=typeof window<"u"?b.useLayoutEffect:b.useEffect,ff=new WeakMap;function ox(e,t){var r=rx(null,function(n){return e.forEach(function(o){return yl(o,n)})});return nx(function(){var n=ff.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)})}ff.set(r,e)},[e]),r}function ix(e){return e}function sx(e,t){t===void 0&&(t=ix);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 d=function(){var l=s;s=[],l.forEach(i)},u=function(){return Promise.resolve().then(d)};u(),r={push:function(l){s.push(l),u()},filter:function(l){return s=s.filter(l),r}}}};return o}function ax(e){e===void 0&&(e={});var t=sx(null);return t.options=rn({async:!0,ssr:!1},e),t}var pf=function(e){var t=e.sideCar,r=uf(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,rn({},r))};pf.isSideCarExport=!0;function lx(e,t){return e.useMedium(t),pf}var mf=ax(),bl=function(){},fs=b.forwardRef(function(e,t){var r=b.useRef(null),n=b.useState({onScrollCapture:bl,onWheelCapture:bl,onTouchMoveCapture:bl}),o=n[0],i=n[1],s=e.forwardProps,a=e.children,d=e.className,u=e.removeScrollBar,l=e.enabled,f=e.shards,p=e.sideCar,m=e.noRelative,g=e.noIsolation,h=e.inert,y=e.allowPinchZoom,w=e.as,v=w===void 0?"div":w,A=e.gapMode,C=uf(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),F=p,E=ox([r,t]),T=rn(rn({},C),o);return b.createElement(b.Fragment,null,l&&b.createElement(F,{sideCar:mf,removeScrollBar:u,shards:f,noRelative:m,noIsolation:g,inert:h,setCallbacks:i,allowPinchZoom:!!y,lockRef:r,gapMode:A}),s?b.cloneElement(b.Children.only(a),rn(rn({},T),{ref:E})):b.createElement(v,rn({},T,{className:d,ref:E}),a))});fs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},fs.classNames={fullWidth:us,zeroRight:ds};var cx=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function dx(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=cx();return t&&e.setAttribute("nonce",t),e}function ux(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function fx(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var px=function(){var e=0,t=null;return{add:function(r){e==0&&(t=dx())&&(ux(t,r),fx(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},mx=function(){var e=px();return function(t,r){b.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&r])}},hf=function(){var e=mx(),t=function(r){var n=r.styles,o=r.dynamic;return e(n,o),null};return t},hx={left:0,top:0,right:0,gap:0},vl=function(e){return parseInt(e||"",10)||0},gx=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[vl(r),vl(n),vl(o)]},yx=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return hx;var t=gx(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])}},bx=hf(),po="data-scroll-locked",vx=function(e,t,r,n){var o=e.left,i=e.top,s=e.right,a=e.gap;return r===void 0&&(r="margin"),`
|
|
2
|
+
.`.concat(ex,` {
|
|
3
3
|
overflow: hidden `).concat(n,`;
|
|
4
4
|
padding-right: `).concat(a,"px ").concat(n,`;
|
|
5
5
|
}
|
|
6
|
-
body[`).concat(
|
|
6
|
+
body[`).concat(po,`] {
|
|
7
7
|
overflow: hidden `).concat(n,`;
|
|
8
8
|
overscroll-behavior: contain;
|
|
9
9
|
`).concat([t&&"position: relative ".concat(n,";"),r==="margin"&&`
|
|
@@ -16,37 +16,37 @@
|
|
|
16
16
|
`),r==="padding"&&"padding-right: ".concat(a,"px ").concat(n,";")].filter(Boolean).join(""),`
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
.`).concat(
|
|
19
|
+
.`).concat(ds,` {
|
|
20
20
|
right: `).concat(a,"px ").concat(n,`;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
.`).concat(
|
|
23
|
+
.`).concat(us,` {
|
|
24
24
|
margin-right: `).concat(a,"px ").concat(n,`;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
.`).concat(
|
|
27
|
+
.`).concat(ds," .").concat(ds,` {
|
|
28
28
|
right: 0 `).concat(n,`;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
.`).concat(
|
|
31
|
+
.`).concat(us," .").concat(us,` {
|
|
32
32
|
margin-right: 0 `).concat(n,`;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
body[`).concat(
|
|
36
|
-
`).concat(
|
|
35
|
+
body[`).concat(po,`] {
|
|
36
|
+
`).concat(tx,": ").concat(a,`px;
|
|
37
37
|
}
|
|
38
|
-
`)},
|
|
38
|
+
`)},gf=function(){var e=parseInt(document.body.getAttribute(po)||"0",10);return isFinite(e)?e:0},wx=function(){b.useEffect(function(){return document.body.setAttribute(po,(gf()+1).toString()),function(){var e=gf()-1;e<=0?document.body.removeAttribute(po):document.body.setAttribute(po,e.toString())}},[])},Sx=function(e){var t=e.noRelative,r=e.noImportant,n=e.gapMode,o=n===void 0?"margin":n;wx();var i=b.useMemo(function(){return yx(o)},[o]);return b.createElement(bx,{styles:vx(i,!t,o,r?"":"!important")})},wl=!1;if(typeof window<"u")try{var ps=Object.defineProperty({},"passive",{get:function(){return wl=!0,!0}});window.addEventListener("test",ps,ps),window.removeEventListener("test",ps,ps)}catch{wl=!1}var mo=wl?{passive:!1}:!1,xx=function(e){return e.tagName==="TEXTAREA"},yf=function(e,t){if(!(e instanceof Element))return!1;var r=window.getComputedStyle(e);return r[t]!=="hidden"&&!(r.overflowY===r.overflowX&&!xx(e)&&r[t]==="visible")},Ax=function(e){return yf(e,"overflowY")},Cx=function(e){return yf(e,"overflowX")},bf=function(e,t){var r=t.ownerDocument,n=t;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var o=vf(e,n);if(o){var i=wf(e,n),s=i[1],a=i[2];if(s>a)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},Ex=function(e){var t=e.scrollTop,r=e.scrollHeight,n=e.clientHeight;return[t,r,n]},Nx=function(e){var t=e.scrollLeft,r=e.scrollWidth,n=e.clientWidth;return[t,r,n]},vf=function(e,t){return e==="v"?Ax(t):Cx(t)},wf=function(e,t){return e==="v"?Ex(t):Nx(t)},kx=function(e,t){return e==="h"&&t==="rtl"?-1:1},_x=function(e,t,r,n,o){var i=kx(e,window.getComputedStyle(t).direction),s=i*n,a=r.target,d=t.contains(a),u=!1,l=s>0,f=0,p=0;do{if(!a)break;var m=wf(e,a),g=m[0],h=m[1],y=m[2],w=h-y-i*g;(g||w)&&vf(e,a)&&(f+=w,p+=g);var v=a.parentNode;a=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!d&&a!==document.body||d&&(t.contains(a)||t===a));return(l&&Math.abs(f)<1||!l&&Math.abs(p)<1)&&(u=!0),u},ms=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Sf=function(e){return[e.deltaX,e.deltaY]},xf=function(e){return e&&"current"in e?e.current:e},Tx=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Fx=function(e){return`
|
|
39
39
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
40
40
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
41
|
-
`)},_x=0,fo=[];function kx(e){var t=b.useRef([]),r=b.useRef([0,0]),n=b.useRef(),o=b.useState(_x++)[0],i=b.useState(mf)[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=YS([e.lockRef.current],(e.shards||[]).map(Sf),!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 w=ps(h),v=r.current,x="deltaX"in h?h.deltaX:v[0]-w[0],N="deltaY"in h?h.deltaY:v[1]-w[1],P,E=h.target,_=Math.abs(x)>Math.abs(N)?"h":"v";if("touches"in h&&_==="h"&&E.type==="range")return!1;var C=window.getSelection(),A=C&&C.anchorNode,O=A?A===E||A.contains(E):!1;if(O)return!1;var T=yf(_,E);if(!T)return!0;if(T?P=_:(P=_==="v"?"h":"v",T=yf(_,E)),!T)return!1;if(!n.current&&"changedTouches"in h&&(x||N)&&(n.current=P),!P)return!0;var z=n.current||P;return Cx(z,y,h,z==="h"?x:N)},[]),d=b.useCallback(function(h){var y=h;if(!(!fo.length||fo[fo.length-1]!==i)){var w="deltaY"in y?wf(y):ps(y),v=t.current.filter(function(P){return P.name===y.type&&(P.target===y.target||y.target===P.shadowParent)&&Ex(P.delta,w)})[0];if(v&&v.should){y.cancelable&&y.preventDefault();return}if(!v){var x=(s.current.shards||[]).map(Sf).filter(Boolean).filter(function(P){return P.contains(y.target)}),N=x.length>0?a(y,x[0]):!s.current.noIsolation;N&&y.cancelable&&y.preventDefault()}}},[]),u=b.useCallback(function(h,y,w,v){var x={name:h,delta:y,target:w,should:v,shadowParent:Tx(w)};t.current.push(x),setTimeout(function(){t.current=t.current.filter(function(N){return N!==x})},1)},[]),l=b.useCallback(function(h){r.current=ps(h),n.current=void 0},[]),f=b.useCallback(function(h){u(h.type,wf(h),h.target,a(h,e.lockRef.current))},[]),p=b.useCallback(function(h){u(h.type,ps(h),h.target,a(h,e.lockRef.current))},[]);b.useEffect(function(){return fo.push(i),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener("wheel",d,uo),document.addEventListener("touchmove",d,uo),document.addEventListener("touchstart",l,uo),function(){fo=fo.filter(function(h){return h!==i}),document.removeEventListener("wheel",d,uo),document.removeEventListener("touchmove",d,uo),document.removeEventListener("touchstart",l,uo)}},[]);var m=e.removeScrollBar,g=e.inert;return b.createElement(b.Fragment,null,g?b.createElement(i,{styles:Nx(o)}):null,m?b.createElement(yx,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Tx(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Fx=ox(pf,kx);var ms=b.forwardRef(function(e,t){return b.createElement(us,tn({},e,{ref:t,sideCar:Fx}))});ms.classNames=us.classNames;var Px=[" ","Enter","ArrowUp","ArrowDown"],Ox=[" ","Enter"],Hn="Select",[hs,gs,Ix]=Wa(Hn),[po]=xr(Hn,[Ix,is]),ys=is(),[Mx,Tn]=po(Hn),[Lx,Dx]=po(Hn),xf=e=>{const{__scopeSelect:t,children:r,open:n,defaultOpen:o,onOpenChange:i,value:s,defaultValue:a,onValueChange:d,dir:u,name:l,autoComplete:f,disabled:p,required:m,form:g}=e,h=ys(t),[y,w]=b.useState(null),[v,x]=b.useState(null),[N,P]=b.useState(!1),E=no(u),[_,C]=en({prop:n,defaultProp:o??!1,onChange:i,caller:Hn}),[A,O]=en({prop:s,defaultProp:a,onChange:d,caller:Hn}),T=b.useRef(null),z=y?g||!!y.closest("form"):!0,[q,I]=b.useState(new Set),$=Array.from(q).map(M=>M.props.value).join(";");return c.jsx(of,{...h,children:c.jsxs(Mx,{required:m,scope:t,trigger:y,onTriggerChange:w,valueNode:v,onValueNodeChange:x,valueNodeHasChildren:N,onValueNodeHasChildrenChange:P,contentId:cn(),value:A,onValueChange:O,open:_,onOpenChange:C,dir:E,triggerPointerDownPosRef:T,disabled:p,children:[c.jsx(hs.Provider,{scope:t,children:c.jsx(Lx,{scope:e.__scopeSelect,onNativeOptionAdd:b.useCallback(M=>{I(D=>new Set(D).add(M))},[]),onNativeOptionRemove:b.useCallback(M=>{I(D=>{const L=new Set(D);return L.delete(M),L})},[]),children:r})}),z?c.jsxs(Wf,{"aria-hidden":!0,required:m,tabIndex:-1,name:l,autoComplete:f,value:A,onChange:M=>O(M.target.value),disabled:p,form:g,children:[A===void 0?c.jsx("option",{value:""}):null,Array.from(q)]},$):null]})})};xf.displayName=Hn;var Af="SelectTrigger",Cf=b.forwardRef((e,t)=>{const{__scopeSelect:r,disabled:n=!1,...o}=e,i=ys(r),s=Tn(Af,r),a=s.disabled||n,d=Ze(t,s.onTriggerChange),u=gs(r),l=b.useRef("touch"),[f,p,m]=Gf(h=>{const y=u().filter(x=>!x.disabled),w=y.find(x=>x.value===s.value),v=Kf(y,h,w);v!==void 0&&s.onValueChange(v.value)}),g=h=>{a||(s.onOpenChange(!0),m()),h&&(s.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})};return c.jsx(dl,{asChild:!0,...i,children:c.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":Rf(s.value)?"":void 0,...o,ref:d,onClick:Le(o.onClick,h=>{h.currentTarget.focus(),l.current!=="mouse"&&g(h)}),onPointerDown:Le(o.onPointerDown,h=>{l.current=h.pointerType;const y=h.target;y.hasPointerCapture(h.pointerId)&&y.releasePointerCapture(h.pointerId),h.button===0&&h.ctrlKey===!1&&h.pointerType==="mouse"&&(g(h),h.preventDefault())}),onKeyDown:Le(o.onKeyDown,h=>{const y=f.current!=="";!(h.ctrlKey||h.altKey||h.metaKey)&&h.key.length===1&&p(h.key),!(y&&h.key===" ")&&Px.includes(h.key)&&(g(),h.preventDefault())})})})});Cf.displayName=Af;var Ef="SelectValue",Nf=b.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,style:o,children:i,placeholder:s="",...a}=e,d=Tn(Ef,r),{onValueNodeHasChildrenChange:u}=d,l=i!==void 0,f=Ze(t,d.onValueNodeChange);return er(()=>{u(l)},[u,l]),c.jsx($e.span,{...a,ref:f,style:{pointerEvents:"none"},children:Rf(d.value)?c.jsx(c.Fragment,{children:s}):i})});Nf.displayName=Ef;var Bx="SelectIcon",_f=b.forwardRef((e,t)=>{const{__scopeSelect:r,children:n,...o}=e;return c.jsx($e.span,{"aria-hidden":!0,...o,ref:t,children:n||"▼"})});_f.displayName=Bx;var $x="SelectPortal",kf=e=>c.jsx(ss,{asChild:!0,...e});kf.displayName=$x;var Wn="SelectContent",Tf=b.forwardRef((e,t)=>{const r=Tn(Wn,e.__scopeSelect),[n,o]=b.useState();if(er(()=>{o(new DocumentFragment)},[]),!r.open){const i=n;return i?ki.createPortal(c.jsx(Ff,{scope:e.__scopeSelect,children:c.jsx(hs.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),i):null}return c.jsx(Pf,{...e,ref:t})});Tf.displayName=Wn;var Vr=10,[Ff,Fn]=po(Wn),jx="SelectContentImpl",zx=LS("SelectContent.RemoveScroll"),Pf=b.forwardRef((e,t)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:i,onPointerDownOutside:s,side:a,sideOffset:d,align:u,alignOffset:l,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:g,hideWhenDetached:h,avoidCollisions:y,...w}=e,v=Tn(Wn,r),[x,N]=b.useState(null),[P,E]=b.useState(null),_=Ze(t,K=>N(K)),[C,A]=b.useState(null),[O,T]=b.useState(null),z=gs(r),[q,I]=b.useState(!1),$=b.useRef(!1);b.useEffect(()=>{if(x)return fl(x)},[x]),Ka();const M=b.useCallback(K=>{const[re,...Te]=z().map(he=>he.ref.current),[Z]=Te.slice(-1),te=document.activeElement;for(const he of K)if(he===te||(he?.scrollIntoView({block:"nearest"}),he===re&&P&&(P.scrollTop=0),he===Z&&P&&(P.scrollTop=P.scrollHeight),he?.focus(),document.activeElement!==te))return},[z,P]),D=b.useCallback(()=>M([C,x]),[M,C,x]);b.useEffect(()=>{q&&D()},[q,D]);const{onOpenChange:L,triggerPointerDownPosRef:U}=v;b.useEffect(()=>{if(x){let K={x:0,y:0};const re=Z=>{K={x:Math.abs(Math.round(Z.pageX)-(U.current?.x??0)),y:Math.abs(Math.round(Z.pageY)-(U.current?.y??0))}},Te=Z=>{K.x<=10&&K.y<=10?Z.preventDefault():x.contains(Z.target)||L(!1),document.removeEventListener("pointermove",re),U.current=null};return U.current!==null&&(document.addEventListener("pointermove",re),document.addEventListener("pointerup",Te,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",re),document.removeEventListener("pointerup",Te,{capture:!0})}}},[x,L,U]),b.useEffect(()=>{const K=()=>L(!1);return window.addEventListener("blur",K),window.addEventListener("resize",K),()=>{window.removeEventListener("blur",K),window.removeEventListener("resize",K)}},[L]);const[j,se]=Gf(K=>{const re=z().filter(te=>!te.disabled),Te=re.find(te=>te.ref.current===document.activeElement),Z=Kf(re,K,Te);Z&&setTimeout(()=>Z.ref.current.focus())}),H=b.useCallback((K,re,Te)=>{const Z=!$.current&&!Te;(v.value!==void 0&&v.value===re||Z)&&(A(K),Z&&($.current=!0))},[v.value]),G=b.useCallback(()=>x?.focus(),[x]),ee=b.useCallback((K,re,Te)=>{const Z=!$.current&&!Te;(v.value!==void 0&&v.value===re||Z)&&T(K)},[v.value]),de=n==="popper"?yl:Of,ne=de===yl?{side:a,sideOffset:d,align:u,alignOffset:l,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:g,hideWhenDetached:h,avoidCollisions:y}:{};return c.jsx(Ff,{scope:r,content:x,viewport:P,onViewportChange:E,itemRefCallback:H,selectedItem:C,onItemLeave:G,itemTextRefCallback:ee,focusSelectedItem:D,selectedItemText:O,position:n,isPositioned:q,searchRef:j,children:c.jsx(ms,{as:zx,allowPinchZoom:!0,children:c.jsx(qi,{asChild:!0,trapped:v.open,onMountAutoFocus:K=>{K.preventDefault()},onUnmountAutoFocus:Le(o,K=>{v.trigger?.focus({preventScroll:!0}),K.preventDefault()}),children:c.jsx(Ki,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:K=>K.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:c.jsx(de,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:K=>K.preventDefault(),...w,...ne,onPlaced:()=>I(!0),ref:_,style:{display:"flex",flexDirection:"column",outline:"none",...w.style},onKeyDown:Le(w.onKeyDown,K=>{const re=K.ctrlKey||K.altKey||K.metaKey;if(K.key==="Tab"&&K.preventDefault(),!re&&K.key.length===1&&se(K.key),["ArrowUp","ArrowDown","Home","End"].includes(K.key)){let Z=z().filter(te=>!te.disabled).map(te=>te.ref.current);if(["ArrowUp","End"].includes(K.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(K.key)){const te=K.target,he=Z.indexOf(te);Z=Z.slice(he+1)}setTimeout(()=>M(Z)),K.preventDefault()}})})})})})})});Pf.displayName=jx;var Ux="SelectItemAlignedPosition",Of=b.forwardRef((e,t)=>{const{__scopeSelect:r,onPlaced:n,...o}=e,i=Tn(Wn,r),s=Fn(Wn,r),[a,d]=b.useState(null),[u,l]=b.useState(null),f=Ze(t,_=>l(_)),p=gs(r),m=b.useRef(!1),g=b.useRef(!0),{viewport:h,selectedItem:y,selectedItemText:w,focusSelectedItem:v}=s,x=b.useCallback(()=>{if(i.trigger&&i.valueNode&&a&&u&&h&&y&&w){const _=i.trigger.getBoundingClientRect(),C=u.getBoundingClientRect(),A=i.valueNode.getBoundingClientRect(),O=w.getBoundingClientRect();if(i.dir!=="rtl"){const te=O.left-C.left,he=A.left-te,le=_.left-he,Xe=_.width+le,ge=Math.max(Xe,C.width),Se=window.innerWidth-Vr,ae=Jo(he,[Vr,Math.max(Vr,Se-ge)]);a.style.minWidth=Xe+"px",a.style.left=ae+"px"}else{const te=C.right-O.right,he=window.innerWidth-A.right-te,le=window.innerWidth-_.right-he,Xe=_.width+le,ge=Math.max(Xe,C.width),Se=window.innerWidth-Vr,ae=Jo(he,[Vr,Math.max(Vr,Se-ge)]);a.style.minWidth=Xe+"px",a.style.right=ae+"px"}const T=p(),z=window.innerHeight-Vr*2,q=h.scrollHeight,I=window.getComputedStyle(u),$=parseInt(I.borderTopWidth,10),M=parseInt(I.paddingTop,10),D=parseInt(I.borderBottomWidth,10),L=parseInt(I.paddingBottom,10),U=$+M+q+L+D,j=Math.min(y.offsetHeight*5,U),se=window.getComputedStyle(h),H=parseInt(se.paddingTop,10),G=parseInt(se.paddingBottom,10),ee=_.top+_.height/2-Vr,de=z-ee,ne=y.offsetHeight/2,K=y.offsetTop+ne,re=$+M+K,Te=U-re;if(re<=ee){const te=T.length>0&&y===T[T.length-1].ref.current;a.style.bottom="0px";const he=u.clientHeight-h.offsetTop-h.offsetHeight,le=Math.max(de,ne+(te?G:0)+he+D),Xe=re+le;a.style.height=Xe+"px"}else{const te=T.length>0&&y===T[0].ref.current;a.style.top="0px";const le=Math.max(ee,$+h.offsetTop+(te?H:0)+ne)+Te;a.style.height=le+"px",h.scrollTop=re-ee+h.offsetTop}a.style.margin=`${Vr}px 0`,a.style.minHeight=j+"px",a.style.maxHeight=z+"px",n?.(),requestAnimationFrame(()=>m.current=!0)}},[p,i.trigger,i.valueNode,a,u,h,y,w,i.dir,n]);er(()=>x(),[x]);const[N,P]=b.useState();er(()=>{u&&P(window.getComputedStyle(u).zIndex)},[u]);const E=b.useCallback(_=>{_&&g.current===!0&&(x(),v?.(),g.current=!1)},[x,v]);return c.jsx(Hx,{scope:r,contentWrapper:a,shouldExpandOnScrollRef:m,onScrollButtonChange:E,children:c.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:N},children:c.jsx($e.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Of.displayName=Ux;var Vx="SelectPopperPosition",yl=b.forwardRef((e,t)=>{const{__scopeSelect:r,align:n="start",collisionPadding:o=Vr,...i}=e,s=ys(r);return c.jsx(sf,{...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)"}})});yl.displayName=Vx;var[Hx,bl]=po(Wn,{}),vl="SelectViewport",If=b.forwardRef((e,t)=>{const{__scopeSelect:r,nonce:n,...o}=e,i=Fn(vl,r),s=bl(vl,r),a=Ze(t,i.onViewportChange),d=b.useRef(0);return c.jsxs(c.Fragment,{children:[c.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}),c.jsx(hs.Slot,{scope:r,children:c.jsx($e.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Le(o.onScroll,u=>{const l=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:p}=s;if(p?.current&&f){const m=Math.abs(d.current-l.scrollTop);if(m>0){const g=window.innerHeight-Vr*2,h=parseFloat(f.style.minHeight),y=parseFloat(f.style.height),w=Math.max(h,y);if(w<g){const v=w+m,x=Math.min(g,v),N=v-x;f.style.height=x+"px",f.style.bottom==="0px"&&(l.scrollTop=N>0?N:0,f.style.justifyContent="flex-end")}}}d.current=l.scrollTop})})})]})});If.displayName=vl;var Mf="SelectGroup",[Wx,Rx]=po(Mf),Gx=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=cn();return c.jsx(Wx,{scope:r,id:o,children:c.jsx($e.div,{role:"group","aria-labelledby":o,...n,ref:t})})});Gx.displayName=Mf;var Lf="SelectLabel",Kx=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=Rx(Lf,r);return c.jsx($e.div,{id:o.id,...n,ref:t})});Kx.displayName=Lf;var bs="SelectItem",[qx,Df]=po(bs),Bf=b.forwardRef((e,t)=>{const{__scopeSelect:r,value:n,disabled:o=!1,textValue:i,...s}=e,a=Tn(bs,r),d=Fn(bs,r),u=a.value===n,[l,f]=b.useState(i??""),[p,m]=b.useState(!1),g=Ze(t,v=>d.itemRefCallback?.(v,n,o)),h=cn(),y=b.useRef("touch"),w=()=>{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 c.jsx(qx,{scope:r,value:n,disabled:o,textId:h,isSelected:u,onItemTextChange:b.useCallback(v=>{f(x=>x||(v?.textContent??"").trim())},[]),children:c.jsx(hs.ItemSlot,{scope:r,value:n,disabled:o,textValue:l,children:c.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:g,onFocus:Le(s.onFocus,()=>m(!0)),onBlur:Le(s.onBlur,()=>m(!1)),onClick:Le(s.onClick,()=>{y.current!=="mouse"&&w()}),onPointerUp:Le(s.onPointerUp,()=>{y.current==="mouse"&&w()}),onPointerDown:Le(s.onPointerDown,v=>{y.current=v.pointerType}),onPointerMove:Le(s.onPointerMove,v=>{y.current=v.pointerType,o?d.onItemLeave?.():y.current==="mouse"&&v.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Le(s.onPointerLeave,v=>{v.currentTarget===document.activeElement&&d.onItemLeave?.()}),onKeyDown:Le(s.onKeyDown,v=>{d.searchRef?.current!==""&&v.key===" "||(Ox.includes(v.key)&&w(),v.key===" "&&v.preventDefault())})})})})});Bf.displayName=bs;var ri="SelectItemText",$f=b.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,style:o,...i}=e,s=Tn(ri,r),a=Fn(ri,r),d=Df(ri,r),u=Dx(ri,r),[l,f]=b.useState(null),p=Ze(t,w=>f(w),d.onItemTextChange,w=>a.itemTextRefCallback?.(w,d.value,d.disabled)),m=l?.textContent,g=b.useMemo(()=>c.jsx("option",{value:d.value,disabled:d.disabled,children:m},d.value),[d.disabled,d.value,m]),{onNativeOptionAdd:h,onNativeOptionRemove:y}=u;return er(()=>(h(g),()=>y(g)),[h,y,g]),c.jsxs(c.Fragment,{children:[c.jsx($e.span,{id:d.textId,...i,ref:p}),d.isSelected&&s.valueNode&&!s.valueNodeHasChildren?ki.createPortal(i.children,s.valueNode):null]})});$f.displayName=ri;var jf="SelectItemIndicator",zf=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return Df(jf,r).isSelected?c.jsx($e.span,{"aria-hidden":!0,...n,ref:t}):null});zf.displayName=jf;var wl="SelectScrollUpButton",Uf=b.forwardRef((e,t)=>{const r=Fn(wl,e.__scopeSelect),n=bl(wl,e.__scopeSelect),[o,i]=b.useState(!1),s=Ze(t,n.onScrollButtonChange);return er(()=>{if(r.viewport&&r.isPositioned){let a=function(){const u=d.scrollTop>0;i(u)};const d=r.viewport;return a(),d.addEventListener("scroll",a),()=>d.removeEventListener("scroll",a)}},[r.viewport,r.isPositioned]),o?c.jsx(Hf,{...e,ref:s,onAutoScroll:()=>{const{viewport:a,selectedItem:d}=r;a&&d&&(a.scrollTop=a.scrollTop-d.offsetHeight)}}):null});Uf.displayName=wl;var Sl="SelectScrollDownButton",Vf=b.forwardRef((e,t)=>{const r=Fn(Sl,e.__scopeSelect),n=bl(Sl,e.__scopeSelect),[o,i]=b.useState(!1),s=Ze(t,n.onScrollButtonChange);return er(()=>{if(r.viewport&&r.isPositioned){let a=function(){const u=d.scrollHeight-d.clientHeight,l=Math.ceil(d.scrollTop)<u;i(l)};const d=r.viewport;return a(),d.addEventListener("scroll",a),()=>d.removeEventListener("scroll",a)}},[r.viewport,r.isPositioned]),o?c.jsx(Hf,{...e,ref:s,onAutoScroll:()=>{const{viewport:a,selectedItem:d}=r;a&&d&&(a.scrollTop=a.scrollTop+d.offsetHeight)}}):null});Vf.displayName=Sl;var Hf=b.forwardRef((e,t)=>{const{__scopeSelect:r,onAutoScroll:n,...o}=e,i=Fn("SelectScrollButton",r),s=b.useRef(null),a=gs(r),d=b.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return b.useEffect(()=>()=>d(),[d]),er(()=>{a().find(l=>l.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[a]),c.jsx($e.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:Le(o.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(n,50))}),onPointerMove:Le(o.onPointerMove,()=>{i.onItemLeave?.(),s.current===null&&(s.current=window.setInterval(n,50))}),onPointerLeave:Le(o.onPointerLeave,()=>{d()})})}),Yx="SelectSeparator",Xx=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return c.jsx($e.div,{"aria-hidden":!0,...n,ref:t})});Xx.displayName=Yx;var xl="SelectArrow",Jx=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=ys(r),i=Tn(xl,r),s=Fn(xl,r);return i.open&&s.position==="popper"?c.jsx(af,{...o,...n,ref:t}):null});Jx.displayName=xl;var Qx="SelectBubbleInput",Wf=b.forwardRef(({__scopeSelect:e,value:t,...r},n)=>{const o=b.useRef(null),i=Ze(n,o),s=ti(t);return b.useEffect(()=>{const a=o.current;if(!a)return;const d=window.HTMLSelectElement.prototype,l=Object.getOwnPropertyDescriptor(d,"value").set;if(s!==t&&l){const f=new Event("change",{bubbles:!0});l.call(a,t),a.dispatchEvent(f)}},[s,t]),c.jsx($e.select,{...r,style:{...lf,...r.style},ref:i,defaultValue:t})});Wf.displayName=Qx;function Rf(e){return e===""||e===void 0}function Gf(e){const t=ar(e),r=b.useRef(""),n=b.useRef(0),o=b.useCallback(s=>{const a=r.current+s;t(a),(function d(u){r.current=u,window.clearTimeout(n.current),u!==""&&(n.current=window.setTimeout(()=>d(""),1e3))})(a)},[t]),i=b.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,o,i]}function Kf(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=Zx(e,Math.max(i,0));o.length===1&&(s=s.filter(u=>u!==r));const d=s.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return d!==r?d:void 0}function Zx(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var e0=xf,t0=Cf,r0=Nf,n0=_f,o0=kf,i0=Tf,s0=If,a0=Bf,l0=$f,c0=zf,d0=Uf,u0=Vf;function f0({...e}){return c.jsx(e0,{"data-slot":"select",...e})}function p0({className:e,...t}){return c.jsx(r0,{"data-slot":"select-value",className:B("truncate min-w-0",e),...t})}function m0({className:e,size:t="default",children:r,...n}){const o=e?.includes("w-full");return c.jsxs(t0,{"data-slot":"select-trigger","data-size":t,className:B("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,c.jsx(n0,{asChild:!0,children:c.jsx(Ko,{className:"size-4 opacity-50"})})]})}function h0({className:e,children:t,position:r="popper",...n}){return c.jsx(o0,{children:c.jsxs(i0,{"data-slot":"select-content",className:B("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:[c.jsx(g0,{}),c.jsx(s0,{className:B("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),c.jsx(y0,{})]})})}function Al({className:e,children:t,...r}){return c.jsxs(a0,{"data-slot":"select-item",className:B("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:[c.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:c.jsx(c0,{children:c.jsx(Ri,{className:"size-4"})})}),c.jsx(l0,{className:"truncate",children:t})]})}function g0({className:e,...t}){return c.jsx(d0,{"data-slot":"select-scroll-up-button",className:B("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(Bv,{className:"size-4"})})}function y0({className:e,...t}){return c.jsx(u0,{"data-slot":"select-scroll-down-button",className:B("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(Ko,{className:"size-4"})})}function qf(e,t){return function(){return e.apply(t,arguments)}}const{toString:b0}=Object.prototype,{getPrototypeOf:Cl}=Object,{iterator:vs,toStringTag:Yf}=Symbol,ws=(e=>t=>{const r=b0.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),Hr=e=>(e=e.toLowerCase(),t=>ws(t)===e),Ss=e=>t=>typeof t===e,{isArray:mo}=Array,ho=Ss("undefined");function ni(e){return e!==null&&!ho(e)&&e.constructor!==null&&!ho(e.constructor)&&mr(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Xf=Hr("ArrayBuffer");function v0(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Xf(e.buffer),t}const w0=Ss("string"),mr=Ss("function"),Jf=Ss("number"),oi=e=>e!==null&&typeof e=="object",S0=e=>e===!0||e===!1,xs=e=>{if(ws(e)!=="object")return!1;const t=Cl(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Yf in e)&&!(vs in e)},x0=e=>{if(!oi(e)||ni(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},A0=Hr("Date"),C0=Hr("File"),E0=e=>!!(e&&typeof e.uri<"u"),N0=e=>e&&typeof e.getParts<"u",_0=Hr("Blob"),k0=Hr("FileList"),T0=e=>oi(e)&&mr(e.pipe);function F0(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const Qf=F0(),Zf=typeof Qf.FormData<"u"?Qf.FormData:void 0,P0=e=>{let t;return e&&(Zf&&e instanceof Zf||mr(e.append)&&((t=ws(e))==="formdata"||t==="object"&&mr(e.toString)&&e.toString()==="[object FormData]"))},O0=Hr("URLSearchParams"),[I0,M0,L0,D0]=["ReadableStream","Request","Response","Headers"].map(Hr),B0=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ii(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,o;if(typeof e!="object"&&(e=[e]),mo(e))for(n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else{if(ni(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 ep(e,t){if(ni(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 Rn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,tp=e=>!ho(e)&&e!==Rn;function El(){const{caseless:e,skipUndefined:t}=tp(this)&&this||{},r={},n=(o,i)=>{if(i==="__proto__"||i==="constructor"||i==="prototype")return;const s=e&&ep(r,i)||i;xs(r[s])&&xs(o)?r[s]=El(r[s],o):xs(o)?r[s]=El({},o):mo(o)?r[s]=o.slice():(!t||!ho(o))&&(r[s]=o)};for(let o=0,i=arguments.length;o<i;o++)arguments[o]&&ii(arguments[o],n);return r}const $0=(e,t,r,{allOwnKeys:n}={})=>(ii(t,(o,i)=>{r&&mr(o)?Object.defineProperty(e,i,{value:qf(o,r),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,i,{value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:n}),e),j0=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),z0=(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)},U0=(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&&Cl(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},V0=(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},H0=e=>{if(!e)return null;if(mo(e))return e;let t=e.length;if(!Jf(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},W0=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Cl(Uint8Array)),R0=(e,t)=>{const n=(e&&e[vs]).call(e);let o;for(;(o=n.next())&&!o.done;){const i=o.value;t.call(e,i[0],i[1])}},G0=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},K0=Hr("HTMLFormElement"),q0=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,o){return n.toUpperCase()+o}),rp=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),Y0=Hr("RegExp"),np=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};ii(r,(o,i)=>{let s;(s=t(o,i,e))!==!1&&(n[i]=s||o)}),Object.defineProperties(e,n)},X0=e=>{np(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+"'")})}})},J0=(e,t)=>{const r={},n=o=>{o.forEach(i=>{r[i]=!0})};return mo(e)?n(e):n(String(e).split(t)),r},Q0=()=>{},Z0=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function eA(e){return!!(e&&mr(e.append)&&e[Yf]==="FormData"&&e[vs])}const tA=e=>{const t=new Array(10),r=(n,o)=>{if(oi(n)){if(t.indexOf(n)>=0)return;if(ni(n))return n;if(!("toJSON"in n)){t[o]=n;const i=mo(n)?[]:{};return ii(n,(s,a)=>{const d=r(s,o+1);!ho(d)&&(i[a]=d)}),t[o]=void 0,i}}return n};return r(e,0)},rA=Hr("AsyncFunction"),nA=e=>e&&(oi(e)||mr(e))&&mr(e.then)&&mr(e.catch),op=((e,t)=>e?setImmediate:t?((r,n)=>(Rn.addEventListener("message",({source:o,data:i})=>{o===Rn&&i===r&&n.length&&n.shift()()},!1),o=>{n.push(o),Rn.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",mr(Rn.postMessage)),oA=typeof queueMicrotask<"u"?queueMicrotask.bind(Rn):typeof process<"u"&&process.nextTick||op,R={isArray:mo,isArrayBuffer:Xf,isBuffer:ni,isFormData:P0,isArrayBufferView:v0,isString:w0,isNumber:Jf,isBoolean:S0,isObject:oi,isPlainObject:xs,isEmptyObject:x0,isReadableStream:I0,isRequest:M0,isResponse:L0,isHeaders:D0,isUndefined:ho,isDate:A0,isFile:C0,isReactNativeBlob:E0,isReactNative:N0,isBlob:_0,isRegExp:Y0,isFunction:mr,isStream:T0,isURLSearchParams:O0,isTypedArray:W0,isFileList:k0,forEach:ii,merge:El,extend:$0,trim:B0,stripBOM:j0,inherits:z0,toFlatObject:U0,kindOf:ws,kindOfTest:Hr,endsWith:V0,toArray:H0,forEachEntry:R0,matchAll:G0,isHTMLForm:K0,hasOwnProperty:rp,hasOwnProp:rp,reduceDescriptors:np,freezeMethods:X0,toObjectSet:J0,toCamelCase:q0,noop:Q0,toFiniteNumber:Z0,findKey:ep,global:Rn,isContextDefined:tp,isSpecCompliantForm:eA,toJSONObject:tA,isAsyncFn:rA,isThenable:nA,setImmediate:op,asap:oA,isIterable:e=>e!=null&&mr(e[vs])};let Ye=class Uy extends Error{static from(t,r,n,o,i,s){const a=new Uy(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:R.toJSONObject(this.config),code:this.code,status:this.status}}};Ye.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",Ye.ERR_BAD_OPTION="ERR_BAD_OPTION",Ye.ECONNABORTED="ECONNABORTED",Ye.ETIMEDOUT="ETIMEDOUT",Ye.ERR_NETWORK="ERR_NETWORK",Ye.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",Ye.ERR_DEPRECATED="ERR_DEPRECATED",Ye.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",Ye.ERR_BAD_REQUEST="ERR_BAD_REQUEST",Ye.ERR_CANCELED="ERR_CANCELED",Ye.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",Ye.ERR_INVALID_URL="ERR_INVALID_URL";const iA=null;function Nl(e){return R.isPlainObject(e)||R.isArray(e)}function ip(e){return R.endsWith(e,"[]")?e.slice(0,-2):e}function _l(e,t,r){return e?e.concat(t).map(function(o,i){return o=ip(o),!r&&i?"["+o+"]":o}).join(r?".":""):t}function sA(e){return R.isArray(e)&&!e.some(Nl)}const aA=R.toFlatObject(R,{},null,function(t){return/^is[A-Z]/.test(t)});function As(e,t,r){if(!R.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=R.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,y){return!R.isUndefined(y[h])});const n=r.metaTokens,o=r.visitor||l,i=r.dots,s=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&R.isSpecCompliantForm(t);if(!R.isFunction(o))throw new TypeError("visitor must be a function");function u(g){if(g===null)return"";if(R.isDate(g))return g.toISOString();if(R.isBoolean(g))return g.toString();if(!d&&R.isBlob(g))throw new Ye("Blob is not supported. Use a Buffer instead.");return R.isArrayBuffer(g)||R.isTypedArray(g)?d&&typeof Blob=="function"?new Blob([g]):Buffer.from(g):g}function l(g,h,y){let w=g;if(R.isReactNative(t)&&R.isReactNativeBlob(g))return t.append(_l(y,h,i),u(g)),!1;if(g&&!y&&typeof g=="object"){if(R.endsWith(h,"{}"))h=n?h:h.slice(0,-2),g=JSON.stringify(g);else if(R.isArray(g)&&sA(g)||(R.isFileList(g)||R.endsWith(h,"[]"))&&(w=R.toArray(g)))return h=ip(h),w.forEach(function(x,N){!(R.isUndefined(x)||x===null)&&t.append(s===!0?_l([h],N,i):s===null?h:h+"[]",u(x))}),!1}return Nl(g)?!0:(t.append(_l(y,h,i),u(g)),!1)}const f=[],p=Object.assign(aA,{defaultVisitor:l,convertValue:u,isVisitable:Nl});function m(g,h){if(!R.isUndefined(g)){if(f.indexOf(g)!==-1)throw Error("Circular reference detected in "+h.join("."));f.push(g),R.forEach(g,function(w,v){(!(R.isUndefined(w)||w===null)&&o.call(t,w,R.isString(v)?v.trim():v,h,p))===!0&&m(w,h?h.concat(v):[v])}),f.pop()}}if(!R.isObject(e))throw new TypeError("data must be an object");return m(e),t}function sp(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function kl(e,t){this._pairs=[],e&&As(e,this,t)}const ap=kl.prototype;ap.append=function(t,r){this._pairs.push([t,r])},ap.toString=function(t){const r=t?function(n){return t.call(this,n,sp)}:sp;return this._pairs.map(function(o){return r(o[0])+"="+r(o[1])},"").join("&")};function lA(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function lp(e,t,r){if(!t)return e;const n=r&&r.encode||lA,o=R.isFunction(r)?{serialize:r}:r,i=o&&o.serialize;let s;if(i?s=i(t,o):s=R.isURLSearchParams(t)?t.toString():new kl(t,o).toString(n),s){const a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class cp{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){R.forEach(this.handlers,function(n){n!==null&&t(n)})}}const Tl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},cA={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:kl,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Fl=typeof window<"u"&&typeof document<"u",Pl=typeof navigator=="object"&&navigator||void 0,dA=Fl&&(!Pl||["ReactNative","NativeScript","NS"].indexOf(Pl.product)<0),uA=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",fA=Fl&&window.location.href||"http://localhost",ir={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Fl,hasStandardBrowserEnv:dA,hasStandardBrowserWebWorkerEnv:uA,navigator:Pl,origin:fA},Symbol.toStringTag,{value:"Module"})),...cA};function pA(e,t){return As(e,new ir.classes.URLSearchParams,{visitor:function(r,n,o,i){return ir.isNode&&R.isBuffer(r)?(this.append(n,r.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...t})}function mA(e){return R.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function hA(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 dp(e){function t(r,n,o,i){let s=r[i++];if(s==="__proto__")return!0;const a=Number.isFinite(+s),d=i>=r.length;return s=!s&&R.isArray(o)?o.length:s,d?(R.hasOwnProp(o,s)?o[s]=[o[s],n]:o[s]=n,!a):((!o[s]||!R.isObject(o[s]))&&(o[s]=[]),t(r,n,o[s],i)&&R.isArray(o[s])&&(o[s]=hA(o[s])),!a)}if(R.isFormData(e)&&R.isFunction(e.entries)){const r={};return R.forEachEntry(e,(n,o)=>{t(mA(n),o,r,0)}),r}return null}function gA(e,t,r){if(R.isString(e))try{return(t||JSON.parse)(e),R.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}const si={transitional:Tl,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){const n=r.getContentType()||"",o=n.indexOf("application/json")>-1,i=R.isObject(t);if(i&&R.isHTMLForm(t)&&(t=new FormData(t)),R.isFormData(t))return o?JSON.stringify(dp(t)):t;if(R.isArrayBuffer(t)||R.isBuffer(t)||R.isStream(t)||R.isFile(t)||R.isBlob(t)||R.isReadableStream(t))return t;if(R.isArrayBufferView(t))return t.buffer;if(R.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 pA(t,this.formSerializer).toString();if((a=R.isFileList(t))||n.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return As(a?{"files[]":t}:t,d&&new d,this.formSerializer)}}return i||o?(r.setContentType("application/json",!1),gA(t)):t}],transformResponse:[function(t){const r=this.transitional||si.transitional,n=r&&r.forcedJSONParsing,o=this.responseType==="json";if(R.isResponse(t)||R.isReadableStream(t))return t;if(t&&R.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"?Ye.from(a,Ye.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}}};R.forEach(["delete","get","head","post","put","patch"],e=>{si.headers[e]={}});const yA=R.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"]),bA=e=>{const t={};let r,n,o;return e&&e.split(`
|
|
42
|
-
`).forEach(function(s){o=s.indexOf(":"),r=s.substring(0,o).trim().toLowerCase(),n=s.substring(o+1).trim(),!(!r||t[r]&&
|
|
43
|
-
`)}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[up]=this[up]={accessors:{}}).accessors,o=this.prototype;function i(s){const a=ai(s);n[a]||(xA(o,s),n[a]=!0)}return R.isArray(t)?t.forEach(i):i(t),this}};hr.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),R.reduceDescriptors(hr.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}}),R.freezeMethods(hr);function Il(e,t){const r=this||si,n=t||r,o=hr.from(n.headers);let i=n.data;return R.forEach(e,function(a){i=a.call(r,i,o.normalize(),t?t.status:void 0)}),o.normalize(),i}function fp(e){return!!(e&&e.__CANCEL__)}let li=class extends Ye{constructor(t,r,n){super(t??"canceled",Ye.ERR_CANCELED,r,n),this.name="CanceledError",this.__CANCEL__=!0}};function pp(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new Ye("Request failed with status code "+r.status,[Ye.ERR_BAD_REQUEST,Ye.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function AA(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function CA(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(d){const u=Date.now(),l=n[i];s||(s=u),r[o]=d,n[o]=u;let f=i,p=0;for(;f!==o;)p+=r[f++],f=f%e;if(o=(o+1)%e,o===i&&(i=(i+1)%e),u-s<t)return;const m=l&&u-l;return m?Math.round(p*1e3/m):void 0}}function EA(e,t){let r=0,n=1e3/t,o,i;const s=(u,l=Date.now())=>{r=l,o=null,i&&(clearTimeout(i),i=null),e(...u)};return[(...u)=>{const l=Date.now(),f=l-r;f>=n?s(u,l):(o=u,i||(i=setTimeout(()=>{i=null,s(o)},n-f)))},()=>o&&s(o)]}const Es=(e,t,r=3)=>{let n=0;const o=CA(50,250);return EA(i=>{const s=i.loaded,a=i.lengthComputable?i.total:void 0,d=s-n,u=o(d),l=s<=a;n=s;const f={loaded:s,total:a,progress:a?s/a:void 0,bytes:d,rate:u||void 0,estimated:u&&a&&l?(a-s)/u:void 0,event:i,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},r)},mp=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},hp=e=>(...t)=>R.asap(()=>e(...t)),NA=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,_A=ir.hasStandardBrowserEnv?{write(e,t,r,n,o,i,s){if(typeof document>"u")return;const a=[`${e}=${encodeURIComponent(t)}`];R.isNumber(r)&&a.push(`expires=${new Date(r).toUTCString()}`),R.isString(n)&&a.push(`path=${n}`),R.isString(o)&&a.push(`domain=${o}`),i===!0&&a.push("secure"),R.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 kA(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function TA(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function gp(e,t,r){let n=!kA(t);return e&&(n||r==!1)?TA(e,t):t}const yp=e=>e instanceof hr?{...e}:e;function Gn(e,t){t=t||{};const r={};function n(u,l,f,p){return R.isPlainObject(u)&&R.isPlainObject(l)?R.merge.call({caseless:p},u,l):R.isPlainObject(l)?R.merge({},l):R.isArray(l)?l.slice():l}function o(u,l,f,p){if(R.isUndefined(l)){if(!R.isUndefined(u))return n(void 0,u,f,p)}else return n(u,l,f,p)}function i(u,l){if(!R.isUndefined(l))return n(void 0,l)}function s(u,l){if(R.isUndefined(l)){if(!R.isUndefined(u))return n(void 0,u)}else return n(void 0,l)}function a(u,l,f){if(f in t)return n(u,l);if(f in e)return n(void 0,u)}const d={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,l,f)=>o(yp(u),yp(l),f,!0)};return R.forEach(Object.keys({...e,...t}),function(l){if(l==="__proto__"||l==="constructor"||l==="prototype")return;const f=R.hasOwnProp(d,l)?d[l]:o,p=f(e[l],t[l],l);R.isUndefined(p)&&f!==a||(r[l]=p)}),r}const bp=e=>{const t=Gn({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:o,xsrfCookieName:i,headers:s,auth:a}=t;if(t.headers=s=hr.from(s),t.url=lp(gp(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),R.isFormData(r)){if(ir.hasStandardBrowserEnv||ir.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if(R.isFunction(r.getHeaders)){const d=r.getHeaders(),u=["content-type","content-length"];Object.entries(d).forEach(([l,f])=>{u.includes(l.toLowerCase())&&s.set(l,f)})}}if(ir.hasStandardBrowserEnv&&(n&&R.isFunction(n)&&(n=n(t)),n||n!==!1&&NA(t.url))){const d=o&&i&&_A.read(i);d&&s.set(o,d)}return t},FA=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(r,n){const o=bp(e);let i=o.data;const s=hr.from(o.headers).normalize();let{responseType:a,onUploadProgress:d,onDownloadProgress:u}=o,l,f,p,m,g;function h(){m&&m(),g&&g(),o.cancelToken&&o.cancelToken.unsubscribe(l),o.signal&&o.signal.removeEventListener("abort",l)}let y=new XMLHttpRequest;y.open(o.method.toUpperCase(),o.url,!0),y.timeout=o.timeout;function w(){if(!y)return;const x=hr.from("getAllResponseHeaders"in y&&y.getAllResponseHeaders()),P={data:!a||a==="text"||a==="json"?y.responseText:y.response,status:y.status,statusText:y.statusText,headers:x,config:e,request:y};pp(function(_){r(_),h()},function(_){n(_),h()},P),y=null}"onloadend"in y?y.onloadend=w:y.onreadystatechange=function(){!y||y.readyState!==4||y.status===0&&!(y.responseURL&&y.responseURL.indexOf("file:")===0)||setTimeout(w)},y.onabort=function(){y&&(n(new Ye("Request aborted",Ye.ECONNABORTED,e,y)),y=null)},y.onerror=function(N){const P=N&&N.message?N.message:"Network Error",E=new Ye(P,Ye.ERR_NETWORK,e,y);E.event=N||null,n(E),y=null},y.ontimeout=function(){let N=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const P=o.transitional||Tl;o.timeoutErrorMessage&&(N=o.timeoutErrorMessage),n(new Ye(N,P.clarifyTimeoutError?Ye.ETIMEDOUT:Ye.ECONNABORTED,e,y)),y=null},i===void 0&&s.setContentType(null),"setRequestHeader"in y&&R.forEach(s.toJSON(),function(N,P){y.setRequestHeader(P,N)}),R.isUndefined(o.withCredentials)||(y.withCredentials=!!o.withCredentials),a&&a!=="json"&&(y.responseType=o.responseType),u&&([p,g]=Es(u,!0),y.addEventListener("progress",p)),d&&y.upload&&([f,m]=Es(d),y.upload.addEventListener("progress",f),y.upload.addEventListener("loadend",m)),(o.cancelToken||o.signal)&&(l=x=>{y&&(n(!x||x.type?new li(null,e,y):x),y.abort(),y=null)},o.cancelToken&&o.cancelToken.subscribe(l),o.signal&&(o.signal.aborted?l():o.signal.addEventListener("abort",l)));const v=AA(o.url);if(v&&ir.protocols.indexOf(v)===-1){n(new Ye("Unsupported protocol "+v+":",Ye.ERR_BAD_REQUEST,e));return}y.send(i||null)})},PA=(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 l=u instanceof Error?u:this.reason;n.abort(l instanceof Ye?l:new li(l instanceof Error?l.message:l))}};let s=t&&setTimeout(()=>{s=null,i(new Ye(`timeout of ${t}ms exceeded`,Ye.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:d}=n;return d.unsubscribe=()=>R.asap(a),d}},OA=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},IA=async function*(e,t){for await(const r of MA(e))yield*OA(r,t)},MA=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()}},vp=(e,t,r,n)=>{const o=IA(e,t);let i=0,s,a=d=>{s||(s=!0,n&&n(d))};return new ReadableStream({async pull(d){try{const{done:u,value:l}=await o.next();if(u){a(),d.close();return}let f=l.byteLength;if(r){let p=i+=f;r(p)}d.enqueue(new Uint8Array(l))}catch(u){throw a(u),u}},cancel(d){return a(d),o.return()}},{highWaterMark:2})},wp=64*1024,{isFunction:Ns}=R,LA=(({Request:e,Response:t})=>({Request:e,Response:t}))(R.global),{ReadableStream:Sp,TextEncoder:xp}=R.global,Ap=(e,...t)=>{try{return!!e(...t)}catch{return!1}},DA=e=>{e=R.merge.call({skipUndefined:!0},LA,e);const{fetch:t,Request:r,Response:n}=e,o=t?Ns(t):typeof fetch=="function",i=Ns(r),s=Ns(n);if(!o)return!1;const a=o&&Ns(Sp),d=o&&(typeof xp=="function"?(g=>h=>g.encode(h))(new xp):async g=>new Uint8Array(await new r(g).arrayBuffer())),u=i&&a&&Ap(()=>{let g=!1;const h=new Sp,y=new r(ir.origin,{body:h,method:"POST",get duplex(){return g=!0,"half"}}).headers.has("Content-Type");return h.cancel(),g&&!y}),l=s&&a&&Ap(()=>R.isReadableStream(new n("").body)),f={stream:l&&(g=>g.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(g=>{!f[g]&&(f[g]=(h,y)=>{let w=h&&h[g];if(w)return w.call(h);throw new Ye(`Response type '${g}' is not supported`,Ye.ERR_NOT_SUPPORT,y)})});const p=async g=>{if(g==null)return 0;if(R.isBlob(g))return g.size;if(R.isSpecCompliantForm(g))return(await new r(ir.origin,{method:"POST",body:g}).arrayBuffer()).byteLength;if(R.isArrayBufferView(g)||R.isArrayBuffer(g))return g.byteLength;if(R.isURLSearchParams(g)&&(g=g+""),R.isString(g))return(await d(g)).byteLength},m=async(g,h)=>{const y=R.toFiniteNumber(g.getContentLength());return y??p(h)};return async g=>{let{url:h,method:y,data:w,signal:v,cancelToken:x,timeout:N,onDownloadProgress:P,onUploadProgress:E,responseType:_,headers:C,withCredentials:A="same-origin",fetchOptions:O}=bp(g),T=t||fetch;_=_?(_+"").toLowerCase():"text";let z=PA([v,x&&x.toAbortSignal()],N),q=null;const I=z&&z.unsubscribe&&(()=>{z.unsubscribe()});let $;try{if(E&&u&&y!=="get"&&y!=="head"&&($=await m(C,w))!==0){let se=new r(h,{method:"POST",body:w,duplex:"half"}),H;if(R.isFormData(w)&&(H=se.headers.get("content-type"))&&C.setContentType(H),se.body){const[G,ee]=mp($,Es(hp(E)));w=vp(se.body,wp,G,ee)}}R.isString(A)||(A=A?"include":"omit");const M=i&&"credentials"in r.prototype,D={...O,signal:z,method:y.toUpperCase(),headers:C.normalize().toJSON(),body:w,duplex:"half",credentials:M?A:void 0};q=i&&new r(h,D);let L=await(i?T(q,O):T(h,D));const U=l&&(_==="stream"||_==="response");if(l&&(P||U&&I)){const se={};["status","statusText","headers"].forEach(de=>{se[de]=L[de]});const H=R.toFiniteNumber(L.headers.get("content-length")),[G,ee]=P&&mp(H,Es(hp(P),!0))||[];L=new n(vp(L.body,wp,G,()=>{ee&&ee(),I&&I()}),se)}_=_||"text";let j=await f[R.findKey(f,_)||"text"](L,g);return!U&&I&&I(),await new Promise((se,H)=>{pp(se,H,{data:j,headers:hr.from(L.headers),status:L.status,statusText:L.statusText,config:g,request:q})})}catch(M){throw I&&I(),M&&M.name==="TypeError"&&/Load failed|fetch/i.test(M.message)?Object.assign(new Ye("Network Error",Ye.ERR_NETWORK,g,q,M&&M.response),{cause:M.cause||M}):Ye.from(M,M&&M.code,g,q,M&&M.response)}}},BA=new Map,Cp=e=>{let t=e&&e.env||{};const{fetch:r,Request:n,Response:o}=t,i=[n,o,r];let s=i.length,a=s,d,u,l=BA;for(;a--;)d=i[a],u=l.get(d),u===void 0&&l.set(d,u=a?new Map:DA(t)),l=u;return u};Cp();const Ml={http:iA,xhr:FA,fetch:{get:Cp}};R.forEach(Ml,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Ep=e=>`- ${e}`,$A=e=>R.isFunction(e)||e===null||e===!1;function jA(e,t){e=R.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,!$A(n)&&(o=Ml[(a=String(n)).toLowerCase()],o===void 0))throw new Ye(`Unknown adapter '${a}'`);if(o&&(R.isFunction(o)||(o=o.get(t))))break;i[a||"#"+s]=o}if(!o){const s=Object.entries(i).map(([d,u])=>`adapter ${d} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=r?s.length>1?`since :
|
|
44
|
-
`+s.map(
|
|
45
|
-
`):" "+
|
|
46
|
-
`+i):n.stack=i}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=Gn(this.defaults,r);const{transitional:n,paramsSerializer:o,headers:i}=r;n!==void 0&&ks.assertOptions(n,{silentJSONParsing:Pr.transitional(Pr.boolean),forcedJSONParsing:Pr.transitional(Pr.boolean),clarifyTimeoutError:Pr.transitional(Pr.boolean),legacyInterceptorReqResOrdering:Pr.transitional(Pr.boolean)},!1),o!=null&&(R.isFunction(o)?r.paramsSerializer={serialize:o}:ks.assertOptions(o,{encode:Pr.function,serialize:Pr.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),ks.assertOptions(r,{baseUrl:Pr.spelling("baseURL"),withXsrfToken:Pr.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s=i&&R.merge(i.common,i[r.method]);i&&R.forEach(["delete","get","head","post","put","patch","common"],g=>{delete i[g]}),r.headers=hr.concat(s,i);const a=[];let d=!0;this.interceptors.request.forEach(function(h){if(typeof h.runWhen=="function"&&h.runWhen(r)===!1)return;d=d&&h.synchronous;const y=r.transitional||Tl;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 l,f=0,p;if(!d){const g=[_p.bind(this),void 0];for(g.unshift(...a),g.push(...u),p=g.length,l=Promise.resolve(r);f<p;)l=l.then(g[f++],g[f++]);return l}p=a.length;let m=r;for(;f<p;){const g=a[f++],h=a[f++];try{m=g(m)}catch(y){h.call(this,y);break}}try{l=_p.call(this,m)}catch(g){return Promise.reject(g)}for(f=0,p=u.length;f<p;)l=l.then(u[f++],u[f++]);return l}getUri(t){t=Gn(this.defaults,t);const r=gp(t.baseURL,t.url,t.allowAbsoluteUrls);return lp(r,t.params,t.paramsSerializer)}};R.forEach(["delete","get","head","options"],function(t){Kn.prototype[t]=function(r,n){return this.request(Gn(n||{},{method:t,url:r,data:(n||{}).data}))}}),R.forEach(["post","put","patch"],function(t){function r(n){return function(i,s,a){return this.request(Gn(a||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:s}))}}Kn.prototype[t]=r(),Kn.prototype[t+"Form"]=r(!0)});let UA=class Vy{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 li(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 Vy(function(o){t=o}),cancel:t}}};function VA(e){return function(r){return e.apply(null,r)}}function HA(e){return R.isObject(e)&&e.isAxiosError===!0}const Dl={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(Dl).forEach(([e,t])=>{Dl[t]=e});function Fp(e){const t=new Kn(e),r=qf(Kn.prototype.request,t);return R.extend(r,Kn.prototype,t,{allOwnKeys:!0}),R.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return Fp(Gn(e,o))},r}const Ct=Fp(si);Ct.Axios=Kn,Ct.CanceledError=li,Ct.CancelToken=UA,Ct.isCancel=fp,Ct.VERSION=kp,Ct.toFormData=As,Ct.AxiosError=Ye,Ct.Cancel=Ct.CanceledError,Ct.all=function(t){return Promise.all(t)},Ct.spread=VA,Ct.isAxiosError=HA,Ct.mergeConfig=Gn,Ct.AxiosHeaders=hr,Ct.formToJSON=e=>dp(R.isHTMLForm(e)?new FormData(e):e),Ct.getAdapter=Np.getAdapter,Ct.HttpStatusCode=Dl,Ct.default=Ct;const{Axios:uO,AxiosError:WA,CanceledError:fO,isCancel:pO,CancelToken:mO,VERSION:hO,all:gO,Cancel:yO,isAxiosError:bO,spread:vO,toFormData:wO,AxiosHeaders:SO,HttpStatusCode:xO,formToJSON:AO,getAdapter:CO,mergeConfig:EO}=Ct;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 Pp(e){const t={array:[],pathPrefixToStrip:""};function r(a,d){if(a===null||typeof a!="object")return null;if(Array.isArray(a)&&a.length>0)return{array:a,fullPath:d};const u=Object.keys(a);for(const l of u){const f=a[l],p=d?`${d}.${l}`:l;if(Array.isArray(f)&&f.length>0)return{array:f,fullPath:p};if(f!==null&&typeof f=="object"){const m=r(f,p);if(m)return m}}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 RA(e){return e.length>=4&&Array.isArray(e[3])&&e[3].length===0}function GA(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 ci(e,t,r){if(!e)return[];if(Array.isArray(e)){if(e.length===0)return[];if(RA(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=>GA(o,t,r))}if(typeof e=="object"){const{array:n,pathPrefixToStrip:o}=Pp(e);if(Array.isArray(n)&&n.length>0){const i=d=>!d||!d.trim()||!o?d:d.startsWith(o)?d.substring(o.length).replace(/^\.+/,"")||void 0:d,s=i(t),a=i(r);return ci(n,s,a)}}return[]}function KA(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 qA(e){return Array.isArray(e)&&e.length>=4&&Array.isArray(e[3])&&e[3].length>0&&Array.isArray(e[3][0])}function YA(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 Op(e){const{response:t,sourceUrl:r,rowsIndex:n,rowsPath:o,columns:i,columnsQueryParam:s="sf",columnsQueryParamSeparator:a=","}=e;let d;if(o&&o.trim()?d=jt(t,o):typeof n=="number"?d=t?.[n]:d=t,!Array.isArray(d)||d.length===0)return[];const u=d.filter(p=>Array.isArray(p));if(u.length===0)return Array.isArray(d[0])?[]:null;if(!Array.isArray(u[0]))return null;const l=YA(r,s,a),f=l.length>0?l:Array.isArray(i)&&i.length>0?i:[];return u.map(p=>{const m={};return(f.length>0?f:Array.from({length:p.length},(h,y)=>`col${y}`)).forEach((h,y)=>{m[h]=p[y]}),m})}function XA(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(f=>f!=null&&typeof f=="object"&&!Array.isArray(f));if(s.length===0)return[];const a=Array.isArray(n)?n.filter(Boolean):[],d=o??" - ",u=f=>{if(r){const p=r.includes(".")?jt(f,r):f?.[r];if(p!=null&&String(p).trim()!=="")return String(p)}return String(f?.label??f?.name??f?.title??f?.text??f?.username??f?.email??f?.value??f?.id??f)},l=(f,p)=>{if(i){const m=i.includes(".")?jt(f,i):f?.[i];if(m!=null)return String(m)}return String(f?.value??f?.id??f?.key??f?.email??f?.username??f?.label??f?.name??p??f)};return s.map(f=>{let p="";a.length>0&&(p=a.map(h=>jt(f,h)).filter(h=>h!=null&&String(h).trim()!=="").map(h=>String(h)).join(d)),p||(p=u(f));const m=l(f,p);return{label:typeof p=="string"?p:String(p??""),value:typeof m=="string"?m:String(m??""),disabled:!!f?.disabled}})}function Ip(e){return e!=null&&!Array.isArray(e)&&(typeof e=="string"||typeof e=="number"||typeof e=="boolean")}function JA(e,t){const{array:r,pathPrefixToStrip:n}=Pp(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 d=a.includes(".")?jt(s,a):s?.[a];if(Ip(d))return String(d)}return null}function QA(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(Ip(s))return String(s);const a=JA(e,n);if(a!=null)return a}const i=ci(e,o,n||o);if(i.length>0){const s=i[0].value;if(s!=null&&String(s).trim()!=="")return String(s)}return null}let Mp=null;function ZA(e){Mp=e}function Lp(){return(Mp?.()??"").replace(/\/+$/,"")}function rn(e){const t=typeof e=="string"?e.trim():"";if(!t||/^https?:\/\//i.test(t))return t;const r=Lp();return r?t.startsWith("/")?`${r}${t}`:`${r}/${t}`:t}function eC(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 tC(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=zd(e=>({viewerContext:void 0,authHeaders:void 0,_setViewerContext:t=>e({viewerContext:eC(t)?t:void 0}),_setAuthHeaders:t=>e({authHeaders:tC(t)}),_reset:()=>e({viewerContext:void 0,authHeaders:void 0})}));function rC(e){qn.getState()._setViewerContext(e)}function nC(e){qn.getState()._setAuthHeaders(e)}function oC(){qn.getState()._reset()}function iC(){return qn.getState().viewerContext}function Ts(){return qn.getState().authHeaders}function sC(e){if(e?.token!=null&&String(e.token).trim()!=="")return String(e.token);const t=Ts(),r=t?.Authorization??t?.authorization;if(r?.trim()){const n=r.match(/^Bearer\s+(.+)$/i);return n?n[1]:r}}function Dp(e,t){const r=sC(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 go(e,t){const r={},{formValues:n={},submissionContext:o,apiRealtime:i}=t;for(const{key:s,value:a}of e??[]){const d=s?.trim();if(!d||a==null)continue;let u=$a(String(a),n,o,i);u=Dp(u,o),r[d]=u}return r}const aC=/^\{([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\}$/i;function Bp(e){const t=e.trim().match(aC);return t?t[1]:e}const lC={applicantId:["id","applicant_id"],applicant_id:["id","applicantId"],id:["applicantId","applicant_id"]};function Wr(e,t,r,n,o,i){let s=e;if(o&&typeof e=="string"&&(s=s.replace(/\{resp:([^}]+)\}/g,(a,d)=>{const u=d.trim().split(".");if(u.length<2)return a;const l=u[0],f=u.slice(1).join("."),p=o[l];if(p==null)return a;const m=Qe(p,f);return m==null?a:String(m)}),s.includes("{documentId}")||s.includes("%7BdocumentId%7D"))){let a;for(const d of Object.values(o)){const u=Qe(d,"data.id")??Qe(d,"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 d=t?.documentId??(t&&Qe(t,"documentId")),u=n?.documentId??(n&&Qe(n,"documentId"));d!=null&&d!==""?a=String(d):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,d)=>{const u=d.trim();if(i==null||u==="")return a;const l=Qe(i,u);return l==null?a:String(l)}),s=s.replace(/\{(?:ctx:|\@)(\w+)\}/g,(a,d)=>n&&n[d]!==void 0&&n[d]!==null?String(n[d]):a),s=s.replace(/\{(\w+)\}/g,(a,d)=>{if(a.includes("ctx:")||a.includes("@"))return a;const u=r[d];if(u!=null)return Bp(String(u));let l=t[d];if(l==null||l===""){const f=Object.keys(t).find(p=>p.toLowerCase()===d.toLowerCase());f&&(l=t[f])}if((l==null||l==="")&&(l=n?.[d]),l==null||l===""){const f=lC[d];if(f)for(const p of f){const m=t[p]??n?.[p];if(m!=null&&m!==""){l=m;break}}}return l!=null&&l!==""?Bp(String(l)):a}),s}const cC=new Set(["authorization"]);function dC(e){return cC.has(e.trim().toLowerCase())}function Bl(e){return(e??[]).filter(t=>!dC(t.key))}function $l(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 uC(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 Fs(e,t){const{formValues:r={},submissionContext:n,urlParams:o={},apiRealtime:i}=t;let s=Wr(e,r,o,n);return s=Dp(s,n),i!==void 0&&(s=$a(s,r,n,i)),s}function jl(e,t={}){const r=uC(e),n={};if(r.type==="bearer"){const o=r.token??"";if(!o.trim())return n;const i=Fs(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"]=Fs(o,t)),n}if(r.type==="basic"){const o=r.username??"",i=r.password??"";if(!o.trim()&&!i.trim())return n;const s=Fs(o,t),a=Fs(i,t);n.Authorization=`Basic ${btoa(`${s}:${a}`)}`}return n}function $p({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,d]=S.useState([]),[u,l]=S.useState([]),[f,p]=S.useState([]),[m,g]=S.useState(!1),[h,y]=S.useState(null),w=!!(s?.apiEndpoint&&(s?.valueSource==="api"||s?.optionsSource==="api"||n?.valueSource==="api"||n?.optionsSource==="api")),v=e.options||n?.options||[],x=S.useMemo(()=>KA(Array.isArray(v)?v:[]),[v]),N=S.useMemo(()=>{const O=s?.apiEndpoint||n?.apiEndpoint||"",T=s?.apiQueryParams||n?.apiQueryParams;return Ho(O,T)},[s?.apiEndpoint,n?.apiEndpoint,s?.apiQueryParams,n?.apiQueryParams]),P=S.useMemo(()=>{const O=new Set;for(const z of n?.dependentFields??[])typeof z=="string"&&z.trim()&&O.add(z.trim());const T=s?.apiClientFilter?.matchField?.trim()||n?.apiClientFilter?.matchField?.trim();return T&&O.add(T),[...O]},[n?.dependentFields,s?.apiClientFilter?.matchField,n?.apiClientFilter?.matchField]),E=S.useMemo(()=>{const O=new Set([...N,...P]);if(O.size===0)return null;const T={};return O.forEach(z=>{T[z]=t[z]}),JSON.stringify(T)},[N,P,t]),_=S.useMemo(()=>JSON.stringify(r||{}),[r]),C=S.useMemo(()=>{const O=new Set;e.name?.trim()&&O.add(e.name.trim());const T=e.key;return typeof T=="string"&&T.trim()&&O.add(T.trim()),[...O]},[e.name,e.key]);return S.useEffect(()=>{const O=s?.apiEndpoint;if(!w||!O){d([]);return}let T=!1;return(async()=>{a.length===0&&g(!0),y(null);try{const I=s?.apiMethod||n?.apiMethod||"GET",$=s?.apiRealtime||n?.apiRealtime,M=s?.apiQueryParams||n?.apiQueryParams||{},D=za({apiEndpoint:O,apiMethod:I,apiQueryParams:M,formValues:t,submissionContext:r,apiRealtime:$,additionalRequiredFieldNames:P,excludeFormFieldNames:C});if(D.blocked){T||(d([]),g(!1));return}const L={"Content-Type":"application/json"},U=s?.apiKey||n?.apiKey;U&&(L["X-CSCAPI-KEY"]=U);const j=s?.apiAuth??n?.apiAuth??i?.apiAuth??$l(s?.apiHeaders??n?.apiHeaders??i?.apiHeaders)??{type:"none"},se=jl(j,{formValues:t,submissionContext:r,apiRealtime:$});Object.assign(L,se);const H=s?.apiHeaders??n?.apiHeaders??i?.apiHeaders,G=s?.apiBodyFields??n?.apiBodyFields??i?.apiBodyFields,ee=go(Bl(H),{formValues:t,submissionContext:r,apiRealtime:$});Object.assign(L,ee);const de=go(G,{formValues:t,submissionContext:r,apiRealtime:$}),ne={method:I.toLowerCase(),url:rn(D.url),headers:L};(D.postBodyBase!=null||Object.keys(de).length>0)&&(ne.data={...D.postBodyBase??{},...de});const K=await Ct(ne),re=s?.apiLabelField||n?.apiLabelField,Te=s?.apiValueField||n?.apiValueField,Z=K.data;let te=[];Array.isArray(Z)?te=Z:Z?.data&&(Array.isArray(Z.data)?te=Z.data:Z.data?.data&&Array.isArray(Z.data.data)?te=Z.data.data:Z.data.districts?te=Z.data.districts:Z.data.states?te=Z.data.states:Z.data.cities&&(te=Z.data.cities)),p(te);const he=ci(K.data,re,Te);l(he);const le=s?.apiClientFilter||n?.apiClientFilter;let Xe=he;if(le?.filterField&&le?.matchField){const ge=t[le.matchField];ge!=null?Xe=he.filter(Se=>{const ae=te.find(He=>String(jt(He,Te||"code"))===String(Se.value));if(!ae)return!1;const ve=jt(ae,le.filterField);return String(ve)===String(ge)}):Xe=[]}T||d(Xe)}catch(I){if(T)return;let $="Failed to load options";if(I.response){const M=I.response.data;I.response.status===404?$="API endpoint not found.":I.response.status===401?$="Authentication failed.":typeof M=="string"?$=M:M&&typeof M=="object"&&($=M.error||M.message||M.detail||$)}else I.message&&($=String(I.message));y($),a.length===0&&d([])}finally{T||g(!1)}})(),()=>{T=!0}},[w,s?.apiEndpoint,s?.apiMethod,n?.apiEndpoint,n?.apiMethod,E,P,C,_]),S.useEffect(()=>{const O=s?.apiClientFilter||n?.apiClientFilter;if(!w||!O||f.length===0)return;const T=t[O.matchField],z=s?.apiValueField||n?.apiValueField;if(T==null){d([]);return}const q=u.filter(I=>{const $=f.find(D=>String(jt(D,z||"code"))===String(I.value));if(!$)return!1;const M=jt($,O.filterField);return String(M)===String(T)});d(q)},[w,s?.apiClientFilter?.matchField,n?.apiClientFilter?.matchField,s?.apiClientFilter?.filterField,n?.apiClientFilter?.filterField,s?.apiValueField,n?.apiValueField,t[s?.apiClientFilter?.matchField||n?.apiClientFilter?.matchField||""],u,f]),{options:w?a:x,isLoadingOptions:m,optionsError:h}}const jp=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a,formValues:d={},submissionContext:u,excludedOptionValues:l,isPrepopulateTarget:f=!1})=>{const p=e.properties,m=p?.apiEndpoint?{apiEndpoint:p.apiEndpoint,valueSource:p.valueSource,optionsSource:p.optionsSource}:null,g=e.apidata||null,h=m||g,y=!!(h?.apiEndpoint&&(h?.valueSource==="api"||h?.optionsSource==="api"||p?.valueSource==="api"||p?.optionsSource==="api")),{options:w,isLoadingOptions:v,optionsError:x}=$p({field:e,formValues:d,submissionContext:u}),N=l?.length?new Set(l.map(String)):null,P=N?w.filter(j=>!N.has(String(j.value??j.label??""))):w,E="__clear__",_=t!=null&&String(t).trim()!=="",C=_?P.some(j=>String(j.value??j.label??"")===String(t)):!1,A=S.useMemo(()=>{if(!_||C)return P;const j=String(t);return[{label:j,value:j},...P]},[P,_,C,t]),O=_?String(t):void 0,T=`${ht(e)}-${O??"empty"}`,z=S.useCallback(j=>{r(j===E?"":j),n?.()},[r,n]),q=e.appearance?.size||"md",I={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},$=e.placeholder||"Select an option",M=p?.apiClientFilter?.matchField?.trim()||h?.apiClientFilter?.matchField?.trim(),D=y&&M&&(d[M]===void 0||d[M]===null||d[M]===""),L=v?"Loading options...":D?`Select ${M} first`:l?.length?"No available options":y?"No options available from API":"No options available";return y&&f&&v?c.jsx(At,{field:e,error:o||x||void 0,isRequired:s,className:a,children:c.jsxs("div",{role:"status","aria-label":"Loading options",className:B("flex items-center justify-center gap-2 w-full min-w-0 rounded-md border border-input bg-muted/50 text-muted-foreground",I[q],e.appearance?.className),children:[c.jsx(qo,{className:"h-4 w-4 animate-spin shrink-0"}),c.jsx("span",{className:"truncate",children:"Loading..."})]})}):c.jsx(At,{field:e,error:o||x||void 0,isRequired:s,className:a,children:c.jsxs(f0,{value:O,onValueChange:z,disabled:i||e.disabled||v&&P.length===0,children:[c.jsx(m0,{id:ht(e),"aria-describedby":$t(e,!!o||!!x),"aria-invalid":Zt(!!o||!!x),"aria-required":s,className:B("w-full min-w-0",I[q],o&&"border-destructive focus-visible:ring-destructive",x&&"border-destructive focus-visible:ring-destructive",e.appearance?.className),children:c.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[v&&c.jsx(qo,{className:"h-4 w-4 animate-spin text-muted-foreground shrink-0"}),P.length===0&&l?.length&&!_?c.jsx("span",{className:"text-muted-foreground truncate",children:"No available options"}):_?c.jsx(p0,{placeholder:$}):c.jsx("span",{className:"text-muted-foreground truncate",children:$})]})}),c.jsx(h0,{children:A.length===0?c.jsx(Al,{value:"__no_options__",disabled:!0,children:L}):c.jsxs(c.Fragment,{children:[_?c.jsx(Al,{value:E,children:$}):null,A.map((j,se)=>{const H=String(j.value??j.label??se);if(H===E)return null;const G=j.label||j.value||String(j);return c.jsx(Al,{value:H,disabled:j.disabled||!1,children:G},H)})]})})]},T)})},zp=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Up=sd,Vp=(e,t)=>r=>{var n;if(t?.variants==null)return Up(e,r?.class,r?.className);const{variants:o,defaultVariants:i}=t,s=Object.keys(o).map(u=>{const l=r?.[u],f=i?.[u];if(l===null)return null;const p=zp(l)||zp(f);return o[u][p]}),a=r&&Object.entries(r).reduce((u,l)=>{let[f,p]=l;return p===void 0||(u[f]=p),u},{}),d=t==null||(n=t.compoundVariants)===null||n===void 0?void 0:n.reduce((u,l)=>{let{class:f,className:p,...m}=l;return Object.entries(m).every(g=>{let[h,y]=g;return Array.isArray(y)?y.includes({...i,...a}[h]):{...i,...a}[h]===y})?[...u,f,p]:u},[]);return Up(e,s,d,r?.class,r?.className)},fC=Vp("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 Kt({className:e,variant:t,size:r,asChild:n=!1,...o}){const i=n?ru:"button";return c.jsx(i,{"data-slot":"button",className:B(fC({variant:t,size:r,className:e})),...o})}function pC(e,t){return b.useReducer((r,n)=>t[r][n]??r,e)}var Er=e=>{const{present:t,children:r}=e,n=mC(t),o=typeof r=="function"?r({present:n.isPresent}):b.Children.only(r),i=Ze(n.ref,hC(o));return typeof r=="function"||n.isPresent?b.cloneElement(o,{ref:i}):null};Er.displayName="Presence";function mC(e){const[t,r]=b.useState(),n=b.useRef(null),o=b.useRef(e),i=b.useRef("none"),s=e?"mounted":"unmounted",[a,d]=pC(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{const u=Ps(n.current);i.current=a==="mounted"?u:"none"},[a]),er(()=>{const u=n.current,l=o.current;if(l!==e){const p=i.current,m=Ps(u);e?d("MOUNT"):m==="none"||u?.display==="none"?d("UNMOUNT"):d(l&&p!==m?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,d]),er(()=>{if(t){let u;const l=t.ownerDocument.defaultView??window,f=m=>{const h=Ps(n.current).includes(CSS.escape(m.animationName));if(m.target===t&&h&&(d("ANIMATION_END"),!o.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",u=l.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},p=m=>{m.target===t&&(i.current=Ps(n.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{l.clearTimeout(u),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:b.useCallback(u=>{n.current=u?getComputedStyle(u):null,r(u)},[])}}function Ps(e){return e?.animationName||"none"}function hC(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 gC(e){const t=yC(e),r=b.forwardRef((n,o)=>{const{children:i,...s}=n,a=b.Children.toArray(i),d=a.find(vC);if(d){const u=d.props.children,l=a.map(f=>f===d?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:f);return c.jsx(t,{...s,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...s,ref:o,children:i})});return r.displayName=`${e}.Slot`,r}function yC(e){const t=b.forwardRef((r,n)=>{const{children:o,...i}=r;if(b.isValidElement(o)){const s=SC(o),a=wC(i,o.props);return o.type!==b.Fragment&&(a.ref=n?zn(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 bC=Symbol("radix.slottable");function vC(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===bC}function wC(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 d=i(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...i}:n==="className"&&(r[n]=[o,i].filter(Boolean).join(" "))}return{...e,...r}}function SC(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 Os="Popover",[Hp]=xr(Os,[is]),di=is(),[xC,Pn]=Hp(Os),Wp=e=>{const{__scopePopover:t,children:r,open:n,defaultOpen:o,onOpenChange:i,modal:s=!1}=e,a=di(t),d=b.useRef(null),[u,l]=b.useState(!1),[f,p]=en({prop:n,defaultProp:o??!1,onChange:i,caller:Os});return c.jsx(of,{...a,children:c.jsx(xC,{scope:t,contentId:cn(),triggerRef:d,open:f,onOpenChange:p,onOpenToggle:b.useCallback(()=>p(m=>!m),[p]),hasCustomAnchor:u,onCustomAnchorAdd:b.useCallback(()=>l(!0),[]),onCustomAnchorRemove:b.useCallback(()=>l(!1),[]),modal:s,children:r})})};Wp.displayName=Os;var Rp="PopoverAnchor",Gp=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=Pn(Rp,r),i=di(r),{onCustomAnchorAdd:s,onCustomAnchorRemove:a}=o;return b.useEffect(()=>(s(),()=>a()),[s,a]),c.jsx(dl,{...i,...n,ref:t})});Gp.displayName=Rp;var Kp="PopoverTrigger",qp=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=Pn(Kp,r),i=di(r),s=Ze(t,o.triggerRef),a=c.jsx($e.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Zp(o.open),...n,ref:s,onClick:Le(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:c.jsx(dl,{asChild:!0,...i,children:a})});qp.displayName=Kp;var zl="PopoverPortal",[AC,CC]=Hp(zl,{forceMount:void 0}),Yp=e=>{const{__scopePopover:t,forceMount:r,children:n,container:o}=e,i=Pn(zl,t);return c.jsx(AC,{scope:t,forceMount:r,children:c.jsx(Er,{present:r||i.open,children:c.jsx(ss,{asChild:!0,container:o,children:n})})})};Yp.displayName=zl;var yo="PopoverContent",Xp=b.forwardRef((e,t)=>{const r=CC(yo,e.__scopePopover),{forceMount:n=r.forceMount,...o}=e,i=Pn(yo,e.__scopePopover);return c.jsx(Er,{present:n||i.open,children:i.modal?c.jsx(NC,{...o,ref:t}):c.jsx(_C,{...o,ref:t})})});Xp.displayName=yo;var EC=gC("PopoverContent.RemoveScroll"),NC=b.forwardRef((e,t)=>{const r=Pn(yo,e.__scopePopover),n=b.useRef(null),o=Ze(t,n),i=b.useRef(!1);return b.useEffect(()=>{const s=n.current;if(s)return fl(s)},[]),c.jsx(ms,{as:EC,allowPinchZoom:!0,children:c.jsx(Jp,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Le(e.onCloseAutoFocus,s=>{s.preventDefault(),i.current||r.triggerRef.current?.focus()}),onPointerDownOutside:Le(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,d=a.button===0&&a.ctrlKey===!0,u=a.button===2||d;i.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:Le(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})})}),_C=b.forwardRef((e,t)=>{const r=Pn(yo,e.__scopePopover),n=b.useRef(!1),o=b.useRef(!1);return c.jsx(Jp,{...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()}})}),Jp=b.forwardRef((e,t)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:s,onEscapeKeyDown:a,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:l,...f}=e,p=Pn(yo,r),m=di(r);return Ka(),c.jsx(qi,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:i,children:c.jsx(Ki,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:l,onEscapeKeyDown:a,onPointerDownOutside:d,onFocusOutside:u,onDismiss:()=>p.onOpenChange(!1),children:c.jsx(sf,{"data-state":Zp(p.open),role:"dialog",id:p.contentId,...m,...f,ref:t,style:{...f.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)"}})})})}),Qp="PopoverClose",kC=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=Pn(Qp,r);return c.jsx($e.button,{type:"button",...n,ref:t,onClick:Le(e.onClick,()=>o.onOpenChange(!1))})});kC.displayName=Qp;var TC="PopoverArrow",FC=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=di(r);return c.jsx(af,{...o,...n,ref:t})});FC.displayName=TC;function Zp(e){return e?"open":"closed"}var PC=Wp,OC=Gp,IC=qp,MC=Yp,LC=Xp;function Ul({...e}){return c.jsx(PC,{"data-slot":"popover",...e})}function em({...e}){return c.jsx(IC,{"data-slot":"popover-trigger",...e})}function Vl({className:e,align:t="center",sideOffset:r=4,...n}){return c.jsx(MC,{children:c.jsx(LC,{"data-slot":"popover-content",align:t,sideOffset:r,className:B("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 DC({...e}){return c.jsx(OC,{"data-slot":"popover-anchor",...e})}const tm={};function On(){const e=tm?.VITE_CLIENT_ID?.trim()||tm?.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}const rm={};let nm=null;function BC(e){nm=e}function $C(){return(rm?.VITE_API_BASE_URL?.trim()||rm?.VITE_API_URL?.trim()||"").replace(/\/$/,"")}const pn=Ct.create({baseURL:$C()});pn.interceptors.request.use(e=>{const t=On();t&&(e.params={...e.params,clientId:t}),typeof FormData<"u"&&e.data instanceof FormData&&delete e.headers["Content-Type"];let r=nm?.();if((!r||Object.keys(r).length===0)&&(r=Ts()),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});function om(e){return JSON.stringify(e).slice(1,-1)}function im(e){const t=e.asyncSearchValueObjectKeys;return Array.isArray(t)?t.map(r=>typeof r=="string"?r.trim():"").filter(Boolean):[]}function jC(e){return e.asyncSearchValueMode==="object"&&im(e).length>0}function zC(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 UC(e,t){const r=t.mode??"debounce",n=Math.max(0,t.intervalMs??300),[o,i]=S.useState(()=>r==="throttle"?e:""),s=S.useRef(0),a=S.useRef(void 0);return S.useEffect(()=>{if(e===""){a.current&&clearTimeout(a.current),i("");return}if(r==="debounce"){const l=setTimeout(()=>i(e),n);return()=>clearTimeout(l)}const d=Date.now(),u=d-s.current;return u>=n?(s.current=d,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 Hl(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 Wl(e,t){return e==null||e===""?!0:t&&typeof e=="object"&&!Array.isArray(e)?Object.keys(e).length===0:!1}function VC(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 HC(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 WC(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 sm(e,t){return typeof t=="number"&&t>0?e.slice(0,t):e}function Rl(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.label=="string"&&t.value!==null&&t.value!==void 0}const am=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:d,formValues:u={},submissionContext:l})=>{const f=e.properties||{},p=jC(f),m=f.apiEndpoint?.trim()||"",g=f.apiRealtime===!0,h=(f.apiMethod||"GET").toUpperCase()==="POST"?"POST":"GET",y=f.searchInBody===!0,w=h==="POST"||h==="GET"&&y,v=f.searchStrategy??f.searchSchedule??"debounce",x=f.searchIntervalMs??f.intervalMs??300,N=f.minQueryLength??0,P=f.maxResults,E=f.searchQueryParam||"q",_=f.clearable!==!1,C=u,[A,O]=S.useState(()=>Wl(t,p)?"":p&&typeof t=="object"&&t!==null&&!Array.isArray(t)?f.initialDisplayLabel||"":f.initialDisplayLabel||String(t)),[T,z]=S.useState(!1),[q,I]=S.useState([]),[$,M]=S.useState([]),[D,L]=S.useState([]),[U,j]=S.useState(!1),[se,H]=S.useState(null),[G,ee]=S.useState(-1),de=S.useRef(Hl(t,p)),ne=S.useRef(Wl(t,p)?"":p&&typeof t=="object"&&t!==null&&!Array.isArray(t)?f.initialDisplayLabel||"":f.initialDisplayLabel||String(t??"")),K=S.useRef(void 0),re=S.useRef(0),Te=S.useRef(null),Z=UC(A,{mode:v,intervalMs:x}),te=S.useMemo(()=>q.filter(Rl),[q]);S.useEffect(()=>{if(te.length===0){G!==-1&&ee(-1);return}(G<0||G>=te.length)&&ee(0)},[G,te.length]);const he=S.useMemo(()=>{const oe=Ho(m,f.apiQueryParams),pe=new Set(oe);for(const We of f.dependentFields||[])We&&pe.add(We);return pe},[m,f.apiQueryParams,f.dependentFields]),le=S.useMemo(()=>{if(he.size===0)return null;const oe={};return he.forEach(pe=>{oe[pe]=C[pe]}),JSON.stringify(oe)},[he,C]),Xe=S.useMemo(()=>JSON.stringify(u),[u]),ge=S.useMemo(()=>JSON.stringify(l||{}),[l]);S.useEffect(()=>{const oe=Hl(t,p);if(oe===de.current)return;if(de.current=oe,Wl(t,p)){ne.current="",O(""),I([]),M([]),L([]),H(null),z(!1);return}const pe=f.initialDisplayLabel||(!p&&typeof t=="string"?t:"");ne.current=pe,O(pe)},[t,f.initialDisplayLabel,p]),S.useEffect(()=>{if(!m){I([]),M([]),L([]),j(!1);return}if(s||i||e.disabled){I([]),M([]),L([]),j(!1);return}const oe=Z;if(oe.length<N){I([]),M([]),L([]),j(!1),H(null);return}const pe=za({apiEndpoint:m,apiMethod:h,apiQueryParams:f.apiQueryParams,formValues:C,submissionContext:l,apiRealtime:g,additionalRequiredFieldNames:f.dependentFields});if(pe.blocked){I([]),M([]),L([]),j(!1),H(null);return}Te.current?.abort();const We=new AbortController;Te.current=We;const Tt=++re.current;return(async()=>{j(!0),H(null);const Fe=rn(pe.url),Ke={};w&&(Ke["Content-Type"]="application/json"),f.apiKey&&(Ke["X-CSCAPI-KEY"]=f.apiKey);const nt=f.apiAuth??$l(f.apiHeaders)??{type:"none"},yt=jl(nt,{formValues:C,submissionContext:l,apiRealtime:g});Object.assign(Ke,yt);const Yt=go(Bl(f.apiHeaders),{formValues:C,submissionContext:l,apiRealtime:g});Object.assign(Ke,Yt);const St=go(f.apiBodyFields,{formValues:C,submissionContext:l,apiRealtime:g});try{let Pe;if(!w)Pe=(await pn.get(Fe,{params:{[E]:oe},signal:We.signal,headers:Object.keys(Ke).length?Ke:void 0})).data;else{let Ot={};pe.postBodyBase&&Object.keys(pe.postBodyBase).length>0?Ot={...pe.postBodyBase}:g&&Object.keys(C).length>0&&(Ot={...C}),Ot={...Ot,...St};let Jt=Ot;if(f.searchBodyTemplate?.trim()){let an=f.searchBodyTemplate.replace(/\{\{query\}\}/g,()=>om(oe)).replace(/\{query\}/g,()=>om(oe));an=$a(an,C,l,g);const Qt=JSON.parse(an);Jt={...Ot,...Qt}}else Jt={...Ot,[E]:oe};Pe=(await pn.post(Fe,Jt,{signal:We.signal,headers:Object.keys(Ke).length?Ke:void 0})).data}if(Tt!==re.current)return;const ft=f.apiResultsFormat,et=f.apiResultsConfig,xt=ft==="clinicaltables_v3",ur=qA(Pe),Nr=xt||ft===void 0&&ur,rr=ft==="tuple_array";let Gr=null;Nr?Gr=Op({response:Pe,sourceUrl:Fe,rowsIndex:et?.rowsIndex??3,rowsPath:et?.rowsPath,columns:et?.columns,columnsQueryParam:et?.columnsQueryParam??"sf",columnsQueryParamSeparator:et?.columnsQueryParamSeparator??","}):rr&&(Gr=Op({response:Pe,sourceUrl:Fe,rowsIndex:et?.rowsIndex,rowsPath:et?.rowsPath,columns:et?.columns,columnsQueryParam:et?.columnsQueryParam,columnsQueryParamSeparator:et?.columnsQueryParamSeparator}));const hn=WC(Pe),Ft=Gr!==null,br=Gr&&Array.isArray(Gr)?Gr:Array.isArray(hn)&&hn.every(Ot=>Ot&&typeof Ot=="object"&&!Array.isArray(Ot))?hn:null;L(br??hn);const Io=Array.isArray(f.apiLabelFields)&&f.apiLabelFields.length>0,sn=br&&(Ft||Io)?XA({rows:br,apiLabelField:f.apiLabelField,apiLabelFields:f.apiLabelFields,apiLabelSeparator:f.apiLabelSeparator,apiValueField:f.apiValueField}):ci(Pe,f.apiLabelField,f.apiValueField);M(sn);const Lr=f.apiClientFilter;let Xt=sn;if(Lr?.filterField&&Lr?.matchField){const Ot=C[Lr.matchField];if(Ot!=null){const Jt=f.apiValueField;Xt=sn.filter(Et=>{const Qt=(br??hn).find(fr=>String(jt(fr,Jt||"code"))===String(Et.value));if(!Qt)return!1;const wr=jt(Qt,Lr.filterField);return String(wr)===String(Ot)})}else Xt=[]}const vr=sm(Xt,P).filter(Rl);I(vr),ee(vr.length>0?0:-1)}catch(Pe){if(Ct.isCancel(Pe)||Pe?.code==="ERR_CANCELED"||Tt!==re.current)return;I([]),M([]),L([]),H(HC(Pe)),ee(-1)}finally{Tt===re.current&&j(!1)}})(),()=>{We.abort()}},[Z,m,h,y,w,E,N,P,f.apiKey,f.searchBodyTemplate,f.apiLabelField,f.apiLabelFields,f.apiLabelSeparator,f.apiValueField,f.apiQueryParams,f.apiClientFilter,f.apiResultsFormat,f.apiResultsConfig,f.dependentFields,g,C,l,s,i,e.disabled,le,Xe,ge]),S.useEffect(()=>{const oe=f.apiClientFilter;if(!oe||D.length===0||$.length===0)return;const pe=C[oe.matchField],We=f.apiValueField;if(pe==null){I([]);return}const Tt=$.filter(Fe=>{const Ke=D.find(yt=>String(jt(yt,We||"code"))===String(Fe.value));if(!Ke)return!1;const nt=jt(Ke,oe.filterField);return String(nt)===String(pe)}),ze=sm(Tt,P).filter(Rl);I(ze),ee(ze.length>0?0:-1)},[f.apiClientFilter,f.apiValueField,C,P,$,D]);const Se=i||e.disabled,ae=s||e.readOnly,ve=S.useCallback(oe=>{const pe=oe.target.value;ae||Se||(de.current&&ne.current&&pe!==ne.current&&(de.current="",ne.current="",r(p?null:"")),O(pe),z(!0),ee(-1))},[Se,ae,p,r]),He=S.useCallback(oe=>{const pe=typeof oe?.label=="string"?oe.label:String(oe?.value??""),We=f.apiValueField||"code";if(p){const Tt=im(f),ze=D.find(Fe=>String(jt(Fe,We))===String(oe.value));if(ze&&typeof ze=="object"&&!Array.isArray(ze)&&Tt.length>0){const Fe=zC(ze,Tt);de.current=Hl(Fe,!0),ne.current=pe,r(Fe),O(pe)}else de.current=`S:${String(oe.value)}`,ne.current=pe,r(String(oe.value)),O(pe)}else de.current=`S:${String(oe.value)}`,ne.current=pe,r(String(oe.value)),O(pe);K.current&&clearTimeout(K.current),z(!1),ee(-1),n?.()},[p,n,r,f,D]),dt=S.useCallback(oe=>{oe.preventDefault(),oe.stopPropagation(),!(Se||ae)&&(de.current="",ne.current="",r(p?null:""),O(""),I([]),M([]),L([]),H(null),z(!1),n?.())},[Se,ae,p,r,n]),Ge=S.useMemo(()=>T&&!ae&&(U||!!se||te.length>0||Z.length>=N&&!U),[T,ae,U,se,te.length,Z,N]),Rt=S.useCallback(oe=>{if(!(ae||Se))if(oe.key==="ArrowDown")oe.preventDefault(),z(!0),ee(pe=>te.length===0?-1:(pe+1)%te.length);else if(oe.key==="ArrowUp")oe.preventDefault(),z(!0),ee(pe=>te.length===0?-1:pe<=0?te.length-1:pe-1);else if(oe.key==="Enter"){const pe=G>=0?te[G]:void 0;Ge&&pe&&!pe.disabled&&(oe.preventDefault(),He(pe))}else oe.key==="Escape"&&z(!1)},[Se,ae,G,Ge,te,He]),Je=e.appearance?.size||"md",Y={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},je=ht(e),gt=$t(e,!!(o||se)),Ie=Z.length>=N&&!U&&!se&&te.length===0;return c.jsx(At,{field:e,error:o||se||void 0,isRequired:a,className:d,children:c.jsxs(Ul,{open:Ge,onOpenChange:oe=>{oe||z(!1)},children:[c.jsx(DC,{asChild:!0,children:c.jsxs("div",{className:"relative flex w-full min-w-0 items-center gap-1",children:[c.jsx(An,{id:je,role:"combobox","aria-expanded":Ge,"aria-autocomplete":"list","aria-controls":Ge?`${je}-listbox`:void 0,"aria-activedescendant":G>=0?`${je}-opt-${G}`:void 0,value:A,onChange:ve,onKeyDown:Rt,onFocus:()=>{K.current&&clearTimeout(K.current),!ae&&!Se&&z(!0)},onBlur:()=>{K.current=setTimeout(()=>{z(!1),n?.()},150)},placeholder:e.placeholder||"Search…",disabled:Se,readOnly:ae,"aria-describedby":gt,"aria-invalid":Zt(!!(o||se)),"aria-required":a,className:B("pr-20",Y[Je],(o||se)&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)}),c.jsxs("div",{className:"pointer-events-none absolute right-1 top-1/2 flex -translate-y-1/2 items-center gap-0.5",children:[U&&c.jsx(qo,{className:"pointer-events-none h-4 w-4 animate-spin text-muted-foreground"}),_&&VC(t,A,p)&&!Se&&!ae&&c.jsx(Kt,{type:"button",variant:"ghost",size:"icon",className:"pointer-events-auto h-8 w-8 shrink-0",onMouseDown:oe=>oe.preventDefault(),onClick:dt,"aria-label":"Clear",children:c.jsx(Xo,{className:"h-4 w-4"})})]})]})}),c.jsx(Vl,{className:"p-0 w-[var(--radix-popover-trigger-width)] min-w-[12rem] overflow-hidden",align:"start",onOpenAutoFocus:oe=>oe.preventDefault(),onCloseAutoFocus:oe=>oe.preventDefault(),children:c.jsx("div",{id:`${je}-listbox`,role:"listbox",children:se?c.jsx("div",{className:"px-3 py-2 text-sm text-destructive",children:se}):U?c.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-sm text-muted-foreground",children:[c.jsx(qo,{className:"h-4 w-4 animate-spin shrink-0"}),"Loading…"]}):Ie?c.jsx("ul",{className:"py-1","aria-label":"Search results",children:c.jsx("li",{role:"option","aria-disabled":!0,className:"cursor-default select-none px-3 py-2 text-sm text-muted-foreground",onMouseDown:oe=>oe.preventDefault(),children:"No results found"})}):c.jsx("ul",{className:"max-h-60 overflow-y-auto overscroll-contain py-1","aria-label":"Search results",children:te.map((oe,pe)=>c.jsx("li",{id:`${je}-opt-${pe}`,role:"option","aria-selected":G===pe,className:B(oe.disabled?"cursor-not-allowed opacity-60":"cursor-pointer","px-3 py-2 text-sm",G===pe&&"bg-accent text-accent-foreground"),onMouseEnter:()=>ee(pe),onMouseDown:We=>We.preventDefault(),onClick:()=>{oe.disabled||He(oe)},children:oe.label},`${oe.value}-${pe}`))})})})]})})};var Is="Checkbox",[RC]=xr(Is),[GC,Gl]=RC(Is);function KC(e){const{__scopeCheckbox:t,checked:r,children:n,defaultChecked:o,disabled:i,form:s,name:a,onCheckedChange:d,required:u,value:l="on",internal_do_not_use_render:f}=e,[p,m]=en({prop:r,defaultProp:o??!1,onChange:d,caller:Is}),[g,h]=b.useState(null),[y,w]=b.useState(null),v=b.useRef(!1),x=g?!!s||!!g.closest("form"):!0,N={checked:p,disabled:i,setChecked:m,control:g,setControl:h,name:a,form:s,value:l,hasConsumerStoppedPropagationRef:v,required:u,defaultChecked:In(o)?!1:o,isFormControl:x,bubbleInput:y,setBubbleInput:w};return c.jsx(GC,{scope:t,...N,children:qC(f)?f(N):n})}var lm="CheckboxTrigger",cm=b.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:r,...n},o)=>{const{control:i,value:s,disabled:a,checked:d,required:u,setControl:l,setChecked:f,hasConsumerStoppedPropagationRef:p,isFormControl:m,bubbleInput:g}=Gl(lm,e),h=Ze(o,l),y=b.useRef(d);return b.useEffect(()=>{const w=i?.form;if(w){const v=()=>f(y.current);return w.addEventListener("reset",v),()=>w.removeEventListener("reset",v)}},[i,f]),c.jsx($e.button,{type:"button",role:"checkbox","aria-checked":In(d)?"mixed":d,"aria-required":u,"data-state":hm(d),"data-disabled":a?"":void 0,disabled:a,value:s,...n,ref:h,onKeyDown:Le(t,w=>{w.key==="Enter"&&w.preventDefault()}),onClick:Le(r,w=>{f(v=>In(v)?!0:!v),g&&m&&(p.current=w.isPropagationStopped(),p.current||w.stopPropagation())})})});cm.displayName=lm;var dm=b.forwardRef((e,t)=>{const{__scopeCheckbox:r,name:n,checked:o,defaultChecked:i,required:s,disabled:a,value:d,onCheckedChange:u,form:l,...f}=e;return c.jsx(KC,{__scopeCheckbox:r,checked:o,defaultChecked:i,disabled:a,required:s,onCheckedChange:u,name:n,form:l,value:d,internal_do_not_use_render:({isFormControl:p})=>c.jsxs(c.Fragment,{children:[c.jsx(cm,{...f,ref:t,__scopeCheckbox:r}),p&&c.jsx(mm,{__scopeCheckbox:r})]})})});dm.displayName=Is;var um="CheckboxIndicator",fm=b.forwardRef((e,t)=>{const{__scopeCheckbox:r,forceMount:n,...o}=e,i=Gl(um,r);return c.jsx(Er,{present:n||In(i.checked)||i.checked===!0,children:c.jsx($e.span,{"data-state":hm(i.checked),"data-disabled":i.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});fm.displayName=um;var pm="CheckboxBubbleInput",mm=b.forwardRef(({__scopeCheckbox:e,...t},r)=>{const{control:n,hasConsumerStoppedPropagationRef:o,checked:i,defaultChecked:s,required:a,disabled:d,name:u,value:l,form:f,bubbleInput:p,setBubbleInput:m}=Gl(pm,e),g=Ze(r,m),h=ti(i),y=ei(n);b.useEffect(()=>{const v=p;if(!v)return;const x=window.HTMLInputElement.prototype,P=Object.getOwnPropertyDescriptor(x,"checked").set,E=!o.current;if(h!==i&&P){const _=new Event("click",{bubbles:E});v.indeterminate=In(i),P.call(v,In(i)?!1:i),v.dispatchEvent(_)}},[p,h,i,o]);const w=b.useRef(In(i)?!1:i);return c.jsx($e.input,{type:"checkbox","aria-hidden":!0,defaultChecked:s??w.current,required:a,disabled:d,name:u,value:l,form:f,...t,tabIndex:-1,ref:g,style:{...t.style,...y,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});mm.displayName=pm;function qC(e){return typeof e=="function"}function In(e){return e==="indeterminate"}function hm(e){return In(e)?"indeterminate":e?"checked":"unchecked"}function Ms({className:e,...t}){return c.jsx(dm,{"data-slot":"checkbox",className:B("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:c.jsx(fm,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:c.jsx(Ri,{className:"size-3.5"})})})}const YC=Vp("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 XC({className:e,variant:t,asChild:r=!1,...n}){const o=r?ru:"span";return c.jsx(o,{"data-slot":"badge",className:B(YC({variant:t}),e),...n})}function JC(e,t){return b.useReducer((r,n)=>t[r][n]??r,e)}var Kl="ScrollArea",[gm]=xr(Kl),[QC,Or]=gm(Kl),ym=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,type:n="hover",dir:o,scrollHideDelay:i=600,...s}=e,[a,d]=b.useState(null),[u,l]=b.useState(null),[f,p]=b.useState(null),[m,g]=b.useState(null),[h,y]=b.useState(null),[w,v]=b.useState(0),[x,N]=b.useState(0),[P,E]=b.useState(!1),[_,C]=b.useState(!1),A=Ze(t,T=>d(T)),O=no(o);return c.jsx(QC,{scope:r,type:n,dir:O,scrollHideDelay:i,scrollArea:a,viewport:u,onViewportChange:l,content:f,onContentChange:p,scrollbarX:m,onScrollbarXChange:g,scrollbarXEnabled:P,onScrollbarXEnabledChange:E,scrollbarY:h,onScrollbarYChange:y,scrollbarYEnabled:_,onScrollbarYEnabledChange:C,onCornerWidthChange:v,onCornerHeightChange:N,children:c.jsx($e.div,{dir:O,...s,ref:A,style:{position:"relative","--radix-scroll-area-corner-width":w+"px","--radix-scroll-area-corner-height":x+"px",...e.style}})})});ym.displayName=Kl;var bm="ScrollAreaViewport",vm=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,children:n,nonce:o,...i}=e,s=Or(bm,r),a=b.useRef(null),d=Ze(t,a,s.onViewportChange);return c.jsxs(c.Fragment,{children:[c.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}),c.jsx($e.div,{"data-radix-scroll-area-viewport":"",...i,ref:d,style:{overflowX:s.scrollbarXEnabled?"scroll":"hidden",overflowY:s.scrollbarYEnabled?"scroll":"hidden",...e.style},children:c.jsx("div",{ref:s.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});vm.displayName=bm;var nn="ScrollAreaScrollbar",wm=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Or(nn,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"?c.jsx(ZC,{...n,ref:t,forceMount:r}):o.type==="scroll"?c.jsx(eE,{...n,ref:t,forceMount:r}):o.type==="auto"?c.jsx(Sm,{...n,ref:t,forceMount:r}):o.type==="always"?c.jsx(ql,{...n,ref:t}):null});wm.displayName=nn;var ZC=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Or(nn,e.__scopeScrollArea),[i,s]=b.useState(!1);return b.useEffect(()=>{const a=o.scrollArea;let d=0;if(a){const u=()=>{window.clearTimeout(d),s(!0)},l=()=>{d=window.setTimeout(()=>s(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",l),()=>{window.clearTimeout(d),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",l)}}},[o.scrollArea,o.scrollHideDelay]),c.jsx(Er,{present:r||i,children:c.jsx(Sm,{"data-state":i?"visible":"hidden",...n,ref:t})})}),eE=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Or(nn,e.__scopeScrollArea),i=e.orientation==="horizontal",s=$s(()=>d("SCROLL_END"),100),[a,d]=JC("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(()=>d("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,d]),b.useEffect(()=>{const u=o.viewport,l=i?"scrollLeft":"scrollTop";if(u){let f=u[l];const p=()=>{const m=u[l];f!==m&&(d("SCROLL"),s()),f=m};return u.addEventListener("scroll",p),()=>u.removeEventListener("scroll",p)}},[o.viewport,i,d,s]),c.jsx(Er,{present:r||a!=="hidden",children:c.jsx(ql,{"data-state":a==="hidden"?"hidden":"visible",...n,ref:t,onPointerEnter:Le(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:Le(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),Sm=b.forwardRef((e,t)=>{const r=Or(nn,e.__scopeScrollArea),{forceMount:n,...o}=e,[i,s]=b.useState(!1),a=e.orientation==="horizontal",d=$s(()=>{if(r.viewport){const u=r.viewport.offsetWidth<r.viewport.scrollWidth,l=r.viewport.offsetHeight<r.viewport.scrollHeight;s(a?u:l)}},10);return bo(r.viewport,d),bo(r.content,d),c.jsx(Er,{present:n||i,children:c.jsx(ql,{"data-state":i?"visible":"hidden",...o,ref:t})})}),ql=b.forwardRef((e,t)=>{const{orientation:r="vertical",...n}=e,o=Or(nn,e.__scopeScrollArea),i=b.useRef(null),s=b.useRef(0),[a,d]=b.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=Nm(a.viewport,a.content),l={...n,sizes:a,onSizesChange:d,hasThumb:u>0&&u<1,onThumbChange:p=>i.current=p,onThumbPointerUp:()=>s.current=0,onThumbPointerDown:p=>s.current=p};function f(p,m){return sE(p,s.current,a,m)}return r==="horizontal"?c.jsx(tE,{...l,ref:t,onThumbPositionChange:()=>{if(o.viewport&&i.current){const p=o.viewport.scrollLeft,m=_m(p,a,o.dir);i.current.style.transform=`translate3d(${m}px, 0, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollLeft=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollLeft=f(p,o.dir))}}):r==="vertical"?c.jsx(rE,{...l,ref:t,onThumbPositionChange:()=>{if(o.viewport&&i.current){const p=o.viewport.scrollTop,m=_m(p,a);i.current.style.transform=`translate3d(0, ${m}px, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollTop=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollTop=f(p))}}):null}),tE=b.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...o}=e,i=Or(nn,e.__scopeScrollArea),[s,a]=b.useState(),d=b.useRef(null),u=Ze(t,d,i.onScrollbarXChange);return b.useEffect(()=>{d.current&&a(getComputedStyle(d.current))},[d]),c.jsx(Am,{"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":Bs(r)+"px",...e.style},onThumbPointerDown:l=>e.onThumbPointerDown(l.x),onDragScroll:l=>e.onDragScroll(l.x),onWheelScroll:(l,f)=>{if(i.viewport){const p=i.viewport.scrollLeft+l.deltaX;e.onWheelScroll(p),Tm(p,f)&&l.preventDefault()}},onResize:()=>{d.current&&i.viewport&&s&&n({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:Ds(s.paddingLeft),paddingEnd:Ds(s.paddingRight)}})}})}),rE=b.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...o}=e,i=Or(nn,e.__scopeScrollArea),[s,a]=b.useState(),d=b.useRef(null),u=Ze(t,d,i.onScrollbarYChange);return b.useEffect(()=>{d.current&&a(getComputedStyle(d.current))},[d]),c.jsx(Am,{"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":Bs(r)+"px",...e.style},onThumbPointerDown:l=>e.onThumbPointerDown(l.y),onDragScroll:l=>e.onDragScroll(l.y),onWheelScroll:(l,f)=>{if(i.viewport){const p=i.viewport.scrollTop+l.deltaY;e.onWheelScroll(p),Tm(p,f)&&l.preventDefault()}},onResize:()=>{d.current&&i.viewport&&s&&n({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:Ds(s.paddingTop),paddingEnd:Ds(s.paddingBottom)}})}})}),[nE,xm]=gm(nn),Am=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:o,onThumbChange:i,onThumbPointerUp:s,onThumbPointerDown:a,onThumbPositionChange:d,onDragScroll:u,onWheelScroll:l,onResize:f,...p}=e,m=Or(nn,r),[g,h]=b.useState(null),y=Ze(t,A=>h(A)),w=b.useRef(null),v=b.useRef(""),x=m.viewport,N=n.content-n.viewport,P=ar(l),E=ar(d),_=$s(f,10);function C(A){if(w.current){const O=A.clientX-w.current.left,T=A.clientY-w.current.top;u({x:O,y:T})}}return b.useEffect(()=>{const A=O=>{const T=O.target;g?.contains(T)&&P(O,N)};return document.addEventListener("wheel",A,{passive:!1}),()=>document.removeEventListener("wheel",A,{passive:!1})},[x,g,N,P]),b.useEffect(E,[n,E]),bo(g,_),bo(m.content,_),c.jsx(nE,{scope:r,scrollbar:g,hasThumb:o,onThumbChange:ar(i),onThumbPointerUp:ar(s),onThumbPositionChange:E,onThumbPointerDown:ar(a),children:c.jsx($e.div,{...p,ref:y,style:{position:"absolute",...p.style},onPointerDown:Le(e.onPointerDown,A=>{A.button===0&&(A.target.setPointerCapture(A.pointerId),w.current=g.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),C(A))}),onPointerMove:Le(e.onPointerMove,C),onPointerUp:Le(e.onPointerUp,A=>{const O=A.target;O.hasPointerCapture(A.pointerId)&&O.releasePointerCapture(A.pointerId),document.body.style.webkitUserSelect=v.current,m.viewport&&(m.viewport.style.scrollBehavior=""),w.current=null})})})}),Ls="ScrollAreaThumb",Cm=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=xm(Ls,e.__scopeScrollArea);return c.jsx(Er,{present:r||o.hasThumb,children:c.jsx(oE,{ref:t,...n})})}),oE=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,style:n,...o}=e,i=Or(Ls,r),s=xm(Ls,r),{onThumbPositionChange:a}=s,d=Ze(t,f=>s.onThumbChange(f)),u=b.useRef(void 0),l=$s(()=>{u.current&&(u.current(),u.current=void 0)},100);return b.useEffect(()=>{const f=i.viewport;if(f){const p=()=>{if(l(),!u.current){const m=aE(f,a);u.current=m,a()}};return a(),f.addEventListener("scroll",p),()=>f.removeEventListener("scroll",p)}},[i.viewport,l,a]),c.jsx($e.div,{"data-state":s.hasThumb?"visible":"hidden",...o,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:Le(e.onPointerDownCapture,f=>{const m=f.target.getBoundingClientRect(),g=f.clientX-m.left,h=f.clientY-m.top;s.onThumbPointerDown({x:g,y:h})}),onPointerUp:Le(e.onPointerUp,s.onThumbPointerUp)})});Cm.displayName=Ls;var Yl="ScrollAreaCorner",Em=b.forwardRef((e,t)=>{const r=Or(Yl,e.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?c.jsx(iE,{...e,ref:t}):null});Em.displayName=Yl;var iE=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,...n}=e,o=Or(Yl,r),[i,s]=b.useState(0),[a,d]=b.useState(0),u=!!(i&&a);return bo(o.scrollbarX,()=>{const l=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(l),d(l)}),bo(o.scrollbarY,()=>{const l=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(l),s(l)}),u?c.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 Ds(e){return e?parseInt(e,10):0}function Nm(e,t){const r=e/t;return isNaN(r)?0:r}function Bs(e){const t=Nm(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,n=(e.scrollbar.size-r)*t;return Math.max(n,18)}function sE(e,t,r,n="ltr"){const o=Bs(r),i=o/2,s=t||i,a=o-s,d=r.scrollbar.paddingStart+s,u=r.scrollbar.size-r.scrollbar.paddingEnd-a,l=r.content-r.viewport,f=n==="ltr"?[0,l]:[l*-1,0];return km([d,u],f)(e)}function _m(e,t,r="ltr"){const n=Bs(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,i=t.scrollbar.size-o,s=t.content-t.viewport,a=i-n,d=r==="ltr"?[0,s]:[s*-1,0],u=Jo(e,d);return km([0,s],[0,a])(u)}function km(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 Tm(e,t){return e>0&&e<t}var aE=(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 $s(e,t){const r=ar(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 bo(e,t){const r=ar(t);er(()=>{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 lE=ym,cE=vm,dE=Em;function uE({className:e,children:t,...r}){return c.jsxs(lE,{"data-slot":"scroll-area",className:B("relative",e),...r,children:[c.jsx(cE,{"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}),c.jsx(fE,{}),c.jsx(dE,{})]})}function fE({className:e,orientation:t="vertical",...r}){return c.jsx(wm,{"data-slot":"scroll-area-scrollbar",orientation:t,className:B("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:c.jsx(Cm,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const Fm=({field:e,value:t=[],onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a,formValues:d={},submissionContext:u,excludedOptionValues:l})=>{const{options:f,isLoadingOptions:p,optionsError:m}=$p({field:e,formValues:d,submissionContext:u}),g=l?.length?new Set(l.map(String)):null,h=g?f.filter(_=>!g.has(String(_.value??_.label??""))):f,y=Array.isArray(t)?t:[],w=y.map(_=>h.find(C=>String(C.value)===String(_))).filter(Boolean),v=S.useCallback(_=>{const C=y.includes(_)?y.filter(A=>A!==_):[...y,_];r(C),n?.()},[y,r,n]),x=S.useCallback(_=>{r(y.filter(C=>C!==_)),n?.()},[y,r,n]),N=e.appearance?.size||"md",P={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},E=w.length>0?`${w.length} selected`:h.length===0&&l?.length?"No available options":e.placeholder||"Select options";return c.jsxs(At,{field:e,error:o||m||void 0,isRequired:s,className:a,children:[c.jsxs(Ul,{children:[c.jsx(em,{asChild:!0,children:c.jsxs(Kt,{type:"button",variant:"outline",role:"combobox","aria-expanded":void 0,"aria-haspopup":"listbox","aria-multiselectable":"true","aria-describedby":$t(e,!!o||!!m),"aria-invalid":Zt(!!o||!!m),"aria-required":s,id:ht(e),disabled:i||e.disabled||p,className:B("w-full min-w-0 justify-between font-normal",P[N],o&&"border-destructive focus-visible:ring-destructive",m&&"border-destructive focus-visible:ring-destructive",e.appearance?.className),children:[c.jsx("span",{className:"truncate",children:E}),c.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[p&&c.jsx(qo,{className:"h-4 w-4 animate-spin text-muted-foreground"}),c.jsx(Ko,{className:"h-4 w-4 opacity-50"})]})]})}),c.jsx(Vl,{className:"w-[var(--radix-popover-trigger-width)] p-0 overflow-hidden",align:"start",children:c.jsx(uE,{className:"h-60 overflow-hidden rounded-md",children:c.jsx("ul",{role:"listbox","aria-multiselectable":"true","aria-label":e.label||e.name||"Options",className:"p-1",children:h.length===0?c.jsx("li",{className:"px-2 py-3 text-sm text-muted-foreground text-center",children:p?"Loading options...":l?.length?"No available options":"No options available"}):h.map(_=>{const C=String(_.value||_.label),A=_.label||_.value||C,O=y.includes(C);return c.jsxs("li",{role:"option","aria-selected":O,className:"flex items-center gap-2 rounded-sm px-2 py-1.5 cursor-pointer hover:bg-accent focus:bg-accent outline-none",onClick:()=>!_.disabled&&v(C),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),_.disabled||v(C))},children:[c.jsx(Ms,{checked:O,disabled:_.disabled,onCheckedChange:()=>!_.disabled&&v(C),onClick:T=>T.stopPropagation(),"aria-hidden":!0,className:"pointer-events-none"}),c.jsx("span",{className:"flex-1 truncate text-sm",children:A})]},C)})})})})]}),w.length>0&&c.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",role:"list","aria-label":"Selected options",children:w.map(_=>{const C=String(_.value||_.label),A=_.label||_.value||C;return c.jsxs(XC,{variant:"secondary",className:"pl-2 pr-1 py-0.5 text-xs font-normal gap-1",children:[c.jsx("span",{className:"truncate max-w-[120px]",children:A}),c.jsx("button",{type:"button","aria-label":`Remove ${A}`,className:"rounded-full p-0.5 hover:bg-muted focus:outline-none focus:ring-2 focus:ring-ring",onClick:()=>x(C),tabIndex:-1,children:c.jsx(Xo,{className:"h-3 w-3"})})]},C)})})]})},Pm=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a})=>{const d=S.useCallback(u=>{r(u===!0),n?.()},[r,n]);return c.jsxs("div",{className:B("space-y-2",a),children:[c.jsxs("div",{className:"flex items-start space-x-3",children:[c.jsx(Ms,{id:ht(e),checked:t||!1,onCheckedChange:d,disabled:i||e.disabled,"aria-describedby":$t(e,!!o),"aria-required":s,className:B(o&&"border-destructive")}),c.jsxs("div",{className:"grid gap-1.5 leading-none",children:[c.jsxs(Cn,{id:Vi(e),htmlFor:ht(e),className:B("text-sm font-medium cursor-pointer",o&&"text-destructive"),children:[e.label,s&&c.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.description&&!o&&c.jsx("p",{id:Ro(e),className:"text-xs text-muted-foreground",children:e.description})]})]}),o&&c.jsx("p",{id:Go(e),className:"text-xs text-destructive",role:"alert",children:o})]})};var js="Switch",[pE]=xr(js),[mE,hE]=pE(js),Om=b.forwardRef((e,t)=>{const{__scopeSwitch:r,name:n,checked:o,defaultChecked:i,required:s,disabled:a,value:d="on",onCheckedChange:u,form:l,...f}=e,[p,m]=b.useState(null),g=Ze(t,x=>m(x)),h=b.useRef(!1),y=p?l||!!p.closest("form"):!0,[w,v]=en({prop:o,defaultProp:i??!1,onChange:u,caller:js});return c.jsxs(mE,{scope:r,checked:w,disabled:a,children:[c.jsx($e.button,{type:"button",role:"switch","aria-checked":w,"aria-required":s,"data-state":Dm(w),"data-disabled":a?"":void 0,disabled:a,value:d,...f,ref:g,onClick:Le(e.onClick,x=>{v(N=>!N),y&&(h.current=x.isPropagationStopped(),h.current||x.stopPropagation())})}),y&&c.jsx(Lm,{control:p,bubbles:!h.current,name:n,value:d,checked:w,required:s,disabled:a,form:l,style:{transform:"translateX(-100%)"}})]})});Om.displayName=js;var Im="SwitchThumb",Mm=b.forwardRef((e,t)=>{const{__scopeSwitch:r,...n}=e,o=hE(Im,r);return c.jsx($e.span,{"data-state":Dm(o.checked),"data-disabled":o.disabled?"":void 0,...n,ref:t})});Mm.displayName=Im;var gE="SwitchBubbleInput",Lm=b.forwardRef(({__scopeSwitch:e,control:t,checked:r,bubbles:n=!0,...o},i)=>{const s=b.useRef(null),a=Ze(s,i),d=ti(r),u=ei(t);return b.useEffect(()=>{const l=s.current;if(!l)return;const f=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(f,"checked").set;if(d!==r&&m){const g=new Event("click",{bubbles:n});m.call(l,r),l.dispatchEvent(g)}},[d,r,n]),c.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}})});Lm.displayName=gE;function Dm(e){return e?"checked":"unchecked"}var yE=Om,bE=Mm;function Bm({className:e,...t}){return c.jsx(yE,{"data-slot":"switch",className:B("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:c.jsx(bE,{"data-slot":"switch-thumb",className:B("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 vE=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a})=>{const d=e.properties;let u=null;if(e.metadata)try{u=typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata}catch{}const l=u?.onValue??d?.onValue??"On",f=u?.offValue??d?.offValue??"Off",p=u?.onText??d?.onText??l,m=u?.offText??d?.offText??f,g=S.useMemo(()=>{const y=t??e.defaultValue??f;return String(y)===String(l)},[t,e.defaultValue,f,l]),h=S.useCallback(y=>{r(y?l:f),n?.()},[r,n,l,f]);return c.jsxs("div",{className:B("space-y-2",a),children:[c.jsxs("div",{className:"space-y-2",children:[e.label&&c.jsxs(Cn,{id:Vi(e),htmlFor:ht(e),className:B("text-sm font-medium block",o&&"text-destructive"),children:[e.label,s&&c.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.description&&!o&&c.jsx("p",{id:Ro(e),className:"text-xs text-muted-foreground",children:e.description}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Bm,{id:ht(e),checked:g,onCheckedChange:h,disabled:i||e.disabled,"aria-describedby":$t(e,!!o),"aria-required":s,className:B(o&&"opacity-50")}),c.jsx("span",{className:"text-sm text-foreground font-medium",children:g?p:m})]})]}),o&&c.jsx("p",{id:Go(e),className:"text-xs text-destructive",role:"alert",children:o})]})};var Xl="rovingFocusGroup.onEntryFocus",wE={bubbles:!1,cancelable:!0},ui="RovingFocusGroup",[Jl,$m,SE]=Wa(ui),[xE,zs]=xr(ui,[SE]),[AE,CE]=xE(ui),jm=b.forwardRef((e,t)=>c.jsx(Jl.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Jl.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(EE,{...e,ref:t})})}));jm.displayName=ui;var EE=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:d,onEntryFocus:u,preventScrollOnEntryFocus:l=!1,...f}=e,p=b.useRef(null),m=Ze(t,p),g=no(i),[h,y]=en({prop:s,defaultProp:a??null,onChange:d,caller:ui}),[w,v]=b.useState(!1),x=ar(u),N=$m(r),P=b.useRef(!1),[E,_]=b.useState(0);return b.useEffect(()=>{const C=p.current;if(C)return C.addEventListener(Xl,x),()=>C.removeEventListener(Xl,x)},[x]),c.jsx(AE,{scope:r,orientation:n,dir:g,loop:o,currentTabStopId:h,onItemFocus:b.useCallback(C=>y(C),[y]),onItemShiftTab:b.useCallback(()=>v(!0),[]),onFocusableItemAdd:b.useCallback(()=>_(C=>C+1),[]),onFocusableItemRemove:b.useCallback(()=>_(C=>C-1),[]),children:c.jsx($e.div,{tabIndex:w||E===0?-1:0,"data-orientation":n,...f,ref:m,style:{outline:"none",...e.style},onMouseDown:Le(e.onMouseDown,()=>{P.current=!0}),onFocus:Le(e.onFocus,C=>{const A=!P.current;if(C.target===C.currentTarget&&A&&!w){const O=new CustomEvent(Xl,wE);if(C.currentTarget.dispatchEvent(O),!O.defaultPrevented){const T=N().filter(M=>M.focusable),z=T.find(M=>M.active),q=T.find(M=>M.id===h),$=[z,q,...T].filter(Boolean).map(M=>M.ref.current);Vm($,l)}}P.current=!1}),onBlur:Le(e.onBlur,()=>v(!1))})})}),zm="RovingFocusGroupItem",Um=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:o=!1,tabStopId:i,children:s,...a}=e,d=cn(),u=i||d,l=CE(zm,r),f=l.currentTabStopId===u,p=$m(r),{onFocusableItemAdd:m,onFocusableItemRemove:g,currentTabStopId:h}=l;return b.useEffect(()=>{if(n)return m(),()=>g()},[n,m,g]),c.jsx(Jl.ItemSlot,{scope:r,id:u,focusable:n,active:o,children:c.jsx($e.span,{tabIndex:f?0:-1,"data-orientation":l.orientation,...a,ref:t,onMouseDown:Le(e.onMouseDown,y=>{n?l.onItemFocus(u):y.preventDefault()}),onFocus:Le(e.onFocus,()=>l.onItemFocus(u)),onKeyDown:Le(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){l.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const w=kE(y,l.orientation,l.dir);if(w!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let x=p().filter(N=>N.focusable).map(N=>N.ref.current);if(w==="last")x.reverse();else if(w==="prev"||w==="next"){w==="prev"&&x.reverse();const N=x.indexOf(y.currentTarget);x=l.loop?TE(x,N+1):x.slice(N+1)}setTimeout(()=>Vm(x))}}),children:typeof s=="function"?s({isCurrentTabStop:f,hasTabStop:h!=null}):s})})});Um.displayName=zm;var NE={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function _E(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function kE(e,t,r){const n=_E(e.key,r);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return NE[n]}function Vm(e,t=!1){const r=document.activeElement;for(const n of e)if(n===r||(n.focus({preventScroll:t}),document.activeElement!==r))return}function TE(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var Hm=jm,Wm=Um,Ql="Radio",[FE,Rm]=xr(Ql),[PE,OE]=FE(Ql),Gm=b.forwardRef((e,t)=>{const{__scopeRadio:r,name:n,checked:o=!1,required:i,disabled:s,value:a="on",onCheck:d,form:u,...l}=e,[f,p]=b.useState(null),m=Ze(t,y=>p(y)),g=b.useRef(!1),h=f?u||!!f.closest("form"):!0;return c.jsxs(PE,{scope:r,checked:o,disabled:s,children:[c.jsx($e.button,{type:"button",role:"radio","aria-checked":o,"data-state":Xm(o),"data-disabled":s?"":void 0,disabled:s,value:a,...l,ref:m,onClick:Le(e.onClick,y=>{o||d?.(),h&&(g.current=y.isPropagationStopped(),g.current||y.stopPropagation())})}),h&&c.jsx(Ym,{control:f,bubbles:!g.current,name:n,value:a,checked:o,required:i,disabled:s,form:u,style:{transform:"translateX(-100%)"}})]})});Gm.displayName=Ql;var Km="RadioIndicator",qm=b.forwardRef((e,t)=>{const{__scopeRadio:r,forceMount:n,...o}=e,i=OE(Km,r);return c.jsx(Er,{present:n||i.checked,children:c.jsx($e.span,{"data-state":Xm(i.checked),"data-disabled":i.disabled?"":void 0,...o,ref:t})})});qm.displayName=Km;var IE="RadioBubbleInput",Ym=b.forwardRef(({__scopeRadio:e,control:t,checked:r,bubbles:n=!0,...o},i)=>{const s=b.useRef(null),a=Ze(s,i),d=ti(r),u=ei(t);return b.useEffect(()=>{const l=s.current;if(!l)return;const f=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(f,"checked").set;if(d!==r&&m){const g=new Event("click",{bubbles:n});m.call(l,r),l.dispatchEvent(g)}},[d,r,n]),c.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}})});Ym.displayName=IE;function Xm(e){return e?"checked":"unchecked"}var ME=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Us="RadioGroup",[LE]=xr(Us,[zs,Rm]),Jm=zs(),Qm=Rm(),[DE,BE]=LE(Us),Zm=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,name:n,defaultValue:o,value:i,required:s=!1,disabled:a=!1,orientation:d,dir:u,loop:l=!0,onValueChange:f,...p}=e,m=Jm(r),g=no(u),[h,y]=en({prop:i,defaultProp:o??null,onChange:f,caller:Us});return c.jsx(DE,{scope:r,name:n,required:s,disabled:a,value:h,onValueChange:y,children:c.jsx(Hm,{asChild:!0,...m,orientation:d,dir:g,loop:l,children:c.jsx($e.div,{role:"radiogroup","aria-required":s,"aria-orientation":d,"data-disabled":a?"":void 0,dir:g,...p,ref:t})})})});Zm.displayName=Us;var eh="RadioGroupItem",th=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,disabled:n,...o}=e,i=BE(eh,r),s=i.disabled||n,a=Jm(r),d=Qm(r),u=b.useRef(null),l=Ze(t,u),f=i.value===o.value,p=b.useRef(!1);return b.useEffect(()=>{const m=h=>{ME.includes(h.key)&&(p.current=!0)},g=()=>p.current=!1;return document.addEventListener("keydown",m),document.addEventListener("keyup",g),()=>{document.removeEventListener("keydown",m),document.removeEventListener("keyup",g)}},[]),c.jsx(Wm,{asChild:!0,...a,focusable:!s,active:f,children:c.jsx(Gm,{disabled:s,required:i.required,checked:f,...d,...o,name:i.name,ref:l,onCheck:()=>i.onValueChange(o.value),onKeyDown:Le(m=>{m.key==="Enter"&&m.preventDefault()}),onFocus:Le(o.onFocus,()=>{p.current&&u.current?.click()})})})});th.displayName=eh;var $E="RadioGroupIndicator",rh=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,...n}=e,o=Qm(r);return c.jsx(qm,{...o,...n,ref:t})});rh.displayName=$E;var jE=Zm,zE=th,UE=rh;function VE({className:e,...t}){return c.jsx(jE,{"data-slot":"radio-group",className:B("grid gap-3",e),...t})}function HE({className:e,...t}){return c.jsx(zE,{"data-slot":"radio-group-item",className:B("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:c.jsx(UE,{"data-slot":"radio-group-indicator",className:"relative flex items-center justify-center",children:c.jsx(au,{className:"fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2"})})})}const nh=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a,excludedOptionValues:d})=>{const u=e.properties,l=Array.isArray(u?.options)&&u.options.length>0?u.options:Array.isArray(e.options)?e.options:[],f=d?.length?new Set(d.map(String)):null,p=f?l.filter(g=>!f.has(String(g.value??g.label??""))):l,m=S.useCallback(g=>{r(g),n?.()},[r,n]);return c.jsx(At,{field:e,error:o,isRequired:s,className:a,children:c.jsx(VE,{value:t||"",onValueChange:m,disabled:i||e.disabled||p.length===0,className:"flex flex-col space-y-2","aria-required":s,children:p.length===0?c.jsx("p",{className:"text-sm text-muted-foreground py-1",children:"No available options"}):p.map(g=>c.jsxs("div",{className:"flex items-center space-x-3",children:[c.jsx(HE,{id:`${ht(e)}-${g.value}`,value:g.value,disabled:g.disabled,className:B(o&&"border-destructive")}),c.jsxs(Cn,{htmlFor:`${ht(e)}-${g.value}`,className:B("text-sm font-normal cursor-pointer",g.disabled&&"text-muted-foreground cursor-not-allowed"),children:[g.label,g.description&&c.jsx("span",{className:"block text-xs text-muted-foreground",children:g.description})]})]},g.value))})})},oh=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:d})=>{const u=e.properties,l=S.useCallback(N=>{r(N.target.value)},[r]),f=N=>{if(N)return N==="today"?new Date().toISOString().split("T")[0]:N},p=f(u?.minDate),m=f(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",w={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},v=e.appearance?.labelPlacement||"top",x=!e.appearance?.hideLabel&&e.label;return c.jsxs("div",{className:B("space-y-2 w-fit",v==="left"&&"flex items-start gap-4",d),children:[x&&c.jsxs(Cn,{id:Vi(e),htmlFor:ht(e),className:B("text-sm font-medium",v==="left"&&"w-32 pt-2 text-right",o&&"text-destructive"),children:[e.label,a&&c.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),c.jsxs("div",{className:"w-fit",children:[c.jsxs("div",{className:"relative w-fit max-w-full",children:[c.jsx(Dv,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"}),c.jsx(An,{id:ht(e),type:h,value:t||"",onChange:l,onBlur:n,disabled:i||e.disabled,readOnly:s||e.readOnly,min:p,max:m,"aria-describedby":$t(e,!!o),"aria-invalid":Zt(!!o),"aria-required":a,className:B(w[y],"pl-10 w-fit",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]}),e.description&&!o&&c.jsx("p",{id:Ro(e),className:"mt-1.5 text-xs text-muted-foreground",children:e.description}),o&&c.jsx("p",{id:Go(e),className:"mt-1.5 text-xs text-destructive",role:"alert",children:o})]})]})};function vo(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 Zl(e,t){return e===1&&t===1}const ih=/\.(jpg|jpeg|png|gif|webp|bmp|svg)(\?|$)/i;function ec(e){return e.type.startsWith("image/")?!0:ih.test(e.name)}function Vs(e){try{const t=e.split("?")[0];return ih.test(t)}catch{return!1}}function tc({items:e,maxFiles:t,disabled:r,objectUrls:n,failedUrlKeys:o,onImageUrlError:i,onRemove:s,onOpenUrl:a,resolveOpenUrl:d,addSlot:u,className:l}){const f=S.useCallback(p=>{try{return p.split("?")[0].split("/").filter(Boolean).pop()||p}catch{return p}},[]);return c.jsxs("div",{"data-file-like-strip":!0,"data-remove-in-dropzone":!0,className:B("relative w-full h-full flex items-center gap-1 min-h-0 overflow-x-auto",l),children:[e.map((p,m)=>{const g=p instanceof File,h=!g&&p&&"url"in p?p:null,y=h?.url??"",w=`${m}-${y}`,v=h&&o.has(y),x=g?n[m]??null:h&&Vs(y)&&!v?y:null,N=g&&ec(p)&&!!x||!!h&&Vs(y)&&!v&&!!x,P=g?p.name:h?h.name??f(y):"",E=d?.(m,p),_=h&&y||E||"",C=!!a&&!!_;return c.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:[N&&x?c.jsx("img",{src:x,alt:"",className:"absolute inset-0 h-full w-full object-cover",onError:()=>{h&&i(y)}}):c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-muted/40",children:c.jsx(cu,{className:"h-7 w-7 text-muted-foreground","aria-hidden":!0})}),c.jsxs("div",{className:"absolute top-0.5 right-0.5 z-10 flex items-center gap-0.5",children:[C&&c.jsx("button",{type:"button",onClick:A=>{A.preventDefault(),A.stopPropagation(),a(_)},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:c.jsx(lu,{className:"h-3 w-3","aria-hidden":!0})}),c.jsx("button",{type:"button",onClick:A=>{A.preventDefault(),A.stopPropagation(),s(m)},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:c.jsx(Xo,{className:"h-3 w-3","aria-hidden":!0})})]}),!N&&P&&c.jsx("span",{className:"sr-only",children:P})]},w+(g?p.name+p.size:""))}),u]})}function rc(e){const[t,r]=S.useState([]);return S.useEffect(()=>{const n=e.map(o=>o instanceof File&&ec(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 d=S.useCallback(v=>{try{return v.split("?")[0].split("/").filter(Boolean).pop()||v}catch{return v}},[]),u=e instanceof File,l=!u&&e&&"url"in e?e:null,f=l?.url??"",p=l&&r.has(f),m=u?t:l&&Vs(f)&&!p?f:null,g=u&&ec(e)&&!!m||!!l&&Vs(f)&&!p&&!!m,h=u?e.name:l?l.name??d(f):"",y=(s?.trim()||f||"").trim(),w=!!i&&!!y;return c.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:[g&&m?c.jsx("img",{src:m,alt:"",className:"absolute inset-0 h-full w-full rounded object-cover",onError:()=>{l&&n(f)}}):c.jsx("div",{className:"absolute inset-0 flex items-center justify-center rounded bg-muted/40",children:c.jsx(cu,{className:"h-8 w-8 text-muted-foreground","aria-hidden":!0})}),c.jsxs("div",{className:"absolute top-1 right-1 z-10 flex items-center gap-1",children:[w&&y&&c.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:c.jsx(lu,{className:"h-3.5 w-3.5","aria-hidden":!0})}),c.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:c.jsx(Xo,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),!g&&h&&c.jsx("p",{className:"sr-only",children:h})]})}const WE=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a,buttonResponses:d})=>{const{gridStretch:u}=Vo(),l=u&&Di(e),f=e.properties,p=S.useRef(null),[m,g]=S.useState(!1),[h,y]=S.useState(),[w,v]=S.useState(()=>new Set),[x,N]=S.useState(0),P=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,E=Bi(e),_=S.useMemo(()=>$i(t),[t]),[C,A]=S.useState(null);S.useEffect(()=>{A(null)},[t,x]);const O=C??_,T=rc(O),z=e.validation?.find(ge=>ge.type==="fileSize"),q=e.validation?.find(ge=>ge.type==="fileType"),I=z?.value?z.value:f?.maxSize??P?.maxSize??10*1024*1024,$=q?.value?q.value:f?.accept??P?.accept??[],M=Array.isArray($)?$.join(","):"",D=()=>{O.length>=E||p.current?.click()},L=S.useCallback(ge=>{if(z){const Se=Xr(ge,z);if(Se!==!0)return typeof Se=="string"?Se:"File size exceeds the maximum allowed size"}else if(ge.size>I)return`File size must be less than ${vo(I)}`;if(q){const Se=Xr(ge,q);if(Se!==!0)return typeof Se=="string"?Se:"File type is not allowed"}return null},[z,q,I]),U=S.useCallback(ge=>{const Se=Ia(ge,E);r(Se),n?.()},[r,n,E]),j=S.useCallback(ge=>{y(void 0);const Se=Array.from(ge),ae=[...O];let ve=null;for(const He of Se){if(ae.length>=E)break;const dt=L(He);if(dt){ve||(ve=dt);continue}ae.push(He)}if(ve&&ae.length===O.length){y(ve);return}ve&&y(ve),A(ae),U(ae)},[O,E,L,U]),se=S.useCallback(ge=>{const Se=ge.target.files;Se&&Se.length>0&&j(Se),p.current&&(p.current.value="")},[j]),H=S.useCallback(ge=>{if(i)return;const Se=O.filter((ae,ve)=>ve!==ge);N(ae=>ae+1),A(Se),U(Se)},[i,O,U]),G=ge=>{ge.preventDefault(),g(!0)},ee=()=>{g(!1)},de=ge=>{ge.preventDefault(),g(!1),ge.dataTransfer.files?.length&&j(ge.dataTransfer.files)},ne=o||h,K=[];(z||I)&&K.push(`Max size: ${vo(I)}`),q&&$.length>0&&K.push(`Allowed types: ${$.join(", ")}`),E>1&&K.push(`Up to ${E} files`);const re=e.appearance?.hideLabel??!1,Te=S.useMemo(()=>{if(!d)return null;const ge=Object.values(d);for(let Se=ge.length-1;Se>=0;Se-=1){const ae=ge[Se],ve=typeof ae?.status=="string"?ae.status.toLowerCase():null;if(ve&&ve!=="success")continue;const He=ae?.code;if(typeof He=="number"&&(He<200||He>=300))continue;const dt=ae?.data,Ge=dt?.file_url||dt?.fileUrl||ae?.file_url||ae?.fileUrl;if(typeof Ge=="string"&&Ge.trim())return Ge}return null},[d]),Z=S.useCallback(ge=>{window.open(ge,"_blank","noopener,noreferrer")},[]),te=S.useCallback(ge=>{v(Se=>new Set(Se).add(ge))},[]),he=O.length===0,le=O.length<E,Xe=Zl(E,O.length);return c.jsx(At,{field:e,error:ne,isRequired:s,className:B(a,"!space-y-0"),hideLabel:re,children:c.jsx("div",{className:B("min-h-[70px] min-w-0 w-full flex flex-col",l?"flex-1 h-full":"h-[70px]"),children:c.jsxs("div",{onClick:ge=>{ge.target.closest("[data-remove-in-dropzone]")||ge.target.closest("[data-no-open-picker]")||D()},onDragOver:G,onDragLeave:ee,onDrop:de,className:B("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",m&&"border-primary bg-primary/10",ne&&"border-destructive",i&&"opacity-50 cursor-not-allowed",!le&&O.length>0&&"cursor-default"),children:[c.jsx("input",{ref:p,id:ht(e),type:"file",accept:M,multiple:E>1,onChange:se,disabled:i||e.disabled||!le,className:"hidden","aria-describedby":$t(e,!!ne),"aria-invalid":Zt(!!ne),"aria-required":s}),he?c.jsxs(c.Fragment,{children:[c.jsx(Gi,{className:"mx-auto h-5 w-5 text-muted-foreground flex-shrink-0"}),c.jsx("p",{className:"text-[11px] text-muted-foreground leading-tight line-clamp-1",children:"Drag & drop or click"}),K.length>0&&c.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-1",children:K.join(" • ")})]}):Xe?c.jsx(nc,{item:O[0],objectUrl:T[0]??null,failedUrlKeys:w,onImageUrlError:te,onRemove:()=>H(0),onOpenUrl:Z,openTarget:O[0]instanceof File?Te:void 0,disabled:i||e.disabled}):c.jsx(tc,{items:O,maxFiles:E,disabled:i,objectUrls:T,failedUrlKeys:w,onImageUrlError:te,onRemove:H,resolveOpenUrl:(ge,Se)=>Se instanceof File&&O.length===1&&Te?.trim()?Te.trim():null,onOpenUrl:ge=>{ge?.trim()&&Z(ge.trim())},addSlot:le?c.jsxs("button",{type:"button","data-no-open-picker":!0,onClick:ge=>{ge.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:[c.jsx(Gi,{className:"h-4 w-4 mb-0.5","aria-hidden":!0}),"Add"]}):void 0})]})})})};function RE(e){const t=GE(e),r=b.forwardRef((n,o)=>{const{children:i,...s}=n,a=b.Children.toArray(i),d=a.find(qE);if(d){const u=d.props.children,l=a.map(f=>f===d?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:f);return c.jsx(t,{...s,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...s,ref:o,children:i})});return r.displayName=`${e}.Slot`,r}function GE(e){const t=b.forwardRef((r,n)=>{const{children:o,...i}=r;if(b.isValidElement(o)){const s=XE(o),a=YE(i,o.props);return o.type!==b.Fragment&&(a.ref=n?zn(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 KE=Symbol("radix.slottable");function qE(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===KE}function YE(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 d=i(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...i}:n==="className"&&(r[n]=[o,i].filter(Boolean).join(" "))}return{...e,...r}}function XE(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 Hs="Dialog",[sh]=xr(Hs),[JE,Rr]=sh(Hs),ah=e=>{const{__scopeDialog:t,children:r,open:n,defaultOpen:o,onOpenChange:i,modal:s=!0}=e,a=b.useRef(null),d=b.useRef(null),[u,l]=en({prop:n,defaultProp:o??!1,onChange:i,caller:Hs});return c.jsx(JE,{scope:t,triggerRef:a,contentRef:d,contentId:cn(),titleId:cn(),descriptionId:cn(),open:u,onOpenChange:l,onOpenToggle:b.useCallback(()=>l(f=>!f),[l]),modal:s,children:r})};ah.displayName=Hs;var lh="DialogTrigger",QE=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Rr(lh,r),i=Ze(t,o.triggerRef);return c.jsx($e.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":sc(o.open),...n,ref:i,onClick:Le(e.onClick,o.onOpenToggle)})});QE.displayName=lh;var oc="DialogPortal",[ZE,ch]=sh(oc,{forceMount:void 0}),dh=e=>{const{__scopeDialog:t,forceMount:r,children:n,container:o}=e,i=Rr(oc,t);return c.jsx(ZE,{scope:t,forceMount:r,children:b.Children.map(n,s=>c.jsx(Er,{present:r||i.open,children:c.jsx(ss,{asChild:!0,container:o,children:s})}))})};dh.displayName=oc;var Ws="DialogOverlay",uh=b.forwardRef((e,t)=>{const r=ch(Ws,e.__scopeDialog),{forceMount:n=r.forceMount,...o}=e,i=Rr(Ws,e.__scopeDialog);return i.modal?c.jsx(Er,{present:n||i.open,children:c.jsx(tN,{...o,ref:t})}):null});uh.displayName=Ws;var eN=RE("DialogOverlay.RemoveScroll"),tN=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Rr(Ws,r);return c.jsx(ms,{as:eN,allowPinchZoom:!0,shards:[o.contentRef],children:c.jsx($e.div,{"data-state":sc(o.open),...n,ref:t,style:{pointerEvents:"auto",...n.style}})})}),Yn="DialogContent",fh=b.forwardRef((e,t)=>{const r=ch(Yn,e.__scopeDialog),{forceMount:n=r.forceMount,...o}=e,i=Rr(Yn,e.__scopeDialog);return c.jsx(Er,{present:n||i.open,children:i.modal?c.jsx(rN,{...o,ref:t}):c.jsx(nN,{...o,ref:t})})});fh.displayName=Yn;var rN=b.forwardRef((e,t)=>{const r=Rr(Yn,e.__scopeDialog),n=b.useRef(null),o=Ze(t,r.contentRef,n);return b.useEffect(()=>{const i=n.current;if(i)return fl(i)},[]),c.jsx(ph,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Le(e.onCloseAutoFocus,i=>{i.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:Le(e.onPointerDownOutside,i=>{const s=i.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&i.preventDefault()}),onFocusOutside:Le(e.onFocusOutside,i=>i.preventDefault())})}),nN=b.forwardRef((e,t)=>{const r=Rr(Yn,e.__scopeDialog),n=b.useRef(!1),o=b.useRef(!1);return c.jsx(ph,{...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()}})}),ph=b.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:i,...s}=e,a=Rr(Yn,r),d=b.useRef(null),u=Ze(t,d);return Ka(),c.jsxs(c.Fragment,{children:[c.jsx(qi,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:i,children:c.jsx(Ki,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":sc(a.open),...s,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),c.jsxs(c.Fragment,{children:[c.jsx(iN,{titleId:a.titleId}),c.jsx(aN,{contentRef:d,descriptionId:a.descriptionId})]})]})}),ic="DialogTitle",mh=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Rr(ic,r);return c.jsx($e.h2,{id:o.titleId,...n,ref:t})});mh.displayName=ic;var hh="DialogDescription",oN=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Rr(hh,r);return c.jsx($e.p,{id:o.descriptionId,...n,ref:t})});oN.displayName=hh;var gh="DialogClose",yh=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Rr(gh,r);return c.jsx($e.button,{type:"button",...n,ref:t,onClick:Le(e.onClick,()=>o.onOpenChange(!1))})});yh.displayName=gh;function sc(e){return e?"open":"closed"}var bh="DialogTitleWarning",[NO,vh]=Hv(bh,{contentName:Yn,titleName:ic,docsSlug:"dialog"}),iN=({titleId:e})=>{const t=vh(bh),r=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
41
|
+
`)},Px=0,ho=[];function Ox(e){var t=b.useRef([]),r=b.useRef([0,0]),n=b.useRef(),o=b.useState(Px++)[0],i=b.useState(hf)[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=ZS([e.lockRef.current],(e.shards||[]).map(xf),!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 w=ms(h),v=r.current,A="deltaX"in h?h.deltaX:v[0]-w[0],C="deltaY"in h?h.deltaY:v[1]-w[1],F,E=h.target,T=Math.abs(A)>Math.abs(C)?"h":"v";if("touches"in h&&T==="h"&&E.type==="range")return!1;var N=window.getSelection(),x=N&&N.anchorNode,O=x?x===E||x.contains(E):!1;if(O)return!1;var k=bf(T,E);if(!k)return!0;if(k?F=T:(F=T==="v"?"h":"v",k=bf(T,E)),!k)return!1;if(!n.current&&"changedTouches"in h&&(A||C)&&(n.current=F),!F)return!0;var D=n.current||F;return _x(D,y,h,D==="h"?A:C)},[]),d=b.useCallback(function(h){var y=h;if(!(!ho.length||ho[ho.length-1]!==i)){var w="deltaY"in y?Sf(y):ms(y),v=t.current.filter(function(F){return F.name===y.type&&(F.target===y.target||y.target===F.shadowParent)&&Tx(F.delta,w)})[0];if(v&&v.should){y.cancelable&&y.preventDefault();return}if(!v){var A=(s.current.shards||[]).map(xf).filter(Boolean).filter(function(F){return F.contains(y.target)}),C=A.length>0?a(y,A[0]):!s.current.noIsolation;C&&y.cancelable&&y.preventDefault()}}},[]),u=b.useCallback(function(h,y,w,v){var A={name:h,delta:y,target:w,should:v,shadowParent:Ix(w)};t.current.push(A),setTimeout(function(){t.current=t.current.filter(function(C){return C!==A})},1)},[]),l=b.useCallback(function(h){r.current=ms(h),n.current=void 0},[]),f=b.useCallback(function(h){u(h.type,Sf(h),h.target,a(h,e.lockRef.current))},[]),p=b.useCallback(function(h){u(h.type,ms(h),h.target,a(h,e.lockRef.current))},[]);b.useEffect(function(){return ho.push(i),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener("wheel",d,mo),document.addEventListener("touchmove",d,mo),document.addEventListener("touchstart",l,mo),function(){ho=ho.filter(function(h){return h!==i}),document.removeEventListener("wheel",d,mo),document.removeEventListener("touchmove",d,mo),document.removeEventListener("touchstart",l,mo)}},[]);var m=e.removeScrollBar,g=e.inert;return b.createElement(b.Fragment,null,g?b.createElement(i,{styles:Fx(o)}):null,m?b.createElement(Sx,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Ix(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Mx=lx(mf,Ox);var hs=b.forwardRef(function(e,t){return b.createElement(fs,rn({},e,{ref:t,sideCar:Mx}))});hs.classNames=fs.classNames;var Lx=[" ","Enter","ArrowUp","ArrowDown"],Dx=[" ","Enter"],Wn="Select",[gs,ys,Bx]=qa(Wn),[go]=xr(Wn,[Bx,ss]),bs=ss(),[$x,Tn]=go(Wn),[jx,zx]=go(Wn),Af=e=>{const{__scopeSelect:t,children:r,open:n,defaultOpen:o,onOpenChange:i,value:s,defaultValue:a,onValueChange:d,dir:u,name:l,autoComplete:f,disabled:p,required:m,form:g}=e,h=bs(t),[y,w]=b.useState(null),[v,A]=b.useState(null),[C,F]=b.useState(!1),E=so(u),[T,N]=tn({prop:n,defaultProp:o??!1,onChange:i,caller:Wn}),[x,O]=tn({prop:s,defaultProp:a,onChange:d,caller:Wn}),k=b.useRef(null),D=y?g||!!y.closest("form"):!0,[R,I]=b.useState(new Set),z=Array.from(R).map(L=>L.props.value).join(";");return c.jsx(sf,{...h,children:c.jsxs($x,{required:m,scope:t,trigger:y,onTriggerChange:w,valueNode:v,onValueNodeChange:A,valueNodeHasChildren:C,onValueNodeHasChildrenChange:F,contentId:cn(),value:x,onValueChange:O,open:T,onOpenChange:N,dir:E,triggerPointerDownPosRef:k,disabled:p,children:[c.jsx(gs.Provider,{scope:t,children:c.jsx(jx,{scope:e.__scopeSelect,onNativeOptionAdd:b.useCallback(L=>{I(B=>new Set(B).add(L))},[]),onNativeOptionRemove:b.useCallback(L=>{I(B=>{const M=new Set(B);return M.delete(L),M})},[]),children:r})}),D?c.jsxs(Rf,{"aria-hidden":!0,required:m,tabIndex:-1,name:l,autoComplete:f,value:x,onChange:L=>O(L.target.value),disabled:p,form:g,children:[x===void 0?c.jsx("option",{value:""}):null,Array.from(R)]},z):null]})})};Af.displayName=Wn;var Cf="SelectTrigger",Ef=b.forwardRef((e,t)=>{const{__scopeSelect:r,disabled:n=!1,...o}=e,i=bs(r),s=Tn(Cf,r),a=s.disabled||n,d=Ze(t,s.onTriggerChange),u=ys(r),l=b.useRef("touch"),[f,p,m]=Kf(h=>{const y=u().filter(A=>!A.disabled),w=y.find(A=>A.value===s.value),v=qf(y,h,w);v!==void 0&&s.onValueChange(v.value)}),g=h=>{a||(s.onOpenChange(!0),m()),h&&(s.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})};return c.jsx(ml,{asChild:!0,...i,children:c.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":Gf(s.value)?"":void 0,...o,ref:d,onClick:Le(o.onClick,h=>{h.currentTarget.focus(),l.current!=="mouse"&&g(h)}),onPointerDown:Le(o.onPointerDown,h=>{l.current=h.pointerType;const y=h.target;y.hasPointerCapture(h.pointerId)&&y.releasePointerCapture(h.pointerId),h.button===0&&h.ctrlKey===!1&&h.pointerType==="mouse"&&(g(h),h.preventDefault())}),onKeyDown:Le(o.onKeyDown,h=>{const y=f.current!=="";!(h.ctrlKey||h.altKey||h.metaKey)&&h.key.length===1&&p(h.key),!(y&&h.key===" ")&&Lx.includes(h.key)&&(g(),h.preventDefault())})})})});Ef.displayName=Cf;var Nf="SelectValue",kf=b.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,style:o,children:i,placeholder:s="",...a}=e,d=Tn(Nf,r),{onValueNodeHasChildrenChange:u}=d,l=i!==void 0,f=Ze(t,d.onValueNodeChange);return er(()=>{u(l)},[u,l]),c.jsx($e.span,{...a,ref:f,style:{pointerEvents:"none"},children:Gf(d.value)?c.jsx(c.Fragment,{children:s}):i})});kf.displayName=Nf;var Ux="SelectIcon",_f=b.forwardRef((e,t)=>{const{__scopeSelect:r,children:n,...o}=e;return c.jsx($e.span,{"aria-hidden":!0,...o,ref:t,children:n||"▼"})});_f.displayName=Ux;var Vx="SelectPortal",Tf=e=>c.jsx(as,{asChild:!0,...e});Tf.displayName=Vx;var Rn="SelectContent",Ff=b.forwardRef((e,t)=>{const r=Tn(Rn,e.__scopeSelect),[n,o]=b.useState();if(er(()=>{o(new DocumentFragment)},[]),!r.open){const i=n;return i?_i.createPortal(c.jsx(Pf,{scope:e.__scopeSelect,children:c.jsx(gs.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),i):null}return c.jsx(Of,{...e,ref:t})});Ff.displayName=Rn;var Vr=10,[Pf,Fn]=go(Rn),Hx="SelectContentImpl",Wx=jS("SelectContent.RemoveScroll"),Of=b.forwardRef((e,t)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:i,onPointerDownOutside:s,side:a,sideOffset:d,align:u,alignOffset:l,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:g,hideWhenDetached:h,avoidCollisions:y,...w}=e,v=Tn(Rn,r),[A,C]=b.useState(null),[F,E]=b.useState(null),T=Ze(t,q=>C(q)),[N,x]=b.useState(null),[O,k]=b.useState(null),D=ys(r),[R,I]=b.useState(!1),z=b.useRef(!1);b.useEffect(()=>{if(A)return gl(A)},[A]),Ja();const L=b.useCallback(q=>{const[ne,...Te]=D().map(he=>he.ref.current),[ee]=Te.slice(-1),te=document.activeElement;for(const he of q)if(he===te||(he?.scrollIntoView({block:"nearest"}),he===ne&&F&&(F.scrollTop=0),he===ee&&F&&(F.scrollTop=F.scrollHeight),he?.focus(),document.activeElement!==te))return},[D,F]),B=b.useCallback(()=>L([N,A]),[L,N,A]);b.useEffect(()=>{R&&B()},[R,B]);const{onOpenChange:M,triggerPointerDownPosRef:V}=v;b.useEffect(()=>{if(A){let q={x:0,y:0};const ne=ee=>{q={x:Math.abs(Math.round(ee.pageX)-(V.current?.x??0)),y:Math.abs(Math.round(ee.pageY)-(V.current?.y??0))}},Te=ee=>{q.x<=10&&q.y<=10?ee.preventDefault():A.contains(ee.target)||M(!1),document.removeEventListener("pointermove",ne),V.current=null};return V.current!==null&&(document.addEventListener("pointermove",ne),document.addEventListener("pointerup",Te,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ne),document.removeEventListener("pointerup",Te,{capture:!0})}}},[A,M,V]),b.useEffect(()=>{const q=()=>M(!1);return window.addEventListener("blur",q),window.addEventListener("resize",q),()=>{window.removeEventListener("blur",q),window.removeEventListener("resize",q)}},[M]);const[$,ie]=Kf(q=>{const ne=D().filter(te=>!te.disabled),Te=ne.find(te=>te.ref.current===document.activeElement),ee=qf(ne,q,Te);ee&&setTimeout(()=>ee.ref.current.focus())}),H=b.useCallback((q,ne,Te)=>{const ee=!z.current&&!Te;(v.value!==void 0&&v.value===ne||ee)&&(x(q),ee&&(z.current=!0))},[v.value]),K=b.useCallback(()=>A?.focus(),[A]),X=b.useCallback((q,ne,Te)=>{const ee=!z.current&&!Te;(v.value!==void 0&&v.value===ne||ee)&&k(q)},[v.value]),le=n==="popper"?Sl:If,re=le===Sl?{side:a,sideOffset:d,align:u,alignOffset:l,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:g,hideWhenDetached:h,avoidCollisions:y}:{};return c.jsx(Pf,{scope:r,content:A,viewport:F,onViewportChange:E,itemRefCallback:H,selectedItem:N,onItemLeave:K,itemTextRefCallback:X,focusSelectedItem:B,selectedItemText:O,position:n,isPositioned:R,searchRef:$,children:c.jsx(hs,{as:Wx,allowPinchZoom:!0,children:c.jsx(Yi,{asChild:!0,trapped:v.open,onMountAutoFocus:q=>{q.preventDefault()},onUnmountAutoFocus:Le(o,q=>{v.trigger?.focus({preventScroll:!0}),q.preventDefault()}),children:c.jsx(qi,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:q=>q.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:c.jsx(le,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:q=>q.preventDefault(),...w,...re,onPlaced:()=>I(!0),ref:T,style:{display:"flex",flexDirection:"column",outline:"none",...w.style},onKeyDown:Le(w.onKeyDown,q=>{const ne=q.ctrlKey||q.altKey||q.metaKey;if(q.key==="Tab"&&q.preventDefault(),!ne&&q.key.length===1&&ie(q.key),["ArrowUp","ArrowDown","Home","End"].includes(q.key)){let ee=D().filter(te=>!te.disabled).map(te=>te.ref.current);if(["ArrowUp","End"].includes(q.key)&&(ee=ee.slice().reverse()),["ArrowUp","ArrowDown"].includes(q.key)){const te=q.target,he=ee.indexOf(te);ee=ee.slice(he+1)}setTimeout(()=>L(ee)),q.preventDefault()}})})})})})})});Of.displayName=Hx;var Rx="SelectItemAlignedPosition",If=b.forwardRef((e,t)=>{const{__scopeSelect:r,onPlaced:n,...o}=e,i=Tn(Rn,r),s=Fn(Rn,r),[a,d]=b.useState(null),[u,l]=b.useState(null),f=Ze(t,T=>l(T)),p=ys(r),m=b.useRef(!1),g=b.useRef(!0),{viewport:h,selectedItem:y,selectedItemText:w,focusSelectedItem:v}=s,A=b.useCallback(()=>{if(i.trigger&&i.valueNode&&a&&u&&h&&y&&w){const T=i.trigger.getBoundingClientRect(),N=u.getBoundingClientRect(),x=i.valueNode.getBoundingClientRect(),O=w.getBoundingClientRect();if(i.dir!=="rtl"){const te=O.left-N.left,he=x.left-te,ce=T.left-he,Xe=T.width+ce,ge=Math.max(Xe,N.width),Se=window.innerWidth-Vr,ae=Jo(he,[Vr,Math.max(Vr,Se-ge)]);a.style.minWidth=Xe+"px",a.style.left=ae+"px"}else{const te=N.right-O.right,he=window.innerWidth-x.right-te,ce=window.innerWidth-T.right-he,Xe=T.width+ce,ge=Math.max(Xe,N.width),Se=window.innerWidth-Vr,ae=Jo(he,[Vr,Math.max(Vr,Se-ge)]);a.style.minWidth=Xe+"px",a.style.right=ae+"px"}const k=p(),D=window.innerHeight-Vr*2,R=h.scrollHeight,I=window.getComputedStyle(u),z=parseInt(I.borderTopWidth,10),L=parseInt(I.paddingTop,10),B=parseInt(I.borderBottomWidth,10),M=parseInt(I.paddingBottom,10),V=z+L+R+M+B,$=Math.min(y.offsetHeight*5,V),ie=window.getComputedStyle(h),H=parseInt(ie.paddingTop,10),K=parseInt(ie.paddingBottom,10),X=T.top+T.height/2-Vr,le=D-X,re=y.offsetHeight/2,q=y.offsetTop+re,ne=z+L+q,Te=V-ne;if(ne<=X){const te=k.length>0&&y===k[k.length-1].ref.current;a.style.bottom="0px";const he=u.clientHeight-h.offsetTop-h.offsetHeight,ce=Math.max(le,re+(te?K:0)+he+B),Xe=ne+ce;a.style.height=Xe+"px"}else{const te=k.length>0&&y===k[0].ref.current;a.style.top="0px";const ce=Math.max(X,z+h.offsetTop+(te?H:0)+re)+Te;a.style.height=ce+"px",h.scrollTop=ne-X+h.offsetTop}a.style.margin=`${Vr}px 0`,a.style.minHeight=$+"px",a.style.maxHeight=D+"px",n?.(),requestAnimationFrame(()=>m.current=!0)}},[p,i.trigger,i.valueNode,a,u,h,y,w,i.dir,n]);er(()=>A(),[A]);const[C,F]=b.useState();er(()=>{u&&F(window.getComputedStyle(u).zIndex)},[u]);const E=b.useCallback(T=>{T&&g.current===!0&&(A(),v?.(),g.current=!1)},[A,v]);return c.jsx(Kx,{scope:r,contentWrapper:a,shouldExpandOnScrollRef:m,onScrollButtonChange:E,children:c.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:C},children:c.jsx($e.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});If.displayName=Rx;var Gx="SelectPopperPosition",Sl=b.forwardRef((e,t)=>{const{__scopeSelect:r,align:n="start",collisionPadding:o=Vr,...i}=e,s=bs(r);return c.jsx(af,{...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)"}})});Sl.displayName=Gx;var[Kx,xl]=go(Rn,{}),Al="SelectViewport",Mf=b.forwardRef((e,t)=>{const{__scopeSelect:r,nonce:n,...o}=e,i=Fn(Al,r),s=xl(Al,r),a=Ze(t,i.onViewportChange),d=b.useRef(0);return c.jsxs(c.Fragment,{children:[c.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}),c.jsx(gs.Slot,{scope:r,children:c.jsx($e.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Le(o.onScroll,u=>{const l=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:p}=s;if(p?.current&&f){const m=Math.abs(d.current-l.scrollTop);if(m>0){const g=window.innerHeight-Vr*2,h=parseFloat(f.style.minHeight),y=parseFloat(f.style.height),w=Math.max(h,y);if(w<g){const v=w+m,A=Math.min(g,v),C=v-A;f.style.height=A+"px",f.style.bottom==="0px"&&(l.scrollTop=C>0?C:0,f.style.justifyContent="flex-end")}}}d.current=l.scrollTop})})})]})});Mf.displayName=Al;var Lf="SelectGroup",[qx,Yx]=go(Lf),Xx=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=cn();return c.jsx(qx,{scope:r,id:o,children:c.jsx($e.div,{role:"group","aria-labelledby":o,...n,ref:t})})});Xx.displayName=Lf;var Df="SelectLabel",Jx=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=Yx(Df,r);return c.jsx($e.div,{id:o.id,...n,ref:t})});Jx.displayName=Df;var vs="SelectItem",[Qx,Bf]=go(vs),$f=b.forwardRef((e,t)=>{const{__scopeSelect:r,value:n,disabled:o=!1,textValue:i,...s}=e,a=Tn(vs,r),d=Fn(vs,r),u=a.value===n,[l,f]=b.useState(i??""),[p,m]=b.useState(!1),g=Ze(t,v=>d.itemRefCallback?.(v,n,o)),h=cn(),y=b.useRef("touch"),w=()=>{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 c.jsx(Qx,{scope:r,value:n,disabled:o,textId:h,isSelected:u,onItemTextChange:b.useCallback(v=>{f(A=>A||(v?.textContent??"").trim())},[]),children:c.jsx(gs.ItemSlot,{scope:r,value:n,disabled:o,textValue:l,children:c.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:g,onFocus:Le(s.onFocus,()=>m(!0)),onBlur:Le(s.onBlur,()=>m(!1)),onClick:Le(s.onClick,()=>{y.current!=="mouse"&&w()}),onPointerUp:Le(s.onPointerUp,()=>{y.current==="mouse"&&w()}),onPointerDown:Le(s.onPointerDown,v=>{y.current=v.pointerType}),onPointerMove:Le(s.onPointerMove,v=>{y.current=v.pointerType,o?d.onItemLeave?.():y.current==="mouse"&&v.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Le(s.onPointerLeave,v=>{v.currentTarget===document.activeElement&&d.onItemLeave?.()}),onKeyDown:Le(s.onKeyDown,v=>{d.searchRef?.current!==""&&v.key===" "||(Dx.includes(v.key)&&w(),v.key===" "&&v.preventDefault())})})})})});$f.displayName=vs;var ri="SelectItemText",jf=b.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,style:o,...i}=e,s=Tn(ri,r),a=Fn(ri,r),d=Bf(ri,r),u=zx(ri,r),[l,f]=b.useState(null),p=Ze(t,w=>f(w),d.onItemTextChange,w=>a.itemTextRefCallback?.(w,d.value,d.disabled)),m=l?.textContent,g=b.useMemo(()=>c.jsx("option",{value:d.value,disabled:d.disabled,children:m},d.value),[d.disabled,d.value,m]),{onNativeOptionAdd:h,onNativeOptionRemove:y}=u;return er(()=>(h(g),()=>y(g)),[h,y,g]),c.jsxs(c.Fragment,{children:[c.jsx($e.span,{id:d.textId,...i,ref:p}),d.isSelected&&s.valueNode&&!s.valueNodeHasChildren?_i.createPortal(i.children,s.valueNode):null]})});jf.displayName=ri;var zf="SelectItemIndicator",Uf=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return Bf(zf,r).isSelected?c.jsx($e.span,{"aria-hidden":!0,...n,ref:t}):null});Uf.displayName=zf;var Cl="SelectScrollUpButton",Vf=b.forwardRef((e,t)=>{const r=Fn(Cl,e.__scopeSelect),n=xl(Cl,e.__scopeSelect),[o,i]=b.useState(!1),s=Ze(t,n.onScrollButtonChange);return er(()=>{if(r.viewport&&r.isPositioned){let a=function(){const u=d.scrollTop>0;i(u)};const d=r.viewport;return a(),d.addEventListener("scroll",a),()=>d.removeEventListener("scroll",a)}},[r.viewport,r.isPositioned]),o?c.jsx(Wf,{...e,ref:s,onAutoScroll:()=>{const{viewport:a,selectedItem:d}=r;a&&d&&(a.scrollTop=a.scrollTop-d.offsetHeight)}}):null});Vf.displayName=Cl;var El="SelectScrollDownButton",Hf=b.forwardRef((e,t)=>{const r=Fn(El,e.__scopeSelect),n=xl(El,e.__scopeSelect),[o,i]=b.useState(!1),s=Ze(t,n.onScrollButtonChange);return er(()=>{if(r.viewport&&r.isPositioned){let a=function(){const u=d.scrollHeight-d.clientHeight,l=Math.ceil(d.scrollTop)<u;i(l)};const d=r.viewport;return a(),d.addEventListener("scroll",a),()=>d.removeEventListener("scroll",a)}},[r.viewport,r.isPositioned]),o?c.jsx(Wf,{...e,ref:s,onAutoScroll:()=>{const{viewport:a,selectedItem:d}=r;a&&d&&(a.scrollTop=a.scrollTop+d.offsetHeight)}}):null});Hf.displayName=El;var Wf=b.forwardRef((e,t)=>{const{__scopeSelect:r,onAutoScroll:n,...o}=e,i=Fn("SelectScrollButton",r),s=b.useRef(null),a=ys(r),d=b.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return b.useEffect(()=>()=>d(),[d]),er(()=>{a().find(l=>l.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[a]),c.jsx($e.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:Le(o.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(n,50))}),onPointerMove:Le(o.onPointerMove,()=>{i.onItemLeave?.(),s.current===null&&(s.current=window.setInterval(n,50))}),onPointerLeave:Le(o.onPointerLeave,()=>{d()})})}),Zx="SelectSeparator",e0=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return c.jsx($e.div,{"aria-hidden":!0,...n,ref:t})});e0.displayName=Zx;var Nl="SelectArrow",t0=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=bs(r),i=Tn(Nl,r),s=Fn(Nl,r);return i.open&&s.position==="popper"?c.jsx(lf,{...o,...n,ref:t}):null});t0.displayName=Nl;var r0="SelectBubbleInput",Rf=b.forwardRef(({__scopeSelect:e,value:t,...r},n)=>{const o=b.useRef(null),i=Ze(n,o),s=ti(t);return b.useEffect(()=>{const a=o.current;if(!a)return;const d=window.HTMLSelectElement.prototype,l=Object.getOwnPropertyDescriptor(d,"value").set;if(s!==t&&l){const f=new Event("change",{bubbles:!0});l.call(a,t),a.dispatchEvent(f)}},[s,t]),c.jsx($e.select,{...r,style:{...cf,...r.style},ref:i,defaultValue:t})});Rf.displayName=r0;function Gf(e){return e===""||e===void 0}function Kf(e){const t=ar(e),r=b.useRef(""),n=b.useRef(0),o=b.useCallback(s=>{const a=r.current+s;t(a),(function d(u){r.current=u,window.clearTimeout(n.current),u!==""&&(n.current=window.setTimeout(()=>d(""),1e3))})(a)},[t]),i=b.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,o,i]}function qf(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=n0(e,Math.max(i,0));o.length===1&&(s=s.filter(u=>u!==r));const d=s.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return d!==r?d:void 0}function n0(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var o0=Af,i0=Ef,s0=kf,a0=_f,l0=Tf,c0=Ff,d0=Mf,u0=$f,f0=jf,p0=Uf,m0=Vf,h0=Hf;function g0({...e}){return c.jsx(o0,{"data-slot":"select",...e})}function y0({className:e,...t}){return c.jsx(s0,{"data-slot":"select-value",className:j("truncate min-w-0",e),...t})}function b0({className:e,size:t="default",children:r,...n}){const o=e?.includes("w-full");return c.jsxs(i0,{"data-slot":"select-trigger","data-size":t,className:j("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,c.jsx(a0,{asChild:!0,children:c.jsx(qo,{className:"size-4 opacity-50"})})]})}function v0({className:e,children:t,position:r="popper",...n}){return c.jsx(l0,{children:c.jsxs(c0,{"data-slot":"select-content",className:j("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:[c.jsx(w0,{}),c.jsx(d0,{className:j("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),c.jsx(S0,{})]})})}function kl({className:e,children:t,...r}){return c.jsxs(u0,{"data-slot":"select-item",className:j("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:[c.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:c.jsx(p0,{children:c.jsx(Gi,{className:"size-4"})})}),c.jsx(f0,{className:"truncate",children:t})]})}function w0({className:e,...t}){return c.jsx(m0,{"data-slot":"select-scroll-up-button",className:j("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(Uv,{className:"size-4"})})}function S0({className:e,...t}){return c.jsx(h0,{"data-slot":"select-scroll-down-button",className:j("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(qo,{className:"size-4"})})}function Yf(e,t){return function(){return e.apply(t,arguments)}}const{toString:x0}=Object.prototype,{getPrototypeOf:_l}=Object,{iterator:ws,toStringTag:Xf}=Symbol,Ss=(e=>t=>{const r=x0.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),Hr=e=>(e=e.toLowerCase(),t=>Ss(t)===e),xs=e=>t=>typeof t===e,{isArray:yo}=Array,bo=xs("undefined");function ni(e){return e!==null&&!bo(e)&&e.constructor!==null&&!bo(e.constructor)&&mr(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Jf=Hr("ArrayBuffer");function A0(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Jf(e.buffer),t}const C0=xs("string"),mr=xs("function"),Qf=xs("number"),oi=e=>e!==null&&typeof e=="object",E0=e=>e===!0||e===!1,As=e=>{if(Ss(e)!=="object")return!1;const t=_l(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Xf in e)&&!(ws in e)},N0=e=>{if(!oi(e)||ni(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},k0=Hr("Date"),_0=Hr("File"),T0=e=>!!(e&&typeof e.uri<"u"),F0=e=>e&&typeof e.getParts<"u",P0=Hr("Blob"),O0=Hr("FileList"),I0=e=>oi(e)&&mr(e.pipe);function M0(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const Zf=M0(),ep=typeof Zf.FormData<"u"?Zf.FormData:void 0,L0=e=>{let t;return e&&(ep&&e instanceof ep||mr(e.append)&&((t=Ss(e))==="formdata"||t==="object"&&mr(e.toString)&&e.toString()==="[object FormData]"))},D0=Hr("URLSearchParams"),[B0,$0,j0,z0]=["ReadableStream","Request","Response","Headers"].map(Hr),U0=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ii(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,o;if(typeof e!="object"&&(e=[e]),yo(e))for(n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else{if(ni(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 tp(e,t){if(ni(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 Gn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,rp=e=>!bo(e)&&e!==Gn;function Tl(){const{caseless:e,skipUndefined:t}=rp(this)&&this||{},r={},n=(o,i)=>{if(i==="__proto__"||i==="constructor"||i==="prototype")return;const s=e&&tp(r,i)||i;As(r[s])&&As(o)?r[s]=Tl(r[s],o):As(o)?r[s]=Tl({},o):yo(o)?r[s]=o.slice():(!t||!bo(o))&&(r[s]=o)};for(let o=0,i=arguments.length;o<i;o++)arguments[o]&&ii(arguments[o],n);return r}const V0=(e,t,r,{allOwnKeys:n}={})=>(ii(t,(o,i)=>{r&&mr(o)?Object.defineProperty(e,i,{value:Yf(o,r),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,i,{value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:n}),e),H0=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),W0=(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)},R0=(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&&_l(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},G0=(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},K0=e=>{if(!e)return null;if(yo(e))return e;let t=e.length;if(!Qf(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},q0=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&_l(Uint8Array)),Y0=(e,t)=>{const n=(e&&e[ws]).call(e);let o;for(;(o=n.next())&&!o.done;){const i=o.value;t.call(e,i[0],i[1])}},X0=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},J0=Hr("HTMLFormElement"),Q0=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,o){return n.toUpperCase()+o}),np=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),Z0=Hr("RegExp"),op=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};ii(r,(o,i)=>{let s;(s=t(o,i,e))!==!1&&(n[i]=s||o)}),Object.defineProperties(e,n)},eA=e=>{op(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+"'")})}})},tA=(e,t)=>{const r={},n=o=>{o.forEach(i=>{r[i]=!0})};return yo(e)?n(e):n(String(e).split(t)),r},rA=()=>{},nA=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function oA(e){return!!(e&&mr(e.append)&&e[Xf]==="FormData"&&e[ws])}const iA=e=>{const t=new Array(10),r=(n,o)=>{if(oi(n)){if(t.indexOf(n)>=0)return;if(ni(n))return n;if(!("toJSON"in n)){t[o]=n;const i=yo(n)?[]:{};return ii(n,(s,a)=>{const d=r(s,o+1);!bo(d)&&(i[a]=d)}),t[o]=void 0,i}}return n};return r(e,0)},sA=Hr("AsyncFunction"),aA=e=>e&&(oi(e)||mr(e))&&mr(e.then)&&mr(e.catch),ip=((e,t)=>e?setImmediate:t?((r,n)=>(Gn.addEventListener("message",({source:o,data:i})=>{o===Gn&&i===r&&n.length&&n.shift()()},!1),o=>{n.push(o),Gn.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",mr(Gn.postMessage)),lA=typeof queueMicrotask<"u"?queueMicrotask.bind(Gn):typeof process<"u"&&process.nextTick||ip,G={isArray:yo,isArrayBuffer:Jf,isBuffer:ni,isFormData:L0,isArrayBufferView:A0,isString:C0,isNumber:Qf,isBoolean:E0,isObject:oi,isPlainObject:As,isEmptyObject:N0,isReadableStream:B0,isRequest:$0,isResponse:j0,isHeaders:z0,isUndefined:bo,isDate:k0,isFile:_0,isReactNativeBlob:T0,isReactNative:F0,isBlob:P0,isRegExp:Z0,isFunction:mr,isStream:I0,isURLSearchParams:D0,isTypedArray:q0,isFileList:O0,forEach:ii,merge:Tl,extend:V0,trim:U0,stripBOM:H0,inherits:W0,toFlatObject:R0,kindOf:Ss,kindOfTest:Hr,endsWith:G0,toArray:K0,forEachEntry:Y0,matchAll:X0,isHTMLForm:J0,hasOwnProperty:np,hasOwnProp:np,reduceDescriptors:op,freezeMethods:eA,toObjectSet:tA,toCamelCase:Q0,noop:rA,toFiniteNumber:nA,findKey:tp,global:Gn,isContextDefined:rp,isSpecCompliantForm:oA,toJSONObject:iA,isAsyncFn:sA,isThenable:aA,setImmediate:ip,asap:lA,isIterable:e=>e!=null&&mr(e[ws])};let Ye=class Ry extends Error{static from(t,r,n,o,i,s){const a=new Ry(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:G.toJSONObject(this.config),code:this.code,status:this.status}}};Ye.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",Ye.ERR_BAD_OPTION="ERR_BAD_OPTION",Ye.ECONNABORTED="ECONNABORTED",Ye.ETIMEDOUT="ETIMEDOUT",Ye.ERR_NETWORK="ERR_NETWORK",Ye.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",Ye.ERR_DEPRECATED="ERR_DEPRECATED",Ye.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",Ye.ERR_BAD_REQUEST="ERR_BAD_REQUEST",Ye.ERR_CANCELED="ERR_CANCELED",Ye.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",Ye.ERR_INVALID_URL="ERR_INVALID_URL";const cA=null;function Fl(e){return G.isPlainObject(e)||G.isArray(e)}function sp(e){return G.endsWith(e,"[]")?e.slice(0,-2):e}function Pl(e,t,r){return e?e.concat(t).map(function(o,i){return o=sp(o),!r&&i?"["+o+"]":o}).join(r?".":""):t}function dA(e){return G.isArray(e)&&!e.some(Fl)}const uA=G.toFlatObject(G,{},null,function(t){return/^is[A-Z]/.test(t)});function Cs(e,t,r){if(!G.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=G.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,y){return!G.isUndefined(y[h])});const n=r.metaTokens,o=r.visitor||l,i=r.dots,s=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&G.isSpecCompliantForm(t);if(!G.isFunction(o))throw new TypeError("visitor must be a function");function u(g){if(g===null)return"";if(G.isDate(g))return g.toISOString();if(G.isBoolean(g))return g.toString();if(!d&&G.isBlob(g))throw new Ye("Blob is not supported. Use a Buffer instead.");return G.isArrayBuffer(g)||G.isTypedArray(g)?d&&typeof Blob=="function"?new Blob([g]):Buffer.from(g):g}function l(g,h,y){let w=g;if(G.isReactNative(t)&&G.isReactNativeBlob(g))return t.append(Pl(y,h,i),u(g)),!1;if(g&&!y&&typeof g=="object"){if(G.endsWith(h,"{}"))h=n?h:h.slice(0,-2),g=JSON.stringify(g);else if(G.isArray(g)&&dA(g)||(G.isFileList(g)||G.endsWith(h,"[]"))&&(w=G.toArray(g)))return h=sp(h),w.forEach(function(A,C){!(G.isUndefined(A)||A===null)&&t.append(s===!0?Pl([h],C,i):s===null?h:h+"[]",u(A))}),!1}return Fl(g)?!0:(t.append(Pl(y,h,i),u(g)),!1)}const f=[],p=Object.assign(uA,{defaultVisitor:l,convertValue:u,isVisitable:Fl});function m(g,h){if(!G.isUndefined(g)){if(f.indexOf(g)!==-1)throw Error("Circular reference detected in "+h.join("."));f.push(g),G.forEach(g,function(w,v){(!(G.isUndefined(w)||w===null)&&o.call(t,w,G.isString(v)?v.trim():v,h,p))===!0&&m(w,h?h.concat(v):[v])}),f.pop()}}if(!G.isObject(e))throw new TypeError("data must be an object");return m(e),t}function ap(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function Ol(e,t){this._pairs=[],e&&Cs(e,this,t)}const lp=Ol.prototype;lp.append=function(t,r){this._pairs.push([t,r])},lp.toString=function(t){const r=t?function(n){return t.call(this,n,ap)}:ap;return this._pairs.map(function(o){return r(o[0])+"="+r(o[1])},"").join("&")};function fA(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function cp(e,t,r){if(!t)return e;const n=r&&r.encode||fA,o=G.isFunction(r)?{serialize:r}:r,i=o&&o.serialize;let s;if(i?s=i(t,o):s=G.isURLSearchParams(t)?t.toString():new Ol(t,o).toString(n),s){const a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class dp{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){G.forEach(this.handlers,function(n){n!==null&&t(n)})}}const Il={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},pA={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ol,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ml=typeof window<"u"&&typeof document<"u",Ll=typeof navigator=="object"&&navigator||void 0,mA=Ml&&(!Ll||["ReactNative","NativeScript","NS"].indexOf(Ll.product)<0),hA=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",gA=Ml&&window.location.href||"http://localhost",ir={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ml,hasStandardBrowserEnv:mA,hasStandardBrowserWebWorkerEnv:hA,navigator:Ll,origin:gA},Symbol.toStringTag,{value:"Module"})),...pA};function yA(e,t){return Cs(e,new ir.classes.URLSearchParams,{visitor:function(r,n,o,i){return ir.isNode&&G.isBuffer(r)?(this.append(n,r.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...t})}function bA(e){return G.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function vA(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 up(e){function t(r,n,o,i){let s=r[i++];if(s==="__proto__")return!0;const a=Number.isFinite(+s),d=i>=r.length;return s=!s&&G.isArray(o)?o.length:s,d?(G.hasOwnProp(o,s)?o[s]=[o[s],n]:o[s]=n,!a):((!o[s]||!G.isObject(o[s]))&&(o[s]=[]),t(r,n,o[s],i)&&G.isArray(o[s])&&(o[s]=vA(o[s])),!a)}if(G.isFormData(e)&&G.isFunction(e.entries)){const r={};return G.forEachEntry(e,(n,o)=>{t(bA(n),o,r,0)}),r}return null}function wA(e,t,r){if(G.isString(e))try{return(t||JSON.parse)(e),G.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}const si={transitional:Il,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){const n=r.getContentType()||"",o=n.indexOf("application/json")>-1,i=G.isObject(t);if(i&&G.isHTMLForm(t)&&(t=new FormData(t)),G.isFormData(t))return o?JSON.stringify(up(t)):t;if(G.isArrayBuffer(t)||G.isBuffer(t)||G.isStream(t)||G.isFile(t)||G.isBlob(t)||G.isReadableStream(t))return t;if(G.isArrayBufferView(t))return t.buffer;if(G.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 yA(t,this.formSerializer).toString();if((a=G.isFileList(t))||n.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return Cs(a?{"files[]":t}:t,d&&new d,this.formSerializer)}}return i||o?(r.setContentType("application/json",!1),wA(t)):t}],transformResponse:[function(t){const r=this.transitional||si.transitional,n=r&&r.forcedJSONParsing,o=this.responseType==="json";if(G.isResponse(t)||G.isReadableStream(t))return t;if(t&&G.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"?Ye.from(a,Ye.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}}};G.forEach(["delete","get","head","post","put","patch"],e=>{si.headers[e]={}});const SA=G.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"]),xA=e=>{const t={};let r,n,o;return e&&e.split(`
|
|
42
|
+
`).forEach(function(s){o=s.indexOf(":"),r=s.substring(0,o).trim().toLowerCase(),n=s.substring(o+1).trim(),!(!r||t[r]&&SA[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t},fp=Symbol("internals");function ai(e){return e&&String(e).trim().toLowerCase()}function Es(e){return e===!1||e==null?e:G.isArray(e)?e.map(Es):String(e).replace(/[\r\n]+$/,"")}function AA(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 CA=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Dl(e,t,r,n,o){if(G.isFunction(n))return n.call(this,t,r);if(o&&(t=r),!!G.isString(t)){if(G.isString(n))return t.indexOf(n)!==-1;if(G.isRegExp(n))return n.test(t)}}function EA(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function NA(e,t){const r=G.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,d,u){const l=ai(d);if(!l)throw new Error("header name must be a non-empty string");const f=G.findKey(o,l);(!f||o[f]===void 0||u===!0||u===void 0&&o[f]!==!1)&&(o[f||d]=Es(a))}const s=(a,d)=>G.forEach(a,(u,l)=>i(u,l,d));if(G.isPlainObject(t)||t instanceof this.constructor)s(t,r);else if(G.isString(t)&&(t=t.trim())&&!CA(t))s(xA(t),r);else if(G.isObject(t)&&G.isIterable(t)){let a={},d,u;for(const l of t){if(!G.isArray(l))throw TypeError("Object iterator must return a key-value pair");a[u=l[0]]=(d=a[u])?G.isArray(d)?[...d,l[1]]:[d,l[1]]:l[1]}s(a,r)}else t!=null&&i(r,t,n);return this}get(t,r){if(t=ai(t),t){const n=G.findKey(this,t);if(n){const o=this[n];if(!r)return o;if(r===!0)return AA(o);if(G.isFunction(r))return r.call(this,o,n);if(G.isRegExp(r))return r.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=ai(t),t){const n=G.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||Dl(this,this[n],n,r)))}return!1}delete(t,r){const n=this;let o=!1;function i(s){if(s=ai(s),s){const a=G.findKey(n,s);a&&(!r||Dl(n,n[a],a,r))&&(delete n[a],o=!0)}}return G.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||Dl(this,this[i],i,t,!0))&&(delete this[i],o=!0)}return o}normalize(t){const r=this,n={};return G.forEach(this,(o,i)=>{const s=G.findKey(n,i);if(s){r[s]=Es(o),delete r[i];return}const a=t?EA(i):String(i).trim();a!==i&&delete r[i],r[a]=Es(o),n[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return G.forEach(this,(n,o)=>{n!=null&&n!==!1&&(r[o]=t&&G.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(`
|
|
43
|
+
`)}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[fp]=this[fp]={accessors:{}}).accessors,o=this.prototype;function i(s){const a=ai(s);n[a]||(NA(o,s),n[a]=!0)}return G.isArray(t)?t.forEach(i):i(t),this}};hr.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),G.reduceDescriptors(hr.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}}),G.freezeMethods(hr);function Bl(e,t){const r=this||si,n=t||r,o=hr.from(n.headers);let i=n.data;return G.forEach(e,function(a){i=a.call(r,i,o.normalize(),t?t.status:void 0)}),o.normalize(),i}function pp(e){return!!(e&&e.__CANCEL__)}let li=class extends Ye{constructor(t,r,n){super(t??"canceled",Ye.ERR_CANCELED,r,n),this.name="CanceledError",this.__CANCEL__=!0}};function mp(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new Ye("Request failed with status code "+r.status,[Ye.ERR_BAD_REQUEST,Ye.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function kA(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function _A(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(d){const u=Date.now(),l=n[i];s||(s=u),r[o]=d,n[o]=u;let f=i,p=0;for(;f!==o;)p+=r[f++],f=f%e;if(o=(o+1)%e,o===i&&(i=(i+1)%e),u-s<t)return;const m=l&&u-l;return m?Math.round(p*1e3/m):void 0}}function TA(e,t){let r=0,n=1e3/t,o,i;const s=(u,l=Date.now())=>{r=l,o=null,i&&(clearTimeout(i),i=null),e(...u)};return[(...u)=>{const l=Date.now(),f=l-r;f>=n?s(u,l):(o=u,i||(i=setTimeout(()=>{i=null,s(o)},n-f)))},()=>o&&s(o)]}const Ns=(e,t,r=3)=>{let n=0;const o=_A(50,250);return TA(i=>{const s=i.loaded,a=i.lengthComputable?i.total:void 0,d=s-n,u=o(d),l=s<=a;n=s;const f={loaded:s,total:a,progress:a?s/a:void 0,bytes:d,rate:u||void 0,estimated:u&&a&&l?(a-s)/u:void 0,event:i,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},r)},hp=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},gp=e=>(...t)=>G.asap(()=>e(...t)),FA=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,PA=ir.hasStandardBrowserEnv?{write(e,t,r,n,o,i,s){if(typeof document>"u")return;const a=[`${e}=${encodeURIComponent(t)}`];G.isNumber(r)&&a.push(`expires=${new Date(r).toUTCString()}`),G.isString(n)&&a.push(`path=${n}`),G.isString(o)&&a.push(`domain=${o}`),i===!0&&a.push("secure"),G.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 OA(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function IA(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function yp(e,t,r){let n=!OA(t);return e&&(n||r==!1)?IA(e,t):t}const bp=e=>e instanceof hr?{...e}:e;function Kn(e,t){t=t||{};const r={};function n(u,l,f,p){return G.isPlainObject(u)&&G.isPlainObject(l)?G.merge.call({caseless:p},u,l):G.isPlainObject(l)?G.merge({},l):G.isArray(l)?l.slice():l}function o(u,l,f,p){if(G.isUndefined(l)){if(!G.isUndefined(u))return n(void 0,u,f,p)}else return n(u,l,f,p)}function i(u,l){if(!G.isUndefined(l))return n(void 0,l)}function s(u,l){if(G.isUndefined(l)){if(!G.isUndefined(u))return n(void 0,u)}else return n(void 0,l)}function a(u,l,f){if(f in t)return n(u,l);if(f in e)return n(void 0,u)}const d={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,l,f)=>o(bp(u),bp(l),f,!0)};return G.forEach(Object.keys({...e,...t}),function(l){if(l==="__proto__"||l==="constructor"||l==="prototype")return;const f=G.hasOwnProp(d,l)?d[l]:o,p=f(e[l],t[l],l);G.isUndefined(p)&&f!==a||(r[l]=p)}),r}const vp=e=>{const t=Kn({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:o,xsrfCookieName:i,headers:s,auth:a}=t;if(t.headers=s=hr.from(s),t.url=cp(yp(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),G.isFormData(r)){if(ir.hasStandardBrowserEnv||ir.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if(G.isFunction(r.getHeaders)){const d=r.getHeaders(),u=["content-type","content-length"];Object.entries(d).forEach(([l,f])=>{u.includes(l.toLowerCase())&&s.set(l,f)})}}if(ir.hasStandardBrowserEnv&&(n&&G.isFunction(n)&&(n=n(t)),n||n!==!1&&FA(t.url))){const d=o&&i&&PA.read(i);d&&s.set(o,d)}return t},MA=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(r,n){const o=vp(e);let i=o.data;const s=hr.from(o.headers).normalize();let{responseType:a,onUploadProgress:d,onDownloadProgress:u}=o,l,f,p,m,g;function h(){m&&m(),g&&g(),o.cancelToken&&o.cancelToken.unsubscribe(l),o.signal&&o.signal.removeEventListener("abort",l)}let y=new XMLHttpRequest;y.open(o.method.toUpperCase(),o.url,!0),y.timeout=o.timeout;function w(){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};mp(function(T){r(T),h()},function(T){n(T),h()},F),y=null}"onloadend"in y?y.onloadend=w:y.onreadystatechange=function(){!y||y.readyState!==4||y.status===0&&!(y.responseURL&&y.responseURL.indexOf("file:")===0)||setTimeout(w)},y.onabort=function(){y&&(n(new Ye("Request aborted",Ye.ECONNABORTED,e,y)),y=null)},y.onerror=function(C){const F=C&&C.message?C.message:"Network Error",E=new Ye(F,Ye.ERR_NETWORK,e,y);E.event=C||null,n(E),y=null},y.ontimeout=function(){let C=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const F=o.transitional||Il;o.timeoutErrorMessage&&(C=o.timeoutErrorMessage),n(new Ye(C,F.clarifyTimeoutError?Ye.ETIMEDOUT:Ye.ECONNABORTED,e,y)),y=null},i===void 0&&s.setContentType(null),"setRequestHeader"in y&&G.forEach(s.toJSON(),function(C,F){y.setRequestHeader(F,C)}),G.isUndefined(o.withCredentials)||(y.withCredentials=!!o.withCredentials),a&&a!=="json"&&(y.responseType=o.responseType),u&&([p,g]=Ns(u,!0),y.addEventListener("progress",p)),d&&y.upload&&([f,m]=Ns(d),y.upload.addEventListener("progress",f),y.upload.addEventListener("loadend",m)),(o.cancelToken||o.signal)&&(l=A=>{y&&(n(!A||A.type?new li(null,e,y):A),y.abort(),y=null)},o.cancelToken&&o.cancelToken.subscribe(l),o.signal&&(o.signal.aborted?l():o.signal.addEventListener("abort",l)));const v=kA(o.url);if(v&&ir.protocols.indexOf(v)===-1){n(new Ye("Unsupported protocol "+v+":",Ye.ERR_BAD_REQUEST,e));return}y.send(i||null)})},LA=(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 l=u instanceof Error?u:this.reason;n.abort(l instanceof Ye?l:new li(l instanceof Error?l.message:l))}};let s=t&&setTimeout(()=>{s=null,i(new Ye(`timeout of ${t}ms exceeded`,Ye.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:d}=n;return d.unsubscribe=()=>G.asap(a),d}},DA=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},BA=async function*(e,t){for await(const r of $A(e))yield*DA(r,t)},$A=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()}},wp=(e,t,r,n)=>{const o=BA(e,t);let i=0,s,a=d=>{s||(s=!0,n&&n(d))};return new ReadableStream({async pull(d){try{const{done:u,value:l}=await o.next();if(u){a(),d.close();return}let f=l.byteLength;if(r){let p=i+=f;r(p)}d.enqueue(new Uint8Array(l))}catch(u){throw a(u),u}},cancel(d){return a(d),o.return()}},{highWaterMark:2})},Sp=64*1024,{isFunction:ks}=G,jA=(({Request:e,Response:t})=>({Request:e,Response:t}))(G.global),{ReadableStream:xp,TextEncoder:Ap}=G.global,Cp=(e,...t)=>{try{return!!e(...t)}catch{return!1}},zA=e=>{e=G.merge.call({skipUndefined:!0},jA,e);const{fetch:t,Request:r,Response:n}=e,o=t?ks(t):typeof fetch=="function",i=ks(r),s=ks(n);if(!o)return!1;const a=o&&ks(xp),d=o&&(typeof Ap=="function"?(g=>h=>g.encode(h))(new Ap):async g=>new Uint8Array(await new r(g).arrayBuffer())),u=i&&a&&Cp(()=>{let g=!1;const h=new xp,y=new r(ir.origin,{body:h,method:"POST",get duplex(){return g=!0,"half"}}).headers.has("Content-Type");return h.cancel(),g&&!y}),l=s&&a&&Cp(()=>G.isReadableStream(new n("").body)),f={stream:l&&(g=>g.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(g=>{!f[g]&&(f[g]=(h,y)=>{let w=h&&h[g];if(w)return w.call(h);throw new Ye(`Response type '${g}' is not supported`,Ye.ERR_NOT_SUPPORT,y)})});const p=async g=>{if(g==null)return 0;if(G.isBlob(g))return g.size;if(G.isSpecCompliantForm(g))return(await new r(ir.origin,{method:"POST",body:g}).arrayBuffer()).byteLength;if(G.isArrayBufferView(g)||G.isArrayBuffer(g))return g.byteLength;if(G.isURLSearchParams(g)&&(g=g+""),G.isString(g))return(await d(g)).byteLength},m=async(g,h)=>{const y=G.toFiniteNumber(g.getContentLength());return y??p(h)};return async g=>{let{url:h,method:y,data:w,signal:v,cancelToken:A,timeout:C,onDownloadProgress:F,onUploadProgress:E,responseType:T,headers:N,withCredentials:x="same-origin",fetchOptions:O}=vp(g),k=t||fetch;T=T?(T+"").toLowerCase():"text";let D=LA([v,A&&A.toAbortSignal()],C),R=null;const I=D&&D.unsubscribe&&(()=>{D.unsubscribe()});let z;try{if(E&&u&&y!=="get"&&y!=="head"&&(z=await m(N,w))!==0){let ie=new r(h,{method:"POST",body:w,duplex:"half"}),H;if(G.isFormData(w)&&(H=ie.headers.get("content-type"))&&N.setContentType(H),ie.body){const[K,X]=hp(z,Ns(gp(E)));w=wp(ie.body,Sp,K,X)}}G.isString(x)||(x=x?"include":"omit");const L=i&&"credentials"in r.prototype,B={...O,signal:D,method:y.toUpperCase(),headers:N.normalize().toJSON(),body:w,duplex:"half",credentials:L?x:void 0};R=i&&new r(h,B);let M=await(i?k(R,O):k(h,B));const V=l&&(T==="stream"||T==="response");if(l&&(F||V&&I)){const ie={};["status","statusText","headers"].forEach(le=>{ie[le]=M[le]});const H=G.toFiniteNumber(M.headers.get("content-length")),[K,X]=F&&hp(H,Ns(gp(F),!0))||[];M=new n(wp(M.body,Sp,K,()=>{X&&X(),I&&I()}),ie)}T=T||"text";let $=await f[G.findKey(f,T)||"text"](M,g);return!V&&I&&I(),await new Promise((ie,H)=>{mp(ie,H,{data:$,headers:hr.from(M.headers),status:M.status,statusText:M.statusText,config:g,request:R})})}catch(L){throw I&&I(),L&&L.name==="TypeError"&&/Load failed|fetch/i.test(L.message)?Object.assign(new Ye("Network Error",Ye.ERR_NETWORK,g,R,L&&L.response),{cause:L.cause||L}):Ye.from(L,L&&L.code,g,R,L&&L.response)}}},UA=new Map,Ep=e=>{let t=e&&e.env||{};const{fetch:r,Request:n,Response:o}=t,i=[n,o,r];let s=i.length,a=s,d,u,l=UA;for(;a--;)d=i[a],u=l.get(d),u===void 0&&l.set(d,u=a?new Map:zA(t)),l=u;return u};Ep();const $l={http:cA,xhr:MA,fetch:{get:Ep}};G.forEach($l,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Np=e=>`- ${e}`,VA=e=>G.isFunction(e)||e===null||e===!1;function HA(e,t){e=G.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,!VA(n)&&(o=$l[(a=String(n)).toLowerCase()],o===void 0))throw new Ye(`Unknown adapter '${a}'`);if(o&&(G.isFunction(o)||(o=o.get(t))))break;i[a||"#"+s]=o}if(!o){const s=Object.entries(i).map(([d,u])=>`adapter ${d} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=r?s.length>1?`since :
|
|
44
|
+
`+s.map(Np).join(`
|
|
45
|
+
`):" "+Np(s[0]):"as no adapter specified";throw new Ye("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o}const kp={getAdapter:HA,adapters:$l};function jl(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new li(null,e)}function _p(e){return jl(e),e.headers=hr.from(e.headers),e.data=Bl.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),kp.getAdapter(e.adapter||si.adapter,e)(e).then(function(n){return jl(e),n.data=Bl.call(e,e.transformResponse,n),n.headers=hr.from(n.headers),n},function(n){return pp(n)||(jl(e),n&&n.response&&(n.response.data=Bl.call(e,e.transformResponse,n.response),n.response.headers=hr.from(n.response.headers))),Promise.reject(n)})}const Tp="1.14.0",_s={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{_s[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const Fp={};_s.transitional=function(t,r,n){function o(i,s){return"[Axios v"+Tp+"] Transitional option '"+i+"'"+s+(n?". "+n:"")}return(i,s,a)=>{if(t===!1)throw new Ye(o(s," has been removed"+(r?" in "+r:"")),Ye.ERR_DEPRECATED);return r&&!Fp[s]&&(Fp[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}},_s.spelling=function(t){return(r,n)=>(console.warn(`${n} is likely a misspelling of ${t}`),!0)};function WA(e,t,r){if(typeof e!="object")throw new Ye("options must be an object",Ye.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],d=a===void 0||s(a,i,e);if(d!==!0)throw new Ye("option "+i+" must be "+d,Ye.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new Ye("Unknown option "+i,Ye.ERR_BAD_OPTION)}}const Ts={assertOptions:WA,validators:_s},Pr=Ts.validators;let qn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new dp,response:new dp}}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+=`
|
|
46
|
+
`+i):n.stack=i}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=Kn(this.defaults,r);const{transitional:n,paramsSerializer:o,headers:i}=r;n!==void 0&&Ts.assertOptions(n,{silentJSONParsing:Pr.transitional(Pr.boolean),forcedJSONParsing:Pr.transitional(Pr.boolean),clarifyTimeoutError:Pr.transitional(Pr.boolean),legacyInterceptorReqResOrdering:Pr.transitional(Pr.boolean)},!1),o!=null&&(G.isFunction(o)?r.paramsSerializer={serialize:o}:Ts.assertOptions(o,{encode:Pr.function,serialize:Pr.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),Ts.assertOptions(r,{baseUrl:Pr.spelling("baseURL"),withXsrfToken:Pr.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s=i&&G.merge(i.common,i[r.method]);i&&G.forEach(["delete","get","head","post","put","patch","common"],g=>{delete i[g]}),r.headers=hr.concat(s,i);const a=[];let d=!0;this.interceptors.request.forEach(function(h){if(typeof h.runWhen=="function"&&h.runWhen(r)===!1)return;d=d&&h.synchronous;const y=r.transitional||Il;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 l,f=0,p;if(!d){const g=[_p.bind(this),void 0];for(g.unshift(...a),g.push(...u),p=g.length,l=Promise.resolve(r);f<p;)l=l.then(g[f++],g[f++]);return l}p=a.length;let m=r;for(;f<p;){const g=a[f++],h=a[f++];try{m=g(m)}catch(y){h.call(this,y);break}}try{l=_p.call(this,m)}catch(g){return Promise.reject(g)}for(f=0,p=u.length;f<p;)l=l.then(u[f++],u[f++]);return l}getUri(t){t=Kn(this.defaults,t);const r=yp(t.baseURL,t.url,t.allowAbsoluteUrls);return cp(r,t.params,t.paramsSerializer)}};G.forEach(["delete","get","head","options"],function(t){qn.prototype[t]=function(r,n){return this.request(Kn(n||{},{method:t,url:r,data:(n||{}).data}))}}),G.forEach(["post","put","patch"],function(t){function r(n){return function(i,s,a){return this.request(Kn(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 RA=class Gy{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 li(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 Gy(function(o){t=o}),cancel:t}}};function GA(e){return function(r){return e.apply(null,r)}}function KA(e){return G.isObject(e)&&e.isAxiosError===!0}const zl={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(zl).forEach(([e,t])=>{zl[t]=e});function Pp(e){const t=new qn(e),r=Yf(qn.prototype.request,t);return G.extend(r,qn.prototype,t,{allOwnKeys:!0}),G.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return Pp(Kn(e,o))},r}const St=Pp(si);St.Axios=qn,St.CanceledError=li,St.CancelToken=RA,St.isCancel=pp,St.VERSION=Tp,St.toFormData=Cs,St.AxiosError=Ye,St.Cancel=St.CanceledError,St.all=function(t){return Promise.all(t)},St.spread=GA,St.isAxiosError=KA,St.mergeConfig=Kn,St.AxiosHeaders=hr,St.formToJSON=e=>up(G.isHTMLForm(e)?new FormData(e):e),St.getAdapter=kp.getAdapter,St.HttpStatusCode=zl,St.default=St;const{Axios:bO,AxiosError:qA,CanceledError:vO,isCancel:wO,CancelToken:SO,VERSION:xO,all:AO,Cancel:CO,isAxiosError:EO,spread:NO,toFormData:kO,AxiosHeaders:_O,HttpStatusCode:TO,formToJSON:FO,getAdapter:PO,mergeConfig:OO}=St;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 Op(e){const t={array:[],pathPrefixToStrip:""};function r(a,d){if(a===null||typeof a!="object")return null;if(Array.isArray(a)&&a.length>0)return{array:a,fullPath:d};const u=Object.keys(a);for(const l of u){const f=a[l],p=d?`${d}.${l}`:l;if(Array.isArray(f)&&f.length>0)return{array:f,fullPath:p};if(f!==null&&typeof f=="object"){const m=r(f,p);if(m)return m}}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 YA(e){return e.length>=4&&Array.isArray(e[3])&&e[3].length===0}function XA(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 ci(e,t,r){if(!e)return[];if(Array.isArray(e)){if(e.length===0)return[];if(YA(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=>XA(o,t,r))}if(typeof e=="object"){const{array:n,pathPrefixToStrip:o}=Op(e);if(Array.isArray(n)&&n.length>0){const i=d=>!d||!d.trim()||!o?d:d.startsWith(o)?d.substring(o.length).replace(/^\.+/,"")||void 0:d,s=i(t),a=i(r);return ci(n,s,a)}}return[]}function JA(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 QA(e){return Array.isArray(e)&&e.length>=4&&Array.isArray(e[3])&&e[3].length>0&&Array.isArray(e[3][0])}function ZA(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 Ip(e){const{response:t,sourceUrl:r,rowsIndex:n,rowsPath:o,columns:i,columnsQueryParam:s="sf",columnsQueryParamSeparator:a=","}=e;let d;if(o&&o.trim()?d=jt(t,o):typeof n=="number"?d=t?.[n]:d=t,!Array.isArray(d)||d.length===0)return[];const u=d.filter(p=>Array.isArray(p));if(u.length===0)return Array.isArray(d[0])?[]:null;if(!Array.isArray(u[0]))return null;const l=ZA(r,s,a),f=l.length>0?l:Array.isArray(i)&&i.length>0?i:[];return u.map(p=>{const m={};return(f.length>0?f:Array.from({length:p.length},(h,y)=>`col${y}`)).forEach((h,y)=>{m[h]=p[y]}),m})}function eC(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(f=>f!=null&&typeof f=="object"&&!Array.isArray(f));if(s.length===0)return[];const a=Array.isArray(n)?n.filter(Boolean):[],d=o??" - ",u=f=>{if(r){const p=r.includes(".")?jt(f,r):f?.[r];if(p!=null&&String(p).trim()!=="")return String(p)}return String(f?.label??f?.name??f?.title??f?.text??f?.username??f?.email??f?.value??f?.id??f)},l=(f,p)=>{if(i){const m=i.includes(".")?jt(f,i):f?.[i];if(m!=null)return String(m)}return String(f?.value??f?.id??f?.key??f?.email??f?.username??f?.label??f?.name??p??f)};return s.map(f=>{let p="";a.length>0&&(p=a.map(h=>jt(f,h)).filter(h=>h!=null&&String(h).trim()!=="").map(h=>String(h)).join(d)),p||(p=u(f));const m=l(f,p);return{label:typeof p=="string"?p:String(p??""),value:typeof m=="string"?m:String(m??""),disabled:!!f?.disabled}})}function Mp(e){return e!=null&&!Array.isArray(e)&&(typeof e=="string"||typeof e=="number"||typeof e=="boolean")}function tC(e,t){const{array:r,pathPrefixToStrip:n}=Op(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 d=a.includes(".")?jt(s,a):s?.[a];if(Mp(d))return String(d)}return null}function rC(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(Mp(s))return String(s);const a=tC(e,n);if(a!=null)return a}const i=ci(e,o,n||o);if(i.length>0){const s=i[0].value;if(s!=null&&String(s).trim()!=="")return String(s)}return null}let Lp=null;function nC(e){Lp=e}function Dp(){return(Lp?.()??"").replace(/\/+$/,"")}function Wr(e){const t=typeof e=="string"?e.trim():"";if(!t||/^https?:\/\//i.test(t))return t;const r=Dp();return r?t.startsWith("/")?`${r}${t}`:`${r}/${t}`:t}function oC(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 iC(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 Yn=Ud(e=>({viewerContext:void 0,authHeaders:void 0,_setViewerContext:t=>e({viewerContext:oC(t)?t:void 0}),_setAuthHeaders:t=>e({authHeaders:iC(t)}),_reset:()=>e({viewerContext:void 0,authHeaders:void 0})}));function sC(e){Yn.getState()._setViewerContext(e)}function aC(e){Yn.getState()._setAuthHeaders(e)}function lC(){Yn.getState()._reset()}function cC(){return Yn.getState().viewerContext}function Fs(){return Yn.getState().authHeaders}function dC(e){if(e?.token!=null&&String(e.token).trim()!=="")return String(e.token);const t=Fs(),r=t?.Authorization??t?.authorization;if(r?.trim()){const n=r.match(/^Bearer\s+(.+)$/i);return n?n[1]:r}}function Bp(e,t){const r=dC(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 Pn(e,t){const r={},{formValues:n={},submissionContext:o,apiRealtime:i}=t;for(const{key:s,value:a}of e??[]){const d=s?.trim();if(!d||a==null)continue;let u=Ha(String(a),n,o,i);u=Bp(u,o),r[d]=u}return r}const uC=/^\{([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\}$/i;function $p(e){const t=e.trim().match(uC);return t?t[1]:e}const fC={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,d)=>{const u=d.trim().split(".");if(u.length<2)return a;const l=u[0],f=u.slice(1).join("."),p=o[l];if(p==null)return a;const m=Qe(p,f);return m==null?a:String(m)}),s.includes("{documentId}")||s.includes("%7BdocumentId%7D"))){let a;for(const d of Object.values(o)){const u=Qe(d,"data.id")??Qe(d,"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 d=t?.documentId??(t&&Qe(t,"documentId")),u=n?.documentId??(n&&Qe(n,"documentId"));d!=null&&d!==""?a=String(d):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,d)=>{const u=d.trim();if(i==null||u==="")return a;const l=Qe(i,u);return l==null?a:String(l)}),s=s.replace(/\{(?:ctx:|\@)(\w+)\}/g,(a,d)=>n&&n[d]!==void 0&&n[d]!==null?String(n[d]):a),s=s.replace(/\{(\w+)\}/g,(a,d)=>{if(a.includes("ctx:")||a.includes("@"))return a;const u=r[d];if(u!=null)return $p(String(u));let l=t[d];if(l==null||l===""){const f=Object.keys(t).find(p=>p.toLowerCase()===d.toLowerCase());f&&(l=t[f])}if((l==null||l==="")&&(l=n?.[d]),l==null||l===""){const f=fC[d];if(f)for(const p of f){const m=t[p]??n?.[p];if(m!=null&&m!==""){l=m;break}}}return l!=null&&l!==""?$p(String(l)):a}),s}const pC=new Set(["authorization"]);function mC(e){return pC.has(e.trim().toLowerCase())}function Ps(e){return(e??[]).filter(t=>!mC(t.key))}function Os(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 hC(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 Is(e,t){const{formValues:r={},submissionContext:n,urlParams:o={},apiRealtime:i}=t;let s=Rr(e,r,o,n);return s=Bp(s,n),i!==void 0&&(s=Ha(s,r,n,i)),s}function Ms(e,t={}){const r=hC(e),n={};if(r.type==="bearer"){const o=r.token??"";if(!o.trim())return n;const i=Is(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"]=Is(o,t)),n}if(r.type==="basic"){const o=r.username??"",i=r.password??"";if(!o.trim()&&!i.trim())return n;const s=Is(o,t),a=Is(i,t);n.Authorization=`Basic ${btoa(`${s}:${a}`)}`}return n}function jp({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,d]=S.useState([]),[u,l]=S.useState([]),[f,p]=S.useState([]),[m,g]=S.useState(!1),[h,y]=S.useState(null),w=!!(s?.apiEndpoint&&(s?.valueSource==="api"||s?.optionsSource==="api"||n?.valueSource==="api"||n?.optionsSource==="api")),v=e.options||n?.options||[],A=S.useMemo(()=>JA(Array.isArray(v)?v:[]),[v]),C=S.useMemo(()=>{const O=s?.apiEndpoint||n?.apiEndpoint||"",k=s?.apiQueryParams||n?.apiQueryParams;return oo(O,k)},[s?.apiEndpoint,n?.apiEndpoint,s?.apiQueryParams,n?.apiQueryParams]),F=S.useMemo(()=>{const O=new Set;for(const D of n?.dependentFields??[])typeof D=="string"&&D.trim()&&O.add(D.trim());const k=s?.apiClientFilter?.matchField?.trim()||n?.apiClientFilter?.matchField?.trim();return k&&O.add(k),[...O]},[n?.dependentFields,s?.apiClientFilter?.matchField,n?.apiClientFilter?.matchField]),E=S.useMemo(()=>{const O=new Set([...C,...F]);if(O.size===0)return null;const k={};return O.forEach(D=>{k[D]=t[D]}),JSON.stringify(k)},[C,F,t]),T=S.useMemo(()=>JSON.stringify(r||{}),[r]),N=S.useMemo(()=>{const O=new Set;e.name?.trim()&&O.add(e.name.trim());const k=e.key;return typeof k=="string"&&k.trim()&&O.add(k.trim()),[...O]},[e.name,e.key]);return S.useEffect(()=>{const O=s?.apiEndpoint;if(!w||!O){d([]);return}let k=!1;return(async()=>{a.length===0&&g(!0),y(null);try{const I=s?.apiMethod||n?.apiMethod||"GET",z=s?.apiRealtime||n?.apiRealtime,L=s?.apiQueryParams||n?.apiQueryParams||{},B=Ui({apiEndpoint:O,apiMethod:I,apiQueryParams:L,formValues:t,submissionContext:r,apiRealtime:z,additionalRequiredFieldNames:F,excludeFormFieldNames:N});if(B.blocked){k||(d([]),g(!1));return}const M={"Content-Type":"application/json"},V=s?.apiKey||n?.apiKey;V&&(M["X-CSCAPI-KEY"]=V);const $=s?.apiAuth??n?.apiAuth??i?.apiAuth??Os(s?.apiHeaders??n?.apiHeaders??i?.apiHeaders)??{type:"none"},ie=Ms($,{formValues:t,submissionContext:r,apiRealtime:z});Object.assign(M,ie);const H=s?.apiHeaders??n?.apiHeaders??i?.apiHeaders,K=s?.apiBodyFields??n?.apiBodyFields??i?.apiBodyFields,X=Pn(Ps(H),{formValues:t,submissionContext:r,apiRealtime:z});Object.assign(M,X);const le=Pn(K,{formValues:t,submissionContext:r,apiRealtime:z}),re={method:I.toLowerCase(),url:Wr(B.url),headers:M};(B.postBodyBase!=null||Object.keys(le).length>0)&&(re.data={...B.postBodyBase??{},...le});const q=await St(re),ne=s?.apiLabelField||n?.apiLabelField,Te=s?.apiValueField||n?.apiValueField,ee=q.data;let te=[];Array.isArray(ee)?te=ee:ee?.data&&(Array.isArray(ee.data)?te=ee.data:ee.data?.data&&Array.isArray(ee.data.data)?te=ee.data.data:ee.data.districts?te=ee.data.districts:ee.data.states?te=ee.data.states:ee.data.cities&&(te=ee.data.cities)),p(te);const he=ci(q.data,ne,Te);l(he);const ce=s?.apiClientFilter||n?.apiClientFilter;let Xe=he;if(ce?.filterField&&ce?.matchField){const ge=t[ce.matchField];ge!=null?Xe=he.filter(Se=>{const ae=te.find(He=>String(jt(He,Te||"code"))===String(Se.value));if(!ae)return!1;const ve=jt(ae,ce.filterField);return String(ve)===String(ge)}):Xe=[]}k||d(Xe)}catch(I){if(k)return;let z="Failed to load options";if(I.response){const L=I.response.data;I.response.status===404?z="API endpoint not found.":I.response.status===401?z="Authentication failed.":typeof L=="string"?z=L:L&&typeof L=="object"&&(z=L.error||L.message||L.detail||z)}else I.message&&(z=String(I.message));y(z),a.length===0&&d([])}finally{k||g(!1)}})(),()=>{k=!0}},[w,s?.apiEndpoint,s?.apiMethod,n?.apiEndpoint,n?.apiMethod,E,F,N,T]),S.useEffect(()=>{const O=s?.apiClientFilter||n?.apiClientFilter;if(!w||!O||f.length===0)return;const k=t[O.matchField],D=s?.apiValueField||n?.apiValueField;if(k==null){d([]);return}const R=u.filter(I=>{const z=f.find(B=>String(jt(B,D||"code"))===String(I.value));if(!z)return!1;const L=jt(z,O.filterField);return String(L)===String(k)});d(R)},[w,s?.apiClientFilter?.matchField,n?.apiClientFilter?.matchField,s?.apiClientFilter?.filterField,n?.apiClientFilter?.filterField,s?.apiValueField,n?.apiValueField,t[s?.apiClientFilter?.matchField||n?.apiClientFilter?.matchField||""],u,f]),{options:w?a:A,isLoadingOptions:m,optionsError:h}}const zp=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a,formValues:d={},submissionContext:u,excludedOptionValues:l,isPrepopulateTarget:f=!1})=>{const p=e.properties,m=p?.apiEndpoint?{apiEndpoint:p.apiEndpoint,valueSource:p.valueSource,optionsSource:p.optionsSource}:null,g=e.apidata||null,h=m||g,y=!!(h?.apiEndpoint&&(h?.valueSource==="api"||h?.optionsSource==="api"||p?.valueSource==="api"||p?.optionsSource==="api")),{options:w,isLoadingOptions:v,optionsError:A}=jp({field:e,formValues:d,submissionContext:u}),C=l?.length?new Set(l.map(String)):null,F=C?w.filter($=>!C.has(String($.value??$.label??""))):w,E="__clear__",T=t!=null&&String(t).trim()!=="",N=T?F.some($=>String($.value??$.label??"")===String(t)):!1,x=S.useMemo(()=>{if(!T||N)return F;const $=String(t);return[{label:$,value:$},...F]},[F,T,N,t]),O=T?String(t):void 0,k=`${ht(e)}-${O??"empty"}`,D=S.useCallback($=>{r($===E?"":$),n?.()},[r,n]),R=e.appearance?.size||"md",I={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},z=e.placeholder||"Select an option",L=p?.apiClientFilter?.matchField?.trim()||h?.apiClientFilter?.matchField?.trim(),B=y&&L&&(d[L]===void 0||d[L]===null||d[L]===""),M=v?"Loading options...":B?`Select ${L} first`:l?.length?"No available options":y?"No options available from API":"No options available";return y&&f&&v?c.jsx(Ct,{field:e,error:o||A||void 0,isRequired:s,className:a,children:c.jsxs("div",{role:"status","aria-label":"Loading options",className:j("flex items-center justify-center gap-2 w-full min-w-0 rounded-md border border-input bg-muted/50 text-muted-foreground",I[R],e.appearance?.className),children:[c.jsx(io,{className:"h-4 w-4 animate-spin shrink-0"}),c.jsx("span",{className:"truncate",children:"Loading..."})]})}):c.jsx(Ct,{field:e,error:o||A||void 0,isRequired:s,className:a,children:c.jsxs(g0,{value:O,onValueChange:D,disabled:i||e.disabled||v&&F.length===0,children:[c.jsx(b0,{id:ht(e),"aria-describedby":$t(e,!!o||!!A),"aria-invalid":Zt(!!o||!!A),"aria-required":s,className:j("w-full min-w-0",I[R],o&&"border-destructive focus-visible:ring-destructive",A&&"border-destructive focus-visible:ring-destructive",e.appearance?.className),children:c.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[v&&c.jsx(io,{className:"h-4 w-4 animate-spin text-muted-foreground shrink-0"}),F.length===0&&l?.length&&!T?c.jsx("span",{className:"text-muted-foreground truncate",children:"No available options"}):T?c.jsx(y0,{placeholder:z}):c.jsx("span",{className:"text-muted-foreground truncate",children:z})]})}),c.jsx(v0,{children:x.length===0?c.jsx(kl,{value:"__no_options__",disabled:!0,children:M}):c.jsxs(c.Fragment,{children:[T?c.jsx(kl,{value:E,children:z}):null,x.map(($,ie)=>{const H=String($.value??$.label??ie);if(H===E)return null;const K=$.label||$.value||String($);return c.jsx(kl,{value:H,disabled:$.disabled||!1,children:K},H)})]})})]},k)})},Up=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Vp=ad,Hp=(e,t)=>r=>{var n;if(t?.variants==null)return Vp(e,r?.class,r?.className);const{variants:o,defaultVariants:i}=t,s=Object.keys(o).map(u=>{const l=r?.[u],f=i?.[u];if(l===null)return null;const p=Up(l)||Up(f);return o[u][p]}),a=r&&Object.entries(r).reduce((u,l)=>{let[f,p]=l;return p===void 0||(u[f]=p),u},{}),d=t==null||(n=t.compoundVariants)===null||n===void 0?void 0:n.reduce((u,l)=>{let{class:f,className:p,...m}=l;return Object.entries(m).every(g=>{let[h,y]=g;return Array.isArray(y)?y.includes({...i,...a}[h]):{...i,...a}[h]===y})?[...u,f,p]:u},[]);return Vp(e,s,d,r?.class,r?.className)},gC=Hp("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 Kt({className:e,variant:t,size:r,asChild:n=!1,...o}){const i=n?nu:"button";return c.jsx(i,{"data-slot":"button",className:j(gC({variant:t,size:r,className:e})),...o})}function yC(e,t){return b.useReducer((r,n)=>t[r][n]??r,e)}var Er=e=>{const{present:t,children:r}=e,n=bC(t),o=typeof r=="function"?r({present:n.isPresent}):b.Children.only(r),i=Ze(n.ref,vC(o));return typeof r=="function"||n.isPresent?b.cloneElement(o,{ref:i}):null};Er.displayName="Presence";function bC(e){const[t,r]=b.useState(),n=b.useRef(null),o=b.useRef(e),i=b.useRef("none"),s=e?"mounted":"unmounted",[a,d]=yC(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{const u=Ls(n.current);i.current=a==="mounted"?u:"none"},[a]),er(()=>{const u=n.current,l=o.current;if(l!==e){const p=i.current,m=Ls(u);e?d("MOUNT"):m==="none"||u?.display==="none"?d("UNMOUNT"):d(l&&p!==m?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,d]),er(()=>{if(t){let u;const l=t.ownerDocument.defaultView??window,f=m=>{const h=Ls(n.current).includes(CSS.escape(m.animationName));if(m.target===t&&h&&(d("ANIMATION_END"),!o.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",u=l.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},p=m=>{m.target===t&&(i.current=Ls(n.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{l.clearTimeout(u),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:b.useCallback(u=>{n.current=u?getComputedStyle(u):null,r(u)},[])}}function Ls(e){return e?.animationName||"none"}function vC(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 wC(e){const t=SC(e),r=b.forwardRef((n,o)=>{const{children:i,...s}=n,a=b.Children.toArray(i),d=a.find(AC);if(d){const u=d.props.children,l=a.map(f=>f===d?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:f);return c.jsx(t,{...s,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...s,ref:o,children:i})});return r.displayName=`${e}.Slot`,r}function SC(e){const t=b.forwardRef((r,n)=>{const{children:o,...i}=r;if(b.isValidElement(o)){const s=EC(o),a=CC(i,o.props);return o.type!==b.Fragment&&(a.ref=n?Un(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 xC=Symbol("radix.slottable");function AC(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===xC}function CC(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 d=i(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...i}:n==="className"&&(r[n]=[o,i].filter(Boolean).join(" "))}return{...e,...r}}function EC(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 Ds="Popover",[Wp]=xr(Ds,[ss]),di=ss(),[NC,On]=Wp(Ds),Rp=e=>{const{__scopePopover:t,children:r,open:n,defaultOpen:o,onOpenChange:i,modal:s=!1}=e,a=di(t),d=b.useRef(null),[u,l]=b.useState(!1),[f,p]=tn({prop:n,defaultProp:o??!1,onChange:i,caller:Ds});return c.jsx(sf,{...a,children:c.jsx(NC,{scope:t,contentId:cn(),triggerRef:d,open:f,onOpenChange:p,onOpenToggle:b.useCallback(()=>p(m=>!m),[p]),hasCustomAnchor:u,onCustomAnchorAdd:b.useCallback(()=>l(!0),[]),onCustomAnchorRemove:b.useCallback(()=>l(!1),[]),modal:s,children:r})})};Rp.displayName=Ds;var Gp="PopoverAnchor",Kp=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=On(Gp,r),i=di(r),{onCustomAnchorAdd:s,onCustomAnchorRemove:a}=o;return b.useEffect(()=>(s(),()=>a()),[s,a]),c.jsx(ml,{...i,...n,ref:t})});Kp.displayName=Gp;var qp="PopoverTrigger",Yp=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=On(qp,r),i=di(r),s=Ze(t,o.triggerRef),a=c.jsx($e.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":em(o.open),...n,ref:s,onClick:Le(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:c.jsx(ml,{asChild:!0,...i,children:a})});Yp.displayName=qp;var Ul="PopoverPortal",[kC,_C]=Wp(Ul,{forceMount:void 0}),Xp=e=>{const{__scopePopover:t,forceMount:r,children:n,container:o}=e,i=On(Ul,t);return c.jsx(kC,{scope:t,forceMount:r,children:c.jsx(Er,{present:r||i.open,children:c.jsx(as,{asChild:!0,container:o,children:n})})})};Xp.displayName=Ul;var vo="PopoverContent",Jp=b.forwardRef((e,t)=>{const r=_C(vo,e.__scopePopover),{forceMount:n=r.forceMount,...o}=e,i=On(vo,e.__scopePopover);return c.jsx(Er,{present:n||i.open,children:i.modal?c.jsx(FC,{...o,ref:t}):c.jsx(PC,{...o,ref:t})})});Jp.displayName=vo;var TC=wC("PopoverContent.RemoveScroll"),FC=b.forwardRef((e,t)=>{const r=On(vo,e.__scopePopover),n=b.useRef(null),o=Ze(t,n),i=b.useRef(!1);return b.useEffect(()=>{const s=n.current;if(s)return gl(s)},[]),c.jsx(hs,{as:TC,allowPinchZoom:!0,children:c.jsx(Qp,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Le(e.onCloseAutoFocus,s=>{s.preventDefault(),i.current||r.triggerRef.current?.focus()}),onPointerDownOutside:Le(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,d=a.button===0&&a.ctrlKey===!0,u=a.button===2||d;i.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:Le(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})})}),PC=b.forwardRef((e,t)=>{const r=On(vo,e.__scopePopover),n=b.useRef(!1),o=b.useRef(!1);return c.jsx(Qp,{...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()}})}),Qp=b.forwardRef((e,t)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:s,onEscapeKeyDown:a,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:l,...f}=e,p=On(vo,r),m=di(r);return Ja(),c.jsx(Yi,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:i,children:c.jsx(qi,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:l,onEscapeKeyDown:a,onPointerDownOutside:d,onFocusOutside:u,onDismiss:()=>p.onOpenChange(!1),children:c.jsx(af,{"data-state":em(p.open),role:"dialog",id:p.contentId,...m,...f,ref:t,style:{...f.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)"}})})})}),Zp="PopoverClose",OC=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=On(Zp,r);return c.jsx($e.button,{type:"button",...n,ref:t,onClick:Le(e.onClick,()=>o.onOpenChange(!1))})});OC.displayName=Zp;var IC="PopoverArrow",MC=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=di(r);return c.jsx(lf,{...o,...n,ref:t})});MC.displayName=IC;function em(e){return e?"open":"closed"}var LC=Rp,DC=Kp,BC=Yp,$C=Xp,jC=Jp;function Vl({...e}){return c.jsx(LC,{"data-slot":"popover",...e})}function tm({...e}){return c.jsx(BC,{"data-slot":"popover-trigger",...e})}function Hl({className:e,align:t="center",sideOffset:r=4,...n}){return c.jsx($C,{children:c.jsx(jC,{"data-slot":"popover-content",align:t,sideOffset:r,className:j("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 zC({...e}){return c.jsx(DC,{"data-slot":"popover-anchor",...e})}const rm={};function In(){const e=rm?.VITE_CLIENT_ID?.trim()||rm?.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}const nm={};let om=null;function UC(e){om=e}function VC(){return(nm?.VITE_API_BASE_URL?.trim()||nm?.VITE_API_URL?.trim()||"").replace(/\/$/,"")}const pn=St.create({baseURL:VC()});pn.interceptors.request.use(e=>{const t=In();t&&(e.params={...e.params,clientId:t}),typeof FormData<"u"&&e.data instanceof FormData&&delete e.headers["Content-Type"];let r=om?.();if((!r||Object.keys(r).length===0)&&(r=Fs()),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});function im(e){return JSON.stringify(e).slice(1,-1)}function sm(e){const t=e.asyncSearchValueObjectKeys;return Array.isArray(t)?t.map(r=>typeof r=="string"?r.trim():"").filter(Boolean):[]}function HC(e){return e.asyncSearchValueMode==="object"&&sm(e).length>0}function WC(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 RC(e,t){const r=t.mode??"debounce",n=Math.max(0,t.intervalMs??300),[o,i]=S.useState(()=>r==="throttle"?e:""),s=S.useRef(0),a=S.useRef(void 0);return S.useEffect(()=>{if(e===""){a.current&&clearTimeout(a.current),i("");return}if(r==="debounce"){const l=setTimeout(()=>i(e),n);return()=>clearTimeout(l)}const d=Date.now(),u=d-s.current;return u>=n?(s.current=d,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 Wl(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 Rl(e,t){return e==null||e===""?!0:t&&typeof e=="object"&&!Array.isArray(e)?Object.keys(e).length===0:!1}function GC(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 KC(e){if(St.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 qC(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 am(e,t){return typeof t=="number"&&t>0?e.slice(0,t):e}function Gl(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.label=="string"&&t.value!==null&&t.value!==void 0}const lm=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:d,formValues:u={},submissionContext:l})=>{const f=e.properties||{},p=HC(f),m=f.apiEndpoint?.trim()||"",g=f.apiRealtime===!0,h=(f.apiMethod||"GET").toUpperCase()==="POST"?"POST":"GET",y=f.searchInBody===!0,w=h==="POST"||h==="GET"&&y,v=f.searchStrategy??f.searchSchedule??"debounce",A=f.searchIntervalMs??f.intervalMs??300,C=f.minQueryLength??0,F=f.maxResults,E=f.searchQueryParam||"q",T=f.clearable!==!1,N=u,[x,O]=S.useState(()=>Rl(t,p)?"":p&&typeof t=="object"&&t!==null&&!Array.isArray(t)?f.initialDisplayLabel||"":f.initialDisplayLabel||String(t)),[k,D]=S.useState(!1),[R,I]=S.useState([]),[z,L]=S.useState([]),[B,M]=S.useState([]),[V,$]=S.useState(!1),[ie,H]=S.useState(null),[K,X]=S.useState(-1),le=S.useRef(Wl(t,p)),re=S.useRef(Rl(t,p)?"":p&&typeof t=="object"&&t!==null&&!Array.isArray(t)?f.initialDisplayLabel||"":f.initialDisplayLabel||String(t??"")),q=S.useRef(void 0),ne=S.useRef(0),Te=S.useRef(null),ee=RC(x,{mode:v,intervalMs:A}),te=S.useMemo(()=>R.filter(Gl),[R]);S.useEffect(()=>{if(te.length===0){K!==-1&&X(-1);return}(K<0||K>=te.length)&&X(0)},[K,te.length]);const he=S.useMemo(()=>{const oe=oo(m,f.apiQueryParams),pe=new Set(oe);for(const We of f.dependentFields||[])We&&pe.add(We);return pe},[m,f.apiQueryParams,f.dependentFields]),ce=S.useMemo(()=>{if(he.size===0)return null;const oe={};return he.forEach(pe=>{oe[pe]=N[pe]}),JSON.stringify(oe)},[he,N]),Xe=S.useMemo(()=>JSON.stringify(u),[u]),ge=S.useMemo(()=>JSON.stringify(l||{}),[l]);S.useEffect(()=>{const oe=Wl(t,p);if(oe===le.current)return;if(le.current=oe,Rl(t,p)){re.current="",O(""),I([]),L([]),M([]),H(null),D(!1);return}const pe=f.initialDisplayLabel||(!p&&typeof t=="string"?t:"");re.current=pe,O(pe)},[t,f.initialDisplayLabel,p]),S.useEffect(()=>{if(!m){I([]),L([]),M([]),$(!1);return}if(s||i||e.disabled){I([]),L([]),M([]),$(!1);return}const oe=ee;if(oe.length<C){I([]),L([]),M([]),$(!1),H(null);return}const pe=Ui({apiEndpoint:m,apiMethod:h,apiQueryParams:f.apiQueryParams,formValues:N,submissionContext:l,apiRealtime:g,additionalRequiredFieldNames:f.dependentFields});if(pe.blocked){I([]),L([]),M([]),$(!1),H(null);return}Te.current?.abort();const We=new AbortController;Te.current=We;const Tt=++ne.current;return(async()=>{$(!0),H(null);const Fe=Wr(pe.url),Ke={};w&&(Ke["Content-Type"]="application/json"),f.apiKey&&(Ke["X-CSCAPI-KEY"]=f.apiKey);const nt=f.apiAuth??Os(f.apiHeaders)??{type:"none"},yt=Ms(nt,{formValues:N,submissionContext:l,apiRealtime:g});Object.assign(Ke,yt);const Yt=Pn(Ps(f.apiHeaders),{formValues:N,submissionContext:l,apiRealtime:g});Object.assign(Ke,Yt);const xt=Pn(f.apiBodyFields,{formValues:N,submissionContext:l,apiRealtime:g});try{let Pe;if(!w)Pe=(await pn.get(Fe,{params:{[E]:oe},signal:We.signal,headers:Object.keys(Ke).length?Ke:void 0})).data;else{let Ot={};pe.postBodyBase&&Object.keys(pe.postBodyBase).length>0?Ot={...pe.postBodyBase}:g&&Object.keys(N).length>0&&(Ot={...N}),Ot={...Ot,...xt};let Jt=Ot;if(f.searchBodyTemplate?.trim()){let an=f.searchBodyTemplate.replace(/\{\{query\}\}/g,()=>im(oe)).replace(/\{query\}/g,()=>im(oe));an=Ha(an,N,l,g);const Qt=JSON.parse(an);Jt={...Ot,...Qt}}else Jt={...Ot,[E]:oe};Pe=(await pn.post(Fe,Jt,{signal:We.signal,headers:Object.keys(Ke).length?Ke:void 0})).data}if(Tt!==ne.current)return;const ft=f.apiResultsFormat,et=f.apiResultsConfig,At=ft==="clinicaltables_v3",ur=QA(Pe),Nr=At||ft===void 0&&ur,rr=ft==="tuple_array";let Kr=null;Nr?Kr=Ip({response:Pe,sourceUrl:Fe,rowsIndex:et?.rowsIndex??3,rowsPath:et?.rowsPath,columns:et?.columns,columnsQueryParam:et?.columnsQueryParam??"sf",columnsQueryParamSeparator:et?.columnsQueryParamSeparator??","}):rr&&(Kr=Ip({response:Pe,sourceUrl:Fe,rowsIndex:et?.rowsIndex,rowsPath:et?.rowsPath,columns:et?.columns,columnsQueryParam:et?.columnsQueryParam,columnsQueryParamSeparator:et?.columnsQueryParamSeparator}));const hn=qC(Pe),Ft=Kr!==null,br=Kr&&Array.isArray(Kr)?Kr:Array.isArray(hn)&&hn.every(Ot=>Ot&&typeof Ot=="object"&&!Array.isArray(Ot))?hn:null;M(br??hn);const Lo=Array.isArray(f.apiLabelFields)&&f.apiLabelFields.length>0,sn=br&&(Ft||Lo)?eC({rows:br,apiLabelField:f.apiLabelField,apiLabelFields:f.apiLabelFields,apiLabelSeparator:f.apiLabelSeparator,apiValueField:f.apiValueField}):ci(Pe,f.apiLabelField,f.apiValueField);L(sn);const Lr=f.apiClientFilter;let Xt=sn;if(Lr?.filterField&&Lr?.matchField){const Ot=N[Lr.matchField];if(Ot!=null){const Jt=f.apiValueField;Xt=sn.filter(Et=>{const Qt=(br??hn).find(fr=>String(jt(fr,Jt||"code"))===String(Et.value));if(!Qt)return!1;const wr=jt(Qt,Lr.filterField);return String(wr)===String(Ot)})}else Xt=[]}const vr=am(Xt,F).filter(Gl);I(vr),X(vr.length>0?0:-1)}catch(Pe){if(St.isCancel(Pe)||Pe?.code==="ERR_CANCELED"||Tt!==ne.current)return;I([]),L([]),M([]),H(KC(Pe)),X(-1)}finally{Tt===ne.current&&$(!1)}})(),()=>{We.abort()}},[ee,m,h,y,w,E,C,F,f.apiKey,f.searchBodyTemplate,f.apiLabelField,f.apiLabelFields,f.apiLabelSeparator,f.apiValueField,f.apiQueryParams,f.apiClientFilter,f.apiResultsFormat,f.apiResultsConfig,f.dependentFields,g,N,l,s,i,e.disabled,ce,Xe,ge]),S.useEffect(()=>{const oe=f.apiClientFilter;if(!oe||B.length===0||z.length===0)return;const pe=N[oe.matchField],We=f.apiValueField;if(pe==null){I([]);return}const Tt=z.filter(Fe=>{const Ke=B.find(yt=>String(jt(yt,We||"code"))===String(Fe.value));if(!Ke)return!1;const nt=jt(Ke,oe.filterField);return String(nt)===String(pe)}),ze=am(Tt,F).filter(Gl);I(ze),X(ze.length>0?0:-1)},[f.apiClientFilter,f.apiValueField,N,F,z,B]);const Se=i||e.disabled,ae=s||e.readOnly,ve=S.useCallback(oe=>{const pe=oe.target.value;ae||Se||(le.current&&re.current&&pe!==re.current&&(le.current="",re.current="",r(p?null:"")),O(pe),D(!0),X(-1))},[Se,ae,p,r]),He=S.useCallback(oe=>{const pe=typeof oe?.label=="string"?oe.label:String(oe?.value??""),We=f.apiValueField||"code";if(p){const Tt=sm(f),ze=B.find(Fe=>String(jt(Fe,We))===String(oe.value));if(ze&&typeof ze=="object"&&!Array.isArray(ze)&&Tt.length>0){const Fe=WC(ze,Tt);le.current=Wl(Fe,!0),re.current=pe,r(Fe),O(pe)}else le.current=`S:${String(oe.value)}`,re.current=pe,r(String(oe.value)),O(pe)}else le.current=`S:${String(oe.value)}`,re.current=pe,r(String(oe.value)),O(pe);q.current&&clearTimeout(q.current),D(!1),X(-1),n?.()},[p,n,r,f,B]),dt=S.useCallback(oe=>{oe.preventDefault(),oe.stopPropagation(),!(Se||ae)&&(le.current="",re.current="",r(p?null:""),O(""),I([]),L([]),M([]),H(null),D(!1),n?.())},[Se,ae,p,r,n]),Ge=S.useMemo(()=>k&&!ae&&(V||!!ie||te.length>0||ee.length>=C&&!V),[k,ae,V,ie,te.length,ee,C]),Rt=S.useCallback(oe=>{if(!(ae||Se))if(oe.key==="ArrowDown")oe.preventDefault(),D(!0),X(pe=>te.length===0?-1:(pe+1)%te.length);else if(oe.key==="ArrowUp")oe.preventDefault(),D(!0),X(pe=>te.length===0?-1:pe<=0?te.length-1:pe-1);else if(oe.key==="Enter"){const pe=K>=0?te[K]:void 0;Ge&&pe&&!pe.disabled&&(oe.preventDefault(),He(pe))}else oe.key==="Escape"&&D(!1)},[Se,ae,K,Ge,te,He]),Je=e.appearance?.size||"md",Y={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},je=ht(e),gt=$t(e,!!(o||ie)),Ie=ee.length>=C&&!V&&!ie&&te.length===0;return c.jsx(Ct,{field:e,error:o||ie||void 0,isRequired:a,className:d,children:c.jsxs(Vl,{open:Ge,onOpenChange:oe=>{oe||D(!1)},children:[c.jsx(zC,{asChild:!0,children:c.jsxs("div",{className:"relative flex w-full min-w-0 items-center gap-1",children:[c.jsx(An,{id:je,role:"combobox","aria-expanded":Ge,"aria-autocomplete":"list","aria-controls":Ge?`${je}-listbox`:void 0,"aria-activedescendant":K>=0?`${je}-opt-${K}`:void 0,value:x,onChange:ve,onKeyDown:Rt,onFocus:()=>{q.current&&clearTimeout(q.current),!ae&&!Se&&D(!0)},onBlur:()=>{q.current=setTimeout(()=>{D(!1),n?.()},150)},placeholder:e.placeholder||"Search…",disabled:Se,readOnly:ae,"aria-describedby":gt,"aria-invalid":Zt(!!(o||ie)),"aria-required":a,className:j("pr-20",Y[Je],(o||ie)&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)}),c.jsxs("div",{className:"pointer-events-none absolute right-1 top-1/2 flex -translate-y-1/2 items-center gap-0.5",children:[V&&c.jsx(io,{className:"pointer-events-none h-4 w-4 animate-spin text-muted-foreground"}),T&&GC(t,x,p)&&!Se&&!ae&&c.jsx(Kt,{type:"button",variant:"ghost",size:"icon",className:"pointer-events-auto h-8 w-8 shrink-0",onMouseDown:oe=>oe.preventDefault(),onClick:dt,"aria-label":"Clear",children:c.jsx(Xo,{className:"h-4 w-4"})})]})]})}),c.jsx(Hl,{className:"p-0 w-[var(--radix-popover-trigger-width)] min-w-[12rem] overflow-hidden",align:"start",onOpenAutoFocus:oe=>oe.preventDefault(),onCloseAutoFocus:oe=>oe.preventDefault(),children:c.jsx("div",{id:`${je}-listbox`,role:"listbox",children:ie?c.jsx("div",{className:"px-3 py-2 text-sm text-destructive",children:ie}):V?c.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-sm text-muted-foreground",children:[c.jsx(io,{className:"h-4 w-4 animate-spin shrink-0"}),"Loading…"]}):Ie?c.jsx("ul",{className:"py-1","aria-label":"Search results",children:c.jsx("li",{role:"option","aria-disabled":!0,className:"cursor-default select-none px-3 py-2 text-sm text-muted-foreground",onMouseDown:oe=>oe.preventDefault(),children:"No results found"})}):c.jsx("ul",{className:"max-h-60 overflow-y-auto overscroll-contain py-1","aria-label":"Search results",children:te.map((oe,pe)=>c.jsx("li",{id:`${je}-opt-${pe}`,role:"option","aria-selected":K===pe,className:j(oe.disabled?"cursor-not-allowed opacity-60":"cursor-pointer","px-3 py-2 text-sm",K===pe&&"bg-accent text-accent-foreground"),onMouseEnter:()=>X(pe),onMouseDown:We=>We.preventDefault(),onClick:()=>{oe.disabled||He(oe)},children:oe.label},`${oe.value}-${pe}`))})})})]})})};var Bs="Checkbox",[YC]=xr(Bs),[XC,Kl]=YC(Bs);function JC(e){const{__scopeCheckbox:t,checked:r,children:n,defaultChecked:o,disabled:i,form:s,name:a,onCheckedChange:d,required:u,value:l="on",internal_do_not_use_render:f}=e,[p,m]=tn({prop:r,defaultProp:o??!1,onChange:d,caller:Bs}),[g,h]=b.useState(null),[y,w]=b.useState(null),v=b.useRef(!1),A=g?!!s||!!g.closest("form"):!0,C={checked:p,disabled:i,setChecked:m,control:g,setControl:h,name:a,form:s,value:l,hasConsumerStoppedPropagationRef:v,required:u,defaultChecked:Mn(o)?!1:o,isFormControl:A,bubbleInput:y,setBubbleInput:w};return c.jsx(XC,{scope:t,...C,children:QC(f)?f(C):n})}var cm="CheckboxTrigger",dm=b.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:r,...n},o)=>{const{control:i,value:s,disabled:a,checked:d,required:u,setControl:l,setChecked:f,hasConsumerStoppedPropagationRef:p,isFormControl:m,bubbleInput:g}=Kl(cm,e),h=Ze(o,l),y=b.useRef(d);return b.useEffect(()=>{const w=i?.form;if(w){const v=()=>f(y.current);return w.addEventListener("reset",v),()=>w.removeEventListener("reset",v)}},[i,f]),c.jsx($e.button,{type:"button",role:"checkbox","aria-checked":Mn(d)?"mixed":d,"aria-required":u,"data-state":gm(d),"data-disabled":a?"":void 0,disabled:a,value:s,...n,ref:h,onKeyDown:Le(t,w=>{w.key==="Enter"&&w.preventDefault()}),onClick:Le(r,w=>{f(v=>Mn(v)?!0:!v),g&&m&&(p.current=w.isPropagationStopped(),p.current||w.stopPropagation())})})});dm.displayName=cm;var um=b.forwardRef((e,t)=>{const{__scopeCheckbox:r,name:n,checked:o,defaultChecked:i,required:s,disabled:a,value:d,onCheckedChange:u,form:l,...f}=e;return c.jsx(JC,{__scopeCheckbox:r,checked:o,defaultChecked:i,disabled:a,required:s,onCheckedChange:u,name:n,form:l,value:d,internal_do_not_use_render:({isFormControl:p})=>c.jsxs(c.Fragment,{children:[c.jsx(dm,{...f,ref:t,__scopeCheckbox:r}),p&&c.jsx(hm,{__scopeCheckbox:r})]})})});um.displayName=Bs;var fm="CheckboxIndicator",pm=b.forwardRef((e,t)=>{const{__scopeCheckbox:r,forceMount:n,...o}=e,i=Kl(fm,r);return c.jsx(Er,{present:n||Mn(i.checked)||i.checked===!0,children:c.jsx($e.span,{"data-state":gm(i.checked),"data-disabled":i.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});pm.displayName=fm;var mm="CheckboxBubbleInput",hm=b.forwardRef(({__scopeCheckbox:e,...t},r)=>{const{control:n,hasConsumerStoppedPropagationRef:o,checked:i,defaultChecked:s,required:a,disabled:d,name:u,value:l,form:f,bubbleInput:p,setBubbleInput:m}=Kl(mm,e),g=Ze(r,m),h=ti(i),y=ei(n);b.useEffect(()=>{const v=p;if(!v)return;const A=window.HTMLInputElement.prototype,F=Object.getOwnPropertyDescriptor(A,"checked").set,E=!o.current;if(h!==i&&F){const T=new Event("click",{bubbles:E});v.indeterminate=Mn(i),F.call(v,Mn(i)?!1:i),v.dispatchEvent(T)}},[p,h,i,o]);const w=b.useRef(Mn(i)?!1:i);return c.jsx($e.input,{type:"checkbox","aria-hidden":!0,defaultChecked:s??w.current,required:a,disabled:d,name:u,value:l,form:f,...t,tabIndex:-1,ref:g,style:{...t.style,...y,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});hm.displayName=mm;function QC(e){return typeof e=="function"}function Mn(e){return e==="indeterminate"}function gm(e){return Mn(e)?"indeterminate":e?"checked":"unchecked"}function $s({className:e,...t}){return c.jsx(um,{"data-slot":"checkbox",className:j("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:c.jsx(pm,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:c.jsx(Gi,{className:"size-3.5"})})})}const ZC=Hp("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 eE({className:e,variant:t,asChild:r=!1,...n}){const o=r?nu:"span";return c.jsx(o,{"data-slot":"badge",className:j(ZC({variant:t}),e),...n})}function tE(e,t){return b.useReducer((r,n)=>t[r][n]??r,e)}var ql="ScrollArea",[ym]=xr(ql),[rE,Or]=ym(ql),bm=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,type:n="hover",dir:o,scrollHideDelay:i=600,...s}=e,[a,d]=b.useState(null),[u,l]=b.useState(null),[f,p]=b.useState(null),[m,g]=b.useState(null),[h,y]=b.useState(null),[w,v]=b.useState(0),[A,C]=b.useState(0),[F,E]=b.useState(!1),[T,N]=b.useState(!1),x=Ze(t,k=>d(k)),O=so(o);return c.jsx(rE,{scope:r,type:n,dir:O,scrollHideDelay:i,scrollArea:a,viewport:u,onViewportChange:l,content:f,onContentChange:p,scrollbarX:m,onScrollbarXChange:g,scrollbarXEnabled:F,onScrollbarXEnabledChange:E,scrollbarY:h,onScrollbarYChange:y,scrollbarYEnabled:T,onScrollbarYEnabledChange:N,onCornerWidthChange:v,onCornerHeightChange:C,children:c.jsx($e.div,{dir:O,...s,ref:x,style:{position:"relative","--radix-scroll-area-corner-width":w+"px","--radix-scroll-area-corner-height":A+"px",...e.style}})})});bm.displayName=ql;var vm="ScrollAreaViewport",wm=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,children:n,nonce:o,...i}=e,s=Or(vm,r),a=b.useRef(null),d=Ze(t,a,s.onViewportChange);return c.jsxs(c.Fragment,{children:[c.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}),c.jsx($e.div,{"data-radix-scroll-area-viewport":"",...i,ref:d,style:{overflowX:s.scrollbarXEnabled?"scroll":"hidden",overflowY:s.scrollbarYEnabled?"scroll":"hidden",...e.style},children:c.jsx("div",{ref:s.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});wm.displayName=vm;var nn="ScrollAreaScrollbar",Sm=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Or(nn,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"?c.jsx(nE,{...n,ref:t,forceMount:r}):o.type==="scroll"?c.jsx(oE,{...n,ref:t,forceMount:r}):o.type==="auto"?c.jsx(xm,{...n,ref:t,forceMount:r}):o.type==="always"?c.jsx(Yl,{...n,ref:t}):null});Sm.displayName=nn;var nE=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Or(nn,e.__scopeScrollArea),[i,s]=b.useState(!1);return b.useEffect(()=>{const a=o.scrollArea;let d=0;if(a){const u=()=>{window.clearTimeout(d),s(!0)},l=()=>{d=window.setTimeout(()=>s(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",l),()=>{window.clearTimeout(d),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",l)}}},[o.scrollArea,o.scrollHideDelay]),c.jsx(Er,{present:r||i,children:c.jsx(xm,{"data-state":i?"visible":"hidden",...n,ref:t})})}),oE=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Or(nn,e.__scopeScrollArea),i=e.orientation==="horizontal",s=Vs(()=>d("SCROLL_END"),100),[a,d]=tE("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(()=>d("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,d]),b.useEffect(()=>{const u=o.viewport,l=i?"scrollLeft":"scrollTop";if(u){let f=u[l];const p=()=>{const m=u[l];f!==m&&(d("SCROLL"),s()),f=m};return u.addEventListener("scroll",p),()=>u.removeEventListener("scroll",p)}},[o.viewport,i,d,s]),c.jsx(Er,{present:r||a!=="hidden",children:c.jsx(Yl,{"data-state":a==="hidden"?"hidden":"visible",...n,ref:t,onPointerEnter:Le(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:Le(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),xm=b.forwardRef((e,t)=>{const r=Or(nn,e.__scopeScrollArea),{forceMount:n,...o}=e,[i,s]=b.useState(!1),a=e.orientation==="horizontal",d=Vs(()=>{if(r.viewport){const u=r.viewport.offsetWidth<r.viewport.scrollWidth,l=r.viewport.offsetHeight<r.viewport.scrollHeight;s(a?u:l)}},10);return wo(r.viewport,d),wo(r.content,d),c.jsx(Er,{present:n||i,children:c.jsx(Yl,{"data-state":i?"visible":"hidden",...o,ref:t})})}),Yl=b.forwardRef((e,t)=>{const{orientation:r="vertical",...n}=e,o=Or(nn,e.__scopeScrollArea),i=b.useRef(null),s=b.useRef(0),[a,d]=b.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=km(a.viewport,a.content),l={...n,sizes:a,onSizesChange:d,hasThumb:u>0&&u<1,onThumbChange:p=>i.current=p,onThumbPointerUp:()=>s.current=0,onThumbPointerDown:p=>s.current=p};function f(p,m){return dE(p,s.current,a,m)}return r==="horizontal"?c.jsx(iE,{...l,ref:t,onThumbPositionChange:()=>{if(o.viewport&&i.current){const p=o.viewport.scrollLeft,m=_m(p,a,o.dir);i.current.style.transform=`translate3d(${m}px, 0, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollLeft=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollLeft=f(p,o.dir))}}):r==="vertical"?c.jsx(sE,{...l,ref:t,onThumbPositionChange:()=>{if(o.viewport&&i.current){const p=o.viewport.scrollTop,m=_m(p,a);i.current.style.transform=`translate3d(0, ${m}px, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollTop=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollTop=f(p))}}):null}),iE=b.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...o}=e,i=Or(nn,e.__scopeScrollArea),[s,a]=b.useState(),d=b.useRef(null),u=Ze(t,d,i.onScrollbarXChange);return b.useEffect(()=>{d.current&&a(getComputedStyle(d.current))},[d]),c.jsx(Cm,{"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":Us(r)+"px",...e.style},onThumbPointerDown:l=>e.onThumbPointerDown(l.x),onDragScroll:l=>e.onDragScroll(l.x),onWheelScroll:(l,f)=>{if(i.viewport){const p=i.viewport.scrollLeft+l.deltaX;e.onWheelScroll(p),Fm(p,f)&&l.preventDefault()}},onResize:()=>{d.current&&i.viewport&&s&&n({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:zs(s.paddingLeft),paddingEnd:zs(s.paddingRight)}})}})}),sE=b.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...o}=e,i=Or(nn,e.__scopeScrollArea),[s,a]=b.useState(),d=b.useRef(null),u=Ze(t,d,i.onScrollbarYChange);return b.useEffect(()=>{d.current&&a(getComputedStyle(d.current))},[d]),c.jsx(Cm,{"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":Us(r)+"px",...e.style},onThumbPointerDown:l=>e.onThumbPointerDown(l.y),onDragScroll:l=>e.onDragScroll(l.y),onWheelScroll:(l,f)=>{if(i.viewport){const p=i.viewport.scrollTop+l.deltaY;e.onWheelScroll(p),Fm(p,f)&&l.preventDefault()}},onResize:()=>{d.current&&i.viewport&&s&&n({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:zs(s.paddingTop),paddingEnd:zs(s.paddingBottom)}})}})}),[aE,Am]=ym(nn),Cm=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:o,onThumbChange:i,onThumbPointerUp:s,onThumbPointerDown:a,onThumbPositionChange:d,onDragScroll:u,onWheelScroll:l,onResize:f,...p}=e,m=Or(nn,r),[g,h]=b.useState(null),y=Ze(t,x=>h(x)),w=b.useRef(null),v=b.useRef(""),A=m.viewport,C=n.content-n.viewport,F=ar(l),E=ar(d),T=Vs(f,10);function N(x){if(w.current){const O=x.clientX-w.current.left,k=x.clientY-w.current.top;u({x:O,y:k})}}return b.useEffect(()=>{const x=O=>{const k=O.target;g?.contains(k)&&F(O,C)};return document.addEventListener("wheel",x,{passive:!1}),()=>document.removeEventListener("wheel",x,{passive:!1})},[A,g,C,F]),b.useEffect(E,[n,E]),wo(g,T),wo(m.content,T),c.jsx(aE,{scope:r,scrollbar:g,hasThumb:o,onThumbChange:ar(i),onThumbPointerUp:ar(s),onThumbPositionChange:E,onThumbPointerDown:ar(a),children:c.jsx($e.div,{...p,ref:y,style:{position:"absolute",...p.style},onPointerDown:Le(e.onPointerDown,x=>{x.button===0&&(x.target.setPointerCapture(x.pointerId),w.current=g.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),N(x))}),onPointerMove:Le(e.onPointerMove,N),onPointerUp:Le(e.onPointerUp,x=>{const O=x.target;O.hasPointerCapture(x.pointerId)&&O.releasePointerCapture(x.pointerId),document.body.style.webkitUserSelect=v.current,m.viewport&&(m.viewport.style.scrollBehavior=""),w.current=null})})})}),js="ScrollAreaThumb",Em=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Am(js,e.__scopeScrollArea);return c.jsx(Er,{present:r||o.hasThumb,children:c.jsx(lE,{ref:t,...n})})}),lE=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,style:n,...o}=e,i=Or(js,r),s=Am(js,r),{onThumbPositionChange:a}=s,d=Ze(t,f=>s.onThumbChange(f)),u=b.useRef(void 0),l=Vs(()=>{u.current&&(u.current(),u.current=void 0)},100);return b.useEffect(()=>{const f=i.viewport;if(f){const p=()=>{if(l(),!u.current){const m=uE(f,a);u.current=m,a()}};return a(),f.addEventListener("scroll",p),()=>f.removeEventListener("scroll",p)}},[i.viewport,l,a]),c.jsx($e.div,{"data-state":s.hasThumb?"visible":"hidden",...o,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:Le(e.onPointerDownCapture,f=>{const m=f.target.getBoundingClientRect(),g=f.clientX-m.left,h=f.clientY-m.top;s.onThumbPointerDown({x:g,y:h})}),onPointerUp:Le(e.onPointerUp,s.onThumbPointerUp)})});Em.displayName=js;var Xl="ScrollAreaCorner",Nm=b.forwardRef((e,t)=>{const r=Or(Xl,e.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?c.jsx(cE,{...e,ref:t}):null});Nm.displayName=Xl;var cE=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,...n}=e,o=Or(Xl,r),[i,s]=b.useState(0),[a,d]=b.useState(0),u=!!(i&&a);return wo(o.scrollbarX,()=>{const l=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(l),d(l)}),wo(o.scrollbarY,()=>{const l=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(l),s(l)}),u?c.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 km(e,t){const r=e/t;return isNaN(r)?0:r}function Us(e){const t=km(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,n=(e.scrollbar.size-r)*t;return Math.max(n,18)}function dE(e,t,r,n="ltr"){const o=Us(r),i=o/2,s=t||i,a=o-s,d=r.scrollbar.paddingStart+s,u=r.scrollbar.size-r.scrollbar.paddingEnd-a,l=r.content-r.viewport,f=n==="ltr"?[0,l]:[l*-1,0];return Tm([d,u],f)(e)}function _m(e,t,r="ltr"){const n=Us(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,i=t.scrollbar.size-o,s=t.content-t.viewport,a=i-n,d=r==="ltr"?[0,s]:[s*-1,0],u=Jo(e,d);return Tm([0,s],[0,a])(u)}function Tm(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 Fm(e,t){return e>0&&e<t}var uE=(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 Vs(e,t){const r=ar(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 wo(e,t){const r=ar(t);er(()=>{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 fE=bm,pE=wm,mE=Nm;function hE({className:e,children:t,...r}){return c.jsxs(fE,{"data-slot":"scroll-area",className:j("relative",e),...r,children:[c.jsx(pE,{"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}),c.jsx(gE,{}),c.jsx(mE,{})]})}function gE({className:e,orientation:t="vertical",...r}){return c.jsx(Sm,{"data-slot":"scroll-area-scrollbar",orientation:t,className:j("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:c.jsx(Em,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const Pm=({field:e,value:t=[],onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a,formValues:d={},submissionContext:u,excludedOptionValues:l})=>{const{options:f,isLoadingOptions:p,optionsError:m}=jp({field:e,formValues:d,submissionContext:u}),g=l?.length?new Set(l.map(String)):null,h=g?f.filter(T=>!g.has(String(T.value??T.label??""))):f,y=Array.isArray(t)?t:[],w=y.map(T=>h.find(N=>String(N.value)===String(T))).filter(Boolean),v=S.useCallback(T=>{const N=y.includes(T)?y.filter(x=>x!==T):[...y,T];r(N),n?.()},[y,r,n]),A=S.useCallback(T=>{r(y.filter(N=>N!==T)),n?.()},[y,r,n]),C=e.appearance?.size||"md",F={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},E=w.length>0?`${w.length} selected`:h.length===0&&l?.length?"No available options":e.placeholder||"Select options";return c.jsxs(Ct,{field:e,error:o||m||void 0,isRequired:s,className:a,children:[c.jsxs(Vl,{children:[c.jsx(tm,{asChild:!0,children:c.jsxs(Kt,{type:"button",variant:"outline",role:"combobox","aria-expanded":void 0,"aria-haspopup":"listbox","aria-multiselectable":"true","aria-describedby":$t(e,!!o||!!m),"aria-invalid":Zt(!!o||!!m),"aria-required":s,id:ht(e),disabled:i||e.disabled||p,className:j("w-full min-w-0 justify-between font-normal",F[C],o&&"border-destructive focus-visible:ring-destructive",m&&"border-destructive focus-visible:ring-destructive",e.appearance?.className),children:[c.jsx("span",{className:"truncate",children:E}),c.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[p&&c.jsx(io,{className:"h-4 w-4 animate-spin text-muted-foreground"}),c.jsx(qo,{className:"h-4 w-4 opacity-50"})]})]})}),c.jsx(Hl,{className:"w-[var(--radix-popover-trigger-width)] p-0 overflow-hidden",align:"start",children:c.jsx(hE,{className:"h-60 overflow-hidden rounded-md",children:c.jsx("ul",{role:"listbox","aria-multiselectable":"true","aria-label":e.label||e.name||"Options",className:"p-1",children:h.length===0?c.jsx("li",{className:"px-2 py-3 text-sm text-muted-foreground text-center",children:p?"Loading options...":l?.length?"No available options":"No options available"}):h.map(T=>{const N=String(T.value||T.label),x=T.label||T.value||N,O=y.includes(N);return c.jsxs("li",{role:"option","aria-selected":O,className:"flex items-center gap-2 rounded-sm px-2 py-1.5 cursor-pointer hover:bg-accent focus:bg-accent outline-none",onClick:()=>!T.disabled&&v(N),onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),T.disabled||v(N))},children:[c.jsx($s,{checked:O,disabled:T.disabled,onCheckedChange:()=>!T.disabled&&v(N),onClick:k=>k.stopPropagation(),"aria-hidden":!0,className:"pointer-events-none"}),c.jsx("span",{className:"flex-1 truncate text-sm",children:x})]},N)})})})})]}),w.length>0&&c.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",role:"list","aria-label":"Selected options",children:w.map(T=>{const N=String(T.value||T.label),x=T.label||T.value||N;return c.jsxs(eE,{variant:"secondary",className:"pl-2 pr-1 py-0.5 text-xs font-normal gap-1",children:[c.jsx("span",{className:"truncate max-w-[120px]",children:x}),c.jsx("button",{type:"button","aria-label":`Remove ${x}`,className:"rounded-full p-0.5 hover:bg-muted focus:outline-none focus:ring-2 focus:ring-ring",onClick:()=>A(N),tabIndex:-1,children:c.jsx(Xo,{className:"h-3 w-3"})})]},N)})})]})},Om=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a})=>{const d=S.useCallback(u=>{r(u===!0),n?.()},[r,n]);return c.jsxs("div",{className:j("space-y-2",a),children:[c.jsxs("div",{className:"flex items-start space-x-3",children:[c.jsx($s,{id:ht(e),checked:t||!1,onCheckedChange:d,disabled:i||e.disabled,"aria-describedby":$t(e,!!o),"aria-required":s,className:j(o&&"border-destructive")}),c.jsxs("div",{className:"grid gap-1.5 leading-none",children:[c.jsxs(Cn,{id:Hi(e),htmlFor:ht(e),className:j("text-sm font-medium cursor-pointer",o&&"text-destructive"),children:[e.label,s&&c.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.description&&!o&&c.jsx("p",{id:Go(e),className:"text-xs text-muted-foreground",children:e.description})]})]}),o&&c.jsx("p",{id:Ko(e),className:"text-xs text-destructive",role:"alert",children:o})]})};var Hs="Switch",[yE]=xr(Hs),[bE,vE]=yE(Hs),Im=b.forwardRef((e,t)=>{const{__scopeSwitch:r,name:n,checked:o,defaultChecked:i,required:s,disabled:a,value:d="on",onCheckedChange:u,form:l,...f}=e,[p,m]=b.useState(null),g=Ze(t,A=>m(A)),h=b.useRef(!1),y=p?l||!!p.closest("form"):!0,[w,v]=tn({prop:o,defaultProp:i??!1,onChange:u,caller:Hs});return c.jsxs(bE,{scope:r,checked:w,disabled:a,children:[c.jsx($e.button,{type:"button",role:"switch","aria-checked":w,"aria-required":s,"data-state":Bm(w),"data-disabled":a?"":void 0,disabled:a,value:d,...f,ref:g,onClick:Le(e.onClick,A=>{v(C=>!C),y&&(h.current=A.isPropagationStopped(),h.current||A.stopPropagation())})}),y&&c.jsx(Dm,{control:p,bubbles:!h.current,name:n,value:d,checked:w,required:s,disabled:a,form:l,style:{transform:"translateX(-100%)"}})]})});Im.displayName=Hs;var Mm="SwitchThumb",Lm=b.forwardRef((e,t)=>{const{__scopeSwitch:r,...n}=e,o=vE(Mm,r);return c.jsx($e.span,{"data-state":Bm(o.checked),"data-disabled":o.disabled?"":void 0,...n,ref:t})});Lm.displayName=Mm;var wE="SwitchBubbleInput",Dm=b.forwardRef(({__scopeSwitch:e,control:t,checked:r,bubbles:n=!0,...o},i)=>{const s=b.useRef(null),a=Ze(s,i),d=ti(r),u=ei(t);return b.useEffect(()=>{const l=s.current;if(!l)return;const f=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(f,"checked").set;if(d!==r&&m){const g=new Event("click",{bubbles:n});m.call(l,r),l.dispatchEvent(g)}},[d,r,n]),c.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}})});Dm.displayName=wE;function Bm(e){return e?"checked":"unchecked"}var SE=Im,xE=Lm;function $m({className:e,...t}){return c.jsx(SE,{"data-slot":"switch",className:j("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:c.jsx(xE,{"data-slot":"switch-thumb",className:j("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 AE=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a})=>{const d=e.properties;let u=null;if(e.metadata)try{u=typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata}catch{}const l=u?.onValue??d?.onValue??"On",f=u?.offValue??d?.offValue??"Off",p=u?.onText??d?.onText??l,m=u?.offText??d?.offText??f,g=S.useMemo(()=>{const y=t??e.defaultValue??f;return String(y)===String(l)},[t,e.defaultValue,f,l]),h=S.useCallback(y=>{r(y?l:f),n?.()},[r,n,l,f]);return c.jsxs("div",{className:j("space-y-2",a),children:[c.jsxs("div",{className:"space-y-2",children:[e.label&&c.jsxs(Cn,{id:Hi(e),htmlFor:ht(e),className:j("text-sm font-medium block",o&&"text-destructive"),children:[e.label,s&&c.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.description&&!o&&c.jsx("p",{id:Go(e),className:"text-xs text-muted-foreground",children:e.description}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx($m,{id:ht(e),checked:g,onCheckedChange:h,disabled:i||e.disabled,"aria-describedby":$t(e,!!o),"aria-required":s,className:j(o&&"opacity-50")}),c.jsx("span",{className:"text-sm text-foreground font-medium",children:g?p:m})]})]}),o&&c.jsx("p",{id:Ko(e),className:"text-xs text-destructive",role:"alert",children:o})]})};var Jl="rovingFocusGroup.onEntryFocus",CE={bubbles:!1,cancelable:!0},ui="RovingFocusGroup",[Ql,jm,EE]=qa(ui),[NE,Ws]=xr(ui,[EE]),[kE,_E]=NE(ui),zm=b.forwardRef((e,t)=>c.jsx(Ql.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Ql.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(TE,{...e,ref:t})})}));zm.displayName=ui;var TE=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:d,onEntryFocus:u,preventScrollOnEntryFocus:l=!1,...f}=e,p=b.useRef(null),m=Ze(t,p),g=so(i),[h,y]=tn({prop:s,defaultProp:a??null,onChange:d,caller:ui}),[w,v]=b.useState(!1),A=ar(u),C=jm(r),F=b.useRef(!1),[E,T]=b.useState(0);return b.useEffect(()=>{const N=p.current;if(N)return N.addEventListener(Jl,A),()=>N.removeEventListener(Jl,A)},[A]),c.jsx(kE,{scope:r,orientation:n,dir:g,loop:o,currentTabStopId:h,onItemFocus:b.useCallback(N=>y(N),[y]),onItemShiftTab:b.useCallback(()=>v(!0),[]),onFocusableItemAdd:b.useCallback(()=>T(N=>N+1),[]),onFocusableItemRemove:b.useCallback(()=>T(N=>N-1),[]),children:c.jsx($e.div,{tabIndex:w||E===0?-1:0,"data-orientation":n,...f,ref:m,style:{outline:"none",...e.style},onMouseDown:Le(e.onMouseDown,()=>{F.current=!0}),onFocus:Le(e.onFocus,N=>{const x=!F.current;if(N.target===N.currentTarget&&x&&!w){const O=new CustomEvent(Jl,CE);if(N.currentTarget.dispatchEvent(O),!O.defaultPrevented){const k=C().filter(L=>L.focusable),D=k.find(L=>L.active),R=k.find(L=>L.id===h),z=[D,R,...k].filter(Boolean).map(L=>L.ref.current);Hm(z,l)}}F.current=!1}),onBlur:Le(e.onBlur,()=>v(!1))})})}),Um="RovingFocusGroupItem",Vm=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:o=!1,tabStopId:i,children:s,...a}=e,d=cn(),u=i||d,l=_E(Um,r),f=l.currentTabStopId===u,p=jm(r),{onFocusableItemAdd:m,onFocusableItemRemove:g,currentTabStopId:h}=l;return b.useEffect(()=>{if(n)return m(),()=>g()},[n,m,g]),c.jsx(Ql.ItemSlot,{scope:r,id:u,focusable:n,active:o,children:c.jsx($e.span,{tabIndex:f?0:-1,"data-orientation":l.orientation,...a,ref:t,onMouseDown:Le(e.onMouseDown,y=>{n?l.onItemFocus(u):y.preventDefault()}),onFocus:Le(e.onFocus,()=>l.onItemFocus(u)),onKeyDown:Le(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){l.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const w=OE(y,l.orientation,l.dir);if(w!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let A=p().filter(C=>C.focusable).map(C=>C.ref.current);if(w==="last")A.reverse();else if(w==="prev"||w==="next"){w==="prev"&&A.reverse();const C=A.indexOf(y.currentTarget);A=l.loop?IE(A,C+1):A.slice(C+1)}setTimeout(()=>Hm(A))}}),children:typeof s=="function"?s({isCurrentTabStop:f,hasTabStop:h!=null}):s})})});Vm.displayName=Um;var FE={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function PE(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function OE(e,t,r){const n=PE(e.key,r);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return FE[n]}function Hm(e,t=!1){const r=document.activeElement;for(const n of e)if(n===r||(n.focus({preventScroll:t}),document.activeElement!==r))return}function IE(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var Wm=zm,Rm=Vm,Zl="Radio",[ME,Gm]=xr(Zl),[LE,DE]=ME(Zl),Km=b.forwardRef((e,t)=>{const{__scopeRadio:r,name:n,checked:o=!1,required:i,disabled:s,value:a="on",onCheck:d,form:u,...l}=e,[f,p]=b.useState(null),m=Ze(t,y=>p(y)),g=b.useRef(!1),h=f?u||!!f.closest("form"):!0;return c.jsxs(LE,{scope:r,checked:o,disabled:s,children:[c.jsx($e.button,{type:"button",role:"radio","aria-checked":o,"data-state":Jm(o),"data-disabled":s?"":void 0,disabled:s,value:a,...l,ref:m,onClick:Le(e.onClick,y=>{o||d?.(),h&&(g.current=y.isPropagationStopped(),g.current||y.stopPropagation())})}),h&&c.jsx(Xm,{control:f,bubbles:!g.current,name:n,value:a,checked:o,required:i,disabled:s,form:u,style:{transform:"translateX(-100%)"}})]})});Km.displayName=Zl;var qm="RadioIndicator",Ym=b.forwardRef((e,t)=>{const{__scopeRadio:r,forceMount:n,...o}=e,i=DE(qm,r);return c.jsx(Er,{present:n||i.checked,children:c.jsx($e.span,{"data-state":Jm(i.checked),"data-disabled":i.disabled?"":void 0,...o,ref:t})})});Ym.displayName=qm;var BE="RadioBubbleInput",Xm=b.forwardRef(({__scopeRadio:e,control:t,checked:r,bubbles:n=!0,...o},i)=>{const s=b.useRef(null),a=Ze(s,i),d=ti(r),u=ei(t);return b.useEffect(()=>{const l=s.current;if(!l)return;const f=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(f,"checked").set;if(d!==r&&m){const g=new Event("click",{bubbles:n});m.call(l,r),l.dispatchEvent(g)}},[d,r,n]),c.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}})});Xm.displayName=BE;function Jm(e){return e?"checked":"unchecked"}var $E=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Rs="RadioGroup",[jE]=xr(Rs,[Ws,Gm]),Qm=Ws(),Zm=Gm(),[zE,UE]=jE(Rs),eh=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,name:n,defaultValue:o,value:i,required:s=!1,disabled:a=!1,orientation:d,dir:u,loop:l=!0,onValueChange:f,...p}=e,m=Qm(r),g=so(u),[h,y]=tn({prop:i,defaultProp:o??null,onChange:f,caller:Rs});return c.jsx(zE,{scope:r,name:n,required:s,disabled:a,value:h,onValueChange:y,children:c.jsx(Wm,{asChild:!0,...m,orientation:d,dir:g,loop:l,children:c.jsx($e.div,{role:"radiogroup","aria-required":s,"aria-orientation":d,"data-disabled":a?"":void 0,dir:g,...p,ref:t})})})});eh.displayName=Rs;var th="RadioGroupItem",rh=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,disabled:n,...o}=e,i=UE(th,r),s=i.disabled||n,a=Qm(r),d=Zm(r),u=b.useRef(null),l=Ze(t,u),f=i.value===o.value,p=b.useRef(!1);return b.useEffect(()=>{const m=h=>{$E.includes(h.key)&&(p.current=!0)},g=()=>p.current=!1;return document.addEventListener("keydown",m),document.addEventListener("keyup",g),()=>{document.removeEventListener("keydown",m),document.removeEventListener("keyup",g)}},[]),c.jsx(Rm,{asChild:!0,...a,focusable:!s,active:f,children:c.jsx(Km,{disabled:s,required:i.required,checked:f,...d,...o,name:i.name,ref:l,onCheck:()=>i.onValueChange(o.value),onKeyDown:Le(m=>{m.key==="Enter"&&m.preventDefault()}),onFocus:Le(o.onFocus,()=>{p.current&&u.current?.click()})})})});rh.displayName=th;var VE="RadioGroupIndicator",nh=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,...n}=e,o=Zm(r);return c.jsx(Ym,{...o,...n,ref:t})});nh.displayName=VE;var HE=eh,WE=rh,RE=nh;function GE({className:e,...t}){return c.jsx(HE,{"data-slot":"radio-group",className:j("grid gap-3",e),...t})}function KE({className:e,...t}){return c.jsx(WE,{"data-slot":"radio-group-item",className:j("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:c.jsx(RE,{"data-slot":"radio-group-indicator",className:"relative flex items-center justify-center",children:c.jsx(lu,{className:"fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2"})})})}const oh=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a,excludedOptionValues:d})=>{const u=e.properties,l=Array.isArray(u?.options)&&u.options.length>0?u.options:Array.isArray(e.options)?e.options:[],f=d?.length?new Set(d.map(String)):null,p=f?l.filter(g=>!f.has(String(g.value??g.label??""))):l,m=S.useCallback(g=>{r(g),n?.()},[r,n]);return c.jsx(Ct,{field:e,error:o,isRequired:s,className:a,children:c.jsx(GE,{value:t||"",onValueChange:m,disabled:i||e.disabled||p.length===0,className:"flex flex-col space-y-2","aria-required":s,children:p.length===0?c.jsx("p",{className:"text-sm text-muted-foreground py-1",children:"No available options"}):p.map(g=>c.jsxs("div",{className:"flex items-center space-x-3",children:[c.jsx(KE,{id:`${ht(e)}-${g.value}`,value:g.value,disabled:g.disabled,className:j(o&&"border-destructive")}),c.jsxs(Cn,{htmlFor:`${ht(e)}-${g.value}`,className:j("text-sm font-normal cursor-pointer",g.disabled&&"text-muted-foreground cursor-not-allowed"),children:[g.label,g.description&&c.jsx("span",{className:"block text-xs text-muted-foreground",children:g.description})]})]},g.value))})})},ih=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:d})=>{const u=e.properties,l=S.useCallback(C=>{r(C.target.value)},[r]),f=C=>{if(C)return C==="today"?new Date().toISOString().split("T")[0]:C},p=f(u?.minDate),m=f(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",w={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 c.jsxs("div",{className:j("space-y-2 w-fit",v==="left"&&"flex items-start gap-4",d),children:[A&&c.jsxs(Cn,{id:Hi(e),htmlFor:ht(e),className:j("text-sm font-medium",v==="left"&&"w-32 pt-2 text-right",o&&"text-destructive"),children:[e.label,a&&c.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),c.jsxs("div",{className:"w-fit",children:[c.jsxs("div",{className:"relative w-fit max-w-full",children:[c.jsx(zv,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"}),c.jsx(An,{id:ht(e),type:h,value:t||"",onChange:l,onBlur:n,disabled:i||e.disabled,readOnly:s||e.readOnly,min:p,max:m,"aria-describedby":$t(e,!!o),"aria-invalid":Zt(!!o),"aria-required":a,className:j(w[y],"pl-10 w-fit",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]}),e.description&&!o&&c.jsx("p",{id:Go(e),className:"mt-1.5 text-xs text-muted-foreground",children:e.description}),o&&c.jsx("p",{id:Ko(e),className:"mt-1.5 text-xs text-destructive",role:"alert",children:o})]})]})};function So(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 ec(e,t){return e===1&&t===1}const sh=/\.(jpg|jpeg|png|gif|webp|bmp|svg)(\?|$)/i;function tc(e){return e.type.startsWith("image/")?!0:sh.test(e.name)}function Gs(e){try{const t=e.split("?")[0];return sh.test(t)}catch{return!1}}function rc({items:e,maxFiles:t,disabled:r,objectUrls:n,failedUrlKeys:o,onImageUrlError:i,onRemove:s,onOpenUrl:a,resolveOpenUrl:d,addSlot:u,className:l}){const f=S.useCallback(p=>{try{return p.split("?")[0].split("/").filter(Boolean).pop()||p}catch{return p}},[]);return c.jsxs("div",{"data-file-like-strip":!0,"data-remove-in-dropzone":!0,className:j("relative w-full h-full flex items-center gap-1 min-h-0 overflow-x-auto",l),children:[e.map((p,m)=>{const g=p instanceof File,h=!g&&p&&"url"in p?p:null,y=h?.url??"",w=`${m}-${y}`,v=h&&o.has(y),A=g?n[m]??null:h&&Gs(y)&&!v?y:null,C=g&&tc(p)&&!!A||!!h&&Gs(y)&&!v&&!!A,F=g?p.name:h?h.name??f(y):"",E=d?.(m,p),T=h&&y||E||"",N=!!a&&!!T;return c.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:[C&&A?c.jsx("img",{src:A,alt:"",className:"absolute inset-0 h-full w-full object-cover",onError:()=>{h&&i(y)}}):c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-muted/40",children:c.jsx(du,{className:"h-7 w-7 text-muted-foreground","aria-hidden":!0})}),c.jsxs("div",{className:"absolute top-0.5 right-0.5 z-10 flex items-center gap-0.5",children:[N&&c.jsx("button",{type:"button",onClick:x=>{x.preventDefault(),x.stopPropagation(),a(T)},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:c.jsx(cu,{className:"h-3 w-3","aria-hidden":!0})}),c.jsx("button",{type:"button",onClick:x=>{x.preventDefault(),x.stopPropagation(),s(m)},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:c.jsx(Xo,{className:"h-3 w-3","aria-hidden":!0})})]}),!C&&F&&c.jsx("span",{className:"sr-only",children:F})]},w+(g?p.name+p.size:""))}),u]})}function nc(e){const[t,r]=S.useState([]);return S.useEffect(()=>{const n=e.map(o=>o instanceof File&&tc(o)?URL.createObjectURL(o):null);return r(n),()=>{n.forEach(o=>{o&&URL.revokeObjectURL(o)})}},[e]),t}function oc({item:e,objectUrl:t,failedUrlKeys:r,onImageUrlError:n,onRemove:o,onOpenUrl:i,openTarget:s,disabled:a}){const d=S.useCallback(v=>{try{return v.split("?")[0].split("/").filter(Boolean).pop()||v}catch{return v}},[]),u=e instanceof File,l=!u&&e&&"url"in e?e:null,f=l?.url??"",p=l&&r.has(f),m=u?t:l&&Gs(f)&&!p?f:null,g=u&&tc(e)&&!!m||!!l&&Gs(f)&&!p&&!!m,h=u?e.name:l?l.name??d(f):"",y=(s?.trim()||f||"").trim(),w=!!i&&!!y;return c.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:[g&&m?c.jsx("img",{src:m,alt:"",className:"absolute inset-0 h-full w-full rounded object-cover",onError:()=>{l&&n(f)}}):c.jsx("div",{className:"absolute inset-0 flex items-center justify-center rounded bg-muted/40",children:c.jsx(du,{className:"h-8 w-8 text-muted-foreground","aria-hidden":!0})}),c.jsxs("div",{className:"absolute top-1 right-1 z-10 flex items-center gap-1",children:[w&&y&&c.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:c.jsx(cu,{className:"h-3.5 w-3.5","aria-hidden":!0})}),c.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:c.jsx(Xo,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),!g&&h&&c.jsx("p",{className:"sr-only",children:h})]})}const qE=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a,buttonResponses:d})=>{const{gridStretch:u}=Wo(),l=u&&Di(e),f=e.properties,p=S.useRef(null),[m,g]=S.useState(!1),[h,y]=S.useState(),[w,v]=S.useState(()=>new Set),[A,C]=S.useState(0),F=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,E=Bi(e),T=S.useMemo(()=>$i(t),[t]),[N,x]=S.useState(null);S.useEffect(()=>{x(null)},[t,A]);const O=N??T,k=nc(O),D=e.validation?.find(ge=>ge.type==="fileSize"),R=e.validation?.find(ge=>ge.type==="fileType"),I=D?.value?D.value:f?.maxSize??F?.maxSize??10*1024*1024,z=R?.value?R.value:f?.accept??F?.accept??[],L=Array.isArray(z)?z.join(","):"",B=()=>{O.length>=E||p.current?.click()},M=S.useCallback(ge=>{if(D){const Se=Jr(ge,D);if(Se!==!0)return typeof Se=="string"?Se:"File size exceeds the maximum allowed size"}else if(ge.size>I)return`File size must be less than ${So(I)}`;if(R){const Se=Jr(ge,R);if(Se!==!0)return typeof Se=="string"?Se:"File type is not allowed"}return null},[D,R,I]),V=S.useCallback(ge=>{const Se=$a(ge,E);r(Se),n?.()},[r,n,E]),$=S.useCallback(ge=>{y(void 0);const Se=Array.from(ge),ae=[...O];let ve=null;for(const He of Se){if(ae.length>=E)break;const dt=M(He);if(dt){ve||(ve=dt);continue}ae.push(He)}if(ve&&ae.length===O.length){y(ve);return}ve&&y(ve),x(ae),V(ae)},[O,E,M,V]),ie=S.useCallback(ge=>{const Se=ge.target.files;Se&&Se.length>0&&$(Se),p.current&&(p.current.value="")},[$]),H=S.useCallback(ge=>{if(i)return;const Se=O.filter((ae,ve)=>ve!==ge);C(ae=>ae+1),x(Se),V(Se)},[i,O,V]),K=ge=>{ge.preventDefault(),g(!0)},X=()=>{g(!1)},le=ge=>{ge.preventDefault(),g(!1),ge.dataTransfer.files?.length&&$(ge.dataTransfer.files)},re=o||h,q=[];(D||I)&&q.push(`Max size: ${So(I)}`),R&&z.length>0&&q.push(`Allowed types: ${z.join(", ")}`),E>1&&q.push(`Up to ${E} files`);const ne=e.appearance?.hideLabel??!1,Te=S.useMemo(()=>{if(!d)return null;const ge=Object.values(d);for(let Se=ge.length-1;Se>=0;Se-=1){const ae=ge[Se],ve=typeof ae?.status=="string"?ae.status.toLowerCase():null;if(ve&&ve!=="success")continue;const He=ae?.code;if(typeof He=="number"&&(He<200||He>=300))continue;const dt=ae?.data,Ge=dt?.file_url||dt?.fileUrl||ae?.file_url||ae?.fileUrl;if(typeof Ge=="string"&&Ge.trim())return Ge}return null},[d]),ee=S.useCallback(ge=>{window.open(ge,"_blank","noopener,noreferrer")},[]),te=S.useCallback(ge=>{v(Se=>new Set(Se).add(ge))},[]),he=O.length===0,ce=O.length<E,Xe=ec(E,O.length);return c.jsx(Ct,{field:e,error:re,isRequired:s,className:j(a,"!space-y-0"),hideLabel:ne,children:c.jsx("div",{className:j("min-h-[70px] min-w-0 w-full flex flex-col",l?"flex-1 h-full":"h-[70px]"),children:c.jsxs("div",{onClick:ge=>{ge.target.closest("[data-remove-in-dropzone]")||ge.target.closest("[data-no-open-picker]")||B()},onDragOver:K,onDragLeave:X,onDrop:le,className:j("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",m&&"border-primary bg-primary/10",re&&"border-destructive",i&&"opacity-50 cursor-not-allowed",!ce&&O.length>0&&"cursor-default"),children:[c.jsx("input",{ref:p,id:ht(e),type:"file",accept:L,multiple:E>1,onChange:ie,disabled:i||e.disabled||!ce,className:"hidden","aria-describedby":$t(e,!!re),"aria-invalid":Zt(!!re),"aria-required":s}),he?c.jsxs(c.Fragment,{children:[c.jsx(Ki,{className:"mx-auto h-5 w-5 text-muted-foreground flex-shrink-0"}),c.jsx("p",{className:"text-[11px] text-muted-foreground leading-tight line-clamp-1",children:"Drag & drop or click"}),q.length>0&&c.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-1",children:q.join(" • ")})]}):Xe?c.jsx(oc,{item:O[0],objectUrl:k[0]??null,failedUrlKeys:w,onImageUrlError:te,onRemove:()=>H(0),onOpenUrl:ee,openTarget:O[0]instanceof File?Te:void 0,disabled:i||e.disabled}):c.jsx(rc,{items:O,maxFiles:E,disabled:i,objectUrls:k,failedUrlKeys:w,onImageUrlError:te,onRemove:H,resolveOpenUrl:(ge,Se)=>Se instanceof File&&O.length===1&&Te?.trim()?Te.trim():null,onOpenUrl:ge=>{ge?.trim()&&ee(ge.trim())},addSlot:ce?c.jsxs("button",{type:"button","data-no-open-picker":!0,onClick:ge=>{ge.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:[c.jsx(Ki,{className:"h-4 w-4 mb-0.5","aria-hidden":!0}),"Add"]}):void 0})]})})})};function YE(e){const t=XE(e),r=b.forwardRef((n,o)=>{const{children:i,...s}=n,a=b.Children.toArray(i),d=a.find(QE);if(d){const u=d.props.children,l=a.map(f=>f===d?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:f);return c.jsx(t,{...s,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...s,ref:o,children:i})});return r.displayName=`${e}.Slot`,r}function XE(e){const t=b.forwardRef((r,n)=>{const{children:o,...i}=r;if(b.isValidElement(o)){const s=eN(o),a=ZE(i,o.props);return o.type!==b.Fragment&&(a.ref=n?Un(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 JE=Symbol("radix.slottable");function QE(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===JE}function ZE(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 d=i(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...i}:n==="className"&&(r[n]=[o,i].filter(Boolean).join(" "))}return{...e,...r}}function eN(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 Ks="Dialog",[ah]=xr(Ks),[tN,Gr]=ah(Ks),lh=e=>{const{__scopeDialog:t,children:r,open:n,defaultOpen:o,onOpenChange:i,modal:s=!0}=e,a=b.useRef(null),d=b.useRef(null),[u,l]=tn({prop:n,defaultProp:o??!1,onChange:i,caller:Ks});return c.jsx(tN,{scope:t,triggerRef:a,contentRef:d,contentId:cn(),titleId:cn(),descriptionId:cn(),open:u,onOpenChange:l,onOpenToggle:b.useCallback(()=>l(f=>!f),[l]),modal:s,children:r})};lh.displayName=Ks;var ch="DialogTrigger",rN=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Gr(ch,r),i=Ze(t,o.triggerRef);return c.jsx($e.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":ac(o.open),...n,ref:i,onClick:Le(e.onClick,o.onOpenToggle)})});rN.displayName=ch;var ic="DialogPortal",[nN,dh]=ah(ic,{forceMount:void 0}),uh=e=>{const{__scopeDialog:t,forceMount:r,children:n,container:o}=e,i=Gr(ic,t);return c.jsx(nN,{scope:t,forceMount:r,children:b.Children.map(n,s=>c.jsx(Er,{present:r||i.open,children:c.jsx(as,{asChild:!0,container:o,children:s})}))})};uh.displayName=ic;var qs="DialogOverlay",fh=b.forwardRef((e,t)=>{const r=dh(qs,e.__scopeDialog),{forceMount:n=r.forceMount,...o}=e,i=Gr(qs,e.__scopeDialog);return i.modal?c.jsx(Er,{present:n||i.open,children:c.jsx(iN,{...o,ref:t})}):null});fh.displayName=qs;var oN=YE("DialogOverlay.RemoveScroll"),iN=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Gr(qs,r);return c.jsx(hs,{as:oN,allowPinchZoom:!0,shards:[o.contentRef],children:c.jsx($e.div,{"data-state":ac(o.open),...n,ref:t,style:{pointerEvents:"auto",...n.style}})})}),Xn="DialogContent",ph=b.forwardRef((e,t)=>{const r=dh(Xn,e.__scopeDialog),{forceMount:n=r.forceMount,...o}=e,i=Gr(Xn,e.__scopeDialog);return c.jsx(Er,{present:n||i.open,children:i.modal?c.jsx(sN,{...o,ref:t}):c.jsx(aN,{...o,ref:t})})});ph.displayName=Xn;var sN=b.forwardRef((e,t)=>{const r=Gr(Xn,e.__scopeDialog),n=b.useRef(null),o=Ze(t,r.contentRef,n);return b.useEffect(()=>{const i=n.current;if(i)return gl(i)},[]),c.jsx(mh,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Le(e.onCloseAutoFocus,i=>{i.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:Le(e.onPointerDownOutside,i=>{const s=i.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&i.preventDefault()}),onFocusOutside:Le(e.onFocusOutside,i=>i.preventDefault())})}),aN=b.forwardRef((e,t)=>{const r=Gr(Xn,e.__scopeDialog),n=b.useRef(!1),o=b.useRef(!1);return c.jsx(mh,{...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()}})}),mh=b.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:i,...s}=e,a=Gr(Xn,r),d=b.useRef(null),u=Ze(t,d);return Ja(),c.jsxs(c.Fragment,{children:[c.jsx(Yi,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:i,children:c.jsx(qi,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":ac(a.open),...s,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),c.jsxs(c.Fragment,{children:[c.jsx(cN,{titleId:a.titleId}),c.jsx(uN,{contentRef:d,descriptionId:a.descriptionId})]})]})}),sc="DialogTitle",hh=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Gr(sc,r);return c.jsx($e.h2,{id:o.titleId,...n,ref:t})});hh.displayName=sc;var gh="DialogDescription",lN=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Gr(gh,r);return c.jsx($e.p,{id:o.descriptionId,...n,ref:t})});lN.displayName=gh;var yh="DialogClose",bh=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Gr(yh,r);return c.jsx($e.button,{type:"button",...n,ref:t,onClick:Le(e.onClick,()=>o.onOpenChange(!1))})});bh.displayName=yh;function ac(e){return e?"open":"closed"}var vh="DialogTitleWarning",[IO,wh]=Kv(vh,{contentName:Xn,titleName:sc,docsSlug:"dialog"}),cN=({titleId:e})=>{const t=wh(vh),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},sN="DialogDescriptionWarning",aN=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${vh(sN).contentName}}.`;return b.useEffect(()=>{const o=e.current?.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},lN=ah,cN=dh,dN=uh,uN=fh,fN=mh,pN=yh;function mN({...e}){return c.jsx(lN,{"data-slot":"dialog",...e})}function hN({...e}){return c.jsx(cN,{"data-slot":"dialog-portal",...e})}function gN({className:e,...t}){return c.jsx(dN,{"data-slot":"dialog-overlay",className:B("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 yN({className:e,children:t,showCloseButton:r=!0,...n}){return c.jsxs(hN,{"data-slot":"dialog-portal",children:[c.jsx(gN,{}),c.jsxs(uN,{"data-slot":"dialog-content",className:B("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&&c.jsxs(pN,{"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:[c.jsx(Xo,{}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function bN({className:e,...t}){return c.jsx("div",{"data-slot":"dialog-header",className:B("flex flex-col gap-2 text-center sm:text-left",e),...t})}function vN({className:e,...t}){return c.jsx("div",{"data-slot":"dialog-footer",className:B("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function wN({className:e,...t}){return c.jsx(fN,{"data-slot":"dialog-title",className:B("text-lg leading-none font-semibold",e),...t})}async function SN(){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 wh(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 Sh=({open:e,onOpenChange:t,onCaptured:r,validateFile:n,accept:o,disabled:i,onValidationMessage:s})=>{const a=S.useRef(null),d=S.useRef(null),u=S.useRef(null),l=S.useRef(null),[f,p]=S.useState(null),[m,g]=S.useState(!1),h=S.useCallback(()=>{a.current&&(a.current.srcObject=null)},[]),y=S.useCallback(()=>{u.current&&(u.current.getTracks().forEach(E=>E.stop()),u.current=null),h()},[h]);S.useEffect(()=>{if(!e){y(),p(null),g(!1);return}if(i)return;let E=!1;return p(null),g(!0),SN().then(_=>{if(E){_.getTracks().forEach(C=>C.stop());return}u.current=_,g(!1)}).catch(_=>{if(E)return;g(!1);const C=_ instanceof Error?_.message:"Could not access camera";p(C)}),()=>{E=!0,u.current&&(u.current.getTracks().forEach(_=>_.stop()),u.current=null),h()}},[e,i,y,h]);const w=S.useCallback(E=>{a.current=E,E&&u.current&&e&&!f&&!m&&(E.srcObject=u.current,wh(E))},[e,f,m]);S.useLayoutEffect(()=>{if(!e||f||m||!u.current)return;let E=!1,_=0;const C=()=>{if(E)return;const O=a.current;!O||!u.current||(O.srcObject=u.current,wh(O))};C();const A=requestAnimationFrame(()=>{C(),_=requestAnimationFrame(C)});return()=>{E=!0,cancelAnimationFrame(A),cancelAnimationFrame(_),h()}},[e,f,m,h]);const v=S.useCallback(()=>{y(),p(null),g(!1),t(!1),l.current&&(l.current.value="")},[y,t]),x=S.useCallback(()=>{const E=a.current,_=d.current;if(!E||!_||!u.current||E.readyState<2)return;const C=E.videoWidth,A=E.videoHeight;if(C===0||A===0)return;_.width=C,_.height=A;const O=_.getContext("2d");O&&(O.drawImage(E,0,0),_.toBlob(T=>{if(!T)return;const z=new File([T],`camera-capture-${Date.now()}.jpg`,{type:"image/jpeg",lastModified:Date.now()}),q=n(z);if(q){s?.(q);return}s?.(void 0),r(z),v()},"image/jpeg",.92))},[r,n,v,s]),N=S.useCallback(E=>{const _=E.target.files?.[0];if(!_)return;const C=n(_);if(C){s?.(C);return}s?.(void 0),r(_),v(),l.current&&(l.current.value="")},[r,n,v,s]),P=typeof navigator<"u"&&typeof navigator.mediaDevices?.getUserMedia=="function";return c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:l,type:"file",accept:o,capture:"user",onChange:N,className:"hidden","aria-hidden":!0}),c.jsx("canvas",{ref:d,className:"hidden","aria-hidden":!0}),c.jsx(mN,{open:e,onOpenChange:E=>{E||v()},children:c.jsxs(yN,{className:"sm:max-w-md",showCloseButton:!0,onPointerDownOutside:E=>E.preventDefault(),children:[c.jsx(bN,{children:c.jsx(wN,{children:"Take a photo"})}),f?c.jsxs("div",{className:"space-y-3 py-2",children:[c.jsx("p",{className:"text-sm text-destructive",children:f}),P&&c.jsx("p",{className:"text-xs text-muted-foreground",children:"You can choose an image from your device instead."}),c.jsx(Kt,{type:"button",variant:"outline",className:"w-full",onClick:()=>l.current?.click(),children:"Choose from device"})]}):m?c.jsx("p",{className:"text-sm text-muted-foreground py-6 text-center",children:"Opening camera…"}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"relative rounded-lg overflow-hidden bg-black aspect-video",children:c.jsx("video",{ref:w,playsInline:!0,muted:!0,className:"w-full h-full object-cover"})}),c.jsxs(vN,{className:"gap-2 sm:gap-0",children:[c.jsx(Kt,{type:"button",variant:"outline",onClick:v,children:"Cancel"}),c.jsx(Kt,{type:"button",onClick:x,children:"Capture photo"})]})]})]})})]})},xN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a})=>{const d=e.properties,[u,l]=S.useState(),[f,p]=S.useState(!1),[m,g]=S.useState(()=>new Set),[h,y]=S.useState("none"),w=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,v=e.validation?.find(G=>G.type==="fileSize"),x=e.validation?.find(G=>G.type==="fileType"),N=v?.value!=null?v.value:d?.maxSize??w?.maxSize??5*1024*1024,P=x?.value!=null?x.value:d?.accept??w?.accept??["image/*"],E=P.join(",")||"image/*",_=Bi(e),C=S.useCallback(G=>{if(v){const ee=Xr(G,v);if(ee!==!0)return typeof ee=="string"?ee:"File size exceeds the maximum allowed size"}else if(G.size>N)return`File size must be less than ${vo(N)}`;if(x){const ee=Xr(G,x);if(ee!==!0)return typeof ee=="string"?ee:"File type is not allowed"}return null},[v,x,N]),A=S.useMemo(()=>$i(t),[t]),O=rc(A),T=S.useCallback(G=>{const ee=Ia(G,_);r(ee),n?.()},[r,n,_]),z=S.useCallback(G=>{const ee=C(G);if(ee){l(ee);return}l(void 0);const de=[...A];de.length>=_||(de.push(G),T(de),y("none"))},[A,_,C,T]),q=S.useCallback(G=>{const ee=A.filter((de,ne)=>ne!==G);T(ee)},[A,T]),I=S.useCallback(()=>{i||A.length>=_||(l(void 0),y("camera"),p(!0))},[i,A.length,_]),$=S.useCallback(G=>{p(G),G||y("none")},[]),M=o||u,D=e.appearance?.hideLabel??!1,L=[];(v||N)&&L.push(`Max size: ${vo(N)}`),x&&P.length>0&&L.push(`Allowed: ${P.join(", ")}`),_>1&&L.push(`Up to ${_} photos`);const U=S.useCallback(G=>{window.open(G,"_blank","noopener,noreferrer")},[]),j=A.length===0,se=A.length<_,H=Zl(_,A.length);return c.jsxs(At,{field:e,error:M,isRequired:s,className:B(a,"!space-y-0"),hideLabel:D,children:[c.jsx("div",{className:"h-[70px] min-h-[70px] min-w-0 w-full flex flex-col",children:c.jsx("div",{role:"button",tabIndex:i||!se?-1:0,id:ht(e),onClick:G=>{i||G.target.closest("[data-remove-in-dropzone]")||G.target.closest("[data-no-open-picker]")||A.length>=_||I()},onKeyDown:G=>{(G.key==="Enter"||G.key===" ")&&(G.preventDefault(),!i&&se&&I())},className:B("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",M&&"border-destructive",i&&"opacity-50 cursor-not-allowed",f&&h==="camera"&&"opacity-70 pointer-events-none",!se&&A.length>0&&"cursor-default"),"aria-describedby":$t(e,!!M),"aria-invalid":Zt(!!M),"aria-required":s,children:j?c.jsxs(c.Fragment,{children:[c.jsx(Wi,{className:"mx-auto h-5 w-5 text-muted-foreground flex-shrink-0"}),c.jsx("p",{className:"text-[11px] text-muted-foreground leading-tight line-clamp-1",children:f?"Opening camera…":"Click to open camera"}),L.length>0&&c.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-1",children:L.join(" • ")})]}):H?c.jsx(nc,{item:A[0],objectUrl:O[0]??null,failedUrlKeys:m,onImageUrlError:G=>g(ee=>new Set(ee).add(G)),onRemove:()=>q(0),onOpenUrl:U,disabled:i}):c.jsx(tc,{items:A,maxFiles:_,disabled:i,objectUrls:O,failedUrlKeys:m,onImageUrlError:G=>g(ee=>new Set(ee).add(G)),onRemove:q,onOpenUrl:U,addSlot:se?c.jsxs("button",{type:"button","data-no-open-picker":!0,onClick:G=>{G.stopPropagation(),I()},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:[c.jsx(Wi,{className:"h-4 w-4 mb-0.5","aria-hidden":!0}),"Add"]}):void 0})})}),c.jsx(Sh,{open:f,onOpenChange:$,onCaptured:z,validateFile:C,accept:E,disabled:i,onValidationMessage:l})]})},AN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a,buttonResponses:d})=>{const u=e.properties,l=S.useRef(null),[f,p]=S.useState(),[m,g]=S.useState(!1),[h,y]=S.useState(()=>new Set),[w,v]=S.useState("none"),x=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,N=e.validation?.find(Z=>Z.type==="fileSize"),P=e.validation?.find(Z=>Z.type==="fileType"),E=N?.value?N.value:u?.maxSize??x?.maxSize??5*1024*1024,_=P?.value?P.value:u?.accept??x?.accept??["image/*"],C=Array.isArray(_)?_.join(","):"image/*",A=Bi(e),O=S.useCallback(Z=>{if(N){const te=Xr(Z,N);if(te!==!0)return typeof te=="string"?te:"File size exceeds the maximum allowed size"}else if(Z.size>E)return`File size must be less than ${vo(E)}`;if(P){const te=Xr(Z,P);if(te!==!0)return typeof te=="string"?te:"File type is not allowed"}return null},[N,P,E]),T=S.useMemo(()=>$i(t),[t]),z=rc(T),q=S.useCallback(Z=>{const te=Ia(Z,A);r(te),n?.()},[r,n,A]),I=S.useCallback(Z=>{p(void 0);const te=Array.from(Z),he=[...T];let le=null;for(const Xe of te){if(he.length>=A)break;const ge=O(Xe);if(ge){le||(le=ge);continue}he.push(Xe)}if(le&&he.length===T.length){p(le);return}le&&p(le),q(he),v("none")},[T,A,O,q]),$=S.useCallback(Z=>{const te=Z.target.files;te&&te.length>0&&I(te),l.current&&(l.current.value="")},[I]),M=S.useCallback(Z=>{q(T.filter((te,he)=>he!==Z))},[T,q]),D=S.useCallback(()=>{i||T.length>=A||m||(p(void 0),v("file"),l.current?.click())},[i,T.length,A,m]),L=S.useCallback(()=>{i||T.length>=A||(p(void 0),v("camera"),g(!0))},[i,T.length,A]),U=S.useCallback(Z=>{const te=O(Z);if(te){p(te);return}p(void 0);const he=[...T];he.length>=A||(he.push(Z),q(he),v("none"))},[T,A,O,q]),j=S.useCallback(Z=>{g(Z),Z||v("none")},[]),se=o||f,H=e.appearance?.hideLabel??!1,G=[];(N||E)&&G.push(`Max size: ${vo(E)}`),P&&_.length>0&&G.push(`Allowed: ${_.join(", ")}`),A>1&&G.push(`Up to ${A} photos`);const ee=S.useMemo(()=>{if(!d)return null;const Z=Object.values(d);for(let te=Z.length-1;te>=0;te-=1){const he=Z[te],le=typeof he?.status=="string"?he.status.toLowerCase():null;if(le&&le!=="success")continue;const Xe=he?.code;if(typeof Xe=="number"&&(Xe<200||Xe>=300))continue;const ge=he?.data,Se=ge?.file_url||ge?.fileUrl||he?.file_url||he?.fileUrl;if(typeof Se=="string"&&Se.trim())return Se.trim()}return null},[d]),de=S.useCallback(Z=>{window.open(Z,"_blank","noopener,noreferrer")},[]),ne=T.length===0,K=T.length<A,re=Zl(A,T.length),Te=K&&!m?c.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:[c.jsx("button",{type:"button",disabled:i,onClick:Z=>{Z.stopPropagation(),D()},className:"flex flex-1 w-full items-center justify-center hover:bg-primary/10 rounded-t","aria-label":"Upload file",title:"Upload",children:c.jsx(Gi,{className:"h-4 w-4","aria-hidden":!0})}),c.jsx("button",{type:"button",disabled:i,onClick:Z=>{Z.stopPropagation(),L()},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:c.jsx(Wi,{className:"h-4 w-4","aria-hidden":!0})})]}):void 0;return c.jsxs(At,{field:e,error:se,isRequired:s,className:B(a,"!space-y-0"),hideLabel:H,children:[c.jsx("div",{className:"h-[70px] min-h-[70px] min-w-0 w-full flex flex-col",children:c.jsxs("div",{className:B("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",se&&"border-destructive",i&&"opacity-50"),children:[c.jsx("input",{ref:l,id:ht(e),type:"file",accept:C,multiple:A>1,onChange:$,disabled:i||e.disabled||m||!K,className:"hidden","aria-describedby":$t(e,!!se),"aria-invalid":Zt(!!se),"aria-required":s}),ne?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-1 w-full pointer-events-auto",children:[c.jsxs("div",{className:"flex items-center justify-center gap-3",children:[c.jsxs("button",{type:"button",disabled:i||m,onClick:D,className:B("inline-flex flex-col items-center gap-0.5 text-[11px] text-muted-foreground hover:text-foreground",i&&"pointer-events-none"),children:[c.jsx(Gi,{className:"h-5 w-5","aria-hidden":!0}),c.jsx("span",{children:"Upload"})]}),c.jsxs("button",{type:"button",disabled:i,onClick:L,className:B("inline-flex flex-col items-center gap-0.5 text-[11px] text-muted-foreground hover:text-foreground",i&&"pointer-events-none",m&&"opacity-70"),children:[c.jsx(Wi,{className:"h-5 w-5","aria-hidden":!0}),c.jsx("span",{children:"Camera"})]})]}),G.length>0&&c.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-2 text-center px-1",children:G.join(" • ")})]}):re?c.jsx(nc,{item:T[0],objectUrl:z[0]??null,failedUrlKeys:h,onImageUrlError:Z=>y(te=>new Set(te).add(Z)),onRemove:()=>M(0),onOpenUrl:de,openTarget:T[0]instanceof File?ee:void 0,disabled:i||e.disabled}):c.jsx(tc,{items:T,maxFiles:A,disabled:i,objectUrls:z,failedUrlKeys:h,onImageUrlError:Z=>y(te=>new Set(te).add(Z)),onRemove:M,resolveOpenUrl:(Z,te)=>te instanceof File&&T.length===1&&ee?ee:null,onOpenUrl:Z=>{Z?.trim()&&de(Z.trim())},addSlot:Te})]})}),c.jsx(Sh,{open:m,onOpenChange:j,onCaptured:U,validateFile:O,accept:C,disabled:i,onValidationMessage:p})]})};function fi(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 wo(n)}}catch{}if(e.response){const r=e.response;if(typeof r=="string")try{const n=JSON.parse(r);return wo(n)}catch{return r}else if(typeof r=="object")return wo(r)}return t}if(e instanceof WA)return e.response?.data?wo(e.response.data):e.message||"An unexpected error occurred";if(typeof e=="string")try{const t=JSON.parse(e);return wo(t)}catch{return e}return typeof e=="object"&&e!==null?wo(e):"An unexpected error occurred"}function wo(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"}function CN(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 EN(e,t){try{const r=CN(e);Bt.toast.success(r&&r.trim()?r:t)}catch{Bt.toast.success(t)}}function ac(e,t,r){try{const n=r(e);Bt.toast.error(n&&n.trim()?n:t)}catch{Bt.toast.error(t)}}function NN(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 Rs="This field is required";function xh(e,t){if(!t?.length)return e;const r=t.find(n=>n.name===e);return r?.label&&r.label.trim()||e}function lc(e,t){if(!e)return"Please complete the required fields.";if(Array.isArray(e)){const i=e.map(s=>{const a=s.message||Rs;if(t?.length&&s.field){const d=xh(s.field,t);return a===Rs?`${d} is required`:`${d}: ${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()||Rs;if(t?.length){const a=xh(o,t);return s===Rs?`${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 cc(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,d=s.metadata,u=typeof d=="object"&&d!==null?d:null,l=a?.submitFieldMapping??u?.submitFieldMapping;if(l&&typeof l=="object"&&Object.keys(l).length>0){const f=i.map(p=>{if(p==null||typeof p!="object")return p;const m={};for(const[g,h]of Object.entries(l))g!=null&&g!==""&&h!=null&&h!==""&&(m[g]=Qe(p,h));return m});n[o]=f;continue}}n[o]=i}return n}function Gs(e){return!!(e instanceof File||Array.isArray(e)&&e.length>0&&e[0]instanceof File)}function _N(e){return Object.values(e).some(t=>Gs(t))}function kN(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 TN(e,t,r){const n={};let o=!1;return Object.entries(e).forEach(([i,s])=>{const a=t?.[i]||i;if(Gs(s)){n[a]=s,o=!0;return}const d=r?.[i]||"string";let u=s;if(d==="number"){const l=Number(s);u=isNaN(l)?s:l}else d==="boolean"?u=s==="true"||s===!0||s==="1"||s===1:d==="date"?u=String(s):s!=null?u=typeof s=="object"?s:String(s):u="";n[a]=u}),{transformed:n,hasFiles:o}}const Ah=Object.freeze(Object.defineProperty({__proto__:null,hasFileValues:_N,isFileValue:Gs,prepareFormDataWithFiles:kN,transformFormValuesWithFiles:TN},Symbol.toStringTag,{value:"Module"}));function FN(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 PN(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 d;if(n.fieldPayloadKeys&&typeof n.fieldPayloadKeys=="object"&&!Array.isArray(n.fieldPayloadKeys)){d={};for(const[u,l]of Object.entries(n.fieldPayloadKeys))typeof l=="string"&&l.trim()&&(d[u]=l.trim());Object.keys(d).length===0&&(d=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}:{},...d?{fieldPayloadKeys:d}:{},...n.heading&&typeof n.heading=="object"?{heading:n.heading}:{}})}return t.length>0?t:void 0}function Ch(e){return e?.mode==="nested_by_section"}function Eh(e){const t=e.payloadKey?.trim();return t||null}function Nh(e,t){return t.fieldPayloadKeys?.[e]?.trim()||e}function _h(e,t,r,n){if(!Ch(r)||!t?.length)return{...e};const o=new Set([]),i=r?.includeUnassignedAtRoot!==!1,s=new Set,a={};for(const d of t){const u=Eh(d);if(!u)continue;const l={};for(const f of d.fieldNames){if(o.has(f)||!(f in e))continue;s.add(f);const p=Nh(f,d);l[p]=e[f]}Object.keys(l).length>0&&(a[u]=l)}if(i)for(const[d,u]of Object.entries(e))o.has(d)||s.has(d)||(a[d]=u);return a}function ON(e,t,r){const n={...e??{}};if(!Ch(r)||!t?.length)return n;for(const o of t){const i=Eh(o);if(i)for(const s of o.fieldNames){if(n[s]?.trim())continue;const a=Nh(s,o);n[s]=`${i}.${a}`}}return n}function IN(e){return e==="null"?null:e==="true"?!0:e==="false"?!1:e}function MN(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 LN(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 d=s===n,u=s.startsWith(`${n}__addmore__`);if(!d&&!u||!MN(a))return;const l=Qe(a,o);l==null||l===""||i.push(l)}),i}function Ks(e,t,r,n,o,i){const s=e.trim().match(/^\{respAll:([^}]+)\}$/);if(s){const u=(s[1]||"").trim(),l=u.split("."),f=l.length>=2?l.slice(1).join("."):"";return(f==="data.id"||f==="data.documentId")&&n?.document_ids!=null&&Array.isArray(n.document_ids)?n.document_ids:LN(u,o)}const a=e.trim().match(/^\{(\w+)\}$/);if(a){const u=a[1],l=t[u];if(l!==void 0)return l;const f=Object.keys(t).find(p=>p.toLowerCase()===u.toLowerCase());if(f)return t[f]}const d=Wr(e,t,r,n,o,i);return IN(String(d))}const DN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:d,onClick:u,onSubmit:l,onReset:f,onCancel:p,isSubmitting:m=!1,formValues:g={},submissionContext:h,bffSubmitApi:y,onBffSubmitResult:w,extraSubmitPayload:v,buttonResponses:x,onButtonApiResponse:N,onValidateForm:P,getValidationErrors:E,allFields:_,onSubmittingChange:C,scopedFormValues:A,scopedFieldNameMap:O,prepopulateResponse:T=null,formSections:z,submitPayload:q})=>{const{gridStretch:I}=Vo(),[$,M]=S.useState(!1),D=e.properties,L=wa.useParams(),U=S.useMemo(()=>({...h,...v}),[h,v]),j=S.useMemo(()=>{if(!A||!O||Object.keys(O).length===0)return g;const Je={};return Object.entries(A).forEach(([Y,je])=>{const gt=O[Y]||Y;gt!==e.name&&(Je[gt]=je)}),Je},[A,O,g,e.name]),H=(()=>{try{const Je=e.metadata;if(typeof Je=="string")return JSON.parse(Je);if(Je&&typeof Je=="object")return Je}catch{}return null})(),G=D?.submitAction??H?.submitAction,ee=D?.apiEndpoint??e.apidata?.apiEndpoint??H?.apiEndpoint;let de=D?.action||H?.action;!de&&e.type==="button"&&(de="submit");const ne=D?.variant||"default",K=D?.size||"default",re=D?.hideLabel??e.appearance?.hideLabel??!1,Te=D?.buttonText||e.label||"Button",Z=D?.closeOnCancel??!0,te=async()=>{if(A&&O&&Object.keys(O).length>0||!P)return!0;const Je=await P();if(!Je&&E)try{const Y=E();Bt.toast.error(lc(Y,_??void 0)||"Please fix the errors before submitting.")}catch{Bt.toast.error("Please fix the errors before submitting.")}return Je},he=async Je=>{if(Je.preventDefault(),(de==="submit"?"submit":de)==="submit"){if(y?.url){if(!await te())return;M(!0),C?.(!0);try{const je=await Xe(),gt=(je?.message??je?.display_message??"Form submitted successfully!").trim();Bt.toast.success(gt||"Form submitted successfully!");const Ie=je!=null&&typeof je=="object"?je:{status:"success",...je!=null?{data:je}:{}};N?.(e.name,Ie)}catch(je){const gt=fi(je);Bt.toast.error(gt)}finally{M(!1),C?.(!1)}return}if(l){if(!await te())return;M(!0),C?.(!0);try{await l(),N?.(e.name,{status:"success"})}finally{M(!1),C?.(!1)}return}Bt.toast.error("Submit not configured. BFF submit API is required for submit buttons.");return}else if(de==="reset"&&f)f();else if(de==="cancel")Z?p&&p():f&&f();else if(de==="download"){const je=D?.downloadApiEndpoint||H?.downloadApiEndpoint||e.downloadApiEndpoint,gt=D?.downloadApiMethod||H?.downloadApiMethod||e.downloadApiMethod;if(je){M(!0);try{const Ie=gt||"GET",oe=rn(Wr(je,j,L,U,x,T??void 0)),pe={method:Ie,headers:{}};Ie!=="GET"&&Ie!=="DELETE"&&(pe.headers={"Content-Type":"application/json"});const We=await fetch(oe,pe);if(!We.ok)throw new Error(`Download failed: ${We.statusText}`);const Tt=await We.blob(),ze=window.URL.createObjectURL(Tt),Fe=document.createElement("a");Fe.href=ze;const Ke=We.headers.get("Content-Disposition");let nt="download";if(Ke){const yt=Ke.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);yt&&yt[1]&&(nt=yt[1].replace(/['"]/g,""))}Fe.download=nt,document.body.appendChild(Fe),Fe.click(),document.body.removeChild(Fe),window.URL.revokeObjectURL(ze);try{const yt=NN(We);Bt.toast.success(yt&&yt.trim()?yt:"Download started.")}catch{Bt.toast.success("Download started.")}}catch(Ie){ac(Ie,"Failed to download file. Please check the API endpoint and try again.",fi)}finally{M(!1)}}else Bt.toast.error("Download endpoint is not configured")}else if(de==="upload"||de==="custom"){const je=de==="custom",gt=je?"api":D?.uploadAction||H?.uploadAction||"database";if(gt==="database")if(l){M(!0);try{await l(Je)}catch(Ie){throw Ie}finally{M(!1)}}else Bt.toast.error("Form submit handler is not available");else if(gt==="api"){const Ie=D?.uploadApiEndpoint||H?.uploadApiEndpoint||e.uploadApiEndpoint;if(D?.uploadApiMethod||H?.uploadApiMethod||e.uploadApiMethod,Ie){if(!await te())return;M(!0);try{const oe=await ge();N?.(e.name,oe),EN(oe,je?"Custom API call completed successfully!":"Upload completed successfully!")}catch(oe){N?.(e.name,{status:"error",code:oe?.response?.code??oe?.response?.status??null,message:fi(oe)}),ac(oe,je?"Failed to call custom API. Please check the API endpoint and try again.":"Failed to upload. Please check the API endpoint and try again.",fi)}finally{M(!1)}}else Bt.toast.error(je?"Custom API endpoint is not configured":"Upload endpoint is not configured")}else gt==="custom"&&Bt.toast.info("Custom upload handler is not implemented")}else u?u():r&&t!==void 0&&r(t||"");n?.()},le=async()=>{if(!G||G!=="api"||!ee)return null;const Je=D?.apiBodyFields??H?.apiBodyFields;if((D?.apiBodyFieldsOnly??H?.apiBodyFieldsOnly??!1)&&Je?.length){const Fe={};return Je.forEach(({key:Ke,value:nt})=>{const yt=Ks(nt,j,L,U,x,T??void 0),Yt=Ke==="user_id"?"context_user_id":Ke;Fe[Yt]=yt}),Fe.user_id!==void 0&&Fe.user_id!==null&&(Fe.context_user_id=Fe.context_user_id??Fe.user_id,delete Fe.user_id),Fe}const je=_?.length?cc(j,_):j,gt=D?.apiFieldMapping??H?.apiFieldMapping,Ie=D?.apiFieldTypes??H?.apiFieldTypes,oe=D?.apiBodyStructure??H?.apiBodyStructure,pe={...Ie};_?.length&&_.forEach(Fe=>{const Ke=Fe.name||Fe.key;Ke&&(Fe.type==="terms"||Fe.type==="checkbox")&&(pe[Ke]="boolean")});const{transformFormValuesWithFiles:We}=await Promise.resolve().then(()=>Ah),{transformed:Tt}=We(je,gt,pe);let ze={};if(oe==="flat"?ze={...Tt}:ze={data:{...Tt}},gt){const Fe={};Object.keys(ze).forEach(Ke=>{const nt=gt[Ke]||Ke;Fe[nt]=ze[Ke]}),ze=Fe}return Je?.length&&Je.forEach(({key:Fe,value:Ke})=>{const nt=Ks(Ke,j,L,U,x,T??void 0),yt=Fe==="user_id"?"context_user_id":Fe;ze[yt]=nt}),ze.user_id!==void 0&&ze.user_id!==null&&(ze.context_user_id=ze.context_user_id??ze.user_id,delete ze.user_id),ze.data?.user_id!==void 0&&ze.data?.user_id!==null&&(ze.data.context_user_id=ze.data.context_user_id??ze.data.user_id,delete ze.data.user_id),ze},Xe=async()=>{if(!y||!y.url)throw new Error("BFF submit API configuration is missing");const Je=_?.length?cc(g,_):g,Y={};Object.keys(Je).forEach(Pe=>{const ft=e.name===Pe&&e.type==="button",et=Pe.toLowerCase().includes("button");!ft&&!et&&(Y[Pe]=Je[Pe])});const je=Object.keys(Y).filter(Pe=>Gs(Y[Pe]));je.forEach(Pe=>{Y[Pe]=""});const gt=_h(Y,z,q),Ie={workflow_id:y.payload?.workflow_id||"",current_step_id:y.payload?.current_step_id||"",form_data:gt},oe=["workflow_id","current_step_id","form_data","submit_body","submit_api_endpoint","submit_api_method"];if(h&&typeof h=="object"&&Object.entries(h).forEach(([Pe,ft])=>{if(ft==null||oe.includes(Pe))return;const et=Pe==="user_id"?"context_user_id":Pe;Ie[et]=Ie[et]??ft}),v&&typeof v=="object"&&Object.entries(v).forEach(([Pe,ft])=>{if(ft==null||oe.includes(Pe))return;const et=Pe==="user_id"?"context_user_id":Pe;Ie[et]=Ie[et]??ft}),G==="api"&&ee)try{const Pe=await le();if(Pe){const ft=D?.apiBodyStructure??H?.apiBodyStructure,et=D?.apiFieldMapping??H?.apiFieldMapping;je.forEach(ur=>{const on=et?.[ur]??ur,Nr=Y[ur]!==void 0&&typeof Y[ur]=="string"?Y[ur]:"";ft==="flat"?Pe[on]=Nr:Pe.data&&typeof Pe.data=="object"?Pe.data[on]=Nr:Pe[on]=Nr}),Ie.submit_body=Pe;let xt=Wr(ee,j,L,U,x,T??void 0);xt=xt.replace(/\{([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\}/gi,"$1"),xt=rn(xt),Ie.submit_api_endpoint=xt,Ie.submit_api_method=D?.submitApiMethod||H?.submitApiMethod||"POST"}}catch{}const pe=(y.method||"POST").toUpperCase(),We=je.length>0,Tt=Ie.submit_api_endpoint??ee??"",ze=typeof Tt=="string"?Tt.toLowerCase():"",Fe=ze.includes("/upload")||ze.includes("/payments")||ze.includes("/bulk-upload"),Ke=We&&Fe;let nt;const yt={...y.headers||{}};if(Ke){const Pe=new FormData;Pe.append("payload",JSON.stringify(Ie));for(const ft of je){const et=Je[ft],xt=D?.apiFieldMapping?.[ft]??ft;et instanceof File?Pe.append(xt,et):Array.isArray(et)&&et.length>0&&et[0]instanceof File&&et.forEach(ur=>Pe.append(xt,ur))}nt=Pe,delete yt["content-type"],delete yt["Content-Type"]}else yt["Content-Type"]="application/json",nt=JSON.stringify(Ie);const Yt=await fetch(y.url,{method:pe,headers:yt,body:nt});if(!Yt.ok){let Pe;const ft=await Yt.text();try{Pe=JSON.parse(ft)}catch{Pe={message:ft}}const et=new Error(`BFF submission failed: ${Yt.status}`);throw et.response=Pe,et}const St=await Yt.json();return w?.(St),l&&await l(),St},ge=async()=>{const Je=D?.uploadApiEndpoint||H?.uploadApiEndpoint;if(!Je)throw new Error("Upload API endpoint is not configured");if(!D)throw new Error("Button properties are not configured");const Y=(D.uploadApiMethod||"POST").toUpperCase(),je=rn(Wr(Je,j,L,U,x,T??void 0)),gt=D.apiBodyFieldsOnly??H?.apiBodyFieldsOnly??!1,Ie=D.apiBodyFieldsOnlyFormat??H?.apiBodyFieldsOnlyFormat??"json";let oe={},pe;const We={};if(gt&&D.apiBodyFields&&D.apiBodyFields.length>0)if(D.apiBodyFields.forEach(({key:Fe,value:Ke})=>{oe[Fe]=Ks(Ke,j,L,U,x,T??void 0)}),Ie==="multipart"){const Fe=new FormData;Object.entries(oe).forEach(([Ke,nt])=>{if(nt instanceof File){Fe.append(Ke,nt);return}if(Array.isArray(nt)&&nt.length>0&&nt[0]instanceof File){nt.forEach(yt=>Fe.append(Ke,yt));return}nt!=null&&Fe.append(Ke,typeof nt=="object"?JSON.stringify(nt):String(nt))}),pe=Fe}else pe=JSON.stringify(oe),We["Content-Type"]="application/json";else{const Fe=j,{transformFormValuesWithFiles:Ke,prepareFormDataWithFiles:nt,hasFileValues:yt}=await Promise.resolve().then(()=>Ah),{transformed:Yt,hasFiles:St}=Ke(Fe,D.apiFieldMapping,D.apiFieldTypes);if((D.apiBodyStructure??H?.apiBodyStructure??"nested")==="flat"?oe={...Yt}:oe={data:{...Yt}},D.apiFieldMapping){const ft={};Object.keys(oe).forEach(et=>{const xt=D.apiFieldMapping[et]||et;ft[xt]=oe[et]}),oe=ft}if(D.apiBodyFields&&D.apiBodyFields.forEach(({key:ft,value:et})=>{oe[ft]=Ks(et,j,L,U,x,T??void 0)}),St||yt(oe)){const ft=nt(oe,D.apiFieldMapping);ft?pe=ft:(pe=JSON.stringify(oe),We["Content-Type"]="application/json")}else pe=JSON.stringify(oe),We["Content-Type"]="application/json"}D.apiHeaders&&D.apiHeaders.forEach(({key:Fe,value:Ke})=>{const nt=Wr(Ke,j,L,U,x,T??void 0);(Fe.toLowerCase()!=="content-type"||!(pe instanceof FormData))&&(We[Fe]=nt)});let Tt=je;if(D.apiQueryParams&&D.apiQueryParams.length>0){const Fe=new URLSearchParams;D.apiQueryParams.forEach(({key:Ke,value:nt})=>{const yt=Wr(nt,j,L,U,x,T??void 0);Fe.append(Ke,yt)}),Tt=`${je}?${Fe.toString()}`}const ze=await fetch(Tt,{method:Y,headers:We,body:Y!=="GET"?pe:void 0});if(!ze.ok){let Fe;const Ke=await ze.text();try{Fe=JSON.parse(Ke)}catch{Fe={message:Ke}}const nt=new Error(`Upload failed: ${ze.status}`);throw nt.response=Fe,nt}try{return await ze.json()}catch{return{}}},Se=de==="submit"?"submit":de,ve=Se==="submit"?"button":Se==="submit"?"submit":Se==="reset"?"reset":"button",He=i||e.disabled||s||e.readOnly||$||Se==="submit"&&m,dt=Te,Ge=ro(e),Rt=Tr(e.appearance)==="stretch";return c.jsx(At,{field:e,error:o,isRequired:a,className:d,hideLabel:re,children:c.jsx("div",{className:B(I&&!Ge&&"flex w-full min-w-0 flex-col",I&&Ge&&"min-w-0 shrink-0"),children:c.jsxs(Kt,{id:ht(e),type:ve,variant:ne,size:K,disabled:He,onClick:he,className:B(e.appearance?.className,I&&!Ge&&"w-full min-w-0 shrink-0",I&&Ge&&!Rt&&"inline-flex w-auto max-w-full shrink-0",I&&Ge&&Rt&&"inline-flex w-full min-w-0 max-w-full shrink-0"),children:[$&&c.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]})})})},BN=({field:e,disabled:t,readOnly:r,isRequired:n,className:o,buttonResponses:i,onButtonApiResponse:s})=>{const a=e.properties,d=a?.buttonText??e.label??"Edit",u=a?.variant??"outline",l=a?.size??"default",f=a?.hideLabel??e.appearance?.hideLabel??!1,p=e.name||e.key||e.id,m=Wo(i?.[p]),g=t||e.disabled||r||e.readOnly||m,h=y=>{y.preventDefault(),!g&&s?.(p,{status:"success"})};return c.jsx(At,{field:e,error:void 0,isRequired:n,className:o,hideLabel:f,children:c.jsx(Kt,{id:ht(e),type:"button",variant:u,size:l,disabled:g,onClick:h,className:B(e.appearance?.className,(!ro(e)||Tr(e.appearance)==="stretch")&&"w-full min-w-0"),children:d})})},$N=({field:e,error:t,disabled:r,readOnly:n,isRequired:o,className:i,onAddMore:s})=>{const a=e.properties||{},d=a.variant||"outline",u=a.size||"default",l=a.buttonText||e.label||"Add More",f=a.hideLabel??e.appearance?.hideLabel??!1,p=r||n||e.disabled||e.readOnly;return c.jsx(At,{field:e,error:t,isRequired:o,className:i,hideLabel:f,children:c.jsxs(Kt,{id:ht(e),type:"button",variant:d,size:u,disabled:!!p,onClick:s,className:B("w-fit",e.appearance?.className),children:[c.jsx(du,{className:"h-4 w-4 mr-1"}),l]})})},kh=S.createContext(null);function jN({value:e,children:t}){return c.jsx(kh.Provider,{value:e,children:t})}function zN(){return S.useContext(kh)}function Th(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(0,t):e}function pi(e){return e.name||e.key||e.id}function dc(e){return e.filter(t=>!t.parentId&&t.type==="sectionHeading"&&pi(t))}function UN(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 VN(e){const t=new Map;for(const r of dc(e)){const n=pi(r);for(const o of UN(r))t.set(o,n)}return t}function HN(e,t){const r=t.properties||{},n=Array.isArray(r.sectionHeadingNames)?r.sectionHeadingNames.filter(s=>typeof s=="string"&&s.trim()):[],o=dc(e);if(n.length===0)return o;const i=new Set(n);return o.filter(s=>i.has(pi(s)))}function WN(e){const t={};for(const r of dc(e))t[pi(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 Fh(e,t,r,n){if(!e||t==="customizeSections")return!0;const o=Th(e),i=t==="sectionHeading"?o:n.get(o);return i?r[i]!==!1:!0}const RN=({field:e,error:t,disabled:r,readOnly:n,isRequired:o,className:i,designMode:s=!1})=>{const a=zN(),d=e.properties||{},u=d.variant||"outline",l=d.size||"default",f=d.buttonText||e.label||"Customise sections",p=d.menuTitle||"VISIBLE SECTIONS",m=d.hideLabel??e.appearance?.hideLabel??!1,g=r||n||e.disabled||e.readOnly,h=S.useMemo(()=>a?.allFields?.length?HN(a.allFields,e):[],[a?.allFields,e]);return c.jsx(At,{field:e,error:t,isRequired:o,className:i,hideLabel:m,children:c.jsxs(Ul,{children:[c.jsx(em,{asChild:!0,children:c.jsxs(Kt,{id:ht(e),type:"button",variant:u,size:l,disabled:!!g,className:B("w-fit gap-2",e.appearance?.className),children:[c.jsx(Uv,{className:"h-4 w-4"}),f]})}),c.jsxs(Vl,{align:"end",className:"w-64 p-0",children:[c.jsx("div",{className:"px-3 py-2 border-b",children:c.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:p})}),c.jsx("div",{className:"max-h-64 overflow-auto p-2 space-y-1",children:h.length===0?c.jsx("p",{className:"text-xs text-muted-foreground px-1 py-2",children:"No section headings on this form."}):h.map(y=>{const w=pi(y),v=y.label||w,x=s||!a?!0:a.visibility[w]!==!1;return c.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md px-1 py-1.5 hover:bg-muted/50",children:[c.jsx(Cn,{htmlFor:`ui-section-${e.id}-${w}`,className:"text-xs font-normal truncate",children:v}),c.jsx(Bm,{id:`ui-section-${e.id}-${w}`,checked:x,disabled:s||!a||!!g,onCheckedChange:N=>{!a||s||a.setSectionVisible(w,!!N)}})]},y.id)})})]})]})})},GN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:d})=>{const u=e.properties,l=u?.max||5,f=u?.icon||"star",p=h=>{i||s||e.disabled||e.readOnly||(r(h),n?.())},m=h=>{},g=h=>{const y=t>=h+1,w=B("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 f==="star"?c.jsx(uu,{className:B(w,"h-6 w-6"),onClick:()=>p(h+1),onMouseEnter:()=>m()},h):c.jsx(uu,{className:B(w,"h-6 w-6"),onClick:()=>p(h+1),onMouseEnter:()=>m()},h)};return c.jsx(At,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{id:ht(e),className:"flex items-center gap-1",role:"radiogroup","aria-label":e.label,"aria-describedby":$t(e,!!o),"aria-invalid":Zt(!!o),"aria-required":a,children:[Array.from({length:l},(h,y)=>g(y)),u?.showValue!==!1&&c.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:t>0?t:""})]})})};var Ph=["PageUp","PageDown"],Oh=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Ih={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},So="Slider",[uc,KN,qN]=Wa(So),[Mh]=xr(So,[qN]),[YN,qs]=Mh(So),Lh=b.forwardRef((e,t)=>{const{name:r,min:n=0,max:o=100,step:i=1,orientation:s="horizontal",disabled:a=!1,minStepsBetweenThumbs:d=0,defaultValue:u=[n],value:l,onValueChange:f=()=>{},onValueCommit:p=()=>{},inverted:m=!1,form:g,...h}=e,y=b.useRef(new Set),w=b.useRef(0),x=s==="horizontal"?XN:JN,[N=[],P]=en({prop:l,defaultProp:u,onChange:T=>{[...y.current][w.current]?.focus(),f(T)}}),E=b.useRef(N);function _(T){const z=r_(N,T);O(T,z)}function C(T){O(T,w.current)}function A(){const T=E.current[w.current];N[w.current]!==T&&p(N)}function O(T,z,{commit:q}={commit:!1}){const I=s_(i),$=a_(Math.round((T-n)/i)*i+n,I),M=Jo($,[n,o]);P((D=[])=>{const L=e_(D,M,z);if(i_(L,d*i)){w.current=L.indexOf(M);const U=String(L)!==String(D);return U&&q&&p(L),U?L:D}else return D})}return c.jsx(YN,{scope:e.__scopeSlider,name:r,disabled:a,min:n,max:o,valueIndexToChangeRef:w,thumbs:y.current,values:N,orientation:s,form:g,children:c.jsx(uc.Provider,{scope:e.__scopeSlider,children:c.jsx(uc.Slot,{scope:e.__scopeSlider,children:c.jsx(x,{"aria-disabled":a,"data-disabled":a?"":void 0,...h,ref:t,onPointerDown:Le(h.onPointerDown,()=>{a||(E.current=N)}),min:n,max:o,inverted:m,onSlideStart:a?void 0:_,onSlideMove:a?void 0:C,onSlideEnd:a?void 0:A,onHomeKeyDown:()=>!a&&O(n,0,{commit:!0}),onEndKeyDown:()=>!a&&O(o,N.length-1,{commit:!0}),onStepKeyDown:({event:T,direction:z})=>{if(!a){const $=Ph.includes(T.key)||T.shiftKey&&Oh.includes(T.key)?10:1,M=w.current,D=N[M],L=i*$*z;O(D+L,M,{commit:!0})}}})})})})});Lh.displayName=So;var[Dh,Bh]=Mh(So,{startEdge:"left",endEdge:"right",size:"width",direction:1}),XN=b.forwardRef((e,t)=>{const{min:r,max:n,dir:o,inverted:i,onSlideStart:s,onSlideMove:a,onSlideEnd:d,onStepKeyDown:u,...l}=e,[f,p]=b.useState(null),m=Ze(t,x=>p(x)),g=b.useRef(void 0),h=no(o),y=h==="ltr",w=y&&!i||!y&&i;function v(x){const N=g.current||f.getBoundingClientRect(),P=[0,N.width],_=mc(P,w?[r,n]:[n,r]);return g.current=N,_(x-N.left)}return c.jsx(Dh,{scope:e.__scopeSlider,startEdge:w?"left":"right",endEdge:w?"right":"left",direction:w?1:-1,size:"width",children:c.jsx($h,{dir:h,"data-orientation":"horizontal",...l,ref:m,style:{...l.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:x=>{const N=v(x.clientX);s?.(N)},onSlideMove:x=>{const N=v(x.clientX);a?.(N)},onSlideEnd:()=>{g.current=void 0,d?.()},onStepKeyDown:x=>{const P=Ih[w?"from-left":"from-right"].includes(x.key);u?.({event:x,direction:P?-1:1})}})})}),JN=b.forwardRef((e,t)=>{const{min:r,max:n,inverted:o,onSlideStart:i,onSlideMove:s,onSlideEnd:a,onStepKeyDown:d,...u}=e,l=b.useRef(null),f=Ze(t,l),p=b.useRef(void 0),m=!o;function g(h){const y=p.current||l.current.getBoundingClientRect(),w=[0,y.height],x=mc(w,m?[n,r]:[r,n]);return p.current=y,x(h-y.top)}return c.jsx(Dh,{scope:e.__scopeSlider,startEdge:m?"bottom":"top",endEdge:m?"top":"bottom",size:"height",direction:m?1:-1,children:c.jsx($h,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:h=>{const y=g(h.clientY);i?.(y)},onSlideMove:h=>{const y=g(h.clientY);s?.(y)},onSlideEnd:()=>{p.current=void 0,a?.()},onStepKeyDown:h=>{const w=Ih[m?"from-bottom":"from-top"].includes(h.key);d?.({event:h,direction:w?-1:1})}})})}),$h=b.forwardRef((e,t)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:o,onSlideEnd:i,onHomeKeyDown:s,onEndKeyDown:a,onStepKeyDown:d,...u}=e,l=qs(So,r);return c.jsx($e.span,{...u,ref:t,onKeyDown:Le(e.onKeyDown,f=>{f.key==="Home"?(s(f),f.preventDefault()):f.key==="End"?(a(f),f.preventDefault()):Ph.concat(Oh).includes(f.key)&&(d(f),f.preventDefault())}),onPointerDown:Le(e.onPointerDown,f=>{const p=f.target;p.setPointerCapture(f.pointerId),f.preventDefault(),l.thumbs.has(p)?p.focus():n(f)}),onPointerMove:Le(e.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&o(f)}),onPointerUp:Le(e.onPointerUp,f=>{const p=f.target;p.hasPointerCapture(f.pointerId)&&(p.releasePointerCapture(f.pointerId),i(f))})})}),jh="SliderTrack",zh=b.forwardRef((e,t)=>{const{__scopeSlider:r,...n}=e,o=qs(jh,r);return c.jsx($e.span,{"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation,...n,ref:t})});zh.displayName=jh;var fc="SliderRange",Uh=b.forwardRef((e,t)=>{const{__scopeSlider:r,...n}=e,o=qs(fc,r),i=Bh(fc,r),s=b.useRef(null),a=Ze(t,s),d=o.values.length,u=o.values.map(p=>Wh(p,o.min,o.max)),l=d>1?Math.min(...u):0,f=100-Math.max(...u);return c.jsx($e.span,{"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,...n,ref:a,style:{...e.style,[i.startEdge]:l+"%",[i.endEdge]:f+"%"}})});Uh.displayName=fc;var pc="SliderThumb",Vh=b.forwardRef((e,t)=>{const r=KN(e.__scopeSlider),[n,o]=b.useState(null),i=Ze(t,a=>o(a)),s=b.useMemo(()=>n?r().findIndex(a=>a.ref.current===n):-1,[r,n]);return c.jsx(QN,{...e,ref:i,index:s})}),QN=b.forwardRef((e,t)=>{const{__scopeSlider:r,index:n,name:o,...i}=e,s=qs(pc,r),a=Bh(pc,r),[d,u]=b.useState(null),l=Ze(t,v=>u(v)),f=d?s.form||!!d.closest("form"):!0,p=ei(d),m=s.values[n],g=m===void 0?0:Wh(m,s.min,s.max),h=t_(n,s.values.length),y=p?.[a.size],w=y?n_(y,g,a.direction):0;return b.useEffect(()=>{if(d)return s.thumbs.add(d),()=>{s.thumbs.delete(d)}},[d,s.thumbs]),c.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${g}% + ${w}px)`},children:[c.jsx(uc.ItemSlot,{scope:e.__scopeSlider,children:c.jsx($e.span,{role:"slider","aria-label":e["aria-label"]||h,"aria-valuemin":s.min,"aria-valuenow":m,"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:l,style:m===void 0?{display:"none"}:e.style,onFocus:Le(e.onFocus,()=>{s.valueIndexToChangeRef.current=n})})}),f&&c.jsx(Hh,{name:o??(s.name?s.name+(s.values.length>1?"[]":""):void 0),form:s.form,value:m},n)]})});Vh.displayName=pc;var ZN="RadioBubbleInput",Hh=b.forwardRef(({__scopeSlider:e,value:t,...r},n)=>{const o=b.useRef(null),i=Ze(o,n),s=ti(t);return b.useEffect(()=>{const a=o.current;if(!a)return;const d=window.HTMLInputElement.prototype,l=Object.getOwnPropertyDescriptor(d,"value").set;if(s!==t&&l){const f=new Event("input",{bubbles:!0});l.call(a,t),a.dispatchEvent(f)}},[s,t]),c.jsx($e.input,{style:{display:"none"},...r,ref:i,defaultValue:t})});Hh.displayName=ZN;function e_(e=[],t,r){const n=[...e];return n[r]=t,n.sort((o,i)=>o-i)}function Wh(e,t,r){const i=100/(r-t)*(e-t);return Jo(i,[0,100])}function t_(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function r_(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 n_(e,t,r){const n=e/2,i=mc([0,50],[0,n]);return(n-i(t)*r)*r}function o_(e){return e.slice(0,-1).map((t,r)=>e[r+1]-t)}function i_(e,t){if(t>0){const r=o_(e);return Math.min(...r)>=t}return!0}function mc(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 s_(e){return(String(e).split(".")[1]||"").length}function a_(e,t){const r=Math.pow(10,t);return Math.round(e*r)/r}var l_=Lh,c_=zh,d_=Uh,u_=Vh;function f_({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 c.jsxs(l_,{"data-slot":"slider",defaultValue:t,value:r,min:n,max:o,className:B("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:[c.jsx(c_,{"data-slot":"slider-track",className:B("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:c.jsx(d_,{"data-slot":"slider-range",className:B("bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")})}),Array.from({length:s.length},(a,d)=>c.jsx(u_,{"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"},d))]})}const p_=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:d})=>{const u=e.properties,l=u?.min??0,f=u?.max??100,p=u?.step??1,m=u?.showValue!==!1,g=u?.marks||[],h=w=>{i||s||e.disabled||e.readOnly||(r(w[0]??l),n?.())},y=t??l;return c.jsx(At,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[m&&c.jsx("span",{className:"text-sm font-medium",children:y}),!m&&c.jsx("span",{className:"text-sm text-muted-foreground",children:l}),!m&&c.jsx("span",{className:"text-sm text-muted-foreground",children:f})]}),c.jsx(f_,{id:ht(e),value:[y],onValueChange:h,min:l,max:f,step:p,disabled:i||e.disabled||s||e.readOnly,className:B("w-full",o&&"border-destructive",e.appearance?.className),"aria-describedby":$t(e,!!o),"aria-invalid":Zt(!!o),"aria-required":a}),g.length>0&&c.jsx("div",{className:"flex justify-between text-xs text-muted-foreground",children:g.map((w,v)=>c.jsx("span",{className:"text-center",children:w.label},v))})]})})},m_=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:d})=>{const u=S.useRef(null),[l,f]=S.useState(!1),p=i||e.disabled||s||e.readOnly,m=S.useCallback(w=>{if(p)return;f(!0);const v=u.current;if(!v)return;const x=v.getContext("2d");if(!x)return;const N=v.getBoundingClientRect(),P="touches"in w?w.touches[0].clientX-N.left:w.clientX-N.left,E="touches"in w?w.touches[0].clientY-N.top:w.clientY-N.top;x.beginPath(),x.moveTo(P,E)},[p]),g=S.useCallback(w=>{if(!l||p)return;const v=u.current;if(!v)return;const x=v.getContext("2d");if(!x)return;const N=v.getBoundingClientRect(),P="touches"in w?w.touches[0].clientX-N.left:w.clientX-N.left,E="touches"in w?w.touches[0].clientY-N.top:w.clientY-N.top;x.lineWidth=2,x.lineCap="round",x.strokeStyle="#000",x.lineTo(P,E),x.stroke(),x.beginPath(),x.moveTo(P,E)},[l,p]),h=S.useCallback(()=>{if(!l)return;f(!1);const w=u.current;if(!w)return;const v=w.toDataURL();r(v),n?.()},[l,r,n]),y=S.useCallback(()=>{const w=u.current;if(!w||p)return;const v=w.getContext("2d");v&&(v.clearRect(0,0,w.width,w.height),r(null),n?.())},[p,r,n]);return S.useEffect(()=>{const w=u.current;if(w&&(w.width=w.offsetWidth,w.height=200,t)){const v=new Image;v.onload=()=>{const x=w.getContext("2d");x&&x.drawImage(v,0,0)},v.src=t}},[t]),c.jsx(At,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{className:"space-y-2",children:[c.jsx("div",{className:B("border-2 border-dashed rounded-lg overflow-hidden",o&&"border-destructive",p&&"opacity-50 cursor-not-allowed"),children:c.jsx("canvas",{ref:u,id:ht(e),className:"w-full cursor-crosshair touch-none",onMouseDown:m,onMouseMove:g,onMouseUp:h,onMouseLeave:h,onTouchStart:m,onTouchMove:g,onTouchEnd:h,"aria-describedby":$t(e,!!o),"aria-invalid":Zt(!!o),"aria-required":a,style:{height:"200px"}})}),!p&&c.jsx("div",{className:"flex justify-end",children:c.jsxs(Kt,{type:"button",variant:"outline",size:"sm",onClick:y,className:"text-xs",children:[c.jsx(Yo,{className:"h-3 w-3 mr-1"}),"Clear"]})})]})})},h_=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:d,hideRowControls:u=!1,formValues:l,submissionContext:f})=>{const p=e.properties,m=p?.columns||[],g=p?.minRows||1,h=p?.maxRows||10,y=!u&&p?.allowAddRow!==!1,w=!u&&p?.allowDeleteRow!==!1,v=i===!1&&s===!1?!1:i||e.disabled||s||e.readOnly,x=t||[],N=y&&x.length<h,P=w&&x.length>g,E=S.useCallback(()=>{if(!N||v)return;const I={};m.forEach($=>{I[$.name]=$.defaultValue??""}),r([...x,I]),n?.()},[x,m,N,v,r,n]),_=S.useCallback(I=>{if(!P||v)return;const $=x.filter((M,D)=>D!==I);r($),n?.()},[x,P,v,r,n]),C=S.useCallback((I,$,M)=>{if(v)return;const D=[...x];D[I]||(D[I]={}),D[I][$]=M,r(D),n?.()},[x,v,r,n]);if(S.useEffect(()=>{if(x.length<g){const I=g-x.length,$=[];for(let M=0;M<I;M++){const D={};m.forEach(L=>{D[L.name]=L.defaultValue??""}),$.push(D)}r([...x,...$])}},[g,m,r,x.length]),m.length===0)return c.jsx(At,{field:e,error:o,isRequired:a,className:d,children:c.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 A=Math.max(1,e.position?.rowSpan??1),O=Math.max(1,e.position?.columnSpan??1),T=Math.max(x.length,1),z=A>=3?"py-4":A>=2?"py-3":"py-2.5",q=O>=3?"px-4":O>=2?"px-3":"px-4";return c.jsx(At,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{id:ht(e),className:B("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":$t(e,!!o),"aria-invalid":Zt(!!o),"aria-required":a,children:[c.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:c.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:[c.jsx("thead",{children:c.jsxs("tr",{className:"border-b border-border bg-muted/60",children:[m.map(I=>c.jsxs("th",{className:B(q,z,"text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground whitespace-nowrap"),children:[I.label,a&&I.validation?.some($=>$.type==="required")&&c.jsx("span",{className:"text-destructive ml-1",children:"*"})]},I.id)),w&&c.jsx("th",{className:"w-12"})]})}),c.jsx("tbody",{className:"h-full",children:x.length===0?c.jsx("tr",{children:c.jsx("td",{colSpan:m.length+(w?1:0),className:B(q,"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.'})}):x.map((I,$)=>{const M=x[$],D=M&&typeof M=="object"&&!Array.isArray(M)?{...l??{},...M}:l;return c.jsxs("tr",{className:"border-b border-border/50 hover:bg-muted/30 transition-colors last:border-b-0",style:{height:`${100/T}%`},children:[m.map(L=>{const U={...L,name:`${e.name}_${$}_${L.name}`,appearance:{...L.appearance,hideLabel:!0}},j=L.name??"",se=I[j]!==void 0?I[j]:j&&Object.keys(I).find(K=>K.toLowerCase()===j.toLowerCase())?I[Object.keys(I).find(K=>K.toLowerCase()===j.toLowerCase())]:void 0,H=!!L.readOnly,G=K=>{if(K==null)return"";if(Array.isArray(K))return K.map(re=>typeof re=="object"&&re!==null&&"name"in re?String(re.name??re):String(re)).join(", ");if(typeof K=="object"&&K!==null&&!(K instanceof Date)){const re=K;return typeof re.name=="string"&&typeof re.code=="string"?`${re.code} ${re.name}`.trim():typeof re.name=="string"?re.name:typeof re.code=="string"?re.code:String(re.name??re.code??K)}return String(K)},ee=K=>typeof K=="object"&&K!==null&&!Array.isArray(K)?G(K):String(K??""),de=L.name?.toLowerCase()==="type"||L.label?.toLowerCase()==="type";if(H){const K=G(se);return c.jsx("td",{className:"px-4 py-2.5 align-middle first:pl-6 last:pr-6",children:c.jsx("div",{className:"min-w-[120px] text-sm text-foreground",children:de&&K?c.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:K}):c.jsx("span",{className:"py-1 block",children:K})})},L.id)}const ne=()=>{switch(L.type){case"text":case"password":case"url":return c.jsx(Hi,{field:U,value:ee(se),onChange:K=>C($,L.name,K),disabled:v,readOnly:v,className:"w-full"});case"number":return c.jsx(Ha,{field:U,value:se??null,onChange:K=>C($,L.name,K),disabled:v,readOnly:v,className:"w-full"});case"email":return c.jsx(fu,{field:U,value:ee(se),onChange:K=>C($,L.name,K),disabled:v,readOnly:v,className:"w-full"});case"phone":case"aadhaar":return c.jsx(pu,{field:U,value:ee(se),onChange:K=>C($,L.name,K),disabled:v,readOnly:v,className:"w-full"});case"textarea":return c.jsx(mu,{field:U,value:ee(se),onChange:K=>C($,L.name,K),disabled:v,readOnly:v,className:"w-full"});case"select":return c.jsx(jp,{field:U,value:typeof se=="string"?se:ee(se),onChange:K=>C($,L.name,K),disabled:v,className:"w-full",formValues:D,submissionContext:f});case"multiselect":{const K=Array.isArray(se)?se:se!=null&&se!==""?[String(se)]:[];return c.jsx(Fm,{field:U,value:K,onChange:re=>C($,L.name,re),disabled:v,className:"w-full",formValues:D,submissionContext:f})}case"asyncsearch":return c.jsx(am,{field:U,value:se,onChange:K=>C($,L.name,K),disabled:v,readOnly:v,className:"w-full",formValues:D,submissionContext:f});case"checkbox":return c.jsx(Pm,{field:U,value:se||!1,onChange:K=>C($,L.name,K),disabled:v,className:"w-full"});case"radio":case"checkboxgroup":return c.jsx(nh,{field:U,value:typeof se=="string"?se:ee(se),onChange:K=>C($,L.name,K),disabled:v,className:"w-full"});case"date":case"time":case"datetime":case"daterange":return c.jsx(oh,{field:U,value:typeof se=="string"?se:ee(se),onChange:K=>C($,L.name,K),disabled:v,readOnly:v,className:"w-full"});default:return c.jsx(Hi,{field:U,value:ee(se),onChange:K=>C($,L.name,K),disabled:v,readOnly:v,className:"w-full"})}};return c.jsx("td",{className:"px-4 py-2.5 align-middle first:pl-6 last:pr-6",children:c.jsx("div",{className:"min-w-[160px] w-full [&_input]:min-w-[10rem] [&_input]:overflow-visible [&_textarea]:min-h-[2.5rem]",children:ne()})},L.id)}),w&&c.jsx("td",{className:"px-2 py-2",children:c.jsx(Kt,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>_($),disabled:!P||v,children:c.jsx(Yo,{className:"h-4 w-4"})})})]},$)})})]})}),N&&c.jsx("div",{className:"shrink-0 p-3 border-t bg-muted/30",children:c.jsxs(Kt,{type:"button",variant:"outline",size:"sm",onClick:E,disabled:v,className:"w-full",children:[c.jsx(du,{className:"h-4 w-4 mr-2"}),"Add Row"]})})]})})},g_="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",y_="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",b_="h-8 min-w-[2ch] max-w-full flex-1 border-0 bg-transparent px-0 shadow-none focus-visible:ring-0";function Rh(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 v_(e){const t=e.replace(/[^\d.-]/g,"");if(t===""||t==="-"||t===".")return null;const r=parseFloat(t);return Number.isNaN(r)?null:r}function w_(e){if(e==null||e==="")return"";const t=typeof e=="number"?e:Number(e);return Number.isNaN(t)?"":String(t)}function Gh(e,t){return Rh(e,{format:"currency"},t)}function mi(e){return e==null||e===""}function Kh(e){return e.mode??"editable"}function S_(e,t){return e.kind==="currency"||e.kind==="input"&&e.inputType==="number"?!0:t?.format==="currency"||t?.format==="number"||t?.format==="percent"}function qh(e,t,r){if(e!==void 0){if(e==="")return"";if(S_(t,r)){const n=Number(e);return Number.isNaN(n)?e:n}return e}}function hc(e,t){if(!(!e||!("defaultValue"in e)||e.defaultValue===void 0))return qh(e.defaultValue,e,t)}function gc(e,t,r){if(!t||!mi(e))return e;if(t.kind==="currency"&&Kh(t)==="static"&&t.value!==void 0)return qh(t.value,t,r);const n=hc(t,r);return n!==void 0?n:e}function x_(e,t,r){const n={...t};for(const[o,i]of Object.entries(e)){const s=r.find(d=>d.key===o);if(!mi(n[o]))continue;const a=gc(n[o],i,s);(!mi(a)||i&&"defaultValue"in i&&i.defaultValue==="")&&(n[o]=a)}return n}function Ys(e,t,r){if(!mi(e))return e;const n=hc(t,r);return n!==void 0?n:e}const A_=new Set(["all_items_summary","invoice_discount","grand_total"]);function C_(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"&&!A_.has(r.slotId));default:return e}}function yc(e){if(typeof e=="number"&&!Number.isNaN(e))return e;const t=Number(e);return Number.isNaN(t)?0:t}function E_(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 N_(e,t,r){const n=u=>yc(r.values[u]),o=(u,l)=>{const f=t.find(p=>p.slotId===u&&p.rowKind==="static");return f?yc(f.values[l]):0},i=(u,l="all")=>C_(t,l).reduce((f,p)=>f+yc(p.values[u]),0),s={...ji.functions,cell:n,cellInRow:o,SUM:i},a=Object.keys(s),d=Object.values(s);try{const u=new Function(...a,`return (${e});`)(...d);return u==null||typeof u=="number"&&Number.isNaN(u)?null:u}catch{return null}}function xo(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=E_(e,n,o.key);if(i?.kind==="formula"){const s=N_(i.expression,r,n),a=e.columns.find(d=>d.key===o.key);n.values[o.key]=mi(s)?hc(i,a)??s:s}}return{rows:r}}function __(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 xo(e,{rows:s})}function Yh(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,l]of Object.entries(e.cells)){const f=r.find(p=>p.key===u);(l.kind==="api"&&l.path||l.kind==="currency"&&l.mode==="api"&&l.path)&&(a[u]=Ys(Qe(i,l.path),l,f))}const d=a.service??a.tariff_type;return{slotId:e.id,rowKind:"dynamic",rowInstanceId:s,label:typeof d=="string"?d:void 0,values:a}})}function bc(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 vc(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:x_(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:bc(e,r,n)}}function k_(e,t,r,n){const o=vc(e,n),i=e.rowSlots.find(d=>d.kind==="dynamic"&&d.block.id===t);if(!i||i.kind!=="dynamic")return xo(e,o);const s=new Map,a=new Map;for(const d of e.rowSlots)if(d.kind==="static"){const u=o.rows.find(l=>l.slotId===d.row.id&&l.rowKind==="static");u&&s.set(d.row.id,{...u,values:{...u.values}})}else{const u=d.block.id===t?Yh(d.block,r,e.columns):o.rows.filter(l=>l.slotId===d.block.id&&l.rowKind==="dynamic");a.set(d.block.id,u.map(l=>({...l,values:{...l.values}})))}return xo(e,{rows:bc(e,s,a)})}function T_(e,t,r){const n=vc(e,r);if(t==null||typeof t!="object"||Array.isArray(t))return xo(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(f=>f.slotId===a.row.id&&f.rowKind==="static")?.values??{}},l=o[a.row.id]??o;for(const[f,p]of Object.entries(a.row.cells)){const m=e.columns.find(g=>g.key===f);(p.kind==="api"&&p.path||p.kind==="currency"&&p.mode==="api"&&p.path)&&(u[f]=Ys(Qe(l,p.path),p,m))}i.set(a.row.id,{slotId:a.row.id,rowKind:"static",rowInstanceId:a.row.id,label:a.row.label,values:u})}else{const d=a.block.apiArrayPath??a.block.id,u=Qe(o,d);s.set(a.block.id,Array.isArray(u)?Yh(a.block,u,e.columns):[])}return xo(e,{rows:bc(e,i,s)})}function Xh(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 F_(e){const t=e?.color?.trim();return t?{color:t}:{}}function wc(e){return{className:Xh(e),style:F_(e)}}function P_(e){return e?!!(e.fontSize||e.bold||e.italic||e.underline||e.color?.trim()):!1}function O_(e,t){if(!e&&!t)return;const r={...e,...t};return P_(r)?r:void 0}function I_(e,t){const r=e?.kind==="label"?O_(t,e.cellStyle):e?.cellStyle;return wc(r)}function Sc(e){return e==="center"?"text-center":e==="right"?"text-right":"text-left"}function Jh(e,t){return e?.align?e.align:t?.align??"left"}function M_(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 Qh(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 L_=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:d})=>{const u=e.properties??{},l=u.columns??[],f=u.currencySymbol??"₹",p=u.emptyDisplay??"—",m=i||s,g=S.useMemo(()=>{const _=vc(u,t);return xo(u,_)},[u,t]);S.useEffect(()=>{!t?.rows?.length&&g.rows.length&&r(g)},[t,g,r]);const h=S.useCallback((_,C,A,O,T)=>{if(m)return;const z=T==="number"?v_(O):O===""?null:O,q=__(u,g,_,C,A,z);r(q)},[m,g,r,u]),y=(_,C,A,O,T,z)=>{const q=l.find(j=>j.key===T),I=Qh(u,_,C,T),$=Sc(Jh(I,q)),M=gc(z,I,q),D=M_(u,_,C),L=D?.kind==="static"?D.row.labelStyle:D?.kind==="dynamic"?D.block.labelStyle:void 0,U=I_(I,L);if(I?.kind==="label")return c.jsx("span",{className:B(U.className||"font-medium",$,!U.style.color&&"text-foreground"),style:U.style,children:O??p});if(I?.kind==="input"&&!m){const j=M==null||M===""?"":String(M);return c.jsx(An,{type:"text",inputMode:I.inputType==="number"?"decimal":"text",value:j,onChange:se=>h(A,_,T,se.target.value,I.inputType),onBlur:n,className:B(g_,$,U.className),style:U.style,disabled:m})}if(I?.kind==="currency"){const j=Kh(I);if(j==="static"){const H=I.value!==void 0&&I.value!==""?gc(null,{...I,mode:"static"},q):M;return c.jsx("span",{className:B("tabular-nums",$,U.className),style:U.style,children:Gh(H,{currencySymbol:f,emptyDisplay:p})})}if(j==="api"||m)return c.jsx("span",{className:B("tabular-nums",$,U.className),style:U.style,children:Gh(M,{currencySymbol:f,emptyDisplay:p})});const se=w_(M);return c.jsxs("div",{className:B(y_,$==="text-center"&&"justify-center",$==="text-right"&&"justify-end",$==="text-left"&&"justify-start",U.className),style:U.style,children:[c.jsx("span",{className:"shrink-0 tabular-nums",children:f}),c.jsx(An,{type:"text",inputMode:"decimal",value:se,onChange:H=>h(A,_,T,H.target.value,"number"),onBlur:n,className:b_,disabled:m})]})}return I?.kind==="static"?c.jsx("span",{className:B($,U.className,!U.style.color&&"text-muted-foreground"),style:U.style,children:I.value}):c.jsx("span",{className:B($,U.className),style:U.style,children:Rh(M,q,{currencySymbol:f,emptyDisplay:p})})},w=u.gridTitle?.trim()??"",v=Math.max(1,e.position?.rowSpan??1),x=Math.max(1,e.position?.columnSpan??1),N=Math.max(g.rows.length,1),P=v>=3?"py-4":v>=2?"py-3":"py-2",E=x>=3?"px-4":x>=2?"px-3":"px-2";return l.length===0?c.jsx(At,{field:e,error:o,isRequired:a,className:d,children:c.jsx("div",{className:"p-4 border rounded-md bg-muted/50 text-sm text-muted-foreground",children:"No columns defined for this billing grid"})}):c.jsx(At,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{id:ht(e),className:B("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",m&&"opacity-70"),"aria-describedby":$t(e,!!o),"aria-invalid":Zt(!!o),"aria-required":a,children:[w?c.jsx("div",{className:B("shrink-0 px-4 py-2 border-b bg-muted/40",Xh(u.gridTitleStyle)||"text-muted-foreground"),style:wc(u.gridTitleStyle).style,children:w}):null,c.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:c.jsxs("table",{className:"w-full h-full min-h-full border-collapse text-sm table-fixed",style:u.minWidth?{minWidth:u.minWidth}:void 0,children:[c.jsx("thead",{children:c.jsx("tr",{className:"border-b border-border bg-muted/60",children:l.map(_=>{const C=wc(_.headerStyle);return c.jsx("th",{className:B(E,P,"text-xs uppercase tracking-wider whitespace-nowrap",Sc(_.align),C.className||"font-semibold text-muted-foreground"),style:C.style,children:_.label},_.id)})})}),c.jsx("tbody",{className:"h-full",children:g.rows.length===0?c.jsx("tr",{children:c.jsx("td",{colSpan:l.length,className:B(E,"py-8 text-center text-sm text-muted-foreground"),children:"No billing rows configured"})}):g.rows.map(_=>c.jsx("tr",{className:"border-b border-border/60",style:{height:`${100/N}%`},children:l.map(C=>{const A=Qh(u,_.slotId,_.rowKind,C.key),O=Jh(A,C);return c.jsx("td",{className:B(E,P,"align-middle whitespace-nowrap",Sc(O)),children:y(_.slotId,_.rowKind,_.rowInstanceId,_.label,C.key,_.values[C.key])},C.id)})},`${_.slotId}-${_.rowInstanceId}`))})]})})]})})};function xc(e,t,r){return T_(e,t,r)}const D_=({field:e,value:t,error:r,disabled:n,isRequired:o,className:i,formValues:s={},submissionContext:a,extraSubmitPayload:d,skipApiCall:u=!1,prepopulateResponse:l=null})=>{const f=e.properties||{},p=f.source??"manual",m=Array.isArray(f.statuses)?f.statuses:[],g=(f.dataPath||"data").trim(),h=f.showStatusText===!0,y=(f.statusTextPath||"data.admissionStatus").trim(),w=f.showCurrentIndicator!==!1,[v,x]=S.useState(null),[N,P]=S.useState(!1),[E,_]=S.useState(null),C=wa.useParams(),A=S.useRef(s),O=S.useRef(a),T=S.useRef(d),z=S.useRef(C);A.current=s,O.current=a,T.current=d,z.current=C;const q=S.useCallback(async()=>{const L=f.apiEndpoint?.trim();if(!L){_("Status API endpoint is not configured");return}P(!0),_(null);try{const U=O.current,j=T.current,se=U!=null&&typeof U=="object"?{...U,...j||{}}:j||{},H=rn(Wr(L,A.current,z.current,se,void 0,l??void 0)),G=(f.apiMethod||"GET").toUpperCase(),ee=await fetch(H,{method:G,headers:G==="POST"?{"Content-Type":"application/json"}:void 0});if(!ee.ok)throw new Error(`HTTP ${ee.status}`);const de=await ee.json(),ne=g?Qe(de,g):de;x(ne&&typeof ne=="object"?ne:{})}catch(U){_(U instanceof Error?U.message:"Failed to load status"),x(null)}finally{P(!1)}},[f.apiEndpoint,f.apiMethod,g,l]);S.useEffect(()=>{p==="api"&&!u&&q()},[p,u,q]);const I=p==="api"?v:t&&typeof t=="object"?(g?Qe(t,g):null)??t:null,$=h&&y&&I?String(Qe(I,y)??Qe({data:I},y)??""):"",M=L=>{if(!I||typeof I!="object")return!1;const U=I[L];return U===!0||U==="true"||U===1};let D=!1;return c.jsx(At,{field:e,error:r||E||void 0,isRequired:o,className:B(i,"!space-y-0 h-full min-h-0 flex flex-col"),children:c.jsxs("div",{className:"rounded-lg border bg-card p-4 h-full min-h-0 flex flex-col",children:[N&&c.jsx("div",{className:"text-sm text-muted-foreground py-2",children:"Loading status..."}),h&&$&&!N&&c.jsx("p",{className:"text-sm text-muted-foreground mb-3 shrink-0","data-status-text":!0,children:$}),!N&&c.jsx("ul",{className:"flex-1 min-h-0 flex flex-col gap-y-8 overflow-y-auto pr-1 py-1",children:m.map(L=>{const U=M(L.key),j=w&&U&&!D;return j&&(D=!0),c.jsxs("li",{className:B("flex items-center gap-3 text-sm",U?"text-foreground":"text-muted-foreground"),children:[U?c.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:c.jsx(Ri,{className:"h-3 w-3"})}):c.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:c.jsx(au,{className:"h-2.5 w-2.5 text-muted-foreground/60"})}),c.jsx("span",{className:"flex-1 min-w-0",children:L.label}),j&&c.jsx("span",{className:"shrink-0 text-xs font-medium text-primary",children:"Current"})]},L.key)})}),!N&&m.length===0&&c.jsx("p",{className:"text-sm text-muted-foreground",children:"No statuses configured."})]})})};function Ac(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 Ao(e,t){if(t){const r=Ac(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 B_(e,t,r,n){if(r?.length){const i=n??" | ",s=r.map(a=>Ac(e,a)).filter(a=>a!=null).map(a=>String(a));if(s.length)return s.join(i)}if(t){const i=Ac(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 $_=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a,submissionContext:d})=>{const u=e.properties||{},{dataSourceContextKey:l,labelField:f="name",valueField:p="email",displayFields:m,displayFieldsSeparator:g=" | ",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:d?Object.keys(d):[],dataSourceContextKey:l,contextKeyValue:d&&l?d[l]:void 0});const w=S.useMemo(()=>{if(!l||!d)return[];const T=d[l];return Array.isArray(T)?T:[]},[l,d]);console.log("[SelectableList] Step 2: contextList from submissionContext",{fieldName:e.name,contextListLength:w.length,contextListSample:w.length>0?w.slice(0,2):[]});const[v,x]=S.useState(()=>w.length>0?w:Array.isArray(t)?t:[]);S.useEffect(()=>{if(w.length>0){console.log("[SelectableList] Step 3: sync fullList from context",{fieldName:e.name,contextListLength:w.length}),x(w);return}Array.isArray(t)&&t.length>0&&x(T=>{const z=T.length===0||t.length>T.length?t:T;return console.log("[SelectableList] Step 3: sync fullList from value",{fieldName:e.name,valueLength:t.length,prevLength:T.length,nextLength:z.length}),z})},[w,t]);const N=S.useMemo(()=>{const T=Array.isArray(t)?t:[];return new Set(T.map(q=>Ao(q,p)))},[t,p]),P=v.length>0&&v.every(T=>N.has(Ao(T,p))),E=v.some(T=>N.has(Ao(T,p))),_=S.useCallback((T,z)=>{const q=Ao(T,p),I=Array.isArray(t)?t:[];z?N.has(q)||r([...I,T]):r(I.filter($=>Ao($,p)!==q)),n?.()},[t,p,N,r,n]),C=S.useCallback(T=>{r(T===!0?[...v]:[]),n?.()},[v,r,n]),A=v.length>0?v:Array.isArray(t)?t:[],O=i||e.disabled;return console.log("[SelectableList] Data in list",{fieldName:e.name,listLength:A.length,listSource:v.length>0?"fullList":"value",valueLength:Array.isArray(t)?t.length:0,fullListLength:v.length,listData:A.length>0?A:[],listDataFirstThree:A.length>0?A.slice(0,3):[]}),c.jsx("div",{className:B("relative z-10 flex flex-col min-h-0 h-full w-full",A.length>0&&"min-h-[14rem]",a),children:c.jsx(At,{field:e,error:o,isRequired:s,className:B("flex-1 min-h-0 flex flex-col",A.length>0&&"min-h-[14rem]"),children:c.jsx("div",{className:B("flex-1 min-h-0 flex flex-col",A.length>0&&"min-h-[14rem]"),children:c.jsxs("div",{className:B("flex-1 min-h-0 flex flex-col",A.length>0&&"overflow-visible"),children:[c.jsxs("div",{role:"listbox","aria-multiselectable":!0,className:B("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",A.length>0?"flex-1 min-h-0":"min-h-0"),children:[h&&A.length>0&&c.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:[c.jsx(Ms,{id:`${ht(e)}-select-all`,checked:P?!0:E?"indeterminate":!1,onCheckedChange:C,disabled:O,"aria-label":"Select all"}),c.jsxs(Cn,{htmlFor:`${ht(e)}-select-all`,className:"text-sm font-medium cursor-pointer",children:["Select all (",A.length,")"]}),c.jsxs("div",{className:"flex gap-1 ml-auto",children:[c.jsx(Kt,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs",disabled:O||P,onClick:()=>{r([...v]),n?.()},children:"Select all"}),c.jsx(Kt,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs",disabled:O||!E,onClick:()=>{r([]),n?.()},children:"Unselect all"})]})]}),A.length===0?c.jsx("p",{className:"px-3 py-4 text-sm text-muted-foreground",children:"No items to display."}):c.jsx(c.Fragment,{children:A.map((T,z)=>{const q=Ao(T,p),I=N.has(q),$=`${ht(e)}-${z}-${q}`;return c.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:[c.jsx(Ms,{id:$,checked:I,onCheckedChange:M=>_(T,M===!0),disabled:O,"aria-describedby":$t(e,!!o)}),c.jsx(Cn,{htmlFor:$,className:"text-sm cursor-pointer flex-1 truncate",children:B_(T,f,m,g)})]},q)})})]}),A.length>0&&N.size===0&&c.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:[c.jsx($v,{className:"h-4 w-4 shrink-0"}),"Please select at least one item."]})]})})})})},Zh=({field:e,children:t,className:r})=>{const n=e.properties,o=n?.collapsible??!1,i=n?.defaultCollapsed??!1,s=n?.columns??1,[a,d]=S.useState(i),u=()=>{o&&d(!a)},l={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 c.jsxs("div",{className:B("border rounded-lg bg-card",r),children:[c.jsxs("div",{className:B("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&&c.jsx("span",{className:"text-muted-foreground",children:a?c.jsx(su,{className:"h-4 w-4"}):c.jsx(Ko,{className:"h-4 w-4"})}),c.jsx("h3",{className:"font-medium text-sm",children:e.label}),e.description&&c.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:e.description})]}),!a&&c.jsx("div",{className:B("p-4 grid gap-4",l[s]),children:t})]})};var j_=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],z_=j_.reduce((e,t)=>{const r=Va(`Primitive.${t}`),n=b.forwardRef((o,i)=>{const{asChild:s,...a}=o,d=s?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(d,{...a,ref:i})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),U_="Separator",eg="horizontal",V_=["horizontal","vertical"],tg=b.forwardRef((e,t)=>{const{decorative:r,orientation:n=eg,...o}=e,i=H_(n)?n:eg,a=r?{role:"none"}:{"aria-orientation":i==="vertical"?i:void 0,role:"separator"};return c.jsx(z_.div,{"data-orientation":i,...a,...o,ref:t})});tg.displayName=U_;function H_(e){return V_.includes(e)}var W_=tg;function Cc({className:e,orientation:t="horizontal",decorative:r=!0,...n}){return c.jsx(W_,{"data-slot":"separator",decorative:r,orientation:t,className:B("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 R_=({field:e,className:t})=>c.jsx("div",{className:B("py-2",t),children:c.jsx(Cc,{})}),G_={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"},K_=({field:e,className:t})=>{const r=e.properties,n=r?.headingLevel??"h3",o=r?.showHorizontalLine??!0,i=G_[n],s=n;return c.jsxs("div",{className:B("w-full min-w-0 space-y-1",t),children:[c.jsx(s,{className:B("m-0 text-foreground",i),children:e.label||"Header"}),e.description&&c.jsx("p",{className:"text-sm text-muted-foreground",children:e.description}),o&&c.jsx(Cc,{className:"w-full"})]})},q_={"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"},Y_={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"},X_=({field:e,className:t})=>{const r=e.properties,n=r?.position??"top-left",o=r?.headingLevel??"h3",i=r?.showHorizontalLine??!0,s=q_[n],a=Y_[o],d=o;return c.jsxs("div",{className:B("w-full min-w-0 space-y-2",t),children:[c.jsx("div",{className:B("flex w-full",s),children:c.jsx(d,{className:B("m-0 text-foreground",a),children:e.label||"Section Heading"})}),i&&c.jsx(Cc,{className:"w-full"})]})},J_=({field:e,className:t})=>{const r=e.appearance?.size||"md",n={sm:"h-4",md:"h-8",lg:"h-12"};return c.jsx("div",{className:B(n[r],t),"aria-hidden":"true"})};function rg(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 Q_(e){if(Array.isArray(e))return e}function Z_(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,o,i,s,a=[],d=!0,u=!1;try{if(i=(r=r.call(e)).next,t!==0)for(;!(d=(n=i.call(r)).done)&&(a.push(n.value),a.length!==t);d=!0);}catch(l){u=!0,o=l}finally{try{if(!d&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(u)throw o}}return a}}function ek(){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 tk(e,t){return Q_(e)||Z_(e,t)||rk(e,t)||ek()}function rk(e,t){if(e){if(typeof e=="string")return rg(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)?rg(e,t):void 0}}const ng=Object.entries,og=Object.setPrototypeOf,nk=Object.isFrozen,ok=Object.getPrototypeOf,ik=Object.getOwnPropertyDescriptor;let lr=Object.freeze,Ir=Object.seal,Co=Object.create,ig=typeof Reflect<"u"&&Reflect,Ec=ig.apply,Nc=ig.construct;lr||(lr=function(t){return t}),Ir||(Ir=function(t){return t}),Ec||(Ec=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)}),Nc||(Nc=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 Eo=zt(Array.prototype.forEach),sk=zt(Array.prototype.lastIndexOf),sg=zt(Array.prototype.pop),No=zt(Array.prototype.push),ak=zt(Array.prototype.splice),cr=Array.isArray,hi=zt(String.prototype.toLowerCase),_c=zt(String.prototype.toString),ag=zt(String.prototype.match),_o=zt(String.prototype.replace),lg=zt(String.prototype.indexOf),lk=zt(String.prototype.trim),ck=zt(Number.prototype.toString),dk=zt(Boolean.prototype.toString),cg=typeof BigInt>"u"?null:zt(BigInt.prototype.toString),dg=typeof Symbol>"u"?null:zt(Symbol.prototype.toString),Pt=zt(Object.prototype.hasOwnProperty),gi=zt(Object.prototype.toString),tr=zt(RegExp.prototype.test),Xs=uk(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 Ec(e,t,n)}}function uk(e){return function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return Nc(e,r)}}function it(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:hi;if(og&&og(e,null),!cr(t))return e;let n=t.length;for(;n--;){let o=t[n];if(typeof o=="string"){const i=r(o);i!==o&&(nk(t)||(t[n]=i),o=i)}e[o]=!0}return e}function fk(e){for(let t=0;t<e.length;t++)Pt(e,t)||(e[t]=null);return e}function gr(e){const t=Co(null);for(const n of ng(e)){var r=tk(n,2);const o=r[0],i=r[1];Pt(e,o)&&(cr(i)?t[o]=fk(i):i&&typeof i=="object"&&i.constructor===Object?t[o]=gr(i):t[o]=i)}return t}function pk(e){switch(typeof e){case"string":return e;case"number":return ck(e);case"boolean":return dk(e);case"bigint":return cg?cg(e):"0";case"symbol":return dg?dg(e):"Symbol()";case"undefined":return gi(e);case"function":case"object":{if(e===null)return gi(e);const t=e,r=Xn(t,"toString");if(typeof r=="function"){const n=r(t);return typeof n=="string"?n:gi(n)}return gi(e)}default:return gi(e)}}function Xn(e,t){for(;e!==null;){const n=ik(e,t);if(n){if(n.get)return zt(n.get);if(typeof n.value=="function")return zt(n.value)}e=ok(e)}function r(){return null}return r}function mk(e){try{return tr(e,""),!0}catch{return!1}}const ug=lr(["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"]),kc=lr(["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"]),Tc=lr(["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"]),hk=lr(["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"]),Fc=lr(["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"]),gk=lr(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),fg=lr(["#text"]),pg=lr(["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"]),Pc=lr(["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"]),mg=lr(["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"]),Js=lr(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),yk=Ir(/{{[\w\W]*|^[\w\W]*}}/g),bk=Ir(/<%[\w\W]*|^[\w\W]*%>/g),vk=Ir(/\${[\w\W]*/g),wk=Ir(/^data-[\-\w.\u00B7-\uFFFF]+$/),Sk=Ir(/^aria-[\-\w]+$/),hg=Ir(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),xk=Ir(/^(?:\w+script|data):/i),Ak=Ir(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ck=Ir(/^html$/i),Ek=Ir(/^[a-z][.\w]*(-[.\w]+)+$/i),ko={element:1,text:3,progressingInstruction:7,comment:8,document:9},Nk=function(){return typeof window>"u"?null:window},_k=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}},gg=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function yg(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Nk();const t=Ee=>yg(Ee);if(t.version="3.4.5",t.removed=[],!e||!e.document||e.document.nodeType!==ko.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,d=e.Element,u=e.NodeFilter,l=e.NamedNodeMap,f=l===void 0?e.NamedNodeMap||e.MozNamedAttrMap:l,p=e.HTMLFormElement,m=e.DOMParser,g=e.trustedTypes,h=d.prototype,y=Xn(h,"cloneNode"),w=Xn(h,"remove"),v=Xn(h,"nextSibling"),x=Xn(h,"childNodes"),N=Xn(h,"parentNode"),P=a&&a.prototype?Xn(a.prototype,"nodeType"):null;if(typeof s=="function"){const Ee=r.createElement("template");Ee.content&&Ee.content.ownerDocument&&(r=Ee.content.ownerDocument)}let E,_="";const C=r,A=C.implementation,O=C.createNodeIterator,T=C.createDocumentFragment,z=C.getElementsByTagName,q=n.importNode;let I=gg();t.isSupported=typeof ng=="function"&&typeof N=="function"&&A&&A.createHTMLDocument!==void 0;const $=yk,M=bk,D=vk,L=wk,U=Sk,j=xk,se=Ak,H=Ek;let G=hg,ee=null;const de=it({},[...ug,...kc,...Tc,...Fc,...fg]);let ne=null;const K=it({},[...pg,...Pc,...mg,...Js]);let re=Object.seal(Co(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}})),Te=null,Z=null;const te=Object.seal(Co(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let he=!0,le=!0,Xe=!1,ge=!0,Se=!1,ae=!0,ve=!1,He=!1,dt=!1,Ge=!1,Rt=!1,Je=!1,Y=!0,je=!1;const gt="user-content-";let Ie=!0,oe=!1,pe={},We=null;const Tt=it({},["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 ze=null;const Fe=it({},["audio","video","img","source","image","track"]);let Ke=null;const nt=it({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),yt="http://www.w3.org/1998/Math/MathML",Yt="http://www.w3.org/2000/svg",St="http://www.w3.org/1999/xhtml";let Pe=St,ft=!1,et=null;const xt=it({},[yt,Yt,St],_c);let ur=it({},["mi","mo","mn","ms","mtext"]),on=it({},["annotation-xml"]);const Nr=it({},["title","style","font","a","script"]);let rr=null;const Gr=["application/xhtml+xml","text/html"],hn="text/html";let Ft=null,br=null;const Io=r.createElement("form"),sn=function(F){return F instanceof RegExp||F instanceof Function},Lr=function(){let F=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(br&&br===F)return;(!F||typeof F!="object")&&(F={}),F=gr(F),rr=Gr.indexOf(F.PARSER_MEDIA_TYPE)===-1?hn:F.PARSER_MEDIA_TYPE,Ft=rr==="application/xhtml+xml"?_c:hi,ee=Pt(F,"ALLOWED_TAGS")&&cr(F.ALLOWED_TAGS)?it({},F.ALLOWED_TAGS,Ft):de,ne=Pt(F,"ALLOWED_ATTR")&&cr(F.ALLOWED_ATTR)?it({},F.ALLOWED_ATTR,Ft):K,et=Pt(F,"ALLOWED_NAMESPACES")&&cr(F.ALLOWED_NAMESPACES)?it({},F.ALLOWED_NAMESPACES,_c):xt,Ke=Pt(F,"ADD_URI_SAFE_ATTR")&&cr(F.ADD_URI_SAFE_ATTR)?it(gr(nt),F.ADD_URI_SAFE_ATTR,Ft):nt,ze=Pt(F,"ADD_DATA_URI_TAGS")&&cr(F.ADD_DATA_URI_TAGS)?it(gr(Fe),F.ADD_DATA_URI_TAGS,Ft):Fe,We=Pt(F,"FORBID_CONTENTS")&&cr(F.FORBID_CONTENTS)?it({},F.FORBID_CONTENTS,Ft):Tt,Te=Pt(F,"FORBID_TAGS")&&cr(F.FORBID_TAGS)?it({},F.FORBID_TAGS,Ft):gr({}),Z=Pt(F,"FORBID_ATTR")&&cr(F.FORBID_ATTR)?it({},F.FORBID_ATTR,Ft):gr({}),pe=Pt(F,"USE_PROFILES")?F.USE_PROFILES&&typeof F.USE_PROFILES=="object"?gr(F.USE_PROFILES):F.USE_PROFILES:!1,he=F.ALLOW_ARIA_ATTR!==!1,le=F.ALLOW_DATA_ATTR!==!1,Xe=F.ALLOW_UNKNOWN_PROTOCOLS||!1,ge=F.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Se=F.SAFE_FOR_TEMPLATES||!1,ae=F.SAFE_FOR_XML!==!1,ve=F.WHOLE_DOCUMENT||!1,Ge=F.RETURN_DOM||!1,Rt=F.RETURN_DOM_FRAGMENT||!1,Je=F.RETURN_TRUSTED_TYPE||!1,dt=F.FORCE_BODY||!1,Y=F.SANITIZE_DOM!==!1,je=F.SANITIZE_NAMED_PROPS||!1,Ie=F.KEEP_CONTENT!==!1,oe=F.IN_PLACE||!1,G=mk(F.ALLOWED_URI_REGEXP)?F.ALLOWED_URI_REGEXP:hg,Pe=typeof F.NAMESPACE=="string"?F.NAMESPACE:St,ur=Pt(F,"MATHML_TEXT_INTEGRATION_POINTS")&&F.MATHML_TEXT_INTEGRATION_POINTS&&typeof F.MATHML_TEXT_INTEGRATION_POINTS=="object"?gr(F.MATHML_TEXT_INTEGRATION_POINTS):it({},["mi","mo","mn","ms","mtext"]),on=Pt(F,"HTML_INTEGRATION_POINTS")&&F.HTML_INTEGRATION_POINTS&&typeof F.HTML_INTEGRATION_POINTS=="object"?gr(F.HTML_INTEGRATION_POINTS):it({},["annotation-xml"]);const X=Pt(F,"CUSTOM_ELEMENT_HANDLING")&&F.CUSTOM_ELEMENT_HANDLING&&typeof F.CUSTOM_ELEMENT_HANDLING=="object"?gr(F.CUSTOM_ELEMENT_HANDLING):Co(null);if(re=Co(null),Pt(X,"tagNameCheck")&&sn(X.tagNameCheck)&&(re.tagNameCheck=X.tagNameCheck),Pt(X,"attributeNameCheck")&&sn(X.attributeNameCheck)&&(re.attributeNameCheck=X.attributeNameCheck),Pt(X,"allowCustomizedBuiltInElements")&&typeof X.allowCustomizedBuiltInElements=="boolean"&&(re.allowCustomizedBuiltInElements=X.allowCustomizedBuiltInElements),Se&&(le=!1),Rt&&(Ge=!0),pe&&(ee=it({},fg),ne=Co(null),pe.html===!0&&(it(ee,ug),it(ne,pg)),pe.svg===!0&&(it(ee,kc),it(ne,Pc),it(ne,Js)),pe.svgFilters===!0&&(it(ee,Tc),it(ne,Pc),it(ne,Js)),pe.mathMl===!0&&(it(ee,Fc),it(ne,mg),it(ne,Js))),te.tagCheck=null,te.attributeCheck=null,Pt(F,"ADD_TAGS")&&(typeof F.ADD_TAGS=="function"?te.tagCheck=F.ADD_TAGS:cr(F.ADD_TAGS)&&(ee===de&&(ee=gr(ee)),it(ee,F.ADD_TAGS,Ft))),Pt(F,"ADD_ATTR")&&(typeof F.ADD_ATTR=="function"?te.attributeCheck=F.ADD_ATTR:cr(F.ADD_ATTR)&&(ne===K&&(ne=gr(ne)),it(ne,F.ADD_ATTR,Ft))),Pt(F,"ADD_URI_SAFE_ATTR")&&cr(F.ADD_URI_SAFE_ATTR)&&it(Ke,F.ADD_URI_SAFE_ATTR,Ft),Pt(F,"FORBID_CONTENTS")&&cr(F.FORBID_CONTENTS)&&(We===Tt&&(We=gr(We)),it(We,F.FORBID_CONTENTS,Ft)),Pt(F,"ADD_FORBID_CONTENTS")&&cr(F.ADD_FORBID_CONTENTS)&&(We===Tt&&(We=gr(We)),it(We,F.ADD_FORBID_CONTENTS,Ft)),Ie&&(ee["#text"]=!0),ve&&it(ee,["html","head","body"]),ee.table&&(it(ee,["tbody"]),delete Te.tbody),F.TRUSTED_TYPES_POLICY){if(typeof F.TRUSTED_TYPES_POLICY.createHTML!="function")throw Xs('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof F.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Xs('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');E=F.TRUSTED_TYPES_POLICY,_=E.createHTML("")}else E===void 0&&(E=_k(g,o)),E!==null&&typeof _=="string"&&(_=E.createHTML(""));lr&&lr(F),br=F},Xt=it({},[...kc,...Tc,...hk]),vr=it({},[...Fc,...gk]),Ot=function(F){let X=N(F);(!X||!X.tagName)&&(X={namespaceURI:Pe,tagName:"template"});const ye=hi(F.tagName),st=hi(X.tagName);return et[F.namespaceURI]?F.namespaceURI===Yt?X.namespaceURI===St?ye==="svg":X.namespaceURI===yt?ye==="svg"&&(st==="annotation-xml"||ur[st]):!!Xt[ye]:F.namespaceURI===yt?X.namespaceURI===St?ye==="math":X.namespaceURI===Yt?ye==="math"&&on[st]:!!vr[ye]:F.namespaceURI===St?X.namespaceURI===Yt&&!on[st]||X.namespaceURI===yt&&!ur[st]?!1:!vr[ye]&&(Nr[ye]||!Xt[ye]):!!(rr==="application/xhtml+xml"&&et[F.namespaceURI]):!1},Jt=function(F){No(t.removed,{element:F});try{N(F).removeChild(F)}catch{w(F)}},Et=function(F,X){try{No(t.removed,{attribute:X.getAttributeNode(F),from:X})}catch{No(t.removed,{attribute:null,from:X})}if(X.removeAttribute(F),F==="is")if(Ge||Rt)try{Jt(X)}catch{}else try{X.setAttribute(F,"")}catch{}},an=function(F){let X=null,ye=null;if(dt)F="<remove></remove>"+F;else{const wt=ag(F,/^[\r\n\t ]+/);ye=wt&&wt[0]}rr==="application/xhtml+xml"&&Pe===St&&(F='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+F+"</body></html>");const st=E?E.createHTML(F):F;if(Pe===St)try{X=new m().parseFromString(st,rr)}catch{}if(!X||!X.documentElement){X=A.createDocument(Pe,"template",null);try{X.documentElement.innerHTML=ft?_:st}catch{}}const _t=X.body||X.documentElement;return F&&ye&&_t.insertBefore(r.createTextNode(ye),_t.childNodes[0]||null),Pe===St?z.call(X,ve?"html":"body")[0]:ve?X.documentElement:_t},Qt=function(F){return O.call(F.ownerDocument||F,F,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},wr=function(F){F.normalize();const X=O.call(F.ownerDocument||F,F,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null);let ye=X.nextNode();for(;ye;){let st=ye.data;Eo([$,M,D],_t=>{st=_o(st,_t," ")}),ye.data=st,ye=X.nextNode()}},fr=function(F){return F instanceof p&&(typeof F.nodeName!="string"||typeof F.textContent!="string"||typeof F.removeChild!="function"||!(F.attributes instanceof f)||typeof F.removeAttribute!="function"||typeof F.setAttribute!="function"||typeof F.namespaceURI!="string"||typeof F.insertBefore!="function"||typeof F.hasChildNodes!="function")},Sr=function(F){if(!P||typeof F!="object"||F===null)return!1;try{return typeof P(F)=="number"}catch{return!1}};function Gt(Ee,F,X){Eo(Ee,ye=>{ye.call(t,F,X,br)})}const nr=function(F){let X=null;if(Gt(I.beforeSanitizeElements,F,null),fr(F))return Jt(F),!0;const ye=Ft(F.nodeName);if(Gt(I.uponSanitizeElement,F,{tagName:ye,allowedTags:ee}),ae&&F.hasChildNodes()&&!Sr(F.firstElementChild)&&tr(/<[/\w!]/g,F.innerHTML)&&tr(/<[/\w!]/g,F.textContent)||ae&&F.namespaceURI===St&&ye==="style"&&Sr(F.firstElementChild)||F.nodeType===ko.progressingInstruction||ae&&F.nodeType===ko.comment&&tr(/<[/\w]/g,F.data))return Jt(F),!0;if(Te[ye]||!(te.tagCheck instanceof Function&&te.tagCheck(ye))&&!ee[ye]){if(!Te[ye]&&oa(ye)&&(re.tagNameCheck instanceof RegExp&&tr(re.tagNameCheck,ye)||re.tagNameCheck instanceof Function&&re.tagNameCheck(ye)))return!1;if(Ie&&!We[ye]){const st=N(F)||F.parentNode,_t=x(F)||F.childNodes;if(_t&&st){const wt=_t.length;for(let It=wt-1;It>=0;--It){const Br=y(_t[It],!0);st.insertBefore(Br,v(F))}}}return Jt(F),!0}return F instanceof d&&!Ot(F)||(ye==="noscript"||ye==="noembed"||ye==="noframes")&&tr(/<\/no(script|embed|frames)/i,F.innerHTML)?(Jt(F),!0):(Se&&F.nodeType===ko.text&&(X=F.textContent,Eo([$,M,D],st=>{X=_o(X,st," ")}),F.textContent!==X&&(No(t.removed,{element:F.cloneNode()}),F.textContent=X)),Gt(I.afterSanitizeElements,F,null),!1)},Dr=function(F,X,ye){if(Z[X]||Y&&(X==="id"||X==="name")&&(ye in r||ye in Io))return!1;const st=ne[X]||te.attributeCheck instanceof Function&&te.attributeCheck(X,F);if(!(le&&!Z[X]&&tr(L,X))){if(!(he&&tr(U,X))){if(!st||Z[X]){if(!(oa(F)&&(re.tagNameCheck instanceof RegExp&&tr(re.tagNameCheck,F)||re.tagNameCheck instanceof Function&&re.tagNameCheck(F))&&(re.attributeNameCheck instanceof RegExp&&tr(re.attributeNameCheck,X)||re.attributeNameCheck instanceof Function&&re.attributeNameCheck(X,F))||X==="is"&&re.allowCustomizedBuiltInElements&&(re.tagNameCheck instanceof RegExp&&tr(re.tagNameCheck,ye)||re.tagNameCheck instanceof Function&&re.tagNameCheck(ye))))return!1}else if(!Ke[X]){if(!tr(G,_o(ye,se,""))){if(!((X==="src"||X==="xlink:href"||X==="href")&&F!=="script"&&lg(ye,"data:")===0&&ze[F])){if(!(Xe&&!tr(j,_o(ye,se,"")))){if(ye)return!1}}}}}}return!0},na=it({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),oa=function(F){return!na[hi(F)]&&tr(H,F)},ia=function(F){Gt(I.beforeSanitizeAttributes,F,null);const X=F.attributes;if(!X||fr(F))return;const ye={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ne,forceKeepAttr:void 0};let st=X.length;for(;st--;){const _t=X[st],wt=_t.name,It=_t.namespaceURI,Br=_t.value,sr=Ft(wt),Mo=Br;let Mt=wt==="value"?Mo:lk(Mo);if(ye.attrName=sr,ye.attrValue=Mt,ye.keepAttr=!0,ye.forceKeepAttr=void 0,Gt(I.uponSanitizeAttribute,F,ye),Mt=ye.attrValue,je&&(sr==="id"||sr==="name")&&lg(Mt,gt)!==0&&(Et(wt,F),Mt=gt+Mt),ae&&tr(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Mt)){Et(wt,F);continue}if(sr==="attributename"&&ag(Mt,"href")){Et(wt,F);continue}if(ye.forceKeepAttr)continue;if(!ye.keepAttr){Et(wt,F);continue}if(!ge&&tr(/\/>/i,Mt)){Et(wt,F);continue}Se&&Eo([$,M,D],tt=>{Mt=_o(Mt,tt," ")});const sa=Ft(F.nodeName);if(!Dr(sa,sr,Mt)){Et(wt,F);continue}if(E&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!It)switch(g.getAttributeType(sa,sr)){case"TrustedHTML":{Mt=E.createHTML(Mt);break}case"TrustedScriptURL":{Mt=E.createScriptURL(Mt);break}}if(Mt!==Mo)try{It?F.setAttributeNS(It,wt,Mt):F.setAttribute(wt,Mt),fr(F)?Jt(F):sg(t.removed)}catch{Et(wt,F)}}Gt(I.afterSanitizeAttributes,F,null)},Ei=function(F){let X=null;const ye=Qt(F);for(Gt(I.beforeSanitizeShadowDOM,F,null);X=ye.nextNode();)Gt(I.uponSanitizeShadowNode,X,null),nr(X),ia(X),X.content instanceof i&&Ei(X.content);Gt(I.afterSanitizeShadowDOM,F,null)},_r=function(F){if(F.nodeType===ko.element&&F.shadowRoot instanceof i){const st=F.shadowRoot;_r(st),Ei(st)}const X=F.childNodes;if(!X)return;const ye=[];Eo(X,st=>{No(ye,st)});for(const st of ye)_r(st)};return t.sanitize=function(Ee){let F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},X=null,ye=null,st=null,_t=null;if(ft=!Ee,ft&&(Ee="<!-->"),typeof Ee!="string"&&!Sr(Ee)&&(Ee=pk(Ee),typeof Ee!="string"))throw Xs("dirty is not a string, aborting");if(!t.isSupported)return Ee;if(He||Lr(F),t.removed=[],typeof Ee=="string"&&(oe=!1),oe){const Br=Ee.nodeName;if(typeof Br=="string"){const sr=Ft(Br);if(!ee[sr]||Te[sr])throw Xs("root node is forbidden and cannot be sanitized in-place")}_r(Ee)}else if(Sr(Ee))X=an("<!---->"),ye=X.ownerDocument.importNode(Ee,!0),ye.nodeType===ko.element&&ye.nodeName==="BODY"||ye.nodeName==="HTML"?X=ye:X.appendChild(ye),_r(ye);else{if(!Ge&&!Se&&!ve&&Ee.indexOf("<")===-1)return E&&Je?E.createHTML(Ee):Ee;if(X=an(Ee),!X)return Ge?null:Je?_:""}X&&dt&&Jt(X.firstChild);const wt=Qt(oe?Ee:X);for(;st=wt.nextNode();)nr(st),ia(st),st.content instanceof i&&Ei(st.content);if(oe)return Se&&wr(Ee),Ee;if(Ge){if(Se&&wr(X),Rt)for(_t=T.call(X.ownerDocument);X.firstChild;)_t.appendChild(X.firstChild);else _t=X;return(ne.shadowroot||ne.shadowrootmode)&&(_t=q.call(n,_t,!0)),_t}let It=ve?X.outerHTML:X.innerHTML;return ve&&ee["!doctype"]&&X.ownerDocument&&X.ownerDocument.doctype&&X.ownerDocument.doctype.name&&tr(Ck,X.ownerDocument.doctype.name)&&(It="<!DOCTYPE "+X.ownerDocument.doctype.name+`>
|
|
52
|
-
`+It),Se&&Eo([$,M,D],Br=>{It=_o(It,Br," ")}),E&&Je?E.createHTML(It):It},t.setConfig=function(){let Ee=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Lr(Ee),He=!0},t.clearConfig=function(){br=null,He=!1},t.isValidAttribute=function(Ee,F,X){br||Lr({});const ye=Ft(Ee),st=Ft(F);return Dr(ye,st,X)},t.addHook=function(Ee,F){typeof F=="function"&&No(I[Ee],F)},t.removeHook=function(Ee,F){if(F!==void 0){const X=sk(I[Ee],F);return X===-1?void 0:ak(I[Ee],X,1)[0]}return sg(I[Ee])},t.removeHooks=function(Ee){I[Ee]=[]},t.removeAllHooks=function(){I=gg()},t}var kk=yg();const Tk=["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"],Fk=["href","target","rel","src","alt","title","class","style","colspan","rowspan"];function Pk(e){return e?kk.sanitize(e,{ALLOWED_TAGS:[...Tk],ALLOWED_ATTR:[...Fk],ALLOW_DATA_ATTR:!1}):""}function Ok(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=Qe(t,i);return s==null?r?"":n:String(s)}):e}function Ik(e){return e&&e.replace(/\{api:[^}]*\}/gi,"").replace(/\{labelapi:[^}]*\}/gi,"").replace(/\{resp:[^}]*\}/gi,"").replace(/\{(?:ctx:|@)\w+\}/gi,"").replace(/\{documentId\}/gi,"").replace(/\{(\w+)\}/g,"")}const bg={sm:"text-sm",md:"text-base",lg:"text-lg"},vg={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"},wg={normal:"font-normal",medium:"font-medium",bold:"font-bold"},Qs={left:"text-left",center:"text-center",right:"text-right",justify:"text-justify"};function Jn(e){return e.properties??{}}function Mk(e){const t=Jn(e);return t.textContent!==void 0?t.textContent:e.label??""}function Lk(e){return Jn(e).textContent===void 0||e.appearance?.hideLabel?!1:!!e.label?.trim()}function Dk(e){return e?.contentLayout==="paragraph"?"paragraph":"single"}function Oc(e,t={}){const{formValues:r={},urlParams:n={},submissionContext:o,buttonResponses:i,prepopulateResponse:s,labelApiResponse:a}=t,d=Wr(e,r,n,o,i,s),u=Ok(d,a,!0);return Ik(u)}const Bk=/\{api:[^}]+\}/,$k=/\{labelapi:[^}]+\}/;function Ic(e){return Bk.test(e)}function Mc(e){return $k.test(e)}function jk(e){const t=e.captionTemplate??"",r=e.descriptionTemplate??"",n=Ic(e.bodyTemplate)||Ic(t)||Ic(r),o=Mc(e.bodyTemplate)||Mc(t)||Mc(r);return!!(n&&e.prepopulateLoading||o&&e.labelApiConfigPresent&&(e.labelApiLoading||e.labelApiResponse===void 0&&e.labelApiError==null))}function Sg(e,t){const r=t??Jn(e),n=r.variant??"body",o=e.appearance?.size??"md",i=bg[o]??bg.md,s=r.fontWeight??"medium";return n!=="body"?B("m-0 text-foreground",vg[n]??vg.h3,r.fontWeight&&wg[r.fontWeight],r.italic&&"italic",r.underline&&"underline",r.textAlign&&Qs[r.textAlign]):B("m-0 text-foreground",i,wg[s],r.italic&&"italic",r.underline&&"underline",r.textAlign&&Qs[r.textAlign])}function zk(e,t){const r=(t??Jn(e)).variant??"body";return r==="body"?"p":r}function Lc(e){const t=[];let r=0,n="";const o=()=>{n&&(t.push({type:"text",value:n}),n="")},i=(s,a,d)=>{if(!e.startsWith(s,r))return!1;const u=e.indexOf(a,r+s.length);if(u===-1)return!1;o();const l=e.slice(r+s.length,u);return t.push({type:d,children:Lc(l)}),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 Uk(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function xg(e){return e.map(t=>{if(t.type==="text")return Uk(t.value);const r=xg(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 Vk(e){return e?xg(Lc(e)):""}function Hk(e,t){return e?t==="markdown-lite"?Vk(e):e:""}function Ag(e,t){return e.map((r,n)=>{const o=`${t}-${n}`;if(r.type==="text")return r.value?S.createElement(S.Fragment,{key:o},r.value):null;const i=Ag(r.children,o);return r.type==="bold"?S.createElement("strong",{key:o,className:"font-bold"},i):r.type==="italic"?S.createElement("em",{key:o,className:"italic"},i):S.createElement("u",{key:o,className:"underline"},i)})}function Cg(e,t){if(!e)return null;if(t!=="markdown-lite")return e;const r=Lc(e);return r.length===1&&r[0]?.type==="text"?r[0].value:Ag(r,"tl")}const Wk="text-label-html prose prose-sm max-w-none [&_p]:m-0 [&_p+p]:mt-2 [&_ul]:my-1 [&_ol]:my-1";function Eg(e,t){if(!e)return null;const{field:r,asDescription:n=!1}=t,o=t.textProps??Jn(r),i=t.contentLayout??Dk(o),s=o.inlineFormat??"none";if(i==="paragraph"){const d=Pk(Hk(e,s));if(!d)return null;const u=n?B("m-0 text-sm",o.descriptionMuted!==!1?"text-muted-foreground":"text-foreground",o.textAlign&&Qs[o.textAlign]):B(Sg(r,o),Wk);return S.createElement("div",{className:u,dangerouslySetInnerHTML:{__html:d}})}if(n)return S.createElement("p",{className:B("mt-0.5 text-sm",o.descriptionMuted!==!1?"text-muted-foreground":"text-foreground",o.textAlign&&Qs[o.textAlign])},Cg(e,s));const a=zk(r,o);return S.createElement(a,{className:Sg(r,o)},Cg(e,s))}function Rk(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 Gk(e,t={}){const{formValues:r={},urlParams:n={},submissionContext:o}=t,i=f=>Wr(f,r,n,o),s=(e.labelApiMethod??"GET").toUpperCase();let a=rn(i(e.labelApiEndpoint));const d=e.labelApiQueryParams??[];if(d.length){const f=new URLSearchParams;d.forEach(({key:m,value:g})=>{m.trim()&&f.append(m,i(g))});const p=f.toString();p&&(a=`${a}${a.includes("?")?"&":"?"}${p}`)}const u={"Content-Type":"application/json"};(e.labelApiHeaders??[]).forEach(({key:f,value:p})=>{f.trim()&&(u[f]=i(p))});let l;s==="POST"&&(e.labelApiBodyFields??[]).length&&(l={},e.labelApiBodyFields.forEach(({key:f,value:p})=>{f.trim()&&(l[f]=i(p))}));try{return s==="POST"?(await pn.post(a,l??{},{headers:Object.keys(u).length?u:void 0})).data:(await pn.get(a,{headers:Object.keys(u).length?u:void 0})).data}catch(f){const p=f,m=p.response?.status,g=typeof p.response?.data=="string"?p.response.data:p.message??"Request failed";throw new Error(m?`HTTP ${m}: ${g}`:String(g))}}const Kk=({field:e,className:t,formValues:r,urlParams:n,submissionContext:o,buttonResponses:i,prepopulateResponse:s,prepopulateLoading:a=!1})=>{const d=Jn(e),u=S.useMemo(()=>Rk(Jn(e)),[e.properties]),[l,f]=S.useState(void 0),[p,m]=S.useState(!1),[g,h]=S.useState(null),y=S.useMemo(()=>u?JSON.stringify({endpoint:u.labelApiEndpoint,method:u.labelApiMethod,query:u.labelApiQueryParams,headers:u.labelApiHeaders,body:u.labelApiBodyFields}):"",[u]),w=S.useCallback(async()=>{if(!u){f(void 0),h(null),m(!1);return}m(!0),h(null);try{const z=await Gk(u,{formValues:r??{},urlParams:n??{},submissionContext:o});f(z)}catch(z){f(void 0),h(z instanceof Error?z.message:"Failed to load label API")}finally{m(!1)}},[u,r,n,o]);S.useEffect(()=>{y&&w()},[y,w]);const v=d.textAlign==="center"?"items-center":d.textAlign==="right"?"items-end":d.textAlign==="justify"?"items-stretch":"items-start",x=Mk(e),N=Lk(e),P=N&&e.label?e.label:"",E=e.description??"",_=jk({bodyTemplate:x,captionTemplate:P,descriptionTemplate:E,prepopulateLoading:a,labelApiConfigPresent:u!=null,labelApiLoading:p,labelApiResponse:l,labelApiError:g}),C={formValues:r??{},urlParams:n??{},submissionContext:o,buttonResponses:i,prepopulateResponse:s,labelApiResponse:l},A=x?Oc(x,C):"",O=N&&e.label?Oc(e.label,C):"",T=E?Oc(E,C):"";return c.jsx("div",{className:B("w-full min-w-0 h-full min-h-[95px] flex flex-col justify-center py-0.5",v,t),children:_?c.jsx("p",{className:"text-sm text-muted-foreground m-0",children:"Loading…"}):c.jsxs(c.Fragment,{children:[g&&u?c.jsx("p",{className:"text-[10px] text-destructive mb-0.5",title:g,children:"Label API failed"}):null,O?c.jsx("div",{className:"text-sm font-medium text-foreground mb-1 w-full",children:O}):null,A?Eg(A,{field:e,textProps:d}):null,T?Eg(T,{field:e,textProps:d,asDescription:!0}):null]})})},Dc=({legend:e,children:t,className:r,collapsible:n=!1,defaultCollapsed:o=!1,headerActions:i,onCollapsedChange:s})=>{const[a,d]=S.useState(o),u=S.useId(),l=f=>{f.stopPropagation(),n&&d(p=>{const m=!p;return s?.(m),m})};return c.jsxs("fieldset",{className:B("min-w-0 rounded-lg border bg-card p-4",r),"data-form-renderer":"config-section-border",children:[n?c.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2 border-b border-border pb-2",children:[c.jsxs("button",{type:"button",className:B("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:l,children:[c.jsx("span",{className:"shrink-0 text-muted-foreground","aria-hidden":!0,children:a?c.jsx(su,{className:"h-4 w-4"}):c.jsx(Ko,{className:"h-4 w-4"})}),c.jsx("span",{className:"truncate",children:e})]}),i!=null?c.jsx("div",{className:"shrink-0",children:i}):null]}):c.jsx("legend",{className:"px-1 text-sm font-medium text-foreground",children:e}),!a&&c.jsxs("div",{id:u,className:"space-y-3",children:[!n&&i!=null?c.jsx("div",{className:"flex justify-end",children:i}):null,t]})]})};function Ng(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 Bc(e){const t=Ng(e),r=e.properties;return!!(t?.apiEndpoint&&(t?.valueSource==="api"||r?.valueSource==="api"))}function _g({field:e,formValues:t={},submissionContext:r,value:n,onChange:o,clearWhenBlocked:i=!0}){const s=e.properties,a=Ng(e),d=Bc(e),[u,l]=S.useState(!1),[f,p]=S.useState(null),m=S.useRef(null),g=S.useRef(n);g.current=n;const h=S.useMemo(()=>{const P=a?.apiEndpoint||s?.apiEndpoint||"",E=a?.apiQueryParams||s?.apiQueryParams;return Ho(P,E)},[a?.apiEndpoint,s?.apiEndpoint,a?.apiQueryParams,s?.apiQueryParams]),y=S.useMemo(()=>{const P=new Set;for(const _ of s?.dependentFields??a?.dependentFields??[])typeof _=="string"&&_.trim()&&P.add(_.trim());const E=a?.apiClientFilter?.matchField?.trim()||s?.apiClientFilter?.matchField?.trim();return E&&P.add(E),[...P]},[s?.dependentFields,a?.dependentFields,a?.apiClientFilter?.matchField,s?.apiClientFilter?.matchField]),w=S.useMemo(()=>{const P=new Set([...h,...y]);if(P.size===0)return null;const E={};return P.forEach(_=>{E[_]=t[_]}),JSON.stringify(E)},[h,y,t]),v=S.useMemo(()=>JSON.stringify(r||{}),[r]),x=S.useMemo(()=>{const P=new Set;e.name?.trim()&&P.add(e.name.trim());const E=e.key;return typeof E=="string"&&E.trim()&&P.add(E.trim()),[...P]},[e.name,e.key]),N=e.type==="number"?null:"";return S.useEffect(()=>{const P=a?.apiEndpoint;if(!d||!P)return;let E=!1;const _=A=>{if(E)return;const O=g.current;if(A==null||A.trim()===""){i&&O!==N&&O!==void 0&&(m.current=null,o(N));return}if(e.type==="number"){const T=Number(A),z=Number.isFinite(T)?T:null;O!==z&&m.current!==A&&(m.current=A,o(z));return}String(O??"")!==A&&m.current!==A&&(m.current=A,o(A))};return(async()=>{l(!0),p(null);try{const A=a?.apiMethod||s?.apiMethod||"GET",O=a?.apiRealtime||s?.apiRealtime,T=a?.apiQueryParams||s?.apiQueryParams||{},z=za({apiEndpoint:P,apiMethod:A,apiQueryParams:T,formValues:t,submissionContext:r,apiRealtime:O,additionalRequiredFieldNames:y,excludeFormFieldNames:x});if(z.blocked){E||(l(!1),i&&_(null));return}const q={"Content-Type":"application/json"},I=a?.apiKey||s?.apiKey;I&&(q["X-CSCAPI-KEY"]=I);const $=e.apidata,M=a?.apiAuth??s?.apiAuth??$?.apiAuth??$l(a?.apiHeaders??s?.apiHeaders??$?.apiHeaders)??{type:"none"},D=jl(M,{formValues:t,submissionContext:r,apiRealtime:O});Object.assign(q,D);const L=a?.apiHeaders??s?.apiHeaders??$?.apiHeaders,U=a?.apiBodyFields??s?.apiBodyFields??$?.apiBodyFields,j=go(Bl(L),{formValues:t,submissionContext:r,apiRealtime:O});Object.assign(q,j);const se=go(U,{formValues:t,submissionContext:r,apiRealtime:O}),H={method:A.toLowerCase(),url:rn(z.url),headers:q};(z.postBodyBase!=null||Object.keys(se).length>0)&&(H.data={...z.postBodyBase??{},...se});const G=await Ct(H),ee=a?.apiLabelField||s?.apiLabelField,de=a?.apiValueField||s?.apiValueField,ne=a?.apiClientFilter||s?.apiClientFilter;let K=QA(G.data,de,ee);if(ne?.filterField&&ne?.matchField&&K!=null){const re=t[ne.matchField];if(re==null)K=null;else{const Te=ci(G.data,ee,de),Z=Array.isArray(G.data)?G.data:G.data?.data?.data&&Array.isArray(G.data.data.data)?G.data.data.data:G.data?.data&&Array.isArray(G.data.data)?G.data.data:[],te=Te.filter(he=>{const le=Z.find(ge=>String(jt(ge,de||"code"))===String(he.value));if(!le)return!1;const Xe=jt(le,ne.filterField);return String(Xe)===String(re)});K=te.length>0?te[0].value:null}}E||_(K)}catch(A){if(E)return;let O="Failed to load value";const T=A;if(T.response){const z=T.response.data;if(T.response.status===404)O="API endpoint not found.";else if(T.response.status===401)O="Authentication failed.";else if(typeof z=="string")O=z;else if(z&&typeof z=="object"){const q=z;O=q.error||q.message||q.detail||O}}else T.message&&(O=String(T.message));p(O)}finally{E||l(!1)}})(),()=>{E=!0}},[d,a?.apiEndpoint,a?.apiMethod,a?.apiValueField,a?.apiLabelField,s?.apiEndpoint,s?.apiMethod,s?.apiValueField,s?.apiLabelField,w,y,x,v,e.type,i,N]),{isLoading:u,error:f}}const qk=({field:e,value:t,onChange:r,formValues:n,submissionContext:o,disabled:i,readOnly:s,...a})=>{const{isLoading:d}=_g({field:e,formValues:n,submissionContext:o,value:t,onChange:r});return c.jsx(Hi,{field:e,value:t||"",onChange:r,disabled:i||d,readOnly:s||d,...a})},Yk=({field:e,value:t,onChange:r,formValues:n,submissionContext:o,disabled:i,readOnly:s,...a})=>{const{isLoading:d}=_g({field:e,formValues:n,submissionContext:o,value:t,onChange:r});return c.jsx(Ha,{field:e,value:t??null,onChange:r,disabled:i||d,readOnly:s||d,...a})},mn=({field:e,value:t,error:r,onChange:n,onBlur:o,disabled:i,readOnly:s,isRequired:a,className:d,formValues:u={},submissionContext:l,onSubmit:f,onReset:p,onCancel:m,isSubmitting:g,bffSubmitApi:h,onBffSubmitResult:y,extraSubmitPayload:w,buttonResponses:v,onButtonApiResponse:x,onValidateForm:N,getValidationErrors:P,allFields:E,onSubmittingChange:_,onAddMore:C,scopedFormValues:A,scopedFieldNameMap:O,excludedOptionValues:T,prepopulateMappedFieldNames:z,fieldValueKey:q,hideTableRowControls:I=!1,urlParams:$={},prepopulateResponse:M=null,prepopulateLoading:D=!1,formSections:L,submitPayload:U})=>{switch(e.type){case"divider":return c.jsx(R_,{field:e,className:d});case"header":return c.jsx(K_,{field:e,className:d});case"sectionHeading":return c.jsx(X_,{field:e,className:d});case"spacer":return c.jsx(J_,{field:e,className:d});case"textLabel":return c.jsx(Kk,{field:e,className:d,formValues:u,urlParams:$,submissionContext:l,buttonResponses:v,prepopulateResponse:M??void 0,prepopulateLoading:D});case"status":return c.jsx(D_,{field:e,value:t??null,error:r,disabled:i,isRequired:a,className:d,formValues:u,submissionContext:l,extraSubmitPayload:w,prepopulateResponse:M})}switch(e.type){case"text":case"password":case"url":return e.type==="text"&&Bc(e)?c.jsx(qk,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:d,formValues:u,submissionContext:l}):c.jsx(Hi,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:d});case"number":return Bc(e)?c.jsx(Yk,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:d,formValues:u,submissionContext:l}):c.jsx(Ha,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:d});case"email":return c.jsx(fu,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:d});case"phone":case"aadhaar":return c.jsx(pu,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:d});case"textarea":case"richtext":return c.jsx(mu,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:d});case"select":{const j=q??e.name??e.key??e.id,se=!!(j&&z?.has(j));return c.jsx(jp,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:d,formValues:u,submissionContext:l,excludedOptionValues:T,isPrepopulateTarget:se})}case"multiselect":{const j=Array.isArray(t)?t:t!=null&&t!==""?[String(t)]:[];return c.jsx(Fm,{field:e,value:j,onChange:se=>n(se),onBlur:o,error:r,disabled:i,isRequired:a,className:d,formValues:u,submissionContext:l,excludedOptionValues:T})}case"asyncsearch":return c.jsx(am,{field:e,value:t,onChange:j=>n(j),onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:d,formValues:u,submissionContext:l});case"checkbox":case"terms":return c.jsx(Pm,{field:e,value:t||!1,onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:d});case"toggle":return c.jsx(vE,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:d});case"radio":case"checkboxgroup":return c.jsx(nh,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:d,excludedOptionValues:T});case"selectablelist":{const j=Array.isArray(t)?t:[];return console.log("[SelectableList] FieldRenderer: passing to SelectableListField",{fieldName:e.name,value:j,valueLength:j.length,submissionContextKeys:l?Object.keys(l):[]}),c.jsx($_,{field:e,value:j,onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:d,submissionContext:l})}case"date":case"time":case"datetime":case"daterange":return c.jsx(oh,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:d});case"file":return c.jsx(WE,{field:e,value:t,onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:d,buttonResponses:v});case"camera":return c.jsx(xN,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:d});case"photoChoice":return c.jsx(AN,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:d,buttonResponses:v});case"signature":return c.jsx(m_,{field:e,value:t||null,onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:d});case"rating":return c.jsx(GN,{field:e,value:t||0,onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:d});case"slider":return c.jsx(p_,{field:e,value:t||0,onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:d});case"table":return c.jsx(h_,{field:e,value:t||[],onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:d,hideRowControls:I,formValues:u,submissionContext:l});case"billingGrid":return c.jsx(L_,{field:e,value:t||{rows:[]},onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:d});case"button":return c.jsx(DN,{field:e,value:t,onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:d,onSubmit:f,onReset:p,onCancel:m,isSubmitting:g,formValues:u,submissionContext:l,buttonResponses:v,onButtonApiResponse:x,bffSubmitApi:h,onBffSubmitResult:y,extraSubmitPayload:w,onValidateForm:N,getValidationErrors:P,allFields:E,onSubmittingChange:_,scopedFormValues:A,scopedFieldNameMap:O,prepopulateResponse:M,formSections:L,submitPayload:U});case"editButton":return c.jsx(BN,{field:e,disabled:i,readOnly:s,isRequired:a,className:d,buttonResponses:v,onButtonApiResponse:x});case"addmore":return c.jsx($N,{field:e,error:r,disabled:i,readOnly:s,isRequired:a,className:d,onAddMore:()=>C?.(e)});case"customizeSections":return c.jsx(RN,{field:e,error:r,disabled:i,readOnly:s,isRequired:a,className:d});default:return c.jsx("div",{className:"p-3 border rounded-md bg-muted/50",children:c.jsxs("p",{className:"text-sm text-muted-foreground",children:["Unsupported field type: ",e.type]})})}},Xk=({steps:e,currentStep:t,completedSteps:r,onStepClick:n,className:o})=>c.jsx("div",{className:B("mb-8",o),children:c.jsx("nav",{"aria-label":"Progress",children:c.jsx("ol",{className:"flex items-center",children:e.map((i,s)=>{const a=r.has(s),d=t===s,u=n&&(a||s===t+1||s<=t);return c.jsxs("li",{className:B("relative",s!==e.length-1&&"pr-8 sm:pr-20 flex-1"),children:[s!==e.length-1&&c.jsx("div",{className:B("absolute top-4 left-8 -right-8 sm:left-12 sm:-right-12 h-0.5",a?"bg-primary":"bg-border"),"aria-hidden":"true"}),c.jsx("button",{type:"button",onClick:()=>u&&n?.(s),disabled:!u,className:B("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",d&&!a&&"border-2 border-primary text-primary",!a&&!d&&"border-2 border-border text-muted-foreground",u&&"cursor-pointer hover:bg-primary/10",!u&&"cursor-default"),"aria-current":d?"step":void 0,children:a?c.jsx(Ri,{className:"h-4 w-4"}):c.jsx("span",{children:s+1})}),c.jsxs("div",{className:"mt-2",children:[c.jsx("span",{className:B("text-sm font-medium",d&&"text-primary",!d&&!a&&"text-muted-foreground"),children:i.name}),i.description&&c.jsx("p",{className:"text-xs text-muted-foreground hidden sm:block",children:i.description})]})]},i.id)})})})});function yi(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 kg(e){return Array.isArray(e)?e.map(yi):[]}function Jk(e){if(!e.moduleId)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 t;typeof e.moduleId=="object"&&e.moduleId._id?t=yi(e.moduleId):t=e.moduleId;const r=e.isDefault??!1;if(!r&&!e.tenantId)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:r,moduleId:t,tenantId:e.tenantId||void 0,featureId:e.featureId,config:e.config??void 0}}class Qk{basePath="/api/form-builder/forms";async getForRendering(t,r){if(!On())throw new Error("Client ID is required");const o=r!==void 0?`${this.basePath}/${t}/render?version=${r}`:`${this.basePath}/${t}/render`,i=await pn.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,d=s.form||s;if(!d.moduleId&&!s.form?.moduleId)throw new Error(`Form response missing required field: moduleId. Form ID: ${t}. Please ensure the backend returns moduleId in the form response.`);if(!(d.isDefault??s.form?.isDefault??!1)&&!d.tenantId&&!s.form?.tenantId)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&&!d.moduleId&&(d.moduleId=s.form.moduleId),s.form?.tenantId&&!d.tenantId&&(d.tenantId=s.form.tenantId),s.form?.isDefault!==void 0&&d.isDefault===void 0&&(d.isDefault=s.form.isDefault);const l=Jk(d);s.form?.moduleId&&(typeof s.form.moduleId=="object"&&s.form.moduleId._id?l.moduleId=yi(s.form.moduleId):typeof s.form.moduleId=="string"&&(l.moduleId=s.form.moduleId));const f=kg(s.fields||[]),p=s.layout?yi(s.layout):null,m=kg(s.rules||[]),g=s.module?yi(s.module):void 0,h=s.clientMapping||s.clientOverrides;return{form:l,fields:f,layout:p,rules:m,module:g,clientMapping:h,clientOverrides:h,BFF_submit_api:a||void 0}}}const Zk=new Qk;function Mn({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=c.jsxs("div",{className:"text-center",children:[c.jsx("div",{className:B("animate-spin rounded-full border-b-2 border-blue-600 mx-auto mb-4",o[t],e)}),r&&c.jsx("p",{className:"text-gray-600",children:r})]});return n?c.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}const eT={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."},tT=300;function rT(){return{...eT}}function nT(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 oT(e){const t=rT();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:PN(r.sections),submitPayload:FN(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 bi(e,t,r,n){const o=t.map(l=>{let f=[],p={};try{l.options&&(f=JSON.parse(l.options)),l.metadata&&(p=JSON.parse(l.metadata))}catch{}const m=qd(l);m&&Object.assign(p,m),f.length>0&&(p.options=f);const g=[];if(l.validationRequired&&g.push({type:"required",message:"This field is required"}),l.validationMinLength!==null&&l.validationMinLength!==void 0&&g.push({type:"minLength",value:l.validationMinLength,message:`Minimum length is ${l.validationMinLength}`}),l.validationMaxLength!==null&&l.validationMaxLength!==void 0&&g.push({type:"maxLength",value:l.validationMaxLength,message:`Maximum length is ${l.validationMaxLength}`}),l.validationPattern&&g.push({type:"pattern",value:l.validationPattern,message:"Invalid format"}),l.validationRules&&typeof l.validationRules=="object"){const H=l.validationRules;if(H.required===!0&&!g.some(G=>G.type==="required")&&g.push({type:"required",message:"This field is required"}),H.allowLetters!==void 0&&g.push({type:"allowLetters",value:H.allowLetters}),H.allowNumbers!==void 0&&g.push({type:"allowNumbers",value:H.allowNumbers}),H.allowSpecialChars!==void 0&&g.push({type:"allowSpecialChars",value:H.allowSpecialChars}),H.minLetters!==void 0&&typeof H.minLetters=="number"&&g.push({type:"minLetters",value:H.minLetters}),H.maxLetters!==void 0&&typeof H.maxLetters=="number"&&g.push({type:"maxLetters",value:H.maxLetters}),H.minNumbers!==void 0&&typeof H.minNumbers=="number"&&g.push({type:"minNumbers",value:H.minNumbers}),H.maxNumbers!==void 0&&typeof H.maxNumbers=="number"&&g.push({type:"maxNumbers",value:H.maxNumbers}),H.minSpecialChars!==void 0&&typeof H.minSpecialChars=="number"&&g.push({type:"minSpecialChars",value:H.minSpecialChars}),H.maxSpecialChars!==void 0&&typeof H.maxSpecialChars=="number"&&g.push({type:"maxSpecialChars",value:H.maxSpecialChars}),H.fileSize!==void 0&&typeof H.fileSize=="number"){const G=H.fileSize/1048576;g.push({type:"fileSize",value:H.fileSize,message:`File size must be less than ${G.toFixed(2)} MB`})}if(H.fileType!==void 0){const G=Array.isArray(H.fileType)?H.fileType:typeof H.fileType=="string"?H.fileType.split(",").map(ee=>ee.trim()).filter(Boolean):[];G.length>0&&g.push({type:"fileType",value:G,message:"File type is not allowed"})}}const h=[],y=new Set;n.filter(H=>{const G=typeof H.targetFieldId=="object"?H.targetFieldId.id||H.targetFieldId._id:H.targetFieldId;return!!(G===l.id||G===l._id||G&&l.fieldKey&&G===l.fieldKey)}).forEach(H=>{try{const G=JSON.parse(H.conditionExpression);!G.id&&H.id&&(G.id=H.id);const ee=typeof H.targetFieldId=="object"?H.targetFieldId?.id||H.targetFieldId?._id:H.targetFieldId;G.action&&(!G.then||!Array.isArray(G.then)||G.then.length===0)&&(G.then=[{action:G.action,...ee&&{target:ee}}]),(!G.then||!Array.isArray(G.then)||G.then.length===0)&&H.action&&(G.then=[{action:H.action,...ee&&{target:ee}}]),G.then&&Array.isArray(G.then)&&ee&&(G.then=G.then.map(ne=>!ne.target&&ee?{...ne,target:ee}:ne));const de=H.conditionExpression||JSON.stringify(G);if(y.has(de))return;y.add(de),h.push(G)}catch{}});const v=l.disabled===!0||p?.disabled===!0||!1;let x=l.readOnly===!0||p?.readOnly===!0||!1;const N=l.hidden===!0||p?.hidden===!0||!1;(p?.valueSource==="calculated"||p?.formula)&&(x=!0);const{disabled:P,readOnly:E,hidden:_,...C}=p,A={};C.hideLabel!==void 0&&(A.hideLabel=C.hideLabel),C.labelPosition!==void 0&&(A.labelPlacement=C.labelPosition),C.size!==void 0&&(A.size=C.size),C.customClass!==void 0&&(A.className=C.customClass);const{labelPosition:O,size:T,customClass:z,visibility:q,...I}=C,$=Object.keys(I).length>0?I:void 0,M=Object.keys(A).length>0?A:void 0,D=l.visibility??p?.visibility??q;let L=nT(D);if(D&&!L){const H=D;(H.visibleToUserType!=null||H.visibleToUserRole!=null||Array.isArray(H.visibleToUserTypes)&&H.visibleToUserTypes.length>0||Array.isArray(H.visibleToUserRoles)&&H.visibleToUserRoles.length>0||Array.isArray(H.visibleToUserIds)&&H.visibleToUserIds.length>0||Array.isArray(H.hiddenFromUserIds)&&H.hiddenFromUserIds.length>0)&&(L={visibleToUserType:H.visibleToUserType??(Array.isArray(H.visibleToUserTypes)?H.visibleToUserTypes[0]:void 0),visibleToUserRole:H.visibleToUserRole??(Array.isArray(H.visibleToUserRoles)?H.visibleToUserRoles[0]:void 0),visibleToUserIds:H.visibleToUserIds,hiddenFromUserIds:H.hiddenFromUserIds})}const U=p?.columnName,se=!!l.parentFieldId&&typeof U=="string"?U:l.fieldKey;return{id:l.id,type:l.fieldType,name:se,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:M,validation:g.length>0?g:void 0,conditions:h.length>0?h:void 0,properties:$,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:v,readOnly:x,hidden:N}});o.forEach((l,f)=>{if(l.visibility){const p=t[f];console.log("[backendToFormSchema] field with visibility",{fieldKey:p?.fieldKey??l.name,name:l.name,type:l.type,parentFieldId:p?.parentFieldId,visibility:l.visibility})}});const i=t;for(let l=0;l<o.length;l++){const f=i[l]?.parentFieldId;if(f){const p=o.find(g=>g.id===f||g.type==="table"&&g.name===f||g.type==="table"&&i[l].fieldKey?.startsWith?.(g.name+"_column_")),m=o[l];if(p&&p.type==="table"&&m){const g=p.properties||{};Array.isArray(g.columns)||(g.columns=[]),g.columns.push(m),p.properties=g}}}const s=o.filter((l,f)=>!i[f]?.parentFieldId);for(const l of s)if(l.type==="table"&&l.properties&&Array.isArray(l.properties.columns)){const f=l.properties.columns;for(const p of f){const m=p.properties?.columnName;typeof m=="string"&&(p.name=m)}f.sort((p,m)=>(p.position?.order??0)-(m.position?.order??0)||(p.position?.column??0)-(m.position?.column??0))}let a;const d=e.config;if(console.log("[Prepopulate] backendToFormSchema config",{formId:e.id,hasRawConfig:d!=null,rawConfigType:typeof d,rawConfigPreview:d!=null?typeof d=="string"?d.slice(0,300):JSON.stringify(d).slice(0,300):null}),d!=null)try{const l=typeof d=="string"?JSON.parse(d):d;l&&typeof l=="object"?a=oT(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=Ti(r);return u&&(a={...a,grid:u}),{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,moduleId:typeof e.moduleId=="string"?e.moduleId:e.moduleId?.id,tenantId:e.tenantId,featureId:e.featureId,isDefault:e.isDefault}}const iT=3;function To(e){if(typeof e=="number"&&!Number.isNaN(e))return e}function Fo(e,t){const r=e&&typeof e=="object"&&!Array.isArray(e)?e:void 0;return To(r?.cellSlot)??To(r?.stackSlot)??To(r?.cellSlotIndex)??To(r?.slotIndex)??To(t?.cellSlotIndex)??To(t?.stackSlot)}function vi(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 Zs(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=Fo(t.position),o=Fo(r.position);return typeof n=="number"&&typeof o=="number"&&n!==o?n-o:String(t.id).localeCompare(String(r.id))})}function wi(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,$o(o)),n=Math.max(n,_d(o,t));return{rowSpan:r,columnSpan:n}}function Tg(e){const t=$c(e);for(const r of t){const n=vi(r.position);if(n)return n}return t.length>=2?"row":"stack"}function Fg(e){return $c(e).slice(0,iT)}function sT(e,t){const r=new Map;for(const n of e){if(!t(n)||typeof n.position?.order!="number")continue;const o=Zs(n),i=r.get(o)??[];i.push(n),r.set(o,i)}return Array.from(r.values()).map(n=>Fg(n))}function Pg(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 d=Zs(a),u=i.get(d)??[];u.push(a),i.set(d,u)}const s=[...i.values()][0]??[];return Fg(s)}function aT(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:d}=wi(r,n),u=e===i&&t===s-1,l=e>=i&&e<i+a,f=t>=s-1&&t<s-1+d;return l&&f&&!u}function lT(e,t,r){const n=new Set(r??[]);for(const o of e){const i=o[0]?.position?.order??0,{rowSpan:s}=wi(o,t);for(let a=i;a<i+s;a++)n.add(a)}return n}function cT(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 dT(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 yr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Po(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(r=>Po(r));if(!yr(e))return e;const t={};for(const[r,n]of Object.entries(e))t[r]=Po(n);return t}function Og(e,...t){const r={...e};for(const n of t)if(!(!n||!yr(n)))for(const[o,i]of Object.entries(n)){const s=r[o];yr(i)&&yr(s)?r[o]=Og(s,i):r[o]=i}return r}function Qn(e){return yr(e)?e:{}}function Si(e){if(e==null)return{};if(typeof e=="string"){const t=e.trim();if(!t)return{};try{const r=JSON.parse(t);return yr(r)?Po(r):{}}catch{return{}}}return yr(e)?Po(e):{}}function Ig(e){const t=e.apidata;return yr(t)&&Object.keys(t).length>0}function uT(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||Ig(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 Mg=["hideLabel","contentAlign","contentVerticalAlign","labelPlacement","widthPercent","widthMode","className","verticalAlign","horizontalAlign","cellAlign","cellJustify","size","variant","minWidth","minHeight"];function fT(e,t){const r=e.appearance,n=yr(r)&&Object.keys(r).length>0?Po(r):{},o=Qn(t.appearance),i={...n};for(const[s,a]of Object.entries(o))s!=="heightPercent"&&i[s]===void 0&&(i[s]=Po(a));for(const s of Mg)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 pT(e,t){const r=Qn(e.position),n=Si(e.metadata),o=Qn(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,d=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:d},l=r.cellGroupId??o.cellGroupId,f=Fo(r,{cellSlotIndex:e.cellSlotIndex??o.cellSlotIndex,stackSlot:n.stackSlot??o.stackSlot}),p=vi(r)??vi(o)??(n.stackDirection==="horizontal"||o.stackDirection==="horizontal"?"row":n.stackDirection==="vertical"||o.stackDirection==="vertical"?"stack":void 0);return typeof l=="string"&&(u.cellGroupId=l),typeof f=="number"&&(u.cellSlot=f),(p==="row"||p==="stack")&&(u.sharedCellLayout=p),u}function mT(e,t){const r=e,n=Si(r.metadata),o=Qn(r.apidata),i=Qn(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),d=(r.type!=null&&String(r.type).trim()!==""?r.type:void 0)??(typeof r.fieldType=="string"?r.fieldType:void 0),u=fT(r,n),l=pT(r,t),f={...r};return f.properties=s,a!==void 0&&(f.name=a),d!==void 0&&(f.type=d),u!==void 0?f.appearance=u:(!yr(r.appearance)||Object.keys(r.appearance).length===0)&&delete f.appearance,f.position=l,yr(f.appearance)&&delete f.appearance.heightPercent,f}function hT(e,t){if(!e||typeof e!="object")return!0;const r=e,n=Si(r.metadata),o=Object.keys(n).length===0&&!(typeof r.metadata=="string"&&r.metadata.trim()!==""),i=!Ig(r);if(uT(r)||!o||!i)return!1;const s=r.position;return!(!(yr(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")||yr(n.appearance)||Mg.some(u=>n[u]!==void 0&&(r.appearance==null||yr(r.appearance)&&r.appearance[u]===void 0))||gT(r))}function gT(e){const t=Qn(e.position),r=Qn(e.layout),n=Si(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 ea(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(hT(o))return o;const s=mT(o,i);return s!==o&&(r=!0),s});return r?{...e,fields:n}:e}function yT(e){return ea(e)}const bT=new Set(["PENDING_PAYMENT","PAYMENT_PENDING","AWAITING_PAYMENT","PAID","PAYMENT_COMPLETED","PAYMENT_FAILED","REFUNDED","AUTHORIZED","CAPTURED","PARTIALLY_PAID"].map(e=>e.toUpperCase()));function jc(e){return typeof e=="string"&&e.trim()!==""}function zc(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"||jc(t.amount)||typeof t.total_amount=="number"||jc(t.total_amount)||jc(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"&&bT.has(r.trim().toUpperCase()))}function vT(e){const t=Qe(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 wT(e,t){const r=vT(e);if(!r)return;const n=Qe(e,"data"),o=n!=null&&typeof n=="object"&&!Array.isArray(n)?n:void 0;if(t?.treatFirstItemIdAsPaymentId===!0||zc(r.item)||o!=null&&zc(o))return r.id}function ST(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 xT(e){return ST(e).some(t=>t.toLowerCase().includes("payment"))}function AT(e){const t=e.properties,r=e.metadata;return!!(t?.mergeSuccessDataIdAsPaymentId||r?.mergeSuccessDataIdAsPaymentId)}function CT(e,t){if(t?.type!=="button"||!Wo(e))return;const r=Qe(e,"data.id");if(r==null||String(r).trim()==="")return;const n=Qe(e,"data");if(AT(t)||n!=null&&typeof n=="object"&&!Array.isArray(n)&&zc(n)||xT(t))return r}const ET=new Set(["section","group","columns","divider","header","sectionHeading","spacer","addmore","textLabel","customizeSections"]);function NT(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 _T(e,t){const r=e.properties,n=Array.isArray(r?.linkedFieldNames)?r.linkedFieldNames:[],o=NT(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 Lg(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 kT(e,t){return Lg(e,t).find(r=>r.heading?.enabled)}function Dg(e,t){const r=e.template??"";return(e.mode??"increment")==="fixed"?r:r.replace(/\{n\}/g,String(t+1))}function Bg(e,t,r,n){const o=_T(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||ET.has(s.type)?!1:i.has(a)})}function TT(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 Uc(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 FT(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 d=Uc(a).map(u=>r(u)).filter(Boolean);i.push({section:s,fieldNames:d})}return i}function xi(e,t=0){return e.heading?.enabled?Dg(e.heading,t):e.name}function $g(e,t,r){if(e.type!=="sectionHeading")return!1;const n=t.heading;return!n?.enabled||!n.headingFieldName?!1:r(e)===n.headingFieldName}function PT(e,t){const r=typeof e.position?.order=="number"?e.position.order:0,n=(e.position?.column??1)-1,o=$o(e),i=_d(e,t);return{row:r,col:n,rowEnd:r+o-1,colEnd:n+i-1}}function Vc(e,t){let r=1/0,n=-1/0,o=1/0,i=-1/0;for(const s of e){const{row:a,col:d,rowEnd:u,colEnd:l}=PT(s,t);r=Math.min(r,a),n=Math.max(n,u),o=Math.min(o,d),i=Math.max(i,l)}return Number.isFinite(r)?{minRow:r,maxRow:n,minCol:o,maxCol:i,rowSpan:n-r+1,colSpan:i-o+1}:null}function OT(e,t,r,n){const o=e.map(l=>t.find(f=>n(f)===l)).filter(l=>!!l&&typeof l.position?.order=="number");if(o.length===0)return null;const i=Vc(o,r);if(!i)return null;const s=o.filter(l=>l.type!=="sectionHeading"),a=s.length>0?s:o,d=Math.min(...a.map(l=>l.position?.order??0)),u=Math.max(1,...a.map(l=>(l.position?.order??d)-d+$o(l)));return{minRow:i.minRow,maxRow:i.maxRow,minCol:i.minCol,maxCol:i.maxCol,blockHeight:u}}function IT(e,t){return e.maxRow+1+t*e.blockHeight}function MT(e,t,r,n){const o=new Map;for(const a of t){const d=r(a);d&&o.set(d,a)}const i=new Map,s=new Set;for(const a of e){const d=a.fieldNames.map(v=>o.get(v)).filter(v=>!!v);if(d.length===0)continue;const u=d.filter(v=>!$g(v,a.section,r)),l=Vc(d,n);if(!l)continue;const{minRow:f,minCol:p,rowSpan:m,colSpan:g}=l,h=`${f}-${p}`;if(i.has(h))continue;const y=new Set;let w=!1;for(let v=f;v<=f+m-1;v++){for(let x=p;x<=p+g-1;x++){const N=`${v}-${x}`;if(s.has(N)){w=!0;break}y.add(N)}if(w)break}if(!w){for(const v of y)s.add(v);i.set(h,{anchorRow:f,anchorCol:p,rowSpan:m,colSpan:g,run:a,legend:xi(a.section,0),renderFields:u.length>0?u:d})}}return{anchorsByOrigin:i,coveredCells:s}}function LT(e,t,r,n,o,i,s){const a=new Set(s),d=new Map;for(const u of e){const l=jg(u.linkedFields.map(p=>i(p)).filter(Boolean),t),f=l?.section;f?.fieldNames?.length?f.fieldNames:u.templateFieldNames,u.blockIds.forEach((p,m)=>{const g=r.filter(_=>_.id.endsWith(`__${p}`));if(g.length===0||!l)return;const h=Vc(g,o);if(!h)return;const{minRow:y,minCol:w,rowSpan:v,colSpan:x}=h,N=`${y}-${w}`;for(let _=y;_<=y+v-1;_++)for(let C=w;C<=w+x-1;C++)a.add(`${_}-${C}`);const P=l,E=xi(f,m+1);d.set(N,{anchorRow:y,anchorCol:w,rowSpan:v,colSpan:x,run:P,legend:E,renderFields:Uc(g),addMoreMeta:{addMoreFieldName:u.addMoreFieldName,blockId:p,blockIndex:m}})})}return{anchorsByOrigin:d,coveredCells:a}}function DT(e,t,r,n){const o=`${e}-${t}`;return r.has(o)?!n.get(o):!1}function BT(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 $T(e,t,r,n){return!(!n||r.run.section.collapsible!==!0||e===r.anchorRow&&t===r.anchorCol)}function jT(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 zT(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 UT(e,t){return new Map([...e,...t])}function VT(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),d=a?n.get(a):void 0;if(!d){o.push({kind:"field",field:s}),i+=1;continue}const u=[],l=new Set(d.fieldNames);for(;i<e.length;){const p=r(e[i]);if(!p||!l.has(p))break;const m=e[i];$g(m,d.section,r)||u.push(m),i+=1}if(u.length===0)continue;const f=o[o.length-1];f?.kind==="border"&&f.run.section.id===d.section.id?f.fields.push(...u):o.push({kind:"border",run:d,fields:u})}return o}function jg(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 HT=2*6e4,zg=50;class WT{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<=zg)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-zg)).forEach(([n])=>this.map.delete(n))}}function RT(e){return(e??"").trim()||"default"}function Ug(e){const t=RT(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 Vg=new WT(HT);function Hg(e){const t=Ug(e),r=Vg.get(t);return r?{value:r.value,isStale:r.isStale}:null}function Wg(e,t){const r=Ug(e);Vg.set(r,t)}function Rg(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 Hc=({schema:e,formId:t,initialValues:r,onSubmit:n,onChange:o,onValidationError:i,onClose:s,mode:a="fill",className:d,children:u,gridLayout:l,unstyled:f=!1,submissionContext:p,onWorkflowSubmitResult:m,initialExtraSubmitPayload:g,onExtraSubmitPayloadChange:h,workflowStepId:y,viewerContext:w,getViewerContext:v,hideTableRowControls:x=!1,themeVars:N,dark:P=!1,omitRootWrapper:E=!1})=>{const _=qn(k=>k.viewerContext),C=S.useMemo(()=>{if(w!==void 0)return w;const k=v?.();return k!==void 0?k:_},[w,v,_]),[A,O]=S.useState(e||null),[T,z]=S.useState(!!t&&!e),[q,I]=S.useState(null),$=e?.BFF_submit_api??q,[M,D]=S.useState(!1),[L,U]=S.useState({}),[j,se]=S.useState({}),[H,G]=S.useState({}),[ee,de]=S.useState({}),[ne,K]=S.useState({}),[re,Te]=S.useState(null),Z=wa.useParams(),te=Nt(k=>k.setValues),he=Nt(k=>k.setSubmitting),le=Nt(k=>k.formDisabled),Xe=Nt(k=>k.visibleFields),ge=Nt(k=>k.requiredFields),Se=Nt(k=>k.updateVisibility),ae=Nt(k=>k.updateRequired),ve=Nt(k=>k.setFieldError),He=S.useRef(!1),dt=S.useRef(void 0),Ge=S.useMemo(()=>{if(!e)return null;const k=e;if(k.form&&Array.isArray(k.form.fields))try{return bi(k.form,k.form.fields,k.form.layout||null,k.form.rules||[])}catch{return e}if(Array.isArray(k.fields)&&k.fields.some(V=>typeof V.metadata=="string"&&V.metadata.startsWith("{")||V.fieldType&&!V.type))try{const V={id:k.id||k._id||"temp",name:k.name||"Form",version:k.version??1,status:k.status||"draft",createdAt:k.createdAt||new Date().toISOString(),updatedAt:k.updatedAt||new Date().toISOString(),createdBy:k.createdBy||"system",category:k.category||"",moduleId:k.moduleId,tenantId:k.tenantId,featureId:k.featureId,isDefault:k.isDefault||!1};return bi(V,k.fields,k.layout||null,k.rules||[])}catch{return e}return e},[e]);S.useEffect(()=>{if(e){const k=e;k.BFF_submit_api&&I(k.BFF_submit_api)}},[e]);const Rt=S.useMemo(()=>{const k=Ge||A,W=k?ea(k):null;if(!W)return null;const V=W.layout,Q=W.rules,J=W.clientMapping,ce=(Array.isArray(W.fields)?W.fields:[]).map(De=>{let Ue={...De};if(De.validationRules&&typeof De.validationRules=="object"&&!De.validation){const fe=De.validationRules,Oe=[];fe.required===!0&&Oe.push({type:"required",message:"This field is required"}),fe.minLength!==void 0&&typeof fe.minLength=="number"&&Oe.push({type:"minLength",value:fe.minLength,message:`Minimum length is ${fe.minLength}`}),fe.maxLength!==void 0&&typeof fe.maxLength=="number"&&Oe.push({type:"maxLength",value:fe.maxLength,message:`Maximum length is ${fe.maxLength}`}),fe.pattern&&typeof fe.pattern=="string"&&Oe.push({type:"pattern",value:fe.pattern,message:"Invalid format"}),fe.allowLetters!==void 0&&Oe.push({type:"allowLetters",value:fe.allowLetters}),fe.allowNumbers!==void 0&&Oe.push({type:"allowNumbers",value:fe.allowNumbers}),fe.allowSpecialChars!==void 0&&Oe.push({type:"allowSpecialChars",value:fe.allowSpecialChars}),Oe.length>0&&(Ue={...Ue,validation:Oe})}const xe=De.required===!0||De.isRequired===!0,Ae=Array.isArray(Ue.validation)&&Ue.validation.some(fe=>fe.type==="required");if(xe&&!Ae){const fe={type:"required",message:"This field is required"},Oe=Array.isArray(Ue.validation)?Ue.validation:[];Ue={...Ue,validation:[...Oe,fe]}}if(De.apidata&&typeof De.apidata=="object"){const fe=De.apidata,Oe=Ue.properties||{},we=(Ue.type||De.fieldType)==="status";if(!Oe.apiEndpoint&&fe.apiEndpoint){const ut={...Oe,apiEndpoint:fe.apiEndpoint,apiMethod:fe.apiMethod,apiKey:fe.apiKey,apiRealtime:fe.apiRealtime,apiAutoDetect:fe.apiAutoDetect,apiLabelField:fe.apiLabelField,apiValueField:fe.apiValueField,apiQueryParams:fe.apiQueryParams,apiClientFilter:fe.apiClientFilter,apiHeaders:fe.apiHeaders,apiBodyFields:fe.apiBodyFields,apiAuth:fe.apiAuth,valueSource:fe.valueSource||(fe.apiEndpoint?"api":void 0),optionsSource:fe.optionsSource||(fe.apiEndpoint?"api":void 0)};we&&(ut.source=Oe.source??"api",Oe.statuses!==void 0&&(ut.statuses=Oe.statuses),Oe.dataPath!==void 0&&(ut.dataPath=Oe.dataPath),Oe.showStatusText!==void 0&&(ut.showStatusText=Oe.showStatusText),Oe.statusTextPath!==void 0&&(ut.statusTextPath=Oe.statusTextPath),Oe.showCurrentIndicator!==void 0&&(ut.showCurrentIndicator=Oe.showCurrentIndicator)),Ue={...Ue,properties:ut}}}const Ve=["select","multiselect","radio","checkboxgroup"],ot=Ue.type||De.fieldType;if(Ve.includes(ot)){const fe=De.options,Oe=Ue.properties?.options,we=Array.isArray(Oe)&&Oe.length>0;if(Array.isArray(fe)&&fe.length>0&&!we){const ut=Ue.properties||{};Ue={...Ue,properties:{...ut,options:fe}}}}return Ue}),Ce=W.config?.rules,Ne=Q&&Array.isArray(Q)?Q:Ce&&Array.isArray(Ce)?Ce:[],Be=Ne.length>0?ce.map(De=>{if((De.conditions&&Array.isArray(De.conditions)?De.conditions:[]).length>0)return De;const xe=De.id??De._id,Ae=De.name||De.key,Ve=Ne.filter(Oe=>{const we=typeof Oe.targetFieldId=="object"?Oe.targetFieldId?.id??Oe.targetFieldId?._id:Oe.targetFieldId;return we?we===xe||we===Ae||we===De.fieldKey:!1});if(Ve.length===0)return De;const ot=[],fe=new Set;return Ve.forEach(Oe=>{try{const we=typeof Oe.conditionExpression=="string"?JSON.parse(Oe.conditionExpression):Oe.conditionExpression;if(!we||typeof we!="object")return;!we.id&&Oe.id&&(we.id=Oe.id);const ut=typeof Oe.targetFieldId=="object"?Oe.targetFieldId?.id??Oe.targetFieldId?._id:Oe.targetFieldId;we.action&&(!we.then||!Array.isArray(we.then)||we.then.length===0)&&(we.then=[{action:we.action,...ut&&{target:ut}}]),(!we.then||!Array.isArray(we.then)||we.then.length===0)&&Oe.action&&(we.then=[{action:Oe.action,...ut&&{target:ut}}]),we.then&&Array.isArray(we.then)&&ut&&(we.then=we.then.map(Dt=>!Dt.target&&ut?{...Dt,target:ut}:Dt));const Vt=Oe.conditionExpression??JSON.stringify(we);if(fe.has(Vt))return;fe.add(Vt),ot.push(we)}catch{}}),ot.length===0?De:{...De,conditions:ot}}):ce;let lt=W.config||{submitAction:"database",layout:"default",autoSave:!0,validateOnChange:!0,showFieldErrors:"inline"};return!lt.layout&&V?typeof V=="object"&&V!==null?lt.layout="default":typeof V=="string"&&["default","card","compact"].includes(V)?lt.layout=V:lt.layout="default":lt.layout||(lt.layout="default"),Q&&!lt.rules&&(lt.rules=Q),J&&!lt.clientMapping&&(lt.clientMapping=J),{...W,fields:Be,config:lt}},[Ge,A]);S.useEffect(()=>{Ge&&Ge!==A&&O(Ge)},[Ge]),S.useEffect(()=>{if(t&&!e){const k=(On()??"").trim()||"default",W=Hg({scope:k,formId:t,version:"latest"});W?.value?.schema?(O(W.value.schema),W.value.bffSubmitApi&&I(W.value.bffSubmitApi),z(!1),W.isStale&&Je({background:!0})):Je({background:!1})}},[t,e]);const Je=async({background:k})=>{if(!t)return;const W=t;k||z(!0);try{const V=await Zk.getForRendering(t),Q=bi(V.form,V.fields,V.layout,V.rules);if(W!==t)return;O(Q),V.BFF_submit_api&&I(V.BFF_submit_api);const J=(On()??"").trim()||"default";Wg({scope:J,formId:W,version:"latest"},{schema:Q,bffSubmitApi:V.BFF_submit_api})}catch{}finally{k||z(!1)}};if(T)return c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx(Mn,{})});if(!Rt)return c.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Form not found"});const Y=Rt,je=S.useMemo(()=>new Set(Object.keys(Y.config?.prepopulateApi?.fieldMapping??{})),[Y.config?.prepopulateApi?.fieldMapping]),gt=S.useCallback(async k=>{const W=Y?.fields?.length?cc(k,Y.fields):k,V=_h(W,Y.config?.sections,Y.config?.submitPayload);if(n){const Q=p?{...V,...p}:V;return n(Q)}return{success:!0}},[n,p,Y?.fields,Y.config?.sections,Y.config?.submitPayload]),{values:Ie,errors:oe,touched:pe,isSubmitting:We,isValid:Tt,submitCount:ze,currentStep:Fe,totalSteps:Ke,completedSteps:nt,currentStepFields:yt,isLastStep:Yt,setFieldValue:St,setFieldTouched:Pe,handleSubmit:ft,validateForm:et,resetForm:xt,nextStep:ur,goToStep:on,shouldShowField:Nr,isFieldEnabled:rr,isFieldRequired:Gr,loadDraft:hn}=Xd({schema:Y,initialValues:r,onSubmit:gt,onChange:o,workflowStepId:y});gv({fields:Y.fields,values:Ie,buttonResponses:j,prepopulateResponse:re,prepopulateResponseRules:Y.config?.prepopulateResponseRules});const Ft=Nt(k=>k.readOnlyFields),br=Nt(k=>k.editableFields),Io=S.useCallback(k=>Ft.has(k),[Ft]),sn=S.useCallback(k=>br.has(k),[br]);S.useEffect(()=>{Y.config?.allowDraft&&a==="fill"&&hn()},[Y.id]),S.useEffect(()=>{dt.current=Y.id,He.current=!1,U({}),G({}),de({}),K({}),Te(null)},[Y.id]),S.useEffect(()=>{const k=Y.config?.prepopulateApi,W=!!(k?.fieldMapping&&Object.keys(k?.fieldMapping??{}).length>0),V=(Y.config?.prepopulateResponseRules?.length??0)>0;if(!k?.enabled||!k.apiEndpoint?.trim()||!W&&!V||He.current)return;He.current=!0;const Q=Y.id;dt.current=Y.id;let J=!1;return D(!0),(async()=>{try{const ce=Nt.getState().values,Ce=typeof p=="object"&&p!==null?{...p,...g||{}}:g||{},Ne=ie=>Wr(ie,ce,Z,Ce);let Be=rn(Ne(k.apiEndpoint));if(k.apiQueryParams?.length){const ie=new URLSearchParams;k.apiQueryParams.forEach(({key:Me,value:me})=>ie.append(Me,Ne(me))),Be=`${Be}${Be.includes("?")?"&":"?"}${ie.toString()}`}const lt={};k.apiHeaders?.forEach(({key:ie,value:Me})=>{ie.trim()&&(lt[ie]=Ne(Me))}),lt["Content-Type"]=lt["Content-Type"]??"application/json";let Ut;if(k.apiMethod==="POST"&&k.apiBodyFields?.length){const ie={};k.apiBodyFields.forEach(({key:Me,value:me})=>{Me.trim()&&(ie[Me]=Ne(me))}),Ut=JSON.stringify(ie)}const De=await fetch(Be,{method:k.apiMethod,headers:lt,body:k.apiMethod==="POST"?Ut:void 0});if(!De.ok){const ie=await De.text();throw new Error(ie||`HTTP ${De.status}`)}const Ue=await De.json(),xe=ie=>{try{return ie.split("?")[0].split("/").filter(Boolean).pop()||ie}catch{return ie}},Ae=(ie,Me)=>{if(ie==null)return null;const me=typeof ie=="string"?ie:ie instanceof Date?ie.toISOString():null;if(!me)return null;const qe=typeof ie=="object"&&ie instanceof Date?ie:new Date(me);if(Number.isNaN(qe.getTime()))return null;const pt=mt=>String(mt).padStart(2,"0");if(Me==="date")return me.length>=10&&me[4]==="-"&&me[7]==="-"?me.slice(0,10):qe.toISOString().slice(0,10);if(Me==="time")return`${pt(qe.getHours())}:${pt(qe.getMinutes())}:${pt(qe.getSeconds())}`;if(Me==="datetime"){const mt=qe.getFullYear(),rt=qe.getMonth()+1,ue=qe.getDate(),bt=qe.getHours(),Re=qe.getMinutes(),kt=qe.getSeconds();return`${mt}-${pt(rt)}-${pt(ue)}T${pt(bt)}:${pt(Re)}:${pt(kt)}`}return null},Ve=(ie,Me)=>{const me=Y.fields.find(ue=>ue.name===ie||ue.key===ie);if(!me)return Me;if((me.type==="file"||me.type==="camera"||me.type==="photoChoice")&&typeof Me=="string"&&Me.startsWith("http"))return{url:Me,name:xe(Me)};if(me.type==="date"||me.type==="datetime"||me.type==="time"){const ue=Ae(Me,me.type);if(ue!==null)return ue}if(me.type==="multiselect")return Array.isArray(Me)?Me.map(ue=>typeof ue=="string"?ue:String(ue)):typeof Me=="string"?Me.trim()===""?[]:Me.includes(",")?Me.split(",").map(ue=>ue.trim()).filter(Boolean):[Me]:Me!=null&&Me!==""?[String(Me)]:[];if(me.type!=="radio"&&me.type!=="select")return Me;const qe=me.properties?.options??me.options;if(!Array.isArray(qe)||qe.length===0)return Me;const pt=qe.map(ue=>ue.value);if(pt.includes(Me))return Me;const mt=String(Me);if(pt.includes(mt))return mt;const rt=qe.find(ue=>ue.value==Me);return rt?rt.value:Me},ot=new Set(Y.fields.filter(ie=>ie.type==="table").map(ie=>ie.name||ie.key)),fe=new Set(Y.fields.filter(ie=>ie.type==="billingGrid").map(ie=>ie.name||ie.key)),Oe=ie=>ie.name||ie.key||ie.id,we={},ut=[],Vt=[],Dt=ON(k?.fieldMapping,Y.config?.sections,Y.config?.submitPayload);for(const[ie,Me]of Object.entries(Dt)){if(!Me?.trim()||ie.startsWith("__"))continue;const me=Qe(Ue,Me),qe=ie.indexOf(".");if(qe>0&&fe.has(ie.slice(0,qe))){const mt=ie.slice(0,qe),rt=ie.slice(qe+1),bt=Y.fields.find(Re=>(Re.name||Re.key)===mt)?.properties;if(bt?.rowSlots?.length){const Re=rt.startsWith("__block__")?rt.slice(9):rt,kt=we[mt]??Nt.getState().values[mt];Array.isArray(me)?we[mt]=k_(bt,Re,me,kt):me!=null&&(we[mt]=xc(bt,me,kt))}continue}if(qe>0&&ot.has(ie.slice(0,qe))){const mt=ie.slice(0,qe),rt=ie.slice(qe+1);ut.push({tableName:mt,columnName:rt,path:Me});continue}if(fe.has(ie)&&me!==void 0&&me!==null&&typeof me=="object"){const rt=Y.fields.find(ue=>(ue.name||ue.key)===ie)?.properties;if(rt?.rowSlots?.length){if(Array.isArray(me)){const ue=rt.rowSlots.find(bt=>bt.kind==="dynamic");if(ue&&ue.kind==="dynamic"){const bt=ue.block.apiArrayPath??"items";we[ie]=xc(rt,{[bt]:me})}}else we[ie]=xc(rt,me);continue}}if(ot.has(ie)&&Array.isArray(me)&&me.length>0&&typeof me[0]=="object"&&me[0]!==null){const rt=Y.fields.find(Re=>(Re.name||Re.key)===ie)?.properties?.columns||[],ue=me.map(Rg),bt=Re=>(Re||"").toLowerCase().replace(/\s+/g,"_").trim();we[ie]=ue.map(Re=>{const kt={};for(const pr of rt){const to=pr.name??"";kt[to]=Re[bt(to)]??Re[to]}return kt});continue}if(me!=null&&(we[ie]=Ve(ie,me)),me==null)continue;let pt=me;if(Array.isArray(me)){const mt=Y.fields.find(rt=>Oe(rt)===ie);if(mt?.type==="addmore"){Vt.push({addMoreFieldName:ie,array:me});continue}if(mt?.type==="multiselect"){const rt=k.multiselectArrayPropertyMap?.[ie];rt&&me.length>0&&me.some(ue=>ue!=null&&typeof ue=="object")&&(pt=me.map(ue=>ue!=null&&typeof ue=="object"&&rt in ue?ue[rt]:void 0).filter(ue=>ue!=null))}}we[ie]=Ve(ie,pt)}const ct={},vt={},or={};for(const{addMoreFieldName:ie,array:Me}of Vt){const me=Y.fields.find(bt=>Oe(bt)===ie);if(!me||me.type!=="addmore")continue;const qe=Bg(me,Y.fields,Y.config?.sections,Oe);if(qe.length===0)continue;const pt=k.addMoreFieldKeyMap?.[ie],mt=Me.length>0&&Me[0]!=null&&typeof Me[0]=="object"?Me[0]:null;if(mt)for(const bt of qe){const Re=Oe(bt),kt=pt&&pt[Re]||Re,pr=mt[kt];pr!=null&&(we[Re]=Ve(Re,pr))}const rt=Me.slice(1),ue=rt.map((bt,Re)=>`prepop_${ie}_${Re}_${Date.now()}`);ue.length>0&&(vt[ie]=ue);for(let bt=0;bt<rt.length;bt++){const Re=rt[bt];if(Re==null||typeof Re!="object")continue;const kt=Re,pr=kt.id;pr!=null&&String(pr).trim()!==""&&(or[`${ie}__${ue[bt]}`]=String(pr));for(const to of qe){const va=Oe(to),BP=pt&&pt[va]||va,rd=kt[BP];if(rd==null)continue;const $P=`${va}__addmore__${ie}__${ue[bt]}`;ct[$P]=Ve(va,rd)}}}Object.keys(vt).length>0&&G(ie=>({...ie,...vt})),Object.keys(or).length>0&&K(ie=>({...ie,...or}));const $r=ie=>(ie||"").toLowerCase().replace(/\s+/g,"_").trim(),qr=[...new Set(ut.map(ie=>ie.tableName))];for(const ie of qr){if(Array.isArray(we[ie]))continue;const Me=ut.find(ue=>ue.tableName===ie);if(!Me?.path?.includes("."))continue;const me=Me.path.replace(/\.[^.]+$/,""),qe=Qe(Ue,me);if(!Array.isArray(qe)||qe.length===0||typeof qe[0]!="object"||qe[0]===null)continue;const mt=Y.fields.find(ue=>(ue.name||ue.key)===ie)?.properties?.columns||[],rt=qe.map(Rg);we[ie]=rt.map(ue=>{const bt={};for(const Re of mt){const kt=Re.name??"",pr=$r(kt),to=ue[pr]??ue[kt];bt[kt]=to}return bt})}const jr=(ie,Me)=>{const me=Qe(Ue,ie);if(Array.isArray(me))return me;if(me!=null)return[me];if(!ie.includes("."))return[];const qe=ie.replace(/\.[^.]+$/,""),pt=Qe(Ue,qe);return!Array.isArray(pt)||pt.length===0||typeof pt[0]!="object"||pt[0]===null?[]:pt.map(mt=>{const rt=mt[Me];if(rt!==null&&typeof rt=="object"&&!Array.isArray(rt)&&!(rt instanceof Date)){const ue=rt;return typeof ue.name=="string"&&typeof ue.code=="string"?`${ue.code} ${ue.name}`.trim():typeof ue.name=="string"?ue.name:typeof ue.code=="string"?ue.code:typeof ue.short_code=="string"?ue.short_code:ue.name??ue.code??""}return rt})};for(const{tableName:ie,columnName:Me,path:me}of ut){const qe=jr(me,Me),mt=Y.fields.find(Re=>(Re.name||Re.key)===ie)?.properties?.columns||[],rt=mt.find(Re=>(Re.name||"").toLowerCase()===Me.toLowerCase())?.name??Me;let ue=Array.isArray(we[ie])?we[ie]:[];const bt=Math.max(ue.length,qe.length);if(bt>ue.length)for(ue=[...ue];ue.length<bt;){const Re={};mt.forEach(kt=>{Re[kt.name||""]=""}),ue.push(Re)}else ue=ue.map(Re=>({...Re}));qe.forEach((Re,kt)=>{ue[kt]&&(ue[kt][rt]=Re)}),we[ie]=ue}if(dt.current===Q){if(Object.keys(we).length>0||Object.keys(ct).length>0){const kt={...Nt.getState().values,...we,...ct};te(kt)}const Me=Qe(Ue,"data.user_id"),me=Qe(Ue,"data.items"),qe=Qe(Ue,"data");let pt=Array.isArray(me)&&me.length>0&&me[0]!=null&&typeof me[0]=="object"&&me[0].id?me[0].id:void 0;pt===void 0&&Array.isArray(qe)&&qe.length>0&&qe[0]!=null&&typeof qe[0]=="object"&&qe[0].id&&(pt=qe[0].id),pt===void 0&&(pt=Qe(Ue,"data.0.id"));const mt=wT(Ue,{treatFirstItemIdAsPaymentId:k?.treatFirstItemIdAsPaymentId===!0}),rt=Qe(Ue,"data.id"),ue=Qe(Ue,"data.batch_id"),bt=Qe(Ue,"data.program_id"),Re={};Me!=null&&(Re.context_user_id=Me),pt!=null&&pt!==""&&(Re.documentId=pt),rt!=null&&String(rt).trim()!==""&&(p?.id===void 0||p?.id===null)&&(Re.id=rt),ue!=null&&String(ue).trim()!==""&&((p?.admission_batch_id===void 0||p?.admission_batch_id===null)&&(Re.admission_batch_id=ue),(p?.batch_id===void 0||p?.batch_id===null)&&(Re.batch_id=ue)),bt!=null&&String(bt).trim()!==""&&(p?.program_id===void 0||p?.program_id===null)&&(Re.program_id=bt),mt!=null&&String(mt).trim()!==""&&(p?.payment_id===void 0||p?.payment_id===null)&&(Re.payment_id=mt),Object.keys(Re).length>0&&U(kt=>{const pr={...kt,...Re};return h?.(pr),pr}),Te(Ue)}}catch(ce){J||ac(ce,"Prepopulate request failed.",fi)}finally{D(!1)}})(),()=>{J=!0}},[Y.id,Y.config?.prepopulateApi?.enabled,Y.config?.prepopulateApi?.apiEndpoint,Y.config?.prepopulateApi?.apiMethod,JSON.stringify(Y.config?.prepopulateApi?.fieldMapping),Y.config?.prepopulateApi?.treatFirstItemIdAsPaymentId,p,g,Z,te,G]),S.useEffect(()=>{Object.keys(oe).length>0&&i?.(oe)},[oe,i]);const Lr=Ke>1,Xt=a==="view",vr=S.useCallback((k,W)=>Xt||!!W&&!sn(k)||Io(k)&&!sn(k),[Xt,sn,Io]),Ot=Y.fields.filter(k=>!k.parentId),Et=[...Lr?yt:Ot.length>0?Ot:Y.fields].filter(k=>!(!k||typeof k!="object"||!k.name&&!k.key)).sort((k,W)=>{const V=typeof k.position?.order=="number"?k.position.order:typeof k.positionOrder=="number"?k.positionOrder:Number.MAX_SAFE_INTEGER,Q=typeof W.position?.order=="number"?W.position.order:typeof W.positionOrder=="number"?W.positionOrder:Number.MAX_SAFE_INTEGER;if(V!==Q)return V-Q;const J=typeof k.position?.column=="number"?k.position.column:1,ce=typeof W.position?.column=="number"?W.position.column:1;return J-ce}),an=S.useCallback(k=>{const W=Nt.getState().errors,V=Object.keys(W).find(Q=>k.includes(Q));V&&requestAnimationFrame(()=>{document.querySelector(`[data-field-name="${V}"]`)?.scrollIntoView({behavior:"smooth",block:"center"})})},[]),Qt=async k=>{if(k?.preventDefault(),Lr&&!Yt){if(!await ur())try{const Q=Nt.getState().errors;Bt.toast.error(lc(Q,Y.fields)||"Please fix the errors before continuing."),an(Et.map(J=>J.name||J.key||J.id).filter(Boolean))}catch{Bt.toast.error("Please fix the errors before continuing.")}return}const W=await ft(k);if(W&&W.success===!1&&W.errors?.length)try{const V=Nt.getState().errors;Bt.toast.error(lc(V,Y.fields)||"Submission failed. Please check the form."),an(Et.map(Q=>Q.name||Q.key||Q.id).filter(Boolean))}catch{Bt.toast.error("Submission failed. Please check the form.")}return W},wr=S.useCallback(()=>{xt(),s&&s()},[xt,s]),fr=S.useCallback((k,W)=>{const V=Y.fields.find(J=>J.type==="button"&&(J.name===k||J.key===k)),Q=CT(W,V);Q!=null&&String(Q).trim()!==""&&(p?.payment_id===void 0||p?.payment_id===null)&&U(J=>{const ce={...J,payment_id:Q};return h?.(ce),ce}),se(J=>{const ce={...J,[k]:W};return!Wo(W)||!(V?.type==="button"&&V.properties?.action==="submit")||Y.fields.filter(Be=>Be.type==="editButton").map(Be=>Be.name).forEach(Be=>delete ce[Be]),ce})},[Y.fields,p,h]),Sr=S.useCallback(async()=>await et(),[et]),Gt=S.useCallback(()=>Nt.getState().errors,[]),nr=S.useMemo(()=>({...g||{},...L}),[g,L]),Dr=S.useMemo(()=>({...typeof p=="object"&&p!==null?p:{},...nr}),[p,nr]),na=Y.config?.layout??Y.layout??"default",oa=["default","card","compact"].includes(na)?na:"default",ia={default:"",card:"bg-card border rounded-lg shadow-sm p-6",compact:"space-y-2"},Ei=S.useMemo(()=>{if(E)return;const k=Y.config?.theme?.cssVariables;if(!(!k&&!N))return{...k??{},...N??{}}},[E,Y.config?.theme?.cssVariables,N]),_r=S.useMemo(()=>Fi({config:Y.config,layout:Y.layout},l),[Y.config,Y.layout,l]),Ee=S.useMemo(()=>_r?{..._r,verticalSpacing:_r.verticalSpacing??_r.spacing??"16px",horizontalSpacing:_r.horizontalSpacing??_r.spacing??"16px",rowHeight:_r.rowHeight??Dn}:null,[_r]),F=Ee!==null;Ee?.rows;const X=Ee?.columns??3,ye=Ee?.verticalSpacing??Ee?.spacing??"16px",st=Ee?.horizontalSpacing??Ee?.spacing??"16px",_t=Ee?.rowHeight??Dn,wt=S.useCallback(k=>{if(!C)return!0;const W=k.visibility;if(!W)return!0;const V=W.visibleToUserType??W.user_type,Q=W.visibleToUserRole??W.user_role,J=Array.isArray(W.visibleToUserIds)?W.visibleToUserIds:Array.isArray(W.users)?W.users:[],ce=Array.isArray(W.hiddenFromUserIds)?W.hiddenFromUserIds:[];if(Array.isArray(ce)&&ce.length>0&&C.userId!=null&&ce.includes(C.userId))return!1;if(J.length>0&&C.userId!=null&&J.includes(C.userId))return!0;const Ce=V!=null&&V!==""&&C.userType!=null&&C.userType!==V,Ne=Q!=null&&Q!==""&&C.role!=null&&C.role!==Q,Be=J.length>0&&(C.userId==null||!J.includes(C.userId));return!(Ce||Ne||Be)},[C]),It=S.useMemo(()=>VN(Y.fields),[Y.fields]),Br=S.useMemo(()=>WN(Y.fields),[Y.fields]),[sr,Mo]=S.useState(Br);S.useEffect(()=>{Mo(Br)},[Y.id,Br]);const Mt=S.useCallback((k,W)=>{Mo(V=>V[k]===W?V:{...V,[k]:W})},[]),sa=S.useMemo(()=>({visibility:sr,setSectionVisible:Mt,fieldToHeading:It,allFields:Y.fields}),[sr,Mt,It,Y.fields]),tt=S.useCallback(k=>k.name||k.key||k.id,[]),kr=k=>{if(!wt(k))return!1;const W=k.name||k.key||k.id;if(!Fh(W,k.type,sr,It))return!1;const V=k.hidden===!0;return Nr(W)||!V&&W},Ty=S.useCallback(k=>{const W=Y.fields.find(Q=>tt(Q)===k);if(W)return W.type;const V=Th(k);return Y.fields.find(Q=>tt(Q)===V)?.type},[Y.fields,tt]),aa=S.useCallback(k=>Fh(k,Ty(k),sr,It),[sr,It,Ty]),gn=S.useCallback(k=>aa(k)?Gr(k):!1,[aa,Gr]);S.useEffect(()=>{const{visibleFields:k,requiredFields:W,errors:V}=Nt.getState(),Q=new Set(k),J=new Set(W),ce=[];for(const Ce of Y.fields){const Ne=tt(Ce);Ne&&(aa(Ne)||(Q.delete(Ne),J.delete(Ne),V[Ne]&&ce.push(Ne)))}Se(Array.from(Q)),ae(Array.from(J));for(const Ce of ce)ve(Ce,void 0)},[sr,It,Y.fields,Y.id,tt,aa,Se,ae,ve,Xe,ge]);const Lt=Y.config?.sections,Zn=S.useCallback(k=>{let W=k;if(k.type==="table"){const Q=k.properties?.columns;if(Array.isArray(Q)&&Q.length>0){const J=Q.filter(ce=>wt(ce));W={...k,properties:{...k.properties,columns:J}}}}const V=TT(W,Lt,tt);return V?{...W,label:Dg(V,0)}:W},[wt,Lt,tt]),yn=S.useCallback(k=>Bg(k,Y.fields,Lt,tt),[Y.fields,Lt,tt]),Kr=S.useCallback((k,W,V)=>`${k}__addmore__${W}__${V}`,[]),la=S.useCallback((k,W)=>`${k}__${W??"base"}`,[]),ca=S.useCallback((k,W)=>{const V=la(k.id,W);return ee[V]??k.defaultCollapsed??!1},[ee,la]),Zc=S.useCallback((k,W,V)=>{const Q=la(k,W);de(J=>J[Q]===V?J:{...J,[Q]:V})},[la]),da=S.useMemo(()=>{const k=[],W=Y.fields.filter(V=>V.type==="addmore");for(const V of W){const Q=tt(V),ce=yn(V).find(lt=>{if(lt.type!=="button")return!1;const Ut=lt.properties,De=lt.metadata;let Ue=Ut?.action;if(!Ue&&De!=null)try{Ue=(typeof De=="string"?JSON.parse(De):De)?.action}catch{}return Ue==="upload"||Ue==="custom"});if(!ce)continue;const Ce=tt(ce),Ne=H[Q]||[],Be=Qe(j[Ce],"data.id")??Qe(j[Ce],"data.documentId")??L.documentId;Be!=null&&String(Be).trim()!==""&&k.push(String(Be));for(const lt of Ne){const Ut=Kr(Ce,Q,lt),De=Qe(j[Ut],"data.id")??Qe(j[Ut],"data.documentId"),Ue=ne[`${Q}__${lt}`],xe=De??Ue;xe!=null&&String(xe).trim()!==""&&k.push(String(xe))}}return k},[Y.fields,H,j,ne,L.documentId,tt,yn,Kr]);S.useEffect(()=>{U(k=>{const W={...k,document_ids:da},V=k.document_ids;return Array.isArray(V)&&V.length===da.length&&da.every((Q,J)=>V[J]===Q)?k:W})},[da]);const ua=S.useCallback((k,W,V,Q)=>{for(const J of V){const ce=tt(J),Ce=Kr(ce,k,W),Ne=Q[Ce];if(Ne==null)continue;const Be=J.type;if(Be==="file"||Be==="camera"||Be==="photoChoice"){if(typeof Ne=="object"&&Ne!==null&&("url"in Ne||"name"in Ne)||Array.isArray(Ne)&&Ne.length>0)return!0;continue}if(Array.isArray(Ne)){if(Ne.length>0)return!0;continue}if(typeof Ne=="string"&&Ne.trim()!==""||typeof Ne=="number"&&!Number.isNaN(Ne)||typeof Ne=="boolean"||typeof Ne=="object"&&Ne!==null&&Object.keys(Ne).length>0)return!0}return!1},[tt,Kr]),eo=S.useCallback(k=>{const W=tt(k);if(!W)return;if(yn(k).length===0){Bt.toast.error("No linked fields configured for this Add More button.");return}const Q=`${Date.now()}_${Math.random().toString(36).slice(2,8)}`;G(J=>({...J,[W]:[...J[W]||[],Q]}))},[tt,yn]),fa=S.useCallback((k,W)=>{G(V=>{const Q=V[k]||[],J=Q.filter(ce=>ce!==W);if(J.length===Q.length)return V;if(J.length===0){const ce={...V};return delete ce[k],ce}return{...V,[k]:J}})},[]),pa=S.useMemo(()=>Et.filter(k=>!k.parentId),[Et]),Ln=S.useMemo(()=>{const k=[];return Et.filter(V=>V.type==="addmore").sort((V,Q)=>{const J=V.position?.order??0,ce=Q.position?.order??0;return J-ce}).forEach(V=>{const Q=tt(V),J=V.position?.order??0,ce=H[Q]||[],Ce=yn(V).sort((Ae,Ve)=>{const ot=Ae.position?.order??0,fe=Ve.position?.order??0;return ot!==fe?ot-fe:(Ae.position?.column??1)-(Ve.position?.column??1)});if(Ce.length===0)return;const Ne=Lg(V,Lt),Be=Ne[0]?.fieldNames?.length?Ne[0].fieldNames:Ce.map(Ae=>tt(Ae)).filter(Boolean),lt=OT(Be,pa,X,tt),Ut=Math.min(...Ce.map(Ae=>Ae.position?.order??0)),De=Math.max(1,...Ce.map(Ae=>(Ae.position?.order??Ut)-Ut+$o(Ae))),Ue=lt?.blockHeight??De,xe=ce.length*Ue;k.push({addMoreFieldName:Q,baseOrder:J,blockHeight:Ue,blockIds:ce,linkedFields:Ce,insertedRows:xe,templateFieldNames:Be,templateBounds:lt})}),k},[Et,pa,X,tt,H,yn,Lt]),Ni=S.useMemo(()=>({}),[]),ma=S.useMemo(()=>Ln.length===0?Et:Et.map(k=>{const W=k.position?.order??0,V=Ln.reduce((Q,J)=>{const ce=J.templateBounds?.maxRow??J.baseOrder;return W>ce?Q+J.insertedRows:Q},0);return V===0?k:{...k,position:{...k.position,order:W+V}}}),[Et,Ln]),ha=S.useCallback(k=>{const W={};return Object.entries(j).forEach(([V,Q])=>{const J=k[V];J&&(W[J]=Q)}),W},[j]),Lo=S.useMemo(()=>{const k=[],W={};return Ln.forEach(V=>{const{addMoreFieldName:Q,blockIds:J,linkedFields:ce,blockHeight:Ce,templateBounds:Ne}=V,Be=Math.min(...ce.map(De=>De.position?.order??0)),Ut=Y.fields.find(De=>tt(De)===Q&&De.type==="addmore")?.properties;J.forEach((De,Ue)=>{const xe={},Ae={},Ve={},ot=Ne?IT(Ne,Ue):V.baseOrder+1+Ue*Ce,fe=ne[`${Q}__${De}`];ce.forEach(we=>{const ut=tt(we),Vt=Kr(ut,Q,De),Dt=(we.position?.order??Be)-Be;if(xe[Vt]=ut,Ae[Vt]=Ie[Vt],!(Ut?.linkedFieldAllowDuplicate?.[ut]??!0)&&(we.type==="select"||we.type==="radio"||we.type==="multiselect")){const vt=[],or=Ie[ut];or!=null&&or!==""&&(Array.isArray(or)?vt.push(...or.map(qr=>String(qr))):vt.push(String(or))),J.filter(qr=>qr!==De).forEach(qr=>{const jr=Kr(ut,Q,qr),Yr=Ie[jr];Yr!=null&&Yr!==""&&(Array.isArray(Yr)?vt.push(...Yr.map(ie=>String(ie))):vt.push(String(Yr)))}),vt.length>0&&(Ve[Vt]=[...new Set(vt)])}k.push({...we,id:`${we.id}__${De}`,name:Vt,position:{...we.position,order:ot+Dt}})});const Oe=ha(xe);Object.keys(xe).forEach(we=>{W[we]={scopedFormValues:Ae,scopedFieldNameMap:xe,scopedButtonResponses:Oe,...fe!=null&&{blockDocumentId:fe},...Ve[we]&&{excludedOptionValues:Ve[we]}}})})}),{clonedFields:k,scopeByFieldName:W}},[Ln,ne,tt,Kr,Ie,ha,Y.fields]),_i=S.useMemo(()=>[...ma,...Lo.clonedFields].sort((k,W)=>{const V=k.position?.order??0,Q=W.position?.order??0;if(V!==Q)return V-Q;const J=k.position?.column??1,ce=W.position?.column??1;if(J!==ce)return J-ce;const Ce=Fo(k.position)??0,Ne=Fo(W.position)??0;return Ce!==Ne?Ce-Ne:String(k.id).localeCompare(String(W.id))}),[ma,Lo.clonedFields]),Do=S.useMemo(()=>sT(_i.filter(k=>!k.parentId),kr),[_i,kr]),ed=S.useCallback((k,W)=>Do.some(V=>aT(k,W,V,X)),[Do,X]);Do.length===0||Math.max(...Do.map(k=>(k[0]?.position?.order??0)+wi(k,X).rowSpan));const ga=S.useMemo(()=>FT(Lt,Uc(Et.filter(k=>!k.parentId)),tt),[Lt,Et,tt]),{anchorsByOrigin:Fy,coveredCells:Py}=S.useMemo(()=>MT(ga,ma,tt,X),[ga,ma,tt,X]),{anchorsByOrigin:Oy,coveredCells:Iy}=S.useMemo(()=>LT(Ln.map(k=>({addMoreFieldName:k.addMoreFieldName,blockIds:k.blockIds,linkedFields:k.linkedFields,templateFieldNames:k.templateFieldNames})),Lt,Lo.clonedFields,pa,X,tt,Py),[Ln,Lt,Lo.clonedFields,pa,X,tt,Py]),bn=S.useMemo(()=>UT(Fy,Oy),[Fy,Oy]),My=S.useMemo(()=>Iy,[Iy]),Ly=String(_t).endsWith("px")?_t:Dn,Dy=S.useCallback((k,W)=>{for(let V=0;V<X;V++){if(V>=W.anchorCol&&V<W.anchorCol+W.colSpan)continue;if(Ni[`${k}-${V}`]||bn.get(`${k}-${V}`)||Pg(k,V,_i,kr).length>0||ed(k,V))return!0}return!1},[X,Ni,bn,_i,kr,ed]),By=S.useMemo(()=>jT(bn,k=>{const W=k.run.section;return W.collapsible?ca(W,k.addMoreMeta?.blockId):!1},Dy),[bn,ca,Dy]),$y=S.useMemo(()=>{const k=[];for(const W of Object.keys(Ni)){const V=Number(W.split("-")[0]);Number.isNaN(V)||k.push(V)}for(const W of bn.values())if(W.renderFields.some(V=>kr(V)))for(let V=W.anchorRow;V<W.anchorRow+W.rowSpan;V++)k.push(V);return lT(Do,X,k)},[Do,X,Ni,bn,kr]),{originalToDisplayRow:ya,displayRowCount:IP,sortedOccupiedRows:MP}=S.useMemo(()=>{const k=cT($y);return{originalToDisplayRow:k.originalToDisplay,displayRowCount:k.displayRowCount,sortedOccupiedRows:k.sortedOriginalRows}},[$y]),jy=Math.max(IP,1),td=S.useCallback((k,W=1)=>dT(k,W,ya),[ya]),zy=S.useMemo(()=>{const k=new Set;for(const W of By){const V=ya.get(W);V!==void 0&&k.add(V)}return k},[By,ya]),LP=S.useMemo(()=>zT(jy,Ly,zy),[jy,Ly,zy]),DP=S.useMemo(()=>VT(Et.filter(k=>!k.parentId&&kr(k)),ga,tt),[Et,ga,tt,kr]),ba=S.useCallback(k=>{if(F)return null;const W=tt(k),V=H[W]||[];if(V.length===0)return null;const Q=yn(k);if(Q.length===0)return null;const J=kT(k,Lt),ce=Q.map(Be=>tt(Be)).filter(Boolean),Ce=jg(ce,Lt),Ne=(Be,lt,Ut,De,Ue,xe,Ae)=>{const Ve=tt(Be),ot=Kr(Ve,W,lt),fe=Be.hidden===!0;if(!(wt(Be)&&(Nr(Ve)||!fe&&Ve)))return null;const we={...Be,id:`${Be.id}__${lt}`,name:ot},Vt=k.properties?.linkedFieldAllowDuplicate?.[Ve]??!0;let Dt;if(!Vt&&(Be.type==="select"||Be.type==="radio"||Be.type==="multiselect")){const ct=[],vt=Ie[Ve];vt!=null&&vt!==""&&(Array.isArray(vt)?ct.push(...vt.map($r=>String($r))):ct.push(String(vt))),V.filter($r=>$r!==lt).forEach($r=>{const qr=Kr(Ve,W,$r),jr=Ie[qr];jr!=null&&jr!==""&&(Array.isArray(jr)?ct.push(...jr.map(Yr=>String(Yr))):ct.push(String(jr)))}),ct.length>0&&(Dt=[...new Set(ct)])}return c.jsx("div",{"data-field-name":ot,"data-form-renderer":"field-wrapper",children:c.jsx(mn,{field:we,value:Ie[ot],error:pe[ot]||ze>0?oe[ot]:void 0,onChange:ct=>St(ot,ct),onBlur:()=>Pe(ot),disabled:le||!rr(Ve)||Xt||!!Be.disabled,readOnly:vr(Ve,!!Be.readOnly),isRequired:gn(Ve),formValues:Ie,submissionContext:Dr,prepopulateMappedFieldNames:je,urlParams:Z,prepopulateResponse:re,prepopulateLoading:M,formSections:Lt,submitPayload:Y.config?.submitPayload,fieldValueKey:ot,buttonResponses:xe,onButtonApiResponse:fr,onSubmit:Qt,onReset:xt,onCancel:wr,isSubmitting:We,bffSubmitApi:$,onBffSubmitResult:m,extraSubmitPayload:Ae,onValidateForm:Sr,getValidationErrors:Gt,allFields:Y.fields,onSubmittingChange:he,scopedFormValues:Ue,scopedFieldNameMap:De,excludedOptionValues:Dt,hideTableRowControls:x})},we.id)};return c.jsx("div",{className:"space-y-3 mt-3",children:V.map((Be,lt)=>{const Ut={},De={};Q.forEach(Dt=>{const ct=tt(Dt),vt=Kr(ct,W,Be);Ut[vt]=ct,De[vt]=Ie[vt]});const Ue=ha(Ut),xe=ua(W,Be,Q,Ie),Ae=J?.heading!=null?xi(J,lt+1):null,Ve=ne[`${W}__${Be}`],ot=Ve!=null?{...nr,documentId:Ve}:nr,fe=Q.map(Dt=>Ne(Dt,Be,lt,Ut,De,Ue,ot)).filter(Boolean),we=Ce?.section?.collapsible===!0,ut=c.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:xe,title:xe?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:Dt=>{Dt.preventDefault(),Dt.stopPropagation(),fa(W,Be)},children:c.jsx(Yo,{className:"h-5 w-5","aria-hidden":!0})}),Vt=c.jsxs(c.Fragment,{children:[!we&&c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[Ae?c.jsx("p",{className:"text-sm font-medium text-foreground",children:Ae}):c.jsxs("p",{className:"text-xs text-muted-foreground",children:["Entry ",lt+1]}),ut]}),fe]});return c.jsx("div",{className:"rounded-md border p-3 space-y-3",children:Ce?c.jsx(Dc,{legend:Ce.section.heading?.enabled?xi(Ce.section,lt+1):Ce.section.name,collapsible:Ce.section.collapsible,defaultCollapsed:Ce.section.defaultCollapsed,headerActions:we?ut:void 0,onCollapsedChange:Dt=>Zc(Ce.section.id,Be,Dt),children:Vt}):Vt},`${k.id}-${Be}`)})})},[F,H,ne,tt,yn,Kr,ua,Ie,pe,ze,oe,St,Pe,rr,Xt,gn,Dr,je,fr,Qt,xt,wr,We,$,m,nr,Sr,Gt,Y.fields,he,Nr,wt,ha,fa,x,Lt,Z,re,M]);return c.jsx("div",{className:E?B("relative",d):B(Sa,P&&"dark",d),style:Ei,"data-form-renderer":E?void 0:"root",children:c.jsxs("div",{className:"relative",children:[M&&c.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/60 rounded-md",children:c.jsx(Mn,{})}),c.jsx("form",{onSubmit:Qt,className:f?B("w-full min-w-0"):B("space-y-6 pb-[100px] w-full min-w-0",ia[oa]),"data-form-renderer":"form","data-form-renderer-layout":F?"grid":"stack",children:c.jsxs(jN,{value:sa,children:[Lr&&Y.steps&&c.jsx(Xk,{steps:Y.steps,currentStep:Fe,completedSteps:nt,onStepClick:on}),c.jsx(Oa.Provider,{value:{gridStretch:F},children:F?c.jsx("div",{className:f?"w-full min-w-0":"grid w-full min-w-0",style:{display:"grid",gridTemplateRows:LP,gridTemplateColumns:`repeat(${X}, 1fr)`,rowGap:ye,columnGap:st},"data-form-renderer":"grid",children:MP.map(k=>Array.from({length:X},(W,V)=>{const Q=td(k);if(!Q)return null;if(ed(k,V))return c.jsx("div",{className:"min-w-0 min-h-0",style:{gridRow:Q,gridColumn:V+1,visibility:"hidden",pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`empty-${k}-${V}`);if(DT(k,V,My,bn)){const xe=BT(k,V,bn);return xe&&$T(k,V,xe,ca(xe.run.section,xe.addMoreMeta?.blockId))?null:c.jsx("div",{className:"min-w-0 min-h-0",style:{gridRow:Q,gridColumn:V+1,visibility:"hidden",pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`section-border-cover-${k}-${V}`)}const J=bn.get(`${k}-${V}`);if(J){const xe=J.renderFields.filter(ct=>kr(ct));if(xe.length===0)return null;const Ae=J.addMoreMeta,Ve=Ae!=null?Ln.find(ct=>ct.addMoreFieldName===Ae.addMoreFieldName)?.linkedFields??[]:[],ot=Ae!=null?ua(Ae.addMoreFieldName,Ae.blockId,Ve,Ie):!1,fe=J.run.section,Oe=Ae?.blockId,we=ca(fe,Oe),ut=fe.collapsible&&we?1:J.rowSpan,Vt=td(J.anchorRow,ut)??Q,Dt=Ae!=null?c.jsx("button",{type:"button",className:B("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",f&&"text-red-600 hover:bg-red-500/10"),disabled:ot,title:ot?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:ct=>{ct.preventDefault(),ct.stopPropagation(),fa(Ae.addMoreFieldName,Ae.blockId)},children:c.jsx(Yo,{className:"h-5 w-5","aria-hidden":!0})}):void 0;return c.jsx("div",{className:B("min-h-0 min-w-0",!(fe.collapsible&&we)&&"self-stretch"),style:{gridRow:Vt,gridColumn:`${V+1} / span ${J.colSpan}`},"data-form-renderer":"grid-cell","data-form-renderer-config-section-border-cell":!0,children:c.jsx(Dc,{legend:J.legend,className:fe.collapsible&&we?void 0:"h-full",collapsible:fe.collapsible,defaultCollapsed:fe.defaultCollapsed,headerActions:Dt,onCollapsedChange:ct=>Zc(fe.id,Oe,ct),children:c.jsx("div",{className:"grid w-full min-w-0",style:{gridTemplateColumns:`repeat(${X}, 1fr)`,gridTemplateRows:`repeat(${J.rowSpan}, minmax(${String(_t).endsWith("px")?_t:Dn}, auto))`,rowGap:ye,columnGap:st},children:xe.map(ct=>{const vt=tt(ct),or=Lo.scopeByFieldName[vt],$r=or?.scopedFieldNameMap?.[vt]||vt,qr=(ct.position?.order??J.anchorRow)-J.anchorRow,jr=ct.position?.column??1,{rowSpan:Yr,columnSpan:ie}=wi([ct],X),Me=Ae!=null?ne[`${Ae.addMoreFieldName}__${Ae.blockId}`]:void 0,me=Me!=null?{...nr,documentId:Me}:nr;return c.jsx("div",{"data-field-name":vt,"data-form-renderer":"field-wrapper",className:"min-h-0 min-w-0",style:{gridRow:`${qr+1} / span ${Yr}`,gridColumn:`${jr} / span ${ie}`,...En(ct)},children:c.jsx(mn,{field:Zn(ct),value:Ie[vt],error:pe[vt]||ze>0?oe[vt]:void 0,onChange:qe=>St(vt,qe),onBlur:()=>Pe(vt),disabled:(ct.type==="table"||ct.type==="billingGrid")&&a==="fill"?!1:le||!rr($r)||Xt||!!ct.disabled,readOnly:(ct.type==="table"||ct.type==="billingGrid")&&a==="fill"?!1:vr($r,!!ct.readOnly),isRequired:gn($r),formValues:Ie,submissionContext:Dr,prepopulateMappedFieldNames:je,urlParams:Z,prepopulateResponse:re,prepopulateLoading:M,formSections:Lt,submitPayload:Y.config?.submitPayload,fieldValueKey:vt,buttonResponses:or?.scopedButtonResponses??j,onButtonApiResponse:fr,onSubmit:Qt,onReset:xt,onCancel:wr,isSubmitting:We,bffSubmitApi:$,onBffSubmitResult:m,extraSubmitPayload:me,onValidateForm:Sr,getValidationErrors:Gt,allFields:Y.fields,onSubmittingChange:he,onAddMore:eo,scopedFormValues:or?.scopedFormValues,scopedFieldNameMap:or?.scopedFieldNameMap,excludedOptionValues:or?.excludedOptionValues,hideTableRowControls:x})},ct.id)})})})},`section-border-${J.run.section.id}-${k}-${V}-${Ae?.blockId??"base"}`)}const ce=Pg(k,V,_i,kr).filter(xe=>!(tt(xe)?.includes("__addmore__")&&My.has(`${k}-${V}`)));if(ce.length===0){const xe=Ni[`${k}-${V}`];if(xe){const Ae=Y.fields.find(fe=>fe.type==="addmore"&&tt(fe)===xe.addMoreFieldName),Ve=Ae!=null?yn(Ae):[],ot=ua(xe.addMoreFieldName,xe.blockId,Ve,Ie);return c.jsx("div",{className:"min-h-0 min-w-0 flex flex-col items-center justify-center",style:{gridRow:Q,gridColumn:V+1},"data-form-renderer":"grid-cell","data-form-renderer-add-more-remove":!0,children:c.jsx("button",{type:"button",className:B("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",f&&"text-red-600 hover:bg-red-500/10"),disabled:ot,title:ot?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:fe=>{fe.preventDefault(),fe.stopPropagation(),fa(xe.addMoreFieldName,xe.blockId)},children:c.jsx(Yo,{className:"h-5 w-5","aria-hidden":!0})})},`add-more-remove-${k}-${V}`)}return c.jsx("div",{className:"min-w-0",style:{pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`empty-${k}-${V}`)}const Ce=ce[0],{rowSpan:Ne,columnSpan:Be}=wi(ce,X),lt=td(k,Ne)??Q;if(ce.length===1&&Ce.type==="section"){const xe=Y.fields.filter(Ae=>Ae.parentId===Ce.id&&Ae.position!=null).sort((Ae,Ve)=>{const ot=typeof Ae.position?.order=="number"?Ae.position.order:0,fe=typeof Ve.position?.order=="number"?Ve.position.order:0;return ot-fe});return c.jsx("div",{className:"min-w-0 min-h-0 w-full overflow-hidden flex flex-col h-full",style:{gridRow:lt,gridColumn:`${V+1} / span ${Be}`,...En(Ce)},"data-form-renderer":"grid-cell",children:c.jsx(Zh,{field:Ce,children:xe.map(Ae=>{const Ve=Ae.name||Ae.key||Ae.id,ot=Ae.hidden===!0;return wt(Ae)&&(Nr(Ve)||!ot&&Ve)?c.jsx("div",{"data-field-name":Ve,"data-form-renderer":"field-wrapper",children:c.jsx(mn,{field:Zn(Ae),value:Ie[Ve],error:pe[Ve]||ze>0?oe[Ve]:void 0,onChange:Oe=>St(Ve,Oe),onBlur:()=>Pe(Ve),disabled:le||!rr(Ve)||Xt||!!Ae.disabled,readOnly:vr(Ve,!!Ae.readOnly),isRequired:gn(Ve),formValues:Ie,submissionContext:Dr,prepopulateMappedFieldNames:je,urlParams:Z,prepopulateResponse:re,prepopulateLoading:M,formSections:Lt,submitPayload:Y.config?.submitPayload,fieldValueKey:Ve,buttonResponses:j,onButtonApiResponse:fr,onSubmit:Qt,onReset:xt,onCancel:wr,isSubmitting:We,bffSubmitApi:$,onBffSubmitResult:m,extraSubmitPayload:nr,onValidateForm:Sr,getValidationErrors:Gt,allFields:Y.fields,onSubmittingChange:he,onAddMore:eo,hideTableRowControls:x})},Ae.id):null})})},Ce.id)}const Ut=Tg(ce),De=ce.some(xe=>["file","camera","photoChoice","addmore","table","billingGrid"].includes(xe.type)),Ue=c.jsx("div",{className:B("flex min-h-0 w-full flex-1 gap-3",Ut==="row"?"flex-row items-stretch":"flex-col items-stretch"),children:ce.map(xe=>{const Ae=xe.name||xe.key||xe.id,Ve=xe.type==="sectionHeading",ot=Lo.scopeByFieldName[Ae],fe=ot?.scopedFieldNameMap?.[Ae]||Ae,Oe=ot?.blockDocumentId!=null?{...nr,documentId:ot.blockDocumentId}:nr,we=xe.appearance?.hideLabel??xe.properties?.hideLabel??!1,ut=xe.type==="table"||xe.type==="billingGrid"?xe.properties?.minWidth:void 0;return c.jsx("div",{"data-field-name":Ae,"data-form-renderer":"field-wrapper",className:B("flex min-h-0 min-w-0 flex-1 flex-col",Uo(xe),Ve&&"items-center justify-center",we&&"items-center"),style:{...ut?{minWidth:ut}:{},...En(xe)},children:c.jsx(mn,{field:Zn(xe),value:Ie[Ae],error:pe[Ae]||ze>0?oe[Ae]:void 0,onChange:Vt=>St(Ae,Vt),onBlur:()=>Pe(Ae),disabled:(xe.type==="table"||xe.type==="billingGrid")&&a==="fill"?!1:le||!rr(fe)||Xt||!!xe.disabled,readOnly:(xe.type==="table"||xe.type==="billingGrid")&&a==="fill"?!1:vr(fe,!!xe.readOnly),isRequired:gn(fe),formValues:Ie,submissionContext:Dr,prepopulateMappedFieldNames:je,urlParams:Z,prepopulateResponse:re,prepopulateLoading:M,formSections:Lt,submitPayload:Y.config?.submitPayload,fieldValueKey:Ae,buttonResponses:ot?.scopedButtonResponses??j,onButtonApiResponse:fr,onSubmit:Qt,onReset:xt,onCancel:wr,isSubmitting:We,bffSubmitApi:$,onBffSubmitResult:m,extraSubmitPayload:Oe,onValidateForm:Sr,getValidationErrors:Gt,allFields:Y.fields,onSubmittingChange:he,onAddMore:eo,scopedFormValues:ot?.scopedFormValues,scopedFieldNameMap:ot?.scopedFieldNameMap,excludedOptionValues:ot?.excludedOptionValues,hideTableRowControls:x})},xe.id)})});return c.jsx("div",{className:B(Td(ce),"self-stretch",De?"overflow-visible":"overflow-hidden"),style:{gridRow:lt,gridColumn:`${V+1} / span ${Be}`,...En(ce[0])},"data-form-renderer":"grid-cell","data-field-name":ce.map(xe=>xe.name||xe.key||xe.id).join(","),children:Ue},ce.map(xe=>xe.id).join("-"))}))}):c.jsx("div",{className:f?"":"space-y-4","data-form-renderer":"stack",children:Et.map(k=>{if(!kr(k))return null;const W=DP.find(Q=>Q.kind==="border"&&Q.fields.some(J=>J.id===k.id));if(W)return W.fields[0]?.id!==k.id?null:c.jsx(Dc,{legend:xi(W.run.section,0),collapsible:W.run.section.collapsible,defaultCollapsed:W.run.section.defaultCollapsed,onCollapsedChange:Q=>Zc(W.run.section.id,void 0,Q),children:W.fields.map(Q=>{const J=tt(Q);return!J||!kr(Q)?null:c.jsxs("div",{"data-field-name":J,"data-form-renderer":"field-wrapper",style:En(Q),children:[c.jsx(mn,{field:Zn(Q),value:Ie[J],error:pe[J]||ze>0?oe[J]:void 0,onChange:ce=>St(J,ce),onBlur:()=>Pe(J),disabled:(Q.type==="table"||Q.type==="billingGrid")&&a==="fill"?!1:le||!rr(J)||Xt||!!Q.disabled,readOnly:(Q.type==="table"||Q.type==="billingGrid")&&a==="fill"?!1:vr(J,!!Q.readOnly),isRequired:gn(J),formValues:Ie,submissionContext:Dr,prepopulateMappedFieldNames:je,urlParams:Z,prepopulateResponse:re,prepopulateLoading:M,formSections:Lt,submitPayload:Y.config?.submitPayload,fieldValueKey:J,buttonResponses:j,onButtonApiResponse:fr,onSubmit:Qt,onReset:xt,onCancel:wr,isSubmitting:We,bffSubmitApi:$,onBffSubmitResult:m,extraSubmitPayload:nr,onValidateForm:Sr,getValidationErrors:Gt,allFields:Y.fields,onSubmittingChange:he,onAddMore:eo,hideTableRowControls:x}),Q.type==="addmore"&&ba(Q)]},Q.id)})},`stack-border-${W.run.section.id}-${k.id}`);if(!k.parentId){const Q=Et.filter(ce=>!ce.parentId&&kr(ce)&&Zs(ce)===Zs(k)),J=$c(Q).slice(0,2);if(J.length>1&&J[0].id!==k.id)return null;if(J.length>1){const ce=Tg(J);return c.jsx("div",{"data-form-renderer":"shared-cell-stack",className:B("flex w-full min-w-0 gap-3",ce==="row"?"flex-row items-stretch":"flex-col"),children:J.map(Ce=>{const Ne=Ce.name||Ce.key||Ce.id;return c.jsxs("div",{"data-field-name":Ne,"data-form-renderer":"field-wrapper",className:B("min-w-0 flex-1 flex flex-col",Uo(Ce)),style:En(Ce),children:[c.jsx(mn,{field:Zn(Ce),value:Ie[Ne],error:pe[Ne]||ze>0?oe[Ne]:void 0,onChange:Be=>St(Ne,Be),onBlur:()=>Pe(Ne),disabled:(Ce.type==="table"||Ce.type==="billingGrid")&&a==="fill"?!1:le||!rr(Ne)||Xt||!!Ce.disabled,readOnly:(Ce.type==="table"||Ce.type==="billingGrid")&&a==="fill"?!1:vr(Ne,!!Ce.readOnly),isRequired:gn(Ne),formValues:Ie,submissionContext:Dr,prepopulateMappedFieldNames:je,urlParams:Z,prepopulateResponse:re,prepopulateLoading:M,formSections:Lt,submitPayload:Y.config?.submitPayload,fieldValueKey:Ne,buttonResponses:j,onButtonApiResponse:fr,onSubmit:Qt,onReset:xt,onCancel:wr,isSubmitting:We,bffSubmitApi:$,onBffSubmitResult:m,extraSubmitPayload:nr,onValidateForm:Sr,getValidationErrors:Gt,allFields:Y.fields,onSubmittingChange:he,onAddMore:eo,hideTableRowControls:x}),Ce.type==="addmore"&&ba(Ce)]},Ce.id)})},J.map(Ce=>Ce.id).join("-"))}}if(k.type==="section"){const Q=Y.fields.filter(J=>J.parentId===k.id&&J.position!=null).sort((J,ce)=>{const Ce=typeof J.position?.order=="number"?J.position.order:0,Ne=typeof ce.position?.order=="number"?ce.position.order:0;return Ce-Ne});return c.jsx(Zh,{field:k,children:Q.map(J=>{const ce=J.name||J.key||J.id,Ce=J.hidden===!0;return wt(J)&&(Nr(ce)||!Ce&&ce)?c.jsxs("div",{"data-field-name":ce,"data-form-renderer":"field-wrapper",style:En(J),children:[c.jsx(mn,{field:Zn(J),value:Ie[ce],error:pe[ce]||ze>0?oe[ce]:void 0,onChange:Be=>St(ce,Be),onBlur:()=>Pe(ce),disabled:le||!rr(ce)||Xt||!!J.disabled,readOnly:vr(ce,!!J.readOnly),isRequired:gn(ce),formValues:Ie,submissionContext:Dr,prepopulateMappedFieldNames:je,urlParams:Z,prepopulateResponse:re,prepopulateLoading:M,formSections:Lt,submitPayload:Y.config?.submitPayload,fieldValueKey:ce,buttonResponses:j,onButtonApiResponse:fr,onSubmit:Qt,onReset:xt,onCancel:wr,isSubmitting:We,bffSubmitApi:$,onBffSubmitResult:m,extraSubmitPayload:nr,onValidateForm:Sr,getValidationErrors:Gt,allFields:Y.fields,onSubmittingChange:he,onAddMore:eo,hideTableRowControls:x}),J.type==="addmore"&&ba(J)]},J.id):null})},k.id)}const V=k.name||k.key||k.id;return c.jsxs("div",{"data-field-name":V,"data-form-renderer":"field-wrapper",style:En(k),children:[c.jsx(mn,{field:Zn(k),value:Ie[V],error:pe[V]||ze>0?oe[V]:void 0,onChange:Q=>St(V,Q),onBlur:()=>Pe(V),disabled:(k.type==="table"||k.type==="billingGrid")&&a==="fill"?!1:le||!rr(V)||Xt||!!k.disabled,readOnly:(k.type==="table"||k.type==="billingGrid")&&a==="fill"?!1:vr(V,!!k.readOnly),isRequired:gn(V),formValues:Ie,submissionContext:Dr,prepopulateMappedFieldNames:je,urlParams:Z,prepopulateResponse:re,prepopulateLoading:M,formSections:Lt,submitPayload:Y.config?.submitPayload,fieldValueKey:V,buttonResponses:j,onButtonApiResponse:fr,onSubmit:Qt,onReset:xt,onCancel:wr,isSubmitting:We,bffSubmitApi:$,onBffSubmitResult:m,extraSubmitPayload:nr,onValidateForm:Sr,getValidationErrors:Gt,allFields:Y.fields,onSubmittingChange:he,onAddMore:eo,hideTableRowControls:x}),k.type==="addmore"&&ba(k)]},k.id)})})}),u]})})]})})};function Wc(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function Gg(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}function GT(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,f)=>{if(!l||typeof l!="object")return null;const p={...l};if(l.fieldType&&!p.type&&(p.type=l.fieldType),l.fieldKey&&!p.key&&!p.name&&(p.key=l.fieldKey,p.name=l.fieldKey),typeof l.positionOrder=="number"&&!isNaN(l.positionOrder)?p.order=l.positionOrder:p.order=f,(typeof p.order!="number"||isNaN(p.order))&&(p.order=f),l.options&&typeof l.options=="string")try{p.options=JSON.parse(l.options)}catch{}if(l.metadata&&typeof l.metadata=="string")try{p.metadata=JSON.parse(l.metadata)}catch{}return p}).filter(l=>l!=null).sort((l,f)=>{const p=typeof l.order=="number"?l.order:0,m=typeof f.order=="number"?f.order:0;return p-m});n.forEach((l,f)=>{(!l||typeof l.order!="number"||isNaN(l.order))&&(l.order=f)});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 d=l=>{let f={...l};if(l.conditionExpression&&typeof l.conditionExpression=="string")try{f={...l,conditionExpression:JSON.parse(l.conditionExpression)}}catch{}if(f.targetFieldId){const p=i.find(m=>m._id===f.targetFieldId||m.id===f.targetFieldId||m.fieldKey===f.targetFieldId);if(p){const m=p.key||p.fieldKey||p.name,g=p._id||p.id||f.targetFieldId;f.targetFieldKey=m,f.targetField=m,f.targetFieldById=g}}return f},u={id:r._id,name:r.name,description:r.description??"",version:r.version,status:r.status,fields:i.map((l,f)=>{const p=l,m=typeof l.metadata=="object"&&l.metadata!==null?l.metadata:{},g=m.hidden===!0||l.hidden===!0,h={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(g&&(h.hidden=!0),h.id||(h.id=h.key||h.name),h.key||(h.key=h.id||h.name),h.name||(h.name=h.key||h.id),l.isRequired!==void 0&&(h.required=l.isRequired),l.placeholder&&(h.placeholder=l.placeholder),l.options&&Array.isArray(l.options)&&(h.options=l.options),l.apidata&&(h.apidata=l.apidata),p.appearance&&typeof p.appearance=="object"&&!Array.isArray(p.appearance)&&Object.keys(p.appearance).length>0&&(h.appearance=Wc(p.appearance)),p.ui!==void 0&&(h.ui=Wc(p.ui)),p.visibility!==void 0&&(h.visibility=Wc(p.visibility)),m.disabled!==void 0&&(h.disabled=m.disabled),m.readOnly!==void 0&&(h.readOnly=m.readOnly),m.hideLabel!==void 0&&(h.hideLabel=m.hideLabel,h.properties||(h.properties={}),h.properties.hideLabel=m.hideLabel,h.appearance||(h.appearance={}),h.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 A=l.validationRules,O={...m};if(A.fileSize!==void 0&&(O.maxSize=A.fileSize),A.fileType&&Array.isArray(A.fileType)){const T=[];A.fileType.forEach(z=>{const q=z.startsWith(".")?z:`.${z}`;T.push(q),q===".csv"?T.push("text/csv"):q===".xls"?T.push("application/vnd.ms-excel"):q===".xlsx"&&T.push("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")}),O.accept=T}h.metadata=O,O.maxSize!==void 0&&(h.maxSize=O.maxSize),O.accept!==void 0&&(h.accept=O.accept)}else if(m&&Object.keys(m).length>0){if(h.metadata=m,(l.type==="toggle"||l.fieldType==="toggle")&&(m.onValue!==void 0&&(h.onValue=m.onValue),m.offValue!==void 0&&(h.offValue=m.offValue),m.onText!==void 0&&(h.onText=m.onText),m.offText!==void 0&&(h.offText=m.offText)),(l.type==="button"||l.fieldType==="button")&&m.action==="download"&&m.downloadApiEndpoint&&typeof m.downloadApiEndpoint=="string"){let A=m.downloadApiEndpoint;A=A.replace(/\{ctx:([^}]+)\}/g,(O,T)=>{const z=t[T];return z!==void 0?String(z):O}),m.downloadApiEndpoint=A,h.metadata=m,h.downloadApiEndpoint=A}if((l.type==="button"||l.fieldType==="button")&&m.action==="submit"){const A=h.properties||{};m.submitAction!==void 0&&(A.submitAction=m.submitAction),m.submitApiMethod!==void 0&&(A.submitApiMethod=m.submitApiMethod),m.apiBodyStructure!==void 0&&(A.apiBodyStructure=m.apiBodyStructure),m.apiBodyFieldsOnly!==void 0&&(A.apiBodyFieldsOnly=m.apiBodyFieldsOnly),m.apiBodyFieldsOnlyFormat!==void 0&&(A.apiBodyFieldsOnlyFormat=m.apiBodyFieldsOnlyFormat),m.apiBodyFields!==void 0&&(A.apiBodyFields=m.apiBodyFields),m.buttonText!==void 0&&(A.buttonText=m.buttonText),m.action!==void 0&&(A.action=m.action),m.variant!==void 0&&(A.variant=m.variant),m.hideLabel!==void 0&&(A.hideLabel=m.hideLabel),l.apidata&&typeof l.apidata=="object"&&l.apidata.apiEndpoint&&(A.apiEndpoint=l.apidata.apiEndpoint),h.properties=A}if((l.type==="button"||l.fieldType==="button")&&(m.action==="upload"||m.action==="custom")){const A=h.properties||{};m.action!==void 0&&(A.action=m.action),m.buttonText!==void 0&&(A.buttonText=m.buttonText),m.variant!==void 0&&(A.variant=m.variant),m.hideLabel!==void 0&&(A.hideLabel=m.hideLabel),m.uploadAction!==void 0&&(A.uploadAction=m.uploadAction),m.uploadApiEndpoint!==void 0&&(A.uploadApiEndpoint=m.uploadApiEndpoint),m.uploadApiMethod!==void 0&&(A.uploadApiMethod=m.uploadApiMethod),m.apiBodyStructure!==void 0&&(A.apiBodyStructure=m.apiBodyStructure),m.apiBodyFieldsOnly!==void 0&&(A.apiBodyFieldsOnly=m.apiBodyFieldsOnly),m.apiBodyFieldsOnlyFormat!==void 0&&(A.apiBodyFieldsOnlyFormat=m.apiBodyFieldsOnlyFormat),m.apiFieldMapping!==void 0&&(A.apiFieldMapping=m.apiFieldMapping),m.apiQueryParams!==void 0&&(A.apiQueryParams=m.apiQueryParams),m.apiBodyFields!==void 0&&(A.apiBodyFields=m.apiBodyFields),m.apiHeaders!==void 0&&(A.apiHeaders=m.apiHeaders),h.properties=A}if(l.type==="status"||l.fieldType==="status"){const A=h.properties||{};if(m.source!==void 0&&(A.source=m.source),m.statuses!==void 0&&(A.statuses=m.statuses),m.dataPath!==void 0&&(A.dataPath=m.dataPath),m.showStatusText!==void 0&&(A.showStatusText=m.showStatusText),m.statusTextPath!==void 0&&(A.statusTextPath=m.statusTextPath),m.showCurrentIndicator!==void 0&&(A.showCurrentIndicator=m.showCurrentIndicator),l.apidata&&typeof l.apidata=="object"&&l.apidata.apiEndpoint){let O=l.apidata.apiEndpoint;O=O.replace(/\{ctx:([^}]+)\}/g,(T,z)=>{const q=t[z];return q!==void 0?String(q):T}),A.apiEndpoint=O,A.source===void 0&&(A.source="api")}l.apidata?.apiMethod!==void 0&&(A.apiMethod=l.apidata.apiMethod),h.properties=A}if(l.type==="addmore"||l.fieldType==="addmore"){const A=h.properties||{};m.linkedFieldNames!==void 0&&(A.linkedFieldNames=m.linkedFieldNames),m.linkedSectionIds!==void 0&&(A.linkedSectionIds=m.linkedSectionIds),m.linkedFieldAllowDuplicate!==void 0&&(A.linkedFieldAllowDuplicate=m.linkedFieldAllowDuplicate),m.buttonText!==void 0&&(A.buttonText=m.buttonText),m.variant!==void 0&&(A.variant=m.variant),m.size!==void 0&&(A.size=m.size),m.hideLabel!==void 0&&(A.hideLabel=m.hideLabel),h.properties=A}if(l.type==="selectablelist"||l.fieldType==="selectablelist"){const A=h.properties||{};m.submitFieldMapping!==void 0&&(A.submitFieldMapping=m.submitFieldMapping),m.displayFields!==void 0&&(A.displayFields=m.displayFields),m.displayFieldsSeparator!==void 0&&(A.displayFieldsSeparator=m.displayFieldsSeparator),m.dataSourceContextKey!==void 0&&(A.dataSourceContextKey=m.dataSourceContextKey),m.showSelectAll!==void 0&&(A.showSelectAll=m.showSelectAll),m.selectAllByDefault!==void 0&&(A.selectAllByDefault=m.selectAllByDefault),h.properties=A}}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"&&(h.validationRules=l.validationRules),typeof l.order=="number"&&(h.order=l.order);const y=l,w=Gg(y.position),v=l.metadata&&typeof l.metadata=="object"&&!Array.isArray(l.metadata)?l.metadata:{},x=Gg(y.layout),P={order:typeof y.positionOrder=="number"?y.positionOrder:l.order??f,column:typeof w.column=="number"?w.column:typeof y.positionColumn=="number"?y.positionColumn:1,columnSpan:typeof w.columnSpan=="number"?w.columnSpan:typeof w.width=="number"?w.width:typeof y.positionWidth=="number"?y.positionWidth:1,rowSpan:typeof w.rowSpan=="number"?w.rowSpan:typeof y.positionRowSpan=="number"?y.positionRowSpan:1},E=Fo(w,{cellSlotIndex:y.cellSlotIndex??x.cellSlotIndex,stackSlot:v.stackSlot??x.stackSlot});typeof E=="number"&&(P.cellSlot=E);const _=w.cellGroupId??x.cellGroupId;typeof _=="string"&&(P.cellGroupId=_);const C=vi(w)??vi(x)??(v.stackDirection==="horizontal"||x.stackDirection==="horizontal"?"row":v.stackDirection==="vertical"||x.stackDirection==="vertical"?"stack":void 0);return(C==="row"||C==="stack")&&(P.sharedCellLayout=C),h.position=P,l.conditions&&Array.isArray(l.conditions)&&(h.conditions=l.conditions),h}).filter(l=>l!=null).sort((l,f)=>{const p=typeof l.order=="number"?l.order:0,m=typeof f.order=="number"?f.order:0;return p-m}),config:{...s,layout:o,...r.rules&&r.rules.length>0&&{rules:r.rules.map(d)},...r.clientMapping&&Object.keys(r.clientMapping).length>0&&{clientMapping:r.clientMapping}},...r.rules&&r.rules.length>0&&{rules:r.rules.map(d)},createdAt:"",updatedAt:"",moduleId:""};return ea(u)}var ta="Tabs",[KT]=xr(ta,[zs]),Kg=zs(),[qT,Rc]=KT(ta),qg=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,onValueChange:o,defaultValue:i,orientation:s="horizontal",dir:a,activationMode:d="automatic",...u}=e,l=no(a),[f,p]=en({prop:n,onChange:o,defaultProp:i??"",caller:ta});return c.jsx(qT,{scope:r,baseId:cn(),value:f,onValueChange:p,orientation:s,dir:l,activationMode:d,children:c.jsx($e.div,{dir:l,"data-orientation":s,...u,ref:t})})});qg.displayName=ta;var Yg="TabsList",Xg=b.forwardRef((e,t)=>{const{__scopeTabs:r,loop:n=!0,...o}=e,i=Rc(Yg,r),s=Kg(r);return c.jsx(Hm,{asChild:!0,...s,orientation:i.orientation,dir:i.dir,loop:n,children:c.jsx($e.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});Xg.displayName=Yg;var Jg="TabsTrigger",Qg=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,disabled:o=!1,...i}=e,s=Rc(Jg,r),a=Kg(r),d=ty(s.baseId,n),u=ry(s.baseId,n),l=n===s.value;return c.jsx(Wm,{asChild:!0,...a,focusable:!o,active:l,children:c.jsx($e.button,{type:"button",role:"tab","aria-selected":l,"aria-controls":u,"data-state":l?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:d,...i,ref:t,onMouseDown:Le(e.onMouseDown,f=>{!o&&f.button===0&&f.ctrlKey===!1?s.onValueChange(n):f.preventDefault()}),onKeyDown:Le(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&s.onValueChange(n)}),onFocus:Le(e.onFocus,()=>{const f=s.activationMode!=="manual";!l&&!o&&f&&s.onValueChange(n)})})})});Qg.displayName=Jg;var Zg="TabsContent",ey=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,forceMount:o,children:i,...s}=e,a=Rc(Zg,r),d=ty(a.baseId,n),u=ry(a.baseId,n),l=n===a.value,f=b.useRef(l);return b.useEffect(()=>{const p=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(p)},[]),c.jsx(Er,{present:o||l,children:({present:p})=>c.jsx($e.div,{"data-state":l?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":d,hidden:!p,id:u,tabIndex:0,...s,ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0},children:p&&i})})});ey.displayName=Zg;function ty(e,t){return`${e}-trigger-${t}`}function ry(e,t){return`${e}-content-${t}`}var YT=qg,XT=Xg,JT=Qg,QT=ey;function ny({className:e,...t}){return c.jsx(YT,{"data-slot":"tabs",className:B("flex flex-col gap-2",e),...t})}function oy({className:e,...t}){return c.jsx(XT,{"data-slot":"tabs-list",className:B("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",e),...t})}function iy({className:e,...t}){return c.jsx(JT,{"data-slot":"tabs-trigger",className:B("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 sy({className:e,...t}){return c.jsx(QT,{"data-slot":"tabs-content",className:B("flex-1 outline-none",e),...t})}function dr({className:e="",...t}){return c.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 ZT({className:e=""}){return c.jsxs("div",{className:`flex flex-col gap-4 ${e}`.trim(),"data-form-renderer":"workflow-steps-view-skeleton",children:[c.jsxs("div",{className:"flex w-full border-b border-neutral-200 dark:border-neutral-700 gap-0",children:[c.jsx(dr,{className:"h-10 w-24 rounded-none"}),c.jsx(dr,{className:"h-10 w-28 rounded-none ml-1"}),c.jsx(dr,{className:"h-10 w-20 rounded-none ml-1"})]}),c.jsxs("div",{className:"mt-4 flex flex-col gap-4 py-4",children:[c.jsx(dr,{className:"h-4 w-32"}),c.jsx(dr,{className:"h-10 w-full"}),c.jsx(dr,{className:"h-4 w-40"}),c.jsx(dr,{className:"h-10 w-full"}),c.jsx(dr,{className:"h-4 w-36"}),c.jsx(dr,{className:"h-24 w-full"})]})]})}function eF(){return c.jsxs("div",{className:"flex flex-col gap-4 py-4","data-form-renderer":"form-loading-skeleton",children:[c.jsx(dr,{className:"h-4 w-28"}),c.jsx(dr,{className:"h-10 w-full"}),c.jsx(dr,{className:"h-4 w-36"}),c.jsx(dr,{className:"h-10 w-full"}),c.jsx(dr,{className:"h-4 w-24"}),c.jsx(dr,{className:"h-20 w-full"})]})}const tF=3e4,rF=10*6e4,nF=9e4,oF=15*6e4;function iF(e){return e!=null&&"on_success"in e&&e.on_success!=null}function sF(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 ay=({getWorkflowState:e,moduleId:t,tenantId:r,submissionContext:n,initialValues:o={},getAuthHeaders:i,onSuccess:s,bootstrapFeatureId:a,subjectUserId:d,viewStepId:u,clientId:l,className:f,onWorkflowSubmitResult:p,viewerContext:m,getViewerContext:g,dark:h=!1,themeVars:y})=>{const w=vn.useQueryClient(),v=S.useMemo(()=>[d??"",u??"",l??""],[d,u,l]),x=S.useMemo(()=>({moduleId:t,tenantId:r,subjectUserId:d,viewStepId:u,clientId:l}),[t,r,d,u,l]),[N,P]=S.useState([]),[E,_]=S.useState(null),[C,A]=S.useState(null),[O,T]=S.useState(null),[z,q]=S.useState({}),I=S.useRef(null),$=S.useRef(null),M=S.useRef(null),D=S.useRef(null),L=S.useMemo(()=>N&&Array.isArray(N)?N.filter(ae=>ae.feature_id):[],[N]),U=vn.useQuery({queryKey:["workflow-steps",t,a??"",r??"",v[0],v[1],v[2]],queryFn:()=>e({...x,featureId:a}),staleTime:tF,gcTime:rF}),j=U.isPending,se=U.error?U.error instanceof Error?U.error.message:"Failed to load workflow steps":null;S.useEffect(()=>{const ae=U.data;if(!ae||N.length>0)return;const ve=ae.steps&&Array.isArray(ae.steps)?ae.steps:[];P(ve);const He=ve.filter(dt=>dt.feature_id);if(He.length>0){const dt=ae.current_step_id,Ge=dt&&He.some(Rt=>Rt.step_id===dt);_(Ge?dt:He[0].step_id)}},[U.data,N.length,a]);const H=S.useMemo(()=>{if(!E)return;const ae=N.find(He=>He.step_id===E),ve=I.current===E;return ae?.feature_id??(ve?D.current:void 0)??void 0},[E,N]),G=vn.useQuery({queryKey:["workflow-step",t,H??"",r??"",v[0],v[1],v[2]],queryFn:()=>e({...x,featureId:H}),enabled:!!H,staleTime:nF,gcTime:oF,refetchOnWindowFocus:!0,refetchOnReconnect:!0}),ee=G.isPending,de=G.error?G.error instanceof Error?G.error.message:"Failed to load form":null;S.useEffect(()=>{!G.data||I.current===E||(A(G.data),T(null),I.current=null,D.current=null)},[G.data,E]),S.useEffect(()=>{T(de)},[de]),S.useEffect(()=>{H===void 0&&I.current!==E&&(A(null),T(null),I.current=null,D.current=null)},[H,E]);const ne=S.useMemo(()=>{const ae=C?.form;if(!ae)return null;const ve=(r??On()??"").trim()||"default",He=Hg({scope:ve,formId:ae._id,version:ae.version});return He?.value?He.value:GT(C,n)},[C,n,r]),K=S.useMemo(()=>{const ae=C?.BFF_submit_api;if(!ae?.url)return;let ve=ae.url;if(ve.startsWith("http://")||ve.startsWith("https://"))try{const Ge=new URL(ve);ve=Ge.pathname+Ge.search}catch{}const He=i?.()??{},dt={...ae.headers||{},"Content-Type":"application/json",...He};return{...ae,url:ve,headers:dt}},[C?.BFF_submit_api,i]),re=S.useMemo(()=>ne?{...ne,status:"published",...K&&{BFF_submit_api:K}}:null,[ne,K]);S.useEffect(()=>{if(!ne?.id)return;const ae=(r??On()??"").trim()||"default";Wg({scope:ae,formId:ne.id,version:ne.version},ne)},[ne,r]);const Te=S.useMemo(()=>{if(!ne)return null;const ae=Fi({config:ne.config,layout:ne.layout},null);if(!ae)return null;const ve=ae.rows,He=ae.columns,dt={verticalSpacing:ae.verticalSpacing??ae.spacing??"16px",horizontalSpacing:ae.horizontalSpacing??ae.spacing??"16px",rowHeight:ae.rowHeight??Dn};let Ge=1;if(Array.isArray(ne.fields))for(const Je of ne.fields){const Y=Je?.position,je=typeof Y?.order=="number"?Y.order:0,gt=typeof Y?.rowSpan=="number"?Y.rowSpan:1;Ge=Math.max(Ge,je+gt)}return{rows:Math.min(ve,Math.max(1,Ge)),columns:He,verticalSpacing:dt.verticalSpacing,horizontalSpacing:dt.horizontalSpacing,rowHeight:dt.rowHeight}},[ne]),Z=S.useMemo(()=>{const ve=re?.config?.theme?.cssVariables;if(!(!ve&&!y))return{...ve??{},...y??{}}},[re?.config,y]),te=S.useCallback(()=>{w.invalidateQueries({queryKey:["workflow-steps",t]}),w.invalidateQueries({queryKey:["workflow-step",t]})},[w,t]),he=S.useCallback(ae=>{if(iF(ae)){const Ge=ae.on_success,Rt=Ge?.action;if(Rt==="redirect"&&Ge?.redirect_url){const Je=sF(Ge.redirect_url.trim(),n);window.location.href=Je;return}if(Rt==="move"){const Je=Ge?.next_step_id,Y=Ge?.next_step_form;if(Je&&Y){I.current=null,D.current=null;const je=Y.featureId??Ge?.next_step_form_id??Y._id;w.removeQueries({queryKey:["workflow-step",t,je,r??"",v[0],v[1],v[2]]}),te(),P(gt=>gt.some(oe=>oe.step_id===Je)?gt:[...gt,{step_id:Je,step_name:Y.name||"Next step",feature_id:je}]),A(null),_(Je),s?.();return}return}if(Rt==="stay"){te(),s?.();return}}const ve=ae;ve.steps&&Array.isArray(ve.steps)&&P(ve.steps);const He=(ve.steps&&Array.isArray(ve.steps)?ve.steps:N).filter(Ge=>Ge.feature_id),dt=ve.current_step_id;dt&&He.some(Ge=>Ge.step_id===dt)?_(dt):He.length>0&&_(He[0].step_id),A(null),te(),s?.(),p?.(ve)},[w,t,r,s,p,N,n,v,te]),le=S.useCallback(async ae=>C?.BFF_submit_api?(s?.(),{success:!0,message:"Saved successfully"}):{success:!1,message:"Submit not configured"},[C?.BFF_submit_api,s]),Xe=S.useCallback((ae,ve)=>{},[]),ge=S.useCallback(ae=>{},[]);if(j)return c.jsx(ZT,{className:f});if(se)return c.jsx("div",{className:B("rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",f),children:se});if(L.length===0)return c.jsx("div",{className:B("py-12 text-center text-sm text-muted-foreground",f),children:"No workflow steps configured."});const Se=C?.step_blocked_message;return c.jsx("div",{className:B(Sa,h&&"dark","flex flex-col gap-4",f),style:Z,"data-form-renderer":"workflow-steps-view",children:c.jsxs(ny,{value:E??"",onValueChange:ae=>_(ae),children:[c.jsx(oy,{className:"w-full justify-start border-b rounded-none h-auto p-0 bg-transparent gap-0","data-form-renderer":"workflow-tabs",children:L.map(ae=>c.jsx(iy,{value:ae.step_id,className:"rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:shadow-none","data-form-renderer":"workflow-tab",children:ae.step_name},ae.step_id))}),L.map(ae=>c.jsx(sy,{value:ae.step_id,className:"mt-4 outline-none",children:ae.step_id!==E?null:ee?c.jsx(eF,{}):O?c.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:O}):Se&&!C?.form?c.jsx("div",{className:B("rounded-lg border border-amber-500/50 bg-amber-500/10 px-4 py-3 text-sm text-amber-800 dark:text-amber-200",f),"data-form-renderer":"workflow-step-blocked",children:Se}):re?.fields?.length?c.jsxs("div",{className:"py-4 [&_*]:box-border",children:[Se?c.jsx("div",{className:B("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:Se}):null,(()=>{const ve=$.current!==E||M.current!==(re?.id??null);if(E&&re&&ve){$.current=E,M.current=re.id??null;const He=Nt.getState();He.setSchema(re,{forceReset:!0});const dt=Nt.getState().values;He.setValues({...dt,...o})}return null})(),c.jsx(Hc,{schema:re,gridLayout:Te,omitRootWrapper:!0,submissionContext:n,initialValues:o,workflowStepId:E??void 0,viewerContext:m,getViewerContext:g,onSubmit:le,onChange:Xe,onValidationError:ge,onClose:()=>{},mode:"fill",unstyled:!0,onWorkflowSubmitResult:he,initialExtraSubmitPayload:Object.keys(z).length>0?z:void 0,onExtraSubmitPayloadChange:ve=>{if(ve&&typeof ve=="object"){const He={};ve.context_user_id!=null&&(He.context_user_id=ve.context_user_id),ve.id!=null&&(He.id=ve.id),ve.batch_id!=null&&(He.batch_id=ve.batch_id),ve.admission_batch_id!=null&&(He.admission_batch_id=ve.admission_batch_id),ve.program_id!=null&&(He.program_id=ve.program_id),Object.keys(He).length>0&&q(dt=>({...dt,...He}))}}},re.id)]}):c.jsx("div",{className:"py-8 text-center text-sm text-muted-foreground",children:"No form schema available for this step."})},ae.step_id))]})})};function aF(e){return typeof e=="object"&&e!==null&&"apiEndpoint"in e}function lF({formSchema:e}){const t=S.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((l,f)=>{const p=`field-${l.id}`;if(a.has(l.id)&&i.push({id:`${p}-duplicate-id`,type:"error",message:`Field "${l.label||l.name||`Field ${f+1}`}" has a duplicate ID`,fieldId:l.id}),a.add(l.id),l.name&&s.has(l.name)&&i.push({id:`${p}-duplicate-name`,type:"error",message:`Field "${l.label||l.name}" has a duplicate name: "${l.name}"`,fieldId:l.id}),l.name&&s.add(l.name),(!l.label||l.label.trim()==="")&&i.push({id:`${p}-missing-label`,type:"warning",message:`Field "${l.name||l.id}" is missing a label`,fieldId:l.id}),(!l.name||l.name.trim()==="")&&i.push({id:`${p}-missing-name`,type:"error",message:`Field "${l.label||l.id}" is missing a field name`,fieldId:l.id}),l.name&&!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(l.name)&&i.push({id:`${p}-invalid-name`,type:"error",message:`Field "${l.label||l.name}" has an invalid name. Use only letters, numbers, and underscores.`,fieldId:l.id}),["select","multiselect","radio","checkboxgroup"].includes(l.type)){const h=l.properties;(!h?.options||h.options.length===0)&&i.push({id:`${p}-no-options`,type:"warning",message:`Field "${l.label||l.name}" has no options defined`,fieldId:l.id})}l.parentId&&(e.fields.some(y=>y.id===l.parentId)||i.push({id:`${p}-orphaned`,type:"error",message:`Field "${l.label||l.name}" references a non-existent parent`,fieldId:l.id}));const g=(h,y)=>{if(y.has(h))return!0;y.add(h);const w=e.fields.find(v=>v.id===h);return w?.parentId?g(w.parentId,y):!1};l.parentId&&g(l.id,new Set)&&i.push({id:`${p}-circular-reference`,type:"error",message:`Field "${l.label||l.name}" has a circular parent reference`,fieldId:l.id})}),e.config.workflowTrigger?.workflowId&&(e.fields.some(f=>f.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 d=e.fields.filter(l=>!l.parentId),u=new Map;return d.forEach(l=>{const f=l.position.order;u.has(f)||u.set(f,[]),u.get(f).push(l)}),u.forEach((l,f)=>{l.length>3&&i.push({id:`row-${f}-too-many-fields`,type:"warning",message:`Row ${f+1} has ${l.length} fields (maximum recommended is 3)`})}),i},[e]),r=S.useMemo(()=>t.filter(i=>i.type==="error"),[t]),n=S.useMemo(()=>t.filter(i=>i.type==="warning"),[t]),o=S.useMemo(()=>r.length===0,[r]);return{issues:t,errors:r,warnings:n,isValid:o}}function cF({field:e,value:t,allValues:r,validateOnChange:n=!1,validateOnBlur:o=!0,debounceMs:i=tT}){const[s,a]=S.useState(),[d,u]=S.useState(!1),l=S.useRef(void 0),f=S.useRef(t),p=S.useCallback(async()=>{if(!e.validation||e.validation.length===0){a(void 0);return}u(!0);let w;for(const v of e.validation){const x=Xr(t,v,r);if(typeof x=="string"){w=x;break}}return a(w),u(!1),w},[e.validation,t,r]),m=S.useCallback(()=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{p()},i)},[p,i]);S.useEffect(()=>(n&&f.current!==t&&m(),f.current=t,()=>{l.current&&clearTimeout(l.current)}),[t,n,m]);const g=S.useCallback(()=>{o&&p()},[o,p]),h=S.useCallback(()=>{a(void 0)},[]),y=S.useCallback(w=>{a(w)},[]);return{error:s,isValidating:d,validate:p,handleBlur:g,clearError:h,setCustomError:y}}const ly="—";function qt(){return{kind:"static",value:ly}}function dF(){return{currencySymbol:"₹",emptyDisplay:ly,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:qt(),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:qt(),service:{kind:"api",path:"service"},unit_price:{kind:"api",path:"unit_price"},discount_pct:qt(),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:qt(),unit_price:{kind:"formula",expression:"SUM('unit_price', 'data')"},discount_pct:qt(),discount_amount:{kind:"formula",expression:"SUM('discount_amount', 'data')"},net_price:{kind:"formula",expression:"SUM('net_price', 'data')"},tax_pct:qt(),total:{kind:"formula",expression:"SUM('total', 'data')"}}}},{kind:"static",row:{id:"invoice_discount",label:"Invoice discount",cells:{tariff_type:{kind:"label"},service:qt(),unit_price:qt(),discount_pct:qt(),discount_amount:{kind:"input",inputType:"number"},net_price:qt(),tax_pct:qt(),total:qt()}}},{kind:"static",row:{id:"grand_total",label:"Grand total",cells:{tariff_type:{kind:"label"},service:qt(),unit_price:qt(),discount_pct:qt(),discount_amount:qt(),net_price:qt(),tax_pct:qt(),total:{kind:"formula",expression:"SUM('total', 'data') - cellInRow('invoice_discount', 'discount_amount')"}}}}]}}const uF={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"}},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:dF()}},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"}}}},cy={padding:"md",showBorder:!1};function dy(e,t){const r="full";return e?{padding:e.padding??cy.padding,maxWidth:e.maxWidth??r,showBorder:e.showBorder??cy.showBorder}:{padding:"md",maxWidth:r,showBorder:!1}}function fF(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 pF(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 mF(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 hF(e){const t=dy(e.container,e.layout);return B(mF(e.layout),pF(t.maxWidth,e.layout),fF(t.padding),t.showBorder&&"rounded-lg border border-border")}const ra=1;function gF(){return{version:ra,layout:"stack",container:{padding:"md",maxWidth:"full",showBorder:!1},dataBindings:[],widgets:[],filterGroups:[]}}function uy(e){return{...e,config:e.config??{},children:Array.isArray(e.children)?e.children.map(uy):void 0}}function yF(e){return{version:ra,layout:e.layout??"stack",container:dy(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(uy):[],filterGroups:Array.isArray(e.filterGroups)?e.filterGroups:[],eventHandlers:e.eventHandlers??[],navigation:e.navigation}}function bF(e){const t=e;return!t||typeof t!="object"?gF():(t.version!==ra&&(t.version=ra),yF(t))}const fy={};let py=null;function vF(e){py=e}function wF(){return(fy?.VITE_API_BASE_URL?.trim()||fy?.VITE_API_URL?.trim()||"").replace(/\/$/,"")}const Ai=Ct.create({baseURL:wF()});Ai.interceptors.request.use(e=>{const t=On();t&&(e.params={...e.params,clientId:t}),typeof FormData<"u"&&e.data instanceof FormData&&delete e.headers["Content-Type"];let r=py?.();if((!r||Object.keys(r).length===0)&&(r=Ts()),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 my(e){const t=await Ai.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 Gc(e,t,r){const n=await Ai.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 Kc(e){const{clientId:t,api:r,context:n,filterState:o}=e,i=await Ai.post(`/api/page-builder/clients/${t}/data-sources/execute`,{api:r,context:n,filterState:o});return i.data?.data??i.data}function SF(e,t){if(!t)return{};const r={};for(const[n,o]of Object.entries(t)){if(!o.trim())continue;const i=Qe(e,o);i!==void 0&&(r[n]=i)}return r}const hy=S.createContext(null);function xF(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 gy(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 AF({schema:e,context:t={},clientId:r,nestingDepth:n=0,onAction:o,getWorkflowState:i,parentContext:s,children:a}){const[d,u]=S.useState(()=>s?s.filterGroups:{}),l=S.useRef(d);l.current=d;const[f,p]=S.useState({}),[m,g]=S.useState(()=>xF(e,{parentContext:s,clientIdProp:r,externalContext:t})),h=S.useRef(null),y=String(r??t.clientId??s?.clientId??""),w=JSON.stringify(t);S.useEffect(()=>{if(s)return;const C=e.prepopulateApi;if(!C?.enabled||!C.api?.path||!y){p({}),g("idle"),h.current=null;return}const A=JSON.stringify({path:C.api.path,method:C.api.method,queryParams:C.api.queryParams,headers:C.api.headers,bodyFields:C.api.bodyFields,auth:C.api.auth,mapping:C.contextMapping,bindings:e.dataBindings,context:w});if(h.current===A)return;let O=!1;return h.current=A,g("loading"),(async()=>{try{const T=gy(e.dataBindings??[],t),z={...t,...T},q=await Kc({clientId:y,api:C.api,context:z});if(O)return;const I=SF(q,C.contextMapping);p({...I,prepopulateResponse:q}),g("ready")}catch{O||(p({}),g("error"))}})(),()=>{O=!0,h.current=null}},[s,e.prepopulateApi,e.dataBindings,w,y]);const v=S.useMemo(()=>{if(s)return{...s.context,...t};const C=gy(e.dataBindings??[],t);return{...t,...C,...f}},[s,t,e.dataBindings,f]),x=String(r??v.clientId??s?.clientId??""),N=S.useCallback((C,A,O)=>{u(T=>({...T,[C]:{...T[C]??{},[A]:O}}))},[]),P=S.useCallback(C=>l.current[C]??{},[]),E=S.useCallback((C,A,O,T)=>{(o??s?.onAction)?.({...C,sourceWidgetId:A,event:O,payload:T})},[o,s?.onAction]),_=S.useMemo(()=>({schema:e,context:v,clientId:x,prepopulateStatus:s?.prepopulateStatus??m,nestingDepth:n,onAction:o??s?.onAction,getWorkflowState:i??s?.getWorkflowState,filterGroups:d,setFilterValue:N,getFilterGroup:P,dispatchAction:E}),[e,v,x,m,n,o,s?.onAction,i,s?.getWorkflowState,d,N,P,E]);return c.jsx(hy.Provider,{value:_,children:a})}function Mr(){const e=S.useContext(hy);if(!e)throw new Error("usePageContext must be used within PageContextProvider");return e}const CF=5,yy=1;function Oo(e){return Number.isFinite(e)?Math.min(CF,Math.max(yy,Math.round(e))):yy}function EF(e,t){const r=Oo(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 NF(e){return Number.isFinite(e)?Math.min(100,Math.max(0,Math.round(e))):0}function _F(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 by(e){return _F(100,Oo(e))}function kF(e){const t=e.trim(),r=/^(\d+(?:\.\d+)?)\s*%?$/.exec(t);return r?NF(Number(r[1])):null}function vy(e,t){const r=Oo(t),n=[];for(let i=0;i<r;i++){const s=kF(e?.[i]??"");if(s===null)return by(r);n.push(s)}return n.reduce((i,s)=>i+s,0)!==100?by(r):n}function TF(e){return e==="sm"?"gap-2":e==="lg"?"gap-6":"gap-4"}function wy(e,t){return vy(t,Oo(e)).map(n=>`minmax(0, ${n}fr)`).join(" ")}function FF(e){return e.length?e.map(t=>`minmax(0, ${t}fr)`).join(" "):"minmax(0, 1fr)"}function PF(e,t,r,n){const o=Oo(t),i=EF(e,o),s=vy(r,o);if(!(n?.collapseEmpty!==!1))return{columns:i,gridTemplate:wy(o,r),sourceIndices:i.map((p,m)=>m)};const d=i.map((p,m)=>({colChildren:p,index:m,percent:s[m]??0})).filter(p=>p.colChildren.length>0);if(d.length===0||d.length===i.length)return{columns:i,gridTemplate:wy(o,r),sourceIndices:i.map((p,m)=>m)};const u=d.reduce((p,m)=>p+m.percent,0),l=d.map(p=>u>0?Math.round(p.percent/u*100):Math.round(100/d.length)),f=100-l.reduce((p,m)=>p+m,0);return f!==0&&l.length>0&&(l[0]+=f),{columns:d.map(p=>p.colChildren),gridTemplate:FF(l),sourceIndices:d.map(p=>p.index)}}function qc(e,t="solid"){return e?t==="dashed"?"rounded-md border border-dashed border-border":"rounded-md border border-border":""}function OF(e){return B(qc(e.showBorder,e.borderStyle??"solid"),e.showBorder&&"p-3")}function IF(e){return B(qc(e.showBorder,e.borderStyle??"solid"),e.showBorder&&"p-2")}function MF(e,t){return e.columnBorders?.[t]!==void 0?!!e.columnBorders[t]:!!e.showColumnBorders}function LF(e,t){const r=MF(e,t);return B(qc(r,e.borderStyle??"dashed"),r&&"p-2")}function DF(e){if(e)return{minHeight:`${e}vh`}}function BF({widget:e,renderChildren:t}){const r=e.config,[n,o]=S.useState(r.defaultCollapsed??!1);return c.jsxs("section",{className:B("space-y-4",OF(r)),"data-widget-id":e.id,children:[r.heading&&c.jsx("div",{className:"flex items-center gap-2",children:r.collapsible?c.jsx("button",{type:"button",className:"text-left text-lg font-semibold hover:underline",onClick:()=>o(i=>!i),children:r.heading}):c.jsx("h2",{className:"text-lg font-semibold",children:r.heading})}),r.showDivider&&c.jsx("hr",{className:"border-border"}),!n&&e.children?.length?c.jsx("div",{className:"space-y-4",children:t?.(e.children)}):null]})}function $F({widget:e,renderChildren:t}){const r=e.config,n=Oo(r.columns??2),o=r.collapseEmptyColumns!==!1,i=PF(e.children??[],n,r.columnWidths,{collapseEmpty:o});return c.jsx("div",{className:B("grid w-full min-w-0 items-stretch",TF(r.gap),IF(r)),style:{gridTemplateColumns:i.gridTemplate,...DF(r.minHeightPercent)},"data-widget-id":e.id,children:i.columns.map((s,a)=>{const d=i.sourceIndices[a]??a;return c.jsx("div",{className:B("flex min-h-[inherit] min-w-0 flex-col space-y-4 overflow-hidden",LF(r,d)),children:t?.(s)},d)})})}function jF({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 c.jsxs("div",{className:B("rounded-lg p-4",n),"data-widget-id":e.id,children:[(r.title||r.subtitle)&&c.jsxs("div",{className:"mb-4",children:[r.title&&c.jsx("h3",{className:"font-semibold",children:r.title}),r.subtitle&&c.jsx("p",{className:"text-sm text-muted-foreground",children:r.subtitle})]}),e.children?.length?c.jsx("div",{className:"space-y-4",children:t?.(e.children)}):null]})}function Sy(e,t){if(e.variable){const r=t[e.variable];return r!=null?String(r):e.fallback??e.text??""}return e.text??""}function zF({widget:e}){const t=e.config,{context:r}=Mr(),n=Sy(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 c.jsx("div",{role:"heading","aria-level":o,className:B("font-semibold tracking-tight",s,i),"data-widget-id":e.id,children:n})}function UF({widget:e}){const t=e.config,{context:r}=Mr(),n=Sy(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 c.jsx("p",{className:B(o,i),"data-widget-id":e.id,children:n})}function VF(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 xy(e,t){const r={...e};for(const[n,o]of Object.entries(r))typeof o=="string"&&(r[n]=VF(o,t));return r}function HF(e,t){return e.replace(/\{\{([^}]+)\}\}/g,(r,n)=>{const o=t[n.trim()];return o!=null?String(o):""})}function Ay(e,t,r,n){if(e.type==="navigate"){const o=HF(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?xy(e.params,t):void 0},n,"click");return}if(e.type==="workflow"&&e.workflowId){r(e,n,"click");return}r(e,n,"click")}function WF({widget:e}){const t=e.config,{context:r,dispatchAction:n}=Mr();return c.jsx(Kt,{variant:t.variant??"default",size:t.size??"default","data-widget-id":e.id,onClick:()=>Ay(t.action,r,n,e.id),children:t.label})}const RF={start:"justify-start",center:"justify-center",end:"justify-end","space-between":"justify-between"},GF={sm:"gap-2",md:"gap-3",lg:"gap-4"};function KF({widget:e}){const t=e.config,{context:r,dispatchAction:n}=Mr(),o=t.buttons??[];return c.jsx("div",{className:B("flex flex-wrap items-center",RF[t.align??"start"],GF[t.gap??"sm"],t.wrap===!1&&"flex-nowrap"),"data-widget-id":e.id,children:o.map(i=>c.jsx(Kt,{variant:i.variant??"outline",size:i.size??"default","data-widget-id":e.id,"data-button-id":i.id,onClick:()=>Ay(i.action,r,n,e.id),children:i.label},i.id))})}function qF(e){const t=e.prepopulateApi;return!!(t?.enabled&&t.api?.path)}function YF(e,t){return e&&(t==="idle"||t==="loading")}function XF(e,t){return!e||t==="ready"||t==="error"}function JF(e,t){const r=Qe(e,t??"");return r===void 0?null:r}function Cy(e,t){if(e.mode==="pageApi"&&e.dataSourceRef)return t[e.dataSourceRef];if(e.mode==="api")return e.api}function Ey({widgetId:e,dataSource:t,enabled:r=!0,page:n,pageSize:o,search:i}){const{schema:s,context:a,clientId:d,getFilterGroup:u,prepopulateStatus:l}=Mr(),f=S.useMemo(()=>t.filterGroupKey?u(t.filterGroupKey):{},[t.filterGroupKey,u]),p=t.mode==="context"&&qF(s),m=YF(p,l),g=r&&(t.mode==="static"||(t.mode==="context"?XF(p,l):!!d)),h=S.useMemo(()=>["page-ds",e,t,a,f,n,o,i,l],[e,t,a,f,n,o,i,l]),y=vn.useQuery({queryKey:h,enabled:g,staleTime:Cy(t,s.dataApis??{})?.staleTimeMs??3e4,queryFn:async()=>{if(t.mode==="static")return t.staticData;if(t.mode==="context")return JF(a,t.contextPath);const w=Cy(t,s.dataApis??{});if(!w)throw new Error(`No API config for data source on widget ${e}`);const v={...a};if(t.requestBindings)for(const P of t.requestBindings){let E;P.source==="binding"?E=a[P.key]:P.source==="filter"&&(E=f[P.key]),E!==void 0&&(v[P.param]=E)}const N={...xy(v,a),...n!==void 0?{page:n,pageSize:o,search:i}:{}};return Kc({clientId:d,api:w,context:N,filterState:f})}});return{...y,isLoading:y.isLoading||m,isPending:y.isPending||m,isFetching:y.isFetching||m}}function Yc(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 Ci(e,t){const r=Qe(e,t.path);return r==null?t.fallback??r:t.formatter?Yc(r,t.formatter):r}function QF(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 ZF={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"},eP={rectangle:"rounded-lg",square:"aspect-square rounded-lg",circle:"aspect-square rounded-full"},tP={sm:"p-2 text-xs",md:"p-4 text-sm",lg:"p-6 text-base"},Xc={sm:"text-lg",md:"text-2xl",lg:"text-3xl"},rP={sm:"gap-2",md:"gap-3",lg:"gap-4"};function nP({title:e,value:t,trend:r,variant:n="default",shape:o="rectangle",size:i="md",layout:s="vertical",isLoading:a,isError:d}){const u=s==="horizontal";return c.jsxs("div",{className:B(ZF[n??"default"],eP[o??"rectangle"],tP[i??"md"],u&&"flex items-center justify-between gap-3"),children:[c.jsxs("div",{className:B(u&&"min-w-0"),children:[e&&c.jsx("p",{className:B("font-medium text-muted-foreground",u?"text-sm":""),children:e}),r!=null&&r!==""&&!u&&c.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:String(r)})]}),a?c.jsx(Mn,{className:"my-2"}):d?c.jsx("p",{className:B("font-bold text-destructive",Xc[i??"md"]),children:"Error"}):c.jsx("p",{className:B("font-bold",u?Xc[i??"md"]:`mt-1 ${Xc[i??"md"]}`),children:String(t)}),u&&r!==null&&r!==void 0&&r!==""&&c.jsx("p",{className:"text-xs text-muted-foreground",children:String(r)})]})}function Ny({stat:e,widgetId:t}){const{data:r,isLoading:n,isError:o}=Ey({widgetId:t,dataSource:e.dataSource}),s=(()=>{if(n)return"";if(r==null)return e.valueMapping.fallback??"—";if(e.dataSource.mode==="context"){const d=r;return e.valueMapping.formatter?Yc(d,e.valueMapping.formatter):d}if(e.dataSource.mode==="static"){const d=e.valueMapping.path?.trim()||"value",u=Ci(r,{...e.valueMapping,path:d});if(u!=null)return e.valueMapping.formatter?Yc(u,e.valueMapping.formatter):u;if(typeof r=="object"&&r!==null&&!Array.isArray(r)){const l=r;if(l.value!==void 0&&l.value!==null)return l.value}return e.valueMapping.fallback??"—"}return Ci(r,e.valueMapping)})(),a=e.trendMapping&&r!==void 0&&e.dataSource.mode!=="context"?Ci(r,e.trendMapping):e.trendMapping&&e.dataSource.mode==="context"&&e.trendMapping.path?Ci({value:r},e.trendMapping):null;return c.jsx(nP,{title:e.title,value:s,trend:a,variant:e.variant,shape:e.shape,size:e.size,layout:e.layout,isLoading:n,isError:o})}function oP({widget:e}){const t=e.config;return c.jsx("div",{"data-widget-id":e.id,children:c.jsx(Ny,{stat:t,widgetId:e.id})})}function iP({stat:e,widgetId:t}){return c.jsx(Ny,{stat:e,widgetId:`${t}-${e.id}`})}function sP({widget:e}){const t=e.config,r=t.stats??[],n=t.columns??1,o=t.direction==="horizontal";return c.jsx("div",{"data-widget-id":e.id,className:B(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",rP[t.gap??"md"]),children:r.map(i=>c.jsx(iP,{stat:i,widgetId:e.id},i.id))})}function aP({widget:e}){const t=e.config,{setFilterValue:r}=Mr(),[n,o]=S.useState("");return S.useEffect(()=>{const i=t.debounceMs??300,s=setTimeout(()=>{r(t.filterGroupKey,"search",n)},i);return()=>clearTimeout(s)},[n,t.debounceMs,t.filterGroupKey,r]),c.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 lP(e,t){if(!e)return[];const r=t?Qe(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 cP({widget:e}){const t=e.config,{dispatchAction:r}=Mr(),[n,o]=S.useState(1),[i,s]=S.useState(""),a=t.pagination?.pageSize??10,{data:d,isLoading:u,isError:l}=Ey({widgetId:e.id,dataSource:t.dataSource,page:n,pageSize:a,search:t.search?.enabled?i:void 0}),f=t.dataSource.mode==="pageApi"?void 0:t.dataSource.api?.itemsPath,p=lP(d,f??"data.items"),m=(g,h)=>{const y=t.dataSource.responseMapping.find(w=>w.target===h);return y?Ci(g,y):Qe(g,h)??""};return c.jsxs("div",{className:"space-y-3","data-widget-id":e.id,children:[t.search?.enabled&&c.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:g=>{s(g.target.value),o(1)}}),c.jsx("div",{className:"overflow-x-auto rounded-md border",children:c.jsxs("table",{className:"w-full text-sm",children:[c.jsx("thead",{children:c.jsx("tr",{className:"border-b bg-muted/50",children:t.columns.map(g=>c.jsx("th",{className:B("px-3 py-2 text-left font-medium",g.align==="center"&&"text-center",g.align==="right"&&"text-right"),style:g.width?{width:g.width}:void 0,children:g.header},g.id))})}),c.jsx("tbody",{children:u?c.jsx("tr",{children:c.jsx("td",{colSpan:t.columns.length,className:"px-3 py-8 text-center",children:c.jsx(Mn,{})})}):l?c.jsx("tr",{children:c.jsx("td",{colSpan:t.columns.length,className:"px-3 py-8 text-center text-destructive",children:"Failed to load data"})}):p.length===0?c.jsx("tr",{children:c.jsx("td",{colSpan:t.columns.length,className:"px-3 py-8 text-center text-muted-foreground",children:t.emptyMessage??"No data"})}):p.map((g,h)=>c.jsx("tr",{className:"cursor-pointer border-b hover:bg-muted/30",onClick:()=>{r({type:"emit",eventName:"row_click",payload:{row:g}},e.id,"row_click")},children:t.columns.map(y=>c.jsx("td",{className:B("px-3 py-2",y.align==="center"&&"text-center",y.align==="right"&&"text-right"),children:String(m(g,y.field))},y.id))},h))})]})}),t.pagination?.enabled&&c.jsxs("div",{className:"flex items-center justify-between text-sm",children:[c.jsxs("span",{className:"text-muted-foreground",children:["Page ",n]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx("button",{type:"button",className:"rounded border px-2 py-1 disabled:opacity-50",disabled:n<=1,onClick:()=>o(g=>Math.max(1,g-1)),children:"Previous"}),c.jsx("button",{type:"button",className:"rounded border px-2 py-1",disabled:p.length<a,onClick:()=>o(g=>g+1),children:"Next"})]})]})]})}const dP=75;function uP(e){return e??dP}function fP(e){return e?"rounded-md border border-border p-3":""}function Jc({scrollBehavior:e="page",maxHeightPercent:t,children:r,className:n}){if(e!=="contained")return n?c.jsx("div",{className:n,children:r}):c.jsx(c.Fragment,{children:r});const o=uP(t);return c.jsx("div",{className:B("min-w-0 overflow-y-auto overflow-x-hidden",n),style:{maxHeight:`${o}vh`},"data-form-embed-scroll":"contained",children:r})}function pP(e,t,r){return["embedded-form",e,t,r??"latest"]}async function mP(e,t){try{const r=await pn.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 hP(e,t,r){const n=r!==void 0?`/api/form-builder/forms/${e}/render?version=${r}`:`/api/form-builder/forms/${e}/render`,o=await pn.get(n,{params:{clientId:t}}),s=o.data?.data??o.data,a=s.form??s,d=s.fields??a.fields??[];let u=s.layout??a.layout??null;(!u||typeof u.columns!="number")&&(u=await mP(e,t));const l=s.rules??a.rules??[],f=bi(a,d,u,l),p=Fi({config:f.config,layout:f.layout},Ti(u))??Ti(u);return{schema:f,gridLayout:p}}const gP=300*1e3;function _y({formId:e,mode:t="fill",contextFieldMapping:r,pageContext:n,clientId:o,formVersion:i,scrollBehavior:s,maxHeightPercent:a,showBorder:d}){const{data:u,isLoading:l,isError:f,error:p}=vn.useQuery({queryKey:pP(e,o,i),queryFn:()=>hP(e,o,i),staleTime:gP}),m=S.useMemo(()=>QF(n,r),[n,r]),g=fP(d);return l?c.jsx(Jc,{scrollBehavior:s,maxHeightPercent:a,className:g,children:c.jsx(Mn,{})}):f?c.jsx(Jc,{scrollBehavior:s,maxHeightPercent:a,className:g,children:c.jsx("p",{className:"text-sm text-destructive",children:p instanceof Error?p.message:"Failed to load form"})}):u?.schema?c.jsx(Jc,{scrollBehavior:s,maxHeightPercent:a,className:g,children:c.jsx(Hc,{schema:u.schema,mode:t,gridLayout:u.gridLayout,initialValues:m,submissionContext:n})}):null}function yP({widget:e}){const t=e.config,{context:r,clientId:n}=Mr();return t.formId?c.jsx(_y,{formId:t.formId,mode:t.mode??"fill",contextFieldMapping:t.contextFieldMapping,pageContext:r,clientId:n,scrollBehavior:t.scrollBehavior,maxHeightPercent:t.maxHeightPercent,showBorder:t.showBorder}):c.jsx("p",{className:"text-sm text-muted-foreground",children:"No form configured"})}function bP({widget:e}){const t=e.config,{context:r,getWorkflowState:n,clientId:o}=Mr(),i=String(r.moduleId??"");if(!n)return c.jsxs("div",{className:"rounded-md border border-dashed p-4 text-sm text-muted-foreground","data-widget-id":e.id,children:["Workflow embed requires ",c.jsx("code",{className:"text-xs",children:"getWorkflowState"})," on PageRenderer. Workflow ID: ",t.workflowId]});if(!i)return c.jsx("p",{className:"text-sm text-destructive","data-widget-id":e.id,children:"moduleId required in page context for workflow embed"});const s={};if(t.contextVariableMapping)for(const[a,d]of Object.entries(t.contextVariableMapping)){const u=r[d];u!=null&&(s[a]=String(u))}return c.jsx(ay,{getWorkflowState:n,moduleId:i,tenantId:r.tenantId?String(r.tenantId):void 0,clientId:o||void 0,submissionContext:s})}function vP({widget:e}){const t=e.config,{schema:r,dispatchAction:n}=Mr(),o=t.previousPage??r.navigation?.previousPage,i=t.nextPage??r.navigation?.nextPage,s=t.showPrevious!==!1&&!!o,a=t.showNext!==!1&&!!i,d=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",l=f=>{n({type:"navigate_page",pageId:f.pageId},e.id,"click")};return c.jsxs("nav",{className:"space-y-3","data-widget-id":e.id,children:[d&&c.jsx("ol",{className:"flex flex-wrap items-center gap-1 text-sm text-muted-foreground",children:r.navigation.breadcrumbs.map((f,p)=>c.jsxs("li",{className:"flex items-center gap-1",children:[p>0&&c.jsx("span",{children:"/"}),f.href?c.jsx("a",{href:f.href,className:"hover:underline",children:f.label}):c.jsx("span",{children:f.label})]},p))}),c.jsxs("div",{className:B("flex items-center gap-2",u),children:[s&&o&&c.jsx(Kt,{variant:"outline",size:"sm",onClick:()=>l(o),children:o.label??"Previous"}),a&&i&&c.jsx(Kt,{variant:"default",size:"sm",onClick:()=>l(i),children:i.label??"Next"})]})]})}function wP(e,t){return e?.length?e.filter(r=>r.config.tabId===t):[]}const SP=1;function xP(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 AP(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 CP(e,t,r){return e?new Set(r?[r]:[]):new Set(t.map(n=>n.id))}function EP({tab:e,shouldRender:t,pageContext:r,clientId:n}){return t?e.formId?c.jsx(_y,{formId:e.formId,mode:e.formMode??"fill",contextFieldMapping:e.contextFieldMapping,pageContext:r,clientId:n,scrollBehavior:e.scrollBehavior,maxHeightPercent:e.maxHeightPercent,showBorder:e.showBorder}):c.jsx("p",{className:"text-sm text-muted-foreground",children:"No form configured for this tab"}):null}function NP({tab:e,shouldLoad:t,shouldRender:r,nestingDepth:n,pageContext:o,clientId:i,onAction:s,getWorkflowState:a}){const d=Mr(),{data:u,isLoading:l,isError:f,error:p}=vn.useQuery({queryKey:["tab-page",e.pageId,e.pageVersion,i],enabled:t&&!!e.pageId,queryFn:async()=>Gc(e.pageId,i,e.pageVersion)});return r?n>=SP?c.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?l?c.jsx(Mn,{}):f?c.jsx("p",{className:"text-sm text-destructive",children:p instanceof Error?p.message:"Failed to load page"}):u?c.jsx(Qc,{page:u,context:o,nestingDepth:n+1,inheritContext:!0,onAction:s,getWorkflowState:a,parentContext:d}):null:c.jsx("p",{className:"text-sm text-muted-foreground",children:"No page configured for this tab"}):null}function _P({tab:e,widgetChildren:t,renderChildren:r}){const n=wP(t,e.id);return n.length===0?c.jsx("p",{className:"text-sm text-muted-foreground py-4",children:"No widgets in this tab"}):c.jsx(c.Fragment,{children:r?.(n)})}function kP({widget:e,renderChildren:t}){const r=e.config,{context:n,clientId:o,nestingDepth:i,onAction:s,getWorkflowState:a}=Mr(),d=r.tabs??[],u=r.defaultTabId??d[0]?.id??"",l=r.lazyLoad!==!1,[f,p]=S.useState(u),[m,g]=S.useState(()=>CP(l,d,u)),h=w=>{g(v=>new Set(v).add(w)),p(w)},y=S.useMemo(()=>!l,[l]);return d.length===0?c.jsx("p",{className:"text-sm text-muted-foreground","data-widget-id":e.id,children:"No tabs configured"}):c.jsxs(ny,{value:f,onValueChange:h,className:"w-full","data-widget-id":e.id,children:[c.jsx(oy,{className:B("mb-4",xP(r.variant)),children:d.map(w=>c.jsx(iy,{value:w.id,disabled:w.disabled,className:AP(r.variant),children:w.label},w.id))}),d.map(w=>{const v=m.has(w.id),x=y||v,N=y||v;return c.jsxs(sy,{value:w.id,forceMount:y||void 0,className:B("mt-0",y&&"data-[state=inactive]:hidden"),children:[w.contentType==="widgets"&&N&&c.jsx(_P,{tab:w,widgetChildren:e.children??[],renderChildren:t}),w.contentType==="form"&&c.jsx(EP,{tab:w,shouldRender:x,pageContext:n,clientId:o}),w.contentType==="page"&&c.jsx(NP,{tab:w,shouldLoad:x,shouldRender:N,nestingDepth:i,pageContext:n,clientId:o,onAction:s,getWorkflowState:a})]},w.id)})]})}const TP={section:BF,columns:$F,card:jF,tab_group:kP,heading:zF,text:UF,button:WF,button_group:KF,stat_card:oP,stat_grid:sP,data_table:cP,search_filter:aP,form_embed:yP,workflow_embed:bP,page_nav:vP};function FP({widget:e}){return c.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: ",c.jsx("code",{className:"text-xs",children:e.type}),e.label&&c.jsxs("span",{className:"ml-1",children:["(",e.label,")"]})]})}function PP({widget:e,renderChildren:t}){const r=TP[e.type]??FP;return c.jsx(r,{widget:e,renderChildren:t})}function ky(e,t){return e.map(r=>c.jsx(PP,{widget:r,renderChildren:t},r.id))}function Qc({page:e,context:t={},onAction:r,chrome:n="none",className:o,nestingDepth:i=0,getWorkflowState:s,inheritContext:a=!1,parentContext:d}){const u=S.useMemo(()=>bF(e.schema),[e.schema]),l=p=>ky(p,l),f=c.jsxs("div",{className:B("studio-page-content min-h-0 min-w-0",hF(u),o),"data-page-id":e.id,"data-nesting-depth":i,children:[n==="minimal"&&u.meta?.title&&c.jsxs("header",{className:"mb-6 border-b pb-4",children:[c.jsx("h1",{className:"text-2xl font-semibold",children:u.meta.title}),u.meta.description&&c.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:u.meta.description})]}),c.jsx("div",{className:"space-y-6",children:ky(u.widgets,l)})]});return a&&d?f:c.jsx(AF,{schema:u,context:t,clientId:String(t.clientId??""),nestingDepth:i,onAction:r,getWorkflowState:s,parentContext:d,children:f})}function OP({clientId:e,tenantId:t,moduleId:r,featureId:n,pageId:o,routePath:i,routeParams:s={},isDefault:a,context:d={},version:u,chrome:l="none",onAction:f,getWorkflowState:p}){const m=S.useMemo(()=>({...s,...d,clientId:e,tenantId:t,moduleId:r,featureId:n}),[s,d,e,t,r,n]),{data:g,isLoading:h,isError:y,error:w}=vn.useQuery({queryKey:["page-resolve",e,t,r,n,o,i,a,u],queryFn:()=>my({clientId:e,tenantId:t,moduleId:r,featureId:n,routePath:i,isDefault:a,version:u}),enabled:!o}),v=o??g?.pageId,x=u??g?.version,{data:N,isLoading:P,isError:E,error:_}=vn.useQuery({queryKey:["page-render",v,e,x],queryFn:()=>Gc(v,e,x),enabled:!!v});return!o&&h?c.jsx("div",{className:"flex items-center justify-center p-12",children:c.jsx(Mn,{})}):y?c.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm text-destructive",children:w instanceof Error?w.message:"Failed to resolve page"}):v?P?c.jsx("div",{className:"flex items-center justify-center p-12",children:c.jsx(Mn,{})}):E||!N?c.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm text-destructive",children:_ instanceof Error?_.message:"Failed to load page"}):c.jsx(Qc,{page:N,context:m,chrome:l,nestingDepth:0,onAction:f,getWorkflowState:p}):c.jsx("div",{className:"rounded-md border p-4 text-sm text-muted-foreground",children:"No page found for the given scope or route."})}be.FIELD_TYPE_REGISTRY=uF,be.FORM_RENDERER_GRID_ROW_HEIGHT_DEFAULT=Dn,be.FORM_RENDERER_ROOT_CLASS=Sa,be.FieldRenderer=mn,be.FormRenderer=Hc,be.PageRenderer=Qc,be.RendererFieldLayoutContext=Oa,be.StudioPageHost=OP,be.WorkflowStepsView=ay,be.appearanceControlClasses=jo,be.appearanceHasExplicitVerticalIntent=Bd,be.appearanceTextareaClasses=kd,be.backendToFormSchema=bi,be.cellAlignmentClasses=$b,be.cellVerticalJustifyClassesForField=Bb,be.effectiveWidthPercent=Mi,be.executeDataSource=Kc,be.fetchPageRender=Gc,be.fieldBlockBoxStyle=Db,be.fieldBlockBoxStyleForField=Ld,be.fieldBlockHorizontalPlacementClass=Pd,be.fieldBlockHorizontalSelfClass=Od,be.fieldBlockHorizontalSelfClassForField=Dd,be.fieldBlockWidthStyle=Na,be.fieldBlockWidthStyleForField=Md,be.fieldGridShellFillsCellVertically=Di,be.formBuilderHttp=pn,be.formLayoutRecordToGridConfig=Ti,be.getBusinessApiOrigin=Lp,be.getClientId=On,be.getRendererHostAuthHeaders=Ts,be.getRendererHostViewerContext=iC,be.getRendererStore=uv,be.gridCellFlexClasses=Fd,be.gridCellFlexClassesForField=Pa,be.gridCellOuterFlexClasses=Td,be.hasExplicitFieldBlockWidth=Id,be.isAsyncSearchFieldProperties=aF,be.isIntrinsicWidthButtonField=ro,be.normalizeWorkflowFormSchema=yT,be.normalizeWorkflowFormToRendererSchema=ea,be.pageBuilderHttp=Ai,be.parseContentVerticalAlign=ka,be.parseMetadataJson=Si,be.resetRendererHostAuth=oC,be.resolveBusinessApiUrl=rn,be.resolveFormGridLayout=Fi,be.resolvePage=my,be.resolvedGridCellVerticalJustifyClasses=Uo,be.resolvedHorizontalAlign=Tr,be.resolvedVerticalAlign=zo,be.resolvedVerticalAlignForField=Fa,be.setBusinessApiOrigin=ZA,be.setFormBuilderAuthProvider=BC,be.setPageBuilderAuthProvider=vF,be.setRendererHostAuthHeaders=nC,be.setRendererHostViewerContext=rC,be.useFieldValidation=cF,be.useFormRenderer=Xd,be.useFormValidation=lF,be.useRendererFieldLayout=Vo,be.useRendererHostAuthStore=qn,Object.defineProperty(be,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},dN="DialogDescriptionWarning",uN=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${wh(dN).contentName}}.`;return b.useEffect(()=>{const o=e.current?.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},fN=lh,pN=uh,mN=fh,hN=ph,gN=hh,yN=bh;function bN({...e}){return c.jsx(fN,{"data-slot":"dialog",...e})}function vN({...e}){return c.jsx(pN,{"data-slot":"dialog-portal",...e})}function wN({className:e,...t}){return c.jsx(mN,{"data-slot":"dialog-overlay",className:j("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 SN({className:e,children:t,showCloseButton:r=!0,...n}){return c.jsxs(vN,{"data-slot":"dialog-portal",children:[c.jsx(wN,{}),c.jsxs(hN,{"data-slot":"dialog-content",className:j("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&&c.jsxs(yN,{"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:[c.jsx(Xo,{}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function xN({className:e,...t}){return c.jsx("div",{"data-slot":"dialog-header",className:j("flex flex-col gap-2 text-center sm:text-left",e),...t})}function AN({className:e,...t}){return c.jsx("div",{"data-slot":"dialog-footer",className:j("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function CN({className:e,...t}){return c.jsx(gN,{"data-slot":"dialog-title",className:j("text-lg leading-none font-semibold",e),...t})}async function EN(){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 Sh(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 xh=({open:e,onOpenChange:t,onCaptured:r,validateFile:n,accept:o,disabled:i,onValidationMessage:s})=>{const a=S.useRef(null),d=S.useRef(null),u=S.useRef(null),l=S.useRef(null),[f,p]=S.useState(null),[m,g]=S.useState(!1),h=S.useCallback(()=>{a.current&&(a.current.srcObject=null)},[]),y=S.useCallback(()=>{u.current&&(u.current.getTracks().forEach(E=>E.stop()),u.current=null),h()},[h]);S.useEffect(()=>{if(!e){y(),p(null),g(!1);return}if(i)return;let E=!1;return p(null),g(!0),EN().then(T=>{if(E){T.getTracks().forEach(N=>N.stop());return}u.current=T,g(!1)}).catch(T=>{if(E)return;g(!1);const N=T instanceof Error?T.message:"Could not access camera";p(N)}),()=>{E=!0,u.current&&(u.current.getTracks().forEach(T=>T.stop()),u.current=null),h()}},[e,i,y,h]);const w=S.useCallback(E=>{a.current=E,E&&u.current&&e&&!f&&!m&&(E.srcObject=u.current,Sh(E))},[e,f,m]);S.useLayoutEffect(()=>{if(!e||f||m||!u.current)return;let E=!1,T=0;const N=()=>{if(E)return;const O=a.current;!O||!u.current||(O.srcObject=u.current,Sh(O))};N();const x=requestAnimationFrame(()=>{N(),T=requestAnimationFrame(N)});return()=>{E=!0,cancelAnimationFrame(x),cancelAnimationFrame(T),h()}},[e,f,m,h]);const v=S.useCallback(()=>{y(),p(null),g(!1),t(!1),l.current&&(l.current.value="")},[y,t]),A=S.useCallback(()=>{const E=a.current,T=d.current;if(!E||!T||!u.current||E.readyState<2)return;const N=E.videoWidth,x=E.videoHeight;if(N===0||x===0)return;T.width=N,T.height=x;const O=T.getContext("2d");O&&(O.drawImage(E,0,0),T.toBlob(k=>{if(!k)return;const D=new File([k],`camera-capture-${Date.now()}.jpg`,{type:"image/jpeg",lastModified:Date.now()}),R=n(D);if(R){s?.(R);return}s?.(void 0),r(D),v()},"image/jpeg",.92))},[r,n,v,s]),C=S.useCallback(E=>{const T=E.target.files?.[0];if(!T)return;const N=n(T);if(N){s?.(N);return}s?.(void 0),r(T),v(),l.current&&(l.current.value="")},[r,n,v,s]),F=typeof navigator<"u"&&typeof navigator.mediaDevices?.getUserMedia=="function";return c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:l,type:"file",accept:o,capture:"user",onChange:C,className:"hidden","aria-hidden":!0}),c.jsx("canvas",{ref:d,className:"hidden","aria-hidden":!0}),c.jsx(bN,{open:e,onOpenChange:E=>{E||v()},children:c.jsxs(SN,{className:"sm:max-w-md",showCloseButton:!0,onPointerDownOutside:E=>E.preventDefault(),children:[c.jsx(xN,{children:c.jsx(CN,{children:"Take a photo"})}),f?c.jsxs("div",{className:"space-y-3 py-2",children:[c.jsx("p",{className:"text-sm text-destructive",children:f}),F&&c.jsx("p",{className:"text-xs text-muted-foreground",children:"You can choose an image from your device instead."}),c.jsx(Kt,{type:"button",variant:"outline",className:"w-full",onClick:()=>l.current?.click(),children:"Choose from device"})]}):m?c.jsx("p",{className:"text-sm text-muted-foreground py-6 text-center",children:"Opening camera…"}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"relative rounded-lg overflow-hidden bg-black aspect-video",children:c.jsx("video",{ref:w,playsInline:!0,muted:!0,className:"w-full h-full object-cover"})}),c.jsxs(AN,{className:"gap-2 sm:gap-0",children:[c.jsx(Kt,{type:"button",variant:"outline",onClick:v,children:"Cancel"}),c.jsx(Kt,{type:"button",onClick:A,children:"Capture photo"})]})]})]})})]})},NN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a})=>{const d=e.properties,[u,l]=S.useState(),[f,p]=S.useState(!1),[m,g]=S.useState(()=>new Set),[h,y]=S.useState("none"),w=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,v=e.validation?.find(K=>K.type==="fileSize"),A=e.validation?.find(K=>K.type==="fileType"),C=v?.value!=null?v.value:d?.maxSize??w?.maxSize??5*1024*1024,F=A?.value!=null?A.value:d?.accept??w?.accept??["image/*"],E=F.join(",")||"image/*",T=Bi(e),N=S.useCallback(K=>{if(v){const X=Jr(K,v);if(X!==!0)return typeof X=="string"?X:"File size exceeds the maximum allowed size"}else if(K.size>C)return`File size must be less than ${So(C)}`;if(A){const X=Jr(K,A);if(X!==!0)return typeof X=="string"?X:"File type is not allowed"}return null},[v,A,C]),x=S.useMemo(()=>$i(t),[t]),O=nc(x),k=S.useCallback(K=>{const X=$a(K,T);r(X),n?.()},[r,n,T]),D=S.useCallback(K=>{const X=N(K);if(X){l(X);return}l(void 0);const le=[...x];le.length>=T||(le.push(K),k(le),y("none"))},[x,T,N,k]),R=S.useCallback(K=>{const X=x.filter((le,re)=>re!==K);k(X)},[x,k]),I=S.useCallback(()=>{i||x.length>=T||(l(void 0),y("camera"),p(!0))},[i,x.length,T]),z=S.useCallback(K=>{p(K),K||y("none")},[]),L=o||u,B=e.appearance?.hideLabel??!1,M=[];(v||C)&&M.push(`Max size: ${So(C)}`),A&&F.length>0&&M.push(`Allowed: ${F.join(", ")}`),T>1&&M.push(`Up to ${T} photos`);const V=S.useCallback(K=>{window.open(K,"_blank","noopener,noreferrer")},[]),$=x.length===0,ie=x.length<T,H=ec(T,x.length);return c.jsxs(Ct,{field:e,error:L,isRequired:s,className:j(a,"!space-y-0"),hideLabel:B,children:[c.jsx("div",{className:"h-[70px] min-h-[70px] min-w-0 w-full flex flex-col",children:c.jsx("div",{role:"button",tabIndex:i||!ie?-1:0,id:ht(e),onClick:K=>{i||K.target.closest("[data-remove-in-dropzone]")||K.target.closest("[data-no-open-picker]")||x.length>=T||I()},onKeyDown:K=>{(K.key==="Enter"||K.key===" ")&&(K.preventDefault(),!i&&ie&&I())},className:j("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",L&&"border-destructive",i&&"opacity-50 cursor-not-allowed",f&&h==="camera"&&"opacity-70 pointer-events-none",!ie&&x.length>0&&"cursor-default"),"aria-describedby":$t(e,!!L),"aria-invalid":Zt(!!L),"aria-required":s,children:$?c.jsxs(c.Fragment,{children:[c.jsx(Ri,{className:"mx-auto h-5 w-5 text-muted-foreground flex-shrink-0"}),c.jsx("p",{className:"text-[11px] text-muted-foreground leading-tight line-clamp-1",children:f?"Opening camera…":"Click to open camera"}),M.length>0&&c.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-1",children:M.join(" • ")})]}):H?c.jsx(oc,{item:x[0],objectUrl:O[0]??null,failedUrlKeys:m,onImageUrlError:K=>g(X=>new Set(X).add(K)),onRemove:()=>R(0),onOpenUrl:V,disabled:i}):c.jsx(rc,{items:x,maxFiles:T,disabled:i,objectUrls:O,failedUrlKeys:m,onImageUrlError:K=>g(X=>new Set(X).add(K)),onRemove:R,onOpenUrl:V,addSlot:ie?c.jsxs("button",{type:"button","data-no-open-picker":!0,onClick:K=>{K.stopPropagation(),I()},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:[c.jsx(Ri,{className:"h-4 w-4 mb-0.5","aria-hidden":!0}),"Add"]}):void 0})})}),c.jsx(xh,{open:f,onOpenChange:z,onCaptured:D,validateFile:N,accept:E,disabled:i,onValidationMessage:l})]})},kN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a,buttonResponses:d})=>{const u=e.properties,l=S.useRef(null),[f,p]=S.useState(),[m,g]=S.useState(!1),[h,y]=S.useState(()=>new Set),[w,v]=S.useState("none"),A=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,C=e.validation?.find(ee=>ee.type==="fileSize"),F=e.validation?.find(ee=>ee.type==="fileType"),E=C?.value?C.value:u?.maxSize??A?.maxSize??5*1024*1024,T=F?.value?F.value:u?.accept??A?.accept??["image/*"],N=Array.isArray(T)?T.join(","):"image/*",x=Bi(e),O=S.useCallback(ee=>{if(C){const te=Jr(ee,C);if(te!==!0)return typeof te=="string"?te:"File size exceeds the maximum allowed size"}else if(ee.size>E)return`File size must be less than ${So(E)}`;if(F){const te=Jr(ee,F);if(te!==!0)return typeof te=="string"?te:"File type is not allowed"}return null},[C,F,E]),k=S.useMemo(()=>$i(t),[t]),D=nc(k),R=S.useCallback(ee=>{const te=$a(ee,x);r(te),n?.()},[r,n,x]),I=S.useCallback(ee=>{p(void 0);const te=Array.from(ee),he=[...k];let ce=null;for(const Xe of te){if(he.length>=x)break;const ge=O(Xe);if(ge){ce||(ce=ge);continue}he.push(Xe)}if(ce&&he.length===k.length){p(ce);return}ce&&p(ce),R(he),v("none")},[k,x,O,R]),z=S.useCallback(ee=>{const te=ee.target.files;te&&te.length>0&&I(te),l.current&&(l.current.value="")},[I]),L=S.useCallback(ee=>{R(k.filter((te,he)=>he!==ee))},[k,R]),B=S.useCallback(()=>{i||k.length>=x||m||(p(void 0),v("file"),l.current?.click())},[i,k.length,x,m]),M=S.useCallback(()=>{i||k.length>=x||(p(void 0),v("camera"),g(!0))},[i,k.length,x]),V=S.useCallback(ee=>{const te=O(ee);if(te){p(te);return}p(void 0);const he=[...k];he.length>=x||(he.push(ee),R(he),v("none"))},[k,x,O,R]),$=S.useCallback(ee=>{g(ee),ee||v("none")},[]),ie=o||f,H=e.appearance?.hideLabel??!1,K=[];(C||E)&&K.push(`Max size: ${So(E)}`),F&&T.length>0&&K.push(`Allowed: ${T.join(", ")}`),x>1&&K.push(`Up to ${x} photos`);const X=S.useMemo(()=>{if(!d)return null;const ee=Object.values(d);for(let te=ee.length-1;te>=0;te-=1){const he=ee[te],ce=typeof he?.status=="string"?he.status.toLowerCase():null;if(ce&&ce!=="success")continue;const Xe=he?.code;if(typeof Xe=="number"&&(Xe<200||Xe>=300))continue;const ge=he?.data,Se=ge?.file_url||ge?.fileUrl||he?.file_url||he?.fileUrl;if(typeof Se=="string"&&Se.trim())return Se.trim()}return null},[d]),le=S.useCallback(ee=>{window.open(ee,"_blank","noopener,noreferrer")},[]),re=k.length===0,q=k.length<x,ne=ec(x,k.length),Te=q&&!m?c.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:[c.jsx("button",{type:"button",disabled:i,onClick:ee=>{ee.stopPropagation(),B()},className:"flex flex-1 w-full items-center justify-center hover:bg-primary/10 rounded-t","aria-label":"Upload file",title:"Upload",children:c.jsx(Ki,{className:"h-4 w-4","aria-hidden":!0})}),c.jsx("button",{type:"button",disabled:i,onClick:ee=>{ee.stopPropagation(),M()},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:c.jsx(Ri,{className:"h-4 w-4","aria-hidden":!0})})]}):void 0;return c.jsxs(Ct,{field:e,error:ie,isRequired:s,className:j(a,"!space-y-0"),hideLabel:H,children:[c.jsx("div",{className:"h-[70px] min-h-[70px] min-w-0 w-full flex flex-col",children:c.jsxs("div",{className:j("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",ie&&"border-destructive",i&&"opacity-50"),children:[c.jsx("input",{ref:l,id:ht(e),type:"file",accept:N,multiple:x>1,onChange:z,disabled:i||e.disabled||m||!q,className:"hidden","aria-describedby":$t(e,!!ie),"aria-invalid":Zt(!!ie),"aria-required":s}),re?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-1 w-full pointer-events-auto",children:[c.jsxs("div",{className:"flex items-center justify-center gap-3",children:[c.jsxs("button",{type:"button",disabled:i||m,onClick:B,className:j("inline-flex flex-col items-center gap-0.5 text-[11px] text-muted-foreground hover:text-foreground",i&&"pointer-events-none"),children:[c.jsx(Ki,{className:"h-5 w-5","aria-hidden":!0}),c.jsx("span",{children:"Upload"})]}),c.jsxs("button",{type:"button",disabled:i,onClick:M,className:j("inline-flex flex-col items-center gap-0.5 text-[11px] text-muted-foreground hover:text-foreground",i&&"pointer-events-none",m&&"opacity-70"),children:[c.jsx(Ri,{className:"h-5 w-5","aria-hidden":!0}),c.jsx("span",{children:"Camera"})]})]}),K.length>0&&c.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-2 text-center px-1",children:K.join(" • ")})]}):ne?c.jsx(oc,{item:k[0],objectUrl:D[0]??null,failedUrlKeys:h,onImageUrlError:ee=>y(te=>new Set(te).add(ee)),onRemove:()=>L(0),onOpenUrl:le,openTarget:k[0]instanceof File?X:void 0,disabled:i||e.disabled}):c.jsx(rc,{items:k,maxFiles:x,disabled:i,objectUrls:D,failedUrlKeys:h,onImageUrlError:ee=>y(te=>new Set(te).add(ee)),onRemove:L,resolveOpenUrl:(ee,te)=>te instanceof File&&k.length===1&&X?X:null,onOpenUrl:ee=>{ee?.trim()&&le(ee.trim())},addSlot:Te})]})}),c.jsx(xh,{open:m,onOpenChange:$,onCaptured:V,validateFile:O,accept:N,disabled:i,onValidationMessage:p})]})};function fi(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 xo(n)}}catch{}if(e.response){const r=e.response;if(typeof r=="string")try{const n=JSON.parse(r);return xo(n)}catch{return r}else if(typeof r=="object")return xo(r)}return t}if(e instanceof qA)return e.response?.data?xo(e.response.data):e.message||"An unexpected error occurred";if(typeof e=="string")try{const t=JSON.parse(e);return xo(t)}catch{return e}return typeof e=="object"&&e!==null?xo(e):"An unexpected error occurred"}function xo(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"}function _N(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 TN(e,t){try{const r=_N(e);Bt.toast.success(r&&r.trim()?r:t)}catch{Bt.toast.success(t)}}function lc(e,t,r){try{const n=r(e);Bt.toast.error(n&&n.trim()?n:t)}catch{Bt.toast.error(t)}}function FN(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 Ys="This field is required";function Ah(e,t){if(!t?.length)return e;const r=t.find(n=>n.name===e);return r?.label&&r.label.trim()||e}function cc(e,t){if(!e)return"Please complete the required fields.";if(Array.isArray(e)){const i=e.map(s=>{const a=s.message||Ys;if(t?.length&&s.field){const d=Ah(s.field,t);return a===Ys?`${d} is required`:`${d}: ${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()||Ys;if(t?.length){const a=Ah(o,t);return s===Ys?`${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 dc(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,d=s.metadata,u=typeof d=="object"&&d!==null?d:null,l=a?.submitFieldMapping??u?.submitFieldMapping;if(l&&typeof l=="object"&&Object.keys(l).length>0){const f=i.map(p=>{if(p==null||typeof p!="object")return p;const m={};for(const[g,h]of Object.entries(l))g!=null&&g!==""&&h!=null&&h!==""&&(m[g]=Qe(p,h));return m});n[o]=f;continue}}n[o]=i}return n}function Xs(e){return!!(e instanceof File||Array.isArray(e)&&e.length>0&&e[0]instanceof File)}function PN(e){return Object.values(e).some(t=>Xs(t))}function ON(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 IN(e,t,r){const n={};let o=!1;return Object.entries(e).forEach(([i,s])=>{const a=t?.[i]||i;if(Xs(s)){n[a]=s,o=!0;return}const d=r?.[i]||"string";let u=s;if(d==="number"){const l=Number(s);u=isNaN(l)?s:l}else d==="boolean"?u=s==="true"||s===!0||s==="1"||s===1:d==="date"?u=String(s):s!=null?u=typeof s=="object"?s:String(s):u="";n[a]=u}),{transformed:n,hasFiles:o}}const Ch=Object.freeze(Object.defineProperty({__proto__:null,hasFileValues:PN,isFileValue:Xs,prepareFormDataWithFiles:ON,transformFormValuesWithFiles:IN},Symbol.toStringTag,{value:"Module"}));function MN(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 LN(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 d;if(n.fieldPayloadKeys&&typeof n.fieldPayloadKeys=="object"&&!Array.isArray(n.fieldPayloadKeys)){d={};for(const[u,l]of Object.entries(n.fieldPayloadKeys))typeof l=="string"&&l.trim()&&(d[u]=l.trim());Object.keys(d).length===0&&(d=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}:{},...d?{fieldPayloadKeys:d}:{},...n.heading&&typeof n.heading=="object"?{heading:n.heading}:{}})}return t.length>0?t:void 0}function Eh(e){return e?.mode==="nested_by_section"}function Nh(e){const t=e.payloadKey?.trim();return t||null}function kh(e,t){return t.fieldPayloadKeys?.[e]?.trim()||e}function _h(e,t,r,n){if(!Eh(r)||!t?.length)return{...e};const o=new Set([]),i=r?.includeUnassignedAtRoot!==!1,s=new Set,a={};for(const d of t){const u=Nh(d);if(!u)continue;const l={};for(const f of d.fieldNames){if(o.has(f)||!(f in e))continue;s.add(f);const p=kh(f,d);l[p]=e[f]}Object.keys(l).length>0&&(a[u]=l)}if(i)for(const[d,u]of Object.entries(e))o.has(d)||s.has(d)||(a[d]=u);return a}function DN(e,t,r){const n={...e??{}};if(!Eh(r)||!t?.length)return n;for(const o of t){const i=Nh(o);if(i)for(const s of o.fieldNames){if(n[s]?.trim())continue;const a=kh(s,o);n[s]=`${i}.${a}`}}return n}function BN(e){return e==="null"?null:e==="true"?!0:e==="false"?!1:e}function $N(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 jN(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 d=s===n,u=s.startsWith(`${n}__addmore__`);if(!d&&!u||!$N(a))return;const l=Qe(a,o);l==null||l===""||i.push(l)}),i}function Js(e,t,r,n,o,i){const s=e.trim().match(/^\{respAll:([^}]+)\}$/);if(s){const u=(s[1]||"").trim(),l=u.split("."),f=l.length>=2?l.slice(1).join("."):"";return(f==="data.id"||f==="data.documentId")&&n?.document_ids!=null&&Array.isArray(n.document_ids)?n.document_ids:jN(u,o)}const a=e.trim().match(/^\{(\w+)\}$/);if(a){const u=a[1],l=t[u];if(l!==void 0)return l;const f=Object.keys(t).find(p=>p.toLowerCase()===u.toLowerCase());if(f)return t[f]}const d=Rr(e,t,r,n,o,i);return BN(String(d))}const zN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:d,onClick:u,onSubmit:l,onReset:f,onCancel:p,isSubmitting:m=!1,formValues:g={},submissionContext:h,bffSubmitApi:y,onBffSubmitResult:w,extraSubmitPayload:v,buttonResponses:A,onButtonApiResponse:C,onValidateForm:F,getValidationErrors:E,allFields:T,onSubmittingChange:N,scopedFormValues:x,scopedFieldNameMap:O,prepopulateResponse:k=null,formSections:D,submitPayload:R})=>{const{gridStretch:I}=Wo(),[z,L]=S.useState(!1),B=e.properties,M=Ea.useParams(),V=S.useMemo(()=>({...h,...v}),[h,v]),$=S.useMemo(()=>{if(!x||!O||Object.keys(O).length===0)return g;const Je={};return Object.entries(x).forEach(([Y,je])=>{const gt=O[Y]||Y;gt!==e.name&&(Je[gt]=je)}),Je},[x,O,g,e.name]),H=(()=>{try{const Je=e.metadata;if(typeof Je=="string")return JSON.parse(Je);if(Je&&typeof Je=="object")return Je}catch{}return null})(),K=B?.submitAction??H?.submitAction,X=B?.apiEndpoint??e.apidata?.apiEndpoint??H?.apiEndpoint;let le=B?.action||H?.action;!le&&e.type==="button"&&(le="submit");const re=B?.variant||"default",q=B?.size||"default",ne=B?.hideLabel??e.appearance?.hideLabel??!1,Te=B?.buttonText||e.label||"Button",ee=B?.closeOnCancel??!0,te=async()=>{if(x&&O&&Object.keys(O).length>0||!F)return!0;const Je=await F();if(!Je&&E)try{const Y=E();Bt.toast.error(cc(Y,T??void 0)||"Please fix the errors before submitting.")}catch{Bt.toast.error("Please fix the errors before submitting.")}return Je},he=async Je=>{if(Je.preventDefault(),(le==="submit"?"submit":le)==="submit"){if(y?.url){if(!await te())return;L(!0),N?.(!0);try{const je=await Xe(),gt=(je?.message??je?.display_message??"Form submitted successfully!").trim();Bt.toast.success(gt||"Form submitted successfully!");const Ie=je!=null&&typeof je=="object"?je:{status:"success",...je!=null?{data:je}:{}};C?.(e.name,Ie)}catch(je){const gt=fi(je);Bt.toast.error(gt)}finally{L(!1),N?.(!1)}return}if(l){if(!await te())return;L(!0),N?.(!0);try{await l(),C?.(e.name,{status:"success"})}finally{L(!1),N?.(!1)}return}Bt.toast.error("Submit not configured. BFF submit API is required for submit buttons.");return}else if(le==="reset"&&f)f();else if(le==="cancel")ee?p&&p():f&&f();else if(le==="download"){const je=B?.downloadApiEndpoint||H?.downloadApiEndpoint||e.downloadApiEndpoint,gt=B?.downloadApiMethod||H?.downloadApiMethod||e.downloadApiMethod;if(je){L(!0);try{const Ie=gt||"GET",oe=Wr(Rr(je,$,M,V,A,k??void 0)),pe={method:Ie,headers:{}};Ie!=="GET"&&Ie!=="DELETE"&&(pe.headers={"Content-Type":"application/json"});const We=await fetch(oe,pe);if(!We.ok)throw new Error(`Download failed: ${We.statusText}`);const Tt=await We.blob(),ze=window.URL.createObjectURL(Tt),Fe=document.createElement("a");Fe.href=ze;const Ke=We.headers.get("Content-Disposition");let nt="download";if(Ke){const yt=Ke.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);yt&&yt[1]&&(nt=yt[1].replace(/['"]/g,""))}Fe.download=nt,document.body.appendChild(Fe),Fe.click(),document.body.removeChild(Fe),window.URL.revokeObjectURL(ze);try{const yt=FN(We);Bt.toast.success(yt&&yt.trim()?yt:"Download started.")}catch{Bt.toast.success("Download started.")}}catch(Ie){lc(Ie,"Failed to download file. Please check the API endpoint and try again.",fi)}finally{L(!1)}}else Bt.toast.error("Download endpoint is not configured")}else if(le==="upload"||le==="custom"){const je=le==="custom",gt=je?"api":B?.uploadAction||H?.uploadAction||"database";if(gt==="database")if(l){L(!0);try{await l(Je)}catch(Ie){throw Ie}finally{L(!1)}}else Bt.toast.error("Form submit handler is not available");else if(gt==="api"){const Ie=B?.uploadApiEndpoint||H?.uploadApiEndpoint||e.uploadApiEndpoint;if(B?.uploadApiMethod||H?.uploadApiMethod||e.uploadApiMethod,Ie){if(!await te())return;L(!0);try{const oe=await ge();C?.(e.name,oe),TN(oe,je?"Custom API call completed successfully!":"Upload completed successfully!")}catch(oe){C?.(e.name,{status:"error",code:oe?.response?.code??oe?.response?.status??null,message:fi(oe)}),lc(oe,je?"Failed to call custom API. Please check the API endpoint and try again.":"Failed to upload. Please check the API endpoint and try again.",fi)}finally{L(!1)}}else Bt.toast.error(je?"Custom API endpoint is not configured":"Upload endpoint is not configured")}else gt==="custom"&&Bt.toast.info("Custom upload handler is not implemented")}else u?u():r&&t!==void 0&&r(t||"");n?.()},ce=async()=>{if(!K||K!=="api"||!X)return null;const Je=B?.apiBodyFields??H?.apiBodyFields;if((B?.apiBodyFieldsOnly??H?.apiBodyFieldsOnly??!1)&&Je?.length){const Fe={};return Je.forEach(({key:Ke,value:nt})=>{const yt=Js(nt,$,M,V,A,k??void 0),Yt=Ke==="user_id"?"context_user_id":Ke;Fe[Yt]=yt}),Fe.user_id!==void 0&&Fe.user_id!==null&&(Fe.context_user_id=Fe.context_user_id??Fe.user_id,delete Fe.user_id),Fe}const je=T?.length?dc($,T):$,gt=B?.apiFieldMapping??H?.apiFieldMapping,Ie=B?.apiFieldTypes??H?.apiFieldTypes,oe=B?.apiBodyStructure??H?.apiBodyStructure,pe={...Ie};T?.length&&T.forEach(Fe=>{const Ke=Fe.name||Fe.key;Ke&&(Fe.type==="terms"||Fe.type==="checkbox")&&(pe[Ke]="boolean")});const{transformFormValuesWithFiles:We}=await Promise.resolve().then(()=>Ch),{transformed:Tt}=We(je,gt,pe);let ze={};if(oe==="flat"?ze={...Tt}:ze={data:{...Tt}},gt){const Fe={};Object.keys(ze).forEach(Ke=>{const nt=gt[Ke]||Ke;Fe[nt]=ze[Ke]}),ze=Fe}return Je?.length&&Je.forEach(({key:Fe,value:Ke})=>{const nt=Js(Ke,$,M,V,A,k??void 0),yt=Fe==="user_id"?"context_user_id":Fe;ze[yt]=nt}),ze.user_id!==void 0&&ze.user_id!==null&&(ze.context_user_id=ze.context_user_id??ze.user_id,delete ze.user_id),ze.data?.user_id!==void 0&&ze.data?.user_id!==null&&(ze.data.context_user_id=ze.data.context_user_id??ze.data.user_id,delete ze.data.user_id),ze},Xe=async()=>{if(!y||!y.url)throw new Error("BFF submit API configuration is missing");const Je=T?.length?dc(g,T):g,Y={};Object.keys(Je).forEach(Pe=>{const ft=e.name===Pe&&e.type==="button",et=Pe.toLowerCase().includes("button");!ft&&!et&&(Y[Pe]=Je[Pe])});const je=Object.keys(Y).filter(Pe=>Xs(Y[Pe]));je.forEach(Pe=>{Y[Pe]=""});const gt=_h(Y,D,R),Ie={workflow_id:y.payload?.workflow_id||"",current_step_id:y.payload?.current_step_id||"",form_data:gt},oe=["workflow_id","current_step_id","form_data","submit_body","submit_api_endpoint","submit_api_method"];if(h&&typeof h=="object"&&Object.entries(h).forEach(([Pe,ft])=>{if(ft==null||oe.includes(Pe))return;const et=Pe==="user_id"?"context_user_id":Pe;Ie[et]=Ie[et]??ft}),v&&typeof v=="object"&&Object.entries(v).forEach(([Pe,ft])=>{if(ft==null||oe.includes(Pe))return;const et=Pe==="user_id"?"context_user_id":Pe;Ie[et]=Ie[et]??ft}),K==="api"&&X)try{const Pe=await ce();if(Pe){const ft=B?.apiBodyStructure??H?.apiBodyStructure,et=B?.apiFieldMapping??H?.apiFieldMapping;je.forEach(ur=>{const on=et?.[ur]??ur,Nr=Y[ur]!==void 0&&typeof Y[ur]=="string"?Y[ur]:"";ft==="flat"?Pe[on]=Nr:Pe.data&&typeof Pe.data=="object"?Pe.data[on]=Nr:Pe[on]=Nr}),Ie.submit_body=Pe;let At=Rr(X,$,M,V,A,k??void 0);At=At.replace(/\{([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\}/gi,"$1"),At=Wr(At),Ie.submit_api_endpoint=At,Ie.submit_api_method=B?.submitApiMethod||H?.submitApiMethod||"POST"}}catch{}const pe=(y.method||"POST").toUpperCase(),We=je.length>0,Tt=Ie.submit_api_endpoint??X??"",ze=typeof Tt=="string"?Tt.toLowerCase():"",Fe=ze.includes("/upload")||ze.includes("/payments")||ze.includes("/bulk-upload"),Ke=We&&Fe;let nt;const yt={...y.headers||{}};if(Ke){const Pe=new FormData;Pe.append("payload",JSON.stringify(Ie));for(const ft of je){const et=Je[ft],At=B?.apiFieldMapping?.[ft]??ft;et instanceof File?Pe.append(At,et):Array.isArray(et)&&et.length>0&&et[0]instanceof File&&et.forEach(ur=>Pe.append(At,ur))}nt=Pe,delete yt["content-type"],delete yt["Content-Type"]}else yt["Content-Type"]="application/json",nt=JSON.stringify(Ie);const Yt=await fetch(y.url,{method:pe,headers:yt,body:nt});if(!Yt.ok){let Pe;const ft=await Yt.text();try{Pe=JSON.parse(ft)}catch{Pe={message:ft}}const et=new Error(`BFF submission failed: ${Yt.status}`);throw et.response=Pe,et}const xt=await Yt.json();return w?.(xt),l&&await l(),xt},ge=async()=>{const Je=B?.uploadApiEndpoint||H?.uploadApiEndpoint;if(!Je)throw new Error("Upload API endpoint is not configured");if(!B)throw new Error("Button properties are not configured");const Y=(B.uploadApiMethod||"POST").toUpperCase(),je=Wr(Rr(Je,$,M,V,A,k??void 0)),gt=B.apiBodyFieldsOnly??H?.apiBodyFieldsOnly??!1,Ie=B.apiBodyFieldsOnlyFormat??H?.apiBodyFieldsOnlyFormat??"json";let oe={},pe;const We={};if(gt&&B.apiBodyFields&&B.apiBodyFields.length>0)if(B.apiBodyFields.forEach(({key:Fe,value:Ke})=>{oe[Fe]=Js(Ke,$,M,V,A,k??void 0)}),Ie==="multipart"){const Fe=new FormData;Object.entries(oe).forEach(([Ke,nt])=>{if(nt instanceof File){Fe.append(Ke,nt);return}if(Array.isArray(nt)&&nt.length>0&&nt[0]instanceof File){nt.forEach(yt=>Fe.append(Ke,yt));return}nt!=null&&Fe.append(Ke,typeof nt=="object"?JSON.stringify(nt):String(nt))}),pe=Fe}else pe=JSON.stringify(oe),We["Content-Type"]="application/json";else{const Fe=$,{transformFormValuesWithFiles:Ke,prepareFormDataWithFiles:nt,hasFileValues:yt}=await Promise.resolve().then(()=>Ch),{transformed:Yt,hasFiles:xt}=Ke(Fe,B.apiFieldMapping,B.apiFieldTypes);if((B.apiBodyStructure??H?.apiBodyStructure??"nested")==="flat"?oe={...Yt}:oe={data:{...Yt}},B.apiFieldMapping){const ft={};Object.keys(oe).forEach(et=>{const At=B.apiFieldMapping[et]||et;ft[At]=oe[et]}),oe=ft}if(B.apiBodyFields&&B.apiBodyFields.forEach(({key:ft,value:et})=>{oe[ft]=Js(et,$,M,V,A,k??void 0)}),xt||yt(oe)){const ft=nt(oe,B.apiFieldMapping);ft?pe=ft:(pe=JSON.stringify(oe),We["Content-Type"]="application/json")}else pe=JSON.stringify(oe),We["Content-Type"]="application/json"}B.apiHeaders&&B.apiHeaders.forEach(({key:Fe,value:Ke})=>{const nt=Rr(Ke,$,M,V,A,k??void 0);(Fe.toLowerCase()!=="content-type"||!(pe instanceof FormData))&&(We[Fe]=nt)});let Tt=je;if(B.apiQueryParams&&B.apiQueryParams.length>0){const Fe=new URLSearchParams;B.apiQueryParams.forEach(({key:Ke,value:nt})=>{const yt=Rr(nt,$,M,V,A,k??void 0);Fe.append(Ke,yt)}),Tt=`${je}?${Fe.toString()}`}const ze=await fetch(Tt,{method:Y,headers:We,body:Y!=="GET"?pe:void 0});if(!ze.ok){let Fe;const Ke=await ze.text();try{Fe=JSON.parse(Ke)}catch{Fe={message:Ke}}const nt=new Error(`Upload failed: ${ze.status}`);throw nt.response=Fe,nt}try{return await ze.json()}catch{return{}}},Se=le==="submit"?"submit":le,ve=Se==="submit"?"button":Se==="submit"?"submit":Se==="reset"?"reset":"button",He=i||e.disabled||s||e.readOnly||z||Se==="submit"&&m,dt=Te,Ge=no(e),Rt=Tr(e.appearance)==="stretch";return c.jsx(Ct,{field:e,error:o,isRequired:a,className:d,hideLabel:ne,children:c.jsx("div",{className:j(I&&!Ge&&"flex w-full min-w-0 flex-col",I&&Ge&&"min-w-0 shrink-0"),children:c.jsxs(Kt,{id:ht(e),type:ve,variant:re,size:q,disabled:He,onClick:he,className:j(e.appearance?.className,I&&!Ge&&"w-full min-w-0 shrink-0",I&&Ge&&!Rt&&"inline-flex w-auto max-w-full shrink-0",I&&Ge&&Rt&&"inline-flex w-full min-w-0 max-w-full shrink-0"),children:[z&&c.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]})})})},UN=({field:e,disabled:t,readOnly:r,isRequired:n,className:o,buttonResponses:i,onButtonApiResponse:s})=>{const a=e.properties,d=a?.buttonText??e.label??"Edit",u=a?.variant??"outline",l=a?.size??"default",f=a?.hideLabel??e.appearance?.hideLabel??!1,p=e.name||e.key||e.id,m=Ro(i?.[p]),g=t||e.disabled||r||e.readOnly||m,h=y=>{y.preventDefault(),!g&&s?.(p,{status:"success"})};return c.jsx(Ct,{field:e,error:void 0,isRequired:n,className:o,hideLabel:f,children:c.jsx(Kt,{id:ht(e),type:"button",variant:u,size:l,disabled:g,onClick:h,className:j(e.appearance?.className,(!no(e)||Tr(e.appearance)==="stretch")&&"w-full min-w-0"),children:d})})},VN=({field:e,error:t,disabled:r,readOnly:n,isRequired:o,className:i,onAddMore:s})=>{const a=e.properties||{},d=a.variant||"outline",u=a.size||"default",l=a.buttonText||e.label||"Add More",f=a.hideLabel??e.appearance?.hideLabel??!1,p=r||n||e.disabled||e.readOnly;return c.jsx(Ct,{field:e,error:t,isRequired:o,className:i,hideLabel:f,children:c.jsxs(Kt,{id:ht(e),type:"button",variant:d,size:u,disabled:!!p,onClick:s,className:j("w-fit",e.appearance?.className),children:[c.jsx(uu,{className:"h-4 w-4 mr-1"}),l]})})},Th=S.createContext(null);function HN({value:e,children:t}){return c.jsx(Th.Provider,{value:e,children:t})}function WN(){return S.useContext(Th)}function Fh(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(0,t):e}function pi(e){return e.name||e.key||e.id}function uc(e){return e.filter(t=>!t.parentId&&t.type==="sectionHeading"&&pi(t))}function RN(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 GN(e){const t=new Map;for(const r of uc(e)){const n=pi(r);for(const o of RN(r))t.set(o,n)}return t}function KN(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(pi(s)))}function qN(e){const t={};for(const r of uc(e))t[pi(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 Ph(e,t,r,n){if(!e||t==="customizeSections")return!0;const o=Fh(e),i=t==="sectionHeading"?o:n.get(o);return i?r[i]!==!1:!0}const YN=({field:e,error:t,disabled:r,readOnly:n,isRequired:o,className:i,designMode:s=!1})=>{const a=WN(),d=e.properties||{},u=d.variant||"outline",l=d.size||"default",f=d.buttonText||e.label||"Customise sections",p=d.menuTitle||"VISIBLE SECTIONS",m=d.hideLabel??e.appearance?.hideLabel??!1,g=r||n||e.disabled||e.readOnly,h=S.useMemo(()=>a?.allFields?.length?KN(a.allFields,e):[],[a?.allFields,e]);return c.jsx(Ct,{field:e,error:t,isRequired:o,className:i,hideLabel:m,children:c.jsxs(Vl,{children:[c.jsx(tm,{asChild:!0,children:c.jsxs(Kt,{id:ht(e),type:"button",variant:u,size:l,disabled:!!g,className:j("w-fit gap-2",e.appearance?.className),children:[c.jsx(Rv,{className:"h-4 w-4"}),f]})}),c.jsxs(Hl,{align:"end",className:"w-64 p-0",children:[c.jsx("div",{className:"px-3 py-2 border-b",children:c.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:p})}),c.jsx("div",{className:"max-h-64 overflow-auto p-2 space-y-1",children:h.length===0?c.jsx("p",{className:"text-xs text-muted-foreground px-1 py-2",children:"No section headings on this form."}):h.map(y=>{const w=pi(y),v=y.label||w,A=s||!a?!0:a.visibility[w]!==!1;return c.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md px-1 py-1.5 hover:bg-muted/50",children:[c.jsx(Cn,{htmlFor:`ui-section-${e.id}-${w}`,className:"text-xs font-normal truncate",children:v}),c.jsx($m,{id:`ui-section-${e.id}-${w}`,checked:A,disabled:s||!a||!!g,onCheckedChange:C=>{!a||s||a.setSectionVisible(w,!!C)}})]},y.id)})})]})]})})},XN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:d})=>{const u=e.properties,l=u?.max||5,f=u?.icon||"star",p=h=>{i||s||e.disabled||e.readOnly||(r(h),n?.())},m=h=>{},g=h=>{const y=t>=h+1,w=j("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 f==="star"?c.jsx(fu,{className:j(w,"h-6 w-6"),onClick:()=>p(h+1),onMouseEnter:()=>m()},h):c.jsx(fu,{className:j(w,"h-6 w-6"),onClick:()=>p(h+1),onMouseEnter:()=>m()},h)};return c.jsx(Ct,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{id:ht(e),className:"flex items-center gap-1",role:"radiogroup","aria-label":e.label,"aria-describedby":$t(e,!!o),"aria-invalid":Zt(!!o),"aria-required":a,children:[Array.from({length:l},(h,y)=>g(y)),u?.showValue!==!1&&c.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:t>0?t:""})]})})};var Oh=["PageUp","PageDown"],Ih=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Mh={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Ao="Slider",[fc,JN,QN]=qa(Ao),[Lh]=xr(Ao,[QN]),[ZN,Qs]=Lh(Ao),Dh=b.forwardRef((e,t)=>{const{name:r,min:n=0,max:o=100,step:i=1,orientation:s="horizontal",disabled:a=!1,minStepsBetweenThumbs:d=0,defaultValue:u=[n],value:l,onValueChange:f=()=>{},onValueCommit:p=()=>{},inverted:m=!1,form:g,...h}=e,y=b.useRef(new Set),w=b.useRef(0),A=s==="horizontal"?ek:tk,[C=[],F]=tn({prop:l,defaultProp:u,onChange:k=>{[...y.current][w.current]?.focus(),f(k)}}),E=b.useRef(C);function T(k){const D=sk(C,k);O(k,D)}function N(k){O(k,w.current)}function x(){const k=E.current[w.current];C[w.current]!==k&&p(C)}function O(k,D,{commit:R}={commit:!1}){const I=dk(i),z=uk(Math.round((k-n)/i)*i+n,I),L=Jo(z,[n,o]);F((B=[])=>{const M=ok(B,L,D);if(ck(M,d*i)){w.current=M.indexOf(L);const V=String(M)!==String(B);return V&&R&&p(M),V?M:B}else return B})}return c.jsx(ZN,{scope:e.__scopeSlider,name:r,disabled:a,min:n,max:o,valueIndexToChangeRef:w,thumbs:y.current,values:C,orientation:s,form:g,children:c.jsx(fc.Provider,{scope:e.__scopeSlider,children:c.jsx(fc.Slot,{scope:e.__scopeSlider,children:c.jsx(A,{"aria-disabled":a,"data-disabled":a?"":void 0,...h,ref:t,onPointerDown:Le(h.onPointerDown,()=>{a||(E.current=C)}),min:n,max:o,inverted:m,onSlideStart:a?void 0:T,onSlideMove:a?void 0:N,onSlideEnd:a?void 0:x,onHomeKeyDown:()=>!a&&O(n,0,{commit:!0}),onEndKeyDown:()=>!a&&O(o,C.length-1,{commit:!0}),onStepKeyDown:({event:k,direction:D})=>{if(!a){const z=Oh.includes(k.key)||k.shiftKey&&Ih.includes(k.key)?10:1,L=w.current,B=C[L],M=i*z*D;O(B+M,L,{commit:!0})}}})})})})});Dh.displayName=Ao;var[Bh,$h]=Lh(Ao,{startEdge:"left",endEdge:"right",size:"width",direction:1}),ek=b.forwardRef((e,t)=>{const{min:r,max:n,dir:o,inverted:i,onSlideStart:s,onSlideMove:a,onSlideEnd:d,onStepKeyDown:u,...l}=e,[f,p]=b.useState(null),m=Ze(t,A=>p(A)),g=b.useRef(void 0),h=so(o),y=h==="ltr",w=y&&!i||!y&&i;function v(A){const C=g.current||f.getBoundingClientRect(),F=[0,C.width],T=hc(F,w?[r,n]:[n,r]);return g.current=C,T(A-C.left)}return c.jsx(Bh,{scope:e.__scopeSlider,startEdge:w?"left":"right",endEdge:w?"right":"left",direction:w?1:-1,size:"width",children:c.jsx(jh,{dir:h,"data-orientation":"horizontal",...l,ref:m,style:{...l.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:A=>{const C=v(A.clientX);s?.(C)},onSlideMove:A=>{const C=v(A.clientX);a?.(C)},onSlideEnd:()=>{g.current=void 0,d?.()},onStepKeyDown:A=>{const F=Mh[w?"from-left":"from-right"].includes(A.key);u?.({event:A,direction:F?-1:1})}})})}),tk=b.forwardRef((e,t)=>{const{min:r,max:n,inverted:o,onSlideStart:i,onSlideMove:s,onSlideEnd:a,onStepKeyDown:d,...u}=e,l=b.useRef(null),f=Ze(t,l),p=b.useRef(void 0),m=!o;function g(h){const y=p.current||l.current.getBoundingClientRect(),w=[0,y.height],A=hc(w,m?[n,r]:[r,n]);return p.current=y,A(h-y.top)}return c.jsx(Bh,{scope:e.__scopeSlider,startEdge:m?"bottom":"top",endEdge:m?"top":"bottom",size:"height",direction:m?1:-1,children:c.jsx(jh,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:h=>{const y=g(h.clientY);i?.(y)},onSlideMove:h=>{const y=g(h.clientY);s?.(y)},onSlideEnd:()=>{p.current=void 0,a?.()},onStepKeyDown:h=>{const w=Mh[m?"from-bottom":"from-top"].includes(h.key);d?.({event:h,direction:w?-1:1})}})})}),jh=b.forwardRef((e,t)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:o,onSlideEnd:i,onHomeKeyDown:s,onEndKeyDown:a,onStepKeyDown:d,...u}=e,l=Qs(Ao,r);return c.jsx($e.span,{...u,ref:t,onKeyDown:Le(e.onKeyDown,f=>{f.key==="Home"?(s(f),f.preventDefault()):f.key==="End"?(a(f),f.preventDefault()):Oh.concat(Ih).includes(f.key)&&(d(f),f.preventDefault())}),onPointerDown:Le(e.onPointerDown,f=>{const p=f.target;p.setPointerCapture(f.pointerId),f.preventDefault(),l.thumbs.has(p)?p.focus():n(f)}),onPointerMove:Le(e.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&o(f)}),onPointerUp:Le(e.onPointerUp,f=>{const p=f.target;p.hasPointerCapture(f.pointerId)&&(p.releasePointerCapture(f.pointerId),i(f))})})}),zh="SliderTrack",Uh=b.forwardRef((e,t)=>{const{__scopeSlider:r,...n}=e,o=Qs(zh,r);return c.jsx($e.span,{"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation,...n,ref:t})});Uh.displayName=zh;var pc="SliderRange",Vh=b.forwardRef((e,t)=>{const{__scopeSlider:r,...n}=e,o=Qs(pc,r),i=$h(pc,r),s=b.useRef(null),a=Ze(t,s),d=o.values.length,u=o.values.map(p=>Rh(p,o.min,o.max)),l=d>1?Math.min(...u):0,f=100-Math.max(...u);return c.jsx($e.span,{"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,...n,ref:a,style:{...e.style,[i.startEdge]:l+"%",[i.endEdge]:f+"%"}})});Vh.displayName=pc;var mc="SliderThumb",Hh=b.forwardRef((e,t)=>{const r=JN(e.__scopeSlider),[n,o]=b.useState(null),i=Ze(t,a=>o(a)),s=b.useMemo(()=>n?r().findIndex(a=>a.ref.current===n):-1,[r,n]);return c.jsx(rk,{...e,ref:i,index:s})}),rk=b.forwardRef((e,t)=>{const{__scopeSlider:r,index:n,name:o,...i}=e,s=Qs(mc,r),a=$h(mc,r),[d,u]=b.useState(null),l=Ze(t,v=>u(v)),f=d?s.form||!!d.closest("form"):!0,p=ei(d),m=s.values[n],g=m===void 0?0:Rh(m,s.min,s.max),h=ik(n,s.values.length),y=p?.[a.size],w=y?ak(y,g,a.direction):0;return b.useEffect(()=>{if(d)return s.thumbs.add(d),()=>{s.thumbs.delete(d)}},[d,s.thumbs]),c.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${g}% + ${w}px)`},children:[c.jsx(fc.ItemSlot,{scope:e.__scopeSlider,children:c.jsx($e.span,{role:"slider","aria-label":e["aria-label"]||h,"aria-valuemin":s.min,"aria-valuenow":m,"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:l,style:m===void 0?{display:"none"}:e.style,onFocus:Le(e.onFocus,()=>{s.valueIndexToChangeRef.current=n})})}),f&&c.jsx(Wh,{name:o??(s.name?s.name+(s.values.length>1?"[]":""):void 0),form:s.form,value:m},n)]})});Hh.displayName=mc;var nk="RadioBubbleInput",Wh=b.forwardRef(({__scopeSlider:e,value:t,...r},n)=>{const o=b.useRef(null),i=Ze(o,n),s=ti(t);return b.useEffect(()=>{const a=o.current;if(!a)return;const d=window.HTMLInputElement.prototype,l=Object.getOwnPropertyDescriptor(d,"value").set;if(s!==t&&l){const f=new Event("input",{bubbles:!0});l.call(a,t),a.dispatchEvent(f)}},[s,t]),c.jsx($e.input,{style:{display:"none"},...r,ref:i,defaultValue:t})});Wh.displayName=nk;function ok(e=[],t,r){const n=[...e];return n[r]=t,n.sort((o,i)=>o-i)}function Rh(e,t,r){const i=100/(r-t)*(e-t);return Jo(i,[0,100])}function ik(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function sk(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 ak(e,t,r){const n=e/2,i=hc([0,50],[0,n]);return(n-i(t)*r)*r}function lk(e){return e.slice(0,-1).map((t,r)=>e[r+1]-t)}function ck(e,t){if(t>0){const r=lk(e);return Math.min(...r)>=t}return!0}function hc(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 dk(e){return(String(e).split(".")[1]||"").length}function uk(e,t){const r=Math.pow(10,t);return Math.round(e*r)/r}var fk=Dh,pk=Uh,mk=Vh,hk=Hh;function gk({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 c.jsxs(fk,{"data-slot":"slider",defaultValue:t,value:r,min:n,max:o,className:j("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:[c.jsx(pk,{"data-slot":"slider-track",className:j("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:c.jsx(mk,{"data-slot":"slider-range",className:j("bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")})}),Array.from({length:s.length},(a,d)=>c.jsx(hk,{"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"},d))]})}const yk=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:d})=>{const u=e.properties,l=u?.min??0,f=u?.max??100,p=u?.step??1,m=u?.showValue!==!1,g=u?.marks||[],h=w=>{i||s||e.disabled||e.readOnly||(r(w[0]??l),n?.())},y=t??l;return c.jsx(Ct,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[m&&c.jsx("span",{className:"text-sm font-medium",children:y}),!m&&c.jsx("span",{className:"text-sm text-muted-foreground",children:l}),!m&&c.jsx("span",{className:"text-sm text-muted-foreground",children:f})]}),c.jsx(gk,{id:ht(e),value:[y],onValueChange:h,min:l,max:f,step:p,disabled:i||e.disabled||s||e.readOnly,className:j("w-full",o&&"border-destructive",e.appearance?.className),"aria-describedby":$t(e,!!o),"aria-invalid":Zt(!!o),"aria-required":a}),g.length>0&&c.jsx("div",{className:"flex justify-between text-xs text-muted-foreground",children:g.map((w,v)=>c.jsx("span",{className:"text-center",children:w.label},v))})]})})},bk=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:d})=>{const u=S.useRef(null),[l,f]=S.useState(!1),p=i||e.disabled||s||e.readOnly,m=S.useCallback(w=>{if(p)return;f(!0);const v=u.current;if(!v)return;const A=v.getContext("2d");if(!A)return;const C=v.getBoundingClientRect(),F="touches"in w?w.touches[0].clientX-C.left:w.clientX-C.left,E="touches"in w?w.touches[0].clientY-C.top:w.clientY-C.top;A.beginPath(),A.moveTo(F,E)},[p]),g=S.useCallback(w=>{if(!l||p)return;const v=u.current;if(!v)return;const A=v.getContext("2d");if(!A)return;const C=v.getBoundingClientRect(),F="touches"in w?w.touches[0].clientX-C.left:w.clientX-C.left,E="touches"in w?w.touches[0].clientY-C.top:w.clientY-C.top;A.lineWidth=2,A.lineCap="round",A.strokeStyle="#000",A.lineTo(F,E),A.stroke(),A.beginPath(),A.moveTo(F,E)},[l,p]),h=S.useCallback(()=>{if(!l)return;f(!1);const w=u.current;if(!w)return;const v=w.toDataURL();r(v),n?.()},[l,r,n]),y=S.useCallback(()=>{const w=u.current;if(!w||p)return;const v=w.getContext("2d");v&&(v.clearRect(0,0,w.width,w.height),r(null),n?.())},[p,r,n]);return S.useEffect(()=>{const w=u.current;if(w&&(w.width=w.offsetWidth,w.height=200,t)){const v=new Image;v.onload=()=>{const A=w.getContext("2d");A&&A.drawImage(v,0,0)},v.src=t}},[t]),c.jsx(Ct,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{className:"space-y-2",children:[c.jsx("div",{className:j("border-2 border-dashed rounded-lg overflow-hidden",o&&"border-destructive",p&&"opacity-50 cursor-not-allowed"),children:c.jsx("canvas",{ref:u,id:ht(e),className:"w-full cursor-crosshair touch-none",onMouseDown:m,onMouseMove:g,onMouseUp:h,onMouseLeave:h,onTouchStart:m,onTouchMove:g,onTouchEnd:h,"aria-describedby":$t(e,!!o),"aria-invalid":Zt(!!o),"aria-required":a,style:{height:"200px"}})}),!p&&c.jsx("div",{className:"flex justify-end",children:c.jsxs(Kt,{type:"button",variant:"outline",size:"sm",onClick:y,className:"text-xs",children:[c.jsx(Yo,{className:"h-3 w-3 mr-1"}),"Clear"]})})]})})},vk=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:d,hideRowControls:u=!1,formValues:l,submissionContext:f})=>{const p=e.properties,m=p?.columns||[],g=p?.minRows||1,h=p?.maxRows||10,y=!u&&p?.allowAddRow!==!1,w=!u&&p?.allowDeleteRow!==!1,v=i===!1&&s===!1?!1:i||e.disabled||s||e.readOnly,A=t||[],C=y&&A.length<h,F=w&&A.length>g,E=S.useCallback(()=>{if(!C||v)return;const I={};m.forEach(z=>{I[z.name]=z.defaultValue??""}),r([...A,I]),n?.()},[A,m,C,v,r,n]),T=S.useCallback(I=>{if(!F||v)return;const z=A.filter((L,B)=>B!==I);r(z),n?.()},[A,F,v,r,n]),N=S.useCallback((I,z,L)=>{if(v)return;const B=[...A];B[I]||(B[I]={}),B[I][z]=L,r(B),n?.()},[A,v,r,n]);if(S.useEffect(()=>{if(A.length<g){const I=g-A.length,z=[];for(let L=0;L<I;L++){const B={};m.forEach(M=>{B[M.name]=M.defaultValue??""}),z.push(B)}r([...A,...z])}},[g,m,r,A.length]),m.length===0)return c.jsx(Ct,{field:e,error:o,isRequired:a,className:d,children:c.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 x=Math.max(1,e.position?.rowSpan??1),O=Math.max(1,e.position?.columnSpan??1),k=Math.max(A.length,1),D=x>=3?"py-4":x>=2?"py-3":"py-2.5",R=O>=3?"px-4":O>=2?"px-3":"px-4";return c.jsx(Ct,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{id:ht(e),className:j("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":$t(e,!!o),"aria-invalid":Zt(!!o),"aria-required":a,children:[c.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:c.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:[c.jsx("thead",{children:c.jsxs("tr",{className:"border-b border-border bg-muted/60",children:[m.map(I=>c.jsxs("th",{className:j(R,D,"text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground whitespace-nowrap"),children:[I.label,a&&I.validation?.some(z=>z.type==="required")&&c.jsx("span",{className:"text-destructive ml-1",children:"*"})]},I.id)),w&&c.jsx("th",{className:"w-12"})]})}),c.jsx("tbody",{className:"h-full",children:A.length===0?c.jsx("tr",{children:c.jsx("td",{colSpan:m.length+(w?1:0),className:j(R,"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((I,z)=>{const L=A[z],B=L&&typeof L=="object"&&!Array.isArray(L)?{...l??{},...L}:l;return c.jsxs("tr",{className:"border-b border-border/50 hover:bg-muted/30 transition-colors last:border-b-0",style:{height:`${100/k}%`},children:[m.map(M=>{const V={...M,name:`${e.name}_${z}_${M.name}`,appearance:{...M.appearance,hideLabel:!0}},$=M.name??"",ie=I[$]!==void 0?I[$]:$&&Object.keys(I).find(q=>q.toLowerCase()===$.toLowerCase())?I[Object.keys(I).find(q=>q.toLowerCase()===$.toLowerCase())]:void 0,H=!!M.readOnly,K=q=>{if(q==null)return"";if(Array.isArray(q))return q.map(ne=>typeof ne=="object"&&ne!==null&&"name"in ne?String(ne.name??ne):String(ne)).join(", ");if(typeof q=="object"&&q!==null&&!(q instanceof Date)){const ne=q;return typeof ne.name=="string"&&typeof ne.code=="string"?`${ne.code} ${ne.name}`.trim():typeof ne.name=="string"?ne.name:typeof ne.code=="string"?ne.code:String(ne.name??ne.code??q)}return String(q)},X=q=>typeof q=="object"&&q!==null&&!Array.isArray(q)?K(q):String(q??""),le=M.name?.toLowerCase()==="type"||M.label?.toLowerCase()==="type";if(H){const q=K(ie);return c.jsx("td",{className:"px-4 py-2.5 align-middle first:pl-6 last:pr-6",children:c.jsx("div",{className:"min-w-[120px] text-sm text-foreground",children:le&&q?c.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:q}):c.jsx("span",{className:"py-1 block",children:q})})},M.id)}const re=()=>{switch(M.type){case"text":case"password":case"url":return c.jsx(Wi,{field:V,value:X(ie),onChange:q=>N(z,M.name,q),disabled:v,readOnly:v,className:"w-full"});case"number":return c.jsx(Ka,{field:V,value:ie??null,onChange:q=>N(z,M.name,q),disabled:v,readOnly:v,className:"w-full"});case"email":return c.jsx(pu,{field:V,value:X(ie),onChange:q=>N(z,M.name,q),disabled:v,readOnly:v,className:"w-full"});case"phone":case"aadhaar":return c.jsx(mu,{field:V,value:X(ie),onChange:q=>N(z,M.name,q),disabled:v,readOnly:v,className:"w-full"});case"textarea":return c.jsx(hu,{field:V,value:X(ie),onChange:q=>N(z,M.name,q),disabled:v,readOnly:v,className:"w-full"});case"select":return c.jsx(zp,{field:V,value:typeof ie=="string"?ie:X(ie),onChange:q=>N(z,M.name,q),disabled:v,className:"w-full",formValues:B,submissionContext:f});case"multiselect":{const q=Array.isArray(ie)?ie:ie!=null&&ie!==""?[String(ie)]:[];return c.jsx(Pm,{field:V,value:q,onChange:ne=>N(z,M.name,ne),disabled:v,className:"w-full",formValues:B,submissionContext:f})}case"asyncsearch":return c.jsx(lm,{field:V,value:ie,onChange:q=>N(z,M.name,q),disabled:v,readOnly:v,className:"w-full",formValues:B,submissionContext:f});case"checkbox":return c.jsx(Om,{field:V,value:ie||!1,onChange:q=>N(z,M.name,q),disabled:v,className:"w-full"});case"radio":case"checkboxgroup":return c.jsx(oh,{field:V,value:typeof ie=="string"?ie:X(ie),onChange:q=>N(z,M.name,q),disabled:v,className:"w-full"});case"date":case"time":case"datetime":case"daterange":return c.jsx(ih,{field:V,value:typeof ie=="string"?ie:X(ie),onChange:q=>N(z,M.name,q),disabled:v,readOnly:v,className:"w-full"});default:return c.jsx(Wi,{field:V,value:X(ie),onChange:q=>N(z,M.name,q),disabled:v,readOnly:v,className:"w-full"})}};return c.jsx("td",{className:"px-4 py-2.5 align-middle first:pl-6 last:pr-6",children:c.jsx("div",{className:"min-w-[160px] w-full [&_input]:min-w-[10rem] [&_input]:overflow-visible [&_textarea]:min-h-[2.5rem]",children:re()})},M.id)}),w&&c.jsx("td",{className:"px-2 py-2",children:c.jsx(Kt,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>T(z),disabled:!F||v,children:c.jsx(Yo,{className:"h-4 w-4"})})})]},z)})})]})}),C&&c.jsx("div",{className:"shrink-0 p-3 border-t bg-muted/30",children:c.jsxs(Kt,{type:"button",variant:"outline",size:"sm",onClick:E,disabled:v,className:"w-full",children:[c.jsx(uu,{className:"h-4 w-4 mr-2"}),"Add Row"]})})]})})},wk="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",Sk="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",xk="h-8 min-w-[2ch] max-w-full flex-1 border-0 bg-transparent px-0 shadow-none focus-visible:ring-0";function Gh(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 Ak(e){const t=e.replace(/[^\d.-]/g,"");if(t===""||t==="-"||t===".")return null;const r=parseFloat(t);return Number.isNaN(r)?null:r}function Ck(e){if(e==null||e==="")return"";const t=typeof e=="number"?e:Number(e);return Number.isNaN(t)?"":String(t)}function Kh(e,t){return Gh(e,{format:"currency"},t)}function mi(e){return e==null||e===""}function qh(e){return e.mode??"editable"}function Ek(e,t){return e.kind==="currency"||e.kind==="input"&&e.inputType==="number"?!0:t?.format==="currency"||t?.format==="number"||t?.format==="percent"}function Yh(e,t,r){if(e!==void 0){if(e==="")return"";if(Ek(t,r)){const n=Number(e);return Number.isNaN(n)?e:n}return e}}function gc(e,t){if(!(!e||!("defaultValue"in e)||e.defaultValue===void 0))return Yh(e.defaultValue,e,t)}function yc(e,t,r){if(!t||!mi(e))return e;if(t.kind==="currency"&&qh(t)==="static"&&t.value!==void 0)return Yh(t.value,t,r);const n=gc(t,r);return n!==void 0?n:e}function Nk(e,t,r){const n={...t};for(const[o,i]of Object.entries(e)){const s=r.find(d=>d.key===o);if(!mi(n[o]))continue;const a=yc(n[o],i,s);(!mi(a)||i&&"defaultValue"in i&&i.defaultValue==="")&&(n[o]=a)}return n}function Zs(e,t,r){if(!mi(e))return e;const n=gc(t,r);return n!==void 0?n:e}const kk=new Set(["all_items_summary","invoice_discount","grand_total"]);function _k(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"&&!kk.has(r.slotId));default:return e}}function bc(e){if(typeof e=="number"&&!Number.isNaN(e))return e;const t=Number(e);return Number.isNaN(t)?0:t}function Tk(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 Fk(e,t,r){const n=u=>bc(r.values[u]),o=(u,l)=>{const f=t.find(p=>p.slotId===u&&p.rowKind==="static");return f?bc(f.values[l]):0},i=(u,l="all")=>_k(t,l).reduce((f,p)=>f+bc(p.values[u]),0),s={...ji.functions,cell:n,cellInRow:o,SUM:i},a=Object.keys(s),d=Object.values(s);try{const u=new Function(...a,`return (${e});`)(...d);return u==null||typeof u=="number"&&Number.isNaN(u)?null:u}catch{return null}}function Pk(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 Ok(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=Tk(e,n,o.key);if(i?.kind==="formula"){const s=Fk(i.expression,r,n),a=e.columns.find(d=>d.key===o.key);n.values[o.key]=mi(s)?gc(i,a)??s:s}}return{rows:r}}function Co(e,t,r=8){let n={rows:t.rows.map(o=>({...o,values:{...o.values}}))};for(let o=0;o<r;o++){const i=Ok(e,n);if(Pk(i.rows,n.rows))return i;n=i}return n}function Ik(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 Co(e,{rows:s})}function Xh(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,l]of Object.entries(e.cells)){const f=r.find(p=>p.key===u);(l.kind==="api"&&l.path||l.kind==="currency"&&l.mode==="api"&&l.path)&&(a[u]=Zs(Qe(i,l.path),l,f))}const d=a.service??a.tariff_type;return{slotId:e.id,rowKind:"dynamic",rowInstanceId:s,label:typeof d=="string"?d:void 0,values:a}})}function vc(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 wc(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:Nk(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:vc(e,r,n)}}function Mk(e,t,r,n){const o=wc(e,n),i=e.rowSlots.find(d=>d.kind==="dynamic"&&d.block.id===t);if(!i||i.kind!=="dynamic")return Co(e,o);const s=new Map,a=new Map;for(const d of e.rowSlots)if(d.kind==="static"){const u=o.rows.find(l=>l.slotId===d.row.id&&l.rowKind==="static");u&&s.set(d.row.id,{...u,values:{...u.values}})}else{const u=d.block.id===t?Xh(d.block,r,e.columns):o.rows.filter(l=>l.slotId===d.block.id&&l.rowKind==="dynamic");a.set(d.block.id,u.map(l=>({...l,values:{...l.values}})))}return Co(e,{rows:vc(e,s,a)})}function Jh(e,t,r){const n=wc(e,r);if(t==null||typeof t!="object"||Array.isArray(t))return Co(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(f=>f.slotId===a.row.id&&f.rowKind==="static")?.values??{}},l=o[a.row.id]??o;for(const[f,p]of Object.entries(a.row.cells)){const m=e.columns.find(g=>g.key===f);(p.kind==="api"&&p.path||p.kind==="currency"&&p.mode==="api"&&p.path)&&(u[f]=Zs(Qe(l,p.path),p,m))}i.set(a.row.id,{slotId:a.row.id,rowKind:"static",rowInstanceId:a.row.id,label:a.row.label,values:u})}else{const d=a.block.apiArrayPath??a.block.id,u=Qe(o,d);s.set(a.block.id,Array.isArray(u)?Xh(a.block,u,e.columns):[])}return Co(e,{rows:vc(e,i,s)})}function Qh(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 Lk(e){const t=e?.color?.trim();return t?{color:t}:{}}function Sc(e){return{className:Qh(e),style:Lk(e)}}function Dk(e){return e?!!(e.fontSize||e.bold||e.italic||e.underline||e.color?.trim()):!1}function Bk(e,t){if(!e&&!t)return;const r={...e,...t};return Dk(r)?r:void 0}function $k(e,t){const r=e?.kind==="label"?Bk(t,e.cellStyle):e?.cellStyle;return Sc(r)}function xc(e){return e==="center"?"text-center":e==="right"?"text-right":"text-left"}function Zh(e,t){return e?.align?e.align:t?.align??"left"}function eg(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 tg(e){if(e.type!=="billingGrid")return!1;const t=eg(e),r=e.properties;return!!(t?.apiEndpoint&&(t?.valueSource==="api"||r?.valueSource==="api"))}function jk(e,t,r){let n=e;if(r?.trim()&&(n=Qe(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 ea(e){return JSON.stringify(e?.rows??[])}function zk({field:e,properties:t,formValues:r={},submissionContext:n,value:o,onChange:i}){const s=tg(e),a=eg(e),[d,u]=S.useState(!1),[l,f]=S.useState(null),p=S.useRef(""),m=S.useRef(o);m.current=o;const g=S.useMemo(()=>{const C=a?.apiEndpoint||"",F=a?.apiQueryParams;return oo(C,F)},[a?.apiEndpoint,a?.apiQueryParams]),h=S.useMemo(()=>{const C=new Set;for(const F of a?.dependentFields??[])typeof F=="string"&&F.trim()&&C.add(F.trim());return[...C]},[a?.dependentFields]),y=S.useMemo(()=>{const C=new Set([...g,...h]);if(C.size===0)return null;const F={};return C.forEach(E=>{F[E]=r[E]}),JSON.stringify(F)},[g,h,r]),w=S.useMemo(()=>JSON.stringify(n||{}),[n]),v=S.useMemo(()=>{const C=new Set;e.name?.trim()&&C.add(e.name.trim());const F=e.key;return typeof F=="string"&&F.trim()&&C.add(F.trim()),[...C]},[e.name,e.key]),A=S.useMemo(()=>JSON.stringify({rowSlots:t.rowSlots,columns:t.columns}),[t.rowSlots,t.columns]);return S.useEffect(()=>{const C=a?.apiEndpoint;if(!s||!C)return;let F=!1;const E=N=>{if(F)return;const x=ea(N),O=ea(m.current);x!==O&&p.current!==x&&(p.current=x,i(N))};return(async()=>{u(!0),f(null);try{const N=a?.apiMethod||"GET",x=a?.apiRealtime,O=Ui({apiEndpoint:C,apiMethod:N,apiQueryParams:a?.apiQueryParams||{},formValues:r,submissionContext:n,apiRealtime:x,additionalRequiredFieldNames:h,excludeFormFieldNames:v});if(O.blocked){F||u(!1);return}const k={"Content-Type":"application/json"};a?.apiKey&&(k["X-CSCAPI-KEY"]=a.apiKey);const D=a?.apiAuth??Os(a?.apiHeaders)??{type:"none"};Object.assign(k,Ms(D,{formValues:r,submissionContext:n,apiRealtime:x})),Object.assign(k,Pn(Ps(a?.apiHeaders),{formValues:r,submissionContext:n,apiRealtime:x}));const R=Pn(a?.apiBodyFields,{formValues:r,submissionContext:n,apiRealtime:x}),I={method:N.toLowerCase(),url:Wr(O.url),headers:k};(O.postBodyBase!=null||Object.keys(R).length>0)&&(I.data={...O.postBodyBase??{},...R});const z=await St(I),L=jk(z.data,t,a?.apiResponsePath);if(!L){F||f("API response could not be mapped to billing grid rows.");return}const B=Jh(t,L,m.current);E(B)}catch(N){if(F)return;let x="Failed to load billing data";const O=N;if(O.response){const k=O.response.data;if(O.response.status===404)x="API endpoint not found.";else if(O.response.status===401)x="Authentication failed.";else if(typeof k=="string")x=k;else if(k&&typeof k=="object"){const D=k;x=D.error||D.message||D.detail||x}}else O.message&&(x=String(O.message));f(x)}finally{F||u(!1)}})(),()=>{F=!0}},[s,a?.apiEndpoint,a?.apiMethod,a?.apiResponsePath,y,h,v,w,A]),{isLoading:d,error:l}}function Uk(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 rg(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 Vk=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,readOnly:s,isRequired:a,className:d,formValues:u,submissionContext:l})=>{const f=e.properties??{},p=f.columns??[],m=f.currencySymbol??"₹",g=f.emptyDisplay??"—",h=i||s,y=tg(e),{isLoading:w}=zk({field:e,properties:f,formValues:u,submissionContext:l,value:t,onChange:r}),v=S.useMemo(()=>{const D=wc(f,t);return Co(f,D)},[f,t]),A=S.useRef("");S.useEffect(()=>{const D=ea(v),R=ea(t);D===R||D===A.current||(A.current=D,r(v))},[v,t,r]),S.useEffect(()=>{!t?.rows?.length&&v.rows.length&&!y&&r(v)},[t,v,r,y]);const C=S.useCallback((D,R,I,z,L)=>{if(h)return;const B=L==="number"?Ak(z):z===""?null:z,M=Ik(f,v,D,R,I,B);r(M)},[h,v,r,f]),F=(D,R,I,z,L,B)=>{const M=p.find(le=>le.key===L),V=rg(f,D,R,L),$=xc(Zh(V,M)),ie=yc(B,V,M),H=Uk(f,D,R),K=H?.kind==="static"?H.row.labelStyle:H?.kind==="dynamic"?H.block.labelStyle:void 0,X=$k(V,K);if(V?.kind==="label")return c.jsx("span",{className:j(X.className||"font-medium",$,!X.style.color&&"text-foreground"),style:X.style,children:z??g});if(V?.kind==="input"&&!h){const le=ie==null||ie===""?"":String(ie);return c.jsx(An,{type:"text",inputMode:V.inputType==="number"?"decimal":"text",value:le,onChange:re=>C(I,D,L,re.target.value,V.inputType),onBlur:n,className:j(wk,$,X.className),style:X.style,disabled:h})}if(V?.kind==="currency"){const le=qh(V);if(le==="static"){const q=V.value!==void 0&&V.value!==""?yc(null,{...V,mode:"static"},M):ie;return c.jsx("span",{className:j("tabular-nums",$,X.className),style:X.style,children:Kh(q,{currencySymbol:m,emptyDisplay:g})})}if(le==="api"||h)return c.jsx("span",{className:j("tabular-nums",$,X.className),style:X.style,children:Kh(ie,{currencySymbol:m,emptyDisplay:g})});const re=Ck(ie);return c.jsxs("div",{className:j(Sk,$==="text-center"&&"justify-center",$==="text-right"&&"justify-end",$==="text-left"&&"justify-start",X.className),style:X.style,children:[c.jsx("span",{className:"shrink-0 tabular-nums",children:m}),c.jsx(An,{type:"text",inputMode:"decimal",value:re,onChange:q=>C(I,D,L,q.target.value,"number"),onBlur:n,className:xk,disabled:h})]})}return V?.kind==="static"?c.jsx("span",{className:j($,X.className,!X.style.color&&"text-muted-foreground"),style:X.style,children:V.value}):c.jsx("span",{className:j($,X.className),style:X.style,children:Gh(ie,M,{currencySymbol:m,emptyDisplay:g})})},E=f.gridTitle?.trim()??"",T=Math.max(1,e.position?.rowSpan??1),N=Math.max(1,e.position?.columnSpan??1),x=Math.max(v.rows.length,1),O=T>=3?"py-4":T>=2?"py-3":"py-2",k=N>=3?"px-4":N>=2?"px-3":"px-2";return p.length===0?c.jsx(Ct,{field:e,error:o,isRequired:a,className:d,children:c.jsx("div",{className:"p-4 border rounded-md bg-muted/50 text-sm text-muted-foreground",children:"No columns defined for this billing grid"})}):c.jsx(Ct,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{id:ht(e),className:j("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":$t(e,!!o),"aria-invalid":Zt(!!o),"aria-required":a,children:[w&&c.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/60",children:c.jsx(io,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),E?c.jsx("div",{className:j("shrink-0 px-4 py-2 border-b bg-muted/40",Qh(f.gridTitleStyle)||"text-muted-foreground"),style:Sc(f.gridTitleStyle).style,children:E}):null,c.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:c.jsxs("table",{className:"w-full h-full min-h-full border-collapse text-sm table-fixed",style:f.minWidth?{minWidth:f.minWidth}:void 0,children:[c.jsx("thead",{children:c.jsx("tr",{className:"border-b border-border bg-muted/60",children:p.map(D=>{const R=Sc(D.headerStyle);return c.jsx("th",{className:j(k,O,"text-xs uppercase tracking-wider whitespace-nowrap",xc(D.align),R.className||"font-semibold text-muted-foreground"),style:R.style,children:D.label},D.id)})})}),c.jsx("tbody",{className:"h-full",children:v.rows.length===0?c.jsx("tr",{children:c.jsx("td",{colSpan:p.length,className:j(k,"py-8 text-center text-sm text-muted-foreground"),children:"No billing rows configured"})}):v.rows.map(D=>c.jsx("tr",{className:"border-b border-border/60",style:{height:`${100/x}%`},children:p.map(R=>{const I=rg(f,D.slotId,D.rowKind,R.key),z=Zh(I,R);return c.jsx("td",{className:j(k,O,"align-middle whitespace-nowrap",xc(z)),children:F(D.slotId,D.rowKind,D.rowInstanceId,D.label,R.key,D.values[R.key])},R.id)})},`${D.slotId}-${D.rowInstanceId}`))})]})})]})})};function Ac(e,t,r){return Jh(e,t,r)}const Hk=({field:e,value:t,error:r,disabled:n,isRequired:o,className:i,formValues:s={},submissionContext:a,extraSubmitPayload:d,skipApiCall:u=!1,prepopulateResponse:l=null})=>{const f=e.properties||{},p=f.source??"manual",m=Array.isArray(f.statuses)?f.statuses:[],g=(f.dataPath||"data").trim(),h=f.showStatusText===!0,y=(f.statusTextPath||"data.admissionStatus").trim(),w=f.showCurrentIndicator!==!1,[v,A]=S.useState(null),[C,F]=S.useState(!1),[E,T]=S.useState(null),N=Ea.useParams(),x=S.useRef(s),O=S.useRef(a),k=S.useRef(d),D=S.useRef(N);x.current=s,O.current=a,k.current=d,D.current=N;const R=S.useCallback(async()=>{const M=f.apiEndpoint?.trim();if(!M){T("Status API endpoint is not configured");return}F(!0),T(null);try{const V=O.current,$=k.current,ie=V!=null&&typeof V=="object"?{...V,...$||{}}:$||{},H=Wr(Rr(M,x.current,D.current,ie,void 0,l??void 0)),K=(f.apiMethod||"GET").toUpperCase(),X=await fetch(H,{method:K,headers:K==="POST"?{"Content-Type":"application/json"}:void 0});if(!X.ok)throw new Error(`HTTP ${X.status}`);const le=await X.json(),re=g?Qe(le,g):le;A(re&&typeof re=="object"?re:{})}catch(V){T(V instanceof Error?V.message:"Failed to load status"),A(null)}finally{F(!1)}},[f.apiEndpoint,f.apiMethod,g,l]);S.useEffect(()=>{p==="api"&&!u&&R()},[p,u,R]);const I=p==="api"?v:t&&typeof t=="object"?(g?Qe(t,g):null)??t:null,z=h&&y&&I?String(Qe(I,y)??Qe({data:I},y)??""):"",L=M=>{if(!I||typeof I!="object")return!1;const V=I[M];return V===!0||V==="true"||V===1};let B=!1;return c.jsx(Ct,{field:e,error:r||E||void 0,isRequired:o,className:j(i,"!space-y-0 h-full min-h-0 flex flex-col"),children:c.jsxs("div",{className:"rounded-lg border bg-card p-4 h-full min-h-0 flex flex-col",children:[C&&c.jsx("div",{className:"text-sm text-muted-foreground py-2",children:"Loading status..."}),h&&z&&!C&&c.jsx("p",{className:"text-sm text-muted-foreground mb-3 shrink-0","data-status-text":!0,children:z}),!C&&c.jsx("ul",{className:"flex-1 min-h-0 flex flex-col gap-y-8 overflow-y-auto pr-1 py-1",children:m.map(M=>{const V=L(M.key),$=w&&V&&!B;return $&&(B=!0),c.jsxs("li",{className:j("flex items-center gap-3 text-sm",V?"text-foreground":"text-muted-foreground"),children:[V?c.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:c.jsx(Gi,{className:"h-3 w-3"})}):c.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:c.jsx(lu,{className:"h-2.5 w-2.5 text-muted-foreground/60"})}),c.jsx("span",{className:"flex-1 min-w-0",children:M.label}),$&&c.jsx("span",{className:"shrink-0 text-xs font-medium text-primary",children:"Current"})]},M.key)})}),!C&&m.length===0&&c.jsx("p",{className:"text-sm text-muted-foreground",children:"No statuses configured."})]})})};function Cc(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 Eo(e,t){if(t){const r=Cc(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 Wk(e,t,r,n){if(r?.length){const i=n??" | ",s=r.map(a=>Cc(e,a)).filter(a=>a!=null).map(a=>String(a));if(s.length)return s.join(i)}if(t){const i=Cc(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 Rk=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:i,isRequired:s,className:a,submissionContext:d})=>{const u=e.properties||{},{dataSourceContextKey:l,labelField:f="name",valueField:p="email",displayFields:m,displayFieldsSeparator:g=" | ",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:d?Object.keys(d):[],dataSourceContextKey:l,contextKeyValue:d&&l?d[l]:void 0});const w=S.useMemo(()=>{if(!l||!d)return[];const k=d[l];return Array.isArray(k)?k:[]},[l,d]);console.log("[SelectableList] Step 2: contextList from submissionContext",{fieldName:e.name,contextListLength:w.length,contextListSample:w.length>0?w.slice(0,2):[]});const[v,A]=S.useState(()=>w.length>0?w:Array.isArray(t)?t:[]);S.useEffect(()=>{if(w.length>0){console.log("[SelectableList] Step 3: sync fullList from context",{fieldName:e.name,contextListLength:w.length}),A(w);return}Array.isArray(t)&&t.length>0&&A(k=>{const D=k.length===0||t.length>k.length?t:k;return console.log("[SelectableList] Step 3: sync fullList from value",{fieldName:e.name,valueLength:t.length,prevLength:k.length,nextLength:D.length}),D})},[w,t]);const C=S.useMemo(()=>{const k=Array.isArray(t)?t:[];return new Set(k.map(R=>Eo(R,p)))},[t,p]),F=v.length>0&&v.every(k=>C.has(Eo(k,p))),E=v.some(k=>C.has(Eo(k,p))),T=S.useCallback((k,D)=>{const R=Eo(k,p),I=Array.isArray(t)?t:[];D?C.has(R)||r([...I,k]):r(I.filter(z=>Eo(z,p)!==R)),n?.()},[t,p,C,r,n]),N=S.useCallback(k=>{r(k===!0?[...v]:[]),n?.()},[v,r,n]),x=v.length>0?v:Array.isArray(t)?t:[],O=i||e.disabled;return console.log("[SelectableList] Data in list",{fieldName:e.name,listLength:x.length,listSource:v.length>0?"fullList":"value",valueLength:Array.isArray(t)?t.length:0,fullListLength:v.length,listData:x.length>0?x:[],listDataFirstThree:x.length>0?x.slice(0,3):[]}),c.jsx("div",{className:j("relative z-10 flex flex-col min-h-0 h-full w-full",x.length>0&&"min-h-[14rem]",a),children:c.jsx(Ct,{field:e,error:o,isRequired:s,className:j("flex-1 min-h-0 flex flex-col",x.length>0&&"min-h-[14rem]"),children:c.jsx("div",{className:j("flex-1 min-h-0 flex flex-col",x.length>0&&"min-h-[14rem]"),children:c.jsxs("div",{className:j("flex-1 min-h-0 flex flex-col",x.length>0&&"overflow-visible"),children:[c.jsxs("div",{role:"listbox","aria-multiselectable":!0,className:j("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",x.length>0?"flex-1 min-h-0":"min-h-0"),children:[h&&x.length>0&&c.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:[c.jsx($s,{id:`${ht(e)}-select-all`,checked:F?!0:E?"indeterminate":!1,onCheckedChange:N,disabled:O,"aria-label":"Select all"}),c.jsxs(Cn,{htmlFor:`${ht(e)}-select-all`,className:"text-sm font-medium cursor-pointer",children:["Select all (",x.length,")"]}),c.jsxs("div",{className:"flex gap-1 ml-auto",children:[c.jsx(Kt,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs",disabled:O||F,onClick:()=>{r([...v]),n?.()},children:"Select all"}),c.jsx(Kt,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs",disabled:O||!E,onClick:()=>{r([]),n?.()},children:"Unselect all"})]})]}),x.length===0?c.jsx("p",{className:"px-3 py-4 text-sm text-muted-foreground",children:"No items to display."}):c.jsx(c.Fragment,{children:x.map((k,D)=>{const R=Eo(k,p),I=C.has(R),z=`${ht(e)}-${D}-${R}`;return c.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:[c.jsx($s,{id:z,checked:I,onCheckedChange:L=>T(k,L===!0),disabled:O,"aria-describedby":$t(e,!!o)}),c.jsx(Cn,{htmlFor:z,className:"text-sm cursor-pointer flex-1 truncate",children:Wk(k,f,m,g)})]},R)})})]}),x.length>0&&C.size===0&&c.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:[c.jsx(Vv,{className:"h-4 w-4 shrink-0"}),"Please select at least one item."]})]})})})})},ng=({field:e,children:t,className:r})=>{const n=e.properties,o=n?.collapsible??!1,i=n?.defaultCollapsed??!1,s=n?.columns??1,[a,d]=S.useState(i),u=()=>{o&&d(!a)},l={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 c.jsxs("div",{className:j("border rounded-lg bg-card",r),children:[c.jsxs("div",{className:j("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&&c.jsx("span",{className:"text-muted-foreground",children:a?c.jsx(au,{className:"h-4 w-4"}):c.jsx(qo,{className:"h-4 w-4"})}),c.jsx("h3",{className:"font-medium text-sm",children:e.label}),e.description&&c.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:e.description})]}),!a&&c.jsx("div",{className:j("p-4 grid gap-4",l[s]),children:t})]})};var Gk=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Kk=Gk.reduce((e,t)=>{const r=Ga(`Primitive.${t}`),n=b.forwardRef((o,i)=>{const{asChild:s,...a}=o,d=s?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(d,{...a,ref:i})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),qk="Separator",og="horizontal",Yk=["horizontal","vertical"],ig=b.forwardRef((e,t)=>{const{decorative:r,orientation:n=og,...o}=e,i=Xk(n)?n:og,a=r?{role:"none"}:{"aria-orientation":i==="vertical"?i:void 0,role:"separator"};return c.jsx(Kk.div,{"data-orientation":i,...a,...o,ref:t})});ig.displayName=qk;function Xk(e){return Yk.includes(e)}var Jk=ig;function Ec({className:e,orientation:t="horizontal",decorative:r=!0,...n}){return c.jsx(Jk,{"data-slot":"separator",decorative:r,orientation:t,className:j("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 Qk=({field:e,className:t})=>c.jsx("div",{className:j("py-2",t),children:c.jsx(Ec,{})}),Zk={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"},e_=({field:e,className:t})=>{const r=e.properties,n=r?.headingLevel??"h3",o=r?.showHorizontalLine??!0,i=Zk[n],s=n;return c.jsxs("div",{className:j("w-full min-w-0 space-y-1",t),children:[c.jsx(s,{className:j("m-0 text-foreground",i),children:e.label||"Header"}),e.description&&c.jsx("p",{className:"text-sm text-muted-foreground",children:e.description}),o&&c.jsx(Ec,{className:"w-full"})]})},t_={"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"},r_={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"},n_=({field:e,className:t})=>{const r=e.properties,n=r?.position??"top-left",o=r?.headingLevel??"h3",i=r?.showHorizontalLine??!0,s=t_[n],a=r_[o],d=o;return c.jsxs("div",{className:j("w-full min-w-0 space-y-2",t),children:[c.jsx("div",{className:j("flex w-full",s),children:c.jsx(d,{className:j("m-0 text-foreground",a),children:e.label||"Section Heading"})}),i&&c.jsx(Ec,{className:"w-full"})]})},o_=({field:e,className:t})=>{const r=e.appearance?.size||"md",n={sm:"h-4",md:"h-8",lg:"h-12"};return c.jsx("div",{className:j(n[r],t),"aria-hidden":"true"})};function sg(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 i_(e){if(Array.isArray(e))return e}function s_(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,o,i,s,a=[],d=!0,u=!1;try{if(i=(r=r.call(e)).next,t!==0)for(;!(d=(n=i.call(r)).done)&&(a.push(n.value),a.length!==t);d=!0);}catch(l){u=!0,o=l}finally{try{if(!d&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(u)throw o}}return a}}function a_(){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 l_(e,t){return i_(e)||s_(e,t)||c_(e,t)||a_()}function c_(e,t){if(e){if(typeof e=="string")return sg(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)?sg(e,t):void 0}}const ag=Object.entries,lg=Object.setPrototypeOf,d_=Object.isFrozen,u_=Object.getPrototypeOf,f_=Object.getOwnPropertyDescriptor;let lr=Object.freeze,Ir=Object.seal,No=Object.create,cg=typeof Reflect<"u"&&Reflect,Nc=cg.apply,kc=cg.construct;lr||(lr=function(t){return t}),Ir||(Ir=function(t){return t}),Nc||(Nc=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)}),kc||(kc=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 ko=zt(Array.prototype.forEach),p_=zt(Array.prototype.lastIndexOf),dg=zt(Array.prototype.pop),_o=zt(Array.prototype.push),m_=zt(Array.prototype.splice),cr=Array.isArray,hi=zt(String.prototype.toLowerCase),_c=zt(String.prototype.toString),ug=zt(String.prototype.match),To=zt(String.prototype.replace),fg=zt(String.prototype.indexOf),h_=zt(String.prototype.trim),g_=zt(Number.prototype.toString),y_=zt(Boolean.prototype.toString),pg=typeof BigInt>"u"?null:zt(BigInt.prototype.toString),mg=typeof Symbol>"u"?null:zt(Symbol.prototype.toString),Pt=zt(Object.prototype.hasOwnProperty),gi=zt(Object.prototype.toString),tr=zt(RegExp.prototype.test),ta=b_(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 Nc(e,t,n)}}function b_(e){return function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return kc(e,r)}}function it(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:hi;if(lg&&lg(e,null),!cr(t))return e;let n=t.length;for(;n--;){let o=t[n];if(typeof o=="string"){const i=r(o);i!==o&&(d_(t)||(t[n]=i),o=i)}e[o]=!0}return e}function v_(e){for(let t=0;t<e.length;t++)Pt(e,t)||(e[t]=null);return e}function gr(e){const t=No(null);for(const n of ag(e)){var r=l_(n,2);const o=r[0],i=r[1];Pt(e,o)&&(cr(i)?t[o]=v_(i):i&&typeof i=="object"&&i.constructor===Object?t[o]=gr(i):t[o]=i)}return t}function w_(e){switch(typeof e){case"string":return e;case"number":return g_(e);case"boolean":return y_(e);case"bigint":return pg?pg(e):"0";case"symbol":return mg?mg(e):"Symbol()";case"undefined":return gi(e);case"function":case"object":{if(e===null)return gi(e);const t=e,r=Jn(t,"toString");if(typeof r=="function"){const n=r(t);return typeof n=="string"?n:gi(n)}return gi(e)}default:return gi(e)}}function Jn(e,t){for(;e!==null;){const n=f_(e,t);if(n){if(n.get)return zt(n.get);if(typeof n.value=="function")return zt(n.value)}e=u_(e)}function r(){return null}return r}function S_(e){try{return tr(e,""),!0}catch{return!1}}const hg=lr(["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"]),Tc=lr(["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"]),Fc=lr(["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"]),x_=lr(["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"]),Pc=lr(["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"]),A_=lr(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),gg=lr(["#text"]),yg=lr(["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"]),Oc=lr(["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"]),bg=lr(["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"]),ra=lr(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),C_=Ir(/{{[\w\W]*|^[\w\W]*}}/g),E_=Ir(/<%[\w\W]*|^[\w\W]*%>/g),N_=Ir(/\${[\w\W]*/g),k_=Ir(/^data-[\-\w.\u00B7-\uFFFF]+$/),__=Ir(/^aria-[\-\w]+$/),vg=Ir(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),T_=Ir(/^(?:\w+script|data):/i),F_=Ir(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),P_=Ir(/^html$/i),O_=Ir(/^[a-z][.\w]*(-[.\w]+)+$/i),Fo={element:1,text:3,progressingInstruction:7,comment:8,document:9},I_=function(){return typeof window>"u"?null:window},M_=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}},wg=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Sg(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:I_();const t=Ee=>Sg(Ee);if(t.version="3.4.5",t.removed=[],!e||!e.document||e.document.nodeType!==Fo.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,d=e.Element,u=e.NodeFilter,l=e.NamedNodeMap,f=l===void 0?e.NamedNodeMap||e.MozNamedAttrMap:l,p=e.HTMLFormElement,m=e.DOMParser,g=e.trustedTypes,h=d.prototype,y=Jn(h,"cloneNode"),w=Jn(h,"remove"),v=Jn(h,"nextSibling"),A=Jn(h,"childNodes"),C=Jn(h,"parentNode"),F=a&&a.prototype?Jn(a.prototype,"nodeType"):null;if(typeof s=="function"){const Ee=r.createElement("template");Ee.content&&Ee.content.ownerDocument&&(r=Ee.content.ownerDocument)}let E,T="";const N=r,x=N.implementation,O=N.createNodeIterator,k=N.createDocumentFragment,D=N.getElementsByTagName,R=n.importNode;let I=wg();t.isSupported=typeof ag=="function"&&typeof C=="function"&&x&&x.createHTMLDocument!==void 0;const z=C_,L=E_,B=N_,M=k_,V=__,$=T_,ie=F_,H=O_;let K=vg,X=null;const le=it({},[...hg,...Tc,...Fc,...Pc,...gg]);let re=null;const q=it({},[...yg,...Oc,...bg,...ra]);let ne=Object.seal(No(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}})),Te=null,ee=null;const te=Object.seal(No(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let he=!0,ce=!0,Xe=!1,ge=!0,Se=!1,ae=!0,ve=!1,He=!1,dt=!1,Ge=!1,Rt=!1,Je=!1,Y=!0,je=!1;const gt="user-content-";let Ie=!0,oe=!1,pe={},We=null;const Tt=it({},["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 ze=null;const Fe=it({},["audio","video","img","source","image","track"]);let Ke=null;const nt=it({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),yt="http://www.w3.org/1998/Math/MathML",Yt="http://www.w3.org/2000/svg",xt="http://www.w3.org/1999/xhtml";let Pe=xt,ft=!1,et=null;const At=it({},[yt,Yt,xt],_c);let ur=it({},["mi","mo","mn","ms","mtext"]),on=it({},["annotation-xml"]);const Nr=it({},["title","style","font","a","script"]);let rr=null;const Kr=["application/xhtml+xml","text/html"],hn="text/html";let Ft=null,br=null;const Lo=r.createElement("form"),sn=function(P){return P instanceof RegExp||P instanceof Function},Lr=function(){let P=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(br&&br===P)return;(!P||typeof P!="object")&&(P={}),P=gr(P),rr=Kr.indexOf(P.PARSER_MEDIA_TYPE)===-1?hn:P.PARSER_MEDIA_TYPE,Ft=rr==="application/xhtml+xml"?_c:hi,X=Pt(P,"ALLOWED_TAGS")&&cr(P.ALLOWED_TAGS)?it({},P.ALLOWED_TAGS,Ft):le,re=Pt(P,"ALLOWED_ATTR")&&cr(P.ALLOWED_ATTR)?it({},P.ALLOWED_ATTR,Ft):q,et=Pt(P,"ALLOWED_NAMESPACES")&&cr(P.ALLOWED_NAMESPACES)?it({},P.ALLOWED_NAMESPACES,_c):At,Ke=Pt(P,"ADD_URI_SAFE_ATTR")&&cr(P.ADD_URI_SAFE_ATTR)?it(gr(nt),P.ADD_URI_SAFE_ATTR,Ft):nt,ze=Pt(P,"ADD_DATA_URI_TAGS")&&cr(P.ADD_DATA_URI_TAGS)?it(gr(Fe),P.ADD_DATA_URI_TAGS,Ft):Fe,We=Pt(P,"FORBID_CONTENTS")&&cr(P.FORBID_CONTENTS)?it({},P.FORBID_CONTENTS,Ft):Tt,Te=Pt(P,"FORBID_TAGS")&&cr(P.FORBID_TAGS)?it({},P.FORBID_TAGS,Ft):gr({}),ee=Pt(P,"FORBID_ATTR")&&cr(P.FORBID_ATTR)?it({},P.FORBID_ATTR,Ft):gr({}),pe=Pt(P,"USE_PROFILES")?P.USE_PROFILES&&typeof P.USE_PROFILES=="object"?gr(P.USE_PROFILES):P.USE_PROFILES:!1,he=P.ALLOW_ARIA_ATTR!==!1,ce=P.ALLOW_DATA_ATTR!==!1,Xe=P.ALLOW_UNKNOWN_PROTOCOLS||!1,ge=P.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Se=P.SAFE_FOR_TEMPLATES||!1,ae=P.SAFE_FOR_XML!==!1,ve=P.WHOLE_DOCUMENT||!1,Ge=P.RETURN_DOM||!1,Rt=P.RETURN_DOM_FRAGMENT||!1,Je=P.RETURN_TRUSTED_TYPE||!1,dt=P.FORCE_BODY||!1,Y=P.SANITIZE_DOM!==!1,je=P.SANITIZE_NAMED_PROPS||!1,Ie=P.KEEP_CONTENT!==!1,oe=P.IN_PLACE||!1,K=S_(P.ALLOWED_URI_REGEXP)?P.ALLOWED_URI_REGEXP:vg,Pe=typeof P.NAMESPACE=="string"?P.NAMESPACE:xt,ur=Pt(P,"MATHML_TEXT_INTEGRATION_POINTS")&&P.MATHML_TEXT_INTEGRATION_POINTS&&typeof P.MATHML_TEXT_INTEGRATION_POINTS=="object"?gr(P.MATHML_TEXT_INTEGRATION_POINTS):it({},["mi","mo","mn","ms","mtext"]),on=Pt(P,"HTML_INTEGRATION_POINTS")&&P.HTML_INTEGRATION_POINTS&&typeof P.HTML_INTEGRATION_POINTS=="object"?gr(P.HTML_INTEGRATION_POINTS):it({},["annotation-xml"]);const J=Pt(P,"CUSTOM_ELEMENT_HANDLING")&&P.CUSTOM_ELEMENT_HANDLING&&typeof P.CUSTOM_ELEMENT_HANDLING=="object"?gr(P.CUSTOM_ELEMENT_HANDLING):No(null);if(ne=No(null),Pt(J,"tagNameCheck")&&sn(J.tagNameCheck)&&(ne.tagNameCheck=J.tagNameCheck),Pt(J,"attributeNameCheck")&&sn(J.attributeNameCheck)&&(ne.attributeNameCheck=J.attributeNameCheck),Pt(J,"allowCustomizedBuiltInElements")&&typeof J.allowCustomizedBuiltInElements=="boolean"&&(ne.allowCustomizedBuiltInElements=J.allowCustomizedBuiltInElements),Se&&(ce=!1),Rt&&(Ge=!0),pe&&(X=it({},gg),re=No(null),pe.html===!0&&(it(X,hg),it(re,yg)),pe.svg===!0&&(it(X,Tc),it(re,Oc),it(re,ra)),pe.svgFilters===!0&&(it(X,Fc),it(re,Oc),it(re,ra)),pe.mathMl===!0&&(it(X,Pc),it(re,bg),it(re,ra))),te.tagCheck=null,te.attributeCheck=null,Pt(P,"ADD_TAGS")&&(typeof P.ADD_TAGS=="function"?te.tagCheck=P.ADD_TAGS:cr(P.ADD_TAGS)&&(X===le&&(X=gr(X)),it(X,P.ADD_TAGS,Ft))),Pt(P,"ADD_ATTR")&&(typeof P.ADD_ATTR=="function"?te.attributeCheck=P.ADD_ATTR:cr(P.ADD_ATTR)&&(re===q&&(re=gr(re)),it(re,P.ADD_ATTR,Ft))),Pt(P,"ADD_URI_SAFE_ATTR")&&cr(P.ADD_URI_SAFE_ATTR)&&it(Ke,P.ADD_URI_SAFE_ATTR,Ft),Pt(P,"FORBID_CONTENTS")&&cr(P.FORBID_CONTENTS)&&(We===Tt&&(We=gr(We)),it(We,P.FORBID_CONTENTS,Ft)),Pt(P,"ADD_FORBID_CONTENTS")&&cr(P.ADD_FORBID_CONTENTS)&&(We===Tt&&(We=gr(We)),it(We,P.ADD_FORBID_CONTENTS,Ft)),Ie&&(X["#text"]=!0),ve&&it(X,["html","head","body"]),X.table&&(it(X,["tbody"]),delete Te.tbody),P.TRUSTED_TYPES_POLICY){if(typeof P.TRUSTED_TYPES_POLICY.createHTML!="function")throw ta('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof P.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ta('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');E=P.TRUSTED_TYPES_POLICY,T=E.createHTML("")}else E===void 0&&(E=M_(g,o)),E!==null&&typeof T=="string"&&(T=E.createHTML(""));lr&&lr(P),br=P},Xt=it({},[...Tc,...Fc,...x_]),vr=it({},[...Pc,...A_]),Ot=function(P){let J=C(P);(!J||!J.tagName)&&(J={namespaceURI:Pe,tagName:"template"});const ye=hi(P.tagName),st=hi(J.tagName);return et[P.namespaceURI]?P.namespaceURI===Yt?J.namespaceURI===xt?ye==="svg":J.namespaceURI===yt?ye==="svg"&&(st==="annotation-xml"||ur[st]):!!Xt[ye]:P.namespaceURI===yt?J.namespaceURI===xt?ye==="math":J.namespaceURI===Yt?ye==="math"&&on[st]:!!vr[ye]:P.namespaceURI===xt?J.namespaceURI===Yt&&!on[st]||J.namespaceURI===yt&&!ur[st]?!1:!vr[ye]&&(Nr[ye]||!Xt[ye]):!!(rr==="application/xhtml+xml"&&et[P.namespaceURI]):!1},Jt=function(P){_o(t.removed,{element:P});try{C(P).removeChild(P)}catch{w(P)}},Et=function(P,J){try{_o(t.removed,{attribute:J.getAttributeNode(P),from:J})}catch{_o(t.removed,{attribute:null,from:J})}if(J.removeAttribute(P),P==="is")if(Ge||Rt)try{Jt(J)}catch{}else try{J.setAttribute(P,"")}catch{}},an=function(P){let J=null,ye=null;if(dt)P="<remove></remove>"+P;else{const wt=ug(P,/^[\r\n\t ]+/);ye=wt&&wt[0]}rr==="application/xhtml+xml"&&Pe===xt&&(P='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+P+"</body></html>");const st=E?E.createHTML(P):P;if(Pe===xt)try{J=new m().parseFromString(st,rr)}catch{}if(!J||!J.documentElement){J=x.createDocument(Pe,"template",null);try{J.documentElement.innerHTML=ft?T:st}catch{}}const kt=J.body||J.documentElement;return P&&ye&&kt.insertBefore(r.createTextNode(ye),kt.childNodes[0]||null),Pe===xt?D.call(J,ve?"html":"body")[0]:ve?J.documentElement:kt},Qt=function(P){return O.call(P.ownerDocument||P,P,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},wr=function(P){P.normalize();const J=O.call(P.ownerDocument||P,P,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null);let ye=J.nextNode();for(;ye;){let st=ye.data;ko([z,L,B],kt=>{st=To(st,kt," ")}),ye.data=st,ye=J.nextNode()}},fr=function(P){return P instanceof p&&(typeof P.nodeName!="string"||typeof P.textContent!="string"||typeof P.removeChild!="function"||!(P.attributes instanceof f)||typeof P.removeAttribute!="function"||typeof P.setAttribute!="function"||typeof P.namespaceURI!="string"||typeof P.insertBefore!="function"||typeof P.hasChildNodes!="function")},Sr=function(P){if(!F||typeof P!="object"||P===null)return!1;try{return typeof F(P)=="number"}catch{return!1}};function Gt(Ee,P,J){ko(Ee,ye=>{ye.call(t,P,J,br)})}const nr=function(P){let J=null;if(Gt(I.beforeSanitizeElements,P,null),fr(P))return Jt(P),!0;const ye=Ft(P.nodeName);if(Gt(I.uponSanitizeElement,P,{tagName:ye,allowedTags:X}),ae&&P.hasChildNodes()&&!Sr(P.firstElementChild)&&tr(/<[/\w!]/g,P.innerHTML)&&tr(/<[/\w!]/g,P.textContent)||ae&&P.namespaceURI===xt&&ye==="style"&&Sr(P.firstElementChild)||P.nodeType===Fo.progressingInstruction||ae&&P.nodeType===Fo.comment&&tr(/<[/\w]/g,P.data))return Jt(P),!0;if(Te[ye]||!(te.tagCheck instanceof Function&&te.tagCheck(ye))&&!X[ye]){if(!Te[ye]&&ca(ye)&&(ne.tagNameCheck instanceof RegExp&&tr(ne.tagNameCheck,ye)||ne.tagNameCheck instanceof Function&&ne.tagNameCheck(ye)))return!1;if(Ie&&!We[ye]){const st=C(P)||P.parentNode,kt=A(P)||P.childNodes;if(kt&&st){const wt=kt.length;for(let It=wt-1;It>=0;--It){const Br=y(kt[It],!0);st.insertBefore(Br,v(P))}}}return Jt(P),!0}return P instanceof d&&!Ot(P)||(ye==="noscript"||ye==="noembed"||ye==="noframes")&&tr(/<\/no(script|embed|frames)/i,P.innerHTML)?(Jt(P),!0):(Se&&P.nodeType===Fo.text&&(J=P.textContent,ko([z,L,B],st=>{J=To(J,st," ")}),P.textContent!==J&&(_o(t.removed,{element:P.cloneNode()}),P.textContent=J)),Gt(I.afterSanitizeElements,P,null),!1)},Dr=function(P,J,ye){if(ee[J]||Y&&(J==="id"||J==="name")&&(ye in r||ye in Lo))return!1;const st=re[J]||te.attributeCheck instanceof Function&&te.attributeCheck(J,P);if(!(ce&&!ee[J]&&tr(M,J))){if(!(he&&tr(V,J))){if(!st||ee[J]){if(!(ca(P)&&(ne.tagNameCheck instanceof RegExp&&tr(ne.tagNameCheck,P)||ne.tagNameCheck instanceof Function&&ne.tagNameCheck(P))&&(ne.attributeNameCheck instanceof RegExp&&tr(ne.attributeNameCheck,J)||ne.attributeNameCheck instanceof Function&&ne.attributeNameCheck(J,P))||J==="is"&&ne.allowCustomizedBuiltInElements&&(ne.tagNameCheck instanceof RegExp&&tr(ne.tagNameCheck,ye)||ne.tagNameCheck instanceof Function&&ne.tagNameCheck(ye))))return!1}else if(!Ke[J]){if(!tr(K,To(ye,ie,""))){if(!((J==="src"||J==="xlink:href"||J==="href")&&P!=="script"&&fg(ye,"data:")===0&&ze[P])){if(!(Xe&&!tr($,To(ye,ie,"")))){if(ye)return!1}}}}}}return!0},la=it({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),ca=function(P){return!la[hi(P)]&&tr(H,P)},da=function(P){Gt(I.beforeSanitizeAttributes,P,null);const J=P.attributes;if(!J||fr(P))return;const ye={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:re,forceKeepAttr:void 0};let st=J.length;for(;st--;){const kt=J[st],wt=kt.name,It=kt.namespaceURI,Br=kt.value,sr=Ft(wt),Do=Br;let Mt=wt==="value"?Do:h_(Do);if(ye.attrName=sr,ye.attrValue=Mt,ye.keepAttr=!0,ye.forceKeepAttr=void 0,Gt(I.uponSanitizeAttribute,P,ye),Mt=ye.attrValue,je&&(sr==="id"||sr==="name")&&fg(Mt,gt)!==0&&(Et(wt,P),Mt=gt+Mt),ae&&tr(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Mt)){Et(wt,P);continue}if(sr==="attributename"&&ug(Mt,"href")){Et(wt,P);continue}if(ye.forceKeepAttr)continue;if(!ye.keepAttr){Et(wt,P);continue}if(!ge&&tr(/\/>/i,Mt)){Et(wt,P);continue}Se&&ko([z,L,B],tt=>{Mt=To(Mt,tt," ")});const ua=Ft(P.nodeName);if(!Dr(ua,sr,Mt)){Et(wt,P);continue}if(E&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!It)switch(g.getAttributeType(ua,sr)){case"TrustedHTML":{Mt=E.createHTML(Mt);break}case"TrustedScriptURL":{Mt=E.createScriptURL(Mt);break}}if(Mt!==Do)try{It?P.setAttributeNS(It,wt,Mt):P.setAttribute(wt,Mt),fr(P)?Jt(P):dg(t.removed)}catch{Et(wt,P)}}Gt(I.afterSanitizeAttributes,P,null)},Ei=function(P){let J=null;const ye=Qt(P);for(Gt(I.beforeSanitizeShadowDOM,P,null);J=ye.nextNode();)Gt(I.uponSanitizeShadowNode,J,null),nr(J),da(J),J.content instanceof i&&Ei(J.content);Gt(I.afterSanitizeShadowDOM,P,null)},kr=function(P){if(P.nodeType===Fo.element&&P.shadowRoot instanceof i){const st=P.shadowRoot;kr(st),Ei(st)}const J=P.childNodes;if(!J)return;const ye=[];ko(J,st=>{_o(ye,st)});for(const st of ye)kr(st)};return t.sanitize=function(Ee){let P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},J=null,ye=null,st=null,kt=null;if(ft=!Ee,ft&&(Ee="<!-->"),typeof Ee!="string"&&!Sr(Ee)&&(Ee=w_(Ee),typeof Ee!="string"))throw ta("dirty is not a string, aborting");if(!t.isSupported)return Ee;if(He||Lr(P),t.removed=[],typeof Ee=="string"&&(oe=!1),oe){const Br=Ee.nodeName;if(typeof Br=="string"){const sr=Ft(Br);if(!X[sr]||Te[sr])throw ta("root node is forbidden and cannot be sanitized in-place")}kr(Ee)}else if(Sr(Ee))J=an("<!---->"),ye=J.ownerDocument.importNode(Ee,!0),ye.nodeType===Fo.element&&ye.nodeName==="BODY"||ye.nodeName==="HTML"?J=ye:J.appendChild(ye),kr(ye);else{if(!Ge&&!Se&&!ve&&Ee.indexOf("<")===-1)return E&&Je?E.createHTML(Ee):Ee;if(J=an(Ee),!J)return Ge?null:Je?T:""}J&&dt&&Jt(J.firstChild);const wt=Qt(oe?Ee:J);for(;st=wt.nextNode();)nr(st),da(st),st.content instanceof i&&Ei(st.content);if(oe)return Se&&wr(Ee),Ee;if(Ge){if(Se&&wr(J),Rt)for(kt=k.call(J.ownerDocument);J.firstChild;)kt.appendChild(J.firstChild);else kt=J;return(re.shadowroot||re.shadowrootmode)&&(kt=R.call(n,kt,!0)),kt}let It=ve?J.outerHTML:J.innerHTML;return ve&&X["!doctype"]&&J.ownerDocument&&J.ownerDocument.doctype&&J.ownerDocument.doctype.name&&tr(P_,J.ownerDocument.doctype.name)&&(It="<!DOCTYPE "+J.ownerDocument.doctype.name+`>
|
|
52
|
+
`+It),Se&&ko([z,L,B],Br=>{It=To(It,Br," ")}),E&&Je?E.createHTML(It):It},t.setConfig=function(){let Ee=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Lr(Ee),He=!0},t.clearConfig=function(){br=null,He=!1},t.isValidAttribute=function(Ee,P,J){br||Lr({});const ye=Ft(Ee),st=Ft(P);return Dr(ye,st,J)},t.addHook=function(Ee,P){typeof P=="function"&&_o(I[Ee],P)},t.removeHook=function(Ee,P){if(P!==void 0){const J=p_(I[Ee],P);return J===-1?void 0:m_(I[Ee],J,1)[0]}return dg(I[Ee])},t.removeHooks=function(Ee){I[Ee]=[]},t.removeAllHooks=function(){I=wg()},t}var L_=Sg();const D_=["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"],B_=["href","target","rel","src","alt","title","class","style","colspan","rowspan"];function $_(e){return e?L_.sanitize(e,{ALLOWED_TAGS:[...D_],ALLOWED_ATTR:[...B_],ALLOW_DATA_ATTR:!1}):""}function j_(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=Qe(t,i);return s==null?r?"":n:String(s)}):e}function z_(e){return e&&e.replace(/\{api:[^}]*\}/gi,"").replace(/\{labelapi:[^}]*\}/gi,"").replace(/\{resp:[^}]*\}/gi,"").replace(/\{(?:ctx:|@)\w+\}/gi,"").replace(/\{documentId\}/gi,"").replace(/\{(\w+)\}/g,"")}const xg={sm:"text-sm",md:"text-base",lg:"text-lg"},Ag={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"},Cg={normal:"font-normal",medium:"font-medium",bold:"font-bold"},na={left:"text-left",center:"text-center",right:"text-right",justify:"text-justify"};function Qn(e){return e.properties??{}}function U_(e){const t=Qn(e);return t.textContent!==void 0?t.textContent:e.label??""}function V_(e){return Qn(e).textContent===void 0||e.appearance?.hideLabel?!1:!!e.label?.trim()}function H_(e){return e?.contentLayout==="paragraph"?"paragraph":"single"}function Ic(e,t={}){const{formValues:r={},urlParams:n={},submissionContext:o,buttonResponses:i,prepopulateResponse:s,labelApiResponse:a}=t,d=Rr(e,r,n,o,i,s),u=j_(d,a,!0);return z_(u)}const W_=/\{api:[^}]+\}/,R_=/\{labelapi:[^}]+\}/;function Mc(e){return W_.test(e)}function Lc(e){return R_.test(e)}function G_(e){const t=e.captionTemplate??"",r=e.descriptionTemplate??"",n=Mc(e.bodyTemplate)||Mc(t)||Mc(r),o=Lc(e.bodyTemplate)||Lc(t)||Lc(r);return!!(n&&e.prepopulateLoading||o&&e.labelApiConfigPresent&&(e.labelApiLoading||e.labelApiResponse===void 0&&e.labelApiError==null))}function Eg(e,t){const r=t??Qn(e),n=r.variant??"body",o=e.appearance?.size??"md",i=xg[o]??xg.md,s=r.fontWeight??"medium";return n!=="body"?j("m-0 text-foreground",Ag[n]??Ag.h3,r.fontWeight&&Cg[r.fontWeight],r.italic&&"italic",r.underline&&"underline",r.textAlign&&na[r.textAlign]):j("m-0 text-foreground",i,Cg[s],r.italic&&"italic",r.underline&&"underline",r.textAlign&&na[r.textAlign])}function K_(e,t){const r=(t??Qn(e)).variant??"body";return r==="body"?"p":r}function Dc(e){const t=[];let r=0,n="";const o=()=>{n&&(t.push({type:"text",value:n}),n="")},i=(s,a,d)=>{if(!e.startsWith(s,r))return!1;const u=e.indexOf(a,r+s.length);if(u===-1)return!1;o();const l=e.slice(r+s.length,u);return t.push({type:d,children:Dc(l)}),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 q_(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Ng(e){return e.map(t=>{if(t.type==="text")return q_(t.value);const r=Ng(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 Y_(e){return e?Ng(Dc(e)):""}function X_(e,t){return e?t==="markdown-lite"?Y_(e):e:""}function kg(e,t){return e.map((r,n)=>{const o=`${t}-${n}`;if(r.type==="text")return r.value?S.createElement(S.Fragment,{key:o},r.value):null;const i=kg(r.children,o);return r.type==="bold"?S.createElement("strong",{key:o,className:"font-bold"},i):r.type==="italic"?S.createElement("em",{key:o,className:"italic"},i):S.createElement("u",{key:o,className:"underline"},i)})}function _g(e,t){if(!e)return null;if(t!=="markdown-lite")return e;const r=Dc(e);return r.length===1&&r[0]?.type==="text"?r[0].value:kg(r,"tl")}const J_="text-label-html prose prose-sm max-w-none [&_p]:m-0 [&_p+p]:mt-2 [&_ul]:my-1 [&_ol]:my-1";function Tg(e,t){if(!e)return null;const{field:r,asDescription:n=!1}=t,o=t.textProps??Qn(r),i=t.contentLayout??H_(o),s=o.inlineFormat??"none";if(i==="paragraph"){const d=$_(X_(e,s));if(!d)return null;const u=n?j("m-0 text-sm",o.descriptionMuted!==!1?"text-muted-foreground":"text-foreground",o.textAlign&&na[o.textAlign]):j(Eg(r,o),J_);return S.createElement("div",{className:u,dangerouslySetInnerHTML:{__html:d}})}if(n)return S.createElement("p",{className:j("mt-0.5 text-sm",o.descriptionMuted!==!1?"text-muted-foreground":"text-foreground",o.textAlign&&na[o.textAlign])},_g(e,s));const a=K_(r,o);return S.createElement(a,{className:Eg(r,o)},_g(e,s))}function Q_(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 Z_(e,t={}){const{formValues:r={},urlParams:n={},submissionContext:o}=t,i=f=>Rr(f,r,n,o),s=(e.labelApiMethod??"GET").toUpperCase();let a=Wr(i(e.labelApiEndpoint));const d=e.labelApiQueryParams??[];if(d.length){const f=new URLSearchParams;d.forEach(({key:m,value:g})=>{m.trim()&&f.append(m,i(g))});const p=f.toString();p&&(a=`${a}${a.includes("?")?"&":"?"}${p}`)}const u={"Content-Type":"application/json"};(e.labelApiHeaders??[]).forEach(({key:f,value:p})=>{f.trim()&&(u[f]=i(p))});let l;s==="POST"&&(e.labelApiBodyFields??[]).length&&(l={},e.labelApiBodyFields.forEach(({key:f,value:p})=>{f.trim()&&(l[f]=i(p))}));try{return s==="POST"?(await pn.post(a,l??{},{headers:Object.keys(u).length?u:void 0})).data:(await pn.get(a,{headers:Object.keys(u).length?u:void 0})).data}catch(f){const p=f,m=p.response?.status,g=typeof p.response?.data=="string"?p.response.data:p.message??"Request failed";throw new Error(m?`HTTP ${m}: ${g}`:String(g))}}const eT=({field:e,className:t,formValues:r,urlParams:n,submissionContext:o,buttonResponses:i,prepopulateResponse:s,prepopulateLoading:a=!1})=>{const d=Qn(e),u=S.useMemo(()=>Q_(Qn(e)),[e.properties]),[l,f]=S.useState(void 0),[p,m]=S.useState(!1),[g,h]=S.useState(null),y=S.useMemo(()=>u?JSON.stringify({endpoint:u.labelApiEndpoint,method:u.labelApiMethod,query:u.labelApiQueryParams,headers:u.labelApiHeaders,body:u.labelApiBodyFields}):"",[u]),w=S.useCallback(async()=>{if(!u){f(void 0),h(null),m(!1);return}m(!0),h(null);try{const D=await Z_(u,{formValues:r??{},urlParams:n??{},submissionContext:o});f(D)}catch(D){f(void 0),h(D instanceof Error?D.message:"Failed to load label API")}finally{m(!1)}},[u,r,n,o]);S.useEffect(()=>{y&&w()},[y,w]);const v=d.textAlign==="center"?"items-center":d.textAlign==="right"?"items-end":d.textAlign==="justify"?"items-stretch":"items-start",A=U_(e),C=V_(e),F=C&&e.label?e.label:"",E=e.description??"",T=G_({bodyTemplate:A,captionTemplate:F,descriptionTemplate:E,prepopulateLoading:a,labelApiConfigPresent:u!=null,labelApiLoading:p,labelApiResponse:l,labelApiError:g}),N={formValues:r??{},urlParams:n??{},submissionContext:o,buttonResponses:i,prepopulateResponse:s,labelApiResponse:l},x=A?Ic(A,N):"",O=C&&e.label?Ic(e.label,N):"",k=E?Ic(E,N):"";return c.jsx("div",{className:j("w-full min-w-0 h-full min-h-[95px] flex flex-col justify-center py-0.5",v,t),children:T?c.jsx("p",{className:"text-sm text-muted-foreground m-0",children:"Loading…"}):c.jsxs(c.Fragment,{children:[g&&u?c.jsx("p",{className:"text-[10px] text-destructive mb-0.5",title:g,children:"Label API failed"}):null,O?c.jsx("div",{className:"text-sm font-medium text-foreground mb-1 w-full",children:O}):null,x?Tg(x,{field:e,textProps:d}):null,k?Tg(k,{field:e,textProps:d,asDescription:!0}):null]})})},Bc=({legend:e,children:t,className:r,collapsible:n=!1,defaultCollapsed:o=!1,headerActions:i,onCollapsedChange:s})=>{const[a,d]=S.useState(o),u=S.useId(),l=f=>{f.stopPropagation(),n&&d(p=>{const m=!p;return s?.(m),m})};return c.jsxs("fieldset",{className:j("min-w-0 rounded-lg border bg-card p-4",r),"data-form-renderer":"config-section-border",children:[n?c.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2 border-b border-border pb-2",children:[c.jsxs("button",{type:"button",className:j("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:l,children:[c.jsx("span",{className:"shrink-0 text-muted-foreground","aria-hidden":!0,children:a?c.jsx(au,{className:"h-4 w-4"}):c.jsx(qo,{className:"h-4 w-4"})}),c.jsx("span",{className:"truncate",children:e})]}),i!=null?c.jsx("div",{className:"shrink-0",children:i}):null]}):c.jsx("legend",{className:"px-1 text-sm font-medium text-foreground",children:e}),!a&&c.jsxs("div",{id:u,className:"space-y-3",children:[!n&&i!=null?c.jsx("div",{className:"flex justify-end",children:i}):null,t]})]})};function Fg(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 $c(e){const t=Fg(e),r=e.properties;return!!(t?.apiEndpoint&&(t?.valueSource==="api"||r?.valueSource==="api"))}function Pg({field:e,formValues:t={},submissionContext:r,value:n,onChange:o,clearWhenBlocked:i=!0}){const s=e.properties,a=Fg(e),d=$c(e),[u,l]=S.useState(!1),[f,p]=S.useState(null),m=S.useRef(null),g=S.useRef(n);g.current=n;const h=S.useMemo(()=>{const F=a?.apiEndpoint||s?.apiEndpoint||"",E=a?.apiQueryParams||s?.apiQueryParams;return oo(F,E)},[a?.apiEndpoint,s?.apiEndpoint,a?.apiQueryParams,s?.apiQueryParams]),y=S.useMemo(()=>{const F=new Set;for(const T of s?.dependentFields??a?.dependentFields??[])typeof T=="string"&&T.trim()&&F.add(T.trim());const E=a?.apiClientFilter?.matchField?.trim()||s?.apiClientFilter?.matchField?.trim();return E&&F.add(E),[...F]},[s?.dependentFields,a?.dependentFields,a?.apiClientFilter?.matchField,s?.apiClientFilter?.matchField]),w=S.useMemo(()=>{const F=new Set([...h,...y]);if(F.size===0)return null;const E={};return F.forEach(T=>{E[T]=t[T]}),JSON.stringify(E)},[h,y,t]),v=S.useMemo(()=>JSON.stringify(r||{}),[r]),A=S.useMemo(()=>{const F=new Set;e.name?.trim()&&F.add(e.name.trim());const E=e.key;return typeof E=="string"&&E.trim()&&F.add(E.trim()),[...F]},[e.name,e.key]),C=e.type==="number"?null:"";return S.useEffect(()=>{const F=a?.apiEndpoint;if(!d||!F)return;let E=!1;const T=x=>{if(E)return;const O=g.current;if(x==null||x.trim()===""){i&&O!==C&&O!==void 0&&(m.current=null,o(C));return}if(e.type==="number"){const k=Number(x),D=Number.isFinite(k)?k:null;O!==D&&m.current!==x&&(m.current=x,o(D));return}String(O??"")!==x&&m.current!==x&&(m.current=x,o(x))};return(async()=>{l(!0),p(null);try{const x=a?.apiMethod||s?.apiMethod||"GET",O=a?.apiRealtime||s?.apiRealtime,k=a?.apiQueryParams||s?.apiQueryParams||{},D=Ui({apiEndpoint:F,apiMethod:x,apiQueryParams:k,formValues:t,submissionContext:r,apiRealtime:O,additionalRequiredFieldNames:y,excludeFormFieldNames:A});if(D.blocked){E||(l(!1),i&&T(null));return}const R={"Content-Type":"application/json"},I=a?.apiKey||s?.apiKey;I&&(R["X-CSCAPI-KEY"]=I);const z=e.apidata,L=a?.apiAuth??s?.apiAuth??z?.apiAuth??Os(a?.apiHeaders??s?.apiHeaders??z?.apiHeaders)??{type:"none"},B=Ms(L,{formValues:t,submissionContext:r,apiRealtime:O});Object.assign(R,B);const M=a?.apiHeaders??s?.apiHeaders??z?.apiHeaders,V=a?.apiBodyFields??s?.apiBodyFields??z?.apiBodyFields,$=Pn(Ps(M),{formValues:t,submissionContext:r,apiRealtime:O});Object.assign(R,$);const ie=Pn(V,{formValues:t,submissionContext:r,apiRealtime:O}),H={method:x.toLowerCase(),url:Wr(D.url),headers:R};(D.postBodyBase!=null||Object.keys(ie).length>0)&&(H.data={...D.postBodyBase??{},...ie});const K=await St(H),X=a?.apiLabelField||s?.apiLabelField,le=a?.apiValueField||s?.apiValueField,re=a?.apiClientFilter||s?.apiClientFilter;let q=rC(K.data,le,X);if(re?.filterField&&re?.matchField&&q!=null){const ne=t[re.matchField];if(ne==null)q=null;else{const Te=ci(K.data,X,le),ee=Array.isArray(K.data)?K.data:K.data?.data?.data&&Array.isArray(K.data.data.data)?K.data.data.data:K.data?.data&&Array.isArray(K.data.data)?K.data.data:[],te=Te.filter(he=>{const ce=ee.find(ge=>String(jt(ge,le||"code"))===String(he.value));if(!ce)return!1;const Xe=jt(ce,re.filterField);return String(Xe)===String(ne)});q=te.length>0?te[0].value:null}}E||T(q)}catch(x){if(E)return;let O="Failed to load value";const k=x;if(k.response){const D=k.response.data;if(k.response.status===404)O="API endpoint not found.";else if(k.response.status===401)O="Authentication failed.";else if(typeof D=="string")O=D;else if(D&&typeof D=="object"){const R=D;O=R.error||R.message||R.detail||O}}else k.message&&(O=String(k.message));p(O)}finally{E||l(!1)}})(),()=>{E=!0}},[d,a?.apiEndpoint,a?.apiMethod,a?.apiValueField,a?.apiLabelField,s?.apiEndpoint,s?.apiMethod,s?.apiValueField,s?.apiLabelField,w,y,A,v,e.type,i,C]),{isLoading:u,error:f}}const tT=({field:e,value:t,onChange:r,formValues:n,submissionContext:o,disabled:i,readOnly:s,...a})=>{const{isLoading:d}=Pg({field:e,formValues:n,submissionContext:o,value:t,onChange:r});return c.jsx(Wi,{field:e,value:t||"",onChange:r,disabled:i||d,readOnly:s||d,...a})},rT=({field:e,value:t,onChange:r,formValues:n,submissionContext:o,disabled:i,readOnly:s,...a})=>{const{isLoading:d}=Pg({field:e,formValues:n,submissionContext:o,value:t,onChange:r});return c.jsx(Ka,{field:e,value:t??null,onChange:r,disabled:i||d,readOnly:s||d,...a})},mn=({field:e,value:t,error:r,onChange:n,onBlur:o,disabled:i,readOnly:s,isRequired:a,className:d,formValues:u={},submissionContext:l,onSubmit:f,onReset:p,onCancel:m,isSubmitting:g,bffSubmitApi:h,onBffSubmitResult:y,extraSubmitPayload:w,buttonResponses:v,onButtonApiResponse:A,onValidateForm:C,getValidationErrors:F,allFields:E,onSubmittingChange:T,onAddMore:N,scopedFormValues:x,scopedFieldNameMap:O,excludedOptionValues:k,prepopulateMappedFieldNames:D,fieldValueKey:R,hideTableRowControls:I=!1,urlParams:z={},prepopulateResponse:L=null,prepopulateLoading:B=!1,formSections:M,submitPayload:V})=>{switch(e.type){case"divider":return c.jsx(Qk,{field:e,className:d});case"header":return c.jsx(e_,{field:e,className:d});case"sectionHeading":return c.jsx(n_,{field:e,className:d});case"spacer":return c.jsx(o_,{field:e,className:d});case"textLabel":return c.jsx(eT,{field:e,className:d,formValues:u,urlParams:z,submissionContext:l,buttonResponses:v,prepopulateResponse:L??void 0,prepopulateLoading:B});case"status":return c.jsx(Hk,{field:e,value:t??null,error:r,disabled:i,isRequired:a,className:d,formValues:u,submissionContext:l,extraSubmitPayload:w,prepopulateResponse:L})}switch(e.type){case"text":case"password":case"url":return e.type==="text"&&$c(e)?c.jsx(tT,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:d,formValues:u,submissionContext:l}):c.jsx(Wi,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:d});case"number":return $c(e)?c.jsx(rT,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:d,formValues:u,submissionContext:l}):c.jsx(Ka,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:d});case"email":return c.jsx(pu,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:d});case"phone":case"aadhaar":return c.jsx(mu,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:d});case"textarea":case"richtext":return c.jsx(hu,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:d});case"select":{const $=R??e.name??e.key??e.id,ie=!!($&&D?.has($));return c.jsx(zp,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:d,formValues:u,submissionContext:l,excludedOptionValues:k,isPrepopulateTarget:ie})}case"multiselect":{const $=Array.isArray(t)?t:t!=null&&t!==""?[String(t)]:[];return c.jsx(Pm,{field:e,value:$,onChange:ie=>n(ie),onBlur:o,error:r,disabled:i,isRequired:a,className:d,formValues:u,submissionContext:l,excludedOptionValues:k})}case"asyncsearch":return c.jsx(lm,{field:e,value:t,onChange:$=>n($),onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:d,formValues:u,submissionContext:l});case"checkbox":case"terms":return c.jsx(Om,{field:e,value:t||!1,onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:d});case"toggle":return c.jsx(AE,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:d});case"radio":case"checkboxgroup":return c.jsx(oh,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:d,excludedOptionValues:k});case"selectablelist":{const $=Array.isArray(t)?t:[];return console.log("[SelectableList] FieldRenderer: passing to SelectableListField",{fieldName:e.name,value:$,valueLength:$.length,submissionContextKeys:l?Object.keys(l):[]}),c.jsx(Rk,{field:e,value:$,onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:d,submissionContext:l})}case"date":case"time":case"datetime":case"daterange":return c.jsx(ih,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:d});case"file":return c.jsx(qE,{field:e,value:t,onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:d,buttonResponses:v});case"camera":return c.jsx(NN,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:d});case"photoChoice":return c.jsx(kN,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:i,isRequired:a,className:d,buttonResponses:v});case"signature":return c.jsx(bk,{field:e,value:t||null,onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:d});case"rating":return c.jsx(XN,{field:e,value:t||0,onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:d});case"slider":return c.jsx(yk,{field:e,value:t||0,onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:d});case"table":return c.jsx(vk,{field:e,value:t||[],onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:d,hideRowControls:I,formValues:u,submissionContext:l});case"billingGrid":return c.jsx(Vk,{field:e,value:t||{rows:[]},onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:d,formValues:u,submissionContext:l});case"button":return c.jsx(zN,{field:e,value:t,onChange:n,onBlur:o,error:r,disabled:i,readOnly:s,isRequired:a,className:d,onSubmit:f,onReset:p,onCancel:m,isSubmitting:g,formValues:u,submissionContext:l,buttonResponses:v,onButtonApiResponse:A,bffSubmitApi:h,onBffSubmitResult:y,extraSubmitPayload:w,onValidateForm:C,getValidationErrors:F,allFields:E,onSubmittingChange:T,scopedFormValues:x,scopedFieldNameMap:O,prepopulateResponse:L,formSections:M,submitPayload:V});case"editButton":return c.jsx(UN,{field:e,disabled:i,readOnly:s,isRequired:a,className:d,buttonResponses:v,onButtonApiResponse:A});case"addmore":return c.jsx(VN,{field:e,error:r,disabled:i,readOnly:s,isRequired:a,className:d,onAddMore:()=>N?.(e)});case"customizeSections":return c.jsx(YN,{field:e,error:r,disabled:i,readOnly:s,isRequired:a,className:d});default:return c.jsx("div",{className:"p-3 border rounded-md bg-muted/50",children:c.jsxs("p",{className:"text-sm text-muted-foreground",children:["Unsupported field type: ",e.type]})})}},nT=({steps:e,currentStep:t,completedSteps:r,onStepClick:n,className:o})=>c.jsx("div",{className:j("mb-8",o),children:c.jsx("nav",{"aria-label":"Progress",children:c.jsx("ol",{className:"flex items-center",children:e.map((i,s)=>{const a=r.has(s),d=t===s,u=n&&(a||s===t+1||s<=t);return c.jsxs("li",{className:j("relative",s!==e.length-1&&"pr-8 sm:pr-20 flex-1"),children:[s!==e.length-1&&c.jsx("div",{className:j("absolute top-4 left-8 -right-8 sm:left-12 sm:-right-12 h-0.5",a?"bg-primary":"bg-border"),"aria-hidden":"true"}),c.jsx("button",{type:"button",onClick:()=>u&&n?.(s),disabled:!u,className:j("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",d&&!a&&"border-2 border-primary text-primary",!a&&!d&&"border-2 border-border text-muted-foreground",u&&"cursor-pointer hover:bg-primary/10",!u&&"cursor-default"),"aria-current":d?"step":void 0,children:a?c.jsx(Gi,{className:"h-4 w-4"}):c.jsx("span",{children:s+1})}),c.jsxs("div",{className:"mt-2",children:[c.jsx("span",{className:j("text-sm font-medium",d&&"text-primary",!d&&!a&&"text-muted-foreground"),children:i.name}),i.description&&c.jsx("p",{className:"text-xs text-muted-foreground hidden sm:block",children:i.description})]})]},i.id)})})})});function yi(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 Og(e){return Array.isArray(e)?e.map(yi):[]}function oT(e){if(!e.moduleId)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 t;typeof e.moduleId=="object"&&e.moduleId._id?t=yi(e.moduleId):t=e.moduleId;const r=e.isDefault??!1;if(!r&&!e.tenantId)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:r,moduleId:t,tenantId:e.tenantId||void 0,featureId:e.featureId,config:e.config??void 0}}class iT{basePath="/api/form-builder/forms";async getForRendering(t,r){if(!In())throw new Error("Client ID is required");const o=r!==void 0?`${this.basePath}/${t}/render?version=${r}`:`${this.basePath}/${t}/render`,i=await pn.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,d=s.form||s;if(!d.moduleId&&!s.form?.moduleId)throw new Error(`Form response missing required field: moduleId. Form ID: ${t}. Please ensure the backend returns moduleId in the form response.`);if(!(d.isDefault??s.form?.isDefault??!1)&&!d.tenantId&&!s.form?.tenantId)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&&!d.moduleId&&(d.moduleId=s.form.moduleId),s.form?.tenantId&&!d.tenantId&&(d.tenantId=s.form.tenantId),s.form?.isDefault!==void 0&&d.isDefault===void 0&&(d.isDefault=s.form.isDefault);const l=oT(d);s.form?.moduleId&&(typeof s.form.moduleId=="object"&&s.form.moduleId._id?l.moduleId=yi(s.form.moduleId):typeof s.form.moduleId=="string"&&(l.moduleId=s.form.moduleId));const f=Og(s.fields||[]),p=s.layout?yi(s.layout):null,m=Og(s.rules||[]),g=s.module?yi(s.module):void 0,h=s.clientMapping||s.clientOverrides;return{form:l,fields:f,layout:p,rules:m,module:g,clientMapping:h,clientOverrides:h,BFF_submit_api:a||void 0}}}const sT=new iT;function Ln({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=c.jsxs("div",{className:"text-center",children:[c.jsx("div",{className:j("animate-spin rounded-full border-b-2 border-blue-600 mx-auto mb-4",o[t],e)}),r&&c.jsx("p",{className:"text-gray-600",children:r})]});return n?c.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}const aT={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."},lT=300;function cT(){return{...aT}}function dT(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 uT(e){const t=cT();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:LN(r.sections),submitPayload:MN(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 bi(e,t,r,n){const o=t.map(l=>{let f=[],p={};try{l.options&&(f=JSON.parse(l.options)),l.metadata&&(p=JSON.parse(l.metadata))}catch{}const m=Yd(l);m&&Object.assign(p,m),f.length>0&&(p.options=f);const g=[];if(l.validationRequired&&g.push({type:"required",message:"This field is required"}),l.validationMinLength!==null&&l.validationMinLength!==void 0&&g.push({type:"minLength",value:l.validationMinLength,message:`Minimum length is ${l.validationMinLength}`}),l.validationMaxLength!==null&&l.validationMaxLength!==void 0&&g.push({type:"maxLength",value:l.validationMaxLength,message:`Maximum length is ${l.validationMaxLength}`}),l.validationPattern&&g.push({type:"pattern",value:l.validationPattern,message:"Invalid format"}),l.validationRules&&typeof l.validationRules=="object"){const H=l.validationRules;if(H.required===!0&&!g.some(K=>K.type==="required")&&g.push({type:"required",message:"This field is required"}),H.allowLetters!==void 0&&g.push({type:"allowLetters",value:H.allowLetters}),H.allowNumbers!==void 0&&g.push({type:"allowNumbers",value:H.allowNumbers}),H.allowSpecialChars!==void 0&&g.push({type:"allowSpecialChars",value:H.allowSpecialChars}),H.minLetters!==void 0&&typeof H.minLetters=="number"&&g.push({type:"minLetters",value:H.minLetters}),H.maxLetters!==void 0&&typeof H.maxLetters=="number"&&g.push({type:"maxLetters",value:H.maxLetters}),H.minNumbers!==void 0&&typeof H.minNumbers=="number"&&g.push({type:"minNumbers",value:H.minNumbers}),H.maxNumbers!==void 0&&typeof H.maxNumbers=="number"&&g.push({type:"maxNumbers",value:H.maxNumbers}),H.minSpecialChars!==void 0&&typeof H.minSpecialChars=="number"&&g.push({type:"minSpecialChars",value:H.minSpecialChars}),H.maxSpecialChars!==void 0&&typeof H.maxSpecialChars=="number"&&g.push({type:"maxSpecialChars",value:H.maxSpecialChars}),H.fileSize!==void 0&&typeof H.fileSize=="number"){const K=H.fileSize/1048576;g.push({type:"fileSize",value:H.fileSize,message:`File size must be less than ${K.toFixed(2)} MB`})}if(H.fileType!==void 0){const K=Array.isArray(H.fileType)?H.fileType:typeof H.fileType=="string"?H.fileType.split(",").map(X=>X.trim()).filter(Boolean):[];K.length>0&&g.push({type:"fileType",value:K,message:"File type is not allowed"})}}const h=[],y=new Set;n.filter(H=>{const K=typeof H.targetFieldId=="object"?H.targetFieldId.id||H.targetFieldId._id:H.targetFieldId;return!!(K===l.id||K===l._id||K&&l.fieldKey&&K===l.fieldKey)}).forEach(H=>{try{const K=JSON.parse(H.conditionExpression);!K.id&&H.id&&(K.id=H.id);const X=typeof H.targetFieldId=="object"?H.targetFieldId?.id||H.targetFieldId?._id:H.targetFieldId;K.action&&(!K.then||!Array.isArray(K.then)||K.then.length===0)&&(K.then=[{action:K.action,...X&&{target:X}}]),(!K.then||!Array.isArray(K.then)||K.then.length===0)&&H.action&&(K.then=[{action:H.action,...X&&{target:X}}]),K.then&&Array.isArray(K.then)&&X&&(K.then=K.then.map(re=>!re.target&&X?{...re,target:X}:re));const le=H.conditionExpression||JSON.stringify(K);if(y.has(le))return;y.add(le),h.push(K)}catch{}});const v=l.disabled===!0||p?.disabled===!0||!1;let A=l.readOnly===!0||p?.readOnly===!0||!1;const C=l.hidden===!0||p?.hidden===!0||!1;(p?.valueSource==="calculated"||p?.formula)&&(A=!0);const{disabled:F,readOnly:E,hidden:T,...N}=p,x={};N.hideLabel!==void 0&&(x.hideLabel=N.hideLabel),N.labelPosition!==void 0&&(x.labelPlacement=N.labelPosition),N.size!==void 0&&(x.size=N.size),N.customClass!==void 0&&(x.className=N.customClass);const{labelPosition:O,size:k,customClass:D,visibility:R,...I}=N,z=Object.keys(I).length>0?I:void 0,L=Object.keys(x).length>0?x:void 0,B=l.visibility??p?.visibility??R;let M=dT(B);if(B&&!M){const H=B;(H.visibleToUserType!=null||H.visibleToUserRole!=null||Array.isArray(H.visibleToUserTypes)&&H.visibleToUserTypes.length>0||Array.isArray(H.visibleToUserRoles)&&H.visibleToUserRoles.length>0||Array.isArray(H.visibleToUserIds)&&H.visibleToUserIds.length>0||Array.isArray(H.hiddenFromUserIds)&&H.hiddenFromUserIds.length>0)&&(M={visibleToUserType:H.visibleToUserType??(Array.isArray(H.visibleToUserTypes)?H.visibleToUserTypes[0]:void 0),visibleToUserRole:H.visibleToUserRole??(Array.isArray(H.visibleToUserRoles)?H.visibleToUserRoles[0]:void 0),visibleToUserIds:H.visibleToUserIds,hiddenFromUserIds:H.hiddenFromUserIds})}const V=p?.columnName,ie=!!l.parentFieldId&&typeof V=="string"?V:l.fieldKey;return{id:l.id,type:l.fieldType,name:ie,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:L,validation:g.length>0?g:void 0,conditions:h.length>0?h:void 0,properties:z,visibility:M&&(M.visibleToUserType!=null||M.visibleToUserRole!=null||Array.isArray(M.visibleToUserIds)&&M.visibleToUserIds.length>0||Array.isArray(M.hiddenFromUserIds)&&M.hiddenFromUserIds.length>0)?M:void 0,disabled:v,readOnly:A,hidden:C}});o.forEach((l,f)=>{if(l.visibility){const p=t[f];console.log("[backendToFormSchema] field with visibility",{fieldKey:p?.fieldKey??l.name,name:l.name,type:l.type,parentFieldId:p?.parentFieldId,visibility:l.visibility})}});const i=t;for(let l=0;l<o.length;l++){const f=i[l]?.parentFieldId;if(f){const p=o.find(g=>g.id===f||g.type==="table"&&g.name===f||g.type==="table"&&i[l].fieldKey?.startsWith?.(g.name+"_column_")),m=o[l];if(p&&p.type==="table"&&m){const g=p.properties||{};Array.isArray(g.columns)||(g.columns=[]),g.columns.push(m),p.properties=g}}}const s=o.filter((l,f)=>!i[f]?.parentFieldId);for(const l of s)if(l.type==="table"&&l.properties&&Array.isArray(l.properties.columns)){const f=l.properties.columns;for(const p of f){const m=p.properties?.columnName;typeof m=="string"&&(p.name=m)}f.sort((p,m)=>(p.position?.order??0)-(m.position?.order??0)||(p.position?.column??0)-(m.position?.column??0))}let a;const d=e.config;if(console.log("[Prepopulate] backendToFormSchema config",{formId:e.id,hasRawConfig:d!=null,rawConfigType:typeof d,rawConfigPreview:d!=null?typeof d=="string"?d.slice(0,300):JSON.stringify(d).slice(0,300):null}),d!=null)try{const l=typeof d=="string"?JSON.parse(d):d;l&&typeof l=="object"?a=uT(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=Ti(r);return u&&(a={...a,grid:u}),{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,moduleId:typeof e.moduleId=="string"?e.moduleId:e.moduleId?.id,tenantId:e.tenantId,featureId:e.featureId,isDefault:e.isDefault}}const fT=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 vi(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 oa(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 jc(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 wi(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,zo(o)),n=Math.max(n,_d(o,t));return{rowSpan:r,columnSpan:n}}function Ig(e){const t=jc(e);for(const r of t){const n=vi(r.position);if(n)return n}return t.length>=2?"row":"stack"}function Mg(e){return jc(e).slice(0,fT)}function pT(e,t){const r=new Map;for(const n of e){if(!t(n)||typeof n.position?.order!="number")continue;const o=oa(n),i=r.get(o)??[];i.push(n),r.set(o,i)}return Array.from(r.values()).map(n=>Mg(n))}function Lg(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 d=oa(a),u=i.get(d)??[];u.push(a),i.set(d,u)}const s=[...i.values()][0]??[];return Mg(s)}function mT(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:d}=wi(r,n),u=e===i&&t===s-1,l=e>=i&&e<i+a,f=t>=s-1&&t<s-1+d;return l&&f&&!u}function hT(e,t,r){const n=new Set(r??[]);for(const o of e){const i=o[0]?.position?.order??0,{rowSpan:s}=wi(o,t);for(let a=i;a<i+s;a++)n.add(a)}return n}function gT(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 yT(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 yr(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(!yr(e))return e;const t={};for(const[r,n]of Object.entries(e))t[r]=Io(n);return t}function Dg(e,...t){const r={...e};for(const n of t)if(!(!n||!yr(n)))for(const[o,i]of Object.entries(n)){const s=r[o];yr(i)&&yr(s)?r[o]=Dg(s,i):r[o]=i}return r}function Zn(e){return yr(e)?e:{}}function Si(e){if(e==null)return{};if(typeof e=="string"){const t=e.trim();if(!t)return{};try{const r=JSON.parse(t);return yr(r)?Io(r):{}}catch{return{}}}return yr(e)?Io(e):{}}function Bg(e){const t=e.apidata;return yr(t)&&Object.keys(t).length>0}function bT(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||Bg(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 vT(e,t){const r=e.appearance,n=yr(r)&&Object.keys(r).length>0?Io(r):{},o=Zn(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 wT(e,t){const r=Zn(e.position),n=Si(e.metadata),o=Zn(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,d=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:d},l=r.cellGroupId??o.cellGroupId,f=Oo(r,{cellSlotIndex:e.cellSlotIndex??o.cellSlotIndex,stackSlot:n.stackSlot??o.stackSlot}),p=vi(r)??vi(o)??(n.stackDirection==="horizontal"||o.stackDirection==="horizontal"?"row":n.stackDirection==="vertical"||o.stackDirection==="vertical"?"stack":void 0);return typeof l=="string"&&(u.cellGroupId=l),typeof f=="number"&&(u.cellSlot=f),(p==="row"||p==="stack")&&(u.sharedCellLayout=p),u}function ST(e,t){const r=e,n=Si(r.metadata),o=Zn(r.apidata),i=Zn(r.properties),s=Dg({},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),d=(r.type!=null&&String(r.type).trim()!==""?r.type:void 0)??(typeof r.fieldType=="string"?r.fieldType:void 0),u=vT(r,n),l=wT(r,t),f={...r};return f.properties=s,a!==void 0&&(f.name=a),d!==void 0&&(f.type=d),u!==void 0?f.appearance=u:(!yr(r.appearance)||Object.keys(r.appearance).length===0)&&delete f.appearance,f.position=l,yr(f.appearance)&&delete f.appearance.heightPercent,f}function xT(e,t){if(!e||typeof e!="object")return!0;const r=e,n=Si(r.metadata),o=Object.keys(n).length===0&&!(typeof r.metadata=="string"&&r.metadata.trim()!==""),i=!Bg(r);if(bT(r)||!o||!i)return!1;const s=r.position;return!(!(yr(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")||yr(n.appearance)||$g.some(u=>n[u]!==void 0&&(r.appearance==null||yr(r.appearance)&&r.appearance[u]===void 0))||AT(r))}function AT(e){const t=Zn(e.position),r=Zn(e.layout),n=Si(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 ia(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(xT(o))return o;const s=ST(o,i);return s!==o&&(r=!0),s});return r?{...e,fields:n}:e}function CT(e){return ia(e)}const ET=new Set(["PENDING_PAYMENT","PAYMENT_PENDING","AWAITING_PAYMENT","PAID","PAYMENT_COMPLETED","PAYMENT_FAILED","REFUNDED","AUTHORIZED","CAPTURED","PARTIALLY_PAID"].map(e=>e.toUpperCase()));function zc(e){return typeof e=="string"&&e.trim()!==""}function Uc(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"||zc(t.amount)||typeof t.total_amount=="number"||zc(t.total_amount)||zc(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"&&ET.has(r.trim().toUpperCase()))}function NT(e){const t=Qe(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 kT(e,t){const r=NT(e);if(!r)return;const n=Qe(e,"data"),o=n!=null&&typeof n=="object"&&!Array.isArray(n)?n:void 0;if(t?.treatFirstItemIdAsPaymentId===!0||Uc(r.item)||o!=null&&Uc(o))return r.id}function _T(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 TT(e){return _T(e).some(t=>t.toLowerCase().includes("payment"))}function FT(e){const t=e.properties,r=e.metadata;return!!(t?.mergeSuccessDataIdAsPaymentId||r?.mergeSuccessDataIdAsPaymentId)}function PT(e,t){if(t?.type!=="button"||!Ro(e))return;const r=Qe(e,"data.id");if(r==null||String(r).trim()==="")return;const n=Qe(e,"data");if(FT(t)||n!=null&&typeof n=="object"&&!Array.isArray(n)&&Uc(n)||TT(t))return r}const OT=new Set(["section","group","columns","divider","header","sectionHeading","spacer","addmore","textLabel","customizeSections"]);function IT(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 MT(e,t){const r=e.properties,n=Array.isArray(r?.linkedFieldNames)?r.linkedFieldNames:[],o=IT(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 jg(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 LT(e,t){return jg(e,t).find(r=>r.heading?.enabled)}function zg(e,t){const r=e.template??"";return(e.mode??"increment")==="fixed"?r:r.replace(/\{n\}/g,String(t+1))}function Ug(e,t,r,n){const o=MT(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||OT.has(s.type)?!1:i.has(a)})}function DT(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 Vc(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 BT(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 d=Vc(a).map(u=>r(u)).filter(Boolean);i.push({section:s,fieldNames:d})}return i}function xi(e,t=0){return e.heading?.enabled?zg(e.heading,t):e.name}function Vg(e,t,r){if(e.type!=="sectionHeading")return!1;const n=t.heading;return!n?.enabled||!n.headingFieldName?!1:r(e)===n.headingFieldName}function $T(e,t){const r=typeof e.position?.order=="number"?e.position.order:0,n=(e.position?.column??1)-1,o=zo(e),i=_d(e,t);return{row:r,col:n,rowEnd:r+o-1,colEnd:n+i-1}}function Hc(e,t){let r=1/0,n=-1/0,o=1/0,i=-1/0;for(const s of e){const{row:a,col:d,rowEnd:u,colEnd:l}=$T(s,t);r=Math.min(r,a),n=Math.max(n,u),o=Math.min(o,d),i=Math.max(i,l)}return Number.isFinite(r)?{minRow:r,maxRow:n,minCol:o,maxCol:i,rowSpan:n-r+1,colSpan:i-o+1}:null}function jT(e,t,r,n){const o=e.map(l=>t.find(f=>n(f)===l)).filter(l=>!!l&&typeof l.position?.order=="number");if(o.length===0)return null;const i=Hc(o,r);if(!i)return null;const s=o.filter(l=>l.type!=="sectionHeading"),a=s.length>0?s:o,d=Math.min(...a.map(l=>l.position?.order??0)),u=Math.max(1,...a.map(l=>(l.position?.order??d)-d+zo(l)));return{minRow:i.minRow,maxRow:i.maxRow,minCol:i.minCol,maxCol:i.maxCol,blockHeight:u}}function zT(e,t){return e.maxRow+1+t*e.blockHeight}function UT(e,t,r,n){const o=new Map;for(const a of t){const d=r(a);d&&o.set(d,a)}const i=new Map,s=new Set;for(const a of e){const d=a.fieldNames.map(v=>o.get(v)).filter(v=>!!v);if(d.length===0)continue;const u=d.filter(v=>!Vg(v,a.section,r)),l=Hc(d,n);if(!l)continue;const{minRow:f,minCol:p,rowSpan:m,colSpan:g}=l,h=`${f}-${p}`;if(i.has(h))continue;const y=new Set;let w=!1;for(let v=f;v<=f+m-1;v++){for(let A=p;A<=p+g-1;A++){const C=`${v}-${A}`;if(s.has(C)){w=!0;break}y.add(C)}if(w)break}if(!w){for(const v of y)s.add(v);i.set(h,{anchorRow:f,anchorCol:p,rowSpan:m,colSpan:g,run:a,legend:xi(a.section,0),renderFields:u.length>0?u:d})}}return{anchorsByOrigin:i,coveredCells:s}}function VT(e,t,r,n,o,i,s){const a=new Set(s),d=new Map;for(const u of e){const l=Hg(u.linkedFields.map(p=>i(p)).filter(Boolean),t),f=l?.section;f?.fieldNames?.length?f.fieldNames:u.templateFieldNames,u.blockIds.forEach((p,m)=>{const g=r.filter(T=>T.id.endsWith(`__${p}`));if(g.length===0||!l)return;const h=Hc(g,o);if(!h)return;const{minRow:y,minCol:w,rowSpan:v,colSpan:A}=h,C=`${y}-${w}`;for(let T=y;T<=y+v-1;T++)for(let N=w;N<=w+A-1;N++)a.add(`${T}-${N}`);const F=l,E=xi(f,m+1);d.set(C,{anchorRow:y,anchorCol:w,rowSpan:v,colSpan:A,run:F,legend:E,renderFields:Vc(g),addMoreMeta:{addMoreFieldName:u.addMoreFieldName,blockId:p,blockIndex:m}})})}return{anchorsByOrigin:d,coveredCells:a}}function HT(e,t,r,n){const o=`${e}-${t}`;return r.has(o)?!n.get(o):!1}function WT(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 RT(e,t,r,n){return!(!n||r.run.section.collapsible!==!0||e===r.anchorRow&&t===r.anchorCol)}function GT(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 KT(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 qT(e,t){return new Map([...e,...t])}function YT(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),d=a?n.get(a):void 0;if(!d){o.push({kind:"field",field:s}),i+=1;continue}const u=[],l=new Set(d.fieldNames);for(;i<e.length;){const p=r(e[i]);if(!p||!l.has(p))break;const m=e[i];Vg(m,d.section,r)||u.push(m),i+=1}if(u.length===0)continue;const f=o[o.length-1];f?.kind==="border"&&f.run.section.id===d.section.id?f.fields.push(...u):o.push({kind:"border",run:d,fields:u})}return o}function Hg(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 XT=2*6e4,Wg=50;class JT{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<=Wg)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-Wg)).forEach(([n])=>this.map.delete(n))}}function QT(e){return(e??"").trim()||"default"}function Rg(e){const t=QT(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 Gg=new JT(XT);function Kg(e){const t=Rg(e),r=Gg.get(t);return r?{value:r.value,isStale:r.isStale}:null}function qg(e,t){const r=Rg(e);Gg.set(r,t)}function Yg(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 Wc=({schema:e,formId:t,initialValues:r,onSubmit:n,onChange:o,onValidationError:i,onClose:s,mode:a="fill",className:d,children:u,gridLayout:l,unstyled:f=!1,submissionContext:p,onWorkflowSubmitResult:m,initialExtraSubmitPayload:g,onExtraSubmitPayloadChange:h,workflowStepId:y,viewerContext:w,getViewerContext:v,hideTableRowControls:A=!1,themeVars:C,dark:F=!1,omitRootWrapper:E=!1})=>{const T=Yn(_=>_.viewerContext),N=S.useMemo(()=>{if(w!==void 0)return w;const _=v?.();return _!==void 0?_:T},[w,v,T]),[x,O]=S.useState(e||null),[k,D]=S.useState(!!t&&!e),[R,I]=S.useState(null),z=e?.BFF_submit_api??R,[L,B]=S.useState(!1),[M,V]=S.useState({}),[$,ie]=S.useState({}),[H,K]=S.useState({}),[X,le]=S.useState({}),[re,q]=S.useState({}),[ne,Te]=S.useState(null),ee=Ea.useParams(),te=Nt(_=>_.setValues),he=Nt(_=>_.setSubmitting),ce=Nt(_=>_.formDisabled),Xe=Nt(_=>_.visibleFields),ge=Nt(_=>_.requiredFields),Se=Nt(_=>_.updateVisibility),ae=Nt(_=>_.updateRequired),ve=Nt(_=>_.setFieldError),He=S.useRef(!1),dt=S.useRef(void 0),Ge=S.useMemo(()=>{if(!e)return null;const _=e;if(_.form&&Array.isArray(_.form.fields))try{return bi(_.form,_.form.fields,_.form.layout||null,_.form.rules||[])}catch{return e}if(Array.isArray(_.fields)&&_.fields.some(U=>typeof U.metadata=="string"&&U.metadata.startsWith("{")||U.fieldType&&!U.type))try{const U={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 bi(U,_.fields,_.layout||null,_.rules||[])}catch{return e}return e},[e]);S.useEffect(()=>{if(e){const _=e;_.BFF_submit_api&&I(_.BFF_submit_api)}},[e]);const Rt=S.useMemo(()=>{const _=Ge||x,W=_?ia(_):null;if(!W)return null;const U=W.layout,Z=W.rules,Q=W.clientMapping,de=(Array.isArray(W.fields)?W.fields:[]).map(De=>{let Ue={...De};if(De.validationRules&&typeof De.validationRules=="object"&&!De.validation){const ue=De.validationRules,Oe=[];ue.required===!0&&Oe.push({type:"required",message:"This field is required"}),ue.minLength!==void 0&&typeof ue.minLength=="number"&&Oe.push({type:"minLength",value:ue.minLength,message:`Minimum length is ${ue.minLength}`}),ue.maxLength!==void 0&&typeof ue.maxLength=="number"&&Oe.push({type:"maxLength",value:ue.maxLength,message:`Maximum length is ${ue.maxLength}`}),ue.pattern&&typeof ue.pattern=="string"&&Oe.push({type:"pattern",value:ue.pattern,message:"Invalid format"}),ue.allowLetters!==void 0&&Oe.push({type:"allowLetters",value:ue.allowLetters}),ue.allowNumbers!==void 0&&Oe.push({type:"allowNumbers",value:ue.allowNumbers}),ue.allowSpecialChars!==void 0&&Oe.push({type:"allowSpecialChars",value:ue.allowSpecialChars}),Oe.length>0&&(Ue={...Ue,validation:Oe})}const xe=De.required===!0||De.isRequired===!0,Ae=Array.isArray(Ue.validation)&&Ue.validation.some(ue=>ue.type==="required");if(xe&&!Ae){const ue={type:"required",message:"This field is required"},Oe=Array.isArray(Ue.validation)?Ue.validation:[];Ue={...Ue,validation:[...Oe,ue]}}if(De.apidata&&typeof De.apidata=="object"){const ue=De.apidata,Oe=Ue.properties||{},we=(Ue.type||De.fieldType)==="status";if(!Oe.apiEndpoint&&ue.apiEndpoint){const ut={...Oe,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,apiBodyFields:ue.apiBodyFields,apiAuth:ue.apiAuth,valueSource:ue.valueSource||(ue.apiEndpoint?"api":void 0),optionsSource:ue.optionsSource||(ue.apiEndpoint?"api":void 0),dependentFields:ue.dependentFields,apiResponsePath:ue.apiResponsePath};we&&(ut.source=Oe.source??"api",Oe.statuses!==void 0&&(ut.statuses=Oe.statuses),Oe.dataPath!==void 0&&(ut.dataPath=Oe.dataPath),Oe.showStatusText!==void 0&&(ut.showStatusText=Oe.showStatusText),Oe.statusTextPath!==void 0&&(ut.statusTextPath=Oe.statusTextPath),Oe.showCurrentIndicator!==void 0&&(ut.showCurrentIndicator=Oe.showCurrentIndicator)),Ue={...Ue,properties:ut}}}const Ve=["select","multiselect","radio","checkboxgroup"],ot=Ue.type||De.fieldType;if(Ve.includes(ot)){const ue=De.options,Oe=Ue.properties?.options,we=Array.isArray(Oe)&&Oe.length>0;if(Array.isArray(ue)&&ue.length>0&&!we){const ut=Ue.properties||{};Ue={...Ue,properties:{...ut,options:ue}}}}return Ue}),Ce=W.config?.rules,Ne=Z&&Array.isArray(Z)?Z:Ce&&Array.isArray(Ce)?Ce:[],Be=Ne.length>0?de.map(De=>{if((De.conditions&&Array.isArray(De.conditions)?De.conditions:[]).length>0)return De;const xe=De.id??De._id,Ae=De.name||De.key,Ve=Ne.filter(Oe=>{const we=typeof Oe.targetFieldId=="object"?Oe.targetFieldId?.id??Oe.targetFieldId?._id:Oe.targetFieldId;return we?we===xe||we===Ae||we===De.fieldKey:!1});if(Ve.length===0)return De;const ot=[],ue=new Set;return Ve.forEach(Oe=>{try{const we=typeof Oe.conditionExpression=="string"?JSON.parse(Oe.conditionExpression):Oe.conditionExpression;if(!we||typeof we!="object")return;!we.id&&Oe.id&&(we.id=Oe.id);const ut=typeof Oe.targetFieldId=="object"?Oe.targetFieldId?.id??Oe.targetFieldId?._id:Oe.targetFieldId;we.action&&(!we.then||!Array.isArray(we.then)||we.then.length===0)&&(we.then=[{action:we.action,...ut&&{target:ut}}]),(!we.then||!Array.isArray(we.then)||we.then.length===0)&&Oe.action&&(we.then=[{action:Oe.action,...ut&&{target:ut}}]),we.then&&Array.isArray(we.then)&&ut&&(we.then=we.then.map(Dt=>!Dt.target&&ut?{...Dt,target:ut}:Dt));const Vt=Oe.conditionExpression??JSON.stringify(we);if(ue.has(Vt))return;ue.add(Vt),ot.push(we)}catch{}}),ot.length===0?De:{...De,conditions:ot}}):de;let lt=W.config||{submitAction:"database",layout:"default",autoSave:!0,validateOnChange:!0,showFieldErrors:"inline"};return!lt.layout&&U?typeof U=="object"&&U!==null?lt.layout="default":typeof U=="string"&&["default","card","compact"].includes(U)?lt.layout=U:lt.layout="default":lt.layout||(lt.layout="default"),Z&&!lt.rules&&(lt.rules=Z),Q&&!lt.clientMapping&&(lt.clientMapping=Q),{...W,fields:Be,config:lt}},[Ge,x]);S.useEffect(()=>{Ge&&Ge!==x&&O(Ge)},[Ge]),S.useEffect(()=>{if(t&&!e){const _=(In()??"").trim()||"default",W=Kg({scope:_,formId:t,version:"latest"});W?.value?.schema?(O(W.value.schema),W.value.bffSubmitApi&&I(W.value.bffSubmitApi),D(!1),W.isStale&&Je({background:!0})):Je({background:!1})}},[t,e]);const Je=async({background:_})=>{if(!t)return;const W=t;_||D(!0);try{const U=await sT.getForRendering(t),Z=bi(U.form,U.fields,U.layout,U.rules);if(W!==t)return;O(Z),U.BFF_submit_api&&I(U.BFF_submit_api);const Q=(In()??"").trim()||"default";qg({scope:Q,formId:W,version:"latest"},{schema:Z,bffSubmitApi:U.BFF_submit_api})}catch{}finally{_||D(!1)}};if(k)return c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx(Ln,{})});if(!Rt)return c.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Form not found"});const Y=Rt,je=S.useMemo(()=>new Set(Object.keys(Y.config?.prepopulateApi?.fieldMapping??{})),[Y.config?.prepopulateApi?.fieldMapping]),gt=S.useCallback(async _=>{const W=Y?.fields?.length?dc(_,Y.fields):_,U=_h(W,Y.config?.sections,Y.config?.submitPayload);if(n){const Z=p?{...U,...p}:U;return n(Z)}return{success:!0}},[n,p,Y?.fields,Y.config?.sections,Y.config?.submitPayload]),{values:Ie,errors:oe,touched:pe,isSubmitting:We,isValid:Tt,submitCount:ze,currentStep:Fe,totalSteps:Ke,completedSteps:nt,currentStepFields:yt,isLastStep:Yt,setFieldValue:xt,setFieldTouched:Pe,handleSubmit:ft,validateForm:et,resetForm:At,nextStep:ur,goToStep:on,shouldShowField:Nr,isFieldEnabled:rr,isFieldRequired:Kr,loadDraft:hn}=Jd({schema:Y,initialValues:r,onSubmit:gt,onChange:o,workflowStepId:y});wv({fields:Y.fields,values:Ie,buttonResponses:$,prepopulateResponse:ne,prepopulateResponseRules:Y.config?.prepopulateResponseRules});const Ft=Nt(_=>_.readOnlyFields),br=Nt(_=>_.editableFields),Lo=S.useCallback(_=>Ft.has(_),[Ft]),sn=S.useCallback(_=>br.has(_),[br]);S.useEffect(()=>{Y.config?.allowDraft&&a==="fill"&&hn()},[Y.id]),S.useEffect(()=>{dt.current=Y.id,He.current=!1,V({}),K({}),le({}),q({}),Te(null)},[Y.id]),S.useEffect(()=>{const _=Y.config?.prepopulateApi,W=!!(_?.fieldMapping&&Object.keys(_?.fieldMapping??{}).length>0),U=(Y.config?.prepopulateResponseRules?.length??0)>0;if(!_?.enabled||!_.apiEndpoint?.trim()||!W&&!U||He.current)return;He.current=!0;const Z=Y.id;dt.current=Y.id;let Q=!1;return B(!0),(async()=>{try{const de=Nt.getState().values,Ce=typeof p=="object"&&p!==null?{...p,...g||{}}:g||{},Ne=se=>Rr(se,de,ee,Ce);let Be=Wr(Ne(_.apiEndpoint));if(_.apiQueryParams?.length){const se=new URLSearchParams;_.apiQueryParams.forEach(({key:Me,value:me})=>se.append(Me,Ne(me))),Be=`${Be}${Be.includes("?")?"&":"?"}${se.toString()}`}const lt={};_.apiHeaders?.forEach(({key:se,value:Me})=>{se.trim()&&(lt[se]=Ne(Me))}),lt["Content-Type"]=lt["Content-Type"]??"application/json";let Ut;if(_.apiMethod==="POST"&&_.apiBodyFields?.length){const se={};_.apiBodyFields.forEach(({key:Me,value:me})=>{Me.trim()&&(se[Me]=Ne(me))}),Ut=JSON.stringify(se)}const De=await fetch(Be,{method:_.apiMethod,headers:lt,body:_.apiMethod==="POST"?Ut:void 0});if(!De.ok){const se=await De.text();throw new Error(se||`HTTP ${De.status}`)}const Ue=await De.json(),xe=se=>{try{return se.split("?")[0].split("/").filter(Boolean).pop()||se}catch{return se}},Ae=(se,Me)=>{if(se==null)return null;const me=typeof se=="string"?se:se instanceof Date?se.toISOString():null;if(!me)return null;const qe=typeof se=="object"&&se instanceof Date?se:new Date(me);if(Number.isNaN(qe.getTime()))return null;const pt=mt=>String(mt).padStart(2,"0");if(Me==="date")return me.length>=10&&me[4]==="-"&&me[7]==="-"?me.slice(0,10):qe.toISOString().slice(0,10);if(Me==="time")return`${pt(qe.getHours())}:${pt(qe.getMinutes())}:${pt(qe.getSeconds())}`;if(Me==="datetime"){const mt=qe.getFullYear(),rt=qe.getMonth()+1,fe=qe.getDate(),bt=qe.getHours(),Re=qe.getMinutes(),_t=qe.getSeconds();return`${mt}-${pt(rt)}-${pt(fe)}T${pt(bt)}:${pt(Re)}:${pt(_t)}`}return null},Ve=(se,Me)=>{const me=Y.fields.find(fe=>fe.name===se||fe.key===se);if(!me)return Me;if((me.type==="file"||me.type==="camera"||me.type==="photoChoice")&&typeof Me=="string"&&Me.startsWith("http"))return{url:Me,name:xe(Me)};if(me.type==="date"||me.type==="datetime"||me.type==="time"){const fe=Ae(Me,me.type);if(fe!==null)return fe}if(me.type==="multiselect")return Array.isArray(Me)?Me.map(fe=>typeof fe=="string"?fe:String(fe)):typeof Me=="string"?Me.trim()===""?[]:Me.includes(",")?Me.split(",").map(fe=>fe.trim()).filter(Boolean):[Me]:Me!=null&&Me!==""?[String(Me)]:[];if(me.type!=="radio"&&me.type!=="select")return Me;const qe=me.properties?.options??me.options;if(!Array.isArray(qe)||qe.length===0)return Me;const pt=qe.map(fe=>fe.value);if(pt.includes(Me))return Me;const mt=String(Me);if(pt.includes(mt))return mt;const rt=qe.find(fe=>fe.value==Me);return rt?rt.value:Me},ot=new Set(Y.fields.filter(se=>se.type==="table").map(se=>se.name||se.key)),ue=new Set(Y.fields.filter(se=>se.type==="billingGrid").map(se=>se.name||se.key)),Oe=se=>se.name||se.key||se.id,we={},ut=[],Vt=[],Dt=DN(_?.fieldMapping,Y.config?.sections,Y.config?.submitPayload);for(const[se,Me]of Object.entries(Dt)){if(!Me?.trim()||se.startsWith("__"))continue;const me=Qe(Ue,Me),qe=se.indexOf(".");if(qe>0&&ue.has(se.slice(0,qe))){const mt=se.slice(0,qe),rt=se.slice(qe+1),bt=Y.fields.find(Re=>(Re.name||Re.key)===mt)?.properties;if(bt?.rowSlots?.length){const Re=rt.startsWith("__block__")?rt.slice(9):rt,_t=we[mt]??Nt.getState().values[mt];Array.isArray(me)?we[mt]=Mk(bt,Re,me,_t):me!=null&&(we[mt]=Ac(bt,me,_t))}continue}if(qe>0&&ot.has(se.slice(0,qe))){const mt=se.slice(0,qe),rt=se.slice(qe+1);ut.push({tableName:mt,columnName:rt,path:Me});continue}if(ue.has(se)&&me!==void 0&&me!==null&&typeof me=="object"){const rt=Y.fields.find(fe=>(fe.name||fe.key)===se)?.properties;if(rt?.rowSlots?.length){if(Array.isArray(me)){const fe=rt.rowSlots.find(bt=>bt.kind==="dynamic");if(fe&&fe.kind==="dynamic"){const bt=fe.block.apiArrayPath??"items";we[se]=Ac(rt,{[bt]:me})}}else we[se]=Ac(rt,me);continue}}if(ot.has(se)&&Array.isArray(me)&&me.length>0&&typeof me[0]=="object"&&me[0]!==null){const rt=Y.fields.find(Re=>(Re.name||Re.key)===se)?.properties?.columns||[],fe=me.map(Yg),bt=Re=>(Re||"").toLowerCase().replace(/\s+/g,"_").trim();we[se]=fe.map(Re=>{const _t={};for(const pr of rt){const ro=pr.name??"";_t[ro]=Re[bt(ro)]??Re[ro]}return _t});continue}if(me!=null&&(we[se]=Ve(se,me)),me==null)continue;let pt=me;if(Array.isArray(me)){const mt=Y.fields.find(rt=>Oe(rt)===se);if(mt?.type==="addmore"){Vt.push({addMoreFieldName:se,array:me});continue}if(mt?.type==="multiselect"){const rt=_.multiselectArrayPropertyMap?.[se];rt&&me.length>0&&me.some(fe=>fe!=null&&typeof fe=="object")&&(pt=me.map(fe=>fe!=null&&typeof fe=="object"&&rt in fe?fe[rt]:void 0).filter(fe=>fe!=null))}}we[se]=Ve(se,pt)}const ct={},vt={},or={};for(const{addMoreFieldName:se,array:Me}of Vt){const me=Y.fields.find(bt=>Oe(bt)===se);if(!me||me.type!=="addmore")continue;const qe=Ug(me,Y.fields,Y.config?.sections,Oe);if(qe.length===0)continue;const pt=_.addMoreFieldKeyMap?.[se],mt=Me.length>0&&Me[0]!=null&&typeof Me[0]=="object"?Me[0]:null;if(mt)for(const bt of qe){const Re=Oe(bt),_t=pt&&pt[Re]||Re,pr=mt[_t];pr!=null&&(we[Re]=Ve(Re,pr))}const rt=Me.slice(1),fe=rt.map((bt,Re)=>`prepop_${se}_${Re}_${Date.now()}`);fe.length>0&&(vt[se]=fe);for(let bt=0;bt<rt.length;bt++){const Re=rt[bt];if(Re==null||typeof Re!="object")continue;const _t=Re,pr=_t.id;pr!=null&&String(pr).trim()!==""&&(or[`${se}__${fe[bt]}`]=String(pr));for(const ro of qe){const Ca=Oe(ro),WP=pt&&pt[Ca]||Ca,nd=_t[WP];if(nd==null)continue;const RP=`${Ca}__addmore__${se}__${fe[bt]}`;ct[RP]=Ve(Ca,nd)}}}Object.keys(vt).length>0&&K(se=>({...se,...vt})),Object.keys(or).length>0&&q(se=>({...se,...or}));const $r=se=>(se||"").toLowerCase().replace(/\s+/g,"_").trim(),Yr=[...new Set(ut.map(se=>se.tableName))];for(const se of Yr){if(Array.isArray(we[se]))continue;const Me=ut.find(fe=>fe.tableName===se);if(!Me?.path?.includes("."))continue;const me=Me.path.replace(/\.[^.]+$/,""),qe=Qe(Ue,me);if(!Array.isArray(qe)||qe.length===0||typeof qe[0]!="object"||qe[0]===null)continue;const mt=Y.fields.find(fe=>(fe.name||fe.key)===se)?.properties?.columns||[],rt=qe.map(Yg);we[se]=rt.map(fe=>{const bt={};for(const Re of mt){const _t=Re.name??"",pr=$r(_t),ro=fe[pr]??fe[_t];bt[_t]=ro}return bt})}const jr=(se,Me)=>{const me=Qe(Ue,se);if(Array.isArray(me))return me;if(me!=null)return[me];if(!se.includes("."))return[];const qe=se.replace(/\.[^.]+$/,""),pt=Qe(Ue,qe);return!Array.isArray(pt)||pt.length===0||typeof pt[0]!="object"||pt[0]===null?[]:pt.map(mt=>{const rt=mt[Me];if(rt!==null&&typeof rt=="object"&&!Array.isArray(rt)&&!(rt instanceof Date)){const fe=rt;return typeof fe.name=="string"&&typeof fe.code=="string"?`${fe.code} ${fe.name}`.trim():typeof fe.name=="string"?fe.name:typeof fe.code=="string"?fe.code:typeof fe.short_code=="string"?fe.short_code:fe.name??fe.code??""}return rt})};for(const{tableName:se,columnName:Me,path:me}of ut){const qe=jr(me,Me),mt=Y.fields.find(Re=>(Re.name||Re.key)===se)?.properties?.columns||[],rt=mt.find(Re=>(Re.name||"").toLowerCase()===Me.toLowerCase())?.name??Me;let fe=Array.isArray(we[se])?we[se]:[];const bt=Math.max(fe.length,qe.length);if(bt>fe.length)for(fe=[...fe];fe.length<bt;){const Re={};mt.forEach(_t=>{Re[_t.name||""]=""}),fe.push(Re)}else fe=fe.map(Re=>({...Re}));qe.forEach((Re,_t)=>{fe[_t]&&(fe[_t][rt]=Re)}),we[se]=fe}if(dt.current===Z){if(Object.keys(we).length>0||Object.keys(ct).length>0){const _t={...Nt.getState().values,...we,...ct};te(_t)}const Me=Qe(Ue,"data.user_id"),me=Qe(Ue,"data.items"),qe=Qe(Ue,"data");let pt=Array.isArray(me)&&me.length>0&&me[0]!=null&&typeof me[0]=="object"&&me[0].id?me[0].id:void 0;pt===void 0&&Array.isArray(qe)&&qe.length>0&&qe[0]!=null&&typeof qe[0]=="object"&&qe[0].id&&(pt=qe[0].id),pt===void 0&&(pt=Qe(Ue,"data.0.id"));const mt=kT(Ue,{treatFirstItemIdAsPaymentId:_?.treatFirstItemIdAsPaymentId===!0}),rt=Qe(Ue,"data.id"),fe=Qe(Ue,"data.batch_id"),bt=Qe(Ue,"data.program_id"),Re={};Me!=null&&(Re.context_user_id=Me),pt!=null&&pt!==""&&(Re.documentId=pt),rt!=null&&String(rt).trim()!==""&&(p?.id===void 0||p?.id===null)&&(Re.id=rt),fe!=null&&String(fe).trim()!==""&&((p?.admission_batch_id===void 0||p?.admission_batch_id===null)&&(Re.admission_batch_id=fe),(p?.batch_id===void 0||p?.batch_id===null)&&(Re.batch_id=fe)),bt!=null&&String(bt).trim()!==""&&(p?.program_id===void 0||p?.program_id===null)&&(Re.program_id=bt),mt!=null&&String(mt).trim()!==""&&(p?.payment_id===void 0||p?.payment_id===null)&&(Re.payment_id=mt),Object.keys(Re).length>0&&V(_t=>{const pr={..._t,...Re};return h?.(pr),pr}),Te(Ue)}}catch(de){Q||lc(de,"Prepopulate request failed.",fi)}finally{B(!1)}})(),()=>{Q=!0}},[Y.id,Y.config?.prepopulateApi?.enabled,Y.config?.prepopulateApi?.apiEndpoint,Y.config?.prepopulateApi?.apiMethod,JSON.stringify(Y.config?.prepopulateApi?.fieldMapping),Y.config?.prepopulateApi?.treatFirstItemIdAsPaymentId,p,g,ee,te,K]),S.useEffect(()=>{Object.keys(oe).length>0&&i?.(oe)},[oe,i]);const Lr=Ke>1,Xt=a==="view",vr=S.useCallback((_,W)=>Xt||!!W&&!sn(_)||Lo(_)&&!sn(_),[Xt,sn,Lo]),Ot=Y.fields.filter(_=>!_.parentId),Et=[...Lr?yt:Ot.length>0?Ot:Y.fields].filter(_=>!(!_||typeof _!="object"||!_.name&&!_.key)).sort((_,W)=>{const U=typeof _.position?.order=="number"?_.position.order:typeof _.positionOrder=="number"?_.positionOrder:Number.MAX_SAFE_INTEGER,Z=typeof W.position?.order=="number"?W.position.order:typeof W.positionOrder=="number"?W.positionOrder:Number.MAX_SAFE_INTEGER;if(U!==Z)return U-Z;const Q=typeof _.position?.column=="number"?_.position.column:1,de=typeof W.position?.column=="number"?W.position.column:1;return Q-de}),an=S.useCallback(_=>{const W=Nt.getState().errors,U=Object.keys(W).find(Z=>_.includes(Z));U&&requestAnimationFrame(()=>{document.querySelector(`[data-field-name="${U}"]`)?.scrollIntoView({behavior:"smooth",block:"center"})})},[]),Qt=async _=>{if(_?.preventDefault(),Lr&&!Yt){if(!await ur())try{const Z=Nt.getState().errors;Bt.toast.error(cc(Z,Y.fields)||"Please fix the errors before continuing."),an(Et.map(Q=>Q.name||Q.key||Q.id).filter(Boolean))}catch{Bt.toast.error("Please fix the errors before continuing.")}return}const W=await ft(_);if(W&&W.success===!1&&W.errors?.length)try{const U=Nt.getState().errors;Bt.toast.error(cc(U,Y.fields)||"Submission failed. Please check the form."),an(Et.map(Z=>Z.name||Z.key||Z.id).filter(Boolean))}catch{Bt.toast.error("Submission failed. Please check the form.")}return W},wr=S.useCallback(()=>{At(),s&&s()},[At,s]),fr=S.useCallback((_,W)=>{const U=Y.fields.find(Q=>Q.type==="button"&&(Q.name===_||Q.key===_)),Z=PT(W,U);Z!=null&&String(Z).trim()!==""&&(p?.payment_id===void 0||p?.payment_id===null)&&V(Q=>{const de={...Q,payment_id:Z};return h?.(de),de}),ie(Q=>{const de={...Q,[_]:W};return!Ro(W)||!(U?.type==="button"&&U.properties?.action==="submit")||Y.fields.filter(Be=>Be.type==="editButton").map(Be=>Be.name).forEach(Be=>delete de[Be]),de})},[Y.fields,p,h]),Sr=S.useCallback(async()=>await et(),[et]),Gt=S.useCallback(()=>Nt.getState().errors,[]),nr=S.useMemo(()=>({...g||{},...M}),[g,M]),Dr=S.useMemo(()=>({...typeof p=="object"&&p!==null?p:{},...nr}),[p,nr]),la=Y.config?.layout??Y.layout??"default",ca=["default","card","compact"].includes(la)?la:"default",da={default:"",card:"bg-card border rounded-lg shadow-sm p-6",compact:"space-y-2"},Ei=S.useMemo(()=>{if(E)return;const _=Y.config?.theme?.cssVariables;if(!(!_&&!C))return{..._??{},...C??{}}},[E,Y.config?.theme?.cssVariables,C]),kr=S.useMemo(()=>Fi({config:Y.config,layout:Y.layout},l),[Y.config,Y.layout,l]),Ee=S.useMemo(()=>kr?{...kr,verticalSpacing:kr.verticalSpacing??kr.spacing??"16px",horizontalSpacing:kr.horizontalSpacing??kr.spacing??"16px",rowHeight:kr.rowHeight??Bn}:null,[kr]),P=Ee!==null;Ee?.rows;const J=Ee?.columns??3,ye=Ee?.verticalSpacing??Ee?.spacing??"16px",st=Ee?.horizontalSpacing??Ee?.spacing??"16px",kt=Ee?.rowHeight??Bn,wt=S.useCallback(_=>{if(!N)return!0;const W=_.visibility;if(!W)return!0;const U=W.visibleToUserType??W.user_type,Z=W.visibleToUserRole??W.user_role,Q=Array.isArray(W.visibleToUserIds)?W.visibleToUserIds:Array.isArray(W.users)?W.users:[],de=Array.isArray(W.hiddenFromUserIds)?W.hiddenFromUserIds:[];if(Array.isArray(de)&&de.length>0&&N.userId!=null&&de.includes(N.userId))return!1;if(Q.length>0&&N.userId!=null&&Q.includes(N.userId))return!0;const Ce=U!=null&&U!==""&&N.userType!=null&&N.userType!==U,Ne=Z!=null&&Z!==""&&N.role!=null&&N.role!==Z,Be=Q.length>0&&(N.userId==null||!Q.includes(N.userId));return!(Ce||Ne||Be)},[N]),It=S.useMemo(()=>GN(Y.fields),[Y.fields]),Br=S.useMemo(()=>qN(Y.fields),[Y.fields]),[sr,Do]=S.useState(Br);S.useEffect(()=>{Do(Br)},[Y.id,Br]);const Mt=S.useCallback((_,W)=>{Do(U=>U[_]===W?U:{...U,[_]:W})},[]),ua=S.useMemo(()=>({visibility:sr,setSectionVisible:Mt,fieldToHeading:It,allFields:Y.fields}),[sr,Mt,It,Y.fields]),tt=S.useCallback(_=>_.name||_.key||_.id,[]),_r=_=>{if(!wt(_))return!1;const W=_.name||_.key||_.id;if(!Ph(W,_.type,sr,It))return!1;const U=_.hidden===!0;return Nr(W)||!U&&W},Iy=S.useCallback(_=>{const W=Y.fields.find(Z=>tt(Z)===_);if(W)return W.type;const U=Fh(_);return Y.fields.find(Z=>tt(Z)===U)?.type},[Y.fields,tt]),fa=S.useCallback(_=>Ph(_,Iy(_),sr,It),[sr,It,Iy]),gn=S.useCallback(_=>fa(_)?Kr(_):!1,[fa,Kr]);S.useEffect(()=>{const{visibleFields:_,requiredFields:W,errors:U}=Nt.getState(),Z=new Set(_),Q=new Set(W),de=[];for(const Ce of Y.fields){const Ne=tt(Ce);Ne&&(fa(Ne)||(Z.delete(Ne),Q.delete(Ne),U[Ne]&&de.push(Ne)))}Se(Array.from(Z)),ae(Array.from(Q));for(const Ce of de)ve(Ce,void 0)},[sr,It,Y.fields,Y.id,tt,fa,Se,ae,ve,Xe,ge]);const Lt=Y.config?.sections,eo=S.useCallback(_=>{let W=_;if(_.type==="table"){const Z=_.properties?.columns;if(Array.isArray(Z)&&Z.length>0){const Q=Z.filter(de=>wt(de));W={..._,properties:{..._.properties,columns:Q}}}}const U=DT(W,Lt,tt);return U?{...W,label:zg(U,0)}:W},[wt,Lt,tt]),yn=S.useCallback(_=>Ug(_,Y.fields,Lt,tt),[Y.fields,Lt,tt]),qr=S.useCallback((_,W,U)=>`${_}__addmore__${W}__${U}`,[]),pa=S.useCallback((_,W)=>`${_}__${W??"base"}`,[]),ma=S.useCallback((_,W)=>{const U=pa(_.id,W);return X[U]??_.defaultCollapsed??!1},[X,pa]),ed=S.useCallback((_,W,U)=>{const Z=pa(_,W);le(Q=>Q[Z]===U?Q:{...Q,[Z]:U})},[pa]),ha=S.useMemo(()=>{const _=[],W=Y.fields.filter(U=>U.type==="addmore");for(const U of W){const Z=tt(U),de=yn(U).find(lt=>{if(lt.type!=="button")return!1;const Ut=lt.properties,De=lt.metadata;let Ue=Ut?.action;if(!Ue&&De!=null)try{Ue=(typeof De=="string"?JSON.parse(De):De)?.action}catch{}return Ue==="upload"||Ue==="custom"});if(!de)continue;const Ce=tt(de),Ne=H[Z]||[],Be=Qe($[Ce],"data.id")??Qe($[Ce],"data.documentId")??M.documentId;Be!=null&&String(Be).trim()!==""&&_.push(String(Be));for(const lt of Ne){const Ut=qr(Ce,Z,lt),De=Qe($[Ut],"data.id")??Qe($[Ut],"data.documentId"),Ue=re[`${Z}__${lt}`],xe=De??Ue;xe!=null&&String(xe).trim()!==""&&_.push(String(xe))}}return _},[Y.fields,H,$,re,M.documentId,tt,yn,qr]);S.useEffect(()=>{V(_=>{const W={..._,document_ids:ha},U=_.document_ids;return Array.isArray(U)&&U.length===ha.length&&ha.every((Z,Q)=>U[Q]===Z)?_:W})},[ha]);const ga=S.useCallback((_,W,U,Z)=>{for(const Q of U){const de=tt(Q),Ce=qr(de,_,W),Ne=Z[Ce];if(Ne==null)continue;const Be=Q.type;if(Be==="file"||Be==="camera"||Be==="photoChoice"){if(typeof Ne=="object"&&Ne!==null&&("url"in Ne||"name"in Ne)||Array.isArray(Ne)&&Ne.length>0)return!0;continue}if(Array.isArray(Ne)){if(Ne.length>0)return!0;continue}if(typeof Ne=="string"&&Ne.trim()!==""||typeof Ne=="number"&&!Number.isNaN(Ne)||typeof Ne=="boolean"||typeof Ne=="object"&&Ne!==null&&Object.keys(Ne).length>0)return!0}return!1},[tt,qr]),to=S.useCallback(_=>{const W=tt(_);if(!W)return;if(yn(_).length===0){Bt.toast.error("No linked fields configured for this Add More button.");return}const Z=`${Date.now()}_${Math.random().toString(36).slice(2,8)}`;K(Q=>({...Q,[W]:[...Q[W]||[],Z]}))},[tt,yn]),ya=S.useCallback((_,W)=>{K(U=>{const Z=U[_]||[],Q=Z.filter(de=>de!==W);if(Q.length===Z.length)return U;if(Q.length===0){const de={...U};return delete de[_],de}return{...U,[_]:Q}})},[]),ba=S.useMemo(()=>Et.filter(_=>!_.parentId),[Et]),Dn=S.useMemo(()=>{const _=[];return Et.filter(U=>U.type==="addmore").sort((U,Z)=>{const Q=U.position?.order??0,de=Z.position?.order??0;return Q-de}).forEach(U=>{const Z=tt(U),Q=U.position?.order??0,de=H[Z]||[],Ce=yn(U).sort((Ae,Ve)=>{const ot=Ae.position?.order??0,ue=Ve.position?.order??0;return ot!==ue?ot-ue:(Ae.position?.column??1)-(Ve.position?.column??1)});if(Ce.length===0)return;const Ne=jg(U,Lt),Be=Ne[0]?.fieldNames?.length?Ne[0].fieldNames:Ce.map(Ae=>tt(Ae)).filter(Boolean),lt=jT(Be,ba,J,tt),Ut=Math.min(...Ce.map(Ae=>Ae.position?.order??0)),De=Math.max(1,...Ce.map(Ae=>(Ae.position?.order??Ut)-Ut+zo(Ae))),Ue=lt?.blockHeight??De,xe=de.length*Ue;_.push({addMoreFieldName:Z,baseOrder:Q,blockHeight:Ue,blockIds:de,linkedFields:Ce,insertedRows:xe,templateFieldNames:Be,templateBounds:lt})}),_},[Et,ba,J,tt,H,yn,Lt]),Ni=S.useMemo(()=>({}),[]),va=S.useMemo(()=>Dn.length===0?Et:Et.map(_=>{const W=_.position?.order??0,U=Dn.reduce((Z,Q)=>{const de=Q.templateBounds?.maxRow??Q.baseOrder;return W>de?Z+Q.insertedRows:Z},0);return U===0?_:{..._,position:{..._.position,order:W+U}}}),[Et,Dn]),wa=S.useCallback(_=>{const W={};return Object.entries($).forEach(([U,Z])=>{const Q=_[U];Q&&(W[Q]=Z)}),W},[$]),Bo=S.useMemo(()=>{const _=[],W={};return Dn.forEach(U=>{const{addMoreFieldName:Z,blockIds:Q,linkedFields:de,blockHeight:Ce,templateBounds:Ne}=U,Be=Math.min(...de.map(De=>De.position?.order??0)),Ut=Y.fields.find(De=>tt(De)===Z&&De.type==="addmore")?.properties;Q.forEach((De,Ue)=>{const xe={},Ae={},Ve={},ot=Ne?zT(Ne,Ue):U.baseOrder+1+Ue*Ce,ue=re[`${Z}__${De}`];de.forEach(we=>{const ut=tt(we),Vt=qr(ut,Z,De),Dt=(we.position?.order??Be)-Be;if(xe[Vt]=ut,Ae[Vt]=Ie[Vt],!(Ut?.linkedFieldAllowDuplicate?.[ut]??!0)&&(we.type==="select"||we.type==="radio"||we.type==="multiselect")){const vt=[],or=Ie[ut];or!=null&&or!==""&&(Array.isArray(or)?vt.push(...or.map(Yr=>String(Yr))):vt.push(String(or))),Q.filter(Yr=>Yr!==De).forEach(Yr=>{const jr=qr(ut,Z,Yr),Xr=Ie[jr];Xr!=null&&Xr!==""&&(Array.isArray(Xr)?vt.push(...Xr.map(se=>String(se))):vt.push(String(Xr)))}),vt.length>0&&(Ve[Vt]=[...new Set(vt)])}_.push({...we,id:`${we.id}__${De}`,name:Vt,position:{...we.position,order:ot+Dt}})});const Oe=wa(xe);Object.keys(xe).forEach(we=>{W[we]={scopedFormValues:Ae,scopedFieldNameMap:xe,scopedButtonResponses:Oe,...ue!=null&&{blockDocumentId:ue},...Ve[we]&&{excludedOptionValues:Ve[we]}}})})}),{clonedFields:_,scopeByFieldName:W}},[Dn,re,tt,qr,Ie,wa,Y.fields]),ki=S.useMemo(()=>[...va,...Bo.clonedFields].sort((_,W)=>{const U=_.position?.order??0,Z=W.position?.order??0;if(U!==Z)return U-Z;const Q=_.position?.column??1,de=W.position?.column??1;if(Q!==de)return Q-de;const Ce=Oo(_.position)??0,Ne=Oo(W.position)??0;return Ce!==Ne?Ce-Ne:String(_.id).localeCompare(String(W.id))}),[va,Bo.clonedFields]),$o=S.useMemo(()=>pT(ki.filter(_=>!_.parentId),_r),[ki,_r]),td=S.useCallback((_,W)=>$o.some(U=>mT(_,W,U,J)),[$o,J]);$o.length===0||Math.max(...$o.map(_=>(_[0]?.position?.order??0)+wi(_,J).rowSpan));const Sa=S.useMemo(()=>BT(Lt,Vc(Et.filter(_=>!_.parentId)),tt),[Lt,Et,tt]),{anchorsByOrigin:My,coveredCells:Ly}=S.useMemo(()=>UT(Sa,va,tt,J),[Sa,va,tt,J]),{anchorsByOrigin:Dy,coveredCells:By}=S.useMemo(()=>VT(Dn.map(_=>({addMoreFieldName:_.addMoreFieldName,blockIds:_.blockIds,linkedFields:_.linkedFields,templateFieldNames:_.templateFieldNames})),Lt,Bo.clonedFields,ba,J,tt,Ly),[Dn,Lt,Bo.clonedFields,ba,J,tt,Ly]),bn=S.useMemo(()=>qT(My,Dy),[My,Dy]),$y=S.useMemo(()=>By,[By]),jy=String(kt).endsWith("px")?kt:Bn,zy=S.useCallback((_,W)=>{for(let U=0;U<J;U++){if(U>=W.anchorCol&&U<W.anchorCol+W.colSpan)continue;if(Ni[`${_}-${U}`]||bn.get(`${_}-${U}`)||Lg(_,U,ki,_r).length>0||td(_,U))return!0}return!1},[J,Ni,bn,ki,_r,td]),Uy=S.useMemo(()=>GT(bn,_=>{const W=_.run.section;return W.collapsible?ma(W,_.addMoreMeta?.blockId):!1},zy),[bn,ma,zy]),Vy=S.useMemo(()=>{const _=[];for(const W of Object.keys(Ni)){const U=Number(W.split("-")[0]);Number.isNaN(U)||_.push(U)}for(const W of bn.values())if(W.renderFields.some(U=>_r(U)))for(let U=W.anchorRow;U<W.anchorRow+W.rowSpan;U++)_.push(U);return hT($o,J,_)},[$o,J,Ni,bn,_r]),{originalToDisplayRow:xa,displayRowCount:zP,sortedOccupiedRows:UP}=S.useMemo(()=>{const _=gT(Vy);return{originalToDisplayRow:_.originalToDisplay,displayRowCount:_.displayRowCount,sortedOccupiedRows:_.sortedOriginalRows}},[Vy]),Hy=Math.max(zP,1),rd=S.useCallback((_,W=1)=>yT(_,W,xa),[xa]),Wy=S.useMemo(()=>{const _=new Set;for(const W of Uy){const U=xa.get(W);U!==void 0&&_.add(U)}return _},[Uy,xa]),VP=S.useMemo(()=>KT(Hy,jy,Wy),[Hy,jy,Wy]),HP=S.useMemo(()=>YT(Et.filter(_=>!_.parentId&&_r(_)),Sa,tt),[Et,Sa,tt,_r]),Aa=S.useCallback(_=>{if(P)return null;const W=tt(_),U=H[W]||[];if(U.length===0)return null;const Z=yn(_);if(Z.length===0)return null;const Q=LT(_,Lt),de=Z.map(Be=>tt(Be)).filter(Boolean),Ce=Hg(de,Lt),Ne=(Be,lt,Ut,De,Ue,xe,Ae)=>{const Ve=tt(Be),ot=qr(Ve,W,lt),ue=Be.hidden===!0;if(!(wt(Be)&&(Nr(Ve)||!ue&&Ve)))return null;const we={...Be,id:`${Be.id}__${lt}`,name:ot},Vt=_.properties?.linkedFieldAllowDuplicate?.[Ve]??!0;let Dt;if(!Vt&&(Be.type==="select"||Be.type==="radio"||Be.type==="multiselect")){const ct=[],vt=Ie[Ve];vt!=null&&vt!==""&&(Array.isArray(vt)?ct.push(...vt.map($r=>String($r))):ct.push(String(vt))),U.filter($r=>$r!==lt).forEach($r=>{const Yr=qr(Ve,W,$r),jr=Ie[Yr];jr!=null&&jr!==""&&(Array.isArray(jr)?ct.push(...jr.map(Xr=>String(Xr))):ct.push(String(jr)))}),ct.length>0&&(Dt=[...new Set(ct)])}return c.jsx("div",{"data-field-name":ot,"data-form-renderer":"field-wrapper",children:c.jsx(mn,{field:we,value:Ie[ot],error:pe[ot]||ze>0?oe[ot]:void 0,onChange:ct=>xt(ot,ct),onBlur:()=>Pe(ot),disabled:ce||!rr(Ve)||Xt||!!Be.disabled,readOnly:vr(Ve,!!Be.readOnly),isRequired:gn(Ve),formValues:Ie,submissionContext:Dr,prepopulateMappedFieldNames:je,urlParams:ee,prepopulateResponse:ne,prepopulateLoading:L,formSections:Lt,submitPayload:Y.config?.submitPayload,fieldValueKey:ot,buttonResponses:xe,onButtonApiResponse:fr,onSubmit:Qt,onReset:At,onCancel:wr,isSubmitting:We,bffSubmitApi:z,onBffSubmitResult:m,extraSubmitPayload:Ae,onValidateForm:Sr,getValidationErrors:Gt,allFields:Y.fields,onSubmittingChange:he,scopedFormValues:Ue,scopedFieldNameMap:De,excludedOptionValues:Dt,hideTableRowControls:A})},we.id)};return c.jsx("div",{className:"space-y-3 mt-3",children:U.map((Be,lt)=>{const Ut={},De={};Z.forEach(Dt=>{const ct=tt(Dt),vt=qr(ct,W,Be);Ut[vt]=ct,De[vt]=Ie[vt]});const Ue=wa(Ut),xe=ga(W,Be,Z,Ie),Ae=Q?.heading!=null?xi(Q,lt+1):null,Ve=re[`${W}__${Be}`],ot=Ve!=null?{...nr,documentId:Ve}:nr,ue=Z.map(Dt=>Ne(Dt,Be,lt,Ut,De,Ue,ot)).filter(Boolean),we=Ce?.section?.collapsible===!0,ut=c.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:xe,title:xe?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:Dt=>{Dt.preventDefault(),Dt.stopPropagation(),ya(W,Be)},children:c.jsx(Yo,{className:"h-5 w-5","aria-hidden":!0})}),Vt=c.jsxs(c.Fragment,{children:[!we&&c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[Ae?c.jsx("p",{className:"text-sm font-medium text-foreground",children:Ae}):c.jsxs("p",{className:"text-xs text-muted-foreground",children:["Entry ",lt+1]}),ut]}),ue]});return c.jsx("div",{className:"rounded-md border p-3 space-y-3",children:Ce?c.jsx(Bc,{legend:Ce.section.heading?.enabled?xi(Ce.section,lt+1):Ce.section.name,collapsible:Ce.section.collapsible,defaultCollapsed:Ce.section.defaultCollapsed,headerActions:we?ut:void 0,onCollapsedChange:Dt=>ed(Ce.section.id,Be,Dt),children:Vt}):Vt},`${_.id}-${Be}`)})})},[P,H,re,tt,yn,qr,ga,Ie,pe,ze,oe,xt,Pe,rr,Xt,gn,Dr,je,fr,Qt,At,wr,We,z,m,nr,Sr,Gt,Y.fields,he,Nr,wt,wa,ya,A,Lt,ee,ne,L]);return c.jsx("div",{className:E?j("relative",d):j(Na,F&&"dark",d),style:Ei,"data-form-renderer":E?void 0:"root",children:c.jsxs("div",{className:"relative",children:[L&&c.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/60 rounded-md",children:c.jsx(Ln,{})}),c.jsx("form",{onSubmit:Qt,className:f?j("w-full min-w-0"):j("space-y-6 pb-[100px] w-full min-w-0",da[ca]),"data-form-renderer":"form","data-form-renderer-layout":P?"grid":"stack",children:c.jsxs(HN,{value:ua,children:[Lr&&Y.steps&&c.jsx(nT,{steps:Y.steps,currentStep:Fe,completedSteps:nt,onStepClick:on}),c.jsx(Ba.Provider,{value:{gridStretch:P},children:P?c.jsx("div",{className:f?"w-full min-w-0":"grid w-full min-w-0",style:{display:"grid",gridTemplateRows:VP,gridTemplateColumns:`repeat(${J}, 1fr)`,rowGap:ye,columnGap:st},"data-form-renderer":"grid",children:UP.map(_=>Array.from({length:J},(W,U)=>{const Z=rd(_);if(!Z)return null;if(td(_,U))return c.jsx("div",{className:"min-w-0 min-h-0",style:{gridRow:Z,gridColumn:U+1,visibility:"hidden",pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`empty-${_}-${U}`);if(HT(_,U,$y,bn)){const xe=WT(_,U,bn);return xe&&RT(_,U,xe,ma(xe.run.section,xe.addMoreMeta?.blockId))?null:c.jsx("div",{className:"min-w-0 min-h-0",style:{gridRow:Z,gridColumn:U+1,visibility:"hidden",pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`section-border-cover-${_}-${U}`)}const Q=bn.get(`${_}-${U}`);if(Q){const xe=Q.renderFields.filter(ct=>_r(ct));if(xe.length===0)return null;const Ae=Q.addMoreMeta,Ve=Ae!=null?Dn.find(ct=>ct.addMoreFieldName===Ae.addMoreFieldName)?.linkedFields??[]:[],ot=Ae!=null?ga(Ae.addMoreFieldName,Ae.blockId,Ve,Ie):!1,ue=Q.run.section,Oe=Ae?.blockId,we=ma(ue,Oe),ut=ue.collapsible&&we?1:Q.rowSpan,Vt=rd(Q.anchorRow,ut)??Z,Dt=Ae!=null?c.jsx("button",{type:"button",className:j("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",f&&"text-red-600 hover:bg-red-500/10"),disabled:ot,title:ot?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:ct=>{ct.preventDefault(),ct.stopPropagation(),ya(Ae.addMoreFieldName,Ae.blockId)},children:c.jsx(Yo,{className:"h-5 w-5","aria-hidden":!0})}):void 0;return c.jsx("div",{className:j("min-h-0 min-w-0",!(ue.collapsible&&we)&&"self-stretch"),style:{gridRow:Vt,gridColumn:`${U+1} / span ${Q.colSpan}`},"data-form-renderer":"grid-cell","data-form-renderer-config-section-border-cell":!0,children:c.jsx(Bc,{legend:Q.legend,className:ue.collapsible&&we?void 0:"h-full",collapsible:ue.collapsible,defaultCollapsed:ue.defaultCollapsed,headerActions:Dt,onCollapsedChange:ct=>ed(ue.id,Oe,ct),children:c.jsx("div",{className:"grid w-full min-w-0",style:{gridTemplateColumns:`repeat(${J}, 1fr)`,gridTemplateRows:`repeat(${Q.rowSpan}, minmax(${String(kt).endsWith("px")?kt:Bn}, auto))`,rowGap:ye,columnGap:st},children:xe.map(ct=>{const vt=tt(ct),or=Bo.scopeByFieldName[vt],$r=or?.scopedFieldNameMap?.[vt]||vt,Yr=(ct.position?.order??Q.anchorRow)-Q.anchorRow,jr=ct.position?.column??1,{rowSpan:Xr,columnSpan:se}=wi([ct],J),Me=Ae!=null?re[`${Ae.addMoreFieldName}__${Ae.blockId}`]:void 0,me=Me!=null?{...nr,documentId:Me}:nr;return c.jsx("div",{"data-field-name":vt,"data-form-renderer":"field-wrapper",className:"min-h-0 min-w-0",style:{gridRow:`${Yr+1} / span ${Xr}`,gridColumn:`${jr} / span ${se}`,...En(ct)},children:c.jsx(mn,{field:eo(ct),value:Ie[vt],error:pe[vt]||ze>0?oe[vt]:void 0,onChange:qe=>xt(vt,qe),onBlur:()=>Pe(vt),disabled:(ct.type==="table"||ct.type==="billingGrid")&&a==="fill"?!1:ce||!rr($r)||Xt||!!ct.disabled,readOnly:(ct.type==="table"||ct.type==="billingGrid")&&a==="fill"?!1:vr($r,!!ct.readOnly),isRequired:gn($r),formValues:Ie,submissionContext:Dr,prepopulateMappedFieldNames:je,urlParams:ee,prepopulateResponse:ne,prepopulateLoading:L,formSections:Lt,submitPayload:Y.config?.submitPayload,fieldValueKey:vt,buttonResponses:or?.scopedButtonResponses??$,onButtonApiResponse:fr,onSubmit:Qt,onReset:At,onCancel:wr,isSubmitting:We,bffSubmitApi:z,onBffSubmitResult:m,extraSubmitPayload:me,onValidateForm:Sr,getValidationErrors:Gt,allFields:Y.fields,onSubmittingChange:he,onAddMore:to,scopedFormValues:or?.scopedFormValues,scopedFieldNameMap:or?.scopedFieldNameMap,excludedOptionValues:or?.excludedOptionValues,hideTableRowControls:A})},ct.id)})})})},`section-border-${Q.run.section.id}-${_}-${U}-${Ae?.blockId??"base"}`)}const de=Lg(_,U,ki,_r).filter(xe=>!(tt(xe)?.includes("__addmore__")&&$y.has(`${_}-${U}`)));if(de.length===0){const xe=Ni[`${_}-${U}`];if(xe){const Ae=Y.fields.find(ue=>ue.type==="addmore"&&tt(ue)===xe.addMoreFieldName),Ve=Ae!=null?yn(Ae):[],ot=ga(xe.addMoreFieldName,xe.blockId,Ve,Ie);return c.jsx("div",{className:"min-h-0 min-w-0 flex flex-col items-center justify-center",style:{gridRow:Z,gridColumn:U+1},"data-form-renderer":"grid-cell","data-form-renderer-add-more-remove":!0,children:c.jsx("button",{type:"button",className:j("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",f&&"text-red-600 hover:bg-red-500/10"),disabled:ot,title:ot?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:ue=>{ue.preventDefault(),ue.stopPropagation(),ya(xe.addMoreFieldName,xe.blockId)},children:c.jsx(Yo,{className:"h-5 w-5","aria-hidden":!0})})},`add-more-remove-${_}-${U}`)}return c.jsx("div",{className:"min-w-0",style:{pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`empty-${_}-${U}`)}const Ce=de[0],{rowSpan:Ne,columnSpan:Be}=wi(de,J),lt=rd(_,Ne)??Z;if(de.length===1&&Ce.type==="section"){const xe=Y.fields.filter(Ae=>Ae.parentId===Ce.id&&Ae.position!=null).sort((Ae,Ve)=>{const ot=typeof Ae.position?.order=="number"?Ae.position.order:0,ue=typeof Ve.position?.order=="number"?Ve.position.order:0;return ot-ue});return c.jsx("div",{className:"min-w-0 min-h-0 w-full overflow-hidden flex flex-col h-full",style:{gridRow:lt,gridColumn:`${U+1} / span ${Be}`,...En(Ce)},"data-form-renderer":"grid-cell",children:c.jsx(ng,{field:Ce,children:xe.map(Ae=>{const Ve=Ae.name||Ae.key||Ae.id,ot=Ae.hidden===!0;return wt(Ae)&&(Nr(Ve)||!ot&&Ve)?c.jsx("div",{"data-field-name":Ve,"data-form-renderer":"field-wrapper",children:c.jsx(mn,{field:eo(Ae),value:Ie[Ve],error:pe[Ve]||ze>0?oe[Ve]:void 0,onChange:Oe=>xt(Ve,Oe),onBlur:()=>Pe(Ve),disabled:ce||!rr(Ve)||Xt||!!Ae.disabled,readOnly:vr(Ve,!!Ae.readOnly),isRequired:gn(Ve),formValues:Ie,submissionContext:Dr,prepopulateMappedFieldNames:je,urlParams:ee,prepopulateResponse:ne,prepopulateLoading:L,formSections:Lt,submitPayload:Y.config?.submitPayload,fieldValueKey:Ve,buttonResponses:$,onButtonApiResponse:fr,onSubmit:Qt,onReset:At,onCancel:wr,isSubmitting:We,bffSubmitApi:z,onBffSubmitResult:m,extraSubmitPayload:nr,onValidateForm:Sr,getValidationErrors:Gt,allFields:Y.fields,onSubmittingChange:he,onAddMore:to,hideTableRowControls:A})},Ae.id):null})})},Ce.id)}const Ut=Ig(de),De=de.some(xe=>["file","camera","photoChoice","addmore","table","billingGrid"].includes(xe.type)),Ue=c.jsx("div",{className:j("flex min-h-0 w-full flex-1 gap-3",Ut==="row"?"flex-row items-stretch":"flex-col items-stretch"),children:de.map(xe=>{const Ae=xe.name||xe.key||xe.id,Ve=xe.type==="sectionHeading",ot=Bo.scopeByFieldName[Ae],ue=ot?.scopedFieldNameMap?.[Ae]||Ae,Oe=ot?.blockDocumentId!=null?{...nr,documentId:ot.blockDocumentId}:nr,we=xe.appearance?.hideLabel??xe.properties?.hideLabel??!1,ut=xe.type==="table"||xe.type==="billingGrid"?xe.properties?.minWidth:void 0;return c.jsx("div",{"data-field-name":Ae,"data-form-renderer":"field-wrapper",className:j("flex min-h-0 min-w-0 flex-1 flex-col",Ho(xe),Ve&&"items-center justify-center",we&&"items-center"),style:{...ut?{minWidth:ut}:{},...En(xe)},children:c.jsx(mn,{field:eo(xe),value:Ie[Ae],error:pe[Ae]||ze>0?oe[Ae]:void 0,onChange:Vt=>xt(Ae,Vt),onBlur:()=>Pe(Ae),disabled:(xe.type==="table"||xe.type==="billingGrid")&&a==="fill"?!1:ce||!rr(ue)||Xt||!!xe.disabled,readOnly:(xe.type==="table"||xe.type==="billingGrid")&&a==="fill"?!1:vr(ue,!!xe.readOnly),isRequired:gn(ue),formValues:Ie,submissionContext:Dr,prepopulateMappedFieldNames:je,urlParams:ee,prepopulateResponse:ne,prepopulateLoading:L,formSections:Lt,submitPayload:Y.config?.submitPayload,fieldValueKey:Ae,buttonResponses:ot?.scopedButtonResponses??$,onButtonApiResponse:fr,onSubmit:Qt,onReset:At,onCancel:wr,isSubmitting:We,bffSubmitApi:z,onBffSubmitResult:m,extraSubmitPayload:Oe,onValidateForm:Sr,getValidationErrors:Gt,allFields:Y.fields,onSubmittingChange:he,onAddMore:to,scopedFormValues:ot?.scopedFormValues,scopedFieldNameMap:ot?.scopedFieldNameMap,excludedOptionValues:ot?.excludedOptionValues,hideTableRowControls:A})},xe.id)})});return c.jsx("div",{className:j(Fd(de),"self-stretch",De?"overflow-visible":"overflow-hidden"),style:{gridRow:lt,gridColumn:`${U+1} / span ${Be}`,...En(de[0])},"data-form-renderer":"grid-cell","data-field-name":de.map(xe=>xe.name||xe.key||xe.id).join(","),children:Ue},de.map(xe=>xe.id).join("-"))}))}):c.jsx("div",{className:f?"":"space-y-4","data-form-renderer":"stack",children:Et.map(_=>{if(!_r(_))return null;const W=HP.find(Z=>Z.kind==="border"&&Z.fields.some(Q=>Q.id===_.id));if(W)return W.fields[0]?.id!==_.id?null:c.jsx(Bc,{legend:xi(W.run.section,0),collapsible:W.run.section.collapsible,defaultCollapsed:W.run.section.defaultCollapsed,onCollapsedChange:Z=>ed(W.run.section.id,void 0,Z),children:W.fields.map(Z=>{const Q=tt(Z);return!Q||!_r(Z)?null:c.jsxs("div",{"data-field-name":Q,"data-form-renderer":"field-wrapper",style:En(Z),children:[c.jsx(mn,{field:eo(Z),value:Ie[Q],error:pe[Q]||ze>0?oe[Q]:void 0,onChange:de=>xt(Q,de),onBlur:()=>Pe(Q),disabled:(Z.type==="table"||Z.type==="billingGrid")&&a==="fill"?!1:ce||!rr(Q)||Xt||!!Z.disabled,readOnly:(Z.type==="table"||Z.type==="billingGrid")&&a==="fill"?!1:vr(Q,!!Z.readOnly),isRequired:gn(Q),formValues:Ie,submissionContext:Dr,prepopulateMappedFieldNames:je,urlParams:ee,prepopulateResponse:ne,prepopulateLoading:L,formSections:Lt,submitPayload:Y.config?.submitPayload,fieldValueKey:Q,buttonResponses:$,onButtonApiResponse:fr,onSubmit:Qt,onReset:At,onCancel:wr,isSubmitting:We,bffSubmitApi:z,onBffSubmitResult:m,extraSubmitPayload:nr,onValidateForm:Sr,getValidationErrors:Gt,allFields:Y.fields,onSubmittingChange:he,onAddMore:to,hideTableRowControls:A}),Z.type==="addmore"&&Aa(Z)]},Z.id)})},`stack-border-${W.run.section.id}-${_.id}`);if(!_.parentId){const Z=Et.filter(de=>!de.parentId&&_r(de)&&oa(de)===oa(_)),Q=jc(Z).slice(0,2);if(Q.length>1&&Q[0].id!==_.id)return null;if(Q.length>1){const de=Ig(Q);return c.jsx("div",{"data-form-renderer":"shared-cell-stack",className:j("flex w-full min-w-0 gap-3",de==="row"?"flex-row items-stretch":"flex-col"),children:Q.map(Ce=>{const Ne=Ce.name||Ce.key||Ce.id;return c.jsxs("div",{"data-field-name":Ne,"data-form-renderer":"field-wrapper",className:j("min-w-0 flex-1 flex flex-col",Ho(Ce)),style:En(Ce),children:[c.jsx(mn,{field:eo(Ce),value:Ie[Ne],error:pe[Ne]||ze>0?oe[Ne]:void 0,onChange:Be=>xt(Ne,Be),onBlur:()=>Pe(Ne),disabled:(Ce.type==="table"||Ce.type==="billingGrid")&&a==="fill"?!1:ce||!rr(Ne)||Xt||!!Ce.disabled,readOnly:(Ce.type==="table"||Ce.type==="billingGrid")&&a==="fill"?!1:vr(Ne,!!Ce.readOnly),isRequired:gn(Ne),formValues:Ie,submissionContext:Dr,prepopulateMappedFieldNames:je,urlParams:ee,prepopulateResponse:ne,prepopulateLoading:L,formSections:Lt,submitPayload:Y.config?.submitPayload,fieldValueKey:Ne,buttonResponses:$,onButtonApiResponse:fr,onSubmit:Qt,onReset:At,onCancel:wr,isSubmitting:We,bffSubmitApi:z,onBffSubmitResult:m,extraSubmitPayload:nr,onValidateForm:Sr,getValidationErrors:Gt,allFields:Y.fields,onSubmittingChange:he,onAddMore:to,hideTableRowControls:A}),Ce.type==="addmore"&&Aa(Ce)]},Ce.id)})},Q.map(Ce=>Ce.id).join("-"))}}if(_.type==="section"){const Z=Y.fields.filter(Q=>Q.parentId===_.id&&Q.position!=null).sort((Q,de)=>{const Ce=typeof Q.position?.order=="number"?Q.position.order:0,Ne=typeof de.position?.order=="number"?de.position.order:0;return Ce-Ne});return c.jsx(ng,{field:_,children:Z.map(Q=>{const de=Q.name||Q.key||Q.id,Ce=Q.hidden===!0;return wt(Q)&&(Nr(de)||!Ce&&de)?c.jsxs("div",{"data-field-name":de,"data-form-renderer":"field-wrapper",style:En(Q),children:[c.jsx(mn,{field:eo(Q),value:Ie[de],error:pe[de]||ze>0?oe[de]:void 0,onChange:Be=>xt(de,Be),onBlur:()=>Pe(de),disabled:ce||!rr(de)||Xt||!!Q.disabled,readOnly:vr(de,!!Q.readOnly),isRequired:gn(de),formValues:Ie,submissionContext:Dr,prepopulateMappedFieldNames:je,urlParams:ee,prepopulateResponse:ne,prepopulateLoading:L,formSections:Lt,submitPayload:Y.config?.submitPayload,fieldValueKey:de,buttonResponses:$,onButtonApiResponse:fr,onSubmit:Qt,onReset:At,onCancel:wr,isSubmitting:We,bffSubmitApi:z,onBffSubmitResult:m,extraSubmitPayload:nr,onValidateForm:Sr,getValidationErrors:Gt,allFields:Y.fields,onSubmittingChange:he,onAddMore:to,hideTableRowControls:A}),Q.type==="addmore"&&Aa(Q)]},Q.id):null})},_.id)}const U=_.name||_.key||_.id;return c.jsxs("div",{"data-field-name":U,"data-form-renderer":"field-wrapper",style:En(_),children:[c.jsx(mn,{field:eo(_),value:Ie[U],error:pe[U]||ze>0?oe[U]:void 0,onChange:Z=>xt(U,Z),onBlur:()=>Pe(U),disabled:(_.type==="table"||_.type==="billingGrid")&&a==="fill"?!1:ce||!rr(U)||Xt||!!_.disabled,readOnly:(_.type==="table"||_.type==="billingGrid")&&a==="fill"?!1:vr(U,!!_.readOnly),isRequired:gn(U),formValues:Ie,submissionContext:Dr,prepopulateMappedFieldNames:je,urlParams:ee,prepopulateResponse:ne,prepopulateLoading:L,formSections:Lt,submitPayload:Y.config?.submitPayload,fieldValueKey:U,buttonResponses:$,onButtonApiResponse:fr,onSubmit:Qt,onReset:At,onCancel:wr,isSubmitting:We,bffSubmitApi:z,onBffSubmitResult:m,extraSubmitPayload:nr,onValidateForm:Sr,getValidationErrors:Gt,allFields:Y.fields,onSubmittingChange:he,onAddMore:to,hideTableRowControls:A}),_.type==="addmore"&&Aa(_)]},_.id)})})}),u]})})]})})};function Rc(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function Xg(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}function ZT(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,f)=>{if(!l||typeof l!="object")return null;const p={...l};if(l.fieldType&&!p.type&&(p.type=l.fieldType),l.fieldKey&&!p.key&&!p.name&&(p.key=l.fieldKey,p.name=l.fieldKey),typeof l.positionOrder=="number"&&!isNaN(l.positionOrder)?p.order=l.positionOrder:p.order=f,(typeof p.order!="number"||isNaN(p.order))&&(p.order=f),l.options&&typeof l.options=="string")try{p.options=JSON.parse(l.options)}catch{}if(l.metadata&&typeof l.metadata=="string")try{p.metadata=JSON.parse(l.metadata)}catch{}return p}).filter(l=>l!=null).sort((l,f)=>{const p=typeof l.order=="number"?l.order:0,m=typeof f.order=="number"?f.order:0;return p-m});n.forEach((l,f)=>{(!l||typeof l.order!="number"||isNaN(l.order))&&(l.order=f)});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 d=l=>{let f={...l};if(l.conditionExpression&&typeof l.conditionExpression=="string")try{f={...l,conditionExpression:JSON.parse(l.conditionExpression)}}catch{}if(f.targetFieldId){const p=i.find(m=>m._id===f.targetFieldId||m.id===f.targetFieldId||m.fieldKey===f.targetFieldId);if(p){const m=p.key||p.fieldKey||p.name,g=p._id||p.id||f.targetFieldId;f.targetFieldKey=m,f.targetField=m,f.targetFieldById=g}}return f},u={id:r._id,name:r.name,description:r.description??"",version:r.version,status:r.status,fields:i.map((l,f)=>{const p=l,m=typeof l.metadata=="object"&&l.metadata!==null?l.metadata:{},g=m.hidden===!0||l.hidden===!0,h={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(g&&(h.hidden=!0),h.id||(h.id=h.key||h.name),h.key||(h.key=h.id||h.name),h.name||(h.name=h.key||h.id),l.isRequired!==void 0&&(h.required=l.isRequired),l.placeholder&&(h.placeholder=l.placeholder),l.options&&Array.isArray(l.options)&&(h.options=l.options),l.apidata&&(h.apidata=l.apidata),p.appearance&&typeof p.appearance=="object"&&!Array.isArray(p.appearance)&&Object.keys(p.appearance).length>0&&(h.appearance=Rc(p.appearance)),p.ui!==void 0&&(h.ui=Rc(p.ui)),p.visibility!==void 0&&(h.visibility=Rc(p.visibility)),m.disabled!==void 0&&(h.disabled=m.disabled),m.readOnly!==void 0&&(h.readOnly=m.readOnly),m.hideLabel!==void 0&&(h.hideLabel=m.hideLabel,h.properties||(h.properties={}),h.properties.hideLabel=m.hideLabel,h.appearance||(h.appearance={}),h.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 x=l.validationRules,O={...m};if(x.fileSize!==void 0&&(O.maxSize=x.fileSize),x.fileType&&Array.isArray(x.fileType)){const k=[];x.fileType.forEach(D=>{const R=D.startsWith(".")?D:`.${D}`;k.push(R),R===".csv"?k.push("text/csv"):R===".xls"?k.push("application/vnd.ms-excel"):R===".xlsx"&&k.push("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")}),O.accept=k}h.metadata=O,O.maxSize!==void 0&&(h.maxSize=O.maxSize),O.accept!==void 0&&(h.accept=O.accept)}else if(m&&Object.keys(m).length>0){if(h.metadata=m,(l.type==="toggle"||l.fieldType==="toggle")&&(m.onValue!==void 0&&(h.onValue=m.onValue),m.offValue!==void 0&&(h.offValue=m.offValue),m.onText!==void 0&&(h.onText=m.onText),m.offText!==void 0&&(h.offText=m.offText)),(l.type==="button"||l.fieldType==="button")&&m.action==="download"&&m.downloadApiEndpoint&&typeof m.downloadApiEndpoint=="string"){let x=m.downloadApiEndpoint;x=x.replace(/\{ctx:([^}]+)\}/g,(O,k)=>{const D=t[k];return D!==void 0?String(D):O}),m.downloadApiEndpoint=x,h.metadata=m,h.downloadApiEndpoint=x}if((l.type==="button"||l.fieldType==="button")&&m.action==="submit"){const x=h.properties||{};m.submitAction!==void 0&&(x.submitAction=m.submitAction),m.submitApiMethod!==void 0&&(x.submitApiMethod=m.submitApiMethod),m.apiBodyStructure!==void 0&&(x.apiBodyStructure=m.apiBodyStructure),m.apiBodyFieldsOnly!==void 0&&(x.apiBodyFieldsOnly=m.apiBodyFieldsOnly),m.apiBodyFieldsOnlyFormat!==void 0&&(x.apiBodyFieldsOnlyFormat=m.apiBodyFieldsOnlyFormat),m.apiBodyFields!==void 0&&(x.apiBodyFields=m.apiBodyFields),m.buttonText!==void 0&&(x.buttonText=m.buttonText),m.action!==void 0&&(x.action=m.action),m.variant!==void 0&&(x.variant=m.variant),m.hideLabel!==void 0&&(x.hideLabel=m.hideLabel),l.apidata&&typeof l.apidata=="object"&&l.apidata.apiEndpoint&&(x.apiEndpoint=l.apidata.apiEndpoint),h.properties=x}if((l.type==="button"||l.fieldType==="button")&&(m.action==="upload"||m.action==="custom")){const x=h.properties||{};m.action!==void 0&&(x.action=m.action),m.buttonText!==void 0&&(x.buttonText=m.buttonText),m.variant!==void 0&&(x.variant=m.variant),m.hideLabel!==void 0&&(x.hideLabel=m.hideLabel),m.uploadAction!==void 0&&(x.uploadAction=m.uploadAction),m.uploadApiEndpoint!==void 0&&(x.uploadApiEndpoint=m.uploadApiEndpoint),m.uploadApiMethod!==void 0&&(x.uploadApiMethod=m.uploadApiMethod),m.apiBodyStructure!==void 0&&(x.apiBodyStructure=m.apiBodyStructure),m.apiBodyFieldsOnly!==void 0&&(x.apiBodyFieldsOnly=m.apiBodyFieldsOnly),m.apiBodyFieldsOnlyFormat!==void 0&&(x.apiBodyFieldsOnlyFormat=m.apiBodyFieldsOnlyFormat),m.apiFieldMapping!==void 0&&(x.apiFieldMapping=m.apiFieldMapping),m.apiQueryParams!==void 0&&(x.apiQueryParams=m.apiQueryParams),m.apiBodyFields!==void 0&&(x.apiBodyFields=m.apiBodyFields),m.apiHeaders!==void 0&&(x.apiHeaders=m.apiHeaders),h.properties=x}if(l.type==="status"||l.fieldType==="status"){const x=h.properties||{};if(m.source!==void 0&&(x.source=m.source),m.statuses!==void 0&&(x.statuses=m.statuses),m.dataPath!==void 0&&(x.dataPath=m.dataPath),m.showStatusText!==void 0&&(x.showStatusText=m.showStatusText),m.statusTextPath!==void 0&&(x.statusTextPath=m.statusTextPath),m.showCurrentIndicator!==void 0&&(x.showCurrentIndicator=m.showCurrentIndicator),l.apidata&&typeof l.apidata=="object"&&l.apidata.apiEndpoint){let O=l.apidata.apiEndpoint;O=O.replace(/\{ctx:([^}]+)\}/g,(k,D)=>{const R=t[D];return R!==void 0?String(R):k}),x.apiEndpoint=O,x.source===void 0&&(x.source="api")}l.apidata?.apiMethod!==void 0&&(x.apiMethod=l.apidata.apiMethod),h.properties=x}if(l.type==="addmore"||l.fieldType==="addmore"){const x=h.properties||{};m.linkedFieldNames!==void 0&&(x.linkedFieldNames=m.linkedFieldNames),m.linkedSectionIds!==void 0&&(x.linkedSectionIds=m.linkedSectionIds),m.linkedFieldAllowDuplicate!==void 0&&(x.linkedFieldAllowDuplicate=m.linkedFieldAllowDuplicate),m.buttonText!==void 0&&(x.buttonText=m.buttonText),m.variant!==void 0&&(x.variant=m.variant),m.size!==void 0&&(x.size=m.size),m.hideLabel!==void 0&&(x.hideLabel=m.hideLabel),h.properties=x}if(l.type==="selectablelist"||l.fieldType==="selectablelist"){const x=h.properties||{};m.submitFieldMapping!==void 0&&(x.submitFieldMapping=m.submitFieldMapping),m.displayFields!==void 0&&(x.displayFields=m.displayFields),m.displayFieldsSeparator!==void 0&&(x.displayFieldsSeparator=m.displayFieldsSeparator),m.dataSourceContextKey!==void 0&&(x.dataSourceContextKey=m.dataSourceContextKey),m.showSelectAll!==void 0&&(x.showSelectAll=m.showSelectAll),m.selectAllByDefault!==void 0&&(x.selectAllByDefault=m.selectAllByDefault),h.properties=x}}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"&&(h.validationRules=l.validationRules),typeof l.order=="number"&&(h.order=l.order);const y=l,w=Xg(y.position),v=l.metadata&&typeof l.metadata=="object"&&!Array.isArray(l.metadata)?l.metadata:{},A=Xg(y.layout),F={order:typeof y.positionOrder=="number"?y.positionOrder:l.order??f,column:typeof w.column=="number"?w.column:typeof y.positionColumn=="number"?y.positionColumn:1,columnSpan:typeof w.columnSpan=="number"?w.columnSpan:typeof w.width=="number"?w.width:typeof y.positionWidth=="number"?y.positionWidth:1,rowSpan:typeof w.rowSpan=="number"?w.rowSpan:typeof y.positionRowSpan=="number"?y.positionRowSpan:1},E=Oo(w,{cellSlotIndex:y.cellSlotIndex??A.cellSlotIndex,stackSlot:v.stackSlot??A.stackSlot});typeof E=="number"&&(F.cellSlot=E);const T=w.cellGroupId??A.cellGroupId;typeof T=="string"&&(F.cellGroupId=T);const N=vi(w)??vi(A)??(v.stackDirection==="horizontal"||A.stackDirection==="horizontal"?"row":v.stackDirection==="vertical"||A.stackDirection==="vertical"?"stack":void 0);return(N==="row"||N==="stack")&&(F.sharedCellLayout=N),h.position=F,l.conditions&&Array.isArray(l.conditions)&&(h.conditions=l.conditions),h}).filter(l=>l!=null).sort((l,f)=>{const p=typeof l.order=="number"?l.order:0,m=typeof f.order=="number"?f.order:0;return p-m}),config:{...s,layout:o,...r.rules&&r.rules.length>0&&{rules:r.rules.map(d)},...r.clientMapping&&Object.keys(r.clientMapping).length>0&&{clientMapping:r.clientMapping}},...r.rules&&r.rules.length>0&&{rules:r.rules.map(d)},createdAt:"",updatedAt:"",moduleId:""};return ia(u)}var sa="Tabs",[eF]=xr(sa,[Ws]),Jg=Ws(),[tF,Gc]=eF(sa),Qg=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,onValueChange:o,defaultValue:i,orientation:s="horizontal",dir:a,activationMode:d="automatic",...u}=e,l=so(a),[f,p]=tn({prop:n,onChange:o,defaultProp:i??"",caller:sa});return c.jsx(tF,{scope:r,baseId:cn(),value:f,onValueChange:p,orientation:s,dir:l,activationMode:d,children:c.jsx($e.div,{dir:l,"data-orientation":s,...u,ref:t})})});Qg.displayName=sa;var Zg="TabsList",ey=b.forwardRef((e,t)=>{const{__scopeTabs:r,loop:n=!0,...o}=e,i=Gc(Zg,r),s=Jg(r);return c.jsx(Wm,{asChild:!0,...s,orientation:i.orientation,dir:i.dir,loop:n,children:c.jsx($e.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});ey.displayName=Zg;var ty="TabsTrigger",ry=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,disabled:o=!1,...i}=e,s=Gc(ty,r),a=Jg(r),d=iy(s.baseId,n),u=sy(s.baseId,n),l=n===s.value;return c.jsx(Rm,{asChild:!0,...a,focusable:!o,active:l,children:c.jsx($e.button,{type:"button",role:"tab","aria-selected":l,"aria-controls":u,"data-state":l?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:d,...i,ref:t,onMouseDown:Le(e.onMouseDown,f=>{!o&&f.button===0&&f.ctrlKey===!1?s.onValueChange(n):f.preventDefault()}),onKeyDown:Le(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&s.onValueChange(n)}),onFocus:Le(e.onFocus,()=>{const f=s.activationMode!=="manual";!l&&!o&&f&&s.onValueChange(n)})})})});ry.displayName=ty;var ny="TabsContent",oy=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,forceMount:o,children:i,...s}=e,a=Gc(ny,r),d=iy(a.baseId,n),u=sy(a.baseId,n),l=n===a.value,f=b.useRef(l);return b.useEffect(()=>{const p=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(p)},[]),c.jsx(Er,{present:o||l,children:({present:p})=>c.jsx($e.div,{"data-state":l?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":d,hidden:!p,id:u,tabIndex:0,...s,ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0},children:p&&i})})});oy.displayName=ny;function iy(e,t){return`${e}-trigger-${t}`}function sy(e,t){return`${e}-content-${t}`}var rF=Qg,nF=ey,oF=ry,iF=oy;function ay({className:e,...t}){return c.jsx(rF,{"data-slot":"tabs",className:j("flex flex-col gap-2",e),...t})}function ly({className:e,...t}){return c.jsx(nF,{"data-slot":"tabs-list",className:j("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",e),...t})}function cy({className:e,...t}){return c.jsx(oF,{"data-slot":"tabs-trigger",className:j("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 dy({className:e,...t}){return c.jsx(iF,{"data-slot":"tabs-content",className:j("flex-1 outline-none",e),...t})}function dr({className:e="",...t}){return c.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 sF({className:e=""}){return c.jsxs("div",{className:`flex flex-col gap-4 ${e}`.trim(),"data-form-renderer":"workflow-steps-view-skeleton",children:[c.jsxs("div",{className:"flex w-full border-b border-neutral-200 dark:border-neutral-700 gap-0",children:[c.jsx(dr,{className:"h-10 w-24 rounded-none"}),c.jsx(dr,{className:"h-10 w-28 rounded-none ml-1"}),c.jsx(dr,{className:"h-10 w-20 rounded-none ml-1"})]}),c.jsxs("div",{className:"mt-4 flex flex-col gap-4 py-4",children:[c.jsx(dr,{className:"h-4 w-32"}),c.jsx(dr,{className:"h-10 w-full"}),c.jsx(dr,{className:"h-4 w-40"}),c.jsx(dr,{className:"h-10 w-full"}),c.jsx(dr,{className:"h-4 w-36"}),c.jsx(dr,{className:"h-24 w-full"})]})]})}function aF(){return c.jsxs("div",{className:"flex flex-col gap-4 py-4","data-form-renderer":"form-loading-skeleton",children:[c.jsx(dr,{className:"h-4 w-28"}),c.jsx(dr,{className:"h-10 w-full"}),c.jsx(dr,{className:"h-4 w-36"}),c.jsx(dr,{className:"h-10 w-full"}),c.jsx(dr,{className:"h-4 w-24"}),c.jsx(dr,{className:"h-20 w-full"})]})}const lF=3e4,cF=10*6e4,dF=9e4,uF=15*6e4;function fF(e){return e!=null&&"on_success"in e&&e.on_success!=null}function pF(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 uy=({getWorkflowState:e,moduleId:t,tenantId:r,submissionContext:n,initialValues:o={},getAuthHeaders:i,onSuccess:s,bootstrapFeatureId:a,subjectUserId:d,viewStepId:u,clientId:l,className:f,onWorkflowSubmitResult:p,viewerContext:m,getViewerContext:g,dark:h=!1,themeVars:y})=>{const w=vn.useQueryClient(),v=S.useMemo(()=>[d??"",u??"",l??""],[d,u,l]),A=S.useMemo(()=>({moduleId:t,tenantId:r,subjectUserId:d,viewStepId:u,clientId:l}),[t,r,d,u,l]),[C,F]=S.useState([]),[E,T]=S.useState(null),[N,x]=S.useState(null),[O,k]=S.useState(null),[D,R]=S.useState({}),I=S.useRef(null),z=S.useRef(null),L=S.useRef(null),B=S.useRef(null),M=S.useMemo(()=>C&&Array.isArray(C)?C.filter(ae=>ae.feature_id):[],[C]),V=vn.useQuery({queryKey:["workflow-steps",t,a??"",r??"",v[0],v[1],v[2]],queryFn:()=>e({...A,featureId:a}),staleTime:lF,gcTime:cF}),$=V.isPending,ie=V.error?V.error instanceof Error?V.error.message:"Failed to load workflow steps":null;S.useEffect(()=>{const ae=V.data;if(!ae||C.length>0)return;const ve=ae.steps&&Array.isArray(ae.steps)?ae.steps:[];F(ve);const He=ve.filter(dt=>dt.feature_id);if(He.length>0){const dt=ae.current_step_id,Ge=dt&&He.some(Rt=>Rt.step_id===dt);T(Ge?dt:He[0].step_id)}},[V.data,C.length,a]);const H=S.useMemo(()=>{if(!E)return;const ae=C.find(He=>He.step_id===E),ve=I.current===E;return ae?.feature_id??(ve?B.current:void 0)??void 0},[E,C]),K=vn.useQuery({queryKey:["workflow-step",t,H??"",r??"",v[0],v[1],v[2]],queryFn:()=>e({...A,featureId:H}),enabled:!!H,staleTime:dF,gcTime:uF,refetchOnWindowFocus:!0,refetchOnReconnect:!0}),X=K.isPending,le=K.error?K.error instanceof Error?K.error.message:"Failed to load form":null;S.useEffect(()=>{!K.data||I.current===E||(x(K.data),k(null),I.current=null,B.current=null)},[K.data,E]),S.useEffect(()=>{k(le)},[le]),S.useEffect(()=>{H===void 0&&I.current!==E&&(x(null),k(null),I.current=null,B.current=null)},[H,E]);const re=S.useMemo(()=>{const ae=N?.form;if(!ae)return null;const ve=(r??In()??"").trim()||"default",He=Kg({scope:ve,formId:ae._id,version:ae.version});return He?.value?He.value:ZT(N,n)},[N,n,r]),q=S.useMemo(()=>{const ae=N?.BFF_submit_api;if(!ae?.url)return;let ve=ae.url;if(ve.startsWith("http://")||ve.startsWith("https://"))try{const Ge=new URL(ve);ve=Ge.pathname+Ge.search}catch{}const He=i?.()??{},dt={...ae.headers||{},"Content-Type":"application/json",...He};return{...ae,url:ve,headers:dt}},[N?.BFF_submit_api,i]),ne=S.useMemo(()=>re?{...re,status:"published",...q&&{BFF_submit_api:q}}:null,[re,q]);S.useEffect(()=>{if(!re?.id)return;const ae=(r??In()??"").trim()||"default";qg({scope:ae,formId:re.id,version:re.version},re)},[re,r]);const Te=S.useMemo(()=>{if(!re)return null;const ae=Fi({config:re.config,layout:re.layout},null);if(!ae)return null;const ve=ae.rows,He=ae.columns,dt={verticalSpacing:ae.verticalSpacing??ae.spacing??"16px",horizontalSpacing:ae.horizontalSpacing??ae.spacing??"16px",rowHeight:ae.rowHeight??Bn};let Ge=1;if(Array.isArray(re.fields))for(const Je of re.fields){const Y=Je?.position,je=typeof Y?.order=="number"?Y.order:0,gt=typeof Y?.rowSpan=="number"?Y.rowSpan:1;Ge=Math.max(Ge,je+gt)}return{rows:Math.min(ve,Math.max(1,Ge)),columns:He,verticalSpacing:dt.verticalSpacing,horizontalSpacing:dt.horizontalSpacing,rowHeight:dt.rowHeight}},[re]),ee=S.useMemo(()=>{const ve=ne?.config?.theme?.cssVariables;if(!(!ve&&!y))return{...ve??{},...y??{}}},[ne?.config,y]),te=S.useCallback(()=>{w.invalidateQueries({queryKey:["workflow-steps",t]}),w.invalidateQueries({queryKey:["workflow-step",t]})},[w,t]),he=S.useCallback(ae=>{if(fF(ae)){const Ge=ae.on_success,Rt=Ge?.action;if(Rt==="redirect"&&Ge?.redirect_url){const Je=pF(Ge.redirect_url.trim(),n);window.location.href=Je;return}if(Rt==="move"){const Je=Ge?.next_step_id,Y=Ge?.next_step_form;if(Je&&Y){I.current=null,B.current=null;const je=Y.featureId??Ge?.next_step_form_id??Y._id;w.removeQueries({queryKey:["workflow-step",t,je,r??"",v[0],v[1],v[2]]}),te(),F(gt=>gt.some(oe=>oe.step_id===Je)?gt:[...gt,{step_id:Je,step_name:Y.name||"Next step",feature_id:je}]),x(null),T(Je),s?.();return}return}if(Rt==="stay"){te(),s?.();return}}const ve=ae;ve.steps&&Array.isArray(ve.steps)&&F(ve.steps);const He=(ve.steps&&Array.isArray(ve.steps)?ve.steps:C).filter(Ge=>Ge.feature_id),dt=ve.current_step_id;dt&&He.some(Ge=>Ge.step_id===dt)?T(dt):He.length>0&&T(He[0].step_id),x(null),te(),s?.(),p?.(ve)},[w,t,r,s,p,C,n,v,te]),ce=S.useCallback(async ae=>N?.BFF_submit_api?(s?.(),{success:!0,message:"Saved successfully"}):{success:!1,message:"Submit not configured"},[N?.BFF_submit_api,s]),Xe=S.useCallback((ae,ve)=>{},[]),ge=S.useCallback(ae=>{},[]);if($)return c.jsx(sF,{className:f});if(ie)return c.jsx("div",{className:j("rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",f),children:ie});if(M.length===0)return c.jsx("div",{className:j("py-12 text-center text-sm text-muted-foreground",f),children:"No workflow steps configured."});const Se=N?.step_blocked_message;return c.jsx("div",{className:j(Na,h&&"dark","flex flex-col gap-4",f),style:ee,"data-form-renderer":"workflow-steps-view",children:c.jsxs(ay,{value:E??"",onValueChange:ae=>T(ae),children:[c.jsx(ly,{className:"w-full justify-start border-b rounded-none h-auto p-0 bg-transparent gap-0","data-form-renderer":"workflow-tabs",children:M.map(ae=>c.jsx(cy,{value:ae.step_id,className:"rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:shadow-none","data-form-renderer":"workflow-tab",children:ae.step_name},ae.step_id))}),M.map(ae=>c.jsx(dy,{value:ae.step_id,className:"mt-4 outline-none",children:ae.step_id!==E?null:X?c.jsx(aF,{}):O?c.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:O}):Se&&!N?.form?c.jsx("div",{className:j("rounded-lg border border-amber-500/50 bg-amber-500/10 px-4 py-3 text-sm text-amber-800 dark:text-amber-200",f),"data-form-renderer":"workflow-step-blocked",children:Se}):ne?.fields?.length?c.jsxs("div",{className:"py-4 [&_*]:box-border",children:[Se?c.jsx("div",{className:j("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:Se}):null,(()=>{const ve=z.current!==E||L.current!==(ne?.id??null);if(E&&ne&&ve){z.current=E,L.current=ne.id??null;const He=Nt.getState();He.setSchema(ne,{forceReset:!0});const dt=Nt.getState().values;He.setValues({...dt,...o})}return null})(),c.jsx(Wc,{schema:ne,gridLayout:Te,omitRootWrapper:!0,submissionContext:n,initialValues:o,workflowStepId:E??void 0,viewerContext:m,getViewerContext:g,onSubmit:ce,onChange:Xe,onValidationError:ge,onClose:()=>{},mode:"fill",unstyled:!0,onWorkflowSubmitResult:he,initialExtraSubmitPayload:Object.keys(D).length>0?D:void 0,onExtraSubmitPayloadChange:ve=>{if(ve&&typeof ve=="object"){const He={};ve.context_user_id!=null&&(He.context_user_id=ve.context_user_id),ve.id!=null&&(He.id=ve.id),ve.batch_id!=null&&(He.batch_id=ve.batch_id),ve.admission_batch_id!=null&&(He.admission_batch_id=ve.admission_batch_id),ve.program_id!=null&&(He.program_id=ve.program_id),Object.keys(He).length>0&&R(dt=>({...dt,...He}))}}},ne.id)]}):c.jsx("div",{className:"py-8 text-center text-sm text-muted-foreground",children:"No form schema available for this step."})},ae.step_id))]})})};function mF(e){return typeof e=="object"&&e!==null&&"apiEndpoint"in e}function hF({formSchema:e}){const t=S.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((l,f)=>{const p=`field-${l.id}`;if(a.has(l.id)&&i.push({id:`${p}-duplicate-id`,type:"error",message:`Field "${l.label||l.name||`Field ${f+1}`}" has a duplicate ID`,fieldId:l.id}),a.add(l.id),l.name&&s.has(l.name)&&i.push({id:`${p}-duplicate-name`,type:"error",message:`Field "${l.label||l.name}" has a duplicate name: "${l.name}"`,fieldId:l.id}),l.name&&s.add(l.name),(!l.label||l.label.trim()==="")&&i.push({id:`${p}-missing-label`,type:"warning",message:`Field "${l.name||l.id}" is missing a label`,fieldId:l.id}),(!l.name||l.name.trim()==="")&&i.push({id:`${p}-missing-name`,type:"error",message:`Field "${l.label||l.id}" is missing a field name`,fieldId:l.id}),l.name&&!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(l.name)&&i.push({id:`${p}-invalid-name`,type:"error",message:`Field "${l.label||l.name}" has an invalid name. Use only letters, numbers, and underscores.`,fieldId:l.id}),["select","multiselect","radio","checkboxgroup"].includes(l.type)){const h=l.properties;(!h?.options||h.options.length===0)&&i.push({id:`${p}-no-options`,type:"warning",message:`Field "${l.label||l.name}" has no options defined`,fieldId:l.id})}l.parentId&&(e.fields.some(y=>y.id===l.parentId)||i.push({id:`${p}-orphaned`,type:"error",message:`Field "${l.label||l.name}" references a non-existent parent`,fieldId:l.id}));const g=(h,y)=>{if(y.has(h))return!0;y.add(h);const w=e.fields.find(v=>v.id===h);return w?.parentId?g(w.parentId,y):!1};l.parentId&&g(l.id,new Set)&&i.push({id:`${p}-circular-reference`,type:"error",message:`Field "${l.label||l.name}" has a circular parent reference`,fieldId:l.id})}),e.config.workflowTrigger?.workflowId&&(e.fields.some(f=>f.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 d=e.fields.filter(l=>!l.parentId),u=new Map;return d.forEach(l=>{const f=l.position.order;u.has(f)||u.set(f,[]),u.get(f).push(l)}),u.forEach((l,f)=>{l.length>3&&i.push({id:`row-${f}-too-many-fields`,type:"warning",message:`Row ${f+1} has ${l.length} fields (maximum recommended is 3)`})}),i},[e]),r=S.useMemo(()=>t.filter(i=>i.type==="error"),[t]),n=S.useMemo(()=>t.filter(i=>i.type==="warning"),[t]),o=S.useMemo(()=>r.length===0,[r]);return{issues:t,errors:r,warnings:n,isValid:o}}function gF({field:e,value:t,allValues:r,validateOnChange:n=!1,validateOnBlur:o=!0,debounceMs:i=lT}){const[s,a]=S.useState(),[d,u]=S.useState(!1),l=S.useRef(void 0),f=S.useRef(t),p=S.useCallback(async()=>{if(!e.validation||e.validation.length===0){a(void 0);return}u(!0);let w;for(const v of e.validation){const A=Jr(t,v,r);if(typeof A=="string"){w=A;break}}return a(w),u(!1),w},[e.validation,t,r]),m=S.useCallback(()=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{p()},i)},[p,i]);S.useEffect(()=>(n&&f.current!==t&&m(),f.current=t,()=>{l.current&&clearTimeout(l.current)}),[t,n,m]);const g=S.useCallback(()=>{o&&p()},[o,p]),h=S.useCallback(()=>{a(void 0)},[]),y=S.useCallback(w=>{a(w)},[]);return{error:s,isValidating:d,validate:p,handleBlur:g,clearError:h,setCustomError:y}}const fy="—";function qt(){return{kind:"static",value:fy}}function yF(){return{currencySymbol:"₹",emptyDisplay:fy,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:qt(),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:qt(),service:{kind:"api",path:"service"},unit_price:{kind:"api",path:"unit_price"},discount_pct:qt(),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:qt(),unit_price:{kind:"formula",expression:"SUM('unit_price', 'data')"},discount_pct:qt(),discount_amount:{kind:"formula",expression:"SUM('discount_amount', 'data')"},net_price:{kind:"formula",expression:"SUM('net_price', 'data')"},tax_pct:qt(),total:{kind:"formula",expression:"SUM('total', 'data')"}}}},{kind:"static",row:{id:"invoice_discount",label:"Invoice discount",cells:{tariff_type:{kind:"label"},service:qt(),unit_price:qt(),discount_pct:qt(),discount_amount:{kind:"input",inputType:"number"},net_price:qt(),tax_pct:qt(),total:qt()}}},{kind:"static",row:{id:"grand_total",label:"Grand total",cells:{tariff_type:{kind:"label"},service:qt(),unit_price:qt(),discount_pct:qt(),discount_amount:qt(),net_price:qt(),tax_pct:qt(),total:{kind:"formula",expression:"SUM('total', 'data') - cellInRow('invoice_discount', 'discount_amount')"}}}}]}}const bF={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"}},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:yF()}},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"}}}},py={padding:"md",showBorder:!1};function my(e,t){const r="full";return e?{padding:e.padding??py.padding,maxWidth:e.maxWidth??r,showBorder:e.showBorder??py.showBorder}:{padding:"md",maxWidth:r,showBorder:!1}}function vF(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 wF(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 SF(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 xF(e){const t=my(e.container,e.layout);return j(SF(e.layout),wF(t.maxWidth,e.layout),vF(t.padding),t.showBorder&&"rounded-lg border border-border")}const aa=1;function AF(){return{version:aa,layout:"stack",container:{padding:"md",maxWidth:"full",showBorder:!1},dataBindings:[],widgets:[],filterGroups:[]}}function hy(e){return{...e,config:e.config??{},children:Array.isArray(e.children)?e.children.map(hy):void 0}}function CF(e){return{version:aa,layout:e.layout??"stack",container:my(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(hy):[],filterGroups:Array.isArray(e.filterGroups)?e.filterGroups:[],eventHandlers:e.eventHandlers??[],navigation:e.navigation}}function EF(e){const t=e;return!t||typeof t!="object"?AF():(t.version!==aa&&(t.version=aa),CF(t))}const gy={};let yy=null;function NF(e){yy=e}function kF(){return(gy?.VITE_API_BASE_URL?.trim()||gy?.VITE_API_URL?.trim()||"").replace(/\/$/,"")}const Ai=St.create({baseURL:kF()});Ai.interceptors.request.use(e=>{const t=In();t&&(e.params={...e.params,clientId:t}),typeof FormData<"u"&&e.data instanceof FormData&&delete e.headers["Content-Type"];let r=yy?.();if((!r||Object.keys(r).length===0)&&(r=Fs()),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 by(e){const t=await Ai.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 Kc(e,t,r){const n=await Ai.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 qc(e){const{clientId:t,api:r,context:n,filterState:o}=e,i=await Ai.post(`/api/page-builder/clients/${t}/data-sources/execute`,{api:r,context:n,filterState:o});return i.data?.data??i.data}function _F(e,t){if(!t)return{};const r={};for(const[n,o]of Object.entries(t)){if(!o.trim())continue;const i=Qe(e,o);i!==void 0&&(r[n]=i)}return r}const vy=S.createContext(null);function TF(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 wy(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 FF({schema:e,context:t={},clientId:r,nestingDepth:n=0,onAction:o,getWorkflowState:i,parentContext:s,children:a}){const[d,u]=S.useState(()=>s?s.filterGroups:{}),l=S.useRef(d);l.current=d;const[f,p]=S.useState({}),[m,g]=S.useState(()=>TF(e,{parentContext:s,clientIdProp:r,externalContext:t})),h=S.useRef(null),y=String(r??t.clientId??s?.clientId??""),w=JSON.stringify(t);S.useEffect(()=>{if(s)return;const N=e.prepopulateApi;if(!N?.enabled||!N.api?.path||!y){p({}),g("idle"),h.current=null;return}const x=JSON.stringify({path:N.api.path,method:N.api.method,queryParams:N.api.queryParams,headers:N.api.headers,bodyFields:N.api.bodyFields,auth:N.api.auth,mapping:N.contextMapping,bindings:e.dataBindings,context:w});if(h.current===x)return;let O=!1;return h.current=x,g("loading"),(async()=>{try{const k=wy(e.dataBindings??[],t),D={...t,...k},R=await qc({clientId:y,api:N.api,context:D});if(O)return;const I=_F(R,N.contextMapping);p({...I,prepopulateResponse:R}),g("ready")}catch{O||(p({}),g("error"))}})(),()=>{O=!0,h.current=null}},[s,e.prepopulateApi,e.dataBindings,w,y]);const v=S.useMemo(()=>{if(s)return{...s.context,...t};const N=wy(e.dataBindings??[],t);return{...t,...N,...f}},[s,t,e.dataBindings,f]),A=String(r??v.clientId??s?.clientId??""),C=S.useCallback((N,x,O)=>{u(k=>({...k,[N]:{...k[N]??{},[x]:O}}))},[]),F=S.useCallback(N=>l.current[N]??{},[]),E=S.useCallback((N,x,O,k)=>{(o??s?.onAction)?.({...N,sourceWidgetId:x,event:O,payload:k})},[o,s?.onAction]),T=S.useMemo(()=>({schema:e,context:v,clientId:A,prepopulateStatus:s?.prepopulateStatus??m,nestingDepth:n,onAction:o??s?.onAction,getWorkflowState:i??s?.getWorkflowState,filterGroups:d,setFilterValue:C,getFilterGroup:F,dispatchAction:E}),[e,v,A,m,n,o,s?.onAction,i,s?.getWorkflowState,d,C,F,E]);return c.jsx(vy.Provider,{value:T,children:a})}function Mr(){const e=S.useContext(vy);if(!e)throw new Error("usePageContext must be used within PageContextProvider");return e}const PF=5,Sy=1;function Mo(e){return Number.isFinite(e)?Math.min(PF,Math.max(Sy,Math.round(e))):Sy}function OF(e,t){const r=Mo(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 IF(e){return Number.isFinite(e)?Math.min(100,Math.max(0,Math.round(e))):0}function MF(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 xy(e){return MF(100,Mo(e))}function LF(e){const t=e.trim(),r=/^(\d+(?:\.\d+)?)\s*%?$/.exec(t);return r?IF(Number(r[1])):null}function Ay(e,t){const r=Mo(t),n=[];for(let i=0;i<r;i++){const s=LF(e?.[i]??"");if(s===null)return xy(r);n.push(s)}return n.reduce((i,s)=>i+s,0)!==100?xy(r):n}function DF(e){return e==="sm"?"gap-2":e==="lg"?"gap-6":"gap-4"}function Cy(e,t){return Ay(t,Mo(e)).map(n=>`minmax(0, ${n}fr)`).join(" ")}function BF(e){return e.length?e.map(t=>`minmax(0, ${t}fr)`).join(" "):"minmax(0, 1fr)"}function $F(e,t,r,n){const o=Mo(t),i=OF(e,o),s=Ay(r,o);if(!(n?.collapseEmpty!==!1))return{columns:i,gridTemplate:Cy(o,r),sourceIndices:i.map((p,m)=>m)};const d=i.map((p,m)=>({colChildren:p,index:m,percent:s[m]??0})).filter(p=>p.colChildren.length>0);if(d.length===0||d.length===i.length)return{columns:i,gridTemplate:Cy(o,r),sourceIndices:i.map((p,m)=>m)};const u=d.reduce((p,m)=>p+m.percent,0),l=d.map(p=>u>0?Math.round(p.percent/u*100):Math.round(100/d.length)),f=100-l.reduce((p,m)=>p+m,0);return f!==0&&l.length>0&&(l[0]+=f),{columns:d.map(p=>p.colChildren),gridTemplate:BF(l),sourceIndices:d.map(p=>p.index)}}function Yc(e,t="solid"){return e?t==="dashed"?"rounded-md border border-dashed border-border":"rounded-md border border-border":""}function jF(e){return j(Yc(e.showBorder,e.borderStyle??"solid"),e.showBorder&&"p-3")}function zF(e){return j(Yc(e.showBorder,e.borderStyle??"solid"),e.showBorder&&"p-2")}function UF(e,t){return e.columnBorders?.[t]!==void 0?!!e.columnBorders[t]:!!e.showColumnBorders}function VF(e,t){const r=UF(e,t);return j(Yc(r,e.borderStyle??"dashed"),r&&"p-2")}function HF(e){if(e)return{minHeight:`${e}vh`}}function WF({widget:e,renderChildren:t}){const r=e.config,[n,o]=S.useState(r.defaultCollapsed??!1);return c.jsxs("section",{className:j("space-y-4",jF(r)),"data-widget-id":e.id,children:[r.heading&&c.jsx("div",{className:"flex items-center gap-2",children:r.collapsible?c.jsx("button",{type:"button",className:"text-left text-lg font-semibold hover:underline",onClick:()=>o(i=>!i),children:r.heading}):c.jsx("h2",{className:"text-lg font-semibold",children:r.heading})}),r.showDivider&&c.jsx("hr",{className:"border-border"}),!n&&e.children?.length?c.jsx("div",{className:"space-y-4",children:t?.(e.children)}):null]})}function RF({widget:e,renderChildren:t}){const r=e.config,n=Mo(r.columns??2),o=r.collapseEmptyColumns!==!1,i=$F(e.children??[],n,r.columnWidths,{collapseEmpty:o});return c.jsx("div",{className:j("grid w-full min-w-0 items-stretch",DF(r.gap),zF(r)),style:{gridTemplateColumns:i.gridTemplate,...HF(r.minHeightPercent)},"data-widget-id":e.id,children:i.columns.map((s,a)=>{const d=i.sourceIndices[a]??a;return c.jsx("div",{className:j("flex min-h-[inherit] min-w-0 flex-col space-y-4 overflow-hidden",VF(r,d)),children:t?.(s)},d)})})}function GF({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 c.jsxs("div",{className:j("rounded-lg p-4",n),"data-widget-id":e.id,children:[(r.title||r.subtitle)&&c.jsxs("div",{className:"mb-4",children:[r.title&&c.jsx("h3",{className:"font-semibold",children:r.title}),r.subtitle&&c.jsx("p",{className:"text-sm text-muted-foreground",children:r.subtitle})]}),e.children?.length?c.jsx("div",{className:"space-y-4",children:t?.(e.children)}):null]})}function Ey(e,t){if(e.variable){const r=t[e.variable];return r!=null?String(r):e.fallback??e.text??""}return e.text??""}function KF({widget:e}){const t=e.config,{context:r}=Mr(),n=Ey(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 c.jsx("div",{role:"heading","aria-level":o,className:j("font-semibold tracking-tight",s,i),"data-widget-id":e.id,children:n})}function qF({widget:e}){const t=e.config,{context:r}=Mr(),n=Ey(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 c.jsx("p",{className:j(o,i),"data-widget-id":e.id,children:n})}function YF(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 Ny(e,t){const r={...e};for(const[n,o]of Object.entries(r))typeof o=="string"&&(r[n]=YF(o,t));return r}function XF(e,t){return e.replace(/\{\{([^}]+)\}\}/g,(r,n)=>{const o=t[n.trim()];return o!=null?String(o):""})}function ky(e,t,r,n){if(e.type==="navigate"){const o=XF(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?Ny(e.params,t):void 0},n,"click");return}if(e.type==="workflow"&&e.workflowId){r(e,n,"click");return}r(e,n,"click")}function JF({widget:e}){const t=e.config,{context:r,dispatchAction:n}=Mr();return c.jsx(Kt,{variant:t.variant??"default",size:t.size??"default","data-widget-id":e.id,onClick:()=>ky(t.action,r,n,e.id),children:t.label})}const QF={start:"justify-start",center:"justify-center",end:"justify-end","space-between":"justify-between"},ZF={sm:"gap-2",md:"gap-3",lg:"gap-4"};function eP({widget:e}){const t=e.config,{context:r,dispatchAction:n}=Mr(),o=t.buttons??[];return c.jsx("div",{className:j("flex flex-wrap items-center",QF[t.align??"start"],ZF[t.gap??"sm"],t.wrap===!1&&"flex-nowrap"),"data-widget-id":e.id,children:o.map(i=>c.jsx(Kt,{variant:i.variant??"outline",size:i.size??"default","data-widget-id":e.id,"data-button-id":i.id,onClick:()=>ky(i.action,r,n,e.id),children:i.label},i.id))})}function tP(e){const t=e.prepopulateApi;return!!(t?.enabled&&t.api?.path)}function rP(e,t){return e&&(t==="idle"||t==="loading")}function nP(e,t){return!e||t==="ready"||t==="error"}function oP(e,t){const r=Qe(e,t??"");return r===void 0?null:r}function _y(e,t){if(e.mode==="pageApi"&&e.dataSourceRef)return t[e.dataSourceRef];if(e.mode==="api")return e.api}function Ty({widgetId:e,dataSource:t,enabled:r=!0,page:n,pageSize:o,search:i}){const{schema:s,context:a,clientId:d,getFilterGroup:u,prepopulateStatus:l}=Mr(),f=S.useMemo(()=>t.filterGroupKey?u(t.filterGroupKey):{},[t.filterGroupKey,u]),p=t.mode==="context"&&tP(s),m=rP(p,l),g=r&&(t.mode==="static"||(t.mode==="context"?nP(p,l):!!d)),h=S.useMemo(()=>["page-ds",e,t,a,f,n,o,i,l],[e,t,a,f,n,o,i,l]),y=vn.useQuery({queryKey:h,enabled:g,staleTime:_y(t,s.dataApis??{})?.staleTimeMs??3e4,queryFn:async()=>{if(t.mode==="static")return t.staticData;if(t.mode==="context")return oP(a,t.contextPath);const w=_y(t,s.dataApis??{});if(!w)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 E;F.source==="binding"?E=a[F.key]:F.source==="filter"&&(E=f[F.key]),E!==void 0&&(v[F.param]=E)}const C={...Ny(v,a),...n!==void 0?{page:n,pageSize:o,search:i}:{}};return qc({clientId:d,api:w,context:C,filterState:f})}});return{...y,isLoading:y.isLoading||m,isPending:y.isPending||m,isFetching:y.isFetching||m}}function Xc(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 Ci(e,t){const r=Qe(e,t.path);return r==null?t.fallback??r:t.formatter?Xc(r,t.formatter):r}function iP(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 sP={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"},aP={rectangle:"rounded-lg",square:"aspect-square rounded-lg",circle:"aspect-square rounded-full"},lP={sm:"p-2 text-xs",md:"p-4 text-sm",lg:"p-6 text-base"},Jc={sm:"text-lg",md:"text-2xl",lg:"text-3xl"},cP={sm:"gap-2",md:"gap-3",lg:"gap-4"};function dP({title:e,value:t,trend:r,variant:n="default",shape:o="rectangle",size:i="md",layout:s="vertical",isLoading:a,isError:d}){const u=s==="horizontal";return c.jsxs("div",{className:j(sP[n??"default"],aP[o??"rectangle"],lP[i??"md"],u&&"flex items-center justify-between gap-3"),children:[c.jsxs("div",{className:j(u&&"min-w-0"),children:[e&&c.jsx("p",{className:j("font-medium text-muted-foreground",u?"text-sm":""),children:e}),r!=null&&r!==""&&!u&&c.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:String(r)})]}),a?c.jsx(Ln,{className:"my-2"}):d?c.jsx("p",{className:j("font-bold text-destructive",Jc[i??"md"]),children:"Error"}):c.jsx("p",{className:j("font-bold",u?Jc[i??"md"]:`mt-1 ${Jc[i??"md"]}`),children:String(t)}),u&&r!==null&&r!==void 0&&r!==""&&c.jsx("p",{className:"text-xs text-muted-foreground",children:String(r)})]})}function Fy({stat:e,widgetId:t}){const{data:r,isLoading:n,isError:o}=Ty({widgetId:t,dataSource:e.dataSource}),s=(()=>{if(n)return"";if(r==null)return e.valueMapping.fallback??"—";if(e.dataSource.mode==="context"){const d=r;return e.valueMapping.formatter?Xc(d,e.valueMapping.formatter):d}if(e.dataSource.mode==="static"){const d=e.valueMapping.path?.trim()||"value",u=Ci(r,{...e.valueMapping,path:d});if(u!=null)return e.valueMapping.formatter?Xc(u,e.valueMapping.formatter):u;if(typeof r=="object"&&r!==null&&!Array.isArray(r)){const l=r;if(l.value!==void 0&&l.value!==null)return l.value}return e.valueMapping.fallback??"—"}return Ci(r,e.valueMapping)})(),a=e.trendMapping&&r!==void 0&&e.dataSource.mode!=="context"?Ci(r,e.trendMapping):e.trendMapping&&e.dataSource.mode==="context"&&e.trendMapping.path?Ci({value:r},e.trendMapping):null;return c.jsx(dP,{title:e.title,value:s,trend:a,variant:e.variant,shape:e.shape,size:e.size,layout:e.layout,isLoading:n,isError:o})}function uP({widget:e}){const t=e.config;return c.jsx("div",{"data-widget-id":e.id,children:c.jsx(Fy,{stat:t,widgetId:e.id})})}function fP({stat:e,widgetId:t}){return c.jsx(Fy,{stat:e,widgetId:`${t}-${e.id}`})}function pP({widget:e}){const t=e.config,r=t.stats??[],n=t.columns??1,o=t.direction==="horizontal";return c.jsx("div",{"data-widget-id":e.id,className:j(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",cP[t.gap??"md"]),children:r.map(i=>c.jsx(fP,{stat:i,widgetId:e.id},i.id))})}function mP({widget:e}){const t=e.config,{setFilterValue:r}=Mr(),[n,o]=S.useState("");return S.useEffect(()=>{const i=t.debounceMs??300,s=setTimeout(()=>{r(t.filterGroupKey,"search",n)},i);return()=>clearTimeout(s)},[n,t.debounceMs,t.filterGroupKey,r]),c.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 hP(e,t){if(!e)return[];const r=t?Qe(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 gP({widget:e}){const t=e.config,{dispatchAction:r}=Mr(),[n,o]=S.useState(1),[i,s]=S.useState(""),a=t.pagination?.pageSize??10,{data:d,isLoading:u,isError:l}=Ty({widgetId:e.id,dataSource:t.dataSource,page:n,pageSize:a,search:t.search?.enabled?i:void 0}),f=t.dataSource.mode==="pageApi"?void 0:t.dataSource.api?.itemsPath,p=hP(d,f??"data.items"),m=(g,h)=>{const y=t.dataSource.responseMapping.find(w=>w.target===h);return y?Ci(g,y):Qe(g,h)??""};return c.jsxs("div",{className:"space-y-3","data-widget-id":e.id,children:[t.search?.enabled&&c.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:g=>{s(g.target.value),o(1)}}),c.jsx("div",{className:"overflow-x-auto rounded-md border",children:c.jsxs("table",{className:"w-full text-sm",children:[c.jsx("thead",{children:c.jsx("tr",{className:"border-b bg-muted/50",children:t.columns.map(g=>c.jsx("th",{className:j("px-3 py-2 text-left font-medium",g.align==="center"&&"text-center",g.align==="right"&&"text-right"),style:g.width?{width:g.width}:void 0,children:g.header},g.id))})}),c.jsx("tbody",{children:u?c.jsx("tr",{children:c.jsx("td",{colSpan:t.columns.length,className:"px-3 py-8 text-center",children:c.jsx(Ln,{})})}):l?c.jsx("tr",{children:c.jsx("td",{colSpan:t.columns.length,className:"px-3 py-8 text-center text-destructive",children:"Failed to load data"})}):p.length===0?c.jsx("tr",{children:c.jsx("td",{colSpan:t.columns.length,className:"px-3 py-8 text-center text-muted-foreground",children:t.emptyMessage??"No data"})}):p.map((g,h)=>c.jsx("tr",{className:"cursor-pointer border-b hover:bg-muted/30",onClick:()=>{r({type:"emit",eventName:"row_click",payload:{row:g}},e.id,"row_click")},children:t.columns.map(y=>c.jsx("td",{className:j("px-3 py-2",y.align==="center"&&"text-center",y.align==="right"&&"text-right"),children:String(m(g,y.field))},y.id))},h))})]})}),t.pagination?.enabled&&c.jsxs("div",{className:"flex items-center justify-between text-sm",children:[c.jsxs("span",{className:"text-muted-foreground",children:["Page ",n]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx("button",{type:"button",className:"rounded border px-2 py-1 disabled:opacity-50",disabled:n<=1,onClick:()=>o(g=>Math.max(1,g-1)),children:"Previous"}),c.jsx("button",{type:"button",className:"rounded border px-2 py-1",disabled:p.length<a,onClick:()=>o(g=>g+1),children:"Next"})]})]})]})}const yP=75;function bP(e){return e??yP}function vP(e){return e?"rounded-md border border-border p-3":""}function Qc({scrollBehavior:e="page",maxHeightPercent:t,children:r,className:n}){if(e!=="contained")return n?c.jsx("div",{className:n,children:r}):c.jsx(c.Fragment,{children:r});const o=bP(t);return c.jsx("div",{className:j("min-w-0 overflow-y-auto overflow-x-hidden",n),style:{maxHeight:`${o}vh`},"data-form-embed-scroll":"contained",children:r})}function wP(e,t,r){return["embedded-form",e,t,r??"latest"]}async function SP(e,t){try{const r=await pn.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 xP(e,t,r){const n=r!==void 0?`/api/form-builder/forms/${e}/render?version=${r}`:`/api/form-builder/forms/${e}/render`,o=await pn.get(n,{params:{clientId:t}}),s=o.data?.data??o.data,a=s.form??s,d=s.fields??a.fields??[];let u=s.layout??a.layout??null;(!u||typeof u.columns!="number")&&(u=await SP(e,t));const l=s.rules??a.rules??[],f=bi(a,d,u,l),p=Fi({config:f.config,layout:f.layout},Ti(u))??Ti(u);return{schema:f,gridLayout:p}}const AP=300*1e3;function Py({formId:e,mode:t="fill",contextFieldMapping:r,pageContext:n,clientId:o,formVersion:i,scrollBehavior:s,maxHeightPercent:a,showBorder:d}){const{data:u,isLoading:l,isError:f,error:p}=vn.useQuery({queryKey:wP(e,o,i),queryFn:()=>xP(e,o,i),staleTime:AP}),m=S.useMemo(()=>iP(n,r),[n,r]),g=vP(d);return l?c.jsx(Qc,{scrollBehavior:s,maxHeightPercent:a,className:g,children:c.jsx(Ln,{})}):f?c.jsx(Qc,{scrollBehavior:s,maxHeightPercent:a,className:g,children:c.jsx("p",{className:"text-sm text-destructive",children:p instanceof Error?p.message:"Failed to load form"})}):u?.schema?c.jsx(Qc,{scrollBehavior:s,maxHeightPercent:a,className:g,children:c.jsx(Wc,{schema:u.schema,mode:t,gridLayout:u.gridLayout,initialValues:m,submissionContext:n})}):null}function CP({widget:e}){const t=e.config,{context:r,clientId:n}=Mr();return t.formId?c.jsx(Py,{formId:t.formId,mode:t.mode??"fill",contextFieldMapping:t.contextFieldMapping,pageContext:r,clientId:n,scrollBehavior:t.scrollBehavior,maxHeightPercent:t.maxHeightPercent,showBorder:t.showBorder}):c.jsx("p",{className:"text-sm text-muted-foreground",children:"No form configured"})}function EP({widget:e}){const t=e.config,{context:r,getWorkflowState:n,clientId:o}=Mr(),i=String(r.moduleId??"");if(!n)return c.jsxs("div",{className:"rounded-md border border-dashed p-4 text-sm text-muted-foreground","data-widget-id":e.id,children:["Workflow embed requires ",c.jsx("code",{className:"text-xs",children:"getWorkflowState"})," on PageRenderer. Workflow ID: ",t.workflowId]});if(!i)return c.jsx("p",{className:"text-sm text-destructive","data-widget-id":e.id,children:"moduleId required in page context for workflow embed"});const s={};if(t.contextVariableMapping)for(const[a,d]of Object.entries(t.contextVariableMapping)){const u=r[d];u!=null&&(s[a]=String(u))}return c.jsx(uy,{getWorkflowState:n,moduleId:i,tenantId:r.tenantId?String(r.tenantId):void 0,clientId:o||void 0,submissionContext:s})}function NP({widget:e}){const t=e.config,{schema:r,dispatchAction:n}=Mr(),o=t.previousPage??r.navigation?.previousPage,i=t.nextPage??r.navigation?.nextPage,s=t.showPrevious!==!1&&!!o,a=t.showNext!==!1&&!!i,d=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",l=f=>{n({type:"navigate_page",pageId:f.pageId},e.id,"click")};return c.jsxs("nav",{className:"space-y-3","data-widget-id":e.id,children:[d&&c.jsx("ol",{className:"flex flex-wrap items-center gap-1 text-sm text-muted-foreground",children:r.navigation.breadcrumbs.map((f,p)=>c.jsxs("li",{className:"flex items-center gap-1",children:[p>0&&c.jsx("span",{children:"/"}),f.href?c.jsx("a",{href:f.href,className:"hover:underline",children:f.label}):c.jsx("span",{children:f.label})]},p))}),c.jsxs("div",{className:j("flex items-center gap-2",u),children:[s&&o&&c.jsx(Kt,{variant:"outline",size:"sm",onClick:()=>l(o),children:o.label??"Previous"}),a&&i&&c.jsx(Kt,{variant:"default",size:"sm",onClick:()=>l(i),children:i.label??"Next"})]})]})}function kP(e,t){return e?.length?e.filter(r=>r.config.tabId===t):[]}const _P=1;function TP(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 FP(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 PP(e,t,r){return e?new Set(r?[r]:[]):new Set(t.map(n=>n.id))}function OP({tab:e,shouldRender:t,pageContext:r,clientId:n}){return t?e.formId?c.jsx(Py,{formId:e.formId,mode:e.formMode??"fill",contextFieldMapping:e.contextFieldMapping,pageContext:r,clientId:n,scrollBehavior:e.scrollBehavior,maxHeightPercent:e.maxHeightPercent,showBorder:e.showBorder}):c.jsx("p",{className:"text-sm text-muted-foreground",children:"No form configured for this tab"}):null}function IP({tab:e,shouldLoad:t,shouldRender:r,nestingDepth:n,pageContext:o,clientId:i,onAction:s,getWorkflowState:a}){const d=Mr(),{data:u,isLoading:l,isError:f,error:p}=vn.useQuery({queryKey:["tab-page",e.pageId,e.pageVersion,i],enabled:t&&!!e.pageId,queryFn:async()=>Kc(e.pageId,i,e.pageVersion)});return r?n>=_P?c.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?l?c.jsx(Ln,{}):f?c.jsx("p",{className:"text-sm text-destructive",children:p instanceof Error?p.message:"Failed to load page"}):u?c.jsx(Zc,{page:u,context:o,nestingDepth:n+1,inheritContext:!0,onAction:s,getWorkflowState:a,parentContext:d}):null:c.jsx("p",{className:"text-sm text-muted-foreground",children:"No page configured for this tab"}):null}function MP({tab:e,widgetChildren:t,renderChildren:r}){const n=kP(t,e.id);return n.length===0?c.jsx("p",{className:"text-sm text-muted-foreground py-4",children:"No widgets in this tab"}):c.jsx(c.Fragment,{children:r?.(n)})}function LP({widget:e,renderChildren:t}){const r=e.config,{context:n,clientId:o,nestingDepth:i,onAction:s,getWorkflowState:a}=Mr(),d=r.tabs??[],u=r.defaultTabId??d[0]?.id??"",l=r.lazyLoad!==!1,[f,p]=S.useState(u),[m,g]=S.useState(()=>PP(l,d,u)),h=w=>{g(v=>new Set(v).add(w)),p(w)},y=S.useMemo(()=>!l,[l]);return d.length===0?c.jsx("p",{className:"text-sm text-muted-foreground","data-widget-id":e.id,children:"No tabs configured"}):c.jsxs(ay,{value:f,onValueChange:h,className:"w-full","data-widget-id":e.id,children:[c.jsx(ly,{className:j("mb-4",TP(r.variant)),children:d.map(w=>c.jsx(cy,{value:w.id,disabled:w.disabled,className:FP(r.variant),children:w.label},w.id))}),d.map(w=>{const v=m.has(w.id),A=y||v,C=y||v;return c.jsxs(dy,{value:w.id,forceMount:y||void 0,className:j("mt-0",y&&"data-[state=inactive]:hidden"),children:[w.contentType==="widgets"&&C&&c.jsx(MP,{tab:w,widgetChildren:e.children??[],renderChildren:t}),w.contentType==="form"&&c.jsx(OP,{tab:w,shouldRender:A,pageContext:n,clientId:o}),w.contentType==="page"&&c.jsx(IP,{tab:w,shouldLoad:A,shouldRender:C,nestingDepth:i,pageContext:n,clientId:o,onAction:s,getWorkflowState:a})]},w.id)})]})}const DP={section:WF,columns:RF,card:GF,tab_group:LP,heading:KF,text:qF,button:JF,button_group:eP,stat_card:uP,stat_grid:pP,data_table:gP,search_filter:mP,form_embed:CP,workflow_embed:EP,page_nav:NP};function BP({widget:e}){return c.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: ",c.jsx("code",{className:"text-xs",children:e.type}),e.label&&c.jsxs("span",{className:"ml-1",children:["(",e.label,")"]})]})}function $P({widget:e,renderChildren:t}){const r=DP[e.type]??BP;return c.jsx(r,{widget:e,renderChildren:t})}function Oy(e,t){return e.map(r=>c.jsx($P,{widget:r,renderChildren:t},r.id))}function Zc({page:e,context:t={},onAction:r,chrome:n="none",className:o,nestingDepth:i=0,getWorkflowState:s,inheritContext:a=!1,parentContext:d}){const u=S.useMemo(()=>EF(e.schema),[e.schema]),l=p=>Oy(p,l),f=c.jsxs("div",{className:j("studio-page-content min-h-0 min-w-0",xF(u),o),"data-page-id":e.id,"data-nesting-depth":i,children:[n==="minimal"&&u.meta?.title&&c.jsxs("header",{className:"mb-6 border-b pb-4",children:[c.jsx("h1",{className:"text-2xl font-semibold",children:u.meta.title}),u.meta.description&&c.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:u.meta.description})]}),c.jsx("div",{className:"space-y-6",children:Oy(u.widgets,l)})]});return a&&d?f:c.jsx(FF,{schema:u,context:t,clientId:String(t.clientId??""),nestingDepth:i,onAction:r,getWorkflowState:s,parentContext:d,children:f})}function jP({clientId:e,tenantId:t,moduleId:r,featureId:n,pageId:o,routePath:i,routeParams:s={},isDefault:a,context:d={},version:u,chrome:l="none",onAction:f,getWorkflowState:p}){const m=S.useMemo(()=>({...s,...d,clientId:e,tenantId:t,moduleId:r,featureId:n}),[s,d,e,t,r,n]),{data:g,isLoading:h,isError:y,error:w}=vn.useQuery({queryKey:["page-resolve",e,t,r,n,o,i,a,u],queryFn:()=>by({clientId:e,tenantId:t,moduleId:r,featureId:n,routePath:i,isDefault:a,version:u}),enabled:!o}),v=o??g?.pageId,A=u??g?.version,{data:C,isLoading:F,isError:E,error:T}=vn.useQuery({queryKey:["page-render",v,e,A],queryFn:()=>Kc(v,e,A),enabled:!!v});return!o&&h?c.jsx("div",{className:"flex items-center justify-center p-12",children:c.jsx(Ln,{})}):y?c.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm text-destructive",children:w instanceof Error?w.message:"Failed to resolve page"}):v?F?c.jsx("div",{className:"flex items-center justify-center p-12",children:c.jsx(Ln,{})}):E||!C?c.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm text-destructive",children:T instanceof Error?T.message:"Failed to load page"}):c.jsx(Zc,{page:C,context:m,chrome:l,nestingDepth:0,onAction:f,getWorkflowState:p}):c.jsx("div",{className:"rounded-md border p-4 text-sm text-muted-foreground",children:"No page found for the given scope or route."})}be.FIELD_TYPE_REGISTRY=bF,be.FORM_RENDERER_GRID_ROW_HEIGHT_DEFAULT=Bn,be.FORM_RENDERER_ROOT_CLASS=Na,be.FieldRenderer=mn,be.FormRenderer=Wc,be.PageRenderer=Zc,be.RendererFieldLayoutContext=Ba,be.StudioPageHost=jP,be.WorkflowStepsView=uy,be.appearanceControlClasses=Uo,be.appearanceHasExplicitVerticalIntent=$d,be.appearanceTextareaClasses=Td,be.backendToFormSchema=bi,be.cellAlignmentClasses=Vb,be.cellVerticalJustifyClassesForField=Ub,be.effectiveWidthPercent=Mi,be.executeDataSource=qc,be.fetchPageRender=Kc,be.fieldBlockBoxStyle=zb,be.fieldBlockBoxStyleForField=Dd,be.fieldBlockHorizontalPlacementClass=Od,be.fieldBlockHorizontalSelfClass=Id,be.fieldBlockHorizontalSelfClassForField=Bd,be.fieldBlockWidthStyle=Pa,be.fieldBlockWidthStyleForField=Ld,be.fieldGridShellFillsCellVertically=Di,be.formBuilderHttp=pn,be.formLayoutRecordToGridConfig=Ti,be.getBusinessApiOrigin=Dp,be.getClientId=In,be.getRendererHostAuthHeaders=Fs,be.getRendererHostViewerContext=cC,be.getRendererStore=hv,be.gridCellFlexClasses=Pd,be.gridCellFlexClassesForField=Da,be.gridCellOuterFlexClasses=Fd,be.hasExplicitFieldBlockWidth=Md,be.isAsyncSearchFieldProperties=mF,be.isIntrinsicWidthButtonField=no,be.normalizeWorkflowFormSchema=CT,be.normalizeWorkflowFormToRendererSchema=ia,be.pageBuilderHttp=Ai,be.parseContentVerticalAlign=Ia,be.parseMetadataJson=Si,be.resetRendererHostAuth=lC,be.resolveBusinessApiUrl=Wr,be.resolveFormGridLayout=Fi,be.resolvePage=by,be.resolvedGridCellVerticalJustifyClasses=Ho,be.resolvedHorizontalAlign=Tr,be.resolvedVerticalAlign=Vo,be.resolvedVerticalAlignForField=La,be.setBusinessApiOrigin=nC,be.setFormBuilderAuthProvider=UC,be.setPageBuilderAuthProvider=NF,be.setRendererHostAuthHeaders=aC,be.setRendererHostViewerContext=sC,be.useFieldValidation=gF,be.useFormRenderer=Jd,be.useFormValidation=hF,be.useRendererFieldLayout=Wo,be.useRendererHostAuthStore=Yn,Object.defineProperty(be,Symbol.toStringTag,{value:"Module"})}));
|