import{onBeforeUnmount as e,onMounted as t,watch as n}from"vue";var r=14/15;function i(i,a,o){let s=!1,c=0,l=null,u=null,d=()=>{l&&(l.removeEventListener(`touchmove`,f),l.removeEventListener(`touchend`,p))},f=e=>{if(s){let t=Math.ceil(e.touches[0].pageY),n=c-t;c=t,o(n)&&e.preventDefault(),clearInterval(u),u=setInterval(()=>{n*=r,(!o(n,!0)||Math.abs(n)<=.1)&&clearInterval(u)},16)}},p=()=>{s=!1,d()},m=e=>{d(),e.touches.length===1&&!s&&(s=!0,c=Math.ceil(e.touches[0].pageY),l=e.target,l.addEventListener(`touchmove`,f,{passive:!1}),l.addEventListener(`touchend`,p))},h=()=>{};t(()=>{document.addEventListener(`touchmove`,h,{passive:!1}),n(i,e=>{a.value.removeEventListener(`touchstart`,m),d(),clearInterval(u),e&&a.value.addEventListener(`touchstart`,m,{passive:!1})},{immediate:!0})}),e(()=>{document.removeEventListener(`touchmove`,h)})}export{i as default};