/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{__decorate as e}from"tslib";import t from"../../analysis/AreaMeasurementAnalysis.js";import s from"../../core/Accessor.js";import{deprecateUnnecessaryViewModel as i}from"../../core/deprecate.js";import r from"../../core/Logger.js";import{watch as n,syncAndInitial as o}from"../../core/reactiveUtils.js";import{measurementAreaUnits as l}from"../../core/units.js";import{property as a,subclass as u}from"../../core/accessorSupport/decorators.js";import{defaultUnitPropertyMetadata as p}from"../../properties/defaultUnit.js";import{AnalysisViewModelMixin as d}from"../support/AnalysisViewModelMixin.js";let m=class extends(d(s)){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?.suppressDeprecationWarning||i(r.getLogger(this),"Area Measurement 3D","arcgis-area-measurement-3d",{version:"4.33"})}initialize(){this.addHandles(n(()=>({analysis:this.analysis,unit:this.unit}),({analysis:e,unit:t})=>{null!=e&&(e.unit=t)},o))}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,perimeterLabel:i}=e,r=t.validMeasurement,n=r?"available":"unavailable";return{mode:null==t.mode||"euclidean"===t.mode?"euclidean":"geodesic",area:{text:r?s:null,state:n},perimeterLength:{text:r?i:null,state:n}}}get unitOptions(){const e=this._userUnitOptions?.filter(e=>l.includes(e));return e&&e.length>0?e:l.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([a({type:t})],m.prototype,"analysis",void 0),e([a({readOnly:!0})],m.prototype,"state",null),e([a({readOnly:!0})],m.prototype,"measurement",null),e([a()],m.prototype,"unitOptions",null),e([a()],m.prototype,"_userUnitOptions",void 0),e([a()],m.prototype,"unit",null),e([a()],m.prototype,"_userUnit",void 0),e([a(p)],m.prototype,"defaultUnit",void 0),m=e([u("esri.widgets.AreaMeasurement3D.AreaMeasurement3DViewModel")],m);const c=m;export{c as default};
