@schema-forms-data/builder 0.3.14 → 0.3.15
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.
Potentially problematic release.
This version of @schema-forms-data/builder might be problematic. Click here for more details.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +28 -12
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -47,5 +47,5 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
47
47
|
- less than the value passed to \`max\` (or ${ln} if no \`max\` prop is set)
|
|
48
48
|
- \`null\` or \`undefined\` if the progress is indeterminate.
|
|
49
49
|
|
|
50
|
-
Defaulting to \`null\`.`}var wl=gl,jf=bl;const Nl=u.forwardRef(({className:e,value:t,...r},n)=>o.jsx(wl,{ref:n,className:W("relative h-4 w-full overflow-hidden rounded-full bg-secondary",e),...r,children:o.jsx(jf,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));Nl.displayName=wl.displayName;var[$r]=Be("Tooltip",[Rt]),Fr=Rt(),Sf="TooltipProvider",bo="tooltip.open",[Th,cn]=$r(Sf),Dt="Tooltip",[Pf,zr]=$r(Dt),Cl=e=>{const{__scopeTooltip:t,children:r,open:n,defaultOpen:s,onOpenChange:a,disableHoverableContent:i,delayDuration:l}=e,c=cn(Dt,e.__scopeTooltip),d=Fr(t),[m,p]=u.useState(null),f=Ke(),x=u.useRef(0),g=i??c.disableHoverableContent,h=l??c.delayDuration,v=u.useRef(!1),[b,w]=it({prop:n,defaultProp:s??!1,onChange:P=>{P?(c.onOpen(),document.dispatchEvent(new CustomEvent(bo))):c.onClose(),a==null||a(P)},caller:Dt}),N=u.useMemo(()=>b?v.current?"delayed-open":"instant-open":"closed",[b]),C=u.useCallback(()=>{window.clearTimeout(x.current),x.current=0,v.current=!1,w(!0)},[w]),j=u.useCallback(()=>{window.clearTimeout(x.current),x.current=0,w(!1)},[w]),S=u.useCallback(()=>{window.clearTimeout(x.current),x.current=window.setTimeout(()=>{v.current=!0,w(!0),x.current=0},h)},[h,w]);return u.useEffect(()=>()=>{x.current&&(window.clearTimeout(x.current),x.current=0)},[]),o.jsx(en,{...d,children:o.jsx(Pf,{scope:t,contentId:f,open:b,stateAttribute:N,trigger:m,onTriggerChange:p,onTriggerEnter:u.useCallback(()=>{c.isOpenDelayedRef.current?S():C()},[c.isOpenDelayedRef,S,C]),onTriggerLeave:u.useCallback(()=>{g?j():(window.clearTimeout(x.current),x.current=0)},[j,g]),onOpen:C,onClose:j,disableHoverableContent:g,children:r})})};Cl.displayName=Dt;var yo="TooltipTrigger",jl=u.forwardRef((e,t)=>{const{__scopeTooltip:r,...n}=e,s=zr(yo,r),a=cn(yo,r),i=Fr(r),l=u.useRef(null),c=te(t,l,s.onTriggerChange),d=u.useRef(!1),m=u.useRef(!1),p=u.useCallback(()=>d.current=!1,[]);return u.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),o.jsx(Ar,{asChild:!0,...i,children:o.jsx(J.button,{"aria-describedby":s.open?s.contentId:void 0,"data-state":s.stateAttribute,...n,ref:c,onPointerMove:Y(e.onPointerMove,f=>{f.pointerType!=="touch"&&!m.current&&!a.isPointerInTransitRef.current&&(s.onTriggerEnter(),m.current=!0)}),onPointerLeave:Y(e.onPointerLeave,()=>{s.onTriggerLeave(),m.current=!1}),onPointerDown:Y(e.onPointerDown,()=>{s.open&&s.onClose(),d.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:Y(e.onFocus,()=>{d.current||s.onOpen()}),onBlur:Y(e.onBlur,s.onClose),onClick:Y(e.onClick,s.onClose)})})});jl.displayName=yo;var Rf="TooltipPortal",[Ih,Ef]=$r(Rf,{forceMount:void 0}),Ct="TooltipContent",Sl=u.forwardRef((e,t)=>{const r=Ef(Ct,e.__scopeTooltip),{forceMount:n=r.forceMount,side:s="top",...a}=e,i=zr(Ct,e.__scopeTooltip);return o.jsx(Se,{present:n||i.open,children:i.disableHoverableContent?o.jsx(Pl,{side:s,...a,ref:t}):o.jsx(Af,{side:s,...a,ref:t})})}),Af=u.forwardRef((e,t)=>{const r=zr(Ct,e.__scopeTooltip),n=cn(Ct,e.__scopeTooltip),s=u.useRef(null),a=te(t,s),[i,l]=u.useState(null),{trigger:c,onClose:d}=r,m=s.current,{onPointerInTransitChange:p}=n,f=u.useCallback(()=>{l(null),p(!1)},[p]),x=u.useCallback((g,h)=>{const v=g.currentTarget,b={x:g.clientX,y:g.clientY},w=Of(b,v.getBoundingClientRect()),N=_f(b,w),C=Df(h.getBoundingClientRect()),j=$f([...N,...C]);l(j),p(!0)},[p]);return u.useEffect(()=>()=>f(),[f]),u.useEffect(()=>{if(c&&m){const g=v=>x(v,m),h=v=>x(v,c);return c.addEventListener("pointerleave",g),m.addEventListener("pointerleave",h),()=>{c.removeEventListener("pointerleave",g),m.removeEventListener("pointerleave",h)}}},[c,m,x,f]),u.useEffect(()=>{if(i){const g=h=>{const v=h.target,b={x:h.clientX,y:h.clientY},w=(c==null?void 0:c.contains(v))||(m==null?void 0:m.contains(v)),N=!Mf(b,i);w?f():N&&(f(),d())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[c,m,i,d,f]),o.jsx(Pl,{...e,ref:a})}),[kf,Tf]=$r(Dt,{isInside:!1}),If=td("TooltipContent"),Pl=u.forwardRef((e,t)=>{const{__scopeTooltip:r,children:n,"aria-label":s,onEscapeKeyDown:a,onPointerDownOutside:i,...l}=e,c=zr(Ct,r),d=Fr(r),{onClose:m}=c;return u.useEffect(()=>(document.addEventListener(bo,m),()=>document.removeEventListener(bo,m)),[m]),u.useEffect(()=>{if(c.trigger){const p=f=>{const x=f.target;x!=null&&x.contains(c.trigger)&&m()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[c.trigger,m]),o.jsx($t,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:p=>p.preventDefault(),onDismiss:m,children:o.jsxs(tn,{"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(If,{children:n}),o.jsx(kf,{scope:r,isInside:!0,children:o.jsx(vp,{id:c.contentId,role:"tooltip",children:s||n})})]})})});Sl.displayName=Ct;var Rl="TooltipArrow",Lf=u.forwardRef((e,t)=>{const{__scopeTooltip:r,...n}=e,s=Fr(r);return Tf(Rl,r).isInside?null:o.jsx(rn,{...s,...n,ref:t})});Lf.displayName=Rl;function Of(e,t){const r=Math.abs(t.top-e.y),n=Math.abs(t.bottom-e.y),s=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(r,n,s,a)){case a:return"left";case s:return"right";case r:return"top";case n:return"bottom";default:throw new Error("unreachable")}}function _f(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 Df(e){const{top:t,right:r,bottom:n,left:s}=e;return[{x:s,y:t},{x:r,y:t},{x:r,y:n},{x:s,y:n}]}function Mf(e,t){const{x:r,y:n}=e;let s=!1;for(let a=0,i=t.length-1;a<t.length;i=a++){const l=t[a],c=t[i],d=l.x,m=l.y,p=c.x,f=c.y;m>n!=f>n&&r<(p-d)*(n-m)/(f-m)+d&&(s=!s)}return s}function $f(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),Ff(t)}function Ff(e){if(e.length<=1)return e.slice();const t=[];for(let n=0;n<e.length;n++){const s=e[n];for(;t.length>=2;){const a=t[t.length-1],i=t[t.length-2];if((a.x-i.x)*(s.y-i.y)>=(a.y-i.y)*(s.x-i.x))t.pop();else break}t.push(s)}t.pop();const r=[];for(let n=e.length-1;n>=0;n--){const s=e[n];for(;r.length>=2;){const a=r[r.length-1],i=r[r.length-2];if((a.x-i.x)*(s.y-i.y)>=(a.y-i.y)*(s.x-i.x))r.pop();else break}r.push(s)}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 zf=Cl,Vf=jl,El=Sl;const Al=zf,kl=Vf,dn=u.forwardRef(({className:e,sideOffset:t=4,...r},n)=>o.jsx(El,{ref:n,sideOffset:t,className:W("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}));dn.displayName=El.displayName;const Bf=To("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground",success:"border-transparent bg-green-500 text-white shadow"}},defaultVariants:{variant:"default"}});function Vr({className:e,variant:t,...r}){return o.jsx("div",{className:W(Bf({variant:t}),e),...r})}const wo=[{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."}]}],Wf=wo.flatMap(e=>e.presets),Hf=({value:e,message:t,onChange:r})=>{const[n,s]=_.useState(!1),[a,i]=_.useState(""),l=_.useMemo(()=>{if(!a.trim())return wo;const p=a.toLowerCase();return wo.map(f=>({...f,presets:f.presets.filter(x=>x.label.toLowerCase().includes(p)||x.description.toLowerCase().includes(p)||x.pattern.toLowerCase().includes(p))})).filter(f=>f.presets.length>0)},[a]),c=_.useMemo(()=>e?Wf.find(p=>p.pattern===e):void 0,[e]),d=p=>{r(p.pattern,`${p.label}: formato inválido`),s(!1),i("")},m=()=>{r(void 0,void 0)};return o.jsxs("div",{className:"space-y-2",children:[o.jsx(B,{className:"text-[10px]",children:"Regex"}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(X,{value:e??"",onChange:p=>r(p.target.value||void 0,t),className:"h-7 text-xs font-mono flex-1",placeholder:"Clique no botão ou digite..."}),e&&o.jsx(le,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:m,children:o.jsx(T.X,{className:"h-3 w-3"})}),o.jsxs(Tr,{open:n,onOpenChange:s,children:[o.jsx(Ir,{asChild:!0,children:o.jsx(le,{variant:"outline",size:"icon",className:"h-7 w-7 shrink-0",children:o.jsx(T.Regex,{className:"h-3.5 w-3.5"})})}),o.jsxs(Vt,{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(T.Search,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),o.jsx(X,{value:a,onChange:p=>i(p.target.value),className:"h-8 text-xs pl-7",placeholder:"Buscar regex (ex: CPF, e-mail, senha)...",autoFocus:!0})]})}),o.jsx(br,{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(p=>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:p.category}),p.presets.map(f=>o.jsxs(Al,{children:[o.jsx(kl,{asChild:!0,children:o.jsxs("button",{onClick:()=>d(f),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(T.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:f.label}),o.jsx("span",{className:"text-[10px] text-muted-foreground font-mono block truncate",children:f.pattern})]})]})}),o.jsxs(dn,{side:"left",className:"max-w-[250px] text-xs",children:[o.jsx("p",{className:"font-semibold mb-1",children:f.label}),o.jsx("p",{children:f.description})]})]},f.pattern+f.label))]},p.category))]})})]})]})]}),c&&o.jsxs(Vr,{variant:"secondary",className:"text-[10px] font-normal gap-1",children:[o.jsx(T.Regex,{className:"h-2.5 w-2.5"}),c.label]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-[10px]",children:"Mensagem do regex"}),o.jsx(X,{value:t??"",onChange:p=>r(e,p.target.value||void 0),className:"h-7 text-xs",placeholder:"Formato inválido"})]})]})},No=[{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"]}]}],Uf=No.flatMap(e=>e.presets),Gf=({value:e,onChange:t})=>{const[r,n]=_.useState(!1),[s,a]=_.useState(""),[i,l]=_.useState(""),c=_.useMemo(()=>new Set(e??[]),[e]),d=_.useMemo(()=>{if(!s.trim())return No;const g=s.toLowerCase();return No.map(h=>({...h,presets:h.presets.filter(v=>v.label.toLowerCase().includes(g)||v.description.toLowerCase().includes(g)||v.value.toLowerCase().includes(g))})).filter(h=>h.presets.length>0)},[s]),m=g=>{const h=new Set(e??[]);g.group?g.group.every(b=>h.has(b))?g.group.forEach(b=>h.delete(b)):g.group.forEach(b=>h.add(b)):h.has(g.value)?h.delete(g.value):h.add(g.value),t(h.size>0?Array.from(h):void 0)},p=()=>{const g=i.trim();if(!g)return;const h=new Set(e??[]);h.add(g),t(Array.from(h)),l("")},f=g=>{const h=new Set(e??[]);h.delete(g),t(h.size>0?Array.from(h):void 0)},x=g=>{const h=Uf.find(v=>v.value===g);return(h==null?void 0:h.label)??g};return o.jsxs("div",{className:"space-y-2",children:[o.jsx(B,{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(g=>o.jsxs(Vr,{variant:"secondary",className:"text-[10px] gap-1 pr-1",children:[x(g),o.jsx("button",{onClick:()=>f(g),className:"hover:text-destructive",children:o.jsx(T.X,{className:"h-2.5 w-2.5"})})]},g))}),o.jsxs(Tr,{open:r,onOpenChange:n,children:[o.jsx(Ir,{asChild:!0,children:o.jsxs(le,{variant:"outline",className:"w-full h-8 text-xs justify-start gap-2",children:[o.jsx(T.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(Vt,{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(T.Search,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),o.jsx(X,{value:s,onChange:g=>a(g.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(X,{value:i,onChange:g=>l(g.target.value),className:"h-7 text-xs font-mono flex-1",placeholder:"Tipo customizado (ex: .dwg)",onKeyDown:g=>g.key==="Enter"&&p()}),o.jsx(le,{variant:"secondary",size:"sm",className:"h-7 text-xs shrink-0",onClick:p,disabled:!i.trim(),children:"Adicionar"})]}),o.jsx(br,{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(g=>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:g.category}),g.presets.map(h=>{const v=h.group?h.group.every(w=>c.has(w)):c.has(h.value),b=h.group?h.group.some(w=>c.has(w))&&!v:!1;return o.jsxs(Al,{children:[o.jsx(kl,{asChild:!0,children:o.jsxs("button",{onClick:()=>m(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(xe,{checked:b?"indeterminate":v,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(T.Info,{className:"h-3 w-3 text-muted-foreground/40 shrink-0"})]})}),o.jsxs(dn,{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(w=>o.jsx("li",{className:"font-mono text-[10px] opacity-80",children:w},w))})]})]},h.value)})]},g.category))]})})]})]})]})},Tl=1048576,mr=1073741824;function Zn(e){return e>=mr&&e%mr===0?"GB":"MB"}function Kn(e,t){return t==="GB"?e/mr:e/Tl}function Jn(e,t){return Math.round(e*(t==="GB"?mr:Tl))}const qf=({value:e,onChange:t})=>{const r=_.useMemo(()=>e?Zn(e):"MB",[]),[n,s]=_.useState(r),[a,i]=_.useState(e?String(Kn(e,r)):"");_.useEffect(()=>{if(e===void 0){i("");return}const d=Zn(e);s(d),i(String(Kn(e,d)))},[e]);const l=d=>{i(d);const m=parseFloat(d);d.trim()===""||isNaN(m)||m<=0?t(void 0):t(Jn(m,n))},c=d=>{s(d);const m=parseFloat(a);!isNaN(m)&&m>0&&t(Jn(m,d))};return o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(B,{className:"text-[10px]",children:"Tamanho máximo do arquivo"}),o.jsxs("div",{className:"flex gap-1.5",children:[o.jsx(X,{type:"number",min:0,step:"any",value:a,onChange:d=>l(d.target.value),placeholder:"Ex: 10",className:"h-8 text-xs flex-1"}),o.jsxs(Ce,{value:n,onValueChange:d=>c(d),children:[o.jsx(ye,{className:"w-[72px] h-8 text-xs",children:o.jsx(je,{})}),o.jsxs(we,{children:[o.jsx(pe,{value:"MB",children:"MB"}),o.jsx(pe,{value:"GB",children:"GB"})]})]})]}),e!==void 0&&o.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["= ",e.toLocaleString("pt-BR")," bytes"]})]})},Xf=new Set(["texto","textarea","email","password","url","phone","tel","cpf","cnpj","cep","rg"]),Yf=({fieldType:e,validation:t,onChange:r})=>{const n=(i,l)=>{const m=["minLength","maxLength","min","max","maxFileSize","minAge","maxAge"].includes(i)?l?Number(l):void 0:l||void 0;r({...t,[i]:m})},s=e==="file",a=Xf.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"}),a&&o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-[10px]",children:"Min caracteres"}),o.jsx(X,{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(B,{className:"text-[10px]",children:"Max caracteres"}),o.jsx(X,{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(B,{className:"text-[10px]",children:"Valor mínimo"}),o.jsx(X,{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(B,{className:"text-[10px]",children:"Valor máximo"}),o.jsx(X,{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(B,{className:"text-[10px]",children:"Data mínima"}),o.jsx(X,{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(B,{className:"text-[10px]",children:"Data máxima"}),o.jsx(X,{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(B,{className:"text-[10px]",children:"Idade mínima (anos)"}),o.jsx(X,{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(B,{className:"text-[10px]",children:"Idade máxima (anos)"}),o.jsx(X,{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"})]})]})]}),s&&o.jsxs("div",{className:"space-y-3",children:[o.jsx(Gf,{value:t==null?void 0:t.fileTypes,onChange:i=>r({...t,fileTypes:i})}),o.jsx(qf,{value:t==null?void 0:t.maxFileSize,onChange:i=>r({...t,maxFileSize:i})})]}),!s&&o.jsx(Hf,{value:(t==null?void 0:t.regex)??"",message:(t==null?void 0:t.regexMessage)??"",onChange:(i,l)=>r({...t,regex:i,regexMessage:l})})]})},Il=({options:e,onChange:t})=>{const r=_.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=_.useCallback((i,l,c)=>{const d=[...e];d[i]={...d[i],[l]:c},t(d)},[e,t]),s=_.useCallback(i=>{r.current.splice(i,1),t(e.filter((l,c)=>c!==i))},[e,t]),a=_.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(T.GripVertical,{className:"h-3 w-3 text-muted-foreground/40 shrink-0"}),o.jsx(X,{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(X,{value:i.label,onChange:c=>n(l,"label",c.target.value),className:"h-7 text-xs flex-1",placeholder:"Label"}),o.jsx($e,{})]}),o.jsx(le,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>s(l),children:o.jsx(T.Trash2,{className:"h-3 w-3"})})]},r.current[l])),o.jsxs(le,{variant:"outline",size:"sm",className:"w-full h-7 text-xs",onClick:a,children:[o.jsx(T.Plus,{className:"h-3 w-3 mr-1"})," Adicionar opção"]})]})},Zf=[{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"}],Kf=["vazio","naoVazio"],Qn=({cond:e,selectedId:t,allFieldIds:r,getFieldLabel:n,onUpdate:s})=>o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-[10px]",children:"Fonte"}),o.jsxs(Ce,{value:e.source||"campo",onValueChange:a=>s({source:a,when:""}),children:[o.jsx(ye,{className:"h-7 text-xs",children:o.jsx(je,{})}),o.jsxs(we,{children:[o.jsx(pe,{value:"campo",children:"Campo do formulário"}),o.jsx(pe,{value:"evento",children:"Variável do evento"})]})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-[10px]",children:e.source==="evento"?"Variável do evento":"Quando o campo"}),o.jsxs(Ce,{value:e.when||"",onValueChange:a=>s({when:a}),children:[o.jsx(ye,{className:"h-7 text-xs",children:o.jsx(je,{placeholder:e.source==="evento"?"Selecione uma variável...":"Selecione um campo..."})}),o.jsx(we,{children:e.source==="evento"?Ro.map(a=>o.jsx(pe,{value:a.key,children:a.label},a.key)):r.filter(a=>a!==t).map(a=>o.jsxs(pe,{value:a,children:[n(a),o.jsxs("span",{className:"text-muted-foreground/50 ml-1 text-[9px] font-mono",children:["(",a,")"]})]},a))})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-[10px]",children:"Operador"}),o.jsxs(Ce,{value:e.operator,onValueChange:a=>s({operator:a}),children:[o.jsx(ye,{className:"h-7 text-xs",children:o.jsx(je,{})}),o.jsx(we,{children:Zf.map(a=>o.jsx(pe,{value:a.value,children:a.label},a.value))})]})]}),!Kf.includes(e.operator)&&o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-[10px]",children:"Valor"}),o.jsx(X,{value:e.value||"",onChange:a=>s({value:a.target.value}),className:"h-7 text-xs",placeholder:"Valor esperado"})]})]}),Jf=({condition:e,selectedId:t,allFieldIds:r,getFieldLabel:n,onChange:s})=>{var m;const a=p=>{e&&s({...e,...p})},i=()=>{if(!e)return;const p=e.extraConditions??[];s({...e,logicOperator:e.logicOperator??"and",extraConditions:[...p,{when:"",operator:"igual",value:"",source:"campo"}]})},l=p=>{if(!e)return;const f=(e.extraConditions??[]).filter((x,g)=>g!==p);s({...e,extraConditions:f,logicOperator:f.length?e.logicOperator:void 0})},c=(p,f)=>{if(!e)return;const x=(e.extraConditions??[]).map((g,h)=>h===p?{...g,...f}:g);s({...e,extraConditions:x})},d=(((m=e==null?void 0:e.extraConditions)==null?void 0:m.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(xe,{id:"has-condition",checked:!!e,onCheckedChange:p=>{s(p?{when:"",operator:"igual",value:"",source:"campo"}:void 0)}}),o.jsx(B,{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(Qn,{cond:e,selectedId:t,allFieldIds:r,getFieldLabel:n,onUpdate:a}),d&&o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-[10px]",children:"Lógica"}),o.jsxs(Ce,{value:e.logicOperator??"and",onValueChange:p=>a({logicOperator:p}),children:[o.jsx(ye,{className:"h-7 text-xs",children:o.jsx(je,{})}),o.jsxs(we,{children:[o.jsx(pe,{value:"and",children:"E (AND) — todas devem ser verdadeiras"}),o.jsx(pe,{value:"or",children:"OU (OR) — pelo menos uma deve ser verdadeira"})]})]})]}),(e.extraConditions??[]).map((p,f)=>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"," ",f+2]}),o.jsx(le,{variant:"ghost",size:"sm",className:"h-5 px-1 text-[10px] text-destructive hover:text-destructive",onClick:()=>l(f),children:"Remover"})]}),o.jsx(Qn,{cond:p,selectedId:t,allFieldIds:r,getFieldLabel:n,onUpdate:x=>c(f,x)})]},f)),o.jsx(le,{variant:"outline",size:"sm",className:"h-6 text-[10px] w-full mt-1",onClick:i,children:"+ Adicionar condição"})]})]})},es=[{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"}],Qf=({subFields:e,onChange:t})=>{const[r,n]=_.useState(null),s=(l,c)=>{const d=e.map((m,p)=>p===l?{...m,...c}:m);t(d)},a=l=>{t(e.filter((c,d)=>d!==l)),n(null)},i=()=>{const l={label:"Novo campo",name:`campo_${e.length+1}`,fieldType:"texto",required:!1};t([...e,l]),n(e.length)};return o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(B,{className:"text-xs font-semibold",children:"Sub-campos"}),o.jsxs(le,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-xs gap-1",onClick:i,children:[o.jsx(T.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((l,c)=>{var d;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===c?null:c),children:[o.jsx(Vr,{variant:"secondary",className:"h-4 text-[9px] px-1 shrink-0",children:c+1}),o.jsx("span",{className:"flex-1 truncate font-medium",children:l.label||l.name||"Campo sem nome"}),o.jsx("span",{className:"text-muted-foreground text-[10px] shrink-0",children:((d=es.find(m=>m.value===l.fieldType))==null?void 0:d.label)??l.fieldType}),o.jsx(le,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 text-destructive hover:text-destructive shrink-0",onClick:m=>{m.stopPropagation(),a(c)},children:o.jsx(T.Trash2,{className:"w-3 h-3"})}),r===c?o.jsx(T.ChevronUp,{className:"w-3 h-3 text-muted-foreground shrink-0"}):o.jsx(T.ChevronDown,{className:"w-3 h-3 text-muted-foreground shrink-0"})]}),r===c&&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(B,{className:"text-[10px]",children:"Label"}),o.jsx(X,{value:l.label,onChange:m=>s(c,{label:m.target.value}),className:"h-7 text-xs",placeholder:"Ex: Nome"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-[10px]",children:"Nome (campo)"}),o.jsx(X,{value:l.name||"",onChange:m=>s(c,{name:m.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(B,{className:"text-[10px]",children:"Tipo de campo"}),o.jsxs(Ce,{value:l.fieldType,onValueChange:m=>s(c,{fieldType:m}),children:[o.jsx(ye,{className:"h-7 text-xs",children:o.jsx(je,{})}),o.jsx(we,{children:es.map(m=>o.jsx(pe,{value:m.value,className:"text-xs",children:m.label},m.value))})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-[10px]",children:"Colunas (1-12)"}),o.jsx(X,{type:"number",min:1,max:12,value:l.tamanho??"",onChange:m=>s(c,{tamanho:m.target.value?Number(m.target.value):void 0}),className:"h-7 text-xs",placeholder:"12"})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-[10px]",children:"Placeholder"}),o.jsx(X,{value:l.placeholder||"",onChange:m=>s(c,{placeholder:m.target.value}),className:"h-7 text-xs",placeholder:"Texto de exemplo..."})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(xe,{id:`sf-req-${c}`,checked:l.required||!1,onCheckedChange:m=>s(c,{required:m===!0})}),o.jsx(B,{htmlFor:`sf-req-${c}`,className:"text-[10px] cursor-pointer",children:"Obrigatório"})]}),["select","radio","checkbox_group"].includes(l.fieldType)&&o.jsx("div",{className:"pt-1",children:o.jsx(Il,{options:l.options||[],onChange:m=>s(c,{options:m})})})]})]},c)}),e.length>0&&o.jsx(Ne,{className:"mt-1"})]})},eh=({config:e,selectedId:t,allFieldIds:r,getFieldLabel:n,onUpdate:s})=>{const a=e.fieldType||"texto",i=["select","radio","checkbox_group","autocomplete"].includes(a),l=a==="field_array",c=e.locked===!0,d=a==="participation_type",m=a==="payment_method",p=a==="terms",f=a==="slider",x=a==="rating",g=a==="date_range",h=a==="sub_form",{schemaId:v,uploadTermsPdf:b}=ke(),[w,N]=_.useState(e.termoPdfUploadId?"upload":"link"),[C,j]=_.useState({status:"idle"}),S=_.useRef(null),P=_.useCallback(async y=>{if(!v){j({status:"error",message:"Salve o schema primeiro para habilitar o upload de PDF."});return}if(!b){j({status:"error",message:"Upload de PDF não configurado. Forneça a prop uploadTermsPdf ao BuilderProvider."});return}j({status:"uploading",fileName:y.name,progress:0});try{const A=await b(y,v);s({termoPdfUploadId:A,termoPdfUrl:void 0}),j({status:"idle"})}catch(A){j({status:"error",message:A instanceof Error?A.message:"Falha no upload do PDF."})}},[v,b,s]);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(T.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(T.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"})]})]}),p&&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(T.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(B,{className:"text-xs",children:"Label"}),o.jsx($e,{})]}),o.jsx(X,{value:e.label,onChange:y=>s({label:y.target.value}),className:"h-8 text-sm"})]}),d||m?o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-xs",children:"Dica (hint)"}),o.jsx(X,{value:e.hint||"",onChange:y=>s({hint:y.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(xe,{id:"req",checked:e.required||!1,onCheckedChange:y=>s({required:y===!0})}),o.jsx(B,{htmlFor:"req",className:"text-xs cursor-pointer",children:"Campo obrigatório"})]})]}):p?o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-xs",children:"Dica (hint)"}),o.jsx(X,{value:e.hint||"",onChange:y=>s({hint:y.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(xe,{id:"req",checked:e.required||!1,onCheckedChange:y=>s({required:y===!0})}),o.jsx(B,{htmlFor:"req",className:"text-xs cursor-pointer",children:"Campo obrigatório"})]}),o.jsx(Ne,{}),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(B,{className:"text-xs",children:"Texto dos termos"}),o.jsx(Mr,{value:e.termoTexto||"",onChange:y=>s({termoTexto:y.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(B,{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:()=>N("link"),className:`flex-1 text-[11px] py-1 rounded transition-colors ${w==="link"?"bg-background shadow-sm font-medium":"text-muted-foreground hover:text-foreground"}`,children:"Link externo"}),o.jsx("button",{type:"button",onClick:()=>N("upload"),className:`flex-1 text-[11px] py-1 rounded transition-colors ${w==="upload"?"bg-background shadow-sm font-medium":"text-muted-foreground hover:text-foreground"}`,children:"Upload de PDF"})]}),w==="link"?o.jsxs("div",{className:"space-y-1",children:[o.jsx(X,{value:e.termoPdfUrl||"",onChange:y=>s({termoPdfUrl:y.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&&C.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(T.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(le,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>{s({termoPdfUploadId:void 0})},children:o.jsx(T.X,{className:"h-3 w-3"})})]}):null,C.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(T.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),o.jsx("span",{className:"truncate",children:C.fileName}),o.jsxs("span",{className:"ml-auto",children:[C.progress,"%"]})]}),o.jsx(Nl,{value:C.progress,className:"h-1"})]}):null,C.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(T.AlertCircle,{className:"h-3.5 w-3.5 text-destructive shrink-0"}),o.jsx("span",{className:"text-[11px] text-destructive",children:C.message}),o.jsx(le,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 ml-auto",onClick:()=>j({status:"idle"}),children:o.jsx(T.X,{className:"h-3 w-3"})})]}):null,C.status!=="uploading"?o.jsxs(o.Fragment,{children:[o.jsx("input",{ref:S,type:"file",accept:"application/pdf",className:"hidden",onChange:y=>{var I;const A=(I=y.target.files)==null?void 0:I[0];A&&P(A),y.target.value=""}}),o.jsxs(le,{type:"button",variant:"outline",size:"sm",className:"w-full h-8 text-xs gap-1.5",disabled:!v,onClick:()=>{var y;return(y=S.current)==null?void 0:y.click()},children:[o.jsx(T.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(B,{className:"text-xs",children:"Nome (chave)"}),o.jsx(X,{value:e.name||t.replace(/^field_/,""),onChange:y=>!c&&s({name:y.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(B,{className:"text-xs",children:"Tipo do campo"}),o.jsxs(Ce,{value:a,onValueChange:y=>!c&&s({fieldType:y}),disabled:c,children:[o.jsx(ye,{className:"h-8 text-sm",children:o.jsx(je,{})}),o.jsx(we,{children:at.map(y=>o.jsx(pe,{value:y.component,children:y.label},y.component))})]})]}),o.jsx(xl,{tamanho:e.tamanho||6,inicioColuna:e.inicioColuna||1,defaultTamanho:6,onTamanhoChange:y=>s({tamanho:y}),onPositionChange:y=>s({inicioColuna:y})}),a!=="file"&&!l&&o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(B,{className:"text-xs",children:"Placeholder"}),o.jsx($e,{})]}),o.jsx(X,{value:e.placeholder||"",onChange:y=>s({placeholder:y.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(B,{className:"text-xs",children:"Dica (hint)"}),o.jsx($e,{})]}),o.jsx(X,{value:e.hint||"",onChange:y=>s({hint:y.target.value}),className:"h-8 text-sm",placeholder:"Texto de ajuda abaixo do campo"})]}),a!=="file"&&!l&&!h&&o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-xs",children:"Valor padrão"}),o.jsx(X,{value:e.defaultValue||"",onChange:y=>s({defaultValue:y.target.value}),className:"h-8 text-sm",placeholder:"Valor inicial do campo"})]}),a!=="file"&&!l&&!h&&o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(B,{className:"text-xs",children:"Valor inicial (runtime)"}),o.jsx($e,{})]}),o.jsx(X,{value:e.initialValue||"",onChange:y=>s({initialValue:y.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&&!h&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(xe,{id:"req",checked:e.required||!1,onCheckedChange:y=>s({required:y===!0})}),o.jsx(B,{htmlFor:"req",className:"text-xs cursor-pointer",children:"Campo obrigatório"})]}),!l&&!h&&!c&&o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(xe,{id:"readonly",checked:e.isReadOnly||!1,onCheckedChange:y=>s({isReadOnly:y===!0||void 0})}),o.jsx(B,{htmlFor:"readonly",className:"text-xs cursor-pointer",children:"Somente leitura"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(xe,{id:"disabled",checked:e.isDisabled||!1,onCheckedChange:y=>s({isDisabled:y===!0||void 0})}),o.jsx(B,{htmlFor:"disabled",className:"text-xs cursor-pointer",children:"Desabilitado"})]})]}),f&&o.jsxs(o.Fragment,{children:[o.jsx(Ne,{}),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(B,{className:"text-xs",children:"Mínimo"}),o.jsx(X,{type:"number",value:e.minValue??0,onChange:y=>s({minValue:Number(y.target.value)}),className:"h-8 text-sm"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-xs",children:"Máximo"}),o.jsx(X,{type:"number",value:e.maxValue??100,onChange:y=>s({maxValue:Number(y.target.value)}),className:"h-8 text-sm"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-xs",children:"Passo"}),o.jsx(X,{type:"number",min:1,value:e.step??1,onChange:y=>s({step:Number(y.target.value)}),className:"h-8 text-sm"})]})]})]})]}),x&&o.jsxs(o.Fragment,{children:[o.jsx(Ne,{}),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(B,{className:"text-xs",children:"Número de estrelas"}),o.jsxs(Ce,{value:String(e.maxRating??5),onValueChange:y=>s({maxRating:Number(y)}),children:[o.jsx(ye,{className:"h-8 text-sm",children:o.jsx(je,{})}),o.jsx(we,{children:[3,4,5,6,7,10].map(y=>o.jsxs(pe,{value:String(y),children:[y," estrelas"]},y))})]})]})]})]}),g&&o.jsxs(o.Fragment,{children:[o.jsx(Ne,{}),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(B,{className:"text-xs",children:"Label da data inicial"}),o.jsx(X,{value:e.dateRangeStartLabel??"Data inicial",onChange:y=>s({dateRangeStartLabel:y.target.value}),className:"h-8 text-sm"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-xs",children:"Label da data final"}),o.jsx(X,{value:e.dateRangeEndLabel??"Data final",onChange:y=>s({dateRangeEndLabel:y.target.value}),className:"h-8 text-sm"})]})]})]}),!l&&o.jsx(Ne,{}),!l&&o.jsx(Yf,{fieldType:a,validation:e.validation,onChange:y=>s({validation:y})}),i&&o.jsxs(o.Fragment,{children:[o.jsx(Ne,{}),a==="radio"&&o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-xs",children:"Estilo visual"}),o.jsxs(Ce,{value:e.visualStyle||"card",onValueChange:y=>s({visualStyle:y}),children:[o.jsx(ye,{className:"h-8 text-sm",children:o.jsx(je,{})}),o.jsxs(we,{children:[o.jsx(pe,{value:"card",children:"Card (padrão)"}),o.jsx(pe,{value:"default",children:"Radio simples"})]})]})]}),o.jsx(Il,{options:e.options||[],onChange:y=>s({options:y})})]}),l&&o.jsxs(o.Fragment,{children:[o.jsx(Ne,{}),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(B,{className:"text-xs",children:"Mín. itens"}),o.jsx(X,{type:"number",min:0,value:e.minItems??"",onChange:y=>s({minItems:y.target.value?Number(y.target.value):void 0}),className:"h-8 text-sm",placeholder:"0"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-xs",children:"Máx. itens"}),o.jsx(X,{type:"number",min:0,value:e.maxItems??"",onChange:y=>s({maxItems:y.target.value?Number(y.target.value):void 0}),className:"h-8 text-sm",placeholder:"Sem limite"})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-xs",children:"Label do item"}),o.jsx(X,{value:e.itemLabel||"",onChange:y=>s({itemLabel:y.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(B,{className:"text-xs",children:"Label do botão adicionar"}),o.jsx(X,{value:e.addLabel||"",onChange:y=>s({addLabel:y.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."})})]})]}),h&&o.jsxs(o.Fragment,{children:[o.jsx(Ne,{}),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(B,{className:"text-xs",children:"Título do grupo (opcional)"}),o.jsx(X,{value:e.subSchemaTitle||"",onChange:y=>s({subSchemaTitle:y.target.value||void 0}),className:"h-8 text-sm",placeholder:"Ex: Endereço, Responsável..."})]}),o.jsx(Qf,{subFields:e.subSchemaFields||[],onChange:y=>s({subSchemaFields:y})})]})]}),o.jsx(Ne,{}),o.jsx(Jf,{condition:e.condition,selectedId:t,allFieldIds:r,getFieldLabel:n,onChange:y=>s({condition:y})}),e.condition&&o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-xs",children:"Valor ao ocultar (clearedValue)"}),o.jsx(X,{value:e.clearedValue??"",onChange:y=>s({clearedValue:y.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&&!h&&o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-xs text-muted-foreground",children:"Resolver de props (avançado)"}),o.jsx(X,{value:e.resolvePropsKey||"",onChange:y=>s({resolvePropsKey:y.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."]})]})]})]})},th=()=>{const{selectedId:e,getConfig:t,updateConfig:r,getAllFieldIds:n}=ke();if(!e)return o.jsx("div",{className:"rounded-xl border bg-card p-4 text-center text-sm text-muted-foreground",children:"Clique em um item para configurá-lo"});const s=t(e),a=me(e),i=d=>r(e,d),l=n().filter(d=>d!==e),c=d=>t(d).label||d;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:a==="step"?"Step":a==="container"?"Container":"Campo"}),o.jsx("span",{className:"text-[10px] font-mono text-muted-foreground",children:e})]}),o.jsx(Ne,{}),a==="step"&&o.jsx(xp,{config:s,onUpdate:i}),a==="container"&&o.jsx(hf,{config:s,onUpdate:i}),a==="field"&&o.jsx(eh,{config:s,selectedId:e,allFieldIds:l,getFieldLabel:c,onUpdate:i})]})},rh=(e,t)=>{var s,a,i,l,c,d;const r=((a=(s=e==null?void 0:e.containers)==null?void 0:s.root)==null?void 0:a.children)||[],n=[];for(const m of r){if(me(m)!=="step")continue;const p=((l=(i=e==null?void 0:e.containers)==null?void 0:i[m])==null?void 0:l.children)||[],f=[];for(const x of p){if(me(x)!=="container")continue;const h=(((d=(c=e==null?void 0:e.containers)==null?void 0:c[x])==null?void 0:d.children)||[]).filter(v=>me(v)==="field").map(v=>{var N,C;const b=t(v),w={id:v,config:b};if(b.fieldType==="field_array"){const j=((C=(N=e==null?void 0:e.containers)==null?void 0:N[v])==null?void 0:C.children)??[];w.subFields=j.filter(S=>me(S)==="field").map(S=>({id:S,config:t(S)}))}return w});f.push({id:x,config:t(x),fields:h})}n.push({id:m,config:t(m),containers:f})}return n},Br=(e,t,r)=>{var l;if(!e||!e.when)return!0;const n=e.source==="evento"?(r==null?void 0:r[e.when])||"":t[e.when]||"",s=parseFloat(n),a=parseFloat(e.value||"");let i;switch(e.operator){case"igual":i=n===(e.value||"");break;case"diferente":i=n!==(e.value||"");break;case"vazio":i=!n;break;case"naoVazio":i=!!n;break;case"contem":i=n.includes(e.value||"");break;case"naoContem":i=!n.includes(e.value||"");break;case"maiorQue":i=!isNaN(s)&&!isNaN(a)&&s>a;break;case"menorQue":i=!isNaN(s)&&!isNaN(a)&&s<a;break;case"maiorOuIgual":i=!isNaN(s)&&!isNaN(a)&&s>=a;break;case"menorOuIgual":i=!isNaN(s)&&!isNaN(a)&&s<=a;break;default:i=!0}if(e.logicOperator&&((l=e.extraConditions)!=null&&l.length)){const c=e.extraConditions.map(d=>Br(d,t,r));return e.logicOperator==="and"?i&&c.every(Boolean):i||c.some(Boolean)}return i},ts=(e,t,r,n)=>{if(!Br(t.condition,r,n))return;const s=t.validation,a=t.fieldType||"texto";if(t.required&&!e)return"Campo obrigatório";if(e){if(s!=null&&s.minLength&&e.length<s.minLength)return`Mínimo ${s.minLength} caracteres`;if(s!=null&&s.maxLength&&e.length>s.maxLength)return`Máximo ${s.maxLength} caracteres`;if(a==="number"){const i=Number(e);if(!isNaN(i)){if((s==null?void 0:s.min)!==void 0&&i<s.min)return`Valor mínimo: ${s.min}`;if((s==null?void 0:s.max)!==void 0&&i>s.max)return`Valor máximo: ${s.max}`}}if((a==="date"||a==="datetime")&&e){if(s!=null&&s.minDate&&e<s.minDate)return`Data mínima: ${s.minDate}`;if(s!=null&&s.maxDate&&e>s.maxDate)return`Data máxima: ${s.maxDate}`}if(s!=null&&s.regex)try{if(!new RegExp(s.regex).test(e))return s.regexMessage||"Formato inválido"}catch{}}},rs={email:"teste@email.com",number:"123",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),textarea:"Texto de teste para preview",checkbox:"true",hidden:"",participation_type:JSON.stringify({tipo:"todos_os_dias",data:null,genero:null}),payment_method:JSON.stringify({metodo:"pix",valorTotal:0}),terms:""},Ll=(e,t)=>{var n;const r=e.fieldType||"texto";if(r==="field_array"){const s=Math.max(e.minItems??1,1),a=Array.from({length:s},()=>{const i={};return t==null||t.forEach(l=>{i[l.id]=Ll(l.config)}),i});return JSON.stringify(a)}return rs[r]!==void 0?rs[r]:(r==="select"||r==="radio")&&((n=e.options)!=null&&n.length)?e.options[0].value||"":"Teste"},oh={glassmorphism:"Glass",card:"Card",flat:"Flat",bordered:"Bordered"},nh=()=>{const{previewTemplateId:e,setPreviewTemplateId:t}=ke(),[r,n]=_.useState(!1),s=Object.values(Ye.TEMPLATE_REGISTRY),a=Ye.TEMPLATE_REGISTRY[e];return o.jsxs(Tr,{open:r,onOpenChange:n,children:[o.jsx(Ir,{asChild:!0,children:o.jsxs(le,{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:(a==null?void 0:a.colors.primary)??"#3b82f6"}}),o.jsx(T.Palette,{className:"w-3.5 h-3.5"}),o.jsx("span",{className:"hidden sm:inline",children:(a==null?void 0:a.displayName)??"Template"})]})}),o.jsxs(Vt,{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:s.map(i=>{const l=i.id===e,c=Ye.isDarkTemplate(i),d=oh[i.layout.containerStyle]??"";return o.jsxs("button",{onClick:()=>{t(i.id),n(!1)},className:W("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(T.Check,{className:"w-3 h-3 text-primary"})})]},i.id)})})]})]})},sh=({onFillMock:e,onClear:t})=>o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx(nh,{}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(le,{variant:"outline",size:"sm",onClick:e,children:[o.jsx(T.FlaskConical,{className:"w-3.5 h-3.5 mr-1"}),"Preencher mock"]}),o.jsxs(le,{variant:"ghost",size:"sm",onClick:t,children:[o.jsx(T.Eraser,{className:"w-3.5 h-3.5 mr-1"}),"Limpar"]})]})]}),ah={texto:"text",number:"number",email:"email",telefone:"tel",cpf:"text",cep:"text",date:"date",datetime:"datetime-local"},Ol=e=>ah[e]||"text",xt=e=>`R$ ${(e/100).toFixed(2).replace(".",",")}`,ih=({config:e,fieldId:t,subFields:r,tamanho:n,error:s,onChange:a,value:i})=>{const l=e.minItems??1,c=e.maxItems??10,d=e.itemLabel||"Item",m=e.addLabel||`Adicionar ${d}`,p=_.useRef(i||""),f=_.useCallback(()=>Object.fromEntries(r.map(j=>[j.id,""])),[r]),[x,g]=_.useState(()=>{if(i)try{const j=JSON.parse(i);if(Array.isArray(j)&&j.length>0)return j}catch{}return[f()]}),[h,v]=_.useState({});_.useEffect(()=>{if(i!==p.current){if(p.current=i||"",!i){g([f()]);return}try{const j=JSON.parse(i);Array.isArray(j)&&g(j)}catch{}}},[i,f]),_.useEffect(()=>{if(!s){v({});return}const j={};x.forEach((S,P)=>{r.forEach(y=>{const A=S[y.id]??"";y.config.required&&!A.trim()&&(j[`${P}.${y.id}`]="Campo obrigatório")})}),v(j)},[s,x,r]);const b=j=>{if(!a)return;const S=j.map(y=>{const A={};return r.forEach(I=>{A[I.id]=y[I.id]??""}),A}),P=JSON.stringify(S);p.current=P,a(P)},w=()=>{if(x.length>=c)return;const j=[...x,f()];g(j),b(j)},N=j=>{if(x.length<=l)return;const S=x.filter((P,y)=>y!==j);g(S),b(S)},C=(j,S,P)=>{const y=x.map((A,I)=>I===j?{...A,[S]:P}:A);g(y),b(y),v(A=>{const I={...A};return delete I[`${j}.${S}`],I})};return o.jsxs("div",{className:"space-y-2",style:{gridColumn:`span ${n}`},children:[e.label&&o.jsx(B,{className:"text-sm font-medium",children:e.label}),o.jsx("div",{className:"space-y-3",children:x.map((j,S)=>o.jsxs("div",{className:"rounded-xl border bg-card p-4 space-y-3 shadow-sm",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"inline-flex h-7 w-7 items-center justify-center rounded-full bg-orange-500 text-white text-xs font-bold shrink-0",children:S+1}),o.jsxs("span",{className:"text-sm font-semibold",children:[d," ",S+1]})]}),x.length>l&&o.jsx(le,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive/60 hover:text-destructive",onClick:()=>N(S),children:o.jsx(T.Trash2,{className:"h-4 w-4"})})]}),r.length===0?o.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Sem sub-campos configurados"}):o.jsx("div",{className:"grid grid-cols-12 gap-3",children:r.map(P=>{const y=P.config.fieldType||"texto",A=P.config.tamanho||6,I=j[P.id]??"",O=F=>C(S,P.id,F),D=h[`${S}.${P.id}`];return o.jsxs("div",{className:"space-y-1",style:{gridColumn:`span ${A}`},children:[o.jsxs(B,{className:"text-xs font-medium",children:[P.config.label,P.config.required&&o.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),y==="textarea"?o.jsx(Mr,{placeholder:P.config.placeholder,className:D?"text-sm border-destructive":"text-sm",value:I,onChange:F=>O(F.target.value)}):y==="select"?o.jsxs(Ce,{value:I,onValueChange:O,children:[o.jsx(ye,{className:D?"text-sm border-destructive":"text-sm",children:o.jsx(je,{placeholder:P.config.placeholder||"Selecione..."})}),o.jsx(we,{children:(P.config.options||[]).map((F,z)=>o.jsx(pe,{value:F.value||`__opt_${z}`,children:F.label},`${z}-${F.value}`))})]}):y==="checkbox"?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(xe,{checked:I==="true",onCheckedChange:F=>O(F?"true":"")}),o.jsx("span",{className:"text-sm text-muted-foreground",children:P.config.placeholder||P.config.label})]}):o.jsx(X,{type:Ol(y),placeholder:P.config.placeholder,className:D?"text-sm border-destructive":"text-sm",value:I,onChange:F=>O(F.target.value)}),D&&o.jsxs("p",{className:"text-xs text-destructive flex items-center gap-1",children:[o.jsx(T.AlertCircle,{className:"h-3 w-3 shrink-0"}),D]})]},P.id)})})]},S))}),o.jsxs(le,{type:"button",variant:"outline",className:"w-full border-dashed border-orange-500 text-orange-500 hover:bg-orange-500/10 hover:text-orange-500 font-semibold",onClick:w,disabled:x.length>=c,children:[o.jsx(T.Plus,{className:"h-4 w-4 mr-2"}),m]}),e.maxItems&&o.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:["Máximo de ",e.maxItems," ",d.toLowerCase(),e.maxItems!==1?"s":""]}),!e.maxItems&&e.hint&&o.jsx("p",{className:"text-xs text-muted-foreground",children:e.hint}),s&&o.jsxs("p",{className:"text-sm text-destructive flex items-center gap-1",children:[o.jsx(T.AlertCircle,{className:"h-4 w-4 shrink-0"}),s]})]})},lh=({config:e,fieldId:t,value:r,onChange:n,visible:s,error:a,subFields:i,eventoData:l,allValues:c})=>{const d=e.fieldType||"texto",m=e.tamanho||6;if(!s)return null;if(d==="field_array")return o.jsx(ih,{config:e,fieldId:t,subFields:i??[],tamanho:m,error:a,onChange:n,value:r});const p=a?"border-destructive":"";return o.jsxs("div",{className:"space-y-1",style:{gridColumn:e.inicioColuna?`${e.inicioColuna} / span ${m}`:`span ${m}`},children:[d!=="terms"&&o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsxs(B,{className:"text-sm font-medium",children:[e.label,e.required&&o.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.condition&&o.jsxs(Vr,{variant:"outline",className:"text-[9px] px-1 py-0 h-4 border-amber-500/50 text-amber-600",children:[o.jsx(T.Zap,{className:"h-2.5 w-2.5 mr-0.5"}),"cond"]})]}),d==="textarea"?o.jsx(Mr,{placeholder:e.placeholder,className:W("text-sm",p),value:r,onChange:f=>n(f.target.value)}):d==="select"?o.jsxs(Ce,{value:r,onValueChange:n,children:[o.jsx(ye,{className:W("text-sm",p),children:o.jsx(je,{placeholder:e.placeholder||"Selecione..."})}),o.jsx(we,{children:(e.options||[]).map((f,x)=>o.jsx(pe,{value:f.value||`__opt_${x}`,children:f.label},`${x}-${f.value}`))})]}):d==="checkbox"?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(xe,{checked:r==="true",onCheckedChange:f=>n(f?"true":"")}),o.jsx("span",{className:"text-sm text-muted-foreground",children:e.placeholder||e.label})]}):d==="checkbox_group"?o.jsx(ch,{config:e,value:r,onChange:n}):d==="radio"?o.jsx("div",{className:"space-y-2",children:(e.options||[{value:"1",label:"Opção 1"}]).map((f,x)=>e.visualStyle==="default"?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"radio",readOnly:!0,checked:r===f.value,className:"accent-orange-500"}),o.jsx("span",{className:"text-sm",children:f.label})]},`${x}-${f.value}`):o.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-xl border-2 transition-all cursor-pointer bg-card border-border",children:[o.jsx("input",{type:"radio",readOnly:!0,checked:r===f.value,className:"accent-orange-500"}),o.jsx("span",{className:"text-sm flex-1",children:f.label})]},`${x}-${f.value}`))}):d==="participation_type"?(()=>{const f=parseInt((l==null?void 0:l["evento.valor"])??"0")||0,x=parseInt((l==null?void 0:l["evento.valorPorDia"])??"0")||0,g=l==null?void 0:l["evento.vagasTotal"],h=l==null?void 0:l["evento.vagasPorDia"],v=l==null?void 0:l["evento.vagasMasculinas"],b=l==null?void 0:l["evento.vagasFemininas"],w=!!(v&&Number(v)>0)&&!!(b&&Number(b)>0),N=l==null?void 0:l["evento.dataInicioEvento"],C=l==null?void 0:l["evento.dataFimEvento"],j=R=>R?R.slice(8,10)+"/"+R.slice(5,7)+"/"+R.slice(0,4):"—",S=N&&C?`${j(N)} a ${j(C)}`:"Período do evento",y=(N&&C?Math.round((new Date(C.slice(0,10)+"T00:00:00Z").getTime()-new Date(N.slice(0,10)+"T00:00:00Z").getTime())/864e5)+1:0)>1;let A={};try{A=r?JSON.parse(r):{}}catch{}const I=A.tipo??null,O=A.data??null,D=A.genero??null,F=R=>n(JSON.stringify({tipo:R,data:null,...w?{genero:D}:{}})),z=R=>n(JSON.stringify({tipo:"por_dia",data:R,...w?{genero:D}:{}})),V=R=>n(JSON.stringify({tipo:I,data:O,genero:R})),k=[];if(y&&N&&C){const R=new Date(N.slice(0,10)+"T00:00:00Z"),$=new Date(C.slice(0,10)+"T00:00:00Z");let L=0;for(;R<=$&&L++<60;)k.push(R.toISOString().slice(0,10)),R.setUTCDate(R.getUTCDate()+1)}const E=R=>{const[$,L,q]=R.split("-").map(Number),ne=new Date(Date.UTC($,L-1,q)),ae=String(q).padStart(2,"0"),ie=String(L).padStart(2,"0"),oe=new Intl.DateTimeFormat("pt-BR",{weekday:"long",timeZone:"UTC"}).format(ne);return`${ae}/${ie} — ${oe.charAt(0).toUpperCase()}${oe.slice(1)}`};return o.jsxs("div",{className:"space-y-2",children:[w&&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(R=>{const $=R==="masculino"?"Masculino":"Feminino";return o.jsx("button",{type:"button",onClick:()=>V(R),className:W("px-3 py-1 rounded-full text-xs font-medium border transition-all",D===R?"border-primary bg-primary text-primary-foreground":"border-border bg-card text-muted-foreground hover:border-primary/60"),children:$},R)})})]}),o.jsxs("button",{type:"button",onClick:()=>F("todos_os_dias"),className:W("w-full text-left flex items-start gap-3 p-4 rounded-xl border-2 transition-all bg-card",I==="todos_os_dias"?"border-primary bg-primary/10":"border-border hover:border-primary/40"),children:[o.jsx("div",{className:W("mt-0.5 p-2 rounded-lg shrink-0",I==="todos_os_dias"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"),children:o.jsx(T.CalendarCheck2,{className:"w-4 h-4"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-sm font-semibold",children:"Participar todos os dias"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:S})]}),o.jsxs("div",{className:"text-right shrink-0",children:[o.jsx("p",{className:W("text-sm font-bold",I==="todos_os_dias"?"text-primary":"text-foreground"),children:f>0?xt(f):"R$ —,—"}),g&&o.jsxs("p",{className:"text-xs text-emerald-500 flex items-center justify-end gap-1",children:[o.jsx(T.Users,{className:"w-3 h-3"}),g," vagas"]})]})]}),y?o.jsxs("button",{type:"button",onClick:()=>F("por_dia"),className:W("w-full text-left flex items-start gap-3 p-4 rounded-xl border-2 transition-all bg-card",I==="por_dia"?"border-primary bg-primary/10":"border-border hover:border-primary/40"),children:[o.jsx("div",{className:W("mt-0.5 p-2 rounded-lg shrink-0",I==="por_dia"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"),children:o.jsx(T.CalendarDays,{className:"w-4 h-4"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-sm font-semibold",children:"Participar um dia"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Escolha o dia desejado"})]}),o.jsxs("div",{className:"text-right shrink-0",children:[o.jsx("p",{className:W("text-sm font-bold",I==="por_dia"?"text-primary":"text-foreground"),children:x>0?xt(x):"R$ —,—"}),h&&o.jsxs("p",{className:"text-xs text-emerald-500 flex items-center justify-end gap-1",children:[o.jsx(T.Users,{className:"w-3 h-3"}),h," vagas/dia"]})]})]}):N?o.jsxs("div",{className:"flex items-start gap-2 px-3 py-2.5 rounded-lg bg-muted/50 border border-border",children:[o.jsx(T.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:'Evento de 1 dia — a opção "Participar um dia" não é exibida.'})]}):o.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-xl border-2 border-border bg-card opacity-40",children:[o.jsx("div",{className:"mt-0.5 p-2 rounded-lg shrink-0 bg-muted text-muted-foreground",children:o.jsx(T.CalendarDays,{className:"w-4 h-4"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-sm font-semibold",children:"Participar um dia"}),o.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Visível se evento tiver 2+ dias"})]}),o.jsx("div",{className:"text-right shrink-0",children:o.jsx("p",{className:"text-sm font-bold text-primary",children:"R$ —,—"})})]}),I==="por_dia"&&k.length>0&&o.jsxs("div",{className:"pl-2 space-y-2",children:[o.jsx("p",{className:"text-xs font-semibold text-primary uppercase tracking-wide",children:"Selecione o dia:"}),k.map(R=>o.jsxs("button",{type:"button",onClick:()=>z(R),className:W("w-full text-left flex items-center justify-between px-4 py-3 rounded-lg border transition-all",O===R?"border-primary bg-primary/10 text-primary":"border-border bg-card hover:border-primary/40"),children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("span",{className:W("w-4 h-4 rounded-full border-2 shrink-0 flex items-center justify-center",O===R?"border-primary bg-primary":"border-muted-foreground"),children:O===R&&o.jsx("span",{className:"w-2 h-2 rounded-full bg-primary-foreground"})}),o.jsx("span",{className:"text-sm",children:E(R)})]}),h&&o.jsxs("span",{className:"text-xs text-emerald-500",children:[h," vagas"]})]},R))]})]})})():d==="payment_method"?(()=>{const g=(c==null?void 0:c._participation_type_field)??"";let h={};try{h=g?JSON.parse(g):{}}catch{}const v=h.tipo??null,b=Number((l==null?void 0:l["evento.valor"])??0)||0,w=Number((l==null?void 0:l["evento.valorPorDia"])??0)||0,N=v==="por_dia"&&w>0?w:b,C=v==="por_dia"?(()=>{if(!h.data)return"Um dia";const[A,I,O]=h.data.split("-");return`${O}/${I}/${A}`})():"Todos os dias",j=v==="por_dia"?[{id:"pix",label:"PIX",desc:"Transferência instantânea (à vista)",taxa:0,parcelas:0},{id:"dinheiro",label:"Dinheiro",desc:"Pagamento em espécie",taxa:0,parcelas:0},{id:"cartao",label:"Cartão de Crédito",desc:"Débito ou crédito na maquininha",taxa:.0315,parcelas:0,taxaLabel:`Taxa InfinityPay: ${(.0315*100).toFixed(2).replace(".",",")}%`}]:[{id:"pix",label:"PIX à Vista",desc:"Pagamento instantâneo sem parcelamento",taxa:0,parcelas:0},{id:"pix_parcelado",label:"PIX Parcelado",desc:"Parcelado em até 7x sem juros",taxa:0,parcelas:7},{id:"cartao",label:"Cartão de Crédito",desc:"Parcelado em até 12x",taxa:.124,parcelas:12,taxaLabel:`Taxa InfinityPay: ${(.124*100).toFixed(2).replace(".",",")}%`},{id:"dinheiro",label:"Dinheiro",desc:"Pagamento em espécie",taxa:0,parcelas:0}];let S={};try{S=r?JSON.parse(r):{}}catch{}const P=S.metodo??null,y=A=>{const I=Math.round(N*(1+A.taxa)*100)/100,O={metodo:A.id,valorTotal:I};A.parcelas>1&&(O.parcelas=A.parcelas),n(JSON.stringify(O))};return o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-border bg-card 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:C})]}),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:xt(N)})]})]}),o.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-amber-500/40 bg-amber-500/10 px-3 py-2.5",children:[o.jsx(T.Info,{className:"h-4 w-4 text-amber-500 mt-0.5 shrink-0"}),o.jsxs("p",{className:"text-xs text-amber-200",children:[o.jsx("span",{className:"font-bold text-amber-400",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:j.map(A=>{const I=P===A.id,O=Math.round(N*(1+A.taxa)*100)/100,D=A.parcelas>1,F=D?Math.round(O/A.parcelas*100)/100:null;return o.jsxs("button",{type:"button",onClick:()=>y(A),className:W("w-full text-left flex items-center gap-4 px-4 py-3 rounded-xl border-2 transition-all bg-card",I?"border-primary bg-primary/10":"border-border hover:border-primary/50"),children:[o.jsx("div",{className:W("flex items-center justify-center w-10 h-10 rounded-lg shrink-0",I?"bg-primary/20":"bg-muted"),children:o.jsx(T.Wallet,{className:W("h-5 w-5",I?"text-primary":"text-muted-foreground")})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"font-semibold text-sm leading-tight",children:A.label}),o.jsx("p",{className:"text-xs text-muted-foreground",children:A.desc}),A.taxaLabel&&o.jsxs("p",{className:"text-xs text-amber-400 mt-0.5",children:["* ",A.taxaLabel]}),A.taxa>0&&o.jsxs("p",{className:"text-xs text-muted-foreground",children:["Total com taxa: ",xt(O)]})]}),o.jsx("div",{className:"text-right shrink-0",children:D?o.jsxs(o.Fragment,{children:[o.jsxs("p",{className:"text-xs text-muted-foreground",children:[A.parcelas,"x de"]}),o.jsx("p",{className:"text-base font-bold text-primary",children:xt(F)})]}):o.jsx("p",{className:"text-base font-bold text-primary",children:xt(O)})})]},A.id)})})]})})():d==="terms"?(()=>{const f=r==="accepted",x=e.termoTexto,g=e.termoPdfUrl,h=!!e.termoPdfUploadId,v=!!(x||g||h);return o.jsxs("div",{className:W("rounded-lg border p-4 space-y-4 transition-colors",f?"border-green-500/40 bg-green-500/5":"border-border bg-muted/30"),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(T.ScrollText,{className:"h-4 w-4 text-primary shrink-0"}),o.jsx("span",{className:"text-sm font-medium",children:e.label||"Termos e condições"})]}),v?o.jsxs("div",{className:"flex items-center gap-1.5",children:[h&&o.jsx("span",{className:"flex items-center gap-1 text-[10px] text-green-600 dark:text-green-400 font-medium border border-green-500/40 bg-green-500/10 rounded px-1.5 py-0.5",children:"PDF enviado ✓"}),o.jsxs(le,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{},children:[o.jsx(T.ExternalLink,{className:"h-3 w-3"}),"Ler termos"]})]}):o.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Conteúdo não configurado"})]}),o.jsxs("label",{className:"flex items-start gap-3 cursor-pointer select-none",children:[o.jsx(xe,{checked:f,onCheckedChange:b=>n(b?"accepted":""),className:"mt-0.5"}),o.jsxs("span",{className:"text-sm leading-snug flex-1",children:["Li e aceito"," ",e.label?`"${e.label}"`:"os termos e condições"]}),f&&o.jsx(T.CheckCircle2,{className:"h-4 w-4 text-green-500 shrink-0 mt-0.5"})]})]})})():d==="file"?o.jsx(X,{type:"file",className:W("text-sm",p)}):d==="hidden"?o.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Campo oculto"}):o.jsx(X,{type:Ol(d),placeholder:e.placeholder,className:W("text-sm",p),value:r,onChange:f=>n(f.target.value)}),a?o.jsxs("p",{className:"text-xs text-destructive flex items-center gap-1",children:[o.jsx(T.AlertCircle,{className:"h-3 w-3 shrink-0"}),a]}):e.hint?o.jsx("p",{className:"text-xs text-muted-foreground",children:e.hint}):null]})},ch=({config:e,value:t,onChange:r})=>{var i;const n=new Set(t?t.split(","):[]),s=(i=e.options)!=null&&i.length?e.options:[{value:"1",label:"Opção 1"}],a=l=>{const c=new Set(n);c.has(l)?c.delete(l):c.add(l),r(Array.from(c).join(","))};return o.jsx("div",{className:"space-y-1",children:s.map((l,c)=>o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(xe,{checked:n.has(l.value),onCheckedChange:()=>a(l.value),disabled:l.disabled}),o.jsx("span",{className:"text-sm",children:l.label})]},`${c}-${l.value}`))})},dh=({step:e,stepIndex:t,formValues:r,errors:n,eventoData:s,onChange:a})=>o.jsxs("div",{className:"rounded-xl border bg-card p-5 space-y-5",children:[o.jsxs("div",{children:[e.config.showLabel!==!1&&o.jsxs("h2",{className:"text-base font-bold text-foreground",children:["Step ",t+1," — ",e.config.label]}),e.config.description&&o.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:e.config.description})]}),o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-12 gap-4",children:e.containers.map(i=>o.jsxs("div",{className:W("space-y-3",i.config.showAsCard&&"rounded-lg border bg-card p-4 shadow-sm"),style:{gridColumn:i.config.inicioColuna?`${i.config.inicioColuna} / span ${i.config.tamanho||12}`:`span ${i.config.tamanho||12}`},children:[i.config.showLabel!==!1&&i.config.label!=="Novo Container"&&o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-semibold text-foreground",children:i.config.label}),i.config.description&&o.jsx("p",{className:"text-xs text-muted-foreground",children:i.config.description})]}),o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-12 gap-3",children:i.fields.map(l=>o.jsx(lh,{config:l.config,fieldId:l.id,subFields:l.subFields,value:r[l.id]||"",onChange:c=>a(l.id,c),visible:Br(l.config.condition,r,s),error:n[l.id],eventoData:s,allValues:r},l.id))})]},i.id))})]}),uh=({currentStep:e,isLastStep:t,onBack:r,onNext:n})=>o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsxs(le,{variant:"outline",onClick:r,disabled:e===0,children:[o.jsx(T.ChevronLeft,{className:"w-4 h-4 mr-1"}),"Voltar"]}),o.jsx(le,{onClick:n,children:t?o.jsxs(o.Fragment,{children:[o.jsx(T.Check,{className:"w-4 h-4 mr-1"}),"Finalizar"]}):o.jsxs(o.Fragment,{children:[o.jsx(T.ChevronRight,{className:"w-4 h-4 mr-1"}),"Próximo"]})})]}),mh=({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(T.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(le,{variant:"outline",onClick:e,children:[o.jsx(T.RotateCcw,{className:"w-4 h-4 mr-1"}),"Recomeçar"]})]}),pr=e=>{if(e)return Lt[e]},ph=({steps:e,currentStep:t,onStepClick:r})=>o.jsx("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:e.map((n,s)=>o.jsx("div",{role:r?"button":void 0,tabIndex:r?0:void 0,onClick:()=>r==null?void 0:r(s),onKeyDown:a=>a.key==="Enter"&&(r==null?void 0:r(s)),className:W("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:s===t?{background:"var(--t-primary)",color:"#ffffff",boxShadow:"0 0 0 3px color-mix(in srgb, var(--t-primary) 30%, transparent)"}:s<t?{background:"#22c55e",color:"#ffffff"}:{background:"hsl(var(--muted))",color:"hsl(var(--muted-foreground))"},children:s<t?o.jsx(T.Check,{className:"w-4 h-4"}):s+1},n.id))}),fh=({steps:e,currentStep:t,onStepClick:r})=>o.jsx("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:e.map((n,s)=>{const a=pr(n.icone)??T.CircleDot;return o.jsx("div",{role:r?"button":void 0,tabIndex:r?0:void 0,onClick:()=>r==null?void 0:r(s),onKeyDown:i=>i.key==="Enter"&&(r==null?void 0:r(s)),className:W("w-9 h-9 rounded-full flex items-center justify-center transition-all shrink-0",r&&"cursor-pointer hover:opacity-80"),style:s===t?{background:"var(--t-primary)",color:"#ffffff",boxShadow:"0 0 0 3px color-mix(in srgb, var(--t-primary) 30%, transparent)"}:s<t?{background:"#22c55e",color:"#ffffff"}:{background:"hsl(var(--muted))",color:"hsl(var(--muted-foreground))"},children:s<t?o.jsx(T.Check,{className:"w-4 h-4"}):o.jsx(a,{className:"w-4 h-4"})},n.id)})}),hh=({steps:e,currentStep:t,position:r,orientation:n="horizontal",onStepClick:s})=>n==="vertical"?o.jsx("div",{className:"flex flex-col gap-0",children:e.map((a,i)=>{const l=pr(a.icone)??T.CircleDot,c=i===t,d=i<t,m=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:()=>s==null?void 0:s(i),className:W("w-8 h-8 rounded-full flex items-center justify-center transition-all shrink-0",s&&"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(T.Check,{className:"w-3.5 h-3.5"}):o.jsx(l,{className:"w-3.5 h-3.5"})}),!m&&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:a.label})]},a.id)})}):o.jsx("div",{className:"w-full flex items-start",children:e.map((a,i)=>{const l=pr(a.icone)??T.CircleDot,c=i===t,d=i<t,m=i===e.length-1;return o.jsxs("div",{className:W("flex items-start",!m&&"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:()=>s==null?void 0:s(i),className:W("w-10 h-10 rounded-full flex items-center justify-center transition-all shrink-0",s&&"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(T.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:a.label})]}),!m&&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)"}})]},a.id)})}),xh=({steps:e,currentStep:t,onStepClick:r,className:n})=>{const s=Ye.useTemplate(),{layout:a}=s;if(!a.showStepIndicators||e.length<=1)return null;const i=a.stepIndicatorVariant??"numbers",l=a.stepIndicatorPosition??"top-center",c=a.stepIndicatorOrientation??"horizontal",d=(t+1)/e.length*100,m=e[t],p=pr(m==null?void 0:m.icone)??T.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:`${d}%`,background:"linear-gradient(90deg, var(--t-primary), var(--t-accent))"}})}),x=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}),o.jsxs("p",{className:"text-xs leading-tight",style:{color:"var(--t-text-muted)"},children:["Passo ",t+1," de ",e.length]})]})]}),f]}),g=o.jsxs("div",{className:"hidden sm:block",children:[i==="numbers"&&o.jsx(ph,{steps:e,currentStep:t,onStepClick:r}),i==="icons"&&o.jsx(fh,{steps:e,currentStep:t,onStepClick:r}),i==="icons-labeled"&&o.jsx(hh,{steps:e,currentStep:t,position:l,orientation:c,onStepClick:r})]}),h=a.showProgressBar?o.jsx("div",{className:"hidden sm:block",children:f}):null;return c==="vertical"?o.jsxs("div",{className:W("flex gap-6 items-start",n),children:[x,o.jsxs("div",{className:"hidden sm:flex gap-6 items-start shrink-0",children:[g,h&&o.jsx("div",{className:"flex-1 pt-4",children:h})]})]}):o.jsxs("div",{className:W("space-y-3",n),children:[x,o.jsxs("div",{className:"hidden sm:block space-y-3",children:[g,h]})]})},gh=({eventoData:e})=>{const{getConfig:t,containers:r,previewTemplateId:n}=ke(),s=rh({containers:r},t),[a,i]=_.useState({}),[l,c]=_.useState(0),[d,m]=_.useState(!1),[p,f]=_.useState({}),[x,g]=_.useState(!1),h=Math.min(l,Math.max(s.length-1,0));_.useEffect(()=>{h!==l&&c(h)},[h,l,c]);const v=_.useCallback((O,D)=>{var F;if(i(z=>({...z,[O]:D})),x){const z=(F=s[h])==null?void 0:F.containers.flatMap(V=>V.fields).find(V=>V.id===O);if(z){const V=ts(D,z.config,{...a,[O]:D},e);f(k=>{const E={...k};return V?E[O]=V:delete E[O],E})}}},[x,s,h,a,e,i,f]),b=_.useCallback(()=>{const O=s[h];if(!O)return!0;const D={};for(const z of O.containers)for(const V of z.fields){if(V.config.fieldType==="field_array"){let E=!1;try{const R=a[V.id],$=R?JSON.parse(R):[],L=V.config.minItems??1;if($.length<L)D[V.id]=`Mínimo de ${L} item${L!==1?"s":""} obrigatório${L!==1?"s":""}`,E=!0;else{for(const q of $){for(const ne of V.subFields??[]){const ae=q[ne.id]??"";if(ne.config.required&&!ae.trim()){E=!0;break}}if(E)break}E&&(D[V.id]="Preencha todos os campos obrigatórios")}}catch{V.config.required&&(D[V.id]="Campo obrigatório")}continue}const k=ts(a[V.id]||"",V.config,a,e);k&&(D[V.id]=k)}f(D),g(!0);const F=Object.keys(D).length;return F>0?(console.warn(`Corrija ${F} campo(s) destacado(s) antes de continuar`),!1):!0},[s,h,a,e,f,g]),w=_.useCallback(()=>{b()&&(g(!1),f({}),h>=s.length-1?m(!0):c(O=>O+1))},[b,h,s.length,g,f,m,c]),N=_.useCallback(()=>{c(O=>O-1),g(!1),f({})},[c,g,f]),C=_.useCallback(()=>{const O={};for(const D of s)for(const F of D.containers)for(const z of F.fields)Br(z.config.condition,a,e)&&(O[z.id]=Ll(z.config,z.subFields));i(D=>({...D,...O}))},[s,a,e,i]),j=_.useCallback(()=>{i({}),f({}),g(!1)},[i,f,g]),S=_.useCallback(()=>{m(!1),c(0),j()},[m,c,j]);if(s.length===0)return 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"});if(d)return o.jsx(mh,{onRestart:S});const P=s[h],y=s.length,A=h===y-1,I=Ye.getTemplateConfig(n);return o.jsxs("div",{className:"space-y-3",children:[o.jsx("div",{className:"px-1",children:o.jsx(sh,{onFillMock:C,onClear:j})}),o.jsx(Ye.TemplateProvider,{config:I,className:I.wrapperClass,style:{minHeight:"100%",padding:"12px",borderRadius:"12px"},children:o.jsxs("div",{className:"max-w-4xl mx-auto space-y-4",children:[o.jsx(xh,{steps:s.map(O=>({id:O.id,label:O.config.label,icone:O.config.icone})),currentStep:h}),o.jsx(dh,{step:P,stepIndex:h,formValues:a,errors:p,eventoData:e,onChange:v}),o.jsx(uh,{currentStep:h,isLastStep:A,onBack:N,onNext:w})]})})]})},_l=({id:e,currentTamanho:t,inicioColuna:r,onResize:n})=>{const s=_.useRef(null),[a,i]=_.useState(!1),[l,c]=_.useState(null),d=_.useRef(null);_.useEffect(()=>()=>{var p;(p=d.current)==null||p.call(d)},[]);const m=_.useCallback(p=>{p.preventDefault(),p.stopPropagation();const f=s.current;if(!f)return;const x=f.parentElement;if(!x)return;const g=x.getBoundingClientRect().width,h=f.getBoundingClientRect().width,v=p.clientX,b=r?13-r:12;i(!0);const w=C=>{const j=C.clientX-v,P=(h+j)/g,y=Math.max(1,Math.min(b,Math.round(P*12)));c(y),n(y)},N=()=>{i(!1),c(null),d.current=null,window.removeEventListener("mousemove",w),window.removeEventListener("mouseup",N)};d.current=()=>{i(!1),c(null),window.removeEventListener("mousemove",w),window.removeEventListener("mouseup",N)},window.addEventListener("mousemove",w),window.addEventListener("mouseup",N)},[r,n]);return{resizeRef:s,resizing:a,resizePreview:l,handleResizeStart:m}},vh=({id:e,elementRef:t,onPositionApply:r,setPositionDrag:n,setSelected:s})=>{const a=_.useRef(null);return _.useEffect(()=>()=>{var l;(l=a.current)==null||l.call(a)},[]),{handlePositionMouseDown:_.useCallback(l=>{l.preventDefault(),l.stopPropagation(),s(e);const c=t.current;if(!c)return;const d=c.parentElement;if(!d)return;const m=d.getBoundingClientRect(),p=m.width/12,f=c.getBoundingClientRect(),x=Math.max(1,Math.round(f.width/p)),g=f.left-m.left,h=l.clientX-f.left,v=C=>{const j=C-m.left-h,S=Math.round(j/p)+1;return Math.max(1,Math.min(13-x,S))},b=Math.max(1,Math.min(12,Math.round(g/p)+1));n({itemId:e,ghostStart:b,ghostSpan:x,cursorX:l.clientX,cursorY:l.clientY});const w=C=>{n({itemId:e,ghostStart:v(C.clientX),ghostSpan:x,cursorX:C.clientX,cursorY:C.clientY})},N=C=>{r(v(C.clientX)),n(null),a.current=null,window.removeEventListener("mousemove",w),window.removeEventListener("mouseup",N)};a.current=()=>{n(null),window.removeEventListener("mousemove",w),window.removeEventListener("mouseup",N)},window.addEventListener("mousemove",w),window.addEventListener("mouseup",N)},[e,t,r,n,s])}},Bt=({id:e,container:t})=>{const{attributes:r,listeners:n,setNodeRef:s,transform:a,transition:i,isDragging:l}=Fe.useSortable({id:e,data:{isCanvasItem:!0,type:"field",id:e,fromContainer:t}}),{selectedId:c,setSelected:d,getConfig:m,updateConfig:p,removeItem:f,setPositionDrag:x,positionDrag:g}=ke(),h=m(e),v=as(e),b=(v==null?void 0:v.icon)||T.Type,w=c===e,N=h.tamanho||6,C=(g==null?void 0:g.itemId)===e,{resizeRef:j,resizing:S,resizePreview:P,handleResizeStart:y}=_l({id:e,currentTamanho:N,inicioColuna:h.inicioColuna,onResize:I=>p(e,{tamanho:I})}),{handlePositionMouseDown:A}=vh({id:e,elementRef:j,onPositionApply:I=>p(e,{inicioColuna:I}),setPositionDrag:x,setSelected:d});return o.jsxs("div",{ref:I=>{s(I),j.current=I},onClick:I=>{I.stopPropagation(),d(e)},"data-field-id":e,className:W("group relative flex items-center gap-2 rounded border bg-card/80 backdrop-blur-sm px-2.5 py-1.5 pb-3 cursor-pointer transition-all text-xs",S&&"ring-2 ring-blue-400/50",C&&"opacity-0 pointer-events-none",w?"border-primary ring-2 ring-primary/30 shadow-md":"border-border/60 hover:border-muted-foreground/50 shadow-sm"),style:{gridColumn:h.inicioColuna?`${h.inicioColuna} / span ${N}`:`span ${N}`,transform:Mt.CSS.Transform.toString(a),transition:i,opacity:l?0:1},children:[o.jsx("div",{onMouseDown:A,onClick:I=>I.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(T.ArrowLeftRight,{className:"h-3 w-3 text-primary/60"})}),o.jsx("div",{...n,...r,className:"cursor-grab shrink-0",onClick:I=>I.stopPropagation(),children:o.jsx(T.GripVertical,{className:"h-3 w-3 text-muted-foreground"})}),o.jsx(b,{className:"h-3.5 w-3.5 text-primary shrink-0"}),o.jsx("span",{className:"font-medium truncate flex-1",children:h.label}),h.condition&&o.jsx(T.Zap,{className:"h-3 w-3 text-amber-500 shrink-0"}),h.required&&o.jsx("span",{className:"text-destructive font-bold",children:"*"}),o.jsxs("span",{className:"text-[9px] text-muted-foreground shrink-0",children:[P??N,"/12"]}),o.jsx("button",{onClick:I=>{I.stopPropagation(),f(e)},className:"opacity-0 group-hover:opacity-100 transition-opacity shrink-0 p-0.5 rounded hover:bg-destructive/10",children:o.jsx(T.Trash2,{className:"h-3 w-3 text-destructive"})}),o.jsx("div",{className:"absolute -bottom-0.5 left-2 text-[8px] text-muted-foreground/30 font-mono truncate max-w-[90%] pointer-events-none",children:e}),o.jsx("div",{"data-resize":!0,onMouseDown:y,className:"absolute right-0 top-0 bottom-0 w-2 cursor-col-resize hover:bg-primary/20 transition-colors flex items-center justify-center",children:o.jsx(T.GripHorizontal,{className:"h-3 w-3 text-primary/40 rotate-90"})})]})},bh=({id:e,container:t})=>{var j;const{attributes:r,listeners:n,setNodeRef:s,transform:a,transition:i,isDragging:l}=Fe.useSortable({id:e,data:{isCanvasItem:!0,type:"field",id:e,fromContainer:t}}),{setNodeRef:c,isOver:d}=jt.useDroppable({id:`zone-${e}`}),{selectedId:m,setSelected:p,getConfig:f,removeItem:x,moveItem:g,containers:h}=ke(),v=f(e),w=(((j=h[e])==null?void 0:j.children)??[]).filter(S=>me(S)==="field"),N=m===e,C=v.tamanho||12;return o.jsxs("div",{ref:s,onClick:S=>{S.stopPropagation(),p(e)},className:W("group/fa relative rounded-lg border overflow-hidden transition-all",l&&"opacity-0 pointer-events-none",N?"border-amber-500 ring-2 ring-amber-500/20 shadow-lg":"border-amber-500/30 hover:border-amber-500/50"),style:{gridColumn:v.inicioColuna?`${v.inicioColuna} / span ${C}`:`span ${C}`,transform:Mt.CSS.Transform.toString(a),transition:i},children:[o.jsxs("div",{className:W("flex items-center gap-1.5 border-b px-2 py-1.5 transition-colors",N?"bg-amber-500/15 border-amber-500/30":"bg-amber-500/10 border-amber-500/20"),children:[o.jsx("div",{...n,...r,className:"cursor-grab shrink-0 p-1 -ml-1 rounded hover:bg-amber-500/20 active:cursor-grabbing transition-colors",onClick:S=>S.stopPropagation(),children:o.jsx(T.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:S=>{S.stopPropagation(),g(e,"up")},className:"p-0 hover:bg-amber-500/10 rounded transition-colors",title:"Mover para cima",children:o.jsx(T.ChevronUp,{className:"h-3 w-3 text-muted-foreground hover:text-amber-500"})}),o.jsx("button",{onClick:S=>{S.stopPropagation(),g(e,"down")},className:"p-0 hover:bg-amber-500/10 rounded transition-colors",title:"Mover para baixo",children:o.jsx(T.ChevronDown,{className:"h-3 w-3 text-muted-foreground hover:text-amber-500"})})]}),o.jsx(T.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:v.label}),o.jsxs("span",{className:"text-[10px] text-muted-foreground shrink-0 bg-amber-500/10 px-1.5 rounded",children:[v.itemLabel||"Item"," · ",w.length," campo",w.length!==1?"s":""]}),o.jsx("button",{onClick:S=>{S.stopPropagation(),x(e)},className:"opacity-0 group-hover/fa:opacity-100 transition-opacity shrink-0 p-0.5 rounded hover:bg-destructive/10",children:o.jsx(T.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:c,className:W("relative p-2 min-h-[40px] gap-1.5 transition-all duration-150",d?"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:[w.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(Fe.SortableContext,{items:w,strategy:Fe.rectSortingStrategy,children:w.map(S=>o.jsx(Bt,{id:S,container:e},S))})]})]})},os=5,yh=({id:e,elementRef:t,tamanho:r,inicioColuna:n,onPositionApply:s,setPositionDrag:a,setSelected:i,reorderStrategy:l})=>{const c=_.useRef({inicioColuna:n,tamanho:r});c.current={inicioColuna:n,tamanho:r};const d=_.useRef(null);return _.useEffect(()=>()=>{var p;(p=d.current)==null||p.call(d)},[]),{handleGripMouseDown:_.useCallback(p=>{p.preventDefault(),p.stopPropagation(),i(e);const f=p.clientX,x=p.clientY;let g=!1;const h=()=>{d.current=null,window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",b)},v=C=>{const j=Math.abs(C.clientX-f),S=Math.abs(C.clientY-x);j<os&&S<os||(g=!0,h(),j>=S?w(C):N(C))},b=()=>{g||h()};window.addEventListener("mousemove",v),window.addEventListener("mouseup",b),d.current=h;const w=C=>{const j=t.current;if(!j)return;const S=j.parentElement;if(!S)return;const P=S.getBoundingClientRect(),A=P.width/12,{tamanho:I}=c.current,O=j.getBoundingClientRect(),D=O.left-P.left,F=Math.max(1,Math.min(12,Math.round(D/A)+1)),z=O.left;a({itemId:e,ghostStart:F,ghostSpan:I,cursorX:C.clientX,cursorY:C.clientY});const V=R=>{const $=R-z,L=Math.round($/A)+1;return Math.max(1,Math.min(13-I,L))};a({itemId:e,ghostStart:V(C.clientX),ghostSpan:I,cursorX:C.clientX,cursorY:C.clientY});const k=R=>{a({itemId:e,ghostStart:V(R.clientX),ghostSpan:I,cursorX:R.clientX,cursorY:R.clientY})},E=R=>{s(V(R.clientX)),a(null),d.current=null,window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",E)};window.addEventListener("mousemove",k),window.addEventListener("mouseup",E),d.current=()=>{a(null),window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",E)}},N=C=>{const j=l,S=t.current;if(!S)return;const P=S.parentElement;if(!P)return;const y=j.dataAttribute||"data-container-id";j.pushSnapshot(),j.setReorderDrag({draggingId:e});let A=C.clientY;const I=D=>{const F=Array.from(P.children).filter(z=>z!==S&&z.getAttribute(y));for(const z of F){const V=z.getBoundingClientRect(),k=V.top+V.height/2;if(D.clientY<k&&D.clientY>V.top&&D.clientY<A){j.moveItemNoSnapshot(e,"up"),A=D.clientY;break}else if(D.clientY>k&&D.clientY<V.bottom&&D.clientY>A){j.moveItemNoSnapshot(e,"down"),A=D.clientY;break}}},O=()=>{j.setReorderDrag(null),d.current=null,window.removeEventListener("mousemove",I),window.removeEventListener("mouseup",O)};window.addEventListener("mousemove",I),window.addEventListener("mouseup",O),d.current=()=>{j.setReorderDrag(null),window.removeEventListener("mousemove",I),window.removeEventListener("mouseup",O)}}},[e,t,s,a,i,l])}},un=({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]})})]}),mn=({id:e,container:t})=>{var k;const{setNodeRef:r,isOver:n}=jt.useDroppable({id:`zone-${e}`}),{selectedId:s,setSelected:a,getConfig:i,updateConfig:l,removeItem:c,moveItem:d,moveItemNoSnapshot:m,setPositionDrag:p,positionDrag:f,reorderDrag:x,setReorderDrag:g,pushSnapshot:h,containers:v}=ke(),b=i(e),w=((k=v[e])==null?void 0:k.children)??[],N=w.filter(E=>me(E)==="field"),C=s===e,j=b.tamanho||12,S=(f==null?void 0:f.itemId)===e,P=(x==null?void 0:x.draggingId)===e,y=f&&w.includes(f.itemId),A=s&&w.includes(s)&&me(s)==="field",{resizeRef:I,resizing:O,resizePreview:D,handleResizeStart:F}=_l({id:e,currentTamanho:j,inicioColuna:b.inicioColuna,onResize:E=>l(e,{tamanho:E})}),z=_.useMemo(()=>({kind:"custom",moveItemNoSnapshot:m,pushSnapshot:h,setReorderDrag:g,dataAttribute:"data-container-id"}),[m,h,g]),{handleGripMouseDown:V}=yh({id:e,elementRef:I,tamanho:j,inicioColuna:b.inicioColuna||1,onPositionApply:E=>l(e,{inicioColuna:E}),setPositionDrag:p,setSelected:a,reorderStrategy:z});return o.jsxs(o.Fragment,{children:[o.jsxs("div",{ref:E=>{I.current=E},onClick:E=>{E.stopPropagation(),a(e)},className:W("group/cont relative rounded-lg border overflow-hidden transition-all",O&&"ring-2 ring-blue-400/50",S&&"opacity-0 pointer-events-none",P&&"opacity-50 ring-2 ring-primary/40",C?"border-primary ring-2 ring-primary/20 shadow-lg":"border-blue-500/30 hover:border-blue-500/50"),"data-container-id":e,style:{gridColumn:b.inicioColuna?`${b.inicioColuna} / span ${j}`:`span ${j}`,minWidth:"80px"},children:[o.jsxs("div",{className:W("flex items-center gap-1.5 border-b px-2 py-1.5 transition-colors",C?"bg-primary/15 border-primary/30":"bg-blue-500/10 border-blue-500/20"),children:[o.jsx("div",{"data-grip":!0,onMouseDown:V,className:"cursor-grab shrink-0 p-1 -ml-1 rounded hover:bg-primary/20 active:cursor-grabbing transition-colors",children:o.jsx(T.GripVertical,{className:"h-3.5 w-3.5 text-primary"})}),o.jsxs("div",{className:"flex flex-col -my-1 shrink-0",children:[o.jsx("button",{onClick:E=>{E.stopPropagation(),d(e,"up")},className:"p-0 hover:bg-primary/10 rounded transition-colors",title:"Mover para cima",children:o.jsx(T.ChevronUp,{className:"h-3 w-3 text-muted-foreground hover:text-primary"})}),o.jsx("button",{onClick:E=>{E.stopPropagation(),d(e,"down")},className:"p-0 hover:bg-primary/10 rounded transition-colors",title:"Mover para baixo",children:o.jsx(T.ChevronDown,{className:"h-3 w-3 text-muted-foreground hover:text-primary"})})]}),o.jsx(T.BoxSelect,{className:"h-3.5 w-3.5 text-blue-500 shrink-0"}),o.jsx("span",{className:W("text-xs font-semibold truncate flex-1",b.showLabel===!1?"text-blue-400/50 dark:text-blue-500/40 italic":"text-blue-700 dark:text-blue-300"),children:b.label}),b.showAsCard&&o.jsx(T.SquareStack,{className:"h-3 w-3 text-blue-400 shrink-0"}),b.showLabel===!1&&o.jsx(T.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:[D??j,"/12"]}),o.jsx("button",{onClick:E=>{E.stopPropagation(),c(e)},className:"opacity-0 group-hover/cont:opacity-100 transition-opacity shrink-0 p-0.5 rounded hover:bg-destructive/10",children:o.jsx(T.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:r,className:W("relative p-2 min-h-[40px] gap-1.5 transition-all duration-150",n?"bg-primary/15 ring-2 ring-inset ring-primary/50":(y||A)&&"bg-muted/30"),style:{display:"grid",gridTemplateColumns:"repeat(12, minmax(0, 1fr))",gridAutoRows:"min-content"},children:[o.jsx(un,{showGuides:!!y||!!A,positionDrag:y?f:null}),w.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(Fe.SortableContext,{items:N,strategy:Fe.rectSortingStrategy,children:w.filter(E=>me(E)==="field").map(E=>i(E).fieldType==="field_array"?o.jsx(bh,{id:E,container:e},E):o.jsx(Bt,{id:E,container:e},E))})]}),o.jsx("div",{onMouseDown:F,className:"absolute right-0 top-0 bottom-0 w-2 cursor-col-resize hover:bg-blue-500/20 transition-colors flex items-center justify-center",children:o.jsx(T.GripHorizontal,{className:"h-3 w-3 text-blue-500/40 rotate-90"})})]}),S&&f&&So.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(T.BoxSelect,{className:"h-2.5 w-2.5"}),"col ",f.ghostStart,"–",f.ghostStart+f.ghostSpan-1]}),document.body)," "]})},Dl=({id:e,container:t,index:r})=>{var S;const{attributes:n,listeners:s,setNodeRef:a,transform:i,transition:l,isDragging:c}=Fe.useSortable({id:e,data:{isCanvasItem:!0,type:"step",id:e}}),{setNodeRef:d,isOver:m}=jt.useDroppable({id:`zone-${e}`}),{selectedId:p,setSelected:f,getConfig:x,removeItem:g,containers:h,positionDrag:v}=ke(),b=x(e),w=((S=h[e])==null?void 0:S.children)??[],N=p===e,C=v&&w.includes(v.itemId),j={transform:Mt.CSS.Transform.toString(i),transition:l,opacity:c?0:1};return o.jsxs("div",{ref:a,style:j,onClick:P=>{P.stopPropagation(),f(e)},className:W("group/step rounded-xl border-2 overflow-hidden transition-all",N?"border-primary ring-2 ring-primary/20":"border-primary/20 hover:border-primary/40"),children:[o.jsxs("div",{className:"flex items-center gap-2 bg-primary/10 border-b border-primary/20 px-3 py-2",children:[o.jsx("div",{...s,...n,className:"cursor-grab shrink-0",onClick:P=>P.stopPropagation(),children:o.jsx(T.GripVertical,{className:"h-3.5 w-3.5 text-muted-foreground"})}),o.jsx(T.Layers,{className:"h-4 w-4 text-primary"}),o.jsxs("span",{className:"text-sm font-bold text-primary truncate flex-1",children:["Step ",r+1," — ",b.label]}),b.description&&o.jsx("span",{className:"text-[10px] text-muted-foreground truncate hidden md:block",children:b.description}),o.jsx("button",{onClick:P=>{P.stopPropagation(),g(e)},className:"opacity-0 group-hover/step:opacity-100 transition-opacity shrink-0 p-1 rounded hover:bg-destructive/10",children:o.jsx(T.Trash2,{className:"h-3.5 w-3.5 text-destructive"})})]}),o.jsxs("div",{ref:d,className:W("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(un,{showGuides:!!C,positionDrag:C?v:null}),w.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"}),w.map(P=>me(P)==="container"?o.jsx(mn,{id:P,container:e},P):o.jsx(Bt,{id:P,container:e},P))]})]})},wh=()=>{var i;const{containers:e,setSelected:t}=ke(),r=((i=e.root)==null?void 0:i.children)??[],n=r.filter(l=>me(l)==="step"),{setNodeRef:s,isOver:a}=jt.useDroppable({id:"root"});return o.jsxs("div",{ref:s,onClick:()=>t(null),className:`min-h-[500px] rounded-xl border p-4 space-y-4 transition-all duration-150 ${a?"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:a?void 0:"hsl(var(--muted) / 0.3)"},children:[r.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(T.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(Fe.SortableContext,{items:n,strategy:Fe.verticalListSortingStrategy,children:r.map((l,c)=>{const d=me(l);return d==="step"?o.jsx(Dl,{id:l,container:"root",index:c},l):d==="container"?o.jsx(mn,{id:l,container:"root"},l):o.jsx(Bt,{id:l,container:"root"},l)})})]})},Nh={personal:"Pessoal",address:"Endereço",health:"Saúde",event:"Evento",payment:"Pagamento",emergency:"Emergência"},Ch={texto:"Texto",selecao:"Seleção",range:"Numérico / Visual",data:"Data e Hora",contato:"Contato / Endereço",outros:"Arquivo / Outros"},jh=()=>{const e=at.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"}),ss.map(t=>o.jsx(ns,{component:t.component,label:t.label,icon:t.icon,color:t.color},t.component))]}),Object.entries(e).map(([t,r])=>o.jsx(ro,{label:Ch[t]??t,children:r.map(n=>o.jsx(ns,{component:n.component,label:n.label,icon:n.icon,color:"border-border"},n.component))},t)),o.jsx(ro,{label:"Blocos pré-configurados",defaultOpen:!1,children:Ye.PRESET_BLOCKS.map(t=>o.jsx(Sh,{block:t},t.id))}),o.jsx(ro,{label:"Blocos de steps",defaultOpen:!1,children:Ye.PRESET_STEP_BLOCKS.map(t=>o.jsx(Ph,{block:t},t.id))})]})},ro=({label:e,children:t,defaultOpen:r=!0})=>{const[n,s]=_.useState(r);return o.jsxs("div",{className:"space-y-2",children:[o.jsxs("button",{type:"button",onClick:()=>s(a=>!a),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(T.ChevronDown,{className:`h-3.5 w-3.5 transition-transform ${n?"":"-rotate-90"}`})]}),n&&o.jsx("div",{className:"space-y-1.5",children:t})]})},ns=({component:e,label:t,icon:r,color:n})=>{const{attributes:s,listeners:a,setNodeRef:i,transform:l,isDragging:c}=jt.useDraggable({id:`palette-${e}`,data:{isPaletteItem:!0,componentType:e}});return o.jsxs("div",{ref:i,...a,...s,className:`flex items-center gap-2 rounded-lg border px-3 py-2 cursor-grab select-none hover:bg-accent transition-colors ${n} ${c?"opacity-50":""}`,style:{transform:c?void 0:Mt.CSS.Translate.toString(l)},children:[o.jsx(T.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})]})},Sh=({block:e})=>{const{attributes:t,listeners:r,setNodeRef:n,transform:s,isDragging:a}=jt.useDraggable({id:`preset-${e.id}`,data:{isPalettePreset:!0,presetId:e.id}}),i=e.icon?Lt[e.icon]:void 0,l=Nh[e.category]??e.category;return o.jsxs("div",{ref:n,...r,...t,className:`flex items-center gap-2 rounded-lg border border-primary/30 bg-primary/5 px-3 py-2 cursor-grab select-none hover:bg-primary/10 transition-colors ${a?"opacity-50":""}`,style:{transform:a?void 0:Mt.CSS.Translate.toString(s)},title:e.description,children:[o.jsx(T.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(Lt.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})]})]})},Ph=({block:e})=>{const{addPresetStepBlock:t}=ke(),r=e.icon?Lt[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(Lt.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"]})]})},oo=e=>({when:e.campoId,operator:e.operador,value:e.valor,source:e.source}),Ml=e=>{var r;const t={campoId:e.when,operador:e.operator,valor:e.value,source:e.source};if(e.logicOperator&&((r=e.extraConditions)!=null&&r.length)){const n=e.extraConditions.map(a=>({campoId:a.when,operador:a.operator,valor:a.value,source:a.source})),s=[t,...n];return e.logicOperator==="or"?{or:s}:{and:s}}return t},$l=e=>{if("campoId"in e)return oo(e);const t=("and"in e?e.and:e.or)??[];if(t.length===0)return;const r="and"in e?"and":"or",[n,...s]=t;if(!("campoId"in n))return;const a=oo(n);return s.length===0?a:{...a,logicOperator:r,extraConditions:s.filter(i=>"campoId"in i).map(oo)}},Rh=(e,t,r)=>{var i,l;const n=c=>t[c]||{label:c,name:c},a=(((l=(i=e==null?void 0:e.containers)==null?void 0:i.root)==null?void 0:l.children)||[]).filter(c=>me(c)==="step").map((c,d)=>{var x,g;const m=n(c),f=(((g=(x=e==null?void 0:e.containers)==null?void 0:x[c])==null?void 0:g.children)||[]).filter(h=>me(h)==="container").map((h,v)=>{var j,S;const b=n(h),N=(((S=(j=e==null?void 0:e.containers)==null?void 0:j[h])==null?void 0:S.children)||[]).filter(P=>me(P)==="field").map((P,y)=>{var O,D;const A=n(P),I=Co(A,P,y);if(I.tipo===de.FieldType.FIELD_ARRAY){const F=((D=(O=e==null?void 0:e.containers)==null?void 0:O[P])==null?void 0:D.children)??[];I.subFields=F.filter(z=>me(z)==="field").map((z,V)=>Co(n(z),z,V))}return I}),C={id:h,titulo:b.label||"Container",descricao:b.description,icone:b.icone,ordem:v,colunas:b.columns||2,tamanho:b.tamanho||12,inicioColuna:b.inicioColuna,showLabel:b.showLabel,showAsCard:b.showAsCard,campos:N};return b.condition&&(C.condicional=Ml(b.condition)),C});return{id:c,titulo:m.label||"Step",descricao:m.description,icone:m.icone,ordem:d,showLabel:m.showLabel,containers:f}});return{id:r.id||"",nome:r.nome,descricao:r.descricao,status:r.status,template:r.template??null,steps:a}},Co=(e,t,r)=>{var s,a,i,l;const n={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((s=e.validate)!=null&&s.length&&(n.validate=e.validate),(a=e.warn)!=null&&a.length&&(n.warn=e.warn),(i=e.options)!=null&&i.length&&(n.opcoes=e.options.map(c=>({valor:c.value,label:c.label,disabled:c.disabled}))),e.validation){const c=e.validation;n.validacao={},c.minLength!==void 0&&(n.validacao.minLength=c.minLength),c.maxLength!==void 0&&(n.validacao.maxLength=c.maxLength),c.min!==void 0&&(n.validacao.min=c.min),c.max!==void 0&&(n.validacao.max=c.max),c.regex&&(n.validacao.regex=c.regex),c.regexMessage&&(n.validacao.regexMessage=c.regexMessage),c.minDate&&(n.validacao.minDate=c.minDate),c.maxDate&&(n.validacao.maxDate=c.maxDate),c.minAge!==void 0&&(n.validacao.minAge=c.minAge),c.maxAge!==void 0&&(n.validacao.maxAge=c.maxAge),(l=c.fileTypes)!=null&&l.length&&(n.validacao.fileTypes=c.fileTypes),c.maxFileSize!==void 0&&(n.validacao.maxFileSize=c.maxFileSize)}if(n.tipo===de.FieldType.FIELD_ARRAY&&(e.itemLabel&&(n.itemLabel=e.itemLabel),e.minItems!==void 0&&(n.minItems=e.minItems),e.maxItems!==void 0&&(n.maxItems=e.maxItems),e.addLabel&&(n.addLabel=e.addLabel)),n.tipo===de.FieldType.TERMS&&(e.termoTexto&&(n.termoTexto=e.termoTexto),e.termoPdfUrl&&(n.termoPdfUrl=e.termoPdfUrl),e.termoPdfUploadId&&(n.termoPdfUploadId=e.termoPdfUploadId)),n.tipo===de.FieldType.SLIDER&&(e.step!==void 0&&(n.step=e.step),e.minValue!==void 0&&(n.minValue=e.minValue),e.maxValue!==void 0&&(n.maxValue=e.maxValue)),n.tipo===de.FieldType.RATING&&e.maxRating!==void 0&&(n.maxRating=e.maxRating),n.tipo===de.FieldType.DATE_RANGE&&(e.dateRangeStartLabel&&(n.dateRangeStartLabel=e.dateRangeStartLabel),e.dateRangeEndLabel&&(n.dateRangeEndLabel=e.dateRangeEndLabel)),n.tipo===de.FieldType.SUB_FORM){const c=e.subSchemaFields??[];(c.length>0||e.subSchemaTitle)&&(n.subSchema={titulo:e.subSchemaTitle,fields:c.map((d,m)=>Co(d,d.name??`subfield-${m}`,m))})}return e.condition&&(n.condicional=Ml(e.condition)),n},Eh=e=>{const t={},r={root:{children:[]}},n=[...e.steps].sort((s,a)=>s.ordem-a.ordem);for(const s of n){const a=s.id||`step-${de.v4Fallback()}`;r.root.children.push(a),t[a]={label:s.titulo,name:a,fieldType:"step",description:s.descricao,icone:s.icone,showLabel:s.showLabel};const i=[],l=[...s.containers].sort((c,d)=>c.ordem-d.ordem);for(const c of l){const d=c.id||`container-${de.v4Fallback()}`;i.push(d);const m=c.condicional?$l(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,...m?{condition:m}:{}};const p=[],f=[...c.campos].sort((x,g)=>x.ordem-g.ordem);for(const x of f){const g=x.id||`${x.tipo}-${de.v4Fallback()}`;if(p.push(g),t[g]=jo(x),x.tipo===de.FieldType.FIELD_ARRAY){const h=[];for(const v of x.subFields??[]){const b=v.id||`${v.tipo}-${de.v4Fallback()}`;h.push(b),t[b]=jo(v)}r[g]={children:h}}}r[d]={children:p}}r[a]={children:i}}return{dndState:{containers:r},configs:t,templateId:e.template??null}},jo=(e,t)=>{var n,s,a,i;const r={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!=null?String(e.clearedValue):void 0,initialValue:e.initialValue!==void 0?String(e.initialValue):void 0,resolvePropsKey:e.resolvePropsKey||void 0,validate:(n=e.validate)!=null&&n.length?e.validate:void 0,warn:(s=e.warn)!=null&&s.length?e.warn:void 0};if((a=e.opcoes)!=null&&a.length&&(r.options=e.opcoes.map(l=>({value:l.valor,label:l.label,disabled:l.disabled}))),e.validacao){const l=e.validacao;r.validation={},l.minLength!==void 0&&(r.validation.minLength=l.minLength),l.maxLength!==void 0&&(r.validation.maxLength=l.maxLength),l.min!==void 0&&(r.validation.min=l.min),l.max!==void 0&&(r.validation.max=l.max),l.regex&&(r.validation.regex=l.regex),l.regexMessage&&(r.validation.regexMessage=l.regexMessage),l.minDate&&(r.validation.minDate=l.minDate),l.maxDate&&(r.validation.maxDate=l.maxDate),l.minAge!==void 0&&(r.validation.minAge=l.minAge),l.maxAge!==void 0&&(r.validation.maxAge=l.maxAge),(i=l.fileTypes)!=null&&i.length&&(r.validation.fileTypes=l.fileTypes),l.maxFileSize!==void 0&&(r.validation.maxFileSize=l.maxFileSize)}if(e.tipo===de.FieldType.FIELD_ARRAY&&(e.itemLabel&&(r.itemLabel=e.itemLabel),e.minItems!==void 0&&(r.minItems=e.minItems),e.maxItems!==void 0&&(r.maxItems=e.maxItems),e.addLabel&&(r.addLabel=e.addLabel)),e.tipo===de.FieldType.TERMS&&(e.termoTexto&&(r.termoTexto=e.termoTexto),e.termoPdfUrl&&(r.termoPdfUrl=e.termoPdfUrl),e.termoPdfUploadId&&(r.termoPdfUploadId=e.termoPdfUploadId)),e.tipo===de.FieldType.SLIDER&&(e.step!==void 0&&(r.step=e.step),e.minValue!==void 0&&(r.minValue=e.minValue),e.maxValue!==void 0&&(r.maxValue=e.maxValue)),e.tipo===de.FieldType.RATING&&e.maxRating!==void 0&&(r.maxRating=e.maxRating),e.tipo===de.FieldType.DATE_RANGE&&(e.dateRangeStartLabel&&(r.dateRangeStartLabel=e.dateRangeStartLabel),e.dateRangeEndLabel&&(r.dateRangeEndLabel=e.dateRangeEndLabel)),e.tipo===de.FieldType.SUB_FORM&&e.subSchema&&(r.subSchemaTitle=e.subSchema.titulo,r.subSchemaFields=e.subSchema.fields.map(l=>jo(l,l.id))),e.condicional){const l=$l(e.condicional);l&&(r.condition=l)}return r},Ah=(e,t)=>{var l,c,d,m,p,f,x;const r=[],n=[],s=g=>t[g]||{label:g,name:g},a=((c=(l=e==null?void 0:e.containers)==null?void 0:l.root)==null?void 0:c.children)||[],i=new Set;for(const g of a){if(me(g)!=="step")continue;const h=s(g).label||g,v=((m=(d=e==null?void 0:e.containers)==null?void 0:d[g])==null?void 0:m.children)||[];if(v.length===0){n.push(`Step "${h}" está vazio (sem containers).`);continue}for(const b of v){if(me(b)!=="container")continue;const w=s(b).label||b,N=((f=(p=e==null?void 0:e.containers)==null?void 0:p[b])==null?void 0:f.children)||[],C=new Map;for(const j of N){if(me(j)!=="field")continue;i.add(j);const S=s(j).name||j;C.has(S)||C.set(S,[]),C.get(S).push(j)}for(const[j,S]of C.entries())S.length>1&&r.push(`Nome duplicado "${j}" no container "${w}" (IDs: ${S.join(", ")}).`)}}for(const[g,h]of Object.entries(t)){if(!((x=h.condition)!=null&&x.when))continue;const v=h.condition.when;if(!i.has(v)){const b=h.label||g;n.push(`Campo "${b}" referencia campo inexistente na condição (when: "${v}").`)}}return{errors:r,warnings:n}};exports.BuilderProvider=Bl;exports.Canvas=wh;exports.ConfigPanel=th;exports.DroppedContainer=mn;exports.DroppedField=Bt;exports.DroppedStep=Dl;exports.EVENT_VARIABLES=Ro;exports.FIELD_TYPES=at;exports.GridOverlay=un;exports.LivePreview=gh;exports.Palette=jh;exports.STRUCTURE_TYPES=ss;exports.builderToFormSchema=Rh;exports.findParentContainer=cs;exports.formSchemaToBuilder=Eh;exports.getFieldMeta=zl;exports.getFieldMetaById=as;exports.getItemType=me;exports.useBuilder=ke;exports.validateBuilderIntegrity=Ah;
|
|
50
|
+
Defaulting to \`null\`.`}var wl=gl,jf=bl;const Nl=u.forwardRef(({className:e,value:t,...r},n)=>o.jsx(wl,{ref:n,className:W("relative h-4 w-full overflow-hidden rounded-full bg-secondary",e),...r,children:o.jsx(jf,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));Nl.displayName=wl.displayName;var[$r]=Be("Tooltip",[Rt]),Fr=Rt(),Sf="TooltipProvider",bo="tooltip.open",[Th,cn]=$r(Sf),Dt="Tooltip",[Pf,zr]=$r(Dt),Cl=e=>{const{__scopeTooltip:t,children:r,open:n,defaultOpen:s,onOpenChange:a,disableHoverableContent:i,delayDuration:l}=e,c=cn(Dt,e.__scopeTooltip),d=Fr(t),[m,p]=u.useState(null),f=Ke(),x=u.useRef(0),g=i??c.disableHoverableContent,h=l??c.delayDuration,v=u.useRef(!1),[b,w]=it({prop:n,defaultProp:s??!1,onChange:P=>{P?(c.onOpen(),document.dispatchEvent(new CustomEvent(bo))):c.onClose(),a==null||a(P)},caller:Dt}),N=u.useMemo(()=>b?v.current?"delayed-open":"instant-open":"closed",[b]),C=u.useCallback(()=>{window.clearTimeout(x.current),x.current=0,v.current=!1,w(!0)},[w]),j=u.useCallback(()=>{window.clearTimeout(x.current),x.current=0,w(!1)},[w]),S=u.useCallback(()=>{window.clearTimeout(x.current),x.current=window.setTimeout(()=>{v.current=!0,w(!0),x.current=0},h)},[h,w]);return u.useEffect(()=>()=>{x.current&&(window.clearTimeout(x.current),x.current=0)},[]),o.jsx(en,{...d,children:o.jsx(Pf,{scope:t,contentId:f,open:b,stateAttribute:N,trigger:m,onTriggerChange:p,onTriggerEnter:u.useCallback(()=>{c.isOpenDelayedRef.current?S():C()},[c.isOpenDelayedRef,S,C]),onTriggerLeave:u.useCallback(()=>{g?j():(window.clearTimeout(x.current),x.current=0)},[j,g]),onOpen:C,onClose:j,disableHoverableContent:g,children:r})})};Cl.displayName=Dt;var yo="TooltipTrigger",jl=u.forwardRef((e,t)=>{const{__scopeTooltip:r,...n}=e,s=zr(yo,r),a=cn(yo,r),i=Fr(r),l=u.useRef(null),c=te(t,l,s.onTriggerChange),d=u.useRef(!1),m=u.useRef(!1),p=u.useCallback(()=>d.current=!1,[]);return u.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),o.jsx(Ar,{asChild:!0,...i,children:o.jsx(J.button,{"aria-describedby":s.open?s.contentId:void 0,"data-state":s.stateAttribute,...n,ref:c,onPointerMove:Y(e.onPointerMove,f=>{f.pointerType!=="touch"&&!m.current&&!a.isPointerInTransitRef.current&&(s.onTriggerEnter(),m.current=!0)}),onPointerLeave:Y(e.onPointerLeave,()=>{s.onTriggerLeave(),m.current=!1}),onPointerDown:Y(e.onPointerDown,()=>{s.open&&s.onClose(),d.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:Y(e.onFocus,()=>{d.current||s.onOpen()}),onBlur:Y(e.onBlur,s.onClose),onClick:Y(e.onClick,s.onClose)})})});jl.displayName=yo;var Rf="TooltipPortal",[Ih,Ef]=$r(Rf,{forceMount:void 0}),Ct="TooltipContent",Sl=u.forwardRef((e,t)=>{const r=Ef(Ct,e.__scopeTooltip),{forceMount:n=r.forceMount,side:s="top",...a}=e,i=zr(Ct,e.__scopeTooltip);return o.jsx(Se,{present:n||i.open,children:i.disableHoverableContent?o.jsx(Pl,{side:s,...a,ref:t}):o.jsx(Af,{side:s,...a,ref:t})})}),Af=u.forwardRef((e,t)=>{const r=zr(Ct,e.__scopeTooltip),n=cn(Ct,e.__scopeTooltip),s=u.useRef(null),a=te(t,s),[i,l]=u.useState(null),{trigger:c,onClose:d}=r,m=s.current,{onPointerInTransitChange:p}=n,f=u.useCallback(()=>{l(null),p(!1)},[p]),x=u.useCallback((g,h)=>{const v=g.currentTarget,b={x:g.clientX,y:g.clientY},w=Of(b,v.getBoundingClientRect()),N=_f(b,w),C=Df(h.getBoundingClientRect()),j=$f([...N,...C]);l(j),p(!0)},[p]);return u.useEffect(()=>()=>f(),[f]),u.useEffect(()=>{if(c&&m){const g=v=>x(v,m),h=v=>x(v,c);return c.addEventListener("pointerleave",g),m.addEventListener("pointerleave",h),()=>{c.removeEventListener("pointerleave",g),m.removeEventListener("pointerleave",h)}}},[c,m,x,f]),u.useEffect(()=>{if(i){const g=h=>{const v=h.target,b={x:h.clientX,y:h.clientY},w=(c==null?void 0:c.contains(v))||(m==null?void 0:m.contains(v)),N=!Mf(b,i);w?f():N&&(f(),d())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[c,m,i,d,f]),o.jsx(Pl,{...e,ref:a})}),[kf,Tf]=$r(Dt,{isInside:!1}),If=td("TooltipContent"),Pl=u.forwardRef((e,t)=>{const{__scopeTooltip:r,children:n,"aria-label":s,onEscapeKeyDown:a,onPointerDownOutside:i,...l}=e,c=zr(Ct,r),d=Fr(r),{onClose:m}=c;return u.useEffect(()=>(document.addEventListener(bo,m),()=>document.removeEventListener(bo,m)),[m]),u.useEffect(()=>{if(c.trigger){const p=f=>{const x=f.target;x!=null&&x.contains(c.trigger)&&m()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[c.trigger,m]),o.jsx($t,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:p=>p.preventDefault(),onDismiss:m,children:o.jsxs(tn,{"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(If,{children:n}),o.jsx(kf,{scope:r,isInside:!0,children:o.jsx(vp,{id:c.contentId,role:"tooltip",children:s||n})})]})})});Sl.displayName=Ct;var Rl="TooltipArrow",Lf=u.forwardRef((e,t)=>{const{__scopeTooltip:r,...n}=e,s=Fr(r);return Tf(Rl,r).isInside?null:o.jsx(rn,{...s,...n,ref:t})});Lf.displayName=Rl;function Of(e,t){const r=Math.abs(t.top-e.y),n=Math.abs(t.bottom-e.y),s=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(r,n,s,a)){case a:return"left";case s:return"right";case r:return"top";case n:return"bottom";default:throw new Error("unreachable")}}function _f(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 Df(e){const{top:t,right:r,bottom:n,left:s}=e;return[{x:s,y:t},{x:r,y:t},{x:r,y:n},{x:s,y:n}]}function Mf(e,t){const{x:r,y:n}=e;let s=!1;for(let a=0,i=t.length-1;a<t.length;i=a++){const l=t[a],c=t[i],d=l.x,m=l.y,p=c.x,f=c.y;m>n!=f>n&&r<(p-d)*(n-m)/(f-m)+d&&(s=!s)}return s}function $f(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),Ff(t)}function Ff(e){if(e.length<=1)return e.slice();const t=[];for(let n=0;n<e.length;n++){const s=e[n];for(;t.length>=2;){const a=t[t.length-1],i=t[t.length-2];if((a.x-i.x)*(s.y-i.y)>=(a.y-i.y)*(s.x-i.x))t.pop();else break}t.push(s)}t.pop();const r=[];for(let n=e.length-1;n>=0;n--){const s=e[n];for(;r.length>=2;){const a=r[r.length-1],i=r[r.length-2];if((a.x-i.x)*(s.y-i.y)>=(a.y-i.y)*(s.x-i.x))r.pop();else break}r.push(s)}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 zf=Cl,Vf=jl,El=Sl;const Al=zf,kl=Vf,dn=u.forwardRef(({className:e,sideOffset:t=4,...r},n)=>o.jsx(El,{ref:n,sideOffset:t,className:W("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}));dn.displayName=El.displayName;const Bf=To("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground",success:"border-transparent bg-green-500 text-white shadow"}},defaultVariants:{variant:"default"}});function Vr({className:e,variant:t,...r}){return o.jsx("div",{className:W(Bf({variant:t}),e),...r})}const wo=[{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."}]}],Wf=wo.flatMap(e=>e.presets),Hf=({value:e,message:t,onChange:r})=>{const[n,s]=_.useState(!1),[a,i]=_.useState(""),l=_.useMemo(()=>{if(!a.trim())return wo;const p=a.toLowerCase();return wo.map(f=>({...f,presets:f.presets.filter(x=>x.label.toLowerCase().includes(p)||x.description.toLowerCase().includes(p)||x.pattern.toLowerCase().includes(p))})).filter(f=>f.presets.length>0)},[a]),c=_.useMemo(()=>e?Wf.find(p=>p.pattern===e):void 0,[e]),d=p=>{r(p.pattern,`${p.label}: formato inválido`),s(!1),i("")},m=()=>{r(void 0,void 0)};return o.jsxs("div",{className:"space-y-2",children:[o.jsx(B,{className:"text-[10px]",children:"Regex"}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(X,{value:e??"",onChange:p=>r(p.target.value||void 0,t),className:"h-7 text-xs font-mono flex-1",placeholder:"Clique no botão ou digite..."}),e&&o.jsx(le,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:m,children:o.jsx(T.X,{className:"h-3 w-3"})}),o.jsxs(Tr,{open:n,onOpenChange:s,children:[o.jsx(Ir,{asChild:!0,children:o.jsx(le,{variant:"outline",size:"icon",className:"h-7 w-7 shrink-0",children:o.jsx(T.Regex,{className:"h-3.5 w-3.5"})})}),o.jsxs(Vt,{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(T.Search,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),o.jsx(X,{value:a,onChange:p=>i(p.target.value),className:"h-8 text-xs pl-7",placeholder:"Buscar regex (ex: CPF, e-mail, senha)...",autoFocus:!0})]})}),o.jsx(br,{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(p=>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:p.category}),p.presets.map(f=>o.jsxs(Al,{children:[o.jsx(kl,{asChild:!0,children:o.jsxs("button",{onClick:()=>d(f),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(T.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:f.label}),o.jsx("span",{className:"text-[10px] text-muted-foreground font-mono block truncate",children:f.pattern})]})]})}),o.jsxs(dn,{side:"left",className:"max-w-[250px] text-xs",children:[o.jsx("p",{className:"font-semibold mb-1",children:f.label}),o.jsx("p",{children:f.description})]})]},f.pattern+f.label))]},p.category))]})})]})]})]}),c&&o.jsxs(Vr,{variant:"secondary",className:"text-[10px] font-normal gap-1",children:[o.jsx(T.Regex,{className:"h-2.5 w-2.5"}),c.label]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-[10px]",children:"Mensagem do regex"}),o.jsx(X,{value:t??"",onChange:p=>r(e,p.target.value||void 0),className:"h-7 text-xs",placeholder:"Formato inválido"})]})]})},No=[{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"]}]}],Uf=No.flatMap(e=>e.presets),Gf=({value:e,onChange:t})=>{const[r,n]=_.useState(!1),[s,a]=_.useState(""),[i,l]=_.useState(""),c=_.useMemo(()=>new Set(e??[]),[e]),d=_.useMemo(()=>{if(!s.trim())return No;const g=s.toLowerCase();return No.map(h=>({...h,presets:h.presets.filter(v=>v.label.toLowerCase().includes(g)||v.description.toLowerCase().includes(g)||v.value.toLowerCase().includes(g))})).filter(h=>h.presets.length>0)},[s]),m=g=>{const h=new Set(e??[]);g.group?g.group.every(b=>h.has(b))?g.group.forEach(b=>h.delete(b)):g.group.forEach(b=>h.add(b)):h.has(g.value)?h.delete(g.value):h.add(g.value),t(h.size>0?Array.from(h):void 0)},p=()=>{const g=i.trim();if(!g)return;const h=new Set(e??[]);h.add(g),t(Array.from(h)),l("")},f=g=>{const h=new Set(e??[]);h.delete(g),t(h.size>0?Array.from(h):void 0)},x=g=>{const h=Uf.find(v=>v.value===g);return(h==null?void 0:h.label)??g};return o.jsxs("div",{className:"space-y-2",children:[o.jsx(B,{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(g=>o.jsxs(Vr,{variant:"secondary",className:"text-[10px] gap-1 pr-1",children:[x(g),o.jsx("button",{onClick:()=>f(g),className:"hover:text-destructive",children:o.jsx(T.X,{className:"h-2.5 w-2.5"})})]},g))}),o.jsxs(Tr,{open:r,onOpenChange:n,children:[o.jsx(Ir,{asChild:!0,children:o.jsxs(le,{variant:"outline",className:"w-full h-8 text-xs justify-start gap-2",children:[o.jsx(T.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(Vt,{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(T.Search,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),o.jsx(X,{value:s,onChange:g=>a(g.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(X,{value:i,onChange:g=>l(g.target.value),className:"h-7 text-xs font-mono flex-1",placeholder:"Tipo customizado (ex: .dwg)",onKeyDown:g=>g.key==="Enter"&&p()}),o.jsx(le,{variant:"secondary",size:"sm",className:"h-7 text-xs shrink-0",onClick:p,disabled:!i.trim(),children:"Adicionar"})]}),o.jsx(br,{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(g=>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:g.category}),g.presets.map(h=>{const v=h.group?h.group.every(w=>c.has(w)):c.has(h.value),b=h.group?h.group.some(w=>c.has(w))&&!v:!1;return o.jsxs(Al,{children:[o.jsx(kl,{asChild:!0,children:o.jsxs("button",{onClick:()=>m(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(xe,{checked:b?"indeterminate":v,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(T.Info,{className:"h-3 w-3 text-muted-foreground/40 shrink-0"})]})}),o.jsxs(dn,{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(w=>o.jsx("li",{className:"font-mono text-[10px] opacity-80",children:w},w))})]})]},h.value)})]},g.category))]})})]})]})]})},Tl=1048576,mr=1073741824;function Zn(e){return e>=mr&&e%mr===0?"GB":"MB"}function Kn(e,t){return t==="GB"?e/mr:e/Tl}function Jn(e,t){return Math.round(e*(t==="GB"?mr:Tl))}const qf=({value:e,onChange:t})=>{const r=_.useMemo(()=>e?Zn(e):"MB",[]),[n,s]=_.useState(r),[a,i]=_.useState(e?String(Kn(e,r)):"");_.useEffect(()=>{if(e===void 0){i("");return}const d=Zn(e);s(d),i(String(Kn(e,d)))},[e]);const l=d=>{i(d);const m=parseFloat(d);d.trim()===""||isNaN(m)||m<=0?t(void 0):t(Jn(m,n))},c=d=>{s(d);const m=parseFloat(a);!isNaN(m)&&m>0&&t(Jn(m,d))};return o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(B,{className:"text-[10px]",children:"Tamanho máximo do arquivo"}),o.jsxs("div",{className:"flex gap-1.5",children:[o.jsx(X,{type:"number",min:0,step:"any",value:a,onChange:d=>l(d.target.value),placeholder:"Ex: 10",className:"h-8 text-xs flex-1"}),o.jsxs(Ce,{value:n,onValueChange:d=>c(d),children:[o.jsx(ye,{className:"w-[72px] h-8 text-xs",children:o.jsx(je,{})}),o.jsxs(we,{children:[o.jsx(pe,{value:"MB",children:"MB"}),o.jsx(pe,{value:"GB",children:"GB"})]})]})]}),e!==void 0&&o.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["= ",e.toLocaleString("pt-BR")," bytes"]})]})},Xf=new Set(["texto","textarea","email","password","url","phone","tel","cpf","cnpj","cep","rg"]),Yf=({fieldType:e,validation:t,onChange:r})=>{const n=(i,l)=>{const m=["minLength","maxLength","min","max","maxFileSize","minAge","maxAge"].includes(i)?l?Number(l):void 0:l||void 0;r({...t,[i]:m})},s=e==="file",a=Xf.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"}),a&&o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-[10px]",children:"Min caracteres"}),o.jsx(X,{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(B,{className:"text-[10px]",children:"Max caracteres"}),o.jsx(X,{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(B,{className:"text-[10px]",children:"Valor mínimo"}),o.jsx(X,{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(B,{className:"text-[10px]",children:"Valor máximo"}),o.jsx(X,{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(B,{className:"text-[10px]",children:"Data mínima"}),o.jsx(X,{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(B,{className:"text-[10px]",children:"Data máxima"}),o.jsx(X,{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(B,{className:"text-[10px]",children:"Idade mínima (anos)"}),o.jsx(X,{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(B,{className:"text-[10px]",children:"Idade máxima (anos)"}),o.jsx(X,{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"})]})]})]}),s&&o.jsxs("div",{className:"space-y-3",children:[o.jsx(Gf,{value:t==null?void 0:t.fileTypes,onChange:i=>r({...t,fileTypes:i})}),o.jsx(qf,{value:t==null?void 0:t.maxFileSize,onChange:i=>r({...t,maxFileSize:i})})]}),!s&&o.jsx(Hf,{value:(t==null?void 0:t.regex)??"",message:(t==null?void 0:t.regexMessage)??"",onChange:(i,l)=>r({...t,regex:i,regexMessage:l})})]})},Il=({options:e,onChange:t})=>{const r=_.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=_.useCallback((i,l,c)=>{const d=[...e];d[i]={...d[i],[l]:c},t(d)},[e,t]),s=_.useCallback(i=>{r.current.splice(i,1),t(e.filter((l,c)=>c!==i))},[e,t]),a=_.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(T.GripVertical,{className:"h-3 w-3 text-muted-foreground/40 shrink-0"}),o.jsx(X,{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(X,{value:i.label,onChange:c=>n(l,"label",c.target.value),className:"h-7 text-xs flex-1",placeholder:"Label"}),o.jsx($e,{})]}),o.jsx(le,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>s(l),children:o.jsx(T.Trash2,{className:"h-3 w-3"})})]},r.current[l])),o.jsxs(le,{variant:"outline",size:"sm",className:"w-full h-7 text-xs",onClick:a,children:[o.jsx(T.Plus,{className:"h-3 w-3 mr-1"})," Adicionar opção"]})]})},Zf=[{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"}],Kf=["vazio","naoVazio"],Qn=({cond:e,selectedId:t,allFieldIds:r,getFieldLabel:n,onUpdate:s})=>o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-[10px]",children:"Fonte"}),o.jsxs(Ce,{value:e.source||"campo",onValueChange:a=>s({source:a,when:""}),children:[o.jsx(ye,{className:"h-7 text-xs",children:o.jsx(je,{})}),o.jsxs(we,{children:[o.jsx(pe,{value:"campo",children:"Campo do formulário"}),o.jsx(pe,{value:"evento",children:"Variável do evento"})]})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-[10px]",children:e.source==="evento"?"Variável do evento":"Quando o campo"}),o.jsxs(Ce,{value:e.when||"",onValueChange:a=>s({when:a}),children:[o.jsx(ye,{className:"h-7 text-xs",children:o.jsx(je,{placeholder:e.source==="evento"?"Selecione uma variável...":"Selecione um campo..."})}),o.jsx(we,{children:e.source==="evento"?Ro.map(a=>o.jsx(pe,{value:a.key,children:a.label},a.key)):r.filter(a=>a!==t).map(a=>o.jsxs(pe,{value:a,children:[n(a),o.jsxs("span",{className:"text-muted-foreground/50 ml-1 text-[9px] font-mono",children:["(",a,")"]})]},a))})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-[10px]",children:"Operador"}),o.jsxs(Ce,{value:e.operator,onValueChange:a=>s({operator:a}),children:[o.jsx(ye,{className:"h-7 text-xs",children:o.jsx(je,{})}),o.jsx(we,{children:Zf.map(a=>o.jsx(pe,{value:a.value,children:a.label},a.value))})]})]}),!Kf.includes(e.operator)&&o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-[10px]",children:"Valor"}),o.jsx(X,{value:e.value||"",onChange:a=>s({value:a.target.value}),className:"h-7 text-xs",placeholder:"Valor esperado"})]})]}),Jf=({condition:e,selectedId:t,allFieldIds:r,getFieldLabel:n,onChange:s})=>{var m;const a=p=>{e&&s({...e,...p})},i=()=>{if(!e)return;const p=e.extraConditions??[];s({...e,logicOperator:e.logicOperator??"and",extraConditions:[...p,{when:"",operator:"igual",value:"",source:"campo"}]})},l=p=>{if(!e)return;const f=(e.extraConditions??[]).filter((x,g)=>g!==p);s({...e,extraConditions:f,logicOperator:f.length?e.logicOperator:void 0})},c=(p,f)=>{if(!e)return;const x=(e.extraConditions??[]).map((g,h)=>h===p?{...g,...f}:g);s({...e,extraConditions:x})},d=(((m=e==null?void 0:e.extraConditions)==null?void 0:m.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(xe,{id:"has-condition",checked:!!e,onCheckedChange:p=>{s(p?{when:"",operator:"igual",value:"",source:"campo"}:void 0)}}),o.jsx(B,{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(Qn,{cond:e,selectedId:t,allFieldIds:r,getFieldLabel:n,onUpdate:a}),d&&o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-[10px]",children:"Lógica"}),o.jsxs(Ce,{value:e.logicOperator??"and",onValueChange:p=>a({logicOperator:p}),children:[o.jsx(ye,{className:"h-7 text-xs",children:o.jsx(je,{})}),o.jsxs(we,{children:[o.jsx(pe,{value:"and",children:"E (AND) — todas devem ser verdadeiras"}),o.jsx(pe,{value:"or",children:"OU (OR) — pelo menos uma deve ser verdadeira"})]})]})]}),(e.extraConditions??[]).map((p,f)=>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"," ",f+2]}),o.jsx(le,{variant:"ghost",size:"sm",className:"h-5 px-1 text-[10px] text-destructive hover:text-destructive",onClick:()=>l(f),children:"Remover"})]}),o.jsx(Qn,{cond:p,selectedId:t,allFieldIds:r,getFieldLabel:n,onUpdate:x=>c(f,x)})]},f)),o.jsx(le,{variant:"outline",size:"sm",className:"h-6 text-[10px] w-full mt-1",onClick:i,children:"+ Adicionar condição"})]})]})},es=[{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"}],Qf=({subFields:e,onChange:t})=>{const[r,n]=_.useState(null),s=(l,c)=>{const d=e.map((m,p)=>p===l?{...m,...c}:m);t(d)},a=l=>{t(e.filter((c,d)=>d!==l)),n(null)},i=()=>{const l={label:"Novo campo",name:`campo_${e.length+1}`,fieldType:"texto",required:!1};t([...e,l]),n(e.length)};return o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(B,{className:"text-xs font-semibold",children:"Sub-campos"}),o.jsxs(le,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-xs gap-1",onClick:i,children:[o.jsx(T.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((l,c)=>{var d;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===c?null:c),children:[o.jsx(Vr,{variant:"secondary",className:"h-4 text-[9px] px-1 shrink-0",children:c+1}),o.jsx("span",{className:"flex-1 truncate font-medium",children:l.label||l.name||"Campo sem nome"}),o.jsx("span",{className:"text-muted-foreground text-[10px] shrink-0",children:((d=es.find(m=>m.value===l.fieldType))==null?void 0:d.label)??l.fieldType}),o.jsx(le,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 text-destructive hover:text-destructive shrink-0",onClick:m=>{m.stopPropagation(),a(c)},children:o.jsx(T.Trash2,{className:"w-3 h-3"})}),r===c?o.jsx(T.ChevronUp,{className:"w-3 h-3 text-muted-foreground shrink-0"}):o.jsx(T.ChevronDown,{className:"w-3 h-3 text-muted-foreground shrink-0"})]}),r===c&&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(B,{className:"text-[10px]",children:"Label"}),o.jsx(X,{value:l.label,onChange:m=>s(c,{label:m.target.value}),className:"h-7 text-xs",placeholder:"Ex: Nome"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-[10px]",children:"Nome (campo)"}),o.jsx(X,{value:l.name||"",onChange:m=>s(c,{name:m.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(B,{className:"text-[10px]",children:"Tipo de campo"}),o.jsxs(Ce,{value:l.fieldType,onValueChange:m=>s(c,{fieldType:m}),children:[o.jsx(ye,{className:"h-7 text-xs",children:o.jsx(je,{})}),o.jsx(we,{children:es.map(m=>o.jsx(pe,{value:m.value,className:"text-xs",children:m.label},m.value))})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-[10px]",children:"Colunas (1-12)"}),o.jsx(X,{type:"number",min:1,max:12,value:l.tamanho??"",onChange:m=>s(c,{tamanho:m.target.value?Number(m.target.value):void 0}),className:"h-7 text-xs",placeholder:"12"})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-[10px]",children:"Placeholder"}),o.jsx(X,{value:l.placeholder||"",onChange:m=>s(c,{placeholder:m.target.value}),className:"h-7 text-xs",placeholder:"Texto de exemplo..."})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(xe,{id:`sf-req-${c}`,checked:l.required||!1,onCheckedChange:m=>s(c,{required:m===!0})}),o.jsx(B,{htmlFor:`sf-req-${c}`,className:"text-[10px] cursor-pointer",children:"Obrigatório"})]}),["select","radio","checkbox_group"].includes(l.fieldType)&&o.jsx("div",{className:"pt-1",children:o.jsx(Il,{options:l.options||[],onChange:m=>s(c,{options:m})})})]})]},c)}),e.length>0&&o.jsx(Ne,{className:"mt-1"})]})},eh=({config:e,selectedId:t,allFieldIds:r,getFieldLabel:n,onUpdate:s})=>{const a=e.fieldType||"texto",i=["select","radio","checkbox_group","autocomplete"].includes(a),l=a==="field_array",c=e.locked===!0,d=a==="participation_type",m=a==="payment_method",p=a==="terms",f=a==="slider",x=a==="rating",g=a==="date_range",h=a==="sub_form",{schemaId:v,uploadTermsPdf:b}=ke(),[w,N]=_.useState(e.termoPdfUploadId?"upload":"link"),[C,j]=_.useState({status:"idle"}),S=_.useRef(null),P=_.useCallback(async y=>{if(!v){j({status:"error",message:"Salve o schema primeiro para habilitar o upload de PDF."});return}if(!b){j({status:"error",message:"Upload de PDF não configurado. Forneça a prop uploadTermsPdf ao BuilderProvider."});return}j({status:"uploading",fileName:y.name,progress:0});try{const A=await b(y,v);s({termoPdfUploadId:A,termoPdfUrl:void 0}),j({status:"idle"})}catch(A){j({status:"error",message:A instanceof Error?A.message:"Falha no upload do PDF."})}},[v,b,s]);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(T.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(T.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"})]})]}),p&&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(T.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(B,{className:"text-xs",children:"Label"}),o.jsx($e,{})]}),o.jsx(X,{value:e.label,onChange:y=>s({label:y.target.value}),className:"h-8 text-sm"})]}),d||m?o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-xs",children:"Dica (hint)"}),o.jsx(X,{value:e.hint||"",onChange:y=>s({hint:y.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(xe,{id:"req",checked:e.required||!1,onCheckedChange:y=>s({required:y===!0})}),o.jsx(B,{htmlFor:"req",className:"text-xs cursor-pointer",children:"Campo obrigatório"})]})]}):p?o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-xs",children:"Dica (hint)"}),o.jsx(X,{value:e.hint||"",onChange:y=>s({hint:y.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(xe,{id:"req",checked:e.required||!1,onCheckedChange:y=>s({required:y===!0})}),o.jsx(B,{htmlFor:"req",className:"text-xs cursor-pointer",children:"Campo obrigatório"})]}),o.jsx(Ne,{}),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(B,{className:"text-xs",children:"Texto dos termos"}),o.jsx(Mr,{value:e.termoTexto||"",onChange:y=>s({termoTexto:y.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(B,{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:()=>N("link"),className:`flex-1 text-[11px] py-1 rounded transition-colors ${w==="link"?"bg-background shadow-sm font-medium":"text-muted-foreground hover:text-foreground"}`,children:"Link externo"}),o.jsx("button",{type:"button",onClick:()=>N("upload"),className:`flex-1 text-[11px] py-1 rounded transition-colors ${w==="upload"?"bg-background shadow-sm font-medium":"text-muted-foreground hover:text-foreground"}`,children:"Upload de PDF"})]}),w==="link"?o.jsxs("div",{className:"space-y-1",children:[o.jsx(X,{value:e.termoPdfUrl||"",onChange:y=>s({termoPdfUrl:y.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&&C.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(T.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(le,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>{s({termoPdfUploadId:void 0})},children:o.jsx(T.X,{className:"h-3 w-3"})})]}):null,C.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(T.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),o.jsx("span",{className:"truncate",children:C.fileName}),o.jsxs("span",{className:"ml-auto",children:[C.progress,"%"]})]}),o.jsx(Nl,{value:C.progress,className:"h-1"})]}):null,C.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(T.AlertCircle,{className:"h-3.5 w-3.5 text-destructive shrink-0"}),o.jsx("span",{className:"text-[11px] text-destructive",children:C.message}),o.jsx(le,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 ml-auto",onClick:()=>j({status:"idle"}),children:o.jsx(T.X,{className:"h-3 w-3"})})]}):null,C.status!=="uploading"?o.jsxs(o.Fragment,{children:[o.jsx("input",{ref:S,type:"file",accept:"application/pdf",className:"hidden",onChange:y=>{var I;const A=(I=y.target.files)==null?void 0:I[0];A&&P(A),y.target.value=""}}),o.jsxs(le,{type:"button",variant:"outline",size:"sm",className:"w-full h-8 text-xs gap-1.5",disabled:!v,onClick:()=>{var y;return(y=S.current)==null?void 0:y.click()},children:[o.jsx(T.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(B,{className:"text-xs",children:"Nome (chave)"}),o.jsx(X,{value:e.name||t.replace(/^field_/,""),onChange:y=>!c&&s({name:y.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(B,{className:"text-xs",children:"Tipo do campo"}),o.jsxs(Ce,{value:a,onValueChange:y=>!c&&s({fieldType:y}),disabled:c,children:[o.jsx(ye,{className:"h-8 text-sm",children:o.jsx(je,{})}),o.jsx(we,{children:at.map(y=>o.jsx(pe,{value:y.component,children:y.label},y.component))})]})]}),o.jsx(xl,{tamanho:e.tamanho||6,inicioColuna:e.inicioColuna||1,defaultTamanho:6,onTamanhoChange:y=>s({tamanho:y}),onPositionChange:y=>s({inicioColuna:y})}),a!=="file"&&!l&&o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(B,{className:"text-xs",children:"Placeholder"}),o.jsx($e,{})]}),o.jsx(X,{value:e.placeholder||"",onChange:y=>s({placeholder:y.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(B,{className:"text-xs",children:"Dica (hint)"}),o.jsx($e,{})]}),o.jsx(X,{value:e.hint||"",onChange:y=>s({hint:y.target.value}),className:"h-8 text-sm",placeholder:"Texto de ajuda abaixo do campo"})]}),a!=="file"&&!l&&!h&&o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-xs",children:"Valor padrão"}),o.jsx(X,{value:e.defaultValue||"",onChange:y=>s({defaultValue:y.target.value}),className:"h-8 text-sm",placeholder:"Valor inicial do campo"})]}),a!=="file"&&!l&&!h&&o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(B,{className:"text-xs",children:"Valor inicial (runtime)"}),o.jsx($e,{})]}),o.jsx(X,{value:e.initialValue||"",onChange:y=>s({initialValue:y.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&&!h&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(xe,{id:"req",checked:e.required||!1,onCheckedChange:y=>s({required:y===!0})}),o.jsx(B,{htmlFor:"req",className:"text-xs cursor-pointer",children:"Campo obrigatório"})]}),!l&&!h&&!c&&o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(xe,{id:"readonly",checked:e.isReadOnly||!1,onCheckedChange:y=>s({isReadOnly:y===!0||void 0})}),o.jsx(B,{htmlFor:"readonly",className:"text-xs cursor-pointer",children:"Somente leitura"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(xe,{id:"disabled",checked:e.isDisabled||!1,onCheckedChange:y=>s({isDisabled:y===!0||void 0})}),o.jsx(B,{htmlFor:"disabled",className:"text-xs cursor-pointer",children:"Desabilitado"})]})]}),f&&o.jsxs(o.Fragment,{children:[o.jsx(Ne,{}),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(B,{className:"text-xs",children:"Mínimo"}),o.jsx(X,{type:"number",value:e.minValue??0,onChange:y=>s({minValue:Number(y.target.value)}),className:"h-8 text-sm"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-xs",children:"Máximo"}),o.jsx(X,{type:"number",value:e.maxValue??100,onChange:y=>s({maxValue:Number(y.target.value)}),className:"h-8 text-sm"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-xs",children:"Passo"}),o.jsx(X,{type:"number",min:1,value:e.step??1,onChange:y=>s({step:Number(y.target.value)}),className:"h-8 text-sm"})]})]})]})]}),x&&o.jsxs(o.Fragment,{children:[o.jsx(Ne,{}),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(B,{className:"text-xs",children:"Número de estrelas"}),o.jsxs(Ce,{value:String(e.maxRating??5),onValueChange:y=>s({maxRating:Number(y)}),children:[o.jsx(ye,{className:"h-8 text-sm",children:o.jsx(je,{})}),o.jsx(we,{children:[3,4,5,6,7,10].map(y=>o.jsxs(pe,{value:String(y),children:[y," estrelas"]},y))})]})]})]})]}),g&&o.jsxs(o.Fragment,{children:[o.jsx(Ne,{}),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(B,{className:"text-xs",children:"Label da data inicial"}),o.jsx(X,{value:e.dateRangeStartLabel??"Data inicial",onChange:y=>s({dateRangeStartLabel:y.target.value}),className:"h-8 text-sm"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-xs",children:"Label da data final"}),o.jsx(X,{value:e.dateRangeEndLabel??"Data final",onChange:y=>s({dateRangeEndLabel:y.target.value}),className:"h-8 text-sm"})]})]})]}),!l&&o.jsx(Ne,{}),!l&&o.jsx(Yf,{fieldType:a,validation:e.validation,onChange:y=>s({validation:y})}),i&&o.jsxs(o.Fragment,{children:[o.jsx(Ne,{}),a==="radio"&&o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-xs",children:"Estilo visual"}),o.jsxs(Ce,{value:e.visualStyle||"card",onValueChange:y=>s({visualStyle:y}),children:[o.jsx(ye,{className:"h-8 text-sm",children:o.jsx(je,{})}),o.jsxs(we,{children:[o.jsx(pe,{value:"card",children:"Card (padrão)"}),o.jsx(pe,{value:"default",children:"Radio simples"})]})]})]}),o.jsx(Il,{options:e.options||[],onChange:y=>s({options:y})})]}),l&&o.jsxs(o.Fragment,{children:[o.jsx(Ne,{}),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(B,{className:"text-xs",children:"Mín. itens"}),o.jsx(X,{type:"number",min:0,value:e.minItems??"",onChange:y=>s({minItems:y.target.value?Number(y.target.value):void 0}),className:"h-8 text-sm",placeholder:"0"})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-xs",children:"Máx. itens"}),o.jsx(X,{type:"number",min:0,value:e.maxItems??"",onChange:y=>s({maxItems:y.target.value?Number(y.target.value):void 0}),className:"h-8 text-sm",placeholder:"Sem limite"})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-xs",children:"Label do item"}),o.jsx(X,{value:e.itemLabel||"",onChange:y=>s({itemLabel:y.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(B,{className:"text-xs",children:"Label do botão adicionar"}),o.jsx(X,{value:e.addLabel||"",onChange:y=>s({addLabel:y.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."})})]})]}),h&&o.jsxs(o.Fragment,{children:[o.jsx(Ne,{}),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(B,{className:"text-xs",children:"Título do grupo (opcional)"}),o.jsx(X,{value:e.subSchemaTitle||"",onChange:y=>s({subSchemaTitle:y.target.value||void 0}),className:"h-8 text-sm",placeholder:"Ex: Endereço, Responsável..."})]}),o.jsx(Qf,{subFields:e.subSchemaFields||[],onChange:y=>s({subSchemaFields:y})})]})]}),o.jsx(Ne,{}),o.jsx(Jf,{condition:e.condition,selectedId:t,allFieldIds:r,getFieldLabel:n,onChange:y=>s({condition:y})}),e.condition&&o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-xs",children:"Valor ao ocultar (clearedValue)"}),o.jsx(X,{value:e.clearedValue??"",onChange:y=>s({clearedValue:y.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&&!h&&o.jsxs("div",{className:"space-y-1",children:[o.jsx(B,{className:"text-xs text-muted-foreground",children:"Resolver de props (avançado)"}),o.jsx(X,{value:e.resolvePropsKey||"",onChange:y=>s({resolvePropsKey:y.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."]})]})]})]})},th=()=>{const{selectedId:e,getConfig:t,updateConfig:r,getAllFieldIds:n}=ke();if(!e)return o.jsx("div",{className:"rounded-xl border bg-card p-4 text-center text-sm text-muted-foreground",children:"Clique em um item para configurá-lo"});const s=t(e),a=me(e),i=d=>r(e,d),l=n().filter(d=>d!==e),c=d=>t(d).label||d;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:a==="step"?"Step":a==="container"?"Container":"Campo"}),o.jsx("span",{className:"text-[10px] font-mono text-muted-foreground",children:e})]}),o.jsx(Ne,{}),a==="step"&&o.jsx(xp,{config:s,onUpdate:i}),a==="container"&&o.jsx(hf,{config:s,onUpdate:i}),a==="field"&&o.jsx(eh,{config:s,selectedId:e,allFieldIds:l,getFieldLabel:c,onUpdate:i})]})},rh=(e,t)=>{var s,a,i,l,c,d;const r=((a=(s=e==null?void 0:e.containers)==null?void 0:s.root)==null?void 0:a.children)||[],n=[];for(const m of r){if(me(m)!=="step")continue;const p=((l=(i=e==null?void 0:e.containers)==null?void 0:i[m])==null?void 0:l.children)||[],f=[];for(const x of p){if(me(x)!=="container")continue;const h=(((d=(c=e==null?void 0:e.containers)==null?void 0:c[x])==null?void 0:d.children)||[]).filter(v=>me(v)==="field").map(v=>{var N,C;const b=t(v),w={id:v,config:b};if(b.fieldType==="field_array"){const j=((C=(N=e==null?void 0:e.containers)==null?void 0:N[v])==null?void 0:C.children)??[];w.subFields=j.filter(S=>me(S)==="field").map(S=>({id:S,config:t(S)}))}return w});f.push({id:x,config:t(x),fields:h})}n.push({id:m,config:t(m),containers:f})}return n},Br=(e,t,r)=>{var l;if(!e||!e.when)return!0;const n=e.source==="evento"?(r==null?void 0:r[e.when])||"":t[e.when]||"",s=parseFloat(n),a=parseFloat(e.value||"");let i;switch(e.operator){case"igual":i=n===(e.value||"");break;case"diferente":i=n!==(e.value||"");break;case"vazio":i=!n;break;case"naoVazio":i=!!n;break;case"contem":i=n.includes(e.value||"");break;case"naoContem":i=!n.includes(e.value||"");break;case"maiorQue":i=!isNaN(s)&&!isNaN(a)&&s>a;break;case"menorQue":i=!isNaN(s)&&!isNaN(a)&&s<a;break;case"maiorOuIgual":i=!isNaN(s)&&!isNaN(a)&&s>=a;break;case"menorOuIgual":i=!isNaN(s)&&!isNaN(a)&&s<=a;break;default:i=!0}if(e.logicOperator&&((l=e.extraConditions)!=null&&l.length)){const c=e.extraConditions.map(d=>Br(d,t,r));return e.logicOperator==="and"?i&&c.every(Boolean):i||c.some(Boolean)}return i},ts=(e,t,r,n)=>{if(!Br(t.condition,r,n))return;const s=t.validation,a=t.fieldType||"texto";if(t.required&&!e)return"Campo obrigatório";if(e){if(s!=null&&s.minLength&&e.length<s.minLength)return`Mínimo ${s.minLength} caracteres`;if(s!=null&&s.maxLength&&e.length>s.maxLength)return`Máximo ${s.maxLength} caracteres`;if(a==="number"){const i=Number(e);if(!isNaN(i)){if((s==null?void 0:s.min)!==void 0&&i<s.min)return`Valor mínimo: ${s.min}`;if((s==null?void 0:s.max)!==void 0&&i>s.max)return`Valor máximo: ${s.max}`}}if((a==="date"||a==="datetime")&&e){if(s!=null&&s.minDate&&e<s.minDate)return`Data mínima: ${s.minDate}`;if(s!=null&&s.maxDate&&e>s.maxDate)return`Data máxima: ${s.maxDate}`}if(s!=null&&s.regex)try{if(!new RegExp(s.regex).test(e))return s.regexMessage||"Formato inválido"}catch{}}},rs={email:"teste@email.com",number:"123",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),textarea:"Texto de teste para preview",checkbox:"true",hidden:"",participation_type:JSON.stringify({tipo:"todos_os_dias",data:null,genero:null}),payment_method:JSON.stringify({metodo:"pix",valorTotal:0}),terms:""},Ll=(e,t)=>{var n;const r=e.fieldType||"texto";if(r==="field_array"){const s=Math.max(e.minItems??1,1),a=Array.from({length:s},()=>{const i={};return t==null||t.forEach(l=>{i[l.id]=Ll(l.config)}),i});return JSON.stringify(a)}return rs[r]!==void 0?rs[r]:(r==="select"||r==="radio")&&((n=e.options)!=null&&n.length)?e.options[0].value||"":"Teste"},oh={glassmorphism:"Glass",card:"Card",flat:"Flat",bordered:"Bordered"},nh=()=>{const{previewTemplateId:e,setPreviewTemplateId:t}=ke(),[r,n]=_.useState(!1),s=Object.values(Ye.TEMPLATE_REGISTRY),a=Ye.TEMPLATE_REGISTRY[e];return o.jsxs(Tr,{open:r,onOpenChange:n,children:[o.jsx(Ir,{asChild:!0,children:o.jsxs(le,{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:(a==null?void 0:a.colors.primary)??"#3b82f6"}}),o.jsx(T.Palette,{className:"w-3.5 h-3.5"}),o.jsx("span",{className:"hidden sm:inline",children:(a==null?void 0:a.displayName)??"Template"})]})}),o.jsxs(Vt,{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:s.map(i=>{const l=i.id===e,c=Ye.isDarkTemplate(i),d=oh[i.layout.containerStyle]??"";return o.jsxs("button",{onClick:()=>{t(i.id),n(!1)},className:W("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(T.Check,{className:"w-3 h-3 text-primary"})})]},i.id)})})]})]})},sh=({onFillMock:e,onClear:t})=>o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx(nh,{}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(le,{variant:"outline",size:"sm",onClick:e,children:[o.jsx(T.FlaskConical,{className:"w-3.5 h-3.5 mr-1"}),"Preencher mock"]}),o.jsxs(le,{variant:"ghost",size:"sm",onClick:t,children:[o.jsx(T.Eraser,{className:"w-3.5 h-3.5 mr-1"}),"Limpar"]})]})]}),ah={texto:"text",number:"number",email:"email",telefone:"tel",cpf:"text",cep:"text",date:"date",datetime:"datetime-local"},Ol=e=>ah[e]||"text",xt=e=>`R$ ${(e/100).toFixed(2).replace(".",",")}`,ih=({config:e,fieldId:t,subFields:r,tamanho:n,error:s,onChange:a,value:i})=>{const l=e.minItems??1,c=e.maxItems??10,d=e.itemLabel||"Item",m=e.addLabel||`Adicionar ${d}`,p=_.useRef(i||""),f=_.useCallback(()=>Object.fromEntries(r.map(j=>[j.id,""])),[r]),[x,g]=_.useState(()=>{if(i)try{const j=JSON.parse(i);if(Array.isArray(j)&&j.length>0)return j}catch{}return[f()]}),[h,v]=_.useState({});_.useEffect(()=>{if(i!==p.current){if(p.current=i||"",!i){g([f()]);return}try{const j=JSON.parse(i);Array.isArray(j)&&g(j)}catch{}}},[i,f]),_.useEffect(()=>{if(!s){v({});return}const j={};x.forEach((S,P)=>{r.forEach(y=>{const A=S[y.id]??"";y.config.required&&!A.trim()&&(j[`${P}.${y.id}`]="Campo obrigatório")})}),v(j)},[s,x,r]);const b=j=>{if(!a)return;const S=j.map(y=>{const A={};return r.forEach(I=>{A[I.id]=y[I.id]??""}),A}),P=JSON.stringify(S);p.current=P,a(P)},w=()=>{if(x.length>=c)return;const j=[...x,f()];g(j),b(j)},N=j=>{if(x.length<=l)return;const S=x.filter((P,y)=>y!==j);g(S),b(S)},C=(j,S,P)=>{const y=x.map((A,I)=>I===j?{...A,[S]:P}:A);g(y),b(y),v(A=>{const I={...A};return delete I[`${j}.${S}`],I})};return o.jsxs("div",{className:"space-y-2",style:{gridColumn:`span ${n}`},children:[e.label&&o.jsx(B,{className:"text-sm font-medium",children:e.label}),o.jsx("div",{className:"space-y-3",children:x.map((j,S)=>o.jsxs("div",{className:"rounded-xl border bg-card p-4 space-y-3 shadow-sm",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"inline-flex h-7 w-7 items-center justify-center rounded-full bg-orange-500 text-white text-xs font-bold shrink-0",children:S+1}),o.jsxs("span",{className:"text-sm font-semibold",children:[d," ",S+1]})]}),x.length>l&&o.jsx(le,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive/60 hover:text-destructive",onClick:()=>N(S),children:o.jsx(T.Trash2,{className:"h-4 w-4"})})]}),r.length===0?o.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Sem sub-campos configurados"}):o.jsx("div",{className:"grid grid-cols-12 gap-3",children:r.map(P=>{const y=P.config.fieldType||"texto",A=P.config.tamanho||6,I=j[P.id]??"",O=F=>C(S,P.id,F),D=h[`${S}.${P.id}`];return o.jsxs("div",{className:"space-y-1",style:{gridColumn:`span ${A}`},children:[o.jsxs(B,{className:"text-xs font-medium",children:[P.config.label,P.config.required&&o.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),y==="textarea"?o.jsx(Mr,{placeholder:P.config.placeholder,className:D?"text-sm border-destructive":"text-sm",value:I,onChange:F=>O(F.target.value)}):y==="select"?o.jsxs(Ce,{value:I,onValueChange:O,children:[o.jsx(ye,{className:D?"text-sm border-destructive":"text-sm",children:o.jsx(je,{placeholder:P.config.placeholder||"Selecione..."})}),o.jsx(we,{children:(P.config.options||[]).map((F,z)=>o.jsx(pe,{value:F.value||`__opt_${z}`,children:F.label},`${z}-${F.value}`))})]}):y==="checkbox"?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(xe,{checked:I==="true",onCheckedChange:F=>O(F?"true":"")}),o.jsx("span",{className:"text-sm text-muted-foreground",children:P.config.placeholder||P.config.label})]}):o.jsx(X,{type:Ol(y),placeholder:P.config.placeholder,className:D?"text-sm border-destructive":"text-sm",value:I,onChange:F=>O(F.target.value)}),D&&o.jsxs("p",{className:"text-xs text-destructive flex items-center gap-1",children:[o.jsx(T.AlertCircle,{className:"h-3 w-3 shrink-0"}),D]})]},P.id)})})]},S))}),o.jsxs(le,{type:"button",variant:"outline",className:"w-full border-dashed border-orange-500 text-orange-500 hover:bg-orange-500/10 hover:text-orange-500 font-semibold",onClick:w,disabled:x.length>=c,children:[o.jsx(T.Plus,{className:"h-4 w-4 mr-2"}),m]}),e.maxItems&&o.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:["Máximo de ",e.maxItems," ",d.toLowerCase(),e.maxItems!==1?"s":""]}),!e.maxItems&&e.hint&&o.jsx("p",{className:"text-xs text-muted-foreground",children:e.hint}),s&&o.jsxs("p",{className:"text-sm text-destructive flex items-center gap-1",children:[o.jsx(T.AlertCircle,{className:"h-4 w-4 shrink-0"}),s]})]})},lh=({config:e,fieldId:t,value:r,onChange:n,visible:s,error:a,subFields:i,eventoData:l,allValues:c})=>{const d=e.fieldType||"texto",m=e.tamanho||6;if(!s)return null;if(d==="field_array")return o.jsx(ih,{config:e,fieldId:t,subFields:i??[],tamanho:m,error:a,onChange:n,value:r});const p=a?"border-destructive":"";return o.jsxs("div",{className:"space-y-1",style:{gridColumn:e.inicioColuna?`${e.inicioColuna} / span ${m}`:`span ${m}`},children:[d!=="terms"&&o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsxs(B,{className:"text-sm font-medium",children:[e.label,e.required&&o.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.condition&&o.jsxs(Vr,{variant:"outline",className:"text-[9px] px-1 py-0 h-4 border-amber-500/50 text-amber-600",children:[o.jsx(T.Zap,{className:"h-2.5 w-2.5 mr-0.5"}),"cond"]})]}),d==="textarea"?o.jsx(Mr,{placeholder:e.placeholder,className:W("text-sm",p),value:r,onChange:f=>n(f.target.value)}):d==="select"?o.jsxs(Ce,{value:r,onValueChange:n,children:[o.jsx(ye,{className:W("text-sm",p),children:o.jsx(je,{placeholder:e.placeholder||"Selecione..."})}),o.jsx(we,{children:(e.options||[]).map((f,x)=>o.jsx(pe,{value:f.value||`__opt_${x}`,children:f.label},`${x}-${f.value}`))})]}):d==="checkbox"?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(xe,{checked:r==="true",onCheckedChange:f=>n(f?"true":"")}),o.jsx("span",{className:"text-sm text-muted-foreground",children:e.placeholder||e.label})]}):d==="checkbox_group"?o.jsx(ch,{config:e,value:r,onChange:n}):d==="radio"?o.jsx("div",{className:"space-y-2",children:(e.options||[{value:"1",label:"Opção 1"}]).map((f,x)=>e.visualStyle==="default"?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"radio",readOnly:!0,checked:r===f.value,className:"accent-orange-500"}),o.jsx("span",{className:"text-sm",children:f.label})]},`${x}-${f.value}`):o.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-xl border-2 transition-all cursor-pointer bg-card border-border",children:[o.jsx("input",{type:"radio",readOnly:!0,checked:r===f.value,className:"accent-orange-500"}),o.jsx("span",{className:"text-sm flex-1",children:f.label})]},`${x}-${f.value}`))}):d==="participation_type"?(()=>{const f=parseInt((l==null?void 0:l["evento.valor"])??"0")||0,x=parseInt((l==null?void 0:l["evento.valorPorDia"])??"0")||0,g=l==null?void 0:l["evento.vagasTotal"],h=l==null?void 0:l["evento.vagasPorDia"],v=l==null?void 0:l["evento.vagasMasculinas"],b=l==null?void 0:l["evento.vagasFemininas"],w=!!(v&&Number(v)>0)&&!!(b&&Number(b)>0),N=l==null?void 0:l["evento.dataInicioEvento"],C=l==null?void 0:l["evento.dataFimEvento"],j=R=>R?R.slice(8,10)+"/"+R.slice(5,7)+"/"+R.slice(0,4):"—",S=N&&C?`${j(N)} a ${j(C)}`:"Período do evento",y=(N&&C?Math.round((new Date(C.slice(0,10)+"T00:00:00Z").getTime()-new Date(N.slice(0,10)+"T00:00:00Z").getTime())/864e5)+1:0)>1;let A={};try{A=r?JSON.parse(r):{}}catch{}const I=A.tipo??null,O=A.data??null,D=A.genero??null,F=R=>n(JSON.stringify({tipo:R,data:null,...w?{genero:D}:{}})),z=R=>n(JSON.stringify({tipo:"por_dia",data:R,...w?{genero:D}:{}})),V=R=>n(JSON.stringify({tipo:I,data:O,genero:R})),k=[];if(y&&N&&C){const R=new Date(N.slice(0,10)+"T00:00:00Z"),$=new Date(C.slice(0,10)+"T00:00:00Z");let L=0;for(;R<=$&&L++<60;)k.push(R.toISOString().slice(0,10)),R.setUTCDate(R.getUTCDate()+1)}const E=R=>{const[$,L,q]=R.split("-").map(Number),ne=new Date(Date.UTC($,L-1,q)),ae=String(q).padStart(2,"0"),ie=String(L).padStart(2,"0"),oe=new Intl.DateTimeFormat("pt-BR",{weekday:"long",timeZone:"UTC"}).format(ne);return`${ae}/${ie} — ${oe.charAt(0).toUpperCase()}${oe.slice(1)}`};return o.jsxs("div",{className:"space-y-2",children:[w&&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(R=>{const $=R==="masculino"?"Masculino":"Feminino";return o.jsx("button",{type:"button",onClick:()=>V(R),className:W("px-3 py-1 rounded-full text-xs font-medium border transition-all",D===R?"border-primary bg-primary text-primary-foreground":"border-border bg-card text-muted-foreground hover:border-primary/60"),children:$},R)})})]}),o.jsxs("button",{type:"button",onClick:()=>F("todos_os_dias"),className:W("w-full text-left flex items-start gap-3 p-4 rounded-xl border-2 transition-all bg-card",I==="todos_os_dias"?"border-primary bg-primary/10":"border-border hover:border-primary/40"),children:[o.jsx("div",{className:W("mt-0.5 p-2 rounded-lg shrink-0",I==="todos_os_dias"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"),children:o.jsx(T.CalendarCheck2,{className:"w-4 h-4"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-sm font-semibold",children:"Participar todos os dias"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:S})]}),o.jsxs("div",{className:"text-right shrink-0",children:[o.jsx("p",{className:W("text-sm font-bold",I==="todos_os_dias"?"text-primary":"text-foreground"),children:f>0?xt(f):"R$ —,—"}),g&&o.jsxs("p",{className:"text-xs text-emerald-500 flex items-center justify-end gap-1",children:[o.jsx(T.Users,{className:"w-3 h-3"}),g," vagas"]})]})]}),y?o.jsxs("button",{type:"button",onClick:()=>F("por_dia"),className:W("w-full text-left flex items-start gap-3 p-4 rounded-xl border-2 transition-all bg-card",I==="por_dia"?"border-primary bg-primary/10":"border-border hover:border-primary/40"),children:[o.jsx("div",{className:W("mt-0.5 p-2 rounded-lg shrink-0",I==="por_dia"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"),children:o.jsx(T.CalendarDays,{className:"w-4 h-4"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-sm font-semibold",children:"Participar um dia"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Escolha o dia desejado"})]}),o.jsxs("div",{className:"text-right shrink-0",children:[o.jsx("p",{className:W("text-sm font-bold",I==="por_dia"?"text-primary":"text-foreground"),children:x>0?xt(x):"R$ —,—"}),h&&o.jsxs("p",{className:"text-xs text-emerald-500 flex items-center justify-end gap-1",children:[o.jsx(T.Users,{className:"w-3 h-3"}),h," vagas/dia"]})]})]}):N?o.jsxs("div",{className:"flex items-start gap-2 px-3 py-2.5 rounded-lg bg-muted/50 border border-border",children:[o.jsx(T.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:'Evento de 1 dia — a opção "Participar um dia" não é exibida.'})]}):o.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-xl border-2 border-border bg-card opacity-40",children:[o.jsx("div",{className:"mt-0.5 p-2 rounded-lg shrink-0 bg-muted text-muted-foreground",children:o.jsx(T.CalendarDays,{className:"w-4 h-4"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-sm font-semibold",children:"Participar um dia"}),o.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Visível se evento tiver 2+ dias"})]}),o.jsx("div",{className:"text-right shrink-0",children:o.jsx("p",{className:"text-sm font-bold text-primary",children:"R$ —,—"})})]}),I==="por_dia"&&k.length>0&&o.jsxs("div",{className:"pl-2 space-y-2",children:[o.jsx("p",{className:"text-xs font-semibold text-primary uppercase tracking-wide",children:"Selecione o dia:"}),k.map(R=>o.jsxs("button",{type:"button",onClick:()=>z(R),className:W("w-full text-left flex items-center justify-between px-4 py-3 rounded-lg border transition-all",O===R?"border-primary bg-primary/10 text-primary":"border-border bg-card hover:border-primary/40"),children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("span",{className:W("w-4 h-4 rounded-full border-2 shrink-0 flex items-center justify-center",O===R?"border-primary bg-primary":"border-muted-foreground"),children:O===R&&o.jsx("span",{className:"w-2 h-2 rounded-full bg-primary-foreground"})}),o.jsx("span",{className:"text-sm",children:E(R)})]}),h&&o.jsxs("span",{className:"text-xs text-emerald-500",children:[h," vagas"]})]},R))]})]})})():d==="payment_method"?(()=>{const g=(c==null?void 0:c._participation_type_field)??"";let h={};try{h=g?JSON.parse(g):{}}catch{}const v=h.tipo??null,b=Number((l==null?void 0:l["evento.valor"])??0)||0,w=Number((l==null?void 0:l["evento.valorPorDia"])??0)||0,N=v==="por_dia"&&w>0?w:b,C=v==="por_dia"?(()=>{if(!h.data)return"Um dia";const[A,I,O]=h.data.split("-");return`${O}/${I}/${A}`})():"Todos os dias",j=v==="por_dia"?[{id:"pix",label:"PIX",desc:"Transferência instantânea (à vista)",taxa:0,parcelas:0},{id:"dinheiro",label:"Dinheiro",desc:"Pagamento em espécie",taxa:0,parcelas:0},{id:"cartao",label:"Cartão de Crédito",desc:"Débito ou crédito na maquininha",taxa:.0315,parcelas:0,taxaLabel:`Taxa InfinityPay: ${(.0315*100).toFixed(2).replace(".",",")}%`}]:[{id:"pix",label:"PIX à Vista",desc:"Pagamento instantâneo sem parcelamento",taxa:0,parcelas:0},{id:"pix_parcelado",label:"PIX Parcelado",desc:"Parcelado em até 7x sem juros",taxa:0,parcelas:7},{id:"cartao",label:"Cartão de Crédito",desc:"Parcelado em até 12x",taxa:.124,parcelas:12,taxaLabel:`Taxa InfinityPay: ${(.124*100).toFixed(2).replace(".",",")}%`},{id:"dinheiro",label:"Dinheiro",desc:"Pagamento em espécie",taxa:0,parcelas:0}];let S={};try{S=r?JSON.parse(r):{}}catch{}const P=S.metodo??null,y=A=>{const I=Math.round(N*(1+A.taxa)*100)/100,O={metodo:A.id,valorTotal:I};A.parcelas>1&&(O.parcelas=A.parcelas),n(JSON.stringify(O))};return o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-border bg-card 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:C})]}),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:xt(N)})]})]}),o.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-amber-500/40 bg-amber-500/10 px-3 py-2.5",children:[o.jsx(T.Info,{className:"h-4 w-4 text-amber-500 mt-0.5 shrink-0"}),o.jsxs("p",{className:"text-xs text-amber-200",children:[o.jsx("span",{className:"font-bold text-amber-400",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:j.map(A=>{const I=P===A.id,O=Math.round(N*(1+A.taxa)*100)/100,D=A.parcelas>1,F=D?Math.round(O/A.parcelas*100)/100:null;return o.jsxs("button",{type:"button",onClick:()=>y(A),className:W("w-full text-left flex items-center gap-4 px-4 py-3 rounded-xl border-2 transition-all bg-card",I?"border-primary bg-primary/10":"border-border hover:border-primary/50"),children:[o.jsx("div",{className:W("flex items-center justify-center w-10 h-10 rounded-lg shrink-0",I?"bg-primary/20":"bg-muted"),children:o.jsx(T.Wallet,{className:W("h-5 w-5",I?"text-primary":"text-muted-foreground")})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"font-semibold text-sm leading-tight",children:A.label}),o.jsx("p",{className:"text-xs text-muted-foreground",children:A.desc}),A.taxaLabel&&o.jsxs("p",{className:"text-xs text-amber-400 mt-0.5",children:["* ",A.taxaLabel]}),A.taxa>0&&o.jsxs("p",{className:"text-xs text-muted-foreground",children:["Total com taxa: ",xt(O)]})]}),o.jsx("div",{className:"text-right shrink-0",children:D?o.jsxs(o.Fragment,{children:[o.jsxs("p",{className:"text-xs text-muted-foreground",children:[A.parcelas,"x de"]}),o.jsx("p",{className:"text-base font-bold text-primary",children:xt(F)})]}):o.jsx("p",{className:"text-base font-bold text-primary",children:xt(O)})})]},A.id)})})]})})():d==="terms"?(()=>{const f=r==="accepted",x=e.termoTexto,g=e.termoPdfUrl,h=!!e.termoPdfUploadId,v=!!(x||g||h);return o.jsxs("div",{className:W("rounded-lg border p-4 space-y-4 transition-colors",f?"border-green-500/40 bg-green-500/5":"border-border bg-muted/30"),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(T.ScrollText,{className:"h-4 w-4 text-primary shrink-0"}),o.jsx("span",{className:"text-sm font-medium",children:e.label||"Termos e condições"})]}),v?o.jsxs("div",{className:"flex items-center gap-1.5",children:[h&&o.jsx("span",{className:"flex items-center gap-1 text-[10px] text-green-600 dark:text-green-400 font-medium border border-green-500/40 bg-green-500/10 rounded px-1.5 py-0.5",children:"PDF enviado ✓"}),o.jsxs(le,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{},children:[o.jsx(T.ExternalLink,{className:"h-3 w-3"}),"Ler termos"]})]}):o.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Conteúdo não configurado"})]}),o.jsxs("label",{className:"flex items-start gap-3 cursor-pointer select-none",children:[o.jsx(xe,{checked:f,onCheckedChange:b=>n(b?"accepted":""),className:"mt-0.5"}),o.jsxs("span",{className:"text-sm leading-snug flex-1",children:["Li e aceito"," ",e.label?`"${e.label}"`:"os termos e condições"]}),f&&o.jsx(T.CheckCircle2,{className:"h-4 w-4 text-green-500 shrink-0 mt-0.5"})]})]})})():d==="file"?o.jsx(X,{type:"file",className:W("text-sm",p)}):d==="hidden"?o.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Campo oculto"}):o.jsx(X,{type:Ol(d),placeholder:e.placeholder,className:W("text-sm",p),value:r,onChange:f=>n(f.target.value)}),a?o.jsxs("p",{className:"text-xs text-destructive flex items-center gap-1",children:[o.jsx(T.AlertCircle,{className:"h-3 w-3 shrink-0"}),a]}):e.hint?o.jsx("p",{className:"text-xs text-muted-foreground",children:e.hint}):null]})},ch=({config:e,value:t,onChange:r})=>{var i;const n=new Set(t?t.split(","):[]),s=(i=e.options)!=null&&i.length?e.options:[{value:"1",label:"Opção 1"}],a=l=>{const c=new Set(n);c.has(l)?c.delete(l):c.add(l),r(Array.from(c).join(","))};return o.jsx("div",{className:"space-y-1",children:s.map((l,c)=>o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(xe,{checked:n.has(l.value),onCheckedChange:()=>a(l.value),disabled:l.disabled}),o.jsx("span",{className:"text-sm",children:l.label})]},`${c}-${l.value}`))})},dh=({step:e,stepIndex:t,formValues:r,errors:n,eventoData:s,onChange:a})=>o.jsxs("div",{className:"rounded-xl border bg-card p-5 space-y-5",children:[o.jsxs("div",{children:[e.config.showLabel!==!1&&o.jsxs("h2",{className:"text-base font-bold text-foreground",children:["Step ",t+1," — ",e.config.label]}),e.config.description&&o.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:e.config.description})]}),o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-12 gap-4",children:e.containers.map(i=>o.jsxs("div",{className:W("space-y-3",i.config.showAsCard&&"rounded-lg border bg-card p-4 shadow-sm"),style:{gridColumn:i.config.inicioColuna?`${i.config.inicioColuna} / span ${i.config.tamanho||12}`:`span ${i.config.tamanho||12}`},children:[i.config.showLabel!==!1&&i.config.label!=="Novo Container"&&o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-semibold text-foreground",children:i.config.label}),i.config.description&&o.jsx("p",{className:"text-xs text-muted-foreground",children:i.config.description})]}),o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-12 gap-3",children:i.fields.map(l=>o.jsx(lh,{config:l.config,fieldId:l.id,subFields:l.subFields,value:r[l.id]||"",onChange:c=>a(l.id,c),visible:Br(l.config.condition,r,s),error:n[l.id],eventoData:s,allValues:r},l.id))})]},i.id))})]}),uh=({currentStep:e,isLastStep:t,onBack:r,onNext:n})=>o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsxs(le,{variant:"outline",onClick:r,disabled:e===0,children:[o.jsx(T.ChevronLeft,{className:"w-4 h-4 mr-1"}),"Voltar"]}),o.jsx(le,{onClick:n,children:t?o.jsxs(o.Fragment,{children:[o.jsx(T.Check,{className:"w-4 h-4 mr-1"}),"Finalizar"]}):o.jsxs(o.Fragment,{children:[o.jsx(T.ChevronRight,{className:"w-4 h-4 mr-1"}),"Próximo"]})})]}),mh=({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(T.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(le,{variant:"outline",onClick:e,children:[o.jsx(T.RotateCcw,{className:"w-4 h-4 mr-1"}),"Recomeçar"]})]}),pr=e=>{if(e)return Lt[e]},ph=({steps:e,currentStep:t,onStepClick:r})=>o.jsx("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:e.map((n,s)=>o.jsx("div",{role:r?"button":void 0,tabIndex:r?0:void 0,onClick:()=>r==null?void 0:r(s),onKeyDown:a=>a.key==="Enter"&&(r==null?void 0:r(s)),className:W("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:s===t?{background:"var(--t-primary)",color:"#ffffff",boxShadow:"0 0 0 3px color-mix(in srgb, var(--t-primary) 30%, transparent)"}:s<t?{background:"#22c55e",color:"#ffffff"}:{background:"hsl(var(--muted))",color:"hsl(var(--muted-foreground))"},children:s<t?o.jsx(T.Check,{className:"w-4 h-4"}):s+1},n.id))}),fh=({steps:e,currentStep:t,onStepClick:r})=>o.jsx("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:e.map((n,s)=>{const a=pr(n.icone)??T.CircleDot;return o.jsx("div",{role:r?"button":void 0,tabIndex:r?0:void 0,onClick:()=>r==null?void 0:r(s),onKeyDown:i=>i.key==="Enter"&&(r==null?void 0:r(s)),className:W("w-9 h-9 rounded-full flex items-center justify-center transition-all shrink-0",r&&"cursor-pointer hover:opacity-80"),style:s===t?{background:"var(--t-primary)",color:"#ffffff",boxShadow:"0 0 0 3px color-mix(in srgb, var(--t-primary) 30%, transparent)"}:s<t?{background:"#22c55e",color:"#ffffff"}:{background:"hsl(var(--muted))",color:"hsl(var(--muted-foreground))"},children:s<t?o.jsx(T.Check,{className:"w-4 h-4"}):o.jsx(a,{className:"w-4 h-4"})},n.id)})}),hh=({steps:e,currentStep:t,position:r,orientation:n="horizontal",onStepClick:s})=>n==="vertical"?o.jsx("div",{className:"flex flex-col gap-0",children:e.map((a,i)=>{const l=pr(a.icone)??T.CircleDot,c=i===t,d=i<t,m=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:()=>s==null?void 0:s(i),className:W("w-8 h-8 rounded-full flex items-center justify-center transition-all shrink-0",s&&"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(T.Check,{className:"w-3.5 h-3.5"}):o.jsx(l,{className:"w-3.5 h-3.5"})}),!m&&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:a.label})]},a.id)})}):o.jsx("div",{className:"w-full flex items-start",children:e.map((a,i)=>{const l=pr(a.icone)??T.CircleDot,c=i===t,d=i<t,m=i===e.length-1;return o.jsxs("div",{className:W("flex items-start",!m&&"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:()=>s==null?void 0:s(i),className:W("w-10 h-10 rounded-full flex items-center justify-center transition-all shrink-0",s&&"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(T.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:a.label})]}),!m&&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)"}})]},a.id)})}),xh=({steps:e,currentStep:t,onStepClick:r,className:n})=>{const s=Ye.useTemplate(),{layout:a}=s;if(!a.showStepIndicators||e.length<=1)return null;const i=a.stepIndicatorVariant??"numbers",l=a.stepIndicatorPosition??"top-center",c=a.stepIndicatorOrientation??"horizontal",d=(t+1)/e.length*100,m=e[t],p=pr(m==null?void 0:m.icone)??T.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:`${d}%`,background:"linear-gradient(90deg, var(--t-primary), var(--t-accent))"}})}),x=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}),o.jsxs("p",{className:"text-xs leading-tight",style:{color:"var(--t-text-muted)"},children:["Passo ",t+1," de ",e.length]})]})]}),f]}),g=o.jsxs("div",{className:"hidden sm:block",children:[i==="numbers"&&o.jsx(ph,{steps:e,currentStep:t,onStepClick:r}),i==="icons"&&o.jsx(fh,{steps:e,currentStep:t,onStepClick:r}),i==="icons-labeled"&&o.jsx(hh,{steps:e,currentStep:t,position:l,orientation:c,onStepClick:r})]}),h=a.showProgressBar?o.jsx("div",{className:"hidden sm:block",children:f}):null;return c==="vertical"?o.jsxs("div",{className:W("flex gap-6 items-start",n),children:[x,o.jsxs("div",{className:"hidden sm:flex gap-6 items-start shrink-0",children:[g,h&&o.jsx("div",{className:"flex-1 pt-4",children:h})]})]}):o.jsxs("div",{className:W("space-y-3",n),children:[x,o.jsxs("div",{className:"hidden sm:block space-y-3",children:[g,h]})]})},gh=({eventoData:e})=>{const{getConfig:t,containers:r,previewTemplateId:n}=ke(),s=rh({containers:r},t),[a,i]=_.useState({}),[l,c]=_.useState(0),[d,m]=_.useState(!1),[p,f]=_.useState({}),[x,g]=_.useState(!1),h=Math.min(l,Math.max(s.length-1,0));_.useEffect(()=>{h!==l&&c(h)},[h,l,c]);const v=_.useCallback((O,D)=>{var F;if(i(z=>({...z,[O]:D})),x){const z=(F=s[h])==null?void 0:F.containers.flatMap(V=>V.fields).find(V=>V.id===O);if(z){const V=ts(D,z.config,{...a,[O]:D},e);f(k=>{const E={...k};return V?E[O]=V:delete E[O],E})}}},[x,s,h,a,e,i,f]),b=_.useCallback(()=>{const O=s[h];if(!O)return!0;const D={};for(const z of O.containers)for(const V of z.fields){if(V.config.fieldType==="field_array"){let E=!1;try{const R=a[V.id],$=R?JSON.parse(R):[],L=V.config.minItems??1;if($.length<L)D[V.id]=`Mínimo de ${L} item${L!==1?"s":""} obrigatório${L!==1?"s":""}`,E=!0;else{for(const q of $){for(const ne of V.subFields??[]){const ae=q[ne.id]??"";if(ne.config.required&&!ae.trim()){E=!0;break}}if(E)break}E&&(D[V.id]="Preencha todos os campos obrigatórios")}}catch{V.config.required&&(D[V.id]="Campo obrigatório")}continue}const k=ts(a[V.id]||"",V.config,a,e);k&&(D[V.id]=k)}f(D),g(!0);const F=Object.keys(D).length;return F>0?(console.warn(`Corrija ${F} campo(s) destacado(s) antes de continuar`),!1):!0},[s,h,a,e,f,g]),w=_.useCallback(()=>{b()&&(g(!1),f({}),h>=s.length-1?m(!0):c(O=>O+1))},[b,h,s.length,g,f,m,c]),N=_.useCallback(()=>{c(O=>O-1),g(!1),f({})},[c,g,f]),C=_.useCallback(()=>{const O={};for(const D of s)for(const F of D.containers)for(const z of F.fields)Br(z.config.condition,a,e)&&(O[z.id]=Ll(z.config,z.subFields));i(D=>({...D,...O}))},[s,a,e,i]),j=_.useCallback(()=>{i({}),f({}),g(!1)},[i,f,g]),S=_.useCallback(()=>{m(!1),c(0),j()},[m,c,j]);if(s.length===0)return 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"});if(d)return o.jsx(mh,{onRestart:S});const P=s[h],y=s.length,A=h===y-1,I=Ye.getTemplateConfig(n);return o.jsxs("div",{className:"space-y-3",children:[o.jsx("div",{className:"px-1",children:o.jsx(sh,{onFillMock:C,onClear:j})}),o.jsx(Ye.TemplateProvider,{config:I,className:I.wrapperClass,style:{minHeight:"100%",padding:"12px",borderRadius:"12px"},children:o.jsxs("div",{className:"max-w-4xl mx-auto space-y-4",children:[o.jsx(xh,{steps:s.map(O=>({id:O.id,label:O.config.label,icone:O.config.icone})),currentStep:h}),o.jsx(dh,{step:P,stepIndex:h,formValues:a,errors:p,eventoData:e,onChange:v}),o.jsx(uh,{currentStep:h,isLastStep:A,onBack:N,onNext:w})]})})]})},_l=({id:e,currentTamanho:t,inicioColuna:r,onResize:n})=>{const s=_.useRef(null),[a,i]=_.useState(!1),[l,c]=_.useState(null),d=_.useRef(null);_.useEffect(()=>()=>{var p;(p=d.current)==null||p.call(d)},[]);const m=_.useCallback(p=>{p.preventDefault(),p.stopPropagation();const f=s.current;if(!f)return;const x=f.parentElement;if(!x)return;const g=x.getBoundingClientRect().width,h=f.getBoundingClientRect().width,v=p.clientX,b=r?13-r:12;i(!0);const w=C=>{const j=C.clientX-v,P=(h+j)/g,y=Math.max(1,Math.min(b,Math.round(P*12)));c(y),n(y)},N=()=>{i(!1),c(null),d.current=null,window.removeEventListener("mousemove",w),window.removeEventListener("mouseup",N)};d.current=()=>{i(!1),c(null),window.removeEventListener("mousemove",w),window.removeEventListener("mouseup",N)},window.addEventListener("mousemove",w),window.addEventListener("mouseup",N)},[r,n]);return{resizeRef:s,resizing:a,resizePreview:l,handleResizeStart:m}},vh=({id:e,elementRef:t,onPositionApply:r,setPositionDrag:n,setSelected:s})=>{const a=_.useRef(null);return _.useEffect(()=>()=>{var l;(l=a.current)==null||l.call(a)},[]),{handlePositionMouseDown:_.useCallback(l=>{l.preventDefault(),l.stopPropagation(),s(e);const c=t.current;if(!c)return;const d=c.parentElement;if(!d)return;const m=d.getBoundingClientRect(),p=m.width/12,f=c.getBoundingClientRect(),x=Math.max(1,Math.round(f.width/p)),g=f.left-m.left,h=l.clientX-f.left,v=C=>{const j=C-m.left-h,S=Math.round(j/p)+1;return Math.max(1,Math.min(13-x,S))},b=Math.max(1,Math.min(12,Math.round(g/p)+1));n({itemId:e,ghostStart:b,ghostSpan:x,cursorX:l.clientX,cursorY:l.clientY});const w=C=>{n({itemId:e,ghostStart:v(C.clientX),ghostSpan:x,cursorX:C.clientX,cursorY:C.clientY})},N=C=>{r(v(C.clientX)),n(null),a.current=null,window.removeEventListener("mousemove",w),window.removeEventListener("mouseup",N)};a.current=()=>{n(null),window.removeEventListener("mousemove",w),window.removeEventListener("mouseup",N)},window.addEventListener("mousemove",w),window.addEventListener("mouseup",N)},[e,t,r,n,s])}},Bt=({id:e,container:t})=>{const{attributes:r,listeners:n,setNodeRef:s,transform:a,transition:i,isDragging:l}=Fe.useSortable({id:e,data:{isCanvasItem:!0,type:"field",id:e,fromContainer:t}}),{selectedId:c,setSelected:d,getConfig:m,updateConfig:p,removeItem:f,setPositionDrag:x,positionDrag:g}=ke(),h=m(e),v=as(e),b=(v==null?void 0:v.icon)||T.Type,w=c===e,N=h.tamanho||6,C=(g==null?void 0:g.itemId)===e,{resizeRef:j,resizing:S,resizePreview:P,handleResizeStart:y}=_l({id:e,currentTamanho:N,inicioColuna:h.inicioColuna,onResize:I=>p(e,{tamanho:I})}),{handlePositionMouseDown:A}=vh({id:e,elementRef:j,onPositionApply:I=>p(e,{inicioColuna:I}),setPositionDrag:x,setSelected:d});return o.jsxs("div",{ref:I=>{s(I),j.current=I},onClick:I=>{I.stopPropagation(),d(e)},"data-field-id":e,className:W("group relative flex items-center gap-2 rounded border bg-card/80 backdrop-blur-sm px-2.5 py-1.5 pb-3 cursor-pointer transition-all text-xs",S&&"ring-2 ring-blue-400/50",C&&"opacity-0 pointer-events-none",w?"border-primary ring-2 ring-primary/30 shadow-md":"border-border/60 hover:border-muted-foreground/50 shadow-sm"),style:{gridColumn:h.inicioColuna?`${h.inicioColuna} / span ${N}`:`span ${N}`,transform:Mt.CSS.Transform.toString(a),transition:i,opacity:l?0:1},children:[o.jsx("div",{onMouseDown:A,onClick:I=>I.stopPropagation(),className:"shrink-0 p-0.5 rounded hover:bg-primary/20 transition-colors",style:{cursor:"ew-resize"},title:"Arrastar para mudar coluna",children:o.jsx(T.ArrowLeftRight,{className:"h-3 w-3 text-primary/60"})}),o.jsx("div",{...n,...r,className:"shrink-0",style:{cursor:"grab"},onClick:I=>I.stopPropagation(),children:o.jsx(T.GripVertical,{className:"h-3 w-3 text-muted-foreground"})}),o.jsx(b,{className:"h-3.5 w-3.5 text-primary shrink-0"}),o.jsx("span",{className:"font-medium truncate flex-1",children:h.label}),h.condition&&o.jsx(T.Zap,{className:"h-3 w-3 text-amber-500 shrink-0"}),h.required&&o.jsx("span",{className:"text-destructive font-bold",children:"*"}),o.jsxs("span",{className:"text-[9px] text-muted-foreground shrink-0",children:[P??N,"/12"]}),o.jsx("button",{onClick:I=>{I.stopPropagation(),f(e)},className:"opacity-0 group-hover:opacity-100 transition-opacity shrink-0 p-0.5 rounded hover:bg-destructive/10",children:o.jsx(T.Trash2,{className:"h-3 w-3 text-destructive"})}),o.jsx("div",{className:"absolute -bottom-0.5 left-2 font-mono truncate max-w-[90%] pointer-events-none text-muted-foreground",style:{fontSize:"8px",opacity:.3},children:e}),o.jsx("div",{"data-resize":!0,onMouseDown:y,className:"absolute right-0 top-0 bottom-0 w-2 hover:bg-primary/20 transition-colors flex items-center justify-center",style:{cursor:"col-resize"},children:o.jsx(T.GripHorizontal,{className:"h-3 w-3 text-primary/40 rotate-90"})})]})},bh=({id:e,container:t})=>{var j;const{attributes:r,listeners:n,setNodeRef:s,transform:a,transition:i,isDragging:l}=Fe.useSortable({id:e,data:{isCanvasItem:!0,type:"field",id:e,fromContainer:t}}),{setNodeRef:c,isOver:d}=jt.useDroppable({id:`zone-${e}`}),{selectedId:m,setSelected:p,getConfig:f,removeItem:x,moveItem:g,containers:h}=ke(),v=f(e),w=(((j=h[e])==null?void 0:j.children)??[]).filter(S=>me(S)==="field"),N=m===e,C=v.tamanho||12;return o.jsxs("div",{ref:s,onClick:S=>{S.stopPropagation(),p(e)},className:W("group/fa relative rounded-lg border overflow-hidden transition-all",l&&"opacity-0 pointer-events-none",N?"border-amber-500 ring-2 ring-amber-500/20 shadow-lg":"border-amber-500/30 hover:border-amber-500/50"),style:{gridColumn:v.inicioColuna?`${v.inicioColuna} / span ${C}`:`span ${C}`,transform:Mt.CSS.Transform.toString(a),transition:i},children:[o.jsxs("div",{className:W("flex items-center gap-1.5 border-b px-2 py-1.5 transition-colors",N?"bg-amber-500/15 border-amber-500/30":"bg-amber-500/10 border-amber-500/20"),children:[o.jsx("div",{...n,...r,className:"shrink-0 p-1 -ml-1 rounded hover:bg-amber-500/20 transition-colors",style:{cursor:"grab"},onClick:S=>S.stopPropagation(),children:o.jsx(T.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:S=>{S.stopPropagation(),g(e,"up")},className:"p-0 hover:bg-amber-500/10 rounded transition-colors",title:"Mover para cima",children:o.jsx(T.ChevronUp,{className:"h-3 w-3 text-muted-foreground hover:text-amber-500"})}),o.jsx("button",{onClick:S=>{S.stopPropagation(),g(e,"down")},className:"p-0 hover:bg-amber-500/10 rounded transition-colors",title:"Mover para baixo",children:o.jsx(T.ChevronDown,{className:"h-3 w-3 text-muted-foreground hover:text-amber-500"})})]}),o.jsx(T.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:v.label}),o.jsxs("span",{className:"text-[10px] text-muted-foreground shrink-0 bg-amber-500/10 px-1.5 rounded",children:[v.itemLabel||"Item"," · ",w.length," campo",w.length!==1?"s":""]}),o.jsx("button",{onClick:S=>{S.stopPropagation(),x(e)},className:"opacity-0 group-hover/fa:opacity-100 transition-opacity shrink-0 p-0.5 rounded hover:bg-destructive/10",children:o.jsx(T.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-muted-foreground font-mono",style:{fontSize:"8px",opacity:.3},children:e})}),o.jsxs("div",{ref:c,className:W("relative p-2 min-h-[40px] gap-1.5 transition-all duration-150",d?"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:[w.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(Fe.SortableContext,{items:w,strategy:Fe.rectSortingStrategy,children:w.map(S=>o.jsx(Bt,{id:S,container:e},S))})]})]})},os=5,yh=({id:e,elementRef:t,tamanho:r,inicioColuna:n,onPositionApply:s,setPositionDrag:a,setSelected:i,reorderStrategy:l})=>{const c=_.useRef({inicioColuna:n,tamanho:r});c.current={inicioColuna:n,tamanho:r};const d=_.useRef(null);return _.useEffect(()=>()=>{var p;(p=d.current)==null||p.call(d)},[]),{handleGripMouseDown:_.useCallback(p=>{p.preventDefault(),p.stopPropagation(),i(e);const f=p.clientX,x=p.clientY;let g=!1;const h=()=>{d.current=null,window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",b)},v=C=>{const j=Math.abs(C.clientX-f),S=Math.abs(C.clientY-x);j<os&&S<os||(g=!0,h(),j>=S?w(C):N(C))},b=()=>{g||h()};window.addEventListener("mousemove",v),window.addEventListener("mouseup",b),d.current=h;const w=C=>{const j=t.current;if(!j)return;const S=j.parentElement;if(!S)return;const P=S.getBoundingClientRect(),A=P.width/12,{tamanho:I}=c.current,O=j.getBoundingClientRect(),D=O.left-P.left,F=Math.max(1,Math.min(12,Math.round(D/A)+1)),z=O.left;a({itemId:e,ghostStart:F,ghostSpan:I,cursorX:C.clientX,cursorY:C.clientY});const V=R=>{const $=R-z,L=Math.round($/A)+1;return Math.max(1,Math.min(13-I,L))};a({itemId:e,ghostStart:V(C.clientX),ghostSpan:I,cursorX:C.clientX,cursorY:C.clientY});const k=R=>{a({itemId:e,ghostStart:V(R.clientX),ghostSpan:I,cursorX:R.clientX,cursorY:R.clientY})},E=R=>{s(V(R.clientX)),a(null),d.current=null,window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",E)};window.addEventListener("mousemove",k),window.addEventListener("mouseup",E),d.current=()=>{a(null),window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",E)}},N=C=>{const j=l,S=t.current;if(!S)return;const P=S.parentElement;if(!P)return;const y=j.dataAttribute||"data-container-id";j.pushSnapshot(),j.setReorderDrag({draggingId:e});let A=C.clientY;const I=D=>{const F=Array.from(P.children).filter(z=>z!==S&&z.getAttribute(y));for(const z of F){const V=z.getBoundingClientRect(),k=V.top+V.height/2;if(D.clientY<k&&D.clientY>V.top&&D.clientY<A){j.moveItemNoSnapshot(e,"up"),A=D.clientY;break}else if(D.clientY>k&&D.clientY<V.bottom&&D.clientY>A){j.moveItemNoSnapshot(e,"down"),A=D.clientY;break}}},O=()=>{j.setReorderDrag(null),d.current=null,window.removeEventListener("mousemove",I),window.removeEventListener("mouseup",O)};window.addEventListener("mousemove",I),window.addEventListener("mouseup",O),d.current=()=>{j.setReorderDrag(null),window.removeEventListener("mousemove",I),window.removeEventListener("mouseup",O)}}},[e,t,s,a,i,l])}},un=({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]})})]}),mn=({id:e,container:t})=>{var k;const{setNodeRef:r,isOver:n}=jt.useDroppable({id:`zone-${e}`}),{selectedId:s,setSelected:a,getConfig:i,updateConfig:l,removeItem:c,moveItem:d,moveItemNoSnapshot:m,setPositionDrag:p,positionDrag:f,reorderDrag:x,setReorderDrag:g,pushSnapshot:h,containers:v}=ke(),b=i(e),w=((k=v[e])==null?void 0:k.children)??[],N=w.filter(E=>me(E)==="field"),C=s===e,j=b.tamanho||12,S=(f==null?void 0:f.itemId)===e,P=(x==null?void 0:x.draggingId)===e,y=f&&w.includes(f.itemId),A=s&&w.includes(s)&&me(s)==="field",{resizeRef:I,resizing:O,resizePreview:D,handleResizeStart:F}=_l({id:e,currentTamanho:j,inicioColuna:b.inicioColuna,onResize:E=>l(e,{tamanho:E})}),z=_.useMemo(()=>({kind:"custom",moveItemNoSnapshot:m,pushSnapshot:h,setReorderDrag:g,dataAttribute:"data-container-id"}),[m,h,g]),{handleGripMouseDown:V}=yh({id:e,elementRef:I,tamanho:j,inicioColuna:b.inicioColuna||1,onPositionApply:E=>l(e,{inicioColuna:E}),setPositionDrag:p,setSelected:a,reorderStrategy:z});return o.jsxs(o.Fragment,{children:[o.jsxs("div",{ref:E=>{I.current=E},onClick:E=>{E.stopPropagation(),a(e)},className:W("group/cont relative rounded-lg border overflow-hidden transition-all",O&&"ring-2 ring-blue-400/50",S&&"opacity-0 pointer-events-none",P&&"opacity-50 ring-2 ring-primary/40",C?"border-primary ring-2 ring-primary/20 shadow-lg":"border-blue-500/30 hover:border-blue-500/50"),"data-container-id":e,style:{gridColumn:b.inicioColuna?`${b.inicioColuna} / span ${j}`:`span ${j}`,minWidth:"80px"},children:[o.jsxs("div",{className:W("flex items-center gap-1.5 border-b px-2 py-1.5 transition-colors",C?"bg-primary/15 border-primary/30":"bg-blue-500/10 border-blue-500/20"),children:[o.jsx("div",{"data-grip":!0,onMouseDown:V,className:"shrink-0 p-1 -ml-1 rounded hover:bg-primary/20 transition-colors",style:{cursor:"grab"},children:o.jsx(T.GripVertical,{className:"h-3.5 w-3.5 text-primary"})}),o.jsxs("div",{className:"flex flex-col -my-1 shrink-0",children:[o.jsx("button",{onClick:E=>{E.stopPropagation(),d(e,"up")},className:"p-0 hover:bg-primary/10 rounded transition-colors",title:"Mover para cima",children:o.jsx(T.ChevronUp,{className:"h-3 w-3 text-muted-foreground hover:text-primary"})}),o.jsx("button",{onClick:E=>{E.stopPropagation(),d(e,"down")},className:"p-0 hover:bg-primary/10 rounded transition-colors",title:"Mover para baixo",children:o.jsx(T.ChevronDown,{className:"h-3 w-3 text-muted-foreground hover:text-primary"})})]}),o.jsx(T.BoxSelect,{className:"h-3.5 w-3.5 text-blue-500 shrink-0"}),o.jsx("span",{className:W("text-xs font-semibold truncate flex-1",b.showLabel===!1?"text-blue-400/50 dark:text-blue-500/40 italic":"text-blue-700 dark:text-blue-300"),children:b.label}),b.showAsCard&&o.jsx(T.SquareStack,{className:"h-3 w-3 text-blue-400 shrink-0"}),b.showLabel===!1&&o.jsx(T.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:[D??j,"/12"]}),o.jsx("button",{onClick:E=>{E.stopPropagation(),c(e)},className:"opacity-0 group-hover/cont:opacity-100 transition-opacity shrink-0 p-0.5 rounded hover:bg-destructive/10",children:o.jsx(T.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-muted-foreground font-mono",style:{fontSize:"8px",opacity:.3},children:e})}),o.jsxs("div",{ref:r,className:W("relative p-2 min-h-[40px] gap-1.5 transition-all duration-150",n?"bg-primary/15 ring-2 ring-inset ring-primary/50":(y||A)&&"bg-muted/30"),style:{display:"grid",gridTemplateColumns:"repeat(12, minmax(0, 1fr))",gridAutoRows:"min-content"},children:[o.jsx(un,{showGuides:!!y||!!A,positionDrag:y?f:null}),w.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(Fe.SortableContext,{items:N,strategy:Fe.rectSortingStrategy,children:w.filter(E=>me(E)==="field").map(E=>i(E).fieldType==="field_array"?o.jsx(bh,{id:E,container:e},E):o.jsx(Bt,{id:E,container:e},E))})]}),o.jsx("div",{onMouseDown:F,className:"absolute right-0 top-0 bottom-0 w-2 hover:bg-blue-500/20 transition-colors flex items-center justify-center",style:{cursor:"col-resize"},children:o.jsx(T.GripHorizontal,{className:"h-3 w-3 text-blue-500/40 rotate-90"})})]}),S&&f&&So.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(T.BoxSelect,{className:"h-2.5 w-2.5"}),"col ",f.ghostStart,"–",f.ghostStart+f.ghostSpan-1]}),document.body)," "]})},Dl=({id:e,container:t,index:r})=>{var S;const{attributes:n,listeners:s,setNodeRef:a,transform:i,transition:l,isDragging:c}=Fe.useSortable({id:e,data:{isCanvasItem:!0,type:"step",id:e}}),{setNodeRef:d,isOver:m}=jt.useDroppable({id:`zone-${e}`}),{selectedId:p,setSelected:f,getConfig:x,removeItem:g,containers:h,positionDrag:v}=ke(),b=x(e),w=((S=h[e])==null?void 0:S.children)??[],N=p===e,C=v&&w.includes(v.itemId),j={transform:Mt.CSS.Transform.toString(i),transition:l,opacity:c?0:1};return o.jsxs("div",{ref:a,style:j,onClick:P=>{P.stopPropagation(),f(e)},className:W("group/step rounded-xl border-2 overflow-hidden transition-all",N?"border-primary ring-2 ring-primary/20":"border-primary/20 hover:border-primary/40"),children:[o.jsxs("div",{className:"flex items-center gap-2 bg-primary/10 border-b border-primary/20 px-3 py-2",children:[o.jsx("div",{...s,...n,className:"shrink-0",style:{cursor:"grab"},onClick:P=>P.stopPropagation(),children:o.jsx(T.GripVertical,{className:"h-3.5 w-3.5 text-muted-foreground"})}),o.jsx(T.Layers,{className:"h-4 w-4 text-primary"}),o.jsxs("span",{className:"text-sm font-bold text-primary truncate flex-1",children:["Step ",r+1," — ",b.label]}),b.description&&o.jsx("span",{className:"text-[10px] text-muted-foreground truncate hidden md:block",children:b.description}),o.jsx("button",{onClick:P=>{P.stopPropagation(),g(e)},className:"opacity-0 group-hover/step:opacity-100 transition-opacity shrink-0 p-1 rounded hover:bg-destructive/10",children:o.jsx(T.Trash2,{className:"h-3.5 w-3.5 text-destructive"})})]}),o.jsxs("div",{ref:d,className:W("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(un,{showGuides:!!C,positionDrag:C?v:null}),w.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"}),w.map(P=>me(P)==="container"?o.jsx(mn,{id:P,container:e},P):o.jsx(Bt,{id:P,container:e},P))]})]})},wh=()=>{var i;const{containers:e,setSelected:t}=ke(),r=((i=e.root)==null?void 0:i.children)??[],n=r.filter(l=>me(l)==="step"),{setNodeRef:s,isOver:a}=jt.useDroppable({id:"root"});return o.jsxs("div",{ref:s,onClick:()=>t(null),className:`min-h-[500px] rounded-xl border p-4 space-y-4 transition-all duration-150 ${a?"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:a?void 0:"hsl(var(--muted) / 0.3)"},children:[r.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(T.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(Fe.SortableContext,{items:n,strategy:Fe.verticalListSortingStrategy,children:r.map((l,c)=>{const d=me(l);return d==="step"?o.jsx(Dl,{id:l,container:"root",index:c},l):d==="container"?o.jsx(mn,{id:l,container:"root"},l):o.jsx(Bt,{id:l,container:"root"},l)})})]})},Nh={personal:"Pessoal",address:"Endereço",health:"Saúde",event:"Evento",payment:"Pagamento",emergency:"Emergência"},Ch={texto:"Texto",selecao:"Seleção",range:"Numérico / Visual",data:"Data e Hora",contato:"Contato / Endereço",outros:"Arquivo / Outros"},jh=()=>{const e=at.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"}),ss.map(t=>o.jsx(ns,{component:t.component,label:t.label,icon:t.icon,color:t.color},t.component))]}),Object.entries(e).map(([t,r])=>o.jsx(ro,{label:Ch[t]??t,children:r.map(n=>o.jsx(ns,{component:n.component,label:n.label,icon:n.icon,color:"border-border"},n.component))},t)),o.jsx(ro,{label:"Blocos pré-configurados",defaultOpen:!1,children:Ye.PRESET_BLOCKS.map(t=>o.jsx(Sh,{block:t},t.id))}),o.jsx(ro,{label:"Blocos de steps",defaultOpen:!1,children:Ye.PRESET_STEP_BLOCKS.map(t=>o.jsx(Ph,{block:t},t.id))})]})},ro=({label:e,children:t,defaultOpen:r=!0})=>{const[n,s]=_.useState(r);return o.jsxs("div",{className:"space-y-2",children:[o.jsxs("button",{type:"button",onClick:()=>s(a=>!a),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(T.ChevronDown,{className:`h-3.5 w-3.5 transition-transform ${n?"":"-rotate-90"}`})]}),n&&o.jsx("div",{className:"space-y-1.5",children:t})]})},ns=({component:e,label:t,icon:r,color:n})=>{const{attributes:s,listeners:a,setNodeRef:i,transform:l,isDragging:c}=jt.useDraggable({id:`palette-${e}`,data:{isPaletteItem:!0,componentType:e}});return o.jsxs("div",{ref:i,...a,...s,className:`flex items-center gap-2 rounded-lg border px-3 py-2 select-none hover:bg-accent transition-colors ${n} ${c?"opacity-50":""}`,style:{cursor:"grab",transform:c?void 0:Mt.CSS.Translate.toString(l)},children:[o.jsx(T.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})]})},Sh=({block:e})=>{const{attributes:t,listeners:r,setNodeRef:n,transform:s,isDragging:a}=jt.useDraggable({id:`preset-${e.id}`,data:{isPalettePreset:!0,presetId:e.id}}),i=e.icon?Lt[e.icon]:void 0,l=Nh[e.category]??e.category;return o.jsxs("div",{ref:n,...r,...t,className:`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 ${a?"opacity-50":""}`,style:{cursor:"grab",transform:a?void 0:Mt.CSS.Translate.toString(s)},title:e.description,children:[o.jsx(T.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(Lt.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})]})]})},Ph=({block:e})=>{const{addPresetStepBlock:t}=ke(),r=e.icon?Lt[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(Lt.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"]})]})},oo=e=>({when:e.campoId,operator:e.operador,value:e.valor,source:e.source}),Ml=e=>{var r;const t={campoId:e.when,operador:e.operator,valor:e.value,source:e.source};if(e.logicOperator&&((r=e.extraConditions)!=null&&r.length)){const n=e.extraConditions.map(a=>({campoId:a.when,operador:a.operator,valor:a.value,source:a.source})),s=[t,...n];return e.logicOperator==="or"?{or:s}:{and:s}}return t},$l=e=>{if("campoId"in e)return oo(e);const t=("and"in e?e.and:e.or)??[];if(t.length===0)return;const r="and"in e?"and":"or",[n,...s]=t;if(!("campoId"in n))return;const a=oo(n);return s.length===0?a:{...a,logicOperator:r,extraConditions:s.filter(i=>"campoId"in i).map(oo)}},Rh=(e,t,r)=>{var i,l;const n=c=>t[c]||{label:c,name:c},a=(((l=(i=e==null?void 0:e.containers)==null?void 0:i.root)==null?void 0:l.children)||[]).filter(c=>me(c)==="step").map((c,d)=>{var x,g;const m=n(c),f=(((g=(x=e==null?void 0:e.containers)==null?void 0:x[c])==null?void 0:g.children)||[]).filter(h=>me(h)==="container").map((h,v)=>{var j,S;const b=n(h),N=(((S=(j=e==null?void 0:e.containers)==null?void 0:j[h])==null?void 0:S.children)||[]).filter(P=>me(P)==="field").map((P,y)=>{var O,D;const A=n(P),I=Co(A,P,y);if(I.tipo===de.FieldType.FIELD_ARRAY){const F=((D=(O=e==null?void 0:e.containers)==null?void 0:O[P])==null?void 0:D.children)??[];I.subFields=F.filter(z=>me(z)==="field").map((z,V)=>Co(n(z),z,V))}return I}),C={id:h,titulo:b.label||"Container",descricao:b.description,icone:b.icone,ordem:v,colunas:b.columns||2,tamanho:b.tamanho||12,inicioColuna:b.inicioColuna,showLabel:b.showLabel,showAsCard:b.showAsCard,campos:N};return b.condition&&(C.condicional=Ml(b.condition)),C});return{id:c,titulo:m.label||"Step",descricao:m.description,icone:m.icone,ordem:d,showLabel:m.showLabel,containers:f}});return{id:r.id||"",nome:r.nome,descricao:r.descricao,status:r.status,template:r.template??null,steps:a}},Co=(e,t,r)=>{var s,a,i,l;const n={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((s=e.validate)!=null&&s.length&&(n.validate=e.validate),(a=e.warn)!=null&&a.length&&(n.warn=e.warn),(i=e.options)!=null&&i.length&&(n.opcoes=e.options.map(c=>({valor:c.value,label:c.label,disabled:c.disabled}))),e.validation){const c=e.validation;n.validacao={},c.minLength!==void 0&&(n.validacao.minLength=c.minLength),c.maxLength!==void 0&&(n.validacao.maxLength=c.maxLength),c.min!==void 0&&(n.validacao.min=c.min),c.max!==void 0&&(n.validacao.max=c.max),c.regex&&(n.validacao.regex=c.regex),c.regexMessage&&(n.validacao.regexMessage=c.regexMessage),c.minDate&&(n.validacao.minDate=c.minDate),c.maxDate&&(n.validacao.maxDate=c.maxDate),c.minAge!==void 0&&(n.validacao.minAge=c.minAge),c.maxAge!==void 0&&(n.validacao.maxAge=c.maxAge),(l=c.fileTypes)!=null&&l.length&&(n.validacao.fileTypes=c.fileTypes),c.maxFileSize!==void 0&&(n.validacao.maxFileSize=c.maxFileSize)}if(n.tipo===de.FieldType.FIELD_ARRAY&&(e.itemLabel&&(n.itemLabel=e.itemLabel),e.minItems!==void 0&&(n.minItems=e.minItems),e.maxItems!==void 0&&(n.maxItems=e.maxItems),e.addLabel&&(n.addLabel=e.addLabel)),n.tipo===de.FieldType.TERMS&&(e.termoTexto&&(n.termoTexto=e.termoTexto),e.termoPdfUrl&&(n.termoPdfUrl=e.termoPdfUrl),e.termoPdfUploadId&&(n.termoPdfUploadId=e.termoPdfUploadId)),n.tipo===de.FieldType.SLIDER&&(e.step!==void 0&&(n.step=e.step),e.minValue!==void 0&&(n.minValue=e.minValue),e.maxValue!==void 0&&(n.maxValue=e.maxValue)),n.tipo===de.FieldType.RATING&&e.maxRating!==void 0&&(n.maxRating=e.maxRating),n.tipo===de.FieldType.DATE_RANGE&&(e.dateRangeStartLabel&&(n.dateRangeStartLabel=e.dateRangeStartLabel),e.dateRangeEndLabel&&(n.dateRangeEndLabel=e.dateRangeEndLabel)),n.tipo===de.FieldType.SUB_FORM){const c=e.subSchemaFields??[];(c.length>0||e.subSchemaTitle)&&(n.subSchema={titulo:e.subSchemaTitle,fields:c.map((d,m)=>Co(d,d.name??`subfield-${m}`,m))})}return e.condition&&(n.condicional=Ml(e.condition)),n},Eh=e=>{const t={},r={root:{children:[]}},n=[...e.steps].sort((s,a)=>s.ordem-a.ordem);for(const s of n){const a=s.id||`step-${de.v4Fallback()}`;r.root.children.push(a),t[a]={label:s.titulo,name:a,fieldType:"step",description:s.descricao,icone:s.icone,showLabel:s.showLabel};const i=[],l=[...s.containers].sort((c,d)=>c.ordem-d.ordem);for(const c of l){const d=c.id||`container-${de.v4Fallback()}`;i.push(d);const m=c.condicional?$l(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,...m?{condition:m}:{}};const p=[],f=[...c.campos].sort((x,g)=>x.ordem-g.ordem);for(const x of f){const g=x.id||`${x.tipo}-${de.v4Fallback()}`;if(p.push(g),t[g]=jo(x),x.tipo===de.FieldType.FIELD_ARRAY){const h=[];for(const v of x.subFields??[]){const b=v.id||`${v.tipo}-${de.v4Fallback()}`;h.push(b),t[b]=jo(v)}r[g]={children:h}}}r[d]={children:p}}r[a]={children:i}}return{dndState:{containers:r},configs:t,templateId:e.template??null}},jo=(e,t)=>{var n,s,a,i;const r={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!=null?String(e.clearedValue):void 0,initialValue:e.initialValue!==void 0?String(e.initialValue):void 0,resolvePropsKey:e.resolvePropsKey||void 0,validate:(n=e.validate)!=null&&n.length?e.validate:void 0,warn:(s=e.warn)!=null&&s.length?e.warn:void 0};if((a=e.opcoes)!=null&&a.length&&(r.options=e.opcoes.map(l=>({value:l.valor,label:l.label,disabled:l.disabled}))),e.validacao){const l=e.validacao;r.validation={},l.minLength!==void 0&&(r.validation.minLength=l.minLength),l.maxLength!==void 0&&(r.validation.maxLength=l.maxLength),l.min!==void 0&&(r.validation.min=l.min),l.max!==void 0&&(r.validation.max=l.max),l.regex&&(r.validation.regex=l.regex),l.regexMessage&&(r.validation.regexMessage=l.regexMessage),l.minDate&&(r.validation.minDate=l.minDate),l.maxDate&&(r.validation.maxDate=l.maxDate),l.minAge!==void 0&&(r.validation.minAge=l.minAge),l.maxAge!==void 0&&(r.validation.maxAge=l.maxAge),(i=l.fileTypes)!=null&&i.length&&(r.validation.fileTypes=l.fileTypes),l.maxFileSize!==void 0&&(r.validation.maxFileSize=l.maxFileSize)}if(e.tipo===de.FieldType.FIELD_ARRAY&&(e.itemLabel&&(r.itemLabel=e.itemLabel),e.minItems!==void 0&&(r.minItems=e.minItems),e.maxItems!==void 0&&(r.maxItems=e.maxItems),e.addLabel&&(r.addLabel=e.addLabel)),e.tipo===de.FieldType.TERMS&&(e.termoTexto&&(r.termoTexto=e.termoTexto),e.termoPdfUrl&&(r.termoPdfUrl=e.termoPdfUrl),e.termoPdfUploadId&&(r.termoPdfUploadId=e.termoPdfUploadId)),e.tipo===de.FieldType.SLIDER&&(e.step!==void 0&&(r.step=e.step),e.minValue!==void 0&&(r.minValue=e.minValue),e.maxValue!==void 0&&(r.maxValue=e.maxValue)),e.tipo===de.FieldType.RATING&&e.maxRating!==void 0&&(r.maxRating=e.maxRating),e.tipo===de.FieldType.DATE_RANGE&&(e.dateRangeStartLabel&&(r.dateRangeStartLabel=e.dateRangeStartLabel),e.dateRangeEndLabel&&(r.dateRangeEndLabel=e.dateRangeEndLabel)),e.tipo===de.FieldType.SUB_FORM&&e.subSchema&&(r.subSchemaTitle=e.subSchema.titulo,r.subSchemaFields=e.subSchema.fields.map(l=>jo(l,l.id))),e.condicional){const l=$l(e.condicional);l&&(r.condition=l)}return r},Ah=(e,t)=>{var l,c,d,m,p,f,x;const r=[],n=[],s=g=>t[g]||{label:g,name:g},a=((c=(l=e==null?void 0:e.containers)==null?void 0:l.root)==null?void 0:c.children)||[],i=new Set;for(const g of a){if(me(g)!=="step")continue;const h=s(g).label||g,v=((m=(d=e==null?void 0:e.containers)==null?void 0:d[g])==null?void 0:m.children)||[];if(v.length===0){n.push(`Step "${h}" está vazio (sem containers).`);continue}for(const b of v){if(me(b)!=="container")continue;const w=s(b).label||b,N=((f=(p=e==null?void 0:e.containers)==null?void 0:p[b])==null?void 0:f.children)||[],C=new Map;for(const j of N){if(me(j)!=="field")continue;i.add(j);const S=s(j).name||j;C.has(S)||C.set(S,[]),C.get(S).push(j)}for(const[j,S]of C.entries())S.length>1&&r.push(`Nome duplicado "${j}" no container "${w}" (IDs: ${S.join(", ")}).`)}}for(const[g,h]of Object.entries(t)){if(!((x=h.condition)!=null&&x.when))continue;const v=h.condition.when;if(!i.has(v)){const b=h.label||g;n.push(`Campo "${b}" referencia campo inexistente na condição (when: "${v}").`)}}return{errors:r,warnings:n}};exports.BuilderProvider=Bl;exports.Canvas=wh;exports.ConfigPanel=th;exports.DroppedContainer=mn;exports.DroppedField=Bt;exports.DroppedStep=Dl;exports.EVENT_VARIABLES=Ro;exports.FIELD_TYPES=at;exports.GridOverlay=un;exports.LivePreview=gh;exports.Palette=jh;exports.STRUCTURE_TYPES=ss;exports.builderToFormSchema=Rh;exports.findParentContainer=cs;exports.formSchemaToBuilder=Eh;exports.getFieldMeta=zl;exports.getFieldMetaById=as;exports.getItemType=me;exports.useBuilder=ke;exports.validateBuilderIntegrity=Ah;
|
|
51
51
|
//# sourceMappingURL=index.cjs.map
|