import{A as L,B as d,t as q,D as A,F as p,G as y,J as x,L as C,K as g}from"./index-BT5eY4j5.js";import{c as D}from"./selection-DqxIs-MO.js";const w={left:!0,right:!0,up:!0,down:!0,horizontal:!0,vertical:!0},T=Object.keys(w);w.all=!0;function S(i){const t={};for(const s of T)i[s]===!0&&(t[s]=!0);return Object.keys(t).length===0?w:(t.horizontal===!0?t.left=t.right=!0:t.left===!0&&t.right===!0&&(t.horizontal=!0),t.vertical===!0?t.up=t.down=!0:t.up===!0&&t.down===!0&&(t.vertical=!0),t.horizontal===!0&&t.vertical===!0&&(t.all=!0),t)}const z=["INPUT","TEXTAREA"];function P(i,t){return t.event===void 0&&i.target!==void 0&&i.target.draggable!==!0&&typeof t.handler=="function"&&z.includes(i.target.nodeName.toUpperCase())===!1&&(i.qClonedBy===void 0||i.qClonedBy.indexOf(t.uid)===-1)}function E(i){const t=[.06,6,50];return typeof i=="string"&&i.length&&i.split(":").forEach((s,a)=>{const l=parseFloat(s);l&&(t[a]=l)}),t}const X=L({name:"touch-swipe",beforeMount(i,{value:t,arg:s,modifiers:a}){if(a.mouse!==!0&&d.has.touch!==!0)return;const l=a.mouseCapture===!0?"Capture":"",e={handler:t,sensitivity:E(s),direction:S(a),noop:q,mouseStart(o){P(o,e)&&A(o)&&(p(e,"temp",[[document,"mousemove","move",`notPassive${l}`],[document,"mouseup","end","notPassiveCapture"]]),e.start(o,!0))},touchStart(o){if(P(o,e)){const u=o.target;p(e,"temp",[[u,"touchmove","move","notPassiveCapture"],[u,"touchcancel","end","notPassiveCapture"],[u,"touchend","end","notPassiveCapture"]]),e.start(o)}},start(o,u){d.is.firefox===!0&&y(i,!0);const c=x(o);e.event={x:c.left,y:c.top,time:Date.now(),mouse:u===!0,dir:!1}},move(o){if(e.event===void 0)return;if(e.event.dir!==!1){C(o);return}const u=Date.now()-e.event.time;if(u===0)return;const c=x(o),f=c.left-e.event.x,r=Math.abs(f),v=c.top-e.event.y,n=Math.abs(v);if(e.event.mouse!==!0){if(r<e.sensitivity[1]&&n<e.sensitivity[1]){e.end(o);return}}else if(window.getSelection().toString()!==""){e.end(o);return}else if(r<e.sensitivity[2]&&n<e.sensitivity[2])return;const m=r/u,h=n/u;e.direction.vertical===!0&&r<n&&r<100&&h>e.sensitivity[0]&&(e.event.dir=v<0?"up":"down"),e.direction.horizontal===!0&&r>n&&n<100&&m>e.sensitivity[0]&&(e.event.dir=f<0?"left":"right"),e.direction.up===!0&&r<n&&v<0&&r<100&&h>e.sensitivity[0]&&(e.event.dir="up"),e.direction.down===!0&&r<n&&v>0&&r<100&&h>e.sensitivity[0]&&(e.event.dir="down"),e.direction.left===!0&&r>n&&f<0&&n<100&&m>e.sensitivity[0]&&(e.event.dir="left"),e.direction.right===!0&&r>n&&f>0&&n<100&&m>e.sensitivity[0]&&(e.event.dir="right"),e.event.dir!==!1?(C(o),e.event.mouse===!0&&(document.body.classList.add("no-pointer-events--children"),document.body.classList.add("non-selectable"),D(),e.styleCleanup=_=>{e.styleCleanup=void 0,document.body.classList.remove("non-selectable");const b=()=>{document.body.classList.remove("no-pointer-events--children")};_===!0?setTimeout(b,50):b()}),e.handler({evt:o,touch:e.event.mouse!==!0,mouse:e.event.mouse,direction:e.event.dir,duration:u,distance:{x:r,y:n}})):e.end(o)},end(o){e.event!==void 0&&(g(e,"temp"),d.is.firefox===!0&&y(i,!1),e.styleCleanup!==void 0&&e.styleCleanup(!0),o!==void 0&&e.event.dir!==!1&&C(o),e.event=void 0)}};if(i.__qtouchswipe=e,a.mouse===!0){const o=a.mouseCapture===!0||a.mousecapture===!0?"Capture":"";p(e,"main",[[i,"mousedown","mouseStart",`passive${o}`]])}d.has.touch===!0&&p(e,"main",[[i,"touchstart","touchStart",`passive${a.capture===!0?"Capture":""}`],[i,"touchmove","noop","notPassiveCapture"]])},updated(i,t){const s=i.__qtouchswipe;s!==void 0&&(t.oldValue!==t.value&&(typeof t.value!="function"&&s.end(),s.handler=t.value),s.direction=S(t.modifiers))},beforeUnmount(i){const t=i.__qtouchswipe;t!==void 0&&(g(t,"main"),g(t,"temp"),d.is.firefox===!0&&y(i,!1),t.styleCleanup!==void 0&&t.styleCleanup(),delete i.__qtouchswipe)}});export{X as T,S as g,P as s};
