"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("vue"),r=require("../../../_util/hooks/useState.js"),O=.1,b=.01,i=20,L=.995**i;function R(E,v){const[c,f]=r.default(),[P,y]=r.default(0),[m,I]=r.default(0),[p,M]=r.default(),h=u.ref();function D(e){const{screenX:t,screenY:n}=e.touches[0];f({x:t,y:n}),clearInterval(h.value)}function _(e){if(!c.value)return;e.preventDefault();const{screenX:t,screenY:n}=e.touches[0],o=t-c.value.x,a=n-c.value.y;v(o,a),f({x:t,y:n});const s=Date.now();I(s-P.value),y(s),M({x:o,y:a})}function X(){if(!c.value)return;const e=p.value;if(f(null),M(null),e){const t=e.x/m.value,n=e.y/m.value,o=Math.abs(t),a=Math.abs(n);if(Math.max(o,a)<O)return;let s=t,T=n;h.value=setInterval(()=>{if(Math.abs(s)<b&&Math.abs(T)<b){clearInterval(h.value);return}s*=L,T*=L,v(s*i,T*i)},i)}}const d=u.ref();function Y(e){const{deltaX:t,deltaY:n}=e;let o=0;const a=Math.abs(t),s=Math.abs(n);a===s?o=d.value==="x"?t:n:a>s?(o=t,d.value="x"):(o=n,d.value="y"),v(-o,-o)&&e.preventDefault()}const l=u.ref({onTouchStart:D,onTouchMove:_,onTouchEnd:X,onWheel:Y});function W(e){l.value.onTouchStart(e)}function x(e){l.value.onTouchMove(e)}function S(e){l.value.onTouchEnd(e)}function N(e){l.value.onWheel(e)}u.onMounted(()=>{document.addEventListener("touchmove",x,{passive:!1}),document.addEventListener("touchend",S,{passive:!1}),E.value?.addEventListener("touchstart",W,{passive:!1}),E.value?.addEventListener("wheel",N,{passive:!1})}),u.onBeforeUnmount(()=>{document.removeEventListener("touchmove",x),document.removeEventListener("touchend",S)})}exports.default=R;
