import{a as g}from"./base-a3ee0d3b.js";import{s as W,ad as B,ak as U}from"./normalize-035cc755.js";const y=(t,e,p)=>{let c={offsetX:0,offsetY:0};const a=i=>{const L=i.clientX,M=i.clientY,{offsetX:n,offsetY:s}=c,o=t.value.getBoundingClientRect(),u=o.left,l=o.top,w=o.width,X=o.height,Y=document.documentElement.clientWidth,x=document.documentElement.clientHeight,b=-u+n,D=-l+s,H=Y-u-w+n,T=x-l-X+s,d=f=>{const r=Math.min(Math.max(n+f.clientX-L,b),H),h=Math.min(Math.max(s+f.clientY-M,D),T);c={offsetX:r,offsetY:h},t.value.style.transform=`translate(${g(r)}, ${g(h)})`},v=()=>{document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",v)};document.addEventListener("mousemove",d),document.addEventListener("mouseup",v)},E=()=>{e.value&&t.value&&e.value.addEventListener("mousedown",a)},m=()=>{e.value&&t.value&&e.value.removeEventListener("mousedown",a)};W(()=>{B(()=>{p.value?E():m()})}),U(()=>{m()})};export{y as u};
