1import{j as e,r as y,c as A}from"./index-hZcJ3UF8.js";import{m as f,B as C,bc as ae,p as se,aS as I,bd as re,g as ne,w as ie,aw as k,a6 as oe,I as R,K as le,kG as B,J as ce,bD as ue,by as de,bv as me,q as U,X as he,A as pe,bT as xe,D as fe,u as ye}from"./App-BRQ1r2T_.js";import{P as X}from"./party-popper-BOeJhFL5.js";import{G as ge}from"./grip-vertical-CRukY2MR.js";import"./tabs-D3mHn8_3.js";import{S as be}from"./Seo-C2Hffg5B.js";function we({progress:t,accentColor:s="hsl(var(--primary))"}){return e.jsx("div",{className:"fixed top-0 left-0 right-0 h-1 bg-white/10 z-50",children:e.jsx(f.div,{className:"h-full",style:{backgroundColor:s},initial:{width:0},animate:{width:`${t}%`},transition:{duration:.3,ease:"easeOut"}})})}function ve({onPrev:t,onNext:s,canGoPrev:n,canGoNext:r,isLastStep:a,isSubmitting:d,onSubmit:b,accentColor:j}){return e.jsxs(f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.5},className:"fixed bottom-8 right-8 flex gap-2 z-50",children:[n&&e.jsx(C,{type:"button",variant:"ghost",size:"icon",onClick:t,className:"rounded-full bg-white/10 hover:bg-white/20 text-white border-0",children:e.jsx(ae,{className:"h-5 w-5"})}),e.jsx(C,{type:"button",onClick:a?b:s,disabled:d,className:"rounded-full px-6",style:{backgroundColor:j},children:d?e.jsx(se,{className:"h-4 w-4 animate-spin"}):a?e.jsxs(e.Fragment,{children:["Enviar",e.jsx(I,{className:"ml-2 h-4 w-4"})]}):e.jsxs(e.Fragment,{children:["OK",e.jsx(I,{className:"ml-2 h-4 w-4"})]})}),r&&!a&&e.jsx(C,{type:"button",variant:"ghost",size:"icon",onClick:s,className:"rounded-full bg-white/10 hover:bg-white/20 text-white border-0",children:e.jsx(re,{className:"h-5 w-5"})})]})}function je({title:t="Bem-vindo!",description:s="Responda algumas perguntas rápidas.",buttonText:n="Começar",onStart:r,accentColor:a}){return e.jsxs(f.div,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},exit:{opacity:0,y:-30},transition:{duration:.5,ease:[.4,0,.2,1]},className:"max-w-2xl mx-auto px-6 text-center text-white",children:[e.jsx(f.h1,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2},className:"text-4xl md:text-5xl lg:text-6xl font-bold mb-6",children:t}),s&&e.jsx(f.p,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.3},className:"text-lg md:text-xl opacity-80 mb-10",children:s}),e.jsx(f.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},transition:{delay:.4},children:e.jsxs(C,{size:"lg",onClick:r,className:"rounded-full px-8 py-6 text-lg font-semibold",style:{backgroundColor:a},children:[n,e.jsx(ne,{className:"ml-2 h-5 w-5"})]})}),e.jsxs(f.p,{initial:{opacity:0}
1,animate:{opacity:.5},transition:{delay:.6},className:"mt-8 text-sm",children:["Pressione ",e.jsx("kbd",{className:"px-2 py-1 bg-white/10 rounded mx-1",children:"Enter âµ"})," para começar"]})]})}function Ne({title:t="Obrigado!",message:s="Suas respostas foram enviadas com sucesso.",onClose:n,accentColor:r}){return e.jsxs(f.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},transition:{duration:.5,ease:[.4,0,.2,1]},className:"max-w-2xl mx-auto px-6 text-center text-white",children:[e.jsx(f.div,{initial:{scale:0},animate:{scale:1},transition:{delay:.2,type:"spring",stiffness:200},className:"mb-8",children:e.jsx("div",{className:"w-24 h-24 rounded-full mx-auto flex items-center justify-center",style:{backgroundColor:r||"hsl(var(--primary))"},children:e.jsx(ie,{className:"h-12 w-12 text-white"})})}),e.jsxs(f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.3},className:"flex items-center justify-center gap-3 mb-4",children:[e.jsx(X,{className:"h-8 w-8"}),e.jsx("h1",{className:"text-4xl md:text-5xl font-bold",children:t}),e.jsx(X,{className:"h-8 w-8"})]}),e.jsx(f.p,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.4},className:"text-lg md:text-xl opacity-80 mb-10",children:s}),n&&e.jsx(f.div,{initial:{opacity:0}
1,animate:{opacity:1},transition:{delay:.6},children:e.jsx(C,{variant:"outline",onClick:n,className:"rounded-full px-8 border-white/30 text-white hover:bg-white/10",children:"Fechar"})})]})}const _e={enter:t=>({y:t>0?100:-100,opacity:0,scale:.95}),center:{y:0,opacity:1,scale:1},exit:t=>({y:t<0?100:-100,opacity:0,scale:.95})};function ke({field:t,questionNumber:s,totalQuestions:n,direction:r,form:a,onNext:d,autoAdvance:b=!0,accentColor:j="hsl(var(--primary))"}){const p=a.watch(t.field_key),x=a.formState.errors[t.field_key],o=l=>{a.setValue(t.field_key,l,{shouldValidate:!0}),b&&setTimeout(d,400)},m=l=>{l.key==="Enter"&&!l.shiftKey&&(l.preventDefault(),d())},u=k("w-full bg-transparent border-0 border-b-2 border-white/30","text-2xl md:text-3xl text-center py-4 focus:outline-none focus:border-white","placeholder:text-white/30 h-auto text-white"),h=()=>{const l=t.field_type;if(l==="hidden")return e.jsx(Q,{field:t,form:a});if(l==="rating")return e.jsx(Ce,{value:p,onChange:c=>{a.setValue(t.field_key,c,{shouldValidate:!0}),b&&setTimeout(d,400)}});if(l==="nps")return e.jsx(Se,{value:p,onChange:c=>{a.setValue(t.field_key,c,{shouldValidate:!0}),b&&setTimeout(d,400)}});if(l==="slider"){const c=t.validation?.min??0,w=t.validation?.max??100,F=t.validation?.step??1;return e.jsx(Ee,{value:p??Math.round((c+w)/2),min:c,max:w,step:F,onChange:S=>a.setValue(t.field_key,S,{shouldValidate:!0})})}if(l==="date")return e.jsx(R,{type:"date",value:p||"",onChange:c=>a.setValue(t.field_key,c.target.value,{shouldValidate:!0}),onKeyDown:m,autoFocus:!0,className:u});if(l==="file_upload")return e.jsx(Te,{field:t,form:a});if(l==="signature")return e.jsx(De,{value:p,onChange:c=>a.setValue(t.field_key,c,{shouldValidate:!0})});if(l==="ranking"&&t.options?.length)return e.jsx(Fe,{field:t,value:p,onChange:c=>a.setValue(t.field_key,c,{shouldValidate:!0})});if((l==="radio"||l==="select")&&t.options?.length)return e.jsx("div",{className:"space-y-3 text-left",children:t.options.map((c,w)=>e.jsxs(f.button,{type:"button",whileHover:{scale:1.02},whileTap:{scale:.98},onClick:()=>o(c.value),className:k("w-full p-4 rounded-xl border-2 text-left transition-all","flex items-center gap-4 bg-white/5 backdrop-blur-sm",p===c.value?"border-white bg-white/20":"border-white/20 hover:border-white/40"),children:[e.jsx("span",{className:k("w-8 h-8 rounded border-2 flex items-center justify-center font-bold text-sm shrink-0",p===c.value?"bg-white text-black border-white":"border-white/50"),children:String.fromCharCode(65+w)}),e.jsx("span",{className:"text-lg flex-1",children:c.label}),p===c.value&&e.jsx(I,{className:"h-5 w-5 shrink-0"})]},c.value))});if(l==="checkbox"&&t.options?.length){const c=Array.isArray(p)?p:[];return e.jsxs("div",{className:"space-y-3 text-left",children:[t.options.map((w,F)=>{const S=c.includes(w.value);return e.jsxs(f.button,{type:"button",whileHover:{scale:1.02},whileTap:{scale:.98},onClick:()=>{const E=S?c.filter(V=>V!==w.value):[...c,w.value];a.setValue(t.field_key,E,{shouldValidate:!0})},className:k("w-full p-4 rounded-xl border-2 text-left transition-all","flex items-center gap-4 bg-white/5 backdrop-blur-sm",S?"border-white bg-white/20":"border-white/20 hover:border-white/40"),children:[e.jsx("span",{className:k("w-8 h-8 rounded border-2 flex items-center justify-center font-bold text-sm shrink-0",S?"bg-white text-black border-white":"border-white/50"),children:String.fromCharCode(65+F)}),e.jsx("span",{className:"text-lg flex-1",children:w.label}),S&&e.jsx(I,{className:"h-5 w-5 shrink-0"})]},w.value)}),e.jsx("p",{className:"text-sm opacity-50 text-center mt-4",children:"Selecione uma ou mais opções"})]})}return l==="textarea"?e.jsx(le,{...a.register(t.field_key),placeholder:t.custom_placeholder||"Digite sua resposta...",className:k("w-full bg-transparent border-0 border-b-2 border-white/30","text-xl text-center py-4 focus:outline-none focus:border-white","placeholder:text-white/30 resize-none min-h-[120px] text-white"),rows:4}):l==="phone"?e.jsx(B,{mask:"(99) 99999-9999",value:p||"",onChange:c=>a.setValue(t.field_key,c.target.value),onKeyDown:m,children:c=>e.jsx(R,{...c,type:"tel",autoFocus:!0,placeholder:t.custom_placeholder||"(11) 99999-9999",className:u})}):l==="cpf"?e.jsx(B,{mask:"999.999.999-99",value:p||"",onChange:c=>a.setValue(t.field_key,c.target.value),onKeyDown:m,children:c=>e.jsx(R,{...c,autoFocus:!0,placeholder:t.custom_placeholder||"000.000.000-00",className:u})}):l==="cnpj"?e.jsx(B,{mask:"99.999.999/9999-99",value:p||"",onChange:c=>a.setValue(t.field_key,c.target.value),onKeyDown:m,children:c=>e.jsx(R,{...c,autoFocus:!0,placeholder:t.custom_placeholder||"00.000.000/0000-00",className:u})}):e.jsx(R,{...a.register(t.field_key),type:l==="number"?"number":l==="email"?"email":"text",autoFocus:!0,placeholder:t.custom_placeholder||"Digite sua resposta...",onKeyDown:m,className:u})};return t.field_type==="hidden"?e.jsx(Q,{field:t,form:a}):e.jsxs(f.div,{custom:r,variants:_e,initial:"enter",animate:"center",exit:"exit",transition:{duration:.4,ease:[.4,0,.2,1]},className:"max-w-2xl mx-auto px-6 text-center text-white",children:[e.jsxs(f.span,{initial:{opacity:0}
1,animate:{opacity:.6},className:"text-sm mb-4 block",children:[s," â ",n]}),e.jsxs(f.h2,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.1},className:"text-2xl md:text-3xl lg:text-4xl font-bold mb-8",children:[t.custom_label||t.display_name,t.required&&e.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),t.tooltip&&e.jsx(f.p,{initial:{opacity:0},animate:{opacity:.7},transition:{delay:.2},className:"text-sm mb-6 opacity-70",children:t.tooltip}),e.jsx(f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2},children:h()}),x&&e.jsx(f.p,{initial:{opacity:0},animate:{opacity:1},className:"mt-4 text-red-400 text-sm",children:x.message}),e.jsxs(f.p,{initial:{opacity:0},animate:{opacity:.5},transition:{delay:.5},className:"mt-8 text-sm",children:["Pressione ",e.jsx("kbd",{className:"px-2 py-1 bg-white/10 rounded mx-1",children:"Enter âµ"})," para continuar"]})]})}function Q({field:t,form:s}){return y.useEffect(()=>{oe().then(n=>{const r=t.field_key,a=n[r]||new URLSearchParams(window.location.search).get(r)||t.validation?.default_value||"";s.setValue(r,a)})},[]),null}function Ce({value:t,onChange:s}){const[n,r]=y.useState(0),a=Number(t)||0;return e.jsx("div",{className:"flex justify-center gap-3",children:[1,2,3,4,5].map(d=>e.jsx(f.button,{type:"button",whileHover:{scale:1.2},whileTap:{scale:.9},onMouseEnter:()=>r(d),onMouseLeave:()=>r(0),onClick:()=>s(d),className:"p-2",children:e.jsx(ce,{className:k("h-10 w-10 md:h-12 md:w-12 transition-colors",(n||a)>=d?"fill-yellow-400 text-yellow-400":"text-white/30")})},d))})}function Se({value:t,onChange:s}){const n=t!=null?Number(t):-1,r=a=>a<=6?"bg-red-500/80 hover:bg-red-500":a<=8?"bg-yellow-500/80 hover:bg-yellow-500":"bg-green-500/80 hover:bg-green-500";return e.jsxs("div",{children:[e.jsx("div",{className:"flex justify-center gap-1 md:gap-2 flex-wrap",children:Array.from({length:11},(a,d)=>d).map(a=>e.jsx(f.button,{type:"button",whileHover:{scale:1.1},whileTap:{scale:.9},onClick:()=>s(a),className:k("w-10 h-10 md:w-12 md:h-12 rounded-lg font-bold text-white transition-all",n===a?"ring-2 ring-white scale-110":"",r(a)),children:a},a))}),e.jsxs("div",{className:"flex justify-between mt-3 text-xs opacity-50",children:[e.jsx("span",{children:"Nada provável"}),e.jsx("span",{children:"Muito provável"})]})]})}function Ee({value:t,min:s,max:n,step:r,onChange:a}){return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"text-4xl font-bold text-center",children:t}),e.jsx("input",{type:"range",min:s,max:n,step:r,value:t,onChange:d=>a(Number(d.target.value)),className:"w-full h-2 bg-white/20 rounded-lg appearance-none cursor-pointer accent-white"}),e.jsxs("div",{className:"flex justify-between text-xs opacity-50",children:[e.jsx("span",{children:s}),e.jsx("span",{children:n})]})]})}function Te({field:t,form:s}){const[n,r]=y.useState(!1),[a,d]=y.useState(null),b=s.watch(t.field_key),j=async p=>{const x=p.target.files?.[0];if(x){r(!0);try{const o=x.name.split(".").pop(),m=`${Date.now()}_${Math.random().toString(36).slice(2)}.${o}`,{error:u}=await A.storage.from("form-uploads").upload(m,x);if(u)throw u;const{data:h}=A.storage.from("form-uploads").getPublicUrl(m);s.setValue(t.field_key,h.publicUrl,{shouldValidate:!0}),x.type.startsWith("image/")&&d(h.publicUrl)}catch(o){console.error("Upload error:",o)}finally{r(!1)}}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("label",{className:k("flex flex-col items-center justify-center w-full h-32 border-2 border-dashed rounded-xl cursor-pointer transition-all","border-white/30 hover:border-white/60 bg-white/5"),children:[e.jsx(ue,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("span",{className:"text-sm opacity-70",children:n?"Enviando...":"Clique para enviar arquivo"}),e.jsx("input",{type:"file",className:"hidden",onChange:j,disabled:n})]}),(a||b)&&e.jsx("div",{className:"text-center",children:a?e.jsx("img",{src:a,alt:"Preview",className:"max-h-32 mx-auto rounded-lg"}):e.jsx("span",{className:"text-sm opacity-70",children:"Arquivo enviado â"})})]})}function De({value:t,onChange:s}){const n=y.useRef(null),[r,a]=y.useState(!1),[d,b]=y.useState(!0);y.useEffect(()=>{const u=n.current;if(!u)return;const h=u.getContext("2d");
1if(!h)return;const l=u.getBoundingClientRect();u.width=l.width,u.height=l.height,h.strokeStyle="#fff",h.lineWidth=2,h.lineCap="round",h.lineJoin="round"},[]);const j=u=>{const l=n.current.getBoundingClientRect();return"touches"in u?{x:u.touches[0].clientX-l.left,y:u.touches[0].clientY-l.top}:{x:u.clientX-l.left,y:u.clientY-l.top}},p=u=>{a(!0);const h=n.current?.getContext("2d");if(!h)return;const l=j(u);h.beginPath(),h.moveTo(l.x,l.y)},x=u=>{if(!r)return;const h=n.current?.getContext("2d");if(!h)return;const l=j(u);h.lineTo(l.x,l.y),h.stroke(),b(!1)},o=()=>{a(!1),!d&&n.current&&s(n.current.toDataURL("image/png"))},m=()=>{const u=n.current;if(!u)return;const h=u.getContext("2d");h&&(h.clearRect(0,0,u.width,u.height),b(!0),s(""))};return e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"border-2 border-dashed border-white/30 rounded-xl overflow-hidden",children:e.jsx("canvas",{ref:n,className:"w-full h-40 cursor-crosshair touch-none",onMouseDown:p,onMouseMove:x,onMouseUp:o,onMouseLeave:o,onTouchStart:p,onTouchMove:x,onTouchEnd:o})}),e.jsx("div",{className:"flex justify-center",children:e.jsxs(C,{type:"button",variant:"ghost",size:"sm",onClick:m,disabled:d,className:"text-white/70 hover:text-white",children:[e.jsx(de,{className:"h-4 w-4 mr-1"})," Limpar"]})})]})}function Fe({field:t,value:s,onChange:n}){const[r,a]=y.useState(()=>Array.isArray(s)&&s.length?s:t.options.map(x=>x.value||x.label)),[d,b]=y.useState(null),j=(x,o)=>{const m=[...r],[u]=m.splice(x,1);m.splice(o,0,u),a(m),n(m)},p=x=>t.options.find(m=>(m.value||m.label)===x)?.label||x;return e.jsxs("div",{className:"space-y-2 text-left",children:[r.map((x,o)=>e.jsxs(f.div,{layout:!0,className:k("flex items-center gap-3 p-4 rounded-xl border-2 bg-white/5 backdrop-blur-sm cursor-grab active:cursor-grabbing transition-all",d===o?"border-white bg-white/20":"border-white/20"),draggable:!0,onDragStart:()=>b(o),onDragOver:m=>m.preventDefault(),onDrop:()=>{d!==null&&j(d,o),b(null)},onDragEnd:()=>b(null),children:[e.jsx(ge,{className:"h-5 w-5 opacity-50 shrink-0"}),e.jsx("span",{className:"w-6 h-6 rounded bg-white/10 flex items-center justify-center text-sm font-bold shrink-0",children:o+1}),e.jsx("span",{className:"text-lg flex-1",children:p(x)})]},x)),e.jsx("p",{className:"text-sm opacity-50 text-center mt-2",children:"Arraste para reordenar"})]})}const Ve=(t,s)=>{const n=t.conditional_logic;return n?.show_when?.length?n.show_when.every(r=>{const a=s[r.field_key];switch(r.operator){case"equals":return a===r.value;case"not_equals":return a!==r.value;case"contains":return Array.isArray(a)?a.includes(r.value):String(a||"").includes(r.value);default:return!0}}):!0},Pe=new Set(["text","email","number","phone","tel","textarea","select","radio","checkbox","cpf","cnpj","date","rating","nps","slider","file_upload","hidden","signature","ranking"]),Ae=t=>{const s=(t||"text").toLowerCase();return s==="tel"?"phone":Pe.has(s)?s:"text"},qe=t=>Array.isArray(t)?t.some(s=>typeof s?.field_key=="string")?t:t.filter(s=>typeof s?.name=="string").map(s=>({field_key:s.name,display_name:s.label||s.name,field_type:Ae(s.type),required:!!s.required,options:Array.isArray(s.options)?s.options.map(n=>({value:String(n.value??""),label:String(n.label??n.value??"")})):void 0,conditional_logic:void 0})):[];function ze({formId:t,formType:s,onSuccess:n,onClose:r}){const[a,d]=y.useState(null),[b,j]=y.useState(!0),[p,x]=y.useState(null),[o,m]=y.useState(-1),[u,h]=y.useState(1),[l,c]=y.useState(!1),[w,F]=y.useState(!1),[S]=y.useState(Date.now()),E=me({mode:"onChange"}),V=E.watch();y.useEffect(()=>{Z()},[t,s]);const Z=async()=>{try{j(!0),x(null),F(!1);let i=A.from("form_configs").select("*");t?i=i.eq("id",t):s&&(i=i.eq("type",s).eq("is_active",!0));const{data:g,error:M}=await i.single();if(M)throw M;const T={...g,fields_config:qe(g.fields_config)};d(T);const O=T.typeform_config||null;Array.isArray(T.fields_config)&&T.fields_config.length>0&&!O?.show_welcome_screen?m(0):m(-1)}catch(i){console.error("Erro ao carregar formulário:",i);const g=i?.message||"Erro ao carregar formulário";x(g),U.error("Erro ao carregar formulário")}finally{j(!1)}},P=y.useMemo(()=>a?.fields_config?a.fields_config.filter(i=>Ve(i,V)):[],[a,V]),v=P.length,ee=v>0,te=v>0?(o+1)/v*100:0,N=a?.typeform_config||{},q=N.accent_color||"hsl(var(--primary))",K=N.background_value||"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",z=y.useCallback(()=>
1{if(o<v-1){const i=P[o];if(i){const g=V[i.field_key];if(i.required&&!g){E.setError(i.field_key,{message:"Este campo é obrigatório"});return}E.clearErrors(i.field_key)}h(1),m(g=>g+1)}},[o,v,P,V,E]),L=y.useCallback(()=>{o>0&&(h(-1),m(i=>i-1))},[o]);y.useEffect(()=>{const i=g=>{w||(g.key==="Enter"&&!g.shiftKey&&(g.preventDefault(),o===-1?m(0):o===v-1?G():z()),g.key==="ArrowUp"&&o>0&&L(),g.key==="ArrowDown"&&o<v-1&&z(),g.key==="Escape"&&r&&r())};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[o,v,z,L,w,r]);const G=async()=>{try{c(!0);const i=E.getValues();for(const _ of P)if(_.required&&!i[_.field_key]){U.error(`O campo "${_.custom_label||_.display_name}" é obrigatório`),c(!1);return}const g=await xe(i?.email,i?.whatsapp||i?.phone);for(const[_,D]of Object.entries(g||{})){if(D==null||D==="")continue;const H=i[_];(H==null||H==="")&&(i[_]=D)}const M=Math.round((Date.now()-S)/1e3),T=String(i?.email??"").trim(),O=String(i?.whatsapp??i?.phone??"").trim(),$=String(i?.name??i?.nome??i?.nome_completo??"").trim();if(T&&$){const{data:_,error:D}=await A.functions.invoke("submit-public-lead",{body:{name:$,email:T,whatsapp:O,source:`typeform_${a.type||a.id}`,form_name:a.title||"Formulário Typeform",page_url:window.location.href,captured_data:i,...g}});if(D)throw D;if(_&&_.success===!1&&!_.leadId)throw new Error(_.message||"Não foi possÃvel registrar suas respostas.")}const{error:W}=await A.from("form_submissions").insert({form_config_id:a.id,submission_data:i,time_to_complete_seconds:M,page_url:window.location.href,completed:!0,step_reached:v,total_steps:v,form_type:a.type||"typeform",source_component:"typeform",utm_source:g?.utm_source||null,utm_medium:g?.utm_medium||null,utm_campaign:g?.utm_campaign||null});W&&console.warn("[TypeformRenderer] form_submissions falhou (lead já salvo):",W);const{error:Y}=await A.from("form_configs").update({submission_count:(a.submission_count||0)+1}).eq("id",a.id);Y&&console.warn("[TypeformRenderer] contador não incrementado:",Y);const J=a.webhook_url;J&&fetch(J,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({form_id:a.id,form_type:a.type,submission_data:i,submitted_at:new Date().toISOString()})}).catch(()=>{}),F(!0),n?.(i)}catch(i){console.error("Erro ao enviar formulário:",i),U.error("Erro ao enviar formulário")}finally{c(!1)}};return b?e.jsx("div",{className:"fixed inset-0 flex items-center justify-center z-50",style:{background:K},children:e.jsx("div",{className:"animate-spin w-8 h-8 border-4 border-white/30 border-t-white rounded-full"})}):p?e.jsx("div",{className:"min-h-screen flex items-center justify-center p-6 bg-background",children:e.jsxs("div",{className:"max-w-md w-full rounded-lg border border-border bg-card p-6 space-y-4",children:[e.jsx("h1",{className:"text-lg font-semibold",children:"Não foi possÃvel carregar o formulário"}),e.jsx("p",{className:"text-sm text-muted-foreground break-words",children:p}),r&&e.jsx(C,{onClick:r,variant:"outline",className:"w-full",children:"Voltar"})]})}):a?!ee&&!N.show_welcome_screen?e.jsx("div",{className:"min-h-screen flex items-center justify-center p-6 bg-background",children:e.jsxs("div",{className:"max-w-md w-full rounded-lg border border-border bg-card p-6 space-y-4",children:[e.jsx("h1",{className:"text-lg font-semibold",children:"Formulário sem campos"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Adicione pelo menos 1 campo ao formulário para conseguir visualizar."}),r&&e.jsx(C,{onClick:r,variant:"outline",className:"w-full",children:"Voltar"})]})}):e.jsxs("div",{className:"fixed inset-0 flex items-center justify-center z-50 overflow-hidden",style:{background:N.background_type==="image"?`url(${K}) center/cover`:K},children:[N.background_type==="image"&&e.jsx("div",{className:"absolute inset-0 bg-black/50"}),o>=0&&!w&&e.jsx(we,{progress:te,accentColor:q}),r&&e.jsx(C,{variant:"ghost",size:"icon",onClick:r,className:"fixed top-4 right-4 z-50 text-white hover:bg-white/10 rounded-full",children:e.jsx(he,{className:"h-5 w-5"})}),e.jsx(pe,{mode:"wait",custom:u,children:o===-1&&N.show_welcome_screen?e.jsx(je,{title:N.welcome_title||a.title,de
1scription:N.welcome_description||a.subtitle,buttonText:N.welcome_button_text,onStart:()=>m(0),accentColor:q},"welcome"):w?e.jsx(Ne,{title:N.thank_you_title,message:N.thank_you_message||a.success_message,onClose:r,accentColor:q},"thankyou"):P[o]?e.jsx(ke,{field:P[o],questionNumber:o+1,totalQuestions:v,direction:u,form:E,onNext:z,autoAdvance:N.auto_advance,accentColor:q},o):null}),o>=0&&!w&&e.jsx(ve,{onPrev:L,onNext:z,canGoPrev:o>0,canGoNext:o<v-1,isLastStep:o===v-1,isSubmitting:l,onSubmit:G,accentColor:q})]}):e.jsx("div",{className:"min-h-screen flex items-center justify-center p-6 bg-background",children:e.jsxs("div",{className:"max-w-md w-full rounded-lg border border-border bg-card p-6 space-y-4",children:[e.jsx("h1",{className:"text-lg font-semibold",children:"Formulário não encontrado"}),r&&e.jsx(C,{onClick:r,variant:"outline",className:"w-full",children:"Voltar"})]})})}function Oe(){const{formId:t}=fe(),s=ye(),n=a=>{console.log("Form submitted:",a),U.success("Formulário enviado com sucesso!")},r=()=>{s(-1)};return t?e.jsxs(e.Fragment,{children:[e.jsx(be,{title:"Pré-visualização de Formulário â Trainning",description:"Pré-visualização interna de formulário dinâmico da Trainning Education.",n
1oindex:!0}),e.jsx(ze,{formId:t,onSuccess:n,onClose:r})]}):e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx("p",{children:"Formulário não encontrado"})})}export{Oe as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.