/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{__decorate as e}from"tslib";import{deprecateWidget as i}from"../core/deprecate.js";import s from"../core/Logger.js";import{property as t,cast as l,subclass as r}from"../core/accessorSupport/decorators.js";import o from"./Widget.js";import n from"./BuildingExplorer/BuildingExplorerViewModel.js";import{css as a}from"./BuildingExplorer/css.js";import d from"./BuildingExplorer/BuildingDisciplinesTree/BuildingDisciplinesTree.js";import p from"./BuildingExplorer/BuildingLevelPicker/BuildingLevelPicker.js";import c from"./BuildingExplorer/BuildingPhasePicker/BuildingPhasePicker.js";import{loadCalciteComponents as g}from"./support/componentsUtils.js";import{globalCss as u}from"./support/globalCss.js";import{Heading as m}from"./support/Heading.js";import{messageBundle as h,tsx as v,classes as y}from"./support/widget.js";const w={levels:!0,phases:!0,disciplines:!0};let b=class extends o{constructor(e,t){super(e,t),this._defaultViewModel=new n({suppressDeprecationWarning:!0}),this.viewModel=this._defaultViewModel,this.visibleElements={...w},this.headingLevel=3,this.messages=null,this.messagesCommon=null,this.toggleSiblingsVisibility=!1,i(s.getLogger(this),"Building Explorer","arcgis-building-explorer",{version:"5.0"})}loadDependencies(){return g({loader:()=>import("@esri/calcite-components/dist/components/calcite-loader")})}destroy(){this.viewModel!==this._defaultViewModel&&this._defaultViewModel.destroy()}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get layers(){return this.viewModel.layers}set layers(e){this.viewModel.layers=e}_castVisibleElements(e){return{...w,...e}}get icon(){return"organization"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}render(){const e=this.viewModel,i="disabled"===e.state||!e.isSupported;return v("div",{"aria-label":this.messages.widgetLabel,class:y(u.widget,a.base,u.panel,{[u.widgetDisabled]:i}),key:this},this._renderContent())}_renderContent(){const e=this.viewModel,i=this.messages;if(!e.isSupported)return v("p",{class:a.panelError},i.unsupported);if(!e.layers.length)return v("p",{class:a.panelError},i.noData);switch(e.state){case"loading":return this._renderLoadingIndicator();case"ready":return v("div",{class:a.content,key:"content"},this._renderLevelPickerSection(),this._renderPhasePickerSection(),this._renderDisciplinesSection());case"failed":return v("p",{class:a.panelError},i.failed);default:return null}}_renderLoadingIndicator(){const e=this.messagesCommon.loading;return v("div",{"aria-label":e,class:a.loadingContainer,key:"loading-container",role:"presentation",title:e},v("calcite-loader",{label:e,type:"indeterminate"}))}_renderLevelPickerSection(){const e=this.viewModel.level,i="ready"===e.state,s=e.allowedValues.length>1;if(!this.visibleElements.levels||!i||!s)return null;const t=this.messages?.level;return v("div",{class:y(a.section,a.levels),key:"levels"},v(m,{level:this.headingLevel},t?.title),v(p,{messages:t,vm:e}))}_renderPhasePickerSection(){const e=this.viewModel.phase,i="ready"===e.state,s=e.allowedValues.length>1;if(!this.visibleElements.phases||!i||!s)return null;const t=this.messages.phase;return v("div",{class:y(a.section,a.phases),key:"phases"},v(m,{level:this.headingLevel},t.title),v(c,{messages:t,vm:e}))}_renderDisciplinesSection(){const e=this.viewModel.disciplines,i="ready"===e.state,s=e.root.hasChildren;if(!this.visibleElements.disciplines||!i||!s)return null;const t=this.messages?.disciplines;return v("div",{class:y(a.section,a.disciplines),key:"disciplines"},v(m,{level:this.headingLevel},t.title),v(d,{messages:t,toggleSiblingsVisibility:this.toggleSiblingsVisibility,vm:e}))}};e([t({type:n})],b.prototype,"viewModel",void 0),e([t()],b.prototype,"view",null),e([t()],b.prototype,"layers",null),e([t()],b.prototype,"visibleElements",void 0),e([l("visibleElements")],b.prototype,"_castVisibleElements",null),e([t()],b.prototype,"headingLevel",void 0),e([t()],b.prototype,"icon",null),e([t()],b.prototype,"label",null),e([t(),h("esri/widgets/BuildingExplorer/t9n/BuildingExplorer")],b.prototype,"messages",void 0),e([t(),h("esri/t9n/common")],b.prototype,"messagesCommon",void 0),e([t({nonNullable:!0})],b.prototype,"toggleSiblingsVisibility",void 0),e([t()],b.prototype,"uiStrings",void 0),b=e([r("esri.widgets.BuildingExplorer")],b);const f=b;export{f as default};
