/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{__decorate as e}from"tslib";import{deprecateWidget as t}from"../core/deprecate.js";import i from"../core/Logger.js";import{property as s,subclass as o}from"../core/accessorSupport/decorators.js";import{systemTimeZone as n,system as r,unknown as a}from"../time/constants.js";import c from"./Widget.js";import{loadCalciteComponents as l}from"./support/componentsUtils.js";import{globalCss as d}from"./support/globalCss.js";import{messageBundle as p,isRTL as m,tsx as h}from"./support/widget.js";import{css as b}from"./TimeZoneLabel/css.js";import g from"./TimeZoneLabel/TimeZoneLabelViewModel.js";let v=class extends c{constructor(e,s){super(e,s),this.disabled=!1,this.expanded=!1,this.messages=null,this.viewModel=new g,this._onExpanderClick=()=>{this.expanded=!this.expanded},t(i.getLogger(this),"Time Zone Label","arcgis-time-zone-label",{version:"4.33"})}loadDependencies(){return l({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone"),label:()=>import("@esri/calcite-components/dist/components/calcite-label")})}get expandDirection(){if(!this.view||!this.container)return"end";const e=m();switch(this.view.ui.getPosition(this.container)){case"top-right":case"bottom-right":case"top-trailing":case"bottom-trailing":return e?"end":"start";case"top-left":case"bottom-left":case"top-leading":case"bottom-leading":return e?"start":"end";default:return"end"}}set expandDirection(e){this._overrideIfSome("expandDirection",e)}get icon(){return"time-zone"}set icon(e){this._overrideIfSome("icon",e)}get interactive(){return!(this.disabled||"disabled"===this.viewModel.state)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}render(){const{expandDirection:e,interactive:t,label:i}=this,s=this.classes(b.base,d.widget,!t&&d.disabled),o=[this._renderExpander(),this._renderName(),this._renderBadge()];return"start"===e&&o.reverse(),h("div",{"aria-label":i,class:s},o)}_getIcon(){const{expanded:e,expandDirection:t}=this;return e?m()?"start"===t?"chevrons-left":"chevrons-right":"start"===t?"chevrons-right":"chevrons-left":"time-zone"}_renderExpander(){const{interactive:e,label:t}=this,i=this._getIcon();return h("calcite-action",{active:!1,class:b.expander,disabled:!e,icon:i,key:b.expander,text:t,title:t,onclick:this._onExpanderClick})}_renderBadge(){const{expanded:e,interactive:t}=this;return h("div",{class:this.classes(b.badge,!e&&b.badgeHidden,!t&&b.badgeDisabled)},h("calcite-icon",{class:b.badgeIcon,icon:"time-zone",scale:"s"}))}_renderName(){const e=this.viewModel.view?.timeZone,t=e===r?n:e,i=e===a;return[h("calcite-label",{class:this.classes(b.label,(!this.expanded||!i)&&b.labelHidden,!this.interactive&&b.labelDisabled)},this.messages.noAdjustment),h("calcite-input-time-zone",{class:this.classes(b.name,(!this.expanded||!t||i)&&b.nameHidden),disabled:!this.interactive,mode:"region",readOnly:!0,value:t})]}};e([s()],v.prototype,"disabled",void 0),e([s()],v.prototype,"expandDirection",null),e([s()],v.prototype,"expanded",void 0),e([s()],v.prototype,"icon",null),e([s({readOnly:!0})],v.prototype,"interactive",null),e([s()],v.prototype,"label",null),e([s(),p("esri/widgets/TimeZoneLabel/t9n/TimeZoneLabel")],v.prototype,"messages",void 0),e([s()],v.prototype,"view",null),e([s()],v.prototype,"viewModel",void 0),v=e([o("esri.widgets.TimeZoneLabel")],v);const u=v;export{u as default};
