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