/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import { c as s } from "../../chunks/runtime.js";
import { LitElement as l } from "@arcgis/lumina";
import { css as n, html as a } from "lit";
import { C as o } from "../../chunks/interfaces.js";
import "@arcgis/toolkit/intl";
import { isEqual as m } from "lodash-es";
import "luxon";
import "d3-array";
import "@arcgis/toolkit/type";
import "../../chunks/series-types.js";
import { bM as h, bO as d } from "../../chunks/index.js";
import "@arcgis/core/Graphic.js";
import "@arcgis/core/renderers/support/jsonUtils.js";
import "@arcgis/core/symbols/support/symbolUtils.js";
import "@esri/arcgis-html-sanitizer";
import "@arcgis/core/intl.js";
import "@arcgis/core/layers/support/FeatureFilter.js";
import "@arcgis/core/smartMapping/statistics/histogram.js";
import "@arcgis/core/smartMapping/statistics/summaryStatistics.js";
import "simple-statistics";
import "@arcgis/core/request.js";
import "@arcgis/core/core/sql.js";
import "@arcgis/core/AttributeBinsGraphic.js";
import "@arcgis/core/geometry/support/jsonUtils.js";
import "@arcgis/core/rest/support/AttributeBinsQuery.js";
import "@arcgis/core/rest/support/StatisticDefinition.js";
import "@arcgis/core/time/TimeExtent.js";
import "@arcgis/core/core/promiseUtils.js";
import { h as c } from "../../chunks/index4.js";
import "@arcgis/toolkit/dom";
const p = n`:host{margin-bottom:var(--arcgis-charts-intra-section-margin);margin-top:var(--arcgis-charts-intra-section-margin);height:100%}`;
class f extends l {
  static {
    this.properties = { layerFieldsInfo: 16, model: 0, page: 1, layer: 0, usePopupTemplateFieldsInfo: 5 };
  }
  static {
    this.styles = p;
  }
  async load() {
    await this.updateFetchLayerFieldsInfo(this.model?.config), this.modelChange(this.model);
  }
  willUpdate(e) {
    let t = !1;
    e.has("model") && this.modelChange(this.model, e.get("model")), e.has("layer") && this.layer !== void 0 && !m(e.get("layer"), this.layer) && (t = !0), e.has("usePopupTemplateFieldsInfo") && this.usePopupTemplateFieldsInfo !== e.get("usePopupTemplateFieldsInfo") && (t = !0), this.layerFieldsInfo === void 0 && (t = !0), t && this.updateFetchLayerFieldsInfo();
  }
  disconnectedCallback() {
    super.disconnectedCallback(), this.model.removeEventListener("arcgisChartsModelConfigChange", this.onModelConfigChange);
  }
  modelChange(e, t) {
    t?.removeEventListener("arcgisChartsModelConfigChange", this.onModelConfigChange), e?.addEventListener("arcgisChartsModelConfigChange", this.onModelConfigChange);
  }
  async updateFetchLayerFieldsInfo(e) {
    const t = e ?? this.model.config;
    let i = this.layer;
    if (!i) {
      const r = c(t) ? t.iLayer : void 0;
      r && (i = await h(r));
    }
    i && (this.layerFieldsInfo = await d(i, this.usePopupTemplateFieldsInfo));
  }
  async onModelConfigChange(e) {
    const i = e?.detail.config ?? this.model.config;
    this.layer === void 0 && await this.updateFetchLayerFieldsInfo(i);
  }
  render() {
    let e;
    switch (this.page) {
      case o.Data:
        e = a`<arcgis-charts-config-heat-chart-data .model=${this.model} .layerFieldsInfo=${this.layerFieldsInfo}></arcgis-charts-config-heat-chart-data>`;
        break;
      case o.Format:
        e = a`<arcgis-charts-config-format .model=${this.model}></arcgis-charts-config-format>`;
        break;
      case o.General:
        e = a`<arcgis-charts-config-general .model=${this.model}></arcgis-charts-config-general>`;
        break;
      default:
        e = "";
        break;
    }
    return e;
  }
}
s("arcgis-charts-config-heat-chart", f);
export {
  f as ArcgisChartsConfigHeatChart
};
