/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
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";let g=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;return!(!t||t.rings.length<1)&&t.rings.every(t=>{const e=3+(t.length>0&&n(t[0],t[t.length-1])?1:0);return t.length>=e})}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"]})],g.prototype,"type",void 0),t([y({type:["cut-fill","stockpile"],nonNullable:!0})],g.prototype,"measureType",void 0),t([y({type:h,value:null})],g.prototype,"geometry",null),t([y({type:i,nonNullable:!0})],g.prototype,"cutFillOptions",void 0),t([y({type:o,nonNullable:!0})],g.prototype,"displayUnits",void 0),t([y({type:r,nonNullable:!0})],g.prototype,"inputUnits",void 0),t([y({readOnly:!0})],g.prototype,"valid",null),g=t([c("esri.analysis.VolumeMeasurementAnalysis")],g);const v=g;export{v as default};
