/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{__decorate as e}from"tslib";import o from"../../Color.js";import{handlesGroup as r}from"../../core/handleUtils.js";import{memoize as t}from"../../core/memoize.js";import{watch as n}from"../../core/reactiveUtils.js";import{getMetersPerVerticalUnitForSR as i}from"../../core/units.js";import{property as s,subclass as l}from"../../core/accessorSupport/decorators.js";import a from"./ElevationProfileLine.js";import{getGroundMinDemResolution as u}from"./support/elevationQuerySourceUtils.js";let p=class extends a{constructor(e){super(e),this.type="ground",this.color=new o("#ff7f00"),this.viewVisualizationEnabled=!0,this.numSamplesForPreview=50,this.numSamplesPerChunk=1e3,this._getQueryElevationDependencies=t((e,o)=>({ground:e,groundLayers:o}))}get available(){const e=this._ground;return null!=e&&e.layers.some(e=>e.visible)}get minDemResolution(){return u(this._ground)}get _queryElevationDependencies(){return this._getQueryElevationDependencies(this._ground,this._groundLayers)}get _ground(){return this._viewModel?.view?.map?.ground}get _groundLayers(){return this._ground?.layers?.toArray()??[]}async queryElevation(e,o){const r=this._queryElevationDependencies;if(null==r)throw new Error("ElevationProfileLineGround: no dependencies");const{ground:t}=r;if(null==t)throw new Error("No ground configured in the view");const n=await t.queryElevation(e,o),s=i(e.spatialReference),l=i(t.layers.at(0).spatialReference);if(s!==l){const e=n.geometry;e.points=e.points.map(([e,r,t])=>[e,r,t===o.noDataValue?t:t*l/s])}return n}attach(e){return r([super.attach(e),n(()=>this._queryElevationDependencies,()=>this._onChange())])}};e([s({type:o,nonNullable:!0})],p.prototype,"color",void 0),e([s()],p.prototype,"viewVisualizationEnabled",void 0),e([s()],p.prototype,"available",null),e([s({readOnly:!0})],p.prototype,"minDemResolution",null),e([s()],p.prototype,"_queryElevationDependencies",null),e([s()],p.prototype,"_ground",null),e([s()],p.prototype,"_groundLayers",null),p=e([l("esri.widgets.ElevationProfile.ElevationProfileLineGround")],p);const d=p;export{d as default};
