import { D as gt, x as P, al as dt, H as et, q as b, am as pt, aF as ot, J as ht, C as tt, e as v, _ as V, a as G, v as _t, b1 as rt, P as ft, b2 as mt, r as A, L as R, T as M, m as W, aG as ct, p as yt, j as w, h as T, G as $, aj as J, b3 as k, b as bt } from "./am-chart.H2jnOzFc.js";
import { S as xt } from "./Slice.DiEswWa6.js";
import { R as kt } from "./RadialLabel.DyVOf2K8.js";
class vt extends gt {
  setupDefaultRules() {
    super.setupDefaultRules();
    const e = this._root.interfaceColors, t = this.rule.bind(this);
    t("PercentSeries").setAll({
      legendLabelText: "{category}",
      legendValueText: "{valuePercentTotal.formatNumber('0.00p')}",
      colors: dt.new(this._root, {}),
      width: P,
      height: P
    }), t("PieChart").setAll({
      radius: et(80),
      startAngle: -90,
      endAngle: 270
    }), t("PieSeries").setAll({
      alignLabels: !0,
      startAngle: -90,
      endAngle: 270
    }), t("PieSeries").states.create("hidden", { endAngle: -90, opacity: 0 }), t("Slice", ["pie"]).setAll({
      position: "absolute",
      isMeasured: !1,
      x: 0,
      y: 0,
      toggleKey: "active",
      tooltipText: "{category}: {valuePercentTotal.formatNumber('0.00p')}",
      strokeWidth: 1,
      strokeOpacity: 1,
      role: "figure",
      lineJoin: "round"
    }), t("Slice", ["pie"]).states.create("active", { shiftRadius: 20, scale: 1 }), t("Slice", ["pie"]).states.create("hoverActive", { scale: 1.04 }), t("Slice", ["pie"]).states.create("hover", { scale: 1.04 }), t("RadialLabel", ["pie"]).setAll({
      textType: "aligned",
      radius: 10,
      text: "{category}: {valuePercentTotal.formatNumber('0.00p')}",
      paddingTop: 5,
      paddingBottom: 5,
      populateText: !0
    }), t("Tick", ["pie"]).setAll({
      location: 1
    }), t("SlicedChart").setAll({
      paddingLeft: 10,
      paddingRight: 10,
      paddingTop: 10,
      paddingBottom: 10
    }), t("FunnelSeries").setAll({
      startLocation: 0,
      endLocation: 1,
      orientation: "vertical",
      alignLabels: !0,
      sequencedInterpolation: !0
    }), t("FunnelSlice").setAll({
      interactive: !0,
      expandDistance: 0
      //tooltipText: "{category}: {valuePercentTotal.formatNumber('0.00p')}"
    }), t("FunnelSlice").states.create("hover", { expandDistance: 0.15 }), t("Label", ["funnel"]).setAll({
      populateText: !0,
      text: "{category}: {valuePercentTotal.formatNumber('0.00p')}",
      centerY: b
    }), t("Label", ["funnel", "horizontal"]).setAll({
      centerX: 0,
      centerY: b,
      rotation: -90
    }), t("Label", ["funnel", "vertical"]).setAll({
      centerY: b,
      centerX: 0
    }), t("Tick", ["funnel"]).setAll({
      location: 1
    }), t("FunnelSlice", ["funnel", "link"]).setAll({
      fillOpacity: 0.5,
      strokeOpacity: 0,
      expandDistance: -0.1
    }), t("FunnelSlice", ["funnel", "link", "vertical"]).setAll({
      height: 10
    }), t("FunnelSlice", ["funnel", "link", "horizontal"]).setAll({
      width: 10
    }), t("PyramidSeries").setAll({
      valueIs: "area"
    }), t("FunnelSlice", ["pyramid", "link"]).setAll({
      fillOpacity: 0.5
    }), t("FunnelSlice", ["pyramid", "link", "vertical"]).setAll({
      height: 0
    }), t("FunnelSlice", ["pyramid", "link", "horizontal"]).setAll({
      width: 0
    }), t("FunnelSlice", ["pyramid"]).setAll({
      interactive: !0,
      expandDistance: 0
    }), t("FunnelSlice", ["pyramid"]).states.create("hover", { expandDistance: 0.15 }), t("Label", ["pyramid"]).setAll({
      populateText: !0,
      text: "{category}: {valuePercentTotal.formatNumber('0.00p')}",
      centerY: b
    }), t("Label", ["pyramid", "horizontal"]).setAll({
      centerX: 0,
      centerY: b,
      rotation: -90
    }), t("Label", ["pyramid", "vertical"]).setAll({
      centerY: b,
      centerX: 0
    }), t("Tick", ["pyramid"]).setAll({
      location: 1
    }), t("FunnelSlice", ["pictorial"]).setAll({
      interactive: !0,
      tooltipText: "{category}: {valuePercentTotal.formatNumber('0.00p')}"
    }), t("Label", ["pictorial"]).setAll({
      populateText: !0,
      text: "{category}: {valuePercentTotal.formatNumber('0.00p')}",
      centerY: b
    }), t("Label", ["pictorial", "horizontal"]).setAll({
      centerX: 0,
      centerY: b,
      rotation: -90
    }), t("Label", ["pictorial", "vertical"]).setAll({
      centerY: b,
      centerX: 0
    }), t("FunnelSlice", ["pictorial", "link"]).setAll({
      fillOpacity: 0.5,
      width: 0,
      height: 0
    }), t("Tick", ["pictorial"]).setAll({
      location: 0.5
    });
    {
      const s = t("Graphics", ["pictorial", "background"]);
      s.setAll({
        fillOpacity: 0.2
      }), pt(s, "fill", e, "alternativeBackground");
    }
  }
}
class H extends ot {
  _afterNew() {
    this._defaultThemes.push(vt.new(this._root)), super._afterNew(), this.chartContainer.children.push(this.seriesContainer), this.seriesContainer.children.push(this.bulletsContainer);
  }
  _processSeries(e) {
    super._processSeries(e), this.seriesContainer.children.moveValue(this.bulletsContainer, this.seriesContainer.children.length - 1);
  }
}
H.className = "PercentChart";
H.classNames = ot.classNames.concat([H.className]);
class X extends ht {
  constructor() {
    super(...arguments), this.slicesContainer = this.children.push(tt.new(this._root, { position: "absolute", isMeasured: !1 })), this.labelsContainer = this.children.push(tt.new(this._root, { position: "absolute", isMeasured: !1 })), this.ticksContainer = this.children.push(tt.new(this._root, { position: "absolute", isMeasured: !1 })), this._lLabels = [], this._rLabels = [], this._hLabels = [], this.slices = this.addDisposer(this._makeSlices()), this.labels = this.addDisposer(this._makeLabels()), this.ticks = this.addDisposer(this._makeTicks());
  }
  _applyThemes(e = !1) {
    const t = this.get("colors");
    return t && t.reset(), super._applyThemes(e);
  }
  /**
   * @ignore
   */
  makeSlice(e) {
    const t = this.slicesContainer.children.push(this.slices.make());
    return t.on("fill", () => {
      this.updateLegendMarker(e);
    }), t.on("fillPattern", () => {
      this.updateLegendMarker(e);
    }), t.on("stroke", () => {
      this.updateLegendMarker(e);
    }), t._setDataItem(e), e.set("slice", t), this.slices.push(t), t;
  }
  /**
   * @ignore
   */
  makeLabel(e) {
    const t = this.labelsContainer.children.push(this.labels.make());
    return t._setDataItem(e), e.set("label", t), this.labels.push(t), t;
  }
  _shouldMakeBullet(e) {
    return e.get("value") != null;
  }
  /**
   * @ignore
   */
  makeTick(e) {
    const t = this.ticksContainer.children.push(this.ticks.make());
    return t._setDataItem(e), e.set("tick", t), this.ticks.push(t), t;
  }
  _afterNew() {
    this.fields.push("category", "fill"), super._afterNew();
  }
  _onDataClear() {
    const e = this.get("colors");
    e && e.reset();
    const t = this.get("patterns");
    t && t.reset();
  }
  _prepareChildren() {
    if (super._prepareChildren(), this._lLabels = [], this._rLabels = [], this._hLabels = [], this._valuesDirty) {
      let e = 0, t = 0, s = 0, i = 1 / 0, l = 0;
      v(this._dataItems, (a) => {
        let n = a.get("valueWorking", 0);
        e += n, t += Math.abs(n);
      }), v(this._dataItems, (a) => {
        let n = a.get("valueWorking", 0);
        n > s && (s = n), n < i && (i = n), l++;
        let r = n / t;
        t == 0 && (r = 0), a.setRaw("valuePercentTotal", r * 100);
      }), this.setPrivateRaw("valueLow", i), this.setPrivateRaw("valueHigh", s), this.setPrivateRaw("valueSum", e), this.setPrivateRaw("valueAverage", e / l), this.setPrivateRaw("valueAbsoluteSum", t);
    }
  }
  /**
   * Shows hidden series.
   *
   * @param   duration  Animation duration in milliseconds
   * @return            Animation promise
   */
  show(e) {
    const t = Object.create(null, {
      show: { get: () => super.show }
    });
    return V(this, void 0, void 0, function* () {
      let s = [];
      s.push(t.show.call(this, e)), s.push(this._sequencedShowHide(!0, e)), yield Promise.all(s);
    });
  }
  /**
   * Hide whole series.
   *
   * @param   duration  Animation duration in milliseconds
   * @return            Animation promise
   */
  hide(e) {
    const t = Object.create(null, {
      hide: { get: () => super.hide }
    });
    return V(this, void 0, void 0, function* () {
      let s = [];
      s.push(t.hide.call(this, e)), s.push(this._sequencedShowHide(!1, e)), yield Promise.all(s);
    });
  }
  /**
   * @ignore
   */
  _updateChildren() {
    super._updateChildren(), this._valuesDirty && v(this._dataItems, (e) => {
      e.get("label").text.markDirtyText();
    }), (this.isDirty("legendLabelText") || this.isDirty("legendValueText")) && v(this._dataItems, (e) => {
      this.updateLegendValue(e);
    }), this._arrange();
  }
  _arrange() {
    this._arrangeDown(this._lLabels), this._arrangeUp(this._lLabels), this._arrangeDown(this._rLabels), this._arrangeUp(this._rLabels), this._arrangeLeft(this._hLabels), this._arrangeRight(this._hLabels), v(this.dataItems, (e) => {
      this._updateTick(e);
    });
  }
  _afterChanged() {
    super._afterChanged(), this._arrange();
  }
  processDataItem(e) {
    if (super.processDataItem(e), e.get("fill") == null) {
      let t = this.get("colors");
      t && e.setRaw("fill", t.next());
    }
    if (e.get("fillPattern") == null) {
      let t = this.get("patterns");
      t && e.setRaw("fillPattern", t.next());
    }
  }
  /**
   * Shows series's data item.
   *
   * @param   dataItem  Data item
   * @param   duration  Animation duration in milliseconds
   * @return            Promise
   */
  showDataItem(e, t) {
    const s = Object.create(null, {
      showDataItem: { get: () => super.showDataItem }
    });
    return V(this, void 0, void 0, function* () {
      const i = [s.showDataItem.call(this, e, t)];
      G(t) || (t = this.get("stateAnimationDuration", 0));
      const l = this.get("stateAnimationEasing");
      let a = e.get("value");
      const n = e.animate({ key: "valueWorking", to: a, duration: t, easing: l });
      n && i.push(n.waitForStop());
      const r = e.get("tick");
      r && i.push(r.show(t));
      const c = e.get("label");
      c && i.push(c.show(t));
      const o = e.get("slice");
      o && i.push(o.show(t)), o.get("active") && o.states.applyAnimate("active"), yield Promise.all(i);
    });
  }
  /**
   * Hides series's data item.
   *
   * @param   dataItem  Data item
   * @param   duration  Animation duration in milliseconds
   * @return            Promise
   */
  hideDataItem(e, t) {
    const s = Object.create(null, {
      hideDataItem: { get: () => super.hideDataItem }
    });
    return V(this, void 0, void 0, function* () {
      const i = [s.hideDataItem.call(this, e, t)], l = this.states.create("hidden", {});
      G(t) || (t = l.get("stateAnimationDuration", this.get("stateAnimationDuration", 0)));
      const a = l.get("stateAnimationEasing", this.get("stateAnimationEasing")), n = e.animate({ key: "valueWorking", to: 0, duration: t, easing: a });
      n && i.push(n.waitForStop());
      const r = e.get("tick");
      r && i.push(r.hide(t));
      const c = e.get("label");
      c && i.push(c.hide(t));
      const o = e.get("slice");
      o.hideTooltip(), o && i.push(o.hide(t)), yield Promise.all(i);
    });
  }
  /**
   * @ignore
   */
  disposeDataItem(e) {
    super.disposeDataItem(e);
    let t = e.get("label");
    t && (this.labels.removeValue(t), t.dispose());
    let s = e.get("tick");
    s && (this.ticks.removeValue(s), s.dispose());
    let i = e.get("slice");
    i && (this.slices.removeValue(i), i.dispose());
  }
  /**
   * Triggers hover on a series data item.
   *
   * @since 5.0.7
   * @param  dataItem  Target data item
   */
  hoverDataItem(e) {
    const t = e.get("slice");
    t && !t.isHidden() && t.hover();
  }
  /**
   * Triggers un-hover on a series data item.
   *
   * @since 5.0.7
   * @param  dataItem  Target data item
   */
  unhoverDataItem(e) {
    const t = e.get("slice");
    t && t.unhover();
  }
  /**
   * @ignore
   */
  updateLegendMarker(e) {
    if (e) {
      const t = e.get("slice");
      if (t) {
        const s = e.get("legendDataItem");
        if (s) {
          const i = s.get("markerRectangle");
          v(_t, (l) => {
            t.get(l) != null && i.set(l, t.get(l));
          });
        }
      }
    }
  }
  _arrangeDown(e) {
    if (e) {
      let t = this._getNextDown();
      e.sort((s, i) => s.y > i.y ? 1 : s.y < i.y ? -1 : 0), v(e, (s) => {
        const i = s.label.adjustedLocalBounds();
        let l = i.top;
        s.y + l < t && (s.y = t - l), s.label.set("y", s.y), t = s.y + i.bottom;
      });
    }
  }
  _getNextUp() {
    return this.labelsContainer.maxHeight();
  }
  _getNextDown() {
    return 0;
  }
  _arrangeUp(e) {
    if (e) {
      let t = this._getNextUp();
      e.sort((s, i) => s.y < i.y ? 1 : s.y > i.y ? -1 : 0), v(e, (s) => {
        const i = s.label.adjustedLocalBounds();
        let l = i.bottom;
        s.y + l > t && (s.y = t - l), s.label.set("y", s.y), t = s.y + i.top;
      });
    }
  }
  _arrangeRight(e) {
    if (e) {
      let t = 0;
      e.sort((s, i) => s.y > i.y ? 1 : s.y < i.y ? -1 : 0), v(e, (s) => {
        const i = s.label.adjustedLocalBounds();
        let l = i.left;
        s.y + l < t && (s.y = t - l), s.label.set("x", s.y), t = s.y + i.right;
      });
    }
  }
  _arrangeLeft(e) {
    if (e) {
      let t = this.labelsContainer.maxWidth();
      e.sort((s, i) => s.y < i.y ? 1 : s.y > i.y ? -1 : 0), v(e, (s) => {
        const i = s.label.adjustedLocalBounds();
        let l = i.right;
        s.y + l > t && (s.y = t - l), s.label.set("x", s.y), t = s.y + i.left;
      });
    }
  }
  _updateSize() {
    super._updateSize(), this.markDirty();
  }
  _updateTick(e) {
  }
  _dispose() {
    super._dispose();
    const e = this.chart;
    e && e.series.removeValue(this);
  }
}
X.className = "PercentSeries";
X.classNames = ht.classNames.concat([X.className]);
class st extends H {
  constructor() {
    super(...arguments), this._maxRadius = 1;
  }
  _afterNew() {
    super._afterNew(), this.seriesContainer.setAll({ x: b, y: b });
  }
  _prepareChildren() {
    super._prepareChildren();
    const e = this.chartContainer, t = e.innerWidth(), s = e.innerHeight(), i = this.get("startAngle", 0), l = this.get("endAngle", 0), a = this.get("innerRadius");
    let n = rt(0, 0, i, l, 1);
    const r = t / (n.right - n.left), c = s / (n.bottom - n.top);
    let o = { left: 0, right: 0, top: 0, bottom: 0 };
    if (a instanceof ft) {
      let g = a.value, d = Math.min(r, c);
      g = Math.max(d * g, d - Math.min(s, t)) / d, o = rt(0, 0, i, l, g), this.setPrivateRaw("irModifyer", g / a.value);
    }
    n = mt([n, o]);
    const p = this._maxRadius;
    this._maxRadius = Math.min(r, c);
    const h = A(this.get("radius", 0), this._maxRadius);
    this.seriesContainer.setAll({
      dy: -h * (n.bottom + n.top) / 2,
      dx: -h * (n.right + n.left) / 2
    }), (this.isDirty("startAngle") || this.isDirty("endAngle") || p != this._maxRadius) && this.series.each((g) => {
      g._markDirtyKey("startAngle");
    }), (this.isDirty("innerRadius") || this.isDirty("radius")) && this.series.each((g) => {
      g._markDirtyKey("innerRadius");
    });
  }
  /**
   * Returns outer radius in pixels.
   *
   * If optional series parameter is passed in, it will return outer radius
   * of that particular series.
   *
   * @param   series  Series
   * @return          Radius in pixels
   */
  radius(e) {
    let t = A(this.get("radius", 0), this._maxRadius), s = A(this.get("innerRadius", 0), t);
    if (e) {
      let i = this.series.indexOf(e), l = this.series.length, a = e.get("radius");
      return a != null ? s + A(a, t - s) : s + (t - s) / l * (i + 1);
    }
    return t;
  }
  /**
   * Returns inner radius in pixels.
   *
   * If optional series parameter is passed in, it will return inner radius
   * of that particular series.
   *
   * @param   series  Series
   * @return          Radius in pixels
   */
  innerRadius(e) {
    const t = this.radius();
    let s = A(this.get("innerRadius", 0), t);
    if (s < 0 && (s = t + s), e) {
      let i = this.series.indexOf(e), l = this.series.length, a = e.get("innerRadius");
      return a != null ? s + A(a, t - s) : s + (t - s) / l * i;
    }
    return s;
  }
  _updateSize() {
    super._updateSize(), this.markDirtyKey("radius");
  }
}
st.className = "PieChart";
st.classNames = H.classNames.concat([st.className]);
class it extends X {
  _makeSlices() {
    return new R(M.new({}), () => xt._new(this._root, {
      themeTags: W(this.slices.template.get("themeTags", []), ["pie", "series"])
    }, [this.slices.template]));
  }
  _makeLabels() {
    return new R(M.new({}), () => kt._new(this._root, {
      themeTags: W(this.labels.template.get("themeTags", []), ["pie", "series"])
    }, [this.labels.template]));
  }
  _makeTicks() {
    return new R(M.new({}), () => ct._new(this._root, {
      themeTags: W(this.ticks.template.get("themeTags", []), ["pie", "series"])
    }, [this.ticks.template]));
  }
  processDataItem(e) {
    super.processDataItem(e);
    const t = this.makeSlice(e);
    t.on("scale", () => {
      this._updateTick(e);
    }), t.on("shiftRadius", () => {
      this._updateTick(e);
    }), t.events.on("positionchanged", () => {
      this._updateTick(e);
    });
    const s = this.makeLabel(e);
    s.events.on("positionchanged", () => {
      this._updateTick(e);
    }), this.makeTick(e), t.events.on("positionchanged", () => {
      s.markDirty();
    });
  }
  _getNextUp() {
    const e = this.chart;
    return e ? e._maxRadius : this.labelsContainer.maxHeight() / 2;
  }
  _getNextDown() {
    const e = this.chart;
    return e ? -e._maxRadius : -this.labelsContainer.maxHeight() / 2;
  }
  _prepareChildren() {
    super._prepareChildren();
    const e = this.chart;
    if (e) {
      if (this.isDirty("alignLabels")) {
        let t = this.labels.template;
        if (this.get("alignLabels"))
          t.set("textType", "aligned");
        else {
          let s = t.get("textType");
          (s == null || s == "aligned") && t.set("textType", "adjusted");
        }
      }
      if (this._valuesDirty || this.isDirty("radius") || this.isDirty("innerRadius") || this.isDirty("startAngle") || this.isDirty("endAngle") || this.isDirty("alignLabels")) {
        this.markDirtyBounds();
        const t = this.get("startAngle", e.get("startAngle", -90)), i = this.get("endAngle", e.get("endAngle", 270)) - t;
        let l = t;
        const a = e.radius(this);
        this.setPrivateRaw("radius", a);
        let n = e.innerRadius(this) * e.getPrivate("irModifyer", 1);
        n < 0 && (n = a + n), v(this._dataItems, (r) => {
          this.updateLegendValue(r);
          let c = i * r.get("valuePercentTotal") / 100;
          const o = r.get("slice");
          if (o) {
            o.set("radius", a), o.set("innerRadius", n), o.set("startAngle", l), o.set("arc", c);
            const g = r.get("fill");
            o._setDefault("fill", g), o._setDefault("stroke", g);
            const d = r.get("fillPattern");
            o._setDefault("fillPattern", d);
          }
          let p = yt(l + c / 2);
          const h = r.get("label");
          if (h && (h.setPrivate("radius", a), h.setPrivate("innerRadius", n), h.set("labelAngle", p), h.get("textType") == "aligned")) {
            let g = a + h.get("radius", 0), d = a * w(p);
            p > 90 && p <= 270 ? (!h.isHidden() && !h.isHiding() && this._lLabels.push({ label: h, y: d }), g *= -1, g -= this.labelsContainer.get("paddingLeft", 0), h.set("centerX", P), h.setPrivateRaw("left", !0)) : (!h.isHidden() && !h.isHiding() && this._rLabels.push({ label: h, y: d }), g += this.labelsContainer.get("paddingRight", 0), h.set("centerX", 0), h.setPrivateRaw("left", !1)), h.set("x", g), h.set("y", a * w(p));
          }
          l += c, this._updateTick(r);
        });
      }
    }
  }
  _updateTick(e) {
    const t = e.get("tick"), s = e.get("label"), i = e.get("slice"), l = t.get("location", 1);
    if (t && s && i) {
      const a = (i.get("shiftRadius", 0) + i.get("radius", 0)) * i.get("scale", 1) * l, n = s.get("labelAngle", 0), r = T(n), c = w(n), o = this.labelsContainer, p = o.get("paddingLeft", 0), h = o.get("paddingRight", 0);
      let g = 0, d = 0;
      g = s.x(), d = s.y();
      let u = [];
      if (g != 0 || d != 0) {
        if (s.get("textType") == "circular") {
          const m = s.radius() - s.get("paddingBottom", 0), y = s.get("labelAngle", 0);
          g = m * T(y), d = m * w(y);
        }
        let _ = -h;
        s.getPrivate("left") && (_ = p), u = [{ x: i.x() + a * r, y: i.y() + a * c }, { x: g + _, y: d }, { x: g, y: d }];
      }
      t.set("points", u);
    }
  }
  _positionBullet(e) {
    const t = e.get("sprite");
    if (t) {
      const i = t.dataItem.get("slice");
      if (i) {
        const l = i.get("innerRadius", 0), a = i.get("radius", 0), n = i.get("startAngle", 0), r = i.get("arc", 0), c = e.get("locationX", 0.5), o = e.get("locationY", 0.5), p = n + r * c, h = l + (a - l) * o;
        t.setAll({ x: T(p) * h, y: w(p) * h });
      }
    }
  }
}
it.className = "PieSeries";
it.classNames = X.classNames.concat([it.className]);
class U extends $ {
  constructor() {
    super(...arguments), this._projectionDirty = !1, this._tlx = 0, this._tly = 0, this._trx = 0, this._try = 0, this._blx = 0, this._bly = 0, this._brx = 0, this._bry = 0, this._cprx = 0, this._cplx = 0, this._cpry = 0, this._cply = 0;
  }
  _afterNew() {
    super._afterNew(), this.set("draw", (e) => {
      const t = this.width(), s = this.height();
      let i = Math.min(t, s) / 2, l = A(this.get("cornerRadiusTL", 0), i), a = A(this.get("cornerRadiusTR", 0), i), n = A(this.get("cornerRadiusBR", 0), i), r = A(this.get("cornerRadiusBL", 0), i), c = this._trx, o = this._try, p = this._tlx, h = this._tly, g = this._brx, d = this._bry, u = this._blx, _ = this._bly;
      o == h && (o = o - 0.01), d == _ && (d = d - 0.01);
      let m = J({ x: p, y: h }, { x: c, y: o }), y = J({ x: c, y: o }, { x: g, y: d }), x = J({ x: g, y: d }, { x: u, y: _ }), f = J({ x: u, y: _ }, { x: p, y: h });
      this.get("orientation") == "horizontal" ? (l = Math.min(l, Math.abs(h - o) / 2), a = Math.min(a, Math.abs(h - o) / 2), n = Math.min(n, Math.abs(_ - d) / 2), r = Math.min(r, Math.abs(_ - d) / 2)) : (l = Math.min(l, Math.abs(p - c) / 2), a = Math.min(a, Math.abs(p - c) / 2), n = Math.min(n, Math.abs(u - g) / 2), r = Math.min(r, Math.abs(u - g) / 2));
      const D = p - l * k((m - f) / 2) * T(f), L = h - l * k((m - f) / 2) * w(f), z = p - l * k((f - m) / 2) * T(m), F = h - l * k((f - m) / 2) * w(m), S = c - a * k((y - m) / 2) * T(m), Q = o - a * k((y - m) / 2) * w(m), N = c - a * k((m - y) / 2) * T(y), Y = o - a * k((m - y) / 2) * w(y), O = g - n * k((x - y) / 2) * T(y), B = d - n * k((x - y) / 2) * w(y), j = g - n * k((y - x) / 2) * T(x), q = d - n * k((y - x) / 2) * w(x), nt = u - r * k((f - x) / 2) * T(x), Z = _ - r * k((f - x) / 2) * w(x), I = u - r * k((x - f) / 2) * T(f), ut = _ - r * k((x - f) / 2) * w(f);
      e.moveTo(z, F), e.lineTo(S, Q), e.arcTo(c, o, N, Y, a), e.quadraticCurveTo(this._cprx, this._cpry, O, B), e.arcTo(g, d, j, q, n), e.lineTo(nt, Z), e.arcTo(u, _, I, ut, r), e.quadraticCurveTo(this._cplx, this._cply, D, L), e.arcTo(p, h, z, F, l);
    });
  }
  getPoint(e, t) {
    let s = this.width(), i = this.height();
    const l = this.get("topWidth", 0), a = this.get("bottomWidth", 0);
    if (this.get("orientation") == "vertical") {
      let n = -l / 2, r = l / 2, c = a / 2, o = -a / 2, p = n + (o - n) * t, h = r + (c - r) * t;
      return { x: p + (h - p) * e, y: i * t };
    } else {
      let n = -l / 2, r = l / 2, c = a / 2, o = -a / 2, p = n + (o - n) * e, h = r + (c - r) * e;
      return { x: s * e, y: p + (h - p) * t };
    }
  }
  _changed() {
    if (this.isDirty("topWidth") || this.isDirty("bottomWidth") || this.isDirty("expandDistance") || this.isDirty("orientation") || this.isDirty("width") || this.isDirty("height")) {
      const e = this.width(), t = this.height(), s = this.get("topWidth", 0), i = this.get("bottomWidth", 0);
      this._clear = !0;
      let l = this.get("expandDistance", 0);
      this.get("orientation") == "vertical" ? (this._tlx = -s / 2, this._tly = 0, this._trx = s / 2, this._try = 0, this._brx = i / 2, this._bry = t, this._blx = -i / 2, this._bly = t, this._cprx = this._trx + (this._brx - this._trx) / 2 + l * t, this._cpry = this._try + 0.5 * t, this._cplx = this._tlx + (this._blx - this._tlx) / 2 - l * t, this._cply = this._tly + 0.5 * t) : (this._tly = s / 2, this._tlx = 0, this._try = -s / 2, this._trx = 0, this._bry = -i / 2, this._brx = e, this._bly = i / 2, this._blx = e, this._cpry = this._try + (this._bry - this._try) / 2 - l * e, this._cprx = this._trx + 0.5 * e, this._cply = this._tly + (this._bly - this._tly) / 2 + l * e, this._cplx = this._tlx + 0.5 * e);
    }
    super._changed();
  }
}
U.className = "FunnelSlice";
U.classNames = $.classNames.concat([U.className]);
class K extends X {
  constructor() {
    super(...arguments), this._tag = "funnel", this.links = this.addDisposer(this._makeLinks()), this._total = 0, this._count = 0, this._nextCoord = 0, this._opposite = !1;
  }
  _makeSlices() {
    return new R(M.new({}), () => U._new(this._root, {
      themeTags: W(this.slices.template.get("themeTags", []), [this._tag, "series", "slice", this.get("orientation")])
    }, [this.slices.template]));
  }
  _makeLabels() {
    return new R(M.new({}), () => bt._new(this._root, {
      themeTags: W(this.labels.template.get("themeTags", []), [this._tag, "series", "label", this.get("orientation")])
    }, [this.labels.template]));
  }
  _makeTicks() {
    return new R(M.new({}), () => ct._new(this._root, {
      themeTags: W(this.ticks.template.get("themeTags", []), [this._tag, "series", "tick", this.get("orientation")])
    }, [this.ticks.template]));
  }
  _makeLinks() {
    return new R(M.new({}), () => U._new(this._root, {
      themeTags: W(this.links.template.get("themeTags", []), [this._tag, "series", "link", this.get("orientation")])
    }, [this.links.template]));
  }
  /**
   * @ignore
   */
  makeLink(e) {
    const t = this.slicesContainer.children.push(this.links.make());
    return t._setDataItem(e), e.set("link", t), this.links.push(t), t;
  }
  _afterNew() {
    super._afterNew();
    const e = this.slicesContainer;
    e.setAll({ isMeasured: !0, position: "relative", width: et(100), height: et(100) }), e.onPrivate("width", () => {
      this.markDirtySize();
    }), e.onPrivate("height", () => {
      this.markDirtySize();
    }), this.get("orientation") == "vertical" ? this.set("layout", this._root.horizontalLayout) : this.set("layout", this._root.verticalLayout);
  }
  processDataItem(e) {
    super.processDataItem(e);
    const t = this.makeSlice(e);
    t._setDataItem(e), e.set("slice", t), this.makeLink(e);
    const s = this.makeLabel(e);
    s.on("x", () => {
      this._updateTick(e);
    }), s.on("y", () => {
      this._updateTick(e);
    }), this.makeTick(e), t.events.on("positionchanged", () => {
      s.markDirty();
    }), t.events.on("boundschanged", () => {
      const i = t.dataItem;
      i && this._updateTick(i);
    });
  }
  _updateChildren() {
    this._opposite = !1, this.children.indexOf(this.labelsContainer) == 0 && (this._opposite = !0);
    let e = 0, t = 0;
    if (v(this.dataItems, (s) => {
      const i = s.get("value");
      G(i) && (t++, i > 0 ? e += Math.abs(s.get("valueWorking", i) / i) : this.get("ignoreZeroValues", !1) || s.isHidden() ? t-- : e += 1);
    }), this._total = 1 / t * e, this._count = t, this.isDirty("alignLabels") && this._fixLayout(), this._total > 0 && (this._valuesDirty || this._sizeDirty)) {
      const s = this.slicesContainer;
      let i;
      this.get("orientation") == "vertical" ? i = s.innerHeight() : i = s.innerWidth(), this._nextCoord = this.get("startLocation", 0) * i, this.markDirtyBounds();
      let l = 0;
      v(this._dataItems, (a) => {
        this.updateLegendValue(a), a.set("index", l), l++;
        const n = a.get("slice"), r = a.get("tick"), c = a.get("label"), o = a.get("link"), p = a.get("fill"), h = a.get("fillPattern");
        n._setDefault("fill", p), n._setDefault("stroke", p), n._setDefault("fillPattern", h), o._setDefault("fill", p), o._setDefault("stroke", p);
        const g = a.get("value");
        G(g) && (g == 0 && this.get("ignoreZeroValues") ? (n.setPrivate("visible", !1), r.setPrivate("visible", !1), c.setPrivate("visible", !1)) : (n.setPrivate("visible", !0), r.setPrivate("visible", !0), c.setPrivate("visible", !0), this.decorateSlice(a), this.isLast(a) ? o.setPrivate("visible", !1) : a.isHidden() || o.setPrivate("visible", !0)));
      });
    }
    super._updateChildren();
  }
  _fixLayout() {
    const e = this.get("orientation"), t = this.labelsContainer, s = this.labels.template;
    this.get("alignLabels") ? (t.set("position", "relative"), t.setAll({ isMeasured: !0 }), e == "vertical" ? (this.set("layout", this._root.horizontalLayout), s.setAll({ centerX: P, x: P })) : (this.set("layout", this._root.verticalLayout), s.setAll({ centerX: 0, x: 0 }))) : (t.setAll({ isMeasured: !1, position: "absolute" }), e == "vertical" ? (t.setAll({ x: b }), s.setAll({ centerX: b, x: 0 })) : (t.setAll({ y: b }), s.setAll({ centerX: b, y: 0 }))), this.markDirtySize();
  }
  getNextValue(e) {
    let t = e.get("index"), s = e.get("valueWorking", 0);
    if (t < this.dataItems.length - 1) {
      let i = this.dataItems[t + 1];
      if (s = i.get("valueWorking", 0), i.isHidden() || i.get("value") == 0 && this.get("ignoreZeroValues"))
        return this.getNextValue(i);
    }
    return s;
  }
  isLast(e) {
    let t = e.get("index");
    if (t == this.dataItems.length - 1)
      return !0;
    for (let s = t + 1; s < this.dataItems.length; s++)
      if (!this.dataItems[s].isHidden())
        return !1;
    return !0;
  }
  decorateSlice(e) {
    const t = this.get("orientation"), s = e.get("slice"), i = e.get("label"), l = e.get("link"), a = this.slicesContainer;
    let n = a.innerWidth(), r = a.innerHeight(), c = n;
    t == "horizontal" && (c = r);
    const o = this.getNextValue(e), p = e.get("value", 0), h = Math.abs(e.get("valueWorking", p)), g = this.get("bottomRatio", 0), d = this.getPrivate("valueHigh", 0);
    let u = 1;
    p != 0 ? u = h / Math.abs(p) : e.isHidden() && (u = 1e-6), this._nextCoord == 1 / 0 && (this._nextCoord = 0);
    let _ = h / d * c, m = (h - (h - o) * g) / d * c;
    s.setAll({ topWidth: _, bottomWidth: m, orientation: t }), l.setAll({ topWidth: m, bottomWidth: (h - (h - o)) / d * c, orientation: t });
    const y = this.get("startLocation", 0), x = this.get("endLocation", 1);
    if (t == "vertical") {
      let f = l.height() * u;
      r = r * (x - y) + f, s.set("y", this._nextCoord);
      let D = Math.min(1e5, Math.max(0, r / this._count * u / this._total - f));
      s.setAll({ height: D, x: n / 2 });
      let L = this._nextCoord + D / 2;
      i.set("y", L), this._nextCoord += D + f, l.setAll({ y: this._nextCoord - f, x: n / 2 });
    } else {
      let f = l.width() * u;
      n = n * (x - y) + f, s.set("x", this._nextCoord);
      let D = Math.min(1e5, Math.max(0, n / this._count * u / this._total - f));
      s.setAll({ width: D, y: r / 2 });
      const L = this._nextCoord + D / 2;
      i.set("x", L), this._nextCoord += D + f, l.setAll({ x: this._nextCoord - f, y: r / 2 });
    }
  }
  /**
   * Hides series's data item.
   *
   * @param   dataItem  Data item
   * @param   duration  Animation duration in milliseconds
   * @return            Promise
   */
  hideDataItem(e, t) {
    const s = Object.create(null, {
      hideDataItem: { get: () => super.hideDataItem }
    });
    return V(this, void 0, void 0, function* () {
      return e.get("link").hide(t), s.hideDataItem.call(this, e, t);
    });
  }
  /**
   * Shows series's data item.
   *
   * @param   dataItem  Data item
   * @param   duration  Animation duration in milliseconds
   * @return            Promise
   */
  showDataItem(e, t) {
    const s = Object.create(null, {
      showDataItem: { get: () => super.showDataItem }
    });
    return V(this, void 0, void 0, function* () {
      return e.get("link").show(t), s.showDataItem.call(this, e, t);
    });
  }
  _updateTick(e) {
    if (this.get("alignLabels")) {
      const t = e.get("tick"), s = e.get("label"), i = e.get("slice");
      if (t && i && s) {
        const l = this.labelsContainer, a = this.slicesContainer;
        let n = t.get("location", 0.5);
        const r = l.width(), c = l.height(), o = l.get("paddingLeft", 0), p = l.get("paddingRight", 0), h = l.get("paddingTop", 0), g = l.get("paddingBottom", 0);
        let d = { x: 0, y: 0 }, u = { x: 0, y: 0 }, _ = { x: 0, y: 0 };
        this._opposite && (n = 1 - n), this.get("orientation") == "vertical" ? (d = i.getPoint(n, 0.5), d.x += i.x() + a.x(), d.y += i.y() + a.y(), this._opposite ? (u.x = r, u.y = s.y(), _.x = r - o, _.y = u.y) : (u.x = a.x() + a.width(), u.y = s.y(), _.x = u.x + r - s.width() - p, _.y = u.y)) : (d = i.getPoint(0.5, n), d.x += i.x() + a.x(), d.y += i.y() + a.y(), this._opposite ? (u.y = c, u.x = s.x(), _.y = c - h, _.x = u.x) : (u.y = a.y() + a.height(), u.x = s.x(), _.y = u.y + c - s.height() - g, _.x = u.x)), t.set("points", [d, u, _]);
      }
    }
  }
  /**
   * @ignore
   */
  disposeDataItem(e) {
    super.disposeDataItem(e);
    let t = e.get("link");
    t && (this.links.removeValue(t), t.dispose());
  }
  _positionBullet(e) {
    const t = e.get("sprite");
    if (t) {
      const i = t.dataItem.get("slice");
      if (i) {
        const l = i.width(), a = i.height(), n = e.get("locationX", 0.5), r = e.get("locationY", 0.5);
        let c = 0, o = 0;
        this.get("orientation") == "horizontal" ? o = a / 2 : c = l / 2, t.setAll({ x: i.x() + l * n - c, y: i.y() - o + a * r });
      }
    }
  }
}
K.className = "FunnelSeries";
K.classNames = X.classNames.concat([K.className]);
class E extends K {
  constructor() {
    super(...arguments), this._tag = "pyramid";
  }
  _prepareChildren() {
    super._prepareChildren(), this._nextSize = void 0;
  }
  decorateSlice(e) {
    const t = this.get("orientation"), s = this.slicesContainer, i = e.get("slice"), l = e.get("label"), a = e.get("link"), n = this.get("valueIs", "area"), r = this.getPrivate("valueAbsoluteSum", 0);
    if (r == 0)
      return;
    const c = this.get("startLocation", 0), o = this.get("endLocation", 1), p = this.get("topWidth", 0), h = this.get("bottomWidth", P), g = Math.abs(e.get("valueWorking", 0)), d = e.get("value", 0);
    let u, _, m = s.innerHeight(), y = s.innerWidth(), x = a.width(), f = a.height();
    t == "horizontal" && ([y, m] = [m, y], [x, f] = [f, x]);
    const D = y / 2;
    let L = 1;
    d != 0 ? L = g / Math.abs(d) : e.isHidden() && (L = 1e-6), f *= L, m = m * (o - c) - f * (this._count * this._total - 1);
    let z = A(p, y);
    G(this._nextSize) || (this._nextSize = z);
    let F = A(h, y), S = this._nextSize, Q = Math.atan2(m, z - F), N = Math.tan(Math.PI / 2 - Q);
    if (N == 0 && (N = 1e-8), n == "area") {
      let Z = (z + F) / 2 * m * g / r, I = Math.abs(S * S - 2 * Z * N);
      u = (S - Math.sqrt(I)) / N, u > 0 ? _ = (2 * Z - u * S) / u : _ = S;
    } else
      u = m * g / r, _ = S - u * N;
    let Y = this._nextCoord + u / 2, O = D, B = this._nextCoord, j = D, q = B + u;
    t == "vertical" ? (l.set("y", Y), l.get("opacity") > 0 && this._rLabels.push({ label: l, y: Y }), i.set("height", u)) : (l.set("x", Y), l.get("opacity") > 0 && this._hLabels.push({ label: l, y: Y }), [O, B] = [B, O], [j, q] = [q, j], i.set("width", u)), i.setAll({ orientation: t, bottomWidth: _, topWidth: S, x: O, y: B }), a.setAll({ orientation: t, x: j, y: q, topWidth: _, bottomWidth: _ }), this._nextSize = _, this._nextCoord += u + f;
  }
}
E.className = "PyramidSeries";
E.classNames = K.classNames.concat([E.className]);
class lt extends E {
  constructor() {
    super(...arguments), this._tag = "pictorial", this.seriesMask = $.new(this._root, { position: "absolute", x: b, y: b, centerX: b, centerY: b }), this.seriesGraphics = this.slicesContainer.children.push($.new(this._root, { themeTags: ["pictorial", "background"], position: "absolute", x: b, y: b, centerX: b, centerY: b }));
  }
  _afterNew() {
    super._afterNew(), this.set("topWidth", P), this.set("bottomWidth", P), this.set("valueIs", "height"), this.slicesContainer.set("mask", this.seriesMask);
  }
  _updateScale() {
    let e = this.slicesContainer, t = e.innerWidth(), s = e.innerHeight(), i = this.seriesMask, l = this.seriesGraphics, a = i.get("scale", 1);
    const n = i.localBounds();
    let r = n.right - n.left, c = n.bottom - n.top;
    this.get("orientation") == "horizontal" ? a = t / r : a = s / c, a != 1 / 0 && a != NaN && (i.set("scale", a), i.set("x", t / 2), i.set("y", s / 2), l.set("scale", a), l.set("x", t / 2), l.set("y", s / 2));
  }
  _prepareChildren() {
    if (super._prepareChildren(), this.isDirty("svgPath")) {
      const e = this.get("svgPath");
      this.seriesMask.set("svgPath", e), this.seriesGraphics.set("svgPath", e);
    }
    this._updateScale();
  }
}
lt.className = "PictorialStackedSeries";
lt.classNames = E.classNames.concat([lt.className]);
class at extends H {
  _afterNew() {
    super._afterNew(), this.seriesContainer.setAll({ isMeasured: !0, layout: this._root.horizontalLayout });
  }
}
at.className = "SlicedChart";
at.classNames = H.classNames.concat([at.className]);
export {
  vt as DefaultTheme,
  K as FunnelSeries,
  U as FunnelSlice,
  H as PercentChart,
  X as PercentSeries,
  lt as PictorialStackedSeries,
  st as PieChart,
  it as PieSeries,
  E as PyramidSeries,
  at as SlicedChart
};
