/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../chunks/_rollupPluginBabelHelpers","../../../core/clock","../InputHandler","./SingleAndDoubleClick","./support"],(function(e,t,i,o,n,a){"use strict";let l=function(e){function o(o=n.DefaultParameters.maximumDoubleClickDelay,a=n.DefaultParameters.maximumDoubleClickDistance,l=n.DefaultParameters.maximumDoubleTouchDelay,u=n.DefaultParameters.maximumDoubleTouchDistance,r=i.clock){var s;return(s=e.call(this,!1)||this).maximumDoubleClickDelay=o,s.maximumDoubleClickDistance=a,s.maximumDoubleTouchDelay=l,s.maximumDoubleTouchDistance=u,s._clock=r,s._pointerState=new Map,s._immediateDoubleClick=s.registerOutgoing("immediate-double-click"),s.registerIncoming("pointer-down",s._handlePointerDown.bind(t._assertThisInitialized(s))),s.registerIncoming("pointer-up",(e=>{s._handlePointerLoss(e,"pointer-up")})),s.registerIncoming("pointer-capture-lost",(e=>{s._handlePointerLoss(e,"pointer-capture-lost")})),s.registerIncoming("pointer-cancel",(e=>{s._handlePointerLoss(e,"pointer-cancel")})),s}t._inheritsLoose(o,e);var l=o.prototype;return l.onUninstall=function(){this._pointerState.forEach((e=>{e.immediateDoubleClick&&e.immediateDoubleClick.timeoutHandle.remove()})),e.prototype.onUninstall.call(this)},l._handlePointerDown=function(e){const t=e.data,i=this._pointerId(t);if(!this._pointerState.has(i)){const e={downButton:t.native.button,immediateDoubleClick:null};this._pointerState.set(i,e),this.startCapturingPointer(t.native)}},l._handlePointerLoss=function(e,t){const i=e.data,o=this._pointerId(i),n=this._pointerState.get(o);if(n&&"pointer-up"===t&&n.downButton===i.native.button){const t=n.immediateDoubleClick;if(t){t.timeoutHandle.remove();const o="touch"===e.data.native.pointerType?this.maximumDoubleTouchDistance:this.maximumDoubleClickDistance;a.manhattanDistance(t,e.data)>o?this._startImmediateDoubleClick(e,n):(this._immediateDoubleClick.emit(e.data,void 0,t.modifiers),this._removeState(i))}else this._startImmediateDoubleClick(e,n)}},l._startImmediateDoubleClick=function(e,t){const i="touch"===e.data.native.pointerType?this.maximumDoubleTouchDelay:this.maximumDoubleClickDelay;t.immediateDoubleClick={x:e.data.x,y:e.data.y,modifiers:e.modifiers,timeoutHandle:this._clock.setTimeout((()=>this._removeState(e.data)),i)}},l._pointerId=function(e){const t=e.native;return"mouse"===t.pointerType?`${t.pointerId}:${t.button}`:`${t.pointerType}`},l._removeState=function(e){const t=this._pointerId(e);this._pointerState.delete(t),this.stopCapturingPointer(e.native),this.refreshHasPendingInputs()},o}(o.InputHandler);e.ImmediateDoubleClick=l,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
