// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define("exports ../../core/iteratorUtils ../../core/MapUtils ../../core/mathUtils ../../core/screenUtils ./interactiveToolUtils ../support/screenUtils".split(" "),function(q,w,x,r,y,z,k){function t(a){let e=null;x.someMap(a,({manipulator:c})=>{if(null!=c&&c.interactive){if(c.grabbing&&c.grabCursor)return e=c.grabCursor,!0;if(c.cursor)return e=c.cursor,!0}return!1});return e}function m(a,e,c){let d=null;c(b=>{if(null==b.manipulators||!z.areToolManipulatorsEditable(b))return!1;const f=b.manipulators.intersect(a, e);if(null==f)return!1;d={tool:b,manipulator:f};return!0});return d}class A{constructor(){this._pointerLocations=new Map;this._hoveredManipulators=new Map;this._grabbedManipulators=new Map;this._draggedManipulators=new Map;this._revertToNullActiveTool=this._stopDrag=!1;this._cursor=null}get cursor(){return this._cursor}hasFocusedManipulators(){return 0a.stopPropagation();switch(a.type){case "pointer-move":"mouse"=== a.pointerType&&this._pointerLocations.set(a.pointerId,{x:a.x,y:a.y,pointerType:a.pointerType});break;case "drag":0 {if((null==h||h.tool!==n||n.automaticManipulatorSelection)&&n.manipulators){let u=!1;n.manipulators.forEach(({manipulator:v})=>{v.selected&&(v.selected=!1,u=!0)});if(u&&n.onManipulatorSelectionChanged)n.onManipulatorSelectionChanged()}});if(null==h)break;const {manipulator:l,tool:p}=h;if(!l.interactive)break;if(l.selectable&&p.automaticManipulatorSelection&&(l.selected=!l.selected,p.onManipulatorSelectionChanged))p.onManipulatorSelectionChanged();l.events.emit("immediate-click",{screenPoint:d,button:a.button, pointerType:a.pointerType,shiftKey:a.native.shiftKey,stopPropagation:c});l?.consumesClicks&&a.stopPropagation();break;case "click":c=k.createScreenPointFromEvent(a);d=m(c,a.pointerType,e.forEachTool)?.manipulator;if(null==d||!d.interactive)break;d.events.emit(a.type,{screenPoint:c,button:a.button,pointerType:a.pointerType,shiftKey:a.native.shiftKey});a.stopPropagation();break;case "double-click":d=k.createScreenPointFromEvent(a);b=m(d,a.pointerType,e.forEachTool);b=null!=b?b.manipulator:null;if(null== b||!b.interactive)break;b.events.emit("double-click",{screenPoint:d,button:a.button,pointerType:a.pointerType,shiftKey:a.native.shiftKey,stopPropagation:c});b?.consumesClicks&&a.stopPropagation();break;case "immediate-double-click":d=k.createScreenPointFromEvent(a),b=m(d,a.pointerType,e.forEachTool),b=null!=b?b.manipulator:null,null!=b&&b.interactive&&(b.events.emit("immediate-double-click",{screenPoint:d,button:a.button,pointerType:a.pointerType,shiftKey:a.native.shiftKey,stopPropagation:c}),b?.consumesClicks&& a.stopPropagation())}this._onFocusChange(e.forEachTool)}_releaseManipulatorBeforeDragging(a,e,c){a.grabbing=!1;a.events.emit("grab-changed",{action:"end",pointerType:e.pointerType,screenPoint:k.createScreenPointFromEvent(e)});this._grabbedManipulators.forEach(({manipulator:d},b)=>{d===a&&this._grabbedManipulators.delete(b)});this._afterManipulatorRelease(c.setActiveTool)}_handlePointerEnd(a,e){const c=this._grabbedManipulators.get(a.pointerId)?.manipulator;null!=c&&c.grabbing&&(c.grabbing=!1,c.events.emit("grab-changed", {action:"end",pointerType:a.pointerType,screenPoint:k.createScreenPointFromEvent(a)}),this._grabbedManipulators.delete(a.pointerId),this._afterManipulatorRelease(e.setActiveTool))}_onFocusChange(a){this._updateCursor();this._updateFocusedManipulatorTools(a)}_updateCursor(){this._cursor=0 {e.add(d)});this._hoveredManipulators.forEach(({tool:d})=>{c.add(d)});a(d=>{d.hasGrabbedManipulators=e.has(d);d.hasHoveredManipulators=c.has(d);var b=this._grabbedManipulators.values();b=w.find(b,({tool:f})=>f===d);d.firstGrabbedManipulator=null!=b?b.manipulator:null})}clearPointers(a,{forEachTool:e,setActiveTool:c},d=!0,b){this._grabbedManipulators.forEach(({tool:f,manipulator:g,pointerType:h},l)=>{f!==a||null!=b&&b!==g||(this._grabbedManipulators.delete(l),g.grabbing=!1,g.events.emit("grab-changed", {action:"end",screenPoint:null,pointerType:h}))});this._draggedManipulators.forEach(({tool:f,manipulator:g},h)=>{f!==a||null!=b&&b!==g||(this._draggedManipulators.delete(h),g.dragging=!1,g.events.emit("drag",{action:"cancel"}))});d&&this._hoveredManipulators.forEach(({tool:f,manipulator:g},h)=>{f!==a||null!=b&&b!==g||(this._hoveredManipulators.delete(h),g.hovering=!1)});this._afterManipulatorRelease(c);this._onFocusChange(e)}updateHoveredStateFromKnownPointers(a){this._pointerLocations.forEach((e, c)=>{this._updateHoveredStateForPointerAtScreenPosition(y.createScreenPoint(e.x,e.y),c,e.pointerType,a)})}handleHoverEvent(a,e){"pointer-up"!==a.type&&"immediate-click"!==a.type&&"pointer-move"!==a.type||"mouse"!==a.pointerType||this._updateHoveredStateForPointerAtScreenPosition(k.createScreenPointFromEvent(a),a.pointerId,a.pointerType,e)}_updateHoveredStateForPointerAtScreenPosition(a,e,c,d){a=m(a,c,d);c=this._hoveredManipulators.get(e)?.manipulator;null==a||a.manipulator.interactive||(a=null);if(null== a||c!==a.manipulator)null!=c&&(c.hovering=!1),null!=a?(a.manipulator.hovering=!0,this._hoveredManipulators.set(e,a)):this._hoveredManipulators.delete(e),this._onFocusChange(d)}_afterManipulatorRelease(a){0===this._grabbedManipulators.size&&this._revertToNullActiveTool&&(a(null),this._revertToNullActiveTool=!1)}}q.ToolViewManagerManipulatorState=A;Object.defineProperty(q,Symbol.toStringTag,{value:"Module"})});