/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{__decorate as t}from"tslib";import"../../../../core/has.js";import{onAbort as e}from"../../../../core/promiseUtils.js";import{watch as o,syncAndInitial as i,on as s}from"../../../../core/reactiveUtils.js";import{property as a,subclass as r}from"../../../../core/accessorSupport/decorators.js";import{LineOfSightAuthoringStore as n}from"./LineOfSightAuthoringStore.js";import{LineOfSightPlacementTool as l}from"./LineOfSightPlacementTool.js";import{ExclusiveOperationManager as c}from"../../../analysis/ExclusiveOperationManager.js";import{AnalysisToolBase as p}from"../../../interactive/AnalysisToolBase.js";const h={ready:"ready",created:"created"};let m=class extends p{constructor(t){super(t),this._authoringStore=new n,this._operationManager=new c,this.analysisViewData=null,this.removeIncompleteOnCancel=!1,this._placementTool=new l({...t,authoringStore:this._authoringStore,parent:this})}get active(){return this._placementTool.active}get state(){return this._placementTool.active?this._placementTool.state:null!=this.analysis.observer?.position?h.created:h.ready}get cursor(){return this._placementTool.cursor}get updating(){return this._placementTool.updating}initialize(){this.view.tools.add(this._placementTool),this.addHandles(o(()=>this.editable,t=>{this.analysisViewData.editable=t},i))}destroy(){this._operationManager.destroy(),this._placementTool.stop(),this.view.tools.remove(this._placementTool),this._placementTool.destroy()}place(t){return this.analysisViewData.interactive=!0,this._operationManager.start("place",async(t,a)=>{const r=this.analysis.clone();let n=!1,l=!1;const c=()=>{l||(l=!0,this.stop(),a.aborted||!this.analysis.valid||this.analysis.equals(r)?t.reject():t.resolve({}))};t.handles.push(e(a,()=>this.stop()),s(()=>this._placementTool,"cancel",()=>c()),o(()=>this._placementTool.active,t=>{t?n=!0:n&&c()},i)),this.resetCreated(),this.continue()},t)}activate(){this.view.focus(),this.continue()}deactivate(){this.onDeactivate()}continue(){this._placementTool.continue()}stop(){this._placementTool.stop(),this.view.activeTool===this&&(this.view.activeTool=null)}resetCreated(){this._placementTool.resetCreated()}get testInfo(){}};t([a({constructOnly:!0})],m.prototype,"view",void 0),t([a({constructOnly:!0})],m.prototype,"analysis",void 0),t([a({constructOnly:!0})],m.prototype,"analysisViewData",void 0),t([a()],m.prototype,"active",null),t([a()],m.prototype,"state",null),t([a()],m.prototype,"cursor",null),t([a()],m.prototype,"updating",null),t([a()],m.prototype,"removeIncompleteOnCancel",void 0),m=t([r("esri.views.3d.analysis.LineOfSight.LineOfSightTool2")],m);export{m as LineOfSightTool2};
