import{__decorate as e}from"tslib";import{InvalidOperationError as r}from"../InvalidOperationError.js";import{applyJsonToSublayer as t,jsonToSublayer as s,sublayerToJson as i}from"../json/SublayerJson.js";import{serializable as a}from"../support/Serializable.js";import{isWMSSublayer as n}from"../utilities/_layers.js";import{checkArg as o}from"../utilities/checkArg.js";import{caseInsensitiveEquals as l}from"../utilities/string.js";import{SublayerExtension as u,SubSublayerExtensionCollection as y}from"./_SublayerExtension.js";const f="SublayerExtension collection for WMSLayerExtension is readonly";let p=class extends u{wfsLayerInfo;get wfsFeatureType(){return this.wfsLayerInfo?.wfsCapabilities.featureTypes.find((e=>e.namespaceUri===this.wfsLayerInfo.namespaceUri&&e.name===this.wfsLayerInfo.name))}get sublayer(){return super.sublayer}get sublayerExtensions(){return super.sublayerExtensions}get layerExtension(){return super.layerExtension}get supportsSublayers(){return!0}get effectiveFullExtent(){return this.sublayer?this.sublayer.fullExtent:this.parentSublayerExtension?this.parentSublayerExtension.effectiveFullExtent:this.layerExtension?this.layerExtension.effectiveFullExtent:void 0}get hasFeatures(){return!0}get canChangeOpacity(){return!1}_initializeWfsPromise;async initializeWfs(){return void 0===this._initializeWfsPromise&&(this._initializeWfsPromise=(async()=>{if(!this.wfsLayerInfo&&this.layerExtension?.wfsUrl)try{await this.layerExtension.initializeWfs();const e=this.layerExtension.wfsCapabilities,t=this.sublayer.name.split(":"),s=t[2===t.length?1:0],i=e.featureTypes.find((e=>l(s,e.name)));if(!i)throw new r(`Could not find a matching WFS feature type for layer "${this.sublayer?.name??""}".`);this.wfsLayerInfo=await(await import("@arcgis/core/layers/ogc/wfsUtils.js")).getWFSLayerInfo(e,i.name)}catch(e){throw this._initializeWfsPromise=void 0,e}})()),this._initializeWfsPromise}_createSublayerExtension(e){return u.factory.create(e,"WMSSublayer")}_isSupportedSublayer(e){return n(e)}_createSublayer(e){return s({...e},"WMS")}async _applySublayerProperties(e,r){return t(e,r)}_serializeSublayer(e){return i(e)}_createSublayerExtensionCollection(){return new h(this)}};p=e([a],p);export{p as WMSSublayerExtension};class h extends y{add(e,t){if(o("sublayerX",e).isNotMissing(),e.sublayer&&this._parent.sublayer.sublayers&&!this._parent.sublayer.sublayers.includes(e.sublayer))throw new r(f);return super.add(e,t)}removeAt(e){throw new r(f)}reorder(e,t){throw new r(f)}}