import{__decorate as e}from"tslib";import{InvalidOperationError as t}from"../InvalidOperationError.js";import{TaskSettings as r}from"../data/TaskSettings.js";import{supportsAttachmentEditing as i}from"../data/support/attachments.js";import{_isGraphicsLayerJson as s}from"../json/FeatureLayerJson.js";import{layerToJson as a}from"../json/LayerJson.js";import{serializable as n}from"../support/Serializable.js";import{notifyChange as o}from"../support/observableUtils.js";import{ReadOnlyCollection as l}from"../utilities/ReadOnlyCollection.js";import{isCSVLayer as p,isFeatureLayer as y,isGraphicsLayer as c,isStreamLayer as u}from"../utilities/_layers.js";import{checkArg as d}from"../utilities/checkArg.js";import{parse as m}from"../utilities/format/number.js";import{LayerExtension as g,LayerExtensionSchema as h,ERR_SCHEMA_READ_ONLY as _}from"./_LayerExtension.js";import{ArrayWrappedCollection as f}from"./support/ArrayWrappedCollection.js";import{PopupTemplateFeatureSettings as S}from"./support/PopupTemplateFeatureSettings.js";export class FeatureLayerExtensionBase extends g{get hasFeatures(){return!0}get layer(){return super.layer}get renderer(){return this.layer?.renderer}get canChangeDefinitionExpression(){return!0}get canChangeRenderer(){return!0}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:t,showLabels:r}=a(this.layer),{definitionExpression:i,drawingInfo:s}=t??{};return i&&(e.layerDefinition={...e.layerDefinition,definitionExpression:i}),s&&(e.layerDefinition={...e.layerDefinition,drawingInfo:s}),void 0!==r&&(e.showLabels=r),e}async*_getFeatures(e,t){const r=this.layer.createQuery();r.objectIds=e.map((e=>m(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)}_applyLayerProperties(e,t){return d("properties",e).isNotMissing(),d("properties.layerType",e.layerType).satisfies((e=>!e||"ArcGISFeatureLayer"===e||"ArcGISStreamLayer"===e||"CSV"===e)),d("layer",t).isNotMissing().satisfies((e=>y(e)||u(e)||p(e)||c(e))),d("properties",e).satisfies((e=>!s(e))),super._applyLayerProperties(e,t)}_getSerializableProperties(){const e=super._getSerializableProperties();return{...e,layer:{...this._toPropertyDef(e.layer),default:{layerType:"ArcGISFeatureLayer"}}}}_createSchema(){return new x(this)}_isSupportedLayer(e){return y(e)}_createFeatureSettings(){return new b(this)}_createTaskSettings(){return new j(this)}_capabilities(){const e=i(this.layer);return this.layer?.capabilities?.operations?{...this.layer.capabilities.operations,supportsAttachmentEditing:e,supportsStandardizedQueries:this.layer.capabilities?.query?.supportsStandardizedQueriesOnly}:{...super._capabilities(),supportsAttachmentEditing:e}}}let b=class extends S{get zoomScale(){const e="point"===this._layerExtension.schema.geometryType?this._layerExtension.layer.maxScale:void 0;return this._getSetting("zoomScale",e)}set zoomScale(e){this._setSetting("zoomScale",e)}};b=e([n],b);let x=class extends h{_fieldCollection;_typesCollection;constructor(e){super(e),this._fieldCollection=this._createFieldCollection(),this._typesCollection=this._createTypeCollection(),o(this,"_fields")}get types(){return this._typesCollection}get _fields(){return this._fieldCollection}_createFieldCollection(){return new f({parent:this._layerExtension,targetProperty:"layer",arrayProperty:"fields"})}_createTypeCollection(){return new f({parent:this._layerExtension,targetProperty:"layer",arrayProperty:"types"})}_getPropertyBindings(){return{primaryKeyField:"objectIdField",geometryType:"geometryType",spatialReference:"spatialReference",displayField:"displayField",typeIdField:"typeIdField"}}};x=e([n],x);export{x as FeatureLayerSchema};let E=class extends x{_setSetting(e,r){if(this._layerBindings.has(e))throw new t(_);super._setSetting(e,r)}_createFieldCollection(){return new l(super._createFieldCollection())}_createTypeCollection(){return new l(super._createTypeCollection())}};E=e([n],E);export{E as FeatureLayerReadOnlySchema};let j=class extends r{_layerExtension;constructor(e,t){super(t),this._layerExtension=e}get enableEditing(){return this._getSetting("enableEditing",this._layerExtension.layer?.editingEnabled??!0)}set enableEditing(e){this._setSetting("enableEditing",e)}};j=e([n],j);