import{y as I,d as S,s as m,c as T,o as k,r as B,G as D,k as w,u as b}from"./index-CDPBytck.js";const t=I(null),l=I(null),C=(a,u)=>{let o=!1;return(...s)=>{o||(a(...s),o=!0,setTimeout(()=>o=!1,u))}},L=["draggable"],x=S({__name:"Draggable",props:{ceiling:{default:.8},floor:{default:.2},isDraggable:{type:Boolean,default:!0},isDroppable:{type:[Boolean,Function],default:!0},parentIds:{},id:{}},emits:["onDragEnd","onDragStart"],setup(a,{expose:u,emit:o}){const s=o,n=m(()=>a.parentIds.at(-1)??null),E=e=>{!e.dataTransfer||!(e.target instanceof HTMLElement)||!a.isDraggable||(e.target.classList.add("dragging"),e.dataTransfer.dropEffect="move",e.dataTransfer.effectAllowed="move",t.value={id:a.id,parentId:n.value},s("onDragStart",{id:a.id,parentId:n.value}))},h=e=>typeof a.isDroppable=="function"?a.isDroppable(t.value,{id:a.id,parentId:n.value,offset:e}):a.isDroppable,g=C(e=>{var r,d;if(!t.value||t.value.id===a.id||a.parentIds.includes(((r=t.value)==null?void 0:r.id)??""))return;const f=(d=l.value)==null?void 0:d.offset,v=e.target.offsetHeight,c=a.floor*v,p=a.ceiling*v;let i=3;e.offsetY<=0&&f&&f!==3?i=f:e.offsetY<=c?i=0:e.offsetY>=p?i=1:e.offsetY>c&&e.offsetY<p&&(i=2),h(i)&&(l.value={id:a.id,parentId:n.value,offset:i})},25),Y=["above","below","asChild"],_=m(()=>{var e;let r="sidebar-indent-nested";return a.id===((e=l.value)==null?void 0:e.id)&&(r+=` dragover-${Y[l.value.offset]}`),r}),y=()=>{if(!l.value||!t.value)return;const e={...t.value},r={...l.value};t.value=null,l.value=null,document.querySelectorAll("div.dragging").forEach(d=>d.classList.remove("dragging")),e.id!==r.id&&s("onDragEnd",e,r)};return u({draggingItem:t,hoveredItem:l}),(e,r)=>(k(),T("div",{class:w(_.value),draggable:e.isDraggable,onDragend:y,onDragover:r[0]||(r[0]=D((...d)=>b(g)&&b(g)(...d),["prevent","stop"])),onDragstart:D(E,["stop"])},[B(e.$slots,"default",{},void 0,!0)],42,L))}}),A=(a,u)=>{const o=a.__vccOpts||a;for(const[s,n]of u)o[s]=n;return o},M=A(x,[["__scopeId","data-v-a89d6a6e"]]);export{M as m};
