/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{__decorate as t}from"tslib";import e from"../../Graphic.js";import r from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import{property as a,subclass as s}from"../../core/accessorSupport/decorators.js";import{isFunctionRaster as n}from"../../layers/raster/datasets/datasetUtils.js";import{getDefaultDatumTransformationForDataset as l,projectDatasetExtent as o,getSourceScale as u}from"../../layers/raster/functions/rasterProjectionHelper.js";import{addMultidimensionalFieldValues as c,commonRasterFieldNames as p,rasterFieldPrefix as m}from"../../layers/support/rasterFieldUtils.js";import{combineTimeExtent as y}from"../../layers/support/timeSupport.js";import{getFetchPopupTemplate as f}from"./support/popupUtils.js";const h=h=>{const d=h;let g=class extends d{constructor(...t){super(...t),this.layer=null,this.tileInfo=null}get fullExtent(){try{return this.layer.loaded?this._getFullExtent():null}catch{return null}}get timeExtent(){return y(this.layer,this.view?.timeExtent,this._get("timeExtent"))}get hasTilingEffects(){const{renderer:t}=this.layer;return!!("raster-stretch"===t?.type&&t.dynamicRangeAdjustment&&!("min-max"===t.stretchType||"standard-deviation"===t.stretchType))}get datumTransformation(){try{return this.layer.loaded?l(this.layer.fullExtent,this.view.spatialReference,!0):null}catch{return null}}supportsSpatialReference(t){try{return!this.layer.loaded||!!o(this.layer.serviceRasterInfo,t)}catch{return!1}}async fetchPopupFeaturesAtLocation(t,i){const{layer:a}=this;if(!t)throw new r("imageryTileLayerView:fetchPopupFeatures","Nothing to fetch without area",{layer:a});const{popupEnabled:s}=a,l=f(a,i);if(!s||null==l)return[];const o=[],{value:u,magdirValue:y,processedValue:h}=await a.identify(t,{timeExtent:this.timeExtent,signal:i?.signal});let d="";if(u?.length){d="imagery-tile"===a.type&&a.hasStandardTime()&&null!=u[0]?u.map(t=>a.getStandardTimeValue(t)).join(", "):u.join(", ");const t={ObjectId:0};t[p.servicePixelValue]="imagery-tile"===a.type&&n(a.raster)?h?.join(", "):d,t[p.rawServicePixelValue]=d;const r=a.raster?.rasterInfo??a.serviceRasterInfo,i=r?.attributeTable;if(null!=i){const{fields:e,features:r}=i,a=e.find(({name:t})=>"value"===t.toLowerCase()),s=t[p.servicePixelValue],n=a?r.find(t=>String(t.attributes[a.name])===s):null;if(n)for(const i in n.attributes)if(n.attributes.hasOwnProperty(i)){t[m+i]=n.attributes[i]}}const s=r?.dataType;"vector-magdir"!==s&&"vector-uv"!==s||(t[p.magnitude]=y?.[0],t[p.direction]=y?.[1]);const{multidimensionalDefinition:l}=this.layer.normalizeRasterFetchOptions({timeExtent:this.timeExtent});c(a.rasterFields,t,l);const{graphicOrigin:f}=a,g=new e({geometry:this.fullExtent?.clone(),attributes:t,layer:a,origin:f,sourceLayer:a});o.push(g)}return o}highlight(t,e){return i()}async getSourceScale(){return await this.layer.load(),u(this.layer.serviceRasterInfo,this.view.spatialReference)}_getFullExtent(){return o(this.layer.serviceRasterInfo,this.view.spatialReference)}};return t([a()],g.prototype,"fullExtent",null),t([a()],g.prototype,"layer",void 0),t([a({readOnly:!0})],g.prototype,"timeExtent",null),t([a()],g.prototype,"tileInfo",void 0),t([a({readOnly:!0})],g.prototype,"hasTilingEffects",null),t([a()],g.prototype,"datumTransformation",null),g=t([s("esri.views.layers.ImageryTileLayerViewMixin")],g),g};export{h as ImageryTileLayerViewMixin};
