/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{destroyMaybe as r}from"../../core/maybe.js";import{throwIfAborted as o}from"../../core/promiseUtils.js";import{property as s,subclass as i}from"../../core/accessorSupport/decorators.js";import{ExportWMSImageParameters as p}from"../../layers/support/ExportWMSImageParameters.js";import{combineTimeExtent as a}from"../../layers/support/timeSupport.js";const m=m=>{const n=m;let h=class extends n{initialize(){this.exportImageParameters=new p({layer:this.layer})}destroy(){this.exportImageParameters=r(this.exportImageParameters)}get exportImageVersion(){return this.exportImageParameters?.commitProperty("version"),this.commitProperty("timeExtent"),(this._get("exportImageVersion")||0)+1}get timeExtent(){return a(this.layer,this.view?.timeExtent,this._get("timeExtent"))}async fetchPopupFeaturesAtTarget(e,r,s){const{layer:i}=this;if(!r)throw new t("wmslayerview:fetchPopupFeatures","Nothing to fetch without geometry",{layer:i});const{popupEnabled:p}=i;if(!p)throw new t("wmslayerview:fetchPopupFeatures","popupEnabled should be true",{popupEnabled:p});const a=this.createFetchPopupFeaturesQuery("point"===r.type?r:r.extent?.center);if(!a)return[];const{extent:m,width:n,height:h,x:u,y}=a;if(!(m&&n&&h))throw new t("wmslayerview:fetchPopupFeatures","WMSLayer does not support fetching features.",{extent:m,width:n,height:h});const c=await i.fetchFeatureInfo(m,n,h,u,y);return o(s),c}};return e([s()],h.prototype,"exportImageParameters",void 0),e([s({readOnly:!0})],h.prototype,"exportImageVersion",null),e([s()],h.prototype,"layer",void 0),e([s({readOnly:!0})],h.prototype,"timeExtent",null),h=e([i("esri.views.layers.WMSLayerView")],h),h};export{m as WMSLayerView};
