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