import{d as B,m as D,z as C,E as g,aX as w,r as p,a as x,g as e,f as E,w as c,h as P,o as T,n as s,be as F,bf as I,b9 as N,ba as S,b7 as V,aF as b,X}from"./index-18beffd6.js";import{u as z}from"./usePageTitle-5c97edcb.js";const R=B({__name:"BlockEdit",async setup(A){let o,n;const l=D(),u=C(),r=g("blockDocumentId"),t=([o,n]=w(()=>l.blockDocuments.getBlockDocument(r.value)),o=await o,n(),o),{blockType:f,blockSchema:i}=t,d=p(t.data),m=p(t.name);function _(k){l.blockDocuments.updateBlockDocument(t.id,k).then(()=>{b("Block updated successfully","success"),u.push(X.block(r.value))}).catch(a=>{b("Failed to update block","error"),console.error(a)})}function y(){u.back()}return z(`Edit Block: ${m.value}`),(k,a)=>{const h=x("p-layout-default");return e(t)?(T(),E(h,{key:0,class:"block-edit"},{header:c(()=>[s(e(F),{"block-document":e(t)},null,8,["block-document"])]),default:c(()=>[s(e(V),{"block-type":e(f)},{default:c(()=>[s(e(I),N({data:d.value,"onUpdate:data":a[0]||(a[0]=v=>d.value=v)},{name:m.value,blockSchema:e(i)},S({submit:_,cancel:y})),null,16,["data"])]),_:1},8,["block-type"])]),_:1})):P("",!0)}}});export{R as default};
