/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import { c as r } from "../../chunks/runtime.js";
import "@arcgis/toolkit/intl";
import { isEqual as n } from "lodash-es";
import "luxon";
import "d3-array";
import "@arcgis/toolkit/type";
import "../../chunks/series-types.js";
import { bM as l, bO as c, cF as h } 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 d } from "../../chunks/index4.js";
import "@arcgis/toolkit/dom";
import { LitElement as m, createEvent as p } from "@arcgis/lumina";
import { css as g, html as a } from "lit";
import { C as o } from "../../chunks/interfaces.js";
const f = g`:host{overflow-y:auto;overflow-x:hidden;margin-bottom:var(--arcgis-charts-intra-section-margin);margin-top:var(--arcgis-charts-intra-section-margin);height:100%}`;
class u extends m {
  constructor() {
    super(...arguments), this.onModelConfigChange = async (e) => {
      const i = e?.detail.config ?? this.model.config;
      this.layer === void 0 && await this.updateFetchLayerFieldsInfo(i);
    }, this.popoverPlacement = "leading", this.arcgisChartsConfigWebChartChange = p();
  }
  static {
    this.properties = { layerFieldsInfo: 16, model: 0, popoverPlacement: 1, r2: 9, calculatedDataMinMaxBounds: 0, calculatedMinMaxBounds: 0, page: 1, layer: 0, usePopupTemplateFieldsInfo: 5 };
  }
  static {
    this.styles = f;
  }
  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("r2") && this.r2Change(this.r2), e.has("layer") && this.layer !== void 0 && !n(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();
  }
  modelChange(e, t) {
    t?.removeEventListener("arcgisChartsModelConfigChange", this.onModelConfigChange), e?.addEventListener("arcgisChartsModelConfigChange", this.onModelConfigChange);
  }
  r2Change(e) {
    Number.isFinite(e) || (this.r2 = void 0);
  }
  async updateFetchLayerFieldsInfo(e) {
    const t = e ?? this.model.config;
    let i = this.layer;
    if (!i) {
      const s = d(t) ? t.iLayer : void 0;
      s && (i = await l(s));
    }
    i && (this.layerFieldsInfo = await c(i, this.usePopupTemplateFieldsInfo));
  }
  render() {
    let e;
    switch (this.page) {
      case o.Data:
        e = a`<arcgis-charts-config-scatter-plot-data .model=${this.model} .r2=${this.r2} .layerFieldsInfo=${this.layerFieldsInfo} .isTableLayer=${h(this.layer)?.isTable}></arcgis-charts-config-scatter-plot-data>`;
        break;
      case o.Axes:
        e = a`<arcgis-charts-config-axes .model=${this.model} show-min-x-bound-option show-max-x-bound-option show-min-y-bound-option show-max-y-bound-option show-enable-x-log-option show-enable-y-log-option .calculatedMinMaxBounds=${this.calculatedMinMaxBounds} .calculatedDataMinMaxBounds=${this.calculatedDataMinMaxBounds}></arcgis-charts-config-axes>`;
        break;
      case o.Guides:
        e = a`<arcgis-charts-config-guides .model=${this.model} enable-x-axis-guide enable-y-axis-guide></arcgis-charts-config-guides>`;
        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;
  }
}
r("arcgis-charts-config-scatter-plot", u);
export {
  u as ArcgisChartsConfigScatterplot
};
