/*
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","../DragEventSeparator","../InputHandler"],(function(t,e,a,i){"use strict";let r=function(t){function i(e=20,i=40){var r;return(r=t.call(this,!1)||this)._threshold=e,r._maxDelta=i,r.state="ready",r.emittedArtificalEnd2=!1,r._vertical=r.registerOutgoing("vertical-two-finger-drag"),r._artificalDrag=r.registerOutgoing("drag"),r.dragEventSeparator=new a.DragEventSeparator({start:(t,e)=>r._observeStart(t,e),update:(t,e,a)=>r._observeUpdate(t,e,a),end:(t,e)=>r._observeEnd(e)}),r.registerIncoming("drag",(t=>r.dragEventSeparator.handle(t))),r}e._inheritsLoose(i,t);var r=i.prototype;return r._observeStart=function(t,e){1===t&&this.emittedArtificalEnd2&&(this.emittedArtificalEnd2=!1,this._artificalDrag.emit({action:"start",button:e.data.button,buttons:e.data.buttons,pointerType:e.data.pointerType,timestamp:e.data.timestamp,pointers:e.data.pointers,pointer:e.data.pointer,angle:e.data.angle,radius:e.data.radius,center:e.data.center}),e.stopPropagation()),this.state=2===t?"ready":"failed"},r._observeUpdate=function(t,e,a){if("failed"!==this.state&&2===t)return"active"===this.state?(this._vertical.emit({delta:e.data.center.y-this._thresholdReachedCenter.y,action:"update"}),void e.stopPropagation()):void(this._checkMovementWithinLimits(e.data,a.data)?this._checkVerticalThresholdReached(e.data,a.data)&&(this.state="active",this.emittedArtificalEnd2=!0,this._thresholdReachedCenter=e.data.center,this._artificalDrag.emit({action:"end",button:e.data.button,buttons:e.data.buttons,pointerType:e.data.pointerType,timestamp:e.data.timestamp,pointers:e.data.pointers,pointer:e.data.pointer,angle:e.data.angle,radius:e.data.radius,center:e.data.center}),this._vertical.emit({delta:e.data.center.y-this._thresholdReachedCenter.y,action:"begin"}),e.stopPropagation()):this.state="failed")},r._observeEnd=function(t){"active"===this.state&&(this._vertical.emit({delta:t.data.center.y-this._thresholdReachedCenter.y,action:"end"}),this.state="ready",t.stopPropagation())},r._checkMovementWithinLimits=function(t,e){let a=-1/0,i=1/0,r=-1/0,n=1/0;e.pointers.forEach((t=>{a=Math.max(a,t.x),i=Math.min(i,t.x),r=Math.max(r,t.y),n=Math.min(n,t.y)}));let s=-1/0,o=1/0,d=-1/0,h=1/0;t.pointers.forEach((t=>{s=Math.max(s,t.x),o=Math.min(o,t.x),d=Math.max(d,t.y),h=Math.min(h,t.y)}));const c=a-i,l=r-n,p=s-o,u=d-h;return Math.abs(t.center.x-e.center.x)<this._threshold&&Math.abs(p-c)<=this._maxDelta&&Math.abs(u-l)<=this._maxDelta},r._checkVerticalThresholdReached=function(t,e){let a=Math.abs(t.center.y-e.center.y);return t.pointers.forEach(((t,i)=>{const r=e.pointers.get(i);a=Math.min(a,Math.abs(t.y-r.y))})),a>=this._threshold},e._createClass(i,[{key:"failed",get:function(){return"failed"===this.state}}]),i}(i.InputHandler);t.VerticalTwoFingerDrag=r,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
