import{d as C,M as x,g as F,b as P,e as c,az as m,c as r,i as u,a as n,j as w,a1 as A,o as k,m as D,u as p,bt as M,bu as N,bv as O,bw as V,bx as j,b0 as f,by as z,ae as E}from"./index-bD6G21oH.js";import{u as H}from"./usePageTitle-27XdpEbQ.js";const G=C({__name:"BlocksCatalogCreate",setup(R){const s=x(),a=A(),b=F("redirect"),i=P("blockTypeSlug"),y=c(()=>i.value?[i.value]:null),d=m(s.blockTypes.getBlockTypeBySlug,y),e=c(()=>d.response),v=c(()=>e.value?[e.value.id]:null),h=m(s.blockSchemas.getBlockSchemaForBlockType,v),l=c(()=>h.response);function S(t){s.blockDocuments.createBlockDocument(t).then(({id:o})=>B(o)).catch(o=>{f("Failed to create block","error"),console.error(o)})}function _(){a.back()}function B(t){if(f("Block created successfully","success"),b.value){const o=a.resolve(z(b.value));a.push(o);return}a.push(E.block(t))}const g=c(()=>e.value?`Create ${e.value.name} Block`:"Create Block");return H(g),(t,o)=>{const T=w("p-layout-default");return e.value?(k(),r(T,{key:0,class:"blocks-catalog-create"},{header:u(()=>[D(p(M),{"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(O),V({key:l.value.id,"block-schema":l.value},j({submit:S,cancel:_})),null,16,["block-schema"])):n("",!0)]),_:1},8,["block-type"])):n("",!0)]),_:1})):n("",!0)}}});export{G as default};
