/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../../chunks/_rollupPluginBabelHelpers","../../chunks/tslib.es6","../../core/Evented","../../core/Logger","../../core/maybe","../../core/accessorSupport/decorators/property","../../core/arrayUtils","../../core/has","../../core/accessorSupport/ensureType","../../core/accessorSupport/decorators/subclass","../../geometry/support/aaBoundingRect","../../geometry/support/contains","../../layers/support/ElevationSampler","../3d/terrain/TerrainConst"],(function(e,t,r,n,o,a,i,s,p,l,c,u,d,v){"use strict";const y=n.getLogger("esri.views.support.GroundViewElevationSampler");let m=function(t){function r(e){var r;return(r=t.call(this,e)||this).demResolution={min:-1,max:-1},r.noDataValue=v.ELEVATION_NODATA_VALUE,r}e._inheritsLoose(r,t);var n=r.prototype;return n.initialize=function(){this.view.basemapTerrain.on("elevation-change",(()=>this.emit("changed",{})))},n.elevationAt=function(e,t){if(o.isNone(this.extent)||!u.extentContainsXYZ(this.extent,e,t)){const r=o.isSome(this.extent)?`${this.extent.xmin}, ${this.extent.ymin}, ${this.extent.xmax}, ${this.extent.ymax}`:null;return y.warn("#elevationAt()",`Point used to sample elevation (${e}, ${t}) is outside of the sampler extent (${r})`),this.noDataValue}return o.unwrapOr(this.view.elevationProvider.getElevation(e,t,0,this.spatialReference,"ground"),this.noDataValue)},n.queryElevation=function(e){return d.updateGeometryElevation(e.clone(),this)},e._createClass(r,[{key:"extent",get:function(){const e=this.view.basemapTerrain;if(o.isNone(e.extent)||!e.spatialReference)return null;const t=c.toExtent(e.extent,e.spatialReference);return t.zmin=e.elevationBounds.min,t.zmax=e.elevationBounds.max,t}}]),r}(r.EventedAccessor);t.__decorate([a.property({readOnly:!0})],m.prototype,"demResolution",void 0),t.__decorate([a.property({readOnly:!0})],m.prototype,"extent",null),t.__decorate([a.property({readOnly:!0})],m.prototype,"noDataValue",void 0),t.__decorate([a.property({readOnly:!0,aliasOf:"view.basemapTerrain.spatialReference"})],m.prototype,"spatialReference",void 0),t.__decorate([a.property({constructOnly:!0})],m.prototype,"view",void 0),m=t.__decorate([l.subclass("esri.views.support.GroundViewElevationSampler")],m);return m}));
