import{__decorate as e}from"tslib";import r from"@arcgis/core/config";import t from"@arcgis/core/core/Collection";import i from"@arcgis/core/geometry/SpatialReference";import{jsonToLayer as s}from"../json/LayerJson.js";import{serializable as a}from"../support/Serializable.js";import{notifyChange as o,watch as n}from"../support/observableUtils.js";import{ReadOnlyCollection as l}from"../utilities/ReadOnlyCollection.js";import{isGeoRssLayer as p}from"../utilities/_layers.js";import{map as u}from"../utilities/promise.js";import{caseInsensitiveEquals as c}from"../utilities/string.js";import{FeatureCollectionLayerExtension as y}from"./FeatureCollectionLayerExtension.js";import{LayerExtension as f,LayerExtensionSchema as m}from"./_LayerExtension.js";export const DEFAULT_GEO_RSS_UTILITY="https://utility.arcgis.com/sharing/rss";let _=class extends f{get layer(){return super.layer}get _featureLayerExtensions(){return this._featureLayerXCache}_featureLayerXCache=[];get hasFeatures(){return!0}_capabilities(){return Object.freeze({supportsAdd:!1,supportsUpdate:!1,supportsDelete:!1,supportsEditing:!1,supportsQuery:!1,supportsAttachmentEditing:!1,supportsStandardizedQueries:!0})}_getSerializableProperties(){const e=super._getSerializableProperties();return{...e,layer:{...this._toPropertyDef(e.layer),default:{layerType:"GeoRSS"}}}}_isSupportedLayer(e){return p(e)}_createSchema(){return new h(this)}async _initializeLayer(){r.geoRSSServiceUrl||(r.geoRSSServiceUrl=DEFAULT_GEO_RSS_UTILITY)}async _onInitialize(){await super._onInitialize(),this.layer.featureCollections&&(this._featureLayerXCache=await u(this.layer.featureCollections,(async e=>{const r={layerType:"ArcGISFeatureLayer",featureCollection:{layers:[e]}};return new y({layer:await s(r)})})),o(this,"_featureLayerExtensions"))}};_=e([a],_);export{_ as GeoRSSLayerExtension};let h=class extends m{_fieldsCollection;constructor(e){super(e),this._fieldsCollection=new d(e),o(this,"_fields")}_getPropertyBindings(){return{spatialReference:{value:i.WGS84}}}get _fields(){return this._fieldsCollection}};h=e([a],h);class d extends l{layerExtension;get _collection(){if(!this.layerExtension?.layer)return new t;let e=new t;return this.layerExtension._featureLayerExtensions.forEach((r=>{const t=r.layer.fields.filter((r=>!e.some((e=>this._fieldsEqual(r,e)))));e=e.concat(t)})),e}constructor(e){super(),this.layerExtension=e,n(e,"_featureLayerExtensions",(()=>this.emit("after-changes")),{sync:!0})}_fieldsEqual(e,r){return!(!c(e.alias,r.alias)||!c(e.name,r.name)||e.type!==r.type)}}