/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{__decorate as t}from"tslib";import"../../core/has.js";import"../../core/Logger.js";import{watch as i,initial as e}from"../../core/reactiveUtils.js";import{property as o,subclass as s}from"../../core/accessorSupport/decorators.js";import r from"./Component.js";import n from"./UI.js";import a from"../../widgets/Attribution.js";import d from"../../widgets/Compass.js";import p from"../../widgets/NavigationToggle.js";import m from"../../widgets/Zoom.js";function c(t){return void 0!==t?.view}let h=class extends n{constructor(t){super(t),this._defaultPositionLookup={attribution:"manual",compass:"top-left","navigation-toggle":"top-left",zoom:"top-left"},this.components=[],this._updateViewAwareWidgets=t=>{this.components.forEach(i=>{const e=this._find(i),o=e?.widget;c(o)&&(o.view=t)})},this._componentsWatcher=(t,i)=>{this._removeComponents(i),this._addComponents(t)},this._adjustPadding=({ready:t,attributionVisible:i})=>{if(t&&!i&&!this._isOverridden("padding")){const{top:t}=this.padding;this.padding=t}}}initialize(){this.addHandles([i(()=>this.components,this._componentsWatcher,e),i(()=>this.view,this._updateViewAwareWidgets,e),i(()=>({ready:this.view?.ready,attributionVisible:this.view?.attributionVisible}),this._adjustPadding,e)])}_add(t,i,e,o,s){let r=t;if("string"==typeof t&&this._defaultPositionLookup[t]){if(this._find(t))return;r=this._createComponent(t)}super._add(r,i,e,o,s)}_removeComponents(t){t.forEach(t=>{const i=this._find(t);i&&(this.remove(i),i.destroy())})}_addComponents(t){this.constructed&&t.forEach(t=>this.add(this._createComponent(t),this._defaultPositionLookup[t]))}_createComponent(t){const i=this._createWidget(t);return new r({id:t,node:i})}_createWidget(t){const i=this.view;switch(t){case"attribution":return new a({view:i});case"compass":return new d({view:i});case"navigation-toggle":return new p({view:i,isDefaultUI:!0});case"zoom":return new m({view:i})}}};t([o()],h.prototype,"components",void 0),h=t([s("esri.views.ui.DefaultUI")],h);const u=h;export{u as default};
