import{d as C,e as P,al as x,W as D,g as o,bG as m,c as r,h as u,a as n,i as F,u as A,o as k,j as N,k as p,co as V,cp as W,cq as X,X as Z,cr as j,P as y,cs as q,bk as w}from"./index-B5elPXvm.js";import{u as G}from"./usePageTitle-c6xxeh_y.js";const z=C({__name:"BlocksCatalogCreate",setup(H){const s=P(),a=A(),i=x("redirect"),b=D("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),h=m(s.blockSchemas.getBlockSchemaForBlockType,v),l=o(()=>h.response);function _(t){s.blockDocuments.createBlockDocument(t).then(({id:c})=>g(c)).catch(c=>{y("Failed to create block","error"),console.error(c)})}function S(){a.back()}function g(t){if(y("Block created successfully","success"),i.value){const c=a.resolve(q(i.value));a.push(c);return}a.push(w.block(t))}const B=o(()=>e.value?`Create ${e.value.name} Block`:"Create Block");return G(B),(t,c)=>{const T=F("p-layout-default");return e.value?(k(),r(T,{key:0,class:"blocks-catalog-create"},{header:u(()=>[N(p(V),{"block-type":e.value},null,8,["block-type"])]),default:u(()=>[e.value?(k(),r(p(W),{key:0,"block-type":e.value},{default:u(()=>[l.value?(k(),r(p(X),Z({key:l.value.id,"block-schema":l.value},j({submit:_,cancel:S})),null,16,["block-schema"])):n("",!0)]),_:1},8,["block-type"])):n("",!0)]),_:1})):n("",!0)}}});export{z as default};
//# sourceMappingURL=BlocksCatalogCreate-xOlUmS4x.js.map
