/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import { c as m } from "../../chunks/runtime.js";
import { css as o, html as l } from "lit";
import { i as h, m as r, s as u, U as s } from "../../chunks/chart-ui-utils2.js";
import { u as p } from "../../chunks/useT9n.js";
import { createRef as g, ref as d } from "lit/directives/ref.js";
import { LitElement as f, createEvent as b, safeClassMap as e } from "@arcgis/lumina";
const a = {
  container: "container",
  label: "label",
  numberInput: "number-input"
}, y = o`.hide{visibility:hidden}.am5-html-container{z-index:101!important}.am5-layer-1000{z-index:1000!important}.am5-layer-30{z-index:100!important}.show{display:block}.notifyPanel{flex:0 1 auto}.disable-interactions{pointer-events:none}.dim-text{color:var(--arcgis-charts-dim-text)}.container{width:var(--arcgis-charts-config-calcite-block-width, var(--arcgis-charts-config-calcite-block-default-width));height:var(--arcgis-charts-config-calcite-block-height, var(--arcgis-charts-config-calcite-block-default-height))}.container>.number-input{margin-bottom:.5rem;display:flex}.container>.number-input>div{width:100%}.label{display:flex;margin-bottom:.5rem}`;
class v extends f {
  constructor() {
    super(...arguments), this._messages = p(), this.characterLimitInputElement = g(), this.arcgisChartsConfigCategoryFormatChange = b();
  }
  static {
    this.properties = { messageOverrides: 0, categoryFormat: 0 };
  }
  static {
    this.styles = y;
  }
  onCharacterLimitChange() {
    const t = this.characterLimitInputElement.value?.value, i = Math.floor(Number(t)), c = i === Number(t) && i >= 0;
    if (t !== void 0 && c && h(t, this.characterLimitInputElement.value?.min, this.characterLimitInputElement.value?.max)) {
      const n = Number.parseInt(t);
      this.updateCategoryFormat({ type: this.categoryFormat.type, characterLimit: n }), this.arcgisChartsConfigCategoryFormatChange.emit(), this.characterLimitInputElement.value && r({
        inputElement: this.characterLimitInputElement.value,
        status: s.IDLE
      });
    } else this.characterLimitInputElement.value && r({
      inputElement: this.characterLimitInputElement.value,
      status: s.INVALID
    });
  }
  updateCategoryFormat(t) {
    this.categoryFormat = {
      ...this.categoryFormat,
      ...t
    };
  }
  render() {
    return l`<div class=${e(a.container)}><calcite-label class=${e(a.label)}>${this._messages.labelCharacterLmt}<calcite-input type=number class=${e(a.numberInput)} min=1 max=100 step=1 .value=${u(this.categoryFormat?.characterLimit, 11)} @calciteInputInput=${this.onCharacterLimitChange} ${d(this.characterLimitInputElement)}></calcite-input></calcite-label></div>`;
  }
}
m("arcgis-charts-config-category-format", v);
export {
  v as ArcgisChartsConfigCategoryFormat
};
