PageSourceSearch

https://novo.gruposvip.com/assets/Forms-CLoKYgYF.js

js gruposvip.com collected 2026-09-26 08:44:09 UTC 59,192 bytes, 27 lines download raw bytes

1import{j as e,b as ce,u as ts}from"./query-Q_ThwKGI.js";import{i as ms,r as j}from"./react-vendor-wefok28f.js";import{B as S}from"./button-DrepnwkX.js";import{s as F}from"./client-DjLwxtrO.js";import{T as ne,a as le,b as ie,u as je,J as pe}from"./index-C4Kq7kkR.js";import{u as ke}from"./AuthProvider-BSQZ2YtM.js";import{u as T}from"./useTranslation-DNoH3foE.js";import{F as as,Q as ye,U as xs,a5 as ps,a6 as rs,a7 as gs,a8 as js,a9 as fs,aa as Se,ab as vs,E as bs,ac as fe,R as _s,G as ws,O as Ns,g as Ce,ad as ys,X as Cs,A as ns,m as ks,L as Ss}from"./icons-By8asZST.js";import{p as zs}from"./parseISO-DQNCGdKl.js";import{f as ls}from"./format-NnwPU_mP.js";import{D as ze,a as Fe,b as Ee,c as De,d as is}from"./badge-u_30_p7s.js";import{T as Z}from"./textarea-DJfrjX2A.js";import{T as Fs,a as Es,b as we,c as Ne}from"./tabs-CMLwnORc.js";import{A as Ds,a as Ps,b as Is,c as As,d as Ts,e as Ls,f as qs,g as Us}from"./alert-dialog-BzFKdENb.js";import{C as M}from"./card-DYyqUxY6.js";import{I as b}from"./input-Cu6Tiemi.js";import{S as B}from"./switch-CnLyyNmH.js";import{S as R,a as O,b as $,c as H,d as y}from"./select-DECm7gW5.js";import{D as Bs,C as Vs,P as Ms}from"./dnd.esm-C5CUyiL7.js";import{L as x}from"./label-Ch0F7L4t.js";import{d as Rs}from"./types-C-Liuvzf.js";import{d as Xe,v as Os}from"./checkIn-CbxIkDcA.js";import{C as X}from"./CollapsibleSection-CvfeAvg5.js";import{T as $s}from"./TrackingSettings-0-C5O2gu.js";import{R as Hs,a as Ze}from"./radio-group-CTqv7D_7.js";import{P as Gs}from"./PlanLimits-DheW4c0J.js";import{u as Ks}from"./useSubscription-svlizlcK.js";import{P as Ws}from"./progress-DCO54Zpc.js";import"./supabase-COHOFxoQ.js";import"./index-DC33WZD-.js";import"./index-DviHZN-M.js";import"./index-lwN0GFAE.js";import"./index-CryppvJw.js";import"./index-CSO0Tzy2.js";import"./tiny-invariant-BaFNuDhB.js";import"./PlanFeatureChecklist-BdN1LsxW.js";const Qs=({form:t,onEdit:i,onShare:s,onDelete:l,onViewStats:r,onCopy:c})=>{const{t:a,i18n:n}=T("forms"),o=t.participants_count??0,h=t.checkins_count??0,p=new Date(t.updated_at).toLocaleDateString(n.language==="pt-BR"?"pt-BR":"en-US",{year:"numeric",month:"short",day:"numeric"});return e.jsx("div",{className:"rounded-2xl border border-border/50 bg-card shadow-sm p-4 hover:border-primary/30 hover:shadow-md transition-all duration-200",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx("div",{className:"h-10 w-10 rounded-2xl bg-primary/10 flex items-center justify-center",children:e.jsx(as,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"text-sm font-semibold",children:t.name}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-[10px] text-muted-foreground uppercase tracking-widest",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ye,{className:"w-3 h-3"}),e.jsxs("span",{children:[t.views_count||0," ",a("card.views")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(xs,{className:"w-3 h-3"}),e.jsxs("span",{children:[o," ",a("card.participants")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ps,{className:"w-3 h-3"}),e.jsxs("span",{children:[h," ",a("card.checkIns")]})]}),t.event_date&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(rs,{className:"w-3 h-3"}),e.jsx("span",{children:ls(zs(t.event_date),"dd/MM/yyyy")})]}),e.jsxs("span",{children:[a("card.updated"),": ",p]})]})]})]}),e.jsxs("div",{className:"flex items-center",children:[e.jsxs(ne,{children:[e.jsx(le,{asChild:!0,children:e.jsx(S,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>r(t),children:e.jsx(ye,{className:"h-3.5 w-3.5 text-muted-foreground"})})}),e.jsx(ie,{children:e.jsx("p",{children:a("card.viewStats")})})]}),e.jsxs(ne,{children:[e.jsx(le,{asChild:!0,children:e.jsx(S,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>i(t.id),children:e.jsx(gs,{className:"h-3.5 w-3.5 text-muted-foreground"})})}),e.jsx(ie,{children:e.jsx("p",{children:a("card.editForm")})})]}),e.jsxs(ne,{children:[e.jsx(le,{asChild:!0,children:e.jsx(S,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>s(t),children:e.jsx(js,{className:"h-3.5 w-3.5 text-muted-foreground"})})}),e.jsx(ie,{children:e.jsx("p",{children:a("card.shareForm")})})]}),e.jsxs(ne,{children:[e.jsx(le,{asChild:!0,children:e.jsx(S,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>c(t),children:e.jsx(fs,{className:"h-3.5 w-3.5 text-muted-foreground"})})}),e.jsx(ie,{children:e.jsx("p",{children:a("card.duplicateForm")})})]}),e.jsxs(ne,{children:[e.jsx(le,{asChild:!0,children:e.jsx(S,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(t),children:e.jsx(Se,{className:"h-3.5 w-3.5 text-destructive"})})}),e.jsx(ie,{children:e.jsx("p",{children:a("card.deleteForm")})})]})]})]})})},Ys=({open:t,onOpenChange:i,form:s})=>{const{toast:l}=je(),{data:r}=ce({queryKey:["profile"],queryFn:async()=>{const{data:{user:u}}=await F.auth.getUser();if(!u)throw new Error("No user found");const{data:v,error:g}=await F.from("profiles").select("user_code").eq("id",u.id).single();if(g)throw g;return v}}),c=u=>{if(!u||!r)return"";if(u.is_optin_page){const v=window.location.origin,g=r.user_code;return`${v}/${g}/optin/${u.slug}`}return`<iframe 
2  src="${window.location.origin}/form/${u.id}"
3  width="100%"
4  height="500px"
5  frameborder="0"
6  style="border: none;"
7></iframe>`},a=u=>{if(!u||!u.check_in_settings||!r)return"";const v=window.location.origin,g=r.user_code;return`${v}/${g}/checkin/${u.slug}`},n=u=>{if(!u||!u.thank_you_settings||!r)return"";const v=window.location.origin,g=r.user_code;return`${v}/${g}/thankyou/${u.slug}`},o=u=>{navigator.clipboard.writeText(u),l({title:"Copied!",description:"The code has been copied to your clipboard"})};if(!s||!r)return null;
7const h=s.check_in_settings&&Object.keys(s.check_in_settings).length>0,p=s.thank_you_settings&&Object.keys(s.thank_you_settings).length>0;return e.jsx(ze,{open:t,onOpenChange:i,children:e.jsxs(Fe,{className:"sm:max-w-md",children:[e.jsxs(Ee,{children:[e.jsx(De,{children:"Share Form"}),e.jsx(is,{children:s.is_optin_page?"Share your optin page URL":p||h?"Choose how you want to share your form":"Get the embed code for your form"})]}),e.jsxs(Fs,{defaultValue:"embed",className:"w-full",children:[e.jsxs(Es,{className:`grid w-full ${p&&h?"grid-cols-3":"grid-cols-2"}`,children:[e.jsx(we,{value:"embed",children:s.is_optin_page?"Optin Page URL":"Embed Code"}),p&&e.jsx(we,{value:"thankyou",children:"Thank You Page URL"}),h&&e.jsx(we,{value:"checkin",children:"Check-in URL"})]}),e.jsxs(Ne,{value:"embed",children:[e.jsx(Z,{value:c(s),readOnly:!0,className:"h-32 font-mono text-sm",onClick:u=>o(c(s))}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:["Click to copy the ",s.is_optin_page?"URL":"embed code"]})]}),p&&e.jsxs(Ne,{value:"thankyou",children:[e.jsx(Z,{value:n(s),readOnly:!0,className:"h-32 font-mono text-sm",onClick:u=>o(n(s))}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Click to copy the thank you page URL"})]}),h&&e.jsxs(Ne,{value:"checkin",children:[e.jsx(Z,{value:a(s),readOnly:!0,className:"h-32 font-mono text-sm",onClick:u=>o(a(s))}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Click to copy the check-in URL"})]})]})]})})},Js=({open:t,onOpenChange:i,onConfirm:s})=>{const{t:l}=T("forms");return e.jsx(Ds,{open:t,onOpenChange:i,children:e.jsxs(Ps,{children:[e.jsxs(Is,{children:[e.jsx(As,{children:l("dialogs.deleteTitle")}),e.jsx(Ts,{children:l("dialogs.deleteMessage")})]}),e.jsxs(Ls,{children:[e.jsx(qs,{children:l("common:cancel")}),e.jsx(Us,{onClick:s,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:l("common:delete")})]})]})})},Xs=({onEdit:t})=>{const i=ms(),{toast:s}=je(),{user:l}=ke(),r=ts(),{t:c}=T("forms"),{t:a}=T("common"),[n,o]=j.useState(null),[h,p]=j.useState(!1),[u,v]=j.useState(!1),{data:g,isLoading:C}=ce({queryKey:["forms",l==null?void 0:l.id],queryFn:async()=>{if(!(l!=null&&l.id))throw new Error("User not authenticated");const{data:d,error:f}=await F.from("forms").select(`
8          *,
9          leads!leads_form_id_fkey(
10            id,
11            is_registered,
12            is_checked_in
13          )
14        `).eq("user_id",l.id).order("created_at",{ascending:!1});if(f)throw f;return d==null?void 0:d.map(N=>{var _,P,q,I;return{...N,participants_count:((P=(_=N.leads)==null?void 0:_.filter(k=>k.is_registered))==null?void 0:P.length)||0,checkins_count:((I=(q=N.leads)==null?void 0:q.filter(k=>k.is_checked_in))==null?void 0:I.length)||0}})},enabled:!!(l!=null&&l.id)}),z=async d=>{try{const{error:f}=await F.from("forms").delete().eq("id",d);if(f)throw f;await r.invalidateQueries({queryKey:["forms"]}),s({title:a("success"),description:c("dialogs.deleteSuccess",{defaultValue:"Form deleted successfully"})}),v(!1)}catch{s({title:a("error"),description:c("dialogs.deleteError",{defaultValue:"Failed to delete form"}),variant:"destructive"})}},w=async d=>{try{const{data:f}=await F.from("form_fields").select("*").eq("form_id",d.id).order("order_index"),N={name:`${d.name} (Copy)`,description:d.description,webhook_url:d.webhook_url,utm_tracking:d.utm_tracking,theme:d.theme,user_id:l.id,is_optin_page:d.is_optin_page,optin_headline:d.optin_headline,optin_subheadline:d.optin_subheadline,button_text:d.button_text,redirect_url:d.redirect_url,header_color:d.header_color,subheadline_color:d.subheadline_color,event_date:d.event_date,show_event_date:d.show_event_date,check_in_settings:d.check_in_settings,registration_settings:d.registration_settings,registration_webhook_url:d.registration_webhook_url,checkin_webhook_url:d.checkin_webhook_url,branding:d.branding,button_effect:d.button_effect,show_views:d.show_views,show_registrations:d.show_registrations,show_countdown:d.show_countdown,thank_you_settings:d.thank_you_settings,headline_size:d.headline_size,subheadline_size:d.subheadline_size,image_url:d.image_url,button_color:d.button_color,button_size:d.button_size,background_gradient_start:d.background_gradient_start,background_gradient_end:d.background_gradient_end,facebook_pixel_id:d.facebook_pixel_id,google_analytics_id:d.google_analytics_id,google_tag_manager_id:d.google_tag_manager_id,views_count:0},{data:_,error:P}=await F.from("forms").insert(N).select().single();if(P)throw P;if(f&&f.length>0){const q=f.map(k=>({form_id:_.id,name:k.name,label:k.label,type:k.type,required:k.required,options:k.options,order_index:k.order_index,placeholder:k.placeholder,show_label:k.show_label})),{error:I}=await F.from("form_fields").insert(q);if(I)throw I}await r.invalidateQueries({queryKey:["forms"]}),s({title:c("actions.copySuccess",{defaultValue:"Form copied successfully!"}),description:c("actions.copyDescription",{original:d.name,copy:`${d.name} (Copy)`,defaultValue:`"${d.name}" was duplicated as "${d.name} (Copy)"`})})}catch{s({title:a("error"),description:c("actions.copyError",{defaultValue:"Failed to copy form"}),variant:"destructive"})}};return l?C?e.jsx("div",{className:"animate-pulse",children:a("loading",{defaultValue:"Loading..."})}):e.jsxs("div",{className:"space-y-4",children:[g==null?void 0:g.map(d=>e.jsx(Qs,{form:d,onEdit:t,onShare:f=>{o(f),p(!0)},onDelete:f=>{o(f),v(!0)},onViewStats:f=>{i(`/forms/${f.id}`)},onCopy:w},d.id)),e.jsx(Ys,{open:h,onOpenChange:p,form:n}),e.jsx(Js,{open:u,onOpenChange:v,onConfirm:()=>n&&z(n.id)})]}):e.jsx("div",{className:"text-center py-12",children:a("pleaseLogin",{defaultValue:"Please log in to view your forms."})})},Zs=({field:t,updateField:i,placeholder:s,helpText:l,label:r})=>{const[c,a]=j.useState(Array.isArray(t.options)?t.options.join(", "):"");j.useEffect(()=>{a(Array.isArray(t.options)?t.options.join(", "):"")},[t.id]);const n=()=>{const o=c.split(",").map(h=>h.trim()).filter(h=>h.length>0);i(t.id,{options:o}),a(o.join(", "))};return e.jsxs("div",{className:"pl-9",children:[r&&e.jsx("label",{className:"text-xs font-medium text-gray-700 mb-1 block",children:r}),e.jsx(b,{value:c,onChange:o=>a(o.target.value),onBlur:n,placeholder:s}),l&&e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:l})]})},et=({fields:t,setFields:i})=>{const{t:s}=T("forms"),l=n=>{if(!n.destination)return;const o=Array.from(t),[h]=o.splice(n.source.index,1);o.splice(n.destination.index,0,h),i(o)},r=()=>{const n={id:Date.now().toString(),name:`field_${t.length+1}`,label:`Field ${t.length+1}`,type:"text",required:!1,showLabel:!1,placeholder:""};i([...t,n])},c=n=>{i(t.filter(o=>o.id!==n))},a=(n,o)=>{i(t.map(h=>h.id===n?{...h,...o}
14:h))};return e.jsxs(M,{className:"p-6",children:[e.jsx(Bs,{onDragEnd:l,children:e.jsx(Vs,{droppableId:"fields",children:n=>e.jsxs("div",{...n.droppableProps,ref:n.innerRef,className:"space-y-4",children:[t.map((o,h)=>e.jsx(Ms,{draggableId:o.id,index:h,children:p=>e.jsxs("div",{ref:p.innerRef,...p.draggableProps,className:"flex flex-col gap-4 bg-white p-4 rounded-lg border",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{...p.dragHandleProps,className:"cursor-move mt-2.5",children:e.jsx(vs,{className:"h-4 w-4 text-gray-400"})}),e.jsxs("div",{className:"flex-1 grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx("div",{className:"w-full",children:e.jsx(b,{value:o.label,onChange:u=>a(o.id,{label:u.target.value}),placeholder:s("fields.labelPlaceholder"),className:"w-full"})}),e.jsx("div",{className:"w-full",children:e.jsxs(R,{value:o.type,onValueChange:u=>a(o.id,{type:u}),children:[e.jsx(O,{className:"w-full",children:e.jsx($,{placeholder:s("fields.selectType")})}),e.jsxs(H,{children:[e.jsx(y,{value:"text",children:s("fields.text")}),e.jsx(y,{value:"email",children:s("fields.email")}),e.jsx(y,{value:"tel",children:s("fields.phone")}),e.jsx(y,{value:"textarea",children:s("fields.textArea")}),e.jsx(y,{value:"select",children:s("fields.select")}),e.jsx(y,{value:"checkbox",children:s("fields.checkbox")}),e.jsx(y,{value:"radio",children:s("fields.radio")})]})]})}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(B,{id:`required-${o.id}`,checked:o.required,onCheckedChange:u=>a(o.id,{required:u}),className:"h-4 w-8 data-[state=checked]:bg-primary"}),e.jsx("span",{className:"text-xs text-gray-600",children:s("fields.required")})]})]}),e.jsx(S,{variant:"ghost",size:"icon",onClick:()=>c(o.id),className:"mt-1.5",children:e.jsx(Se,{className:"h-4 w-4 text-destructive"})})]}),e.jsxs("div",{className:"flex items-center gap-4 pl-9",children:[e.jsx("div",{className:"flex-1",children:e.jsx(b,{value:o.placeholder||"",onChange:u=>a(o.id,{placeholder:u.target.value}),placeholder:s("fields.placeholderOptional")})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{variant:"ghost",size:"icon",onClick:()=>a(o.id,{showLabel:!o.showLabel}),className:"h-8 w-8",children:o.showLabel?e.jsx(ye,{className:"h-3 w-3"}):e.jsx(bs,{className:"h-3 w-3"})}),e.jsx("span",{className:"text-xs text-gray-600",children:s("fields.showLabel")})]})]}),(o.type==="select"||o.type==="checkbox"||o.type==="radio")&&e.jsx(Zs,{field:o,updateField:a,label:s("fields.options"),placeholder:s("fields.optionsPlaceholder"),helpText:s("fields.optionsHelp")})]})},o.id)),n.placeholder]})})}),e.jsxs(S,{variant:"outline",onClick:r,className:"mt-4 w-full",children:[e.jsx(fe,{className:"h-4 w-4 mr-2"}),s("fields.addField")]})]})},st=({onSelectType:t})=>e.jsxs("div",{className:"grid md:grid-cols-2 gap-6",children:[e.jsx(M,{className:"p-8 hover:shadow-lg transition-all duration-200 cursor-pointer bg-white border border-secondary group",onClick:()=>t(!1),children:e.jsxs("div",{className:"flex flex-col items-center text-center space-y-6",children:[e.jsx("div",{className:"p-4 bg-secondary rounded-xl group-hover:bg-primary/10 transition-colors",children:e.jsx(as,{className:"w-8 h-8 text-primary"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xl font-semibold text-foreground",children:"Standard Form"}),e.jsx("p",{className:"text-muted-foreground",children:"Create a regular form to collect information from your users"})]}),e.jsx(S,{className:"w-full",children:"Create Standard Form"})]})}),e.jsx(M,{className:"p-8 hover:shadow-lg transition-all duration-200 cursor-pointer bg-white border border-secondary group",onClick:()=>t(!0),children:e.jsxs("div",{className:"flex flex-col items-center text-center space-y-6",children:[e.jsx("div",{className:"p-4 bg-secondary rounded-xl group-hover:bg-primary/10 transition-colors",children:e.jsx(_s,{className:"w-8 h-8 text-primary"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xl font-semibold text-foreground",children:"Opt-in Page"}),e.jsx("p",{className:"text-muted-foreground",children:"Create a landing page with a form to capture leads"})]}),e.jsx(S,{className:"w-full",children:"Create Opt-in Page"})]})})]}),tt=({formName:t,setFormName:i,description:s,setDescription:l,slug:r,
14setSlug:c,formId:a,slugError:n,setSlugError:o})=>{const{user:h}=ke(),{t:p}=T("forms"),[u,v]=j.useState(!1),[g,C]=j.useState(!1);j.useEffect(()=>{const d=setTimeout(async()=>{if(!r.trim()){o(""),C(!1);return}if(!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(r)){o(p("errors.slugFormat","Slug can only contain lowercase letters, numbers, and hyphens")),C(!1);return}if(r.length<3){o(p("errors.slugMin","Slug must be at least 3 characters")),C(!1);return}if(r.length>100){o(p("errors.slugMax","Slug must be less than 100 characters")),C(!1);return}v(!0);try{let N=F.from("forms").select("id").eq("user_id",h==null?void 0:h.id).eq("slug",r);a&&(N=N.neq("id",a));const{data:_,error:P}=await N;if(P)throw P;_&&_.length>0?(o(p("errors.slugExists","This slug is already in use. Please choose another.")),C(!1)):(o(""),C(!0))}catch(N){console.error("Error validating slug:",N),o(p("errors.slugValidation","Error validating slug")),C(!1)}finally{v(!1)}},300);return()=>clearTimeout(d)},[r,h==null?void 0:h.id,a,o,p]);const z=w=>{const d=w.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-");c(d)};return e.jsx(M,{className:"p-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(x,{htmlFor:"formName",className:"text-base font-semibold",children:p("editor.formName")}),e.jsx(b,{id:"formName",value:t,onChange:w=>i(w.target.value),placeholder:p("editor.formNamePlaceholder"),className:"mt-2"})]}),e.jsxs("div",{children:[e.jsx(x,{htmlFor:"slug",className:"text-base font-semibold",children:p("editor.urlSlug")}),e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:p("editor.urlSlugHint")}),e.jsxs("div",{className:"relative",children:[e.jsx(b,{id:"slug",value:r,onChange:w=>z(w.target.value),placeholder:p("editor.urlSlugPlaceholder"),className:`mt-2 pr-10 ${n?"border-destructive":g?"border-green-500":""}`}),u&&e.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 mt-1",children:e.jsx("div",{className:"animate-spin h-4 w-4 border-2 border-primary border-t-transparent rounded-full"})}),!u&&g&&r&&e.jsx(ws,{className:"absolute right-3 top-1/2 -translate-y-1/2 mt-1 h-4 w-4 text-green-500"}),!u&&n&&r&&e.jsx(Ns,{className:"absolute right-3 top-1/2 -translate-y-1/2 mt-1 h-4 w-4 text-destructive"})]}),n&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:n})]}),e.jsxs("div",{children:[e.jsx(x,{htmlFor:"description",className:"text-base font-semibold",children:p("editor.description")}),e.jsx(b,{id:"description",value:s,onChange:w=>l(w.target.value),placeholder:p("editor.descriptionPlaceholder"),className:"mt-2"})]})]})})},at=(t,i,s,l,r,c,a,n,o,h,p,u,v,g,C,z,w,d,f)=>{const N=g?`${g.getFullYear()}-${String(g.getMonth()+1).padStart(2,"0")}-${String(g.getDate()).padStart(2,"0")}`:null;return{id:f,name:t,description:i,webhook_url:s,utm_tracking:l,theme:r,user_id:c,is_optin_page:a,optin_headline:n,optin_subheadline:o,button_text:h,redirect_url:p,header_color:u,subheadline_color:v,event_date:N,show_event_date:C,show_views:z!==void 0?z:!0,show_registrations:w!==void 0?w:!0,show_countdown:d!==void 0?d:!1}},rt=()=>{const{toast:t}=je(),[i,s]=j.useState(!1),l=ts();return{handleSave:async({formId:c,formName:a,description:n,slug:o,webhookUrl:h,utmTracking:p,theme:u,isOptinPage:v,optinHeadline:g,optinSubheadline:C,buttonText:z,redirectUrl:w,headerColor:d,subheadlineColor:f,eventDate:N,showEventDate:_,fields:P,checkInSettings:q,thankYouSettings:I,registrationSettings:k,headlineSize:V,subheadlineSize:U,imageUrl:K,buttonEffect:W,buttonColor:E,buttonSize:de,facebookPixelId:ee,googleAnalyticsId:se,googleTagManagerId:Q,showViews:te,showRegistrations:he,showCountdown:ue,onSuccess:me})=>{s(!0);try{const{data:{user:G}}=await F.auth.getUser();if(!G)throw new Error("No user found");console.log("Saving form with tracking data:",{facebookPixelId:ee,googleAnalyticsId:se,googleTagManagerId:Q});const Y={...at(a,n,h,p,u,G.id,v,g,C,z,w,d,f,N,_,te,he,ue,c),...o&&{slug:o},check_in_settings:q,thank_you_settings:I,registration_settings:k,headline_size:V,subheadline_size:U,image_url:K,button_effect:W,button_color:E,button_size:de,facebook_pixel_id:ee,google_analytics_id:se,google_tag_manager_id:Q};c||delete Y.id,console.log("Final form data being saved:",Y);const{data:ae,error:J}=await F.from("forms").upsert(Y).select().single();if(J)throw console.error("Error saving form:",J),J;if(console.log("Form saved successfully:",ae),c){const{error:L}=await F.from("form_fields").delete().eq("form_id",c);if(L)throw L}const xe=P.map((L,ve)=>({form_id:ae.id,name:L.name,label:L.label,type:L.type,required:L.required,options:L.options?JSON.stringify(L.options):null,order_index:ve,placeholder:L.placeholder||null,show_label:L.showLabel!==void 0?L.showLabel:!0})),{error:re}=await F.from("form_fields").insert(xe);
14if(re)throw re;await l.invalidateQueries({queryKey:["form",c]}),await l.invalidateQueries({queryKey:["forms"]}),t({title:"Success",description:`Form ${c?"updated":"created"} successfully`}),me()}catch(G){console.error("Form save error:",G),t({title:"Error",description:`Failed to ${c?"update":"create"} form`,variant:"destructive"})}finally{s(!1)}},isSaving:i}},ge=({label:t,value:i,color:s,size:l,onValueChange:r,onColorChange:c,onSizeChange:a,placeholder:n})=>{const{t:o}=T("forms");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(x,{htmlFor:t.toLowerCase(),children:t}),e.jsx(b,{id:t.toLowerCase(),value:i,onChange:h=>r(h.target.value),placeholder:n||`Enter ${t.toLowerCase()}`})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(x,{htmlFor:`${t.toLowerCase()}-color`,children:o("checkIn.color")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{id:`${t.toLowerCase()}-color`,type:"color",value:s,onChange:h=>c(h.target.value),className:"w-16 p-1 h-10"}),e.jsx(b,{value:s,onChange:h=>c(h.target.value),placeholder:"#000000",className:"flex-1"})]})]}),e.jsxs("div",{children:[e.jsx(x,{htmlFor:`${t.toLowerCase()}-size`,children:o("checkIn.size")}),e.jsxs(R,{value:l,onValueChange:a,children:[e.jsx(O,{children:e.jsx($,{placeholder:o("checkIn.selectSize")})}
14),e.jsxs(H,{children:[e.jsxs(y,{value:"text-sm md:text-base",children:[o("checkIn.sizeSmall")," (14px / 16px)"]}),e.jsxs(y,{value:"text-lg md:text-xl",children:[o("checkIn.sizeMedium")," (18px / 20px)"]}),e.jsxs(y,{value:"text-2xl md:text-3xl",children:[o("checkIn.sizeLarge")," (22px / 26px)"]}),e.jsxs(y,{value:"text-3xl md:text-4xl",children:[o("checkIn.sizeExtraLarge")," (28px / 32px)"]})]})]})]})]})]})},os=({text:t,color:i,size:s,onTextChange:l,onColorChange:r,onSizeChange:c})=>{const{t:a}=T("forms");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(x,{htmlFor:"buttonText",children:a("checkIn.buttonText")}),e.jsx(b,{id:"buttonText",value:t,onChange:n=>l(n.target.value),placeholder:a("checkIn.buttonTextPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(x,{htmlFor:"buttonColor",children:a("checkIn.color")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{id:"buttonColor",type:"color",value:i,onChange:n=>r(n.target.value),className:"w-16 p-1 h-10"}),e.jsx(b,{value:i,onChange:n=>r(n.target.value),placeholder:"#000000",className:"flex-1"})]})]}),e.jsxs("div",{children:[e.jsx(x,{htmlFor:"buttonSize",children:a("checkIn.size")}),e.jsxs(R,{value:s,onValueChange:c,children:[e.jsx(O,{children:e.jsx($,{placeholder:a("checkIn.selectSize")})}
14),e.jsxs(H,{children:[e.jsx(y,{value:"sm",children:a("checkIn.sizeSmall")}),e.jsx(y,{value:"md",children:a("checkIn.sizeMedium")}),e.jsx(y,{value:"lg",children:a("checkIn.sizeLarge")})]})]})]})]})]})},nt=({settings:t,setSettings:i})=>{const{t:s}=T("forms"),l=(r,c)=>{i({...t,[r]:c})};return e.jsx(M,{className:"p-6",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ge,{label:s("checkIn.title"),value:t.title,color:t.title_color,size:t.title_size,onValueChange:r=>l("title",r),onColorChange:r=>l("title_color",r),onSizeChange:r=>l("title_size",r)}),e.jsx(ge,{label:s("checkIn.subtitle"),value:t.subtitle,color:t.subtitle_color,size:t.subtitle_size,onValueChange:r=>l("subtitle",r),onColorChange:r=>l("subtitle_color",r),onSizeChange:r=>l("subtitle_size",r)}),e.jsx(os,{text:t.button_text,color:t.button_color,size:t.button_size,onTextChange:r=>l("button_text",r),onColorChange:r=>l("button_color",r),onSizeChange:r=>l("button_size",r)}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(x,{htmlFor:"webhookUrl",children:s("checkIn.webhookUrl")}),e.jsx(b,{id:"webhookUrl",value:t.webhook_url||"",onChange:r=>l("webhook_url",r.target.value),placeholder:s("checkIn.webhookPlaceholder")})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(x,{htmlFor:"footerText",children:s("checkIn.footerText")}),e.jsx(b,{id:"footerText",value:t.footer_text||"",onChange:r=>l("footer_text",r.target.value),placeholder:s("checkIn.footerPlaceholder")})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(x,{htmlFor:"postCheckinUrl",children:s("checkIn.postCheckinUrl")}),e.jsx(b,{id:"postCheckinUrl",value:t.post_checkin_url||"",onChange:r=>l("post_checkin_url",r.target.value),placeholder:s("checkIn.postCheckinPlaceholder")})]})]})})},lt=({headline:t,setHeadline:i,headlineColor:s,setHeadlineColor:l,headlineSize:r,setHeadlineSize:c,subheadline:a,setSubheadline:n,subheadlineColor:o,setSubheadlineColor:h,subheadlineSize:p,setSubheadlineSize:u})=>{const{t:v}=T("forms");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsx(x,{children:"Headline"}),e.jsx(b,{value:t,onChange:g=>i(g.target.value),placeholder:"Enter headline"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{children:v("editor.color")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{type:"color",value:s,onChange:g=>l(g.target.value),className:"w-16 h-10"}),e.jsx(b,{value:s,onChange:g=>l(g.target.value),placeholder:"#000000",className:"flex-1"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{children:v("editor.size")}),e.jsxs(R,{value:r,onValueChange:c,children:[e.jsx(O,{children:e.jsx($,{placeholder:v("editor.selectSize")})}
14),e.jsxs(H,{children:[e.jsx(y,{value:"text-sm md:text-base",children:v("editor.sizeSmall")}),e.jsx(y,{value:"text-lg md:text-xl",children:v("editor.sizeMedium")}),e.jsx(y,{value:"text-2xl md:text-3xl",children:v("editor.sizeLarge")}),e.jsx(y,{value:"text-3xl md:text-4xl",children:v("editor.sizeExtraLarge")})]})]})]})]})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsx(x,{children:"Subheadline"}),e.jsx(b,{value:a,onChange:g=>n(g.target.value),placeholder:"Enter subheadline"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{children:v("editor.color")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{type:"color",value:o,onChange:g=>h(g.target.value),className:"w-16 h-10"}),e.jsx(b,{value:o,onChange:g=>h(g.target.value),placeholder:"#000000",className:"flex-1"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{children:v("editor.size")}),e.jsxs(R,{value:p,onValueChange:u,children:[e.jsx(O,{children:e.jsx($,{placeholder:v("editor.selectSize")})}
14),e.jsxs(H,{children:[e.jsx(y,{value:"text-sm md:text-base",children:v("editor.sizeSmall")}),e.jsx(y,{value:"text-lg md:text-xl",children:v("editor.sizeMedium")}),e.jsx(y,{value:"text-2xl md:text-3xl",children:v("editor.sizeLarge")}),e.jsx(y,{value:"text-3xl md:text-4xl",children:v("editor.sizeExtraLarge")})]})]})]})]})]})]})},it=({buttonText:t,setButtonText:i,utmTracking:s,setUtmTracking:l,redirectUrl:r,setRedirectUrl:c,webhookUrl:a,setWebhookUrl:n,isOptinPage:o,optinHeadline:h,setOptinHeadline:p,optinSubheadline:u,setOptinSubheadline:v,headerColor:g,setHeaderColor:C,subheadlineColor:z,setSubheadlineColor:w,headlineSize:d,setHeadlineSize:f,subheadlineSize:N,setSubheadlineSize:_,showEventDate:P,setShowEventDate:q,imageUrl:I="",setImageUrl:k=()=>{},buttonColor:V="#7E69AB",setButtonColor:U=()=>{},buttonSize:K="lg",setButtonSize:W=()=>{}})=>e.jsxs("div",{className:"space-y-6",children:[o&&e.jsx(M,{className:"p-6",children:e.jsx(lt,{headline:h,setHeadline:p,headlineColor:g,setHeadlineColor:C,headlineSize:d,setHeadlineSize:f,subheadline:u,setSubheadline:v,subheadlineColor:z,setSubheadlineColor:w,subheadlineSize:N,setSubheadlineSize:_})}),e.jsx(M,{className:"p-6",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsx(x,{children:"Media"}),e.jsx(b,{value:I,onChange:E=>k(E.target.value),placeholder:"Enter image or video URL"})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsx(x,{children:"Button Settings"}),e.jsx(b,{value:t,onChange:E=>i(E.target.value),placeholder:"Enter button text"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{children:"Color"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{type:"color",value:V,onChange:E=>U(E.target.value),className:"w-16 h-10"}),e.jsx(b,{value:V,onChange:E=>U(E.target.value),placeholder:"#000000",className:"flex-1"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{children:"Size"}),e.jsxs("select",{value:K,onChange:E=>W(E.target.value),className:"w-full border rounded-md p-2",children:[e.jsx("option",{value:"sm",children:"Small"}),e.jsx("option",{value:"md",children:"Medium"}),e.jsx("option",{value:"lg",children:"Large"})]})]})]})]})]})}),e.jsx(M,{className:"p-6",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(B,{checked:s,onCheckedChange:l,id:"utmTracking"}),e.jsx(x,{htmlFor:"utmTracking",children:"Enable UTM Tracking"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(x,{children:"Redirect URL"}),e.jsx(b,{value:r,onChange:E=>c(E.target.value),placeholder:"https://example.com/thank-you"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Where to redirect after form submission. Use placeholders to pass form data:"}),e.jsxs("p",{className:"text-xs text-muted-foreground/80 font-mono bg-muted/50 p-2 rounded",children:["%EMAIL%, %NAME%, %PHONE% or %FIELD_NAME%",e.jsx("br",{}),"Example: https://checkout.com?email=%EMAIL%&name=%NAME%"]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(x,{children:"Webhook URL"}),e.jsx(b,{value:a,onChange:E=>n(E.target.value),placeholder:"https://example.com/webhook"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Receive form submissions via webhook (JSON POST request)"}),e.jsxs("p",{className:"text-xs text-muted-foreground/80 font-mono bg-muted/50 p-2 rounded",children:["Payload: ","{"," formId, formName, submissionData, leadId, timestamp, utmParams ","}"]})]})]})})]}),ot=({facebookPixelId:t,setFacebookPixelId:i,googleAnalyticsId:s,setGoogleAnalyticsId:l,googleTagManagerId:r,setGoogleTagManagerId:c})=>e.jsx($s,{facebookPixelId:t,setFacebookPixelId:i,googleAnalyticsId:s,setGoogleAnalyticsId:l,googleTagManagerId:r,setGoogleTagManagerId:c}),ct=({eventDate:t,setEventDate:i,showEventDate:s,setShowEventDate:l,showViews:r,setShowViews:c,showRegistrations:a,setShowRegistrations:n,showCountdown:o,setShowCountdown:h})=>{const{t:p}=T("forms"),u=g=>{if(g.target.value){const[C,z,w]=g.target.value.split("-").map(Number),d=new Date(C,z-1,w,12,0,0,0);i(d)}else i(void 0)},v=g=>g?ls(g,"yyyy-MM-dd"):"";return e.jsx(M,{className:"p-6",children:e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs(x,{htmlFor:"event-date",className:"text-base font-medium flex items-center gap-2",children:[e.jsx(rs,{className:"h-4 w-4"}),p("editor.eventDate")]}),e.jsx(b,{id:"event-date",type:"date",value:v(t),onChange:u,className:"max-w-xs"})]}),e.jsxs("div",{className:"space-y-4 pt-2 border-t",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(x,{htmlFor:"show-event-date",className:"text-sm font-medium",children:p("editor.showEventDate")}),e.jsx(B,{id:"show-event-date",checked:s,onCheckedChange:l})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(x,{htmlFor:"show-countdown",className:"text-sm font-medium",children:p("editor.showCountdown")}),e.jsx(B,{id:"show-countdown",checked:o,onCheckedChange:h})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(x,{htmlFor:"show-views",className:"text-sm font-medium",children:p("editor.showViews")}),e.jsx(B,{id:"show-views",checked:r,onCheckedChange:c})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(x,{htmlFor:"show-registrations",className:"text-sm font-medium",children:p("editor.showRegistrations")}),e.jsx(B,{id:"show-registrations",checked:a,onCheckedChange:n})]})]})]})})})},dt=({thankYouSettings:t,setThankYouSettings:i})=>{const{t:s}=T("forms"),l=()=>{i(a=>({...a,next_steps:[...a.next_steps,{text:""}]}))},r=a=>{i(n=>({...n,next_steps:n.next_steps.filter((o,h)=>h!==a)}))},c=(a,n)=>{i(o=>({...o,next_steps:o.next_steps.map((h,p)=>p===a?{text:n}:h)}))};return e.jsx(X,{title:s("thankYouPage.title"),defaultExpanded:!1,children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ge,{label:s("thankYou.headline"),value:t.headline,onValueChange:a=>i(n=>({...n,headline:a})),color:t.headline_color,onColorChange:a=>i(n=>({...n,headline_color:a})),size:t.headline_size,onSizeChange:a=>i(n=>({...n,headline_size:a}))}),e.jsx(ge,{label:s("thankYou.subheadline","Subheadline"),value:t.subheadline,onValueChange:a=>i(n=>({...n,subheadline:a})),color:t.subheadline_color,onColorChange:a=>i(n=>({...n,subheadline_color:a})),size:t.subheadline_size,onSizeChange:a=>i(n=>({...n,subheadline_size:a}))}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(x,{children:s("thankYouPage.videoInstructions")}),e.jsxs(Hs,{value:t.video_type,onValueChange:a=>i(n=>({...n,video_type:a})),children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ze,{value:"url",id:"video-url"}),e.jsx(x,{htmlFor:"video-url",children:s("thankYouPage.videoUrl")})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ze,{value:"embed",id:"video-embed"}),e.jsx(x,{htmlFor:"video-embed",children:s("thankYouPage.embedCode")})]})]}),t.video_type==="url"?e.jsxs("div",{children:[e.jsx(x,{htmlFor:"video-url-input",children:s("thankYouPage.videoUrl")}),e.jsx(b,{id:"video-url-input",type:"url",placeholder:s("thankYouPage.videoUrlPlaceholder"),value:t.video_url||"",onChange:a=>i(n=>({...n,video_url:a.target.value}))})]}):e.jsxs("div",{children:[e.jsx(x,{htmlFor:"embed-code-input",children:s("thankYouPage.embedCode")}),e.jsx(Z,{id:"embed-code-input",placeholder:s("thankYouPage.embedCodePlaceholder"),value:t.embed_code||"",onChange:a=>i(n=>({...n,embed_code:a.target.value})),rows:4})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(x,{children:s("thankYouPage.nextSteps")}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(B,{checked:t.show_next_steps,onCheckedChange:a=>i(n=>({...n,show_next_steps:a}))}),e.jsx("span",{className:"text-sm text-muted-foreground",children:s("thankYouPage.showNextSteps")})]})]}),t.show_next_steps&&e.jsxs("div",{className:"space-y-3",children:[t.next_steps.map((a,n)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-medium w-6",children:[n+1,"."]}),e.jsx(b,{placeholder:s("thankYouPage.stepPlaceholder"),value:a.text,onChange:o=>c(n,o.target.value)}),e.jsx(S,{type:"button",variant:"ghost",size:"icon",onClick:()=>r(n),children:e.jsx(Se,{className:"h-4 w-4"})})]},n)),e.jsxs(S,{type:"button",variant:"outline",size:"sm",onClick:l,className:"w-full",children:[e.jsx(fe,{className:"h-4 w-4 mr-2"}),s("thankYouPage.addStep")]})]})]}),e.jsx(os,{text:t.button_text,onTextChange:a=>i(n=>({...n,button_text:a})),color:t.button_color,onColorChange:a=>i(n=>({...n,button_color:a})),size:t.button_size,onSizeChange:a=>i(n=>({...n,button_size:a}))}),e.jsxs("div",{children:[e.jsx(x,{htmlFor:"button-url",children:s("thankYouPage.buttonUrl")}),e.jsx(b,{id:"button-url",type:"url",placeholder:s("thankYouPage.buttonUrlPlaceholder"),value:t.button_url||"",onChange:a=>i(n=>({...n,button_url:a.target.value}))}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s("thankYouPage.buttonUrlHint")})]})]})})},es={background_color:"#ffffff",headline:"Congratulations!",headline_color:"#222222",headline_size:"3xl",subheadline:"You're all set! Check the next steps below.",subheadline_color:"#666666",subheadline_size:"xl",video_url:null,video_type:"url",embed_code:null,show_next_steps:!1,next_steps:[],button_text:"Continue",button_url:null,button_color:"#7E69AB",button_size:"lg"},ht=({onCancel:t,formId:i})=>{const{t:s}=T(["forms","common"]),[l,r]=j.useState(1),[c,a]=j.useState(!1),[n,o]=j.useState(""),[h,p]=j.useState(""),[u,v]=j.useState(""),[g,C]=j.useState(""),[z,w]=j.useState(""),[d,f]=j.useState(!1),[N,_]=j.useState(""),[P,q]=j.useState(""),[I,k]=j.useState("Submit"),[V,U]=j.useState(""),[K,W]=j.useState("#222222"),[E,de]=j.useState("#666666"),[ee,se]=j.useState(),[Q,te]=j.useState(!1),[he,ue]=j.useState(""),[me,G]=j.useState(!1),[Y,ae]=j.useState("#7E69AB"),[J,xe]=j.useState("lg"),[re,L]=j.useState([{id:"1",name:"name",label:"Name",type:"text",required:!0,showLabel:!1},{id:"2",name:"email",label:"Email",type:"email",required:!0,showLabel:!1},{id:"3",name:"phone",label:"Phone",type:"tel",required:!1,showLabel:!1}]),[ve]=j.useState(Rs),{handleSave:cs,isSaving:Pe}=rt(),[Ie,Ae]=j.useState(Xe),[Te,be]=j.useState(es),[Le,qe]=j.useState("text-xl md:text-2xl"),[Ue,Be]=j.useState("text-base"),[Ve,Me]=j.useState(""),[Re,Oe]=j.useState(""),[$e,He]=j.useState(""),[Ge,Ke]=j.useState(!0),[We,Qe]=j.useState(!0),[Ye,Je]=j.useState(!1),{data:m,isLoading:ds}=ce({queryKey:["form",i],queryFn:async()=>
14{if(!i)return null;const{data:D,error:A}=await F.from("forms").select(`
15          *,
16          form_fields (
17            id,
18            name,
19            label,
20            type,
21            required,
22            options,
23            order_index,
24            placeholder,
25            show_label
26          )
27        `).eq("id",i).maybeSingle();if(A)throw A;return console.log("Fetched form data:",D),D},enabled:!!i});if(j.useEffect(()=>{if(m){if(console.log("Loading existing form data:",m),o(m.name||""),p(m.description||""),v(m.slug||""),w(m.webhook_url||""),f(m.utm_tracking||!1),a(m.is_optin_page||!1),_(m.optin_headline||""),q(m.optin_subheadline||""),k(m.button_text||"Submit"),U(m.redirect_url||""),W(m.header_color||"#222222"),de(m.subheadline_color||"#666666"),qe(m.headline_size||"text-xl md:text-2xl"),Be(m.subheadline_size||"text-base"),ue(m.image_url||""),G(m.button_effect||!1),ae(m.button_color||"#7E69AB"),xe(m.button_size||"lg"),Me(m.facebook_pixel_id||""),Oe(m.google_analytics_id||""),He(m.google_tag_manager_id||""),Ke(m.show_views!==void 0?m.show_views:!0),Qe(m.show_registrations!==void 0?m.show_registrations:!0),m.event_date){const[D,A,_e]=m.event_date.split("-").map(Number),us=new Date(D,A-1,_e);se(us)}if(te(m.show_event_date||!1),Je(m.show_countdown||!1),Ae(m.check_in_settings?Os(m.check_in_settings):Xe),m.thank_you_settings){const D=m.thank_you_settings;be({...D,headline_color:D.headline_color||m.header_color||"#222222",headline_size:D.headline_size||m.headline_size||"3xl",subheadline_color:D.subheadline_color||m.subheadline_color||"#666666",subheadline_size:D.subheadline_size||m.subheadline_size||"xl",button_color:D.button_color||m.button_color||"#7E69AB",button_size:D.button_size||m.button_size||"lg",background_color:D.background_color||"#ffffff"})}else be({...es,headline_color:m.header_color||"#222222",headline_size:m.headline_size||"3xl",subheadline_color:m.subheadline_color||"#666666",subheadline_size:m.subheadline_size||"xl",button_color:m.button_color||"#7E69AB",button_size:m.button_size||"lg"});if(m.form_fields&&Array.isArray(m.form_fields)){const D=[...m.form_fields].sort((A,_e)=>(A.order_index||0)-(_e.order_index||0)).map(A=>({id:A.id,name:A.name,label:A.label,type:A.type,required:A.required,options:A.options?JSON.parse(A.options):void 0,placeholder:A.placeholder||"",showLabel:A.show_label!==void 0?A.show_label:!1}));console.log("Setting form fields:",D),L(D)}r(2)}},[m]),ds)return e.jsx("div",{children:s("common:loading")});const hs=async()=>{n.trim()&&(g||await cs({slug:u,formId:i,formName:n,description:h,webhookUrl:z,utmTracking:d,theme:ve,isOptinPage:c,optinHeadline:N,optinSubheadline:P,buttonText:I,redirectUrl:V,headerColor:K,subheadlineColor:E,eventDate:ee,showEventDate:Q,fields:re,checkInSettings:Ie,thankYouSettings:Te,registrationSettings:{},headlineSize:Le,subheadlineSize:Ue,imageUrl:he,buttonEffect:me,buttonColor:Y,buttonSize:J,facebookPixelId:Ve,googleAnalyticsId:Re,googleTagManagerId:$e,showViews:Ge,showRegistrations:We,showCountdown:Ye,onSuccess:()=>{t()}}))};return e.jsx("div",{className:"space-y-6",children:l===1?e.jsxs("div",{className:"space-y-6",children:[e.jsx("h2",{className:"text-2xl font-semibold",children:s("editor.chooseType")}),e.jsx(st,{onSelectType:D=>{a(D),r(2)}})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(tt,{formName:n,setFormName:o,description:h,setDescription:p,slug:u,setSlug:v,formId:i,slugError:g,setSlugError:C}),e.jsx(X,{title:s("editor.formSettings"),defaultExpanded:!0,children:e.jsx(it,{buttonText:I,setButtonText:k,utmTracking:d,setUtmTracking:f,redirectUrl:V,setRedirectUrl:U,webhookUrl:z,setWebhookUrl:w,isOptinPage:c,optinHeadline:N,setOptinHeadline:_,optinSubheadline:P,setOptinSubheadline:q,headerColor:K,setHeaderColor:W,subheadlineColor:E,setSubheadlineColor:de,headlineSize:Le,setHeadlineSize:qe,subheadlineSize:Ue,setSubheadlineSize:Be,showEventDate:Q,setShowEventDate:te,imageUrl:he,setImageUrl:ue,buttonEffect:me,setButtonEffect:G,buttonColor:Y,setButtonColor:ae,buttonSize:J,setButtonSize:xe})}),e.jsx(X,{title:s("editor.fields"),children:e.jsx(et,{fields:re,setFields:L})}),e.jsx(X,{title:s("editor.displaySettings"),children:e.jsx(ct,{eventDate:ee,setEventDate:se,showEventDate:Q,setShowEventDate:te,
27showViews:Ge,setShowViews:Ke,showRegistrations:We,setShowRegistrations:Qe,showCountdown:Ye,setShowCountdown:Je})}),e.jsx(dt,{thankYouSettings:Te,setThankYouSettings:be}),e.jsx(X,{title:s("editor.checkInSettings"),children:e.jsx(nt,{settings:Ie,setSettings:Ae})}),e.jsx(X,{title:s("editor.trackingSettings"),children:e.jsx(ot,{facebookPixelId:Ve,setFacebookPixelId:Me,googleAnalyticsId:Re,setGoogleAnalyticsId:Oe,googleTagManagerId:$e,setGoogleTagManagerId:He})}),e.jsxs("div",{className:"flex justify-end gap-4",children:[e.jsx(S,{variant:"outline",onClick:()=>r(1),children:s("common:back")}),e.jsx(S,{variant:"outline",onClick:t,children:s("common:cancel")}),e.jsx(S,{onClick:hs,disabled:Pe,children:s(Pe?"common:saving":"editor.saveForm")})]})]})})};function ut({open:t,onOpenChange:i,onSelectAI:s,onSelectManual:l}){const{t:r}=T("forms");return e.jsx(ze,{open:t,onOpenChange:i,children:e.jsxs(Fe,{className:"sm:max-w-md overflow-hidden",children:[e.jsxs(Ee,{children:[e.jsx(De,{children:r("creationMethod.title",{defaultValue:"How do you want to create the form?"})}),e.jsx(is,{children:r("creationMethod.description",{defaultValue:"Choose between AI-assisted or manual creation."})})]}),e.jsxs("div",{className:"grid gap-3 py-4",children:[e.jsxs("button",{onClick:s,className:"w-full text-left p-4 rounded-lg border border-border hover:border-primary hover:bg-accent/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 text-primary mb-1",children:[e.jsx(Ce,{className:"h-5 w-5 flex-shrink-0"}),e.jsx("span",{className:"font-semibold",children:r("creationMethod.withAI",{defaultValue:"Create with AI"})})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r("creationMethod.withAIDescription",{defaultValue:"Answer some questions and AI will create optimized content"})})]}),e.jsxs("button",{onClick:l,className:"w-full text-left p-4 rounded-lg border border-border hover:border-primary hover:bg-accent/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(ys,{className:"h-5 w-5 flex-shrink-0"}),e.jsx("span",{className:"font-semibold",children:r("creationMethod.manual",{defaultValue:"Create from Scratch"})})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r("creationMethod.manualDescription",{defaultValue:"Start with a blank form and configure manually"})})]})]})]})})}const ss={eventName:"",eventType:"webinar",shortDescription:"",imageUrl:"",mainBenefit:"",benefits:["","",""],targetAudience:"",hasEventDate:!1,eventDate:"",ctaStyle:"amigavel",showCountdown:!1,thankYouStyle:"celebracao",nextSteps:["","",""],checkInEnabled:!1},oe=[{id:1,title:"Básico",description:"Nome e tipo do evento"},{id:2,title:"Proposta",description:"Benefícios e público"},{id:3,title:"CTA",description:"Urgência e ação"},{id:4,title:"Confirmação",description:"Pós-cadastro"}],mt={webinar:"Webinar / Live",aula:"Aula Gratuita",ebook:"E-book / PDF",checklist:"Checklist / Template",mentoria:"Mentoria / Consultoria",curso:"Curso / Treinamento",outro:"Outro"},xt={urgente:"Urgente (escassez)",amigavel:"Amigável (acolhedor)",profissional:"Profissional (formal)"},pt={celebracao:"Celebração (parabéns!)",profissional:"Profissional (próximos passos)",instrucional:"Instrucional (como acessar)"};function gt({data:t,onChange:i}){return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"eventName",children:"Nome do Evento / Material *"}),e.jsx(b,{id:"eventName",value:t.eventName,onChange:s=>i({eventName:s.target.value}),placeholder:"Ex: Masterclass de Marketing Digital"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"O nome principal que aparecerá no formulário"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"eventType",children:"Tipo de Evento *"}),e.jsxs(R,{value:t.eventType,onValueChange:s=>i({eventType:s}),children:[e.jsx(O,{children:e.jsx($,{placeholder:"Selecione o tipo"})}),e.jsx(H,{children:Object.entries(mt).map(([s,l])=>e.jsx(y,{value:s,children:l},s))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"shortDescription",children:"Descrição Curta"}
27),e.jsx(Z,{id:"shortDescription",value:t.shortDescription,onChange:s=>i({shortDescription:s.target.value}),placeholder:"Descreva brevemente sobre o que é o evento ou material...",rows:3}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"A IA usará isso para criar textos persuasivos"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"imageUrl",children:"URL da Imagem (opcional)"}),e.jsx(b,{id:"imageUrl",value:t.imageUrl,onChange:s=>i({imageUrl:s.target.value}),placeholder:"https://..."}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Imagem de capa para o formulário"})]})]})}function jt({data:t,onChange:i}){const s=(c,a)=>{const n=[...t.benefits];n[c]=a,i({benefits:n})},l=()=>{t.benefits.length<6&&i({benefits:[...t.benefits,""]})},r=c=>{if(t.benefits.length>2){const a=t.benefits.filter((n,o)=>o!==c);i({benefits:a})}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"mainBenefit",children:"Principal Benefício *"}),e.jsx(b,{id:"mainBenefit",value:t.mainBenefit,onChange:c=>i({mainBenefit:c.target.value}),placeholder:"Ex: Aprenda a dobrar suas vendas em 30 dias"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"O resultado principal que o participante terá"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(x,{children:"Benefícios Adicionais (2-6)"}),t.benefits.length<6&&e.jsxs(S,{type:"button",variant:"outline",size:"sm",onClick:l,className:"h-8",children:[e.jsx(fe,{className:"h-4 w-4 mr-1"}),"Adicionar"]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Liste outros benefícios que o participante terá"}),t.benefits.map((c,a)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{value:c,onChange:n=>s(a,n.target.value),placeholder:`Benefício ${a+1}`}),t.benefits.length>2&&e.jsx(S,{type:"button",variant:"ghost",size:"icon",onClick:()=>r(a),className:"flex-shrink-0",children:e.jsx(Cs,{className:"h-4 w-4"})})]},a))]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"targetAudience",children:"Público-Alvo"}),e.jsx(Z,{id:"targetAudience",value:t.targetAudience,onChange:c=>i({targetAudience:c.target.value}),placeholder:"Ex: Empreendedores e profissionais de marketing que querem aumentar suas vendas online",rows:2}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Descreva para quem é esse evento/material"})]})]})}function ft({data:t,onChange:i}){return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"ctaStyle",children:"Estilo do CTA *"}),e.jsxs(R,{value:t.ctaStyle,onValueChange:s=>i({ctaStyle:s}),children:[e.jsx(O,{children:e.jsx($,{placeholder:"Selecione o estilo"})}),e.jsx(H,{children:Object.entries(xt).map(([s,l])=>e.jsx(y,{value:s,children:l},s))})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Define o tom dos textos de chamada para ação"})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(x,{htmlFor:"hasEventDate",children:"Evento tem data específica?"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Ativar para eventos ao vivo com data marcada"})]}),e.jsx(B,{id:"hasEventDate",checked:t.hasEventDate,onCheckedChange:s=>i({hasEventDate:s})})]}),t.hasEventDate&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"eventDate",children:"Data do Evento"}),e.jsx(b,{id:"eventDate",type:"datetime-local",value:t.eventDate,onChange:s=>i({eventDate:s.target.value})})]}),t.hasEventDate&&e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(x,{htmlFor:"showCountdown",children:"Mostrar Contagem Regressiva"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Exibe um timer até a data do evento"})]}),e.jsx(B,{id:"showCountdown",checked:t.showCountdown,onCheckedChange:s=>i({showCountdown:s})})]})]})}function vt({data:t,onChange:i}){const s=(l,r)=>{const c=[...t.nextSteps];c[l]=r,i({nextSteps:c})};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"thankYouStyle",children:"Estilo da Página de Confirmação *"}),e.jsxs(R,{value:t.thankYouStyle,onValueChange:l=>i({thankYouStyle:l}),children:[e.jsx(O,{children:e.jsx($,{placeholder:"Selecione o estilo"})}),e.jsx(H,{children:Object.entries(pt).map(([l,r])=>e.jsx(y,{value:l,children:r},l))})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Define o tom da página de agradecimento"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(x,{children:"Próximos Passos (opcional)"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Instruções que aparecem após o cadastro (até 3)"}),t.nextSteps.map((l,r)=>
27e.jsx(b,{value:l,onChange:c=>s(r,c.target.value),placeholder:`Passo ${r+1} (ex: Acesse seu email)`},r))]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(x,{htmlFor:"checkInEnabled",children:"Habilitar Check-in"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Cria página de check-in para eventos ao vivo"})]}),e.jsx(B,{id:"checkInEnabled",checked:t.checkInEnabled,onCheckedChange:l=>i({checkInEnabled:l})})]})]})}function bt({open:t,onOpenChange:i,onComplete:s}){const{t:l}=T("forms"),[r,c]=j.useState(1),[a,n]=j.useState(ss),[o,h]=j.useState(!1),p=r/oe.length*100,u=f=>{n(N=>({...N,...f}))},v=f=>{switch(f){case 1:return!!a.eventName.trim();case 2:return!!a.mainBenefit.trim();case 3:return!0;case 4:return!0;default:return!0}},g=()=>{if(!v(r)){pe.error(l("wizard.fillRequired"));return}r<oe.length&&c(f=>f+1)},C=()=>{r>1&&c(f=>f-1)},z=async()=>{if(!v(r)){pe.error(l("wizard.fillRequired"));return}h(!0);try{const{data:f,error:N}=await F.functions.invoke("generate-form",{body:{wizardData:a}});if(N)throw N;const _=f;if(!(_!=null&&_.optinPage)||!(_!=null&&_.thankYouPage))throw new Error(l("wizard.incompleteResponse"));const{data:{user:P}}=await F.auth.getUser();if(!P)throw new Error(l("wizard.notAuthenticated"));const q=_.thankYouPage.nextSteps||[],{data:I,error:k}=await F.from("forms").insert({user_id:P.id,name:a.eventName,is_optin_page:!0,optin_headline:_.optinPage.headline,optin_subheadline:_.optinPage.subheadline,button_text:_.optinPage.buttonText,image_url:a.imageUrl||null,event_date:a.hasEventDate&&a.eventDate?a.eventDate:null,show_event_date:!!(a.hasEventDate&&a.eventDate),show_countdown:a.showCountdown,thank_you_settings:{background_color:"#ffffff",headline:_.thankYouPage.headline,headline_color:"#222222",headline_size:"3xl",subheadline:_.thankYouPage.subheadline,subheadline_color:"#666666",subheadline_size:"xl",video_url:null,video_type:"url",embed_code:null,show_next_steps:q.length>0,next_steps:q,button_text:_.thankYouPage.buttonText||"Continuar",button_url:null,button_color:"#7E69AB",button_size:"lg"},check_in_settings:a.checkInEnabled&&_.checkInPage?{title:_.checkInPage.title||"Check-in do Evento",subtitle:_.checkInPage.subtitle||"Confirme sua presença",title_color:"#222222",title_size:"text-2xl",subtitle_color:"#8E9196",subtitle_size:"text-lg",button_text:_.checkInPage.buttonText||"Fazer Check-in",button_color:"#7E69AB",button_size:"lg",border_color:"#F1F1F1",background_color:"#ffffff",footer_text:_.checkInPage.footerText||"Confirme seu e-mail para entrar na sala secreta",post_checkin_url:null,webhook_url:null}:null}).select().single();if(k)throw k;const V=[{form_id:I.id,name:"name",label:"Nome",type:"text",order_index:0,required:!0,placeholder:"Seu nome completo"},{form_id:I.id,name:"email",label:"Email",type:"email",order_index:1,required:!0,placeholder:"[email protected]"},{form_id:I.id,name:"phone",label:"WhatsApp",type:"phone",order_index:2,required:!1,placeholder:"(00) 00000-0000"}],{error:U}=await F.from("form_fields").insert(V);if(U)throw U;pe.success(l("wizard.success")),s(I.id),i(!1),c(1),n(ss)}catch(f){console.error("Error generating form:",f),pe.error(l("wizard.error"))}finally{h(!1)}},w=()=>{switch(r){case 1:return e.jsx(gt,{data:a,onChange:u});case 2:return e.jsx(jt,{data:a,onChange:u});case 3:return e.jsx(ft,{data:a,onChange:u});case 4:return e.jsx(vt,{data:a,onChange:u});default:return null}},d=oe[r-1];return e.jsx(ze,{open:t,onOpenChange:i,children:e.jsxs(Fe,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ee,{children:e.jsxs(De,{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"h-5 w-5 text-primary"}),l("wizard.title")]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"font-medium",children:l("wizard.step",{current:r,title:d.title})}),e.jsx("span",{className:"text-muted-foreground",children:l("wizard.stepOf",{current:r,total:oe.length})})]}),e.jsx(Ws,{value:p,className:"h-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d.description})]}),e.jsx("div",{className:"min-h-[300px]",children:w()}),e.jsxs("div",{className:"flex justify-between pt-4 border-t",children:[e.jsxs(S,{variant:"outline",onClick:C,disabled:r===1||o,children:[e.jsx(ns,{className:"h-4 w-4 mr-2"}),l("wizard.back")]}),r<oe.length?e.jsxs(S,{onClick:g,children:[l("wizard.next"),e.jsx(ks,{className:"h-4 w-4 ml-2"})]}):e.jsx(S,{onClick:z,disabled:o,children:o?e.jsxs(e.Fragment,{children:[e.jsx(Ss,{className:"h-4 w-4 mr-2 animate-spin"}),l("wizard.generating")]}):e.jsxs(e.Fragment,{children:[e.jsx(Ce,{className:"h-4 w-4 mr-2"}),l("wizard.generateForm")]})})]})]})]})})}const aa=()=>{const{toast:t}=je(),{user:i}=ke(),{data:s}=Ks(),{t:l}=T(["forms","common"]),[r,c]=j.useState(!1),[a,n]=j.useState(null),[o,h]=j.useState(!1),[p,u]=j.useState(!1);ce({queryKey:["userForms"],queryFn:async()=>
27{if(!i)return{count:0};const{count:f}=await F.from("forms").select("*",{count:"exact",head:!0}).eq("user_id",i.id);return{count:f||0}},enabled:!!(i!=null&&i.id)}),ce({queryKey:["profile","subscription"],queryFn:async()=>{if(!i)return null;const{data:f}=await F.from("profiles").select("subscription_plan, leads_count, leads_limit").eq("id",i.id).single();return f},enabled:!!(i!=null&&i.id)});const v=()=>s!=null&&s.canUseProFeature?!0:s!=null&&s.isTrialExpired&&((s==null?void 0:s.formsCount)||0)>=1?(t({title:l("forms:errors.trialExpiredTitle"),description:l("forms:errors.trialExpiredDescription"),variant:"destructive"}),!1):!0,g=()=>{v()&&h(!0)},C=()=>{h(!1),u(!0)},z=()=>{h(!1),n(null),c(!0)},w=f=>{u(!1),n(f),c(!0)},d=f=>{n(f),c(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-8 animate-fade-in",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[r?e.jsxs(S,{variant:"ghost",onClick:()=>{c(!1),n(null)},children:[e.jsx(ns,{className:"w-4 h-4 mr-2"}),l("forms:backToForms")]}):e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:l("forms:title")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:l("forms:subtitle")})]}),!r&&e.jsxs(S,{onClick:g,className:"rounded-lg text-xs font-medium h-8 px-3",children:[e.jsx(fe,{className:"w-4 h-4 mr-2"}),l("forms:newForm")]})]}),e.jsx(Gs,{module:"forms"}),r?e.jsx(ht,{onCancel:()=>{c(!1),n(null)},formId:a}):e.jsx(Xs,{onEdit:d})]}),e.jsx(ut,{open:o,onOpenChange:h,onSelectAI:C,onSelectManual:z}),e.jsx(bt,{open:p,onOpenChange:u,onComplete:w})]})};export{aa 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.