import{d as C,g as P,ao as x,W as F,i as o,bK as m,c as u,j as r,a as n,k as N,u as w,o as k,l as A,m as p,cs as D,ct as V,cu as W,_ as X,cv as j,L as y,cw as E,bo as H}from"./index-DgpKcZLs.js";import{u as I}from"./usePageTitle-CgS480GG.js";const R=C({__name:"BlocksCatalogCreate",setup(K){const s=P(),t=w(),i=x("redirect"),b=F("blockTypeSlug"),d=o(()=>b.value?[b.value]:null),f=m(s.blockTypes.getBlockTypeBySlug,d),e=o(()=>f.response),v=o(()=>e.value?[e.value.id]:null),_=m(s.blockSchemas.getBlockSchemaForBlockType,v),l=o(()=>_.response);function h(a){s.blockDocuments.createBlockDocument(a).then(({id:c})=>g(c)).catch(c=>{y("Failed to create block","error"),console.error(c)})}function S(){t.back()}function g(a){if(y("Block created successfully","success"),i.value){const c=t.resolve(E(i.value));t.push(c);return}t.push(H.block(a))}const B=o(()=>e.value?`Create ${e.value.name} Block`:"Create Block");return I(B),(a,c)=>{const T=N("p-layout-default");return e.value?(k(),u(T,{key:0,class:"blocks-catalog-create"},{header:r(()=>[A(p(D),{"block-type":e.value},null,8,["block-type"])]),default:r(()=>[e.value?(k(),u(p(V),{key:0,"block-type":e.value},{default:r(()=>[l.value?(k(),u(p(W),X({key:l.value.id,"block-schema":l.value},j({submit:h,cancel:S})),null,16,["block-schema"])):n("",!0)]),_:1},8,["block-type"])):n("",!0)]),_:1})):n("",!0)}}});export{R as default};
//# sourceMappingURL=BlocksCatalogCreate--VHURH3e.js.map
