/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{__decorate as e}from"tslib";import s from"./Basemap.js";import t from"./Ground.js";import r from"./core/CollectionFlattener.js";import{EventedAccessor as a}from"./core/Evented.js";import{destroyMaybe as o}from"./core/maybe.js";import{when as i}from"./core/reactiveUtils.js";import{property as l,subclass as n}from"./core/accessorSupport/decorators.js";import p from"./effects/FocusAreas.js";import{isEditableLayer as u}from"./layers/support/editableLayers.js";import{createCache as d,destroyCache as m,basemapEnsureType as y}from"./support/basemapEnsureType.js";import{createFlattenedTablesCollection as h}from"./support/collectionUtils.js";import{ensureType as c}from"./support/groundUtils.js";import{LayersMixin as b}from"./support/LayersMixin.js";import{TablesMixin as f}from"./support/TablesMixin.js";let g=class extends(f(b(a))){constructor(e){super(e),this._allLayers=new r({getCollections:()=>[this.basemap?.baseLayers,this.basemap?.groundLayers,this.ground?.layers,this.layers,this.basemap?.referenceLayers],getChildrenFunction:e=>"layers"in e?e.layers:null}),this.focusAreas=new p,this.allTables=h(this),this.editableLayers=new r({getCollections:()=>[this.allLayers],itemFilterFunction:u}),this._basemapCache=d(),this.ground=new t,this.addHandles(i(()=>this.ground,(e,s)=>{s?.parent===this&&(s.parent=null),e.parent=this},{sync:!0,initial:!0}))}destroy(){m(this._basemapCache),this._basemapCache=null,this.focusAreas.destroy(),this.allLayers.destroy(),this.allTables.destroy(),this.editableLayers.destroy(),this.basemap=o(this.basemap),o(this.ground),this._set("ground",null)}get allLayers(){return this._allLayers}get basemap(){return this._get("basemap")}set basemap(e){this._set("basemap",y(e,this._basemapCache))}get ground(){return this._get("ground")}set ground(e){const s=c(e);null!=s&&this._set("ground",s)}findLayerById(e){return this.allLayers.find(s=>s.id===e)}findTableById(e){return this.allTables.find(s=>s.id===e)}};e([l({readOnly:!0})],g.prototype,"allLayers",null),e([l({type:p,nonNullable:!0,json:{write:{overridePolicy:e=>({enabled:e.areas.length>0,ignoreOrigin:!0})}}})],g.prototype,"focusAreas",void 0),e([l({readOnly:!0})],g.prototype,"allTables",void 0),e([l({type:s,useTypeForAutocast:!1,json:{read:{source:"baseMap"},write:{target:"baseMap"}},value:null})],g.prototype,"basemap",null),e([l({readOnly:!0})],g.prototype,"editableLayers",void 0),e([l({type:t,useTypeForAutocast:!1,nonNullable:!0})],g.prototype,"ground",null),e([l()],g.prototype,"undoRedo",void 0),g=e([n("esri.Map")],g);const j=g;export{j as default};
