import{d as B,u as D,X as w,a7 as d,r as C,e,o as x,b as A,w as c,i as s,am as I,an as $,ah as g,ai as N,af as P,f as R,a6 as p,W as k,p as S}from"./index.a93ec448.js";import{u as T}from"./useRouteParam.ba3137c3.js";const H=B({__name:"BlockEdit",async setup(V){let o,n;const l=D(),u=T("blockDocumentId"),a=([o,n]=w(()=>p.getBlockDocument(u.value)),o=await o,n(),o),{blockType:_,blockSchema:i}=a,t=d(a.data),f=d(a.name);function b(){p.updateBlockDocument(a.id,{data:t.value}).then(()=>{k("Block updated successfully","success"),l.push(S.block(u.value))}).catch(r=>{k("Failed to update block","error"),console.error(r)})}function h(){l.back()}return(r,m)=>{const y=C("p-layout-default");return e(a)?(x(),A(y,{key:0,class:"block-edit"},{header:c(()=>[s(e(I),{"block-document":e(a)},null,8,["block-document"])]),default:c(()=>[s(e(P),{"block-type":e(_)},{default:c(()=>[s(e($),g({data:t.value,"onUpdate:data":m[0]||(m[0]=v=>t.value=v)},{name:f.value,blockSchema:e(i)},N({submit:b,cancel:h})),null,16,["data"])]),_:1},8,["block-type"])]),_:1})):R("",!0)}}});export{H as default};
