import{j as t,d,t as l}from"./vendor-tanstack-DE4ALVGD.js";import{D as p,B as x,g as b,h as i,bv as f,bE as g,bG as j,bH as h,bI as v,bJ as D,y as m}from"./index-CNL5pSma.js";import"./automation-schema-CEK5nVQx.js";import{A as B}from"./automation-wizard-CP5eH6ej.js";import{t as N}from"./event-to-trigger-BEzU9b5I.js";import"./vendor-react-HBv6Kpyp.js";import"./vendor-radix-K8EF6rBE.js";import"./vendor-recharts-B3wzJa9e.js";import"./vendor-forms-BvpM0AtX.js";import"./vendor-date-Bck8LDfw.js";import"./zod-2_bJZbih.js";import"./form-_6uPI_KA.js";import"./use-stepper-CGpO08Vt.js";import"./textarea-CaeS8CF9.js";import"./index-BTIbTWaS.js";import"./radio-group-GICFyAZR.js";import"./collapsible-ByOWaVCG.js";import"./tags-input-CZLIJjbu.js";const y=()=>t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(A,{}),t.jsx(p,{label:"Documentation",id:"automations-guide"})]}),A=()=>t.jsx("div",{className:"flex items-center gap-2",children:t.jsx(x,{children:t.jsxs(b,{children:[t.jsx(i,{children:t.jsx(f,{to:"/automations",className:"text-xl font-semibold",children:"Automations"})}),t.jsx(g,{}),t.jsx(i,{className:"text-xl font-semibold",children:t.jsx(j,{children:"Create"})})]})})});function E(a){const[e,o,s]=a.split("-").map(Number);return new Date(e,o-1,s)}function S(){const{eventId:a,eventDate:e}=v.useSearch(),o=!!(a&&e),{data:s}=l({...D(a??"",e?E(e):new Date),enabled:o});if(!o||!s)return;const{trigger:n,triggerTemplate:r}=N(s);return{trigger:n,triggerTemplate:r}}function K(){const{createAutomation:a,isPending:e}=h(),o=d(),s=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"),o({to:"/automations"})},onError:u=>{m.error(`Failed to create automation: ${u.message}`)}})};return t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsx(y,{}),t.jsx(B,{defaultValues:s,onSubmit:n,isSubmitting:e})]})}export{K as component};
//# sourceMappingURL=create-BGC2ujLA.js.map
