import{n as J,a as K,d as L,b as D,c as E,y as Q,p as M}from"./zoom-C7L8PZhV.js";import{g as R,s as N}from"./transform-DLYM6lt_.js";const x=u=>()=>u;function P(u,{sourceEvent:c,subject:b,target:p,identifier:s,active:g,x:h,y,dx:v,dy:d,dispatch:f}){Object.defineProperties(this,{type:{value:u,enumerable:!0,configurable:!0},sourceEvent:{value:c,enumerable:!0,configurable:!0},subject:{value:b,enumerable:!0,configurable:!0},target:{value:p,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:g,enumerable:!0,configurable:!0},x:{value:h,enumerable:!0,configurable:!0},y:{value:y,enumerable:!0,configurable:!0},dx:{value:v,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:f}})}P.prototype.on=function(){var u=this._.on.apply(this._,arguments);return u===this._?this:u};function U(u){return!u.ctrlKey&&!u.button}function V(){return this.parentNode}function W(u,c){return c??{x:u.x,y:u.y}}function Z(){return navigator.maxTouchPoints||"ontouchstart"in this}function ee(){var u=U,c=V,b=W,p=Z,s={},g=R("start","drag","end"),h=0,y,v,d,f,T=0;function a(e){e.on("mousedown.drag",O).filter(p).on("touchstart.drag",A).on("touchmove.drag",B,J).on("touchend.drag touchcancel.drag",G).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function O(e,t){if(!(f||!u.call(this,e,t))){var r=X(this,c.call(this,e,t),e,t,"mouse");r&&(N(e.view).on("mousemove.drag",S,K).on("mouseup.drag",z,K),L(e.view),D(e),d=!1,y=e.clientX,v=e.clientY,r("start",e))}}function S(e){if(E(e),!d){var t=e.clientX-y,r=e.clientY-v;d=t*t+r*r>T}s.mouse("drag",e)}function z(e){N(e.view).on("mousemove.drag mouseup.drag",null),Q(e.view,d),E(e),s.mouse("end",e)}function A(e,t){if(u.call(this,e,t)){var r=e.changedTouches,n=c.call(this,e,t),o=r.length,l,m;for(l=0;l<o;++l)(m=X(this,n,e,t,r[l].identifier,r[l]))&&(D(e),m("start",e,r[l]))}}function B(e){var t=e.changedTouches,r=t.length,n,o;for(n=0;n<r;++n)(o=s[t[n].identifier])&&(E(e),o("drag",e,t[n]))}function G(e){var t=e.changedTouches,r=t.length,n,o;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),n=0;n<r;++n)(o=s[t[n].identifier])&&(D(e),o("end",e,t[n]))}function X(e,t,r,n,o,l){var m=g.copy(),i=M(l||r,t),Y,q,w;if((w=b.call(e,new P("beforestart",{sourceEvent:r,target:a,identifier:o,active:h,x:i[0],y:i[1],dx:0,dy:0,dispatch:m}),n))!=null)return Y=w.x-i[0]||0,q=w.y-i[1]||0,function H(j,C,I){var F=i,k;switch(j){case"start":s[o]=H,k=h++;break;case"end":delete s[o],--h;case"drag":i=M(I||C,t),k=h;break}m.call(j,e,new P(j,{sourceEvent:C,subject:w,target:a,identifier:o,active:k,x:i[0]+Y,y:i[1]+q,dx:i[0]-F[0],dy:i[1]-F[1],dispatch:m}),n)}}return a.filter=function(e){return arguments.length?(u=typeof e=="function"?e:x(!!e),a):u},a.container=function(e){return arguments.length?(c=typeof e=="function"?e:x(e),a):c},a.subject=function(e){return arguments.length?(b=typeof e=="function"?e:x(e),a):b},a.touchable=function(e){return arguments.length?(p=typeof e=="function"?e:x(!!e),a):p},a.on=function(){var e=g.on.apply(g,arguments);return e===g?a:e},a.clickDistance=function(e){return arguments.length?(T=(e=+e)*e,a):Math.sqrt(T)},a}export{ee as d};
