/*
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{property as e,subclass as s}from"../../../../core/accessorSupport/decorators.js";import r from"../../../../geometry/Point.js";import{estimateStatisticsFromHistograms as a}from"../../../../layers/raster/functions/stretchUtils.js";import i from"../../../../rest/support/ImageHistogramParameters.js";import o from"./RasterLayerAdapter.js";let n=class extends o{generateRasterInfo(t){const e=t?.rasterFunction;try{return this.layer.generateRasterInfo(e,{signal:t?.signal})}catch{return Promise.resolve(this.layer.serviceRasterInfo)}}async estimateStatisticsHistograms(t){const{layer:e}=this,s=e.mosaicRule?.multidimensionalDefinition?.[0]?.variableName??"",o=`${t?.rasterFunction?.functionName??"default"}${s}`,n=this._statsCache.get(o);if(n)return n;let{width:l,height:c,pixelSize:m}=e.rasterInfo,p=1;for(;l>2e3||c>2e3;)l/=2,c/=2,p*=2;const u=t?.rasterFunction??e.rasterFunction,{fullExtent:g,mosaicRule:h}=e;m=new r(m.x*p,m.y*p,g.spatialReference);const f=new i({geometry:g,pixelSize:m,renderingRule:u,mosaicRule:h});let d;if(e.capabilities.operations.supportsComputeStatisticsHistograms)d=await e.computeStatisticsHistograms(f,t);else{const{histograms:s}=await e.computeHistograms(f,t);d={statistics:a(s),histograms:s}}return d&&this._statsCache.put(o,d),d}supportsMultidirectionalHillshade(){return this.layer.version>=10.81}load(t){return this.addResolvingPromise(this.layer.load(t).then(async()=>{const e=t?.signal;this.rasterInfo=await this.generateRasterInfo({rasterFunction:this.rasterFunction,signal:e})})),Promise.resolve(this)}};t([e()],n.prototype,"layer",void 0),n=t([s("esri.smartMapping.raster.support.adapters.ImageryLayerAdapter")],n);const l=n;export{l as default};
