/*
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 t}from"tslib";import e from"../../analysis/DirectLineMeasurementAnalysis.js";import{deprecateUnnecessaryViewModel as i}from"../../core/deprecate.js";import s from"../../core/Logger.js";import{watch as n,syncAndInitial as r}from"../../core/reactiveUtils.js";import{measurementLengthUnits 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(t){super(t),this.analysis=null,this._userUnitOptions=null,this._userUnit=null,this.supportedViewType="3d",this.unsupportedErrorMessage="DirectLineMeasurement3DViewModel is only supported in 3D views.",t?.isDefaultViewModel||i(s.getLogger(this),"Direct Line Measurement 3D","arcgis-direct-line-measurement-3d",{version:"4.33"})}initialize(){this.addHandles(n(()=>({analysis:this.analysis,unit:this.unit}),({analysis:t,unit:e})=>{null!=t&&(t.unit=e)},r))}get state(){return this.disabled||!this.ready?"disabled":null==this.tool?"ready":this.tool.state}get measurement(){const{tool:t}=this;if(null==t)return null;const e=()=>({text:null,state:"unavailable"}),i=t=>({text:t,state:"available"}),{analysisViewData:s}=t,n=null!=s.result;return{mode:s.result?.mode??"euclidean",directDistance:n&&"euclidean"===s.actualVisualizedMeasurement?i(s.directLabelText):e(),horizontalDistance:n?i(s.horizontalLabelText):e(),verticalDistance:n?i(s.verticalLabelText):e()}}get unitOptions(){const t=this._userUnitOptions?.filter(t=>o.includes(t));return t&&t.length>0?t:o.slice()}set unitOptions(t){this._userUnitOptions=t}get unit(){const t=this._userUnit,e=this.unitOptions;if(t&&e.includes(t))return t;const i=this.defaultUnit;return i&&e.includes(i)?i:e[0]}set unit(t){this._userUnit=t}constructAnalysis(){return new e}};t([l({type:e})],d.prototype,"analysis",void 0),t([l({readOnly:!0})],d.prototype,"state",null),t([l({readOnly:!0})],d.prototype,"measurement",null),t([l()],d.prototype,"unitOptions",null),t([l()],d.prototype,"_userUnitOptions",void 0),t([l()],d.prototype,"unit",null),t([l()],d.prototype,"_userUnit",void 0),t([l(u)],d.prototype,"defaultUnit",void 0),d=t([a("esri.widgets.DirectLineMeasurement3D.DirectLineMeasurement3DViewModel")],d);const c=d;export{c as default};
