/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../../../chunks/_rollupPluginBabelHelpers","../../../chunks/tslib.es6","../../../core/Accessor","../../../core/Collection","../../../core/maybe","../../../core/reactiveUtils","../../../core/accessorSupport/decorators/property","../../../core/arrayUtils","../../../core/has","../../../core/accessorSupport/ensureType","../../../core/accessorSupport/decorators/subclass","./AnalysisView3D","./Dimensioning/DimensioningTool","./Dimensioning/DimensioningVisualization","./Dimensioning/LengthDimensionComputation","../../analysis/analysisViewUtils"],(function(e,i,o,s,n,t,a,r,l,c,p,u,m,y,d,_){"use strict";let h=function(i){function o(e){var o;return(o=i.call(this,e)||this).type="dimensioning-view-3d",o.tool=null,o._computations=new s,o._dimensionsToResults=new Map,o._placementTask=null,o}e._inheritsLoose(o,i);var a=o.prototype;return a.initialize=function(){this.own([_.connectAnalysisViewToTool(this,m.DimensioningTool),t.on((()=>this.analysis.dimensions),"change",(({added:e,removed:i})=>{for(const o of i)this._removeDimension(o);for(const o of e)this._addDimension(o)}),{onListenerAdd:e=>{for(const i of e)this._addDimension(i)},onListenerRemove:e=>{for(const i of e)this._removeDimension(i)}})]),this._analysisVisualization=new y.DimensioningVisualization({view:this.view,computations:this._computations})},a.destroy=function(){this._placementTask=n.abortMaybe(this._placementTask),this._analysisVisualization=n.destroyMaybe(this._analysisVisualization),this._computations.drain((e=>e.destroy())),_.removeAnalysisViewTool(this)},a.createLengthDimensions=function(){var i=e._asyncToGenerator((function*(e){return this._placementTask=n.abortMaybe(this._placementTask),this._placementTask=_.activateTemporaryAnalysisViewTool(this,m.DimensioningTool,e),this._placementTask.promise}));function o(e){return i.apply(this,arguments)}return o}(),a._addDimension=function(e){const i=this._dimensionsToResults;if(i.has(e))return;const o=this._computations,s=new d.LengthDimensionComputation({dimension:e});o.add(s),i.set(e,s.result)},a._removeDimension=function(e){const i=this._computations,o=this._dimensionsToResults,s=i.findIndex((i=>i.dimension===e)),t=i.removeAt(s);o.delete(e),n.destroyMaybe(t)},e._createClass(o,[{key:"results",get:function(){return this.analysis.dimensions.map((e=>this._dimensionsToResults.get(e)))}},{key:"testInfo",get:function(){return{visualization:this._analysisVisualization}}}]),o}(u.AnalysisView3D(o));i.__decorate([a.property({readOnly:!0})],h.prototype,"type",void 0),i.__decorate([a.property({constructOnly:!0,nonNullable:!0})],h.prototype,"analysis",void 0),i.__decorate([a.property()],h.prototype,"tool",void 0),i.__decorate([a.property({readOnly:!0})],h.prototype,"results",null),i.__decorate([a.property()],h.prototype,"_analysisVisualization",void 0),i.__decorate([a.property()],h.prototype,"_computations",void 0),i.__decorate([a.property()],h.prototype,"_dimensionsToResults",void 0),i.__decorate([a.property()],h.prototype,"_placementTask",void 0),h=i.__decorate([p.subclass("esri.views.3d.analysis.DimensioningAnalysisView3D")],h);return h}));
