iq-line-form-builder-renderer 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/form-renderer.es.js +3882 -3818
- package/dist/form-renderer.umd.js +17 -17
- package/dist/pages/systemAdmin/modules/formbuilder/components/fields/BillingGridField.d.ts.map +1 -1
- package/dist/pages/systemAdmin/modules/formbuilder/types/field.d.ts +9 -0
- package/dist/pages/systemAdmin/modules/formbuilder/types/field.d.ts.map +1 -1
- package/dist/pages/systemAdmin/modules/formbuilder/utils/billingGridCalc.d.ts.map +1 -1
- package/dist/pages/systemAdmin/modules/formbuilder/utils/billingGridCellValue.d.ts +12 -0
- package/dist/pages/systemAdmin/modules/formbuilder/utils/billingGridCellValue.d.ts.map +1 -0
- package/dist/pages/systemAdmin/modules/formbuilder/utils/billingGridMergeApi.d.ts +2 -2
- package/dist/pages/systemAdmin/modules/formbuilder/utils/billingGridMergeApi.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(ge,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):(ge=typeof globalThis<"u"?globalThis:ge||self,S(ge.FormBuilderRenderer={},ge.React,ge.jsxRuntime,ge.ReactRouterDOM,ge.ReactDOM,ge.Sonner,ge.ReactQuery))})(this,(function(ge,S,c,pa,Wc,$t,gn){"use strict";function Rc(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=Rc(S),Cs=Rc(Wc),ma="iq-fbr",In="95px";function Es(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:In}}function Ns(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 s=o;return{rows:s.rows,columns:s.columns,verticalSpacing:s.verticalSpacing??s.spacing,horizontalSpacing:s.horizontalSpacing??s.spacing,rowHeight:s.rowHeight,spacing:s.spacing}}return null}function Gc(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=Gc(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function Kc(){for(var e,t,r=0,n="",o=arguments.length;r<o;r++)(e=arguments[r])&&(t=Gc(e))&&(n&&(n+=" "),n+=t);return n}const Cy=(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},Ey=(e,t)=>({classGroupId:e,validator:t}),qc=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),_s="-",Yc=[],Ny="arbitrary..",_y=e=>{const t=Ty(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return ky(i);const a=i.split(_s),d=a[0]===""&&a.length>1?1:0;return Xc(a,d,t)},getConflictingClassGroupIds:(i,a)=>{if(a){const d=n[i],u=r[i];return d?u?Cy(u,d):d:u||Yc}return r[i]||Yc}}},Xc=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const o=e[t],s=r.nextPart.get(o);if(s){const u=Xc(e,t+1,s);if(u)return u}const i=r.validators;if(i===null)return;const a=t===0?e.join(_s):e.slice(t).join(_s),d=i.length;for(let u=0;u<d;u++){const l=i[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?Ny+n:void 0})(),Ty=e=>{const{theme:t,classGroups:r}=e;return Fy(r,t)},Fy=(e,t)=>{const r=qc();for(const n in e){const o=e[n];ha(o,r,n,t)}return r},ha=(e,t,r,n)=>{const o=e.length;for(let s=0;s<o;s++){const i=e[s];Py(i,t,r,n)}},Py=(e,t,r,n)=>{if(typeof e=="string"){Oy(e,t,r);return}if(typeof e=="function"){Iy(e,t,r,n);return}My(e,t,r,n)},Oy=(e,t,r)=>{const n=e===""?t:Jc(t,e);n.classGroupId=r},Iy=(e,t,r,n)=>{if(Ly(e)){ha(e(n),t,r,n);return}t.validators===null&&(t.validators=[]),t.validators.push(Ey(r,e))},My=(e,t,r,n)=>{const o=Object.entries(e),s=o.length;for(let i=0;i<s;i++){const[a,d]=o[i];ha(d,Jc(t,a),r,n)}},Jc=(e,t)=>{let r=e;const n=t.split(_s),o=n.length;for(let s=0;s<o;s++){const i=n[s];let a=r.nextPart.get(i);a||(a=qc(),r.nextPart.set(i,a)),r=a}return r},Ly=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Dy=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=Object.create(null),n=Object.create(null);const o=(s,i)=>{r[s]=i,t++,t>e&&(t=0,n=r,r=Object.create(null))};return{get(s){let i=r[s];if(i!==void 0)return i;if((i=n[s])!==void 0)return o(s,i),i},set(s,i){s in r?r[s]=i:o(s,i)}}},ga="!",Qc=":",By=[],Zc=(e,t,r,n,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:n,isExternal:o}),$y=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=o=>{const s=[];let i=0,a=0,d=0,u;const l=o.length;for(let h=0;h<l;h++){const y=o[h];if(i===0&&a===0){if(y===Qc){s.push(o.slice(d,h)),d=h+1;continue}if(y==="/"){u=h;continue}}y==="["?i++:y==="]"?i--:y==="("?a++:y===")"&&a--}const f=s.length===0?o:o.slice(d);let p=f,m=!1;f.endsWith(ga)?(p=f.slice(0,-1),m=!0):f.startsWith(ga)&&(p=f.slice(1),m=!0);const g=u&&u>d?u-d:void 0;return Zc(s,m,p,g)};if(t){const o=t+Qc,s=n;n=i=>i.startsWith(o)?s(i.slice(o.length)):Zc(By,!1,i,void 0,!0)}if(r){const o=n;n=s=>r({className:s,parseClassName:o})}return n},jy=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((r,n)=>{t.set(r,1e6+n)}),r=>{const n=[];let o=[];for(let s=0;s<r.length;s++){const i=r[s],a=i[0]==="[",d=t.has(i);a||d?(o.length>0&&(o.sort(),n.push(...o),o=[]),n.push(i)):o.push(i)}return o.length>0&&(o.sort(),n.push(...o)),n}},zy=e=>({cache:Dy(e.cacheSize),parseClassName:$y(e),sortModifiers:jy(e),..._y(e)}),Uy=/\s+/,Vy=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:o,sortModifiers:s}=t,i=[],a=e.trim().split(Uy);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,v=n(y?g.substring(0,h):g);if(!v){if(!y){d=l+(d.length>0?" "+d:d);continue}if(v=n(g),!v){d=l+(d.length>0?" "+d:d);continue}y=!1}const w=p.length===0?"":p.length===1?p[0]:s(p).join(":"),x=m?w+ga:w,E=x+v;if(i.indexOf(E)>-1)continue;i.push(E);const P=o(v,y);for(let C=0;C<P.length;++C){const N=P[C];i.push(x+N)}d=l+(d.length>0?" "+d:d)}return d},Hy=(...e)=>{let t=0,r,n,o="";for(;t<e.length;)(r=e[t++])&&(n=ed(r))&&(o&&(o+=" "),o+=n);return o},ed=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=ed(e[n]))&&(r&&(r+=" "),r+=t);return r},Wy=(e,...t)=>{let r,n,o,s;const i=d=>{const u=t.reduce((l,f)=>f(l),e());return r=zy(u),n=r.cache.get,o=r.cache.set,s=a,a(d)},a=d=>{const u=n(d);if(u)return u;const l=Vy(d,r);return o(d,l),l};return s=i,(...d)=>s(Hy(...d))},Ry=[],Rt=e=>{const t=r=>r[e]||Ry;return t.isThemeGetter=!0,t},td=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,rd=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Gy=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Ky=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,qy=/\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$/,Yy=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Xy=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Jy=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,yn=e=>Gy.test(e),it=e=>!!e&&!Number.isNaN(Number(e)),bn=e=>!!e&&Number.isInteger(Number(e)),ya=e=>e.endsWith("%")&&it(e.slice(0,-1)),nn=e=>Ky.test(e),nd=()=>!0,Qy=e=>qy.test(e)&&!Yy.test(e),ba=()=>!1,Zy=e=>Xy.test(e),eb=e=>Jy.test(e),tb=e=>!_e(e)&&!ke(e),rb=e=>vn(e,cd,ba),_e=e=>td.test(e),Mn=e=>vn(e,dd,Qy),od=e=>vn(e,db,it),nb=e=>vn(e,fd,nd),ob=e=>vn(e,ud,ba),sd=e=>vn(e,ad,ba),sb=e=>vn(e,ld,eb),ks=e=>vn(e,pd,Zy),ke=e=>rd.test(e),Lo=e=>Ln(e,dd),ib=e=>Ln(e,ud),id=e=>Ln(e,ad),ab=e=>Ln(e,cd),lb=e=>Ln(e,ld),Ts=e=>Ln(e,pd,!0),cb=e=>Ln(e,fd,!0),vn=(e,t,r)=>{const n=td.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},Ln=(e,t,r=!1)=>{const n=rd.exec(e);return n?n[1]?t(n[1]):r:!1},ad=e=>e==="position"||e==="percentage",ld=e=>e==="image"||e==="url",cd=e=>e==="length"||e==="size"||e==="bg-size",dd=e=>e==="length",db=e=>e==="number",ud=e=>e==="family-name",fd=e=>e==="number"||e==="weight",pd=e=>e==="shadow",ub=Wy(()=>{const e=Rt("color"),t=Rt("font"),r=Rt("text"),n=Rt("font-weight"),o=Rt("tracking"),s=Rt("leading"),i=Rt("breakpoint"),a=Rt("container"),d=Rt("spacing"),u=Rt("radius"),l=Rt("shadow"),f=Rt("inset-shadow"),p=Rt("text-shadow"),m=Rt("drop-shadow"),g=Rt("blur"),h=Rt("perspective"),y=Rt("aspect"),v=Rt("ease"),w=Rt("animate"),x=()=>["auto","avoid","all","avoid-page","page","left","right","column"],E=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],P=()=>[...E(),ke,_e],C=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto","contain","none"],_=()=>[ke,_e,d],A=()=>[yn,"full","auto",..._()],I=()=>[bn,"none","subgrid",ke,_e],T=()=>["auto",{span:["full",bn,ke,_e]},bn,ke,_e],U=()=>[bn,"auto",ke,_e],Q=()=>["auto","min","max","fr",ke,_e],O=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],j=()=>["start","end","center","stretch","center-safe","end-safe"],L=()=>["auto",..._()],D=()=>[yn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",..._()],M=()=>[yn,"screen","full","dvw","lvw","svw","min","max","fit",..._()],R=()=>[yn,"screen","full","lh","dvh","lvh","svh","min","max","fit",..._()],$=()=>[e,ke,_e],ie=()=>[...E(),id,sd,{position:[ke,_e]}],V=()=>["no-repeat",{repeat:["","x","y","space","round"]}],K=()=>["auto","cover","contain",ab,rb,{size:[ke,_e]}],X=()=>[ya,Lo,Mn],ce=()=>["","none","full",u,ke,_e],ne=()=>["",it,Lo,Mn],G=()=>["solid","dashed","dotted","double"],ee=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Pe=()=>[it,ya,id,sd],oe=()=>["","none",g,ke,_e],re=()=>["none",it,ke,_e],be=()=>["none",it,ke,_e],de=()=>[it,ke,_e],ot=()=>[yn,"full",..._()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[nn],breakpoint:[nn],color:[nd],container:[nn],"drop-shadow":[nn],ease:["in","out","in-out"],font:[tb],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[nn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[nn],shadow:[nn],spacing:["px",it],text:[nn],"text-shadow":[nn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",yn,_e,ke,y]}],container:["container"],columns:[{columns:[it,_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:C()}],"overflow-x":[{"overflow-x":C()}],"overflow-y":[{"overflow-y":C()}],overscroll:[{overscroll:N()}],"overscroll-x":[{"overscroll-x":N()}],"overscroll-y":[{"overscroll-y":N()}],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:[bn,"auto",ke,_e]}],basis:[{basis:[yn,"full","auto",a,..._()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[it,yn,"auto","initial","none",_e]}],grow:[{grow:["",it,ke,_e]}],shrink:[{shrink:["",it,ke,_e]}],order:[{order:[bn,"first","last","none",ke,_e]}],"grid-cols":[{"grid-cols":I()}],"col-start-end":[{col:T()}],"col-start":[{"col-start":U()}],"col-end":[{"col-end":U()}],"grid-rows":[{"grid-rows":I()}],"row-start-end":[{row:T()}],"row-start":[{"row-start":U()}],"row-end":[{"row-end":U()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":Q()}],"auto-rows":[{"auto-rows":Q()}],gap:[{gap:_()}],"gap-x":[{"gap-x":_()}],"gap-y":[{"gap-y":_()}],"justify-content":[{justify:[...O(),"normal"]}],"justify-items":[{"justify-items":[...j(),"normal"]}],"justify-self":[{"justify-self":["auto",...j()]}],"align-content":[{content:["normal",...O()]}],"align-items":[{items:[...j(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...j(),{baseline:["","last"]}]}],"place-content":[{"place-content":O()}],"place-items":[{"place-items":[...j(),"baseline"]}],"place-self":[{"place-self":["auto",...j()]}],p:[{p:_()}],px:[{px:_()}],py:[{py:_()}],ps:[{ps:_()}],pe:[{pe:_()}],pbs:[{pbs:_()}],pbe:[{pbe:_()}],pt:[{pt:_()}],pr:[{pr:_()}],pb:[{pb:_()}],pl:[{pl:_()}],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":_()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":_()}],"space-y-reverse":["space-y-reverse"],size:[{size:D()}],"inline-size":[{inline:["auto",...M()]}],"min-inline-size":[{"min-inline":["auto",...M()]}],"max-inline-size":[{"max-inline":["none",...M()]}],"block-size":[{block:["auto",...R()]}],"min-block-size":[{"min-block":["auto",...R()]}],"max-block-size":[{"max-block":["none",...R()]}],w:[{w:[a,"screen",...D()]}],"min-w":[{"min-w":[a,"screen","none",...D()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[i]},...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,Lo,Mn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,cb,nb]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",ya,_e]}],"font-family":[{font:[ib,ob,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":[it,"none",ke,od]}],leading:[{leading:[s,..._()]}],"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:$()}],"text-color":[{text:$()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...G(),"wavy"]}],"text-decoration-thickness":[{decoration:[it,"from-font","auto",ke,Mn]}],"text-decoration-color":[{decoration:$()}],"underline-offset":[{"underline-offset":[it,"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:_()}],"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:ie()}],"bg-repeat":[{bg:V()}],"bg-size":[{bg:K()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},bn,ke,_e],radial:["",ke,_e],conic:[bn,ke,_e]},lb,sb]}],"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:ce()}],"rounded-s":[{"rounded-s":ce()}],"rounded-e":[{"rounded-e":ce()}],"rounded-t":[{"rounded-t":ce()}],"rounded-r":[{"rounded-r":ce()}],"rounded-b":[{"rounded-b":ce()}],"rounded-l":[{"rounded-l":ce()}],"rounded-ss":[{"rounded-ss":ce()}],"rounded-se":[{"rounded-se":ce()}],"rounded-ee":[{"rounded-ee":ce()}],"rounded-es":[{"rounded-es":ce()}],"rounded-tl":[{"rounded-tl":ce()}],"rounded-tr":[{"rounded-tr":ce()}],"rounded-br":[{"rounded-br":ce()}],"rounded-bl":[{"rounded-bl":ce()}],"border-w":[{border: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:[...G(),"hidden","none"]}],"divide-style":[{divide:[...G(),"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:[...G(),"none","hidden"]}],"outline-offset":[{"outline-offset":[it,ke,_e]}],"outline-w":[{outline:["",it,Lo,Mn]}],"outline-color":[{outline:$()}],shadow:[{shadow:["","none",l,Ts,ks]}],"shadow-color":[{shadow:$()}],"inset-shadow":[{"inset-shadow":["none",f,Ts,ks]}],"inset-shadow-color":[{"inset-shadow":$()}],"ring-w":[{ring:ne()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:$()}],"ring-offset-w":[{"ring-offset":[it,Mn]}],"ring-offset-color":[{"ring-offset":$()}],"inset-ring-w":[{"inset-ring":ne()}],"inset-ring-color":[{"inset-ring":$()}],"text-shadow":[{"text-shadow":["none",p,Ts,ks]}],"text-shadow-color":[{"text-shadow":$()}],opacity:[{opacity:[it,ke,_e]}],"mix-blend":[{"mix-blend":[...ee(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ee()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[it]}],"mask-image-linear-from-pos":[{"mask-linear-from":Pe()}],"mask-image-linear-to-pos":[{"mask-linear-to":Pe()}],"mask-image-linear-from-color":[{"mask-linear-from":$()}],"mask-image-linear-to-color":[{"mask-linear-to":$()}],"mask-image-t-from-pos":[{"mask-t-from":Pe()}],"mask-image-t-to-pos":[{"mask-t-to":Pe()}],"mask-image-t-from-color":[{"mask-t-from":$()}],"mask-image-t-to-color":[{"mask-t-to":$()}],"mask-image-r-from-pos":[{"mask-r-from":Pe()}],"mask-image-r-to-pos":[{"mask-r-to":Pe()}],"mask-image-r-from-color":[{"mask-r-from":$()}],"mask-image-r-to-color":[{"mask-r-to":$()}],"mask-image-b-from-pos":[{"mask-b-from":Pe()}],"mask-image-b-to-pos":[{"mask-b-to":Pe()}],"mask-image-b-from-color":[{"mask-b-from":$()}],"mask-image-b-to-color":[{"mask-b-to":$()}],"mask-image-l-from-pos":[{"mask-l-from":Pe()}],"mask-image-l-to-pos":[{"mask-l-to":Pe()}],"mask-image-l-from-color":[{"mask-l-from":$()}],"mask-image-l-to-color":[{"mask-l-to":$()}],"mask-image-x-from-pos":[{"mask-x-from":Pe()}],"mask-image-x-to-pos":[{"mask-x-to":Pe()}],"mask-image-x-from-color":[{"mask-x-from":$()}],"mask-image-x-to-color":[{"mask-x-to":$()}],"mask-image-y-from-pos":[{"mask-y-from":Pe()}],"mask-image-y-to-pos":[{"mask-y-to":Pe()}],"mask-image-y-from-color":[{"mask-y-from":$()}],"mask-image-y-to-color":[{"mask-y-to":$()}],"mask-image-radial":[{"mask-radial":[ke,_e]}],"mask-image-radial-from-pos":[{"mask-radial-from":Pe()}],"mask-image-radial-to-pos":[{"mask-radial-to":Pe()}],"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":E()}],"mask-image-conic-pos":[{"mask-conic":[it]}],"mask-image-conic-from-pos":[{"mask-conic-from":Pe()}],"mask-image-conic-to-pos":[{"mask-conic-to":Pe()}],"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:V()}],"mask-size":[{mask:K()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ke,_e]}],filter:[{filter:["","none",ke,_e]}],blur:[{blur:oe()}],brightness:[{brightness:[it,ke,_e]}],contrast:[{contrast:[it,ke,_e]}],"drop-shadow":[{"drop-shadow":["","none",m,Ts,ks]}],"drop-shadow-color":[{"drop-shadow":$()}],grayscale:[{grayscale:["",it,ke,_e]}],"hue-rotate":[{"hue-rotate":[it,ke,_e]}],invert:[{invert:["",it,ke,_e]}],saturate:[{saturate:[it,ke,_e]}],sepia:[{sepia:["",it,ke,_e]}],"backdrop-filter":[{"backdrop-filter":["","none",ke,_e]}],"backdrop-blur":[{"backdrop-blur":oe()}],"backdrop-brightness":[{"backdrop-brightness":[it,ke,_e]}],"backdrop-contrast":[{"backdrop-contrast":[it,ke,_e]}],"backdrop-grayscale":[{"backdrop-grayscale":["",it,ke,_e]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[it,ke,_e]}],"backdrop-invert":[{"backdrop-invert":["",it,ke,_e]}],"backdrop-opacity":[{"backdrop-opacity":[it,ke,_e]}],"backdrop-saturate":[{"backdrop-saturate":[it,ke,_e]}],"backdrop-sepia":[{"backdrop-sepia":["",it,ke,_e]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":_()}],"border-spacing-x":[{"border-spacing-x":_()}],"border-spacing-y":[{"border-spacing-y":_()}],"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:[it,"initial",ke,_e]}],ease:[{ease:["linear","initial",v,ke,_e]}],delay:[{delay:[it,ke,_e]}],animate:[{animate:["none",w,ke,_e]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[h,ke,_e]}],"perspective-origin":[{"perspective-origin":P()}],rotate:[{rotate:re()}],"rotate-x":[{"rotate-x":re()}],"rotate-y":[{"rotate-y":re()}],"rotate-z":[{"rotate-z":re()}],scale:[{scale:be()}],"scale-x":[{"scale-x":be()}],"scale-y":[{"scale-y":be()}],"scale-z":[{"scale-z":be()}],"scale-3d":["scale-3d"],skew:[{skew:de()}],"skew-x":[{"skew-x":de()}],"skew-y":[{"skew-y":de()}],transform:[{transform:[ke,_e,"","none","gpu","cpu"]}],"transform-origin":[{origin:P()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ot()}],"translate-x":[{"translate-x":ot()}],"translate-y":[{"translate-y":ot()}],"translate-z":[{"translate-z":ot()}],"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",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":_()}],"scroll-mx":[{"scroll-mx":_()}],"scroll-my":[{"scroll-my":_()}],"scroll-ms":[{"scroll-ms":_()}],"scroll-me":[{"scroll-me":_()}],"scroll-mbs":[{"scroll-mbs":_()}],"scroll-mbe":[{"scroll-mbe":_()}],"scroll-mt":[{"scroll-mt":_()}],"scroll-mr":[{"scroll-mr":_()}],"scroll-mb":[{"scroll-mb":_()}],"scroll-ml":[{"scroll-ml":_()}],"scroll-p":[{"scroll-p":_()}],"scroll-px":[{"scroll-px":_()}],"scroll-py":[{"scroll-py":_()}],"scroll-ps":[{"scroll-ps":_()}],"scroll-pe":[{"scroll-pe":_()}],"scroll-pbs":[{"scroll-pbs":_()}],"scroll-pbe":[{"scroll-pbe":_()}],"scroll-pt":[{"scroll-pt":_()}],"scroll-pr":[{"scroll-pr":_()}],"scroll-pb":[{"scroll-pb":_()}],"scroll-pl":[{"scroll-pl":_()}],"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",...$()]}],"stroke-w":[{stroke:[it,Lo,Mn,od]}],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 B(...e){return ub(Kc(e))}const fb=["richtext","multiselect","radio","checkboxgroup","signature"],pb=3;function Do(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(pb,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 fb.includes(e.type)?Math.max(t,2):t}function md(e,t){if(e.type==="table"||e.type==="billingGrid"){const s=e.position.columnSpan??t??1;return t!=null?Math.min(s,t):s}if(e.type!=="radio"&&e.type!=="checkboxgroup"){const s=e.position.columnSpan??1;return t!=null?Math.min(s,t):s}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 Bo(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 hd(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 mb(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 hb(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 gb(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 Fs(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 va(e){const t=Fs(e);return{width:t>=100?"100%":`${t}%`,maxWidth:"100%"}}function yb(e){return va(e)}function wa(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t==="start"||t==="center"||t==="end"||t==="stretch"?t:null}function Sa(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t==="start"||t==="center"||t==="end"?t:null}function Fr(e){if(!e)return"start";const t=wa(e.horizontalAlign);if(t)return t;const r=wa(e.contentAlign);if(r)return r;const n=wa(e.cellAlign);return n||"start"}function $o(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 Ps(e){switch(e){case"center":return"items-center";case"end":return"items-end";case"stretch":return"items-stretch";default:return"items-start"}}function xa(e){switch(e){case"center":return"justify-center";case"end":return"justify-end";case"stretch":return"justify-stretch";default:return"justify-start"}}function jo(e){const t=Sa(e.appearance?.contentVerticalAlign);if(t!==null)switch(t){case"center":return"justify-center";case"end":return"justify-end";default:return"justify-start"}return xa(Aa(e))}const bb=jo;function Os(e){if(e.type==="billingGrid"||e.type==="table"||Do(e)>1)return!0;const t=Sa(e.appearance?.contentVerticalAlign);if(t==="center"||t==="end")return!1;if(t==="start")return!0;const r=Aa(e);return r!=="center"&&r!=="end"}function gd(e){const t=e[0];if(!t)return Ca(void 0);if(e.length===1)return Ca(t);const r=Fr(t.appearance);return B("flex flex-col min-h-0 h-full w-full",Ps(r),"justify-start")}function yd(e){const t=Fr(e),r=$o(e);return B("flex flex-col min-h-0 h-full w-full",Ps(t),xa(r))}function bd(e){if(Fs(e)>=100)return"";const r=Fr(e);return r==="center"?"mx-auto":r==="end"?"ml-auto":""}function vd(e){if(Fs(e)>=100)return"w-full";const r=Fr(e);return r==="center"||r==="end"?"min-w-0":r==="stretch"?"min-w-0 self-stretch":"min-w-0 self-start"}function wd(e){return e?e.widthMode==="full"||e.widthMode==="percent"||typeof e.widthPercent=="number"&&!Number.isNaN(e.widthPercent):!1}function to(e){return(e.type==="button"||e.type==="editButton")&&!wd(e.appearance)}function Sd(e){return to(e)?Fr(e.appearance)==="stretch"?{width:"100%",maxWidth:"100%",minWidth:0}:{width:"auto",maxWidth:"100%"}:va(e.appearance)}function xd(e){return Sd(e)}function Ad(e){if(to(e))switch(Fr(e.appearance)){case"center":return"self-center";case"end":return"self-end";case"stretch":return"self-stretch";default:return"self-start"}return vd(e.appearance)}function Cd(e){return e?e.verticalAlign!=null||e.cellJustify!=null:!1}function Aa(e){return e.type!=="button"&&e.type!=="editButton"||Cd(e.appearance)?$o(e.appearance):"start"}function Ca(e){if(!e)return yd(void 0);const t=Fr(e.appearance);return B("flex flex-col min-h-0 h-full w-full",Ps(t),jo(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 B(Ps(Fr(o)),xa($o(o)))}const Ea=S.createContext({gridStretch:!1});function zo(){return S.useContext(Ea)}const Ed=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},wb=(e=>e?Ed(e):Ed),Sb=e=>e;function xb(e,t=Sb){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 Nd=e=>{const t=wb(e),r=n=>xb(t,n);return Object.assign(r,t),r},_d=(e=>e?Nd(e):Nd),Ab=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Cb=/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/,Eb=/^\+?[\d\s-()]{10,}$/,Nb={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:Ab.test(e),url:e=>typeof e!="string"||!e?!0:Cb.test(e),phone:e=>typeof e!="string"||!e?!0:Eb.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 s=n.min==="today"?o:new Date(n.min);if(r<s)return!1}if(n.max){const s=n.max==="today"?o:new Date(n.max);if(r>s)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=s=>r.some(i=>{if(i.endsWith("/*")){const u=i.replace("/*","");if(s.type.startsWith(u))return!0}else if(s.type===i)return!0;const a=s.name.toLowerCase(),d=n[i];return d?d.some(u=>a.endsWith(u)):i.startsWith(".")?a.endsWith(i.toLowerCase()):!1});return e instanceof File?o(e):Array.isArray(e)?e.every(s=>o(s)):!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 Yr(e,t,r={}){const n=Nb[t.type];if(!n)return!0;const o=n(e,t,r);return o===!1?t.message||_b(t):typeof o=="string"?o:!0}function _b(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 Tb=10;function Is(e){const t=e.properties;return t?.maxFiles!=null&&t.maxFiles>0?Math.floor(t.maxFiles):t?.multiple===!0?Tb:1}function kd(e){return typeof e=="object"&&e!==null&&"url"in e&&typeof e.url=="string"&&e.url.length>0}function Td(e){try{return e.split("?")[0].split("/").filter(Boolean).pop()||e}catch{return e}}function Ms(e){if(e==null)return[];if(typeof e=="string")return e.startsWith("http")?[{url:e,name:Td(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:Td(r)}):kd(r)&&t.push(r);return t}return kd(e)?[e]:[]}function Fb(e,t){return e.slice(0,t)}function Na(e,t){const r=Fb(e,t);return r.length===0?null:t===1?r[0]??null:r}function Pb(e){return Ms(e).length}function Ob(e){return e==="file"||e==="camera"||e==="photoChoice"}function _a(e,t){if(!Ob(e.type))return;const r=Is(e);if(Pb(t)>r)return`Maximum ${r} file(s) allowed`}class Ls{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),s=Number(r),i=n!==void 0?Number(n):void 0;return o.substring(s,i!==void 0?s+i: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),s=new Date(r);if(isNaN(o.getTime())||isNaN(s.getTime()))return null;const a=(s.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,s)=>{if(typeof s=="object"&&s!==null){const i=s[n];return o+(Number(i)||0)}return o},0)}};calculate(t,r){try{const{fields:n,currentValue:o,previousValue:s}=r,i={...n};for(const f in i){const p=i[f];(p==null||p==="")&&(i[f]="")}const a={fields:i,currentValue:o,previousValue:s,...Ls.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 s={fields:n,currentValue:n[o.field],previousValue:r[o.field]},i=this.calculate(o.formula,s);n[o.field]=i===null?"":i}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 Fd=new Ls;function Pd(e){if(e==null||e==="")return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:Ds(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:Ds(n)}return null}function Ds(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function Ib(e,t=new Date){const r=Ds(e),n=Ds(t);if(n<r)return{years:0,months:0,days:0};let o=n.getFullYear()-r.getFullYear(),s=n.getMonth()-r.getMonth(),i=n.getDate()-r.getDate();if(i<0){s-=1;const a=new Date(n.getFullYear(),n.getMonth(),0).getDate();i+=a}return s<0&&(o-=1,s+=12),{years:Math.max(0,o),months:Math.max(0,s),days:Math.max(0,i)}}function ka(e){if(e.type!=="number")return;const t=e.properties?.deriveFromDate;if(!(!t?.sourceFieldName||!t.part))return t}function Pr(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(0,t):e}function Ta(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(t):null}function Mb(e,t){const r=Ta(e);return r?`${t.sourceFieldName}${r}`:t.sourceFieldName}function Od(e,t,r){const n=Ta(t);if(n)return[`${e}${n}`];const o=new Set([e]),s=`${e}__addmore__`;for(const i of Object.keys(r))(i===e||i.startsWith(s))&&o.add(i);return[...o]}function Lb(e,t,r){const n=r?Mb(r,e):e.sourceFieldName,o=Pd(t[n]);if(!o)return null;const s=e.referenceDate==="today"||e.referenceDate==null?new Date:Pd(t[e.referenceDate])??new Date;return Ib(o,s)[e.part]}function Id(e,t){const r=ka(e);return r?Pr(r.sourceFieldName)===Pr(t):!1}function Fa(e,t,r,n){const o={...t},s=n?Pr(n):void 0;for(const i of e){if(i.type!=="number")continue;const a=ka(i);if(!a||!i.name||s&&Pr(a.sourceFieldName)!==s)continue;const d=n??a.sourceFieldName,u=Od(i.name,d,o);for(const l of u){if(r.has(l))continue;const f=Lb(a,o,l);o[l]=f}}return o}function Db(e,t,r,n){const o={...t},s=Pr(n);for(const i of e){if(!Id(i,s)||!i.name)continue;const a=Od(i.name,n,o);for(const d of a)r.delete(d),o[d]=null}return o}function Md(e,t){const r=Pr(t);return e.some(n=>Id(n,r))}function Ld(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 Bb(e,t,r,n){let o=Pa(e,r);return n&&(o=Dn(o,t,r)),o}function Pa(e,t){return e.replace(/\{(?:ctx:|\@)(\w+)\}/g,(r,n)=>t?.[n]!==void 0&&t[n]!==null?String(t[n]):r)}function Dn(e,t,r){let n=e.replace(/\{(?:ctx:|\@)(\w+)\}/g,(o,s)=>r?.[s]!==void 0&&r[s]!==null?String(r[s]):o);return n=n.replace(/\{(\w+)\}/g,(o,s)=>{if(o.includes("ctx:")||o.includes("@"))return o;let i=t[s];if(i==null||i===""){const a=Object.keys(t).find(d=>d.toLowerCase()===s.toLowerCase());a&&(i=t[a])}return i!=null&&i!==""?String(i):o}),n}function Bs(e,t){const r=e.match(/\{(\w+)\}/g)||[],n=[];t?.custom&&t.custom.forEach(({value:s})=>{if(s){const i=s.match(/\{(\w+)\}/g)||[];n.push(...i.filter(a=>!a.includes("ctx:")&&!a.includes("@")))}});const o=r.filter(s=>!s.includes("ctx:")&&!s.includes("@"));return new Set([...o.map(s=>s.replace(/[{}]/g,"")),...n.map(s=>s.replace(/[{}]/g,""))])}function $b(e,t){const r=e[t];return r==null||r===""}function Dd(e){const{apiEndpoint:t,apiMethod:r="GET",apiQueryParams:n={},formValues:o,submissionContext:s,apiRealtime:i,additionalRequiredFieldNames:a=[],excludeFormFieldNames:d=[]}=e,u=(r||"GET").toLowerCase(),l=Bs(t,n),f=new Set((d||[]).filter(w=>typeof w=="string"&&w.length>0)),p=new Set((a||[]).filter(w=>typeof w=="string"&&w.length>0)),m=new Set([...l,...p]);let g=!1;for(const w of m){const x=!!(i&&l.has(w)),E=p.has(w);if((x||E)&&$b(o,w)){g=!0;break}}if(g)return{blocked:!0,url:t,postBodyBase:null};let h=t;const y=t.match(/\{(\w+)\}/g)||[];if(h=Pa(h,s),i&&(h=Dn(h,o,s)),n&&Object.keys(n).length>0){const w=n,x=[];if(w.limit){let E=w.limit;i&&(E=Dn(E,o,s)),x.push(`_limit=${encodeURIComponent(E)}`)}if(w.page){let E=w.page;i&&(E=Dn(E,o,s)),x.push(`page=${encodeURIComponent(E)}`)}if(w.sort){let E=w.sort;i&&(E=Dn(E,o,s)),x.push(`sort=${encodeURIComponent(E)}`)}if(w.orderBy){let E=w.orderBy;i&&(E=Dn(E,o,s)),x.push(`orderBy=${encodeURIComponent(E)}`)}if(w.custom?.length&&w.custom.forEach(({key:E,value:P})=>{if(!E||!P)return;let C=Pa(P,s);i&&(C=Dn(C,o,s)),C.match(/\{[^}]+\}/)?C.match(/\{(?!ctx:|\@)(\w+)\}/g)||x.push(`${encodeURIComponent(E)}=`):x.push(`${encodeURIComponent(E)}=${encodeURIComponent(C)}`)}),x.length>0){const E=h.includes("?")?"&":"?";h=`${h}${E}${x.join("&")}`}}if(i&&Object.keys(o).length>0&&u==="get"){const w=C=>C.replace(/\{/g,"").replace(/\}/g,""),x=[];for(const C of n.custom||[])if(C.value){const N=C.value.match(/\{(\w+)\}/g)||[];x.push(...N.map(w))}const E=new Set([...y.map(w),...x]),P={};Object.keys(o).forEach(C=>{!E.has(C)&&!f.has(C)&&(P[C]=o[C])}),Object.keys(P).length>0&&(h=`${h}${h.includes("?")?"&":"?"}${new URLSearchParams(P).toString()}`)}let v=null;if(["post","put","patch"].includes(u))if(i&&Object.keys(o).length>0){v={...o};for(const w of f)delete v[w]}else{v={...o||{}};for(const w of f)delete v[w]}return{blocked:!1,url:h,postBodyBase:v}}const jb=new Set(["select","multiselect","asyncsearch"]);function zb(e){return e?.type==="multiselect"?[]:""}function Bd(e){if(!jb.has(e.type))return[];const t=e.properties??{},r=Ld(e),n=new Set,o=r?.apiClientFilter?.matchField?.trim()||t.apiClientFilter?.matchField?.trim();o&&n.add(o);const s=[...Array.isArray(t.dependentFields)?t.dependentFields:[],...Array.isArray(r?.dependentFields)?r.dependentFields:[]];for(const u of s)typeof u=="string"&&u.trim()&&n.add(u.trim());const i=r?.apiEndpoint||t.apiEndpoint,a=r?.apiRealtime??t.apiRealtime,d=r?.apiQueryParams||t.apiQueryParams;if(i&&a)for(const u of Bs(i,d))n.add(u);return[...n]}function Ub(e,t){const r=Pr(t);return Bd(e).some(n=>Pr(n)===r)}function Vb(e,t){const r=Pr(t);return e.some(n=>Ub(n,r))}function Hb(e){const t=new Map;for(const r of e){const n=r.name;if(n)for(const o of Bd(r)){const s=Pr(o),i=t.get(s)??new Set;i.add(n),t.set(s,i)}}return t}function Wb(e,t,r){const n=Ta(t);if(n)return[`${e}${n}`];const o=new Set([e]),s=`${e}__addmore__`;for(const i of Object.keys(r))(i===e||i.startsWith(s))&&o.add(i);return[...o]}function Rb(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 Gb(e,t,r){const n=Hb(e),o=Pr(r),s=new Set,i=[o];for(;i.length>0;){const u=i.shift(),l=n.get(u);if(l)for(const f of l)s.has(f)||(s.add(f),i.push(f))}const a={...t},d=[];for(const u of s){const l=e.find(p=>p.name===u),f=zb(l);for(const p of Wb(u,r,a))Rb(a[p],f)||d.push(p),a[p]=f}return{values:a,clearedKeys:d}}function Oa(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=_d((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(),s=o.schema!=null&&o.schema.id===r.id,i=n?.forceReset===!0,a={},d=new Set,u=new Set,l=new Set;r.fields.forEach(y=>{const v=y.name||y.key||y.id;v&&(y.defaultValue!==void 0&&(y.type==="multiselect"?a[v]=Array.isArray(y.defaultValue)?y.defaultValue:y.defaultValue!=null&&y.defaultValue!==""?[String(y.defaultValue)]:[]:a[v]=y.defaultValue),y.hidden||d.add(v),y.disabled||u.add(v),y.validation?.some(w=>w.type==="required")&&l.add(v))});const f=r.steps?.length||1,p=[];r.fields.forEach(y=>{const v=y.properties;v?.valueSource==="calculated"&&v?.formula&&p.push({field:y.name,formula:v.formula})});const m=p.length>0?Fd.calculateAll(p,a):{},g=Fa(r.fields,{...a,...m},new Set),h=s&&!i?{...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:i||!s?new Set:o.derivedFieldDirty,isValid:!0,draftId:null})},setFieldValue:(r,n,o)=>{const s=t(),i=s.schema,a=o?.source??"user";let d=new Set(s.derivedFieldDirty);const u=s.values[r];let l={...s.values,[r]:n},f=[];if(i){const p=Pr(r),m=i.fields.find(v=>v.name===p);a==="user"&&m&&ka(m)&&d.add(r);const g=n==null||n===""||Array.isArray(n)&&n.length===0;if(Md(i.fields,r)&&g?l=Db(i.fields,l,d,r):Md(i.fields,r)&&(l=Fa(i.fields,l,d,r)),a==="user"&&u!==n&&!(Array.isArray(u)&&Array.isArray(n)&&u.length===n.length&&u.every((v,w)=>v===n[w]))&&Vb(i.fields,r)){const v=Gb(i.fields,l,r);l=v.values,f=v.clearedKeys}const y=[];if(i.fields.forEach(v=>{const w=v.properties;w?.valueSource==="calculated"&&w?.formula&&(w.formulaSteps||[]).some(P=>P.type==="field"&&P.fieldName===r)&&y.push({field:v.name,formula:w.formula})}),y.length>0){const v=Fd.calculateAll(y,l);l={...l,...v}}}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}}),i?.config.validateOnChange?t().validateField(r):e(p=>{const m={...p.errors};return delete m[r],{errors:m}})},setFieldTouched:(r,n=!0)=>{e(s=>({touched:{...s.touched,[r]:n}}));const o=t().schema;n&&o?.config.validateOnBlur&&t().validateField(r)},setFieldError:(r,n)=>{e(o=>{const s=!!o.errors[r];if(!n&&!s||n&&o.errors[r]===n)return o;const i={...o.errors};return n?i[r]=n:delete i[r],{errors:i,isValid:Object.keys(i).length===0}})},setValues:r=>{const n=t(),o=n.schema;if(!o){e({values:r});return}const s=Fa(o.fields,r,n.derivedFieldDirty);e({values:s})},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 s=n.fields.find(a=>a.name===r);if(!s)return;e({isValidating:!0});let i;if(s.validation)for(const a of s.validation){const d=Yr(o[r],a,o);if(typeof d=="string"){i=d;break}}if(!i){const a=_a(s,o[r]);a&&(i=a)}return e(a=>{const d={...a.errors};return i?d[r]=i:delete d[r],{errors:d,isValid:Object.keys(d).length===0,isValidating:!1}}),i},validateForm:async()=>{const{schema:r,values:n,visibleFields:o,requiredFields:s}=t();if(!r)return!1;e({isValidating:!0});const i={};for(const a of r.fields)if(o.has(a.name)){if(a.validation)for(const d of a.validation){if(d.type==="required"&&!s.has(a.name))continue;const u=Yr(n[a.name],d,n);if(typeof u=="string"){i[a.name]=u;break}}if(!i[a.name]){const d=_a(a,n[a.name]);d&&(i[a.name]=d)}}return e({errors:i,isValid:Object.keys(i).length===0,isValidating:!1}),Object.keys(i).length===0},validateStep:async r=>{const{schema:n,values:o,visibleFields:s}=t();if(!n||!n.steps)return!0;const i=n.steps[r];if(!i)return!0;e({isValidating:!0});const a={};for(const d of i.fields){const u=n.fields.find(l=>l.name===d);if(u&&s.has(u.name)){if(u.validation)for(const l of u.validation){const f=Yr(o[u.name],l,o);if(typeof f=="string"){a[u.name]=f;break}}if(!a[u.name]){const l=_a(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(i=>({currentStep:r+1,completedSteps:new Set([...i.completedSteps,r])})),!0):!1},prevStep:()=>{const{currentStep:r}=t();r>0&&e({currentStep:r-1})},goToStep:r=>{const{totalSteps:n,completedSteps:o,currentStep:s}=t();r>=0&&r<n&&(r<=s||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 Oa(n.visibleFields,o)?n:{visibleFields:o}})},updateEnabled:r=>{e(n=>{const o=new Set(r);return Oa(n.enabledFields,o)?n:{enabledFields:o}})},updateRequired:r=>{e(n=>{const o=new Set(r);return Oa(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:s}=JSON.parse(o);return e({values:s,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 Kb(){return Nt.getState()}function $d({schema:e,initialValues:t,onSubmit:r,onChange:n,workflowStepId:o}){const{values:s,errors:i,touched:a,isValidating:d,isSubmitting:u,submitCount:l,isValid:f,currentStep:p,totalSteps:m,completedSteps:g,visibleFields:h,enabledFields:y,requiredFields:v,setSchema:w,setFieldValue:x,setFieldTouched:E,setFieldError:P,setValues:C,resetForm:N,validateField:_,validateForm:A,validateStep:I,nextStep:T,prevStep:U,goToStep:Q,setSubmitting:O,incrementSubmitCount:j,saveDraft:L,loadDraft:D,clearDraft:M}=Nt(),R=S.useRef(null);S.useLayoutEffect(()=>{if(w(e,{forceReset:!!o}),t&&Object.keys(t).length>0){const de=Nt.getState().values;C({...de,...t});try{R.current=JSON.stringify(t)}catch{R.current=null}}else R.current=null},[e.id,o]),S.useLayoutEffect(()=>{if(!t||Object.keys(t).length===0)return;let de;try{de=JSON.stringify(t)}catch{return}if(de===R.current)return;const ot=Nt.getState().values;C({...ot,...t}),R.current=de},[t,C]);const $=S.useCallback((de,ot)=>{const Se={...s,[de]:ot};x(de,ot),n?.(Se,de)},[x,n,s]),ie=S.useCallback(async de=>{if(de?.preventDefault(),j(),!await A())return{success:!1,errors:Object.entries(i).map(([Se,xe])=>({field:Se,rule:"validation",message:xe}))};if(!r)return{success:!0};O(!0);try{const Se=await r(s);return Se.success&&M(),Se}catch(Se){return{success:!1,message:Se instanceof Error?Se.message:"Submission failed"}}finally{O(!1)}},[A,r,s,i,j,O,M]),V=S.useCallback(de=>({value:s[de],error:i[de],touched:a[de]||!1,isVisible:h.has(de),isEnabled:y.has(de),isRequired:v.has(de)}),[s,i,a,h,y,v]),K=S.useMemo(()=>{if(!e.steps||e.steps.length===0)return e.fields;const de=e.steps[p];return de?e.fields.filter(ot=>de.fields.includes(ot.name)):[]},[e,p]),X=p===0,ce=p===m-1,ne=S.useCallback(de=>g.has(de),[g]),G=S.useMemo(()=>m<=1?100:Math.round(g.size/m*100),[g.size,m]),ee=S.useCallback(de=>h.has(de),[h]),Pe=S.useCallback(de=>y.has(de),[y]),oe=S.useCallback(de=>v.has(de),[v]),re=S.useMemo(()=>Object.entries(i).filter(([de])=>h.has(de)),[i,h]),be=re.length>0;return{values:s,errors:i,touched:a,isValidating:d,isSubmitting:u,submitCount:l,isValid:f,hasErrors:be,visibleErrors:re,currentStep:p,totalSteps:m,completedSteps:g,currentStepFields:K,isFirstStep:X,isLastStep:ce,isStepCompleted:ne,progress:G,setFieldValue:$,setFieldTouched:E,setFieldError:P,setValues:C,validateField:_,getFieldState:V,shouldShowField:ee,isFieldEnabled:Pe,isFieldRequired:oe,handleSubmit:ie,resetForm:N,validateForm:A,validateStep:I,nextStep:T,prevStep:U,goToStep:Q,saveDraft:L,loadDraft:D,clearDraft:M}}function jd(e){return"logic"in e&&"conditions"in e}function Uo(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 tt(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],s=n.slice(1).join("."),i=zd(e,o);Array.isArray(i)&&i.length>0&&(r=tt(i[0],s))}}return r}const qb=new Set(["section","group","columns","divider","header","sectionHeading","spacer","textLabel","addmore","customizeSections"]);function Yb(e){return e===!0||e==="true"?!0:e===!1||e==="false"?!1:e}function Xb(e,t){if(e==null||typeof t.path!="string"||!t.path.trim())return!1;const r=tt(e,t.path),n=Yb(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 Jb(e,t,r){return e?e==="__allFields__"?t.filter(n=>!qb.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 Ud="__buttonResponse:";function Qb({fields:e,values:t,buttonResponses:r,prepopulateResponse:n=null,prepopulateResponseRules:o}){const{updateVisibility:s,updateEnabled:i,updateRequired:a,updateReadOnly:d,updateEditable:u,updateFormDisabled:l}=Nt(),f=S.useCallback(C=>C.name||C.key||C.id,[]),p=S.useCallback((C,N)=>{if(!C)return f(N);const _=e.find(A=>A.id===C||A.name===C||A.key===C);return _?f(_):C},[e,f]),m=S.useCallback(C=>{const N=e.find(_=>_.id===C||_.name===C||_.key===C);return N?f(N):C},[e,f]),g=S.useCallback(C=>{const{field:N,operator:_,value:A}=C;if(typeof N=="string"&&N.startsWith(Ud)){const U=N.slice(Ud.length),Q=r?.[U],O=Uo(Q);return A==="success"?O:A==="failure"?Q!=null&&!O:!1}const I=m(N),T=t[I];switch(_){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 U=Number(T);return U>=Number(A[0])&&U<=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(C=>{const N=C.conditions.map(_=>jd(_)?h(_):g(_));return C.logic==="and"?N.every(Boolean):N.some(Boolean)},[g]),y=S.useCallback(C=>jd(C)?h(C):g(C),[g,h]),v=S.useCallback(()=>{const C=new Set,N=new Set,_=new Set,A=new Set,I=new Set;e.forEach(O=>{const j=f(O);O.hidden||C.add(j),O.disabled||N.add(j),O.validation?.some(L=>L.type==="required")&&_.add(j)});let T=!1;if(n!=null&&o?.length)for(const O of o){if(!Xb(n,O.when))continue;const{action:j,target:L}=O.then;if(j==="disableForm")T=!0;else if(j==="enableForm")T=!1;else{const D=Jb(L,e,f);for(const M of D)switch(j){case"disable":N.delete(M);break;case"enable":N.add(M);break;case"hide":C.delete(M);break;case"show":C.add(M);break;case"readOnly":A.add(M),I.delete(M);break;case"editable":I.add(M),A.delete(M);break}}}e.forEach(O=>{O.conditions&&O.conditions.forEach(j=>{(y(j.when)?j.then:j.else||[]).forEach(M=>{switch(M.action){case"disableForm":T=!0;break;case"enableForm":T=!1;break;default:{const R=p(M.target,O);switch(M.action){case"show":C.add(R);break;case"hide":C.delete(R);break;case"enable":N.add(R);break;case"disable":N.delete(R);break;case"require":_.add(R);break;case"unrequire":_.delete(R);break}break}}})})});const U=O=>e.filter(j=>j.type!=="editButton"&&(j.name||j.key||j.id)).map(j=>f(j)),Q=()=>e.filter(O=>O.type==="button").map(O=>f(O));return e.forEach(O=>{if(O.type!=="editButton")return;const j=f(O);if(!Uo(r?.[j]))return;const L=O.properties;L?.rules&&L.rules.length>0?L.rules.forEach(D=>{const M=[];D.allFields&&M.push(...U(O.id)),D.allButtons&&M.push(...Q()),D.fieldNames?.length&&D.fieldNames.forEach(R=>{const $=e.find(ie=>f(ie)===R||ie.id===R||ie.name===R);M.push($?f($):R)}),D.buttonNames?.length&&M.push(...D.buttonNames),M.forEach(R=>{switch(D.action){case"enable":N.add(R),A.delete(R);break;case"disable":N.delete(R);break;case"show":C.add(R);break;case"hide":C.delete(R);break;case"readOnly":A.add(R);break;case"editable":I.add(R);break}})}):((L?.enableFieldNames??[]).forEach(D=>N.add(D)),(L?.disableFieldNames??[]).forEach(D=>N.delete(D)),(L?.showFieldNames??[]).forEach(D=>C.add(D)),(L?.hideFieldNames??[]).forEach(D=>C.delete(D)))}),{visible:Array.from(C),enabled:Array.from(N),required:Array.from(_),readOnly:Array.from(A),editable:Array.from(I),formDisabled:T}},[e,y,f,p,t,r,n,o]),w=S.useMemo(()=>v(),[v]);S.useEffect(()=>{s(w.visible),i(w.enabled),a(w.required),d(w.readOnly??[]),u(w.editable??[]),l(w.formDisabled??!1)},[w,s,i,a,d,u,l]);const x=S.useCallback(C=>w.visible.includes(C),[w.visible]),E=S.useCallback(C=>w.enabled.includes(C),[w.enabled]),P=S.useCallback(C=>w.required.includes(C),[w.required]);return{evaluateCondition:y,evaluateExpression:g,evaluateGroup:h,isFieldVisible:x,isFieldEnabled:E,isFieldRequired:P,visibleFields:w.visible,enabledFields:w.enabled,requiredFields:w.required}}function wn({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 Vd(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Bn(...e){return t=>{let r=!1;const n=e.map(o=>{const s=Vd(o,t);return!r&&typeof s=="function"&&(r=!0),s});if(r)return()=>{for(let o=0;o<n.length;o++){const s=n[o];typeof s=="function"?s():Vd(e[o],null)}}}}function Qe(...e){return b.useCallback(Bn(...e),e)}var Zb=Symbol.for("react.lazy"),$s=b[" use ".trim().toString()];function ev(e){return typeof e=="object"&&e!==null&&"then"in e}function Hd(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Zb&&"_payload"in e&&ev(e._payload)}function Ia(e){const t=tv(e),r=b.forwardRef((n,o)=>{let{children:s,...i}=n;Hd(s)&&typeof $s=="function"&&(s=$s(s._payload));const a=b.Children.toArray(s),d=a.find(nv);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,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}var Wd=Ia("Slot");function tv(e){const t=b.forwardRef((r,n)=>{let{children:o,...s}=r;if(Hd(o)&&typeof $s=="function"&&(o=$s(o._payload)),b.isValidElement(o)){const i=sv(o),a=ov(s,o.props);return o.type!==b.Fragment&&(a.ref=n?Bn(n,i):i),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var rv=Symbol("radix.slottable");function nv(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===rv}function ov(e,t){const r={...t};for(const n in t){const o=e[n],s=t[n];/^on[A-Z]/.test(n)?o&&s?r[n]=(...a)=>{const d=s(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function sv(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 iv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],av=iv.reduce((e,t)=>{const r=Ia(`Primitive.${t}`),n=b.forwardRef((o,s)=>{const{asChild:i,...a}=o,d=i?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(d,{...a,ref:s})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),lv="Label",Rd=b.forwardRef((e,t)=>c.jsx(av.label,{...e,ref:t,onMouseDown:r=>{r.target.closest("button, input, select, textarea")||(e.onMouseDown?.(r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));Rd.displayName=lv;var cv=Rd;function Sn({className:e,...t}){return c.jsx(cv,{"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 js(e){return`formsmith-label-${e.id}`}function Vo(e){return`formsmith-desc-${e.id}`}function Ho(e){return`formsmith-error-${e.id}`}function jt(e,t){const r=[];return e.description&&r.push(Vo(e)),t&&r.push(Ho(e)),r.length>0?r.join(" "):void 0}function Jt(e){return e?!0:void 0}const dv={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 xn(e){return e.ui?.cellStyle}function uv(e){const t=e.ui;if(!t)return;const r=t.fontToken?dv[t.fontToken]:void 0;if(!(!r&&!t.wrapperStyle))return{...r,...t.wrapperStyle}}function fv(e){return e.type==="button"||e.type==="editButton"}const Et=({field:e,error:t,isRequired:r,children:n,className:o,hideLabel:s})=>{const{gridStretch:i}=zo(),a=i&&Os(e),d=!(s??e.appearance?.hideLabel)&&e.label,u=e.appearance?.labelPlacement||"top",l=uv(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=xd(e),g=to(e),h=fv(e),y=Fr(e.appearance);return c.jsx("div",{className:B(mb(u),u!=="floating"&&"space-y-2",a&&!h&&"flex-1 min-h-0 h-full",i&&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",bd(e.appearance),Ad(e),a&&!h&&"flex-1 min-h-0",i&&h&&"shrink-0"),style:m,children:[d&&c.jsxs(Sn,{id:js(e),htmlFor:ht(e),style:e.ui?.labelStyle,className:B(hb(u,!!t)),children:[e.label,r&&c.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),c.jsxs("div",{className:B(gb(u),h&&i&&"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:Vo(e),className:"text-xs text-muted-foreground",style:e.ui?.descriptionStyle,children:e.description}),t&&c.jsx("p",{id:Ho(e),className:"text-xs text-destructive",role:"alert",children:typeof t=="string"?t:String(t||"An error occurred")})]})]})]})})},Ma=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=e.properties,l=S.useCallback(f=>{r(f.target.value)},[r]);return c.jsx(Et,{field:e,error:o,isRequired:a,className:d,children:c.jsx(wn,{id:ht(e),type:"text",value:t||"",onChange:l,onBlur:n,placeholder:e.placeholder,disabled:s||e.disabled,readOnly:i||e.readOnly,minLength:u?.minLength,maxLength:u?.maxLength,pattern:u?.pattern,autoComplete:u?.autoComplete,inputMode:u?.inputMode,"aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:B(Bo(e.appearance),o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})})},Gd=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,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 v=parseFloat(y);isNaN(v)||r(v)},[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(Et,{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(wn,{id:ht(e),type:"text",inputMode:l?"decimal":"numeric",autoComplete:"off",value:t??"",onChange:f,onKeyDown:p,onBlur:n,placeholder:e.placeholder,disabled:s||e.disabled,readOnly:i||e.readOnly,"aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:B(Bo(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(),mv=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,n)=>n?n.toUpperCase():r.toLowerCase()),Kd=e=>{const t=mv(e);return t.charAt(0).toUpperCase()+t.slice(1)},qd=(...e)=>e.filter((t,r,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===r).join(" ").trim(),hv=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var gv={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 yv=S.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:o="",children:s,iconNode:i,...a},d)=>S.createElement("svg",{ref:d,...gv,width:t,height:t,stroke:e,strokeWidth:n?Number(r)*24/Number(t):r,className:qd("lucide",o),...!s&&!hv(a)&&{"aria-hidden":"true"},...a},[...i.map(([u,l])=>S.createElement(u,l)),...Array.isArray(s)?s:[s]]));const Gt=(e,t)=>{const r=S.forwardRef(({className:n,...o},s)=>S.createElement(yv,{ref:s,iconNode:t,className:qd(`lucide-${pv(Kd(e))}`,`lucide-${e}`,n),...o}));return r.displayName=Kd(e),r};const bv=Gt("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);const zs=Gt("camera",[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);const Us=Gt("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Wo=Gt("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const Yd=Gt("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const vv=Gt("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);const wv=Gt("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const Xd=Gt("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const Jd=Gt("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Qd=Gt("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const Ro=Gt("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const Sv=Gt("mail",[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]);const xv=Gt("phone",[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]]);const Zd=Gt("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const Av=Gt("sliders-horizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);const eu=Gt("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);const Go=Gt("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);const Vs=Gt("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const Ko=Gt("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),tu=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=S.useCallback(l=>{r(l.target.value)},[r]);return c.jsx(Et,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{className:"relative",children:[c.jsx(Sv,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),c.jsx(wn,{id:ht(e),type:"email",value:t||"",onChange:u,onBlur:n,placeholder:e.placeholder||"email@example.com",disabled:s||e.disabled,readOnly:i||e.readOnly,autoComplete:"email",inputMode:"email","aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:B(Bo(e.appearance),"pl-10",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]})})},ru=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=S.useCallback(l=>{const f=l.target.value.replace(/[^\d\s+\-()]/g,"");r(f)},[r]);return c.jsx(Et,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{className:"relative",children:[c.jsx(xv,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),c.jsx(wn,{id:ht(e),type:"tel",value:t||"",onChange:u,onBlur:n,placeholder:e.placeholder||"+91 12345 67890",disabled:s||e.disabled,readOnly:i||e.readOnly,autoComplete:"tel",inputMode:"tel","aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:B(Bo(e.appearance),"pl-10",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]})})};function Cv({className:e,maxLength:t,showCharacterCount:r=!1,autoResize:n=!1,onChange:o,value:s,...i}){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(()=>{s&&u(String(s).length)},[s]),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:s,...i}),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 nu=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const{gridStretch:u}=zo(),l=u&&Os(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(Et,{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(Cv,{id:ht(e),value:t||"",onChange:p,onBlur:n,placeholder:e.placeholder,disabled:s||e.disabled,readOnly:i||e.readOnly,minLength:f?.minLength,maxLength:f?.maxLength,rows:2,"aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:B(hd(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 qo(e,[t,r]){return Math.min(r,Math.max(t,e))}function Me(e,t,{checkForDefaultPrevented:r=!0}={}){return function(o){if(e?.(o),r===!1||!o.defaultPrevented)return t?.(o)}}function Ev(e,t){const r=b.createContext(t),n=s=>{const{children:i,...a}=s,d=b.useMemo(()=>a,Object.values(a));return c.jsx(r.Provider,{value:d,children:i})};n.displayName=e+"Provider";function o(s){const i=b.useContext(r);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[n,o]}function vr(e,t=[]){let r=[];function n(s,i){const a=b.createContext(i),d=r.length;r=[...r,i];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=s+"Provider";function l(f,p){const m=p?.[e]?.[d]||a,g=b.useContext(m);if(g)return g;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,l]}const o=()=>{const s=r.map(i=>b.createContext(i));return function(a){const d=a?.[e]||s;return b.useMemo(()=>({[`__scope${e}`]:{...a,[e]:d}}),[a,d])}};return o.scopeName=e,[n,Nv(o,...t)]}function Nv(...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(s){const i=n.reduce((a,{useScope:d,scopeName:u})=>{const f=d(s)[`__scope${u}`];return{...a,...f}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return r.scopeName=t.scopeName,r}function ou(e){const t=_v(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),d=a.find(Tv);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,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function _v(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=Pv(o),a=Fv(s,o.props);return o.type!==b.Fragment&&(a.ref=n?Bn(n,i):i),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var kv=Symbol("radix.slottable");function Tv(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===kv}function Fv(e,t){const r={...t};for(const n in t){const o=e[n],s=t[n];/^on[A-Z]/.test(n)?o&&s?r[n]=(...a)=>{const d=s(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function Pv(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 La(e){const t=e+"CollectionProvider",[r,n]=vr(t),[o,s]=r(t,{collectionRef:{current:null},itemMap:new Map}),i=h=>{const{scope:y,children:v}=h,w=S.useRef(null),x=S.useRef(new Map).current;return c.jsx(o,{scope:y,itemMap:x,collectionRef:w,children:v})};i.displayName=t;const a=e+"CollectionSlot",d=ou(a),u=S.forwardRef((h,y)=>{const{scope:v,children:w}=h,x=s(a,v),E=Qe(y,x.collectionRef);return c.jsx(d,{ref:E,children:w})});u.displayName=a;const l=e+"CollectionItemSlot",f="data-radix-collection-item",p=ou(l),m=S.forwardRef((h,y)=>{const{scope:v,children:w,...x}=h,E=S.useRef(null),P=Qe(y,E),C=s(l,v);return S.useEffect(()=>(C.itemMap.set(E,{ref:E,...x}),()=>{C.itemMap.delete(E)})),c.jsx(p,{[f]:"",ref:P,children:w})});m.displayName=l;function g(h){const y=s(e+"CollectionConsumer",h);return S.useCallback(()=>{const w=y.collectionRef.current;if(!w)return[];const x=Array.from(w.querySelectorAll(`[${f}]`));return Array.from(y.itemMap.values()).sort((C,N)=>x.indexOf(C.ref.current)-x.indexOf(N.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:i,Slot:u,ItemSlot:m},g,n]}var Ov=b.createContext(void 0);function ro(e){const t=b.useContext(Ov);return e||t||"ltr"}function Iv(e){const t=Mv(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),d=a.find(Dv);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,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function Mv(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=$v(o),a=Bv(s,o.props);return o.type!==b.Fragment&&(a.ref=n?Bn(n,i):i),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Lv=Symbol("radix.slottable");function Dv(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Lv}function Bv(e,t){const r={...t};for(const n in t){const o=e[n],s=t[n];/^on[A-Z]/.test(n)?o&&s?r[n]=(...a)=>{const d=s(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function $v(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 jv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Be=jv.reduce((e,t)=>{const r=Iv(`Primitive.${t}`),n=b.forwardRef((o,s)=>{const{asChild:i,...a}=o,d=i?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(d,{...a,ref:s})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function zv(e,t){e&&Cs.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 Uv(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 Vv="DismissableLayer",Da="dismissableLayer.update",Hv="dismissableLayer.pointerDownOutside",Wv="dismissableLayer.focusOutside",su,iu=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Hs=b.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...d}=e,u=b.useContext(iu),[l,f]=b.useState(null),p=l?.ownerDocument??globalThis?.document,[,m]=b.useState({}),g=Qe(t,N=>f(N)),h=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=h.indexOf(y),w=l?h.indexOf(l):-1,x=u.layersWithOutsidePointerEventsDisabled.size>0,E=w>=v,P=Kv(N=>{const _=N.target,A=[...u.branches].some(I=>I.contains(_));!E||A||(o?.(N),i?.(N),N.defaultPrevented||a?.())},p),C=qv(N=>{const _=N.target;[...u.branches].some(I=>I.contains(_))||(s?.(N),i?.(N),N.defaultPrevented||a?.())},p);return Uv(N=>{w===u.layers.size-1&&(n?.(N),!N.defaultPrevented&&a&&(N.preventDefault(),a()))},p),b.useEffect(()=>{if(l)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(su=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(l)),u.layers.add(l),au(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=su)}},[l,p,r,u]),b.useEffect(()=>()=>{l&&(u.layers.delete(l),u.layersWithOutsidePointerEventsDisabled.delete(l),au())},[l,u]),b.useEffect(()=>{const N=()=>m({});return document.addEventListener(Da,N),()=>document.removeEventListener(Da,N)},[]),c.jsx(Be.div,{...d,ref:g,style:{pointerEvents:x?E?"auto":"none":void 0,...e.style},onFocusCapture:Me(e.onFocusCapture,C.onFocusCapture),onBlurCapture:Me(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:Me(e.onPointerDownCapture,P.onPointerDownCapture)})});Hs.displayName=Vv;var Rv="DismissableLayerBranch",Gv=b.forwardRef((e,t)=>{const r=b.useContext(iu),n=b.useRef(null),o=Qe(t,n);return b.useEffect(()=>{const s=n.current;if(s)return r.branches.add(s),()=>{r.branches.delete(s)}},[r.branches]),c.jsx(Be.div,{...e,ref:o})});Gv.displayName=Rv;function Kv(e,t=globalThis?.document){const r=ar(e),n=b.useRef(!1),o=b.useRef(()=>{});return b.useEffect(()=>{const s=a=>{if(a.target&&!n.current){let d=function(){lu(Hv,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},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,r]),{onPointerDownCapture:()=>n.current=!0}}function qv(e,t=globalThis?.document){const r=ar(e),n=b.useRef(!1);return b.useEffect(()=>{const o=s=>{s.target&&!n.current&&lu(Wv,r,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,r]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function au(){const e=new CustomEvent(Da);document.dispatchEvent(e)}function lu(e,t,r,{discrete:n}){const o=r.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&o.addEventListener(e,t,{once:!0}),n?zv(o,s):o.dispatchEvent(s)}var Ba=0;function $a(){b.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??cu()),document.body.insertAdjacentElement("beforeend",e[1]??cu()),Ba++,()=>{Ba===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Ba--}},[])}function cu(){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 ja="focusScope.autoFocusOnMount",za="focusScope.autoFocusOnUnmount",du={bubbles:!1,cancelable:!0},Yv="FocusScope",Ws=b.forwardRef((e,t)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,d]=b.useState(null),u=ar(o),l=ar(s),f=b.useRef(null),p=Qe(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 E=x.target;a.contains(E)?f.current=E:An(f.current,{select:!0})},y=function(x){if(m.paused||!a)return;const E=x.relatedTarget;E!==null&&(a.contains(E)||An(f.current,{select:!0}))},v=function(x){if(document.activeElement===document.body)for(const P of x)P.removedNodes.length>0&&An(a)};document.addEventListener("focusin",h),document.addEventListener("focusout",y);const w=new MutationObserver(v);return a&&w.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",h),document.removeEventListener("focusout",y),w.disconnect()}}},[n,a,m.paused]),b.useEffect(()=>{if(a){pu.add(m);const h=document.activeElement;if(!a.contains(h)){const v=new CustomEvent(ja,du);a.addEventListener(ja,u),a.dispatchEvent(v),v.defaultPrevented||(Xv(tw(uu(a)),{select:!0}),document.activeElement===h&&An(a))}return()=>{a.removeEventListener(ja,u),setTimeout(()=>{const v=new CustomEvent(za,du);a.addEventListener(za,l),a.dispatchEvent(v),v.defaultPrevented||An(h??document.body,{select:!0}),a.removeEventListener(za,l),pu.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,v=document.activeElement;if(y&&v){const w=h.currentTarget,[x,E]=Jv(w);x&&E?!h.shiftKey&&v===E?(h.preventDefault(),r&&An(x,{select:!0})):h.shiftKey&&v===x&&(h.preventDefault(),r&&An(E,{select:!0})):v===w&&h.preventDefault()}},[r,n,m.paused]);return c.jsx(Be.div,{tabIndex:-1,...i,ref:p,onKeyDown:g})});Ws.displayName=Yv;function Xv(e,{select:t=!1}={}){const r=document.activeElement;for(const n of e)if(An(n,{select:t}),document.activeElement!==r)return}function Jv(e){const t=uu(e),r=fu(t,e),n=fu(t.reverse(),e);return[r,n]}function uu(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 fu(e,t){for(const r of e)if(!Qv(r,{upTo:t}))return r}function Qv(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 Zv(e){return e instanceof HTMLInputElement&&"select"in e}function An(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&Zv(e)&&t&&e.select()}}var pu=ew();function ew(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=mu(e,t),e.unshift(t)},remove(t){e=mu(e,t),e[0]?.resume()}}}function mu(e,t){const r=[...e],n=r.indexOf(t);return n!==-1&&r.splice(n,1),r}function tw(e){return e.filter(t=>t.tagName!=="A")}var Qt=globalThis?.document?b.useLayoutEffect:()=>{},rw=b[" useId ".trim().toString()]||(()=>{}),nw=0;function on(e){const[t,r]=b.useState(rw());return Qt(()=>{r(n=>n??String(nw++))},[e]),e||(t?`radix-${t}`:"")}const ow=["top","right","bottom","left"],Cn=Math.min,wr=Math.max,Rs=Math.round,Gs=Math.floor,Xr=e=>({x:e,y:e}),sw={left:"right",right:"left",bottom:"top",top:"bottom"};function Ua(e,t,r){return wr(e,Cn(t,r))}function sn(e,t){return typeof e=="function"?e(t):e}function an(e){return e.split("-")[0]}function no(e){return e.split("-")[1]}function Va(e){return e==="x"?"y":"x"}function Ha(e){return e==="y"?"height":"width"}function Jr(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Wa(e){return Va(Jr(e))}function iw(e,t,r){r===void 0&&(r=!1);const n=no(e),o=Wa(e),s=Ha(o);let i=o==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Ks(i)),[i,Ks(i)]}function aw(e){const t=Ks(e);return[Ra(e),t,Ra(t)]}function Ra(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const hu=["left","right"],gu=["right","left"],lw=["top","bottom"],cw=["bottom","top"];function dw(e,t,r){switch(e){case"top":case"bottom":return r?t?gu:hu:t?hu:gu;case"left":case"right":return t?lw:cw;default:return[]}}function uw(e,t,r,n){const o=no(e);let s=dw(an(e),r==="start",n);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ra)))),s}function Ks(e){const t=an(e);return sw[t]+e.slice(t.length)}function fw(e){return{top:0,right:0,bottom:0,left:0,...e}}function yu(e){return typeof e!="number"?fw(e):{top:e,right:e,bottom:e,left:e}}function qs(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 bu(e,t,r){let{reference:n,floating:o}=e;const s=Jr(t),i=Wa(t),a=Ha(i),d=an(t),u=s==="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(no(t)){case"start":m[i]-=p*(r&&u?-1:1);break;case"end":m[i]+=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:s,rects:i,elements:a,strategy:d}=e,{boundary:u="clippingAncestors",rootBoundary:l="viewport",elementContext:f="floating",altBoundary:p=!1,padding:m=0}=sn(t,e),g=yu(m),y=a[p?f==="floating"?"reference":"floating":f],v=qs(await s.getClippingRect({element:(r=await(s.isElement==null?void 0:s.isElement(y)))==null||r?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:l,strategy:d})),w=f==="floating"?{x:n,y:o,width:i.floating.width,height:i.floating.height}:i.reference,x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),E=await(s.isElement==null?void 0:s.isElement(x))?await(s.getScale==null?void 0:s.getScale(x))||{x:1,y:1}:{x:1,y:1},P=qs(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:x,strategy:d}):w);return{top:(v.top-P.top+g.top)/E.y,bottom:(P.bottom-v.bottom+g.bottom)/E.y,left:(v.left-P.left+g.left)/E.x,right:(P.right-v.right+g.right)/E.x}}const mw=50,hw=async(e,t,r)=>{const{placement:n="bottom",strategy:o="absolute",middleware:s=[],platform:i}=r,a=i.detectOverflow?i:{...i,detectOverflow:pw},d=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:l,y:f}=bu(u,n,d),p=n,m=0;const g={};for(let h=0;h<s.length;h++){const y=s[h];if(!y)continue;const{name:v,fn:w}=y,{x,y:E,data:P,reset:C}=await w({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=E??f,g[v]={...g[v],...P},C&&m<mw&&(m++,typeof C=="object"&&(C.placement&&(p=C.placement),C.rects&&(u=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:l,y:f}=bu(u,p,d)),h=-1)}return{x:l,y:f,placement:p,strategy:o,middlewareData:g}},gw=e=>({name:"arrow",options:e,async fn(t){const{x:r,y:n,placement:o,rects:s,platform:i,elements:a,middlewareData:d}=t,{element:u,padding:l=0}=sn(e,t)||{};if(u==null)return{};const f=yu(l),p={x:r,y:n},m=Wa(o),g=Ha(m),h=await i.getDimensions(u),y=m==="y",v=y?"top":"left",w=y?"bottom":"right",x=y?"clientHeight":"clientWidth",E=s.reference[g]+s.reference[m]-p[m]-s.floating[g],P=p[m]-s.reference[m],C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let N=C?C[x]:0;(!N||!await(i.isElement==null?void 0:i.isElement(C)))&&(N=a.floating[x]||s.floating[g]);const _=E/2-P/2,A=N/2-h[g]/2-1,I=Cn(f[v],A),T=Cn(f[w],A),U=I,Q=N-h[g]-T,O=N/2-h[g]/2+_,j=Ua(U,O,Q),L=!d.arrow&&no(o)!=null&&O!==j&&s.reference[g]/2-(O<U?I:T)-h[g]/2<0,D=L?O<U?O-U:O-Q:0;return{[m]:p[m]+D,data:{[m]:j,centerOffset:O-j-D,...L&&{alignmentOffset:D}},reset:L}}}),yw=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var r,n;const{placement:o,middlewareData:s,rects:i,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}=sn(e,t);if((r=s.arrow)!=null&&r.alignmentOffset)return{};const v=an(o),w=Jr(a),x=an(a)===a,E=await(d.isRTL==null?void 0:d.isRTL(u.floating)),P=p||(x||!h?[Ks(a)]:aw(a)),C=g!=="none";!p&&C&&P.push(...uw(a,h,g,E));const N=[a,...P],_=await d.detectOverflow(t,y),A=[];let I=((n=s.flip)==null?void 0:n.overflows)||[];if(l&&A.push(_[v]),f){const O=iw(o,i,E);A.push(_[O[0]],_[O[1]])}if(I=[...I,{placement:o,overflows:A}],!A.every(O=>O<=0)){var T,U;const O=(((T=s.flip)==null?void 0:T.index)||0)+1,j=N[O];if(j&&(!(f==="alignment"?w!==Jr(j):!1)||I.every(M=>Jr(M.placement)===w?M.overflows[0]>0:!0)))return{data:{index:O,overflows:I},reset:{placement:j}};let L=(U=I.filter(D=>D.overflows[0]<=0).sort((D,M)=>D.overflows[1]-M.overflows[1])[0])==null?void 0:U.placement;if(!L)switch(m){case"bestFit":{var Q;const D=(Q=I.filter(M=>{if(C){const R=Jr(M.placement);return R===w||R==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(R=>R>0).reduce((R,$)=>R+$,0)]).sort((M,R)=>M[1]-R[1])[0])==null?void 0:Q[0];D&&(L=D);break}case"initialPlacement":L=a;break}if(o!==L)return{reset:{placement:L}}}return{}}}};function vu(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function wu(e){return ow.some(t=>e[t]>=0)}const bw=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:r,platform:n}=t,{strategy:o="referenceHidden",...s}=sn(e,t);switch(o){case"referenceHidden":{const i=await n.detectOverflow(t,{...s,elementContext:"reference"}),a=vu(i,r.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:wu(a)}}}case"escaped":{const i=await n.detectOverflow(t,{...s,altBoundary:!0}),a=vu(i,r.floating);return{data:{escapedOffsets:a,escaped:wu(a)}}}default:return{}}}}},Su=new Set(["left","top"]);async function vw(e,t){const{placement:r,platform:n,elements:o}=e,s=await(n.isRTL==null?void 0:n.isRTL(o.floating)),i=an(r),a=no(r),d=Jr(r)==="y",u=Su.has(i)?-1:1,l=s&&d?-1:1,f=sn(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 ww=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var r,n;const{x:o,y:s,placement:i,middlewareData:a}=t,d=await vw(t,e);return i===((r=a.offset)==null?void 0:r.placement)&&(n=a.arrow)!=null&&n.alignmentOffset?{}:{x:o+d.x,y:s+d.y,data:{...d,placement:i}}}}},Sw=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:n,placement:o,platform:s}=t,{mainAxis:i=!0,crossAxis:a=!1,limiter:d={fn:v=>{let{x:w,y:x}=v;return{x:w,y:x}}},...u}=sn(e,t),l={x:r,y:n},f=await s.detectOverflow(t,u),p=Jr(an(o)),m=Va(p);let g=l[m],h=l[p];if(i){const v=m==="y"?"top":"left",w=m==="y"?"bottom":"right",x=g+f[v],E=g-f[w];g=Ua(x,g,E)}if(a){const v=p==="y"?"top":"left",w=p==="y"?"bottom":"right",x=h+f[v],E=h-f[w];h=Ua(x,h,E)}const y=d.fn({...t,[m]:g,[p]:h});return{...y,data:{x:y.x-r,y:y.y-n,enabled:{[m]:i,[p]:a}}}}}},xw=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:r,y:n,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:d=!0,crossAxis:u=!0}=sn(e,t),l={x:r,y:n},f=Jr(o),p=Va(f);let m=l[p],g=l[f];const h=sn(a,t),y=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(d){const x=p==="y"?"height":"width",E=s.reference[p]-s.floating[x]+y.mainAxis,P=s.reference[p]+s.reference[x]-y.mainAxis;m<E?m=E:m>P&&(m=P)}if(u){var v,w;const x=p==="y"?"width":"height",E=Su.has(an(o)),P=s.reference[f]-s.floating[x]+(E&&((v=i.offset)==null?void 0:v[f])||0)+(E?0:y.crossAxis),C=s.reference[f]+s.reference[x]+(E?0:((w=i.offset)==null?void 0:w[f])||0)-(E?y.crossAxis:0);g<P?g=P:g>C&&(g=C)}return{[p]:m,[f]:g}}}},Aw=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var r,n;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:d=()=>{},...u}=sn(e,t),l=await i.detectOverflow(t,u),f=an(o),p=no(o),m=Jr(o)==="y",{width:g,height:h}=s.floating;let y,v;f==="top"||f==="bottom"?(y=f,v=p===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(v=f,y=p==="end"?"top":"bottom");const w=h-l.top-l.bottom,x=g-l.left-l.right,E=Cn(h-l[y],w),P=Cn(g-l[v],x),C=!t.middlewareData.shift;let N=E,_=P;if((r=t.middlewareData.shift)!=null&&r.enabled.x&&(_=x),(n=t.middlewareData.shift)!=null&&n.enabled.y&&(N=w),C&&!p){const I=wr(l.left,0),T=wr(l.right,0),U=wr(l.top,0),Q=wr(l.bottom,0);m?_=g-2*(I!==0||T!==0?I+T:wr(l.left,l.right)):N=h-2*(U!==0||Q!==0?U+Q:wr(l.top,l.bottom))}await d({...t,availableWidth:_,availableHeight:N});const A=await i.getDimensions(a.floating);return g!==A.width||h!==A.height?{reset:{rects:!0}}:{}}}};function Ys(){return typeof window<"u"}function oo(e){return xu(e)?(e.nodeName||"").toLowerCase():"#document"}function Sr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Qr(e){var t;return(t=(xu(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function xu(e){return Ys()?e instanceof Node||e instanceof Sr(e).Node:!1}function Ur(e){return Ys()?e instanceof Element||e instanceof Sr(e).Element:!1}function ln(e){return Ys()?e instanceof HTMLElement||e instanceof Sr(e).HTMLElement:!1}function Au(e){return!Ys()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Sr(e).ShadowRoot}function Yo(e){const{overflow:t,overflowX:r,overflowY:n,display:o}=Vr(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+r)&&o!=="inline"&&o!=="contents"}function Cw(e){return/^(table|td|th)$/.test(oo(e))}function Xs(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Ew=/transform|translate|scale|rotate|perspective|filter/,Nw=/paint|layout|strict|content/,$n=e=>!!e&&e!=="none";let Ga;function Ka(e){const t=Ur(e)?Vr(e):e;return $n(t.transform)||$n(t.translate)||$n(t.scale)||$n(t.rotate)||$n(t.perspective)||!qa()&&($n(t.backdropFilter)||$n(t.filter))||Ew.test(t.willChange||"")||Nw.test(t.contain||"")}function _w(e){let t=En(e);for(;ln(t)&&!so(t);){if(Ka(t))return t;if(Xs(t))return null;t=En(t)}return null}function qa(){return Ga==null&&(Ga=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Ga}function so(e){return/^(html|body|#document)$/.test(oo(e))}function Vr(e){return Sr(e).getComputedStyle(e)}function Js(e){return Ur(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function En(e){if(oo(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Au(e)&&e.host||Qr(e);return Au(t)?t.host:t}function Cu(e){const t=En(e);return so(t)?e.ownerDocument?e.ownerDocument.body:e.body:ln(t)&&Yo(t)?t:Cu(t)}function Xo(e,t,r){var n;t===void 0&&(t=[]),r===void 0&&(r=!0);const o=Cu(e),s=o===((n=e.ownerDocument)==null?void 0:n.body),i=Sr(o);if(s){const a=Ya(i);return t.concat(i,i.visualViewport||[],Yo(o)?o:[],a&&r?Xo(a):[])}else return t.concat(o,Xo(o,[],r))}function Ya(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Eu(e){const t=Vr(e);let r=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const o=ln(e),s=o?e.offsetWidth:r,i=o?e.offsetHeight:n,a=Rs(r)!==s||Rs(n)!==i;return a&&(r=s,n=i),{width:r,height:n,$:a}}function Xa(e){return Ur(e)?e:e.contextElement}function io(e){const t=Xa(e);if(!ln(t))return Xr(1);const r=t.getBoundingClientRect(),{width:n,height:o,$:s}=Eu(t);let i=(s?Rs(r.width):r.width)/n,a=(s?Rs(r.height):r.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const kw=Xr(0);function Nu(e){const t=Sr(e);return!qa()||!t.visualViewport?kw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Tw(e,t,r){return t===void 0&&(t=!1),!r||t&&r!==Sr(e)?!1:t}function jn(e,t,r,n){t===void 0&&(t=!1),r===void 0&&(r=!1);const o=e.getBoundingClientRect(),s=Xa(e);let i=Xr(1);t&&(n?Ur(n)&&(i=io(n)):i=io(e));const a=Tw(s,r,n)?Nu(s):Xr(0);let d=(o.left+a.x)/i.x,u=(o.top+a.y)/i.y,l=o.width/i.x,f=o.height/i.y;if(s){const p=Sr(s),m=n&&Ur(n)?Sr(n):n;let g=p,h=Ya(g);for(;h&&n&&m!==g;){const y=io(h),v=h.getBoundingClientRect(),w=Vr(h),x=v.left+(h.clientLeft+parseFloat(w.paddingLeft))*y.x,E=v.top+(h.clientTop+parseFloat(w.paddingTop))*y.y;d*=y.x,u*=y.y,l*=y.x,f*=y.y,d+=x,u+=E,g=Sr(h),h=Ya(g)}}return qs({width:l,height:f,x:d,y:u})}function Qs(e,t){const r=Js(e).scrollLeft;return t?t.left+r:jn(Qr(e)).left+r}function _u(e,t){const r=e.getBoundingClientRect(),n=r.left+t.scrollLeft-Qs(e,r),o=r.top+t.scrollTop;return{x:n,y:o}}function Fw(e){let{elements:t,rect:r,offsetParent:n,strategy:o}=e;const s=o==="fixed",i=Qr(n),a=t?Xs(t.floating):!1;if(n===i||a&&s)return r;let d={scrollLeft:0,scrollTop:0},u=Xr(1);const l=Xr(0),f=ln(n);if((f||!f&&!s)&&((oo(n)!=="body"||Yo(i))&&(d=Js(n)),f)){const m=jn(n);u=io(n),l.x=m.x+n.clientLeft,l.y=m.y+n.clientTop}const p=i&&!f&&!s?_u(i,d):Xr(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 Pw(e){return Array.from(e.getClientRects())}function Ow(e){const t=Qr(e),r=Js(e),n=e.ownerDocument.body,o=wr(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),s=wr(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let i=-r.scrollLeft+Qs(e);const a=-r.scrollTop;return Vr(n).direction==="rtl"&&(i+=wr(t.clientWidth,n.clientWidth)-o),{width:o,height:s,x:i,y:a}}const ku=25;function Iw(e,t){const r=Sr(e),n=Qr(e),o=r.visualViewport;let s=n.clientWidth,i=n.clientHeight,a=0,d=0;if(o){s=o.width,i=o.height;const l=qa();(!l||l&&t==="fixed")&&(a=o.offsetLeft,d=o.offsetTop)}const u=Qs(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<=ku&&(s-=g)}else u<=ku&&(s+=u);return{width:s,height:i,x:a,y:d}}function Mw(e,t){const r=jn(e,!0,t==="fixed"),n=r.top+e.clientTop,o=r.left+e.clientLeft,s=ln(e)?io(e):Xr(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,d=o*s.x,u=n*s.y;return{width:i,height:a,x:d,y:u}}function Tu(e,t,r){let n;if(t==="viewport")n=Iw(e,r);else if(t==="document")n=Ow(Qr(e));else if(Ur(t))n=Mw(t,r);else{const o=Nu(e);n={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return qs(n)}function Fu(e,t){const r=En(e);return r===t||!Ur(r)||so(r)?!1:Vr(r).position==="fixed"||Fu(r,t)}function Lw(e,t){const r=t.get(e);if(r)return r;let n=Xo(e,[],!1).filter(a=>Ur(a)&&oo(a)!=="body"),o=null;const s=Vr(e).position==="fixed";let i=s?En(e):e;for(;Ur(i)&&!so(i);){const a=Vr(i),d=Ka(i);!d&&a.position==="fixed"&&(o=null),(s?!d&&!o:!d&&a.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Yo(i)&&!d&&Fu(e,i))?n=n.filter(l=>l!==i):o=a,i=En(i)}return t.set(e,n),n}function Dw(e){let{element:t,boundary:r,rootBoundary:n,strategy:o}=e;const i=[...r==="clippingAncestors"?Xs(t)?[]:Lw(t,this._c):[].concat(r),n],a=Tu(t,i[0],o);let d=a.top,u=a.right,l=a.bottom,f=a.left;for(let p=1;p<i.length;p++){const m=Tu(t,i[p],o);d=wr(m.top,d),u=Cn(m.right,u),l=Cn(m.bottom,l),f=wr(m.left,f)}return{width:u-f,height:l-d,x:f,y:d}}function Bw(e){const{width:t,height:r}=Eu(e);return{width:t,height:r}}function $w(e,t,r){const n=ln(t),o=Qr(t),s=r==="fixed",i=jn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const d=Xr(0);function u(){d.x=Qs(o)}if(n||!n&&!s)if((oo(t)!=="body"||Yo(o))&&(a=Js(t)),n){const m=jn(t,!0,s,t);d.x=m.x+t.clientLeft,d.y=m.y+t.clientTop}else o&&u();s&&!n&&o&&u();const l=o&&!n&&!s?_u(o,a):Xr(0),f=i.left+a.scrollLeft-d.x-l.x,p=i.top+a.scrollTop-d.y-l.y;return{x:f,y:p,width:i.width,height:i.height}}function Ja(e){return Vr(e).position==="static"}function Pu(e,t){if(!ln(e)||Vr(e).position==="fixed")return null;if(t)return t(e);let r=e.offsetParent;return Qr(e)===r&&(r=r.ownerDocument.body),r}function Ou(e,t){const r=Sr(e);if(Xs(e))return r;if(!ln(e)){let o=En(e);for(;o&&!so(o);){if(Ur(o)&&!Ja(o))return o;o=En(o)}return r}let n=Pu(e,t);for(;n&&Cw(n)&&Ja(n);)n=Pu(n,t);return n&&so(n)&&Ja(n)&&!Ka(n)?r:n||_w(e)||r}const jw=async function(e){const t=this.getOffsetParent||Ou,r=this.getDimensions,n=await r(e.floating);return{reference:$w(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function zw(e){return Vr(e).direction==="rtl"}const Uw={convertOffsetParentRelativeRectToViewportRelativeRect:Fw,getDocumentElement:Qr,getClippingRect:Dw,getOffsetParent:Ou,getElementRects:jw,getClientRects:Pw,getDimensions:Bw,getScale:io,isElement:Ur,isRTL:zw};function Iu(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Vw(e,t){let r=null,n;const o=Qr(e);function s(){var a;clearTimeout(n),(a=r)==null||a.disconnect(),r=null}function i(a,d){a===void 0&&(a=!1),d===void 0&&(d=1),s();const u=e.getBoundingClientRect(),{left:l,top:f,width:p,height:m}=u;if(a||t(),!p||!m)return;const g=Gs(f),h=Gs(o.clientWidth-(l+p)),y=Gs(o.clientHeight-(f+m)),v=Gs(l),x={rootMargin:-g+"px "+-h+"px "+-y+"px "+-v+"px",threshold:wr(0,Cn(1,d))||1};let E=!0;function P(C){const N=C[0].intersectionRatio;if(N!==d){if(!E)return i();N?i(!1,N):n=setTimeout(()=>{i(!1,1e-7)},1e3)}N===1&&!Iu(u,e.getBoundingClientRect())&&i(),E=!1}try{r=new IntersectionObserver(P,{...x,root:o.ownerDocument})}catch{r=new IntersectionObserver(P,x)}r.observe(e)}return i(!0),s}function Hw(e,t,r,n){n===void 0&&(n={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:d=!1}=n,u=Xa(e),l=o||s?[...u?Xo(u):[],...t?Xo(t):[]]:[];l.forEach(v=>{o&&v.addEventListener("scroll",r,{passive:!0}),s&&v.addEventListener("resize",r)});const f=u&&a?Vw(u,r):null;let p=-1,m=null;i&&(m=new ResizeObserver(v=>{let[w]=v;w&&w.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?jn(e):null;d&&y();function y(){const v=jn(e);h&&!Iu(h,v)&&r(),h=v,g=requestAnimationFrame(y)}return r(),()=>{var v;l.forEach(w=>{o&&w.removeEventListener("scroll",r),s&&w.removeEventListener("resize",r)}),f?.(),(v=m)==null||v.disconnect(),m=null,d&&cancelAnimationFrame(g)}}const Ww=ww,Rw=Sw,Gw=yw,Kw=Aw,qw=bw,Mu=gw,Yw=xw,Xw=(e,t,r)=>{const n=new Map,o={platform:Uw,...r},s={...o.platform,_c:n};return hw(e,t,{...o,platform:s})};var Jw=typeof document<"u",Qw=function(){},Zs=Jw?S.useLayoutEffect:Qw;function ei(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(!ei(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 s=o[n];if(!(s==="_owner"&&e.$$typeof)&&!ei(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Lu(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Du(e,t){const r=Lu(e);return Math.round(t*r)/r}function Qa(e){const t=b.useRef(e);return Zs(()=>{t.current=e}),t}function Zw(e){e===void 0&&(e={});const{placement:t="bottom",strategy:r="absolute",middleware:n=[],platform:o,elements:{reference:s,floating:i}={},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);ei(p,n)||m(n);const[g,h]=b.useState(null),[y,v]=b.useState(null),w=b.useCallback(M=>{M!==C.current&&(C.current=M,h(M))},[]),x=b.useCallback(M=>{M!==N.current&&(N.current=M,v(M))},[]),E=s||g,P=i||y,C=b.useRef(null),N=b.useRef(null),_=b.useRef(l),A=d!=null,I=Qa(d),T=Qa(o),U=Qa(u),Q=b.useCallback(()=>{if(!C.current||!N.current)return;const M={placement:t,strategy:r,middleware:p};T.current&&(M.platform=T.current),Xw(C.current,N.current,M).then(R=>{const $={...R,isPositioned:U.current!==!1};O.current&&!ei(_.current,$)&&(_.current=$,Cs.flushSync(()=>{f($)}))})},[p,t,r,T,U]);Zs(()=>{u===!1&&_.current.isPositioned&&(_.current.isPositioned=!1,f(M=>({...M,isPositioned:!1})))},[u]);const O=b.useRef(!1);Zs(()=>(O.current=!0,()=>{O.current=!1}),[]),Zs(()=>{if(E&&(C.current=E),P&&(N.current=P),E&&P){if(I.current)return I.current(E,P,Q);Q()}},[E,P,Q,I,A]);const j=b.useMemo(()=>({reference:C,floating:N,setReference:w,setFloating:x}),[w,x]),L=b.useMemo(()=>({reference:E,floating:P}),[E,P]),D=b.useMemo(()=>{const M={position:r,left:0,top:0};if(!L.floating)return M;const R=Du(L.floating,l.x),$=Du(L.floating,l.y);return a?{...M,transform:"translate("+R+"px, "+$+"px)",...Lu(L.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:R,top:$}},[r,a,L.floating,l.x,l.y]);return b.useMemo(()=>({...l,update:Q,refs:j,elements:L,floatingStyles:D}),[l,Q,j,L,D])}const eS=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?Mu({element:n.current,padding:o}).fn(r):{}:n?Mu({element:n,padding:o}).fn(r):{}}}},tS=(e,t)=>{const r=Ww(e);return{name:r.name,fn:r.fn,options:[e,t]}},rS=(e,t)=>{const r=Rw(e);return{name:r.name,fn:r.fn,options:[e,t]}},nS=(e,t)=>({fn:Yw(e).fn,options:[e,t]}),oS=(e,t)=>{const r=Gw(e);return{name:r.name,fn:r.fn,options:[e,t]}},sS=(e,t)=>{const r=Kw(e);return{name:r.name,fn:r.fn,options:[e,t]}},iS=(e,t)=>{const r=qw(e);return{name:r.name,fn:r.fn,options:[e,t]}},aS=(e,t)=>{const r=eS(e);return{name:r.name,fn:r.fn,options:[e,t]}};var lS="Arrow",Bu=b.forwardRef((e,t)=>{const{children:r,width:n=10,height:o=5,...s}=e;return c.jsx(Be.svg,{...s,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"})})});Bu.displayName=lS;var cS=Bu;function Jo(e){const[t,r]=b.useState(void 0);return Qt(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});const n=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const d=s.borderBoxSize,u=Array.isArray(d)?d[0]:d;i=u.inlineSize,a=u.blockSize}else i=e.offsetWidth,a=e.offsetHeight;r({width:i,height:a})});return n.observe(e,{box:"border-box"}),()=>n.unobserve(e)}else r(void 0)},[e]),t}var Za="Popper",[$u,ti]=vr(Za),[dS,ju]=$u(Za),zu=e=>{const{__scopePopper:t,children:r}=e,[n,o]=b.useState(null);return c.jsx(dS,{scope:t,anchor:n,onAnchorChange:o,children:r})};zu.displayName=Za;var Uu="PopperAnchor",Vu=b.forwardRef((e,t)=>{const{__scopePopper:r,virtualRef:n,...o}=e,s=ju(Uu,r),i=b.useRef(null),a=Qe(t,i),d=b.useRef(null);return b.useEffect(()=>{const u=d.current;d.current=n?.current||i.current,u!==d.current&&s.onAnchorChange(d.current)}),n?null:c.jsx(Be.div,{...o,ref:a})});Vu.displayName=Uu;var el="PopperContent",[uS,fS]=$u(el),Hu=b.forwardRef((e,t)=>{const{__scopePopper:r,side:n="bottom",sideOffset:o=0,align:s="center",alignOffset:i=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(el,r),[v,w]=b.useState(null),x=Qe(t,G=>w(G)),[E,P]=b.useState(null),C=Jo(E),N=C?.width??0,_=C?.height??0,A=n+(s!=="center"?"-"+s:""),I=typeof l=="number"?l:{top:0,right:0,bottom:0,left:0,...l},T=Array.isArray(u)?u:[u],U=T.length>0,Q={padding:I,boundary:T.filter(mS),altBoundary:U},{refs:O,floatingStyles:j,placement:L,isPositioned:D,middlewareData:M}=Zw({strategy:"fixed",placement:A,whileElementsMounted:(...G)=>Hw(...G,{animationFrame:m==="always"}),elements:{reference:y.anchor},middleware:[tS({mainAxis:o+_,alignmentAxis:i}),d&&rS({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?nS():void 0,...Q}),d&&oS({...Q}),sS({...Q,apply:({elements:G,rects:ee,availableWidth:Pe,availableHeight:oe})=>{const{width:re,height:be}=ee.reference,de=G.floating.style;de.setProperty("--radix-popper-available-width",`${Pe}px`),de.setProperty("--radix-popper-available-height",`${oe}px`),de.setProperty("--radix-popper-anchor-width",`${re}px`),de.setProperty("--radix-popper-anchor-height",`${be}px`)}}),E&&aS({element:E,padding:a}),hS({arrowWidth:N,arrowHeight:_}),p&&iS({strategy:"referenceHidden",...Q})]}),[R,$]=Gu(L),ie=ar(g);Qt(()=>{D&&ie?.()},[D,ie]);const V=M.arrow?.x,K=M.arrow?.y,X=M.arrow?.centerOffset!==0,[ce,ne]=b.useState();return Qt(()=>{v&&ne(window.getComputedStyle(v).zIndex)},[v]),c.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...j,transform:D?j.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ce,"--radix-popper-transform-origin":[M.transformOrigin?.x,M.transformOrigin?.y].join(" "),...M.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(uS,{scope:r,placedSide:R,onArrowChange:P,arrowX:V,arrowY:K,shouldHideArrow:X,children:c.jsx(Be.div,{"data-side":R,"data-align":$,...h,ref:x,style:{...h.style,animation:D?void 0:"none"}})})})});Hu.displayName=el;var Wu="PopperArrow",pS={top:"bottom",right:"left",bottom:"top",left:"right"},Ru=b.forwardRef(function(t,r){const{__scopePopper:n,...o}=t,s=fS(Wu,n),i=pS[s.placedSide];return c.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:c.jsx(cS,{...o,ref:r,style:{...o.style,display:"block"}})})});Ru.displayName=Wu;function mS(e){return e!==null}var hS=e=>({name:"transformOrigin",options:e,fn(t){const{placement:r,rects:n,middlewareData:o}=t,i=o.arrow?.centerOffset!==0,a=i?0:e.arrowWidth,d=i?0:e.arrowHeight,[u,l]=Gu(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=i?f:`${p}px`,h=`${-d}px`):u==="top"?(g=i?f:`${p}px`,h=`${n.floating.height+d}px`):u==="right"?(g=`${-d}px`,h=i?f:`${m}px`):u==="left"&&(g=`${n.floating.width+d}px`,h=i?f:`${m}px`),{data:{x:g,y:h}}}});function Gu(e){const[t,r="center"]=e.split("-");return[t,r]}var Ku=zu,tl=Vu,qu=Hu,Yu=Ru,gS="Portal",ri=b.forwardRef((e,t)=>{const{container:r,...n}=e,[o,s]=b.useState(!1);Qt(()=>s(!0),[]);const i=r||o&&globalThis?.document?.body;return i?Wc.createPortal(c.jsx(Be.div,{...n,ref:t}),i):null});ri.displayName=gS;function yS(e){const t=bS(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),d=a.find(wS);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,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function bS(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=xS(o),a=SS(s,o.props);return o.type!==b.Fragment&&(a.ref=n?Bn(n,i):i),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var vS=Symbol("radix.slottable");function wS(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===vS}function SS(e,t){const r={...t};for(const n in t){const o=e[n],s=t[n];/^on[A-Z]/.test(n)?o&&s?r[n]=(...a)=>{const d=s(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function xS(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 AS=b[" useInsertionEffect ".trim().toString()]||Qt;function Zr({prop:e,defaultProp:t,onChange:r=()=>{},caller:n}){const[o,s,i]=CS({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=ES(l)?l(e):l;f!==e&&i.current?.(f)}else s(l)},[a,e,s,i]);return[d,u]}function CS({defaultProp:e,onChange:t}){const[r,n]=b.useState(e),o=b.useRef(r),s=b.useRef(t);return AS(()=>{s.current=t},[t]),b.useEffect(()=>{o.current!==r&&(s.current?.(r),o.current=r)},[r,o]),[r,n,s]}function ES(e){return typeof e=="function"}function Qo(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 Xu=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"}),NS="VisuallyHidden",_S=b.forwardRef((e,t)=>c.jsx(Be.span,{...e,ref:t,style:{...Xu,...e.style}}));_S.displayName=NS;var kS=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},ao=new WeakMap,ni=new WeakMap,oi={},rl=0,Ju=function(e){return e&&(e.host||Ju(e.parentNode))},TS=function(e,t){return t.map(function(r){if(e.contains(r))return r;var n=Ju(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})},FS=function(e,t,r,n){var o=TS(t,Array.isArray(e)?e:[e]);oi[r]||(oi[r]=new WeakMap);var s=oi[r],i=[],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=(ao.get(p)||0)+1,y=(s.get(p)||0)+1;ao.set(p,h),s.set(p,y),i.push(p),h===1&&g&&ni.set(p,!0),y===1&&p.setAttribute(r,"true"),g||p.setAttribute(n,"true")}catch(v){console.error("aria-hidden: cannot operate on ",p,v)}})};return l(t),a.clear(),rl++,function(){i.forEach(function(f){var p=ao.get(f)-1,m=s.get(f)-1;ao.set(f,p),s.set(f,m),p||(ni.has(f)||f.removeAttribute(n),ni.delete(f)),m||f.removeAttribute(r)}),rl--,rl||(ao=new WeakMap,ao=new WeakMap,ni=new WeakMap,oi={})}},nl=function(e,t,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(e)?e:[e]),o=kS(e);return o?(n.push.apply(n,Array.from(o.querySelectorAll("[aria-live], script"))),FS(n,o,r,"aria-hidden")):function(){return null}},en=function(){return en=Object.assign||function(t){for(var r,n=1,o=arguments.length;n<o;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])}return t},en.apply(this,arguments)};function Qu(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 PS(e,t,r){if(r||arguments.length===2)for(var n=0,o=t.length,s;n<o;n++)(s||!(n in t))&&(s||(s=Array.prototype.slice.call(t,0,n)),s[n]=t[n]);return e.concat(s||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var si="right-scroll-bar-position",ii="width-before-scroll-bar",OS="with-scroll-bars-hidden",IS="--removed-body-scroll-bar-size";function ol(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function MS(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 LS=typeof window<"u"?b.useLayoutEffect:b.useEffect,Zu=new WeakMap;function DS(e,t){var r=MS(null,function(n){return e.forEach(function(o){return ol(o,n)})});return LS(function(){var n=Zu.get(r);if(n){var o=new Set(n),s=new Set(e),i=r.current;o.forEach(function(a){s.has(a)||ol(a,null)}),s.forEach(function(a){o.has(a)||ol(a,i)})}Zu.set(r,e)},[e]),r}function BS(e){return e}function $S(e,t){t===void 0&&(t=BS);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(s){var i=t(s,n);return r.push(i),function(){r=r.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(n=!0;r.length;){var i=r;r=[],i.forEach(s)}r={push:function(a){return s(a)},filter:function(){return r}}},assignMedium:function(s){n=!0;var i=[];if(r.length){var a=r;r=[],a.forEach(s),i=r}var d=function(){var l=i;i=[],l.forEach(s)},u=function(){return Promise.resolve().then(d)};u(),r={push:function(l){i.push(l),u()},filter:function(l){return i=i.filter(l),r}}}};return o}function jS(e){e===void 0&&(e={});var t=$S(null);return t.options=en({async:!0,ssr:!1},e),t}var ef=function(e){var t=e.sideCar,r=Qu(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,en({},r))};ef.isSideCarExport=!0;function zS(e,t){return e.useMedium(t),ef}var tf=jS(),sl=function(){},ai=b.forwardRef(function(e,t){var r=b.useRef(null),n=b.useState({onScrollCapture:sl,onWheelCapture:sl,onTouchMoveCapture:sl}),o=n[0],s=n[1],i=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,v=e.as,w=v===void 0?"div":v,x=e.gapMode,E=Qu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),P=p,C=DS([r,t]),N=en(en({},E),o);return b.createElement(b.Fragment,null,l&&b.createElement(P,{sideCar:tf,removeScrollBar:u,shards:f,noRelative:m,noIsolation:g,inert:h,setCallbacks:s,allowPinchZoom:!!y,lockRef:r,gapMode:x}),i?b.cloneElement(b.Children.only(a),en(en({},N),{ref:C})):b.createElement(w,en({},N,{className:d,ref:C}),a))});ai.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},ai.classNames={fullWidth:ii,zeroRight:si};var US=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function VS(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=US();return t&&e.setAttribute("nonce",t),e}function HS(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function WS(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var RS=function(){var e=0,t=null;return{add:function(r){e==0&&(t=VS())&&(HS(t,r),WS(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},GS=function(){var e=RS();return function(t,r){b.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&r])}},rf=function(){var e=GS(),t=function(r){var n=r.styles,o=r.dynamic;return e(n,o),null};return t},KS={left:0,top:0,right:0,gap:0},il=function(e){return parseInt(e||"",10)||0},qS=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[il(r),il(n),il(o)]},YS=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return KS;var t=qS(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])}},XS=rf(),lo="data-scroll-locked",JS=function(e,t,r,n){var o=e.left,s=e.top,i=e.right,a=e.gap;return r===void 0&&(r="margin"),`
|
|
2
|
-
.`.concat(
|
|
1
|
+
(function(ge,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):(ge=typeof globalThis<"u"?globalThis:ge||self,S(ge.FormBuilderRenderer={},ge.React,ge.jsxRuntime,ge.ReactRouterDOM,ge.ReactDOM,ge.Sonner,ge.ReactQuery))})(this,(function(ge,S,c,ha,qc,$t,gn){"use strict";function Yc(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=Yc(S),Es=Yc(qc),ga="iq-fbr",In="95px";function Ns(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:In}}function _s(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 s=o;return{rows:s.rows,columns:s.columns,verticalSpacing:s.verticalSpacing??s.spacing,horizontalSpacing:s.horizontalSpacing??s.spacing,rowHeight:s.rowHeight,spacing:s.spacing}}return null}function Xc(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=Xc(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function Jc(){for(var e,t,r=0,n="",o=arguments.length;r<o;r++)(e=arguments[r])&&(t=Xc(e))&&(n&&(n+=" "),n+=t);return n}const Py=(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},Oy=(e,t)=>({classGroupId:e,validator:t}),Qc=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),ks="-",Zc=[],Iy="arbitrary..",My=e=>{const t=Dy(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return Ly(i);const a=i.split(ks),d=a[0]===""&&a.length>1?1:0;return ed(a,d,t)},getConflictingClassGroupIds:(i,a)=>{if(a){const d=n[i],u=r[i];return d?u?Py(u,d):d:u||Zc}return r[i]||Zc}}},ed=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const o=e[t],s=r.nextPart.get(o);if(s){const u=ed(e,t+1,s);if(u)return u}const i=r.validators;if(i===null)return;const a=t===0?e.join(ks):e.slice(t).join(ks),d=i.length;for(let u=0;u<d;u++){const l=i[u];if(l.validator(a))return l.classGroupId}},Ly=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?Iy+n:void 0})(),Dy=e=>{const{theme:t,classGroups:r}=e;return By(r,t)},By=(e,t)=>{const r=Qc();for(const n in e){const o=e[n];ya(o,r,n,t)}return r},ya=(e,t,r,n)=>{const o=e.length;for(let s=0;s<o;s++){const i=e[s];$y(i,t,r,n)}},$y=(e,t,r,n)=>{if(typeof e=="string"){jy(e,t,r);return}if(typeof e=="function"){zy(e,t,r,n);return}Uy(e,t,r,n)},jy=(e,t,r)=>{const n=e===""?t:td(t,e);n.classGroupId=r},zy=(e,t,r,n)=>{if(Vy(e)){ya(e(n),t,r,n);return}t.validators===null&&(t.validators=[]),t.validators.push(Oy(r,e))},Uy=(e,t,r,n)=>{const o=Object.entries(e),s=o.length;for(let i=0;i<s;i++){const[a,d]=o[i];ya(d,td(t,a),r,n)}},td=(e,t)=>{let r=e;const n=t.split(ks),o=n.length;for(let s=0;s<o;s++){const i=n[s];let a=r.nextPart.get(i);a||(a=Qc(),r.nextPart.set(i,a)),r=a}return r},Vy=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Hy=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=Object.create(null),n=Object.create(null);const o=(s,i)=>{r[s]=i,t++,t>e&&(t=0,n=r,r=Object.create(null))};return{get(s){let i=r[s];if(i!==void 0)return i;if((i=n[s])!==void 0)return o(s,i),i},set(s,i){s in r?r[s]=i:o(s,i)}}},ba="!",rd=":",Wy=[],nd=(e,t,r,n,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:n,isExternal:o}),Ry=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=o=>{const s=[];let i=0,a=0,d=0,u;const l=o.length;for(let h=0;h<l;h++){const y=o[h];if(i===0&&a===0){if(y===rd){s.push(o.slice(d,h)),d=h+1;continue}if(y==="/"){u=h;continue}}y==="["?i++:y==="]"?i--:y==="("?a++:y===")"&&a--}const f=s.length===0?o:o.slice(d);let p=f,m=!1;f.endsWith(ba)?(p=f.slice(0,-1),m=!0):f.startsWith(ba)&&(p=f.slice(1),m=!0);const g=u&&u>d?u-d:void 0;return nd(s,m,p,g)};if(t){const o=t+rd,s=n;n=i=>i.startsWith(o)?s(i.slice(o.length)):nd(Wy,!1,i,void 0,!0)}if(r){const o=n;n=s=>r({className:s,parseClassName:o})}return n},Gy=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((r,n)=>{t.set(r,1e6+n)}),r=>{const n=[];let o=[];for(let s=0;s<r.length;s++){const i=r[s],a=i[0]==="[",d=t.has(i);a||d?(o.length>0&&(o.sort(),n.push(...o),o=[]),n.push(i)):o.push(i)}return o.length>0&&(o.sort(),n.push(...o)),n}},Ky=e=>({cache:Hy(e.cacheSize),parseClassName:Ry(e),sortModifiers:Gy(e),...My(e)}),qy=/\s+/,Yy=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:o,sortModifiers:s}=t,i=[],a=e.trim().split(qy);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,v=n(y?g.substring(0,h):g);if(!v){if(!y){d=l+(d.length>0?" "+d:d);continue}if(v=n(g),!v){d=l+(d.length>0?" "+d:d);continue}y=!1}const w=p.length===0?"":p.length===1?p[0]:s(p).join(":"),x=m?w+ba:w,E=x+v;if(i.indexOf(E)>-1)continue;i.push(E);const P=o(v,y);for(let C=0;C<P.length;++C){const N=P[C];i.push(x+N)}d=l+(d.length>0?" "+d:d)}return d},Xy=(...e)=>{let t=0,r,n,o="";for(;t<e.length;)(r=e[t++])&&(n=od(r))&&(o&&(o+=" "),o+=n);return o},od=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=od(e[n]))&&(r&&(r+=" "),r+=t);return r},Jy=(e,...t)=>{let r,n,o,s;const i=d=>{const u=t.reduce((l,f)=>f(l),e());return r=Ky(u),n=r.cache.get,o=r.cache.set,s=a,a(d)},a=d=>{const u=n(d);if(u)return u;const l=Yy(d,r);return o(d,l),l};return s=i,(...d)=>s(Xy(...d))},Qy=[],Rt=e=>{const t=r=>r[e]||Qy;return t.isThemeGetter=!0,t},sd=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,id=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Zy=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,eb=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,tb=/\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$/,rb=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,nb=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ob=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,yn=e=>Zy.test(e),it=e=>!!e&&!Number.isNaN(Number(e)),bn=e=>!!e&&Number.isInteger(Number(e)),va=e=>e.endsWith("%")&&it(e.slice(0,-1)),nn=e=>eb.test(e),ad=()=>!0,sb=e=>tb.test(e)&&!rb.test(e),wa=()=>!1,ib=e=>nb.test(e),ab=e=>ob.test(e),lb=e=>!_e(e)&&!ke(e),cb=e=>vn(e,pd,wa),_e=e=>sd.test(e),Mn=e=>vn(e,md,sb),ld=e=>vn(e,yb,it),db=e=>vn(e,gd,ad),ub=e=>vn(e,hd,wa),cd=e=>vn(e,ud,wa),fb=e=>vn(e,fd,ab),Ts=e=>vn(e,yd,ib),ke=e=>id.test(e),Lo=e=>Ln(e,md),pb=e=>Ln(e,hd),dd=e=>Ln(e,ud),mb=e=>Ln(e,pd),hb=e=>Ln(e,fd),Fs=e=>Ln(e,yd,!0),gb=e=>Ln(e,gd,!0),vn=(e,t,r)=>{const n=sd.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},Ln=(e,t,r=!1)=>{const n=id.exec(e);return n?n[1]?t(n[1]):r:!1},ud=e=>e==="position"||e==="percentage",fd=e=>e==="image"||e==="url",pd=e=>e==="length"||e==="size"||e==="bg-size",md=e=>e==="length",yb=e=>e==="number",hd=e=>e==="family-name",gd=e=>e==="number"||e==="weight",yd=e=>e==="shadow",bb=Jy(()=>{const e=Rt("color"),t=Rt("font"),r=Rt("text"),n=Rt("font-weight"),o=Rt("tracking"),s=Rt("leading"),i=Rt("breakpoint"),a=Rt("container"),d=Rt("spacing"),u=Rt("radius"),l=Rt("shadow"),f=Rt("inset-shadow"),p=Rt("text-shadow"),m=Rt("drop-shadow"),g=Rt("blur"),h=Rt("perspective"),y=Rt("aspect"),v=Rt("ease"),w=Rt("animate"),x=()=>["auto","avoid","all","avoid-page","page","left","right","column"],E=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],P=()=>[...E(),ke,_e],C=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto","contain","none"],_=()=>[ke,_e,d],A=()=>[yn,"full","auto",..._()],I=()=>[bn,"none","subgrid",ke,_e],T=()=>["auto",{span:["full",bn,ke,_e]},bn,ke,_e],W=()=>[bn,"auto",ke,_e],J=()=>["auto","min","max","fr",ke,_e],O=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],j=()=>["start","end","center","stretch","center-safe","end-safe"],M=()=>["auto",..._()],D=()=>[yn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",..._()],L=()=>[yn,"screen","full","dvw","lvw","svw","min","max","fit",..._()],U=()=>[yn,"screen","full","lh","dvh","lvh","svh","min","max","fit",..._()],$=()=>[e,ke,_e],ie=()=>[...E(),dd,cd,{position:[ke,_e]}],V=()=>["no-repeat",{repeat:["","x","y","space","round"]}],K=()=>["auto","cover","contain",mb,cb,{size:[ke,_e]}],X=()=>[va,Lo,Mn],ce=()=>["","none","full",u,ke,_e],ne=()=>["",it,Lo,Mn],G=()=>["solid","dashed","dotted","double"],ee=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Pe=()=>[it,va,dd,cd],oe=()=>["","none",g,ke,_e],re=()=>["none",it,ke,_e],be=()=>["none",it,ke,_e],de=()=>[it,ke,_e],ot=()=>[yn,"full",..._()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[nn],breakpoint:[nn],color:[ad],container:[nn],"drop-shadow":[nn],ease:["in","out","in-out"],font:[lb],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[nn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[nn],shadow:[nn],spacing:["px",it],text:[nn],"text-shadow":[nn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",yn,_e,ke,y]}],container:["container"],columns:[{columns:[it,_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:C()}],"overflow-x":[{"overflow-x":C()}],"overflow-y":[{"overflow-y":C()}],overscroll:[{overscroll:N()}],"overscroll-x":[{"overscroll-x":N()}],"overscroll-y":[{"overscroll-y":N()}],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:[bn,"auto",ke,_e]}],basis:[{basis:[yn,"full","auto",a,..._()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[it,yn,"auto","initial","none",_e]}],grow:[{grow:["",it,ke,_e]}],shrink:[{shrink:["",it,ke,_e]}],order:[{order:[bn,"first","last","none",ke,_e]}],"grid-cols":[{"grid-cols":I()}],"col-start-end":[{col:T()}],"col-start":[{"col-start":W()}],"col-end":[{"col-end":W()}],"grid-rows":[{"grid-rows":I()}],"row-start-end":[{row:T()}],"row-start":[{"row-start":W()}],"row-end":[{"row-end":W()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":J()}],"auto-rows":[{"auto-rows":J()}],gap:[{gap:_()}],"gap-x":[{"gap-x":_()}],"gap-y":[{"gap-y":_()}],"justify-content":[{justify:[...O(),"normal"]}],"justify-items":[{"justify-items":[...j(),"normal"]}],"justify-self":[{"justify-self":["auto",...j()]}],"align-content":[{content:["normal",...O()]}],"align-items":[{items:[...j(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...j(),{baseline:["","last"]}]}],"place-content":[{"place-content":O()}],"place-items":[{"place-items":[...j(),"baseline"]}],"place-self":[{"place-self":["auto",...j()]}],p:[{p:_()}],px:[{px:_()}],py:[{py:_()}],ps:[{ps:_()}],pe:[{pe:_()}],pbs:[{pbs:_()}],pbe:[{pbe:_()}],pt:[{pt:_()}],pr:[{pr:_()}],pb:[{pb:_()}],pl:[{pl:_()}],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":_()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":_()}],"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:[i]},...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,Lo,Mn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,gb,db]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",va,_e]}],"font-family":[{font:[pb,ub,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":[it,"none",ke,ld]}],leading:[{leading:[s,..._()]}],"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:$()}],"text-color":[{text:$()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...G(),"wavy"]}],"text-decoration-thickness":[{decoration:[it,"from-font","auto",ke,Mn]}],"text-decoration-color":[{decoration:$()}],"underline-offset":[{"underline-offset":[it,"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:_()}],"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:ie()}],"bg-repeat":[{bg:V()}],"bg-size":[{bg:K()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},bn,ke,_e],radial:["",ke,_e],conic:[bn,ke,_e]},hb,fb]}],"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:ce()}],"rounded-s":[{"rounded-s":ce()}],"rounded-e":[{"rounded-e":ce()}],"rounded-t":[{"rounded-t":ce()}],"rounded-r":[{"rounded-r":ce()}],"rounded-b":[{"rounded-b":ce()}],"rounded-l":[{"rounded-l":ce()}],"rounded-ss":[{"rounded-ss":ce()}],"rounded-se":[{"rounded-se":ce()}],"rounded-ee":[{"rounded-ee":ce()}],"rounded-es":[{"rounded-es":ce()}],"rounded-tl":[{"rounded-tl":ce()}],"rounded-tr":[{"rounded-tr":ce()}],"rounded-br":[{"rounded-br":ce()}],"rounded-bl":[{"rounded-bl":ce()}],"border-w":[{border: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:[...G(),"hidden","none"]}],"divide-style":[{divide:[...G(),"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:[...G(),"none","hidden"]}],"outline-offset":[{"outline-offset":[it,ke,_e]}],"outline-w":[{outline:["",it,Lo,Mn]}],"outline-color":[{outline:$()}],shadow:[{shadow:["","none",l,Fs,Ts]}],"shadow-color":[{shadow:$()}],"inset-shadow":[{"inset-shadow":["none",f,Fs,Ts]}],"inset-shadow-color":[{"inset-shadow":$()}],"ring-w":[{ring:ne()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:$()}],"ring-offset-w":[{"ring-offset":[it,Mn]}],"ring-offset-color":[{"ring-offset":$()}],"inset-ring-w":[{"inset-ring":ne()}],"inset-ring-color":[{"inset-ring":$()}],"text-shadow":[{"text-shadow":["none",p,Fs,Ts]}],"text-shadow-color":[{"text-shadow":$()}],opacity:[{opacity:[it,ke,_e]}],"mix-blend":[{"mix-blend":[...ee(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ee()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[it]}],"mask-image-linear-from-pos":[{"mask-linear-from":Pe()}],"mask-image-linear-to-pos":[{"mask-linear-to":Pe()}],"mask-image-linear-from-color":[{"mask-linear-from":$()}],"mask-image-linear-to-color":[{"mask-linear-to":$()}],"mask-image-t-from-pos":[{"mask-t-from":Pe()}],"mask-image-t-to-pos":[{"mask-t-to":Pe()}],"mask-image-t-from-color":[{"mask-t-from":$()}],"mask-image-t-to-color":[{"mask-t-to":$()}],"mask-image-r-from-pos":[{"mask-r-from":Pe()}],"mask-image-r-to-pos":[{"mask-r-to":Pe()}],"mask-image-r-from-color":[{"mask-r-from":$()}],"mask-image-r-to-color":[{"mask-r-to":$()}],"mask-image-b-from-pos":[{"mask-b-from":Pe()}],"mask-image-b-to-pos":[{"mask-b-to":Pe()}],"mask-image-b-from-color":[{"mask-b-from":$()}],"mask-image-b-to-color":[{"mask-b-to":$()}],"mask-image-l-from-pos":[{"mask-l-from":Pe()}],"mask-image-l-to-pos":[{"mask-l-to":Pe()}],"mask-image-l-from-color":[{"mask-l-from":$()}],"mask-image-l-to-color":[{"mask-l-to":$()}],"mask-image-x-from-pos":[{"mask-x-from":Pe()}],"mask-image-x-to-pos":[{"mask-x-to":Pe()}],"mask-image-x-from-color":[{"mask-x-from":$()}],"mask-image-x-to-color":[{"mask-x-to":$()}],"mask-image-y-from-pos":[{"mask-y-from":Pe()}],"mask-image-y-to-pos":[{"mask-y-to":Pe()}],"mask-image-y-from-color":[{"mask-y-from":$()}],"mask-image-y-to-color":[{"mask-y-to":$()}],"mask-image-radial":[{"mask-radial":[ke,_e]}],"mask-image-radial-from-pos":[{"mask-radial-from":Pe()}],"mask-image-radial-to-pos":[{"mask-radial-to":Pe()}],"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":E()}],"mask-image-conic-pos":[{"mask-conic":[it]}],"mask-image-conic-from-pos":[{"mask-conic-from":Pe()}],"mask-image-conic-to-pos":[{"mask-conic-to":Pe()}],"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:V()}],"mask-size":[{mask:K()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ke,_e]}],filter:[{filter:["","none",ke,_e]}],blur:[{blur:oe()}],brightness:[{brightness:[it,ke,_e]}],contrast:[{contrast:[it,ke,_e]}],"drop-shadow":[{"drop-shadow":["","none",m,Fs,Ts]}],"drop-shadow-color":[{"drop-shadow":$()}],grayscale:[{grayscale:["",it,ke,_e]}],"hue-rotate":[{"hue-rotate":[it,ke,_e]}],invert:[{invert:["",it,ke,_e]}],saturate:[{saturate:[it,ke,_e]}],sepia:[{sepia:["",it,ke,_e]}],"backdrop-filter":[{"backdrop-filter":["","none",ke,_e]}],"backdrop-blur":[{"backdrop-blur":oe()}],"backdrop-brightness":[{"backdrop-brightness":[it,ke,_e]}],"backdrop-contrast":[{"backdrop-contrast":[it,ke,_e]}],"backdrop-grayscale":[{"backdrop-grayscale":["",it,ke,_e]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[it,ke,_e]}],"backdrop-invert":[{"backdrop-invert":["",it,ke,_e]}],"backdrop-opacity":[{"backdrop-opacity":[it,ke,_e]}],"backdrop-saturate":[{"backdrop-saturate":[it,ke,_e]}],"backdrop-sepia":[{"backdrop-sepia":["",it,ke,_e]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":_()}],"border-spacing-x":[{"border-spacing-x":_()}],"border-spacing-y":[{"border-spacing-y":_()}],"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:[it,"initial",ke,_e]}],ease:[{ease:["linear","initial",v,ke,_e]}],delay:[{delay:[it,ke,_e]}],animate:[{animate:["none",w,ke,_e]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[h,ke,_e]}],"perspective-origin":[{"perspective-origin":P()}],rotate:[{rotate:re()}],"rotate-x":[{"rotate-x":re()}],"rotate-y":[{"rotate-y":re()}],"rotate-z":[{"rotate-z":re()}],scale:[{scale:be()}],"scale-x":[{"scale-x":be()}],"scale-y":[{"scale-y":be()}],"scale-z":[{"scale-z":be()}],"scale-3d":["scale-3d"],skew:[{skew:de()}],"skew-x":[{"skew-x":de()}],"skew-y":[{"skew-y":de()}],transform:[{transform:[ke,_e,"","none","gpu","cpu"]}],"transform-origin":[{origin:P()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ot()}],"translate-x":[{"translate-x":ot()}],"translate-y":[{"translate-y":ot()}],"translate-z":[{"translate-z":ot()}],"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",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":_()}],"scroll-mx":[{"scroll-mx":_()}],"scroll-my":[{"scroll-my":_()}],"scroll-ms":[{"scroll-ms":_()}],"scroll-me":[{"scroll-me":_()}],"scroll-mbs":[{"scroll-mbs":_()}],"scroll-mbe":[{"scroll-mbe":_()}],"scroll-mt":[{"scroll-mt":_()}],"scroll-mr":[{"scroll-mr":_()}],"scroll-mb":[{"scroll-mb":_()}],"scroll-ml":[{"scroll-ml":_()}],"scroll-p":[{"scroll-p":_()}],"scroll-px":[{"scroll-px":_()}],"scroll-py":[{"scroll-py":_()}],"scroll-ps":[{"scroll-ps":_()}],"scroll-pe":[{"scroll-pe":_()}],"scroll-pbs":[{"scroll-pbs":_()}],"scroll-pbe":[{"scroll-pbe":_()}],"scroll-pt":[{"scroll-pt":_()}],"scroll-pr":[{"scroll-pr":_()}],"scroll-pb":[{"scroll-pb":_()}],"scroll-pl":[{"scroll-pl":_()}],"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",...$()]}],"stroke-w":[{stroke:[it,Lo,Mn,ld]}],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 B(...e){return bb(Jc(e))}const vb=["richtext","multiselect","radio","checkboxgroup","signature"],wb=3;function Do(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(wb,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 vb.includes(e.type)?Math.max(t,2):t}function bd(e,t){if(e.type==="table"||e.type==="billingGrid"){const s=e.position.columnSpan??t??1;return t!=null?Math.min(s,t):s}if(e.type!=="radio"&&e.type!=="checkboxgroup"){const s=e.position.columnSpan??1;return t!=null?Math.min(s,t):s}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 Bo(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 vd(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 Sb(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 xb(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 Ab(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 Ps(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 Sa(e){const t=Ps(e);return{width:t>=100?"100%":`${t}%`,maxWidth:"100%"}}function Cb(e){return Sa(e)}function xa(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t==="start"||t==="center"||t==="end"||t==="stretch"?t:null}function Aa(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t==="start"||t==="center"||t==="end"?t:null}function Fr(e){if(!e)return"start";const t=xa(e.horizontalAlign);if(t)return t;const r=xa(e.contentAlign);if(r)return r;const n=xa(e.cellAlign);return n||"start"}function $o(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 Os(e){switch(e){case"center":return"items-center";case"end":return"items-end";case"stretch":return"items-stretch";default:return"items-start"}}function Ca(e){switch(e){case"center":return"justify-center";case"end":return"justify-end";case"stretch":return"justify-stretch";default:return"justify-start"}}function jo(e){const t=Aa(e.appearance?.contentVerticalAlign);if(t!==null)switch(t){case"center":return"justify-center";case"end":return"justify-end";default:return"justify-start"}return Ca(Ea(e))}const Eb=jo;function Is(e){if(e.type==="billingGrid"||e.type==="table"||Do(e)>1)return!0;const t=Aa(e.appearance?.contentVerticalAlign);if(t==="center"||t==="end")return!1;if(t==="start")return!0;const r=Ea(e);return r!=="center"&&r!=="end"}function wd(e){const t=e[0];if(!t)return Na(void 0);if(e.length===1)return Na(t);const r=Fr(t.appearance);return B("flex flex-col min-h-0 h-full w-full",Os(r),"justify-start")}function Sd(e){const t=Fr(e),r=$o(e);return B("flex flex-col min-h-0 h-full w-full",Os(t),Ca(r))}function xd(e){if(Ps(e)>=100)return"";const r=Fr(e);return r==="center"?"mx-auto":r==="end"?"ml-auto":""}function Ad(e){if(Ps(e)>=100)return"w-full";const r=Fr(e);return r==="center"||r==="end"?"min-w-0":r==="stretch"?"min-w-0 self-stretch":"min-w-0 self-start"}function Cd(e){return e?e.widthMode==="full"||e.widthMode==="percent"||typeof e.widthPercent=="number"&&!Number.isNaN(e.widthPercent):!1}function to(e){return(e.type==="button"||e.type==="editButton")&&!Cd(e.appearance)}function Ed(e){return to(e)?Fr(e.appearance)==="stretch"?{width:"100%",maxWidth:"100%",minWidth:0}:{width:"auto",maxWidth:"100%"}:Sa(e.appearance)}function Nd(e){return Ed(e)}function _d(e){if(to(e))switch(Fr(e.appearance)){case"center":return"self-center";case"end":return"self-end";case"stretch":return"self-stretch";default:return"self-start"}return Ad(e.appearance)}function kd(e){return e?e.verticalAlign!=null||e.cellJustify!=null:!1}function Ea(e){return e.type!=="button"&&e.type!=="editButton"||kd(e.appearance)?$o(e.appearance):"start"}function Na(e){if(!e)return Sd(void 0);const t=Fr(e.appearance);return B("flex flex-col min-h-0 h-full w-full",Os(t),jo(e))}function Nb(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(Os(Fr(o)),Ca($o(o)))}const _a=S.createContext({gridStretch:!1});function zo(){return S.useContext(_a)}const Td=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},_b=(e=>e?Td(e):Td),kb=e=>e;function Tb(e,t=kb){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 Fd=e=>{const t=_b(e),r=n=>Tb(t,n);return Object.assign(r,t),r},Pd=(e=>e?Fd(e):Fd),Fb=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Pb=/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/,Ob=/^\+?[\d\s-()]{10,}$/,Ib={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:Fb.test(e),url:e=>typeof e!="string"||!e?!0:Pb.test(e),phone:e=>typeof e!="string"||!e?!0:Ob.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 s=n.min==="today"?o:new Date(n.min);if(r<s)return!1}if(n.max){const s=n.max==="today"?o:new Date(n.max);if(r>s)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=s=>r.some(i=>{if(i.endsWith("/*")){const u=i.replace("/*","");if(s.type.startsWith(u))return!0}else if(s.type===i)return!0;const a=s.name.toLowerCase(),d=n[i];return d?d.some(u=>a.endsWith(u)):i.startsWith(".")?a.endsWith(i.toLowerCase()):!1});return e instanceof File?o(e):Array.isArray(e)?e.every(s=>o(s)):!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 Yr(e,t,r={}){const n=Ib[t.type];if(!n)return!0;const o=n(e,t,r);return o===!1?t.message||Mb(t):typeof o=="string"?o:!0}function Mb(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 ${Lb(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 Lb(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}const Db=10;function Ms(e){const t=e.properties;return t?.maxFiles!=null&&t.maxFiles>0?Math.floor(t.maxFiles):t?.multiple===!0?Db:1}function Od(e){return typeof e=="object"&&e!==null&&"url"in e&&typeof e.url=="string"&&e.url.length>0}function Id(e){try{return e.split("?")[0].split("/").filter(Boolean).pop()||e}catch{return e}}function Ls(e){if(e==null)return[];if(typeof e=="string")return e.startsWith("http")?[{url:e,name:Id(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:Id(r)}):Od(r)&&t.push(r);return t}return Od(e)?[e]:[]}function Bb(e,t){return e.slice(0,t)}function ka(e,t){const r=Bb(e,t);return r.length===0?null:t===1?r[0]??null:r}function $b(e){return Ls(e).length}function jb(e){return e==="file"||e==="camera"||e==="photoChoice"}function Ta(e,t){if(!jb(e.type))return;const r=Ms(e);if($b(t)>r)return`Maximum ${r} file(s) allowed`}class Ds{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),s=Number(r),i=n!==void 0?Number(n):void 0;return o.substring(s,i!==void 0?s+i: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),s=new Date(r);if(isNaN(o.getTime())||isNaN(s.getTime()))return null;const a=(s.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,s)=>{if(typeof s=="object"&&s!==null){const i=s[n];return o+(Number(i)||0)}return o},0)}};calculate(t,r){try{const{fields:n,currentValue:o,previousValue:s}=r,i={...n};for(const f in i){const p=i[f];(p==null||p==="")&&(i[f]="")}const a={fields:i,currentValue:o,previousValue:s,...Ds.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 s={fields:n,currentValue:n[o.field],previousValue:r[o.field]},i=this.calculate(o.formula,s);n[o.field]=i===null?"":i}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 Md=new Ds;function Ld(e){if(e==null||e==="")return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:Bs(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:Bs(n)}return null}function Bs(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function zb(e,t=new Date){const r=Bs(e),n=Bs(t);if(n<r)return{years:0,months:0,days:0};let o=n.getFullYear()-r.getFullYear(),s=n.getMonth()-r.getMonth(),i=n.getDate()-r.getDate();if(i<0){s-=1;const a=new Date(n.getFullYear(),n.getMonth(),0).getDate();i+=a}return s<0&&(o-=1,s+=12),{years:Math.max(0,o),months:Math.max(0,s),days:Math.max(0,i)}}function Fa(e){if(e.type!=="number")return;const t=e.properties?.deriveFromDate;if(!(!t?.sourceFieldName||!t.part))return t}function Pr(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(0,t):e}function Pa(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(t):null}function Ub(e,t){const r=Pa(e);return r?`${t.sourceFieldName}${r}`:t.sourceFieldName}function Dd(e,t,r){const n=Pa(t);if(n)return[`${e}${n}`];const o=new Set([e]),s=`${e}__addmore__`;for(const i of Object.keys(r))(i===e||i.startsWith(s))&&o.add(i);return[...o]}function Vb(e,t,r){const n=r?Ub(r,e):e.sourceFieldName,o=Ld(t[n]);if(!o)return null;const s=e.referenceDate==="today"||e.referenceDate==null?new Date:Ld(t[e.referenceDate])??new Date;return zb(o,s)[e.part]}function Bd(e,t){const r=Fa(e);return r?Pr(r.sourceFieldName)===Pr(t):!1}function Oa(e,t,r,n){const o={...t},s=n?Pr(n):void 0;for(const i of e){if(i.type!=="number")continue;const a=Fa(i);if(!a||!i.name||s&&Pr(a.sourceFieldName)!==s)continue;const d=n??a.sourceFieldName,u=Dd(i.name,d,o);for(const l of u){if(r.has(l))continue;const f=Vb(a,o,l);o[l]=f}}return o}function Hb(e,t,r,n){const o={...t},s=Pr(n);for(const i of e){if(!Bd(i,s)||!i.name)continue;const a=Dd(i.name,n,o);for(const d of a)r.delete(d),o[d]=null}return o}function $d(e,t){const r=Pr(t);return e.some(n=>Bd(n,r))}function jd(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 Wb(e,t,r,n){let o=Ia(e,r);return n&&(o=Dn(o,t,r)),o}function Ia(e,t){return e.replace(/\{(?:ctx:|\@)(\w+)\}/g,(r,n)=>t?.[n]!==void 0&&t[n]!==null?String(t[n]):r)}function Dn(e,t,r){let n=e.replace(/\{(?:ctx:|\@)(\w+)\}/g,(o,s)=>r?.[s]!==void 0&&r[s]!==null?String(r[s]):o);return n=n.replace(/\{(\w+)\}/g,(o,s)=>{if(o.includes("ctx:")||o.includes("@"))return o;let i=t[s];if(i==null||i===""){const a=Object.keys(t).find(d=>d.toLowerCase()===s.toLowerCase());a&&(i=t[a])}return i!=null&&i!==""?String(i):o}),n}function $s(e,t){const r=e.match(/\{(\w+)\}/g)||[],n=[];t?.custom&&t.custom.forEach(({value:s})=>{if(s){const i=s.match(/\{(\w+)\}/g)||[];n.push(...i.filter(a=>!a.includes("ctx:")&&!a.includes("@")))}});const o=r.filter(s=>!s.includes("ctx:")&&!s.includes("@"));return new Set([...o.map(s=>s.replace(/[{}]/g,"")),...n.map(s=>s.replace(/[{}]/g,""))])}function Rb(e,t){const r=e[t];return r==null||r===""}function zd(e){const{apiEndpoint:t,apiMethod:r="GET",apiQueryParams:n={},formValues:o,submissionContext:s,apiRealtime:i,additionalRequiredFieldNames:a=[],excludeFormFieldNames:d=[]}=e,u=(r||"GET").toLowerCase(),l=$s(t,n),f=new Set((d||[]).filter(w=>typeof w=="string"&&w.length>0)),p=new Set((a||[]).filter(w=>typeof w=="string"&&w.length>0)),m=new Set([...l,...p]);let g=!1;for(const w of m){const x=!!(i&&l.has(w)),E=p.has(w);if((x||E)&&Rb(o,w)){g=!0;break}}if(g)return{blocked:!0,url:t,postBodyBase:null};let h=t;const y=t.match(/\{(\w+)\}/g)||[];if(h=Ia(h,s),i&&(h=Dn(h,o,s)),n&&Object.keys(n).length>0){const w=n,x=[];if(w.limit){let E=w.limit;i&&(E=Dn(E,o,s)),x.push(`_limit=${encodeURIComponent(E)}`)}if(w.page){let E=w.page;i&&(E=Dn(E,o,s)),x.push(`page=${encodeURIComponent(E)}`)}if(w.sort){let E=w.sort;i&&(E=Dn(E,o,s)),x.push(`sort=${encodeURIComponent(E)}`)}if(w.orderBy){let E=w.orderBy;i&&(E=Dn(E,o,s)),x.push(`orderBy=${encodeURIComponent(E)}`)}if(w.custom?.length&&w.custom.forEach(({key:E,value:P})=>{if(!E||!P)return;let C=Ia(P,s);i&&(C=Dn(C,o,s)),C.match(/\{[^}]+\}/)?C.match(/\{(?!ctx:|\@)(\w+)\}/g)||x.push(`${encodeURIComponent(E)}=`):x.push(`${encodeURIComponent(E)}=${encodeURIComponent(C)}`)}),x.length>0){const E=h.includes("?")?"&":"?";h=`${h}${E}${x.join("&")}`}}if(i&&Object.keys(o).length>0&&u==="get"){const w=C=>C.replace(/\{/g,"").replace(/\}/g,""),x=[];for(const C of n.custom||[])if(C.value){const N=C.value.match(/\{(\w+)\}/g)||[];x.push(...N.map(w))}const E=new Set([...y.map(w),...x]),P={};Object.keys(o).forEach(C=>{!E.has(C)&&!f.has(C)&&(P[C]=o[C])}),Object.keys(P).length>0&&(h=`${h}${h.includes("?")?"&":"?"}${new URLSearchParams(P).toString()}`)}let v=null;if(["post","put","patch"].includes(u))if(i&&Object.keys(o).length>0){v={...o};for(const w of f)delete v[w]}else{v={...o||{}};for(const w of f)delete v[w]}return{blocked:!1,url:h,postBodyBase:v}}const Gb=new Set(["select","multiselect","asyncsearch"]);function Kb(e){return e?.type==="multiselect"?[]:""}function Ud(e){if(!Gb.has(e.type))return[];const t=e.properties??{},r=jd(e),n=new Set,o=r?.apiClientFilter?.matchField?.trim()||t.apiClientFilter?.matchField?.trim();o&&n.add(o);const s=[...Array.isArray(t.dependentFields)?t.dependentFields:[],...Array.isArray(r?.dependentFields)?r.dependentFields:[]];for(const u of s)typeof u=="string"&&u.trim()&&n.add(u.trim());const i=r?.apiEndpoint||t.apiEndpoint,a=r?.apiRealtime??t.apiRealtime,d=r?.apiQueryParams||t.apiQueryParams;if(i&&a)for(const u of $s(i,d))n.add(u);return[...n]}function qb(e,t){const r=Pr(t);return Ud(e).some(n=>Pr(n)===r)}function Yb(e,t){const r=Pr(t);return e.some(n=>qb(n,r))}function Xb(e){const t=new Map;for(const r of e){const n=r.name;if(n)for(const o of Ud(r)){const s=Pr(o),i=t.get(s)??new Set;i.add(n),t.set(s,i)}}return t}function Jb(e,t,r){const n=Pa(t);if(n)return[`${e}${n}`];const o=new Set([e]),s=`${e}__addmore__`;for(const i of Object.keys(r))(i===e||i.startsWith(s))&&o.add(i);return[...o]}function Qb(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 Zb(e,t,r){const n=Xb(e),o=Pr(r),s=new Set,i=[o];for(;i.length>0;){const u=i.shift(),l=n.get(u);if(l)for(const f of l)s.has(f)||(s.add(f),i.push(f))}const a={...t},d=[];for(const u of s){const l=e.find(p=>p.name===u),f=Kb(l);for(const p of Jb(u,r,a))Qb(a[p],f)||d.push(p),a[p]=f}return{values:a,clearedKeys:d}}function Ma(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=Pd((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(),s=o.schema!=null&&o.schema.id===r.id,i=n?.forceReset===!0,a={},d=new Set,u=new Set,l=new Set;r.fields.forEach(y=>{const v=y.name||y.key||y.id;v&&(y.defaultValue!==void 0&&(y.type==="multiselect"?a[v]=Array.isArray(y.defaultValue)?y.defaultValue:y.defaultValue!=null&&y.defaultValue!==""?[String(y.defaultValue)]:[]:a[v]=y.defaultValue),y.hidden||d.add(v),y.disabled||u.add(v),y.validation?.some(w=>w.type==="required")&&l.add(v))});const f=r.steps?.length||1,p=[];r.fields.forEach(y=>{const v=y.properties;v?.valueSource==="calculated"&&v?.formula&&p.push({field:y.name,formula:v.formula})});const m=p.length>0?Md.calculateAll(p,a):{},g=Oa(r.fields,{...a,...m},new Set),h=s&&!i?{...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:i||!s?new Set:o.derivedFieldDirty,isValid:!0,draftId:null})},setFieldValue:(r,n,o)=>{const s=t(),i=s.schema,a=o?.source??"user";let d=new Set(s.derivedFieldDirty);const u=s.values[r];let l={...s.values,[r]:n},f=[];if(i){const p=Pr(r),m=i.fields.find(v=>v.name===p);a==="user"&&m&&Fa(m)&&d.add(r);const g=n==null||n===""||Array.isArray(n)&&n.length===0;if($d(i.fields,r)&&g?l=Hb(i.fields,l,d,r):$d(i.fields,r)&&(l=Oa(i.fields,l,d,r)),a==="user"&&u!==n&&!(Array.isArray(u)&&Array.isArray(n)&&u.length===n.length&&u.every((v,w)=>v===n[w]))&&Yb(i.fields,r)){const v=Zb(i.fields,l,r);l=v.values,f=v.clearedKeys}const y=[];if(i.fields.forEach(v=>{const w=v.properties;w?.valueSource==="calculated"&&w?.formula&&(w.formulaSteps||[]).some(P=>P.type==="field"&&P.fieldName===r)&&y.push({field:v.name,formula:w.formula})}),y.length>0){const v=Md.calculateAll(y,l);l={...l,...v}}}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}}),i?.config.validateOnChange?t().validateField(r):e(p=>{const m={...p.errors};return delete m[r],{errors:m}})},setFieldTouched:(r,n=!0)=>{e(s=>({touched:{...s.touched,[r]:n}}));const o=t().schema;n&&o?.config.validateOnBlur&&t().validateField(r)},setFieldError:(r,n)=>{e(o=>{const s=!!o.errors[r];if(!n&&!s||n&&o.errors[r]===n)return o;const i={...o.errors};return n?i[r]=n:delete i[r],{errors:i,isValid:Object.keys(i).length===0}})},setValues:r=>{const n=t(),o=n.schema;if(!o){e({values:r});return}const s=Oa(o.fields,r,n.derivedFieldDirty);e({values:s})},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 s=n.fields.find(a=>a.name===r);if(!s)return;e({isValidating:!0});let i;if(s.validation)for(const a of s.validation){const d=Yr(o[r],a,o);if(typeof d=="string"){i=d;break}}if(!i){const a=Ta(s,o[r]);a&&(i=a)}return e(a=>{const d={...a.errors};return i?d[r]=i:delete d[r],{errors:d,isValid:Object.keys(d).length===0,isValidating:!1}}),i},validateForm:async()=>{const{schema:r,values:n,visibleFields:o,requiredFields:s}=t();if(!r)return!1;e({isValidating:!0});const i={};for(const a of r.fields)if(o.has(a.name)){if(a.validation)for(const d of a.validation){if(d.type==="required"&&!s.has(a.name))continue;const u=Yr(n[a.name],d,n);if(typeof u=="string"){i[a.name]=u;break}}if(!i[a.name]){const d=Ta(a,n[a.name]);d&&(i[a.name]=d)}}return e({errors:i,isValid:Object.keys(i).length===0,isValidating:!1}),Object.keys(i).length===0},validateStep:async r=>{const{schema:n,values:o,visibleFields:s}=t();if(!n||!n.steps)return!0;const i=n.steps[r];if(!i)return!0;e({isValidating:!0});const a={};for(const d of i.fields){const u=n.fields.find(l=>l.name===d);if(u&&s.has(u.name)){if(u.validation)for(const l of u.validation){const f=Yr(o[u.name],l,o);if(typeof f=="string"){a[u.name]=f;break}}if(!a[u.name]){const l=Ta(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(i=>({currentStep:r+1,completedSteps:new Set([...i.completedSteps,r])})),!0):!1},prevStep:()=>{const{currentStep:r}=t();r>0&&e({currentStep:r-1})},goToStep:r=>{const{totalSteps:n,completedSteps:o,currentStep:s}=t();r>=0&&r<n&&(r<=s||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 Ma(n.visibleFields,o)?n:{visibleFields:o}})},updateEnabled:r=>{e(n=>{const o=new Set(r);return Ma(n.enabledFields,o)?n:{enabledFields:o}})},updateRequired:r=>{e(n=>{const o=new Set(r);return Ma(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:s}=JSON.parse(o);return e({values:s,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 ev(){return Nt.getState()}function Vd({schema:e,initialValues:t,onSubmit:r,onChange:n,workflowStepId:o}){const{values:s,errors:i,touched:a,isValidating:d,isSubmitting:u,submitCount:l,isValid:f,currentStep:p,totalSteps:m,completedSteps:g,visibleFields:h,enabledFields:y,requiredFields:v,setSchema:w,setFieldValue:x,setFieldTouched:E,setFieldError:P,setValues:C,resetForm:N,validateField:_,validateForm:A,validateStep:I,nextStep:T,prevStep:W,goToStep:J,setSubmitting:O,incrementSubmitCount:j,saveDraft:M,loadDraft:D,clearDraft:L}=Nt(),U=S.useRef(null);S.useLayoutEffect(()=>{if(w(e,{forceReset:!!o}),t&&Object.keys(t).length>0){const de=Nt.getState().values;C({...de,...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 de;try{de=JSON.stringify(t)}catch{return}if(de===U.current)return;const ot=Nt.getState().values;C({...ot,...t}),U.current=de},[t,C]);const $=S.useCallback((de,ot)=>{const Se={...s,[de]:ot};x(de,ot),n?.(Se,de)},[x,n,s]),ie=S.useCallback(async de=>{if(de?.preventDefault(),j(),!await A())return{success:!1,errors:Object.entries(i).map(([Se,xe])=>({field:Se,rule:"validation",message:xe}))};if(!r)return{success:!0};O(!0);try{const Se=await r(s);return Se.success&&L(),Se}catch(Se){return{success:!1,message:Se instanceof Error?Se.message:"Submission failed"}}finally{O(!1)}},[A,r,s,i,j,O,L]),V=S.useCallback(de=>({value:s[de],error:i[de],touched:a[de]||!1,isVisible:h.has(de),isEnabled:y.has(de),isRequired:v.has(de)}),[s,i,a,h,y,v]),K=S.useMemo(()=>{if(!e.steps||e.steps.length===0)return e.fields;const de=e.steps[p];return de?e.fields.filter(ot=>de.fields.includes(ot.name)):[]},[e,p]),X=p===0,ce=p===m-1,ne=S.useCallback(de=>g.has(de),[g]),G=S.useMemo(()=>m<=1?100:Math.round(g.size/m*100),[g.size,m]),ee=S.useCallback(de=>h.has(de),[h]),Pe=S.useCallback(de=>y.has(de),[y]),oe=S.useCallback(de=>v.has(de),[v]),re=S.useMemo(()=>Object.entries(i).filter(([de])=>h.has(de)),[i,h]),be=re.length>0;return{values:s,errors:i,touched:a,isValidating:d,isSubmitting:u,submitCount:l,isValid:f,hasErrors:be,visibleErrors:re,currentStep:p,totalSteps:m,completedSteps:g,currentStepFields:K,isFirstStep:X,isLastStep:ce,isStepCompleted:ne,progress:G,setFieldValue:$,setFieldTouched:E,setFieldError:P,setValues:C,validateField:_,getFieldState:V,shouldShowField:ee,isFieldEnabled:Pe,isFieldRequired:oe,handleSubmit:ie,resetForm:N,validateForm:A,validateStep:I,nextStep:T,prevStep:W,goToStep:J,saveDraft:M,loadDraft:D,clearDraft:L}}function Hd(e){return"logic"in e&&"conditions"in e}function Uo(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 Wd(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=Wd(e,t);if(r===void 0&&t.includes(".")){const n=t.split(".");if(n.length>=2){const o=n[0],s=n.slice(1).join("."),i=Wd(e,o);Array.isArray(i)&&i.length>0&&(r=Qe(i[0],s))}}return r}const tv=new Set(["section","group","columns","divider","header","sectionHeading","spacer","textLabel","addmore","customizeSections"]);function rv(e){return e===!0||e==="true"?!0:e===!1||e==="false"?!1:e}function nv(e,t){if(e==null||typeof t.path!="string"||!t.path.trim())return!1;const r=Qe(e,t.path),n=rv(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 ov(e,t,r){return e?e==="__allFields__"?t.filter(n=>!tv.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 Rd="__buttonResponse:";function sv({fields:e,values:t,buttonResponses:r,prepopulateResponse:n=null,prepopulateResponseRules:o}){const{updateVisibility:s,updateEnabled:i,updateRequired:a,updateReadOnly:d,updateEditable:u,updateFormDisabled:l}=Nt(),f=S.useCallback(C=>C.name||C.key||C.id,[]),p=S.useCallback((C,N)=>{if(!C)return f(N);const _=e.find(A=>A.id===C||A.name===C||A.key===C);return _?f(_):C},[e,f]),m=S.useCallback(C=>{const N=e.find(_=>_.id===C||_.name===C||_.key===C);return N?f(N):C},[e,f]),g=S.useCallback(C=>{const{field:N,operator:_,value:A}=C;if(typeof N=="string"&&N.startsWith(Rd)){const W=N.slice(Rd.length),J=r?.[W],O=Uo(J);return A==="success"?O:A==="failure"?J!=null&&!O:!1}const I=m(N),T=t[I];switch(_){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 W=Number(T);return W>=Number(A[0])&&W<=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(C=>{const N=C.conditions.map(_=>Hd(_)?h(_):g(_));return C.logic==="and"?N.every(Boolean):N.some(Boolean)},[g]),y=S.useCallback(C=>Hd(C)?h(C):g(C),[g,h]),v=S.useCallback(()=>{const C=new Set,N=new Set,_=new Set,A=new Set,I=new Set;e.forEach(O=>{const j=f(O);O.hidden||C.add(j),O.disabled||N.add(j),O.validation?.some(M=>M.type==="required")&&_.add(j)});let T=!1;if(n!=null&&o?.length)for(const O of o){if(!nv(n,O.when))continue;const{action:j,target:M}=O.then;if(j==="disableForm")T=!0;else if(j==="enableForm")T=!1;else{const D=ov(M,e,f);for(const L of D)switch(j){case"disable":N.delete(L);break;case"enable":N.add(L);break;case"hide":C.delete(L);break;case"show":C.add(L);break;case"readOnly":A.add(L),I.delete(L);break;case"editable":I.add(L),A.delete(L);break}}}e.forEach(O=>{O.conditions&&O.conditions.forEach(j=>{(y(j.when)?j.then:j.else||[]).forEach(L=>{switch(L.action){case"disableForm":T=!0;break;case"enableForm":T=!1;break;default:{const U=p(L.target,O);switch(L.action){case"show":C.add(U);break;case"hide":C.delete(U);break;case"enable":N.add(U);break;case"disable":N.delete(U);break;case"require":_.add(U);break;case"unrequire":_.delete(U);break}break}}})})});const W=O=>e.filter(j=>j.type!=="editButton"&&(j.name||j.key||j.id)).map(j=>f(j)),J=()=>e.filter(O=>O.type==="button").map(O=>f(O));return e.forEach(O=>{if(O.type!=="editButton")return;const j=f(O);if(!Uo(r?.[j]))return;const M=O.properties;M?.rules&&M.rules.length>0?M.rules.forEach(D=>{const L=[];D.allFields&&L.push(...W(O.id)),D.allButtons&&L.push(...J()),D.fieldNames?.length&&D.fieldNames.forEach(U=>{const $=e.find(ie=>f(ie)===U||ie.id===U||ie.name===U);L.push($?f($):U)}),D.buttonNames?.length&&L.push(...D.buttonNames),L.forEach(U=>{switch(D.action){case"enable":N.add(U),A.delete(U);break;case"disable":N.delete(U);break;case"show":C.add(U);break;case"hide":C.delete(U);break;case"readOnly":A.add(U);break;case"editable":I.add(U);break}})}):((M?.enableFieldNames??[]).forEach(D=>N.add(D)),(M?.disableFieldNames??[]).forEach(D=>N.delete(D)),(M?.showFieldNames??[]).forEach(D=>C.add(D)),(M?.hideFieldNames??[]).forEach(D=>C.delete(D)))}),{visible:Array.from(C),enabled:Array.from(N),required:Array.from(_),readOnly:Array.from(A),editable:Array.from(I),formDisabled:T}},[e,y,f,p,t,r,n,o]),w=S.useMemo(()=>v(),[v]);S.useEffect(()=>{s(w.visible),i(w.enabled),a(w.required),d(w.readOnly??[]),u(w.editable??[]),l(w.formDisabled??!1)},[w,s,i,a,d,u,l]);const x=S.useCallback(C=>w.visible.includes(C),[w.visible]),E=S.useCallback(C=>w.enabled.includes(C),[w.enabled]),P=S.useCallback(C=>w.required.includes(C),[w.required]);return{evaluateCondition:y,evaluateExpression:g,evaluateGroup:h,isFieldVisible:x,isFieldEnabled:E,isFieldRequired:P,visibleFields:w.visible,enabledFields:w.enabled,requiredFields:w.required}}function wn({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 Gd(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Bn(...e){return t=>{let r=!1;const n=e.map(o=>{const s=Gd(o,t);return!r&&typeof s=="function"&&(r=!0),s});if(r)return()=>{for(let o=0;o<n.length;o++){const s=n[o];typeof s=="function"?s():Gd(e[o],null)}}}}function Ze(...e){return b.useCallback(Bn(...e),e)}var iv=Symbol.for("react.lazy"),js=b[" use ".trim().toString()];function av(e){return typeof e=="object"&&e!==null&&"then"in e}function Kd(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===iv&&"_payload"in e&&av(e._payload)}function La(e){const t=lv(e),r=b.forwardRef((n,o)=>{let{children:s,...i}=n;Kd(s)&&typeof js=="function"&&(s=js(s._payload));const a=b.Children.toArray(s),d=a.find(dv);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,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}var qd=La("Slot");function lv(e){const t=b.forwardRef((r,n)=>{let{children:o,...s}=r;if(Kd(o)&&typeof js=="function"&&(o=js(o._payload)),b.isValidElement(o)){const i=fv(o),a=uv(s,o.props);return o.type!==b.Fragment&&(a.ref=n?Bn(n,i):i),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 dv(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===cv}function uv(e,t){const r={...t};for(const n in t){const o=e[n],s=t[n];/^on[A-Z]/.test(n)?o&&s?r[n]=(...a)=>{const d=s(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function fv(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 pv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],mv=pv.reduce((e,t)=>{const r=La(`Primitive.${t}`),n=b.forwardRef((o,s)=>{const{asChild:i,...a}=o,d=i?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(d,{...a,ref:s})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),hv="Label",Yd=b.forwardRef((e,t)=>c.jsx(mv.label,{...e,ref:t,onMouseDown:r=>{r.target.closest("button, input, select, textarea")||(e.onMouseDown?.(r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));Yd.displayName=hv;var gv=Yd;function Sn({className:e,...t}){return c.jsx(gv,{"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 zs(e){return`formsmith-label-${e.id}`}function Vo(e){return`formsmith-desc-${e.id}`}function Ho(e){return`formsmith-error-${e.id}`}function jt(e,t){const r=[];return e.description&&r.push(Vo(e)),t&&r.push(Ho(e)),r.length>0?r.join(" "):void 0}function Jt(e){return e?!0:void 0}const yv={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 xn(e){return e.ui?.cellStyle}function bv(e){const t=e.ui;if(!t)return;const r=t.fontToken?yv[t.fontToken]:void 0;if(!(!r&&!t.wrapperStyle))return{...r,...t.wrapperStyle}}function vv(e){return e.type==="button"||e.type==="editButton"}const Et=({field:e,error:t,isRequired:r,children:n,className:o,hideLabel:s})=>{const{gridStretch:i}=zo(),a=i&&Is(e),d=!(s??e.appearance?.hideLabel)&&e.label,u=e.appearance?.labelPlacement||"top",l=bv(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=Nd(e),g=to(e),h=vv(e),y=Fr(e.appearance);return c.jsx("div",{className:B(Sb(u),u!=="floating"&&"space-y-2",a&&!h&&"flex-1 min-h-0 h-full",i&&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",xd(e.appearance),_d(e),a&&!h&&"flex-1 min-h-0",i&&h&&"shrink-0"),style:m,children:[d&&c.jsxs(Sn,{id:zs(e),htmlFor:ht(e),style:e.ui?.labelStyle,className:B(xb(u,!!t)),children:[e.label,r&&c.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),c.jsxs("div",{className:B(Ab(u),h&&i&&"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:Vo(e),className:"text-xs text-muted-foreground",style:e.ui?.descriptionStyle,children:e.description}),t&&c.jsx("p",{id:Ho(e),className:"text-xs text-destructive",role:"alert",children:typeof t=="string"?t:String(t||"An error occurred")})]})]})]})})},Da=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=e.properties,l=S.useCallback(f=>{r(f.target.value)},[r]);return c.jsx(Et,{field:e,error:o,isRequired:a,className:d,children:c.jsx(wn,{id:ht(e),type:"text",value:t||"",onChange:l,onBlur:n,placeholder:e.placeholder,disabled:s||e.disabled,readOnly:i||e.readOnly,minLength:u?.minLength,maxLength:u?.maxLength,pattern:u?.pattern,autoComplete:u?.autoComplete,inputMode:u?.inputMode,"aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:B(Bo(e.appearance),o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})})},Xd=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,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 v=parseFloat(y);isNaN(v)||r(v)},[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(Et,{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(wn,{id:ht(e),type:"text",inputMode:l?"decimal":"numeric",autoComplete:"off",value:t??"",onChange:f,onKeyDown:p,onBlur:n,placeholder:e.placeholder,disabled:s||e.disabled,readOnly:i||e.readOnly,"aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:B(Bo(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 wv=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Sv=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,n)=>n?n.toUpperCase():r.toLowerCase()),Jd=e=>{const t=Sv(e);return t.charAt(0).toUpperCase()+t.slice(1)},Qd=(...e)=>e.filter((t,r,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===r).join(" ").trim(),xv=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Av={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 Cv=S.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:o="",children:s,iconNode:i,...a},d)=>S.createElement("svg",{ref:d,...Av,width:t,height:t,stroke:e,strokeWidth:n?Number(r)*24/Number(t):r,className:Qd("lucide",o),...!s&&!xv(a)&&{"aria-hidden":"true"},...a},[...i.map(([u,l])=>S.createElement(u,l)),...Array.isArray(s)?s:[s]]));const Gt=(e,t)=>{const r=S.forwardRef(({className:n,...o},s)=>S.createElement(Cv,{ref:s,iconNode:t,className:Qd(`lucide-${wv(Jd(e))}`,`lucide-${e}`,n),...o}));return r.displayName=Jd(e),r};const Ev=Gt("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);const Us=Gt("camera",[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);const Vs=Gt("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Wo=Gt("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const Zd=Gt("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Nv=Gt("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);const _v=Gt("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const eu=Gt("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const tu=Gt("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const ru=Gt("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const Ro=Gt("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const kv=Gt("mail",[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]);const Tv=Gt("phone",[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]]);const nu=Gt("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const Fv=Gt("sliders-horizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);const ou=Gt("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);const Go=Gt("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);const Hs=Gt("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const Ko=Gt("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),su=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=S.useCallback(l=>{r(l.target.value)},[r]);return c.jsx(Et,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{className:"relative",children:[c.jsx(kv,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),c.jsx(wn,{id:ht(e),type:"email",value:t||"",onChange:u,onBlur:n,placeholder:e.placeholder||"email@example.com",disabled:s||e.disabled,readOnly:i||e.readOnly,autoComplete:"email",inputMode:"email","aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:B(Bo(e.appearance),"pl-10",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]})})},iu=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=S.useCallback(l=>{const f=l.target.value.replace(/[^\d\s+\-()]/g,"");r(f)},[r]);return c.jsx(Et,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{className:"relative",children:[c.jsx(Tv,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),c.jsx(wn,{id:ht(e),type:"tel",value:t||"",onChange:u,onBlur:n,placeholder:e.placeholder||"+91 12345 67890",disabled:s||e.disabled,readOnly:i||e.readOnly,autoComplete:"tel",inputMode:"tel","aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:B(Bo(e.appearance),"pl-10",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]})})};function Pv({className:e,maxLength:t,showCharacterCount:r=!1,autoResize:n=!1,onChange:o,value:s,...i}){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(()=>{s&&u(String(s).length)},[s]),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:s,...i}),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 au=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const{gridStretch:u}=zo(),l=u&&Is(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(Et,{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(Pv,{id:ht(e),value:t||"",onChange:p,onBlur:n,placeholder:e.placeholder,disabled:s||e.disabled,readOnly:i||e.readOnly,minLength:f?.minLength,maxLength:f?.maxLength,rows:2,"aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:B(vd(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 qo(e,[t,r]){return Math.min(r,Math.max(t,e))}function Me(e,t,{checkForDefaultPrevented:r=!0}={}){return function(o){if(e?.(o),r===!1||!o.defaultPrevented)return t?.(o)}}function Ov(e,t){const r=b.createContext(t),n=s=>{const{children:i,...a}=s,d=b.useMemo(()=>a,Object.values(a));return c.jsx(r.Provider,{value:d,children:i})};n.displayName=e+"Provider";function o(s){const i=b.useContext(r);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[n,o]}function vr(e,t=[]){let r=[];function n(s,i){const a=b.createContext(i),d=r.length;r=[...r,i];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=s+"Provider";function l(f,p){const m=p?.[e]?.[d]||a,g=b.useContext(m);if(g)return g;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,l]}const o=()=>{const s=r.map(i=>b.createContext(i));return function(a){const d=a?.[e]||s;return b.useMemo(()=>({[`__scope${e}`]:{...a,[e]:d}}),[a,d])}};return o.scopeName=e,[n,Iv(o,...t)]}function Iv(...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(s){const i=n.reduce((a,{useScope:d,scopeName:u})=>{const f=d(s)[`__scope${u}`];return{...a,...f}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return r.scopeName=t.scopeName,r}function lu(e){const t=Mv(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),d=a.find(Dv);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,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function Mv(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=$v(o),a=Bv(s,o.props);return o.type!==b.Fragment&&(a.ref=n?Bn(n,i):i),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Lv=Symbol("radix.slottable");function Dv(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Lv}function Bv(e,t){const r={...t};for(const n in t){const o=e[n],s=t[n];/^on[A-Z]/.test(n)?o&&s?r[n]=(...a)=>{const d=s(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function $v(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 Ba(e){const t=e+"CollectionProvider",[r,n]=vr(t),[o,s]=r(t,{collectionRef:{current:null},itemMap:new Map}),i=h=>{const{scope:y,children:v}=h,w=S.useRef(null),x=S.useRef(new Map).current;return c.jsx(o,{scope:y,itemMap:x,collectionRef:w,children:v})};i.displayName=t;const a=e+"CollectionSlot",d=lu(a),u=S.forwardRef((h,y)=>{const{scope:v,children:w}=h,x=s(a,v),E=Ze(y,x.collectionRef);return c.jsx(d,{ref:E,children:w})});u.displayName=a;const l=e+"CollectionItemSlot",f="data-radix-collection-item",p=lu(l),m=S.forwardRef((h,y)=>{const{scope:v,children:w,...x}=h,E=S.useRef(null),P=Ze(y,E),C=s(l,v);return S.useEffect(()=>(C.itemMap.set(E,{ref:E,...x}),()=>{C.itemMap.delete(E)})),c.jsx(p,{[f]:"",ref:P,children:w})});m.displayName=l;function g(h){const y=s(e+"CollectionConsumer",h);return S.useCallback(()=>{const w=y.collectionRef.current;if(!w)return[];const x=Array.from(w.querySelectorAll(`[${f}]`));return Array.from(y.itemMap.values()).sort((C,N)=>x.indexOf(C.ref.current)-x.indexOf(N.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:i,Slot:u,ItemSlot:m},g,n]}var jv=b.createContext(void 0);function ro(e){const t=b.useContext(jv);return e||t||"ltr"}function zv(e){const t=Uv(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),d=a.find(Hv);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,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function Uv(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=Rv(o),a=Wv(s,o.props);return o.type!==b.Fragment&&(a.ref=n?Bn(n,i):i),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Vv=Symbol("radix.slottable");function Hv(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Vv}function Wv(e,t){const r={...t};for(const n in t){const o=e[n],s=t[n];/^on[A-Z]/.test(n)?o&&s?r[n]=(...a)=>{const d=s(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function Rv(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 Gv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Be=Gv.reduce((e,t)=>{const r=zv(`Primitive.${t}`),n=b.forwardRef((o,s)=>{const{asChild:i,...a}=o,d=i?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(d,{...a,ref:s})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function Kv(e,t){e&&Es.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 qv(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 Yv="DismissableLayer",$a="dismissableLayer.update",Xv="dismissableLayer.pointerDownOutside",Jv="dismissableLayer.focusOutside",cu,du=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ws=b.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...d}=e,u=b.useContext(du),[l,f]=b.useState(null),p=l?.ownerDocument??globalThis?.document,[,m]=b.useState({}),g=Ze(t,N=>f(N)),h=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=h.indexOf(y),w=l?h.indexOf(l):-1,x=u.layersWithOutsidePointerEventsDisabled.size>0,E=w>=v,P=ew(N=>{const _=N.target,A=[...u.branches].some(I=>I.contains(_));!E||A||(o?.(N),i?.(N),N.defaultPrevented||a?.())},p),C=tw(N=>{const _=N.target;[...u.branches].some(I=>I.contains(_))||(s?.(N),i?.(N),N.defaultPrevented||a?.())},p);return qv(N=>{w===u.layers.size-1&&(n?.(N),!N.defaultPrevented&&a&&(N.preventDefault(),a()))},p),b.useEffect(()=>{if(l)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(cu=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(l)),u.layers.add(l),uu(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=cu)}},[l,p,r,u]),b.useEffect(()=>()=>{l&&(u.layers.delete(l),u.layersWithOutsidePointerEventsDisabled.delete(l),uu())},[l,u]),b.useEffect(()=>{const N=()=>m({});return document.addEventListener($a,N),()=>document.removeEventListener($a,N)},[]),c.jsx(Be.div,{...d,ref:g,style:{pointerEvents:x?E?"auto":"none":void 0,...e.style},onFocusCapture:Me(e.onFocusCapture,C.onFocusCapture),onBlurCapture:Me(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:Me(e.onPointerDownCapture,P.onPointerDownCapture)})});Ws.displayName=Yv;var Qv="DismissableLayerBranch",Zv=b.forwardRef((e,t)=>{const r=b.useContext(du),n=b.useRef(null),o=Ze(t,n);return b.useEffect(()=>{const s=n.current;if(s)return r.branches.add(s),()=>{r.branches.delete(s)}},[r.branches]),c.jsx(Be.div,{...e,ref:o})});Zv.displayName=Qv;function ew(e,t=globalThis?.document){const r=ar(e),n=b.useRef(!1),o=b.useRef(()=>{});return b.useEffect(()=>{const s=a=>{if(a.target&&!n.current){let d=function(){fu(Xv,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},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,r]),{onPointerDownCapture:()=>n.current=!0}}function tw(e,t=globalThis?.document){const r=ar(e),n=b.useRef(!1);return b.useEffect(()=>{const o=s=>{s.target&&!n.current&&fu(Jv,r,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,r]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function uu(){const e=new CustomEvent($a);document.dispatchEvent(e)}function fu(e,t,r,{discrete:n}){const o=r.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&o.addEventListener(e,t,{once:!0}),n?Kv(o,s):o.dispatchEvent(s)}var ja=0;function za(){b.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??pu()),document.body.insertAdjacentElement("beforeend",e[1]??pu()),ja++,()=>{ja===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),ja--}},[])}function pu(){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 Ua="focusScope.autoFocusOnMount",Va="focusScope.autoFocusOnUnmount",mu={bubbles:!1,cancelable:!0},rw="FocusScope",Rs=b.forwardRef((e,t)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,d]=b.useState(null),u=ar(o),l=ar(s),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 E=x.target;a.contains(E)?f.current=E:An(f.current,{select:!0})},y=function(x){if(m.paused||!a)return;const E=x.relatedTarget;E!==null&&(a.contains(E)||An(f.current,{select:!0}))},v=function(x){if(document.activeElement===document.body)for(const P of x)P.removedNodes.length>0&&An(a)};document.addEventListener("focusin",h),document.addEventListener("focusout",y);const w=new MutationObserver(v);return a&&w.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",h),document.removeEventListener("focusout",y),w.disconnect()}}},[n,a,m.paused]),b.useEffect(()=>{if(a){yu.add(m);const h=document.activeElement;if(!a.contains(h)){const v=new CustomEvent(Ua,mu);a.addEventListener(Ua,u),a.dispatchEvent(v),v.defaultPrevented||(nw(lw(hu(a)),{select:!0}),document.activeElement===h&&An(a))}return()=>{a.removeEventListener(Ua,u),setTimeout(()=>{const v=new CustomEvent(Va,mu);a.addEventListener(Va,l),a.dispatchEvent(v),v.defaultPrevented||An(h??document.body,{select:!0}),a.removeEventListener(Va,l),yu.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,v=document.activeElement;if(y&&v){const w=h.currentTarget,[x,E]=ow(w);x&&E?!h.shiftKey&&v===E?(h.preventDefault(),r&&An(x,{select:!0})):h.shiftKey&&v===x&&(h.preventDefault(),r&&An(E,{select:!0})):v===w&&h.preventDefault()}},[r,n,m.paused]);return c.jsx(Be.div,{tabIndex:-1,...i,ref:p,onKeyDown:g})});Rs.displayName=rw;function nw(e,{select:t=!1}={}){const r=document.activeElement;for(const n of e)if(An(n,{select:t}),document.activeElement!==r)return}function ow(e){const t=hu(e),r=gu(t,e),n=gu(t.reverse(),e);return[r,n]}function hu(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 gu(e,t){for(const r of e)if(!sw(r,{upTo:t}))return r}function sw(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 iw(e){return e instanceof HTMLInputElement&&"select"in e}function An(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&iw(e)&&t&&e.select()}}var yu=aw();function aw(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=bu(e,t),e.unshift(t)},remove(t){e=bu(e,t),e[0]?.resume()}}}function bu(e,t){const r=[...e],n=r.indexOf(t);return n!==-1&&r.splice(n,1),r}function lw(e){return e.filter(t=>t.tagName!=="A")}var Qt=globalThis?.document?b.useLayoutEffect:()=>{},cw=b[" useId ".trim().toString()]||(()=>{}),dw=0;function on(e){const[t,r]=b.useState(cw());return Qt(()=>{r(n=>n??String(dw++))},[e]),e||(t?`radix-${t}`:"")}const uw=["top","right","bottom","left"],Cn=Math.min,wr=Math.max,Gs=Math.round,Ks=Math.floor,Xr=e=>({x:e,y:e}),fw={left:"right",right:"left",bottom:"top",top:"bottom"};function Ha(e,t,r){return wr(e,Cn(t,r))}function sn(e,t){return typeof e=="function"?e(t):e}function an(e){return e.split("-")[0]}function no(e){return e.split("-")[1]}function Wa(e){return e==="x"?"y":"x"}function Ra(e){return e==="y"?"height":"width"}function Jr(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Ga(e){return Wa(Jr(e))}function pw(e,t,r){r===void 0&&(r=!1);const n=no(e),o=Ga(e),s=Ra(o);let i=o==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=qs(i)),[i,qs(i)]}function mw(e){const t=qs(e);return[Ka(e),t,Ka(t)]}function Ka(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const vu=["left","right"],wu=["right","left"],hw=["top","bottom"],gw=["bottom","top"];function yw(e,t,r){switch(e){case"top":case"bottom":return r?t?wu:vu:t?vu:wu;case"left":case"right":return t?hw:gw;default:return[]}}function bw(e,t,r,n){const o=no(e);let s=yw(an(e),r==="start",n);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ka)))),s}function qs(e){const t=an(e);return fw[t]+e.slice(t.length)}function vw(e){return{top:0,right:0,bottom:0,left:0,...e}}function Su(e){return typeof e!="number"?vw(e):{top:e,right:e,bottom:e,left:e}}function Ys(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 xu(e,t,r){let{reference:n,floating:o}=e;const s=Jr(t),i=Ga(t),a=Ra(i),d=an(t),u=s==="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(no(t)){case"start":m[i]-=p*(r&&u?-1:1);break;case"end":m[i]+=p*(r&&u?-1:1);break}return m}async function ww(e,t){var r;t===void 0&&(t={});const{x:n,y:o,platform:s,rects:i,elements:a,strategy:d}=e,{boundary:u="clippingAncestors",rootBoundary:l="viewport",elementContext:f="floating",altBoundary:p=!1,padding:m=0}=sn(t,e),g=Su(m),y=a[p?f==="floating"?"reference":"floating":f],v=Ys(await s.getClippingRect({element:(r=await(s.isElement==null?void 0:s.isElement(y)))==null||r?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:l,strategy:d})),w=f==="floating"?{x:n,y:o,width:i.floating.width,height:i.floating.height}:i.reference,x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),E=await(s.isElement==null?void 0:s.isElement(x))?await(s.getScale==null?void 0:s.getScale(x))||{x:1,y:1}:{x:1,y:1},P=Ys(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:x,strategy:d}):w);return{top:(v.top-P.top+g.top)/E.y,bottom:(P.bottom-v.bottom+g.bottom)/E.y,left:(v.left-P.left+g.left)/E.x,right:(P.right-v.right+g.right)/E.x}}const Sw=50,xw=async(e,t,r)=>{const{placement:n="bottom",strategy:o="absolute",middleware:s=[],platform:i}=r,a=i.detectOverflow?i:{...i,detectOverflow:ww},d=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:l,y:f}=xu(u,n,d),p=n,m=0;const g={};for(let h=0;h<s.length;h++){const y=s[h];if(!y)continue;const{name:v,fn:w}=y,{x,y:E,data:P,reset:C}=await w({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=E??f,g[v]={...g[v],...P},C&&m<Sw&&(m++,typeof C=="object"&&(C.placement&&(p=C.placement),C.rects&&(u=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:l,y:f}=xu(u,p,d)),h=-1)}return{x:l,y:f,placement:p,strategy:o,middlewareData:g}},Aw=e=>({name:"arrow",options:e,async fn(t){const{x:r,y:n,placement:o,rects:s,platform:i,elements:a,middlewareData:d}=t,{element:u,padding:l=0}=sn(e,t)||{};if(u==null)return{};const f=Su(l),p={x:r,y:n},m=Ga(o),g=Ra(m),h=await i.getDimensions(u),y=m==="y",v=y?"top":"left",w=y?"bottom":"right",x=y?"clientHeight":"clientWidth",E=s.reference[g]+s.reference[m]-p[m]-s.floating[g],P=p[m]-s.reference[m],C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let N=C?C[x]:0;(!N||!await(i.isElement==null?void 0:i.isElement(C)))&&(N=a.floating[x]||s.floating[g]);const _=E/2-P/2,A=N/2-h[g]/2-1,I=Cn(f[v],A),T=Cn(f[w],A),W=I,J=N-h[g]-T,O=N/2-h[g]/2+_,j=Ha(W,O,J),M=!d.arrow&&no(o)!=null&&O!==j&&s.reference[g]/2-(O<W?I:T)-h[g]/2<0,D=M?O<W?O-W:O-J:0;return{[m]:p[m]+D,data:{[m]:j,centerOffset:O-j-D,...M&&{alignmentOffset:D}},reset:M}}}),Cw=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var r,n;const{placement:o,middlewareData:s,rects:i,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}=sn(e,t);if((r=s.arrow)!=null&&r.alignmentOffset)return{};const v=an(o),w=Jr(a),x=an(a)===a,E=await(d.isRTL==null?void 0:d.isRTL(u.floating)),P=p||(x||!h?[qs(a)]:mw(a)),C=g!=="none";!p&&C&&P.push(...bw(a,h,g,E));const N=[a,...P],_=await d.detectOverflow(t,y),A=[];let I=((n=s.flip)==null?void 0:n.overflows)||[];if(l&&A.push(_[v]),f){const O=pw(o,i,E);A.push(_[O[0]],_[O[1]])}if(I=[...I,{placement:o,overflows:A}],!A.every(O=>O<=0)){var T,W;const O=(((T=s.flip)==null?void 0:T.index)||0)+1,j=N[O];if(j&&(!(f==="alignment"?w!==Jr(j):!1)||I.every(L=>Jr(L.placement)===w?L.overflows[0]>0:!0)))return{data:{index:O,overflows:I},reset:{placement:j}};let M=(W=I.filter(D=>D.overflows[0]<=0).sort((D,L)=>D.overflows[1]-L.overflows[1])[0])==null?void 0:W.placement;if(!M)switch(m){case"bestFit":{var J;const D=(J=I.filter(L=>{if(C){const U=Jr(L.placement);return U===w||U==="y"}return!0}).map(L=>[L.placement,L.overflows.filter(U=>U>0).reduce((U,$)=>U+$,0)]).sort((L,U)=>L[1]-U[1])[0])==null?void 0:J[0];D&&(M=D);break}case"initialPlacement":M=a;break}if(o!==M)return{reset:{placement:M}}}return{}}}};function Au(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Cu(e){return uw.some(t=>e[t]>=0)}const Ew=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:r,platform:n}=t,{strategy:o="referenceHidden",...s}=sn(e,t);switch(o){case"referenceHidden":{const i=await n.detectOverflow(t,{...s,elementContext:"reference"}),a=Au(i,r.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Cu(a)}}}case"escaped":{const i=await n.detectOverflow(t,{...s,altBoundary:!0}),a=Au(i,r.floating);return{data:{escapedOffsets:a,escaped:Cu(a)}}}default:return{}}}}},Eu=new Set(["left","top"]);async function Nw(e,t){const{placement:r,platform:n,elements:o}=e,s=await(n.isRTL==null?void 0:n.isRTL(o.floating)),i=an(r),a=no(r),d=Jr(r)==="y",u=Eu.has(i)?-1:1,l=s&&d?-1:1,f=sn(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:s,placement:i,middlewareData:a}=t,d=await Nw(t,e);return i===((r=a.offset)==null?void 0:r.placement)&&(n=a.arrow)!=null&&n.alignmentOffset?{}:{x:o+d.x,y:s+d.y,data:{...d,placement:i}}}}},kw=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:n,placement:o,platform:s}=t,{mainAxis:i=!0,crossAxis:a=!1,limiter:d={fn:v=>{let{x:w,y:x}=v;return{x:w,y:x}}},...u}=sn(e,t),l={x:r,y:n},f=await s.detectOverflow(t,u),p=Jr(an(o)),m=Wa(p);let g=l[m],h=l[p];if(i){const v=m==="y"?"top":"left",w=m==="y"?"bottom":"right",x=g+f[v],E=g-f[w];g=Ha(x,g,E)}if(a){const v=p==="y"?"top":"left",w=p==="y"?"bottom":"right",x=h+f[v],E=h-f[w];h=Ha(x,h,E)}const y=d.fn({...t,[m]:g,[p]:h});return{...y,data:{x:y.x-r,y:y.y-n,enabled:{[m]:i,[p]:a}}}}}},Tw=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:r,y:n,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:d=!0,crossAxis:u=!0}=sn(e,t),l={x:r,y:n},f=Jr(o),p=Wa(f);let m=l[p],g=l[f];const h=sn(a,t),y=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(d){const x=p==="y"?"height":"width",E=s.reference[p]-s.floating[x]+y.mainAxis,P=s.reference[p]+s.reference[x]-y.mainAxis;m<E?m=E:m>P&&(m=P)}if(u){var v,w;const x=p==="y"?"width":"height",E=Eu.has(an(o)),P=s.reference[f]-s.floating[x]+(E&&((v=i.offset)==null?void 0:v[f])||0)+(E?0:y.crossAxis),C=s.reference[f]+s.reference[x]+(E?0:((w=i.offset)==null?void 0:w[f])||0)-(E?y.crossAxis:0);g<P?g=P:g>C&&(g=C)}return{[p]:m,[f]:g}}}},Fw=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var r,n;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:d=()=>{},...u}=sn(e,t),l=await i.detectOverflow(t,u),f=an(o),p=no(o),m=Jr(o)==="y",{width:g,height:h}=s.floating;let y,v;f==="top"||f==="bottom"?(y=f,v=p===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(v=f,y=p==="end"?"top":"bottom");const w=h-l.top-l.bottom,x=g-l.left-l.right,E=Cn(h-l[y],w),P=Cn(g-l[v],x),C=!t.middlewareData.shift;let N=E,_=P;if((r=t.middlewareData.shift)!=null&&r.enabled.x&&(_=x),(n=t.middlewareData.shift)!=null&&n.enabled.y&&(N=w),C&&!p){const I=wr(l.left,0),T=wr(l.right,0),W=wr(l.top,0),J=wr(l.bottom,0);m?_=g-2*(I!==0||T!==0?I+T:wr(l.left,l.right)):N=h-2*(W!==0||J!==0?W+J:wr(l.top,l.bottom))}await d({...t,availableWidth:_,availableHeight:N});const A=await i.getDimensions(a.floating);return g!==A.width||h!==A.height?{reset:{rects:!0}}:{}}}};function Xs(){return typeof window<"u"}function oo(e){return Nu(e)?(e.nodeName||"").toLowerCase():"#document"}function Sr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Qr(e){var t;return(t=(Nu(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Nu(e){return Xs()?e instanceof Node||e instanceof Sr(e).Node:!1}function Ur(e){return Xs()?e instanceof Element||e instanceof Sr(e).Element:!1}function ln(e){return Xs()?e instanceof HTMLElement||e instanceof Sr(e).HTMLElement:!1}function _u(e){return!Xs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Sr(e).ShadowRoot}function Yo(e){const{overflow:t,overflowX:r,overflowY:n,display:o}=Vr(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+r)&&o!=="inline"&&o!=="contents"}function Pw(e){return/^(table|td|th)$/.test(oo(e))}function Js(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Ow=/transform|translate|scale|rotate|perspective|filter/,Iw=/paint|layout|strict|content/,$n=e=>!!e&&e!=="none";let qa;function Ya(e){const t=Ur(e)?Vr(e):e;return $n(t.transform)||$n(t.translate)||$n(t.scale)||$n(t.rotate)||$n(t.perspective)||!Xa()&&($n(t.backdropFilter)||$n(t.filter))||Ow.test(t.willChange||"")||Iw.test(t.contain||"")}function Mw(e){let t=En(e);for(;ln(t)&&!so(t);){if(Ya(t))return t;if(Js(t))return null;t=En(t)}return null}function Xa(){return qa==null&&(qa=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),qa}function so(e){return/^(html|body|#document)$/.test(oo(e))}function Vr(e){return Sr(e).getComputedStyle(e)}function Qs(e){return Ur(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function En(e){if(oo(e)==="html")return e;const t=e.assignedSlot||e.parentNode||_u(e)&&e.host||Qr(e);return _u(t)?t.host:t}function ku(e){const t=En(e);return so(t)?e.ownerDocument?e.ownerDocument.body:e.body:ln(t)&&Yo(t)?t:ku(t)}function Xo(e,t,r){var n;t===void 0&&(t=[]),r===void 0&&(r=!0);const o=ku(e),s=o===((n=e.ownerDocument)==null?void 0:n.body),i=Sr(o);if(s){const a=Ja(i);return t.concat(i,i.visualViewport||[],Yo(o)?o:[],a&&r?Xo(a):[])}else return t.concat(o,Xo(o,[],r))}function Ja(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Tu(e){const t=Vr(e);let r=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const o=ln(e),s=o?e.offsetWidth:r,i=o?e.offsetHeight:n,a=Gs(r)!==s||Gs(n)!==i;return a&&(r=s,n=i),{width:r,height:n,$:a}}function Qa(e){return Ur(e)?e:e.contextElement}function io(e){const t=Qa(e);if(!ln(t))return Xr(1);const r=t.getBoundingClientRect(),{width:n,height:o,$:s}=Tu(t);let i=(s?Gs(r.width):r.width)/n,a=(s?Gs(r.height):r.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Lw=Xr(0);function Fu(e){const t=Sr(e);return!Xa()||!t.visualViewport?Lw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Dw(e,t,r){return t===void 0&&(t=!1),!r||t&&r!==Sr(e)?!1:t}function jn(e,t,r,n){t===void 0&&(t=!1),r===void 0&&(r=!1);const o=e.getBoundingClientRect(),s=Qa(e);let i=Xr(1);t&&(n?Ur(n)&&(i=io(n)):i=io(e));const a=Dw(s,r,n)?Fu(s):Xr(0);let d=(o.left+a.x)/i.x,u=(o.top+a.y)/i.y,l=o.width/i.x,f=o.height/i.y;if(s){const p=Sr(s),m=n&&Ur(n)?Sr(n):n;let g=p,h=Ja(g);for(;h&&n&&m!==g;){const y=io(h),v=h.getBoundingClientRect(),w=Vr(h),x=v.left+(h.clientLeft+parseFloat(w.paddingLeft))*y.x,E=v.top+(h.clientTop+parseFloat(w.paddingTop))*y.y;d*=y.x,u*=y.y,l*=y.x,f*=y.y,d+=x,u+=E,g=Sr(h),h=Ja(g)}}return Ys({width:l,height:f,x:d,y:u})}function Zs(e,t){const r=Qs(e).scrollLeft;return t?t.left+r:jn(Qr(e)).left+r}function Pu(e,t){const r=e.getBoundingClientRect(),n=r.left+t.scrollLeft-Zs(e,r),o=r.top+t.scrollTop;return{x:n,y:o}}function Bw(e){let{elements:t,rect:r,offsetParent:n,strategy:o}=e;const s=o==="fixed",i=Qr(n),a=t?Js(t.floating):!1;if(n===i||a&&s)return r;let d={scrollLeft:0,scrollTop:0},u=Xr(1);const l=Xr(0),f=ln(n);if((f||!f&&!s)&&((oo(n)!=="body"||Yo(i))&&(d=Qs(n)),f)){const m=jn(n);u=io(n),l.x=m.x+n.clientLeft,l.y=m.y+n.clientTop}const p=i&&!f&&!s?Pu(i,d):Xr(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 $w(e){return Array.from(e.getClientRects())}function jw(e){const t=Qr(e),r=Qs(e),n=e.ownerDocument.body,o=wr(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),s=wr(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let i=-r.scrollLeft+Zs(e);const a=-r.scrollTop;return Vr(n).direction==="rtl"&&(i+=wr(t.clientWidth,n.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Ou=25;function zw(e,t){const r=Sr(e),n=Qr(e),o=r.visualViewport;let s=n.clientWidth,i=n.clientHeight,a=0,d=0;if(o){s=o.width,i=o.height;const l=Xa();(!l||l&&t==="fixed")&&(a=o.offsetLeft,d=o.offsetTop)}const u=Zs(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<=Ou&&(s-=g)}else u<=Ou&&(s+=u);return{width:s,height:i,x:a,y:d}}function Uw(e,t){const r=jn(e,!0,t==="fixed"),n=r.top+e.clientTop,o=r.left+e.clientLeft,s=ln(e)?io(e):Xr(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,d=o*s.x,u=n*s.y;return{width:i,height:a,x:d,y:u}}function Iu(e,t,r){let n;if(t==="viewport")n=zw(e,r);else if(t==="document")n=jw(Qr(e));else if(Ur(t))n=Uw(t,r);else{const o=Fu(e);n={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Ys(n)}function Mu(e,t){const r=En(e);return r===t||!Ur(r)||so(r)?!1:Vr(r).position==="fixed"||Mu(r,t)}function Vw(e,t){const r=t.get(e);if(r)return r;let n=Xo(e,[],!1).filter(a=>Ur(a)&&oo(a)!=="body"),o=null;const s=Vr(e).position==="fixed";let i=s?En(e):e;for(;Ur(i)&&!so(i);){const a=Vr(i),d=Ya(i);!d&&a.position==="fixed"&&(o=null),(s?!d&&!o:!d&&a.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Yo(i)&&!d&&Mu(e,i))?n=n.filter(l=>l!==i):o=a,i=En(i)}return t.set(e,n),n}function Hw(e){let{element:t,boundary:r,rootBoundary:n,strategy:o}=e;const i=[...r==="clippingAncestors"?Js(t)?[]:Vw(t,this._c):[].concat(r),n],a=Iu(t,i[0],o);let d=a.top,u=a.right,l=a.bottom,f=a.left;for(let p=1;p<i.length;p++){const m=Iu(t,i[p],o);d=wr(m.top,d),u=Cn(m.right,u),l=Cn(m.bottom,l),f=wr(m.left,f)}return{width:u-f,height:l-d,x:f,y:d}}function Ww(e){const{width:t,height:r}=Tu(e);return{width:t,height:r}}function Rw(e,t,r){const n=ln(t),o=Qr(t),s=r==="fixed",i=jn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const d=Xr(0);function u(){d.x=Zs(o)}if(n||!n&&!s)if((oo(t)!=="body"||Yo(o))&&(a=Qs(t)),n){const m=jn(t,!0,s,t);d.x=m.x+t.clientLeft,d.y=m.y+t.clientTop}else o&&u();s&&!n&&o&&u();const l=o&&!n&&!s?Pu(o,a):Xr(0),f=i.left+a.scrollLeft-d.x-l.x,p=i.top+a.scrollTop-d.y-l.y;return{x:f,y:p,width:i.width,height:i.height}}function Za(e){return Vr(e).position==="static"}function Lu(e,t){if(!ln(e)||Vr(e).position==="fixed")return null;if(t)return t(e);let r=e.offsetParent;return Qr(e)===r&&(r=r.ownerDocument.body),r}function Du(e,t){const r=Sr(e);if(Js(e))return r;if(!ln(e)){let o=En(e);for(;o&&!so(o);){if(Ur(o)&&!Za(o))return o;o=En(o)}return r}let n=Lu(e,t);for(;n&&Pw(n)&&Za(n);)n=Lu(n,t);return n&&so(n)&&Za(n)&&!Ya(n)?r:n||Mw(e)||r}const Gw=async function(e){const t=this.getOffsetParent||Du,r=this.getDimensions,n=await r(e.floating);return{reference:Rw(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function Kw(e){return Vr(e).direction==="rtl"}const qw={convertOffsetParentRelativeRectToViewportRelativeRect:Bw,getDocumentElement:Qr,getClippingRect:Hw,getOffsetParent:Du,getElementRects:Gw,getClientRects:$w,getDimensions:Ww,getScale:io,isElement:Ur,isRTL:Kw};function Bu(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Yw(e,t){let r=null,n;const o=Qr(e);function s(){var a;clearTimeout(n),(a=r)==null||a.disconnect(),r=null}function i(a,d){a===void 0&&(a=!1),d===void 0&&(d=1),s();const u=e.getBoundingClientRect(),{left:l,top:f,width:p,height:m}=u;if(a||t(),!p||!m)return;const g=Ks(f),h=Ks(o.clientWidth-(l+p)),y=Ks(o.clientHeight-(f+m)),v=Ks(l),x={rootMargin:-g+"px "+-h+"px "+-y+"px "+-v+"px",threshold:wr(0,Cn(1,d))||1};let E=!0;function P(C){const N=C[0].intersectionRatio;if(N!==d){if(!E)return i();N?i(!1,N):n=setTimeout(()=>{i(!1,1e-7)},1e3)}N===1&&!Bu(u,e.getBoundingClientRect())&&i(),E=!1}try{r=new IntersectionObserver(P,{...x,root:o.ownerDocument})}catch{r=new IntersectionObserver(P,x)}r.observe(e)}return i(!0),s}function Xw(e,t,r,n){n===void 0&&(n={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:d=!1}=n,u=Qa(e),l=o||s?[...u?Xo(u):[],...t?Xo(t):[]]:[];l.forEach(v=>{o&&v.addEventListener("scroll",r,{passive:!0}),s&&v.addEventListener("resize",r)});const f=u&&a?Yw(u,r):null;let p=-1,m=null;i&&(m=new ResizeObserver(v=>{let[w]=v;w&&w.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?jn(e):null;d&&y();function y(){const v=jn(e);h&&!Bu(h,v)&&r(),h=v,g=requestAnimationFrame(y)}return r(),()=>{var v;l.forEach(w=>{o&&w.removeEventListener("scroll",r),s&&w.removeEventListener("resize",r)}),f?.(),(v=m)==null||v.disconnect(),m=null,d&&cancelAnimationFrame(g)}}const Jw=_w,Qw=kw,Zw=Cw,eS=Fw,tS=Ew,$u=Aw,rS=Tw,nS=(e,t,r)=>{const n=new Map,o={platform:qw,...r},s={...o.platform,_c:n};return xw(e,t,{...o,platform:s})};var oS=typeof document<"u",sS=function(){},ei=oS?S.useLayoutEffect:sS;function ti(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(!ti(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 s=o[n];if(!(s==="_owner"&&e.$$typeof)&&!ti(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function ju(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function zu(e,t){const r=ju(e);return Math.round(t*r)/r}function el(e){const t=b.useRef(e);return ei(()=>{t.current=e}),t}function iS(e){e===void 0&&(e={});const{placement:t="bottom",strategy:r="absolute",middleware:n=[],platform:o,elements:{reference:s,floating:i}={},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);ti(p,n)||m(n);const[g,h]=b.useState(null),[y,v]=b.useState(null),w=b.useCallback(L=>{L!==C.current&&(C.current=L,h(L))},[]),x=b.useCallback(L=>{L!==N.current&&(N.current=L,v(L))},[]),E=s||g,P=i||y,C=b.useRef(null),N=b.useRef(null),_=b.useRef(l),A=d!=null,I=el(d),T=el(o),W=el(u),J=b.useCallback(()=>{if(!C.current||!N.current)return;const L={placement:t,strategy:r,middleware:p};T.current&&(L.platform=T.current),nS(C.current,N.current,L).then(U=>{const $={...U,isPositioned:W.current!==!1};O.current&&!ti(_.current,$)&&(_.current=$,Es.flushSync(()=>{f($)}))})},[p,t,r,T,W]);ei(()=>{u===!1&&_.current.isPositioned&&(_.current.isPositioned=!1,f(L=>({...L,isPositioned:!1})))},[u]);const O=b.useRef(!1);ei(()=>(O.current=!0,()=>{O.current=!1}),[]),ei(()=>{if(E&&(C.current=E),P&&(N.current=P),E&&P){if(I.current)return I.current(E,P,J);J()}},[E,P,J,I,A]);const j=b.useMemo(()=>({reference:C,floating:N,setReference:w,setFloating:x}),[w,x]),M=b.useMemo(()=>({reference:E,floating:P}),[E,P]),D=b.useMemo(()=>{const L={position:r,left:0,top:0};if(!M.floating)return L;const U=zu(M.floating,l.x),$=zu(M.floating,l.y);return a?{...L,transform:"translate("+U+"px, "+$+"px)",...ju(M.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:U,top:$}},[r,a,M.floating,l.x,l.y]);return b.useMemo(()=>({...l,update:J,refs:j,elements:M,floatingStyles:D}),[l,J,j,M,D])}const aS=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?$u({element:n.current,padding:o}).fn(r):{}:n?$u({element:n,padding:o}).fn(r):{}}}},lS=(e,t)=>{const r=Jw(e);return{name:r.name,fn:r.fn,options:[e,t]}},cS=(e,t)=>{const r=Qw(e);return{name:r.name,fn:r.fn,options:[e,t]}},dS=(e,t)=>({fn:rS(e).fn,options:[e,t]}),uS=(e,t)=>{const r=Zw(e);return{name:r.name,fn:r.fn,options:[e,t]}},fS=(e,t)=>{const r=eS(e);return{name:r.name,fn:r.fn,options:[e,t]}},pS=(e,t)=>{const r=tS(e);return{name:r.name,fn:r.fn,options:[e,t]}},mS=(e,t)=>{const r=aS(e);return{name:r.name,fn:r.fn,options:[e,t]}};var hS="Arrow",Uu=b.forwardRef((e,t)=>{const{children:r,width:n=10,height:o=5,...s}=e;return c.jsx(Be.svg,{...s,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"})})});Uu.displayName=hS;var gS=Uu;function Jo(e){const[t,r]=b.useState(void 0);return Qt(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});const n=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const d=s.borderBoxSize,u=Array.isArray(d)?d[0]:d;i=u.inlineSize,a=u.blockSize}else i=e.offsetWidth,a=e.offsetHeight;r({width:i,height:a})});return n.observe(e,{box:"border-box"}),()=>n.unobserve(e)}else r(void 0)},[e]),t}var tl="Popper",[Vu,ri]=vr(tl),[yS,Hu]=Vu(tl),Wu=e=>{const{__scopePopper:t,children:r}=e,[n,o]=b.useState(null);return c.jsx(yS,{scope:t,anchor:n,onAnchorChange:o,children:r})};Wu.displayName=tl;var Ru="PopperAnchor",Gu=b.forwardRef((e,t)=>{const{__scopePopper:r,virtualRef:n,...o}=e,s=Hu(Ru,r),i=b.useRef(null),a=Ze(t,i),d=b.useRef(null);return b.useEffect(()=>{const u=d.current;d.current=n?.current||i.current,u!==d.current&&s.onAnchorChange(d.current)}),n?null:c.jsx(Be.div,{...o,ref:a})});Gu.displayName=Ru;var rl="PopperContent",[bS,vS]=Vu(rl),Ku=b.forwardRef((e,t)=>{const{__scopePopper:r,side:n="bottom",sideOffset:o=0,align:s="center",alignOffset:i=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=Hu(rl,r),[v,w]=b.useState(null),x=Ze(t,G=>w(G)),[E,P]=b.useState(null),C=Jo(E),N=C?.width??0,_=C?.height??0,A=n+(s!=="center"?"-"+s:""),I=typeof l=="number"?l:{top:0,right:0,bottom:0,left:0,...l},T=Array.isArray(u)?u:[u],W=T.length>0,J={padding:I,boundary:T.filter(SS),altBoundary:W},{refs:O,floatingStyles:j,placement:M,isPositioned:D,middlewareData:L}=iS({strategy:"fixed",placement:A,whileElementsMounted:(...G)=>Xw(...G,{animationFrame:m==="always"}),elements:{reference:y.anchor},middleware:[lS({mainAxis:o+_,alignmentAxis:i}),d&&cS({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?dS():void 0,...J}),d&&uS({...J}),fS({...J,apply:({elements:G,rects:ee,availableWidth:Pe,availableHeight:oe})=>{const{width:re,height:be}=ee.reference,de=G.floating.style;de.setProperty("--radix-popper-available-width",`${Pe}px`),de.setProperty("--radix-popper-available-height",`${oe}px`),de.setProperty("--radix-popper-anchor-width",`${re}px`),de.setProperty("--radix-popper-anchor-height",`${be}px`)}}),E&&mS({element:E,padding:a}),xS({arrowWidth:N,arrowHeight:_}),p&&pS({strategy:"referenceHidden",...J})]}),[U,$]=Xu(M),ie=ar(g);Qt(()=>{D&&ie?.()},[D,ie]);const V=L.arrow?.x,K=L.arrow?.y,X=L.arrow?.centerOffset!==0,[ce,ne]=b.useState();return Qt(()=>{v&&ne(window.getComputedStyle(v).zIndex)},[v]),c.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...j,transform:D?j.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ce,"--radix-popper-transform-origin":[L.transformOrigin?.x,L.transformOrigin?.y].join(" "),...L.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(bS,{scope:r,placedSide:U,onArrowChange:P,arrowX:V,arrowY:K,shouldHideArrow:X,children:c.jsx(Be.div,{"data-side":U,"data-align":$,...h,ref:x,style:{...h.style,animation:D?void 0:"none"}})})})});Ku.displayName=rl;var qu="PopperArrow",wS={top:"bottom",right:"left",bottom:"top",left:"right"},Yu=b.forwardRef(function(t,r){const{__scopePopper:n,...o}=t,s=vS(qu,n),i=wS[s.placedSide];return c.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:c.jsx(gS,{...o,ref:r,style:{...o.style,display:"block"}})})});Yu.displayName=qu;function SS(e){return e!==null}var xS=e=>({name:"transformOrigin",options:e,fn(t){const{placement:r,rects:n,middlewareData:o}=t,i=o.arrow?.centerOffset!==0,a=i?0:e.arrowWidth,d=i?0:e.arrowHeight,[u,l]=Xu(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=i?f:`${p}px`,h=`${-d}px`):u==="top"?(g=i?f:`${p}px`,h=`${n.floating.height+d}px`):u==="right"?(g=`${-d}px`,h=i?f:`${m}px`):u==="left"&&(g=`${n.floating.width+d}px`,h=i?f:`${m}px`),{data:{x:g,y:h}}}});function Xu(e){const[t,r="center"]=e.split("-");return[t,r]}var Ju=Wu,nl=Gu,Qu=Ku,Zu=Yu,AS="Portal",ni=b.forwardRef((e,t)=>{const{container:r,...n}=e,[o,s]=b.useState(!1);Qt(()=>s(!0),[]);const i=r||o&&globalThis?.document?.body;return i?qc.createPortal(c.jsx(Be.div,{...n,ref:t}),i):null});ni.displayName=AS;function CS(e){const t=ES(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),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,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function ES(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=TS(o),a=kS(s,o.props);return o.type!==b.Fragment&&(a.ref=n?Bn(n,i):i),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var NS=Symbol("radix.slottable");function _S(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===NS}function kS(e,t){const r={...t};for(const n in t){const o=e[n],s=t[n];/^on[A-Z]/.test(n)?o&&s?r[n]=(...a)=>{const d=s(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function TS(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 FS=b[" useInsertionEffect ".trim().toString()]||Qt;function Zr({prop:e,defaultProp:t,onChange:r=()=>{},caller:n}){const[o,s,i]=PS({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=OS(l)?l(e):l;f!==e&&i.current?.(f)}else s(l)},[a,e,s,i]);return[d,u]}function PS({defaultProp:e,onChange:t}){const[r,n]=b.useState(e),o=b.useRef(r),s=b.useRef(t);return FS(()=>{s.current=t},[t]),b.useEffect(()=>{o.current!==r&&(s.current?.(r),o.current=r)},[r,o]),[r,n,s]}function OS(e){return typeof e=="function"}function Qo(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 ef=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"}),IS="VisuallyHidden",MS=b.forwardRef((e,t)=>c.jsx(Be.span,{...e,ref:t,style:{...ef,...e.style}}));MS.displayName=IS;var LS=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},ao=new WeakMap,oi=new WeakMap,si={},ol=0,tf=function(e){return e&&(e.host||tf(e.parentNode))},DS=function(e,t){return t.map(function(r){if(e.contains(r))return r;var n=tf(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})},BS=function(e,t,r,n){var o=DS(t,Array.isArray(e)?e:[e]);si[r]||(si[r]=new WeakMap);var s=si[r],i=[],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=(ao.get(p)||0)+1,y=(s.get(p)||0)+1;ao.set(p,h),s.set(p,y),i.push(p),h===1&&g&&oi.set(p,!0),y===1&&p.setAttribute(r,"true"),g||p.setAttribute(n,"true")}catch(v){console.error("aria-hidden: cannot operate on ",p,v)}})};return l(t),a.clear(),ol++,function(){i.forEach(function(f){var p=ao.get(f)-1,m=s.get(f)-1;ao.set(f,p),s.set(f,m),p||(oi.has(f)||f.removeAttribute(n),oi.delete(f)),m||f.removeAttribute(r)}),ol--,ol||(ao=new WeakMap,ao=new WeakMap,oi=new WeakMap,si={})}},sl=function(e,t,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(e)?e:[e]),o=LS(e);return o?(n.push.apply(n,Array.from(o.querySelectorAll("[aria-live], script"))),BS(n,o,r,"aria-hidden")):function(){return null}},en=function(){return en=Object.assign||function(t){for(var r,n=1,o=arguments.length;n<o;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])}return t},en.apply(this,arguments)};function rf(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 $S(e,t,r){if(r||arguments.length===2)for(var n=0,o=t.length,s;n<o;n++)(s||!(n in t))&&(s||(s=Array.prototype.slice.call(t,0,n)),s[n]=t[n]);return e.concat(s||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var ii="right-scroll-bar-position",ai="width-before-scroll-bar",jS="with-scroll-bars-hidden",zS="--removed-body-scroll-bar-size";function il(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function US(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 VS=typeof window<"u"?b.useLayoutEffect:b.useEffect,nf=new WeakMap;function HS(e,t){var r=US(null,function(n){return e.forEach(function(o){return il(o,n)})});return VS(function(){var n=nf.get(r);if(n){var o=new Set(n),s=new Set(e),i=r.current;o.forEach(function(a){s.has(a)||il(a,null)}),s.forEach(function(a){o.has(a)||il(a,i)})}nf.set(r,e)},[e]),r}function WS(e){return e}function RS(e,t){t===void 0&&(t=WS);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(s){var i=t(s,n);return r.push(i),function(){r=r.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(n=!0;r.length;){var i=r;r=[],i.forEach(s)}r={push:function(a){return s(a)},filter:function(){return r}}},assignMedium:function(s){n=!0;var i=[];if(r.length){var a=r;r=[],a.forEach(s),i=r}var d=function(){var l=i;i=[],l.forEach(s)},u=function(){return Promise.resolve().then(d)};u(),r={push:function(l){i.push(l),u()},filter:function(l){return i=i.filter(l),r}}}};return o}function GS(e){e===void 0&&(e={});var t=RS(null);return t.options=en({async:!0,ssr:!1},e),t}var of=function(e){var t=e.sideCar,r=rf(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,en({},r))};of.isSideCarExport=!0;function KS(e,t){return e.useMedium(t),of}var sf=GS(),al=function(){},li=b.forwardRef(function(e,t){var r=b.useRef(null),n=b.useState({onScrollCapture:al,onWheelCapture:al,onTouchMoveCapture:al}),o=n[0],s=n[1],i=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,v=e.as,w=v===void 0?"div":v,x=e.gapMode,E=rf(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),P=p,C=HS([r,t]),N=en(en({},E),o);return b.createElement(b.Fragment,null,l&&b.createElement(P,{sideCar:sf,removeScrollBar:u,shards:f,noRelative:m,noIsolation:g,inert:h,setCallbacks:s,allowPinchZoom:!!y,lockRef:r,gapMode:x}),i?b.cloneElement(b.Children.only(a),en(en({},N),{ref:C})):b.createElement(w,en({},N,{className:d,ref:C}),a))});li.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},li.classNames={fullWidth:ai,zeroRight:ii};var qS=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function YS(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=qS();return t&&e.setAttribute("nonce",t),e}function XS(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function JS(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var QS=function(){var e=0,t=null;return{add:function(r){e==0&&(t=YS())&&(XS(t,r),JS(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},ZS=function(){var e=QS();return function(t,r){b.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&r])}},af=function(){var e=ZS(),t=function(r){var n=r.styles,o=r.dynamic;return e(n,o),null};return t},ex={left:0,top:0,right:0,gap:0},ll=function(e){return parseInt(e||"",10)||0},tx=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[ll(r),ll(n),ll(o)]},rx=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return ex;var t=tx(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])}},nx=af(),lo="data-scroll-locked",ox=function(e,t,r,n){var o=e.left,s=e.top,i=e.right,a=e.gap;return r===void 0&&(r="margin"),`
|
|
2
|
+
.`.concat(jS,` {
|
|
3
3
|
overflow: hidden `).concat(n,`;
|
|
4
4
|
padding-right: `).concat(a,"px ").concat(n,`;
|
|
5
5
|
}
|
|
@@ -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(ii,` {
|
|
20
20
|
right: `).concat(a,"px ").concat(n,`;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
.`).concat(
|
|
23
|
+
.`).concat(ai,` {
|
|
24
24
|
margin-right: `).concat(a,"px ").concat(n,`;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
.`).concat(
|
|
27
|
+
.`).concat(ii," .").concat(ii,` {
|
|
28
28
|
right: 0 `).concat(n,`;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
.`).concat(
|
|
31
|
+
.`).concat(ai," .").concat(ai,` {
|
|
32
32
|
margin-right: 0 `).concat(n,`;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
body[`).concat(lo,`] {
|
|
36
|
-
`).concat(
|
|
36
|
+
`).concat(zS,": ").concat(a,`px;
|
|
37
37
|
}
|
|
38
|
-
`)},
|
|
38
|
+
`)},lf=function(){var e=parseInt(document.body.getAttribute(lo)||"0",10);return isFinite(e)?e:0},sx=function(){b.useEffect(function(){return document.body.setAttribute(lo,(lf()+1).toString()),function(){var e=lf()-1;e<=0?document.body.removeAttribute(lo):document.body.setAttribute(lo,e.toString())}},[])},ix=function(e){var t=e.noRelative,r=e.noImportant,n=e.gapMode,o=n===void 0?"margin":n;sx();var s=b.useMemo(function(){return rx(o)},[o]);return b.createElement(nx,{styles:ox(s,!t,o,r?"":"!important")})},cl=!1;if(typeof window<"u")try{var ci=Object.defineProperty({},"passive",{get:function(){return cl=!0,!0}});window.addEventListener("test",ci,ci),window.removeEventListener("test",ci,ci)}catch{cl=!1}var co=cl?{passive:!1}:!1,ax=function(e){return e.tagName==="TEXTAREA"},cf=function(e,t){if(!(e instanceof Element))return!1;var r=window.getComputedStyle(e);return r[t]!=="hidden"&&!(r.overflowY===r.overflowX&&!ax(e)&&r[t]==="visible")},lx=function(e){return cf(e,"overflowY")},cx=function(e){return cf(e,"overflowX")},df=function(e,t){var r=t.ownerDocument,n=t;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var o=uf(e,n);if(o){var s=ff(e,n),i=s[1],a=s[2];if(i>a)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},dx=function(e){var t=e.scrollTop,r=e.scrollHeight,n=e.clientHeight;return[t,r,n]},ux=function(e){var t=e.scrollLeft,r=e.scrollWidth,n=e.clientWidth;return[t,r,n]},uf=function(e,t){return e==="v"?lx(t):cx(t)},ff=function(e,t){return e==="v"?dx(t):ux(t)},fx=function(e,t){return e==="h"&&t==="rtl"?-1:1},px=function(e,t,r,n,o){var s=fx(e,window.getComputedStyle(t).direction),i=s*n,a=r.target,d=t.contains(a),u=!1,l=i>0,f=0,p=0;do{if(!a)break;var m=ff(e,a),g=m[0],h=m[1],y=m[2],v=h-y-s*g;(g||v)&&uf(e,a)&&(f+=v,p+=g);var w=a.parentNode;a=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}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},di=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},pf=function(e){return[e.deltaX,e.deltaY]},mf=function(e){return e&&"current"in e?e.current:e},mx=function(e,t){return e[0]===t[0]&&e[1]===t[1]},hx=function(e){return`
|
|
39
39
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
40
40
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
41
|
-
`)},cx=0,uo=[];function dx(e){var t=b.useRef([]),r=b.useRef([0,0]),n=b.useRef(),o=b.useState(cx++)[0],s=b.useState(rf)[0],i=b.useRef(e);b.useEffect(function(){i.current=e},[e]),b.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var h=PS([e.lockRef.current],(e.shards||[]).map(df),!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!i.current.allowPinchZoom;var v=ci(h),w=r.current,x="deltaX"in h?h.deltaX:w[0]-v[0],E="deltaY"in h?h.deltaY:w[1]-v[1],P,C=h.target,N=Math.abs(x)>Math.abs(E)?"h":"v";if("touches"in h&&N==="h"&&C.type==="range")return!1;var _=window.getSelection(),A=_&&_.anchorNode,I=A?A===C||A.contains(C):!1;if(I)return!1;var T=sf(N,C);if(!T)return!0;if(T?P=N:(P=N==="v"?"h":"v",T=sf(N,C)),!T)return!1;if(!n.current&&"changedTouches"in h&&(x||E)&&(n.current=P),!P)return!0;var U=n.current||P;return ix(U,y,h,U==="h"?x:E)},[]),d=b.useCallback(function(h){var y=h;if(!(!uo.length||uo[uo.length-1]!==s)){var v="deltaY"in y?cf(y):ci(y),w=t.current.filter(function(P){return P.name===y.type&&(P.target===y.target||y.target===P.shadowParent)&&ax(P.delta,v)})[0];if(w&&w.should){y.cancelable&&y.preventDefault();return}if(!w){var x=(i.current.shards||[]).map(df).filter(Boolean).filter(function(P){return P.contains(y.target)}),E=x.length>0?a(y,x[0]):!i.current.noIsolation;E&&y.cancelable&&y.preventDefault()}}},[]),u=b.useCallback(function(h,y,v,w){var x={name:h,delta:y,target:v,should:w,shadowParent:ux(v)};t.current.push(x),setTimeout(function(){t.current=t.current.filter(function(E){return E!==x})},1)},[]),l=b.useCallback(function(h){r.current=ci(h),n.current=void 0},[]),f=b.useCallback(function(h){u(h.type,cf(h),h.target,a(h,e.lockRef.current))},[]),p=b.useCallback(function(h){u(h.type,ci(h),h.target,a(h,e.lockRef.current))},[]);b.useEffect(function(){return uo.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener("wheel",d,co),document.addEventListener("touchmove",d,co),document.addEventListener("touchstart",l,co),function(){uo=uo.filter(function(h){return h!==s}),document.removeEventListener("wheel",d,co),document.removeEventListener("touchmove",d,co),document.removeEventListener("touchstart",l,co)}},[]);var m=e.removeScrollBar,g=e.inert;return b.createElement(b.Fragment,null,g?b.createElement(s,{styles:lx(o)}):null,m?b.createElement(ZS,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function ux(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const fx=zS(tf,dx);var di=b.forwardRef(function(e,t){return b.createElement(ai,en({},e,{ref:t,sideCar:fx}))});di.classNames=ai.classNames;var px=[" ","Enter","ArrowUp","ArrowDown"],mx=[" ","Enter"],zn="Select",[ui,fi,hx]=La(zn),[fo]=vr(zn,[hx,ti]),pi=ti(),[gx,Nn]=fo(zn),[yx,bx]=fo(zn),uf=e=>{const{__scopeSelect:t,children:r,open:n,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:d,dir:u,name:l,autoComplete:f,disabled:p,required:m,form:g}=e,h=pi(t),[y,v]=b.useState(null),[w,x]=b.useState(null),[E,P]=b.useState(!1),C=ro(u),[N,_]=Zr({prop:n,defaultProp:o??!1,onChange:s,caller:zn}),[A,I]=Zr({prop:i,defaultProp:a,onChange:d,caller:zn}),T=b.useRef(null),U=y?g||!!y.closest("form"):!0,[Q,O]=b.useState(new Set),j=Array.from(Q).map(L=>L.props.value).join(";");return c.jsx(Ku,{...h,children:c.jsxs(gx,{required:m,scope:t,trigger:y,onTriggerChange:v,valueNode:w,onValueNodeChange:x,valueNodeHasChildren:E,onValueNodeHasChildrenChange:P,contentId:on(),value:A,onValueChange:I,open:N,onOpenChange:_,dir:C,triggerPointerDownPosRef:T,disabled:p,children:[c.jsx(ui.Provider,{scope:t,children:c.jsx(yx,{scope:e.__scopeSelect,onNativeOptionAdd:b.useCallback(L=>{O(D=>new Set(D).add(L))},[]),onNativeOptionRemove:b.useCallback(L=>{O(D=>{const M=new Set(D);return M.delete(L),M})},[]),children:r})}),U?c.jsxs(If,{"aria-hidden":!0,required:m,tabIndex:-1,name:l,autoComplete:f,value:A,onChange:L=>I(L.target.value),disabled:p,form:g,children:[A===void 0?c.jsx("option",{value:""}):null,Array.from(Q)]},j):null]})})};uf.displayName=zn;var ff="SelectTrigger",pf=b.forwardRef((e,t)=>{const{__scopeSelect:r,disabled:n=!1,...o}=e,s=pi(r),i=Nn(ff,r),a=i.disabled||n,d=Qe(t,i.onTriggerChange),u=fi(r),l=b.useRef("touch"),[f,p,m]=Lf(h=>{const y=u().filter(x=>!x.disabled),v=y.find(x=>x.value===i.value),w=Df(y,h,v);w!==void 0&&i.onValueChange(w.value)}),g=h=>{a||(i.onOpenChange(!0),m()),h&&(i.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})};return c.jsx(tl,{asChild:!0,...s,children:c.jsx(Be.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":Mf(i.value)?"":void 0,...o,ref:d,onClick:Me(o.onClick,h=>{h.currentTarget.focus(),l.current!=="mouse"&&g(h)}),onPointerDown:Me(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:Me(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())})})})});pf.displayName=ff;var mf="SelectValue",hf=b.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,style:o,children:s,placeholder:i="",...a}=e,d=Nn(mf,r),{onValueNodeHasChildrenChange:u}=d,l=s!==void 0,f=Qe(t,d.onValueNodeChange);return Qt(()=>{u(l)},[u,l]),c.jsx(Be.span,{...a,ref:f,style:{pointerEvents:"none"},children:Mf(d.value)?c.jsx(c.Fragment,{children:i}):s})});hf.displayName=mf;var vx="SelectIcon",gf=b.forwardRef((e,t)=>{const{__scopeSelect:r,children:n,...o}=e;return c.jsx(Be.span,{"aria-hidden":!0,...o,ref:t,children:n||"▼"})});gf.displayName=vx;var wx="SelectPortal",yf=e=>c.jsx(ri,{asChild:!0,...e});yf.displayName=wx;var Un="SelectContent",bf=b.forwardRef((e,t)=>{const r=Nn(Un,e.__scopeSelect),[n,o]=b.useState();if(Qt(()=>{o(new DocumentFragment)},[]),!r.open){const s=n;return s?Cs.createPortal(c.jsx(vf,{scope:e.__scopeSelect,children:c.jsx(ui.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx(wf,{...e,ref:t})});bf.displayName=Un;var Hr=10,[vf,_n]=fo(Un),Sx="SelectContentImpl",xx=yS("SelectContent.RemoveScroll"),wf=b.forwardRef((e,t)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:d,align:u,alignOffset:l,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:g,hideWhenDetached:h,avoidCollisions:y,...v}=e,w=Nn(Un,r),[x,E]=b.useState(null),[P,C]=b.useState(null),N=Qe(t,G=>E(G)),[_,A]=b.useState(null),[I,T]=b.useState(null),U=fi(r),[Q,O]=b.useState(!1),j=b.useRef(!1);b.useEffect(()=>{if(x)return nl(x)},[x]),$a();const L=b.useCallback(G=>{const[ee,...Pe]=U().map(be=>be.ref.current),[oe]=Pe.slice(-1),re=document.activeElement;for(const be of G)if(be===re||(be?.scrollIntoView({block:"nearest"}),be===ee&&P&&(P.scrollTop=0),be===oe&&P&&(P.scrollTop=P.scrollHeight),be?.focus(),document.activeElement!==re))return},[U,P]),D=b.useCallback(()=>L([_,x]),[L,_,x]);b.useEffect(()=>{Q&&D()},[Q,D]);const{onOpenChange:M,triggerPointerDownPosRef:R}=w;b.useEffect(()=>{if(x){let G={x:0,y:0};const ee=oe=>{G={x:Math.abs(Math.round(oe.pageX)-(R.current?.x??0)),y:Math.abs(Math.round(oe.pageY)-(R.current?.y??0))}},Pe=oe=>{G.x<=10&&G.y<=10?oe.preventDefault():x.contains(oe.target)||M(!1),document.removeEventListener("pointermove",ee),R.current=null};return R.current!==null&&(document.addEventListener("pointermove",ee),document.addEventListener("pointerup",Pe,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ee),document.removeEventListener("pointerup",Pe,{capture:!0})}}},[x,M,R]),b.useEffect(()=>{const G=()=>M(!1);return window.addEventListener("blur",G),window.addEventListener("resize",G),()=>{window.removeEventListener("blur",G),window.removeEventListener("resize",G)}},[M]);const[$,ie]=Lf(G=>{const ee=U().filter(re=>!re.disabled),Pe=ee.find(re=>re.ref.current===document.activeElement),oe=Df(ee,G,Pe);oe&&setTimeout(()=>oe.ref.current.focus())}),V=b.useCallback((G,ee,Pe)=>{const oe=!j.current&&!Pe;(w.value!==void 0&&w.value===ee||oe)&&(A(G),oe&&(j.current=!0))},[w.value]),K=b.useCallback(()=>x?.focus(),[x]),X=b.useCallback((G,ee,Pe)=>{const oe=!j.current&&!Pe;(w.value!==void 0&&w.value===ee||oe)&&T(G)},[w.value]),ce=n==="popper"?ll:Sf,ne=ce===ll?{side:a,sideOffset:d,align:u,alignOffset:l,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:g,hideWhenDetached:h,avoidCollisions:y}:{};return c.jsx(vf,{scope:r,content:x,viewport:P,onViewportChange:C,itemRefCallback:V,selectedItem:_,onItemLeave:K,itemTextRefCallback:X,focusSelectedItem:D,selectedItemText:I,position:n,isPositioned:Q,searchRef:$,children:c.jsx(di,{as:xx,allowPinchZoom:!0,children:c.jsx(Ws,{asChild:!0,trapped:w.open,onMountAutoFocus:G=>{G.preventDefault()},onUnmountAutoFocus:Me(o,G=>{w.trigger?.focus({preventScroll:!0}),G.preventDefault()}),children:c.jsx(Hs,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:G=>G.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:c.jsx(ce,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:G=>G.preventDefault(),...v,...ne,onPlaced:()=>O(!0),ref:N,style:{display:"flex",flexDirection:"column",outline:"none",...v.style},onKeyDown:Me(v.onKeyDown,G=>{const ee=G.ctrlKey||G.altKey||G.metaKey;if(G.key==="Tab"&&G.preventDefault(),!ee&&G.key.length===1&&ie(G.key),["ArrowUp","ArrowDown","Home","End"].includes(G.key)){let oe=U().filter(re=>!re.disabled).map(re=>re.ref.current);if(["ArrowUp","End"].includes(G.key)&&(oe=oe.slice().reverse()),["ArrowUp","ArrowDown"].includes(G.key)){const re=G.target,be=oe.indexOf(re);oe=oe.slice(be+1)}setTimeout(()=>L(oe)),G.preventDefault()}})})})})})})});wf.displayName=Sx;var Ax="SelectItemAlignedPosition",Sf=b.forwardRef((e,t)=>{const{__scopeSelect:r,onPlaced:n,...o}=e,s=Nn(Un,r),i=_n(Un,r),[a,d]=b.useState(null),[u,l]=b.useState(null),f=Qe(t,N=>l(N)),p=fi(r),m=b.useRef(!1),g=b.useRef(!0),{viewport:h,selectedItem:y,selectedItemText:v,focusSelectedItem:w}=i,x=b.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&h&&y&&v){const N=s.trigger.getBoundingClientRect(),_=u.getBoundingClientRect(),A=s.valueNode.getBoundingClientRect(),I=v.getBoundingClientRect();if(s.dir!=="rtl"){const re=I.left-_.left,be=A.left-re,de=N.left-be,ot=N.width+de,Se=Math.max(ot,_.width),xe=window.innerWidth-Hr,ae=qo(be,[Hr,Math.max(Hr,xe-Se)]);a.style.minWidth=ot+"px",a.style.left=ae+"px"}else{const re=_.right-I.right,be=window.innerWidth-A.right-re,de=window.innerWidth-N.right-be,ot=N.width+de,Se=Math.max(ot,_.width),xe=window.innerWidth-Hr,ae=qo(be,[Hr,Math.max(Hr,xe-Se)]);a.style.minWidth=ot+"px",a.style.right=ae+"px"}const T=p(),U=window.innerHeight-Hr*2,Q=h.scrollHeight,O=window.getComputedStyle(u),j=parseInt(O.borderTopWidth,10),L=parseInt(O.paddingTop,10),D=parseInt(O.borderBottomWidth,10),M=parseInt(O.paddingBottom,10),R=j+L+Q+M+D,$=Math.min(y.offsetHeight*5,R),ie=window.getComputedStyle(h),V=parseInt(ie.paddingTop,10),K=parseInt(ie.paddingBottom,10),X=N.top+N.height/2-Hr,ce=U-X,ne=y.offsetHeight/2,G=y.offsetTop+ne,ee=j+L+G,Pe=R-ee;if(ee<=X){const re=T.length>0&&y===T[T.length-1].ref.current;a.style.bottom="0px";const be=u.clientHeight-h.offsetTop-h.offsetHeight,de=Math.max(ce,ne+(re?K:0)+be+D),ot=ee+de;a.style.height=ot+"px"}else{const re=T.length>0&&y===T[0].ref.current;a.style.top="0px";const de=Math.max(X,j+h.offsetTop+(re?V:0)+ne)+Pe;a.style.height=de+"px",h.scrollTop=ee-X+h.offsetTop}a.style.margin=`${Hr}px 0`,a.style.minHeight=$+"px",a.style.maxHeight=U+"px",n?.(),requestAnimationFrame(()=>m.current=!0)}},[p,s.trigger,s.valueNode,a,u,h,y,v,s.dir,n]);Qt(()=>x(),[x]);const[E,P]=b.useState();Qt(()=>{u&&P(window.getComputedStyle(u).zIndex)},[u]);const C=b.useCallback(N=>{N&&g.current===!0&&(x(),w?.(),g.current=!1)},[x,w]);return c.jsx(Ex,{scope:r,contentWrapper:a,shouldExpandOnScrollRef:m,onScrollButtonChange:C,children:c.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:c.jsx(Be.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Sf.displayName=Ax;var Cx="SelectPopperPosition",ll=b.forwardRef((e,t)=>{const{__scopeSelect:r,align:n="start",collisionPadding:o=Hr,...s}=e,i=pi(r);return c.jsx(qu,{...i,...s,ref:t,align:n,collisionPadding:o,style:{boxSizing:"border-box",...s.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)"}})});ll.displayName=Cx;var[Ex,cl]=fo(Un,{}),dl="SelectViewport",xf=b.forwardRef((e,t)=>{const{__scopeSelect:r,nonce:n,...o}=e,s=_n(dl,r),i=cl(dl,r),a=Qe(t,s.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(ui.Slot,{scope:r,children:c.jsx(Be.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Me(o.onScroll,u=>{const l=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:p}=i;if(p?.current&&f){const m=Math.abs(d.current-l.scrollTop);if(m>0){const g=window.innerHeight-Hr*2,h=parseFloat(f.style.minHeight),y=parseFloat(f.style.height),v=Math.max(h,y);if(v<g){const w=v+m,x=Math.min(g,w),E=w-x;f.style.height=x+"px",f.style.bottom==="0px"&&(l.scrollTop=E>0?E:0,f.style.justifyContent="flex-end")}}}d.current=l.scrollTop})})})]})});xf.displayName=dl;var Af="SelectGroup",[Nx,_x]=fo(Af),kx=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=on();return c.jsx(Nx,{scope:r,id:o,children:c.jsx(Be.div,{role:"group","aria-labelledby":o,...n,ref:t})})});kx.displayName=Af;var Cf="SelectLabel",Tx=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=_x(Cf,r);return c.jsx(Be.div,{id:o.id,...n,ref:t})});Tx.displayName=Cf;var mi="SelectItem",[Fx,Ef]=fo(mi),Nf=b.forwardRef((e,t)=>{const{__scopeSelect:r,value:n,disabled:o=!1,textValue:s,...i}=e,a=Nn(mi,r),d=_n(mi,r),u=a.value===n,[l,f]=b.useState(s??""),[p,m]=b.useState(!1),g=Qe(t,w=>d.itemRefCallback?.(w,n,o)),h=on(),y=b.useRef("touch"),v=()=>{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(Fx,{scope:r,value:n,disabled:o,textId:h,isSelected:u,onItemTextChange:b.useCallback(w=>{f(x=>x||(w?.textContent??"").trim())},[]),children:c.jsx(ui.ItemSlot,{scope:r,value:n,disabled:o,textValue:l,children:c.jsx(Be.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,...i,ref:g,onFocus:Me(i.onFocus,()=>m(!0)),onBlur:Me(i.onBlur,()=>m(!1)),onClick:Me(i.onClick,()=>{y.current!=="mouse"&&v()}),onPointerUp:Me(i.onPointerUp,()=>{y.current==="mouse"&&v()}),onPointerDown:Me(i.onPointerDown,w=>{y.current=w.pointerType}),onPointerMove:Me(i.onPointerMove,w=>{y.current=w.pointerType,o?d.onItemLeave?.():y.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Me(i.onPointerLeave,w=>{w.currentTarget===document.activeElement&&d.onItemLeave?.()}),onKeyDown:Me(i.onKeyDown,w=>{d.searchRef?.current!==""&&w.key===" "||(mx.includes(w.key)&&v(),w.key===" "&&w.preventDefault())})})})})});Nf.displayName=mi;var Zo="SelectItemText",_f=b.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,style:o,...s}=e,i=Nn(Zo,r),a=_n(Zo,r),d=Ef(Zo,r),u=bx(Zo,r),[l,f]=b.useState(null),p=Qe(t,v=>f(v),d.onItemTextChange,v=>a.itemTextRefCallback?.(v,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 Qt(()=>(h(g),()=>y(g)),[h,y,g]),c.jsxs(c.Fragment,{children:[c.jsx(Be.span,{id:d.textId,...s,ref:p}),d.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Cs.createPortal(s.children,i.valueNode):null]})});_f.displayName=Zo;var kf="SelectItemIndicator",Tf=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return Ef(kf,r).isSelected?c.jsx(Be.span,{"aria-hidden":!0,...n,ref:t}):null});Tf.displayName=kf;var ul="SelectScrollUpButton",Ff=b.forwardRef((e,t)=>{const r=_n(ul,e.__scopeSelect),n=cl(ul,e.__scopeSelect),[o,s]=b.useState(!1),i=Qe(t,n.onScrollButtonChange);return Qt(()=>{if(r.viewport&&r.isPositioned){let a=function(){const u=d.scrollTop>0;s(u)};const d=r.viewport;return a(),d.addEventListener("scroll",a),()=>d.removeEventListener("scroll",a)}},[r.viewport,r.isPositioned]),o?c.jsx(Of,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:d}=r;a&&d&&(a.scrollTop=a.scrollTop-d.offsetHeight)}}):null});Ff.displayName=ul;var fl="SelectScrollDownButton",Pf=b.forwardRef((e,t)=>{const r=_n(fl,e.__scopeSelect),n=cl(fl,e.__scopeSelect),[o,s]=b.useState(!1),i=Qe(t,n.onScrollButtonChange);return Qt(()=>{if(r.viewport&&r.isPositioned){let a=function(){const u=d.scrollHeight-d.clientHeight,l=Math.ceil(d.scrollTop)<u;s(l)};const d=r.viewport;return a(),d.addEventListener("scroll",a),()=>d.removeEventListener("scroll",a)}},[r.viewport,r.isPositioned]),o?c.jsx(Of,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:d}=r;a&&d&&(a.scrollTop=a.scrollTop+d.offsetHeight)}}):null});Pf.displayName=fl;var Of=b.forwardRef((e,t)=>{const{__scopeSelect:r,onAutoScroll:n,...o}=e,s=_n("SelectScrollButton",r),i=b.useRef(null),a=fi(r),d=b.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return b.useEffect(()=>()=>d(),[d]),Qt(()=>{a().find(l=>l.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[a]),c.jsx(Be.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:Me(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(n,50))}),onPointerMove:Me(o.onPointerMove,()=>{s.onItemLeave?.(),i.current===null&&(i.current=window.setInterval(n,50))}),onPointerLeave:Me(o.onPointerLeave,()=>{d()})})}),Px="SelectSeparator",Ox=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return c.jsx(Be.div,{"aria-hidden":!0,...n,ref:t})});Ox.displayName=Px;var pl="SelectArrow",Ix=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=pi(r),s=Nn(pl,r),i=_n(pl,r);return s.open&&i.position==="popper"?c.jsx(Yu,{...o,...n,ref:t}):null});Ix.displayName=pl;var Mx="SelectBubbleInput",If=b.forwardRef(({__scopeSelect:e,value:t,...r},n)=>{const o=b.useRef(null),s=Qe(n,o),i=Qo(t);return b.useEffect(()=>{const a=o.current;if(!a)return;const d=window.HTMLSelectElement.prototype,l=Object.getOwnPropertyDescriptor(d,"value").set;if(i!==t&&l){const f=new Event("change",{bubbles:!0});l.call(a,t),a.dispatchEvent(f)}},[i,t]),c.jsx(Be.select,{...r,style:{...Xu,...r.style},ref:s,defaultValue:t})});If.displayName=Mx;function Mf(e){return e===""||e===void 0}function Lf(e){const t=ar(e),r=b.useRef(""),n=b.useRef(0),o=b.useCallback(i=>{const a=r.current+i;t(a),(function d(u){r.current=u,window.clearTimeout(n.current),u!==""&&(n.current=window.setTimeout(()=>d(""),1e3))})(a)},[t]),s=b.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,o,s]}function Df(e,t,r){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=r?e.indexOf(r):-1;let i=Lx(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==r));const d=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return d!==r?d:void 0}function Lx(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var Dx=uf,Bx=pf,$x=hf,jx=gf,zx=yf,Ux=bf,Vx=xf,Hx=Nf,Wx=_f,Rx=Tf,Gx=Ff,Kx=Pf;function qx({...e}){return c.jsx(Dx,{"data-slot":"select",...e})}function Yx({className:e,...t}){return c.jsx($x,{"data-slot":"select-value",className:B("truncate min-w-0",e),...t})}function Xx({className:e,size:t="default",children:r,...n}){const o=e?.includes("w-full");return c.jsxs(Bx,{"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(jx,{asChild:!0,children:c.jsx(Wo,{className:"size-4 opacity-50"})})]})}function Jx({className:e,children:t,position:r="popper",...n}){return c.jsx(zx,{children:c.jsxs(Ux,{"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(Qx,{}),c.jsx(Vx,{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(Zx,{})]})})}function ml({className:e,children:t,...r}){return c.jsxs(Hx,{"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(Rx,{children:c.jsx(Us,{className:"size-4"})})}),c.jsx(Wx,{className:"truncate",children:t})]})}function Qx({className:e,...t}){return c.jsx(Gx,{"data-slot":"select-scroll-up-button",className:B("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(vv,{className:"size-4"})})}function Zx({className:e,...t}){return c.jsx(Kx,{"data-slot":"select-scroll-down-button",className:B("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(Wo,{className:"size-4"})})}function Bf(e,t){return function(){return e.apply(t,arguments)}}const{toString:e0}=Object.prototype,{getPrototypeOf:hl}=Object,{iterator:hi,toStringTag:$f}=Symbol,gi=(e=>t=>{const r=e0.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),Wr=e=>(e=e.toLowerCase(),t=>gi(t)===e),yi=e=>t=>typeof t===e,{isArray:po}=Array,mo=yi("undefined");function es(e){return e!==null&&!mo(e)&&e.constructor!==null&&!mo(e.constructor)&&pr(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const jf=Wr("ArrayBuffer");function t0(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&jf(e.buffer),t}const r0=yi("string"),pr=yi("function"),zf=yi("number"),ts=e=>e!==null&&typeof e=="object",n0=e=>e===!0||e===!1,bi=e=>{if(gi(e)!=="object")return!1;const t=hl(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!($f in e)&&!(hi in e)},o0=e=>{if(!ts(e)||es(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},s0=Wr("Date"),i0=Wr("File"),a0=e=>!!(e&&typeof e.uri<"u"),l0=e=>e&&typeof e.getParts<"u",c0=Wr("Blob"),d0=Wr("FileList"),u0=e=>ts(e)&&pr(e.pipe);function f0(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const Uf=f0(),Vf=typeof Uf.FormData<"u"?Uf.FormData:void 0,p0=e=>{let t;return e&&(Vf&&e instanceof Vf||pr(e.append)&&((t=gi(e))==="formdata"||t==="object"&&pr(e.toString)&&e.toString()==="[object FormData]"))},m0=Wr("URLSearchParams"),[h0,g0,y0,b0]=["ReadableStream","Request","Response","Headers"].map(Wr),v0=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function rs(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,o;if(typeof e!="object"&&(e=[e]),po(e))for(n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else{if(es(e))return;const s=r?Object.getOwnPropertyNames(e):Object.keys(e),i=s.length;let a;for(n=0;n<i;n++)a=s[n],t.call(null,e[a],a,e)}}function Hf(e,t){if(es(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 Vn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Wf=e=>!mo(e)&&e!==Vn;function gl(){const{caseless:e,skipUndefined:t}=Wf(this)&&this||{},r={},n=(o,s)=>{if(s==="__proto__"||s==="constructor"||s==="prototype")return;const i=e&&Hf(r,s)||s;bi(r[i])&&bi(o)?r[i]=gl(r[i],o):bi(o)?r[i]=gl({},o):po(o)?r[i]=o.slice():(!t||!mo(o))&&(r[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&rs(arguments[o],n);return r}const w0=(e,t,r,{allOwnKeys:n}={})=>(rs(t,(o,s)=>{r&&pr(o)?Object.defineProperty(e,s,{value:Bf(o,r),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,s,{value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:n}),e),S0=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),x0=(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)},A0=(e,t,r,n)=>{let o,s,i;const a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)i=o[s],(!n||n(i,e,t))&&!a[i]&&(t[i]=e[i],a[i]=!0);e=r!==!1&&hl(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},C0=(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},E0=e=>{if(!e)return null;if(po(e))return e;let t=e.length;if(!zf(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},N0=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&hl(Uint8Array)),_0=(e,t)=>{const n=(e&&e[hi]).call(e);let o;for(;(o=n.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},k0=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},T0=Wr("HTMLFormElement"),F0=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,o){return n.toUpperCase()+o}),Rf=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),P0=Wr("RegExp"),Gf=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};rs(r,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(n[s]=i||o)}),Object.defineProperties(e,n)},O0=e=>{Gf(e,(t,r)=>{if(pr(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=e[r];if(pr(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+"'")})}})},I0=(e,t)=>{const r={},n=o=>{o.forEach(s=>{r[s]=!0})};return po(e)?n(e):n(String(e).split(t)),r},M0=()=>{},L0=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function D0(e){return!!(e&&pr(e.append)&&e[$f]==="FormData"&&e[hi])}const B0=e=>{const t=new Array(10),r=(n,o)=>{if(ts(n)){if(t.indexOf(n)>=0)return;if(es(n))return n;if(!("toJSON"in n)){t[o]=n;const s=po(n)?[]:{};return rs(n,(i,a)=>{const d=r(i,o+1);!mo(d)&&(s[a]=d)}),t[o]=void 0,s}}return n};return r(e,0)},$0=Wr("AsyncFunction"),j0=e=>e&&(ts(e)||pr(e))&&pr(e.then)&&pr(e.catch),Kf=((e,t)=>e?setImmediate:t?((r,n)=>(Vn.addEventListener("message",({source:o,data:s})=>{o===Vn&&s===r&&n.length&&n.shift()()},!1),o=>{n.push(o),Vn.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",pr(Vn.postMessage)),z0=typeof queueMicrotask<"u"?queueMicrotask.bind(Vn):typeof process<"u"&&process.nextTick||Kf,W={isArray:po,isArrayBuffer:jf,isBuffer:es,isFormData:p0,isArrayBufferView:t0,isString:r0,isNumber:zf,isBoolean:n0,isObject:ts,isPlainObject:bi,isEmptyObject:o0,isReadableStream:h0,isRequest:g0,isResponse:y0,isHeaders:b0,isUndefined:mo,isDate:s0,isFile:i0,isReactNativeBlob:a0,isReactNative:l0,isBlob:c0,isRegExp:P0,isFunction:pr,isStream:u0,isURLSearchParams:m0,isTypedArray:N0,isFileList:d0,forEach:rs,merge:gl,extend:w0,trim:v0,stripBOM:S0,inherits:x0,toFlatObject:A0,kindOf:gi,kindOfTest:Wr,endsWith:C0,toArray:E0,forEachEntry:_0,matchAll:k0,isHTMLForm:T0,hasOwnProperty:Rf,hasOwnProp:Rf,reduceDescriptors:Gf,freezeMethods:O0,toObjectSet:I0,toCamelCase:F0,noop:M0,toFiniteNumber:L0,findKey:Hf,global:Vn,isContextDefined:Wf,isSpecCompliantForm:D0,toJSONObject:B0,isAsyncFn:$0,isThenable:j0,setImmediate:Kf,asap:z0,isIterable:e=>e!=null&&pr(e[hi])};let qe=class xy extends Error{static from(t,r,n,o,s,i){const a=new xy(t.message,r||t.code,n,o,s);return a.cause=t,a.name=t.name,t.status!=null&&a.status==null&&(a.status=t.status),i&&Object.assign(a,i),a}constructor(t,r,n,o,s){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),s&&(this.response=s,this.status=s.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:W.toJSONObject(this.config),code:this.code,status:this.status}}};qe.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",qe.ERR_BAD_OPTION="ERR_BAD_OPTION",qe.ECONNABORTED="ECONNABORTED",qe.ETIMEDOUT="ETIMEDOUT",qe.ERR_NETWORK="ERR_NETWORK",qe.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",qe.ERR_DEPRECATED="ERR_DEPRECATED",qe.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",qe.ERR_BAD_REQUEST="ERR_BAD_REQUEST",qe.ERR_CANCELED="ERR_CANCELED",qe.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",qe.ERR_INVALID_URL="ERR_INVALID_URL";const U0=null;function yl(e){return W.isPlainObject(e)||W.isArray(e)}function qf(e){return W.endsWith(e,"[]")?e.slice(0,-2):e}function bl(e,t,r){return e?e.concat(t).map(function(o,s){return o=qf(o),!r&&s?"["+o+"]":o}).join(r?".":""):t}function V0(e){return W.isArray(e)&&!e.some(yl)}const H0=W.toFlatObject(W,{},null,function(t){return/^is[A-Z]/.test(t)});function vi(e,t,r){if(!W.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=W.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,y){return!W.isUndefined(y[h])});const n=r.metaTokens,o=r.visitor||l,s=r.dots,i=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&W.isSpecCompliantForm(t);if(!W.isFunction(o))throw new TypeError("visitor must be a function");function u(g){if(g===null)return"";if(W.isDate(g))return g.toISOString();if(W.isBoolean(g))return g.toString();if(!d&&W.isBlob(g))throw new qe("Blob is not supported. Use a Buffer instead.");return W.isArrayBuffer(g)||W.isTypedArray(g)?d&&typeof Blob=="function"?new Blob([g]):Buffer.from(g):g}function l(g,h,y){let v=g;if(W.isReactNative(t)&&W.isReactNativeBlob(g))return t.append(bl(y,h,s),u(g)),!1;if(g&&!y&&typeof g=="object"){if(W.endsWith(h,"{}"))h=n?h:h.slice(0,-2),g=JSON.stringify(g);else if(W.isArray(g)&&V0(g)||(W.isFileList(g)||W.endsWith(h,"[]"))&&(v=W.toArray(g)))return h=qf(h),v.forEach(function(x,E){!(W.isUndefined(x)||x===null)&&t.append(i===!0?bl([h],E,s):i===null?h:h+"[]",u(x))}),!1}return yl(g)?!0:(t.append(bl(y,h,s),u(g)),!1)}const f=[],p=Object.assign(H0,{defaultVisitor:l,convertValue:u,isVisitable:yl});function m(g,h){if(!W.isUndefined(g)){if(f.indexOf(g)!==-1)throw Error("Circular reference detected in "+h.join("."));f.push(g),W.forEach(g,function(v,w){(!(W.isUndefined(v)||v===null)&&o.call(t,v,W.isString(w)?w.trim():w,h,p))===!0&&m(v,h?h.concat(w):[w])}),f.pop()}}if(!W.isObject(e))throw new TypeError("data must be an object");return m(e),t}function Yf(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function vl(e,t){this._pairs=[],e&&vi(e,this,t)}const Xf=vl.prototype;Xf.append=function(t,r){this._pairs.push([t,r])},Xf.toString=function(t){const r=t?function(n){return t.call(this,n,Yf)}:Yf;return this._pairs.map(function(o){return r(o[0])+"="+r(o[1])},"").join("&")};function W0(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Jf(e,t,r){if(!t)return e;const n=r&&r.encode||W0,o=W.isFunction(r)?{serialize:r}:r,s=o&&o.serialize;let i;if(s?i=s(t,o):i=W.isURLSearchParams(t)?t.toString():new vl(t,o).toString(n),i){const a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class Qf{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){W.forEach(this.handlers,function(n){n!==null&&t(n)})}}const wl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},R0={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:vl,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Sl=typeof window<"u"&&typeof document<"u",xl=typeof navigator=="object"&&navigator||void 0,G0=Sl&&(!xl||["ReactNative","NativeScript","NS"].indexOf(xl.product)<0),K0=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",q0=Sl&&window.location.href||"http://localhost",nr={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Sl,hasStandardBrowserEnv:G0,hasStandardBrowserWebWorkerEnv:K0,navigator:xl,origin:q0},Symbol.toStringTag,{value:"Module"})),...R0};function Y0(e,t){return vi(e,new nr.classes.URLSearchParams,{visitor:function(r,n,o,s){return nr.isNode&&W.isBuffer(r)?(this.append(n,r.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function X0(e){return W.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function J0(e){const t={},r=Object.keys(e);let n;const o=r.length;let s;for(n=0;n<o;n++)s=r[n],t[s]=e[s];return t}function Zf(e){function t(r,n,o,s){let i=r[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),d=s>=r.length;return i=!i&&W.isArray(o)?o.length:i,d?(W.hasOwnProp(o,i)?o[i]=[o[i],n]:o[i]=n,!a):((!o[i]||!W.isObject(o[i]))&&(o[i]=[]),t(r,n,o[i],s)&&W.isArray(o[i])&&(o[i]=J0(o[i])),!a)}if(W.isFormData(e)&&W.isFunction(e.entries)){const r={};return W.forEachEntry(e,(n,o)=>{t(X0(n),o,r,0)}),r}return null}function Q0(e,t,r){if(W.isString(e))try{return(t||JSON.parse)(e),W.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}const ns={transitional:wl,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){const n=r.getContentType()||"",o=n.indexOf("application/json")>-1,s=W.isObject(t);if(s&&W.isHTMLForm(t)&&(t=new FormData(t)),W.isFormData(t))return o?JSON.stringify(Zf(t)):t;if(W.isArrayBuffer(t)||W.isBuffer(t)||W.isStream(t)||W.isFile(t)||W.isBlob(t)||W.isReadableStream(t))return t;if(W.isArrayBufferView(t))return t.buffer;if(W.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(s){if(n.indexOf("application/x-www-form-urlencoded")>-1)return Y0(t,this.formSerializer).toString();if((a=W.isFileList(t))||n.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return vi(a?{"files[]":t}:t,d&&new d,this.formSerializer)}}return s||o?(r.setContentType("application/json",!1),Q0(t)):t}],transformResponse:[function(t){const r=this.transitional||ns.transitional,n=r&&r.forcedJSONParsing,o=this.responseType==="json";if(W.isResponse(t)||W.isReadableStream(t))return t;if(t&&W.isString(t)&&(n&&!this.responseType||o)){const i=!(r&&r.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?qe.from(a,qe.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:nr.classes.FormData,Blob:nr.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};W.forEach(["delete","get","head","post","put","patch"],e=>{ns.headers[e]={}});const Z0=W.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"]),eA=e=>{const t={};let r,n,o;return e&&e.split(`
|
|
42
|
-
`).forEach(function(i){o=i.indexOf(":"),r=i.substring(0,o).trim().toLowerCase(),n=i.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[ep]=this[ep]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=os(i);n[a]||(oA(o,i),n[a]=!0)}return W.isArray(t)?t.forEach(s):s(t),this}};mr.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),W.reduceDescriptors(mr.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}}),W.freezeMethods(mr);function Cl(e,t){const r=this||ns,n=t||r,o=mr.from(n.headers);let s=n.data;return W.forEach(e,function(a){s=a.call(r,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function tp(e){return!!(e&&e.__CANCEL__)}let ss=class extends qe{constructor(t,r,n){super(t??"canceled",qe.ERR_CANCELED,r,n),this.name="CanceledError",this.__CANCEL__=!0}};function rp(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new qe("Request failed with status code "+r.status,[qe.ERR_BAD_REQUEST,qe.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function sA(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function iA(e,t){e=e||10;const r=new Array(e),n=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(d){const u=Date.now(),l=n[s];i||(i=u),r[o]=d,n[o]=u;let f=s,p=0;for(;f!==o;)p+=r[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),u-i<t)return;const m=l&&u-l;return m?Math.round(p*1e3/m):void 0}}function aA(e,t){let r=0,n=1e3/t,o,s;const i=(u,l=Date.now())=>{r=l,o=null,s&&(clearTimeout(s),s=null),e(...u)};return[(...u)=>{const l=Date.now(),f=l-r;f>=n?i(u,l):(o=u,s||(s=setTimeout(()=>{s=null,i(o)},n-f)))},()=>o&&i(o)]}const Si=(e,t,r=3)=>{let n=0;const o=iA(50,250);return aA(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,d=i-n,u=o(d),l=i<=a;n=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:d,rate:u||void 0,estimated:u&&a&&l?(a-i)/u:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},r)},np=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},op=e=>(...t)=>W.asap(()=>e(...t)),lA=nr.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,nr.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(nr.origin),nr.navigator&&/(msie|trident)/i.test(nr.navigator.userAgent)):()=>!0,cA=nr.hasStandardBrowserEnv?{write(e,t,r,n,o,s,i){if(typeof document>"u")return;const a=[`${e}=${encodeURIComponent(t)}`];W.isNumber(r)&&a.push(`expires=${new Date(r).toUTCString()}`),W.isString(n)&&a.push(`path=${n}`),W.isString(o)&&a.push(`domain=${o}`),s===!0&&a.push("secure"),W.isString(i)&&a.push(`SameSite=${i}`),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 dA(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function uA(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function sp(e,t,r){let n=!dA(t);return e&&(n||r==!1)?uA(e,t):t}const ip=e=>e instanceof mr?{...e}:e;function Hn(e,t){t=t||{};const r={};function n(u,l,f,p){return W.isPlainObject(u)&&W.isPlainObject(l)?W.merge.call({caseless:p},u,l):W.isPlainObject(l)?W.merge({},l):W.isArray(l)?l.slice():l}function o(u,l,f,p){if(W.isUndefined(l)){if(!W.isUndefined(u))return n(void 0,u,f,p)}else return n(u,l,f,p)}function s(u,l){if(!W.isUndefined(l))return n(void 0,l)}function i(u,l){if(W.isUndefined(l)){if(!W.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:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(u,l,f)=>o(ip(u),ip(l),f,!0)};return W.forEach(Object.keys({...e,...t}),function(l){if(l==="__proto__"||l==="constructor"||l==="prototype")return;const f=W.hasOwnProp(d,l)?d[l]:o,p=f(e[l],t[l],l);W.isUndefined(p)&&f!==a||(r[l]=p)}),r}const ap=e=>{const t=Hn({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=mr.from(i),t.url=Jf(sp(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),W.isFormData(r)){if(nr.hasStandardBrowserEnv||nr.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(W.isFunction(r.getHeaders)){const d=r.getHeaders(),u=["content-type","content-length"];Object.entries(d).forEach(([l,f])=>{u.includes(l.toLowerCase())&&i.set(l,f)})}}if(nr.hasStandardBrowserEnv&&(n&&W.isFunction(n)&&(n=n(t)),n||n!==!1&&lA(t.url))){const d=o&&s&&cA.read(s);d&&i.set(o,d)}return t},fA=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(r,n){const o=ap(e);let s=o.data;const i=mr.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 v(){if(!y)return;const x=mr.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};rp(function(N){r(N),h()},function(N){n(N),h()},P),y=null}"onloadend"in y?y.onloadend=v:y.onreadystatechange=function(){!y||y.readyState!==4||y.status===0&&!(y.responseURL&&y.responseURL.indexOf("file:")===0)||setTimeout(v)},y.onabort=function(){y&&(n(new qe("Request aborted",qe.ECONNABORTED,e,y)),y=null)},y.onerror=function(E){const P=E&&E.message?E.message:"Network Error",C=new qe(P,qe.ERR_NETWORK,e,y);C.event=E||null,n(C),y=null},y.ontimeout=function(){let E=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const P=o.transitional||wl;o.timeoutErrorMessage&&(E=o.timeoutErrorMessage),n(new qe(E,P.clarifyTimeoutError?qe.ETIMEDOUT:qe.ECONNABORTED,e,y)),y=null},s===void 0&&i.setContentType(null),"setRequestHeader"in y&&W.forEach(i.toJSON(),function(E,P){y.setRequestHeader(P,E)}),W.isUndefined(o.withCredentials)||(y.withCredentials=!!o.withCredentials),a&&a!=="json"&&(y.responseType=o.responseType),u&&([p,g]=Si(u,!0),y.addEventListener("progress",p)),d&&y.upload&&([f,m]=Si(d),y.upload.addEventListener("progress",f),y.upload.addEventListener("loadend",m)),(o.cancelToken||o.signal)&&(l=x=>{y&&(n(!x||x.type?new ss(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 w=sA(o.url);if(w&&nr.protocols.indexOf(w)===-1){n(new qe("Unsupported protocol "+w+":",qe.ERR_BAD_REQUEST,e));return}y.send(s||null)})},pA=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,o;const s=function(u){if(!o){o=!0,a();const l=u instanceof Error?u:this.reason;n.abort(l instanceof qe?l:new ss(l instanceof Error?l.message:l))}};let i=t&&setTimeout(()=>{i=null,s(new qe(`timeout of ${t}ms exceeded`,qe.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(s):u.removeEventListener("abort",s)}),e=null)};e.forEach(u=>u.addEventListener("abort",s));const{signal:d}=n;return d.unsubscribe=()=>W.asap(a),d}},mA=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},hA=async function*(e,t){for await(const r of gA(e))yield*mA(r,t)},gA=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()}},lp=(e,t,r,n)=>{const o=hA(e,t);let s=0,i,a=d=>{i||(i=!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=s+=f;r(p)}d.enqueue(new Uint8Array(l))}catch(u){throw a(u),u}},cancel(d){return a(d),o.return()}},{highWaterMark:2})},cp=64*1024,{isFunction:xi}=W,yA=(({Request:e,Response:t})=>({Request:e,Response:t}))(W.global),{ReadableStream:dp,TextEncoder:up}=W.global,fp=(e,...t)=>{try{return!!e(...t)}catch{return!1}},bA=e=>{e=W.merge.call({skipUndefined:!0},yA,e);const{fetch:t,Request:r,Response:n}=e,o=t?xi(t):typeof fetch=="function",s=xi(r),i=xi(n);if(!o)return!1;const a=o&&xi(dp),d=o&&(typeof up=="function"?(g=>h=>g.encode(h))(new up):async g=>new Uint8Array(await new r(g).arrayBuffer())),u=s&&a&&fp(()=>{let g=!1;const h=new dp,y=new r(nr.origin,{body:h,method:"POST",get duplex(){return g=!0,"half"}}).headers.has("Content-Type");return h.cancel(),g&&!y}),l=i&&a&&fp(()=>W.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 v=h&&h[g];if(v)return v.call(h);throw new qe(`Response type '${g}' is not supported`,qe.ERR_NOT_SUPPORT,y)})});const p=async g=>{if(g==null)return 0;if(W.isBlob(g))return g.size;if(W.isSpecCompliantForm(g))return(await new r(nr.origin,{method:"POST",body:g}).arrayBuffer()).byteLength;if(W.isArrayBufferView(g)||W.isArrayBuffer(g))return g.byteLength;if(W.isURLSearchParams(g)&&(g=g+""),W.isString(g))return(await d(g)).byteLength},m=async(g,h)=>{const y=W.toFiniteNumber(g.getContentLength());return y??p(h)};return async g=>{let{url:h,method:y,data:v,signal:w,cancelToken:x,timeout:E,onDownloadProgress:P,onUploadProgress:C,responseType:N,headers:_,withCredentials:A="same-origin",fetchOptions:I}=ap(g),T=t||fetch;N=N?(N+"").toLowerCase():"text";let U=pA([w,x&&x.toAbortSignal()],E),Q=null;const O=U&&U.unsubscribe&&(()=>{U.unsubscribe()});let j;try{if(C&&u&&y!=="get"&&y!=="head"&&(j=await m(_,v))!==0){let ie=new r(h,{method:"POST",body:v,duplex:"half"}),V;if(W.isFormData(v)&&(V=ie.headers.get("content-type"))&&_.setContentType(V),ie.body){const[K,X]=np(j,Si(op(C)));v=lp(ie.body,cp,K,X)}}W.isString(A)||(A=A?"include":"omit");const L=s&&"credentials"in r.prototype,D={...I,signal:U,method:y.toUpperCase(),headers:_.normalize().toJSON(),body:v,duplex:"half",credentials:L?A:void 0};Q=s&&new r(h,D);let M=await(s?T(Q,I):T(h,D));const R=l&&(N==="stream"||N==="response");if(l&&(P||R&&O)){const ie={};["status","statusText","headers"].forEach(ce=>{ie[ce]=M[ce]});const V=W.toFiniteNumber(M.headers.get("content-length")),[K,X]=P&&np(V,Si(op(P),!0))||[];M=new n(lp(M.body,cp,K,()=>{X&&X(),O&&O()}),ie)}N=N||"text";let $=await f[W.findKey(f,N)||"text"](M,g);return!R&&O&&O(),await new Promise((ie,V)=>{rp(ie,V,{data:$,headers:mr.from(M.headers),status:M.status,statusText:M.statusText,config:g,request:Q})})}catch(L){throw O&&O(),L&&L.name==="TypeError"&&/Load failed|fetch/i.test(L.message)?Object.assign(new qe("Network Error",qe.ERR_NETWORK,g,Q,L&&L.response),{cause:L.cause||L}):qe.from(L,L&&L.code,g,Q,L&&L.response)}}},vA=new Map,pp=e=>{let t=e&&e.env||{};const{fetch:r,Request:n,Response:o}=t,s=[n,o,r];let i=s.length,a=i,d,u,l=vA;for(;a--;)d=s[a],u=l.get(d),u===void 0&&l.set(d,u=a?new Map:bA(t)),l=u;return u};pp();const El={http:U0,xhr:fA,fetch:{get:pp}};W.forEach(El,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const mp=e=>`- ${e}`,wA=e=>W.isFunction(e)||e===null||e===!1;function SA(e,t){e=W.isArray(e)?e:[e];const{length:r}=e;let n,o;const s={};for(let i=0;i<r;i++){n=e[i];let a;if(o=n,!wA(n)&&(o=El[(a=String(n)).toLowerCase()],o===void 0))throw new qe(`Unknown adapter '${a}'`);if(o&&(W.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([d,u])=>`adapter ${d} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=r?i.length>1?`since :
|
|
44
|
-
`+i.map(
|
|
45
|
-
`):" "+
|
|
46
|
-
`+s):n.stack=s}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=Hn(this.defaults,r);const{transitional:n,paramsSerializer:o,headers:s}=r;n!==void 0&&Ci.assertOptions(n,{silentJSONParsing:Or.transitional(Or.boolean),forcedJSONParsing:Or.transitional(Or.boolean),clarifyTimeoutError:Or.transitional(Or.boolean),legacyInterceptorReqResOrdering:Or.transitional(Or.boolean)},!1),o!=null&&(W.isFunction(o)?r.paramsSerializer={serialize:o}:Ci.assertOptions(o,{encode:Or.function,serialize:Or.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),Ci.assertOptions(r,{baseUrl:Or.spelling("baseURL"),withXsrfToken:Or.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let i=s&&W.merge(s.common,s[r.method]);s&&W.forEach(["delete","get","head","post","put","patch","common"],g=>{delete s[g]}),r.headers=mr.concat(i,s);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||wl;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=[gp.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=gp.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=Hn(this.defaults,t);const r=sp(t.baseURL,t.url,t.allowAbsoluteUrls);return Jf(r,t.params,t.paramsSerializer)}};W.forEach(["delete","get","head","options"],function(t){Wn.prototype[t]=function(r,n){return this.request(Hn(n||{},{method:t,url:r,data:(n||{}).data}))}}),W.forEach(["post","put","patch"],function(t){function r(n){return function(s,i,a){return this.request(Hn(a||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Wn.prototype[t]=r(),Wn.prototype[t+"Form"]=r(!0)});let AA=class Ay{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(s){r=s});const n=this;this.promise.then(o=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](o);n._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(a=>{n.subscribe(a),s=a}).then(o);return i.cancel=function(){n.unsubscribe(s)},i},t(function(s,i,a){n.reason||(n.reason=new ss(s,i,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 Ay(function(o){t=o}),cancel:t}}};function CA(e){return function(r){return e.apply(null,r)}}function EA(e){return W.isObject(e)&&e.isAxiosError===!0}const _l={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(_l).forEach(([e,t])=>{_l[t]=e});function vp(e){const t=new Wn(e),r=Bf(Wn.prototype.request,t);return W.extend(r,Wn.prototype,t,{allOwnKeys:!0}),W.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return vp(Hn(e,o))},r}const _t=vp(ns);_t.Axios=Wn,_t.CanceledError=ss,_t.CancelToken=AA,_t.isCancel=tp,_t.VERSION=yp,_t.toFormData=vi,_t.AxiosError=qe,_t.Cancel=_t.CanceledError,_t.all=function(t){return Promise.all(t)},_t.spread=CA,_t.isAxiosError=EA,_t.mergeConfig=Hn,_t.AxiosHeaders=mr,_t.formToJSON=e=>Zf(W.isHTMLForm(e)?new FormData(e):e),_t.getAdapter=hp.getAdapter,_t.HttpStatusCode=_l,_t.default=_t;const{Axios:_P,AxiosError:NA,CanceledError:kP,isCancel:TP,CancelToken:FP,VERSION:PP,all:OP,Cancel:IP,isAxiosError:MP,spread:LP,toFormData:DP,AxiosHeaders:BP,HttpStatusCode:$P,formToJSON:jP,getAdapter:zP,mergeConfig:UP}=_t;function or(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 _A(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:s}=n,i=s?`data.${s}.`:"";return{array:o,pathPrefixToStrip:i}}function kA(e){return e.length>=4&&Array.isArray(e[3])&&e[3].length===0}function TA(e,t,r){if(typeof e=="string"||typeof e=="number"||typeof e=="boolean"){const s=String(e);return{label:s,value:s,disabled:!1}}if(e==null)return{label:"",value:"",disabled:!0};if(typeof e!="object"||Array.isArray(e)){const s=Array.isArray(e)?"":String(e);return{label:s,value:s,disabled:!1}}let n,o;if(t){const s=t.includes(".")?or(e,t):e[t];n=String(s!==void 0?s: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 s=r.includes(".")?or(e,r):e[r];o=String(s!==void 0?s: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 kl(e,t,r){if(!e)return[];if(Array.isArray(e)){if(e.length===0)return[];if(kA(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=>TA(o,t,r))}if(typeof e=="object"){const{array:n,pathPrefixToStrip:o}=_A(e);if(Array.isArray(n)&&n.length>0){const s=d=>!d||!d.trim()||!o?d:d.startsWith(o)?d.substring(o.length).replace(/^\.+/,"")||void 0:d,i=s(t),a=s(r);return kl(n,i,a)}}return[]}function FA(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 PA(e){return Array.isArray(e)&&e.length>=4&&Array.isArray(e[3])&&e[3].length>0&&Array.isArray(e[3][0])}function OA(e,t,r){if(!e)return[];try{const o=new URL(e).searchParams.get(t);return o?o.split(r).map(s=>s.trim()).filter(Boolean):[]}catch{const n=e.indexOf("?");if(n<0)return[];const o=e.slice(n+1);try{const i=new URLSearchParams(o).get(t);return i?i.split(r).map(a=>a.trim()).filter(Boolean):[]}catch{return[]}}}function wp(e){const{response:t,sourceUrl:r,rowsIndex:n,rowsPath:o,columns:s,columnsQueryParam:i="sf",columnsQueryParamSeparator:a=","}=e;let d;if(o&&o.trim()?d=or(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=OA(r,i,a),f=l.length>0?l:Array.isArray(s)&&s.length>0?s:[];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 IA(e){const{rows:t,apiLabelField:r,apiLabelFields:n,apiLabelSeparator:o,apiValueField:s}=e;if(!Array.isArray(t)||t.length===0)return[];const i=t.filter(f=>f!=null&&typeof f=="object"&&!Array.isArray(f));if(i.length===0)return[];const a=Array.isArray(n)?n.filter(Boolean):[],d=o??" - ",u=f=>{if(r){const p=r.includes(".")?or(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(s){const m=s.includes(".")?or(f,s):f?.[s];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 i.map(f=>{let p="";a.length>0&&(p=a.map(h=>or(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}})}let Sp=null;function MA(e){Sp=e}function xp(){return(Sp?.()??"").replace(/\/+$/,"")}function cn(e){const t=typeof e=="string"?e.trim():"";if(!t||/^https?:\/\//i.test(t))return t;const r=xp();return r?t.startsWith("/")?`${r}${t}`:`${r}/${t}`:t}function Ap({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,valueSource:n.valueSource,optionsSource:n.optionsSource}:null,s=e.apidata||null,i=o||s,[a,d]=S.useState([]),[u,l]=S.useState([]),[f,p]=S.useState([]),[m,g]=S.useState(!1),[h,y]=S.useState(null),v=!!(i?.apiEndpoint&&(i?.valueSource==="api"||i?.optionsSource==="api"||n?.valueSource==="api"||n?.optionsSource==="api")),w=e.options||n?.options||[],x=S.useMemo(()=>FA(Array.isArray(w)?w:[]),[w]),E=S.useMemo(()=>{const I=i?.apiEndpoint||n?.apiEndpoint||"",T=i?.apiQueryParams||n?.apiQueryParams;return Bs(I,T)},[i?.apiEndpoint,n?.apiEndpoint,i?.apiQueryParams,n?.apiQueryParams]),P=S.useMemo(()=>{const I=new Set;for(const U of n?.dependentFields??[])typeof U=="string"&&U.trim()&&I.add(U.trim());const T=i?.apiClientFilter?.matchField?.trim()||n?.apiClientFilter?.matchField?.trim();return T&&I.add(T),[...I]},[n?.dependentFields,i?.apiClientFilter?.matchField,n?.apiClientFilter?.matchField]),C=S.useMemo(()=>{const I=new Set([...E,...P]);if(I.size===0)return null;const T={};return I.forEach(U=>{T[U]=t[U]}),JSON.stringify(T)},[E,P,t]),N=S.useMemo(()=>JSON.stringify(r||{}),[r]),_=S.useMemo(()=>{const I=new Set;e.name?.trim()&&I.add(e.name.trim());const T=e.key;return typeof T=="string"&&T.trim()&&I.add(T.trim()),[...I]},[e.name,e.key]);return S.useEffect(()=>{const I=i?.apiEndpoint;if(!v||!I){d([]);return}let T=!1;return(async()=>{a.length===0&&g(!0),y(null);try{const O=i?.apiMethod||n?.apiMethod||"GET",j=i?.apiRealtime||n?.apiRealtime,L=i?.apiQueryParams||n?.apiQueryParams||{},D=Dd({apiEndpoint:I,apiMethod:O,apiQueryParams:L,formValues:t,submissionContext:r,apiRealtime:j,additionalRequiredFieldNames:P,excludeFormFieldNames:_});if(D.blocked){T||(d([]),g(!1));return}const M={"Content-Type":"application/json"},R=i?.apiKey||n?.apiKey;R&&(M["X-CSCAPI-KEY"]=R);const $={method:O.toLowerCase(),url:cn(D.url),headers:M};D.postBodyBase!=null&&($.data=D.postBodyBase);const ie=await _t($),V=i?.apiLabelField||n?.apiLabelField,K=i?.apiValueField||n?.apiValueField,X=ie.data;let ce=[];Array.isArray(X)?ce=X:X?.data&&(Array.isArray(X.data)?ce=X.data:X.data?.data&&Array.isArray(X.data.data)?ce=X.data.data:X.data.districts?ce=X.data.districts:X.data.states?ce=X.data.states:X.data.cities&&(ce=X.data.cities)),p(ce);const ne=kl(ie.data,V,K);l(ne);const G=i?.apiClientFilter||n?.apiClientFilter;let ee=ne;if(G?.filterField&&G?.matchField){const Pe=t[G.matchField];Pe!=null?ee=ne.filter(oe=>{const re=ce.find(de=>String(or(de,K||"code"))===String(oe.value));if(!re)return!1;const be=or(re,G.filterField);return String(be)===String(Pe)}):ee=[]}T||d(ee)}catch(O){if(T)return;let j="Failed to load options";if(O.response){const L=O.response.data;O.response.status===404?j="API endpoint not found.":O.response.status===401?j="Authentication failed.":typeof L=="string"?j=L:L&&typeof L=="object"&&(j=L.error||L.message||L.detail||j)}else O.message&&(j=String(O.message));y(j),a.length===0&&d([])}finally{T||g(!1)}})(),()=>{T=!0}},[v,i?.apiEndpoint,i?.apiMethod,n?.apiEndpoint,n?.apiMethod,C,P,_,N]),S.useEffect(()=>{const I=i?.apiClientFilter||n?.apiClientFilter;if(!v||!I||f.length===0)return;const T=t[I.matchField],U=i?.apiValueField||n?.apiValueField;if(T==null){d([]);return}const Q=u.filter(O=>{const j=f.find(D=>String(or(D,U||"code"))===String(O.value));if(!j)return!1;const L=or(j,I.filterField);return String(L)===String(T)});d(Q)},[v,i?.apiClientFilter?.matchField,n?.apiClientFilter?.matchField,i?.apiClientFilter?.filterField,n?.apiClientFilter?.filterField,i?.apiValueField,n?.apiValueField,t[i?.apiClientFilter?.matchField||n?.apiClientFilter?.matchField||""],u,f]),{options:v?a:x,isLoadingOptions:m,optionsError:h}}const Cp=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,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:v,isLoadingOptions:w,optionsError:x}=Ap({field:e,formValues:d,submissionContext:u}),E=l?.length?new Set(l.map(String)):null,P=E?v.filter($=>!E.has(String($.value??$.label??""))):v,C="__clear__",N=t!=null&&String(t).trim()!=="",_=N?P.some($=>String($.value??$.label??"")===String(t)):!1,A=S.useMemo(()=>{if(!N||_)return P;const $=String(t);return[{label:$,value:$},...P]},[P,N,_,t]),I=N?String(t):void 0,T=`${ht(e)}-${I??"empty"}`,U=S.useCallback($=>{r($===C?"":$),n?.()},[r,n]),Q=e.appearance?.size||"md",O={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},j=e.placeholder||"Select an option",L=p?.apiClientFilter?.matchField?.trim()||h?.apiClientFilter?.matchField?.trim(),D=y&&L&&(d[L]===void 0||d[L]===null||d[L]===""),M=w?"Loading options...":D?`Select ${L} first`:l?.length?"No available options":y?"No options available from API":"No options available";return y&&f&&w?c.jsx(Et,{field:e,error:o||x||void 0,isRequired:i,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",O[Q],e.appearance?.className),children:[c.jsx(Ro,{className:"h-4 w-4 animate-spin shrink-0"}),c.jsx("span",{className:"truncate",children:"Loading..."})]})}):c.jsx(Et,{field:e,error:o||x||void 0,isRequired:i,className:a,children:c.jsxs(qx,{value:I,onValueChange:U,disabled:s||e.disabled||w&&P.length===0,children:[c.jsx(Xx,{id:ht(e),"aria-describedby":jt(e,!!o||!!x),"aria-invalid":Jt(!!o||!!x),"aria-required":i,className:B("w-full min-w-0",O[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:[w&&c.jsx(Ro,{className:"h-4 w-4 animate-spin text-muted-foreground shrink-0"}),P.length===0&&l?.length&&!N?c.jsx("span",{className:"text-muted-foreground truncate",children:"No available options"}):N?c.jsx(Yx,{placeholder:j}):c.jsx("span",{className:"text-muted-foreground truncate",children:j})]})}),c.jsx(Jx,{children:A.length===0?c.jsx(ml,{value:"__no_options__",disabled:!0,children:M}):c.jsxs(c.Fragment,{children:[N?c.jsx(ml,{value:C,children:j}):null,A.map(($,ie)=>{const V=String($.value??$.label??ie);if(V===C)return null;const K=$.label||$.value||String($);return c.jsx(ml,{value:V,disabled:$.disabled||!1,children:K},V)})]})})]},T)})},Ep=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Np=Kc,_p=(e,t)=>r=>{var n;if(t?.variants==null)return Np(e,r?.class,r?.className);const{variants:o,defaultVariants:s}=t,i=Object.keys(o).map(u=>{const l=r?.[u],f=s?.[u];if(l===null)return null;const p=Ep(l)||Ep(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({...s,...a}[h]):{...s,...a}[h]===y})?[...u,f,p]:u},[]);return Np(e,i,d,r?.class,r?.className)},LA=_p("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 Yt({className:e,variant:t,size:r,asChild:n=!1,...o}){const s=n?Wd:"button";return c.jsx(s,{"data-slot":"button",className:B(LA({variant:t,size:r,className:e})),...o})}function DA(e,t){return b.useReducer((r,n)=>t[r][n]??r,e)}var xr=e=>{const{present:t,children:r}=e,n=BA(t),o=typeof r=="function"?r({present:n.isPresent}):b.Children.only(r),s=Qe(n.ref,$A(o));return typeof r=="function"||n.isPresent?b.cloneElement(o,{ref:s}):null};xr.displayName="Presence";function BA(e){const[t,r]=b.useState(),n=b.useRef(null),o=b.useRef(e),s=b.useRef("none"),i=e?"mounted":"unmounted",[a,d]=DA(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{const u=Ei(n.current);s.current=a==="mounted"?u:"none"},[a]),Qt(()=>{const u=n.current,l=o.current;if(l!==e){const p=s.current,m=Ei(u);e?d("MOUNT"):m==="none"||u?.display==="none"?d("UNMOUNT"):d(l&&p!==m?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,d]),Qt(()=>{if(t){let u;const l=t.ownerDocument.defaultView??window,f=m=>{const h=Ei(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&&(s.current=Ei(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 Ei(e){return e?.animationName||"none"}function $A(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 jA(e){const t=zA(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),d=a.find(VA);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,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function zA(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=WA(o),a=HA(s,o.props);return o.type!==b.Fragment&&(a.ref=n?Bn(n,i):i),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var UA=Symbol("radix.slottable");function VA(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===UA}function HA(e,t){const r={...t};for(const n in t){const o=e[n],s=t[n];/^on[A-Z]/.test(n)?o&&s?r[n]=(...a)=>{const d=s(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function WA(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 Ni="Popover",[kp]=vr(Ni,[ti]),is=ti(),[RA,kn]=kp(Ni),Tp=e=>{const{__scopePopover:t,children:r,open:n,defaultOpen:o,onOpenChange:s,modal:i=!1}=e,a=is(t),d=b.useRef(null),[u,l]=b.useState(!1),[f,p]=Zr({prop:n,defaultProp:o??!1,onChange:s,caller:Ni});return c.jsx(Ku,{...a,children:c.jsx(RA,{scope:t,contentId:on(),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:i,children:r})})};Tp.displayName=Ni;var Fp="PopoverAnchor",Pp=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=kn(Fp,r),s=is(r),{onCustomAnchorAdd:i,onCustomAnchorRemove:a}=o;return b.useEffect(()=>(i(),()=>a()),[i,a]),c.jsx(tl,{...s,...n,ref:t})});Pp.displayName=Fp;var Op="PopoverTrigger",Ip=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=kn(Op,r),s=is(r),i=Qe(t,o.triggerRef),a=c.jsx(Be.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":$p(o.open),...n,ref:i,onClick:Me(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:c.jsx(tl,{asChild:!0,...s,children:a})});Ip.displayName=Op;var Tl="PopoverPortal",[GA,KA]=kp(Tl,{forceMount:void 0}),Mp=e=>{const{__scopePopover:t,forceMount:r,children:n,container:o}=e,s=kn(Tl,t);return c.jsx(GA,{scope:t,forceMount:r,children:c.jsx(xr,{present:r||s.open,children:c.jsx(ri,{asChild:!0,container:o,children:n})})})};Mp.displayName=Tl;var ho="PopoverContent",Lp=b.forwardRef((e,t)=>{const r=KA(ho,e.__scopePopover),{forceMount:n=r.forceMount,...o}=e,s=kn(ho,e.__scopePopover);return c.jsx(xr,{present:n||s.open,children:s.modal?c.jsx(YA,{...o,ref:t}):c.jsx(XA,{...o,ref:t})})});Lp.displayName=ho;var qA=jA("PopoverContent.RemoveScroll"),YA=b.forwardRef((e,t)=>{const r=kn(ho,e.__scopePopover),n=b.useRef(null),o=Qe(t,n),s=b.useRef(!1);return b.useEffect(()=>{const i=n.current;if(i)return nl(i)},[]),c.jsx(di,{as:qA,allowPinchZoom:!0,children:c.jsx(Dp,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Me(e.onCloseAutoFocus,i=>{i.preventDefault(),s.current||r.triggerRef.current?.focus()}),onPointerDownOutside:Me(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,d=a.button===0&&a.ctrlKey===!0,u=a.button===2||d;s.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:Me(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),XA=b.forwardRef((e,t)=>{const r=kn(ho,e.__scopePopover),n=b.useRef(!1),o=b.useRef(!1);return c.jsx(Dp,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{e.onCloseAutoFocus?.(s),s.defaultPrevented||(n.current||r.triggerRef.current?.focus(),s.preventDefault()),n.current=!1,o.current=!1},onInteractOutside:s=>{e.onInteractOutside?.(s),s.defaultPrevented||(n.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;r.triggerRef.current?.contains(i)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Dp=b.forwardRef((e,t)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:i,onEscapeKeyDown:a,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:l,...f}=e,p=kn(ho,r),m=is(r);return $a(),c.jsx(Ws,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:s,children:c.jsx(Hs,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:l,onEscapeKeyDown:a,onPointerDownOutside:d,onFocusOutside:u,onDismiss:()=>p.onOpenChange(!1),children:c.jsx(qu,{"data-state":$p(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)"}})})})}),Bp="PopoverClose",JA=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=kn(Bp,r);return c.jsx(Be.button,{type:"button",...n,ref:t,onClick:Me(e.onClick,()=>o.onOpenChange(!1))})});JA.displayName=Bp;var QA="PopoverArrow",ZA=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=is(r);return c.jsx(Yu,{...o,...n,ref:t})});ZA.displayName=QA;function $p(e){return e?"open":"closed"}var eC=Tp,tC=Pp,rC=Ip,nC=Mp,oC=Lp;function Fl({...e}){return c.jsx(eC,{"data-slot":"popover",...e})}function jp({...e}){return c.jsx(rC,{"data-slot":"popover-trigger",...e})}function Pl({className:e,align:t="center",sideOffset:r=4,...n}){return c.jsx(nC,{children:c.jsx(oC,{"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 sC({...e}){return c.jsx(tC,{"data-slot":"popover-anchor",...e})}const zp={};function Tn(){const e=zp?.VITE_CLIENT_ID?.trim()||zp?.VITE_DEFAULT_CLIENT_ID?.trim()||null;return(typeof localStorage<"u"?localStorage.getItem("clientId"):null)||(typeof sessionStorage<"u"?sessionStorage.getItem("clientId"):null)||(typeof window<"u"?new URLSearchParams(window.location.search).get("clientId"):null)||e}function iC(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 aC(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 Rn=_d(e=>({viewerContext:void 0,authHeaders:void 0,_setViewerContext:t=>e({viewerContext:iC(t)?t:void 0}),_setAuthHeaders:t=>e({authHeaders:aC(t)}),_reset:()=>e({viewerContext:void 0,authHeaders:void 0})}));function lC(e){Rn.getState()._setViewerContext(e)}function cC(e){Rn.getState()._setAuthHeaders(e)}function dC(){Rn.getState()._reset()}function uC(){return Rn.getState().viewerContext}function Ol(){return Rn.getState().authHeaders}const Up={};let Vp=null;function fC(e){Vp=e}function pC(){return(Up?.VITE_API_BASE_URL?.trim()||Up?.VITE_API_URL?.trim()||"").replace(/\/$/,"")}const dn=_t.create({baseURL:pC()});dn.interceptors.request.use(e=>{const t=Tn();t&&(e.params={...e.params,clientId:t}),typeof FormData<"u"&&e.data instanceof FormData&&delete e.headers["Content-Type"];let r=Vp?.();if((!r||Object.keys(r).length===0)&&(r=Ol()),r){const n=e.headers??{};for(const[o,s]of Object.entries(r))s!==void 0&&s!==""&&(n[o]=s);e.headers=n}return e});function Hp(e){return JSON.stringify(e).slice(1,-1)}function Wp(e){const t=e.asyncSearchValueObjectKeys;return Array.isArray(t)?t.map(r=>typeof r=="string"?r.trim():"").filter(Boolean):[]}function mC(e){return e.asyncSearchValueMode==="object"&&Wp(e).length>0}function hC(e,t){const r={};for(const n of t){const o=n.trim();if(!o)continue;const s=or(e,o);s==null||typeof s=="object"?r[o]="":r[o]=String(s)}return r}function gC(e,t){const r=t.mode??"debounce",n=Math.max(0,t.intervalMs??300),[o,s]=S.useState(()=>r==="throttle"?e:""),i=S.useRef(0),a=S.useRef(void 0);return S.useEffect(()=>{if(e===""){a.current&&clearTimeout(a.current),s("");return}if(r==="debounce"){const l=setTimeout(()=>s(e),n);return()=>clearTimeout(l)}const d=Date.now(),u=d-i.current;return u>=n?(i.current=d,s(e),()=>{a.current&&clearTimeout(a.current)}):(a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{i.current=Date.now(),s(e),a.current=void 0},n-u),()=>{a.current&&clearTimeout(a.current)})},[e,r,n]),o}function Il(e,t){if(e==null||e==="")return"";if(t&&typeof e=="object"&&!Array.isArray(e)){const r=e,o=Object.keys(r).sort().map(s=>[s,r[s]??""]);return`O:${JSON.stringify(o)}`}return typeof e=="string"?`S:${e}`:""}function Ml(e,t){return e==null||e===""?!0:t&&typeof e=="object"&&!Array.isArray(e)?Object.keys(e).length===0:!1}function yC(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 bC(e){if(_t.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 vC(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 Rp(e,t){return typeof t=="number"&&t>0?e.slice(0,t):e}function Ll(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.label=="string"&&t.value!==null&&t.value!==void 0}const Gp=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d,formValues:u={},submissionContext:l})=>{const f=e.properties||{},p=mC(f),m=f.apiEndpoint?.trim()||"",g=f.apiRealtime===!0,h=(f.apiMethod||"GET").toUpperCase()==="POST"?"POST":"GET",y=f.searchInBody===!0,v=h==="POST"||h==="GET"&&y,w=f.searchStrategy??f.searchSchedule??"debounce",x=f.searchIntervalMs??f.intervalMs??300,E=f.minQueryLength??0,P=f.maxResults,C=f.searchQueryParam||"q",N=f.clearable!==!1,_=u,[A,I]=S.useState(()=>Ml(t,p)?"":p&&typeof t=="object"&&t!==null&&!Array.isArray(t)?f.initialDisplayLabel||"":f.initialDisplayLabel||String(t)),[T,U]=S.useState(!1),[Q,O]=S.useState([]),[j,L]=S.useState([]),[D,M]=S.useState([]),[R,$]=S.useState(!1),[ie,V]=S.useState(null),[K,X]=S.useState(-1),ce=S.useRef(Il(t,p)),ne=S.useRef(Ml(t,p)?"":p&&typeof t=="object"&&t!==null&&!Array.isArray(t)?f.initialDisplayLabel||"":f.initialDisplayLabel||String(t??"")),G=S.useRef(void 0),ee=S.useRef(0),Pe=S.useRef(null),oe=gC(A,{mode:w,intervalMs:x}),re=S.useMemo(()=>Q.filter(Ll),[Q]);S.useEffect(()=>{if(re.length===0){K!==-1&&X(-1);return}(K<0||K>=re.length)&&X(0)},[K,re.length]);const be=S.useMemo(()=>{const te=Bs(m,f.apiQueryParams),pe=new Set(te);for(const We of f.dependentFields||[])We&&pe.add(We);return pe},[m,f.apiQueryParams,f.dependentFields]),de=S.useMemo(()=>{if(be.size===0)return null;const te={};return be.forEach(pe=>{te[pe]=_[pe]}),JSON.stringify(te)},[be,_]),ot=S.useMemo(()=>JSON.stringify(u),[u]),Se=S.useMemo(()=>JSON.stringify(l||{}),[l]);S.useEffect(()=>{const te=Il(t,p);if(te===ce.current)return;if(ce.current=te,Ml(t,p)){ne.current="",I(""),O([]),L([]),M([]),V(null),U(!1);return}const pe=f.initialDisplayLabel||(!p&&typeof t=="string"?t:"");ne.current=pe,I(pe)},[t,f.initialDisplayLabel,p]),S.useEffect(()=>{if(!m){O([]),L([]),M([]),$(!1);return}if(i||s||e.disabled){O([]),L([]),M([]),$(!1);return}const te=oe;if(te.length<E){O([]),L([]),M([]),$(!1),V(null);return}const pe=Dd({apiEndpoint:m,apiMethod:h,apiQueryParams:f.apiQueryParams,formValues:_,submissionContext:l,apiRealtime:g,additionalRequiredFieldNames:f.dependentFields});if(pe.blocked){O([]),L([]),M([]),$(!1),V(null);return}Pe.current?.abort();const We=new AbortController;Pe.current=We;const Pt=++ee.current;return(async()=>{$(!0),V(null);const Te=cn(pe.url),Xe={};v&&(Xe["Content-Type"]="application/json"),f.apiKey&&(Xe["X-CSCAPI-KEY"]=f.apiKey);try{let Ue;if(!v)Ue=(await dn.get(Te,{params:{[C]:te},signal:We.signal,headers:Object.keys(Xe).length?Xe:void 0})).data;else{let It={};pe.postBodyBase&&Object.keys(pe.postBodyBase).length>0?It={...pe.postBodyBase}:g&&Object.keys(_).length>0&&(It={..._});let Er=It;if(f.searchBodyTemplate?.trim()){let sr=f.searchBodyTemplate.replace(/\{\{query\}\}/g,()=>Hp(te)).replace(/\{query\}/g,()=>Hp(te));sr=Bb(sr,_,l,g);const fn=JSON.parse(sr);Er={...It,...fn}}else Er={...It,[C]:te};Ue=(await dn.post(Te,Er,{signal:We.signal,headers:Object.keys(Xe).length?Xe:void 0})).data}if(Pt!==ee.current)return;const ft=f.apiResultsFormat,St=f.apiResultsConfig,xt=ft==="clinicaltables_v3",ze=PA(Ue),pt=xt||ft===void 0&&ze,At=ft==="tuple_array";let Ut=null;pt?Ut=wp({response:Ue,sourceUrl:Te,rowsIndex:St?.rowsIndex??3,rowsPath:St?.rowsPath,columns:St?.columns,columnsQueryParam:St?.columnsQueryParam??"sf",columnsQueryParamSeparator:St?.columnsQueryParamSeparator??","}):At&&(Ut=wp({response:Ue,sourceUrl:Te,rowsIndex:St?.rowsIndex,rowsPath:St?.rowsPath,columns:St?.columns,columnsQueryParam:St?.columnsQueryParam,columnsQueryParamSeparator:St?.columnsQueryParamSeparator}));const ur=vC(Ue),Ar=Ut!==null,Vt=Ut&&Array.isArray(Ut)?Ut:Array.isArray(ur)&&ur.every(It=>It&&typeof It=="object"&&!Array.isArray(It))?ur:null;M(Vt??ur);const Po=Array.isArray(f.apiLabelFields)&&f.apiLabelFields.length>0,Xn=Vt&&(Ar||Po)?IA({rows:Vt,apiLabelField:f.apiLabelField,apiLabelFields:f.apiLabelFields,apiLabelSeparator:f.apiLabelSeparator,apiValueField:f.apiValueField}):kl(Ue,f.apiLabelField,f.apiValueField);L(Xn);const Ct=f.apiClientFilter;let Cr=Xn;if(Ct?.filterField&&Ct?.matchField){const It=_[Ct.matchField];if(It!=null){const Er=f.apiValueField;Cr=Xn.filter(er=>{const fn=(Vt??ur).find(kt=>String(or(kt,Er||"code"))===String(er.value));if(!fn)return!1;const yr=or(fn,Ct.filterField);return String(yr)===String(It)})}else Cr=[]}const Jn=Rp(Cr,P).filter(Ll);O(Jn),X(Jn.length>0?0:-1)}catch(Ue){if(_t.isCancel(Ue)||Ue?.code==="ERR_CANCELED"||Pt!==ee.current)return;O([]),L([]),M([]),V(bC(Ue)),X(-1)}finally{Pt===ee.current&&$(!1)}})(),()=>{We.abort()}},[oe,m,h,y,v,C,E,P,f.apiKey,f.searchBodyTemplate,f.apiLabelField,f.apiLabelFields,f.apiLabelSeparator,f.apiValueField,f.apiQueryParams,f.apiClientFilter,f.apiResultsFormat,f.apiResultsConfig,f.dependentFields,g,_,l,i,s,e.disabled,de,ot,Se]),S.useEffect(()=>{const te=f.apiClientFilter;if(!te||D.length===0||j.length===0)return;const pe=_[te.matchField],We=f.apiValueField;if(pe==null){O([]);return}const Pt=j.filter(Te=>{const Xe=D.find(ft=>String(or(ft,We||"code"))===String(Te.value));if(!Xe)return!1;const Ue=or(Xe,te.filterField);return String(Ue)===String(pe)}),je=Rp(Pt,P).filter(Ll);O(je),X(je.length>0?0:-1)},[f.apiClientFilter,f.apiValueField,_,P,j,D]);const xe=s||e.disabled,ae=i||e.readOnly,ve=S.useCallback(te=>{const pe=te.target.value;ae||xe||(ce.current&&ne.current&&pe!==ne.current&&(ce.current="",ne.current="",r(p?null:"")),I(pe),U(!0),X(-1))},[xe,ae,p,r]),Ye=S.useCallback(te=>{const pe=typeof te?.label=="string"?te.label:String(te?.value??""),We=f.apiValueField||"code";if(p){const Pt=Wp(f),je=D.find(Te=>String(or(Te,We))===String(te.value));if(je&&typeof je=="object"&&!Array.isArray(je)&&Pt.length>0){const Te=hC(je,Pt);ce.current=Il(Te,!0),ne.current=pe,r(Te),I(pe)}else ce.current=`S:${String(te.value)}`,ne.current=pe,r(String(te.value)),I(pe)}else ce.current=`S:${String(te.value)}`,ne.current=pe,r(String(te.value)),I(pe);G.current&&clearTimeout(G.current),U(!1),X(-1),n?.()},[p,n,r,f,D]),ct=S.useCallback(te=>{te.preventDefault(),te.stopPropagation(),!(xe||ae)&&(ce.current="",ne.current="",r(p?null:""),I(""),O([]),L([]),M([]),V(null),U(!1),n?.())},[xe,ae,p,r,n]),Ge=S.useMemo(()=>T&&!ae&&(R||!!ie||re.length>0||oe.length>=E&&!R),[T,ae,R,ie,re.length,oe,E]),Kt=S.useCallback(te=>{if(!(ae||xe))if(te.key==="ArrowDown")te.preventDefault(),U(!0),X(pe=>re.length===0?-1:(pe+1)%re.length);else if(te.key==="ArrowUp")te.preventDefault(),U(!0),X(pe=>re.length===0?-1:pe<=0?re.length-1:pe-1);else if(te.key==="Enter"){const pe=K>=0?re[K]:void 0;Ge&&pe&&!pe.disabled&&(te.preventDefault(),Ye(pe))}else te.key==="Escape"&&U(!1)},[xe,ae,K,Ge,re,Ye]),Je=e.appearance?.size||"md",q={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},$e=ht(e),gt=jt(e,!!(o||ie)),Oe=oe.length>=E&&!R&&!ie&&re.length===0;return c.jsx(Et,{field:e,error:o||ie||void 0,isRequired:a,className:d,children:c.jsxs(Fl,{open:Ge,onOpenChange:te=>{te||U(!1)},children:[c.jsx(sC,{asChild:!0,children:c.jsxs("div",{className:"relative flex w-full min-w-0 items-center gap-1",children:[c.jsx(wn,{id:$e,role:"combobox","aria-expanded":Ge,"aria-autocomplete":"list","aria-controls":Ge?`${$e}-listbox`:void 0,"aria-activedescendant":K>=0?`${$e}-opt-${K}`:void 0,value:A,onChange:ve,onKeyDown:Kt,onFocus:()=>{G.current&&clearTimeout(G.current),!ae&&!xe&&U(!0)},onBlur:()=>{G.current=setTimeout(()=>{U(!1),n?.()},150)},placeholder:e.placeholder||"Search…",disabled:xe,readOnly:ae,"aria-describedby":gt,"aria-invalid":Jt(!!(o||ie)),"aria-required":a,className:B("pr-20",q[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:[R&&c.jsx(Ro,{className:"pointer-events-none h-4 w-4 animate-spin text-muted-foreground"}),N&&yC(t,A,p)&&!xe&&!ae&&c.jsx(Yt,{type:"button",variant:"ghost",size:"icon",className:"pointer-events-auto h-8 w-8 shrink-0",onMouseDown:te=>te.preventDefault(),onClick:ct,"aria-label":"Clear",children:c.jsx(Ko,{className:"h-4 w-4"})})]})]})}),c.jsx(Pl,{className:"p-0 w-[var(--radix-popover-trigger-width)] min-w-[12rem] overflow-hidden",align:"start",onOpenAutoFocus:te=>te.preventDefault(),onCloseAutoFocus:te=>te.preventDefault(),children:c.jsx("div",{id:`${$e}-listbox`,role:"listbox",children:ie?c.jsx("div",{className:"px-3 py-2 text-sm text-destructive",children:ie}):R?c.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-sm text-muted-foreground",children:[c.jsx(Ro,{className:"h-4 w-4 animate-spin shrink-0"}),"Loading…"]}):Oe?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:te=>te.preventDefault(),children:"No results found"})}):c.jsx("ul",{className:"max-h-60 overflow-y-auto overscroll-contain py-1","aria-label":"Search results",children:re.map((te,pe)=>c.jsx("li",{id:`${$e}-opt-${pe}`,role:"option","aria-selected":K===pe,className:B(te.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:()=>{te.disabled||Ye(te)},children:te.label},`${te.value}-${pe}`))})})})]})})};var _i="Checkbox",[wC]=vr(_i),[SC,Dl]=wC(_i);function xC(e){const{__scopeCheckbox:t,checked:r,children:n,defaultChecked:o,disabled:s,form:i,name:a,onCheckedChange:d,required:u,value:l="on",internal_do_not_use_render:f}=e,[p,m]=Zr({prop:r,defaultProp:o??!1,onChange:d,caller:_i}),[g,h]=b.useState(null),[y,v]=b.useState(null),w=b.useRef(!1),x=g?!!i||!!g.closest("form"):!0,E={checked:p,disabled:s,setChecked:m,control:g,setControl:h,name:a,form:i,value:l,hasConsumerStoppedPropagationRef:w,required:u,defaultChecked:Fn(o)?!1:o,isFormControl:x,bubbleInput:y,setBubbleInput:v};return c.jsx(SC,{scope:t,...E,children:AC(f)?f(E):n})}var Kp="CheckboxTrigger",qp=b.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:r,...n},o)=>{const{control:s,value:i,disabled:a,checked:d,required:u,setControl:l,setChecked:f,hasConsumerStoppedPropagationRef:p,isFormControl:m,bubbleInput:g}=Dl(Kp,e),h=Qe(o,l),y=b.useRef(d);return b.useEffect(()=>{const v=s?.form;if(v){const w=()=>f(y.current);return v.addEventListener("reset",w),()=>v.removeEventListener("reset",w)}},[s,f]),c.jsx(Be.button,{type:"button",role:"checkbox","aria-checked":Fn(d)?"mixed":d,"aria-required":u,"data-state":em(d),"data-disabled":a?"":void 0,disabled:a,value:i,...n,ref:h,onKeyDown:Me(t,v=>{v.key==="Enter"&&v.preventDefault()}),onClick:Me(r,v=>{f(w=>Fn(w)?!0:!w),g&&m&&(p.current=v.isPropagationStopped(),p.current||v.stopPropagation())})})});qp.displayName=Kp;var Yp=b.forwardRef((e,t)=>{const{__scopeCheckbox:r,name:n,checked:o,defaultChecked:s,required:i,disabled:a,value:d,onCheckedChange:u,form:l,...f}=e;return c.jsx(xC,{__scopeCheckbox:r,checked:o,defaultChecked:s,disabled:a,required:i,onCheckedChange:u,name:n,form:l,value:d,internal_do_not_use_render:({isFormControl:p})=>c.jsxs(c.Fragment,{children:[c.jsx(qp,{...f,ref:t,__scopeCheckbox:r}),p&&c.jsx(Zp,{__scopeCheckbox:r})]})})});Yp.displayName=_i;var Xp="CheckboxIndicator",Jp=b.forwardRef((e,t)=>{const{__scopeCheckbox:r,forceMount:n,...o}=e,s=Dl(Xp,r);return c.jsx(xr,{present:n||Fn(s.checked)||s.checked===!0,children:c.jsx(Be.span,{"data-state":em(s.checked),"data-disabled":s.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});Jp.displayName=Xp;var Qp="CheckboxBubbleInput",Zp=b.forwardRef(({__scopeCheckbox:e,...t},r)=>{const{control:n,hasConsumerStoppedPropagationRef:o,checked:s,defaultChecked:i,required:a,disabled:d,name:u,value:l,form:f,bubbleInput:p,setBubbleInput:m}=Dl(Qp,e),g=Qe(r,m),h=Qo(s),y=Jo(n);b.useEffect(()=>{const w=p;if(!w)return;const x=window.HTMLInputElement.prototype,P=Object.getOwnPropertyDescriptor(x,"checked").set,C=!o.current;if(h!==s&&P){const N=new Event("click",{bubbles:C});w.indeterminate=Fn(s),P.call(w,Fn(s)?!1:s),w.dispatchEvent(N)}},[p,h,s,o]);const v=b.useRef(Fn(s)?!1:s);return c.jsx(Be.input,{type:"checkbox","aria-hidden":!0,defaultChecked:i??v.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%)"}})});Zp.displayName=Qp;function AC(e){return typeof e=="function"}function Fn(e){return e==="indeterminate"}function em(e){return Fn(e)?"indeterminate":e?"checked":"unchecked"}function ki({className:e,...t}){return c.jsx(Yp,{"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(Jp,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:c.jsx(Us,{className:"size-3.5"})})})}const CC=_p("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 EC({className:e,variant:t,asChild:r=!1,...n}){const o=r?Wd:"span";return c.jsx(o,{"data-slot":"badge",className:B(CC({variant:t}),e),...n})}function NC(e,t){return b.useReducer((r,n)=>t[r][n]??r,e)}var Bl="ScrollArea",[tm]=vr(Bl),[_C,Ir]=tm(Bl),rm=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,type:n="hover",dir:o,scrollHideDelay:s=600,...i}=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),[v,w]=b.useState(0),[x,E]=b.useState(0),[P,C]=b.useState(!1),[N,_]=b.useState(!1),A=Qe(t,T=>d(T)),I=ro(o);return c.jsx(_C,{scope:r,type:n,dir:I,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:l,content:f,onContentChange:p,scrollbarX:m,onScrollbarXChange:g,scrollbarXEnabled:P,onScrollbarXEnabledChange:C,scrollbarY:h,onScrollbarYChange:y,scrollbarYEnabled:N,onScrollbarYEnabledChange:_,onCornerWidthChange:w,onCornerHeightChange:E,children:c.jsx(Be.div,{dir:I,...i,ref:A,style:{position:"relative","--radix-scroll-area-corner-width":v+"px","--radix-scroll-area-corner-height":x+"px",...e.style}})})});rm.displayName=Bl;var nm="ScrollAreaViewport",om=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,children:n,nonce:o,...s}=e,i=Ir(nm,r),a=b.useRef(null),d=Qe(t,a,i.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(Be.div,{"data-radix-scroll-area-viewport":"",...s,ref:d,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:c.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});om.displayName=nm;var tn="ScrollAreaScrollbar",sm=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Ir(tn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return b.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?c.jsx(kC,{...n,ref:t,forceMount:r}):o.type==="scroll"?c.jsx(TC,{...n,ref:t,forceMount:r}):o.type==="auto"?c.jsx(im,{...n,ref:t,forceMount:r}):o.type==="always"?c.jsx($l,{...n,ref:t}):null});sm.displayName=tn;var kC=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Ir(tn,e.__scopeScrollArea),[s,i]=b.useState(!1);return b.useEffect(()=>{const a=o.scrollArea;let d=0;if(a){const u=()=>{window.clearTimeout(d),i(!0)},l=()=>{d=window.setTimeout(()=>i(!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(xr,{present:r||s,children:c.jsx(im,{"data-state":s?"visible":"hidden",...n,ref:t})})}),TC=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Ir(tn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Oi(()=>d("SCROLL_END"),100),[a,d]=NC("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=s?"scrollLeft":"scrollTop";if(u){let f=u[l];const p=()=>{const m=u[l];f!==m&&(d("SCROLL"),i()),f=m};return u.addEventListener("scroll",p),()=>u.removeEventListener("scroll",p)}},[o.viewport,s,d,i]),c.jsx(xr,{present:r||a!=="hidden",children:c.jsx($l,{"data-state":a==="hidden"?"hidden":"visible",...n,ref:t,onPointerEnter:Me(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:Me(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),im=b.forwardRef((e,t)=>{const r=Ir(tn,e.__scopeScrollArea),{forceMount:n,...o}=e,[s,i]=b.useState(!1),a=e.orientation==="horizontal",d=Oi(()=>{if(r.viewport){const u=r.viewport.offsetWidth<r.viewport.scrollWidth,l=r.viewport.offsetHeight<r.viewport.scrollHeight;i(a?u:l)}},10);return go(r.viewport,d),go(r.content,d),c.jsx(xr,{present:n||s,children:c.jsx($l,{"data-state":s?"visible":"hidden",...o,ref:t})})}),$l=b.forwardRef((e,t)=>{const{orientation:r="vertical",...n}=e,o=Ir(tn,e.__scopeScrollArea),s=b.useRef(null),i=b.useRef(0),[a,d]=b.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=um(a.viewport,a.content),l={...n,sizes:a,onSizesChange:d,hasThumb:u>0&&u<1,onThumbChange:p=>s.current=p,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:p=>i.current=p};function f(p,m){return LC(p,i.current,a,m)}return r==="horizontal"?c.jsx(FC,{...l,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollLeft,m=fm(p,a,o.dir);s.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(PC,{...l,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollTop,m=fm(p,a);s.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}),FC=b.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...o}=e,s=Ir(tn,e.__scopeScrollArea),[i,a]=b.useState(),d=b.useRef(null),u=Qe(t,d,s.onScrollbarXChange);return b.useEffect(()=>{d.current&&a(getComputedStyle(d.current))},[d]),c.jsx(lm,{"data-orientation":"horizontal",...o,ref:u,sizes:r,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Pi(r)+"px",...e.style},onThumbPointerDown:l=>e.onThumbPointerDown(l.x),onDragScroll:l=>e.onDragScroll(l.x),onWheelScroll:(l,f)=>{if(s.viewport){const p=s.viewport.scrollLeft+l.deltaX;e.onWheelScroll(p),mm(p,f)&&l.preventDefault()}},onResize:()=>{d.current&&s.viewport&&i&&n({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:Fi(i.paddingLeft),paddingEnd:Fi(i.paddingRight)}})}})}),PC=b.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...o}=e,s=Ir(tn,e.__scopeScrollArea),[i,a]=b.useState(),d=b.useRef(null),u=Qe(t,d,s.onScrollbarYChange);return b.useEffect(()=>{d.current&&a(getComputedStyle(d.current))},[d]),c.jsx(lm,{"data-orientation":"vertical",...o,ref:u,sizes:r,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Pi(r)+"px",...e.style},onThumbPointerDown:l=>e.onThumbPointerDown(l.y),onDragScroll:l=>e.onDragScroll(l.y),onWheelScroll:(l,f)=>{if(s.viewport){const p=s.viewport.scrollTop+l.deltaY;e.onWheelScroll(p),mm(p,f)&&l.preventDefault()}},onResize:()=>{d.current&&s.viewport&&i&&n({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:Fi(i.paddingTop),paddingEnd:Fi(i.paddingBottom)}})}})}),[OC,am]=tm(tn),lm=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:d,onDragScroll:u,onWheelScroll:l,onResize:f,...p}=e,m=Ir(tn,r),[g,h]=b.useState(null),y=Qe(t,A=>h(A)),v=b.useRef(null),w=b.useRef(""),x=m.viewport,E=n.content-n.viewport,P=ar(l),C=ar(d),N=Oi(f,10);function _(A){if(v.current){const I=A.clientX-v.current.left,T=A.clientY-v.current.top;u({x:I,y:T})}}return b.useEffect(()=>{const A=I=>{const T=I.target;g?.contains(T)&&P(I,E)};return document.addEventListener("wheel",A,{passive:!1}),()=>document.removeEventListener("wheel",A,{passive:!1})},[x,g,E,P]),b.useEffect(C,[n,C]),go(g,N),go(m.content,N),c.jsx(OC,{scope:r,scrollbar:g,hasThumb:o,onThumbChange:ar(s),onThumbPointerUp:ar(i),onThumbPositionChange:C,onThumbPointerDown:ar(a),children:c.jsx(Be.div,{...p,ref:y,style:{position:"absolute",...p.style},onPointerDown:Me(e.onPointerDown,A=>{A.button===0&&(A.target.setPointerCapture(A.pointerId),v.current=g.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),_(A))}),onPointerMove:Me(e.onPointerMove,_),onPointerUp:Me(e.onPointerUp,A=>{const I=A.target;I.hasPointerCapture(A.pointerId)&&I.releasePointerCapture(A.pointerId),document.body.style.webkitUserSelect=w.current,m.viewport&&(m.viewport.style.scrollBehavior=""),v.current=null})})})}),Ti="ScrollAreaThumb",cm=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=am(Ti,e.__scopeScrollArea);return c.jsx(xr,{present:r||o.hasThumb,children:c.jsx(IC,{ref:t,...n})})}),IC=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,style:n,...o}=e,s=Ir(Ti,r),i=am(Ti,r),{onThumbPositionChange:a}=i,d=Qe(t,f=>i.onThumbChange(f)),u=b.useRef(void 0),l=Oi(()=>{u.current&&(u.current(),u.current=void 0)},100);return b.useEffect(()=>{const f=s.viewport;if(f){const p=()=>{if(l(),!u.current){const m=DC(f,a);u.current=m,a()}};return a(),f.addEventListener("scroll",p),()=>f.removeEventListener("scroll",p)}},[s.viewport,l,a]),c.jsx(Be.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:Me(e.onPointerDownCapture,f=>{const m=f.target.getBoundingClientRect(),g=f.clientX-m.left,h=f.clientY-m.top;i.onThumbPointerDown({x:g,y:h})}),onPointerUp:Me(e.onPointerUp,i.onThumbPointerUp)})});cm.displayName=Ti;var jl="ScrollAreaCorner",dm=b.forwardRef((e,t)=>{const r=Ir(jl,e.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?c.jsx(MC,{...e,ref:t}):null});dm.displayName=jl;var MC=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,...n}=e,o=Ir(jl,r),[s,i]=b.useState(0),[a,d]=b.useState(0),u=!!(s&&a);return go(o.scrollbarX,()=>{const l=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(l),d(l)}),go(o.scrollbarY,()=>{const l=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(l),i(l)}),u?c.jsx(Be.div,{...n,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Fi(e){return e?parseInt(e,10):0}function um(e,t){const r=e/t;return isNaN(r)?0:r}function Pi(e){const t=um(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,n=(e.scrollbar.size-r)*t;return Math.max(n,18)}function LC(e,t,r,n="ltr"){const o=Pi(r),s=o/2,i=t||s,a=o-i,d=r.scrollbar.paddingStart+i,u=r.scrollbar.size-r.scrollbar.paddingEnd-a,l=r.content-r.viewport,f=n==="ltr"?[0,l]:[l*-1,0];return pm([d,u],f)(e)}function fm(e,t,r="ltr"){const n=Pi(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-n,d=r==="ltr"?[0,i]:[i*-1,0],u=qo(e,d);return pm([0,i],[0,a])(u)}function pm(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 mm(e,t){return e>0&&e<t}var DC=(e,t=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},n=0;return(function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=r.left!==s.left,a=r.top!==s.top;(i||a)&&t(),r=s,n=window.requestAnimationFrame(o)})(),()=>window.cancelAnimationFrame(n)};function Oi(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 go(e,t){const r=ar(t);Qt(()=>{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 BC=rm,$C=om,jC=dm;function zC({className:e,children:t,...r}){return c.jsxs(BC,{"data-slot":"scroll-area",className:B("relative",e),...r,children:[c.jsx($C,{"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(UC,{}),c.jsx(jC,{})]})}function UC({className:e,orientation:t="vertical",...r}){return c.jsx(sm,{"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 hm=({field:e,value:t=[],onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,formValues:d={},submissionContext:u,excludedOptionValues:l})=>{const{options:f,isLoadingOptions:p,optionsError:m}=Ap({field:e,formValues:d,submissionContext:u}),g=l?.length?new Set(l.map(String)):null,h=g?f.filter(N=>!g.has(String(N.value??N.label??""))):f,y=Array.isArray(t)?t:[],v=y.map(N=>h.find(_=>String(_.value)===String(N))).filter(Boolean),w=S.useCallback(N=>{const _=y.includes(N)?y.filter(A=>A!==N):[...y,N];r(_),n?.()},[y,r,n]),x=S.useCallback(N=>{r(y.filter(_=>_!==N)),n?.()},[y,r,n]),E=e.appearance?.size||"md",P={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},C=v.length>0?`${v.length} selected`:h.length===0&&l?.length?"No available options":e.placeholder||"Select options";return c.jsxs(Et,{field:e,error:o||m||void 0,isRequired:i,className:a,children:[c.jsxs(Fl,{children:[c.jsx(jp,{asChild:!0,children:c.jsxs(Yt,{type:"button",variant:"outline",role:"combobox","aria-expanded":void 0,"aria-haspopup":"listbox","aria-multiselectable":"true","aria-describedby":jt(e,!!o||!!m),"aria-invalid":Jt(!!o||!!m),"aria-required":i,id:ht(e),disabled:s||e.disabled||p,className:B("w-full min-w-0 justify-between font-normal",P[E],o&&"border-destructive focus-visible:ring-destructive",m&&"border-destructive focus-visible:ring-destructive",e.appearance?.className),children:[c.jsx("span",{className:"truncate",children:C}),c.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[p&&c.jsx(Ro,{className:"h-4 w-4 animate-spin text-muted-foreground"}),c.jsx(Wo,{className:"h-4 w-4 opacity-50"})]})]})}),c.jsx(Pl,{className:"w-[var(--radix-popover-trigger-width)] p-0 overflow-hidden",align:"start",children:c.jsx(zC,{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(N=>{const _=String(N.value||N.label),A=N.label||N.value||_,I=y.includes(_);return c.jsxs("li",{role:"option","aria-selected":I,className:"flex items-center gap-2 rounded-sm px-2 py-1.5 cursor-pointer hover:bg-accent focus:bg-accent outline-none",onClick:()=>!N.disabled&&w(_),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),N.disabled||w(_))},children:[c.jsx(ki,{checked:I,disabled:N.disabled,onCheckedChange:()=>!N.disabled&&w(_),onClick:T=>T.stopPropagation(),"aria-hidden":!0,className:"pointer-events-none"}),c.jsx("span",{className:"flex-1 truncate text-sm",children:A})]},_)})})})})]}),v.length>0&&c.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",role:"list","aria-label":"Selected options",children:v.map(N=>{const _=String(N.value||N.label),A=N.label||N.value||_;return c.jsxs(EC,{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(_),tabIndex:-1,children:c.jsx(Ko,{className:"h-3 w-3"})})]},_)})})]})},gm=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,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(ki,{id:ht(e),checked:t||!1,onCheckedChange:d,disabled:s||e.disabled,"aria-describedby":jt(e,!!o),"aria-required":i,className:B(o&&"border-destructive")}),c.jsxs("div",{className:"grid gap-1.5 leading-none",children:[c.jsxs(Sn,{id:js(e),htmlFor:ht(e),className:B("text-sm font-medium cursor-pointer",o&&"text-destructive"),children:[e.label,i&&c.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.description&&!o&&c.jsx("p",{id:Vo(e),className:"text-xs text-muted-foreground",children:e.description})]})]}),o&&c.jsx("p",{id:Ho(e),className:"text-xs text-destructive",role:"alert",children:o})]})};var Ii="Switch",[VC]=vr(Ii),[HC,WC]=VC(Ii),ym=b.forwardRef((e,t)=>{const{__scopeSwitch:r,name:n,checked:o,defaultChecked:s,required:i,disabled:a,value:d="on",onCheckedChange:u,form:l,...f}=e,[p,m]=b.useState(null),g=Qe(t,x=>m(x)),h=b.useRef(!1),y=p?l||!!p.closest("form"):!0,[v,w]=Zr({prop:o,defaultProp:s??!1,onChange:u,caller:Ii});return c.jsxs(HC,{scope:r,checked:v,disabled:a,children:[c.jsx(Be.button,{type:"button",role:"switch","aria-checked":v,"aria-required":i,"data-state":Sm(v),"data-disabled":a?"":void 0,disabled:a,value:d,...f,ref:g,onClick:Me(e.onClick,x=>{w(E=>!E),y&&(h.current=x.isPropagationStopped(),h.current||x.stopPropagation())})}),y&&c.jsx(wm,{control:p,bubbles:!h.current,name:n,value:d,checked:v,required:i,disabled:a,form:l,style:{transform:"translateX(-100%)"}})]})});ym.displayName=Ii;var bm="SwitchThumb",vm=b.forwardRef((e,t)=>{const{__scopeSwitch:r,...n}=e,o=WC(bm,r);return c.jsx(Be.span,{"data-state":Sm(o.checked),"data-disabled":o.disabled?"":void 0,...n,ref:t})});vm.displayName=bm;var RC="SwitchBubbleInput",wm=b.forwardRef(({__scopeSwitch:e,control:t,checked:r,bubbles:n=!0,...o},s)=>{const i=b.useRef(null),a=Qe(i,s),d=Qo(r),u=Jo(t);return b.useEffect(()=>{const l=i.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}})});wm.displayName=RC;function Sm(e){return e?"checked":"unchecked"}var GC=ym,KC=vm;function xm({className:e,...t}){return c.jsx(GC,{"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(KC,{"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 qC=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,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(Sn,{id:js(e),htmlFor:ht(e),className:B("text-sm font-medium block",o&&"text-destructive"),children:[e.label,i&&c.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.description&&!o&&c.jsx("p",{id:Vo(e),className:"text-xs text-muted-foreground",children:e.description}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(xm,{id:ht(e),checked:g,onCheckedChange:h,disabled:s||e.disabled,"aria-describedby":jt(e,!!o),"aria-required":i,className:B(o&&"opacity-50")}),c.jsx("span",{className:"text-sm text-foreground font-medium",children:g?p:m})]})]}),o&&c.jsx("p",{id:Ho(e),className:"text-xs text-destructive",role:"alert",children:o})]})};var zl="rovingFocusGroup.onEntryFocus",YC={bubbles:!1,cancelable:!0},as="RovingFocusGroup",[Ul,Am,XC]=La(as),[JC,Mi]=vr(as,[XC]),[QC,ZC]=JC(as),Cm=b.forwardRef((e,t)=>c.jsx(Ul.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Ul.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(eE,{...e,ref:t})})}));Cm.displayName=as;var eE=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:d,onEntryFocus:u,preventScrollOnEntryFocus:l=!1,...f}=e,p=b.useRef(null),m=Qe(t,p),g=ro(s),[h,y]=Zr({prop:i,defaultProp:a??null,onChange:d,caller:as}),[v,w]=b.useState(!1),x=ar(u),E=Am(r),P=b.useRef(!1),[C,N]=b.useState(0);return b.useEffect(()=>{const _=p.current;if(_)return _.addEventListener(zl,x),()=>_.removeEventListener(zl,x)},[x]),c.jsx(QC,{scope:r,orientation:n,dir:g,loop:o,currentTabStopId:h,onItemFocus:b.useCallback(_=>y(_),[y]),onItemShiftTab:b.useCallback(()=>w(!0),[]),onFocusableItemAdd:b.useCallback(()=>N(_=>_+1),[]),onFocusableItemRemove:b.useCallback(()=>N(_=>_-1),[]),children:c.jsx(Be.div,{tabIndex:v||C===0?-1:0,"data-orientation":n,...f,ref:m,style:{outline:"none",...e.style},onMouseDown:Me(e.onMouseDown,()=>{P.current=!0}),onFocus:Me(e.onFocus,_=>{const A=!P.current;if(_.target===_.currentTarget&&A&&!v){const I=new CustomEvent(zl,YC);if(_.currentTarget.dispatchEvent(I),!I.defaultPrevented){const T=E().filter(L=>L.focusable),U=T.find(L=>L.active),Q=T.find(L=>L.id===h),j=[U,Q,...T].filter(Boolean).map(L=>L.ref.current);_m(j,l)}}P.current=!1}),onBlur:Me(e.onBlur,()=>w(!1))})})}),Em="RovingFocusGroupItem",Nm=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:o=!1,tabStopId:s,children:i,...a}=e,d=on(),u=s||d,l=ZC(Em,r),f=l.currentTabStopId===u,p=Am(r),{onFocusableItemAdd:m,onFocusableItemRemove:g,currentTabStopId:h}=l;return b.useEffect(()=>{if(n)return m(),()=>g()},[n,m,g]),c.jsx(Ul.ItemSlot,{scope:r,id:u,focusable:n,active:o,children:c.jsx(Be.span,{tabIndex:f?0:-1,"data-orientation":l.orientation,...a,ref:t,onMouseDown:Me(e.onMouseDown,y=>{n?l.onItemFocus(u):y.preventDefault()}),onFocus:Me(e.onFocus,()=>l.onItemFocus(u)),onKeyDown:Me(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){l.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const v=nE(y,l.orientation,l.dir);if(v!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let x=p().filter(E=>E.focusable).map(E=>E.ref.current);if(v==="last")x.reverse();else if(v==="prev"||v==="next"){v==="prev"&&x.reverse();const E=x.indexOf(y.currentTarget);x=l.loop?oE(x,E+1):x.slice(E+1)}setTimeout(()=>_m(x))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:h!=null}):i})})});Nm.displayName=Em;var tE={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function rE(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function nE(e,t,r){const n=rE(e.key,r);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return tE[n]}function _m(e,t=!1){const r=document.activeElement;for(const n of e)if(n===r||(n.focus({preventScroll:t}),document.activeElement!==r))return}function oE(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var km=Cm,Tm=Nm,Vl="Radio",[sE,Fm]=vr(Vl),[iE,aE]=sE(Vl),Pm=b.forwardRef((e,t)=>{const{__scopeRadio:r,name:n,checked:o=!1,required:s,disabled:i,value:a="on",onCheck:d,form:u,...l}=e,[f,p]=b.useState(null),m=Qe(t,y=>p(y)),g=b.useRef(!1),h=f?u||!!f.closest("form"):!0;return c.jsxs(iE,{scope:r,checked:o,disabled:i,children:[c.jsx(Be.button,{type:"button",role:"radio","aria-checked":o,"data-state":Lm(o),"data-disabled":i?"":void 0,disabled:i,value:a,...l,ref:m,onClick:Me(e.onClick,y=>{o||d?.(),h&&(g.current=y.isPropagationStopped(),g.current||y.stopPropagation())})}),h&&c.jsx(Mm,{control:f,bubbles:!g.current,name:n,value:a,checked:o,required:s,disabled:i,form:u,style:{transform:"translateX(-100%)"}})]})});Pm.displayName=Vl;var Om="RadioIndicator",Im=b.forwardRef((e,t)=>{const{__scopeRadio:r,forceMount:n,...o}=e,s=aE(Om,r);return c.jsx(xr,{present:n||s.checked,children:c.jsx(Be.span,{"data-state":Lm(s.checked),"data-disabled":s.disabled?"":void 0,...o,ref:t})})});Im.displayName=Om;var lE="RadioBubbleInput",Mm=b.forwardRef(({__scopeRadio:e,control:t,checked:r,bubbles:n=!0,...o},s)=>{const i=b.useRef(null),a=Qe(i,s),d=Qo(r),u=Jo(t);return b.useEffect(()=>{const l=i.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(Be.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}})});Mm.displayName=lE;function Lm(e){return e?"checked":"unchecked"}var cE=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Li="RadioGroup",[dE]=vr(Li,[Mi,Fm]),Dm=Mi(),Bm=Fm(),[uE,fE]=dE(Li),$m=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,name:n,defaultValue:o,value:s,required:i=!1,disabled:a=!1,orientation:d,dir:u,loop:l=!0,onValueChange:f,...p}=e,m=Dm(r),g=ro(u),[h,y]=Zr({prop:s,defaultProp:o??null,onChange:f,caller:Li});return c.jsx(uE,{scope:r,name:n,required:i,disabled:a,value:h,onValueChange:y,children:c.jsx(km,{asChild:!0,...m,orientation:d,dir:g,loop:l,children:c.jsx(Be.div,{role:"radiogroup","aria-required":i,"aria-orientation":d,"data-disabled":a?"":void 0,dir:g,...p,ref:t})})})});$m.displayName=Li;var jm="RadioGroupItem",zm=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,disabled:n,...o}=e,s=fE(jm,r),i=s.disabled||n,a=Dm(r),d=Bm(r),u=b.useRef(null),l=Qe(t,u),f=s.value===o.value,p=b.useRef(!1);return b.useEffect(()=>{const m=h=>{cE.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(Tm,{asChild:!0,...a,focusable:!i,active:f,children:c.jsx(Pm,{disabled:i,required:s.required,checked:f,...d,...o,name:s.name,ref:l,onCheck:()=>s.onValueChange(o.value),onKeyDown:Me(m=>{m.key==="Enter"&&m.preventDefault()}),onFocus:Me(o.onFocus,()=>{p.current&&u.current?.click()})})})});zm.displayName=jm;var pE="RadioGroupIndicator",Um=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,...n}=e,o=Bm(r);return c.jsx(Im,{...o,...n,ref:t})});Um.displayName=pE;var mE=$m,hE=zm,gE=Um;function yE({className:e,...t}){return c.jsx(mE,{"data-slot":"radio-group",className:B("grid gap-3",e),...t})}function bE({className:e,...t}){return c.jsx(hE,{"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(gE,{"data-slot":"radio-group-indicator",className:"relative flex items-center justify-center",children:c.jsx(Xd,{className:"fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2"})})})}const Vm=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,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(Et,{field:e,error:o,isRequired:i,className:a,children:c.jsx(yE,{value:t||"",onValueChange:m,disabled:s||e.disabled||p.length===0,className:"flex flex-col space-y-2","aria-required":i,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(bE,{id:`${ht(e)}-${g.value}`,value:g.value,disabled:g.disabled,className:B(o&&"border-destructive")}),c.jsxs(Sn,{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))})})},Hm=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=e.properties,l=S.useCallback(E=>{r(E.target.value)},[r]),f=E=>{if(E)return E==="today"?new Date().toISOString().split("T")[0]:E},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",v={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},w=e.appearance?.labelPlacement||"top",x=!e.appearance?.hideLabel&&e.label;return c.jsxs("div",{className:B("space-y-2 w-fit",w==="left"&&"flex items-start gap-4",d),children:[x&&c.jsxs(Sn,{id:js(e),htmlFor:ht(e),className:B("text-sm font-medium",w==="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(bv,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"}),c.jsx(wn,{id:ht(e),type:h,value:t||"",onChange:l,onBlur:n,disabled:s||e.disabled,readOnly:i||e.readOnly,min:p,max:m,"aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:B(v[y],"pl-10 w-fit",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]}),e.description&&!o&&c.jsx("p",{id:Vo(e),className:"mt-1.5 text-xs text-muted-foreground",children:e.description}),o&&c.jsx("p",{id:Ho(e),className:"mt-1.5 text-xs text-destructive",role:"alert",children:o})]})]})};function yo(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 Hl(e,t){return e===1&&t===1}const Wm=/\.(jpg|jpeg|png|gif|webp|bmp|svg)(\?|$)/i;function Wl(e){return e.type.startsWith("image/")?!0:Wm.test(e.name)}function Di(e){try{const t=e.split("?")[0];return Wm.test(t)}catch{return!1}}function Rl({items:e,maxFiles:t,disabled:r,objectUrls:n,failedUrlKeys:o,onImageUrlError:s,onRemove:i,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??"",v=`${m}-${y}`,w=h&&o.has(y),x=g?n[m]??null:h&&Di(y)&&!w?y:null,E=g&&Wl(p)&&!!x||!!h&&Di(y)&&!w&&!!x,P=g?p.name:h?h.name??f(y):"",C=d?.(m,p),N=h&&y||C||"",_=!!a&&!!N;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:[E&&x?c.jsx("img",{src:x,alt:"",className:"absolute inset-0 h-full w-full object-cover",onError:()=>{h&&s(y)}}):c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-muted/40",children:c.jsx(Qd,{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.jsx("button",{type:"button",onClick:A=>{A.preventDefault(),A.stopPropagation(),a(N)},disabled:r,className:"inline-flex h-5 w-5 items-center justify-center rounded bg-background/90 text-foreground hover:bg-background focus:outline-none focus:ring-2 focus:ring-primary","aria-label":"Open file",title:"Open file",children:c.jsx(Jd,{className:"h-3 w-3","aria-hidden":!0})}),c.jsx("button",{type:"button",onClick:A=>{A.preventDefault(),A.stopPropagation(),i(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(Ko,{className:"h-3 w-3","aria-hidden":!0})})]}),!E&&P&&c.jsx("span",{className:"sr-only",children:P})]},v+(g?p.name+p.size:""))}),u]})}function Gl(e){const[t,r]=S.useState([]);return S.useEffect(()=>{const n=e.map(o=>o instanceof File&&Wl(o)?URL.createObjectURL(o):null);return r(n),()=>{n.forEach(o=>{o&&URL.revokeObjectURL(o)})}},[e]),t}function Kl({item:e,objectUrl:t,failedUrlKeys:r,onImageUrlError:n,onRemove:o,onOpenUrl:s,openTarget:i,disabled:a}){const d=S.useCallback(w=>{try{return w.split("?")[0].split("/").filter(Boolean).pop()||w}catch{return w}},[]),u=e instanceof File,l=!u&&e&&"url"in e?e:null,f=l?.url??"",p=l&&r.has(f),m=u?t:l&&Di(f)&&!p?f:null,g=u&&Wl(e)&&!!m||!!l&&Di(f)&&!p&&!!m,h=u?e.name:l?l.name??d(f):"",y=(i?.trim()||f||"").trim(),v=!!s&&!!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(Qd,{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:[v&&y&&c.jsx("button",{type:"button",onClick:w=>{w.preventDefault(),w.stopPropagation(),s(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(Jd,{className:"h-3.5 w-3.5","aria-hidden":!0})}),c.jsx("button",{type:"button",onClick:w=>{w.preventDefault(),w.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(Ko,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),!g&&h&&c.jsx("p",{className:"sr-only",children:h})]})}const vE=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,buttonResponses:d})=>{const{gridStretch:u}=zo(),l=u&&Os(e),f=e.properties,p=S.useRef(null),[m,g]=S.useState(!1),[h,y]=S.useState(),[v,w]=S.useState(()=>new Set),[x,E]=S.useState(0),P=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,C=Is(e),N=S.useMemo(()=>Ms(t),[t]),[_,A]=S.useState(null);S.useEffect(()=>{A(null)},[t,x]);const I=_??N,T=Gl(I),U=e.validation?.find(Se=>Se.type==="fileSize"),Q=e.validation?.find(Se=>Se.type==="fileType"),O=U?.value?U.value:f?.maxSize??P?.maxSize??10*1024*1024,j=Q?.value?Q.value:f?.accept??P?.accept??[],L=Array.isArray(j)?j.join(","):"",D=()=>{I.length>=C||p.current?.click()},M=S.useCallback(Se=>{if(U){const xe=Yr(Se,U);if(xe!==!0)return typeof xe=="string"?xe:"File size exceeds the maximum allowed size"}else if(Se.size>O)return`File size must be less than ${yo(O)}`;if(Q){const xe=Yr(Se,Q);if(xe!==!0)return typeof xe=="string"?xe:"File type is not allowed"}return null},[U,Q,O]),R=S.useCallback(Se=>{const xe=Na(Se,C);r(xe),n?.()},[r,n,C]),$=S.useCallback(Se=>{y(void 0);const xe=Array.from(Se),ae=[...I];let ve=null;for(const Ye of xe){if(ae.length>=C)break;const ct=M(Ye);if(ct){ve||(ve=ct);continue}ae.push(Ye)}if(ve&&ae.length===I.length){y(ve);return}ve&&y(ve),A(ae),R(ae)},[I,C,M,R]),ie=S.useCallback(Se=>{const xe=Se.target.files;xe&&xe.length>0&&$(xe),p.current&&(p.current.value="")},[$]),V=S.useCallback(Se=>{if(s)return;const xe=I.filter((ae,ve)=>ve!==Se);E(ae=>ae+1),A(xe),R(xe)},[s,I,R]),K=Se=>{Se.preventDefault(),g(!0)},X=()=>{g(!1)},ce=Se=>{Se.preventDefault(),g(!1),Se.dataTransfer.files?.length&&$(Se.dataTransfer.files)},ne=o||h,G=[];(U||O)&&G.push(`Max size: ${yo(O)}`),Q&&j.length>0&&G.push(`Allowed types: ${j.join(", ")}`),C>1&&G.push(`Up to ${C} files`);const ee=e.appearance?.hideLabel??!1,Pe=S.useMemo(()=>{if(!d)return null;const Se=Object.values(d);for(let xe=Se.length-1;xe>=0;xe-=1){const ae=Se[xe],ve=typeof ae?.status=="string"?ae.status.toLowerCase():null;if(ve&&ve!=="success")continue;const Ye=ae?.code;if(typeof Ye=="number"&&(Ye<200||Ye>=300))continue;const ct=ae?.data,Ge=ct?.file_url||ct?.fileUrl||ae?.file_url||ae?.fileUrl;if(typeof Ge=="string"&&Ge.trim())return Ge}return null},[d]),oe=S.useCallback(Se=>{window.open(Se,"_blank","noopener,noreferrer")},[]),re=S.useCallback(Se=>{w(xe=>new Set(xe).add(Se))},[]),be=I.length===0,de=I.length<C,ot=Hl(C,I.length);return c.jsx(Et,{field:e,error:ne,isRequired:i,className:B(a,"!space-y-0"),hideLabel:ee,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:Se=>{Se.target.closest("[data-remove-in-dropzone]")||Se.target.closest("[data-no-open-picker]")||D()},onDragOver:K,onDragLeave:X,onDrop:ce,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",s&&"opacity-50 cursor-not-allowed",!de&&I.length>0&&"cursor-default"),children:[c.jsx("input",{ref:p,id:ht(e),type:"file",accept:L,multiple:C>1,onChange:ie,disabled:s||e.disabled||!de,className:"hidden","aria-describedby":jt(e,!!ne),"aria-invalid":Jt(!!ne),"aria-required":i}),be?c.jsxs(c.Fragment,{children:[c.jsx(Vs,{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"}),G.length>0&&c.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-1",children:G.join(" • ")})]}):ot?c.jsx(Kl,{item:I[0],objectUrl:T[0]??null,failedUrlKeys:v,onImageUrlError:re,onRemove:()=>V(0),onOpenUrl:oe,openTarget:I[0]instanceof File?Pe:void 0,disabled:s||e.disabled}):c.jsx(Rl,{items:I,maxFiles:C,disabled:s,objectUrls:T,failedUrlKeys:v,onImageUrlError:re,onRemove:V,resolveOpenUrl:(Se,xe)=>xe instanceof File&&I.length===1&&Pe?.trim()?Pe.trim():null,onOpenUrl:Se=>{Se?.trim()&&oe(Se.trim())},addSlot:de?c.jsxs("button",{type:"button","data-no-open-picker":!0,onClick:Se=>{Se.stopPropagation(),p.current?.click()},disabled:s||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(Vs,{className:"h-4 w-4 mb-0.5","aria-hidden":!0}),"Add"]}):void 0})]})})})};function wE(e){const t=SE(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),d=a.find(AE);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,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function SE(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=EE(o),a=CE(s,o.props);return o.type!==b.Fragment&&(a.ref=n?Bn(n,i):i),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var xE=Symbol("radix.slottable");function AE(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===xE}function CE(e,t){const r={...t};for(const n in t){const o=e[n],s=t[n];/^on[A-Z]/.test(n)?o&&s?r[n]=(...a)=>{const d=s(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function EE(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 Bi="Dialog",[Rm]=vr(Bi),[NE,Rr]=Rm(Bi),Gm=e=>{const{__scopeDialog:t,children:r,open:n,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=b.useRef(null),d=b.useRef(null),[u,l]=Zr({prop:n,defaultProp:o??!1,onChange:s,caller:Bi});return c.jsx(NE,{scope:t,triggerRef:a,contentRef:d,contentId:on(),titleId:on(),descriptionId:on(),open:u,onOpenChange:l,onOpenToggle:b.useCallback(()=>l(f=>!f),[l]),modal:i,children:r})};Gm.displayName=Bi;var Km="DialogTrigger",_E=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Rr(Km,r),s=Qe(t,o.triggerRef);return c.jsx(Be.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Xl(o.open),...n,ref:s,onClick:Me(e.onClick,o.onOpenToggle)})});_E.displayName=Km;var ql="DialogPortal",[kE,qm]=Rm(ql,{forceMount:void 0}),Ym=e=>{const{__scopeDialog:t,forceMount:r,children:n,container:o}=e,s=Rr(ql,t);return c.jsx(kE,{scope:t,forceMount:r,children:b.Children.map(n,i=>c.jsx(xr,{present:r||s.open,children:c.jsx(ri,{asChild:!0,container:o,children:i})}))})};Ym.displayName=ql;var $i="DialogOverlay",Xm=b.forwardRef((e,t)=>{const r=qm($i,e.__scopeDialog),{forceMount:n=r.forceMount,...o}=e,s=Rr($i,e.__scopeDialog);return s.modal?c.jsx(xr,{present:n||s.open,children:c.jsx(FE,{...o,ref:t})}):null});Xm.displayName=$i;var TE=wE("DialogOverlay.RemoveScroll"),FE=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Rr($i,r);return c.jsx(di,{as:TE,allowPinchZoom:!0,shards:[o.contentRef],children:c.jsx(Be.div,{"data-state":Xl(o.open),...n,ref:t,style:{pointerEvents:"auto",...n.style}})})}),Gn="DialogContent",Jm=b.forwardRef((e,t)=>{const r=qm(Gn,e.__scopeDialog),{forceMount:n=r.forceMount,...o}=e,s=Rr(Gn,e.__scopeDialog);return c.jsx(xr,{present:n||s.open,children:s.modal?c.jsx(PE,{...o,ref:t}):c.jsx(OE,{...o,ref:t})})});Jm.displayName=Gn;var PE=b.forwardRef((e,t)=>{const r=Rr(Gn,e.__scopeDialog),n=b.useRef(null),o=Qe(t,r.contentRef,n);return b.useEffect(()=>{const s=n.current;if(s)return nl(s)},[]),c.jsx(Qm,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Me(e.onCloseAutoFocus,s=>{s.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:Me(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:Me(e.onFocusOutside,s=>s.preventDefault())})}),OE=b.forwardRef((e,t)=>{const r=Rr(Gn,e.__scopeDialog),n=b.useRef(!1),o=b.useRef(!1);return c.jsx(Qm,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{e.onCloseAutoFocus?.(s),s.defaultPrevented||(n.current||r.triggerRef.current?.focus(),s.preventDefault()),n.current=!1,o.current=!1},onInteractOutside:s=>{e.onInteractOutside?.(s),s.defaultPrevented||(n.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;r.triggerRef.current?.contains(i)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Qm=b.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=Rr(Gn,r),d=b.useRef(null),u=Qe(t,d);return $a(),c.jsxs(c.Fragment,{children:[c.jsx(Ws,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:s,children:c.jsx(Hs,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Xl(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),c.jsxs(c.Fragment,{children:[c.jsx(ME,{titleId:a.titleId}),c.jsx(DE,{contentRef:d,descriptionId:a.descriptionId})]})]})}),Yl="DialogTitle",Zm=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Rr(Yl,r);return c.jsx(Be.h2,{id:o.titleId,...n,ref:t})});Zm.displayName=Yl;var eh="DialogDescription",IE=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Rr(eh,r);return c.jsx(Be.p,{id:o.descriptionId,...n,ref:t})});IE.displayName=eh;var th="DialogClose",rh=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Rr(th,r);return c.jsx(Be.button,{type:"button",...n,ref:t,onClick:Me(e.onClick,()=>o.onOpenChange(!1))})});rh.displayName=th;function Xl(e){return e?"open":"closed"}var nh="DialogTitleWarning",[VP,oh]=Ev(nh,{contentName:Gn,titleName:Yl,docsSlug:"dialog"}),ME=({titleId:e})=>{const t=oh(nh),r=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
41
|
+
`)},gx=0,uo=[];function yx(e){var t=b.useRef([]),r=b.useRef([0,0]),n=b.useRef(),o=b.useState(gx++)[0],s=b.useState(af)[0],i=b.useRef(e);b.useEffect(function(){i.current=e},[e]),b.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var h=$S([e.lockRef.current],(e.shards||[]).map(mf),!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!i.current.allowPinchZoom;var v=di(h),w=r.current,x="deltaX"in h?h.deltaX:w[0]-v[0],E="deltaY"in h?h.deltaY:w[1]-v[1],P,C=h.target,N=Math.abs(x)>Math.abs(E)?"h":"v";if("touches"in h&&N==="h"&&C.type==="range")return!1;var _=window.getSelection(),A=_&&_.anchorNode,I=A?A===C||A.contains(C):!1;if(I)return!1;var T=df(N,C);if(!T)return!0;if(T?P=N:(P=N==="v"?"h":"v",T=df(N,C)),!T)return!1;if(!n.current&&"changedTouches"in h&&(x||E)&&(n.current=P),!P)return!0;var W=n.current||P;return px(W,y,h,W==="h"?x:E)},[]),d=b.useCallback(function(h){var y=h;if(!(!uo.length||uo[uo.length-1]!==s)){var v="deltaY"in y?pf(y):di(y),w=t.current.filter(function(P){return P.name===y.type&&(P.target===y.target||y.target===P.shadowParent)&&mx(P.delta,v)})[0];if(w&&w.should){y.cancelable&&y.preventDefault();return}if(!w){var x=(i.current.shards||[]).map(mf).filter(Boolean).filter(function(P){return P.contains(y.target)}),E=x.length>0?a(y,x[0]):!i.current.noIsolation;E&&y.cancelable&&y.preventDefault()}}},[]),u=b.useCallback(function(h,y,v,w){var x={name:h,delta:y,target:v,should:w,shadowParent:bx(v)};t.current.push(x),setTimeout(function(){t.current=t.current.filter(function(E){return E!==x})},1)},[]),l=b.useCallback(function(h){r.current=di(h),n.current=void 0},[]),f=b.useCallback(function(h){u(h.type,pf(h),h.target,a(h,e.lockRef.current))},[]),p=b.useCallback(function(h){u(h.type,di(h),h.target,a(h,e.lockRef.current))},[]);b.useEffect(function(){return uo.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener("wheel",d,co),document.addEventListener("touchmove",d,co),document.addEventListener("touchstart",l,co),function(){uo=uo.filter(function(h){return h!==s}),document.removeEventListener("wheel",d,co),document.removeEventListener("touchmove",d,co),document.removeEventListener("touchstart",l,co)}},[]);var m=e.removeScrollBar,g=e.inert;return b.createElement(b.Fragment,null,g?b.createElement(s,{styles:hx(o)}):null,m?b.createElement(ix,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function bx(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const vx=KS(sf,yx);var ui=b.forwardRef(function(e,t){return b.createElement(li,en({},e,{ref:t,sideCar:vx}))});ui.classNames=li.classNames;var wx=[" ","Enter","ArrowUp","ArrowDown"],Sx=[" ","Enter"],zn="Select",[fi,pi,xx]=Ba(zn),[fo]=vr(zn,[xx,ri]),mi=ri(),[Ax,Nn]=fo(zn),[Cx,Ex]=fo(zn),hf=e=>{const{__scopeSelect:t,children:r,open:n,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:d,dir:u,name:l,autoComplete:f,disabled:p,required:m,form:g}=e,h=mi(t),[y,v]=b.useState(null),[w,x]=b.useState(null),[E,P]=b.useState(!1),C=ro(u),[N,_]=Zr({prop:n,defaultProp:o??!1,onChange:s,caller:zn}),[A,I]=Zr({prop:i,defaultProp:a,onChange:d,caller:zn}),T=b.useRef(null),W=y?g||!!y.closest("form"):!0,[J,O]=b.useState(new Set),j=Array.from(J).map(M=>M.props.value).join(";");return c.jsx(Ju,{...h,children:c.jsxs(Ax,{required:m,scope:t,trigger:y,onTriggerChange:v,valueNode:w,onValueNodeChange:x,valueNodeHasChildren:E,onValueNodeHasChildrenChange:P,contentId:on(),value:A,onValueChange:I,open:N,onOpenChange:_,dir:C,triggerPointerDownPosRef:T,disabled:p,children:[c.jsx(fi.Provider,{scope:t,children:c.jsx(Cx,{scope:e.__scopeSelect,onNativeOptionAdd:b.useCallback(M=>{O(D=>new Set(D).add(M))},[]),onNativeOptionRemove:b.useCallback(M=>{O(D=>{const L=new Set(D);return L.delete(M),L})},[]),children:r})}),W?c.jsxs(Bf,{"aria-hidden":!0,required:m,tabIndex:-1,name:l,autoComplete:f,value:A,onChange:M=>I(M.target.value),disabled:p,form:g,children:[A===void 0?c.jsx("option",{value:""}):null,Array.from(J)]},j):null]})})};hf.displayName=zn;var gf="SelectTrigger",yf=b.forwardRef((e,t)=>{const{__scopeSelect:r,disabled:n=!1,...o}=e,s=mi(r),i=Nn(gf,r),a=i.disabled||n,d=Ze(t,i.onTriggerChange),u=pi(r),l=b.useRef("touch"),[f,p,m]=jf(h=>{const y=u().filter(x=>!x.disabled),v=y.find(x=>x.value===i.value),w=zf(y,h,v);w!==void 0&&i.onValueChange(w.value)}),g=h=>{a||(i.onOpenChange(!0),m()),h&&(i.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})};return c.jsx(nl,{asChild:!0,...s,children:c.jsx(Be.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":$f(i.value)?"":void 0,...o,ref:d,onClick:Me(o.onClick,h=>{h.currentTarget.focus(),l.current!=="mouse"&&g(h)}),onPointerDown:Me(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:Me(o.onKeyDown,h=>{const y=f.current!=="";!(h.ctrlKey||h.altKey||h.metaKey)&&h.key.length===1&&p(h.key),!(y&&h.key===" ")&&wx.includes(h.key)&&(g(),h.preventDefault())})})})});yf.displayName=gf;var bf="SelectValue",vf=b.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,style:o,children:s,placeholder:i="",...a}=e,d=Nn(bf,r),{onValueNodeHasChildrenChange:u}=d,l=s!==void 0,f=Ze(t,d.onValueNodeChange);return Qt(()=>{u(l)},[u,l]),c.jsx(Be.span,{...a,ref:f,style:{pointerEvents:"none"},children:$f(d.value)?c.jsx(c.Fragment,{children:i}):s})});vf.displayName=bf;var Nx="SelectIcon",wf=b.forwardRef((e,t)=>{const{__scopeSelect:r,children:n,...o}=e;return c.jsx(Be.span,{"aria-hidden":!0,...o,ref:t,children:n||"▼"})});wf.displayName=Nx;var _x="SelectPortal",Sf=e=>c.jsx(ni,{asChild:!0,...e});Sf.displayName=_x;var Un="SelectContent",xf=b.forwardRef((e,t)=>{const r=Nn(Un,e.__scopeSelect),[n,o]=b.useState();if(Qt(()=>{o(new DocumentFragment)},[]),!r.open){const s=n;return s?Es.createPortal(c.jsx(Af,{scope:e.__scopeSelect,children:c.jsx(fi.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx(Cf,{...e,ref:t})});xf.displayName=Un;var Hr=10,[Af,_n]=fo(Un),kx="SelectContentImpl",Tx=CS("SelectContent.RemoveScroll"),Cf=b.forwardRef((e,t)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:d,align:u,alignOffset:l,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:g,hideWhenDetached:h,avoidCollisions:y,...v}=e,w=Nn(Un,r),[x,E]=b.useState(null),[P,C]=b.useState(null),N=Ze(t,G=>E(G)),[_,A]=b.useState(null),[I,T]=b.useState(null),W=pi(r),[J,O]=b.useState(!1),j=b.useRef(!1);b.useEffect(()=>{if(x)return sl(x)},[x]),za();const M=b.useCallback(G=>{const[ee,...Pe]=W().map(be=>be.ref.current),[oe]=Pe.slice(-1),re=document.activeElement;for(const be of G)if(be===re||(be?.scrollIntoView({block:"nearest"}),be===ee&&P&&(P.scrollTop=0),be===oe&&P&&(P.scrollTop=P.scrollHeight),be?.focus(),document.activeElement!==re))return},[W,P]),D=b.useCallback(()=>M([_,x]),[M,_,x]);b.useEffect(()=>{J&&D()},[J,D]);const{onOpenChange:L,triggerPointerDownPosRef:U}=w;b.useEffect(()=>{if(x){let G={x:0,y:0};const ee=oe=>{G={x:Math.abs(Math.round(oe.pageX)-(U.current?.x??0)),y:Math.abs(Math.round(oe.pageY)-(U.current?.y??0))}},Pe=oe=>{G.x<=10&&G.y<=10?oe.preventDefault():x.contains(oe.target)||L(!1),document.removeEventListener("pointermove",ee),U.current=null};return U.current!==null&&(document.addEventListener("pointermove",ee),document.addEventListener("pointerup",Pe,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ee),document.removeEventListener("pointerup",Pe,{capture:!0})}}},[x,L,U]),b.useEffect(()=>{const G=()=>L(!1);return window.addEventListener("blur",G),window.addEventListener("resize",G),()=>{window.removeEventListener("blur",G),window.removeEventListener("resize",G)}},[L]);const[$,ie]=jf(G=>{const ee=W().filter(re=>!re.disabled),Pe=ee.find(re=>re.ref.current===document.activeElement),oe=zf(ee,G,Pe);oe&&setTimeout(()=>oe.ref.current.focus())}),V=b.useCallback((G,ee,Pe)=>{const oe=!j.current&&!Pe;(w.value!==void 0&&w.value===ee||oe)&&(A(G),oe&&(j.current=!0))},[w.value]),K=b.useCallback(()=>x?.focus(),[x]),X=b.useCallback((G,ee,Pe)=>{const oe=!j.current&&!Pe;(w.value!==void 0&&w.value===ee||oe)&&T(G)},[w.value]),ce=n==="popper"?dl:Ef,ne=ce===dl?{side:a,sideOffset:d,align:u,alignOffset:l,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:g,hideWhenDetached:h,avoidCollisions:y}:{};return c.jsx(Af,{scope:r,content:x,viewport:P,onViewportChange:C,itemRefCallback:V,selectedItem:_,onItemLeave:K,itemTextRefCallback:X,focusSelectedItem:D,selectedItemText:I,position:n,isPositioned:J,searchRef:$,children:c.jsx(ui,{as:Tx,allowPinchZoom:!0,children:c.jsx(Rs,{asChild:!0,trapped:w.open,onMountAutoFocus:G=>{G.preventDefault()},onUnmountAutoFocus:Me(o,G=>{w.trigger?.focus({preventScroll:!0}),G.preventDefault()}),children:c.jsx(Ws,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:G=>G.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:c.jsx(ce,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:G=>G.preventDefault(),...v,...ne,onPlaced:()=>O(!0),ref:N,style:{display:"flex",flexDirection:"column",outline:"none",...v.style},onKeyDown:Me(v.onKeyDown,G=>{const ee=G.ctrlKey||G.altKey||G.metaKey;if(G.key==="Tab"&&G.preventDefault(),!ee&&G.key.length===1&&ie(G.key),["ArrowUp","ArrowDown","Home","End"].includes(G.key)){let oe=W().filter(re=>!re.disabled).map(re=>re.ref.current);if(["ArrowUp","End"].includes(G.key)&&(oe=oe.slice().reverse()),["ArrowUp","ArrowDown"].includes(G.key)){const re=G.target,be=oe.indexOf(re);oe=oe.slice(be+1)}setTimeout(()=>M(oe)),G.preventDefault()}})})})})})})});Cf.displayName=kx;var Fx="SelectItemAlignedPosition",Ef=b.forwardRef((e,t)=>{const{__scopeSelect:r,onPlaced:n,...o}=e,s=Nn(Un,r),i=_n(Un,r),[a,d]=b.useState(null),[u,l]=b.useState(null),f=Ze(t,N=>l(N)),p=pi(r),m=b.useRef(!1),g=b.useRef(!0),{viewport:h,selectedItem:y,selectedItemText:v,focusSelectedItem:w}=i,x=b.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&h&&y&&v){const N=s.trigger.getBoundingClientRect(),_=u.getBoundingClientRect(),A=s.valueNode.getBoundingClientRect(),I=v.getBoundingClientRect();if(s.dir!=="rtl"){const re=I.left-_.left,be=A.left-re,de=N.left-be,ot=N.width+de,Se=Math.max(ot,_.width),xe=window.innerWidth-Hr,ae=qo(be,[Hr,Math.max(Hr,xe-Se)]);a.style.minWidth=ot+"px",a.style.left=ae+"px"}else{const re=_.right-I.right,be=window.innerWidth-A.right-re,de=window.innerWidth-N.right-be,ot=N.width+de,Se=Math.max(ot,_.width),xe=window.innerWidth-Hr,ae=qo(be,[Hr,Math.max(Hr,xe-Se)]);a.style.minWidth=ot+"px",a.style.right=ae+"px"}const T=p(),W=window.innerHeight-Hr*2,J=h.scrollHeight,O=window.getComputedStyle(u),j=parseInt(O.borderTopWidth,10),M=parseInt(O.paddingTop,10),D=parseInt(O.borderBottomWidth,10),L=parseInt(O.paddingBottom,10),U=j+M+J+L+D,$=Math.min(y.offsetHeight*5,U),ie=window.getComputedStyle(h),V=parseInt(ie.paddingTop,10),K=parseInt(ie.paddingBottom,10),X=N.top+N.height/2-Hr,ce=W-X,ne=y.offsetHeight/2,G=y.offsetTop+ne,ee=j+M+G,Pe=U-ee;if(ee<=X){const re=T.length>0&&y===T[T.length-1].ref.current;a.style.bottom="0px";const be=u.clientHeight-h.offsetTop-h.offsetHeight,de=Math.max(ce,ne+(re?K:0)+be+D),ot=ee+de;a.style.height=ot+"px"}else{const re=T.length>0&&y===T[0].ref.current;a.style.top="0px";const de=Math.max(X,j+h.offsetTop+(re?V:0)+ne)+Pe;a.style.height=de+"px",h.scrollTop=ee-X+h.offsetTop}a.style.margin=`${Hr}px 0`,a.style.minHeight=$+"px",a.style.maxHeight=W+"px",n?.(),requestAnimationFrame(()=>m.current=!0)}},[p,s.trigger,s.valueNode,a,u,h,y,v,s.dir,n]);Qt(()=>x(),[x]);const[E,P]=b.useState();Qt(()=>{u&&P(window.getComputedStyle(u).zIndex)},[u]);const C=b.useCallback(N=>{N&&g.current===!0&&(x(),w?.(),g.current=!1)},[x,w]);return c.jsx(Ox,{scope:r,contentWrapper:a,shouldExpandOnScrollRef:m,onScrollButtonChange:C,children:c.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:c.jsx(Be.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Ef.displayName=Fx;var Px="SelectPopperPosition",dl=b.forwardRef((e,t)=>{const{__scopeSelect:r,align:n="start",collisionPadding:o=Hr,...s}=e,i=mi(r);return c.jsx(Qu,{...i,...s,ref:t,align:n,collisionPadding:o,style:{boxSizing:"border-box",...s.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)"}})});dl.displayName=Px;var[Ox,ul]=fo(Un,{}),fl="SelectViewport",Nf=b.forwardRef((e,t)=>{const{__scopeSelect:r,nonce:n,...o}=e,s=_n(fl,r),i=ul(fl,r),a=Ze(t,s.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(fi.Slot,{scope:r,children:c.jsx(Be.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Me(o.onScroll,u=>{const l=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:p}=i;if(p?.current&&f){const m=Math.abs(d.current-l.scrollTop);if(m>0){const g=window.innerHeight-Hr*2,h=parseFloat(f.style.minHeight),y=parseFloat(f.style.height),v=Math.max(h,y);if(v<g){const w=v+m,x=Math.min(g,w),E=w-x;f.style.height=x+"px",f.style.bottom==="0px"&&(l.scrollTop=E>0?E:0,f.style.justifyContent="flex-end")}}}d.current=l.scrollTop})})})]})});Nf.displayName=fl;var _f="SelectGroup",[Ix,Mx]=fo(_f),Lx=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=on();return c.jsx(Ix,{scope:r,id:o,children:c.jsx(Be.div,{role:"group","aria-labelledby":o,...n,ref:t})})});Lx.displayName=_f;var kf="SelectLabel",Dx=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=Mx(kf,r);return c.jsx(Be.div,{id:o.id,...n,ref:t})});Dx.displayName=kf;var hi="SelectItem",[Bx,Tf]=fo(hi),Ff=b.forwardRef((e,t)=>{const{__scopeSelect:r,value:n,disabled:o=!1,textValue:s,...i}=e,a=Nn(hi,r),d=_n(hi,r),u=a.value===n,[l,f]=b.useState(s??""),[p,m]=b.useState(!1),g=Ze(t,w=>d.itemRefCallback?.(w,n,o)),h=on(),y=b.useRef("touch"),v=()=>{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(Bx,{scope:r,value:n,disabled:o,textId:h,isSelected:u,onItemTextChange:b.useCallback(w=>{f(x=>x||(w?.textContent??"").trim())},[]),children:c.jsx(fi.ItemSlot,{scope:r,value:n,disabled:o,textValue:l,children:c.jsx(Be.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,...i,ref:g,onFocus:Me(i.onFocus,()=>m(!0)),onBlur:Me(i.onBlur,()=>m(!1)),onClick:Me(i.onClick,()=>{y.current!=="mouse"&&v()}),onPointerUp:Me(i.onPointerUp,()=>{y.current==="mouse"&&v()}),onPointerDown:Me(i.onPointerDown,w=>{y.current=w.pointerType}),onPointerMove:Me(i.onPointerMove,w=>{y.current=w.pointerType,o?d.onItemLeave?.():y.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Me(i.onPointerLeave,w=>{w.currentTarget===document.activeElement&&d.onItemLeave?.()}),onKeyDown:Me(i.onKeyDown,w=>{d.searchRef?.current!==""&&w.key===" "||(Sx.includes(w.key)&&v(),w.key===" "&&w.preventDefault())})})})})});Ff.displayName=hi;var Zo="SelectItemText",Pf=b.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,style:o,...s}=e,i=Nn(Zo,r),a=_n(Zo,r),d=Tf(Zo,r),u=Ex(Zo,r),[l,f]=b.useState(null),p=Ze(t,v=>f(v),d.onItemTextChange,v=>a.itemTextRefCallback?.(v,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 Qt(()=>(h(g),()=>y(g)),[h,y,g]),c.jsxs(c.Fragment,{children:[c.jsx(Be.span,{id:d.textId,...s,ref:p}),d.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Es.createPortal(s.children,i.valueNode):null]})});Pf.displayName=Zo;var Of="SelectItemIndicator",If=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return Tf(Of,r).isSelected?c.jsx(Be.span,{"aria-hidden":!0,...n,ref:t}):null});If.displayName=Of;var pl="SelectScrollUpButton",Mf=b.forwardRef((e,t)=>{const r=_n(pl,e.__scopeSelect),n=ul(pl,e.__scopeSelect),[o,s]=b.useState(!1),i=Ze(t,n.onScrollButtonChange);return Qt(()=>{if(r.viewport&&r.isPositioned){let a=function(){const u=d.scrollTop>0;s(u)};const d=r.viewport;return a(),d.addEventListener("scroll",a),()=>d.removeEventListener("scroll",a)}},[r.viewport,r.isPositioned]),o?c.jsx(Df,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:d}=r;a&&d&&(a.scrollTop=a.scrollTop-d.offsetHeight)}}):null});Mf.displayName=pl;var ml="SelectScrollDownButton",Lf=b.forwardRef((e,t)=>{const r=_n(ml,e.__scopeSelect),n=ul(ml,e.__scopeSelect),[o,s]=b.useState(!1),i=Ze(t,n.onScrollButtonChange);return Qt(()=>{if(r.viewport&&r.isPositioned){let a=function(){const u=d.scrollHeight-d.clientHeight,l=Math.ceil(d.scrollTop)<u;s(l)};const d=r.viewport;return a(),d.addEventListener("scroll",a),()=>d.removeEventListener("scroll",a)}},[r.viewport,r.isPositioned]),o?c.jsx(Df,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:d}=r;a&&d&&(a.scrollTop=a.scrollTop+d.offsetHeight)}}):null});Lf.displayName=ml;var Df=b.forwardRef((e,t)=>{const{__scopeSelect:r,onAutoScroll:n,...o}=e,s=_n("SelectScrollButton",r),i=b.useRef(null),a=pi(r),d=b.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return b.useEffect(()=>()=>d(),[d]),Qt(()=>{a().find(l=>l.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[a]),c.jsx(Be.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:Me(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(n,50))}),onPointerMove:Me(o.onPointerMove,()=>{s.onItemLeave?.(),i.current===null&&(i.current=window.setInterval(n,50))}),onPointerLeave:Me(o.onPointerLeave,()=>{d()})})}),$x="SelectSeparator",jx=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return c.jsx(Be.div,{"aria-hidden":!0,...n,ref:t})});jx.displayName=$x;var hl="SelectArrow",zx=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=mi(r),s=Nn(hl,r),i=_n(hl,r);return s.open&&i.position==="popper"?c.jsx(Zu,{...o,...n,ref:t}):null});zx.displayName=hl;var Ux="SelectBubbleInput",Bf=b.forwardRef(({__scopeSelect:e,value:t,...r},n)=>{const o=b.useRef(null),s=Ze(n,o),i=Qo(t);return b.useEffect(()=>{const a=o.current;if(!a)return;const d=window.HTMLSelectElement.prototype,l=Object.getOwnPropertyDescriptor(d,"value").set;if(i!==t&&l){const f=new Event("change",{bubbles:!0});l.call(a,t),a.dispatchEvent(f)}},[i,t]),c.jsx(Be.select,{...r,style:{...ef,...r.style},ref:s,defaultValue:t})});Bf.displayName=Ux;function $f(e){return e===""||e===void 0}function jf(e){const t=ar(e),r=b.useRef(""),n=b.useRef(0),o=b.useCallback(i=>{const a=r.current+i;t(a),(function d(u){r.current=u,window.clearTimeout(n.current),u!==""&&(n.current=window.setTimeout(()=>d(""),1e3))})(a)},[t]),s=b.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,o,s]}function zf(e,t,r){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=r?e.indexOf(r):-1;let i=Vx(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==r));const d=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return d!==r?d:void 0}function Vx(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var Hx=hf,Wx=yf,Rx=vf,Gx=wf,Kx=Sf,qx=xf,Yx=Nf,Xx=Ff,Jx=Pf,Qx=If,Zx=Mf,e0=Lf;function t0({...e}){return c.jsx(Hx,{"data-slot":"select",...e})}function r0({className:e,...t}){return c.jsx(Rx,{"data-slot":"select-value",className:B("truncate min-w-0",e),...t})}function n0({className:e,size:t="default",children:r,...n}){const o=e?.includes("w-full");return c.jsxs(Wx,{"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(Gx,{asChild:!0,children:c.jsx(Wo,{className:"size-4 opacity-50"})})]})}function o0({className:e,children:t,position:r="popper",...n}){return c.jsx(Kx,{children:c.jsxs(qx,{"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(s0,{}),c.jsx(Yx,{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(i0,{})]})})}function gl({className:e,children:t,...r}){return c.jsxs(Xx,{"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(Qx,{children:c.jsx(Vs,{className:"size-4"})})}),c.jsx(Jx,{className:"truncate",children:t})]})}function s0({className:e,...t}){return c.jsx(Zx,{"data-slot":"select-scroll-up-button",className:B("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(Nv,{className:"size-4"})})}function i0({className:e,...t}){return c.jsx(e0,{"data-slot":"select-scroll-down-button",className:B("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(Wo,{className:"size-4"})})}function Uf(e,t){return function(){return e.apply(t,arguments)}}const{toString:a0}=Object.prototype,{getPrototypeOf:yl}=Object,{iterator:gi,toStringTag:Vf}=Symbol,yi=(e=>t=>{const r=a0.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),Wr=e=>(e=e.toLowerCase(),t=>yi(t)===e),bi=e=>t=>typeof t===e,{isArray:po}=Array,mo=bi("undefined");function es(e){return e!==null&&!mo(e)&&e.constructor!==null&&!mo(e.constructor)&&pr(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Hf=Wr("ArrayBuffer");function l0(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Hf(e.buffer),t}const c0=bi("string"),pr=bi("function"),Wf=bi("number"),ts=e=>e!==null&&typeof e=="object",d0=e=>e===!0||e===!1,vi=e=>{if(yi(e)!=="object")return!1;const t=yl(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Vf in e)&&!(gi in e)},u0=e=>{if(!ts(e)||es(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},f0=Wr("Date"),p0=Wr("File"),m0=e=>!!(e&&typeof e.uri<"u"),h0=e=>e&&typeof e.getParts<"u",g0=Wr("Blob"),y0=Wr("FileList"),b0=e=>ts(e)&&pr(e.pipe);function v0(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const Rf=v0(),Gf=typeof Rf.FormData<"u"?Rf.FormData:void 0,w0=e=>{let t;return e&&(Gf&&e instanceof Gf||pr(e.append)&&((t=yi(e))==="formdata"||t==="object"&&pr(e.toString)&&e.toString()==="[object FormData]"))},S0=Wr("URLSearchParams"),[x0,A0,C0,E0]=["ReadableStream","Request","Response","Headers"].map(Wr),N0=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function rs(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,o;if(typeof e!="object"&&(e=[e]),po(e))for(n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else{if(es(e))return;const s=r?Object.getOwnPropertyNames(e):Object.keys(e),i=s.length;let a;for(n=0;n<i;n++)a=s[n],t.call(null,e[a],a,e)}}function Kf(e,t){if(es(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 Vn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,qf=e=>!mo(e)&&e!==Vn;function bl(){const{caseless:e,skipUndefined:t}=qf(this)&&this||{},r={},n=(o,s)=>{if(s==="__proto__"||s==="constructor"||s==="prototype")return;const i=e&&Kf(r,s)||s;vi(r[i])&&vi(o)?r[i]=bl(r[i],o):vi(o)?r[i]=bl({},o):po(o)?r[i]=o.slice():(!t||!mo(o))&&(r[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&rs(arguments[o],n);return r}const _0=(e,t,r,{allOwnKeys:n}={})=>(rs(t,(o,s)=>{r&&pr(o)?Object.defineProperty(e,s,{value:Uf(o,r),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,s,{value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:n}),e),k0=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),T0=(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)},F0=(e,t,r,n)=>{let o,s,i;const a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)i=o[s],(!n||n(i,e,t))&&!a[i]&&(t[i]=e[i],a[i]=!0);e=r!==!1&&yl(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},P0=(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},O0=e=>{if(!e)return null;if(po(e))return e;let t=e.length;if(!Wf(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},I0=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&yl(Uint8Array)),M0=(e,t)=>{const n=(e&&e[gi]).call(e);let o;for(;(o=n.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},L0=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},D0=Wr("HTMLFormElement"),B0=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,o){return n.toUpperCase()+o}),Yf=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),$0=Wr("RegExp"),Xf=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};rs(r,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(n[s]=i||o)}),Object.defineProperties(e,n)},j0=e=>{Xf(e,(t,r)=>{if(pr(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=e[r];if(pr(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+"'")})}})},z0=(e,t)=>{const r={},n=o=>{o.forEach(s=>{r[s]=!0})};return po(e)?n(e):n(String(e).split(t)),r},U0=()=>{},V0=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function H0(e){return!!(e&&pr(e.append)&&e[Vf]==="FormData"&&e[gi])}const W0=e=>{const t=new Array(10),r=(n,o)=>{if(ts(n)){if(t.indexOf(n)>=0)return;if(es(n))return n;if(!("toJSON"in n)){t[o]=n;const s=po(n)?[]:{};return rs(n,(i,a)=>{const d=r(i,o+1);!mo(d)&&(s[a]=d)}),t[o]=void 0,s}}return n};return r(e,0)},R0=Wr("AsyncFunction"),G0=e=>e&&(ts(e)||pr(e))&&pr(e.then)&&pr(e.catch),Jf=((e,t)=>e?setImmediate:t?((r,n)=>(Vn.addEventListener("message",({source:o,data:s})=>{o===Vn&&s===r&&n.length&&n.shift()()},!1),o=>{n.push(o),Vn.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",pr(Vn.postMessage)),K0=typeof queueMicrotask<"u"?queueMicrotask.bind(Vn):typeof process<"u"&&process.nextTick||Jf,R={isArray:po,isArrayBuffer:Hf,isBuffer:es,isFormData:w0,isArrayBufferView:l0,isString:c0,isNumber:Wf,isBoolean:d0,isObject:ts,isPlainObject:vi,isEmptyObject:u0,isReadableStream:x0,isRequest:A0,isResponse:C0,isHeaders:E0,isUndefined:mo,isDate:f0,isFile:p0,isReactNativeBlob:m0,isReactNative:h0,isBlob:g0,isRegExp:$0,isFunction:pr,isStream:b0,isURLSearchParams:S0,isTypedArray:I0,isFileList:y0,forEach:rs,merge:bl,extend:_0,trim:N0,stripBOM:k0,inherits:T0,toFlatObject:F0,kindOf:yi,kindOfTest:Wr,endsWith:P0,toArray:O0,forEachEntry:M0,matchAll:L0,isHTMLForm:D0,hasOwnProperty:Yf,hasOwnProp:Yf,reduceDescriptors:Xf,freezeMethods:j0,toObjectSet:z0,toCamelCase:B0,noop:U0,toFiniteNumber:V0,findKey:Kf,global:Vn,isContextDefined:qf,isSpecCompliantForm:H0,toJSONObject:W0,isAsyncFn:R0,isThenable:G0,setImmediate:Jf,asap:K0,isIterable:e=>e!=null&&pr(e[gi])};let qe=class Ty extends Error{static from(t,r,n,o,s,i){const a=new Ty(t.message,r||t.code,n,o,s);return a.cause=t,a.name=t.name,t.status!=null&&a.status==null&&(a.status=t.status),i&&Object.assign(a,i),a}constructor(t,r,n,o,s){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),s&&(this.response=s,this.status=s.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}}};qe.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",qe.ERR_BAD_OPTION="ERR_BAD_OPTION",qe.ECONNABORTED="ECONNABORTED",qe.ETIMEDOUT="ETIMEDOUT",qe.ERR_NETWORK="ERR_NETWORK",qe.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",qe.ERR_DEPRECATED="ERR_DEPRECATED",qe.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",qe.ERR_BAD_REQUEST="ERR_BAD_REQUEST",qe.ERR_CANCELED="ERR_CANCELED",qe.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",qe.ERR_INVALID_URL="ERR_INVALID_URL";const q0=null;function vl(e){return R.isPlainObject(e)||R.isArray(e)}function Qf(e){return R.endsWith(e,"[]")?e.slice(0,-2):e}function wl(e,t,r){return e?e.concat(t).map(function(o,s){return o=Qf(o),!r&&s?"["+o+"]":o}).join(r?".":""):t}function Y0(e){return R.isArray(e)&&!e.some(vl)}const X0=R.toFlatObject(R,{},null,function(t){return/^is[A-Z]/.test(t)});function wi(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,s=r.dots,i=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 qe("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 v=g;if(R.isReactNative(t)&&R.isReactNativeBlob(g))return t.append(wl(y,h,s),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)&&Y0(g)||(R.isFileList(g)||R.endsWith(h,"[]"))&&(v=R.toArray(g)))return h=Qf(h),v.forEach(function(x,E){!(R.isUndefined(x)||x===null)&&t.append(i===!0?wl([h],E,s):i===null?h:h+"[]",u(x))}),!1}return vl(g)?!0:(t.append(wl(y,h,s),u(g)),!1)}const f=[],p=Object.assign(X0,{defaultVisitor:l,convertValue:u,isVisitable:vl});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(v,w){(!(R.isUndefined(v)||v===null)&&o.call(t,v,R.isString(w)?w.trim():w,h,p))===!0&&m(v,h?h.concat(w):[w])}),f.pop()}}if(!R.isObject(e))throw new TypeError("data must be an object");return m(e),t}function Zf(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function Sl(e,t){this._pairs=[],e&&wi(e,this,t)}const ep=Sl.prototype;ep.append=function(t,r){this._pairs.push([t,r])},ep.toString=function(t){const r=t?function(n){return t.call(this,n,Zf)}:Zf;return this._pairs.map(function(o){return r(o[0])+"="+r(o[1])},"").join("&")};function J0(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function tp(e,t,r){if(!t)return e;const n=r&&r.encode||J0,o=R.isFunction(r)?{serialize:r}:r,s=o&&o.serialize;let i;if(s?i=s(t,o):i=R.isURLSearchParams(t)?t.toString():new Sl(t,o).toString(n),i){const a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class rp{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 xl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},Q0={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Sl,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Al=typeof window<"u"&&typeof document<"u",Cl=typeof navigator=="object"&&navigator||void 0,Z0=Al&&(!Cl||["ReactNative","NativeScript","NS"].indexOf(Cl.product)<0),eA=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",tA=Al&&window.location.href||"http://localhost",nr={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Al,hasStandardBrowserEnv:Z0,hasStandardBrowserWebWorkerEnv:eA,navigator:Cl,origin:tA},Symbol.toStringTag,{value:"Module"})),...Q0};function rA(e,t){return wi(e,new nr.classes.URLSearchParams,{visitor:function(r,n,o,s){return nr.isNode&&R.isBuffer(r)?(this.append(n,r.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function nA(e){return R.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function oA(e){const t={},r=Object.keys(e);let n;const o=r.length;let s;for(n=0;n<o;n++)s=r[n],t[s]=e[s];return t}function np(e){function t(r,n,o,s){let i=r[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),d=s>=r.length;return i=!i&&R.isArray(o)?o.length:i,d?(R.hasOwnProp(o,i)?o[i]=[o[i],n]:o[i]=n,!a):((!o[i]||!R.isObject(o[i]))&&(o[i]=[]),t(r,n,o[i],s)&&R.isArray(o[i])&&(o[i]=oA(o[i])),!a)}if(R.isFormData(e)&&R.isFunction(e.entries)){const r={};return R.forEachEntry(e,(n,o)=>{t(nA(n),o,r,0)}),r}return null}function sA(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 ns={transitional:xl,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){const n=r.getContentType()||"",o=n.indexOf("application/json")>-1,s=R.isObject(t);if(s&&R.isHTMLForm(t)&&(t=new FormData(t)),R.isFormData(t))return o?JSON.stringify(np(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(s){if(n.indexOf("application/x-www-form-urlencoded")>-1)return rA(t,this.formSerializer).toString();if((a=R.isFileList(t))||n.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return wi(a?{"files[]":t}:t,d&&new d,this.formSerializer)}}return s||o?(r.setContentType("application/json",!1),sA(t)):t}],transformResponse:[function(t){const r=this.transitional||ns.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 i=!(r&&r.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?qe.from(a,qe.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:nr.classes.FormData,Blob:nr.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=>{ns.headers[e]={}});const iA=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"]),aA=e=>{const t={};let r,n,o;return e&&e.split(`
|
|
42
|
+
`).forEach(function(i){o=i.indexOf(":"),r=i.substring(0,o).trim().toLowerCase(),n=i.substring(o+1).trim(),!(!r||t[r]&&iA[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t},op=Symbol("internals");function os(e){return e&&String(e).trim().toLowerCase()}function Si(e){return e===!1||e==null?e:R.isArray(e)?e.map(Si):String(e).replace(/[\r\n]+$/,"")}function lA(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 El(e,t,r,n,o){if(R.isFunction(n))return n.call(this,t,r);if(o&&(t=r),!!R.isString(t)){if(R.isString(n))return t.indexOf(n)!==-1;if(R.isRegExp(n))return n.test(t)}}function dA(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function uA(e,t){const r=R.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(o,s,i){return this[n].call(this,t,o,s,i)},configurable:!0})})}let mr=class{constructor(t){t&&this.set(t)}set(t,r,n){const o=this;function s(a,d,u){const l=os(d);if(!l)throw new Error("header name must be a non-empty string");const f=R.findKey(o,l);(!f||o[f]===void 0||u===!0||u===void 0&&o[f]!==!1)&&(o[f||d]=Si(a))}const i=(a,d)=>R.forEach(a,(u,l)=>s(u,l,d));if(R.isPlainObject(t)||t instanceof this.constructor)i(t,r);else if(R.isString(t)&&(t=t.trim())&&!cA(t))i(aA(t),r);else if(R.isObject(t)&&R.isIterable(t)){let a={},d,u;for(const l of t){if(!R.isArray(l))throw TypeError("Object iterator must return a key-value pair");a[u=l[0]]=(d=a[u])?R.isArray(d)?[...d,l[1]]:[d,l[1]]:l[1]}i(a,r)}else t!=null&&s(r,t,n);return this}get(t,r){if(t=os(t),t){const n=R.findKey(this,t);if(n){const o=this[n];if(!r)return o;if(r===!0)return lA(o);if(R.isFunction(r))return r.call(this,o,n);if(R.isRegExp(r))return r.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=os(t),t){const n=R.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||El(this,this[n],n,r)))}return!1}delete(t,r){const n=this;let o=!1;function s(i){if(i=os(i),i){const a=R.findKey(n,i);a&&(!r||El(n,n[a],a,r))&&(delete n[a],o=!0)}}return R.isArray(t)?t.forEach(s):s(t),o}clear(t){const r=Object.keys(this);let n=r.length,o=!1;for(;n--;){const s=r[n];(!t||El(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const r=this,n={};return R.forEach(this,(o,s)=>{const i=R.findKey(n,s);if(i){r[i]=Si(o),delete r[s];return}const a=t?dA(s):String(s).trim();a!==s&&delete r[s],r[a]=Si(o),n[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return R.forEach(this,(n,o)=>{n!=null&&n!==!1&&(r[o]=t&&R.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[op]=this[op]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=os(i);n[a]||(uA(o,i),n[a]=!0)}return R.isArray(t)?t.forEach(s):s(t),this}};mr.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),R.reduceDescriptors(mr.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}}),R.freezeMethods(mr);function Nl(e,t){const r=this||ns,n=t||r,o=mr.from(n.headers);let s=n.data;return R.forEach(e,function(a){s=a.call(r,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function sp(e){return!!(e&&e.__CANCEL__)}let ss=class extends qe{constructor(t,r,n){super(t??"canceled",qe.ERR_CANCELED,r,n),this.name="CanceledError",this.__CANCEL__=!0}};function ip(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new qe("Request failed with status code "+r.status,[qe.ERR_BAD_REQUEST,qe.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function fA(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function pA(e,t){e=e||10;const r=new Array(e),n=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(d){const u=Date.now(),l=n[s];i||(i=u),r[o]=d,n[o]=u;let f=s,p=0;for(;f!==o;)p+=r[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),u-i<t)return;const m=l&&u-l;return m?Math.round(p*1e3/m):void 0}}function mA(e,t){let r=0,n=1e3/t,o,s;const i=(u,l=Date.now())=>{r=l,o=null,s&&(clearTimeout(s),s=null),e(...u)};return[(...u)=>{const l=Date.now(),f=l-r;f>=n?i(u,l):(o=u,s||(s=setTimeout(()=>{s=null,i(o)},n-f)))},()=>o&&i(o)]}const xi=(e,t,r=3)=>{let n=0;const o=pA(50,250);return mA(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,d=i-n,u=o(d),l=i<=a;n=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:d,rate:u||void 0,estimated:u&&a&&l?(a-i)/u:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},r)},ap=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},lp=e=>(...t)=>R.asap(()=>e(...t)),hA=nr.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,nr.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(nr.origin),nr.navigator&&/(msie|trident)/i.test(nr.navigator.userAgent)):()=>!0,gA=nr.hasStandardBrowserEnv?{write(e,t,r,n,o,s,i){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}`),s===!0&&a.push("secure"),R.isString(i)&&a.push(`SameSite=${i}`),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 yA(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function bA(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function cp(e,t,r){let n=!yA(t);return e&&(n||r==!1)?bA(e,t):t}const dp=e=>e instanceof mr?{...e}:e;function Hn(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 s(u,l){if(!R.isUndefined(l))return n(void 0,l)}function i(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:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(u,l,f)=>o(dp(u),dp(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 up=e=>{const t=Hn({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=mr.from(i),t.url=tp(cp(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),R.isFormData(r)){if(nr.hasStandardBrowserEnv||nr.hasStandardBrowserWebWorkerEnv)i.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())&&i.set(l,f)})}}if(nr.hasStandardBrowserEnv&&(n&&R.isFunction(n)&&(n=n(t)),n||n!==!1&&hA(t.url))){const d=o&&s&&gA.read(s);d&&i.set(o,d)}return t},vA=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(r,n){const o=up(e);let s=o.data;const i=mr.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 v(){if(!y)return;const x=mr.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};ip(function(N){r(N),h()},function(N){n(N),h()},P),y=null}"onloadend"in y?y.onloadend=v:y.onreadystatechange=function(){!y||y.readyState!==4||y.status===0&&!(y.responseURL&&y.responseURL.indexOf("file:")===0)||setTimeout(v)},y.onabort=function(){y&&(n(new qe("Request aborted",qe.ECONNABORTED,e,y)),y=null)},y.onerror=function(E){const P=E&&E.message?E.message:"Network Error",C=new qe(P,qe.ERR_NETWORK,e,y);C.event=E||null,n(C),y=null},y.ontimeout=function(){let E=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const P=o.transitional||xl;o.timeoutErrorMessage&&(E=o.timeoutErrorMessage),n(new qe(E,P.clarifyTimeoutError?qe.ETIMEDOUT:qe.ECONNABORTED,e,y)),y=null},s===void 0&&i.setContentType(null),"setRequestHeader"in y&&R.forEach(i.toJSON(),function(E,P){y.setRequestHeader(P,E)}),R.isUndefined(o.withCredentials)||(y.withCredentials=!!o.withCredentials),a&&a!=="json"&&(y.responseType=o.responseType),u&&([p,g]=xi(u,!0),y.addEventListener("progress",p)),d&&y.upload&&([f,m]=xi(d),y.upload.addEventListener("progress",f),y.upload.addEventListener("loadend",m)),(o.cancelToken||o.signal)&&(l=x=>{y&&(n(!x||x.type?new ss(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 w=fA(o.url);if(w&&nr.protocols.indexOf(w)===-1){n(new qe("Unsupported protocol "+w+":",qe.ERR_BAD_REQUEST,e));return}y.send(s||null)})},wA=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,o;const s=function(u){if(!o){o=!0,a();const l=u instanceof Error?u:this.reason;n.abort(l instanceof qe?l:new ss(l instanceof Error?l.message:l))}};let i=t&&setTimeout(()=>{i=null,s(new qe(`timeout of ${t}ms exceeded`,qe.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(s):u.removeEventListener("abort",s)}),e=null)};e.forEach(u=>u.addEventListener("abort",s));const{signal:d}=n;return d.unsubscribe=()=>R.asap(a),d}},SA=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},xA=async function*(e,t){for await(const r of AA(e))yield*SA(r,t)},AA=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()}},fp=(e,t,r,n)=>{const o=xA(e,t);let s=0,i,a=d=>{i||(i=!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=s+=f;r(p)}d.enqueue(new Uint8Array(l))}catch(u){throw a(u),u}},cancel(d){return a(d),o.return()}},{highWaterMark:2})},pp=64*1024,{isFunction:Ai}=R,CA=(({Request:e,Response:t})=>({Request:e,Response:t}))(R.global),{ReadableStream:mp,TextEncoder:hp}=R.global,gp=(e,...t)=>{try{return!!e(...t)}catch{return!1}},EA=e=>{e=R.merge.call({skipUndefined:!0},CA,e);const{fetch:t,Request:r,Response:n}=e,o=t?Ai(t):typeof fetch=="function",s=Ai(r),i=Ai(n);if(!o)return!1;const a=o&&Ai(mp),d=o&&(typeof hp=="function"?(g=>h=>g.encode(h))(new hp):async g=>new Uint8Array(await new r(g).arrayBuffer())),u=s&&a&&gp(()=>{let g=!1;const h=new mp,y=new r(nr.origin,{body:h,method:"POST",get duplex(){return g=!0,"half"}}).headers.has("Content-Type");return h.cancel(),g&&!y}),l=i&&a&&gp(()=>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 v=h&&h[g];if(v)return v.call(h);throw new qe(`Response type '${g}' is not supported`,qe.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(nr.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:v,signal:w,cancelToken:x,timeout:E,onDownloadProgress:P,onUploadProgress:C,responseType:N,headers:_,withCredentials:A="same-origin",fetchOptions:I}=up(g),T=t||fetch;N=N?(N+"").toLowerCase():"text";let W=wA([w,x&&x.toAbortSignal()],E),J=null;const O=W&&W.unsubscribe&&(()=>{W.unsubscribe()});let j;try{if(C&&u&&y!=="get"&&y!=="head"&&(j=await m(_,v))!==0){let ie=new r(h,{method:"POST",body:v,duplex:"half"}),V;if(R.isFormData(v)&&(V=ie.headers.get("content-type"))&&_.setContentType(V),ie.body){const[K,X]=ap(j,xi(lp(C)));v=fp(ie.body,pp,K,X)}}R.isString(A)||(A=A?"include":"omit");const M=s&&"credentials"in r.prototype,D={...I,signal:W,method:y.toUpperCase(),headers:_.normalize().toJSON(),body:v,duplex:"half",credentials:M?A:void 0};J=s&&new r(h,D);let L=await(s?T(J,I):T(h,D));const U=l&&(N==="stream"||N==="response");if(l&&(P||U&&O)){const ie={};["status","statusText","headers"].forEach(ce=>{ie[ce]=L[ce]});const V=R.toFiniteNumber(L.headers.get("content-length")),[K,X]=P&&ap(V,xi(lp(P),!0))||[];L=new n(fp(L.body,pp,K,()=>{X&&X(),O&&O()}),ie)}N=N||"text";let $=await f[R.findKey(f,N)||"text"](L,g);return!U&&O&&O(),await new Promise((ie,V)=>{ip(ie,V,{data:$,headers:mr.from(L.headers),status:L.status,statusText:L.statusText,config:g,request:J})})}catch(M){throw O&&O(),M&&M.name==="TypeError"&&/Load failed|fetch/i.test(M.message)?Object.assign(new qe("Network Error",qe.ERR_NETWORK,g,J,M&&M.response),{cause:M.cause||M}):qe.from(M,M&&M.code,g,J,M&&M.response)}}},NA=new Map,yp=e=>{let t=e&&e.env||{};const{fetch:r,Request:n,Response:o}=t,s=[n,o,r];let i=s.length,a=i,d,u,l=NA;for(;a--;)d=s[a],u=l.get(d),u===void 0&&l.set(d,u=a?new Map:EA(t)),l=u;return u};yp();const _l={http:q0,xhr:vA,fetch:{get:yp}};R.forEach(_l,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const bp=e=>`- ${e}`,_A=e=>R.isFunction(e)||e===null||e===!1;function kA(e,t){e=R.isArray(e)?e:[e];const{length:r}=e;let n,o;const s={};for(let i=0;i<r;i++){n=e[i];let a;if(o=n,!_A(n)&&(o=_l[(a=String(n)).toLowerCase()],o===void 0))throw new qe(`Unknown adapter '${a}'`);if(o&&(R.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([d,u])=>`adapter ${d} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=r?i.length>1?`since :
|
|
44
|
+
`+i.map(bp).join(`
|
|
45
|
+
`):" "+bp(i[0]):"as no adapter specified";throw new qe("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o}const vp={getAdapter:kA,adapters:_l};function kl(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new ss(null,e)}function wp(e){return kl(e),e.headers=mr.from(e.headers),e.data=Nl.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),vp.getAdapter(e.adapter||ns.adapter,e)(e).then(function(n){return kl(e),n.data=Nl.call(e,e.transformResponse,n),n.headers=mr.from(n.headers),n},function(n){return sp(n)||(kl(e),n&&n.response&&(n.response.data=Nl.call(e,e.transformResponse,n.response),n.response.headers=mr.from(n.response.headers))),Promise.reject(n)})}const Sp="1.14.0",Ci={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ci[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const xp={};Ci.transitional=function(t,r,n){function o(s,i){return"[Axios v"+Sp+"] Transitional option '"+s+"'"+i+(n?". "+n:"")}return(s,i,a)=>{if(t===!1)throw new qe(o(i," has been removed"+(r?" in "+r:"")),qe.ERR_DEPRECATED);return r&&!xp[i]&&(xp[i]=!0,console.warn(o(i," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(s,i,a):!0}},Ci.spelling=function(t){return(r,n)=>(console.warn(`${n} is likely a misspelling of ${t}`),!0)};function TA(e,t,r){if(typeof e!="object")throw new qe("options must be an object",qe.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let o=n.length;for(;o-- >0;){const s=n[o],i=t[s];if(i){const a=e[s],d=a===void 0||i(a,s,e);if(d!==!0)throw new qe("option "+s+" must be "+d,qe.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new qe("Unknown option "+s,qe.ERR_BAD_OPTION)}}const Ei={assertOptions:TA,validators:Ci},Or=Ei.validators;let Wn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new rp,response:new rp}}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 s=o.stack?o.stack.replace(/^.+\n/,""):"";try{n.stack?s&&!String(n.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(n.stack+=`
|
|
46
|
+
`+s):n.stack=s}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=Hn(this.defaults,r);const{transitional:n,paramsSerializer:o,headers:s}=r;n!==void 0&&Ei.assertOptions(n,{silentJSONParsing:Or.transitional(Or.boolean),forcedJSONParsing:Or.transitional(Or.boolean),clarifyTimeoutError:Or.transitional(Or.boolean),legacyInterceptorReqResOrdering:Or.transitional(Or.boolean)},!1),o!=null&&(R.isFunction(o)?r.paramsSerializer={serialize:o}:Ei.assertOptions(o,{encode:Or.function,serialize:Or.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),Ei.assertOptions(r,{baseUrl:Or.spelling("baseURL"),withXsrfToken:Or.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let i=s&&R.merge(s.common,s[r.method]);s&&R.forEach(["delete","get","head","post","put","patch","common"],g=>{delete s[g]}),r.headers=mr.concat(i,s);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||xl;y&&y.legacyInterceptorReqResOrdering?a.unshift(h.fulfilled,h.rejected):a.push(h.fulfilled,h.rejected)});const u=[];this.interceptors.response.forEach(function(h){u.push(h.fulfilled,h.rejected)});let l,f=0,p;if(!d){const g=[wp.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=wp.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=Hn(this.defaults,t);const r=cp(t.baseURL,t.url,t.allowAbsoluteUrls);return tp(r,t.params,t.paramsSerializer)}};R.forEach(["delete","get","head","options"],function(t){Wn.prototype[t]=function(r,n){return this.request(Hn(n||{},{method:t,url:r,data:(n||{}).data}))}}),R.forEach(["post","put","patch"],function(t){function r(n){return function(s,i,a){return this.request(Hn(a||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Wn.prototype[t]=r(),Wn.prototype[t+"Form"]=r(!0)});let FA=class Fy{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(s){r=s});const n=this;this.promise.then(o=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](o);n._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(a=>{n.subscribe(a),s=a}).then(o);return i.cancel=function(){n.unsubscribe(s)},i},t(function(s,i,a){n.reason||(n.reason=new ss(s,i,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 Fy(function(o){t=o}),cancel:t}}};function PA(e){return function(r){return e.apply(null,r)}}function OA(e){return R.isObject(e)&&e.isAxiosError===!0}const Tl={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Tl).forEach(([e,t])=>{Tl[t]=e});function Ap(e){const t=new Wn(e),r=Uf(Wn.prototype.request,t);return R.extend(r,Wn.prototype,t,{allOwnKeys:!0}),R.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return Ap(Hn(e,o))},r}const _t=Ap(ns);_t.Axios=Wn,_t.CanceledError=ss,_t.CancelToken=FA,_t.isCancel=sp,_t.VERSION=Sp,_t.toFormData=wi,_t.AxiosError=qe,_t.Cancel=_t.CanceledError,_t.all=function(t){return Promise.all(t)},_t.spread=PA,_t.isAxiosError=OA,_t.mergeConfig=Hn,_t.AxiosHeaders=mr,_t.formToJSON=e=>np(R.isHTMLForm(e)?new FormData(e):e),_t.getAdapter=vp.getAdapter,_t.HttpStatusCode=Tl,_t.default=_t;const{Axios:LP,AxiosError:IA,CanceledError:DP,isCancel:BP,CancelToken:$P,VERSION:jP,all:zP,Cancel:UP,isAxiosError:VP,spread:HP,toFormData:WP,AxiosHeaders:RP,HttpStatusCode:GP,formToJSON:KP,getAdapter:qP,mergeConfig:YP}=_t;function or(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 MA(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:s}=n,i=s?`data.${s}.`:"";return{array:o,pathPrefixToStrip:i}}function LA(e){return e.length>=4&&Array.isArray(e[3])&&e[3].length===0}function DA(e,t,r){if(typeof e=="string"||typeof e=="number"||typeof e=="boolean"){const s=String(e);return{label:s,value:s,disabled:!1}}if(e==null)return{label:"",value:"",disabled:!0};if(typeof e!="object"||Array.isArray(e)){const s=Array.isArray(e)?"":String(e);return{label:s,value:s,disabled:!1}}let n,o;if(t){const s=t.includes(".")?or(e,t):e[t];n=String(s!==void 0?s: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 s=r.includes(".")?or(e,r):e[r];o=String(s!==void 0?s: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 Fl(e,t,r){if(!e)return[];if(Array.isArray(e)){if(e.length===0)return[];if(LA(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=>DA(o,t,r))}if(typeof e=="object"){const{array:n,pathPrefixToStrip:o}=MA(e);if(Array.isArray(n)&&n.length>0){const s=d=>!d||!d.trim()||!o?d:d.startsWith(o)?d.substring(o.length).replace(/^\.+/,"")||void 0:d,i=s(t),a=s(r);return Fl(n,i,a)}}return[]}function BA(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 $A(e){return Array.isArray(e)&&e.length>=4&&Array.isArray(e[3])&&e[3].length>0&&Array.isArray(e[3][0])}function jA(e,t,r){if(!e)return[];try{const o=new URL(e).searchParams.get(t);return o?o.split(r).map(s=>s.trim()).filter(Boolean):[]}catch{const n=e.indexOf("?");if(n<0)return[];const o=e.slice(n+1);try{const i=new URLSearchParams(o).get(t);return i?i.split(r).map(a=>a.trim()).filter(Boolean):[]}catch{return[]}}}function Cp(e){const{response:t,sourceUrl:r,rowsIndex:n,rowsPath:o,columns:s,columnsQueryParam:i="sf",columnsQueryParamSeparator:a=","}=e;let d;if(o&&o.trim()?d=or(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=jA(r,i,a),f=l.length>0?l:Array.isArray(s)&&s.length>0?s:[];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 zA(e){const{rows:t,apiLabelField:r,apiLabelFields:n,apiLabelSeparator:o,apiValueField:s}=e;if(!Array.isArray(t)||t.length===0)return[];const i=t.filter(f=>f!=null&&typeof f=="object"&&!Array.isArray(f));if(i.length===0)return[];const a=Array.isArray(n)?n.filter(Boolean):[],d=o??" - ",u=f=>{if(r){const p=r.includes(".")?or(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(s){const m=s.includes(".")?or(f,s):f?.[s];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 i.map(f=>{let p="";a.length>0&&(p=a.map(h=>or(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}})}let Ep=null;function UA(e){Ep=e}function Np(){return(Ep?.()??"").replace(/\/+$/,"")}function cn(e){const t=typeof e=="string"?e.trim():"";if(!t||/^https?:\/\//i.test(t))return t;const r=Np();return r?t.startsWith("/")?`${r}${t}`:`${r}/${t}`:t}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,valueSource:n.valueSource,optionsSource:n.optionsSource}:null,s=e.apidata||null,i=o||s,[a,d]=S.useState([]),[u,l]=S.useState([]),[f,p]=S.useState([]),[m,g]=S.useState(!1),[h,y]=S.useState(null),v=!!(i?.apiEndpoint&&(i?.valueSource==="api"||i?.optionsSource==="api"||n?.valueSource==="api"||n?.optionsSource==="api")),w=e.options||n?.options||[],x=S.useMemo(()=>BA(Array.isArray(w)?w:[]),[w]),E=S.useMemo(()=>{const I=i?.apiEndpoint||n?.apiEndpoint||"",T=i?.apiQueryParams||n?.apiQueryParams;return $s(I,T)},[i?.apiEndpoint,n?.apiEndpoint,i?.apiQueryParams,n?.apiQueryParams]),P=S.useMemo(()=>{const I=new Set;for(const W of n?.dependentFields??[])typeof W=="string"&&W.trim()&&I.add(W.trim());const T=i?.apiClientFilter?.matchField?.trim()||n?.apiClientFilter?.matchField?.trim();return T&&I.add(T),[...I]},[n?.dependentFields,i?.apiClientFilter?.matchField,n?.apiClientFilter?.matchField]),C=S.useMemo(()=>{const I=new Set([...E,...P]);if(I.size===0)return null;const T={};return I.forEach(W=>{T[W]=t[W]}),JSON.stringify(T)},[E,P,t]),N=S.useMemo(()=>JSON.stringify(r||{}),[r]),_=S.useMemo(()=>{const I=new Set;e.name?.trim()&&I.add(e.name.trim());const T=e.key;return typeof T=="string"&&T.trim()&&I.add(T.trim()),[...I]},[e.name,e.key]);return S.useEffect(()=>{const I=i?.apiEndpoint;if(!v||!I){d([]);return}let T=!1;return(async()=>{a.length===0&&g(!0),y(null);try{const O=i?.apiMethod||n?.apiMethod||"GET",j=i?.apiRealtime||n?.apiRealtime,M=i?.apiQueryParams||n?.apiQueryParams||{},D=zd({apiEndpoint:I,apiMethod:O,apiQueryParams:M,formValues:t,submissionContext:r,apiRealtime:j,additionalRequiredFieldNames:P,excludeFormFieldNames:_});if(D.blocked){T||(d([]),g(!1));return}const L={"Content-Type":"application/json"},U=i?.apiKey||n?.apiKey;U&&(L["X-CSCAPI-KEY"]=U);const $={method:O.toLowerCase(),url:cn(D.url),headers:L};D.postBodyBase!=null&&($.data=D.postBodyBase);const ie=await _t($),V=i?.apiLabelField||n?.apiLabelField,K=i?.apiValueField||n?.apiValueField,X=ie.data;let ce=[];Array.isArray(X)?ce=X:X?.data&&(Array.isArray(X.data)?ce=X.data:X.data?.data&&Array.isArray(X.data.data)?ce=X.data.data:X.data.districts?ce=X.data.districts:X.data.states?ce=X.data.states:X.data.cities&&(ce=X.data.cities)),p(ce);const ne=Fl(ie.data,V,K);l(ne);const G=i?.apiClientFilter||n?.apiClientFilter;let ee=ne;if(G?.filterField&&G?.matchField){const Pe=t[G.matchField];Pe!=null?ee=ne.filter(oe=>{const re=ce.find(de=>String(or(de,K||"code"))===String(oe.value));if(!re)return!1;const be=or(re,G.filterField);return String(be)===String(Pe)}):ee=[]}T||d(ee)}catch(O){if(T)return;let j="Failed to load options";if(O.response){const M=O.response.data;O.response.status===404?j="API endpoint not found.":O.response.status===401?j="Authentication failed.":typeof M=="string"?j=M:M&&typeof M=="object"&&(j=M.error||M.message||M.detail||j)}else O.message&&(j=String(O.message));y(j),a.length===0&&d([])}finally{T||g(!1)}})(),()=>{T=!0}},[v,i?.apiEndpoint,i?.apiMethod,n?.apiEndpoint,n?.apiMethod,C,P,_,N]),S.useEffect(()=>{const I=i?.apiClientFilter||n?.apiClientFilter;if(!v||!I||f.length===0)return;const T=t[I.matchField],W=i?.apiValueField||n?.apiValueField;if(T==null){d([]);return}const J=u.filter(O=>{const j=f.find(D=>String(or(D,W||"code"))===String(O.value));if(!j)return!1;const M=or(j,I.filterField);return String(M)===String(T)});d(J)},[v,i?.apiClientFilter?.matchField,n?.apiClientFilter?.matchField,i?.apiClientFilter?.filterField,n?.apiClientFilter?.filterField,i?.apiValueField,n?.apiValueField,t[i?.apiClientFilter?.matchField||n?.apiClientFilter?.matchField||""],u,f]),{options:v?a:x,isLoadingOptions:m,optionsError:h}}const kp=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,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:v,isLoadingOptions:w,optionsError:x}=_p({field:e,formValues:d,submissionContext:u}),E=l?.length?new Set(l.map(String)):null,P=E?v.filter($=>!E.has(String($.value??$.label??""))):v,C="__clear__",N=t!=null&&String(t).trim()!=="",_=N?P.some($=>String($.value??$.label??"")===String(t)):!1,A=S.useMemo(()=>{if(!N||_)return P;const $=String(t);return[{label:$,value:$},...P]},[P,N,_,t]),I=N?String(t):void 0,T=`${ht(e)}-${I??"empty"}`,W=S.useCallback($=>{r($===C?"":$),n?.()},[r,n]),J=e.appearance?.size||"md",O={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},j=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=w?"Loading options...":D?`Select ${M} first`:l?.length?"No available options":y?"No options available from API":"No options available";return y&&f&&w?c.jsx(Et,{field:e,error:o||x||void 0,isRequired:i,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",O[J],e.appearance?.className),children:[c.jsx(Ro,{className:"h-4 w-4 animate-spin shrink-0"}),c.jsx("span",{className:"truncate",children:"Loading..."})]})}):c.jsx(Et,{field:e,error:o||x||void 0,isRequired:i,className:a,children:c.jsxs(t0,{value:I,onValueChange:W,disabled:s||e.disabled||w&&P.length===0,children:[c.jsx(n0,{id:ht(e),"aria-describedby":jt(e,!!o||!!x),"aria-invalid":Jt(!!o||!!x),"aria-required":i,className:B("w-full min-w-0",O[J],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:[w&&c.jsx(Ro,{className:"h-4 w-4 animate-spin text-muted-foreground shrink-0"}),P.length===0&&l?.length&&!N?c.jsx("span",{className:"text-muted-foreground truncate",children:"No available options"}):N?c.jsx(r0,{placeholder:j}):c.jsx("span",{className:"text-muted-foreground truncate",children:j})]})}),c.jsx(o0,{children:A.length===0?c.jsx(gl,{value:"__no_options__",disabled:!0,children:L}):c.jsxs(c.Fragment,{children:[N?c.jsx(gl,{value:C,children:j}):null,A.map(($,ie)=>{const V=String($.value??$.label??ie);if(V===C)return null;const K=$.label||$.value||String($);return c.jsx(gl,{value:V,disabled:$.disabled||!1,children:K},V)})]})})]},T)})},Tp=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Fp=Jc,Pp=(e,t)=>r=>{var n;if(t?.variants==null)return Fp(e,r?.class,r?.className);const{variants:o,defaultVariants:s}=t,i=Object.keys(o).map(u=>{const l=r?.[u],f=s?.[u];if(l===null)return null;const p=Tp(l)||Tp(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({...s,...a}[h]):{...s,...a}[h]===y})?[...u,f,p]:u},[]);return Fp(e,i,d,r?.class,r?.className)},VA=Pp("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 Yt({className:e,variant:t,size:r,asChild:n=!1,...o}){const s=n?qd:"button";return c.jsx(s,{"data-slot":"button",className:B(VA({variant:t,size:r,className:e})),...o})}function HA(e,t){return b.useReducer((r,n)=>t[r][n]??r,e)}var xr=e=>{const{present:t,children:r}=e,n=WA(t),o=typeof r=="function"?r({present:n.isPresent}):b.Children.only(r),s=Ze(n.ref,RA(o));return typeof r=="function"||n.isPresent?b.cloneElement(o,{ref:s}):null};xr.displayName="Presence";function WA(e){const[t,r]=b.useState(),n=b.useRef(null),o=b.useRef(e),s=b.useRef("none"),i=e?"mounted":"unmounted",[a,d]=HA(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{const u=Ni(n.current);s.current=a==="mounted"?u:"none"},[a]),Qt(()=>{const u=n.current,l=o.current;if(l!==e){const p=s.current,m=Ni(u);e?d("MOUNT"):m==="none"||u?.display==="none"?d("UNMOUNT"):d(l&&p!==m?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,d]),Qt(()=>{if(t){let u;const l=t.ownerDocument.defaultView??window,f=m=>{const h=Ni(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&&(s.current=Ni(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 Ni(e){return e?.animationName||"none"}function RA(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 GA(e){const t=KA(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),d=a.find(YA);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,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function KA(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=JA(o),a=XA(s,o.props);return o.type!==b.Fragment&&(a.ref=n?Bn(n,i):i),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var qA=Symbol("radix.slottable");function YA(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===qA}function XA(e,t){const r={...t};for(const n in t){const o=e[n],s=t[n];/^on[A-Z]/.test(n)?o&&s?r[n]=(...a)=>{const d=s(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function JA(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 _i="Popover",[Op]=vr(_i,[ri]),is=ri(),[QA,kn]=Op(_i),Ip=e=>{const{__scopePopover:t,children:r,open:n,defaultOpen:o,onOpenChange:s,modal:i=!1}=e,a=is(t),d=b.useRef(null),[u,l]=b.useState(!1),[f,p]=Zr({prop:n,defaultProp:o??!1,onChange:s,caller:_i});return c.jsx(Ju,{...a,children:c.jsx(QA,{scope:t,contentId:on(),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:i,children:r})})};Ip.displayName=_i;var Mp="PopoverAnchor",Lp=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=kn(Mp,r),s=is(r),{onCustomAnchorAdd:i,onCustomAnchorRemove:a}=o;return b.useEffect(()=>(i(),()=>a()),[i,a]),c.jsx(nl,{...s,...n,ref:t})});Lp.displayName=Mp;var Dp="PopoverTrigger",Bp=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=kn(Dp,r),s=is(r),i=Ze(t,o.triggerRef),a=c.jsx(Be.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Vp(o.open),...n,ref:i,onClick:Me(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:c.jsx(nl,{asChild:!0,...s,children:a})});Bp.displayName=Dp;var Pl="PopoverPortal",[ZA,eC]=Op(Pl,{forceMount:void 0}),$p=e=>{const{__scopePopover:t,forceMount:r,children:n,container:o}=e,s=kn(Pl,t);return c.jsx(ZA,{scope:t,forceMount:r,children:c.jsx(xr,{present:r||s.open,children:c.jsx(ni,{asChild:!0,container:o,children:n})})})};$p.displayName=Pl;var ho="PopoverContent",jp=b.forwardRef((e,t)=>{const r=eC(ho,e.__scopePopover),{forceMount:n=r.forceMount,...o}=e,s=kn(ho,e.__scopePopover);return c.jsx(xr,{present:n||s.open,children:s.modal?c.jsx(rC,{...o,ref:t}):c.jsx(nC,{...o,ref:t})})});jp.displayName=ho;var tC=GA("PopoverContent.RemoveScroll"),rC=b.forwardRef((e,t)=>{const r=kn(ho,e.__scopePopover),n=b.useRef(null),o=Ze(t,n),s=b.useRef(!1);return b.useEffect(()=>{const i=n.current;if(i)return sl(i)},[]),c.jsx(ui,{as:tC,allowPinchZoom:!0,children:c.jsx(zp,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Me(e.onCloseAutoFocus,i=>{i.preventDefault(),s.current||r.triggerRef.current?.focus()}),onPointerDownOutside:Me(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,d=a.button===0&&a.ctrlKey===!0,u=a.button===2||d;s.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:Me(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),nC=b.forwardRef((e,t)=>{const r=kn(ho,e.__scopePopover),n=b.useRef(!1),o=b.useRef(!1);return c.jsx(zp,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{e.onCloseAutoFocus?.(s),s.defaultPrevented||(n.current||r.triggerRef.current?.focus(),s.preventDefault()),n.current=!1,o.current=!1},onInteractOutside:s=>{e.onInteractOutside?.(s),s.defaultPrevented||(n.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;r.triggerRef.current?.contains(i)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),zp=b.forwardRef((e,t)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:i,onEscapeKeyDown:a,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:l,...f}=e,p=kn(ho,r),m=is(r);return za(),c.jsx(Rs,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:s,children:c.jsx(Ws,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:l,onEscapeKeyDown:a,onPointerDownOutside:d,onFocusOutside:u,onDismiss:()=>p.onOpenChange(!1),children:c.jsx(Qu,{"data-state":Vp(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)"}})})})}),Up="PopoverClose",oC=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=kn(Up,r);return c.jsx(Be.button,{type:"button",...n,ref:t,onClick:Me(e.onClick,()=>o.onOpenChange(!1))})});oC.displayName=Up;var sC="PopoverArrow",iC=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=is(r);return c.jsx(Zu,{...o,...n,ref:t})});iC.displayName=sC;function Vp(e){return e?"open":"closed"}var aC=Ip,lC=Lp,cC=Bp,dC=$p,uC=jp;function Ol({...e}){return c.jsx(aC,{"data-slot":"popover",...e})}function Hp({...e}){return c.jsx(cC,{"data-slot":"popover-trigger",...e})}function Il({className:e,align:t="center",sideOffset:r=4,...n}){return c.jsx(dC,{children:c.jsx(uC,{"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 fC({...e}){return c.jsx(lC,{"data-slot":"popover-anchor",...e})}const Wp={};function Tn(){const e=Wp?.VITE_CLIENT_ID?.trim()||Wp?.VITE_DEFAULT_CLIENT_ID?.trim()||null;return(typeof localStorage<"u"?localStorage.getItem("clientId"):null)||(typeof sessionStorage<"u"?sessionStorage.getItem("clientId"):null)||(typeof window<"u"?new URLSearchParams(window.location.search).get("clientId"):null)||e}function pC(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 mC(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 Rn=Pd(e=>({viewerContext:void 0,authHeaders:void 0,_setViewerContext:t=>e({viewerContext:pC(t)?t:void 0}),_setAuthHeaders:t=>e({authHeaders:mC(t)}),_reset:()=>e({viewerContext:void 0,authHeaders:void 0})}));function hC(e){Rn.getState()._setViewerContext(e)}function gC(e){Rn.getState()._setAuthHeaders(e)}function yC(){Rn.getState()._reset()}function bC(){return Rn.getState().viewerContext}function Ml(){return Rn.getState().authHeaders}const Rp={};let Gp=null;function vC(e){Gp=e}function wC(){return(Rp?.VITE_API_BASE_URL?.trim()||Rp?.VITE_API_URL?.trim()||"").replace(/\/$/,"")}const dn=_t.create({baseURL:wC()});dn.interceptors.request.use(e=>{const t=Tn();t&&(e.params={...e.params,clientId:t}),typeof FormData<"u"&&e.data instanceof FormData&&delete e.headers["Content-Type"];let r=Gp?.();if((!r||Object.keys(r).length===0)&&(r=Ml()),r){const n=e.headers??{};for(const[o,s]of Object.entries(r))s!==void 0&&s!==""&&(n[o]=s);e.headers=n}return e});function Kp(e){return JSON.stringify(e).slice(1,-1)}function qp(e){const t=e.asyncSearchValueObjectKeys;return Array.isArray(t)?t.map(r=>typeof r=="string"?r.trim():"").filter(Boolean):[]}function SC(e){return e.asyncSearchValueMode==="object"&&qp(e).length>0}function xC(e,t){const r={};for(const n of t){const o=n.trim();if(!o)continue;const s=or(e,o);s==null||typeof s=="object"?r[o]="":r[o]=String(s)}return r}function AC(e,t){const r=t.mode??"debounce",n=Math.max(0,t.intervalMs??300),[o,s]=S.useState(()=>r==="throttle"?e:""),i=S.useRef(0),a=S.useRef(void 0);return S.useEffect(()=>{if(e===""){a.current&&clearTimeout(a.current),s("");return}if(r==="debounce"){const l=setTimeout(()=>s(e),n);return()=>clearTimeout(l)}const d=Date.now(),u=d-i.current;return u>=n?(i.current=d,s(e),()=>{a.current&&clearTimeout(a.current)}):(a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{i.current=Date.now(),s(e),a.current=void 0},n-u),()=>{a.current&&clearTimeout(a.current)})},[e,r,n]),o}function Ll(e,t){if(e==null||e==="")return"";if(t&&typeof e=="object"&&!Array.isArray(e)){const r=e,o=Object.keys(r).sort().map(s=>[s,r[s]??""]);return`O:${JSON.stringify(o)}`}return typeof e=="string"?`S:${e}`:""}function Dl(e,t){return e==null||e===""?!0:t&&typeof e=="object"&&!Array.isArray(e)?Object.keys(e).length===0:!1}function CC(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 EC(e){if(_t.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 NC(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 Yp(e,t){return typeof t=="number"&&t>0?e.slice(0,t):e}function Bl(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.label=="string"&&t.value!==null&&t.value!==void 0}const Xp=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d,formValues:u={},submissionContext:l})=>{const f=e.properties||{},p=SC(f),m=f.apiEndpoint?.trim()||"",g=f.apiRealtime===!0,h=(f.apiMethod||"GET").toUpperCase()==="POST"?"POST":"GET",y=f.searchInBody===!0,v=h==="POST"||h==="GET"&&y,w=f.searchStrategy??f.searchSchedule??"debounce",x=f.searchIntervalMs??f.intervalMs??300,E=f.minQueryLength??0,P=f.maxResults,C=f.searchQueryParam||"q",N=f.clearable!==!1,_=u,[A,I]=S.useState(()=>Dl(t,p)?"":p&&typeof t=="object"&&t!==null&&!Array.isArray(t)?f.initialDisplayLabel||"":f.initialDisplayLabel||String(t)),[T,W]=S.useState(!1),[J,O]=S.useState([]),[j,M]=S.useState([]),[D,L]=S.useState([]),[U,$]=S.useState(!1),[ie,V]=S.useState(null),[K,X]=S.useState(-1),ce=S.useRef(Ll(t,p)),ne=S.useRef(Dl(t,p)?"":p&&typeof t=="object"&&t!==null&&!Array.isArray(t)?f.initialDisplayLabel||"":f.initialDisplayLabel||String(t??"")),G=S.useRef(void 0),ee=S.useRef(0),Pe=S.useRef(null),oe=AC(A,{mode:w,intervalMs:x}),re=S.useMemo(()=>J.filter(Bl),[J]);S.useEffect(()=>{if(re.length===0){K!==-1&&X(-1);return}(K<0||K>=re.length)&&X(0)},[K,re.length]);const be=S.useMemo(()=>{const te=$s(m,f.apiQueryParams),pe=new Set(te);for(const We of f.dependentFields||[])We&&pe.add(We);return pe},[m,f.apiQueryParams,f.dependentFields]),de=S.useMemo(()=>{if(be.size===0)return null;const te={};return be.forEach(pe=>{te[pe]=_[pe]}),JSON.stringify(te)},[be,_]),ot=S.useMemo(()=>JSON.stringify(u),[u]),Se=S.useMemo(()=>JSON.stringify(l||{}),[l]);S.useEffect(()=>{const te=Ll(t,p);if(te===ce.current)return;if(ce.current=te,Dl(t,p)){ne.current="",I(""),O([]),M([]),L([]),V(null),W(!1);return}const pe=f.initialDisplayLabel||(!p&&typeof t=="string"?t:"");ne.current=pe,I(pe)},[t,f.initialDisplayLabel,p]),S.useEffect(()=>{if(!m){O([]),M([]),L([]),$(!1);return}if(i||s||e.disabled){O([]),M([]),L([]),$(!1);return}const te=oe;if(te.length<E){O([]),M([]),L([]),$(!1),V(null);return}const pe=zd({apiEndpoint:m,apiMethod:h,apiQueryParams:f.apiQueryParams,formValues:_,submissionContext:l,apiRealtime:g,additionalRequiredFieldNames:f.dependentFields});if(pe.blocked){O([]),M([]),L([]),$(!1),V(null);return}Pe.current?.abort();const We=new AbortController;Pe.current=We;const Pt=++ee.current;return(async()=>{$(!0),V(null);const Te=cn(pe.url),Xe={};v&&(Xe["Content-Type"]="application/json"),f.apiKey&&(Xe["X-CSCAPI-KEY"]=f.apiKey);try{let Ue;if(!v)Ue=(await dn.get(Te,{params:{[C]:te},signal:We.signal,headers:Object.keys(Xe).length?Xe:void 0})).data;else{let It={};pe.postBodyBase&&Object.keys(pe.postBodyBase).length>0?It={...pe.postBodyBase}:g&&Object.keys(_).length>0&&(It={..._});let Er=It;if(f.searchBodyTemplate?.trim()){let sr=f.searchBodyTemplate.replace(/\{\{query\}\}/g,()=>Kp(te)).replace(/\{query\}/g,()=>Kp(te));sr=Wb(sr,_,l,g);const fn=JSON.parse(sr);Er={...It,...fn}}else Er={...It,[C]:te};Ue=(await dn.post(Te,Er,{signal:We.signal,headers:Object.keys(Xe).length?Xe:void 0})).data}if(Pt!==ee.current)return;const ft=f.apiResultsFormat,St=f.apiResultsConfig,xt=ft==="clinicaltables_v3",ze=$A(Ue),pt=xt||ft===void 0&&ze,At=ft==="tuple_array";let Ut=null;pt?Ut=Cp({response:Ue,sourceUrl:Te,rowsIndex:St?.rowsIndex??3,rowsPath:St?.rowsPath,columns:St?.columns,columnsQueryParam:St?.columnsQueryParam??"sf",columnsQueryParamSeparator:St?.columnsQueryParamSeparator??","}):At&&(Ut=Cp({response:Ue,sourceUrl:Te,rowsIndex:St?.rowsIndex,rowsPath:St?.rowsPath,columns:St?.columns,columnsQueryParam:St?.columnsQueryParam,columnsQueryParamSeparator:St?.columnsQueryParamSeparator}));const ur=NC(Ue),Ar=Ut!==null,Vt=Ut&&Array.isArray(Ut)?Ut:Array.isArray(ur)&&ur.every(It=>It&&typeof It=="object"&&!Array.isArray(It))?ur:null;L(Vt??ur);const Po=Array.isArray(f.apiLabelFields)&&f.apiLabelFields.length>0,Xn=Vt&&(Ar||Po)?zA({rows:Vt,apiLabelField:f.apiLabelField,apiLabelFields:f.apiLabelFields,apiLabelSeparator:f.apiLabelSeparator,apiValueField:f.apiValueField}):Fl(Ue,f.apiLabelField,f.apiValueField);M(Xn);const Ct=f.apiClientFilter;let Cr=Xn;if(Ct?.filterField&&Ct?.matchField){const It=_[Ct.matchField];if(It!=null){const Er=f.apiValueField;Cr=Xn.filter(er=>{const fn=(Vt??ur).find(kt=>String(or(kt,Er||"code"))===String(er.value));if(!fn)return!1;const yr=or(fn,Ct.filterField);return String(yr)===String(It)})}else Cr=[]}const Jn=Yp(Cr,P).filter(Bl);O(Jn),X(Jn.length>0?0:-1)}catch(Ue){if(_t.isCancel(Ue)||Ue?.code==="ERR_CANCELED"||Pt!==ee.current)return;O([]),M([]),L([]),V(EC(Ue)),X(-1)}finally{Pt===ee.current&&$(!1)}})(),()=>{We.abort()}},[oe,m,h,y,v,C,E,P,f.apiKey,f.searchBodyTemplate,f.apiLabelField,f.apiLabelFields,f.apiLabelSeparator,f.apiValueField,f.apiQueryParams,f.apiClientFilter,f.apiResultsFormat,f.apiResultsConfig,f.dependentFields,g,_,l,i,s,e.disabled,de,ot,Se]),S.useEffect(()=>{const te=f.apiClientFilter;if(!te||D.length===0||j.length===0)return;const pe=_[te.matchField],We=f.apiValueField;if(pe==null){O([]);return}const Pt=j.filter(Te=>{const Xe=D.find(ft=>String(or(ft,We||"code"))===String(Te.value));if(!Xe)return!1;const Ue=or(Xe,te.filterField);return String(Ue)===String(pe)}),je=Yp(Pt,P).filter(Bl);O(je),X(je.length>0?0:-1)},[f.apiClientFilter,f.apiValueField,_,P,j,D]);const xe=s||e.disabled,ae=i||e.readOnly,ve=S.useCallback(te=>{const pe=te.target.value;ae||xe||(ce.current&&ne.current&&pe!==ne.current&&(ce.current="",ne.current="",r(p?null:"")),I(pe),W(!0),X(-1))},[xe,ae,p,r]),Ye=S.useCallback(te=>{const pe=typeof te?.label=="string"?te.label:String(te?.value??""),We=f.apiValueField||"code";if(p){const Pt=qp(f),je=D.find(Te=>String(or(Te,We))===String(te.value));if(je&&typeof je=="object"&&!Array.isArray(je)&&Pt.length>0){const Te=xC(je,Pt);ce.current=Ll(Te,!0),ne.current=pe,r(Te),I(pe)}else ce.current=`S:${String(te.value)}`,ne.current=pe,r(String(te.value)),I(pe)}else ce.current=`S:${String(te.value)}`,ne.current=pe,r(String(te.value)),I(pe);G.current&&clearTimeout(G.current),W(!1),X(-1),n?.()},[p,n,r,f,D]),ct=S.useCallback(te=>{te.preventDefault(),te.stopPropagation(),!(xe||ae)&&(ce.current="",ne.current="",r(p?null:""),I(""),O([]),M([]),L([]),V(null),W(!1),n?.())},[xe,ae,p,r,n]),Ge=S.useMemo(()=>T&&!ae&&(U||!!ie||re.length>0||oe.length>=E&&!U),[T,ae,U,ie,re.length,oe,E]),Kt=S.useCallback(te=>{if(!(ae||xe))if(te.key==="ArrowDown")te.preventDefault(),W(!0),X(pe=>re.length===0?-1:(pe+1)%re.length);else if(te.key==="ArrowUp")te.preventDefault(),W(!0),X(pe=>re.length===0?-1:pe<=0?re.length-1:pe-1);else if(te.key==="Enter"){const pe=K>=0?re[K]:void 0;Ge&&pe&&!pe.disabled&&(te.preventDefault(),Ye(pe))}else te.key==="Escape"&&W(!1)},[xe,ae,K,Ge,re,Ye]),Je=e.appearance?.size||"md",q={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},$e=ht(e),gt=jt(e,!!(o||ie)),Oe=oe.length>=E&&!U&&!ie&&re.length===0;return c.jsx(Et,{field:e,error:o||ie||void 0,isRequired:a,className:d,children:c.jsxs(Ol,{open:Ge,onOpenChange:te=>{te||W(!1)},children:[c.jsx(fC,{asChild:!0,children:c.jsxs("div",{className:"relative flex w-full min-w-0 items-center gap-1",children:[c.jsx(wn,{id:$e,role:"combobox","aria-expanded":Ge,"aria-autocomplete":"list","aria-controls":Ge?`${$e}-listbox`:void 0,"aria-activedescendant":K>=0?`${$e}-opt-${K}`:void 0,value:A,onChange:ve,onKeyDown:Kt,onFocus:()=>{G.current&&clearTimeout(G.current),!ae&&!xe&&W(!0)},onBlur:()=>{G.current=setTimeout(()=>{W(!1),n?.()},150)},placeholder:e.placeholder||"Search…",disabled:xe,readOnly:ae,"aria-describedby":gt,"aria-invalid":Jt(!!(o||ie)),"aria-required":a,className:B("pr-20",q[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:[U&&c.jsx(Ro,{className:"pointer-events-none h-4 w-4 animate-spin text-muted-foreground"}),N&&CC(t,A,p)&&!xe&&!ae&&c.jsx(Yt,{type:"button",variant:"ghost",size:"icon",className:"pointer-events-auto h-8 w-8 shrink-0",onMouseDown:te=>te.preventDefault(),onClick:ct,"aria-label":"Clear",children:c.jsx(Ko,{className:"h-4 w-4"})})]})]})}),c.jsx(Il,{className:"p-0 w-[var(--radix-popover-trigger-width)] min-w-[12rem] overflow-hidden",align:"start",onOpenAutoFocus:te=>te.preventDefault(),onCloseAutoFocus:te=>te.preventDefault(),children:c.jsx("div",{id:`${$e}-listbox`,role:"listbox",children:ie?c.jsx("div",{className:"px-3 py-2 text-sm text-destructive",children:ie}):U?c.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-sm text-muted-foreground",children:[c.jsx(Ro,{className:"h-4 w-4 animate-spin shrink-0"}),"Loading…"]}):Oe?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:te=>te.preventDefault(),children:"No results found"})}):c.jsx("ul",{className:"max-h-60 overflow-y-auto overscroll-contain py-1","aria-label":"Search results",children:re.map((te,pe)=>c.jsx("li",{id:`${$e}-opt-${pe}`,role:"option","aria-selected":K===pe,className:B(te.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:()=>{te.disabled||Ye(te)},children:te.label},`${te.value}-${pe}`))})})})]})})};var ki="Checkbox",[_C]=vr(ki),[kC,$l]=_C(ki);function TC(e){const{__scopeCheckbox:t,checked:r,children:n,defaultChecked:o,disabled:s,form:i,name:a,onCheckedChange:d,required:u,value:l="on",internal_do_not_use_render:f}=e,[p,m]=Zr({prop:r,defaultProp:o??!1,onChange:d,caller:ki}),[g,h]=b.useState(null),[y,v]=b.useState(null),w=b.useRef(!1),x=g?!!i||!!g.closest("form"):!0,E={checked:p,disabled:s,setChecked:m,control:g,setControl:h,name:a,form:i,value:l,hasConsumerStoppedPropagationRef:w,required:u,defaultChecked:Fn(o)?!1:o,isFormControl:x,bubbleInput:y,setBubbleInput:v};return c.jsx(kC,{scope:t,...E,children:FC(f)?f(E):n})}var Jp="CheckboxTrigger",Qp=b.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:r,...n},o)=>{const{control:s,value:i,disabled:a,checked:d,required:u,setControl:l,setChecked:f,hasConsumerStoppedPropagationRef:p,isFormControl:m,bubbleInput:g}=$l(Jp,e),h=Ze(o,l),y=b.useRef(d);return b.useEffect(()=>{const v=s?.form;if(v){const w=()=>f(y.current);return v.addEventListener("reset",w),()=>v.removeEventListener("reset",w)}},[s,f]),c.jsx(Be.button,{type:"button",role:"checkbox","aria-checked":Fn(d)?"mixed":d,"aria-required":u,"data-state":om(d),"data-disabled":a?"":void 0,disabled:a,value:i,...n,ref:h,onKeyDown:Me(t,v=>{v.key==="Enter"&&v.preventDefault()}),onClick:Me(r,v=>{f(w=>Fn(w)?!0:!w),g&&m&&(p.current=v.isPropagationStopped(),p.current||v.stopPropagation())})})});Qp.displayName=Jp;var Zp=b.forwardRef((e,t)=>{const{__scopeCheckbox:r,name:n,checked:o,defaultChecked:s,required:i,disabled:a,value:d,onCheckedChange:u,form:l,...f}=e;return c.jsx(TC,{__scopeCheckbox:r,checked:o,defaultChecked:s,disabled:a,required:i,onCheckedChange:u,name:n,form:l,value:d,internal_do_not_use_render:({isFormControl:p})=>c.jsxs(c.Fragment,{children:[c.jsx(Qp,{...f,ref:t,__scopeCheckbox:r}),p&&c.jsx(nm,{__scopeCheckbox:r})]})})});Zp.displayName=ki;var em="CheckboxIndicator",tm=b.forwardRef((e,t)=>{const{__scopeCheckbox:r,forceMount:n,...o}=e,s=$l(em,r);return c.jsx(xr,{present:n||Fn(s.checked)||s.checked===!0,children:c.jsx(Be.span,{"data-state":om(s.checked),"data-disabled":s.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});tm.displayName=em;var rm="CheckboxBubbleInput",nm=b.forwardRef(({__scopeCheckbox:e,...t},r)=>{const{control:n,hasConsumerStoppedPropagationRef:o,checked:s,defaultChecked:i,required:a,disabled:d,name:u,value:l,form:f,bubbleInput:p,setBubbleInput:m}=$l(rm,e),g=Ze(r,m),h=Qo(s),y=Jo(n);b.useEffect(()=>{const w=p;if(!w)return;const x=window.HTMLInputElement.prototype,P=Object.getOwnPropertyDescriptor(x,"checked").set,C=!o.current;if(h!==s&&P){const N=new Event("click",{bubbles:C});w.indeterminate=Fn(s),P.call(w,Fn(s)?!1:s),w.dispatchEvent(N)}},[p,h,s,o]);const v=b.useRef(Fn(s)?!1:s);return c.jsx(Be.input,{type:"checkbox","aria-hidden":!0,defaultChecked:i??v.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%)"}})});nm.displayName=rm;function FC(e){return typeof e=="function"}function Fn(e){return e==="indeterminate"}function om(e){return Fn(e)?"indeterminate":e?"checked":"unchecked"}function Ti({className:e,...t}){return c.jsx(Zp,{"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(tm,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:c.jsx(Vs,{className:"size-3.5"})})})}const PC=Pp("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 OC({className:e,variant:t,asChild:r=!1,...n}){const o=r?qd:"span";return c.jsx(o,{"data-slot":"badge",className:B(PC({variant:t}),e),...n})}function IC(e,t){return b.useReducer((r,n)=>t[r][n]??r,e)}var jl="ScrollArea",[sm]=vr(jl),[MC,Ir]=sm(jl),im=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,type:n="hover",dir:o,scrollHideDelay:s=600,...i}=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),[v,w]=b.useState(0),[x,E]=b.useState(0),[P,C]=b.useState(!1),[N,_]=b.useState(!1),A=Ze(t,T=>d(T)),I=ro(o);return c.jsx(MC,{scope:r,type:n,dir:I,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:l,content:f,onContentChange:p,scrollbarX:m,onScrollbarXChange:g,scrollbarXEnabled:P,onScrollbarXEnabledChange:C,scrollbarY:h,onScrollbarYChange:y,scrollbarYEnabled:N,onScrollbarYEnabledChange:_,onCornerWidthChange:w,onCornerHeightChange:E,children:c.jsx(Be.div,{dir:I,...i,ref:A,style:{position:"relative","--radix-scroll-area-corner-width":v+"px","--radix-scroll-area-corner-height":x+"px",...e.style}})})});im.displayName=jl;var am="ScrollAreaViewport",lm=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,children:n,nonce:o,...s}=e,i=Ir(am,r),a=b.useRef(null),d=Ze(t,a,i.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(Be.div,{"data-radix-scroll-area-viewport":"",...s,ref:d,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:c.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});lm.displayName=am;var tn="ScrollAreaScrollbar",cm=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Ir(tn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return b.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?c.jsx(LC,{...n,ref:t,forceMount:r}):o.type==="scroll"?c.jsx(DC,{...n,ref:t,forceMount:r}):o.type==="auto"?c.jsx(dm,{...n,ref:t,forceMount:r}):o.type==="always"?c.jsx(zl,{...n,ref:t}):null});cm.displayName=tn;var LC=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Ir(tn,e.__scopeScrollArea),[s,i]=b.useState(!1);return b.useEffect(()=>{const a=o.scrollArea;let d=0;if(a){const u=()=>{window.clearTimeout(d),i(!0)},l=()=>{d=window.setTimeout(()=>i(!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(xr,{present:r||s,children:c.jsx(dm,{"data-state":s?"visible":"hidden",...n,ref:t})})}),DC=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Ir(tn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Ii(()=>d("SCROLL_END"),100),[a,d]=IC("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=s?"scrollLeft":"scrollTop";if(u){let f=u[l];const p=()=>{const m=u[l];f!==m&&(d("SCROLL"),i()),f=m};return u.addEventListener("scroll",p),()=>u.removeEventListener("scroll",p)}},[o.viewport,s,d,i]),c.jsx(xr,{present:r||a!=="hidden",children:c.jsx(zl,{"data-state":a==="hidden"?"hidden":"visible",...n,ref:t,onPointerEnter:Me(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:Me(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),dm=b.forwardRef((e,t)=>{const r=Ir(tn,e.__scopeScrollArea),{forceMount:n,...o}=e,[s,i]=b.useState(!1),a=e.orientation==="horizontal",d=Ii(()=>{if(r.viewport){const u=r.viewport.offsetWidth<r.viewport.scrollWidth,l=r.viewport.offsetHeight<r.viewport.scrollHeight;i(a?u:l)}},10);return go(r.viewport,d),go(r.content,d),c.jsx(xr,{present:n||s,children:c.jsx(zl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),zl=b.forwardRef((e,t)=>{const{orientation:r="vertical",...n}=e,o=Ir(tn,e.__scopeScrollArea),s=b.useRef(null),i=b.useRef(0),[a,d]=b.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=hm(a.viewport,a.content),l={...n,sizes:a,onSizesChange:d,hasThumb:u>0&&u<1,onThumbChange:p=>s.current=p,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:p=>i.current=p};function f(p,m){return VC(p,i.current,a,m)}return r==="horizontal"?c.jsx(BC,{...l,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollLeft,m=gm(p,a,o.dir);s.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($C,{...l,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollTop,m=gm(p,a);s.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}),BC=b.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...o}=e,s=Ir(tn,e.__scopeScrollArea),[i,a]=b.useState(),d=b.useRef(null),u=Ze(t,d,s.onScrollbarXChange);return b.useEffect(()=>{d.current&&a(getComputedStyle(d.current))},[d]),c.jsx(fm,{"data-orientation":"horizontal",...o,ref:u,sizes:r,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Oi(r)+"px",...e.style},onThumbPointerDown:l=>e.onThumbPointerDown(l.x),onDragScroll:l=>e.onDragScroll(l.x),onWheelScroll:(l,f)=>{if(s.viewport){const p=s.viewport.scrollLeft+l.deltaX;e.onWheelScroll(p),bm(p,f)&&l.preventDefault()}},onResize:()=>{d.current&&s.viewport&&i&&n({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:Pi(i.paddingLeft),paddingEnd:Pi(i.paddingRight)}})}})}),$C=b.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...o}=e,s=Ir(tn,e.__scopeScrollArea),[i,a]=b.useState(),d=b.useRef(null),u=Ze(t,d,s.onScrollbarYChange);return b.useEffect(()=>{d.current&&a(getComputedStyle(d.current))},[d]),c.jsx(fm,{"data-orientation":"vertical",...o,ref:u,sizes:r,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Oi(r)+"px",...e.style},onThumbPointerDown:l=>e.onThumbPointerDown(l.y),onDragScroll:l=>e.onDragScroll(l.y),onWheelScroll:(l,f)=>{if(s.viewport){const p=s.viewport.scrollTop+l.deltaY;e.onWheelScroll(p),bm(p,f)&&l.preventDefault()}},onResize:()=>{d.current&&s.viewport&&i&&n({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:Pi(i.paddingTop),paddingEnd:Pi(i.paddingBottom)}})}})}),[jC,um]=sm(tn),fm=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:d,onDragScroll:u,onWheelScroll:l,onResize:f,...p}=e,m=Ir(tn,r),[g,h]=b.useState(null),y=Ze(t,A=>h(A)),v=b.useRef(null),w=b.useRef(""),x=m.viewport,E=n.content-n.viewport,P=ar(l),C=ar(d),N=Ii(f,10);function _(A){if(v.current){const I=A.clientX-v.current.left,T=A.clientY-v.current.top;u({x:I,y:T})}}return b.useEffect(()=>{const A=I=>{const T=I.target;g?.contains(T)&&P(I,E)};return document.addEventListener("wheel",A,{passive:!1}),()=>document.removeEventListener("wheel",A,{passive:!1})},[x,g,E,P]),b.useEffect(C,[n,C]),go(g,N),go(m.content,N),c.jsx(jC,{scope:r,scrollbar:g,hasThumb:o,onThumbChange:ar(s),onThumbPointerUp:ar(i),onThumbPositionChange:C,onThumbPointerDown:ar(a),children:c.jsx(Be.div,{...p,ref:y,style:{position:"absolute",...p.style},onPointerDown:Me(e.onPointerDown,A=>{A.button===0&&(A.target.setPointerCapture(A.pointerId),v.current=g.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),_(A))}),onPointerMove:Me(e.onPointerMove,_),onPointerUp:Me(e.onPointerUp,A=>{const I=A.target;I.hasPointerCapture(A.pointerId)&&I.releasePointerCapture(A.pointerId),document.body.style.webkitUserSelect=w.current,m.viewport&&(m.viewport.style.scrollBehavior=""),v.current=null})})})}),Fi="ScrollAreaThumb",pm=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=um(Fi,e.__scopeScrollArea);return c.jsx(xr,{present:r||o.hasThumb,children:c.jsx(zC,{ref:t,...n})})}),zC=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,style:n,...o}=e,s=Ir(Fi,r),i=um(Fi,r),{onThumbPositionChange:a}=i,d=Ze(t,f=>i.onThumbChange(f)),u=b.useRef(void 0),l=Ii(()=>{u.current&&(u.current(),u.current=void 0)},100);return b.useEffect(()=>{const f=s.viewport;if(f){const p=()=>{if(l(),!u.current){const m=HC(f,a);u.current=m,a()}};return a(),f.addEventListener("scroll",p),()=>f.removeEventListener("scroll",p)}},[s.viewport,l,a]),c.jsx(Be.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:Me(e.onPointerDownCapture,f=>{const m=f.target.getBoundingClientRect(),g=f.clientX-m.left,h=f.clientY-m.top;i.onThumbPointerDown({x:g,y:h})}),onPointerUp:Me(e.onPointerUp,i.onThumbPointerUp)})});pm.displayName=Fi;var Ul="ScrollAreaCorner",mm=b.forwardRef((e,t)=>{const r=Ir(Ul,e.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?c.jsx(UC,{...e,ref:t}):null});mm.displayName=Ul;var UC=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,...n}=e,o=Ir(Ul,r),[s,i]=b.useState(0),[a,d]=b.useState(0),u=!!(s&&a);return go(o.scrollbarX,()=>{const l=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(l),d(l)}),go(o.scrollbarY,()=>{const l=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(l),i(l)}),u?c.jsx(Be.div,{...n,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Pi(e){return e?parseInt(e,10):0}function hm(e,t){const r=e/t;return isNaN(r)?0:r}function Oi(e){const t=hm(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,n=(e.scrollbar.size-r)*t;return Math.max(n,18)}function VC(e,t,r,n="ltr"){const o=Oi(r),s=o/2,i=t||s,a=o-i,d=r.scrollbar.paddingStart+i,u=r.scrollbar.size-r.scrollbar.paddingEnd-a,l=r.content-r.viewport,f=n==="ltr"?[0,l]:[l*-1,0];return ym([d,u],f)(e)}function gm(e,t,r="ltr"){const n=Oi(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-n,d=r==="ltr"?[0,i]:[i*-1,0],u=qo(e,d);return ym([0,i],[0,a])(u)}function ym(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 bm(e,t){return e>0&&e<t}var HC=(e,t=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},n=0;return(function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=r.left!==s.left,a=r.top!==s.top;(i||a)&&t(),r=s,n=window.requestAnimationFrame(o)})(),()=>window.cancelAnimationFrame(n)};function Ii(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 go(e,t){const r=ar(t);Qt(()=>{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 WC=im,RC=lm,GC=mm;function KC({className:e,children:t,...r}){return c.jsxs(WC,{"data-slot":"scroll-area",className:B("relative",e),...r,children:[c.jsx(RC,{"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(qC,{}),c.jsx(GC,{})]})}function qC({className:e,orientation:t="vertical",...r}){return c.jsx(cm,{"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(pm,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const vm=({field:e,value:t=[],onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,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(N=>!g.has(String(N.value??N.label??""))):f,y=Array.isArray(t)?t:[],v=y.map(N=>h.find(_=>String(_.value)===String(N))).filter(Boolean),w=S.useCallback(N=>{const _=y.includes(N)?y.filter(A=>A!==N):[...y,N];r(_),n?.()},[y,r,n]),x=S.useCallback(N=>{r(y.filter(_=>_!==N)),n?.()},[y,r,n]),E=e.appearance?.size||"md",P={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},C=v.length>0?`${v.length} selected`:h.length===0&&l?.length?"No available options":e.placeholder||"Select options";return c.jsxs(Et,{field:e,error:o||m||void 0,isRequired:i,className:a,children:[c.jsxs(Ol,{children:[c.jsx(Hp,{asChild:!0,children:c.jsxs(Yt,{type:"button",variant:"outline",role:"combobox","aria-expanded":void 0,"aria-haspopup":"listbox","aria-multiselectable":"true","aria-describedby":jt(e,!!o||!!m),"aria-invalid":Jt(!!o||!!m),"aria-required":i,id:ht(e),disabled:s||e.disabled||p,className:B("w-full min-w-0 justify-between font-normal",P[E],o&&"border-destructive focus-visible:ring-destructive",m&&"border-destructive focus-visible:ring-destructive",e.appearance?.className),children:[c.jsx("span",{className:"truncate",children:C}),c.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[p&&c.jsx(Ro,{className:"h-4 w-4 animate-spin text-muted-foreground"}),c.jsx(Wo,{className:"h-4 w-4 opacity-50"})]})]})}),c.jsx(Il,{className:"w-[var(--radix-popover-trigger-width)] p-0 overflow-hidden",align:"start",children:c.jsx(KC,{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(N=>{const _=String(N.value||N.label),A=N.label||N.value||_,I=y.includes(_);return c.jsxs("li",{role:"option","aria-selected":I,className:"flex items-center gap-2 rounded-sm px-2 py-1.5 cursor-pointer hover:bg-accent focus:bg-accent outline-none",onClick:()=>!N.disabled&&w(_),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),N.disabled||w(_))},children:[c.jsx(Ti,{checked:I,disabled:N.disabled,onCheckedChange:()=>!N.disabled&&w(_),onClick:T=>T.stopPropagation(),"aria-hidden":!0,className:"pointer-events-none"}),c.jsx("span",{className:"flex-1 truncate text-sm",children:A})]},_)})})})})]}),v.length>0&&c.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",role:"list","aria-label":"Selected options",children:v.map(N=>{const _=String(N.value||N.label),A=N.label||N.value||_;return c.jsxs(OC,{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(_),tabIndex:-1,children:c.jsx(Ko,{className:"h-3 w-3"})})]},_)})})]})},wm=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,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(Ti,{id:ht(e),checked:t||!1,onCheckedChange:d,disabled:s||e.disabled,"aria-describedby":jt(e,!!o),"aria-required":i,className:B(o&&"border-destructive")}),c.jsxs("div",{className:"grid gap-1.5 leading-none",children:[c.jsxs(Sn,{id:zs(e),htmlFor:ht(e),className:B("text-sm font-medium cursor-pointer",o&&"text-destructive"),children:[e.label,i&&c.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.description&&!o&&c.jsx("p",{id:Vo(e),className:"text-xs text-muted-foreground",children:e.description})]})]}),o&&c.jsx("p",{id:Ho(e),className:"text-xs text-destructive",role:"alert",children:o})]})};var Mi="Switch",[YC]=vr(Mi),[XC,JC]=YC(Mi),Sm=b.forwardRef((e,t)=>{const{__scopeSwitch:r,name:n,checked:o,defaultChecked:s,required:i,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,[v,w]=Zr({prop:o,defaultProp:s??!1,onChange:u,caller:Mi});return c.jsxs(XC,{scope:r,checked:v,disabled:a,children:[c.jsx(Be.button,{type:"button",role:"switch","aria-checked":v,"aria-required":i,"data-state":Em(v),"data-disabled":a?"":void 0,disabled:a,value:d,...f,ref:g,onClick:Me(e.onClick,x=>{w(E=>!E),y&&(h.current=x.isPropagationStopped(),h.current||x.stopPropagation())})}),y&&c.jsx(Cm,{control:p,bubbles:!h.current,name:n,value:d,checked:v,required:i,disabled:a,form:l,style:{transform:"translateX(-100%)"}})]})});Sm.displayName=Mi;var xm="SwitchThumb",Am=b.forwardRef((e,t)=>{const{__scopeSwitch:r,...n}=e,o=JC(xm,r);return c.jsx(Be.span,{"data-state":Em(o.checked),"data-disabled":o.disabled?"":void 0,...n,ref:t})});Am.displayName=xm;var QC="SwitchBubbleInput",Cm=b.forwardRef(({__scopeSwitch:e,control:t,checked:r,bubbles:n=!0,...o},s)=>{const i=b.useRef(null),a=Ze(i,s),d=Qo(r),u=Jo(t);return b.useEffect(()=>{const l=i.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}})});Cm.displayName=QC;function Em(e){return e?"checked":"unchecked"}var ZC=Sm,eE=Am;function Nm({className:e,...t}){return c.jsx(ZC,{"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(eE,{"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 tE=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,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(Sn,{id:zs(e),htmlFor:ht(e),className:B("text-sm font-medium block",o&&"text-destructive"),children:[e.label,i&&c.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.description&&!o&&c.jsx("p",{id:Vo(e),className:"text-xs text-muted-foreground",children:e.description}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Nm,{id:ht(e),checked:g,onCheckedChange:h,disabled:s||e.disabled,"aria-describedby":jt(e,!!o),"aria-required":i,className:B(o&&"opacity-50")}),c.jsx("span",{className:"text-sm text-foreground font-medium",children:g?p:m})]})]}),o&&c.jsx("p",{id:Ho(e),className:"text-xs text-destructive",role:"alert",children:o})]})};var Vl="rovingFocusGroup.onEntryFocus",rE={bubbles:!1,cancelable:!0},as="RovingFocusGroup",[Hl,_m,nE]=Ba(as),[oE,Li]=vr(as,[nE]),[sE,iE]=oE(as),km=b.forwardRef((e,t)=>c.jsx(Hl.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Hl.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(aE,{...e,ref:t})})}));km.displayName=as;var aE=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:d,onEntryFocus:u,preventScrollOnEntryFocus:l=!1,...f}=e,p=b.useRef(null),m=Ze(t,p),g=ro(s),[h,y]=Zr({prop:i,defaultProp:a??null,onChange:d,caller:as}),[v,w]=b.useState(!1),x=ar(u),E=_m(r),P=b.useRef(!1),[C,N]=b.useState(0);return b.useEffect(()=>{const _=p.current;if(_)return _.addEventListener(Vl,x),()=>_.removeEventListener(Vl,x)},[x]),c.jsx(sE,{scope:r,orientation:n,dir:g,loop:o,currentTabStopId:h,onItemFocus:b.useCallback(_=>y(_),[y]),onItemShiftTab:b.useCallback(()=>w(!0),[]),onFocusableItemAdd:b.useCallback(()=>N(_=>_+1),[]),onFocusableItemRemove:b.useCallback(()=>N(_=>_-1),[]),children:c.jsx(Be.div,{tabIndex:v||C===0?-1:0,"data-orientation":n,...f,ref:m,style:{outline:"none",...e.style},onMouseDown:Me(e.onMouseDown,()=>{P.current=!0}),onFocus:Me(e.onFocus,_=>{const A=!P.current;if(_.target===_.currentTarget&&A&&!v){const I=new CustomEvent(Vl,rE);if(_.currentTarget.dispatchEvent(I),!I.defaultPrevented){const T=E().filter(M=>M.focusable),W=T.find(M=>M.active),J=T.find(M=>M.id===h),j=[W,J,...T].filter(Boolean).map(M=>M.ref.current);Pm(j,l)}}P.current=!1}),onBlur:Me(e.onBlur,()=>w(!1))})})}),Tm="RovingFocusGroupItem",Fm=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:o=!1,tabStopId:s,children:i,...a}=e,d=on(),u=s||d,l=iE(Tm,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(Hl.ItemSlot,{scope:r,id:u,focusable:n,active:o,children:c.jsx(Be.span,{tabIndex:f?0:-1,"data-orientation":l.orientation,...a,ref:t,onMouseDown:Me(e.onMouseDown,y=>{n?l.onItemFocus(u):y.preventDefault()}),onFocus:Me(e.onFocus,()=>l.onItemFocus(u)),onKeyDown:Me(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){l.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const v=dE(y,l.orientation,l.dir);if(v!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let x=p().filter(E=>E.focusable).map(E=>E.ref.current);if(v==="last")x.reverse();else if(v==="prev"||v==="next"){v==="prev"&&x.reverse();const E=x.indexOf(y.currentTarget);x=l.loop?uE(x,E+1):x.slice(E+1)}setTimeout(()=>Pm(x))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:h!=null}):i})})});Fm.displayName=Tm;var lE={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function cE(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function dE(e,t,r){const n=cE(e.key,r);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return lE[n]}function Pm(e,t=!1){const r=document.activeElement;for(const n of e)if(n===r||(n.focus({preventScroll:t}),document.activeElement!==r))return}function uE(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var Om=km,Im=Fm,Wl="Radio",[fE,Mm]=vr(Wl),[pE,mE]=fE(Wl),Lm=b.forwardRef((e,t)=>{const{__scopeRadio:r,name:n,checked:o=!1,required:s,disabled:i,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:i,children:[c.jsx(Be.button,{type:"button",role:"radio","aria-checked":o,"data-state":jm(o),"data-disabled":i?"":void 0,disabled:i,value:a,...l,ref:m,onClick:Me(e.onClick,y=>{o||d?.(),h&&(g.current=y.isPropagationStopped(),g.current||y.stopPropagation())})}),h&&c.jsx($m,{control:f,bubbles:!g.current,name:n,value:a,checked:o,required:s,disabled:i,form:u,style:{transform:"translateX(-100%)"}})]})});Lm.displayName=Wl;var Dm="RadioIndicator",Bm=b.forwardRef((e,t)=>{const{__scopeRadio:r,forceMount:n,...o}=e,s=mE(Dm,r);return c.jsx(xr,{present:n||s.checked,children:c.jsx(Be.span,{"data-state":jm(s.checked),"data-disabled":s.disabled?"":void 0,...o,ref:t})})});Bm.displayName=Dm;var hE="RadioBubbleInput",$m=b.forwardRef(({__scopeRadio:e,control:t,checked:r,bubbles:n=!0,...o},s)=>{const i=b.useRef(null),a=Ze(i,s),d=Qo(r),u=Jo(t);return b.useEffect(()=>{const l=i.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(Be.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}})});$m.displayName=hE;function jm(e){return e?"checked":"unchecked"}var gE=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Di="RadioGroup",[yE]=vr(Di,[Li,Mm]),zm=Li(),Um=Mm(),[bE,vE]=yE(Di),Vm=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,name:n,defaultValue:o,value:s,required:i=!1,disabled:a=!1,orientation:d,dir:u,loop:l=!0,onValueChange:f,...p}=e,m=zm(r),g=ro(u),[h,y]=Zr({prop:s,defaultProp:o??null,onChange:f,caller:Di});return c.jsx(bE,{scope:r,name:n,required:i,disabled:a,value:h,onValueChange:y,children:c.jsx(Om,{asChild:!0,...m,orientation:d,dir:g,loop:l,children:c.jsx(Be.div,{role:"radiogroup","aria-required":i,"aria-orientation":d,"data-disabled":a?"":void 0,dir:g,...p,ref:t})})})});Vm.displayName=Di;var Hm="RadioGroupItem",Wm=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,disabled:n,...o}=e,s=vE(Hm,r),i=s.disabled||n,a=zm(r),d=Um(r),u=b.useRef(null),l=Ze(t,u),f=s.value===o.value,p=b.useRef(!1);return b.useEffect(()=>{const m=h=>{gE.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(Im,{asChild:!0,...a,focusable:!i,active:f,children:c.jsx(Lm,{disabled:i,required:s.required,checked:f,...d,...o,name:s.name,ref:l,onCheck:()=>s.onValueChange(o.value),onKeyDown:Me(m=>{m.key==="Enter"&&m.preventDefault()}),onFocus:Me(o.onFocus,()=>{p.current&&u.current?.click()})})})});Wm.displayName=Hm;var wE="RadioGroupIndicator",Rm=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,...n}=e,o=Um(r);return c.jsx(Bm,{...o,...n,ref:t})});Rm.displayName=wE;var SE=Vm,xE=Wm,AE=Rm;function CE({className:e,...t}){return c.jsx(SE,{"data-slot":"radio-group",className:B("grid gap-3",e),...t})}function EE({className:e,...t}){return c.jsx(xE,{"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(AE,{"data-slot":"radio-group-indicator",className:"relative flex items-center justify-center",children:c.jsx(eu,{className:"fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2"})})})}const Gm=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,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(Et,{field:e,error:o,isRequired:i,className:a,children:c.jsx(CE,{value:t||"",onValueChange:m,disabled:s||e.disabled||p.length===0,className:"flex flex-col space-y-2","aria-required":i,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(EE,{id:`${ht(e)}-${g.value}`,value:g.value,disabled:g.disabled,className:B(o&&"border-destructive")}),c.jsxs(Sn,{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))})})},Km=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=e.properties,l=S.useCallback(E=>{r(E.target.value)},[r]),f=E=>{if(E)return E==="today"?new Date().toISOString().split("T")[0]:E},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",v={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},w=e.appearance?.labelPlacement||"top",x=!e.appearance?.hideLabel&&e.label;return c.jsxs("div",{className:B("space-y-2 w-fit",w==="left"&&"flex items-start gap-4",d),children:[x&&c.jsxs(Sn,{id:zs(e),htmlFor:ht(e),className:B("text-sm font-medium",w==="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(Ev,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"}),c.jsx(wn,{id:ht(e),type:h,value:t||"",onChange:l,onBlur:n,disabled:s||e.disabled,readOnly:i||e.readOnly,min:p,max:m,"aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:B(v[y],"pl-10 w-fit",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]}),e.description&&!o&&c.jsx("p",{id:Vo(e),className:"mt-1.5 text-xs text-muted-foreground",children:e.description}),o&&c.jsx("p",{id:Ho(e),className:"mt-1.5 text-xs text-destructive",role:"alert",children:o})]})]})};function yo(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 Rl(e,t){return e===1&&t===1}const qm=/\.(jpg|jpeg|png|gif|webp|bmp|svg)(\?|$)/i;function Gl(e){return e.type.startsWith("image/")?!0:qm.test(e.name)}function Bi(e){try{const t=e.split("?")[0];return qm.test(t)}catch{return!1}}function Kl({items:e,maxFiles:t,disabled:r,objectUrls:n,failedUrlKeys:o,onImageUrlError:s,onRemove:i,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??"",v=`${m}-${y}`,w=h&&o.has(y),x=g?n[m]??null:h&&Bi(y)&&!w?y:null,E=g&&Gl(p)&&!!x||!!h&&Bi(y)&&!w&&!!x,P=g?p.name:h?h.name??f(y):"",C=d?.(m,p),N=h&&y||C||"",_=!!a&&!!N;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:[E&&x?c.jsx("img",{src:x,alt:"",className:"absolute inset-0 h-full w-full object-cover",onError:()=>{h&&s(y)}}):c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-muted/40",children:c.jsx(ru,{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.jsx("button",{type:"button",onClick:A=>{A.preventDefault(),A.stopPropagation(),a(N)},disabled:r,className:"inline-flex h-5 w-5 items-center justify-center rounded bg-background/90 text-foreground hover:bg-background focus:outline-none focus:ring-2 focus:ring-primary","aria-label":"Open file",title:"Open file",children:c.jsx(tu,{className:"h-3 w-3","aria-hidden":!0})}),c.jsx("button",{type:"button",onClick:A=>{A.preventDefault(),A.stopPropagation(),i(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(Ko,{className:"h-3 w-3","aria-hidden":!0})})]}),!E&&P&&c.jsx("span",{className:"sr-only",children:P})]},v+(g?p.name+p.size:""))}),u]})}function ql(e){const[t,r]=S.useState([]);return S.useEffect(()=>{const n=e.map(o=>o instanceof File&&Gl(o)?URL.createObjectURL(o):null);return r(n),()=>{n.forEach(o=>{o&&URL.revokeObjectURL(o)})}},[e]),t}function Yl({item:e,objectUrl:t,failedUrlKeys:r,onImageUrlError:n,onRemove:o,onOpenUrl:s,openTarget:i,disabled:a}){const d=S.useCallback(w=>{try{return w.split("?")[0].split("/").filter(Boolean).pop()||w}catch{return w}},[]),u=e instanceof File,l=!u&&e&&"url"in e?e:null,f=l?.url??"",p=l&&r.has(f),m=u?t:l&&Bi(f)&&!p?f:null,g=u&&Gl(e)&&!!m||!!l&&Bi(f)&&!p&&!!m,h=u?e.name:l?l.name??d(f):"",y=(i?.trim()||f||"").trim(),v=!!s&&!!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(ru,{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:[v&&y&&c.jsx("button",{type:"button",onClick:w=>{w.preventDefault(),w.stopPropagation(),s(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(tu,{className:"h-3.5 w-3.5","aria-hidden":!0})}),c.jsx("button",{type:"button",onClick:w=>{w.preventDefault(),w.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(Ko,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),!g&&h&&c.jsx("p",{className:"sr-only",children:h})]})}const NE=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,buttonResponses:d})=>{const{gridStretch:u}=zo(),l=u&&Is(e),f=e.properties,p=S.useRef(null),[m,g]=S.useState(!1),[h,y]=S.useState(),[v,w]=S.useState(()=>new Set),[x,E]=S.useState(0),P=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,C=Ms(e),N=S.useMemo(()=>Ls(t),[t]),[_,A]=S.useState(null);S.useEffect(()=>{A(null)},[t,x]);const I=_??N,T=ql(I),W=e.validation?.find(Se=>Se.type==="fileSize"),J=e.validation?.find(Se=>Se.type==="fileType"),O=W?.value?W.value:f?.maxSize??P?.maxSize??10*1024*1024,j=J?.value?J.value:f?.accept??P?.accept??[],M=Array.isArray(j)?j.join(","):"",D=()=>{I.length>=C||p.current?.click()},L=S.useCallback(Se=>{if(W){const xe=Yr(Se,W);if(xe!==!0)return typeof xe=="string"?xe:"File size exceeds the maximum allowed size"}else if(Se.size>O)return`File size must be less than ${yo(O)}`;if(J){const xe=Yr(Se,J);if(xe!==!0)return typeof xe=="string"?xe:"File type is not allowed"}return null},[W,J,O]),U=S.useCallback(Se=>{const xe=ka(Se,C);r(xe),n?.()},[r,n,C]),$=S.useCallback(Se=>{y(void 0);const xe=Array.from(Se),ae=[...I];let ve=null;for(const Ye of xe){if(ae.length>=C)break;const ct=L(Ye);if(ct){ve||(ve=ct);continue}ae.push(Ye)}if(ve&&ae.length===I.length){y(ve);return}ve&&y(ve),A(ae),U(ae)},[I,C,L,U]),ie=S.useCallback(Se=>{const xe=Se.target.files;xe&&xe.length>0&&$(xe),p.current&&(p.current.value="")},[$]),V=S.useCallback(Se=>{if(s)return;const xe=I.filter((ae,ve)=>ve!==Se);E(ae=>ae+1),A(xe),U(xe)},[s,I,U]),K=Se=>{Se.preventDefault(),g(!0)},X=()=>{g(!1)},ce=Se=>{Se.preventDefault(),g(!1),Se.dataTransfer.files?.length&&$(Se.dataTransfer.files)},ne=o||h,G=[];(W||O)&&G.push(`Max size: ${yo(O)}`),J&&j.length>0&&G.push(`Allowed types: ${j.join(", ")}`),C>1&&G.push(`Up to ${C} files`);const ee=e.appearance?.hideLabel??!1,Pe=S.useMemo(()=>{if(!d)return null;const Se=Object.values(d);for(let xe=Se.length-1;xe>=0;xe-=1){const ae=Se[xe],ve=typeof ae?.status=="string"?ae.status.toLowerCase():null;if(ve&&ve!=="success")continue;const Ye=ae?.code;if(typeof Ye=="number"&&(Ye<200||Ye>=300))continue;const ct=ae?.data,Ge=ct?.file_url||ct?.fileUrl||ae?.file_url||ae?.fileUrl;if(typeof Ge=="string"&&Ge.trim())return Ge}return null},[d]),oe=S.useCallback(Se=>{window.open(Se,"_blank","noopener,noreferrer")},[]),re=S.useCallback(Se=>{w(xe=>new Set(xe).add(Se))},[]),be=I.length===0,de=I.length<C,ot=Rl(C,I.length);return c.jsx(Et,{field:e,error:ne,isRequired:i,className:B(a,"!space-y-0"),hideLabel:ee,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:Se=>{Se.target.closest("[data-remove-in-dropzone]")||Se.target.closest("[data-no-open-picker]")||D()},onDragOver:K,onDragLeave:X,onDrop:ce,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",s&&"opacity-50 cursor-not-allowed",!de&&I.length>0&&"cursor-default"),children:[c.jsx("input",{ref:p,id:ht(e),type:"file",accept:M,multiple:C>1,onChange:ie,disabled:s||e.disabled||!de,className:"hidden","aria-describedby":jt(e,!!ne),"aria-invalid":Jt(!!ne),"aria-required":i}),be?c.jsxs(c.Fragment,{children:[c.jsx(Hs,{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"}),G.length>0&&c.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-1",children:G.join(" • ")})]}):ot?c.jsx(Yl,{item:I[0],objectUrl:T[0]??null,failedUrlKeys:v,onImageUrlError:re,onRemove:()=>V(0),onOpenUrl:oe,openTarget:I[0]instanceof File?Pe:void 0,disabled:s||e.disabled}):c.jsx(Kl,{items:I,maxFiles:C,disabled:s,objectUrls:T,failedUrlKeys:v,onImageUrlError:re,onRemove:V,resolveOpenUrl:(Se,xe)=>xe instanceof File&&I.length===1&&Pe?.trim()?Pe.trim():null,onOpenUrl:Se=>{Se?.trim()&&oe(Se.trim())},addSlot:de?c.jsxs("button",{type:"button","data-no-open-picker":!0,onClick:Se=>{Se.stopPropagation(),p.current?.click()},disabled:s||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(Hs,{className:"h-4 w-4 mb-0.5","aria-hidden":!0}),"Add"]}):void 0})]})})})};function _E(e){const t=kE(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),d=a.find(FE);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,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function kE(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=OE(o),a=PE(s,o.props);return o.type!==b.Fragment&&(a.ref=n?Bn(n,i):i),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var TE=Symbol("radix.slottable");function FE(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===TE}function PE(e,t){const r={...t};for(const n in t){const o=e[n],s=t[n];/^on[A-Z]/.test(n)?o&&s?r[n]=(...a)=>{const d=s(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function OE(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 $i="Dialog",[Ym]=vr($i),[IE,Rr]=Ym($i),Xm=e=>{const{__scopeDialog:t,children:r,open:n,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=b.useRef(null),d=b.useRef(null),[u,l]=Zr({prop:n,defaultProp:o??!1,onChange:s,caller:$i});return c.jsx(IE,{scope:t,triggerRef:a,contentRef:d,contentId:on(),titleId:on(),descriptionId:on(),open:u,onOpenChange:l,onOpenToggle:b.useCallback(()=>l(f=>!f),[l]),modal:i,children:r})};Xm.displayName=$i;var Jm="DialogTrigger",ME=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Rr(Jm,r),s=Ze(t,o.triggerRef);return c.jsx(Be.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Ql(o.open),...n,ref:s,onClick:Me(e.onClick,o.onOpenToggle)})});ME.displayName=Jm;var Xl="DialogPortal",[LE,Qm]=Ym(Xl,{forceMount:void 0}),Zm=e=>{const{__scopeDialog:t,forceMount:r,children:n,container:o}=e,s=Rr(Xl,t);return c.jsx(LE,{scope:t,forceMount:r,children:b.Children.map(n,i=>c.jsx(xr,{present:r||s.open,children:c.jsx(ni,{asChild:!0,container:o,children:i})}))})};Zm.displayName=Xl;var ji="DialogOverlay",eh=b.forwardRef((e,t)=>{const r=Qm(ji,e.__scopeDialog),{forceMount:n=r.forceMount,...o}=e,s=Rr(ji,e.__scopeDialog);return s.modal?c.jsx(xr,{present:n||s.open,children:c.jsx(BE,{...o,ref:t})}):null});eh.displayName=ji;var DE=_E("DialogOverlay.RemoveScroll"),BE=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Rr(ji,r);return c.jsx(ui,{as:DE,allowPinchZoom:!0,shards:[o.contentRef],children:c.jsx(Be.div,{"data-state":Ql(o.open),...n,ref:t,style:{pointerEvents:"auto",...n.style}})})}),Gn="DialogContent",th=b.forwardRef((e,t)=>{const r=Qm(Gn,e.__scopeDialog),{forceMount:n=r.forceMount,...o}=e,s=Rr(Gn,e.__scopeDialog);return c.jsx(xr,{present:n||s.open,children:s.modal?c.jsx($E,{...o,ref:t}):c.jsx(jE,{...o,ref:t})})});th.displayName=Gn;var $E=b.forwardRef((e,t)=>{const r=Rr(Gn,e.__scopeDialog),n=b.useRef(null),o=Ze(t,r.contentRef,n);return b.useEffect(()=>{const s=n.current;if(s)return sl(s)},[]),c.jsx(rh,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Me(e.onCloseAutoFocus,s=>{s.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:Me(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:Me(e.onFocusOutside,s=>s.preventDefault())})}),jE=b.forwardRef((e,t)=>{const r=Rr(Gn,e.__scopeDialog),n=b.useRef(!1),o=b.useRef(!1);return c.jsx(rh,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{e.onCloseAutoFocus?.(s),s.defaultPrevented||(n.current||r.triggerRef.current?.focus(),s.preventDefault()),n.current=!1,o.current=!1},onInteractOutside:s=>{e.onInteractOutside?.(s),s.defaultPrevented||(n.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;r.triggerRef.current?.contains(i)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),rh=b.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=Rr(Gn,r),d=b.useRef(null),u=Ze(t,d);return za(),c.jsxs(c.Fragment,{children:[c.jsx(Rs,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:s,children:c.jsx(Ws,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Ql(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),c.jsxs(c.Fragment,{children:[c.jsx(UE,{titleId:a.titleId}),c.jsx(HE,{contentRef:d,descriptionId:a.descriptionId})]})]})}),Jl="DialogTitle",nh=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Rr(Jl,r);return c.jsx(Be.h2,{id:o.titleId,...n,ref:t})});nh.displayName=Jl;var oh="DialogDescription",zE=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Rr(oh,r);return c.jsx(Be.p,{id:o.descriptionId,...n,ref:t})});zE.displayName=oh;var sh="DialogClose",ih=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Rr(sh,r);return c.jsx(Be.button,{type:"button",...n,ref:t,onClick:Me(e.onClick,()=>o.onOpenChange(!1))})});ih.displayName=sh;function Ql(e){return e?"open":"closed"}var ah="DialogTitleWarning",[XP,lh]=Ov(ah,{contentName:Gn,titleName:Jl,docsSlug:"dialog"}),UE=({titleId:e})=>{const t=lh(ah),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},LE="DialogDescriptionWarning",DE=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${oh(LE).contentName}}.`;return b.useEffect(()=>{const o=e.current?.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},BE=Gm,$E=Ym,jE=Xm,zE=Jm,UE=Zm,VE=rh;function HE({...e}){return c.jsx(BE,{"data-slot":"dialog",...e})}function WE({...e}){return c.jsx($E,{"data-slot":"dialog-portal",...e})}function RE({className:e,...t}){return c.jsx(jE,{"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 GE({className:e,children:t,showCloseButton:r=!0,...n}){return c.jsxs(WE,{"data-slot":"dialog-portal",children:[c.jsx(RE,{}),c.jsxs(zE,{"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(VE,{"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(Ko,{}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function KE({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 qE({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 YE({className:e,...t}){return c.jsx(UE,{"data-slot":"dialog-title",className:B("text-lg leading-none font-semibold",e),...t})}async function XE(){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 ih=({open:e,onOpenChange:t,onCaptured:r,validateFile:n,accept:o,disabled:s,onValidationMessage:i})=>{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(C=>C.stop()),u.current=null),h()},[h]);S.useEffect(()=>{if(!e){y(),p(null),g(!1);return}if(s)return;let C=!1;return p(null),g(!0),XE().then(N=>{if(C){N.getTracks().forEach(_=>_.stop());return}u.current=N,g(!1)}).catch(N=>{if(C)return;g(!1);const _=N instanceof Error?N.message:"Could not access camera";p(_)}),()=>{C=!0,u.current&&(u.current.getTracks().forEach(N=>N.stop()),u.current=null),h()}},[e,s,y,h]);const v=S.useCallback(C=>{a.current=C,C&&u.current&&e&&!f&&!m&&(C.srcObject=u.current,sh(C))},[e,f,m]);S.useLayoutEffect(()=>{if(!e||f||m||!u.current)return;let C=!1,N=0;const _=()=>{if(C)return;const I=a.current;!I||!u.current||(I.srcObject=u.current,sh(I))};_();const A=requestAnimationFrame(()=>{_(),N=requestAnimationFrame(_)});return()=>{C=!0,cancelAnimationFrame(A),cancelAnimationFrame(N),h()}},[e,f,m,h]);const w=S.useCallback(()=>{y(),p(null),g(!1),t(!1),l.current&&(l.current.value="")},[y,t]),x=S.useCallback(()=>{const C=a.current,N=d.current;if(!C||!N||!u.current||C.readyState<2)return;const _=C.videoWidth,A=C.videoHeight;if(_===0||A===0)return;N.width=_,N.height=A;const I=N.getContext("2d");I&&(I.drawImage(C,0,0),N.toBlob(T=>{if(!T)return;const U=new File([T],`camera-capture-${Date.now()}.jpg`,{type:"image/jpeg",lastModified:Date.now()}),Q=n(U);if(Q){i?.(Q);return}i?.(void 0),r(U),w()},"image/jpeg",.92))},[r,n,w,i]),E=S.useCallback(C=>{const N=C.target.files?.[0];if(!N)return;const _=n(N);if(_){i?.(_);return}i?.(void 0),r(N),w(),l.current&&(l.current.value="")},[r,n,w,i]),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:E,className:"hidden","aria-hidden":!0}),c.jsx("canvas",{ref:d,className:"hidden","aria-hidden":!0}),c.jsx(HE,{open:e,onOpenChange:C=>{C||w()},children:c.jsxs(GE,{className:"sm:max-w-md",showCloseButton:!0,onPointerDownOutside:C=>C.preventDefault(),children:[c.jsx(KE,{children:c.jsx(YE,{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(Yt,{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:v,playsInline:!0,muted:!0,className:"w-full h-full object-cover"})}),c.jsxs(qE,{className:"gap-2 sm:gap-0",children:[c.jsx(Yt,{type:"button",variant:"outline",onClick:w,children:"Cancel"}),c.jsx(Yt,{type:"button",onClick:x,children:"Capture photo"})]})]})]})})]})},JE=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,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"),v=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,w=e.validation?.find(K=>K.type==="fileSize"),x=e.validation?.find(K=>K.type==="fileType"),E=w?.value!=null?w.value:d?.maxSize??v?.maxSize??5*1024*1024,P=x?.value!=null?x.value:d?.accept??v?.accept??["image/*"],C=P.join(",")||"image/*",N=Is(e),_=S.useCallback(K=>{if(w){const X=Yr(K,w);if(X!==!0)return typeof X=="string"?X:"File size exceeds the maximum allowed size"}else if(K.size>E)return`File size must be less than ${yo(E)}`;if(x){const X=Yr(K,x);if(X!==!0)return typeof X=="string"?X:"File type is not allowed"}return null},[w,x,E]),A=S.useMemo(()=>Ms(t),[t]),I=Gl(A),T=S.useCallback(K=>{const X=Na(K,N);r(X),n?.()},[r,n,N]),U=S.useCallback(K=>{const X=_(K);if(X){l(X);return}l(void 0);const ce=[...A];ce.length>=N||(ce.push(K),T(ce),y("none"))},[A,N,_,T]),Q=S.useCallback(K=>{const X=A.filter((ce,ne)=>ne!==K);T(X)},[A,T]),O=S.useCallback(()=>{s||A.length>=N||(l(void 0),y("camera"),p(!0))},[s,A.length,N]),j=S.useCallback(K=>{p(K),K||y("none")},[]),L=o||u,D=e.appearance?.hideLabel??!1,M=[];(w||E)&&M.push(`Max size: ${yo(E)}`),x&&P.length>0&&M.push(`Allowed: ${P.join(", ")}`),N>1&&M.push(`Up to ${N} photos`);const R=S.useCallback(K=>{window.open(K,"_blank","noopener,noreferrer")},[]),$=A.length===0,ie=A.length<N,V=Hl(N,A.length);return c.jsxs(Et,{field:e,error:L,isRequired:i,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:s||!ie?-1:0,id:ht(e),onClick:K=>{s||K.target.closest("[data-remove-in-dropzone]")||K.target.closest("[data-no-open-picker]")||A.length>=N||O()},onKeyDown:K=>{(K.key==="Enter"||K.key===" ")&&(K.preventDefault(),!s&&ie&&O())},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",L&&"border-destructive",s&&"opacity-50 cursor-not-allowed",f&&h==="camera"&&"opacity-70 pointer-events-none",!ie&&A.length>0&&"cursor-default"),"aria-describedby":jt(e,!!L),"aria-invalid":Jt(!!L),"aria-required":i,children:$?c.jsxs(c.Fragment,{children:[c.jsx(zs,{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(" • ")})]}):V?c.jsx(Kl,{item:A[0],objectUrl:I[0]??null,failedUrlKeys:m,onImageUrlError:K=>g(X=>new Set(X).add(K)),onRemove:()=>Q(0),onOpenUrl:R,disabled:s}):c.jsx(Rl,{items:A,maxFiles:N,disabled:s,objectUrls:I,failedUrlKeys:m,onImageUrlError:K=>g(X=>new Set(X).add(K)),onRemove:Q,onOpenUrl:R,addSlot:ie?c.jsxs("button",{type:"button","data-no-open-picker":!0,onClick:K=>{K.stopPropagation(),O()},disabled:s,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(zs,{className:"h-4 w-4 mb-0.5","aria-hidden":!0}),"Add"]}):void 0})})}),c.jsx(ih,{open:f,onOpenChange:j,onCaptured:U,validateFile:_,accept:C,disabled:s,onValidationMessage:l})]})},QE=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,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),[v,w]=S.useState("none"),x=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,E=e.validation?.find(oe=>oe.type==="fileSize"),P=e.validation?.find(oe=>oe.type==="fileType"),C=E?.value?E.value:u?.maxSize??x?.maxSize??5*1024*1024,N=P?.value?P.value:u?.accept??x?.accept??["image/*"],_=Array.isArray(N)?N.join(","):"image/*",A=Is(e),I=S.useCallback(oe=>{if(E){const re=Yr(oe,E);if(re!==!0)return typeof re=="string"?re:"File size exceeds the maximum allowed size"}else if(oe.size>C)return`File size must be less than ${yo(C)}`;if(P){const re=Yr(oe,P);if(re!==!0)return typeof re=="string"?re:"File type is not allowed"}return null},[E,P,C]),T=S.useMemo(()=>Ms(t),[t]),U=Gl(T),Q=S.useCallback(oe=>{const re=Na(oe,A);r(re),n?.()},[r,n,A]),O=S.useCallback(oe=>{p(void 0);const re=Array.from(oe),be=[...T];let de=null;for(const ot of re){if(be.length>=A)break;const Se=I(ot);if(Se){de||(de=Se);continue}be.push(ot)}if(de&&be.length===T.length){p(de);return}de&&p(de),Q(be),w("none")},[T,A,I,Q]),j=S.useCallback(oe=>{const re=oe.target.files;re&&re.length>0&&O(re),l.current&&(l.current.value="")},[O]),L=S.useCallback(oe=>{Q(T.filter((re,be)=>be!==oe))},[T,Q]),D=S.useCallback(()=>{s||T.length>=A||m||(p(void 0),w("file"),l.current?.click())},[s,T.length,A,m]),M=S.useCallback(()=>{s||T.length>=A||(p(void 0),w("camera"),g(!0))},[s,T.length,A]),R=S.useCallback(oe=>{const re=I(oe);if(re){p(re);return}p(void 0);const be=[...T];be.length>=A||(be.push(oe),Q(be),w("none"))},[T,A,I,Q]),$=S.useCallback(oe=>{g(oe),oe||w("none")},[]),ie=o||f,V=e.appearance?.hideLabel??!1,K=[];(E||C)&&K.push(`Max size: ${yo(C)}`),P&&N.length>0&&K.push(`Allowed: ${N.join(", ")}`),A>1&&K.push(`Up to ${A} photos`);const X=S.useMemo(()=>{if(!d)return null;const oe=Object.values(d);for(let re=oe.length-1;re>=0;re-=1){const be=oe[re],de=typeof be?.status=="string"?be.status.toLowerCase():null;if(de&&de!=="success")continue;const ot=be?.code;if(typeof ot=="number"&&(ot<200||ot>=300))continue;const Se=be?.data,xe=Se?.file_url||Se?.fileUrl||be?.file_url||be?.fileUrl;if(typeof xe=="string"&&xe.trim())return xe.trim()}return null},[d]),ce=S.useCallback(oe=>{window.open(oe,"_blank","noopener,noreferrer")},[]),ne=T.length===0,G=T.length<A,ee=Hl(A,T.length),Pe=G&&!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:s,onClick:oe=>{oe.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(Vs,{className:"h-4 w-4","aria-hidden":!0})}),c.jsx("button",{type:"button",disabled:s,onClick:oe=>{oe.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(zs,{className:"h-4 w-4","aria-hidden":!0})})]}):void 0;return c.jsxs(Et,{field:e,error:ie,isRequired:i,className:B(a,"!space-y-0"),hideLabel:V,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",ie&&"border-destructive",s&&"opacity-50"),children:[c.jsx("input",{ref:l,id:ht(e),type:"file",accept:_,multiple:A>1,onChange:j,disabled:s||e.disabled||m||!G,className:"hidden","aria-describedby":jt(e,!!ie),"aria-invalid":Jt(!!ie),"aria-required":i}),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:s||m,onClick:D,className:B("inline-flex flex-col items-center gap-0.5 text-[11px] text-muted-foreground hover:text-foreground",s&&"pointer-events-none"),children:[c.jsx(Vs,{className:"h-5 w-5","aria-hidden":!0}),c.jsx("span",{children:"Upload"})]}),c.jsxs("button",{type:"button",disabled:s,onClick:M,className:B("inline-flex flex-col items-center gap-0.5 text-[11px] text-muted-foreground hover:text-foreground",s&&"pointer-events-none",m&&"opacity-70"),children:[c.jsx(zs,{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(" • ")})]}):ee?c.jsx(Kl,{item:T[0],objectUrl:U[0]??null,failedUrlKeys:h,onImageUrlError:oe=>y(re=>new Set(re).add(oe)),onRemove:()=>L(0),onOpenUrl:ce,openTarget:T[0]instanceof File?X:void 0,disabled:s||e.disabled}):c.jsx(Rl,{items:T,maxFiles:A,disabled:s,objectUrls:U,failedUrlKeys:h,onImageUrlError:oe=>y(re=>new Set(re).add(oe)),onRemove:L,resolveOpenUrl:(oe,re)=>re instanceof File&&T.length===1&&X?X:null,onOpenUrl:oe=>{oe?.trim()&&ce(oe.trim())},addSlot:Pe})]})}),c.jsx(ih,{open:m,onOpenChange:$,onCaptured:R,validateFile:I,accept:_,disabled:s,onValidationMessage:p})]})};function ls(e){if(e instanceof Error){const t=e.message;if(t&&(t.includes("{")||t.includes("[")))try{const r=t.match(/\{[\s\S]*\}/);if(r){const n=JSON.parse(r[0]);return bo(n)}}catch{}if(e.response){const r=e.response;if(typeof r=="string")try{const n=JSON.parse(r);return bo(n)}catch{return r}else if(typeof r=="object")return bo(r)}return t}if(e instanceof NA)return e.response?.data?bo(e.response.data):e.message||"An unexpected error occurred";if(typeof e=="string")try{const t=JSON.parse(e);return bo(t)}catch{return e}return typeof e=="object"&&e!==null?bo(e):"An unexpected error occurred"}function bo(e){if(e?.display_message&&typeof e.display_message=="string")return e.display_message.trim();if(e?.errors&&Array.isArray(e.errors)){const t=e.errors.filter(r=>r&&typeof r=="string");if(t.length>0)return t.join(". ")}if(e?.error?.explanation&&Array.isArray(e.error.explanation)){const t=e.error.explanation.filter(r=>r&&typeof r=="string");if(t.length>0)return t.join(". ")}if(e?.explanation&&Array.isArray(e.explanation)){const t=e.explanation.filter(r=>r&&typeof r=="string");if(t.length>0)return t.join(". ")}if(e?.errors&&Array.isArray(e.errors)){const t=e.errors.filter(r=>r!=null&&String(r).trim());if(t.length>0)return t.map(r=>typeof r=="string"?r:r?.message||String(r)).join(". ")}return e?.message&&typeof e.message=="string"?e.message:e?.display_message&&typeof e.display_message=="string"?e.display_message:e?.error?.display_message&&typeof e.error.display_message=="string"?e.error.display_message:e?.error?.message&&typeof e.error.message=="string"?e.error.message:e?.error&&typeof e.error=="string"?e.error:"An unexpected error occurred"}function ZE(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=ZE(e);$t.toast.success(r&&r.trim()?r:t)}catch{$t.toast.success(t)}}function Jl(e,t,r){try{const n=r(e);$t.toast.error(n&&n.trim()?n:t)}catch{$t.toast.error(t)}}function tN(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 ji="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 Ql(e,t){if(!e)return"Please complete the required fields.";if(Array.isArray(e)){const s=e.map(i=>{const a=i.message||ji;if(t?.length&&i.field){const d=ah(i.field,t);return a===ji?`${d} is required`:`${d}: ${a}`}return a}).filter(i=>typeof i=="string"&&i.length>0);return s.length===0?"Please complete the required fields.":s.length===1?s[0]:`${s[0]} (and ${s.length-1} more)`}const n=Object.entries(e).map(([o,s])=>{const i=s?.trim()||ji;if(t?.length){const a=ah(o,t);return i===ji?`${a} is required`:`${a}: ${i}`}return i}).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)`}const rN=/^\{([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\}$/i;function lh(e){const t=e.trim().match(rN);return t?t[1]:e}const nN={applicantId:["id","applicant_id"],applicant_id:["id","applicantId"],id:["applicantId","applicant_id"]};function rn(e,t,r,n,o,s){let i=e;if(o&&typeof e=="string"&&(i=i.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=tt(p,f);return m==null?a:String(m)}),i.includes("{documentId}")||i.includes("%7BdocumentId%7D"))){let a;for(const d of Object.values(o)){const u=tt(d,"data.id")??tt(d,"data.documentId");if(u!=null){a=String(u);break}}a&&(i=i.replace(/\{documentId\}/g,a).replace(/%7BdocumentId%7D/gi,a))}if(i.includes("{documentId}")||i.includes("%7BdocumentId%7D")){let a;const d=t?.documentId??(t&&tt(t,"documentId")),u=n?.documentId??(n&&tt(n,"documentId"));d!=null&&d!==""?a=String(d):u!=null&&u!==""&&(a=String(u)),a&&(i=i.replace(/\{documentId\}/g,a).replace(/%7BdocumentId%7D/gi,a))}return i=i.replace(/\{api:([^}]+)\}/g,(a,d)=>{const u=d.trim();if(s==null||u==="")return a;const l=tt(s,u);return l==null?a:String(l)}),i=i.replace(/\{(?:ctx:|\@)(\w+)\}/g,(a,d)=>n&&n[d]!==void 0&&n[d]!==null?String(n[d]):a),i=i.replace(/\{(\w+)\}/g,(a,d)=>{if(a.includes("ctx:")||a.includes("@"))return a;const u=r[d];if(u!=null)return lh(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=nN[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!==""?lh(String(l)):a}),i}function Zl(e,t){if(!t?.length)return e;const r=new Map;for(const o of t){const s=o.name||o.key||o.id;s&&r.set(s,o)}const n={};for(const[o,s]of Object.entries(e)){const i=r.get(o);if(i?.type==="selectablelist"&&Array.isArray(s)&&s.length>0){const a=i.properties,d=i.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=s.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]=tt(p,h));return m});n[o]=f;continue}}n[o]=s}return n}function zi(e){return!!(e instanceof File||Array.isArray(e)&&e.length>0&&e[0]instanceof File)}function oN(e){return Object.values(e).some(t=>zi(t))}function sN(e,t){const r=new FormData;let n=!1;return Object.entries(e).forEach(([o,s])=>{const i=t?.[o]||o;s instanceof File?(r.append(i,s),n=!0):Array.isArray(s)&&s.length>0&&s[0]instanceof File?(s.forEach(a=>{r.append(i,a)}),n=!0):s!=null&&(typeof s=="object"?r.append(i,JSON.stringify(s)):r.append(i,String(s)))}),n?r:null}function iN(e,t,r){const n={};let o=!1;return Object.entries(e).forEach(([s,i])=>{const a=t?.[s]||s;if(zi(i)){n[a]=i,o=!0;return}const d=r?.[s]||"string";let u=i;if(d==="number"){const l=Number(i);u=isNaN(l)?i:l}else d==="boolean"?u=i==="true"||i===!0||i==="1"||i===1:d==="date"?u=String(i):i!=null?u=typeof i=="object"?i:String(i):u="";n[a]=u}),{transformed:n,hasFiles:o}}const ch=Object.freeze(Object.defineProperty({__proto__:null,hasFileValues:oN,isFileValue:zi,prepareFormDataWithFiles:sN,transformFormValuesWithFiles:iN},Symbol.toStringTag,{value:"Module"}));function aN(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():"",s=typeof n.name=="string"&&n.name.trim()?n.name.trim():"";if(!o||!s)continue;const i=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:s,fieldNames:i,...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 dh(e){return e?.mode==="nested_by_section"}function uh(e){const t=e.payloadKey?.trim();return t||null}function fh(e,t){return t.fieldPayloadKeys?.[e]?.trim()||e}function ph(e,t,r,n){if(!dh(r)||!t?.length)return{...e};const o=new Set([]),s=r?.includeUnassignedAtRoot!==!1,i=new Set,a={};for(const d of t){const u=uh(d);if(!u)continue;const l={};for(const f of d.fieldNames){if(o.has(f)||!(f in e))continue;i.add(f);const p=fh(f,d);l[p]=e[f]}Object.keys(l).length>0&&(a[u]=l)}if(s)for(const[d,u]of Object.entries(e))o.has(d)||i.has(d)||(a[d]=u);return a}function cN(e,t,r){const n={...e??{}};if(!dh(r)||!t?.length)return n;for(const o of t){const s=uh(o);if(s)for(const i of o.fieldNames){if(n[i]?.trim())continue;const a=fh(i,o);n[i]=`${s}.${a}`}}return n}function dN(e){return e==="null"?null:e==="true"?!0:e==="false"?!1:e}function uN(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 fN(e,t){if(!t)return[];const r=e.trim().split(".");if(r.length<2)return[];const n=r[0],o=r.slice(1).join("."),s=[];return Object.entries(t).forEach(([i,a])=>{const d=i===n,u=i.startsWith(`${n}__addmore__`);if(!d&&!u||!uN(a))return;const l=tt(a,o);l==null||l===""||s.push(l)}),s}function Ui(e,t,r,n,o,s){const i=e.trim().match(/^\{respAll:([^}]+)\}$/);if(i){const u=(i[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:fN(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=rn(e,t,r,n,o,s);return dN(String(d))}const pN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d,onClick:u,onSubmit:l,onReset:f,onCancel:p,isSubmitting:m=!1,formValues:g={},submissionContext:h,bffSubmitApi:y,onBffSubmitResult:v,extraSubmitPayload:w,buttonResponses:x,onButtonApiResponse:E,onValidateForm:P,getValidationErrors:C,allFields:N,onSubmittingChange:_,scopedFormValues:A,scopedFieldNameMap:I,prepopulateResponse:T=null,formSections:U,submitPayload:Q})=>{const{gridStretch:O}=zo(),[j,L]=S.useState(!1),D=e.properties,M=pa.useParams(),R=S.useMemo(()=>({...h,...w}),[h,w]),$=S.useMemo(()=>{if(!A||!I||Object.keys(I).length===0)return g;const Je={};return Object.entries(A).forEach(([q,$e])=>{const gt=I[q]||q;gt!==e.name&&(Je[gt]=$e)}),Je},[A,I,g,e.name]),V=(()=>{try{const Je=e.metadata;if(typeof Je=="string")return JSON.parse(Je);if(Je&&typeof Je=="object")return Je}catch{}return null})(),K=D?.submitAction??V?.submitAction,X=D?.apiEndpoint??e.apidata?.apiEndpoint??V?.apiEndpoint;let ce=D?.action||V?.action;!ce&&e.type==="button"&&(ce="submit");const ne=D?.variant||"default",G=D?.size||"default",ee=D?.hideLabel??e.appearance?.hideLabel??!1,Pe=D?.buttonText||e.label||"Button",oe=D?.closeOnCancel??!0,re=async()=>{if(A&&I&&Object.keys(I).length>0||!P)return!0;const Je=await P();if(!Je&&C)try{const q=C();$t.toast.error(Ql(q,N??void 0)||"Please fix the errors before submitting.")}catch{$t.toast.error("Please fix the errors before submitting.")}return Je},be=async Je=>{if(Je.preventDefault(),(ce==="submit"?"submit":ce)==="submit"){if(y?.url){if(!await re())return;L(!0),_?.(!0);try{const $e=await ot(),gt=($e?.message??$e?.display_message??"Form submitted successfully!").trim();$t.toast.success(gt||"Form submitted successfully!");const Oe=$e!=null&&typeof $e=="object"?$e:{status:"success",...$e!=null?{data:$e}:{}};E?.(e.name,Oe)}catch($e){const gt=ls($e);$t.toast.error(gt)}finally{L(!1),_?.(!1)}return}if(l){if(!await re())return;L(!0),_?.(!0);try{await l(),E?.(e.name,{status:"success"})}finally{L(!1),_?.(!1)}return}$t.toast.error("Submit not configured. BFF submit API is required for submit buttons.");return}else if(ce==="reset"&&f)f();else if(ce==="cancel")oe?p&&p():f&&f();else if(ce==="download"){const $e=D?.downloadApiEndpoint||V?.downloadApiEndpoint||e.downloadApiEndpoint,gt=D?.downloadApiMethod||V?.downloadApiMethod||e.downloadApiMethod;if($e){L(!0);try{const Oe=gt||"GET",te=cn(rn($e,$,M,R,x,T??void 0)),pe={method:Oe,headers:{}};Oe!=="GET"&&Oe!=="DELETE"&&(pe.headers={"Content-Type":"application/json"});const We=await fetch(te,pe);if(!We.ok)throw new Error(`Download failed: ${We.statusText}`);const Pt=await We.blob(),je=window.URL.createObjectURL(Pt),Te=document.createElement("a");Te.href=je;const Xe=We.headers.get("Content-Disposition");let Ue="download";if(Xe){const ft=Xe.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);ft&&ft[1]&&(Ue=ft[1].replace(/['"]/g,""))}Te.download=Ue,document.body.appendChild(Te),Te.click(),document.body.removeChild(Te),window.URL.revokeObjectURL(je);try{const ft=tN(We);$t.toast.success(ft&&ft.trim()?ft:"Download started.")}catch{$t.toast.success("Download started.")}}catch(Oe){Jl(Oe,"Failed to download file. Please check the API endpoint and try again.",ls)}finally{L(!1)}}else $t.toast.error("Download endpoint is not configured")}else if(ce==="upload"||ce==="custom"){const $e=ce==="custom",gt=$e?"api":D?.uploadAction||V?.uploadAction||"database";if(gt==="database")if(l){L(!0);try{await l(Je)}catch(Oe){throw Oe}finally{L(!1)}}else $t.toast.error("Form submit handler is not available");else if(gt==="api"){const Oe=D?.uploadApiEndpoint||V?.uploadApiEndpoint||e.uploadApiEndpoint;if(D?.uploadApiMethod||V?.uploadApiMethod||e.uploadApiMethod,Oe){if(!await re())return;L(!0);try{const te=await Se();E?.(e.name,te),eN(te,$e?"Custom API call completed successfully!":"Upload completed successfully!")}catch(te){E?.(e.name,{status:"error",code:te?.response?.code??te?.response?.status??null,message:ls(te)}),Jl(te,$e?"Failed to call custom API. Please check the API endpoint and try again.":"Failed to upload. Please check the API endpoint and try again.",ls)}finally{L(!1)}}else $t.toast.error($e?"Custom API endpoint is not configured":"Upload endpoint is not configured")}else gt==="custom"&&$t.toast.info("Custom upload handler is not implemented")}else u?u():r&&t!==void 0&&r(t||"");n?.()},de=async()=>{if(!K||K!=="api"||!X)return null;const Je=D?.apiBodyFields??V?.apiBodyFields;if((D?.apiBodyFieldsOnly??V?.apiBodyFieldsOnly??!1)&&Je?.length){const Te={};return Je.forEach(({key:Xe,value:Ue})=>{const ft=Ui(Ue,$,M,R,x,T??void 0),St=Xe==="user_id"?"context_user_id":Xe;Te[St]=ft}),Te.user_id!==void 0&&Te.user_id!==null&&(Te.context_user_id=Te.context_user_id??Te.user_id,delete Te.user_id),Te}const $e=N?.length?Zl($,N):$,gt=D?.apiFieldMapping??V?.apiFieldMapping,Oe=D?.apiFieldTypes??V?.apiFieldTypes,te=D?.apiBodyStructure??V?.apiBodyStructure,pe={...Oe};N?.length&&N.forEach(Te=>{const Xe=Te.name||Te.key;Xe&&(Te.type==="terms"||Te.type==="checkbox")&&(pe[Xe]="boolean")});const{transformFormValuesWithFiles:We}=await Promise.resolve().then(()=>ch),{transformed:Pt}=We($e,gt,pe);let je={};if(te==="flat"?je={...Pt}:je={data:{...Pt}},gt){const Te={};Object.keys(je).forEach(Xe=>{const Ue=gt[Xe]||Xe;Te[Ue]=je[Xe]}),je=Te}return Je?.length&&Je.forEach(({key:Te,value:Xe})=>{const Ue=Ui(Xe,$,M,R,x,T??void 0),ft=Te==="user_id"?"context_user_id":Te;je[ft]=Ue}),je.user_id!==void 0&&je.user_id!==null&&(je.context_user_id=je.context_user_id??je.user_id,delete je.user_id),je.data?.user_id!==void 0&&je.data?.user_id!==null&&(je.data.context_user_id=je.data.context_user_id??je.data.user_id,delete je.data.user_id),je},ot=async()=>{if(!y||!y.url)throw new Error("BFF submit API configuration is missing");const Je=N?.length?Zl(g,N):g,q={};Object.keys(Je).forEach(ze=>{const yt=e.name===ze&&e.type==="button",pt=ze.toLowerCase().includes("button");!yt&&!pt&&(q[ze]=Je[ze])});const $e=Object.keys(q).filter(ze=>zi(q[ze]));$e.forEach(ze=>{q[ze]=""});const gt=ph(q,U,Q),Oe={workflow_id:y.payload?.workflow_id||"",current_step_id:y.payload?.current_step_id||"",form_data:gt},te=["workflow_id","current_step_id","form_data","submit_body","submit_api_endpoint","submit_api_method"];if(h&&typeof h=="object"&&Object.entries(h).forEach(([ze,yt])=>{if(yt==null||te.includes(ze))return;const pt=ze==="user_id"?"context_user_id":ze;Oe[pt]=Oe[pt]??yt}),w&&typeof w=="object"&&Object.entries(w).forEach(([ze,yt])=>{if(yt==null||te.includes(ze))return;const pt=ze==="user_id"?"context_user_id":ze;Oe[pt]=Oe[pt]??yt}),K==="api"&&X)try{const ze=await de();if(ze){const yt=D?.apiBodyStructure??V?.apiBodyStructure,pt=D?.apiFieldMapping??V?.apiFieldMapping;$e.forEach(Ut=>{const ur=pt?.[Ut]??Ut,Ar=q[Ut]!==void 0&&typeof q[Ut]=="string"?q[Ut]:"";yt==="flat"?ze[ur]=Ar:ze.data&&typeof ze.data=="object"?ze.data[ur]=Ar:ze[ur]=Ar}),Oe.submit_body=ze;let At=rn(X,$,M,R,x,T??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=cn(At),Oe.submit_api_endpoint=At,Oe.submit_api_method=D?.submitApiMethod||V?.submitApiMethod||"POST"}}catch{}const pe=(y.method||"POST").toUpperCase(),We=$e.length>0,Pt=Oe.submit_api_endpoint??X??"",je=typeof Pt=="string"?Pt.toLowerCase():"",Te=je.includes("/upload")||je.includes("/payments")||je.includes("/bulk-upload"),Xe=We&&Te;let Ue;const ft={...y.headers||{}};if(Xe){const ze=new FormData;ze.append("payload",JSON.stringify(Oe));for(const yt of $e){const pt=Je[yt],At=D?.apiFieldMapping?.[yt]??yt;pt instanceof File?ze.append(At,pt):Array.isArray(pt)&&pt.length>0&&pt[0]instanceof File&&pt.forEach(Ut=>ze.append(At,Ut))}Ue=ze,delete ft["content-type"],delete ft["Content-Type"]}else ft["Content-Type"]="application/json",Ue=JSON.stringify(Oe);const St=await fetch(y.url,{method:pe,headers:ft,body:Ue});if(!St.ok){let ze;const yt=await St.text();try{ze=JSON.parse(yt)}catch{ze={message:yt}}const pt=new Error(`BFF submission failed: ${St.status}`);throw pt.response=ze,pt}const xt=await St.json();return v?.(xt),l&&await l(),xt},Se=async()=>{const Je=D?.uploadApiEndpoint||V?.uploadApiEndpoint;if(!Je)throw new Error("Upload API endpoint is not configured");if(!D)throw new Error("Button properties are not configured");const q=(D.uploadApiMethod||"POST").toUpperCase(),$e=cn(rn(Je,$,M,R,x,T??void 0)),gt=D.apiBodyFieldsOnly??V?.apiBodyFieldsOnly??!1,Oe=D.apiBodyFieldsOnlyFormat??V?.apiBodyFieldsOnlyFormat??"json";let te={},pe;const We={};if(gt&&D.apiBodyFields&&D.apiBodyFields.length>0)if(D.apiBodyFields.forEach(({key:Te,value:Xe})=>{te[Te]=Ui(Xe,$,M,R,x,T??void 0)}),Oe==="multipart"){const Te=new FormData;Object.entries(te).forEach(([Xe,Ue])=>{if(Ue instanceof File){Te.append(Xe,Ue);return}if(Array.isArray(Ue)&&Ue.length>0&&Ue[0]instanceof File){Ue.forEach(ft=>Te.append(Xe,ft));return}Ue!=null&&Te.append(Xe,typeof Ue=="object"?JSON.stringify(Ue):String(Ue))}),pe=Te}else pe=JSON.stringify(te),We["Content-Type"]="application/json";else{const Te=$,{transformFormValuesWithFiles:Xe,prepareFormDataWithFiles:Ue,hasFileValues:ft}=await Promise.resolve().then(()=>ch),{transformed:St,hasFiles:xt}=Xe(Te,D.apiFieldMapping,D.apiFieldTypes);if((D.apiBodyStructure??V?.apiBodyStructure??"nested")==="flat"?te={...St}:te={data:{...St}},D.apiFieldMapping){const yt={};Object.keys(te).forEach(pt=>{const At=D.apiFieldMapping[pt]||pt;yt[At]=te[pt]}),te=yt}if(D.apiBodyFields&&D.apiBodyFields.forEach(({key:yt,value:pt})=>{te[yt]=Ui(pt,$,M,R,x,T??void 0)}),xt||ft(te)){const yt=Ue(te,D.apiFieldMapping);yt?pe=yt:(pe=JSON.stringify(te),We["Content-Type"]="application/json")}else pe=JSON.stringify(te),We["Content-Type"]="application/json"}D.apiHeaders&&D.apiHeaders.forEach(({key:Te,value:Xe})=>{const Ue=rn(Xe,$,M,R,x,T??void 0);(Te.toLowerCase()!=="content-type"||!(pe instanceof FormData))&&(We[Te]=Ue)});let Pt=$e;if(D.apiQueryParams&&D.apiQueryParams.length>0){const Te=new URLSearchParams;D.apiQueryParams.forEach(({key:Xe,value:Ue})=>{const ft=rn(Ue,$,M,R,x,T??void 0);Te.append(Xe,ft)}),Pt=`${$e}?${Te.toString()}`}const je=await fetch(Pt,{method:q,headers:We,body:q!=="GET"?pe:void 0});if(!je.ok){let Te;const Xe=await je.text();try{Te=JSON.parse(Xe)}catch{Te={message:Xe}}const Ue=new Error(`Upload failed: ${je.status}`);throw Ue.response=Te,Ue}try{return await je.json()}catch{return{}}},xe=ce==="submit"?"submit":ce,ve=xe==="submit"?"button":xe==="submit"?"submit":xe==="reset"?"reset":"button",Ye=s||e.disabled||i||e.readOnly||j||xe==="submit"&&m,ct=Pe,Ge=to(e),Kt=Fr(e.appearance)==="stretch";return c.jsx(Et,{field:e,error:o,isRequired:a,className:d,hideLabel:ee,children:c.jsx("div",{className:B(O&&!Ge&&"flex w-full min-w-0 flex-col",O&&Ge&&"min-w-0 shrink-0"),children:c.jsxs(Yt,{id:ht(e),type:ve,variant:ne,size:G,disabled:Ye,onClick:be,className:B(e.appearance?.className,O&&!Ge&&"w-full min-w-0 shrink-0",O&&Ge&&!Kt&&"inline-flex w-auto max-w-full shrink-0",O&&Ge&&Kt&&"inline-flex w-full min-w-0 max-w-full shrink-0"),children:[j&&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}),ct]})})})},mN=({field:e,disabled:t,readOnly:r,isRequired:n,className:o,buttonResponses:s,onButtonApiResponse:i})=>{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=Uo(s?.[p]),g=t||e.disabled||r||e.readOnly||m,h=y=>{y.preventDefault(),!g&&i?.(p,{status:"success"})};return c.jsx(Et,{field:e,error:void 0,isRequired:n,className:o,hideLabel:f,children:c.jsx(Yt,{id:ht(e),type:"button",variant:u,size:l,disabled:g,onClick:h,className:B(e.appearance?.className,(!to(e)||Fr(e.appearance)==="stretch")&&"w-full min-w-0"),children:d})})},hN=({field:e,error:t,disabled:r,readOnly:n,isRequired:o,className:s,onAddMore:i})=>{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(Et,{field:e,error:t,isRequired:o,className:s,hideLabel:f,children:c.jsxs(Yt,{id:ht(e),type:"button",variant:d,size:u,disabled:!!p,onClick:i,className:B("w-fit",e.appearance?.className),children:[c.jsx(Zd,{className:"h-4 w-4 mr-1"}),l]})})},mh=S.createContext(null);function gN({value:e,children:t}){return c.jsx(mh.Provider,{value:e,children:t})}function yN(){return S.useContext(mh)}function hh(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(0,t):e}function cs(e){return e.name||e.key||e.id}function ec(e){return e.filter(t=>!t.parentId&&t.type==="sectionHeading"&&cs(t))}function bN(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 ec(e)){const n=cs(r);for(const o of bN(r))t.set(o,n)}return t}function wN(e,t){const r=t.properties||{},n=Array.isArray(r.sectionHeadingNames)?r.sectionHeadingNames.filter(i=>typeof i=="string"&&i.trim()):[],o=ec(e);if(n.length===0)return o;const s=new Set(n);return o.filter(i=>s.has(cs(i)))}function SN(e){const t={};for(const r of ec(e))t[cs(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 gh(e,t,r,n){if(!e||t==="customizeSections")return!0;const o=hh(e),s=t==="sectionHeading"?o:n.get(o);return s?r[s]!==!1:!0}const xN=({field:e,error:t,disabled:r,readOnly:n,isRequired:o,className:s,designMode:i=!1})=>{const a=yN(),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?wN(a.allFields,e):[],[a?.allFields,e]);return c.jsx(Et,{field:e,error:t,isRequired:o,className:s,hideLabel:m,children:c.jsxs(Fl,{children:[c.jsx(jp,{asChild:!0,children:c.jsxs(Yt,{id:ht(e),type:"button",variant:u,size:l,disabled:!!g,className:B("w-fit gap-2",e.appearance?.className),children:[c.jsx(Av,{className:"h-4 w-4"}),f]})}),c.jsxs(Pl,{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 v=cs(y),w=y.label||v,x=i||!a?!0:a.visibility[v]!==!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(Sn,{htmlFor:`ui-section-${e.id}-${v}`,className:"text-xs font-normal truncate",children:w}),c.jsx(xm,{id:`ui-section-${e.id}-${v}`,checked:x,disabled:i||!a||!!g,onCheckedChange:E=>{!a||i||a.setSectionVisible(v,!!E)}})]},y.id)})})]})]})})},AN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=e.properties,l=u?.max||5,f=u?.icon||"star",p=h=>{s||i||e.disabled||e.readOnly||(r(h),n?.())},m=h=>{},g=h=>{const y=t>=h+1,v=B("transition-colors cursor-pointer",y?"fill-yellow-400 text-yellow-400":"text-muted-foreground",(s||i||e.disabled||e.readOnly)&&"cursor-not-allowed opacity-50",!(s||i||e.disabled||e.readOnly)&&"hover:text-yellow-400");return f==="star"?c.jsx(eu,{className:B(v,"h-6 w-6"),onClick:()=>p(h+1),onMouseEnter:()=>m()},h):c.jsx(eu,{className:B(v,"h-6 w-6"),onClick:()=>p(h+1),onMouseEnter:()=>m()},h)};return c.jsx(Et,{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":jt(e,!!o),"aria-invalid":Jt(!!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 yh=["PageUp","PageDown"],bh=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],vh={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},vo="Slider",[tc,CN,EN]=La(vo),[wh]=vr(vo,[EN]),[NN,Vi]=wh(vo),Sh=b.forwardRef((e,t)=>{const{name:r,min:n=0,max:o=100,step:s=1,orientation:i="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),v=b.useRef(0),x=i==="horizontal"?_N:kN,[E=[],P]=Zr({prop:l,defaultProp:u,onChange:T=>{[...y.current][v.current]?.focus(),f(T)}}),C=b.useRef(E);function N(T){const U=IN(E,T);I(T,U)}function _(T){I(T,v.current)}function A(){const T=C.current[v.current];E[v.current]!==T&&p(E)}function I(T,U,{commit:Q}={commit:!1}){const O=BN(s),j=$N(Math.round((T-n)/s)*s+n,O),L=qo(j,[n,o]);P((D=[])=>{const M=PN(D,L,U);if(DN(M,d*s)){v.current=M.indexOf(L);const R=String(M)!==String(D);return R&&Q&&p(M),R?M:D}else return D})}return c.jsx(NN,{scope:e.__scopeSlider,name:r,disabled:a,min:n,max:o,valueIndexToChangeRef:v,thumbs:y.current,values:E,orientation:i,form:g,children:c.jsx(tc.Provider,{scope:e.__scopeSlider,children:c.jsx(tc.Slot,{scope:e.__scopeSlider,children:c.jsx(x,{"aria-disabled":a,"data-disabled":a?"":void 0,...h,ref:t,onPointerDown:Me(h.onPointerDown,()=>{a||(C.current=E)}),min:n,max:o,inverted:m,onSlideStart:a?void 0:N,onSlideMove:a?void 0:_,onSlideEnd:a?void 0:A,onHomeKeyDown:()=>!a&&I(n,0,{commit:!0}),onEndKeyDown:()=>!a&&I(o,E.length-1,{commit:!0}),onStepKeyDown:({event:T,direction:U})=>{if(!a){const j=yh.includes(T.key)||T.shiftKey&&bh.includes(T.key)?10:1,L=v.current,D=E[L],M=s*j*U;I(D+M,L,{commit:!0})}}})})})})});Sh.displayName=vo;var[xh,Ah]=wh(vo,{startEdge:"left",endEdge:"right",size:"width",direction:1}),_N=b.forwardRef((e,t)=>{const{min:r,max:n,dir:o,inverted:s,onSlideStart:i,onSlideMove:a,onSlideEnd:d,onStepKeyDown:u,...l}=e,[f,p]=b.useState(null),m=Qe(t,x=>p(x)),g=b.useRef(void 0),h=ro(o),y=h==="ltr",v=y&&!s||!y&&s;function w(x){const E=g.current||f.getBoundingClientRect(),P=[0,E.width],N=oc(P,v?[r,n]:[n,r]);return g.current=E,N(x-E.left)}return c.jsx(xh,{scope:e.__scopeSlider,startEdge:v?"left":"right",endEdge:v?"right":"left",direction:v?1:-1,size:"width",children:c.jsx(Ch,{dir:h,"data-orientation":"horizontal",...l,ref:m,style:{...l.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:x=>{const E=w(x.clientX);i?.(E)},onSlideMove:x=>{const E=w(x.clientX);a?.(E)},onSlideEnd:()=>{g.current=void 0,d?.()},onStepKeyDown:x=>{const P=vh[v?"from-left":"from-right"].includes(x.key);u?.({event:x,direction:P?-1:1})}})})}),kN=b.forwardRef((e,t)=>{const{min:r,max:n,inverted:o,onSlideStart:s,onSlideMove:i,onSlideEnd:a,onStepKeyDown:d,...u}=e,l=b.useRef(null),f=Qe(t,l),p=b.useRef(void 0),m=!o;function g(h){const y=p.current||l.current.getBoundingClientRect(),v=[0,y.height],x=oc(v,m?[n,r]:[r,n]);return p.current=y,x(h-y.top)}return c.jsx(xh,{scope:e.__scopeSlider,startEdge:m?"bottom":"top",endEdge:m?"top":"bottom",size:"height",direction:m?1:-1,children:c.jsx(Ch,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:h=>{const y=g(h.clientY);s?.(y)},onSlideMove:h=>{const y=g(h.clientY);i?.(y)},onSlideEnd:()=>{p.current=void 0,a?.()},onStepKeyDown:h=>{const v=vh[m?"from-bottom":"from-top"].includes(h.key);d?.({event:h,direction:v?-1:1})}})})}),Ch=b.forwardRef((e,t)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:o,onSlideEnd:s,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:d,...u}=e,l=Vi(vo,r);return c.jsx(Be.span,{...u,ref:t,onKeyDown:Me(e.onKeyDown,f=>{f.key==="Home"?(i(f),f.preventDefault()):f.key==="End"?(a(f),f.preventDefault()):yh.concat(bh).includes(f.key)&&(d(f),f.preventDefault())}),onPointerDown:Me(e.onPointerDown,f=>{const p=f.target;p.setPointerCapture(f.pointerId),f.preventDefault(),l.thumbs.has(p)?p.focus():n(f)}),onPointerMove:Me(e.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&o(f)}),onPointerUp:Me(e.onPointerUp,f=>{const p=f.target;p.hasPointerCapture(f.pointerId)&&(p.releasePointerCapture(f.pointerId),s(f))})})}),Eh="SliderTrack",Nh=b.forwardRef((e,t)=>{const{__scopeSlider:r,...n}=e,o=Vi(Eh,r);return c.jsx(Be.span,{"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation,...n,ref:t})});Nh.displayName=Eh;var rc="SliderRange",_h=b.forwardRef((e,t)=>{const{__scopeSlider:r,...n}=e,o=Vi(rc,r),s=Ah(rc,r),i=b.useRef(null),a=Qe(t,i),d=o.values.length,u=o.values.map(p=>Fh(p,o.min,o.max)),l=d>1?Math.min(...u):0,f=100-Math.max(...u);return c.jsx(Be.span,{"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,...n,ref:a,style:{...e.style,[s.startEdge]:l+"%",[s.endEdge]:f+"%"}})});_h.displayName=rc;var nc="SliderThumb",kh=b.forwardRef((e,t)=>{const r=CN(e.__scopeSlider),[n,o]=b.useState(null),s=Qe(t,a=>o(a)),i=b.useMemo(()=>n?r().findIndex(a=>a.ref.current===n):-1,[r,n]);return c.jsx(TN,{...e,ref:s,index:i})}),TN=b.forwardRef((e,t)=>{const{__scopeSlider:r,index:n,name:o,...s}=e,i=Vi(nc,r),a=Ah(nc,r),[d,u]=b.useState(null),l=Qe(t,w=>u(w)),f=d?i.form||!!d.closest("form"):!0,p=Jo(d),m=i.values[n],g=m===void 0?0:Fh(m,i.min,i.max),h=ON(n,i.values.length),y=p?.[a.size],v=y?MN(y,g,a.direction):0;return b.useEffect(()=>{if(d)return i.thumbs.add(d),()=>{i.thumbs.delete(d)}},[d,i.thumbs]),c.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${g}% + ${v}px)`},children:[c.jsx(tc.ItemSlot,{scope:e.__scopeSlider,children:c.jsx(Be.span,{role:"slider","aria-label":e["aria-label"]||h,"aria-valuemin":i.min,"aria-valuenow":m,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...s,ref:l,style:m===void 0?{display:"none"}:e.style,onFocus:Me(e.onFocus,()=>{i.valueIndexToChangeRef.current=n})})}),f&&c.jsx(Th,{name:o??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:m},n)]})});kh.displayName=nc;var FN="RadioBubbleInput",Th=b.forwardRef(({__scopeSlider:e,value:t,...r},n)=>{const o=b.useRef(null),s=Qe(o,n),i=Qo(t);return b.useEffect(()=>{const a=o.current;if(!a)return;const d=window.HTMLInputElement.prototype,l=Object.getOwnPropertyDescriptor(d,"value").set;if(i!==t&&l){const f=new Event("input",{bubbles:!0});l.call(a,t),a.dispatchEvent(f)}},[i,t]),c.jsx(Be.input,{style:{display:"none"},...r,ref:s,defaultValue:t})});Th.displayName=FN;function PN(e=[],t,r){const n=[...e];return n[r]=t,n.sort((o,s)=>o-s)}function Fh(e,t,r){const s=100/(r-t)*(e-t);return qo(s,[0,100])}function ON(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function IN(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 MN(e,t,r){const n=e/2,s=oc([0,50],[0,n]);return(n-s(t)*r)*r}function LN(e){return e.slice(0,-1).map((t,r)=>e[r+1]-t)}function DN(e,t){if(t>0){const r=LN(e);return Math.min(...r)>=t}return!0}function oc(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 BN(e){return(String(e).split(".")[1]||"").length}function $N(e,t){const r=Math.pow(10,t);return Math.round(e*r)/r}var jN=Sh,zN=Nh,UN=_h,VN=kh;function HN({className:e,defaultValue:t,value:r,min:n=0,max:o=100,...s}){const i=b.useMemo(()=>Array.isArray(r)?r:Array.isArray(t)?t:[n,o],[r,t,n,o]);return c.jsxs(jN,{"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),...s,children:[c.jsx(zN,{"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(UN,{"data-slot":"slider-range",className:B("bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")})}),Array.from({length:i.length},(a,d)=>c.jsx(VN,{"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 WN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,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=v=>{s||i||e.disabled||e.readOnly||(r(v[0]??l),n?.())},y=t??l;return c.jsx(Et,{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(HN,{id:ht(e),value:[y],onValueChange:h,min:l,max:f,step:p,disabled:s||e.disabled||i||e.readOnly,className:B("w-full",o&&"border-destructive",e.appearance?.className),"aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a}),g.length>0&&c.jsx("div",{className:"flex justify-between text-xs text-muted-foreground",children:g.map((v,w)=>c.jsx("span",{className:"text-center",children:v.label},w))})]})})},RN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=S.useRef(null),[l,f]=S.useState(!1),p=s||e.disabled||i||e.readOnly,m=S.useCallback(v=>{if(p)return;f(!0);const w=u.current;if(!w)return;const x=w.getContext("2d");if(!x)return;const E=w.getBoundingClientRect(),P="touches"in v?v.touches[0].clientX-E.left:v.clientX-E.left,C="touches"in v?v.touches[0].clientY-E.top:v.clientY-E.top;x.beginPath(),x.moveTo(P,C)},[p]),g=S.useCallback(v=>{if(!l||p)return;const w=u.current;if(!w)return;const x=w.getContext("2d");if(!x)return;const E=w.getBoundingClientRect(),P="touches"in v?v.touches[0].clientX-E.left:v.clientX-E.left,C="touches"in v?v.touches[0].clientY-E.top:v.clientY-E.top;x.lineWidth=2,x.lineCap="round",x.strokeStyle="#000",x.lineTo(P,C),x.stroke(),x.beginPath(),x.moveTo(P,C)},[l,p]),h=S.useCallback(()=>{if(!l)return;f(!1);const v=u.current;if(!v)return;const w=v.toDataURL();r(w),n?.()},[l,r,n]),y=S.useCallback(()=>{const v=u.current;if(!v||p)return;const w=v.getContext("2d");w&&(w.clearRect(0,0,v.width,v.height),r(null),n?.())},[p,r,n]);return S.useEffect(()=>{const v=u.current;if(v&&(v.width=v.offsetWidth,v.height=200,t)){const w=new Image;w.onload=()=>{const x=v.getContext("2d");x&&x.drawImage(w,0,0)},w.src=t}},[t]),c.jsx(Et,{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":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,style:{height:"200px"}})}),!p&&c.jsx("div",{className:"flex justify-end",children:c.jsxs(Yt,{type:"button",variant:"outline",size:"sm",onClick:y,className:"text-xs",children:[c.jsx(Go,{className:"h-3 w-3 mr-1"}),"Clear"]})})]})})},GN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,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,v=!u&&p?.allowDeleteRow!==!1,w=s===!1&&i===!1?!1:s||e.disabled||i||e.readOnly,x=t||[],E=y&&x.length<h,P=v&&x.length>g,C=S.useCallback(()=>{if(!E||w)return;const O={};m.forEach(j=>{O[j.name]=j.defaultValue??""}),r([...x,O]),n?.()},[x,m,E,w,r,n]),N=S.useCallback(O=>{if(!P||w)return;const j=x.filter((L,D)=>D!==O);r(j),n?.()},[x,P,w,r,n]),_=S.useCallback((O,j,L)=>{if(w)return;const D=[...x];D[O]||(D[O]={}),D[O][j]=L,r(D),n?.()},[x,w,r,n]);if(S.useEffect(()=>{if(x.length<g){const O=g-x.length,j=[];for(let L=0;L<O;L++){const D={};m.forEach(M=>{D[M.name]=M.defaultValue??""}),j.push(D)}r([...x,...j])}},[g,m,r,x.length]),m.length===0)return c.jsx(Et,{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),I=Math.max(1,e.position?.columnSpan??1),T=Math.max(x.length,1),U=A>=3?"py-4":A>=2?"py-3":"py-2.5",Q=I>=3?"px-4":I>=2?"px-3":"px-4";return c.jsx(Et,{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",w&&"opacity-50"),"aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!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(O=>c.jsxs("th",{className:B(Q,U,"text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground whitespace-nowrap"),children:[O.label,a&&O.validation?.some(j=>j.type==="required")&&c.jsx("span",{className:"text-destructive ml-1",children:"*"})]},O.id)),v&&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+(v?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((O,j)=>{const L=x[j],D=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/T}%`},children:[m.map(M=>{const R={...M,name:`${e.name}_${j}_${M.name}`,appearance:{...M.appearance,hideLabel:!0}},$=M.name??"",ie=O[$]!==void 0?O[$]:$&&Object.keys(O).find(G=>G.toLowerCase()===$.toLowerCase())?O[Object.keys(O).find(G=>G.toLowerCase()===$.toLowerCase())]:void 0,V=!!M.readOnly,K=G=>{if(G==null)return"";if(Array.isArray(G))return G.map(ee=>typeof ee=="object"&&ee!==null&&"name"in ee?String(ee.name??ee):String(ee)).join(", ");if(typeof G=="object"&&G!==null&&!(G instanceof Date)){const ee=G;return typeof ee.name=="string"&&typeof ee.code=="string"?`${ee.code} ${ee.name}`.trim():typeof ee.name=="string"?ee.name:typeof ee.code=="string"?ee.code:String(ee.name??ee.code??G)}return String(G)},X=G=>typeof G=="object"&&G!==null&&!Array.isArray(G)?K(G):String(G??""),ce=M.name?.toLowerCase()==="type"||M.label?.toLowerCase()==="type";if(V){const G=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:ce&&G?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:G}):c.jsx("span",{className:"py-1 block",children:G})})},M.id)}const ne=()=>{switch(M.type){case"text":case"password":case"url":return c.jsx(Ma,{field:R,value:X(ie),onChange:G=>_(j,M.name,G),disabled:w,readOnly:w,className:"w-full"});case"number":return c.jsx(Gd,{field:R,value:ie??null,onChange:G=>_(j,M.name,G),disabled:w,readOnly:w,className:"w-full"});case"email":return c.jsx(tu,{field:R,value:X(ie),onChange:G=>_(j,M.name,G),disabled:w,readOnly:w,className:"w-full"});case"phone":case"aadhaar":return c.jsx(ru,{field:R,value:X(ie),onChange:G=>_(j,M.name,G),disabled:w,readOnly:w,className:"w-full"});case"textarea":return c.jsx(nu,{field:R,value:X(ie),onChange:G=>_(j,M.name,G),disabled:w,readOnly:w,className:"w-full"});case"select":return c.jsx(Cp,{field:R,value:typeof ie=="string"?ie:X(ie),onChange:G=>_(j,M.name,G),disabled:w,className:"w-full",formValues:D,submissionContext:f});case"multiselect":{const G=Array.isArray(ie)?ie:ie!=null&&ie!==""?[String(ie)]:[];return c.jsx(hm,{field:R,value:G,onChange:ee=>_(j,M.name,ee),disabled:w,className:"w-full",formValues:D,submissionContext:f})}case"asyncsearch":return c.jsx(Gp,{field:R,value:ie,onChange:G=>_(j,M.name,G),disabled:w,readOnly:w,className:"w-full",formValues:D,submissionContext:f});case"checkbox":return c.jsx(gm,{field:R,value:ie||!1,onChange:G=>_(j,M.name,G),disabled:w,className:"w-full"});case"radio":case"checkboxgroup":return c.jsx(Vm,{field:R,value:typeof ie=="string"?ie:X(ie),onChange:G=>_(j,M.name,G),disabled:w,className:"w-full"});case"date":case"time":case"datetime":case"daterange":return c.jsx(Hm,{field:R,value:typeof ie=="string"?ie:X(ie),onChange:G=>_(j,M.name,G),disabled:w,readOnly:w,className:"w-full"});default:return c.jsx(Ma,{field:R,value:X(ie),onChange:G=>_(j,M.name,G),disabled:w,readOnly:w,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()})},M.id)}),v&&c.jsx("td",{className:"px-2 py-2",children:c.jsx(Yt,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>N(j),disabled:!P||w,children:c.jsx(Go,{className:"h-4 w-4"})})})]},j)})})]})}),E&&c.jsx("div",{className:"shrink-0 p-3 border-t bg-muted/30",children:c.jsxs(Yt,{type:"button",variant:"outline",size:"sm",onClick:C,disabled:w,className:"w-full",children:[c.jsx(Zd,{className:"h-4 w-4 mr-2"}),"Add Row"]})})]})})};function Ph(e,t,r){const n=r?.emptyDisplay??"—";if(e==null||e==="")return n;const o=t?.format??"text",s=typeof e=="number"?e:Number(e);switch(o){case"currency":return Number.isNaN(s)?n:`${r?.currencySymbol??"₹"}${s.toLocaleString("en-IN",{minimumFractionDigits:0,maximumFractionDigits:2})}`;case"percent":return Number.isNaN(s)?n:`${s}%`;case"number":return Number.isNaN(s)?n:String(s);default:return String(e)}}function KN(e){const t=e.replace(/[^\d.-]/g,"");if(t===""||t==="-"||t===".")return null;const r=parseFloat(t);return Number.isNaN(r)?null:r}function qN(e){if(e==null||e==="")return"";const t=typeof e=="number"?e:Number(e);return Number.isNaN(t)?"":String(t)}function YN(e,t){return Ph(e,{format:"currency"},t)}const XN=new Set(["all_items_summary","invoice_discount","grand_total"]);function JN(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"&&!XN.has(r.slotId));default:return e}}function sc(e){if(typeof e=="number"&&!Number.isNaN(e))return e;const t=Number(e);return Number.isNaN(t)?0:t}function QN(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 ZN(e,t,r){const n=u=>sc(r.values[u]),o=(u,l)=>{const f=t.find(p=>p.slotId===u&&p.rowKind==="static");return f?sc(f.values[l]):0},s=(u,l="all")=>JN(t,l).reduce((f,p)=>f+sc(p.values[u]),0),i={...Ls.functions,cell:n,cellInRow:o,SUM:s},a=Object.keys(i),d=Object.values(i);try{const u=new Function(...a,`return (${e});`)(...d);return u==null||typeof u=="number"&&Number.isNaN(u)?null:u}catch{return null}}function wo(e,t){const r=t.rows.map(n=>({...n,values:{...n.values}}));for(const n of r)for(const o of e.columns){const s=QN(e,n,o.key);s?.kind==="formula"&&(n.values[o.key]=ZN(s.expression,r,n))}return{rows:r}}function e_(e,t,r,n,o,s){const i=t.rows.map(a=>a.rowInstanceId!==r||a.slotId!==n?a:{...a,values:{...a.values,[o]:s}});return wo(e,{rows:i})}function Oh(e,t){return t.map((r,n)=>{const o=typeof r=="object"&&r!==null?r:{},s=e.rowIdField&&o[e.rowIdField]!=null?String(o[e.rowIdField]):String(n),i={};for(const[d,u]of Object.entries(e.cells))u.kind==="api"&&u.path&&(i[d]=tt(o,u.path));const a=i.service??i.tariff_type;return{slotId:e.id,rowKind:"dynamic",rowInstanceId:s,label:typeof a=="string"?a:void 0,values:i}})}function ic(e,t,r){const n=[];for(const o of e.rowSlots)if(o.kind==="static"){const s=t.get(o.row.id);s&&n.push(s)}else n.push(...r.get(o.block.id)??[]);return n}function ac(e,t){const r=new Map,n=new Map;for(const o of e.rowSlots)if(o.kind==="static"){const s=t?.rows.find(i=>i.slotId===o.row.id&&i.rowKind==="static");r.set(o.row.id,{slotId:o.row.id,rowKind:"static",rowInstanceId:o.row.id,label:o.row.label,values:s?.values?{...s.values}:{}})}else{const s=t?.rows.filter(i=>i.slotId===o.block.id&&i.rowKind==="dynamic")??[];n.set(o.block.id,s.map(i=>({...i,values:{...i.values}})))}return{rows:ic(e,r,n)}}function t_(e,t,r,n){const o=ac(e,n),s=e.rowSlots.find(d=>d.kind==="dynamic"&&d.block.id===t);if(!s||s.kind!=="dynamic")return wo(e,o);const i=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&&i.set(d.row.id,{...u,values:{...u.values}})}else{const u=d.block.id===t?Oh(d.block,r):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 wo(e,{rows:ic(e,i,a)})}function r_(e,t,r){const n=ac(e,r);if(t==null||typeof t!="object"||Array.isArray(t))return wo(e,n);const o=t,s=new Map,i=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))p.kind==="api"&&p.path&&(u[f]=tt(l,p.path));s.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=tt(o,d);i.set(a.block.id,Array.isArray(u)?Oh(a.block,u):[])}return wo(e,{rows:ic(e,s,i)})}function Ih(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 n_(e){const t=e?.color?.trim();return t?{color:t}:{}}function lc(e){return{className:Ih(e),style:n_(e)}}function cc(e){return e==="center"?"text-center":e==="right"?"text-right":"text-left"}function Mh(e,t){return e?.align?e.align:t?.align??"left"}function o_(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 Lh(e,t,r,n){const o=e.rowSlots.find(s=>r==="static"?s.kind==="static"&&s.row.id===t:s.kind==="dynamic"&&s.block.id===t);if(o)return o.kind==="static"?o.row.cells[n]:o.block.cells[n]}const s_=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=e.properties??{},l=u.columns??[],f=u.currencySymbol??"₹",p=u.emptyDisplay??"—",m=s||i,g=S.useMemo(()=>{const N=ac(u,t);return wo(u,N)},[u,t]);S.useEffect(()=>{!t?.rows?.length&&g.rows.length&&r(g)},[t,g,r]);const h=S.useCallback((N,_,A,I,T)=>{if(m)return;const U=T==="number"?KN(I):I===""?null:I,Q=e_(u,g,N,_,A,U);r(Q)},[m,g,r,u]),y=(N,_,A,I,T,U)=>{const Q=l.find(M=>M.key===T),O=Lh(u,N,_,T),j=cc(Mh(O,Q)),L=o_(u,N,_),D=L?.kind==="static"?L.row.labelStyle:L?.kind==="dynamic"?L.block.labelStyle:void 0;if(O?.kind==="label"){const M=lc(D);return c.jsx("span",{className:B(M.className||"font-medium",j,!D?.color&&"text-foreground"),style:M.style,children:I??p})}if(O?.kind==="input"&&!m){const M=U==null||U===""?"":String(U);return c.jsx(wn,{type:"text",inputMode:O.inputType==="number"?"decimal":"text",value:M,onChange:R=>h(A,N,T,R.target.value,O.inputType),onBlur:n,className:B("h-8 text-sm border-0 shadow-none focus-visible:ring-1 bg-transparent",j),disabled:m})}if(O?.kind==="currency"){if(!m){const M=qN(U);return c.jsxs("div",{className:B("flex w-full items-center gap-0.5",j==="text-center"&&"justify-center",j==="text-right"&&"justify-end",j==="text-left"&&"justify-start"),children:[c.jsx("span",{className:"shrink-0 text-sm tabular-nums text-foreground",children:f}),c.jsx(wn,{type:"text",inputMode:"decimal",value:M,onChange:R=>h(A,N,T,R.target.value,"number"),onBlur:n,className:"h-8 min-w-[2ch] max-w-full flex-1 border-0 bg-transparent text-sm tabular-nums shadow-none focus-visible:ring-1",disabled:m})]})}return c.jsx("span",{className:B("tabular-nums",j),children:YN(U,{currencySymbol:f,emptyDisplay:p})})}return O?.kind==="static"?c.jsx("span",{className:B("text-muted-foreground",j),children:O.value}):c.jsx("span",{className:B(j),children:Ph(U,Q,{currencySymbol:f,emptyDisplay:p})})},v=u.gridTitle?.trim()??"",w=Math.max(1,e.position?.rowSpan??1),x=Math.max(1,e.position?.columnSpan??1),E=Math.max(g.rows.length,1),P=w>=3?"py-4":w>=2?"py-3":"py-2",C=x>=3?"px-4":x>=2?"px-3":"px-2";return l.length===0?c.jsx(Et,{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(Et,{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":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,children:[v?c.jsx("div",{className:B("shrink-0 px-4 py-2 border-b bg-muted/40",Ih(u.gridTitleStyle)||"text-muted-foreground"),style:lc(u.gridTitleStyle).style,children:v}):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(N=>{const _=lc(N.headerStyle);return c.jsx("th",{className:B(C,P,"text-xs uppercase tracking-wider whitespace-nowrap",cc(N.align),_.className||"font-semibold text-muted-foreground"),style:_.style,children:N.label},N.id)})})}),c.jsx("tbody",{className:"h-full",children:g.rows.length===0?c.jsx("tr",{children:c.jsx("td",{colSpan:l.length,className:B(C,"py-8 text-center text-sm text-muted-foreground"),children:"No billing rows configured"})}):g.rows.map(N=>c.jsx("tr",{className:"border-b border-border/60",style:{height:`${100/E}%`},children:l.map(_=>{const A=Lh(u,N.slotId,N.rowKind,_.key),I=Mh(A,_);return c.jsx("td",{className:B(C,P,"align-middle whitespace-nowrap",cc(I)),children:y(N.slotId,N.rowKind,N.rowInstanceId,N.label,_.key,N.values[_.key])},_.id)})},`${N.slotId}-${N.rowInstanceId}`))})]})})]})})};function dc(e,t,r){return r_(e,t,r)}const i_=({field:e,value:t,error:r,disabled:n,isRequired:o,className:s,formValues:i={},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(),v=f.showCurrentIndicator!==!1,[w,x]=S.useState(null),[E,P]=S.useState(!1),[C,N]=S.useState(null),_=pa.useParams(),A=S.useRef(i),I=S.useRef(a),T=S.useRef(d),U=S.useRef(_);A.current=i,I.current=a,T.current=d,U.current=_;const Q=S.useCallback(async()=>{const M=f.apiEndpoint?.trim();if(!M){N("Status API endpoint is not configured");return}P(!0),N(null);try{const R=I.current,$=T.current,ie=R!=null&&typeof R=="object"?{...R,...$||{}}:$||{},V=cn(rn(M,A.current,U.current,ie,void 0,l??void 0)),K=(f.apiMethod||"GET").toUpperCase(),X=await fetch(V,{method:K,headers:K==="POST"?{"Content-Type":"application/json"}:void 0});if(!X.ok)throw new Error(`HTTP ${X.status}`);const ce=await X.json(),ne=g?tt(ce,g):ce;x(ne&&typeof ne=="object"?ne:{})}catch(R){N(R instanceof Error?R.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 O=p==="api"?w:t&&typeof t=="object"?(g?tt(t,g):null)??t:null,j=h&&y&&O?String(tt(O,y)??tt({data:O},y)??""):"",L=M=>{if(!O||typeof O!="object")return!1;const R=O[M];return R===!0||R==="true"||R===1};let D=!1;return c.jsx(Et,{field:e,error:r||C||void 0,isRequired:o,className:B(s,"!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:[E&&c.jsx("div",{className:"text-sm text-muted-foreground py-2",children:"Loading status..."}),h&&j&&!E&&c.jsx("p",{className:"text-sm text-muted-foreground mb-3 shrink-0","data-status-text":!0,children:j}),!E&&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 R=L(M.key),$=v&&R&&!D;return $&&(D=!0),c.jsxs("li",{className:B("flex items-center gap-3 text-sm",R?"text-foreground":"text-muted-foreground"),children:[R?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(Us,{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(Xd,{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)})}),!E&&m.length===0&&c.jsx("p",{className:"text-sm text-muted-foreground",children:"No statuses configured."})]})})};function uc(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 So(e,t){if(t){const r=uc(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 a_(e,t,r,n){if(r?.length){const s=n??" | ",i=r.map(a=>uc(e,a)).filter(a=>a!=null).map(a=>String(a));if(i.length)return i.join(s)}if(t){const s=uc(e,t);if(s!=null)return String(s)}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 l_=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,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 v=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:v.length,contextListSample:v.length>0?v.slice(0,2):[]});const[w,x]=S.useState(()=>v.length>0?v:Array.isArray(t)?t:[]);S.useEffect(()=>{if(v.length>0){console.log("[SelectableList] Step 3: sync fullList from context",{fieldName:e.name,contextListLength:v.length}),x(v);return}Array.isArray(t)&&t.length>0&&x(T=>{const U=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:U.length}),U})},[v,t]);const E=S.useMemo(()=>{const T=Array.isArray(t)?t:[];return new Set(T.map(Q=>So(Q,p)))},[t,p]),P=w.length>0&&w.every(T=>E.has(So(T,p))),C=w.some(T=>E.has(So(T,p))),N=S.useCallback((T,U)=>{const Q=So(T,p),O=Array.isArray(t)?t:[];U?E.has(Q)||r([...O,T]):r(O.filter(j=>So(j,p)!==Q)),n?.()},[t,p,E,r,n]),_=S.useCallback(T=>{r(T===!0?[...w]:[]),n?.()},[w,r,n]),A=w.length>0?w:Array.isArray(t)?t:[],I=s||e.disabled;return console.log("[SelectableList] Data in list",{fieldName:e.name,listLength:A.length,listSource:w.length>0?"fullList":"value",valueLength:Array.isArray(t)?t.length:0,fullListLength:w.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(Et,{field:e,error:o,isRequired:i,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(ki,{id:`${ht(e)}-select-all`,checked:P?!0:C?"indeterminate":!1,onCheckedChange:_,disabled:I,"aria-label":"Select all"}),c.jsxs(Sn,{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(Yt,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs",disabled:I||P,onClick:()=>{r([...w]),n?.()},children:"Select all"}),c.jsx(Yt,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs",disabled:I||!C,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,U)=>{const Q=So(T,p),O=E.has(Q),j=`${ht(e)}-${U}-${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(ki,{id:j,checked:O,onCheckedChange:L=>N(T,L===!0),disabled:I,"aria-describedby":jt(e,!!o)}),c.jsx(Sn,{htmlFor:j,className:"text-sm cursor-pointer flex-1 truncate",children:a_(T,f,m,g)})]},Q)})})]}),A.length>0&&E.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(wv,{className:"h-4 w-4 shrink-0"}),"Please select at least one item."]})]})})})})},Dh=({field:e,children:t,className:r})=>{const n=e.properties,o=n?.collapsible??!1,s=n?.defaultCollapsed??!1,i=n?.columns??1,[a,d]=S.useState(s),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(Yd,{className:"h-4 w-4"}):c.jsx(Wo,{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[i]),children:t})]})};var c_=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],d_=c_.reduce((e,t)=>{const r=Ia(`Primitive.${t}`),n=b.forwardRef((o,s)=>{const{asChild:i,...a}=o,d=i?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(d,{...a,ref:s})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),u_="Separator",Bh="horizontal",f_=["horizontal","vertical"],$h=b.forwardRef((e,t)=>{const{decorative:r,orientation:n=Bh,...o}=e,s=p_(n)?n:Bh,a=r?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return c.jsx(d_.div,{"data-orientation":s,...a,...o,ref:t})});$h.displayName=u_;function p_(e){return f_.includes(e)}var m_=$h;function fc({className:e,orientation:t="horizontal",decorative:r=!0,...n}){return c.jsx(m_,{"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 h_=({field:e,className:t})=>c.jsx("div",{className:B("py-2",t),children:c.jsx(fc,{})}),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"},y_=({field:e,className:t})=>{const r=e.properties,n=r?.headingLevel??"h3",o=r?.showHorizontalLine??!0,s=g_[n],i=n;return c.jsxs("div",{className:B("w-full min-w-0 space-y-1",t),children:[c.jsx(i,{className:B("m-0 text-foreground",s),children:e.label||"Header"}),e.description&&c.jsx("p",{className:"text-sm text-muted-foreground",children:e.description}),o&&c.jsx(fc,{className:"w-full"})]})},b_={"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"},v_={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"},w_=({field:e,className:t})=>{const r=e.properties,n=r?.position??"top-left",o=r?.headingLevel??"h3",s=r?.showHorizontalLine??!0,i=b_[n],a=v_[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",i),children:c.jsx(d,{className:B("m-0 text-foreground",a),children:e.label||"Section Heading"})}),s&&c.jsx(fc,{className:"w-full"})]})},S_=({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 jh(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 x_(e){if(Array.isArray(e))return e}function A_(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,o,s,i,a=[],d=!0,u=!1;try{if(s=(r=r.call(e)).next,t!==0)for(;!(d=(n=s.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&&(i=r.return(),Object(i)!==i))return}finally{if(u)throw o}}return a}}function C_(){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 E_(e,t){return x_(e)||A_(e,t)||N_(e,t)||C_()}function N_(e,t){if(e){if(typeof e=="string")return jh(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)?jh(e,t):void 0}}const zh=Object.entries,Uh=Object.setPrototypeOf,__=Object.isFrozen,k_=Object.getPrototypeOf,T_=Object.getOwnPropertyDescriptor;let lr=Object.freeze,Mr=Object.seal,xo=Object.create,Vh=typeof Reflect<"u"&&Reflect,pc=Vh.apply,mc=Vh.construct;lr||(lr=function(t){return t}),Mr||(Mr=function(t){return t}),pc||(pc=function(t,r){for(var n=arguments.length,o=new Array(n>2?n-2:0),s=2;s<n;s++)o[s-2]=arguments[s];return t.apply(r,o)}),mc||(mc=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 Ao=zt(Array.prototype.forEach),F_=zt(Array.prototype.lastIndexOf),Hh=zt(Array.prototype.pop),Co=zt(Array.prototype.push),P_=zt(Array.prototype.splice),cr=Array.isArray,ds=zt(String.prototype.toLowerCase),hc=zt(String.prototype.toString),Wh=zt(String.prototype.match),Eo=zt(String.prototype.replace),Rh=zt(String.prototype.indexOf),O_=zt(String.prototype.trim),I_=zt(Number.prototype.toString),M_=zt(Boolean.prototype.toString),Gh=typeof BigInt>"u"?null:zt(BigInt.prototype.toString),Kh=typeof Symbol>"u"?null:zt(Symbol.prototype.toString),Ot=zt(Object.prototype.hasOwnProperty),us=zt(Object.prototype.toString),Zt=zt(RegExp.prototype.test),Hi=L_(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 pc(e,t,n)}}function L_(e){return function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return mc(e,r)}}function nt(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ds;if(Uh&&Uh(e,null),!cr(t))return e;let n=t.length;for(;n--;){let o=t[n];if(typeof o=="string"){const s=r(o);s!==o&&(__(t)||(t[n]=s),o=s)}e[o]=!0}return e}function D_(e){for(let t=0;t<e.length;t++)Ot(e,t)||(e[t]=null);return e}function hr(e){const t=xo(null);for(const n of zh(e)){var r=E_(n,2);const o=r[0],s=r[1];Ot(e,o)&&(cr(s)?t[o]=D_(s):s&&typeof s=="object"&&s.constructor===Object?t[o]=hr(s):t[o]=s)}return t}function B_(e){switch(typeof e){case"string":return e;case"number":return I_(e);case"boolean":return M_(e);case"bigint":return Gh?Gh(e):"0";case"symbol":return Kh?Kh(e):"Symbol()";case"undefined":return us(e);case"function":case"object":{if(e===null)return us(e);const t=e,r=Kn(t,"toString");if(typeof r=="function"){const n=r(t);return typeof n=="string"?n:us(n)}return us(e)}default:return us(e)}}function Kn(e,t){for(;e!==null;){const n=T_(e,t);if(n){if(n.get)return zt(n.get);if(typeof n.value=="function")return zt(n.value)}e=k_(e)}function r(){return null}return r}function $_(e){try{return Zt(e,""),!0}catch{return!1}}const qh=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"]),gc=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"]),yc=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"]),j_=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"]),bc=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"]),z_=lr(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Yh=lr(["#text"]),Xh=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"]),vc=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"]),Jh=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"]),Wi=lr(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),U_=Mr(/{{[\w\W]*|^[\w\W]*}}/g),V_=Mr(/<%[\w\W]*|^[\w\W]*%>/g),H_=Mr(/\${[\w\W]*/g),W_=Mr(/^data-[\-\w.\u00B7-\uFFFF]+$/),R_=Mr(/^aria-[\-\w]+$/),Qh=Mr(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),G_=Mr(/^(?:\w+script|data):/i),K_=Mr(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),q_=Mr(/^html$/i),Y_=Mr(/^[a-z][.\w]*(-[.\w]+)+$/i),No={element:1,text:3,progressingInstruction:7,comment:8,document:9},X_=function(){return typeof window>"u"?null:window},J_=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 s="dompurify"+(n?"#"+n:"");try{return t.createPolicy(s,{createHTML(i){return i},createScriptURL(i){return i}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},Zh=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function eg(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:X_();const t=Ee=>eg(Ee);if(t.version="3.4.5",t.removed=[],!e||!e.document||e.document.nodeType!==No.document||!e.Element)return t.isSupported=!1,t;let r=e.document;const n=r,o=n.currentScript,s=e.DocumentFragment,i=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=Kn(h,"cloneNode"),v=Kn(h,"remove"),w=Kn(h,"nextSibling"),x=Kn(h,"childNodes"),E=Kn(h,"parentNode"),P=a&&a.prototype?Kn(a.prototype,"nodeType"):null;if(typeof i=="function"){const Ee=r.createElement("template");Ee.content&&Ee.content.ownerDocument&&(r=Ee.content.ownerDocument)}let C,N="";const _=r,A=_.implementation,I=_.createNodeIterator,T=_.createDocumentFragment,U=_.getElementsByTagName,Q=n.importNode;let O=Zh();t.isSupported=typeof zh=="function"&&typeof E=="function"&&A&&A.createHTMLDocument!==void 0;const j=U_,L=V_,D=H_,M=W_,R=R_,$=G_,ie=K_,V=Y_;let K=Qh,X=null;const ce=nt({},[...qh,...gc,...yc,...bc,...Yh]);let ne=null;const G=nt({},[...Xh,...vc,...Jh,...Wi]);let ee=Object.seal(xo(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}})),Pe=null,oe=null;const re=Object.seal(xo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let be=!0,de=!0,ot=!1,Se=!0,xe=!1,ae=!0,ve=!1,Ye=!1,ct=!1,Ge=!1,Kt=!1,Je=!1,q=!0,$e=!1;const gt="user-content-";let Oe=!0,te=!1,pe={},We=null;const Pt=nt({},["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 je=null;const Te=nt({},["audio","video","img","source","image","track"]);let Xe=null;const Ue=nt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ft="http://www.w3.org/1998/Math/MathML",St="http://www.w3.org/2000/svg",xt="http://www.w3.org/1999/xhtml";let ze=xt,yt=!1,pt=null;const At=nt({},[ft,St,xt],hc);let Ut=nt({},["mi","mo","mn","ms","mtext"]),ur=nt({},["annotation-xml"]);const Ar=nt({},["title","style","font","a","script"]);let Vt=null;const Po=["application/xhtml+xml","text/html"],Xn="text/html";let Ct=null,Cr=null;const Jn=r.createElement("form"),It=function(F){return F instanceof RegExp||F instanceof Function},Er=function(){let F=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Cr&&Cr===F)return;(!F||typeof F!="object")&&(F={}),F=hr(F),Vt=Po.indexOf(F.PARSER_MEDIA_TYPE)===-1?Xn:F.PARSER_MEDIA_TYPE,Ct=Vt==="application/xhtml+xml"?hc:ds,X=Ot(F,"ALLOWED_TAGS")&&cr(F.ALLOWED_TAGS)?nt({},F.ALLOWED_TAGS,Ct):ce,ne=Ot(F,"ALLOWED_ATTR")&&cr(F.ALLOWED_ATTR)?nt({},F.ALLOWED_ATTR,Ct):G,pt=Ot(F,"ALLOWED_NAMESPACES")&&cr(F.ALLOWED_NAMESPACES)?nt({},F.ALLOWED_NAMESPACES,hc):At,Xe=Ot(F,"ADD_URI_SAFE_ATTR")&&cr(F.ADD_URI_SAFE_ATTR)?nt(hr(Ue),F.ADD_URI_SAFE_ATTR,Ct):Ue,je=Ot(F,"ADD_DATA_URI_TAGS")&&cr(F.ADD_DATA_URI_TAGS)?nt(hr(Te),F.ADD_DATA_URI_TAGS,Ct):Te,We=Ot(F,"FORBID_CONTENTS")&&cr(F.FORBID_CONTENTS)?nt({},F.FORBID_CONTENTS,Ct):Pt,Pe=Ot(F,"FORBID_TAGS")&&cr(F.FORBID_TAGS)?nt({},F.FORBID_TAGS,Ct):hr({}),oe=Ot(F,"FORBID_ATTR")&&cr(F.FORBID_ATTR)?nt({},F.FORBID_ATTR,Ct):hr({}),pe=Ot(F,"USE_PROFILES")?F.USE_PROFILES&&typeof F.USE_PROFILES=="object"?hr(F.USE_PROFILES):F.USE_PROFILES:!1,be=F.ALLOW_ARIA_ATTR!==!1,de=F.ALLOW_DATA_ATTR!==!1,ot=F.ALLOW_UNKNOWN_PROTOCOLS||!1,Se=F.ALLOW_SELF_CLOSE_IN_ATTR!==!1,xe=F.SAFE_FOR_TEMPLATES||!1,ae=F.SAFE_FOR_XML!==!1,ve=F.WHOLE_DOCUMENT||!1,Ge=F.RETURN_DOM||!1,Kt=F.RETURN_DOM_FRAGMENT||!1,Je=F.RETURN_TRUSTED_TYPE||!1,ct=F.FORCE_BODY||!1,q=F.SANITIZE_DOM!==!1,$e=F.SANITIZE_NAMED_PROPS||!1,Oe=F.KEEP_CONTENT!==!1,te=F.IN_PLACE||!1,K=$_(F.ALLOWED_URI_REGEXP)?F.ALLOWED_URI_REGEXP:Qh,ze=typeof F.NAMESPACE=="string"?F.NAMESPACE:xt,Ut=Ot(F,"MATHML_TEXT_INTEGRATION_POINTS")&&F.MATHML_TEXT_INTEGRATION_POINTS&&typeof F.MATHML_TEXT_INTEGRATION_POINTS=="object"?hr(F.MATHML_TEXT_INTEGRATION_POINTS):nt({},["mi","mo","mn","ms","mtext"]),ur=Ot(F,"HTML_INTEGRATION_POINTS")&&F.HTML_INTEGRATION_POINTS&&typeof F.HTML_INTEGRATION_POINTS=="object"?hr(F.HTML_INTEGRATION_POINTS):nt({},["annotation-xml"]);const Y=Ot(F,"CUSTOM_ELEMENT_HANDLING")&&F.CUSTOM_ELEMENT_HANDLING&&typeof F.CUSTOM_ELEMENT_HANDLING=="object"?hr(F.CUSTOM_ELEMENT_HANDLING):xo(null);if(ee=xo(null),Ot(Y,"tagNameCheck")&&It(Y.tagNameCheck)&&(ee.tagNameCheck=Y.tagNameCheck),Ot(Y,"attributeNameCheck")&&It(Y.attributeNameCheck)&&(ee.attributeNameCheck=Y.attributeNameCheck),Ot(Y,"allowCustomizedBuiltInElements")&&typeof Y.allowCustomizedBuiltInElements=="boolean"&&(ee.allowCustomizedBuiltInElements=Y.allowCustomizedBuiltInElements),xe&&(de=!1),Kt&&(Ge=!0),pe&&(X=nt({},Yh),ne=xo(null),pe.html===!0&&(nt(X,qh),nt(ne,Xh)),pe.svg===!0&&(nt(X,gc),nt(ne,vc),nt(ne,Wi)),pe.svgFilters===!0&&(nt(X,yc),nt(ne,vc),nt(ne,Wi)),pe.mathMl===!0&&(nt(X,bc),nt(ne,Jh),nt(ne,Wi))),re.tagCheck=null,re.attributeCheck=null,Ot(F,"ADD_TAGS")&&(typeof F.ADD_TAGS=="function"?re.tagCheck=F.ADD_TAGS:cr(F.ADD_TAGS)&&(X===ce&&(X=hr(X)),nt(X,F.ADD_TAGS,Ct))),Ot(F,"ADD_ATTR")&&(typeof F.ADD_ATTR=="function"?re.attributeCheck=F.ADD_ATTR:cr(F.ADD_ATTR)&&(ne===G&&(ne=hr(ne)),nt(ne,F.ADD_ATTR,Ct))),Ot(F,"ADD_URI_SAFE_ATTR")&&cr(F.ADD_URI_SAFE_ATTR)&&nt(Xe,F.ADD_URI_SAFE_ATTR,Ct),Ot(F,"FORBID_CONTENTS")&&cr(F.FORBID_CONTENTS)&&(We===Pt&&(We=hr(We)),nt(We,F.FORBID_CONTENTS,Ct)),Ot(F,"ADD_FORBID_CONTENTS")&&cr(F.ADD_FORBID_CONTENTS)&&(We===Pt&&(We=hr(We)),nt(We,F.ADD_FORBID_CONTENTS,Ct)),Oe&&(X["#text"]=!0),ve&&nt(X,["html","head","body"]),X.table&&(nt(X,["tbody"]),delete Pe.tbody),F.TRUSTED_TYPES_POLICY){if(typeof F.TRUSTED_TYPES_POLICY.createHTML!="function")throw Hi('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof F.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Hi('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');C=F.TRUSTED_TYPES_POLICY,N=C.createHTML("")}else C===void 0&&(C=J_(g,o)),C!==null&&typeof N=="string"&&(N=C.createHTML(""));lr&&lr(F),Cr=F},er=nt({},[...gc,...yc,...j_]),sr=nt({},[...bc,...z_]),fn=function(F){let Y=E(F);(!Y||!Y.tagName)&&(Y={namespaceURI:ze,tagName:"template"});const he=ds(F.tagName),st=ds(Y.tagName);return pt[F.namespaceURI]?F.namespaceURI===St?Y.namespaceURI===xt?he==="svg":Y.namespaceURI===ft?he==="svg"&&(st==="annotation-xml"||Ut[st]):!!er[he]:F.namespaceURI===ft?Y.namespaceURI===xt?he==="math":Y.namespaceURI===St?he==="math"&&ur[st]:!!sr[he]:F.namespaceURI===xt?Y.namespaceURI===St&&!ur[st]||Y.namespaceURI===ft&&!Ut[st]?!1:!sr[he]&&(Ar[he]||!er[he]):!!(Vt==="application/xhtml+xml"&&pt[F.namespaceURI]):!1},yr=function(F){Co(t.removed,{element:F});try{E(F).removeChild(F)}catch{v(F)}},kt=function(F,Y){try{Co(t.removed,{attribute:Y.getAttributeNode(F),from:Y})}catch{Co(t.removed,{attribute:null,from:Y})}if(Y.removeAttribute(F),F==="is")if(Ge||Kt)try{yr(Y)}catch{}else try{Y.setAttribute(F,"")}catch{}},ws=function(F){let Y=null,he=null;if(ct)F="<remove></remove>"+F;else{const wt=Wh(F,/^[\r\n\t ]+/);he=wt&&wt[0]}Vt==="application/xhtml+xml"&&ze===xt&&(F='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+F+"</body></html>");const st=C?C.createHTML(F):F;if(ze===xt)try{Y=new m().parseFromString(st,Vt)}catch{}if(!Y||!Y.documentElement){Y=A.createDocument(ze,"template",null);try{Y.documentElement.innerHTML=yt?N:st}catch{}}const Tt=Y.body||Y.documentElement;return F&&he&&Tt.insertBefore(r.createTextNode(he),Tt.childNodes[0]||null),ze===xt?U.call(Y,ve?"html":"body")[0]:ve?Y.documentElement:Tt},Nr=function(F){return I.call(F.ownerDocument||F,F,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Dr=function(F){F.normalize();const Y=I.call(F.ownerDocument||F,F,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null);let he=Y.nextNode();for(;he;){let st=he.data;Ao([j,L,D],Tt=>{st=Eo(st,Tt," ")}),he.data=st,he=Y.nextNode()}},_r=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")},br=function(F){if(!P||typeof F!="object"||F===null)return!1;try{return typeof P(F)=="number"}catch{return!1}};function qt(Ee,F,Y){Ao(Ee,he=>{he.call(t,F,Y,Cr)})}const tr=function(F){let Y=null;if(qt(O.beforeSanitizeElements,F,null),_r(F))return yr(F),!0;const he=Ct(F.nodeName);if(qt(O.uponSanitizeElement,F,{tagName:he,allowedTags:X}),ae&&F.hasChildNodes()&&!br(F.firstElementChild)&&Zt(/<[/\w!]/g,F.innerHTML)&&Zt(/<[/\w!]/g,F.textContent)||ae&&F.namespaceURI===xt&&he==="style"&&br(F.firstElementChild)||F.nodeType===No.progressingInstruction||ae&&F.nodeType===No.comment&&Zt(/<[/\w]/g,F.data))return yr(F),!0;if(Pe[he]||!(re.tagCheck instanceof Function&&re.tagCheck(he))&&!X[he]){if(!Pe[he]&&Ji(he)&&(ee.tagNameCheck instanceof RegExp&&Zt(ee.tagNameCheck,he)||ee.tagNameCheck instanceof Function&&ee.tagNameCheck(he)))return!1;if(Oe&&!We[he]){const st=E(F)||F.parentNode,Tt=x(F)||F.childNodes;if(Tt&&st){const wt=Tt.length;for(let Mt=wt-1;Mt>=0;--Mt){const $r=y(Tt[Mt],!0);st.insertBefore($r,w(F))}}}return yr(F),!0}return F instanceof d&&!fn(F)||(he==="noscript"||he==="noembed"||he==="noframes")&&Zt(/<\/no(script|embed|frames)/i,F.innerHTML)?(yr(F),!0):(xe&&F.nodeType===No.text&&(Y=F.textContent,Ao([j,L,D],st=>{Y=Eo(Y,st," ")}),F.textContent!==Y&&(Co(t.removed,{element:F.cloneNode()}),F.textContent=Y)),qt(O.afterSanitizeElements,F,null),!1)},Br=function(F,Y,he){if(oe[Y]||q&&(Y==="id"||Y==="name")&&(he in r||he in Jn))return!1;const st=ne[Y]||re.attributeCheck instanceof Function&&re.attributeCheck(Y,F);if(!(de&&!oe[Y]&&Zt(M,Y))){if(!(be&&Zt(R,Y))){if(!st||oe[Y]){if(!(Ji(F)&&(ee.tagNameCheck instanceof RegExp&&Zt(ee.tagNameCheck,F)||ee.tagNameCheck instanceof Function&&ee.tagNameCheck(F))&&(ee.attributeNameCheck instanceof RegExp&&Zt(ee.attributeNameCheck,Y)||ee.attributeNameCheck instanceof Function&&ee.attributeNameCheck(Y,F))||Y==="is"&&ee.allowCustomizedBuiltInElements&&(ee.tagNameCheck instanceof RegExp&&Zt(ee.tagNameCheck,he)||ee.tagNameCheck instanceof Function&&ee.tagNameCheck(he))))return!1}else if(!Xe[Y]){if(!Zt(K,Eo(he,ie,""))){if(!((Y==="src"||Y==="xlink:href"||Y==="href")&&F!=="script"&&Rh(he,"data:")===0&&je[F])){if(!(ot&&!Zt($,Eo(he,ie,"")))){if(he)return!1}}}}}}return!0},Xi=nt({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Ji=function(F){return!Xi[ds(F)]&&Zt(V,F)},Qi=function(F){qt(O.beforeSanitizeAttributes,F,null);const Y=F.attributes;if(!Y||_r(F))return;const he={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ne,forceKeepAttr:void 0};let st=Y.length;for(;st--;){const Tt=Y[st],wt=Tt.name,Mt=Tt.namespaceURI,$r=Tt.value,ir=Ct(wt),Oo=$r;let Lt=wt==="value"?Oo:O_(Oo);if(he.attrName=ir,he.attrValue=Lt,he.keepAttr=!0,he.forceKeepAttr=void 0,qt(O.uponSanitizeAttribute,F,he),Lt=he.attrValue,$e&&(ir==="id"||ir==="name")&&Rh(Lt,gt)!==0&&(kt(wt,F),Lt=gt+Lt),ae&&Zt(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Lt)){kt(wt,F);continue}if(ir==="attributename"&&Wh(Lt,"href")){kt(wt,F);continue}if(he.forceKeepAttr)continue;if(!he.keepAttr){kt(wt,F);continue}if(!Se&&Zt(/\/>/i,Lt)){kt(wt,F);continue}xe&&Ao([j,L,D],Ze=>{Lt=Eo(Lt,Ze," ")});const Zi=Ct(F.nodeName);if(!Br(Zi,ir,Lt)){kt(wt,F);continue}if(C&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!Mt)switch(g.getAttributeType(Zi,ir)){case"TrustedHTML":{Lt=C.createHTML(Lt);break}case"TrustedScriptURL":{Lt=C.createScriptURL(Lt);break}}if(Lt!==Oo)try{Mt?F.setAttributeNS(Mt,wt,Lt):F.setAttribute(wt,Lt),_r(F)?yr(F):Hh(t.removed)}catch{kt(wt,F)}}qt(O.afterSanitizeAttributes,F,null)},Ss=function(F){let Y=null;const he=Nr(F);for(qt(O.beforeSanitizeShadowDOM,F,null);Y=he.nextNode();)qt(O.uponSanitizeShadowNode,Y,null),tr(Y),Qi(Y),Y.content instanceof s&&Ss(Y.content);qt(O.afterSanitizeShadowDOM,F,null)},kr=function(F){if(F.nodeType===No.element&&F.shadowRoot instanceof s){const st=F.shadowRoot;kr(st),Ss(st)}const Y=F.childNodes;if(!Y)return;const he=[];Ao(Y,st=>{Co(he,st)});for(const st of he)kr(st)};return t.sanitize=function(Ee){let F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},Y=null,he=null,st=null,Tt=null;if(yt=!Ee,yt&&(Ee="<!-->"),typeof Ee!="string"&&!br(Ee)&&(Ee=B_(Ee),typeof Ee!="string"))throw Hi("dirty is not a string, aborting");if(!t.isSupported)return Ee;if(Ye||Er(F),t.removed=[],typeof Ee=="string"&&(te=!1),te){const $r=Ee.nodeName;if(typeof $r=="string"){const ir=Ct($r);if(!X[ir]||Pe[ir])throw Hi("root node is forbidden and cannot be sanitized in-place")}kr(Ee)}else if(br(Ee))Y=ws("<!---->"),he=Y.ownerDocument.importNode(Ee,!0),he.nodeType===No.element&&he.nodeName==="BODY"||he.nodeName==="HTML"?Y=he:Y.appendChild(he),kr(he);else{if(!Ge&&!xe&&!ve&&Ee.indexOf("<")===-1)return C&&Je?C.createHTML(Ee):Ee;if(Y=ws(Ee),!Y)return Ge?null:Je?N:""}Y&&ct&&yr(Y.firstChild);const wt=Nr(te?Ee:Y);for(;st=wt.nextNode();)tr(st),Qi(st),st.content instanceof s&&Ss(st.content);if(te)return xe&&Dr(Ee),Ee;if(Ge){if(xe&&Dr(Y),Kt)for(Tt=T.call(Y.ownerDocument);Y.firstChild;)Tt.appendChild(Y.firstChild);else Tt=Y;return(ne.shadowroot||ne.shadowrootmode)&&(Tt=Q.call(n,Tt,!0)),Tt}let Mt=ve?Y.outerHTML:Y.innerHTML;return ve&&X["!doctype"]&&Y.ownerDocument&&Y.ownerDocument.doctype&&Y.ownerDocument.doctype.name&&Zt(q_,Y.ownerDocument.doctype.name)&&(Mt="<!DOCTYPE "+Y.ownerDocument.doctype.name+`>
|
|
52
|
-
`+Mt),xe&&Ao([j,L,D],$r=>{Mt=Eo(Mt,$r," ")}),C&&Je?C.createHTML(Mt):Mt},t.setConfig=function(){let Ee=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Er(Ee),Ye=!0},t.clearConfig=function(){Cr=null,Ye=!1},t.isValidAttribute=function(Ee,F,Y){Cr||Er({});const he=Ct(Ee),st=Ct(F);return Br(he,st,Y)},t.addHook=function(Ee,F){typeof F=="function"&&Co(O[Ee],F)},t.removeHook=function(Ee,F){if(F!==void 0){const Y=F_(O[Ee],F);return Y===-1?void 0:P_(O[Ee],Y,1)[0]}return Hh(O[Ee])},t.removeHooks=function(Ee){O[Ee]=[]},t.removeAllHooks=function(){O=Zh()},t}var Q_=eg();const Z_=["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"],ek=["href","target","rel","src","alt","title","class","style","colspan","rowspan"];function tk(e){return e?Q_.sanitize(e,{ALLOWED_TAGS:[...Z_],ALLOWED_ATTR:[...ek],ALLOW_DATA_ATTR:!1}):""}function rk(e,t,r=!1){return e.includes("{labelapi:")?e.replace(/\{labelapi:([^}]+)\}/g,(n,o)=>{const s=o.trim();if(s===""||t==null)return r?"":n;const i=tt(t,s);return i==null?r?"":n:String(i)}):e}function nk(e){return e&&e.replace(/\{api:[^}]*\}/gi,"").replace(/\{labelapi:[^}]*\}/gi,"").replace(/\{resp:[^}]*\}/gi,"").replace(/\{(?:ctx:|@)\w+\}/gi,"").replace(/\{documentId\}/gi,"").replace(/\{(\w+)\}/g,"")}const tg={sm:"text-sm",md:"text-base",lg:"text-lg"},rg={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"},ng={normal:"font-normal",medium:"font-medium",bold:"font-bold"},Ri={left:"text-left",center:"text-center",right:"text-right",justify:"text-justify"};function qn(e){return e.properties??{}}function ok(e){const t=qn(e);return t.textContent!==void 0?t.textContent:e.label??""}function sk(e){return qn(e).textContent===void 0||e.appearance?.hideLabel?!1:!!e.label?.trim()}function ik(e){return e?.contentLayout==="paragraph"?"paragraph":"single"}function wc(e,t={}){const{formValues:r={},urlParams:n={},submissionContext:o,buttonResponses:s,prepopulateResponse:i,labelApiResponse:a}=t,d=rn(e,r,n,o,s,i),u=rk(d,a,!0);return nk(u)}const ak=/\{api:[^}]+\}/,lk=/\{labelapi:[^}]+\}/;function Sc(e){return ak.test(e)}function xc(e){return lk.test(e)}function ck(e){const t=e.captionTemplate??"",r=e.descriptionTemplate??"",n=Sc(e.bodyTemplate)||Sc(t)||Sc(r),o=xc(e.bodyTemplate)||xc(t)||xc(r);return!!(n&&e.prepopulateLoading||o&&e.labelApiConfigPresent&&(e.labelApiLoading||e.labelApiResponse===void 0&&e.labelApiError==null))}function og(e,t){const r=t??qn(e),n=r.variant??"body",o=e.appearance?.size??"md",s=tg[o]??tg.md,i=r.fontWeight??"medium";return n!=="body"?B("m-0 text-foreground",rg[n]??rg.h3,r.fontWeight&&ng[r.fontWeight],r.italic&&"italic",r.underline&&"underline",r.textAlign&&Ri[r.textAlign]):B("m-0 text-foreground",s,ng[i],r.italic&&"italic",r.underline&&"underline",r.textAlign&&Ri[r.textAlign])}function dk(e,t){const r=(t??qn(e)).variant??"body";return r==="body"?"p":r}function Ac(e){const t=[];let r=0,n="";const o=()=>{n&&(t.push({type:"text",value:n}),n="")},s=(i,a,d)=>{if(!e.startsWith(i,r))return!1;const u=e.indexOf(a,r+i.length);if(u===-1)return!1;o();const l=e.slice(r+i.length,u);return t.push({type:d,children:Ac(l)}),r=u+a.length,!0};for(;r<e.length;){if(e[r]==="\\"&&r+1<e.length){n+=e[r+1],r+=2;continue}s("**","**","bold")||s("__","__","underline")||s("*","*","italic")||s("_","_","italic")||(n+=e[r],r+=1)}return o(),t}function uk(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function sg(e){return e.map(t=>{if(t.type==="text")return uk(t.value);const r=sg(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 fk(e){return e?sg(Ac(e)):""}function pk(e,t){return e?t==="markdown-lite"?fk(e):e:""}function ig(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 s=ig(r.children,o);return r.type==="bold"?S.createElement("strong",{key:o,className:"font-bold"},s):r.type==="italic"?S.createElement("em",{key:o,className:"italic"},s):S.createElement("u",{key:o,className:"underline"},s)})}function ag(e,t){if(!e)return null;if(t!=="markdown-lite")return e;const r=Ac(e);return r.length===1&&r[0]?.type==="text"?r[0].value:ig(r,"tl")}const mk="text-label-html prose prose-sm max-w-none [&_p]:m-0 [&_p+p]:mt-2 [&_ul]:my-1 [&_ol]:my-1";function lg(e,t){if(!e)return null;const{field:r,asDescription:n=!1}=t,o=t.textProps??qn(r),s=t.contentLayout??ik(o),i=o.inlineFormat??"none";if(s==="paragraph"){const d=tk(pk(e,i));if(!d)return null;const u=n?B("m-0 text-sm",o.descriptionMuted!==!1?"text-muted-foreground":"text-foreground",o.textAlign&&Ri[o.textAlign]):B(og(r,o),mk);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&&Ri[o.textAlign])},ag(e,i));const a=dk(r,o);return S.createElement(a,{className:og(r,o)},ag(e,i))}function hk(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,s=f=>rn(f,r,n,o),i=(e.labelApiMethod??"GET").toUpperCase();let a=cn(s(e.labelApiEndpoint));const d=e.labelApiQueryParams??[];if(d.length){const f=new URLSearchParams;d.forEach(({key:m,value:g})=>{m.trim()&&f.append(m,s(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]=s(p))});let l;i==="POST"&&(e.labelApiBodyFields??[]).length&&(l={},e.labelApiBodyFields.forEach(({key:f,value:p})=>{f.trim()&&(l[f]=s(p))}));try{return i==="POST"?(await dn.post(a,l??{},{headers:Object.keys(u).length?u:void 0})).data:(await dn.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 yk=({field:e,className:t,formValues:r,urlParams:n,submissionContext:o,buttonResponses:s,prepopulateResponse:i,prepopulateLoading:a=!1})=>{const d=qn(e),u=S.useMemo(()=>hk(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]),v=S.useCallback(async()=>{if(!u){f(void 0),h(null),m(!1);return}m(!0),h(null);try{const U=await gk(u,{formValues:r??{},urlParams:n??{},submissionContext:o});f(U)}catch(U){f(void 0),h(U instanceof Error?U.message:"Failed to load label API")}finally{m(!1)}},[u,r,n,o]);S.useEffect(()=>{y&&v()},[y,v]);const w=d.textAlign==="center"?"items-center":d.textAlign==="right"?"items-end":d.textAlign==="justify"?"items-stretch":"items-start",x=ok(e),E=sk(e),P=E&&e.label?e.label:"",C=e.description??"",N=ck({bodyTemplate:x,captionTemplate:P,descriptionTemplate:C,prepopulateLoading:a,labelApiConfigPresent:u!=null,labelApiLoading:p,labelApiResponse:l,labelApiError:g}),_={formValues:r??{},urlParams:n??{},submissionContext:o,buttonResponses:s,prepopulateResponse:i,labelApiResponse:l},A=x?wc(x,_):"",I=E&&e.label?wc(e.label,_):"",T=C?wc(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",w,t),children:N?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,I?c.jsx("div",{className:"text-sm font-medium text-foreground mb-1 w-full",children:I}):null,A?lg(A,{field:e,textProps:d}):null,T?lg(T,{field:e,textProps:d,asDescription:!0}):null]})})},Cc=({legend:e,children:t,className:r,collapsible:n=!1,defaultCollapsed:o=!1,headerActions:s,onCollapsedChange:i})=>{const[a,d]=S.useState(o),u=S.useId(),l=f=>{f.stopPropagation(),n&&d(p=>{const m=!p;return i?.(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(Yd,{className:"h-4 w-4"}):c.jsx(Wo,{className:"h-4 w-4"})}),c.jsx("span",{className:"truncate",children:e})]}),s!=null?c.jsx("div",{className:"shrink-0",children:s}):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&&s!=null?c.jsx("div",{className:"flex justify-end",children:s}):null,t]})]})},un=({field:e,value:t,error:r,onChange:n,onBlur:o,disabled:s,readOnly:i,isRequired:a,className:d,formValues:u={},submissionContext:l,onSubmit:f,onReset:p,onCancel:m,isSubmitting:g,bffSubmitApi:h,onBffSubmitResult:y,extraSubmitPayload:v,buttonResponses:w,onButtonApiResponse:x,onValidateForm:E,getValidationErrors:P,allFields:C,onSubmittingChange:N,onAddMore:_,scopedFormValues:A,scopedFieldNameMap:I,excludedOptionValues:T,prepopulateMappedFieldNames:U,fieldValueKey:Q,hideTableRowControls:O=!1,urlParams:j={},prepopulateResponse:L=null,prepopulateLoading:D=!1,formSections:M,submitPayload:R})=>{switch(e.type){case"divider":return c.jsx(h_,{field:e,className:d});case"header":return c.jsx(y_,{field:e,className:d});case"sectionHeading":return c.jsx(w_,{field:e,className:d});case"spacer":return c.jsx(S_,{field:e,className:d});case"textLabel":return c.jsx(yk,{field:e,className:d,formValues:u,urlParams:j,submissionContext:l,buttonResponses:w,prepopulateResponse:L??void 0,prepopulateLoading:D});case"status":return c.jsx(i_,{field:e,value:t??null,error:r,disabled:s,isRequired:a,className:d,formValues:u,submissionContext:l,extraSubmitPayload:v,prepopulateResponse:L})}switch(e.type){case"text":case"password":case"url":return c.jsx(Ma,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"number":return c.jsx(Gd,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"email":return c.jsx(tu,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"phone":case"aadhaar":return c.jsx(ru,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"textarea":case"richtext":return c.jsx(nu,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"select":{const $=Q??e.name??e.key??e.id,ie=!!($&&U?.has($));return c.jsx(Cp,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d,formValues:u,submissionContext:l,excludedOptionValues:T,isPrepopulateTarget:ie})}case"multiselect":{const $=Array.isArray(t)?t:t!=null&&t!==""?[String(t)]:[];return c.jsx(hm,{field:e,value:$,onChange:ie=>n(ie),onBlur:o,error:r,disabled:s,isRequired:a,className:d,formValues:u,submissionContext:l,excludedOptionValues:T})}case"asyncsearch":return c.jsx(Gp,{field:e,value:t,onChange:$=>n($),onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d,formValues:u,submissionContext:l});case"checkbox":case"terms":return c.jsx(gm,{field:e,value:t||!1,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d});case"toggle":return c.jsx(qC,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d});case"radio":case"checkboxgroup":return c.jsx(Vm,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d,excludedOptionValues:T});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(l_,{field:e,value:$,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d,submissionContext:l})}case"date":case"time":case"datetime":case"daterange":return c.jsx(Hm,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"file":return c.jsx(vE,{field:e,value:t,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d,buttonResponses:w});case"camera":return c.jsx(JE,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d});case"photoChoice":return c.jsx(QE,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d,buttonResponses:w});case"signature":return c.jsx(RN,{field:e,value:t||null,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"rating":return c.jsx(AN,{field:e,value:t||0,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"slider":return c.jsx(WN,{field:e,value:t||0,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"table":return c.jsx(GN,{field:e,value:t||[],onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d,hideRowControls:O,formValues:u,submissionContext:l});case"billingGrid":return c.jsx(s_,{field:e,value:t||{rows:[]},onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"button":return c.jsx(pN,{field:e,value:t,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d,onSubmit:f,onReset:p,onCancel:m,isSubmitting:g,formValues:u,submissionContext:l,buttonResponses:w,onButtonApiResponse:x,bffSubmitApi:h,onBffSubmitResult:y,extraSubmitPayload:v,onValidateForm:E,getValidationErrors:P,allFields:C,onSubmittingChange:N,scopedFormValues:A,scopedFieldNameMap:I,prepopulateResponse:L,formSections:M,submitPayload:R});case"editButton":return c.jsx(mN,{field:e,disabled:s,readOnly:i,isRequired:a,className:d,buttonResponses:w,onButtonApiResponse:x});case"addmore":return c.jsx(hN,{field:e,error:r,disabled:s,readOnly:i,isRequired:a,className:d,onAddMore:()=>_?.(e)});case"customizeSections":return c.jsx(xN,{field:e,error:r,disabled:s,readOnly:i,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]})})}},bk=({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((s,i)=>{const a=r.has(i),d=t===i,u=n&&(a||i===t+1||i<=t);return c.jsxs("li",{className:B("relative",i!==e.length-1&&"pr-8 sm:pr-20 flex-1"),children:[i!==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?.(i),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(Us,{className:"h-4 w-4"}):c.jsx("span",{children:i+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:s.name}),s.description&&c.jsx("p",{className:"text-xs text-muted-foreground hidden sm:block",children:s.description})]})]},s.id)})})})});function fs(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 cg(e){return Array.isArray(e)?e.map(fs):[]}function vk(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=fs(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 wk{basePath="/api/form-builder/forms";async getForRendering(t,r){if(!Tn())throw new Error("Client ID is required");const o=r!==void 0?`${this.basePath}/${t}/render?version=${r}`:`${this.basePath}/${t}/render`,s=await dn.get(o),i=s.data?.data||s.data,a=i?.BFF_submit_api||i?.bff_submit_api||s.data?.BFF_submit_api||s.data?.bff_submit_api,d=i.form||i;if(!d.moduleId&&!i.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??i.form?.isDefault??!1)&&!d.tenantId&&!i.form?.tenantId)throw new Error(`Form response missing required field: tenantId. Form ID: ${t}. Please ensure the backend returns tenantId for non-default forms.`);i.form?.moduleId&&!d.moduleId&&(d.moduleId=i.form.moduleId),i.form?.tenantId&&!d.tenantId&&(d.tenantId=i.form.tenantId),i.form?.isDefault!==void 0&&d.isDefault===void 0&&(d.isDefault=i.form.isDefault);const l=vk(d);i.form?.moduleId&&(typeof i.form.moduleId=="object"&&i.form.moduleId._id?l.moduleId=fs(i.form.moduleId):typeof i.form.moduleId=="string"&&(l.moduleId=i.form.moduleId));const f=cg(i.fields||[]),p=i.layout?fs(i.layout):null,m=cg(i.rules||[]),g=i.module?fs(i.module):void 0,h=i.clientMapping||i.clientOverrides;return{form:l,fields:f,layout:p,rules:m,module:g,clientMapping:h,clientOverrides:h,BFF_submit_api:a||void 0}}}const Sk=new wk;function Pn({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"},s=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:s}):s}const xk={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."},Ak=300;function Ck(){return{...xk}}function Ek(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 i={};return r!=null&&r!==""&&(i.visibleToUserType=r),n!=null&&n!==""&&(i.visibleToUserRole=n),o.length>0&&(i.visibleToUserIds=o),i}function Nk(e){const t=Ck();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:aN(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 ps(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=Ld(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 V=l.validationRules;if(V.required===!0&&!g.some(K=>K.type==="required")&&g.push({type:"required",message:"This field is required"}),V.allowLetters!==void 0&&g.push({type:"allowLetters",value:V.allowLetters}),V.allowNumbers!==void 0&&g.push({type:"allowNumbers",value:V.allowNumbers}),V.allowSpecialChars!==void 0&&g.push({type:"allowSpecialChars",value:V.allowSpecialChars}),V.minLetters!==void 0&&typeof V.minLetters=="number"&&g.push({type:"minLetters",value:V.minLetters}),V.maxLetters!==void 0&&typeof V.maxLetters=="number"&&g.push({type:"maxLetters",value:V.maxLetters}),V.minNumbers!==void 0&&typeof V.minNumbers=="number"&&g.push({type:"minNumbers",value:V.minNumbers}),V.maxNumbers!==void 0&&typeof V.maxNumbers=="number"&&g.push({type:"maxNumbers",value:V.maxNumbers}),V.minSpecialChars!==void 0&&typeof V.minSpecialChars=="number"&&g.push({type:"minSpecialChars",value:V.minSpecialChars}),V.maxSpecialChars!==void 0&&typeof V.maxSpecialChars=="number"&&g.push({type:"maxSpecialChars",value:V.maxSpecialChars}),V.fileSize!==void 0&&typeof V.fileSize=="number"){const K=V.fileSize/1048576;g.push({type:"fileSize",value:V.fileSize,message:`File size must be less than ${K.toFixed(2)} MB`})}if(V.fileType!==void 0){const K=Array.isArray(V.fileType)?V.fileType:typeof V.fileType=="string"?V.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(V=>{const K=typeof V.targetFieldId=="object"?V.targetFieldId.id||V.targetFieldId._id:V.targetFieldId;return!!(K===l.id||K===l._id||K&&l.fieldKey&&K===l.fieldKey)}).forEach(V=>{try{const K=JSON.parse(V.conditionExpression);!K.id&&V.id&&(K.id=V.id);const X=typeof V.targetFieldId=="object"?V.targetFieldId?.id||V.targetFieldId?._id:V.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)&&V.action&&(K.then=[{action:V.action,...X&&{target:X}}]),K.then&&Array.isArray(K.then)&&X&&(K.then=K.then.map(ne=>!ne.target&&X?{...ne,target:X}:ne));const ce=V.conditionExpression||JSON.stringify(K);if(y.has(ce))return;y.add(ce),h.push(K)}catch{}});const w=l.disabled===!0||p?.disabled===!0||!1;let x=l.readOnly===!0||p?.readOnly===!0||!1;const E=l.hidden===!0||p?.hidden===!0||!1;(p?.valueSource==="calculated"||p?.formula)&&(x=!0);const{disabled:P,readOnly:C,hidden:N,..._}=p,A={};_.hideLabel!==void 0&&(A.hideLabel=_.hideLabel),_.labelPosition!==void 0&&(A.labelPlacement=_.labelPosition),_.size!==void 0&&(A.size=_.size),_.customClass!==void 0&&(A.className=_.customClass);const{labelPosition:I,size:T,customClass:U,visibility:Q,...O}=_,j=Object.keys(O).length>0?O:void 0,L=Object.keys(A).length>0?A:void 0,D=l.visibility??p?.visibility??Q;let M=Ek(D);if(D&&!M){const V=D;(V.visibleToUserType!=null||V.visibleToUserRole!=null||Array.isArray(V.visibleToUserTypes)&&V.visibleToUserTypes.length>0||Array.isArray(V.visibleToUserRoles)&&V.visibleToUserRoles.length>0||Array.isArray(V.visibleToUserIds)&&V.visibleToUserIds.length>0||Array.isArray(V.hiddenFromUserIds)&&V.hiddenFromUserIds.length>0)&&(M={visibleToUserType:V.visibleToUserType??(Array.isArray(V.visibleToUserTypes)?V.visibleToUserTypes[0]:void 0),visibleToUserRole:V.visibleToUserRole??(Array.isArray(V.visibleToUserRoles)?V.visibleToUserRoles[0]:void 0),visibleToUserIds:V.visibleToUserIds,hiddenFromUserIds:V.hiddenFromUserIds})}const R=p?.columnName,ie=!!l.parentFieldId&&typeof R=="string"?R: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:j,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:w,readOnly:x,hidden:E}});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 s=t;for(let l=0;l<o.length;l++){const f=s[l]?.parentFieldId;if(f){const p=o.find(g=>g.id===f||g.type==="table"&&g.name===f||g.type==="table"&&s[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 i=o.filter((l,f)=>!s[f]?.parentFieldId);for(const l of i)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=Nk(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=Es(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:i,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 _k=3;function _o(e){if(typeof e=="number"&&!Number.isNaN(e))return e}function ko(e,t){const r=e&&typeof e=="object"&&!Array.isArray(e)?e:void 0;return _o(r?.cellSlot)??_o(r?.stackSlot)??_o(r?.cellSlotIndex)??_o(r?.slotIndex)??_o(t?.cellSlotIndex)??_o(t?.stackSlot)}function ms(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 Gi(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 Ec(e){return[...e].sort((t,r)=>{const n=ko(t.position),o=ko(r.position);return typeof n=="number"&&typeof o=="number"&&n!==o?n-o:String(t.id).localeCompare(String(r.id))})}function hs(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,Do(o)),n=Math.max(n,md(o,t));return{rowSpan:r,columnSpan:n}}function dg(e){const t=Ec(e);for(const r of t){const n=ms(r.position);if(n)return n}return t.length>=2?"row":"stack"}function ug(e){return Ec(e).slice(0,_k)}function kk(e,t){const r=new Map;for(const n of e){if(!t(n)||typeof n.position?.order!="number")continue;const o=Gi(n),s=r.get(o)??[];s.push(n),r.set(o,s)}return Array.from(r.values()).map(n=>ug(n))}function fg(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 s=new Map;for(const a of o){const d=Gi(a),u=s.get(d)??[];u.push(a),s.set(d,u)}const i=[...s.values()][0]??[];return ug(i)}function Tk(e,t,r,n){const o=r[0],s=o.position?.order,i=o.position?.column??1;if(typeof s!="number")return!1;const{rowSpan:a,columnSpan:d}=hs(r,n),u=e===s&&t===i-1,l=e>=s&&e<s+a,f=t>=i-1&&t<i-1+d;return l&&f&&!u}function Fk(e,t,r){const n=new Set(r??[]);for(const o of e){const s=o[0]?.position?.order??0,{rowSpan:i}=hs(o,t);for(let a=s;a<s+i;a++)n.add(a)}return n}function Pk(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 Ok(e,t,r){const n=r.get(e);if(n===void 0)return;let o=0;for(let s=e;s<e+t&&r.has(s);s++)o++;return`${n+1} / span ${Math.max(o,1)}`}function gr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function To(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(r=>To(r));if(!gr(e))return e;const t={};for(const[r,n]of Object.entries(e))t[r]=To(n);return t}function pg(e,...t){const r={...e};for(const n of t)if(!(!n||!gr(n)))for(const[o,s]of Object.entries(n)){const i=r[o];gr(s)&&gr(i)?r[o]=pg(i,s):r[o]=s}return r}function Yn(e){return gr(e)?e:{}}function gs(e){if(e==null)return{};if(typeof e=="string"){const t=e.trim();if(!t)return{};try{const r=JSON.parse(t);return gr(r)?To(r):{}}catch{return{}}}return gr(e)?To(e):{}}function mg(e){const t=e.apidata;return gr(t)&&Object.keys(t).length>0}function Ik(e){if(typeof e.metadata=="string"&&e.metadata.trim()!==""||typeof e.metadata=="object"&&e.metadata!==null&&!Array.isArray(e.metadata)&&Object.keys(e.metadata).length>0||mg(e))return!0;const t=e.fieldKey,r=e.fieldType,n=e.name,o=e.type;return!!(t&&(!n||String(n).trim()==="")||r&&(!o||String(o).trim()==="")||t&&n&&t!==n||r&&o&&r!==o||!n&&e.key&&typeof e.key=="string")}const hg=["hideLabel","contentAlign","contentVerticalAlign","labelPlacement","widthPercent","widthMode","className","verticalAlign","horizontalAlign","cellAlign","cellJustify","size","variant","minWidth","minHeight"];function Mk(e,t){const r=e.appearance,n=gr(r)&&Object.keys(r).length>0?To(r):{},o=Yn(t.appearance),s={...n};for(const[i,a]of Object.entries(o))i!=="heightPercent"&&s[i]===void 0&&(s[i]=To(a));for(const i of hg)s[i]===void 0&&t[i]!==void 0&&(s[i]=t[i]);return delete s.heightPercent,Object.keys(s).length>0?s:void 0}function Lk(e,t){const r=Yn(e.position),n=gs(e.metadata),o=Yn(e.layout),s=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,i=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:s,column:i,columnSpan:a,rowSpan:d},l=r.cellGroupId??o.cellGroupId,f=ko(r,{cellSlotIndex:e.cellSlotIndex??o.cellSlotIndex,stackSlot:n.stackSlot??o.stackSlot}),p=ms(r)??ms(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 Dk(e,t){const r=e,n=gs(r.metadata),o=Yn(r.apidata),s=Yn(r.properties),i=pg({},n,o,s),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=Mk(r,n),l=Lk(r,t),f={...r};return f.properties=i,a!==void 0&&(f.name=a),d!==void 0&&(f.type=d),u!==void 0?f.appearance=u:(!gr(r.appearance)||Object.keys(r.appearance).length===0)&&delete f.appearance,f.position=l,gr(f.appearance)&&delete f.appearance.heightPercent,f}function Bk(e,t){if(!e||typeof e!="object")return!0;const r=e,n=gs(r.metadata),o=Object.keys(n).length===0&&!(typeof r.metadata=="string"&&r.metadata.trim()!==""),s=!mg(r);if(Ik(r)||!o||!s)return!1;const i=r.position;return!(!(gr(i)&&typeof i.order=="number"&&!Number.isNaN(i.order))&&(typeof r.positionRow=="number"||typeof r.positionColumn=="number"||typeof r.positionWidth=="number"||typeof r.positionRowSpan=="number"||typeof r.positionOrder=="number")||gr(n.appearance)||hg.some(u=>n[u]!==void 0&&(r.appearance==null||gr(r.appearance)&&r.appearance[u]===void 0))||$k(r))}function $k(e){const t=Yn(e.position),r=Yn(e.layout),n=gs(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 Ki(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,s)=>{if(Bk(o))return o;const i=Dk(o,s);return i!==o&&(r=!0),i});return r?{...e,fields:n}:e}function jk(e){return Ki(e)}const zk=new Set(["PENDING_PAYMENT","PAYMENT_PENDING","AWAITING_PAYMENT","PAID","PAYMENT_COMPLETED","PAYMENT_FAILED","REFUNDED","AUTHORIZED","CAPTURED","PARTIALLY_PAID"].map(e=>e.toUpperCase()));function Nc(e){return typeof e=="string"&&e.trim()!==""}function _c(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"||Nc(t.amount)||typeof t.total_amount=="number"||Nc(t.total_amount)||Nc(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"&&zk.has(r.trim().toUpperCase()))}function Uk(e){const t=tt(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 Vk(e,t){const r=Uk(e);if(!r)return;const n=tt(e,"data"),o=n!=null&&typeof n=="object"&&!Array.isArray(n)?n:void 0;if(t?.treatFirstItemIdAsPaymentId===!0||_c(r.item)||o!=null&&_c(o))return r.id}function Hk(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 Wk(e){return Hk(e).some(t=>t.toLowerCase().includes("payment"))}function Rk(e){const t=e.properties,r=e.metadata;return!!(t?.mergeSuccessDataIdAsPaymentId||r?.mergeSuccessDataIdAsPaymentId)}function Gk(e,t){if(t?.type!=="button"||!Uo(e))return;const r=tt(e,"data.id");if(r==null||String(r).trim()==="")return;const n=tt(e,"data");if(Rk(t)||n!=null&&typeof n=="object"&&!Array.isArray(n)&&_c(n)||Wk(t))return r}const Kk=new Set(["section","group","columns","divider","header","sectionHeading","spacer","addmore","textLabel","customizeSections"]);function qk(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 s=r.get(o);if(s?.fieldNames?.length)for(const i of s.fieldNames)i&&!n.includes(i)&&n.push(i)}return n}function Yk(e,t){const r=e.properties,n=Array.isArray(r?.linkedFieldNames)?r.linkedFieldNames:[],o=qk(Array.isArray(r?.linkedSectionIds)?r.linkedSectionIds:[],t),s=new Set,i=[];for(const a of[...n,...o])!a||s.has(a)||(s.add(a),i.push(a));return i}function gg(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(s=>[s.id,s]));return n.map(s=>o.get(s)).filter(s=>!!s)}function Xk(e,t){return gg(e,t).find(r=>r.heading?.enabled)}function yg(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=Yk(e,r);if(o.length===0)return[];const s=new Set(o);return t.filter(i=>{const a=n(i);return!a||i.id===e.id||Kk.has(i.type)?!1:s.has(a)})}function Jk(e,t,r){if(e.type!=="sectionHeading"||!t?.length)return;const n=r(e);if(n)for(const o of t){const s=o.heading;if(s?.enabled&&s.headingFieldName===n)return s}}function kc(e){return[...e].sort((t,r)=>{const n=t.position?.order??0,o=r.position?.order??0;if(n!==o)return n-o;const s=t.position?.column??1,i=r.position?.column??1;return s-i})}function Qk(e,t,r){if(!e?.length)return[];const n=e.filter(i=>i.showBorder===!0);if(n.length===0)return[];const o=new Map;for(const i of t){const a=r(i);a&&o.set(a,i)}const s=[];for(const i of n){const a=i.fieldNames.map(u=>o.get(u)).filter(u=>!!u);if(a.length===0)continue;const d=kc(a).map(u=>r(u)).filter(Boolean);s.push({section:i,fieldNames:d})}return s}function ys(e,t=0){return e.heading?.enabled?yg(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 Zk(e,t){const r=typeof e.position?.order=="number"?e.position.order:0,n=(e.position?.column??1)-1,o=Do(e),s=md(e,t);return{row:r,col:n,rowEnd:r+o-1,colEnd:n+s-1}}function Tc(e,t){let r=1/0,n=-1/0,o=1/0,s=-1/0;for(const i of e){const{row:a,col:d,rowEnd:u,colEnd:l}=Zk(i,t);r=Math.min(r,a),n=Math.max(n,u),o=Math.min(o,d),s=Math.max(s,l)}return Number.isFinite(r)?{minRow:r,maxRow:n,minCol:o,maxCol:s,rowSpan:n-r+1,colSpan:s-o+1}:null}function eT(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 s=Tc(o,r);if(!s)return null;const i=o.filter(l=>l.type!=="sectionHeading"),a=i.length>0?i:o,d=Math.min(...a.map(l=>l.position?.order??0)),u=Math.max(1,...a.map(l=>(l.position?.order??d)-d+Do(l)));return{minRow:s.minRow,maxRow:s.maxRow,minCol:s.minCol,maxCol:s.maxCol,blockHeight:u}}function tT(e,t){return e.maxRow+1+t*e.blockHeight}function rT(e,t,r,n){const o=new Map;for(const a of t){const d=r(a);d&&o.set(d,a)}const s=new Map,i=new Set;for(const a of e){const d=a.fieldNames.map(w=>o.get(w)).filter(w=>!!w);if(d.length===0)continue;const u=d.filter(w=>!vg(w,a.section,r)),l=Tc(d,n);if(!l)continue;const{minRow:f,minCol:p,rowSpan:m,colSpan:g}=l,h=`${f}-${p}`;if(s.has(h))continue;const y=new Set;let v=!1;for(let w=f;w<=f+m-1;w++){for(let x=p;x<=p+g-1;x++){const E=`${w}-${x}`;if(i.has(E)){v=!0;break}y.add(E)}if(v)break}if(!v){for(const w of y)i.add(w);s.set(h,{anchorRow:f,anchorCol:p,rowSpan:m,colSpan:g,run:a,legend:ys(a.section,0),renderFields:u.length>0?u:d})}}return{anchorsByOrigin:s,coveredCells:i}}function nT(e,t,r,n,o,s,i){const a=new Set(i),d=new Map;for(const u of e){const l=wg(u.linkedFields.map(p=>s(p)).filter(Boolean),t),f=l?.section;f?.fieldNames?.length?f.fieldNames:u.templateFieldNames,u.blockIds.forEach((p,m)=>{const g=r.filter(N=>N.id.endsWith(`__${p}`));if(g.length===0||!l)return;const h=Tc(g,o);if(!h)return;const{minRow:y,minCol:v,rowSpan:w,colSpan:x}=h,E=`${y}-${v}`;for(let N=y;N<=y+w-1;N++)for(let _=v;_<=v+x-1;_++)a.add(`${N}-${_}`);const P=l,C=ys(f,m+1);d.set(E,{anchorRow:y,anchorCol:v,rowSpan:w,colSpan:x,run:P,legend:C,renderFields:kc(g),addMoreMeta:{addMoreFieldName:u.addMoreFieldName,blockId:p,blockIndex:m}})})}return{anchorsByOrigin:d,coveredCells:a}}function oT(e,t,r,n){const o=`${e}-${t}`;return r.has(o)?!n.get(o):!1}function sT(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 iT(e,t,r,n){return!(!n||r.run.section.collapsible!==!0||e===r.anchorRow&&t===r.anchorCol)}function aT(e,t,r){const n=new Set;for(const o of e.values())if(t(o))for(let s=o.anchorRow+1;s<o.anchorRow+o.rowSpan;s++)r(s,o)||n.add(s);return n}function lT(e,t,r){const n=o=>r.has(o)?"minmax(0, auto)":`minmax(${t}, auto)`;return Array.from({length:e},(o,s)=>n(s)).join(" ")}function cT(e,t){return new Map([...e,...t])}function dT(e,t,r){if(t.length===0)return e.map(i=>({kind:"field",field:i}));const n=new Map;for(const i of t)for(const a of i.fieldNames)n.set(a,i);const o=[];let s=0;for(;s<e.length;){const i=e[s],a=r(i),d=a?n.get(a):void 0;if(!d){o.push({kind:"field",field:i}),s+=1;continue}const u=[],l=new Set(d.fieldNames);for(;s<e.length;){const p=r(e[s]);if(!p||!l.has(p))break;const m=e[s];vg(m,d.section,r)||u.push(m),s+=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 wg(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(s=>r.has(s));if(o.length>0)return{section:n,fieldNames:o}}}const uT=2*6e4,Sg=50;class fT{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<=Sg)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-Sg)).forEach(([n])=>this.map.delete(n))}}function pT(e){return(e??"").trim()||"default"}function xg(e){const t=pT(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 Ag=new fT(uT);function Cg(e){const t=xg(e),r=Ag.get(t);return r?{value:r.value,isStale:r.isStale}:null}function Eg(e,t){const r=xg(e);Ag.set(r,t)}function Ng(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 s=o;typeof s.name=="string"&&typeof s.code=="string"?t[n]=`${s.code} ${s.name}`.trim():typeof s.name=="string"?t[n]=s.name:typeof s.code=="string"?t[n]=s.code:typeof s.short_code=="string"?t[n]=s.short_code:t[n]=s.name??s.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 Fc=({schema:e,formId:t,initialValues:r,onSubmit:n,onChange:o,onValidationError:s,onClose:i,mode:a="fill",className:d,children:u,gridLayout:l,unstyled:f=!1,submissionContext:p,onWorkflowSubmitResult:m,initialExtraSubmitPayload:g,onExtraSubmitPayloadChange:h,workflowStepId:y,viewerContext:v,getViewerContext:w,hideTableRowControls:x=!1,themeVars:E,dark:P=!1,omitRootWrapper:C=!1})=>{const N=Rn(k=>k.viewerContext),_=S.useMemo(()=>{if(v!==void 0)return v;const k=w?.();return k!==void 0?k:N},[v,w,N]),[A,I]=S.useState(e||null),[T,U]=S.useState(!!t&&!e),[Q,O]=S.useState(null),j=e?.BFF_submit_api??Q,[L,D]=S.useState(!1),[M,R]=S.useState({}),[$,ie]=S.useState({}),[V,K]=S.useState({}),[X,ce]=S.useState({}),[ne,G]=S.useState({}),[ee,Pe]=S.useState(null),oe=pa.useParams(),re=Nt(k=>k.setValues),be=Nt(k=>k.setSubmitting),de=Nt(k=>k.formDisabled),ot=Nt(k=>k.visibleFields),Se=Nt(k=>k.requiredFields),xe=Nt(k=>k.updateVisibility),ae=Nt(k=>k.updateRequired),ve=Nt(k=>k.setFieldError),Ye=S.useRef(!1),ct=S.useRef(void 0),Ge=S.useMemo(()=>{if(!e)return null;const k=e;if(k.form&&Array.isArray(k.form.fields))try{return ps(k.form,k.form.fields,k.form.layout||null,k.form.rules||[])}catch{return e}if(Array.isArray(k.fields)&&k.fields.some(z=>typeof z.metadata=="string"&&z.metadata.startsWith("{")||z.fieldType&&!z.type))try{const z={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 ps(z,k.fields,k.layout||null,k.rules||[])}catch{return e}return e},[e]);S.useEffect(()=>{if(e){const k=e;k.BFF_submit_api&&O(k.BFF_submit_api)}},[e]);const Kt=S.useMemo(()=>{const k=Ge||A,H=k?Ki(k):null;if(!H)return null;const z=H.layout,Z=H.rules,J=H.clientMapping,le=(Array.isArray(H.fields)?H.fields:[]).map(Le=>{let Ve={...Le};if(Le.validationRules&&typeof Le.validationRules=="object"&&!Le.validation){const fe=Le.validationRules,Fe=[];fe.required===!0&&Fe.push({type:"required",message:"This field is required"}),fe.minLength!==void 0&&typeof fe.minLength=="number"&&Fe.push({type:"minLength",value:fe.minLength,message:`Minimum length is ${fe.minLength}`}),fe.maxLength!==void 0&&typeof fe.maxLength=="number"&&Fe.push({type:"maxLength",value:fe.maxLength,message:`Maximum length is ${fe.maxLength}`}),fe.pattern&&typeof fe.pattern=="string"&&Fe.push({type:"pattern",value:fe.pattern,message:"Invalid format"}),fe.allowLetters!==void 0&&Fe.push({type:"allowLetters",value:fe.allowLetters}),fe.allowNumbers!==void 0&&Fe.push({type:"allowNumbers",value:fe.allowNumbers}),fe.allowSpecialChars!==void 0&&Fe.push({type:"allowSpecialChars",value:fe.allowSpecialChars}),Fe.length>0&&(Ve={...Ve,validation:Fe})}const we=Le.required===!0||Le.isRequired===!0,Ae=Array.isArray(Ve.validation)&&Ve.validation.some(fe=>fe.type==="required");if(we&&!Ae){const fe={type:"required",message:"This field is required"},Fe=Array.isArray(Ve.validation)?Ve.validation:[];Ve={...Ve,validation:[...Fe,fe]}}if(Le.apidata&&typeof Le.apidata=="object"){const fe=Le.apidata,Fe=Ve.properties||{},ye=(Ve.type||Le.fieldType)==="status";if(!Fe.apiEndpoint&&fe.apiEndpoint){const dt={...Fe,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,valueSource:fe.valueSource||(fe.apiEndpoint?"api":void 0),optionsSource:fe.optionsSource||(fe.apiEndpoint?"api":void 0)};ye&&(dt.source=Fe.source??"api",Fe.statuses!==void 0&&(dt.statuses=Fe.statuses),Fe.dataPath!==void 0&&(dt.dataPath=Fe.dataPath),Fe.showStatusText!==void 0&&(dt.showStatusText=Fe.showStatusText),Fe.statusTextPath!==void 0&&(dt.statusTextPath=Fe.statusTextPath),Fe.showCurrentIndicator!==void 0&&(dt.showCurrentIndicator=Fe.showCurrentIndicator)),Ve={...Ve,properties:dt}}}const He=["select","multiselect","radio","checkboxgroup"],rt=Ve.type||Le.fieldType;if(He.includes(rt)){const fe=Le.options,Fe=Ve.properties?.options,ye=Array.isArray(Fe)&&Fe.length>0;if(Array.isArray(fe)&&fe.length>0&&!ye){const dt=Ve.properties||{};Ve={...Ve,properties:{...dt,options:fe}}}}return Ve}),Ce=H.config?.rules,Ne=Z&&Array.isArray(Z)?Z:Ce&&Array.isArray(Ce)?Ce:[],De=Ne.length>0?le.map(Le=>{if((Le.conditions&&Array.isArray(Le.conditions)?Le.conditions:[]).length>0)return Le;const we=Le.id??Le._id,Ae=Le.name||Le.key,He=Ne.filter(Fe=>{const ye=typeof Fe.targetFieldId=="object"?Fe.targetFieldId?.id??Fe.targetFieldId?._id:Fe.targetFieldId;return ye?ye===we||ye===Ae||ye===Le.fieldKey:!1});if(He.length===0)return Le;const rt=[],fe=new Set;return He.forEach(Fe=>{try{const ye=typeof Fe.conditionExpression=="string"?JSON.parse(Fe.conditionExpression):Fe.conditionExpression;if(!ye||typeof ye!="object")return;!ye.id&&Fe.id&&(ye.id=Fe.id);const dt=typeof Fe.targetFieldId=="object"?Fe.targetFieldId?.id??Fe.targetFieldId?._id:Fe.targetFieldId;ye.action&&(!ye.then||!Array.isArray(ye.then)||ye.then.length===0)&&(ye.then=[{action:ye.action,...dt&&{target:dt}}]),(!ye.then||!Array.isArray(ye.then)||ye.then.length===0)&&Fe.action&&(ye.then=[{action:Fe.action,...dt&&{target:dt}}]),ye.then&&Array.isArray(ye.then)&&dt&&(ye.then=ye.then.map(Bt=>!Bt.target&&dt?{...Bt,target:dt}:Bt));const Wt=Fe.conditionExpression??JSON.stringify(ye);if(fe.has(Wt))return;fe.add(Wt),rt.push(ye)}catch{}}),rt.length===0?Le:{...Le,conditions:rt}}):le;let at=H.config||{submitAction:"database",layout:"default",autoSave:!0,validateOnChange:!0,showFieldErrors:"inline"};return!at.layout&&z?typeof z=="object"&&z!==null?at.layout="default":typeof z=="string"&&["default","card","compact"].includes(z)?at.layout=z:at.layout="default":at.layout||(at.layout="default"),Z&&!at.rules&&(at.rules=Z),J&&!at.clientMapping&&(at.clientMapping=J),{...H,fields:De,config:at}},[Ge,A]);S.useEffect(()=>{Ge&&Ge!==A&&I(Ge)},[Ge]),S.useEffect(()=>{if(t&&!e){const k=(Tn()??"").trim()||"default",H=Cg({scope:k,formId:t,version:"latest"});H?.value?.schema?(I(H.value.schema),H.value.bffSubmitApi&&O(H.value.bffSubmitApi),U(!1),H.isStale&&Je({background:!0})):Je({background:!1})}},[t,e]);const Je=async({background:k})=>{if(!t)return;const H=t;k||U(!0);try{const z=await Sk.getForRendering(t),Z=ps(z.form,z.fields,z.layout,z.rules);if(H!==t)return;I(Z),z.BFF_submit_api&&O(z.BFF_submit_api);const J=(Tn()??"").trim()||"default";Eg({scope:J,formId:H,version:"latest"},{schema:Z,bffSubmitApi:z.BFF_submit_api})}catch{}finally{k||U(!1)}};if(T)return c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx(Pn,{})});if(!Kt)return c.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Form not found"});const q=Kt,$e=S.useMemo(()=>new Set(Object.keys(q.config?.prepopulateApi?.fieldMapping??{})),[q.config?.prepopulateApi?.fieldMapping]),gt=S.useCallback(async k=>{const H=q?.fields?.length?Zl(k,q.fields):k,z=ph(H,q.config?.sections,q.config?.submitPayload);if(n){const Z=p?{...z,...p}:z;return n(Z)}return{success:!0}},[n,p,q?.fields,q.config?.sections,q.config?.submitPayload]),{values:Oe,errors:te,touched:pe,isSubmitting:We,isValid:Pt,submitCount:je,currentStep:Te,totalSteps:Xe,completedSteps:Ue,currentStepFields:ft,isLastStep:St,setFieldValue:xt,setFieldTouched:ze,handleSubmit:yt,validateForm:pt,resetForm:At,nextStep:Ut,goToStep:ur,shouldShowField:Ar,isFieldEnabled:Vt,isFieldRequired:Po,loadDraft:Xn}=$d({schema:q,initialValues:r,onSubmit:gt,onChange:o,workflowStepId:y});Qb({fields:q.fields,values:Oe,buttonResponses:$,prepopulateResponse:ee,prepopulateResponseRules:q.config?.prepopulateResponseRules});const Ct=Nt(k=>k.readOnlyFields),Cr=Nt(k=>k.editableFields),Jn=S.useCallback(k=>Ct.has(k),[Ct]),It=S.useCallback(k=>Cr.has(k),[Cr]);S.useEffect(()=>{q.config?.allowDraft&&a==="fill"&&Xn()},[q.id]),S.useEffect(()=>{ct.current=q.id,Ye.current=!1,R({}),K({}),ce({}),G({}),Pe(null)},[q.id]),S.useEffect(()=>{const k=q.config?.prepopulateApi,H=!!(k?.fieldMapping&&Object.keys(k?.fieldMapping??{}).length>0),z=(q.config?.prepopulateResponseRules?.length??0)>0;if(!k?.enabled||!k.apiEndpoint?.trim()||!H&&!z||Ye.current)return;Ye.current=!0;const Z=q.id;ct.current=q.id;let J=!1;return D(!0),(async()=>{try{const le=Nt.getState().values,Ce=typeof p=="object"&&p!==null?{...p,...g||{}}:g||{},Ne=se=>rn(se,le,oe,Ce);let De=cn(Ne(k.apiEndpoint));if(k.apiQueryParams?.length){const se=new URLSearchParams;k.apiQueryParams.forEach(({key:Ie,value:me})=>se.append(Ie,Ne(me))),De=`${De}${De.includes("?")?"&":"?"}${se.toString()}`}const at={};k.apiHeaders?.forEach(({key:se,value:Ie})=>{se.trim()&&(at[se]=Ne(Ie))}),at["Content-Type"]=at["Content-Type"]??"application/json";let Ht;if(k.apiMethod==="POST"&&k.apiBodyFields?.length){const se={};k.apiBodyFields.forEach(({key:Ie,value:me})=>{Ie.trim()&&(se[Ie]=Ne(me))}),Ht=JSON.stringify(se)}const Le=await fetch(De,{method:k.apiMethod,headers:at,body:k.apiMethod==="POST"?Ht:void 0});if(!Le.ok){const se=await Le.text();throw new Error(se||`HTTP ${Le.status}`)}const Ve=await Le.json(),we=se=>{try{return se.split("?")[0].split("/").filter(Boolean).pop()||se}catch{return se}},Ae=(se,Ie)=>{if(se==null)return null;const me=typeof se=="string"?se:se instanceof Date?se.toISOString():null;if(!me)return null;const Ke=typeof se=="object"&&se instanceof Date?se:new Date(me);if(Number.isNaN(Ke.getTime()))return null;const ut=mt=>String(mt).padStart(2,"0");if(Ie==="date")return me.length>=10&&me[4]==="-"&&me[7]==="-"?me.slice(0,10):Ke.toISOString().slice(0,10);if(Ie==="time")return`${ut(Ke.getHours())}:${ut(Ke.getMinutes())}:${ut(Ke.getSeconds())}`;if(Ie==="datetime"){const mt=Ke.getFullYear(),et=Ke.getMonth()+1,ue=Ke.getDate(),bt=Ke.getHours(),Re=Ke.getMinutes(),Ft=Ke.getSeconds();return`${mt}-${ut(et)}-${ut(ue)}T${ut(bt)}:${ut(Re)}:${ut(Ft)}`}return null},He=(se,Ie)=>{const me=q.fields.find(ue=>ue.name===se||ue.key===se);if(!me)return Ie;if((me.type==="file"||me.type==="camera"||me.type==="photoChoice")&&typeof Ie=="string"&&Ie.startsWith("http"))return{url:Ie,name:we(Ie)};if(me.type==="date"||me.type==="datetime"||me.type==="time"){const ue=Ae(Ie,me.type);if(ue!==null)return ue}if(me.type==="multiselect")return Array.isArray(Ie)?Ie.map(ue=>typeof ue=="string"?ue:String(ue)):typeof Ie=="string"?Ie.trim()===""?[]:Ie.includes(",")?Ie.split(",").map(ue=>ue.trim()).filter(Boolean):[Ie]:Ie!=null&&Ie!==""?[String(Ie)]:[];if(me.type!=="radio"&&me.type!=="select")return Ie;const Ke=me.properties?.options??me.options;if(!Array.isArray(Ke)||Ke.length===0)return Ie;const ut=Ke.map(ue=>ue.value);if(ut.includes(Ie))return Ie;const mt=String(Ie);if(ut.includes(mt))return mt;const et=Ke.find(ue=>ue.value==Ie);return et?et.value:Ie},rt=new Set(q.fields.filter(se=>se.type==="table").map(se=>se.name||se.key)),fe=new Set(q.fields.filter(se=>se.type==="billingGrid").map(se=>se.name||se.key)),Fe=se=>se.name||se.key||se.id,ye={},dt=[],Wt=[],Bt=cN(k?.fieldMapping,q.config?.sections,q.config?.submitPayload);for(const[se,Ie]of Object.entries(Bt)){if(!Ie?.trim()||se.startsWith("__"))continue;const me=tt(Ve,Ie),Ke=se.indexOf(".");if(Ke>0&&fe.has(se.slice(0,Ke))){const mt=se.slice(0,Ke),et=se.slice(Ke+1),bt=q.fields.find(Re=>(Re.name||Re.key)===mt)?.properties;if(bt?.rowSlots?.length){const Re=et.startsWith("__block__")?et.slice(9):et,Ft=ye[mt]??Nt.getState().values[mt];Array.isArray(me)?ye[mt]=t_(bt,Re,me,Ft):me!=null&&(ye[mt]=dc(bt,me,Ft))}continue}if(Ke>0&&rt.has(se.slice(0,Ke))){const mt=se.slice(0,Ke),et=se.slice(Ke+1);dt.push({tableName:mt,columnName:et,path:Ie});continue}if(fe.has(se)&&me!==void 0&&me!==null&&typeof me=="object"){const et=q.fields.find(ue=>(ue.name||ue.key)===se)?.properties;if(et?.rowSlots?.length){if(Array.isArray(me)){const ue=et.rowSlots.find(bt=>bt.kind==="dynamic");if(ue&&ue.kind==="dynamic"){const bt=ue.block.apiArrayPath??"items";ye[se]=dc(et,{[bt]:me})}}else ye[se]=dc(et,me);continue}}if(rt.has(se)&&Array.isArray(me)&&me.length>0&&typeof me[0]=="object"&&me[0]!==null){const et=q.fields.find(Re=>(Re.name||Re.key)===se)?.properties?.columns||[],ue=me.map(Ng),bt=Re=>(Re||"").toLowerCase().replace(/\s+/g,"_").trim();ye[se]=ue.map(Re=>{const Ft={};for(const fr of et){const eo=fr.name??"";Ft[eo]=Re[bt(eo)]??Re[eo]}return Ft});continue}if(me!=null&&(ye[se]=He(se,me)),me==null)continue;let ut=me;if(Array.isArray(me)){const mt=q.fields.find(et=>Fe(et)===se);if(mt?.type==="addmore"){Wt.push({addMoreFieldName:se,array:me});continue}if(mt?.type==="multiselect"){const et=k.multiselectArrayPropertyMap?.[se];et&&me.length>0&&me.some(ue=>ue!=null&&typeof ue=="object")&&(ut=me.map(ue=>ue!=null&&typeof ue=="object"&&et in ue?ue[et]:void 0).filter(ue=>ue!=null))}}ye[se]=He(se,ut)}const lt={},vt={},rr={};for(const{addMoreFieldName:se,array:Ie}of Wt){const me=q.fields.find(bt=>Fe(bt)===se);if(!me||me.type!=="addmore")continue;const Ke=bg(me,q.fields,q.config?.sections,Fe);if(Ke.length===0)continue;const ut=k.addMoreFieldKeyMap?.[se],mt=Ie.length>0&&Ie[0]!=null&&typeof Ie[0]=="object"?Ie[0]:null;if(mt)for(const bt of Ke){const Re=Fe(bt),Ft=ut&&ut[Re]||Re,fr=mt[Ft];fr!=null&&(ye[Re]=He(Re,fr))}const et=Ie.slice(1),ue=et.map((bt,Re)=>`prepop_${se}_${Re}_${Date.now()}`);ue.length>0&&(vt[se]=ue);for(let bt=0;bt<et.length;bt++){const Re=et[bt];if(Re==null||typeof Re!="object")continue;const Ft=Re,fr=Ft.id;fr!=null&&String(fr).trim()!==""&&(rr[`${se}__${ue[bt]}`]=String(fr));for(const eo of Ke){const fa=Fe(eo),ZF=ut&&ut[fa]||fa,Hc=Ft[ZF];if(Hc==null)continue;const eP=`${fa}__addmore__${se}__${ue[bt]}`;lt[eP]=He(fa,Hc)}}}Object.keys(vt).length>0&&K(se=>({...se,...vt})),Object.keys(rr).length>0&&G(se=>({...se,...rr}));const jr=se=>(se||"").toLowerCase().replace(/\s+/g,"_").trim(),Kr=[...new Set(dt.map(se=>se.tableName))];for(const se of Kr){if(Array.isArray(ye[se]))continue;const Ie=dt.find(ue=>ue.tableName===se);if(!Ie?.path?.includes("."))continue;const me=Ie.path.replace(/\.[^.]+$/,""),Ke=tt(Ve,me);if(!Array.isArray(Ke)||Ke.length===0||typeof Ke[0]!="object"||Ke[0]===null)continue;const mt=q.fields.find(ue=>(ue.name||ue.key)===se)?.properties?.columns||[],et=Ke.map(Ng);ye[se]=et.map(ue=>{const bt={};for(const Re of mt){const Ft=Re.name??"",fr=jr(Ft),eo=ue[fr]??ue[Ft];bt[Ft]=eo}return bt})}const zr=(se,Ie)=>{const me=tt(Ve,se);if(Array.isArray(me))return me;if(me!=null)return[me];if(!se.includes("."))return[];const Ke=se.replace(/\.[^.]+$/,""),ut=tt(Ve,Ke);return!Array.isArray(ut)||ut.length===0||typeof ut[0]!="object"||ut[0]===null?[]:ut.map(mt=>{const et=mt[Ie];if(et!==null&&typeof et=="object"&&!Array.isArray(et)&&!(et instanceof Date)){const ue=et;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 et})};for(const{tableName:se,columnName:Ie,path:me}of dt){const Ke=zr(me,Ie),mt=q.fields.find(Re=>(Re.name||Re.key)===se)?.properties?.columns||[],et=mt.find(Re=>(Re.name||"").toLowerCase()===Ie.toLowerCase())?.name??Ie;let ue=Array.isArray(ye[se])?ye[se]:[];const bt=Math.max(ue.length,Ke.length);if(bt>ue.length)for(ue=[...ue];ue.length<bt;){const Re={};mt.forEach(Ft=>{Re[Ft.name||""]=""}),ue.push(Re)}else ue=ue.map(Re=>({...Re}));Ke.forEach((Re,Ft)=>{ue[Ft]&&(ue[Ft][et]=Re)}),ye[se]=ue}if(ct.current===Z){if(Object.keys(ye).length>0||Object.keys(lt).length>0){const Ft={...Nt.getState().values,...ye,...lt};re(Ft)}const Ie=tt(Ve,"data.user_id"),me=tt(Ve,"data.items"),Ke=tt(Ve,"data");let ut=Array.isArray(me)&&me.length>0&&me[0]!=null&&typeof me[0]=="object"&&me[0].id?me[0].id:void 0;ut===void 0&&Array.isArray(Ke)&&Ke.length>0&&Ke[0]!=null&&typeof Ke[0]=="object"&&Ke[0].id&&(ut=Ke[0].id),ut===void 0&&(ut=tt(Ve,"data.0.id"));const mt=Vk(Ve,{treatFirstItemIdAsPaymentId:k?.treatFirstItemIdAsPaymentId===!0}),et=tt(Ve,"data.id"),ue=tt(Ve,"data.batch_id"),bt=tt(Ve,"data.program_id"),Re={};Ie!=null&&(Re.context_user_id=Ie),ut!=null&&ut!==""&&(Re.documentId=ut),et!=null&&String(et).trim()!==""&&(p?.id===void 0||p?.id===null)&&(Re.id=et),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&&R(Ft=>{const fr={...Ft,...Re};return h?.(fr),fr}),Pe(Ve)}}catch(le){J||Jl(le,"Prepopulate request failed.",ls)}finally{D(!1)}})(),()=>{J=!0}},[q.id,q.config?.prepopulateApi?.enabled,q.config?.prepopulateApi?.apiEndpoint,q.config?.prepopulateApi?.apiMethod,JSON.stringify(q.config?.prepopulateApi?.fieldMapping),q.config?.prepopulateApi?.treatFirstItemIdAsPaymentId,p,g,oe,re,K]),S.useEffect(()=>{Object.keys(te).length>0&&s?.(te)},[te,s]);const Er=Xe>1,er=a==="view",sr=S.useCallback((k,H)=>er||!!H&&!It(k)||Jn(k)&&!It(k),[er,It,Jn]),fn=q.fields.filter(k=>!k.parentId),kt=[...Er?ft:fn.length>0?fn:q.fields].filter(k=>!(!k||typeof k!="object"||!k.name&&!k.key)).sort((k,H)=>{const z=typeof k.position?.order=="number"?k.position.order:typeof k.positionOrder=="number"?k.positionOrder:Number.MAX_SAFE_INTEGER,Z=typeof H.position?.order=="number"?H.position.order:typeof H.positionOrder=="number"?H.positionOrder:Number.MAX_SAFE_INTEGER;if(z!==Z)return z-Z;const J=typeof k.position?.column=="number"?k.position.column:1,le=typeof H.position?.column=="number"?H.position.column:1;return J-le}),ws=S.useCallback(k=>{const H=Nt.getState().errors,z=Object.keys(H).find(Z=>k.includes(Z));z&&requestAnimationFrame(()=>{document.querySelector(`[data-field-name="${z}"]`)?.scrollIntoView({behavior:"smooth",block:"center"})})},[]),Nr=async k=>{if(k?.preventDefault(),Er&&!St){if(!await Ut())try{const Z=Nt.getState().errors;$t.toast.error(Ql(Z,q.fields)||"Please fix the errors before continuing."),ws(kt.map(J=>J.name||J.key||J.id).filter(Boolean))}catch{$t.toast.error("Please fix the errors before continuing.")}return}const H=await yt(k);if(H&&H.success===!1&&H.errors?.length)try{const z=Nt.getState().errors;$t.toast.error(Ql(z,q.fields)||"Submission failed. Please check the form."),ws(kt.map(Z=>Z.name||Z.key||Z.id).filter(Boolean))}catch{$t.toast.error("Submission failed. Please check the form.")}return H},Dr=S.useCallback(()=>{At(),i&&i()},[At,i]),_r=S.useCallback((k,H)=>{const z=q.fields.find(J=>J.type==="button"&&(J.name===k||J.key===k)),Z=Gk(H,z);Z!=null&&String(Z).trim()!==""&&(p?.payment_id===void 0||p?.payment_id===null)&&R(J=>{const le={...J,payment_id:Z};return h?.(le),le}),ie(J=>{const le={...J,[k]:H};return!Uo(H)||!(z?.type==="button"&&z.properties?.action==="submit")||q.fields.filter(De=>De.type==="editButton").map(De=>De.name).forEach(De=>delete le[De]),le})},[q.fields,p,h]),br=S.useCallback(async()=>await pt(),[pt]),qt=S.useCallback(()=>Nt.getState().errors,[]),tr=S.useMemo(()=>({...g||{},...M}),[g,M]),Br=S.useMemo(()=>({...typeof p=="object"&&p!==null?p:{},...tr}),[p,tr]),Xi=q.config?.layout??q.layout??"default",Ji=["default","card","compact"].includes(Xi)?Xi:"default",Qi={default:"",card:"bg-card border rounded-lg shadow-sm p-6",compact:"space-y-2"},Ss=S.useMemo(()=>{if(C)return;const k=q.config?.theme?.cssVariables;if(!(!k&&!E))return{...k??{},...E??{}}},[C,q.config?.theme?.cssVariables,E]),kr=S.useMemo(()=>Ns({config:q.config,layout:q.layout},l),[q.config,q.layout,l]),Ee=S.useMemo(()=>kr?{...kr,verticalSpacing:kr.verticalSpacing??kr.spacing??"16px",horizontalSpacing:kr.horizontalSpacing??kr.spacing??"16px",rowHeight:kr.rowHeight??In}:null,[kr]),F=Ee!==null;Ee?.rows;const Y=Ee?.columns??3,he=Ee?.verticalSpacing??Ee?.spacing??"16px",st=Ee?.horizontalSpacing??Ee?.spacing??"16px",Tt=Ee?.rowHeight??In,wt=S.useCallback(k=>{if(!_)return!0;const H=k.visibility;if(!H)return!0;const z=H.visibleToUserType??H.user_type,Z=H.visibleToUserRole??H.user_role,J=Array.isArray(H.visibleToUserIds)?H.visibleToUserIds:Array.isArray(H.users)?H.users:[],le=Array.isArray(H.hiddenFromUserIds)?H.hiddenFromUserIds:[];if(Array.isArray(le)&&le.length>0&&_.userId!=null&&le.includes(_.userId))return!1;if(J.length>0&&_.userId!=null&&J.includes(_.userId))return!0;const Ce=z!=null&&z!==""&&_.userType!=null&&_.userType!==z,Ne=Z!=null&&Z!==""&&_.role!=null&&_.role!==Z,De=J.length>0&&(_.userId==null||!J.includes(_.userId));return!(Ce||Ne||De)},[_]),Mt=S.useMemo(()=>vN(q.fields),[q.fields]),$r=S.useMemo(()=>SN(q.fields),[q.fields]),[ir,Oo]=S.useState($r);S.useEffect(()=>{Oo($r)},[q.id,$r]);const Lt=S.useCallback((k,H)=>{Oo(z=>z[k]===H?z:{...z,[k]:H})},[]),Zi=S.useMemo(()=>({visibility:ir,setSectionVisible:Lt,fieldToHeading:Mt,allFields:q.fields}),[ir,Lt,Mt,q.fields]),Ze=S.useCallback(k=>k.name||k.key||k.id,[]),Tr=k=>{if(!wt(k))return!1;const H=k.name||k.key||k.id;if(!gh(H,k.type,ir,Mt))return!1;const z=k.hidden===!0;return Ar(H)||!z&&H},dy=S.useCallback(k=>{const H=q.fields.find(Z=>Ze(Z)===k);if(H)return H.type;const z=hh(k);return q.fields.find(Z=>Ze(Z)===z)?.type},[q.fields,Ze]),ea=S.useCallback(k=>gh(k,dy(k),ir,Mt),[ir,Mt,dy]),pn=S.useCallback(k=>ea(k)?Po(k):!1,[ea,Po]);S.useEffect(()=>{const{visibleFields:k,requiredFields:H,errors:z}=Nt.getState(),Z=new Set(k),J=new Set(H),le=[];for(const Ce of q.fields){const Ne=Ze(Ce);Ne&&(ea(Ne)||(Z.delete(Ne),J.delete(Ne),z[Ne]&&le.push(Ne)))}xe(Array.from(Z)),ae(Array.from(J));for(const Ce of le)ve(Ce,void 0)},[ir,Mt,q.fields,q.id,Ze,ea,xe,ae,ve,ot,Se]);const Dt=q.config?.sections,Qn=S.useCallback(k=>{let H=k;if(k.type==="table"){const Z=k.properties?.columns;if(Array.isArray(Z)&&Z.length>0){const J=Z.filter(le=>wt(le));H={...k,properties:{...k.properties,columns:J}}}}const z=Jk(H,Dt,Ze);return z?{...H,label:yg(z,0)}:H},[wt,Dt,Ze]),mn=S.useCallback(k=>bg(k,q.fields,Dt,Ze),[q.fields,Dt,Ze]),Gr=S.useCallback((k,H,z)=>`${k}__addmore__${H}__${z}`,[]),ta=S.useCallback((k,H)=>`${k}__${H??"base"}`,[]),ra=S.useCallback((k,H)=>{const z=ta(k.id,H);return X[z]??k.defaultCollapsed??!1},[X,ta]),zc=S.useCallback((k,H,z)=>{const Z=ta(k,H);ce(J=>J[Z]===z?J:{...J,[Z]:z})},[ta]),na=S.useMemo(()=>{const k=[],H=q.fields.filter(z=>z.type==="addmore");for(const z of H){const Z=Ze(z),le=mn(z).find(at=>{if(at.type!=="button")return!1;const Ht=at.properties,Le=at.metadata;let Ve=Ht?.action;if(!Ve&&Le!=null)try{Ve=(typeof Le=="string"?JSON.parse(Le):Le)?.action}catch{}return Ve==="upload"||Ve==="custom"});if(!le)continue;const Ce=Ze(le),Ne=V[Z]||[],De=tt($[Ce],"data.id")??tt($[Ce],"data.documentId")??M.documentId;De!=null&&String(De).trim()!==""&&k.push(String(De));for(const at of Ne){const Ht=Gr(Ce,Z,at),Le=tt($[Ht],"data.id")??tt($[Ht],"data.documentId"),Ve=ne[`${Z}__${at}`],we=Le??Ve;we!=null&&String(we).trim()!==""&&k.push(String(we))}}return k},[q.fields,V,$,ne,M.documentId,Ze,mn,Gr]);S.useEffect(()=>{R(k=>{const H={...k,document_ids:na},z=k.document_ids;return Array.isArray(z)&&z.length===na.length&&na.every((Z,J)=>z[J]===Z)?k:H})},[na]);const oa=S.useCallback((k,H,z,Z)=>{for(const J of z){const le=Ze(J),Ce=Gr(le,k,H),Ne=Z[Ce];if(Ne==null)continue;const De=J.type;if(De==="file"||De==="camera"||De==="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},[Ze,Gr]),Zn=S.useCallback(k=>{const H=Ze(k);if(!H)return;if(mn(k).length===0){$t.toast.error("No linked fields configured for this Add More button.");return}const Z=`${Date.now()}_${Math.random().toString(36).slice(2,8)}`;K(J=>({...J,[H]:[...J[H]||[],Z]}))},[Ze,mn]),sa=S.useCallback((k,H)=>{K(z=>{const Z=z[k]||[],J=Z.filter(le=>le!==H);if(J.length===Z.length)return z;if(J.length===0){const le={...z};return delete le[k],le}return{...z,[k]:J}})},[]),ia=S.useMemo(()=>kt.filter(k=>!k.parentId),[kt]),On=S.useMemo(()=>{const k=[];return kt.filter(z=>z.type==="addmore").sort((z,Z)=>{const J=z.position?.order??0,le=Z.position?.order??0;return J-le}).forEach(z=>{const Z=Ze(z),J=z.position?.order??0,le=V[Z]||[],Ce=mn(z).sort((Ae,He)=>{const rt=Ae.position?.order??0,fe=He.position?.order??0;return rt!==fe?rt-fe:(Ae.position?.column??1)-(He.position?.column??1)});if(Ce.length===0)return;const Ne=gg(z,Dt),De=Ne[0]?.fieldNames?.length?Ne[0].fieldNames:Ce.map(Ae=>Ze(Ae)).filter(Boolean),at=eT(De,ia,Y,Ze),Ht=Math.min(...Ce.map(Ae=>Ae.position?.order??0)),Le=Math.max(1,...Ce.map(Ae=>(Ae.position?.order??Ht)-Ht+Do(Ae))),Ve=at?.blockHeight??Le,we=le.length*Ve;k.push({addMoreFieldName:Z,baseOrder:J,blockHeight:Ve,blockIds:le,linkedFields:Ce,insertedRows:we,templateFieldNames:De,templateBounds:at})}),k},[kt,ia,Y,Ze,V,mn,Dt]),xs=S.useMemo(()=>({}),[]),aa=S.useMemo(()=>On.length===0?kt:kt.map(k=>{const H=k.position?.order??0,z=On.reduce((Z,J)=>{const le=J.templateBounds?.maxRow??J.baseOrder;return H>le?Z+J.insertedRows:Z},0);return z===0?k:{...k,position:{...k.position,order:H+z}}}),[kt,On]),la=S.useCallback(k=>{const H={};return Object.entries($).forEach(([z,Z])=>{const J=k[z];J&&(H[J]=Z)}),H},[$]),Io=S.useMemo(()=>{const k=[],H={};return On.forEach(z=>{const{addMoreFieldName:Z,blockIds:J,linkedFields:le,blockHeight:Ce,templateBounds:Ne}=z,De=Math.min(...le.map(Le=>Le.position?.order??0)),Ht=q.fields.find(Le=>Ze(Le)===Z&&Le.type==="addmore")?.properties;J.forEach((Le,Ve)=>{const we={},Ae={},He={},rt=Ne?tT(Ne,Ve):z.baseOrder+1+Ve*Ce,fe=ne[`${Z}__${Le}`];le.forEach(ye=>{const dt=Ze(ye),Wt=Gr(dt,Z,Le),Bt=(ye.position?.order??De)-De;if(we[Wt]=dt,Ae[Wt]=Oe[Wt],!(Ht?.linkedFieldAllowDuplicate?.[dt]??!0)&&(ye.type==="select"||ye.type==="radio"||ye.type==="multiselect")){const vt=[],rr=Oe[dt];rr!=null&&rr!==""&&(Array.isArray(rr)?vt.push(...rr.map(Kr=>String(Kr))):vt.push(String(rr))),J.filter(Kr=>Kr!==Le).forEach(Kr=>{const zr=Gr(dt,Z,Kr),qr=Oe[zr];qr!=null&&qr!==""&&(Array.isArray(qr)?vt.push(...qr.map(se=>String(se))):vt.push(String(qr)))}),vt.length>0&&(He[Wt]=[...new Set(vt)])}k.push({...ye,id:`${ye.id}__${Le}`,name:Wt,position:{...ye.position,order:rt+Bt}})});const Fe=la(we);Object.keys(we).forEach(ye=>{H[ye]={scopedFormValues:Ae,scopedFieldNameMap:we,scopedButtonResponses:Fe,...fe!=null&&{blockDocumentId:fe},...He[ye]&&{excludedOptionValues:He[ye]}}})})}),{clonedFields:k,scopeByFieldName:H}},[On,ne,Ze,Gr,Oe,la,q.fields]),As=S.useMemo(()=>[...aa,...Io.clonedFields].sort((k,H)=>{const z=k.position?.order??0,Z=H.position?.order??0;if(z!==Z)return z-Z;const J=k.position?.column??1,le=H.position?.column??1;if(J!==le)return J-le;const Ce=ko(k.position)??0,Ne=ko(H.position)??0;return Ce!==Ne?Ce-Ne:String(k.id).localeCompare(String(H.id))}),[aa,Io.clonedFields]),Mo=S.useMemo(()=>kk(As.filter(k=>!k.parentId),Tr),[As,Tr]),Uc=S.useCallback((k,H)=>Mo.some(z=>Tk(k,H,z,Y)),[Mo,Y]);Mo.length===0||Math.max(...Mo.map(k=>(k[0]?.position?.order??0)+hs(k,Y).rowSpan));const ca=S.useMemo(()=>Qk(Dt,kc(kt.filter(k=>!k.parentId)),Ze),[Dt,kt,Ze]),{anchorsByOrigin:uy,coveredCells:fy}=S.useMemo(()=>rT(ca,aa,Ze,Y),[ca,aa,Ze,Y]),{anchorsByOrigin:py,coveredCells:my}=S.useMemo(()=>nT(On.map(k=>({addMoreFieldName:k.addMoreFieldName,blockIds:k.blockIds,linkedFields:k.linkedFields,templateFieldNames:k.templateFieldNames})),Dt,Io.clonedFields,ia,Y,Ze,fy),[On,Dt,Io.clonedFields,ia,Y,Ze,fy]),hn=S.useMemo(()=>cT(uy,py),[uy,py]),hy=S.useMemo(()=>my,[my]),gy=String(Tt).endsWith("px")?Tt:In,yy=S.useCallback((k,H)=>{for(let z=0;z<Y;z++){if(z>=H.anchorCol&&z<H.anchorCol+H.colSpan)continue;if(xs[`${k}-${z}`]||hn.get(`${k}-${z}`)||fg(k,z,As,Tr).length>0||Uc(k,z))return!0}return!1},[Y,xs,hn,As,Tr,Uc]),by=S.useMemo(()=>aT(hn,k=>{const H=k.run.section;return H.collapsible?ra(H,k.addMoreMeta?.blockId):!1},yy),[hn,ra,yy]),vy=S.useMemo(()=>{const k=[];for(const H of Object.keys(xs)){const z=Number(H.split("-")[0]);Number.isNaN(z)||k.push(z)}for(const H of hn.values())if(H.renderFields.some(z=>Tr(z)))for(let z=H.anchorRow;z<H.anchorRow+H.rowSpan;z++)k.push(z);return Fk(Mo,Y,k)},[Mo,Y,xs,hn,Tr]),{originalToDisplayRow:da,displayRowCount:YF,sortedOccupiedRows:XF}=S.useMemo(()=>{const k=Pk(vy);return{originalToDisplayRow:k.originalToDisplay,displayRowCount:k.displayRowCount,sortedOccupiedRows:k.sortedOriginalRows}},[vy]),wy=Math.max(YF,1),Vc=S.useCallback((k,H=1)=>Ok(k,H,da),[da]),Sy=S.useMemo(()=>{const k=new Set;for(const H of by){const z=da.get(H);z!==void 0&&k.add(z)}return k},[by,da]),JF=S.useMemo(()=>lT(wy,gy,Sy),[wy,gy,Sy]),QF=S.useMemo(()=>dT(kt.filter(k=>!k.parentId&&Tr(k)),ca,Ze),[kt,ca,Ze,Tr]),ua=S.useCallback(k=>{if(F)return null;const H=Ze(k),z=V[H]||[];if(z.length===0)return null;const Z=mn(k);if(Z.length===0)return null;const J=Xk(k,Dt),le=Z.map(De=>Ze(De)).filter(Boolean),Ce=wg(le,Dt),Ne=(De,at,Ht,Le,Ve,we,Ae)=>{const He=Ze(De),rt=Gr(He,H,at),fe=De.hidden===!0;if(!(wt(De)&&(Ar(He)||!fe&&He)))return null;const ye={...De,id:`${De.id}__${at}`,name:rt},Wt=k.properties?.linkedFieldAllowDuplicate?.[He]??!0;let Bt;if(!Wt&&(De.type==="select"||De.type==="radio"||De.type==="multiselect")){const lt=[],vt=Oe[He];vt!=null&&vt!==""&&(Array.isArray(vt)?lt.push(...vt.map(jr=>String(jr))):lt.push(String(vt))),z.filter(jr=>jr!==at).forEach(jr=>{const Kr=Gr(He,H,jr),zr=Oe[Kr];zr!=null&&zr!==""&&(Array.isArray(zr)?lt.push(...zr.map(qr=>String(qr))):lt.push(String(zr)))}),lt.length>0&&(Bt=[...new Set(lt)])}return c.jsx("div",{"data-field-name":rt,"data-form-renderer":"field-wrapper",children:c.jsx(un,{field:ye,value:Oe[rt],error:pe[rt]||je>0?te[rt]:void 0,onChange:lt=>xt(rt,lt),onBlur:()=>ze(rt),disabled:de||!Vt(He)||er||!!De.disabled,readOnly:sr(He,!!De.readOnly),isRequired:pn(He),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:L,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:rt,buttonResponses:we,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:Ae,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,scopedFormValues:Ve,scopedFieldNameMap:Le,excludedOptionValues:Bt,hideTableRowControls:x})},ye.id)};return c.jsx("div",{className:"space-y-3 mt-3",children:z.map((De,at)=>{const Ht={},Le={};Z.forEach(Bt=>{const lt=Ze(Bt),vt=Gr(lt,H,De);Ht[vt]=lt,Le[vt]=Oe[vt]});const Ve=la(Ht),we=oa(H,De,Z,Oe),Ae=J?.heading!=null?ys(J,at+1):null,He=ne[`${H}__${De}`],rt=He!=null?{...tr,documentId:He}:tr,fe=Z.map(Bt=>Ne(Bt,De,at,Ht,Le,Ve,rt)).filter(Boolean),ye=Ce?.section?.collapsible===!0,dt=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:we,title:we?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:Bt=>{Bt.preventDefault(),Bt.stopPropagation(),sa(H,De)},children:c.jsx(Go,{className:"h-5 w-5","aria-hidden":!0})}),Wt=c.jsxs(c.Fragment,{children:[!ye&&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 ",at+1]}),dt]}),fe]});return c.jsx("div",{className:"rounded-md border p-3 space-y-3",children:Ce?c.jsx(Cc,{legend:Ce.section.heading?.enabled?ys(Ce.section,at+1):Ce.section.name,collapsible:Ce.section.collapsible,defaultCollapsed:Ce.section.defaultCollapsed,headerActions:ye?dt:void 0,onCollapsedChange:Bt=>zc(Ce.section.id,De,Bt),children:Wt}):Wt},`${k.id}-${De}`)})})},[F,V,ne,Ze,mn,Gr,oa,Oe,pe,je,te,xt,ze,Vt,er,pn,Br,$e,_r,Nr,At,Dr,We,j,m,tr,br,qt,q.fields,be,Ar,wt,la,sa,x,Dt,oe,ee,L]);return c.jsx("div",{className:C?B("relative",d):B(ma,P&&"dark",d),style:Ss,"data-form-renderer":C?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(Pn,{})}),c.jsx("form",{onSubmit:Nr,className:f?B("w-full min-w-0"):B("space-y-6 pb-[100px] w-full min-w-0",Qi[Ji]),"data-form-renderer":"form","data-form-renderer-layout":F?"grid":"stack",children:c.jsxs(gN,{value:Zi,children:[Er&&q.steps&&c.jsx(bk,{steps:q.steps,currentStep:Te,completedSteps:Ue,onStepClick:ur}),c.jsx(Ea.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:JF,gridTemplateColumns:`repeat(${Y}, 1fr)`,rowGap:he,columnGap:st},"data-form-renderer":"grid",children:XF.map(k=>Array.from({length:Y},(H,z)=>{const Z=Vc(k);if(!Z)return null;if(Uc(k,z))return c.jsx("div",{className:"min-w-0 min-h-0",style:{gridRow:Z,gridColumn:z+1,visibility:"hidden",pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`empty-${k}-${z}`);if(oT(k,z,hy,hn)){const we=sT(k,z,hn);return we&&iT(k,z,we,ra(we.run.section,we.addMoreMeta?.blockId))?null:c.jsx("div",{className:"min-w-0 min-h-0",style:{gridRow:Z,gridColumn:z+1,visibility:"hidden",pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`section-border-cover-${k}-${z}`)}const J=hn.get(`${k}-${z}`);if(J){const we=J.renderFields.filter(lt=>Tr(lt));if(we.length===0)return null;const Ae=J.addMoreMeta,He=Ae!=null?On.find(lt=>lt.addMoreFieldName===Ae.addMoreFieldName)?.linkedFields??[]:[],rt=Ae!=null?oa(Ae.addMoreFieldName,Ae.blockId,He,Oe):!1,fe=J.run.section,Fe=Ae?.blockId,ye=ra(fe,Fe),dt=fe.collapsible&&ye?1:J.rowSpan,Wt=Vc(J.anchorRow,dt)??Z,Bt=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:rt,title:rt?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:lt=>{lt.preventDefault(),lt.stopPropagation(),sa(Ae.addMoreFieldName,Ae.blockId)},children:c.jsx(Go,{className:"h-5 w-5","aria-hidden":!0})}):void 0;return c.jsx("div",{className:B("min-h-0 min-w-0",!(fe.collapsible&&ye)&&"self-stretch"),style:{gridRow:Wt,gridColumn:`${z+1} / span ${J.colSpan}`},"data-form-renderer":"grid-cell","data-form-renderer-config-section-border-cell":!0,children:c.jsx(Cc,{legend:J.legend,className:fe.collapsible&&ye?void 0:"h-full",collapsible:fe.collapsible,defaultCollapsed:fe.defaultCollapsed,headerActions:Bt,onCollapsedChange:lt=>zc(fe.id,Fe,lt),children:c.jsx("div",{className:"grid w-full min-w-0",style:{gridTemplateColumns:`repeat(${Y}, 1fr)`,gridTemplateRows:`repeat(${J.rowSpan}, minmax(${String(Tt).endsWith("px")?Tt:In}, auto))`,rowGap:he,columnGap:st},children:we.map(lt=>{const vt=Ze(lt),rr=Io.scopeByFieldName[vt],jr=rr?.scopedFieldNameMap?.[vt]||vt,Kr=(lt.position?.order??J.anchorRow)-J.anchorRow,zr=lt.position?.column??1,{rowSpan:qr,columnSpan:se}=hs([lt],Y),Ie=Ae!=null?ne[`${Ae.addMoreFieldName}__${Ae.blockId}`]:void 0,me=Ie!=null?{...tr,documentId:Ie}:tr;return c.jsx("div",{"data-field-name":vt,"data-form-renderer":"field-wrapper",className:"min-h-0 min-w-0",style:{gridRow:`${Kr+1} / span ${qr}`,gridColumn:`${zr} / span ${se}`,...xn(lt)},children:c.jsx(un,{field:Qn(lt),value:Oe[vt],error:pe[vt]||je>0?te[vt]:void 0,onChange:Ke=>xt(vt,Ke),onBlur:()=>ze(vt),disabled:(lt.type==="table"||lt.type==="billingGrid")&&a==="fill"?!1:de||!Vt(jr)||er||!!lt.disabled,readOnly:(lt.type==="table"||lt.type==="billingGrid")&&a==="fill"?!1:sr(jr,!!lt.readOnly),isRequired:pn(jr),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:L,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:vt,buttonResponses:rr?.scopedButtonResponses??$,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:me,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,onAddMore:Zn,scopedFormValues:rr?.scopedFormValues,scopedFieldNameMap:rr?.scopedFieldNameMap,excludedOptionValues:rr?.excludedOptionValues,hideTableRowControls:x})},lt.id)})})})},`section-border-${J.run.section.id}-${k}-${z}-${Ae?.blockId??"base"}`)}const le=fg(k,z,As,Tr).filter(we=>!(Ze(we)?.includes("__addmore__")&&hy.has(`${k}-${z}`)));if(le.length===0){const we=xs[`${k}-${z}`];if(we){const Ae=q.fields.find(fe=>fe.type==="addmore"&&Ze(fe)===we.addMoreFieldName),He=Ae!=null?mn(Ae):[],rt=oa(we.addMoreFieldName,we.blockId,He,Oe);return c.jsx("div",{className:"min-h-0 min-w-0 flex flex-col items-center justify-center",style:{gridRow:Z,gridColumn:z+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:rt,title:rt?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:fe=>{fe.preventDefault(),fe.stopPropagation(),sa(we.addMoreFieldName,we.blockId)},children:c.jsx(Go,{className:"h-5 w-5","aria-hidden":!0})})},`add-more-remove-${k}-${z}`)}return c.jsx("div",{className:"min-w-0",style:{pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`empty-${k}-${z}`)}const Ce=le[0],{rowSpan:Ne,columnSpan:De}=hs(le,Y),at=Vc(k,Ne)??Z;if(le.length===1&&Ce.type==="section"){const we=q.fields.filter(Ae=>Ae.parentId===Ce.id&&Ae.position!=null).sort((Ae,He)=>{const rt=typeof Ae.position?.order=="number"?Ae.position.order:0,fe=typeof He.position?.order=="number"?He.position.order:0;return rt-fe});return c.jsx("div",{className:"min-w-0 min-h-0 w-full overflow-hidden flex flex-col h-full",style:{gridRow:at,gridColumn:`${z+1} / span ${De}`,...xn(Ce)},"data-form-renderer":"grid-cell",children:c.jsx(Dh,{field:Ce,children:we.map(Ae=>{const He=Ae.name||Ae.key||Ae.id,rt=Ae.hidden===!0;return wt(Ae)&&(Ar(He)||!rt&&He)?c.jsx("div",{"data-field-name":He,"data-form-renderer":"field-wrapper",children:c.jsx(un,{field:Qn(Ae),value:Oe[He],error:pe[He]||je>0?te[He]:void 0,onChange:Fe=>xt(He,Fe),onBlur:()=>ze(He),disabled:de||!Vt(He)||er||!!Ae.disabled,readOnly:sr(He,!!Ae.readOnly),isRequired:pn(He),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:L,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:He,buttonResponses:$,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:tr,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,onAddMore:Zn,hideTableRowControls:x})},Ae.id):null})})},Ce.id)}const Ht=dg(le),Le=le.some(we=>["file","camera","photoChoice","addmore","table","billingGrid"].includes(we.type)),Ve=c.jsx("div",{className:B("flex min-h-0 w-full flex-1 gap-3",Ht==="row"?"flex-row items-stretch":"flex-col items-stretch"),children:le.map(we=>{const Ae=we.name||we.key||we.id,He=we.type==="sectionHeading",rt=Io.scopeByFieldName[Ae],fe=rt?.scopedFieldNameMap?.[Ae]||Ae,Fe=rt?.blockDocumentId!=null?{...tr,documentId:rt.blockDocumentId}:tr,ye=we.appearance?.hideLabel??we.properties?.hideLabel??!1,dt=we.type==="table"||we.type==="billingGrid"?we.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",jo(we),He&&"items-center justify-center",ye&&"items-center"),style:{...dt?{minWidth:dt}:{},...xn(we)},children:c.jsx(un,{field:Qn(we),value:Oe[Ae],error:pe[Ae]||je>0?te[Ae]:void 0,onChange:Wt=>xt(Ae,Wt),onBlur:()=>ze(Ae),disabled:(we.type==="table"||we.type==="billingGrid")&&a==="fill"?!1:de||!Vt(fe)||er||!!we.disabled,readOnly:(we.type==="table"||we.type==="billingGrid")&&a==="fill"?!1:sr(fe,!!we.readOnly),isRequired:pn(fe),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:L,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:Ae,buttonResponses:rt?.scopedButtonResponses??$,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:Fe,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,onAddMore:Zn,scopedFormValues:rt?.scopedFormValues,scopedFieldNameMap:rt?.scopedFieldNameMap,excludedOptionValues:rt?.excludedOptionValues,hideTableRowControls:x})},we.id)})});return c.jsx("div",{className:B(gd(le),"self-stretch",Le?"overflow-visible":"overflow-hidden"),style:{gridRow:at,gridColumn:`${z+1} / span ${De}`,...xn(le[0])},"data-form-renderer":"grid-cell","data-field-name":le.map(we=>we.name||we.key||we.id).join(","),children:Ve},le.map(we=>we.id).join("-"))}))}):c.jsx("div",{className:f?"":"space-y-4","data-form-renderer":"stack",children:kt.map(k=>{if(!Tr(k))return null;const H=QF.find(Z=>Z.kind==="border"&&Z.fields.some(J=>J.id===k.id));if(H)return H.fields[0]?.id!==k.id?null:c.jsx(Cc,{legend:ys(H.run.section,0),collapsible:H.run.section.collapsible,defaultCollapsed:H.run.section.defaultCollapsed,onCollapsedChange:Z=>zc(H.run.section.id,void 0,Z),children:H.fields.map(Z=>{const J=Ze(Z);return!J||!Tr(Z)?null:c.jsxs("div",{"data-field-name":J,"data-form-renderer":"field-wrapper",style:xn(Z),children:[c.jsx(un,{field:Qn(Z),value:Oe[J],error:pe[J]||je>0?te[J]:void 0,onChange:le=>xt(J,le),onBlur:()=>ze(J),disabled:(Z.type==="table"||Z.type==="billingGrid")&&a==="fill"?!1:de||!Vt(J)||er||!!Z.disabled,readOnly:(Z.type==="table"||Z.type==="billingGrid")&&a==="fill"?!1:sr(J,!!Z.readOnly),isRequired:pn(J),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:L,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:J,buttonResponses:$,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:tr,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,onAddMore:Zn,hideTableRowControls:x}),Z.type==="addmore"&&ua(Z)]},Z.id)})},`stack-border-${H.run.section.id}-${k.id}`);if(!k.parentId){const Z=kt.filter(le=>!le.parentId&&Tr(le)&&Gi(le)===Gi(k)),J=Ec(Z).slice(0,2);if(J.length>1&&J[0].id!==k.id)return null;if(J.length>1){const le=dg(J);return c.jsx("div",{"data-form-renderer":"shared-cell-stack",className:B("flex w-full min-w-0 gap-3",le==="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",jo(Ce)),style:xn(Ce),children:[c.jsx(un,{field:Qn(Ce),value:Oe[Ne],error:pe[Ne]||je>0?te[Ne]:void 0,onChange:De=>xt(Ne,De),onBlur:()=>ze(Ne),disabled:(Ce.type==="table"||Ce.type==="billingGrid")&&a==="fill"?!1:de||!Vt(Ne)||er||!!Ce.disabled,readOnly:(Ce.type==="table"||Ce.type==="billingGrid")&&a==="fill"?!1:sr(Ne,!!Ce.readOnly),isRequired:pn(Ne),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:L,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:Ne,buttonResponses:$,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:tr,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,onAddMore:Zn,hideTableRowControls:x}),Ce.type==="addmore"&&ua(Ce)]},Ce.id)})},J.map(Ce=>Ce.id).join("-"))}}if(k.type==="section"){const Z=q.fields.filter(J=>J.parentId===k.id&&J.position!=null).sort((J,le)=>{const Ce=typeof J.position?.order=="number"?J.position.order:0,Ne=typeof le.position?.order=="number"?le.position.order:0;return Ce-Ne});return c.jsx(Dh,{field:k,children:Z.map(J=>{const le=J.name||J.key||J.id,Ce=J.hidden===!0;return wt(J)&&(Ar(le)||!Ce&&le)?c.jsxs("div",{"data-field-name":le,"data-form-renderer":"field-wrapper",style:xn(J),children:[c.jsx(un,{field:Qn(J),value:Oe[le],error:pe[le]||je>0?te[le]:void 0,onChange:De=>xt(le,De),onBlur:()=>ze(le),disabled:de||!Vt(le)||er||!!J.disabled,readOnly:sr(le,!!J.readOnly),isRequired:pn(le),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:L,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:le,buttonResponses:$,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:tr,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,onAddMore:Zn,hideTableRowControls:x}),J.type==="addmore"&&ua(J)]},J.id):null})},k.id)}const z=k.name||k.key||k.id;return c.jsxs("div",{"data-field-name":z,"data-form-renderer":"field-wrapper",style:xn(k),children:[c.jsx(un,{field:Qn(k),value:Oe[z],error:pe[z]||je>0?te[z]:void 0,onChange:Z=>xt(z,Z),onBlur:()=>ze(z),disabled:(k.type==="table"||k.type==="billingGrid")&&a==="fill"?!1:de||!Vt(z)||er||!!k.disabled,readOnly:(k.type==="table"||k.type==="billingGrid")&&a==="fill"?!1:sr(z,!!k.readOnly),isRequired:pn(z),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:L,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:z,buttonResponses:$,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:tr,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,onAddMore:Zn,hideTableRowControls:x}),k.type==="addmore"&&ua(k)]},k.id)})})}),u]})})]})})};function Pc(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function _g(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}function mT(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 s=n.filter(l=>l!=null&&typeof l=="object"&&typeof l.order=="number"&&!isNaN(l.order));let i={};const a=r.config;if(a!=null)if(typeof a=="string")try{i=JSON.parse(a)}catch{}else typeof a=="object"&&a!==null&&(i={...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=s.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:s.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=Pc(p.appearance)),p.ui!==void 0&&(h.ui=Pc(p.ui)),p.visibility!==void 0&&(h.visibility=Pc(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,I={...m};if(A.fileSize!==void 0&&(I.maxSize=A.fileSize),A.fileType&&Array.isArray(A.fileType)){const T=[];A.fileType.forEach(U=>{const Q=U.startsWith(".")?U:`.${U}`;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")}),I.accept=T}h.metadata=I,I.maxSize!==void 0&&(h.maxSize=I.maxSize),I.accept!==void 0&&(h.accept=I.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,(I,T)=>{const U=t[T];return U!==void 0?String(U):I}),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 I=l.apidata.apiEndpoint;I=I.replace(/\{ctx:([^}]+)\}/g,(T,U)=>{const Q=t[U];return Q!==void 0?String(Q):T}),A.apiEndpoint=I,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,v=_g(y.position),w=l.metadata&&typeof l.metadata=="object"&&!Array.isArray(l.metadata)?l.metadata:{},x=_g(y.layout),P={order:typeof y.positionOrder=="number"?y.positionOrder:l.order??f,column:typeof v.column=="number"?v.column:typeof y.positionColumn=="number"?y.positionColumn:1,columnSpan:typeof v.columnSpan=="number"?v.columnSpan:typeof v.width=="number"?v.width:typeof y.positionWidth=="number"?y.positionWidth:1,rowSpan:typeof v.rowSpan=="number"?v.rowSpan:typeof y.positionRowSpan=="number"?y.positionRowSpan:1},C=ko(v,{cellSlotIndex:y.cellSlotIndex??x.cellSlotIndex,stackSlot:w.stackSlot??x.stackSlot});typeof C=="number"&&(P.cellSlot=C);const N=v.cellGroupId??x.cellGroupId;typeof N=="string"&&(P.cellGroupId=N);const _=ms(v)??ms(x)??(w.stackDirection==="horizontal"||x.stackDirection==="horizontal"?"row":w.stackDirection==="vertical"||x.stackDirection==="vertical"?"stack":void 0);return(_==="row"||_==="stack")&&(P.sharedCellLayout=_),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:{...i,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 Ki(u)}var qi="Tabs",[hT]=vr(qi,[Mi]),kg=Mi(),[gT,Oc]=hT(qi),Tg=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,onValueChange:o,defaultValue:s,orientation:i="horizontal",dir:a,activationMode:d="automatic",...u}=e,l=ro(a),[f,p]=Zr({prop:n,onChange:o,defaultProp:s??"",caller:qi});return c.jsx(gT,{scope:r,baseId:on(),value:f,onValueChange:p,orientation:i,dir:l,activationMode:d,children:c.jsx(Be.div,{dir:l,"data-orientation":i,...u,ref:t})})});Tg.displayName=qi;var Fg="TabsList",Pg=b.forwardRef((e,t)=>{const{__scopeTabs:r,loop:n=!0,...o}=e,s=Oc(Fg,r),i=kg(r);return c.jsx(km,{asChild:!0,...i,orientation:s.orientation,dir:s.dir,loop:n,children:c.jsx(Be.div,{role:"tablist","aria-orientation":s.orientation,...o,ref:t})})});Pg.displayName=Fg;var Og="TabsTrigger",Ig=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,disabled:o=!1,...s}=e,i=Oc(Og,r),a=kg(r),d=Dg(i.baseId,n),u=Bg(i.baseId,n),l=n===i.value;return c.jsx(Tm,{asChild:!0,...a,focusable:!o,active:l,children:c.jsx(Be.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,...s,ref:t,onMouseDown:Me(e.onMouseDown,f=>{!o&&f.button===0&&f.ctrlKey===!1?i.onValueChange(n):f.preventDefault()}),onKeyDown:Me(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&i.onValueChange(n)}),onFocus:Me(e.onFocus,()=>{const f=i.activationMode!=="manual";!l&&!o&&f&&i.onValueChange(n)})})})});Ig.displayName=Og;var Mg="TabsContent",Lg=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,forceMount:o,children:s,...i}=e,a=Oc(Mg,r),d=Dg(a.baseId,n),u=Bg(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(xr,{present:o||l,children:({present:p})=>c.jsx(Be.div,{"data-state":l?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":d,hidden:!p,id:u,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0},children:p&&s})})});Lg.displayName=Mg;function Dg(e,t){return`${e}-trigger-${t}`}function Bg(e,t){return`${e}-content-${t}`}var yT=Tg,bT=Pg,vT=Ig,wT=Lg;function $g({className:e,...t}){return c.jsx(yT,{"data-slot":"tabs",className:B("flex flex-col gap-2",e),...t})}function jg({className:e,...t}){return c.jsx(bT,{"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 zg({className:e,...t}){return c.jsx(vT,{"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 Ug({className:e,...t}){return c.jsx(wT,{"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 ST({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 xT(){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 AT=3e4,CT=10*6e4,ET=9e4,NT=15*6e4;function _T(e){return e!=null&&"on_success"in e&&e.on_success!=null}function kT(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 Vg=({getWorkflowState:e,moduleId:t,tenantId:r,submissionContext:n,initialValues:o={},getAuthHeaders:s,onSuccess:i,bootstrapFeatureId:a,subjectUserId:d,viewStepId:u,clientId:l,className:f,onWorkflowSubmitResult:p,viewerContext:m,getViewerContext:g,dark:h=!1,themeVars:y})=>{const v=gn.useQueryClient(),w=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]),[E,P]=S.useState([]),[C,N]=S.useState(null),[_,A]=S.useState(null),[I,T]=S.useState(null),[U,Q]=S.useState({}),O=S.useRef(null),j=S.useRef(null),L=S.useRef(null),D=S.useRef(null),M=S.useMemo(()=>E&&Array.isArray(E)?E.filter(ae=>ae.feature_id):[],[E]),R=gn.useQuery({queryKey:["workflow-steps",t,a??"",r??"",w[0],w[1],w[2]],queryFn:()=>e({...x,featureId:a}),staleTime:AT,gcTime:CT}),$=R.isPending,ie=R.error?R.error instanceof Error?R.error.message:"Failed to load workflow steps":null;S.useEffect(()=>{const ae=R.data;if(!ae||E.length>0)return;const ve=ae.steps&&Array.isArray(ae.steps)?ae.steps:[];P(ve);const Ye=ve.filter(ct=>ct.feature_id);if(Ye.length>0){const ct=ae.current_step_id,Ge=ct&&Ye.some(Kt=>Kt.step_id===ct);N(Ge?ct:Ye[0].step_id)}},[R.data,E.length,a]);const V=S.useMemo(()=>{if(!C)return;const ae=E.find(Ye=>Ye.step_id===C),ve=O.current===C;return ae?.feature_id??(ve?D.current:void 0)??void 0},[C,E]),K=gn.useQuery({queryKey:["workflow-step",t,V??"",r??"",w[0],w[1],w[2]],queryFn:()=>e({...x,featureId:V}),enabled:!!V,staleTime:ET,gcTime:NT,refetchOnWindowFocus:!0,refetchOnReconnect:!0}),X=K.isPending,ce=K.error?K.error instanceof Error?K.error.message:"Failed to load form":null;S.useEffect(()=>{!K.data||O.current===C||(A(K.data),T(null),O.current=null,D.current=null)},[K.data,C]),S.useEffect(()=>{T(ce)},[ce]),S.useEffect(()=>{V===void 0&&O.current!==C&&(A(null),T(null),O.current=null,D.current=null)},[V,C]);const ne=S.useMemo(()=>{const ae=_?.form;if(!ae)return null;const ve=(r??Tn()??"").trim()||"default",Ye=Cg({scope:ve,formId:ae._id,version:ae.version});return Ye?.value?Ye.value:mT(_,n)},[_,n,r]),G=S.useMemo(()=>{const ae=_?.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 Ye=s?.()??{},ct={...ae.headers||{},"Content-Type":"application/json",...Ye};return{...ae,url:ve,headers:ct}},[_?.BFF_submit_api,s]),ee=S.useMemo(()=>ne?{...ne,status:"published",...G&&{BFF_submit_api:G}}:null,[ne,G]);S.useEffect(()=>{if(!ne?.id)return;const ae=(r??Tn()??"").trim()||"default";Eg({scope:ae,formId:ne.id,version:ne.version},ne)},[ne,r]);const Pe=S.useMemo(()=>{if(!ne)return null;const ae=Ns({config:ne.config,layout:ne.layout},null);if(!ae)return null;const ve=ae.rows,Ye=ae.columns,ct={verticalSpacing:ae.verticalSpacing??ae.spacing??"16px",horizontalSpacing:ae.horizontalSpacing??ae.spacing??"16px",rowHeight:ae.rowHeight??In};let Ge=1;if(Array.isArray(ne.fields))for(const Je of ne.fields){const q=Je?.position,$e=typeof q?.order=="number"?q.order:0,gt=typeof q?.rowSpan=="number"?q.rowSpan:1;Ge=Math.max(Ge,$e+gt)}return{rows:Math.min(ve,Math.max(1,Ge)),columns:Ye,verticalSpacing:ct.verticalSpacing,horizontalSpacing:ct.horizontalSpacing,rowHeight:ct.rowHeight}},[ne]),oe=S.useMemo(()=>{const ve=ee?.config?.theme?.cssVariables;if(!(!ve&&!y))return{...ve??{},...y??{}}},[ee?.config,y]),re=S.useCallback(()=>{v.invalidateQueries({queryKey:["workflow-steps",t]}),v.invalidateQueries({queryKey:["workflow-step",t]})},[v,t]),be=S.useCallback(ae=>{if(_T(ae)){const Ge=ae.on_success,Kt=Ge?.action;if(Kt==="redirect"&&Ge?.redirect_url){const Je=kT(Ge.redirect_url.trim(),n);window.location.href=Je;return}if(Kt==="move"){const Je=Ge?.next_step_id,q=Ge?.next_step_form;if(Je&&q){O.current=null,D.current=null;const $e=q.featureId??Ge?.next_step_form_id??q._id;v.removeQueries({queryKey:["workflow-step",t,$e,r??"",w[0],w[1],w[2]]}),re(),P(gt=>gt.some(te=>te.step_id===Je)?gt:[...gt,{step_id:Je,step_name:q.name||"Next step",feature_id:$e}]),A(null),N(Je),i?.();return}return}if(Kt==="stay"){re(),i?.();return}}const ve=ae;ve.steps&&Array.isArray(ve.steps)&&P(ve.steps);const Ye=(ve.steps&&Array.isArray(ve.steps)?ve.steps:E).filter(Ge=>Ge.feature_id),ct=ve.current_step_id;ct&&Ye.some(Ge=>Ge.step_id===ct)?N(ct):Ye.length>0&&N(Ye[0].step_id),A(null),re(),i?.(),p?.(ve)},[v,t,r,i,p,E,n,w,re]),de=S.useCallback(async ae=>_?.BFF_submit_api?(i?.(),{success:!0,message:"Saved successfully"}):{success:!1,message:"Submit not configured"},[_?.BFF_submit_api,i]),ot=S.useCallback((ae,ve)=>{},[]),Se=S.useCallback(ae=>{},[]);if($)return c.jsx(ST,{className:f});if(ie)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:ie});if(M.length===0)return c.jsx("div",{className:B("py-12 text-center text-sm text-muted-foreground",f),children:"No workflow steps configured."});const xe=_?.step_blocked_message;return c.jsx("div",{className:B(ma,h&&"dark","flex flex-col gap-4",f),style:oe,"data-form-renderer":"workflow-steps-view",children:c.jsxs($g,{value:C??"",onValueChange:ae=>N(ae),children:[c.jsx(jg,{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(zg,{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(Ug,{value:ae.step_id,className:"mt-4 outline-none",children:ae.step_id!==C?null:X?c.jsx(xT,{}):I?c.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:I}):xe&&!_?.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:xe}):ee?.fields?.length?c.jsxs("div",{className:"py-4 [&_*]:box-border",children:[xe?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:xe}):null,(()=>{const ve=j.current!==C||L.current!==(ee?.id??null);if(C&&ee&&ve){j.current=C,L.current=ee.id??null;const Ye=Nt.getState();Ye.setSchema(ee,{forceReset:!0});const ct=Nt.getState().values;Ye.setValues({...ct,...o})}return null})(),c.jsx(Fc,{schema:ee,gridLayout:Pe,omitRootWrapper:!0,submissionContext:n,initialValues:o,workflowStepId:C??void 0,viewerContext:m,getViewerContext:g,onSubmit:de,onChange:ot,onValidationError:Se,onClose:()=>{},mode:"fill",unstyled:!0,onWorkflowSubmitResult:be,initialExtraSubmitPayload:Object.keys(U).length>0?U:void 0,onExtraSubmitPayloadChange:ve=>{if(ve&&typeof ve=="object"){const Ye={};ve.context_user_id!=null&&(Ye.context_user_id=ve.context_user_id),ve.id!=null&&(Ye.id=ve.id),ve.batch_id!=null&&(Ye.batch_id=ve.batch_id),ve.admission_batch_id!=null&&(Ye.admission_batch_id=ve.admission_batch_id),ve.program_id!=null&&(Ye.program_id=ve.program_id),Object.keys(Ye).length>0&&Q(ct=>({...ct,...Ye}))}}},ee.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 TT(e){return typeof e=="object"&&e!==null&&"apiEndpoint"in e}function FT({formSchema:e}){const t=S.useMemo(()=>{if(!e)return[];const s=[];(!e.name||e.name.trim()==="")&&s.push({id:"form-name-required",type:"error",message:"Form name is required"});const i=new Set,a=new Set;e.fields.forEach((l,f)=>{const p=`field-${l.id}`;if(a.has(l.id)&&s.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&&i.has(l.name)&&s.push({id:`${p}-duplicate-name`,type:"error",message:`Field "${l.label||l.name}" has a duplicate name: "${l.name}"`,fieldId:l.id}),l.name&&i.add(l.name),(!l.label||l.label.trim()==="")&&s.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()==="")&&s.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)&&s.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)&&s.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)||s.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 v=e.fields.find(w=>w.id===h);return v?.parentId?g(v.parentId,y):!1};l.parentId&&g(l.id,new Set)&&s.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"))||s.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&&s.push({id:`row-${f}-too-many-fields`,type:"warning",message:`Row ${f+1} has ${l.length} fields (maximum recommended is 3)`})}),s},[e]),r=S.useMemo(()=>t.filter(s=>s.type==="error"),[t]),n=S.useMemo(()=>t.filter(s=>s.type==="warning"),[t]),o=S.useMemo(()=>r.length===0,[r]);return{issues:t,errors:r,warnings:n,isValid:o}}function PT({field:e,value:t,allValues:r,validateOnChange:n=!1,validateOnBlur:o=!0,debounceMs:s=Ak}){const[i,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 v;for(const w of e.validation){const x=Yr(t,w,r);if(typeof x=="string"){v=x;break}}return a(v),u(!1),v},[e.validation,t,r]),m=S.useCallback(()=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{p()},s)},[p,s]);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(v=>{a(v)},[]);return{error:i,isValidating:d,validate:p,handleBlur:g,clearError:h,setCustomError:y}}const Hg="—";function Xt(){return{kind:"static",value:Hg}}function OT(){return{currencySymbol:"₹",emptyDisplay:Hg,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:Xt(),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:Xt(),service:{kind:"api",path:"service"},unit_price:{kind:"api",path:"unit_price"},discount_pct:Xt(),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:Xt(),unit_price:{kind:"formula",expression:"SUM('unit_price', 'data')"},discount_pct:Xt(),discount_amount:{kind:"formula",expression:"SUM('discount_amount', 'data')"},net_price:{kind:"formula",expression:"SUM('net_price', 'data')"},tax_pct:Xt(),total:{kind:"formula",expression:"SUM('total', 'data')"}}}},{kind:"static",row:{id:"invoice_discount",label:"Invoice discount",cells:{tariff_type:{kind:"label"},service:Xt(),unit_price:Xt(),discount_pct:Xt(),discount_amount:{kind:"input",inputType:"number"},net_price:Xt(),tax_pct:Xt(),total:Xt()}}},{kind:"static",row:{id:"grand_total",label:"Grand total",cells:{tariff_type:{kind:"label"},service:Xt(),unit_price:Xt(),discount_pct:Xt(),discount_amount:Xt(),net_price:Xt(),tax_pct:Xt(),total:{kind:"formula",expression:"SUM('total', 'data') - cellInRow('invoice_discount', 'discount_amount')"}}}}]}}const IT={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:OT()}},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"}}}},Wg={padding:"md",showBorder:!1};function Rg(e,t){const r="full";return e?{padding:e.padding??Wg.padding,maxWidth:e.maxWidth??r,showBorder:e.showBorder??Wg.showBorder}:{padding:"md",maxWidth:r,showBorder:!1}}function MT(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 LT(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 DT(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 BT(e){const t=Rg(e.container,e.layout);return B(DT(e.layout),LT(t.maxWidth,e.layout),MT(t.padding),t.showBorder&&"rounded-lg border border-border")}const Yi=1;function $T(){return{version:Yi,layout:"stack",container:{padding:"md",maxWidth:"full",showBorder:!1},dataBindings:[],widgets:[],filterGroups:[]}}function Gg(e){return{...e,config:e.config??{},children:Array.isArray(e.children)?e.children.map(Gg):void 0}}function jT(e){return{version:Yi,layout:e.layout??"stack",container:Rg(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(Gg):[],filterGroups:Array.isArray(e.filterGroups)?e.filterGroups:[],eventHandlers:e.eventHandlers??[],navigation:e.navigation}}function zT(e){const t=e;return!t||typeof t!="object"?$T():(t.version!==Yi&&(t.version=Yi),jT(t))}const Kg={};let qg=null;function UT(e){qg=e}function VT(){return(Kg?.VITE_API_BASE_URL?.trim()||Kg?.VITE_API_URL?.trim()||"").replace(/\/$/,"")}const bs=_t.create({baseURL:VT()});bs.interceptors.request.use(e=>{const t=Tn();t&&(e.params={...e.params,clientId:t}),typeof FormData<"u"&&e.data instanceof FormData&&delete e.headers["Content-Type"];let r=qg?.();if((!r||Object.keys(r).length===0)&&(r=Ol()),r){const n=e.headers??{};for(const[o,s]of Object.entries(r))s!==void 0&&s!==""&&(n[o]=s);e.headers=n}return e});async function Yg(e){const t=await bs.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 Ic(e,t,r){const n=await bs.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 Mc(e){const{clientId:t,api:r,context:n,filterState:o}=e,s=await bs.post(`/api/page-builder/clients/${t}/data-sources/execute`,{api:r,context:n,filterState:o});return s.data?.data??s.data}function HT(e,t){if(!t)return{};const r={};for(const[n,o]of Object.entries(t)){if(!o.trim())continue;const s=tt(e,o);s!==void 0&&(r[n]=s)}return r}const Xg=S.createContext(null);function Jg(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 WT({schema:e,context:t={},clientId:r,nestingDepth:n=0,onAction:o,getWorkflowState:s,parentContext:i,children:a}){const[d,u]=S.useState(()=>i?i.filterGroups:{}),l=S.useRef(d);l.current=d;const[f,p]=S.useState({}),m=S.useRef(null),g=String(r??t.clientId??i?.clientId??""),h=JSON.stringify(t);S.useEffect(()=>{if(i)return;const C=e.prepopulateApi;if(!C?.enabled||!C.api?.path||!g){p({}),m.current=null;return}const N=JSON.stringify({path:C.api.path,method:C.api.method,mapping:C.contextMapping,bindings:e.dataBindings,context:h});if(m.current===N)return;let _=!1;return m.current=N,(async()=>{try{const A=Jg(e.dataBindings??[],t),I={...t,...A},T=await Mc({clientId:g,api:C.api,context:I});if(_)return;const U=HT(T,C.contextMapping);p({...U,prepopulateResponse:T})}catch{_||p({})}})(),()=>{_=!0}},[i,e.prepopulateApi,e.dataBindings,h,g]);const y=S.useMemo(()=>{if(i)return{...i.context,...t};const C=Jg(e.dataBindings??[],t);return{...t,...C,...f}},[i,t,e.dataBindings,f]),v=String(r??y.clientId??i?.clientId??""),w=S.useCallback((C,N,_)=>{u(A=>({...A,[C]:{...A[C]??{},[N]:_}}))},[]),x=S.useCallback(C=>l.current[C]??{},[]),E=S.useCallback((C,N,_,A)=>{(o??i?.onAction)?.({...C,sourceWidgetId:N,event:_,payload:A})},[o,i?.onAction]),P=S.useMemo(()=>({schema:e,context:y,clientId:v,nestingDepth:n,onAction:o??i?.onAction,getWorkflowState:s??i?.getWorkflowState,filterGroups:d,setFilterValue:w,getFilterGroup:x,dispatchAction:E}),[e,y,v,n,o,i?.onAction,s,i?.getWorkflowState,d,w,x,E]);return c.jsx(Xg.Provider,{value:P,children:a})}function Lr(){const e=S.useContext(Xg);if(!e)throw new Error("usePageContext must be used within PageContextProvider");return e}const RT=5,Qg=1;function Fo(e){return Number.isFinite(e)?Math.min(RT,Math.max(Qg,Math.round(e))):Qg}function GT(e,t){const r=Fo(t),n=Array.from({length:r},()=>[]);return e.forEach((o,s)=>{const i=o.config,a=i.columnIndex!==void 0?Math.min(Math.max(0,i.columnIndex),r-1):s%r;n[a].push(o)}),n}function KT(e){return Number.isFinite(e)?Math.min(100,Math.max(0,Math.round(e))):0}function qT(e,t){const r=Math.max(1,t),n=Math.min(100,Math.max(0,Math.round(e))),o=Math.floor(n/r),s=n-o*r;return Array.from({length:r},(i,a)=>o+(a<s?1:0))}function Zg(e){return qT(100,Fo(e))}function YT(e){const t=e.trim(),r=/^(\d+(?:\.\d+)?)\s*%?$/.exec(t);return r?KT(Number(r[1])):null}function ey(e,t){const r=Fo(t),n=[];for(let s=0;s<r;s++){const i=YT(e?.[s]??"");if(i===null)return Zg(r);n.push(i)}return n.reduce((s,i)=>s+i,0)!==100?Zg(r):n}function XT(e){return e==="sm"?"gap-2":e==="lg"?"gap-6":"gap-4"}function ty(e,t){return ey(t,Fo(e)).map(n=>`minmax(0, ${n}fr)`).join(" ")}function JT(e){return e.length?e.map(t=>`minmax(0, ${t}fr)`).join(" "):"minmax(0, 1fr)"}function QT(e,t,r,n){const o=Fo(t),s=GT(e,o),i=ey(r,o);if(!(n?.collapseEmpty!==!1))return{columns:s,gridTemplate:ty(o,r),sourceIndices:s.map((p,m)=>m)};const d=s.map((p,m)=>({colChildren:p,index:m,percent:i[m]??0})).filter(p=>p.colChildren.length>0);if(d.length===0||d.length===s.length)return{columns:s,gridTemplate:ty(o,r),sourceIndices:s.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:JT(l),sourceIndices:d.map(p=>p.index)}}function Lc(e,t="solid"){return e?t==="dashed"?"rounded-md border border-dashed border-border":"rounded-md border border-border":""}function ZT(e){return B(Lc(e.showBorder,e.borderStyle??"solid"),e.showBorder&&"p-3")}function eF(e){return B(Lc(e.showBorder,e.borderStyle??"solid"),e.showBorder&&"p-2")}function tF(e,t){return e.columnBorders?.[t]!==void 0?!!e.columnBorders[t]:!!e.showColumnBorders}function rF(e,t){const r=tF(e,t);return B(Lc(r,e.borderStyle??"dashed"),r&&"p-2")}function nF(e){if(e)return{minHeight:`${e}vh`}}function oF({widget:e,renderChildren:t}){const r=e.config,[n,o]=S.useState(r.defaultCollapsed??!1);return c.jsxs("section",{className:B("space-y-4",ZT(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(s=>!s),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 sF({widget:e,renderChildren:t}){const r=e.config,n=Fo(r.columns??2),o=r.collapseEmptyColumns!==!1,s=QT(e.children??[],n,r.columnWidths,{collapseEmpty:o});return c.jsx("div",{className:B("grid w-full min-w-0 items-stretch",XT(r.gap),eF(r)),style:{gridTemplateColumns:s.gridTemplate,...nF(r.minHeightPercent)},"data-widget-id":e.id,children:s.columns.map((i,a)=>{const d=s.sourceIndices[a]??a;return c.jsx("div",{className:B("flex min-h-[inherit] min-w-0 flex-col space-y-4 overflow-hidden",rF(r,d)),children:t?.(i)},d)})})}function iF({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 ry(e,t){if(e.variable){const r=t[e.variable];return r!=null?String(r):e.fallback??e.text??""}return e.text??""}function aF({widget:e}){const t=e.config,{context:r}=Lr(),n=ry(t,r),o=t.level??2,s=t.align==="center"?"text-center":t.align==="right"?"text-right":"text-left",i=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",i,s),"data-widget-id":e.id,children:n})}function lF({widget:e}){const t=e.config,{context:r}=Lr(),n=ry(t,r),o=t.preset==="caption"?"text-sm text-muted-foreground":t.preset==="small"?"text-xs text-muted-foreground":"text-base",s=t.align==="center"?"text-center":t.align==="right"?"text-right":"text-left";return c.jsx("p",{className:B(o,s),"data-widget-id":e.id,children:n})}function cF(e,t){return!e||typeof e!="string"?e:e.replace(/\{\{([^}]+)\}\}/g,(r,n)=>{const o=n.trim(),s=t[o];return s==null?"":String(s)})}function ny(e,t){const r={...e};for(const[n,o]of Object.entries(r))typeof o=="string"&&(r[n]=cF(o,t));return r}function dF(e,t){return e.replace(/\{\{([^}]+)\}\}/g,(r,n)=>{const o=t[n.trim()];return o!=null?String(o):""})}function oy(e,t,r,n){if(e.type==="navigate"){const o=dF(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 uF({widget:e}){const t=e.config,{context:r,dispatchAction:n}=Lr();return c.jsx(Yt,{variant:t.variant??"default",size:t.size??"default","data-widget-id":e.id,onClick:()=>oy(t.action,r,n,e.id),children:t.label})}const fF={start:"justify-start",center:"justify-center",end:"justify-end","space-between":"justify-between"},pF={sm:"gap-2",md:"gap-3",lg:"gap-4"};function mF({widget:e}){const t=e.config,{context:r,dispatchAction:n}=Lr(),o=t.buttons??[];return c.jsx("div",{className:B("flex flex-wrap items-center",fF[t.align??"start"],pF[t.gap??"sm"],t.wrap===!1&&"flex-nowrap"),"data-widget-id":e.id,children:o.map(s=>c.jsx(Yt,{variant:s.variant??"outline",size:s.size??"default","data-widget-id":e.id,"data-button-id":s.id,onClick:()=>oy(s.action,r,n,e.id),children:s.label},s.id))})}function sy(e,t){if(e.mode==="pageApi"&&e.dataSourceRef)return t[e.dataSourceRef];if(e.mode==="api")return e.api}function iy({widgetId:e,dataSource:t,enabled:r=!0,page:n,pageSize:o,search:s}){const{schema:i,context:a,clientId:d,getFilterGroup:u}=Lr(),l=S.useMemo(()=>t.filterGroupKey?u(t.filterGroupKey):{},[t.filterGroupKey,u]),f=S.useMemo(()=>["page-ds",e,t,a,l,n,o,s],[e,t,a,l,n,o,s]);return gn.useQuery({queryKey:f,enabled:r&&(!!d||t.mode==="static"),staleTime:sy(t,i.dataApis??{})?.staleTimeMs??3e4,queryFn:async()=>{if(t.mode==="static")return t.staticData;if(t.mode==="context")return tt(a,t.contextPath??"");const p=sy(t,i.dataApis??{});if(!p)throw new Error(`No API config for data source on widget ${e}`);const m={...a};if(t.requestBindings)for(const y of t.requestBindings){let v;y.source==="binding"?v=a[y.key]:y.source==="filter"&&(v=l[y.key]),v!==void 0&&(m[y.param]=v)}const h={...ny(m,a),...n!==void 0?{page:n,pageSize:o,search:s}:{}};return Mc({clientId:d,api:p,context:h,filterState:l})}})}function Dc(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 vs(e,t){const r=tt(e,t.path);return r==null?t.fallback??r:t.formatter?Dc(r,t.formatter):r}function hF(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 gF={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"},yF={rectangle:"rounded-lg",square:"aspect-square rounded-lg",circle:"aspect-square rounded-full"},bF={sm:"p-2 text-xs",md:"p-4 text-sm",lg:"p-6 text-base"},Bc={sm:"text-lg",md:"text-2xl",lg:"text-3xl"},vF={sm:"gap-2",md:"gap-3",lg:"gap-4"};function wF({title:e,value:t,trend:r,variant:n="default",shape:o="rectangle",size:s="md",layout:i="vertical",isLoading:a,isError:d}){const u=i==="horizontal";return c.jsxs("div",{className:B(gF[n??"default"],yF[o??"rectangle"],bF[s??"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(Pn,{className:"my-2"}):d?c.jsx("p",{className:B("font-bold text-destructive",Bc[s??"md"]),children:"Error"}):c.jsx("p",{className:B("font-bold",u?Bc[s??"md"]:`mt-1 ${Bc[s??"md"]}`),children:String(t)}),u&&r!==null&&r!==void 0&&r!==""&&c.jsx("p",{className:"text-xs text-muted-foreground",children:String(r)})]})}function ay({stat:e,widgetId:t}){const{data:r,isLoading:n,isError:o}=iy({widgetId:t,dataSource:e.dataSource}),i=(()=>{if(r==null)return e.valueMapping.fallback??"—";if(e.dataSource.mode==="context"){const d=r;return e.valueMapping.formatter?Dc(d,e.valueMapping.formatter):d}if(e.dataSource.mode==="static"){const d=e.valueMapping.path?.trim()||"value",u=vs(r,{...e.valueMapping,path:d});if(u!=null)return e.valueMapping.formatter?Dc(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 vs(r,e.valueMapping)})(),a=e.trendMapping&&r!==void 0&&e.dataSource.mode!=="context"?vs(r,e.trendMapping):e.trendMapping&&e.dataSource.mode==="context"&&e.trendMapping.path?vs({value:r},e.trendMapping):null;return c.jsx(wF,{title:e.title,value:i,trend:a,variant:e.variant,shape:e.shape,size:e.size,layout:e.layout,isLoading:n,isError:o})}function SF({widget:e}){const t=e.config;return c.jsx("div",{"data-widget-id":e.id,children:c.jsx(ay,{stat:t,widgetId:e.id})})}function xF({stat:e,widgetId:t}){return c.jsx(ay,{stat:e,widgetId:`${t}-${e.id}`})}function AF({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",vF[t.gap??"md"]),children:r.map(s=>c.jsx(xF,{stat:s,widgetId:e.id},s.id))})}function CF({widget:e}){const t=e.config,{setFilterValue:r}=Lr(),[n,o]=S.useState("");return S.useEffect(()=>{const s=t.debounceMs??300,i=setTimeout(()=>{r(t.filterGroupKey,"search",n)},s);return()=>clearTimeout(i)},[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:s=>o(s.target.value),"data-widget-id":e.id})}function EF(e,t){if(!e)return[];const r=t?tt(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 NF({widget:e}){const t=e.config,{dispatchAction:r}=Lr(),[n,o]=S.useState(1),[s,i]=S.useState(""),a=t.pagination?.pageSize??10,{data:d,isLoading:u,isError:l}=iy({widgetId:e.id,dataSource:t.dataSource,page:n,pageSize:a,search:t.search?.enabled?s:void 0}),f=t.dataSource.mode==="pageApi"?void 0:t.dataSource.api?.itemsPath,p=EF(d,f??"data.items"),m=(g,h)=>{const y=t.dataSource.responseMapping.find(v=>v.target===h);return y?vs(g,y):tt(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:s,onChange:g=>{i(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(Pn,{})})}):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 _F=75;function kF(e){return e??_F}function $c({scrollBehavior:e="page",maxHeightPercent:t,children:r,className:n}){if(e!=="contained")return c.jsx(c.Fragment,{children:r});const o=kF(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 TF(e,t,r){return["embedded-form",e,t,r??"latest"]}async function FF(e,t){try{const r=await dn.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 PF(e,t,r){const n=r!==void 0?`/api/form-builder/forms/${e}/render?version=${r}`:`/api/form-builder/forms/${e}/render`,o=await dn.get(n,{params:{clientId:t}}),i=o.data?.data??o.data,a=i.form??i,d=i.fields??a.fields??[];let u=i.layout??a.layout??null;(!u||typeof u.columns!="number")&&(u=await FF(e,t));const l=i.rules??a.rules??[],f=ps(a,d,u,l),p=Ns({config:f.config,layout:f.layout},Es(u))??Es(u);return{schema:f,gridLayout:p}}const OF=300*1e3;function ly({formId:e,mode:t="fill",contextFieldMapping:r,pageContext:n,clientId:o,formVersion:s,scrollBehavior:i,maxHeightPercent:a}){const{data:d,isLoading:u,isError:l,error:f}=gn.useQuery({queryKey:TF(e,o,s),queryFn:()=>PF(e,o,s),staleTime:OF}),p=S.useMemo(()=>hF(n,r),[n,r]);return u?c.jsx($c,{scrollBehavior:i,maxHeightPercent:a,children:c.jsx(Pn,{})}):l?c.jsx($c,{scrollBehavior:i,maxHeightPercent:a,children:c.jsx("p",{className:"text-sm text-destructive",children:f instanceof Error?f.message:"Failed to load form"})}):d?.schema?c.jsx($c,{scrollBehavior:i,maxHeightPercent:a,children:c.jsx(Fc,{schema:d.schema,mode:t,gridLayout:d.gridLayout,initialValues:p,submissionContext:n})}):null}function IF({widget:e}){const t=e.config,{context:r,clientId:n}=Lr();return t.formId?c.jsx(ly,{formId:t.formId,mode:t.mode??"fill",contextFieldMapping:t.contextFieldMapping,pageContext:r,clientId:n,scrollBehavior:t.scrollBehavior,maxHeightPercent:t.maxHeightPercent}):c.jsx("p",{className:"text-sm text-muted-foreground",children:"No form configured"})}function MF({widget:e}){const t=e.config,{context:r,getWorkflowState:n,clientId:o}=Lr(),s=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(!s)return c.jsx("p",{className:"text-sm text-destructive","data-widget-id":e.id,children:"moduleId required in page context for workflow embed"});const i={};if(t.contextVariableMapping)for(const[a,d]of Object.entries(t.contextVariableMapping)){const u=r[d];u!=null&&(i[a]=String(u))}return c.jsx(Vg,{getWorkflowState:n,moduleId:s,tenantId:r.tenantId?String(r.tenantId):void 0,clientId:o||void 0,submissionContext:i})}function LF({widget:e}){const t=e.config,{schema:r,dispatchAction:n}=Lr(),o=t.previousPage??r.navigation?.previousPage,s=t.nextPage??r.navigation?.nextPage,i=t.showPrevious!==!1&&!!o,a=t.showNext!==!1&&!!s,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:[i&&o&&c.jsx(Yt,{variant:"outline",size:"sm",onClick:()=>l(o),children:o.label??"Previous"}),a&&s&&c.jsx(Yt,{variant:"default",size:"sm",onClick:()=>l(s),children:s.label??"Next"})]})]})}function DF(e,t){return e?.length?e.filter(r=>r.config.tabId===t):[]}const BF=1;function $F(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 jF(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 zF(e,t,r){return e?new Set(r?[r]:[]):new Set(t.map(n=>n.id))}function UF({tab:e,shouldRender:t,pageContext:r,clientId:n}){return t?e.formId?c.jsx(ly,{formId:e.formId,mode:e.formMode??"fill",contextFieldMapping:e.contextFieldMapping,pageContext:r,clientId:n,scrollBehavior:e.scrollBehavior,maxHeightPercent:e.maxHeightPercent}):c.jsx("p",{className:"text-sm text-muted-foreground",children:"No form configured for this tab"}):null}function VF({tab:e,shouldLoad:t,shouldRender:r,nestingDepth:n,pageContext:o,clientId:s,onAction:i,getWorkflowState:a}){const d=Lr(),{data:u,isLoading:l,isError:f,error:p}=gn.useQuery({queryKey:["tab-page",e.pageId,e.pageVersion,s],enabled:t&&!!e.pageId,queryFn:async()=>Ic(e.pageId,s,e.pageVersion)});return r?n>=BF?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(Pn,{}):f?c.jsx("p",{className:"text-sm text-destructive",children:p instanceof Error?p.message:"Failed to load page"}):u?c.jsx(jc,{page:u,context:o,nestingDepth:n+1,inheritContext:!0,onAction:i,getWorkflowState:a,parentContext:d}):null:c.jsx("p",{className:"text-sm text-muted-foreground",children:"No page configured for this tab"}):null}function HF({tab:e,widgetChildren:t,renderChildren:r}){const n=DF(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 WF({widget:e,renderChildren:t}){const r=e.config,{context:n,clientId:o,nestingDepth:s,onAction:i,getWorkflowState:a}=Lr(),d=r.tabs??[],u=r.defaultTabId??d[0]?.id??"",l=r.lazyLoad!==!1,[f,p]=S.useState(u),[m,g]=S.useState(()=>zF(l,d,u)),h=v=>{g(w=>new Set(w).add(v)),p(v)},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($g,{value:f,onValueChange:h,className:"w-full","data-widget-id":e.id,children:[c.jsx(jg,{className:B("mb-4",$F(r.variant)),children:d.map(v=>c.jsx(zg,{value:v.id,disabled:v.disabled,className:jF(r.variant),children:v.label},v.id))}),d.map(v=>{const w=m.has(v.id),x=y||w,E=y||w;return c.jsxs(Ug,{value:v.id,forceMount:y||void 0,className:B("mt-0",y&&"data-[state=inactive]:hidden"),children:[v.contentType==="widgets"&&E&&c.jsx(HF,{tab:v,widgetChildren:e.children??[],renderChildren:t}),v.contentType==="form"&&c.jsx(UF,{tab:v,shouldRender:x,pageContext:n,clientId:o}),v.contentType==="page"&&c.jsx(VF,{tab:v,shouldLoad:x,shouldRender:E,nestingDepth:s,pageContext:n,clientId:o,onAction:i,getWorkflowState:a})]},v.id)})]})}const RF={section:oF,columns:sF,card:iF,tab_group:WF,heading:aF,text:lF,button:uF,button_group:mF,stat_card:SF,stat_grid:AF,data_table:NF,search_filter:CF,form_embed:IF,workflow_embed:MF,page_nav:LF};function GF({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 KF({widget:e,renderChildren:t}){const r=RF[e.type]??GF;return c.jsx(r,{widget:e,renderChildren:t})}function cy(e,t){return e.map(r=>c.jsx(KF,{widget:r,renderChildren:t},r.id))}function jc({page:e,context:t={},onAction:r,chrome:n="none",className:o,nestingDepth:s=0,getWorkflowState:i,inheritContext:a=!1,parentContext:d}){const u=S.useMemo(()=>zT(e.schema),[e.schema]),l=p=>cy(p,l),f=c.jsxs("div",{className:B("studio-page-content min-h-0 min-w-0",BT(u),o),"data-page-id":e.id,"data-nesting-depth":s,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:cy(u.widgets,l)})]});return a&&d?f:c.jsx(WT,{schema:u,context:t,clientId:String(t.clientId??""),nestingDepth:s,onAction:r,getWorkflowState:i,parentContext:d,children:f})}function qF({clientId:e,tenantId:t,moduleId:r,featureId:n,pageId:o,routePath:s,routeParams:i={},isDefault:a,context:d={},version:u,chrome:l="none",onAction:f,getWorkflowState:p}){const m=S.useMemo(()=>({...i,...d,clientId:e,tenantId:t,moduleId:r,featureId:n}),[i,d,e,t,r,n]),{data:g,isLoading:h,isError:y,error:v}=gn.useQuery({queryKey:["page-resolve",e,t,r,n,o,s,a,u],queryFn:()=>Yg({clientId:e,tenantId:t,moduleId:r,featureId:n,routePath:s,isDefault:a,version:u}),enabled:!o}),w=o??g?.pageId,x=u??g?.version,{data:E,isLoading:P,isError:C,error:N}=gn.useQuery({queryKey:["page-render",w,e,x],queryFn:()=>Ic(w,e,x),enabled:!!w});return!o&&h?c.jsx("div",{className:"flex items-center justify-center p-12",children:c.jsx(Pn,{})}):y?c.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm text-destructive",children:v instanceof Error?v.message:"Failed to resolve page"}):w?P?c.jsx("div",{className:"flex items-center justify-center p-12",children:c.jsx(Pn,{})}):C||!E?c.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm text-destructive",children:N instanceof Error?N.message:"Failed to load page"}):c.jsx(jc,{page:E,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."})}ge.FIELD_TYPE_REGISTRY=IT,ge.FORM_RENDERER_GRID_ROW_HEIGHT_DEFAULT=In,ge.FORM_RENDERER_ROOT_CLASS=ma,ge.FieldRenderer=un,ge.FormRenderer=Fc,ge.PageRenderer=jc,ge.RendererFieldLayoutContext=Ea,ge.StudioPageHost=qF,ge.WorkflowStepsView=Vg,ge.appearanceControlClasses=Bo,ge.appearanceHasExplicitVerticalIntent=Cd,ge.appearanceTextareaClasses=hd,ge.backendToFormSchema=ps,ge.cellAlignmentClasses=vb,ge.cellVerticalJustifyClassesForField=bb,ge.effectiveWidthPercent=Fs,ge.executeDataSource=Mc,ge.fetchPageRender=Ic,ge.fieldBlockBoxStyle=yb,ge.fieldBlockBoxStyleForField=xd,ge.fieldBlockHorizontalPlacementClass=bd,ge.fieldBlockHorizontalSelfClass=vd,ge.fieldBlockHorizontalSelfClassForField=Ad,ge.fieldBlockWidthStyle=va,ge.fieldBlockWidthStyleForField=Sd,ge.fieldGridShellFillsCellVertically=Os,ge.formBuilderHttp=dn,ge.formLayoutRecordToGridConfig=Es,ge.getBusinessApiOrigin=xp,ge.getClientId=Tn,ge.getRendererHostAuthHeaders=Ol,ge.getRendererHostViewerContext=uC,ge.getRendererStore=Kb,ge.gridCellFlexClasses=yd,ge.gridCellFlexClassesForField=Ca,ge.gridCellOuterFlexClasses=gd,ge.hasExplicitFieldBlockWidth=wd,ge.isAsyncSearchFieldProperties=TT,ge.isIntrinsicWidthButtonField=to,ge.normalizeWorkflowFormSchema=jk,ge.normalizeWorkflowFormToRendererSchema=Ki,ge.pageBuilderHttp=bs,ge.parseContentVerticalAlign=Sa,ge.parseMetadataJson=gs,ge.resetRendererHostAuth=dC,ge.resolveBusinessApiUrl=cn,ge.resolveFormGridLayout=Ns,ge.resolvePage=Yg,ge.resolvedGridCellVerticalJustifyClasses=jo,ge.resolvedHorizontalAlign=Fr,ge.resolvedVerticalAlign=$o,ge.resolvedVerticalAlignForField=Aa,ge.setBusinessApiOrigin=MA,ge.setFormBuilderAuthProvider=fC,ge.setPageBuilderAuthProvider=UT,ge.setRendererHostAuthHeaders=cC,ge.setRendererHostViewerContext=lC,ge.useFieldValidation=PT,ge.useFormRenderer=$d,ge.useFormValidation=FT,ge.useRendererFieldLayout=zo,ge.useRendererHostAuthStore=Rn,Object.defineProperty(ge,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},VE="DialogDescriptionWarning",HE=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${lh(VE).contentName}}.`;return b.useEffect(()=>{const o=e.current?.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},WE=Xm,RE=Zm,GE=eh,KE=th,qE=nh,YE=ih;function XE({...e}){return c.jsx(WE,{"data-slot":"dialog",...e})}function JE({...e}){return c.jsx(RE,{"data-slot":"dialog-portal",...e})}function QE({className:e,...t}){return c.jsx(GE,{"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 ZE({className:e,children:t,showCloseButton:r=!0,...n}){return c.jsxs(JE,{"data-slot":"dialog-portal",children:[c.jsx(QE,{}),c.jsxs(KE,{"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(YE,{"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(Ko,{}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function eN({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 tN({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 rN({className:e,...t}){return c.jsx(qE,{"data-slot":"dialog-title",className:B("text-lg leading-none font-semibold",e),...t})}async function nN(){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 ch(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 dh=({open:e,onOpenChange:t,onCaptured:r,validateFile:n,accept:o,disabled:s,onValidationMessage:i})=>{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(C=>C.stop()),u.current=null),h()},[h]);S.useEffect(()=>{if(!e){y(),p(null),g(!1);return}if(s)return;let C=!1;return p(null),g(!0),nN().then(N=>{if(C){N.getTracks().forEach(_=>_.stop());return}u.current=N,g(!1)}).catch(N=>{if(C)return;g(!1);const _=N instanceof Error?N.message:"Could not access camera";p(_)}),()=>{C=!0,u.current&&(u.current.getTracks().forEach(N=>N.stop()),u.current=null),h()}},[e,s,y,h]);const v=S.useCallback(C=>{a.current=C,C&&u.current&&e&&!f&&!m&&(C.srcObject=u.current,ch(C))},[e,f,m]);S.useLayoutEffect(()=>{if(!e||f||m||!u.current)return;let C=!1,N=0;const _=()=>{if(C)return;const I=a.current;!I||!u.current||(I.srcObject=u.current,ch(I))};_();const A=requestAnimationFrame(()=>{_(),N=requestAnimationFrame(_)});return()=>{C=!0,cancelAnimationFrame(A),cancelAnimationFrame(N),h()}},[e,f,m,h]);const w=S.useCallback(()=>{y(),p(null),g(!1),t(!1),l.current&&(l.current.value="")},[y,t]),x=S.useCallback(()=>{const C=a.current,N=d.current;if(!C||!N||!u.current||C.readyState<2)return;const _=C.videoWidth,A=C.videoHeight;if(_===0||A===0)return;N.width=_,N.height=A;const I=N.getContext("2d");I&&(I.drawImage(C,0,0),N.toBlob(T=>{if(!T)return;const W=new File([T],`camera-capture-${Date.now()}.jpg`,{type:"image/jpeg",lastModified:Date.now()}),J=n(W);if(J){i?.(J);return}i?.(void 0),r(W),w()},"image/jpeg",.92))},[r,n,w,i]),E=S.useCallback(C=>{const N=C.target.files?.[0];if(!N)return;const _=n(N);if(_){i?.(_);return}i?.(void 0),r(N),w(),l.current&&(l.current.value="")},[r,n,w,i]),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:E,className:"hidden","aria-hidden":!0}),c.jsx("canvas",{ref:d,className:"hidden","aria-hidden":!0}),c.jsx(XE,{open:e,onOpenChange:C=>{C||w()},children:c.jsxs(ZE,{className:"sm:max-w-md",showCloseButton:!0,onPointerDownOutside:C=>C.preventDefault(),children:[c.jsx(eN,{children:c.jsx(rN,{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(Yt,{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:v,playsInline:!0,muted:!0,className:"w-full h-full object-cover"})}),c.jsxs(tN,{className:"gap-2 sm:gap-0",children:[c.jsx(Yt,{type:"button",variant:"outline",onClick:w,children:"Cancel"}),c.jsx(Yt,{type:"button",onClick:x,children:"Capture photo"})]})]})]})})]})},oN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,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"),v=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,w=e.validation?.find(K=>K.type==="fileSize"),x=e.validation?.find(K=>K.type==="fileType"),E=w?.value!=null?w.value:d?.maxSize??v?.maxSize??5*1024*1024,P=x?.value!=null?x.value:d?.accept??v?.accept??["image/*"],C=P.join(",")||"image/*",N=Ms(e),_=S.useCallback(K=>{if(w){const X=Yr(K,w);if(X!==!0)return typeof X=="string"?X:"File size exceeds the maximum allowed size"}else if(K.size>E)return`File size must be less than ${yo(E)}`;if(x){const X=Yr(K,x);if(X!==!0)return typeof X=="string"?X:"File type is not allowed"}return null},[w,x,E]),A=S.useMemo(()=>Ls(t),[t]),I=ql(A),T=S.useCallback(K=>{const X=ka(K,N);r(X),n?.()},[r,n,N]),W=S.useCallback(K=>{const X=_(K);if(X){l(X);return}l(void 0);const ce=[...A];ce.length>=N||(ce.push(K),T(ce),y("none"))},[A,N,_,T]),J=S.useCallback(K=>{const X=A.filter((ce,ne)=>ne!==K);T(X)},[A,T]),O=S.useCallback(()=>{s||A.length>=N||(l(void 0),y("camera"),p(!0))},[s,A.length,N]),j=S.useCallback(K=>{p(K),K||y("none")},[]),M=o||u,D=e.appearance?.hideLabel??!1,L=[];(w||E)&&L.push(`Max size: ${yo(E)}`),x&&P.length>0&&L.push(`Allowed: ${P.join(", ")}`),N>1&&L.push(`Up to ${N} photos`);const U=S.useCallback(K=>{window.open(K,"_blank","noopener,noreferrer")},[]),$=A.length===0,ie=A.length<N,V=Rl(N,A.length);return c.jsxs(Et,{field:e,error:M,isRequired:i,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:s||!ie?-1:0,id:ht(e),onClick:K=>{s||K.target.closest("[data-remove-in-dropzone]")||K.target.closest("[data-no-open-picker]")||A.length>=N||O()},onKeyDown:K=>{(K.key==="Enter"||K.key===" ")&&(K.preventDefault(),!s&&ie&&O())},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",s&&"opacity-50 cursor-not-allowed",f&&h==="camera"&&"opacity-70 pointer-events-none",!ie&&A.length>0&&"cursor-default"),"aria-describedby":jt(e,!!M),"aria-invalid":Jt(!!M),"aria-required":i,children:$?c.jsxs(c.Fragment,{children:[c.jsx(Us,{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(" • ")})]}):V?c.jsx(Yl,{item:A[0],objectUrl:I[0]??null,failedUrlKeys:m,onImageUrlError:K=>g(X=>new Set(X).add(K)),onRemove:()=>J(0),onOpenUrl:U,disabled:s}):c.jsx(Kl,{items:A,maxFiles:N,disabled:s,objectUrls:I,failedUrlKeys:m,onImageUrlError:K=>g(X=>new Set(X).add(K)),onRemove:J,onOpenUrl:U,addSlot:ie?c.jsxs("button",{type:"button","data-no-open-picker":!0,onClick:K=>{K.stopPropagation(),O()},disabled:s,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(Us,{className:"h-4 w-4 mb-0.5","aria-hidden":!0}),"Add"]}):void 0})})}),c.jsx(dh,{open:f,onOpenChange:j,onCaptured:W,validateFile:_,accept:C,disabled:s,onValidationMessage:l})]})},sN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,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),[v,w]=S.useState("none"),x=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,E=e.validation?.find(oe=>oe.type==="fileSize"),P=e.validation?.find(oe=>oe.type==="fileType"),C=E?.value?E.value:u?.maxSize??x?.maxSize??5*1024*1024,N=P?.value?P.value:u?.accept??x?.accept??["image/*"],_=Array.isArray(N)?N.join(","):"image/*",A=Ms(e),I=S.useCallback(oe=>{if(E){const re=Yr(oe,E);if(re!==!0)return typeof re=="string"?re:"File size exceeds the maximum allowed size"}else if(oe.size>C)return`File size must be less than ${yo(C)}`;if(P){const re=Yr(oe,P);if(re!==!0)return typeof re=="string"?re:"File type is not allowed"}return null},[E,P,C]),T=S.useMemo(()=>Ls(t),[t]),W=ql(T),J=S.useCallback(oe=>{const re=ka(oe,A);r(re),n?.()},[r,n,A]),O=S.useCallback(oe=>{p(void 0);const re=Array.from(oe),be=[...T];let de=null;for(const ot of re){if(be.length>=A)break;const Se=I(ot);if(Se){de||(de=Se);continue}be.push(ot)}if(de&&be.length===T.length){p(de);return}de&&p(de),J(be),w("none")},[T,A,I,J]),j=S.useCallback(oe=>{const re=oe.target.files;re&&re.length>0&&O(re),l.current&&(l.current.value="")},[O]),M=S.useCallback(oe=>{J(T.filter((re,be)=>be!==oe))},[T,J]),D=S.useCallback(()=>{s||T.length>=A||m||(p(void 0),w("file"),l.current?.click())},[s,T.length,A,m]),L=S.useCallback(()=>{s||T.length>=A||(p(void 0),w("camera"),g(!0))},[s,T.length,A]),U=S.useCallback(oe=>{const re=I(oe);if(re){p(re);return}p(void 0);const be=[...T];be.length>=A||(be.push(oe),J(be),w("none"))},[T,A,I,J]),$=S.useCallback(oe=>{g(oe),oe||w("none")},[]),ie=o||f,V=e.appearance?.hideLabel??!1,K=[];(E||C)&&K.push(`Max size: ${yo(C)}`),P&&N.length>0&&K.push(`Allowed: ${N.join(", ")}`),A>1&&K.push(`Up to ${A} photos`);const X=S.useMemo(()=>{if(!d)return null;const oe=Object.values(d);for(let re=oe.length-1;re>=0;re-=1){const be=oe[re],de=typeof be?.status=="string"?be.status.toLowerCase():null;if(de&&de!=="success")continue;const ot=be?.code;if(typeof ot=="number"&&(ot<200||ot>=300))continue;const Se=be?.data,xe=Se?.file_url||Se?.fileUrl||be?.file_url||be?.fileUrl;if(typeof xe=="string"&&xe.trim())return xe.trim()}return null},[d]),ce=S.useCallback(oe=>{window.open(oe,"_blank","noopener,noreferrer")},[]),ne=T.length===0,G=T.length<A,ee=Rl(A,T.length),Pe=G&&!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:s,onClick:oe=>{oe.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(Hs,{className:"h-4 w-4","aria-hidden":!0})}),c.jsx("button",{type:"button",disabled:s,onClick:oe=>{oe.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(Us,{className:"h-4 w-4","aria-hidden":!0})})]}):void 0;return c.jsxs(Et,{field:e,error:ie,isRequired:i,className:B(a,"!space-y-0"),hideLabel:V,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",ie&&"border-destructive",s&&"opacity-50"),children:[c.jsx("input",{ref:l,id:ht(e),type:"file",accept:_,multiple:A>1,onChange:j,disabled:s||e.disabled||m||!G,className:"hidden","aria-describedby":jt(e,!!ie),"aria-invalid":Jt(!!ie),"aria-required":i}),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:s||m,onClick:D,className:B("inline-flex flex-col items-center gap-0.5 text-[11px] text-muted-foreground hover:text-foreground",s&&"pointer-events-none"),children:[c.jsx(Hs,{className:"h-5 w-5","aria-hidden":!0}),c.jsx("span",{children:"Upload"})]}),c.jsxs("button",{type:"button",disabled:s,onClick:L,className:B("inline-flex flex-col items-center gap-0.5 text-[11px] text-muted-foreground hover:text-foreground",s&&"pointer-events-none",m&&"opacity-70"),children:[c.jsx(Us,{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(" • ")})]}):ee?c.jsx(Yl,{item:T[0],objectUrl:W[0]??null,failedUrlKeys:h,onImageUrlError:oe=>y(re=>new Set(re).add(oe)),onRemove:()=>M(0),onOpenUrl:ce,openTarget:T[0]instanceof File?X:void 0,disabled:s||e.disabled}):c.jsx(Kl,{items:T,maxFiles:A,disabled:s,objectUrls:W,failedUrlKeys:h,onImageUrlError:oe=>y(re=>new Set(re).add(oe)),onRemove:M,resolveOpenUrl:(oe,re)=>re instanceof File&&T.length===1&&X?X:null,onOpenUrl:oe=>{oe?.trim()&&ce(oe.trim())},addSlot:Pe})]})}),c.jsx(dh,{open:m,onOpenChange:$,onCaptured:U,validateFile:I,accept:_,disabled:s,onValidationMessage:p})]})};function ls(e){if(e instanceof Error){const t=e.message;if(t&&(t.includes("{")||t.includes("[")))try{const r=t.match(/\{[\s\S]*\}/);if(r){const n=JSON.parse(r[0]);return bo(n)}}catch{}if(e.response){const r=e.response;if(typeof r=="string")try{const n=JSON.parse(r);return bo(n)}catch{return r}else if(typeof r=="object")return bo(r)}return t}if(e instanceof IA)return e.response?.data?bo(e.response.data):e.message||"An unexpected error occurred";if(typeof e=="string")try{const t=JSON.parse(e);return bo(t)}catch{return e}return typeof e=="object"&&e!==null?bo(e):"An unexpected error occurred"}function bo(e){if(e?.display_message&&typeof e.display_message=="string")return e.display_message.trim();if(e?.errors&&Array.isArray(e.errors)){const t=e.errors.filter(r=>r&&typeof r=="string");if(t.length>0)return t.join(". ")}if(e?.error?.explanation&&Array.isArray(e.error.explanation)){const t=e.error.explanation.filter(r=>r&&typeof r=="string");if(t.length>0)return t.join(". ")}if(e?.explanation&&Array.isArray(e.explanation)){const t=e.explanation.filter(r=>r&&typeof r=="string");if(t.length>0)return t.join(". ")}if(e?.errors&&Array.isArray(e.errors)){const t=e.errors.filter(r=>r!=null&&String(r).trim());if(t.length>0)return t.map(r=>typeof r=="string"?r:r?.message||String(r)).join(". ")}return e?.message&&typeof e.message=="string"?e.message:e?.display_message&&typeof e.display_message=="string"?e.display_message:e?.error?.display_message&&typeof e.error.display_message=="string"?e.error.display_message:e?.error?.message&&typeof e.error.message=="string"?e.error.message:e?.error&&typeof e.error=="string"?e.error:"An unexpected error occurred"}function iN(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 aN(e,t){try{const r=iN(e);$t.toast.success(r&&r.trim()?r:t)}catch{$t.toast.success(t)}}function Zl(e,t,r){try{const n=r(e);$t.toast.error(n&&n.trim()?n:t)}catch{$t.toast.error(t)}}function lN(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 zi="This field is required";function uh(e,t){if(!t?.length)return e;const r=t.find(n=>n.name===e);return r?.label&&r.label.trim()||e}function ec(e,t){if(!e)return"Please complete the required fields.";if(Array.isArray(e)){const s=e.map(i=>{const a=i.message||zi;if(t?.length&&i.field){const d=uh(i.field,t);return a===zi?`${d} is required`:`${d}: ${a}`}return a}).filter(i=>typeof i=="string"&&i.length>0);return s.length===0?"Please complete the required fields.":s.length===1?s[0]:`${s[0]} (and ${s.length-1} more)`}const n=Object.entries(e).map(([o,s])=>{const i=s?.trim()||zi;if(t?.length){const a=uh(o,t);return i===zi?`${a} is required`:`${a}: ${i}`}return i}).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)`}const cN=/^\{([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\}$/i;function fh(e){const t=e.trim().match(cN);return t?t[1]:e}const dN={applicantId:["id","applicant_id"],applicant_id:["id","applicantId"],id:["applicantId","applicant_id"]};function rn(e,t,r,n,o,s){let i=e;if(o&&typeof e=="string"&&(i=i.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)}),i.includes("{documentId}")||i.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&&(i=i.replace(/\{documentId\}/g,a).replace(/%7BdocumentId%7D/gi,a))}if(i.includes("{documentId}")||i.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&&(i=i.replace(/\{documentId\}/g,a).replace(/%7BdocumentId%7D/gi,a))}return i=i.replace(/\{api:([^}]+)\}/g,(a,d)=>{const u=d.trim();if(s==null||u==="")return a;const l=Qe(s,u);return l==null?a:String(l)}),i=i.replace(/\{(?:ctx:|\@)(\w+)\}/g,(a,d)=>n&&n[d]!==void 0&&n[d]!==null?String(n[d]):a),i=i.replace(/\{(\w+)\}/g,(a,d)=>{if(a.includes("ctx:")||a.includes("@"))return a;const u=r[d];if(u!=null)return fh(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=dN[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!==""?fh(String(l)):a}),i}function tc(e,t){if(!t?.length)return e;const r=new Map;for(const o of t){const s=o.name||o.key||o.id;s&&r.set(s,o)}const n={};for(const[o,s]of Object.entries(e)){const i=r.get(o);if(i?.type==="selectablelist"&&Array.isArray(s)&&s.length>0){const a=i.properties,d=i.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=s.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]=s}return n}function Ui(e){return!!(e instanceof File||Array.isArray(e)&&e.length>0&&e[0]instanceof File)}function uN(e){return Object.values(e).some(t=>Ui(t))}function fN(e,t){const r=new FormData;let n=!1;return Object.entries(e).forEach(([o,s])=>{const i=t?.[o]||o;s instanceof File?(r.append(i,s),n=!0):Array.isArray(s)&&s.length>0&&s[0]instanceof File?(s.forEach(a=>{r.append(i,a)}),n=!0):s!=null&&(typeof s=="object"?r.append(i,JSON.stringify(s)):r.append(i,String(s)))}),n?r:null}function pN(e,t,r){const n={};let o=!1;return Object.entries(e).forEach(([s,i])=>{const a=t?.[s]||s;if(Ui(i)){n[a]=i,o=!0;return}const d=r?.[s]||"string";let u=i;if(d==="number"){const l=Number(i);u=isNaN(l)?i:l}else d==="boolean"?u=i==="true"||i===!0||i==="1"||i===1:d==="date"?u=String(i):i!=null?u=typeof i=="object"?i:String(i):u="";n[a]=u}),{transformed:n,hasFiles:o}}const ph=Object.freeze(Object.defineProperty({__proto__:null,hasFileValues:uN,isFileValue:Ui,prepareFormDataWithFiles:fN,transformFormValuesWithFiles:pN},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 hN(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():"",s=typeof n.name=="string"&&n.name.trim()?n.name.trim():"";if(!o||!s)continue;const i=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:s,fieldNames:i,...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 mh(e){return e?.mode==="nested_by_section"}function hh(e){const t=e.payloadKey?.trim();return t||null}function gh(e,t){return t.fieldPayloadKeys?.[e]?.trim()||e}function yh(e,t,r,n){if(!mh(r)||!t?.length)return{...e};const o=new Set([]),s=r?.includeUnassignedAtRoot!==!1,i=new Set,a={};for(const d of t){const u=hh(d);if(!u)continue;const l={};for(const f of d.fieldNames){if(o.has(f)||!(f in e))continue;i.add(f);const p=gh(f,d);l[p]=e[f]}Object.keys(l).length>0&&(a[u]=l)}if(s)for(const[d,u]of Object.entries(e))o.has(d)||i.has(d)||(a[d]=u);return a}function gN(e,t,r){const n={...e??{}};if(!mh(r)||!t?.length)return n;for(const o of t){const s=hh(o);if(s)for(const i of o.fieldNames){if(n[i]?.trim())continue;const a=gh(i,o);n[i]=`${s}.${a}`}}return n}function yN(e){return e==="null"?null:e==="true"?!0:e==="false"?!1:e}function bN(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 vN(e,t){if(!t)return[];const r=e.trim().split(".");if(r.length<2)return[];const n=r[0],o=r.slice(1).join("."),s=[];return Object.entries(t).forEach(([i,a])=>{const d=i===n,u=i.startsWith(`${n}__addmore__`);if(!d&&!u||!bN(a))return;const l=Qe(a,o);l==null||l===""||s.push(l)}),s}function Vi(e,t,r,n,o,s){const i=e.trim().match(/^\{respAll:([^}]+)\}$/);if(i){const u=(i[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:vN(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=rn(e,t,r,n,o,s);return yN(String(d))}const wN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d,onClick:u,onSubmit:l,onReset:f,onCancel:p,isSubmitting:m=!1,formValues:g={},submissionContext:h,bffSubmitApi:y,onBffSubmitResult:v,extraSubmitPayload:w,buttonResponses:x,onButtonApiResponse:E,onValidateForm:P,getValidationErrors:C,allFields:N,onSubmittingChange:_,scopedFormValues:A,scopedFieldNameMap:I,prepopulateResponse:T=null,formSections:W,submitPayload:J})=>{const{gridStretch:O}=zo(),[j,M]=S.useState(!1),D=e.properties,L=ha.useParams(),U=S.useMemo(()=>({...h,...w}),[h,w]),$=S.useMemo(()=>{if(!A||!I||Object.keys(I).length===0)return g;const Je={};return Object.entries(A).forEach(([q,$e])=>{const gt=I[q]||q;gt!==e.name&&(Je[gt]=$e)}),Je},[A,I,g,e.name]),V=(()=>{try{const Je=e.metadata;if(typeof Je=="string")return JSON.parse(Je);if(Je&&typeof Je=="object")return Je}catch{}return null})(),K=D?.submitAction??V?.submitAction,X=D?.apiEndpoint??e.apidata?.apiEndpoint??V?.apiEndpoint;let ce=D?.action||V?.action;!ce&&e.type==="button"&&(ce="submit");const ne=D?.variant||"default",G=D?.size||"default",ee=D?.hideLabel??e.appearance?.hideLabel??!1,Pe=D?.buttonText||e.label||"Button",oe=D?.closeOnCancel??!0,re=async()=>{if(A&&I&&Object.keys(I).length>0||!P)return!0;const Je=await P();if(!Je&&C)try{const q=C();$t.toast.error(ec(q,N??void 0)||"Please fix the errors before submitting.")}catch{$t.toast.error("Please fix the errors before submitting.")}return Je},be=async Je=>{if(Je.preventDefault(),(ce==="submit"?"submit":ce)==="submit"){if(y?.url){if(!await re())return;M(!0),_?.(!0);try{const $e=await ot(),gt=($e?.message??$e?.display_message??"Form submitted successfully!").trim();$t.toast.success(gt||"Form submitted successfully!");const Oe=$e!=null&&typeof $e=="object"?$e:{status:"success",...$e!=null?{data:$e}:{}};E?.(e.name,Oe)}catch($e){const gt=ls($e);$t.toast.error(gt)}finally{M(!1),_?.(!1)}return}if(l){if(!await re())return;M(!0),_?.(!0);try{await l(),E?.(e.name,{status:"success"})}finally{M(!1),_?.(!1)}return}$t.toast.error("Submit not configured. BFF submit API is required for submit buttons.");return}else if(ce==="reset"&&f)f();else if(ce==="cancel")oe?p&&p():f&&f();else if(ce==="download"){const $e=D?.downloadApiEndpoint||V?.downloadApiEndpoint||e.downloadApiEndpoint,gt=D?.downloadApiMethod||V?.downloadApiMethod||e.downloadApiMethod;if($e){M(!0);try{const Oe=gt||"GET",te=cn(rn($e,$,L,U,x,T??void 0)),pe={method:Oe,headers:{}};Oe!=="GET"&&Oe!=="DELETE"&&(pe.headers={"Content-Type":"application/json"});const We=await fetch(te,pe);if(!We.ok)throw new Error(`Download failed: ${We.statusText}`);const Pt=await We.blob(),je=window.URL.createObjectURL(Pt),Te=document.createElement("a");Te.href=je;const Xe=We.headers.get("Content-Disposition");let Ue="download";if(Xe){const ft=Xe.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);ft&&ft[1]&&(Ue=ft[1].replace(/['"]/g,""))}Te.download=Ue,document.body.appendChild(Te),Te.click(),document.body.removeChild(Te),window.URL.revokeObjectURL(je);try{const ft=lN(We);$t.toast.success(ft&&ft.trim()?ft:"Download started.")}catch{$t.toast.success("Download started.")}}catch(Oe){Zl(Oe,"Failed to download file. Please check the API endpoint and try again.",ls)}finally{M(!1)}}else $t.toast.error("Download endpoint is not configured")}else if(ce==="upload"||ce==="custom"){const $e=ce==="custom",gt=$e?"api":D?.uploadAction||V?.uploadAction||"database";if(gt==="database")if(l){M(!0);try{await l(Je)}catch(Oe){throw Oe}finally{M(!1)}}else $t.toast.error("Form submit handler is not available");else if(gt==="api"){const Oe=D?.uploadApiEndpoint||V?.uploadApiEndpoint||e.uploadApiEndpoint;if(D?.uploadApiMethod||V?.uploadApiMethod||e.uploadApiMethod,Oe){if(!await re())return;M(!0);try{const te=await Se();E?.(e.name,te),aN(te,$e?"Custom API call completed successfully!":"Upload completed successfully!")}catch(te){E?.(e.name,{status:"error",code:te?.response?.code??te?.response?.status??null,message:ls(te)}),Zl(te,$e?"Failed to call custom API. Please check the API endpoint and try again.":"Failed to upload. Please check the API endpoint and try again.",ls)}finally{M(!1)}}else $t.toast.error($e?"Custom API endpoint is not configured":"Upload endpoint is not configured")}else gt==="custom"&&$t.toast.info("Custom upload handler is not implemented")}else u?u():r&&t!==void 0&&r(t||"");n?.()},de=async()=>{if(!K||K!=="api"||!X)return null;const Je=D?.apiBodyFields??V?.apiBodyFields;if((D?.apiBodyFieldsOnly??V?.apiBodyFieldsOnly??!1)&&Je?.length){const Te={};return Je.forEach(({key:Xe,value:Ue})=>{const ft=Vi(Ue,$,L,U,x,T??void 0),St=Xe==="user_id"?"context_user_id":Xe;Te[St]=ft}),Te.user_id!==void 0&&Te.user_id!==null&&(Te.context_user_id=Te.context_user_id??Te.user_id,delete Te.user_id),Te}const $e=N?.length?tc($,N):$,gt=D?.apiFieldMapping??V?.apiFieldMapping,Oe=D?.apiFieldTypes??V?.apiFieldTypes,te=D?.apiBodyStructure??V?.apiBodyStructure,pe={...Oe};N?.length&&N.forEach(Te=>{const Xe=Te.name||Te.key;Xe&&(Te.type==="terms"||Te.type==="checkbox")&&(pe[Xe]="boolean")});const{transformFormValuesWithFiles:We}=await Promise.resolve().then(()=>ph),{transformed:Pt}=We($e,gt,pe);let je={};if(te==="flat"?je={...Pt}:je={data:{...Pt}},gt){const Te={};Object.keys(je).forEach(Xe=>{const Ue=gt[Xe]||Xe;Te[Ue]=je[Xe]}),je=Te}return Je?.length&&Je.forEach(({key:Te,value:Xe})=>{const Ue=Vi(Xe,$,L,U,x,T??void 0),ft=Te==="user_id"?"context_user_id":Te;je[ft]=Ue}),je.user_id!==void 0&&je.user_id!==null&&(je.context_user_id=je.context_user_id??je.user_id,delete je.user_id),je.data?.user_id!==void 0&&je.data?.user_id!==null&&(je.data.context_user_id=je.data.context_user_id??je.data.user_id,delete je.data.user_id),je},ot=async()=>{if(!y||!y.url)throw new Error("BFF submit API configuration is missing");const Je=N?.length?tc(g,N):g,q={};Object.keys(Je).forEach(ze=>{const yt=e.name===ze&&e.type==="button",pt=ze.toLowerCase().includes("button");!yt&&!pt&&(q[ze]=Je[ze])});const $e=Object.keys(q).filter(ze=>Ui(q[ze]));$e.forEach(ze=>{q[ze]=""});const gt=yh(q,W,J),Oe={workflow_id:y.payload?.workflow_id||"",current_step_id:y.payload?.current_step_id||"",form_data:gt},te=["workflow_id","current_step_id","form_data","submit_body","submit_api_endpoint","submit_api_method"];if(h&&typeof h=="object"&&Object.entries(h).forEach(([ze,yt])=>{if(yt==null||te.includes(ze))return;const pt=ze==="user_id"?"context_user_id":ze;Oe[pt]=Oe[pt]??yt}),w&&typeof w=="object"&&Object.entries(w).forEach(([ze,yt])=>{if(yt==null||te.includes(ze))return;const pt=ze==="user_id"?"context_user_id":ze;Oe[pt]=Oe[pt]??yt}),K==="api"&&X)try{const ze=await de();if(ze){const yt=D?.apiBodyStructure??V?.apiBodyStructure,pt=D?.apiFieldMapping??V?.apiFieldMapping;$e.forEach(Ut=>{const ur=pt?.[Ut]??Ut,Ar=q[Ut]!==void 0&&typeof q[Ut]=="string"?q[Ut]:"";yt==="flat"?ze[ur]=Ar:ze.data&&typeof ze.data=="object"?ze.data[ur]=Ar:ze[ur]=Ar}),Oe.submit_body=ze;let At=rn(X,$,L,U,x,T??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=cn(At),Oe.submit_api_endpoint=At,Oe.submit_api_method=D?.submitApiMethod||V?.submitApiMethod||"POST"}}catch{}const pe=(y.method||"POST").toUpperCase(),We=$e.length>0,Pt=Oe.submit_api_endpoint??X??"",je=typeof Pt=="string"?Pt.toLowerCase():"",Te=je.includes("/upload")||je.includes("/payments")||je.includes("/bulk-upload"),Xe=We&&Te;let Ue;const ft={...y.headers||{}};if(Xe){const ze=new FormData;ze.append("payload",JSON.stringify(Oe));for(const yt of $e){const pt=Je[yt],At=D?.apiFieldMapping?.[yt]??yt;pt instanceof File?ze.append(At,pt):Array.isArray(pt)&&pt.length>0&&pt[0]instanceof File&&pt.forEach(Ut=>ze.append(At,Ut))}Ue=ze,delete ft["content-type"],delete ft["Content-Type"]}else ft["Content-Type"]="application/json",Ue=JSON.stringify(Oe);const St=await fetch(y.url,{method:pe,headers:ft,body:Ue});if(!St.ok){let ze;const yt=await St.text();try{ze=JSON.parse(yt)}catch{ze={message:yt}}const pt=new Error(`BFF submission failed: ${St.status}`);throw pt.response=ze,pt}const xt=await St.json();return v?.(xt),l&&await l(),xt},Se=async()=>{const Je=D?.uploadApiEndpoint||V?.uploadApiEndpoint;if(!Je)throw new Error("Upload API endpoint is not configured");if(!D)throw new Error("Button properties are not configured");const q=(D.uploadApiMethod||"POST").toUpperCase(),$e=cn(rn(Je,$,L,U,x,T??void 0)),gt=D.apiBodyFieldsOnly??V?.apiBodyFieldsOnly??!1,Oe=D.apiBodyFieldsOnlyFormat??V?.apiBodyFieldsOnlyFormat??"json";let te={},pe;const We={};if(gt&&D.apiBodyFields&&D.apiBodyFields.length>0)if(D.apiBodyFields.forEach(({key:Te,value:Xe})=>{te[Te]=Vi(Xe,$,L,U,x,T??void 0)}),Oe==="multipart"){const Te=new FormData;Object.entries(te).forEach(([Xe,Ue])=>{if(Ue instanceof File){Te.append(Xe,Ue);return}if(Array.isArray(Ue)&&Ue.length>0&&Ue[0]instanceof File){Ue.forEach(ft=>Te.append(Xe,ft));return}Ue!=null&&Te.append(Xe,typeof Ue=="object"?JSON.stringify(Ue):String(Ue))}),pe=Te}else pe=JSON.stringify(te),We["Content-Type"]="application/json";else{const Te=$,{transformFormValuesWithFiles:Xe,prepareFormDataWithFiles:Ue,hasFileValues:ft}=await Promise.resolve().then(()=>ph),{transformed:St,hasFiles:xt}=Xe(Te,D.apiFieldMapping,D.apiFieldTypes);if((D.apiBodyStructure??V?.apiBodyStructure??"nested")==="flat"?te={...St}:te={data:{...St}},D.apiFieldMapping){const yt={};Object.keys(te).forEach(pt=>{const At=D.apiFieldMapping[pt]||pt;yt[At]=te[pt]}),te=yt}if(D.apiBodyFields&&D.apiBodyFields.forEach(({key:yt,value:pt})=>{te[yt]=Vi(pt,$,L,U,x,T??void 0)}),xt||ft(te)){const yt=Ue(te,D.apiFieldMapping);yt?pe=yt:(pe=JSON.stringify(te),We["Content-Type"]="application/json")}else pe=JSON.stringify(te),We["Content-Type"]="application/json"}D.apiHeaders&&D.apiHeaders.forEach(({key:Te,value:Xe})=>{const Ue=rn(Xe,$,L,U,x,T??void 0);(Te.toLowerCase()!=="content-type"||!(pe instanceof FormData))&&(We[Te]=Ue)});let Pt=$e;if(D.apiQueryParams&&D.apiQueryParams.length>0){const Te=new URLSearchParams;D.apiQueryParams.forEach(({key:Xe,value:Ue})=>{const ft=rn(Ue,$,L,U,x,T??void 0);Te.append(Xe,ft)}),Pt=`${$e}?${Te.toString()}`}const je=await fetch(Pt,{method:q,headers:We,body:q!=="GET"?pe:void 0});if(!je.ok){let Te;const Xe=await je.text();try{Te=JSON.parse(Xe)}catch{Te={message:Xe}}const Ue=new Error(`Upload failed: ${je.status}`);throw Ue.response=Te,Ue}try{return await je.json()}catch{return{}}},xe=ce==="submit"?"submit":ce,ve=xe==="submit"?"button":xe==="submit"?"submit":xe==="reset"?"reset":"button",Ye=s||e.disabled||i||e.readOnly||j||xe==="submit"&&m,ct=Pe,Ge=to(e),Kt=Fr(e.appearance)==="stretch";return c.jsx(Et,{field:e,error:o,isRequired:a,className:d,hideLabel:ee,children:c.jsx("div",{className:B(O&&!Ge&&"flex w-full min-w-0 flex-col",O&&Ge&&"min-w-0 shrink-0"),children:c.jsxs(Yt,{id:ht(e),type:ve,variant:ne,size:G,disabled:Ye,onClick:be,className:B(e.appearance?.className,O&&!Ge&&"w-full min-w-0 shrink-0",O&&Ge&&!Kt&&"inline-flex w-auto max-w-full shrink-0",O&&Ge&&Kt&&"inline-flex w-full min-w-0 max-w-full shrink-0"),children:[j&&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}),ct]})})})},SN=({field:e,disabled:t,readOnly:r,isRequired:n,className:o,buttonResponses:s,onButtonApiResponse:i})=>{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=Uo(s?.[p]),g=t||e.disabled||r||e.readOnly||m,h=y=>{y.preventDefault(),!g&&i?.(p,{status:"success"})};return c.jsx(Et,{field:e,error:void 0,isRequired:n,className:o,hideLabel:f,children:c.jsx(Yt,{id:ht(e),type:"button",variant:u,size:l,disabled:g,onClick:h,className:B(e.appearance?.className,(!to(e)||Fr(e.appearance)==="stretch")&&"w-full min-w-0"),children:d})})},xN=({field:e,error:t,disabled:r,readOnly:n,isRequired:o,className:s,onAddMore:i})=>{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(Et,{field:e,error:t,isRequired:o,className:s,hideLabel:f,children:c.jsxs(Yt,{id:ht(e),type:"button",variant:d,size:u,disabled:!!p,onClick:i,className:B("w-fit",e.appearance?.className),children:[c.jsx(nu,{className:"h-4 w-4 mr-1"}),l]})})},bh=S.createContext(null);function AN({value:e,children:t}){return c.jsx(bh.Provider,{value:e,children:t})}function CN(){return S.useContext(bh)}function vh(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(0,t):e}function cs(e){return e.name||e.key||e.id}function rc(e){return e.filter(t=>!t.parentId&&t.type==="sectionHeading"&&cs(t))}function EN(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 NN(e){const t=new Map;for(const r of rc(e)){const n=cs(r);for(const o of EN(r))t.set(o,n)}return t}function _N(e,t){const r=t.properties||{},n=Array.isArray(r.sectionHeadingNames)?r.sectionHeadingNames.filter(i=>typeof i=="string"&&i.trim()):[],o=rc(e);if(n.length===0)return o;const s=new Set(n);return o.filter(i=>s.has(cs(i)))}function kN(e){const t={};for(const r of rc(e))t[cs(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 wh(e,t,r,n){if(!e||t==="customizeSections")return!0;const o=vh(e),s=t==="sectionHeading"?o:n.get(o);return s?r[s]!==!1:!0}const TN=({field:e,error:t,disabled:r,readOnly:n,isRequired:o,className:s,designMode:i=!1})=>{const a=CN(),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?_N(a.allFields,e):[],[a?.allFields,e]);return c.jsx(Et,{field:e,error:t,isRequired:o,className:s,hideLabel:m,children:c.jsxs(Ol,{children:[c.jsx(Hp,{asChild:!0,children:c.jsxs(Yt,{id:ht(e),type:"button",variant:u,size:l,disabled:!!g,className:B("w-fit gap-2",e.appearance?.className),children:[c.jsx(Fv,{className:"h-4 w-4"}),f]})}),c.jsxs(Il,{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 v=cs(y),w=y.label||v,x=i||!a?!0:a.visibility[v]!==!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(Sn,{htmlFor:`ui-section-${e.id}-${v}`,className:"text-xs font-normal truncate",children:w}),c.jsx(Nm,{id:`ui-section-${e.id}-${v}`,checked:x,disabled:i||!a||!!g,onCheckedChange:E=>{!a||i||a.setSectionVisible(v,!!E)}})]},y.id)})})]})]})})},FN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=e.properties,l=u?.max||5,f=u?.icon||"star",p=h=>{s||i||e.disabled||e.readOnly||(r(h),n?.())},m=h=>{},g=h=>{const y=t>=h+1,v=B("transition-colors cursor-pointer",y?"fill-yellow-400 text-yellow-400":"text-muted-foreground",(s||i||e.disabled||e.readOnly)&&"cursor-not-allowed opacity-50",!(s||i||e.disabled||e.readOnly)&&"hover:text-yellow-400");return f==="star"?c.jsx(ou,{className:B(v,"h-6 w-6"),onClick:()=>p(h+1),onMouseEnter:()=>m()},h):c.jsx(ou,{className:B(v,"h-6 w-6"),onClick:()=>p(h+1),onMouseEnter:()=>m()},h)};return c.jsx(Et,{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":jt(e,!!o),"aria-invalid":Jt(!!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 Sh=["PageUp","PageDown"],xh=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Ah={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},vo="Slider",[nc,PN,ON]=Ba(vo),[Ch]=vr(vo,[ON]),[IN,Hi]=Ch(vo),Eh=b.forwardRef((e,t)=>{const{name:r,min:n=0,max:o=100,step:s=1,orientation:i="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),v=b.useRef(0),x=i==="horizontal"?MN:LN,[E=[],P]=Zr({prop:l,defaultProp:u,onChange:T=>{[...y.current][v.current]?.focus(),f(T)}}),C=b.useRef(E);function N(T){const W=zN(E,T);I(T,W)}function _(T){I(T,v.current)}function A(){const T=C.current[v.current];E[v.current]!==T&&p(E)}function I(T,W,{commit:J}={commit:!1}){const O=WN(s),j=RN(Math.round((T-n)/s)*s+n,O),M=qo(j,[n,o]);P((D=[])=>{const L=$N(D,M,W);if(HN(L,d*s)){v.current=L.indexOf(M);const U=String(L)!==String(D);return U&&J&&p(L),U?L:D}else return D})}return c.jsx(IN,{scope:e.__scopeSlider,name:r,disabled:a,min:n,max:o,valueIndexToChangeRef:v,thumbs:y.current,values:E,orientation:i,form:g,children:c.jsx(nc.Provider,{scope:e.__scopeSlider,children:c.jsx(nc.Slot,{scope:e.__scopeSlider,children:c.jsx(x,{"aria-disabled":a,"data-disabled":a?"":void 0,...h,ref:t,onPointerDown:Me(h.onPointerDown,()=>{a||(C.current=E)}),min:n,max:o,inverted:m,onSlideStart:a?void 0:N,onSlideMove:a?void 0:_,onSlideEnd:a?void 0:A,onHomeKeyDown:()=>!a&&I(n,0,{commit:!0}),onEndKeyDown:()=>!a&&I(o,E.length-1,{commit:!0}),onStepKeyDown:({event:T,direction:W})=>{if(!a){const j=Sh.includes(T.key)||T.shiftKey&&xh.includes(T.key)?10:1,M=v.current,D=E[M],L=s*j*W;I(D+L,M,{commit:!0})}}})})})})});Eh.displayName=vo;var[Nh,_h]=Ch(vo,{startEdge:"left",endEdge:"right",size:"width",direction:1}),MN=b.forwardRef((e,t)=>{const{min:r,max:n,dir:o,inverted:s,onSlideStart:i,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=ro(o),y=h==="ltr",v=y&&!s||!y&&s;function w(x){const E=g.current||f.getBoundingClientRect(),P=[0,E.width],N=ic(P,v?[r,n]:[n,r]);return g.current=E,N(x-E.left)}return c.jsx(Nh,{scope:e.__scopeSlider,startEdge:v?"left":"right",endEdge:v?"right":"left",direction:v?1:-1,size:"width",children:c.jsx(kh,{dir:h,"data-orientation":"horizontal",...l,ref:m,style:{...l.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:x=>{const E=w(x.clientX);i?.(E)},onSlideMove:x=>{const E=w(x.clientX);a?.(E)},onSlideEnd:()=>{g.current=void 0,d?.()},onStepKeyDown:x=>{const P=Ah[v?"from-left":"from-right"].includes(x.key);u?.({event:x,direction:P?-1:1})}})})}),LN=b.forwardRef((e,t)=>{const{min:r,max:n,inverted:o,onSlideStart:s,onSlideMove:i,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(),v=[0,y.height],x=ic(v,m?[n,r]:[r,n]);return p.current=y,x(h-y.top)}return c.jsx(Nh,{scope:e.__scopeSlider,startEdge:m?"bottom":"top",endEdge:m?"top":"bottom",size:"height",direction:m?1:-1,children:c.jsx(kh,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:h=>{const y=g(h.clientY);s?.(y)},onSlideMove:h=>{const y=g(h.clientY);i?.(y)},onSlideEnd:()=>{p.current=void 0,a?.()},onStepKeyDown:h=>{const v=Ah[m?"from-bottom":"from-top"].includes(h.key);d?.({event:h,direction:v?-1:1})}})})}),kh=b.forwardRef((e,t)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:o,onSlideEnd:s,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:d,...u}=e,l=Hi(vo,r);return c.jsx(Be.span,{...u,ref:t,onKeyDown:Me(e.onKeyDown,f=>{f.key==="Home"?(i(f),f.preventDefault()):f.key==="End"?(a(f),f.preventDefault()):Sh.concat(xh).includes(f.key)&&(d(f),f.preventDefault())}),onPointerDown:Me(e.onPointerDown,f=>{const p=f.target;p.setPointerCapture(f.pointerId),f.preventDefault(),l.thumbs.has(p)?p.focus():n(f)}),onPointerMove:Me(e.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&o(f)}),onPointerUp:Me(e.onPointerUp,f=>{const p=f.target;p.hasPointerCapture(f.pointerId)&&(p.releasePointerCapture(f.pointerId),s(f))})})}),Th="SliderTrack",Fh=b.forwardRef((e,t)=>{const{__scopeSlider:r,...n}=e,o=Hi(Th,r);return c.jsx(Be.span,{"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation,...n,ref:t})});Fh.displayName=Th;var oc="SliderRange",Ph=b.forwardRef((e,t)=>{const{__scopeSlider:r,...n}=e,o=Hi(oc,r),s=_h(oc,r),i=b.useRef(null),a=Ze(t,i),d=o.values.length,u=o.values.map(p=>Mh(p,o.min,o.max)),l=d>1?Math.min(...u):0,f=100-Math.max(...u);return c.jsx(Be.span,{"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,...n,ref:a,style:{...e.style,[s.startEdge]:l+"%",[s.endEdge]:f+"%"}})});Ph.displayName=oc;var sc="SliderThumb",Oh=b.forwardRef((e,t)=>{const r=PN(e.__scopeSlider),[n,o]=b.useState(null),s=Ze(t,a=>o(a)),i=b.useMemo(()=>n?r().findIndex(a=>a.ref.current===n):-1,[r,n]);return c.jsx(DN,{...e,ref:s,index:i})}),DN=b.forwardRef((e,t)=>{const{__scopeSlider:r,index:n,name:o,...s}=e,i=Hi(sc,r),a=_h(sc,r),[d,u]=b.useState(null),l=Ze(t,w=>u(w)),f=d?i.form||!!d.closest("form"):!0,p=Jo(d),m=i.values[n],g=m===void 0?0:Mh(m,i.min,i.max),h=jN(n,i.values.length),y=p?.[a.size],v=y?UN(y,g,a.direction):0;return b.useEffect(()=>{if(d)return i.thumbs.add(d),()=>{i.thumbs.delete(d)}},[d,i.thumbs]),c.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${g}% + ${v}px)`},children:[c.jsx(nc.ItemSlot,{scope:e.__scopeSlider,children:c.jsx(Be.span,{role:"slider","aria-label":e["aria-label"]||h,"aria-valuemin":i.min,"aria-valuenow":m,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...s,ref:l,style:m===void 0?{display:"none"}:e.style,onFocus:Me(e.onFocus,()=>{i.valueIndexToChangeRef.current=n})})}),f&&c.jsx(Ih,{name:o??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:m},n)]})});Oh.displayName=sc;var BN="RadioBubbleInput",Ih=b.forwardRef(({__scopeSlider:e,value:t,...r},n)=>{const o=b.useRef(null),s=Ze(o,n),i=Qo(t);return b.useEffect(()=>{const a=o.current;if(!a)return;const d=window.HTMLInputElement.prototype,l=Object.getOwnPropertyDescriptor(d,"value").set;if(i!==t&&l){const f=new Event("input",{bubbles:!0});l.call(a,t),a.dispatchEvent(f)}},[i,t]),c.jsx(Be.input,{style:{display:"none"},...r,ref:s,defaultValue:t})});Ih.displayName=BN;function $N(e=[],t,r){const n=[...e];return n[r]=t,n.sort((o,s)=>o-s)}function Mh(e,t,r){const s=100/(r-t)*(e-t);return qo(s,[0,100])}function jN(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function zN(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 UN(e,t,r){const n=e/2,s=ic([0,50],[0,n]);return(n-s(t)*r)*r}function VN(e){return e.slice(0,-1).map((t,r)=>e[r+1]-t)}function HN(e,t){if(t>0){const r=VN(e);return Math.min(...r)>=t}return!0}function ic(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 WN(e){return(String(e).split(".")[1]||"").length}function RN(e,t){const r=Math.pow(10,t);return Math.round(e*r)/r}var GN=Eh,KN=Fh,qN=Ph,YN=Oh;function XN({className:e,defaultValue:t,value:r,min:n=0,max:o=100,...s}){const i=b.useMemo(()=>Array.isArray(r)?r:Array.isArray(t)?t:[n,o],[r,t,n,o]);return c.jsxs(GN,{"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),...s,children:[c.jsx(KN,{"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(qN,{"data-slot":"slider-range",className:B("bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")})}),Array.from({length:i.length},(a,d)=>c.jsx(YN,{"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 JN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,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=v=>{s||i||e.disabled||e.readOnly||(r(v[0]??l),n?.())},y=t??l;return c.jsx(Et,{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(XN,{id:ht(e),value:[y],onValueChange:h,min:l,max:f,step:p,disabled:s||e.disabled||i||e.readOnly,className:B("w-full",o&&"border-destructive",e.appearance?.className),"aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a}),g.length>0&&c.jsx("div",{className:"flex justify-between text-xs text-muted-foreground",children:g.map((v,w)=>c.jsx("span",{className:"text-center",children:v.label},w))})]})})},QN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=S.useRef(null),[l,f]=S.useState(!1),p=s||e.disabled||i||e.readOnly,m=S.useCallback(v=>{if(p)return;f(!0);const w=u.current;if(!w)return;const x=w.getContext("2d");if(!x)return;const E=w.getBoundingClientRect(),P="touches"in v?v.touches[0].clientX-E.left:v.clientX-E.left,C="touches"in v?v.touches[0].clientY-E.top:v.clientY-E.top;x.beginPath(),x.moveTo(P,C)},[p]),g=S.useCallback(v=>{if(!l||p)return;const w=u.current;if(!w)return;const x=w.getContext("2d");if(!x)return;const E=w.getBoundingClientRect(),P="touches"in v?v.touches[0].clientX-E.left:v.clientX-E.left,C="touches"in v?v.touches[0].clientY-E.top:v.clientY-E.top;x.lineWidth=2,x.lineCap="round",x.strokeStyle="#000",x.lineTo(P,C),x.stroke(),x.beginPath(),x.moveTo(P,C)},[l,p]),h=S.useCallback(()=>{if(!l)return;f(!1);const v=u.current;if(!v)return;const w=v.toDataURL();r(w),n?.()},[l,r,n]),y=S.useCallback(()=>{const v=u.current;if(!v||p)return;const w=v.getContext("2d");w&&(w.clearRect(0,0,v.width,v.height),r(null),n?.())},[p,r,n]);return S.useEffect(()=>{const v=u.current;if(v&&(v.width=v.offsetWidth,v.height=200,t)){const w=new Image;w.onload=()=>{const x=v.getContext("2d");x&&x.drawImage(w,0,0)},w.src=t}},[t]),c.jsx(Et,{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":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,style:{height:"200px"}})}),!p&&c.jsx("div",{className:"flex justify-end",children:c.jsxs(Yt,{type:"button",variant:"outline",size:"sm",onClick:y,className:"text-xs",children:[c.jsx(Go,{className:"h-3 w-3 mr-1"}),"Clear"]})})]})})},ZN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,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,v=!u&&p?.allowDeleteRow!==!1,w=s===!1&&i===!1?!1:s||e.disabled||i||e.readOnly,x=t||[],E=y&&x.length<h,P=v&&x.length>g,C=S.useCallback(()=>{if(!E||w)return;const O={};m.forEach(j=>{O[j.name]=j.defaultValue??""}),r([...x,O]),n?.()},[x,m,E,w,r,n]),N=S.useCallback(O=>{if(!P||w)return;const j=x.filter((M,D)=>D!==O);r(j),n?.()},[x,P,w,r,n]),_=S.useCallback((O,j,M)=>{if(w)return;const D=[...x];D[O]||(D[O]={}),D[O][j]=M,r(D),n?.()},[x,w,r,n]);if(S.useEffect(()=>{if(x.length<g){const O=g-x.length,j=[];for(let M=0;M<O;M++){const D={};m.forEach(L=>{D[L.name]=L.defaultValue??""}),j.push(D)}r([...x,...j])}},[g,m,r,x.length]),m.length===0)return c.jsx(Et,{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),I=Math.max(1,e.position?.columnSpan??1),T=Math.max(x.length,1),W=A>=3?"py-4":A>=2?"py-3":"py-2.5",J=I>=3?"px-4":I>=2?"px-3":"px-4";return c.jsx(Et,{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",w&&"opacity-50"),"aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!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(O=>c.jsxs("th",{className:B(J,W,"text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground whitespace-nowrap"),children:[O.label,a&&O.validation?.some(j=>j.type==="required")&&c.jsx("span",{className:"text-destructive ml-1",children:"*"})]},O.id)),v&&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+(v?1:0),className:B(J,"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((O,j)=>{const M=x[j],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}_${j}_${L.name}`,appearance:{...L.appearance,hideLabel:!0}},$=L.name??"",ie=O[$]!==void 0?O[$]:$&&Object.keys(O).find(G=>G.toLowerCase()===$.toLowerCase())?O[Object.keys(O).find(G=>G.toLowerCase()===$.toLowerCase())]:void 0,V=!!L.readOnly,K=G=>{if(G==null)return"";if(Array.isArray(G))return G.map(ee=>typeof ee=="object"&&ee!==null&&"name"in ee?String(ee.name??ee):String(ee)).join(", ");if(typeof G=="object"&&G!==null&&!(G instanceof Date)){const ee=G;return typeof ee.name=="string"&&typeof ee.code=="string"?`${ee.code} ${ee.name}`.trim():typeof ee.name=="string"?ee.name:typeof ee.code=="string"?ee.code:String(ee.name??ee.code??G)}return String(G)},X=G=>typeof G=="object"&&G!==null&&!Array.isArray(G)?K(G):String(G??""),ce=L.name?.toLowerCase()==="type"||L.label?.toLowerCase()==="type";if(V){const G=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:ce&&G?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:G}):c.jsx("span",{className:"py-1 block",children:G})})},L.id)}const ne=()=>{switch(L.type){case"text":case"password":case"url":return c.jsx(Da,{field:U,value:X(ie),onChange:G=>_(j,L.name,G),disabled:w,readOnly:w,className:"w-full"});case"number":return c.jsx(Xd,{field:U,value:ie??null,onChange:G=>_(j,L.name,G),disabled:w,readOnly:w,className:"w-full"});case"email":return c.jsx(su,{field:U,value:X(ie),onChange:G=>_(j,L.name,G),disabled:w,readOnly:w,className:"w-full"});case"phone":case"aadhaar":return c.jsx(iu,{field:U,value:X(ie),onChange:G=>_(j,L.name,G),disabled:w,readOnly:w,className:"w-full"});case"textarea":return c.jsx(au,{field:U,value:X(ie),onChange:G=>_(j,L.name,G),disabled:w,readOnly:w,className:"w-full"});case"select":return c.jsx(kp,{field:U,value:typeof ie=="string"?ie:X(ie),onChange:G=>_(j,L.name,G),disabled:w,className:"w-full",formValues:D,submissionContext:f});case"multiselect":{const G=Array.isArray(ie)?ie:ie!=null&&ie!==""?[String(ie)]:[];return c.jsx(vm,{field:U,value:G,onChange:ee=>_(j,L.name,ee),disabled:w,className:"w-full",formValues:D,submissionContext:f})}case"asyncsearch":return c.jsx(Xp,{field:U,value:ie,onChange:G=>_(j,L.name,G),disabled:w,readOnly:w,className:"w-full",formValues:D,submissionContext:f});case"checkbox":return c.jsx(wm,{field:U,value:ie||!1,onChange:G=>_(j,L.name,G),disabled:w,className:"w-full"});case"radio":case"checkboxgroup":return c.jsx(Gm,{field:U,value:typeof ie=="string"?ie:X(ie),onChange:G=>_(j,L.name,G),disabled:w,className:"w-full"});case"date":case"time":case"datetime":case"daterange":return c.jsx(Km,{field:U,value:typeof ie=="string"?ie:X(ie),onChange:G=>_(j,L.name,G),disabled:w,readOnly:w,className:"w-full"});default:return c.jsx(Da,{field:U,value:X(ie),onChange:G=>_(j,L.name,G),disabled:w,readOnly:w,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)}),v&&c.jsx("td",{className:"px-2 py-2",children:c.jsx(Yt,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>N(j),disabled:!P||w,children:c.jsx(Go,{className:"h-4 w-4"})})})]},j)})})]})}),E&&c.jsx("div",{className:"shrink-0 p-3 border-t bg-muted/30",children:c.jsxs(Yt,{type:"button",variant:"outline",size:"sm",onClick:C,disabled:w,className:"w-full",children:[c.jsx(nu,{className:"h-4 w-4 mr-2"}),"Add Row"]})})]})})};function Lh(e,t,r){const n=r?.emptyDisplay??"—";if(e==null||e==="")return n;const o=t?.format??"text",s=typeof e=="number"?e:Number(e);switch(o){case"currency":return Number.isNaN(s)?n:`${r?.currencySymbol??"₹"}${s.toLocaleString("en-IN",{minimumFractionDigits:0,maximumFractionDigits:2})}`;case"percent":return Number.isNaN(s)?n:`${s}%`;case"number":return Number.isNaN(s)?n:String(s);default:return String(e)}}function e_(e){const t=e.replace(/[^\d.-]/g,"");if(t===""||t==="-"||t===".")return null;const r=parseFloat(t);return Number.isNaN(r)?null:r}function t_(e){if(e==null||e==="")return"";const t=typeof e=="number"?e:Number(e);return Number.isNaN(t)?"":String(t)}function Dh(e,t){return Lh(e,{format:"currency"},t)}function ds(e){return e==null||e===""}function Bh(e){return e.mode??"editable"}function r_(e,t){return e.kind==="currency"||e.kind==="input"&&e.inputType==="number"?!0:t?.format==="currency"||t?.format==="number"||t?.format==="percent"}function $h(e,t,r){if(e!==void 0){if(e==="")return"";if(r_(t,r)){const n=Number(e);return Number.isNaN(n)?e:n}return e}}function ac(e,t){if(!(!e||!("defaultValue"in e)||e.defaultValue===void 0))return $h(e.defaultValue,e,t)}function lc(e,t,r){if(!t||!ds(e))return e;if(t.kind==="currency"&&Bh(t)==="static"&&t.value!==void 0)return $h(t.value,t,r);const n=ac(t,r);return n!==void 0?n:e}function n_(e,t,r){const n={...t};for(const[o,s]of Object.entries(e)){const i=r.find(d=>d.key===o);if(!ds(n[o]))continue;const a=lc(n[o],s,i);(!ds(a)||s&&"defaultValue"in s&&s.defaultValue==="")&&(n[o]=a)}return n}function Wi(e,t,r){if(!ds(e))return e;const n=ac(t,r);return n!==void 0?n:e}const o_=new Set(["all_items_summary","invoice_discount","grand_total"]);function s_(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"&&!o_.has(r.slotId));default:return e}}function cc(e){if(typeof e=="number"&&!Number.isNaN(e))return e;const t=Number(e);return Number.isNaN(t)?0:t}function i_(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 a_(e,t,r){const n=u=>cc(r.values[u]),o=(u,l)=>{const f=t.find(p=>p.slotId===u&&p.rowKind==="static");return f?cc(f.values[l]):0},s=(u,l="all")=>s_(t,l).reduce((f,p)=>f+cc(p.values[u]),0),i={...Ds.functions,cell:n,cellInRow:o,SUM:s},a=Object.keys(i),d=Object.values(i);try{const u=new Function(...a,`return (${e});`)(...d);return u==null||typeof u=="number"&&Number.isNaN(u)?null:u}catch{return null}}function wo(e,t){const r=t.rows.map(n=>({...n,values:{...n.values}}));for(const n of r)for(const o of e.columns){const s=i_(e,n,o.key);if(s?.kind==="formula"){const i=a_(s.expression,r,n),a=e.columns.find(d=>d.key===o.key);n.values[o.key]=ds(i)?ac(s,a)??i:i}}return{rows:r}}function l_(e,t,r,n,o,s){const i=t.rows.map(a=>a.rowInstanceId!==r||a.slotId!==n?a:{...a,values:{...a.values,[o]:s}});return wo(e,{rows:i})}function jh(e,t,r=[]){return t.map((n,o)=>{const s=typeof n=="object"&&n!==null?n:{},i=e.rowIdField&&s[e.rowIdField]!=null?String(s[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]=Wi(Qe(s,l.path),l,f))}const d=a.service??a.tariff_type;return{slotId:e.id,rowKind:"dynamic",rowInstanceId:i,label:typeof d=="string"?d:void 0,values:a}})}function dc(e,t,r){const n=[];for(const o of e.rowSlots)if(o.kind==="static"){const s=t.get(o.row.id);s&&n.push(s)}else n.push(...r.get(o.block.id)??[]);return n}function uc(e,t){const r=new Map,n=new Map;for(const o of e.rowSlots)if(o.kind==="static"){const s=t?.rows.find(i=>i.slotId===o.row.id&&i.rowKind==="static");r.set(o.row.id,{slotId:o.row.id,rowKind:"static",rowInstanceId:o.row.id,label:o.row.label,values:n_(o.row.cells,s?.values?{...s.values}:{},e.columns)})}else{const s=t?.rows.filter(i=>i.slotId===o.block.id&&i.rowKind==="dynamic")??[];n.set(o.block.id,s.map(i=>({...i,values:{...i.values}})))}return{rows:dc(e,r,n)}}function c_(e,t,r,n){const o=uc(e,n),s=e.rowSlots.find(d=>d.kind==="dynamic"&&d.block.id===t);if(!s||s.kind!=="dynamic")return wo(e,o);const i=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&&i.set(d.row.id,{...u,values:{...u.values}})}else{const u=d.block.id===t?jh(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 wo(e,{rows:dc(e,i,a)})}function d_(e,t,r){const n=uc(e,r);if(t==null||typeof t!="object"||Array.isArray(t))return wo(e,n);const o=t,s=new Map,i=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]=Wi(Qe(l,p.path),p,m))}s.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);i.set(a.block.id,Array.isArray(u)?jh(a.block,u,e.columns):[])}return wo(e,{rows:dc(e,s,i)})}function zh(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 u_(e){const t=e?.color?.trim();return t?{color:t}:{}}function fc(e){return{className:zh(e),style:u_(e)}}function pc(e){return e==="center"?"text-center":e==="right"?"text-right":"text-left"}function Uh(e,t){return e?.align?e.align:t?.align??"left"}function f_(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 Vh(e,t,r,n){const o=e.rowSlots.find(s=>r==="static"?s.kind==="static"&&s.row.id===t:s.kind==="dynamic"&&s.block.id===t);if(o)return o.kind==="static"?o.row.cells[n]:o.block.cells[n]}const p_=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=e.properties??{},l=u.columns??[],f=u.currencySymbol??"₹",p=u.emptyDisplay??"—",m=s||i,g=S.useMemo(()=>{const N=uc(u,t);return wo(u,N)},[u,t]);S.useEffect(()=>{!t?.rows?.length&&g.rows.length&&r(g)},[t,g,r]);const h=S.useCallback((N,_,A,I,T)=>{if(m)return;const W=T==="number"?e_(I):I===""?null:I,J=l_(u,g,N,_,A,W);r(J)},[m,g,r,u]),y=(N,_,A,I,T,W)=>{const J=l.find(U=>U.key===T),O=Vh(u,N,_,T),j=pc(Uh(O,J)),M=lc(W,O,J),D=f_(u,N,_),L=D?.kind==="static"?D.row.labelStyle:D?.kind==="dynamic"?D.block.labelStyle:void 0;if(O?.kind==="label"){const U=fc(L);return c.jsx("span",{className:B(U.className||"font-medium",j,!L?.color&&"text-foreground"),style:U.style,children:I??p})}if(O?.kind==="input"&&!m){const U=M==null||M===""?"":String(M);return c.jsx(wn,{type:"text",inputMode:O.inputType==="number"?"decimal":"text",value:U,onChange:$=>h(A,N,T,$.target.value,O.inputType),onBlur:n,className:B("h-8 text-sm border-0 shadow-none focus-visible:ring-1 bg-transparent",j),disabled:m})}if(O?.kind==="currency"){const U=Bh(O);if(U==="static"){const ie=O.value!==void 0&&O.value!==""?lc(null,{...O,mode:"static"},J):M;return c.jsx("span",{className:B("tabular-nums",j),children:Dh(ie,{currencySymbol:f,emptyDisplay:p})})}if(U==="api"||m)return c.jsx("span",{className:B("tabular-nums",j),children:Dh(M,{currencySymbol:f,emptyDisplay:p})});const $=t_(M);return c.jsxs("div",{className:B("flex w-full items-center gap-0.5",j==="text-center"&&"justify-center",j==="text-right"&&"justify-end",j==="text-left"&&"justify-start"),children:[c.jsx("span",{className:"shrink-0 text-sm tabular-nums text-foreground",children:f}),c.jsx(wn,{type:"text",inputMode:"decimal",value:$,onChange:ie=>h(A,N,T,ie.target.value,"number"),onBlur:n,className:"h-8 min-w-[2ch] max-w-full flex-1 border-0 bg-transparent text-sm tabular-nums shadow-none focus-visible:ring-1",disabled:m})]})}return O?.kind==="static"?c.jsx("span",{className:B("text-muted-foreground",j),children:O.value}):c.jsx("span",{className:B(j),children:Lh(M,J,{currencySymbol:f,emptyDisplay:p})})},v=u.gridTitle?.trim()??"",w=Math.max(1,e.position?.rowSpan??1),x=Math.max(1,e.position?.columnSpan??1),E=Math.max(g.rows.length,1),P=w>=3?"py-4":w>=2?"py-3":"py-2",C=x>=3?"px-4":x>=2?"px-3":"px-2";return l.length===0?c.jsx(Et,{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(Et,{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":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,children:[v?c.jsx("div",{className:B("shrink-0 px-4 py-2 border-b bg-muted/40",zh(u.gridTitleStyle)||"text-muted-foreground"),style:fc(u.gridTitleStyle).style,children:v}):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(N=>{const _=fc(N.headerStyle);return c.jsx("th",{className:B(C,P,"text-xs uppercase tracking-wider whitespace-nowrap",pc(N.align),_.className||"font-semibold text-muted-foreground"),style:_.style,children:N.label},N.id)})})}),c.jsx("tbody",{className:"h-full",children:g.rows.length===0?c.jsx("tr",{children:c.jsx("td",{colSpan:l.length,className:B(C,"py-8 text-center text-sm text-muted-foreground"),children:"No billing rows configured"})}):g.rows.map(N=>c.jsx("tr",{className:"border-b border-border/60",style:{height:`${100/E}%`},children:l.map(_=>{const A=Vh(u,N.slotId,N.rowKind,_.key),I=Uh(A,_);return c.jsx("td",{className:B(C,P,"align-middle whitespace-nowrap",pc(I)),children:y(N.slotId,N.rowKind,N.rowInstanceId,N.label,_.key,N.values[_.key])},_.id)})},`${N.slotId}-${N.rowInstanceId}`))})]})})]})})};function mc(e,t,r){return d_(e,t,r)}const m_=({field:e,value:t,error:r,disabled:n,isRequired:o,className:s,formValues:i={},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(),v=f.showCurrentIndicator!==!1,[w,x]=S.useState(null),[E,P]=S.useState(!1),[C,N]=S.useState(null),_=ha.useParams(),A=S.useRef(i),I=S.useRef(a),T=S.useRef(d),W=S.useRef(_);A.current=i,I.current=a,T.current=d,W.current=_;const J=S.useCallback(async()=>{const L=f.apiEndpoint?.trim();if(!L){N("Status API endpoint is not configured");return}P(!0),N(null);try{const U=I.current,$=T.current,ie=U!=null&&typeof U=="object"?{...U,...$||{}}:$||{},V=cn(rn(L,A.current,W.current,ie,void 0,l??void 0)),K=(f.apiMethod||"GET").toUpperCase(),X=await fetch(V,{method:K,headers:K==="POST"?{"Content-Type":"application/json"}:void 0});if(!X.ok)throw new Error(`HTTP ${X.status}`);const ce=await X.json(),ne=g?Qe(ce,g):ce;x(ne&&typeof ne=="object"?ne:{})}catch(U){N(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&&J()},[p,u,J]);const O=p==="api"?w:t&&typeof t=="object"?(g?Qe(t,g):null)??t:null,j=h&&y&&O?String(Qe(O,y)??Qe({data:O},y)??""):"",M=L=>{if(!O||typeof O!="object")return!1;const U=O[L];return U===!0||U==="true"||U===1};let D=!1;return c.jsx(Et,{field:e,error:r||C||void 0,isRequired:o,className:B(s,"!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:[E&&c.jsx("div",{className:"text-sm text-muted-foreground py-2",children:"Loading status..."}),h&&j&&!E&&c.jsx("p",{className:"text-sm text-muted-foreground mb-3 shrink-0","data-status-text":!0,children:j}),!E&&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),$=v&&U&&!D;return $&&(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(Vs,{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(eu,{className:"h-2.5 w-2.5 text-muted-foreground/60"})}),c.jsx("span",{className:"flex-1 min-w-0",children:L.label}),$&&c.jsx("span",{className:"shrink-0 text-xs font-medium text-primary",children:"Current"})]},L.key)})}),!E&&m.length===0&&c.jsx("p",{className:"text-sm text-muted-foreground",children:"No statuses configured."})]})})};function hc(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 So(e,t){if(t){const r=hc(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 h_(e,t,r,n){if(r?.length){const s=n??" | ",i=r.map(a=>hc(e,a)).filter(a=>a!=null).map(a=>String(a));if(i.length)return i.join(s)}if(t){const s=hc(e,t);if(s!=null)return String(s)}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 g_=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,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 v=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:v.length,contextListSample:v.length>0?v.slice(0,2):[]});const[w,x]=S.useState(()=>v.length>0?v:Array.isArray(t)?t:[]);S.useEffect(()=>{if(v.length>0){console.log("[SelectableList] Step 3: sync fullList from context",{fieldName:e.name,contextListLength:v.length}),x(v);return}Array.isArray(t)&&t.length>0&&x(T=>{const W=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:W.length}),W})},[v,t]);const E=S.useMemo(()=>{const T=Array.isArray(t)?t:[];return new Set(T.map(J=>So(J,p)))},[t,p]),P=w.length>0&&w.every(T=>E.has(So(T,p))),C=w.some(T=>E.has(So(T,p))),N=S.useCallback((T,W)=>{const J=So(T,p),O=Array.isArray(t)?t:[];W?E.has(J)||r([...O,T]):r(O.filter(j=>So(j,p)!==J)),n?.()},[t,p,E,r,n]),_=S.useCallback(T=>{r(T===!0?[...w]:[]),n?.()},[w,r,n]),A=w.length>0?w:Array.isArray(t)?t:[],I=s||e.disabled;return console.log("[SelectableList] Data in list",{fieldName:e.name,listLength:A.length,listSource:w.length>0?"fullList":"value",valueLength:Array.isArray(t)?t.length:0,fullListLength:w.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(Et,{field:e,error:o,isRequired:i,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(Ti,{id:`${ht(e)}-select-all`,checked:P?!0:C?"indeterminate":!1,onCheckedChange:_,disabled:I,"aria-label":"Select all"}),c.jsxs(Sn,{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(Yt,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs",disabled:I||P,onClick:()=>{r([...w]),n?.()},children:"Select all"}),c.jsx(Yt,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs",disabled:I||!C,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,W)=>{const J=So(T,p),O=E.has(J),j=`${ht(e)}-${W}-${J}`;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(Ti,{id:j,checked:O,onCheckedChange:M=>N(T,M===!0),disabled:I,"aria-describedby":jt(e,!!o)}),c.jsx(Sn,{htmlFor:j,className:"text-sm cursor-pointer flex-1 truncate",children:h_(T,f,m,g)})]},J)})})]}),A.length>0&&E.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."]})]})})})})},Hh=({field:e,children:t,className:r})=>{const n=e.properties,o=n?.collapsible??!1,s=n?.defaultCollapsed??!1,i=n?.columns??1,[a,d]=S.useState(s),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(Zd,{className:"h-4 w-4"}):c.jsx(Wo,{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[i]),children:t})]})};var y_=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],b_=y_.reduce((e,t)=>{const r=La(`Primitive.${t}`),n=b.forwardRef((o,s)=>{const{asChild:i,...a}=o,d=i?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(d,{...a,ref:s})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),v_="Separator",Wh="horizontal",w_=["horizontal","vertical"],Rh=b.forwardRef((e,t)=>{const{decorative:r,orientation:n=Wh,...o}=e,s=S_(n)?n:Wh,a=r?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return c.jsx(b_.div,{"data-orientation":s,...a,...o,ref:t})});Rh.displayName=v_;function S_(e){return w_.includes(e)}var x_=Rh;function gc({className:e,orientation:t="horizontal",decorative:r=!0,...n}){return c.jsx(x_,{"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 A_=({field:e,className:t})=>c.jsx("div",{className:B("py-2",t),children:c.jsx(gc,{})}),C_={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,s=C_[n],i=n;return c.jsxs("div",{className:B("w-full min-w-0 space-y-1",t),children:[c.jsx(i,{className:B("m-0 text-foreground",s),children:e.label||"Header"}),e.description&&c.jsx("p",{className:"text-sm text-muted-foreground",children:e.description}),o&&c.jsx(gc,{className:"w-full"})]})},N_={"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"},__={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?.position??"top-left",o=r?.headingLevel??"h3",s=r?.showHorizontalLine??!0,i=N_[n],a=__[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",i),children:c.jsx(d,{className:B("m-0 text-foreground",a),children:e.label||"Section Heading"})}),s&&c.jsx(gc,{className:"w-full"})]})},T_=({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 Gh(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 F_(e){if(Array.isArray(e))return e}function P_(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,o,s,i,a=[],d=!0,u=!1;try{if(s=(r=r.call(e)).next,t!==0)for(;!(d=(n=s.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&&(i=r.return(),Object(i)!==i))return}finally{if(u)throw o}}return a}}function O_(){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 I_(e,t){return F_(e)||P_(e,t)||M_(e,t)||O_()}function M_(e,t){if(e){if(typeof e=="string")return Gh(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)?Gh(e,t):void 0}}const Kh=Object.entries,qh=Object.setPrototypeOf,L_=Object.isFrozen,D_=Object.getPrototypeOf,B_=Object.getOwnPropertyDescriptor;let lr=Object.freeze,Mr=Object.seal,xo=Object.create,Yh=typeof Reflect<"u"&&Reflect,yc=Yh.apply,bc=Yh.construct;lr||(lr=function(t){return t}),Mr||(Mr=function(t){return t}),yc||(yc=function(t,r){for(var n=arguments.length,o=new Array(n>2?n-2:0),s=2;s<n;s++)o[s-2]=arguments[s];return t.apply(r,o)}),bc||(bc=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 Ao=zt(Array.prototype.forEach),$_=zt(Array.prototype.lastIndexOf),Xh=zt(Array.prototype.pop),Co=zt(Array.prototype.push),j_=zt(Array.prototype.splice),cr=Array.isArray,us=zt(String.prototype.toLowerCase),vc=zt(String.prototype.toString),Jh=zt(String.prototype.match),Eo=zt(String.prototype.replace),Qh=zt(String.prototype.indexOf),z_=zt(String.prototype.trim),U_=zt(Number.prototype.toString),V_=zt(Boolean.prototype.toString),Zh=typeof BigInt>"u"?null:zt(BigInt.prototype.toString),eg=typeof Symbol>"u"?null:zt(Symbol.prototype.toString),Ot=zt(Object.prototype.hasOwnProperty),fs=zt(Object.prototype.toString),Zt=zt(RegExp.prototype.test),Ri=H_(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 yc(e,t,n)}}function H_(e){return function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return bc(e,r)}}function nt(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:us;if(qh&&qh(e,null),!cr(t))return e;let n=t.length;for(;n--;){let o=t[n];if(typeof o=="string"){const s=r(o);s!==o&&(L_(t)||(t[n]=s),o=s)}e[o]=!0}return e}function W_(e){for(let t=0;t<e.length;t++)Ot(e,t)||(e[t]=null);return e}function hr(e){const t=xo(null);for(const n of Kh(e)){var r=I_(n,2);const o=r[0],s=r[1];Ot(e,o)&&(cr(s)?t[o]=W_(s):s&&typeof s=="object"&&s.constructor===Object?t[o]=hr(s):t[o]=s)}return t}function R_(e){switch(typeof e){case"string":return e;case"number":return U_(e);case"boolean":return V_(e);case"bigint":return Zh?Zh(e):"0";case"symbol":return eg?eg(e):"Symbol()";case"undefined":return fs(e);case"function":case"object":{if(e===null)return fs(e);const t=e,r=Kn(t,"toString");if(typeof r=="function"){const n=r(t);return typeof n=="string"?n:fs(n)}return fs(e)}default:return fs(e)}}function Kn(e,t){for(;e!==null;){const n=B_(e,t);if(n){if(n.get)return zt(n.get);if(typeof n.value=="function")return zt(n.value)}e=D_(e)}function r(){return null}return r}function G_(e){try{return Zt(e,""),!0}catch{return!1}}const tg=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"]),wc=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"]),Sc=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"]),K_=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"]),xc=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"]),q_=lr(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),rg=lr(["#text"]),ng=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"]),Ac=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"]),og=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"]),Gi=lr(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Y_=Mr(/{{[\w\W]*|^[\w\W]*}}/g),X_=Mr(/<%[\w\W]*|^[\w\W]*%>/g),J_=Mr(/\${[\w\W]*/g),Q_=Mr(/^data-[\-\w.\u00B7-\uFFFF]+$/),Z_=Mr(/^aria-[\-\w]+$/),sg=Mr(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ek=Mr(/^(?:\w+script|data):/i),tk=Mr(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),rk=Mr(/^html$/i),nk=Mr(/^[a-z][.\w]*(-[.\w]+)+$/i),No={element:1,text:3,progressingInstruction:7,comment:8,document:9},ok=function(){return typeof window>"u"?null:window},sk=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 s="dompurify"+(n?"#"+n:"");try{return t.createPolicy(s,{createHTML(i){return i},createScriptURL(i){return i}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},ig=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function ag(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ok();const t=Ee=>ag(Ee);if(t.version="3.4.5",t.removed=[],!e||!e.document||e.document.nodeType!==No.document||!e.Element)return t.isSupported=!1,t;let r=e.document;const n=r,o=n.currentScript,s=e.DocumentFragment,i=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=Kn(h,"cloneNode"),v=Kn(h,"remove"),w=Kn(h,"nextSibling"),x=Kn(h,"childNodes"),E=Kn(h,"parentNode"),P=a&&a.prototype?Kn(a.prototype,"nodeType"):null;if(typeof i=="function"){const Ee=r.createElement("template");Ee.content&&Ee.content.ownerDocument&&(r=Ee.content.ownerDocument)}let C,N="";const _=r,A=_.implementation,I=_.createNodeIterator,T=_.createDocumentFragment,W=_.getElementsByTagName,J=n.importNode;let O=ig();t.isSupported=typeof Kh=="function"&&typeof E=="function"&&A&&A.createHTMLDocument!==void 0;const j=Y_,M=X_,D=J_,L=Q_,U=Z_,$=ek,ie=tk,V=nk;let K=sg,X=null;const ce=nt({},[...tg,...wc,...Sc,...xc,...rg]);let ne=null;const G=nt({},[...ng,...Ac,...og,...Gi]);let ee=Object.seal(xo(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}})),Pe=null,oe=null;const re=Object.seal(xo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let be=!0,de=!0,ot=!1,Se=!0,xe=!1,ae=!0,ve=!1,Ye=!1,ct=!1,Ge=!1,Kt=!1,Je=!1,q=!0,$e=!1;const gt="user-content-";let Oe=!0,te=!1,pe={},We=null;const Pt=nt({},["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 je=null;const Te=nt({},["audio","video","img","source","image","track"]);let Xe=null;const Ue=nt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ft="http://www.w3.org/1998/Math/MathML",St="http://www.w3.org/2000/svg",xt="http://www.w3.org/1999/xhtml";let ze=xt,yt=!1,pt=null;const At=nt({},[ft,St,xt],vc);let Ut=nt({},["mi","mo","mn","ms","mtext"]),ur=nt({},["annotation-xml"]);const Ar=nt({},["title","style","font","a","script"]);let Vt=null;const Po=["application/xhtml+xml","text/html"],Xn="text/html";let Ct=null,Cr=null;const Jn=r.createElement("form"),It=function(F){return F instanceof RegExp||F instanceof Function},Er=function(){let F=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Cr&&Cr===F)return;(!F||typeof F!="object")&&(F={}),F=hr(F),Vt=Po.indexOf(F.PARSER_MEDIA_TYPE)===-1?Xn:F.PARSER_MEDIA_TYPE,Ct=Vt==="application/xhtml+xml"?vc:us,X=Ot(F,"ALLOWED_TAGS")&&cr(F.ALLOWED_TAGS)?nt({},F.ALLOWED_TAGS,Ct):ce,ne=Ot(F,"ALLOWED_ATTR")&&cr(F.ALLOWED_ATTR)?nt({},F.ALLOWED_ATTR,Ct):G,pt=Ot(F,"ALLOWED_NAMESPACES")&&cr(F.ALLOWED_NAMESPACES)?nt({},F.ALLOWED_NAMESPACES,vc):At,Xe=Ot(F,"ADD_URI_SAFE_ATTR")&&cr(F.ADD_URI_SAFE_ATTR)?nt(hr(Ue),F.ADD_URI_SAFE_ATTR,Ct):Ue,je=Ot(F,"ADD_DATA_URI_TAGS")&&cr(F.ADD_DATA_URI_TAGS)?nt(hr(Te),F.ADD_DATA_URI_TAGS,Ct):Te,We=Ot(F,"FORBID_CONTENTS")&&cr(F.FORBID_CONTENTS)?nt({},F.FORBID_CONTENTS,Ct):Pt,Pe=Ot(F,"FORBID_TAGS")&&cr(F.FORBID_TAGS)?nt({},F.FORBID_TAGS,Ct):hr({}),oe=Ot(F,"FORBID_ATTR")&&cr(F.FORBID_ATTR)?nt({},F.FORBID_ATTR,Ct):hr({}),pe=Ot(F,"USE_PROFILES")?F.USE_PROFILES&&typeof F.USE_PROFILES=="object"?hr(F.USE_PROFILES):F.USE_PROFILES:!1,be=F.ALLOW_ARIA_ATTR!==!1,de=F.ALLOW_DATA_ATTR!==!1,ot=F.ALLOW_UNKNOWN_PROTOCOLS||!1,Se=F.ALLOW_SELF_CLOSE_IN_ATTR!==!1,xe=F.SAFE_FOR_TEMPLATES||!1,ae=F.SAFE_FOR_XML!==!1,ve=F.WHOLE_DOCUMENT||!1,Ge=F.RETURN_DOM||!1,Kt=F.RETURN_DOM_FRAGMENT||!1,Je=F.RETURN_TRUSTED_TYPE||!1,ct=F.FORCE_BODY||!1,q=F.SANITIZE_DOM!==!1,$e=F.SANITIZE_NAMED_PROPS||!1,Oe=F.KEEP_CONTENT!==!1,te=F.IN_PLACE||!1,K=G_(F.ALLOWED_URI_REGEXP)?F.ALLOWED_URI_REGEXP:sg,ze=typeof F.NAMESPACE=="string"?F.NAMESPACE:xt,Ut=Ot(F,"MATHML_TEXT_INTEGRATION_POINTS")&&F.MATHML_TEXT_INTEGRATION_POINTS&&typeof F.MATHML_TEXT_INTEGRATION_POINTS=="object"?hr(F.MATHML_TEXT_INTEGRATION_POINTS):nt({},["mi","mo","mn","ms","mtext"]),ur=Ot(F,"HTML_INTEGRATION_POINTS")&&F.HTML_INTEGRATION_POINTS&&typeof F.HTML_INTEGRATION_POINTS=="object"?hr(F.HTML_INTEGRATION_POINTS):nt({},["annotation-xml"]);const Y=Ot(F,"CUSTOM_ELEMENT_HANDLING")&&F.CUSTOM_ELEMENT_HANDLING&&typeof F.CUSTOM_ELEMENT_HANDLING=="object"?hr(F.CUSTOM_ELEMENT_HANDLING):xo(null);if(ee=xo(null),Ot(Y,"tagNameCheck")&&It(Y.tagNameCheck)&&(ee.tagNameCheck=Y.tagNameCheck),Ot(Y,"attributeNameCheck")&&It(Y.attributeNameCheck)&&(ee.attributeNameCheck=Y.attributeNameCheck),Ot(Y,"allowCustomizedBuiltInElements")&&typeof Y.allowCustomizedBuiltInElements=="boolean"&&(ee.allowCustomizedBuiltInElements=Y.allowCustomizedBuiltInElements),xe&&(de=!1),Kt&&(Ge=!0),pe&&(X=nt({},rg),ne=xo(null),pe.html===!0&&(nt(X,tg),nt(ne,ng)),pe.svg===!0&&(nt(X,wc),nt(ne,Ac),nt(ne,Gi)),pe.svgFilters===!0&&(nt(X,Sc),nt(ne,Ac),nt(ne,Gi)),pe.mathMl===!0&&(nt(X,xc),nt(ne,og),nt(ne,Gi))),re.tagCheck=null,re.attributeCheck=null,Ot(F,"ADD_TAGS")&&(typeof F.ADD_TAGS=="function"?re.tagCheck=F.ADD_TAGS:cr(F.ADD_TAGS)&&(X===ce&&(X=hr(X)),nt(X,F.ADD_TAGS,Ct))),Ot(F,"ADD_ATTR")&&(typeof F.ADD_ATTR=="function"?re.attributeCheck=F.ADD_ATTR:cr(F.ADD_ATTR)&&(ne===G&&(ne=hr(ne)),nt(ne,F.ADD_ATTR,Ct))),Ot(F,"ADD_URI_SAFE_ATTR")&&cr(F.ADD_URI_SAFE_ATTR)&&nt(Xe,F.ADD_URI_SAFE_ATTR,Ct),Ot(F,"FORBID_CONTENTS")&&cr(F.FORBID_CONTENTS)&&(We===Pt&&(We=hr(We)),nt(We,F.FORBID_CONTENTS,Ct)),Ot(F,"ADD_FORBID_CONTENTS")&&cr(F.ADD_FORBID_CONTENTS)&&(We===Pt&&(We=hr(We)),nt(We,F.ADD_FORBID_CONTENTS,Ct)),Oe&&(X["#text"]=!0),ve&&nt(X,["html","head","body"]),X.table&&(nt(X,["tbody"]),delete Pe.tbody),F.TRUSTED_TYPES_POLICY){if(typeof F.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ri('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof F.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ri('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');C=F.TRUSTED_TYPES_POLICY,N=C.createHTML("")}else C===void 0&&(C=sk(g,o)),C!==null&&typeof N=="string"&&(N=C.createHTML(""));lr&&lr(F),Cr=F},er=nt({},[...wc,...Sc,...K_]),sr=nt({},[...xc,...q_]),fn=function(F){let Y=E(F);(!Y||!Y.tagName)&&(Y={namespaceURI:ze,tagName:"template"});const he=us(F.tagName),st=us(Y.tagName);return pt[F.namespaceURI]?F.namespaceURI===St?Y.namespaceURI===xt?he==="svg":Y.namespaceURI===ft?he==="svg"&&(st==="annotation-xml"||Ut[st]):!!er[he]:F.namespaceURI===ft?Y.namespaceURI===xt?he==="math":Y.namespaceURI===St?he==="math"&&ur[st]:!!sr[he]:F.namespaceURI===xt?Y.namespaceURI===St&&!ur[st]||Y.namespaceURI===ft&&!Ut[st]?!1:!sr[he]&&(Ar[he]||!er[he]):!!(Vt==="application/xhtml+xml"&&pt[F.namespaceURI]):!1},yr=function(F){Co(t.removed,{element:F});try{E(F).removeChild(F)}catch{v(F)}},kt=function(F,Y){try{Co(t.removed,{attribute:Y.getAttributeNode(F),from:Y})}catch{Co(t.removed,{attribute:null,from:Y})}if(Y.removeAttribute(F),F==="is")if(Ge||Kt)try{yr(Y)}catch{}else try{Y.setAttribute(F,"")}catch{}},Ss=function(F){let Y=null,he=null;if(ct)F="<remove></remove>"+F;else{const wt=Jh(F,/^[\r\n\t ]+/);he=wt&&wt[0]}Vt==="application/xhtml+xml"&&ze===xt&&(F='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+F+"</body></html>");const st=C?C.createHTML(F):F;if(ze===xt)try{Y=new m().parseFromString(st,Vt)}catch{}if(!Y||!Y.documentElement){Y=A.createDocument(ze,"template",null);try{Y.documentElement.innerHTML=yt?N:st}catch{}}const Tt=Y.body||Y.documentElement;return F&&he&&Tt.insertBefore(r.createTextNode(he),Tt.childNodes[0]||null),ze===xt?W.call(Y,ve?"html":"body")[0]:ve?Y.documentElement:Tt},Nr=function(F){return I.call(F.ownerDocument||F,F,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Dr=function(F){F.normalize();const Y=I.call(F.ownerDocument||F,F,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null);let he=Y.nextNode();for(;he;){let st=he.data;Ao([j,M,D],Tt=>{st=Eo(st,Tt," ")}),he.data=st,he=Y.nextNode()}},_r=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")},br=function(F){if(!P||typeof F!="object"||F===null)return!1;try{return typeof P(F)=="number"}catch{return!1}};function qt(Ee,F,Y){Ao(Ee,he=>{he.call(t,F,Y,Cr)})}const tr=function(F){let Y=null;if(qt(O.beforeSanitizeElements,F,null),_r(F))return yr(F),!0;const he=Ct(F.nodeName);if(qt(O.uponSanitizeElement,F,{tagName:he,allowedTags:X}),ae&&F.hasChildNodes()&&!br(F.firstElementChild)&&Zt(/<[/\w!]/g,F.innerHTML)&&Zt(/<[/\w!]/g,F.textContent)||ae&&F.namespaceURI===xt&&he==="style"&&br(F.firstElementChild)||F.nodeType===No.progressingInstruction||ae&&F.nodeType===No.comment&&Zt(/<[/\w]/g,F.data))return yr(F),!0;if(Pe[he]||!(re.tagCheck instanceof Function&&re.tagCheck(he))&&!X[he]){if(!Pe[he]&&Zi(he)&&(ee.tagNameCheck instanceof RegExp&&Zt(ee.tagNameCheck,he)||ee.tagNameCheck instanceof Function&&ee.tagNameCheck(he)))return!1;if(Oe&&!We[he]){const st=E(F)||F.parentNode,Tt=x(F)||F.childNodes;if(Tt&&st){const wt=Tt.length;for(let Mt=wt-1;Mt>=0;--Mt){const $r=y(Tt[Mt],!0);st.insertBefore($r,w(F))}}}return yr(F),!0}return F instanceof d&&!fn(F)||(he==="noscript"||he==="noembed"||he==="noframes")&&Zt(/<\/no(script|embed|frames)/i,F.innerHTML)?(yr(F),!0):(xe&&F.nodeType===No.text&&(Y=F.textContent,Ao([j,M,D],st=>{Y=Eo(Y,st," ")}),F.textContent!==Y&&(Co(t.removed,{element:F.cloneNode()}),F.textContent=Y)),qt(O.afterSanitizeElements,F,null),!1)},Br=function(F,Y,he){if(oe[Y]||q&&(Y==="id"||Y==="name")&&(he in r||he in Jn))return!1;const st=ne[Y]||re.attributeCheck instanceof Function&&re.attributeCheck(Y,F);if(!(de&&!oe[Y]&&Zt(L,Y))){if(!(be&&Zt(U,Y))){if(!st||oe[Y]){if(!(Zi(F)&&(ee.tagNameCheck instanceof RegExp&&Zt(ee.tagNameCheck,F)||ee.tagNameCheck instanceof Function&&ee.tagNameCheck(F))&&(ee.attributeNameCheck instanceof RegExp&&Zt(ee.attributeNameCheck,Y)||ee.attributeNameCheck instanceof Function&&ee.attributeNameCheck(Y,F))||Y==="is"&&ee.allowCustomizedBuiltInElements&&(ee.tagNameCheck instanceof RegExp&&Zt(ee.tagNameCheck,he)||ee.tagNameCheck instanceof Function&&ee.tagNameCheck(he))))return!1}else if(!Xe[Y]){if(!Zt(K,Eo(he,ie,""))){if(!((Y==="src"||Y==="xlink:href"||Y==="href")&&F!=="script"&&Qh(he,"data:")===0&&je[F])){if(!(ot&&!Zt($,Eo(he,ie,"")))){if(he)return!1}}}}}}return!0},Qi=nt({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Zi=function(F){return!Qi[us(F)]&&Zt(V,F)},ea=function(F){qt(O.beforeSanitizeAttributes,F,null);const Y=F.attributes;if(!Y||_r(F))return;const he={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ne,forceKeepAttr:void 0};let st=Y.length;for(;st--;){const Tt=Y[st],wt=Tt.name,Mt=Tt.namespaceURI,$r=Tt.value,ir=Ct(wt),Oo=$r;let Lt=wt==="value"?Oo:z_(Oo);if(he.attrName=ir,he.attrValue=Lt,he.keepAttr=!0,he.forceKeepAttr=void 0,qt(O.uponSanitizeAttribute,F,he),Lt=he.attrValue,$e&&(ir==="id"||ir==="name")&&Qh(Lt,gt)!==0&&(kt(wt,F),Lt=gt+Lt),ae&&Zt(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Lt)){kt(wt,F);continue}if(ir==="attributename"&&Jh(Lt,"href")){kt(wt,F);continue}if(he.forceKeepAttr)continue;if(!he.keepAttr){kt(wt,F);continue}if(!Se&&Zt(/\/>/i,Lt)){kt(wt,F);continue}xe&&Ao([j,M,D],et=>{Lt=Eo(Lt,et," ")});const ta=Ct(F.nodeName);if(!Br(ta,ir,Lt)){kt(wt,F);continue}if(C&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!Mt)switch(g.getAttributeType(ta,ir)){case"TrustedHTML":{Lt=C.createHTML(Lt);break}case"TrustedScriptURL":{Lt=C.createScriptURL(Lt);break}}if(Lt!==Oo)try{Mt?F.setAttributeNS(Mt,wt,Lt):F.setAttribute(wt,Lt),_r(F)?yr(F):Xh(t.removed)}catch{kt(wt,F)}}qt(O.afterSanitizeAttributes,F,null)},xs=function(F){let Y=null;const he=Nr(F);for(qt(O.beforeSanitizeShadowDOM,F,null);Y=he.nextNode();)qt(O.uponSanitizeShadowNode,Y,null),tr(Y),ea(Y),Y.content instanceof s&&xs(Y.content);qt(O.afterSanitizeShadowDOM,F,null)},kr=function(F){if(F.nodeType===No.element&&F.shadowRoot instanceof s){const st=F.shadowRoot;kr(st),xs(st)}const Y=F.childNodes;if(!Y)return;const he=[];Ao(Y,st=>{Co(he,st)});for(const st of he)kr(st)};return t.sanitize=function(Ee){let F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},Y=null,he=null,st=null,Tt=null;if(yt=!Ee,yt&&(Ee="<!-->"),typeof Ee!="string"&&!br(Ee)&&(Ee=R_(Ee),typeof Ee!="string"))throw Ri("dirty is not a string, aborting");if(!t.isSupported)return Ee;if(Ye||Er(F),t.removed=[],typeof Ee=="string"&&(te=!1),te){const $r=Ee.nodeName;if(typeof $r=="string"){const ir=Ct($r);if(!X[ir]||Pe[ir])throw Ri("root node is forbidden and cannot be sanitized in-place")}kr(Ee)}else if(br(Ee))Y=Ss("<!---->"),he=Y.ownerDocument.importNode(Ee,!0),he.nodeType===No.element&&he.nodeName==="BODY"||he.nodeName==="HTML"?Y=he:Y.appendChild(he),kr(he);else{if(!Ge&&!xe&&!ve&&Ee.indexOf("<")===-1)return C&&Je?C.createHTML(Ee):Ee;if(Y=Ss(Ee),!Y)return Ge?null:Je?N:""}Y&&ct&&yr(Y.firstChild);const wt=Nr(te?Ee:Y);for(;st=wt.nextNode();)tr(st),ea(st),st.content instanceof s&&xs(st.content);if(te)return xe&&Dr(Ee),Ee;if(Ge){if(xe&&Dr(Y),Kt)for(Tt=T.call(Y.ownerDocument);Y.firstChild;)Tt.appendChild(Y.firstChild);else Tt=Y;return(ne.shadowroot||ne.shadowrootmode)&&(Tt=J.call(n,Tt,!0)),Tt}let Mt=ve?Y.outerHTML:Y.innerHTML;return ve&&X["!doctype"]&&Y.ownerDocument&&Y.ownerDocument.doctype&&Y.ownerDocument.doctype.name&&Zt(rk,Y.ownerDocument.doctype.name)&&(Mt="<!DOCTYPE "+Y.ownerDocument.doctype.name+`>
|
|
52
|
+
`+Mt),xe&&Ao([j,M,D],$r=>{Mt=Eo(Mt,$r," ")}),C&&Je?C.createHTML(Mt):Mt},t.setConfig=function(){let Ee=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Er(Ee),Ye=!0},t.clearConfig=function(){Cr=null,Ye=!1},t.isValidAttribute=function(Ee,F,Y){Cr||Er({});const he=Ct(Ee),st=Ct(F);return Br(he,st,Y)},t.addHook=function(Ee,F){typeof F=="function"&&Co(O[Ee],F)},t.removeHook=function(Ee,F){if(F!==void 0){const Y=$_(O[Ee],F);return Y===-1?void 0:j_(O[Ee],Y,1)[0]}return Xh(O[Ee])},t.removeHooks=function(Ee){O[Ee]=[]},t.removeAllHooks=function(){O=ig()},t}var ik=ag();const ak=["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"],lk=["href","target","rel","src","alt","title","class","style","colspan","rowspan"];function ck(e){return e?ik.sanitize(e,{ALLOWED_TAGS:[...ak],ALLOWED_ATTR:[...lk],ALLOW_DATA_ATTR:!1}):""}function dk(e,t,r=!1){return e.includes("{labelapi:")?e.replace(/\{labelapi:([^}]+)\}/g,(n,o)=>{const s=o.trim();if(s===""||t==null)return r?"":n;const i=Qe(t,s);return i==null?r?"":n:String(i)}):e}function uk(e){return e&&e.replace(/\{api:[^}]*\}/gi,"").replace(/\{labelapi:[^}]*\}/gi,"").replace(/\{resp:[^}]*\}/gi,"").replace(/\{(?:ctx:|@)\w+\}/gi,"").replace(/\{documentId\}/gi,"").replace(/\{(\w+)\}/g,"")}const lg={sm:"text-sm",md:"text-base",lg:"text-lg"},cg={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"},dg={normal:"font-normal",medium:"font-medium",bold:"font-bold"},Ki={left:"text-left",center:"text-center",right:"text-right",justify:"text-justify"};function qn(e){return e.properties??{}}function fk(e){const t=qn(e);return t.textContent!==void 0?t.textContent:e.label??""}function pk(e){return qn(e).textContent===void 0||e.appearance?.hideLabel?!1:!!e.label?.trim()}function mk(e){return e?.contentLayout==="paragraph"?"paragraph":"single"}function Cc(e,t={}){const{formValues:r={},urlParams:n={},submissionContext:o,buttonResponses:s,prepopulateResponse:i,labelApiResponse:a}=t,d=rn(e,r,n,o,s,i),u=dk(d,a,!0);return uk(u)}const hk=/\{api:[^}]+\}/,gk=/\{labelapi:[^}]+\}/;function Ec(e){return hk.test(e)}function Nc(e){return gk.test(e)}function yk(e){const t=e.captionTemplate??"",r=e.descriptionTemplate??"",n=Ec(e.bodyTemplate)||Ec(t)||Ec(r),o=Nc(e.bodyTemplate)||Nc(t)||Nc(r);return!!(n&&e.prepopulateLoading||o&&e.labelApiConfigPresent&&(e.labelApiLoading||e.labelApiResponse===void 0&&e.labelApiError==null))}function ug(e,t){const r=t??qn(e),n=r.variant??"body",o=e.appearance?.size??"md",s=lg[o]??lg.md,i=r.fontWeight??"medium";return n!=="body"?B("m-0 text-foreground",cg[n]??cg.h3,r.fontWeight&&dg[r.fontWeight],r.italic&&"italic",r.underline&&"underline",r.textAlign&&Ki[r.textAlign]):B("m-0 text-foreground",s,dg[i],r.italic&&"italic",r.underline&&"underline",r.textAlign&&Ki[r.textAlign])}function bk(e,t){const r=(t??qn(e)).variant??"body";return r==="body"?"p":r}function _c(e){const t=[];let r=0,n="";const o=()=>{n&&(t.push({type:"text",value:n}),n="")},s=(i,a,d)=>{if(!e.startsWith(i,r))return!1;const u=e.indexOf(a,r+i.length);if(u===-1)return!1;o();const l=e.slice(r+i.length,u);return t.push({type:d,children:_c(l)}),r=u+a.length,!0};for(;r<e.length;){if(e[r]==="\\"&&r+1<e.length){n+=e[r+1],r+=2;continue}s("**","**","bold")||s("__","__","underline")||s("*","*","italic")||s("_","_","italic")||(n+=e[r],r+=1)}return o(),t}function vk(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function fg(e){return e.map(t=>{if(t.type==="text")return vk(t.value);const r=fg(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 wk(e){return e?fg(_c(e)):""}function Sk(e,t){return e?t==="markdown-lite"?wk(e):e:""}function pg(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 s=pg(r.children,o);return r.type==="bold"?S.createElement("strong",{key:o,className:"font-bold"},s):r.type==="italic"?S.createElement("em",{key:o,className:"italic"},s):S.createElement("u",{key:o,className:"underline"},s)})}function mg(e,t){if(!e)return null;if(t!=="markdown-lite")return e;const r=_c(e);return r.length===1&&r[0]?.type==="text"?r[0].value:pg(r,"tl")}const xk="text-label-html prose prose-sm max-w-none [&_p]:m-0 [&_p+p]:mt-2 [&_ul]:my-1 [&_ol]:my-1";function hg(e,t){if(!e)return null;const{field:r,asDescription:n=!1}=t,o=t.textProps??qn(r),s=t.contentLayout??mk(o),i=o.inlineFormat??"none";if(s==="paragraph"){const d=ck(Sk(e,i));if(!d)return null;const u=n?B("m-0 text-sm",o.descriptionMuted!==!1?"text-muted-foreground":"text-foreground",o.textAlign&&Ki[o.textAlign]):B(ug(r,o),xk);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&&Ki[o.textAlign])},mg(e,i));const a=bk(r,o);return S.createElement(a,{className:ug(r,o)},mg(e,i))}function Ak(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 Ck(e,t={}){const{formValues:r={},urlParams:n={},submissionContext:o}=t,s=f=>rn(f,r,n,o),i=(e.labelApiMethod??"GET").toUpperCase();let a=cn(s(e.labelApiEndpoint));const d=e.labelApiQueryParams??[];if(d.length){const f=new URLSearchParams;d.forEach(({key:m,value:g})=>{m.trim()&&f.append(m,s(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]=s(p))});let l;i==="POST"&&(e.labelApiBodyFields??[]).length&&(l={},e.labelApiBodyFields.forEach(({key:f,value:p})=>{f.trim()&&(l[f]=s(p))}));try{return i==="POST"?(await dn.post(a,l??{},{headers:Object.keys(u).length?u:void 0})).data:(await dn.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 Ek=({field:e,className:t,formValues:r,urlParams:n,submissionContext:o,buttonResponses:s,prepopulateResponse:i,prepopulateLoading:a=!1})=>{const d=qn(e),u=S.useMemo(()=>Ak(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]),v=S.useCallback(async()=>{if(!u){f(void 0),h(null),m(!1);return}m(!0),h(null);try{const W=await Ck(u,{formValues:r??{},urlParams:n??{},submissionContext:o});f(W)}catch(W){f(void 0),h(W instanceof Error?W.message:"Failed to load label API")}finally{m(!1)}},[u,r,n,o]);S.useEffect(()=>{y&&v()},[y,v]);const w=d.textAlign==="center"?"items-center":d.textAlign==="right"?"items-end":d.textAlign==="justify"?"items-stretch":"items-start",x=fk(e),E=pk(e),P=E&&e.label?e.label:"",C=e.description??"",N=yk({bodyTemplate:x,captionTemplate:P,descriptionTemplate:C,prepopulateLoading:a,labelApiConfigPresent:u!=null,labelApiLoading:p,labelApiResponse:l,labelApiError:g}),_={formValues:r??{},urlParams:n??{},submissionContext:o,buttonResponses:s,prepopulateResponse:i,labelApiResponse:l},A=x?Cc(x,_):"",I=E&&e.label?Cc(e.label,_):"",T=C?Cc(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",w,t),children:N?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,I?c.jsx("div",{className:"text-sm font-medium text-foreground mb-1 w-full",children:I}):null,A?hg(A,{field:e,textProps:d}):null,T?hg(T,{field:e,textProps:d,asDescription:!0}):null]})})},kc=({legend:e,children:t,className:r,collapsible:n=!1,defaultCollapsed:o=!1,headerActions:s,onCollapsedChange:i})=>{const[a,d]=S.useState(o),u=S.useId(),l=f=>{f.stopPropagation(),n&&d(p=>{const m=!p;return i?.(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(Zd,{className:"h-4 w-4"}):c.jsx(Wo,{className:"h-4 w-4"})}),c.jsx("span",{className:"truncate",children:e})]}),s!=null?c.jsx("div",{className:"shrink-0",children:s}):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&&s!=null?c.jsx("div",{className:"flex justify-end",children:s}):null,t]})]})},un=({field:e,value:t,error:r,onChange:n,onBlur:o,disabled:s,readOnly:i,isRequired:a,className:d,formValues:u={},submissionContext:l,onSubmit:f,onReset:p,onCancel:m,isSubmitting:g,bffSubmitApi:h,onBffSubmitResult:y,extraSubmitPayload:v,buttonResponses:w,onButtonApiResponse:x,onValidateForm:E,getValidationErrors:P,allFields:C,onSubmittingChange:N,onAddMore:_,scopedFormValues:A,scopedFieldNameMap:I,excludedOptionValues:T,prepopulateMappedFieldNames:W,fieldValueKey:J,hideTableRowControls:O=!1,urlParams:j={},prepopulateResponse:M=null,prepopulateLoading:D=!1,formSections:L,submitPayload:U})=>{switch(e.type){case"divider":return c.jsx(A_,{field:e,className:d});case"header":return c.jsx(E_,{field:e,className:d});case"sectionHeading":return c.jsx(k_,{field:e,className:d});case"spacer":return c.jsx(T_,{field:e,className:d});case"textLabel":return c.jsx(Ek,{field:e,className:d,formValues:u,urlParams:j,submissionContext:l,buttonResponses:w,prepopulateResponse:M??void 0,prepopulateLoading:D});case"status":return c.jsx(m_,{field:e,value:t??null,error:r,disabled:s,isRequired:a,className:d,formValues:u,submissionContext:l,extraSubmitPayload:v,prepopulateResponse:M})}switch(e.type){case"text":case"password":case"url":return c.jsx(Da,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"number":return c.jsx(Xd,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"email":return c.jsx(su,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"phone":case"aadhaar":return c.jsx(iu,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"textarea":case"richtext":return c.jsx(au,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"select":{const $=J??e.name??e.key??e.id,ie=!!($&&W?.has($));return c.jsx(kp,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d,formValues:u,submissionContext:l,excludedOptionValues:T,isPrepopulateTarget:ie})}case"multiselect":{const $=Array.isArray(t)?t:t!=null&&t!==""?[String(t)]:[];return c.jsx(vm,{field:e,value:$,onChange:ie=>n(ie),onBlur:o,error:r,disabled:s,isRequired:a,className:d,formValues:u,submissionContext:l,excludedOptionValues:T})}case"asyncsearch":return c.jsx(Xp,{field:e,value:t,onChange:$=>n($),onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d,formValues:u,submissionContext:l});case"checkbox":case"terms":return c.jsx(wm,{field:e,value:t||!1,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d});case"toggle":return c.jsx(tE,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d});case"radio":case"checkboxgroup":return c.jsx(Gm,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d,excludedOptionValues:T});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(g_,{field:e,value:$,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d,submissionContext:l})}case"date":case"time":case"datetime":case"daterange":return c.jsx(Km,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"file":return c.jsx(NE,{field:e,value:t,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d,buttonResponses:w});case"camera":return c.jsx(oN,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d});case"photoChoice":return c.jsx(sN,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d,buttonResponses:w});case"signature":return c.jsx(QN,{field:e,value:t||null,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"rating":return c.jsx(FN,{field:e,value:t||0,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"slider":return c.jsx(JN,{field:e,value:t||0,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"table":return c.jsx(ZN,{field:e,value:t||[],onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d,hideRowControls:O,formValues:u,submissionContext:l});case"billingGrid":return c.jsx(p_,{field:e,value:t||{rows:[]},onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"button":return c.jsx(wN,{field:e,value:t,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d,onSubmit:f,onReset:p,onCancel:m,isSubmitting:g,formValues:u,submissionContext:l,buttonResponses:w,onButtonApiResponse:x,bffSubmitApi:h,onBffSubmitResult:y,extraSubmitPayload:v,onValidateForm:E,getValidationErrors:P,allFields:C,onSubmittingChange:N,scopedFormValues:A,scopedFieldNameMap:I,prepopulateResponse:M,formSections:L,submitPayload:U});case"editButton":return c.jsx(SN,{field:e,disabled:s,readOnly:i,isRequired:a,className:d,buttonResponses:w,onButtonApiResponse:x});case"addmore":return c.jsx(xN,{field:e,error:r,disabled:s,readOnly:i,isRequired:a,className:d,onAddMore:()=>_?.(e)});case"customizeSections":return c.jsx(TN,{field:e,error:r,disabled:s,readOnly:i,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]})})}},Nk=({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((s,i)=>{const a=r.has(i),d=t===i,u=n&&(a||i===t+1||i<=t);return c.jsxs("li",{className:B("relative",i!==e.length-1&&"pr-8 sm:pr-20 flex-1"),children:[i!==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?.(i),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(Vs,{className:"h-4 w-4"}):c.jsx("span",{children:i+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:s.name}),s.description&&c.jsx("p",{className:"text-xs text-muted-foreground hidden sm:block",children:s.description})]})]},s.id)})})})});function ps(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 gg(e){return Array.isArray(e)?e.map(ps):[]}function _k(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=ps(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 kk{basePath="/api/form-builder/forms";async getForRendering(t,r){if(!Tn())throw new Error("Client ID is required");const o=r!==void 0?`${this.basePath}/${t}/render?version=${r}`:`${this.basePath}/${t}/render`,s=await dn.get(o),i=s.data?.data||s.data,a=i?.BFF_submit_api||i?.bff_submit_api||s.data?.BFF_submit_api||s.data?.bff_submit_api,d=i.form||i;if(!d.moduleId&&!i.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??i.form?.isDefault??!1)&&!d.tenantId&&!i.form?.tenantId)throw new Error(`Form response missing required field: tenantId. Form ID: ${t}. Please ensure the backend returns tenantId for non-default forms.`);i.form?.moduleId&&!d.moduleId&&(d.moduleId=i.form.moduleId),i.form?.tenantId&&!d.tenantId&&(d.tenantId=i.form.tenantId),i.form?.isDefault!==void 0&&d.isDefault===void 0&&(d.isDefault=i.form.isDefault);const l=_k(d);i.form?.moduleId&&(typeof i.form.moduleId=="object"&&i.form.moduleId._id?l.moduleId=ps(i.form.moduleId):typeof i.form.moduleId=="string"&&(l.moduleId=i.form.moduleId));const f=gg(i.fields||[]),p=i.layout?ps(i.layout):null,m=gg(i.rules||[]),g=i.module?ps(i.module):void 0,h=i.clientMapping||i.clientOverrides;return{form:l,fields:f,layout:p,rules:m,module:g,clientMapping:h,clientOverrides:h,BFF_submit_api:a||void 0}}}const Tk=new kk;function Pn({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"},s=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:s}):s}const Fk={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."},Pk=300;function Ok(){return{...Fk}}function Ik(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 i={};return r!=null&&r!==""&&(i.visibleToUserType=r),n!=null&&n!==""&&(i.visibleToUserRole=n),o.length>0&&(i.visibleToUserIds=o),i}function Mk(e){const t=Ok();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:hN(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 ms(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=jd(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 V=l.validationRules;if(V.required===!0&&!g.some(K=>K.type==="required")&&g.push({type:"required",message:"This field is required"}),V.allowLetters!==void 0&&g.push({type:"allowLetters",value:V.allowLetters}),V.allowNumbers!==void 0&&g.push({type:"allowNumbers",value:V.allowNumbers}),V.allowSpecialChars!==void 0&&g.push({type:"allowSpecialChars",value:V.allowSpecialChars}),V.minLetters!==void 0&&typeof V.minLetters=="number"&&g.push({type:"minLetters",value:V.minLetters}),V.maxLetters!==void 0&&typeof V.maxLetters=="number"&&g.push({type:"maxLetters",value:V.maxLetters}),V.minNumbers!==void 0&&typeof V.minNumbers=="number"&&g.push({type:"minNumbers",value:V.minNumbers}),V.maxNumbers!==void 0&&typeof V.maxNumbers=="number"&&g.push({type:"maxNumbers",value:V.maxNumbers}),V.minSpecialChars!==void 0&&typeof V.minSpecialChars=="number"&&g.push({type:"minSpecialChars",value:V.minSpecialChars}),V.maxSpecialChars!==void 0&&typeof V.maxSpecialChars=="number"&&g.push({type:"maxSpecialChars",value:V.maxSpecialChars}),V.fileSize!==void 0&&typeof V.fileSize=="number"){const K=V.fileSize/1048576;g.push({type:"fileSize",value:V.fileSize,message:`File size must be less than ${K.toFixed(2)} MB`})}if(V.fileType!==void 0){const K=Array.isArray(V.fileType)?V.fileType:typeof V.fileType=="string"?V.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(V=>{const K=typeof V.targetFieldId=="object"?V.targetFieldId.id||V.targetFieldId._id:V.targetFieldId;return!!(K===l.id||K===l._id||K&&l.fieldKey&&K===l.fieldKey)}).forEach(V=>{try{const K=JSON.parse(V.conditionExpression);!K.id&&V.id&&(K.id=V.id);const X=typeof V.targetFieldId=="object"?V.targetFieldId?.id||V.targetFieldId?._id:V.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)&&V.action&&(K.then=[{action:V.action,...X&&{target:X}}]),K.then&&Array.isArray(K.then)&&X&&(K.then=K.then.map(ne=>!ne.target&&X?{...ne,target:X}:ne));const ce=V.conditionExpression||JSON.stringify(K);if(y.has(ce))return;y.add(ce),h.push(K)}catch{}});const w=l.disabled===!0||p?.disabled===!0||!1;let x=l.readOnly===!0||p?.readOnly===!0||!1;const E=l.hidden===!0||p?.hidden===!0||!1;(p?.valueSource==="calculated"||p?.formula)&&(x=!0);const{disabled:P,readOnly:C,hidden:N,..._}=p,A={};_.hideLabel!==void 0&&(A.hideLabel=_.hideLabel),_.labelPosition!==void 0&&(A.labelPlacement=_.labelPosition),_.size!==void 0&&(A.size=_.size),_.customClass!==void 0&&(A.className=_.customClass);const{labelPosition:I,size:T,customClass:W,visibility:J,...O}=_,j=Object.keys(O).length>0?O:void 0,M=Object.keys(A).length>0?A:void 0,D=l.visibility??p?.visibility??J;let L=Ik(D);if(D&&!L){const V=D;(V.visibleToUserType!=null||V.visibleToUserRole!=null||Array.isArray(V.visibleToUserTypes)&&V.visibleToUserTypes.length>0||Array.isArray(V.visibleToUserRoles)&&V.visibleToUserRoles.length>0||Array.isArray(V.visibleToUserIds)&&V.visibleToUserIds.length>0||Array.isArray(V.hiddenFromUserIds)&&V.hiddenFromUserIds.length>0)&&(L={visibleToUserType:V.visibleToUserType??(Array.isArray(V.visibleToUserTypes)?V.visibleToUserTypes[0]:void 0),visibleToUserRole:V.visibleToUserRole??(Array.isArray(V.visibleToUserRoles)?V.visibleToUserRoles[0]:void 0),visibleToUserIds:V.visibleToUserIds,hiddenFromUserIds:V.hiddenFromUserIds})}const U=p?.columnName,ie=!!l.parentFieldId&&typeof U=="string"?U: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:M,validation:g.length>0?g:void 0,conditions:h.length>0?h:void 0,properties:j,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:w,readOnly:x,hidden:E}});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 s=t;for(let l=0;l<o.length;l++){const f=s[l]?.parentFieldId;if(f){const p=o.find(g=>g.id===f||g.type==="table"&&g.name===f||g.type==="table"&&s[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 i=o.filter((l,f)=>!s[f]?.parentFieldId);for(const l of i)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=Mk(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=Ns(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:i,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 Lk=3;function _o(e){if(typeof e=="number"&&!Number.isNaN(e))return e}function ko(e,t){const r=e&&typeof e=="object"&&!Array.isArray(e)?e:void 0;return _o(r?.cellSlot)??_o(r?.stackSlot)??_o(r?.cellSlotIndex)??_o(r?.slotIndex)??_o(t?.cellSlotIndex)??_o(t?.stackSlot)}function hs(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 qi(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 Tc(e){return[...e].sort((t,r)=>{const n=ko(t.position),o=ko(r.position);return typeof n=="number"&&typeof o=="number"&&n!==o?n-o:String(t.id).localeCompare(String(r.id))})}function gs(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,Do(o)),n=Math.max(n,bd(o,t));return{rowSpan:r,columnSpan:n}}function yg(e){const t=Tc(e);for(const r of t){const n=hs(r.position);if(n)return n}return t.length>=2?"row":"stack"}function bg(e){return Tc(e).slice(0,Lk)}function Dk(e,t){const r=new Map;for(const n of e){if(!t(n)||typeof n.position?.order!="number")continue;const o=qi(n),s=r.get(o)??[];s.push(n),r.set(o,s)}return Array.from(r.values()).map(n=>bg(n))}function vg(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 s=new Map;for(const a of o){const d=qi(a),u=s.get(d)??[];u.push(a),s.set(d,u)}const i=[...s.values()][0]??[];return bg(i)}function Bk(e,t,r,n){const o=r[0],s=o.position?.order,i=o.position?.column??1;if(typeof s!="number")return!1;const{rowSpan:a,columnSpan:d}=gs(r,n),u=e===s&&t===i-1,l=e>=s&&e<s+a,f=t>=i-1&&t<i-1+d;return l&&f&&!u}function $k(e,t,r){const n=new Set(r??[]);for(const o of e){const s=o[0]?.position?.order??0,{rowSpan:i}=gs(o,t);for(let a=s;a<s+i;a++)n.add(a)}return n}function jk(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 zk(e,t,r){const n=r.get(e);if(n===void 0)return;let o=0;for(let s=e;s<e+t&&r.has(s);s++)o++;return`${n+1} / span ${Math.max(o,1)}`}function gr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function To(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(r=>To(r));if(!gr(e))return e;const t={};for(const[r,n]of Object.entries(e))t[r]=To(n);return t}function wg(e,...t){const r={...e};for(const n of t)if(!(!n||!gr(n)))for(const[o,s]of Object.entries(n)){const i=r[o];gr(s)&&gr(i)?r[o]=wg(i,s):r[o]=s}return r}function Yn(e){return gr(e)?e:{}}function ys(e){if(e==null)return{};if(typeof e=="string"){const t=e.trim();if(!t)return{};try{const r=JSON.parse(t);return gr(r)?To(r):{}}catch{return{}}}return gr(e)?To(e):{}}function Sg(e){const t=e.apidata;return gr(t)&&Object.keys(t).length>0}function Uk(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||Sg(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 xg=["hideLabel","contentAlign","contentVerticalAlign","labelPlacement","widthPercent","widthMode","className","verticalAlign","horizontalAlign","cellAlign","cellJustify","size","variant","minWidth","minHeight"];function Vk(e,t){const r=e.appearance,n=gr(r)&&Object.keys(r).length>0?To(r):{},o=Yn(t.appearance),s={...n};for(const[i,a]of Object.entries(o))i!=="heightPercent"&&s[i]===void 0&&(s[i]=To(a));for(const i of xg)s[i]===void 0&&t[i]!==void 0&&(s[i]=t[i]);return delete s.heightPercent,Object.keys(s).length>0?s:void 0}function Hk(e,t){const r=Yn(e.position),n=ys(e.metadata),o=Yn(e.layout),s=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,i=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:s,column:i,columnSpan:a,rowSpan:d},l=r.cellGroupId??o.cellGroupId,f=ko(r,{cellSlotIndex:e.cellSlotIndex??o.cellSlotIndex,stackSlot:n.stackSlot??o.stackSlot}),p=hs(r)??hs(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 Wk(e,t){const r=e,n=ys(r.metadata),o=Yn(r.apidata),s=Yn(r.properties),i=wg({},n,o,s),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=Vk(r,n),l=Hk(r,t),f={...r};return f.properties=i,a!==void 0&&(f.name=a),d!==void 0&&(f.type=d),u!==void 0?f.appearance=u:(!gr(r.appearance)||Object.keys(r.appearance).length===0)&&delete f.appearance,f.position=l,gr(f.appearance)&&delete f.appearance.heightPercent,f}function Rk(e,t){if(!e||typeof e!="object")return!0;const r=e,n=ys(r.metadata),o=Object.keys(n).length===0&&!(typeof r.metadata=="string"&&r.metadata.trim()!==""),s=!Sg(r);if(Uk(r)||!o||!s)return!1;const i=r.position;return!(!(gr(i)&&typeof i.order=="number"&&!Number.isNaN(i.order))&&(typeof r.positionRow=="number"||typeof r.positionColumn=="number"||typeof r.positionWidth=="number"||typeof r.positionRowSpan=="number"||typeof r.positionOrder=="number")||gr(n.appearance)||xg.some(u=>n[u]!==void 0&&(r.appearance==null||gr(r.appearance)&&r.appearance[u]===void 0))||Gk(r))}function Gk(e){const t=Yn(e.position),r=Yn(e.layout),n=ys(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 Yi(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,s)=>{if(Rk(o))return o;const i=Wk(o,s);return i!==o&&(r=!0),i});return r?{...e,fields:n}:e}function Kk(e){return Yi(e)}const qk=new Set(["PENDING_PAYMENT","PAYMENT_PENDING","AWAITING_PAYMENT","PAID","PAYMENT_COMPLETED","PAYMENT_FAILED","REFUNDED","AUTHORIZED","CAPTURED","PARTIALLY_PAID"].map(e=>e.toUpperCase()));function Fc(e){return typeof e=="string"&&e.trim()!==""}function Pc(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"||Fc(t.amount)||typeof t.total_amount=="number"||Fc(t.total_amount)||Fc(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"&&qk.has(r.trim().toUpperCase()))}function Yk(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 Xk(e,t){const r=Yk(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||Pc(r.item)||o!=null&&Pc(o))return r.id}function Jk(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 Qk(e){return Jk(e).some(t=>t.toLowerCase().includes("payment"))}function Zk(e){const t=e.properties,r=e.metadata;return!!(t?.mergeSuccessDataIdAsPaymentId||r?.mergeSuccessDataIdAsPaymentId)}function eT(e,t){if(t?.type!=="button"||!Uo(e))return;const r=Qe(e,"data.id");if(r==null||String(r).trim()==="")return;const n=Qe(e,"data");if(Zk(t)||n!=null&&typeof n=="object"&&!Array.isArray(n)&&Pc(n)||Qk(t))return r}const tT=new Set(["section","group","columns","divider","header","sectionHeading","spacer","addmore","textLabel","customizeSections"]);function rT(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 s=r.get(o);if(s?.fieldNames?.length)for(const i of s.fieldNames)i&&!n.includes(i)&&n.push(i)}return n}function nT(e,t){const r=e.properties,n=Array.isArray(r?.linkedFieldNames)?r.linkedFieldNames:[],o=rT(Array.isArray(r?.linkedSectionIds)?r.linkedSectionIds:[],t),s=new Set,i=[];for(const a of[...n,...o])!a||s.has(a)||(s.add(a),i.push(a));return i}function Ag(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(s=>[s.id,s]));return n.map(s=>o.get(s)).filter(s=>!!s)}function oT(e,t){return Ag(e,t).find(r=>r.heading?.enabled)}function Cg(e,t){const r=e.template??"";return(e.mode??"increment")==="fixed"?r:r.replace(/\{n\}/g,String(t+1))}function Eg(e,t,r,n){const o=nT(e,r);if(o.length===0)return[];const s=new Set(o);return t.filter(i=>{const a=n(i);return!a||i.id===e.id||tT.has(i.type)?!1:s.has(a)})}function sT(e,t,r){if(e.type!=="sectionHeading"||!t?.length)return;const n=r(e);if(n)for(const o of t){const s=o.heading;if(s?.enabled&&s.headingFieldName===n)return s}}function Oc(e){return[...e].sort((t,r)=>{const n=t.position?.order??0,o=r.position?.order??0;if(n!==o)return n-o;const s=t.position?.column??1,i=r.position?.column??1;return s-i})}function iT(e,t,r){if(!e?.length)return[];const n=e.filter(i=>i.showBorder===!0);if(n.length===0)return[];const o=new Map;for(const i of t){const a=r(i);a&&o.set(a,i)}const s=[];for(const i of n){const a=i.fieldNames.map(u=>o.get(u)).filter(u=>!!u);if(a.length===0)continue;const d=Oc(a).map(u=>r(u)).filter(Boolean);s.push({section:i,fieldNames:d})}return s}function bs(e,t=0){return e.heading?.enabled?Cg(e.heading,t):e.name}function Ng(e,t,r){if(e.type!=="sectionHeading")return!1;const n=t.heading;return!n?.enabled||!n.headingFieldName?!1:r(e)===n.headingFieldName}function aT(e,t){const r=typeof e.position?.order=="number"?e.position.order:0,n=(e.position?.column??1)-1,o=Do(e),s=bd(e,t);return{row:r,col:n,rowEnd:r+o-1,colEnd:n+s-1}}function Ic(e,t){let r=1/0,n=-1/0,o=1/0,s=-1/0;for(const i of e){const{row:a,col:d,rowEnd:u,colEnd:l}=aT(i,t);r=Math.min(r,a),n=Math.max(n,u),o=Math.min(o,d),s=Math.max(s,l)}return Number.isFinite(r)?{minRow:r,maxRow:n,minCol:o,maxCol:s,rowSpan:n-r+1,colSpan:s-o+1}:null}function lT(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 s=Ic(o,r);if(!s)return null;const i=o.filter(l=>l.type!=="sectionHeading"),a=i.length>0?i:o,d=Math.min(...a.map(l=>l.position?.order??0)),u=Math.max(1,...a.map(l=>(l.position?.order??d)-d+Do(l)));return{minRow:s.minRow,maxRow:s.maxRow,minCol:s.minCol,maxCol:s.maxCol,blockHeight:u}}function cT(e,t){return e.maxRow+1+t*e.blockHeight}function dT(e,t,r,n){const o=new Map;for(const a of t){const d=r(a);d&&o.set(d,a)}const s=new Map,i=new Set;for(const a of e){const d=a.fieldNames.map(w=>o.get(w)).filter(w=>!!w);if(d.length===0)continue;const u=d.filter(w=>!Ng(w,a.section,r)),l=Ic(d,n);if(!l)continue;const{minRow:f,minCol:p,rowSpan:m,colSpan:g}=l,h=`${f}-${p}`;if(s.has(h))continue;const y=new Set;let v=!1;for(let w=f;w<=f+m-1;w++){for(let x=p;x<=p+g-1;x++){const E=`${w}-${x}`;if(i.has(E)){v=!0;break}y.add(E)}if(v)break}if(!v){for(const w of y)i.add(w);s.set(h,{anchorRow:f,anchorCol:p,rowSpan:m,colSpan:g,run:a,legend:bs(a.section,0),renderFields:u.length>0?u:d})}}return{anchorsByOrigin:s,coveredCells:i}}function uT(e,t,r,n,o,s,i){const a=new Set(i),d=new Map;for(const u of e){const l=_g(u.linkedFields.map(p=>s(p)).filter(Boolean),t),f=l?.section;f?.fieldNames?.length?f.fieldNames:u.templateFieldNames,u.blockIds.forEach((p,m)=>{const g=r.filter(N=>N.id.endsWith(`__${p}`));if(g.length===0||!l)return;const h=Ic(g,o);if(!h)return;const{minRow:y,minCol:v,rowSpan:w,colSpan:x}=h,E=`${y}-${v}`;for(let N=y;N<=y+w-1;N++)for(let _=v;_<=v+x-1;_++)a.add(`${N}-${_}`);const P=l,C=bs(f,m+1);d.set(E,{anchorRow:y,anchorCol:v,rowSpan:w,colSpan:x,run:P,legend:C,renderFields:Oc(g),addMoreMeta:{addMoreFieldName:u.addMoreFieldName,blockId:p,blockIndex:m}})})}return{anchorsByOrigin:d,coveredCells:a}}function fT(e,t,r,n){const o=`${e}-${t}`;return r.has(o)?!n.get(o):!1}function pT(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 mT(e,t,r,n){return!(!n||r.run.section.collapsible!==!0||e===r.anchorRow&&t===r.anchorCol)}function hT(e,t,r){const n=new Set;for(const o of e.values())if(t(o))for(let s=o.anchorRow+1;s<o.anchorRow+o.rowSpan;s++)r(s,o)||n.add(s);return n}function gT(e,t,r){const n=o=>r.has(o)?"minmax(0, auto)":`minmax(${t}, auto)`;return Array.from({length:e},(o,s)=>n(s)).join(" ")}function yT(e,t){return new Map([...e,...t])}function bT(e,t,r){if(t.length===0)return e.map(i=>({kind:"field",field:i}));const n=new Map;for(const i of t)for(const a of i.fieldNames)n.set(a,i);const o=[];let s=0;for(;s<e.length;){const i=e[s],a=r(i),d=a?n.get(a):void 0;if(!d){o.push({kind:"field",field:i}),s+=1;continue}const u=[],l=new Set(d.fieldNames);for(;s<e.length;){const p=r(e[s]);if(!p||!l.has(p))break;const m=e[s];Ng(m,d.section,r)||u.push(m),s+=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 _g(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(s=>r.has(s));if(o.length>0)return{section:n,fieldNames:o}}}const vT=2*6e4,kg=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<=kg)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-kg)).forEach(([n])=>this.map.delete(n))}}function ST(e){return(e??"").trim()||"default"}function Tg(e){const t=ST(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 Fg=new wT(vT);function Pg(e){const t=Tg(e),r=Fg.get(t);return r?{value:r.value,isStale:r.isStale}:null}function Og(e,t){const r=Tg(e);Fg.set(r,t)}function Ig(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 s=o;typeof s.name=="string"&&typeof s.code=="string"?t[n]=`${s.code} ${s.name}`.trim():typeof s.name=="string"?t[n]=s.name:typeof s.code=="string"?t[n]=s.code:typeof s.short_code=="string"?t[n]=s.short_code:t[n]=s.name??s.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 Mc=({schema:e,formId:t,initialValues:r,onSubmit:n,onChange:o,onValidationError:s,onClose:i,mode:a="fill",className:d,children:u,gridLayout:l,unstyled:f=!1,submissionContext:p,onWorkflowSubmitResult:m,initialExtraSubmitPayload:g,onExtraSubmitPayloadChange:h,workflowStepId:y,viewerContext:v,getViewerContext:w,hideTableRowControls:x=!1,themeVars:E,dark:P=!1,omitRootWrapper:C=!1})=>{const N=Rn(k=>k.viewerContext),_=S.useMemo(()=>{if(v!==void 0)return v;const k=w?.();return k!==void 0?k:N},[v,w,N]),[A,I]=S.useState(e||null),[T,W]=S.useState(!!t&&!e),[J,O]=S.useState(null),j=e?.BFF_submit_api??J,[M,D]=S.useState(!1),[L,U]=S.useState({}),[$,ie]=S.useState({}),[V,K]=S.useState({}),[X,ce]=S.useState({}),[ne,G]=S.useState({}),[ee,Pe]=S.useState(null),oe=ha.useParams(),re=Nt(k=>k.setValues),be=Nt(k=>k.setSubmitting),de=Nt(k=>k.formDisabled),ot=Nt(k=>k.visibleFields),Se=Nt(k=>k.requiredFields),xe=Nt(k=>k.updateVisibility),ae=Nt(k=>k.updateRequired),ve=Nt(k=>k.setFieldError),Ye=S.useRef(!1),ct=S.useRef(void 0),Ge=S.useMemo(()=>{if(!e)return null;const k=e;if(k.form&&Array.isArray(k.form.fields))try{return ms(k.form,k.form.fields,k.form.layout||null,k.form.rules||[])}catch{return e}if(Array.isArray(k.fields)&&k.fields.some(z=>typeof z.metadata=="string"&&z.metadata.startsWith("{")||z.fieldType&&!z.type))try{const z={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 ms(z,k.fields,k.layout||null,k.rules||[])}catch{return e}return e},[e]);S.useEffect(()=>{if(e){const k=e;k.BFF_submit_api&&O(k.BFF_submit_api)}},[e]);const Kt=S.useMemo(()=>{const k=Ge||A,H=k?Yi(k):null;if(!H)return null;const z=H.layout,Z=H.rules,Q=H.clientMapping,le=(Array.isArray(H.fields)?H.fields:[]).map(Le=>{let Ve={...Le};if(Le.validationRules&&typeof Le.validationRules=="object"&&!Le.validation){const fe=Le.validationRules,Fe=[];fe.required===!0&&Fe.push({type:"required",message:"This field is required"}),fe.minLength!==void 0&&typeof fe.minLength=="number"&&Fe.push({type:"minLength",value:fe.minLength,message:`Minimum length is ${fe.minLength}`}),fe.maxLength!==void 0&&typeof fe.maxLength=="number"&&Fe.push({type:"maxLength",value:fe.maxLength,message:`Maximum length is ${fe.maxLength}`}),fe.pattern&&typeof fe.pattern=="string"&&Fe.push({type:"pattern",value:fe.pattern,message:"Invalid format"}),fe.allowLetters!==void 0&&Fe.push({type:"allowLetters",value:fe.allowLetters}),fe.allowNumbers!==void 0&&Fe.push({type:"allowNumbers",value:fe.allowNumbers}),fe.allowSpecialChars!==void 0&&Fe.push({type:"allowSpecialChars",value:fe.allowSpecialChars}),Fe.length>0&&(Ve={...Ve,validation:Fe})}const we=Le.required===!0||Le.isRequired===!0,Ae=Array.isArray(Ve.validation)&&Ve.validation.some(fe=>fe.type==="required");if(we&&!Ae){const fe={type:"required",message:"This field is required"},Fe=Array.isArray(Ve.validation)?Ve.validation:[];Ve={...Ve,validation:[...Fe,fe]}}if(Le.apidata&&typeof Le.apidata=="object"){const fe=Le.apidata,Fe=Ve.properties||{},ye=(Ve.type||Le.fieldType)==="status";if(!Fe.apiEndpoint&&fe.apiEndpoint){const dt={...Fe,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,valueSource:fe.valueSource||(fe.apiEndpoint?"api":void 0),optionsSource:fe.optionsSource||(fe.apiEndpoint?"api":void 0)};ye&&(dt.source=Fe.source??"api",Fe.statuses!==void 0&&(dt.statuses=Fe.statuses),Fe.dataPath!==void 0&&(dt.dataPath=Fe.dataPath),Fe.showStatusText!==void 0&&(dt.showStatusText=Fe.showStatusText),Fe.statusTextPath!==void 0&&(dt.statusTextPath=Fe.statusTextPath),Fe.showCurrentIndicator!==void 0&&(dt.showCurrentIndicator=Fe.showCurrentIndicator)),Ve={...Ve,properties:dt}}}const He=["select","multiselect","radio","checkboxgroup"],rt=Ve.type||Le.fieldType;if(He.includes(rt)){const fe=Le.options,Fe=Ve.properties?.options,ye=Array.isArray(Fe)&&Fe.length>0;if(Array.isArray(fe)&&fe.length>0&&!ye){const dt=Ve.properties||{};Ve={...Ve,properties:{...dt,options:fe}}}}return Ve}),Ce=H.config?.rules,Ne=Z&&Array.isArray(Z)?Z:Ce&&Array.isArray(Ce)?Ce:[],De=Ne.length>0?le.map(Le=>{if((Le.conditions&&Array.isArray(Le.conditions)?Le.conditions:[]).length>0)return Le;const we=Le.id??Le._id,Ae=Le.name||Le.key,He=Ne.filter(Fe=>{const ye=typeof Fe.targetFieldId=="object"?Fe.targetFieldId?.id??Fe.targetFieldId?._id:Fe.targetFieldId;return ye?ye===we||ye===Ae||ye===Le.fieldKey:!1});if(He.length===0)return Le;const rt=[],fe=new Set;return He.forEach(Fe=>{try{const ye=typeof Fe.conditionExpression=="string"?JSON.parse(Fe.conditionExpression):Fe.conditionExpression;if(!ye||typeof ye!="object")return;!ye.id&&Fe.id&&(ye.id=Fe.id);const dt=typeof Fe.targetFieldId=="object"?Fe.targetFieldId?.id??Fe.targetFieldId?._id:Fe.targetFieldId;ye.action&&(!ye.then||!Array.isArray(ye.then)||ye.then.length===0)&&(ye.then=[{action:ye.action,...dt&&{target:dt}}]),(!ye.then||!Array.isArray(ye.then)||ye.then.length===0)&&Fe.action&&(ye.then=[{action:Fe.action,...dt&&{target:dt}}]),ye.then&&Array.isArray(ye.then)&&dt&&(ye.then=ye.then.map(Bt=>!Bt.target&&dt?{...Bt,target:dt}:Bt));const Wt=Fe.conditionExpression??JSON.stringify(ye);if(fe.has(Wt))return;fe.add(Wt),rt.push(ye)}catch{}}),rt.length===0?Le:{...Le,conditions:rt}}):le;let at=H.config||{submitAction:"database",layout:"default",autoSave:!0,validateOnChange:!0,showFieldErrors:"inline"};return!at.layout&&z?typeof z=="object"&&z!==null?at.layout="default":typeof z=="string"&&["default","card","compact"].includes(z)?at.layout=z:at.layout="default":at.layout||(at.layout="default"),Z&&!at.rules&&(at.rules=Z),Q&&!at.clientMapping&&(at.clientMapping=Q),{...H,fields:De,config:at}},[Ge,A]);S.useEffect(()=>{Ge&&Ge!==A&&I(Ge)},[Ge]),S.useEffect(()=>{if(t&&!e){const k=(Tn()??"").trim()||"default",H=Pg({scope:k,formId:t,version:"latest"});H?.value?.schema?(I(H.value.schema),H.value.bffSubmitApi&&O(H.value.bffSubmitApi),W(!1),H.isStale&&Je({background:!0})):Je({background:!1})}},[t,e]);const Je=async({background:k})=>{if(!t)return;const H=t;k||W(!0);try{const z=await Tk.getForRendering(t),Z=ms(z.form,z.fields,z.layout,z.rules);if(H!==t)return;I(Z),z.BFF_submit_api&&O(z.BFF_submit_api);const Q=(Tn()??"").trim()||"default";Og({scope:Q,formId:H,version:"latest"},{schema:Z,bffSubmitApi:z.BFF_submit_api})}catch{}finally{k||W(!1)}};if(T)return c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx(Pn,{})});if(!Kt)return c.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Form not found"});const q=Kt,$e=S.useMemo(()=>new Set(Object.keys(q.config?.prepopulateApi?.fieldMapping??{})),[q.config?.prepopulateApi?.fieldMapping]),gt=S.useCallback(async k=>{const H=q?.fields?.length?tc(k,q.fields):k,z=yh(H,q.config?.sections,q.config?.submitPayload);if(n){const Z=p?{...z,...p}:z;return n(Z)}return{success:!0}},[n,p,q?.fields,q.config?.sections,q.config?.submitPayload]),{values:Oe,errors:te,touched:pe,isSubmitting:We,isValid:Pt,submitCount:je,currentStep:Te,totalSteps:Xe,completedSteps:Ue,currentStepFields:ft,isLastStep:St,setFieldValue:xt,setFieldTouched:ze,handleSubmit:yt,validateForm:pt,resetForm:At,nextStep:Ut,goToStep:ur,shouldShowField:Ar,isFieldEnabled:Vt,isFieldRequired:Po,loadDraft:Xn}=Vd({schema:q,initialValues:r,onSubmit:gt,onChange:o,workflowStepId:y});sv({fields:q.fields,values:Oe,buttonResponses:$,prepopulateResponse:ee,prepopulateResponseRules:q.config?.prepopulateResponseRules});const Ct=Nt(k=>k.readOnlyFields),Cr=Nt(k=>k.editableFields),Jn=S.useCallback(k=>Ct.has(k),[Ct]),It=S.useCallback(k=>Cr.has(k),[Cr]);S.useEffect(()=>{q.config?.allowDraft&&a==="fill"&&Xn()},[q.id]),S.useEffect(()=>{ct.current=q.id,Ye.current=!1,U({}),K({}),ce({}),G({}),Pe(null)},[q.id]),S.useEffect(()=>{const k=q.config?.prepopulateApi,H=!!(k?.fieldMapping&&Object.keys(k?.fieldMapping??{}).length>0),z=(q.config?.prepopulateResponseRules?.length??0)>0;if(!k?.enabled||!k.apiEndpoint?.trim()||!H&&!z||Ye.current)return;Ye.current=!0;const Z=q.id;ct.current=q.id;let Q=!1;return D(!0),(async()=>{try{const le=Nt.getState().values,Ce=typeof p=="object"&&p!==null?{...p,...g||{}}:g||{},Ne=se=>rn(se,le,oe,Ce);let De=cn(Ne(k.apiEndpoint));if(k.apiQueryParams?.length){const se=new URLSearchParams;k.apiQueryParams.forEach(({key:Ie,value:me})=>se.append(Ie,Ne(me))),De=`${De}${De.includes("?")?"&":"?"}${se.toString()}`}const at={};k.apiHeaders?.forEach(({key:se,value:Ie})=>{se.trim()&&(at[se]=Ne(Ie))}),at["Content-Type"]=at["Content-Type"]??"application/json";let Ht;if(k.apiMethod==="POST"&&k.apiBodyFields?.length){const se={};k.apiBodyFields.forEach(({key:Ie,value:me})=>{Ie.trim()&&(se[Ie]=Ne(me))}),Ht=JSON.stringify(se)}const Le=await fetch(De,{method:k.apiMethod,headers:at,body:k.apiMethod==="POST"?Ht:void 0});if(!Le.ok){const se=await Le.text();throw new Error(se||`HTTP ${Le.status}`)}const Ve=await Le.json(),we=se=>{try{return se.split("?")[0].split("/").filter(Boolean).pop()||se}catch{return se}},Ae=(se,Ie)=>{if(se==null)return null;const me=typeof se=="string"?se:se instanceof Date?se.toISOString():null;if(!me)return null;const Ke=typeof se=="object"&&se instanceof Date?se:new Date(me);if(Number.isNaN(Ke.getTime()))return null;const ut=mt=>String(mt).padStart(2,"0");if(Ie==="date")return me.length>=10&&me[4]==="-"&&me[7]==="-"?me.slice(0,10):Ke.toISOString().slice(0,10);if(Ie==="time")return`${ut(Ke.getHours())}:${ut(Ke.getMinutes())}:${ut(Ke.getSeconds())}`;if(Ie==="datetime"){const mt=Ke.getFullYear(),tt=Ke.getMonth()+1,ue=Ke.getDate(),bt=Ke.getHours(),Re=Ke.getMinutes(),Ft=Ke.getSeconds();return`${mt}-${ut(tt)}-${ut(ue)}T${ut(bt)}:${ut(Re)}:${ut(Ft)}`}return null},He=(se,Ie)=>{const me=q.fields.find(ue=>ue.name===se||ue.key===se);if(!me)return Ie;if((me.type==="file"||me.type==="camera"||me.type==="photoChoice")&&typeof Ie=="string"&&Ie.startsWith("http"))return{url:Ie,name:we(Ie)};if(me.type==="date"||me.type==="datetime"||me.type==="time"){const ue=Ae(Ie,me.type);if(ue!==null)return ue}if(me.type==="multiselect")return Array.isArray(Ie)?Ie.map(ue=>typeof ue=="string"?ue:String(ue)):typeof Ie=="string"?Ie.trim()===""?[]:Ie.includes(",")?Ie.split(",").map(ue=>ue.trim()).filter(Boolean):[Ie]:Ie!=null&&Ie!==""?[String(Ie)]:[];if(me.type!=="radio"&&me.type!=="select")return Ie;const Ke=me.properties?.options??me.options;if(!Array.isArray(Ke)||Ke.length===0)return Ie;const ut=Ke.map(ue=>ue.value);if(ut.includes(Ie))return Ie;const mt=String(Ie);if(ut.includes(mt))return mt;const tt=Ke.find(ue=>ue.value==Ie);return tt?tt.value:Ie},rt=new Set(q.fields.filter(se=>se.type==="table").map(se=>se.name||se.key)),fe=new Set(q.fields.filter(se=>se.type==="billingGrid").map(se=>se.name||se.key)),Fe=se=>se.name||se.key||se.id,ye={},dt=[],Wt=[],Bt=gN(k?.fieldMapping,q.config?.sections,q.config?.submitPayload);for(const[se,Ie]of Object.entries(Bt)){if(!Ie?.trim()||se.startsWith("__"))continue;const me=Qe(Ve,Ie),Ke=se.indexOf(".");if(Ke>0&&fe.has(se.slice(0,Ke))){const mt=se.slice(0,Ke),tt=se.slice(Ke+1),bt=q.fields.find(Re=>(Re.name||Re.key)===mt)?.properties;if(bt?.rowSlots?.length){const Re=tt.startsWith("__block__")?tt.slice(9):tt,Ft=ye[mt]??Nt.getState().values[mt];Array.isArray(me)?ye[mt]=c_(bt,Re,me,Ft):me!=null&&(ye[mt]=mc(bt,me,Ft))}continue}if(Ke>0&&rt.has(se.slice(0,Ke))){const mt=se.slice(0,Ke),tt=se.slice(Ke+1);dt.push({tableName:mt,columnName:tt,path:Ie});continue}if(fe.has(se)&&me!==void 0&&me!==null&&typeof me=="object"){const tt=q.fields.find(ue=>(ue.name||ue.key)===se)?.properties;if(tt?.rowSlots?.length){if(Array.isArray(me)){const ue=tt.rowSlots.find(bt=>bt.kind==="dynamic");if(ue&&ue.kind==="dynamic"){const bt=ue.block.apiArrayPath??"items";ye[se]=mc(tt,{[bt]:me})}}else ye[se]=mc(tt,me);continue}}if(rt.has(se)&&Array.isArray(me)&&me.length>0&&typeof me[0]=="object"&&me[0]!==null){const tt=q.fields.find(Re=>(Re.name||Re.key)===se)?.properties?.columns||[],ue=me.map(Ig),bt=Re=>(Re||"").toLowerCase().replace(/\s+/g,"_").trim();ye[se]=ue.map(Re=>{const Ft={};for(const fr of tt){const eo=fr.name??"";Ft[eo]=Re[bt(eo)]??Re[eo]}return Ft});continue}if(me!=null&&(ye[se]=He(se,me)),me==null)continue;let ut=me;if(Array.isArray(me)){const mt=q.fields.find(tt=>Fe(tt)===se);if(mt?.type==="addmore"){Wt.push({addMoreFieldName:se,array:me});continue}if(mt?.type==="multiselect"){const tt=k.multiselectArrayPropertyMap?.[se];tt&&me.length>0&&me.some(ue=>ue!=null&&typeof ue=="object")&&(ut=me.map(ue=>ue!=null&&typeof ue=="object"&&tt in ue?ue[tt]:void 0).filter(ue=>ue!=null))}}ye[se]=He(se,ut)}const lt={},vt={},rr={};for(const{addMoreFieldName:se,array:Ie}of Wt){const me=q.fields.find(bt=>Fe(bt)===se);if(!me||me.type!=="addmore")continue;const Ke=Eg(me,q.fields,q.config?.sections,Fe);if(Ke.length===0)continue;const ut=k.addMoreFieldKeyMap?.[se],mt=Ie.length>0&&Ie[0]!=null&&typeof Ie[0]=="object"?Ie[0]:null;if(mt)for(const bt of Ke){const Re=Fe(bt),Ft=ut&&ut[Re]||Re,fr=mt[Ft];fr!=null&&(ye[Re]=He(Re,fr))}const tt=Ie.slice(1),ue=tt.map((bt,Re)=>`prepop_${se}_${Re}_${Date.now()}`);ue.length>0&&(vt[se]=ue);for(let bt=0;bt<tt.length;bt++){const Re=tt[bt];if(Re==null||typeof Re!="object")continue;const Ft=Re,fr=Ft.id;fr!=null&&String(fr).trim()!==""&&(rr[`${se}__${ue[bt]}`]=String(fr));for(const eo of Ke){const ma=Fe(eo),aP=ut&&ut[ma]||ma,Kc=Ft[aP];if(Kc==null)continue;const lP=`${ma}__addmore__${se}__${ue[bt]}`;lt[lP]=He(ma,Kc)}}}Object.keys(vt).length>0&&K(se=>({...se,...vt})),Object.keys(rr).length>0&&G(se=>({...se,...rr}));const jr=se=>(se||"").toLowerCase().replace(/\s+/g,"_").trim(),Kr=[...new Set(dt.map(se=>se.tableName))];for(const se of Kr){if(Array.isArray(ye[se]))continue;const Ie=dt.find(ue=>ue.tableName===se);if(!Ie?.path?.includes("."))continue;const me=Ie.path.replace(/\.[^.]+$/,""),Ke=Qe(Ve,me);if(!Array.isArray(Ke)||Ke.length===0||typeof Ke[0]!="object"||Ke[0]===null)continue;const mt=q.fields.find(ue=>(ue.name||ue.key)===se)?.properties?.columns||[],tt=Ke.map(Ig);ye[se]=tt.map(ue=>{const bt={};for(const Re of mt){const Ft=Re.name??"",fr=jr(Ft),eo=ue[fr]??ue[Ft];bt[Ft]=eo}return bt})}const zr=(se,Ie)=>{const me=Qe(Ve,se);if(Array.isArray(me))return me;if(me!=null)return[me];if(!se.includes("."))return[];const Ke=se.replace(/\.[^.]+$/,""),ut=Qe(Ve,Ke);return!Array.isArray(ut)||ut.length===0||typeof ut[0]!="object"||ut[0]===null?[]:ut.map(mt=>{const tt=mt[Ie];if(tt!==null&&typeof tt=="object"&&!Array.isArray(tt)&&!(tt instanceof Date)){const ue=tt;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 tt})};for(const{tableName:se,columnName:Ie,path:me}of dt){const Ke=zr(me,Ie),mt=q.fields.find(Re=>(Re.name||Re.key)===se)?.properties?.columns||[],tt=mt.find(Re=>(Re.name||"").toLowerCase()===Ie.toLowerCase())?.name??Ie;let ue=Array.isArray(ye[se])?ye[se]:[];const bt=Math.max(ue.length,Ke.length);if(bt>ue.length)for(ue=[...ue];ue.length<bt;){const Re={};mt.forEach(Ft=>{Re[Ft.name||""]=""}),ue.push(Re)}else ue=ue.map(Re=>({...Re}));Ke.forEach((Re,Ft)=>{ue[Ft]&&(ue[Ft][tt]=Re)}),ye[se]=ue}if(ct.current===Z){if(Object.keys(ye).length>0||Object.keys(lt).length>0){const Ft={...Nt.getState().values,...ye,...lt};re(Ft)}const Ie=Qe(Ve,"data.user_id"),me=Qe(Ve,"data.items"),Ke=Qe(Ve,"data");let ut=Array.isArray(me)&&me.length>0&&me[0]!=null&&typeof me[0]=="object"&&me[0].id?me[0].id:void 0;ut===void 0&&Array.isArray(Ke)&&Ke.length>0&&Ke[0]!=null&&typeof Ke[0]=="object"&&Ke[0].id&&(ut=Ke[0].id),ut===void 0&&(ut=Qe(Ve,"data.0.id"));const mt=Xk(Ve,{treatFirstItemIdAsPaymentId:k?.treatFirstItemIdAsPaymentId===!0}),tt=Qe(Ve,"data.id"),ue=Qe(Ve,"data.batch_id"),bt=Qe(Ve,"data.program_id"),Re={};Ie!=null&&(Re.context_user_id=Ie),ut!=null&&ut!==""&&(Re.documentId=ut),tt!=null&&String(tt).trim()!==""&&(p?.id===void 0||p?.id===null)&&(Re.id=tt),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(Ft=>{const fr={...Ft,...Re};return h?.(fr),fr}),Pe(Ve)}}catch(le){Q||Zl(le,"Prepopulate request failed.",ls)}finally{D(!1)}})(),()=>{Q=!0}},[q.id,q.config?.prepopulateApi?.enabled,q.config?.prepopulateApi?.apiEndpoint,q.config?.prepopulateApi?.apiMethod,JSON.stringify(q.config?.prepopulateApi?.fieldMapping),q.config?.prepopulateApi?.treatFirstItemIdAsPaymentId,p,g,oe,re,K]),S.useEffect(()=>{Object.keys(te).length>0&&s?.(te)},[te,s]);const Er=Xe>1,er=a==="view",sr=S.useCallback((k,H)=>er||!!H&&!It(k)||Jn(k)&&!It(k),[er,It,Jn]),fn=q.fields.filter(k=>!k.parentId),kt=[...Er?ft:fn.length>0?fn:q.fields].filter(k=>!(!k||typeof k!="object"||!k.name&&!k.key)).sort((k,H)=>{const z=typeof k.position?.order=="number"?k.position.order:typeof k.positionOrder=="number"?k.positionOrder:Number.MAX_SAFE_INTEGER,Z=typeof H.position?.order=="number"?H.position.order:typeof H.positionOrder=="number"?H.positionOrder:Number.MAX_SAFE_INTEGER;if(z!==Z)return z-Z;const Q=typeof k.position?.column=="number"?k.position.column:1,le=typeof H.position?.column=="number"?H.position.column:1;return Q-le}),Ss=S.useCallback(k=>{const H=Nt.getState().errors,z=Object.keys(H).find(Z=>k.includes(Z));z&&requestAnimationFrame(()=>{document.querySelector(`[data-field-name="${z}"]`)?.scrollIntoView({behavior:"smooth",block:"center"})})},[]),Nr=async k=>{if(k?.preventDefault(),Er&&!St){if(!await Ut())try{const Z=Nt.getState().errors;$t.toast.error(ec(Z,q.fields)||"Please fix the errors before continuing."),Ss(kt.map(Q=>Q.name||Q.key||Q.id).filter(Boolean))}catch{$t.toast.error("Please fix the errors before continuing.")}return}const H=await yt(k);if(H&&H.success===!1&&H.errors?.length)try{const z=Nt.getState().errors;$t.toast.error(ec(z,q.fields)||"Submission failed. Please check the form."),Ss(kt.map(Z=>Z.name||Z.key||Z.id).filter(Boolean))}catch{$t.toast.error("Submission failed. Please check the form.")}return H},Dr=S.useCallback(()=>{At(),i&&i()},[At,i]),_r=S.useCallback((k,H)=>{const z=q.fields.find(Q=>Q.type==="button"&&(Q.name===k||Q.key===k)),Z=eT(H,z);Z!=null&&String(Z).trim()!==""&&(p?.payment_id===void 0||p?.payment_id===null)&&U(Q=>{const le={...Q,payment_id:Z};return h?.(le),le}),ie(Q=>{const le={...Q,[k]:H};return!Uo(H)||!(z?.type==="button"&&z.properties?.action==="submit")||q.fields.filter(De=>De.type==="editButton").map(De=>De.name).forEach(De=>delete le[De]),le})},[q.fields,p,h]),br=S.useCallback(async()=>await pt(),[pt]),qt=S.useCallback(()=>Nt.getState().errors,[]),tr=S.useMemo(()=>({...g||{},...L}),[g,L]),Br=S.useMemo(()=>({...typeof p=="object"&&p!==null?p:{},...tr}),[p,tr]),Qi=q.config?.layout??q.layout??"default",Zi=["default","card","compact"].includes(Qi)?Qi:"default",ea={default:"",card:"bg-card border rounded-lg shadow-sm p-6",compact:"space-y-2"},xs=S.useMemo(()=>{if(C)return;const k=q.config?.theme?.cssVariables;if(!(!k&&!E))return{...k??{},...E??{}}},[C,q.config?.theme?.cssVariables,E]),kr=S.useMemo(()=>_s({config:q.config,layout:q.layout},l),[q.config,q.layout,l]),Ee=S.useMemo(()=>kr?{...kr,verticalSpacing:kr.verticalSpacing??kr.spacing??"16px",horizontalSpacing:kr.horizontalSpacing??kr.spacing??"16px",rowHeight:kr.rowHeight??In}:null,[kr]),F=Ee!==null;Ee?.rows;const Y=Ee?.columns??3,he=Ee?.verticalSpacing??Ee?.spacing??"16px",st=Ee?.horizontalSpacing??Ee?.spacing??"16px",Tt=Ee?.rowHeight??In,wt=S.useCallback(k=>{if(!_)return!0;const H=k.visibility;if(!H)return!0;const z=H.visibleToUserType??H.user_type,Z=H.visibleToUserRole??H.user_role,Q=Array.isArray(H.visibleToUserIds)?H.visibleToUserIds:Array.isArray(H.users)?H.users:[],le=Array.isArray(H.hiddenFromUserIds)?H.hiddenFromUserIds:[];if(Array.isArray(le)&&le.length>0&&_.userId!=null&&le.includes(_.userId))return!1;if(Q.length>0&&_.userId!=null&&Q.includes(_.userId))return!0;const Ce=z!=null&&z!==""&&_.userType!=null&&_.userType!==z,Ne=Z!=null&&Z!==""&&_.role!=null&&_.role!==Z,De=Q.length>0&&(_.userId==null||!Q.includes(_.userId));return!(Ce||Ne||De)},[_]),Mt=S.useMemo(()=>NN(q.fields),[q.fields]),$r=S.useMemo(()=>kN(q.fields),[q.fields]),[ir,Oo]=S.useState($r);S.useEffect(()=>{Oo($r)},[q.id,$r]);const Lt=S.useCallback((k,H)=>{Oo(z=>z[k]===H?z:{...z,[k]:H})},[]),ta=S.useMemo(()=>({visibility:ir,setSectionVisible:Lt,fieldToHeading:Mt,allFields:q.fields}),[ir,Lt,Mt,q.fields]),et=S.useCallback(k=>k.name||k.key||k.id,[]),Tr=k=>{if(!wt(k))return!1;const H=k.name||k.key||k.id;if(!wh(H,k.type,ir,Mt))return!1;const z=k.hidden===!0;return Ar(H)||!z&&H},yy=S.useCallback(k=>{const H=q.fields.find(Z=>et(Z)===k);if(H)return H.type;const z=vh(k);return q.fields.find(Z=>et(Z)===z)?.type},[q.fields,et]),ra=S.useCallback(k=>wh(k,yy(k),ir,Mt),[ir,Mt,yy]),pn=S.useCallback(k=>ra(k)?Po(k):!1,[ra,Po]);S.useEffect(()=>{const{visibleFields:k,requiredFields:H,errors:z}=Nt.getState(),Z=new Set(k),Q=new Set(H),le=[];for(const Ce of q.fields){const Ne=et(Ce);Ne&&(ra(Ne)||(Z.delete(Ne),Q.delete(Ne),z[Ne]&&le.push(Ne)))}xe(Array.from(Z)),ae(Array.from(Q));for(const Ce of le)ve(Ce,void 0)},[ir,Mt,q.fields,q.id,et,ra,xe,ae,ve,ot,Se]);const Dt=q.config?.sections,Qn=S.useCallback(k=>{let H=k;if(k.type==="table"){const Z=k.properties?.columns;if(Array.isArray(Z)&&Z.length>0){const Q=Z.filter(le=>wt(le));H={...k,properties:{...k.properties,columns:Q}}}}const z=sT(H,Dt,et);return z?{...H,label:Cg(z,0)}:H},[wt,Dt,et]),mn=S.useCallback(k=>Eg(k,q.fields,Dt,et),[q.fields,Dt,et]),Gr=S.useCallback((k,H,z)=>`${k}__addmore__${H}__${z}`,[]),na=S.useCallback((k,H)=>`${k}__${H??"base"}`,[]),oa=S.useCallback((k,H)=>{const z=na(k.id,H);return X[z]??k.defaultCollapsed??!1},[X,na]),Wc=S.useCallback((k,H,z)=>{const Z=na(k,H);ce(Q=>Q[Z]===z?Q:{...Q,[Z]:z})},[na]),sa=S.useMemo(()=>{const k=[],H=q.fields.filter(z=>z.type==="addmore");for(const z of H){const Z=et(z),le=mn(z).find(at=>{if(at.type!=="button")return!1;const Ht=at.properties,Le=at.metadata;let Ve=Ht?.action;if(!Ve&&Le!=null)try{Ve=(typeof Le=="string"?JSON.parse(Le):Le)?.action}catch{}return Ve==="upload"||Ve==="custom"});if(!le)continue;const Ce=et(le),Ne=V[Z]||[],De=Qe($[Ce],"data.id")??Qe($[Ce],"data.documentId")??L.documentId;De!=null&&String(De).trim()!==""&&k.push(String(De));for(const at of Ne){const Ht=Gr(Ce,Z,at),Le=Qe($[Ht],"data.id")??Qe($[Ht],"data.documentId"),Ve=ne[`${Z}__${at}`],we=Le??Ve;we!=null&&String(we).trim()!==""&&k.push(String(we))}}return k},[q.fields,V,$,ne,L.documentId,et,mn,Gr]);S.useEffect(()=>{U(k=>{const H={...k,document_ids:sa},z=k.document_ids;return Array.isArray(z)&&z.length===sa.length&&sa.every((Z,Q)=>z[Q]===Z)?k:H})},[sa]);const ia=S.useCallback((k,H,z,Z)=>{for(const Q of z){const le=et(Q),Ce=Gr(le,k,H),Ne=Z[Ce];if(Ne==null)continue;const De=Q.type;if(De==="file"||De==="camera"||De==="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},[et,Gr]),Zn=S.useCallback(k=>{const H=et(k);if(!H)return;if(mn(k).length===0){$t.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,[H]:[...Q[H]||[],Z]}))},[et,mn]),aa=S.useCallback((k,H)=>{K(z=>{const Z=z[k]||[],Q=Z.filter(le=>le!==H);if(Q.length===Z.length)return z;if(Q.length===0){const le={...z};return delete le[k],le}return{...z,[k]:Q}})},[]),la=S.useMemo(()=>kt.filter(k=>!k.parentId),[kt]),On=S.useMemo(()=>{const k=[];return kt.filter(z=>z.type==="addmore").sort((z,Z)=>{const Q=z.position?.order??0,le=Z.position?.order??0;return Q-le}).forEach(z=>{const Z=et(z),Q=z.position?.order??0,le=V[Z]||[],Ce=mn(z).sort((Ae,He)=>{const rt=Ae.position?.order??0,fe=He.position?.order??0;return rt!==fe?rt-fe:(Ae.position?.column??1)-(He.position?.column??1)});if(Ce.length===0)return;const Ne=Ag(z,Dt),De=Ne[0]?.fieldNames?.length?Ne[0].fieldNames:Ce.map(Ae=>et(Ae)).filter(Boolean),at=lT(De,la,Y,et),Ht=Math.min(...Ce.map(Ae=>Ae.position?.order??0)),Le=Math.max(1,...Ce.map(Ae=>(Ae.position?.order??Ht)-Ht+Do(Ae))),Ve=at?.blockHeight??Le,we=le.length*Ve;k.push({addMoreFieldName:Z,baseOrder:Q,blockHeight:Ve,blockIds:le,linkedFields:Ce,insertedRows:we,templateFieldNames:De,templateBounds:at})}),k},[kt,la,Y,et,V,mn,Dt]),As=S.useMemo(()=>({}),[]),ca=S.useMemo(()=>On.length===0?kt:kt.map(k=>{const H=k.position?.order??0,z=On.reduce((Z,Q)=>{const le=Q.templateBounds?.maxRow??Q.baseOrder;return H>le?Z+Q.insertedRows:Z},0);return z===0?k:{...k,position:{...k.position,order:H+z}}}),[kt,On]),da=S.useCallback(k=>{const H={};return Object.entries($).forEach(([z,Z])=>{const Q=k[z];Q&&(H[Q]=Z)}),H},[$]),Io=S.useMemo(()=>{const k=[],H={};return On.forEach(z=>{const{addMoreFieldName:Z,blockIds:Q,linkedFields:le,blockHeight:Ce,templateBounds:Ne}=z,De=Math.min(...le.map(Le=>Le.position?.order??0)),Ht=q.fields.find(Le=>et(Le)===Z&&Le.type==="addmore")?.properties;Q.forEach((Le,Ve)=>{const we={},Ae={},He={},rt=Ne?cT(Ne,Ve):z.baseOrder+1+Ve*Ce,fe=ne[`${Z}__${Le}`];le.forEach(ye=>{const dt=et(ye),Wt=Gr(dt,Z,Le),Bt=(ye.position?.order??De)-De;if(we[Wt]=dt,Ae[Wt]=Oe[Wt],!(Ht?.linkedFieldAllowDuplicate?.[dt]??!0)&&(ye.type==="select"||ye.type==="radio"||ye.type==="multiselect")){const vt=[],rr=Oe[dt];rr!=null&&rr!==""&&(Array.isArray(rr)?vt.push(...rr.map(Kr=>String(Kr))):vt.push(String(rr))),Q.filter(Kr=>Kr!==Le).forEach(Kr=>{const zr=Gr(dt,Z,Kr),qr=Oe[zr];qr!=null&&qr!==""&&(Array.isArray(qr)?vt.push(...qr.map(se=>String(se))):vt.push(String(qr)))}),vt.length>0&&(He[Wt]=[...new Set(vt)])}k.push({...ye,id:`${ye.id}__${Le}`,name:Wt,position:{...ye.position,order:rt+Bt}})});const Fe=da(we);Object.keys(we).forEach(ye=>{H[ye]={scopedFormValues:Ae,scopedFieldNameMap:we,scopedButtonResponses:Fe,...fe!=null&&{blockDocumentId:fe},...He[ye]&&{excludedOptionValues:He[ye]}}})})}),{clonedFields:k,scopeByFieldName:H}},[On,ne,et,Gr,Oe,da,q.fields]),Cs=S.useMemo(()=>[...ca,...Io.clonedFields].sort((k,H)=>{const z=k.position?.order??0,Z=H.position?.order??0;if(z!==Z)return z-Z;const Q=k.position?.column??1,le=H.position?.column??1;if(Q!==le)return Q-le;const Ce=ko(k.position)??0,Ne=ko(H.position)??0;return Ce!==Ne?Ce-Ne:String(k.id).localeCompare(String(H.id))}),[ca,Io.clonedFields]),Mo=S.useMemo(()=>Dk(Cs.filter(k=>!k.parentId),Tr),[Cs,Tr]),Rc=S.useCallback((k,H)=>Mo.some(z=>Bk(k,H,z,Y)),[Mo,Y]);Mo.length===0||Math.max(...Mo.map(k=>(k[0]?.position?.order??0)+gs(k,Y).rowSpan));const ua=S.useMemo(()=>iT(Dt,Oc(kt.filter(k=>!k.parentId)),et),[Dt,kt,et]),{anchorsByOrigin:by,coveredCells:vy}=S.useMemo(()=>dT(ua,ca,et,Y),[ua,ca,et,Y]),{anchorsByOrigin:wy,coveredCells:Sy}=S.useMemo(()=>uT(On.map(k=>({addMoreFieldName:k.addMoreFieldName,blockIds:k.blockIds,linkedFields:k.linkedFields,templateFieldNames:k.templateFieldNames})),Dt,Io.clonedFields,la,Y,et,vy),[On,Dt,Io.clonedFields,la,Y,et,vy]),hn=S.useMemo(()=>yT(by,wy),[by,wy]),xy=S.useMemo(()=>Sy,[Sy]),Ay=String(Tt).endsWith("px")?Tt:In,Cy=S.useCallback((k,H)=>{for(let z=0;z<Y;z++){if(z>=H.anchorCol&&z<H.anchorCol+H.colSpan)continue;if(As[`${k}-${z}`]||hn.get(`${k}-${z}`)||vg(k,z,Cs,Tr).length>0||Rc(k,z))return!0}return!1},[Y,As,hn,Cs,Tr,Rc]),Ey=S.useMemo(()=>hT(hn,k=>{const H=k.run.section;return H.collapsible?oa(H,k.addMoreMeta?.blockId):!1},Cy),[hn,oa,Cy]),Ny=S.useMemo(()=>{const k=[];for(const H of Object.keys(As)){const z=Number(H.split("-")[0]);Number.isNaN(z)||k.push(z)}for(const H of hn.values())if(H.renderFields.some(z=>Tr(z)))for(let z=H.anchorRow;z<H.anchorRow+H.rowSpan;z++)k.push(z);return $k(Mo,Y,k)},[Mo,Y,As,hn,Tr]),{originalToDisplayRow:fa,displayRowCount:nP,sortedOccupiedRows:oP}=S.useMemo(()=>{const k=jk(Ny);return{originalToDisplayRow:k.originalToDisplay,displayRowCount:k.displayRowCount,sortedOccupiedRows:k.sortedOriginalRows}},[Ny]),_y=Math.max(nP,1),Gc=S.useCallback((k,H=1)=>zk(k,H,fa),[fa]),ky=S.useMemo(()=>{const k=new Set;for(const H of Ey){const z=fa.get(H);z!==void 0&&k.add(z)}return k},[Ey,fa]),sP=S.useMemo(()=>gT(_y,Ay,ky),[_y,Ay,ky]),iP=S.useMemo(()=>bT(kt.filter(k=>!k.parentId&&Tr(k)),ua,et),[kt,ua,et,Tr]),pa=S.useCallback(k=>{if(F)return null;const H=et(k),z=V[H]||[];if(z.length===0)return null;const Z=mn(k);if(Z.length===0)return null;const Q=oT(k,Dt),le=Z.map(De=>et(De)).filter(Boolean),Ce=_g(le,Dt),Ne=(De,at,Ht,Le,Ve,we,Ae)=>{const He=et(De),rt=Gr(He,H,at),fe=De.hidden===!0;if(!(wt(De)&&(Ar(He)||!fe&&He)))return null;const ye={...De,id:`${De.id}__${at}`,name:rt},Wt=k.properties?.linkedFieldAllowDuplicate?.[He]??!0;let Bt;if(!Wt&&(De.type==="select"||De.type==="radio"||De.type==="multiselect")){const lt=[],vt=Oe[He];vt!=null&&vt!==""&&(Array.isArray(vt)?lt.push(...vt.map(jr=>String(jr))):lt.push(String(vt))),z.filter(jr=>jr!==at).forEach(jr=>{const Kr=Gr(He,H,jr),zr=Oe[Kr];zr!=null&&zr!==""&&(Array.isArray(zr)?lt.push(...zr.map(qr=>String(qr))):lt.push(String(zr)))}),lt.length>0&&(Bt=[...new Set(lt)])}return c.jsx("div",{"data-field-name":rt,"data-form-renderer":"field-wrapper",children:c.jsx(un,{field:ye,value:Oe[rt],error:pe[rt]||je>0?te[rt]:void 0,onChange:lt=>xt(rt,lt),onBlur:()=>ze(rt),disabled:de||!Vt(He)||er||!!De.disabled,readOnly:sr(He,!!De.readOnly),isRequired:pn(He),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:M,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:rt,buttonResponses:we,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:Ae,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,scopedFormValues:Ve,scopedFieldNameMap:Le,excludedOptionValues:Bt,hideTableRowControls:x})},ye.id)};return c.jsx("div",{className:"space-y-3 mt-3",children:z.map((De,at)=>{const Ht={},Le={};Z.forEach(Bt=>{const lt=et(Bt),vt=Gr(lt,H,De);Ht[vt]=lt,Le[vt]=Oe[vt]});const Ve=da(Ht),we=ia(H,De,Z,Oe),Ae=Q?.heading!=null?bs(Q,at+1):null,He=ne[`${H}__${De}`],rt=He!=null?{...tr,documentId:He}:tr,fe=Z.map(Bt=>Ne(Bt,De,at,Ht,Le,Ve,rt)).filter(Boolean),ye=Ce?.section?.collapsible===!0,dt=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:we,title:we?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:Bt=>{Bt.preventDefault(),Bt.stopPropagation(),aa(H,De)},children:c.jsx(Go,{className:"h-5 w-5","aria-hidden":!0})}),Wt=c.jsxs(c.Fragment,{children:[!ye&&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 ",at+1]}),dt]}),fe]});return c.jsx("div",{className:"rounded-md border p-3 space-y-3",children:Ce?c.jsx(kc,{legend:Ce.section.heading?.enabled?bs(Ce.section,at+1):Ce.section.name,collapsible:Ce.section.collapsible,defaultCollapsed:Ce.section.defaultCollapsed,headerActions:ye?dt:void 0,onCollapsedChange:Bt=>Wc(Ce.section.id,De,Bt),children:Wt}):Wt},`${k.id}-${De}`)})})},[F,V,ne,et,mn,Gr,ia,Oe,pe,je,te,xt,ze,Vt,er,pn,Br,$e,_r,Nr,At,Dr,We,j,m,tr,br,qt,q.fields,be,Ar,wt,da,aa,x,Dt,oe,ee,M]);return c.jsx("div",{className:C?B("relative",d):B(ga,P&&"dark",d),style:xs,"data-form-renderer":C?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(Pn,{})}),c.jsx("form",{onSubmit:Nr,className:f?B("w-full min-w-0"):B("space-y-6 pb-[100px] w-full min-w-0",ea[Zi]),"data-form-renderer":"form","data-form-renderer-layout":F?"grid":"stack",children:c.jsxs(AN,{value:ta,children:[Er&&q.steps&&c.jsx(Nk,{steps:q.steps,currentStep:Te,completedSteps:Ue,onStepClick:ur}),c.jsx(_a.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:sP,gridTemplateColumns:`repeat(${Y}, 1fr)`,rowGap:he,columnGap:st},"data-form-renderer":"grid",children:oP.map(k=>Array.from({length:Y},(H,z)=>{const Z=Gc(k);if(!Z)return null;if(Rc(k,z))return c.jsx("div",{className:"min-w-0 min-h-0",style:{gridRow:Z,gridColumn:z+1,visibility:"hidden",pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`empty-${k}-${z}`);if(fT(k,z,xy,hn)){const we=pT(k,z,hn);return we&&mT(k,z,we,oa(we.run.section,we.addMoreMeta?.blockId))?null:c.jsx("div",{className:"min-w-0 min-h-0",style:{gridRow:Z,gridColumn:z+1,visibility:"hidden",pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`section-border-cover-${k}-${z}`)}const Q=hn.get(`${k}-${z}`);if(Q){const we=Q.renderFields.filter(lt=>Tr(lt));if(we.length===0)return null;const Ae=Q.addMoreMeta,He=Ae!=null?On.find(lt=>lt.addMoreFieldName===Ae.addMoreFieldName)?.linkedFields??[]:[],rt=Ae!=null?ia(Ae.addMoreFieldName,Ae.blockId,He,Oe):!1,fe=Q.run.section,Fe=Ae?.blockId,ye=oa(fe,Fe),dt=fe.collapsible&&ye?1:Q.rowSpan,Wt=Gc(Q.anchorRow,dt)??Z,Bt=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:rt,title:rt?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:lt=>{lt.preventDefault(),lt.stopPropagation(),aa(Ae.addMoreFieldName,Ae.blockId)},children:c.jsx(Go,{className:"h-5 w-5","aria-hidden":!0})}):void 0;return c.jsx("div",{className:B("min-h-0 min-w-0",!(fe.collapsible&&ye)&&"self-stretch"),style:{gridRow:Wt,gridColumn:`${z+1} / span ${Q.colSpan}`},"data-form-renderer":"grid-cell","data-form-renderer-config-section-border-cell":!0,children:c.jsx(kc,{legend:Q.legend,className:fe.collapsible&&ye?void 0:"h-full",collapsible:fe.collapsible,defaultCollapsed:fe.defaultCollapsed,headerActions:Bt,onCollapsedChange:lt=>Wc(fe.id,Fe,lt),children:c.jsx("div",{className:"grid w-full min-w-0",style:{gridTemplateColumns:`repeat(${Y}, 1fr)`,gridTemplateRows:`repeat(${Q.rowSpan}, minmax(${String(Tt).endsWith("px")?Tt:In}, auto))`,rowGap:he,columnGap:st},children:we.map(lt=>{const vt=et(lt),rr=Io.scopeByFieldName[vt],jr=rr?.scopedFieldNameMap?.[vt]||vt,Kr=(lt.position?.order??Q.anchorRow)-Q.anchorRow,zr=lt.position?.column??1,{rowSpan:qr,columnSpan:se}=gs([lt],Y),Ie=Ae!=null?ne[`${Ae.addMoreFieldName}__${Ae.blockId}`]:void 0,me=Ie!=null?{...tr,documentId:Ie}:tr;return c.jsx("div",{"data-field-name":vt,"data-form-renderer":"field-wrapper",className:"min-h-0 min-w-0",style:{gridRow:`${Kr+1} / span ${qr}`,gridColumn:`${zr} / span ${se}`,...xn(lt)},children:c.jsx(un,{field:Qn(lt),value:Oe[vt],error:pe[vt]||je>0?te[vt]:void 0,onChange:Ke=>xt(vt,Ke),onBlur:()=>ze(vt),disabled:(lt.type==="table"||lt.type==="billingGrid")&&a==="fill"?!1:de||!Vt(jr)||er||!!lt.disabled,readOnly:(lt.type==="table"||lt.type==="billingGrid")&&a==="fill"?!1:sr(jr,!!lt.readOnly),isRequired:pn(jr),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:M,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:vt,buttonResponses:rr?.scopedButtonResponses??$,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:me,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,onAddMore:Zn,scopedFormValues:rr?.scopedFormValues,scopedFieldNameMap:rr?.scopedFieldNameMap,excludedOptionValues:rr?.excludedOptionValues,hideTableRowControls:x})},lt.id)})})})},`section-border-${Q.run.section.id}-${k}-${z}-${Ae?.blockId??"base"}`)}const le=vg(k,z,Cs,Tr).filter(we=>!(et(we)?.includes("__addmore__")&&xy.has(`${k}-${z}`)));if(le.length===0){const we=As[`${k}-${z}`];if(we){const Ae=q.fields.find(fe=>fe.type==="addmore"&&et(fe)===we.addMoreFieldName),He=Ae!=null?mn(Ae):[],rt=ia(we.addMoreFieldName,we.blockId,He,Oe);return c.jsx("div",{className:"min-h-0 min-w-0 flex flex-col items-center justify-center",style:{gridRow:Z,gridColumn:z+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:rt,title:rt?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:fe=>{fe.preventDefault(),fe.stopPropagation(),aa(we.addMoreFieldName,we.blockId)},children:c.jsx(Go,{className:"h-5 w-5","aria-hidden":!0})})},`add-more-remove-${k}-${z}`)}return c.jsx("div",{className:"min-w-0",style:{pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`empty-${k}-${z}`)}const Ce=le[0],{rowSpan:Ne,columnSpan:De}=gs(le,Y),at=Gc(k,Ne)??Z;if(le.length===1&&Ce.type==="section"){const we=q.fields.filter(Ae=>Ae.parentId===Ce.id&&Ae.position!=null).sort((Ae,He)=>{const rt=typeof Ae.position?.order=="number"?Ae.position.order:0,fe=typeof He.position?.order=="number"?He.position.order:0;return rt-fe});return c.jsx("div",{className:"min-w-0 min-h-0 w-full overflow-hidden flex flex-col h-full",style:{gridRow:at,gridColumn:`${z+1} / span ${De}`,...xn(Ce)},"data-form-renderer":"grid-cell",children:c.jsx(Hh,{field:Ce,children:we.map(Ae=>{const He=Ae.name||Ae.key||Ae.id,rt=Ae.hidden===!0;return wt(Ae)&&(Ar(He)||!rt&&He)?c.jsx("div",{"data-field-name":He,"data-form-renderer":"field-wrapper",children:c.jsx(un,{field:Qn(Ae),value:Oe[He],error:pe[He]||je>0?te[He]:void 0,onChange:Fe=>xt(He,Fe),onBlur:()=>ze(He),disabled:de||!Vt(He)||er||!!Ae.disabled,readOnly:sr(He,!!Ae.readOnly),isRequired:pn(He),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:M,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:He,buttonResponses:$,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:tr,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,onAddMore:Zn,hideTableRowControls:x})},Ae.id):null})})},Ce.id)}const Ht=yg(le),Le=le.some(we=>["file","camera","photoChoice","addmore","table","billingGrid"].includes(we.type)),Ve=c.jsx("div",{className:B("flex min-h-0 w-full flex-1 gap-3",Ht==="row"?"flex-row items-stretch":"flex-col items-stretch"),children:le.map(we=>{const Ae=we.name||we.key||we.id,He=we.type==="sectionHeading",rt=Io.scopeByFieldName[Ae],fe=rt?.scopedFieldNameMap?.[Ae]||Ae,Fe=rt?.blockDocumentId!=null?{...tr,documentId:rt.blockDocumentId}:tr,ye=we.appearance?.hideLabel??we.properties?.hideLabel??!1,dt=we.type==="table"||we.type==="billingGrid"?we.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",jo(we),He&&"items-center justify-center",ye&&"items-center"),style:{...dt?{minWidth:dt}:{},...xn(we)},children:c.jsx(un,{field:Qn(we),value:Oe[Ae],error:pe[Ae]||je>0?te[Ae]:void 0,onChange:Wt=>xt(Ae,Wt),onBlur:()=>ze(Ae),disabled:(we.type==="table"||we.type==="billingGrid")&&a==="fill"?!1:de||!Vt(fe)||er||!!we.disabled,readOnly:(we.type==="table"||we.type==="billingGrid")&&a==="fill"?!1:sr(fe,!!we.readOnly),isRequired:pn(fe),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:M,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:Ae,buttonResponses:rt?.scopedButtonResponses??$,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:Fe,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,onAddMore:Zn,scopedFormValues:rt?.scopedFormValues,scopedFieldNameMap:rt?.scopedFieldNameMap,excludedOptionValues:rt?.excludedOptionValues,hideTableRowControls:x})},we.id)})});return c.jsx("div",{className:B(wd(le),"self-stretch",Le?"overflow-visible":"overflow-hidden"),style:{gridRow:at,gridColumn:`${z+1} / span ${De}`,...xn(le[0])},"data-form-renderer":"grid-cell","data-field-name":le.map(we=>we.name||we.key||we.id).join(","),children:Ve},le.map(we=>we.id).join("-"))}))}):c.jsx("div",{className:f?"":"space-y-4","data-form-renderer":"stack",children:kt.map(k=>{if(!Tr(k))return null;const H=iP.find(Z=>Z.kind==="border"&&Z.fields.some(Q=>Q.id===k.id));if(H)return H.fields[0]?.id!==k.id?null:c.jsx(kc,{legend:bs(H.run.section,0),collapsible:H.run.section.collapsible,defaultCollapsed:H.run.section.defaultCollapsed,onCollapsedChange:Z=>Wc(H.run.section.id,void 0,Z),children:H.fields.map(Z=>{const Q=et(Z);return!Q||!Tr(Z)?null:c.jsxs("div",{"data-field-name":Q,"data-form-renderer":"field-wrapper",style:xn(Z),children:[c.jsx(un,{field:Qn(Z),value:Oe[Q],error:pe[Q]||je>0?te[Q]:void 0,onChange:le=>xt(Q,le),onBlur:()=>ze(Q),disabled:(Z.type==="table"||Z.type==="billingGrid")&&a==="fill"?!1:de||!Vt(Q)||er||!!Z.disabled,readOnly:(Z.type==="table"||Z.type==="billingGrid")&&a==="fill"?!1:sr(Q,!!Z.readOnly),isRequired:pn(Q),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:M,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:Q,buttonResponses:$,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:tr,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,onAddMore:Zn,hideTableRowControls:x}),Z.type==="addmore"&&pa(Z)]},Z.id)})},`stack-border-${H.run.section.id}-${k.id}`);if(!k.parentId){const Z=kt.filter(le=>!le.parentId&&Tr(le)&&qi(le)===qi(k)),Q=Tc(Z).slice(0,2);if(Q.length>1&&Q[0].id!==k.id)return null;if(Q.length>1){const le=yg(Q);return c.jsx("div",{"data-form-renderer":"shared-cell-stack",className:B("flex w-full min-w-0 gap-3",le==="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:B("min-w-0 flex-1 flex flex-col",jo(Ce)),style:xn(Ce),children:[c.jsx(un,{field:Qn(Ce),value:Oe[Ne],error:pe[Ne]||je>0?te[Ne]:void 0,onChange:De=>xt(Ne,De),onBlur:()=>ze(Ne),disabled:(Ce.type==="table"||Ce.type==="billingGrid")&&a==="fill"?!1:de||!Vt(Ne)||er||!!Ce.disabled,readOnly:(Ce.type==="table"||Ce.type==="billingGrid")&&a==="fill"?!1:sr(Ne,!!Ce.readOnly),isRequired:pn(Ne),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:M,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:Ne,buttonResponses:$,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:tr,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,onAddMore:Zn,hideTableRowControls:x}),Ce.type==="addmore"&&pa(Ce)]},Ce.id)})},Q.map(Ce=>Ce.id).join("-"))}}if(k.type==="section"){const Z=q.fields.filter(Q=>Q.parentId===k.id&&Q.position!=null).sort((Q,le)=>{const Ce=typeof Q.position?.order=="number"?Q.position.order:0,Ne=typeof le.position?.order=="number"?le.position.order:0;return Ce-Ne});return c.jsx(Hh,{field:k,children:Z.map(Q=>{const le=Q.name||Q.key||Q.id,Ce=Q.hidden===!0;return wt(Q)&&(Ar(le)||!Ce&&le)?c.jsxs("div",{"data-field-name":le,"data-form-renderer":"field-wrapper",style:xn(Q),children:[c.jsx(un,{field:Qn(Q),value:Oe[le],error:pe[le]||je>0?te[le]:void 0,onChange:De=>xt(le,De),onBlur:()=>ze(le),disabled:de||!Vt(le)||er||!!Q.disabled,readOnly:sr(le,!!Q.readOnly),isRequired:pn(le),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:M,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:le,buttonResponses:$,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:tr,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,onAddMore:Zn,hideTableRowControls:x}),Q.type==="addmore"&&pa(Q)]},Q.id):null})},k.id)}const z=k.name||k.key||k.id;return c.jsxs("div",{"data-field-name":z,"data-form-renderer":"field-wrapper",style:xn(k),children:[c.jsx(un,{field:Qn(k),value:Oe[z],error:pe[z]||je>0?te[z]:void 0,onChange:Z=>xt(z,Z),onBlur:()=>ze(z),disabled:(k.type==="table"||k.type==="billingGrid")&&a==="fill"?!1:de||!Vt(z)||er||!!k.disabled,readOnly:(k.type==="table"||k.type==="billingGrid")&&a==="fill"?!1:sr(z,!!k.readOnly),isRequired:pn(z),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:M,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:z,buttonResponses:$,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:tr,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,onAddMore:Zn,hideTableRowControls:x}),k.type==="addmore"&&pa(k)]},k.id)})})}),u]})})]})})};function Lc(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function Mg(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}function xT(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 s=n.filter(l=>l!=null&&typeof l=="object"&&typeof l.order=="number"&&!isNaN(l.order));let i={};const a=r.config;if(a!=null)if(typeof a=="string")try{i=JSON.parse(a)}catch{}else typeof a=="object"&&a!==null&&(i={...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=s.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:s.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=Lc(p.appearance)),p.ui!==void 0&&(h.ui=Lc(p.ui)),p.visibility!==void 0&&(h.visibility=Lc(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,I={...m};if(A.fileSize!==void 0&&(I.maxSize=A.fileSize),A.fileType&&Array.isArray(A.fileType)){const T=[];A.fileType.forEach(W=>{const J=W.startsWith(".")?W:`.${W}`;T.push(J),J===".csv"?T.push("text/csv"):J===".xls"?T.push("application/vnd.ms-excel"):J===".xlsx"&&T.push("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")}),I.accept=T}h.metadata=I,I.maxSize!==void 0&&(h.maxSize=I.maxSize),I.accept!==void 0&&(h.accept=I.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,(I,T)=>{const W=t[T];return W!==void 0?String(W):I}),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 I=l.apidata.apiEndpoint;I=I.replace(/\{ctx:([^}]+)\}/g,(T,W)=>{const J=t[W];return J!==void 0?String(J):T}),A.apiEndpoint=I,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,v=Mg(y.position),w=l.metadata&&typeof l.metadata=="object"&&!Array.isArray(l.metadata)?l.metadata:{},x=Mg(y.layout),P={order:typeof y.positionOrder=="number"?y.positionOrder:l.order??f,column:typeof v.column=="number"?v.column:typeof y.positionColumn=="number"?y.positionColumn:1,columnSpan:typeof v.columnSpan=="number"?v.columnSpan:typeof v.width=="number"?v.width:typeof y.positionWidth=="number"?y.positionWidth:1,rowSpan:typeof v.rowSpan=="number"?v.rowSpan:typeof y.positionRowSpan=="number"?y.positionRowSpan:1},C=ko(v,{cellSlotIndex:y.cellSlotIndex??x.cellSlotIndex,stackSlot:w.stackSlot??x.stackSlot});typeof C=="number"&&(P.cellSlot=C);const N=v.cellGroupId??x.cellGroupId;typeof N=="string"&&(P.cellGroupId=N);const _=hs(v)??hs(x)??(w.stackDirection==="horizontal"||x.stackDirection==="horizontal"?"row":w.stackDirection==="vertical"||x.stackDirection==="vertical"?"stack":void 0);return(_==="row"||_==="stack")&&(P.sharedCellLayout=_),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:{...i,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 Yi(u)}var Xi="Tabs",[AT]=vr(Xi,[Li]),Lg=Li(),[CT,Dc]=AT(Xi),Dg=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,onValueChange:o,defaultValue:s,orientation:i="horizontal",dir:a,activationMode:d="automatic",...u}=e,l=ro(a),[f,p]=Zr({prop:n,onChange:o,defaultProp:s??"",caller:Xi});return c.jsx(CT,{scope:r,baseId:on(),value:f,onValueChange:p,orientation:i,dir:l,activationMode:d,children:c.jsx(Be.div,{dir:l,"data-orientation":i,...u,ref:t})})});Dg.displayName=Xi;var Bg="TabsList",$g=b.forwardRef((e,t)=>{const{__scopeTabs:r,loop:n=!0,...o}=e,s=Dc(Bg,r),i=Lg(r);return c.jsx(Om,{asChild:!0,...i,orientation:s.orientation,dir:s.dir,loop:n,children:c.jsx(Be.div,{role:"tablist","aria-orientation":s.orientation,...o,ref:t})})});$g.displayName=Bg;var jg="TabsTrigger",zg=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,disabled:o=!1,...s}=e,i=Dc(jg,r),a=Lg(r),d=Hg(i.baseId,n),u=Wg(i.baseId,n),l=n===i.value;return c.jsx(Im,{asChild:!0,...a,focusable:!o,active:l,children:c.jsx(Be.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,...s,ref:t,onMouseDown:Me(e.onMouseDown,f=>{!o&&f.button===0&&f.ctrlKey===!1?i.onValueChange(n):f.preventDefault()}),onKeyDown:Me(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&i.onValueChange(n)}),onFocus:Me(e.onFocus,()=>{const f=i.activationMode!=="manual";!l&&!o&&f&&i.onValueChange(n)})})})});zg.displayName=jg;var Ug="TabsContent",Vg=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,forceMount:o,children:s,...i}=e,a=Dc(Ug,r),d=Hg(a.baseId,n),u=Wg(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(xr,{present:o||l,children:({present:p})=>c.jsx(Be.div,{"data-state":l?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":d,hidden:!p,id:u,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0},children:p&&s})})});Vg.displayName=Ug;function Hg(e,t){return`${e}-trigger-${t}`}function Wg(e,t){return`${e}-content-${t}`}var ET=Dg,NT=$g,_T=zg,kT=Vg;function Rg({className:e,...t}){return c.jsx(ET,{"data-slot":"tabs",className:B("flex flex-col gap-2",e),...t})}function Gg({className:e,...t}){return c.jsx(NT,{"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 Kg({className:e,...t}){return c.jsx(_T,{"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 qg({className:e,...t}){return c.jsx(kT,{"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 TT({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 FT(){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 PT=3e4,OT=10*6e4,IT=9e4,MT=15*6e4;function LT(e){return e!=null&&"on_success"in e&&e.on_success!=null}function DT(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 Yg=({getWorkflowState:e,moduleId:t,tenantId:r,submissionContext:n,initialValues:o={},getAuthHeaders:s,onSuccess:i,bootstrapFeatureId:a,subjectUserId:d,viewStepId:u,clientId:l,className:f,onWorkflowSubmitResult:p,viewerContext:m,getViewerContext:g,dark:h=!1,themeVars:y})=>{const v=gn.useQueryClient(),w=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]),[E,P]=S.useState([]),[C,N]=S.useState(null),[_,A]=S.useState(null),[I,T]=S.useState(null),[W,J]=S.useState({}),O=S.useRef(null),j=S.useRef(null),M=S.useRef(null),D=S.useRef(null),L=S.useMemo(()=>E&&Array.isArray(E)?E.filter(ae=>ae.feature_id):[],[E]),U=gn.useQuery({queryKey:["workflow-steps",t,a??"",r??"",w[0],w[1],w[2]],queryFn:()=>e({...x,featureId:a}),staleTime:PT,gcTime:OT}),$=U.isPending,ie=U.error?U.error instanceof Error?U.error.message:"Failed to load workflow steps":null;S.useEffect(()=>{const ae=U.data;if(!ae||E.length>0)return;const ve=ae.steps&&Array.isArray(ae.steps)?ae.steps:[];P(ve);const Ye=ve.filter(ct=>ct.feature_id);if(Ye.length>0){const ct=ae.current_step_id,Ge=ct&&Ye.some(Kt=>Kt.step_id===ct);N(Ge?ct:Ye[0].step_id)}},[U.data,E.length,a]);const V=S.useMemo(()=>{if(!C)return;const ae=E.find(Ye=>Ye.step_id===C),ve=O.current===C;return ae?.feature_id??(ve?D.current:void 0)??void 0},[C,E]),K=gn.useQuery({queryKey:["workflow-step",t,V??"",r??"",w[0],w[1],w[2]],queryFn:()=>e({...x,featureId:V}),enabled:!!V,staleTime:IT,gcTime:MT,refetchOnWindowFocus:!0,refetchOnReconnect:!0}),X=K.isPending,ce=K.error?K.error instanceof Error?K.error.message:"Failed to load form":null;S.useEffect(()=>{!K.data||O.current===C||(A(K.data),T(null),O.current=null,D.current=null)},[K.data,C]),S.useEffect(()=>{T(ce)},[ce]),S.useEffect(()=>{V===void 0&&O.current!==C&&(A(null),T(null),O.current=null,D.current=null)},[V,C]);const ne=S.useMemo(()=>{const ae=_?.form;if(!ae)return null;const ve=(r??Tn()??"").trim()||"default",Ye=Pg({scope:ve,formId:ae._id,version:ae.version});return Ye?.value?Ye.value:xT(_,n)},[_,n,r]),G=S.useMemo(()=>{const ae=_?.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 Ye=s?.()??{},ct={...ae.headers||{},"Content-Type":"application/json",...Ye};return{...ae,url:ve,headers:ct}},[_?.BFF_submit_api,s]),ee=S.useMemo(()=>ne?{...ne,status:"published",...G&&{BFF_submit_api:G}}:null,[ne,G]);S.useEffect(()=>{if(!ne?.id)return;const ae=(r??Tn()??"").trim()||"default";Og({scope:ae,formId:ne.id,version:ne.version},ne)},[ne,r]);const Pe=S.useMemo(()=>{if(!ne)return null;const ae=_s({config:ne.config,layout:ne.layout},null);if(!ae)return null;const ve=ae.rows,Ye=ae.columns,ct={verticalSpacing:ae.verticalSpacing??ae.spacing??"16px",horizontalSpacing:ae.horizontalSpacing??ae.spacing??"16px",rowHeight:ae.rowHeight??In};let Ge=1;if(Array.isArray(ne.fields))for(const Je of ne.fields){const q=Je?.position,$e=typeof q?.order=="number"?q.order:0,gt=typeof q?.rowSpan=="number"?q.rowSpan:1;Ge=Math.max(Ge,$e+gt)}return{rows:Math.min(ve,Math.max(1,Ge)),columns:Ye,verticalSpacing:ct.verticalSpacing,horizontalSpacing:ct.horizontalSpacing,rowHeight:ct.rowHeight}},[ne]),oe=S.useMemo(()=>{const ve=ee?.config?.theme?.cssVariables;if(!(!ve&&!y))return{...ve??{},...y??{}}},[ee?.config,y]),re=S.useCallback(()=>{v.invalidateQueries({queryKey:["workflow-steps",t]}),v.invalidateQueries({queryKey:["workflow-step",t]})},[v,t]),be=S.useCallback(ae=>{if(LT(ae)){const Ge=ae.on_success,Kt=Ge?.action;if(Kt==="redirect"&&Ge?.redirect_url){const Je=DT(Ge.redirect_url.trim(),n);window.location.href=Je;return}if(Kt==="move"){const Je=Ge?.next_step_id,q=Ge?.next_step_form;if(Je&&q){O.current=null,D.current=null;const $e=q.featureId??Ge?.next_step_form_id??q._id;v.removeQueries({queryKey:["workflow-step",t,$e,r??"",w[0],w[1],w[2]]}),re(),P(gt=>gt.some(te=>te.step_id===Je)?gt:[...gt,{step_id:Je,step_name:q.name||"Next step",feature_id:$e}]),A(null),N(Je),i?.();return}return}if(Kt==="stay"){re(),i?.();return}}const ve=ae;ve.steps&&Array.isArray(ve.steps)&&P(ve.steps);const Ye=(ve.steps&&Array.isArray(ve.steps)?ve.steps:E).filter(Ge=>Ge.feature_id),ct=ve.current_step_id;ct&&Ye.some(Ge=>Ge.step_id===ct)?N(ct):Ye.length>0&&N(Ye[0].step_id),A(null),re(),i?.(),p?.(ve)},[v,t,r,i,p,E,n,w,re]),de=S.useCallback(async ae=>_?.BFF_submit_api?(i?.(),{success:!0,message:"Saved successfully"}):{success:!1,message:"Submit not configured"},[_?.BFF_submit_api,i]),ot=S.useCallback((ae,ve)=>{},[]),Se=S.useCallback(ae=>{},[]);if($)return c.jsx(TT,{className:f});if(ie)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:ie});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 xe=_?.step_blocked_message;return c.jsx("div",{className:B(ga,h&&"dark","flex flex-col gap-4",f),style:oe,"data-form-renderer":"workflow-steps-view",children:c.jsxs(Rg,{value:C??"",onValueChange:ae=>N(ae),children:[c.jsx(Gg,{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(Kg,{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(qg,{value:ae.step_id,className:"mt-4 outline-none",children:ae.step_id!==C?null:X?c.jsx(FT,{}):I?c.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:I}):xe&&!_?.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:xe}):ee?.fields?.length?c.jsxs("div",{className:"py-4 [&_*]:box-border",children:[xe?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:xe}):null,(()=>{const ve=j.current!==C||M.current!==(ee?.id??null);if(C&&ee&&ve){j.current=C,M.current=ee.id??null;const Ye=Nt.getState();Ye.setSchema(ee,{forceReset:!0});const ct=Nt.getState().values;Ye.setValues({...ct,...o})}return null})(),c.jsx(Mc,{schema:ee,gridLayout:Pe,omitRootWrapper:!0,submissionContext:n,initialValues:o,workflowStepId:C??void 0,viewerContext:m,getViewerContext:g,onSubmit:de,onChange:ot,onValidationError:Se,onClose:()=>{},mode:"fill",unstyled:!0,onWorkflowSubmitResult:be,initialExtraSubmitPayload:Object.keys(W).length>0?W:void 0,onExtraSubmitPayloadChange:ve=>{if(ve&&typeof ve=="object"){const Ye={};ve.context_user_id!=null&&(Ye.context_user_id=ve.context_user_id),ve.id!=null&&(Ye.id=ve.id),ve.batch_id!=null&&(Ye.batch_id=ve.batch_id),ve.admission_batch_id!=null&&(Ye.admission_batch_id=ve.admission_batch_id),ve.program_id!=null&&(Ye.program_id=ve.program_id),Object.keys(Ye).length>0&&J(ct=>({...ct,...Ye}))}}},ee.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 BT(e){return typeof e=="object"&&e!==null&&"apiEndpoint"in e}function $T({formSchema:e}){const t=S.useMemo(()=>{if(!e)return[];const s=[];(!e.name||e.name.trim()==="")&&s.push({id:"form-name-required",type:"error",message:"Form name is required"});const i=new Set,a=new Set;e.fields.forEach((l,f)=>{const p=`field-${l.id}`;if(a.has(l.id)&&s.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&&i.has(l.name)&&s.push({id:`${p}-duplicate-name`,type:"error",message:`Field "${l.label||l.name}" has a duplicate name: "${l.name}"`,fieldId:l.id}),l.name&&i.add(l.name),(!l.label||l.label.trim()==="")&&s.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()==="")&&s.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)&&s.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)&&s.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)||s.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 v=e.fields.find(w=>w.id===h);return v?.parentId?g(v.parentId,y):!1};l.parentId&&g(l.id,new Set)&&s.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"))||s.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&&s.push({id:`row-${f}-too-many-fields`,type:"warning",message:`Row ${f+1} has ${l.length} fields (maximum recommended is 3)`})}),s},[e]),r=S.useMemo(()=>t.filter(s=>s.type==="error"),[t]),n=S.useMemo(()=>t.filter(s=>s.type==="warning"),[t]),o=S.useMemo(()=>r.length===0,[r]);return{issues:t,errors:r,warnings:n,isValid:o}}function jT({field:e,value:t,allValues:r,validateOnChange:n=!1,validateOnBlur:o=!0,debounceMs:s=Pk}){const[i,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 v;for(const w of e.validation){const x=Yr(t,w,r);if(typeof x=="string"){v=x;break}}return a(v),u(!1),v},[e.validation,t,r]),m=S.useCallback(()=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{p()},s)},[p,s]);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(v=>{a(v)},[]);return{error:i,isValidating:d,validate:p,handleBlur:g,clearError:h,setCustomError:y}}const Xg="—";function Xt(){return{kind:"static",value:Xg}}function zT(){return{currencySymbol:"₹",emptyDisplay:Xg,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:Xt(),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:Xt(),service:{kind:"api",path:"service"},unit_price:{kind:"api",path:"unit_price"},discount_pct:Xt(),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:Xt(),unit_price:{kind:"formula",expression:"SUM('unit_price', 'data')"},discount_pct:Xt(),discount_amount:{kind:"formula",expression:"SUM('discount_amount', 'data')"},net_price:{kind:"formula",expression:"SUM('net_price', 'data')"},tax_pct:Xt(),total:{kind:"formula",expression:"SUM('total', 'data')"}}}},{kind:"static",row:{id:"invoice_discount",label:"Invoice discount",cells:{tariff_type:{kind:"label"},service:Xt(),unit_price:Xt(),discount_pct:Xt(),discount_amount:{kind:"input",inputType:"number"},net_price:Xt(),tax_pct:Xt(),total:Xt()}}},{kind:"static",row:{id:"grand_total",label:"Grand total",cells:{tariff_type:{kind:"label"},service:Xt(),unit_price:Xt(),discount_pct:Xt(),discount_amount:Xt(),net_price:Xt(),tax_pct:Xt(),total:{kind:"formula",expression:"SUM('total', 'data') - cellInRow('invoice_discount', 'discount_amount')"}}}}]}}const UT={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:zT()}},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"}}}},Jg={padding:"md",showBorder:!1};function Qg(e,t){const r="full";return e?{padding:e.padding??Jg.padding,maxWidth:e.maxWidth??r,showBorder:e.showBorder??Jg.showBorder}:{padding:"md",maxWidth:r,showBorder:!1}}function VT(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 HT(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 WT(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 RT(e){const t=Qg(e.container,e.layout);return B(WT(e.layout),HT(t.maxWidth,e.layout),VT(t.padding),t.showBorder&&"rounded-lg border border-border")}const Ji=1;function GT(){return{version:Ji,layout:"stack",container:{padding:"md",maxWidth:"full",showBorder:!1},dataBindings:[],widgets:[],filterGroups:[]}}function Zg(e){return{...e,config:e.config??{},children:Array.isArray(e.children)?e.children.map(Zg):void 0}}function KT(e){return{version:Ji,layout:e.layout??"stack",container:Qg(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(Zg):[],filterGroups:Array.isArray(e.filterGroups)?e.filterGroups:[],eventHandlers:e.eventHandlers??[],navigation:e.navigation}}function qT(e){const t=e;return!t||typeof t!="object"?GT():(t.version!==Ji&&(t.version=Ji),KT(t))}const ey={};let ty=null;function YT(e){ty=e}function XT(){return(ey?.VITE_API_BASE_URL?.trim()||ey?.VITE_API_URL?.trim()||"").replace(/\/$/,"")}const vs=_t.create({baseURL:XT()});vs.interceptors.request.use(e=>{const t=Tn();t&&(e.params={...e.params,clientId:t}),typeof FormData<"u"&&e.data instanceof FormData&&delete e.headers["Content-Type"];let r=ty?.();if((!r||Object.keys(r).length===0)&&(r=Ml()),r){const n=e.headers??{};for(const[o,s]of Object.entries(r))s!==void 0&&s!==""&&(n[o]=s);e.headers=n}return e});async function ry(e){const t=await vs.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 Bc(e,t,r){const n=await vs.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 $c(e){const{clientId:t,api:r,context:n,filterState:o}=e,s=await vs.post(`/api/page-builder/clients/${t}/data-sources/execute`,{api:r,context:n,filterState:o});return s.data?.data??s.data}function JT(e,t){if(!t)return{};const r={};for(const[n,o]of Object.entries(t)){if(!o.trim())continue;const s=Qe(e,o);s!==void 0&&(r[n]=s)}return r}const ny=S.createContext(null);function oy(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 QT({schema:e,context:t={},clientId:r,nestingDepth:n=0,onAction:o,getWorkflowState:s,parentContext:i,children:a}){const[d,u]=S.useState(()=>i?i.filterGroups:{}),l=S.useRef(d);l.current=d;const[f,p]=S.useState({}),m=S.useRef(null),g=String(r??t.clientId??i?.clientId??""),h=JSON.stringify(t);S.useEffect(()=>{if(i)return;const C=e.prepopulateApi;if(!C?.enabled||!C.api?.path||!g){p({}),m.current=null;return}const N=JSON.stringify({path:C.api.path,method:C.api.method,mapping:C.contextMapping,bindings:e.dataBindings,context:h});if(m.current===N)return;let _=!1;return m.current=N,(async()=>{try{const A=oy(e.dataBindings??[],t),I={...t,...A},T=await $c({clientId:g,api:C.api,context:I});if(_)return;const W=JT(T,C.contextMapping);p({...W,prepopulateResponse:T})}catch{_||p({})}})(),()=>{_=!0}},[i,e.prepopulateApi,e.dataBindings,h,g]);const y=S.useMemo(()=>{if(i)return{...i.context,...t};const C=oy(e.dataBindings??[],t);return{...t,...C,...f}},[i,t,e.dataBindings,f]),v=String(r??y.clientId??i?.clientId??""),w=S.useCallback((C,N,_)=>{u(A=>({...A,[C]:{...A[C]??{},[N]:_}}))},[]),x=S.useCallback(C=>l.current[C]??{},[]),E=S.useCallback((C,N,_,A)=>{(o??i?.onAction)?.({...C,sourceWidgetId:N,event:_,payload:A})},[o,i?.onAction]),P=S.useMemo(()=>({schema:e,context:y,clientId:v,nestingDepth:n,onAction:o??i?.onAction,getWorkflowState:s??i?.getWorkflowState,filterGroups:d,setFilterValue:w,getFilterGroup:x,dispatchAction:E}),[e,y,v,n,o,i?.onAction,s,i?.getWorkflowState,d,w,x,E]);return c.jsx(ny.Provider,{value:P,children:a})}function Lr(){const e=S.useContext(ny);if(!e)throw new Error("usePageContext must be used within PageContextProvider");return e}const ZT=5,sy=1;function Fo(e){return Number.isFinite(e)?Math.min(ZT,Math.max(sy,Math.round(e))):sy}function eF(e,t){const r=Fo(t),n=Array.from({length:r},()=>[]);return e.forEach((o,s)=>{const i=o.config,a=i.columnIndex!==void 0?Math.min(Math.max(0,i.columnIndex),r-1):s%r;n[a].push(o)}),n}function tF(e){return Number.isFinite(e)?Math.min(100,Math.max(0,Math.round(e))):0}function rF(e,t){const r=Math.max(1,t),n=Math.min(100,Math.max(0,Math.round(e))),o=Math.floor(n/r),s=n-o*r;return Array.from({length:r},(i,a)=>o+(a<s?1:0))}function iy(e){return rF(100,Fo(e))}function nF(e){const t=e.trim(),r=/^(\d+(?:\.\d+)?)\s*%?$/.exec(t);return r?tF(Number(r[1])):null}function ay(e,t){const r=Fo(t),n=[];for(let s=0;s<r;s++){const i=nF(e?.[s]??"");if(i===null)return iy(r);n.push(i)}return n.reduce((s,i)=>s+i,0)!==100?iy(r):n}function oF(e){return e==="sm"?"gap-2":e==="lg"?"gap-6":"gap-4"}function ly(e,t){return ay(t,Fo(e)).map(n=>`minmax(0, ${n}fr)`).join(" ")}function sF(e){return e.length?e.map(t=>`minmax(0, ${t}fr)`).join(" "):"minmax(0, 1fr)"}function iF(e,t,r,n){const o=Fo(t),s=eF(e,o),i=ay(r,o);if(!(n?.collapseEmpty!==!1))return{columns:s,gridTemplate:ly(o,r),sourceIndices:s.map((p,m)=>m)};const d=s.map((p,m)=>({colChildren:p,index:m,percent:i[m]??0})).filter(p=>p.colChildren.length>0);if(d.length===0||d.length===s.length)return{columns:s,gridTemplate:ly(o,r),sourceIndices:s.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:sF(l),sourceIndices:d.map(p=>p.index)}}function jc(e,t="solid"){return e?t==="dashed"?"rounded-md border border-dashed border-border":"rounded-md border border-border":""}function aF(e){return B(jc(e.showBorder,e.borderStyle??"solid"),e.showBorder&&"p-3")}function lF(e){return B(jc(e.showBorder,e.borderStyle??"solid"),e.showBorder&&"p-2")}function cF(e,t){return e.columnBorders?.[t]!==void 0?!!e.columnBorders[t]:!!e.showColumnBorders}function dF(e,t){const r=cF(e,t);return B(jc(r,e.borderStyle??"dashed"),r&&"p-2")}function uF(e){if(e)return{minHeight:`${e}vh`}}function fF({widget:e,renderChildren:t}){const r=e.config,[n,o]=S.useState(r.defaultCollapsed??!1);return c.jsxs("section",{className:B("space-y-4",aF(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(s=>!s),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 pF({widget:e,renderChildren:t}){const r=e.config,n=Fo(r.columns??2),o=r.collapseEmptyColumns!==!1,s=iF(e.children??[],n,r.columnWidths,{collapseEmpty:o});return c.jsx("div",{className:B("grid w-full min-w-0 items-stretch",oF(r.gap),lF(r)),style:{gridTemplateColumns:s.gridTemplate,...uF(r.minHeightPercent)},"data-widget-id":e.id,children:s.columns.map((i,a)=>{const d=s.sourceIndices[a]??a;return c.jsx("div",{className:B("flex min-h-[inherit] min-w-0 flex-col space-y-4 overflow-hidden",dF(r,d)),children:t?.(i)},d)})})}function mF({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 cy(e,t){if(e.variable){const r=t[e.variable];return r!=null?String(r):e.fallback??e.text??""}return e.text??""}function hF({widget:e}){const t=e.config,{context:r}=Lr(),n=cy(t,r),o=t.level??2,s=t.align==="center"?"text-center":t.align==="right"?"text-right":"text-left",i=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",i,s),"data-widget-id":e.id,children:n})}function gF({widget:e}){const t=e.config,{context:r}=Lr(),n=cy(t,r),o=t.preset==="caption"?"text-sm text-muted-foreground":t.preset==="small"?"text-xs text-muted-foreground":"text-base",s=t.align==="center"?"text-center":t.align==="right"?"text-right":"text-left";return c.jsx("p",{className:B(o,s),"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(),s=t[o];return s==null?"":String(s)})}function dy(e,t){const r={...e};for(const[n,o]of Object.entries(r))typeof o=="string"&&(r[n]=yF(o,t));return r}function bF(e,t){return e.replace(/\{\{([^}]+)\}\}/g,(r,n)=>{const o=t[n.trim()];return o!=null?String(o):""})}function uy(e,t,r,n){if(e.type==="navigate"){const o=bF(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?dy(e.params,t):void 0},n,"click");return}if(e.type==="workflow"&&e.workflowId){r(e,n,"click");return}r(e,n,"click")}function vF({widget:e}){const t=e.config,{context:r,dispatchAction:n}=Lr();return c.jsx(Yt,{variant:t.variant??"default",size:t.size??"default","data-widget-id":e.id,onClick:()=>uy(t.action,r,n,e.id),children:t.label})}const wF={start:"justify-start",center:"justify-center",end:"justify-end","space-between":"justify-between"},SF={sm:"gap-2",md:"gap-3",lg:"gap-4"};function xF({widget:e}){const t=e.config,{context:r,dispatchAction:n}=Lr(),o=t.buttons??[];return c.jsx("div",{className:B("flex flex-wrap items-center",wF[t.align??"start"],SF[t.gap??"sm"],t.wrap===!1&&"flex-nowrap"),"data-widget-id":e.id,children:o.map(s=>c.jsx(Yt,{variant:s.variant??"outline",size:s.size??"default","data-widget-id":e.id,"data-button-id":s.id,onClick:()=>uy(s.action,r,n,e.id),children:s.label},s.id))})}function fy(e,t){if(e.mode==="pageApi"&&e.dataSourceRef)return t[e.dataSourceRef];if(e.mode==="api")return e.api}function py({widgetId:e,dataSource:t,enabled:r=!0,page:n,pageSize:o,search:s}){const{schema:i,context:a,clientId:d,getFilterGroup:u}=Lr(),l=S.useMemo(()=>t.filterGroupKey?u(t.filterGroupKey):{},[t.filterGroupKey,u]),f=S.useMemo(()=>["page-ds",e,t,a,l,n,o,s],[e,t,a,l,n,o,s]);return gn.useQuery({queryKey:f,enabled:r&&(!!d||t.mode==="static"),staleTime:fy(t,i.dataApis??{})?.staleTimeMs??3e4,queryFn:async()=>{if(t.mode==="static")return t.staticData;if(t.mode==="context")return Qe(a,t.contextPath??"");const p=fy(t,i.dataApis??{});if(!p)throw new Error(`No API config for data source on widget ${e}`);const m={...a};if(t.requestBindings)for(const y of t.requestBindings){let v;y.source==="binding"?v=a[y.key]:y.source==="filter"&&(v=l[y.key]),v!==void 0&&(m[y.param]=v)}const h={...dy(m,a),...n!==void 0?{page:n,pageSize:o,search:s}:{}};return $c({clientId:d,api:p,context:h,filterState:l})}})}function zc(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 ws(e,t){const r=Qe(e,t.path);return r==null?t.fallback??r:t.formatter?zc(r,t.formatter):r}function AF(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 CF={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"},EF={rectangle:"rounded-lg",square:"aspect-square rounded-lg",circle:"aspect-square rounded-full"},NF={sm:"p-2 text-xs",md:"p-4 text-sm",lg:"p-6 text-base"},Uc={sm:"text-lg",md:"text-2xl",lg:"text-3xl"},_F={sm:"gap-2",md:"gap-3",lg:"gap-4"};function kF({title:e,value:t,trend:r,variant:n="default",shape:o="rectangle",size:s="md",layout:i="vertical",isLoading:a,isError:d}){const u=i==="horizontal";return c.jsxs("div",{className:B(CF[n??"default"],EF[o??"rectangle"],NF[s??"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(Pn,{className:"my-2"}):d?c.jsx("p",{className:B("font-bold text-destructive",Uc[s??"md"]),children:"Error"}):c.jsx("p",{className:B("font-bold",u?Uc[s??"md"]:`mt-1 ${Uc[s??"md"]}`),children:String(t)}),u&&r!==null&&r!==void 0&&r!==""&&c.jsx("p",{className:"text-xs text-muted-foreground",children:String(r)})]})}function my({stat:e,widgetId:t}){const{data:r,isLoading:n,isError:o}=py({widgetId:t,dataSource:e.dataSource}),i=(()=>{if(r==null)return e.valueMapping.fallback??"—";if(e.dataSource.mode==="context"){const d=r;return e.valueMapping.formatter?zc(d,e.valueMapping.formatter):d}if(e.dataSource.mode==="static"){const d=e.valueMapping.path?.trim()||"value",u=ws(r,{...e.valueMapping,path:d});if(u!=null)return e.valueMapping.formatter?zc(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 ws(r,e.valueMapping)})(),a=e.trendMapping&&r!==void 0&&e.dataSource.mode!=="context"?ws(r,e.trendMapping):e.trendMapping&&e.dataSource.mode==="context"&&e.trendMapping.path?ws({value:r},e.trendMapping):null;return c.jsx(kF,{title:e.title,value:i,trend:a,variant:e.variant,shape:e.shape,size:e.size,layout:e.layout,isLoading:n,isError:o})}function TF({widget:e}){const t=e.config;return c.jsx("div",{"data-widget-id":e.id,children:c.jsx(my,{stat:t,widgetId:e.id})})}function FF({stat:e,widgetId:t}){return c.jsx(my,{stat:e,widgetId:`${t}-${e.id}`})}function PF({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",_F[t.gap??"md"]),children:r.map(s=>c.jsx(FF,{stat:s,widgetId:e.id},s.id))})}function OF({widget:e}){const t=e.config,{setFilterValue:r}=Lr(),[n,o]=S.useState("");return S.useEffect(()=>{const s=t.debounceMs??300,i=setTimeout(()=>{r(t.filterGroupKey,"search",n)},s);return()=>clearTimeout(i)},[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:s=>o(s.target.value),"data-widget-id":e.id})}function IF(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 MF({widget:e}){const t=e.config,{dispatchAction:r}=Lr(),[n,o]=S.useState(1),[s,i]=S.useState(""),a=t.pagination?.pageSize??10,{data:d,isLoading:u,isError:l}=py({widgetId:e.id,dataSource:t.dataSource,page:n,pageSize:a,search:t.search?.enabled?s:void 0}),f=t.dataSource.mode==="pageApi"?void 0:t.dataSource.api?.itemsPath,p=IF(d,f??"data.items"),m=(g,h)=>{const y=t.dataSource.responseMapping.find(v=>v.target===h);return y?ws(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:s,onChange:g=>{i(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(Pn,{})})}):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 LF=75;function DF(e){return e??LF}function Vc({scrollBehavior:e="page",maxHeightPercent:t,children:r,className:n}){if(e!=="contained")return c.jsx(c.Fragment,{children:r});const o=DF(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 BF(e,t,r){return["embedded-form",e,t,r??"latest"]}async function $F(e,t){try{const r=await dn.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 jF(e,t,r){const n=r!==void 0?`/api/form-builder/forms/${e}/render?version=${r}`:`/api/form-builder/forms/${e}/render`,o=await dn.get(n,{params:{clientId:t}}),i=o.data?.data??o.data,a=i.form??i,d=i.fields??a.fields??[];let u=i.layout??a.layout??null;(!u||typeof u.columns!="number")&&(u=await $F(e,t));const l=i.rules??a.rules??[],f=ms(a,d,u,l),p=_s({config:f.config,layout:f.layout},Ns(u))??Ns(u);return{schema:f,gridLayout:p}}const zF=300*1e3;function hy({formId:e,mode:t="fill",contextFieldMapping:r,pageContext:n,clientId:o,formVersion:s,scrollBehavior:i,maxHeightPercent:a}){const{data:d,isLoading:u,isError:l,error:f}=gn.useQuery({queryKey:BF(e,o,s),queryFn:()=>jF(e,o,s),staleTime:zF}),p=S.useMemo(()=>AF(n,r),[n,r]);return u?c.jsx(Vc,{scrollBehavior:i,maxHeightPercent:a,children:c.jsx(Pn,{})}):l?c.jsx(Vc,{scrollBehavior:i,maxHeightPercent:a,children:c.jsx("p",{className:"text-sm text-destructive",children:f instanceof Error?f.message:"Failed to load form"})}):d?.schema?c.jsx(Vc,{scrollBehavior:i,maxHeightPercent:a,children:c.jsx(Mc,{schema:d.schema,mode:t,gridLayout:d.gridLayout,initialValues:p,submissionContext:n})}):null}function UF({widget:e}){const t=e.config,{context:r,clientId:n}=Lr();return t.formId?c.jsx(hy,{formId:t.formId,mode:t.mode??"fill",contextFieldMapping:t.contextFieldMapping,pageContext:r,clientId:n,scrollBehavior:t.scrollBehavior,maxHeightPercent:t.maxHeightPercent}):c.jsx("p",{className:"text-sm text-muted-foreground",children:"No form configured"})}function VF({widget:e}){const t=e.config,{context:r,getWorkflowState:n,clientId:o}=Lr(),s=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(!s)return c.jsx("p",{className:"text-sm text-destructive","data-widget-id":e.id,children:"moduleId required in page context for workflow embed"});const i={};if(t.contextVariableMapping)for(const[a,d]of Object.entries(t.contextVariableMapping)){const u=r[d];u!=null&&(i[a]=String(u))}return c.jsx(Yg,{getWorkflowState:n,moduleId:s,tenantId:r.tenantId?String(r.tenantId):void 0,clientId:o||void 0,submissionContext:i})}function HF({widget:e}){const t=e.config,{schema:r,dispatchAction:n}=Lr(),o=t.previousPage??r.navigation?.previousPage,s=t.nextPage??r.navigation?.nextPage,i=t.showPrevious!==!1&&!!o,a=t.showNext!==!1&&!!s,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:[i&&o&&c.jsx(Yt,{variant:"outline",size:"sm",onClick:()=>l(o),children:o.label??"Previous"}),a&&s&&c.jsx(Yt,{variant:"default",size:"sm",onClick:()=>l(s),children:s.label??"Next"})]})]})}function WF(e,t){return e?.length?e.filter(r=>r.config.tabId===t):[]}const RF=1;function GF(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 KF(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 qF(e,t,r){return e?new Set(r?[r]:[]):new Set(t.map(n=>n.id))}function YF({tab:e,shouldRender:t,pageContext:r,clientId:n}){return t?e.formId?c.jsx(hy,{formId:e.formId,mode:e.formMode??"fill",contextFieldMapping:e.contextFieldMapping,pageContext:r,clientId:n,scrollBehavior:e.scrollBehavior,maxHeightPercent:e.maxHeightPercent}):c.jsx("p",{className:"text-sm text-muted-foreground",children:"No form configured for this tab"}):null}function XF({tab:e,shouldLoad:t,shouldRender:r,nestingDepth:n,pageContext:o,clientId:s,onAction:i,getWorkflowState:a}){const d=Lr(),{data:u,isLoading:l,isError:f,error:p}=gn.useQuery({queryKey:["tab-page",e.pageId,e.pageVersion,s],enabled:t&&!!e.pageId,queryFn:async()=>Bc(e.pageId,s,e.pageVersion)});return r?n>=RF?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(Pn,{}):f?c.jsx("p",{className:"text-sm text-destructive",children:p instanceof Error?p.message:"Failed to load page"}):u?c.jsx(Hc,{page:u,context:o,nestingDepth:n+1,inheritContext:!0,onAction:i,getWorkflowState:a,parentContext:d}):null:c.jsx("p",{className:"text-sm text-muted-foreground",children:"No page configured for this tab"}):null}function JF({tab:e,widgetChildren:t,renderChildren:r}){const n=WF(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 QF({widget:e,renderChildren:t}){const r=e.config,{context:n,clientId:o,nestingDepth:s,onAction:i,getWorkflowState:a}=Lr(),d=r.tabs??[],u=r.defaultTabId??d[0]?.id??"",l=r.lazyLoad!==!1,[f,p]=S.useState(u),[m,g]=S.useState(()=>qF(l,d,u)),h=v=>{g(w=>new Set(w).add(v)),p(v)},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(Rg,{value:f,onValueChange:h,className:"w-full","data-widget-id":e.id,children:[c.jsx(Gg,{className:B("mb-4",GF(r.variant)),children:d.map(v=>c.jsx(Kg,{value:v.id,disabled:v.disabled,className:KF(r.variant),children:v.label},v.id))}),d.map(v=>{const w=m.has(v.id),x=y||w,E=y||w;return c.jsxs(qg,{value:v.id,forceMount:y||void 0,className:B("mt-0",y&&"data-[state=inactive]:hidden"),children:[v.contentType==="widgets"&&E&&c.jsx(JF,{tab:v,widgetChildren:e.children??[],renderChildren:t}),v.contentType==="form"&&c.jsx(YF,{tab:v,shouldRender:x,pageContext:n,clientId:o}),v.contentType==="page"&&c.jsx(XF,{tab:v,shouldLoad:x,shouldRender:E,nestingDepth:s,pageContext:n,clientId:o,onAction:i,getWorkflowState:a})]},v.id)})]})}const ZF={section:fF,columns:pF,card:mF,tab_group:QF,heading:hF,text:gF,button:vF,button_group:xF,stat_card:TF,stat_grid:PF,data_table:MF,search_filter:OF,form_embed:UF,workflow_embed:VF,page_nav:HF};function eP({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 tP({widget:e,renderChildren:t}){const r=ZF[e.type]??eP;return c.jsx(r,{widget:e,renderChildren:t})}function gy(e,t){return e.map(r=>c.jsx(tP,{widget:r,renderChildren:t},r.id))}function Hc({page:e,context:t={},onAction:r,chrome:n="none",className:o,nestingDepth:s=0,getWorkflowState:i,inheritContext:a=!1,parentContext:d}){const u=S.useMemo(()=>qT(e.schema),[e.schema]),l=p=>gy(p,l),f=c.jsxs("div",{className:B("studio-page-content min-h-0 min-w-0",RT(u),o),"data-page-id":e.id,"data-nesting-depth":s,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:gy(u.widgets,l)})]});return a&&d?f:c.jsx(QT,{schema:u,context:t,clientId:String(t.clientId??""),nestingDepth:s,onAction:r,getWorkflowState:i,parentContext:d,children:f})}function rP({clientId:e,tenantId:t,moduleId:r,featureId:n,pageId:o,routePath:s,routeParams:i={},isDefault:a,context:d={},version:u,chrome:l="none",onAction:f,getWorkflowState:p}){const m=S.useMemo(()=>({...i,...d,clientId:e,tenantId:t,moduleId:r,featureId:n}),[i,d,e,t,r,n]),{data:g,isLoading:h,isError:y,error:v}=gn.useQuery({queryKey:["page-resolve",e,t,r,n,o,s,a,u],queryFn:()=>ry({clientId:e,tenantId:t,moduleId:r,featureId:n,routePath:s,isDefault:a,version:u}),enabled:!o}),w=o??g?.pageId,x=u??g?.version,{data:E,isLoading:P,isError:C,error:N}=gn.useQuery({queryKey:["page-render",w,e,x],queryFn:()=>Bc(w,e,x),enabled:!!w});return!o&&h?c.jsx("div",{className:"flex items-center justify-center p-12",children:c.jsx(Pn,{})}):y?c.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm text-destructive",children:v instanceof Error?v.message:"Failed to resolve page"}):w?P?c.jsx("div",{className:"flex items-center justify-center p-12",children:c.jsx(Pn,{})}):C||!E?c.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm text-destructive",children:N instanceof Error?N.message:"Failed to load page"}):c.jsx(Hc,{page:E,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."})}ge.FIELD_TYPE_REGISTRY=UT,ge.FORM_RENDERER_GRID_ROW_HEIGHT_DEFAULT=In,ge.FORM_RENDERER_ROOT_CLASS=ga,ge.FieldRenderer=un,ge.FormRenderer=Mc,ge.PageRenderer=Hc,ge.RendererFieldLayoutContext=_a,ge.StudioPageHost=rP,ge.WorkflowStepsView=Yg,ge.appearanceControlClasses=Bo,ge.appearanceHasExplicitVerticalIntent=kd,ge.appearanceTextareaClasses=vd,ge.backendToFormSchema=ms,ge.cellAlignmentClasses=Nb,ge.cellVerticalJustifyClassesForField=Eb,ge.effectiveWidthPercent=Ps,ge.executeDataSource=$c,ge.fetchPageRender=Bc,ge.fieldBlockBoxStyle=Cb,ge.fieldBlockBoxStyleForField=Nd,ge.fieldBlockHorizontalPlacementClass=xd,ge.fieldBlockHorizontalSelfClass=Ad,ge.fieldBlockHorizontalSelfClassForField=_d,ge.fieldBlockWidthStyle=Sa,ge.fieldBlockWidthStyleForField=Ed,ge.fieldGridShellFillsCellVertically=Is,ge.formBuilderHttp=dn,ge.formLayoutRecordToGridConfig=Ns,ge.getBusinessApiOrigin=Np,ge.getClientId=Tn,ge.getRendererHostAuthHeaders=Ml,ge.getRendererHostViewerContext=bC,ge.getRendererStore=ev,ge.gridCellFlexClasses=Sd,ge.gridCellFlexClassesForField=Na,ge.gridCellOuterFlexClasses=wd,ge.hasExplicitFieldBlockWidth=Cd,ge.isAsyncSearchFieldProperties=BT,ge.isIntrinsicWidthButtonField=to,ge.normalizeWorkflowFormSchema=Kk,ge.normalizeWorkflowFormToRendererSchema=Yi,ge.pageBuilderHttp=vs,ge.parseContentVerticalAlign=Aa,ge.parseMetadataJson=ys,ge.resetRendererHostAuth=yC,ge.resolveBusinessApiUrl=cn,ge.resolveFormGridLayout=_s,ge.resolvePage=ry,ge.resolvedGridCellVerticalJustifyClasses=jo,ge.resolvedHorizontalAlign=Fr,ge.resolvedVerticalAlign=$o,ge.resolvedVerticalAlignForField=Ea,ge.setBusinessApiOrigin=UA,ge.setFormBuilderAuthProvider=vC,ge.setPageBuilderAuthProvider=YT,ge.setRendererHostAuthHeaders=gC,ge.setRendererHostViewerContext=hC,ge.useFieldValidation=jT,ge.useFormRenderer=Vd,ge.useFormValidation=$T,ge.useRendererFieldLayout=zo,ge.useRendererHostAuthStore=Rn,Object.defineProperty(ge,Symbol.toStringTag,{value:"Module"})}));
|