import{X as Q,bT as S,r as u,a5 as t,j as w,V as m,aK as l}from"./index-BLPf7Sv2.js";import{Q as B}from"./index-DJ3d-9TM.js";import{a as v}from"./use-full-view-BmMw2SH8.js";import{c as x}from"./translations-DLkuGKH9.js";const V=({route:o,params:d})=>{v();const n=Q("codeBuddyTranslations",x),{setNodeFormValidBySlug:p,nodes:i,updateNode:y}=S(),s=d.type,a=u.useMemo(()=>i.find(r=>r.type==="start"),[i]),c=a?.data?.step?.type;u.useLayoutEffect(()=>{s&&a&&c!==s&&y(a.id,{...a.data,step:{...a.data?.step??{},type:s}})},[s,a?.id,c]);const[C,g]=t.createQuickCommand.useMutation(),k=async r=>{try{const e=await C({quickCommandsCreateRequest:r});o.$parent.quickCommand.$go({quickCommandSlug:e.slug}),t.quickCommand.invalidate({slug:e.slug}),t.allQuickCommandsV3.invalidate(),t.contentDependencies.invalidate(),m.showToaster({type:"success",title:n.codeBuddyTranslations.createdQuickCommandSuccessTitle,message:n.codeBuddyTranslations.createdQuickCommandSuccessMessage})}catch(e){const f=l({error:e});p(e?.data?.field,!1,f);const T=l({error:e,prefix:n.codeBuddyTranslations.unableToUpdateQuickCommand});throw m.showToaster({type:"error",message:T}),e}};return w.jsx(B,{onClickBack:()=>o.$parent.$go(),onSave:k,isSaving:g,enableKeyboardShortcuts:!0,id:d.id||"",route:o,isViewer:!1,isEdit:!1,useOnly:!1})};export{V as CreateQuickCommandPage};