import{__decorate as e}from"tslib";import{layerToJson as t}from"../json/LayerJson.js";import{serializable as r}from"../support/Serializable.js";import{notifyChange as i,watch as a}from"../support/observableUtils.js";import{ReadOnlyCollection as s}from"../utilities/ReadOnlyCollection.js";import{isWFSLayer as l}from"../utilities/_layers.js";import{LayerExtension as n,LayerExtensionSchema as o}from"./_LayerExtension.js";import{ArrayWrappedCollection as p}from"./support/ArrayWrappedCollection.js";import{PopupTemplateFeatureSettings as d}from"./support/PopupTemplateFeatureSettings.js";import{addOutFields as y}from"./support/layers.js";let u=class extends n{get renderer(){return this.layer?.renderer}get hasFeatures(){return!0}get layer(){return super.layer}get canChangeLabels(){return!0}get canChangeRenderer(){return!0}get canChangeDefinitionExpression(){return!0}get enableClientSideData(){return this._enableClientSideData}set enableClientSideData(e){this._enableClientSideData=e,this._updateClientSideFields()}_enableClientSideData;get _layerView(){return this.layer&&this.mapExtension?._allLayerViews.find((e=>e.layer===this.layer))}_getProjectWebmapJSON(){const e=super._getProjectWebmapJSON();if(!e||this.dynamicallyAddedLayer)return e;const{layerDefinition:r}=t(this.layer),{definitionExpression:i,drawingInfo:a}=r??{};return i&&(e.layerDefinition={...e.layerDefinition,definitionExpression:i}),a&&(e.layerDefinition={...e.layerDefinition,drawingInfo:a}),e}async _onInitialize(){await super._onInitialize(),this._updateClientSideFields(),this._handles.add(a(this,"layer",(()=>{this._updateClientSideFields()}),{sync:!0}))}_applyPortalItemProperties(e){if("WFS"!==e.type)throw new Error(`Cannot create WFS layer from Portal item that has type: ${e.type}`);this.layer.url=e.url||this.layer.url}_capabilities(){return this.layer?.capabilities?.operations?{...this.layer.capabilities.operations,supportsAttachmentEditing:!1,supportsStandardizedQueries:this.layer.capabilities?.query?.supportsStandardizedQueriesOnly}:{...super._capabilities(),supportsStandardizedQueries:!0}}_getSerializableProperties(){const e=super._getSerializableProperties();return{...e,layer:{...this._toPropertyDef(e.layer),default:{layerType:"WFS"}},enableClientSideData:{serializeModes:["initial"],default:!1}}}_isSupportedLayer(e){return l(e)}_createFeatureSettings(){return new d(this)}_createSchema(){return new c(this)}async*_getFeatures(e,t){const r=this.layer.createQuery();r.objectIds=e,r.where=void 0,r.outFields=t.outFields,r.returnGeometry=t.returnGeometry,yield*(await import("../support/_query.js")).executeQuery(r,this,this.layer,t.cancelToken)}_updateClientSideFields(){this.layer&&this._enableClientSideData&&y(this.layer,this.featureSettings.outFields)}};u=e([r],u);export{u as WFSLayerExtension};let c=class extends o{_fieldsCollection;constructor(e){super(e),this._fieldsCollection=new s(new p({parent:e,targetProperty:"layer",arrayProperty:"fields"}),{destroyBackingCollection:!0}),i(this,"_fields")}destroy(){this._fieldsCollection.destroy(),super.destroy()}_getPropertyBindings(){return{primaryKeyField:"objectIdField",geometryType:"geometryType",spatialReference:"spatialReference",displayField:"displayField"}}get _fields(){return this._fieldsCollection}};c=e([r],c);