/*
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.js";import{volumeMeasurementConfiguration as s}from"./VolumeMeasurement/volumeMeasurementConfiguration.js";import i from"./VolumeMeasurement/VolumeMeasurementCutFillOptions.js";import o from"./VolumeMeasurement/VolumeMeasurementDisplayUnits.js";import r from"./VolumeMeasurement/VolumeMeasurementInputUnits.js";import{equals as n}from"../core/arrayUtils.js";import{clamp as l}from"../core/mathUtils.js";import{equalsMaybe as a}from"../core/maybe.js";import{watch as m,syncAndInitial as u}from"../core/reactiveUtils.js";import{convertUnit as p}from"../core/units.js";import{property as y,subclass as c}from"../core/accessorSupport/decorators.js";import h from"../geometry/Polygon.js";import{i as g}from"../chunks/simplifyOperator.js";let f=class extends e{constructor(t){super(t),this.type="volume-measurement",this.measureType="cut-fill",this.cutFillOptions=new i,this.displayUnits=new o,this.inputUnits=new r,this._constrainTargetElevation=t=>{if(this.cutFillOptions.constrainTargetElevation!==this._constrainTargetElevation)return t;const e=p(t,this.inputUnits.elevation??"meters","meters"),{minTargetElevation:i,maxTargetElevation:o}=s;if(e<i||e>o){const t=l(e,i,o);return p(t,"meters",this.inputUnits.elevation??"meters")}return t}}initialize(){this.addHandles(m(()=>this.cutFillOptions,t=>t.constrainTargetElevation=this._constrainTargetElevation,u))}set geometry(t){null!=t?this._set("geometry",t.clone()):this._set("geometry",null)}get valid(){const{geometry:t}=this;if(1!==t?.rings.length)return!1;const e=t.rings[0],s=3+(e.length>0&&n(e[0],e[e.length-1])?1:0);if(e.length<s)return!1;if(!t.isClockwise(e)){const e=t.clone();return e.rings[0].reverse(),g(e)}return g(t)}clear(){this.geometry=null}equals(t){return this===t||super.equals(t)&&this.measureType===t.measureType&&a(this.geometry,t.geometry)&&this.displayUnits.equals(t.displayUnits)&&this.inputUnits.equals(t.inputUnits)&&this.cutFillOptions.equals(t.cutFillOptions)}};t([y({type:["volume-measurement"]})],f.prototype,"type",void 0),t([y({type:["cut-fill","stockpile"],nonNullable:!0})],f.prototype,"measureType",void 0),t([y({type:h,value:null})],f.prototype,"geometry",null),t([y({type:i,nonNullable:!0})],f.prototype,"cutFillOptions",void 0),t([y({type:o,nonNullable:!0})],f.prototype,"displayUnits",void 0),t([y({type:r,nonNullable:!0})],f.prototype,"inputUnits",void 0),t([y({readOnly:!0})],f.prototype,"valid",null),f=t([c("esri.analysis.VolumeMeasurementAnalysis")],f);const v=f;export{v as default};
