@schema-forms-data/react 4.0.3 → 4.0.4
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/index.cjs +2 -2
- package/dist/index.js +70 -2
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -79,7 +79,7 @@ If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHid
|
|
|
79
79
|
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return g.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},Lw="DialogDescriptionWarning",Mw=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${sf(Lw).contentName}}.`;return g.useEffect(()=>{var n;const a=(n=e.current)==null?void 0:n.getAttribute("aria-describedby");t&&a&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Vw=Gp,Bw=Kp,lf=Yp,cf=Jp,df=ef,uf=rf,Uw=af;const Hw=Vw,Ww=Bw,mf=g.forwardRef(({className:e,...t},r)=>o.jsx(lf,{ref:r,className:K("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));mf.displayName=lf.displayName;const pf=g.forwardRef(({className:e,children:t,...r},n)=>o.jsxs(Ww,{children:[o.jsx(mf,{}),o.jsxs(cf,{ref:n,className:K("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...r,children:[t,o.jsxs(Uw,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[o.jsx(_.X,{className:"h-4 w-4"}),o.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));pf.displayName=cf.displayName;const ff=({className:e,...t})=>o.jsx("div",{className:K("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});ff.displayName="DialogHeader";const hf=g.forwardRef(({className:e,...t},r)=>o.jsx(df,{ref:r,className:K("text-lg font-semibold leading-none tracking-tight",e),...t}));hf.displayName=df.displayName;const xf=g.forwardRef(({className:e,...t},r)=>o.jsx(uf,{ref:r,className:K("text-sm text-muted-foreground",e),...t}));xf.displayName=uf.displayName;var Io="Popover",[gf]=_t(Io,[Fn]),pa=Fn(),[qw,Br]=gf(Io),vf=e=>{const{__scopePopover:t,children:r,open:n,defaultOpen:a,onOpenChange:s,modal:i=!1}=e,l=pa(t),c=g.useRef(null),[d,u]=g.useState(!1),[m,p]=dr({prop:n,defaultProp:a??!1,onChange:s,caller:Io});return o.jsx(qi,{...l,children:o.jsx(qw,{scope:t,contentId:wr(),triggerRef:c,open:m,onOpenChange:p,onOpenToggle:g.useCallback(()=>p(f=>!f),[p]),hasCustomAnchor:d,onCustomAnchorAdd:g.useCallback(()=>u(!0),[]),onCustomAnchorRemove:g.useCallback(()=>u(!1),[]),modal:i,children:r})})};vf.displayName=Io;var bf="PopoverAnchor",Gw=g.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,a=Br(bf,r),s=pa(r),{onCustomAnchorAdd:i,onCustomAnchorRemove:l}=a;return g.useEffect(()=>(i(),()=>l()),[i,l]),o.jsx(ko,{...s,...n,ref:t})});Gw.displayName=bf;var yf="PopoverTrigger",wf=g.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,a=Br(yf,r),s=pa(r),i=ke(t,a.triggerRef),l=o.jsx(we.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":Sf(a.open),...n,ref:i,onClick:ge(e.onClick,a.onOpenToggle)});return a.hasCustomAnchor?l:o.jsx(ko,{asChild:!0,...s,children:l})});wf.displayName=yf;var al="PopoverPortal",[Xw,Zw]=gf(al,{forceMount:void 0}),jf=e=>{const{__scopePopover:t,forceMount:r,children:n,container:a}=e,s=Br(al,t);return o.jsx(Xw,{scope:t,forceMount:r,children:o.jsx(Ot,{present:r||s.open,children:o.jsx(Co,{asChild:!0,container:a,children:n})})})};jf.displayName=al;var Dn="PopoverContent",kf=g.forwardRef((e,t)=>{const r=Zw(Dn,e.__scopePopover),{forceMount:n=r.forceMount,...a}=e,s=Br(Dn,e.__scopePopover);return o.jsx(Ot,{present:n||s.open,children:s.modal?o.jsx(Yw,{...a,ref:t}):o.jsx(Jw,{...a,ref:t})})});kf.displayName=Dn;var Kw=$n("PopoverContent.RemoveScroll"),Yw=g.forwardRef((e,t)=>{const r=Br(Dn,e.__scopePopover),n=g.useRef(null),a=ke(t,n),s=g.useRef(!1);return g.useEffect(()=>{const i=n.current;if(i)return Zi(i)},[]),o.jsx(So,{as:Kw,allowPinchZoom:!0,children:o.jsx(Cf,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ge(e.onCloseAutoFocus,i=>{var l;i.preventDefault(),s.current||(l=r.triggerRef.current)==null||l.focus()}),onPointerDownOutside:ge(e.onPointerDownOutside,i=>{const l=i.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;s.current=d},{checkForDefaultPrevented:!1}),onFocusOutside:ge(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),Jw=g.forwardRef((e,t)=>{const r=Br(Dn,e.__scopePopover),n=g.useRef(!1),a=g.useRef(!1);return o.jsx(Cf,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,l;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(n.current||(l=r.triggerRef.current)==null||l.focus(),s.preventDefault()),n.current=!1,a.current=!1},onInteractOutside:s=>{var i,l;(i=e.onInteractOutside)==null||i.call(e,s),s.defaultPrevented||(n.current=!0,s.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const c=s.target;(l=r.triggerRef.current)!=null&&l.contains(c)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&a.current&&s.preventDefault()}})}),Cf=g.forwardRef((e,t)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:s,disableOutsidePointerEvents:i,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onInteractOutside:u,...m}=e,p=Br(Dn,r),f=pa(r);return Fi(),o.jsx(vo,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:s,children:o.jsx(ua,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:u,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onDismiss:()=>p.onOpenChange(!1),children:o.jsx(Gi,{"data-state":Sf(p.open),role:"dialog",id:p.contentId,...f,...m,ref:t,style:{...m.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)"}})})})}),Nf="PopoverClose",Qw=g.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,a=Br(Nf,r);return o.jsx(we.button,{type:"button",...n,ref:t,onClick:ge(e.onClick,()=>a.onOpenChange(!1))})});Qw.displayName=Nf;var e1="PopoverArrow",t1=g.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,a=pa(r);return o.jsx(Xi,{...a,...n,ref:t})});t1.displayName=e1;function Sf(e){return e?"open":"closed"}var r1=vf,n1=wf,a1=jf,$f=kf;const Po=r1,_o=n1,fa=g.forwardRef(({className:e,align:t="center",sideOffset:r=4,...n},a)=>o.jsx(a1,{children:o.jsx($f,{ref:a,align:t,sideOffset:r,className:K("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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",e),...n})}));fa.displayName=$f.displayName;var[Oo]=_t("Tooltip",[Fn]),Fo=Fn(),Ef="TooltipProvider",o1=700,oi="tooltip.open",[s1,ol]=Oo(Ef),Df=e=>{const{__scopeTooltip:t,delayDuration:r=o1,skipDelayDuration:n=300,disableHoverableContent:a=!1,children:s}=e,i=g.useRef(!0),l=g.useRef(!1),c=g.useRef(0);return g.useEffect(()=>{const d=c.current;return()=>window.clearTimeout(d)},[]),o.jsx(s1,{scope:t,isOpenDelayedRef:i,delayDuration:r,onOpen:g.useCallback(()=>{window.clearTimeout(c.current),i.current=!1},[]),onClose:g.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>i.current=!0,n)},[n]),isPointerInTransitRef:l,onPointerInTransitChange:g.useCallback(d=>{l.current=d},[]),disableHoverableContent:a,children:s})};Df.displayName=Ef;var na="Tooltip",[i1,zo]=Oo(na),Tf=e=>{const{__scopeTooltip:t,children:r,open:n,defaultOpen:a,onOpenChange:s,disableHoverableContent:i,delayDuration:l}=e,c=ol(na,e.__scopeTooltip),d=Fo(t),[u,m]=g.useState(null),p=wr(),f=g.useRef(0),b=i??c.disableHoverableContent,h=l??c.delayDuration,x=g.useRef(!1),[y,v]=dr({prop:n,defaultProp:a??!1,onChange:$=>{$?(c.onOpen(),document.dispatchEvent(new CustomEvent(oi))):c.onClose(),s==null||s($)},caller:na}),j=g.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),w=g.useCallback(()=>{window.clearTimeout(f.current),f.current=0,x.current=!1,v(!0)},[v]),C=g.useCallback(()=>{window.clearTimeout(f.current),f.current=0,v(!1)},[v]),S=g.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{x.current=!0,v(!0),f.current=0},h)},[h,v]);return g.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),o.jsx(qi,{...d,children:o.jsx(i1,{scope:t,contentId:p,open:y,stateAttribute:j,trigger:u,onTriggerChange:m,onTriggerEnter:g.useCallback(()=>{c.isOpenDelayedRef.current?S():w()},[c.isOpenDelayedRef,S,w]),onTriggerLeave:g.useCallback(()=>{b?C():(window.clearTimeout(f.current),f.current=0)},[C,b]),onOpen:w,onClose:C,disableHoverableContent:b,children:r})})};Tf.displayName=na;var si="TooltipTrigger",Af=g.forwardRef((e,t)=>{const{__scopeTooltip:r,...n}=e,a=zo(si,r),s=ol(si,r),i=Fo(r),l=g.useRef(null),c=ke(t,l,a.onTriggerChange),d=g.useRef(!1),u=g.useRef(!1),m=g.useCallback(()=>d.current=!1,[]);return g.useEffect(()=>()=>document.removeEventListener("pointerup",m),[m]),o.jsx(ko,{asChild:!0,...i,children:o.jsx(we.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...n,ref:c,onPointerMove:ge(e.onPointerMove,p=>{p.pointerType!=="touch"&&!u.current&&!s.isPointerInTransitRef.current&&(a.onTriggerEnter(),u.current=!0)}),onPointerLeave:ge(e.onPointerLeave,()=>{a.onTriggerLeave(),u.current=!1}),onPointerDown:ge(e.onPointerDown,()=>{a.open&&a.onClose(),d.current=!0,document.addEventListener("pointerup",m,{once:!0})}),onFocus:ge(e.onFocus,()=>{d.current||a.onOpen()}),onBlur:ge(e.onBlur,a.onClose),onClick:ge(e.onClick,a.onClose)})})});Af.displayName=si;var l1="TooltipPortal",[l$,c1]=Oo(l1,{forceMount:void 0}),Tn="TooltipContent",Rf=g.forwardRef((e,t)=>{const r=c1(Tn,e.__scopeTooltip),{forceMount:n=r.forceMount,side:a="top",...s}=e,i=zo(Tn,e.__scopeTooltip);return o.jsx(Ot,{present:n||i.open,children:i.disableHoverableContent?o.jsx(If,{side:a,...s,ref:t}):o.jsx(d1,{side:a,...s,ref:t})})}),d1=g.forwardRef((e,t)=>{const r=zo(Tn,e.__scopeTooltip),n=ol(Tn,e.__scopeTooltip),a=g.useRef(null),s=ke(t,a),[i,l]=g.useState(null),{trigger:c,onClose:d}=r,u=a.current,{onPointerInTransitChange:m}=n,p=g.useCallback(()=>{l(null),m(!1)},[m]),f=g.useCallback((b,h)=>{const x=b.currentTarget,y={x:b.clientX,y:b.clientY},v=h1(y,x.getBoundingClientRect()),j=x1(y,v),w=g1(h.getBoundingClientRect()),C=b1([...j,...w]);l(C),m(!0)},[m]);return g.useEffect(()=>()=>p(),[p]),g.useEffect(()=>{if(c&&u){const b=x=>f(x,u),h=x=>f(x,c);return c.addEventListener("pointerleave",b),u.addEventListener("pointerleave",h),()=>{c.removeEventListener("pointerleave",b),u.removeEventListener("pointerleave",h)}}},[c,u,f,p]),g.useEffect(()=>{if(i){const b=h=>{const x=h.target,y={x:h.clientX,y:h.clientY},v=(c==null?void 0:c.contains(x))||(u==null?void 0:u.contains(x)),j=!v1(y,i);v?p():j&&(p(),d())};return document.addEventListener("pointermove",b),()=>document.removeEventListener("pointermove",b)}},[c,u,i,d,p]),o.jsx(If,{...e,ref:s})}),[u1,m1]=Oo(na,{isInside:!1}),p1=Nv("TooltipContent"),If=g.forwardRef((e,t)=>{const{__scopeTooltip:r,children:n,"aria-label":a,onEscapeKeyDown:s,onPointerDownOutside:i,...l}=e,c=zo(Tn,r),d=Fo(r),{onClose:u}=c;return g.useEffect(()=>(document.addEventListener(oi,u),()=>document.removeEventListener(oi,u)),[u]),g.useEffect(()=>{if(c.trigger){const m=p=>{const f=p.target;f!=null&&f.contains(c.trigger)&&u()};return window.addEventListener("scroll",m,{capture:!0}),()=>window.removeEventListener("scroll",m,{capture:!0})}},[c.trigger,u]),o.jsx(ua,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:m=>m.preventDefault(),onDismiss:u,children:o.jsxs(Gi,{"data-state":c.stateAttribute,...d,...l,ref:t,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[o.jsx(p1,{children:n}),o.jsx(u1,{scope:r,isInside:!0,children:o.jsx(My,{id:c.contentId,role:"tooltip",children:a||n})})]})})});Rf.displayName=Tn;var Pf="TooltipArrow",f1=g.forwardRef((e,t)=>{const{__scopeTooltip:r,...n}=e,a=Fo(r);return m1(Pf,r).isInside?null:o.jsx(Xi,{...a,...n,ref:t})});f1.displayName=Pf;function h1(e,t){const r=Math.abs(t.top-e.y),n=Math.abs(t.bottom-e.y),a=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(r,n,a,s)){case s:return"left";case a:return"right";case r:return"top";case n:return"bottom";default:throw new Error("unreachable")}}function x1(e,t,r=5){const n=[];switch(t){case"top":n.push({x:e.x-r,y:e.y+r},{x:e.x+r,y:e.y+r});break;case"bottom":n.push({x:e.x-r,y:e.y-r},{x:e.x+r,y:e.y-r});break;case"left":n.push({x:e.x+r,y:e.y-r},{x:e.x+r,y:e.y+r});break;case"right":n.push({x:e.x-r,y:e.y-r},{x:e.x-r,y:e.y+r});break}return n}function g1(e){const{top:t,right:r,bottom:n,left:a}=e;return[{x:a,y:t},{x:r,y:t},{x:r,y:n},{x:a,y:n}]}function v1(e,t){const{x:r,y:n}=e;let a=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const l=t[s],c=t[i],d=l.x,u=l.y,m=c.x,p=c.y;u>n!=p>n&&r<(m-d)*(n-u)/(p-u)+d&&(a=!a)}return a}function b1(e){const t=e.slice();return t.sort((r,n)=>r.x<n.x?-1:r.x>n.x?1:r.y<n.y?-1:r.y>n.y?1:0),y1(t)}function y1(e){if(e.length<=1)return e.slice();const t=[];for(let n=0;n<e.length;n++){const a=e[n];for(;t.length>=2;){const s=t[t.length-1],i=t[t.length-2];if((s.x-i.x)*(a.y-i.y)>=(s.y-i.y)*(a.x-i.x))t.pop();else break}t.push(a)}t.pop();const r=[];for(let n=e.length-1;n>=0;n--){const a=e[n];for(;r.length>=2;){const s=r[r.length-1],i=r[r.length-2];if((s.x-i.x)*(a.y-i.y)>=(s.y-i.y)*(a.x-i.x))r.pop();else break}r.push(a)}return r.pop(),t.length===1&&r.length===1&&t[0].x===r[0].x&&t[0].y===r[0].y?t:t.concat(r)}var w1=Df,j1=Tf,k1=Af,_f=Rf;const C1=w1,Of=j1,Ff=k1,sl=g.forwardRef(({className:e,sideOffset:t=4,...r},n)=>o.jsx(_f,{ref:n,sideOffset:t,className:K("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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",e),...r}));sl.displayName=_f.displayName;function N1(e,t){return g.useReducer((r,n)=>t[r][n]??r,e)}var il="ScrollArea",[zf]=_t(il),[S1,Wt]=zf(il),Lf=g.forwardRef((e,t)=>{const{__scopeScrollArea:r,type:n="hover",dir:a,scrollHideDelay:s=600,...i}=e,[l,c]=g.useState(null),[d,u]=g.useState(null),[m,p]=g.useState(null),[f,b]=g.useState(null),[h,x]=g.useState(null),[y,v]=g.useState(0),[j,w]=g.useState(0),[C,S]=g.useState(!1),[$,k]=g.useState(!1),E=ke(t,O=>c(O)),D=ca(a);return o.jsx(S1,{scope:r,type:n,dir:D,scrollHideDelay:s,scrollArea:l,viewport:d,onViewportChange:u,content:m,onContentChange:p,scrollbarX:f,onScrollbarXChange:b,scrollbarXEnabled:C,onScrollbarXEnabledChange:S,scrollbarY:h,onScrollbarYChange:x,scrollbarYEnabled:$,onScrollbarYEnabledChange:k,onCornerWidthChange:v,onCornerHeightChange:w,children:o.jsx(we.div,{dir:D,...i,ref:E,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":j+"px",...e.style}})})});Lf.displayName=il;var Mf="ScrollAreaViewport",Vf=g.forwardRef((e,t)=>{const{__scopeScrollArea:r,children:n,nonce:a,...s}=e,i=Wt(Mf,r),l=g.useRef(null),c=ke(t,l,i.onViewportChange);return o.jsxs(o.Fragment,{children:[o.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:a}),o.jsx(we.div,{"data-radix-scroll-area-viewport":"",...s,ref:c,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:o.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});Vf.displayName=Mf;var fr="ScrollAreaScrollbar",ll=g.forwardRef((e,t)=>{const{forceMount:r,...n}=e,a=Wt(fr,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=a,l=e.orientation==="horizontal";return g.useEffect(()=>(l?s(!0):i(!0),()=>{l?s(!1):i(!1)}),[l,s,i]),a.type==="hover"?o.jsx($1,{...n,ref:t,forceMount:r}):a.type==="scroll"?o.jsx(E1,{...n,ref:t,forceMount:r}):a.type==="auto"?o.jsx(Bf,{...n,ref:t,forceMount:r}):a.type==="always"?o.jsx(cl,{...n,ref:t}):null});ll.displayName=fr;var $1=g.forwardRef((e,t)=>{const{forceMount:r,...n}=e,a=Wt(fr,e.__scopeScrollArea),[s,i]=g.useState(!1);return g.useEffect(()=>{const l=a.scrollArea;let c=0;if(l){const d=()=>{window.clearTimeout(c),i(!0)},u=()=>{c=window.setTimeout(()=>i(!1),a.scrollHideDelay)};return l.addEventListener("pointerenter",d),l.addEventListener("pointerleave",u),()=>{window.clearTimeout(c),l.removeEventListener("pointerenter",d),l.removeEventListener("pointerleave",u)}}},[a.scrollArea,a.scrollHideDelay]),o.jsx(Ot,{present:r||s,children:o.jsx(Bf,{"data-state":s?"visible":"hidden",...n,ref:t})})}),E1=g.forwardRef((e,t)=>{const{forceMount:r,...n}=e,a=Wt(fr,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Mo(()=>c("SCROLL_END"),100),[l,c]=N1("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 g.useEffect(()=>{if(l==="idle"){const d=window.setTimeout(()=>c("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(d)}},[l,a.scrollHideDelay,c]),g.useEffect(()=>{const d=a.viewport,u=s?"scrollLeft":"scrollTop";if(d){let m=d[u];const p=()=>{const f=d[u];m!==f&&(c("SCROLL"),i()),m=f};return d.addEventListener("scroll",p),()=>d.removeEventListener("scroll",p)}},[a.viewport,s,c,i]),o.jsx(Ot,{present:r||l!=="hidden",children:o.jsx(cl,{"data-state":l==="hidden"?"hidden":"visible",...n,ref:t,onPointerEnter:ge(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:ge(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),Bf=g.forwardRef((e,t)=>{const r=Wt(fr,e.__scopeScrollArea),{forceMount:n,...a}=e,[s,i]=g.useState(!1),l=e.orientation==="horizontal",c=Mo(()=>{if(r.viewport){const d=r.viewport.offsetWidth<r.viewport.scrollWidth,u=r.viewport.offsetHeight<r.viewport.scrollHeight;i(l?d:u)}},10);return An(r.viewport,c),An(r.content,c),o.jsx(Ot,{present:n||s,children:o.jsx(cl,{"data-state":s?"visible":"hidden",...a,ref:t})})}),cl=g.forwardRef((e,t)=>{const{orientation:r="vertical",...n}=e,a=Wt(fr,e.__scopeScrollArea),s=g.useRef(null),i=g.useRef(0),[l,c]=g.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),d=Gf(l.viewport,l.content),u={...n,sizes:l,onSizesChange:c,hasThumb:d>0&&d<1,onThumbChange:p=>s.current=p,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:p=>i.current=p};function m(p,f){return P1(p,i.current,l,f)}return r==="horizontal"?o.jsx(D1,{...u,ref:t,onThumbPositionChange:()=>{if(a.viewport&&s.current){const p=a.viewport.scrollLeft,f=Ac(p,l,a.dir);s.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:p=>{a.viewport&&(a.viewport.scrollLeft=p)},onDragScroll:p=>{a.viewport&&(a.viewport.scrollLeft=m(p,a.dir))}}):r==="vertical"?o.jsx(T1,{...u,ref:t,onThumbPositionChange:()=>{if(a.viewport&&s.current){const p=a.viewport.scrollTop,f=Ac(p,l);s.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:p=>{a.viewport&&(a.viewport.scrollTop=p)},onDragScroll:p=>{a.viewport&&(a.viewport.scrollTop=m(p))}}):null}),D1=g.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...a}=e,s=Wt(fr,e.__scopeScrollArea),[i,l]=g.useState(),c=g.useRef(null),d=ke(t,c,s.onScrollbarXChange);return g.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),o.jsx(Hf,{"data-orientation":"horizontal",...a,ref:d,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":Lo(r)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.x),onDragScroll:u=>e.onDragScroll(u.x),onWheelScroll:(u,m)=>{if(s.viewport){const p=s.viewport.scrollLeft+u.deltaX;e.onWheelScroll(p),Zf(p,m)&&u.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&n({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Ya(i.paddingLeft),paddingEnd:Ya(i.paddingRight)}})}})}),T1=g.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...a}=e,s=Wt(fr,e.__scopeScrollArea),[i,l]=g.useState(),c=g.useRef(null),d=ke(t,c,s.onScrollbarYChange);return g.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),o.jsx(Hf,{"data-orientation":"vertical",...a,ref:d,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":Lo(r)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.y),onDragScroll:u=>e.onDragScroll(u.y),onWheelScroll:(u,m)=>{if(s.viewport){const p=s.viewport.scrollTop+u.deltaY;e.onWheelScroll(p),Zf(p,m)&&u.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&n({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Ya(i.paddingTop),paddingEnd:Ya(i.paddingBottom)}})}})}),[A1,Uf]=zf(fr),Hf=g.forwardRef((e,t)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:a,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:l,onThumbPositionChange:c,onDragScroll:d,onWheelScroll:u,onResize:m,...p}=e,f=Wt(fr,r),[b,h]=g.useState(null),x=ke(t,E=>h(E)),y=g.useRef(null),v=g.useRef(""),j=f.viewport,w=n.content-n.viewport,C=ft(u),S=ft(c),$=Mo(m,10);function k(E){if(y.current){const D=E.clientX-y.current.left,O=E.clientY-y.current.top;d({x:D,y:O})}}return g.useEffect(()=>{const E=D=>{const O=D.target;b!=null&&b.contains(O)&&C(D,w)};return document.addEventListener("wheel",E,{passive:!1}),()=>document.removeEventListener("wheel",E,{passive:!1})},[j,b,w,C]),g.useEffect(S,[n,S]),An(b,$),An(f.content,$),o.jsx(A1,{scope:r,scrollbar:b,hasThumb:a,onThumbChange:ft(s),onThumbPointerUp:ft(i),onThumbPositionChange:S,onThumbPointerDown:ft(l),children:o.jsx(we.div,{...p,ref:x,style:{position:"absolute",...p.style},onPointerDown:ge(e.onPointerDown,E=>{E.button===0&&(E.target.setPointerCapture(E.pointerId),y.current=b.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),k(E))}),onPointerMove:ge(e.onPointerMove,k),onPointerUp:ge(e.onPointerUp,E=>{const D=E.target;D.hasPointerCapture(E.pointerId)&&D.releasePointerCapture(E.pointerId),document.body.style.webkitUserSelect=v.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),Ka="ScrollAreaThumb",Wf=g.forwardRef((e,t)=>{const{forceMount:r,...n}=e,a=Uf(Ka,e.__scopeScrollArea);return o.jsx(Ot,{present:r||a.hasThumb,children:o.jsx(R1,{ref:t,...n})})}),R1=g.forwardRef((e,t)=>{const{__scopeScrollArea:r,style:n,...a}=e,s=Wt(Ka,r),i=Uf(Ka,r),{onThumbPositionChange:l}=i,c=ke(t,m=>i.onThumbChange(m)),d=g.useRef(void 0),u=Mo(()=>{d.current&&(d.current(),d.current=void 0)},100);return g.useEffect(()=>{const m=s.viewport;if(m){const p=()=>{if(u(),!d.current){const f=_1(m,l);d.current=f,l()}};return l(),m.addEventListener("scroll",p),()=>m.removeEventListener("scroll",p)}},[s.viewport,u,l]),o.jsx(we.div,{"data-state":i.hasThumb?"visible":"hidden",...a,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:ge(e.onPointerDownCapture,m=>{const p=m.target.getBoundingClientRect(),f=m.clientX-p.left,b=m.clientY-p.top;i.onThumbPointerDown({x:f,y:b})}),onPointerUp:ge(e.onPointerUp,i.onThumbPointerUp)})});Wf.displayName=Ka;var dl="ScrollAreaCorner",qf=g.forwardRef((e,t)=>{const r=Wt(dl,e.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?o.jsx(I1,{...e,ref:t}):null});qf.displayName=dl;var I1=g.forwardRef((e,t)=>{const{__scopeScrollArea:r,...n}=e,a=Wt(dl,r),[s,i]=g.useState(0),[l,c]=g.useState(0),d=!!(s&&l);return An(a.scrollbarX,()=>{var u;const m=((u=a.scrollbarX)==null?void 0:u.offsetHeight)||0;a.onCornerHeightChange(m),c(m)}),An(a.scrollbarY,()=>{var u;const m=((u=a.scrollbarY)==null?void 0:u.offsetWidth)||0;a.onCornerWidthChange(m),i(m)}),d?o.jsx(we.div,{...n,ref:t,style:{width:s,height:l,position:"absolute",right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Ya(e){return e?parseInt(e,10):0}function Gf(e,t){const r=e/t;return isNaN(r)?0:r}function Lo(e){const t=Gf(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,n=(e.scrollbar.size-r)*t;return Math.max(n,18)}function P1(e,t,r,n="ltr"){const a=Lo(r),s=a/2,i=t||s,l=a-i,c=r.scrollbar.paddingStart+i,d=r.scrollbar.size-r.scrollbar.paddingEnd-l,u=r.content-r.viewport,m=n==="ltr"?[0,u]:[u*-1,0];return Xf([c,d],m)(e)}function Ac(e,t,r="ltr"){const n=Lo(t),a=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-a,i=t.content-t.viewport,l=s-n,c=r==="ltr"?[0,i]:[i*-1,0],d=ta(e,c);return Xf([0,i],[0,l])(d)}function Xf(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 Zf(e,t){return e>0&&e<t}var _1=(e,t=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},n=0;return function a(){const s={left:e.scrollLeft,top:e.scrollTop},i=r.left!==s.left,l=r.top!==s.top;(i||l)&&t(),r=s,n=window.requestAnimationFrame(a)}(),()=>window.cancelAnimationFrame(n)};function Mo(e,t){const r=ft(e),n=g.useRef(0);return g.useEffect(()=>()=>window.clearTimeout(n.current),[]),g.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,t)},[r,t])}function An(e,t){const r=ft(t);lt(()=>{let n=0;if(e){const a=new ResizeObserver(()=>{cancelAnimationFrame(n),n=window.requestAnimationFrame(r)});return a.observe(e),()=>{window.cancelAnimationFrame(n),a.unobserve(e)}}},[e,r])}var Kf=Lf,O1=Vf,F1=qf;const Vo=g.forwardRef(({className:e,children:t,...r},n)=>o.jsxs(Kf,{ref:n,className:K("relative overflow-hidden",e),...r,children:[o.jsx(O1,{className:"h-full w-full rounded-[inherit]",children:t}),o.jsx(Yf,{}),o.jsx(F1,{})]}));Vo.displayName=Kf.displayName;const Yf=g.forwardRef(({className:e,orientation:t="vertical",...r},n)=>o.jsx(ll,{ref:n,orientation:t,className:K("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...r,children:o.jsx(Wf,{className:"relative flex-1 rounded-full bg-border"})}));Yf.displayName=ll.displayName;const Rc=Object.entries(_.icons).map(([e,t])=>({name:e,kebab:e.replace(/([A-Z])/g,(r,n,a)=>a===0?n.toLowerCase():`-${n.toLowerCase()}`),component:t})),Jf=({value:e,onChange:t,label:r="Ícone (Lucide)",hideLabel:n=!1,className:a})=>{const[s,i]=N.useState(!1),[l,c]=N.useState(""),d=N.useMemo(()=>Qg(e),[e]),u=N.useMemo(()=>{const f=l.toLowerCase();return f?Rc.filter(b=>b.name.toLowerCase().includes(f)||b.kebab.includes(f)):Rc},[l]),m=f=>{t(f),i(!1)},p=f=>{i(f),f||c("")};return o.jsxs("div",{className:`space-y-1 ${a??""}`,children:[!n&&o.jsx(ie,{className:"text-xs",children:r}),o.jsx(De,{type:"button",variant:"outline",className:"w-full h-8 justify-start text-xs font-normal gap-2",onClick:()=>i(!0),children:d?o.jsxs(o.Fragment,{children:[N.createElement(d,{className:"h-3.5 w-3.5 shrink-0"}),o.jsx("span",{className:"truncate",children:e})]}):o.jsx("span",{className:"text-muted-foreground",children:"Selecionar ícone…"})}),o.jsx(Hw,{open:s,onOpenChange:p,children:o.jsxs(pf,{className:"max-w-3xl max-h-[85vh] flex flex-col gap-0 p-0",children:[o.jsxs(ff,{className:"px-4 pt-4 pb-2 border-b",children:[o.jsx(hf,{children:"Selecionar ícone"}),o.jsx(xf,{children:"Pesquise e clique em um ícone da biblioteca Lucide."})]}),o.jsx("div",{className:"px-4 py-2 border-b",children:o.jsxs("div",{className:"relative",children:[o.jsx(_.Search,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),o.jsx(ue,{autoFocus:!0,placeholder:"Buscar ícones…",value:l,onChange:f=>c(f.target.value),className:"pl-8 h-9 text-sm"})]})}),o.jsx(Vo,{className:"flex-1 px-4 py-2",children:o.jsxs("div",{className:"grid grid-cols-5 gap-2 sm:grid-cols-7 md:grid-cols-8 pb-2",children:[o.jsxs(De,{type:"button",variant:e?"outline":"secondary",className:"flex flex-col items-center justify-center h-20 gap-1 p-1",onClick:()=>m(void 0),children:[o.jsx("div",{className:"h-6 w-6 rounded border-2 border-dashed border-muted-foreground/30"}),o.jsx("span",{className:"text-[10px] leading-tight text-center",children:"Nenhum"})]}),u.map(({name:f,component:b})=>o.jsxs(De,{type:"button",variant:e===f?"secondary":"outline",className:"flex flex-col items-center justify-center h-20 gap-1 p-1 overflow-hidden",onClick:()=>m(f),children:[N.createElement(b,{size:24}),o.jsx("span",{className:"text-[9px] leading-tight text-center break-all line-clamp-2",children:f})]},f))]})})]})})]})};var z1=Object.defineProperty,L1=(e,t,r)=>t in e?z1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ic=(e,t,r)=>L1(e,typeof t!="symbol"?t+"":t,r);const Ja=N.createContext({}),Nr=()=>N.useContext(Ja),at=(e,t,r={})=>{if(!e)return!0;if("and"in e||"or"in e){const d="and"in e&&Array.isArray(e.and)&&e.and.length>0,u="or"in e&&Array.isArray(e.or)&&e.or.length>0;return d&&u?(console.warn("[evaluateFieldCondition] FieldConditionGroup com `and` e `or` simultâneos — apenas `and` será avaliado."),e.and.every(m=>at(m,t,r))):d?e.and.every(m=>at(m,t,r)):u?e.or.some(m=>at(m,t,r)):!0}const n=e;if(!n.campoId)return!0;const a=n.source==="evento"?r[n.campoId]:t[n.campoId];if(Array.isArray(a)){const d=n.valor;switch(n.operador){case"contem":return a.includes(d);case"naoContem":return!a.includes(d);case"vazio":return a.length===0;case"naoVazio":return a.length>0;case"igual":return a.length===1&&a[0]===d;case"diferente":return!(a.length===1&&a[0]===d);default:return!0}}const s=a==null||a===!1?"":a===!0?"1":String(a),i=n.valor!==void 0?String(n.valor):"",l=Number(s),c=Number(i);switch(n.operador){case"igual":return s===i;case"diferente":return s!==i;case"vazio":return!s;case"naoVazio":return!!s;case"contem":return s.includes(i);case"naoContem":return!s.includes(i);case"maiorQue":return!isNaN(l)&&!isNaN(c)?l>c:s>i;case"menorQue":return!isNaN(l)&&!isNaN(c)?l<c:s<i;case"maiorOuIgual":return!isNaN(l)&&!isNaN(c)?l>=c:s>=i;case"menorOuIgual":return!isNaN(l)&&!isNaN(c)?l<=c:s<=i;default:return!0}},M1=/^\d{3}\.?\d{3}\.?\d{3}-?\d{2}$/,V1=/^\(?\d{2}\)?\s?\d{4,5}-?\d{4}$/,B1=/^\d{5}-?\d{3}$/,U1=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,H1=e=>{const t=e.replace(/\D/g,"");if(t.length!==11||/^(\d)\1{10}$/.test(t))return!1;const r=n=>{let a=0;for(let i=0;i<n;i++)a+=parseInt(t[i])*(n+1-i);const s=a*10%11;return s>=10?0:s};return r(9)===parseInt(t[9])&&r(10)===parseInt(t[10])},Wn=new Map,W1=e=>{if(Wn.has(e))return Wn.get(e);if(/^\/.*\/[gimsuy]*$/.test(e))return Wn.set(e,null),null;try{const t=new RegExp(e);return Wn.set(e,t),t}catch{return Wn.set(e,null),null}},Ta=(e,t,r={})=>{const n=e.validacao;if(e.tipo===T.CHECKBOX||e.tipo===T.SWITCH)return e.obrigatorio&&!t?"Campo obrigatório":void 0;if(e.tipo===T.SLIDER){const s=t!=null&&t!==""?Number(t):NaN;return e.obrigatorio&&isNaN(s)?"Campo obrigatório":isNaN(s)?void 0:(n==null?void 0:n.min)!==void 0&&s<n.min?`Valor mínimo: ${n.min}`:(n==null?void 0:n.max)!==void 0&&s>n.max?`Valor máximo: ${n.max}`:void 0}if(e.tipo===T.RATING){const s=t!==void 0?Number(t):0;return e.obrigatorio&&(!s||s<1)?"Avaliação obrigatória":void 0}if(e.tipo===T.DATE_RANGE){const s=t;if(e.obrigatorio){if(!(s!=null&&s.start))return"Data inicial obrigatória";if(!(s!=null&&s.end))return"Data final obrigatória"}return s!=null&&s.start&&s!=null&&s.end&&s.start>s.end?"A data inicial deve ser menor ou igual à data final":void 0}if(e.tipo===T.PARTICIPATION_TYPE){if(!e.obrigatorio)return;const s=t;return s!=null&&s.tipo?s.tipo==="por_dia"&&!s.data?"Selecione um dia para participar":"genero"in(s??{})&&!(s!=null&&s.genero)?"Selecione o sexo":void 0:"Selecione o tipo de participação"}if(e.tipo===T.CHECKBOX_GROUP){const s=Array.isArray(t)?t:[];return e.obrigatorio&&s.length===0?"Selecione pelo menos uma opção":void 0}if(e.tipo===T.FILE)return e.obrigatorio&&!t?"Arquivo obrigatório":void 0;if(e.tipo===T.TERMS)return e.obrigatorio&&t!=="accepted"?"Você precisa aceitar os termos para continuar":void 0;if(e.tipo===T.NUMBER){const s=t!=null?String(t):"";if(e.obrigatorio&&!s)return"Campo obrigatório";if(!s)return;const i=Number(s);return isNaN(i)?"Deve ser um número":(n==null?void 0:n.min)!==void 0&&i<n.min?`Valor mínimo: ${n.min}`:(n==null?void 0:n.max)!==void 0&&i>n.max?`Valor máximo: ${n.max}`:void 0}const a=t!=null?String(t):"";if(e.obrigatorio&&!a.trim())return"Campo obrigatório";if(a){if(e.tipo===T.EMAIL&&!U1.test(a))return"E-mail inválido";if(e.tipo===T.CPF&&(!M1.test(a)||!H1(a)))return"CPF inválido";if(e.tipo===T.TELEFONE&&!V1.test(a))return"Telefone inválido";if(e.tipo===T.CEP&&!B1.test(a))return"CEP inválido";if(n!=null&&n.minLength&&a.length<n.minLength)return`Mínimo ${n.minLength} caracteres`;if(n!=null&&n.maxLength&&a.length>n.maxLength)return`Máximo ${n.maxLength} caracteres`;if((e.tipo===T.DATE||e.tipo===T.DATETIME)&&a){if(n!=null&&n.minDate&&a<n.minDate)return`Data mínima: ${n.minDate}`;if(n!=null&&n.maxDate&&a>n.maxDate)return`Data máxima: ${n.maxDate}`}if((e.tipo===T.DATE||e.tipo===T.DATETIME)&&a&&((n==null?void 0:n.minAge)!=null||(n==null?void 0:n.maxAge)!=null)){const s=a.split("T")[0],i=new Date(s+"T00:00:00"),l=r["evento.dataInicioEvento"],c=l?new Date(l.split("T")[0]+"T00:00:00"):new Date;let d=c.getFullYear()-i.getFullYear();const u=c.getMonth()-i.getMonth();if((u<0||u===0&&c.getDate()<i.getDate())&&d--,n.minAge!=null&&d<n.minAge)return`Idade mínima: ${n.minAge} ano${n.minAge!==1?"s":""}`;if(n.maxAge!=null&&d>n.maxAge)return`Idade máxima: ${n.maxAge} ano${n.maxAge!==1?"s":""}`}if(n!=null&&n.regex){const s=W1(n.regex);if(s&&!s.test(a))return n.regexMessage||"Formato inválido"}}},Pc=new Set(["__proto__","constructor","prototype"]),pn=(e,t,r)=>{const n=t.split(".");let a=e;for(let i=0;i<n.length-1;i++){const l=n[i];if(Pc.has(l))return;(a[l]==null||typeof a[l]!="object")&&(a[l]={}),a=a[l]}const s=n[n.length-1];Pc.has(s)||(a[s]=r)},bn=async(e,t,r,n,a,s)=>{for(const i of e){const l=s[i.type];if(!l)continue;const c=await l(r,n,i,a);if(c)return i.message??c}},Qf=(e,t={},r={})=>async n=>{var a,s,i,l,c;const d={},u=[...e.containers].sort((m,p)=>m.ordem-p.ordem);for(const m of u){if(m.repeatable||m.condicional&&!at(m.condicional,n,t))continue;const p=[...m.campos].sort((f,b)=>f.ordem-b.ordem);for(const f of p){if(!at(f.condicional,n,t)||f.tipo===T.HIDDEN||f.isDisabled||f.isReadOnly)continue;if(f.tipo===T.FIELD_ARRAY){const h=Array.isArray(n[f.nome])?n[f.nome]:[];f.obrigatorio&&h.length===0?d[f.nome]={type:"custom",message:"Adicione pelo menos um item"}:f.minItems&&h.length<f.minItems?d[f.nome]={type:"custom",message:`Mínimo de ${f.minItems} item${f.minItems!==1?"s":""}`}:f.maxItems&&h.length>f.maxItems&&(d[f.nome]={type:"custom",message:`Máximo de ${f.maxItems} item${f.maxItems!==1?"s":""}`});for(let x=0;x<h.length;x++){const y=h[x];for(const v of f.subFields??[]){if(v.isDisabled||v.isReadOnly||!at(v.condicional,y,t))continue;const j=Ta(v,y[v.nome],t);if(j){pn(d,`${f.nome}.${x}.${v.nome}`,{type:"custom",message:j});continue}if((a=v.validate)!=null&&a.length){const w=await bn(v.validate,v.nome,y[v.nome],y,t,r);w&&pn(d,`${f.nome}.${x}.${v.nome}`,{type:"custom",message:w})}}}continue}if(f.tipo===T.SUB_FORM){const h=n[f.nome]??{};f.obrigatorio&&Object.keys(h).length===0&&(d[f.nome]={type:"custom",message:"Campo obrigatório"});for(const x of((s=f.subSchema)==null?void 0:s.fields)??[]){if(x.isDisabled||x.isReadOnly)continue;const y=Ta(x,h[x.nome],t);if(y){pn(d,`${f.nome}.${x.nome}`,{type:"custom",message:y});continue}if((i=x.validate)!=null&&i.length){const v=await bn(x.validate,x.nome,h[x.nome],h,t,r);v&&pn(d,`${f.nome}.${x.nome}`,{type:"custom",message:v})}}continue}const b=Ta(f,n[f.nome],t);if(b&&(d[f.nome]={type:"custom",message:b}),!d[f.nome]&&(l=f.validate)!=null&&l.length){const h=await bn(f.validate,f.nome,n[f.nome],n,t,r);h&&(d[f.nome]={type:"custom",message:h})}}}for(const m of u){if(!m.repeatable||!m.nome||m.condicional&&!at(m.condicional,n,t))continue;const p=Array.isArray(n[m.nome])?n[m.nome]:[];m.minItems&&p.length<m.minItems?d[m.nome]={type:"custom",message:`Mínimo de ${m.minItems} ${m.itemLabel??"item"}${m.minItems!==1?"s":""}`}:m.maxItems&&p.length>m.maxItems&&(d[m.nome]={type:"custom",message:`Máximo de ${m.maxItems} ${m.itemLabel??"item"}${m.maxItems!==1?"s":""}`});for(let f=0;f<p.length;f++){const b=p[f];for(const h of m.campos){if(!at(h.condicional,b,t)||h.tipo===T.HIDDEN||h.isDisabled||h.isReadOnly)continue;const x=Ta(h,b[h.nome],t);if(x){pn(d,`${m.nome}.${f}.${h.nome}`,{type:"custom",message:x});continue}if((c=h.validate)!=null&&c.length){const y=await bn(h.validate,h.nome,b[h.nome],b,t,r);y&&pn(d,`${m.nome}.${f}.${h.nome}`,{type:"custom",message:y})}}}}return Object.keys(d).length>0?{values:{},errors:d}:{values:n,errors:{}}},eh=(e,t={},r={})=>async n=>{var a,s;const i={},l=[...e.containers].sort((c,d)=>c.ordem-d.ordem);for(const c of l)if(!(c.condicional&&!at(c.condicional,n,t))){if(c.repeatable&&c.nome){const d=Array.isArray(n[c.nome])?n[c.nome]:[];for(let u=0;u<d.length;u++){const m=d[u];for(const p of[...c.campos].sort((f,b)=>f.ordem-b.ordem)){if(!((a=p.warn)!=null&&a.length)||!at(p.condicional,m,t))continue;const f=await bn(p.warn,p.nome,m[p.nome],m,t,r);f&&(i[`${c.nome}.${u}.${p.nome}`]=f)}}continue}for(const d of[...c.campos].sort((u,m)=>u.ordem-m.ordem)){if(!((s=d.warn)!=null&&s.length)||!at(d.condicional,n,t))continue;const u=await bn(d.warn,d.nome,n[d.nome],n,t,r);u&&(i[d.nome]=u)}}return i},q1=/\{\{\s*(?:event|evento)\.([a-zA-Z0-9_.]+)\s*\}\}/g,xt=(e,t)=>e?e.replace(q1,(r,n)=>t[`evento.${n}`]??t[n]??r):e??"",G1=(e,t)=>({...e,label:xt(e.label,t)}),th=(e,t)=>{var r;return{...e,label:xt(e.label,t),placeholder:xt(e.placeholder,t),hint:xt(e.hint,t),defaultValue:typeof e.defaultValue=="string"?xt(e.defaultValue,t):e.defaultValue,opcoes:(r=e.opcoes)==null?void 0:r.map(n=>G1(n,t))}},Bo=(e,t)=>({...e,titulo:xt(e.titulo,t),descricao:xt(e.descricao,t),campos:e.campos.map(r=>th(r,t))}),rh=(e,t)=>({...e,titulo:xt(e.titulo,t),descricao:xt(e.descricao,t),containers:e.containers.map(r=>Bo(r,t))}),nh=()=>{const e=sa(),t=e.layout.containerStyle,r=e.layout.roundness??"rounded-xl",n=K("overflow-hidden",r,t==="card"?"border":"",t==="bordered"?"border":"",t==="glassmorphism"?"backdrop-blur-sm":""),a=t==="glassmorphism"?{background:"var(--t-surface)",borderColor:"var(--t-border)",borderWidth:"1px",borderStyle:"solid"}:{},s=K("border-b px-6 py-4",t==="flat"?"border-transparent":"");return{wrapperClass:n,wrapperStyle:a,headerClass:s,headerStyle:t==="glassmorphism"?{borderColor:"var(--t-border)"}:{},tmpl:e}},Tt=({name:e,control:t,placeholder:r,type:n="text",disabled:a,readOnly:s})=>{var i;const{field:l,fieldState:c}=$e.useController({name:e,control:t}),d=!!c.error;return o.jsxs("div",{className:"space-y-1",children:[o.jsx(ue,{...l,value:l.value??"",type:n,placeholder:r,disabled:a,readOnly:s,className:K(d&&"border-destructive focus-visible:ring-destructive")}),((i=c.error)==null?void 0:i.message)&&o.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})},Uo=({name:e,control:t,placeholder:r,disabled:n,readOnly:a})=>{var s;const{field:i,fieldState:l}=$e.useController({name:e,control:t});return o.jsxs("div",{className:"space-y-1",children:[o.jsx(po,{...i,value:i.value??"",placeholder:r,disabled:n,readOnly:a,rows:3,className:K(l.error&&"border-destructive focus-visible:ring-destructive")}),((s=l.error)==null?void 0:s.message)&&o.jsx("p",{className:"text-sm text-destructive",children:l.error.message})]})},Ho=({name:e,control:t,placeholder:r,options:n,disabled:a,readOnly:s})=>{var i;const{field:l,fieldState:c}=$e.useController({name:e,control:t});return o.jsxs("div",{className:"space-y-1",children:[o.jsxs(Bt,{value:l.value??"",onValueChange:d=>!s&&l.onChange(d),disabled:a||s,children:[o.jsx(Rt,{className:K(c.error&&"border-destructive focus:ring-destructive"),onBlur:l.onBlur,children:o.jsx(Ut,{placeholder:r??"Selecione..."})}),o.jsx(It,{children:n.map(d=>o.jsx(qe,{value:d.valor,disabled:d.disabled,children:d.label},d.valor))})]}),((i=c.error)==null?void 0:i.message)&&o.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})},Wo=({name:e,control:t,label:r,disabled:n,readOnly:a})=>{var s;const{field:i,fieldState:l}=$e.useController({name:e,control:t});return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx(et,{name:i.name,checked:!!i.value,onCheckedChange:c=>!a&&i.onChange(!!c),onBlur:i.onBlur,disabled:n}),r&&o.jsx("span",{className:"text-sm leading-none",children:r})]}),((s=l.error)==null?void 0:s.message)&&o.jsx("p",{className:"text-sm text-destructive",children:l.error.message})]})},ul=({name:e,control:t,options:r,disabled:n})=>{var a;const{field:s,fieldState:i}=$e.useController({name:e,control:t}),l=Array.isArray(s.value)?s.value:[],c=d=>{const u=l.includes(d)?l.filter(m=>m!==d):[...l,d];s.onChange(u)};return o.jsxs("div",{className:"space-y-1",children:[o.jsx("div",{className:"flex flex-col gap-2",onBlur:s.onBlur,children:r.map(d=>o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx(et,{checked:l.includes(d.valor),onCheckedChange:()=>c(d.valor),disabled:n||d.disabled}),o.jsx("span",{className:"text-sm leading-none",children:d.label})]},d.valor))}),((a=i.error)==null?void 0:a.message)&&o.jsx("p",{className:"text-sm text-destructive",children:i.error.message})]})},ml=({name:e,control:t,options:r,visualStyle:n="default",disabled:a})=>{var s;const{field:i,fieldState:l}=$e.useController({name:e,control:t}),c=n==="card";return o.jsxs("div",{className:"space-y-1",onBlur:i.onBlur,children:[o.jsx(Pi,{value:i.value??"",onValueChange:i.onChange,className:K(c?"grid grid-cols-2 gap-2 sm:grid-cols-3":"flex flex-col gap-2"),children:r.map(d=>o.jsxs("label",{className:K("flex items-center gap-2 cursor-pointer",c&&"rounded-lg border p-3 transition-colors hover:bg-accent data-[selected=true]:border-primary data-[selected=true]:bg-primary/5",(a||d.disabled)&&"cursor-not-allowed opacity-50"),"data-selected":i.value===d.valor?"true":void 0,children:[o.jsx(_i,{value:d.valor,disabled:a||d.disabled}),o.jsx("span",{className:"text-sm leading-none",children:d.label})]},d.valor))}),((s=l.error)==null?void 0:s.message)&&o.jsx("p",{className:"text-sm text-destructive",children:l.error.message})]})},ah=e=>{const t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return`${t}-${r}-${n}`},X1=e=>{const t=new Date;return t.setFullYear(t.getFullYear()-e),ah(t)},Z1=e=>{const t=new Date;return t.setFullYear(t.getFullYear()-e),ah(t)},Rn=({name:e,control:t,isDatetime:r,disabled:n,readOnly:a,validacao:s})=>{var i;const{field:l,fieldState:c}=$e.useController({name:e,control:t}),d=r?"datetime-local":"date",u=f=>r?f+"T00:00":f,m=(s==null?void 0:s.minAge)!=null?u(X1(s.minAge)):(s==null?void 0:s.maxDate)!=null?u(s.maxDate):void 0,p=(s==null?void 0:s.maxAge)!=null?u(Z1(s.maxAge)):(s==null?void 0:s.minDate)!=null?u(s.minDate):void 0;return o.jsxs("div",{className:"space-y-1",children:[o.jsx(ue,{name:l.name,value:l.value??"",onChange:l.onChange,onBlur:l.onBlur,type:d,min:p,max:m,disabled:n,readOnly:a,className:K(c.error&&"border-destructive focus-visible:ring-destructive")}),((i=c.error)==null?void 0:i.message)&&o.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})};function K1(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}const oh={128:"€",130:"‚",131:"ƒ",132:"„",133:"…",134:"†",135:"‡",136:"ˆ",137:"‰",138:"Š",139:"‹",140:"Œ",142:"Ž",145:"‘",146:"’",147:"“",148:"”",149:"•",150:"–",151:"—",152:"˜",153:"™",154:"š",155:"›",156:"œ",158:"ž",159:"Ÿ"};for(const[e,t]of Object.entries(oh));let _c;function Y1(){if(!(typeof globalThis.TextDecoder>"u"))return _c??(_c=new globalThis.TextDecoder("utf-8"))}const In=32*1024,Gt=65533;function J1(e,t="utf-8"){switch(t.toLowerCase()){case"utf-8":case"utf8":{const r=Y1();return r?r.decode(e):ej(e)}case"utf-16le":return tj(e);case"us-ascii":case"ascii":return rj(e);case"latin1":case"iso-8859-1":return nj(e);case"windows-1252":return aj(e);default:throw new RangeError(`Encoding '${t}' not supported`)}}function pl(e,t){t.length!==0&&(e.push(String.fromCharCode.apply(null,t)),t.length=0)}function Ke(e,t,r){t.push(r),t.length>=In&&pl(e,t)}function Q1(e,t,r){if(r<=65535){Ke(e,t,r);return}r-=65536,Ke(e,t,55296+(r>>10)),Ke(e,t,56320+(r&1023))}function ej(e){const t=[],r=[];let n=0;for(e.length>=3&&e[0]===239&&e[1]===187&&e[2]===191&&(n=3);n<e.length;){const a=e[n];if(a<=127){Ke(t,r,a),n++;continue}if(a<194||a>244){Ke(t,r,Gt),n++;continue}if(a<=223){if(n+1>=e.length){Ke(t,r,Gt),n++;continue}const d=e[n+1];if((d&192)!==128){Ke(t,r,Gt),n++;continue}const u=(a&31)<<6|d&63;Ke(t,r,u),n+=2;continue}if(a<=239){if(n+2>=e.length){Ke(t,r,Gt),n++;continue}const d=e[n+1],u=e[n+2];if(!((d&192)===128&&(u&192)===128&&!(a===224&&d<160)&&!(a===237&&d>=160))){Ke(t,r,Gt),n++;continue}const m=(a&15)<<12|(d&63)<<6|u&63;Ke(t,r,m),n+=3;continue}if(n+3>=e.length){Ke(t,r,Gt),n++;continue}const s=e[n+1],i=e[n+2],l=e[n+3];if(!((s&192)===128&&(i&192)===128&&(l&192)===128&&!(a===240&&s<144)&&!(a===244&&s>143))){Ke(t,r,Gt),n++;continue}const c=(a&7)<<18|(s&63)<<12|(i&63)<<6|l&63;Q1(t,r,c),n+=4}return pl(t,r),t.join("")}function tj(e){const t=[],r=[],n=e.length;let a=0;for(;a+1<n;){const s=e[a]|e[a+1]<<8;if(a+=2,s>=55296&&s<=56319){if(a+1<n){const i=e[a]|e[a+1]<<8;i>=56320&&i<=57343?(Ke(t,r,s),Ke(t,r,i),a+=2):Ke(t,r,Gt)}else Ke(t,r,Gt);continue}if(s>=56320&&s<=57343){Ke(t,r,Gt);continue}Ke(t,r,s)}return a<n&&Ke(t,r,Gt),pl(t,r),t.join("")}function rj(e){const t=[];for(let r=0;r<e.length;r+=In){const n=Math.min(e.length,r+In),a=new Array(n-r);for(let s=r,i=0;s<n;s++,i++)a[i]=e[s]&127;t.push(String.fromCharCode.apply(null,a))}return t.join("")}function nj(e){const t=[];for(let r=0;r<e.length;r+=In){const n=Math.min(e.length,r+In),a=new Array(n-r);for(let s=r,i=0;s<n;s++,i++)a[i]=e[s];t.push(String.fromCharCode.apply(null,a))}return t.join("")}function aj(e){const t=[];let r="";for(let n=0;n<e.length;n++){const a=e[n],s=a>=128&&a<=159?oh[a]:void 0;r+=s??String.fromCharCode(a),r.length>=In&&(t.push(r),r="")}return r&&t.push(r),t.join("")}function kt(e){return new DataView(e.buffer,e.byteOffset)}const oj={len:1,get(e,t){return kt(e).getUint8(t)},put(e,t,r){return kt(e).setUint8(t,r),t+1}},Ue={len:2,get(e,t){return kt(e).getUint16(t,!0)},put(e,t,r){return kt(e).setUint16(t,r,!0),t+2}},fn={len:2,get(e,t){return kt(e).getUint16(t)},put(e,t,r){return kt(e).setUint16(t,r),t+2}},Ge={len:4,get(e,t){return kt(e).getUint32(t,!0)},put(e,t,r){return kt(e).setUint32(t,r,!0),t+4}},Oc={len:4,get(e,t){return kt(e).getUint32(t)},put(e,t,r){return kt(e).setUint32(t,r),t+4}},sj={len:4,get(e,t){return kt(e).getInt32(t)},put(e,t,r){return kt(e).setInt32(t,r),t+4}},ij={len:8,get(e,t){return kt(e).getBigUint64(t,!0)},put(e,t,r){return kt(e).setBigUint64(t,r,!0),t+8}};let vr=class{constructor(t,r){this.len=t,this.encoding=r}get(t,r=0){const n=t.subarray(r,r+this.len);return J1(n,this.encoding)}};const lj="End-Of-Stream";class Je extends Error{constructor(){super(lj),this.name="EndOfStreamError"}}let cj=class extends Error{constructor(t="The operation was aborted"){super(t),this.name="AbortError"}},sh=class{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(t,r=!1){const n=await this.read(t,r);return this.peekQueue.push(t.subarray(0,n)),n}async read(t,r=!1){if(t.length===0)return 0;let n=this.readFromPeekBuffer(t);if(this.endOfStream||(n+=await this.readRemainderFromStream(t.subarray(n),r)),n===0&&!r)throw new Je;return n}readFromPeekBuffer(t){let r=t.length,n=0;for(;this.peekQueue.length>0&&r>0;){const a=this.peekQueue.pop();if(!a)throw new Error("peekData should be defined");const s=Math.min(a.length,r);t.set(a.subarray(0,s),n),n+=s,r-=s,s<a.length&&this.peekQueue.push(a.subarray(s))}return n}async readRemainderFromStream(t,r){let n=0;for(;n<t.length&&!this.endOfStream;){if(this.interrupted)throw new cj;const a=await this.readFromStream(t.subarray(n),r);if(a===0)break;n+=a}if(!r&&n<t.length)throw new Je;return n}},dj=class extends sh{constructor(t){super(),this.reader=t}async abort(){return this.close()}async close(){this.reader.releaseLock()}},uj=class extends dj{async readFromStream(t,r){if(t.length===0)return 0;const n=await this.reader.read(new Uint8Array(t.length),{min:r?void 0:t.length});return n.done&&(this.endOfStream=n.done),n.value?(t.set(n.value),n.value.length):0}},Fc=class extends sh{constructor(t){super(),this.reader=t,this.buffer=null}writeChunk(t,r){const n=Math.min(r.length,t.length);return t.set(r.subarray(0,n)),n<r.length?this.buffer=r.subarray(n):this.buffer=null,n}async readFromStream(t,r){if(t.length===0)return 0;let n=0;for(this.buffer&&(n+=this.writeChunk(t,this.buffer));n<t.length&&!this.endOfStream;){const a=await this.reader.read();if(a.done){this.endOfStream=!0;break}a.value&&(n+=this.writeChunk(t.subarray(n),a.value))}if(!r&&n===0&&this.endOfStream)throw new Je;return n}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}};function mj(e){try{const t=e.getReader({mode:"byob"});return t instanceof ReadableStreamDefaultReader?new Fc(t):new uj(t)}catch(t){if(t instanceof TypeError)return new Fc(e.getReader());throw t}}class fl{constructor(t){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=t==null?void 0:t.onClose,t!=null&&t.abortSignal&&t.abortSignal.addEventListener("abort",()=>{this.abort()})}async readToken(t,r=this.position){const n=new Uint8Array(t.len);if(await this.readBuffer(n,{position:r})<t.len)throw new Je;return t.get(n,0)}async peekToken(t,r=this.position){const n=new Uint8Array(t.len);if(await this.peekBuffer(n,{position:r})<t.len)throw new Je;return t.get(n,0)}async readNumber(t){if(await this.readBuffer(this.numBuffer,{length:t.len})<t.len)throw new Je;return t.get(this.numBuffer,0)}async peekNumber(t){if(await this.peekBuffer(this.numBuffer,{length:t.len})<t.len)throw new Je;return t.get(this.numBuffer,0)}async ignore(t){if(t<0)throw new RangeError("ignore length must be ≥ 0 bytes");if(this.fileInfo.size!==void 0){const r=this.fileInfo.size-this.position;if(t>r)return this.position+=r,r}return this.position+=t,t}async close(){var t;await this.abort(),await((t=this.onClose)==null?void 0:t.call(this))}normalizeOptions(t,r){if(!this.supportsRandomAccess()&&r&&r.position!==void 0&&r.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");return{mayBeLess:!1,offset:0,length:t.length,position:this.position,...r}}abort(){return Promise.resolve()}}const pj=256e3;let fj=class extends fl{constructor(t,r){super(r),this.streamReader=t,this.fileInfo=(r==null?void 0:r.fileInfo)??{}}async readBuffer(t,r){const n=this.normalizeOptions(t,r),a=n.position-this.position;if(a>0)return await this.ignore(a),this.readBuffer(t,r);if(a<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(n.length===0)return 0;const s=await this.streamReader.read(t.subarray(0,n.length),n.mayBeLess);if(this.position+=s,(!r||!r.mayBeLess)&&s<n.length)throw new Je;return s}async peekBuffer(t,r){const n=this.normalizeOptions(t,r);let a=0;if(n.position){const s=n.position-this.position;if(s>0){const i=new Uint8Array(n.length+s);return a=await this.peekBuffer(i,{mayBeLess:n.mayBeLess}),t.set(i.subarray(s)),a-s}if(s<0)throw new Error("Cannot peek from a negative offset in a stream")}if(n.length>0){try{a=await this.streamReader.peek(t.subarray(0,n.length),n.mayBeLess)}catch(s){if(r!=null&&r.mayBeLess&&s instanceof Je)return 0;throw s}if(!n.mayBeLess&&a<n.length)throw new Je}return a}async ignore(t){if(t<0)throw new RangeError("ignore length must be ≥ 0 bytes");const r=Math.min(pj,t),n=new Uint8Array(r);let a=0;for(;a<t;){const s=t-a,i=await this.readBuffer(n,{length:Math.min(r,s)});if(i<0)return i;a+=i}return a}abort(){return this.streamReader.abort()}async close(){return this.streamReader.close()}supportsRandomAccess(){return!1}},hj=class extends fl{constructor(t,r){super(r),this.uint8Array=t,this.fileInfo={...(r==null?void 0:r.fileInfo)??{},size:t.length}}async readBuffer(t,r){r!=null&&r.position&&(this.position=r.position);const n=await this.peekBuffer(t,r);return this.position+=n,n}async peekBuffer(t,r){const n=this.normalizeOptions(t,r),a=Math.min(this.uint8Array.length-n.position,n.length);if(!n.mayBeLess&&a<n.length)throw new Je;return t.set(this.uint8Array.subarray(n.position,n.position+a)),a}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(t){this.position=t}},xj=class extends fl{constructor(t,r){super(r),this.blob=t,this.fileInfo={...(r==null?void 0:r.fileInfo)??{},size:t.size,mimeType:t.type}}async readBuffer(t,r){r!=null&&r.position&&(this.position=r.position);const n=await this.peekBuffer(t,r);return this.position+=n,n}async peekBuffer(t,r){const n=this.normalizeOptions(t,r),a=Math.min(this.blob.size-n.position,n.length);if(!n.mayBeLess&&a<n.length)throw new Je;const s=await this.blob.slice(n.position,n.position+a).arrayBuffer();return t.set(new Uint8Array(s)),a}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(t){this.position=t}};function gj(e,t){const r=mj(e),n=t??{},a=n.onClose;return n.onClose=async()=>{if(await r.close(),a)return a()},new fj(r,n)}function vj(e,t){return new hj(e,t)}function bj(e,t){return new xj(e,t)}var ii={exports:{}},vs,zc;function yj(){if(zc)return vs;zc=1;var e=1e3,t=e*60,r=t*60,n=r*24,a=n*7,s=n*365.25;vs=function(u,m){m=m||{};var p=typeof u;if(p==="string"&&u.length>0)return i(u);if(p==="number"&&isFinite(u))return m.long?c(u):l(u);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(u))};function i(u){if(u=String(u),!(u.length>100)){var m=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(u);if(m){var p=parseFloat(m[1]),f=(m[2]||"ms").toLowerCase();switch(f){case"years":case"year":case"yrs":case"yr":case"y":return p*s;case"weeks":case"week":case"w":return p*a;case"days":case"day":case"d":return p*n;case"hours":case"hour":case"hrs":case"hr":case"h":return p*r;case"minutes":case"minute":case"mins":case"min":case"m":return p*t;case"seconds":case"second":case"secs":case"sec":case"s":return p*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return p;default:return}}}}function l(u){var m=Math.abs(u);return m>=n?Math.round(u/n)+"d":m>=r?Math.round(u/r)+"h":m>=t?Math.round(u/t)+"m":m>=e?Math.round(u/e)+"s":u+"ms"}function c(u){var m=Math.abs(u);return m>=n?d(u,m,n,"day"):m>=r?d(u,m,r,"hour"):m>=t?d(u,m,t,"minute"):m>=e?d(u,m,e,"second"):u+" ms"}function d(u,m,p,f){var b=m>=p*1.5;return Math.round(u/p)+" "+f+(b?"s":"")}return vs}function wj(e){r.debug=r,r.default=r,r.coerce=c,r.disable=i,r.enable=a,r.enabled=l,r.humanize=yj(),r.destroy=d,Object.keys(e).forEach(u=>{r[u]=e[u]}),r.names=[],r.skips=[],r.formatters={};function t(u){let m=0;for(let p=0;p<u.length;p++)m=(m<<5)-m+u.charCodeAt(p),m|=0;return r.colors[Math.abs(m)%r.colors.length]}r.selectColor=t;function r(u){let m,p=null,f,b;function h(...x){if(!h.enabled)return;const y=h,v=Number(new Date),j=v-(m||v);y.diff=j,y.prev=m,y.curr=v,m=v,x[0]=r.coerce(x[0]),typeof x[0]!="string"&&x.unshift("%O");let w=0;x[0]=x[0].replace(/%([a-zA-Z%])/g,(C,S)=>{if(C==="%%")return"%";w++;const $=r.formatters[S];if(typeof $=="function"){const k=x[w];C=$.call(y,k),x.splice(w,1),w--}return C}),r.formatArgs.call(y,x),(y.log||r.log).apply(y,x)}return h.namespace=u,h.useColors=r.useColors(),h.color=r.selectColor(u),h.extend=n,h.destroy=r.destroy,Object.defineProperty(h,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(f!==r.namespaces&&(f=r.namespaces,b=r.enabled(u)),b),set:x=>{p=x}}),typeof r.init=="function"&&r.init(h),h}function n(u,m){const p=r(this.namespace+(typeof m>"u"?":":m)+u);return p.log=this.log,p}function a(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];const m=(typeof u=="string"?u:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const p of m)p[0]==="-"?r.skips.push(p.slice(1)):r.names.push(p)}function s(u,m){let p=0,f=0,b=-1,h=0;for(;p<u.length;)if(f<m.length&&(m[f]===u[p]||m[f]==="*"))m[f]==="*"?(b=f,h=p,f++):(p++,f++);else if(b!==-1)f=b+1,h++,p=h;else return!1;for(;f<m.length&&m[f]==="*";)f++;return f===m.length}function i(){const u=[...r.names,...r.skips.map(m=>"-"+m)].join(",");return r.enable(""),u}function l(u){for(const m of r.skips)if(s(u,m))return!1;for(const m of r.names)if(s(u,m))return!0;return!1}function c(u){return u instanceof Error?u.stack||u.message:u}function d(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}var jj=wj;(function(e,t){t.formatArgs=n,t.save=a,t.load=s,t.useColors=r,t.storage=i(),t.destroy=(()=>{let c=!1;return()=>{c||(c=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function r(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let c;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(c=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(c[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function n(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const d="color: "+this.color;c.splice(1,0,d,"color: inherit");let u=0,m=0;c[0].replace(/%[a-zA-Z%]/g,p=>{p!=="%%"&&(u++,p==="%c"&&(m=u))}),c.splice(m,0,d)}t.log=console.debug||console.log||(()=>{});function a(c){try{c?t.storage.setItem("debug",c):t.storage.removeItem("debug")}catch{}}function s(){let c;try{c=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch{}return!c&&typeof process<"u"&&"env"in process&&(c=process.env.DEBUG),c}function i(){try{return localStorage}catch{}}e.exports=jj(t);const{formatters:l}=e.exports;l.j=function(c){try{return JSON.stringify(c)}catch(d){return"[UnexpectedJSONParseError]: "+d.message}}})(ii,ii.exports);var kj=ii.exports;const Cj=K1(kj),yn={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},Lc={get(e){return{signature:Ge.get(e,0),compressedSize:Ge.get(e,8),uncompressedSize:Ge.get(e,12)}},len:16},Nj={get(e){const t=Ue.get(e,6);return{signature:Ge.get(e,0),minVersion:Ue.get(e,4),dataDescriptor:!!(t&8),compressedMethod:Ue.get(e,8),compressedSize:Ge.get(e,18),uncompressedSize:Ge.get(e,22),filenameLength:Ue.get(e,26),extraFieldLength:Ue.get(e,28),filename:null}},len:30},Sj={get(e){return{signature:Ge.get(e,0),nrOfThisDisk:Ue.get(e,4),nrOfThisDiskWithTheStart:Ue.get(e,6),nrOfEntriesOnThisDisk:Ue.get(e,8),nrOfEntriesOfSize:Ue.get(e,10),sizeOfCd:Ge.get(e,12),offsetOfStartOfCd:Ge.get(e,16),zipFileCommentLength:Ue.get(e,20)}},len:22},$j={get(e){const t=Ue.get(e,8);return{signature:Ge.get(e,0),minVersion:Ue.get(e,6),dataDescriptor:!!(t&8),compressedMethod:Ue.get(e,10),compressedSize:Ge.get(e,20),uncompressedSize:Ge.get(e,24),filenameLength:Ue.get(e,28),extraFieldLength:Ue.get(e,30),fileCommentLength:Ue.get(e,32),relativeOffsetOfLocalHeader:Ge.get(e,42),filename:null}},len:46};function ih(e){const t=new Uint8Array(Ge.len);return Ge.put(t,0,e),t}const nr=Cj("tokenizer:inflate"),bs=256*1024,Ej=ih(yn.DataDescriptor),Aa=ih(yn.EndOfCentralDirectory);class ha{constructor(t){this.tokenizer=t,this.syncBuffer=new Uint8Array(bs)}async isZip(){return await this.peekSignature()===yn.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(Ge)}async findEndOfCentralDirectoryLocator(){const t=this.tokenizer,r=Math.min(16*1024,t.fileInfo.size),n=this.syncBuffer.subarray(0,r);await this.tokenizer.readBuffer(n,{position:t.fileInfo.size-r});for(let a=n.length-4;a>=0;a--)if(n[a]===Aa[0]&&n[a+1]===Aa[1]&&n[a+2]===Aa[2]&&n[a+3]===Aa[3])return t.fileInfo.size-r+a;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){nr("Cannot reading central-directory without random-read support");return}nr("Reading central-directory...");const t=this.tokenizer.position,r=await this.findEndOfCentralDirectoryLocator();if(r>0){nr("Central-directory 32-bit signature found");const n=await this.tokenizer.readToken(Sj,r),a=[];this.tokenizer.setPosition(n.offsetOfStartOfCd);for(let s=0;s<n.nrOfEntriesOfSize;++s){const i=await this.tokenizer.readToken($j);if(i.signature!==yn.CentralFileHeader)throw new Error("Expected Central-File-Header signature");i.filename=await this.tokenizer.readToken(new vr(i.filenameLength,"utf-8")),await this.tokenizer.ignore(i.extraFieldLength),await this.tokenizer.ignore(i.fileCommentLength),a.push(i),nr(`Add central-directory file-entry: n=${s+1}/${a.length}: filename=${a[s].filename}`)}return this.tokenizer.setPosition(t),a}this.tokenizer.setPosition(t)}async unzip(t){const r=await this.readCentralDirectory();if(r)return this.iterateOverCentralDirectory(r,t);let n=!1;do{const a=await this.readLocalFileHeader();if(!a)break;const s=t(a);n=!!s.stop;let i;if(await this.tokenizer.ignore(a.extraFieldLength),a.dataDescriptor&&a.compressedSize===0){const l=[];let c=bs;nr("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let d=-1;for(;d<0&&c===bs;){c=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),d=Dj(this.syncBuffer.subarray(0,c),Ej);const u=d>=0?d:c;if(s.handler){const m=new Uint8Array(u);await this.tokenizer.readBuffer(m),l.push(m)}else await this.tokenizer.ignore(u)}nr(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),s.handler&&await this.inflate(a,Tj(l),s.handler)}else s.handler?(nr(`Reading compressed-file-data: ${a.compressedSize} bytes`),i=new Uint8Array(a.compressedSize),await this.tokenizer.readBuffer(i),await this.inflate(a,i,s.handler)):(nr(`Ignoring compressed-file-data: ${a.compressedSize} bytes`),await this.tokenizer.ignore(a.compressedSize));if(nr(`Reading data-descriptor at pos=${this.tokenizer.position}`),a.dataDescriptor&&(await this.tokenizer.readToken(Lc)).signature!==134695760)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-Lc.len}`)}while(!n)}async iterateOverCentralDirectory(t,r){for(const n of t){const a=r(n);if(a.handler){this.tokenizer.setPosition(n.relativeOffsetOfLocalHeader);const s=await this.readLocalFileHeader();if(s){await this.tokenizer.ignore(s.extraFieldLength);const i=new Uint8Array(n.compressedSize);await this.tokenizer.readBuffer(i),await this.inflate(s,i,a.handler)}}if(a.stop)break}}async inflate(t,r,n){if(t.compressedMethod===0)return n(r);if(t.compressedMethod!==8)throw new Error(`Unsupported ZIP compression method: ${t.compressedMethod}`);nr(`Decompress filename=${t.filename}, compressed-size=${r.length}`);const a=await ha.decompressDeflateRaw(r);return n(a)}static async decompressDeflateRaw(t){const r=new ReadableStream({start(s){s.enqueue(t),s.close()}}),n=new DecompressionStream("deflate-raw"),a=r.pipeThrough(n);try{const s=await new Response(a).arrayBuffer();return new Uint8Array(s)}catch(s){const i=s instanceof Error?`Failed to deflate ZIP entry: ${s.message}`:"Unknown decompression error in ZIP entry";throw new TypeError(i)}}async readLocalFileHeader(){const t=await this.tokenizer.peekToken(Ge);if(t===yn.LocalFileHeader){const r=await this.tokenizer.readToken(Nj);return r.filename=await this.tokenizer.readToken(new vr(r.filenameLength,"utf-8")),r}if(t===yn.CentralFileHeader)return!1;throw t===3759263696?new Error("Encrypted ZIP"):new Error("Unexpected signature")}}function Dj(e,t){const r=e.length,n=t.length;if(n>r)return-1;for(let a=0;a<=r-n;a++){let s=!0;for(let i=0;i<n;i++)if(e[a+i]!==t[i]){s=!1;break}if(s)return a}return-1}function Tj(e){const t=e.reduce((a,s)=>a+s.length,0),r=new Uint8Array(t);let n=0;for(const a of e)r.set(a,n),n+=a.length;return r}let Aj=class{constructor(t){this.tokenizer=t}inflate(){const t=this.tokenizer;return new ReadableStream({async pull(r){const n=new Uint8Array(1024),a=await t.readBuffer(n,{mayBeLess:!0});if(a===0){r.close();return}r.enqueue(n.subarray(0,a))}}).pipeThrough(new DecompressionStream("gzip"))}};new globalThis.TextDecoder("utf8");new globalThis.TextEncoder;Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Mc(e){const{byteLength:t}=e;if(t===6)return e.getUint16(0)*2**32+e.getUint32(2);if(t===5)return e.getUint8(0)*2**32+e.getUint32(1);if(t===4)return e.getUint32(0);if(t===3)return e.getUint8(0)*2**16+e.getUint16(1);if(t===2)return e.getUint16(0);if(t===1)return e.getUint8(0)}function Rj(e,t){if(t==="utf-16le"){const r=[];for(let n=0;n<e.length;n++){const a=e.charCodeAt(n);r.push(a&255,a>>8&255)}return r}if(t==="utf-16be"){const r=[];for(let n=0;n<e.length;n++){const a=e.charCodeAt(n);r.push(a>>8&255,a&255)}return r}return[...e].map(r=>r.charCodeAt(0))}function Ij(e,t=0){const r=Number.parseInt(new vr(6).get(e,148).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(r))return!1;let n=8*32;for(let a=t;a<t+148;a++)n+=e[a];for(let a=t+156;a<t+512;a++)n+=e[a];return r===n}const Pj={get:(e,t)=>e[t+3]&127|e[t+2]<<7|e[t+1]<<14|e[t]<<21,len:4},_j=["jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","oga","ogg","ogv","opus","flac","wav","spx","amr","pdf","epub","elf","macho","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ttc","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","j2c","jp2","jpm","jpx","mj2","aif","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","dcm","ics","glb","pcap","dsf","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a","mie","asf","ogm","ogx","mpc","arrow","shp","aac","mp1","it","s3m","xm","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet","class","arj","cpio","ace","avro","icc","fbx","vsdx","vtt","apk","drc","lz4","potx","xltx","dotx","xltm","ott","ots","otp","odg","otg","xlsm","docm","dotm","potm","pptm","jar","jmp","rm","sav","ppsm","ppsx","tar.gz","reg","dat"],Oj=["image/jpeg","image/png","image/gif","image/webp","image/flif","image/x-xcf","image/x-canon-cr2","image/x-canon-cr3","image/tiff","image/bmp","image/vnd.ms-photo","image/vnd.adobe.photoshop","application/x-indesign","application/epub+zip","application/x-xpinstall","application/vnd.ms-powerpoint.slideshow.macroenabled.12","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.slideshow","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/vnd.apache.arrow.file","video/mp4","audio/midi","video/matroska","video/webm","video/quicktime","video/vnd.avi","audio/wav","audio/qcelp","audio/x-ms-asf","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","video/ogg","audio/ogg","audio/ogg; codecs=opus","application/ogg","audio/flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-elf","application/x-mach-binary","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","font/collection","image/x-icon","video/x-flv","application/postscript","application/eps","application/x-xz","application/x-sqlite3","application/x-nintendo-nes-rom","application/x-google-chrome-extension","application/vnd.ms-cab-compressed","application/x-deb","application/x-unix-archive","application/x-rpm","application/x-compress","application/x-lzip","application/x-cfb","application/x-mie","application/mxf","video/mp2t","application/x-blender","image/bpg","image/j2c","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","application/xml","application/x-mobipocket-ebook","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/icns","image/ktx","application/dicom","audio/x-musepack","text/calendar","text/vcard","text/vtt","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","application/x.ms.shortcut","application/x.apple.alias","audio/x-voc","audio/vnd.dolby.dd-raw","audio/x-m4a","image/apng","image/x-olympus-orf","image/x-sony-arw","image/x-adobe-dng","image/x-nikon-nef","image/x-panasonic-rw2","image/x-fujifilm-raf","video/x-m4v","video/3gpp2","application/x-esri-shape","audio/aac","audio/x-it","audio/x-s3m","audio/x-xm","video/MP1S","video/MP2P","application/vnd.sketchup.skp","image/avif","application/x-lzh-compressed","application/pgp-encrypted","application/x-asar","model/stl","application/vnd.ms-htmlhelp","model/3mf","image/jxl","application/zstd","image/jls","application/vnd.ms-outlook","image/vnd.dwg","application/vnd.apache.parquet","application/java-vm","application/x-arj","application/x-cpio","application/x-ace-compressed","application/avro","application/vnd.iccprofile","application/x.autodesk.fbx","application/vnd.visio","application/vnd.android.package-archive","application/vnd.google.draco","application/x-lz4","application/vnd.openxmlformats-officedocument.presentationml.template","application/vnd.openxmlformats-officedocument.spreadsheetml.template","application/vnd.openxmlformats-officedocument.wordprocessingml.template","application/vnd.ms-excel.template.macroenabled.12","application/vnd.oasis.opendocument.text-template","application/vnd.oasis.opendocument.spreadsheet-template","application/vnd.oasis.opendocument.presentation-template","application/vnd.oasis.opendocument.graphics","application/vnd.oasis.opendocument.graphics-template","application/vnd.ms-excel.sheet.macroenabled.12","application/vnd.ms-word.document.macroenabled.12","application/vnd.ms-word.template.macroenabled.12","application/vnd.ms-powerpoint.template.macroenabled.12","application/vnd.ms-powerpoint.presentation.macroenabled.12","application/java-archive","application/vnd.rn-realmedia","application/x-spss-sav","application/x-ms-regedit","application/x-ft-windows-registry-hive","application/x-jmp-data"],Kn=4100,Fj=Kn-2,ur=1024*1024,Vc=1024,zj=2**31-1,Lt=16*1024*1024,qo=ur,Bc=ur,Lj=Lt,Mj=1,Uc=100,ys=Lt,Hc=64,Wc=qo,Vj=256,Bj=512,Uj=Lt,Hj=512,Wj=512,qc=256,Gc=qo,Xc=qo,qj=qo,Zc=Lt,Gj=new Set(["Unexpected signature","Encrypted ZIP","Expected Central-File-Header signature"]),Xj=["ZIP entry count exceeds ","Unsupported ZIP compression method:","ZIP entry compressed data exceeds ","ZIP entry decompressed data exceeds ","Expected data-descriptor-signature at position "],Zj=new Set(["Z_BUF_ERROR","Z_DATA_ERROR","ERR_INVALID_STATE"]);class Yr extends Error{}function Kj(e){var t;const r=e==null?void 0:e.streamReader;if(((t=r==null?void 0:r.constructor)==null?void 0:t.name)!=="WebStreamByobReader")return e;const{reader:n}=r,a=async()=>{await n.cancel(),n.releaseLock()};return r.close=a,r.abort=async()=>{r.interrupted=!0,await a()},e}function hl(e,t,r){if(!Number.isFinite(e)||e<0||e>t)throw new Yr(`${r} has invalid size ${e} (maximum ${t} bytes)`);return e}async function Rr(e,t,{maximumLength:r=Lt,reason:n="skip"}={}){const a=hl(t,r,n);await e.ignore(a)}async function ws(e,t,r,{maximumLength:n=t.length,reason:a="read"}={}){const s=t.length,i=hl(s,n,a);return e.readBuffer(t,{...r,length:i})}async function Yj(e,{maximumLength:t=ur}={}){const r=new ReadableStream({start(l){l.enqueue(e),l.close()}}).pipeThrough(new DecompressionStream("deflate-raw")).getReader(),n=[];let a=0;try{for(;;){const{done:l,value:c}=await r.read();if(l)break;if(a+=c.length,a>t)throw await r.cancel(),new Error(`ZIP entry decompressed data exceeds ${t} bytes`);n.push(c)}}finally{r.releaseLock()}const s=new Uint8Array(a);let i=0;for(const l of n)s.set(l,i),i+=l.length;return s}const lh=134695760,Qa=16,Jj=Qa-1;function Qj(e,t){if(e.length<Qa)return-1;const r=e.length-Qa;for(let n=0;n<=r;n++)if(Ge.get(e,n)===lh&&Ge.get(e,n+8)===t+n)return n;return-1}function ek(e){return(e.codePointAt(0)&32)!==0}function tk(e,t){const r=new Uint8Array(t);let n=0;for(const a of e)r.set(a,n),n+=a.length;return r}async function rk(e,{shouldBuffer:t,maximumLength:r=ur}={}){const{syncBuffer:n}=e,{length:a}=n,s=[];let i=0;for(;;){const l=await e.tokenizer.peekBuffer(n,{mayBeLess:!0}),c=Qj(n.subarray(0,l),i),d=c>=0?0:l===a?Math.min(Jj,l-1):0,u=c>=0?c:l-d;if(u===0)break;if(i+=u,i>r)throw new Error(`ZIP entry compressed data exceeds ${r} bytes`);if(t){const m=new Uint8Array(u);await e.tokenizer.readBuffer(m),s.push(m)}else await e.tokenizer.ignore(u);if(c>=0)break}if(mt(e.tokenizer)||(e.knownSizeDescriptorScannedBytes+=i),!!t)return tk(s,i)}function nk(e,t){return mt(e.tokenizer)?Math.max(0,Lt-(e.tokenizer.position-t)):Math.max(0,ur-e.knownSizeDescriptorScannedBytes)}async function ak(e,t,{shouldBuffer:r,maximumDescriptorLength:n=ur}={}){if(t.dataDescriptor&&t.compressedSize===0)return rk(e,{shouldBuffer:r,maximumLength:n});if(!r){await Rr(e.tokenizer,t.compressedSize,{maximumLength:mt(e.tokenizer)?ur:e.tokenizer.fileInfo.size,reason:"ZIP entry compressed data"});return}const a=uk(e.tokenizer);if(!Number.isFinite(t.compressedSize)||t.compressedSize<0||t.compressedSize>a)throw new Error(`ZIP entry compressed data exceeds ${a} bytes`);const s=new Uint8Array(t.compressedSize);return await e.tokenizer.readBuffer(s),s}ha.prototype.inflate=async function(e,t,r){if(e.compressedMethod===0)return r(t);if(e.compressedMethod!==8)throw new Error(`Unsupported ZIP compression method: ${e.compressedMethod}`);const n=await Yj(t,{maximumLength:ur});return r(n)};ha.prototype.unzip=async function(e){let t=!1,r=0;const n=this.tokenizer.position;this.knownSizeDescriptorScannedBytes=0;do{if(Yn(this.tokenizer,n,Lt))throw new Yr(`ZIP stream probing exceeds ${Lt} bytes`);const a=await this.readLocalFileHeader();if(!a)break;if(r++,r>Vc)throw new Error(`ZIP entry count exceeds ${Vc}`);const s=e(a);t=!!s.stop,await this.tokenizer.ignore(a.extraFieldLength);const i=await ak(this,a,{shouldBuffer:!!s.handler,maximumDescriptorLength:Math.min(ur,nk(this,n))});if(s.handler&&await this.inflate(a,i,s.handler),a.dataDescriptor){const l=new Uint8Array(Qa);if(await this.tokenizer.readBuffer(l),Ge.get(l,0)!==lh)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-l.length}`)}if(Yn(this.tokenizer,n,Lt))throw new Yr(`ZIP stream probing exceeds ${Lt} bytes`)}while(!t)};function ok(e,t){const r=e.getReader();let n=0,a=!1,s=!1;const i=async l=>{a||s||(s=!0,await r.cancel(l))};return new ReadableStream({async pull(l){if(n>=t){l.close(),await i();return}const{done:c,value:d}=await r.read();if(c||!d){a=!0,l.close();return}const u=t-n;if(d.length>u){l.enqueue(d.subarray(0,u)),n+=u,l.close(),await i();return}l.enqueue(d),n+=d.length},async cancel(l){await i(l)}})}async function sk(e,t){return new xk(t).fromBlob(e)}function Kc(e){switch(e=e.toLowerCase(),e){case"application/epub+zip":return{ext:"epub",mime:e};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:e};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:e};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:e};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:e};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:e};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:e};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:e};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:e};case"application/vnd.openxmlformats-officedocument.presentationml.slideshow":return{ext:"ppsx",mime:e};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:e};case"application/vnd.ms-excel.sheet.macroenabled":return{ext:"xlsm",mime:"application/vnd.ms-excel.sheet.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.spreadsheetml.template":return{ext:"xltx",mime:e};case"application/vnd.ms-excel.template.macroenabled":return{ext:"xltm",mime:"application/vnd.ms-excel.template.macroenabled.12"};case"application/vnd.ms-powerpoint.slideshow.macroenabled":return{ext:"ppsm",mime:"application/vnd.ms-powerpoint.slideshow.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return{ext:"docx",mime:e};case"application/vnd.ms-word.document.macroenabled":return{ext:"docm",mime:"application/vnd.ms-word.document.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.template":return{ext:"dotx",mime:e};case"application/vnd.ms-word.template.macroenabledtemplate":return{ext:"dotm",mime:"application/vnd.ms-word.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.template":return{ext:"potx",mime:e};case"application/vnd.ms-powerpoint.template.macroenabled":return{ext:"potm",mime:"application/vnd.ms-powerpoint.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.presentation":return{ext:"pptx",mime:e};case"application/vnd.ms-powerpoint.presentation.macroenabled":return{ext:"pptm",mime:"application/vnd.ms-powerpoint.presentation.macroenabled.12"};case"application/vnd.ms-visio.drawing":return{ext:"vsdx",mime:"application/vnd.visio"};case"application/vnd.ms-package.3dmanufacturing-3dmodel+xml":return{ext:"3mf",mime:"model/3mf"}}}function ar(e,t,r){r={offset:0,...r};for(const[n,a]of t.entries())if(r.mask){if(a!==(r.mask[n]&e[n+r.offset]))return!1}else if(a!==e[n+r.offset])return!1;return!0}function ik(e){return Number.isFinite(e)?Math.max(1,Math.trunc(e)):Kn}function lk(e,t,r){return r===void 0?e.read(t):(r.throwIfAborted(),new Promise((n,a)=>{const s=()=>{r.removeEventListener("abort",i)},i=()=>{const l=r.reason;s(),(async()=>{try{await e.cancel(l)}catch{}})(),a(l)};r.addEventListener("abort",i,{once:!0}),(async()=>{try{const l=await e.read(t);s(),n(l)}catch(l){s(),a(l)}})()}))}function ck(e){return Number.isFinite(e)?Math.max(0,Math.min(Fj,Math.trunc(e))):0}function dk(e){return Number.isFinite(e)?Math.max(0,e):Number.MAX_SAFE_INTEGER}function mt(e){const t=e.fileInfo.size;return!Number.isFinite(t)||t===Number.MAX_SAFE_INTEGER}function Yn(e,t,r){return mt(e)&&e.position-t>r}function uk(e){const t=e.fileInfo.size,r=Number.isFinite(t)?Math.max(0,t-e.position):Number.MAX_SAFE_INTEGER;return Math.min(r,zj)}function mk(e){if(e instanceof Je||e instanceof Yr)return!0;if(!(e instanceof Error))return!1;if(Gj.has(e.message)||Zj.has(e.code))return!0;for(const t of Xj)if(e.message.startsWith(t))return!0;return!1}function Yc(e,t=ur){const r=[e.compressedSize,e.uncompressedSize];for(const n of r)if(!Number.isFinite(n)||n<0||n>t)return!1;return!0}function pk(){return{hasContentTypesEntry:!1,hasParsedContentTypesEntry:!1,isParsingContentTypes:!1,hasUnparseableContentTypes:!1,hasWordDirectory:!1,hasPresentationDirectory:!1,hasSpreadsheetDirectory:!1,hasThreeDimensionalModelEntry:!1}}function fk(e,t){t.startsWith("word/")&&(e.hasWordDirectory=!0),t.startsWith("ppt/")&&(e.hasPresentationDirectory=!0),t.startsWith("xl/")&&(e.hasSpreadsheetDirectory=!0),t.startsWith("3D/")&&t.endsWith(".model")&&(e.hasThreeDimensionalModelEntry=!0)}function Jc(e){if(!(!e.hasContentTypesEntry||e.hasUnparseableContentTypes||e.isParsingContentTypes||e.hasParsedContentTypesEntry)){if(e.hasWordDirectory)return{ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"};if(e.hasPresentationDirectory)return{ext:"pptx",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"};if(e.hasSpreadsheetDirectory)return{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};if(e.hasThreeDimensionalModelEntry)return{ext:"3mf",mime:"model/3mf"}}}function hk(e){const t=e.indexOf('.main+xml"');if(t===-1){const a="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";return e.includes(`ContentType="${a}"`)?a:void 0}const r=e.slice(0,t),n=r.lastIndexOf('"');return r.slice(n+1)}let xk=class ch{constructor(t){Ic(this,"detectConfident",async n=>{if(this.buffer=new Uint8Array(Kn),n.fileInfo.size===void 0&&(n.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=n,mt(n)&&(await n.peekBuffer(this.buffer,{length:3,mayBeLess:!0}),this.check([31,139,8])))return this.detectGzip(n);if(await n.peekBuffer(this.buffer,{length:32,mayBeLess:!0}),this.check([66,77]))return{ext:"bmp",mime:"image/bmp"};if(this.check([11,119]))return{ext:"ac3",mime:"audio/vnd.dolby.dd-raw"};if(this.check([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(this.check([77,90]))return{ext:"exe",mime:"application/x-msdownload"};if(this.check([37,33]))return await n.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString("PS-Adobe-",{offset:2})&&this.checkString(" EPSF-",{offset:14})?{ext:"eps",mime:"application/eps"}:{ext:"ps",mime:"application/postscript"};if(this.check([31,160])||this.check([31,157]))return{ext:"Z",mime:"application/x-compress"};if(this.check([199,113]))return{ext:"cpio",mime:"application/x-cpio"};if(this.check([96,234]))return{ext:"arj",mime:"application/x-arj"};if(this.check([239,187,191]))return this.detectionReentryCount>=qc?void 0:(this.detectionReentryCount++,await this.tokenizer.ignore(3),this.detectConfident(n));if(this.check([71,73,70]))return{ext:"gif",mime:"image/gif"};if(this.check([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(this.check([31,139,8]))return this.detectGzip(n);if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await Rr(n,6,{maximumLength:6,reason:"ID3 header prefix"});const a=await n.readToken(Pj),s=mt(n);if(!Number.isFinite(a)||a<0||s&&(a>ys||n.position+a>ys))return;if(n.position+a>n.fileInfo.size)return s?void 0:{ext:"mp3",mime:"audio/mpeg"};try{await Rr(n,a,{maximumLength:s?ys:n.fileInfo.size,reason:"ID3 payload"})}catch(i){if(i instanceof Je)return;throw i}return this.detectionReentryCount>=qc?void 0:(this.detectionReentryCount++,this.parseTokenizer(n,this.detectionReentryCount))}if(this.checkString("MP+"))return{ext:"mpc",mime:"audio/x-musepack"};if((this.buffer[0]===67||this.buffer[0]===70)&&this.check([87,83],{offset:1}))return{ext:"swf",mime:"application/x-shockwave-flash"};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:"jls",mime:"image/jls"}:{ext:"jpg",mime:"image/jpeg"};if(this.check([79,98,106,1]))return{ext:"avro",mime:"application/avro"};if(this.checkString("FLIF"))return{ext:"flif",mime:"image/flif"};if(this.checkString("8BPS"))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(this.checkString("MPCK"))return{ext:"mpc",mime:"audio/x-musepack"};if(this.checkString("FORM"))return{ext:"aif",mime:"audio/aiff"};if(this.checkString("icns",{offset:0}))return{ext:"icns",mime:"image/icns"};if(this.check([80,75,3,4])){let a;const s=pk();try{await new ha(n).unzip(i=>{fk(s,i.filename);const l=i.filename==="[Content_Types].xml",c=Jc(s);if(!l&&c)return a=c,{stop:!0};switch(i.filename){case"META-INF/mozilla.rsa":return a={ext:"xpi",mime:"application/x-xpinstall"},{stop:!0};case"META-INF/MANIFEST.MF":return a={ext:"jar",mime:"application/java-archive"},{stop:!0};case"mimetype":return Yc(i,Bc)?{async handler(d){const u=new TextDecoder("utf-8").decode(d).trim();a=Kc(u)},stop:!0}:{};case"[Content_Types].xml":return s.hasContentTypesEntry=!0,Yc(i,Bc)?(s.isParsingContentTypes=!0,{async handler(d){const u=new TextDecoder("utf-8").decode(d),m=hk(u);m&&(a=Kc(m)),s.hasParsedContentTypesEntry=!0,s.isParsingContentTypes=!1},stop:!0}):(s.hasUnparseableContentTypes=!0,{});default:return/classes\d*\.dex/.test(i.filename)?(a={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}})}catch(i){if(!mk(i))throw i;s.isParsingContentTypes&&(s.isParsingContentTypes=!1,s.hasUnparseableContentTypes=!0)}return a??Jc(s)??{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await n.ignore(28);const a=new Uint8Array(8);return await n.readBuffer(a),ar(a,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:ar(a,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:ar(a,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:ar(a,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:ar(a,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:ar(a,[1,118,111,114,98,105,115])?{ext:"ogg",mime:"audio/ogg"}:{ext:"ogx",mime:"application/ogg"}}if(this.check([80,75])&&(this.buffer[2]===3||this.buffer[2]===5||this.buffer[2]===7)&&(this.buffer[3]===4||this.buffer[3]===6||this.buffer[3]===8))return{ext:"zip",mime:"application/zip"};if(this.checkString("MThd"))return{ext:"mid",mime:"audio/midi"};if(this.checkString("wOFF")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff",mime:"font/woff"};if(this.checkString("wOF2")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff2",mime:"font/woff2"};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:"pcap",mime:"application/vnd.tcpdump.pcap"};if(this.checkString("DSD "))return{ext:"dsf",mime:"audio/x-dsf"};if(this.checkString("LZIP"))return{ext:"lz",mime:"application/x-lzip"};if(this.checkString("fLaC"))return{ext:"flac",mime:"audio/flac"};if(this.check([66,80,71,251]))return{ext:"bpg",mime:"image/bpg"};if(this.checkString("wvpk"))return{ext:"wv",mime:"audio/wavpack"};if(this.checkString("%PDF"))return{ext:"pdf",mime:"application/pdf"};if(this.check([0,97,115,109]))return{ext:"wasm",mime:"application/wasm"};if(this.check([73,73])){const a=await this.readTiffHeader(!1);if(a)return a}if(this.check([77,77])){const a=await this.readTiffHeader(!0);if(a)return a}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163])){async function a(){const d=await n.peekNumber(oj);let u=128,m=0;for(;!(d&u)&&u!==0;)++m,u>>=1;const p=new Uint8Array(m+1);return await ws(n,p,void 0,{maximumLength:p.length,reason:"EBML field"}),p}async function s(){const d=await a(),u=await a();u[0]^=128>>u.length-1;const m=Math.min(6,u.length),p=new DataView(d.buffer),f=new DataView(u.buffer,u.length-m,m);return{id:Mc(p),len:Mc(f)}}async function i(d){let u=0;for(;d>0;){if(u++,u>Vj||Yn(n,c,Lt))return;const m=n.position,p=await s();if(p.id===17026){if(p.len>Hc)return;const f=hl(p.len,Hc,"EBML DocType");return(await n.readToken(new vr(f))).replaceAll(/\00.*$/g,"")}if(mt(n)&&(!Number.isFinite(p.len)||p.len<0||p.len>Wc)||(await Rr(n,p.len,{maximumLength:mt(n)?Wc:n.fileInfo.size,reason:"EBML payload"}),--d,n.position<=m))return}}const l=await s(),c=n.position;switch(await i(l.len)){case"webm":return{ext:"webm",mime:"video/webm"};case"matroska":return{ext:"mkv",mime:"video/matroska"};default:return}}if(this.checkString("SQLi"))return{ext:"sqlite",mime:"application/x-sqlite3"};if(this.check([78,69,83,26]))return{ext:"nes",mime:"application/x-nintendo-nes-rom"};if(this.checkString("Cr24"))return{ext:"crx",mime:"application/x-google-chrome-extension"};if(this.checkString("MSCF")||this.checkString("ISc("))return{ext:"cab",mime:"application/vnd.ms-cab-compressed"};if(this.check([237,171,238,219]))return{ext:"rpm",mime:"application/x-rpm"};if(this.check([197,208,211,198]))return{ext:"eps",mime:"application/eps"};if(this.check([40,181,47,253]))return{ext:"zst",mime:"application/zstd"};if(this.check([127,69,76,70]))return{ext:"elf",mime:"application/x-elf"};if(this.check([33,66,68,78]))return{ext:"pst",mime:"application/vnd.ms-outlook"};if(this.checkString("PAR1")||this.checkString("PARE"))return{ext:"parquet",mime:"application/vnd.apache.parquet"};if(this.checkString("ttcf"))return{ext:"ttc",mime:"font/collection"};if(this.check([254,237,250,206])||this.check([254,237,250,207])||this.check([206,250,237,254])||this.check([207,250,237,254]))return{ext:"macho",mime:"application/x-mach-binary"};if(this.check([4,34,77,24]))return{ext:"lz4",mime:"application/x-lz4"};if(this.checkString("regf"))return{ext:"dat",mime:"application/x-ft-windows-registry-hive"};if(this.checkString("$FL2")||this.checkString("$FL3"))return{ext:"sav",mime:"application/x-spss-sav"};if(this.check([79,84,84,79,0]))return{ext:"otf",mime:"font/otf"};if(this.checkString("#!AMR"))return{ext:"amr",mime:"audio/amr"};if(this.checkString("{\\rtf"))return{ext:"rtf",mime:"application/rtf"};if(this.check([70,76,86,1]))return{ext:"flv",mime:"video/x-flv"};if(this.checkString("IMPM"))return{ext:"it",mime:"audio/x-it"};if(this.checkString("-lh0-",{offset:2})||this.checkString("-lh1-",{offset:2})||this.checkString("-lh2-",{offset:2})||this.checkString("-lh3-",{offset:2})||this.checkString("-lh4-",{offset:2})||this.checkString("-lh5-",{offset:2})||this.checkString("-lh6-",{offset:2})||this.checkString("-lh7-",{offset:2})||this.checkString("-lzs-",{offset:2})||this.checkString("-lz4-",{offset:2})||this.checkString("-lz5-",{offset:2})||this.checkString("-lhd-",{offset:2}))return{ext:"lzh",mime:"application/x-lzh-compressed"};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:"mpg",mime:"video/MP1S"};if(this.check([68],{offset:4,mask:[196]}))return{ext:"mpg",mime:"video/MP2P"}}if(this.checkString("ITSF"))return{ext:"chm",mime:"application/vnd.ms-htmlhelp"};if(this.check([202,254,186,190])){const a=Oc.get(this.buffer,4),s=fn.get(this.buffer,6);if(a>0&&a<=30)return{ext:"macho",mime:"application/x-mach-binary"};if(s>30)return{ext:"class",mime:"application/java-vm"}}if(this.checkString(".RMF"))return{ext:"rm",mime:"application/vnd.rn-realmedia"};if(this.checkString("DRACO"))return{ext:"drc",mime:"application/vnd.google.draco"};if(this.check([253,55,122,88,90,0]))return{ext:"xz",mime:"application/x-xz"};if(this.checkString("<?xml "))return{ext:"xml",mime:"application/xml"};if(this.check([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(this.check([82,97,114,33,26,7])&&(this.buffer[6]===0||this.buffer[6]===1))return{ext:"rar",mime:"application/x-rar-compressed"};if(this.checkString("solid "))return{ext:"stl",mime:"model/stl"};if(this.checkString("AC")){const a=new vr(4,"latin1").get(this.buffer,2);if(a.match("^d*")&&a>=1e3&&a<=1050)return{ext:"dwg",mime:"image/vnd.dwg"}}if(this.checkString("070707"))return{ext:"cpio",mime:"application/x-cpio"};if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!<arch>"))return await n.ignore(8),await n.readToken(new vr(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("WEBVTT")&&[`
|
|
80
80
|
`,"\r"," "," ","\0"].some(a=>this.checkString(a,{offset:6})))return{ext:"vtt",mime:"text/vtt"};if(this.check([137,80,78,71,13,10,26,10])){const a={ext:"png",mime:"image/png"},s={ext:"apng",mime:"image/apng"};await n.ignore(8);async function i(){return{length:await n.readToken(sj),type:await n.readToken(new vr(4,"latin1"))}}const l=mt(n),c=n.position;let d=0,u=!1;do{if(d++,d>Bj||Yn(n,c,Uj))break;const m=n.position,p=await i();if(p.length<0)return;if(p.type==="IHDR"){if(p.length!==13)return;u=!0}switch(p.type){case"IDAT":return a;case"acTL":return s;default:if(!u&&p.type!=="CgBI")return;if(l&&p.length>Gc)return u&&ek(p.type)?a:void 0;try{await Rr(n,p.length+4,{maximumLength:l?Gc+4:n.fileInfo.size,reason:"PNG chunk payload"})}catch(f){if(!l&&(f instanceof Yr||f instanceof Je))return a;throw f}}if(n.position<=m)break}while(n.position+8<n.fileInfo.size);return a}if(this.check([65,82,82,79,87,49,0,0]))return{ext:"arrow",mime:"application/vnd.apache.arrow.file"};if(this.check([103,108,84,70,2,0,0,0]))return{ext:"glb",mime:"model/gltf-binary"};if(this.check([102,114,101,101],{offset:4})||this.check([109,100,97,116],{offset:4})||this.check([109,111,111,118],{offset:4})||this.check([119,105,100,101],{offset:4}))return{ext:"mov",mime:"video/quicktime"};if(this.check([73,73,82,79,8,0,0,0,24]))return{ext:"orf",mime:"image/x-olympus-orf"};if(this.checkString("gimp xcf "))return{ext:"xcf",mime:"image/x-xcf"};if(this.checkString("ftyp",{offset:4})&&this.buffer[8]&96){const a=new vr(4,"latin1").get(this.buffer,8).replace("\0"," ").trim();switch(a){case"avif":case"avis":return{ext:"avif",mime:"image/avif"};case"mif1":return{ext:"heic",mime:"image/heif"};case"msf1":return{ext:"heic",mime:"image/heif-sequence"};case"heic":case"heix":return{ext:"heic",mime:"image/heic"};case"hevc":case"hevx":return{ext:"heic",mime:"image/heic-sequence"};case"qt":return{ext:"mov",mime:"video/quicktime"};case"M4V":case"M4VH":case"M4VP":return{ext:"m4v",mime:"video/x-m4v"};case"M4P":return{ext:"m4p",mime:"video/mp4"};case"M4B":return{ext:"m4b",mime:"audio/mp4"};case"M4A":return{ext:"m4a",mime:"audio/x-m4a"};case"F4V":return{ext:"f4v",mime:"video/mp4"};case"F4P":return{ext:"f4p",mime:"video/mp4"};case"F4A":return{ext:"f4a",mime:"audio/mp4"};case"F4B":return{ext:"f4b",mime:"audio/mp4"};case"crx":return{ext:"cr3",mime:"image/x-canon-cr3"};default:return a.startsWith("3g")?a.startsWith("3g2")?{ext:"3g2",mime:"video/3gpp2"}:{ext:"3gp",mime:"video/3gpp"}:{ext:"mp4",mime:"video/mp4"}}}if(this.checkString(`REGEDIT4\r
|
|
81
81
|
`))return{ext:"reg",mime:"application/x-ms-regedit"};if(this.check([82,73,70,70])){if(this.checkString("WEBP",{offset:8}))return{ext:"webp",mime:"image/webp"};if(this.check([65,86,73],{offset:8}))return{ext:"avi",mime:"video/vnd.avi"};if(this.check([87,65,86,69],{offset:8}))return{ext:"wav",mime:"audio/wav"};if(this.check([81,76,67,77],{offset:8}))return{ext:"qcp",mime:"audio/qcelp"}}if(this.check([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:"rw2",mime:"image/x-panasonic-rw2"};if(this.check([48,38,178,117,142,102,207,17,166,217])){let a=!1;try{async function s(){const d=new Uint8Array(16);return await ws(n,d,void 0,{maximumLength:d.length,reason:"ASF header GUID"}),{id:d,size:Number(await n.readToken(ij))}}await Rr(n,30,{maximumLength:30,reason:"ASF header prelude"});const i=mt(n),l=n.position;let c=0;for(;n.position+24<n.fileInfo.size&&(c++,!(c>Hj||Yn(n,l,Lt)));){const d=n.position,u=await s();let m=u.size-24;if(!Number.isFinite(m)||m<0){a=!0;break}if(ar(u.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){const p=new Uint8Array(16);if(m-=await ws(n,p,void 0,{maximumLength:p.length,reason:"ASF stream type GUID"}),ar(p,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"audio/x-ms-asf"};if(ar(p,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"video/x-ms-asf"};break}if(i&&m>Xc){a=!0;break}if(await Rr(n,m,{maximumLength:i?Xc:n.fileInfo.size,reason:"ASF header payload"}),n.position<=d){a=!0;break}}}catch(s){if(s instanceof Je||s instanceof Yr)mt(n)&&(a=!0);else throw s}return a?void 0:{ext:"asf",mime:"application/vnd.ms-asf"}}if(this.check([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:"ktx",mime:"image/ktx"};if((this.check([126,16,4])||this.check([126,24,4]))&&this.check([48,77,73,69],{offset:4}))return{ext:"mie",mime:"application/x-mie"};if(this.check([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:"shp",mime:"application/x-esri-shape"};if(this.check([255,79,255,81]))return{ext:"j2c",mime:"image/j2c"};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10]))switch(await n.ignore(20),await n.readToken(new vr(4,"ascii"))){case"jp2 ":return{ext:"jp2",mime:"image/jp2"};case"jpx ":return{ext:"jpx",mime:"image/jpx"};case"jpm ":return{ext:"jpm",mime:"image/jpm"};case"mjp2":return{ext:"mj2",mime:"image/mj2"};default:return}if(this.check([255,10])||this.check([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:"jxl",mime:"image/jxl"};if(this.check([254,255]))return this.checkString("<?xml ",{offset:2,encoding:"utf-16be"})?{ext:"xml",mime:"application/xml"}:void 0;if(this.check([208,207,17,224,161,177,26,225]))return{ext:"cfb",mime:"application/x-cfb"};if(await n.peekBuffer(this.buffer,{length:Math.min(256,n.fileInfo.size),mayBeLess:!0}),this.check([97,99,115,112],{offset:36}))return{ext:"icc",mime:"application/vnd.iccprofile"};if(this.checkString("**ACE",{offset:7})&&this.checkString("**",{offset:12}))return{ext:"ace",mime:"application/x-ace-compressed"};if(this.checkString("BEGIN:")){if(this.checkString("VCARD",{offset:6}))return{ext:"vcf",mime:"text/vcard"};if(this.checkString("VCALENDAR",{offset:6}))return{ext:"ics",mime:"text/calendar"}}if(this.checkString("FUJIFILMCCD-RAW"))return{ext:"raf",mime:"image/x-fujifilm-raf"};if(this.checkString("Extended Module:"))return{ext:"xm",mime:"audio/x-xm"};if(this.checkString("Creative Voice File"))return{ext:"voc",mime:"audio/x-voc"};if(this.check([4,0,0,0])&&this.buffer.length>=16){const a=new DataView(this.buffer.buffer).getUint32(12,!0);if(a>12&&this.buffer.length>=a+16)try{const s=new TextDecoder().decode(this.buffer.subarray(16,a+16));if(JSON.parse(s).files)return{ext:"asar",mime:"application/x-asar"}}catch{}}if(this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2]))return{ext:"mxf",mime:"application/mxf"};if(this.checkString("SCRM",{offset:44}))return{ext:"s3m",mime:"audio/x-s3m"};if(this.check([71])&&this.check([71],{offset:188}))return{ext:"mts",mime:"video/mp2t"};if(this.check([71],{offset:4})&&this.check([71],{offset:196}))return{ext:"mts",mime:"video/mp2t"};if(this.check([66,79,79,75,77,79,66,73],{offset:60}))return{ext:"mobi",mime:"application/x-mobipocket-ebook"};if(this.check([68,73,67,77],{offset:128}))return{ext:"dcm",mime:"application/dicom"};if(this.check([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70]))return{ext:"lnk",mime:"application/x.ms.shortcut"};if(this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0]))return{ext:"alias",mime:"application/x.apple.alias"};if(this.checkString("Kaydara FBX Binary \0"))return{ext:"fbx",mime:"application/x.autodesk.fbx"};if(this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8})))return{ext:"eot",mime:"application/vnd.ms-fontobject"};if(this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29]))return{ext:"indd",mime:"application/x-indesign"};if(this.check([255,255,0,0,7,0,0,0,4,0,0,0,1,0,1,0])||this.check([0,0,255,255,0,0,0,7,0,0,0,4,0,1,0,1]))return{ext:"jmp",mime:"application/x-jmp-data"};if(await n.peekBuffer(this.buffer,{length:Math.min(512,n.fileInfo.size),mayBeLess:!0}),this.checkString("ustar",{offset:257})&&(this.checkString("\0",{offset:262})||this.checkString(" ",{offset:262}))||this.check([0,0,0,0,0,0],{offset:257})&&Ij(this.buffer))return{ext:"tar",mime:"application/x-tar"};if(this.check([255,254])){const a="utf-16le";return this.checkString("<?xml ",{offset:2,encoding:a})?{ext:"xml",mime:"application/xml"}:this.check([255,14],{offset:2})&&this.checkString("SketchUp Model",{offset:4,encoding:a})?{ext:"skp",mime:"application/vnd.sketchup.skp"}:this.checkString(`Windows Registry Editor Version 5.00\r
|
|
82
|
-
`,{offset:2,encoding:a})?{ext:"reg",mime:"application/x-ms-regedit"}:void 0}if(this.checkString("-----BEGIN PGP MESSAGE-----"))return{ext:"pgp",mime:"application/pgp-encrypted"}}),Ic(this,"detectImprecise",async n=>{this.buffer=new Uint8Array(Kn);const a=dk(n.fileInfo.size);if(await n.peekBuffer(this.buffer,{length:Math.min(8,a),mayBeLess:!0}),this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(this.check([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(this.check([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(this.check([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(await n.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,a),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let s=0;s<=this.options.mpegOffsetTolerance;++s){const i=this.scanMpeg(s);if(i)return i}});const r=ck(t==null?void 0:t.mpegOffsetTolerance);this.options={...t,mpegOffsetTolerance:r},this.detectors=[...this.options.customDetectors??[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:this.options.signal},this.gzipProbeDepth=0}getTokenizerOptions(){return{...this.tokenizerOptions}}createTokenizerFromWebStream(t){return Kj(gj(t,this.getTokenizerOptions()))}async parseTokenizer(t,r=0){this.detectionReentryCount=r;const n=t.position;for(const a of this.detectors){let s;try{s=await a.detect(t)}catch(i){if(i instanceof Je||i instanceof Yr)return;throw i}if(s)return s;if(n!==t.position)return}}async fromTokenizer(t){try{return await this.parseTokenizer(t)}finally{await t.close()}}async fromBuffer(t){if(!(t instanceof Uint8Array||t instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof t}\``);const r=t instanceof Uint8Array?t:new Uint8Array(t);if((r==null?void 0:r.length)>1)return this.fromTokenizer(vj(r,this.getTokenizerOptions()))}async fromBlob(t){var r;(r=this.options.signal)==null||r.throwIfAborted();const n=bj(t,this.getTokenizerOptions());return this.fromTokenizer(n)}async fromStream(t){var r;(r=this.options.signal)==null||r.throwIfAborted();const n=this.createTokenizerFromWebStream(t);return this.fromTokenizer(n)}async toDetectionStream(t,r){const n=ik((r==null?void 0:r.sampleSize)??Kn);let a,s;const i=t.getReader({mode:"byob"});try{const{value:d,done:u}=await lk(i,new Uint8Array(n),this.options.signal);if(s=d,!u&&d)try{a=await this.fromBuffer(d.subarray(0,n))}catch(m){if(!(m instanceof Je))throw m;a=void 0}s=d}finally{i.releaseLock()}const l=new TransformStream({async start(d){d.enqueue(s)},transform(d,u){u.enqueue(d)}}),c=t.pipeThrough(l);return c.fileType=a,c}async detectGzip(t){var r;if(this.gzipProbeDepth>=Mj)return{ext:"gz",mime:"application/gzip"};const n=new Aj(t),a=ok(n.inflate(),Lj),s=mt(t);let i,l,c,d;if(s){const u=new AbortController;i=setTimeout(()=>{u.abort(new DOMException(`Operation timed out after ${Uc} ms`,"TimeoutError"))},Uc),l=this.options.signal===void 0?u.signal:AbortSignal.any([this.options.signal,u.signal]),c=new ch({...this.options,signal:l}),c.gzipProbeDepth=this.gzipProbeDepth+1}else this.gzipProbeDepth++;try{d=await(c??this).fromStream(a)}catch(u){if((u==null?void 0:u.name)==="AbortError"&&((r=l==null?void 0:l.reason)==null?void 0:r.name)!=="TimeoutError")throw u}finally{clearTimeout(i),s||this.gzipProbeDepth--}return(d==null?void 0:d.ext)==="tar"?{ext:"tar.gz",mime:"application/gzip"}:{ext:"gz",mime:"application/gzip"}}check(t,r){return ar(this.buffer,t,r)}checkString(t,r){return this.check(Rj(t,r==null?void 0:r.encoding),r)}async readTiffTag(t){const r=await this.tokenizer.readToken(t?fn:Ue);switch(await this.tokenizer.ignore(10),r){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"}}}async readTiffIFD(t){const r=await this.tokenizer.readToken(t?fn:Ue);if(!(r>Wj)&&!(mt(this.tokenizer)&&2+r*12>Zc))for(let n=0;n<r;++n){const a=await this.readTiffTag(t);if(a)return a}}async readTiffHeader(t){const r={ext:"tif",mime:"image/tiff"},n=(t?fn:Ue).get(this.buffer,2),a=(t?Oc:Ge).get(this.buffer,4);if(n===42){if(a>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(a>=8){const l=(t?fn:Ue).get(this.buffer,8),c=(t?fn:Ue).get(this.buffer,10);if(l===28&&c===254||l===31&&c===11)return{ext:"nef",mime:"image/x-nikon-nef"}}}if(mt(this.tokenizer)&&a>qj)return r;const s=mt(this.tokenizer)?Zc:this.tokenizer.fileInfo.size;try{await Rr(this.tokenizer,a,{maximumLength:s,reason:"TIFF IFD offset"})}catch(l){if(l instanceof Je)return;throw l}let i;try{i=await this.readTiffIFD(t)}catch(l){if(l instanceof Je)return;throw l}return i??r}if(n===43)return r}scanMpeg(t){if(this.check([255,224],{offset:t,mask:[255,224]})){if(this.check([16],{offset:t+1,mask:[22]}))return this.check([8],{offset:t+1,mask:[8]})?{ext:"aac",mime:"audio/aac"}:{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:t+1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:t+1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:t+1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}};new Set(_j);new Set(Oj);const Qc=e=>e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`,xl=({name:e,control:t,disabled:r,campo:n,fileTypes:a,maxFileSize:s})=>{var i;const{field:l,fieldState:c}=$e.useController({name:e,control:t}),{uploadFile:d,deleteUploadedFile:u}=Nr(),[m,p]=N.useState({status:"idle"}),f=N.useRef(null),[b,h]=N.useState(!1),x=N.useRef(!0);N.useEffect(()=>()=>{x.current=!1},[]);const y=typeof l.value=="string"&&l.value?l.value:null,v=N.useCallback(async S=>{var $;if(a&&a.length>0){const k=await sk(S),E=(k==null?void 0:k.ext)??"",D=(k==null?void 0:k.mime)??"",O=(($=S.name.split(".").pop())==null?void 0:$.toLowerCase())??"",L=S.type.toLowerCase();if(!a.some(A=>{const z=A.toLowerCase();return!!(E&&(z===E||z===D)||D&&z.endsWith("/*")&&D.startsWith(z.slice(0,-1))||!E&&(z===O||z===L||z.endsWith("/*")&&L.startsWith(z.slice(0,-1))))})){p({status:"error",message:`Tipo de arquivo não permitido. Permitidos: ${a.join(", ")}`});return}}if(s&&S.size>s){p({status:"error",message:`Arquivo muito grande. Tamanho máximo: ${Qc(s)}`});return}if(!d){p({status:"error",message:"Preview: upload não disponível sem configuração."});return}p({status:"uploading",fileName:S.name,progress:0});try{if(y&&u)try{await u(y)}catch{}const k=await d(S,n??e,E=>{x.current&&p(D=>D.status==="uploading"?{...D,progress:Math.min(100,E)}:D)});if(!x.current)return;l.onChange(k),p({status:"done",uploadId:k,fileName:S.name,size:S.size})}catch{if(!x.current)return;p({status:"error",message:"Falha no upload. Tente novamente."})}},[d,u,y,n,e,l,a,s]),j=N.useCallback(S=>{var $;const k=($=S.target.files)==null?void 0:$[0];k&&v(k),S.target.value=""},[v]),w=N.useCallback(()=>{l.onChange(""),p({status:"idle"}),f.current&&(f.current.value="")},[l]);if(m.status==="done"||m.status==="idle"&&y){const S=m.status==="done"?m.fileName:"Arquivo enviado",$=m.status==="done"?m.size:null;return o.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-input bg-muted/20 px-4 py-3 gap-2",children:[o.jsx("span",{className:"text-sm font-medium truncate flex-1",children:S}),$!==null&&o.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:Qc($)}),!r&&o.jsx("button",{type:"button",onClick:w,className:"ml-2 shrink-0 text-muted-foreground hover:text-destructive transition-colors","aria-label":"Remover arquivo",children:"✕"})]})}if(m.status==="uploading"){const{fileName:S,progress:$}=m;return o.jsxs("div",{className:"rounded-lg border border-input px-4 py-3 space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-sm font-medium truncate flex-1",children:S}),o.jsxs("span",{className:"text-xs text-muted-foreground ml-2",children:[$,"%"]})]}),o.jsx("div",{className:"h-2 rounded-full bg-muted overflow-hidden",children:o.jsx("div",{className:"h-full bg-primary transition-all duration-200 rounded-full",style:{width:`${$}%`}})})]})}const C=m.status==="error";return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{role:"button",tabIndex:r?-1:0,"aria-label":"Selecionar arquivo",className:K("flex items-center justify-center rounded-lg border-2 border-dashed px-4 py-6 transition-colors cursor-pointer",b?"border-primary bg-primary/5":C||c.error?"border-destructive bg-destructive/5":"border-input hover:border-muted-foreground hover:bg-muted/20",r&&"opacity-50 cursor-not-allowed"),onClick:()=>{var S;return!r&&((S=f.current)==null?void 0:S.click())},onKeyDown:S=>{var $;(S.key==="Enter"||S.key===" ")&&(($=f.current)==null||$.click())},onDragOver:S=>{S.preventDefault(),r||h(!0)},onDragLeave:()=>h(!1),onDrop:r?void 0:S=>{var $;S.preventDefault(),h(!1);const k=($=S.dataTransfer.files)==null?void 0:$[0];k&&v(k)},onBlur:l.onBlur,children:[o.jsx("input",{ref:f,type:"file",onChange:j,disabled:r,className:"sr-only"}),o.jsx("span",{className:"text-sm text-muted-foreground",children:b?"Solte o arquivo aqui":"Clique ou arraste um arquivo"})]}),C&&o.jsxs("p",{className:"text-sm text-destructive",children:[m.message," · ",o.jsx("button",{type:"button",className:"underline hover:no-underline",onClick:()=>p({status:"idle"}),children:"Tentar novamente"})]}),!C&&((i=c.error)==null?void 0:i.message)&&o.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})},gk={cpf:e=>e.replace(/\D/g,"").slice(0,11).replace(/(\d{3})(\d)/,"$1.$2").replace(/(\d{3})(\d)/,"$1.$2").replace(/(\d{3})(\d{1,2})$/,"$1-$2"),telefone:e=>{const t=e.replace(/\D/g,"").slice(0,11);return t.length<=10?t.replace(/(\d{2})(\d)/,"($1) $2").replace(/(\d{4})(\d)/,"$1-$2"):t.replace(/(\d{2})(\d)/,"($1) $2").replace(/(\d{5})(\d)/,"$1-$2")},cep:e=>e.replace(/\D/g,"").slice(0,8).replace(/(\d{5})(\d)/,"$1-$2")},_r=({name:e,control:t,placeholder:r,maskType:n,disabled:a,readOnly:s})=>{var i;const{field:l,fieldState:c}=$e.useController({name:e,control:t}),d=gk[n||""],u=N.useCallback(m=>{l.onChange(d?d(m.target.value):m.target.value)},[l,d]);return o.jsxs("div",{className:"space-y-1",children:[o.jsx(ue,{name:l.name,value:l.value||"",onChange:u,onBlur:l.onBlur,placeholder:r,disabled:a,readOnly:s,className:K(c.error&&"border-destructive focus-visible:ring-destructive")}),((i=c.error)==null?void 0:i.message)&&o.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})},Go=({name:e,control:t})=>{const{field:r}=$e.useController({name:e,control:t});return o.jsx("input",{type:"hidden",...r,value:r.value??""})},dh=e=>e.replace(/\D/g,""),vk=e=>{const t=dh(e).slice(0,8);return t.length<=5?t:`${t.slice(0,5)}-${t.slice(5)}`},bk=async(e,t)=>{const r=await fetch(`https://viacep.com.br/ws/${e}/json/`,{signal:t});if(!r.ok)throw new Error("Falha ao consultar CEP");return r.json()},gl=({name:e,control:t,placeholder:r="00000-000",disabled:n,readOnly:a,cepFillMap:s})=>{var i,l;const{field:c,fieldState:d}=$e.useController({name:e,control:t}),{setValue:u}=$e.useFormContext(),{cepLookup:m}=Nr(),[p,f]=N.useState("idle"),[b,h]=N.useState(null),x=N.useRef(null),y=N.useRef(!0);N.useEffect(()=>()=>{var w;y.current=!1,(w=x.current)==null||w.abort()},[]);const v=N.useCallback(async()=>{var w;c.onBlur();const C=dh(c.value??"");if(C.length===8){(w=x.current)==null||w.abort(),x.current=new AbortController,f("loading"),h(null);try{let S;if(m){const E=x.current;if(S=await m(C,E.signal),E.signal.aborted||!y.current)return}else{const E=await bk(C,x.current.signal);if(!y.current)return;if(E.erro){f("error"),h("CEP não encontrado");return}S={logradouro:E.logradouro,bairro:E.bairro,cidade:E.localidade,estado:E.uf}}if(!y.current)return;if(S.erro){f("error"),h("CEP não encontrado");return}const $=e.includes(".")?`${e.substring(0,e.lastIndexOf("."))}.`:"",k=(E,D,O)=>{if(!O)return;const L=s!=null&&s[E]?`${$}${s[E]}`:`${$}${D}`;u(L,O,{shouldDirty:!0,shouldValidate:!0})};k("logradouro","_address_logradouro",S.logradouro),k("bairro","_address_bairro",S.bairro),k("cidade","_address_cidade",S.cidade),k("estado","_address_estado",S.estado),f("success")}catch(S){if(S instanceof Error&&S.name==="AbortError"||!y.current)return;f("error"),h("Erro ao buscar CEP")}}},[c,m,u,e,s]),j=N.useCallback(w=>{c.onChange(vk(w.target.value))},[c]);return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"relative",children:[o.jsx(ue,{name:c.name,value:c.value||"",onChange:j,onBlur:v,placeholder:r,disabled:n,readOnly:a,className:K("pr-9",d.error&&"border-destructive focus-visible:ring-destructive")}),o.jsxs("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none",children:[p==="loading"&&o.jsx(_.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"}),p==="success"&&o.jsx(_.Check,{className:"h-4 w-4 text-green-500"}),p==="error"&&o.jsx(_.AlertCircle,{className:"h-4 w-4 text-destructive"})]})]}),(((i=d.error)==null?void 0:i.message)||b)&&o.jsx("p",{className:"text-sm text-destructive",children:((l=d.error)==null?void 0:l.message)||b})]})},yk=({field:e,control:t,nameOverride:r})=>{const n={name:r,control:t,placeholder:e.placeholder};switch(e.tipo){case T.TEXTO:return o.jsx(Tt,{...n,type:"text"});case T.EMAIL:return o.jsx(Tt,{...n,type:"email"});case T.NUMBER:return o.jsx(Tt,{...n,type:"number"});case T.TEXTAREA:return o.jsx(Uo,{...n});case T.SELECT:return o.jsx(Ho,{...n,options:e.opcoes??[]});case T.RADIO:return o.jsx(ml,{...n,options:e.opcoes??[]});case T.CHECKBOX:return o.jsx(Wo,{name:r,control:t,label:e.label});case T.CHECKBOX_GROUP:return o.jsx(ul,{...n,options:e.opcoes??[]});case T.DATE:return o.jsx(Rn,{...n,validacao:e.validacao});case T.DATETIME:return o.jsx(Rn,{...n,isDatetime:!0,validacao:e.validacao});case T.FILE:return o.jsx(xl,{name:r,control:t});case T.TELEFONE:return o.jsx(_r,{...n,maskType:"telefone"});case T.CPF:return o.jsx(_r,{...n,maskType:"cpf"});case T.CEP:return o.jsx(gl,{name:r,control:t,placeholder:e.placeholder});case T.HIDDEN:return o.jsx(Go,{name:r,control:t});default:return console.error(`[DFFieldArray] Tipo de sub-campo "${e.tipo}" não suportado em FIELD_ARRAY. Usando DFTextField como fallback.`),o.jsx(Tt,{...n,type:"text"})}},uh=({name:e,control:t,subFields:r=[],minItems:n=1,maxItems:a,itemLabel:s="Item",addLabel:i})=>{var l;const{fields:c,append:d,remove:u}=$e.useFieldArray({control:t,name:e}),{errors:m}=$e.useFormState({control:t}),p=(l=m[e])==null?void 0:l.message,f=N.useCallback(()=>{const y={};for(const v of r)v.initialValue!==void 0?y[v.nome]=v.initialValue:v.defaultValue!==void 0&&(y[v.nome]=v.defaultValue);return y},[r]);N.useEffect(()=>{if(c.length<n)for(let y=c.length;y<n;y++)d(f())},[n]);const b=[...r].sort((y,v)=>y.ordem-v.ordem),h=!a||c.length<a,x=i??`Adicionar ${s.toLowerCase()}`;return o.jsxs("div",{className:"space-y-3",children:[c.map((y,v)=>o.jsxs("div",{className:"rounded-lg border border-input p-4",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-primary/10 text-xs font-bold text-primary shrink-0",children:v+1}),o.jsxs("span",{className:"text-sm font-semibold",children:[s," ",v+1]})]}),c.length>n&&o.jsx(De,{type:"button",variant:"ghost",size:"icon",onClick:()=>u(v),"aria-label":`Remover ${s.toLowerCase()} ${v+1}`,className:"text-muted-foreground hover:text-destructive",children:o.jsx(_.Trash2,{className:"w-4 h-4"})})]}),o.jsx("div",{className:"grid grid-cols-12 gap-4",children:b.map(j=>{const w=`${e}.${v}.${j.nome}`,C=`span ${j.tamanho??12}`,S=o.jsx(yk,{field:j,control:t,nameOverride:w});return j.tipo===T.CHECKBOX||j.tipo===T.HIDDEN?o.jsx("div",{className:"max-sm:!col-span-12",style:{gridColumn:C},children:S},j.id):o.jsxs("div",{className:"max-sm:!col-span-12 space-y-2",style:{gridColumn:C},children:[o.jsxs("label",{className:"font-medium flex items-center gap-1 text-sm text-foreground",children:[j.label,j.obrigatorio&&o.jsx("span",{className:"text-destructive",children:"*"})]}),S,j.hint&&o.jsx("p",{className:"text-xs text-muted-foreground",children:j.hint})]},j.id)})})]},y.id)),h&&o.jsxs(De,{type:"button",variant:"outline",className:"w-full",onClick:()=>d(f()),children:[o.jsx(_.Plus,{className:"w-4 h-4"}),x]}),a&&o.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:["Máximo de ",a," ",s.toLowerCase(),a>1?"s":""]}),p&&o.jsxs("p",{className:"text-sm text-destructive flex items-center gap-1",children:[o.jsx(_.AlertCircle,{className:"w-4 h-4 shrink-0"}),p]})]})},ed=e=>`R$ ${(e/100).toFixed(2).replace(".",",")}`,wk=(e,t)=>{const r=new Date(e.slice(0,10)+"T00:00:00Z"),n=new Date(t.slice(0,10)+"T00:00:00Z");return Math.round((n.getTime()-r.getTime())/864e5)+1},jk=(e,t)=>{const r=[],n=new Date(e.slice(0,10)+"T00:00:00Z"),a=new Date(t.slice(0,10)+"T00:00:00Z");let s=0;for(;n<=a&&s<60;)r.push(n.toISOString().slice(0,10)),n.setUTCDate(n.getUTCDate()+1),s++;return r},kk=e=>{const[t,r,n]=e.split("-").map(Number),a=new Date(Date.UTC(t,r-1,n)),s=String(n).padStart(2,"0"),i=String(r).padStart(2,"0"),l=new Intl.DateTimeFormat("pt-BR",{weekday:"long",timeZone:"UTC"}).format(a),c=l.charAt(0).toUpperCase()+l.slice(1);return`${s}/${i} - ${c}`},Ck=(e,t)=>{const r=n=>{const[a,s,i]=n.slice(0,10).split("-");return`${i}/${s}/${a}`};return`${r(e)} a ${r(t)}`},mh=({name:e,control:t})=>{var r;const{field:n,fieldState:a}=$e.useController({name:e,control:t}),{externalData:s={}}=Nr(),i=n.value??null,l=(r=a.error)==null?void 0:r.message,c=V=>s[`evento.${V}`]??s[V],d=c("dataInicioEvento")??"",u=c("dataFimEvento")??"",m=Number(c("valor")??0),p=Number(c("valorPorDia")??0),f=c("vagasTotal"),b=c("vagasPorDia"),h=c("vagasMasculinas"),x=c("vagasFemininas"),y=f!=null?Number(f):null,v=b!=null?Number(b):null,j=h!=null?Number(h):null,w=x!=null?Number(x):null,C=d&&u?jk(d,u):[],S=(d&&u?wk(d,u):0)>1,$=j!=null&&j>0&&w!=null&&w>0,k=j!=null&&w==null?"masculino":w!=null&&j==null?"feminino":null,E=(i==null?void 0:i.tipo)??null,D=(i==null?void 0:i.data)??null,O=(i==null?void 0:i.genero)??null,L=N.useRef(i);L.current=i;const A=N.useRef(n.onChange);A.current=n.onChange,N.useEffect(()=>{var V,M,P;k&&((V=L.current)==null?void 0:V.genero)!==k&&A.current({tipo:((M=L.current)==null?void 0:M.tipo)??null,data:((P=L.current)==null?void 0:P.data)??null,genero:k})},[k]);const z=V=>{const M={tipo:V,data:null};($||k)&&(M.genero=O??k??void 0),n.onChange(M)},X=V=>{const M={tipo:"por_dia",data:V};($||k)&&(M.genero=O??k??void 0),n.onChange(M)},q=V=>{n.onChange({tipo:E,data:D,genero:V})},Z=V=>E===V;return o.jsxs("div",{className:"space-y-3",children:[$&&o.jsxs("div",{className:"flex items-center gap-2 px-1",children:[o.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:"Você é:"}),o.jsx("div",{className:"flex gap-2",children:["masculino","feminino"].map(V=>o.jsx("button",{type:"button",onClick:()=>q(V),className:K("px-3 py-1 rounded-full text-xs font-medium border transition-all",O===V?"border-primary bg-primary/10 text-primary":"border-input text-muted-foreground hover:border-primary/50"),children:V==="masculino"?"Masculino":"Feminino"},V))})]}),o.jsxs("button",{type:"button",onClick:()=>z("todos_os_dias"),className:K("w-full text-left flex items-start gap-3 p-4 rounded-xl border-2 transition-all",Z("todos_os_dias")?"border-primary bg-primary/5":"border-input hover:border-primary/50"),children:[o.jsx("div",{className:K("mt-0.5 p-2 rounded-lg shrink-0 transition-colors",Z("todos_os_dias")?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:o.jsx(_.CalendarCheck2,{className:"w-4 h-4"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"font-semibold text-sm",children:"Participar todos os dias"}),d&&u?o.jsx("p",{className:"text-xs text-muted-foreground",children:Ck(d,u)}):o.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Datas do evento"})]}),o.jsxs("div",{className:"text-right shrink-0",children:[m>0&&o.jsx("p",{className:K("font-bold text-sm",Z("todos_os_dias")?"text-primary":"text-foreground"),children:ed(m)}),y!=null&&y>0&&o.jsxs("p",{className:"text-xs flex items-center justify-end gap-1 text-muted-foreground",children:[o.jsx(_.Users,{className:"w-3 h-3"}),y," vagas disponíveis"]})]})]}),S?o.jsxs("button",{type:"button",onClick:()=>z("por_dia"),className:K("w-full text-left flex items-start gap-3 p-4 rounded-xl border-2 transition-all",Z("por_dia")?"border-primary bg-primary/5":"border-input hover:border-primary/50"),children:[o.jsx("div",{className:K("mt-0.5 p-2 rounded-lg shrink-0 transition-colors",Z("por_dia")?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:o.jsx(_.CalendarDays,{className:"w-4 h-4"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"font-semibold text-sm",children:"Participar um dia"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Escolha o dia desejado abaixo"})]}),o.jsxs("div",{className:"text-right shrink-0",children:[p>0&&o.jsx("p",{className:K("font-bold text-sm",Z("por_dia")?"text-primary":"text-foreground"),children:ed(p)}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"por dia"})]})]}):d?o.jsxs("div",{className:"flex items-start gap-2 px-3 py-2.5 rounded-lg border border-input bg-muted/30",children:[o.jsx(_.Info,{className:"w-3.5 h-3.5 mt-0.5 shrink-0 text-muted-foreground"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:'Este evento ocorre em apenas 1 dia — a opção "Participar um dia" não é necessária.'})]}):null,E==="por_dia"&&o.jsxs("div",{className:"pl-2 space-y-2",children:[o.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-primary",children:"Selecione o dia:"}),C.length===0?o.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Nenhuma data configurada no evento"}):C.map(V=>o.jsxs("button",{type:"button",onClick:()=>X(V),className:K("w-full text-left flex items-center justify-between px-4 py-3 rounded-lg border transition-all",D===V?"border-primary bg-primary/5":"border-input hover:border-primary/50"),children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("span",{className:K("w-4 h-4 rounded-full border-2 shrink-0 flex items-center justify-center transition-colors",D===V?"border-primary bg-primary":"border-input"),children:D===V&&o.jsx("span",{className:"w-2 h-2 rounded-full bg-white"})}),o.jsx("span",{className:"text-sm",children:kk(V)})]}),v!=null&&o.jsxs("span",{className:"text-xs text-muted-foreground",children:[v," vagas"]})]},V))]}),l&&o.jsx("p",{className:"text-sm text-destructive",children:l})]})},td=.0315,rd=.124,nd=7,ad=12,ph=[{id:"pix",label:"PIX",description:"Transferência instantânea (à vista)",Icon:_.Smartphone,taxa:0},{id:"dinheiro",label:"Dinheiro",description:"Pagamento em espécie",Icon:_.Banknote,taxa:0},{id:"cartao",label:"Cartão de Crédito",description:"Débito ou crédito na maquininha",Icon:_.CreditCard,taxa:td,taxaLabel:`Taxa: ${(td*100).toFixed(2).replace(".",",")}%`}],fh=[{id:"pix",label:"PIX à Vista",description:"Pagamento instantâneo sem parcelamento",Icon:_.Smartphone,taxa:0},{id:"pix_parcelado",label:"PIX Parcelado",description:`Parcelado em até ${nd}x sem juros`,Icon:_.Smartphone,taxa:0,parcelas:nd},{id:"cartao",label:"Cartão de Crédito",description:`Parcelado em até ${ad}x`,Icon:_.CreditCard,taxa:rd,parcelas:ad,taxaLabel:`Taxa: ${(rd*100).toFixed(2).replace(".",",")}%`},{id:"dinheiro",label:"Dinheiro",description:"Pagamento em espécie",Icon:_.Banknote,taxa:0}],Ra=e=>`R$ ${(e/100).toFixed(2).replace(".",",")}`,od=(e,t)=>Math.round(e*(1+t)*100)/100,Nk=(e,t)=>Math.round(e/t*100)/100,hh=({name:e,control:t,relatedFieldName:r="tipo_participacao"})=>{var n;const{field:a,fieldState:s}=$e.useController({name:e,control:t}),{externalData:i={},paymentMethodOptions:l}=Nr(),c=a.value??null,d=(n=s.error)==null?void 0:n.message,u=$e.useWatch({control:t,name:r}),m=(u==null?void 0:u.tipo)??null,p=j=>i[`evento.${j}`]??i[j],f=Number(p("valor")??0),b=Number(p("valorPorDia")??0),h=m==="por_dia"&&b>0?b:f,x=m==="por_dia"?(l==null?void 0:l.porDia)??ph:(l==null?void 0:l.todosOsDias)??fh,y=m==="por_dia"?(()=>{if(!(u!=null&&u.data))return"Um dia";const j=u.data.split("-");if(j.length===3){const[w,C,S]=j;return`${S}/${C}/${w}`}return u.data})():"Todos os dias",v=j=>{if(j.disabled)return;const w=od(h,j.taxa),C={metodo:j.id,valorTotal:w};j.parcelas&&(C.parcelas=j.parcelas),a.onChange(C)};return o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-input px-4 py-3",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:"Tipo de participação"}),o.jsx("p",{className:"font-semibold",children:y})]}),o.jsxs("div",{className:"text-right",children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:"Valor base"}),o.jsx("p",{className:"text-lg font-bold text-primary",children:Ra(h)})]})]}),o.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-input bg-muted/30 px-3 py-2.5",children:[o.jsx(_.Info,{className:"h-4 w-4 mt-0.5 shrink-0 text-muted-foreground"}),o.jsxs("p",{className:"text-xs",children:[o.jsx("span",{className:"font-bold",children:"Importante:"})," Para validar a inscrição e garantir sua vaga, o pagamento deve ser realizado no ato da inscrição."]})]}),o.jsx("p",{className:"text-sm font-semibold text-primary",children:"Selecione a forma de pagamento:"}),o.jsx("div",{className:"space-y-3",children:x.map(j=>{const{Icon:w}=j,C=(c==null?void 0:c.metodo)===j.id,S=od(h,j.taxa),$=!!j.parcelas&&j.parcelas>1,k=$?Nk(S,j.parcelas):null;return o.jsxs("button",{type:"button",disabled:j.disabled,onClick:()=>v(j),className:K("w-full text-left flex items-center gap-4 px-4 py-3 rounded-xl border-2 transition-all",C?"border-primary bg-primary/5":"border-input hover:border-primary/50",j.disabled&&"opacity-50 cursor-not-allowed"),children:[o.jsx("div",{className:K("flex items-center justify-center w-10 h-10 rounded-lg shrink-0 transition-colors",C?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:o.jsx(w,{className:"h-5 w-5"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"font-semibold text-sm leading-tight",children:j.label}),o.jsx("p",{className:"text-xs text-muted-foreground",children:j.description}),j.taxaLabel&&o.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["* ",j.taxaLabel]}),j.taxa>0&&o.jsxs("p",{className:"text-xs text-muted-foreground",children:["Total com taxa: ",Ra(S)]})]}),o.jsx("div",{className:"text-right shrink-0",children:$?o.jsxs(o.Fragment,{children:[o.jsxs("p",{className:"text-xs text-muted-foreground",children:[j.parcelas,"x de"]}),o.jsx("p",{className:"text-base font-bold text-primary",children:Ra(k)})]}):o.jsx("p",{className:"text-base font-bold text-primary",children:Ra(S)})})]},j.id)})}),d&&o.jsx("p",{className:"text-xs text-destructive",children:d})]})},xh=({name:e,control:t,label:r,termoTexto:n,termoPdfUrl:a,termoPdfUploadId:s})=>{var i;const{field:l,fieldState:c}=$e.useController({name:e,control:t}),{resolveTermsUploadUrl:d}=Nr(),u=!!c.error,m=(i=c.error)==null?void 0:i.message,[p,f]=N.useState(null),[b,h]=N.useState(!1),[x,y]=N.useState(!1),v=N.useRef(null);N.useEffect(()=>{var $;x&&(($=v.current)==null||$.focus())},[x]),N.useEffect(()=>{if(!s||!d){f(null);return}let $=!1;return h(!0),d(s).then(k=>{$||f(k)}).catch(()=>{$||f(null)}).finally(()=>{$||h(!1)}),()=>{$=!0}},[s,d]);const j=l.value==="accepted",w=p||a||null,C=!!(n||w||s),S=!!w;return o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:K("rounded-lg border p-4 space-y-4 transition-colors",u?"border-destructive bg-destructive/5":j?"border-green-500 bg-green-500/5":"border-input"),children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(_.ScrollText,{className:"h-4 w-4 shrink-0"}),o.jsx("span",{className:"text-sm font-medium",children:r||"Termos e condições"})]}),C?o.jsxs(De,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2 text-xs",disabled:b,onClick:()=>y(!0),children:[b?o.jsx(_.Loader2,{className:"h-3 w-3 animate-spin"}):o.jsx(_.ExternalLink,{className:"h-3 w-3"}),"Ler termos"]}):o.jsx("span",{className:"text-xs text-muted-foreground italic",children:s&&b?"Carregando PDF...":"Conteúdo não configurado"})]}),o.jsxs("label",{className:"flex items-start gap-3 cursor-pointer select-none",children:[o.jsx(et,{className:"mt-0.5",checked:j,onCheckedChange:$=>l.onChange($?"accepted":"")}),o.jsxs("span",{className:"text-sm leading-snug flex-1",children:["Li e aceito ",r?`"${r}"`:"os termos e condições"]}),j&&o.jsx(_.CheckCircle2,{className:"h-4 w-4 text-green-500 shrink-0 mt-0.5"})]})]}),u&&o.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-destructive",children:[o.jsx(_.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),m||"Você precisa aceitar os termos para continuar"]}),x&&o.jsx("div",{ref:v,role:"dialog","aria-modal":"true","aria-label":"Termos e condições",tabIndex:-1,className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 outline-none",onClick:()=>y(!1),onKeyDown:$=>{$.key==="Escape"&&y(!1)},children:o.jsxs("div",{className:"relative w-full max-w-2xl max-h-[90vh] rounded-xl overflow-hidden flex flex-col bg-background shadow-xl",onClick:$=>$.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-input",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(_.ScrollText,{className:"h-4 w-4"}),o.jsx("span",{className:"font-semibold",children:"Termos e condições"})]}),o.jsx(De,{type:"button",variant:"ghost",size:"icon",onClick:()=>y(!1),children:o.jsx(_.X,{className:"h-4 w-4"})})]}),o.jsx("div",{className:"flex-1 overflow-auto p-4",children:S?o.jsx("iframe",{src:w,className:"w-full rounded border",style:{height:"62vh"},title:"Termos e condições",sandbox:"allow-scripts"}):o.jsx("p",{className:"text-sm whitespace-pre-wrap leading-relaxed",children:n})})]})})]})},Sk=({name:e,control:t,placeholder:r,disabled:n,readOnly:a})=>{var s;const{field:i,fieldState:l}=$e.useController({name:e,control:t}),[c,d]=N.useState(!1),u=!!l.error;return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"relative",children:[o.jsx(ue,{...i,value:i.value??"",type:c?"text":"password",placeholder:r,disabled:n,readOnly:a,className:K("pr-10",u&&"border-destructive focus-visible:ring-destructive")}),o.jsx("button",{type:"button",tabIndex:-1,onClick:()=>d(m=>!m),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors","aria-label":c?"Ocultar senha":"Mostrar senha",children:c?o.jsx(_.EyeOff,{size:16}):o.jsx(_.Eye,{size:16})})]}),((s=l.error)==null?void 0:s.message)&&o.jsx("p",{className:"text-sm text-destructive",children:l.error.message})]})},gh=({name:e,control:t,label:r,disabled:n,readOnly:a})=>{var s;const{field:i,fieldState:l}=$e.useController({name:e,control:t}),c=!!i.value;return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("label",{className:"flex items-center gap-3 cursor-pointer select-none",children:[o.jsx(Oi,{checked:c,onCheckedChange:d=>!a&&i.onChange(d),disabled:n||a,onBlur:i.onBlur}),o.jsx("span",{className:"text-sm leading-none",children:r})]}),((s=l.error)==null?void 0:s.message)&&o.jsx("p",{className:"text-sm text-destructive",children:l.error.message})]})},$k=({name:e,control:t,minValue:r=0,maxValue:n=100,step:a=1,disabled:s,readOnly:i})=>{var l;const{field:c,fieldState:d}=$e.useController({name:e,control:t}),u=c.value??r;return N.useEffect(()=>{(c.value===void 0||c.value===null)&&c.onChange(r)},[]),o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(Ao,{min:r,max:n,step:a,value:[u],onValueChange:m=>!i&&c.onChange(m[0]),disabled:s||i,className:"flex-1"}),o.jsx("span",{className:"text-sm font-medium text-primary min-w-[3rem] text-right tabular-nums",children:u})]}),o.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[o.jsx("span",{children:r}),o.jsx("span",{children:n})]}),((l=d.error)==null?void 0:l.message)&&o.jsx("p",{className:"text-sm text-destructive",children:d.error.message})]})},js=e=>/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(e),Ek=({name:e,control:t,disabled:r,readOnly:n})=>{var a;const{field:s,fieldState:i}=$e.useController({name:e,control:t}),l=s.value||"#000000",[c,d]=N.useState(l);return N.useEffect(()=>{d(l)},[l]),o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("input",{type:"color",value:js(l)?l:"#000000",disabled:r||n,onChange:u=>s.onChange(u.target.value),className:"h-10 w-14 cursor-pointer rounded-lg border border-input bg-transparent p-1 disabled:cursor-not-allowed disabled:opacity-50"}),o.jsx(ue,{type:"text",value:c,readOnly:n,disabled:r,onChange:u=>{const m=u.target.value;d(m),js(m)&&s.onChange(m.toUpperCase())},onBlur:()=>{js(c)||d(l),s.onBlur()},className:K("flex-1 font-mono uppercase",i.error&&"border-destructive focus-visible:ring-destructive"),maxLength:7,placeholder:"#000000"})]}),((a=i.error)==null?void 0:a.message)&&o.jsx("p",{className:"text-sm text-destructive",children:i.error.message})]})},Dk=({name:e,control:t,options:r,placeholder:n,disabled:a,readOnly:s})=>{var i,l;const{field:c,fieldState:d}=$e.useController({name:e,control:t}),[u,m]=N.useState(""),[p,f]=N.useState(!1),[b,h]=N.useState(-1),x=N.useRef(null),y=N.useRef(null),v=`autocomplete-${e}-listbox`,j=((i=r.find(D=>D.valor===c.value))==null?void 0:i.label)??"",w=u.length>0?r.filter(D=>D.label.toLowerCase().includes(u.toLowerCase())):r;N.useEffect(()=>{const D=O=>{x.current&&!x.current.contains(O.target)&&(f(!1),m(""),h(-1))};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[]);const C=()=>{f(!1),m(""),h(-1)};N.useEffect(()=>{if(b<0||!y.current)return;const D=y.current.querySelector(`[id="${v}-option-${b}"]`);D==null||D.scrollIntoView({block:"nearest"})},[b,v]);const S=D=>{D.disabled||(c.onChange(D.valor),C())},$=()=>{c.onChange(""),m(""),h(-1)},k=D=>{if(!p){(D.key==="ArrowDown"||D.key==="ArrowUp")&&(D.preventDefault(),f(!0),h(0));return}switch(D.key){case"ArrowDown":D.preventDefault(),h(O=>O<w.length-1?O+1:O);break;case"ArrowUp":D.preventDefault(),h(O=>O>0?O-1:0);break;case"Enter":D.preventDefault(),b>=0&&w[b]&&!w[b].disabled&&S(w[b]);break;case"Escape":D.preventDefault(),C();break;case"Tab":C();break}},E=p&&b>=0?`${v}-option-${b}`:void 0;return o.jsxs("div",{className:"space-y-1",ref:x,children:[o.jsxs("div",{className:"relative",children:[o.jsx(ue,{type:"text",role:"combobox","aria-expanded":p,"aria-haspopup":"listbox","aria-autocomplete":"list","aria-controls":v,"aria-activedescendant":E,value:p?u:j,placeholder:n??"Buscar...",disabled:a,readOnly:s,onChange:D=>{m(D.target.value),h(-1),f(!0)},onFocus:()=>!s&&f(!0),onKeyDown:k,className:K("pr-8",d.error&&"border-destructive focus-visible:ring-destructive"),autoComplete:"off"}),o.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1",children:c.value?o.jsx("button",{type:"button",onClick:$,className:"text-[var(--t-text-muted)] hover:text-[var(--t-text)]",tabIndex:-1,"aria-label":"Limpar seleção",children:o.jsx(_.X,{size:14})}):o.jsx(_.ChevronDown,{size:16,className:"text-muted-foreground pointer-events-none","aria-hidden":"true"})}),p&&!a&&!s&&o.jsx("ul",{role:"listbox",id:v,ref:y,"aria-label":"Opções disponíveis",className:"absolute z-50 mt-1 max-h-60 w-full overflow-auto rounded-lg border border-input bg-popover shadow-lg",children:w.length===0?o.jsx("li",{role:"option","aria-selected":!1,className:"px-3 py-2 text-sm text-muted-foreground",children:"Nenhuma opção encontrada"}):w.map((D,O)=>o.jsx("li",{id:`${v}-option-${O}`,role:"option","aria-selected":c.value===D.valor,"aria-disabled":D.disabled,onMouseDown:()=>S(D),className:["flex cursor-pointer items-center px-3 py-2 text-sm",D.disabled?"cursor-not-allowed opacity-40":O===b?"bg-accent":"hover:bg-accent",c.value===D.valor?"font-medium text-primary":"text-foreground"].join(" "),children:D.label},D.valor))})]}),((l=d.error)==null?void 0:l.message)&&o.jsx("p",{className:"text-sm text-destructive",role:"alert",children:d.error.message})]})},vh=({name:e,control:t,placeholder:r,disabled:n,readOnly:a})=>{var s;const{field:i,fieldState:l}=$e.useController({name:e,control:t}),c=!!l.error;return o.jsxs("div",{className:"space-y-1",children:[o.jsx(ue,{...i,value:i.value??"",type:"time",placeholder:r,disabled:n,readOnly:a,className:K(c&&"border-destructive focus-visible:ring-destructive")}),((s=l.error)==null?void 0:s.message)&&o.jsx("p",{className:"text-sm text-destructive",children:l.error.message})]})},Tk=({name:e,control:t,startLabel:r="Data inicial",endLabel:n="Data final",disabled:a,readOnly:s})=>{var i;const{field:l,fieldState:c}=$e.useController({name:e,control:t}),d=l.value??{},u=(p,f)=>{l.onChange({...d,[p]:f})},m=!!c.error;return o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{children:r}),o.jsx(ue,{type:"date",value:d.start??"",disabled:a,readOnly:s,onChange:p=>u("start",p.target.value),max:d.end??void 0,className:K(m&&"border-destructive focus-visible:ring-destructive")})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{children:n}),o.jsx(ue,{type:"date",value:d.end??"",disabled:a,readOnly:s,onChange:p=>u("end",p.target.value),min:d.start??void 0,className:K(m&&"border-destructive focus-visible:ring-destructive")})]})]}),((i=c.error)==null?void 0:i.message)&&o.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})},Ak=({name:e,control:t,maxRating:r=5,disabled:n,readOnly:a})=>{var s;const{field:i,fieldState:l}=$e.useController({name:e,control:t}),c=i.value??0,d=Array.from({length:r},(u,m)=>m+1);return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-1",children:[d.map(u=>o.jsx("button",{type:"button",disabled:n||a,onClick:()=>i.onChange(u===c?0:u),className:"transition-transform hover:scale-110 disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded","aria-label":`${u} estrela${u>1?"s":""}`,children:o.jsx(_.Star,{size:24,className:"transition-colors",fill:u<=c?"var(--color-primary)":"transparent",stroke:u<=c?"var(--color-primary)":"currentColor"})},u)),c>0&&o.jsxs("span",{className:"ml-2 text-sm text-muted-foreground",children:[c,"/",r]})]}),((s=l.error)==null?void 0:s.message)&&o.jsx("p",{className:"text-sm text-destructive",children:l.error.message})]})},Rk=({field:e,name:t,control:r,disabled:n,readOnly:a})=>{const s=n||e.isDisabled,i=a||e.isReadOnly;switch(e.tipo){case T.EMAIL:return o.jsx(Tt,{name:t,control:r,type:"email",placeholder:e.placeholder,disabled:s,readOnly:i});case T.NUMBER:return o.jsx(Tt,{name:t,control:r,type:"number",placeholder:e.placeholder,disabled:s,readOnly:i});case T.PASSWORD:return o.jsx(Tt,{name:t,control:r,type:"password",placeholder:e.placeholder,disabled:s,readOnly:i});case T.TELEFONE:return o.jsx(_r,{name:t,control:r,maskType:"telefone",placeholder:e.placeholder??"(00) 00000-0000",disabled:s,readOnly:i});case T.CPF:return o.jsx(_r,{name:t,control:r,maskType:"cpf",placeholder:e.placeholder??"000.000.000-00",disabled:s,readOnly:i});case T.CEP:return o.jsx(_r,{name:t,control:r,maskType:"cep",placeholder:e.placeholder??"00000-000",disabled:s,readOnly:i});case T.TEXTAREA:return o.jsx(Uo,{name:t,control:r,placeholder:e.placeholder,disabled:s,readOnly:i});case T.SELECT:return o.jsx(Ho,{name:t,control:r,options:e.opcoes??[],placeholder:e.placeholder,disabled:s,readOnly:i});case T.CHECKBOX:return o.jsx(Wo,{name:t,control:r,label:e.label??"",disabled:s,readOnly:i});case T.SWITCH:return o.jsx(gh,{name:t,control:r,label:e.label??"",disabled:s,readOnly:i});case T.DATE:return o.jsx(Rn,{name:t,control:r,disabled:s,readOnly:i});case T.TIME:return o.jsx(vh,{name:t,control:r,disabled:s,readOnly:i});case T.HIDDEN:return o.jsx(Go,{name:t,control:r});default:return o.jsx(Tt,{name:t,control:r,type:"text",placeholder:e.placeholder,disabled:s,readOnly:i})}},Ik=({name:e,control:t,subSchema:r,disabled:n,readOnly:a})=>{if(!r||r.fields.length===0)return null;const s=[...r.fields].sort((i,l)=>i.ordem-l.ordem);return o.jsxs("div",{className:"rounded-xl border border-input bg-muted/30 p-4 space-y-4",children:[r.titulo&&o.jsx("h4",{className:"text-sm font-semibold text-muted-foreground",children:r.titulo}),o.jsx("div",{className:"grid grid-cols-12 gap-4",children:s.map(i=>{const l=`${e}.${i.nome}`,c=i.tipo===T.CHECKBOX||i.tipo===T.SWITCH||i.tipo===T.HIDDEN,d=i.tamanho??6;return o.jsxs("div",{className:`col-span-${d}`,children:[!c&&o.jsxs("label",{className:"mb-1 block text-sm font-medium text-foreground",children:[i.label,i.obrigatorio&&o.jsx("span",{className:"text-destructive",children:" *"})]}),o.jsx(Rk,{field:i,name:l,control:t,disabled:n,readOnly:a})]},i.id)})})]})},bh=({field:e,control:t,nameOverride:r})=>{var n,a;const s=r??e.nome,{componentMapper:i}=Nr(),l=i==null?void 0:i[e.tipo];if(l)return o.jsx(l,{name:s,control:t,field:e});const c={name:s,control:t,placeholder:e.placeholder,disabled:e.isDisabled,readOnly:e.isReadOnly};switch(e.tipo){case T.TEXTO:return o.jsx(Tt,{...c,type:"text"});case T.EMAIL:return o.jsx(Tt,{...c,type:"email"});case T.NUMBER:return o.jsx(Tt,{...c,type:"number"});case T.PASSWORD:return o.jsx(Sk,{...c});case T.TEXTAREA:return o.jsx(Uo,{...c});case T.SELECT:return o.jsx(Ho,{...c,options:e.opcoes??[]});case T.AUTOCOMPLETE:return o.jsx(Dk,{...c,options:e.opcoes??[]});case T.SWITCH:return o.jsx(gh,{name:s,control:t,label:e.label,disabled:e.isDisabled,readOnly:e.isReadOnly});case T.SLIDER:return o.jsx($k,{name:s,control:t,minValue:e.minValue,maxValue:e.maxValue,step:e.step,disabled:e.isDisabled,readOnly:e.isReadOnly});case T.RATING:return o.jsx(Ak,{name:s,control:t,maxRating:e.maxRating,disabled:e.isDisabled,readOnly:e.isReadOnly});case T.COLOR:return o.jsx(Ek,{name:s,control:t,disabled:e.isDisabled,readOnly:e.isReadOnly});case T.TIME:return o.jsx(vh,{...c});case T.DATE_RANGE:return o.jsx(Tk,{name:s,control:t,startLabel:e.dateRangeStartLabel,endLabel:e.dateRangeEndLabel,disabled:e.isDisabled,readOnly:e.isReadOnly});case T.RADIO:return o.jsx(ml,{...c,options:e.opcoes??[]});case T.CHECKBOX:return o.jsx(Wo,{name:s,control:t,label:e.label,disabled:e.isDisabled,readOnly:e.isReadOnly});case T.CHECKBOX_GROUP:return o.jsx(ul,{...c,options:e.opcoes??[]});case T.DATE:return o.jsx(Rn,{name:s,control:t,disabled:e.isDisabled,readOnly:e.isReadOnly,validacao:e.validacao});case T.DATETIME:return o.jsx(Rn,{name:s,control:t,isDatetime:!0,disabled:e.isDisabled,readOnly:e.isReadOnly,validacao:e.validacao});case T.FILE:return o.jsx(xl,{name:s,control:t,disabled:e.isDisabled,fileTypes:(n=e.validacao)==null?void 0:n.fileTypes,maxFileSize:(a=e.validacao)==null?void 0:a.maxFileSize});case T.TELEFONE:return o.jsx(_r,{...c,maskType:"telefone"});case T.CPF:return o.jsx(_r,{...c,maskType:"cpf"});case T.CEP:return o.jsx(gl,{name:s,control:t,placeholder:e.placeholder,disabled:e.isDisabled,readOnly:e.isReadOnly,cepFillMap:e.cepFillMap});case T.HIDDEN:return o.jsx(Go,{name:s,control:t});case T.PARTICIPATION_TYPE:return o.jsx(mh,{name:s,control:t});case T.PAYMENT_METHOD:return o.jsx(hh,{name:s,control:t,relatedFieldName:e.relatedFieldName});case T.TERMS:return o.jsx(xh,{name:s,control:t,label:e.label,termoTexto:e.termoTexto,termoPdfUrl:e.termoPdfUrl,termoPdfUploadId:e.termoPdfUploadId});case T.FIELD_ARRAY:return o.jsx(uh,{name:s,control:t,subFields:e.subFields,minItems:e.minItems,maxItems:e.maxItems,itemLabel:e.itemLabel,addLabel:e.addLabel});case T.SUB_FORM:return o.jsx(Ik,{name:s,control:t,subSchema:e.subSchema,disabled:e.isDisabled,readOnly:e.isReadOnly});default:return o.jsx(Tt,{...c,type:"text"})}},Pk=({container:e,control:t})=>{var r;const{externalData:n={},fieldResolvers:a}=Nr(),s=e.icone?Pt[e.icone]:void 0,i=n,l=N.useMemo(()=>Bo(e,i),[e,JSON.stringify(i)]),c=N.useMemo(()=>[...l.campos].sort((x,y)=>x.ordem-y.ordem),[l.campos]),d=$e.useWatch({control:t}),{wrapperClass:u,wrapperStyle:m,headerClass:p,headerStyle:f,tmpl:b}=nh(),h=x=>{if(!at(x.condicional,d,n))return null;let y=x;if(x.resolvePropsKey&&a!=null&&a[x.resolvePropsKey]){const S=a[x.resolvePropsKey](x,d,n);y={...x,...S}}if(y.opcoesFromVar){const S=n[y.opcoesFromVar];Array.isArray(S)&&(y={...y,opcoes:S.map($=>typeof $=="string"?{valor:$,label:$}:$&&typeof $=="object"&&"valor"in $&&"label"in $?$:{valor:String($),label:String($)})})}const v=y.tamanho??12,j=y.inicioColuna,w=j?`${j} / span ${v}`:`span ${v}`,C=o.jsx(bh,{field:y,control:t});return y.tipo===T.CHECKBOX||y.tipo===T.HIDDEN||y.tipo===T.SWITCH?o.jsx("div",{className:"max-sm:!col-span-12",style:{gridColumn:w},children:C},y.id):o.jsxs("div",{className:"max-sm:!col-span-12 space-y-2",style:{gridColumn:w},children:[o.jsxs("label",{className:"font-medium flex items-center gap-1",style:{color:"var(--t-text)"},children:[y.label,y.obrigatorio&&o.jsx("span",{className:"text-destructive",children:"*"})]}),C,y.hint&&o.jsx("p",{className:"text-xs text-muted-foreground",children:y.hint})]},y.id)};return o.jsxs("div",{className:u,style:m,children:[(l.titulo||s)&&o.jsx("div",{className:p,style:f,children:o.jsxs("div",{className:"flex items-center gap-3",children:[s&&o.jsx("div",{className:"p-2 rounded-xl",style:{background:"color-mix(in srgb, var(--t-primary) 12%, transparent)"},children:o.jsx(s,{className:"w-5 h-5",style:{color:"var(--t-primary)"}})}),o.jsxs("div",{children:[o.jsx("h3",{className:((r=b.typography)==null?void 0:r.stepTitleClass)??"text-lg font-semibold",style:{color:"var(--t-text)"},children:l.titulo}),l.descricao&&o.jsx("p",{className:"text-sm",style:{color:"var(--t-text-muted)"},children:l.descricao})]})]})}),o.jsx("div",{className:"p-6 grid grid-cols-12 gap-4",children:c.map(h)})]})},_k=({container:e,control:t})=>{var r;const{externalData:n={}}=Nr(),a=e.nome??"__invalid__",s=e.minItems??1,i=e.maxItems,l=e.itemLabel??"Item",c=e.icone?Pt[e.icone]:void 0,d=n,u=N.useMemo(()=>Bo(e,d),[e,JSON.stringify(d)]),m=N.useMemo(()=>[...u.campos].sort((k,E)=>k.ordem-E.ordem),[u.campos]),p=N.useCallback(()=>{const k={};for(const E of m)E.initialValue!==void 0?k[E.nome]=typeof E.initialValue=="string"?xt(E.initialValue,d):E.initialValue:E.defaultValue!==void 0&&(k[E.nome]=E.defaultValue);return k},[m,d]),{fields:f,append:b,remove:h}=$e.useFieldArray({control:t,name:a});N.useEffect(()=>{if(e.nome&&f.length<s)for(let k=f.length;k<s;k++)b(p())},[s]);const x=$e.useWatch({control:t}),y=N.useMemo(()=>{const k=x[a];return Array.isArray(k)?k:[]},[x,a]),{wrapperClass:v,wrapperStyle:j,headerClass:w,headerStyle:C,tmpl:S}=nh();if(!e.nome)return console.error("[RepeatableContainerRenderer] container.nome é obrigatório para containers repetíveis. Container id:",e.id),null;const $=(k,E)=>{const D=y[E]??{};if(!at(k.condicional,D,n))return null;const O=`${a}.${E}.${k.nome}`,L=k.tamanho??12,A=k.inicioColuna,z=A?`${A} / span ${L}`:`span ${L}`,X=o.jsx(bh,{field:k,control:t,nameOverride:O});return k.tipo===T.CHECKBOX||k.tipo===T.HIDDEN?o.jsx("div",{className:"max-sm:!col-span-12",style:{gridColumn:z},children:X},`${k.id}-${E}`):o.jsxs("div",{className:"max-sm:!col-span-12 space-y-2",style:{gridColumn:z},children:[o.jsxs("label",{className:"font-medium flex items-center gap-1",style:{color:"var(--t-text)"},children:[k.label,k.obrigatorio&&o.jsx("span",{className:"text-destructive",children:"*"})]}),X,k.hint&&o.jsx("p",{className:"text-xs text-muted-foreground",children:k.hint})]},`${k.id}-${E}`)};return o.jsxs("div",{className:v,style:j,children:[(u.titulo||c)&&o.jsx("div",{className:w,style:C,children:o.jsxs("div",{className:"flex items-center gap-3",children:[c&&o.jsx("div",{className:"p-2 rounded-xl",style:{background:"color-mix(in srgb, var(--t-primary) 12%, transparent)"},children:o.jsx(c,{className:"w-5 h-5",style:{color:"var(--t-primary)"}})}),o.jsxs("div",{children:[o.jsx("h3",{className:((r=S.typography)==null?void 0:r.stepTitleClass)??"text-lg font-semibold",style:{color:"var(--t-text)"},children:u.titulo}),u.descricao&&o.jsx("p",{className:"text-sm",style:{color:"var(--t-text-muted)"},children:u.descricao})]})]})}),o.jsxs("div",{className:"p-6 space-y-4",children:[f.map((k,E)=>o.jsxs("div",{className:"border border-input rounded-lg p-4 bg-muted/30",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold shrink-0 bg-primary text-primary-foreground",children:E+1}),o.jsxs("span",{className:"text-sm font-semibold",children:[l," ",E+1]})]}),f.length>s&&o.jsx("button",{type:"button",onClick:()=>h(E),className:"inline-flex items-center justify-center rounded-md p-1.5 text-destructive hover:bg-destructive/10 transition-colors","aria-label":"Remover item",children:o.jsx(_.Trash2,{className:"w-4 h-4"})})]}),o.jsx("div",{className:"grid grid-cols-12 gap-4",children:m.map(D=>$(D,E))})]},k.id)),(!i||f.length<i)&&o.jsxs("button",{type:"button",className:"w-full flex items-center justify-center gap-2 py-2 px-4 border border-input rounded-lg text-sm hover:bg-accent transition-colors",onClick:()=>b(p()),children:[o.jsx(_.Plus,{className:"w-4 h-4"}),"Adicionar ",l.toLowerCase()]}),i&&o.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:["Máximo de ",i," ",l.toLowerCase(),i>1?"s":""]})]})]})},yh=e=>e.container.repeatable&&e.container.nome?o.jsx(_k,{...e}):o.jsx(Pk,{...e}),wh=({step:e,control:t,externalData:r={}})=>{const n=N.useMemo(()=>[...e.containers].sort((s,i)=>s.ordem-i.ordem),[e.containers]),a=$e.useWatch({control:t});return o.jsx("div",{className:"grid grid-cols-12 gap-4",children:n.map(s=>{if(s.condicional&&!at(s.condicional,a,r))return null;const i=s.tamanho??12,l=s.inicioColuna,c=l?`${l} / span ${i}`:`span ${i}`;return o.jsx("div",{className:"max-sm:!col-span-12",style:{gridColumn:c},children:o.jsx(yh,{container:s,control:t})},s.id)})})},xa=N.createContext({submitting:!1,warnings:{},requestSubmit:()=>{}}),Ok=xa.Provider,Fk=()=>{const e=kh("useFormApi"),t=N.useContext(xa);return{change:(r,n)=>e.setValue(r,n,{shouldValidate:!0,shouldDirty:!0}),reset:r=>e.reset(r),submit:t.requestSubmit,getState:()=>{const{errors:r,isDirty:n,isValid:a}=e.formState;return{values:e.getValues(),errors:Object.fromEntries(Object.entries(r).map(([s,i])=>[s,i==null?void 0:i.message])),warnings:t.warnings,dirty:n,valid:a,submitting:t.submitting}}}},jh=()=>{const e=kh("useFormState"),t=N.useContext(xa),r=$e.useWatch({control:e.control}),{errors:n,isDirty:a,isValid:s}=e.formState;return{values:r,errors:Object.fromEntries(Object.entries(n).map(([i,l])=>[i,l==null?void 0:l.message])),warnings:t.warnings,dirty:a,valid:s,submitting:t.submitting}},zk=e=>{var t;const r=$e.useFormContext(),{warnings:n}=N.useContext(xa),a=$e.useWatch({control:r.control,name:e}),s=r.getFieldState(e,r.formState);return{value:a,error:(t=s.error)==null?void 0:t.message,warning:n[e],dirty:s.isDirty,touched:s.isTouched,valid:!s.error}},Lk=e=>{var t;const{control:r}=$e.useFormContext(),{warnings:n}=N.useContext(xa),{field:a,fieldState:s}=$e.useController({name:e,control:r});return{input:{name:a.name,value:a.value,onChange:a.onChange,onBlur:a.onBlur,ref:a.ref},meta:{error:(t=s.error)==null?void 0:t.message,warning:n[e],touched:s.isTouched,dirty:s.isDirty,valid:!s.error}}},kh=e=>{const t=$e.useFormContext();if(!t)throw new Error(`[SchemaForms] O hook '${e}' foi chamado fora de um <FormRenderer />. Certifique-se de que o componente está dentro da árvore de renderização do formulário.`);return t},sd=({stepIndex:e,totalSteps:t,step:r,defaultValues:n,externalData:a,fieldErrors:s,isSubmitting:i,submitError:l,validatorMapper:c={},onWarningsChange:d,onValuesChange:u,onSubmit:m,onBack:p})=>{const f=e===t-1,b=N.useMemo(()=>JSON.stringify(a),[a]),h=N.useMemo(()=>Qf(r,a,c),[r.id,b]),x=N.useMemo(()=>eh(r,a,c),[r.id,b]),[y,v]=N.useState({}),j=N.useRef(d);j.current=d;const w=a,C=N.useMemo(()=>rh(r,w),[r,b]),S=$e.useForm({resolver:h,defaultValues:n,mode:"onTouched"}),{control:$,handleSubmit:k,setError:E,clearErrors:D,setValue:O}=S;N.useEffect(()=>{D();for(const[U,Q]of Object.entries(s))E(U,{type:"server",message:Q})},[s,E,D]);const L=N.useMemo(()=>r.containers.filter(U=>!U.repeatable).flatMap(U=>U.campos).filter(U=>!!U.condicional),[r.containers]),A=N.useMemo(()=>r.containers.filter(U=>!!U.condicional),[r.containers]),z=N.useMemo(()=>r.containers.filter(U=>!U.repeatable).flatMap(U=>U.campos).filter(U=>{var Q;return U.condicional&&((Q=U.setValues)==null?void 0:Q.length)}),[r.containers]),X=N.useMemo(()=>r.containers.filter(U=>U.repeatable&&!!U.nome).map(U=>({container:U,fields:U.campos.filter(Q=>!!Q.condicional)})).filter(U=>U.fields.length>0),[r.containers]),q=N.useRef({}),Z=N.useRef(!0),V=$e.useWatch({control:$}),M=N.useRef(u);M.current=u,N.useEffect(()=>{var U;(U=M.current)==null||U.call(M,V)},[V]),N.useEffect(()=>{let U=!1;return x(V).then(Q=>{var Y;U||(v(Q),(Y=j.current)==null||Y.call(j,Q))}).catch(Q=>{U||console.error("[StepForm] warnComputer error:",Q)}),()=>{U=!0}},[V,x]),N.useEffect(()=>{var U;if(!L.length&&!z.length&&!A.length&&!X.length)return;const Q=V;for(const H of L)if(!at(H.condicional,Q,a)){if(D(H.nome),H.tipo===T.FIELD_ARRAY){const W=Q[H.nome];Array.isArray(W)&&W.forEach((G,ne)=>{(H.subFields??[]).forEach(J=>D(`${H.nome}.${ne}.${J.nome}`))})}if(H.clearedValue!==void 0){const W=H.clearedValue??"";Q[H.nome]!==W&&O(H.nome,W,{shouldValidate:!1})}}for(const H of A)if(!at(H.condicional,Q,a))if(H.repeatable&&H.nome)(Array.isArray(Q[H.nome])?Q[H.nome]:[]).forEach((W,G)=>{for(const ne of H.campos)D(`${H.nome}.${G}.${ne.nome}`)});else for(const W of H.campos){D(W.nome);const G=W.clearedValue!==void 0?W.clearedValue:void 0;G!==void 0&&Q[W.nome]!==G&&O(W.nome,G,{shouldValidate:!1})}for(const{container:H,fields:W}of X){const G=H.nome,ne=Array.isArray(Q[G])?Q[G]:[];for(let J=0;J<ne.length;J++){const te=ne[J];for(const ce of W)if(!at(ce.condicional,te,a)&&(D(`${G}.${J}.${ce.nome}`),ce.clearedValue!==void 0)){const be=ce.clearedValue??"";te[ce.nome]!==be&&O(`${G}.${J}.${ce.nome}`,be,{shouldValidate:!1})}}}const Y=Z.current;for(const H of z){const W=at(H.condicional,Q,a),G=Y?W:q.current[H.nome]??!1;if(W&&!G&&(U=H.setValues)!=null&&U.length)for(const ne of H.setValues){const J=typeof ne.valor=="string"?xt(ne.valor,w):ne.valor;O(ne.campo,J,{shouldValidate:!1})}q.current[H.nome]=W}Z.current=!1},[V,L,z,A,X,a,O,D]);const P=C.icone?Pt[C.icone]:void 0,se=N.useMemo(()=>()=>{S.handleSubmit(m)()},[m]);return o.jsx($e.FormProvider,{...S,children:o.jsx(Ok,{value:{submitting:i,warnings:y,requestSubmit:se},children:o.jsx("form",{onSubmit:k(m),noValidate:!0,onKeyDown:U=>{U.key==="Enter"&&U.target.tagName==="INPUT"&&U.preventDefault()},children:o.jsxs("div",{className:"space-y-6",children:[C.showLabel!==!1&&o.jsxs("div",{className:"text-center space-y-2",children:[P&&o.jsx("div",{className:"w-12 h-12 mx-auto rounded-xl flex items-center justify-center",style:{background:"color-mix(in srgb, var(--t-primary) 12%, transparent)"},children:o.jsx(P,{className:"w-6 h-6",style:{color:"var(--t-primary)"}})}),o.jsx("h2",{className:"text-2xl font-bold",style:{color:"var(--t-text)"},children:C.titulo}),C.descricao&&o.jsx("p",{className:"text-sm text-muted-foreground",children:C.descricao})]}),o.jsx(wh,{step:C,control:$,externalData:a}),o.jsxs("div",{className:"flex items-center justify-between gap-4 pt-6 pb-2",children:[o.jsxs(De,{type:"button",variant:"outline",onClick:p,disabled:e===0,className:K(e>0&&"border-primary/40 text-primary hover:bg-primary/5"),children:[o.jsx(_.ChevronLeft,{className:"w-4 h-4"}),o.jsx("span",{className:"hidden sm:inline",children:"Anterior"})]}),o.jsxs("span",{className:"text-xs font-semibold tabular-nums sm:hidden text-muted-foreground",children:[e+1,"/",t]}),o.jsxs(De,{type:"submit",disabled:i,children:[i?o.jsx(_.Loader2,{className:"w-4 h-4 animate-spin"}):f?o.jsx(_.Check,{className:"w-4 h-4"}):o.jsx(_.ChevronRight,{className:"w-4 h-4"}),o.jsx("span",{className:"hidden sm:inline",children:f?"Finalizar":"Próximo"})]})]}),l&&o.jsx("p",{className:"text-sm text-destructive mt-2 text-center",children:l})]})})})})},eo=e=>{if(e)return Pt[e]},Mk=({steps:e,currentStep:t,onStepClick:r})=>o.jsx("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:e.map((n,a)=>o.jsx("div",{role:r?"button":void 0,tabIndex:r?0:void 0,onClick:()=>r==null?void 0:r(a),onKeyDown:s=>s.key==="Enter"&&(r==null?void 0:r(a)),className:K("w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold transition-all shrink-0",r&&"cursor-pointer hover:opacity-80"),style:a===t?{background:"var(--t-primary)",color:"#ffffff",boxShadow:"0 0 0 3px color-mix(in srgb, var(--t-primary) 30%, transparent)"}:a<t?{background:"#22c55e",color:"#ffffff"}:{background:"hsl(var(--muted))",color:"hsl(var(--muted-foreground))"},children:a<t?o.jsx(_.Check,{className:"w-4 h-4"}):a+1},n.id))}),Vk=({steps:e,currentStep:t,onStepClick:r})=>o.jsx("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:e.map((n,a)=>{const s=eo(n.icone)??_.CircleDot;return o.jsx("div",{role:r?"button":void 0,tabIndex:r?0:void 0,onClick:()=>r==null?void 0:r(a),onKeyDown:i=>i.key==="Enter"&&(r==null?void 0:r(a)),className:K("w-9 h-9 rounded-full flex items-center justify-center transition-all shrink-0",r&&"cursor-pointer hover:opacity-80"),style:a===t?{background:"var(--t-primary)",color:"#ffffff",boxShadow:"0 0 0 3px color-mix(in srgb, var(--t-primary) 30%, transparent)"}:a<t?{background:"#22c55e",color:"#ffffff"}:{background:"hsl(var(--muted))",color:"hsl(var(--muted-foreground))"},children:a<t?o.jsx(_.Check,{className:"w-4 h-4"}):o.jsx(s,{className:"w-4 h-4"})},n.id)})}),Bk=({steps:e,currentStep:t,position:r,orientation:n="horizontal",onStepClick:a})=>n==="vertical"?o.jsx("div",{className:"flex flex-col gap-0",children:e.map((s,i)=>{const l=eo(s.icone)??_.CircleDot,c=i===t,d=i<t,u=i===e.length-1;return o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsxs("div",{className:"flex flex-col items-center",children:[o.jsx("button",{type:"button",onClick:()=>a==null?void 0:a(i),className:K("w-8 h-8 rounded-full flex items-center justify-center transition-all shrink-0",a&&"cursor-pointer hover:opacity-80"),style:c?{background:"var(--t-primary)",color:"#fff",boxShadow:"0 0 10px color-mix(in srgb, var(--t-primary) 50%, transparent)"}:d?{background:"#22c55e",color:"#fff"}:{background:"color-mix(in srgb, var(--t-text) 8%, transparent)",color:"var(--t-text-muted)",border:"1.5px solid color-mix(in srgb, var(--t-border) 60%, transparent)"},children:d?o.jsx(_.Check,{className:"w-3.5 h-3.5"}):o.jsx(l,{className:"w-3.5 h-3.5"})}),!u&&o.jsx("div",{className:"w-[2px] my-1",style:{height:"24px",background:d?"#22c55e":"color-mix(in srgb, var(--t-border) 50%, transparent)"}})]}),o.jsx("span",{className:"text-sm font-medium leading-tight mt-1.5",style:c?{color:"var(--t-primary)"}:d?{color:"#16a34a"}:{color:"var(--t-text-muted)"},children:s.label??s.id})]},s.id)})}):o.jsx("div",{className:"w-full flex items-start",children:e.map((s,i)=>{const l=eo(s.icone)??_.CircleDot,c=i===t,d=i<t,u=i===e.length-1;return o.jsxs("div",{className:K("flex items-start",!u&&"flex-1"),children:[o.jsxs("div",{className:"flex flex-col items-center gap-1.5 w-[56px] shrink-0 mx-auto",children:[o.jsx("button",{type:"button",onClick:()=>a==null?void 0:a(i),className:K("w-10 h-10 rounded-full flex items-center justify-center transition-all shrink-0",a&&"cursor-pointer hover:opacity-80"),style:c?{background:"var(--t-primary)",color:"#ffffff",boxShadow:"0 0 12px color-mix(in srgb, var(--t-primary) 50%, transparent)"}:d?{background:"#22c55e",color:"#ffffff"}:{background:"color-mix(in srgb, var(--t-text) 8%, transparent)",color:"var(--t-text-muted)",border:"1.5px solid color-mix(in srgb, var(--t-border) 60%, transparent)"},children:d?o.jsx(_.Check,{className:"w-4 h-4"}):o.jsx(l,{className:"w-4 h-4"})}),o.jsx("span",{className:"text-[10px] font-medium text-center leading-tight line-clamp-2 px-0.5",style:c?{color:"var(--t-primary)"}:d?{color:"#16a34a"}:{color:"var(--t-text-muted)"},children:s.label??s.id})]}),!u&&o.jsx("div",{className:"flex-1 h-[1.5px] mt-5 mx-1",style:{background:d?"linear-gradient(90deg, var(--t-primary), color-mix(in srgb, var(--t-primary) 40%, transparent))":"color-mix(in srgb, var(--t-border) 50%, transparent)"}})]},s.id)})}),Ch=({steps:e,currentStep:t,onStepClick:r,className:n,forceShow:a})=>{const s=sa(),{layout:i}=s;if(!i.showStepIndicators||e.length<=1&&!a)return null;const l=i.stepIndicatorVariant??"numbers",c=i.stepIndicatorPosition??"top-center",d=i.stepIndicatorOrientation??"horizontal",u=(t+1)/e.length*100,m=e[t],p=eo(m==null?void 0:m.icone)??_.CircleDot,f=o.jsx("div",{className:"h-1 rounded-full overflow-hidden",style:{background:"color-mix(in srgb, var(--t-primary) 15%, transparent)"},children:o.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${u}%`,background:"linear-gradient(90deg, var(--t-primary), var(--t-accent))"}})}),b=o.jsxs("div",{className:"block sm:hidden space-y-2",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center shrink-0",style:{background:"var(--t-primary)",color:"#fff"},children:o.jsx(p,{className:"w-5 h-5"})}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("p",{className:"text-sm font-semibold leading-tight truncate",style:{color:"var(--t-text)"},children:(m==null?void 0:m.label)??(m==null?void 0:m.id)}),o.jsxs("p",{className:"text-xs leading-tight",style:{color:"var(--t-text-muted)"},children:["Passo ",t+1," de ",e.length]})]})]}),f]}),h=o.jsxs("div",{className:"hidden sm:block",children:[l==="numbers"&&o.jsx(Mk,{steps:e,currentStep:t,onStepClick:r}),l==="icons"&&o.jsx(Vk,{steps:e,currentStep:t,onStepClick:r}),l==="icons-labeled"&&o.jsx(Bk,{steps:e,currentStep:t,position:c,orientation:d,onStepClick:r})]}),x=i.showProgressBar?o.jsx("div",{className:"hidden sm:block",children:f}):null;return d==="vertical"?o.jsxs("div",{className:K("flex gap-6 items-start",n),children:[b,o.jsxs("div",{className:"hidden sm:flex gap-6 items-start shrink-0",children:[h,x&&o.jsx("div",{className:"flex-1 pt-4",children:x})]})]}):o.jsxs("div",{className:K("space-y-3",n),children:[b,o.jsxs("div",{className:"hidden sm:block space-y-3",children:[h,x]})]})},Uk=(e,t,r)=>{var n;const a={...t},s=r;for(const i of e.containers){for(const l of i.campos)if(a[l.nome]===void 0&&(l.initialValue!==void 0?a[l.nome]=typeof l.initialValue=="string"?xt(l.initialValue,s):l.initialValue:l.defaultValue!==void 0&&(a[l.nome]=l.defaultValue)),l.tipo===T.FIELD_ARRAY&&(n=l.subFields)!=null&&n.length){const c=a[l.nome];Array.isArray(c)&&c.length>0&&(a[l.nome]=c.map(d=>{const u={...d};for(const m of l.subFields)u[m.nome]===void 0&&(m.initialValue!==void 0?u[m.nome]=typeof m.initialValue=="string"?xt(m.initialValue,s):m.initialValue:m.defaultValue!==void 0&&(u[m.nome]=m.defaultValue));return u}))}if(i.repeatable&&i.nome){const l=a[i.nome];Array.isArray(l)&&l.length>0&&(a[i.nome]=l.map(c=>{const d={...c};for(const u of i.campos)d[u.nome]===void 0&&(u.initialValue!==void 0?d[u.nome]=typeof u.initialValue=="string"?xt(u.initialValue,s):u.initialValue:u.defaultValue!==void 0&&(d[u.nome]=u.defaultValue));return d}))}}return a},Hk=({schema:e,initialValues:t={},initialStep:r=0,onSubmitStep:n,onComplete:a,template:s,formTitle:i,externalData:l={},fieldErrors:c={},uploadFile:d,deleteUploadedFile:u,cepLookup:m,resolveTermsUploadUrl:p,fieldResolvers:f,validatorMapper:b,componentMapper:h,paymentMethodOptions:x,onValuesChange:y,className:v,StepIndicator:j=Ch})=>{const[w,C]=N.useState(()=>r),[S,$]=N.useState({...t}),[k,E]=N.useState(()=>r),[D,O]=N.useState(!1),[L,A]=N.useState(null),[z,X]=N.useState({}),q=N.useRef(p);q.current=p;const Z=N.useCallback(me=>q.current(me),[]),V=!!p,M=N.useRef(u);M.current=u;const P=N.useCallback(me=>M.current(me),[]),se=!!u,U=N.useMemo(()=>JSON.stringify(l),[l]),Q=N.useMemo(()=>JSON.stringify(e.stepConfig),[e.stepConfig]),Y=N.useMemo(()=>{const me=uo(s);return e.stepConfig?{...me,layout:{...me.layout,...e.stepConfig}}:me},[s,Q]),H=N.useMemo(()=>[...e.steps].sort((me,Ee)=>me.ordem-Ee.ordem),[e.steps]),W=H.length,G=W>0?H[Math.min(w,W-1)]:null,ne=N.useMemo(()=>G?Uk(G,S,l):{},[G,S,U]),J=N.useMemo(()=>({uploadFile:d,deleteUploadedFile:se?P:void 0,cepLookup:m,resolveTermsUploadUrl:V?Z:void 0,externalData:l,fieldResolvers:f,validatorMapper:b,fieldWarnings:z,componentMapper:h,paymentMethodOptions:x}),[d,se,P,m,Z,V,f,b,z,h,x,U]),te=N.useCallback(async me=>{if(!D){O(!0),A(null);try{const Ee={...S,...me};if($(Ee),n&&await n(w,me),w===W-1)a&&await a(Ee);else{const Fe=w+1;C(Fe),E(Nt=>Math.max(Nt,Fe))}}catch(Ee){console.error("[FormRenderer] Submit error:",Ee);const Fe=Ee instanceof Error?Ee.message:"Ocorreu um erro. Tente novamente.";A(Fe)}finally{O(!1)}}},[w,S,D,W,n,a]),ce=N.useCallback(()=>{w>0&&C(me=>me-1)},[w]);if(!G)return o.jsx(Ja.Provider,{value:J,children:o.jsx(ea,{config:Y,className:`min-h-dvh ${Y.wrapperClass??""} ${v??""}`,renderWrapper:!0,children:o.jsx("div",{className:"w-full max-w-4xl mx-auto px-4 py-6 sm:px-6 text-center text-muted-foreground",children:"Nenhum step configurado."})})});const be=Y.layout.eventTitleStyle??"bar",Ce=(Y.layout.stepIndicatorOrientation??"horizontal")==="vertical",ve=W>=1?o.jsx(j,{steps:H.map(me=>({id:me.id,label:me.titulo,icone:me.icone})),currentStep:w,onStepClick:me=>{me!==w&&me<=k&&C(me)}}):null;return o.jsx(Ja.Provider,{value:J,children:o.jsx(ea,{config:Y,className:`min-h-dvh ${Y.wrapperClass??""} ${v??""}`,renderWrapper:!0,children:o.jsxs("div",{className:"w-full max-w-4xl mx-auto px-4 py-6 sm:px-6",children:[i&&be==="bar"&&o.jsx("div",{className:"w-full text-center text-sm font-medium py-2.5 px-4 mb-6 rounded-lg border border-input text-muted-foreground bg-muted/30",children:i}),i&&be==="inline"&&o.jsxs("div",{className:"text-center mb-6",children:[o.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest mb-1",style:{color:"var(--t-text-muted)"},children:"Inscrição"}),o.jsx("h1",{className:"text-2xl font-bold",style:{color:"var(--t-text)"},children:i}),o.jsx("div",{className:"h-0.5 w-12 mx-auto mt-3 rounded-full",style:{background:"var(--t-primary)"}})]}),Ce?o.jsxs("div",{className:"flex gap-6 items-start",children:[o.jsx("div",{className:"hidden sm:block shrink-0 w-44 pt-1",children:ve}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"sm:hidden mb-6",children:ve}),o.jsx(sd,{stepIndex:w,totalSteps:W,step:G,defaultValues:ne,externalData:l,fieldErrors:c,isSubmitting:D,submitError:L,validatorMapper:b,onWarningsChange:X,onValuesChange:y,onSubmit:te,onBack:ce},w)]})]}):o.jsxs(o.Fragment,{children:[ve&&o.jsx("div",{className:"mb-8",children:ve}),o.jsx(sd,{stepIndex:w,totalSteps:W,step:G,defaultValues:ne,externalData:l,fieldErrors:c,isSubmitting:D,submitError:L,validatorMapper:b,onWarningsChange:X,onValuesChange:y,onSubmit:te,onBack:ce},w)]})]})})})},Wk=({children:e,render:t,onChange:r})=>{const n=jh(),a=N.useRef(r);return a.current=r,N.useEffect(()=>{var s;(s=a.current)==null||s.call(a,n)},[n.values,n.dirty,n.valid,n.submitting,n.errors,n.warnings]),t?o.jsx(o.Fragment,{children:t(n)}):typeof e=="function"?o.jsx(o.Fragment,{children:e(n)}):e!==void 0?o.jsx(o.Fragment,{children:e}):null},Or=[{component:"texto",label:"Texto",icon:_.Type,group:"texto"},{component:"textarea",label:"Área de texto",icon:_.AlignLeft,group:"texto"},{component:"number",label:"Número",icon:_.Hash,group:"texto"},{component:"email",label:"E-mail",icon:_.Mail,group:"texto"},{component:"password",label:"Senha",icon:_.Lock,group:"texto"},{component:"select",label:"Seleção",icon:_.ChevronDown,group:"selecao"},{component:"autocomplete",label:"Autocomplete",icon:_.Search,group:"selecao"},{component:"radio",label:"Radio",icon:_.CircleDot,group:"selecao"},{component:"checkbox",label:"Checkbox",icon:_.CheckSquare,group:"selecao"},{component:"checkbox_group",label:"Grupo de checkboxes",icon:_.ListChecks,group:"selecao"},{component:"switch",label:"Switch (toggle)",icon:_.ToggleLeft,group:"selecao"},{component:"slider",label:"Slider",icon:_.SlidersHorizontal,group:"range"},{component:"rating",label:"Avaliação (estrelas)",icon:_.Star,group:"range"},{component:"color",label:"Cor",icon:_.Palette,group:"range"},{component:"date",label:"Data",icon:_.Calendar,group:"data"},{component:"datetime",label:"Data e hora",icon:_.Clock,group:"data"},{component:"time",label:"Horário",icon:_.Timer,group:"data"},{component:"date_range",label:"Período",icon:_.CalendarRange,group:"data"},{component:"telefone",label:"Telefone",icon:_.Phone,group:"contato"},{component:"cpf",label:"CPF",icon:_.CreditCard,group:"contato"},{component:"cep",label:"CEP",icon:_.MapPin,group:"contato"},{component:"file",label:"Arquivo",icon:_.Upload,group:"outros"},{component:"hidden",label:"Oculto",icon:_.EyeOff,group:"outros"},{component:"field_array",label:"Lista de itens",icon:_.List,group:"outros"},{component:"terms",label:"Termos e condições",icon:_.ScrollText,group:"outros"},{component:"sub_form",label:"Sub-formulário",icon:_.LayoutList,group:"outros"}],vl=[{component:"step",label:"Step",icon:_.Layers,color:"border-primary/40 bg-primary/5"},{component:"container",label:"Container",icon:_.BoxSelect,color:"border-blue-500/40 bg-blue-500/5"}],bl=[{key:"evento.nome",label:"Nome do evento",type:"string"},{key:"evento.descricao",label:"Descrição",type:"string"},{key:"evento.valor",label:"Valor (centavos)",type:"number"},{key:"evento.valorPorDia",label:"Valor por dia",type:"number"},{key:"evento.vagasTotal",label:"Vagas totais",type:"number"},{key:"evento.vagasPorDia",label:"Vagas por dia",type:"number"},{key:"evento.vagasMasculinas",label:"Vagas masculinas",type:"number"},{key:"evento.vagasFemininas",label:"Vagas femininas",type:"number"},{key:"evento.dataInicioEvento",label:"Data início",type:"date"},{key:"evento.dataFimEvento",label:"Data fim",type:"date"},{key:"evento.dataAberturaInscricoes",label:"Abertura inscrições",type:"date"},{key:"evento.localNome",label:"Local - Nome",type:"string"},{key:"evento.localEndereco",label:"Local - Endereço",type:"string"},{key:"evento.localTelefone",label:"Local - Telefone",type:"string"},{key:"evento.localMapUrl",label:"Local - URL do mapa",type:"string"},{key:"evento.localMapLink",label:"Local - Link do mapa",type:"string"},{key:"evento.status",label:"Status do evento",type:"string"},{key:"evento.publicId",label:"ID público (URL)",type:"string"},{key:"evento.fotoCapa",label:"URL da foto de capa",type:"string"},{key:"evento.template",label:"Template visual",type:"string"}],He=e=>e.startsWith("step-")||e==="step"?"step":e.startsWith("container-")||e==="container"?"container":"field",qk=e=>Or.find(t=>t.component===e),Nh=e=>{const t=Or.map(n=>n.component).filter(n=>n.includes("_"));for(const n of t)if(e.startsWith(n))return Or.find(a=>a.component===n);const r=e.split("-")[0];return Or.find(n=>n.component===r)},ks=e=>({when:e.campoId,operator:e.operador,value:e.valor,source:e.source}),Sh=e=>{var t;const r={campoId:e.when,operador:e.operator,valor:e.value,source:e.source};if(e.logicOperator&&(t=e.extraConditions)!=null&&t.length){const n=e.extraConditions.map(s=>({campoId:s.when,operador:s.operator,valor:s.value,source:s.source})),a=[r,...n];return e.logicOperator==="or"?{or:a}:{and:a}}return r},$h=e=>{if("campoId"in e)return ks(e);const t=("and"in e?e.and:e.or)??[];if(t.length===0)return;const r="and"in e?"and":"or",[n,...a]=t;if(!("campoId"in n)){console.warn("[formSchemaToBuilder] Condicional com grupo aninhado detectada — não suportado no editor visual. A condicional será removida.",e);return}const s=ks(n);return a.length===0?s:{...s,logicOperator:r,extraConditions:a.filter(i=>"campoId"in i).map(ks)}},to=(e,t)=>{var r;if("campoId"in e){const n=(r=t[e.campoId])==null?void 0:r.name;return n?{...e,campoId:n}:e}return"and"in e&&Array.isArray(e.and)?{and:e.and.map(n=>to(n,t))}:"or"in e&&Array.isArray(e.or)?{or:e.or.map(n=>to(n,t))}:e},yl=(e,t,r)=>{var n,a;const s=l=>t[l]||{label:l,name:l},i=(((a=(n=e==null?void 0:e.containers)==null?void 0:n.root)==null?void 0:a.children)||[]).filter(l=>He(l)==="step").map((l,c)=>{var d,u;const m=s(l),p=(((u=(d=e==null?void 0:e.containers)==null?void 0:d[l])==null?void 0:u.children)||[]).filter(f=>He(f)==="container").map((f,b)=>{var h,x;const y=s(f),v=(((x=(h=e==null?void 0:e.containers)==null?void 0:h[f])==null?void 0:x.children)||[]).filter(w=>He(w)==="field").map((w,C)=>{var S,$;const k=s(w),E=li(k,w,C);if(E.condicional&&(E.condicional=to(E.condicional,t)),E.tipo===T.FIELD_ARRAY){const D=(($=(S=e==null?void 0:e.containers)==null?void 0:S[w])==null?void 0:$.children)??[];E.subFields=D.filter(O=>He(O)==="field").map((O,L)=>li(s(O),O,L))}return E}),j={id:f,titulo:y.label||"Container",descricao:y.description,icone:y.icone,ordem:b,colunas:y.columns||2,tamanho:y.tamanho||12,inicioColuna:y.inicioColuna,showLabel:y.showLabel,showAsCard:y.showAsCard,campos:v};return y.condition&&(j.condicional=to(Sh(y.condition),t)),j});return{id:l,titulo:m.label||"Step",descricao:m.description,icone:m.icone,ordem:c,showLabel:m.showLabel,containers:p}});return{id:r.id||"",nome:r.nome,descricao:r.descricao,status:r.status,template:r.template??null,stepConfig:r.stepConfig&&Object.keys(r.stepConfig).length>0?r.stepConfig:void 0,steps:i}},li=(e,t,r)=>{var n,a,s,i;const l={id:t,nome:e.name||t,label:e.label||"",tipo:e.fieldType||"texto",obrigatorio:e.required||!1,tamanho:e.tamanho||6,inicioColuna:e.inicioColuna,ordem:r,placeholder:e.placeholder,hint:e.hint,defaultValue:e.defaultValue,mascara:e.mascara,mascaraCustom:e.mascaraCustom,locked:e.locked||void 0,visualStyle:e.visualStyle,isReadOnly:e.isReadOnly||void 0,isDisabled:e.isDisabled||void 0,clearedValue:e.clearedValue!==void 0?e.clearedValue:void 0,initialValue:e.initialValue!==void 0?e.initialValue:void 0,resolvePropsKey:e.resolvePropsKey||void 0};if((n=e.validate)!=null&&n.length&&(l.validate=e.validate),(a=e.warn)!=null&&a.length&&(l.warn=e.warn),(s=e.options)!=null&&s.length&&(l.opcoes=e.options.map(c=>({valor:c.value,label:c.label,disabled:c.disabled}))),e.validation){const c=e.validation;l.validacao={},c.minLength!==void 0&&(l.validacao.minLength=c.minLength),c.maxLength!==void 0&&(l.validacao.maxLength=c.maxLength),c.min!==void 0&&(l.validacao.min=c.min),c.max!==void 0&&(l.validacao.max=c.max),c.regex&&(l.validacao.regex=c.regex),c.regexMessage&&(l.validacao.regexMessage=c.regexMessage),c.minDate&&(l.validacao.minDate=c.minDate),c.maxDate&&(l.validacao.maxDate=c.maxDate),c.minAge!==void 0&&(l.validacao.minAge=c.minAge),c.maxAge!==void 0&&(l.validacao.maxAge=c.maxAge),(i=c.fileTypes)!=null&&i.length&&(l.validacao.fileTypes=c.fileTypes),c.maxFileSize!==void 0&&(l.validacao.maxFileSize=c.maxFileSize)}if(l.tipo===T.FIELD_ARRAY&&(e.itemLabel&&(l.itemLabel=e.itemLabel),e.minItems!==void 0&&(l.minItems=e.minItems),e.maxItems!==void 0&&(l.maxItems=e.maxItems),e.addLabel&&(l.addLabel=e.addLabel)),l.tipo===T.TERMS&&(e.termoTexto&&(l.termoTexto=e.termoTexto),e.termoPdfUrl&&(l.termoPdfUrl=e.termoPdfUrl),e.termoPdfUploadId&&(l.termoPdfUploadId=e.termoPdfUploadId)),l.tipo===T.SLIDER&&(e.step!==void 0&&(l.step=e.step),e.minValue!==void 0&&(l.minValue=e.minValue),e.maxValue!==void 0&&(l.maxValue=e.maxValue)),l.tipo===T.RATING&&e.maxRating!==void 0&&(l.maxRating=e.maxRating),l.tipo===T.DATE_RANGE&&(e.dateRangeStartLabel&&(l.dateRangeStartLabel=e.dateRangeStartLabel),e.dateRangeEndLabel&&(l.dateRangeEndLabel=e.dateRangeEndLabel)),l.tipo===T.SUB_FORM){const c=e.subSchemaFields??[];(c.length>0||e.subSchemaTitle)&&(l.subSchema={titulo:e.subSchemaTitle,fields:c.map((d,u)=>li(d,d.name??`subfield-${u}`,u))})}return e.condition&&(l.condicional=Sh(e.condition)),l},Eh=e=>{const t={},r={root:{children:[]}},n=[...e.steps].sort((a,s)=>a.ordem-s.ordem);for(const a of n){const s=a.id||`step-${St()}`;r.root.children.push(s),t[s]={label:a.titulo,name:s,fieldType:"step",description:a.descricao,icone:a.icone,showLabel:a.showLabel};const i=[],l=[...a.containers].sort((c,d)=>c.ordem-d.ordem);for(const c of l){const d=c.id||`container-${St()}`;i.push(d);const u=c.condicional?$h(c.condicional):void 0;t[d]={label:c.titulo,name:d,fieldType:"container",description:c.descricao,icone:c.icone,columns:c.colunas,tamanho:c.tamanho||12,inicioColuna:c.inicioColuna,showLabel:c.showLabel,showAsCard:c.showAsCard,...u?{condition:u}:{}};const m=[],p=[...c.campos].sort((f,b)=>f.ordem-b.ordem);for(const f of p){const b=f.id||`${f.tipo}-${St()}`;if(m.push(b),t[b]=ci(f),f.tipo===T.FIELD_ARRAY){const h=[];for(const x of f.subFields??[]){const y=x.id||`${x.tipo}-${St()}`;h.push(y),t[y]=ci(x)}r[b]={children:h}}}r[d]={children:m}}r[s]={children:i}}return{dndState:{containers:r},configs:t,templateId:e.template??null,stepConfig:e.stepConfig}},ci=(e,t)=>{var r,n,a,s;const i={label:e.label,name:e.nome,fieldType:e.tipo,required:e.obrigatorio,tamanho:e.tamanho,inicioColuna:e.inicioColuna,placeholder:e.placeholder,hint:e.hint,defaultValue:e.defaultValue,mascara:e.mascara,mascaraCustom:e.mascaraCustom,locked:e.locked||void 0,visualStyle:e.visualStyle,isReadOnly:e.isReadOnly||void 0,isDisabled:e.isDisabled||void 0,clearedValue:e.clearedValue!==void 0?String(e.clearedValue??""):void 0,initialValue:e.initialValue!==void 0?String(e.initialValue):void 0,resolvePropsKey:e.resolvePropsKey||void 0,validate:(r=e.validate)!=null&&r.length?e.validate:void 0,warn:(n=e.warn)!=null&&n.length?e.warn:void 0};if((a=e.opcoes)!=null&&a.length&&(i.options=e.opcoes.map(l=>({value:l.valor,label:l.label,disabled:l.disabled}))),e.validacao){const l=e.validacao;i.validation={},l.minLength!==void 0&&(i.validation.minLength=l.minLength),l.maxLength!==void 0&&(i.validation.maxLength=l.maxLength),l.min!==void 0&&(i.validation.min=l.min),l.max!==void 0&&(i.validation.max=l.max),l.regex&&(i.validation.regex=l.regex),l.regexMessage&&(i.validation.regexMessage=l.regexMessage),l.minDate&&(i.validation.minDate=l.minDate),l.maxDate&&(i.validation.maxDate=l.maxDate),l.minAge!==void 0&&(i.validation.minAge=l.minAge),l.maxAge!==void 0&&(i.validation.maxAge=l.maxAge),(s=l.fileTypes)!=null&&s.length&&(i.validation.fileTypes=l.fileTypes),l.maxFileSize!==void 0&&(i.validation.maxFileSize=l.maxFileSize)}if(e.tipo===T.FIELD_ARRAY&&(e.itemLabel&&(i.itemLabel=e.itemLabel),e.minItems!==void 0&&(i.minItems=e.minItems),e.maxItems!==void 0&&(i.maxItems=e.maxItems),e.addLabel&&(i.addLabel=e.addLabel)),e.tipo===T.TERMS&&(e.termoTexto&&(i.termoTexto=e.termoTexto),e.termoPdfUrl&&(i.termoPdfUrl=e.termoPdfUrl),e.termoPdfUploadId&&(i.termoPdfUploadId=e.termoPdfUploadId)),e.tipo===T.SLIDER&&(e.step!==void 0&&(i.step=e.step),e.minValue!==void 0&&(i.minValue=e.minValue),e.maxValue!==void 0&&(i.maxValue=e.maxValue)),e.tipo===T.RATING&&e.maxRating!==void 0&&(i.maxRating=e.maxRating),e.tipo===T.DATE_RANGE&&(e.dateRangeStartLabel&&(i.dateRangeStartLabel=e.dateRangeStartLabel),e.dateRangeEndLabel&&(i.dateRangeEndLabel=e.dateRangeEndLabel)),e.tipo===T.SUB_FORM&&e.subSchema&&(i.subSchemaTitle=e.subSchema.titulo,i.subSchemaFields=e.subSchema.fields.map(l=>ci(l,l.id))),e.condicional){const l=$h(e.condicional);l&&(i.condition=l)}return i},Dh=(e,t)=>{var r,n,a,s,i,l,c,d,u,m,p;const f=[],b=[],h=v=>t[v]||{label:v,name:v},x=((n=(r=e==null?void 0:e.containers)==null?void 0:r.root)==null?void 0:n.children)||[],y=new Set;for(const v of x){if(He(v)!=="step")continue;const j=h(v).label||v,w=((s=(a=e==null?void 0:e.containers)==null?void 0:a[v])==null?void 0:s.children)||[];if(w.length===0){b.push(`Step "${j}" está vazio (sem containers).`);continue}for(const C of w){if(He(C)!=="container")continue;const S=h(C).label||C,$=((l=(i=e==null?void 0:e.containers)==null?void 0:i[C])==null?void 0:l.children)||[],k=new Map;for(const E of $){if(He(E)!=="field")continue;y.add(E);const D=h(E).name;(!D||!D.trim())&&f.push(`Campo "${h(E).label||E}" (${E}) no container "${S}" não tem nome definido.`);const O=D||E;k.has(O)||k.set(O,[]),k.get(O).push(E)}for(const[E,D]of k.entries())D.length>1&&f.push(`Nome duplicado "${E}" no container "${S}" (IDs: ${D.join(", ")}).`)}}for(const[v,j]of Object.entries(t)){if(!((c=j.condition)!=null&&c.when))continue;const w=j.condition.when;if(!y.has(w)){const C=j.label||v;b.push(`Campo "${C}" referencia campo inexistente na condição (when: "${w}").`)}}for(const v of x){if(He(v)!=="step")continue;const j=h(v).label||v,w=((u=(d=e==null?void 0:e.containers)==null?void 0:d[v])==null?void 0:u.children)||[],C=new Map;for(const S of w){if(He(S)!=="container")continue;const $=((p=(m=e==null?void 0:e.containers)==null?void 0:m[S])==null?void 0:p.children)||[];for(const k of $){if(He(k)!=="field")continue;const E=h(k).name||k;C.has(E)||C.set(E,new Set),C.get(E).add(S)}}for(const[S,$]of C.entries())$.size>1&&f.push(`Nome duplicado "${S}" no step "${j}" em containers diferentes (containers: ${[...$].join(", ")}). Isso causa colisão no formulário.`)}return{errors:f,warnings:b}},Th=N.createContext(null),Gk=e=>{if(e.startsWith("step"))return"step";if(e.startsWith("container"))return"container";const t=e.match(/^([a-z_]+)-/);return t?t[1]:e.split("-")[0]},Cs=(e,t)=>{const r=t||Gk(e),n=r==="step",a=r==="container",s=r==="field_array";return{label:n?"Novo Step":a?"Novo Container":s?"Lista de itens":r||e,name:e,fieldType:r||"texto",required:!1,columns:2,tamanho:a||s?12:n?void 0:6,showLabel:a?!0:void 0,itemLabel:s?"Item":void 0}},Ns=e=>typeof structuredClone=="function"?{containers:structuredClone(e.containers),configs:structuredClone(e.configs)}:{containers:JSON.parse(JSON.stringify(e.containers)),configs:JSON.parse(JSON.stringify(e.configs))},Ah=(e,t)=>{const r=[e],n=t[e];if(n!=null&&n.children)for(const a of n.children)r.push(...Ah(a,t));return r},wl=(e,t)=>{for(const[r,n]of Object.entries(t))if(n.children.includes(e))return r;return null},Rh=({children:e,initialConfigs:t,initialContainers:r,initialTemplateId:n,initialStepConfig:a,schemaId:s,uploadTermsPdf:i,deleteTermsPdf:l})=>{const[c,d]=N.useState({selectedId:null,configs:t||{},showPreview:!1,containers:r??{root:{children:[]}},previewTemplateId:n||"moderno",stepConfig:a??{}}),[u,m]=N.useState(null),[p,f]=N.useState(null),b=N.useRef([]),h=N.useRef([]),x=M=>{b.current=[...b.current.slice(-49),Ns(M)],h.current=[]},y=N.useCallback(()=>{d(M=>(x(M),{...M}))},[]),v=N.useCallback(()=>{b.current.length!==0&&d(M=>{h.current=[...h.current,Ns(M)];const P=b.current.pop();return{...M,containers:P.containers,configs:P.configs}})},[]),j=N.useCallback(()=>{h.current.length!==0&&d(M=>{b.current=[...b.current,Ns(M)];const P=h.current.pop();return{...M,containers:P.containers,configs:P.configs}})},[]);N.useEffect(()=>{const M=P=>{const se=P.metaKey||P.ctrlKey;se&&P.key==="z"&&!P.shiftKey&&(P.preventDefault(),v()),se&&P.key==="z"&&P.shiftKey&&(P.preventDefault(),j()),se&&P.key==="y"&&(P.preventDefault(),j())};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[v,j]);const w=N.useCallback(M=>c.configs[M]??Cs(M),[c.configs]),C=N.useCallback(()=>{const M=[],P=se=>{var U;const Q=((U=c.containers[se])==null?void 0:U.children)??[];for(const Y of Q)He(Y)==="field"?M.push(Y):c.containers[Y]&&P(Y)};return P("root"),M},[c.containers]),S=N.useCallback(M=>{d(P=>({...P,selectedId:M}))},[]),$=N.useCallback(M=>{d(P=>({...P,showPreview:M}))},[]),k=N.useCallback(M=>{d(P=>({...P,previewTemplateId:M}))},[]),E=N.useCallback(M=>{d(P=>({...P,stepConfig:{...P.stepConfig,...M}}))},[]),D=N.useCallback((M,P)=>{d(se=>({...se,configs:{...se.configs,[M]:{...se.configs[M]??Cs(M),...P}}}))},[]),O=N.useCallback((M,P,se)=>{const U=`${M}-${St()}`,Q=He(U);return d(Y=>{var H;x(Y);const W={...Y.containers};(Q==="step"||Q==="container"||M==="field_array")&&(W[U]={children:[]});const G=[...((H=W[P])==null?void 0:H.children)??[]];return se!==void 0&&se>=0?G.splice(se,0,U):G.push(U),W[P]={children:G},{...Y,containers:W,configs:{...Y.configs,[U]:Cs(U,M)},selectedId:U}}),U},[]),L=N.useCallback((M,P)=>{const se=`container-${St()}`;return d(U=>{var Q,Y,H;x(U);const W={...U.containers},G={...U.configs},ne=[];for(const te of M.containerTemplate.campos){const ce=te.locked&&te.id?te.id:`${String(te.tipo).toLowerCase()}-${St()}`;if(ne.push(ce),G[ce]={label:te.label,name:te.locked?te.id:te.nome,fieldType:te.tipo,required:te.obrigatorio||!1,placeholder:te.placeholder,hint:te.hint,tamanho:te.tamanho||6,inicioColuna:te.inicioColuna,defaultValue:te.defaultValue!=null?String(te.defaultValue):void 0,locked:te.locked||!1,options:(Q=te.opcoes)==null?void 0:Q.map(be=>({value:be.valor,label:be.label})),...te.tipo==="field_array"&&{itemLabel:te.itemLabel,minItems:te.minItems,maxItems:te.maxItems,addLabel:te.addLabel}},te.tipo==="field_array"){const be=[];for(const Ce of te.subFields??[]){const ve=`${String(Ce.tipo).toLowerCase()}-${St()}`;be.push(ve),G[ve]={label:Ce.label,name:Ce.nome,fieldType:Ce.tipo,required:Ce.obrigatorio||!1,placeholder:Ce.placeholder,hint:Ce.hint,tamanho:Ce.tamanho||6,inicioColuna:Ce.inicioColuna,options:(Y=Ce.opcoes)==null?void 0:Y.map(me=>({value:me.valor,label:me.label}))}}W[ce]={children:be}}}W[se]={children:ne},G[se]={label:M.containerTemplate.titulo||M.name,description:M.containerTemplate.descricao,icone:M.containerTemplate.icone,tamanho:M.containerTemplate.tamanho||12,inicioColuna:M.containerTemplate.inicioColuna,showLabel:!0};const J=[...((H=W[P])==null?void 0:H.children)??[]];return J.push(se),W[P]={children:J},{...U,containers:W,configs:G,selectedId:se}}),se},[]),A=N.useCallback(M=>{const P=[];return d(se=>{var U,Q,Y;x(se);const H={...se.containers},W={...se.configs};for(const G of M.steps){const ne=`step-${St()}`;P.push(ne);const J=[];for(const ce of G.containers){const be=`container-${St()}`;J.push(be);const Ce=[];for(const ve of ce.campos){const me=ve.locked&&ve.id?ve.id:`${String(ve.tipo).toLowerCase()}-${St()}`;if(Ce.push(me),W[me]={label:ve.label,name:ve.locked?ve.id:ve.nome,fieldType:ve.tipo,required:ve.obrigatorio||!1,placeholder:ve.placeholder,hint:ve.hint,tamanho:ve.tamanho||12,inicioColuna:ve.inicioColuna,defaultValue:ve.defaultValue!=null?String(ve.defaultValue):void 0,locked:ve.locked||!1,options:(U=ve.opcoes)==null?void 0:U.map(Ee=>({value:Ee.valor,label:Ee.label})),...ve.tipo==="field_array"&&{itemLabel:ve.itemLabel,minItems:ve.minItems,maxItems:ve.maxItems,addLabel:ve.addLabel}},ve.tipo==="field_array"){const Ee=[];for(const Fe of ve.subFields??[]){const Nt=`${String(Fe.tipo).toLowerCase()}-${St()}`;Ee.push(Nt),W[Nt]={label:Fe.label,name:Fe.nome,fieldType:Fe.tipo,required:Fe.obrigatorio||!1,placeholder:Fe.placeholder,hint:Fe.hint,tamanho:Fe.tamanho||6,inicioColuna:Fe.inicioColuna,options:(Q=Fe.opcoes)==null?void 0:Q.map(dt=>({value:dt.valor,label:dt.label}))}}H[me]={children:Ee}}}H[be]={children:Ce},W[be]={label:ce.titulo,description:ce.descricao,icone:ce.icone,tamanho:ce.tamanho||12,showLabel:!0}}H[ne]={children:J},W[ne]={label:G.titulo,description:G.descricao,icone:G.icone};const te=[...((Y=H.root)==null?void 0:Y.children)??[],ne];H.root={children:te}}return{...se,containers:H,configs:W,selectedId:P[0]??se.selectedId}}),P},[]),z=N.useCallback((M,P,se,U)=>{d(Q=>{var Y,H;x(Q);const W={...Q.containers},G=(((Y=W[P])==null?void 0:Y.children)??[]).filter(te=>te!==M);W[P]={children:G};const ne=[...(((H=W[se])==null?void 0:H.children)??[]).filter(te=>te!==M)],J=Math.max(0,Math.min(U,ne.length));return ne.splice(J,0,M),W[se]={children:ne},{...Q,containers:W}})},[]),X=N.useCallback((M,P)=>{d(se=>(x(se),{...se,containers:{...se.containers,[M]:{children:P}}}))},[]),q=N.useCallback(M=>{d(P=>{x(P);const se=Ah(M,P.containers),U={};for(const[Y,H]of Object.entries(P.containers))se.includes(Y)||(U[Y]={children:H.children.filter(W=>!se.includes(W))});const Q={...P.configs};for(const Y of se)delete Q[Y];return{...P,containers:U,configs:Q,selectedId:se.includes(P.selectedId??"")?null:P.selectedId}})},[]),Z=N.useCallback((M,P)=>{d(se=>{const U=wl(M,se.containers);if(!U)return se;const Q=[...se.containers[U].children],Y=Q.indexOf(M),H=P==="up"?Y-1:Y+1;return H<0||H>=Q.length?se:([Q[Y],Q[H]]=[Q[H],Q[Y]],{...se,containers:{...se.containers,[U]:{children:Q}}})})},[]),V=N.useCallback((M,P)=>{y(),Z(M,P)},[Z,y]);return o.jsx(Th.Provider,{value:{selectedId:c.selectedId,configs:c.configs,showPreview:c.showPreview,containers:c.containers,positionDrag:u,reorderDrag:p,canUndo:b.current.length>0,canRedo:h.current.length>0,schemaId:s,uploadTermsPdf:i,deleteTermsPdf:l,previewTemplateId:c.previewTemplateId,setPreviewTemplateId:k,stepConfig:c.stepConfig,updateStepConfig:E,getConfig:w,getAllFieldIds:C,setSelected:S,updateConfig:D,setShowPreview:$,addItem:O,addPresetBlock:L,addPresetStepBlock:A,moveCanvasItem:z,reorderInContainer:X,removeItem:q,moveItem:V,moveItemNoSnapshot:Z,setPositionDrag:m,setReorderDrag:f,undo:v,redo:j,pushSnapshot:y},children:e})},gt=()=>{const e=N.useContext(Th);if(!e)throw new Error("useBuilder must be inside BuilderProvider");return e},Xk=()=>{const{containers:e,configs:t,stepConfig:r}=gt(),n=N.useCallback(s=>yl({containers:e},t,{...s,stepConfig:r}),[e,t,r]),a=N.useCallback(()=>Dh({containers:e},t),[e,t]);return{buildSchema:n,validate:a}};function Ih(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(r=Ih(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function Zk(){for(var e,t,r=0,n="",a=arguments.length;r<a;r++)(e=arguments[r])&&(t=Ih(e))&&(n&&(n+=" "),n+=t);return n}const Kk=(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},Yk=(e,t)=>({classGroupId:e,validator:t}),Ph=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),ro="-",id=[],Jk="arbitrary..",Qk=e=>{const t=tC(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:a=>{if(a.startsWith("[")&&a.endsWith("]"))return eC(a);const s=a.split(ro),i=s[0]===""&&s.length>1?1:0;return _h(s,i,t)},getConflictingClassGroupIds:(a,s)=>{if(s){const i=n[a],l=r[a];return i?l?Kk(l,i):i:l||id}return r[a]||id}}},_h=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const n=e[t],a=r.nextPart.get(n);if(a){const c=_h(e,t+1,a);if(c)return c}const s=r.validators;if(s===null)return;const i=t===0?e.join(ro):e.slice(t).join(ro),l=s.length;for(let c=0;c<l;c++){const d=s[c];if(d.validator(i))return d.classGroupId}},eC=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?Jk+n:void 0})(),tC=e=>{const{theme:t,classGroups:r}=e;return rC(r,t)},rC=(e,t)=>{const r=Ph();for(const n in e){const a=e[n];jl(a,r,n,t)}return r},jl=(e,t,r,n)=>{const a=e.length;for(let s=0;s<a;s++){const i=e[s];nC(i,t,r,n)}},nC=(e,t,r,n)=>{if(typeof e=="string"){aC(e,t,r);return}if(typeof e=="function"){oC(e,t,r,n);return}sC(e,t,r,n)},aC=(e,t,r)=>{const n=e===""?t:Oh(t,e);n.classGroupId=r},oC=(e,t,r,n)=>{if(iC(e)){jl(e(n),t,r,n);return}t.validators===null&&(t.validators=[]),t.validators.push(Yk(r,e))},sC=(e,t,r,n)=>{const a=Object.entries(e),s=a.length;for(let i=0;i<s;i++){const[l,c]=a[i];jl(c,Oh(t,l),r,n)}},Oh=(e,t)=>{let r=e;const n=t.split(ro),a=n.length;for(let s=0;s<a;s++){const i=n[s];let l=r.nextPart.get(i);l||(l=Ph(),r.nextPart.set(i,l)),r=l}return r},iC=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,lC=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=Object.create(null),n=Object.create(null);const a=(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 a(s,i),i},set(s,i){s in r?r[s]=i:a(s,i)}}},di="!",ld=":",cC=[],cd=(e,t,r,n,a)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:n,isExternal:a}),dC=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=a=>{const s=[];let i=0,l=0,c=0,d;const u=a.length;for(let h=0;h<u;h++){const x=a[h];if(i===0&&l===0){if(x===ld){s.push(a.slice(c,h)),c=h+1;continue}if(x==="/"){d=h;continue}}x==="["?i++:x==="]"?i--:x==="("?l++:x===")"&&l--}const m=s.length===0?a:a.slice(c);let p=m,f=!1;m.endsWith(di)?(p=m.slice(0,-1),f=!0):m.startsWith(di)&&(p=m.slice(1),f=!0);const b=d&&d>c?d-c:void 0;return cd(s,f,p,b)};if(t){const a=t+ld,s=n;n=i=>i.startsWith(a)?s(i.slice(a.length)):cd(cC,!1,i,void 0,!0)}if(r){const a=n;n=s=>r({className:s,parseClassName:a})}return n},uC=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((r,n)=>{t.set(r,1e6+n)}),r=>{const n=[];let a=[];for(let s=0;s<r.length;s++){const i=r[s],l=i[0]==="[",c=t.has(i);l||c?(a.length>0&&(a.sort(),n.push(...a),a=[]),n.push(i)):a.push(i)}return a.length>0&&(a.sort(),n.push(...a)),n}},mC=e=>({cache:lC(e.cacheSize),parseClassName:dC(e),sortModifiers:uC(e),...Qk(e)}),pC=/\s+/,fC=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a,sortModifiers:s}=t,i=[],l=e.trim().split(pC);let c="";for(let d=l.length-1;d>=0;d-=1){const u=l[d],{isExternal:m,modifiers:p,hasImportantModifier:f,baseClassName:b,maybePostfixModifierPosition:h}=r(u);if(m){c=u+(c.length>0?" "+c:c);continue}let x=!!h,y=n(x?b.substring(0,h):b);if(!y){if(!x){c=u+(c.length>0?" "+c:c);continue}if(y=n(b),!y){c=u+(c.length>0?" "+c:c);continue}x=!1}const v=p.length===0?"":p.length===1?p[0]:s(p).join(":"),j=f?v+di:v,w=j+y;if(i.indexOf(w)>-1)continue;i.push(w);const C=a(y,x);for(let S=0;S<C.length;++S){const $=C[S];i.push(j+$)}c=u+(c.length>0?" "+c:c)}return c},hC=(...e)=>{let t=0,r,n,a="";for(;t<e.length;)(r=e[t++])&&(n=Fh(r))&&(a&&(a+=" "),a+=n);return a},Fh=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=Fh(e[n]))&&(r&&(r+=" "),r+=t);return r},xC=(e,...t)=>{let r,n,a,s;const i=c=>{const d=t.reduce((u,m)=>m(u),e());return r=mC(d),n=r.cache.get,a=r.cache.set,s=l,l(c)},l=c=>{const d=n(c);if(d)return d;const u=fC(c,r);return a(c,u),u};return s=i,(...c)=>s(hC(...c))},gC=[],nt=e=>{const t=r=>r[e]||gC;return t.isThemeGetter=!0,t},zh=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Lh=/^\((?:(\w[\w-]*):)?(.+)\)$/i,vC=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,bC=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,yC=/\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$/,wC=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,jC=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,kC=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Er=e=>vC.test(e),Se=e=>!!e&&!Number.isNaN(Number(e)),Dr=e=>!!e&&Number.isInteger(Number(e)),Ss=e=>e.endsWith("%")&&Se(e.slice(0,-1)),xr=e=>bC.test(e),Mh=()=>!0,CC=e=>yC.test(e)&&!wC.test(e),kl=()=>!1,NC=e=>jC.test(e),SC=e=>kC.test(e),$C=e=>!fe(e)&&!xe(e),EC=e=>Ur(e,Uh,kl),fe=e=>zh.test(e),Xr=e=>Ur(e,Hh,CC),dd=e=>Ur(e,OC,Se),DC=e=>Ur(e,qh,Mh),TC=e=>Ur(e,Wh,kl),ud=e=>Ur(e,Vh,kl),AC=e=>Ur(e,Bh,SC),Ia=e=>Ur(e,Gh,NC),xe=e=>Lh.test(e),qn=e=>on(e,Hh),RC=e=>on(e,Wh),md=e=>on(e,Vh),IC=e=>on(e,Uh),PC=e=>on(e,Bh),Pa=e=>on(e,Gh,!0),_C=e=>on(e,qh,!0),Ur=(e,t,r)=>{const n=zh.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},on=(e,t,r=!1)=>{const n=Lh.exec(e);return n?n[1]?t(n[1]):r:!1},Vh=e=>e==="position"||e==="percentage",Bh=e=>e==="image"||e==="url",Uh=e=>e==="length"||e==="size"||e==="bg-size",Hh=e=>e==="length",OC=e=>e==="number",Wh=e=>e==="family-name",qh=e=>e==="number"||e==="weight",Gh=e=>e==="shadow",FC=()=>{const e=nt("color"),t=nt("font"),r=nt("text"),n=nt("font-weight"),a=nt("tracking"),s=nt("leading"),i=nt("breakpoint"),l=nt("container"),c=nt("spacing"),d=nt("radius"),u=nt("shadow"),m=nt("inset-shadow"),p=nt("text-shadow"),f=nt("drop-shadow"),b=nt("blur"),h=nt("perspective"),x=nt("aspect"),y=nt("ease"),v=nt("animate"),j=()=>["auto","avoid","all","avoid-page","page","left","right","column"],w=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],C=()=>[...w(),xe,fe],S=()=>["auto","hidden","clip","visible","scroll"],$=()=>["auto","contain","none"],k=()=>[xe,fe,c],E=()=>[Er,"full","auto",...k()],D=()=>[Dr,"none","subgrid",xe,fe],O=()=>["auto",{span:["full",Dr,xe,fe]},Dr,xe,fe],L=()=>[Dr,"auto",xe,fe],A=()=>["auto","min","max","fr",xe,fe],z=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],X=()=>["start","end","center","stretch","center-safe","end-safe"],q=()=>["auto",...k()],Z=()=>[Er,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...k()],V=()=>[Er,"screen","full","dvw","lvw","svw","min","max","fit",...k()],M=()=>[Er,"screen","full","lh","dvh","lvh","svh","min","max","fit",...k()],P=()=>[e,xe,fe],se=()=>[...w(),md,ud,{position:[xe,fe]}],U=()=>["no-repeat",{repeat:["","x","y","space","round"]}],Q=()=>["auto","cover","contain",IC,EC,{size:[xe,fe]}],Y=()=>[Ss,qn,Xr],H=()=>["","none","full",d,xe,fe],W=()=>["",Se,qn,Xr],G=()=>["solid","dashed","dotted","double"],ne=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],J=()=>[Se,Ss,md,ud],te=()=>["","none",b,xe,fe],ce=()=>["none",Se,xe,fe],be=()=>["none",Se,xe,fe],Ce=()=>[Se,xe,fe],ve=()=>[Er,"full",...k()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[xr],breakpoint:[xr],color:[Mh],container:[xr],"drop-shadow":[xr],ease:["in","out","in-out"],font:[$C],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[xr],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[xr],shadow:[xr],spacing:["px",Se],text:[xr],"text-shadow":[xr],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Er,fe,xe,x]}],container:["container"],columns:[{columns:[Se,fe,xe,l]}],"break-after":[{"break-after":j()}],"break-before":[{"break-before":j()}],"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:C()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:$()}],"overscroll-x":[{"overscroll-x":$()}],"overscroll-y":[{"overscroll-y":$()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:E()}],"inset-x":[{"inset-x":E()}],"inset-y":[{"inset-y":E()}],start:[{"inset-s":E(),start:E()}],end:[{"inset-e":E(),end:E()}],"inset-bs":[{"inset-bs":E()}],"inset-be":[{"inset-be":E()}],top:[{top:E()}],right:[{right:E()}],bottom:[{bottom:E()}],left:[{left:E()}],visibility:["visible","invisible","collapse"],z:[{z:[Dr,"auto",xe,fe]}],basis:[{basis:[Er,"full","auto",l,...k()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Se,Er,"auto","initial","none",fe]}],grow:[{grow:["",Se,xe,fe]}],shrink:[{shrink:["",Se,xe,fe]}],order:[{order:[Dr,"first","last","none",xe,fe]}],"grid-cols":[{"grid-cols":D()}],"col-start-end":[{col:O()}],"col-start":[{"col-start":L()}],"col-end":[{"col-end":L()}],"grid-rows":[{"grid-rows":D()}],"row-start-end":[{row:O()}],"row-start":[{"row-start":L()}],"row-end":[{"row-end":L()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":A()}],"auto-rows":[{"auto-rows":A()}],gap:[{gap:k()}],"gap-x":[{"gap-x":k()}],"gap-y":[{"gap-y":k()}],"justify-content":[{justify:[...z(),"normal"]}],"justify-items":[{"justify-items":[...X(),"normal"]}],"justify-self":[{"justify-self":["auto",...X()]}],"align-content":[{content:["normal",...z()]}],"align-items":[{items:[...X(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...X(),{baseline:["","last"]}]}],"place-content":[{"place-content":z()}],"place-items":[{"place-items":[...X(),"baseline"]}],"place-self":[{"place-self":["auto",...X()]}],p:[{p:k()}],px:[{px:k()}],py:[{py:k()}],ps:[{ps:k()}],pe:[{pe:k()}],pbs:[{pbs:k()}],pbe:[{pbe:k()}],pt:[{pt:k()}],pr:[{pr:k()}],pb:[{pb:k()}],pl:[{pl:k()}],m:[{m:q()}],mx:[{mx:q()}],my:[{my:q()}],ms:[{ms:q()}],me:[{me:q()}],mbs:[{mbs:q()}],mbe:[{mbe:q()}],mt:[{mt:q()}],mr:[{mr:q()}],mb:[{mb:q()}],ml:[{ml:q()}],"space-x":[{"space-x":k()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":k()}],"space-y-reverse":["space-y-reverse"],size:[{size:Z()}],"inline-size":[{inline:["auto",...V()]}],"min-inline-size":[{"min-inline":["auto",...V()]}],"max-inline-size":[{"max-inline":["none",...V()]}],"block-size":[{block:["auto",...M()]}],"min-block-size":[{"min-block":["auto",...M()]}],"max-block-size":[{"max-block":["none",...M()]}],w:[{w:[l,"screen",...Z()]}],"min-w":[{"min-w":[l,"screen","none",...Z()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[i]},...Z()]}],h:[{h:["screen","lh",...Z()]}],"min-h":[{"min-h":["screen","lh","none",...Z()]}],"max-h":[{"max-h":["screen","lh",...Z()]}],"font-size":[{text:["base",r,qn,Xr]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,_C,DC]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ss,fe]}],"font-family":[{font:[RC,TC,t]}],"font-features":[{"font-features":[fe]}],"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:[a,xe,fe]}],"line-clamp":[{"line-clamp":[Se,"none",xe,dd]}],leading:[{leading:[s,...k()]}],"list-image":[{"list-image":["none",xe,fe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",xe,fe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:P()}],"text-color":[{text:P()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...G(),"wavy"]}],"text-decoration-thickness":[{decoration:[Se,"from-font","auto",xe,Xr]}],"text-decoration-color":[{decoration:P()}],"underline-offset":[{"underline-offset":[Se,"auto",xe,fe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:k()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",xe,fe]}],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",xe,fe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:se()}],"bg-repeat":[{bg:U()}],"bg-size":[{bg:Q()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Dr,xe,fe],radial:["",xe,fe],conic:[Dr,xe,fe]},PC,AC]}],"bg-color":[{bg:P()}],"gradient-from-pos":[{from:Y()}],"gradient-via-pos":[{via:Y()}],"gradient-to-pos":[{to:Y()}],"gradient-from":[{from:P()}],"gradient-via":[{via:P()}],"gradient-to":[{to:P()}],rounded:[{rounded:H()}],"rounded-s":[{"rounded-s":H()}],"rounded-e":[{"rounded-e":H()}],"rounded-t":[{"rounded-t":H()}],"rounded-r":[{"rounded-r":H()}],"rounded-b":[{"rounded-b":H()}],"rounded-l":[{"rounded-l":H()}],"rounded-ss":[{"rounded-ss":H()}],"rounded-se":[{"rounded-se":H()}],"rounded-ee":[{"rounded-ee":H()}],"rounded-es":[{"rounded-es":H()}],"rounded-tl":[{"rounded-tl":H()}],"rounded-tr":[{"rounded-tr":H()}],"rounded-br":[{"rounded-br":H()}],"rounded-bl":[{"rounded-bl":H()}],"border-w":[{border:W()}],"border-w-x":[{"border-x":W()}],"border-w-y":[{"border-y":W()}],"border-w-s":[{"border-s":W()}],"border-w-e":[{"border-e":W()}],"border-w-bs":[{"border-bs":W()}],"border-w-be":[{"border-be":W()}],"border-w-t":[{"border-t":W()}],"border-w-r":[{"border-r":W()}],"border-w-b":[{"border-b":W()}],"border-w-l":[{"border-l":W()}],"divide-x":[{"divide-x":W()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":W()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...G(),"hidden","none"]}],"divide-style":[{divide:[...G(),"hidden","none"]}],"border-color":[{border:P()}],"border-color-x":[{"border-x":P()}],"border-color-y":[{"border-y":P()}],"border-color-s":[{"border-s":P()}],"border-color-e":[{"border-e":P()}],"border-color-bs":[{"border-bs":P()}],"border-color-be":[{"border-be":P()}],"border-color-t":[{"border-t":P()}],"border-color-r":[{"border-r":P()}],"border-color-b":[{"border-b":P()}],"border-color-l":[{"border-l":P()}],"divide-color":[{divide:P()}],"outline-style":[{outline:[...G(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Se,xe,fe]}],"outline-w":[{outline:["",Se,qn,Xr]}],"outline-color":[{outline:P()}],shadow:[{shadow:["","none",u,Pa,Ia]}],"shadow-color":[{shadow:P()}],"inset-shadow":[{"inset-shadow":["none",m,Pa,Ia]}],"inset-shadow-color":[{"inset-shadow":P()}],"ring-w":[{ring:W()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:P()}],"ring-offset-w":[{"ring-offset":[Se,Xr]}],"ring-offset-color":[{"ring-offset":P()}],"inset-ring-w":[{"inset-ring":W()}],"inset-ring-color":[{"inset-ring":P()}],"text-shadow":[{"text-shadow":["none",p,Pa,Ia]}],"text-shadow-color":[{"text-shadow":P()}],opacity:[{opacity:[Se,xe,fe]}],"mix-blend":[{"mix-blend":[...ne(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ne()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Se]}],"mask-image-linear-from-pos":[{"mask-linear-from":J()}],"mask-image-linear-to-pos":[{"mask-linear-to":J()}],"mask-image-linear-from-color":[{"mask-linear-from":P()}],"mask-image-linear-to-color":[{"mask-linear-to":P()}],"mask-image-t-from-pos":[{"mask-t-from":J()}],"mask-image-t-to-pos":[{"mask-t-to":J()}],"mask-image-t-from-color":[{"mask-t-from":P()}],"mask-image-t-to-color":[{"mask-t-to":P()}],"mask-image-r-from-pos":[{"mask-r-from":J()}],"mask-image-r-to-pos":[{"mask-r-to":J()}],"mask-image-r-from-color":[{"mask-r-from":P()}],"mask-image-r-to-color":[{"mask-r-to":P()}],"mask-image-b-from-pos":[{"mask-b-from":J()}],"mask-image-b-to-pos":[{"mask-b-to":J()}],"mask-image-b-from-color":[{"mask-b-from":P()}],"mask-image-b-to-color":[{"mask-b-to":P()}],"mask-image-l-from-pos":[{"mask-l-from":J()}],"mask-image-l-to-pos":[{"mask-l-to":J()}],"mask-image-l-from-color":[{"mask-l-from":P()}],"mask-image-l-to-color":[{"mask-l-to":P()}],"mask-image-x-from-pos":[{"mask-x-from":J()}],"mask-image-x-to-pos":[{"mask-x-to":J()}],"mask-image-x-from-color":[{"mask-x-from":P()}],"mask-image-x-to-color":[{"mask-x-to":P()}],"mask-image-y-from-pos":[{"mask-y-from":J()}],"mask-image-y-to-pos":[{"mask-y-to":J()}],"mask-image-y-from-color":[{"mask-y-from":P()}],"mask-image-y-to-color":[{"mask-y-to":P()}],"mask-image-radial":[{"mask-radial":[xe,fe]}],"mask-image-radial-from-pos":[{"mask-radial-from":J()}],"mask-image-radial-to-pos":[{"mask-radial-to":J()}],"mask-image-radial-from-color":[{"mask-radial-from":P()}],"mask-image-radial-to-color":[{"mask-radial-to":P()}],"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":w()}],"mask-image-conic-pos":[{"mask-conic":[Se]}],"mask-image-conic-from-pos":[{"mask-conic-from":J()}],"mask-image-conic-to-pos":[{"mask-conic-to":J()}],"mask-image-conic-from-color":[{"mask-conic-from":P()}],"mask-image-conic-to-color":[{"mask-conic-to":P()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:se()}],"mask-repeat":[{mask:U()}],"mask-size":[{mask:Q()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",xe,fe]}],filter:[{filter:["","none",xe,fe]}],blur:[{blur:te()}],brightness:[{brightness:[Se,xe,fe]}],contrast:[{contrast:[Se,xe,fe]}],"drop-shadow":[{"drop-shadow":["","none",f,Pa,Ia]}],"drop-shadow-color":[{"drop-shadow":P()}],grayscale:[{grayscale:["",Se,xe,fe]}],"hue-rotate":[{"hue-rotate":[Se,xe,fe]}],invert:[{invert:["",Se,xe,fe]}],saturate:[{saturate:[Se,xe,fe]}],sepia:[{sepia:["",Se,xe,fe]}],"backdrop-filter":[{"backdrop-filter":["","none",xe,fe]}],"backdrop-blur":[{"backdrop-blur":te()}],"backdrop-brightness":[{"backdrop-brightness":[Se,xe,fe]}],"backdrop-contrast":[{"backdrop-contrast":[Se,xe,fe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Se,xe,fe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Se,xe,fe]}],"backdrop-invert":[{"backdrop-invert":["",Se,xe,fe]}],"backdrop-opacity":[{"backdrop-opacity":[Se,xe,fe]}],"backdrop-saturate":[{"backdrop-saturate":[Se,xe,fe]}],"backdrop-sepia":[{"backdrop-sepia":["",Se,xe,fe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":k()}],"border-spacing-x":[{"border-spacing-x":k()}],"border-spacing-y":[{"border-spacing-y":k()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",xe,fe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Se,"initial",xe,fe]}],ease:[{ease:["linear","initial",y,xe,fe]}],delay:[{delay:[Se,xe,fe]}],animate:[{animate:["none",v,xe,fe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[h,xe,fe]}],"perspective-origin":[{"perspective-origin":C()}],rotate:[{rotate:ce()}],"rotate-x":[{"rotate-x":ce()}],"rotate-y":[{"rotate-y":ce()}],"rotate-z":[{"rotate-z":ce()}],scale:[{scale:be()}],"scale-x":[{"scale-x":be()}],"scale-y":[{"scale-y":be()}],"scale-z":[{"scale-z":be()}],"scale-3d":["scale-3d"],skew:[{skew:Ce()}],"skew-x":[{"skew-x":Ce()}],"skew-y":[{"skew-y":Ce()}],transform:[{transform:[xe,fe,"","none","gpu","cpu"]}],"transform-origin":[{origin:C()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ve()}],"translate-x":[{"translate-x":ve()}],"translate-y":[{"translate-y":ve()}],"translate-z":[{"translate-z":ve()}],"translate-none":["translate-none"],accent:[{accent:P()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:P()}],"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",xe,fe]}],"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":k()}],"scroll-mx":[{"scroll-mx":k()}],"scroll-my":[{"scroll-my":k()}],"scroll-ms":[{"scroll-ms":k()}],"scroll-me":[{"scroll-me":k()}],"scroll-mbs":[{"scroll-mbs":k()}],"scroll-mbe":[{"scroll-mbe":k()}],"scroll-mt":[{"scroll-mt":k()}],"scroll-mr":[{"scroll-mr":k()}],"scroll-mb":[{"scroll-mb":k()}],"scroll-ml":[{"scroll-ml":k()}],"scroll-p":[{"scroll-p":k()}],"scroll-px":[{"scroll-px":k()}],"scroll-py":[{"scroll-py":k()}],"scroll-ps":[{"scroll-ps":k()}],"scroll-pe":[{"scroll-pe":k()}],"scroll-pbs":[{"scroll-pbs":k()}],"scroll-pbe":[{"scroll-pbe":k()}],"scroll-pt":[{"scroll-pt":k()}],"scroll-pr":[{"scroll-pr":k()}],"scroll-pb":[{"scroll-pb":k()}],"scroll-pl":[{"scroll-pl":k()}],"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",xe,fe]}],fill:[{fill:["none",...P()]}],"stroke-w":[{stroke:[Se,qn,Xr,dd]}],stroke:[{stroke:["none",...P()]}],"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"]}},zC=xC(FC);function Ht(...e){return zC(Zk(e))}const yr=({onInsert:e})=>{const[t,r]=N.useState(null),n=async a=>{const s=`{{${a}}}`;try{await navigator.clipboard.writeText(s)}catch{const i=document.createElement("textarea");i.value=s,i.style.position="fixed",i.style.opacity="0",document.body.appendChild(i),i.select(),document.execCommand("copy"),document.body.removeChild(i)}e&&e(s),r(a),setTimeout(()=>r(null),1500)};return o.jsxs(Po,{children:[o.jsx(_o,{asChild:!0,children:o.jsx(De,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 text-muted-foreground hover:text-primary",title:"Inserir variável do evento",children:o.jsx(_.Braces,{className:"h-3.5 w-3.5"})})}),o.jsxs(fa,{className:"w-80 p-0",align:"end",side:"left",sideOffset:6,children:[o.jsxs("div",{className:"px-3 py-2 border-b border-border",children:[o.jsx("p",{className:"text-xs font-semibold text-foreground",children:"Variáveis do evento"}),o.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Clique para copiar. Use"," ",o.jsx("code",{className:"bg-muted px-1 rounded text-[10px]",children:"{{evento.xxx}}"})," ","em labels, placeholders e hints."]})]}),o.jsx("div",{className:"max-h-64 overflow-y-auto py-1",children:bl.map(a=>{const s=t===a.key;return o.jsxs("button",{type:"button",onClick:()=>n(a.key),className:Ht("w-full flex items-center justify-between px-3 py-1.5 text-left hover:bg-accent transition-colors",s&&"bg-primary/10"),children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx("p",{className:"text-xs font-medium truncate",children:a.label}),o.jsx("code",{className:"text-[10px] text-muted-foreground font-mono",children:`{{${a.key}}}`})]}),o.jsx("div",{className:"ml-2 shrink-0",children:s?o.jsx(_.Check,{className:"h-3.5 w-3.5 text-primary"}):o.jsx(_.Braces,{className:"h-3 w-3 text-muted-foreground/50"})})]},a.key)})})]})]})},LC=({config:e,onUpdate:t})=>o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(ie,{className:"text-xs",children:"Label"}),o.jsx(yr,{})]}),o.jsx(ue,{value:e.label,onChange:r=>t({label:r.target.value}),className:"h-8 text-sm"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(ie,{className:"text-xs",children:"Descrição"}),o.jsx(yr,{})]}),o.jsx(ue,{value:e.description||"",onChange:r=>t({description:r.target.value}),className:"h-8 text-sm",placeholder:"Descrição do step"})]}),o.jsx(Jf,{value:e.icone,onChange:r=>t({icone:r})}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(et,{id:"step-show-label",checked:e.showLabel!==!1,onCheckedChange:r=>t({showLabel:r===!0})}),o.jsx(ie,{htmlFor:"step-show-label",className:"text-xs cursor-pointer",children:"Exibir título no formulário"})]})]}),MC=({inicioColuna:e,tamanho:t,onSelect:r})=>o.jsxs("div",{className:"space-y-2",children:[o.jsx(ie,{className:"text-xs",children:"Posição no grid"}),o.jsx("div",{className:"flex gap-0.5",children:Array.from({length:12},(n,a)=>{const s=a+1,i=s>=e&&s<e+t;return o.jsx("button",{onClick:()=>r(s),className:Ht("flex-1 h-6 rounded-sm text-[8px] font-mono transition-all border",i?"bg-primary text-primary-foreground border-primary":"bg-muted/50 text-muted-foreground/50 border-border/50 hover:bg-muted hover:border-border"),children:s},s)})}),o.jsxs("p",{className:"text-[9px] text-muted-foreground",children:["Início: col ",e," · Span: ",t]})]}),Xh=({tamanho:e,inicioColuna:t,defaultTamanho:r=6,onTamanhoChange:n,onPositionChange:a})=>{const s=13-t;return o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsxs(ie,{className:"text-xs",children:["Tamanho (",e,"/12 colunas)"]}),o.jsx(Ao,{value:[e],onValueChange:([i])=>{const l=Math.min(i,s);n(l)},min:1,max:s,step:1,className:"py-1"}),o.jsxs("div",{className:"flex justify-between text-[9px] text-muted-foreground",children:[o.jsx("span",{children:"1"}),o.jsx("span",{children:"3"}),o.jsx("span",{children:"6"}),o.jsx("span",{children:"9"}),o.jsx("span",{children:"12"})]})]}),o.jsx(MC,{inicioColuna:t,tamanho:e,onSelect:i=>{const l=13-i,c=Math.min(e,l);a(i),c!==e&&n(c)}})]})},VC=({config:e,onUpdate:t})=>o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(ie,{className:"text-xs",children:"Label"}),o.jsx(yr,{})]}),o.jsx(ue,{value:e.label,onChange:r=>t({label:r.target.value}),className:"h-8 text-sm"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(ie,{className:"text-xs",children:"Descrição"}),o.jsx(yr,{})]}),o.jsx(ue,{value:e.description||"",onChange:r=>t({description:r.target.value}),className:"h-8 text-sm",placeholder:"Descrição do container"})]}),o.jsx(Jf,{value:e.icone,onChange:r=>t({icone:r})}),o.jsx(Xh,{tamanho:e.tamanho||12,inicioColuna:e.inicioColuna||1,defaultTamanho:12,onTamanhoChange:r=>t({tamanho:r}),onPositionChange:r=>t({inicioColuna:r})}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Colunas internas"}),o.jsxs(Bt,{value:String(e.columns||2),onValueChange:r=>t({columns:Number(r)}),children:[o.jsx(Rt,{className:"h-8 text-sm",children:o.jsx(Ut,{})}),o.jsxs(It,{children:[o.jsx(qe,{value:"1",children:"1 coluna"}),o.jsx(qe,{value:"2",children:"2 colunas"}),o.jsx(qe,{value:"3",children:"3 colunas"}),o.jsx(qe,{value:"4",children:"4 colunas"})]})]}),o.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Grid interno simplificado para campos"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(et,{id:"show-label",checked:e.showLabel!==!1,onCheckedChange:r=>t({showLabel:r===!0})}),o.jsx(ie,{htmlFor:"show-label",className:"text-xs cursor-pointer",children:"Exibir label no formulário"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(et,{id:"show-as-card",checked:e.showAsCard||!1,onCheckedChange:r=>t({showAsCard:r===!0})}),o.jsx(ie,{htmlFor:"show-as-card",className:"text-xs cursor-pointer",children:"Exibir como card"})]})]}),ui=[{category:"Texto básico",presets:[{pattern:"^[A-Za-z]+$",label:"Apenas letras",description:"Aceita somente letras de A-Z (maiúsculas e minúsculas), sem espaços, números ou especiais."},{pattern:"^[a-z]+$",label:"Apenas minúsculas",description:"Aceita somente letras minúsculas de a-z."},{pattern:"^[A-Z]+$",label:"Apenas maiúsculas",description:"Aceita somente letras maiúsculas de A-Z."},{pattern:"^[A-Za-zÀ-ÿ]+$",label:"Letras com acentos",description:"Aceita letras incluindo acentuadas (é, ã, ü, etc.)."},{pattern:"^[A-Za-zÀ-ÿ\\s]+$",label:"Letras, acentos e espaços",description:"Aceita letras com acentos e espaços — ideal para nomes completos."},{pattern:"^[A-Za-z0-9]+$",label:"Alfanumérico",description:"Apenas letras e números, sem espaços ou caracteres especiais."},{pattern:"^[A-Za-z0-9\\s]+$",label:"Alfanumérico com espaços",description:"Letras, números e espaços."},{pattern:"^[A-Za-z0-9_]+$",label:"Alfanumérico + underscore",description:"Letras, números e underscore (_). Padrão para usernames."},{pattern:"^[A-Za-z0-9_-]+$",label:"Slug-friendly",description:"Letras, números, underscore e hífen. Ideal para slugs de URL."},{pattern:"^\\S+$",label:"Sem espaços",description:"Aceita qualquer caractere exceto espaços em branco."},{pattern:"^.{1,}$",label:"Não vazio",description:"Exige pelo menos 1 caractere (qualquer um)."}]},{category:"Números",presets:[{pattern:"^[0-9]+$",label:"Apenas dígitos",description:"Aceita somente dígitos numéricos (0-9)."},{pattern:"^-?[0-9]+$",label:"Inteiro (com negativo)",description:"Número inteiro, opcionalmente negativo."},{pattern:"^[0-9]+\\.?[0-9]*$",label:"Decimal positivo",description:"Número decimal positivo (ex: 3.14, 42)."},{pattern:"^-?[0-9]+\\.?[0-9]*$",label:"Decimal (com negativo)",description:"Número decimal, opcionalmente negativo."},{pattern:"^\\d{1,3}(\\.\\d{3})*(,\\d{2})?$",label:"Formato BR (1.234,56)",description:"Número no formato brasileiro com pontos de milhar e vírgula decimal."},{pattern:"^\\d{1,3}(,\\d{3})*(\\.\\d{2})?$",label:"Formato US (1,234.56)",description:"Número no formato americano com vírgulas de milhar e ponto decimal."},{pattern:"^[01]+$",label:"Binário",description:"Aceita apenas 0 e 1 — representação binária."},{pattern:"^[0-9A-Fa-f]+$",label:"Hexadecimal",description:"Aceita dígitos hexadecimais (0-9, A-F)."},{pattern:"^0[xX][0-9A-Fa-f]+$",label:"Hex com prefixo 0x",description:"Hexadecimal com prefixo 0x (ex: 0xFF)."},{pattern:"^[0-7]+$",label:"Octal",description:"Aceita apenas dígitos octais (0-7)."},{pattern:"^\\d+(\\.\\d{1,2})?$",label:"Monetário (2 casas)",description:"Número com até 2 casas decimais — ideal para valores monetários."},{pattern:"^\\d+(\\.\\d{1,4})?$",label:"Até 4 casas decimais",description:"Número com até 4 casas decimais."}]},{category:"Documentos BR",presets:[{pattern:"^\\d{3}\\.\\d{3}\\.\\d{3}-\\d{2}$",label:"CPF (com máscara)",description:"CPF formatado: 123.456.789-00."},{pattern:"^\\d{11}$",label:"CPF (sem máscara)",description:"CPF apenas dígitos: 12345678900."},{pattern:"^\\d{2}\\.\\d{3}\\.\\d{3}/\\d{4}-\\d{2}$",label:"CNPJ (com máscara)",description:"CNPJ formatado: 12.345.678/0001-00."},{pattern:"^\\d{14}$",label:"CNPJ (sem máscara)",description:"CNPJ apenas dígitos: 12345678000100."},{pattern:"^\\d{5}-?\\d{3}$",label:"CEP",description:"CEP brasileiro: 12345-678 ou 12345678."},{pattern:"^\\d{1,2}\\.\\d{3}\\.\\d{3}[-]?\\d{1}$",label:"RG (formato comum)",description:"RG no formato mais comum: 1.234.567-8."},{pattern:"^\\d{11}$",label:"PIS/PASEP",description:"PIS/PASEP com 11 dígitos."},{pattern:"^\\d{3}\\.?\\d{7}-?\\d{1}$",label:"Título de eleitor",description:"Título de eleitor com 12 dígitos."},{pattern:"^[A-Z]{2}\\d{7}$",label:"Passaporte BR",description:"Passaporte brasileiro: 2 letras + 7 dígitos (ex: AB1234567)."},{pattern:"^\\d{11}$",label:"CNH (registro)",description:"Número de registro da CNH: 11 dígitos."},{pattern:"^\\d{10}$",label:"Certidão (matrícula)",description:"Matrícula de certidão de nascimento/casamento."},{pattern:"^\\d{3}\\.\\d{3}\\.\\d{3}-\\d{2}$|^\\d{2}\\.\\d{3}\\.\\d{3}/\\d{4}-\\d{2}$",label:"CPF ou CNPJ",description:"Aceita CPF (123.456.789-00) ou CNPJ (12.345.678/0001-00)."}]},{category:"Contato",presets:[{pattern:"^[\\w.-]+@[\\w.-]+\\.[A-Za-z]{2,}$",label:"E-mail simples",description:"Validação básica de e-mail: usuario@dominio.com."},{pattern:"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$",label:"E-mail completo",description:"E-mail com mais caracteres aceitos no usuário."},{pattern:"^\\(\\d{2}\\)\\s?\\d{4,5}-\\d{4}$",label:"Telefone BR (com máscara)",description:"Telefone formatado: (11) 91234-5678 ou (11) 1234-5678."},{pattern:"^\\d{10,11}$",label:"Telefone BR (sem máscara)",description:"Telefone apenas dígitos: 11912345678."},{pattern:"^\\+\\d{1,3}\\s?\\d{2,3}\\s?\\d{4,5}[-]?\\d{4}$",label:"Telefone internacional",description:"Formato +55 11 91234-5678."},{pattern:"^\\+55\\d{10,11}$",label:"Celular BR (+55)",description:"Celular brasileiro com DDI: +5511912345678."},{pattern:"^\\d{4,5}-\\d{4}$",label:"Telefone (sem DDD)",description:"Número local: 1234-5678 ou 91234-5678."},{pattern:"^0800\\d{6,7}$",label:"0800",description:"Número 0800 (SAC): 0800XXXXXXX."}]},{category:"Internet / URLs",presets:[{pattern:"^https?://[\\w.-]+(:\\d+)?(/[\\w./-]*)*$",label:"URL HTTP/HTTPS",description:"URL completa com protocolo http ou https."},{pattern:"^(https?://)?[\\w.-]+\\.[A-Za-z]{2,}(/.*)?$",label:"URL (protocolo opcional)",description:"URL com ou sem http:// na frente."},{pattern:"^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*\\.[a-z]{2,}$",label:"Domínio",description:"Nome de domínio válido: exemplo.com.br."},{pattern:"^((25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)$",label:"IPv4",description:"Endereço IPv4: 192.168.0.1."},{pattern:"^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$",label:"IPv6 (completo)",description:"Endereço IPv6 completo."},{pattern:"^[a-z][a-z0-9-]*$",label:"Subdomínio",description:"Nome de subdomínio válido (letra inicial, alfanumérico + hífen)."},{pattern:"^[A-Za-z][A-Za-z0-9+.-]*://.*$",label:"URI genérica",description:"Qualquer URI com esquema (ftp://, mailto:, tel:, etc.)."},{pattern:"^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$",label:"Cor hex (#FFF)",description:"Código de cor hexadecimal: #FFF ou #FFFFFF."},{pattern:"^#[0-9A-Fa-f]{8}$",label:"Cor hex com alpha",description:"Cor hexadecimal com canal alpha: #FFFFFFFF."},{pattern:"^rgb\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*\\)$",label:"Cor RGB",description:"Cor no formato rgb(255, 0, 0)."}]},{category:"Data e hora",presets:[{pattern:"^\\d{2}/\\d{2}/\\d{4}$",label:"Data DD/MM/AAAA",description:"Data no formato brasileiro: 25/12/2024."},{pattern:"^\\d{4}-\\d{2}-\\d{2}$",label:"Data ISO (AAAA-MM-DD)",description:"Data no formato ISO 8601: 2024-12-25."},{pattern:"^\\d{2}/\\d{2}/\\d{2}$",label:"Data DD/MM/AA",description:"Data com ano de 2 dígitos: 25/12/24."},{pattern:"^\\d{2}-\\d{2}-\\d{4}$",label:"Data DD-MM-AAAA",description:"Data com hífens: 25-12-2024."},{pattern:"^\\d{2}:\\d{2}$",label:"Hora HH:MM",description:"Horário 24h: 14:30."},{pattern:"^\\d{2}:\\d{2}:\\d{2}$",label:"Hora HH:MM:SS",description:"Horário com segundos: 14:30:59."},{pattern:"^(0[1-9]|1[0-2])/\\d{4}$",label:"Mês/Ano (MM/AAAA)",description:"Mês e ano: 12/2024."},{pattern:"^\\d{4}$",label:"Ano (4 dígitos)",description:"Ano com 4 dígitos: 2024."},{pattern:"^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}$",label:"DateTime ISO (sem seg)",description:"Data e hora ISO: 2024-12-25T14:30."},{pattern:"^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}$",label:"DateTime ISO (com seg)",description:"Data e hora ISO com segundos."},{pattern:"^\\d{2}/\\d{2}/\\d{4}\\s\\d{2}:\\d{2}$",label:"DateTime BR",description:"Data e hora BR: 25/12/2024 14:30."}]},{category:"Senhas",presets:[{pattern:"^.{6,}$",label:"Mín. 6 caracteres",description:"Exige no mínimo 6 caracteres (qualquer tipo)."},{pattern:"^.{8,}$",label:"Mín. 8 caracteres",description:"Exige no mínimo 8 caracteres."},{pattern:"^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d).{8,}$",label:"Forte (letra+número)",description:"Mín. 8 chars com pelo menos 1 maiúscula, 1 minúscula e 1 número."},{pattern:"^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[!@#$%^&*]).{8,}$",label:"Muito forte",description:"Mín. 8 chars com maiúscula, minúscula, número e caractere especial."},{pattern:"^(?=.*[A-Z])(?=.*\\d).{6,}$",label:"Média (maiúsc+número)",description:"Mín. 6 chars com pelo menos 1 maiúscula e 1 número."},{pattern:"^(?!.*\\s).{8,}$",label:"Sem espaços (mín. 8)",description:"Mín. 8 caracteres, sem espaços."}]},{category:"Nomes e texto formatado",presets:[{pattern:"^[A-Za-zÀ-ÿ]{2,}(\\s[A-Za-zÀ-ÿ]{2,})+$",label:"Nome completo",description:"Nome e sobrenome (mínimo 2 palavras, cada com 2+ letras)."},{pattern:"^[A-Za-zÀ-ÿ]{2,}$",label:"Primeiro nome",description:"Apenas o primeiro nome (mínimo 2 letras, com acentos)."},{pattern:"^[A-Za-zÀ-ÿ'\\-\\s]+$",label:"Nome com apóstrofo/hífen",description:"Nome que aceita D'Silva, Maria-José, etc."},{pattern:"^[A-Z][a-zà-ÿ]+(\\s[A-Z][a-zà-ÿ]+)*$",label:"Nome capitalizado",description:"Cada palavra inicia com maiúscula: João Silva."},{pattern:"^@[A-Za-z0-9_]{1,30}$",label:"Username (@handle)",description:"Username no estilo @usuario (letras, números, underscore, até 30 chars)."},{pattern:"^[a-z0-9_]{3,20}$",label:"Username simples",description:"Username minúsculo: 3-20 chars, letras, números e underscore."},{pattern:"^[A-Za-z0-9._%+-]+$",label:"Parte local do e-mail",description:"Parte antes do @ em endereços de e-mail."}]},{category:"Endereço",presets:[{pattern:"^[A-Za-zÀ-ÿ0-9\\s,./-]+$",label:"Endereço genérico",description:"Aceita letras, números, espaços, vírgulas, pontos, barras e hífens."},{pattern:"^\\d{1,6}$",label:"Número residencial",description:"Número do endereço: 1 a 6 dígitos."},{pattern:"^\\d{5}-?\\d{3}$",label:"CEP",description:"CEP: 12345-678 ou 12345678."},{pattern:"^[A-Z]{2}$",label:"UF (estado)",description:"Sigla do estado brasileiro: SP, RJ, MG, etc."},{pattern:"^(Rua|Av|Avenida|Travessa|Alameda|Praça|Rod|Rodovia)\\s.+$",label:"Logradouro BR",description:"Começa com tipo de via: Rua, Avenida, Travessa, etc."},{pattern:"^(Apt|Apto|Sala|Bloco|Lote|Casa)\\s?\\d+.*$",label:"Complemento",description:"Complemento: Apto 123, Bloco B, Sala 3, etc."}]},{category:"Financeiro",presets:[{pattern:"^R\\$\\s?\\d{1,3}(\\.\\d{3})*(,\\d{2})?$",label:"Moeda BRL (R$)",description:"Valor em reais: R$ 1.234,56."},{pattern:"^\\$\\d{1,3}(,\\d{3})*(\\.\\d{2})?$",label:"Moeda USD ($)",description:"Valor em dólares: $1,234.56."},{pattern:"^\\d{4}[\\s-]?\\d{4}[\\s-]?\\d{4}[\\s-]?\\d{4}$",label:"Cartão de crédito",description:"Número de cartão: 1234 5678 9012 3456."},{pattern:"^(0[1-9]|1[0-2])/\\d{2}$",label:"Validade cartão (MM/AA)",description:"Data de validade: 12/25."},{pattern:"^\\d{3,4}$",label:"CVV",description:"Código de segurança: 3 ou 4 dígitos."},{pattern:"^\\d{1,6}(-[0-9Xx])?$",label:"Agência bancária",description:"Número da agência: 1234-5 ou 1234."},{pattern:"^\\d{1,12}(-[0-9Xx])?$",label:"Conta bancária",description:"Número da conta: até 12 dígitos com dígito verificador."},{pattern:"^\\d{1,3}(\\.\\d{3})*(,\\d{2})$",label:"Valor BR sem símbolo",description:"Valor monetário sem R$: 1.234,56."}]},{category:"Veículos",presets:[{pattern:"^[A-Z]{3}-?\\d{4}$",label:"Placa antiga (ABC-1234)",description:"Placa veicular formato antigo: ABC-1234."},{pattern:"^[A-Z]{3}\\d[A-Z]\\d{2}$",label:"Placa Mercosul (ABC1D23)",description:"Placa veicular Mercosul: ABC1D23."},{pattern:"^[A-Z]{3}-?\\d{4}$|^[A-Z]{3}\\d[A-Z]\\d{2}$",label:"Placa (ambos formatos)",description:"Aceita placa antiga (ABC-1234) ou Mercosul (ABC1D23)."},{pattern:"^\\d{11}$",label:"RENAVAM",description:"RENAVAM: 11 dígitos numéricos."},{pattern:"^[A-Z0-9]{17}$",label:"Chassi (VIN)",description:"Número de chassi/VIN: 17 caracteres alfanuméricos maiúsculos."}]},{category:"Códigos e identificadores",presets:[{pattern:"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$",label:"UUID v4",description:"UUID formato padrão: 550e8400-e29b-41d4-a716-446655440000."},{pattern:"^[A-Za-z0-9+/]+={0,2}$",label:"Base64",description:"String codificada em Base64."},{pattern:"^[A-Za-z0-9-_]+$",label:"Base64 URL-safe",description:"Base64 com caracteres seguros para URL."},{pattern:"^[0-9a-f]{32}$",label:"MD5 hash",description:"Hash MD5: 32 caracteres hexadecimais."},{pattern:"^[0-9a-f]{40}$",label:"SHA-1 hash",description:"Hash SHA-1: 40 caracteres hexadecimais."},{pattern:"^[0-9a-f]{64}$",label:"SHA-256 hash",description:"Hash SHA-256: 64 caracteres hexadecimais."},{pattern:"^\\d{8,14}$",label:"Código de barras",description:"Código de barras numérico: 8-14 dígitos."},{pattern:"^\\d{44}$",label:"Linha digitável boleto",description:"Linha digitável de boleto: 44 dígitos."},{pattern:"^[A-Z]{2}\\d{2}[A-Z0-9]{4}\\d{7}([A-Z0-9]?){0,16}\\d{2}$",label:"IBAN",description:"Código bancário internacional IBAN."},{pattern:"^[A-Z]{4}[A-Z]{2}[A-Z0-9]{2}([A-Z0-9]{3})?$",label:"SWIFT/BIC",description:"Código SWIFT bancário: 8 ou 11 caracteres."}]},{category:"Saúde e governo",presets:[{pattern:"^\\d{15}$",label:"Cartão SUS",description:"Número do Cartão Nacional de Saúde: 15 dígitos."},{pattern:"^\\d{6,7}$",label:"CRM/CRO/CRP",description:"Número de registro profissional de saúde."},{pattern:"^\\d{3}\\.\\d{5}\\.\\d{2}-\\d$",label:"NIT/PIS",description:"Número de Identificação do Trabalhador."},{pattern:"^\\d{7}-?\\d{2}\\.\\d{4}\\.\\d\\.\\d{2}\\.\\d{4}$",label:"Processo judicial",description:"Número de processo judicial (formato CNJ)."},{pattern:"^\\d{12}$",label:"Inscrição estadual (genérica)",description:"Inscrição estadual genérica: 12 dígitos."},{pattern:"^\\d{11}$",label:"NIS/NIT",description:"Número de Identificação Social: 11 dígitos."}]},{category:"Redes sociais",presets:[{pattern:"^https?://(www\\.)?instagram\\.com/[A-Za-z0-9_.]+/?$",label:"Perfil Instagram",description:"URL de perfil do Instagram."},{pattern:"^https?://(www\\.)?facebook\\.com/.+$",label:"Perfil Facebook",description:"URL de perfil ou página do Facebook."},{pattern:"^https?://(www\\.)?linkedin\\.com/in/[A-Za-z0-9-]+/?$",label:"Perfil LinkedIn",description:"URL de perfil do LinkedIn."},{pattern:"^https?://(www\\.)?(twitter|x)\\.com/[A-Za-z0-9_]+/?$",label:"Perfil Twitter/X",description:"URL de perfil no Twitter/X."},{pattern:"^https?://(www\\.)?youtube\\.com/(c/|channel/|@)[A-Za-z0-9_-]+/?$",label:"Canal YouTube",description:"URL de canal do YouTube."},{pattern:"^https?://(www\\.)?github\\.com/[A-Za-z0-9_-]+/?$",label:"Perfil GitHub",description:"URL de perfil do GitHub."},{pattern:"^https?://(www\\.)?tiktok\\.com/@[A-Za-z0-9_.]+/?$",label:"Perfil TikTok",description:"URL de perfil do TikTok."}]},{category:"Programação",presets:[{pattern:"^[a-z][a-zA-Z0-9]*$",label:"camelCase",description:"Formato camelCase: minúscula inicial, sem espaços."},{pattern:"^[A-Z][a-zA-Z0-9]*$",label:"PascalCase",description:"Formato PascalCase: maiúscula inicial."},{pattern:"^[a-z]+(_[a-z]+)*$",label:"snake_case",description:"Formato snake_case: minúsculas separadas por underscore."},{pattern:"^[a-z]+(-[a-z]+)*$",label:"kebab-case",description:"Formato kebab-case: minúsculas separadas por hífen."},{pattern:"^[A-Z]+(_[A-Z]+)*$",label:"SCREAMING_SNAKE",description:"Constantes: MAIÚSCULAS_COM_UNDERSCORES."},{pattern:"^[a-zA-Z_$][a-zA-Z0-9_$]*$",label:"Variável JS válida",description:"Nome de variável JavaScript válido."},{pattern:"^v?\\d+\\.\\d+\\.\\d+(-[a-zA-Z0-9.]+)?$",label:"Semver",description:"Versionamento semântico: v1.2.3 ou 1.2.3-beta.1."},{pattern:"^[a-z][a-z0-9]*(-[a-z][a-z0-9]*)*$",label:"Nome de pacote npm",description:"Nome válido de pacote npm."}]}],BC=ui.flatMap(e=>e.presets),UC=({value:e,message:t,onChange:r})=>{const[n,a]=N.useState(!1),[s,i]=N.useState(""),l=N.useMemo(()=>{if(!s.trim())return ui;const u=s.toLowerCase();return ui.map(m=>({...m,presets:m.presets.filter(p=>p.label.toLowerCase().includes(u)||p.description.toLowerCase().includes(u)||p.pattern.toLowerCase().includes(u))})).filter(m=>m.presets.length>0)},[s]),c=N.useMemo(()=>e?BC.find(u=>u.pattern===e):void 0,[e]),d=u=>{r(u.pattern,`${u.label}: formato inválido`),a(!1),i("")};return o.jsxs("div",{className:"space-y-2",children:[o.jsx(ie,{className:"text-[10px]",children:"Regex"}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(ue,{value:e??"",onChange:u=>r(u.target.value||void 0,t),className:"h-7 text-xs font-mono flex-1",placeholder:"Clique no botão ou digite..."}),e&&o.jsx(De,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>{r(void 0,void 0)},children:o.jsx(_.X,{className:"h-3 w-3"})}),o.jsxs(Po,{open:n,onOpenChange:a,children:[o.jsx(_o,{asChild:!0,children:o.jsx(De,{variant:"outline",size:"icon",className:"h-7 w-7 shrink-0",children:o.jsx(_.Regex,{className:"h-3.5 w-3.5"})})}),o.jsxs(fa,{className:"w-[360px] p-0",side:"left",align:"start",sideOffset:8,children:[o.jsx("div",{className:"p-2 border-b",children:o.jsxs("div",{className:"relative",children:[o.jsx(_.Search,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),o.jsx(ue,{value:s,onChange:u=>i(u.target.value),className:"h-8 text-xs pl-7",placeholder:"Buscar regex (ex: CPF, e-mail, senha)...",autoFocus:!0})]})}),o.jsx(Vo,{className:"h-[360px]",children:o.jsxs("div",{className:"p-1",children:[l.length===0&&o.jsx("p",{className:"text-xs text-muted-foreground text-center py-8",children:"Nenhum regex encontrado"}),l.map(u=>o.jsxs("div",{className:"mb-1",children:[o.jsx("p",{className:"text-[10px] font-semibold text-muted-foreground uppercase tracking-wide px-2 py-1.5 sticky top-0 bg-popover z-10",children:u.category}),u.presets.map(m=>o.jsxs(Of,{children:[o.jsx(Ff,{asChild:!0,children:o.jsxs("button",{onClick:()=>d(m),className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-left hover:bg-accent transition-colors group",children:[o.jsx(_.ChevronRight,{className:"h-3 w-3 text-muted-foreground/50 group-hover:text-primary shrink-0"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("span",{className:"text-xs font-medium block truncate",children:m.label}),o.jsx("span",{className:"text-[10px] text-muted-foreground font-mono block truncate",children:m.pattern})]})]})}),o.jsxs(sl,{side:"left",className:"max-w-[250px] text-xs",children:[o.jsx("p",{className:"font-semibold mb-1",children:m.label}),o.jsx("p",{children:m.description})]})]},m.pattern+m.label))]},u.category))]})})]})]})]}),c&&o.jsxs(Di,{variant:"secondary",className:"text-[10px] font-normal gap-1",children:[o.jsx(_.Regex,{className:"h-2.5 w-2.5"}),c.label]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Mensagem do regex"}),o.jsx(ue,{value:t??"",onChange:u=>r(e,u.target.value||void 0),className:"h-7 text-xs",placeholder:"Formato inválido"})]})]})},mi=[{category:"Imagens",presets:[{value:"image/jpeg",label:"JPEG",description:"Imagem JPEG — formato mais comum para fotos. Boa compressão, perde qualidade."},{value:"image/png",label:"PNG",description:"Imagem PNG — suporta transparência, sem perda de qualidade. Arquivos maiores."},{value:"image/gif",label:"GIF",description:"Imagem GIF — suporta animações simples e transparência. Limitado a 256 cores."},{value:"image/webp",label:"WebP",description:"Formato moderno do Google — compressão superior ao JPEG e PNG."},{value:"image/svg+xml",label:"SVG",description:"Imagem vetorial XML — escalável sem perda. Ideal para logos e ícones."},{value:"image/bmp",label:"BMP",description:"Bitmap — sem compressão, arquivos muito grandes."},{value:"image/tiff",label:"TIFF",description:"Imagem TIFF — alta qualidade, usado em impressão profissional."},{value:"image/avif",label:"AVIF",description:"Formato moderno — melhor compressão que WebP, suporte crescente."},{value:"image/heic",label:"HEIC",description:"Formato padrão do iPhone — alta qualidade, tamanho reduzido."},{value:"image/*",label:"Qualquer imagem",description:"Aceita todos os formatos de imagem (JPEG, PNG, GIF, WebP, etc.)."}]},{category:"Documentos",presets:[{value:"application/pdf",label:"PDF",description:"Documento PDF — formato universal para documentos. Preserva formatação."},{value:"application/msword",label:"DOC (Word antigo)",description:"Microsoft Word 97-2003 (.doc)."},{value:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",label:"DOCX (Word)",description:"Microsoft Word moderno (.docx) — formato atual do Word."},{value:"application/vnd.ms-excel",label:"XLS (Excel antigo)",description:"Microsoft Excel 97-2003 (.xls)."},{value:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",label:"XLSX (Excel)",description:"Microsoft Excel moderno (.xlsx) — formato atual do Excel."},{value:"application/vnd.ms-powerpoint",label:"PPT (PowerPoint antigo)",description:"Microsoft PowerPoint 97-2003 (.ppt)."},{value:"application/vnd.openxmlformats-officedocument.presentationml.presentation",label:"PPTX (PowerPoint)",description:"Microsoft PowerPoint moderno (.pptx)."},{value:"application/vnd.oasis.opendocument.text",label:"ODT (LibreOffice)",description:"Documento de texto LibreOffice/OpenOffice (.odt)."},{value:"application/vnd.oasis.opendocument.spreadsheet",label:"ODS (LibreOffice)",description:"Planilha LibreOffice/OpenOffice (.ods)."},{value:"application/rtf",label:"RTF",description:"Rich Text Format — compatível com quase todos os editores de texto."},{value:"text/plain",label:"TXT",description:"Texto puro sem formatação (.txt)."},{value:"text/csv",label:"CSV",description:"Valores separados por vírgula — planilhas simples e dados tabulares."}]},{category:"Vídeos",presets:[{value:"video/mp4",label:"MP4",description:"Vídeo MP4 — formato mais compatível, boa compressão (H.264/H.265)."},{value:"video/webm",label:"WebM",description:"Vídeo WebM — formato aberto do Google, boa compressão."},{value:"video/quicktime",label:"MOV",description:"Vídeo QuickTime — formato padrão do macOS/iPhone."},{value:"video/x-msvideo",label:"AVI",description:"Vídeo AVI — formato antigo da Microsoft, arquivos grandes."},{value:"video/x-matroska",label:"MKV",description:"Matroska — contêiner flexível, suporta múltiplas faixas de áudio/legenda."},{value:"video/*",label:"Qualquer vídeo",description:"Aceita todos os formatos de vídeo."}]},{category:"Áudios",presets:[{value:"audio/mpeg",label:"MP3",description:"Áudio MP3 — formato mais popular, boa compressão com perda."},{value:"audio/wav",label:"WAV",description:"Áudio WAV — sem compressão, alta qualidade, arquivos grandes."},{value:"audio/ogg",label:"OGG",description:"Áudio OGG Vorbis — formato aberto, boa qualidade."},{value:"audio/aac",label:"AAC",description:"Áudio AAC — qualidade superior ao MP3 no mesmo bitrate."},{value:"audio/flac",label:"FLAC",description:"Áudio FLAC — compressão sem perda, alta fidelidade."},{value:"audio/webm",label:"WebM Áudio",description:"Áudio no contêiner WebM."},{value:"audio/*",label:"Qualquer áudio",description:"Aceita todos os formatos de áudio."}]},{category:"Compactados",presets:[{value:"application/zip",label:"ZIP",description:"Arquivo compactado ZIP — o mais universal."},{value:"application/x-rar-compressed",label:"RAR",description:"Arquivo compactado RAR — boa compressão, formato proprietário."},{value:"application/gzip",label:"GZ / GZIP",description:"Compactação GZIP — muito usado em ambientes Unix/Linux."},{value:"application/x-7z-compressed",label:"7Z",description:"Arquivo 7-Zip — excelente taxa de compressão."},{value:"application/x-tar",label:"TAR",description:"TAR — agrupa arquivos sem compressão (usado com gzip)."}]},{category:"Dados / Código",presets:[{value:"application/json",label:"JSON",description:"Dados JSON — formato leve para troca de dados."},{value:"application/xml",label:"XML",description:"Dados XML — formato de marcação extensível."},{value:"text/html",label:"HTML",description:"Página web HTML."},{value:"text/css",label:"CSS",description:"Folha de estilo CSS."},{value:"application/javascript",label:"JavaScript",description:"Código JavaScript (.js)."},{value:"application/x-yaml",label:"YAML",description:"Dados YAML — formato legível para configurações."},{value:"text/markdown",label:"Markdown",description:"Texto Markdown (.md) — formatação leve."}]},{category:"Fontes",presets:[{value:"font/ttf",label:"TTF",description:"Fonte TrueType — amplamente suportada."},{value:"font/otf",label:"OTF",description:"Fonte OpenType — recursos tipográficos avançados."},{value:"font/woff",label:"WOFF",description:"Web Open Font Format — otimizado para web."},{value:"font/woff2",label:"WOFF2",description:"WOFF2 — compressão superior ao WOFF."}]},{category:"Atalhos comuns",presets:[{value:"image/*",label:"Todas as imagens",description:"Aceita qualquer formato de imagem."},{value:"video/*",label:"Todos os vídeos",description:"Aceita qualquer formato de vídeo."},{value:"audio/*",label:"Todos os áudios",description:"Aceita qualquer formato de áudio."},{value:"_group_documentos",label:"Documentos comuns",description:"PDF + Word .doc e .docx.",group:["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"]},{value:"_group_imagens_web",label:"Imagens web",description:"JPEG, PNG e WebP — formatos mais usados na web.",group:["image/jpeg","image/png","image/webp"]},{value:"_group_planilhas",label:"Planilhas",description:"Excel .xls, .xlsx e CSV.",group:["application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","text/csv"]}]}],HC=mi.flatMap(e=>e.presets),WC=({value:e,onChange:t})=>{const[r,n]=N.useState(!1),[a,s]=N.useState(""),[i,l]=N.useState(""),c=N.useMemo(()=>new Set(e??[]),[e]),d=N.useMemo(()=>{if(!a.trim())return mi;const b=a.toLowerCase();return mi.map(h=>({...h,presets:h.presets.filter(x=>x.label.toLowerCase().includes(b)||x.description.toLowerCase().includes(b)||x.value.toLowerCase().includes(b))})).filter(h=>h.presets.length>0)},[a]),u=b=>{const h=new Set(e??[]);b.group?b.group.every(x=>h.has(x))?b.group.forEach(x=>h.delete(x)):b.group.forEach(x=>h.add(x)):h.has(b.value)?h.delete(b.value):h.add(b.value),t(h.size>0?Array.from(h):void 0)},m=()=>{const b=i.trim();if(!b)return;const h=new Set(e??[]);h.add(b),t(Array.from(h)),l("")},p=b=>{const h=new Set(e??[]);h.delete(b),t(h.size>0?Array.from(h):void 0)},f=b=>{const h=HC.find(x=>x.value===b);return(h==null?void 0:h.label)??b};return o.jsxs("div",{className:"space-y-2",children:[o.jsx(ie,{className:"text-[10px]",children:"Tipos de arquivo aceitos"}),((e==null?void 0:e.length)??0)>0&&o.jsx("div",{className:"flex flex-wrap gap-1",children:e.map(b=>o.jsxs(Di,{variant:"secondary",className:"text-[10px] gap-1 pr-1",children:[f(b),o.jsx("button",{onClick:()=>p(b),className:"hover:text-destructive",children:o.jsx(_.X,{className:"h-2.5 w-2.5"})})]},b))}),o.jsxs(Po,{open:r,onOpenChange:n,children:[o.jsx(_o,{asChild:!0,children:o.jsxs(De,{variant:"outline",className:"w-full h-8 text-xs justify-start gap-2",children:[o.jsx(_.FileType2,{className:"h-3.5 w-3.5"}),((e==null?void 0:e.length)??0)>0?`${e.length} tipo(s) selecionado(s)`:"Selecionar tipos de arquivo..."]})}),o.jsxs(fa,{className:"w-[360px] p-0",side:"left",align:"start",sideOffset:8,children:[o.jsx("div",{className:"p-2 border-b",children:o.jsxs("div",{className:"relative",children:[o.jsx(_.Search,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),o.jsx(ue,{value:a,onChange:b=>s(b.target.value),className:"h-8 text-xs pl-7",placeholder:"Buscar tipos (ex: PDF, imagem, vídeo)...",autoFocus:!0})]})}),o.jsxs("div",{className:"px-2 py-1.5 border-b flex gap-1",children:[o.jsx(ue,{value:i,onChange:b=>l(b.target.value),className:"h-7 text-xs font-mono flex-1",placeholder:"Tipo customizado (ex: .dwg)",onKeyDown:b=>b.key==="Enter"&&m()}),o.jsx(De,{variant:"secondary",size:"sm",className:"h-7 text-xs shrink-0",onClick:m,disabled:!i.trim(),children:"Adicionar"})]}),o.jsx(Vo,{className:"h-[320px]",children:o.jsxs("div",{className:"p-1",children:[d.length===0&&o.jsx("p",{className:"text-xs text-muted-foreground text-center py-8",children:"Nenhum tipo encontrado"}),d.map(b=>o.jsxs("div",{className:"mb-1",children:[o.jsx("p",{className:"text-[10px] font-semibold text-muted-foreground uppercase tracking-wide px-2 py-1.5 sticky top-0 bg-popover z-10",children:b.category}),b.presets.map(h=>{const x=h.group?h.group.every(v=>c.has(v)):c.has(h.value),y=h.group?h.group.some(v=>c.has(v))&&!x:!1;return o.jsxs(Of,{children:[o.jsx(Ff,{asChild:!0,children:o.jsxs("button",{onClick:()=>u(h),className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-left hover:bg-accent transition-colors",children:[o.jsx(et,{checked:y?"indeterminate":x,className:"h-3.5 w-3.5",tabIndex:-1}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("span",{className:"text-xs font-medium",children:h.label}),!h.group&&o.jsx("span",{className:"text-[10px] text-muted-foreground font-mono ml-2",children:h.value}),h.group&&o.jsxs("span",{className:"text-[10px] text-muted-foreground ml-2",children:[h.group.length," tipos"]})]}),o.jsx(_.Info,{className:"h-3 w-3 text-muted-foreground/40 shrink-0"})]})}),o.jsxs(sl,{side:"left",className:"max-w-[250px] text-xs",children:[o.jsx("p",{className:"font-semibold mb-1",children:h.label}),o.jsx("p",{children:h.description}),h.group&&o.jsx("ul",{className:"mt-1 space-y-0.5",children:h.group.map(v=>o.jsx("li",{className:"font-mono text-[10px] opacity-80",children:v},v))})]})]},h.value)})]},b.category))]})})]})]})]})},Zh=1048576,no=1073741824;function pd(e){return e>=no&&e%no===0?"GB":"MB"}function fd(e,t){return t==="GB"?e/no:e/Zh}function hd(e,t){return Math.round(e*(t==="GB"?no:Zh))}const qC=({value:e,onChange:t})=>{const r=N.useMemo(()=>e?pd(e):"MB",[]),[n,a]=N.useState(r),[s,i]=N.useState(e?String(fd(e,r)):"");N.useEffect(()=>{if(e===void 0){i("");return}const d=pd(e);a(d),i(String(fd(e,d)))},[e]);const l=d=>{i(d);const u=parseFloat(d);d.trim()===""||isNaN(u)||u<=0?t(void 0):t(hd(u,n))},c=d=>{a(d);const u=parseFloat(s);!isNaN(u)&&u>0&&t(hd(u,d))};return o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(ie,{className:"text-[10px]",children:"Tamanho máximo do arquivo"}),o.jsxs("div",{className:"flex gap-1.5",children:[o.jsx(ue,{type:"number",min:0,step:"any",value:s,onChange:d=>l(d.target.value),placeholder:"Ex: 10",className:"h-8 text-xs flex-1"}),o.jsxs(Bt,{value:n,onValueChange:d=>c(d),children:[o.jsx(Rt,{className:"w-[72px] h-8 text-xs",children:o.jsx(Ut,{})}),o.jsxs(It,{children:[o.jsx(qe,{value:"MB",children:"MB"}),o.jsx(qe,{value:"GB",children:"GB"})]})]})]}),e!==void 0&&o.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["= ",e.toLocaleString("pt-BR")," bytes"]})]})},GC=new Set(["texto","textarea","email","password","url","phone","tel","cpf","cnpj","cep","rg"]),XC=({fieldType:e,validation:t,onChange:r})=>{const n=(i,l)=>{const c=["minLength","maxLength","min","max","maxFileSize","minAge","maxAge"].includes(i)?l?Number(l):void 0:l||void 0;r({...t,[i]:c})},a=e==="file",s=GC.has(e);return o.jsxs("div",{className:"space-y-3",children:[o.jsx("h4",{className:"text-xs font-semibold text-muted-foreground uppercase",children:"Validação"}),s&&o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Min caracteres"}),o.jsx(ue,{type:"number",min:0,value:(t==null?void 0:t.minLength)??"",onChange:i=>n("minLength",i.target.value),className:"h-7 text-xs"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Max caracteres"}),o.jsx(ue,{type:"number",min:0,value:(t==null?void 0:t.maxLength)??"",onChange:i=>n("maxLength",i.target.value),className:"h-7 text-xs"})]})]}),e==="number"&&o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Valor mínimo"}),o.jsx(ue,{type:"number",value:(t==null?void 0:t.min)??"",onChange:i=>n("min",i.target.value),className:"h-7 text-xs"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Valor máximo"}),o.jsx(ue,{type:"number",value:(t==null?void 0:t.max)??"",onChange:i=>n("max",i.target.value),className:"h-7 text-xs"})]})]}),(e==="date"||e==="datetime")&&o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Data mínima"}),o.jsx(ue,{type:"date",value:(t==null?void 0:t.minDate)??"",onChange:i=>n("minDate",i.target.value),className:"h-7 text-xs"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Data máxima"}),o.jsx(ue,{type:"date",value:(t==null?void 0:t.maxDate)??"",onChange:i=>n("maxDate",i.target.value),className:"h-7 text-xs"})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Idade mínima (anos)"}),o.jsx(ue,{type:"number",min:0,value:(t==null?void 0:t.minAge)??"",onChange:i=>n("minAge",i.target.value),className:"h-7 text-xs",placeholder:"ex: 18"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Idade máxima (anos)"}),o.jsx(ue,{type:"number",min:0,value:(t==null?void 0:t.maxAge)??"",onChange:i=>n("maxAge",i.target.value),className:"h-7 text-xs",placeholder:"ex: 60"})]})]})]}),a&&o.jsxs("div",{className:"space-y-3",children:[o.jsx(WC,{value:t==null?void 0:t.fileTypes,onChange:i=>r({...t,fileTypes:i})}),o.jsx(qC,{value:t==null?void 0:t.maxFileSize,onChange:i=>r({...t,maxFileSize:i})})]}),!a&&o.jsx(UC,{value:(t==null?void 0:t.regex)??"",message:(t==null?void 0:t.regexMessage)??"",onChange:(i,l)=>r({...t,regex:i,regexMessage:l})})]})},Kh=({options:e,onChange:t})=>{const r=N.useRef([]);if(r.current.length<e.length)for(let i=r.current.length;i<e.length;i++)r.current.push(`opt-${Math.random().toString(36).slice(2)}`);const n=N.useCallback((i,l,c)=>{const d=[...e];d[i]={...d[i],[l]:c},t(d)},[e,t]),a=N.useCallback(i=>{r.current.splice(i,1),t(e.filter((l,c)=>c!==i))},[e,t]),s=N.useCallback(()=>{t([...e,{value:"",label:""}])},[e,t]);return o.jsxs("div",{className:"space-y-2",children:[o.jsx("h4",{className:"text-xs font-semibold text-muted-foreground uppercase",children:"Opções"}),e.map((i,l)=>o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(_.GripVertical,{className:"h-3 w-3 text-muted-foreground/40 shrink-0"}),o.jsx(ue,{value:i.value,onChange:c=>n(l,"value",c.target.value),className:"h-7 text-xs flex-1",placeholder:"Valor"}),o.jsxs("div",{className:"flex items-center gap-0.5 flex-1",children:[o.jsx(ue,{value:i.label,onChange:c=>n(l,"label",c.target.value),className:"h-7 text-xs flex-1",placeholder:"Label"}),o.jsx(yr,{})]}),o.jsx(De,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>a(l),children:o.jsx(_.Trash2,{className:"h-3 w-3"})})]},r.current[l])),o.jsxs(De,{variant:"outline",size:"sm",className:"w-full h-7 text-xs",onClick:s,children:[o.jsx(_.Plus,{className:"h-3 w-3 mr-1"})," Adicionar opção"]})]})},ZC=[{value:"igual",label:"Igual a"},{value:"diferente",label:"Diferente de"},{value:"vazio",label:"Vazio"},{value:"naoVazio",label:"Não vazio"},{value:"contem",label:"Contém"},{value:"naoContem",label:"Não contém"},{value:"maiorQue",label:"Maior que"},{value:"menorQue",label:"Menor que"},{value:"maiorOuIgual",label:"Maior ou igual a"},{value:"menorOuIgual",label:"Menor ou igual a"}],KC=["vazio","naoVazio"],xd=({cond:e,selectedId:t,allFieldIds:r,getFieldLabel:n,onUpdate:a})=>o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Fonte"}),o.jsxs(Bt,{value:e.source||"campo",onValueChange:s=>a({source:s,when:""}),children:[o.jsx(Rt,{className:"h-7 text-xs",children:o.jsx(Ut,{})}),o.jsxs(It,{children:[o.jsx(qe,{value:"campo",children:"Campo do formulário"}),o.jsx(qe,{value:"evento",children:"Variável do evento"})]})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:e.source==="evento"?"Variável do evento":"Quando o campo"}),o.jsxs(Bt,{value:e.when||"",onValueChange:s=>a({when:s}),children:[o.jsx(Rt,{className:"h-7 text-xs",children:o.jsx(Ut,{placeholder:e.source==="evento"?"Selecione uma variável...":"Selecione um campo..."})}),o.jsx(It,{children:e.source==="evento"?bl.map(s=>o.jsx(qe,{value:s.key,children:s.label},s.key)):r.filter(s=>s!==t).map(s=>o.jsxs(qe,{value:s,children:[n(s),o.jsxs("span",{className:"text-muted-foreground/50 ml-1 text-[9px] font-mono",children:["(",s,")"]})]},s))})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Operador"}),o.jsxs(Bt,{value:e.operator,onValueChange:s=>a({operator:s}),children:[o.jsx(Rt,{className:"h-7 text-xs",children:o.jsx(Ut,{})}),o.jsx(It,{children:ZC.map(s=>o.jsx(qe,{value:s.value,children:s.label},s.value))})]})]}),!KC.includes(e.operator)&&o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Valor"}),o.jsx(ue,{value:e.value||"",onChange:s=>a({value:s.target.value}),className:"h-7 text-xs",placeholder:"Valor esperado"})]})]}),YC=({condition:e,selectedId:t,allFieldIds:r,getFieldLabel:n,onChange:a})=>{var s;const i=m=>{e&&a({...e,...m})},l=()=>{if(!e)return;const m=e.extraConditions??[];a({...e,logicOperator:e.logicOperator??"and",extraConditions:[...m,{when:"",operator:"igual",value:"",source:"campo"}]})},c=m=>{if(!e)return;const p=(e.extraConditions??[]).filter((f,b)=>b!==m);a({...e,extraConditions:p,logicOperator:p.length?e.logicOperator:void 0})},d=(m,p)=>{if(!e)return;const f=(e.extraConditions??[]).map((b,h)=>h===m?{...b,...p}:b);a({...e,extraConditions:f})},u=(((s=e==null?void 0:e.extraConditions)==null?void 0:s.length)??0)>0;return o.jsxs("div",{className:"space-y-3",children:[o.jsx("h4",{className:"text-xs font-semibold text-muted-foreground uppercase",children:"Condicional"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(et,{id:"has-condition",checked:!!e,onCheckedChange:m=>{a(m?{when:"",operator:"igual",value:"",source:"campo"}:void 0)}}),o.jsx(ie,{htmlFor:"has-condition",className:"text-xs cursor-pointer",children:"Exibir condicionalmente"})]}),e&&o.jsxs("div",{className:"space-y-2 pl-2 border-l-2 border-amber-500/30",children:[o.jsx(xd,{cond:e,selectedId:t,allFieldIds:r,getFieldLabel:n,onUpdate:i}),u&&o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Lógica"}),o.jsxs(Bt,{value:e.logicOperator??"and",onValueChange:m=>i({logicOperator:m}),children:[o.jsx(Rt,{className:"h-7 text-xs",children:o.jsx(Ut,{})}),o.jsxs(It,{children:[o.jsx(qe,{value:"and",children:"E (AND) — todas devem ser verdadeiras"}),o.jsx(qe,{value:"or",children:"OU (OR) — pelo menos uma deve ser verdadeira"})]})]})]}),(e.extraConditions??[]).map((m,p)=>o.jsxs("div",{className:"space-y-2 pt-2 border-t border-border/40",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("span",{className:"text-[10px] text-muted-foreground font-medium uppercase",children:[e.logicOperator==="or"?"OU":"E"," — condição"," ",p+2]}),o.jsx(De,{variant:"ghost",size:"sm",className:"h-5 px-1 text-[10px] text-destructive hover:text-destructive",onClick:()=>c(p),children:"Remover"})]}),o.jsx(xd,{cond:m,selectedId:t,allFieldIds:r,getFieldLabel:n,onUpdate:f=>d(p,f)})]},p)),o.jsx(De,{variant:"outline",size:"sm",className:"h-6 text-[10px] w-full mt-1",onClick:l,children:"+ Adicionar condição"})]})]})},gd=[{value:"texto",label:"Texto"},{value:"textarea",label:"Área de texto"},{value:"number",label:"Número"},{value:"email",label:"E-mail"},{value:"telefone",label:"Telefone"},{value:"cpf",label:"CPF"},{value:"cep",label:"CEP"},{value:"date",label:"Data"},{value:"datetime",label:"Data e hora"},{value:"select",label:"Seleção"},{value:"radio",label:"Radio"},{value:"checkbox",label:"Checkbox"}],JC=({subFields:e,onChange:t})=>{const[r,n]=N.useState(null),a=(i,l)=>{const c=e.map((d,u)=>u===i?{...d,...l}:d);t(c)},s=i=>{t(e.filter((l,c)=>c!==i)),n(null)};return o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(ie,{className:"text-xs font-semibold",children:"Sub-campos"}),o.jsxs(De,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-xs gap-1",onClick:()=>{const i={label:"Novo campo",name:`campo_${e.length+1}`,fieldType:"texto",required:!1};t([...e,i]),n(e.length)},children:[o.jsx(_.Plus,{className:"w-3 h-3"}),"Adicionar"]})]}),e.length===0&&o.jsx("p",{className:"text-[11px] text-muted-foreground italic py-1",children:"Nenhum sub-campo adicionado."}),e.map((i,l)=>{var c;return o.jsxs("div",{className:"border rounded-md text-xs overflow-hidden",children:[o.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 cursor-pointer hover:bg-muted/40 select-none",onClick:()=>n(r===l?null:l),children:[o.jsx(Di,{variant:"secondary",className:"h-4 text-[9px] px-1 shrink-0",children:l+1}),o.jsx("span",{className:"flex-1 truncate font-medium",children:i.label||i.name||"Campo sem nome"}),o.jsx("span",{className:"text-muted-foreground text-[10px] shrink-0",children:((c=gd.find(d=>d.value===i.fieldType))==null?void 0:c.label)??i.fieldType}),o.jsx(De,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 text-destructive hover:text-destructive shrink-0",onClick:d=>{d.stopPropagation(),s(l)},children:o.jsx(_.Trash2,{className:"w-3 h-3"})}),r===l?o.jsx(_.ChevronUp,{className:"w-3 h-3 text-muted-foreground shrink-0"}):o.jsx(_.ChevronDown,{className:"w-3 h-3 text-muted-foreground shrink-0"})]}),r===l&&o.jsxs("div",{className:"px-2 pb-2 space-y-2 border-t bg-muted/20",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-2 pt-2",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Label"}),o.jsx(ue,{value:i.label,onChange:d=>a(l,{label:d.target.value}),className:"h-7 text-xs",placeholder:"Ex: Nome"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Nome (campo)"}),o.jsx(ue,{value:i.name||"",onChange:d=>a(l,{name:d.target.value}),className:"h-7 text-xs",placeholder:"Ex: nome"})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Tipo de campo"}),o.jsxs(Bt,{value:i.fieldType,onValueChange:d=>a(l,{fieldType:d}),children:[o.jsx(Rt,{className:"h-7 text-xs",children:o.jsx(Ut,{})}),o.jsx(It,{children:gd.map(d=>o.jsx(qe,{value:d.value,className:"text-xs",children:d.label},d.value))})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Colunas (1-12)"}),o.jsx(ue,{type:"number",min:1,max:12,value:i.tamanho??"",onChange:d=>a(l,{tamanho:d.target.value?Number(d.target.value):void 0}),className:"h-7 text-xs",placeholder:"12"})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Placeholder"}),o.jsx(ue,{value:i.placeholder||"",onChange:d=>a(l,{placeholder:d.target.value}),className:"h-7 text-xs",placeholder:"Texto de exemplo..."})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(et,{id:`sf-req-${l}`,checked:i.required||!1,onCheckedChange:d=>a(l,{required:d===!0})}),o.jsx(ie,{htmlFor:`sf-req-${l}`,className:"text-[10px] cursor-pointer",children:"Obrigatório"})]}),["select","radio","checkbox_group"].includes(i.fieldType)&&o.jsx("div",{className:"pt-1",children:o.jsx(Kh,{options:i.options||[],onChange:d=>a(l,{options:d})})})]})]},l)}),e.length>0&&o.jsx(it,{className:"mt-1"})]})},QC=({config:e,selectedId:t,allFieldIds:r,getFieldLabel:n,onUpdate:a})=>{const s=e.fieldType||"texto",i=["select","radio","checkbox_group","autocomplete"].includes(s),l=s==="field_array",c=e.locked===!0,d=s==="participation_type",u=s==="payment_method",m=s==="terms",p=s==="file",f=s==="slider",b=!!(e.isDisabled||e.isReadOnly),h=s==="rating",x=s==="date_range",y=s==="sub_form",{schemaId:v,uploadTermsPdf:j,deleteTermsPdf:w}=gt(),[C,S]=N.useState(e.termoPdfUploadId?"upload":"link"),[$,k]=N.useState({status:"idle"}),E=N.useRef(null),D=N.useRef(!0);N.useEffect(()=>()=>{D.current=!1},[]);const O=N.useCallback(async A=>{if(a({termoPdfUploadId:void 0}),w&&v)try{await w(A,v)}catch{}},[w,v,a]),L=N.useCallback(async A=>{if(A.type!=="application/pdf"){k({status:"error",message:"Apenas arquivos PDF são permitidos."});return}if(!v){k({status:"error",message:"Salve o schema primeiro para habilitar o upload de PDF."});return}if(!j){k({status:"error",message:"Upload de PDF não configurado. Forneça a prop uploadTermsPdf ao BuilderProvider."});return}const z=e.termoPdfUploadId;k({status:"uploading",fileName:A.name,progress:0});try{const X=await j(A,v,q=>k(Z=>Z.status==="uploading"?{...Z,progress:q}:Z));if(!D.current)return;if(z&&w)try{await w(z,v)}catch{}if(!D.current)return;a({termoPdfUploadId:X,termoPdfUrl:void 0}),k({status:"idle"})}catch(X){if(!D.current)return;k({status:"error",message:X instanceof Error?X.message:"Falha no upload do PDF."})}},[v,j,w,e.termoPdfUploadId,a]);return o.jsxs("div",{className:"space-y-4",children:[c&&o.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-amber-500/10 border border-amber-500/30 px-3 py-2",children:[o.jsx(_.Lock,{className:"h-4 w-4 text-amber-500 shrink-0"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs font-medium text-amber-600 dark:text-amber-400",children:"Campo bloqueado"}),o.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Tipo, nome e ID são fixos (integração automática)"})]})]}),d&&o.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-primary/5 border border-primary/30 px-3 py-2",children:[o.jsx(_.Lock,{className:"h-4 w-4 text-primary shrink-0"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs font-medium text-primary",children:"Tipo de Participação"}),o.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Datas, preços e vagas são carregados automaticamente do evento"})]})]}),m&&o.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-primary/5 border border-primary/30 px-3 py-2",children:[o.jsx(_.ScrollText,{className:"h-4 w-4 text-primary shrink-0"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs font-medium text-primary",children:"Termos e Condições"}),o.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Configure o texto ou URL do PDF abaixo"})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(ie,{className:"text-xs",children:"Label"}),o.jsx(yr,{})]}),o.jsx(ue,{value:e.label,onChange:A=>a({label:A.target.value}),className:"h-8 text-sm"})]}),d||u?o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Dica (hint)"}),o.jsx(ue,{value:e.hint||"",onChange:A=>a({hint:A.target.value}),className:"h-8 text-sm",placeholder:"Texto de ajuda abaixo do campo"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(et,{id:"req",checked:e.required||!1,onCheckedChange:A=>a({required:A===!0})}),o.jsx(ie,{htmlFor:"req",className:"text-xs cursor-pointer",children:"Campo obrigatório"})]})]}):m?o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Dica (hint)"}),o.jsx(ue,{value:e.hint||"",onChange:A=>a({hint:A.target.value}),className:"h-8 text-sm",placeholder:"Ex: Leia os termos antes de continuar"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(et,{id:"req",checked:e.required||!1,onCheckedChange:A=>a({required:A===!0})}),o.jsx(ie,{htmlFor:"req",className:"text-xs cursor-pointer",children:"Campo obrigatório"})]}),o.jsx(it,{}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("h4",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Conteúdo dos termos"}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Texto dos termos"}),o.jsx(po,{value:e.termoTexto||"",onChange:A=>a({termoTexto:A.target.value||void 0}),className:"text-sm min-h-[120px] resize-y",placeholder:"Escreva aqui os termos e condições que o usuário deverá ler e aceitar..."})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ie,{className:"text-xs",children:"PDF dos termos (opcional)"}),o.jsxs("div",{className:"flex gap-1 p-0.5 bg-muted rounded-md",children:[o.jsx("button",{type:"button",onClick:()=>S("link"),className:`flex-1 text-[11px] py-1 rounded transition-colors ${C==="link"?"bg-background shadow-sm font-medium":"text-muted-foreground hover:text-foreground"}`,children:"Link externo"}),o.jsx("button",{type:"button",onClick:()=>S("upload"),className:`flex-1 text-[11px] py-1 rounded transition-colors ${C==="upload"?"bg-background shadow-sm font-medium":"text-muted-foreground hover:text-foreground"}`,children:"Upload de PDF"})]}),C==="link"?o.jsxs("div",{className:"space-y-1",children:[o.jsx(ue,{value:e.termoPdfUrl||"",onChange:A=>a({termoPdfUrl:A.target.value||void 0}),className:"h-8 text-sm",placeholder:"https://exemplo.com/termos.pdf"}),o.jsx("p",{className:"text-[9px] text-muted-foreground",children:"URL pública de um PDF. Tem prioridade sobre o texto acima."})]}):o.jsxs("div",{className:"space-y-2",children:[e.termoPdfUploadId&&$.status==="idle"?o.jsxs("div",{className:"flex items-center gap-2 rounded border border-green-500/40 bg-green-500/10 px-2 py-1.5",children:[o.jsx(_.CheckCircle2,{className:"h-3.5 w-3.5 text-green-600 shrink-0"}),o.jsx("span",{className:"text-[11px] text-green-700 dark:text-green-400 flex-1",children:"PDF enviado ✓"}),o.jsx(De,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>O(e.termoPdfUploadId),children:o.jsx(_.X,{className:"h-3 w-3"})})]}):null,$.status==="uploading"?o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:[o.jsx(_.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),o.jsx("span",{className:"truncate",children:$.fileName}),o.jsxs("span",{className:"ml-auto",children:[$.progress,"%"]})]}),o.jsx(el,{value:$.progress,className:"h-1"})]}):null,$.status==="error"?o.jsxs("div",{className:"flex items-center gap-2 rounded border border-destructive/40 bg-destructive/10 px-2 py-1.5",children:[o.jsx(_.AlertCircle,{className:"h-3.5 w-3.5 text-destructive shrink-0"}),o.jsx("span",{className:"text-[11px] text-destructive",children:$.message}),o.jsx(De,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 ml-auto",onClick:()=>k({status:"idle"}),children:o.jsx(_.X,{className:"h-3 w-3"})})]}):null,$.status!=="uploading"?o.jsxs(o.Fragment,{children:[o.jsx("input",{ref:E,type:"file",accept:"application/pdf",className:"hidden",onChange:A=>{var z;const X=(z=A.target.files)==null?void 0:z[0];X&&L(X),A.target.value=""}}),o.jsxs(De,{type:"button",variant:"outline",size:"sm",className:"w-full h-8 text-xs gap-1.5",disabled:!v,onClick:()=>{var A;return(A=E.current)==null?void 0:A.click()},children:[o.jsx(_.Upload,{className:"h-3.5 w-3.5"}),e.termoPdfUploadId?"Substituir PDF":"Selecionar PDF"]}),!v&&o.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Salve o schema uma vez para habilitar o upload."})]}):null]})]})]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Nome (chave)"}),o.jsx(ue,{value:e.name||t.replace(/^field_/,""),onChange:A=>!c&&a({name:A.target.value}),className:"h-8 text-xs font-mono",placeholder:"nome_do_campo",disabled:c}),c?o.jsx("p",{className:"text-[9px] text-amber-500",children:"ID fixo — necessário para auto-preenchimento"}):o.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Usado como chave no JSON do formulário"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Tipo do campo"}),o.jsxs(Bt,{value:s,onValueChange:A=>!c&&a({fieldType:A}),disabled:c,children:[o.jsx(Rt,{className:"h-8 text-sm",children:o.jsx(Ut,{})}),o.jsx(It,{children:Or.map(A=>o.jsx(qe,{value:A.component,children:A.label},A.component))})]})]}),o.jsx(Xh,{tamanho:e.tamanho||6,inicioColuna:e.inicioColuna||1,defaultTamanho:6,onTamanhoChange:A=>a({tamanho:A}),onPositionChange:A=>a({inicioColuna:A})}),s!=="file"&&!l&&o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(ie,{className:"text-xs",children:"Placeholder"}),o.jsx(yr,{})]}),o.jsx(ue,{value:e.placeholder||"",onChange:A=>a({placeholder:A.target.value}),className:"h-8 text-sm",placeholder:"Texto de exemplo..."})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(ie,{className:"text-xs",children:"Dica (hint)"}),o.jsx(yr,{})]}),o.jsx(ue,{value:e.hint||"",onChange:A=>a({hint:A.target.value}),className:"h-8 text-sm",placeholder:"Texto de ajuda abaixo do campo"})]}),s!=="file"&&!l&&!y&&o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Valor padrão"}),o.jsx(ue,{value:e.defaultValue||"",onChange:A=>a({defaultValue:A.target.value}),className:"h-8 text-sm",placeholder:"Valor inicial do campo"})]}),s!=="file"&&!l&&!y&&o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(ie,{className:"text-xs",children:"Valor inicial (runtime)"}),o.jsx(yr,{})]}),o.jsx(ue,{value:e.initialValue||"",onChange:A=>a({initialValue:A.target.value||void 0}),className:"h-8 text-sm",placeholder:"{{evento.nome}} ou valor fixo"}),o.jsxs("p",{className:"text-[9px] text-muted-foreground",children:['Sobrepõe "Valor padrão" — suporta variáveis'," ",o.jsx("code",{children:"{{evento.x}}"})]})]}),!l&&!y&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(et,{id:"req",checked:e.required||!1,onCheckedChange:A=>a({required:A===!0})}),o.jsx(ie,{htmlFor:"req",className:"text-xs cursor-pointer",children:"Campo obrigatório"})]}),!l&&!y&&!c&&!p&&o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(et,{id:"readonly",checked:e.isReadOnly||!1,onCheckedChange:A=>a({isReadOnly:A===!0||void 0})}),o.jsx(ie,{htmlFor:"readonly",className:"text-xs cursor-pointer",children:"Somente leitura"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(et,{id:"disabled",checked:e.isDisabled||!1,onCheckedChange:A=>a({isDisabled:A===!0||void 0})}),o.jsx(ie,{htmlFor:"disabled",className:"text-xs cursor-pointer",children:"Desabilitado"})]})]}),f&&o.jsxs(o.Fragment,{children:[o.jsx(it,{}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("h4",{className:"text-xs font-semibold text-muted-foreground uppercase",children:"Slider"}),o.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Mínimo"}),o.jsx(ue,{type:"number",value:e.minValue??0,onChange:A=>a({minValue:Number(A.target.value)}),className:"h-8 text-sm"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Máximo"}),o.jsx(ue,{type:"number",value:e.maxValue??100,onChange:A=>a({maxValue:Number(A.target.value)}),className:"h-8 text-sm"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Passo"}),o.jsx(ue,{type:"number",min:1,value:e.step??1,onChange:A=>a({step:Number(A.target.value)}),className:"h-8 text-sm"})]})]})]})]}),h&&o.jsxs(o.Fragment,{children:[o.jsx(it,{}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("h4",{className:"text-xs font-semibold text-muted-foreground uppercase",children:"Avaliação"}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Número de estrelas"}),o.jsxs(Bt,{value:String(e.maxRating??5),onValueChange:A=>a({maxRating:Number(A)}),children:[o.jsx(Rt,{className:"h-8 text-sm",children:o.jsx(Ut,{})}),o.jsx(It,{children:[3,4,5,6,7,10].map(A=>o.jsxs(qe,{value:String(A),children:[A," estrelas"]},A))})]})]})]})]}),x&&o.jsxs(o.Fragment,{children:[o.jsx(it,{}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("h4",{className:"text-xs font-semibold text-muted-foreground uppercase",children:"Período"}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Label da data inicial"}),o.jsx(ue,{value:e.dateRangeStartLabel??"Data inicial",onChange:A=>a({dateRangeStartLabel:A.target.value}),className:"h-8 text-sm"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Label da data final"}),o.jsx(ue,{value:e.dateRangeEndLabel??"Data final",onChange:A=>a({dateRangeEndLabel:A.target.value}),className:"h-8 text-sm"})]})]})]}),!l&&o.jsx(it,{}),!l&&!m&&!b&&o.jsx(XC,{fieldType:s,validation:e.validation,onChange:A=>a({validation:A})}),i&&o.jsxs(o.Fragment,{children:[o.jsx(it,{}),s==="radio"&&o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Estilo visual"}),o.jsxs(Bt,{value:e.visualStyle||"card",onValueChange:A=>a({visualStyle:A}),children:[o.jsx(Rt,{className:"h-8 text-sm",children:o.jsx(Ut,{})}),o.jsxs(It,{children:[o.jsx(qe,{value:"card",children:"Card (padrão)"}),o.jsx(qe,{value:"default",children:"Radio simples"})]})]})]}),o.jsx(Kh,{options:e.options||[],onChange:A=>a({options:A})})]}),l&&o.jsxs(o.Fragment,{children:[o.jsx(it,{}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("h4",{className:"text-xs font-semibold text-muted-foreground uppercase",children:"Lista de itens"}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Mín. itens"}),o.jsx(ue,{type:"number",min:0,value:e.minItems??"",onChange:A=>a({minItems:A.target.value?Number(A.target.value):void 0}),className:"h-8 text-sm",placeholder:"0"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Máx. itens"}),o.jsx(ue,{type:"number",min:0,value:e.maxItems??"",onChange:A=>a({maxItems:A.target.value?Number(A.target.value):void 0}),className:"h-8 text-sm",placeholder:"Sem limite"})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Label do item"}),o.jsx(ue,{value:e.itemLabel||"",onChange:A=>a({itemLabel:A.target.value||void 0}),className:"h-8 text-sm",placeholder:"Ex: Contato"}),o.jsx("p",{className:"text-[9px] text-muted-foreground",children:'Prefixo exibido em cada item (ex: "Contato 1", "Contato 2")'})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Label do botão adicionar"}),o.jsx(ue,{value:e.addLabel||"",onChange:A=>a({addLabel:A.target.value||void 0}),className:"h-8 text-sm",placeholder:"Ex: Adicionar contato"})]}),o.jsx("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/5 px-3 py-2",children:o.jsx("p",{className:"text-[11px] text-amber-700 dark:text-amber-400",children:"Os sub-campos são configurados visualmente no canvas: arraste campos da paleta para dentro da caixa laranja."})})]})]}),y&&o.jsxs(o.Fragment,{children:[o.jsx(it,{}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("h4",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Sub-formulário"}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Título do grupo (opcional)"}),o.jsx(ue,{value:e.subSchemaTitle||"",onChange:A=>a({subSchemaTitle:A.target.value||void 0}),className:"h-8 text-sm",placeholder:"Ex: Endereço, Responsável..."})]}),o.jsx(JC,{subFields:e.subSchemaFields||[],onChange:A=>a({subSchemaFields:A})})]})]}),!b&&!m&&o.jsxs(o.Fragment,{children:[o.jsx(it,{}),o.jsx(YC,{condition:e.condition,selectedId:t,allFieldIds:r,getFieldLabel:n,onChange:A=>a({condition:A})})]}),!b&&!m&&e.condition&&o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Valor ao ocultar (clearedValue)"}),o.jsx(ue,{value:e.clearedValue??"",onChange:A=>a({clearedValue:A.target.value||void 0}),className:"h-8 text-sm",placeholder:"Deixar vazio = não limpar"}),o.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Valor aplicado automaticamente quando o campo fica oculto."})]}),!l&&!y&&o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs text-muted-foreground",children:"Resolver de props (avançado)"}),o.jsx(ue,{value:e.resolvePropsKey||"",onChange:A=>a({resolvePropsKey:A.target.value||void 0}),className:"h-8 text-xs font-mono",placeholder:"chaveDoResolver"}),o.jsxs("p",{className:"text-[9px] text-muted-foreground",children:["Registre este key em"," ",o.jsx("code",{children:"RendererContext.fieldResolvers"})," para opções dinâmicas."]})]})]})]})},eN={glassmorphism:"Glass",card:"Card",flat:"Flat",bordered:"Bordered"},Yh=()=>{const{previewTemplateId:e,setPreviewTemplateId:t}=gt(),[r,n]=N.useState(!1),a=Object.values(Kr),s=Kr[e];return o.jsxs(Po,{open:r,onOpenChange:n,children:[o.jsx(_o,{asChild:!0,children:o.jsxs(De,{variant:"outline",size:"sm",className:"gap-1.5",title:"Selecionar template visual",children:[o.jsx("span",{className:"w-3.5 h-3.5 rounded-full shrink-0 border border-white/20",style:{background:(s==null?void 0:s.colors.primary)??"#3b82f6"}}),o.jsx(_.Palette,{className:"w-3.5 h-3.5"}),o.jsx("span",{className:"hidden sm:inline",children:(s==null?void 0:s.displayName)??"Template"})]})}),o.jsxs(fa,{side:"bottom",align:"end",className:"w-80 p-3",children:[o.jsx("p",{className:"text-xs font-semibold text-muted-foreground mb-2 uppercase tracking-wider",children:"Template de Preview"}),o.jsx("div",{className:"grid grid-cols-3 gap-1.5 max-h-72 overflow-y-auto pr-0.5",children:a.map(i=>{const l=i.id===e,c=su(i),d=eN[i.layout.containerStyle]??"";return o.jsxs("button",{onClick:()=>{t(i.id),n(!1)},className:Ht("relative flex flex-col items-center gap-1.5 rounded-lg p-2 border text-center transition-all hover:scale-[1.02]",l?"border-primary ring-1 ring-primary":"border-border hover:border-muted-foreground/40"),children:[o.jsxs("div",{className:"w-full h-8 rounded-md flex items-center justify-center gap-0.5",style:{background:i.colors.background.startsWith("#")||i.colors.background.startsWith("rgba")?i.colors.background:void 0},"data-muted":!i.colors.background.startsWith("#")&&!i.colors.background.startsWith("rgba")?"true":void 0,children:[o.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:i.colors.primary}}),o.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:i.colors.accent}})]}),o.jsx("span",{className:"text-[10px] font-medium leading-tight line-clamp-2",children:i.displayName}),o.jsxs("div",{className:"flex items-center gap-0.5 flex-wrap justify-center",children:[c&&o.jsx("span",{className:"text-[9px] px-1 rounded bg-zinc-800 text-zinc-300",children:"dark"}),d&&o.jsx("span",{className:"text-[9px] px-1 rounded bg-muted text-muted-foreground",children:d})]}),l&&o.jsx("div",{className:"absolute top-1 right-1",children:o.jsx(_.Check,{className:"w-3 h-3 text-primary"})})]},i.id)})})]})]})},tN=[{value:"numbers",label:"Números"},{value:"icons",label:"Ícones"},{value:"icons-labeled",label:"Ícones + rótulo"}],rN=[{value:"top-center",label:"Centralizado"},{value:"top-left",label:"Esquerda"}],nN=[{value:"horizontal",label:"Horizontal"},{value:"vertical",label:"Vertical (sidebar)"}],aN=()=>{const{stepConfig:e,updateStepConfig:t}=gt();return o.jsxs("div",{className:"space-y-5",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Template visual"}),o.jsx(Yh,{})]}),o.jsx(it,{}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Indicador de steps"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(et,{id:"sc-show-indicators",checked:e.showStepIndicators!==!1,onCheckedChange:r=>t({showStepIndicators:r===!0})}),o.jsx(ie,{htmlFor:"sc-show-indicators",className:"text-xs cursor-pointer",children:"Exibir indicador de steps"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(et,{id:"sc-show-progress",checked:e.showProgressBar===!0,onCheckedChange:r=>t({showProgressBar:r===!0})}),o.jsx(ie,{htmlFor:"sc-show-progress",className:"text-xs cursor-pointer",children:"Exibir barra de progresso"})]})]}),o.jsx(it,{}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ie,{className:"text-xs",children:"Variante visual"}),o.jsx("div",{className:"flex flex-col gap-1.5",children:tN.map(r=>o.jsx("button",{type:"button",onClick:()=>t({stepIndicatorVariant:r.value}),className:`text-left text-xs px-3 py-1.5 rounded-md border transition-colors ${e.stepIndicatorVariant===r.value?"border-primary bg-primary/10 text-primary font-medium":"border-border bg-muted/30 text-muted-foreground hover:bg-muted/60"}`,children:r.label},r.value))}),!e.stepIndicatorVariant&&o.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Herdado do template"})]}),o.jsx(it,{}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ie,{className:"text-xs",children:"Orientação"}),o.jsx("div",{className:"flex gap-2",children:nN.map(r=>o.jsx("button",{type:"button",onClick:()=>t({stepIndicatorOrientation:r.value}),className:`flex-1 text-xs px-2 py-1.5 rounded-md border transition-colors ${e.stepIndicatorOrientation===r.value?"border-primary bg-primary/10 text-primary font-medium":"border-border bg-muted/30 text-muted-foreground hover:bg-muted/60"}`,children:r.label},r.value))}),!e.stepIndicatorOrientation&&o.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Herdado do template"})]}),o.jsx(it,{}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ie,{className:"text-xs",children:"Posição (desktop)"}),o.jsx("div",{className:"flex gap-2",children:rN.map(r=>o.jsx("button",{type:"button",onClick:()=>t({stepIndicatorPosition:r.value}),className:`flex-1 text-xs px-2 py-1.5 rounded-md border transition-colors ${e.stepIndicatorPosition===r.value?"border-primary bg-primary/10 text-primary font-medium":"border-border bg-muted/30 text-muted-foreground hover:bg-muted/60"}`,children:r.label},r.value))}),!e.stepIndicatorPosition&&o.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Herdado do template"})]})]})},oN=()=>{const{selectedId:e,getConfig:t,updateConfig:r,getAllFieldIds:n}=gt();if(!e)return o.jsxs("div",{className:"rounded-xl border bg-card p-4 space-y-4 max-h-[calc(100vh-160px)] overflow-y-auto",children:[o.jsx("div",{className:"flex items-center justify-between",children:o.jsx("h3",{className:"text-sm font-bold text-foreground",children:"Formulário"})}),o.jsx(it,{}),o.jsx(aN,{})]});const a=t(e),s=He(e),i=c=>r(e,c),l=n().filter(c=>c!==e);return o.jsxs("div",{className:"rounded-xl border bg-card p-4 space-y-4 max-h-[calc(100vh-160px)] overflow-y-auto",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("h3",{className:"text-sm font-bold text-foreground",children:s==="step"?"Step":s==="container"?"Container":"Campo"}),o.jsx("span",{className:"text-[10px] font-mono text-muted-foreground",children:e})]}),o.jsx(it,{}),s==="step"&&o.jsx(LC,{config:a,onUpdate:i}),s==="container"&&o.jsx(VC,{config:a,onUpdate:i}),s==="field"&&o.jsx(QC,{config:a,selectedId:e,allFieldIds:l,getFieldLabel:c=>t(c).label||c,onUpdate:i})]})};var ga=e=>e.type==="checkbox",Zr=e=>e instanceof Date,bt=e=>e==null;const Jh=e=>typeof e=="object";var tt=e=>!bt(e)&&!Array.isArray(e)&&Jh(e)&&!Zr(e),Qh=e=>tt(e)&&e.target?ga(e.target)?e.target.checked:e.target.value:e,sN=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,ex=(e,t)=>e.has(sN(t)),iN=e=>{const t=e.constructor&&e.constructor.prototype;return tt(t)&&t.hasOwnProperty("isPrototypeOf")},Cl=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Le(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(Cl&&(e instanceof Blob||t))return e;const r=Array.isArray(e);if(!r&&!(tt(e)&&iN(e)))return e;const n=r?[]:Object.create(Object.getPrototypeOf(e));for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=Le(e[a]));return n}var Xo=e=>/^\w*$/.test(e),Oe=e=>e===void 0,Zo=e=>Array.isArray(e)?e.filter(Boolean):[],Nl=e=>Zo(e.replace(/["|']|\]/g,"").split(/\.|\[/)),ae=(e,t,r)=>{if(!t||!tt(e))return r;const n=(Xo(t)?[t]:Nl(t)).reduce((a,s)=>bt(a)?a:a[s],e);return Oe(n)||n===e?Oe(e[t])?r:e[t]:n},$t=e=>typeof e=="boolean",ht=e=>typeof e=="function",_e=(e,t,r)=>{let n=-1;const a=Xo(t)?[t]:Nl(t),s=a.length,i=s-1;for(;++n<s;){const l=a[n];let c=r;if(n!==i){const d=e[l];c=tt(d)||Array.isArray(d)?d:isNaN(+a[n+1])?{}:[]}if(l==="__proto__"||l==="constructor"||l==="prototype")return;e[l]=c,e=e[l]}};const ao={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},zt={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},gr={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Sl=N.createContext(null);Sl.displayName="HookFormControlContext";const Ko=()=>N.useContext(Sl);var tx=(e,t,r,n=!0)=>{const a={defaultValues:t._defaultValues};for(const s in e)Object.defineProperty(a,s,{get:()=>{const i=s;return t._proxyFormState[i]!==zt.all&&(t._proxyFormState[i]=!n||zt.all),r&&(r[i]=!0),e[i]}});return a};const Yo=typeof window<"u"?N.useLayoutEffect:N.useEffect;function rx(e){const t=Ko(),{control:r=t,disabled:n,name:a,exact:s}=e||{},[i,l]=N.useState(r._formState),c=N.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Yo(()=>r._subscribe({name:a,formState:c.current,exact:s,callback:d=>{!n&&l({...r._formState,...d})}}),[a,n,s]),N.useEffect(()=>{c.current.isValid&&r._setValid(!0)},[r]),N.useMemo(()=>tx(i,r,c.current,!1),[i,r])}var Dt=e=>typeof e=="string",pi=(e,t,r,n,a)=>Dt(e)?(n&&t.watch.add(e),ae(r,e,a)):Array.isArray(e)?e.map(s=>(n&&t.watch.add(s),ae(r,s))):(n&&(t.watchAll=!0),r),fi=e=>bt(e)||!Jh(e);function Kt(e,t,r=new WeakSet){if(fi(e)||fi(t))return Object.is(e,t);if(Zr(e)&&Zr(t))return Object.is(e.getTime(),t.getTime());const n=Object.keys(e),a=Object.keys(t);if(n.length!==a.length)return!1;if(r.has(e)||r.has(t))return!0;r.add(e),r.add(t);for(const s of n){const i=e[s];if(!a.includes(s))return!1;if(s!=="ref"){const l=t[s];if(Zr(i)&&Zr(l)||tt(i)&&tt(l)||Array.isArray(i)&&Array.isArray(l)?!Kt(i,l,r):!Object.is(i,l))return!1}}return!0}function Mn(e){const t=Ko(),{control:r=t,name:n,defaultValue:a,disabled:s,exact:i,compute:l}=e||{},c=N.useRef(a),d=N.useRef(l),u=N.useRef(void 0),m=N.useRef(r),p=N.useRef(n);d.current=l;const[f,b]=N.useState(()=>{const w=r._getWatch(n,c.current);return d.current?d.current(w):w}),h=N.useCallback(w=>{const C=pi(n,r._names,w||r._formValues,!1,c.current);return d.current?d.current(C):C},[r._formValues,r._names,n]),x=N.useCallback(w=>{if(!s){const C=pi(n,r._names,w||r._formValues,!1,c.current);if(d.current){const S=d.current(C);Kt(S,u.current)||(b(S),u.current=S)}else b(C)}},[r._formValues,r._names,s,n]);Yo(()=>((m.current!==r||!Kt(p.current,n))&&(m.current=r,p.current=n,x()),r._subscribe({name:n,formState:{values:!0},exact:i,callback:w=>{x(w.values)}})),[r,i,n,x]),N.useEffect(()=>r._removeUnmounted());const y=m.current!==r,v=p.current,j=N.useMemo(()=>{if(s)return null;const w=!y&&!Kt(v,n);return y||w?h():null},[s,y,n,v,h]);return j!==null?j:f}function Me(e){const t=Ko(),{name:r,disabled:n,control:a=t,shouldUnregister:s,defaultValue:i,exact:l=!0}=e,c=ex(a._names.array,r),d=N.useMemo(()=>ae(a._formValues,r,ae(a._defaultValues,r,i)),[a,r,i]),u=Mn({control:a,name:r,defaultValue:d,exact:l}),m=rx({control:a,name:r,exact:l}),p=N.useRef(e),f=N.useRef(void 0),b=N.useRef(a.register(r,{...e.rules,value:u,...$t(e.disabled)?{disabled:e.disabled}:{}}));p.current=e;const h=N.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!ae(m.errors,r)},isDirty:{enumerable:!0,get:()=>!!ae(m.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!ae(m.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!ae(m.validatingFields,r)},error:{enumerable:!0,get:()=>ae(m.errors,r)}}),[m,r]),x=N.useCallback(w=>b.current.onChange({target:{value:Qh(w),name:r},type:ao.CHANGE}),[r]),y=N.useCallback(()=>b.current.onBlur({target:{value:ae(a._formValues,r),name:r},type:ao.BLUR}),[r,a._formValues]),v=N.useCallback(w=>{const C=ae(a._fields,r);C&&C._f&&w&&(C._f.ref={focus:()=>ht(w.focus)&&w.focus(),select:()=>ht(w.select)&&w.select(),setCustomValidity:S=>ht(w.setCustomValidity)&&w.setCustomValidity(S),reportValidity:()=>ht(w.reportValidity)&&w.reportValidity()})},[a._fields,r]),j=N.useMemo(()=>({name:r,value:u,...$t(n)||m.disabled?{disabled:m.disabled||n}:{},onChange:x,onBlur:y,ref:v}),[r,n,m.disabled,x,y,v,u]);return N.useEffect(()=>{const w=a._options.shouldUnregister||s,C=f.current;C&&C!==r&&!c&&a.unregister(C),a.register(r,{...p.current.rules,...$t(p.current.disabled)?{disabled:p.current.disabled}:{}});const S=($,k)=>{const E=ae(a._fields,$);E&&E._f&&(E._f.mount=k)};if(S(r,!0),w){const $=Le(ae(a._options.defaultValues,r,p.current.defaultValue));_e(a._defaultValues,r,$),Oe(ae(a._formValues,r))&&_e(a._formValues,r,$)}return!c&&a.register(r),f.current=r,()=>{(c?w&&!a._state.action:w)?a.unregister(r):S(r,!1)}},[r,a,c,s]),N.useEffect(()=>{a._setDisabledField({disabled:n,name:r})},[n,r,a]),N.useMemo(()=>({field:j,formState:m,fieldState:h}),[j,m,h])}const $l=N.createContext(null);$l.displayName="HookFormContext";const lN=()=>N.useContext($l),cN=e=>{const{children:t,watch:r,getValues:n,getFieldState:a,setError:s,clearErrors:i,setValue:l,trigger:c,formState:d,resetField:u,reset:m,handleSubmit:p,unregister:f,control:b,register:h,setFocus:x,subscribe:y}=e;return N.createElement($l.Provider,{value:N.useMemo(()=>({watch:r,getValues:n,getFieldState:a,setError:s,clearErrors:i,setValue:l,trigger:c,formState:d,resetField:u,reset:m,handleSubmit:p,unregister:f,control:b,register:h,setFocus:x,subscribe:y}),[i,b,d,a,n,p,h,m,u,s,x,l,y,c,f,r])},N.createElement(Sl.Provider,{value:b},t))};var dN=(e,t,r,n,a)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[n]:a||!0}}:{},yt=e=>Array.isArray(e)?e:[e],vd=()=>{let e=[];return{get observers(){return e},next:t=>{for(const r of e)r.next&&r.next(t)},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter(r=>r!==t)}}),unsubscribe:()=>{e=[]}}};function nx(e,t){const r={};for(const n in e)if(e.hasOwnProperty(n)){const a=e[n],s=t[n];if(a&&tt(a)&&s){const i=nx(a,s);tt(i)&&(r[n]=i)}else e[n]&&(r[n]=s)}return r}var ct=e=>tt(e)&&!Object.keys(e).length,El=e=>e.type==="file",oo=e=>{if(!Cl)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},ax=e=>e.type==="select-multiple",Dl=e=>e.type==="radio",uN=e=>Dl(e)||ga(e),$s=e=>oo(e)&&e.isConnected;function mN(e,t){const r=t.slice(0,-1).length;let n=0;for(;n<r;)e=Oe(e)?n++:e[t[n++]];return e}function pN(e){for(const t in e)if(e.hasOwnProperty(t)&&!Oe(e[t]))return!1;return!0}function Be(e,t){const r=Array.isArray(t)?t:Xo(t)?[t]:Nl(t),n=r.length===1?e:mN(e,r),a=r.length-1,s=r[a];return n&&delete n[s],a!==0&&(tt(n)&&ct(n)||Array.isArray(n)&&pN(n))&&Be(e,r.slice(0,-1)),e}var fN=e=>{for(const t in e)if(ht(e[t]))return!0;return!1};function ox(e){return Array.isArray(e)||tt(e)&&!fN(e)}function hi(e,t={}){for(const r in e){const n=e[r];ox(n)?(t[r]=Array.isArray(n)?[]:{},hi(n,t[r])):Oe(n)||(t[r]=!0)}return t}function vn(e,t,r){r||(r=hi(t));for(const n in e){const a=e[n];if(ox(a))Oe(t)||fi(r[n])?r[n]=hi(a,Array.isArray(a)?[]:{}):vn(a,bt(t)?{}:t[n],r[n]);else{const s=t[n];r[n]=!Kt(a,s)}}return r}const bd={value:!1,isValid:!1},yd={value:!0,isValid:!0};var sx=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(r=>r&&r.checked&&!r.disabled).map(r=>r.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Oe(e[0].attributes.value)?Oe(e[0].value)||e[0].value===""?yd:{value:e[0].value,isValid:!0}:yd:bd}return bd},ix=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:n})=>Oe(e)?e:t?e===""?NaN:e&&+e:r&&Dt(e)?new Date(e):n?n(e):e;const wd={isValid:!1,value:null};var lx=e=>Array.isArray(e)?e.reduce((t,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:t,wd):wd;function jd(e){const t=e.ref;return El(t)?t.files:Dl(t)?lx(e.refs).value:ax(t)?[...t.selectedOptions].map(({value:r})=>r):ga(t)?sx(e.refs).value:ix(Oe(t.value)?e.ref.value:t.value,e)}var hN=(e,t,r,n)=>{const a={};for(const s of e){const i=ae(t,s);i&&_e(a,s,i._f)}return{criteriaMode:r,names:[...e],fields:a,shouldUseNativeValidation:n}},so=e=>e instanceof RegExp,Gn=e=>Oe(e)?e:so(e)?e.source:tt(e)?so(e.value)?e.value.source:e.value:e,wn=e=>({isOnSubmit:!e||e===zt.onSubmit,isOnBlur:e===zt.onBlur,isOnChange:e===zt.onChange,isOnAll:e===zt.all,isOnTouch:e===zt.onTouched});const kd="AsyncFunction";var xN=e=>!!e&&!!e.validate&&!!(ht(e.validate)&&e.validate.constructor.name===kd||tt(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===kd)),gN=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),xi=(e,t,r)=>!r&&(t.watchAll||t.watch.has(e)||[...t.watch].some(n=>e.startsWith(n)&&/^\.\w+/.test(e.slice(n.length))));const Sn=(e,t,r,n)=>{for(const a of r||Object.keys(e)){const s=ae(e,a);if(s){const{_f:i,...l}=s;if(i){if(i.refs&&i.refs[0]&&t(i.refs[0],a)&&!n||i.ref&&t(i.ref,i.name)&&!n)return!0;if(Sn(l,t))break}else if(tt(l)&&Sn(l,t))break}}};function Cd(e,t,r){const n=ae(e,r);if(n||Xo(r))return{error:n,name:r};const a=r.split(".");for(;a.length;){const s=a.join("."),i=ae(t,s),l=ae(e,s);if(i&&!Array.isArray(i)&&r!==s)return{name:r};if(l&&l.type)return{name:s,error:l};if(l&&l.root&&l.root.type)return{name:`${s}.root`,error:l.root};a.pop()}return{name:r}}var vN=(e,t,r,n)=>{r(e);const{name:a,...s}=e;return ct(s)||Object.keys(s).length>=Object.keys(t).length||Object.keys(s).find(i=>t[i]===(!n||zt.all))},bN=(e,t,r)=>!e||!t||e===t||yt(e).some(n=>n&&(r?n===t:n.startsWith(t)||t.startsWith(n))),yN=(e,t,r,n,a)=>a.isOnAll?!1:!r&&a.isOnTouch?!(t||e):(r?n.isOnBlur:a.isOnBlur)?!e:(r?n.isOnChange:a.isOnChange)?e:!0,wN=(e,t)=>!Zo(ae(e,t)).length&&Be(e,t),cx=(e,t,r)=>{const n=yt(ae(e,r));return _e(n,"root",t[r]),_e(e,r,n),e};function Nd(e,t,r="validate"){if(Dt(e)||Array.isArray(e)&&e.every(Dt)||$t(e)&&!e)return{type:r,message:Dt(e)?e:"",ref:t}}var hn=e=>tt(e)&&!so(e)?e:{value:e,message:""},gi=async(e,t,r,n,a,s)=>{const{ref:i,refs:l,required:c,maxLength:d,minLength:u,min:m,max:p,pattern:f,validate:b,name:h,valueAsNumber:x,mount:y}=e._f,v=ae(r,h);if(!y||t.has(h))return{};const j=l?l[0]:i,w=L=>{a&&j.reportValidity&&(j.setCustomValidity($t(L)?"":L||""),j.reportValidity())},C={},S=Dl(i),$=ga(i),k=S||$,E=(x||El(i))&&Oe(i.value)&&Oe(v)||oo(i)&&i.value===""||v===""||Array.isArray(v)&&!v.length,D=dN.bind(null,h,n,C),O=(L,A,z,X=gr.maxLength,q=gr.minLength)=>{const Z=L?A:z;C[h]={type:L?X:q,message:Z,ref:i,...D(L?X:q,Z)}};if(s?!Array.isArray(v)||!v.length:c&&(!k&&(E||bt(v))||$t(v)&&!v||$&&!sx(l).isValid||S&&!lx(l).isValid)){const{value:L,message:A}=Dt(c)?{value:!!c,message:c}:hn(c);if(L&&(C[h]={type:gr.required,message:A,ref:j,...D(gr.required,A)},!n))return w(A),C}if(!E&&(!bt(m)||!bt(p))){let L,A;const z=hn(p),X=hn(m);if(!bt(v)&&!isNaN(v)){const q=i.valueAsNumber||v&&+v;bt(z.value)||(L=q>z.value),bt(X.value)||(A=q<X.value)}else{const q=i.valueAsDate||new Date(v),Z=P=>new Date(new Date().toDateString()+" "+P),V=i.type=="time",M=i.type=="week";Dt(z.value)&&v&&(L=V?Z(v)>Z(z.value):M?v>z.value:q>new Date(z.value)),Dt(X.value)&&v&&(A=V?Z(v)<Z(X.value):M?v<X.value:q<new Date(X.value))}if((L||A)&&(O(!!L,z.message,X.message,gr.max,gr.min),!n))return w(C[h].message),C}if((d||u)&&!E&&(Dt(v)||s&&Array.isArray(v))){const L=hn(d),A=hn(u),z=!bt(L.value)&&v.length>+L.value,X=!bt(A.value)&&v.length<+A.value;if((z||X)&&(O(z,L.message,A.message),!n))return w(C[h].message),C}if(f&&!E&&Dt(v)){const{value:L,message:A}=hn(f);if(so(L)&&!v.match(L)&&(C[h]={type:gr.pattern,message:A,ref:i,...D(gr.pattern,A)},!n))return w(A),C}if(b){if(ht(b)){const L=await b(v,r),A=Nd(L,j);if(A&&(C[h]={...A,...D(gr.validate,A.message)},!n))return w(A.message),C}else if(tt(b)){let L={};for(const A in b){if(!ct(L)&&!n)break;const z=Nd(await b[A](v,r),j,A);z&&(L={...z,...D(A,z.message)},w(z.message),n&&(C[h]=L))}if(!ct(L)&&(C[h]={ref:j,...L},!n))return C}}return w(!0),C};const jN={mode:zt.onSubmit,reValidateMode:zt.onChange,shouldFocusError:!0};function kN(e={}){let t={...jN,...e},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:ht(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},n={},a=tt(t.defaultValues)||tt(t.values)?Le(t.defaultValues||t.values)||{}:{},s=t.shouldUnregister?{}:Le(a),i={action:!1,mount:!1,watch:!1,keepIsValid:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},c,d=0;const u={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},m={...u};let p={...m};const f={array:vd(),state:vd()},b=t.criteriaMode===zt.all,h=I=>F=>{clearTimeout(d),d=setTimeout(I,F)},x=async I=>{if(!i.keepIsValid&&!t.disabled&&(m.isValid||p.isValid||I)){let F;t.resolver?(F=ct((await k()).errors),y()):F=await D(n,!0),F!==r.isValid&&f.state.next({isValid:F})}},y=(I,F)=>{!t.disabled&&(m.isValidating||m.validatingFields||p.isValidating||p.validatingFields)&&((I||Array.from(l.mount)).forEach(B=>{B&&(F?_e(r.validatingFields,B,F):Be(r.validatingFields,B))}),f.state.next({validatingFields:r.validatingFields,isValidating:!ct(r.validatingFields)}))},v=(I,F=[],B,le,oe=!0,re=!0)=>{if(le&&B&&!t.disabled){if(i.action=!0,re&&Array.isArray(ae(n,I))){const ye=B(ae(n,I),le.argA,le.argB);oe&&_e(n,I,ye)}if(re&&Array.isArray(ae(r.errors,I))){const ye=B(ae(r.errors,I),le.argA,le.argB);oe&&_e(r.errors,I,ye),wN(r.errors,I)}if((m.touchedFields||p.touchedFields)&&re&&Array.isArray(ae(r.touchedFields,I))){const ye=B(ae(r.touchedFields,I),le.argA,le.argB);oe&&_e(r.touchedFields,I,ye)}(m.dirtyFields||p.dirtyFields)&&(r.dirtyFields=vn(a,s)),f.state.next({name:I,isDirty:L(I,F),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else _e(s,I,F)},j=(I,F)=>{_e(r.errors,I,F),f.state.next({errors:r.errors})},w=I=>{r.errors=I,f.state.next({errors:r.errors,isValid:!1})},C=(I,F,B,le)=>{const oe=ae(n,I);if(oe){const re=ae(s,I,Oe(B)?ae(a,I):B);Oe(re)||le&&le.defaultChecked||F?_e(s,I,F?re:jd(oe._f)):X(I,re),i.mount&&!i.action&&x()}},S=(I,F,B,le,oe)=>{let re=!1,ye=!1;const Re={name:I};if(!t.disabled){if(!B||le){(m.isDirty||p.isDirty)&&(ye=r.isDirty,r.isDirty=Re.isDirty=L(),re=ye!==Re.isDirty);const Ie=Kt(ae(a,I),F);ye=!!ae(r.dirtyFields,I),Ie?Be(r.dirtyFields,I):_e(r.dirtyFields,I,!0),Re.dirtyFields=r.dirtyFields,re=re||(m.dirtyFields||p.dirtyFields)&&ye!==!Ie}if(B){const Ie=ae(r.touchedFields,I);Ie||(_e(r.touchedFields,I,B),Re.touchedFields=r.touchedFields,re=re||(m.touchedFields||p.touchedFields)&&Ie!==B)}re&&oe&&f.state.next(Re)}return re?Re:{}},$=(I,F,B,le)=>{const oe=ae(r.errors,I),re=(m.isValid||p.isValid)&&$t(F)&&r.isValid!==F;if(t.delayError&&B?(c=h(()=>j(I,B)),c(t.delayError)):(clearTimeout(d),c=null,B?_e(r.errors,I,B):Be(r.errors,I)),(B?!Kt(oe,B):oe)||!ct(le)||re){const ye={...le,...re&&$t(F)?{isValid:F}:{},errors:r.errors,name:I};r={...r,...ye},f.state.next(ye)}},k=async I=>(y(I,!0),await t.resolver(s,t.context,hN(I||l.mount,n,t.criteriaMode,t.shouldUseNativeValidation))),E=async I=>{const{errors:F}=await k(I);if(y(I),I)for(const B of I){const le=ae(F,B);le?_e(r.errors,B,le):Be(r.errors,B)}else r.errors=F;return F},D=async(I,F,B={valid:!0})=>{for(const le in I){const oe=I[le];if(oe){const{_f:re,...ye}=oe;if(re){const Re=l.array.has(re.name),Ie=oe._f&&xN(oe._f);Ie&&m.validatingFields&&y([re.name],!0);const ot=await gi(oe,l.disabled,s,b,t.shouldUseNativeValidation&&!F,Re);if(Ie&&m.validatingFields&&y([re.name]),ot[re.name]&&(B.valid=!1,F||e.shouldUseNativeValidation))break;!F&&(ae(ot,re.name)?Re?cx(r.errors,ot,re.name):_e(r.errors,re.name,ot[re.name]):Be(r.errors,re.name))}!ct(ye)&&await D(ye,F,B)}}return B.valid},O=()=>{for(const I of l.unMount){const F=ae(n,I);F&&(F._f.refs?F._f.refs.every(B=>!$s(B)):!$s(F._f.ref))&&ne(I)}l.unMount=new Set},L=(I,F)=>!t.disabled&&(I&&F&&_e(s,I,F),!Kt(se(),a)),A=(I,F,B)=>pi(I,l,{...i.mount?s:Oe(F)?a:Dt(I)?{[I]:F}:F},B,F),z=I=>Zo(ae(i.mount?s:a,I,t.shouldUnregister?ae(a,I,[]):[])),X=(I,F,B={})=>{const le=ae(n,I);let oe=F;if(le){const re=le._f;re&&(!re.disabled&&_e(s,I,ix(F,re)),oe=oo(re.ref)&&bt(F)?"":F,ax(re.ref)?[...re.ref.options].forEach(ye=>ye.selected=oe.includes(ye.value)):re.refs?ga(re.ref)?re.refs.forEach(ye=>{(!ye.defaultChecked||!ye.disabled)&&(Array.isArray(oe)?ye.checked=!!oe.find(Re=>Re===ye.value):ye.checked=oe===ye.value||!!oe)}):re.refs.forEach(ye=>ye.checked=ye.value===oe):El(re.ref)?re.ref.value="":(re.ref.value=oe,re.ref.type||f.state.next({name:I,values:Le(s)})))}(B.shouldDirty||B.shouldTouch)&&S(I,oe,B.shouldTouch,B.shouldDirty,!0),B.shouldValidate&&P(I)},q=(I,F,B)=>{for(const le in F){if(!F.hasOwnProperty(le))return;const oe=F[le],re=I+"."+le,ye=ae(n,re);(l.array.has(I)||tt(oe)||ye&&!ye._f)&&!Zr(oe)?q(re,oe,B):X(re,oe,B)}},Z=(I,F,B={})=>{const le=ae(n,I),oe=l.array.has(I),re=Le(F);_e(s,I,re),oe?(f.array.next({name:I,values:Le(s)}),(m.isDirty||m.dirtyFields||p.isDirty||p.dirtyFields)&&B.shouldDirty&&f.state.next({name:I,dirtyFields:vn(a,s),isDirty:L(I,re)})):le&&!le._f&&!bt(re)?q(I,re,B):X(I,re,B),xi(I,l)?f.state.next({...r,name:I,values:Le(s)}):f.state.next({name:i.mount?I:void 0,values:Le(s)})},V=async I=>{i.mount=!0;const F=I.target;let B=F.name,le=!0;const oe=ae(n,B),re=Ie=>{le=Number.isNaN(Ie)||Zr(Ie)&&isNaN(Ie.getTime())||Kt(Ie,ae(s,B,Ie))},ye=wn(t.mode),Re=wn(t.reValidateMode);if(oe){let Ie,ot;const tr=F.type?jd(oe._f):Qh(I),rr=I.type===ao.BLUR||I.type===ao.FOCUS_OUT,Qo=!gN(oe._f)&&!t.resolver&&!ae(r.errors,B)&&!oe._f.deps||yN(rr,ae(r.touchedFields,B),r.isSubmitted,Re,ye),Vn=xi(B,l,rr);_e(s,B,tr),rr?(!F||!F.readOnly)&&(oe._f.onBlur&&oe._f.onBlur(I),c&&c(0)):oe._f.onChange&&oe._f.onChange(I);const Bn=S(B,tr,rr),es=!ct(Bn)||Vn;if(!rr&&f.state.next({name:B,type:I.type,values:Le(s)}),Qo)return(m.isValid||p.isValid)&&(t.mode==="onBlur"?rr&&x():rr||x()),es&&f.state.next({name:B,...Vn?{}:Bn});if(!rr&&Vn&&f.state.next({...r}),t.resolver){const{errors:ya}=await k([B]);if(y([B]),re(tr),le){const ts=Cd(r.errors,n,B),sn=Cd(ya,n,ts.name||B);Ie=sn.error,B=sn.name,ot=ct(ya)}}else y([B],!0),Ie=(await gi(oe,l.disabled,s,b,t.shouldUseNativeValidation))[B],y([B]),re(tr),le&&(Ie?ot=!1:(m.isValid||p.isValid)&&(ot=await D(n,!0)));le&&(oe._f.deps&&(!Array.isArray(oe._f.deps)||oe._f.deps.length>0)&&P(oe._f.deps),$(B,ot,Ie,Bn))}},M=(I,F)=>{if(ae(r.errors,F)&&I.focus)return I.focus(),1},P=async(I,F={})=>{let B,le;const oe=yt(I);if(t.resolver){const re=await E(Oe(I)?I:oe);B=ct(re),le=I?!oe.some(ye=>ae(re,ye)):B}else I?(le=(await Promise.all(oe.map(async re=>{const ye=ae(n,re);return await D(ye&&ye._f?{[re]:ye}:ye)}))).every(Boolean),!(!le&&!r.isValid)&&x()):le=B=await D(n);return f.state.next({...!Dt(I)||(m.isValid||p.isValid)&&B!==r.isValid?{}:{name:I},...t.resolver||!I?{isValid:B}:{},errors:r.errors}),F.shouldFocus&&!le&&Sn(n,M,I?oe:l.mount),le},se=(I,F)=>{let B={...i.mount?s:a};return F&&(B=nx(F.dirtyFields?r.dirtyFields:r.touchedFields,B)),Oe(I)?B:Dt(I)?ae(B,I):I.map(le=>ae(B,le))},U=(I,F)=>({invalid:!!ae((F||r).errors,I),isDirty:!!ae((F||r).dirtyFields,I),error:ae((F||r).errors,I),isValidating:!!ae(r.validatingFields,I),isTouched:!!ae((F||r).touchedFields,I)}),Q=I=>{const F=I?yt(I):void 0;F==null||F.forEach(B=>Be(r.errors,B)),F?F.forEach(B=>{f.state.next({name:B,errors:r.errors})}):f.state.next({errors:{}})},Y=(I,F,B)=>{const le=(ae(n,I,{_f:{}})._f||{}).ref,oe=ae(r.errors,I)||{},{ref:re,message:ye,type:Re,...Ie}=oe;_e(r.errors,I,{...Ie,...F,ref:le}),f.state.next({name:I,errors:r.errors,isValid:!1}),B&&B.shouldFocus&&le&&le.focus&&le.focus()},H=(I,F)=>ht(I)?f.state.subscribe({next:B=>"values"in B&&I(A(void 0,F),B)}):A(I,F,!0),W=I=>f.state.subscribe({next:F=>{bN(I.name,F.name,I.exact)&&vN(F,I.formState||m,Nt,I.reRenderRoot)&&I.callback({values:{...s},...r,...F,defaultValues:a})}}).unsubscribe,G=I=>(i.mount=!0,p={...p,...I.formState},W({...I,formState:{...u,...I.formState}})),ne=(I,F={})=>{for(const B of I?yt(I):l.mount)l.mount.delete(B),l.array.delete(B),F.keepValue||(Be(n,B),Be(s,B)),!F.keepError&&Be(r.errors,B),!F.keepDirty&&Be(r.dirtyFields,B),!F.keepTouched&&Be(r.touchedFields,B),!F.keepIsValidating&&Be(r.validatingFields,B),!t.shouldUnregister&&!F.keepDefaultValue&&Be(a,B);f.state.next({values:Le(s)}),f.state.next({...r,...F.keepDirty?{isDirty:L()}:{}}),!F.keepIsValid&&x()},J=({disabled:I,name:F})=>{if($t(I)&&i.mount||I||l.disabled.has(F)){const B=l.disabled.has(F)!==!!I;I?l.disabled.add(F):l.disabled.delete(F),B&&i.mount&&!i.action&&x()}},te=(I,F={})=>{let B=ae(n,I);const le=$t(F.disabled)||$t(t.disabled);return _e(n,I,{...B||{},_f:{...B&&B._f?B._f:{ref:{name:I}},name:I,mount:!0,...F}}),l.mount.add(I),B?J({disabled:$t(F.disabled)?F.disabled:t.disabled,name:I}):C(I,!0,F.value),{...le?{disabled:F.disabled||t.disabled}:{},...t.progressive?{required:!!F.required,min:Gn(F.min),max:Gn(F.max),minLength:Gn(F.minLength),maxLength:Gn(F.maxLength),pattern:Gn(F.pattern)}:{},name:I,onChange:V,onBlur:V,ref:oe=>{if(oe){te(I,F),B=ae(n,I);const re=Oe(oe.value)&&oe.querySelectorAll&&oe.querySelectorAll("input,select,textarea")[0]||oe,ye=uN(re),Re=B._f.refs||[];if(ye?Re.find(Ie=>Ie===re):re===B._f.ref)return;_e(n,I,{_f:{...B._f,...ye?{refs:[...Re.filter($s),re,...Array.isArray(ae(a,I))?[{}]:[]],ref:{type:re.type,name:I}}:{ref:re}}}),C(I,!1,void 0,re)}else B=ae(n,I,{}),B._f&&(B._f.mount=!1),(t.shouldUnregister||F.shouldUnregister)&&!(ex(l.array,I)&&i.action)&&l.unMount.add(I)}}},ce=()=>t.shouldFocusError&&Sn(n,M,l.mount),be=I=>{$t(I)&&(f.state.next({disabled:I}),Sn(n,(F,B)=>{const le=ae(n,B);le&&(F.disabled=le._f.disabled||I,Array.isArray(le._f.refs)&&le._f.refs.forEach(oe=>{oe.disabled=le._f.disabled||I}))},0,!1))},Ce=(I,F)=>async B=>{let le;B&&(B.preventDefault&&B.preventDefault(),B.persist&&B.persist());let oe=Le(s);if(f.state.next({isSubmitting:!0}),t.resolver){const{errors:re,values:ye}=await k();y(),r.errors=re,oe=Le(ye)}else await D(n);if(l.disabled.size)for(const re of l.disabled)Be(oe,re);if(Be(r.errors,"root"),ct(r.errors)){f.state.next({errors:{}});try{await I(oe,B)}catch(re){le=re}}else F&&await F({...r.errors},B),ce(),setTimeout(ce);if(f.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ct(r.errors)&&!le,submitCount:r.submitCount+1,errors:r.errors}),le)throw le},ve=(I,F={})=>{ae(n,I)&&(Oe(F.defaultValue)?Z(I,Le(ae(a,I))):(Z(I,F.defaultValue),_e(a,I,Le(F.defaultValue))),F.keepTouched||Be(r.touchedFields,I),F.keepDirty||(Be(r.dirtyFields,I),r.isDirty=F.defaultValue?L(I,Le(ae(a,I))):L()),F.keepError||(Be(r.errors,I),m.isValid&&x()),f.state.next({...r}))},me=(I,F={})=>{const B=I?Le(I):a,le=Le(B),oe=ct(I),re=oe?a:le;if(F.keepDefaultValues||(a=B),!F.keepValues){if(F.keepDirtyValues){const ye=new Set([...l.mount,...Object.keys(vn(a,s))]);for(const Re of Array.from(ye)){const Ie=ae(r.dirtyFields,Re),ot=ae(s,Re),tr=ae(re,Re);Ie&&!Oe(ot)?_e(re,Re,ot):!Ie&&!Oe(tr)&&Z(Re,tr)}}else{if(Cl&&Oe(I))for(const ye of l.mount){const Re=ae(n,ye);if(Re&&Re._f){const Ie=Array.isArray(Re._f.refs)?Re._f.refs[0]:Re._f.ref;if(oo(Ie)){const ot=Ie.closest("form");if(ot){ot.reset();break}}}}if(F.keepFieldsRef)for(const ye of l.mount)Z(ye,ae(re,ye));else n={}}s=t.shouldUnregister?F.keepDefaultValues?Le(a):{}:Le(re),f.array.next({values:{...re}}),f.state.next({values:{...re}})}l={mount:F.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},i.mount=!m.isValid||!!F.keepIsValid||!!F.keepDirtyValues||!t.shouldUnregister&&!ct(re),i.watch=!!t.shouldUnregister,i.keepIsValid=!!F.keepIsValid,i.action=!1,F.keepErrors||(r.errors={}),f.state.next({submitCount:F.keepSubmitCount?r.submitCount:0,isDirty:oe?!1:F.keepDirty?r.isDirty:!!(F.keepDefaultValues&&!Kt(I,a)),isSubmitted:F.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:oe?{}:F.keepDirtyValues?F.keepDefaultValues&&s?vn(a,s):r.dirtyFields:F.keepDefaultValues&&I?vn(a,I):F.keepDirty?r.dirtyFields:{},touchedFields:F.keepTouched?r.touchedFields:{},errors:F.keepErrors?r.errors:{},isSubmitSuccessful:F.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:a})},Ee=(I,F)=>me(ht(I)?I(s):I,{...t.resetOptions,...F}),Fe=(I,F={})=>{const B=ae(n,I),le=B&&B._f;if(le){const oe=le.refs?le.refs[0]:le.ref;oe.focus&&setTimeout(()=>{oe.focus(),F.shouldSelect&&ht(oe.select)&&oe.select()})}},Nt=I=>{r={...r,...I}},dt={control:{register:te,unregister:ne,getFieldState:U,handleSubmit:Ce,setError:Y,_subscribe:W,_runSchema:k,_updateIsValidating:y,_focusError:ce,_getWatch:A,_getDirty:L,_setValid:x,_setFieldArray:v,_setDisabledField:J,_setErrors:w,_getFieldArray:z,_reset:me,_resetDefaultValues:()=>ht(t.defaultValues)&&t.defaultValues().then(I=>{Ee(I,t.resetOptions),f.state.next({isLoading:!1})}),_removeUnmounted:O,_disableForm:be,_subjects:f,_proxyFormState:m,get _fields(){return n},get _formValues(){return s},get _state(){return i},set _state(I){i=I},get _defaultValues(){return a},get _names(){return l},set _names(I){l=I},get _formState(){return r},get _options(){return t},set _options(I){t={...t,...I}}},subscribe:G,trigger:P,register:te,handleSubmit:Ce,watch:H,setValue:Z,getValues:se,reset:Ee,resetField:ve,clearErrors:Q,unregister:ne,setError:Y,setFocus:Fe,getFieldState:U};return{...dt,formControl:dt}}var Tr=()=>{if(typeof crypto<"u"&&crypto.randomUUID)return crypto.randomUUID();const e=typeof performance>"u"?Date.now():performance.now()*1e3;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const r=(Math.random()*16+e)%16|0;return(t=="x"?r:r&3|8).toString(16)})},Es=(e,t,r={})=>r.shouldFocus||Oe(r.shouldFocus)?r.focusName||`${e}.${Oe(r.focusIndex)?t:r.focusIndex}.`:"",Ds=(e,t)=>[...e,...yt(t)],Ts=e=>Array.isArray(e)?e.map(()=>{}):void 0;function As(e,t,r){return[...e.slice(0,t),...yt(r),...e.slice(t)]}var Rs=(e,t,r)=>Array.isArray(e)?(Oe(e[r])&&(e[r]=void 0),e.splice(r,0,e.splice(t,1)[0]),e):[],Is=(e,t)=>[...yt(t),...yt(e)];function CN(e,t){let r=0;const n=[...e];for(const a of t)n.splice(a-r,1),r++;return Zo(n).length?n:[]}var Ps=(e,t)=>Oe(t)?[]:CN(e,yt(t).sort((r,n)=>r-n)),_s=(e,t,r)=>{[e[t],e[r]]=[e[r],e[t]]},Sd=(e,t,r)=>(e[t]=r,e);function dx(e){const t=Ko(),{control:r=t,name:n,keyName:a="id",shouldUnregister:s,rules:i}=e,[l,c]=N.useState(r._getFieldArray(n)),d=N.useRef(r._getFieldArray(n).map(Tr)),u=N.useRef(!1);r._names.array.add(n),N.useMemo(()=>i&&l.length>=0&&r.register(n,i),[r,n,l.length,i]),Yo(()=>r._subjects.array.subscribe({next:({values:w,name:C})=>{if(C===n||!C){const S=ae(w,n);Array.isArray(S)&&(c(S),d.current=S.map(Tr))}}}).unsubscribe,[r,n]);const m=N.useCallback(w=>{u.current=!0,r._setFieldArray(n,w)},[r,n]),p=(w,C)=>{const S=yt(Le(w)),$=Ds(r._getFieldArray(n),S);r._names.focus=Es(n,$.length-1,C),d.current=Ds(d.current,S.map(Tr)),m($),c($),r._setFieldArray(n,$,Ds,{argA:Ts(w)})},f=(w,C)=>{const S=yt(Le(w)),$=Is(r._getFieldArray(n),S);r._names.focus=Es(n,0,C),d.current=Is(d.current,S.map(Tr)),m($),c($),r._setFieldArray(n,$,Is,{argA:Ts(w)})},b=w=>{const C=Ps(r._getFieldArray(n),w);d.current=Ps(d.current,w),m(C),c(C),!Array.isArray(ae(r._fields,n))&&_e(r._fields,n,void 0),r._setFieldArray(n,C,Ps,{argA:w})},h=(w,C,S)=>{const $=yt(Le(C)),k=As(r._getFieldArray(n),w,$);r._names.focus=Es(n,w,S),d.current=As(d.current,w,$.map(Tr)),m(k),c(k),r._setFieldArray(n,k,As,{argA:w,argB:Ts(C)})},x=(w,C)=>{const S=r._getFieldArray(n);_s(S,w,C),_s(d.current,w,C),m(S),c(S),r._setFieldArray(n,S,_s,{argA:w,argB:C},!1)},y=(w,C)=>{const S=r._getFieldArray(n);Rs(S,w,C),Rs(d.current,w,C),m(S),c(S),r._setFieldArray(n,S,Rs,{argA:w,argB:C},!1)},v=(w,C)=>{const S=Le(C),$=Sd(r._getFieldArray(n),w,S);d.current=[...$].map((k,E)=>!k||E===w?Tr():d.current[E]),m($),c([...$]),r._setFieldArray(n,$,Sd,{argA:w,argB:S},!0,!1)},j=w=>{const C=yt(Le(w));d.current=C.map(Tr),m([...C]),c([...C]),r._setFieldArray(n,[...C],S=>S,{},!0,!1)};return N.useEffect(()=>{if(r._state.action=!1,xi(n,r._names)&&r._subjects.state.next({...r._formState}),u.current&&(!wn(r._options.mode).isOnSubmit||r._formState.isSubmitted)&&!wn(r._options.reValidateMode).isOnSubmit)if(r._options.resolver)r._runSchema([n]).then(w=>{r._updateIsValidating([n]);const C=ae(w.errors,n),S=ae(r._formState.errors,n);(S?!C&&S.type||C&&(S.type!==C.type||S.message!==C.message):C&&C.type)&&(C?_e(r._formState.errors,n,C):Be(r._formState.errors,n),r._subjects.state.next({errors:r._formState.errors}))});else{const w=ae(r._fields,n);w&&w._f&&!(wn(r._options.reValidateMode).isOnSubmit&&wn(r._options.mode).isOnSubmit)&&gi(w,r._names.disabled,r._formValues,r._options.criteriaMode===zt.all,r._options.shouldUseNativeValidation,!0).then(C=>!ct(C)&&r._subjects.state.next({errors:cx(r._formState.errors,C,n)}))}r._subjects.state.next({name:n,values:Le(r._formValues)}),r._names.focus&&Sn(r._fields,(w,C)=>{if(r._names.focus&&C.startsWith(r._names.focus)&&w.focus)return w.focus(),1}),r._names.focus="",r._setValid(),u.current=!1},[l,n,r]),N.useEffect(()=>(!ae(r._formValues,n)&&r._setFieldArray(n),()=>{const w=(C,S)=>{const $=ae(r._fields,C);$&&$._f&&($._f.mount=S)};r._options.shouldUnregister||s?r.unregister(n):w(n,!1)}),[n,r,a,s]),{swap:N.useCallback(x,[m,n,r]),move:N.useCallback(y,[m,n,r]),prepend:N.useCallback(f,[m,n,r]),append:N.useCallback(p,[m,n,r]),remove:N.useCallback(b,[m,n,r]),insert:N.useCallback(h,[m,n,r]),update:N.useCallback(v,[m,n,r]),replace:N.useCallback(j,[m,n,r]),fields:N.useMemo(()=>l.map((w,C)=>({...w,[a]:d.current[C]||Tr()})),[l,a])}}function NN(e={}){const t=N.useRef(void 0),r=N.useRef(void 0),[n,a]=N.useState({isDirty:!1,isValidating:!1,isLoading:ht(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:ht(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:n},e.defaultValues&&!ht(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:i,...l}=kN(e);t.current={...l,formState:n}}const s=t.current.control;return s._options=e,Yo(()=>{const i=s._subscribe({formState:s._proxyFormState,callback:()=>a({...s._formState}),reRenderRoot:!0});return a(l=>({...l,isReady:!0})),s._formState.isReady=!0,i},[s]),N.useEffect(()=>s._disableForm(e.disabled),[s,e.disabled]),N.useEffect(()=>{e.mode&&(s._options.mode=e.mode),e.reValidateMode&&(s._options.reValidateMode=e.reValidateMode)},[s,e.mode,e.reValidateMode]),N.useEffect(()=>{e.errors&&(s._setErrors(e.errors),s._focusError())},[s,e.errors]),N.useEffect(()=>{e.shouldUnregister&&s._subjects.state.next({values:s._getWatch()})},[s,e.shouldUnregister]),N.useEffect(()=>{if(s._proxyFormState.isDirty){const i=s._getDirty();i!==n.isDirty&&s._subjects.state.next({isDirty:i})}},[s,n.isDirty]),N.useEffect(()=>{var i;e.values&&!Kt(e.values,r.current)?(s._reset(e.values,{keepFieldsRef:!0,...s._options.resetOptions}),!((i=s._options.resetOptions)===null||i===void 0)&&i.keepIsValid||s._setValid(),r.current=e.values,a(l=>({...l}))):s._resetDefaultValues()},[s,e.values]),N.useEffect(()=>{s._state.mount||(s._setValid(),s._state.mount=!0),s._state.watch&&(s._state.watch=!1,s._subjects.state.next({...s._formState})),s._removeUnmounted()}),t.current.formState=N.useMemo(()=>tx(n,s),[s,n]),t.current}var SN=Object.defineProperty,$N=(e,t,r)=>t in e?SN(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,$d=(e,t,r)=>$N(e,typeof t!="symbol"?t+"":t,r);const vi=N.createContext({}),Hr=()=>N.useContext(vi),st=(e,t,r={})=>{if(!e)return!0;if("and"in e||"or"in e){const d="and"in e&&Array.isArray(e.and)&&e.and.length>0,u="or"in e&&Array.isArray(e.or)&&e.or.length>0;return d&&u?(console.warn("[evaluateFieldCondition] FieldConditionGroup com `and` e `or` simultâneos — apenas `and` será avaliado."),e.and.every(m=>st(m,t,r))):d?e.and.every(m=>st(m,t,r)):u?e.or.some(m=>st(m,t,r)):!0}const n=e;if(!n.campoId)return!0;const a=n.source==="evento"?r[n.campoId]:t[n.campoId];if(Array.isArray(a)){const d=n.valor;switch(n.operador){case"contem":return a.includes(d);case"naoContem":return!a.includes(d);case"vazio":return a.length===0;case"naoVazio":return a.length>0;case"igual":return a.length===1&&a[0]===d;case"diferente":return!(a.length===1&&a[0]===d);default:return!0}}const s=a==null||a===!1?"":a===!0?"1":String(a),i=n.valor!==void 0?String(n.valor):"",l=Number(s),c=Number(i);switch(n.operador){case"igual":return s===i;case"diferente":return s!==i;case"vazio":return!s;case"naoVazio":return!!s;case"contem":return s.includes(i);case"naoContem":return!s.includes(i);case"maiorQue":return!isNaN(l)&&!isNaN(c)?l>c:s>i;case"menorQue":return!isNaN(l)&&!isNaN(c)?l<c:s<i;case"maiorOuIgual":return!isNaN(l)&&!isNaN(c)?l>=c:s>=i;case"menorOuIgual":return!isNaN(l)&&!isNaN(c)?l<=c:s<=i;default:return!0}},EN=/^\d{3}\.?\d{3}\.?\d{3}-?\d{2}$/,DN=/^\(?\d{2}\)?\s?\d{4,5}-?\d{4}$/,TN=/^\d{5}-?\d{3}$/,AN=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,RN=e=>{const t=e.replace(/\D/g,"");if(t.length!==11||/^(\d)\1{10}$/.test(t))return!1;const r=n=>{let a=0;for(let i=0;i<n;i++)a+=parseInt(t[i])*(n+1-i);const s=a*10%11;return s>=10?0:s};return r(9)===parseInt(t[9])&&r(10)===parseInt(t[10])},Xn=new Map,IN=e=>{if(Xn.has(e))return Xn.get(e);if(/^\/.*\/[gimsuy]*$/.test(e))return Xn.set(e,null),null;try{const t=new RegExp(e);return Xn.set(e,t),t}catch{return Xn.set(e,null),null}},_a=(e,t,r={})=>{const n=e.validacao;if(e.tipo===T.CHECKBOX||e.tipo===T.SWITCH)return e.obrigatorio&&!t?"Campo obrigatório":void 0;if(e.tipo===T.SLIDER){const s=t!=null&&t!==""?Number(t):NaN;return e.obrigatorio&&isNaN(s)?"Campo obrigatório":isNaN(s)?void 0:(n==null?void 0:n.min)!==void 0&&s<n.min?`Valor mínimo: ${n.min}`:(n==null?void 0:n.max)!==void 0&&s>n.max?`Valor máximo: ${n.max}`:void 0}if(e.tipo===T.RATING){const s=t!==void 0?Number(t):0;return e.obrigatorio&&(!s||s<1)?"Avaliação obrigatória":void 0}if(e.tipo===T.DATE_RANGE){const s=t;if(e.obrigatorio){if(!(s!=null&&s.start))return"Data inicial obrigatória";if(!(s!=null&&s.end))return"Data final obrigatória"}return s!=null&&s.start&&s!=null&&s.end&&s.start>s.end?"A data inicial deve ser menor ou igual à data final":void 0}if(e.tipo===T.PARTICIPATION_TYPE){if(!e.obrigatorio)return;const s=t;return s!=null&&s.tipo?s.tipo==="por_dia"&&!s.data?"Selecione um dia para participar":"genero"in(s??{})&&!(s!=null&&s.genero)?"Selecione o sexo":void 0:"Selecione o tipo de participação"}if(e.tipo===T.CHECKBOX_GROUP){const s=Array.isArray(t)?t:[];return e.obrigatorio&&s.length===0?"Selecione pelo menos uma opção":void 0}if(e.tipo===T.FILE)return e.obrigatorio&&!t?"Arquivo obrigatório":void 0;if(e.tipo===T.TERMS)return e.obrigatorio&&t!=="accepted"?"Você precisa aceitar os termos para continuar":void 0;if(e.tipo===T.NUMBER){const s=t!=null?String(t):"";if(e.obrigatorio&&!s)return"Campo obrigatório";if(!s)return;const i=Number(s);return isNaN(i)?"Deve ser um número":(n==null?void 0:n.min)!==void 0&&i<n.min?`Valor mínimo: ${n.min}`:(n==null?void 0:n.max)!==void 0&&i>n.max?`Valor máximo: ${n.max}`:void 0}const a=t!=null?String(t):"";if(e.obrigatorio&&!a.trim())return"Campo obrigatório";if(a){if(e.tipo===T.EMAIL&&!AN.test(a))return"E-mail inválido";if(e.tipo===T.CPF&&(!EN.test(a)||!RN(a)))return"CPF inválido";if(e.tipo===T.TELEFONE&&!DN.test(a))return"Telefone inválido";if(e.tipo===T.CEP&&!TN.test(a))return"CEP inválido";if(n!=null&&n.minLength&&a.length<n.minLength)return`Mínimo ${n.minLength} caracteres`;if(n!=null&&n.maxLength&&a.length>n.maxLength)return`Máximo ${n.maxLength} caracteres`;if((e.tipo===T.DATE||e.tipo===T.DATETIME)&&a){if(n!=null&&n.minDate&&a<n.minDate)return`Data mínima: ${n.minDate}`;if(n!=null&&n.maxDate&&a>n.maxDate)return`Data máxima: ${n.maxDate}`}if((e.tipo===T.DATE||e.tipo===T.DATETIME)&&a&&((n==null?void 0:n.minAge)!=null||(n==null?void 0:n.maxAge)!=null)){const s=a.split("T")[0],i=new Date(s+"T00:00:00"),l=r["evento.dataInicioEvento"],c=l?new Date(l.split("T")[0]+"T00:00:00"):new Date;let d=c.getFullYear()-i.getFullYear();const u=c.getMonth()-i.getMonth();if((u<0||u===0&&c.getDate()<i.getDate())&&d--,n.minAge!=null&&d<n.minAge)return`Idade mínima: ${n.minAge} ano${n.minAge!==1?"s":""}`;if(n.maxAge!=null&&d>n.maxAge)return`Idade máxima: ${n.maxAge} ano${n.maxAge!==1?"s":""}`}if(n!=null&&n.regex){const s=IN(n.regex);if(s&&!s.test(a))return n.regexMessage||"Formato inválido"}}},Ed=new Set(["__proto__","constructor","prototype"]),xn=(e,t,r)=>{const n=t.split(".");let a=e;for(let i=0;i<n.length-1;i++){const l=n[i];if(Ed.has(l))return;(a[l]==null||typeof a[l]!="object")&&(a[l]={}),a=a[l]}const s=n[n.length-1];Ed.has(s)||(a[s]=r)},jn=async(e,t,r,n,a,s)=>{for(const i of e){const l=s[i.type];if(!l)continue;const c=await l(r,n,i,a);if(c)return i.message??c}},PN=(e,t={},r={})=>async n=>{var a,s,i,l,c;const d={},u=[...e.containers].sort((m,p)=>m.ordem-p.ordem);for(const m of u){if(m.repeatable||m.condicional&&!st(m.condicional,n,t))continue;const p=[...m.campos].sort((f,b)=>f.ordem-b.ordem);for(const f of p){if(!st(f.condicional,n,t)||f.tipo===T.HIDDEN||f.isDisabled||f.isReadOnly)continue;if(f.tipo===T.FIELD_ARRAY){const h=Array.isArray(n[f.nome])?n[f.nome]:[];f.obrigatorio&&h.length===0?d[f.nome]={type:"custom",message:"Adicione pelo menos um item"}:f.minItems&&h.length<f.minItems?d[f.nome]={type:"custom",message:`Mínimo de ${f.minItems} item${f.minItems!==1?"s":""}`}:f.maxItems&&h.length>f.maxItems&&(d[f.nome]={type:"custom",message:`Máximo de ${f.maxItems} item${f.maxItems!==1?"s":""}`});for(let x=0;x<h.length;x++){const y=h[x];for(const v of f.subFields??[]){if(v.isDisabled||v.isReadOnly||!st(v.condicional,y,t))continue;const j=_a(v,y[v.nome],t);if(j){xn(d,`${f.nome}.${x}.${v.nome}`,{type:"custom",message:j});continue}if((a=v.validate)!=null&&a.length){const w=await jn(v.validate,v.nome,y[v.nome],y,t,r);w&&xn(d,`${f.nome}.${x}.${v.nome}`,{type:"custom",message:w})}}}continue}if(f.tipo===T.SUB_FORM){const h=n[f.nome]??{};f.obrigatorio&&Object.keys(h).length===0&&(d[f.nome]={type:"custom",message:"Campo obrigatório"});for(const x of((s=f.subSchema)==null?void 0:s.fields)??[]){if(x.isDisabled||x.isReadOnly)continue;const y=_a(x,h[x.nome],t);if(y){xn(d,`${f.nome}.${x.nome}`,{type:"custom",message:y});continue}if((i=x.validate)!=null&&i.length){const v=await jn(x.validate,x.nome,h[x.nome],h,t,r);v&&xn(d,`${f.nome}.${x.nome}`,{type:"custom",message:v})}}continue}const b=_a(f,n[f.nome],t);if(b&&(d[f.nome]={type:"custom",message:b}),!d[f.nome]&&(l=f.validate)!=null&&l.length){const h=await jn(f.validate,f.nome,n[f.nome],n,t,r);h&&(d[f.nome]={type:"custom",message:h})}}}for(const m of u){if(!m.repeatable||!m.nome||m.condicional&&!st(m.condicional,n,t))continue;const p=Array.isArray(n[m.nome])?n[m.nome]:[];m.minItems&&p.length<m.minItems?d[m.nome]={type:"custom",message:`Mínimo de ${m.minItems} ${m.itemLabel??"item"}${m.minItems!==1?"s":""}`}:m.maxItems&&p.length>m.maxItems&&(d[m.nome]={type:"custom",message:`Máximo de ${m.maxItems} ${m.itemLabel??"item"}${m.maxItems!==1?"s":""}`});for(let f=0;f<p.length;f++){const b=p[f];for(const h of m.campos){if(!st(h.condicional,b,t)||h.tipo===T.HIDDEN||h.isDisabled||h.isReadOnly)continue;const x=_a(h,b[h.nome],t);if(x){xn(d,`${m.nome}.${f}.${h.nome}`,{type:"custom",message:x});continue}if((c=h.validate)!=null&&c.length){const y=await jn(h.validate,h.nome,b[h.nome],b,t,r);y&&xn(d,`${m.nome}.${f}.${h.nome}`,{type:"custom",message:y})}}}}return Object.keys(d).length>0?{values:{},errors:d}:{values:n,errors:{}}},_N=(e,t={},r={})=>async n=>{var a,s;const i={},l=[...e.containers].sort((c,d)=>c.ordem-d.ordem);for(const c of l)if(!(c.condicional&&!st(c.condicional,n,t))){if(c.repeatable&&c.nome){const d=Array.isArray(n[c.nome])?n[c.nome]:[];for(let u=0;u<d.length;u++){const m=d[u];for(const p of[...c.campos].sort((f,b)=>f.ordem-b.ordem)){if(!((a=p.warn)!=null&&a.length)||!st(p.condicional,m,t))continue;const f=await jn(p.warn,p.nome,m[p.nome],m,t,r);f&&(i[`${c.nome}.${u}.${p.nome}`]=f)}}continue}for(const d of[...c.campos].sort((u,m)=>u.ordem-m.ordem)){if(!((s=d.warn)!=null&&s.length)||!st(d.condicional,n,t))continue;const u=await jn(d.warn,d.nome,n[d.nome],n,t,r);u&&(i[d.nome]=u)}}return i},ON=/\{\{\s*(?:event|evento)\.([a-zA-Z0-9_.]+)\s*\}\}/g,wt=(e,t)=>e?e.replace(ON,(r,n)=>t[`evento.${n}`]??t[n]??r):e??"",FN=(e,t)=>({...e,label:wt(e.label,t)}),zN=(e,t)=>{var r;return{...e,label:wt(e.label,t),placeholder:wt(e.placeholder,t),hint:wt(e.hint,t),defaultValue:typeof e.defaultValue=="string"?wt(e.defaultValue,t):e.defaultValue,opcoes:(r=e.opcoes)==null?void 0:r.map(n=>FN(n,t))}},Tl=(e,t)=>({...e,titulo:wt(e.titulo,t),descricao:wt(e.descricao,t),campos:e.campos.map(r=>zN(r,t))}),LN=(e,t)=>({...e,titulo:wt(e.titulo,t),descricao:wt(e.descricao,t),containers:e.containers.map(r=>Tl(r,t))}),ux=()=>{const e=sa(),t=e.layout.containerStyle,r=e.layout.roundness??"rounded-xl",n=K("overflow-hidden",r,t==="card"?"border":"",t==="bordered"?"border":"",t==="glassmorphism"?"backdrop-blur-sm":""),a=t==="glassmorphism"?{background:"var(--t-surface)",borderColor:"var(--t-border)",borderWidth:"1px",borderStyle:"solid"}:{},s=K("border-b px-6 py-4",t==="flat"?"border-transparent":"");return{wrapperClass:n,wrapperStyle:a,headerClass:s,headerStyle:t==="glassmorphism"?{borderColor:"var(--t-border)"}:{},tmpl:e}},Mt=({name:e,control:t,placeholder:r,type:n="text",disabled:a,readOnly:s})=>{var i;const{field:l,fieldState:c}=Me({name:e,control:t}),d=!!c.error;return o.jsxs("div",{className:"space-y-1",children:[o.jsx(ue,{...l,value:l.value??"",type:n,placeholder:r,disabled:a,readOnly:s,className:K(d&&"border-destructive focus-visible:ring-destructive")}),((i=c.error)==null?void 0:i.message)&&o.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})},Al=({name:e,control:t,placeholder:r,disabled:n,readOnly:a})=>{var s;const{field:i,fieldState:l}=Me({name:e,control:t});return o.jsxs("div",{className:"space-y-1",children:[o.jsx(po,{...i,value:i.value??"",placeholder:r,disabled:n,readOnly:a,rows:3,className:K(l.error&&"border-destructive focus-visible:ring-destructive")}),((s=l.error)==null?void 0:s.message)&&o.jsx("p",{className:"text-sm text-destructive",children:l.error.message})]})},Rl=({name:e,control:t,placeholder:r,options:n,disabled:a,readOnly:s})=>{var i;const{field:l,fieldState:c}=Me({name:e,control:t});return o.jsxs("div",{className:"space-y-1",children:[o.jsxs(Bt,{value:l.value??"",onValueChange:d=>!s&&l.onChange(d),disabled:a||s,children:[o.jsx(Rt,{className:K(c.error&&"border-destructive focus:ring-destructive"),onBlur:l.onBlur,children:o.jsx(Ut,{placeholder:r??"Selecione..."})}),o.jsx(It,{children:n.map(d=>o.jsx(qe,{value:d.valor,disabled:d.disabled,children:d.label},d.valor))})]}),((i=c.error)==null?void 0:i.message)&&o.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})},Il=({name:e,control:t,label:r,disabled:n,readOnly:a})=>{var s;const{field:i,fieldState:l}=Me({name:e,control:t});return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx(et,{name:i.name,checked:!!i.value,onCheckedChange:c=>!a&&i.onChange(!!c),onBlur:i.onBlur,disabled:n}),r&&o.jsx("span",{className:"text-sm leading-none",children:r})]}),((s=l.error)==null?void 0:s.message)&&o.jsx("p",{className:"text-sm text-destructive",children:l.error.message})]})},mx=({name:e,control:t,options:r,disabled:n})=>{var a;const{field:s,fieldState:i}=Me({name:e,control:t}),l=Array.isArray(s.value)?s.value:[],c=d=>{const u=l.includes(d)?l.filter(m=>m!==d):[...l,d];s.onChange(u)};return o.jsxs("div",{className:"space-y-1",children:[o.jsx("div",{className:"flex flex-col gap-2",onBlur:s.onBlur,children:r.map(d=>o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx(et,{checked:l.includes(d.valor),onCheckedChange:()=>c(d.valor),disabled:n||d.disabled}),o.jsx("span",{className:"text-sm leading-none",children:d.label})]},d.valor))}),((a=i.error)==null?void 0:a.message)&&o.jsx("p",{className:"text-sm text-destructive",children:i.error.message})]})},px=({name:e,control:t,options:r,visualStyle:n="default",disabled:a})=>{var s;const{field:i,fieldState:l}=Me({name:e,control:t}),c=n==="card";return o.jsxs("div",{className:"space-y-1",onBlur:i.onBlur,children:[o.jsx(Pi,{value:i.value??"",onValueChange:i.onChange,className:K(c?"grid grid-cols-2 gap-2 sm:grid-cols-3":"flex flex-col gap-2"),children:r.map(d=>o.jsxs("label",{className:K("flex items-center gap-2 cursor-pointer",c&&"rounded-lg border p-3 transition-colors hover:bg-accent data-[selected=true]:border-primary data-[selected=true]:bg-primary/5",(a||d.disabled)&&"cursor-not-allowed opacity-50"),"data-selected":i.value===d.valor?"true":void 0,children:[o.jsx(_i,{value:d.valor,disabled:a||d.disabled}),o.jsx("span",{className:"text-sm leading-none",children:d.label})]},d.valor))}),((s=l.error)==null?void 0:s.message)&&o.jsx("p",{className:"text-sm text-destructive",children:l.error.message})]})},fx=e=>{const t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return`${t}-${r}-${n}`},MN=e=>{const t=new Date;return t.setFullYear(t.getFullYear()-e),fx(t)},VN=e=>{const t=new Date;return t.setFullYear(t.getFullYear()-e),fx(t)},aa=({name:e,control:t,isDatetime:r,disabled:n,readOnly:a,validacao:s})=>{var i;const{field:l,fieldState:c}=Me({name:e,control:t}),d=r?"datetime-local":"date",u=f=>r?f+"T00:00":f,m=(s==null?void 0:s.minAge)!=null?u(MN(s.minAge)):(s==null?void 0:s.maxDate)!=null?u(s.maxDate):void 0,p=(s==null?void 0:s.maxAge)!=null?u(VN(s.maxAge)):(s==null?void 0:s.minDate)!=null?u(s.minDate):void 0;return o.jsxs("div",{className:"space-y-1",children:[o.jsx(ue,{name:l.name,value:l.value??"",onChange:l.onChange,onBlur:l.onBlur,type:d,min:p,max:m,disabled:n,readOnly:a,className:K(c.error&&"border-destructive focus-visible:ring-destructive")}),((i=c.error)==null?void 0:i.message)&&o.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})};function BN(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}const hx={128:"€",130:"‚",131:"ƒ",132:"„",133:"…",134:"†",135:"‡",136:"ˆ",137:"‰",138:"Š",139:"‹",140:"Œ",142:"Ž",145:"‘",146:"’",147:"“",148:"”",149:"•",150:"–",151:"—",152:"˜",153:"™",154:"š",155:"›",156:"œ",158:"ž",159:"Ÿ"};for(const[e,t]of Object.entries(hx));let Dd;function UN(){if(!(typeof globalThis.TextDecoder>"u"))return Dd??(Dd=new globalThis.TextDecoder("utf-8"))}const Pn=32*1024,Xt=65533;function HN(e,t="utf-8"){switch(t.toLowerCase()){case"utf-8":case"utf8":{const r=UN();return r?r.decode(e):qN(e)}case"utf-16le":return GN(e);case"us-ascii":case"ascii":return XN(e);case"latin1":case"iso-8859-1":return ZN(e);case"windows-1252":return KN(e);default:throw new RangeError(`Encoding '${t}' not supported`)}}function Pl(e,t){t.length!==0&&(e.push(String.fromCharCode.apply(null,t)),t.length=0)}function Ye(e,t,r){t.push(r),t.length>=Pn&&Pl(e,t)}function WN(e,t,r){if(r<=65535){Ye(e,t,r);return}r-=65536,Ye(e,t,55296+(r>>10)),Ye(e,t,56320+(r&1023))}function qN(e){const t=[],r=[];let n=0;for(e.length>=3&&e[0]===239&&e[1]===187&&e[2]===191&&(n=3);n<e.length;){const a=e[n];if(a<=127){Ye(t,r,a),n++;continue}if(a<194||a>244){Ye(t,r,Xt),n++;continue}if(a<=223){if(n+1>=e.length){Ye(t,r,Xt),n++;continue}const d=e[n+1];if((d&192)!==128){Ye(t,r,Xt),n++;continue}const u=(a&31)<<6|d&63;Ye(t,r,u),n+=2;continue}if(a<=239){if(n+2>=e.length){Ye(t,r,Xt),n++;continue}const d=e[n+1],u=e[n+2];if(!((d&192)===128&&(u&192)===128&&!(a===224&&d<160)&&!(a===237&&d>=160))){Ye(t,r,Xt),n++;continue}const m=(a&15)<<12|(d&63)<<6|u&63;Ye(t,r,m),n+=3;continue}if(n+3>=e.length){Ye(t,r,Xt),n++;continue}const s=e[n+1],i=e[n+2],l=e[n+3];if(!((s&192)===128&&(i&192)===128&&(l&192)===128&&!(a===240&&s<144)&&!(a===244&&s>143))){Ye(t,r,Xt),n++;continue}const c=(a&7)<<18|(s&63)<<12|(i&63)<<6|l&63;WN(t,r,c),n+=4}return Pl(t,r),t.join("")}function GN(e){const t=[],r=[],n=e.length;let a=0;for(;a+1<n;){const s=e[a]|e[a+1]<<8;if(a+=2,s>=55296&&s<=56319){if(a+1<n){const i=e[a]|e[a+1]<<8;i>=56320&&i<=57343?(Ye(t,r,s),Ye(t,r,i),a+=2):Ye(t,r,Xt)}else Ye(t,r,Xt);continue}if(s>=56320&&s<=57343){Ye(t,r,Xt);continue}Ye(t,r,s)}return a<n&&Ye(t,r,Xt),Pl(t,r),t.join("")}function XN(e){const t=[];for(let r=0;r<e.length;r+=Pn){const n=Math.min(e.length,r+Pn),a=new Array(n-r);for(let s=r,i=0;s<n;s++,i++)a[i]=e[s]&127;t.push(String.fromCharCode.apply(null,a))}return t.join("")}function ZN(e){const t=[];for(let r=0;r<e.length;r+=Pn){const n=Math.min(e.length,r+Pn),a=new Array(n-r);for(let s=r,i=0;s<n;s++,i++)a[i]=e[s];t.push(String.fromCharCode.apply(null,a))}return t.join("")}function KN(e){const t=[];let r="";for(let n=0;n<e.length;n++){const a=e[n],s=a>=128&&a<=159?hx[a]:void 0;r+=s??String.fromCharCode(a),r.length>=Pn&&(t.push(r),r="")}return r&&t.push(r),t.join("")}function Ct(e){return new DataView(e.buffer,e.byteOffset)}const YN={len:1,get(e,t){return Ct(e).getUint8(t)},put(e,t,r){return Ct(e).setUint8(t,r),t+1}},We={len:2,get(e,t){return Ct(e).getUint16(t,!0)},put(e,t,r){return Ct(e).setUint16(t,r,!0),t+2}},gn={len:2,get(e,t){return Ct(e).getUint16(t)},put(e,t,r){return Ct(e).setUint16(t,r),t+2}},Xe={len:4,get(e,t){return Ct(e).getUint32(t,!0)},put(e,t,r){return Ct(e).setUint32(t,r,!0),t+4}},Td={len:4,get(e,t){return Ct(e).getUint32(t)},put(e,t,r){return Ct(e).setUint32(t,r),t+4}},JN={len:4,get(e,t){return Ct(e).getInt32(t)},put(e,t,r){return Ct(e).setInt32(t,r),t+4}},QN={len:8,get(e,t){return Ct(e).getBigUint64(t,!0)},put(e,t,r){return Ct(e).setBigUint64(t,r,!0),t+8}};class br{constructor(t,r){this.len=t,this.encoding=r}get(t,r=0){const n=t.subarray(r,r+this.len);return HN(n,this.encoding)}}const e2="End-Of-Stream";class Qe extends Error{constructor(){super(e2),this.name="EndOfStreamError"}}class t2 extends Error{constructor(t="The operation was aborted"){super(t),this.name="AbortError"}}class xx{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(t,r=!1){const n=await this.read(t,r);return this.peekQueue.push(t.subarray(0,n)),n}async read(t,r=!1){if(t.length===0)return 0;let n=this.readFromPeekBuffer(t);if(this.endOfStream||(n+=await this.readRemainderFromStream(t.subarray(n),r)),n===0&&!r)throw new Qe;return n}readFromPeekBuffer(t){let r=t.length,n=0;for(;this.peekQueue.length>0&&r>0;){const a=this.peekQueue.pop();if(!a)throw new Error("peekData should be defined");const s=Math.min(a.length,r);t.set(a.subarray(0,s),n),n+=s,r-=s,s<a.length&&this.peekQueue.push(a.subarray(s))}return n}async readRemainderFromStream(t,r){let n=0;for(;n<t.length&&!this.endOfStream;){if(this.interrupted)throw new t2;const a=await this.readFromStream(t.subarray(n),r);if(a===0)break;n+=a}if(!r&&n<t.length)throw new Qe;return n}}class r2 extends xx{constructor(t){super(),this.reader=t}async abort(){return this.close()}async close(){this.reader.releaseLock()}}class n2 extends r2{async readFromStream(t,r){if(t.length===0)return 0;const n=await this.reader.read(new Uint8Array(t.length),{min:r?void 0:t.length});return n.done&&(this.endOfStream=n.done),n.value?(t.set(n.value),n.value.length):0}}class Ad extends xx{constructor(t){super(),this.reader=t,this.buffer=null}writeChunk(t,r){const n=Math.min(r.length,t.length);return t.set(r.subarray(0,n)),n<r.length?this.buffer=r.subarray(n):this.buffer=null,n}async readFromStream(t,r){if(t.length===0)return 0;let n=0;for(this.buffer&&(n+=this.writeChunk(t,this.buffer));n<t.length&&!this.endOfStream;){const a=await this.reader.read();if(a.done){this.endOfStream=!0;break}a.value&&(n+=this.writeChunk(t.subarray(n),a.value))}if(!r&&n===0&&this.endOfStream)throw new Qe;return n}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}}function a2(e){try{const t=e.getReader({mode:"byob"});return t instanceof ReadableStreamDefaultReader?new Ad(t):new n2(t)}catch(t){if(t instanceof TypeError)return new Ad(e.getReader());throw t}}class _l{constructor(t){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=t==null?void 0:t.onClose,t!=null&&t.abortSignal&&t.abortSignal.addEventListener("abort",()=>{this.abort()})}async readToken(t,r=this.position){const n=new Uint8Array(t.len);if(await this.readBuffer(n,{position:r})<t.len)throw new Qe;return t.get(n,0)}async peekToken(t,r=this.position){const n=new Uint8Array(t.len);if(await this.peekBuffer(n,{position:r})<t.len)throw new Qe;return t.get(n,0)}async readNumber(t){if(await this.readBuffer(this.numBuffer,{length:t.len})<t.len)throw new Qe;return t.get(this.numBuffer,0)}async peekNumber(t){if(await this.peekBuffer(this.numBuffer,{length:t.len})<t.len)throw new Qe;return t.get(this.numBuffer,0)}async ignore(t){if(t<0)throw new RangeError("ignore length must be ≥ 0 bytes");if(this.fileInfo.size!==void 0){const r=this.fileInfo.size-this.position;if(t>r)return this.position+=r,r}return this.position+=t,t}async close(){var t;await this.abort(),await((t=this.onClose)==null?void 0:t.call(this))}normalizeOptions(t,r){if(!this.supportsRandomAccess()&&r&&r.position!==void 0&&r.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");return{mayBeLess:!1,offset:0,length:t.length,position:this.position,...r}}abort(){return Promise.resolve()}}const o2=256e3;class s2 extends _l{constructor(t,r){super(r),this.streamReader=t,this.fileInfo=(r==null?void 0:r.fileInfo)??{}}async readBuffer(t,r){const n=this.normalizeOptions(t,r),a=n.position-this.position;if(a>0)return await this.ignore(a),this.readBuffer(t,r);if(a<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(n.length===0)return 0;const s=await this.streamReader.read(t.subarray(0,n.length),n.mayBeLess);if(this.position+=s,(!r||!r.mayBeLess)&&s<n.length)throw new Qe;return s}async peekBuffer(t,r){const n=this.normalizeOptions(t,r);let a=0;if(n.position){const s=n.position-this.position;if(s>0){const i=new Uint8Array(n.length+s);return a=await this.peekBuffer(i,{mayBeLess:n.mayBeLess}),t.set(i.subarray(s)),a-s}if(s<0)throw new Error("Cannot peek from a negative offset in a stream")}if(n.length>0){try{a=await this.streamReader.peek(t.subarray(0,n.length),n.mayBeLess)}catch(s){if(r!=null&&r.mayBeLess&&s instanceof Qe)return 0;throw s}if(!n.mayBeLess&&a<n.length)throw new Qe}return a}async ignore(t){if(t<0)throw new RangeError("ignore length must be ≥ 0 bytes");const r=Math.min(o2,t),n=new Uint8Array(r);let a=0;for(;a<t;){const s=t-a,i=await this.readBuffer(n,{length:Math.min(r,s)});if(i<0)return i;a+=i}return a}abort(){return this.streamReader.abort()}async close(){return this.streamReader.close()}supportsRandomAccess(){return!1}}class i2 extends _l{constructor(t,r){super(r),this.uint8Array=t,this.fileInfo={...(r==null?void 0:r.fileInfo)??{},size:t.length}}async readBuffer(t,r){r!=null&&r.position&&(this.position=r.position);const n=await this.peekBuffer(t,r);return this.position+=n,n}async peekBuffer(t,r){const n=this.normalizeOptions(t,r),a=Math.min(this.uint8Array.length-n.position,n.length);if(!n.mayBeLess&&a<n.length)throw new Qe;return t.set(this.uint8Array.subarray(n.position,n.position+a)),a}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(t){this.position=t}}class l2 extends _l{constructor(t,r){super(r),this.blob=t,this.fileInfo={...(r==null?void 0:r.fileInfo)??{},size:t.size,mimeType:t.type}}async readBuffer(t,r){r!=null&&r.position&&(this.position=r.position);const n=await this.peekBuffer(t,r);return this.position+=n,n}async peekBuffer(t,r){const n=this.normalizeOptions(t,r),a=Math.min(this.blob.size-n.position,n.length);if(!n.mayBeLess&&a<n.length)throw new Qe;const s=await this.blob.slice(n.position,n.position+a).arrayBuffer();return t.set(new Uint8Array(s)),a}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(t){this.position=t}}function c2(e,t){const r=a2(e),n=t??{},a=n.onClose;return n.onClose=async()=>{if(await r.close(),a)return a()},new s2(r,n)}function d2(e,t){return new i2(e,t)}function u2(e,t){return new l2(e,t)}var bi={exports:{}},Os,Rd;function m2(){if(Rd)return Os;Rd=1;var e=1e3,t=e*60,r=t*60,n=r*24,a=n*7,s=n*365.25;Os=function(u,m){m=m||{};var p=typeof u;if(p==="string"&&u.length>0)return i(u);if(p==="number"&&isFinite(u))return m.long?c(u):l(u);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(u))};function i(u){if(u=String(u),!(u.length>100)){var m=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(u);if(m){var p=parseFloat(m[1]),f=(m[2]||"ms").toLowerCase();switch(f){case"years":case"year":case"yrs":case"yr":case"y":return p*s;case"weeks":case"week":case"w":return p*a;case"days":case"day":case"d":return p*n;case"hours":case"hour":case"hrs":case"hr":case"h":return p*r;case"minutes":case"minute":case"mins":case"min":case"m":return p*t;case"seconds":case"second":case"secs":case"sec":case"s":return p*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return p;default:return}}}}function l(u){var m=Math.abs(u);return m>=n?Math.round(u/n)+"d":m>=r?Math.round(u/r)+"h":m>=t?Math.round(u/t)+"m":m>=e?Math.round(u/e)+"s":u+"ms"}function c(u){var m=Math.abs(u);return m>=n?d(u,m,n,"day"):m>=r?d(u,m,r,"hour"):m>=t?d(u,m,t,"minute"):m>=e?d(u,m,e,"second"):u+" ms"}function d(u,m,p,f){var b=m>=p*1.5;return Math.round(u/p)+" "+f+(b?"s":"")}return Os}function p2(e){r.debug=r,r.default=r,r.coerce=c,r.disable=i,r.enable=a,r.enabled=l,r.humanize=m2(),r.destroy=d,Object.keys(e).forEach(u=>{r[u]=e[u]}),r.names=[],r.skips=[],r.formatters={};function t(u){let m=0;for(let p=0;p<u.length;p++)m=(m<<5)-m+u.charCodeAt(p),m|=0;return r.colors[Math.abs(m)%r.colors.length]}r.selectColor=t;function r(u){let m,p=null,f,b;function h(...x){if(!h.enabled)return;const y=h,v=Number(new Date),j=v-(m||v);y.diff=j,y.prev=m,y.curr=v,m=v,x[0]=r.coerce(x[0]),typeof x[0]!="string"&&x.unshift("%O");let w=0;x[0]=x[0].replace(/%([a-zA-Z%])/g,(C,S)=>{if(C==="%%")return"%";w++;const $=r.formatters[S];if(typeof $=="function"){const k=x[w];C=$.call(y,k),x.splice(w,1),w--}return C}),r.formatArgs.call(y,x),(y.log||r.log).apply(y,x)}return h.namespace=u,h.useColors=r.useColors(),h.color=r.selectColor(u),h.extend=n,h.destroy=r.destroy,Object.defineProperty(h,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(f!==r.namespaces&&(f=r.namespaces,b=r.enabled(u)),b),set:x=>{p=x}}),typeof r.init=="function"&&r.init(h),h}function n(u,m){const p=r(this.namespace+(typeof m>"u"?":":m)+u);return p.log=this.log,p}function a(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];const m=(typeof u=="string"?u:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const p of m)p[0]==="-"?r.skips.push(p.slice(1)):r.names.push(p)}function s(u,m){let p=0,f=0,b=-1,h=0;for(;p<u.length;)if(f<m.length&&(m[f]===u[p]||m[f]==="*"))m[f]==="*"?(b=f,h=p,f++):(p++,f++);else if(b!==-1)f=b+1,h++,p=h;else return!1;for(;f<m.length&&m[f]==="*";)f++;return f===m.length}function i(){const u=[...r.names,...r.skips.map(m=>"-"+m)].join(",");return r.enable(""),u}function l(u){for(const m of r.skips)if(s(u,m))return!1;for(const m of r.names)if(s(u,m))return!0;return!1}function c(u){return u instanceof Error?u.stack||u.message:u}function d(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}var f2=p2;(function(e,t){t.formatArgs=n,t.save=a,t.load=s,t.useColors=r,t.storage=i(),t.destroy=(()=>{let c=!1;return()=>{c||(c=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function r(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let c;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(c=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(c[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function n(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const d="color: "+this.color;c.splice(1,0,d,"color: inherit");let u=0,m=0;c[0].replace(/%[a-zA-Z%]/g,p=>{p!=="%%"&&(u++,p==="%c"&&(m=u))}),c.splice(m,0,d)}t.log=console.debug||console.log||(()=>{});function a(c){try{c?t.storage.setItem("debug",c):t.storage.removeItem("debug")}catch{}}function s(){let c;try{c=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch{}return!c&&typeof process<"u"&&"env"in process&&(c=process.env.DEBUG),c}function i(){try{return localStorage}catch{}}e.exports=f2(t);const{formatters:l}=e.exports;l.j=function(c){try{return JSON.stringify(c)}catch(d){return"[UnexpectedJSONParseError]: "+d.message}}})(bi,bi.exports);var h2=bi.exports;const x2=BN(h2),kn={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},Id={get(e){return{signature:Xe.get(e,0),compressedSize:Xe.get(e,8),uncompressedSize:Xe.get(e,12)}},len:16},g2={get(e){const t=We.get(e,6);return{signature:Xe.get(e,0),minVersion:We.get(e,4),dataDescriptor:!!(t&8),compressedMethod:We.get(e,8),compressedSize:Xe.get(e,18),uncompressedSize:Xe.get(e,22),filenameLength:We.get(e,26),extraFieldLength:We.get(e,28),filename:null}},len:30},v2={get(e){return{signature:Xe.get(e,0),nrOfThisDisk:We.get(e,4),nrOfThisDiskWithTheStart:We.get(e,6),nrOfEntriesOnThisDisk:We.get(e,8),nrOfEntriesOfSize:We.get(e,10),sizeOfCd:Xe.get(e,12),offsetOfStartOfCd:Xe.get(e,16),zipFileCommentLength:We.get(e,20)}},len:22},b2={get(e){const t=We.get(e,8);return{signature:Xe.get(e,0),minVersion:We.get(e,6),dataDescriptor:!!(t&8),compressedMethod:We.get(e,10),compressedSize:Xe.get(e,20),uncompressedSize:Xe.get(e,24),filenameLength:We.get(e,28),extraFieldLength:We.get(e,30),fileCommentLength:We.get(e,32),relativeOffsetOfLocalHeader:Xe.get(e,42),filename:null}},len:46};function gx(e){const t=new Uint8Array(Xe.len);return Xe.put(t,0,e),t}const or=x2("tokenizer:inflate"),Fs=256*1024,y2=gx(kn.DataDescriptor),Oa=gx(kn.EndOfCentralDirectory);class va{constructor(t){this.tokenizer=t,this.syncBuffer=new Uint8Array(Fs)}async isZip(){return await this.peekSignature()===kn.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(Xe)}async findEndOfCentralDirectoryLocator(){const t=this.tokenizer,r=Math.min(16*1024,t.fileInfo.size),n=this.syncBuffer.subarray(0,r);await this.tokenizer.readBuffer(n,{position:t.fileInfo.size-r});for(let a=n.length-4;a>=0;a--)if(n[a]===Oa[0]&&n[a+1]===Oa[1]&&n[a+2]===Oa[2]&&n[a+3]===Oa[3])return t.fileInfo.size-r+a;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){or("Cannot reading central-directory without random-read support");return}or("Reading central-directory...");const t=this.tokenizer.position,r=await this.findEndOfCentralDirectoryLocator();if(r>0){or("Central-directory 32-bit signature found");const n=await this.tokenizer.readToken(v2,r),a=[];this.tokenizer.setPosition(n.offsetOfStartOfCd);for(let s=0;s<n.nrOfEntriesOfSize;++s){const i=await this.tokenizer.readToken(b2);if(i.signature!==kn.CentralFileHeader)throw new Error("Expected Central-File-Header signature");i.filename=await this.tokenizer.readToken(new br(i.filenameLength,"utf-8")),await this.tokenizer.ignore(i.extraFieldLength),await this.tokenizer.ignore(i.fileCommentLength),a.push(i),or(`Add central-directory file-entry: n=${s+1}/${a.length}: filename=${a[s].filename}`)}return this.tokenizer.setPosition(t),a}this.tokenizer.setPosition(t)}async unzip(t){const r=await this.readCentralDirectory();if(r)return this.iterateOverCentralDirectory(r,t);let n=!1;do{const a=await this.readLocalFileHeader();if(!a)break;const s=t(a);n=!!s.stop;let i;if(await this.tokenizer.ignore(a.extraFieldLength),a.dataDescriptor&&a.compressedSize===0){const l=[];let c=Fs;or("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let d=-1;for(;d<0&&c===Fs;){c=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),d=w2(this.syncBuffer.subarray(0,c),y2);const u=d>=0?d:c;if(s.handler){const m=new Uint8Array(u);await this.tokenizer.readBuffer(m),l.push(m)}else await this.tokenizer.ignore(u)}or(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),s.handler&&await this.inflate(a,j2(l),s.handler)}else s.handler?(or(`Reading compressed-file-data: ${a.compressedSize} bytes`),i=new Uint8Array(a.compressedSize),await this.tokenizer.readBuffer(i),await this.inflate(a,i,s.handler)):(or(`Ignoring compressed-file-data: ${a.compressedSize} bytes`),await this.tokenizer.ignore(a.compressedSize));if(or(`Reading data-descriptor at pos=${this.tokenizer.position}`),a.dataDescriptor&&(await this.tokenizer.readToken(Id)).signature!==134695760)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-Id.len}`)}while(!n)}async iterateOverCentralDirectory(t,r){for(const n of t){const a=r(n);if(a.handler){this.tokenizer.setPosition(n.relativeOffsetOfLocalHeader);const s=await this.readLocalFileHeader();if(s){await this.tokenizer.ignore(s.extraFieldLength);const i=new Uint8Array(n.compressedSize);await this.tokenizer.readBuffer(i),await this.inflate(s,i,a.handler)}}if(a.stop)break}}async inflate(t,r,n){if(t.compressedMethod===0)return n(r);if(t.compressedMethod!==8)throw new Error(`Unsupported ZIP compression method: ${t.compressedMethod}`);or(`Decompress filename=${t.filename}, compressed-size=${r.length}`);const a=await va.decompressDeflateRaw(r);return n(a)}static async decompressDeflateRaw(t){const r=new ReadableStream({start(s){s.enqueue(t),s.close()}}),n=new DecompressionStream("deflate-raw"),a=r.pipeThrough(n);try{const s=await new Response(a).arrayBuffer();return new Uint8Array(s)}catch(s){const i=s instanceof Error?`Failed to deflate ZIP entry: ${s.message}`:"Unknown decompression error in ZIP entry";throw new TypeError(i)}}async readLocalFileHeader(){const t=await this.tokenizer.peekToken(Xe);if(t===kn.LocalFileHeader){const r=await this.tokenizer.readToken(g2);return r.filename=await this.tokenizer.readToken(new br(r.filenameLength,"utf-8")),r}if(t===kn.CentralFileHeader)return!1;throw t===3759263696?new Error("Encrypted ZIP"):new Error("Unexpected signature")}}function w2(e,t){const r=e.length,n=t.length;if(n>r)return-1;for(let a=0;a<=r-n;a++){let s=!0;for(let i=0;i<n;i++)if(e[a+i]!==t[i]){s=!1;break}if(s)return a}return-1}function j2(e){const t=e.reduce((a,s)=>a+s.length,0),r=new Uint8Array(t);let n=0;for(const a of e)r.set(a,n),n+=a.length;return r}class k2{constructor(t){this.tokenizer=t}inflate(){const t=this.tokenizer;return new ReadableStream({async pull(r){const n=new Uint8Array(1024),a=await t.readBuffer(n,{mayBeLess:!0});if(a===0){r.close();return}r.enqueue(n.subarray(0,a))}}).pipeThrough(new DecompressionStream("gzip"))}}new globalThis.TextDecoder("utf8");new globalThis.TextEncoder;Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Pd(e){const{byteLength:t}=e;if(t===6)return e.getUint16(0)*2**32+e.getUint32(2);if(t===5)return e.getUint8(0)*2**32+e.getUint32(1);if(t===4)return e.getUint32(0);if(t===3)return e.getUint8(0)*2**16+e.getUint16(1);if(t===2)return e.getUint16(0);if(t===1)return e.getUint8(0)}function C2(e,t){if(t==="utf-16le"){const r=[];for(let n=0;n<e.length;n++){const a=e.charCodeAt(n);r.push(a&255,a>>8&255)}return r}if(t==="utf-16be"){const r=[];for(let n=0;n<e.length;n++){const a=e.charCodeAt(n);r.push(a>>8&255,a&255)}return r}return[...e].map(r=>r.charCodeAt(0))}function N2(e,t=0){const r=Number.parseInt(new br(6).get(e,148).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(r))return!1;let n=256;for(let a=t;a<t+148;a++)n+=e[a];for(let a=t+156;a<t+512;a++)n+=e[a];return r===n}const S2={get:(e,t)=>e[t+3]&127|e[t+2]<<7|e[t+1]<<14|e[t]<<21,len:4},$2=["jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","oga","ogg","ogv","opus","flac","wav","spx","amr","pdf","epub","elf","macho","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ttc","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","j2c","jp2","jpm","jpx","mj2","aif","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","dcm","ics","glb","pcap","dsf","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a","mie","asf","ogm","ogx","mpc","arrow","shp","aac","mp1","it","s3m","xm","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet","class","arj","cpio","ace","avro","icc","fbx","vsdx","vtt","apk","drc","lz4","potx","xltx","dotx","xltm","ott","ots","otp","odg","otg","xlsm","docm","dotm","potm","pptm","jar","jmp","rm","sav","ppsm","ppsx","tar.gz","reg","dat"],E2=["image/jpeg","image/png","image/gif","image/webp","image/flif","image/x-xcf","image/x-canon-cr2","image/x-canon-cr3","image/tiff","image/bmp","image/vnd.ms-photo","image/vnd.adobe.photoshop","application/x-indesign","application/epub+zip","application/x-xpinstall","application/vnd.ms-powerpoint.slideshow.macroenabled.12","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.slideshow","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/vnd.apache.arrow.file","video/mp4","audio/midi","video/matroska","video/webm","video/quicktime","video/vnd.avi","audio/wav","audio/qcelp","audio/x-ms-asf","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","video/ogg","audio/ogg","audio/ogg; codecs=opus","application/ogg","audio/flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-elf","application/x-mach-binary","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","font/collection","image/x-icon","video/x-flv","application/postscript","application/eps","application/x-xz","application/x-sqlite3","application/x-nintendo-nes-rom","application/x-google-chrome-extension","application/vnd.ms-cab-compressed","application/x-deb","application/x-unix-archive","application/x-rpm","application/x-compress","application/x-lzip","application/x-cfb","application/x-mie","application/mxf","video/mp2t","application/x-blender","image/bpg","image/j2c","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","application/xml","application/x-mobipocket-ebook","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/icns","image/ktx","application/dicom","audio/x-musepack","text/calendar","text/vcard","text/vtt","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","application/x.ms.shortcut","application/x.apple.alias","audio/x-voc","audio/vnd.dolby.dd-raw","audio/x-m4a","image/apng","image/x-olympus-orf","image/x-sony-arw","image/x-adobe-dng","image/x-nikon-nef","image/x-panasonic-rw2","image/x-fujifilm-raf","video/x-m4v","video/3gpp2","application/x-esri-shape","audio/aac","audio/x-it","audio/x-s3m","audio/x-xm","video/MP1S","video/MP2P","application/vnd.sketchup.skp","image/avif","application/x-lzh-compressed","application/pgp-encrypted","application/x-asar","model/stl","application/vnd.ms-htmlhelp","model/3mf","image/jxl","application/zstd","image/jls","application/vnd.ms-outlook","image/vnd.dwg","application/vnd.apache.parquet","application/java-vm","application/x-arj","application/x-cpio","application/x-ace-compressed","application/avro","application/vnd.iccprofile","application/x.autodesk.fbx","application/vnd.visio","application/vnd.android.package-archive","application/vnd.google.draco","application/x-lz4","application/vnd.openxmlformats-officedocument.presentationml.template","application/vnd.openxmlformats-officedocument.spreadsheetml.template","application/vnd.openxmlformats-officedocument.wordprocessingml.template","application/vnd.ms-excel.template.macroenabled.12","application/vnd.oasis.opendocument.text-template","application/vnd.oasis.opendocument.spreadsheet-template","application/vnd.oasis.opendocument.presentation-template","application/vnd.oasis.opendocument.graphics","application/vnd.oasis.opendocument.graphics-template","application/vnd.ms-excel.sheet.macroenabled.12","application/vnd.ms-word.document.macroenabled.12","application/vnd.ms-word.template.macroenabled.12","application/vnd.ms-powerpoint.template.macroenabled.12","application/vnd.ms-powerpoint.presentation.macroenabled.12","application/java-archive","application/vnd.rn-realmedia","application/x-spss-sav","application/x-ms-regedit","application/x-ft-windows-registry-hive","application/x-jmp-data"],Jn=4100,D2=Jn-2,mr=1024*1024,_d=1024,T2=2**31-1,Vt=16*1024*1024,Jo=mr,Od=mr,A2=Vt,R2=1,Fd=100,zs=Vt,zd=64,Ld=Jo,I2=256,P2=512,_2=Vt,O2=512,F2=512,Md=256,Vd=Jo,Bd=Jo,z2=Jo,Ud=Vt,L2=new Set(["Unexpected signature","Encrypted ZIP","Expected Central-File-Header signature"]),M2=["ZIP entry count exceeds ","Unsupported ZIP compression method:","ZIP entry compressed data exceeds ","ZIP entry decompressed data exceeds ","Expected data-descriptor-signature at position "],V2=new Set(["Z_BUF_ERROR","Z_DATA_ERROR","ERR_INVALID_STATE"]);class Jr extends Error{}function B2(e){var t;const r=e==null?void 0:e.streamReader;if(((t=r==null?void 0:r.constructor)==null?void 0:t.name)!=="WebStreamByobReader")return e;const{reader:n}=r,a=async()=>{await n.cancel(),n.releaseLock()};return r.close=a,r.abort=async()=>{r.interrupted=!0,await a()},e}function Ol(e,t,r){if(!Number.isFinite(e)||e<0||e>t)throw new Jr(`${r} has invalid size ${e} (maximum ${t} bytes)`);return e}async function Ir(e,t,{maximumLength:r=Vt,reason:n="skip"}={}){const a=Ol(t,r,n);await e.ignore(a)}async function Ls(e,t,r,{maximumLength:n=t.length,reason:a="read"}={}){const s=t.length,i=Ol(s,n,a);return e.readBuffer(t,{...r,length:i})}async function U2(e,{maximumLength:t=mr}={}){const r=new ReadableStream({start(l){l.enqueue(e),l.close()}}).pipeThrough(new DecompressionStream("deflate-raw")).getReader(),n=[];let a=0;try{for(;;){const{done:l,value:c}=await r.read();if(l)break;if(a+=c.length,a>t)throw await r.cancel(),new Error(`ZIP entry decompressed data exceeds ${t} bytes`);n.push(c)}}finally{r.releaseLock()}const s=new Uint8Array(a);let i=0;for(const l of n)s.set(l,i),i+=l.length;return s}const vx=134695760,io=16,H2=io-1;function W2(e,t){if(e.length<io)return-1;const r=e.length-io;for(let n=0;n<=r;n++)if(Xe.get(e,n)===vx&&Xe.get(e,n+8)===t+n)return n;return-1}function q2(e){return(e.codePointAt(0)&32)!==0}function G2(e,t){const r=new Uint8Array(t);let n=0;for(const a of e)r.set(a,n),n+=a.length;return r}async function X2(e,{shouldBuffer:t,maximumLength:r=mr}={}){const{syncBuffer:n}=e,{length:a}=n,s=[];let i=0;for(;;){const l=await e.tokenizer.peekBuffer(n,{mayBeLess:!0}),c=W2(n.subarray(0,l),i),d=c>=0?0:l===a?Math.min(H2,l-1):0,u=c>=0?c:l-d;if(u===0)break;if(i+=u,i>r)throw new Error(`ZIP entry compressed data exceeds ${r} bytes`);if(t){const m=new Uint8Array(u);await e.tokenizer.readBuffer(m),s.push(m)}else await e.tokenizer.ignore(u);if(c>=0)break}if(pt(e.tokenizer)||(e.knownSizeDescriptorScannedBytes+=i),!!t)return G2(s,i)}function Z2(e,t){return pt(e.tokenizer)?Math.max(0,Vt-(e.tokenizer.position-t)):Math.max(0,mr-e.knownSizeDescriptorScannedBytes)}async function K2(e,t,{shouldBuffer:r,maximumDescriptorLength:n=mr}={}){if(t.dataDescriptor&&t.compressedSize===0)return X2(e,{shouldBuffer:r,maximumLength:n});if(!r){await Ir(e.tokenizer,t.compressedSize,{maximumLength:pt(e.tokenizer)?mr:e.tokenizer.fileInfo.size,reason:"ZIP entry compressed data"});return}const a=nS(e.tokenizer);if(!Number.isFinite(t.compressedSize)||t.compressedSize<0||t.compressedSize>a)throw new Error(`ZIP entry compressed data exceeds ${a} bytes`);const s=new Uint8Array(t.compressedSize);return await e.tokenizer.readBuffer(s),s}va.prototype.inflate=async function(e,t,r){if(e.compressedMethod===0)return r(t);if(e.compressedMethod!==8)throw new Error(`Unsupported ZIP compression method: ${e.compressedMethod}`);const n=await U2(t,{maximumLength:mr});return r(n)};va.prototype.unzip=async function(e){let t=!1,r=0;const n=this.tokenizer.position;this.knownSizeDescriptorScannedBytes=0;do{if(Qn(this.tokenizer,n,Vt))throw new Jr(`ZIP stream probing exceeds ${Vt} bytes`);const a=await this.readLocalFileHeader();if(!a)break;if(r++,r>_d)throw new Error(`ZIP entry count exceeds ${_d}`);const s=e(a);t=!!s.stop,await this.tokenizer.ignore(a.extraFieldLength);const i=await K2(this,a,{shouldBuffer:!!s.handler,maximumDescriptorLength:Math.min(mr,Z2(this,n))});if(s.handler&&await this.inflate(a,i,s.handler),a.dataDescriptor){const l=new Uint8Array(io);if(await this.tokenizer.readBuffer(l),Xe.get(l,0)!==vx)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-l.length}`)}if(Qn(this.tokenizer,n,Vt))throw new Jr(`ZIP stream probing exceeds ${Vt} bytes`)}while(!t)};function Y2(e,t){const r=e.getReader();let n=0,a=!1,s=!1;const i=async l=>{a||s||(s=!0,await r.cancel(l))};return new ReadableStream({async pull(l){if(n>=t){l.close(),await i();return}const{done:c,value:d}=await r.read();if(c||!d){a=!0,l.close();return}const u=t-n;if(d.length>u){l.enqueue(d.subarray(0,u)),n+=u,l.close(),await i();return}l.enqueue(d),n+=d.length},async cancel(l){await i(l)}})}async function J2(e,t){return new Fl(t).fromBlob(e)}function Hd(e){switch(e=e.toLowerCase(),e){case"application/epub+zip":return{ext:"epub",mime:e};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:e};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:e};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:e};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:e};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:e};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:e};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:e};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:e};case"application/vnd.openxmlformats-officedocument.presentationml.slideshow":return{ext:"ppsx",mime:e};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:e};case"application/vnd.ms-excel.sheet.macroenabled":return{ext:"xlsm",mime:"application/vnd.ms-excel.sheet.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.spreadsheetml.template":return{ext:"xltx",mime:e};case"application/vnd.ms-excel.template.macroenabled":return{ext:"xltm",mime:"application/vnd.ms-excel.template.macroenabled.12"};case"application/vnd.ms-powerpoint.slideshow.macroenabled":return{ext:"ppsm",mime:"application/vnd.ms-powerpoint.slideshow.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return{ext:"docx",mime:e};case"application/vnd.ms-word.document.macroenabled":return{ext:"docm",mime:"application/vnd.ms-word.document.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.template":return{ext:"dotx",mime:e};case"application/vnd.ms-word.template.macroenabledtemplate":return{ext:"dotm",mime:"application/vnd.ms-word.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.template":return{ext:"potx",mime:e};case"application/vnd.ms-powerpoint.template.macroenabled":return{ext:"potm",mime:"application/vnd.ms-powerpoint.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.presentation":return{ext:"pptx",mime:e};case"application/vnd.ms-powerpoint.presentation.macroenabled":return{ext:"pptm",mime:"application/vnd.ms-powerpoint.presentation.macroenabled.12"};case"application/vnd.ms-visio.drawing":return{ext:"vsdx",mime:"application/vnd.visio"};case"application/vnd.ms-package.3dmanufacturing-3dmodel+xml":return{ext:"3mf",mime:"model/3mf"}}}function sr(e,t,r){r={offset:0,...r};for(const[n,a]of t.entries())if(r.mask){if(a!==(r.mask[n]&e[n+r.offset]))return!1}else if(a!==e[n+r.offset])return!1;return!0}function Q2(e){return Number.isFinite(e)?Math.max(1,Math.trunc(e)):Jn}function eS(e,t,r){return r===void 0?e.read(t):(r.throwIfAborted(),new Promise((n,a)=>{const s=()=>{r.removeEventListener("abort",i)},i=()=>{const l=r.reason;s(),(async()=>{try{await e.cancel(l)}catch{}})(),a(l)};r.addEventListener("abort",i,{once:!0}),(async()=>{try{const l=await e.read(t);s(),n(l)}catch(l){s(),a(l)}})()}))}function tS(e){return Number.isFinite(e)?Math.max(0,Math.min(D2,Math.trunc(e))):0}function rS(e){return Number.isFinite(e)?Math.max(0,e):Number.MAX_SAFE_INTEGER}function pt(e){const t=e.fileInfo.size;return!Number.isFinite(t)||t===Number.MAX_SAFE_INTEGER}function Qn(e,t,r){return pt(e)&&e.position-t>r}function nS(e){const t=e.fileInfo.size,r=Number.isFinite(t)?Math.max(0,t-e.position):Number.MAX_SAFE_INTEGER;return Math.min(r,T2)}function aS(e){if(e instanceof Qe||e instanceof Jr)return!0;if(!(e instanceof Error))return!1;if(L2.has(e.message)||V2.has(e.code))return!0;for(const t of M2)if(e.message.startsWith(t))return!0;return!1}function Wd(e,t=mr){const r=[e.compressedSize,e.uncompressedSize];for(const n of r)if(!Number.isFinite(n)||n<0||n>t)return!1;return!0}function oS(){return{hasContentTypesEntry:!1,hasParsedContentTypesEntry:!1,isParsingContentTypes:!1,hasUnparseableContentTypes:!1,hasWordDirectory:!1,hasPresentationDirectory:!1,hasSpreadsheetDirectory:!1,hasThreeDimensionalModelEntry:!1}}function sS(e,t){t.startsWith("word/")&&(e.hasWordDirectory=!0),t.startsWith("ppt/")&&(e.hasPresentationDirectory=!0),t.startsWith("xl/")&&(e.hasSpreadsheetDirectory=!0),t.startsWith("3D/")&&t.endsWith(".model")&&(e.hasThreeDimensionalModelEntry=!0)}function qd(e){if(!(!e.hasContentTypesEntry||e.hasUnparseableContentTypes||e.isParsingContentTypes||e.hasParsedContentTypesEntry)){if(e.hasWordDirectory)return{ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"};if(e.hasPresentationDirectory)return{ext:"pptx",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"};if(e.hasSpreadsheetDirectory)return{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};if(e.hasThreeDimensionalModelEntry)return{ext:"3mf",mime:"model/3mf"}}}function iS(e){const t=e.indexOf('.main+xml"');if(t===-1){const a="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";return e.includes(`ContentType="${a}"`)?a:void 0}const r=e.slice(0,t),n=r.lastIndexOf('"');return r.slice(n+1)}class Fl{constructor(t){$d(this,"detectConfident",async n=>{if(this.buffer=new Uint8Array(Jn),n.fileInfo.size===void 0&&(n.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=n,pt(n)&&(await n.peekBuffer(this.buffer,{length:3,mayBeLess:!0}),this.check([31,139,8])))return this.detectGzip(n);if(await n.peekBuffer(this.buffer,{length:32,mayBeLess:!0}),this.check([66,77]))return{ext:"bmp",mime:"image/bmp"};if(this.check([11,119]))return{ext:"ac3",mime:"audio/vnd.dolby.dd-raw"};if(this.check([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(this.check([77,90]))return{ext:"exe",mime:"application/x-msdownload"};if(this.check([37,33]))return await n.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString("PS-Adobe-",{offset:2})&&this.checkString(" EPSF-",{offset:14})?{ext:"eps",mime:"application/eps"}:{ext:"ps",mime:"application/postscript"};if(this.check([31,160])||this.check([31,157]))return{ext:"Z",mime:"application/x-compress"};if(this.check([199,113]))return{ext:"cpio",mime:"application/x-cpio"};if(this.check([96,234]))return{ext:"arj",mime:"application/x-arj"};if(this.check([239,187,191]))return this.detectionReentryCount>=Md?void 0:(this.detectionReentryCount++,await this.tokenizer.ignore(3),this.detectConfident(n));if(this.check([71,73,70]))return{ext:"gif",mime:"image/gif"};if(this.check([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(this.check([31,139,8]))return this.detectGzip(n);if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await Ir(n,6,{maximumLength:6,reason:"ID3 header prefix"});const a=await n.readToken(S2),s=pt(n);if(!Number.isFinite(a)||a<0||s&&(a>zs||n.position+a>zs))return;if(n.position+a>n.fileInfo.size)return s?void 0:{ext:"mp3",mime:"audio/mpeg"};try{await Ir(n,a,{maximumLength:s?zs:n.fileInfo.size,reason:"ID3 payload"})}catch(i){if(i instanceof Qe)return;throw i}return this.detectionReentryCount>=Md?void 0:(this.detectionReentryCount++,this.parseTokenizer(n,this.detectionReentryCount))}if(this.checkString("MP+"))return{ext:"mpc",mime:"audio/x-musepack"};if((this.buffer[0]===67||this.buffer[0]===70)&&this.check([87,83],{offset:1}))return{ext:"swf",mime:"application/x-shockwave-flash"};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:"jls",mime:"image/jls"}:{ext:"jpg",mime:"image/jpeg"};if(this.check([79,98,106,1]))return{ext:"avro",mime:"application/avro"};if(this.checkString("FLIF"))return{ext:"flif",mime:"image/flif"};if(this.checkString("8BPS"))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(this.checkString("MPCK"))return{ext:"mpc",mime:"audio/x-musepack"};if(this.checkString("FORM"))return{ext:"aif",mime:"audio/aiff"};if(this.checkString("icns",{offset:0}))return{ext:"icns",mime:"image/icns"};if(this.check([80,75,3,4])){let a;const s=oS();try{await new va(n).unzip(i=>{sS(s,i.filename);const l=i.filename==="[Content_Types].xml",c=qd(s);if(!l&&c)return a=c,{stop:!0};switch(i.filename){case"META-INF/mozilla.rsa":return a={ext:"xpi",mime:"application/x-xpinstall"},{stop:!0};case"META-INF/MANIFEST.MF":return a={ext:"jar",mime:"application/java-archive"},{stop:!0};case"mimetype":return Wd(i,Od)?{async handler(d){const u=new TextDecoder("utf-8").decode(d).trim();a=Hd(u)},stop:!0}:{};case"[Content_Types].xml":return s.hasContentTypesEntry=!0,Wd(i,Od)?(s.isParsingContentTypes=!0,{async handler(d){const u=new TextDecoder("utf-8").decode(d),m=iS(u);m&&(a=Hd(m)),s.hasParsedContentTypesEntry=!0,s.isParsingContentTypes=!1},stop:!0}):(s.hasUnparseableContentTypes=!0,{});default:return/classes\d*\.dex/.test(i.filename)?(a={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}})}catch(i){if(!aS(i))throw i;s.isParsingContentTypes&&(s.isParsingContentTypes=!1,s.hasUnparseableContentTypes=!0)}return a??qd(s)??{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await n.ignore(28);const a=new Uint8Array(8);return await n.readBuffer(a),sr(a,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:sr(a,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:sr(a,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:sr(a,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:sr(a,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:sr(a,[1,118,111,114,98,105,115])?{ext:"ogg",mime:"audio/ogg"}:{ext:"ogx",mime:"application/ogg"}}if(this.check([80,75])&&(this.buffer[2]===3||this.buffer[2]===5||this.buffer[2]===7)&&(this.buffer[3]===4||this.buffer[3]===6||this.buffer[3]===8))return{ext:"zip",mime:"application/zip"};if(this.checkString("MThd"))return{ext:"mid",mime:"audio/midi"};if(this.checkString("wOFF")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff",mime:"font/woff"};if(this.checkString("wOF2")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff2",mime:"font/woff2"};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:"pcap",mime:"application/vnd.tcpdump.pcap"};if(this.checkString("DSD "))return{ext:"dsf",mime:"audio/x-dsf"};if(this.checkString("LZIP"))return{ext:"lz",mime:"application/x-lzip"};if(this.checkString("fLaC"))return{ext:"flac",mime:"audio/flac"};if(this.check([66,80,71,251]))return{ext:"bpg",mime:"image/bpg"};if(this.checkString("wvpk"))return{ext:"wv",mime:"audio/wavpack"};if(this.checkString("%PDF"))return{ext:"pdf",mime:"application/pdf"};if(this.check([0,97,115,109]))return{ext:"wasm",mime:"application/wasm"};if(this.check([73,73])){const a=await this.readTiffHeader(!1);if(a)return a}if(this.check([77,77])){const a=await this.readTiffHeader(!0);if(a)return a}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163])){async function a(){const d=await n.peekNumber(YN);let u=128,m=0;for(;!(d&u)&&u!==0;)++m,u>>=1;const p=new Uint8Array(m+1);return await Ls(n,p,void 0,{maximumLength:p.length,reason:"EBML field"}),p}async function s(){const d=await a(),u=await a();u[0]^=128>>u.length-1;const m=Math.min(6,u.length),p=new DataView(d.buffer),f=new DataView(u.buffer,u.length-m,m);return{id:Pd(p),len:Pd(f)}}async function i(d){let u=0;for(;d>0;){if(u++,u>I2||Qn(n,c,Vt))return;const m=n.position,p=await s();if(p.id===17026){if(p.len>zd)return;const f=Ol(p.len,zd,"EBML DocType");return(await n.readToken(new br(f))).replaceAll(/\00.*$/g,"")}if(pt(n)&&(!Number.isFinite(p.len)||p.len<0||p.len>Ld)||(await Ir(n,p.len,{maximumLength:pt(n)?Ld:n.fileInfo.size,reason:"EBML payload"}),--d,n.position<=m))return}}const l=await s(),c=n.position;switch(await i(l.len)){case"webm":return{ext:"webm",mime:"video/webm"};case"matroska":return{ext:"mkv",mime:"video/matroska"};default:return}}if(this.checkString("SQLi"))return{ext:"sqlite",mime:"application/x-sqlite3"};if(this.check([78,69,83,26]))return{ext:"nes",mime:"application/x-nintendo-nes-rom"};if(this.checkString("Cr24"))return{ext:"crx",mime:"application/x-google-chrome-extension"};if(this.checkString("MSCF")||this.checkString("ISc("))return{ext:"cab",mime:"application/vnd.ms-cab-compressed"};if(this.check([237,171,238,219]))return{ext:"rpm",mime:"application/x-rpm"};if(this.check([197,208,211,198]))return{ext:"eps",mime:"application/eps"};if(this.check([40,181,47,253]))return{ext:"zst",mime:"application/zstd"};if(this.check([127,69,76,70]))return{ext:"elf",mime:"application/x-elf"};if(this.check([33,66,68,78]))return{ext:"pst",mime:"application/vnd.ms-outlook"};if(this.checkString("PAR1")||this.checkString("PARE"))return{ext:"parquet",mime:"application/vnd.apache.parquet"};if(this.checkString("ttcf"))return{ext:"ttc",mime:"font/collection"};if(this.check([254,237,250,206])||this.check([254,237,250,207])||this.check([206,250,237,254])||this.check([207,250,237,254]))return{ext:"macho",mime:"application/x-mach-binary"};if(this.check([4,34,77,24]))return{ext:"lz4",mime:"application/x-lz4"};if(this.checkString("regf"))return{ext:"dat",mime:"application/x-ft-windows-registry-hive"};if(this.checkString("$FL2")||this.checkString("$FL3"))return{ext:"sav",mime:"application/x-spss-sav"};if(this.check([79,84,84,79,0]))return{ext:"otf",mime:"font/otf"};if(this.checkString("#!AMR"))return{ext:"amr",mime:"audio/amr"};if(this.checkString("{\\rtf"))return{ext:"rtf",mime:"application/rtf"};if(this.check([70,76,86,1]))return{ext:"flv",mime:"video/x-flv"};if(this.checkString("IMPM"))return{ext:"it",mime:"audio/x-it"};if(this.checkString("-lh0-",{offset:2})||this.checkString("-lh1-",{offset:2})||this.checkString("-lh2-",{offset:2})||this.checkString("-lh3-",{offset:2})||this.checkString("-lh4-",{offset:2})||this.checkString("-lh5-",{offset:2})||this.checkString("-lh6-",{offset:2})||this.checkString("-lh7-",{offset:2})||this.checkString("-lzs-",{offset:2})||this.checkString("-lz4-",{offset:2})||this.checkString("-lz5-",{offset:2})||this.checkString("-lhd-",{offset:2}))return{ext:"lzh",mime:"application/x-lzh-compressed"};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:"mpg",mime:"video/MP1S"};if(this.check([68],{offset:4,mask:[196]}))return{ext:"mpg",mime:"video/MP2P"}}if(this.checkString("ITSF"))return{ext:"chm",mime:"application/vnd.ms-htmlhelp"};if(this.check([202,254,186,190])){const a=Td.get(this.buffer,4),s=gn.get(this.buffer,6);if(a>0&&a<=30)return{ext:"macho",mime:"application/x-mach-binary"};if(s>30)return{ext:"class",mime:"application/java-vm"}}if(this.checkString(".RMF"))return{ext:"rm",mime:"application/vnd.rn-realmedia"};if(this.checkString("DRACO"))return{ext:"drc",mime:"application/vnd.google.draco"};if(this.check([253,55,122,88,90,0]))return{ext:"xz",mime:"application/x-xz"};if(this.checkString("<?xml "))return{ext:"xml",mime:"application/xml"};if(this.check([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(this.check([82,97,114,33,26,7])&&(this.buffer[6]===0||this.buffer[6]===1))return{ext:"rar",mime:"application/x-rar-compressed"};if(this.checkString("solid "))return{ext:"stl",mime:"model/stl"};if(this.checkString("AC")){const a=new br(4,"latin1").get(this.buffer,2);if(a.match("^d*")&&a>=1e3&&a<=1050)return{ext:"dwg",mime:"image/vnd.dwg"}}if(this.checkString("070707"))return{ext:"cpio",mime:"application/x-cpio"};if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!<arch>"))return await n.ignore(8),await n.readToken(new br(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("WEBVTT")&&[`
|
|
82
|
+
`,{offset:2,encoding:a})?{ext:"reg",mime:"application/x-ms-regedit"}:void 0}if(this.checkString("-----BEGIN PGP MESSAGE-----"))return{ext:"pgp",mime:"application/pgp-encrypted"}}),Ic(this,"detectImprecise",async n=>{this.buffer=new Uint8Array(Kn);const a=dk(n.fileInfo.size);if(await n.peekBuffer(this.buffer,{length:Math.min(8,a),mayBeLess:!0}),this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(this.check([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(this.check([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(this.check([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(await n.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,a),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let s=0;s<=this.options.mpegOffsetTolerance;++s){const i=this.scanMpeg(s);if(i)return i}});const r=ck(t==null?void 0:t.mpegOffsetTolerance);this.options={...t,mpegOffsetTolerance:r},this.detectors=[...this.options.customDetectors??[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:this.options.signal},this.gzipProbeDepth=0}getTokenizerOptions(){return{...this.tokenizerOptions}}createTokenizerFromWebStream(t){return Kj(gj(t,this.getTokenizerOptions()))}async parseTokenizer(t,r=0){this.detectionReentryCount=r;const n=t.position;for(const a of this.detectors){let s;try{s=await a.detect(t)}catch(i){if(i instanceof Je||i instanceof Yr)return;throw i}if(s)return s;if(n!==t.position)return}}async fromTokenizer(t){try{return await this.parseTokenizer(t)}finally{await t.close()}}async fromBuffer(t){if(!(t instanceof Uint8Array||t instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof t}\``);const r=t instanceof Uint8Array?t:new Uint8Array(t);if((r==null?void 0:r.length)>1)return this.fromTokenizer(vj(r,this.getTokenizerOptions()))}async fromBlob(t){var r;(r=this.options.signal)==null||r.throwIfAborted();const n=bj(t,this.getTokenizerOptions());return this.fromTokenizer(n)}async fromStream(t){var r;(r=this.options.signal)==null||r.throwIfAborted();const n=this.createTokenizerFromWebStream(t);return this.fromTokenizer(n)}async toDetectionStream(t,r){const n=ik((r==null?void 0:r.sampleSize)??Kn);let a,s;const i=t.getReader({mode:"byob"});try{const{value:d,done:u}=await lk(i,new Uint8Array(n),this.options.signal);if(s=d,!u&&d)try{a=await this.fromBuffer(d.subarray(0,n))}catch(m){if(!(m instanceof Je))throw m;a=void 0}s=d}finally{i.releaseLock()}const l=new TransformStream({async start(d){d.enqueue(s)},transform(d,u){u.enqueue(d)}}),c=t.pipeThrough(l);return c.fileType=a,c}async detectGzip(t){var r;if(this.gzipProbeDepth>=Mj)return{ext:"gz",mime:"application/gzip"};const n=new Aj(t),a=ok(n.inflate(),Lj),s=mt(t);let i,l,c,d;if(s){const u=new AbortController;i=setTimeout(()=>{u.abort(new DOMException(`Operation timed out after ${Uc} ms`,"TimeoutError"))},Uc),l=this.options.signal===void 0?u.signal:AbortSignal.any([this.options.signal,u.signal]),c=new ch({...this.options,signal:l}),c.gzipProbeDepth=this.gzipProbeDepth+1}else this.gzipProbeDepth++;try{d=await(c??this).fromStream(a)}catch(u){if((u==null?void 0:u.name)==="AbortError"&&((r=l==null?void 0:l.reason)==null?void 0:r.name)!=="TimeoutError")throw u}finally{clearTimeout(i),s||this.gzipProbeDepth--}return(d==null?void 0:d.ext)==="tar"?{ext:"tar.gz",mime:"application/gzip"}:{ext:"gz",mime:"application/gzip"}}check(t,r){return ar(this.buffer,t,r)}checkString(t,r){return this.check(Rj(t,r==null?void 0:r.encoding),r)}async readTiffTag(t){const r=await this.tokenizer.readToken(t?fn:Ue);switch(await this.tokenizer.ignore(10),r){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"}}}async readTiffIFD(t){const r=await this.tokenizer.readToken(t?fn:Ue);if(!(r>Wj)&&!(mt(this.tokenizer)&&2+r*12>Zc))for(let n=0;n<r;++n){const a=await this.readTiffTag(t);if(a)return a}}async readTiffHeader(t){const r={ext:"tif",mime:"image/tiff"},n=(t?fn:Ue).get(this.buffer,2),a=(t?Oc:Ge).get(this.buffer,4);if(n===42){if(a>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(a>=8){const l=(t?fn:Ue).get(this.buffer,8),c=(t?fn:Ue).get(this.buffer,10);if(l===28&&c===254||l===31&&c===11)return{ext:"nef",mime:"image/x-nikon-nef"}}}if(mt(this.tokenizer)&&a>qj)return r;const s=mt(this.tokenizer)?Zc:this.tokenizer.fileInfo.size;try{await Rr(this.tokenizer,a,{maximumLength:s,reason:"TIFF IFD offset"})}catch(l){if(l instanceof Je)return;throw l}let i;try{i=await this.readTiffIFD(t)}catch(l){if(l instanceof Je)return;throw l}return i??r}if(n===43)return r}scanMpeg(t){if(this.check([255,224],{offset:t,mask:[255,224]})){if(this.check([16],{offset:t+1,mask:[22]}))return this.check([8],{offset:t+1,mask:[8]})?{ext:"aac",mime:"audio/aac"}:{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:t+1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:t+1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:t+1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}};new Set(_j);new Set(Oj);const Qc=e=>e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`,xl=({name:e,control:t,disabled:r,campo:n,fileTypes:a,maxFileSize:s})=>{var i;const{field:l,fieldState:c}=$e.useController({name:e,control:t}),{uploadFile:d,deleteUploadedFile:u}=Nr(),[m,p]=N.useState({status:"idle"}),f=N.useRef(null),[b,h]=N.useState(!1),x=N.useRef(!0);N.useEffect(()=>()=>{x.current=!1},[]);const y=typeof l.value=="string"&&l.value?l.value:null,v=N.useCallback(async S=>{var $;if(a&&a.length>0){const k=await sk(S),E=(k==null?void 0:k.ext)??"",D=(k==null?void 0:k.mime)??"",O=(($=S.name.split(".").pop())==null?void 0:$.toLowerCase())??"",L=S.type.toLowerCase();if(!a.some(A=>{const z=A.toLowerCase();return!!(E&&(z===E||z===D)||D&&z.endsWith("/*")&&D.startsWith(z.slice(0,-1))||!E&&(z===O||z===L||z.endsWith("/*")&&L.startsWith(z.slice(0,-1))))})){p({status:"error",message:`Tipo de arquivo não permitido. Permitidos: ${a.join(", ")}`});return}}if(s&&S.size>s){p({status:"error",message:`Arquivo muito grande. Tamanho máximo: ${Qc(s)}`});return}if(!d){p({status:"error",message:"Preview: upload não disponível sem configuração."});return}p({status:"uploading",fileName:S.name,progress:0});try{if(y&&u)try{await u(y)}catch{}const k=await d(S,n??e,E=>{x.current&&p(D=>D.status==="uploading"?{...D,progress:Math.min(100,E)}:D)});if(!x.current)return;l.onChange(k),p({status:"done",uploadId:k,fileName:S.name,size:S.size})}catch{if(!x.current)return;p({status:"error",message:"Falha no upload. Tente novamente."})}},[d,u,y,n,e,l,a,s]),j=N.useCallback(S=>{var $;const k=($=S.target.files)==null?void 0:$[0];k&&v(k),S.target.value=""},[v]),w=N.useCallback(()=>{l.onChange(""),p({status:"idle"}),f.current&&(f.current.value="")},[l]);if(m.status==="done"||m.status==="idle"&&y){const S=m.status==="done"?m.fileName:"Arquivo enviado",$=m.status==="done"?m.size:null;return o.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-green-500 bg-green-500/5 px-4 py-3 gap-2",children:[o.jsxs("svg",{className:"shrink-0 text-green-500",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[o.jsx("rect",{width:"20",height:"20",rx:"4",fill:"currentColor",fillOpacity:"0.15"}),o.jsx("path",{d:"M5 10.5L8.5 14L15 7",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),o.jsx("span",{className:"text-sm font-medium truncate flex-1",children:S}),$!==null&&o.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:Qc($)}),!r&&o.jsx("button",{type:"button",onClick:w,className:"ml-2 shrink-0 text-muted-foreground hover:text-destructive transition-colors","aria-label":"Remover arquivo",children:"✕"})]})}if(m.status==="uploading"){const{fileName:S,progress:$}=m;return o.jsxs("div",{className:"rounded-lg border border-input px-4 py-3 space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-sm font-medium truncate flex-1",children:S}),o.jsxs("span",{className:"text-xs text-muted-foreground ml-2",children:[$,"%"]})]}),o.jsx("div",{className:"h-2 rounded-full bg-muted overflow-hidden",children:o.jsx("div",{className:"h-full bg-primary transition-all duration-200 rounded-full",style:{width:`${$}%`}})})]})}const C=m.status==="error";return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{role:"button",tabIndex:r?-1:0,"aria-label":"Selecionar arquivo",className:K("flex items-center justify-center rounded-lg border-2 border-dashed px-4 py-6 transition-colors cursor-pointer",b?"border-primary bg-primary/5":C||c.error?"border-destructive bg-destructive/5":"border-input hover:border-muted-foreground hover:bg-muted/20",r&&"opacity-50 cursor-not-allowed"),onClick:()=>{var S;return!r&&((S=f.current)==null?void 0:S.click())},onKeyDown:S=>{var $;(S.key==="Enter"||S.key===" ")&&(($=f.current)==null||$.click())},onDragOver:S=>{S.preventDefault(),r||h(!0)},onDragLeave:()=>h(!1),onDrop:r?void 0:S=>{var $;S.preventDefault(),h(!1);const k=($=S.dataTransfer.files)==null?void 0:$[0];k&&v(k)},onBlur:l.onBlur,children:[o.jsx("input",{ref:f,type:"file",onChange:j,disabled:r,className:"sr-only"}),o.jsx("span",{className:"text-sm text-muted-foreground",children:b?"Solte o arquivo aqui":"Clique ou arraste um arquivo"})]}),C&&o.jsxs("p",{className:"text-sm text-destructive",children:[m.message," · ",o.jsx("button",{type:"button",className:"underline hover:no-underline",onClick:()=>p({status:"idle"}),children:"Tentar novamente"})]}),!C&&((i=c.error)==null?void 0:i.message)&&o.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})},gk={cpf:e=>e.replace(/\D/g,"").slice(0,11).replace(/(\d{3})(\d)/,"$1.$2").replace(/(\d{3})(\d)/,"$1.$2").replace(/(\d{3})(\d{1,2})$/,"$1-$2"),telefone:e=>{const t=e.replace(/\D/g,"").slice(0,11);return t.length<=10?t.replace(/(\d{2})(\d)/,"($1) $2").replace(/(\d{4})(\d)/,"$1-$2"):t.replace(/(\d{2})(\d)/,"($1) $2").replace(/(\d{5})(\d)/,"$1-$2")},cep:e=>e.replace(/\D/g,"").slice(0,8).replace(/(\d{5})(\d)/,"$1-$2")},_r=({name:e,control:t,placeholder:r,maskType:n,disabled:a,readOnly:s})=>{var i;const{field:l,fieldState:c}=$e.useController({name:e,control:t}),d=gk[n||""],u=N.useCallback(m=>{l.onChange(d?d(m.target.value):m.target.value)},[l,d]);return o.jsxs("div",{className:"space-y-1",children:[o.jsx(ue,{name:l.name,value:l.value||"",onChange:u,onBlur:l.onBlur,placeholder:r,disabled:a,readOnly:s,className:K(c.error&&"border-destructive focus-visible:ring-destructive")}),((i=c.error)==null?void 0:i.message)&&o.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})},Go=({name:e,control:t})=>{const{field:r}=$e.useController({name:e,control:t});return o.jsx("input",{type:"hidden",...r,value:r.value??""})},dh=e=>e.replace(/\D/g,""),vk=e=>{const t=dh(e).slice(0,8);return t.length<=5?t:`${t.slice(0,5)}-${t.slice(5)}`},bk=async(e,t)=>{const r=await fetch(`https://viacep.com.br/ws/${e}/json/`,{signal:t});if(!r.ok)throw new Error("Falha ao consultar CEP");return r.json()},gl=({name:e,control:t,placeholder:r="00000-000",disabled:n,readOnly:a,cepFillMap:s})=>{var i,l;const{field:c,fieldState:d}=$e.useController({name:e,control:t}),{setValue:u}=$e.useFormContext(),{cepLookup:m}=Nr(),[p,f]=N.useState("idle"),[b,h]=N.useState(null),x=N.useRef(null),y=N.useRef(!0);N.useEffect(()=>()=>{var w;y.current=!1,(w=x.current)==null||w.abort()},[]);const v=N.useCallback(async()=>{var w;c.onBlur();const C=dh(c.value??"");if(C.length===8){(w=x.current)==null||w.abort(),x.current=new AbortController,f("loading"),h(null);try{let S;if(m){const E=x.current;if(S=await m(C,E.signal),E.signal.aborted||!y.current)return}else{const E=await bk(C,x.current.signal);if(!y.current)return;if(E.erro){f("error"),h("CEP não encontrado");return}S={logradouro:E.logradouro,bairro:E.bairro,cidade:E.localidade,estado:E.uf}}if(!y.current)return;if(S.erro){f("error"),h("CEP não encontrado");return}const $=e.includes(".")?`${e.substring(0,e.lastIndexOf("."))}.`:"",k=(E,D,O)=>{if(!O)return;const L=s!=null&&s[E]?`${$}${s[E]}`:`${$}${D}`;u(L,O,{shouldDirty:!0,shouldValidate:!0})};k("logradouro","_address_logradouro",S.logradouro),k("bairro","_address_bairro",S.bairro),k("cidade","_address_cidade",S.cidade),k("estado","_address_estado",S.estado),f("success")}catch(S){if(S instanceof Error&&S.name==="AbortError"||!y.current)return;f("error"),h("Erro ao buscar CEP")}}},[c,m,u,e,s]),j=N.useCallback(w=>{c.onChange(vk(w.target.value))},[c]);return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"relative",children:[o.jsx(ue,{name:c.name,value:c.value||"",onChange:j,onBlur:v,placeholder:r,disabled:n,readOnly:a,className:K("pr-9",d.error&&"border-destructive focus-visible:ring-destructive")}),o.jsxs("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none",children:[p==="loading"&&o.jsx(_.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"}),p==="success"&&o.jsx(_.Check,{className:"h-4 w-4 text-green-500"}),p==="error"&&o.jsx(_.AlertCircle,{className:"h-4 w-4 text-destructive"})]})]}),(((i=d.error)==null?void 0:i.message)||b)&&o.jsx("p",{className:"text-sm text-destructive",children:((l=d.error)==null?void 0:l.message)||b})]})},yk=({field:e,control:t,nameOverride:r})=>{const n={name:r,control:t,placeholder:e.placeholder};switch(e.tipo){case T.TEXTO:return o.jsx(Tt,{...n,type:"text"});case T.EMAIL:return o.jsx(Tt,{...n,type:"email"});case T.NUMBER:return o.jsx(Tt,{...n,type:"number"});case T.TEXTAREA:return o.jsx(Uo,{...n});case T.SELECT:return o.jsx(Ho,{...n,options:e.opcoes??[]});case T.RADIO:return o.jsx(ml,{...n,options:e.opcoes??[]});case T.CHECKBOX:return o.jsx(Wo,{name:r,control:t,label:e.label});case T.CHECKBOX_GROUP:return o.jsx(ul,{...n,options:e.opcoes??[]});case T.DATE:return o.jsx(Rn,{...n,validacao:e.validacao});case T.DATETIME:return o.jsx(Rn,{...n,isDatetime:!0,validacao:e.validacao});case T.FILE:return o.jsx(xl,{name:r,control:t});case T.TELEFONE:return o.jsx(_r,{...n,maskType:"telefone"});case T.CPF:return o.jsx(_r,{...n,maskType:"cpf"});case T.CEP:return o.jsx(gl,{name:r,control:t,placeholder:e.placeholder});case T.HIDDEN:return o.jsx(Go,{name:r,control:t});default:return console.error(`[DFFieldArray] Tipo de sub-campo "${e.tipo}" não suportado em FIELD_ARRAY. Usando DFTextField como fallback.`),o.jsx(Tt,{...n,type:"text"})}},uh=({name:e,control:t,subFields:r=[],minItems:n=1,maxItems:a,itemLabel:s="Item",addLabel:i})=>{var l;const{fields:c,append:d,remove:u}=$e.useFieldArray({control:t,name:e}),{errors:m}=$e.useFormState({control:t}),p=(l=m[e])==null?void 0:l.message,f=N.useCallback(()=>{const y={};for(const v of r)v.initialValue!==void 0?y[v.nome]=v.initialValue:v.defaultValue!==void 0&&(y[v.nome]=v.defaultValue);return y},[r]);N.useEffect(()=>{if(c.length<n)for(let y=c.length;y<n;y++)d(f())},[n]);const b=[...r].sort((y,v)=>y.ordem-v.ordem),h=!a||c.length<a,x=i??`Adicionar ${s.toLowerCase()}`;return o.jsxs("div",{className:"space-y-3",children:[c.map((y,v)=>o.jsxs("div",{className:"rounded-lg border border-input p-4",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-primary/10 text-xs font-bold text-primary shrink-0",children:v+1}),o.jsxs("span",{className:"text-sm font-semibold",children:[s," ",v+1]})]}),c.length>n&&o.jsx(De,{type:"button",variant:"ghost",size:"icon",onClick:()=>u(v),"aria-label":`Remover ${s.toLowerCase()} ${v+1}`,className:"text-muted-foreground hover:text-destructive",children:o.jsx(_.Trash2,{className:"w-4 h-4"})})]}),o.jsx("div",{className:"grid grid-cols-12 gap-4",children:b.map(j=>{const w=`${e}.${v}.${j.nome}`,C=`span ${j.tamanho??12}`,S=o.jsx(yk,{field:j,control:t,nameOverride:w});return j.tipo===T.CHECKBOX||j.tipo===T.HIDDEN?o.jsx("div",{className:"max-sm:!col-span-12",style:{gridColumn:C},children:S},j.id):o.jsxs("div",{className:"max-sm:!col-span-12 space-y-2",style:{gridColumn:C},children:[o.jsxs("label",{className:"font-medium flex items-center gap-1 text-sm text-foreground",children:[j.label,j.obrigatorio&&o.jsx("span",{className:"text-destructive",children:"*"})]}),S,j.hint&&o.jsx("p",{className:"text-xs text-muted-foreground",children:j.hint})]},j.id)})})]},y.id)),h&&o.jsxs(De,{type:"button",variant:"outline",className:"w-full",onClick:()=>d(f()),children:[o.jsx(_.Plus,{className:"w-4 h-4"}),x]}),a&&o.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:["Máximo de ",a," ",s.toLowerCase(),a>1?"s":""]}),p&&o.jsxs("p",{className:"text-sm text-destructive flex items-center gap-1",children:[o.jsx(_.AlertCircle,{className:"w-4 h-4 shrink-0"}),p]})]})},ed=e=>`R$ ${(e/100).toFixed(2).replace(".",",")}`,wk=(e,t)=>{const r=new Date(e.slice(0,10)+"T00:00:00Z"),n=new Date(t.slice(0,10)+"T00:00:00Z");return Math.round((n.getTime()-r.getTime())/864e5)+1},jk=(e,t)=>{const r=[],n=new Date(e.slice(0,10)+"T00:00:00Z"),a=new Date(t.slice(0,10)+"T00:00:00Z");let s=0;for(;n<=a&&s<60;)r.push(n.toISOString().slice(0,10)),n.setUTCDate(n.getUTCDate()+1),s++;return r},kk=e=>{const[t,r,n]=e.split("-").map(Number),a=new Date(Date.UTC(t,r-1,n)),s=String(n).padStart(2,"0"),i=String(r).padStart(2,"0"),l=new Intl.DateTimeFormat("pt-BR",{weekday:"long",timeZone:"UTC"}).format(a),c=l.charAt(0).toUpperCase()+l.slice(1);return`${s}/${i} - ${c}`},Ck=(e,t)=>{const r=n=>{const[a,s,i]=n.slice(0,10).split("-");return`${i}/${s}/${a}`};return`${r(e)} a ${r(t)}`},mh=({name:e,control:t})=>{var r;const{field:n,fieldState:a}=$e.useController({name:e,control:t}),{externalData:s={}}=Nr(),i=n.value??null,l=(r=a.error)==null?void 0:r.message,c=V=>s[`evento.${V}`]??s[V],d=c("dataInicioEvento")??"",u=c("dataFimEvento")??"",m=Number(c("valor")??0),p=Number(c("valorPorDia")??0),f=c("vagasTotal"),b=c("vagasPorDia"),h=c("vagasMasculinas"),x=c("vagasFemininas"),y=f!=null?Number(f):null,v=b!=null?Number(b):null,j=h!=null?Number(h):null,w=x!=null?Number(x):null,C=d&&u?jk(d,u):[],S=(d&&u?wk(d,u):0)>1,$=j!=null&&j>0&&w!=null&&w>0,k=j!=null&&w==null?"masculino":w!=null&&j==null?"feminino":null,E=(i==null?void 0:i.tipo)??null,D=(i==null?void 0:i.data)??null,O=(i==null?void 0:i.genero)??null,L=N.useRef(i);L.current=i;const A=N.useRef(n.onChange);A.current=n.onChange,N.useEffect(()=>{var V,M,P;k&&((V=L.current)==null?void 0:V.genero)!==k&&A.current({tipo:((M=L.current)==null?void 0:M.tipo)??null,data:((P=L.current)==null?void 0:P.data)??null,genero:k})},[k]);const z=V=>{const M={tipo:V,data:null};($||k)&&(M.genero=O??k??void 0),n.onChange(M)},X=V=>{const M={tipo:"por_dia",data:V};($||k)&&(M.genero=O??k??void 0),n.onChange(M)},q=V=>{n.onChange({tipo:E,data:D,genero:V})},Z=V=>E===V;return o.jsxs("div",{className:"space-y-3",children:[$&&o.jsxs("div",{className:"flex items-center gap-2 px-1",children:[o.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:"Você é:"}),o.jsx("div",{className:"flex gap-2",children:["masculino","feminino"].map(V=>o.jsx("button",{type:"button",onClick:()=>q(V),className:K("px-3 py-1 rounded-full text-xs font-medium border transition-all",O===V?"border-primary bg-primary/10 text-primary":"border-input text-muted-foreground hover:border-primary/50"),children:V==="masculino"?"Masculino":"Feminino"},V))})]}),o.jsxs("button",{type:"button",onClick:()=>z("todos_os_dias"),className:K("w-full text-left flex items-start gap-3 p-4 rounded-xl border-2 transition-all",Z("todos_os_dias")?"border-primary bg-primary/5":"border-input hover:border-primary/50"),children:[o.jsx("div",{className:K("mt-0.5 p-2 rounded-lg shrink-0 transition-colors",Z("todos_os_dias")?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:o.jsx(_.CalendarCheck2,{className:"w-4 h-4"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"font-semibold text-sm",children:"Participar todos os dias"}),d&&u?o.jsx("p",{className:"text-xs text-muted-foreground",children:Ck(d,u)}):o.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Datas do evento"})]}),o.jsxs("div",{className:"text-right shrink-0",children:[m>0&&o.jsx("p",{className:K("font-bold text-sm",Z("todos_os_dias")?"text-primary":"text-foreground"),children:ed(m)}),y!=null&&y>0&&o.jsxs("p",{className:"text-xs flex items-center justify-end gap-1 text-muted-foreground",children:[o.jsx(_.Users,{className:"w-3 h-3"}),y," vagas disponíveis"]})]})]}),S?o.jsxs("button",{type:"button",onClick:()=>z("por_dia"),className:K("w-full text-left flex items-start gap-3 p-4 rounded-xl border-2 transition-all",Z("por_dia")?"border-primary bg-primary/5":"border-input hover:border-primary/50"),children:[o.jsx("div",{className:K("mt-0.5 p-2 rounded-lg shrink-0 transition-colors",Z("por_dia")?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:o.jsx(_.CalendarDays,{className:"w-4 h-4"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"font-semibold text-sm",children:"Participar um dia"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Escolha o dia desejado abaixo"})]}),o.jsxs("div",{className:"text-right shrink-0",children:[p>0&&o.jsx("p",{className:K("font-bold text-sm",Z("por_dia")?"text-primary":"text-foreground"),children:ed(p)}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"por dia"})]})]}):d?o.jsxs("div",{className:"flex items-start gap-2 px-3 py-2.5 rounded-lg border border-input bg-muted/30",children:[o.jsx(_.Info,{className:"w-3.5 h-3.5 mt-0.5 shrink-0 text-muted-foreground"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:'Este evento ocorre em apenas 1 dia — a opção "Participar um dia" não é necessária.'})]}):null,E==="por_dia"&&o.jsxs("div",{className:"pl-2 space-y-2",children:[o.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-primary",children:"Selecione o dia:"}),C.length===0?o.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Nenhuma data configurada no evento"}):C.map(V=>o.jsxs("button",{type:"button",onClick:()=>X(V),className:K("w-full text-left flex items-center justify-between px-4 py-3 rounded-lg border transition-all",D===V?"border-primary bg-primary/5":"border-input hover:border-primary/50"),children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("span",{className:K("w-4 h-4 rounded-full border-2 shrink-0 flex items-center justify-center transition-colors",D===V?"border-primary bg-primary":"border-input"),children:D===V&&o.jsx("span",{className:"w-2 h-2 rounded-full bg-white"})}),o.jsx("span",{className:"text-sm",children:kk(V)})]}),v!=null&&o.jsxs("span",{className:"text-xs text-muted-foreground",children:[v," vagas"]})]},V))]}),l&&o.jsx("p",{className:"text-sm text-destructive",children:l})]})},td=.0315,rd=.124,nd=7,ad=12,ph=[{id:"pix",label:"PIX",description:"Transferência instantânea (à vista)",Icon:_.Smartphone,taxa:0},{id:"dinheiro",label:"Dinheiro",description:"Pagamento em espécie",Icon:_.Banknote,taxa:0},{id:"cartao",label:"Cartão de Crédito",description:"Débito ou crédito na maquininha",Icon:_.CreditCard,taxa:td,taxaLabel:`Taxa: ${(td*100).toFixed(2).replace(".",",")}%`}],fh=[{id:"pix",label:"PIX à Vista",description:"Pagamento instantâneo sem parcelamento",Icon:_.Smartphone,taxa:0},{id:"pix_parcelado",label:"PIX Parcelado",description:`Parcelado em até ${nd}x sem juros`,Icon:_.Smartphone,taxa:0,parcelas:nd},{id:"cartao",label:"Cartão de Crédito",description:`Parcelado em até ${ad}x`,Icon:_.CreditCard,taxa:rd,parcelas:ad,taxaLabel:`Taxa: ${(rd*100).toFixed(2).replace(".",",")}%`},{id:"dinheiro",label:"Dinheiro",description:"Pagamento em espécie",Icon:_.Banknote,taxa:0}],Ra=e=>`R$ ${(e/100).toFixed(2).replace(".",",")}`,od=(e,t)=>Math.round(e*(1+t)*100)/100,Nk=(e,t)=>Math.round(e/t*100)/100,hh=({name:e,control:t,relatedFieldName:r="tipo_participacao"})=>{var n;const{field:a,fieldState:s}=$e.useController({name:e,control:t}),{externalData:i={},paymentMethodOptions:l}=Nr(),c=a.value??null,d=(n=s.error)==null?void 0:n.message,u=$e.useWatch({control:t,name:r}),m=(u==null?void 0:u.tipo)??null,p=j=>i[`evento.${j}`]??i[j],f=Number(p("valor")??0),b=Number(p("valorPorDia")??0),h=m==="por_dia"&&b>0?b:f,x=m==="por_dia"?(l==null?void 0:l.porDia)??ph:(l==null?void 0:l.todosOsDias)??fh,y=m==="por_dia"?(()=>{if(!(u!=null&&u.data))return"Um dia";const j=u.data.split("-");if(j.length===3){const[w,C,S]=j;return`${S}/${C}/${w}`}return u.data})():"Todos os dias",v=j=>{if(j.disabled)return;const w=od(h,j.taxa),C={metodo:j.id,valorTotal:w};j.parcelas&&(C.parcelas=j.parcelas),a.onChange(C)};return o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-input px-4 py-3",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:"Tipo de participação"}),o.jsx("p",{className:"font-semibold",children:y})]}),o.jsxs("div",{className:"text-right",children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:"Valor base"}),o.jsx("p",{className:"text-lg font-bold text-primary",children:Ra(h)})]})]}),o.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-input bg-muted/30 px-3 py-2.5",children:[o.jsx(_.Info,{className:"h-4 w-4 mt-0.5 shrink-0 text-muted-foreground"}),o.jsxs("p",{className:"text-xs",children:[o.jsx("span",{className:"font-bold",children:"Importante:"})," Para validar a inscrição e garantir sua vaga, o pagamento deve ser realizado no ato da inscrição."]})]}),o.jsx("p",{className:"text-sm font-semibold text-primary",children:"Selecione a forma de pagamento:"}),o.jsx("div",{className:"space-y-3",children:x.map(j=>{const{Icon:w}=j,C=(c==null?void 0:c.metodo)===j.id,S=od(h,j.taxa),$=!!j.parcelas&&j.parcelas>1,k=$?Nk(S,j.parcelas):null;return o.jsxs("button",{type:"button",disabled:j.disabled,onClick:()=>v(j),className:K("w-full text-left flex items-center gap-4 px-4 py-3 rounded-xl border-2 transition-all",C?"border-primary bg-primary/5":"border-input hover:border-primary/50",j.disabled&&"opacity-50 cursor-not-allowed"),children:[o.jsx("div",{className:K("flex items-center justify-center w-10 h-10 rounded-lg shrink-0 transition-colors",C?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:o.jsx(w,{className:"h-5 w-5"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"font-semibold text-sm leading-tight",children:j.label}),o.jsx("p",{className:"text-xs text-muted-foreground",children:j.description}),j.taxaLabel&&o.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["* ",j.taxaLabel]}),j.taxa>0&&o.jsxs("p",{className:"text-xs text-muted-foreground",children:["Total com taxa: ",Ra(S)]})]}),o.jsx("div",{className:"text-right shrink-0",children:$?o.jsxs(o.Fragment,{children:[o.jsxs("p",{className:"text-xs text-muted-foreground",children:[j.parcelas,"x de"]}),o.jsx("p",{className:"text-base font-bold text-primary",children:Ra(k)})]}):o.jsx("p",{className:"text-base font-bold text-primary",children:Ra(S)})})]},j.id)})}),d&&o.jsx("p",{className:"text-xs text-destructive",children:d})]})},xh=({name:e,control:t,label:r,termoTexto:n,termoPdfUrl:a,termoPdfUploadId:s})=>{var i;const{field:l,fieldState:c}=$e.useController({name:e,control:t}),{resolveTermsUploadUrl:d}=Nr(),u=!!c.error,m=(i=c.error)==null?void 0:i.message,[p,f]=N.useState(null),[b,h]=N.useState(!1),[x,y]=N.useState(!1),v=N.useRef(null);N.useEffect(()=>{var $;x&&(($=v.current)==null||$.focus())},[x]),N.useEffect(()=>{if(!s||!d){f(null);return}let $=!1;return h(!0),d(s).then(k=>{$||f(k)}).catch(()=>{$||f(null)}).finally(()=>{$||h(!1)}),()=>{$=!0}},[s,d]);const j=l.value==="accepted",w=p||a||null,C=!!(n||w||s),S=!!w;return o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:K("rounded-lg border p-4 space-y-4 transition-colors",u?"border-destructive bg-destructive/5":j?"border-green-500 bg-green-500/5":"border-input"),children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(_.ScrollText,{className:"h-4 w-4 shrink-0"}),o.jsx("span",{className:"text-sm font-medium",children:r||"Termos e condições"})]}),C?o.jsxs(De,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2 text-xs",disabled:b,onClick:()=>y(!0),children:[b?o.jsx(_.Loader2,{className:"h-3 w-3 animate-spin"}):o.jsx(_.ExternalLink,{className:"h-3 w-3"}),"Ler termos"]}):o.jsx("span",{className:"text-xs text-muted-foreground italic",children:s&&b?"Carregando PDF...":"Conteúdo não configurado"})]}),o.jsxs("label",{className:"flex items-start gap-3 cursor-pointer select-none",children:[o.jsx(et,{className:"mt-0.5",checked:j,onCheckedChange:$=>l.onChange($?"accepted":"")}),o.jsxs("span",{className:"text-sm leading-snug flex-1",children:["Li e aceito ",r?`"${r}"`:"os termos e condições"]}),j&&o.jsx(_.CheckCircle2,{className:"h-4 w-4 text-green-500 shrink-0 mt-0.5"})]})]}),u&&o.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-destructive",children:[o.jsx(_.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),m||"Você precisa aceitar os termos para continuar"]}),x&&o.jsx("div",{ref:v,role:"dialog","aria-modal":"true","aria-label":"Termos e condições",tabIndex:-1,className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 outline-none",onClick:()=>y(!1),onKeyDown:$=>{$.key==="Escape"&&y(!1)},children:o.jsxs("div",{className:"relative w-full max-w-2xl max-h-[90vh] rounded-xl overflow-hidden flex flex-col bg-background shadow-xl",onClick:$=>$.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-input",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(_.ScrollText,{className:"h-4 w-4"}),o.jsx("span",{className:"font-semibold",children:"Termos e condições"})]}),o.jsx(De,{type:"button",variant:"ghost",size:"icon",onClick:()=>y(!1),children:o.jsx(_.X,{className:"h-4 w-4"})})]}),o.jsx("div",{className:"flex-1 overflow-auto p-4",children:S?o.jsx("iframe",{src:w,className:"w-full rounded border",style:{height:"62vh"},title:"Termos e condições",sandbox:"allow-scripts"}):o.jsx("p",{className:"text-sm whitespace-pre-wrap leading-relaxed",children:n})})]})})]})},Sk=({name:e,control:t,placeholder:r,disabled:n,readOnly:a})=>{var s;const{field:i,fieldState:l}=$e.useController({name:e,control:t}),[c,d]=N.useState(!1),u=!!l.error;return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"relative",children:[o.jsx(ue,{...i,value:i.value??"",type:c?"text":"password",placeholder:r,disabled:n,readOnly:a,className:K("pr-10",u&&"border-destructive focus-visible:ring-destructive")}),o.jsx("button",{type:"button",tabIndex:-1,onClick:()=>d(m=>!m),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors","aria-label":c?"Ocultar senha":"Mostrar senha",children:c?o.jsx(_.EyeOff,{size:16}):o.jsx(_.Eye,{size:16})})]}),((s=l.error)==null?void 0:s.message)&&o.jsx("p",{className:"text-sm text-destructive",children:l.error.message})]})},gh=({name:e,control:t,label:r,disabled:n,readOnly:a})=>{var s;const{field:i,fieldState:l}=$e.useController({name:e,control:t}),c=!!i.value;return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("label",{className:"flex items-center gap-3 cursor-pointer select-none",children:[o.jsx(Oi,{checked:c,onCheckedChange:d=>!a&&i.onChange(d),disabled:n||a,onBlur:i.onBlur}),o.jsx("span",{className:"text-sm leading-none",children:r})]}),((s=l.error)==null?void 0:s.message)&&o.jsx("p",{className:"text-sm text-destructive",children:l.error.message})]})},$k=({name:e,control:t,minValue:r=0,maxValue:n=100,step:a=1,disabled:s,readOnly:i})=>{var l;const{field:c,fieldState:d}=$e.useController({name:e,control:t}),u=c.value??r;return N.useEffect(()=>{(c.value===void 0||c.value===null)&&c.onChange(r)},[]),o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(Ao,{min:r,max:n,step:a,value:[u],onValueChange:m=>!i&&c.onChange(m[0]),disabled:s||i,className:"flex-1"}),o.jsx("span",{className:"text-sm font-medium text-primary min-w-[3rem] text-right tabular-nums",children:u})]}),o.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[o.jsx("span",{children:r}),o.jsx("span",{children:n})]}),((l=d.error)==null?void 0:l.message)&&o.jsx("p",{className:"text-sm text-destructive",children:d.error.message})]})},js=e=>/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(e),Ek=({name:e,control:t,disabled:r,readOnly:n})=>{var a;const{field:s,fieldState:i}=$e.useController({name:e,control:t}),l=s.value||"#000000",[c,d]=N.useState(l);return N.useEffect(()=>{d(l)},[l]),o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("input",{type:"color",value:js(l)?l:"#000000",disabled:r||n,onChange:u=>s.onChange(u.target.value),className:"h-10 w-14 cursor-pointer rounded-lg border border-input bg-transparent p-1 disabled:cursor-not-allowed disabled:opacity-50"}),o.jsx(ue,{type:"text",value:c,readOnly:n,disabled:r,onChange:u=>{const m=u.target.value;d(m),js(m)&&s.onChange(m.toUpperCase())},onBlur:()=>{js(c)||d(l),s.onBlur()},className:K("flex-1 font-mono uppercase",i.error&&"border-destructive focus-visible:ring-destructive"),maxLength:7,placeholder:"#000000"})]}),((a=i.error)==null?void 0:a.message)&&o.jsx("p",{className:"text-sm text-destructive",children:i.error.message})]})},Dk=({name:e,control:t,options:r,placeholder:n,disabled:a,readOnly:s})=>{var i,l;const{field:c,fieldState:d}=$e.useController({name:e,control:t}),[u,m]=N.useState(""),[p,f]=N.useState(!1),[b,h]=N.useState(-1),x=N.useRef(null),y=N.useRef(null),v=`autocomplete-${e}-listbox`,j=((i=r.find(D=>D.valor===c.value))==null?void 0:i.label)??"",w=u.length>0?r.filter(D=>D.label.toLowerCase().includes(u.toLowerCase())):r;N.useEffect(()=>{const D=O=>{x.current&&!x.current.contains(O.target)&&(f(!1),m(""),h(-1))};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[]);const C=()=>{f(!1),m(""),h(-1)};N.useEffect(()=>{if(b<0||!y.current)return;const D=y.current.querySelector(`[id="${v}-option-${b}"]`);D==null||D.scrollIntoView({block:"nearest"})},[b,v]);const S=D=>{D.disabled||(c.onChange(D.valor),C())},$=()=>{c.onChange(""),m(""),h(-1)},k=D=>{if(!p){(D.key==="ArrowDown"||D.key==="ArrowUp")&&(D.preventDefault(),f(!0),h(0));return}switch(D.key){case"ArrowDown":D.preventDefault(),h(O=>O<w.length-1?O+1:O);break;case"ArrowUp":D.preventDefault(),h(O=>O>0?O-1:0);break;case"Enter":D.preventDefault(),b>=0&&w[b]&&!w[b].disabled&&S(w[b]);break;case"Escape":D.preventDefault(),C();break;case"Tab":C();break}},E=p&&b>=0?`${v}-option-${b}`:void 0;return o.jsxs("div",{className:"space-y-1",ref:x,children:[o.jsxs("div",{className:"relative",children:[o.jsx(ue,{type:"text",role:"combobox","aria-expanded":p,"aria-haspopup":"listbox","aria-autocomplete":"list","aria-controls":v,"aria-activedescendant":E,value:p?u:j,placeholder:n??"Buscar...",disabled:a,readOnly:s,onChange:D=>{m(D.target.value),h(-1),f(!0)},onFocus:()=>!s&&f(!0),onKeyDown:k,className:K("pr-8",d.error&&"border-destructive focus-visible:ring-destructive"),autoComplete:"off"}),o.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1",children:c.value?o.jsx("button",{type:"button",onClick:$,className:"text-[var(--t-text-muted)] hover:text-[var(--t-text)]",tabIndex:-1,"aria-label":"Limpar seleção",children:o.jsx(_.X,{size:14})}):o.jsx(_.ChevronDown,{size:16,className:"text-muted-foreground pointer-events-none","aria-hidden":"true"})}),p&&!a&&!s&&o.jsx("ul",{role:"listbox",id:v,ref:y,"aria-label":"Opções disponíveis",className:"absolute z-50 mt-1 max-h-60 w-full overflow-auto rounded-lg border border-input bg-popover shadow-lg",children:w.length===0?o.jsx("li",{role:"option","aria-selected":!1,className:"px-3 py-2 text-sm text-muted-foreground",children:"Nenhuma opção encontrada"}):w.map((D,O)=>o.jsx("li",{id:`${v}-option-${O}`,role:"option","aria-selected":c.value===D.valor,"aria-disabled":D.disabled,onMouseDown:()=>S(D),className:["flex cursor-pointer items-center px-3 py-2 text-sm",D.disabled?"cursor-not-allowed opacity-40":O===b?"bg-accent":"hover:bg-accent",c.value===D.valor?"font-medium text-primary":"text-foreground"].join(" "),children:D.label},D.valor))})]}),((l=d.error)==null?void 0:l.message)&&o.jsx("p",{className:"text-sm text-destructive",role:"alert",children:d.error.message})]})},vh=({name:e,control:t,placeholder:r,disabled:n,readOnly:a})=>{var s;const{field:i,fieldState:l}=$e.useController({name:e,control:t}),c=!!l.error;return o.jsxs("div",{className:"space-y-1",children:[o.jsx(ue,{...i,value:i.value??"",type:"time",placeholder:r,disabled:n,readOnly:a,className:K(c&&"border-destructive focus-visible:ring-destructive")}),((s=l.error)==null?void 0:s.message)&&o.jsx("p",{className:"text-sm text-destructive",children:l.error.message})]})},Tk=({name:e,control:t,startLabel:r="Data inicial",endLabel:n="Data final",disabled:a,readOnly:s})=>{var i;const{field:l,fieldState:c}=$e.useController({name:e,control:t}),d=l.value??{},u=(p,f)=>{l.onChange({...d,[p]:f})},m=!!c.error;return o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{children:r}),o.jsx(ue,{type:"date",value:d.start??"",disabled:a,readOnly:s,onChange:p=>u("start",p.target.value),max:d.end??void 0,className:K(m&&"border-destructive focus-visible:ring-destructive")})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{children:n}),o.jsx(ue,{type:"date",value:d.end??"",disabled:a,readOnly:s,onChange:p=>u("end",p.target.value),min:d.start??void 0,className:K(m&&"border-destructive focus-visible:ring-destructive")})]})]}),((i=c.error)==null?void 0:i.message)&&o.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})},Ak=({name:e,control:t,maxRating:r=5,disabled:n,readOnly:a})=>{var s;const{field:i,fieldState:l}=$e.useController({name:e,control:t}),c=i.value??0,d=Array.from({length:r},(u,m)=>m+1);return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-1",children:[d.map(u=>o.jsx("button",{type:"button",disabled:n||a,onClick:()=>i.onChange(u===c?0:u),className:"transition-transform hover:scale-110 disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded","aria-label":`${u} estrela${u>1?"s":""}`,children:o.jsx(_.Star,{size:24,className:"transition-colors",fill:u<=c?"var(--color-primary)":"transparent",stroke:u<=c?"var(--color-primary)":"currentColor"})},u)),c>0&&o.jsxs("span",{className:"ml-2 text-sm text-muted-foreground",children:[c,"/",r]})]}),((s=l.error)==null?void 0:s.message)&&o.jsx("p",{className:"text-sm text-destructive",children:l.error.message})]})},Rk=({field:e,name:t,control:r,disabled:n,readOnly:a})=>{const s=n||e.isDisabled,i=a||e.isReadOnly;switch(e.tipo){case T.EMAIL:return o.jsx(Tt,{name:t,control:r,type:"email",placeholder:e.placeholder,disabled:s,readOnly:i});case T.NUMBER:return o.jsx(Tt,{name:t,control:r,type:"number",placeholder:e.placeholder,disabled:s,readOnly:i});case T.PASSWORD:return o.jsx(Tt,{name:t,control:r,type:"password",placeholder:e.placeholder,disabled:s,readOnly:i});case T.TELEFONE:return o.jsx(_r,{name:t,control:r,maskType:"telefone",placeholder:e.placeholder??"(00) 00000-0000",disabled:s,readOnly:i});case T.CPF:return o.jsx(_r,{name:t,control:r,maskType:"cpf",placeholder:e.placeholder??"000.000.000-00",disabled:s,readOnly:i});case T.CEP:return o.jsx(_r,{name:t,control:r,maskType:"cep",placeholder:e.placeholder??"00000-000",disabled:s,readOnly:i});case T.TEXTAREA:return o.jsx(Uo,{name:t,control:r,placeholder:e.placeholder,disabled:s,readOnly:i});case T.SELECT:return o.jsx(Ho,{name:t,control:r,options:e.opcoes??[],placeholder:e.placeholder,disabled:s,readOnly:i});case T.CHECKBOX:return o.jsx(Wo,{name:t,control:r,label:e.label??"",disabled:s,readOnly:i});case T.SWITCH:return o.jsx(gh,{name:t,control:r,label:e.label??"",disabled:s,readOnly:i});case T.DATE:return o.jsx(Rn,{name:t,control:r,disabled:s,readOnly:i});case T.TIME:return o.jsx(vh,{name:t,control:r,disabled:s,readOnly:i});case T.HIDDEN:return o.jsx(Go,{name:t,control:r});default:return o.jsx(Tt,{name:t,control:r,type:"text",placeholder:e.placeholder,disabled:s,readOnly:i})}},Ik=({name:e,control:t,subSchema:r,disabled:n,readOnly:a})=>{if(!r||r.fields.length===0)return null;const s=[...r.fields].sort((i,l)=>i.ordem-l.ordem);return o.jsxs("div",{className:"rounded-xl border border-input bg-muted/30 p-4 space-y-4",children:[r.titulo&&o.jsx("h4",{className:"text-sm font-semibold text-muted-foreground",children:r.titulo}),o.jsx("div",{className:"grid grid-cols-12 gap-4",children:s.map(i=>{const l=`${e}.${i.nome}`,c=i.tipo===T.CHECKBOX||i.tipo===T.SWITCH||i.tipo===T.HIDDEN,d=i.tamanho??6;return o.jsxs("div",{className:`col-span-${d}`,children:[!c&&o.jsxs("label",{className:"mb-1 block text-sm font-medium text-foreground",children:[i.label,i.obrigatorio&&o.jsx("span",{className:"text-destructive",children:" *"})]}),o.jsx(Rk,{field:i,name:l,control:t,disabled:n,readOnly:a})]},i.id)})})]})},bh=({field:e,control:t,nameOverride:r})=>{var n,a;const s=r??e.nome,{componentMapper:i}=Nr(),l=i==null?void 0:i[e.tipo];if(l)return o.jsx(l,{name:s,control:t,field:e});const c={name:s,control:t,placeholder:e.placeholder,disabled:e.isDisabled,readOnly:e.isReadOnly};switch(e.tipo){case T.TEXTO:return o.jsx(Tt,{...c,type:"text"});case T.EMAIL:return o.jsx(Tt,{...c,type:"email"});case T.NUMBER:return o.jsx(Tt,{...c,type:"number"});case T.PASSWORD:return o.jsx(Sk,{...c});case T.TEXTAREA:return o.jsx(Uo,{...c});case T.SELECT:return o.jsx(Ho,{...c,options:e.opcoes??[]});case T.AUTOCOMPLETE:return o.jsx(Dk,{...c,options:e.opcoes??[]});case T.SWITCH:return o.jsx(gh,{name:s,control:t,label:e.label,disabled:e.isDisabled,readOnly:e.isReadOnly});case T.SLIDER:return o.jsx($k,{name:s,control:t,minValue:e.minValue,maxValue:e.maxValue,step:e.step,disabled:e.isDisabled,readOnly:e.isReadOnly});case T.RATING:return o.jsx(Ak,{name:s,control:t,maxRating:e.maxRating,disabled:e.isDisabled,readOnly:e.isReadOnly});case T.COLOR:return o.jsx(Ek,{name:s,control:t,disabled:e.isDisabled,readOnly:e.isReadOnly});case T.TIME:return o.jsx(vh,{...c});case T.DATE_RANGE:return o.jsx(Tk,{name:s,control:t,startLabel:e.dateRangeStartLabel,endLabel:e.dateRangeEndLabel,disabled:e.isDisabled,readOnly:e.isReadOnly});case T.RADIO:return o.jsx(ml,{...c,options:e.opcoes??[]});case T.CHECKBOX:return o.jsx(Wo,{name:s,control:t,label:e.label,disabled:e.isDisabled,readOnly:e.isReadOnly});case T.CHECKBOX_GROUP:return o.jsx(ul,{...c,options:e.opcoes??[]});case T.DATE:return o.jsx(Rn,{name:s,control:t,disabled:e.isDisabled,readOnly:e.isReadOnly,validacao:e.validacao});case T.DATETIME:return o.jsx(Rn,{name:s,control:t,isDatetime:!0,disabled:e.isDisabled,readOnly:e.isReadOnly,validacao:e.validacao});case T.FILE:return o.jsx(xl,{name:s,control:t,disabled:e.isDisabled,fileTypes:(n=e.validacao)==null?void 0:n.fileTypes,maxFileSize:(a=e.validacao)==null?void 0:a.maxFileSize});case T.TELEFONE:return o.jsx(_r,{...c,maskType:"telefone"});case T.CPF:return o.jsx(_r,{...c,maskType:"cpf"});case T.CEP:return o.jsx(gl,{name:s,control:t,placeholder:e.placeholder,disabled:e.isDisabled,readOnly:e.isReadOnly,cepFillMap:e.cepFillMap});case T.HIDDEN:return o.jsx(Go,{name:s,control:t});case T.PARTICIPATION_TYPE:return o.jsx(mh,{name:s,control:t});case T.PAYMENT_METHOD:return o.jsx(hh,{name:s,control:t,relatedFieldName:e.relatedFieldName});case T.TERMS:return o.jsx(xh,{name:s,control:t,label:e.label,termoTexto:e.termoTexto,termoPdfUrl:e.termoPdfUrl,termoPdfUploadId:e.termoPdfUploadId});case T.FIELD_ARRAY:return o.jsx(uh,{name:s,control:t,subFields:e.subFields,minItems:e.minItems,maxItems:e.maxItems,itemLabel:e.itemLabel,addLabel:e.addLabel});case T.SUB_FORM:return o.jsx(Ik,{name:s,control:t,subSchema:e.subSchema,disabled:e.isDisabled,readOnly:e.isReadOnly});default:return o.jsx(Tt,{...c,type:"text"})}},Pk=({container:e,control:t})=>{var r;const{externalData:n={},fieldResolvers:a}=Nr(),s=e.icone?Pt[e.icone]:void 0,i=n,l=N.useMemo(()=>Bo(e,i),[e,JSON.stringify(i)]),c=N.useMemo(()=>[...l.campos].sort((x,y)=>x.ordem-y.ordem),[l.campos]),d=$e.useWatch({control:t}),{wrapperClass:u,wrapperStyle:m,headerClass:p,headerStyle:f,tmpl:b}=nh(),h=x=>{if(!at(x.condicional,d,n))return null;let y=x;if(x.resolvePropsKey&&a!=null&&a[x.resolvePropsKey]){const S=a[x.resolvePropsKey](x,d,n);y={...x,...S}}if(y.opcoesFromVar){const S=n[y.opcoesFromVar];Array.isArray(S)&&(y={...y,opcoes:S.map($=>typeof $=="string"?{valor:$,label:$}:$&&typeof $=="object"&&"valor"in $&&"label"in $?$:{valor:String($),label:String($)})})}const v=y.tamanho??12,j=y.inicioColuna,w=j?`${j} / span ${v}`:`span ${v}`,C=o.jsx(bh,{field:y,control:t});return y.tipo===T.CHECKBOX||y.tipo===T.HIDDEN||y.tipo===T.SWITCH?o.jsx("div",{className:"max-sm:!col-span-12",style:{gridColumn:w},children:C},y.id):o.jsxs("div",{className:"max-sm:!col-span-12 space-y-2",style:{gridColumn:w},children:[o.jsxs("label",{className:"font-medium flex items-center gap-1",style:{color:"var(--t-text)"},children:[y.label,y.obrigatorio&&o.jsx("span",{className:"text-destructive",children:"*"})]}),C,y.hint&&o.jsx("p",{className:"text-xs text-muted-foreground",children:y.hint})]},y.id)};return o.jsxs("div",{className:u,style:m,children:[(l.titulo||s)&&o.jsx("div",{className:p,style:f,children:o.jsxs("div",{className:"flex items-center gap-3",children:[s&&o.jsx("div",{className:"p-2 rounded-xl",style:{background:"color-mix(in srgb, var(--t-primary) 12%, transparent)"},children:o.jsx(s,{className:"w-5 h-5",style:{color:"var(--t-primary)"}})}),o.jsxs("div",{children:[o.jsx("h3",{className:((r=b.typography)==null?void 0:r.stepTitleClass)??"text-lg font-semibold",style:{color:"var(--t-text)"},children:l.titulo}),l.descricao&&o.jsx("p",{className:"text-sm",style:{color:"var(--t-text-muted)"},children:l.descricao})]})]})}),o.jsx("div",{className:"p-6 grid grid-cols-12 gap-4",children:c.map(h)})]})},_k=({container:e,control:t})=>{var r;const{externalData:n={}}=Nr(),a=e.nome??"__invalid__",s=e.minItems??1,i=e.maxItems,l=e.itemLabel??"Item",c=e.icone?Pt[e.icone]:void 0,d=n,u=N.useMemo(()=>Bo(e,d),[e,JSON.stringify(d)]),m=N.useMemo(()=>[...u.campos].sort((k,E)=>k.ordem-E.ordem),[u.campos]),p=N.useCallback(()=>{const k={};for(const E of m)E.initialValue!==void 0?k[E.nome]=typeof E.initialValue=="string"?xt(E.initialValue,d):E.initialValue:E.defaultValue!==void 0&&(k[E.nome]=E.defaultValue);return k},[m,d]),{fields:f,append:b,remove:h}=$e.useFieldArray({control:t,name:a});N.useEffect(()=>{if(e.nome&&f.length<s)for(let k=f.length;k<s;k++)b(p())},[s]);const x=$e.useWatch({control:t}),y=N.useMemo(()=>{const k=x[a];return Array.isArray(k)?k:[]},[x,a]),{wrapperClass:v,wrapperStyle:j,headerClass:w,headerStyle:C,tmpl:S}=nh();if(!e.nome)return console.error("[RepeatableContainerRenderer] container.nome é obrigatório para containers repetíveis. Container id:",e.id),null;const $=(k,E)=>{const D=y[E]??{};if(!at(k.condicional,D,n))return null;const O=`${a}.${E}.${k.nome}`,L=k.tamanho??12,A=k.inicioColuna,z=A?`${A} / span ${L}`:`span ${L}`,X=o.jsx(bh,{field:k,control:t,nameOverride:O});return k.tipo===T.CHECKBOX||k.tipo===T.HIDDEN?o.jsx("div",{className:"max-sm:!col-span-12",style:{gridColumn:z},children:X},`${k.id}-${E}`):o.jsxs("div",{className:"max-sm:!col-span-12 space-y-2",style:{gridColumn:z},children:[o.jsxs("label",{className:"font-medium flex items-center gap-1",style:{color:"var(--t-text)"},children:[k.label,k.obrigatorio&&o.jsx("span",{className:"text-destructive",children:"*"})]}),X,k.hint&&o.jsx("p",{className:"text-xs text-muted-foreground",children:k.hint})]},`${k.id}-${E}`)};return o.jsxs("div",{className:v,style:j,children:[(u.titulo||c)&&o.jsx("div",{className:w,style:C,children:o.jsxs("div",{className:"flex items-center gap-3",children:[c&&o.jsx("div",{className:"p-2 rounded-xl",style:{background:"color-mix(in srgb, var(--t-primary) 12%, transparent)"},children:o.jsx(c,{className:"w-5 h-5",style:{color:"var(--t-primary)"}})}),o.jsxs("div",{children:[o.jsx("h3",{className:((r=S.typography)==null?void 0:r.stepTitleClass)??"text-lg font-semibold",style:{color:"var(--t-text)"},children:u.titulo}),u.descricao&&o.jsx("p",{className:"text-sm",style:{color:"var(--t-text-muted)"},children:u.descricao})]})]})}),o.jsxs("div",{className:"p-6 space-y-4",children:[f.map((k,E)=>o.jsxs("div",{className:"border border-input rounded-lg p-4 bg-muted/30",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold shrink-0 bg-primary text-primary-foreground",children:E+1}),o.jsxs("span",{className:"text-sm font-semibold",children:[l," ",E+1]})]}),f.length>s&&o.jsx("button",{type:"button",onClick:()=>h(E),className:"inline-flex items-center justify-center rounded-md p-1.5 text-destructive hover:bg-destructive/10 transition-colors","aria-label":"Remover item",children:o.jsx(_.Trash2,{className:"w-4 h-4"})})]}),o.jsx("div",{className:"grid grid-cols-12 gap-4",children:m.map(D=>$(D,E))})]},k.id)),(!i||f.length<i)&&o.jsxs("button",{type:"button",className:"w-full flex items-center justify-center gap-2 py-2 px-4 border border-input rounded-lg text-sm hover:bg-accent transition-colors",onClick:()=>b(p()),children:[o.jsx(_.Plus,{className:"w-4 h-4"}),"Adicionar ",l.toLowerCase()]}),i&&o.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:["Máximo de ",i," ",l.toLowerCase(),i>1?"s":""]})]})]})},yh=e=>e.container.repeatable&&e.container.nome?o.jsx(_k,{...e}):o.jsx(Pk,{...e}),wh=({step:e,control:t,externalData:r={}})=>{const n=N.useMemo(()=>[...e.containers].sort((s,i)=>s.ordem-i.ordem),[e.containers]),a=$e.useWatch({control:t});return o.jsx("div",{className:"grid grid-cols-12 gap-4",children:n.map(s=>{if(s.condicional&&!at(s.condicional,a,r))return null;const i=s.tamanho??12,l=s.inicioColuna,c=l?`${l} / span ${i}`:`span ${i}`;return o.jsx("div",{className:"max-sm:!col-span-12",style:{gridColumn:c},children:o.jsx(yh,{container:s,control:t})},s.id)})})},xa=N.createContext({submitting:!1,warnings:{},requestSubmit:()=>{}}),Ok=xa.Provider,Fk=()=>{const e=kh("useFormApi"),t=N.useContext(xa);return{change:(r,n)=>e.setValue(r,n,{shouldValidate:!0,shouldDirty:!0}),reset:r=>e.reset(r),submit:t.requestSubmit,getState:()=>{const{errors:r,isDirty:n,isValid:a}=e.formState;return{values:e.getValues(),errors:Object.fromEntries(Object.entries(r).map(([s,i])=>[s,i==null?void 0:i.message])),warnings:t.warnings,dirty:n,valid:a,submitting:t.submitting}}}},jh=()=>{const e=kh("useFormState"),t=N.useContext(xa),r=$e.useWatch({control:e.control}),{errors:n,isDirty:a,isValid:s}=e.formState;return{values:r,errors:Object.fromEntries(Object.entries(n).map(([i,l])=>[i,l==null?void 0:l.message])),warnings:t.warnings,dirty:a,valid:s,submitting:t.submitting}},zk=e=>{var t;const r=$e.useFormContext(),{warnings:n}=N.useContext(xa),a=$e.useWatch({control:r.control,name:e}),s=r.getFieldState(e,r.formState);return{value:a,error:(t=s.error)==null?void 0:t.message,warning:n[e],dirty:s.isDirty,touched:s.isTouched,valid:!s.error}},Lk=e=>{var t;const{control:r}=$e.useFormContext(),{warnings:n}=N.useContext(xa),{field:a,fieldState:s}=$e.useController({name:e,control:r});return{input:{name:a.name,value:a.value,onChange:a.onChange,onBlur:a.onBlur,ref:a.ref},meta:{error:(t=s.error)==null?void 0:t.message,warning:n[e],touched:s.isTouched,dirty:s.isDirty,valid:!s.error}}},kh=e=>{const t=$e.useFormContext();if(!t)throw new Error(`[SchemaForms] O hook '${e}' foi chamado fora de um <FormRenderer />. Certifique-se de que o componente está dentro da árvore de renderização do formulário.`);return t},sd=({stepIndex:e,totalSteps:t,step:r,defaultValues:n,externalData:a,fieldErrors:s,isSubmitting:i,submitError:l,validatorMapper:c={},onWarningsChange:d,onValuesChange:u,onSubmit:m,onBack:p})=>{const f=e===t-1,b=N.useMemo(()=>JSON.stringify(a),[a]),h=N.useMemo(()=>Qf(r,a,c),[r.id,b]),x=N.useMemo(()=>eh(r,a,c),[r.id,b]),[y,v]=N.useState({}),j=N.useRef(d);j.current=d;const w=a,C=N.useMemo(()=>rh(r,w),[r,b]),S=$e.useForm({resolver:h,defaultValues:n,mode:"onTouched"}),{control:$,handleSubmit:k,setError:E,clearErrors:D,setValue:O}=S;N.useEffect(()=>{D();for(const[U,Q]of Object.entries(s))E(U,{type:"server",message:Q})},[s,E,D]);const L=N.useMemo(()=>r.containers.filter(U=>!U.repeatable).flatMap(U=>U.campos).filter(U=>!!U.condicional),[r.containers]),A=N.useMemo(()=>r.containers.filter(U=>!!U.condicional),[r.containers]),z=N.useMemo(()=>r.containers.filter(U=>!U.repeatable).flatMap(U=>U.campos).filter(U=>{var Q;return U.condicional&&((Q=U.setValues)==null?void 0:Q.length)}),[r.containers]),X=N.useMemo(()=>r.containers.filter(U=>U.repeatable&&!!U.nome).map(U=>({container:U,fields:U.campos.filter(Q=>!!Q.condicional)})).filter(U=>U.fields.length>0),[r.containers]),q=N.useRef({}),Z=N.useRef(!0),V=$e.useWatch({control:$}),M=N.useRef(u);M.current=u,N.useEffect(()=>{var U;(U=M.current)==null||U.call(M,V)},[V]),N.useEffect(()=>{let U=!1;return x(V).then(Q=>{var Y;U||(v(Q),(Y=j.current)==null||Y.call(j,Q))}).catch(Q=>{U||console.error("[StepForm] warnComputer error:",Q)}),()=>{U=!0}},[V,x]),N.useEffect(()=>{var U;if(!L.length&&!z.length&&!A.length&&!X.length)return;const Q=V;for(const H of L)if(!at(H.condicional,Q,a)){if(D(H.nome),H.tipo===T.FIELD_ARRAY){const W=Q[H.nome];Array.isArray(W)&&W.forEach((G,ne)=>{(H.subFields??[]).forEach(J=>D(`${H.nome}.${ne}.${J.nome}`))})}if(H.clearedValue!==void 0){const W=H.clearedValue??"";Q[H.nome]!==W&&O(H.nome,W,{shouldValidate:!1})}}for(const H of A)if(!at(H.condicional,Q,a))if(H.repeatable&&H.nome)(Array.isArray(Q[H.nome])?Q[H.nome]:[]).forEach((W,G)=>{for(const ne of H.campos)D(`${H.nome}.${G}.${ne.nome}`)});else for(const W of H.campos){D(W.nome);const G=W.clearedValue!==void 0?W.clearedValue:void 0;G!==void 0&&Q[W.nome]!==G&&O(W.nome,G,{shouldValidate:!1})}for(const{container:H,fields:W}of X){const G=H.nome,ne=Array.isArray(Q[G])?Q[G]:[];for(let J=0;J<ne.length;J++){const te=ne[J];for(const ce of W)if(!at(ce.condicional,te,a)&&(D(`${G}.${J}.${ce.nome}`),ce.clearedValue!==void 0)){const be=ce.clearedValue??"";te[ce.nome]!==be&&O(`${G}.${J}.${ce.nome}`,be,{shouldValidate:!1})}}}const Y=Z.current;for(const H of z){const W=at(H.condicional,Q,a),G=Y?W:q.current[H.nome]??!1;if(W&&!G&&(U=H.setValues)!=null&&U.length)for(const ne of H.setValues){const J=typeof ne.valor=="string"?xt(ne.valor,w):ne.valor;O(ne.campo,J,{shouldValidate:!1})}q.current[H.nome]=W}Z.current=!1},[V,L,z,A,X,a,O,D]);const P=C.icone?Pt[C.icone]:void 0,se=N.useMemo(()=>()=>{S.handleSubmit(m)()},[m]);return o.jsx($e.FormProvider,{...S,children:o.jsx(Ok,{value:{submitting:i,warnings:y,requestSubmit:se},children:o.jsx("form",{onSubmit:k(m),noValidate:!0,onKeyDown:U=>{U.key==="Enter"&&U.target.tagName==="INPUT"&&U.preventDefault()},children:o.jsxs("div",{className:"space-y-6",children:[C.showLabel!==!1&&o.jsxs("div",{className:"text-center space-y-2",children:[P&&o.jsx("div",{className:"w-12 h-12 mx-auto rounded-xl flex items-center justify-center",style:{background:"color-mix(in srgb, var(--t-primary) 12%, transparent)"},children:o.jsx(P,{className:"w-6 h-6",style:{color:"var(--t-primary)"}})}),o.jsx("h2",{className:"text-2xl font-bold",style:{color:"var(--t-text)"},children:C.titulo}),C.descricao&&o.jsx("p",{className:"text-sm text-muted-foreground",children:C.descricao})]}),o.jsx(wh,{step:C,control:$,externalData:a}),o.jsxs("div",{className:"flex items-center justify-between gap-4 pt-6 pb-2",children:[o.jsxs(De,{type:"button",variant:"outline",onClick:p,disabled:e===0,className:K(e>0&&"border-primary/40 text-primary hover:bg-primary/5"),children:[o.jsx(_.ChevronLeft,{className:"w-4 h-4"}),o.jsx("span",{className:"hidden sm:inline",children:"Anterior"})]}),o.jsxs("span",{className:"text-xs font-semibold tabular-nums sm:hidden text-muted-foreground",children:[e+1,"/",t]}),o.jsxs(De,{type:"submit",disabled:i,children:[i?o.jsx(_.Loader2,{className:"w-4 h-4 animate-spin"}):f?o.jsx(_.Check,{className:"w-4 h-4"}):o.jsx(_.ChevronRight,{className:"w-4 h-4"}),o.jsx("span",{className:"hidden sm:inline",children:f?"Finalizar":"Próximo"})]})]}),l&&o.jsx("p",{className:"text-sm text-destructive mt-2 text-center",children:l})]})})})})},eo=e=>{if(e)return Pt[e]},Mk=({steps:e,currentStep:t,onStepClick:r})=>o.jsx("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:e.map((n,a)=>o.jsx("div",{role:r?"button":void 0,tabIndex:r?0:void 0,onClick:()=>r==null?void 0:r(a),onKeyDown:s=>s.key==="Enter"&&(r==null?void 0:r(a)),className:K("w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold transition-all shrink-0",r&&"cursor-pointer hover:opacity-80"),style:a===t?{background:"var(--t-primary)",color:"#ffffff",boxShadow:"0 0 0 3px color-mix(in srgb, var(--t-primary) 30%, transparent)"}:a<t?{background:"#22c55e",color:"#ffffff"}:{background:"hsl(var(--muted))",color:"hsl(var(--muted-foreground))"},children:a<t?o.jsx(_.Check,{className:"w-4 h-4"}):a+1},n.id))}),Vk=({steps:e,currentStep:t,onStepClick:r})=>o.jsx("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:e.map((n,a)=>{const s=eo(n.icone)??_.CircleDot;return o.jsx("div",{role:r?"button":void 0,tabIndex:r?0:void 0,onClick:()=>r==null?void 0:r(a),onKeyDown:i=>i.key==="Enter"&&(r==null?void 0:r(a)),className:K("w-9 h-9 rounded-full flex items-center justify-center transition-all shrink-0",r&&"cursor-pointer hover:opacity-80"),style:a===t?{background:"var(--t-primary)",color:"#ffffff",boxShadow:"0 0 0 3px color-mix(in srgb, var(--t-primary) 30%, transparent)"}:a<t?{background:"#22c55e",color:"#ffffff"}:{background:"hsl(var(--muted))",color:"hsl(var(--muted-foreground))"},children:a<t?o.jsx(_.Check,{className:"w-4 h-4"}):o.jsx(s,{className:"w-4 h-4"})},n.id)})}),Bk=({steps:e,currentStep:t,position:r,orientation:n="horizontal",onStepClick:a})=>n==="vertical"?o.jsx("div",{className:"flex flex-col gap-0",children:e.map((s,i)=>{const l=eo(s.icone)??_.CircleDot,c=i===t,d=i<t,u=i===e.length-1;return o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsxs("div",{className:"flex flex-col items-center",children:[o.jsx("button",{type:"button",onClick:()=>a==null?void 0:a(i),className:K("w-8 h-8 rounded-full flex items-center justify-center transition-all shrink-0",a&&"cursor-pointer hover:opacity-80"),style:c?{background:"var(--t-primary)",color:"#fff",boxShadow:"0 0 10px color-mix(in srgb, var(--t-primary) 50%, transparent)"}:d?{background:"#22c55e",color:"#fff"}:{background:"color-mix(in srgb, var(--t-text) 8%, transparent)",color:"var(--t-text-muted)",border:"1.5px solid color-mix(in srgb, var(--t-border) 60%, transparent)"},children:d?o.jsx(_.Check,{className:"w-3.5 h-3.5"}):o.jsx(l,{className:"w-3.5 h-3.5"})}),!u&&o.jsx("div",{className:"w-[2px] my-1",style:{height:"24px",background:d?"#22c55e":"color-mix(in srgb, var(--t-border) 50%, transparent)"}})]}),o.jsx("span",{className:"text-sm font-medium leading-tight mt-1.5",style:c?{color:"var(--t-primary)"}:d?{color:"#16a34a"}:{color:"var(--t-text-muted)"},children:s.label??s.id})]},s.id)})}):o.jsx("div",{className:"w-full flex items-start",children:e.map((s,i)=>{const l=eo(s.icone)??_.CircleDot,c=i===t,d=i<t,u=i===e.length-1;return o.jsxs("div",{className:K("flex items-start",!u&&"flex-1"),children:[o.jsxs("div",{className:"flex flex-col items-center gap-1.5 w-[56px] shrink-0 mx-auto",children:[o.jsx("button",{type:"button",onClick:()=>a==null?void 0:a(i),className:K("w-10 h-10 rounded-full flex items-center justify-center transition-all shrink-0",a&&"cursor-pointer hover:opacity-80"),style:c?{background:"var(--t-primary)",color:"#ffffff",boxShadow:"0 0 12px color-mix(in srgb, var(--t-primary) 50%, transparent)"}:d?{background:"#22c55e",color:"#ffffff"}:{background:"color-mix(in srgb, var(--t-text) 8%, transparent)",color:"var(--t-text-muted)",border:"1.5px solid color-mix(in srgb, var(--t-border) 60%, transparent)"},children:d?o.jsx(_.Check,{className:"w-4 h-4"}):o.jsx(l,{className:"w-4 h-4"})}),o.jsx("span",{className:"text-[10px] font-medium text-center leading-tight line-clamp-2 px-0.5",style:c?{color:"var(--t-primary)"}:d?{color:"#16a34a"}:{color:"var(--t-text-muted)"},children:s.label??s.id})]}),!u&&o.jsx("div",{className:"flex-1 h-[1.5px] mt-5 mx-1",style:{background:d?"linear-gradient(90deg, var(--t-primary), color-mix(in srgb, var(--t-primary) 40%, transparent))":"color-mix(in srgb, var(--t-border) 50%, transparent)"}})]},s.id)})}),Ch=({steps:e,currentStep:t,onStepClick:r,className:n,forceShow:a})=>{const s=sa(),{layout:i}=s;if(!i.showStepIndicators||e.length<=1&&!a)return null;const l=i.stepIndicatorVariant??"numbers",c=i.stepIndicatorPosition??"top-center",d=i.stepIndicatorOrientation??"horizontal",u=(t+1)/e.length*100,m=e[t],p=eo(m==null?void 0:m.icone)??_.CircleDot,f=o.jsx("div",{className:"h-1 rounded-full overflow-hidden",style:{background:"color-mix(in srgb, var(--t-primary) 15%, transparent)"},children:o.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${u}%`,background:"linear-gradient(90deg, var(--t-primary), var(--t-accent))"}})}),b=o.jsxs("div",{className:"block sm:hidden space-y-2",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center shrink-0",style:{background:"var(--t-primary)",color:"#fff"},children:o.jsx(p,{className:"w-5 h-5"})}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("p",{className:"text-sm font-semibold leading-tight truncate",style:{color:"var(--t-text)"},children:(m==null?void 0:m.label)??(m==null?void 0:m.id)}),o.jsxs("p",{className:"text-xs leading-tight",style:{color:"var(--t-text-muted)"},children:["Passo ",t+1," de ",e.length]})]})]}),f]}),h=o.jsxs("div",{className:"hidden sm:block",children:[l==="numbers"&&o.jsx(Mk,{steps:e,currentStep:t,onStepClick:r}),l==="icons"&&o.jsx(Vk,{steps:e,currentStep:t,onStepClick:r}),l==="icons-labeled"&&o.jsx(Bk,{steps:e,currentStep:t,position:c,orientation:d,onStepClick:r})]}),x=i.showProgressBar?o.jsx("div",{className:"hidden sm:block",children:f}):null;return d==="vertical"?o.jsxs("div",{className:K("flex gap-6 items-start",n),children:[b,o.jsxs("div",{className:"hidden sm:flex gap-6 items-start shrink-0",children:[h,x&&o.jsx("div",{className:"flex-1 pt-4",children:x})]})]}):o.jsxs("div",{className:K("space-y-3",n),children:[b,o.jsxs("div",{className:"hidden sm:block space-y-3",children:[h,x]})]})},Uk=(e,t,r)=>{var n;const a={...t},s=r;for(const i of e.containers){for(const l of i.campos)if(a[l.nome]===void 0&&(l.initialValue!==void 0?a[l.nome]=typeof l.initialValue=="string"?xt(l.initialValue,s):l.initialValue:l.defaultValue!==void 0&&(a[l.nome]=l.defaultValue)),l.tipo===T.FIELD_ARRAY&&(n=l.subFields)!=null&&n.length){const c=a[l.nome];Array.isArray(c)&&c.length>0&&(a[l.nome]=c.map(d=>{const u={...d};for(const m of l.subFields)u[m.nome]===void 0&&(m.initialValue!==void 0?u[m.nome]=typeof m.initialValue=="string"?xt(m.initialValue,s):m.initialValue:m.defaultValue!==void 0&&(u[m.nome]=m.defaultValue));return u}))}if(i.repeatable&&i.nome){const l=a[i.nome];Array.isArray(l)&&l.length>0&&(a[i.nome]=l.map(c=>{const d={...c};for(const u of i.campos)d[u.nome]===void 0&&(u.initialValue!==void 0?d[u.nome]=typeof u.initialValue=="string"?xt(u.initialValue,s):u.initialValue:u.defaultValue!==void 0&&(d[u.nome]=u.defaultValue));return d}))}}return a},Hk=({schema:e,initialValues:t={},initialStep:r=0,onSubmitStep:n,onComplete:a,template:s,formTitle:i,externalData:l={},fieldErrors:c={},uploadFile:d,deleteUploadedFile:u,cepLookup:m,resolveTermsUploadUrl:p,fieldResolvers:f,validatorMapper:b,componentMapper:h,paymentMethodOptions:x,onValuesChange:y,className:v,StepIndicator:j=Ch})=>{const[w,C]=N.useState(()=>r),[S,$]=N.useState({...t}),[k,E]=N.useState(()=>r),[D,O]=N.useState(!1),[L,A]=N.useState(null),[z,X]=N.useState({}),q=N.useRef(p);q.current=p;const Z=N.useCallback(me=>q.current(me),[]),V=!!p,M=N.useRef(u);M.current=u;const P=N.useCallback(me=>M.current(me),[]),se=!!u,U=N.useMemo(()=>JSON.stringify(l),[l]),Q=N.useMemo(()=>JSON.stringify(e.stepConfig),[e.stepConfig]),Y=N.useMemo(()=>{const me=uo(s);return e.stepConfig?{...me,layout:{...me.layout,...e.stepConfig}}:me},[s,Q]),H=N.useMemo(()=>[...e.steps].sort((me,Ee)=>me.ordem-Ee.ordem),[e.steps]),W=H.length,G=W>0?H[Math.min(w,W-1)]:null,ne=N.useMemo(()=>G?Uk(G,S,l):{},[G,S,U]),J=N.useMemo(()=>({uploadFile:d,deleteUploadedFile:se?P:void 0,cepLookup:m,resolveTermsUploadUrl:V?Z:void 0,externalData:l,fieldResolvers:f,validatorMapper:b,fieldWarnings:z,componentMapper:h,paymentMethodOptions:x}),[d,se,P,m,Z,V,f,b,z,h,x,U]),te=N.useCallback(async me=>{if(!D){O(!0),A(null);try{const Ee={...S,...me};if($(Ee),n&&await n(w,me),w===W-1)a&&await a(Ee);else{const Fe=w+1;C(Fe),E(Nt=>Math.max(Nt,Fe))}}catch(Ee){console.error("[FormRenderer] Submit error:",Ee);const Fe=Ee instanceof Error?Ee.message:"Ocorreu um erro. Tente novamente.";A(Fe)}finally{O(!1)}}},[w,S,D,W,n,a]),ce=N.useCallback(()=>{w>0&&C(me=>me-1)},[w]);if(!G)return o.jsx(Ja.Provider,{value:J,children:o.jsx(ea,{config:Y,className:`min-h-dvh ${Y.wrapperClass??""} ${v??""}`,renderWrapper:!0,children:o.jsx("div",{className:"w-full max-w-4xl mx-auto px-4 py-6 sm:px-6 text-center text-muted-foreground",children:"Nenhum step configurado."})})});const be=Y.layout.eventTitleStyle??"bar",Ce=(Y.layout.stepIndicatorOrientation??"horizontal")==="vertical",ve=W>=1?o.jsx(j,{steps:H.map(me=>({id:me.id,label:me.titulo,icone:me.icone})),currentStep:w,onStepClick:me=>{me!==w&&me<=k&&C(me)}}):null;return o.jsx(Ja.Provider,{value:J,children:o.jsx(ea,{config:Y,className:`min-h-dvh ${Y.wrapperClass??""} ${v??""}`,renderWrapper:!0,children:o.jsxs("div",{className:"w-full max-w-4xl mx-auto px-4 py-6 sm:px-6",children:[i&&be==="bar"&&o.jsx("div",{className:"w-full text-center text-sm font-medium py-2.5 px-4 mb-6 rounded-lg border border-input text-muted-foreground bg-muted/30",children:i}),i&&be==="inline"&&o.jsxs("div",{className:"text-center mb-6",children:[o.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest mb-1",style:{color:"var(--t-text-muted)"},children:"Inscrição"}),o.jsx("h1",{className:"text-2xl font-bold",style:{color:"var(--t-text)"},children:i}),o.jsx("div",{className:"h-0.5 w-12 mx-auto mt-3 rounded-full",style:{background:"var(--t-primary)"}})]}),Ce?o.jsxs("div",{className:"flex gap-6 items-start",children:[o.jsx("div",{className:"hidden sm:block shrink-0 w-44 pt-1",children:ve}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"sm:hidden mb-6",children:ve}),o.jsx(sd,{stepIndex:w,totalSteps:W,step:G,defaultValues:ne,externalData:l,fieldErrors:c,isSubmitting:D,submitError:L,validatorMapper:b,onWarningsChange:X,onValuesChange:y,onSubmit:te,onBack:ce},w)]})]}):o.jsxs(o.Fragment,{children:[ve&&o.jsx("div",{className:"mb-8",children:ve}),o.jsx(sd,{stepIndex:w,totalSteps:W,step:G,defaultValues:ne,externalData:l,fieldErrors:c,isSubmitting:D,submitError:L,validatorMapper:b,onWarningsChange:X,onValuesChange:y,onSubmit:te,onBack:ce},w)]})]})})})},Wk=({children:e,render:t,onChange:r})=>{const n=jh(),a=N.useRef(r);return a.current=r,N.useEffect(()=>{var s;(s=a.current)==null||s.call(a,n)},[n.values,n.dirty,n.valid,n.submitting,n.errors,n.warnings]),t?o.jsx(o.Fragment,{children:t(n)}):typeof e=="function"?o.jsx(o.Fragment,{children:e(n)}):e!==void 0?o.jsx(o.Fragment,{children:e}):null},Or=[{component:"texto",label:"Texto",icon:_.Type,group:"texto"},{component:"textarea",label:"Área de texto",icon:_.AlignLeft,group:"texto"},{component:"number",label:"Número",icon:_.Hash,group:"texto"},{component:"email",label:"E-mail",icon:_.Mail,group:"texto"},{component:"password",label:"Senha",icon:_.Lock,group:"texto"},{component:"select",label:"Seleção",icon:_.ChevronDown,group:"selecao"},{component:"autocomplete",label:"Autocomplete",icon:_.Search,group:"selecao"},{component:"radio",label:"Radio",icon:_.CircleDot,group:"selecao"},{component:"checkbox",label:"Checkbox",icon:_.CheckSquare,group:"selecao"},{component:"checkbox_group",label:"Grupo de checkboxes",icon:_.ListChecks,group:"selecao"},{component:"switch",label:"Switch (toggle)",icon:_.ToggleLeft,group:"selecao"},{component:"slider",label:"Slider",icon:_.SlidersHorizontal,group:"range"},{component:"rating",label:"Avaliação (estrelas)",icon:_.Star,group:"range"},{component:"color",label:"Cor",icon:_.Palette,group:"range"},{component:"date",label:"Data",icon:_.Calendar,group:"data"},{component:"datetime",label:"Data e hora",icon:_.Clock,group:"data"},{component:"time",label:"Horário",icon:_.Timer,group:"data"},{component:"date_range",label:"Período",icon:_.CalendarRange,group:"data"},{component:"telefone",label:"Telefone",icon:_.Phone,group:"contato"},{component:"cpf",label:"CPF",icon:_.CreditCard,group:"contato"},{component:"cep",label:"CEP",icon:_.MapPin,group:"contato"},{component:"file",label:"Arquivo",icon:_.Upload,group:"outros"},{component:"hidden",label:"Oculto",icon:_.EyeOff,group:"outros"},{component:"field_array",label:"Lista de itens",icon:_.List,group:"outros"},{component:"terms",label:"Termos e condições",icon:_.ScrollText,group:"outros"},{component:"sub_form",label:"Sub-formulário",icon:_.LayoutList,group:"outros"}],vl=[{component:"step",label:"Step",icon:_.Layers,color:"border-primary/40 bg-primary/5"},{component:"container",label:"Container",icon:_.BoxSelect,color:"border-blue-500/40 bg-blue-500/5"}],bl=[{key:"evento.nome",label:"Nome do evento",type:"string"},{key:"evento.descricao",label:"Descrição",type:"string"},{key:"evento.valor",label:"Valor (centavos)",type:"number"},{key:"evento.valorPorDia",label:"Valor por dia",type:"number"},{key:"evento.vagasTotal",label:"Vagas totais",type:"number"},{key:"evento.vagasPorDia",label:"Vagas por dia",type:"number"},{key:"evento.vagasMasculinas",label:"Vagas masculinas",type:"number"},{key:"evento.vagasFemininas",label:"Vagas femininas",type:"number"},{key:"evento.dataInicioEvento",label:"Data início",type:"date"},{key:"evento.dataFimEvento",label:"Data fim",type:"date"},{key:"evento.dataAberturaInscricoes",label:"Abertura inscrições",type:"date"},{key:"evento.localNome",label:"Local - Nome",type:"string"},{key:"evento.localEndereco",label:"Local - Endereço",type:"string"},{key:"evento.localTelefone",label:"Local - Telefone",type:"string"},{key:"evento.localMapUrl",label:"Local - URL do mapa",type:"string"},{key:"evento.localMapLink",label:"Local - Link do mapa",type:"string"},{key:"evento.status",label:"Status do evento",type:"string"},{key:"evento.publicId",label:"ID público (URL)",type:"string"},{key:"evento.fotoCapa",label:"URL da foto de capa",type:"string"},{key:"evento.template",label:"Template visual",type:"string"}],He=e=>e.startsWith("step-")||e==="step"?"step":e.startsWith("container-")||e==="container"?"container":"field",qk=e=>Or.find(t=>t.component===e),Nh=e=>{const t=Or.map(n=>n.component).filter(n=>n.includes("_"));for(const n of t)if(e.startsWith(n))return Or.find(a=>a.component===n);const r=e.split("-")[0];return Or.find(n=>n.component===r)},ks=e=>({when:e.campoId,operator:e.operador,value:e.valor,source:e.source}),Sh=e=>{var t;const r={campoId:e.when,operador:e.operator,valor:e.value,source:e.source};if(e.logicOperator&&(t=e.extraConditions)!=null&&t.length){const n=e.extraConditions.map(s=>({campoId:s.when,operador:s.operator,valor:s.value,source:s.source})),a=[r,...n];return e.logicOperator==="or"?{or:a}:{and:a}}return r},$h=e=>{if("campoId"in e)return ks(e);const t=("and"in e?e.and:e.or)??[];if(t.length===0)return;const r="and"in e?"and":"or",[n,...a]=t;if(!("campoId"in n)){console.warn("[formSchemaToBuilder] Condicional com grupo aninhado detectada — não suportado no editor visual. A condicional será removida.",e);return}const s=ks(n);return a.length===0?s:{...s,logicOperator:r,extraConditions:a.filter(i=>"campoId"in i).map(ks)}},to=(e,t)=>{var r;if("campoId"in e){const n=(r=t[e.campoId])==null?void 0:r.name;return n?{...e,campoId:n}:e}return"and"in e&&Array.isArray(e.and)?{and:e.and.map(n=>to(n,t))}:"or"in e&&Array.isArray(e.or)?{or:e.or.map(n=>to(n,t))}:e},yl=(e,t,r)=>{var n,a;const s=l=>t[l]||{label:l,name:l},i=(((a=(n=e==null?void 0:e.containers)==null?void 0:n.root)==null?void 0:a.children)||[]).filter(l=>He(l)==="step").map((l,c)=>{var d,u;const m=s(l),p=(((u=(d=e==null?void 0:e.containers)==null?void 0:d[l])==null?void 0:u.children)||[]).filter(f=>He(f)==="container").map((f,b)=>{var h,x;const y=s(f),v=(((x=(h=e==null?void 0:e.containers)==null?void 0:h[f])==null?void 0:x.children)||[]).filter(w=>He(w)==="field").map((w,C)=>{var S,$;const k=s(w),E=li(k,w,C);if(E.condicional&&(E.condicional=to(E.condicional,t)),E.tipo===T.FIELD_ARRAY){const D=(($=(S=e==null?void 0:e.containers)==null?void 0:S[w])==null?void 0:$.children)??[];E.subFields=D.filter(O=>He(O)==="field").map((O,L)=>li(s(O),O,L))}return E}),j={id:f,titulo:y.label||"Container",descricao:y.description,icone:y.icone,ordem:b,colunas:y.columns||2,tamanho:y.tamanho||12,inicioColuna:y.inicioColuna,showLabel:y.showLabel,showAsCard:y.showAsCard,campos:v};return y.condition&&(j.condicional=to(Sh(y.condition),t)),j});return{id:l,titulo:m.label||"Step",descricao:m.description,icone:m.icone,ordem:c,showLabel:m.showLabel,containers:p}});return{id:r.id||"",nome:r.nome,descricao:r.descricao,status:r.status,template:r.template??null,stepConfig:r.stepConfig&&Object.keys(r.stepConfig).length>0?r.stepConfig:void 0,steps:i}},li=(e,t,r)=>{var n,a,s,i;const l={id:t,nome:e.name||t,label:e.label||"",tipo:e.fieldType||"texto",obrigatorio:e.required||!1,tamanho:e.tamanho||6,inicioColuna:e.inicioColuna,ordem:r,placeholder:e.placeholder,hint:e.hint,defaultValue:e.defaultValue,mascara:e.mascara,mascaraCustom:e.mascaraCustom,locked:e.locked||void 0,visualStyle:e.visualStyle,isReadOnly:e.isReadOnly||void 0,isDisabled:e.isDisabled||void 0,clearedValue:e.clearedValue!==void 0?e.clearedValue:void 0,initialValue:e.initialValue!==void 0?e.initialValue:void 0,resolvePropsKey:e.resolvePropsKey||void 0};if((n=e.validate)!=null&&n.length&&(l.validate=e.validate),(a=e.warn)!=null&&a.length&&(l.warn=e.warn),(s=e.options)!=null&&s.length&&(l.opcoes=e.options.map(c=>({valor:c.value,label:c.label,disabled:c.disabled}))),e.validation){const c=e.validation;l.validacao={},c.minLength!==void 0&&(l.validacao.minLength=c.minLength),c.maxLength!==void 0&&(l.validacao.maxLength=c.maxLength),c.min!==void 0&&(l.validacao.min=c.min),c.max!==void 0&&(l.validacao.max=c.max),c.regex&&(l.validacao.regex=c.regex),c.regexMessage&&(l.validacao.regexMessage=c.regexMessage),c.minDate&&(l.validacao.minDate=c.minDate),c.maxDate&&(l.validacao.maxDate=c.maxDate),c.minAge!==void 0&&(l.validacao.minAge=c.minAge),c.maxAge!==void 0&&(l.validacao.maxAge=c.maxAge),(i=c.fileTypes)!=null&&i.length&&(l.validacao.fileTypes=c.fileTypes),c.maxFileSize!==void 0&&(l.validacao.maxFileSize=c.maxFileSize)}if(l.tipo===T.FIELD_ARRAY&&(e.itemLabel&&(l.itemLabel=e.itemLabel),e.minItems!==void 0&&(l.minItems=e.minItems),e.maxItems!==void 0&&(l.maxItems=e.maxItems),e.addLabel&&(l.addLabel=e.addLabel)),l.tipo===T.TERMS&&(e.termoTexto&&(l.termoTexto=e.termoTexto),e.termoPdfUrl&&(l.termoPdfUrl=e.termoPdfUrl),e.termoPdfUploadId&&(l.termoPdfUploadId=e.termoPdfUploadId)),l.tipo===T.SLIDER&&(e.step!==void 0&&(l.step=e.step),e.minValue!==void 0&&(l.minValue=e.minValue),e.maxValue!==void 0&&(l.maxValue=e.maxValue)),l.tipo===T.RATING&&e.maxRating!==void 0&&(l.maxRating=e.maxRating),l.tipo===T.DATE_RANGE&&(e.dateRangeStartLabel&&(l.dateRangeStartLabel=e.dateRangeStartLabel),e.dateRangeEndLabel&&(l.dateRangeEndLabel=e.dateRangeEndLabel)),l.tipo===T.SUB_FORM){const c=e.subSchemaFields??[];(c.length>0||e.subSchemaTitle)&&(l.subSchema={titulo:e.subSchemaTitle,fields:c.map((d,u)=>li(d,d.name??`subfield-${u}`,u))})}return e.condition&&(l.condicional=Sh(e.condition)),l},Eh=e=>{const t={},r={root:{children:[]}},n=[...e.steps].sort((a,s)=>a.ordem-s.ordem);for(const a of n){const s=a.id||`step-${St()}`;r.root.children.push(s),t[s]={label:a.titulo,name:s,fieldType:"step",description:a.descricao,icone:a.icone,showLabel:a.showLabel};const i=[],l=[...a.containers].sort((c,d)=>c.ordem-d.ordem);for(const c of l){const d=c.id||`container-${St()}`;i.push(d);const u=c.condicional?$h(c.condicional):void 0;t[d]={label:c.titulo,name:d,fieldType:"container",description:c.descricao,icone:c.icone,columns:c.colunas,tamanho:c.tamanho||12,inicioColuna:c.inicioColuna,showLabel:c.showLabel,showAsCard:c.showAsCard,...u?{condition:u}:{}};const m=[],p=[...c.campos].sort((f,b)=>f.ordem-b.ordem);for(const f of p){const b=f.id||`${f.tipo}-${St()}`;if(m.push(b),t[b]=ci(f),f.tipo===T.FIELD_ARRAY){const h=[];for(const x of f.subFields??[]){const y=x.id||`${x.tipo}-${St()}`;h.push(y),t[y]=ci(x)}r[b]={children:h}}}r[d]={children:m}}r[s]={children:i}}return{dndState:{containers:r},configs:t,templateId:e.template??null,stepConfig:e.stepConfig}},ci=(e,t)=>{var r,n,a,s;const i={label:e.label,name:e.nome,fieldType:e.tipo,required:e.obrigatorio,tamanho:e.tamanho,inicioColuna:e.inicioColuna,placeholder:e.placeholder,hint:e.hint,defaultValue:e.defaultValue,mascara:e.mascara,mascaraCustom:e.mascaraCustom,locked:e.locked||void 0,visualStyle:e.visualStyle,isReadOnly:e.isReadOnly||void 0,isDisabled:e.isDisabled||void 0,clearedValue:e.clearedValue!==void 0?String(e.clearedValue??""):void 0,initialValue:e.initialValue!==void 0?String(e.initialValue):void 0,resolvePropsKey:e.resolvePropsKey||void 0,validate:(r=e.validate)!=null&&r.length?e.validate:void 0,warn:(n=e.warn)!=null&&n.length?e.warn:void 0};if((a=e.opcoes)!=null&&a.length&&(i.options=e.opcoes.map(l=>({value:l.valor,label:l.label,disabled:l.disabled}))),e.validacao){const l=e.validacao;i.validation={},l.minLength!==void 0&&(i.validation.minLength=l.minLength),l.maxLength!==void 0&&(i.validation.maxLength=l.maxLength),l.min!==void 0&&(i.validation.min=l.min),l.max!==void 0&&(i.validation.max=l.max),l.regex&&(i.validation.regex=l.regex),l.regexMessage&&(i.validation.regexMessage=l.regexMessage),l.minDate&&(i.validation.minDate=l.minDate),l.maxDate&&(i.validation.maxDate=l.maxDate),l.minAge!==void 0&&(i.validation.minAge=l.minAge),l.maxAge!==void 0&&(i.validation.maxAge=l.maxAge),(s=l.fileTypes)!=null&&s.length&&(i.validation.fileTypes=l.fileTypes),l.maxFileSize!==void 0&&(i.validation.maxFileSize=l.maxFileSize)}if(e.tipo===T.FIELD_ARRAY&&(e.itemLabel&&(i.itemLabel=e.itemLabel),e.minItems!==void 0&&(i.minItems=e.minItems),e.maxItems!==void 0&&(i.maxItems=e.maxItems),e.addLabel&&(i.addLabel=e.addLabel)),e.tipo===T.TERMS&&(e.termoTexto&&(i.termoTexto=e.termoTexto),e.termoPdfUrl&&(i.termoPdfUrl=e.termoPdfUrl),e.termoPdfUploadId&&(i.termoPdfUploadId=e.termoPdfUploadId)),e.tipo===T.SLIDER&&(e.step!==void 0&&(i.step=e.step),e.minValue!==void 0&&(i.minValue=e.minValue),e.maxValue!==void 0&&(i.maxValue=e.maxValue)),e.tipo===T.RATING&&e.maxRating!==void 0&&(i.maxRating=e.maxRating),e.tipo===T.DATE_RANGE&&(e.dateRangeStartLabel&&(i.dateRangeStartLabel=e.dateRangeStartLabel),e.dateRangeEndLabel&&(i.dateRangeEndLabel=e.dateRangeEndLabel)),e.tipo===T.SUB_FORM&&e.subSchema&&(i.subSchemaTitle=e.subSchema.titulo,i.subSchemaFields=e.subSchema.fields.map(l=>ci(l,l.id))),e.condicional){const l=$h(e.condicional);l&&(i.condition=l)}return i},Dh=(e,t)=>{var r,n,a,s,i,l,c,d,u,m,p;const f=[],b=[],h=v=>t[v]||{label:v,name:v},x=((n=(r=e==null?void 0:e.containers)==null?void 0:r.root)==null?void 0:n.children)||[],y=new Set;for(const v of x){if(He(v)!=="step")continue;const j=h(v).label||v,w=((s=(a=e==null?void 0:e.containers)==null?void 0:a[v])==null?void 0:s.children)||[];if(w.length===0){b.push(`Step "${j}" está vazio (sem containers).`);continue}for(const C of w){if(He(C)!=="container")continue;const S=h(C).label||C,$=((l=(i=e==null?void 0:e.containers)==null?void 0:i[C])==null?void 0:l.children)||[],k=new Map;for(const E of $){if(He(E)!=="field")continue;y.add(E);const D=h(E).name;(!D||!D.trim())&&f.push(`Campo "${h(E).label||E}" (${E}) no container "${S}" não tem nome definido.`);const O=D||E;k.has(O)||k.set(O,[]),k.get(O).push(E)}for(const[E,D]of k.entries())D.length>1&&f.push(`Nome duplicado "${E}" no container "${S}" (IDs: ${D.join(", ")}).`)}}for(const[v,j]of Object.entries(t)){if(!((c=j.condition)!=null&&c.when))continue;const w=j.condition.when;if(!y.has(w)){const C=j.label||v;b.push(`Campo "${C}" referencia campo inexistente na condição (when: "${w}").`)}}for(const v of x){if(He(v)!=="step")continue;const j=h(v).label||v,w=((u=(d=e==null?void 0:e.containers)==null?void 0:d[v])==null?void 0:u.children)||[],C=new Map;for(const S of w){if(He(S)!=="container")continue;const $=((p=(m=e==null?void 0:e.containers)==null?void 0:m[S])==null?void 0:p.children)||[];for(const k of $){if(He(k)!=="field")continue;const E=h(k).name||k;C.has(E)||C.set(E,new Set),C.get(E).add(S)}}for(const[S,$]of C.entries())$.size>1&&f.push(`Nome duplicado "${S}" no step "${j}" em containers diferentes (containers: ${[...$].join(", ")}). Isso causa colisão no formulário.`)}return{errors:f,warnings:b}},Th=N.createContext(null),Gk=e=>{if(e.startsWith("step"))return"step";if(e.startsWith("container"))return"container";const t=e.match(/^([a-z_]+)-/);return t?t[1]:e.split("-")[0]},Cs=(e,t)=>{const r=t||Gk(e),n=r==="step",a=r==="container",s=r==="field_array";return{label:n?"Novo Step":a?"Novo Container":s?"Lista de itens":r||e,name:e,fieldType:r||"texto",required:!1,columns:2,tamanho:a||s?12:n?void 0:6,showLabel:a?!0:void 0,itemLabel:s?"Item":void 0}},Ns=e=>typeof structuredClone=="function"?{containers:structuredClone(e.containers),configs:structuredClone(e.configs)}:{containers:JSON.parse(JSON.stringify(e.containers)),configs:JSON.parse(JSON.stringify(e.configs))},Ah=(e,t)=>{const r=[e],n=t[e];if(n!=null&&n.children)for(const a of n.children)r.push(...Ah(a,t));return r},wl=(e,t)=>{for(const[r,n]of Object.entries(t))if(n.children.includes(e))return r;return null},Rh=({children:e,initialConfigs:t,initialContainers:r,initialTemplateId:n,initialStepConfig:a,schemaId:s,uploadTermsPdf:i,deleteTermsPdf:l})=>{const[c,d]=N.useState({selectedId:null,configs:t||{},showPreview:!1,containers:r??{root:{children:[]}},previewTemplateId:n||"moderno",stepConfig:a??{}}),[u,m]=N.useState(null),[p,f]=N.useState(null),b=N.useRef([]),h=N.useRef([]),x=M=>{b.current=[...b.current.slice(-49),Ns(M)],h.current=[]},y=N.useCallback(()=>{d(M=>(x(M),{...M}))},[]),v=N.useCallback(()=>{b.current.length!==0&&d(M=>{h.current=[...h.current,Ns(M)];const P=b.current.pop();return{...M,containers:P.containers,configs:P.configs}})},[]),j=N.useCallback(()=>{h.current.length!==0&&d(M=>{b.current=[...b.current,Ns(M)];const P=h.current.pop();return{...M,containers:P.containers,configs:P.configs}})},[]);N.useEffect(()=>{const M=P=>{const se=P.metaKey||P.ctrlKey;se&&P.key==="z"&&!P.shiftKey&&(P.preventDefault(),v()),se&&P.key==="z"&&P.shiftKey&&(P.preventDefault(),j()),se&&P.key==="y"&&(P.preventDefault(),j())};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[v,j]);const w=N.useCallback(M=>c.configs[M]??Cs(M),[c.configs]),C=N.useCallback(()=>{const M=[],P=se=>{var U;const Q=((U=c.containers[se])==null?void 0:U.children)??[];for(const Y of Q)He(Y)==="field"?M.push(Y):c.containers[Y]&&P(Y)};return P("root"),M},[c.containers]),S=N.useCallback(M=>{d(P=>({...P,selectedId:M}))},[]),$=N.useCallback(M=>{d(P=>({...P,showPreview:M}))},[]),k=N.useCallback(M=>{d(P=>({...P,previewTemplateId:M}))},[]),E=N.useCallback(M=>{d(P=>({...P,stepConfig:{...P.stepConfig,...M}}))},[]),D=N.useCallback((M,P)=>{d(se=>({...se,configs:{...se.configs,[M]:{...se.configs[M]??Cs(M),...P}}}))},[]),O=N.useCallback((M,P,se)=>{const U=`${M}-${St()}`,Q=He(U);return d(Y=>{var H;x(Y);const W={...Y.containers};(Q==="step"||Q==="container"||M==="field_array")&&(W[U]={children:[]});const G=[...((H=W[P])==null?void 0:H.children)??[]];return se!==void 0&&se>=0?G.splice(se,0,U):G.push(U),W[P]={children:G},{...Y,containers:W,configs:{...Y.configs,[U]:Cs(U,M)},selectedId:U}}),U},[]),L=N.useCallback((M,P)=>{const se=`container-${St()}`;return d(U=>{var Q,Y,H;x(U);const W={...U.containers},G={...U.configs},ne=[];for(const te of M.containerTemplate.campos){const ce=te.locked&&te.id?te.id:`${String(te.tipo).toLowerCase()}-${St()}`;if(ne.push(ce),G[ce]={label:te.label,name:te.locked?te.id:te.nome,fieldType:te.tipo,required:te.obrigatorio||!1,placeholder:te.placeholder,hint:te.hint,tamanho:te.tamanho||6,inicioColuna:te.inicioColuna,defaultValue:te.defaultValue!=null?String(te.defaultValue):void 0,locked:te.locked||!1,options:(Q=te.opcoes)==null?void 0:Q.map(be=>({value:be.valor,label:be.label})),...te.tipo==="field_array"&&{itemLabel:te.itemLabel,minItems:te.minItems,maxItems:te.maxItems,addLabel:te.addLabel}},te.tipo==="field_array"){const be=[];for(const Ce of te.subFields??[]){const ve=`${String(Ce.tipo).toLowerCase()}-${St()}`;be.push(ve),G[ve]={label:Ce.label,name:Ce.nome,fieldType:Ce.tipo,required:Ce.obrigatorio||!1,placeholder:Ce.placeholder,hint:Ce.hint,tamanho:Ce.tamanho||6,inicioColuna:Ce.inicioColuna,options:(Y=Ce.opcoes)==null?void 0:Y.map(me=>({value:me.valor,label:me.label}))}}W[ce]={children:be}}}W[se]={children:ne},G[se]={label:M.containerTemplate.titulo||M.name,description:M.containerTemplate.descricao,icone:M.containerTemplate.icone,tamanho:M.containerTemplate.tamanho||12,inicioColuna:M.containerTemplate.inicioColuna,showLabel:!0};const J=[...((H=W[P])==null?void 0:H.children)??[]];return J.push(se),W[P]={children:J},{...U,containers:W,configs:G,selectedId:se}}),se},[]),A=N.useCallback(M=>{const P=[];return d(se=>{var U,Q,Y;x(se);const H={...se.containers},W={...se.configs};for(const G of M.steps){const ne=`step-${St()}`;P.push(ne);const J=[];for(const ce of G.containers){const be=`container-${St()}`;J.push(be);const Ce=[];for(const ve of ce.campos){const me=ve.locked&&ve.id?ve.id:`${String(ve.tipo).toLowerCase()}-${St()}`;if(Ce.push(me),W[me]={label:ve.label,name:ve.locked?ve.id:ve.nome,fieldType:ve.tipo,required:ve.obrigatorio||!1,placeholder:ve.placeholder,hint:ve.hint,tamanho:ve.tamanho||12,inicioColuna:ve.inicioColuna,defaultValue:ve.defaultValue!=null?String(ve.defaultValue):void 0,locked:ve.locked||!1,options:(U=ve.opcoes)==null?void 0:U.map(Ee=>({value:Ee.valor,label:Ee.label})),...ve.tipo==="field_array"&&{itemLabel:ve.itemLabel,minItems:ve.minItems,maxItems:ve.maxItems,addLabel:ve.addLabel}},ve.tipo==="field_array"){const Ee=[];for(const Fe of ve.subFields??[]){const Nt=`${String(Fe.tipo).toLowerCase()}-${St()}`;Ee.push(Nt),W[Nt]={label:Fe.label,name:Fe.nome,fieldType:Fe.tipo,required:Fe.obrigatorio||!1,placeholder:Fe.placeholder,hint:Fe.hint,tamanho:Fe.tamanho||6,inicioColuna:Fe.inicioColuna,options:(Q=Fe.opcoes)==null?void 0:Q.map(dt=>({value:dt.valor,label:dt.label}))}}H[me]={children:Ee}}}H[be]={children:Ce},W[be]={label:ce.titulo,description:ce.descricao,icone:ce.icone,tamanho:ce.tamanho||12,showLabel:!0}}H[ne]={children:J},W[ne]={label:G.titulo,description:G.descricao,icone:G.icone};const te=[...((Y=H.root)==null?void 0:Y.children)??[],ne];H.root={children:te}}return{...se,containers:H,configs:W,selectedId:P[0]??se.selectedId}}),P},[]),z=N.useCallback((M,P,se,U)=>{d(Q=>{var Y,H;x(Q);const W={...Q.containers},G=(((Y=W[P])==null?void 0:Y.children)??[]).filter(te=>te!==M);W[P]={children:G};const ne=[...(((H=W[se])==null?void 0:H.children)??[]).filter(te=>te!==M)],J=Math.max(0,Math.min(U,ne.length));return ne.splice(J,0,M),W[se]={children:ne},{...Q,containers:W}})},[]),X=N.useCallback((M,P)=>{d(se=>(x(se),{...se,containers:{...se.containers,[M]:{children:P}}}))},[]),q=N.useCallback(M=>{d(P=>{x(P);const se=Ah(M,P.containers),U={};for(const[Y,H]of Object.entries(P.containers))se.includes(Y)||(U[Y]={children:H.children.filter(W=>!se.includes(W))});const Q={...P.configs};for(const Y of se)delete Q[Y];return{...P,containers:U,configs:Q,selectedId:se.includes(P.selectedId??"")?null:P.selectedId}})},[]),Z=N.useCallback((M,P)=>{d(se=>{const U=wl(M,se.containers);if(!U)return se;const Q=[...se.containers[U].children],Y=Q.indexOf(M),H=P==="up"?Y-1:Y+1;return H<0||H>=Q.length?se:([Q[Y],Q[H]]=[Q[H],Q[Y]],{...se,containers:{...se.containers,[U]:{children:Q}}})})},[]),V=N.useCallback((M,P)=>{y(),Z(M,P)},[Z,y]);return o.jsx(Th.Provider,{value:{selectedId:c.selectedId,configs:c.configs,showPreview:c.showPreview,containers:c.containers,positionDrag:u,reorderDrag:p,canUndo:b.current.length>0,canRedo:h.current.length>0,schemaId:s,uploadTermsPdf:i,deleteTermsPdf:l,previewTemplateId:c.previewTemplateId,setPreviewTemplateId:k,stepConfig:c.stepConfig,updateStepConfig:E,getConfig:w,getAllFieldIds:C,setSelected:S,updateConfig:D,setShowPreview:$,addItem:O,addPresetBlock:L,addPresetStepBlock:A,moveCanvasItem:z,reorderInContainer:X,removeItem:q,moveItem:V,moveItemNoSnapshot:Z,setPositionDrag:m,setReorderDrag:f,undo:v,redo:j,pushSnapshot:y},children:e})},gt=()=>{const e=N.useContext(Th);if(!e)throw new Error("useBuilder must be inside BuilderProvider");return e},Xk=()=>{const{containers:e,configs:t,stepConfig:r}=gt(),n=N.useCallback(s=>yl({containers:e},t,{...s,stepConfig:r}),[e,t,r]),a=N.useCallback(()=>Dh({containers:e},t),[e,t]);return{buildSchema:n,validate:a}};function Ih(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(r=Ih(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function Zk(){for(var e,t,r=0,n="",a=arguments.length;r<a;r++)(e=arguments[r])&&(t=Ih(e))&&(n&&(n+=" "),n+=t);return n}const Kk=(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},Yk=(e,t)=>({classGroupId:e,validator:t}),Ph=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),ro="-",id=[],Jk="arbitrary..",Qk=e=>{const t=tC(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:a=>{if(a.startsWith("[")&&a.endsWith("]"))return eC(a);const s=a.split(ro),i=s[0]===""&&s.length>1?1:0;return _h(s,i,t)},getConflictingClassGroupIds:(a,s)=>{if(s){const i=n[a],l=r[a];return i?l?Kk(l,i):i:l||id}return r[a]||id}}},_h=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const n=e[t],a=r.nextPart.get(n);if(a){const c=_h(e,t+1,a);if(c)return c}const s=r.validators;if(s===null)return;const i=t===0?e.join(ro):e.slice(t).join(ro),l=s.length;for(let c=0;c<l;c++){const d=s[c];if(d.validator(i))return d.classGroupId}},eC=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?Jk+n:void 0})(),tC=e=>{const{theme:t,classGroups:r}=e;return rC(r,t)},rC=(e,t)=>{const r=Ph();for(const n in e){const a=e[n];jl(a,r,n,t)}return r},jl=(e,t,r,n)=>{const a=e.length;for(let s=0;s<a;s++){const i=e[s];nC(i,t,r,n)}},nC=(e,t,r,n)=>{if(typeof e=="string"){aC(e,t,r);return}if(typeof e=="function"){oC(e,t,r,n);return}sC(e,t,r,n)},aC=(e,t,r)=>{const n=e===""?t:Oh(t,e);n.classGroupId=r},oC=(e,t,r,n)=>{if(iC(e)){jl(e(n),t,r,n);return}t.validators===null&&(t.validators=[]),t.validators.push(Yk(r,e))},sC=(e,t,r,n)=>{const a=Object.entries(e),s=a.length;for(let i=0;i<s;i++){const[l,c]=a[i];jl(c,Oh(t,l),r,n)}},Oh=(e,t)=>{let r=e;const n=t.split(ro),a=n.length;for(let s=0;s<a;s++){const i=n[s];let l=r.nextPart.get(i);l||(l=Ph(),r.nextPart.set(i,l)),r=l}return r},iC=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,lC=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=Object.create(null),n=Object.create(null);const a=(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 a(s,i),i},set(s,i){s in r?r[s]=i:a(s,i)}}},di="!",ld=":",cC=[],cd=(e,t,r,n,a)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:n,isExternal:a}),dC=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=a=>{const s=[];let i=0,l=0,c=0,d;const u=a.length;for(let h=0;h<u;h++){const x=a[h];if(i===0&&l===0){if(x===ld){s.push(a.slice(c,h)),c=h+1;continue}if(x==="/"){d=h;continue}}x==="["?i++:x==="]"?i--:x==="("?l++:x===")"&&l--}const m=s.length===0?a:a.slice(c);let p=m,f=!1;m.endsWith(di)?(p=m.slice(0,-1),f=!0):m.startsWith(di)&&(p=m.slice(1),f=!0);const b=d&&d>c?d-c:void 0;return cd(s,f,p,b)};if(t){const a=t+ld,s=n;n=i=>i.startsWith(a)?s(i.slice(a.length)):cd(cC,!1,i,void 0,!0)}if(r){const a=n;n=s=>r({className:s,parseClassName:a})}return n},uC=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((r,n)=>{t.set(r,1e6+n)}),r=>{const n=[];let a=[];for(let s=0;s<r.length;s++){const i=r[s],l=i[0]==="[",c=t.has(i);l||c?(a.length>0&&(a.sort(),n.push(...a),a=[]),n.push(i)):a.push(i)}return a.length>0&&(a.sort(),n.push(...a)),n}},mC=e=>({cache:lC(e.cacheSize),parseClassName:dC(e),sortModifiers:uC(e),...Qk(e)}),pC=/\s+/,fC=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a,sortModifiers:s}=t,i=[],l=e.trim().split(pC);let c="";for(let d=l.length-1;d>=0;d-=1){const u=l[d],{isExternal:m,modifiers:p,hasImportantModifier:f,baseClassName:b,maybePostfixModifierPosition:h}=r(u);if(m){c=u+(c.length>0?" "+c:c);continue}let x=!!h,y=n(x?b.substring(0,h):b);if(!y){if(!x){c=u+(c.length>0?" "+c:c);continue}if(y=n(b),!y){c=u+(c.length>0?" "+c:c);continue}x=!1}const v=p.length===0?"":p.length===1?p[0]:s(p).join(":"),j=f?v+di:v,w=j+y;if(i.indexOf(w)>-1)continue;i.push(w);const C=a(y,x);for(let S=0;S<C.length;++S){const $=C[S];i.push(j+$)}c=u+(c.length>0?" "+c:c)}return c},hC=(...e)=>{let t=0,r,n,a="";for(;t<e.length;)(r=e[t++])&&(n=Fh(r))&&(a&&(a+=" "),a+=n);return a},Fh=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=Fh(e[n]))&&(r&&(r+=" "),r+=t);return r},xC=(e,...t)=>{let r,n,a,s;const i=c=>{const d=t.reduce((u,m)=>m(u),e());return r=mC(d),n=r.cache.get,a=r.cache.set,s=l,l(c)},l=c=>{const d=n(c);if(d)return d;const u=fC(c,r);return a(c,u),u};return s=i,(...c)=>s(hC(...c))},gC=[],nt=e=>{const t=r=>r[e]||gC;return t.isThemeGetter=!0,t},zh=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Lh=/^\((?:(\w[\w-]*):)?(.+)\)$/i,vC=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,bC=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,yC=/\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$/,wC=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,jC=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,kC=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Er=e=>vC.test(e),Se=e=>!!e&&!Number.isNaN(Number(e)),Dr=e=>!!e&&Number.isInteger(Number(e)),Ss=e=>e.endsWith("%")&&Se(e.slice(0,-1)),xr=e=>bC.test(e),Mh=()=>!0,CC=e=>yC.test(e)&&!wC.test(e),kl=()=>!1,NC=e=>jC.test(e),SC=e=>kC.test(e),$C=e=>!fe(e)&&!xe(e),EC=e=>Ur(e,Uh,kl),fe=e=>zh.test(e),Xr=e=>Ur(e,Hh,CC),dd=e=>Ur(e,OC,Se),DC=e=>Ur(e,qh,Mh),TC=e=>Ur(e,Wh,kl),ud=e=>Ur(e,Vh,kl),AC=e=>Ur(e,Bh,SC),Ia=e=>Ur(e,Gh,NC),xe=e=>Lh.test(e),qn=e=>on(e,Hh),RC=e=>on(e,Wh),md=e=>on(e,Vh),IC=e=>on(e,Uh),PC=e=>on(e,Bh),Pa=e=>on(e,Gh,!0),_C=e=>on(e,qh,!0),Ur=(e,t,r)=>{const n=zh.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},on=(e,t,r=!1)=>{const n=Lh.exec(e);return n?n[1]?t(n[1]):r:!1},Vh=e=>e==="position"||e==="percentage",Bh=e=>e==="image"||e==="url",Uh=e=>e==="length"||e==="size"||e==="bg-size",Hh=e=>e==="length",OC=e=>e==="number",Wh=e=>e==="family-name",qh=e=>e==="number"||e==="weight",Gh=e=>e==="shadow",FC=()=>{const e=nt("color"),t=nt("font"),r=nt("text"),n=nt("font-weight"),a=nt("tracking"),s=nt("leading"),i=nt("breakpoint"),l=nt("container"),c=nt("spacing"),d=nt("radius"),u=nt("shadow"),m=nt("inset-shadow"),p=nt("text-shadow"),f=nt("drop-shadow"),b=nt("blur"),h=nt("perspective"),x=nt("aspect"),y=nt("ease"),v=nt("animate"),j=()=>["auto","avoid","all","avoid-page","page","left","right","column"],w=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],C=()=>[...w(),xe,fe],S=()=>["auto","hidden","clip","visible","scroll"],$=()=>["auto","contain","none"],k=()=>[xe,fe,c],E=()=>[Er,"full","auto",...k()],D=()=>[Dr,"none","subgrid",xe,fe],O=()=>["auto",{span:["full",Dr,xe,fe]},Dr,xe,fe],L=()=>[Dr,"auto",xe,fe],A=()=>["auto","min","max","fr",xe,fe],z=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],X=()=>["start","end","center","stretch","center-safe","end-safe"],q=()=>["auto",...k()],Z=()=>[Er,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...k()],V=()=>[Er,"screen","full","dvw","lvw","svw","min","max","fit",...k()],M=()=>[Er,"screen","full","lh","dvh","lvh","svh","min","max","fit",...k()],P=()=>[e,xe,fe],se=()=>[...w(),md,ud,{position:[xe,fe]}],U=()=>["no-repeat",{repeat:["","x","y","space","round"]}],Q=()=>["auto","cover","contain",IC,EC,{size:[xe,fe]}],Y=()=>[Ss,qn,Xr],H=()=>["","none","full",d,xe,fe],W=()=>["",Se,qn,Xr],G=()=>["solid","dashed","dotted","double"],ne=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],J=()=>[Se,Ss,md,ud],te=()=>["","none",b,xe,fe],ce=()=>["none",Se,xe,fe],be=()=>["none",Se,xe,fe],Ce=()=>[Se,xe,fe],ve=()=>[Er,"full",...k()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[xr],breakpoint:[xr],color:[Mh],container:[xr],"drop-shadow":[xr],ease:["in","out","in-out"],font:[$C],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[xr],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[xr],shadow:[xr],spacing:["px",Se],text:[xr],"text-shadow":[xr],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Er,fe,xe,x]}],container:["container"],columns:[{columns:[Se,fe,xe,l]}],"break-after":[{"break-after":j()}],"break-before":[{"break-before":j()}],"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:C()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:$()}],"overscroll-x":[{"overscroll-x":$()}],"overscroll-y":[{"overscroll-y":$()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:E()}],"inset-x":[{"inset-x":E()}],"inset-y":[{"inset-y":E()}],start:[{"inset-s":E(),start:E()}],end:[{"inset-e":E(),end:E()}],"inset-bs":[{"inset-bs":E()}],"inset-be":[{"inset-be":E()}],top:[{top:E()}],right:[{right:E()}],bottom:[{bottom:E()}],left:[{left:E()}],visibility:["visible","invisible","collapse"],z:[{z:[Dr,"auto",xe,fe]}],basis:[{basis:[Er,"full","auto",l,...k()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Se,Er,"auto","initial","none",fe]}],grow:[{grow:["",Se,xe,fe]}],shrink:[{shrink:["",Se,xe,fe]}],order:[{order:[Dr,"first","last","none",xe,fe]}],"grid-cols":[{"grid-cols":D()}],"col-start-end":[{col:O()}],"col-start":[{"col-start":L()}],"col-end":[{"col-end":L()}],"grid-rows":[{"grid-rows":D()}],"row-start-end":[{row:O()}],"row-start":[{"row-start":L()}],"row-end":[{"row-end":L()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":A()}],"auto-rows":[{"auto-rows":A()}],gap:[{gap:k()}],"gap-x":[{"gap-x":k()}],"gap-y":[{"gap-y":k()}],"justify-content":[{justify:[...z(),"normal"]}],"justify-items":[{"justify-items":[...X(),"normal"]}],"justify-self":[{"justify-self":["auto",...X()]}],"align-content":[{content:["normal",...z()]}],"align-items":[{items:[...X(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...X(),{baseline:["","last"]}]}],"place-content":[{"place-content":z()}],"place-items":[{"place-items":[...X(),"baseline"]}],"place-self":[{"place-self":["auto",...X()]}],p:[{p:k()}],px:[{px:k()}],py:[{py:k()}],ps:[{ps:k()}],pe:[{pe:k()}],pbs:[{pbs:k()}],pbe:[{pbe:k()}],pt:[{pt:k()}],pr:[{pr:k()}],pb:[{pb:k()}],pl:[{pl:k()}],m:[{m:q()}],mx:[{mx:q()}],my:[{my:q()}],ms:[{ms:q()}],me:[{me:q()}],mbs:[{mbs:q()}],mbe:[{mbe:q()}],mt:[{mt:q()}],mr:[{mr:q()}],mb:[{mb:q()}],ml:[{ml:q()}],"space-x":[{"space-x":k()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":k()}],"space-y-reverse":["space-y-reverse"],size:[{size:Z()}],"inline-size":[{inline:["auto",...V()]}],"min-inline-size":[{"min-inline":["auto",...V()]}],"max-inline-size":[{"max-inline":["none",...V()]}],"block-size":[{block:["auto",...M()]}],"min-block-size":[{"min-block":["auto",...M()]}],"max-block-size":[{"max-block":["none",...M()]}],w:[{w:[l,"screen",...Z()]}],"min-w":[{"min-w":[l,"screen","none",...Z()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[i]},...Z()]}],h:[{h:["screen","lh",...Z()]}],"min-h":[{"min-h":["screen","lh","none",...Z()]}],"max-h":[{"max-h":["screen","lh",...Z()]}],"font-size":[{text:["base",r,qn,Xr]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,_C,DC]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ss,fe]}],"font-family":[{font:[RC,TC,t]}],"font-features":[{"font-features":[fe]}],"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:[a,xe,fe]}],"line-clamp":[{"line-clamp":[Se,"none",xe,dd]}],leading:[{leading:[s,...k()]}],"list-image":[{"list-image":["none",xe,fe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",xe,fe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:P()}],"text-color":[{text:P()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...G(),"wavy"]}],"text-decoration-thickness":[{decoration:[Se,"from-font","auto",xe,Xr]}],"text-decoration-color":[{decoration:P()}],"underline-offset":[{"underline-offset":[Se,"auto",xe,fe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:k()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",xe,fe]}],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",xe,fe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:se()}],"bg-repeat":[{bg:U()}],"bg-size":[{bg:Q()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Dr,xe,fe],radial:["",xe,fe],conic:[Dr,xe,fe]},PC,AC]}],"bg-color":[{bg:P()}],"gradient-from-pos":[{from:Y()}],"gradient-via-pos":[{via:Y()}],"gradient-to-pos":[{to:Y()}],"gradient-from":[{from:P()}],"gradient-via":[{via:P()}],"gradient-to":[{to:P()}],rounded:[{rounded:H()}],"rounded-s":[{"rounded-s":H()}],"rounded-e":[{"rounded-e":H()}],"rounded-t":[{"rounded-t":H()}],"rounded-r":[{"rounded-r":H()}],"rounded-b":[{"rounded-b":H()}],"rounded-l":[{"rounded-l":H()}],"rounded-ss":[{"rounded-ss":H()}],"rounded-se":[{"rounded-se":H()}],"rounded-ee":[{"rounded-ee":H()}],"rounded-es":[{"rounded-es":H()}],"rounded-tl":[{"rounded-tl":H()}],"rounded-tr":[{"rounded-tr":H()}],"rounded-br":[{"rounded-br":H()}],"rounded-bl":[{"rounded-bl":H()}],"border-w":[{border:W()}],"border-w-x":[{"border-x":W()}],"border-w-y":[{"border-y":W()}],"border-w-s":[{"border-s":W()}],"border-w-e":[{"border-e":W()}],"border-w-bs":[{"border-bs":W()}],"border-w-be":[{"border-be":W()}],"border-w-t":[{"border-t":W()}],"border-w-r":[{"border-r":W()}],"border-w-b":[{"border-b":W()}],"border-w-l":[{"border-l":W()}],"divide-x":[{"divide-x":W()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":W()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...G(),"hidden","none"]}],"divide-style":[{divide:[...G(),"hidden","none"]}],"border-color":[{border:P()}],"border-color-x":[{"border-x":P()}],"border-color-y":[{"border-y":P()}],"border-color-s":[{"border-s":P()}],"border-color-e":[{"border-e":P()}],"border-color-bs":[{"border-bs":P()}],"border-color-be":[{"border-be":P()}],"border-color-t":[{"border-t":P()}],"border-color-r":[{"border-r":P()}],"border-color-b":[{"border-b":P()}],"border-color-l":[{"border-l":P()}],"divide-color":[{divide:P()}],"outline-style":[{outline:[...G(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Se,xe,fe]}],"outline-w":[{outline:["",Se,qn,Xr]}],"outline-color":[{outline:P()}],shadow:[{shadow:["","none",u,Pa,Ia]}],"shadow-color":[{shadow:P()}],"inset-shadow":[{"inset-shadow":["none",m,Pa,Ia]}],"inset-shadow-color":[{"inset-shadow":P()}],"ring-w":[{ring:W()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:P()}],"ring-offset-w":[{"ring-offset":[Se,Xr]}],"ring-offset-color":[{"ring-offset":P()}],"inset-ring-w":[{"inset-ring":W()}],"inset-ring-color":[{"inset-ring":P()}],"text-shadow":[{"text-shadow":["none",p,Pa,Ia]}],"text-shadow-color":[{"text-shadow":P()}],opacity:[{opacity:[Se,xe,fe]}],"mix-blend":[{"mix-blend":[...ne(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ne()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Se]}],"mask-image-linear-from-pos":[{"mask-linear-from":J()}],"mask-image-linear-to-pos":[{"mask-linear-to":J()}],"mask-image-linear-from-color":[{"mask-linear-from":P()}],"mask-image-linear-to-color":[{"mask-linear-to":P()}],"mask-image-t-from-pos":[{"mask-t-from":J()}],"mask-image-t-to-pos":[{"mask-t-to":J()}],"mask-image-t-from-color":[{"mask-t-from":P()}],"mask-image-t-to-color":[{"mask-t-to":P()}],"mask-image-r-from-pos":[{"mask-r-from":J()}],"mask-image-r-to-pos":[{"mask-r-to":J()}],"mask-image-r-from-color":[{"mask-r-from":P()}],"mask-image-r-to-color":[{"mask-r-to":P()}],"mask-image-b-from-pos":[{"mask-b-from":J()}],"mask-image-b-to-pos":[{"mask-b-to":J()}],"mask-image-b-from-color":[{"mask-b-from":P()}],"mask-image-b-to-color":[{"mask-b-to":P()}],"mask-image-l-from-pos":[{"mask-l-from":J()}],"mask-image-l-to-pos":[{"mask-l-to":J()}],"mask-image-l-from-color":[{"mask-l-from":P()}],"mask-image-l-to-color":[{"mask-l-to":P()}],"mask-image-x-from-pos":[{"mask-x-from":J()}],"mask-image-x-to-pos":[{"mask-x-to":J()}],"mask-image-x-from-color":[{"mask-x-from":P()}],"mask-image-x-to-color":[{"mask-x-to":P()}],"mask-image-y-from-pos":[{"mask-y-from":J()}],"mask-image-y-to-pos":[{"mask-y-to":J()}],"mask-image-y-from-color":[{"mask-y-from":P()}],"mask-image-y-to-color":[{"mask-y-to":P()}],"mask-image-radial":[{"mask-radial":[xe,fe]}],"mask-image-radial-from-pos":[{"mask-radial-from":J()}],"mask-image-radial-to-pos":[{"mask-radial-to":J()}],"mask-image-radial-from-color":[{"mask-radial-from":P()}],"mask-image-radial-to-color":[{"mask-radial-to":P()}],"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":w()}],"mask-image-conic-pos":[{"mask-conic":[Se]}],"mask-image-conic-from-pos":[{"mask-conic-from":J()}],"mask-image-conic-to-pos":[{"mask-conic-to":J()}],"mask-image-conic-from-color":[{"mask-conic-from":P()}],"mask-image-conic-to-color":[{"mask-conic-to":P()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:se()}],"mask-repeat":[{mask:U()}],"mask-size":[{mask:Q()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",xe,fe]}],filter:[{filter:["","none",xe,fe]}],blur:[{blur:te()}],brightness:[{brightness:[Se,xe,fe]}],contrast:[{contrast:[Se,xe,fe]}],"drop-shadow":[{"drop-shadow":["","none",f,Pa,Ia]}],"drop-shadow-color":[{"drop-shadow":P()}],grayscale:[{grayscale:["",Se,xe,fe]}],"hue-rotate":[{"hue-rotate":[Se,xe,fe]}],invert:[{invert:["",Se,xe,fe]}],saturate:[{saturate:[Se,xe,fe]}],sepia:[{sepia:["",Se,xe,fe]}],"backdrop-filter":[{"backdrop-filter":["","none",xe,fe]}],"backdrop-blur":[{"backdrop-blur":te()}],"backdrop-brightness":[{"backdrop-brightness":[Se,xe,fe]}],"backdrop-contrast":[{"backdrop-contrast":[Se,xe,fe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Se,xe,fe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Se,xe,fe]}],"backdrop-invert":[{"backdrop-invert":["",Se,xe,fe]}],"backdrop-opacity":[{"backdrop-opacity":[Se,xe,fe]}],"backdrop-saturate":[{"backdrop-saturate":[Se,xe,fe]}],"backdrop-sepia":[{"backdrop-sepia":["",Se,xe,fe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":k()}],"border-spacing-x":[{"border-spacing-x":k()}],"border-spacing-y":[{"border-spacing-y":k()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",xe,fe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Se,"initial",xe,fe]}],ease:[{ease:["linear","initial",y,xe,fe]}],delay:[{delay:[Se,xe,fe]}],animate:[{animate:["none",v,xe,fe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[h,xe,fe]}],"perspective-origin":[{"perspective-origin":C()}],rotate:[{rotate:ce()}],"rotate-x":[{"rotate-x":ce()}],"rotate-y":[{"rotate-y":ce()}],"rotate-z":[{"rotate-z":ce()}],scale:[{scale:be()}],"scale-x":[{"scale-x":be()}],"scale-y":[{"scale-y":be()}],"scale-z":[{"scale-z":be()}],"scale-3d":["scale-3d"],skew:[{skew:Ce()}],"skew-x":[{"skew-x":Ce()}],"skew-y":[{"skew-y":Ce()}],transform:[{transform:[xe,fe,"","none","gpu","cpu"]}],"transform-origin":[{origin:C()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ve()}],"translate-x":[{"translate-x":ve()}],"translate-y":[{"translate-y":ve()}],"translate-z":[{"translate-z":ve()}],"translate-none":["translate-none"],accent:[{accent:P()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:P()}],"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",xe,fe]}],"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":k()}],"scroll-mx":[{"scroll-mx":k()}],"scroll-my":[{"scroll-my":k()}],"scroll-ms":[{"scroll-ms":k()}],"scroll-me":[{"scroll-me":k()}],"scroll-mbs":[{"scroll-mbs":k()}],"scroll-mbe":[{"scroll-mbe":k()}],"scroll-mt":[{"scroll-mt":k()}],"scroll-mr":[{"scroll-mr":k()}],"scroll-mb":[{"scroll-mb":k()}],"scroll-ml":[{"scroll-ml":k()}],"scroll-p":[{"scroll-p":k()}],"scroll-px":[{"scroll-px":k()}],"scroll-py":[{"scroll-py":k()}],"scroll-ps":[{"scroll-ps":k()}],"scroll-pe":[{"scroll-pe":k()}],"scroll-pbs":[{"scroll-pbs":k()}],"scroll-pbe":[{"scroll-pbe":k()}],"scroll-pt":[{"scroll-pt":k()}],"scroll-pr":[{"scroll-pr":k()}],"scroll-pb":[{"scroll-pb":k()}],"scroll-pl":[{"scroll-pl":k()}],"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",xe,fe]}],fill:[{fill:["none",...P()]}],"stroke-w":[{stroke:[Se,qn,Xr,dd]}],stroke:[{stroke:["none",...P()]}],"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"]}},zC=xC(FC);function Ht(...e){return zC(Zk(e))}const yr=({onInsert:e})=>{const[t,r]=N.useState(null),n=async a=>{const s=`{{${a}}}`;try{await navigator.clipboard.writeText(s)}catch{const i=document.createElement("textarea");i.value=s,i.style.position="fixed",i.style.opacity="0",document.body.appendChild(i),i.select(),document.execCommand("copy"),document.body.removeChild(i)}e&&e(s),r(a),setTimeout(()=>r(null),1500)};return o.jsxs(Po,{children:[o.jsx(_o,{asChild:!0,children:o.jsx(De,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 text-muted-foreground hover:text-primary",title:"Inserir variável do evento",children:o.jsx(_.Braces,{className:"h-3.5 w-3.5"})})}),o.jsxs(fa,{className:"w-80 p-0",align:"end",side:"left",sideOffset:6,children:[o.jsxs("div",{className:"px-3 py-2 border-b border-border",children:[o.jsx("p",{className:"text-xs font-semibold text-foreground",children:"Variáveis do evento"}),o.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Clique para copiar. Use"," ",o.jsx("code",{className:"bg-muted px-1 rounded text-[10px]",children:"{{evento.xxx}}"})," ","em labels, placeholders e hints."]})]}),o.jsx("div",{className:"max-h-64 overflow-y-auto py-1",children:bl.map(a=>{const s=t===a.key;return o.jsxs("button",{type:"button",onClick:()=>n(a.key),className:Ht("w-full flex items-center justify-between px-3 py-1.5 text-left hover:bg-accent transition-colors",s&&"bg-primary/10"),children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx("p",{className:"text-xs font-medium truncate",children:a.label}),o.jsx("code",{className:"text-[10px] text-muted-foreground font-mono",children:`{{${a.key}}}`})]}),o.jsx("div",{className:"ml-2 shrink-0",children:s?o.jsx(_.Check,{className:"h-3.5 w-3.5 text-primary"}):o.jsx(_.Braces,{className:"h-3 w-3 text-muted-foreground/50"})})]},a.key)})})]})]})},LC=({config:e,onUpdate:t})=>o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(ie,{className:"text-xs",children:"Label"}),o.jsx(yr,{})]}),o.jsx(ue,{value:e.label,onChange:r=>t({label:r.target.value}),className:"h-8 text-sm"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(ie,{className:"text-xs",children:"Descrição"}),o.jsx(yr,{})]}),o.jsx(ue,{value:e.description||"",onChange:r=>t({description:r.target.value}),className:"h-8 text-sm",placeholder:"Descrição do step"})]}),o.jsx(Jf,{value:e.icone,onChange:r=>t({icone:r})}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(et,{id:"step-show-label",checked:e.showLabel!==!1,onCheckedChange:r=>t({showLabel:r===!0})}),o.jsx(ie,{htmlFor:"step-show-label",className:"text-xs cursor-pointer",children:"Exibir título no formulário"})]})]}),MC=({inicioColuna:e,tamanho:t,onSelect:r})=>o.jsxs("div",{className:"space-y-2",children:[o.jsx(ie,{className:"text-xs",children:"Posição no grid"}),o.jsx("div",{className:"flex gap-0.5",children:Array.from({length:12},(n,a)=>{const s=a+1,i=s>=e&&s<e+t;return o.jsx("button",{onClick:()=>r(s),className:Ht("flex-1 h-6 rounded-sm text-[8px] font-mono transition-all border",i?"bg-primary text-primary-foreground border-primary":"bg-muted/50 text-muted-foreground/50 border-border/50 hover:bg-muted hover:border-border"),children:s},s)})}),o.jsxs("p",{className:"text-[9px] text-muted-foreground",children:["Início: col ",e," · Span: ",t]})]}),Xh=({tamanho:e,inicioColuna:t,defaultTamanho:r=6,onTamanhoChange:n,onPositionChange:a})=>{const s=13-t;return o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsxs(ie,{className:"text-xs",children:["Tamanho (",e,"/12 colunas)"]}),o.jsx(Ao,{value:[e],onValueChange:([i])=>{const l=Math.min(i,s);n(l)},min:1,max:s,step:1,className:"py-1"}),o.jsxs("div",{className:"flex justify-between text-[9px] text-muted-foreground",children:[o.jsx("span",{children:"1"}),o.jsx("span",{children:"3"}),o.jsx("span",{children:"6"}),o.jsx("span",{children:"9"}),o.jsx("span",{children:"12"})]})]}),o.jsx(MC,{inicioColuna:t,tamanho:e,onSelect:i=>{const l=13-i,c=Math.min(e,l);a(i),c!==e&&n(c)}})]})},VC=({config:e,onUpdate:t})=>o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(ie,{className:"text-xs",children:"Label"}),o.jsx(yr,{})]}),o.jsx(ue,{value:e.label,onChange:r=>t({label:r.target.value}),className:"h-8 text-sm"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(ie,{className:"text-xs",children:"Descrição"}),o.jsx(yr,{})]}),o.jsx(ue,{value:e.description||"",onChange:r=>t({description:r.target.value}),className:"h-8 text-sm",placeholder:"Descrição do container"})]}),o.jsx(Jf,{value:e.icone,onChange:r=>t({icone:r})}),o.jsx(Xh,{tamanho:e.tamanho||12,inicioColuna:e.inicioColuna||1,defaultTamanho:12,onTamanhoChange:r=>t({tamanho:r}),onPositionChange:r=>t({inicioColuna:r})}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Colunas internas"}),o.jsxs(Bt,{value:String(e.columns||2),onValueChange:r=>t({columns:Number(r)}),children:[o.jsx(Rt,{className:"h-8 text-sm",children:o.jsx(Ut,{})}),o.jsxs(It,{children:[o.jsx(qe,{value:"1",children:"1 coluna"}),o.jsx(qe,{value:"2",children:"2 colunas"}),o.jsx(qe,{value:"3",children:"3 colunas"}),o.jsx(qe,{value:"4",children:"4 colunas"})]})]}),o.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Grid interno simplificado para campos"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(et,{id:"show-label",checked:e.showLabel!==!1,onCheckedChange:r=>t({showLabel:r===!0})}),o.jsx(ie,{htmlFor:"show-label",className:"text-xs cursor-pointer",children:"Exibir label no formulário"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(et,{id:"show-as-card",checked:e.showAsCard||!1,onCheckedChange:r=>t({showAsCard:r===!0})}),o.jsx(ie,{htmlFor:"show-as-card",className:"text-xs cursor-pointer",children:"Exibir como card"})]})]}),ui=[{category:"Texto básico",presets:[{pattern:"^[A-Za-z]+$",label:"Apenas letras",description:"Aceita somente letras de A-Z (maiúsculas e minúsculas), sem espaços, números ou especiais."},{pattern:"^[a-z]+$",label:"Apenas minúsculas",description:"Aceita somente letras minúsculas de a-z."},{pattern:"^[A-Z]+$",label:"Apenas maiúsculas",description:"Aceita somente letras maiúsculas de A-Z."},{pattern:"^[A-Za-zÀ-ÿ]+$",label:"Letras com acentos",description:"Aceita letras incluindo acentuadas (é, ã, ü, etc.)."},{pattern:"^[A-Za-zÀ-ÿ\\s]+$",label:"Letras, acentos e espaços",description:"Aceita letras com acentos e espaços — ideal para nomes completos."},{pattern:"^[A-Za-z0-9]+$",label:"Alfanumérico",description:"Apenas letras e números, sem espaços ou caracteres especiais."},{pattern:"^[A-Za-z0-9\\s]+$",label:"Alfanumérico com espaços",description:"Letras, números e espaços."},{pattern:"^[A-Za-z0-9_]+$",label:"Alfanumérico + underscore",description:"Letras, números e underscore (_). Padrão para usernames."},{pattern:"^[A-Za-z0-9_-]+$",label:"Slug-friendly",description:"Letras, números, underscore e hífen. Ideal para slugs de URL."},{pattern:"^\\S+$",label:"Sem espaços",description:"Aceita qualquer caractere exceto espaços em branco."},{pattern:"^.{1,}$",label:"Não vazio",description:"Exige pelo menos 1 caractere (qualquer um)."}]},{category:"Números",presets:[{pattern:"^[0-9]+$",label:"Apenas dígitos",description:"Aceita somente dígitos numéricos (0-9)."},{pattern:"^-?[0-9]+$",label:"Inteiro (com negativo)",description:"Número inteiro, opcionalmente negativo."},{pattern:"^[0-9]+\\.?[0-9]*$",label:"Decimal positivo",description:"Número decimal positivo (ex: 3.14, 42)."},{pattern:"^-?[0-9]+\\.?[0-9]*$",label:"Decimal (com negativo)",description:"Número decimal, opcionalmente negativo."},{pattern:"^\\d{1,3}(\\.\\d{3})*(,\\d{2})?$",label:"Formato BR (1.234,56)",description:"Número no formato brasileiro com pontos de milhar e vírgula decimal."},{pattern:"^\\d{1,3}(,\\d{3})*(\\.\\d{2})?$",label:"Formato US (1,234.56)",description:"Número no formato americano com vírgulas de milhar e ponto decimal."},{pattern:"^[01]+$",label:"Binário",description:"Aceita apenas 0 e 1 — representação binária."},{pattern:"^[0-9A-Fa-f]+$",label:"Hexadecimal",description:"Aceita dígitos hexadecimais (0-9, A-F)."},{pattern:"^0[xX][0-9A-Fa-f]+$",label:"Hex com prefixo 0x",description:"Hexadecimal com prefixo 0x (ex: 0xFF)."},{pattern:"^[0-7]+$",label:"Octal",description:"Aceita apenas dígitos octais (0-7)."},{pattern:"^\\d+(\\.\\d{1,2})?$",label:"Monetário (2 casas)",description:"Número com até 2 casas decimais — ideal para valores monetários."},{pattern:"^\\d+(\\.\\d{1,4})?$",label:"Até 4 casas decimais",description:"Número com até 4 casas decimais."}]},{category:"Documentos BR",presets:[{pattern:"^\\d{3}\\.\\d{3}\\.\\d{3}-\\d{2}$",label:"CPF (com máscara)",description:"CPF formatado: 123.456.789-00."},{pattern:"^\\d{11}$",label:"CPF (sem máscara)",description:"CPF apenas dígitos: 12345678900."},{pattern:"^\\d{2}\\.\\d{3}\\.\\d{3}/\\d{4}-\\d{2}$",label:"CNPJ (com máscara)",description:"CNPJ formatado: 12.345.678/0001-00."},{pattern:"^\\d{14}$",label:"CNPJ (sem máscara)",description:"CNPJ apenas dígitos: 12345678000100."},{pattern:"^\\d{5}-?\\d{3}$",label:"CEP",description:"CEP brasileiro: 12345-678 ou 12345678."},{pattern:"^\\d{1,2}\\.\\d{3}\\.\\d{3}[-]?\\d{1}$",label:"RG (formato comum)",description:"RG no formato mais comum: 1.234.567-8."},{pattern:"^\\d{11}$",label:"PIS/PASEP",description:"PIS/PASEP com 11 dígitos."},{pattern:"^\\d{3}\\.?\\d{7}-?\\d{1}$",label:"Título de eleitor",description:"Título de eleitor com 12 dígitos."},{pattern:"^[A-Z]{2}\\d{7}$",label:"Passaporte BR",description:"Passaporte brasileiro: 2 letras + 7 dígitos (ex: AB1234567)."},{pattern:"^\\d{11}$",label:"CNH (registro)",description:"Número de registro da CNH: 11 dígitos."},{pattern:"^\\d{10}$",label:"Certidão (matrícula)",description:"Matrícula de certidão de nascimento/casamento."},{pattern:"^\\d{3}\\.\\d{3}\\.\\d{3}-\\d{2}$|^\\d{2}\\.\\d{3}\\.\\d{3}/\\d{4}-\\d{2}$",label:"CPF ou CNPJ",description:"Aceita CPF (123.456.789-00) ou CNPJ (12.345.678/0001-00)."}]},{category:"Contato",presets:[{pattern:"^[\\w.-]+@[\\w.-]+\\.[A-Za-z]{2,}$",label:"E-mail simples",description:"Validação básica de e-mail: usuario@dominio.com."},{pattern:"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$",label:"E-mail completo",description:"E-mail com mais caracteres aceitos no usuário."},{pattern:"^\\(\\d{2}\\)\\s?\\d{4,5}-\\d{4}$",label:"Telefone BR (com máscara)",description:"Telefone formatado: (11) 91234-5678 ou (11) 1234-5678."},{pattern:"^\\d{10,11}$",label:"Telefone BR (sem máscara)",description:"Telefone apenas dígitos: 11912345678."},{pattern:"^\\+\\d{1,3}\\s?\\d{2,3}\\s?\\d{4,5}[-]?\\d{4}$",label:"Telefone internacional",description:"Formato +55 11 91234-5678."},{pattern:"^\\+55\\d{10,11}$",label:"Celular BR (+55)",description:"Celular brasileiro com DDI: +5511912345678."},{pattern:"^\\d{4,5}-\\d{4}$",label:"Telefone (sem DDD)",description:"Número local: 1234-5678 ou 91234-5678."},{pattern:"^0800\\d{6,7}$",label:"0800",description:"Número 0800 (SAC): 0800XXXXXXX."}]},{category:"Internet / URLs",presets:[{pattern:"^https?://[\\w.-]+(:\\d+)?(/[\\w./-]*)*$",label:"URL HTTP/HTTPS",description:"URL completa com protocolo http ou https."},{pattern:"^(https?://)?[\\w.-]+\\.[A-Za-z]{2,}(/.*)?$",label:"URL (protocolo opcional)",description:"URL com ou sem http:// na frente."},{pattern:"^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*\\.[a-z]{2,}$",label:"Domínio",description:"Nome de domínio válido: exemplo.com.br."},{pattern:"^((25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)$",label:"IPv4",description:"Endereço IPv4: 192.168.0.1."},{pattern:"^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$",label:"IPv6 (completo)",description:"Endereço IPv6 completo."},{pattern:"^[a-z][a-z0-9-]*$",label:"Subdomínio",description:"Nome de subdomínio válido (letra inicial, alfanumérico + hífen)."},{pattern:"^[A-Za-z][A-Za-z0-9+.-]*://.*$",label:"URI genérica",description:"Qualquer URI com esquema (ftp://, mailto:, tel:, etc.)."},{pattern:"^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$",label:"Cor hex (#FFF)",description:"Código de cor hexadecimal: #FFF ou #FFFFFF."},{pattern:"^#[0-9A-Fa-f]{8}$",label:"Cor hex com alpha",description:"Cor hexadecimal com canal alpha: #FFFFFFFF."},{pattern:"^rgb\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*\\)$",label:"Cor RGB",description:"Cor no formato rgb(255, 0, 0)."}]},{category:"Data e hora",presets:[{pattern:"^\\d{2}/\\d{2}/\\d{4}$",label:"Data DD/MM/AAAA",description:"Data no formato brasileiro: 25/12/2024."},{pattern:"^\\d{4}-\\d{2}-\\d{2}$",label:"Data ISO (AAAA-MM-DD)",description:"Data no formato ISO 8601: 2024-12-25."},{pattern:"^\\d{2}/\\d{2}/\\d{2}$",label:"Data DD/MM/AA",description:"Data com ano de 2 dígitos: 25/12/24."},{pattern:"^\\d{2}-\\d{2}-\\d{4}$",label:"Data DD-MM-AAAA",description:"Data com hífens: 25-12-2024."},{pattern:"^\\d{2}:\\d{2}$",label:"Hora HH:MM",description:"Horário 24h: 14:30."},{pattern:"^\\d{2}:\\d{2}:\\d{2}$",label:"Hora HH:MM:SS",description:"Horário com segundos: 14:30:59."},{pattern:"^(0[1-9]|1[0-2])/\\d{4}$",label:"Mês/Ano (MM/AAAA)",description:"Mês e ano: 12/2024."},{pattern:"^\\d{4}$",label:"Ano (4 dígitos)",description:"Ano com 4 dígitos: 2024."},{pattern:"^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}$",label:"DateTime ISO (sem seg)",description:"Data e hora ISO: 2024-12-25T14:30."},{pattern:"^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}$",label:"DateTime ISO (com seg)",description:"Data e hora ISO com segundos."},{pattern:"^\\d{2}/\\d{2}/\\d{4}\\s\\d{2}:\\d{2}$",label:"DateTime BR",description:"Data e hora BR: 25/12/2024 14:30."}]},{category:"Senhas",presets:[{pattern:"^.{6,}$",label:"Mín. 6 caracteres",description:"Exige no mínimo 6 caracteres (qualquer tipo)."},{pattern:"^.{8,}$",label:"Mín. 8 caracteres",description:"Exige no mínimo 8 caracteres."},{pattern:"^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d).{8,}$",label:"Forte (letra+número)",description:"Mín. 8 chars com pelo menos 1 maiúscula, 1 minúscula e 1 número."},{pattern:"^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[!@#$%^&*]).{8,}$",label:"Muito forte",description:"Mín. 8 chars com maiúscula, minúscula, número e caractere especial."},{pattern:"^(?=.*[A-Z])(?=.*\\d).{6,}$",label:"Média (maiúsc+número)",description:"Mín. 6 chars com pelo menos 1 maiúscula e 1 número."},{pattern:"^(?!.*\\s).{8,}$",label:"Sem espaços (mín. 8)",description:"Mín. 8 caracteres, sem espaços."}]},{category:"Nomes e texto formatado",presets:[{pattern:"^[A-Za-zÀ-ÿ]{2,}(\\s[A-Za-zÀ-ÿ]{2,})+$",label:"Nome completo",description:"Nome e sobrenome (mínimo 2 palavras, cada com 2+ letras)."},{pattern:"^[A-Za-zÀ-ÿ]{2,}$",label:"Primeiro nome",description:"Apenas o primeiro nome (mínimo 2 letras, com acentos)."},{pattern:"^[A-Za-zÀ-ÿ'\\-\\s]+$",label:"Nome com apóstrofo/hífen",description:"Nome que aceita D'Silva, Maria-José, etc."},{pattern:"^[A-Z][a-zà-ÿ]+(\\s[A-Z][a-zà-ÿ]+)*$",label:"Nome capitalizado",description:"Cada palavra inicia com maiúscula: João Silva."},{pattern:"^@[A-Za-z0-9_]{1,30}$",label:"Username (@handle)",description:"Username no estilo @usuario (letras, números, underscore, até 30 chars)."},{pattern:"^[a-z0-9_]{3,20}$",label:"Username simples",description:"Username minúsculo: 3-20 chars, letras, números e underscore."},{pattern:"^[A-Za-z0-9._%+-]+$",label:"Parte local do e-mail",description:"Parte antes do @ em endereços de e-mail."}]},{category:"Endereço",presets:[{pattern:"^[A-Za-zÀ-ÿ0-9\\s,./-]+$",label:"Endereço genérico",description:"Aceita letras, números, espaços, vírgulas, pontos, barras e hífens."},{pattern:"^\\d{1,6}$",label:"Número residencial",description:"Número do endereço: 1 a 6 dígitos."},{pattern:"^\\d{5}-?\\d{3}$",label:"CEP",description:"CEP: 12345-678 ou 12345678."},{pattern:"^[A-Z]{2}$",label:"UF (estado)",description:"Sigla do estado brasileiro: SP, RJ, MG, etc."},{pattern:"^(Rua|Av|Avenida|Travessa|Alameda|Praça|Rod|Rodovia)\\s.+$",label:"Logradouro BR",description:"Começa com tipo de via: Rua, Avenida, Travessa, etc."},{pattern:"^(Apt|Apto|Sala|Bloco|Lote|Casa)\\s?\\d+.*$",label:"Complemento",description:"Complemento: Apto 123, Bloco B, Sala 3, etc."}]},{category:"Financeiro",presets:[{pattern:"^R\\$\\s?\\d{1,3}(\\.\\d{3})*(,\\d{2})?$",label:"Moeda BRL (R$)",description:"Valor em reais: R$ 1.234,56."},{pattern:"^\\$\\d{1,3}(,\\d{3})*(\\.\\d{2})?$",label:"Moeda USD ($)",description:"Valor em dólares: $1,234.56."},{pattern:"^\\d{4}[\\s-]?\\d{4}[\\s-]?\\d{4}[\\s-]?\\d{4}$",label:"Cartão de crédito",description:"Número de cartão: 1234 5678 9012 3456."},{pattern:"^(0[1-9]|1[0-2])/\\d{2}$",label:"Validade cartão (MM/AA)",description:"Data de validade: 12/25."},{pattern:"^\\d{3,4}$",label:"CVV",description:"Código de segurança: 3 ou 4 dígitos."},{pattern:"^\\d{1,6}(-[0-9Xx])?$",label:"Agência bancária",description:"Número da agência: 1234-5 ou 1234."},{pattern:"^\\d{1,12}(-[0-9Xx])?$",label:"Conta bancária",description:"Número da conta: até 12 dígitos com dígito verificador."},{pattern:"^\\d{1,3}(\\.\\d{3})*(,\\d{2})$",label:"Valor BR sem símbolo",description:"Valor monetário sem R$: 1.234,56."}]},{category:"Veículos",presets:[{pattern:"^[A-Z]{3}-?\\d{4}$",label:"Placa antiga (ABC-1234)",description:"Placa veicular formato antigo: ABC-1234."},{pattern:"^[A-Z]{3}\\d[A-Z]\\d{2}$",label:"Placa Mercosul (ABC1D23)",description:"Placa veicular Mercosul: ABC1D23."},{pattern:"^[A-Z]{3}-?\\d{4}$|^[A-Z]{3}\\d[A-Z]\\d{2}$",label:"Placa (ambos formatos)",description:"Aceita placa antiga (ABC-1234) ou Mercosul (ABC1D23)."},{pattern:"^\\d{11}$",label:"RENAVAM",description:"RENAVAM: 11 dígitos numéricos."},{pattern:"^[A-Z0-9]{17}$",label:"Chassi (VIN)",description:"Número de chassi/VIN: 17 caracteres alfanuméricos maiúsculos."}]},{category:"Códigos e identificadores",presets:[{pattern:"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$",label:"UUID v4",description:"UUID formato padrão: 550e8400-e29b-41d4-a716-446655440000."},{pattern:"^[A-Za-z0-9+/]+={0,2}$",label:"Base64",description:"String codificada em Base64."},{pattern:"^[A-Za-z0-9-_]+$",label:"Base64 URL-safe",description:"Base64 com caracteres seguros para URL."},{pattern:"^[0-9a-f]{32}$",label:"MD5 hash",description:"Hash MD5: 32 caracteres hexadecimais."},{pattern:"^[0-9a-f]{40}$",label:"SHA-1 hash",description:"Hash SHA-1: 40 caracteres hexadecimais."},{pattern:"^[0-9a-f]{64}$",label:"SHA-256 hash",description:"Hash SHA-256: 64 caracteres hexadecimais."},{pattern:"^\\d{8,14}$",label:"Código de barras",description:"Código de barras numérico: 8-14 dígitos."},{pattern:"^\\d{44}$",label:"Linha digitável boleto",description:"Linha digitável de boleto: 44 dígitos."},{pattern:"^[A-Z]{2}\\d{2}[A-Z0-9]{4}\\d{7}([A-Z0-9]?){0,16}\\d{2}$",label:"IBAN",description:"Código bancário internacional IBAN."},{pattern:"^[A-Z]{4}[A-Z]{2}[A-Z0-9]{2}([A-Z0-9]{3})?$",label:"SWIFT/BIC",description:"Código SWIFT bancário: 8 ou 11 caracteres."}]},{category:"Saúde e governo",presets:[{pattern:"^\\d{15}$",label:"Cartão SUS",description:"Número do Cartão Nacional de Saúde: 15 dígitos."},{pattern:"^\\d{6,7}$",label:"CRM/CRO/CRP",description:"Número de registro profissional de saúde."},{pattern:"^\\d{3}\\.\\d{5}\\.\\d{2}-\\d$",label:"NIT/PIS",description:"Número de Identificação do Trabalhador."},{pattern:"^\\d{7}-?\\d{2}\\.\\d{4}\\.\\d\\.\\d{2}\\.\\d{4}$",label:"Processo judicial",description:"Número de processo judicial (formato CNJ)."},{pattern:"^\\d{12}$",label:"Inscrição estadual (genérica)",description:"Inscrição estadual genérica: 12 dígitos."},{pattern:"^\\d{11}$",label:"NIS/NIT",description:"Número de Identificação Social: 11 dígitos."}]},{category:"Redes sociais",presets:[{pattern:"^https?://(www\\.)?instagram\\.com/[A-Za-z0-9_.]+/?$",label:"Perfil Instagram",description:"URL de perfil do Instagram."},{pattern:"^https?://(www\\.)?facebook\\.com/.+$",label:"Perfil Facebook",description:"URL de perfil ou página do Facebook."},{pattern:"^https?://(www\\.)?linkedin\\.com/in/[A-Za-z0-9-]+/?$",label:"Perfil LinkedIn",description:"URL de perfil do LinkedIn."},{pattern:"^https?://(www\\.)?(twitter|x)\\.com/[A-Za-z0-9_]+/?$",label:"Perfil Twitter/X",description:"URL de perfil no Twitter/X."},{pattern:"^https?://(www\\.)?youtube\\.com/(c/|channel/|@)[A-Za-z0-9_-]+/?$",label:"Canal YouTube",description:"URL de canal do YouTube."},{pattern:"^https?://(www\\.)?github\\.com/[A-Za-z0-9_-]+/?$",label:"Perfil GitHub",description:"URL de perfil do GitHub."},{pattern:"^https?://(www\\.)?tiktok\\.com/@[A-Za-z0-9_.]+/?$",label:"Perfil TikTok",description:"URL de perfil do TikTok."}]},{category:"Programação",presets:[{pattern:"^[a-z][a-zA-Z0-9]*$",label:"camelCase",description:"Formato camelCase: minúscula inicial, sem espaços."},{pattern:"^[A-Z][a-zA-Z0-9]*$",label:"PascalCase",description:"Formato PascalCase: maiúscula inicial."},{pattern:"^[a-z]+(_[a-z]+)*$",label:"snake_case",description:"Formato snake_case: minúsculas separadas por underscore."},{pattern:"^[a-z]+(-[a-z]+)*$",label:"kebab-case",description:"Formato kebab-case: minúsculas separadas por hífen."},{pattern:"^[A-Z]+(_[A-Z]+)*$",label:"SCREAMING_SNAKE",description:"Constantes: MAIÚSCULAS_COM_UNDERSCORES."},{pattern:"^[a-zA-Z_$][a-zA-Z0-9_$]*$",label:"Variável JS válida",description:"Nome de variável JavaScript válido."},{pattern:"^v?\\d+\\.\\d+\\.\\d+(-[a-zA-Z0-9.]+)?$",label:"Semver",description:"Versionamento semântico: v1.2.3 ou 1.2.3-beta.1."},{pattern:"^[a-z][a-z0-9]*(-[a-z][a-z0-9]*)*$",label:"Nome de pacote npm",description:"Nome válido de pacote npm."}]}],BC=ui.flatMap(e=>e.presets),UC=({value:e,message:t,onChange:r})=>{const[n,a]=N.useState(!1),[s,i]=N.useState(""),l=N.useMemo(()=>{if(!s.trim())return ui;const u=s.toLowerCase();return ui.map(m=>({...m,presets:m.presets.filter(p=>p.label.toLowerCase().includes(u)||p.description.toLowerCase().includes(u)||p.pattern.toLowerCase().includes(u))})).filter(m=>m.presets.length>0)},[s]),c=N.useMemo(()=>e?BC.find(u=>u.pattern===e):void 0,[e]),d=u=>{r(u.pattern,`${u.label}: formato inválido`),a(!1),i("")};return o.jsxs("div",{className:"space-y-2",children:[o.jsx(ie,{className:"text-[10px]",children:"Regex"}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(ue,{value:e??"",onChange:u=>r(u.target.value||void 0,t),className:"h-7 text-xs font-mono flex-1",placeholder:"Clique no botão ou digite..."}),e&&o.jsx(De,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>{r(void 0,void 0)},children:o.jsx(_.X,{className:"h-3 w-3"})}),o.jsxs(Po,{open:n,onOpenChange:a,children:[o.jsx(_o,{asChild:!0,children:o.jsx(De,{variant:"outline",size:"icon",className:"h-7 w-7 shrink-0",children:o.jsx(_.Regex,{className:"h-3.5 w-3.5"})})}),o.jsxs(fa,{className:"w-[360px] p-0",side:"left",align:"start",sideOffset:8,children:[o.jsx("div",{className:"p-2 border-b",children:o.jsxs("div",{className:"relative",children:[o.jsx(_.Search,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),o.jsx(ue,{value:s,onChange:u=>i(u.target.value),className:"h-8 text-xs pl-7",placeholder:"Buscar regex (ex: CPF, e-mail, senha)...",autoFocus:!0})]})}),o.jsx(Vo,{className:"h-[360px]",children:o.jsxs("div",{className:"p-1",children:[l.length===0&&o.jsx("p",{className:"text-xs text-muted-foreground text-center py-8",children:"Nenhum regex encontrado"}),l.map(u=>o.jsxs("div",{className:"mb-1",children:[o.jsx("p",{className:"text-[10px] font-semibold text-muted-foreground uppercase tracking-wide px-2 py-1.5 sticky top-0 bg-popover z-10",children:u.category}),u.presets.map(m=>o.jsxs(Of,{children:[o.jsx(Ff,{asChild:!0,children:o.jsxs("button",{onClick:()=>d(m),className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-left hover:bg-accent transition-colors group",children:[o.jsx(_.ChevronRight,{className:"h-3 w-3 text-muted-foreground/50 group-hover:text-primary shrink-0"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("span",{className:"text-xs font-medium block truncate",children:m.label}),o.jsx("span",{className:"text-[10px] text-muted-foreground font-mono block truncate",children:m.pattern})]})]})}),o.jsxs(sl,{side:"left",className:"max-w-[250px] text-xs",children:[o.jsx("p",{className:"font-semibold mb-1",children:m.label}),o.jsx("p",{children:m.description})]})]},m.pattern+m.label))]},u.category))]})})]})]})]}),c&&o.jsxs(Di,{variant:"secondary",className:"text-[10px] font-normal gap-1",children:[o.jsx(_.Regex,{className:"h-2.5 w-2.5"}),c.label]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Mensagem do regex"}),o.jsx(ue,{value:t??"",onChange:u=>r(e,u.target.value||void 0),className:"h-7 text-xs",placeholder:"Formato inválido"})]})]})},mi=[{category:"Imagens",presets:[{value:"image/jpeg",label:"JPEG",description:"Imagem JPEG — formato mais comum para fotos. Boa compressão, perde qualidade."},{value:"image/png",label:"PNG",description:"Imagem PNG — suporta transparência, sem perda de qualidade. Arquivos maiores."},{value:"image/gif",label:"GIF",description:"Imagem GIF — suporta animações simples e transparência. Limitado a 256 cores."},{value:"image/webp",label:"WebP",description:"Formato moderno do Google — compressão superior ao JPEG e PNG."},{value:"image/svg+xml",label:"SVG",description:"Imagem vetorial XML — escalável sem perda. Ideal para logos e ícones."},{value:"image/bmp",label:"BMP",description:"Bitmap — sem compressão, arquivos muito grandes."},{value:"image/tiff",label:"TIFF",description:"Imagem TIFF — alta qualidade, usado em impressão profissional."},{value:"image/avif",label:"AVIF",description:"Formato moderno — melhor compressão que WebP, suporte crescente."},{value:"image/heic",label:"HEIC",description:"Formato padrão do iPhone — alta qualidade, tamanho reduzido."},{value:"image/*",label:"Qualquer imagem",description:"Aceita todos os formatos de imagem (JPEG, PNG, GIF, WebP, etc.)."}]},{category:"Documentos",presets:[{value:"application/pdf",label:"PDF",description:"Documento PDF — formato universal para documentos. Preserva formatação."},{value:"application/msword",label:"DOC (Word antigo)",description:"Microsoft Word 97-2003 (.doc)."},{value:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",label:"DOCX (Word)",description:"Microsoft Word moderno (.docx) — formato atual do Word."},{value:"application/vnd.ms-excel",label:"XLS (Excel antigo)",description:"Microsoft Excel 97-2003 (.xls)."},{value:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",label:"XLSX (Excel)",description:"Microsoft Excel moderno (.xlsx) — formato atual do Excel."},{value:"application/vnd.ms-powerpoint",label:"PPT (PowerPoint antigo)",description:"Microsoft PowerPoint 97-2003 (.ppt)."},{value:"application/vnd.openxmlformats-officedocument.presentationml.presentation",label:"PPTX (PowerPoint)",description:"Microsoft PowerPoint moderno (.pptx)."},{value:"application/vnd.oasis.opendocument.text",label:"ODT (LibreOffice)",description:"Documento de texto LibreOffice/OpenOffice (.odt)."},{value:"application/vnd.oasis.opendocument.spreadsheet",label:"ODS (LibreOffice)",description:"Planilha LibreOffice/OpenOffice (.ods)."},{value:"application/rtf",label:"RTF",description:"Rich Text Format — compatível com quase todos os editores de texto."},{value:"text/plain",label:"TXT",description:"Texto puro sem formatação (.txt)."},{value:"text/csv",label:"CSV",description:"Valores separados por vírgula — planilhas simples e dados tabulares."}]},{category:"Vídeos",presets:[{value:"video/mp4",label:"MP4",description:"Vídeo MP4 — formato mais compatível, boa compressão (H.264/H.265)."},{value:"video/webm",label:"WebM",description:"Vídeo WebM — formato aberto do Google, boa compressão."},{value:"video/quicktime",label:"MOV",description:"Vídeo QuickTime — formato padrão do macOS/iPhone."},{value:"video/x-msvideo",label:"AVI",description:"Vídeo AVI — formato antigo da Microsoft, arquivos grandes."},{value:"video/x-matroska",label:"MKV",description:"Matroska — contêiner flexível, suporta múltiplas faixas de áudio/legenda."},{value:"video/*",label:"Qualquer vídeo",description:"Aceita todos os formatos de vídeo."}]},{category:"Áudios",presets:[{value:"audio/mpeg",label:"MP3",description:"Áudio MP3 — formato mais popular, boa compressão com perda."},{value:"audio/wav",label:"WAV",description:"Áudio WAV — sem compressão, alta qualidade, arquivos grandes."},{value:"audio/ogg",label:"OGG",description:"Áudio OGG Vorbis — formato aberto, boa qualidade."},{value:"audio/aac",label:"AAC",description:"Áudio AAC — qualidade superior ao MP3 no mesmo bitrate."},{value:"audio/flac",label:"FLAC",description:"Áudio FLAC — compressão sem perda, alta fidelidade."},{value:"audio/webm",label:"WebM Áudio",description:"Áudio no contêiner WebM."},{value:"audio/*",label:"Qualquer áudio",description:"Aceita todos os formatos de áudio."}]},{category:"Compactados",presets:[{value:"application/zip",label:"ZIP",description:"Arquivo compactado ZIP — o mais universal."},{value:"application/x-rar-compressed",label:"RAR",description:"Arquivo compactado RAR — boa compressão, formato proprietário."},{value:"application/gzip",label:"GZ / GZIP",description:"Compactação GZIP — muito usado em ambientes Unix/Linux."},{value:"application/x-7z-compressed",label:"7Z",description:"Arquivo 7-Zip — excelente taxa de compressão."},{value:"application/x-tar",label:"TAR",description:"TAR — agrupa arquivos sem compressão (usado com gzip)."}]},{category:"Dados / Código",presets:[{value:"application/json",label:"JSON",description:"Dados JSON — formato leve para troca de dados."},{value:"application/xml",label:"XML",description:"Dados XML — formato de marcação extensível."},{value:"text/html",label:"HTML",description:"Página web HTML."},{value:"text/css",label:"CSS",description:"Folha de estilo CSS."},{value:"application/javascript",label:"JavaScript",description:"Código JavaScript (.js)."},{value:"application/x-yaml",label:"YAML",description:"Dados YAML — formato legível para configurações."},{value:"text/markdown",label:"Markdown",description:"Texto Markdown (.md) — formatação leve."}]},{category:"Fontes",presets:[{value:"font/ttf",label:"TTF",description:"Fonte TrueType — amplamente suportada."},{value:"font/otf",label:"OTF",description:"Fonte OpenType — recursos tipográficos avançados."},{value:"font/woff",label:"WOFF",description:"Web Open Font Format — otimizado para web."},{value:"font/woff2",label:"WOFF2",description:"WOFF2 — compressão superior ao WOFF."}]},{category:"Atalhos comuns",presets:[{value:"image/*",label:"Todas as imagens",description:"Aceita qualquer formato de imagem."},{value:"video/*",label:"Todos os vídeos",description:"Aceita qualquer formato de vídeo."},{value:"audio/*",label:"Todos os áudios",description:"Aceita qualquer formato de áudio."},{value:"_group_documentos",label:"Documentos comuns",description:"PDF + Word .doc e .docx.",group:["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"]},{value:"_group_imagens_web",label:"Imagens web",description:"JPEG, PNG e WebP — formatos mais usados na web.",group:["image/jpeg","image/png","image/webp"]},{value:"_group_planilhas",label:"Planilhas",description:"Excel .xls, .xlsx e CSV.",group:["application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","text/csv"]}]}],HC=mi.flatMap(e=>e.presets),WC=({value:e,onChange:t})=>{const[r,n]=N.useState(!1),[a,s]=N.useState(""),[i,l]=N.useState(""),c=N.useMemo(()=>new Set(e??[]),[e]),d=N.useMemo(()=>{if(!a.trim())return mi;const b=a.toLowerCase();return mi.map(h=>({...h,presets:h.presets.filter(x=>x.label.toLowerCase().includes(b)||x.description.toLowerCase().includes(b)||x.value.toLowerCase().includes(b))})).filter(h=>h.presets.length>0)},[a]),u=b=>{const h=new Set(e??[]);b.group?b.group.every(x=>h.has(x))?b.group.forEach(x=>h.delete(x)):b.group.forEach(x=>h.add(x)):h.has(b.value)?h.delete(b.value):h.add(b.value),t(h.size>0?Array.from(h):void 0)},m=()=>{const b=i.trim();if(!b)return;const h=new Set(e??[]);h.add(b),t(Array.from(h)),l("")},p=b=>{const h=new Set(e??[]);h.delete(b),t(h.size>0?Array.from(h):void 0)},f=b=>{const h=HC.find(x=>x.value===b);return(h==null?void 0:h.label)??b};return o.jsxs("div",{className:"space-y-2",children:[o.jsx(ie,{className:"text-[10px]",children:"Tipos de arquivo aceitos"}),((e==null?void 0:e.length)??0)>0&&o.jsx("div",{className:"flex flex-wrap gap-1",children:e.map(b=>o.jsxs(Di,{variant:"secondary",className:"text-[10px] gap-1 pr-1",children:[f(b),o.jsx("button",{onClick:()=>p(b),className:"hover:text-destructive",children:o.jsx(_.X,{className:"h-2.5 w-2.5"})})]},b))}),o.jsxs(Po,{open:r,onOpenChange:n,children:[o.jsx(_o,{asChild:!0,children:o.jsxs(De,{variant:"outline",className:"w-full h-8 text-xs justify-start gap-2",children:[o.jsx(_.FileType2,{className:"h-3.5 w-3.5"}),((e==null?void 0:e.length)??0)>0?`${e.length} tipo(s) selecionado(s)`:"Selecionar tipos de arquivo..."]})}),o.jsxs(fa,{className:"w-[360px] p-0",side:"left",align:"start",sideOffset:8,children:[o.jsx("div",{className:"p-2 border-b",children:o.jsxs("div",{className:"relative",children:[o.jsx(_.Search,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),o.jsx(ue,{value:a,onChange:b=>s(b.target.value),className:"h-8 text-xs pl-7",placeholder:"Buscar tipos (ex: PDF, imagem, vídeo)...",autoFocus:!0})]})}),o.jsxs("div",{className:"px-2 py-1.5 border-b flex gap-1",children:[o.jsx(ue,{value:i,onChange:b=>l(b.target.value),className:"h-7 text-xs font-mono flex-1",placeholder:"Tipo customizado (ex: .dwg)",onKeyDown:b=>b.key==="Enter"&&m()}),o.jsx(De,{variant:"secondary",size:"sm",className:"h-7 text-xs shrink-0",onClick:m,disabled:!i.trim(),children:"Adicionar"})]}),o.jsx(Vo,{className:"h-[320px]",children:o.jsxs("div",{className:"p-1",children:[d.length===0&&o.jsx("p",{className:"text-xs text-muted-foreground text-center py-8",children:"Nenhum tipo encontrado"}),d.map(b=>o.jsxs("div",{className:"mb-1",children:[o.jsx("p",{className:"text-[10px] font-semibold text-muted-foreground uppercase tracking-wide px-2 py-1.5 sticky top-0 bg-popover z-10",children:b.category}),b.presets.map(h=>{const x=h.group?h.group.every(v=>c.has(v)):c.has(h.value),y=h.group?h.group.some(v=>c.has(v))&&!x:!1;return o.jsxs(Of,{children:[o.jsx(Ff,{asChild:!0,children:o.jsxs("button",{onClick:()=>u(h),className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-left hover:bg-accent transition-colors",children:[o.jsx(et,{checked:y?"indeterminate":x,className:"h-3.5 w-3.5",tabIndex:-1}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("span",{className:"text-xs font-medium",children:h.label}),!h.group&&o.jsx("span",{className:"text-[10px] text-muted-foreground font-mono ml-2",children:h.value}),h.group&&o.jsxs("span",{className:"text-[10px] text-muted-foreground ml-2",children:[h.group.length," tipos"]})]}),o.jsx(_.Info,{className:"h-3 w-3 text-muted-foreground/40 shrink-0"})]})}),o.jsxs(sl,{side:"left",className:"max-w-[250px] text-xs",children:[o.jsx("p",{className:"font-semibold mb-1",children:h.label}),o.jsx("p",{children:h.description}),h.group&&o.jsx("ul",{className:"mt-1 space-y-0.5",children:h.group.map(v=>o.jsx("li",{className:"font-mono text-[10px] opacity-80",children:v},v))})]})]},h.value)})]},b.category))]})})]})]})]})},Zh=1048576,no=1073741824;function pd(e){return e>=no&&e%no===0?"GB":"MB"}function fd(e,t){return t==="GB"?e/no:e/Zh}function hd(e,t){return Math.round(e*(t==="GB"?no:Zh))}const qC=({value:e,onChange:t})=>{const r=N.useMemo(()=>e?pd(e):"MB",[]),[n,a]=N.useState(r),[s,i]=N.useState(e?String(fd(e,r)):"");N.useEffect(()=>{if(e===void 0){i("");return}const d=pd(e);a(d),i(String(fd(e,d)))},[e]);const l=d=>{i(d);const u=parseFloat(d);d.trim()===""||isNaN(u)||u<=0?t(void 0):t(hd(u,n))},c=d=>{a(d);const u=parseFloat(s);!isNaN(u)&&u>0&&t(hd(u,d))};return o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(ie,{className:"text-[10px]",children:"Tamanho máximo do arquivo"}),o.jsxs("div",{className:"flex gap-1.5",children:[o.jsx(ue,{type:"number",min:0,step:"any",value:s,onChange:d=>l(d.target.value),placeholder:"Ex: 10",className:"h-8 text-xs flex-1"}),o.jsxs(Bt,{value:n,onValueChange:d=>c(d),children:[o.jsx(Rt,{className:"w-[72px] h-8 text-xs",children:o.jsx(Ut,{})}),o.jsxs(It,{children:[o.jsx(qe,{value:"MB",children:"MB"}),o.jsx(qe,{value:"GB",children:"GB"})]})]})]}),e!==void 0&&o.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["= ",e.toLocaleString("pt-BR")," bytes"]})]})},GC=new Set(["texto","textarea","email","password","url","phone","tel","cpf","cnpj","cep","rg"]),XC=({fieldType:e,validation:t,onChange:r})=>{const n=(i,l)=>{const c=["minLength","maxLength","min","max","maxFileSize","minAge","maxAge"].includes(i)?l?Number(l):void 0:l||void 0;r({...t,[i]:c})},a=e==="file",s=GC.has(e);return o.jsxs("div",{className:"space-y-3",children:[o.jsx("h4",{className:"text-xs font-semibold text-muted-foreground uppercase",children:"Validação"}),s&&o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Min caracteres"}),o.jsx(ue,{type:"number",min:0,value:(t==null?void 0:t.minLength)??"",onChange:i=>n("minLength",i.target.value),className:"h-7 text-xs"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Max caracteres"}),o.jsx(ue,{type:"number",min:0,value:(t==null?void 0:t.maxLength)??"",onChange:i=>n("maxLength",i.target.value),className:"h-7 text-xs"})]})]}),e==="number"&&o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Valor mínimo"}),o.jsx(ue,{type:"number",value:(t==null?void 0:t.min)??"",onChange:i=>n("min",i.target.value),className:"h-7 text-xs"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Valor máximo"}),o.jsx(ue,{type:"number",value:(t==null?void 0:t.max)??"",onChange:i=>n("max",i.target.value),className:"h-7 text-xs"})]})]}),(e==="date"||e==="datetime")&&o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Data mínima"}),o.jsx(ue,{type:"date",value:(t==null?void 0:t.minDate)??"",onChange:i=>n("minDate",i.target.value),className:"h-7 text-xs"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Data máxima"}),o.jsx(ue,{type:"date",value:(t==null?void 0:t.maxDate)??"",onChange:i=>n("maxDate",i.target.value),className:"h-7 text-xs"})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Idade mínima (anos)"}),o.jsx(ue,{type:"number",min:0,value:(t==null?void 0:t.minAge)??"",onChange:i=>n("minAge",i.target.value),className:"h-7 text-xs",placeholder:"ex: 18"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Idade máxima (anos)"}),o.jsx(ue,{type:"number",min:0,value:(t==null?void 0:t.maxAge)??"",onChange:i=>n("maxAge",i.target.value),className:"h-7 text-xs",placeholder:"ex: 60"})]})]})]}),a&&o.jsxs("div",{className:"space-y-3",children:[o.jsx(WC,{value:t==null?void 0:t.fileTypes,onChange:i=>r({...t,fileTypes:i})}),o.jsx(qC,{value:t==null?void 0:t.maxFileSize,onChange:i=>r({...t,maxFileSize:i})})]}),!a&&o.jsx(UC,{value:(t==null?void 0:t.regex)??"",message:(t==null?void 0:t.regexMessage)??"",onChange:(i,l)=>r({...t,regex:i,regexMessage:l})})]})},Kh=({options:e,onChange:t})=>{const r=N.useRef([]);if(r.current.length<e.length)for(let i=r.current.length;i<e.length;i++)r.current.push(`opt-${Math.random().toString(36).slice(2)}`);const n=N.useCallback((i,l,c)=>{const d=[...e];d[i]={...d[i],[l]:c},t(d)},[e,t]),a=N.useCallback(i=>{r.current.splice(i,1),t(e.filter((l,c)=>c!==i))},[e,t]),s=N.useCallback(()=>{t([...e,{value:"",label:""}])},[e,t]);return o.jsxs("div",{className:"space-y-2",children:[o.jsx("h4",{className:"text-xs font-semibold text-muted-foreground uppercase",children:"Opções"}),e.map((i,l)=>o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(_.GripVertical,{className:"h-3 w-3 text-muted-foreground/40 shrink-0"}),o.jsx(ue,{value:i.value,onChange:c=>n(l,"value",c.target.value),className:"h-7 text-xs flex-1",placeholder:"Valor"}),o.jsxs("div",{className:"flex items-center gap-0.5 flex-1",children:[o.jsx(ue,{value:i.label,onChange:c=>n(l,"label",c.target.value),className:"h-7 text-xs flex-1",placeholder:"Label"}),o.jsx(yr,{})]}),o.jsx(De,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>a(l),children:o.jsx(_.Trash2,{className:"h-3 w-3"})})]},r.current[l])),o.jsxs(De,{variant:"outline",size:"sm",className:"w-full h-7 text-xs",onClick:s,children:[o.jsx(_.Plus,{className:"h-3 w-3 mr-1"})," Adicionar opção"]})]})},ZC=[{value:"igual",label:"Igual a"},{value:"diferente",label:"Diferente de"},{value:"vazio",label:"Vazio"},{value:"naoVazio",label:"Não vazio"},{value:"contem",label:"Contém"},{value:"naoContem",label:"Não contém"},{value:"maiorQue",label:"Maior que"},{value:"menorQue",label:"Menor que"},{value:"maiorOuIgual",label:"Maior ou igual a"},{value:"menorOuIgual",label:"Menor ou igual a"}],KC=["vazio","naoVazio"],xd=({cond:e,selectedId:t,allFieldIds:r,getFieldLabel:n,onUpdate:a})=>o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Fonte"}),o.jsxs(Bt,{value:e.source||"campo",onValueChange:s=>a({source:s,when:""}),children:[o.jsx(Rt,{className:"h-7 text-xs",children:o.jsx(Ut,{})}),o.jsxs(It,{children:[o.jsx(qe,{value:"campo",children:"Campo do formulário"}),o.jsx(qe,{value:"evento",children:"Variável do evento"})]})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:e.source==="evento"?"Variável do evento":"Quando o campo"}),o.jsxs(Bt,{value:e.when||"",onValueChange:s=>a({when:s}),children:[o.jsx(Rt,{className:"h-7 text-xs",children:o.jsx(Ut,{placeholder:e.source==="evento"?"Selecione uma variável...":"Selecione um campo..."})}),o.jsx(It,{children:e.source==="evento"?bl.map(s=>o.jsx(qe,{value:s.key,children:s.label},s.key)):r.filter(s=>s!==t).map(s=>o.jsxs(qe,{value:s,children:[n(s),o.jsxs("span",{className:"text-muted-foreground/50 ml-1 text-[9px] font-mono",children:["(",s,")"]})]},s))})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Operador"}),o.jsxs(Bt,{value:e.operator,onValueChange:s=>a({operator:s}),children:[o.jsx(Rt,{className:"h-7 text-xs",children:o.jsx(Ut,{})}),o.jsx(It,{children:ZC.map(s=>o.jsx(qe,{value:s.value,children:s.label},s.value))})]})]}),!KC.includes(e.operator)&&o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Valor"}),o.jsx(ue,{value:e.value||"",onChange:s=>a({value:s.target.value}),className:"h-7 text-xs",placeholder:"Valor esperado"})]})]}),YC=({condition:e,selectedId:t,allFieldIds:r,getFieldLabel:n,onChange:a})=>{var s;const i=m=>{e&&a({...e,...m})},l=()=>{if(!e)return;const m=e.extraConditions??[];a({...e,logicOperator:e.logicOperator??"and",extraConditions:[...m,{when:"",operator:"igual",value:"",source:"campo"}]})},c=m=>{if(!e)return;const p=(e.extraConditions??[]).filter((f,b)=>b!==m);a({...e,extraConditions:p,logicOperator:p.length?e.logicOperator:void 0})},d=(m,p)=>{if(!e)return;const f=(e.extraConditions??[]).map((b,h)=>h===m?{...b,...p}:b);a({...e,extraConditions:f})},u=(((s=e==null?void 0:e.extraConditions)==null?void 0:s.length)??0)>0;return o.jsxs("div",{className:"space-y-3",children:[o.jsx("h4",{className:"text-xs font-semibold text-muted-foreground uppercase",children:"Condicional"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(et,{id:"has-condition",checked:!!e,onCheckedChange:m=>{a(m?{when:"",operator:"igual",value:"",source:"campo"}:void 0)}}),o.jsx(ie,{htmlFor:"has-condition",className:"text-xs cursor-pointer",children:"Exibir condicionalmente"})]}),e&&o.jsxs("div",{className:"space-y-2 pl-2 border-l-2 border-amber-500/30",children:[o.jsx(xd,{cond:e,selectedId:t,allFieldIds:r,getFieldLabel:n,onUpdate:i}),u&&o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Lógica"}),o.jsxs(Bt,{value:e.logicOperator??"and",onValueChange:m=>i({logicOperator:m}),children:[o.jsx(Rt,{className:"h-7 text-xs",children:o.jsx(Ut,{})}),o.jsxs(It,{children:[o.jsx(qe,{value:"and",children:"E (AND) — todas devem ser verdadeiras"}),o.jsx(qe,{value:"or",children:"OU (OR) — pelo menos uma deve ser verdadeira"})]})]})]}),(e.extraConditions??[]).map((m,p)=>o.jsxs("div",{className:"space-y-2 pt-2 border-t border-border/40",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("span",{className:"text-[10px] text-muted-foreground font-medium uppercase",children:[e.logicOperator==="or"?"OU":"E"," — condição"," ",p+2]}),o.jsx(De,{variant:"ghost",size:"sm",className:"h-5 px-1 text-[10px] text-destructive hover:text-destructive",onClick:()=>c(p),children:"Remover"})]}),o.jsx(xd,{cond:m,selectedId:t,allFieldIds:r,getFieldLabel:n,onUpdate:f=>d(p,f)})]},p)),o.jsx(De,{variant:"outline",size:"sm",className:"h-6 text-[10px] w-full mt-1",onClick:l,children:"+ Adicionar condição"})]})]})},gd=[{value:"texto",label:"Texto"},{value:"textarea",label:"Área de texto"},{value:"number",label:"Número"},{value:"email",label:"E-mail"},{value:"telefone",label:"Telefone"},{value:"cpf",label:"CPF"},{value:"cep",label:"CEP"},{value:"date",label:"Data"},{value:"datetime",label:"Data e hora"},{value:"select",label:"Seleção"},{value:"radio",label:"Radio"},{value:"checkbox",label:"Checkbox"}],JC=({subFields:e,onChange:t})=>{const[r,n]=N.useState(null),a=(i,l)=>{const c=e.map((d,u)=>u===i?{...d,...l}:d);t(c)},s=i=>{t(e.filter((l,c)=>c!==i)),n(null)};return o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(ie,{className:"text-xs font-semibold",children:"Sub-campos"}),o.jsxs(De,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-xs gap-1",onClick:()=>{const i={label:"Novo campo",name:`campo_${e.length+1}`,fieldType:"texto",required:!1};t([...e,i]),n(e.length)},children:[o.jsx(_.Plus,{className:"w-3 h-3"}),"Adicionar"]})]}),e.length===0&&o.jsx("p",{className:"text-[11px] text-muted-foreground italic py-1",children:"Nenhum sub-campo adicionado."}),e.map((i,l)=>{var c;return o.jsxs("div",{className:"border rounded-md text-xs overflow-hidden",children:[o.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 cursor-pointer hover:bg-muted/40 select-none",onClick:()=>n(r===l?null:l),children:[o.jsx(Di,{variant:"secondary",className:"h-4 text-[9px] px-1 shrink-0",children:l+1}),o.jsx("span",{className:"flex-1 truncate font-medium",children:i.label||i.name||"Campo sem nome"}),o.jsx("span",{className:"text-muted-foreground text-[10px] shrink-0",children:((c=gd.find(d=>d.value===i.fieldType))==null?void 0:c.label)??i.fieldType}),o.jsx(De,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 text-destructive hover:text-destructive shrink-0",onClick:d=>{d.stopPropagation(),s(l)},children:o.jsx(_.Trash2,{className:"w-3 h-3"})}),r===l?o.jsx(_.ChevronUp,{className:"w-3 h-3 text-muted-foreground shrink-0"}):o.jsx(_.ChevronDown,{className:"w-3 h-3 text-muted-foreground shrink-0"})]}),r===l&&o.jsxs("div",{className:"px-2 pb-2 space-y-2 border-t bg-muted/20",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-2 pt-2",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Label"}),o.jsx(ue,{value:i.label,onChange:d=>a(l,{label:d.target.value}),className:"h-7 text-xs",placeholder:"Ex: Nome"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Nome (campo)"}),o.jsx(ue,{value:i.name||"",onChange:d=>a(l,{name:d.target.value}),className:"h-7 text-xs",placeholder:"Ex: nome"})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Tipo de campo"}),o.jsxs(Bt,{value:i.fieldType,onValueChange:d=>a(l,{fieldType:d}),children:[o.jsx(Rt,{className:"h-7 text-xs",children:o.jsx(Ut,{})}),o.jsx(It,{children:gd.map(d=>o.jsx(qe,{value:d.value,className:"text-xs",children:d.label},d.value))})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Colunas (1-12)"}),o.jsx(ue,{type:"number",min:1,max:12,value:i.tamanho??"",onChange:d=>a(l,{tamanho:d.target.value?Number(d.target.value):void 0}),className:"h-7 text-xs",placeholder:"12"})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-[10px]",children:"Placeholder"}),o.jsx(ue,{value:i.placeholder||"",onChange:d=>a(l,{placeholder:d.target.value}),className:"h-7 text-xs",placeholder:"Texto de exemplo..."})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(et,{id:`sf-req-${l}`,checked:i.required||!1,onCheckedChange:d=>a(l,{required:d===!0})}),o.jsx(ie,{htmlFor:`sf-req-${l}`,className:"text-[10px] cursor-pointer",children:"Obrigatório"})]}),["select","radio","checkbox_group"].includes(i.fieldType)&&o.jsx("div",{className:"pt-1",children:o.jsx(Kh,{options:i.options||[],onChange:d=>a(l,{options:d})})})]})]},l)}),e.length>0&&o.jsx(it,{className:"mt-1"})]})},QC=({config:e,selectedId:t,allFieldIds:r,getFieldLabel:n,onUpdate:a})=>{const s=e.fieldType||"texto",i=["select","radio","checkbox_group","autocomplete"].includes(s),l=s==="field_array",c=e.locked===!0,d=s==="participation_type",u=s==="payment_method",m=s==="terms",p=s==="file",f=s==="slider",b=!!(e.isDisabled||e.isReadOnly),h=s==="rating",x=s==="date_range",y=s==="sub_form",{schemaId:v,uploadTermsPdf:j,deleteTermsPdf:w}=gt(),[C,S]=N.useState(e.termoPdfUploadId?"upload":"link"),[$,k]=N.useState({status:"idle"}),E=N.useRef(null),D=N.useRef(!0);N.useEffect(()=>()=>{D.current=!1},[]);const O=N.useCallback(async A=>{if(a({termoPdfUploadId:void 0}),w&&v)try{await w(A,v)}catch{}},[w,v,a]),L=N.useCallback(async A=>{if(A.type!=="application/pdf"){k({status:"error",message:"Apenas arquivos PDF são permitidos."});return}if(!v){k({status:"error",message:"Salve o schema primeiro para habilitar o upload de PDF."});return}if(!j){k({status:"error",message:"Upload de PDF não configurado. Forneça a prop uploadTermsPdf ao BuilderProvider."});return}const z=e.termoPdfUploadId;k({status:"uploading",fileName:A.name,progress:0});try{const X=await j(A,v,q=>k(Z=>Z.status==="uploading"?{...Z,progress:q}:Z));if(!D.current)return;if(z&&w)try{await w(z,v)}catch{}if(!D.current)return;a({termoPdfUploadId:X,termoPdfUrl:void 0}),k({status:"idle"})}catch(X){if(!D.current)return;k({status:"error",message:X instanceof Error?X.message:"Falha no upload do PDF."})}},[v,j,w,e.termoPdfUploadId,a]);return o.jsxs("div",{className:"space-y-4",children:[c&&o.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-amber-500/10 border border-amber-500/30 px-3 py-2",children:[o.jsx(_.Lock,{className:"h-4 w-4 text-amber-500 shrink-0"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs font-medium text-amber-600 dark:text-amber-400",children:"Campo bloqueado"}),o.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Tipo, nome e ID são fixos (integração automática)"})]})]}),d&&o.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-primary/5 border border-primary/30 px-3 py-2",children:[o.jsx(_.Lock,{className:"h-4 w-4 text-primary shrink-0"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs font-medium text-primary",children:"Tipo de Participação"}),o.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Datas, preços e vagas são carregados automaticamente do evento"})]})]}),m&&o.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-primary/5 border border-primary/30 px-3 py-2",children:[o.jsx(_.ScrollText,{className:"h-4 w-4 text-primary shrink-0"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs font-medium text-primary",children:"Termos e Condições"}),o.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Configure o texto ou URL do PDF abaixo"})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(ie,{className:"text-xs",children:"Label"}),o.jsx(yr,{})]}),o.jsx(ue,{value:e.label,onChange:A=>a({label:A.target.value}),className:"h-8 text-sm"})]}),d||u?o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Dica (hint)"}),o.jsx(ue,{value:e.hint||"",onChange:A=>a({hint:A.target.value}),className:"h-8 text-sm",placeholder:"Texto de ajuda abaixo do campo"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(et,{id:"req",checked:e.required||!1,onCheckedChange:A=>a({required:A===!0})}),o.jsx(ie,{htmlFor:"req",className:"text-xs cursor-pointer",children:"Campo obrigatório"})]})]}):m?o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Dica (hint)"}),o.jsx(ue,{value:e.hint||"",onChange:A=>a({hint:A.target.value}),className:"h-8 text-sm",placeholder:"Ex: Leia os termos antes de continuar"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(et,{id:"req",checked:e.required||!1,onCheckedChange:A=>a({required:A===!0})}),o.jsx(ie,{htmlFor:"req",className:"text-xs cursor-pointer",children:"Campo obrigatório"})]}),o.jsx(it,{}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("h4",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Conteúdo dos termos"}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Texto dos termos"}),o.jsx(po,{value:e.termoTexto||"",onChange:A=>a({termoTexto:A.target.value||void 0}),className:"text-sm min-h-[120px] resize-y",placeholder:"Escreva aqui os termos e condições que o usuário deverá ler e aceitar..."})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ie,{className:"text-xs",children:"PDF dos termos (opcional)"}),o.jsxs("div",{className:"flex gap-1 p-0.5 bg-muted rounded-md",children:[o.jsx("button",{type:"button",onClick:()=>S("link"),className:`flex-1 text-[11px] py-1 rounded transition-colors ${C==="link"?"bg-background shadow-sm font-medium":"text-muted-foreground hover:text-foreground"}`,children:"Link externo"}),o.jsx("button",{type:"button",onClick:()=>S("upload"),className:`flex-1 text-[11px] py-1 rounded transition-colors ${C==="upload"?"bg-background shadow-sm font-medium":"text-muted-foreground hover:text-foreground"}`,children:"Upload de PDF"})]}),C==="link"?o.jsxs("div",{className:"space-y-1",children:[o.jsx(ue,{value:e.termoPdfUrl||"",onChange:A=>a({termoPdfUrl:A.target.value||void 0}),className:"h-8 text-sm",placeholder:"https://exemplo.com/termos.pdf"}),o.jsx("p",{className:"text-[9px] text-muted-foreground",children:"URL pública de um PDF. Tem prioridade sobre o texto acima."})]}):o.jsxs("div",{className:"space-y-2",children:[e.termoPdfUploadId&&$.status==="idle"?o.jsxs("div",{className:"flex items-center gap-2 rounded border border-green-500/40 bg-green-500/10 px-2 py-1.5",children:[o.jsx(_.CheckCircle2,{className:"h-3.5 w-3.5 text-green-600 shrink-0"}),o.jsx("span",{className:"text-[11px] text-green-700 dark:text-green-400 flex-1",children:"PDF enviado ✓"}),o.jsx(De,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>O(e.termoPdfUploadId),children:o.jsx(_.X,{className:"h-3 w-3"})})]}):null,$.status==="uploading"?o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:[o.jsx(_.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),o.jsx("span",{className:"truncate",children:$.fileName}),o.jsxs("span",{className:"ml-auto",children:[$.progress,"%"]})]}),o.jsx(el,{value:$.progress,className:"h-1"})]}):null,$.status==="error"?o.jsxs("div",{className:"flex items-center gap-2 rounded border border-destructive/40 bg-destructive/10 px-2 py-1.5",children:[o.jsx(_.AlertCircle,{className:"h-3.5 w-3.5 text-destructive shrink-0"}),o.jsx("span",{className:"text-[11px] text-destructive",children:$.message}),o.jsx(De,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 ml-auto",onClick:()=>k({status:"idle"}),children:o.jsx(_.X,{className:"h-3 w-3"})})]}):null,$.status!=="uploading"?o.jsxs(o.Fragment,{children:[o.jsx("input",{ref:E,type:"file",accept:"application/pdf",className:"hidden",onChange:A=>{var z;const X=(z=A.target.files)==null?void 0:z[0];X&&L(X),A.target.value=""}}),o.jsxs(De,{type:"button",variant:"outline",size:"sm",className:"w-full h-8 text-xs gap-1.5",disabled:!v,onClick:()=>{var A;return(A=E.current)==null?void 0:A.click()},children:[o.jsx(_.Upload,{className:"h-3.5 w-3.5"}),e.termoPdfUploadId?"Substituir PDF":"Selecionar PDF"]}),!v&&o.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Salve o schema uma vez para habilitar o upload."})]}):null]})]})]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Nome (chave)"}),o.jsx(ue,{value:e.name||t.replace(/^field_/,""),onChange:A=>!c&&a({name:A.target.value}),className:"h-8 text-xs font-mono",placeholder:"nome_do_campo",disabled:c}),c?o.jsx("p",{className:"text-[9px] text-amber-500",children:"ID fixo — necessário para auto-preenchimento"}):o.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Usado como chave no JSON do formulário"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Tipo do campo"}),o.jsxs(Bt,{value:s,onValueChange:A=>!c&&a({fieldType:A}),disabled:c,children:[o.jsx(Rt,{className:"h-8 text-sm",children:o.jsx(Ut,{})}),o.jsx(It,{children:Or.map(A=>o.jsx(qe,{value:A.component,children:A.label},A.component))})]})]}),o.jsx(Xh,{tamanho:e.tamanho||6,inicioColuna:e.inicioColuna||1,defaultTamanho:6,onTamanhoChange:A=>a({tamanho:A}),onPositionChange:A=>a({inicioColuna:A})}),s!=="file"&&!l&&o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(ie,{className:"text-xs",children:"Placeholder"}),o.jsx(yr,{})]}),o.jsx(ue,{value:e.placeholder||"",onChange:A=>a({placeholder:A.target.value}),className:"h-8 text-sm",placeholder:"Texto de exemplo..."})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(ie,{className:"text-xs",children:"Dica (hint)"}),o.jsx(yr,{})]}),o.jsx(ue,{value:e.hint||"",onChange:A=>a({hint:A.target.value}),className:"h-8 text-sm",placeholder:"Texto de ajuda abaixo do campo"})]}),s!=="file"&&!l&&!y&&o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Valor padrão"}),o.jsx(ue,{value:e.defaultValue||"",onChange:A=>a({defaultValue:A.target.value}),className:"h-8 text-sm",placeholder:"Valor inicial do campo"})]}),s!=="file"&&!l&&!y&&o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(ie,{className:"text-xs",children:"Valor inicial (runtime)"}),o.jsx(yr,{})]}),o.jsx(ue,{value:e.initialValue||"",onChange:A=>a({initialValue:A.target.value||void 0}),className:"h-8 text-sm",placeholder:"{{evento.nome}} ou valor fixo"}),o.jsxs("p",{className:"text-[9px] text-muted-foreground",children:['Sobrepõe "Valor padrão" — suporta variáveis'," ",o.jsx("code",{children:"{{evento.x}}"})]})]}),!l&&!y&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(et,{id:"req",checked:e.required||!1,onCheckedChange:A=>a({required:A===!0})}),o.jsx(ie,{htmlFor:"req",className:"text-xs cursor-pointer",children:"Campo obrigatório"})]}),!l&&!y&&!c&&!p&&o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(et,{id:"readonly",checked:e.isReadOnly||!1,onCheckedChange:A=>a({isReadOnly:A===!0||void 0})}),o.jsx(ie,{htmlFor:"readonly",className:"text-xs cursor-pointer",children:"Somente leitura"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(et,{id:"disabled",checked:e.isDisabled||!1,onCheckedChange:A=>a({isDisabled:A===!0||void 0})}),o.jsx(ie,{htmlFor:"disabled",className:"text-xs cursor-pointer",children:"Desabilitado"})]})]}),f&&o.jsxs(o.Fragment,{children:[o.jsx(it,{}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("h4",{className:"text-xs font-semibold text-muted-foreground uppercase",children:"Slider"}),o.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Mínimo"}),o.jsx(ue,{type:"number",value:e.minValue??0,onChange:A=>a({minValue:Number(A.target.value)}),className:"h-8 text-sm"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Máximo"}),o.jsx(ue,{type:"number",value:e.maxValue??100,onChange:A=>a({maxValue:Number(A.target.value)}),className:"h-8 text-sm"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Passo"}),o.jsx(ue,{type:"number",min:1,value:e.step??1,onChange:A=>a({step:Number(A.target.value)}),className:"h-8 text-sm"})]})]})]})]}),h&&o.jsxs(o.Fragment,{children:[o.jsx(it,{}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("h4",{className:"text-xs font-semibold text-muted-foreground uppercase",children:"Avaliação"}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Número de estrelas"}),o.jsxs(Bt,{value:String(e.maxRating??5),onValueChange:A=>a({maxRating:Number(A)}),children:[o.jsx(Rt,{className:"h-8 text-sm",children:o.jsx(Ut,{})}),o.jsx(It,{children:[3,4,5,6,7,10].map(A=>o.jsxs(qe,{value:String(A),children:[A," estrelas"]},A))})]})]})]})]}),x&&o.jsxs(o.Fragment,{children:[o.jsx(it,{}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("h4",{className:"text-xs font-semibold text-muted-foreground uppercase",children:"Período"}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Label da data inicial"}),o.jsx(ue,{value:e.dateRangeStartLabel??"Data inicial",onChange:A=>a({dateRangeStartLabel:A.target.value}),className:"h-8 text-sm"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Label da data final"}),o.jsx(ue,{value:e.dateRangeEndLabel??"Data final",onChange:A=>a({dateRangeEndLabel:A.target.value}),className:"h-8 text-sm"})]})]})]}),!l&&o.jsx(it,{}),!l&&!m&&!b&&o.jsx(XC,{fieldType:s,validation:e.validation,onChange:A=>a({validation:A})}),i&&o.jsxs(o.Fragment,{children:[o.jsx(it,{}),s==="radio"&&o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Estilo visual"}),o.jsxs(Bt,{value:e.visualStyle||"card",onValueChange:A=>a({visualStyle:A}),children:[o.jsx(Rt,{className:"h-8 text-sm",children:o.jsx(Ut,{})}),o.jsxs(It,{children:[o.jsx(qe,{value:"card",children:"Card (padrão)"}),o.jsx(qe,{value:"default",children:"Radio simples"})]})]})]}),o.jsx(Kh,{options:e.options||[],onChange:A=>a({options:A})})]}),l&&o.jsxs(o.Fragment,{children:[o.jsx(it,{}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("h4",{className:"text-xs font-semibold text-muted-foreground uppercase",children:"Lista de itens"}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Mín. itens"}),o.jsx(ue,{type:"number",min:0,value:e.minItems??"",onChange:A=>a({minItems:A.target.value?Number(A.target.value):void 0}),className:"h-8 text-sm",placeholder:"0"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Máx. itens"}),o.jsx(ue,{type:"number",min:0,value:e.maxItems??"",onChange:A=>a({maxItems:A.target.value?Number(A.target.value):void 0}),className:"h-8 text-sm",placeholder:"Sem limite"})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Label do item"}),o.jsx(ue,{value:e.itemLabel||"",onChange:A=>a({itemLabel:A.target.value||void 0}),className:"h-8 text-sm",placeholder:"Ex: Contato"}),o.jsx("p",{className:"text-[9px] text-muted-foreground",children:'Prefixo exibido em cada item (ex: "Contato 1", "Contato 2")'})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Label do botão adicionar"}),o.jsx(ue,{value:e.addLabel||"",onChange:A=>a({addLabel:A.target.value||void 0}),className:"h-8 text-sm",placeholder:"Ex: Adicionar contato"})]}),o.jsx("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/5 px-3 py-2",children:o.jsx("p",{className:"text-[11px] text-amber-700 dark:text-amber-400",children:"Os sub-campos são configurados visualmente no canvas: arraste campos da paleta para dentro da caixa laranja."})})]})]}),y&&o.jsxs(o.Fragment,{children:[o.jsx(it,{}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("h4",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Sub-formulário"}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Título do grupo (opcional)"}),o.jsx(ue,{value:e.subSchemaTitle||"",onChange:A=>a({subSchemaTitle:A.target.value||void 0}),className:"h-8 text-sm",placeholder:"Ex: Endereço, Responsável..."})]}),o.jsx(JC,{subFields:e.subSchemaFields||[],onChange:A=>a({subSchemaFields:A})})]})]}),!b&&!m&&o.jsxs(o.Fragment,{children:[o.jsx(it,{}),o.jsx(YC,{condition:e.condition,selectedId:t,allFieldIds:r,getFieldLabel:n,onChange:A=>a({condition:A})})]}),!b&&!m&&e.condition&&o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs",children:"Valor ao ocultar (clearedValue)"}),o.jsx(ue,{value:e.clearedValue??"",onChange:A=>a({clearedValue:A.target.value||void 0}),className:"h-8 text-sm",placeholder:"Deixar vazio = não limpar"}),o.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Valor aplicado automaticamente quando o campo fica oculto."})]}),!l&&!y&&o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{className:"text-xs text-muted-foreground",children:"Resolver de props (avançado)"}),o.jsx(ue,{value:e.resolvePropsKey||"",onChange:A=>a({resolvePropsKey:A.target.value||void 0}),className:"h-8 text-xs font-mono",placeholder:"chaveDoResolver"}),o.jsxs("p",{className:"text-[9px] text-muted-foreground",children:["Registre este key em"," ",o.jsx("code",{children:"RendererContext.fieldResolvers"})," para opções dinâmicas."]})]})]})]})},eN={glassmorphism:"Glass",card:"Card",flat:"Flat",bordered:"Bordered"},Yh=()=>{const{previewTemplateId:e,setPreviewTemplateId:t}=gt(),[r,n]=N.useState(!1),a=Object.values(Kr),s=Kr[e];return o.jsxs(Po,{open:r,onOpenChange:n,children:[o.jsx(_o,{asChild:!0,children:o.jsxs(De,{variant:"outline",size:"sm",className:"gap-1.5",title:"Selecionar template visual",children:[o.jsx("span",{className:"w-3.5 h-3.5 rounded-full shrink-0 border border-white/20",style:{background:(s==null?void 0:s.colors.primary)??"#3b82f6"}}),o.jsx(_.Palette,{className:"w-3.5 h-3.5"}),o.jsx("span",{className:"hidden sm:inline",children:(s==null?void 0:s.displayName)??"Template"})]})}),o.jsxs(fa,{side:"bottom",align:"end",className:"w-80 p-3",children:[o.jsx("p",{className:"text-xs font-semibold text-muted-foreground mb-2 uppercase tracking-wider",children:"Template de Preview"}),o.jsx("div",{className:"grid grid-cols-3 gap-1.5 max-h-72 overflow-y-auto pr-0.5",children:a.map(i=>{const l=i.id===e,c=su(i),d=eN[i.layout.containerStyle]??"";return o.jsxs("button",{onClick:()=>{t(i.id),n(!1)},className:Ht("relative flex flex-col items-center gap-1.5 rounded-lg p-2 border text-center transition-all hover:scale-[1.02]",l?"border-primary ring-1 ring-primary":"border-border hover:border-muted-foreground/40"),children:[o.jsxs("div",{className:"w-full h-8 rounded-md flex items-center justify-center gap-0.5",style:{background:i.colors.background.startsWith("#")||i.colors.background.startsWith("rgba")?i.colors.background:void 0},"data-muted":!i.colors.background.startsWith("#")&&!i.colors.background.startsWith("rgba")?"true":void 0,children:[o.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:i.colors.primary}}),o.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:i.colors.accent}})]}),o.jsx("span",{className:"text-[10px] font-medium leading-tight line-clamp-2",children:i.displayName}),o.jsxs("div",{className:"flex items-center gap-0.5 flex-wrap justify-center",children:[c&&o.jsx("span",{className:"text-[9px] px-1 rounded bg-zinc-800 text-zinc-300",children:"dark"}),d&&o.jsx("span",{className:"text-[9px] px-1 rounded bg-muted text-muted-foreground",children:d})]}),l&&o.jsx("div",{className:"absolute top-1 right-1",children:o.jsx(_.Check,{className:"w-3 h-3 text-primary"})})]},i.id)})})]})]})},tN=[{value:"numbers",label:"Números"},{value:"icons",label:"Ícones"},{value:"icons-labeled",label:"Ícones + rótulo"}],rN=[{value:"top-center",label:"Centralizado"},{value:"top-left",label:"Esquerda"}],nN=[{value:"horizontal",label:"Horizontal"},{value:"vertical",label:"Vertical (sidebar)"}],aN=()=>{const{stepConfig:e,updateStepConfig:t}=gt();return o.jsxs("div",{className:"space-y-5",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Template visual"}),o.jsx(Yh,{})]}),o.jsx(it,{}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Indicador de steps"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(et,{id:"sc-show-indicators",checked:e.showStepIndicators!==!1,onCheckedChange:r=>t({showStepIndicators:r===!0})}),o.jsx(ie,{htmlFor:"sc-show-indicators",className:"text-xs cursor-pointer",children:"Exibir indicador de steps"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(et,{id:"sc-show-progress",checked:e.showProgressBar===!0,onCheckedChange:r=>t({showProgressBar:r===!0})}),o.jsx(ie,{htmlFor:"sc-show-progress",className:"text-xs cursor-pointer",children:"Exibir barra de progresso"})]})]}),o.jsx(it,{}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ie,{className:"text-xs",children:"Variante visual"}),o.jsx("div",{className:"flex flex-col gap-1.5",children:tN.map(r=>o.jsx("button",{type:"button",onClick:()=>t({stepIndicatorVariant:r.value}),className:`text-left text-xs px-3 py-1.5 rounded-md border transition-colors ${e.stepIndicatorVariant===r.value?"border-primary bg-primary/10 text-primary font-medium":"border-border bg-muted/30 text-muted-foreground hover:bg-muted/60"}`,children:r.label},r.value))}),!e.stepIndicatorVariant&&o.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Herdado do template"})]}),o.jsx(it,{}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ie,{className:"text-xs",children:"Orientação"}),o.jsx("div",{className:"flex gap-2",children:nN.map(r=>o.jsx("button",{type:"button",onClick:()=>t({stepIndicatorOrientation:r.value}),className:`flex-1 text-xs px-2 py-1.5 rounded-md border transition-colors ${e.stepIndicatorOrientation===r.value?"border-primary bg-primary/10 text-primary font-medium":"border-border bg-muted/30 text-muted-foreground hover:bg-muted/60"}`,children:r.label},r.value))}),!e.stepIndicatorOrientation&&o.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Herdado do template"})]}),o.jsx(it,{}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ie,{className:"text-xs",children:"Posição (desktop)"}),o.jsx("div",{className:"flex gap-2",children:rN.map(r=>o.jsx("button",{type:"button",onClick:()=>t({stepIndicatorPosition:r.value}),className:`flex-1 text-xs px-2 py-1.5 rounded-md border transition-colors ${e.stepIndicatorPosition===r.value?"border-primary bg-primary/10 text-primary font-medium":"border-border bg-muted/30 text-muted-foreground hover:bg-muted/60"}`,children:r.label},r.value))}),!e.stepIndicatorPosition&&o.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Herdado do template"})]})]})},oN=()=>{const{selectedId:e,getConfig:t,updateConfig:r,getAllFieldIds:n}=gt();if(!e)return o.jsxs("div",{className:"rounded-xl border bg-card p-4 space-y-4 max-h-[calc(100vh-160px)] overflow-y-auto",children:[o.jsx("div",{className:"flex items-center justify-between",children:o.jsx("h3",{className:"text-sm font-bold text-foreground",children:"Formulário"})}),o.jsx(it,{}),o.jsx(aN,{})]});const a=t(e),s=He(e),i=c=>r(e,c),l=n().filter(c=>c!==e);return o.jsxs("div",{className:"rounded-xl border bg-card p-4 space-y-4 max-h-[calc(100vh-160px)] overflow-y-auto",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("h3",{className:"text-sm font-bold text-foreground",children:s==="step"?"Step":s==="container"?"Container":"Campo"}),o.jsx("span",{className:"text-[10px] font-mono text-muted-foreground",children:e})]}),o.jsx(it,{}),s==="step"&&o.jsx(LC,{config:a,onUpdate:i}),s==="container"&&o.jsx(VC,{config:a,onUpdate:i}),s==="field"&&o.jsx(QC,{config:a,selectedId:e,allFieldIds:l,getFieldLabel:c=>t(c).label||c,onUpdate:i})]})};var ga=e=>e.type==="checkbox",Zr=e=>e instanceof Date,bt=e=>e==null;const Jh=e=>typeof e=="object";var tt=e=>!bt(e)&&!Array.isArray(e)&&Jh(e)&&!Zr(e),Qh=e=>tt(e)&&e.target?ga(e.target)?e.target.checked:e.target.value:e,sN=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,ex=(e,t)=>e.has(sN(t)),iN=e=>{const t=e.constructor&&e.constructor.prototype;return tt(t)&&t.hasOwnProperty("isPrototypeOf")},Cl=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Le(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(Cl&&(e instanceof Blob||t))return e;const r=Array.isArray(e);if(!r&&!(tt(e)&&iN(e)))return e;const n=r?[]:Object.create(Object.getPrototypeOf(e));for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=Le(e[a]));return n}var Xo=e=>/^\w*$/.test(e),Oe=e=>e===void 0,Zo=e=>Array.isArray(e)?e.filter(Boolean):[],Nl=e=>Zo(e.replace(/["|']|\]/g,"").split(/\.|\[/)),ae=(e,t,r)=>{if(!t||!tt(e))return r;const n=(Xo(t)?[t]:Nl(t)).reduce((a,s)=>bt(a)?a:a[s],e);return Oe(n)||n===e?Oe(e[t])?r:e[t]:n},$t=e=>typeof e=="boolean",ht=e=>typeof e=="function",_e=(e,t,r)=>{let n=-1;const a=Xo(t)?[t]:Nl(t),s=a.length,i=s-1;for(;++n<s;){const l=a[n];let c=r;if(n!==i){const d=e[l];c=tt(d)||Array.isArray(d)?d:isNaN(+a[n+1])?{}:[]}if(l==="__proto__"||l==="constructor"||l==="prototype")return;e[l]=c,e=e[l]}};const ao={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},zt={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},gr={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Sl=N.createContext(null);Sl.displayName="HookFormControlContext";const Ko=()=>N.useContext(Sl);var tx=(e,t,r,n=!0)=>{const a={defaultValues:t._defaultValues};for(const s in e)Object.defineProperty(a,s,{get:()=>{const i=s;return t._proxyFormState[i]!==zt.all&&(t._proxyFormState[i]=!n||zt.all),r&&(r[i]=!0),e[i]}});return a};const Yo=typeof window<"u"?N.useLayoutEffect:N.useEffect;function rx(e){const t=Ko(),{control:r=t,disabled:n,name:a,exact:s}=e||{},[i,l]=N.useState(r._formState),c=N.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Yo(()=>r._subscribe({name:a,formState:c.current,exact:s,callback:d=>{!n&&l({...r._formState,...d})}}),[a,n,s]),N.useEffect(()=>{c.current.isValid&&r._setValid(!0)},[r]),N.useMemo(()=>tx(i,r,c.current,!1),[i,r])}var Dt=e=>typeof e=="string",pi=(e,t,r,n,a)=>Dt(e)?(n&&t.watch.add(e),ae(r,e,a)):Array.isArray(e)?e.map(s=>(n&&t.watch.add(s),ae(r,s))):(n&&(t.watchAll=!0),r),fi=e=>bt(e)||!Jh(e);function Kt(e,t,r=new WeakSet){if(fi(e)||fi(t))return Object.is(e,t);if(Zr(e)&&Zr(t))return Object.is(e.getTime(),t.getTime());const n=Object.keys(e),a=Object.keys(t);if(n.length!==a.length)return!1;if(r.has(e)||r.has(t))return!0;r.add(e),r.add(t);for(const s of n){const i=e[s];if(!a.includes(s))return!1;if(s!=="ref"){const l=t[s];if(Zr(i)&&Zr(l)||tt(i)&&tt(l)||Array.isArray(i)&&Array.isArray(l)?!Kt(i,l,r):!Object.is(i,l))return!1}}return!0}function Mn(e){const t=Ko(),{control:r=t,name:n,defaultValue:a,disabled:s,exact:i,compute:l}=e||{},c=N.useRef(a),d=N.useRef(l),u=N.useRef(void 0),m=N.useRef(r),p=N.useRef(n);d.current=l;const[f,b]=N.useState(()=>{const w=r._getWatch(n,c.current);return d.current?d.current(w):w}),h=N.useCallback(w=>{const C=pi(n,r._names,w||r._formValues,!1,c.current);return d.current?d.current(C):C},[r._formValues,r._names,n]),x=N.useCallback(w=>{if(!s){const C=pi(n,r._names,w||r._formValues,!1,c.current);if(d.current){const S=d.current(C);Kt(S,u.current)||(b(S),u.current=S)}else b(C)}},[r._formValues,r._names,s,n]);Yo(()=>((m.current!==r||!Kt(p.current,n))&&(m.current=r,p.current=n,x()),r._subscribe({name:n,formState:{values:!0},exact:i,callback:w=>{x(w.values)}})),[r,i,n,x]),N.useEffect(()=>r._removeUnmounted());const y=m.current!==r,v=p.current,j=N.useMemo(()=>{if(s)return null;const w=!y&&!Kt(v,n);return y||w?h():null},[s,y,n,v,h]);return j!==null?j:f}function Me(e){const t=Ko(),{name:r,disabled:n,control:a=t,shouldUnregister:s,defaultValue:i,exact:l=!0}=e,c=ex(a._names.array,r),d=N.useMemo(()=>ae(a._formValues,r,ae(a._defaultValues,r,i)),[a,r,i]),u=Mn({control:a,name:r,defaultValue:d,exact:l}),m=rx({control:a,name:r,exact:l}),p=N.useRef(e),f=N.useRef(void 0),b=N.useRef(a.register(r,{...e.rules,value:u,...$t(e.disabled)?{disabled:e.disabled}:{}}));p.current=e;const h=N.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!ae(m.errors,r)},isDirty:{enumerable:!0,get:()=>!!ae(m.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!ae(m.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!ae(m.validatingFields,r)},error:{enumerable:!0,get:()=>ae(m.errors,r)}}),[m,r]),x=N.useCallback(w=>b.current.onChange({target:{value:Qh(w),name:r},type:ao.CHANGE}),[r]),y=N.useCallback(()=>b.current.onBlur({target:{value:ae(a._formValues,r),name:r},type:ao.BLUR}),[r,a._formValues]),v=N.useCallback(w=>{const C=ae(a._fields,r);C&&C._f&&w&&(C._f.ref={focus:()=>ht(w.focus)&&w.focus(),select:()=>ht(w.select)&&w.select(),setCustomValidity:S=>ht(w.setCustomValidity)&&w.setCustomValidity(S),reportValidity:()=>ht(w.reportValidity)&&w.reportValidity()})},[a._fields,r]),j=N.useMemo(()=>({name:r,value:u,...$t(n)||m.disabled?{disabled:m.disabled||n}:{},onChange:x,onBlur:y,ref:v}),[r,n,m.disabled,x,y,v,u]);return N.useEffect(()=>{const w=a._options.shouldUnregister||s,C=f.current;C&&C!==r&&!c&&a.unregister(C),a.register(r,{...p.current.rules,...$t(p.current.disabled)?{disabled:p.current.disabled}:{}});const S=($,k)=>{const E=ae(a._fields,$);E&&E._f&&(E._f.mount=k)};if(S(r,!0),w){const $=Le(ae(a._options.defaultValues,r,p.current.defaultValue));_e(a._defaultValues,r,$),Oe(ae(a._formValues,r))&&_e(a._formValues,r,$)}return!c&&a.register(r),f.current=r,()=>{(c?w&&!a._state.action:w)?a.unregister(r):S(r,!1)}},[r,a,c,s]),N.useEffect(()=>{a._setDisabledField({disabled:n,name:r})},[n,r,a]),N.useMemo(()=>({field:j,formState:m,fieldState:h}),[j,m,h])}const $l=N.createContext(null);$l.displayName="HookFormContext";const lN=()=>N.useContext($l),cN=e=>{const{children:t,watch:r,getValues:n,getFieldState:a,setError:s,clearErrors:i,setValue:l,trigger:c,formState:d,resetField:u,reset:m,handleSubmit:p,unregister:f,control:b,register:h,setFocus:x,subscribe:y}=e;return N.createElement($l.Provider,{value:N.useMemo(()=>({watch:r,getValues:n,getFieldState:a,setError:s,clearErrors:i,setValue:l,trigger:c,formState:d,resetField:u,reset:m,handleSubmit:p,unregister:f,control:b,register:h,setFocus:x,subscribe:y}),[i,b,d,a,n,p,h,m,u,s,x,l,y,c,f,r])},N.createElement(Sl.Provider,{value:b},t))};var dN=(e,t,r,n,a)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[n]:a||!0}}:{},yt=e=>Array.isArray(e)?e:[e],vd=()=>{let e=[];return{get observers(){return e},next:t=>{for(const r of e)r.next&&r.next(t)},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter(r=>r!==t)}}),unsubscribe:()=>{e=[]}}};function nx(e,t){const r={};for(const n in e)if(e.hasOwnProperty(n)){const a=e[n],s=t[n];if(a&&tt(a)&&s){const i=nx(a,s);tt(i)&&(r[n]=i)}else e[n]&&(r[n]=s)}return r}var ct=e=>tt(e)&&!Object.keys(e).length,El=e=>e.type==="file",oo=e=>{if(!Cl)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},ax=e=>e.type==="select-multiple",Dl=e=>e.type==="radio",uN=e=>Dl(e)||ga(e),$s=e=>oo(e)&&e.isConnected;function mN(e,t){const r=t.slice(0,-1).length;let n=0;for(;n<r;)e=Oe(e)?n++:e[t[n++]];return e}function pN(e){for(const t in e)if(e.hasOwnProperty(t)&&!Oe(e[t]))return!1;return!0}function Be(e,t){const r=Array.isArray(t)?t:Xo(t)?[t]:Nl(t),n=r.length===1?e:mN(e,r),a=r.length-1,s=r[a];return n&&delete n[s],a!==0&&(tt(n)&&ct(n)||Array.isArray(n)&&pN(n))&&Be(e,r.slice(0,-1)),e}var fN=e=>{for(const t in e)if(ht(e[t]))return!0;return!1};function ox(e){return Array.isArray(e)||tt(e)&&!fN(e)}function hi(e,t={}){for(const r in e){const n=e[r];ox(n)?(t[r]=Array.isArray(n)?[]:{},hi(n,t[r])):Oe(n)||(t[r]=!0)}return t}function vn(e,t,r){r||(r=hi(t));for(const n in e){const a=e[n];if(ox(a))Oe(t)||fi(r[n])?r[n]=hi(a,Array.isArray(a)?[]:{}):vn(a,bt(t)?{}:t[n],r[n]);else{const s=t[n];r[n]=!Kt(a,s)}}return r}const bd={value:!1,isValid:!1},yd={value:!0,isValid:!0};var sx=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(r=>r&&r.checked&&!r.disabled).map(r=>r.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Oe(e[0].attributes.value)?Oe(e[0].value)||e[0].value===""?yd:{value:e[0].value,isValid:!0}:yd:bd}return bd},ix=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:n})=>Oe(e)?e:t?e===""?NaN:e&&+e:r&&Dt(e)?new Date(e):n?n(e):e;const wd={isValid:!1,value:null};var lx=e=>Array.isArray(e)?e.reduce((t,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:t,wd):wd;function jd(e){const t=e.ref;return El(t)?t.files:Dl(t)?lx(e.refs).value:ax(t)?[...t.selectedOptions].map(({value:r})=>r):ga(t)?sx(e.refs).value:ix(Oe(t.value)?e.ref.value:t.value,e)}var hN=(e,t,r,n)=>{const a={};for(const s of e){const i=ae(t,s);i&&_e(a,s,i._f)}return{criteriaMode:r,names:[...e],fields:a,shouldUseNativeValidation:n}},so=e=>e instanceof RegExp,Gn=e=>Oe(e)?e:so(e)?e.source:tt(e)?so(e.value)?e.value.source:e.value:e,wn=e=>({isOnSubmit:!e||e===zt.onSubmit,isOnBlur:e===zt.onBlur,isOnChange:e===zt.onChange,isOnAll:e===zt.all,isOnTouch:e===zt.onTouched});const kd="AsyncFunction";var xN=e=>!!e&&!!e.validate&&!!(ht(e.validate)&&e.validate.constructor.name===kd||tt(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===kd)),gN=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),xi=(e,t,r)=>!r&&(t.watchAll||t.watch.has(e)||[...t.watch].some(n=>e.startsWith(n)&&/^\.\w+/.test(e.slice(n.length))));const Sn=(e,t,r,n)=>{for(const a of r||Object.keys(e)){const s=ae(e,a);if(s){const{_f:i,...l}=s;if(i){if(i.refs&&i.refs[0]&&t(i.refs[0],a)&&!n||i.ref&&t(i.ref,i.name)&&!n)return!0;if(Sn(l,t))break}else if(tt(l)&&Sn(l,t))break}}};function Cd(e,t,r){const n=ae(e,r);if(n||Xo(r))return{error:n,name:r};const a=r.split(".");for(;a.length;){const s=a.join("."),i=ae(t,s),l=ae(e,s);if(i&&!Array.isArray(i)&&r!==s)return{name:r};if(l&&l.type)return{name:s,error:l};if(l&&l.root&&l.root.type)return{name:`${s}.root`,error:l.root};a.pop()}return{name:r}}var vN=(e,t,r,n)=>{r(e);const{name:a,...s}=e;return ct(s)||Object.keys(s).length>=Object.keys(t).length||Object.keys(s).find(i=>t[i]===(!n||zt.all))},bN=(e,t,r)=>!e||!t||e===t||yt(e).some(n=>n&&(r?n===t:n.startsWith(t)||t.startsWith(n))),yN=(e,t,r,n,a)=>a.isOnAll?!1:!r&&a.isOnTouch?!(t||e):(r?n.isOnBlur:a.isOnBlur)?!e:(r?n.isOnChange:a.isOnChange)?e:!0,wN=(e,t)=>!Zo(ae(e,t)).length&&Be(e,t),cx=(e,t,r)=>{const n=yt(ae(e,r));return _e(n,"root",t[r]),_e(e,r,n),e};function Nd(e,t,r="validate"){if(Dt(e)||Array.isArray(e)&&e.every(Dt)||$t(e)&&!e)return{type:r,message:Dt(e)?e:"",ref:t}}var hn=e=>tt(e)&&!so(e)?e:{value:e,message:""},gi=async(e,t,r,n,a,s)=>{const{ref:i,refs:l,required:c,maxLength:d,minLength:u,min:m,max:p,pattern:f,validate:b,name:h,valueAsNumber:x,mount:y}=e._f,v=ae(r,h);if(!y||t.has(h))return{};const j=l?l[0]:i,w=L=>{a&&j.reportValidity&&(j.setCustomValidity($t(L)?"":L||""),j.reportValidity())},C={},S=Dl(i),$=ga(i),k=S||$,E=(x||El(i))&&Oe(i.value)&&Oe(v)||oo(i)&&i.value===""||v===""||Array.isArray(v)&&!v.length,D=dN.bind(null,h,n,C),O=(L,A,z,X=gr.maxLength,q=gr.minLength)=>{const Z=L?A:z;C[h]={type:L?X:q,message:Z,ref:i,...D(L?X:q,Z)}};if(s?!Array.isArray(v)||!v.length:c&&(!k&&(E||bt(v))||$t(v)&&!v||$&&!sx(l).isValid||S&&!lx(l).isValid)){const{value:L,message:A}=Dt(c)?{value:!!c,message:c}:hn(c);if(L&&(C[h]={type:gr.required,message:A,ref:j,...D(gr.required,A)},!n))return w(A),C}if(!E&&(!bt(m)||!bt(p))){let L,A;const z=hn(p),X=hn(m);if(!bt(v)&&!isNaN(v)){const q=i.valueAsNumber||v&&+v;bt(z.value)||(L=q>z.value),bt(X.value)||(A=q<X.value)}else{const q=i.valueAsDate||new Date(v),Z=P=>new Date(new Date().toDateString()+" "+P),V=i.type=="time",M=i.type=="week";Dt(z.value)&&v&&(L=V?Z(v)>Z(z.value):M?v>z.value:q>new Date(z.value)),Dt(X.value)&&v&&(A=V?Z(v)<Z(X.value):M?v<X.value:q<new Date(X.value))}if((L||A)&&(O(!!L,z.message,X.message,gr.max,gr.min),!n))return w(C[h].message),C}if((d||u)&&!E&&(Dt(v)||s&&Array.isArray(v))){const L=hn(d),A=hn(u),z=!bt(L.value)&&v.length>+L.value,X=!bt(A.value)&&v.length<+A.value;if((z||X)&&(O(z,L.message,A.message),!n))return w(C[h].message),C}if(f&&!E&&Dt(v)){const{value:L,message:A}=hn(f);if(so(L)&&!v.match(L)&&(C[h]={type:gr.pattern,message:A,ref:i,...D(gr.pattern,A)},!n))return w(A),C}if(b){if(ht(b)){const L=await b(v,r),A=Nd(L,j);if(A&&(C[h]={...A,...D(gr.validate,A.message)},!n))return w(A.message),C}else if(tt(b)){let L={};for(const A in b){if(!ct(L)&&!n)break;const z=Nd(await b[A](v,r),j,A);z&&(L={...z,...D(A,z.message)},w(z.message),n&&(C[h]=L))}if(!ct(L)&&(C[h]={ref:j,...L},!n))return C}}return w(!0),C};const jN={mode:zt.onSubmit,reValidateMode:zt.onChange,shouldFocusError:!0};function kN(e={}){let t={...jN,...e},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:ht(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},n={},a=tt(t.defaultValues)||tt(t.values)?Le(t.defaultValues||t.values)||{}:{},s=t.shouldUnregister?{}:Le(a),i={action:!1,mount:!1,watch:!1,keepIsValid:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},c,d=0;const u={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},m={...u};let p={...m};const f={array:vd(),state:vd()},b=t.criteriaMode===zt.all,h=I=>F=>{clearTimeout(d),d=setTimeout(I,F)},x=async I=>{if(!i.keepIsValid&&!t.disabled&&(m.isValid||p.isValid||I)){let F;t.resolver?(F=ct((await k()).errors),y()):F=await D(n,!0),F!==r.isValid&&f.state.next({isValid:F})}},y=(I,F)=>{!t.disabled&&(m.isValidating||m.validatingFields||p.isValidating||p.validatingFields)&&((I||Array.from(l.mount)).forEach(B=>{B&&(F?_e(r.validatingFields,B,F):Be(r.validatingFields,B))}),f.state.next({validatingFields:r.validatingFields,isValidating:!ct(r.validatingFields)}))},v=(I,F=[],B,le,oe=!0,re=!0)=>{if(le&&B&&!t.disabled){if(i.action=!0,re&&Array.isArray(ae(n,I))){const ye=B(ae(n,I),le.argA,le.argB);oe&&_e(n,I,ye)}if(re&&Array.isArray(ae(r.errors,I))){const ye=B(ae(r.errors,I),le.argA,le.argB);oe&&_e(r.errors,I,ye),wN(r.errors,I)}if((m.touchedFields||p.touchedFields)&&re&&Array.isArray(ae(r.touchedFields,I))){const ye=B(ae(r.touchedFields,I),le.argA,le.argB);oe&&_e(r.touchedFields,I,ye)}(m.dirtyFields||p.dirtyFields)&&(r.dirtyFields=vn(a,s)),f.state.next({name:I,isDirty:L(I,F),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else _e(s,I,F)},j=(I,F)=>{_e(r.errors,I,F),f.state.next({errors:r.errors})},w=I=>{r.errors=I,f.state.next({errors:r.errors,isValid:!1})},C=(I,F,B,le)=>{const oe=ae(n,I);if(oe){const re=ae(s,I,Oe(B)?ae(a,I):B);Oe(re)||le&&le.defaultChecked||F?_e(s,I,F?re:jd(oe._f)):X(I,re),i.mount&&!i.action&&x()}},S=(I,F,B,le,oe)=>{let re=!1,ye=!1;const Re={name:I};if(!t.disabled){if(!B||le){(m.isDirty||p.isDirty)&&(ye=r.isDirty,r.isDirty=Re.isDirty=L(),re=ye!==Re.isDirty);const Ie=Kt(ae(a,I),F);ye=!!ae(r.dirtyFields,I),Ie?Be(r.dirtyFields,I):_e(r.dirtyFields,I,!0),Re.dirtyFields=r.dirtyFields,re=re||(m.dirtyFields||p.dirtyFields)&&ye!==!Ie}if(B){const Ie=ae(r.touchedFields,I);Ie||(_e(r.touchedFields,I,B),Re.touchedFields=r.touchedFields,re=re||(m.touchedFields||p.touchedFields)&&Ie!==B)}re&&oe&&f.state.next(Re)}return re?Re:{}},$=(I,F,B,le)=>{const oe=ae(r.errors,I),re=(m.isValid||p.isValid)&&$t(F)&&r.isValid!==F;if(t.delayError&&B?(c=h(()=>j(I,B)),c(t.delayError)):(clearTimeout(d),c=null,B?_e(r.errors,I,B):Be(r.errors,I)),(B?!Kt(oe,B):oe)||!ct(le)||re){const ye={...le,...re&&$t(F)?{isValid:F}:{},errors:r.errors,name:I};r={...r,...ye},f.state.next(ye)}},k=async I=>(y(I,!0),await t.resolver(s,t.context,hN(I||l.mount,n,t.criteriaMode,t.shouldUseNativeValidation))),E=async I=>{const{errors:F}=await k(I);if(y(I),I)for(const B of I){const le=ae(F,B);le?_e(r.errors,B,le):Be(r.errors,B)}else r.errors=F;return F},D=async(I,F,B={valid:!0})=>{for(const le in I){const oe=I[le];if(oe){const{_f:re,...ye}=oe;if(re){const Re=l.array.has(re.name),Ie=oe._f&&xN(oe._f);Ie&&m.validatingFields&&y([re.name],!0);const ot=await gi(oe,l.disabled,s,b,t.shouldUseNativeValidation&&!F,Re);if(Ie&&m.validatingFields&&y([re.name]),ot[re.name]&&(B.valid=!1,F||e.shouldUseNativeValidation))break;!F&&(ae(ot,re.name)?Re?cx(r.errors,ot,re.name):_e(r.errors,re.name,ot[re.name]):Be(r.errors,re.name))}!ct(ye)&&await D(ye,F,B)}}return B.valid},O=()=>{for(const I of l.unMount){const F=ae(n,I);F&&(F._f.refs?F._f.refs.every(B=>!$s(B)):!$s(F._f.ref))&&ne(I)}l.unMount=new Set},L=(I,F)=>!t.disabled&&(I&&F&&_e(s,I,F),!Kt(se(),a)),A=(I,F,B)=>pi(I,l,{...i.mount?s:Oe(F)?a:Dt(I)?{[I]:F}:F},B,F),z=I=>Zo(ae(i.mount?s:a,I,t.shouldUnregister?ae(a,I,[]):[])),X=(I,F,B={})=>{const le=ae(n,I);let oe=F;if(le){const re=le._f;re&&(!re.disabled&&_e(s,I,ix(F,re)),oe=oo(re.ref)&&bt(F)?"":F,ax(re.ref)?[...re.ref.options].forEach(ye=>ye.selected=oe.includes(ye.value)):re.refs?ga(re.ref)?re.refs.forEach(ye=>{(!ye.defaultChecked||!ye.disabled)&&(Array.isArray(oe)?ye.checked=!!oe.find(Re=>Re===ye.value):ye.checked=oe===ye.value||!!oe)}):re.refs.forEach(ye=>ye.checked=ye.value===oe):El(re.ref)?re.ref.value="":(re.ref.value=oe,re.ref.type||f.state.next({name:I,values:Le(s)})))}(B.shouldDirty||B.shouldTouch)&&S(I,oe,B.shouldTouch,B.shouldDirty,!0),B.shouldValidate&&P(I)},q=(I,F,B)=>{for(const le in F){if(!F.hasOwnProperty(le))return;const oe=F[le],re=I+"."+le,ye=ae(n,re);(l.array.has(I)||tt(oe)||ye&&!ye._f)&&!Zr(oe)?q(re,oe,B):X(re,oe,B)}},Z=(I,F,B={})=>{const le=ae(n,I),oe=l.array.has(I),re=Le(F);_e(s,I,re),oe?(f.array.next({name:I,values:Le(s)}),(m.isDirty||m.dirtyFields||p.isDirty||p.dirtyFields)&&B.shouldDirty&&f.state.next({name:I,dirtyFields:vn(a,s),isDirty:L(I,re)})):le&&!le._f&&!bt(re)?q(I,re,B):X(I,re,B),xi(I,l)?f.state.next({...r,name:I,values:Le(s)}):f.state.next({name:i.mount?I:void 0,values:Le(s)})},V=async I=>{i.mount=!0;const F=I.target;let B=F.name,le=!0;const oe=ae(n,B),re=Ie=>{le=Number.isNaN(Ie)||Zr(Ie)&&isNaN(Ie.getTime())||Kt(Ie,ae(s,B,Ie))},ye=wn(t.mode),Re=wn(t.reValidateMode);if(oe){let Ie,ot;const tr=F.type?jd(oe._f):Qh(I),rr=I.type===ao.BLUR||I.type===ao.FOCUS_OUT,Qo=!gN(oe._f)&&!t.resolver&&!ae(r.errors,B)&&!oe._f.deps||yN(rr,ae(r.touchedFields,B),r.isSubmitted,Re,ye),Vn=xi(B,l,rr);_e(s,B,tr),rr?(!F||!F.readOnly)&&(oe._f.onBlur&&oe._f.onBlur(I),c&&c(0)):oe._f.onChange&&oe._f.onChange(I);const Bn=S(B,tr,rr),es=!ct(Bn)||Vn;if(!rr&&f.state.next({name:B,type:I.type,values:Le(s)}),Qo)return(m.isValid||p.isValid)&&(t.mode==="onBlur"?rr&&x():rr||x()),es&&f.state.next({name:B,...Vn?{}:Bn});if(!rr&&Vn&&f.state.next({...r}),t.resolver){const{errors:ya}=await k([B]);if(y([B]),re(tr),le){const ts=Cd(r.errors,n,B),sn=Cd(ya,n,ts.name||B);Ie=sn.error,B=sn.name,ot=ct(ya)}}else y([B],!0),Ie=(await gi(oe,l.disabled,s,b,t.shouldUseNativeValidation))[B],y([B]),re(tr),le&&(Ie?ot=!1:(m.isValid||p.isValid)&&(ot=await D(n,!0)));le&&(oe._f.deps&&(!Array.isArray(oe._f.deps)||oe._f.deps.length>0)&&P(oe._f.deps),$(B,ot,Ie,Bn))}},M=(I,F)=>{if(ae(r.errors,F)&&I.focus)return I.focus(),1},P=async(I,F={})=>{let B,le;const oe=yt(I);if(t.resolver){const re=await E(Oe(I)?I:oe);B=ct(re),le=I?!oe.some(ye=>ae(re,ye)):B}else I?(le=(await Promise.all(oe.map(async re=>{const ye=ae(n,re);return await D(ye&&ye._f?{[re]:ye}:ye)}))).every(Boolean),!(!le&&!r.isValid)&&x()):le=B=await D(n);return f.state.next({...!Dt(I)||(m.isValid||p.isValid)&&B!==r.isValid?{}:{name:I},...t.resolver||!I?{isValid:B}:{},errors:r.errors}),F.shouldFocus&&!le&&Sn(n,M,I?oe:l.mount),le},se=(I,F)=>{let B={...i.mount?s:a};return F&&(B=nx(F.dirtyFields?r.dirtyFields:r.touchedFields,B)),Oe(I)?B:Dt(I)?ae(B,I):I.map(le=>ae(B,le))},U=(I,F)=>({invalid:!!ae((F||r).errors,I),isDirty:!!ae((F||r).dirtyFields,I),error:ae((F||r).errors,I),isValidating:!!ae(r.validatingFields,I),isTouched:!!ae((F||r).touchedFields,I)}),Q=I=>{const F=I?yt(I):void 0;F==null||F.forEach(B=>Be(r.errors,B)),F?F.forEach(B=>{f.state.next({name:B,errors:r.errors})}):f.state.next({errors:{}})},Y=(I,F,B)=>{const le=(ae(n,I,{_f:{}})._f||{}).ref,oe=ae(r.errors,I)||{},{ref:re,message:ye,type:Re,...Ie}=oe;_e(r.errors,I,{...Ie,...F,ref:le}),f.state.next({name:I,errors:r.errors,isValid:!1}),B&&B.shouldFocus&&le&&le.focus&&le.focus()},H=(I,F)=>ht(I)?f.state.subscribe({next:B=>"values"in B&&I(A(void 0,F),B)}):A(I,F,!0),W=I=>f.state.subscribe({next:F=>{bN(I.name,F.name,I.exact)&&vN(F,I.formState||m,Nt,I.reRenderRoot)&&I.callback({values:{...s},...r,...F,defaultValues:a})}}).unsubscribe,G=I=>(i.mount=!0,p={...p,...I.formState},W({...I,formState:{...u,...I.formState}})),ne=(I,F={})=>{for(const B of I?yt(I):l.mount)l.mount.delete(B),l.array.delete(B),F.keepValue||(Be(n,B),Be(s,B)),!F.keepError&&Be(r.errors,B),!F.keepDirty&&Be(r.dirtyFields,B),!F.keepTouched&&Be(r.touchedFields,B),!F.keepIsValidating&&Be(r.validatingFields,B),!t.shouldUnregister&&!F.keepDefaultValue&&Be(a,B);f.state.next({values:Le(s)}),f.state.next({...r,...F.keepDirty?{isDirty:L()}:{}}),!F.keepIsValid&&x()},J=({disabled:I,name:F})=>{if($t(I)&&i.mount||I||l.disabled.has(F)){const B=l.disabled.has(F)!==!!I;I?l.disabled.add(F):l.disabled.delete(F),B&&i.mount&&!i.action&&x()}},te=(I,F={})=>{let B=ae(n,I);const le=$t(F.disabled)||$t(t.disabled);return _e(n,I,{...B||{},_f:{...B&&B._f?B._f:{ref:{name:I}},name:I,mount:!0,...F}}),l.mount.add(I),B?J({disabled:$t(F.disabled)?F.disabled:t.disabled,name:I}):C(I,!0,F.value),{...le?{disabled:F.disabled||t.disabled}:{},...t.progressive?{required:!!F.required,min:Gn(F.min),max:Gn(F.max),minLength:Gn(F.minLength),maxLength:Gn(F.maxLength),pattern:Gn(F.pattern)}:{},name:I,onChange:V,onBlur:V,ref:oe=>{if(oe){te(I,F),B=ae(n,I);const re=Oe(oe.value)&&oe.querySelectorAll&&oe.querySelectorAll("input,select,textarea")[0]||oe,ye=uN(re),Re=B._f.refs||[];if(ye?Re.find(Ie=>Ie===re):re===B._f.ref)return;_e(n,I,{_f:{...B._f,...ye?{refs:[...Re.filter($s),re,...Array.isArray(ae(a,I))?[{}]:[]],ref:{type:re.type,name:I}}:{ref:re}}}),C(I,!1,void 0,re)}else B=ae(n,I,{}),B._f&&(B._f.mount=!1),(t.shouldUnregister||F.shouldUnregister)&&!(ex(l.array,I)&&i.action)&&l.unMount.add(I)}}},ce=()=>t.shouldFocusError&&Sn(n,M,l.mount),be=I=>{$t(I)&&(f.state.next({disabled:I}),Sn(n,(F,B)=>{const le=ae(n,B);le&&(F.disabled=le._f.disabled||I,Array.isArray(le._f.refs)&&le._f.refs.forEach(oe=>{oe.disabled=le._f.disabled||I}))},0,!1))},Ce=(I,F)=>async B=>{let le;B&&(B.preventDefault&&B.preventDefault(),B.persist&&B.persist());let oe=Le(s);if(f.state.next({isSubmitting:!0}),t.resolver){const{errors:re,values:ye}=await k();y(),r.errors=re,oe=Le(ye)}else await D(n);if(l.disabled.size)for(const re of l.disabled)Be(oe,re);if(Be(r.errors,"root"),ct(r.errors)){f.state.next({errors:{}});try{await I(oe,B)}catch(re){le=re}}else F&&await F({...r.errors},B),ce(),setTimeout(ce);if(f.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ct(r.errors)&&!le,submitCount:r.submitCount+1,errors:r.errors}),le)throw le},ve=(I,F={})=>{ae(n,I)&&(Oe(F.defaultValue)?Z(I,Le(ae(a,I))):(Z(I,F.defaultValue),_e(a,I,Le(F.defaultValue))),F.keepTouched||Be(r.touchedFields,I),F.keepDirty||(Be(r.dirtyFields,I),r.isDirty=F.defaultValue?L(I,Le(ae(a,I))):L()),F.keepError||(Be(r.errors,I),m.isValid&&x()),f.state.next({...r}))},me=(I,F={})=>{const B=I?Le(I):a,le=Le(B),oe=ct(I),re=oe?a:le;if(F.keepDefaultValues||(a=B),!F.keepValues){if(F.keepDirtyValues){const ye=new Set([...l.mount,...Object.keys(vn(a,s))]);for(const Re of Array.from(ye)){const Ie=ae(r.dirtyFields,Re),ot=ae(s,Re),tr=ae(re,Re);Ie&&!Oe(ot)?_e(re,Re,ot):!Ie&&!Oe(tr)&&Z(Re,tr)}}else{if(Cl&&Oe(I))for(const ye of l.mount){const Re=ae(n,ye);if(Re&&Re._f){const Ie=Array.isArray(Re._f.refs)?Re._f.refs[0]:Re._f.ref;if(oo(Ie)){const ot=Ie.closest("form");if(ot){ot.reset();break}}}}if(F.keepFieldsRef)for(const ye of l.mount)Z(ye,ae(re,ye));else n={}}s=t.shouldUnregister?F.keepDefaultValues?Le(a):{}:Le(re),f.array.next({values:{...re}}),f.state.next({values:{...re}})}l={mount:F.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},i.mount=!m.isValid||!!F.keepIsValid||!!F.keepDirtyValues||!t.shouldUnregister&&!ct(re),i.watch=!!t.shouldUnregister,i.keepIsValid=!!F.keepIsValid,i.action=!1,F.keepErrors||(r.errors={}),f.state.next({submitCount:F.keepSubmitCount?r.submitCount:0,isDirty:oe?!1:F.keepDirty?r.isDirty:!!(F.keepDefaultValues&&!Kt(I,a)),isSubmitted:F.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:oe?{}:F.keepDirtyValues?F.keepDefaultValues&&s?vn(a,s):r.dirtyFields:F.keepDefaultValues&&I?vn(a,I):F.keepDirty?r.dirtyFields:{},touchedFields:F.keepTouched?r.touchedFields:{},errors:F.keepErrors?r.errors:{},isSubmitSuccessful:F.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:a})},Ee=(I,F)=>me(ht(I)?I(s):I,{...t.resetOptions,...F}),Fe=(I,F={})=>{const B=ae(n,I),le=B&&B._f;if(le){const oe=le.refs?le.refs[0]:le.ref;oe.focus&&setTimeout(()=>{oe.focus(),F.shouldSelect&&ht(oe.select)&&oe.select()})}},Nt=I=>{r={...r,...I}},dt={control:{register:te,unregister:ne,getFieldState:U,handleSubmit:Ce,setError:Y,_subscribe:W,_runSchema:k,_updateIsValidating:y,_focusError:ce,_getWatch:A,_getDirty:L,_setValid:x,_setFieldArray:v,_setDisabledField:J,_setErrors:w,_getFieldArray:z,_reset:me,_resetDefaultValues:()=>ht(t.defaultValues)&&t.defaultValues().then(I=>{Ee(I,t.resetOptions),f.state.next({isLoading:!1})}),_removeUnmounted:O,_disableForm:be,_subjects:f,_proxyFormState:m,get _fields(){return n},get _formValues(){return s},get _state(){return i},set _state(I){i=I},get _defaultValues(){return a},get _names(){return l},set _names(I){l=I},get _formState(){return r},get _options(){return t},set _options(I){t={...t,...I}}},subscribe:G,trigger:P,register:te,handleSubmit:Ce,watch:H,setValue:Z,getValues:se,reset:Ee,resetField:ve,clearErrors:Q,unregister:ne,setError:Y,setFocus:Fe,getFieldState:U};return{...dt,formControl:dt}}var Tr=()=>{if(typeof crypto<"u"&&crypto.randomUUID)return crypto.randomUUID();const e=typeof performance>"u"?Date.now():performance.now()*1e3;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const r=(Math.random()*16+e)%16|0;return(t=="x"?r:r&3|8).toString(16)})},Es=(e,t,r={})=>r.shouldFocus||Oe(r.shouldFocus)?r.focusName||`${e}.${Oe(r.focusIndex)?t:r.focusIndex}.`:"",Ds=(e,t)=>[...e,...yt(t)],Ts=e=>Array.isArray(e)?e.map(()=>{}):void 0;function As(e,t,r){return[...e.slice(0,t),...yt(r),...e.slice(t)]}var Rs=(e,t,r)=>Array.isArray(e)?(Oe(e[r])&&(e[r]=void 0),e.splice(r,0,e.splice(t,1)[0]),e):[],Is=(e,t)=>[...yt(t),...yt(e)];function CN(e,t){let r=0;const n=[...e];for(const a of t)n.splice(a-r,1),r++;return Zo(n).length?n:[]}var Ps=(e,t)=>Oe(t)?[]:CN(e,yt(t).sort((r,n)=>r-n)),_s=(e,t,r)=>{[e[t],e[r]]=[e[r],e[t]]},Sd=(e,t,r)=>(e[t]=r,e);function dx(e){const t=Ko(),{control:r=t,name:n,keyName:a="id",shouldUnregister:s,rules:i}=e,[l,c]=N.useState(r._getFieldArray(n)),d=N.useRef(r._getFieldArray(n).map(Tr)),u=N.useRef(!1);r._names.array.add(n),N.useMemo(()=>i&&l.length>=0&&r.register(n,i),[r,n,l.length,i]),Yo(()=>r._subjects.array.subscribe({next:({values:w,name:C})=>{if(C===n||!C){const S=ae(w,n);Array.isArray(S)&&(c(S),d.current=S.map(Tr))}}}).unsubscribe,[r,n]);const m=N.useCallback(w=>{u.current=!0,r._setFieldArray(n,w)},[r,n]),p=(w,C)=>{const S=yt(Le(w)),$=Ds(r._getFieldArray(n),S);r._names.focus=Es(n,$.length-1,C),d.current=Ds(d.current,S.map(Tr)),m($),c($),r._setFieldArray(n,$,Ds,{argA:Ts(w)})},f=(w,C)=>{const S=yt(Le(w)),$=Is(r._getFieldArray(n),S);r._names.focus=Es(n,0,C),d.current=Is(d.current,S.map(Tr)),m($),c($),r._setFieldArray(n,$,Is,{argA:Ts(w)})},b=w=>{const C=Ps(r._getFieldArray(n),w);d.current=Ps(d.current,w),m(C),c(C),!Array.isArray(ae(r._fields,n))&&_e(r._fields,n,void 0),r._setFieldArray(n,C,Ps,{argA:w})},h=(w,C,S)=>{const $=yt(Le(C)),k=As(r._getFieldArray(n),w,$);r._names.focus=Es(n,w,S),d.current=As(d.current,w,$.map(Tr)),m(k),c(k),r._setFieldArray(n,k,As,{argA:w,argB:Ts(C)})},x=(w,C)=>{const S=r._getFieldArray(n);_s(S,w,C),_s(d.current,w,C),m(S),c(S),r._setFieldArray(n,S,_s,{argA:w,argB:C},!1)},y=(w,C)=>{const S=r._getFieldArray(n);Rs(S,w,C),Rs(d.current,w,C),m(S),c(S),r._setFieldArray(n,S,Rs,{argA:w,argB:C},!1)},v=(w,C)=>{const S=Le(C),$=Sd(r._getFieldArray(n),w,S);d.current=[...$].map((k,E)=>!k||E===w?Tr():d.current[E]),m($),c([...$]),r._setFieldArray(n,$,Sd,{argA:w,argB:S},!0,!1)},j=w=>{const C=yt(Le(w));d.current=C.map(Tr),m([...C]),c([...C]),r._setFieldArray(n,[...C],S=>S,{},!0,!1)};return N.useEffect(()=>{if(r._state.action=!1,xi(n,r._names)&&r._subjects.state.next({...r._formState}),u.current&&(!wn(r._options.mode).isOnSubmit||r._formState.isSubmitted)&&!wn(r._options.reValidateMode).isOnSubmit)if(r._options.resolver)r._runSchema([n]).then(w=>{r._updateIsValidating([n]);const C=ae(w.errors,n),S=ae(r._formState.errors,n);(S?!C&&S.type||C&&(S.type!==C.type||S.message!==C.message):C&&C.type)&&(C?_e(r._formState.errors,n,C):Be(r._formState.errors,n),r._subjects.state.next({errors:r._formState.errors}))});else{const w=ae(r._fields,n);w&&w._f&&!(wn(r._options.reValidateMode).isOnSubmit&&wn(r._options.mode).isOnSubmit)&&gi(w,r._names.disabled,r._formValues,r._options.criteriaMode===zt.all,r._options.shouldUseNativeValidation,!0).then(C=>!ct(C)&&r._subjects.state.next({errors:cx(r._formState.errors,C,n)}))}r._subjects.state.next({name:n,values:Le(r._formValues)}),r._names.focus&&Sn(r._fields,(w,C)=>{if(r._names.focus&&C.startsWith(r._names.focus)&&w.focus)return w.focus(),1}),r._names.focus="",r._setValid(),u.current=!1},[l,n,r]),N.useEffect(()=>(!ae(r._formValues,n)&&r._setFieldArray(n),()=>{const w=(C,S)=>{const $=ae(r._fields,C);$&&$._f&&($._f.mount=S)};r._options.shouldUnregister||s?r.unregister(n):w(n,!1)}),[n,r,a,s]),{swap:N.useCallback(x,[m,n,r]),move:N.useCallback(y,[m,n,r]),prepend:N.useCallback(f,[m,n,r]),append:N.useCallback(p,[m,n,r]),remove:N.useCallback(b,[m,n,r]),insert:N.useCallback(h,[m,n,r]),update:N.useCallback(v,[m,n,r]),replace:N.useCallback(j,[m,n,r]),fields:N.useMemo(()=>l.map((w,C)=>({...w,[a]:d.current[C]||Tr()})),[l,a])}}function NN(e={}){const t=N.useRef(void 0),r=N.useRef(void 0),[n,a]=N.useState({isDirty:!1,isValidating:!1,isLoading:ht(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:ht(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:n},e.defaultValues&&!ht(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:i,...l}=kN(e);t.current={...l,formState:n}}const s=t.current.control;return s._options=e,Yo(()=>{const i=s._subscribe({formState:s._proxyFormState,callback:()=>a({...s._formState}),reRenderRoot:!0});return a(l=>({...l,isReady:!0})),s._formState.isReady=!0,i},[s]),N.useEffect(()=>s._disableForm(e.disabled),[s,e.disabled]),N.useEffect(()=>{e.mode&&(s._options.mode=e.mode),e.reValidateMode&&(s._options.reValidateMode=e.reValidateMode)},[s,e.mode,e.reValidateMode]),N.useEffect(()=>{e.errors&&(s._setErrors(e.errors),s._focusError())},[s,e.errors]),N.useEffect(()=>{e.shouldUnregister&&s._subjects.state.next({values:s._getWatch()})},[s,e.shouldUnregister]),N.useEffect(()=>{if(s._proxyFormState.isDirty){const i=s._getDirty();i!==n.isDirty&&s._subjects.state.next({isDirty:i})}},[s,n.isDirty]),N.useEffect(()=>{var i;e.values&&!Kt(e.values,r.current)?(s._reset(e.values,{keepFieldsRef:!0,...s._options.resetOptions}),!((i=s._options.resetOptions)===null||i===void 0)&&i.keepIsValid||s._setValid(),r.current=e.values,a(l=>({...l}))):s._resetDefaultValues()},[s,e.values]),N.useEffect(()=>{s._state.mount||(s._setValid(),s._state.mount=!0),s._state.watch&&(s._state.watch=!1,s._subjects.state.next({...s._formState})),s._removeUnmounted()}),t.current.formState=N.useMemo(()=>tx(n,s),[s,n]),t.current}var SN=Object.defineProperty,$N=(e,t,r)=>t in e?SN(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,$d=(e,t,r)=>$N(e,typeof t!="symbol"?t+"":t,r);const vi=N.createContext({}),Hr=()=>N.useContext(vi),st=(e,t,r={})=>{if(!e)return!0;if("and"in e||"or"in e){const d="and"in e&&Array.isArray(e.and)&&e.and.length>0,u="or"in e&&Array.isArray(e.or)&&e.or.length>0;return d&&u?(console.warn("[evaluateFieldCondition] FieldConditionGroup com `and` e `or` simultâneos — apenas `and` será avaliado."),e.and.every(m=>st(m,t,r))):d?e.and.every(m=>st(m,t,r)):u?e.or.some(m=>st(m,t,r)):!0}const n=e;if(!n.campoId)return!0;const a=n.source==="evento"?r[n.campoId]:t[n.campoId];if(Array.isArray(a)){const d=n.valor;switch(n.operador){case"contem":return a.includes(d);case"naoContem":return!a.includes(d);case"vazio":return a.length===0;case"naoVazio":return a.length>0;case"igual":return a.length===1&&a[0]===d;case"diferente":return!(a.length===1&&a[0]===d);default:return!0}}const s=a==null||a===!1?"":a===!0?"1":String(a),i=n.valor!==void 0?String(n.valor):"",l=Number(s),c=Number(i);switch(n.operador){case"igual":return s===i;case"diferente":return s!==i;case"vazio":return!s;case"naoVazio":return!!s;case"contem":return s.includes(i);case"naoContem":return!s.includes(i);case"maiorQue":return!isNaN(l)&&!isNaN(c)?l>c:s>i;case"menorQue":return!isNaN(l)&&!isNaN(c)?l<c:s<i;case"maiorOuIgual":return!isNaN(l)&&!isNaN(c)?l>=c:s>=i;case"menorOuIgual":return!isNaN(l)&&!isNaN(c)?l<=c:s<=i;default:return!0}},EN=/^\d{3}\.?\d{3}\.?\d{3}-?\d{2}$/,DN=/^\(?\d{2}\)?\s?\d{4,5}-?\d{4}$/,TN=/^\d{5}-?\d{3}$/,AN=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,RN=e=>{const t=e.replace(/\D/g,"");if(t.length!==11||/^(\d)\1{10}$/.test(t))return!1;const r=n=>{let a=0;for(let i=0;i<n;i++)a+=parseInt(t[i])*(n+1-i);const s=a*10%11;return s>=10?0:s};return r(9)===parseInt(t[9])&&r(10)===parseInt(t[10])},Xn=new Map,IN=e=>{if(Xn.has(e))return Xn.get(e);if(/^\/.*\/[gimsuy]*$/.test(e))return Xn.set(e,null),null;try{const t=new RegExp(e);return Xn.set(e,t),t}catch{return Xn.set(e,null),null}},_a=(e,t,r={})=>{const n=e.validacao;if(e.tipo===T.CHECKBOX||e.tipo===T.SWITCH)return e.obrigatorio&&!t?"Campo obrigatório":void 0;if(e.tipo===T.SLIDER){const s=t!=null&&t!==""?Number(t):NaN;return e.obrigatorio&&isNaN(s)?"Campo obrigatório":isNaN(s)?void 0:(n==null?void 0:n.min)!==void 0&&s<n.min?`Valor mínimo: ${n.min}`:(n==null?void 0:n.max)!==void 0&&s>n.max?`Valor máximo: ${n.max}`:void 0}if(e.tipo===T.RATING){const s=t!==void 0?Number(t):0;return e.obrigatorio&&(!s||s<1)?"Avaliação obrigatória":void 0}if(e.tipo===T.DATE_RANGE){const s=t;if(e.obrigatorio){if(!(s!=null&&s.start))return"Data inicial obrigatória";if(!(s!=null&&s.end))return"Data final obrigatória"}return s!=null&&s.start&&s!=null&&s.end&&s.start>s.end?"A data inicial deve ser menor ou igual à data final":void 0}if(e.tipo===T.PARTICIPATION_TYPE){if(!e.obrigatorio)return;const s=t;return s!=null&&s.tipo?s.tipo==="por_dia"&&!s.data?"Selecione um dia para participar":"genero"in(s??{})&&!(s!=null&&s.genero)?"Selecione o sexo":void 0:"Selecione o tipo de participação"}if(e.tipo===T.CHECKBOX_GROUP){const s=Array.isArray(t)?t:[];return e.obrigatorio&&s.length===0?"Selecione pelo menos uma opção":void 0}if(e.tipo===T.FILE)return e.obrigatorio&&!t?"Arquivo obrigatório":void 0;if(e.tipo===T.TERMS)return e.obrigatorio&&t!=="accepted"?"Você precisa aceitar os termos para continuar":void 0;if(e.tipo===T.NUMBER){const s=t!=null?String(t):"";if(e.obrigatorio&&!s)return"Campo obrigatório";if(!s)return;const i=Number(s);return isNaN(i)?"Deve ser um número":(n==null?void 0:n.min)!==void 0&&i<n.min?`Valor mínimo: ${n.min}`:(n==null?void 0:n.max)!==void 0&&i>n.max?`Valor máximo: ${n.max}`:void 0}const a=t!=null?String(t):"";if(e.obrigatorio&&!a.trim())return"Campo obrigatório";if(a){if(e.tipo===T.EMAIL&&!AN.test(a))return"E-mail inválido";if(e.tipo===T.CPF&&(!EN.test(a)||!RN(a)))return"CPF inválido";if(e.tipo===T.TELEFONE&&!DN.test(a))return"Telefone inválido";if(e.tipo===T.CEP&&!TN.test(a))return"CEP inválido";if(n!=null&&n.minLength&&a.length<n.minLength)return`Mínimo ${n.minLength} caracteres`;if(n!=null&&n.maxLength&&a.length>n.maxLength)return`Máximo ${n.maxLength} caracteres`;if((e.tipo===T.DATE||e.tipo===T.DATETIME)&&a){if(n!=null&&n.minDate&&a<n.minDate)return`Data mínima: ${n.minDate}`;if(n!=null&&n.maxDate&&a>n.maxDate)return`Data máxima: ${n.maxDate}`}if((e.tipo===T.DATE||e.tipo===T.DATETIME)&&a&&((n==null?void 0:n.minAge)!=null||(n==null?void 0:n.maxAge)!=null)){const s=a.split("T")[0],i=new Date(s+"T00:00:00"),l=r["evento.dataInicioEvento"],c=l?new Date(l.split("T")[0]+"T00:00:00"):new Date;let d=c.getFullYear()-i.getFullYear();const u=c.getMonth()-i.getMonth();if((u<0||u===0&&c.getDate()<i.getDate())&&d--,n.minAge!=null&&d<n.minAge)return`Idade mínima: ${n.minAge} ano${n.minAge!==1?"s":""}`;if(n.maxAge!=null&&d>n.maxAge)return`Idade máxima: ${n.maxAge} ano${n.maxAge!==1?"s":""}`}if(n!=null&&n.regex){const s=IN(n.regex);if(s&&!s.test(a))return n.regexMessage||"Formato inválido"}}},Ed=new Set(["__proto__","constructor","prototype"]),xn=(e,t,r)=>{const n=t.split(".");let a=e;for(let i=0;i<n.length-1;i++){const l=n[i];if(Ed.has(l))return;(a[l]==null||typeof a[l]!="object")&&(a[l]={}),a=a[l]}const s=n[n.length-1];Ed.has(s)||(a[s]=r)},jn=async(e,t,r,n,a,s)=>{for(const i of e){const l=s[i.type];if(!l)continue;const c=await l(r,n,i,a);if(c)return i.message??c}},PN=(e,t={},r={})=>async n=>{var a,s,i,l,c;const d={},u=[...e.containers].sort((m,p)=>m.ordem-p.ordem);for(const m of u){if(m.repeatable||m.condicional&&!st(m.condicional,n,t))continue;const p=[...m.campos].sort((f,b)=>f.ordem-b.ordem);for(const f of p){if(!st(f.condicional,n,t)||f.tipo===T.HIDDEN||f.isDisabled||f.isReadOnly)continue;if(f.tipo===T.FIELD_ARRAY){const h=Array.isArray(n[f.nome])?n[f.nome]:[];f.obrigatorio&&h.length===0?d[f.nome]={type:"custom",message:"Adicione pelo menos um item"}:f.minItems&&h.length<f.minItems?d[f.nome]={type:"custom",message:`Mínimo de ${f.minItems} item${f.minItems!==1?"s":""}`}:f.maxItems&&h.length>f.maxItems&&(d[f.nome]={type:"custom",message:`Máximo de ${f.maxItems} item${f.maxItems!==1?"s":""}`});for(let x=0;x<h.length;x++){const y=h[x];for(const v of f.subFields??[]){if(v.isDisabled||v.isReadOnly||!st(v.condicional,y,t))continue;const j=_a(v,y[v.nome],t);if(j){xn(d,`${f.nome}.${x}.${v.nome}`,{type:"custom",message:j});continue}if((a=v.validate)!=null&&a.length){const w=await jn(v.validate,v.nome,y[v.nome],y,t,r);w&&xn(d,`${f.nome}.${x}.${v.nome}`,{type:"custom",message:w})}}}continue}if(f.tipo===T.SUB_FORM){const h=n[f.nome]??{};f.obrigatorio&&Object.keys(h).length===0&&(d[f.nome]={type:"custom",message:"Campo obrigatório"});for(const x of((s=f.subSchema)==null?void 0:s.fields)??[]){if(x.isDisabled||x.isReadOnly)continue;const y=_a(x,h[x.nome],t);if(y){xn(d,`${f.nome}.${x.nome}`,{type:"custom",message:y});continue}if((i=x.validate)!=null&&i.length){const v=await jn(x.validate,x.nome,h[x.nome],h,t,r);v&&xn(d,`${f.nome}.${x.nome}`,{type:"custom",message:v})}}continue}const b=_a(f,n[f.nome],t);if(b&&(d[f.nome]={type:"custom",message:b}),!d[f.nome]&&(l=f.validate)!=null&&l.length){const h=await jn(f.validate,f.nome,n[f.nome],n,t,r);h&&(d[f.nome]={type:"custom",message:h})}}}for(const m of u){if(!m.repeatable||!m.nome||m.condicional&&!st(m.condicional,n,t))continue;const p=Array.isArray(n[m.nome])?n[m.nome]:[];m.minItems&&p.length<m.minItems?d[m.nome]={type:"custom",message:`Mínimo de ${m.minItems} ${m.itemLabel??"item"}${m.minItems!==1?"s":""}`}:m.maxItems&&p.length>m.maxItems&&(d[m.nome]={type:"custom",message:`Máximo de ${m.maxItems} ${m.itemLabel??"item"}${m.maxItems!==1?"s":""}`});for(let f=0;f<p.length;f++){const b=p[f];for(const h of m.campos){if(!st(h.condicional,b,t)||h.tipo===T.HIDDEN||h.isDisabled||h.isReadOnly)continue;const x=_a(h,b[h.nome],t);if(x){xn(d,`${m.nome}.${f}.${h.nome}`,{type:"custom",message:x});continue}if((c=h.validate)!=null&&c.length){const y=await jn(h.validate,h.nome,b[h.nome],b,t,r);y&&xn(d,`${m.nome}.${f}.${h.nome}`,{type:"custom",message:y})}}}}return Object.keys(d).length>0?{values:{},errors:d}:{values:n,errors:{}}},_N=(e,t={},r={})=>async n=>{var a,s;const i={},l=[...e.containers].sort((c,d)=>c.ordem-d.ordem);for(const c of l)if(!(c.condicional&&!st(c.condicional,n,t))){if(c.repeatable&&c.nome){const d=Array.isArray(n[c.nome])?n[c.nome]:[];for(let u=0;u<d.length;u++){const m=d[u];for(const p of[...c.campos].sort((f,b)=>f.ordem-b.ordem)){if(!((a=p.warn)!=null&&a.length)||!st(p.condicional,m,t))continue;const f=await jn(p.warn,p.nome,m[p.nome],m,t,r);f&&(i[`${c.nome}.${u}.${p.nome}`]=f)}}continue}for(const d of[...c.campos].sort((u,m)=>u.ordem-m.ordem)){if(!((s=d.warn)!=null&&s.length)||!st(d.condicional,n,t))continue;const u=await jn(d.warn,d.nome,n[d.nome],n,t,r);u&&(i[d.nome]=u)}}return i},ON=/\{\{\s*(?:event|evento)\.([a-zA-Z0-9_.]+)\s*\}\}/g,wt=(e,t)=>e?e.replace(ON,(r,n)=>t[`evento.${n}`]??t[n]??r):e??"",FN=(e,t)=>({...e,label:wt(e.label,t)}),zN=(e,t)=>{var r;return{...e,label:wt(e.label,t),placeholder:wt(e.placeholder,t),hint:wt(e.hint,t),defaultValue:typeof e.defaultValue=="string"?wt(e.defaultValue,t):e.defaultValue,opcoes:(r=e.opcoes)==null?void 0:r.map(n=>FN(n,t))}},Tl=(e,t)=>({...e,titulo:wt(e.titulo,t),descricao:wt(e.descricao,t),campos:e.campos.map(r=>zN(r,t))}),LN=(e,t)=>({...e,titulo:wt(e.titulo,t),descricao:wt(e.descricao,t),containers:e.containers.map(r=>Tl(r,t))}),ux=()=>{const e=sa(),t=e.layout.containerStyle,r=e.layout.roundness??"rounded-xl",n=K("overflow-hidden",r,t==="card"?"border":"",t==="bordered"?"border":"",t==="glassmorphism"?"backdrop-blur-sm":""),a=t==="glassmorphism"?{background:"var(--t-surface)",borderColor:"var(--t-border)",borderWidth:"1px",borderStyle:"solid"}:{},s=K("border-b px-6 py-4",t==="flat"?"border-transparent":"");return{wrapperClass:n,wrapperStyle:a,headerClass:s,headerStyle:t==="glassmorphism"?{borderColor:"var(--t-border)"}:{},tmpl:e}},Mt=({name:e,control:t,placeholder:r,type:n="text",disabled:a,readOnly:s})=>{var i;const{field:l,fieldState:c}=Me({name:e,control:t}),d=!!c.error;return o.jsxs("div",{className:"space-y-1",children:[o.jsx(ue,{...l,value:l.value??"",type:n,placeholder:r,disabled:a,readOnly:s,className:K(d&&"border-destructive focus-visible:ring-destructive")}),((i=c.error)==null?void 0:i.message)&&o.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})},Al=({name:e,control:t,placeholder:r,disabled:n,readOnly:a})=>{var s;const{field:i,fieldState:l}=Me({name:e,control:t});return o.jsxs("div",{className:"space-y-1",children:[o.jsx(po,{...i,value:i.value??"",placeholder:r,disabled:n,readOnly:a,rows:3,className:K(l.error&&"border-destructive focus-visible:ring-destructive")}),((s=l.error)==null?void 0:s.message)&&o.jsx("p",{className:"text-sm text-destructive",children:l.error.message})]})},Rl=({name:e,control:t,placeholder:r,options:n,disabled:a,readOnly:s})=>{var i;const{field:l,fieldState:c}=Me({name:e,control:t});return o.jsxs("div",{className:"space-y-1",children:[o.jsxs(Bt,{value:l.value??"",onValueChange:d=>!s&&l.onChange(d),disabled:a||s,children:[o.jsx(Rt,{className:K(c.error&&"border-destructive focus:ring-destructive"),onBlur:l.onBlur,children:o.jsx(Ut,{placeholder:r??"Selecione..."})}),o.jsx(It,{children:n.map(d=>o.jsx(qe,{value:d.valor,disabled:d.disabled,children:d.label},d.valor))})]}),((i=c.error)==null?void 0:i.message)&&o.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})},Il=({name:e,control:t,label:r,disabled:n,readOnly:a})=>{var s;const{field:i,fieldState:l}=Me({name:e,control:t});return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx(et,{name:i.name,checked:!!i.value,onCheckedChange:c=>!a&&i.onChange(!!c),onBlur:i.onBlur,disabled:n}),r&&o.jsx("span",{className:"text-sm leading-none",children:r})]}),((s=l.error)==null?void 0:s.message)&&o.jsx("p",{className:"text-sm text-destructive",children:l.error.message})]})},mx=({name:e,control:t,options:r,disabled:n})=>{var a;const{field:s,fieldState:i}=Me({name:e,control:t}),l=Array.isArray(s.value)?s.value:[],c=d=>{const u=l.includes(d)?l.filter(m=>m!==d):[...l,d];s.onChange(u)};return o.jsxs("div",{className:"space-y-1",children:[o.jsx("div",{className:"flex flex-col gap-2",onBlur:s.onBlur,children:r.map(d=>o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx(et,{checked:l.includes(d.valor),onCheckedChange:()=>c(d.valor),disabled:n||d.disabled}),o.jsx("span",{className:"text-sm leading-none",children:d.label})]},d.valor))}),((a=i.error)==null?void 0:a.message)&&o.jsx("p",{className:"text-sm text-destructive",children:i.error.message})]})},px=({name:e,control:t,options:r,visualStyle:n="default",disabled:a})=>{var s;const{field:i,fieldState:l}=Me({name:e,control:t}),c=n==="card";return o.jsxs("div",{className:"space-y-1",onBlur:i.onBlur,children:[o.jsx(Pi,{value:i.value??"",onValueChange:i.onChange,className:K(c?"grid grid-cols-2 gap-2 sm:grid-cols-3":"flex flex-col gap-2"),children:r.map(d=>o.jsxs("label",{className:K("flex items-center gap-2 cursor-pointer",c&&"rounded-lg border p-3 transition-colors hover:bg-accent data-[selected=true]:border-primary data-[selected=true]:bg-primary/5",(a||d.disabled)&&"cursor-not-allowed opacity-50"),"data-selected":i.value===d.valor?"true":void 0,children:[o.jsx(_i,{value:d.valor,disabled:a||d.disabled}),o.jsx("span",{className:"text-sm leading-none",children:d.label})]},d.valor))}),((s=l.error)==null?void 0:s.message)&&o.jsx("p",{className:"text-sm text-destructive",children:l.error.message})]})},fx=e=>{const t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return`${t}-${r}-${n}`},MN=e=>{const t=new Date;return t.setFullYear(t.getFullYear()-e),fx(t)},VN=e=>{const t=new Date;return t.setFullYear(t.getFullYear()-e),fx(t)},aa=({name:e,control:t,isDatetime:r,disabled:n,readOnly:a,validacao:s})=>{var i;const{field:l,fieldState:c}=Me({name:e,control:t}),d=r?"datetime-local":"date",u=f=>r?f+"T00:00":f,m=(s==null?void 0:s.minAge)!=null?u(MN(s.minAge)):(s==null?void 0:s.maxDate)!=null?u(s.maxDate):void 0,p=(s==null?void 0:s.maxAge)!=null?u(VN(s.maxAge)):(s==null?void 0:s.minDate)!=null?u(s.minDate):void 0;return o.jsxs("div",{className:"space-y-1",children:[o.jsx(ue,{name:l.name,value:l.value??"",onChange:l.onChange,onBlur:l.onBlur,type:d,min:p,max:m,disabled:n,readOnly:a,className:K(c.error&&"border-destructive focus-visible:ring-destructive")}),((i=c.error)==null?void 0:i.message)&&o.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})};function BN(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}const hx={128:"€",130:"‚",131:"ƒ",132:"„",133:"…",134:"†",135:"‡",136:"ˆ",137:"‰",138:"Š",139:"‹",140:"Œ",142:"Ž",145:"‘",146:"’",147:"“",148:"”",149:"•",150:"–",151:"—",152:"˜",153:"™",154:"š",155:"›",156:"œ",158:"ž",159:"Ÿ"};for(const[e,t]of Object.entries(hx));let Dd;function UN(){if(!(typeof globalThis.TextDecoder>"u"))return Dd??(Dd=new globalThis.TextDecoder("utf-8"))}const Pn=32*1024,Xt=65533;function HN(e,t="utf-8"){switch(t.toLowerCase()){case"utf-8":case"utf8":{const r=UN();return r?r.decode(e):qN(e)}case"utf-16le":return GN(e);case"us-ascii":case"ascii":return XN(e);case"latin1":case"iso-8859-1":return ZN(e);case"windows-1252":return KN(e);default:throw new RangeError(`Encoding '${t}' not supported`)}}function Pl(e,t){t.length!==0&&(e.push(String.fromCharCode.apply(null,t)),t.length=0)}function Ye(e,t,r){t.push(r),t.length>=Pn&&Pl(e,t)}function WN(e,t,r){if(r<=65535){Ye(e,t,r);return}r-=65536,Ye(e,t,55296+(r>>10)),Ye(e,t,56320+(r&1023))}function qN(e){const t=[],r=[];let n=0;for(e.length>=3&&e[0]===239&&e[1]===187&&e[2]===191&&(n=3);n<e.length;){const a=e[n];if(a<=127){Ye(t,r,a),n++;continue}if(a<194||a>244){Ye(t,r,Xt),n++;continue}if(a<=223){if(n+1>=e.length){Ye(t,r,Xt),n++;continue}const d=e[n+1];if((d&192)!==128){Ye(t,r,Xt),n++;continue}const u=(a&31)<<6|d&63;Ye(t,r,u),n+=2;continue}if(a<=239){if(n+2>=e.length){Ye(t,r,Xt),n++;continue}const d=e[n+1],u=e[n+2];if(!((d&192)===128&&(u&192)===128&&!(a===224&&d<160)&&!(a===237&&d>=160))){Ye(t,r,Xt),n++;continue}const m=(a&15)<<12|(d&63)<<6|u&63;Ye(t,r,m),n+=3;continue}if(n+3>=e.length){Ye(t,r,Xt),n++;continue}const s=e[n+1],i=e[n+2],l=e[n+3];if(!((s&192)===128&&(i&192)===128&&(l&192)===128&&!(a===240&&s<144)&&!(a===244&&s>143))){Ye(t,r,Xt),n++;continue}const c=(a&7)<<18|(s&63)<<12|(i&63)<<6|l&63;WN(t,r,c),n+=4}return Pl(t,r),t.join("")}function GN(e){const t=[],r=[],n=e.length;let a=0;for(;a+1<n;){const s=e[a]|e[a+1]<<8;if(a+=2,s>=55296&&s<=56319){if(a+1<n){const i=e[a]|e[a+1]<<8;i>=56320&&i<=57343?(Ye(t,r,s),Ye(t,r,i),a+=2):Ye(t,r,Xt)}else Ye(t,r,Xt);continue}if(s>=56320&&s<=57343){Ye(t,r,Xt);continue}Ye(t,r,s)}return a<n&&Ye(t,r,Xt),Pl(t,r),t.join("")}function XN(e){const t=[];for(let r=0;r<e.length;r+=Pn){const n=Math.min(e.length,r+Pn),a=new Array(n-r);for(let s=r,i=0;s<n;s++,i++)a[i]=e[s]&127;t.push(String.fromCharCode.apply(null,a))}return t.join("")}function ZN(e){const t=[];for(let r=0;r<e.length;r+=Pn){const n=Math.min(e.length,r+Pn),a=new Array(n-r);for(let s=r,i=0;s<n;s++,i++)a[i]=e[s];t.push(String.fromCharCode.apply(null,a))}return t.join("")}function KN(e){const t=[];let r="";for(let n=0;n<e.length;n++){const a=e[n],s=a>=128&&a<=159?hx[a]:void 0;r+=s??String.fromCharCode(a),r.length>=Pn&&(t.push(r),r="")}return r&&t.push(r),t.join("")}function Ct(e){return new DataView(e.buffer,e.byteOffset)}const YN={len:1,get(e,t){return Ct(e).getUint8(t)},put(e,t,r){return Ct(e).setUint8(t,r),t+1}},We={len:2,get(e,t){return Ct(e).getUint16(t,!0)},put(e,t,r){return Ct(e).setUint16(t,r,!0),t+2}},gn={len:2,get(e,t){return Ct(e).getUint16(t)},put(e,t,r){return Ct(e).setUint16(t,r),t+2}},Xe={len:4,get(e,t){return Ct(e).getUint32(t,!0)},put(e,t,r){return Ct(e).setUint32(t,r,!0),t+4}},Td={len:4,get(e,t){return Ct(e).getUint32(t)},put(e,t,r){return Ct(e).setUint32(t,r),t+4}},JN={len:4,get(e,t){return Ct(e).getInt32(t)},put(e,t,r){return Ct(e).setInt32(t,r),t+4}},QN={len:8,get(e,t){return Ct(e).getBigUint64(t,!0)},put(e,t,r){return Ct(e).setBigUint64(t,r,!0),t+8}};class br{constructor(t,r){this.len=t,this.encoding=r}get(t,r=0){const n=t.subarray(r,r+this.len);return HN(n,this.encoding)}}const e2="End-Of-Stream";class Qe extends Error{constructor(){super(e2),this.name="EndOfStreamError"}}class t2 extends Error{constructor(t="The operation was aborted"){super(t),this.name="AbortError"}}class xx{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(t,r=!1){const n=await this.read(t,r);return this.peekQueue.push(t.subarray(0,n)),n}async read(t,r=!1){if(t.length===0)return 0;let n=this.readFromPeekBuffer(t);if(this.endOfStream||(n+=await this.readRemainderFromStream(t.subarray(n),r)),n===0&&!r)throw new Qe;return n}readFromPeekBuffer(t){let r=t.length,n=0;for(;this.peekQueue.length>0&&r>0;){const a=this.peekQueue.pop();if(!a)throw new Error("peekData should be defined");const s=Math.min(a.length,r);t.set(a.subarray(0,s),n),n+=s,r-=s,s<a.length&&this.peekQueue.push(a.subarray(s))}return n}async readRemainderFromStream(t,r){let n=0;for(;n<t.length&&!this.endOfStream;){if(this.interrupted)throw new t2;const a=await this.readFromStream(t.subarray(n),r);if(a===0)break;n+=a}if(!r&&n<t.length)throw new Qe;return n}}class r2 extends xx{constructor(t){super(),this.reader=t}async abort(){return this.close()}async close(){this.reader.releaseLock()}}class n2 extends r2{async readFromStream(t,r){if(t.length===0)return 0;const n=await this.reader.read(new Uint8Array(t.length),{min:r?void 0:t.length});return n.done&&(this.endOfStream=n.done),n.value?(t.set(n.value),n.value.length):0}}class Ad extends xx{constructor(t){super(),this.reader=t,this.buffer=null}writeChunk(t,r){const n=Math.min(r.length,t.length);return t.set(r.subarray(0,n)),n<r.length?this.buffer=r.subarray(n):this.buffer=null,n}async readFromStream(t,r){if(t.length===0)return 0;let n=0;for(this.buffer&&(n+=this.writeChunk(t,this.buffer));n<t.length&&!this.endOfStream;){const a=await this.reader.read();if(a.done){this.endOfStream=!0;break}a.value&&(n+=this.writeChunk(t.subarray(n),a.value))}if(!r&&n===0&&this.endOfStream)throw new Qe;return n}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}}function a2(e){try{const t=e.getReader({mode:"byob"});return t instanceof ReadableStreamDefaultReader?new Ad(t):new n2(t)}catch(t){if(t instanceof TypeError)return new Ad(e.getReader());throw t}}class _l{constructor(t){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=t==null?void 0:t.onClose,t!=null&&t.abortSignal&&t.abortSignal.addEventListener("abort",()=>{this.abort()})}async readToken(t,r=this.position){const n=new Uint8Array(t.len);if(await this.readBuffer(n,{position:r})<t.len)throw new Qe;return t.get(n,0)}async peekToken(t,r=this.position){const n=new Uint8Array(t.len);if(await this.peekBuffer(n,{position:r})<t.len)throw new Qe;return t.get(n,0)}async readNumber(t){if(await this.readBuffer(this.numBuffer,{length:t.len})<t.len)throw new Qe;return t.get(this.numBuffer,0)}async peekNumber(t){if(await this.peekBuffer(this.numBuffer,{length:t.len})<t.len)throw new Qe;return t.get(this.numBuffer,0)}async ignore(t){if(t<0)throw new RangeError("ignore length must be ≥ 0 bytes");if(this.fileInfo.size!==void 0){const r=this.fileInfo.size-this.position;if(t>r)return this.position+=r,r}return this.position+=t,t}async close(){var t;await this.abort(),await((t=this.onClose)==null?void 0:t.call(this))}normalizeOptions(t,r){if(!this.supportsRandomAccess()&&r&&r.position!==void 0&&r.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");return{mayBeLess:!1,offset:0,length:t.length,position:this.position,...r}}abort(){return Promise.resolve()}}const o2=256e3;class s2 extends _l{constructor(t,r){super(r),this.streamReader=t,this.fileInfo=(r==null?void 0:r.fileInfo)??{}}async readBuffer(t,r){const n=this.normalizeOptions(t,r),a=n.position-this.position;if(a>0)return await this.ignore(a),this.readBuffer(t,r);if(a<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(n.length===0)return 0;const s=await this.streamReader.read(t.subarray(0,n.length),n.mayBeLess);if(this.position+=s,(!r||!r.mayBeLess)&&s<n.length)throw new Qe;return s}async peekBuffer(t,r){const n=this.normalizeOptions(t,r);let a=0;if(n.position){const s=n.position-this.position;if(s>0){const i=new Uint8Array(n.length+s);return a=await this.peekBuffer(i,{mayBeLess:n.mayBeLess}),t.set(i.subarray(s)),a-s}if(s<0)throw new Error("Cannot peek from a negative offset in a stream")}if(n.length>0){try{a=await this.streamReader.peek(t.subarray(0,n.length),n.mayBeLess)}catch(s){if(r!=null&&r.mayBeLess&&s instanceof Qe)return 0;throw s}if(!n.mayBeLess&&a<n.length)throw new Qe}return a}async ignore(t){if(t<0)throw new RangeError("ignore length must be ≥ 0 bytes");const r=Math.min(o2,t),n=new Uint8Array(r);let a=0;for(;a<t;){const s=t-a,i=await this.readBuffer(n,{length:Math.min(r,s)});if(i<0)return i;a+=i}return a}abort(){return this.streamReader.abort()}async close(){return this.streamReader.close()}supportsRandomAccess(){return!1}}class i2 extends _l{constructor(t,r){super(r),this.uint8Array=t,this.fileInfo={...(r==null?void 0:r.fileInfo)??{},size:t.length}}async readBuffer(t,r){r!=null&&r.position&&(this.position=r.position);const n=await this.peekBuffer(t,r);return this.position+=n,n}async peekBuffer(t,r){const n=this.normalizeOptions(t,r),a=Math.min(this.uint8Array.length-n.position,n.length);if(!n.mayBeLess&&a<n.length)throw new Qe;return t.set(this.uint8Array.subarray(n.position,n.position+a)),a}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(t){this.position=t}}class l2 extends _l{constructor(t,r){super(r),this.blob=t,this.fileInfo={...(r==null?void 0:r.fileInfo)??{},size:t.size,mimeType:t.type}}async readBuffer(t,r){r!=null&&r.position&&(this.position=r.position);const n=await this.peekBuffer(t,r);return this.position+=n,n}async peekBuffer(t,r){const n=this.normalizeOptions(t,r),a=Math.min(this.blob.size-n.position,n.length);if(!n.mayBeLess&&a<n.length)throw new Qe;const s=await this.blob.slice(n.position,n.position+a).arrayBuffer();return t.set(new Uint8Array(s)),a}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(t){this.position=t}}function c2(e,t){const r=a2(e),n=t??{},a=n.onClose;return n.onClose=async()=>{if(await r.close(),a)return a()},new s2(r,n)}function d2(e,t){return new i2(e,t)}function u2(e,t){return new l2(e,t)}var bi={exports:{}},Os,Rd;function m2(){if(Rd)return Os;Rd=1;var e=1e3,t=e*60,r=t*60,n=r*24,a=n*7,s=n*365.25;Os=function(u,m){m=m||{};var p=typeof u;if(p==="string"&&u.length>0)return i(u);if(p==="number"&&isFinite(u))return m.long?c(u):l(u);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(u))};function i(u){if(u=String(u),!(u.length>100)){var m=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(u);if(m){var p=parseFloat(m[1]),f=(m[2]||"ms").toLowerCase();switch(f){case"years":case"year":case"yrs":case"yr":case"y":return p*s;case"weeks":case"week":case"w":return p*a;case"days":case"day":case"d":return p*n;case"hours":case"hour":case"hrs":case"hr":case"h":return p*r;case"minutes":case"minute":case"mins":case"min":case"m":return p*t;case"seconds":case"second":case"secs":case"sec":case"s":return p*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return p;default:return}}}}function l(u){var m=Math.abs(u);return m>=n?Math.round(u/n)+"d":m>=r?Math.round(u/r)+"h":m>=t?Math.round(u/t)+"m":m>=e?Math.round(u/e)+"s":u+"ms"}function c(u){var m=Math.abs(u);return m>=n?d(u,m,n,"day"):m>=r?d(u,m,r,"hour"):m>=t?d(u,m,t,"minute"):m>=e?d(u,m,e,"second"):u+" ms"}function d(u,m,p,f){var b=m>=p*1.5;return Math.round(u/p)+" "+f+(b?"s":"")}return Os}function p2(e){r.debug=r,r.default=r,r.coerce=c,r.disable=i,r.enable=a,r.enabled=l,r.humanize=m2(),r.destroy=d,Object.keys(e).forEach(u=>{r[u]=e[u]}),r.names=[],r.skips=[],r.formatters={};function t(u){let m=0;for(let p=0;p<u.length;p++)m=(m<<5)-m+u.charCodeAt(p),m|=0;return r.colors[Math.abs(m)%r.colors.length]}r.selectColor=t;function r(u){let m,p=null,f,b;function h(...x){if(!h.enabled)return;const y=h,v=Number(new Date),j=v-(m||v);y.diff=j,y.prev=m,y.curr=v,m=v,x[0]=r.coerce(x[0]),typeof x[0]!="string"&&x.unshift("%O");let w=0;x[0]=x[0].replace(/%([a-zA-Z%])/g,(C,S)=>{if(C==="%%")return"%";w++;const $=r.formatters[S];if(typeof $=="function"){const k=x[w];C=$.call(y,k),x.splice(w,1),w--}return C}),r.formatArgs.call(y,x),(y.log||r.log).apply(y,x)}return h.namespace=u,h.useColors=r.useColors(),h.color=r.selectColor(u),h.extend=n,h.destroy=r.destroy,Object.defineProperty(h,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(f!==r.namespaces&&(f=r.namespaces,b=r.enabled(u)),b),set:x=>{p=x}}),typeof r.init=="function"&&r.init(h),h}function n(u,m){const p=r(this.namespace+(typeof m>"u"?":":m)+u);return p.log=this.log,p}function a(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];const m=(typeof u=="string"?u:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const p of m)p[0]==="-"?r.skips.push(p.slice(1)):r.names.push(p)}function s(u,m){let p=0,f=0,b=-1,h=0;for(;p<u.length;)if(f<m.length&&(m[f]===u[p]||m[f]==="*"))m[f]==="*"?(b=f,h=p,f++):(p++,f++);else if(b!==-1)f=b+1,h++,p=h;else return!1;for(;f<m.length&&m[f]==="*";)f++;return f===m.length}function i(){const u=[...r.names,...r.skips.map(m=>"-"+m)].join(",");return r.enable(""),u}function l(u){for(const m of r.skips)if(s(u,m))return!1;for(const m of r.names)if(s(u,m))return!0;return!1}function c(u){return u instanceof Error?u.stack||u.message:u}function d(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}var f2=p2;(function(e,t){t.formatArgs=n,t.save=a,t.load=s,t.useColors=r,t.storage=i(),t.destroy=(()=>{let c=!1;return()=>{c||(c=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function r(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let c;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(c=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(c[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function n(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const d="color: "+this.color;c.splice(1,0,d,"color: inherit");let u=0,m=0;c[0].replace(/%[a-zA-Z%]/g,p=>{p!=="%%"&&(u++,p==="%c"&&(m=u))}),c.splice(m,0,d)}t.log=console.debug||console.log||(()=>{});function a(c){try{c?t.storage.setItem("debug",c):t.storage.removeItem("debug")}catch{}}function s(){let c;try{c=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch{}return!c&&typeof process<"u"&&"env"in process&&(c=process.env.DEBUG),c}function i(){try{return localStorage}catch{}}e.exports=f2(t);const{formatters:l}=e.exports;l.j=function(c){try{return JSON.stringify(c)}catch(d){return"[UnexpectedJSONParseError]: "+d.message}}})(bi,bi.exports);var h2=bi.exports;const x2=BN(h2),kn={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},Id={get(e){return{signature:Xe.get(e,0),compressedSize:Xe.get(e,8),uncompressedSize:Xe.get(e,12)}},len:16},g2={get(e){const t=We.get(e,6);return{signature:Xe.get(e,0),minVersion:We.get(e,4),dataDescriptor:!!(t&8),compressedMethod:We.get(e,8),compressedSize:Xe.get(e,18),uncompressedSize:Xe.get(e,22),filenameLength:We.get(e,26),extraFieldLength:We.get(e,28),filename:null}},len:30},v2={get(e){return{signature:Xe.get(e,0),nrOfThisDisk:We.get(e,4),nrOfThisDiskWithTheStart:We.get(e,6),nrOfEntriesOnThisDisk:We.get(e,8),nrOfEntriesOfSize:We.get(e,10),sizeOfCd:Xe.get(e,12),offsetOfStartOfCd:Xe.get(e,16),zipFileCommentLength:We.get(e,20)}},len:22},b2={get(e){const t=We.get(e,8);return{signature:Xe.get(e,0),minVersion:We.get(e,6),dataDescriptor:!!(t&8),compressedMethod:We.get(e,10),compressedSize:Xe.get(e,20),uncompressedSize:Xe.get(e,24),filenameLength:We.get(e,28),extraFieldLength:We.get(e,30),fileCommentLength:We.get(e,32),relativeOffsetOfLocalHeader:Xe.get(e,42),filename:null}},len:46};function gx(e){const t=new Uint8Array(Xe.len);return Xe.put(t,0,e),t}const or=x2("tokenizer:inflate"),Fs=256*1024,y2=gx(kn.DataDescriptor),Oa=gx(kn.EndOfCentralDirectory);class va{constructor(t){this.tokenizer=t,this.syncBuffer=new Uint8Array(Fs)}async isZip(){return await this.peekSignature()===kn.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(Xe)}async findEndOfCentralDirectoryLocator(){const t=this.tokenizer,r=Math.min(16*1024,t.fileInfo.size),n=this.syncBuffer.subarray(0,r);await this.tokenizer.readBuffer(n,{position:t.fileInfo.size-r});for(let a=n.length-4;a>=0;a--)if(n[a]===Oa[0]&&n[a+1]===Oa[1]&&n[a+2]===Oa[2]&&n[a+3]===Oa[3])return t.fileInfo.size-r+a;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){or("Cannot reading central-directory without random-read support");return}or("Reading central-directory...");const t=this.tokenizer.position,r=await this.findEndOfCentralDirectoryLocator();if(r>0){or("Central-directory 32-bit signature found");const n=await this.tokenizer.readToken(v2,r),a=[];this.tokenizer.setPosition(n.offsetOfStartOfCd);for(let s=0;s<n.nrOfEntriesOfSize;++s){const i=await this.tokenizer.readToken(b2);if(i.signature!==kn.CentralFileHeader)throw new Error("Expected Central-File-Header signature");i.filename=await this.tokenizer.readToken(new br(i.filenameLength,"utf-8")),await this.tokenizer.ignore(i.extraFieldLength),await this.tokenizer.ignore(i.fileCommentLength),a.push(i),or(`Add central-directory file-entry: n=${s+1}/${a.length}: filename=${a[s].filename}`)}return this.tokenizer.setPosition(t),a}this.tokenizer.setPosition(t)}async unzip(t){const r=await this.readCentralDirectory();if(r)return this.iterateOverCentralDirectory(r,t);let n=!1;do{const a=await this.readLocalFileHeader();if(!a)break;const s=t(a);n=!!s.stop;let i;if(await this.tokenizer.ignore(a.extraFieldLength),a.dataDescriptor&&a.compressedSize===0){const l=[];let c=Fs;or("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let d=-1;for(;d<0&&c===Fs;){c=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),d=w2(this.syncBuffer.subarray(0,c),y2);const u=d>=0?d:c;if(s.handler){const m=new Uint8Array(u);await this.tokenizer.readBuffer(m),l.push(m)}else await this.tokenizer.ignore(u)}or(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),s.handler&&await this.inflate(a,j2(l),s.handler)}else s.handler?(or(`Reading compressed-file-data: ${a.compressedSize} bytes`),i=new Uint8Array(a.compressedSize),await this.tokenizer.readBuffer(i),await this.inflate(a,i,s.handler)):(or(`Ignoring compressed-file-data: ${a.compressedSize} bytes`),await this.tokenizer.ignore(a.compressedSize));if(or(`Reading data-descriptor at pos=${this.tokenizer.position}`),a.dataDescriptor&&(await this.tokenizer.readToken(Id)).signature!==134695760)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-Id.len}`)}while(!n)}async iterateOverCentralDirectory(t,r){for(const n of t){const a=r(n);if(a.handler){this.tokenizer.setPosition(n.relativeOffsetOfLocalHeader);const s=await this.readLocalFileHeader();if(s){await this.tokenizer.ignore(s.extraFieldLength);const i=new Uint8Array(n.compressedSize);await this.tokenizer.readBuffer(i),await this.inflate(s,i,a.handler)}}if(a.stop)break}}async inflate(t,r,n){if(t.compressedMethod===0)return n(r);if(t.compressedMethod!==8)throw new Error(`Unsupported ZIP compression method: ${t.compressedMethod}`);or(`Decompress filename=${t.filename}, compressed-size=${r.length}`);const a=await va.decompressDeflateRaw(r);return n(a)}static async decompressDeflateRaw(t){const r=new ReadableStream({start(s){s.enqueue(t),s.close()}}),n=new DecompressionStream("deflate-raw"),a=r.pipeThrough(n);try{const s=await new Response(a).arrayBuffer();return new Uint8Array(s)}catch(s){const i=s instanceof Error?`Failed to deflate ZIP entry: ${s.message}`:"Unknown decompression error in ZIP entry";throw new TypeError(i)}}async readLocalFileHeader(){const t=await this.tokenizer.peekToken(Xe);if(t===kn.LocalFileHeader){const r=await this.tokenizer.readToken(g2);return r.filename=await this.tokenizer.readToken(new br(r.filenameLength,"utf-8")),r}if(t===kn.CentralFileHeader)return!1;throw t===3759263696?new Error("Encrypted ZIP"):new Error("Unexpected signature")}}function w2(e,t){const r=e.length,n=t.length;if(n>r)return-1;for(let a=0;a<=r-n;a++){let s=!0;for(let i=0;i<n;i++)if(e[a+i]!==t[i]){s=!1;break}if(s)return a}return-1}function j2(e){const t=e.reduce((a,s)=>a+s.length,0),r=new Uint8Array(t);let n=0;for(const a of e)r.set(a,n),n+=a.length;return r}class k2{constructor(t){this.tokenizer=t}inflate(){const t=this.tokenizer;return new ReadableStream({async pull(r){const n=new Uint8Array(1024),a=await t.readBuffer(n,{mayBeLess:!0});if(a===0){r.close();return}r.enqueue(n.subarray(0,a))}}).pipeThrough(new DecompressionStream("gzip"))}}new globalThis.TextDecoder("utf8");new globalThis.TextEncoder;Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Pd(e){const{byteLength:t}=e;if(t===6)return e.getUint16(0)*2**32+e.getUint32(2);if(t===5)return e.getUint8(0)*2**32+e.getUint32(1);if(t===4)return e.getUint32(0);if(t===3)return e.getUint8(0)*2**16+e.getUint16(1);if(t===2)return e.getUint16(0);if(t===1)return e.getUint8(0)}function C2(e,t){if(t==="utf-16le"){const r=[];for(let n=0;n<e.length;n++){const a=e.charCodeAt(n);r.push(a&255,a>>8&255)}return r}if(t==="utf-16be"){const r=[];for(let n=0;n<e.length;n++){const a=e.charCodeAt(n);r.push(a>>8&255,a&255)}return r}return[...e].map(r=>r.charCodeAt(0))}function N2(e,t=0){const r=Number.parseInt(new br(6).get(e,148).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(r))return!1;let n=256;for(let a=t;a<t+148;a++)n+=e[a];for(let a=t+156;a<t+512;a++)n+=e[a];return r===n}const S2={get:(e,t)=>e[t+3]&127|e[t+2]<<7|e[t+1]<<14|e[t]<<21,len:4},$2=["jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","oga","ogg","ogv","opus","flac","wav","spx","amr","pdf","epub","elf","macho","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ttc","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","j2c","jp2","jpm","jpx","mj2","aif","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","dcm","ics","glb","pcap","dsf","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a","mie","asf","ogm","ogx","mpc","arrow","shp","aac","mp1","it","s3m","xm","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet","class","arj","cpio","ace","avro","icc","fbx","vsdx","vtt","apk","drc","lz4","potx","xltx","dotx","xltm","ott","ots","otp","odg","otg","xlsm","docm","dotm","potm","pptm","jar","jmp","rm","sav","ppsm","ppsx","tar.gz","reg","dat"],E2=["image/jpeg","image/png","image/gif","image/webp","image/flif","image/x-xcf","image/x-canon-cr2","image/x-canon-cr3","image/tiff","image/bmp","image/vnd.ms-photo","image/vnd.adobe.photoshop","application/x-indesign","application/epub+zip","application/x-xpinstall","application/vnd.ms-powerpoint.slideshow.macroenabled.12","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.slideshow","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/vnd.apache.arrow.file","video/mp4","audio/midi","video/matroska","video/webm","video/quicktime","video/vnd.avi","audio/wav","audio/qcelp","audio/x-ms-asf","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","video/ogg","audio/ogg","audio/ogg; codecs=opus","application/ogg","audio/flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-elf","application/x-mach-binary","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","font/collection","image/x-icon","video/x-flv","application/postscript","application/eps","application/x-xz","application/x-sqlite3","application/x-nintendo-nes-rom","application/x-google-chrome-extension","application/vnd.ms-cab-compressed","application/x-deb","application/x-unix-archive","application/x-rpm","application/x-compress","application/x-lzip","application/x-cfb","application/x-mie","application/mxf","video/mp2t","application/x-blender","image/bpg","image/j2c","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","application/xml","application/x-mobipocket-ebook","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/icns","image/ktx","application/dicom","audio/x-musepack","text/calendar","text/vcard","text/vtt","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","application/x.ms.shortcut","application/x.apple.alias","audio/x-voc","audio/vnd.dolby.dd-raw","audio/x-m4a","image/apng","image/x-olympus-orf","image/x-sony-arw","image/x-adobe-dng","image/x-nikon-nef","image/x-panasonic-rw2","image/x-fujifilm-raf","video/x-m4v","video/3gpp2","application/x-esri-shape","audio/aac","audio/x-it","audio/x-s3m","audio/x-xm","video/MP1S","video/MP2P","application/vnd.sketchup.skp","image/avif","application/x-lzh-compressed","application/pgp-encrypted","application/x-asar","model/stl","application/vnd.ms-htmlhelp","model/3mf","image/jxl","application/zstd","image/jls","application/vnd.ms-outlook","image/vnd.dwg","application/vnd.apache.parquet","application/java-vm","application/x-arj","application/x-cpio","application/x-ace-compressed","application/avro","application/vnd.iccprofile","application/x.autodesk.fbx","application/vnd.visio","application/vnd.android.package-archive","application/vnd.google.draco","application/x-lz4","application/vnd.openxmlformats-officedocument.presentationml.template","application/vnd.openxmlformats-officedocument.spreadsheetml.template","application/vnd.openxmlformats-officedocument.wordprocessingml.template","application/vnd.ms-excel.template.macroenabled.12","application/vnd.oasis.opendocument.text-template","application/vnd.oasis.opendocument.spreadsheet-template","application/vnd.oasis.opendocument.presentation-template","application/vnd.oasis.opendocument.graphics","application/vnd.oasis.opendocument.graphics-template","application/vnd.ms-excel.sheet.macroenabled.12","application/vnd.ms-word.document.macroenabled.12","application/vnd.ms-word.template.macroenabled.12","application/vnd.ms-powerpoint.template.macroenabled.12","application/vnd.ms-powerpoint.presentation.macroenabled.12","application/java-archive","application/vnd.rn-realmedia","application/x-spss-sav","application/x-ms-regedit","application/x-ft-windows-registry-hive","application/x-jmp-data"],Jn=4100,D2=Jn-2,mr=1024*1024,_d=1024,T2=2**31-1,Vt=16*1024*1024,Jo=mr,Od=mr,A2=Vt,R2=1,Fd=100,zs=Vt,zd=64,Ld=Jo,I2=256,P2=512,_2=Vt,O2=512,F2=512,Md=256,Vd=Jo,Bd=Jo,z2=Jo,Ud=Vt,L2=new Set(["Unexpected signature","Encrypted ZIP","Expected Central-File-Header signature"]),M2=["ZIP entry count exceeds ","Unsupported ZIP compression method:","ZIP entry compressed data exceeds ","ZIP entry decompressed data exceeds ","Expected data-descriptor-signature at position "],V2=new Set(["Z_BUF_ERROR","Z_DATA_ERROR","ERR_INVALID_STATE"]);class Jr extends Error{}function B2(e){var t;const r=e==null?void 0:e.streamReader;if(((t=r==null?void 0:r.constructor)==null?void 0:t.name)!=="WebStreamByobReader")return e;const{reader:n}=r,a=async()=>{await n.cancel(),n.releaseLock()};return r.close=a,r.abort=async()=>{r.interrupted=!0,await a()},e}function Ol(e,t,r){if(!Number.isFinite(e)||e<0||e>t)throw new Jr(`${r} has invalid size ${e} (maximum ${t} bytes)`);return e}async function Ir(e,t,{maximumLength:r=Vt,reason:n="skip"}={}){const a=Ol(t,r,n);await e.ignore(a)}async function Ls(e,t,r,{maximumLength:n=t.length,reason:a="read"}={}){const s=t.length,i=Ol(s,n,a);return e.readBuffer(t,{...r,length:i})}async function U2(e,{maximumLength:t=mr}={}){const r=new ReadableStream({start(l){l.enqueue(e),l.close()}}).pipeThrough(new DecompressionStream("deflate-raw")).getReader(),n=[];let a=0;try{for(;;){const{done:l,value:c}=await r.read();if(l)break;if(a+=c.length,a>t)throw await r.cancel(),new Error(`ZIP entry decompressed data exceeds ${t} bytes`);n.push(c)}}finally{r.releaseLock()}const s=new Uint8Array(a);let i=0;for(const l of n)s.set(l,i),i+=l.length;return s}const vx=134695760,io=16,H2=io-1;function W2(e,t){if(e.length<io)return-1;const r=e.length-io;for(let n=0;n<=r;n++)if(Xe.get(e,n)===vx&&Xe.get(e,n+8)===t+n)return n;return-1}function q2(e){return(e.codePointAt(0)&32)!==0}function G2(e,t){const r=new Uint8Array(t);let n=0;for(const a of e)r.set(a,n),n+=a.length;return r}async function X2(e,{shouldBuffer:t,maximumLength:r=mr}={}){const{syncBuffer:n}=e,{length:a}=n,s=[];let i=0;for(;;){const l=await e.tokenizer.peekBuffer(n,{mayBeLess:!0}),c=W2(n.subarray(0,l),i),d=c>=0?0:l===a?Math.min(H2,l-1):0,u=c>=0?c:l-d;if(u===0)break;if(i+=u,i>r)throw new Error(`ZIP entry compressed data exceeds ${r} bytes`);if(t){const m=new Uint8Array(u);await e.tokenizer.readBuffer(m),s.push(m)}else await e.tokenizer.ignore(u);if(c>=0)break}if(pt(e.tokenizer)||(e.knownSizeDescriptorScannedBytes+=i),!!t)return G2(s,i)}function Z2(e,t){return pt(e.tokenizer)?Math.max(0,Vt-(e.tokenizer.position-t)):Math.max(0,mr-e.knownSizeDescriptorScannedBytes)}async function K2(e,t,{shouldBuffer:r,maximumDescriptorLength:n=mr}={}){if(t.dataDescriptor&&t.compressedSize===0)return X2(e,{shouldBuffer:r,maximumLength:n});if(!r){await Ir(e.tokenizer,t.compressedSize,{maximumLength:pt(e.tokenizer)?mr:e.tokenizer.fileInfo.size,reason:"ZIP entry compressed data"});return}const a=nS(e.tokenizer);if(!Number.isFinite(t.compressedSize)||t.compressedSize<0||t.compressedSize>a)throw new Error(`ZIP entry compressed data exceeds ${a} bytes`);const s=new Uint8Array(t.compressedSize);return await e.tokenizer.readBuffer(s),s}va.prototype.inflate=async function(e,t,r){if(e.compressedMethod===0)return r(t);if(e.compressedMethod!==8)throw new Error(`Unsupported ZIP compression method: ${e.compressedMethod}`);const n=await U2(t,{maximumLength:mr});return r(n)};va.prototype.unzip=async function(e){let t=!1,r=0;const n=this.tokenizer.position;this.knownSizeDescriptorScannedBytes=0;do{if(Qn(this.tokenizer,n,Vt))throw new Jr(`ZIP stream probing exceeds ${Vt} bytes`);const a=await this.readLocalFileHeader();if(!a)break;if(r++,r>_d)throw new Error(`ZIP entry count exceeds ${_d}`);const s=e(a);t=!!s.stop,await this.tokenizer.ignore(a.extraFieldLength);const i=await K2(this,a,{shouldBuffer:!!s.handler,maximumDescriptorLength:Math.min(mr,Z2(this,n))});if(s.handler&&await this.inflate(a,i,s.handler),a.dataDescriptor){const l=new Uint8Array(io);if(await this.tokenizer.readBuffer(l),Xe.get(l,0)!==vx)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-l.length}`)}if(Qn(this.tokenizer,n,Vt))throw new Jr(`ZIP stream probing exceeds ${Vt} bytes`)}while(!t)};function Y2(e,t){const r=e.getReader();let n=0,a=!1,s=!1;const i=async l=>{a||s||(s=!0,await r.cancel(l))};return new ReadableStream({async pull(l){if(n>=t){l.close(),await i();return}const{done:c,value:d}=await r.read();if(c||!d){a=!0,l.close();return}const u=t-n;if(d.length>u){l.enqueue(d.subarray(0,u)),n+=u,l.close(),await i();return}l.enqueue(d),n+=d.length},async cancel(l){await i(l)}})}async function J2(e,t){return new Fl(t).fromBlob(e)}function Hd(e){switch(e=e.toLowerCase(),e){case"application/epub+zip":return{ext:"epub",mime:e};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:e};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:e};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:e};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:e};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:e};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:e};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:e};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:e};case"application/vnd.openxmlformats-officedocument.presentationml.slideshow":return{ext:"ppsx",mime:e};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:e};case"application/vnd.ms-excel.sheet.macroenabled":return{ext:"xlsm",mime:"application/vnd.ms-excel.sheet.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.spreadsheetml.template":return{ext:"xltx",mime:e};case"application/vnd.ms-excel.template.macroenabled":return{ext:"xltm",mime:"application/vnd.ms-excel.template.macroenabled.12"};case"application/vnd.ms-powerpoint.slideshow.macroenabled":return{ext:"ppsm",mime:"application/vnd.ms-powerpoint.slideshow.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return{ext:"docx",mime:e};case"application/vnd.ms-word.document.macroenabled":return{ext:"docm",mime:"application/vnd.ms-word.document.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.template":return{ext:"dotx",mime:e};case"application/vnd.ms-word.template.macroenabledtemplate":return{ext:"dotm",mime:"application/vnd.ms-word.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.template":return{ext:"potx",mime:e};case"application/vnd.ms-powerpoint.template.macroenabled":return{ext:"potm",mime:"application/vnd.ms-powerpoint.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.presentation":return{ext:"pptx",mime:e};case"application/vnd.ms-powerpoint.presentation.macroenabled":return{ext:"pptm",mime:"application/vnd.ms-powerpoint.presentation.macroenabled.12"};case"application/vnd.ms-visio.drawing":return{ext:"vsdx",mime:"application/vnd.visio"};case"application/vnd.ms-package.3dmanufacturing-3dmodel+xml":return{ext:"3mf",mime:"model/3mf"}}}function sr(e,t,r){r={offset:0,...r};for(const[n,a]of t.entries())if(r.mask){if(a!==(r.mask[n]&e[n+r.offset]))return!1}else if(a!==e[n+r.offset])return!1;return!0}function Q2(e){return Number.isFinite(e)?Math.max(1,Math.trunc(e)):Jn}function eS(e,t,r){return r===void 0?e.read(t):(r.throwIfAborted(),new Promise((n,a)=>{const s=()=>{r.removeEventListener("abort",i)},i=()=>{const l=r.reason;s(),(async()=>{try{await e.cancel(l)}catch{}})(),a(l)};r.addEventListener("abort",i,{once:!0}),(async()=>{try{const l=await e.read(t);s(),n(l)}catch(l){s(),a(l)}})()}))}function tS(e){return Number.isFinite(e)?Math.max(0,Math.min(D2,Math.trunc(e))):0}function rS(e){return Number.isFinite(e)?Math.max(0,e):Number.MAX_SAFE_INTEGER}function pt(e){const t=e.fileInfo.size;return!Number.isFinite(t)||t===Number.MAX_SAFE_INTEGER}function Qn(e,t,r){return pt(e)&&e.position-t>r}function nS(e){const t=e.fileInfo.size,r=Number.isFinite(t)?Math.max(0,t-e.position):Number.MAX_SAFE_INTEGER;return Math.min(r,T2)}function aS(e){if(e instanceof Qe||e instanceof Jr)return!0;if(!(e instanceof Error))return!1;if(L2.has(e.message)||V2.has(e.code))return!0;for(const t of M2)if(e.message.startsWith(t))return!0;return!1}function Wd(e,t=mr){const r=[e.compressedSize,e.uncompressedSize];for(const n of r)if(!Number.isFinite(n)||n<0||n>t)return!1;return!0}function oS(){return{hasContentTypesEntry:!1,hasParsedContentTypesEntry:!1,isParsingContentTypes:!1,hasUnparseableContentTypes:!1,hasWordDirectory:!1,hasPresentationDirectory:!1,hasSpreadsheetDirectory:!1,hasThreeDimensionalModelEntry:!1}}function sS(e,t){t.startsWith("word/")&&(e.hasWordDirectory=!0),t.startsWith("ppt/")&&(e.hasPresentationDirectory=!0),t.startsWith("xl/")&&(e.hasSpreadsheetDirectory=!0),t.startsWith("3D/")&&t.endsWith(".model")&&(e.hasThreeDimensionalModelEntry=!0)}function qd(e){if(!(!e.hasContentTypesEntry||e.hasUnparseableContentTypes||e.isParsingContentTypes||e.hasParsedContentTypesEntry)){if(e.hasWordDirectory)return{ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"};if(e.hasPresentationDirectory)return{ext:"pptx",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"};if(e.hasSpreadsheetDirectory)return{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};if(e.hasThreeDimensionalModelEntry)return{ext:"3mf",mime:"model/3mf"}}}function iS(e){const t=e.indexOf('.main+xml"');if(t===-1){const a="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";return e.includes(`ContentType="${a}"`)?a:void 0}const r=e.slice(0,t),n=r.lastIndexOf('"');return r.slice(n+1)}class Fl{constructor(t){$d(this,"detectConfident",async n=>{if(this.buffer=new Uint8Array(Jn),n.fileInfo.size===void 0&&(n.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=n,pt(n)&&(await n.peekBuffer(this.buffer,{length:3,mayBeLess:!0}),this.check([31,139,8])))return this.detectGzip(n);if(await n.peekBuffer(this.buffer,{length:32,mayBeLess:!0}),this.check([66,77]))return{ext:"bmp",mime:"image/bmp"};if(this.check([11,119]))return{ext:"ac3",mime:"audio/vnd.dolby.dd-raw"};if(this.check([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(this.check([77,90]))return{ext:"exe",mime:"application/x-msdownload"};if(this.check([37,33]))return await n.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString("PS-Adobe-",{offset:2})&&this.checkString(" EPSF-",{offset:14})?{ext:"eps",mime:"application/eps"}:{ext:"ps",mime:"application/postscript"};if(this.check([31,160])||this.check([31,157]))return{ext:"Z",mime:"application/x-compress"};if(this.check([199,113]))return{ext:"cpio",mime:"application/x-cpio"};if(this.check([96,234]))return{ext:"arj",mime:"application/x-arj"};if(this.check([239,187,191]))return this.detectionReentryCount>=Md?void 0:(this.detectionReentryCount++,await this.tokenizer.ignore(3),this.detectConfident(n));if(this.check([71,73,70]))return{ext:"gif",mime:"image/gif"};if(this.check([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(this.check([31,139,8]))return this.detectGzip(n);if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await Ir(n,6,{maximumLength:6,reason:"ID3 header prefix"});const a=await n.readToken(S2),s=pt(n);if(!Number.isFinite(a)||a<0||s&&(a>zs||n.position+a>zs))return;if(n.position+a>n.fileInfo.size)return s?void 0:{ext:"mp3",mime:"audio/mpeg"};try{await Ir(n,a,{maximumLength:s?zs:n.fileInfo.size,reason:"ID3 payload"})}catch(i){if(i instanceof Qe)return;throw i}return this.detectionReentryCount>=Md?void 0:(this.detectionReentryCount++,this.parseTokenizer(n,this.detectionReentryCount))}if(this.checkString("MP+"))return{ext:"mpc",mime:"audio/x-musepack"};if((this.buffer[0]===67||this.buffer[0]===70)&&this.check([87,83],{offset:1}))return{ext:"swf",mime:"application/x-shockwave-flash"};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:"jls",mime:"image/jls"}:{ext:"jpg",mime:"image/jpeg"};if(this.check([79,98,106,1]))return{ext:"avro",mime:"application/avro"};if(this.checkString("FLIF"))return{ext:"flif",mime:"image/flif"};if(this.checkString("8BPS"))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(this.checkString("MPCK"))return{ext:"mpc",mime:"audio/x-musepack"};if(this.checkString("FORM"))return{ext:"aif",mime:"audio/aiff"};if(this.checkString("icns",{offset:0}))return{ext:"icns",mime:"image/icns"};if(this.check([80,75,3,4])){let a;const s=oS();try{await new va(n).unzip(i=>{sS(s,i.filename);const l=i.filename==="[Content_Types].xml",c=qd(s);if(!l&&c)return a=c,{stop:!0};switch(i.filename){case"META-INF/mozilla.rsa":return a={ext:"xpi",mime:"application/x-xpinstall"},{stop:!0};case"META-INF/MANIFEST.MF":return a={ext:"jar",mime:"application/java-archive"},{stop:!0};case"mimetype":return Wd(i,Od)?{async handler(d){const u=new TextDecoder("utf-8").decode(d).trim();a=Hd(u)},stop:!0}:{};case"[Content_Types].xml":return s.hasContentTypesEntry=!0,Wd(i,Od)?(s.isParsingContentTypes=!0,{async handler(d){const u=new TextDecoder("utf-8").decode(d),m=iS(u);m&&(a=Hd(m)),s.hasParsedContentTypesEntry=!0,s.isParsingContentTypes=!1},stop:!0}):(s.hasUnparseableContentTypes=!0,{});default:return/classes\d*\.dex/.test(i.filename)?(a={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}})}catch(i){if(!aS(i))throw i;s.isParsingContentTypes&&(s.isParsingContentTypes=!1,s.hasUnparseableContentTypes=!0)}return a??qd(s)??{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await n.ignore(28);const a=new Uint8Array(8);return await n.readBuffer(a),sr(a,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:sr(a,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:sr(a,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:sr(a,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:sr(a,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:sr(a,[1,118,111,114,98,105,115])?{ext:"ogg",mime:"audio/ogg"}:{ext:"ogx",mime:"application/ogg"}}if(this.check([80,75])&&(this.buffer[2]===3||this.buffer[2]===5||this.buffer[2]===7)&&(this.buffer[3]===4||this.buffer[3]===6||this.buffer[3]===8))return{ext:"zip",mime:"application/zip"};if(this.checkString("MThd"))return{ext:"mid",mime:"audio/midi"};if(this.checkString("wOFF")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff",mime:"font/woff"};if(this.checkString("wOF2")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff2",mime:"font/woff2"};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:"pcap",mime:"application/vnd.tcpdump.pcap"};if(this.checkString("DSD "))return{ext:"dsf",mime:"audio/x-dsf"};if(this.checkString("LZIP"))return{ext:"lz",mime:"application/x-lzip"};if(this.checkString("fLaC"))return{ext:"flac",mime:"audio/flac"};if(this.check([66,80,71,251]))return{ext:"bpg",mime:"image/bpg"};if(this.checkString("wvpk"))return{ext:"wv",mime:"audio/wavpack"};if(this.checkString("%PDF"))return{ext:"pdf",mime:"application/pdf"};if(this.check([0,97,115,109]))return{ext:"wasm",mime:"application/wasm"};if(this.check([73,73])){const a=await this.readTiffHeader(!1);if(a)return a}if(this.check([77,77])){const a=await this.readTiffHeader(!0);if(a)return a}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163])){async function a(){const d=await n.peekNumber(YN);let u=128,m=0;for(;!(d&u)&&u!==0;)++m,u>>=1;const p=new Uint8Array(m+1);return await Ls(n,p,void 0,{maximumLength:p.length,reason:"EBML field"}),p}async function s(){const d=await a(),u=await a();u[0]^=128>>u.length-1;const m=Math.min(6,u.length),p=new DataView(d.buffer),f=new DataView(u.buffer,u.length-m,m);return{id:Pd(p),len:Pd(f)}}async function i(d){let u=0;for(;d>0;){if(u++,u>I2||Qn(n,c,Vt))return;const m=n.position,p=await s();if(p.id===17026){if(p.len>zd)return;const f=Ol(p.len,zd,"EBML DocType");return(await n.readToken(new br(f))).replaceAll(/\00.*$/g,"")}if(pt(n)&&(!Number.isFinite(p.len)||p.len<0||p.len>Ld)||(await Ir(n,p.len,{maximumLength:pt(n)?Ld:n.fileInfo.size,reason:"EBML payload"}),--d,n.position<=m))return}}const l=await s(),c=n.position;switch(await i(l.len)){case"webm":return{ext:"webm",mime:"video/webm"};case"matroska":return{ext:"mkv",mime:"video/matroska"};default:return}}if(this.checkString("SQLi"))return{ext:"sqlite",mime:"application/x-sqlite3"};if(this.check([78,69,83,26]))return{ext:"nes",mime:"application/x-nintendo-nes-rom"};if(this.checkString("Cr24"))return{ext:"crx",mime:"application/x-google-chrome-extension"};if(this.checkString("MSCF")||this.checkString("ISc("))return{ext:"cab",mime:"application/vnd.ms-cab-compressed"};if(this.check([237,171,238,219]))return{ext:"rpm",mime:"application/x-rpm"};if(this.check([197,208,211,198]))return{ext:"eps",mime:"application/eps"};if(this.check([40,181,47,253]))return{ext:"zst",mime:"application/zstd"};if(this.check([127,69,76,70]))return{ext:"elf",mime:"application/x-elf"};if(this.check([33,66,68,78]))return{ext:"pst",mime:"application/vnd.ms-outlook"};if(this.checkString("PAR1")||this.checkString("PARE"))return{ext:"parquet",mime:"application/vnd.apache.parquet"};if(this.checkString("ttcf"))return{ext:"ttc",mime:"font/collection"};if(this.check([254,237,250,206])||this.check([254,237,250,207])||this.check([206,250,237,254])||this.check([207,250,237,254]))return{ext:"macho",mime:"application/x-mach-binary"};if(this.check([4,34,77,24]))return{ext:"lz4",mime:"application/x-lz4"};if(this.checkString("regf"))return{ext:"dat",mime:"application/x-ft-windows-registry-hive"};if(this.checkString("$FL2")||this.checkString("$FL3"))return{ext:"sav",mime:"application/x-spss-sav"};if(this.check([79,84,84,79,0]))return{ext:"otf",mime:"font/otf"};if(this.checkString("#!AMR"))return{ext:"amr",mime:"audio/amr"};if(this.checkString("{\\rtf"))return{ext:"rtf",mime:"application/rtf"};if(this.check([70,76,86,1]))return{ext:"flv",mime:"video/x-flv"};if(this.checkString("IMPM"))return{ext:"it",mime:"audio/x-it"};if(this.checkString("-lh0-",{offset:2})||this.checkString("-lh1-",{offset:2})||this.checkString("-lh2-",{offset:2})||this.checkString("-lh3-",{offset:2})||this.checkString("-lh4-",{offset:2})||this.checkString("-lh5-",{offset:2})||this.checkString("-lh6-",{offset:2})||this.checkString("-lh7-",{offset:2})||this.checkString("-lzs-",{offset:2})||this.checkString("-lz4-",{offset:2})||this.checkString("-lz5-",{offset:2})||this.checkString("-lhd-",{offset:2}))return{ext:"lzh",mime:"application/x-lzh-compressed"};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:"mpg",mime:"video/MP1S"};if(this.check([68],{offset:4,mask:[196]}))return{ext:"mpg",mime:"video/MP2P"}}if(this.checkString("ITSF"))return{ext:"chm",mime:"application/vnd.ms-htmlhelp"};if(this.check([202,254,186,190])){const a=Td.get(this.buffer,4),s=gn.get(this.buffer,6);if(a>0&&a<=30)return{ext:"macho",mime:"application/x-mach-binary"};if(s>30)return{ext:"class",mime:"application/java-vm"}}if(this.checkString(".RMF"))return{ext:"rm",mime:"application/vnd.rn-realmedia"};if(this.checkString("DRACO"))return{ext:"drc",mime:"application/vnd.google.draco"};if(this.check([253,55,122,88,90,0]))return{ext:"xz",mime:"application/x-xz"};if(this.checkString("<?xml "))return{ext:"xml",mime:"application/xml"};if(this.check([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(this.check([82,97,114,33,26,7])&&(this.buffer[6]===0||this.buffer[6]===1))return{ext:"rar",mime:"application/x-rar-compressed"};if(this.checkString("solid "))return{ext:"stl",mime:"model/stl"};if(this.checkString("AC")){const a=new br(4,"latin1").get(this.buffer,2);if(a.match("^d*")&&a>=1e3&&a<=1050)return{ext:"dwg",mime:"image/vnd.dwg"}}if(this.checkString("070707"))return{ext:"cpio",mime:"application/x-cpio"};if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!<arch>"))return await n.ignore(8),await n.readToken(new br(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("WEBVTT")&&[`
|
|
83
83
|
`,"\r"," "," ","\0"].some(a=>this.checkString(a,{offset:6})))return{ext:"vtt",mime:"text/vtt"};if(this.check([137,80,78,71,13,10,26,10])){const a={ext:"png",mime:"image/png"},s={ext:"apng",mime:"image/apng"};await n.ignore(8);async function i(){return{length:await n.readToken(JN),type:await n.readToken(new br(4,"latin1"))}}const l=pt(n),c=n.position;let d=0,u=!1;do{if(d++,d>P2||Qn(n,c,_2))break;const m=n.position,p=await i();if(p.length<0)return;if(p.type==="IHDR"){if(p.length!==13)return;u=!0}switch(p.type){case"IDAT":return a;case"acTL":return s;default:if(!u&&p.type!=="CgBI")return;if(l&&p.length>Vd)return u&&q2(p.type)?a:void 0;try{await Ir(n,p.length+4,{maximumLength:l?Vd+4:n.fileInfo.size,reason:"PNG chunk payload"})}catch(f){if(!l&&(f instanceof Jr||f instanceof Qe))return a;throw f}}if(n.position<=m)break}while(n.position+8<n.fileInfo.size);return a}if(this.check([65,82,82,79,87,49,0,0]))return{ext:"arrow",mime:"application/vnd.apache.arrow.file"};if(this.check([103,108,84,70,2,0,0,0]))return{ext:"glb",mime:"model/gltf-binary"};if(this.check([102,114,101,101],{offset:4})||this.check([109,100,97,116],{offset:4})||this.check([109,111,111,118],{offset:4})||this.check([119,105,100,101],{offset:4}))return{ext:"mov",mime:"video/quicktime"};if(this.check([73,73,82,79,8,0,0,0,24]))return{ext:"orf",mime:"image/x-olympus-orf"};if(this.checkString("gimp xcf "))return{ext:"xcf",mime:"image/x-xcf"};if(this.checkString("ftyp",{offset:4})&&this.buffer[8]&96){const a=new br(4,"latin1").get(this.buffer,8).replace("\0"," ").trim();switch(a){case"avif":case"avis":return{ext:"avif",mime:"image/avif"};case"mif1":return{ext:"heic",mime:"image/heif"};case"msf1":return{ext:"heic",mime:"image/heif-sequence"};case"heic":case"heix":return{ext:"heic",mime:"image/heic"};case"hevc":case"hevx":return{ext:"heic",mime:"image/heic-sequence"};case"qt":return{ext:"mov",mime:"video/quicktime"};case"M4V":case"M4VH":case"M4VP":return{ext:"m4v",mime:"video/x-m4v"};case"M4P":return{ext:"m4p",mime:"video/mp4"};case"M4B":return{ext:"m4b",mime:"audio/mp4"};case"M4A":return{ext:"m4a",mime:"audio/x-m4a"};case"F4V":return{ext:"f4v",mime:"video/mp4"};case"F4P":return{ext:"f4p",mime:"video/mp4"};case"F4A":return{ext:"f4a",mime:"audio/mp4"};case"F4B":return{ext:"f4b",mime:"audio/mp4"};case"crx":return{ext:"cr3",mime:"image/x-canon-cr3"};default:return a.startsWith("3g")?a.startsWith("3g2")?{ext:"3g2",mime:"video/3gpp2"}:{ext:"3gp",mime:"video/3gpp"}:{ext:"mp4",mime:"video/mp4"}}}if(this.checkString(`REGEDIT4\r
|
|
84
84
|
`))return{ext:"reg",mime:"application/x-ms-regedit"};if(this.check([82,73,70,70])){if(this.checkString("WEBP",{offset:8}))return{ext:"webp",mime:"image/webp"};if(this.check([65,86,73],{offset:8}))return{ext:"avi",mime:"video/vnd.avi"};if(this.check([87,65,86,69],{offset:8}))return{ext:"wav",mime:"audio/wav"};if(this.check([81,76,67,77],{offset:8}))return{ext:"qcp",mime:"audio/qcelp"}}if(this.check([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:"rw2",mime:"image/x-panasonic-rw2"};if(this.check([48,38,178,117,142,102,207,17,166,217])){let a=!1;try{async function s(){const d=new Uint8Array(16);return await Ls(n,d,void 0,{maximumLength:d.length,reason:"ASF header GUID"}),{id:d,size:Number(await n.readToken(QN))}}await Ir(n,30,{maximumLength:30,reason:"ASF header prelude"});const i=pt(n),l=n.position;let c=0;for(;n.position+24<n.fileInfo.size&&(c++,!(c>O2||Qn(n,l,Vt)));){const d=n.position,u=await s();let m=u.size-24;if(!Number.isFinite(m)||m<0){a=!0;break}if(sr(u.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){const p=new Uint8Array(16);if(m-=await Ls(n,p,void 0,{maximumLength:p.length,reason:"ASF stream type GUID"}),sr(p,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"audio/x-ms-asf"};if(sr(p,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"video/x-ms-asf"};break}if(i&&m>Bd){a=!0;break}if(await Ir(n,m,{maximumLength:i?Bd:n.fileInfo.size,reason:"ASF header payload"}),n.position<=d){a=!0;break}}}catch(s){if(s instanceof Qe||s instanceof Jr)pt(n)&&(a=!0);else throw s}return a?void 0:{ext:"asf",mime:"application/vnd.ms-asf"}}if(this.check([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:"ktx",mime:"image/ktx"};if((this.check([126,16,4])||this.check([126,24,4]))&&this.check([48,77,73,69],{offset:4}))return{ext:"mie",mime:"application/x-mie"};if(this.check([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:"shp",mime:"application/x-esri-shape"};if(this.check([255,79,255,81]))return{ext:"j2c",mime:"image/j2c"};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10]))switch(await n.ignore(20),await n.readToken(new br(4,"ascii"))){case"jp2 ":return{ext:"jp2",mime:"image/jp2"};case"jpx ":return{ext:"jpx",mime:"image/jpx"};case"jpm ":return{ext:"jpm",mime:"image/jpm"};case"mjp2":return{ext:"mj2",mime:"image/mj2"};default:return}if(this.check([255,10])||this.check([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:"jxl",mime:"image/jxl"};if(this.check([254,255]))return this.checkString("<?xml ",{offset:2,encoding:"utf-16be"})?{ext:"xml",mime:"application/xml"}:void 0;if(this.check([208,207,17,224,161,177,26,225]))return{ext:"cfb",mime:"application/x-cfb"};if(await n.peekBuffer(this.buffer,{length:Math.min(256,n.fileInfo.size),mayBeLess:!0}),this.check([97,99,115,112],{offset:36}))return{ext:"icc",mime:"application/vnd.iccprofile"};if(this.checkString("**ACE",{offset:7})&&this.checkString("**",{offset:12}))return{ext:"ace",mime:"application/x-ace-compressed"};if(this.checkString("BEGIN:")){if(this.checkString("VCARD",{offset:6}))return{ext:"vcf",mime:"text/vcard"};if(this.checkString("VCALENDAR",{offset:6}))return{ext:"ics",mime:"text/calendar"}}if(this.checkString("FUJIFILMCCD-RAW"))return{ext:"raf",mime:"image/x-fujifilm-raf"};if(this.checkString("Extended Module:"))return{ext:"xm",mime:"audio/x-xm"};if(this.checkString("Creative Voice File"))return{ext:"voc",mime:"audio/x-voc"};if(this.check([4,0,0,0])&&this.buffer.length>=16){const a=new DataView(this.buffer.buffer).getUint32(12,!0);if(a>12&&this.buffer.length>=a+16)try{const s=new TextDecoder().decode(this.buffer.subarray(16,a+16));if(JSON.parse(s).files)return{ext:"asar",mime:"application/x-asar"}}catch{}}if(this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2]))return{ext:"mxf",mime:"application/mxf"};if(this.checkString("SCRM",{offset:44}))return{ext:"s3m",mime:"audio/x-s3m"};if(this.check([71])&&this.check([71],{offset:188}))return{ext:"mts",mime:"video/mp2t"};if(this.check([71],{offset:4})&&this.check([71],{offset:196}))return{ext:"mts",mime:"video/mp2t"};if(this.check([66,79,79,75,77,79,66,73],{offset:60}))return{ext:"mobi",mime:"application/x-mobipocket-ebook"};if(this.check([68,73,67,77],{offset:128}))return{ext:"dcm",mime:"application/dicom"};if(this.check([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70]))return{ext:"lnk",mime:"application/x.ms.shortcut"};if(this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0]))return{ext:"alias",mime:"application/x.apple.alias"};if(this.checkString("Kaydara FBX Binary \0"))return{ext:"fbx",mime:"application/x.autodesk.fbx"};if(this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8})))return{ext:"eot",mime:"application/vnd.ms-fontobject"};if(this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29]))return{ext:"indd",mime:"application/x-indesign"};if(this.check([255,255,0,0,7,0,0,0,4,0,0,0,1,0,1,0])||this.check([0,0,255,255,0,0,0,7,0,0,0,4,0,1,0,1]))return{ext:"jmp",mime:"application/x-jmp-data"};if(await n.peekBuffer(this.buffer,{length:Math.min(512,n.fileInfo.size),mayBeLess:!0}),this.checkString("ustar",{offset:257})&&(this.checkString("\0",{offset:262})||this.checkString(" ",{offset:262}))||this.check([0,0,0,0,0,0],{offset:257})&&N2(this.buffer))return{ext:"tar",mime:"application/x-tar"};if(this.check([255,254])){const a="utf-16le";return this.checkString("<?xml ",{offset:2,encoding:a})?{ext:"xml",mime:"application/xml"}:this.check([255,14],{offset:2})&&this.checkString("SketchUp Model",{offset:4,encoding:a})?{ext:"skp",mime:"application/vnd.sketchup.skp"}:this.checkString(`Windows Registry Editor Version 5.00\r
|
|
85
|
-
`,{offset:2,encoding:a})?{ext:"reg",mime:"application/x-ms-regedit"}:void 0}if(this.checkString("-----BEGIN PGP MESSAGE-----"))return{ext:"pgp",mime:"application/pgp-encrypted"}}),$d(this,"detectImprecise",async n=>{this.buffer=new Uint8Array(Jn);const a=rS(n.fileInfo.size);if(await n.peekBuffer(this.buffer,{length:Math.min(8,a),mayBeLess:!0}),this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(this.check([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(this.check([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(this.check([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(await n.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,a),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let s=0;s<=this.options.mpegOffsetTolerance;++s){const i=this.scanMpeg(s);if(i)return i}});const r=tS(t==null?void 0:t.mpegOffsetTolerance);this.options={...t,mpegOffsetTolerance:r},this.detectors=[...this.options.customDetectors??[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:this.options.signal},this.gzipProbeDepth=0}getTokenizerOptions(){return{...this.tokenizerOptions}}createTokenizerFromWebStream(t){return B2(c2(t,this.getTokenizerOptions()))}async parseTokenizer(t,r=0){this.detectionReentryCount=r;const n=t.position;for(const a of this.detectors){let s;try{s=await a.detect(t)}catch(i){if(i instanceof Qe||i instanceof Jr)return;throw i}if(s)return s;if(n!==t.position)return}}async fromTokenizer(t){try{return await this.parseTokenizer(t)}finally{await t.close()}}async fromBuffer(t){if(!(t instanceof Uint8Array||t instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof t}\``);const r=t instanceof Uint8Array?t:new Uint8Array(t);if((r==null?void 0:r.length)>1)return this.fromTokenizer(d2(r,this.getTokenizerOptions()))}async fromBlob(t){var r;(r=this.options.signal)==null||r.throwIfAborted();const n=u2(t,this.getTokenizerOptions());return this.fromTokenizer(n)}async fromStream(t){var r;(r=this.options.signal)==null||r.throwIfAborted();const n=this.createTokenizerFromWebStream(t);return this.fromTokenizer(n)}async toDetectionStream(t,r){const n=Q2((r==null?void 0:r.sampleSize)??Jn);let a,s;const i=t.getReader({mode:"byob"});try{const{value:d,done:u}=await eS(i,new Uint8Array(n),this.options.signal);if(s=d,!u&&d)try{a=await this.fromBuffer(d.subarray(0,n))}catch(m){if(!(m instanceof Qe))throw m;a=void 0}s=d}finally{i.releaseLock()}const l=new TransformStream({async start(d){d.enqueue(s)},transform(d,u){u.enqueue(d)}}),c=t.pipeThrough(l);return c.fileType=a,c}async detectGzip(t){var r;if(this.gzipProbeDepth>=R2)return{ext:"gz",mime:"application/gzip"};const n=new k2(t),a=Y2(n.inflate(),A2),s=pt(t);let i,l,c,d;if(s){const u=new AbortController;i=setTimeout(()=>{u.abort(new DOMException(`Operation timed out after ${Fd} ms`,"TimeoutError"))},Fd),l=this.options.signal===void 0?u.signal:AbortSignal.any([this.options.signal,u.signal]),c=new Fl({...this.options,signal:l}),c.gzipProbeDepth=this.gzipProbeDepth+1}else this.gzipProbeDepth++;try{d=await(c??this).fromStream(a)}catch(u){if((u==null?void 0:u.name)==="AbortError"&&((r=l==null?void 0:l.reason)==null?void 0:r.name)!=="TimeoutError")throw u}finally{clearTimeout(i),s||this.gzipProbeDepth--}return(d==null?void 0:d.ext)==="tar"?{ext:"tar.gz",mime:"application/gzip"}:{ext:"gz",mime:"application/gzip"}}check(t,r){return sr(this.buffer,t,r)}checkString(t,r){return this.check(C2(t,r==null?void 0:r.encoding),r)}async readTiffTag(t){const r=await this.tokenizer.readToken(t?gn:We);switch(await this.tokenizer.ignore(10),r){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"}}}async readTiffIFD(t){const r=await this.tokenizer.readToken(t?gn:We);if(!(r>F2)&&!(pt(this.tokenizer)&&2+r*12>Ud))for(let n=0;n<r;++n){const a=await this.readTiffTag(t);if(a)return a}}async readTiffHeader(t){const r={ext:"tif",mime:"image/tiff"},n=(t?gn:We).get(this.buffer,2),a=(t?Td:Xe).get(this.buffer,4);if(n===42){if(a>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(a>=8){const l=(t?gn:We).get(this.buffer,8),c=(t?gn:We).get(this.buffer,10);if(l===28&&c===254||l===31&&c===11)return{ext:"nef",mime:"image/x-nikon-nef"}}}if(pt(this.tokenizer)&&a>z2)return r;const s=pt(this.tokenizer)?Ud:this.tokenizer.fileInfo.size;try{await Ir(this.tokenizer,a,{maximumLength:s,reason:"TIFF IFD offset"})}catch(l){if(l instanceof Qe)return;throw l}let i;try{i=await this.readTiffIFD(t)}catch(l){if(l instanceof Qe)return;throw l}return i??r}if(n===43)return r}scanMpeg(t){if(this.check([255,224],{offset:t,mask:[255,224]})){if(this.check([16],{offset:t+1,mask:[22]}))return this.check([8],{offset:t+1,mask:[8]})?{ext:"aac",mime:"audio/aac"}:{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:t+1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:t+1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:t+1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}}new Set($2);new Set(E2);const Gd=e=>e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`,bx=({name:e,control:t,disabled:r,campo:n,fileTypes:a,maxFileSize:s})=>{var i;const{field:l,fieldState:c}=Me({name:e,control:t}),{uploadFile:d,deleteUploadedFile:u}=Hr(),[m,p]=N.useState({status:"idle"}),f=N.useRef(null),[b,h]=N.useState(!1),x=N.useRef(!0);N.useEffect(()=>()=>{x.current=!1},[]);const y=typeof l.value=="string"&&l.value?l.value:null,v=N.useCallback(async S=>{var $;if(a&&a.length>0){const k=await J2(S),E=(k==null?void 0:k.ext)??"",D=(k==null?void 0:k.mime)??"",O=(($=S.name.split(".").pop())==null?void 0:$.toLowerCase())??"",L=S.type.toLowerCase();if(!a.some(A=>{const z=A.toLowerCase();return!!(E&&(z===E||z===D)||D&&z.endsWith("/*")&&D.startsWith(z.slice(0,-1))||!E&&(z===O||z===L||z.endsWith("/*")&&L.startsWith(z.slice(0,-1))))})){p({status:"error",message:`Tipo de arquivo não permitido. Permitidos: ${a.join(", ")}`});return}}if(s&&S.size>s){p({status:"error",message:`Arquivo muito grande. Tamanho máximo: ${Gd(s)}`});return}if(!d){p({status:"error",message:"Preview: upload não disponível sem configuração."});return}p({status:"uploading",fileName:S.name,progress:0});try{if(y&&u)try{await u(y)}catch{}const k=await d(S,n??e,E=>{x.current&&p(D=>D.status==="uploading"?{...D,progress:Math.min(100,E)}:D)});if(!x.current)return;l.onChange(k),p({status:"done",uploadId:k,fileName:S.name,size:S.size})}catch{if(!x.current)return;p({status:"error",message:"Falha no upload. Tente novamente."})}},[d,u,y,n,e,l,a,s]),j=N.useCallback(S=>{var $;const k=($=S.target.files)==null?void 0:$[0];k&&v(k),S.target.value=""},[v]),w=N.useCallback(()=>{l.onChange(""),p({status:"idle"}),f.current&&(f.current.value="")},[l]);if(m.status==="done"||m.status==="idle"&&y){const S=m.status==="done"?m.fileName:"Arquivo enviado",$=m.status==="done"?m.size:null;return o.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-input bg-muted/20 px-4 py-3 gap-2",children:[o.jsx("span",{className:"text-sm font-medium truncate flex-1",children:S}),$!==null&&o.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:Gd($)}),!r&&o.jsx("button",{type:"button",onClick:w,className:"ml-2 shrink-0 text-muted-foreground hover:text-destructive transition-colors","aria-label":"Remover arquivo",children:"✕"})]})}if(m.status==="uploading"){const{fileName:S,progress:$}=m;return o.jsxs("div",{className:"rounded-lg border border-input px-4 py-3 space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-sm font-medium truncate flex-1",children:S}),o.jsxs("span",{className:"text-xs text-muted-foreground ml-2",children:[$,"%"]})]}),o.jsx("div",{className:"h-2 rounded-full bg-muted overflow-hidden",children:o.jsx("div",{className:"h-full bg-primary transition-all duration-200 rounded-full",style:{width:`${$}%`}})})]})}const C=m.status==="error";return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{role:"button",tabIndex:r?-1:0,"aria-label":"Selecionar arquivo",className:K("flex items-center justify-center rounded-lg border-2 border-dashed px-4 py-6 transition-colors cursor-pointer",b?"border-primary bg-primary/5":C||c.error?"border-destructive bg-destructive/5":"border-input hover:border-muted-foreground hover:bg-muted/20",r&&"opacity-50 cursor-not-allowed"),onClick:()=>{var S;return!r&&((S=f.current)==null?void 0:S.click())},onKeyDown:S=>{var $;(S.key==="Enter"||S.key===" ")&&(($=f.current)==null||$.click())},onDragOver:S=>{S.preventDefault(),r||h(!0)},onDragLeave:()=>h(!1),onDrop:r?void 0:S=>{var $;S.preventDefault(),h(!1);const k=($=S.dataTransfer.files)==null?void 0:$[0];k&&v(k)},onBlur:l.onBlur,children:[o.jsx("input",{ref:f,type:"file",onChange:j,disabled:r,className:"sr-only"}),o.jsx("span",{className:"text-sm text-muted-foreground",children:b?"Solte o arquivo aqui":"Clique ou arraste um arquivo"})]}),C&&o.jsxs("p",{className:"text-sm text-destructive",children:[m.message," · ",o.jsx("button",{type:"button",className:"underline hover:no-underline",onClick:()=>p({status:"idle"}),children:"Tentar novamente"})]}),!C&&((i=c.error)==null?void 0:i.message)&&o.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})},lS={cpf:e=>e.replace(/\D/g,"").slice(0,11).replace(/(\d{3})(\d)/,"$1.$2").replace(/(\d{3})(\d)/,"$1.$2").replace(/(\d{3})(\d{1,2})$/,"$1-$2"),telefone:e=>{const t=e.replace(/\D/g,"").slice(0,11);return t.length<=10?t.replace(/(\d{2})(\d)/,"($1) $2").replace(/(\d{4})(\d)/,"$1-$2"):t.replace(/(\d{2})(\d)/,"($1) $2").replace(/(\d{5})(\d)/,"$1-$2")},cep:e=>e.replace(/\D/g,"").slice(0,8).replace(/(\d{5})(\d)/,"$1-$2")},Qr=({name:e,control:t,placeholder:r,maskType:n,disabled:a,readOnly:s})=>{var i;const{field:l,fieldState:c}=Me({name:e,control:t}),d=lS[n||""],u=N.useCallback(m=>{l.onChange(d?d(m.target.value):m.target.value)},[l,d]);return o.jsxs("div",{className:"space-y-1",children:[o.jsx(ue,{name:l.name,value:l.value||"",onChange:u,onBlur:l.onBlur,placeholder:r,disabled:a,readOnly:s,className:K(c.error&&"border-destructive focus-visible:ring-destructive")}),((i=c.error)==null?void 0:i.message)&&o.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})},zl=({name:e,control:t})=>{const{field:r}=Me({name:e,control:t});return o.jsx("input",{type:"hidden",...r,value:r.value??""})},yx=e=>e.replace(/\D/g,""),cS=e=>{const t=yx(e).slice(0,8);return t.length<=5?t:`${t.slice(0,5)}-${t.slice(5)}`},dS=async(e,t)=>{const r=await fetch(`https://viacep.com.br/ws/${e}/json/`,{signal:t});if(!r.ok)throw new Error("Falha ao consultar CEP");return r.json()},wx=({name:e,control:t,placeholder:r="00000-000",disabled:n,readOnly:a,cepFillMap:s})=>{var i,l;const{field:c,fieldState:d}=Me({name:e,control:t}),{setValue:u}=lN(),{cepLookup:m}=Hr(),[p,f]=N.useState("idle"),[b,h]=N.useState(null),x=N.useRef(null),y=N.useRef(!0);N.useEffect(()=>()=>{var w;y.current=!1,(w=x.current)==null||w.abort()},[]);const v=N.useCallback(async()=>{var w;c.onBlur();const C=yx(c.value??"");if(C.length===8){(w=x.current)==null||w.abort(),x.current=new AbortController,f("loading"),h(null);try{let S;if(m){const E=x.current;if(S=await m(C,E.signal),E.signal.aborted||!y.current)return}else{const E=await dS(C,x.current.signal);if(!y.current)return;if(E.erro){f("error"),h("CEP não encontrado");return}S={logradouro:E.logradouro,bairro:E.bairro,cidade:E.localidade,estado:E.uf}}if(!y.current)return;if(S.erro){f("error"),h("CEP não encontrado");return}const $=e.includes(".")?`${e.substring(0,e.lastIndexOf("."))}.`:"",k=(E,D,O)=>{if(!O)return;const L=s!=null&&s[E]?`${$}${s[E]}`:`${$}${D}`;u(L,O,{shouldDirty:!0,shouldValidate:!0})};k("logradouro","_address_logradouro",S.logradouro),k("bairro","_address_bairro",S.bairro),k("cidade","_address_cidade",S.cidade),k("estado","_address_estado",S.estado),f("success")}catch(S){if(S instanceof Error&&S.name==="AbortError"||!y.current)return;f("error"),h("Erro ao buscar CEP")}}},[c,m,u,e,s]),j=N.useCallback(w=>{c.onChange(cS(w.target.value))},[c]);return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"relative",children:[o.jsx(ue,{name:c.name,value:c.value||"",onChange:j,onBlur:v,placeholder:r,disabled:n,readOnly:a,className:K("pr-9",d.error&&"border-destructive focus-visible:ring-destructive")}),o.jsxs("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none",children:[p==="loading"&&o.jsx(_.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"}),p==="success"&&o.jsx(_.Check,{className:"h-4 w-4 text-green-500"}),p==="error"&&o.jsx(_.AlertCircle,{className:"h-4 w-4 text-destructive"})]})]}),(((i=d.error)==null?void 0:i.message)||b)&&o.jsx("p",{className:"text-sm text-destructive",children:((l=d.error)==null?void 0:l.message)||b})]})},uS=({field:e,control:t,nameOverride:r})=>{const n={name:r,control:t,placeholder:e.placeholder};switch(e.tipo){case T.TEXTO:return o.jsx(Mt,{...n,type:"text"});case T.EMAIL:return o.jsx(Mt,{...n,type:"email"});case T.NUMBER:return o.jsx(Mt,{...n,type:"number"});case T.TEXTAREA:return o.jsx(Al,{...n});case T.SELECT:return o.jsx(Rl,{...n,options:e.opcoes??[]});case T.RADIO:return o.jsx(px,{...n,options:e.opcoes??[]});case T.CHECKBOX:return o.jsx(Il,{name:r,control:t,label:e.label});case T.CHECKBOX_GROUP:return o.jsx(mx,{...n,options:e.opcoes??[]});case T.DATE:return o.jsx(aa,{...n,validacao:e.validacao});case T.DATETIME:return o.jsx(aa,{...n,isDatetime:!0,validacao:e.validacao});case T.FILE:return o.jsx(bx,{name:r,control:t});case T.TELEFONE:return o.jsx(Qr,{...n,maskType:"telefone"});case T.CPF:return o.jsx(Qr,{...n,maskType:"cpf"});case T.CEP:return o.jsx(wx,{name:r,control:t,placeholder:e.placeholder});case T.HIDDEN:return o.jsx(zl,{name:r,control:t});default:return console.error(`[DFFieldArray] Tipo de sub-campo "${e.tipo}" não suportado em FIELD_ARRAY. Usando DFTextField como fallback.`),o.jsx(Mt,{...n,type:"text"})}},mS=({name:e,control:t,subFields:r=[],minItems:n=1,maxItems:a,itemLabel:s="Item",addLabel:i})=>{var l;const{fields:c,append:d,remove:u}=dx({control:t,name:e}),{errors:m}=rx({control:t}),p=(l=m[e])==null?void 0:l.message,f=N.useCallback(()=>{const y={};for(const v of r)v.initialValue!==void 0?y[v.nome]=v.initialValue:v.defaultValue!==void 0&&(y[v.nome]=v.defaultValue);return y},[r]);N.useEffect(()=>{if(c.length<n)for(let y=c.length;y<n;y++)d(f())},[n]);const b=[...r].sort((y,v)=>y.ordem-v.ordem),h=!a||c.length<a,x=i??`Adicionar ${s.toLowerCase()}`;return o.jsxs("div",{className:"space-y-3",children:[c.map((y,v)=>o.jsxs("div",{className:"rounded-lg border border-input p-4",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-primary/10 text-xs font-bold text-primary shrink-0",children:v+1}),o.jsxs("span",{className:"text-sm font-semibold",children:[s," ",v+1]})]}),c.length>n&&o.jsx(De,{type:"button",variant:"ghost",size:"icon",onClick:()=>u(v),"aria-label":`Remover ${s.toLowerCase()} ${v+1}`,className:"text-muted-foreground hover:text-destructive",children:o.jsx(_.Trash2,{className:"w-4 h-4"})})]}),o.jsx("div",{className:"grid grid-cols-12 gap-4",children:b.map(j=>{const w=`${e}.${v}.${j.nome}`,C=`span ${j.tamanho??12}`,S=o.jsx(uS,{field:j,control:t,nameOverride:w});return j.tipo===T.CHECKBOX||j.tipo===T.HIDDEN?o.jsx("div",{className:"max-sm:!col-span-12",style:{gridColumn:C},children:S},j.id):o.jsxs("div",{className:"max-sm:!col-span-12 space-y-2",style:{gridColumn:C},children:[o.jsxs("label",{className:"font-medium flex items-center gap-1 text-sm text-foreground",children:[j.label,j.obrigatorio&&o.jsx("span",{className:"text-destructive",children:"*"})]}),S,j.hint&&o.jsx("p",{className:"text-xs text-muted-foreground",children:j.hint})]},j.id)})})]},y.id)),h&&o.jsxs(De,{type:"button",variant:"outline",className:"w-full",onClick:()=>d(f()),children:[o.jsx(_.Plus,{className:"w-4 h-4"}),x]}),a&&o.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:["Máximo de ",a," ",s.toLowerCase(),a>1?"s":""]}),p&&o.jsxs("p",{className:"text-sm text-destructive flex items-center gap-1",children:[o.jsx(_.AlertCircle,{className:"w-4 h-4 shrink-0"}),p]})]})},Xd=e=>`R$ ${(e/100).toFixed(2).replace(".",",")}`,pS=(e,t)=>{const r=new Date(e.slice(0,10)+"T00:00:00Z"),n=new Date(t.slice(0,10)+"T00:00:00Z");return Math.round((n.getTime()-r.getTime())/864e5)+1},fS=(e,t)=>{const r=[],n=new Date(e.slice(0,10)+"T00:00:00Z"),a=new Date(t.slice(0,10)+"T00:00:00Z");let s=0;for(;n<=a&&s<60;)r.push(n.toISOString().slice(0,10)),n.setUTCDate(n.getUTCDate()+1),s++;return r},hS=e=>{const[t,r,n]=e.split("-").map(Number),a=new Date(Date.UTC(t,r-1,n)),s=String(n).padStart(2,"0"),i=String(r).padStart(2,"0"),l=new Intl.DateTimeFormat("pt-BR",{weekday:"long",timeZone:"UTC"}).format(a),c=l.charAt(0).toUpperCase()+l.slice(1);return`${s}/${i} - ${c}`},xS=(e,t)=>{const r=n=>{const[a,s,i]=n.slice(0,10).split("-");return`${i}/${s}/${a}`};return`${r(e)} a ${r(t)}`},gS=({name:e,control:t})=>{var r;const{field:n,fieldState:a}=Me({name:e,control:t}),{externalData:s={}}=Hr(),i=n.value??null,l=(r=a.error)==null?void 0:r.message,c=V=>s[`evento.${V}`]??s[V],d=c("dataInicioEvento")??"",u=c("dataFimEvento")??"",m=Number(c("valor")??0),p=Number(c("valorPorDia")??0),f=c("vagasTotal"),b=c("vagasPorDia"),h=c("vagasMasculinas"),x=c("vagasFemininas"),y=f!=null?Number(f):null,v=b!=null?Number(b):null,j=h!=null?Number(h):null,w=x!=null?Number(x):null,C=d&&u?fS(d,u):[],S=(d&&u?pS(d,u):0)>1,$=j!=null&&j>0&&w!=null&&w>0,k=j!=null&&w==null?"masculino":w!=null&&j==null?"feminino":null,E=(i==null?void 0:i.tipo)??null,D=(i==null?void 0:i.data)??null,O=(i==null?void 0:i.genero)??null,L=N.useRef(i);L.current=i;const A=N.useRef(n.onChange);A.current=n.onChange,N.useEffect(()=>{var V,M,P;k&&((V=L.current)==null?void 0:V.genero)!==k&&A.current({tipo:((M=L.current)==null?void 0:M.tipo)??null,data:((P=L.current)==null?void 0:P.data)??null,genero:k})},[k]);const z=V=>{const M={tipo:V,data:null};($||k)&&(M.genero=O??k??void 0),n.onChange(M)},X=V=>{const M={tipo:"por_dia",data:V};($||k)&&(M.genero=O??k??void 0),n.onChange(M)},q=V=>{n.onChange({tipo:E,data:D,genero:V})},Z=V=>E===V;return o.jsxs("div",{className:"space-y-3",children:[$&&o.jsxs("div",{className:"flex items-center gap-2 px-1",children:[o.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:"Você é:"}),o.jsx("div",{className:"flex gap-2",children:["masculino","feminino"].map(V=>o.jsx("button",{type:"button",onClick:()=>q(V),className:K("px-3 py-1 rounded-full text-xs font-medium border transition-all",O===V?"border-primary bg-primary/10 text-primary":"border-input text-muted-foreground hover:border-primary/50"),children:V==="masculino"?"Masculino":"Feminino"},V))})]}),o.jsxs("button",{type:"button",onClick:()=>z("todos_os_dias"),className:K("w-full text-left flex items-start gap-3 p-4 rounded-xl border-2 transition-all",Z("todos_os_dias")?"border-primary bg-primary/5":"border-input hover:border-primary/50"),children:[o.jsx("div",{className:K("mt-0.5 p-2 rounded-lg shrink-0 transition-colors",Z("todos_os_dias")?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:o.jsx(_.CalendarCheck2,{className:"w-4 h-4"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"font-semibold text-sm",children:"Participar todos os dias"}),d&&u?o.jsx("p",{className:"text-xs text-muted-foreground",children:xS(d,u)}):o.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Datas do evento"})]}),o.jsxs("div",{className:"text-right shrink-0",children:[m>0&&o.jsx("p",{className:K("font-bold text-sm",Z("todos_os_dias")?"text-primary":"text-foreground"),children:Xd(m)}),y!=null&&y>0&&o.jsxs("p",{className:"text-xs flex items-center justify-end gap-1 text-muted-foreground",children:[o.jsx(_.Users,{className:"w-3 h-3"}),y," vagas disponíveis"]})]})]}),S?o.jsxs("button",{type:"button",onClick:()=>z("por_dia"),className:K("w-full text-left flex items-start gap-3 p-4 rounded-xl border-2 transition-all",Z("por_dia")?"border-primary bg-primary/5":"border-input hover:border-primary/50"),children:[o.jsx("div",{className:K("mt-0.5 p-2 rounded-lg shrink-0 transition-colors",Z("por_dia")?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:o.jsx(_.CalendarDays,{className:"w-4 h-4"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"font-semibold text-sm",children:"Participar um dia"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Escolha o dia desejado abaixo"})]}),o.jsxs("div",{className:"text-right shrink-0",children:[p>0&&o.jsx("p",{className:K("font-bold text-sm",Z("por_dia")?"text-primary":"text-foreground"),children:Xd(p)}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"por dia"})]})]}):d?o.jsxs("div",{className:"flex items-start gap-2 px-3 py-2.5 rounded-lg border border-input bg-muted/30",children:[o.jsx(_.Info,{className:"w-3.5 h-3.5 mt-0.5 shrink-0 text-muted-foreground"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:'Este evento ocorre em apenas 1 dia — a opção "Participar um dia" não é necessária.'})]}):null,E==="por_dia"&&o.jsxs("div",{className:"pl-2 space-y-2",children:[o.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-primary",children:"Selecione o dia:"}),C.length===0?o.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Nenhuma data configurada no evento"}):C.map(V=>o.jsxs("button",{type:"button",onClick:()=>X(V),className:K("w-full text-left flex items-center justify-between px-4 py-3 rounded-lg border transition-all",D===V?"border-primary bg-primary/5":"border-input hover:border-primary/50"),children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("span",{className:K("w-4 h-4 rounded-full border-2 shrink-0 flex items-center justify-center transition-colors",D===V?"border-primary bg-primary":"border-input"),children:D===V&&o.jsx("span",{className:"w-2 h-2 rounded-full bg-white"})}),o.jsx("span",{className:"text-sm",children:hS(V)})]}),v!=null&&o.jsxs("span",{className:"text-xs text-muted-foreground",children:[v," vagas"]})]},V))]}),l&&o.jsx("p",{className:"text-sm text-destructive",children:l})]})},Zd=.0315,Kd=.124,Yd=7,Jd=12,vS=[{id:"pix",label:"PIX",description:"Transferência instantânea (à vista)",Icon:_.Smartphone,taxa:0},{id:"dinheiro",label:"Dinheiro",description:"Pagamento em espécie",Icon:_.Banknote,taxa:0},{id:"cartao",label:"Cartão de Crédito",description:"Débito ou crédito na maquininha",Icon:_.CreditCard,taxa:Zd,taxaLabel:`Taxa: ${(Zd*100).toFixed(2).replace(".",",")}%`}],bS=[{id:"pix",label:"PIX à Vista",description:"Pagamento instantâneo sem parcelamento",Icon:_.Smartphone,taxa:0},{id:"pix_parcelado",label:"PIX Parcelado",description:`Parcelado em até ${Yd}x sem juros`,Icon:_.Smartphone,taxa:0,parcelas:Yd},{id:"cartao",label:"Cartão de Crédito",description:`Parcelado em até ${Jd}x`,Icon:_.CreditCard,taxa:Kd,parcelas:Jd,taxaLabel:`Taxa: ${(Kd*100).toFixed(2).replace(".",",")}%`},{id:"dinheiro",label:"Dinheiro",description:"Pagamento em espécie",Icon:_.Banknote,taxa:0}],Fa=e=>`R$ ${(e/100).toFixed(2).replace(".",",")}`,Qd=(e,t)=>Math.round(e*(1+t)*100)/100,yS=(e,t)=>Math.round(e/t*100)/100,wS=({name:e,control:t,relatedFieldName:r="tipo_participacao"})=>{var n;const{field:a,fieldState:s}=Me({name:e,control:t}),{externalData:i={},paymentMethodOptions:l}=Hr(),c=a.value??null,d=(n=s.error)==null?void 0:n.message,u=Mn({control:t,name:r}),m=(u==null?void 0:u.tipo)??null,p=j=>i[`evento.${j}`]??i[j],f=Number(p("valor")??0),b=Number(p("valorPorDia")??0),h=m==="por_dia"&&b>0?b:f,x=m==="por_dia"?(l==null?void 0:l.porDia)??vS:(l==null?void 0:l.todosOsDias)??bS,y=m==="por_dia"?(()=>{if(!(u!=null&&u.data))return"Um dia";const j=u.data.split("-");if(j.length===3){const[w,C,S]=j;return`${S}/${C}/${w}`}return u.data})():"Todos os dias",v=j=>{if(j.disabled)return;const w=Qd(h,j.taxa),C={metodo:j.id,valorTotal:w};j.parcelas&&(C.parcelas=j.parcelas),a.onChange(C)};return o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-input px-4 py-3",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:"Tipo de participação"}),o.jsx("p",{className:"font-semibold",children:y})]}),o.jsxs("div",{className:"text-right",children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:"Valor base"}),o.jsx("p",{className:"text-lg font-bold text-primary",children:Fa(h)})]})]}),o.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-input bg-muted/30 px-3 py-2.5",children:[o.jsx(_.Info,{className:"h-4 w-4 mt-0.5 shrink-0 text-muted-foreground"}),o.jsxs("p",{className:"text-xs",children:[o.jsx("span",{className:"font-bold",children:"Importante:"})," Para validar a inscrição e garantir sua vaga, o pagamento deve ser realizado no ato da inscrição."]})]}),o.jsx("p",{className:"text-sm font-semibold text-primary",children:"Selecione a forma de pagamento:"}),o.jsx("div",{className:"space-y-3",children:x.map(j=>{const{Icon:w}=j,C=(c==null?void 0:c.metodo)===j.id,S=Qd(h,j.taxa),$=!!j.parcelas&&j.parcelas>1,k=$?yS(S,j.parcelas):null;return o.jsxs("button",{type:"button",disabled:j.disabled,onClick:()=>v(j),className:K("w-full text-left flex items-center gap-4 px-4 py-3 rounded-xl border-2 transition-all",C?"border-primary bg-primary/5":"border-input hover:border-primary/50",j.disabled&&"opacity-50 cursor-not-allowed"),children:[o.jsx("div",{className:K("flex items-center justify-center w-10 h-10 rounded-lg shrink-0 transition-colors",C?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:o.jsx(w,{className:"h-5 w-5"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"font-semibold text-sm leading-tight",children:j.label}),o.jsx("p",{className:"text-xs text-muted-foreground",children:j.description}),j.taxaLabel&&o.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["* ",j.taxaLabel]}),j.taxa>0&&o.jsxs("p",{className:"text-xs text-muted-foreground",children:["Total com taxa: ",Fa(S)]})]}),o.jsx("div",{className:"text-right shrink-0",children:$?o.jsxs(o.Fragment,{children:[o.jsxs("p",{className:"text-xs text-muted-foreground",children:[j.parcelas,"x de"]}),o.jsx("p",{className:"text-base font-bold text-primary",children:Fa(k)})]}):o.jsx("p",{className:"text-base font-bold text-primary",children:Fa(S)})})]},j.id)})}),d&&o.jsx("p",{className:"text-xs text-destructive",children:d})]})},jS=({name:e,control:t,label:r,termoTexto:n,termoPdfUrl:a,termoPdfUploadId:s})=>{var i;const{field:l,fieldState:c}=Me({name:e,control:t}),{resolveTermsUploadUrl:d}=Hr(),u=!!c.error,m=(i=c.error)==null?void 0:i.message,[p,f]=N.useState(null),[b,h]=N.useState(!1),[x,y]=N.useState(!1),v=N.useRef(null);N.useEffect(()=>{var $;x&&(($=v.current)==null||$.focus())},[x]),N.useEffect(()=>{if(!s||!d){f(null);return}let $=!1;return h(!0),d(s).then(k=>{$||f(k)}).catch(()=>{$||f(null)}).finally(()=>{$||h(!1)}),()=>{$=!0}},[s,d]);const j=l.value==="accepted",w=p||a||null,C=!!(n||w||s),S=!!w;return o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:K("rounded-lg border p-4 space-y-4 transition-colors",u?"border-destructive bg-destructive/5":j?"border-green-500 bg-green-500/5":"border-input"),children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(_.ScrollText,{className:"h-4 w-4 shrink-0"}),o.jsx("span",{className:"text-sm font-medium",children:r||"Termos e condições"})]}),C?o.jsxs(De,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2 text-xs",disabled:b,onClick:()=>y(!0),children:[b?o.jsx(_.Loader2,{className:"h-3 w-3 animate-spin"}):o.jsx(_.ExternalLink,{className:"h-3 w-3"}),"Ler termos"]}):o.jsx("span",{className:"text-xs text-muted-foreground italic",children:s&&b?"Carregando PDF...":"Conteúdo não configurado"})]}),o.jsxs("label",{className:"flex items-start gap-3 cursor-pointer select-none",children:[o.jsx(et,{className:"mt-0.5",checked:j,onCheckedChange:$=>l.onChange($?"accepted":"")}),o.jsxs("span",{className:"text-sm leading-snug flex-1",children:["Li e aceito ",r?`"${r}"`:"os termos e condições"]}),j&&o.jsx(_.CheckCircle2,{className:"h-4 w-4 text-green-500 shrink-0 mt-0.5"})]})]}),u&&o.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-destructive",children:[o.jsx(_.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),m||"Você precisa aceitar os termos para continuar"]}),x&&o.jsx("div",{ref:v,role:"dialog","aria-modal":"true","aria-label":"Termos e condições",tabIndex:-1,className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 outline-none",onClick:()=>y(!1),onKeyDown:$=>{$.key==="Escape"&&y(!1)},children:o.jsxs("div",{className:"relative w-full max-w-2xl max-h-[90vh] rounded-xl overflow-hidden flex flex-col bg-background shadow-xl",onClick:$=>$.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-input",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(_.ScrollText,{className:"h-4 w-4"}),o.jsx("span",{className:"font-semibold",children:"Termos e condições"})]}),o.jsx(De,{type:"button",variant:"ghost",size:"icon",onClick:()=>y(!1),children:o.jsx(_.X,{className:"h-4 w-4"})})]}),o.jsx("div",{className:"flex-1 overflow-auto p-4",children:S?o.jsx("iframe",{src:w,className:"w-full rounded border",style:{height:"62vh"},title:"Termos e condições",sandbox:"allow-scripts"}):o.jsx("p",{className:"text-sm whitespace-pre-wrap leading-relaxed",children:n})})]})})]})},kS=({name:e,control:t,placeholder:r,disabled:n,readOnly:a})=>{var s;const{field:i,fieldState:l}=Me({name:e,control:t}),[c,d]=N.useState(!1),u=!!l.error;return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"relative",children:[o.jsx(ue,{...i,value:i.value??"",type:c?"text":"password",placeholder:r,disabled:n,readOnly:a,className:K("pr-10",u&&"border-destructive focus-visible:ring-destructive")}),o.jsx("button",{type:"button",tabIndex:-1,onClick:()=>d(m=>!m),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors","aria-label":c?"Ocultar senha":"Mostrar senha",children:c?o.jsx(_.EyeOff,{size:16}):o.jsx(_.Eye,{size:16})})]}),((s=l.error)==null?void 0:s.message)&&o.jsx("p",{className:"text-sm text-destructive",children:l.error.message})]})},jx=({name:e,control:t,label:r,disabled:n,readOnly:a})=>{var s;const{field:i,fieldState:l}=Me({name:e,control:t}),c=!!i.value;return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("label",{className:"flex items-center gap-3 cursor-pointer select-none",children:[o.jsx(Oi,{checked:c,onCheckedChange:d=>!a&&i.onChange(d),disabled:n||a,onBlur:i.onBlur}),o.jsx("span",{className:"text-sm leading-none",children:r})]}),((s=l.error)==null?void 0:s.message)&&o.jsx("p",{className:"text-sm text-destructive",children:l.error.message})]})},CS=({name:e,control:t,minValue:r=0,maxValue:n=100,step:a=1,disabled:s,readOnly:i})=>{var l;const{field:c,fieldState:d}=Me({name:e,control:t}),u=c.value??r;return N.useEffect(()=>{(c.value===void 0||c.value===null)&&c.onChange(r)},[]),o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(Ao,{min:r,max:n,step:a,value:[u],onValueChange:m=>!i&&c.onChange(m[0]),disabled:s||i,className:"flex-1"}),o.jsx("span",{className:"text-sm font-medium text-primary min-w-[3rem] text-right tabular-nums",children:u})]}),o.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[o.jsx("span",{children:r}),o.jsx("span",{children:n})]}),((l=d.error)==null?void 0:l.message)&&o.jsx("p",{className:"text-sm text-destructive",children:d.error.message})]})},Ms=e=>/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(e),NS=({name:e,control:t,disabled:r,readOnly:n})=>{var a;const{field:s,fieldState:i}=Me({name:e,control:t}),l=s.value||"#000000",[c,d]=N.useState(l);return N.useEffect(()=>{d(l)},[l]),o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("input",{type:"color",value:Ms(l)?l:"#000000",disabled:r||n,onChange:u=>s.onChange(u.target.value),className:"h-10 w-14 cursor-pointer rounded-lg border border-input bg-transparent p-1 disabled:cursor-not-allowed disabled:opacity-50"}),o.jsx(ue,{type:"text",value:c,readOnly:n,disabled:r,onChange:u=>{const m=u.target.value;d(m),Ms(m)&&s.onChange(m.toUpperCase())},onBlur:()=>{Ms(c)||d(l),s.onBlur()},className:K("flex-1 font-mono uppercase",i.error&&"border-destructive focus-visible:ring-destructive"),maxLength:7,placeholder:"#000000"})]}),((a=i.error)==null?void 0:a.message)&&o.jsx("p",{className:"text-sm text-destructive",children:i.error.message})]})},SS=({name:e,control:t,options:r,placeholder:n,disabled:a,readOnly:s})=>{var i,l;const{field:c,fieldState:d}=Me({name:e,control:t}),[u,m]=N.useState(""),[p,f]=N.useState(!1),[b,h]=N.useState(-1),x=N.useRef(null),y=N.useRef(null),v=`autocomplete-${e}-listbox`,j=((i=r.find(D=>D.valor===c.value))==null?void 0:i.label)??"",w=u.length>0?r.filter(D=>D.label.toLowerCase().includes(u.toLowerCase())):r;N.useEffect(()=>{const D=O=>{x.current&&!x.current.contains(O.target)&&(f(!1),m(""),h(-1))};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[]);const C=()=>{f(!1),m(""),h(-1)};N.useEffect(()=>{if(b<0||!y.current)return;const D=y.current.querySelector(`[id="${v}-option-${b}"]`);D==null||D.scrollIntoView({block:"nearest"})},[b,v]);const S=D=>{D.disabled||(c.onChange(D.valor),C())},$=()=>{c.onChange(""),m(""),h(-1)},k=D=>{if(!p){(D.key==="ArrowDown"||D.key==="ArrowUp")&&(D.preventDefault(),f(!0),h(0));return}switch(D.key){case"ArrowDown":D.preventDefault(),h(O=>O<w.length-1?O+1:O);break;case"ArrowUp":D.preventDefault(),h(O=>O>0?O-1:0);break;case"Enter":D.preventDefault(),b>=0&&w[b]&&!w[b].disabled&&S(w[b]);break;case"Escape":D.preventDefault(),C();break;case"Tab":C();break}},E=p&&b>=0?`${v}-option-${b}`:void 0;return o.jsxs("div",{className:"space-y-1",ref:x,children:[o.jsxs("div",{className:"relative",children:[o.jsx(ue,{type:"text",role:"combobox","aria-expanded":p,"aria-haspopup":"listbox","aria-autocomplete":"list","aria-controls":v,"aria-activedescendant":E,value:p?u:j,placeholder:n??"Buscar...",disabled:a,readOnly:s,onChange:D=>{m(D.target.value),h(-1),f(!0)},onFocus:()=>!s&&f(!0),onKeyDown:k,className:K("pr-8",d.error&&"border-destructive focus-visible:ring-destructive"),autoComplete:"off"}),o.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1",children:c.value?o.jsx("button",{type:"button",onClick:$,className:"text-[var(--t-text-muted)] hover:text-[var(--t-text)]",tabIndex:-1,"aria-label":"Limpar seleção",children:o.jsx(_.X,{size:14})}):o.jsx(_.ChevronDown,{size:16,className:"text-muted-foreground pointer-events-none","aria-hidden":"true"})}),p&&!a&&!s&&o.jsx("ul",{role:"listbox",id:v,ref:y,"aria-label":"Opções disponíveis",className:"absolute z-50 mt-1 max-h-60 w-full overflow-auto rounded-lg border border-input bg-popover shadow-lg",children:w.length===0?o.jsx("li",{role:"option","aria-selected":!1,className:"px-3 py-2 text-sm text-muted-foreground",children:"Nenhuma opção encontrada"}):w.map((D,O)=>o.jsx("li",{id:`${v}-option-${O}`,role:"option","aria-selected":c.value===D.valor,"aria-disabled":D.disabled,onMouseDown:()=>S(D),className:["flex cursor-pointer items-center px-3 py-2 text-sm",D.disabled?"cursor-not-allowed opacity-40":O===b?"bg-accent":"hover:bg-accent",c.value===D.valor?"font-medium text-primary":"text-foreground"].join(" "),children:D.label},D.valor))})]}),((l=d.error)==null?void 0:l.message)&&o.jsx("p",{className:"text-sm text-destructive",role:"alert",children:d.error.message})]})},kx=({name:e,control:t,placeholder:r,disabled:n,readOnly:a})=>{var s;const{field:i,fieldState:l}=Me({name:e,control:t}),c=!!l.error;return o.jsxs("div",{className:"space-y-1",children:[o.jsx(ue,{...i,value:i.value??"",type:"time",placeholder:r,disabled:n,readOnly:a,className:K(c&&"border-destructive focus-visible:ring-destructive")}),((s=l.error)==null?void 0:s.message)&&o.jsx("p",{className:"text-sm text-destructive",children:l.error.message})]})},$S=({name:e,control:t,startLabel:r="Data inicial",endLabel:n="Data final",disabled:a,readOnly:s})=>{var i;const{field:l,fieldState:c}=Me({name:e,control:t}),d=l.value??{},u=(p,f)=>{l.onChange({...d,[p]:f})},m=!!c.error;return o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{children:r}),o.jsx(ue,{type:"date",value:d.start??"",disabled:a,readOnly:s,onChange:p=>u("start",p.target.value),max:d.end??void 0,className:K(m&&"border-destructive focus-visible:ring-destructive")})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{children:n}),o.jsx(ue,{type:"date",value:d.end??"",disabled:a,readOnly:s,onChange:p=>u("end",p.target.value),min:d.start??void 0,className:K(m&&"border-destructive focus-visible:ring-destructive")})]})]}),((i=c.error)==null?void 0:i.message)&&o.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})},ES=({name:e,control:t,maxRating:r=5,disabled:n,readOnly:a})=>{var s;const{field:i,fieldState:l}=Me({name:e,control:t}),c=i.value??0,d=Array.from({length:r},(u,m)=>m+1);return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-1",children:[d.map(u=>o.jsx("button",{type:"button",disabled:n||a,onClick:()=>i.onChange(u===c?0:u),className:"transition-transform hover:scale-110 disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded","aria-label":`${u} estrela${u>1?"s":""}`,children:o.jsx(_.Star,{size:24,className:"transition-colors",fill:u<=c?"var(--color-primary)":"transparent",stroke:u<=c?"var(--color-primary)":"currentColor"})},u)),c>0&&o.jsxs("span",{className:"ml-2 text-sm text-muted-foreground",children:[c,"/",r]})]}),((s=l.error)==null?void 0:s.message)&&o.jsx("p",{className:"text-sm text-destructive",children:l.error.message})]})},DS=({field:e,name:t,control:r,disabled:n,readOnly:a})=>{const s=n||e.isDisabled,i=a||e.isReadOnly;switch(e.tipo){case T.EMAIL:return o.jsx(Mt,{name:t,control:r,type:"email",placeholder:e.placeholder,disabled:s,readOnly:i});case T.NUMBER:return o.jsx(Mt,{name:t,control:r,type:"number",placeholder:e.placeholder,disabled:s,readOnly:i});case T.PASSWORD:return o.jsx(Mt,{name:t,control:r,type:"password",placeholder:e.placeholder,disabled:s,readOnly:i});case T.TELEFONE:return o.jsx(Qr,{name:t,control:r,maskType:"telefone",placeholder:e.placeholder??"(00) 00000-0000",disabled:s,readOnly:i});case T.CPF:return o.jsx(Qr,{name:t,control:r,maskType:"cpf",placeholder:e.placeholder??"000.000.000-00",disabled:s,readOnly:i});case T.CEP:return o.jsx(Qr,{name:t,control:r,maskType:"cep",placeholder:e.placeholder??"00000-000",disabled:s,readOnly:i});case T.TEXTAREA:return o.jsx(Al,{name:t,control:r,placeholder:e.placeholder,disabled:s,readOnly:i});case T.SELECT:return o.jsx(Rl,{name:t,control:r,options:e.opcoes??[],placeholder:e.placeholder,disabled:s,readOnly:i});case T.CHECKBOX:return o.jsx(Il,{name:t,control:r,label:e.label??"",disabled:s,readOnly:i});case T.SWITCH:return o.jsx(jx,{name:t,control:r,label:e.label??"",disabled:s,readOnly:i});case T.DATE:return o.jsx(aa,{name:t,control:r,disabled:s,readOnly:i});case T.TIME:return o.jsx(kx,{name:t,control:r,disabled:s,readOnly:i});case T.HIDDEN:return o.jsx(zl,{name:t,control:r});default:return o.jsx(Mt,{name:t,control:r,type:"text",placeholder:e.placeholder,disabled:s,readOnly:i})}},TS=({name:e,control:t,subSchema:r,disabled:n,readOnly:a})=>{if(!r||r.fields.length===0)return null;const s=[...r.fields].sort((i,l)=>i.ordem-l.ordem);return o.jsxs("div",{className:"rounded-xl border border-input bg-muted/30 p-4 space-y-4",children:[r.titulo&&o.jsx("h4",{className:"text-sm font-semibold text-muted-foreground",children:r.titulo}),o.jsx("div",{className:"grid grid-cols-12 gap-4",children:s.map(i=>{const l=`${e}.${i.nome}`,c=i.tipo===T.CHECKBOX||i.tipo===T.SWITCH||i.tipo===T.HIDDEN,d=i.tamanho??6;return o.jsxs("div",{className:`col-span-${d}`,children:[!c&&o.jsxs("label",{className:"mb-1 block text-sm font-medium text-foreground",children:[i.label,i.obrigatorio&&o.jsx("span",{className:"text-destructive",children:" *"})]}),o.jsx(DS,{field:i,name:l,control:t,disabled:n,readOnly:a})]},i.id)})})]})},Cx=({field:e,control:t,nameOverride:r})=>{var n,a;const s=r??e.nome,{componentMapper:i}=Hr(),l=i==null?void 0:i[e.tipo];if(l)return o.jsx(l,{name:s,control:t,field:e});const c={name:s,control:t,placeholder:e.placeholder,disabled:e.isDisabled,readOnly:e.isReadOnly};switch(e.tipo){case T.TEXTO:return o.jsx(Mt,{...c,type:"text"});case T.EMAIL:return o.jsx(Mt,{...c,type:"email"});case T.NUMBER:return o.jsx(Mt,{...c,type:"number"});case T.PASSWORD:return o.jsx(kS,{...c});case T.TEXTAREA:return o.jsx(Al,{...c});case T.SELECT:return o.jsx(Rl,{...c,options:e.opcoes??[]});case T.AUTOCOMPLETE:return o.jsx(SS,{...c,options:e.opcoes??[]});case T.SWITCH:return o.jsx(jx,{name:s,control:t,label:e.label,disabled:e.isDisabled,readOnly:e.isReadOnly});case T.SLIDER:return o.jsx(CS,{name:s,control:t,minValue:e.minValue,maxValue:e.maxValue,step:e.step,disabled:e.isDisabled,readOnly:e.isReadOnly});case T.RATING:return o.jsx(ES,{name:s,control:t,maxRating:e.maxRating,disabled:e.isDisabled,readOnly:e.isReadOnly});case T.COLOR:return o.jsx(NS,{name:s,control:t,disabled:e.isDisabled,readOnly:e.isReadOnly});case T.TIME:return o.jsx(kx,{...c});case T.DATE_RANGE:return o.jsx($S,{name:s,control:t,startLabel:e.dateRangeStartLabel,endLabel:e.dateRangeEndLabel,disabled:e.isDisabled,readOnly:e.isReadOnly});case T.RADIO:return o.jsx(px,{...c,options:e.opcoes??[]});case T.CHECKBOX:return o.jsx(Il,{name:s,control:t,label:e.label,disabled:e.isDisabled,readOnly:e.isReadOnly});case T.CHECKBOX_GROUP:return o.jsx(mx,{...c,options:e.opcoes??[]});case T.DATE:return o.jsx(aa,{name:s,control:t,disabled:e.isDisabled,readOnly:e.isReadOnly,validacao:e.validacao});case T.DATETIME:return o.jsx(aa,{name:s,control:t,isDatetime:!0,disabled:e.isDisabled,readOnly:e.isReadOnly,validacao:e.validacao});case T.FILE:return o.jsx(bx,{name:s,control:t,disabled:e.isDisabled,fileTypes:(n=e.validacao)==null?void 0:n.fileTypes,maxFileSize:(a=e.validacao)==null?void 0:a.maxFileSize});case T.TELEFONE:return o.jsx(Qr,{...c,maskType:"telefone"});case T.CPF:return o.jsx(Qr,{...c,maskType:"cpf"});case T.CEP:return o.jsx(wx,{name:s,control:t,placeholder:e.placeholder,disabled:e.isDisabled,readOnly:e.isReadOnly,cepFillMap:e.cepFillMap});case T.HIDDEN:return o.jsx(zl,{name:s,control:t});case T.PARTICIPATION_TYPE:return o.jsx(gS,{name:s,control:t});case T.PAYMENT_METHOD:return o.jsx(wS,{name:s,control:t,relatedFieldName:e.relatedFieldName});case T.TERMS:return o.jsx(jS,{name:s,control:t,label:e.label,termoTexto:e.termoTexto,termoPdfUrl:e.termoPdfUrl,termoPdfUploadId:e.termoPdfUploadId});case T.FIELD_ARRAY:return o.jsx(mS,{name:s,control:t,subFields:e.subFields,minItems:e.minItems,maxItems:e.maxItems,itemLabel:e.itemLabel,addLabel:e.addLabel});case T.SUB_FORM:return o.jsx(TS,{name:s,control:t,subSchema:e.subSchema,disabled:e.isDisabled,readOnly:e.isReadOnly});default:return o.jsx(Mt,{...c,type:"text"})}},AS=({container:e,control:t})=>{var r;const{externalData:n={},fieldResolvers:a}=Hr(),s=e.icone?Pt[e.icone]:void 0,i=n,l=N.useMemo(()=>Tl(e,i),[e,JSON.stringify(i)]),c=N.useMemo(()=>[...l.campos].sort((x,y)=>x.ordem-y.ordem),[l.campos]),d=Mn({control:t}),{wrapperClass:u,wrapperStyle:m,headerClass:p,headerStyle:f,tmpl:b}=ux(),h=x=>{if(!st(x.condicional,d,n))return null;let y=x;if(x.resolvePropsKey&&a!=null&&a[x.resolvePropsKey]){const S=a[x.resolvePropsKey](x,d,n);y={...x,...S}}if(y.opcoesFromVar){const S=n[y.opcoesFromVar];Array.isArray(S)&&(y={...y,opcoes:S.map($=>typeof $=="string"?{valor:$,label:$}:$&&typeof $=="object"&&"valor"in $&&"label"in $?$:{valor:String($),label:String($)})})}const v=y.tamanho??12,j=y.inicioColuna,w=j?`${j} / span ${v}`:`span ${v}`,C=o.jsx(Cx,{field:y,control:t});return y.tipo===T.CHECKBOX||y.tipo===T.HIDDEN||y.tipo===T.SWITCH?o.jsx("div",{className:"max-sm:!col-span-12",style:{gridColumn:w},children:C},y.id):o.jsxs("div",{className:"max-sm:!col-span-12 space-y-2",style:{gridColumn:w},children:[o.jsxs("label",{className:"font-medium flex items-center gap-1",style:{color:"var(--t-text)"},children:[y.label,y.obrigatorio&&o.jsx("span",{className:"text-destructive",children:"*"})]}),C,y.hint&&o.jsx("p",{className:"text-xs text-muted-foreground",children:y.hint})]},y.id)};return o.jsxs("div",{className:u,style:m,children:[(l.titulo||s)&&o.jsx("div",{className:p,style:f,children:o.jsxs("div",{className:"flex items-center gap-3",children:[s&&o.jsx("div",{className:"p-2 rounded-xl",style:{background:"color-mix(in srgb, var(--t-primary) 12%, transparent)"},children:o.jsx(s,{className:"w-5 h-5",style:{color:"var(--t-primary)"}})}),o.jsxs("div",{children:[o.jsx("h3",{className:((r=b.typography)==null?void 0:r.stepTitleClass)??"text-lg font-semibold",style:{color:"var(--t-text)"},children:l.titulo}),l.descricao&&o.jsx("p",{className:"text-sm",style:{color:"var(--t-text-muted)"},children:l.descricao})]})]})}),o.jsx("div",{className:"p-6 grid grid-cols-12 gap-4",children:c.map(h)})]})},RS=({container:e,control:t})=>{var r;const{externalData:n={}}=Hr(),a=e.nome??"__invalid__",s=e.minItems??1,i=e.maxItems,l=e.itemLabel??"Item",c=e.icone?Pt[e.icone]:void 0,d=n,u=N.useMemo(()=>Tl(e,d),[e,JSON.stringify(d)]),m=N.useMemo(()=>[...u.campos].sort((k,E)=>k.ordem-E.ordem),[u.campos]),p=N.useCallback(()=>{const k={};for(const E of m)E.initialValue!==void 0?k[E.nome]=typeof E.initialValue=="string"?wt(E.initialValue,d):E.initialValue:E.defaultValue!==void 0&&(k[E.nome]=E.defaultValue);return k},[m,d]),{fields:f,append:b,remove:h}=dx({control:t,name:a});N.useEffect(()=>{if(e.nome&&f.length<s)for(let k=f.length;k<s;k++)b(p())},[s]);const x=Mn({control:t}),y=N.useMemo(()=>{const k=x[a];return Array.isArray(k)?k:[]},[x,a]),{wrapperClass:v,wrapperStyle:j,headerClass:w,headerStyle:C,tmpl:S}=ux();if(!e.nome)return console.error("[RepeatableContainerRenderer] container.nome é obrigatório para containers repetíveis. Container id:",e.id),null;const $=(k,E)=>{const D=y[E]??{};if(!st(k.condicional,D,n))return null;const O=`${a}.${E}.${k.nome}`,L=k.tamanho??12,A=k.inicioColuna,z=A?`${A} / span ${L}`:`span ${L}`,X=o.jsx(Cx,{field:k,control:t,nameOverride:O});return k.tipo===T.CHECKBOX||k.tipo===T.HIDDEN?o.jsx("div",{className:"max-sm:!col-span-12",style:{gridColumn:z},children:X},`${k.id}-${E}`):o.jsxs("div",{className:"max-sm:!col-span-12 space-y-2",style:{gridColumn:z},children:[o.jsxs("label",{className:"font-medium flex items-center gap-1",style:{color:"var(--t-text)"},children:[k.label,k.obrigatorio&&o.jsx("span",{className:"text-destructive",children:"*"})]}),X,k.hint&&o.jsx("p",{className:"text-xs text-muted-foreground",children:k.hint})]},`${k.id}-${E}`)};return o.jsxs("div",{className:v,style:j,children:[(u.titulo||c)&&o.jsx("div",{className:w,style:C,children:o.jsxs("div",{className:"flex items-center gap-3",children:[c&&o.jsx("div",{className:"p-2 rounded-xl",style:{background:"color-mix(in srgb, var(--t-primary) 12%, transparent)"},children:o.jsx(c,{className:"w-5 h-5",style:{color:"var(--t-primary)"}})}),o.jsxs("div",{children:[o.jsx("h3",{className:((r=S.typography)==null?void 0:r.stepTitleClass)??"text-lg font-semibold",style:{color:"var(--t-text)"},children:u.titulo}),u.descricao&&o.jsx("p",{className:"text-sm",style:{color:"var(--t-text-muted)"},children:u.descricao})]})]})}),o.jsxs("div",{className:"p-6 space-y-4",children:[f.map((k,E)=>o.jsxs("div",{className:"border border-input rounded-lg p-4 bg-muted/30",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold shrink-0 bg-primary text-primary-foreground",children:E+1}),o.jsxs("span",{className:"text-sm font-semibold",children:[l," ",E+1]})]}),f.length>s&&o.jsx("button",{type:"button",onClick:()=>h(E),className:"inline-flex items-center justify-center rounded-md p-1.5 text-destructive hover:bg-destructive/10 transition-colors","aria-label":"Remover item",children:o.jsx(_.Trash2,{className:"w-4 h-4"})})]}),o.jsx("div",{className:"grid grid-cols-12 gap-4",children:m.map(D=>$(D,E))})]},k.id)),(!i||f.length<i)&&o.jsxs("button",{type:"button",className:"w-full flex items-center justify-center gap-2 py-2 px-4 border border-input rounded-lg text-sm hover:bg-accent transition-colors",onClick:()=>b(p()),children:[o.jsx(_.Plus,{className:"w-4 h-4"}),"Adicionar ",l.toLowerCase()]}),i&&o.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:["Máximo de ",i," ",l.toLowerCase(),i>1?"s":""]})]})]})},IS=e=>e.container.repeatable&&e.container.nome?o.jsx(RS,{...e}):o.jsx(AS,{...e}),PS=({step:e,control:t,externalData:r={}})=>{const n=N.useMemo(()=>[...e.containers].sort((s,i)=>s.ordem-i.ordem),[e.containers]),a=Mn({control:t});return o.jsx("div",{className:"grid grid-cols-12 gap-4",children:n.map(s=>{if(s.condicional&&!st(s.condicional,a,r))return null;const i=s.tamanho??12,l=s.inicioColuna,c=l?`${l} / span ${i}`:`span ${i}`;return o.jsx("div",{className:"max-sm:!col-span-12",style:{gridColumn:c},children:o.jsx(IS,{container:s,control:t})},s.id)})})},_S=N.createContext({submitting:!1,warnings:{},requestSubmit:()=>{}}),OS=_S.Provider,eu=({stepIndex:e,totalSteps:t,step:r,defaultValues:n,externalData:a,fieldErrors:s,isSubmitting:i,submitError:l,validatorMapper:c={},onWarningsChange:d,onValuesChange:u,onSubmit:m,onBack:p})=>{const f=e===t-1,b=N.useMemo(()=>JSON.stringify(a),[a]),h=N.useMemo(()=>PN(r,a,c),[r.id,b]),x=N.useMemo(()=>_N(r,a,c),[r.id,b]),[y,v]=N.useState({}),j=N.useRef(d);j.current=d;const w=a,C=N.useMemo(()=>LN(r,w),[r,b]),S=NN({resolver:h,defaultValues:n,mode:"onTouched"}),{control:$,handleSubmit:k,setError:E,clearErrors:D,setValue:O}=S;N.useEffect(()=>{D();for(const[U,Q]of Object.entries(s))E(U,{type:"server",message:Q})},[s,E,D]);const L=N.useMemo(()=>r.containers.filter(U=>!U.repeatable).flatMap(U=>U.campos).filter(U=>!!U.condicional),[r.containers]),A=N.useMemo(()=>r.containers.filter(U=>!!U.condicional),[r.containers]),z=N.useMemo(()=>r.containers.filter(U=>!U.repeatable).flatMap(U=>U.campos).filter(U=>{var Q;return U.condicional&&((Q=U.setValues)==null?void 0:Q.length)}),[r.containers]),X=N.useMemo(()=>r.containers.filter(U=>U.repeatable&&!!U.nome).map(U=>({container:U,fields:U.campos.filter(Q=>!!Q.condicional)})).filter(U=>U.fields.length>0),[r.containers]),q=N.useRef({}),Z=N.useRef(!0),V=Mn({control:$}),M=N.useRef(u);M.current=u,N.useEffect(()=>{var U;(U=M.current)==null||U.call(M,V)},[V]),N.useEffect(()=>{let U=!1;return x(V).then(Q=>{var Y;U||(v(Q),(Y=j.current)==null||Y.call(j,Q))}).catch(Q=>{U||console.error("[StepForm] warnComputer error:",Q)}),()=>{U=!0}},[V,x]),N.useEffect(()=>{var U;if(!L.length&&!z.length&&!A.length&&!X.length)return;const Q=V;for(const H of L)if(!st(H.condicional,Q,a)){if(D(H.nome),H.tipo===T.FIELD_ARRAY){const W=Q[H.nome];Array.isArray(W)&&W.forEach((G,ne)=>{(H.subFields??[]).forEach(J=>D(`${H.nome}.${ne}.${J.nome}`))})}if(H.clearedValue!==void 0){const W=H.clearedValue??"";Q[H.nome]!==W&&O(H.nome,W,{shouldValidate:!1})}}for(const H of A)if(!st(H.condicional,Q,a))if(H.repeatable&&H.nome)(Array.isArray(Q[H.nome])?Q[H.nome]:[]).forEach((W,G)=>{for(const ne of H.campos)D(`${H.nome}.${G}.${ne.nome}`)});else for(const W of H.campos){D(W.nome);const G=W.clearedValue!==void 0?W.clearedValue:void 0;G!==void 0&&Q[W.nome]!==G&&O(W.nome,G,{shouldValidate:!1})}for(const{container:H,fields:W}of X){const G=H.nome,ne=Array.isArray(Q[G])?Q[G]:[];for(let J=0;J<ne.length;J++){const te=ne[J];for(const ce of W)if(!st(ce.condicional,te,a)&&(D(`${G}.${J}.${ce.nome}`),ce.clearedValue!==void 0)){const be=ce.clearedValue??"";te[ce.nome]!==be&&O(`${G}.${J}.${ce.nome}`,be,{shouldValidate:!1})}}}const Y=Z.current;for(const H of z){const W=st(H.condicional,Q,a),G=Y?W:q.current[H.nome]??!1;if(W&&!G&&(U=H.setValues)!=null&&U.length)for(const ne of H.setValues){const J=typeof ne.valor=="string"?wt(ne.valor,w):ne.valor;O(ne.campo,J,{shouldValidate:!1})}q.current[H.nome]=W}Z.current=!1},[V,L,z,A,X,a,O,D]);const P=C.icone?Pt[C.icone]:void 0,se=N.useMemo(()=>()=>{S.handleSubmit(m)()},[m]);return o.jsx(cN,{...S,children:o.jsx(OS,{value:{submitting:i,warnings:y,requestSubmit:se},children:o.jsx("form",{onSubmit:k(m),noValidate:!0,onKeyDown:U=>{U.key==="Enter"&&U.target.tagName==="INPUT"&&U.preventDefault()},children:o.jsxs("div",{className:"space-y-6",children:[C.showLabel!==!1&&o.jsxs("div",{className:"text-center space-y-2",children:[P&&o.jsx("div",{className:"w-12 h-12 mx-auto rounded-xl flex items-center justify-center",style:{background:"color-mix(in srgb, var(--t-primary) 12%, transparent)"},children:o.jsx(P,{className:"w-6 h-6",style:{color:"var(--t-primary)"}})}),o.jsx("h2",{className:"text-2xl font-bold",style:{color:"var(--t-text)"},children:C.titulo}),C.descricao&&o.jsx("p",{className:"text-sm text-muted-foreground",children:C.descricao})]}),o.jsx(PS,{step:C,control:$,externalData:a}),o.jsxs("div",{className:"flex items-center justify-between gap-4 pt-6 pb-2",children:[o.jsxs(De,{type:"button",variant:"outline",onClick:p,disabled:e===0,className:K(e>0&&"border-primary/40 text-primary hover:bg-primary/5"),children:[o.jsx(_.ChevronLeft,{className:"w-4 h-4"}),o.jsx("span",{className:"hidden sm:inline",children:"Anterior"})]}),o.jsxs("span",{className:"text-xs font-semibold tabular-nums sm:hidden text-muted-foreground",children:[e+1,"/",t]}),o.jsxs(De,{type:"submit",disabled:i,children:[i?o.jsx(_.Loader2,{className:"w-4 h-4 animate-spin"}):f?o.jsx(_.Check,{className:"w-4 h-4"}):o.jsx(_.ChevronRight,{className:"w-4 h-4"}),o.jsx("span",{className:"hidden sm:inline",children:f?"Finalizar":"Próximo"})]})]}),l&&o.jsx("p",{className:"text-sm text-destructive mt-2 text-center",children:l})]})})})})},lo=e=>{if(e)return Pt[e]},FS=({steps:e,currentStep:t,onStepClick:r})=>o.jsx("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:e.map((n,a)=>o.jsx("div",{role:r?"button":void 0,tabIndex:r?0:void 0,onClick:()=>r==null?void 0:r(a),onKeyDown:s=>s.key==="Enter"&&(r==null?void 0:r(a)),className:K("w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold transition-all shrink-0",r&&"cursor-pointer hover:opacity-80"),style:a===t?{background:"var(--t-primary)",color:"#ffffff",boxShadow:"0 0 0 3px color-mix(in srgb, var(--t-primary) 30%, transparent)"}:a<t?{background:"#22c55e",color:"#ffffff"}:{background:"hsl(var(--muted))",color:"hsl(var(--muted-foreground))"},children:a<t?o.jsx(_.Check,{className:"w-4 h-4"}):a+1},n.id))}),zS=({steps:e,currentStep:t,onStepClick:r})=>o.jsx("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:e.map((n,a)=>{const s=lo(n.icone)??_.CircleDot;return o.jsx("div",{role:r?"button":void 0,tabIndex:r?0:void 0,onClick:()=>r==null?void 0:r(a),onKeyDown:i=>i.key==="Enter"&&(r==null?void 0:r(a)),className:K("w-9 h-9 rounded-full flex items-center justify-center transition-all shrink-0",r&&"cursor-pointer hover:opacity-80"),style:a===t?{background:"var(--t-primary)",color:"#ffffff",boxShadow:"0 0 0 3px color-mix(in srgb, var(--t-primary) 30%, transparent)"}:a<t?{background:"#22c55e",color:"#ffffff"}:{background:"hsl(var(--muted))",color:"hsl(var(--muted-foreground))"},children:a<t?o.jsx(_.Check,{className:"w-4 h-4"}):o.jsx(s,{className:"w-4 h-4"})},n.id)})}),LS=({steps:e,currentStep:t,position:r,orientation:n="horizontal",onStepClick:a})=>n==="vertical"?o.jsx("div",{className:"flex flex-col gap-0",children:e.map((s,i)=>{const l=lo(s.icone)??_.CircleDot,c=i===t,d=i<t,u=i===e.length-1;return o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsxs("div",{className:"flex flex-col items-center",children:[o.jsx("button",{type:"button",onClick:()=>a==null?void 0:a(i),className:K("w-8 h-8 rounded-full flex items-center justify-center transition-all shrink-0",a&&"cursor-pointer hover:opacity-80"),style:c?{background:"var(--t-primary)",color:"#fff",boxShadow:"0 0 10px color-mix(in srgb, var(--t-primary) 50%, transparent)"}:d?{background:"#22c55e",color:"#fff"}:{background:"color-mix(in srgb, var(--t-text) 8%, transparent)",color:"var(--t-text-muted)",border:"1.5px solid color-mix(in srgb, var(--t-border) 60%, transparent)"},children:d?o.jsx(_.Check,{className:"w-3.5 h-3.5"}):o.jsx(l,{className:"w-3.5 h-3.5"})}),!u&&o.jsx("div",{className:"w-[2px] my-1",style:{height:"24px",background:d?"#22c55e":"color-mix(in srgb, var(--t-border) 50%, transparent)"}})]}),o.jsx("span",{className:"text-sm font-medium leading-tight mt-1.5",style:c?{color:"var(--t-primary)"}:d?{color:"#16a34a"}:{color:"var(--t-text-muted)"},children:s.label??s.id})]},s.id)})}):o.jsx("div",{className:"w-full flex items-start",children:e.map((s,i)=>{const l=lo(s.icone)??_.CircleDot,c=i===t,d=i<t,u=i===e.length-1;return o.jsxs("div",{className:K("flex items-start",!u&&"flex-1"),children:[o.jsxs("div",{className:"flex flex-col items-center gap-1.5 w-[56px] shrink-0 mx-auto",children:[o.jsx("button",{type:"button",onClick:()=>a==null?void 0:a(i),className:K("w-10 h-10 rounded-full flex items-center justify-center transition-all shrink-0",a&&"cursor-pointer hover:opacity-80"),style:c?{background:"var(--t-primary)",color:"#ffffff",boxShadow:"0 0 12px color-mix(in srgb, var(--t-primary) 50%, transparent)"}:d?{background:"#22c55e",color:"#ffffff"}:{background:"color-mix(in srgb, var(--t-text) 8%, transparent)",color:"var(--t-text-muted)",border:"1.5px solid color-mix(in srgb, var(--t-border) 60%, transparent)"},children:d?o.jsx(_.Check,{className:"w-4 h-4"}):o.jsx(l,{className:"w-4 h-4"})}),o.jsx("span",{className:"text-[10px] font-medium text-center leading-tight line-clamp-2 px-0.5",style:c?{color:"var(--t-primary)"}:d?{color:"#16a34a"}:{color:"var(--t-text-muted)"},children:s.label??s.id})]}),!u&&o.jsx("div",{className:"flex-1 h-[1.5px] mt-5 mx-1",style:{background:d?"linear-gradient(90deg, var(--t-primary), color-mix(in srgb, var(--t-primary) 40%, transparent))":"color-mix(in srgb, var(--t-border) 50%, transparent)"}})]},s.id)})}),Nx=({steps:e,currentStep:t,onStepClick:r,className:n,forceShow:a})=>{const s=sa(),{layout:i}=s;if(!i.showStepIndicators||e.length<=1&&!a)return null;const l=i.stepIndicatorVariant??"numbers",c=i.stepIndicatorPosition??"top-center",d=i.stepIndicatorOrientation??"horizontal",u=(t+1)/e.length*100,m=e[t],p=lo(m==null?void 0:m.icone)??_.CircleDot,f=o.jsx("div",{className:"h-1 rounded-full overflow-hidden",style:{background:"color-mix(in srgb, var(--t-primary) 15%, transparent)"},children:o.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${u}%`,background:"linear-gradient(90deg, var(--t-primary), var(--t-accent))"}})}),b=o.jsxs("div",{className:"block sm:hidden space-y-2",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center shrink-0",style:{background:"var(--t-primary)",color:"#fff"},children:o.jsx(p,{className:"w-5 h-5"})}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("p",{className:"text-sm font-semibold leading-tight truncate",style:{color:"var(--t-text)"},children:(m==null?void 0:m.label)??(m==null?void 0:m.id)}),o.jsxs("p",{className:"text-xs leading-tight",style:{color:"var(--t-text-muted)"},children:["Passo ",t+1," de ",e.length]})]})]}),f]}),h=o.jsxs("div",{className:"hidden sm:block",children:[l==="numbers"&&o.jsx(FS,{steps:e,currentStep:t,onStepClick:r}),l==="icons"&&o.jsx(zS,{steps:e,currentStep:t,onStepClick:r}),l==="icons-labeled"&&o.jsx(LS,{steps:e,currentStep:t,position:c,orientation:d,onStepClick:r})]}),x=i.showProgressBar?o.jsx("div",{className:"hidden sm:block",children:f}):null;return d==="vertical"?o.jsxs("div",{className:K("flex gap-6 items-start",n),children:[b,o.jsxs("div",{className:"hidden sm:flex gap-6 items-start shrink-0",children:[h,x&&o.jsx("div",{className:"flex-1 pt-4",children:x})]})]}):o.jsxs("div",{className:K("space-y-3",n),children:[b,o.jsxs("div",{className:"hidden sm:block space-y-3",children:[h,x]})]})},MS=(e,t,r)=>{var n;const a={...t},s=r;for(const i of e.containers){for(const l of i.campos)if(a[l.nome]===void 0&&(l.initialValue!==void 0?a[l.nome]=typeof l.initialValue=="string"?wt(l.initialValue,s):l.initialValue:l.defaultValue!==void 0&&(a[l.nome]=l.defaultValue)),l.tipo===T.FIELD_ARRAY&&(n=l.subFields)!=null&&n.length){const c=a[l.nome];Array.isArray(c)&&c.length>0&&(a[l.nome]=c.map(d=>{const u={...d};for(const m of l.subFields)u[m.nome]===void 0&&(m.initialValue!==void 0?u[m.nome]=typeof m.initialValue=="string"?wt(m.initialValue,s):m.initialValue:m.defaultValue!==void 0&&(u[m.nome]=m.defaultValue));return u}))}if(i.repeatable&&i.nome){const l=a[i.nome];Array.isArray(l)&&l.length>0&&(a[i.nome]=l.map(c=>{const d={...c};for(const u of i.campos)d[u.nome]===void 0&&(u.initialValue!==void 0?d[u.nome]=typeof u.initialValue=="string"?wt(u.initialValue,s):u.initialValue:u.defaultValue!==void 0&&(d[u.nome]=u.defaultValue));return d}))}}return a},VS=({schema:e,initialValues:t={},initialStep:r=0,onSubmitStep:n,onComplete:a,template:s,formTitle:i,externalData:l={},fieldErrors:c={},uploadFile:d,deleteUploadedFile:u,cepLookup:m,resolveTermsUploadUrl:p,fieldResolvers:f,validatorMapper:b,componentMapper:h,paymentMethodOptions:x,onValuesChange:y,className:v,StepIndicator:j=Nx})=>{const[w,C]=N.useState(()=>r),[S,$]=N.useState({...t}),[k,E]=N.useState(()=>r),[D,O]=N.useState(!1),[L,A]=N.useState(null),[z,X]=N.useState({}),q=N.useRef(p);q.current=p;const Z=N.useCallback(me=>q.current(me),[]),V=!!p,M=N.useRef(u);M.current=u;const P=N.useCallback(me=>M.current(me),[]),se=!!u,U=N.useMemo(()=>JSON.stringify(l),[l]),Q=N.useMemo(()=>JSON.stringify(e.stepConfig),[e.stepConfig]),Y=N.useMemo(()=>{const me=uo(s);return e.stepConfig?{...me,layout:{...me.layout,...e.stepConfig}}:me},[s,Q]),H=N.useMemo(()=>[...e.steps].sort((me,Ee)=>me.ordem-Ee.ordem),[e.steps]),W=H.length,G=W>0?H[Math.min(w,W-1)]:null,ne=N.useMemo(()=>G?MS(G,S,l):{},[G,S,U]),J=N.useMemo(()=>({uploadFile:d,deleteUploadedFile:se?P:void 0,cepLookup:m,resolveTermsUploadUrl:V?Z:void 0,externalData:l,fieldResolvers:f,validatorMapper:b,fieldWarnings:z,componentMapper:h,paymentMethodOptions:x}),[d,se,P,m,Z,V,f,b,z,h,x,U]),te=N.useCallback(async me=>{if(!D){O(!0),A(null);try{const Ee={...S,...me};if($(Ee),n&&await n(w,me),w===W-1)a&&await a(Ee);else{const Fe=w+1;C(Fe),E(Nt=>Math.max(Nt,Fe))}}catch(Ee){console.error("[FormRenderer] Submit error:",Ee);const Fe=Ee instanceof Error?Ee.message:"Ocorreu um erro. Tente novamente.";A(Fe)}finally{O(!1)}}},[w,S,D,W,n,a]),ce=N.useCallback(()=>{w>0&&C(me=>me-1)},[w]);if(!G)return o.jsx(vi.Provider,{value:J,children:o.jsx(ea,{config:Y,className:`min-h-dvh ${Y.wrapperClass??""} ${v??""}`,renderWrapper:!0,children:o.jsx("div",{className:"w-full max-w-4xl mx-auto px-4 py-6 sm:px-6 text-center text-muted-foreground",children:"Nenhum step configurado."})})});const be=Y.layout.eventTitleStyle??"bar",Ce=(Y.layout.stepIndicatorOrientation??"horizontal")==="vertical",ve=W>=1?o.jsx(j,{steps:H.map(me=>({id:me.id,label:me.titulo,icone:me.icone})),currentStep:w,onStepClick:me=>{me!==w&&me<=k&&C(me)}}):null;return o.jsx(vi.Provider,{value:J,children:o.jsx(ea,{config:Y,className:`min-h-dvh ${Y.wrapperClass??""} ${v??""}`,renderWrapper:!0,children:o.jsxs("div",{className:"w-full max-w-4xl mx-auto px-4 py-6 sm:px-6",children:[i&&be==="bar"&&o.jsx("div",{className:"w-full text-center text-sm font-medium py-2.5 px-4 mb-6 rounded-lg border border-input text-muted-foreground bg-muted/30",children:i}),i&&be==="inline"&&o.jsxs("div",{className:"text-center mb-6",children:[o.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest mb-1",style:{color:"var(--t-text-muted)"},children:"Inscrição"}),o.jsx("h1",{className:"text-2xl font-bold",style:{color:"var(--t-text)"},children:i}),o.jsx("div",{className:"h-0.5 w-12 mx-auto mt-3 rounded-full",style:{background:"var(--t-primary)"}})]}),Ce?o.jsxs("div",{className:"flex gap-6 items-start",children:[o.jsx("div",{className:"hidden sm:block shrink-0 w-44 pt-1",children:ve}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"sm:hidden mb-6",children:ve}),o.jsx(eu,{stepIndex:w,totalSteps:W,step:G,defaultValues:ne,externalData:l,fieldErrors:c,isSubmitting:D,submitError:L,validatorMapper:b,onWarningsChange:X,onValuesChange:y,onSubmit:te,onBack:ce},w)]})]}):o.jsxs(o.Fragment,{children:[ve&&o.jsx("div",{className:"mb-8",children:ve}),o.jsx(eu,{stepIndex:w,totalSteps:W,step:G,defaultValues:ne,externalData:l,fieldErrors:c,isSubmitting:D,submitError:L,validatorMapper:b,onWarningsChange:X,onValuesChange:y,onSubmit:te,onBack:ce},w)]})]})})})},BS=({onFillMock:e,onClear:t})=>o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx(Yh,{}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(De,{variant:"outline",size:"sm",onClick:e,children:[o.jsx(_.FlaskConical,{className:"w-3.5 h-3.5 mr-1"}),"Preencher mock"]}),o.jsxs(De,{variant:"ghost",size:"sm",onClick:t,children:[o.jsx(_.Eraser,{className:"w-3.5 h-3.5 mr-1"}),"Limpar"]})]})]}),US=({onRestart:e})=>o.jsxs("div",{className:"max-w-4xl mx-auto flex flex-col items-center justify-center py-16 space-y-4",children:[o.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center",children:o.jsx(_.PartyPopper,{className:"w-8 h-8 text-primary"})}),o.jsx("h2",{className:"text-xl font-bold text-foreground",children:"Formulário enviado!"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Este é um preview simulado. Nenhum dado foi enviado."}),o.jsxs(De,{variant:"outline",onClick:e,children:[o.jsx(_.RotateCcw,{className:"w-4 h-4 mr-1"}),"Recomeçar"]})]}),HS=e=>o.jsx(Nx,{...e,forceShow:!0}),WS=async(e,t,r)=>{for(let n=20;n<=100;n+=20)await new Promise(a=>setTimeout(a,80)),r==null||r(n);return`mock-upload-${Date.now()}`},qS=async e=>({}),tu={texto:"Texto de teste",textarea:"Texto longo de exemplo para preview do formulário.",email:"teste@email.com",number:42,telefone:"(11) 99999-9999",cpf:"123.456.789-00",cep:"01001-000",date:new Date().toISOString().slice(0,10),datetime:new Date().toISOString().slice(0,10),time:"10:30",password:"Senha123!",masked:"123456",checkbox:!0,switch:!0,slider:50,rating:4,color:"#3B82F6",participation_type:{tipo:"todos_os_dias",data:null,genero:null},payment_method:{metodo:"pix",valorTotal:0},date_range:{start:new Date().toISOString().slice(0,10),end:new Date().toISOString().slice(0,10)},file:"mock-upload-preview"};function GS(e){var t,r;const n=e.tipo;if(!(n==="hidden"||n==="terms"||n==="field_array"))return tu[n]!==void 0?tu[n]:(n==="select"||n==="radio"||n==="autocomplete")&&(t=e.opcoes)!=null&&t.length?e.opcoes[0].valor:n==="checkbox_group"&&(r=e.opcoes)!=null&&r.length?[e.opcoes[0].valor]:"Teste"}function XS(e){const t={};for(const r of e.steps)for(const n of r.containers)for(const a of n.campos){const s=GS(a);s!==void 0&&(t[a.nome]=s)}return t}const ZS=({eventoData:e})=>{const{containers:t,configs:r,previewTemplateId:n,stepConfig:a}=gt(),s=N.useMemo(()=>yl({containers:t},r,{nome:"Preview",status:ji.RASCUNHO,template:n,stepConfig:a}),[t,r,n,a]),[i,l]=N.useState(0),[c,d]=N.useState({}),[u,m]=N.useState(!1),p=N.useCallback(()=>{d(XS(s)),l(h=>h+1),m(!1)},[s]),f=N.useCallback(()=>{d({}),l(h=>h+1),m(!1)},[]),b=N.useCallback(()=>{d({}),l(h=>h+1),m(!1)},[]);return s.steps.length===0?o.jsx("div",{className:"rounded-lg border border-dashed border-border/40 p-6 text-center text-xs text-muted-foreground/50",children:"Adicione steps, containers e campos para ver o preview ao vivo"}):u?o.jsx(US,{onRestart:b}):o.jsxs("div",{className:"space-y-3",children:[o.jsx("div",{className:"px-1",children:o.jsx(BS,{onFillMock:p,onClear:f})}),o.jsx(VS,{schema:s,initialValues:c,template:n,externalData:e,uploadFile:WS,cepLookup:qS,onComplete:async()=>m(!0),StepIndicator:HS},i)]})},Sx=({id:e,currentTamanho:t,inicioColuna:r,onResize:n,pushSnapshot:a})=>{const s=N.useRef(null),[i,l]=N.useState(!1),[c,d]=N.useState(null),u=N.useRef(null);N.useEffect(()=>()=>{var p;(p=u.current)==null||p.call(u)},[]);const m=N.useCallback(p=>{p.preventDefault(),p.stopPropagation(),a==null||a();const f=s.current;if(!f)return;const b=f.parentElement;if(!b)return;const h=b.getBoundingClientRect().width,x=f.getBoundingClientRect().width,y=p.clientX,v=r?13-r:12;l(!0);const j=C=>{const S=C.clientX-y,$=(x+S)/h,k=Math.max(1,Math.min(v,Math.round($*12)));d(k),n(k)},w=()=>{l(!1),d(null),u.current=null,window.removeEventListener("mousemove",j),window.removeEventListener("mouseup",w)};u.current=()=>{l(!1),d(null),window.removeEventListener("mousemove",j),window.removeEventListener("mouseup",w)},window.addEventListener("mousemove",j),window.addEventListener("mouseup",w)},[r,n,a]);return{resizeRef:s,resizing:i,resizePreview:c,handleResizeStart:m}},KS=({id:e,elementRef:t,onPositionApply:r,setPositionDrag:n,setSelected:a,pushSnapshot:s})=>{const i=N.useRef(null);return N.useEffect(()=>()=>{var l;(l=i.current)==null||l.call(i)},[]),{handlePositionMouseDown:N.useCallback(l=>{l.preventDefault(),l.stopPropagation(),s==null||s(),a(e);const c=t.current;if(!c)return;const d=c.parentElement;if(!d)return;const u=d.getBoundingClientRect(),m=u.width/12,p=c.getBoundingClientRect(),f=Math.max(1,Math.round(p.width/m)),b=p.left-u.left,h=l.clientX-p.left,x=w=>{const C=w-u.left-h,S=Math.round(C/m)+1;return Math.max(1,Math.min(13-f,S))},y=Math.max(1,Math.min(12,Math.round(b/m)+1));n({itemId:e,ghostStart:y,ghostSpan:f,cursorX:l.clientX,cursorY:l.clientY});const v=w=>{n({itemId:e,ghostStart:x(w.clientX),ghostSpan:f,cursorX:w.clientX,cursorY:w.clientY})},j=w=>{r(x(w.clientX)),n(null),i.current=null,window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",j)};i.current=()=>{n(null),window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",j)},window.addEventListener("mousemove",v),window.addEventListener("mouseup",j)},[e,t,r,n,a,s])}},ba=({id:e,container:t})=>{const{attributes:r,listeners:n,setNodeRef:a,transform:s,transition:i,isDragging:l}=Yt.useSortable({id:e,data:{isCanvasItem:!0,type:"field",id:e,fromContainer:t}}),{selectedId:c,setSelected:d,getConfig:u,updateConfig:m,removeItem:p,setPositionDrag:f,positionDrag:b,pushSnapshot:h}=gt(),x=u(e),y=Nh(e),v=(y==null?void 0:y.icon)||_.Type,j=c===e,w=x.tamanho||6,C=(b==null?void 0:b.itemId)===e,[S,$]=N.useState(!1),k="var(--t-primary, hsl(var(--primary)))",E=j?k:S?`color-mix(in srgb, ${k} 60%, transparent)`:`color-mix(in srgb, ${k} 25%, transparent)`,D=j?`0 0 0 2px color-mix(in srgb, ${k} 30%, transparent)`:void 0,{resizeRef:O,resizing:L,resizePreview:A,handleResizeStart:z}=Sx({id:e,currentTamanho:w,inicioColuna:x.inicioColuna,onResize:q=>m(e,{tamanho:q}),pushSnapshot:h}),{handlePositionMouseDown:X}=KS({id:e,elementRef:O,onPositionApply:q=>m(e,{inicioColuna:q}),setPositionDrag:f,setSelected:d,pushSnapshot:h});return o.jsxs("div",{ref:q=>{a(q),O.current=q},onClick:q=>{q.stopPropagation(),d(e)},"data-field-id":e,onMouseEnter:()=>$(!0),onMouseLeave:()=>$(!1),className:Ht("relative flex items-center gap-2 rounded border bg-card/80 backdrop-blur-sm px-2.5 pt-1.5 pb-3.5 cursor-pointer transition-all text-xs",L&&"ring-2 ring-blue-400/50",C&&"opacity-0 pointer-events-none"),style:{gridColumn:x.inicioColuna?`${x.inicioColuna} / span ${w}`:`span ${w}`,transform:oa.CSS.Transform.toString(s),transition:i,opacity:l?0:1,borderColor:E,boxShadow:D},children:[o.jsx("div",{onMouseDown:X,onClick:q=>q.stopPropagation(),className:"cursor-ew-resize shrink-0 p-0.5 rounded hover:bg-primary/20 transition-colors",title:"Arrastar para mudar coluna",children:o.jsx(_.ArrowLeftRight,{className:"h-3 w-3 text-primary/60"})}),o.jsx("div",{...n,...r,className:"cursor-grab shrink-0",onClick:q=>q.stopPropagation(),children:o.jsx(_.GripVertical,{className:"h-3 w-3 text-primary"})}),o.jsx(v,{className:"h-3.5 w-3.5 text-primary shrink-0"}),o.jsx("span",{className:"font-medium truncate flex-1",children:x.label}),x.condition&&o.jsx(_.Zap,{className:"h-3 w-3 text-amber-500 shrink-0"}),x.required&&o.jsx("span",{className:"text-destructive font-bold",children:"*"}),o.jsxs("span",{className:"text-[9px] text-muted-foreground shrink-0",children:[A??w,"/12"]}),o.jsx("button",{onClick:q=>{q.stopPropagation(),p(e)},className:"transition-opacity shrink-0 p-0.5 rounded hover:bg-destructive/10",style:{opacity:S?1:0},children:o.jsx(_.Trash2,{className:"h-3 w-3 text-destructive"})}),o.jsx("div",{className:"absolute left-2 -bottom-0.5 font-mono truncate max-w-[90%] pointer-events-none text-[8px] text-muted-foreground/30",children:e}),o.jsx("div",{"data-resize":!0,onMouseDown:z,className:"cursor-col-resize absolute right-0 top-0 bottom-0 w-2 hover:bg-primary/20 transition-colors flex items-center justify-center",children:o.jsx(_.GripHorizontal,{className:"h-3 w-3 text-primary/40 rotate-90"})})]})},YS=({id:e,container:t})=>{var r;const{attributes:n,listeners:a,setNodeRef:s,transform:i,transition:l,isDragging:c}=Yt.useSortable({id:e,data:{isCanvasItem:!0,type:"field",id:e,fromContainer:t}}),{setNodeRef:d,isOver:u}=Zt.useDroppable({id:`zone-${e}`}),{selectedId:m,setSelected:p,getConfig:f,removeItem:b,moveItem:h,containers:x}=gt(),y=f(e),v=(((r=x[e])==null?void 0:r.children)??[]).filter(C=>He(C)==="field"),j=m===e,w=y.tamanho||12;return o.jsxs("div",{ref:s,onClick:C=>{C.stopPropagation(),p(e)},className:Ht("group/fa relative rounded-lg border overflow-hidden transition-all",c&&"opacity-0 pointer-events-none",j?"border-amber-500 ring-2 ring-amber-500/20 shadow-lg":"border-amber-500/30 hover:border-amber-500/55"),style:{gridColumn:y.inicioColuna?`${y.inicioColuna} / span ${w}`:`span ${w}`,transform:oa.CSS.Transform.toString(i),transition:l},children:[o.jsxs("div",{className:Ht("flex items-center gap-1.5 border-b px-2 py-1.5 transition-colors",j?"bg-amber-500/15 border-amber-500/30":"bg-amber-500/10 border-amber-500/20"),children:[o.jsx("div",{...a,...n,className:"cursor-grab shrink-0 p-1 -ml-1 rounded hover:bg-amber-500/20 transition-colors",onClick:C=>C.stopPropagation(),children:o.jsx(_.GripVertical,{className:"h-3.5 w-3.5 text-amber-500"})}),o.jsxs("div",{className:"flex flex-col -my-1 shrink-0",children:[o.jsx("button",{onClick:C=>{C.stopPropagation(),h(e,"up")},className:"p-0 hover:bg-amber-500/10 rounded transition-colors",title:"Mover para cima",children:o.jsx(_.ChevronUp,{className:"h-3 w-3 text-muted-foreground hover:text-amber-500"})}),o.jsx("button",{onClick:C=>{C.stopPropagation(),h(e,"down")},className:"p-0 hover:bg-amber-500/10 rounded transition-colors",title:"Mover para baixo",children:o.jsx(_.ChevronDown,{className:"h-3 w-3 text-muted-foreground hover:text-amber-500"})})]}),o.jsx(_.List,{className:"h-3.5 w-3.5 text-amber-500 shrink-0"}),o.jsx("span",{className:"text-xs font-semibold truncate flex-1 text-amber-700 dark:text-amber-300",children:y.label}),o.jsxs("span",{className:"text-[10px] text-muted-foreground shrink-0 bg-amber-500/10 px-1.5 rounded",children:[y.itemLabel||"Item"," · ",v.length," campo",v.length!==1?"s":""]}),o.jsx("button",{onClick:C=>{C.stopPropagation(),b(e)},className:"opacity-0 group-hover/fa:opacity-100 transition-opacity shrink-0 p-0.5 rounded hover:bg-destructive/10",children:o.jsx(_.Trash2,{className:"h-3 w-3 text-destructive"})})]}),o.jsx("div",{className:"px-2 -mt-0.5 mb-0.5",children:o.jsx("span",{className:"text-[8px] text-muted-foreground/30 font-mono",children:e})}),o.jsxs("div",{ref:d,className:Ht("relative p-2 min-h-[40px] gap-1.5 transition-all duration-150",u?"bg-amber-500/10 ring-2 ring-inset ring-amber-500/40":""),style:{display:"grid",gridTemplateColumns:"repeat(12, minmax(0, 1fr))",gridAutoRows:"min-content"},children:[v.length===0&&o.jsx("p",{className:"text-[10px] text-muted-foreground/60 text-center py-2 italic",style:{gridColumn:"span 12"},children:"Arraste campos aqui"}),o.jsx(Yt.SortableContext,{items:v,strategy:Yt.rectSortingStrategy,children:v.map(C=>o.jsx(ba,{id:C,container:e},C))})]})]})},ru=5,JS=({id:e,elementRef:t,tamanho:r,inicioColuna:n,onPositionApply:a,setPositionDrag:s,setSelected:i,reorderStrategy:l})=>{const c=N.useRef({inicioColuna:n,tamanho:r});c.current={inicioColuna:n,tamanho:r};const d=N.useRef(null);return N.useEffect(()=>()=>{var u;(u=d.current)==null||u.call(d)},[]),{handleGripMouseDown:N.useCallback(u=>{u.preventDefault(),u.stopPropagation(),i(e);const m=u.clientX,p=u.clientY;let f=!1;const b=()=>{d.current=null,window.removeEventListener("mousemove",h),window.removeEventListener("mouseup",x)},h=j=>{const w=Math.abs(j.clientX-m),C=Math.abs(j.clientY-p);w<ru&&C<ru||(f=!0,b(),w>=C?y(j):v(j))},x=()=>{f||b()};window.addEventListener("mousemove",h),window.addEventListener("mouseup",x),d.current=b;const y=j=>{const w=t.current;if(!w)return;const C=w.parentElement;if(!C)return;const S=C.getBoundingClientRect(),$=S.width/12,{tamanho:k}=c.current,E=w.getBoundingClientRect(),D=E.left-S.left,O=Math.max(1,Math.min(12,Math.round(D/$)+1)),L=E.left;s({itemId:e,ghostStart:O,ghostSpan:k,cursorX:j.clientX,cursorY:j.clientY});const A=q=>{const Z=q-L,V=Math.round(Z/$)+1;return Math.max(1,Math.min(13-k,V))};s({itemId:e,ghostStart:A(j.clientX),ghostSpan:k,cursorX:j.clientX,cursorY:j.clientY});const z=q=>{s({itemId:e,ghostStart:A(q.clientX),ghostSpan:k,cursorX:q.clientX,cursorY:q.clientY})},X=q=>{a(A(q.clientX)),s(null),d.current=null,window.removeEventListener("mousemove",z),window.removeEventListener("mouseup",X)};window.addEventListener("mousemove",z),window.addEventListener("mouseup",X),d.current=()=>{s(null),window.removeEventListener("mousemove",z),window.removeEventListener("mouseup",X)}},v=j=>{const w=l,C=t.current;if(!C)return;const S=C.parentElement;if(!S)return;const $=w.dataAttribute||"data-container-id";w.pushSnapshot(),w.setReorderDrag({draggingId:e});let k=j.clientY;const E=O=>{const L=Array.from(S.children).filter(A=>A!==C&&A.getAttribute($));for(const A of L){const z=A.getBoundingClientRect(),X=z.top+z.height/2;if(O.clientY<X&&O.clientY>z.top&&O.clientY<k){w.moveItemNoSnapshot(e,"up"),k=O.clientY;break}else if(O.clientY>X&&O.clientY<z.bottom&&O.clientY>k){w.moveItemNoSnapshot(e,"down"),k=O.clientY;break}}},D=()=>{w.setReorderDrag(null),d.current=null,window.removeEventListener("mousemove",E),window.removeEventListener("mouseup",D)};window.addEventListener("mousemove",E),window.addEventListener("mouseup",D),d.current=()=>{w.setReorderDrag(null),window.removeEventListener("mousemove",E),window.removeEventListener("mouseup",D)}}},[e,t,a,s,i,l])}},Ll=({showGuides:e,positionDrag:t})=>!e&&!t?null:o.jsxs(o.Fragment,{children:[e&&o.jsx("div",{className:"absolute inset-0 pointer-events-none z-10",style:{display:"grid",gridTemplateColumns:"repeat(12, 1fr)",padding:"inherit",gap:"inherit"},children:Array.from({length:12},(r,n)=>o.jsx("div",{className:"border border-dashed border-muted-foreground/20 rounded-sm flex items-end justify-center pb-1",children:o.jsx("span",{className:"text-[8px] text-muted-foreground/40 font-mono",children:n+1})},n))}),t&&o.jsx("div",{className:"absolute pointer-events-none z-20 rounded-lg border-2 border-dashed border-destructive/60 bg-destructive/10",style:{top:"12px",bottom:"12px",left:`calc(${(t.ghostStart-1)/12*100}% + 12px)`,width:`calc(${t.ghostSpan/12*100}% - 8px)`,transition:"left 0.1s ease-out, width 0.1s ease-out"},children:o.jsxs("div",{className:"absolute -top-5 left-1/2 -translate-x-1/2 bg-destructive text-destructive-foreground text-[10px] font-bold px-2 py-0.5 rounded whitespace-nowrap",children:[t.ghostStart," →"," ",t.ghostStart+t.ghostSpan-1]})})]}),Ml=({id:e,container:t})=>{var r;const{setNodeRef:n,isOver:a}=Zt.useDroppable({id:`zone-${e}`}),{selectedId:s,setSelected:i,getConfig:l,updateConfig:c,removeItem:d,moveItem:u,moveItemNoSnapshot:m,setPositionDrag:p,positionDrag:f,reorderDrag:b,setReorderDrag:h,pushSnapshot:x,containers:y}=gt(),v=l(e),j=((r=y[e])==null?void 0:r.children)??[],w=j.filter(Y=>He(Y)==="field"),C=s===e,S=v.tamanho||12,$=(f==null?void 0:f.itemId)===e,k=(b==null?void 0:b.draggingId)===e,E=f&&j.includes(f.itemId),D=s&&j.includes(s)&&He(s)==="field",[O,L]=N.useState(!1),A="var(--t-primary, hsl(var(--primary)))",z=C?A:O?"rgba(59,130,246,0.55)":"rgba(59,130,246,0.3)",X=C?`color-mix(in srgb, ${A} 15%, transparent)`:O?"rgba(59,130,246,0.12)":"rgba(59,130,246,0.07)",q=C?`color-mix(in srgb, ${A} 30%, transparent)`:O?"rgba(59,130,246,0.28)":"rgba(59,130,246,0.18)",Z=C?`0 0 0 3px color-mix(in srgb, ${A} 20%, transparent)`:O?"0 0 0 2px rgba(59,130,246,0.25)":void 0,{resizeRef:V,resizing:M,resizePreview:P,handleResizeStart:se}=Sx({id:e,currentTamanho:S,inicioColuna:v.inicioColuna,onResize:Y=>c(e,{tamanho:Y}),pushSnapshot:x}),U=N.useMemo(()=>({kind:"custom",moveItemNoSnapshot:m,pushSnapshot:x,setReorderDrag:h,dataAttribute:"data-container-id"}),[m,x,h]),{handleGripMouseDown:Q}=JS({id:e,elementRef:V,tamanho:S,inicioColuna:v.inicioColuna||1,onPositionApply:Y=>c(e,{inicioColuna:Y}),setPositionDrag:p,setSelected:i,reorderStrategy:U});return o.jsxs(o.Fragment,{children:[o.jsxs("div",{ref:Y=>{V.current=Y},onClick:Y=>{Y.stopPropagation(),i(e)},onMouseEnter:()=>L(!0),onMouseLeave:()=>L(!1),className:Ht("relative rounded-lg border overflow-hidden transition-all",M&&"ring-2 ring-blue-400/50",$&&"opacity-0 pointer-events-none",k&&"opacity-50"),"data-container-id":e,style:{gridColumn:v.inicioColuna?`${v.inicioColuna} / span ${S}`:`span ${S}`,minWidth:"80px",borderColor:z,boxShadow:Z},children:[o.jsxs("div",{className:"flex items-center gap-1.5 border-b px-2 py-1.5 transition-colors",style:{backgroundColor:X,borderColor:q},children:[o.jsx("div",{"data-grip":!0,onMouseDown:Q,className:"cursor-grab shrink-0 p-1 -ml-1 rounded hover:bg-primary/20 transition-colors",children:o.jsx(_.GripVertical,{className:"h-3.5 w-3.5 text-blue-500"})}),o.jsxs("div",{className:"flex flex-col -my-1 shrink-0",children:[o.jsx("button",{onClick:Y=>{Y.stopPropagation(),u(e,"up")},className:"p-0 hover:bg-primary/10 rounded transition-colors",title:"Mover para cima",children:o.jsx(_.ChevronUp,{className:"h-3 w-3 text-muted-foreground hover:text-primary"})}),o.jsx("button",{onClick:Y=>{Y.stopPropagation(),u(e,"down")},className:"p-0 hover:bg-primary/10 rounded transition-colors",title:"Mover para baixo",children:o.jsx(_.ChevronDown,{className:"h-3 w-3 text-muted-foreground hover:text-primary"})})]}),o.jsx(_.BoxSelect,{className:"h-3.5 w-3.5 text-blue-500 shrink-0"}),o.jsx("span",{className:Ht("text-xs font-semibold truncate flex-1",v.showLabel===!1?"text-blue-500/50 italic":"text-blue-700 dark:text-blue-300"),children:v.label}),v.showAsCard&&o.jsx(_.SquareStack,{className:"h-3 w-3 text-blue-400 shrink-0"}),v.showLabel===!1&&o.jsx(_.EyeOff,{className:"h-3 w-3 text-muted-foreground/50 shrink-0"}),o.jsxs("span",{className:"text-[10px] text-muted-foreground shrink-0 bg-blue-500/10 px-1.5 rounded",children:[P??S,"/12"]}),o.jsx("button",{onClick:Y=>{Y.stopPropagation(),d(e)},className:"transition-opacity shrink-0 p-0.5 rounded hover:bg-destructive/10",style:{opacity:O?1:0},children:o.jsx(_.Trash2,{className:"h-3 w-3 text-destructive"})})]}),o.jsx("div",{className:"px-2 -mt-0.5 mb-0.5",children:o.jsx("span",{className:"text-[8px] text-muted-foreground/30 font-mono",children:e})}),o.jsxs("div",{ref:n,className:Ht("relative p-2 min-h-[40px] gap-1.5 transition-all duration-150",a?"bg-primary/15 ring-2 ring-inset ring-primary/50":(E||D)&&"bg-muted/30"),style:{display:"grid",gridTemplateColumns:"repeat(12, minmax(0, 1fr))",gridAutoRows:"min-content"},children:[o.jsx(Ll,{showGuides:!!E||!!D,positionDrag:E?f:null}),j.length===0&&o.jsx("p",{className:"text-[10px] text-muted-foreground/60 text-center py-2 italic",style:{gridColumn:"span 12"},children:"Arraste campos aqui"}),o.jsx(Yt.SortableContext,{items:w,strategy:Yt.rectSortingStrategy,children:j.filter(Y=>He(Y)==="field").map(Y=>l(Y).fieldType==="field_array"?o.jsx(YS,{id:Y,container:e},Y):o.jsx(ba,{id:Y,container:e},Y))})]}),o.jsx("div",{onMouseDown:se,className:"cursor-col-resize absolute right-0 top-0 bottom-0 w-2 hover:bg-blue-500/20 transition-colors flex items-center justify-center",children:o.jsx(_.GripHorizontal,{className:"h-3 w-3 text-blue-500/40 rotate-90"})})]}),$&&f&&yi.createPortal(o.jsxs("div",{style:{position:"fixed",left:f.cursorX+14,top:f.cursorY-18,zIndex:9999,pointerEvents:"none"},className:"flex items-center gap-1 bg-foreground text-background text-[10px] font-mono px-2 py-0.5 rounded shadow-xl border border-border/20",children:[o.jsx(_.BoxSelect,{className:"h-2.5 w-2.5"}),"col ",f.ghostStart,"–",f.ghostStart+f.ghostSpan-1]}),document.body)," "]})},$x=({id:e,container:t,index:r})=>{var n;const{attributes:a,listeners:s,setNodeRef:i,transform:l,transition:c,isDragging:d}=Yt.useSortable({id:e,data:{isCanvasItem:!0,type:"step",id:e}}),{setNodeRef:u,isOver:m}=Zt.useDroppable({id:`zone-${e}`}),{selectedId:p,setSelected:f,getConfig:b,removeItem:h,containers:x,positionDrag:y}=gt(),v=b(e),j=((n=x[e])==null?void 0:n.children)??[],w=p===e,C=y&&j.includes(y.itemId),[S,$]=N.useState(!1),k="var(--t-primary, hsl(var(--primary)))",E=w?k:S?`color-mix(in srgb, ${k} 60%, transparent)`:`color-mix(in srgb, ${k} 25%, transparent)`,D=w?`color-mix(in srgb, ${k} 14%, transparent)`:S?`color-mix(in srgb, ${k} 10%, transparent)`:`color-mix(in srgb, ${k} 6%, transparent)`,O=w?`color-mix(in srgb, ${k} 28%, transparent)`:`color-mix(in srgb, ${k} 15%, transparent)`,L=w?`0 0 0 3px color-mix(in srgb, ${k} 20%, transparent)`:void 0,A={transform:oa.CSS.Transform.toString(l),transition:c,opacity:d?0:1};return o.jsxs("div",{ref:i,style:{...A,borderWidth:"2px",borderStyle:"solid",borderColor:E,boxShadow:L},onMouseEnter:()=>$(!0),onMouseLeave:()=>$(!1),onClick:z=>{z.stopPropagation(),f(e)},className:"group/step rounded-xl overflow-hidden transition-all",children:[o.jsxs("div",{className:"flex items-center gap-2 border-b px-3 py-2",style:{backgroundColor:D,borderColor:O},children:[o.jsx("div",{...s,...a,className:"cursor-grab shrink-0",onClick:z=>z.stopPropagation(),children:o.jsx(_.GripVertical,{className:"h-3.5 w-3.5 text-primary"})}),o.jsx(_.Layers,{className:"h-4 w-4 text-primary shrink-0"}),o.jsxs("span",{className:"text-sm font-bold truncate flex-1 text-primary",children:["Step ",r+1," — ",v.label]}),v.description&&o.jsx("span",{className:"text-[10px] text-muted-foreground truncate hidden md:block",children:v.description}),o.jsx("button",{onClick:z=>{z.stopPropagation(),h(e)},className:"transition-opacity shrink-0 p-1 rounded hover:bg-destructive/10",style:{opacity:S?1:0},children:o.jsx(_.Trash2,{className:"h-3.5 w-3.5 text-destructive"})})]}),o.jsxs("div",{ref:u,className:Ht("relative p-3 min-h-[80px] gap-2 items-start transition-all duration-150",m?"bg-blue-500/20 ring-2 ring-inset ring-blue-400/70 shadow-[inset_0_0_0_2px_theme(colors.blue.400/50%)]":""),style:{display:"grid",gridTemplateColumns:"repeat(12, minmax(0, 1fr))",gridAutoRows:"min-content",backgroundImage:"radial-gradient(circle, hsl(var(--muted-foreground) / 0.15) 1px, transparent 1px)",backgroundSize:"16px 16px"},children:[o.jsx(Ll,{showGuides:!!C,positionDrag:C?y:null}),j.length===0&&o.jsx("p",{className:"text-xs text-muted-foreground/50 text-center py-6 italic w-full",style:{gridColumn:"span 12"},children:"Arraste containers aqui"}),j.map(z=>He(z)==="container"?o.jsx(Ml,{id:z,container:e},z):o.jsx(ba,{id:z,container:e},z))]})]})},QS=()=>{var e;const{containers:t,setSelected:r}=gt(),n=((e=t.root)==null?void 0:e.children)??[],a=n.filter(l=>He(l)==="step"),{setNodeRef:s,isOver:i}=Zt.useDroppable({id:"root"});return o.jsxs("div",{ref:s,onClick:()=>r(null),className:`min-h-[500px] rounded-xl border p-4 space-y-4 transition-all duration-150 ${i?"bg-primary/10 border-primary/60 ring-2 ring-primary/30 shadow-[0_0_0_4px_theme(colors.primary/10%)]":"border-border/40"}`,style:{backgroundImage:"radial-gradient(circle, hsl(var(--muted-foreground) / 0.12) 1px, transparent 1px)",backgroundSize:"20px 20px",backgroundColor:i?void 0:"hsl(var(--muted) / 0.3)"},children:[n.length===0&&o.jsx("div",{className:"flex items-center justify-center h-[400px]",children:o.jsxs("div",{className:"text-center space-y-2",children:[o.jsx(_.Layers,{className:"h-10 w-10 text-muted-foreground/30 mx-auto"}),o.jsxs("p",{className:"text-sm text-muted-foreground/50",children:["Arraste ",o.jsx("strong",{children:"Steps"})," da paleta para cá"]})]})}),o.jsx(Yt.SortableContext,{items:a,strategy:Yt.verticalListSortingStrategy,children:n.map((l,c)=>{const d=He(l);return d==="step"?o.jsx($x,{id:l,container:"root",index:c},l):d==="container"?o.jsx(Ml,{id:l,container:"root"},l):o.jsx(ba,{id:l,container:"root"},l)})})]})},e$={personal:"Pessoal",address:"Endereço",health:"Saúde",event:"Evento",payment:"Pagamento",emergency:"Emergência"},t$={texto:"Texto",selecao:"Seleção",range:"Numérico / Visual",data:"Data e Hora",contato:"Contato / Endereço",outros:"Arquivo / Outros"},r$=()=>{const e=Or.reduce((t,r)=>{const n=r.group??"outros";return t[n]||(t[n]=[]),t[n].push(r),t},{});return o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("h2",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Estrutura"}),vl.map(t=>o.jsx(nu,{component:t.component,label:t.label,icon:t.icon,color:t.color},t.component))]}),Object.entries(e).map(([t,r])=>o.jsx(Vs,{label:t$[t]??t,children:r.map(n=>o.jsx(nu,{component:n.component,label:n.label,icon:n.icon,color:"border-border"},n.component))},t)),o.jsx(Vs,{label:"Blocos pré-configurados",defaultOpen:!1,children:mo.map(t=>o.jsx(n$,{block:t},t.id))}),o.jsx(Vs,{label:"Blocos de steps",defaultOpen:!1,children:Ci.map(t=>o.jsx(a$,{block:t},t.id))})]})},Vs=({label:e,children:t,defaultOpen:r=!0})=>{const[n,a]=N.useState(r);return o.jsxs("div",{className:"space-y-2",children:[o.jsxs("button",{type:"button",onClick:()=>a(s=>!s),className:"flex w-full items-center justify-between text-xs font-semibold text-muted-foreground uppercase tracking-wide hover:text-foreground transition-colors",children:[e,o.jsx(_.ChevronDown,{className:`h-3.5 w-3.5 transition-transform ${n?"":"-rotate-90"}`})]}),n&&o.jsx("div",{className:"space-y-1.5",children:t})]})},nu=({component:e,label:t,icon:r,color:n})=>{const{attributes:a,listeners:s,setNodeRef:i,transform:l,isDragging:c}=Zt.useDraggable({id:`palette-${e}`,data:{isPaletteItem:!0,componentType:e}});return o.jsxs("div",{ref:i,...s,...a,className:`cursor-grab flex items-center gap-2 rounded-lg border px-3 py-2 select-none hover:bg-accent transition-colors ${n} ${c?"opacity-50":""}`,style:{transform:c?void 0:oa.CSS.Translate.toString(l)},children:[o.jsx(_.GripVertical,{className:"h-4 w-4 text-muted-foreground"}),o.jsx(r,{className:"h-4 w-4"}),o.jsx("span",{className:"text-sm font-medium",children:t})]})},n$=({block:e})=>{const{attributes:t,listeners:r,setNodeRef:n,transform:a,isDragging:s}=Zt.useDraggable({id:`preset-${e.id}`,data:{isPalettePreset:!0,presetId:e.id}}),i=e.icon?Pt[e.icon]:void 0,l=e$[e.category]??e.category;return o.jsxs("div",{ref:n,...r,...t,className:`cursor-grab flex items-center gap-2 rounded-lg border border-primary/30 bg-primary/5 px-3 py-2 select-none hover:bg-primary/10 transition-colors ${s?"opacity-50":""}`,style:{transform:s?void 0:oa.CSS.Translate.toString(a)},title:e.description,children:[o.jsx(_.GripVertical,{className:"h-4 w-4 text-muted-foreground shrink-0"}),i?o.jsx(i,{className:"h-4 w-4 text-primary shrink-0"}):o.jsx(Pt.Blocks,{className:"h-4 w-4 text-primary shrink-0"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("span",{className:"text-sm font-medium block truncate",children:e.name}),o.jsx("span",{className:"text-[10px] text-muted-foreground",children:l})]})]})},a$=({block:e})=>{const{addPresetStepBlock:t}=gt(),r=e.icon?Pt[e.icon]:void 0;return o.jsxs("button",{type:"button",onClick:()=>t(e),className:"w-full flex items-center gap-2 rounded-lg border border-amber-500/30 bg-amber-500/5 px-3 py-2 cursor-pointer select-none hover:bg-amber-500/15 transition-colors text-left",title:e.description,children:[r?o.jsx(r,{className:"h-4 w-4 text-amber-400 shrink-0"}):o.jsx(Pt.Layers,{className:"h-4 w-4 text-amber-400 shrink-0"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("span",{className:"text-sm font-medium block truncate",children:e.name}),o.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[e.steps.length," steps"]})]}),o.jsxs("span",{className:"text-[10px] text-amber-400 border border-amber-500/30 rounded px-1.5 py-0.5 shrink-0",children:["+",e.steps.length," steps"]})]})},o$=[...vl,...Or],Ex=({data:e})=>{const{getConfig:t}=gt();if(!e)return null;const r=e;if(r.isPalettePreset){const n=ki(r.presetId);return o.jsxs("div",{className:"flex items-center gap-2 rounded-full bg-primary text-primary-foreground px-3 py-1.5 shadow-2xl text-xs font-semibold cursor-grabbing pointer-events-none",children:[o.jsx(Pt.Blocks,{className:"h-3.5 w-3.5 shrink-0"}),(n==null?void 0:n.name)??"Bloco"]})}if(r.isPaletteItem){const n=o$.find(s=>s.component===r.componentType),a=n==null?void 0:n.icon;return o.jsxs("div",{className:"flex items-center gap-2 rounded-full bg-primary text-primary-foreground px-3 py-1.5 shadow-2xl text-xs font-semibold cursor-grabbing pointer-events-none",children:[a&&o.jsx(a,{className:"h-3.5 w-3.5 shrink-0"}),(n==null?void 0:n.label)??r.componentType]})}if(r.isCanvasItem){const{type:n,id:a}=r,s=t(a),i={step:"border-primary/80 bg-primary text-primary-foreground",container:"border-blue-600 bg-blue-600 text-white",field:"border-primary/80 bg-primary text-primary-foreground"},l={step:"Step",container:"Container",field:"Campo"};return o.jsxs("div",{className:Ht("flex items-center gap-2 rounded-full px-3 py-1.5 shadow-2xl text-xs font-semibold cursor-grabbing pointer-events-none min-w-[100px] max-w-[200px]",i[n]??"border-border bg-card"),children:[o.jsx(_.GripVertical,{className:"h-3 w-3 opacity-60 shrink-0"}),o.jsxs("span",{className:"opacity-70 shrink-0",children:[l[n]??n,":"]}),o.jsx("span",{className:"truncate",children:s.label||a})]})}return null},Dx=({schema:e,children:t,uploadTermsPdf:r,deleteTermsPdf:n})=>{var a;const s=N.useMemo(()=>{var i;return(i=e==null?void 0:e.steps)!=null&&i.length?Eh(e):null},[e]);return o.jsx(C1,{children:o.jsx(Rh,{initialConfigs:s==null?void 0:s.configs,initialContainers:(a=s==null?void 0:s.dndState)==null?void 0:a.containers,initialTemplateId:(s==null?void 0:s.templateId)??void 0,initialStepConfig:s==null?void 0:s.stepConfig,schemaId:(e==null?void 0:e.id)??void 0,uploadTermsPdf:r,deleteTermsPdf:n,children:t})})},Tx=({children:e,onError:t})=>{const{containers:r,addItem:n,addPresetBlock:a,moveCanvasItem:s,reorderInContainer:i}=gt(),l=Zt.useSensors(Zt.useSensor(Zt.PointerSensor,{activationConstraint:{distance:5}})),[c,d]=N.useState(null);return o.jsxs(Zt.DndContext,{sensors:l,onDragStart:u=>{d({data:u.active.data.current})},onDragEnd:u=>{var m,p,f,b,h;d(null);const{active:x,over:y}=u;if(!y)return;const v=x.data.current,j=String(y.id);if(v!=null&&v.isPalettePreset){const{presetId:w}=v,C=ki(w);if(!C)return;if(j.startsWith("zone-")){const S=j.slice(5);a(C,S)}else j==="root"&&(t==null||t("Arraste o bloco sobre um step existente."));return}if(v!=null&&v.isPaletteItem){const{componentType:w}=v;j==="root"?n(w,"root"):j.startsWith("zone-")&&n(w,j.slice(5));return}if(v!=null&&v.isCanvasItem){const{type:w,id:C}=v;if(w==="step"){const S=((m=r.root)==null?void 0:m.children)??[],$=S.indexOf(C),k=S.indexOf(j);$!==-1&&k!==-1&&$!==k&&i("root",Yt.arrayMove(S,$,k));return}if(w==="field"){const S=v.fromContainer;let $=S,k=null;if(j.startsWith("zone-"))$=j.slice(5);else{const E=wl(j,r);E&&($=E,k=j)}if($===S&&k){const E=((p=r[S])==null?void 0:p.children)??[],D=E.indexOf(C),O=E.indexOf(k);D!==-1&&O!==-1&&D!==O&&i(S,Yt.arrayMove(E,D,O))}else if($!==S){const E=k?(((f=r[$])==null?void 0:f.children)??[]).indexOf(k):-1;s(C,S,$,E>=0?E:((h=(b=r[$])==null?void 0:b.children)==null?void 0:h.length)??0)}}}},children:[e,o.jsx(Zt.DragOverlay,{dropAnimation:null,children:c?o.jsx(Ex,{data:c.data}):null})]})},s$=({schema:e,children:t,onError:r,uploadTermsPdf:n,deleteTermsPdf:a})=>o.jsx(Dx,{schema:e,uploadTermsPdf:n,deleteTermsPdf:a,children:o.jsx(Tx,{onError:r,children:t})});exports.BuilderDndContext=Tx;exports.BuilderProvider=Rh;exports.BuilderShell=s$;exports.BuilderWrapper=Dx;exports.Canvas=QS;exports.ConfigPanel=oN;exports.ContainerRenderer=yh;exports.DFCepField=gl;exports.DFCheckbox=Wo;exports.DFCheckboxGroup=ul;exports.DFDateField=Rn;exports.DFFieldArray=uh;exports.DFFileUpload=xl;exports.DFHidden=Go;exports.DFMaskedInput=_r;exports.DFParticipationType=mh;exports.DFPaymentMethod=hh;exports.DFRadioGroup=ml;exports.DFSelect=Ho;exports.DFTerms=xh;exports.DFTextField=Tt;exports.DFTextarea=Uo;exports.DefaultStepIndicator=Ch;exports.DragGhost=Ex;exports.DroppedContainer=Ml;exports.DroppedField=ba;exports.DroppedStep=$x;exports.EVENT_VARIABLES=bl;exports.FIELD_TYPES=Or;exports.FIELD_TYPE_ICONS=Bx;exports.FIELD_TYPE_LABELS=Vx;exports.FieldType=T;exports.FormRenderer=Hk;exports.FormSchemaStatus=ji;exports.FormSpy=Wk;exports.GridOverlay=Ll;exports.LivePreview=ZS;exports.MaskType=au;exports.OPCOES_POR_DIA=ph;exports.OPCOES_TODOS_OS_DIAS=fh;exports.PRESET_BLOCKS=mo;exports.PRESET_STEP_BLOCKS=Ci;exports.Palette=r$;exports.RendererContext=Ja;exports.STRUCTURE_TYPES=vl;exports.StepRenderer=wh;exports.TEMPLATE_REGISTRY=Kr;exports.TemplateProvider=ea;exports.builderToFormSchema=yl;exports.evaluateFieldCondition=at;exports.findParentContainer=wl;exports.formSchemaToBuilder=Eh;exports.generateId=ou;exports.getAllTemplates=ag;exports.getFieldMeta=qk;exports.getFieldMetaById=Nh;exports.getItemType=He;exports.getPresetById=ki;exports.getPresetStepBlockById=cg;exports.getPresetsByCategory=lg;exports.getTemplateConfig=uo;exports.interpolate=xt;exports.interpolateContainer=Bo;exports.interpolateField=th;exports.interpolateStep=rh;exports.isDarkTemplate=su;exports.isGlassmorphism=og;exports.makeStepResolver=Qf;exports.makeStepWarnComputer=eh;exports.useBuilder=gt;exports.useBuilderExport=Xk;exports.useField=zk;exports.useFieldApi=Lk;exports.useFormApi=Fk;exports.useFormState=jh;exports.useRendererContext=Nr;exports.useTemplate=sa;exports.v4Fallback=St;exports.validateBuilderIntegrity=Dh;
|
|
85
|
+
`,{offset:2,encoding:a})?{ext:"reg",mime:"application/x-ms-regedit"}:void 0}if(this.checkString("-----BEGIN PGP MESSAGE-----"))return{ext:"pgp",mime:"application/pgp-encrypted"}}),$d(this,"detectImprecise",async n=>{this.buffer=new Uint8Array(Jn);const a=rS(n.fileInfo.size);if(await n.peekBuffer(this.buffer,{length:Math.min(8,a),mayBeLess:!0}),this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(this.check([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(this.check([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(this.check([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(await n.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,a),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let s=0;s<=this.options.mpegOffsetTolerance;++s){const i=this.scanMpeg(s);if(i)return i}});const r=tS(t==null?void 0:t.mpegOffsetTolerance);this.options={...t,mpegOffsetTolerance:r},this.detectors=[...this.options.customDetectors??[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:this.options.signal},this.gzipProbeDepth=0}getTokenizerOptions(){return{...this.tokenizerOptions}}createTokenizerFromWebStream(t){return B2(c2(t,this.getTokenizerOptions()))}async parseTokenizer(t,r=0){this.detectionReentryCount=r;const n=t.position;for(const a of this.detectors){let s;try{s=await a.detect(t)}catch(i){if(i instanceof Qe||i instanceof Jr)return;throw i}if(s)return s;if(n!==t.position)return}}async fromTokenizer(t){try{return await this.parseTokenizer(t)}finally{await t.close()}}async fromBuffer(t){if(!(t instanceof Uint8Array||t instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof t}\``);const r=t instanceof Uint8Array?t:new Uint8Array(t);if((r==null?void 0:r.length)>1)return this.fromTokenizer(d2(r,this.getTokenizerOptions()))}async fromBlob(t){var r;(r=this.options.signal)==null||r.throwIfAborted();const n=u2(t,this.getTokenizerOptions());return this.fromTokenizer(n)}async fromStream(t){var r;(r=this.options.signal)==null||r.throwIfAborted();const n=this.createTokenizerFromWebStream(t);return this.fromTokenizer(n)}async toDetectionStream(t,r){const n=Q2((r==null?void 0:r.sampleSize)??Jn);let a,s;const i=t.getReader({mode:"byob"});try{const{value:d,done:u}=await eS(i,new Uint8Array(n),this.options.signal);if(s=d,!u&&d)try{a=await this.fromBuffer(d.subarray(0,n))}catch(m){if(!(m instanceof Qe))throw m;a=void 0}s=d}finally{i.releaseLock()}const l=new TransformStream({async start(d){d.enqueue(s)},transform(d,u){u.enqueue(d)}}),c=t.pipeThrough(l);return c.fileType=a,c}async detectGzip(t){var r;if(this.gzipProbeDepth>=R2)return{ext:"gz",mime:"application/gzip"};const n=new k2(t),a=Y2(n.inflate(),A2),s=pt(t);let i,l,c,d;if(s){const u=new AbortController;i=setTimeout(()=>{u.abort(new DOMException(`Operation timed out after ${Fd} ms`,"TimeoutError"))},Fd),l=this.options.signal===void 0?u.signal:AbortSignal.any([this.options.signal,u.signal]),c=new Fl({...this.options,signal:l}),c.gzipProbeDepth=this.gzipProbeDepth+1}else this.gzipProbeDepth++;try{d=await(c??this).fromStream(a)}catch(u){if((u==null?void 0:u.name)==="AbortError"&&((r=l==null?void 0:l.reason)==null?void 0:r.name)!=="TimeoutError")throw u}finally{clearTimeout(i),s||this.gzipProbeDepth--}return(d==null?void 0:d.ext)==="tar"?{ext:"tar.gz",mime:"application/gzip"}:{ext:"gz",mime:"application/gzip"}}check(t,r){return sr(this.buffer,t,r)}checkString(t,r){return this.check(C2(t,r==null?void 0:r.encoding),r)}async readTiffTag(t){const r=await this.tokenizer.readToken(t?gn:We);switch(await this.tokenizer.ignore(10),r){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"}}}async readTiffIFD(t){const r=await this.tokenizer.readToken(t?gn:We);if(!(r>F2)&&!(pt(this.tokenizer)&&2+r*12>Ud))for(let n=0;n<r;++n){const a=await this.readTiffTag(t);if(a)return a}}async readTiffHeader(t){const r={ext:"tif",mime:"image/tiff"},n=(t?gn:We).get(this.buffer,2),a=(t?Td:Xe).get(this.buffer,4);if(n===42){if(a>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(a>=8){const l=(t?gn:We).get(this.buffer,8),c=(t?gn:We).get(this.buffer,10);if(l===28&&c===254||l===31&&c===11)return{ext:"nef",mime:"image/x-nikon-nef"}}}if(pt(this.tokenizer)&&a>z2)return r;const s=pt(this.tokenizer)?Ud:this.tokenizer.fileInfo.size;try{await Ir(this.tokenizer,a,{maximumLength:s,reason:"TIFF IFD offset"})}catch(l){if(l instanceof Qe)return;throw l}let i;try{i=await this.readTiffIFD(t)}catch(l){if(l instanceof Qe)return;throw l}return i??r}if(n===43)return r}scanMpeg(t){if(this.check([255,224],{offset:t,mask:[255,224]})){if(this.check([16],{offset:t+1,mask:[22]}))return this.check([8],{offset:t+1,mask:[8]})?{ext:"aac",mime:"audio/aac"}:{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:t+1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:t+1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:t+1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}}new Set($2);new Set(E2);const Gd=e=>e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`,bx=({name:e,control:t,disabled:r,campo:n,fileTypes:a,maxFileSize:s})=>{var i;const{field:l,fieldState:c}=Me({name:e,control:t}),{uploadFile:d,deleteUploadedFile:u}=Hr(),[m,p]=N.useState({status:"idle"}),f=N.useRef(null),[b,h]=N.useState(!1),x=N.useRef(!0);N.useEffect(()=>()=>{x.current=!1},[]);const y=typeof l.value=="string"&&l.value?l.value:null,v=N.useCallback(async S=>{var $;if(a&&a.length>0){const k=await J2(S),E=(k==null?void 0:k.ext)??"",D=(k==null?void 0:k.mime)??"",O=(($=S.name.split(".").pop())==null?void 0:$.toLowerCase())??"",L=S.type.toLowerCase();if(!a.some(A=>{const z=A.toLowerCase();return!!(E&&(z===E||z===D)||D&&z.endsWith("/*")&&D.startsWith(z.slice(0,-1))||!E&&(z===O||z===L||z.endsWith("/*")&&L.startsWith(z.slice(0,-1))))})){p({status:"error",message:`Tipo de arquivo não permitido. Permitidos: ${a.join(", ")}`});return}}if(s&&S.size>s){p({status:"error",message:`Arquivo muito grande. Tamanho máximo: ${Gd(s)}`});return}if(!d){p({status:"error",message:"Preview: upload não disponível sem configuração."});return}p({status:"uploading",fileName:S.name,progress:0});try{if(y&&u)try{await u(y)}catch{}const k=await d(S,n??e,E=>{x.current&&p(D=>D.status==="uploading"?{...D,progress:Math.min(100,E)}:D)});if(!x.current)return;l.onChange(k),p({status:"done",uploadId:k,fileName:S.name,size:S.size})}catch{if(!x.current)return;p({status:"error",message:"Falha no upload. Tente novamente."})}},[d,u,y,n,e,l,a,s]),j=N.useCallback(S=>{var $;const k=($=S.target.files)==null?void 0:$[0];k&&v(k),S.target.value=""},[v]),w=N.useCallback(()=>{l.onChange(""),p({status:"idle"}),f.current&&(f.current.value="")},[l]);if(m.status==="done"||m.status==="idle"&&y){const S=m.status==="done"?m.fileName:"Arquivo enviado",$=m.status==="done"?m.size:null;return o.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-green-500 bg-green-500/5 px-4 py-3 gap-2",children:[o.jsxs("svg",{className:"shrink-0 text-green-500",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[o.jsx("rect",{width:"20",height:"20",rx:"4",fill:"currentColor",fillOpacity:"0.15"}),o.jsx("path",{d:"M5 10.5L8.5 14L15 7",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),o.jsx("span",{className:"text-sm font-medium truncate flex-1",children:S}),$!==null&&o.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:Gd($)}),!r&&o.jsx("button",{type:"button",onClick:w,className:"ml-2 shrink-0 text-muted-foreground hover:text-destructive transition-colors","aria-label":"Remover arquivo",children:"✕"})]})}if(m.status==="uploading"){const{fileName:S,progress:$}=m;return o.jsxs("div",{className:"rounded-lg border border-input px-4 py-3 space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-sm font-medium truncate flex-1",children:S}),o.jsxs("span",{className:"text-xs text-muted-foreground ml-2",children:[$,"%"]})]}),o.jsx("div",{className:"h-2 rounded-full bg-muted overflow-hidden",children:o.jsx("div",{className:"h-full bg-primary transition-all duration-200 rounded-full",style:{width:`${$}%`}})})]})}const C=m.status==="error";return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{role:"button",tabIndex:r?-1:0,"aria-label":"Selecionar arquivo",className:K("flex items-center justify-center rounded-lg border-2 border-dashed px-4 py-6 transition-colors cursor-pointer",b?"border-primary bg-primary/5":C||c.error?"border-destructive bg-destructive/5":"border-input hover:border-muted-foreground hover:bg-muted/20",r&&"opacity-50 cursor-not-allowed"),onClick:()=>{var S;return!r&&((S=f.current)==null?void 0:S.click())},onKeyDown:S=>{var $;(S.key==="Enter"||S.key===" ")&&(($=f.current)==null||$.click())},onDragOver:S=>{S.preventDefault(),r||h(!0)},onDragLeave:()=>h(!1),onDrop:r?void 0:S=>{var $;S.preventDefault(),h(!1);const k=($=S.dataTransfer.files)==null?void 0:$[0];k&&v(k)},onBlur:l.onBlur,children:[o.jsx("input",{ref:f,type:"file",onChange:j,disabled:r,className:"sr-only"}),o.jsx("span",{className:"text-sm text-muted-foreground",children:b?"Solte o arquivo aqui":"Clique ou arraste um arquivo"})]}),C&&o.jsxs("p",{className:"text-sm text-destructive",children:[m.message," · ",o.jsx("button",{type:"button",className:"underline hover:no-underline",onClick:()=>p({status:"idle"}),children:"Tentar novamente"})]}),!C&&((i=c.error)==null?void 0:i.message)&&o.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})},lS={cpf:e=>e.replace(/\D/g,"").slice(0,11).replace(/(\d{3})(\d)/,"$1.$2").replace(/(\d{3})(\d)/,"$1.$2").replace(/(\d{3})(\d{1,2})$/,"$1-$2"),telefone:e=>{const t=e.replace(/\D/g,"").slice(0,11);return t.length<=10?t.replace(/(\d{2})(\d)/,"($1) $2").replace(/(\d{4})(\d)/,"$1-$2"):t.replace(/(\d{2})(\d)/,"($1) $2").replace(/(\d{5})(\d)/,"$1-$2")},cep:e=>e.replace(/\D/g,"").slice(0,8).replace(/(\d{5})(\d)/,"$1-$2")},Qr=({name:e,control:t,placeholder:r,maskType:n,disabled:a,readOnly:s})=>{var i;const{field:l,fieldState:c}=Me({name:e,control:t}),d=lS[n||""],u=N.useCallback(m=>{l.onChange(d?d(m.target.value):m.target.value)},[l,d]);return o.jsxs("div",{className:"space-y-1",children:[o.jsx(ue,{name:l.name,value:l.value||"",onChange:u,onBlur:l.onBlur,placeholder:r,disabled:a,readOnly:s,className:K(c.error&&"border-destructive focus-visible:ring-destructive")}),((i=c.error)==null?void 0:i.message)&&o.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})},zl=({name:e,control:t})=>{const{field:r}=Me({name:e,control:t});return o.jsx("input",{type:"hidden",...r,value:r.value??""})},yx=e=>e.replace(/\D/g,""),cS=e=>{const t=yx(e).slice(0,8);return t.length<=5?t:`${t.slice(0,5)}-${t.slice(5)}`},dS=async(e,t)=>{const r=await fetch(`https://viacep.com.br/ws/${e}/json/`,{signal:t});if(!r.ok)throw new Error("Falha ao consultar CEP");return r.json()},wx=({name:e,control:t,placeholder:r="00000-000",disabled:n,readOnly:a,cepFillMap:s})=>{var i,l;const{field:c,fieldState:d}=Me({name:e,control:t}),{setValue:u}=lN(),{cepLookup:m}=Hr(),[p,f]=N.useState("idle"),[b,h]=N.useState(null),x=N.useRef(null),y=N.useRef(!0);N.useEffect(()=>()=>{var w;y.current=!1,(w=x.current)==null||w.abort()},[]);const v=N.useCallback(async()=>{var w;c.onBlur();const C=yx(c.value??"");if(C.length===8){(w=x.current)==null||w.abort(),x.current=new AbortController,f("loading"),h(null);try{let S;if(m){const E=x.current;if(S=await m(C,E.signal),E.signal.aborted||!y.current)return}else{const E=await dS(C,x.current.signal);if(!y.current)return;if(E.erro){f("error"),h("CEP não encontrado");return}S={logradouro:E.logradouro,bairro:E.bairro,cidade:E.localidade,estado:E.uf}}if(!y.current)return;if(S.erro){f("error"),h("CEP não encontrado");return}const $=e.includes(".")?`${e.substring(0,e.lastIndexOf("."))}.`:"",k=(E,D,O)=>{if(!O)return;const L=s!=null&&s[E]?`${$}${s[E]}`:`${$}${D}`;u(L,O,{shouldDirty:!0,shouldValidate:!0})};k("logradouro","_address_logradouro",S.logradouro),k("bairro","_address_bairro",S.bairro),k("cidade","_address_cidade",S.cidade),k("estado","_address_estado",S.estado),f("success")}catch(S){if(S instanceof Error&&S.name==="AbortError"||!y.current)return;f("error"),h("Erro ao buscar CEP")}}},[c,m,u,e,s]),j=N.useCallback(w=>{c.onChange(cS(w.target.value))},[c]);return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"relative",children:[o.jsx(ue,{name:c.name,value:c.value||"",onChange:j,onBlur:v,placeholder:r,disabled:n,readOnly:a,className:K("pr-9",d.error&&"border-destructive focus-visible:ring-destructive")}),o.jsxs("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none",children:[p==="loading"&&o.jsx(_.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"}),p==="success"&&o.jsx(_.Check,{className:"h-4 w-4 text-green-500"}),p==="error"&&o.jsx(_.AlertCircle,{className:"h-4 w-4 text-destructive"})]})]}),(((i=d.error)==null?void 0:i.message)||b)&&o.jsx("p",{className:"text-sm text-destructive",children:((l=d.error)==null?void 0:l.message)||b})]})},uS=({field:e,control:t,nameOverride:r})=>{const n={name:r,control:t,placeholder:e.placeholder};switch(e.tipo){case T.TEXTO:return o.jsx(Mt,{...n,type:"text"});case T.EMAIL:return o.jsx(Mt,{...n,type:"email"});case T.NUMBER:return o.jsx(Mt,{...n,type:"number"});case T.TEXTAREA:return o.jsx(Al,{...n});case T.SELECT:return o.jsx(Rl,{...n,options:e.opcoes??[]});case T.RADIO:return o.jsx(px,{...n,options:e.opcoes??[]});case T.CHECKBOX:return o.jsx(Il,{name:r,control:t,label:e.label});case T.CHECKBOX_GROUP:return o.jsx(mx,{...n,options:e.opcoes??[]});case T.DATE:return o.jsx(aa,{...n,validacao:e.validacao});case T.DATETIME:return o.jsx(aa,{...n,isDatetime:!0,validacao:e.validacao});case T.FILE:return o.jsx(bx,{name:r,control:t});case T.TELEFONE:return o.jsx(Qr,{...n,maskType:"telefone"});case T.CPF:return o.jsx(Qr,{...n,maskType:"cpf"});case T.CEP:return o.jsx(wx,{name:r,control:t,placeholder:e.placeholder});case T.HIDDEN:return o.jsx(zl,{name:r,control:t});default:return console.error(`[DFFieldArray] Tipo de sub-campo "${e.tipo}" não suportado em FIELD_ARRAY. Usando DFTextField como fallback.`),o.jsx(Mt,{...n,type:"text"})}},mS=({name:e,control:t,subFields:r=[],minItems:n=1,maxItems:a,itemLabel:s="Item",addLabel:i})=>{var l;const{fields:c,append:d,remove:u}=dx({control:t,name:e}),{errors:m}=rx({control:t}),p=(l=m[e])==null?void 0:l.message,f=N.useCallback(()=>{const y={};for(const v of r)v.initialValue!==void 0?y[v.nome]=v.initialValue:v.defaultValue!==void 0&&(y[v.nome]=v.defaultValue);return y},[r]);N.useEffect(()=>{if(c.length<n)for(let y=c.length;y<n;y++)d(f())},[n]);const b=[...r].sort((y,v)=>y.ordem-v.ordem),h=!a||c.length<a,x=i??`Adicionar ${s.toLowerCase()}`;return o.jsxs("div",{className:"space-y-3",children:[c.map((y,v)=>o.jsxs("div",{className:"rounded-lg border border-input p-4",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-primary/10 text-xs font-bold text-primary shrink-0",children:v+1}),o.jsxs("span",{className:"text-sm font-semibold",children:[s," ",v+1]})]}),c.length>n&&o.jsx(De,{type:"button",variant:"ghost",size:"icon",onClick:()=>u(v),"aria-label":`Remover ${s.toLowerCase()} ${v+1}`,className:"text-muted-foreground hover:text-destructive",children:o.jsx(_.Trash2,{className:"w-4 h-4"})})]}),o.jsx("div",{className:"grid grid-cols-12 gap-4",children:b.map(j=>{const w=`${e}.${v}.${j.nome}`,C=`span ${j.tamanho??12}`,S=o.jsx(uS,{field:j,control:t,nameOverride:w});return j.tipo===T.CHECKBOX||j.tipo===T.HIDDEN?o.jsx("div",{className:"max-sm:!col-span-12",style:{gridColumn:C},children:S},j.id):o.jsxs("div",{className:"max-sm:!col-span-12 space-y-2",style:{gridColumn:C},children:[o.jsxs("label",{className:"font-medium flex items-center gap-1 text-sm text-foreground",children:[j.label,j.obrigatorio&&o.jsx("span",{className:"text-destructive",children:"*"})]}),S,j.hint&&o.jsx("p",{className:"text-xs text-muted-foreground",children:j.hint})]},j.id)})})]},y.id)),h&&o.jsxs(De,{type:"button",variant:"outline",className:"w-full",onClick:()=>d(f()),children:[o.jsx(_.Plus,{className:"w-4 h-4"}),x]}),a&&o.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:["Máximo de ",a," ",s.toLowerCase(),a>1?"s":""]}),p&&o.jsxs("p",{className:"text-sm text-destructive flex items-center gap-1",children:[o.jsx(_.AlertCircle,{className:"w-4 h-4 shrink-0"}),p]})]})},Xd=e=>`R$ ${(e/100).toFixed(2).replace(".",",")}`,pS=(e,t)=>{const r=new Date(e.slice(0,10)+"T00:00:00Z"),n=new Date(t.slice(0,10)+"T00:00:00Z");return Math.round((n.getTime()-r.getTime())/864e5)+1},fS=(e,t)=>{const r=[],n=new Date(e.slice(0,10)+"T00:00:00Z"),a=new Date(t.slice(0,10)+"T00:00:00Z");let s=0;for(;n<=a&&s<60;)r.push(n.toISOString().slice(0,10)),n.setUTCDate(n.getUTCDate()+1),s++;return r},hS=e=>{const[t,r,n]=e.split("-").map(Number),a=new Date(Date.UTC(t,r-1,n)),s=String(n).padStart(2,"0"),i=String(r).padStart(2,"0"),l=new Intl.DateTimeFormat("pt-BR",{weekday:"long",timeZone:"UTC"}).format(a),c=l.charAt(0).toUpperCase()+l.slice(1);return`${s}/${i} - ${c}`},xS=(e,t)=>{const r=n=>{const[a,s,i]=n.slice(0,10).split("-");return`${i}/${s}/${a}`};return`${r(e)} a ${r(t)}`},gS=({name:e,control:t})=>{var r;const{field:n,fieldState:a}=Me({name:e,control:t}),{externalData:s={}}=Hr(),i=n.value??null,l=(r=a.error)==null?void 0:r.message,c=V=>s[`evento.${V}`]??s[V],d=c("dataInicioEvento")??"",u=c("dataFimEvento")??"",m=Number(c("valor")??0),p=Number(c("valorPorDia")??0),f=c("vagasTotal"),b=c("vagasPorDia"),h=c("vagasMasculinas"),x=c("vagasFemininas"),y=f!=null?Number(f):null,v=b!=null?Number(b):null,j=h!=null?Number(h):null,w=x!=null?Number(x):null,C=d&&u?fS(d,u):[],S=(d&&u?pS(d,u):0)>1,$=j!=null&&j>0&&w!=null&&w>0,k=j!=null&&w==null?"masculino":w!=null&&j==null?"feminino":null,E=(i==null?void 0:i.tipo)??null,D=(i==null?void 0:i.data)??null,O=(i==null?void 0:i.genero)??null,L=N.useRef(i);L.current=i;const A=N.useRef(n.onChange);A.current=n.onChange,N.useEffect(()=>{var V,M,P;k&&((V=L.current)==null?void 0:V.genero)!==k&&A.current({tipo:((M=L.current)==null?void 0:M.tipo)??null,data:((P=L.current)==null?void 0:P.data)??null,genero:k})},[k]);const z=V=>{const M={tipo:V,data:null};($||k)&&(M.genero=O??k??void 0),n.onChange(M)},X=V=>{const M={tipo:"por_dia",data:V};($||k)&&(M.genero=O??k??void 0),n.onChange(M)},q=V=>{n.onChange({tipo:E,data:D,genero:V})},Z=V=>E===V;return o.jsxs("div",{className:"space-y-3",children:[$&&o.jsxs("div",{className:"flex items-center gap-2 px-1",children:[o.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:"Você é:"}),o.jsx("div",{className:"flex gap-2",children:["masculino","feminino"].map(V=>o.jsx("button",{type:"button",onClick:()=>q(V),className:K("px-3 py-1 rounded-full text-xs font-medium border transition-all",O===V?"border-primary bg-primary/10 text-primary":"border-input text-muted-foreground hover:border-primary/50"),children:V==="masculino"?"Masculino":"Feminino"},V))})]}),o.jsxs("button",{type:"button",onClick:()=>z("todos_os_dias"),className:K("w-full text-left flex items-start gap-3 p-4 rounded-xl border-2 transition-all",Z("todos_os_dias")?"border-primary bg-primary/5":"border-input hover:border-primary/50"),children:[o.jsx("div",{className:K("mt-0.5 p-2 rounded-lg shrink-0 transition-colors",Z("todos_os_dias")?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:o.jsx(_.CalendarCheck2,{className:"w-4 h-4"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"font-semibold text-sm",children:"Participar todos os dias"}),d&&u?o.jsx("p",{className:"text-xs text-muted-foreground",children:xS(d,u)}):o.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Datas do evento"})]}),o.jsxs("div",{className:"text-right shrink-0",children:[m>0&&o.jsx("p",{className:K("font-bold text-sm",Z("todos_os_dias")?"text-primary":"text-foreground"),children:Xd(m)}),y!=null&&y>0&&o.jsxs("p",{className:"text-xs flex items-center justify-end gap-1 text-muted-foreground",children:[o.jsx(_.Users,{className:"w-3 h-3"}),y," vagas disponíveis"]})]})]}),S?o.jsxs("button",{type:"button",onClick:()=>z("por_dia"),className:K("w-full text-left flex items-start gap-3 p-4 rounded-xl border-2 transition-all",Z("por_dia")?"border-primary bg-primary/5":"border-input hover:border-primary/50"),children:[o.jsx("div",{className:K("mt-0.5 p-2 rounded-lg shrink-0 transition-colors",Z("por_dia")?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:o.jsx(_.CalendarDays,{className:"w-4 h-4"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"font-semibold text-sm",children:"Participar um dia"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Escolha o dia desejado abaixo"})]}),o.jsxs("div",{className:"text-right shrink-0",children:[p>0&&o.jsx("p",{className:K("font-bold text-sm",Z("por_dia")?"text-primary":"text-foreground"),children:Xd(p)}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"por dia"})]})]}):d?o.jsxs("div",{className:"flex items-start gap-2 px-3 py-2.5 rounded-lg border border-input bg-muted/30",children:[o.jsx(_.Info,{className:"w-3.5 h-3.5 mt-0.5 shrink-0 text-muted-foreground"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:'Este evento ocorre em apenas 1 dia — a opção "Participar um dia" não é necessária.'})]}):null,E==="por_dia"&&o.jsxs("div",{className:"pl-2 space-y-2",children:[o.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-primary",children:"Selecione o dia:"}),C.length===0?o.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Nenhuma data configurada no evento"}):C.map(V=>o.jsxs("button",{type:"button",onClick:()=>X(V),className:K("w-full text-left flex items-center justify-between px-4 py-3 rounded-lg border transition-all",D===V?"border-primary bg-primary/5":"border-input hover:border-primary/50"),children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("span",{className:K("w-4 h-4 rounded-full border-2 shrink-0 flex items-center justify-center transition-colors",D===V?"border-primary bg-primary":"border-input"),children:D===V&&o.jsx("span",{className:"w-2 h-2 rounded-full bg-white"})}),o.jsx("span",{className:"text-sm",children:hS(V)})]}),v!=null&&o.jsxs("span",{className:"text-xs text-muted-foreground",children:[v," vagas"]})]},V))]}),l&&o.jsx("p",{className:"text-sm text-destructive",children:l})]})},Zd=.0315,Kd=.124,Yd=7,Jd=12,vS=[{id:"pix",label:"PIX",description:"Transferência instantânea (à vista)",Icon:_.Smartphone,taxa:0},{id:"dinheiro",label:"Dinheiro",description:"Pagamento em espécie",Icon:_.Banknote,taxa:0},{id:"cartao",label:"Cartão de Crédito",description:"Débito ou crédito na maquininha",Icon:_.CreditCard,taxa:Zd,taxaLabel:`Taxa: ${(Zd*100).toFixed(2).replace(".",",")}%`}],bS=[{id:"pix",label:"PIX à Vista",description:"Pagamento instantâneo sem parcelamento",Icon:_.Smartphone,taxa:0},{id:"pix_parcelado",label:"PIX Parcelado",description:`Parcelado em até ${Yd}x sem juros`,Icon:_.Smartphone,taxa:0,parcelas:Yd},{id:"cartao",label:"Cartão de Crédito",description:`Parcelado em até ${Jd}x`,Icon:_.CreditCard,taxa:Kd,parcelas:Jd,taxaLabel:`Taxa: ${(Kd*100).toFixed(2).replace(".",",")}%`},{id:"dinheiro",label:"Dinheiro",description:"Pagamento em espécie",Icon:_.Banknote,taxa:0}],Fa=e=>`R$ ${(e/100).toFixed(2).replace(".",",")}`,Qd=(e,t)=>Math.round(e*(1+t)*100)/100,yS=(e,t)=>Math.round(e/t*100)/100,wS=({name:e,control:t,relatedFieldName:r="tipo_participacao"})=>{var n;const{field:a,fieldState:s}=Me({name:e,control:t}),{externalData:i={},paymentMethodOptions:l}=Hr(),c=a.value??null,d=(n=s.error)==null?void 0:n.message,u=Mn({control:t,name:r}),m=(u==null?void 0:u.tipo)??null,p=j=>i[`evento.${j}`]??i[j],f=Number(p("valor")??0),b=Number(p("valorPorDia")??0),h=m==="por_dia"&&b>0?b:f,x=m==="por_dia"?(l==null?void 0:l.porDia)??vS:(l==null?void 0:l.todosOsDias)??bS,y=m==="por_dia"?(()=>{if(!(u!=null&&u.data))return"Um dia";const j=u.data.split("-");if(j.length===3){const[w,C,S]=j;return`${S}/${C}/${w}`}return u.data})():"Todos os dias",v=j=>{if(j.disabled)return;const w=Qd(h,j.taxa),C={metodo:j.id,valorTotal:w};j.parcelas&&(C.parcelas=j.parcelas),a.onChange(C)};return o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-input px-4 py-3",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:"Tipo de participação"}),o.jsx("p",{className:"font-semibold",children:y})]}),o.jsxs("div",{className:"text-right",children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:"Valor base"}),o.jsx("p",{className:"text-lg font-bold text-primary",children:Fa(h)})]})]}),o.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-input bg-muted/30 px-3 py-2.5",children:[o.jsx(_.Info,{className:"h-4 w-4 mt-0.5 shrink-0 text-muted-foreground"}),o.jsxs("p",{className:"text-xs",children:[o.jsx("span",{className:"font-bold",children:"Importante:"})," Para validar a inscrição e garantir sua vaga, o pagamento deve ser realizado no ato da inscrição."]})]}),o.jsx("p",{className:"text-sm font-semibold text-primary",children:"Selecione a forma de pagamento:"}),o.jsx("div",{className:"space-y-3",children:x.map(j=>{const{Icon:w}=j,C=(c==null?void 0:c.metodo)===j.id,S=Qd(h,j.taxa),$=!!j.parcelas&&j.parcelas>1,k=$?yS(S,j.parcelas):null;return o.jsxs("button",{type:"button",disabled:j.disabled,onClick:()=>v(j),className:K("w-full text-left flex items-center gap-4 px-4 py-3 rounded-xl border-2 transition-all",C?"border-primary bg-primary/5":"border-input hover:border-primary/50",j.disabled&&"opacity-50 cursor-not-allowed"),children:[o.jsx("div",{className:K("flex items-center justify-center w-10 h-10 rounded-lg shrink-0 transition-colors",C?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:o.jsx(w,{className:"h-5 w-5"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"font-semibold text-sm leading-tight",children:j.label}),o.jsx("p",{className:"text-xs text-muted-foreground",children:j.description}),j.taxaLabel&&o.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["* ",j.taxaLabel]}),j.taxa>0&&o.jsxs("p",{className:"text-xs text-muted-foreground",children:["Total com taxa: ",Fa(S)]})]}),o.jsx("div",{className:"text-right shrink-0",children:$?o.jsxs(o.Fragment,{children:[o.jsxs("p",{className:"text-xs text-muted-foreground",children:[j.parcelas,"x de"]}),o.jsx("p",{className:"text-base font-bold text-primary",children:Fa(k)})]}):o.jsx("p",{className:"text-base font-bold text-primary",children:Fa(S)})})]},j.id)})}),d&&o.jsx("p",{className:"text-xs text-destructive",children:d})]})},jS=({name:e,control:t,label:r,termoTexto:n,termoPdfUrl:a,termoPdfUploadId:s})=>{var i;const{field:l,fieldState:c}=Me({name:e,control:t}),{resolveTermsUploadUrl:d}=Hr(),u=!!c.error,m=(i=c.error)==null?void 0:i.message,[p,f]=N.useState(null),[b,h]=N.useState(!1),[x,y]=N.useState(!1),v=N.useRef(null);N.useEffect(()=>{var $;x&&(($=v.current)==null||$.focus())},[x]),N.useEffect(()=>{if(!s||!d){f(null);return}let $=!1;return h(!0),d(s).then(k=>{$||f(k)}).catch(()=>{$||f(null)}).finally(()=>{$||h(!1)}),()=>{$=!0}},[s,d]);const j=l.value==="accepted",w=p||a||null,C=!!(n||w||s),S=!!w;return o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:K("rounded-lg border p-4 space-y-4 transition-colors",u?"border-destructive bg-destructive/5":j?"border-green-500 bg-green-500/5":"border-input"),children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(_.ScrollText,{className:"h-4 w-4 shrink-0"}),o.jsx("span",{className:"text-sm font-medium",children:r||"Termos e condições"})]}),C?o.jsxs(De,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2 text-xs",disabled:b,onClick:()=>y(!0),children:[b?o.jsx(_.Loader2,{className:"h-3 w-3 animate-spin"}):o.jsx(_.ExternalLink,{className:"h-3 w-3"}),"Ler termos"]}):o.jsx("span",{className:"text-xs text-muted-foreground italic",children:s&&b?"Carregando PDF...":"Conteúdo não configurado"})]}),o.jsxs("label",{className:"flex items-start gap-3 cursor-pointer select-none",children:[o.jsx(et,{className:"mt-0.5",checked:j,onCheckedChange:$=>l.onChange($?"accepted":"")}),o.jsxs("span",{className:"text-sm leading-snug flex-1",children:["Li e aceito ",r?`"${r}"`:"os termos e condições"]}),j&&o.jsx(_.CheckCircle2,{className:"h-4 w-4 text-green-500 shrink-0 mt-0.5"})]})]}),u&&o.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-destructive",children:[o.jsx(_.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),m||"Você precisa aceitar os termos para continuar"]}),x&&o.jsx("div",{ref:v,role:"dialog","aria-modal":"true","aria-label":"Termos e condições",tabIndex:-1,className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 outline-none",onClick:()=>y(!1),onKeyDown:$=>{$.key==="Escape"&&y(!1)},children:o.jsxs("div",{className:"relative w-full max-w-2xl max-h-[90vh] rounded-xl overflow-hidden flex flex-col bg-background shadow-xl",onClick:$=>$.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-input",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(_.ScrollText,{className:"h-4 w-4"}),o.jsx("span",{className:"font-semibold",children:"Termos e condições"})]}),o.jsx(De,{type:"button",variant:"ghost",size:"icon",onClick:()=>y(!1),children:o.jsx(_.X,{className:"h-4 w-4"})})]}),o.jsx("div",{className:"flex-1 overflow-auto p-4",children:S?o.jsx("iframe",{src:w,className:"w-full rounded border",style:{height:"62vh"},title:"Termos e condições",sandbox:"allow-scripts"}):o.jsx("p",{className:"text-sm whitespace-pre-wrap leading-relaxed",children:n})})]})})]})},kS=({name:e,control:t,placeholder:r,disabled:n,readOnly:a})=>{var s;const{field:i,fieldState:l}=Me({name:e,control:t}),[c,d]=N.useState(!1),u=!!l.error;return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"relative",children:[o.jsx(ue,{...i,value:i.value??"",type:c?"text":"password",placeholder:r,disabled:n,readOnly:a,className:K("pr-10",u&&"border-destructive focus-visible:ring-destructive")}),o.jsx("button",{type:"button",tabIndex:-1,onClick:()=>d(m=>!m),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors","aria-label":c?"Ocultar senha":"Mostrar senha",children:c?o.jsx(_.EyeOff,{size:16}):o.jsx(_.Eye,{size:16})})]}),((s=l.error)==null?void 0:s.message)&&o.jsx("p",{className:"text-sm text-destructive",children:l.error.message})]})},jx=({name:e,control:t,label:r,disabled:n,readOnly:a})=>{var s;const{field:i,fieldState:l}=Me({name:e,control:t}),c=!!i.value;return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("label",{className:"flex items-center gap-3 cursor-pointer select-none",children:[o.jsx(Oi,{checked:c,onCheckedChange:d=>!a&&i.onChange(d),disabled:n||a,onBlur:i.onBlur}),o.jsx("span",{className:"text-sm leading-none",children:r})]}),((s=l.error)==null?void 0:s.message)&&o.jsx("p",{className:"text-sm text-destructive",children:l.error.message})]})},CS=({name:e,control:t,minValue:r=0,maxValue:n=100,step:a=1,disabled:s,readOnly:i})=>{var l;const{field:c,fieldState:d}=Me({name:e,control:t}),u=c.value??r;return N.useEffect(()=>{(c.value===void 0||c.value===null)&&c.onChange(r)},[]),o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(Ao,{min:r,max:n,step:a,value:[u],onValueChange:m=>!i&&c.onChange(m[0]),disabled:s||i,className:"flex-1"}),o.jsx("span",{className:"text-sm font-medium text-primary min-w-[3rem] text-right tabular-nums",children:u})]}),o.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[o.jsx("span",{children:r}),o.jsx("span",{children:n})]}),((l=d.error)==null?void 0:l.message)&&o.jsx("p",{className:"text-sm text-destructive",children:d.error.message})]})},Ms=e=>/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(e),NS=({name:e,control:t,disabled:r,readOnly:n})=>{var a;const{field:s,fieldState:i}=Me({name:e,control:t}),l=s.value||"#000000",[c,d]=N.useState(l);return N.useEffect(()=>{d(l)},[l]),o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("input",{type:"color",value:Ms(l)?l:"#000000",disabled:r||n,onChange:u=>s.onChange(u.target.value),className:"h-10 w-14 cursor-pointer rounded-lg border border-input bg-transparent p-1 disabled:cursor-not-allowed disabled:opacity-50"}),o.jsx(ue,{type:"text",value:c,readOnly:n,disabled:r,onChange:u=>{const m=u.target.value;d(m),Ms(m)&&s.onChange(m.toUpperCase())},onBlur:()=>{Ms(c)||d(l),s.onBlur()},className:K("flex-1 font-mono uppercase",i.error&&"border-destructive focus-visible:ring-destructive"),maxLength:7,placeholder:"#000000"})]}),((a=i.error)==null?void 0:a.message)&&o.jsx("p",{className:"text-sm text-destructive",children:i.error.message})]})},SS=({name:e,control:t,options:r,placeholder:n,disabled:a,readOnly:s})=>{var i,l;const{field:c,fieldState:d}=Me({name:e,control:t}),[u,m]=N.useState(""),[p,f]=N.useState(!1),[b,h]=N.useState(-1),x=N.useRef(null),y=N.useRef(null),v=`autocomplete-${e}-listbox`,j=((i=r.find(D=>D.valor===c.value))==null?void 0:i.label)??"",w=u.length>0?r.filter(D=>D.label.toLowerCase().includes(u.toLowerCase())):r;N.useEffect(()=>{const D=O=>{x.current&&!x.current.contains(O.target)&&(f(!1),m(""),h(-1))};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[]);const C=()=>{f(!1),m(""),h(-1)};N.useEffect(()=>{if(b<0||!y.current)return;const D=y.current.querySelector(`[id="${v}-option-${b}"]`);D==null||D.scrollIntoView({block:"nearest"})},[b,v]);const S=D=>{D.disabled||(c.onChange(D.valor),C())},$=()=>{c.onChange(""),m(""),h(-1)},k=D=>{if(!p){(D.key==="ArrowDown"||D.key==="ArrowUp")&&(D.preventDefault(),f(!0),h(0));return}switch(D.key){case"ArrowDown":D.preventDefault(),h(O=>O<w.length-1?O+1:O);break;case"ArrowUp":D.preventDefault(),h(O=>O>0?O-1:0);break;case"Enter":D.preventDefault(),b>=0&&w[b]&&!w[b].disabled&&S(w[b]);break;case"Escape":D.preventDefault(),C();break;case"Tab":C();break}},E=p&&b>=0?`${v}-option-${b}`:void 0;return o.jsxs("div",{className:"space-y-1",ref:x,children:[o.jsxs("div",{className:"relative",children:[o.jsx(ue,{type:"text",role:"combobox","aria-expanded":p,"aria-haspopup":"listbox","aria-autocomplete":"list","aria-controls":v,"aria-activedescendant":E,value:p?u:j,placeholder:n??"Buscar...",disabled:a,readOnly:s,onChange:D=>{m(D.target.value),h(-1),f(!0)},onFocus:()=>!s&&f(!0),onKeyDown:k,className:K("pr-8",d.error&&"border-destructive focus-visible:ring-destructive"),autoComplete:"off"}),o.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1",children:c.value?o.jsx("button",{type:"button",onClick:$,className:"text-[var(--t-text-muted)] hover:text-[var(--t-text)]",tabIndex:-1,"aria-label":"Limpar seleção",children:o.jsx(_.X,{size:14})}):o.jsx(_.ChevronDown,{size:16,className:"text-muted-foreground pointer-events-none","aria-hidden":"true"})}),p&&!a&&!s&&o.jsx("ul",{role:"listbox",id:v,ref:y,"aria-label":"Opções disponíveis",className:"absolute z-50 mt-1 max-h-60 w-full overflow-auto rounded-lg border border-input bg-popover shadow-lg",children:w.length===0?o.jsx("li",{role:"option","aria-selected":!1,className:"px-3 py-2 text-sm text-muted-foreground",children:"Nenhuma opção encontrada"}):w.map((D,O)=>o.jsx("li",{id:`${v}-option-${O}`,role:"option","aria-selected":c.value===D.valor,"aria-disabled":D.disabled,onMouseDown:()=>S(D),className:["flex cursor-pointer items-center px-3 py-2 text-sm",D.disabled?"cursor-not-allowed opacity-40":O===b?"bg-accent":"hover:bg-accent",c.value===D.valor?"font-medium text-primary":"text-foreground"].join(" "),children:D.label},D.valor))})]}),((l=d.error)==null?void 0:l.message)&&o.jsx("p",{className:"text-sm text-destructive",role:"alert",children:d.error.message})]})},kx=({name:e,control:t,placeholder:r,disabled:n,readOnly:a})=>{var s;const{field:i,fieldState:l}=Me({name:e,control:t}),c=!!l.error;return o.jsxs("div",{className:"space-y-1",children:[o.jsx(ue,{...i,value:i.value??"",type:"time",placeholder:r,disabled:n,readOnly:a,className:K(c&&"border-destructive focus-visible:ring-destructive")}),((s=l.error)==null?void 0:s.message)&&o.jsx("p",{className:"text-sm text-destructive",children:l.error.message})]})},$S=({name:e,control:t,startLabel:r="Data inicial",endLabel:n="Data final",disabled:a,readOnly:s})=>{var i;const{field:l,fieldState:c}=Me({name:e,control:t}),d=l.value??{},u=(p,f)=>{l.onChange({...d,[p]:f})},m=!!c.error;return o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{children:r}),o.jsx(ue,{type:"date",value:d.start??"",disabled:a,readOnly:s,onChange:p=>u("start",p.target.value),max:d.end??void 0,className:K(m&&"border-destructive focus-visible:ring-destructive")})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(ie,{children:n}),o.jsx(ue,{type:"date",value:d.end??"",disabled:a,readOnly:s,onChange:p=>u("end",p.target.value),min:d.start??void 0,className:K(m&&"border-destructive focus-visible:ring-destructive")})]})]}),((i=c.error)==null?void 0:i.message)&&o.jsx("p",{className:"text-sm text-destructive",children:c.error.message})]})},ES=({name:e,control:t,maxRating:r=5,disabled:n,readOnly:a})=>{var s;const{field:i,fieldState:l}=Me({name:e,control:t}),c=i.value??0,d=Array.from({length:r},(u,m)=>m+1);return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-1",children:[d.map(u=>o.jsx("button",{type:"button",disabled:n||a,onClick:()=>i.onChange(u===c?0:u),className:"transition-transform hover:scale-110 disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded","aria-label":`${u} estrela${u>1?"s":""}`,children:o.jsx(_.Star,{size:24,className:"transition-colors",fill:u<=c?"var(--color-primary)":"transparent",stroke:u<=c?"var(--color-primary)":"currentColor"})},u)),c>0&&o.jsxs("span",{className:"ml-2 text-sm text-muted-foreground",children:[c,"/",r]})]}),((s=l.error)==null?void 0:s.message)&&o.jsx("p",{className:"text-sm text-destructive",children:l.error.message})]})},DS=({field:e,name:t,control:r,disabled:n,readOnly:a})=>{const s=n||e.isDisabled,i=a||e.isReadOnly;switch(e.tipo){case T.EMAIL:return o.jsx(Mt,{name:t,control:r,type:"email",placeholder:e.placeholder,disabled:s,readOnly:i});case T.NUMBER:return o.jsx(Mt,{name:t,control:r,type:"number",placeholder:e.placeholder,disabled:s,readOnly:i});case T.PASSWORD:return o.jsx(Mt,{name:t,control:r,type:"password",placeholder:e.placeholder,disabled:s,readOnly:i});case T.TELEFONE:return o.jsx(Qr,{name:t,control:r,maskType:"telefone",placeholder:e.placeholder??"(00) 00000-0000",disabled:s,readOnly:i});case T.CPF:return o.jsx(Qr,{name:t,control:r,maskType:"cpf",placeholder:e.placeholder??"000.000.000-00",disabled:s,readOnly:i});case T.CEP:return o.jsx(Qr,{name:t,control:r,maskType:"cep",placeholder:e.placeholder??"00000-000",disabled:s,readOnly:i});case T.TEXTAREA:return o.jsx(Al,{name:t,control:r,placeholder:e.placeholder,disabled:s,readOnly:i});case T.SELECT:return o.jsx(Rl,{name:t,control:r,options:e.opcoes??[],placeholder:e.placeholder,disabled:s,readOnly:i});case T.CHECKBOX:return o.jsx(Il,{name:t,control:r,label:e.label??"",disabled:s,readOnly:i});case T.SWITCH:return o.jsx(jx,{name:t,control:r,label:e.label??"",disabled:s,readOnly:i});case T.DATE:return o.jsx(aa,{name:t,control:r,disabled:s,readOnly:i});case T.TIME:return o.jsx(kx,{name:t,control:r,disabled:s,readOnly:i});case T.HIDDEN:return o.jsx(zl,{name:t,control:r});default:return o.jsx(Mt,{name:t,control:r,type:"text",placeholder:e.placeholder,disabled:s,readOnly:i})}},TS=({name:e,control:t,subSchema:r,disabled:n,readOnly:a})=>{if(!r||r.fields.length===0)return null;const s=[...r.fields].sort((i,l)=>i.ordem-l.ordem);return o.jsxs("div",{className:"rounded-xl border border-input bg-muted/30 p-4 space-y-4",children:[r.titulo&&o.jsx("h4",{className:"text-sm font-semibold text-muted-foreground",children:r.titulo}),o.jsx("div",{className:"grid grid-cols-12 gap-4",children:s.map(i=>{const l=`${e}.${i.nome}`,c=i.tipo===T.CHECKBOX||i.tipo===T.SWITCH||i.tipo===T.HIDDEN,d=i.tamanho??6;return o.jsxs("div",{className:`col-span-${d}`,children:[!c&&o.jsxs("label",{className:"mb-1 block text-sm font-medium text-foreground",children:[i.label,i.obrigatorio&&o.jsx("span",{className:"text-destructive",children:" *"})]}),o.jsx(DS,{field:i,name:l,control:t,disabled:n,readOnly:a})]},i.id)})})]})},Cx=({field:e,control:t,nameOverride:r})=>{var n,a;const s=r??e.nome,{componentMapper:i}=Hr(),l=i==null?void 0:i[e.tipo];if(l)return o.jsx(l,{name:s,control:t,field:e});const c={name:s,control:t,placeholder:e.placeholder,disabled:e.isDisabled,readOnly:e.isReadOnly};switch(e.tipo){case T.TEXTO:return o.jsx(Mt,{...c,type:"text"});case T.EMAIL:return o.jsx(Mt,{...c,type:"email"});case T.NUMBER:return o.jsx(Mt,{...c,type:"number"});case T.PASSWORD:return o.jsx(kS,{...c});case T.TEXTAREA:return o.jsx(Al,{...c});case T.SELECT:return o.jsx(Rl,{...c,options:e.opcoes??[]});case T.AUTOCOMPLETE:return o.jsx(SS,{...c,options:e.opcoes??[]});case T.SWITCH:return o.jsx(jx,{name:s,control:t,label:e.label,disabled:e.isDisabled,readOnly:e.isReadOnly});case T.SLIDER:return o.jsx(CS,{name:s,control:t,minValue:e.minValue,maxValue:e.maxValue,step:e.step,disabled:e.isDisabled,readOnly:e.isReadOnly});case T.RATING:return o.jsx(ES,{name:s,control:t,maxRating:e.maxRating,disabled:e.isDisabled,readOnly:e.isReadOnly});case T.COLOR:return o.jsx(NS,{name:s,control:t,disabled:e.isDisabled,readOnly:e.isReadOnly});case T.TIME:return o.jsx(kx,{...c});case T.DATE_RANGE:return o.jsx($S,{name:s,control:t,startLabel:e.dateRangeStartLabel,endLabel:e.dateRangeEndLabel,disabled:e.isDisabled,readOnly:e.isReadOnly});case T.RADIO:return o.jsx(px,{...c,options:e.opcoes??[]});case T.CHECKBOX:return o.jsx(Il,{name:s,control:t,label:e.label,disabled:e.isDisabled,readOnly:e.isReadOnly});case T.CHECKBOX_GROUP:return o.jsx(mx,{...c,options:e.opcoes??[]});case T.DATE:return o.jsx(aa,{name:s,control:t,disabled:e.isDisabled,readOnly:e.isReadOnly,validacao:e.validacao});case T.DATETIME:return o.jsx(aa,{name:s,control:t,isDatetime:!0,disabled:e.isDisabled,readOnly:e.isReadOnly,validacao:e.validacao});case T.FILE:return o.jsx(bx,{name:s,control:t,disabled:e.isDisabled,fileTypes:(n=e.validacao)==null?void 0:n.fileTypes,maxFileSize:(a=e.validacao)==null?void 0:a.maxFileSize});case T.TELEFONE:return o.jsx(Qr,{...c,maskType:"telefone"});case T.CPF:return o.jsx(Qr,{...c,maskType:"cpf"});case T.CEP:return o.jsx(wx,{name:s,control:t,placeholder:e.placeholder,disabled:e.isDisabled,readOnly:e.isReadOnly,cepFillMap:e.cepFillMap});case T.HIDDEN:return o.jsx(zl,{name:s,control:t});case T.PARTICIPATION_TYPE:return o.jsx(gS,{name:s,control:t});case T.PAYMENT_METHOD:return o.jsx(wS,{name:s,control:t,relatedFieldName:e.relatedFieldName});case T.TERMS:return o.jsx(jS,{name:s,control:t,label:e.label,termoTexto:e.termoTexto,termoPdfUrl:e.termoPdfUrl,termoPdfUploadId:e.termoPdfUploadId});case T.FIELD_ARRAY:return o.jsx(mS,{name:s,control:t,subFields:e.subFields,minItems:e.minItems,maxItems:e.maxItems,itemLabel:e.itemLabel,addLabel:e.addLabel});case T.SUB_FORM:return o.jsx(TS,{name:s,control:t,subSchema:e.subSchema,disabled:e.isDisabled,readOnly:e.isReadOnly});default:return o.jsx(Mt,{...c,type:"text"})}},AS=({container:e,control:t})=>{var r;const{externalData:n={},fieldResolvers:a}=Hr(),s=e.icone?Pt[e.icone]:void 0,i=n,l=N.useMemo(()=>Tl(e,i),[e,JSON.stringify(i)]),c=N.useMemo(()=>[...l.campos].sort((x,y)=>x.ordem-y.ordem),[l.campos]),d=Mn({control:t}),{wrapperClass:u,wrapperStyle:m,headerClass:p,headerStyle:f,tmpl:b}=ux(),h=x=>{if(!st(x.condicional,d,n))return null;let y=x;if(x.resolvePropsKey&&a!=null&&a[x.resolvePropsKey]){const S=a[x.resolvePropsKey](x,d,n);y={...x,...S}}if(y.opcoesFromVar){const S=n[y.opcoesFromVar];Array.isArray(S)&&(y={...y,opcoes:S.map($=>typeof $=="string"?{valor:$,label:$}:$&&typeof $=="object"&&"valor"in $&&"label"in $?$:{valor:String($),label:String($)})})}const v=y.tamanho??12,j=y.inicioColuna,w=j?`${j} / span ${v}`:`span ${v}`,C=o.jsx(Cx,{field:y,control:t});return y.tipo===T.CHECKBOX||y.tipo===T.HIDDEN||y.tipo===T.SWITCH?o.jsx("div",{className:"max-sm:!col-span-12",style:{gridColumn:w},children:C},y.id):o.jsxs("div",{className:"max-sm:!col-span-12 space-y-2",style:{gridColumn:w},children:[o.jsxs("label",{className:"font-medium flex items-center gap-1",style:{color:"var(--t-text)"},children:[y.label,y.obrigatorio&&o.jsx("span",{className:"text-destructive",children:"*"})]}),C,y.hint&&o.jsx("p",{className:"text-xs text-muted-foreground",children:y.hint})]},y.id)};return o.jsxs("div",{className:u,style:m,children:[(l.titulo||s)&&o.jsx("div",{className:p,style:f,children:o.jsxs("div",{className:"flex items-center gap-3",children:[s&&o.jsx("div",{className:"p-2 rounded-xl",style:{background:"color-mix(in srgb, var(--t-primary) 12%, transparent)"},children:o.jsx(s,{className:"w-5 h-5",style:{color:"var(--t-primary)"}})}),o.jsxs("div",{children:[o.jsx("h3",{className:((r=b.typography)==null?void 0:r.stepTitleClass)??"text-lg font-semibold",style:{color:"var(--t-text)"},children:l.titulo}),l.descricao&&o.jsx("p",{className:"text-sm",style:{color:"var(--t-text-muted)"},children:l.descricao})]})]})}),o.jsx("div",{className:"p-6 grid grid-cols-12 gap-4",children:c.map(h)})]})},RS=({container:e,control:t})=>{var r;const{externalData:n={}}=Hr(),a=e.nome??"__invalid__",s=e.minItems??1,i=e.maxItems,l=e.itemLabel??"Item",c=e.icone?Pt[e.icone]:void 0,d=n,u=N.useMemo(()=>Tl(e,d),[e,JSON.stringify(d)]),m=N.useMemo(()=>[...u.campos].sort((k,E)=>k.ordem-E.ordem),[u.campos]),p=N.useCallback(()=>{const k={};for(const E of m)E.initialValue!==void 0?k[E.nome]=typeof E.initialValue=="string"?wt(E.initialValue,d):E.initialValue:E.defaultValue!==void 0&&(k[E.nome]=E.defaultValue);return k},[m,d]),{fields:f,append:b,remove:h}=dx({control:t,name:a});N.useEffect(()=>{if(e.nome&&f.length<s)for(let k=f.length;k<s;k++)b(p())},[s]);const x=Mn({control:t}),y=N.useMemo(()=>{const k=x[a];return Array.isArray(k)?k:[]},[x,a]),{wrapperClass:v,wrapperStyle:j,headerClass:w,headerStyle:C,tmpl:S}=ux();if(!e.nome)return console.error("[RepeatableContainerRenderer] container.nome é obrigatório para containers repetíveis. Container id:",e.id),null;const $=(k,E)=>{const D=y[E]??{};if(!st(k.condicional,D,n))return null;const O=`${a}.${E}.${k.nome}`,L=k.tamanho??12,A=k.inicioColuna,z=A?`${A} / span ${L}`:`span ${L}`,X=o.jsx(Cx,{field:k,control:t,nameOverride:O});return k.tipo===T.CHECKBOX||k.tipo===T.HIDDEN?o.jsx("div",{className:"max-sm:!col-span-12",style:{gridColumn:z},children:X},`${k.id}-${E}`):o.jsxs("div",{className:"max-sm:!col-span-12 space-y-2",style:{gridColumn:z},children:[o.jsxs("label",{className:"font-medium flex items-center gap-1",style:{color:"var(--t-text)"},children:[k.label,k.obrigatorio&&o.jsx("span",{className:"text-destructive",children:"*"})]}),X,k.hint&&o.jsx("p",{className:"text-xs text-muted-foreground",children:k.hint})]},`${k.id}-${E}`)};return o.jsxs("div",{className:v,style:j,children:[(u.titulo||c)&&o.jsx("div",{className:w,style:C,children:o.jsxs("div",{className:"flex items-center gap-3",children:[c&&o.jsx("div",{className:"p-2 rounded-xl",style:{background:"color-mix(in srgb, var(--t-primary) 12%, transparent)"},children:o.jsx(c,{className:"w-5 h-5",style:{color:"var(--t-primary)"}})}),o.jsxs("div",{children:[o.jsx("h3",{className:((r=S.typography)==null?void 0:r.stepTitleClass)??"text-lg font-semibold",style:{color:"var(--t-text)"},children:u.titulo}),u.descricao&&o.jsx("p",{className:"text-sm",style:{color:"var(--t-text-muted)"},children:u.descricao})]})]})}),o.jsxs("div",{className:"p-6 space-y-4",children:[f.map((k,E)=>o.jsxs("div",{className:"border border-input rounded-lg p-4 bg-muted/30",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold shrink-0 bg-primary text-primary-foreground",children:E+1}),o.jsxs("span",{className:"text-sm font-semibold",children:[l," ",E+1]})]}),f.length>s&&o.jsx("button",{type:"button",onClick:()=>h(E),className:"inline-flex items-center justify-center rounded-md p-1.5 text-destructive hover:bg-destructive/10 transition-colors","aria-label":"Remover item",children:o.jsx(_.Trash2,{className:"w-4 h-4"})})]}),o.jsx("div",{className:"grid grid-cols-12 gap-4",children:m.map(D=>$(D,E))})]},k.id)),(!i||f.length<i)&&o.jsxs("button",{type:"button",className:"w-full flex items-center justify-center gap-2 py-2 px-4 border border-input rounded-lg text-sm hover:bg-accent transition-colors",onClick:()=>b(p()),children:[o.jsx(_.Plus,{className:"w-4 h-4"}),"Adicionar ",l.toLowerCase()]}),i&&o.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:["Máximo de ",i," ",l.toLowerCase(),i>1?"s":""]})]})]})},IS=e=>e.container.repeatable&&e.container.nome?o.jsx(RS,{...e}):o.jsx(AS,{...e}),PS=({step:e,control:t,externalData:r={}})=>{const n=N.useMemo(()=>[...e.containers].sort((s,i)=>s.ordem-i.ordem),[e.containers]),a=Mn({control:t});return o.jsx("div",{className:"grid grid-cols-12 gap-4",children:n.map(s=>{if(s.condicional&&!st(s.condicional,a,r))return null;const i=s.tamanho??12,l=s.inicioColuna,c=l?`${l} / span ${i}`:`span ${i}`;return o.jsx("div",{className:"max-sm:!col-span-12",style:{gridColumn:c},children:o.jsx(IS,{container:s,control:t})},s.id)})})},_S=N.createContext({submitting:!1,warnings:{},requestSubmit:()=>{}}),OS=_S.Provider,eu=({stepIndex:e,totalSteps:t,step:r,defaultValues:n,externalData:a,fieldErrors:s,isSubmitting:i,submitError:l,validatorMapper:c={},onWarningsChange:d,onValuesChange:u,onSubmit:m,onBack:p})=>{const f=e===t-1,b=N.useMemo(()=>JSON.stringify(a),[a]),h=N.useMemo(()=>PN(r,a,c),[r.id,b]),x=N.useMemo(()=>_N(r,a,c),[r.id,b]),[y,v]=N.useState({}),j=N.useRef(d);j.current=d;const w=a,C=N.useMemo(()=>LN(r,w),[r,b]),S=NN({resolver:h,defaultValues:n,mode:"onTouched"}),{control:$,handleSubmit:k,setError:E,clearErrors:D,setValue:O}=S;N.useEffect(()=>{D();for(const[U,Q]of Object.entries(s))E(U,{type:"server",message:Q})},[s,E,D]);const L=N.useMemo(()=>r.containers.filter(U=>!U.repeatable).flatMap(U=>U.campos).filter(U=>!!U.condicional),[r.containers]),A=N.useMemo(()=>r.containers.filter(U=>!!U.condicional),[r.containers]),z=N.useMemo(()=>r.containers.filter(U=>!U.repeatable).flatMap(U=>U.campos).filter(U=>{var Q;return U.condicional&&((Q=U.setValues)==null?void 0:Q.length)}),[r.containers]),X=N.useMemo(()=>r.containers.filter(U=>U.repeatable&&!!U.nome).map(U=>({container:U,fields:U.campos.filter(Q=>!!Q.condicional)})).filter(U=>U.fields.length>0),[r.containers]),q=N.useRef({}),Z=N.useRef(!0),V=Mn({control:$}),M=N.useRef(u);M.current=u,N.useEffect(()=>{var U;(U=M.current)==null||U.call(M,V)},[V]),N.useEffect(()=>{let U=!1;return x(V).then(Q=>{var Y;U||(v(Q),(Y=j.current)==null||Y.call(j,Q))}).catch(Q=>{U||console.error("[StepForm] warnComputer error:",Q)}),()=>{U=!0}},[V,x]),N.useEffect(()=>{var U;if(!L.length&&!z.length&&!A.length&&!X.length)return;const Q=V;for(const H of L)if(!st(H.condicional,Q,a)){if(D(H.nome),H.tipo===T.FIELD_ARRAY){const W=Q[H.nome];Array.isArray(W)&&W.forEach((G,ne)=>{(H.subFields??[]).forEach(J=>D(`${H.nome}.${ne}.${J.nome}`))})}if(H.clearedValue!==void 0){const W=H.clearedValue??"";Q[H.nome]!==W&&O(H.nome,W,{shouldValidate:!1})}}for(const H of A)if(!st(H.condicional,Q,a))if(H.repeatable&&H.nome)(Array.isArray(Q[H.nome])?Q[H.nome]:[]).forEach((W,G)=>{for(const ne of H.campos)D(`${H.nome}.${G}.${ne.nome}`)});else for(const W of H.campos){D(W.nome);const G=W.clearedValue!==void 0?W.clearedValue:void 0;G!==void 0&&Q[W.nome]!==G&&O(W.nome,G,{shouldValidate:!1})}for(const{container:H,fields:W}of X){const G=H.nome,ne=Array.isArray(Q[G])?Q[G]:[];for(let J=0;J<ne.length;J++){const te=ne[J];for(const ce of W)if(!st(ce.condicional,te,a)&&(D(`${G}.${J}.${ce.nome}`),ce.clearedValue!==void 0)){const be=ce.clearedValue??"";te[ce.nome]!==be&&O(`${G}.${J}.${ce.nome}`,be,{shouldValidate:!1})}}}const Y=Z.current;for(const H of z){const W=st(H.condicional,Q,a),G=Y?W:q.current[H.nome]??!1;if(W&&!G&&(U=H.setValues)!=null&&U.length)for(const ne of H.setValues){const J=typeof ne.valor=="string"?wt(ne.valor,w):ne.valor;O(ne.campo,J,{shouldValidate:!1})}q.current[H.nome]=W}Z.current=!1},[V,L,z,A,X,a,O,D]);const P=C.icone?Pt[C.icone]:void 0,se=N.useMemo(()=>()=>{S.handleSubmit(m)()},[m]);return o.jsx(cN,{...S,children:o.jsx(OS,{value:{submitting:i,warnings:y,requestSubmit:se},children:o.jsx("form",{onSubmit:k(m),noValidate:!0,onKeyDown:U=>{U.key==="Enter"&&U.target.tagName==="INPUT"&&U.preventDefault()},children:o.jsxs("div",{className:"space-y-6",children:[C.showLabel!==!1&&o.jsxs("div",{className:"text-center space-y-2",children:[P&&o.jsx("div",{className:"w-12 h-12 mx-auto rounded-xl flex items-center justify-center",style:{background:"color-mix(in srgb, var(--t-primary) 12%, transparent)"},children:o.jsx(P,{className:"w-6 h-6",style:{color:"var(--t-primary)"}})}),o.jsx("h2",{className:"text-2xl font-bold",style:{color:"var(--t-text)"},children:C.titulo}),C.descricao&&o.jsx("p",{className:"text-sm text-muted-foreground",children:C.descricao})]}),o.jsx(PS,{step:C,control:$,externalData:a}),o.jsxs("div",{className:"flex items-center justify-between gap-4 pt-6 pb-2",children:[o.jsxs(De,{type:"button",variant:"outline",onClick:p,disabled:e===0,className:K(e>0&&"border-primary/40 text-primary hover:bg-primary/5"),children:[o.jsx(_.ChevronLeft,{className:"w-4 h-4"}),o.jsx("span",{className:"hidden sm:inline",children:"Anterior"})]}),o.jsxs("span",{className:"text-xs font-semibold tabular-nums sm:hidden text-muted-foreground",children:[e+1,"/",t]}),o.jsxs(De,{type:"submit",disabled:i,children:[i?o.jsx(_.Loader2,{className:"w-4 h-4 animate-spin"}):f?o.jsx(_.Check,{className:"w-4 h-4"}):o.jsx(_.ChevronRight,{className:"w-4 h-4"}),o.jsx("span",{className:"hidden sm:inline",children:f?"Finalizar":"Próximo"})]})]}),l&&o.jsx("p",{className:"text-sm text-destructive mt-2 text-center",children:l})]})})})})},lo=e=>{if(e)return Pt[e]},FS=({steps:e,currentStep:t,onStepClick:r})=>o.jsx("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:e.map((n,a)=>o.jsx("div",{role:r?"button":void 0,tabIndex:r?0:void 0,onClick:()=>r==null?void 0:r(a),onKeyDown:s=>s.key==="Enter"&&(r==null?void 0:r(a)),className:K("w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold transition-all shrink-0",r&&"cursor-pointer hover:opacity-80"),style:a===t?{background:"var(--t-primary)",color:"#ffffff",boxShadow:"0 0 0 3px color-mix(in srgb, var(--t-primary) 30%, transparent)"}:a<t?{background:"#22c55e",color:"#ffffff"}:{background:"hsl(var(--muted))",color:"hsl(var(--muted-foreground))"},children:a<t?o.jsx(_.Check,{className:"w-4 h-4"}):a+1},n.id))}),zS=({steps:e,currentStep:t,onStepClick:r})=>o.jsx("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:e.map((n,a)=>{const s=lo(n.icone)??_.CircleDot;return o.jsx("div",{role:r?"button":void 0,tabIndex:r?0:void 0,onClick:()=>r==null?void 0:r(a),onKeyDown:i=>i.key==="Enter"&&(r==null?void 0:r(a)),className:K("w-9 h-9 rounded-full flex items-center justify-center transition-all shrink-0",r&&"cursor-pointer hover:opacity-80"),style:a===t?{background:"var(--t-primary)",color:"#ffffff",boxShadow:"0 0 0 3px color-mix(in srgb, var(--t-primary) 30%, transparent)"}:a<t?{background:"#22c55e",color:"#ffffff"}:{background:"hsl(var(--muted))",color:"hsl(var(--muted-foreground))"},children:a<t?o.jsx(_.Check,{className:"w-4 h-4"}):o.jsx(s,{className:"w-4 h-4"})},n.id)})}),LS=({steps:e,currentStep:t,position:r,orientation:n="horizontal",onStepClick:a})=>n==="vertical"?o.jsx("div",{className:"flex flex-col gap-0",children:e.map((s,i)=>{const l=lo(s.icone)??_.CircleDot,c=i===t,d=i<t,u=i===e.length-1;return o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsxs("div",{className:"flex flex-col items-center",children:[o.jsx("button",{type:"button",onClick:()=>a==null?void 0:a(i),className:K("w-8 h-8 rounded-full flex items-center justify-center transition-all shrink-0",a&&"cursor-pointer hover:opacity-80"),style:c?{background:"var(--t-primary)",color:"#fff",boxShadow:"0 0 10px color-mix(in srgb, var(--t-primary) 50%, transparent)"}:d?{background:"#22c55e",color:"#fff"}:{background:"color-mix(in srgb, var(--t-text) 8%, transparent)",color:"var(--t-text-muted)",border:"1.5px solid color-mix(in srgb, var(--t-border) 60%, transparent)"},children:d?o.jsx(_.Check,{className:"w-3.5 h-3.5"}):o.jsx(l,{className:"w-3.5 h-3.5"})}),!u&&o.jsx("div",{className:"w-[2px] my-1",style:{height:"24px",background:d?"#22c55e":"color-mix(in srgb, var(--t-border) 50%, transparent)"}})]}),o.jsx("span",{className:"text-sm font-medium leading-tight mt-1.5",style:c?{color:"var(--t-primary)"}:d?{color:"#16a34a"}:{color:"var(--t-text-muted)"},children:s.label??s.id})]},s.id)})}):o.jsx("div",{className:"w-full flex items-start",children:e.map((s,i)=>{const l=lo(s.icone)??_.CircleDot,c=i===t,d=i<t,u=i===e.length-1;return o.jsxs("div",{className:K("flex items-start",!u&&"flex-1"),children:[o.jsxs("div",{className:"flex flex-col items-center gap-1.5 w-[56px] shrink-0 mx-auto",children:[o.jsx("button",{type:"button",onClick:()=>a==null?void 0:a(i),className:K("w-10 h-10 rounded-full flex items-center justify-center transition-all shrink-0",a&&"cursor-pointer hover:opacity-80"),style:c?{background:"var(--t-primary)",color:"#ffffff",boxShadow:"0 0 12px color-mix(in srgb, var(--t-primary) 50%, transparent)"}:d?{background:"#22c55e",color:"#ffffff"}:{background:"color-mix(in srgb, var(--t-text) 8%, transparent)",color:"var(--t-text-muted)",border:"1.5px solid color-mix(in srgb, var(--t-border) 60%, transparent)"},children:d?o.jsx(_.Check,{className:"w-4 h-4"}):o.jsx(l,{className:"w-4 h-4"})}),o.jsx("span",{className:"text-[10px] font-medium text-center leading-tight line-clamp-2 px-0.5",style:c?{color:"var(--t-primary)"}:d?{color:"#16a34a"}:{color:"var(--t-text-muted)"},children:s.label??s.id})]}),!u&&o.jsx("div",{className:"flex-1 h-[1.5px] mt-5 mx-1",style:{background:d?"linear-gradient(90deg, var(--t-primary), color-mix(in srgb, var(--t-primary) 40%, transparent))":"color-mix(in srgb, var(--t-border) 50%, transparent)"}})]},s.id)})}),Nx=({steps:e,currentStep:t,onStepClick:r,className:n,forceShow:a})=>{const s=sa(),{layout:i}=s;if(!i.showStepIndicators||e.length<=1&&!a)return null;const l=i.stepIndicatorVariant??"numbers",c=i.stepIndicatorPosition??"top-center",d=i.stepIndicatorOrientation??"horizontal",u=(t+1)/e.length*100,m=e[t],p=lo(m==null?void 0:m.icone)??_.CircleDot,f=o.jsx("div",{className:"h-1 rounded-full overflow-hidden",style:{background:"color-mix(in srgb, var(--t-primary) 15%, transparent)"},children:o.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${u}%`,background:"linear-gradient(90deg, var(--t-primary), var(--t-accent))"}})}),b=o.jsxs("div",{className:"block sm:hidden space-y-2",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center shrink-0",style:{background:"var(--t-primary)",color:"#fff"},children:o.jsx(p,{className:"w-5 h-5"})}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("p",{className:"text-sm font-semibold leading-tight truncate",style:{color:"var(--t-text)"},children:(m==null?void 0:m.label)??(m==null?void 0:m.id)}),o.jsxs("p",{className:"text-xs leading-tight",style:{color:"var(--t-text-muted)"},children:["Passo ",t+1," de ",e.length]})]})]}),f]}),h=o.jsxs("div",{className:"hidden sm:block",children:[l==="numbers"&&o.jsx(FS,{steps:e,currentStep:t,onStepClick:r}),l==="icons"&&o.jsx(zS,{steps:e,currentStep:t,onStepClick:r}),l==="icons-labeled"&&o.jsx(LS,{steps:e,currentStep:t,position:c,orientation:d,onStepClick:r})]}),x=i.showProgressBar?o.jsx("div",{className:"hidden sm:block",children:f}):null;return d==="vertical"?o.jsxs("div",{className:K("flex gap-6 items-start",n),children:[b,o.jsxs("div",{className:"hidden sm:flex gap-6 items-start shrink-0",children:[h,x&&o.jsx("div",{className:"flex-1 pt-4",children:x})]})]}):o.jsxs("div",{className:K("space-y-3",n),children:[b,o.jsxs("div",{className:"hidden sm:block space-y-3",children:[h,x]})]})},MS=(e,t,r)=>{var n;const a={...t},s=r;for(const i of e.containers){for(const l of i.campos)if(a[l.nome]===void 0&&(l.initialValue!==void 0?a[l.nome]=typeof l.initialValue=="string"?wt(l.initialValue,s):l.initialValue:l.defaultValue!==void 0&&(a[l.nome]=l.defaultValue)),l.tipo===T.FIELD_ARRAY&&(n=l.subFields)!=null&&n.length){const c=a[l.nome];Array.isArray(c)&&c.length>0&&(a[l.nome]=c.map(d=>{const u={...d};for(const m of l.subFields)u[m.nome]===void 0&&(m.initialValue!==void 0?u[m.nome]=typeof m.initialValue=="string"?wt(m.initialValue,s):m.initialValue:m.defaultValue!==void 0&&(u[m.nome]=m.defaultValue));return u}))}if(i.repeatable&&i.nome){const l=a[i.nome];Array.isArray(l)&&l.length>0&&(a[i.nome]=l.map(c=>{const d={...c};for(const u of i.campos)d[u.nome]===void 0&&(u.initialValue!==void 0?d[u.nome]=typeof u.initialValue=="string"?wt(u.initialValue,s):u.initialValue:u.defaultValue!==void 0&&(d[u.nome]=u.defaultValue));return d}))}}return a},VS=({schema:e,initialValues:t={},initialStep:r=0,onSubmitStep:n,onComplete:a,template:s,formTitle:i,externalData:l={},fieldErrors:c={},uploadFile:d,deleteUploadedFile:u,cepLookup:m,resolveTermsUploadUrl:p,fieldResolvers:f,validatorMapper:b,componentMapper:h,paymentMethodOptions:x,onValuesChange:y,className:v,StepIndicator:j=Nx})=>{const[w,C]=N.useState(()=>r),[S,$]=N.useState({...t}),[k,E]=N.useState(()=>r),[D,O]=N.useState(!1),[L,A]=N.useState(null),[z,X]=N.useState({}),q=N.useRef(p);q.current=p;const Z=N.useCallback(me=>q.current(me),[]),V=!!p,M=N.useRef(u);M.current=u;const P=N.useCallback(me=>M.current(me),[]),se=!!u,U=N.useMemo(()=>JSON.stringify(l),[l]),Q=N.useMemo(()=>JSON.stringify(e.stepConfig),[e.stepConfig]),Y=N.useMemo(()=>{const me=uo(s);return e.stepConfig?{...me,layout:{...me.layout,...e.stepConfig}}:me},[s,Q]),H=N.useMemo(()=>[...e.steps].sort((me,Ee)=>me.ordem-Ee.ordem),[e.steps]),W=H.length,G=W>0?H[Math.min(w,W-1)]:null,ne=N.useMemo(()=>G?MS(G,S,l):{},[G,S,U]),J=N.useMemo(()=>({uploadFile:d,deleteUploadedFile:se?P:void 0,cepLookup:m,resolveTermsUploadUrl:V?Z:void 0,externalData:l,fieldResolvers:f,validatorMapper:b,fieldWarnings:z,componentMapper:h,paymentMethodOptions:x}),[d,se,P,m,Z,V,f,b,z,h,x,U]),te=N.useCallback(async me=>{if(!D){O(!0),A(null);try{const Ee={...S,...me};if($(Ee),n&&await n(w,me),w===W-1)a&&await a(Ee);else{const Fe=w+1;C(Fe),E(Nt=>Math.max(Nt,Fe))}}catch(Ee){console.error("[FormRenderer] Submit error:",Ee);const Fe=Ee instanceof Error?Ee.message:"Ocorreu um erro. Tente novamente.";A(Fe)}finally{O(!1)}}},[w,S,D,W,n,a]),ce=N.useCallback(()=>{w>0&&C(me=>me-1)},[w]);if(!G)return o.jsx(vi.Provider,{value:J,children:o.jsx(ea,{config:Y,className:`min-h-dvh ${Y.wrapperClass??""} ${v??""}`,renderWrapper:!0,children:o.jsx("div",{className:"w-full max-w-4xl mx-auto px-4 py-6 sm:px-6 text-center text-muted-foreground",children:"Nenhum step configurado."})})});const be=Y.layout.eventTitleStyle??"bar",Ce=(Y.layout.stepIndicatorOrientation??"horizontal")==="vertical",ve=W>=1?o.jsx(j,{steps:H.map(me=>({id:me.id,label:me.titulo,icone:me.icone})),currentStep:w,onStepClick:me=>{me!==w&&me<=k&&C(me)}}):null;return o.jsx(vi.Provider,{value:J,children:o.jsx(ea,{config:Y,className:`min-h-dvh ${Y.wrapperClass??""} ${v??""}`,renderWrapper:!0,children:o.jsxs("div",{className:"w-full max-w-4xl mx-auto px-4 py-6 sm:px-6",children:[i&&be==="bar"&&o.jsx("div",{className:"w-full text-center text-sm font-medium py-2.5 px-4 mb-6 rounded-lg border border-input text-muted-foreground bg-muted/30",children:i}),i&&be==="inline"&&o.jsxs("div",{className:"text-center mb-6",children:[o.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest mb-1",style:{color:"var(--t-text-muted)"},children:"Inscrição"}),o.jsx("h1",{className:"text-2xl font-bold",style:{color:"var(--t-text)"},children:i}),o.jsx("div",{className:"h-0.5 w-12 mx-auto mt-3 rounded-full",style:{background:"var(--t-primary)"}})]}),Ce?o.jsxs("div",{className:"flex gap-6 items-start",children:[o.jsx("div",{className:"hidden sm:block shrink-0 w-44 pt-1",children:ve}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"sm:hidden mb-6",children:ve}),o.jsx(eu,{stepIndex:w,totalSteps:W,step:G,defaultValues:ne,externalData:l,fieldErrors:c,isSubmitting:D,submitError:L,validatorMapper:b,onWarningsChange:X,onValuesChange:y,onSubmit:te,onBack:ce},w)]})]}):o.jsxs(o.Fragment,{children:[ve&&o.jsx("div",{className:"mb-8",children:ve}),o.jsx(eu,{stepIndex:w,totalSteps:W,step:G,defaultValues:ne,externalData:l,fieldErrors:c,isSubmitting:D,submitError:L,validatorMapper:b,onWarningsChange:X,onValuesChange:y,onSubmit:te,onBack:ce},w)]})]})})})},BS=({onFillMock:e,onClear:t})=>o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx(Yh,{}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(De,{variant:"outline",size:"sm",onClick:e,children:[o.jsx(_.FlaskConical,{className:"w-3.5 h-3.5 mr-1"}),"Preencher mock"]}),o.jsxs(De,{variant:"ghost",size:"sm",onClick:t,children:[o.jsx(_.Eraser,{className:"w-3.5 h-3.5 mr-1"}),"Limpar"]})]})]}),US=({onRestart:e})=>o.jsxs("div",{className:"max-w-4xl mx-auto flex flex-col items-center justify-center py-16 space-y-4",children:[o.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center",children:o.jsx(_.PartyPopper,{className:"w-8 h-8 text-primary"})}),o.jsx("h2",{className:"text-xl font-bold text-foreground",children:"Formulário enviado!"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Este é um preview simulado. Nenhum dado foi enviado."}),o.jsxs(De,{variant:"outline",onClick:e,children:[o.jsx(_.RotateCcw,{className:"w-4 h-4 mr-1"}),"Recomeçar"]})]}),HS=e=>o.jsx(Nx,{...e,forceShow:!0}),WS=async(e,t,r)=>{for(let n=20;n<=100;n+=20)await new Promise(a=>setTimeout(a,80)),r==null||r(n);return`mock-upload-${Date.now()}`},qS=async e=>({}),tu={texto:"Texto de teste",textarea:"Texto longo de exemplo para preview do formulário.",email:"teste@email.com",number:42,telefone:"(11) 99999-9999",cpf:"123.456.789-00",cep:"01001-000",date:new Date().toISOString().slice(0,10),datetime:new Date().toISOString().slice(0,10),time:"10:30",password:"Senha123!",masked:"123456",checkbox:!0,switch:!0,slider:50,rating:4,color:"#3B82F6",participation_type:{tipo:"todos_os_dias",data:null,genero:null},payment_method:{metodo:"pix",valorTotal:0},date_range:{start:new Date().toISOString().slice(0,10),end:new Date().toISOString().slice(0,10)},file:"mock-upload-preview"};function GS(e){var t,r;const n=e.tipo;if(!(n==="hidden"||n==="terms"||n==="field_array"))return tu[n]!==void 0?tu[n]:(n==="select"||n==="radio"||n==="autocomplete")&&(t=e.opcoes)!=null&&t.length?e.opcoes[0].valor:n==="checkbox_group"&&(r=e.opcoes)!=null&&r.length?[e.opcoes[0].valor]:"Teste"}function XS(e){const t={};for(const r of e.steps)for(const n of r.containers)for(const a of n.campos){const s=GS(a);s!==void 0&&(t[a.nome]=s)}return t}const ZS=({eventoData:e})=>{const{containers:t,configs:r,previewTemplateId:n,stepConfig:a}=gt(),s=N.useMemo(()=>yl({containers:t},r,{nome:"Preview",status:ji.RASCUNHO,template:n,stepConfig:a}),[t,r,n,a]),[i,l]=N.useState(0),[c,d]=N.useState({}),[u,m]=N.useState(!1),p=N.useCallback(()=>{d(XS(s)),l(h=>h+1),m(!1)},[s]),f=N.useCallback(()=>{d({}),l(h=>h+1),m(!1)},[]),b=N.useCallback(()=>{d({}),l(h=>h+1),m(!1)},[]);return s.steps.length===0?o.jsx("div",{className:"rounded-lg border border-dashed border-border/40 p-6 text-center text-xs text-muted-foreground/50",children:"Adicione steps, containers e campos para ver o preview ao vivo"}):u?o.jsx(US,{onRestart:b}):o.jsxs("div",{className:"space-y-3",children:[o.jsx("div",{className:"px-1",children:o.jsx(BS,{onFillMock:p,onClear:f})}),o.jsx(VS,{schema:s,initialValues:c,template:n,externalData:e,uploadFile:WS,cepLookup:qS,onComplete:async()=>m(!0),StepIndicator:HS},i)]})},Sx=({id:e,currentTamanho:t,inicioColuna:r,onResize:n,pushSnapshot:a})=>{const s=N.useRef(null),[i,l]=N.useState(!1),[c,d]=N.useState(null),u=N.useRef(null);N.useEffect(()=>()=>{var p;(p=u.current)==null||p.call(u)},[]);const m=N.useCallback(p=>{p.preventDefault(),p.stopPropagation(),a==null||a();const f=s.current;if(!f)return;const b=f.parentElement;if(!b)return;const h=b.getBoundingClientRect().width,x=f.getBoundingClientRect().width,y=p.clientX,v=r?13-r:12;l(!0);const j=C=>{const S=C.clientX-y,$=(x+S)/h,k=Math.max(1,Math.min(v,Math.round($*12)));d(k),n(k)},w=()=>{l(!1),d(null),u.current=null,window.removeEventListener("mousemove",j),window.removeEventListener("mouseup",w)};u.current=()=>{l(!1),d(null),window.removeEventListener("mousemove",j),window.removeEventListener("mouseup",w)},window.addEventListener("mousemove",j),window.addEventListener("mouseup",w)},[r,n,a]);return{resizeRef:s,resizing:i,resizePreview:c,handleResizeStart:m}},KS=({id:e,elementRef:t,onPositionApply:r,setPositionDrag:n,setSelected:a,pushSnapshot:s})=>{const i=N.useRef(null);return N.useEffect(()=>()=>{var l;(l=i.current)==null||l.call(i)},[]),{handlePositionMouseDown:N.useCallback(l=>{l.preventDefault(),l.stopPropagation(),s==null||s(),a(e);const c=t.current;if(!c)return;const d=c.parentElement;if(!d)return;const u=d.getBoundingClientRect(),m=u.width/12,p=c.getBoundingClientRect(),f=Math.max(1,Math.round(p.width/m)),b=p.left-u.left,h=l.clientX-p.left,x=w=>{const C=w-u.left-h,S=Math.round(C/m)+1;return Math.max(1,Math.min(13-f,S))},y=Math.max(1,Math.min(12,Math.round(b/m)+1));n({itemId:e,ghostStart:y,ghostSpan:f,cursorX:l.clientX,cursorY:l.clientY});const v=w=>{n({itemId:e,ghostStart:x(w.clientX),ghostSpan:f,cursorX:w.clientX,cursorY:w.clientY})},j=w=>{r(x(w.clientX)),n(null),i.current=null,window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",j)};i.current=()=>{n(null),window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",j)},window.addEventListener("mousemove",v),window.addEventListener("mouseup",j)},[e,t,r,n,a,s])}},ba=({id:e,container:t})=>{const{attributes:r,listeners:n,setNodeRef:a,transform:s,transition:i,isDragging:l}=Yt.useSortable({id:e,data:{isCanvasItem:!0,type:"field",id:e,fromContainer:t}}),{selectedId:c,setSelected:d,getConfig:u,updateConfig:m,removeItem:p,setPositionDrag:f,positionDrag:b,pushSnapshot:h}=gt(),x=u(e),y=Nh(e),v=(y==null?void 0:y.icon)||_.Type,j=c===e,w=x.tamanho||6,C=(b==null?void 0:b.itemId)===e,[S,$]=N.useState(!1),k="var(--t-primary, hsl(var(--primary)))",E=j?k:S?`color-mix(in srgb, ${k} 60%, transparent)`:`color-mix(in srgb, ${k} 25%, transparent)`,D=j?`0 0 0 2px color-mix(in srgb, ${k} 30%, transparent)`:void 0,{resizeRef:O,resizing:L,resizePreview:A,handleResizeStart:z}=Sx({id:e,currentTamanho:w,inicioColuna:x.inicioColuna,onResize:q=>m(e,{tamanho:q}),pushSnapshot:h}),{handlePositionMouseDown:X}=KS({id:e,elementRef:O,onPositionApply:q=>m(e,{inicioColuna:q}),setPositionDrag:f,setSelected:d,pushSnapshot:h});return o.jsxs("div",{ref:q=>{a(q),O.current=q},onClick:q=>{q.stopPropagation(),d(e)},"data-field-id":e,onMouseEnter:()=>$(!0),onMouseLeave:()=>$(!1),className:Ht("relative flex items-center gap-2 rounded border bg-card/80 backdrop-blur-sm px-2.5 pt-1.5 pb-3.5 cursor-pointer transition-all text-xs",L&&"ring-2 ring-blue-400/50",C&&"opacity-0 pointer-events-none"),style:{gridColumn:x.inicioColuna?`${x.inicioColuna} / span ${w}`:`span ${w}`,transform:oa.CSS.Transform.toString(s),transition:i,opacity:l?0:1,borderColor:E,boxShadow:D},children:[o.jsx("div",{onMouseDown:X,onClick:q=>q.stopPropagation(),className:"cursor-ew-resize shrink-0 p-0.5 rounded hover:bg-primary/20 transition-colors",title:"Arrastar para mudar coluna",children:o.jsx(_.ArrowLeftRight,{className:"h-3 w-3 text-primary/60"})}),o.jsx("div",{...n,...r,className:"cursor-grab shrink-0",onClick:q=>q.stopPropagation(),children:o.jsx(_.GripVertical,{className:"h-3 w-3 text-primary"})}),o.jsx(v,{className:"h-3.5 w-3.5 text-primary shrink-0"}),o.jsx("span",{className:"font-medium truncate flex-1",children:x.label}),x.condition&&o.jsx(_.Zap,{className:"h-3 w-3 text-amber-500 shrink-0"}),x.required&&o.jsx("span",{className:"text-destructive font-bold",children:"*"}),o.jsxs("span",{className:"text-[9px] text-muted-foreground shrink-0",children:[A??w,"/12"]}),o.jsx("button",{onClick:q=>{q.stopPropagation(),p(e)},className:"transition-opacity shrink-0 p-0.5 rounded hover:bg-destructive/10",style:{opacity:S?1:0},children:o.jsx(_.Trash2,{className:"h-3 w-3 text-destructive"})}),o.jsx("div",{className:"absolute left-2 -bottom-0.5 font-mono truncate max-w-[90%] pointer-events-none text-[8px] text-muted-foreground/30",children:e}),o.jsx("div",{"data-resize":!0,onMouseDown:z,className:"cursor-col-resize absolute right-0 top-0 bottom-0 w-2 hover:bg-primary/20 transition-colors flex items-center justify-center",children:o.jsx(_.GripHorizontal,{className:"h-3 w-3 text-primary/40 rotate-90"})})]})},YS=({id:e,container:t})=>{var r;const{attributes:n,listeners:a,setNodeRef:s,transform:i,transition:l,isDragging:c}=Yt.useSortable({id:e,data:{isCanvasItem:!0,type:"field",id:e,fromContainer:t}}),{setNodeRef:d,isOver:u}=Zt.useDroppable({id:`zone-${e}`}),{selectedId:m,setSelected:p,getConfig:f,removeItem:b,moveItem:h,containers:x}=gt(),y=f(e),v=(((r=x[e])==null?void 0:r.children)??[]).filter(C=>He(C)==="field"),j=m===e,w=y.tamanho||12;return o.jsxs("div",{ref:s,onClick:C=>{C.stopPropagation(),p(e)},className:Ht("group/fa relative rounded-lg border overflow-hidden transition-all",c&&"opacity-0 pointer-events-none",j?"border-amber-500 ring-2 ring-amber-500/20 shadow-lg":"border-amber-500/30 hover:border-amber-500/55"),style:{gridColumn:y.inicioColuna?`${y.inicioColuna} / span ${w}`:`span ${w}`,transform:oa.CSS.Transform.toString(i),transition:l},children:[o.jsxs("div",{className:Ht("flex items-center gap-1.5 border-b px-2 py-1.5 transition-colors",j?"bg-amber-500/15 border-amber-500/30":"bg-amber-500/10 border-amber-500/20"),children:[o.jsx("div",{...a,...n,className:"cursor-grab shrink-0 p-1 -ml-1 rounded hover:bg-amber-500/20 transition-colors",onClick:C=>C.stopPropagation(),children:o.jsx(_.GripVertical,{className:"h-3.5 w-3.5 text-amber-500"})}),o.jsxs("div",{className:"flex flex-col -my-1 shrink-0",children:[o.jsx("button",{onClick:C=>{C.stopPropagation(),h(e,"up")},className:"p-0 hover:bg-amber-500/10 rounded transition-colors",title:"Mover para cima",children:o.jsx(_.ChevronUp,{className:"h-3 w-3 text-muted-foreground hover:text-amber-500"})}),o.jsx("button",{onClick:C=>{C.stopPropagation(),h(e,"down")},className:"p-0 hover:bg-amber-500/10 rounded transition-colors",title:"Mover para baixo",children:o.jsx(_.ChevronDown,{className:"h-3 w-3 text-muted-foreground hover:text-amber-500"})})]}),o.jsx(_.List,{className:"h-3.5 w-3.5 text-amber-500 shrink-0"}),o.jsx("span",{className:"text-xs font-semibold truncate flex-1 text-amber-700 dark:text-amber-300",children:y.label}),o.jsxs("span",{className:"text-[10px] text-muted-foreground shrink-0 bg-amber-500/10 px-1.5 rounded",children:[y.itemLabel||"Item"," · ",v.length," campo",v.length!==1?"s":""]}),o.jsx("button",{onClick:C=>{C.stopPropagation(),b(e)},className:"opacity-0 group-hover/fa:opacity-100 transition-opacity shrink-0 p-0.5 rounded hover:bg-destructive/10",children:o.jsx(_.Trash2,{className:"h-3 w-3 text-destructive"})})]}),o.jsx("div",{className:"px-2 -mt-0.5 mb-0.5",children:o.jsx("span",{className:"text-[8px] text-muted-foreground/30 font-mono",children:e})}),o.jsxs("div",{ref:d,className:Ht("relative p-2 min-h-[40px] gap-1.5 transition-all duration-150",u?"bg-amber-500/10 ring-2 ring-inset ring-amber-500/40":""),style:{display:"grid",gridTemplateColumns:"repeat(12, minmax(0, 1fr))",gridAutoRows:"min-content"},children:[v.length===0&&o.jsx("p",{className:"text-[10px] text-muted-foreground/60 text-center py-2 italic",style:{gridColumn:"span 12"},children:"Arraste campos aqui"}),o.jsx(Yt.SortableContext,{items:v,strategy:Yt.rectSortingStrategy,children:v.map(C=>o.jsx(ba,{id:C,container:e},C))})]})]})},ru=5,JS=({id:e,elementRef:t,tamanho:r,inicioColuna:n,onPositionApply:a,setPositionDrag:s,setSelected:i,reorderStrategy:l})=>{const c=N.useRef({inicioColuna:n,tamanho:r});c.current={inicioColuna:n,tamanho:r};const d=N.useRef(null);return N.useEffect(()=>()=>{var u;(u=d.current)==null||u.call(d)},[]),{handleGripMouseDown:N.useCallback(u=>{u.preventDefault(),u.stopPropagation(),i(e);const m=u.clientX,p=u.clientY;let f=!1;const b=()=>{d.current=null,window.removeEventListener("mousemove",h),window.removeEventListener("mouseup",x)},h=j=>{const w=Math.abs(j.clientX-m),C=Math.abs(j.clientY-p);w<ru&&C<ru||(f=!0,b(),w>=C?y(j):v(j))},x=()=>{f||b()};window.addEventListener("mousemove",h),window.addEventListener("mouseup",x),d.current=b;const y=j=>{const w=t.current;if(!w)return;const C=w.parentElement;if(!C)return;const S=C.getBoundingClientRect(),$=S.width/12,{tamanho:k}=c.current,E=w.getBoundingClientRect(),D=E.left-S.left,O=Math.max(1,Math.min(12,Math.round(D/$)+1)),L=E.left;s({itemId:e,ghostStart:O,ghostSpan:k,cursorX:j.clientX,cursorY:j.clientY});const A=q=>{const Z=q-L,V=Math.round(Z/$)+1;return Math.max(1,Math.min(13-k,V))};s({itemId:e,ghostStart:A(j.clientX),ghostSpan:k,cursorX:j.clientX,cursorY:j.clientY});const z=q=>{s({itemId:e,ghostStart:A(q.clientX),ghostSpan:k,cursorX:q.clientX,cursorY:q.clientY})},X=q=>{a(A(q.clientX)),s(null),d.current=null,window.removeEventListener("mousemove",z),window.removeEventListener("mouseup",X)};window.addEventListener("mousemove",z),window.addEventListener("mouseup",X),d.current=()=>{s(null),window.removeEventListener("mousemove",z),window.removeEventListener("mouseup",X)}},v=j=>{const w=l,C=t.current;if(!C)return;const S=C.parentElement;if(!S)return;const $=w.dataAttribute||"data-container-id";w.pushSnapshot(),w.setReorderDrag({draggingId:e});let k=j.clientY;const E=O=>{const L=Array.from(S.children).filter(A=>A!==C&&A.getAttribute($));for(const A of L){const z=A.getBoundingClientRect(),X=z.top+z.height/2;if(O.clientY<X&&O.clientY>z.top&&O.clientY<k){w.moveItemNoSnapshot(e,"up"),k=O.clientY;break}else if(O.clientY>X&&O.clientY<z.bottom&&O.clientY>k){w.moveItemNoSnapshot(e,"down"),k=O.clientY;break}}},D=()=>{w.setReorderDrag(null),d.current=null,window.removeEventListener("mousemove",E),window.removeEventListener("mouseup",D)};window.addEventListener("mousemove",E),window.addEventListener("mouseup",D),d.current=()=>{w.setReorderDrag(null),window.removeEventListener("mousemove",E),window.removeEventListener("mouseup",D)}}},[e,t,a,s,i,l])}},Ll=({showGuides:e,positionDrag:t})=>!e&&!t?null:o.jsxs(o.Fragment,{children:[e&&o.jsx("div",{className:"absolute inset-0 pointer-events-none z-10",style:{display:"grid",gridTemplateColumns:"repeat(12, 1fr)",padding:"inherit",gap:"inherit"},children:Array.from({length:12},(r,n)=>o.jsx("div",{className:"border border-dashed border-muted-foreground/20 rounded-sm flex items-end justify-center pb-1",children:o.jsx("span",{className:"text-[8px] text-muted-foreground/40 font-mono",children:n+1})},n))}),t&&o.jsx("div",{className:"absolute pointer-events-none z-20 rounded-lg border-2 border-dashed border-destructive/60 bg-destructive/10",style:{top:"12px",bottom:"12px",left:`calc(${(t.ghostStart-1)/12*100}% + 12px)`,width:`calc(${t.ghostSpan/12*100}% - 8px)`,transition:"left 0.1s ease-out, width 0.1s ease-out"},children:o.jsxs("div",{className:"absolute -top-5 left-1/2 -translate-x-1/2 bg-destructive text-destructive-foreground text-[10px] font-bold px-2 py-0.5 rounded whitespace-nowrap",children:[t.ghostStart," →"," ",t.ghostStart+t.ghostSpan-1]})})]}),Ml=({id:e,container:t})=>{var r;const{setNodeRef:n,isOver:a}=Zt.useDroppable({id:`zone-${e}`}),{selectedId:s,setSelected:i,getConfig:l,updateConfig:c,removeItem:d,moveItem:u,moveItemNoSnapshot:m,setPositionDrag:p,positionDrag:f,reorderDrag:b,setReorderDrag:h,pushSnapshot:x,containers:y}=gt(),v=l(e),j=((r=y[e])==null?void 0:r.children)??[],w=j.filter(Y=>He(Y)==="field"),C=s===e,S=v.tamanho||12,$=(f==null?void 0:f.itemId)===e,k=(b==null?void 0:b.draggingId)===e,E=f&&j.includes(f.itemId),D=s&&j.includes(s)&&He(s)==="field",[O,L]=N.useState(!1),A="var(--t-primary, hsl(var(--primary)))",z=C?A:O?"rgba(59,130,246,0.55)":"rgba(59,130,246,0.3)",X=C?`color-mix(in srgb, ${A} 15%, transparent)`:O?"rgba(59,130,246,0.12)":"rgba(59,130,246,0.07)",q=C?`color-mix(in srgb, ${A} 30%, transparent)`:O?"rgba(59,130,246,0.28)":"rgba(59,130,246,0.18)",Z=C?`0 0 0 3px color-mix(in srgb, ${A} 20%, transparent)`:O?"0 0 0 2px rgba(59,130,246,0.25)":void 0,{resizeRef:V,resizing:M,resizePreview:P,handleResizeStart:se}=Sx({id:e,currentTamanho:S,inicioColuna:v.inicioColuna,onResize:Y=>c(e,{tamanho:Y}),pushSnapshot:x}),U=N.useMemo(()=>({kind:"custom",moveItemNoSnapshot:m,pushSnapshot:x,setReorderDrag:h,dataAttribute:"data-container-id"}),[m,x,h]),{handleGripMouseDown:Q}=JS({id:e,elementRef:V,tamanho:S,inicioColuna:v.inicioColuna||1,onPositionApply:Y=>c(e,{inicioColuna:Y}),setPositionDrag:p,setSelected:i,reorderStrategy:U});return o.jsxs(o.Fragment,{children:[o.jsxs("div",{ref:Y=>{V.current=Y},onClick:Y=>{Y.stopPropagation(),i(e)},onMouseEnter:()=>L(!0),onMouseLeave:()=>L(!1),className:Ht("relative rounded-lg border overflow-hidden transition-all",M&&"ring-2 ring-blue-400/50",$&&"opacity-0 pointer-events-none",k&&"opacity-50"),"data-container-id":e,style:{gridColumn:v.inicioColuna?`${v.inicioColuna} / span ${S}`:`span ${S}`,minWidth:"80px",borderColor:z,boxShadow:Z},children:[o.jsxs("div",{className:"flex items-center gap-1.5 border-b px-2 py-1.5 transition-colors",style:{backgroundColor:X,borderColor:q},children:[o.jsx("div",{"data-grip":!0,onMouseDown:Q,className:"cursor-grab shrink-0 p-1 -ml-1 rounded hover:bg-primary/20 transition-colors",children:o.jsx(_.GripVertical,{className:"h-3.5 w-3.5 text-blue-500"})}),o.jsxs("div",{className:"flex flex-col -my-1 shrink-0",children:[o.jsx("button",{onClick:Y=>{Y.stopPropagation(),u(e,"up")},className:"p-0 hover:bg-primary/10 rounded transition-colors",title:"Mover para cima",children:o.jsx(_.ChevronUp,{className:"h-3 w-3 text-muted-foreground hover:text-primary"})}),o.jsx("button",{onClick:Y=>{Y.stopPropagation(),u(e,"down")},className:"p-0 hover:bg-primary/10 rounded transition-colors",title:"Mover para baixo",children:o.jsx(_.ChevronDown,{className:"h-3 w-3 text-muted-foreground hover:text-primary"})})]}),o.jsx(_.BoxSelect,{className:"h-3.5 w-3.5 text-blue-500 shrink-0"}),o.jsx("span",{className:Ht("text-xs font-semibold truncate flex-1",v.showLabel===!1?"text-blue-500/50 italic":"text-blue-700 dark:text-blue-300"),children:v.label}),v.showAsCard&&o.jsx(_.SquareStack,{className:"h-3 w-3 text-blue-400 shrink-0"}),v.showLabel===!1&&o.jsx(_.EyeOff,{className:"h-3 w-3 text-muted-foreground/50 shrink-0"}),o.jsxs("span",{className:"text-[10px] text-muted-foreground shrink-0 bg-blue-500/10 px-1.5 rounded",children:[P??S,"/12"]}),o.jsx("button",{onClick:Y=>{Y.stopPropagation(),d(e)},className:"transition-opacity shrink-0 p-0.5 rounded hover:bg-destructive/10",style:{opacity:O?1:0},children:o.jsx(_.Trash2,{className:"h-3 w-3 text-destructive"})})]}),o.jsx("div",{className:"px-2 -mt-0.5 mb-0.5",children:o.jsx("span",{className:"text-[8px] text-muted-foreground/30 font-mono",children:e})}),o.jsxs("div",{ref:n,className:Ht("relative p-2 min-h-[40px] gap-1.5 transition-all duration-150",a?"bg-primary/15 ring-2 ring-inset ring-primary/50":(E||D)&&"bg-muted/30"),style:{display:"grid",gridTemplateColumns:"repeat(12, minmax(0, 1fr))",gridAutoRows:"min-content"},children:[o.jsx(Ll,{showGuides:!!E||!!D,positionDrag:E?f:null}),j.length===0&&o.jsx("p",{className:"text-[10px] text-muted-foreground/60 text-center py-2 italic",style:{gridColumn:"span 12"},children:"Arraste campos aqui"}),o.jsx(Yt.SortableContext,{items:w,strategy:Yt.rectSortingStrategy,children:j.filter(Y=>He(Y)==="field").map(Y=>l(Y).fieldType==="field_array"?o.jsx(YS,{id:Y,container:e},Y):o.jsx(ba,{id:Y,container:e},Y))})]}),o.jsx("div",{onMouseDown:se,className:"cursor-col-resize absolute right-0 top-0 bottom-0 w-2 hover:bg-blue-500/20 transition-colors flex items-center justify-center",children:o.jsx(_.GripHorizontal,{className:"h-3 w-3 text-blue-500/40 rotate-90"})})]}),$&&f&&yi.createPortal(o.jsxs("div",{style:{position:"fixed",left:f.cursorX+14,top:f.cursorY-18,zIndex:9999,pointerEvents:"none"},className:"flex items-center gap-1 bg-foreground text-background text-[10px] font-mono px-2 py-0.5 rounded shadow-xl border border-border/20",children:[o.jsx(_.BoxSelect,{className:"h-2.5 w-2.5"}),"col ",f.ghostStart,"–",f.ghostStart+f.ghostSpan-1]}),document.body)," "]})},$x=({id:e,container:t,index:r})=>{var n;const{attributes:a,listeners:s,setNodeRef:i,transform:l,transition:c,isDragging:d}=Yt.useSortable({id:e,data:{isCanvasItem:!0,type:"step",id:e}}),{setNodeRef:u,isOver:m}=Zt.useDroppable({id:`zone-${e}`}),{selectedId:p,setSelected:f,getConfig:b,removeItem:h,containers:x,positionDrag:y}=gt(),v=b(e),j=((n=x[e])==null?void 0:n.children)??[],w=p===e,C=y&&j.includes(y.itemId),[S,$]=N.useState(!1),k="var(--t-primary, hsl(var(--primary)))",E=w?k:S?`color-mix(in srgb, ${k} 60%, transparent)`:`color-mix(in srgb, ${k} 25%, transparent)`,D=w?`color-mix(in srgb, ${k} 14%, transparent)`:S?`color-mix(in srgb, ${k} 10%, transparent)`:`color-mix(in srgb, ${k} 6%, transparent)`,O=w?`color-mix(in srgb, ${k} 28%, transparent)`:`color-mix(in srgb, ${k} 15%, transparent)`,L=w?`0 0 0 3px color-mix(in srgb, ${k} 20%, transparent)`:void 0,A={transform:oa.CSS.Transform.toString(l),transition:c,opacity:d?0:1};return o.jsxs("div",{ref:i,style:{...A,borderWidth:"2px",borderStyle:"solid",borderColor:E,boxShadow:L},onMouseEnter:()=>$(!0),onMouseLeave:()=>$(!1),onClick:z=>{z.stopPropagation(),f(e)},className:"group/step rounded-xl overflow-hidden transition-all",children:[o.jsxs("div",{className:"flex items-center gap-2 border-b px-3 py-2",style:{backgroundColor:D,borderColor:O},children:[o.jsx("div",{...s,...a,className:"cursor-grab shrink-0",onClick:z=>z.stopPropagation(),children:o.jsx(_.GripVertical,{className:"h-3.5 w-3.5 text-primary"})}),o.jsx(_.Layers,{className:"h-4 w-4 text-primary shrink-0"}),o.jsxs("span",{className:"text-sm font-bold truncate flex-1 text-primary",children:["Step ",r+1," — ",v.label]}),v.description&&o.jsx("span",{className:"text-[10px] text-muted-foreground truncate hidden md:block",children:v.description}),o.jsx("button",{onClick:z=>{z.stopPropagation(),h(e)},className:"transition-opacity shrink-0 p-1 rounded hover:bg-destructive/10",style:{opacity:S?1:0},children:o.jsx(_.Trash2,{className:"h-3.5 w-3.5 text-destructive"})})]}),o.jsxs("div",{ref:u,className:Ht("relative p-3 min-h-[80px] gap-2 items-start transition-all duration-150",m?"bg-blue-500/20 ring-2 ring-inset ring-blue-400/70 shadow-[inset_0_0_0_2px_theme(colors.blue.400/50%)]":""),style:{display:"grid",gridTemplateColumns:"repeat(12, minmax(0, 1fr))",gridAutoRows:"min-content",backgroundImage:"radial-gradient(circle, hsl(var(--muted-foreground) / 0.15) 1px, transparent 1px)",backgroundSize:"16px 16px"},children:[o.jsx(Ll,{showGuides:!!C,positionDrag:C?y:null}),j.length===0&&o.jsx("p",{className:"text-xs text-muted-foreground/50 text-center py-6 italic w-full",style:{gridColumn:"span 12"},children:"Arraste containers aqui"}),j.map(z=>He(z)==="container"?o.jsx(Ml,{id:z,container:e},z):o.jsx(ba,{id:z,container:e},z))]})]})},QS=()=>{var e;const{containers:t,setSelected:r}=gt(),n=((e=t.root)==null?void 0:e.children)??[],a=n.filter(l=>He(l)==="step"),{setNodeRef:s,isOver:i}=Zt.useDroppable({id:"root"});return o.jsxs("div",{ref:s,onClick:()=>r(null),className:`min-h-[500px] rounded-xl border p-4 space-y-4 transition-all duration-150 ${i?"bg-primary/10 border-primary/60 ring-2 ring-primary/30 shadow-[0_0_0_4px_theme(colors.primary/10%)]":"border-border/40"}`,style:{backgroundImage:"radial-gradient(circle, hsl(var(--muted-foreground) / 0.12) 1px, transparent 1px)",backgroundSize:"20px 20px",backgroundColor:i?void 0:"hsl(var(--muted) / 0.3)"},children:[n.length===0&&o.jsx("div",{className:"flex items-center justify-center h-[400px]",children:o.jsxs("div",{className:"text-center space-y-2",children:[o.jsx(_.Layers,{className:"h-10 w-10 text-muted-foreground/30 mx-auto"}),o.jsxs("p",{className:"text-sm text-muted-foreground/50",children:["Arraste ",o.jsx("strong",{children:"Steps"})," da paleta para cá"]})]})}),o.jsx(Yt.SortableContext,{items:a,strategy:Yt.verticalListSortingStrategy,children:n.map((l,c)=>{const d=He(l);return d==="step"?o.jsx($x,{id:l,container:"root",index:c},l):d==="container"?o.jsx(Ml,{id:l,container:"root"},l):o.jsx(ba,{id:l,container:"root"},l)})})]})},e$={personal:"Pessoal",address:"Endereço",health:"Saúde",event:"Evento",payment:"Pagamento",emergency:"Emergência"},t$={texto:"Texto",selecao:"Seleção",range:"Numérico / Visual",data:"Data e Hora",contato:"Contato / Endereço",outros:"Arquivo / Outros"},r$=()=>{const e=Or.reduce((t,r)=>{const n=r.group??"outros";return t[n]||(t[n]=[]),t[n].push(r),t},{});return o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("h2",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Estrutura"}),vl.map(t=>o.jsx(nu,{component:t.component,label:t.label,icon:t.icon,color:t.color},t.component))]}),Object.entries(e).map(([t,r])=>o.jsx(Vs,{label:t$[t]??t,children:r.map(n=>o.jsx(nu,{component:n.component,label:n.label,icon:n.icon,color:"border-border"},n.component))},t)),o.jsx(Vs,{label:"Blocos pré-configurados",defaultOpen:!1,children:mo.map(t=>o.jsx(n$,{block:t},t.id))}),o.jsx(Vs,{label:"Blocos de steps",defaultOpen:!1,children:Ci.map(t=>o.jsx(a$,{block:t},t.id))})]})},Vs=({label:e,children:t,defaultOpen:r=!0})=>{const[n,a]=N.useState(r);return o.jsxs("div",{className:"space-y-2",children:[o.jsxs("button",{type:"button",onClick:()=>a(s=>!s),className:"flex w-full items-center justify-between text-xs font-semibold text-muted-foreground uppercase tracking-wide hover:text-foreground transition-colors",children:[e,o.jsx(_.ChevronDown,{className:`h-3.5 w-3.5 transition-transform ${n?"":"-rotate-90"}`})]}),n&&o.jsx("div",{className:"space-y-1.5",children:t})]})},nu=({component:e,label:t,icon:r,color:n})=>{const{attributes:a,listeners:s,setNodeRef:i,transform:l,isDragging:c}=Zt.useDraggable({id:`palette-${e}`,data:{isPaletteItem:!0,componentType:e}});return o.jsxs("div",{ref:i,...s,...a,className:`cursor-grab flex items-center gap-2 rounded-lg border px-3 py-2 select-none hover:bg-accent transition-colors ${n} ${c?"opacity-50":""}`,style:{transform:c?void 0:oa.CSS.Translate.toString(l)},children:[o.jsx(_.GripVertical,{className:"h-4 w-4 text-muted-foreground"}),o.jsx(r,{className:"h-4 w-4"}),o.jsx("span",{className:"text-sm font-medium",children:t})]})},n$=({block:e})=>{const{attributes:t,listeners:r,setNodeRef:n,transform:a,isDragging:s}=Zt.useDraggable({id:`preset-${e.id}`,data:{isPalettePreset:!0,presetId:e.id}}),i=e.icon?Pt[e.icon]:void 0,l=e$[e.category]??e.category;return o.jsxs("div",{ref:n,...r,...t,className:`cursor-grab flex items-center gap-2 rounded-lg border border-primary/30 bg-primary/5 px-3 py-2 select-none hover:bg-primary/10 transition-colors ${s?"opacity-50":""}`,style:{transform:s?void 0:oa.CSS.Translate.toString(a)},title:e.description,children:[o.jsx(_.GripVertical,{className:"h-4 w-4 text-muted-foreground shrink-0"}),i?o.jsx(i,{className:"h-4 w-4 text-primary shrink-0"}):o.jsx(Pt.Blocks,{className:"h-4 w-4 text-primary shrink-0"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("span",{className:"text-sm font-medium block truncate",children:e.name}),o.jsx("span",{className:"text-[10px] text-muted-foreground",children:l})]})]})},a$=({block:e})=>{const{addPresetStepBlock:t}=gt(),r=e.icon?Pt[e.icon]:void 0;return o.jsxs("button",{type:"button",onClick:()=>t(e),className:"w-full flex items-center gap-2 rounded-lg border border-amber-500/30 bg-amber-500/5 px-3 py-2 cursor-pointer select-none hover:bg-amber-500/15 transition-colors text-left",title:e.description,children:[r?o.jsx(r,{className:"h-4 w-4 text-amber-400 shrink-0"}):o.jsx(Pt.Layers,{className:"h-4 w-4 text-amber-400 shrink-0"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("span",{className:"text-sm font-medium block truncate",children:e.name}),o.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[e.steps.length," steps"]})]}),o.jsxs("span",{className:"text-[10px] text-amber-400 border border-amber-500/30 rounded px-1.5 py-0.5 shrink-0",children:["+",e.steps.length," steps"]})]})},o$=[...vl,...Or],Ex=({data:e})=>{const{getConfig:t}=gt();if(!e)return null;const r=e;if(r.isPalettePreset){const n=ki(r.presetId);return o.jsxs("div",{className:"flex items-center gap-2 rounded-full bg-primary text-primary-foreground px-3 py-1.5 shadow-2xl text-xs font-semibold cursor-grabbing pointer-events-none",children:[o.jsx(Pt.Blocks,{className:"h-3.5 w-3.5 shrink-0"}),(n==null?void 0:n.name)??"Bloco"]})}if(r.isPaletteItem){const n=o$.find(s=>s.component===r.componentType),a=n==null?void 0:n.icon;return o.jsxs("div",{className:"flex items-center gap-2 rounded-full bg-primary text-primary-foreground px-3 py-1.5 shadow-2xl text-xs font-semibold cursor-grabbing pointer-events-none",children:[a&&o.jsx(a,{className:"h-3.5 w-3.5 shrink-0"}),(n==null?void 0:n.label)??r.componentType]})}if(r.isCanvasItem){const{type:n,id:a}=r,s=t(a),i={step:"border-primary/80 bg-primary text-primary-foreground",container:"border-blue-600 bg-blue-600 text-white",field:"border-primary/80 bg-primary text-primary-foreground"},l={step:"Step",container:"Container",field:"Campo"};return o.jsxs("div",{className:Ht("flex items-center gap-2 rounded-full px-3 py-1.5 shadow-2xl text-xs font-semibold cursor-grabbing pointer-events-none min-w-[100px] max-w-[200px]",i[n]??"border-border bg-card"),children:[o.jsx(_.GripVertical,{className:"h-3 w-3 opacity-60 shrink-0"}),o.jsxs("span",{className:"opacity-70 shrink-0",children:[l[n]??n,":"]}),o.jsx("span",{className:"truncate",children:s.label||a})]})}return null},Dx=({schema:e,children:t,uploadTermsPdf:r,deleteTermsPdf:n})=>{var a;const s=N.useMemo(()=>{var i;return(i=e==null?void 0:e.steps)!=null&&i.length?Eh(e):null},[e]);return o.jsx(C1,{children:o.jsx(Rh,{initialConfigs:s==null?void 0:s.configs,initialContainers:(a=s==null?void 0:s.dndState)==null?void 0:a.containers,initialTemplateId:(s==null?void 0:s.templateId)??void 0,initialStepConfig:s==null?void 0:s.stepConfig,schemaId:(e==null?void 0:e.id)??void 0,uploadTermsPdf:r,deleteTermsPdf:n,children:t})})},Tx=({children:e,onError:t})=>{const{containers:r,addItem:n,addPresetBlock:a,moveCanvasItem:s,reorderInContainer:i}=gt(),l=Zt.useSensors(Zt.useSensor(Zt.PointerSensor,{activationConstraint:{distance:5}})),[c,d]=N.useState(null);return o.jsxs(Zt.DndContext,{sensors:l,onDragStart:u=>{d({data:u.active.data.current})},onDragEnd:u=>{var m,p,f,b,h;d(null);const{active:x,over:y}=u;if(!y)return;const v=x.data.current,j=String(y.id);if(v!=null&&v.isPalettePreset){const{presetId:w}=v,C=ki(w);if(!C)return;if(j.startsWith("zone-")){const S=j.slice(5);a(C,S)}else j==="root"&&(t==null||t("Arraste o bloco sobre um step existente."));return}if(v!=null&&v.isPaletteItem){const{componentType:w}=v;j==="root"?n(w,"root"):j.startsWith("zone-")&&n(w,j.slice(5));return}if(v!=null&&v.isCanvasItem){const{type:w,id:C}=v;if(w==="step"){const S=((m=r.root)==null?void 0:m.children)??[],$=S.indexOf(C),k=S.indexOf(j);$!==-1&&k!==-1&&$!==k&&i("root",Yt.arrayMove(S,$,k));return}if(w==="field"){const S=v.fromContainer;let $=S,k=null;if(j.startsWith("zone-"))$=j.slice(5);else{const E=wl(j,r);E&&($=E,k=j)}if($===S&&k){const E=((p=r[S])==null?void 0:p.children)??[],D=E.indexOf(C),O=E.indexOf(k);D!==-1&&O!==-1&&D!==O&&i(S,Yt.arrayMove(E,D,O))}else if($!==S){const E=k?(((f=r[$])==null?void 0:f.children)??[]).indexOf(k):-1;s(C,S,$,E>=0?E:((h=(b=r[$])==null?void 0:b.children)==null?void 0:h.length)??0)}}}},children:[e,o.jsx(Zt.DragOverlay,{dropAnimation:null,children:c?o.jsx(Ex,{data:c.data}):null})]})},s$=({schema:e,children:t,onError:r,uploadTermsPdf:n,deleteTermsPdf:a})=>o.jsx(Dx,{schema:e,uploadTermsPdf:n,deleteTermsPdf:a,children:o.jsx(Tx,{onError:r,children:t})});exports.BuilderDndContext=Tx;exports.BuilderProvider=Rh;exports.BuilderShell=s$;exports.BuilderWrapper=Dx;exports.Canvas=QS;exports.ConfigPanel=oN;exports.ContainerRenderer=yh;exports.DFCepField=gl;exports.DFCheckbox=Wo;exports.DFCheckboxGroup=ul;exports.DFDateField=Rn;exports.DFFieldArray=uh;exports.DFFileUpload=xl;exports.DFHidden=Go;exports.DFMaskedInput=_r;exports.DFParticipationType=mh;exports.DFPaymentMethod=hh;exports.DFRadioGroup=ml;exports.DFSelect=Ho;exports.DFTerms=xh;exports.DFTextField=Tt;exports.DFTextarea=Uo;exports.DefaultStepIndicator=Ch;exports.DragGhost=Ex;exports.DroppedContainer=Ml;exports.DroppedField=ba;exports.DroppedStep=$x;exports.EVENT_VARIABLES=bl;exports.FIELD_TYPES=Or;exports.FIELD_TYPE_ICONS=Bx;exports.FIELD_TYPE_LABELS=Vx;exports.FieldType=T;exports.FormRenderer=Hk;exports.FormSchemaStatus=ji;exports.FormSpy=Wk;exports.GridOverlay=Ll;exports.LivePreview=ZS;exports.MaskType=au;exports.OPCOES_POR_DIA=ph;exports.OPCOES_TODOS_OS_DIAS=fh;exports.PRESET_BLOCKS=mo;exports.PRESET_STEP_BLOCKS=Ci;exports.Palette=r$;exports.RendererContext=Ja;exports.STRUCTURE_TYPES=vl;exports.StepRenderer=wh;exports.TEMPLATE_REGISTRY=Kr;exports.TemplateProvider=ea;exports.builderToFormSchema=yl;exports.evaluateFieldCondition=at;exports.findParentContainer=wl;exports.formSchemaToBuilder=Eh;exports.generateId=ou;exports.getAllTemplates=ag;exports.getFieldMeta=qk;exports.getFieldMetaById=Nh;exports.getItemType=He;exports.getPresetById=ki;exports.getPresetStepBlockById=cg;exports.getPresetsByCategory=lg;exports.getTemplateConfig=uo;exports.interpolate=xt;exports.interpolateContainer=Bo;exports.interpolateField=th;exports.interpolateStep=rh;exports.isDarkTemplate=su;exports.isGlassmorphism=og;exports.makeStepResolver=Qf;exports.makeStepWarnComputer=eh;exports.useBuilder=gt;exports.useBuilderExport=Xk;exports.useField=zk;exports.useFieldApi=Lk;exports.useFormApi=Fk;exports.useFormState=jh;exports.useRendererContext=Nr;exports.useTemplate=sa;exports.v4Fallback=St;exports.validateBuilderIntegrity=Dh;
|