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