import{_ as s,$ as m,cS as F,a0 as b,g,m as M,s as E,R,cA as V}from"./index.6c049565.js";import{a as I}from"./BitmapContainer.941a277e.js";import{y as $,u as q}from"./LayerView.7c2db9bf.js";import{v as U}from"./ExportStrategy.4fe2a8bd.js";import{i as W}from"./RefreshableLayerView.5868f703.js";import{l as L}from"./ExportWMSImageParameters.04ece485.js";import"./WGLContainer.bbd0fcb8.js";import"./enums.2d9e6f64.js";import"./pixelUtils.f4eba4af.js";import"./utils.eb2c3fd5.js";import"./Utils.e8554a0e.js";import"./enums.0295eb81.js";import"./Texture.8e8dfb11.js";import"./VertexElementDescriptor.1fdca6da.js";import"./MaterialKey.bbaab8f1.js";import"./VertexArrayObject.729879be.js";import"./ProgramTemplate.83fdf5b6.js";import"./StyleDefinition.d56936e4.js";import"./config.82550349.js";import"./GeometryUtils.51c4032a.js";import"./earcut.afc1d357.js";import"./Bitmap.5c9e2d15.js";const j=t=>{let e=class extends t{initialize(){this.exportImageParameters=new L({layer:this.layer})}destroy(){this.exportImageParameters.destroy(),this.exportImageParameters=null}get exportImageVersion(){var r;return(r=this.exportImageParameters)==null||r.commitProperty("version"),this.commitProperty("timeExtent"),(this._get("exportImageVersion")||0)+1}fetchPopupFeatures(r){const{layer:a}=this;if(!r)return Promise.reject(new g("wmslayerview:fetchPopupFeatures","Nothing to fetch without area",{layer:a}));const{popupEnabled:n}=a;if(!n)return Promise.reject(new g("wmslayerview:fetchPopupFeatures","popupEnabled should be true",{popupEnabled:n}));const u=this.createFetchPopupFeaturesQuery(r);if(!u)return Promise.resolve([]);const{extent:i,width:o,height:p,x:d,y:l}=u;if(!(i&&o&&p))throw new g("wmslayerview:fetchPopupFeatures","WMSLayer does not support fetching features.",{extent:i,width:o,height:p});return a.fetchFeatureInfo(i,o,p,d,l)}};return s([m()],e.prototype,"exportImageParameters",void 0),s([m({readOnly:!0})],e.prototype,"exportImageVersion",null),s([m()],e.prototype,"layer",void 0),s([m(F)],e.prototype,"timeExtent",void 0),e=s([b("esri.layers.mixins.WMSLayerView")],e),e};let h=class extends j(W($(q))){constructor(){super(...arguments),this.bitmapContainer=new I}supportsSpatialReference(t){return this.layer.serviceSupportsSpatialReference(t)}update(t){this.strategy.update(t).catch(e=>{M(e)||E.getLogger(this.declaredClass).error(e)})}attach(){const{layer:t}=this,{imageMaxHeight:e,imageMaxWidth:r}=t;this.bitmapContainer=new I,this.container.addChild(this.bitmapContainer),this.strategy=new U({container:this.bitmapContainer,fetchSource:this.fetchImage.bind(this),requestUpdate:this.requestUpdate.bind(this),imageMaxHeight:e,imageMaxWidth:r,imageRotationSupported:!1,imageNormalizationSupported:!1,hidpi:!1}),this.handles.add(R(()=>this.exportImageVersion,()=>this.requestUpdate()),"exportImageVersion")}detach(){this.handles.remove("exportImageVersion"),this.strategy.destroy(),this.strategy=null,this.container.removeAllChildren()}moveStart(){}viewChange(){}moveEnd(){this.requestUpdate()}createFetchPopupFeaturesQuery(t){const{view:e,bitmapContainer:r}=this,{x:a,y:n}=t,{spatialReference:u}=e;let i=null,o=0,p=0;if(r.children.some(C=>{const{width:x,height:f,resolution:w,x:c,y}=C,v=c+w*x,P=y-w*f;return a>=c&&a<=v&&n<=y&&n>=P&&(i=new V({xmin:c,ymin:P,xmax:v,ymax:y,spatialReference:u}),o=x,p=f,!0)}),!i)return null;const d=i.width/o,l=Math.round((a-i.xmin)/d),S=Math.round((i.ymax-n)/d);return{extent:i,width:o,height:p,x:l,y:S}}async doRefresh(){this.requestUpdate()}isUpdating(){return this.strategy.updating||this.updateRequested}fetchImage(t,e,r,a){return this.layer.fetchImageBitmap(t,e,r,{timeExtent:this.timeExtent,...a})}};s([m()],h.prototype,"strategy",void 0),s([m()],h.prototype,"updating",void 0),h=s([b("esri.views.2d.layers.WMSLayerView2D")],h);const se=h;export{se as default};