import{d as C,al as F,am as x,W as A,b as o,bk as m,c as r,e as u,a as n,f as P,u as R,o as k,g as V,h as p,cc as D,cd as N,ce as W,R as X,cf as w,_ as f,cg as H,aX as L}from"./index-BjFilUfY.js";import{u as Q}from"./usePageTitle-J4-vayug.js";const z=C({__name:"BlocksCatalogCreate",setup($){const s=F(),a=R(),i=x("redirect"),b=A("blockTypeSlug"),d=o(()=>b.value?[b.value]:null),y=m(s.blockTypes.getBlockTypeBySlug,d),e=o(()=>y.response),v=o(()=>e.value?[e.value.id]:null),_=m(s.blockSchemas.getBlockSchemaForBlockType,v),l=o(()=>_.response);function h(t){s.blockDocuments.createBlockDocument(t).then(({id:c})=>S(c)).catch(c=>{f("Failed to create block","error"),console.error(c)})}function g(){a.back()}function S(t){if(f("Block created successfully","success"),i.value){const c=a.resolve(H(i.value));a.push(c);return}a.push(L.block(t))}const B=o(()=>e.value?`Create ${e.value.name} Block`:"Create Block");return Q(B),(t,c)=>{const T=P("p-layout-default");return e.value?(k(),r(T,{key:0,class:"blocks-catalog-create"},{header:u(()=>[V(p(D),{"block-type":e.value},null,8,["block-type"])]),default:u(()=>[e.value?(k(),r(p(N),{key:0,"block-type":e.value},{default:u(()=>[l.value?(k(),r(p(W),X({key:l.value.id,"block-schema":l.value},w({submit:h,cancel:g})),null,16,["block-schema"])):n("",!0)]),_:1},8,["block-type"])):n("",!0)]),_:1})):n("",!0)}}});export{z as default};
//# sourceMappingURL=BlocksCatalogCreate-DtWFsvp_.js.map
