/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{__decorate as i}from"tslib";import{destroyHandle as t}from"../../../core/handleUtils.js";import"../../../core/has.js";import s from"../../../core/Logger.js";import{mapCollection as e}from"../../../core/mapCollectionUtils.js";import{abortMaybe as o,destroyMaybe as n}from"../../../core/maybe.js";import{property as r,subclass as l}from"../../../core/accessorSupport/decorators.js";import a 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";let D=class extends a{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:e}=this.view,o=d(i,t,e);return null==o&&h(this.analysis,i.spatialReference,s.getLogger(this)),o};const i=e(()=>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._analysisController=new p({analysisViewData:this,view:this.view})}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._analysisController?.updating||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,s=new c({dimension:i,projectAndAlignPoint:this._projectAndAlignPoint});return t.set(i,s),{computation:s,remove:()=>this._removeComputation(s)}}_removeComputation(i){const{dimension:t}=i;t===this.selectedDimension&&(this.selectedDimension=null),this._dimensionsToComputations.delete(t),i.destroy()}};i([r({readOnly:!0})],D.prototype,"type",void 0),i([r({constructOnly:!0,nonNullable:!0})],D.prototype,"analysis",void 0),i([r()],D.prototype,"tool",void 0),i([r()],D.prototype,"updating",null),i([r({readOnly:!0})],D.prototype,"results",null),i([r()],D.prototype,"computations",void 0),i([r()],D.prototype,"selectedDimension",void 0),i([r()],D.prototype,"selectedComputation",null),i([r()],D.prototype,"userOperation",void 0),i([r()],D.prototype,"_analysisVisualization",void 0),i([r()],D.prototype,"_analysisController",void 0),i([r()],D.prototype,"_dimensionsToComputations",void 0),D=i([l("esri.views.3d.analysis.DimensionAnalysisView3D")],D);const _=D;export{_ as default};
