/*
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 i}from"tslib";import{destroyHandle as t}from"../../../core/handleUtils.js";import"../../../core/has.js";import e from"../../../core/Logger.js";import{mapCollection as s}from"../../../core/mapCollectionUtils.js";import{abortMaybe as o,destroyMaybe as n}from"../../../core/maybe.js";import{property as r,subclass as a}from"../../../core/accessorSupport/decorators.js";import{AnalysisView3D as l}from"./AnalysisView3D.js";import{DimensionController as p}from"./Dimension/DimensionController.js";import{DimensionTool as m}from"./Dimension/DimensionTool.js";import{DimensionVisualization as u}from"./Dimension/DimensionVisualization.js";import{LengthDimensionComputation as c}from"./Dimension/LengthDimensionComputation.js";import{applyProjectionAndElevationAlignment as d,logFailedGeometryProjectionError as h}from"./support/projectionUtils.js";import{connectAnalysisViewToTool as y,removeAnalysisViewTool as v,startPlaceOperation as g}from"../../analysis/analysisViewUtils.js";import{loadAutomaticLengthMeasurementUtils as D}from"../../support/automaticLengthMeasurementUtils.js";let _=class extends l{constructor(i){super(i),this.type="dimension-view-3d",this.analysis=null,this.tool=null,this.selectedDimension=null,this.userOperation=null,this._dimensionsToComputations=new Map,this._projectAndAlignPoint=null}initialize(){this._projectAndAlignPoint=i=>{if(null==i)return null;const{spatialReference:t,elevationProvider:s}=this.view,o=d(i,t,s);return null==o&&h(this.analysis,i.spatialReference,e.getLogger(this)),o};const i=s(()=>this.analysis.dimensions,i=>this._createComputation(i));this.computations=i,this.addHandles([y(this,m),t(i)]),this._analysisVisualization=new u({analysisViewData:this,view:this.view,isDecoration:!this.parent}),this.addResolvingPromise(D().then(i=>{this._analysisController=new p({analysisViewData:this,view:this.view,automaticLengthMeasurementUtils:i})}))}destroy(){this.userOperation=o(this.userOperation),v(this),this._analysisVisualization=n(this._analysisVisualization)}get visible(){return super.visible}set visible(i){super.visible=i}get interactive(){return super.interactive}set interactive(i){super.interactive=i}get updating(){return this._analysisVisualization?.loadingMessages??!1}get results(){return this.analysis.dimensions.map(i=>this._dimensionsToComputations.get(i).result)}get selectedComputation(){const{selectedDimension:i}=this;return null==i?null:this._dimensionsToComputations.get(i)}get testInfo(){}async createLengthDimensions(i){this.selectedDimension=null,await g(this,{placementOptions:i,onToolActivated:i=>i.place("multiple")})}place(i){return this.selectedDimension=null,g(this,{placementOptions:i,onToolActivated:i=>i.place("single")})}_createComputation(i){const{_dimensionsToComputations:t}=this,e=new c({dimension:i,projectAndAlignPoint:this._projectAndAlignPoint});return t.set(i,e),{computation:e,remove:()=>this._removeComputation(e)}}_removeComputation(i){const{dimension:t}=i;t===this.selectedDimension&&(this.selectedDimension=null),this._dimensionsToComputations.delete(t),i.destroy()}};i([r({readOnly:!0})],_.prototype,"type",void 0),i([r({constructOnly:!0,nonNullable:!0})],_.prototype,"analysis",void 0),i([r()],_.prototype,"tool",void 0),i([r()],_.prototype,"updating",null),i([r({readOnly:!0})],_.prototype,"results",null),i([r()],_.prototype,"computations",void 0),i([r()],_.prototype,"selectedDimension",void 0),i([r()],_.prototype,"selectedComputation",null),i([r()],_.prototype,"userOperation",void 0),i([r()],_.prototype,"_analysisVisualization",void 0),i([r()],_.prototype,"_analysisController",void 0),i([r()],_.prototype,"_dimensionsToComputations",void 0),_=i([a("esri.views.3d.analysis.DimensionAnalysisView3D")],_);const f=_;export{f as default};
