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