/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{__decorate as e}from"tslib";import{createTask as t}from"../../../core/asyncUtils.js";import{throwIfAborted as r}from"../../../core/promiseUtils.js";import{whenOnce as i}from"../../../core/reactiveUtils.js";import{property as o,subclass as s}from"../../../core/accessorSupport/decorators.js";import n from"../../Widget.js";import{css as a}from"../css.js";import{loadArrowDependencies as c,Arrow as d}from"./Arrow.js";import{getRelativeAngleBetweenPoints as l,getPixelXYFromRelativeAngle as u}from"./imageNavigationUtils.js";import p from"./NavigationUIPanoramicViewModel.js";import{tsx as m}from"../../support/widget.js";let g=class extends n{constructor(e){super(e),this.directionMode="Relative",this.navigate=null,this.viewModel=new p,this._clickTask=null,this._handleClick=e=>{this._clickTask?.abort(),this._clickTask=t(async t=>{const o=e.target;if(!this.navigate||!this.currentNode)return;await i(()=>"compiled"===this.viewModel.state,{signal:t});const s=o.getAttribute("data-direction");r(t),await this.navigate(this.currentNode,{direction:s,signal:t})})}}loadDependencies(){return c()}set currentNode(e){this.viewModel.currentNode=e}get currentNode(){return this.viewModel.currentNode}set currentBestFeature(e){this.viewModel.currentBestFeature=e}get currentBestFeature(){return this.viewModel.currentBestFeature}get nodes(){return this.viewModel.nodes}set nodes(e){this.viewModel.nodes=e}render(){const{currentNode:e,currentBestFeature:t}=this;if(!e)return null;if(!t)return null;const{towards:r,backwards:i,left:o,right:s,currentHeading:n}=e;return m("div",{class:a.navigationUI},m("div",{class:a.navigationDirectionPad},[r,i,o,s].map((t,r)=>{if(!t)return null;const i=l(e.geometry.x,e.geometry.y,t.geometry.x,t.geometry.y)-n,{x:o,y:s}=u(i);return m(d,{class:a.navigationDirection,"data-direction":e.getDirectionTo(t),icon:"chevron-up",key:r,onclick:this._handleClick,rotateZ:i,x:o,y:s})})))}};e([o()],g.prototype,"currentNode",null),e([o()],g.prototype,"directionMode",void 0),e([o()],g.prototype,"currentBestFeature",null),e([o()],g.prototype,"navigate",void 0),e([o({nonNullable:!0})],g.prototype,"nodes",null),e([o()],g.prototype,"viewModel",void 0),e([o()],g.prototype,"_clickTask",void 0),g=e([s("esri.widgets.OrientedImageryViewer.components.NavigationUI360")],g);const v=g;export{v as default};
