/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import { C as f, m as a } from "./model-setter.js";
import { k as b, s as m, a as _ } from "./utils.js";
import { e as h, f as S } from "./utils2.js";
import { C as L } from "./chart-model.js";
import { cloneDeep as T } from "lodash-es";
import "@arcgis/toolkit/type";
import { W as x } from "./series-types.js";
import { f as c } from "./rest-js-object-literals.js";
import "@arcgis/toolkit/intl";
import "luxon";
import "d3-array";
import { aO as C, aN as X, bI as p, aQ as B, i as A } from "./index.js";
import "@esri/arcgis-html-sanitizer";
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 "@arcgis/core/request.js";
import "./runtime.js";
import { c as M, b as O } from "./index4.js";
import "@arcgis/toolkit/dom";
import "@arcgis/core/intl.js";
import { G as g } from "./common.js";
var P = Object.defineProperty, D = Object.getOwnPropertyDescriptor, V = (t, e, i, s) => {
  for (var o = D(e, i), n = t.length - 1, d; n >= 0; n--)
    (d = t[n]) && (o = d(e, i, o) || o);
  return o && P(e, i, o), o;
};
const R = (t) => b({ config: t, axisIndex: 0, isMax: !0 }), E = (t, e) => {
  m({ config: t, value: e, axisIndex: 0, isMax: !0 });
};
class y extends f {
  /**
   * Maximum bound set for the x-axis.
   *
   * `null` indicates no explicit maximum.
   */
  get maxXBound() {
    return R(this._config);
  }
  set maxXBound(e) {
    E(this._config, e);
  }
}
V([
  a
], y.prototype, "maxXBound");
var W = Object.defineProperty, w = Object.getOwnPropertyDescriptor, F = (t, e, i, s) => {
  for (var o = w(e, i), n = t.length - 1, d; n >= 0; n--)
    (d = t[n]) && (o = d(e, i, o) || o);
  return o && W(e, i, o), o;
};
const j = (t) => b({ config: t, axisIndex: 0, isMax: !1 }), N = (t, e) => {
  m({ config: t, value: e, axisIndex: 0, isMax: !1 });
};
class v extends f {
  /**
   * Minimum bound set for the x-axis.
   *
   * `null` indicates no explicit minimum.
   */
  get minXBound() {
    return j(this._config);
  }
  set minXBound(e) {
    N(this._config, e);
  }
}
F([
  a
], v.prototype, "minXBound");
class $ extends f {
}
_($, [y, v]);
class De extends f {
  /**
   * Whether the x-axis labels are visible.
   */
  get xAxisLabelsVisibility() {
    return h(0, this._config);
  }
  set xAxisLabelsVisibility(e) {
    this.guardSetterFromAsyncOverwrite(() => {
      S(e, 0, this._config), this.emitConfigUpdate("xAxisLabelsVisibility");
    });
  }
}
const I = (t) => {
  for (const e of t.axes ?? [])
    for (const i of e?.guides ?? [])
      if (i.label !== void 0)
        return i.label;
}, Q = (t, e) => {
  for (const i of e.axes ?? [])
    for (const s of i?.guides ?? []) {
      const o = s.label?.text ?? "";
      s.label = T(t), s.label !== void 0 && (s.label.text = o);
    }
};
function r(t) {
  return {
    ...t,
    axis: t.orientation === g.X ? t.config.axes?.[0] : t.config.axes?.[1],
    index: t.index ?? 0,
    orientation: t.orientation ?? g.Y
  };
}
const U = (t) => {
  const { axis: e, index: i } = r(t);
  return e?.guides?.[i]?.visible ?? !0;
}, Y = (t) => {
  const { visible: e, axis: i, index: s } = r(t);
  i?.guides?.[s] !== void 0 && (i.guides[s].visible = e);
}, G = (t) => {
  const e = A(t.start, t.end);
  M(t.style) && e === c.SFS ? t.style = { type: c.SFS, color: t.style.color } : O(t.style) && e === c.SLS && (t.style = { type: c.SLS, color: t.style.color });
}, q = (t) => {
  const { axis: e, index: i } = r(t);
  return e?.guides?.[i]?.start ?? null;
}, z = (t) => {
  const { start: e, axis: i, index: s } = r(t);
  i?.guides?.[s] !== void 0 && (i.guides[s].start = e, G(i.guides[s]));
}, H = (t) => {
  const { axis: e, index: i } = r(t);
  return e?.guides?.[i]?.end;
}, J = (t) => {
  const { end: e, axis: i, index: s } = r(t);
  i?.guides?.[s] !== void 0 && (i.guides[s].end = e, G(i.guides[s]));
}, K = (t) => {
  const { axis: e, index: i } = r(t);
  return e?.guides?.[i]?.name;
}, Z = (t) => {
  const { name: e, axis: i, index: s } = r(t);
  i?.guides?.[s] !== void 0 && (i.guides[s].name = e);
}, k = (t) => {
  const { axis: e, index: i } = r(t);
  return e?.guides?.[i]?.label?.text;
}, ee = (t) => {
  const { labelText: e, axis: i, index: s } = r(t), o = i?.guides?.[s]?.label ?? C(e, X(p.GuideLabel), p.GuideLabel);
  i?.guides?.[s] !== void 0 && (i.guides[s].label = { ...o, text: e });
}, ie = (t) => {
  const { axis: e, index: i } = r(t);
  return e?.guides?.[i]?.above ?? !1;
}, te = (t) => {
  const { above: e, axis: i, index: s } = r(t);
  i?.guides?.[s] !== void 0 && (i.guides[s].above = e);
}, se = (t) => {
  const { axis: e, index: i } = r(t);
  return e?.guides?.[i]?.style;
}, oe = (t) => {
  const { style: e, axis: i, index: s } = r(t);
  i?.guides?.[s] !== void 0 && (i.guides[s].style = e);
}, Ve = (t) => {
  const { config: e, name: i, index: s, orientation: o } = t, n = o === g.X ? e.axes?.[0] : e.axes?.[1];
  if (n !== void 0) {
    n.guides = n.guides ?? [];
    const d = {
      type: x.Guide,
      name: i,
      start: n.valueFormat.type === x.DateAxisFormat ? "" : 0,
      style: B()
    };
    s !== void 0 && s < n.guides.length ? n.guides.splice(s, 0, d) : n.guides.push(d);
  }
}, Re = (t) => {
  const { config: e, index: i, orientation: s } = t, o = s === g.X ? e.axes?.[0] : e.axes?.[1];
  o?.guides !== void 0 && (i !== void 0 && i < o.guides.length ? o.guides.splice(i, 1) : o.guides.pop());
}, ne = (t) => {
  const { axis: e, index: i } = r(t);
  return e?.guides?.[i]?.tooltipReverseColor ?? !1;
}, re = (t) => {
  const { reverseColor: e, axis: i, index: s } = r(t);
  i?.guides?.[s] !== void 0 && (i.guides[s].tooltipReverseColor = e);
};
var de = Object.defineProperty, ae = Object.getOwnPropertyDescriptor, u = (t, e, i, s) => {
  for (var o = ae(e, i), n = t.length - 1, d; n >= 0; n--)
    (d = t[n]) && (o = d(e, i, o) || o);
  return o && de(e, i, o), o;
};
class l extends L {
  /**
   * The guide labels text symbol (font, color, style).
   */
  get guideLabelsSymbol() {
    return I(this._config);
  }
  set guideLabelsSymbol(e) {
    Q(e, this._config);
  }
  /**
   * Gets whether a guide is visible.
   *
   * @param index - Default `0`. The index of the guide in the list of guides for the given axis orientation.
   * @param orientation - Default `y`. The axis orientation of the guide.
   */
  getGuideVisibility(e, i) {
    return U({ config: this._config, index: e, orientation: i });
  }
  setGuideVisibility(e, i, s) {
    Y({ visible: e, config: this._config, index: i, orientation: s });
  }
  /**
   * Gets the start value of a guide.
   *
   * @param index - Default `0`. The index of the guide in the list of guides for the given axis orientation.
   * @param orientation - Default `y`. The axis orientation of the guide.
   */
  getGuideStart(e, i) {
    return q({ config: this._config, index: e, orientation: i });
  }
  setGuideStart(e, i, s) {
    z({ start: e, config: this._config, index: i, orientation: s });
  }
  /**
   * Gets the end value of a guide.
   *
   * @param index - Default `0`. The index of the guide in the list of guides for the given axis orientation.
   * @param orientation - Default `y`. The axis orientation of the guide.
   */
  getGuideEnd(e, i) {
    return H({ config: this._config, index: e, orientation: i });
  }
  setGuideEnd(e, i, s) {
    J({ end: e, config: this._config, index: i, orientation: s });
  }
  /**
   * Gets the name of a guide.
   *
   * @param index - Default `0`. The index of the guide in the list of guides for the given axis orientation.
   * @param orientation - Default `y`. The axis orientation of the guide.
   */
  getGuideName(e, i) {
    return K({ config: this._config, index: e, orientation: i });
  }
  setGuideName(e, i, s) {
    Z({ name: e, config: this._config, index: i, orientation: s });
  }
  /**
   * Gets the guide label text.
   *
   * @param index - Default `0`. The index of the guide in the list of guides for the given axis orientation.
   * @param orientation - Default `y`. The axis orientation of the guide.
   */
  getGuideLabelText(e, i) {
    return k({ config: this._config, index: e, orientation: i });
  }
  setGuideLabelText(e, i, s) {
    ee({ labelText: e, config: this._config, index: i, orientation: s });
  }
  /**
   * Gets whether the guide should be rendered above the other chart elements.
   *
   * @param index - Default `0`. The index of the guide in the list of guides for the given axis orientation.
   * @param orientation - Default `y`. The axis orientation of the guide.
   */
  getGuideAbove(e, i) {
    return ie({ config: this._config, index: e, orientation: i });
  }
  setGuideAbove(e, i, s) {
    te({ above: e, config: this._config, index: i, orientation: s });
  }
  /**
   * Gets the guide style.
   *
   * @param index - Default `0`. The index of the guide in the list of guides for the given axis orientation.
   * @param orientation - Default `y`. The axis orientation of the guide.
   */
  getGuideStyle(e, i) {
    return se({ config: this._config, index: e, orientation: i });
  }
  setGuideStyle(e, i, s) {
    oe({ style: e, config: this._config, index: i, orientation: s });
  }
  /**
   * Gets whether the tooltip text color should be reversed for a guide.
   *
   * @param index - The index of the guide in the list of guides for the given axis orientation.
   * @param orientation - The axis orientation of the guide.
   */
  getTooltipReverseColor(e, i) {
    return ne({ config: this._config, index: e, orientation: i });
  }
  setTooltipReverseColor(e, i, s) {
    re({ reverseColor: e, config: this._config, index: i, orientation: s });
  }
}
u([
  a
], l.prototype, "guideLabelsSymbol");
u([
  a
], l.prototype, "setGuideVisibility");
u([
  a
], l.prototype, "setGuideStart");
u([
  a
], l.prototype, "setGuideEnd");
u([
  a
], l.prototype, "setGuideName");
u([
  a
], l.prototype, "setGuideLabelText");
u([
  a
], l.prototype, "setGuideAbove");
u([
  a
], l.prototype, "setGuideStyle");
u([
  a
], l.prototype, "setTooltipReverseColor");
export {
  l as M,
  De as W,
  Ve as a,
  $ as b,
  Re as d
};
