import { au as J, G as K, m as I, a0 as ee, a6 as te, a1 as V, aX as se, a as ie, a3 as ae, e as ne, V as q, aY as oe, aZ as re, L as E, T as R, aW as y, x as le } from "./am-chart.H2jnOzFc.js";
import { A as de, aV as ve, aU as Te, at as Ae, as as be, a$ as Ne, Q as ye, a_ as De, b0 as Pe, av as we, X as Ie } from "./am-chart.H2jnOzFc.js";
import { S as $ } from "./Scrollbar.BdZVb_Z-.js";
import { B as Fe } from "./BaseColumnSeries.C7jwOxIJ.js";
import { C as z } from "./EditableAxisLabel.wN0t_G2B.js";
import { E as Se } from "./EditableAxisLabel.wN0t_G2B.js";
import { C as W, a as Q } from "./CandlestickSeries.CkXGtRWE.js";
import { A as Le, G as Me } from "./CandlestickSeries.CkXGtRWE.js";
import { A as ke } from "./AxisLabelRadial.Bs1P_q_F.js";
import { C as Ge } from "./ColumnSeries.DGazbfza.js";
import { c as j, a as B } from "./MonotoneXTension.CJMEHHj3.js";
import { c as H } from "./cardinal.BCA_LB0u.js";
function Z(l, t) {
  this._context = l, this._t = t;
}
Z.prototype = {
  areaStart: function() {
    this._line = 0;
  },
  areaEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._x = this._y = NaN, this._point = 0;
  },
  lineEnd: function() {
    0 < this._t && this._t < 1 && this._point === 2 && this._context.lineTo(this._x, this._y), (this._line || this._line !== 0 && this._point === 1) && this._context.closePath(), this._line >= 0 && (this._t = 1 - this._t, this._line = 1 - this._line);
  },
  point: function(l, t) {
    switch (l = +l, t = +t, this._point) {
      case 0:
        this._point = 1, this._line ? this._context.lineTo(l, t) : this._context.moveTo(l, t);
        break;
      case 1:
        this._point = 2;
      // falls through
      default: {
        if (this._t <= 0)
          this._context.lineTo(this._x, t), this._context.lineTo(l, t);
        else {
          var e = this._x * (1 - this._t) + l * this._t;
          this._context.lineTo(e, this._y), this._context.lineTo(e, t);
        }
        break;
      }
    }
    this._x = l, this._y = t;
  }
};
function he(l) {
  return new Z(l, 1);
}
class Y extends $ {
  constructor() {
    super(...arguments), this.chart = this.children.push(J.new(this._root, {
      themeTags: ["chart"],
      interactive: !1,
      interactiveChildren: !1,
      panX: !1,
      panY: !1,
      wheelX: "none",
      wheelY: "none"
    })), this.overlay = this.children.push(K.new(this._root, {
      themeTags: ["overlay"],
      interactive: !1
    }));
  }
  _afterNew() {
    this._addOrientationClass(), this._settings.themeTags = I(this._settings.themeTags, ["scrollbar", "xy", "chart", this._settings.orientation]);
    const t = this.children;
    t.moveValue(this.thumb), t.moveValue(this.startGrip), t.moveValue(this.endGrip), this.thumb.set("opacity", 0), this.thumb.states.create("hover", { opacity: 0.2 });
    const e = this.chart.plotContainer;
    e.set("interactive", !1), e.remove("background"), e.children.removeValue(this.chart.zoomOutButton), super._afterNew();
  }
  _updateThumb() {
    super._updateThumb(), this.overlay.set("draw", (t) => {
      const e = this.startGrip, s = this.endGrip;
      let i = e.x(), a = e.y(), n = s.x(), o = s.y();
      const r = this.height(), h = this.width();
      i > n && ([i, n] = [n, i]), a > o && ([a, o] = [o, a]), this.get("orientation") === "horizontal" ? (t.moveTo(0, 0), t.lineTo(i, 0), t.lineTo(i, r), t.lineTo(0, r), t.lineTo(0, 0), t.moveTo(n, 0), t.lineTo(h, 0), t.lineTo(h, r), t.lineTo(n, r), t.lineTo(n, 0)) : (t.moveTo(0, 0), t.lineTo(0, a), t.lineTo(h, a), t.lineTo(h, 0), t.lineTo(0, 0), t.moveTo(0, o), t.lineTo(0, r), t.lineTo(h, r), t.lineTo(h, o), t.lineTo(0, o));
    });
  }
}
Y.className = "XYChartScrollbar";
Y.classNames = $.classNames.concat([Y.className]);
class S extends z {
  constructor() {
    super(...arguments), this._frequency = 1, this._itemMap = {};
  }
  _afterNew() {
    this._settings.themeTags = I(this._settings.themeTags, ["axis"]), this.fields.push("category"), super._afterNew();
  }
  _prepareAxisItems() {
    this.setPrivateRaw("baseInterval", this.get("baseInterval"));
    const t = this.get("renderer"), e = this.dataItems.length;
    let s = this.startIndex();
    s > 0 && s--;
    let i = this.endIndex();
    i < e && i++;
    let a = t.axisLength() / Math.max(t.get("minGridDistance"), 1 / Number.MAX_SAFE_INTEGER), n = Math.min(e, Math.ceil((i - s) / a));
    s = Math.floor(s / n) * n, this._frequency = n;
    for (let m = 0; m < e; m++)
      this._toggleDataItem(this.dataItems[m], !1);
    let o = Number(this.dataItems[s].get("category")), r = Number(this.dataItems[i - 1].get("category")), h = r - o;
    i - s < a && (h = r - o - ((r - o) / this.baseDuration() - (i - s)) * this.baseDuration());
    let c = ee(0, h, a, this.get("gridIntervals"));
    const A = te(c.timeUnit), b = this.getPrivate("baseInterval");
    V(c) < this.baseDuration() && (c = Object.assign({}, b));
    const P = this.get("dateFormats");
    let u = -1 / 0, _ = -1 / 0, d = -1 / 0, x, g = [], v = !1;
    for (let m = s; m < i; m++) {
      let T = this.dataItems[m], f = T.get("index"), w = !1, D = Number(T.get("category")), N = new Date(D), p = se(N, c.timeUnit);
      x = P[c.timeUnit];
      let G = !1;
      c.timeUnit != "year" && c.timeUnit != "week" && A && this.get("markUnitChange") && ie(u) && ae(D, u, A, this._root.utc) && (x = this.get("periodChangeDateFormats")[c.timeUnit], f - n * 0.5 < _ && g.pop(), g.push({ format: x, dataItem: T }), v = !0, G = !0, _ = f, d = p);
      let F = !1;
      c.timeUnit === "day" || c.timeUnit === "week" ? f - _ >= n && (F = !0) : p % c.count === 0 && p != d && (F = !0), !G && F && (f - n * 0.7 < _ && v && (w = !0), w || (g.push({ format: x, dataItem: T }), _ = f, d = p), v = !1), u = D;
    }
    if (g.length > 0) {
      let m = g[0].dataItem.get("index", 0);
      ne(g, (T) => {
        const f = T.dataItem, w = T.format;
        this._createAssets(f, []), this._toggleDataItem(f, !0);
        let D = Number(f.get("category")), N = new Date(D);
        const p = f.get("label");
        p && p.set("text", this._root.dateFormatter.format(N, w)), m++, this._prepareDataItem(f, m, n);
      });
    }
  }
  /**
   * Returns a duration of currently active `baseInterval` in milliseconds.
   *
   * @return Duration
   */
  baseDuration() {
    return V(this.getPrivate("baseInterval"));
  }
  /**
   * Returns text to be used in an axis tooltip for specific relative position.
   *
   * @param   position  Position
   * @return            Tooltip text
   */
  getTooltipText(t, e) {
    let s = this.dataItems[this.axisPositionToIndex(t)];
    if (s) {
      let i = this.get("dateFormats")[this.getPrivate("baseInterval").timeUnit];
      return this._root.dateFormatter.format(new Date(s.get("category", 0)), this.get("tooltipDateFormat", i));
    }
  }
  _updateTooltipText(t, e) {
    t.label.set("text", this.getTooltipText(e));
  }
}
S.className = "CategoryDateAxis";
S.classNames = z.classNames.concat([S.className]);
class C extends q {
  constructor() {
    super(...arguments), this._dataGrouped = !1, this._groupingCalculated = !1, this._intervalDuration = 1;
  }
  _afterNew() {
    this._settings.themeTags = I(this._settings.themeTags, ["axis"]), super._afterNew();
  }
  _adjustMinMax(t, e, s, i) {
    let a;
    const n = this.getDurationFormatter(), o = this.get("baseUnit");
    if (this.setRaw("maxPrecision", 0), o == "millisecond" || o == "second" || o == "minute" || o == "hour") {
      s <= 1 && (s = 1), s = Math.round(s);
      let r = e - t;
      r === 0 && (r = Math.abs(e));
      let h = r / s, c = [60, 30, 20, 15, 10, 2, 1], A = 1;
      o == "hour" && (c = [24, 12, 6, 4, 2, 1]);
      for (let x of c)
        if (r / x > s) {
          A = x;
          break;
        }
      let b = Math.ceil((e - t) / A / s), P = Math.log(Math.abs(b)) * Math.LOG10E, u = Math.pow(10, Math.floor(P)) / 10, _ = b / u;
      b = oe(c, _) * u, h = A * b, t = Math.floor(t / h) * h, e = Math.ceil(e / h) * h, a = { min: t, max: e, step: h };
    } else
      a = super._adjustMinMax(t, e, s, i);
    return this.setPrivateRaw("durationFormat", n.getFormat(a.step, a.max, o)), a;
  }
  _formatText(t) {
    return this.getDurationFormatter().format(t, this.getPrivate("durationFormat"), this.get("baseUnit"));
  }
  /**
   * Returns text to be used in an axis tooltip for specific relative position.
   *
   * @param   position  Position
   * @return            Tooltip text
   */
  getTooltipText(t, e) {
    const s = this.getDurationFormatter(), i = this.get("extraTooltipPrecision", 0), a = this.getPrivate("stepDecimalPlaces", 0) + i, n = re(this.positionToValue(t), a);
    return s.format(n, this.getPrivate("durationFormat"), this.get("baseUnit"));
  }
}
C.className = "DurationAxis";
C.classNames = q.classNames.concat([C.className]);
class X extends W {
  _draw() {
    const t = this._display;
    t.moveTo(this.get("lowX1", 0), this.get("lowY1", 0)), t.lineTo(this.get("highX1", 0), this.get("highY1", 0));
    let e = this.width(), s = this.height();
    if (this.get("orientation") == "vertical") {
      let i = s, a = 0;
      t.moveTo(0, i), t.lineTo(e / 2, i), t.moveTo(e / 2, a), t.lineTo(e, a);
    } else {
      let i = 0, a = e;
      t.moveTo(i, 0), t.lineTo(i, s / 2), t.moveTo(a, s / 2), t.lineTo(a, s);
    }
  }
}
X.className = "OHLC";
X.classNames = W.classNames.concat([X.className]);
class L extends Q {
  constructor() {
    super(...arguments), this.columns = this.addDisposer(new E(R.new({
      themeTags: ["autocolor"]
    }), () => X._new(this._root, {
      themeTags: I(this.columns.template.get("themeTags", []), ["ohlc", "series", "column"])
    }, [this.columns.template])));
  }
  /**
   * @ignore
   */
  makeColumn(t, e) {
    const s = this.mainContainer.children.push(e.make());
    return s._setDataItem(t), e.push(s), s;
  }
  _processAxisRange(t) {
    super._processAxisRange(t), t.columns = new E(R.new({}), () => X._new(this._root, {
      themeTags: I(t.columns.template.get("themeTags", []), ["ohlc", "series", "column"])
    }, [this.columns.template, t.columns.template]));
  }
}
L.className = "OHLCSeries";
L.classNames = Q.classNames.concat([L.className]);
class M extends y {
  _afterNew() {
    this._setDefault("curveFactory", j(this.get("tension", 0.5))), super._afterNew();
  }
  _updateChildren() {
    this.isDirty("tension") && (this.set("curveFactory", j(this.get("tension", 0.5))), this._valuesDirty = !0), super._updateChildren();
  }
}
M.className = "SmoothedYLineSeries";
M.classNames = y.classNames.concat([M.className]);
class O extends y {
  _afterNew() {
    this._setDefault("curveFactory", B(this.get("tension", 0.5))), super._afterNew();
  }
  _updateChildren() {
    this.isDirty("tension") && (this.set("curveFactory", B(this.get("tension", 0.5))), this._valuesDirty = !0), super._updateChildren();
  }
}
O.className = "SmoothedXLineSeries";
O.classNames = y.classNames.concat([O.className]);
class k extends y {
  _afterNew() {
    this._setDefault("curveFactory", H.tension(this.get("tension", 0.5))), super._afterNew();
  }
  _updateChildren() {
    this.isDirty("tension") && (this.set("curveFactory", H.tension(this.get("tension", 0.5))), this._valuesDirty = !0), super._updateChildren();
  }
}
k.className = "SmoothedXYLineSeries";
k.classNames = y.classNames.concat([k.className]);
class U extends y {
  _afterNew() {
    this._setDefault("curveFactory", he), super._afterNew();
  }
  _getPoints(t, e) {
    let s = e.points, i = this.get("stepWidth", le).value / 2, a = t.get("locationX", e.locationX), n = t.get("locationY", e.locationY), o = a, r = n;
    e.baseAxis === e.xAxis ? (a -= i, o += i) : e.baseAxis === e.yAxis && (n -= i, r += i);
    let h = e.xAxis.getDataItemPositionX(t, e.xField, a, e.vcx), c = e.yAxis.getDataItemPositionY(t, e.yField, n, e.vcy), A = e.xAxis.getDataItemPositionX(t, e.xField, o, e.vcx), b = e.yAxis.getDataItemPositionY(t, e.yField, r, e.vcy);
    if (this._shouldInclude(h)) {
      const P = this.getPoint(h, c), u = [P.x, P.y], _ = this.getPoint(A, b), d = [_.x, _.y];
      if (e.fillVisible) {
        let x = h, g = c, v = A, m = b;
        if (e.baseAxis === e.xAxis ? (g = e.basePosY, m = e.basePosY) : e.baseAxis === e.yAxis && (x = e.basePosX, v = e.basePosX), e.getOpen) {
          let w = t.get(e.xOpenField), D = t.get(e.yOpenField);
          if (w != null && D != null)
            if (a = t.get("openLocationX", e.openLocationX), n = t.get("openLocationY", e.openLocationY), o = a, r = n, e.baseAxis === e.xAxis ? (a -= i, o += i) : e.baseAxis === e.yAxis && (n -= i, r += i), e.stacked) {
              let N = t.get("stackToItemX"), p = t.get("stackToItemY");
              N ? (x = e.xAxis.getDataItemPositionX(N, e.xField, a, N.component.get("vcx")), v = e.xAxis.getDataItemPositionX(N, e.xField, o, N.component.get("vcx"))) : e.yAxis === e.baseAxis ? (x = e.basePosX, v = e.basePosX) : e.baseAxis === e.yAxis && (x = e.xAxis.getDataItemPositionX(t, e.xOpenField, a, e.vcx), v = e.xAxis.getDataItemPositionX(t, e.xOpenField, o, e.vcx)), p ? (g = e.yAxis.getDataItemPositionY(p, e.yField, n, p.component.get("vcy")), m = e.yAxis.getDataItemPositionY(p, e.yField, r, p.component.get("vcy"))) : e.xAxis === e.baseAxis ? (g = e.basePosY, m = e.basePosY) : e.baseAxis === e.yAxis && (g = e.yAxis.getDataItemPositionY(t, e.yOpenField, n, e.vcy), m = e.yAxis.getDataItemPositionY(t, e.yOpenField, r, e.vcy));
            } else
              x = e.xAxis.getDataItemPositionX(t, e.xOpenField, a, e.vcx), g = e.yAxis.getDataItemPositionY(t, e.yOpenField, n, e.vcy), v = e.xAxis.getDataItemPositionX(t, e.xOpenField, o, e.vcx), m = e.yAxis.getDataItemPositionY(t, e.yOpenField, r, e.vcy);
        }
        let T = this.getPoint(x, g), f = this.getPoint(v, m);
        u[2] = T.x, u[3] = T.y, d[2] = f.x, d[3] = f.y;
      }
      s.push(u), s.push(d), t.set("point", { x: u[0] + (d[0] - u[0]) / 2, y: u[1] + (d[1] - u[1]) / 2 });
    }
    this.get("noRisers") && (e.points = [], e.segments.push(s));
  }
}
U.className = "StepLineSeries";
U.classNames = y.classNames.concat([U.className]);
export {
  de as Axis,
  Le as AxisBullet,
  ve as AxisLabel,
  ke as AxisLabelRadial,
  Te as AxisRenderer,
  Ae as AxisRendererX,
  be as AxisRendererY,
  Ne as AxisTick,
  Fe as BaseColumnSeries,
  W as Candlestick,
  Q as CandlestickSeries,
  z as CategoryAxis,
  S as CategoryDateAxis,
  Ge as ColumnSeries,
  ye as DateAxis,
  De as DefaultTheme,
  C as DurationAxis,
  Se as EditableAxisLabel,
  Me as GaplessDateAxis,
  Pe as Grid,
  y as LineSeries,
  X as OHLC,
  L as OHLCSeries,
  O as SmoothedXLineSeries,
  k as SmoothedXYLineSeries,
  M as SmoothedYLineSeries,
  U as StepLineSeries,
  q as ValueAxis,
  J as XYChart,
  Y as XYChartScrollbar,
  we as XYCursor,
  Ie as XYSeries
};
