import{o as E,eL as k}from"./index-6Jqoo2rk.js";import{u as C}from"./useIsCleaned-qdS5-id0.js";const f=new Map;function D(e,r){const n=f.get(e)||{callbacks:[],listener:o=>{n.callbacks.forEach(c=>c(o))}};return f.has(e)||(f.set(e,n),document.addEventListener(e,n.listener)),n.callbacks.push(r),{cleanup:()=>{n.callbacks=n.callbacks.filter(o=>o!==r),!n.callbacks.length&&(f.delete(e),document.removeEventListener(e,n.listener))}}}function l(e,r){const{cleanup:n}=D(e,r);E(n)}function T(e,r){const n=C();let o=!1,c,a;const d=t=>[t.clientX-c,t.clientY-a],b=t=>[t.changedTouches[0].clientX-c,t.changedTouches[0].clientY-a];function v(t,s,i){if(o)return;o=!0,c=s,a=i;const{onStart:h,globalCursor:g}=r();h?.(t),g&&(document.body.style.setProperty("cursor",g(),"important"),e.style.setProperty("cursor",g(),"important"))}let u=!1,m;function p(t,s){o&&(m=()=>{const{onMove:i}=r();i?.(...s,t)},!u&&(u=!0,k(()=>{u=!1,!(!o||n())&&m()})))}function y(t,s){if(!o)return;const{onEnd:i,globalCursor:h}=r();i?.(...s,t),h&&(document.body.style.removeProperty("cursor"),e.style.removeProperty("cursor")),o=!1,u=!1,c=a=void 0}e.addEventListener("pointerdown",t=>{v(t,t.clientX,t.clientY)}),e.addEventListener("touchstart",t=>{v(t,t.changedTouches[0].clientX,t.changedTouches[0].clientY)}),l("pointermove",t=>{p(t,d(t))}),l("touchmove",t=>{p(t,b(t))}),l("pointermove",t=>{p(t,d(t))}),l("pointerup",t=>{y(t,d(t))}),l("touchend",t=>{y(t,b(t))})}export{T as s};
//# sourceMappingURL=useSwipe-COx9W9fX.js.map
