import{isLayerExtension as e,ItemType as t}from"../ItemType.js";import{LayerExtension as r}from"./_LayerExtension.js";import{LayerExtensionCollectionBase as n}from"./support/_LayerExtensionCollection.js";export class LayerExtensionCollectionImpl extends n{get _mapExtension(){return this._parent}constructor(e){super(e,"map.layers")}toJSON(){const e=[];return this.forEach((r=>{e.push(`item://${encodeURIComponent(t.LAYER_EXTENSION)}/${encodeURIComponent(r.id)}`)})),e}_forLayer(t){const n=this._mapExtension?._deferredProperties?.layerExtensions?.map((t=>e(t)?t:r.create(t)))??[];n?.length&&(this._mapExtension._deferredProperties.layerExtensions=n);for(const e of n)e.layer||e._resolveLayer(this._layers),e.layer&&(this._layerExtensionMap.set(e.layer,e),this._uninitializedLayerExtensions.remove(e),this._mapExtension&&!e.mapExtension&&e._setMapExtension(this._mapExtension));return super._forLayer(t)}}