/*
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 t from"../../analysis/AreaMeasurementAnalysis.js";import{deprecateUnnecessaryViewModel as s}from"../../core/deprecate.js";import i from"../../core/Logger.js";import{watch as r,syncAndInitial as n}from"../../core/reactiveUtils.js";import{measurementAreaUnits as o}from"../../core/units.js";import{property as l,subclass as a}from"../../core/accessorSupport/decorators.js";import{defaultUnitPropertyMetadata as u}from"../../properties/defaultUnit.js";import p from"../support/AnalysisViewModel.js";let d=class extends p{constructor(e){super(e),this.analysis=null,this._userUnitOptions=null,this._userUnit=null,this.supportedViewType="3d",this.unsupportedErrorMessage="AreaMeasurement3DViewModel is only supported in 3D views.",e?.isDefaultViewModel||s(i.getLogger(this),"Area Measurement 3D","arcgis-area-measurement-3d",{version:"4.33"})}initialize(){this.addHandles(r(()=>({analysis:this.analysis,unit:this.unit}),({analysis:e,unit:t})=>{null!=e&&(e.unit=t)},n))}get state(){return this.disabled||!this.ready?"disabled":null==this.tool?"ready":this.tool.state}get measurement(){if(null==this.tool||this.disabled||this.tool.destroyed)return null;const{analysisView:e}=this;if(null==e)return null;const{viewData:t,areaLabel:s,perimeterLengthLabel:i}=e,r=t.validMeasurement,n="euclidean"===t.mode,o=0===t.intersectingSegments.size,l=o?r?"available":"unavailable":"invalid";return{mode:n?"euclidean":"geodesic",area:{text:o&&r?s:null,state:l},perimeterLength:{text:o&&r?i:null,state:l}}}get unitOptions(){const e=this._userUnitOptions?.filter(e=>o.includes(e));return e&&e.length>0?e:o.slice()}set unitOptions(e){this._userUnitOptions=e}get unit(){const e=this._userUnit,t=this.unitOptions;if(e&&t.includes(e))return e;const s=this.defaultUnit;return s&&t.includes(s)?s:t[0]}set unit(e){this._userUnit=e}constructAnalysis(){return new t}};e([l({type:t})],d.prototype,"analysis",void 0),e([l({readOnly:!0})],d.prototype,"state",null),e([l({readOnly:!0})],d.prototype,"measurement",null),e([l()],d.prototype,"unitOptions",null),e([l()],d.prototype,"_userUnitOptions",void 0),e([l()],d.prototype,"unit",null),e([l()],d.prototype,"_userUnit",void 0),e([l(u)],d.prototype,"defaultUnit",void 0),d=e([a("esri.widgets.AreaMeasurement3D.AreaMeasurement3DViewModel")],d);const m=d;export{m as default};
