/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import { m as e } from "./model-setter.js";
import { H as o } from "./common.js";
import { S as u, g as _, a as S } from "./serial-chart-model.js";
import { a as C, b as T, s as A, c as O, d as F, e as L, f as x, h as D, i as b, j as v, k as w, l as B, m as I, n as P, o as R, p as E, q as k, r as W, t as G, u as H, v as N, w as Y, x as M, y as U, z as V, A as m, B as c, C as X, D as j, E as K, F as q, G as z, H as J, I as y, J as Q, K as Z, L as $, M as tt, N as et, O as it, P as st, Q as rt } from "./serial-chart-data.js";
import { s as d } from "./data.js";
import { W as ot, a as f } from "./series-types.js";
import { bR as h, d7 as nt, br as at } from "./index.js";
import "@arcgis/toolkit/intl";
import "lodash-es";
import "luxon";
import "d3-array";
import "@arcgis/toolkit/type";
import "@arcgis/core/Graphic.js";
import "@arcgis/core/renderers/support/jsonUtils.js";
import "@arcgis/core/symbols/support/symbolUtils.js";
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 "./runtime.js";
import "@arcgis/toolkit/dom";
var gt = Object.defineProperty, pt = Object.getOwnPropertyDescriptor, i = (p, t, r, a) => {
  for (var n = pt(t, r), g = p.length - 1, l; g >= 0; g--)
    (l = p[g]) && (n = l(t, r, n) || n);
  return n && gt(t, r, n), n;
};
class s extends u {
  constructor() {
    super(...arguments), this._chartType = ot.HeatSeries;
  }
  /**
   * Generate the proper chart title given the current config.
   */
  generateChartTitle() {
    return this.layerInfo !== void 0 ? C(this._config, this.layerInfo, this.commonStrings) : "";
  }
  /**
   * Generate the proper y-axis title given the current config.
   */
  generateYAxisTitle() {
    const t = this.yTemporalBinning?.unit;
    return t !== void 0 ? this.commonStrings.utilsStrings.heatChartCalendarDatePartsUnits[t] : "";
  }
  async setup(t) {
    await this.loadConfigFromLayer(t), this.setupLocalProps(), typeof this.resolveSetup == "function" && this.resolveSetup();
  }
  /**
   * The y axis field used by the heat chart.
   */
  get yAxisField() {
    return T(this._config);
  }
  set yAxisField(t) {
    A({
      yField: t,
      config: this._config,
      layerInfo: this.layerInfo
    });
  }
  /**
   * The calendar view type for the heat chart.
   * `SingleCalendarView` - A single calendar view showing all data in one calendar.
   * `SequentialCalendarViews` - Multiple sequential calendar views (e.g., years).
   *
   * **Note**: This is only applicable for calendar heat charts (when `xAxisField` and `yAxisField` are date fields).
   */
  get viewType() {
    return O(this._config);
  }
  set viewType(t) {
    this.guardSetterFromAsyncOverwrite(() => {
      F(t, this._config), this.emitConfigUpdate("heatChartViewType");
    });
  }
  /**
   * The x axis temporal binning used by the heat chart.
   *
   * @example
   * ```ts
   * heatChartModel.xTemporalBinning = {
   *   type: WebChartTypes.CalendarDateParts,
   *   unit: WebChartCalendarDatePartsUnits.MonthOfYear,
   * };
   * ```
   */
  get xTemporalBinning() {
    return L(this._config);
  }
  set xTemporalBinning(t) {
    x({
      commonStrings: this.commonStrings,
      binning: t,
      config: this._config
    });
  }
  /**
   * The y axis temporal binning used by the heat chart.
   *
   * @example
   * ```ts
   * heatChartModel.yTemporalBinning = {
   *   type: WebChartTypes.CalendarDateParts,
   *   unit: WebChartCalendarDatePartsUnits.DayOfMonth,
   * };
   * ```
   */
  get yTemporalBinning() {
    return D(this._config);
  }
  set yTemporalBinning(t) {
    b({
      commonStrings: this.commonStrings,
      binning: t,
      config: this._config
    });
  }
  /**
   * The number of class breaks used by the heat chart.
   * @default 5
   * */
  get breaksCount() {
    return v(this._config);
  }
  set breaksCount(t) {
    this.guardSetterFromAsyncOverwrite(() => {
      w(t, this._config), this.emitConfigUpdate("breaksCount");
    });
  }
  /**
   * The classification method to be used for the heat chart.
   * `equal-interval` - Divides the range of values into equal-sized intervals.
   * `quantile` - Divides the range of values into intervals that contain an equal number of features.
   * `natural-breaks` - Identifies natural groupings of values in the data by minimizing the variance within classes and maximizing the variance between classes.
   * `manual` - Allows you to manually specify the class breaks.
   */
  get classificationMethod() {
    return B(this._config);
  }
  set classificationMethod(t) {
    this.guardSetterFromAsyncOverwrite(() => {
      t && (I(t, this._config), this.emitConfigUpdate("classificationMethod"));
    });
  }
  /**
   * Hide the empty rows and columns in the heat chart.
   */
  get hideEmptyRowsAndColumns() {
    return P(this._config);
  }
  set hideEmptyRowsAndColumns(t) {
    R(this._config, t);
  }
  /**
   * The grid line width used by the heat chart.
   */
  get gridLineWidth() {
    return E(this._config);
  }
  set gridLineWidth(t) {
    k(t, this._config);
  }
  /**
   * The grid line color used by the heat chart.
   */
  get gridLineColor() {
    return W(this._config);
  }
  set gridLineColor(t) {
    G(t, this._config);
  }
  /**
   * The name of the series that is used by the heat chart.
   * @internal
   */
  get seriesName() {
    return _(0, this._config);
  }
  set seriesName(t) {
    typeof t == "string" && S(t, 0, this._config);
  }
  /**
   * The heat rules type used by the heat chart.
   * `gradient`: A gradient of colors is applied to the cells based on their values, with the range of colors determined by the minimum and maximum values in the data.
   * `renderer`: A class break renderer is used to apply specific colors to cells based on defined value ranges, allowing for more customized visualizations.
   */
  get heatRulesType() {
    return H(this._config);
  }
  set heatRulesType(t) {
    N(this._config, t);
  }
  /**
   * Set the gradient rules for the heat chart, which define how data values map to colors.
   *
   * @example
   * In this example, we set the gradient rules for the heat chart to use a color gradient from light blue to red, with specific colors for values outside the defined range.
   *
   * ```js
   * heatChartModel.gradientRules = {
   *   colorList: [
   *     [200, 225, 255, 255],
   *     [220, 0, 0, 255],
   *   ],
   *   minValue: 100,
   *   maxValue: 250,
   *   outsideRangeLowerColor: [0, 255, 255, 255],
   *   outsideRangeUpperColor: [0, 30, 30, 255],
   * };
   * ```
   */
  get gradientRules() {
    return Y(this._config);
  }
  set gradientRules(t) {
    M(this._config, t);
  }
  /**
   * Gets the grid lines symbol. Contains styling information such as line width, line style, and line color.
   */
  getGridLinesSymbol() {
    return this._config.series?.[0]?.gridLine;
  }
  setGridLinesSymbol(t) {
    this._config.series?.[0] && (this._config.series[0].gridLine = t);
  }
  /**
   * Heat chart only supports one numeric field, if there are multiple numeric fields provided in the array, only the first one will be used and the rest will be ignored.
   */
  get numericFields() {
    const t = U(this._config);
    return t !== void 0 ? [t] : [];
  }
  set numericFields(t) {
    const { idField: r } = h(this.layerInfo.layer), a = nt(t[0]), n = a ? r : t[0];
    V({
      field: n,
      config: this._config,
      layerInfo: this.layerInfo,
      commonStrings: this.commonStrings
    });
    const g = m(this._config);
    a && g !== f.Count && c({
      aggregationType: f.Count,
      config: this._config,
      layerInfo: this.layerInfo,
      commonStrings: this.commonStrings
    });
  }
  /**
   * The aggregation type for the heat chart.
   */
  get aggregationType() {
    return m(this._config);
  }
  set aggregationType(t) {
    c({
      aggregationType: t,
      config: this._config,
      layerInfo: this.layerInfo,
      commonStrings: this.commonStrings
    });
  }
  /**
   * Split-by field not supported for heat charts.
   * @internal
   */
  get splitByField() {
    return "";
  }
  set splitByField(t) {
  }
  get legendPosition() {
    return X(this._config);
  }
  set legendPosition(t) {
    j(t, this._config);
  }
  get nullPolicy() {
    return K(this._config);
  }
  set nullPolicy(t) {
    q(t, this._config);
  }
  get emptyCell() {
    return z(this._config);
  }
  /**
   * The heat chart's empty cell configuration.
   */
  set emptyCell(t) {
    this.guardSetterFromAsyncOverwrite(() => {
      J(t, this._config), this.emitConfigUpdate("emptyCell");
    });
  }
  getSortOrder() {
    return o.Asc;
  }
  setSortOrder(t, r) {
  }
  /**
   * Get the sort order on the x axis for the heat chart.
   * @returns {"Asc" | "Desc" | "customSort"}
   */
  getXAxisSortOrder() {
    const t = y(this._config)[0];
    return t === o.Asc || t === o.Desc || t === o.customSort ? t : o.Asc;
  }
  setXAxisSortOrder(t, r) {
    d(t, this._config, r);
  }
  /**
   * Gets the sort order for on the y axis for heat chart.
   * @returns {"Asc" | "Desc" | "customSort"}
   */
  getYAxisSortOrder() {
    const t = y(this._config)[1];
    return t === o.Asc || t === o.Desc || t === o.customSort ? t : o.Asc;
  }
  setYAxisSortOrder(t, r) {
    d(t, this._config, r, !0);
  }
  get emptyCellText() {
    return Q(this._config);
  }
  set emptyCellText(t) {
    Z(t, this._config);
  }
  get includeLeapDay() {
    return $(this._config);
  }
  /**
   * Whether to include leap day (February 29) in the heat chart when using "day of month" temporal binning.
   */
  set includeLeapDay(t) {
    this.guardSetterFromAsyncOverwrite(() => {
      tt(t, this._config), this.emitConfigUpdate("includeLeapDay");
    });
  }
  /**
   * The first day of the week used for date-based bins.
   *
   * - `1`: Monday
   * - `7`: Sunday
   */
  get firstDayOfWeek() {
    return et(this._config);
  }
  set firstDayOfWeek(t) {
    this.guardSetterFromAsyncOverwrite(() => {
      it(t, this._config), this.emitConfigUpdate("firstDayOfWeek");
    });
  }
  get emptyCellSymbol() {
    return st(this._config);
  }
  set emptyCellSymbol(t) {
    rt(t, this._config);
  }
  // Chart override methods that aren't supported
  /**
   * The heat chart's rotatedState (not supported)
   * @internal
   */
  get rotatedState() {
    return !1;
  }
  set rotatedState(t) {
  }
  setAssignToSecondValueAxis(t, r) {
  }
  set stackedType(t) {
  }
  set binTemporalData(t) {
  }
  set nullCategory(t) {
  }
  /**
   * Generates the default config for the heat chart
   * @private
   */
  generateDefaultConfig() {
    const t = at(this.commonStrings, h(this.layerInfo.layer).idField);
    return t.axes?.forEach((r, a) => {
      r && (r.valueFormat = {
        // use short date format for y axis labels
        intlOptions: { timeZone: void 0, dateStyle: a > 0 ? "long" : "medium" },
        type: "date"
      });
    }), t;
  }
}
i([
  e
], s.prototype, "yAxisField");
i([
  e
], s.prototype, "xTemporalBinning");
i([
  e
], s.prototype, "yTemporalBinning");
i([
  e
], s.prototype, "hideEmptyRowsAndColumns");
i([
  e
], s.prototype, "gridLineWidth");
i([
  e
], s.prototype, "gridLineColor");
i([
  e
], s.prototype, "seriesName");
i([
  e
], s.prototype, "heatRulesType");
i([
  e
], s.prototype, "gradientRules");
i([
  e
], s.prototype, "setGridLinesSymbol");
i([
  e
], s.prototype, "numericFields");
i([
  e
], s.prototype, "aggregationType");
i([
  e
], s.prototype, "splitByField");
i([
  e
], s.prototype, "legendPosition");
i([
  e
], s.prototype, "nullPolicy");
i([
  e
], s.prototype, "setSortOrder");
i([
  e
], s.prototype, "setXAxisSortOrder");
i([
  e
], s.prototype, "setYAxisSortOrder");
i([
  e
], s.prototype, "emptyCellText");
i([
  e
], s.prototype, "firstDayOfWeek");
i([
  e
], s.prototype, "emptyCellSymbol");
i([
  e
], s.prototype, "rotatedState");
i([
  e
], s.prototype, "setAssignToSecondValueAxis");
i([
  e
], s.prototype, "stackedType");
i([
  e
], s.prototype, "binTemporalData");
i([
  e
], s.prototype, "nullCategory");
export {
  s as HeatChartModel
};
