import{d as B,u as w,ao as C,O as k,e as D,r as g,g as e,o as x,f as $,w as c,k as s,aQ as N,aR as P,aL as R,aM as T,aJ as A,h as E,aC as p,a4 as _,t as I}from"./index.52551726.js";import{u as S}from"./useRouteParam.4bc8e74f.js";const J=B({__name:"BlockEdit",async setup(V){let o,n;const l=w(),u=S("blockDocumentId"),a=([o,n]=C(()=>p.getBlockDocument(u.value)),o=await o,n(),o),{blockType:i,blockSchema:f}=a,r=k(a.data),m=k(a.name);function b(d){p.updateBlockDocument(a.id,d).then(()=>{_("Block updated successfully","success"),l.push(I.block(u.value))}).catch(t=>{_("Failed to update block","error"),console.error(t)})}function h(){l.back()}return D(`Edit Block: ${m.value}`),(d,t)=>{const y=g("p-layout-default");return e(a)?(x(),$(y,{key:0,class:"block-edit"},{header:c(()=>[s(e(N),{"block-document":e(a)},null,8,["block-document"])]),default:c(()=>[s(e(A),{"block-type":e(i)},{default:c(()=>[s(e(P),R({data:r.value,"onUpdate:data":t[0]||(t[0]=v=>r.value=v)},{name:m.value,blockSchema:e(f)},T({submit:b,cancel:h})),null,16,["data"])]),_:1},8,["block-type"])]),_:1})):E("",!0)}}});export{J as default};
