(function(u,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],d):(u=typeof globalThis<"u"?globalThis:u||self,d(u.HDraggable={},u.Vue))})(this,function(u,d){"use strict";function q(e){return Object.prototype.toString.call(e).slice(8,-1)}function H(e){return q(e)==="Object"}const C=()=>/AppleWebKit.*Mobile.*/.test(navigator.userAgent);function x(e){return e.touches?e.touches[0]||e.changedTouches[0]:e}function w(e){return e.offsetParent||document.body||document.documentElement}const F=C(),O=F?"touchstart":"mousedown",_=F?"touchmove":"mousemove",j=F?"touchend":"mouseup";function b(e){const{overflow:t,side:f,left:g,right:i}=e;let c=null;function v(){if(d.unref(e.disabled))return;const n=d.unref(e.target),l=d.unref(e.handle||e.target);function y(r){r.preventDefault();const{clientX:m,clientY:I}=x(r),a=n.offsetLeft,R=n.offsetTop,{width:D,height:B}=n.getBoundingClientRect(),K=m-a,k=I-R;let P=Number.NEGATIVE_INFINITY,U=Number.NEGATIVE_INFINITY,Y=Number.POSITIVE_INFINITY,L=Number.POSITIVE_INFINITY;t||(P=0,U=0,Y=w(n).clientWidth-D,L=w(n).clientHeight-B);let s=0,o=0;function M(N){var $;N.preventDefault(),N.stopImmediatePropagation();const{clientX:S,clientY:T}=x(N);s=S-K,o=T-k,s
Y&&(s=Y),oL&&(o=L);const{clientWidth:E,clientHeight:A}=w(n),V=s/E*100,X=o/A*100;n.style.left=`${s}px`,n.style.top=`${o}px`,($=e.siteUpdated)==null||$.call(e,{x:s,y:o},{x:V,y:X})}function W(N){var T;const{clientX:S}=x(N);if(f){const{clientWidth:E,clientHeight:A}=w(n);g||(i?s=E-D:s=S>Math.floor(E/2)?E-D:0);const V=s/E*100,X=o/A*100;n.style.left=`${s}px`,(T=e.siteUpdated)==null||T.call(e,{x:s,y:o},{x:V,y:X})}window.removeEventListener(_,M),window.removeEventListener(j,W)}window.addEventListener(_,M,{passive:!1}),window.addEventListener(j,W,{passive:!1})}return l.addEventListener(O,y),c=()=>l.removeEventListener(O,y),p}function p(){c==null||c(),c=null}return d.watch(()=>[e.target,e.handle,e.disabled],v,{immediate:!0}),{init:v,destroy:p}}const G={created(e,t,f){let g=e,i=e;const{overflow:c,side:v,left:p,right:n}=t.modifiers;let l;if(t.value)if(H(t.value)){const{target:r,handle:m,siteUpdated:I}=t.value;r&&h(r,e,a=>g=a),m&&h(m,e,a=>i=a),l=I}else h(t.value,e,r=>i=r);const y=b({target:g,handle:i,overflow:c,side:v,left:p,right:n,siteUpdated:l});e.unDragFn=y.destroy},beforeUnmount(e){var t;(t=e.unDragFn)==null||t.call(e)},bind(e,t,f){let g=e,i=e;const{overflow:c,side:v,left:p,right:n}=t.modifiers;let l;if(t.value)if(H(t.value)){const{target:r,handle:m,siteUpdated:I}=t.value;r&&h(r,e,a=>g=a),m&&h(m,e,a=>i=a),l=I}else h(t.value,e,r=>i=r);const y=b({target:g,handle:i,overflow:c,side:v,left:p,right:n,siteUpdated:l});e.unDragFn=y.destroy},unbind(e){var t;(t=e.unDragFn)==null||t.call(e)}};function h(e,t,f){f(typeof e=="function"?e():typeof e=="string"?t.querySelector(e):e)}u.drag=b,u.draggable=G,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});