import{j as e,L as D,d as f}from"./vendor-tanstack-DE4ALVGD.js";import{q as g,I as x,y as s,db as y}from"./index-CNL5pSma.js";import{D as w,a as j,b as C,c as B,d as m}from"./dropdown-menu-D34zumpn.js";import{u as b}from"./use-delete-confirmation-dialog-mtiBAiyE.js";const E=({blockDocument:n,onDelete:a})=>{const t=u=>{navigator.clipboard.writeText(u),s.success("Copied to clipboard!")},{id:c,name:r}=n;return e.jsxs(w,{children:[e.jsx(j,{asChild:!0,children:e.jsxs(g,{variant:"outline",className:"size-8 p-0",children:[e.jsx("span",{className:"sr-only",children:"Open menu"}),e.jsx(x,{id:"MoreVertical",className:"size-4"})]})}),e.jsxs(C,{align:"end",children:[e.jsx(B,{children:"Actions"}),r&&e.jsx(m,{onClick:()=>t(r),children:"Copy Name"}),e.jsx(D,{to:"/blocks/block/$id/edit",params:{id:c},children:e.jsx(m,{children:"Edit"})}),e.jsx(m,{onClick:a,children:"Delete"})]})]})},I=()=>{const n=f(),[a,t]=b(),{deleteBlockDocument:c,mutateAsync:r}=y();return[a,(o,{shouldNavigate:p=!1,onSuccess:h=()=>{}}={})=>{if(Array.isArray(o)){const d=async()=>{try{await Promise.all(o.map(l=>r(l))),s.success("Blocks deleted"),p&&n({to:"/blocks"})}catch(l){const k=l instanceof Error?l.message:"Unknown error while deleting block.";s.error(k),console.error(k)}},i=o.length>1?`Are you sure you want to delete these ${o.length} selected blocks?`:"Are you sure you want to delete this selected block?";t({title:"Delete Blocks",description:i,onConfirm:()=>{d(),h()}})}else t({title:"Delete Block",description:`Are you sure you want to delete ${o.name?o.name:"this block"}?`,onConfirm:()=>{c(o.id,{onSuccess:()=>{s.success("Block deleted"),p&&n({to:"/blocks"}),h()},onError:d=>{const i=d.message||"Unknown error while deleting block.";s.error(i),console.error(i)}})}})}]};export{E as B,I as u};
//# sourceMappingURL=use-delete-block-document-confirmation-dialog-CE9u_x9J.js.map
