import{B as e,Et as t,H as n,Lt as r,Rt as i,Tt as a,Ut as o,W as s,bt as c,q as l,r as u,tt as d,yt as f}from"../chunks/De2yIhEs.js";import"../chunks/D5dhgX4z.js";import"../chunks/UJE8BsR4.js";import"../chunks/Cj9ecUMW.js";import"../chunks/BFbU5qhn.js";import"../chunks/tmK-_Zu8.js";import"../chunks/CXy0rHsr.js";import{B as p,U as m,n as h}from"../chunks/DVD-VP-F.js";import"../chunks/BNS5LF6k.js";import{r as g}from"../chunks/DLl5XHy4.js";import"../chunks/BrMTXoyD.js";import{n as _,t as v}from"../chunks/U2gI3XA6.js";import{t as y}from"../chunks/CoakvsTA.js";var b=s(`<!> <!>`,1);function x(s,x){i(x,!0);let S=t(!1),C=t(null);u(async()=>{v.definitions.length===0&&await _.load()});async function w(e){a(S,!0),a(C,null);try{await _.create(e),await g(`/actions/custom`)}catch(e){throw e instanceof Error&&a(C,e.message,!0),e}finally{a(S,!1)}}function T(){g(`/actions/custom`)}p(s,{heading:`Create Custom Action`,description:`Create a blank action or start from a built-in action template.`,actions:e=>{m(e,{variant:`secondary`,onclick:T,children:(e,t)=>{o(),n(e,l(`← Back to List`))},$$slots:{default:!0}})},children:(t,r)=>{var i=b(),a=f(i),o=e=>{h(e,{variant:`error`,title:`Unable to create custom action`,get message(){return d(C)},actionLabel:`Back to list`,onAction:T,testId:`custom-action-create-error-state`})};e(a,e=>{d(C)&&e(o)});var s=c(a,2),l=e=>{h(e,{variant:`loading`,title:`Loading templates`,message:`Fetching template definitions before creating your custom action.`,testId:`custom-action-create-loading-state`})},u=e=>{y(e,{get definitions(){return v.definitions},onSubmit:w,onCancel:T,get submitting(){return d(S)}})};e(s,e=>{v.loading?e(l):e(u,!1)}),n(t,i)},$$slots:{actions:!0,default:!0}}),r()}export{x as component};