/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{__decorate as t}from"tslib";import r from"../../../core/Accessor.js";import"../../../core/has.js";import{destroyMaybe as e}from"../../../core/maybe.js";import{watch as o,initial as i,syncAndInitial as n}from"../../../core/reactiveUtils.js";import{property as a,subclass as s}from"../../../core/accessorSupport/decorators.js";import{DoubleClickZoom as d}from"./handlers/DoubleClickZoom.js";import{DragRotate as m}from"./handlers/DragRotate.js";import{DragZoom as p}from"./handlers/DragZoom.js";import{GamepadNavigation as g}from"./handlers/GamepadNavigation.js";import{KeyboardNavigation as c}from"./handlers/KeyboardNavigation.js";import{MouseWheelZoom as u}from"./handlers/MouseWheelZoom.js";import{PinchAndPanNavigation as l}from"./handlers/PinchAndPanNavigation.js";import{PointerDownCancelAnimation as h}from"./handlers/PointerDownCancelAnimation.js";import{TwoFingerTilt as w}from"./handlers/TwoFingerTilt.js";import{BrowserEventSource as f}from"../../input/BrowserEventSource.js";import{InputManager as v,ViewEventPriorities as y}from"../../input/InputManager.js";import{PreventContextMenu as _}from"../../input/handlers/PreventContextMenu.js";import{getPointerActions as D}from"../../input/handlers/support.js";import{Drag as P}from"../../input/recognizers/Drag.js";import{ImmediateDoubleClick as j}from"../../input/recognizers/ImmediateDoubleClick.js";import{PointerClickHoldAndDrag as A}from"../../input/recognizers/PointerClickHoldAndDrag.js";import{SingleAndDoubleClick as M}from"../../input/recognizers/SingleAndDoubleClick.js";import{VerticalTwoFingerDrag as b}from"../../input/recognizers/VerticalTwoFingerDrag.js";let T=class extends r{constructor(){super(...arguments),this.mode="default",this._updateMode=({mode:t,dragPrimary:r,dragSecondary:e,dragTertiary:o})=>{"pro"===t&&(e="zoom",o="pan"===r?"rotate":"pan");const i={dragPrimary:r,dragSecondary:e,dragTertiary:o};this._modeDragPan&&(this._modeDragPan.pointerActions=D("pan",i)),this._modeDragRotate&&(this._modeDragRotate.pointerActions=D("rotate",i)),this._modeDragZoom&&(this._modeDragZoom.pointerActions=D("zoom",i))}}destroy(){this.disconnect()}get primaryDragAction(){return this.view.navigation.actionMap.dragPrimary}set primaryDragAction(t){const{actionMap:r}=this.view.navigation;r.dragPrimary=t,r.dragSecondary="pan"===t?"rotate":"pan"}get updating(){return!!this._inputManager?.updating}get latestPointerInfo(){return this._inputManager?.latestPointerInfo}get latestPenInfo(){return this._inputManager?.latestPenInfo}get multiTouchActive(){return this._inputManager?.multiTouchActive??!1}disconnect(){this.removeAllHandles(),this.view.viewEvents.disconnect(),this._modeDragPan=null,this._modeDragRotate=null,this._modeDragZoom=null,this._modeKeyboardNavigation=null,this._inputManager=e(this._inputManager),this._source=e(this._source)}connect(){const t=this.view;this._source=new f(this.view.surface,t.input);const r=[new j,new A,new M,new P(this.view.navigation),new b],e=new v({eventSource:this._source,recognizers:r});this._inputManager=e,e.installHandlers("prevent-context-menu",[new _],y.INTERNAL);const a={fov:"Shift",pan:{left:"ArrowLeft",right:"ArrowRight",forward:"ArrowUp",backward:"ArrowDown",up:["u","U"],down:["j","J"]},lookAround:{headingLeft:["a","A"],headingRight:["d","D"],tiltUp:["w","W"],tiltDown:["s","S"]},modifier:["b","B"],zoom:{zoomIn:["+","="],zoomOut:["-","_"]},reset:{heading:["n","N"],tilt:["p","P"]}};this._modeDragPan=new l(t,["primary"]),this._modeDragRotate=new m(t,["secondary"],0),this._modeDragZoom=new p(t,["tertiary"],a.fov),this._modeKeyboardNavigation=new c(t,a),e.installHandlers("navigation",[new h(t),new d(t),new g(t),new u(t,a.fov),new m(t,["primary"],1,a.modifier),new l(t,["secondary"],a.modifier,!0),new l(t,["tertiary"],a.modifier),this._modeDragRotate,this._modeDragZoom,this._modeDragPan,this._modeKeyboardNavigation,new w(t)],y.INTERNAL),this.view.viewEvents.connect(e),this.addHandles([o(()=>this.view.navigation?.browserTouchPanEnabled,t=>{this._source.browserTouchPanningEnabled=!t},i),o(()=>{const{actionMap:t}=this.view.navigation,{dragPrimary:r,dragSecondary:e,dragTertiary:o}=t;return{mode:this.mode,dragPrimary:r,dragSecondary:e,dragTertiary:o}},this._updateMode,n)])}isModifierKeyDown(t){return this._inputManager?.isModifierKeyDown(t)??!1}get test(){}};t([a()],T.prototype,"view",void 0),t([a({type:["default","pro"]})],T.prototype,"mode",void 0),t([a({readOnly:!0})],T.prototype,"updating",null),t([a()],T.prototype,"latestPointerInfo",null),t([a()],T.prototype,"latestPenInfo",null),t([a()],T.prototype,"multiTouchActive",null),t([a()],T.prototype,"_inputManager",void 0),T=t([s("esri.views.3d.input.SceneInputManager")],T);const I=T;export{I as default};
