import{j as e,G as d,t as l}from"./vendor-tanstack-BVzzyDEt.js";import{D as p,B as x,a as b,b as i,bq as f,bz as g,bB as j,bC as h,bD as v,bE as D,w as m}from"./index-BJkJ93Lr.js";import"./automation-schema-CK40VptI.js";import{A as B}from"./automation-wizard-DYQKHgDR.js";import{t as N}from"./event-to-trigger-BEzU9b5I.js";import"./vendor-react-Bce9NwRC.js";import"./vendor-radix-CTAic6HB.js";import"./vendor-recharts-Mwm2qLZp.js";import"./vendor-forms-BN3tpxM2.js";import"./vendor-date-2jFo9aCm.js";import"./use-stepper-D5a6mnYn.js";import"./index-BCjE1NvU.js";import"./textarea-BWNxlLo9.js";import"./radio-group-Bp8yWMIB.js";import"./collapsible-B_Qn5IIc.js";const A=()=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(y,{}),e.jsx(p,{label:"Documentation",id:"automations-guide"})]}),y=()=>e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(x,{children:e.jsxs(b,{children:[e.jsx(i,{children:e.jsx(f,{to:"/automations",className:"text-xl font-semibold",children:"Automations"})}),e.jsx(g,{}),e.jsx(i,{className:"text-xl font-semibold",children:e.jsx(j,{children:"Create"})})]})})});function E(a){const[t,s,o]=a.split("-").map(Number);return new Date(t,s-1,o)}function S(){const{eventId:a,eventDate:t}=v.useSearch(),s=!!(a&&t),{data:o}=l({...D(a??"",t?E(t):new Date),enabled:s});if(!s||!o)return;const{trigger:n,triggerTemplate:r}=N(o);return{trigger:n,triggerTemplate:r}}function W(){const{createAutomation:a,isPending:t}=h(),s=d(),o=S(),n=r=>{const c={name:r.name,description:r.description??"",enabled:!0,trigger:r.trigger,actions:r.actions};a(c,{onSuccess:()=>{m.success("Automation created successfully"),s({to:"/automations"})},onError:u=>{m.error(`Failed to create automation: ${u.message}`)}})};return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(A,{}),e.jsx(B,{defaultValues:o,onSubmit:n,isSubmitting:t})]})}export{W as component};
//# sourceMappingURL=create-Bt4_AGqB.js.map
