import { m as sr, B as pr, n as ca, i as Sr, k as ga, g as dr, p as Nr, f as b, e as C, a as ha, l as pa, r as ya, b as yr, c as Or, u as Ur, d as Ma, T as ea, P as Ta, h as tr, j as F, o as ta, q as Lr, s as Ia, S as Vr, R as La, t as W, v as j, w as _a, x as rr, y as _r, z as k, A as w, C as z, D as ur, E as na, F as Da, G as xa, H as Xr } from "./index-SHEAnnHB.js";
import { p as Ga, s as Ea, a as ma, h as Ra, D as Yr } from "./labelLayoutHelper-cE7kdX3K.js";
import { s as Pa, g as Ca, u as qr } from "./labelGuideHelper-C6WIwKAi.js";
import "react";
import "react-dom";
import "lodash";
import "@emotion/react";
import "@alkuip/core";
import "@alkuip/forms";
import "@mui/material";
import "@alkuip/charts";
import "@emotion/styled";
function Aa(a) {
  if (a) {
    for (var r = [], n = 0; n < a.length; n++)
      r.push(a[n].slice());
    return r;
  }
}
function Sa(a, r) {
  var n = a.label, e = r && r.getTextGuideLine();
  return {
    dataIndex: a.dataIndex,
    dataType: a.dataType,
    seriesIndex: a.seriesModel.seriesIndex,
    text: a.label.style.text,
    rect: a.hostRect,
    labelRect: a.rect,
    // x: labelAttr.x,
    // y: labelAttr.y,
    align: n.style.align,
    verticalAlign: n.style.verticalAlign,
    labelLinePoints: Aa(e && e.shape.points)
  };
}
var Hr = ["align", "verticalAlign", "width", "height", "fontSize"], S = new ea(), fr = sr(), Na = sr();
function ar(a, r, n) {
  for (var e = 0; e < n.length; e++) {
    var t = n[e];
    r[t] != null && (a[t] = r[t]);
  }
}
var er = ["x", "y", "rotation"], Oa = (
  /** @class */
  function() {
    function a() {
      this._labelList = [], this._chartViewList = [];
    }
    return a.prototype.clearLabels = function() {
      this._labelList = [], this._chartViewList = [];
    }, a.prototype._addLabel = function(r, n, e, t, v) {
      var o = t.style, i = t.__hostTarget, d = i.textConfig || {}, s = t.getComputedTransform(), u = t.getBoundingRect().plain();
      pr.applyTransform(u, u, s), s ? S.setLocalTransform(s) : (S.x = S.y = S.rotation = S.originX = S.originY = 0, S.scaleX = S.scaleY = 1), S.rotation = ca(S.rotation);
      var l = t.__hostTarget, f;
      if (l) {
        f = l.getBoundingRect().plain();
        var c = l.getComputedTransform();
        pr.applyTransform(f, f, c);
      }
      var p = f && l.getTextGuideLine();
      this._labelList.push({
        label: t,
        labelLine: p,
        seriesModel: e,
        dataIndex: r,
        dataType: n,
        layoutOption: v,
        computedLayoutOption: null,
        rect: u,
        hostRect: f,
        // Label with lower priority will be hidden when overlapped
        // Use rect size as default priority
        priority: f ? f.width * f.height : 0,
        // Save default label attributes.
        // For restore if developers want get back to default value in callback.
        defaultAttr: {
          ignore: t.ignore,
          labelGuideIgnore: p && p.ignore,
          x: S.x,
          y: S.y,
          scaleX: S.scaleX,
          scaleY: S.scaleY,
          rotation: S.rotation,
          style: {
            x: o.x,
            y: o.y,
            align: o.align,
            verticalAlign: o.verticalAlign,
            width: o.width,
            height: o.height,
            fontSize: o.fontSize
          },
          cursor: t.cursor,
          attachedPos: d.position,
          attachedRot: d.rotation
        }
      });
    }, a.prototype.addLabelsOfSeries = function(r) {
      var n = this;
      this._chartViewList.push(r);
      var e = r.__model, t = e.get("labelLayout");
      (Sr(t) || ga(t).length) && r.group.traverse(function(v) {
        if (v.ignore)
          return !0;
        var o = v.getTextContent(), i = dr(v);
        o && !o.disableLabelLayout && n._addLabel(i.dataIndex, i.dataType, e, o, t);
      });
    }, a.prototype.updateLayoutConfig = function(r) {
      var n = r.getWidth(), e = r.getHeight();
      function t(y, G) {
        return function() {
          qr(y, G);
        };
      }
      for (var v = 0; v < this._labelList.length; v++) {
        var o = this._labelList[v], i = o.label, d = i.__hostTarget, s = o.defaultAttr, u = void 0;
        Sr(o.layoutOption) ? u = o.layoutOption(Sa(o, d)) : u = o.layoutOption, u = u || {}, o.computedLayoutOption = u;
        var l = Math.PI / 180;
        d && d.setTextConfig({
          // Force to set local false.
          local: !1,
          // Ignore position and rotation config on the host el if x or y is changed.
          position: u.x != null || u.y != null ? null : s.attachedPos,
          // Ignore rotation config on the host el if rotation is changed.
          rotation: u.rotate != null ? u.rotate * l : s.attachedRot,
          offset: [u.dx || 0, u.dy || 0]
        });
        var f = !1;
        if (u.x != null ? (i.x = Nr(u.x, n), i.setStyle("x", 0), f = !0) : (i.x = s.x, i.setStyle("x", s.style.x)), u.y != null ? (i.y = Nr(u.y, e), i.setStyle("y", 0), f = !0) : (i.y = s.y, i.setStyle("y", s.style.y)), u.labelLinePoints) {
          var c = d.getTextGuideLine();
          c && (c.setShape({
            points: u.labelLinePoints
          }), f = !1);
        }
        var p = fr(i);
        p.needsUpdateLabelLine = f, i.rotation = u.rotate != null ? u.rotate * l : s.rotation, i.scaleX = s.scaleX, i.scaleY = s.scaleY;
        for (var g = 0; g < Hr.length; g++) {
          var h = Hr[g];
          i.setStyle(h, u[h] != null ? u[h] : s.style[h]);
        }
        if (u.draggable) {
          if (i.draggable = !0, i.cursor = "move", d) {
            var L = o.seriesModel;
            if (o.dataIndex != null) {
              var x = o.seriesModel.getData(o.dataType);
              L = x.getItemModel(o.dataIndex);
            }
            i.on("drag", t(d, L.getModel("labelLine")));
          }
        } else
          i.off("drag"), i.cursor = s.cursor;
      }
    }, a.prototype.layout = function(r) {
      var n = r.getWidth(), e = r.getHeight(), t = Ga(this._labelList), v = b(t, function(d) {
        return d.layoutOption.moveOverlap === "shiftX";
      }), o = b(t, function(d) {
        return d.layoutOption.moveOverlap === "shiftY";
      });
      Ea(v, 0, n), ma(o, 0, e);
      var i = b(t, function(d) {
        return d.layoutOption.hideOverlap;
      });
      Ra(i);
    }, a.prototype.processLabelsOverall = function() {
      var r = this;
      C(this._chartViewList, function(n) {
        var e = n.__model, t = n.ignoreLabelLineUpdate, v = e.isAnimationEnabled();
        n.group.traverse(function(o) {
          if (o.ignore && !o.forceLabelAnimation)
            return !0;
          var i = !t, d = o.getTextContent();
          !i && d && (i = fr(d).needsUpdateLabelLine), i && r._updateLabelLine(o, e), v && r._animateLabels(o, e);
        });
      });
    }, a.prototype._updateLabelLine = function(r, n) {
      var e = r.getTextContent(), t = dr(r), v = t.dataIndex;
      if (e && v != null) {
        var o = n.getData(t.dataType), i = o.getItemModel(v), d = {}, s = o.getItemVisual(v, "style");
        if (s) {
          var u = o.getVisual("drawType");
          d.stroke = s[u];
        }
        var l = i.getModel("labelLine");
        Pa(r, Ca(i), d), qr(r, l);
      }
    }, a.prototype._animateLabels = function(r, n) {
      var e = r.getTextContent(), t = r.getTextGuideLine();
      if (e && (r.forceLabelAnimation || !e.ignore && !e.invisible && !r.disableLabelAnimation && !ha(r))) {
        var v = fr(e), o = v.oldLayout, i = dr(r), d = i.dataIndex, s = {
          x: e.x,
          y: e.y,
          rotation: e.rotation
        }, u = n.getData(i.dataType);
        if (o) {
          e.attr(o);
          var f = r.prevStates;
          f && (Or(f, "select") >= 0 && e.attr(v.oldLayoutSelect), Or(f, "emphasis") >= 0 && e.attr(v.oldLayoutEmphasis)), Ur(e, s, n, d);
        } else if (e.attr(s), !pa(e).valueAnimation) {
          var l = ya(e.style.opacity, 1);
          e.style.opacity = 0, yr(e, {
            style: {
              opacity: l
            }
          }, n, d);
        }
        if (v.oldLayout = s, e.states.select) {
          var c = v.oldLayoutSelect = {};
          ar(c, s, er), ar(c, e.states.select, er);
        }
        if (e.states.emphasis) {
          var p = v.oldLayoutEmphasis = {};
          ar(p, s, er), ar(p, e.states.emphasis, er);
        }
        Ma(e, d, u, n, n);
      }
      if (t && !t.ignore && !t.invisible) {
        var v = Na(t), o = v.oldLayout, g = {
          points: t.shape.points
        };
        o ? (t.attr({
          shape: o
        }), Ur(t, {
          shape: g
        }, n)) : (t.setShape(g), t.style.strokePercent = 0, yr(t, {
          style: {
            strokePercent: 1
          }
        }, n)), v.oldLayout = g;
      }
    }, a;
  }()
), lr = sr();
function Te(a) {
  a.registerUpdateLifecycle("series:beforeupdate", function(r, n, e) {
    var t = lr(n).labelManager;
    t || (t = lr(n).labelManager = new Oa()), t.clearLabels();
  }), a.registerUpdateLifecycle("series:layoutlabels", function(r, n, e) {
    var t = lr(n).labelManager;
    e.updatedSeries.forEach(function(v) {
      t.addLabelsOfSeries(n.getViewOfSeriesModel(v));
    }), t.updateLayoutConfig(n), t.layout(n), t.processLabelsOverall();
  });
}
var Y = Ta.CMD;
function $(a, r) {
  return Math.abs(a - r) < 1e-5;
}
function Mr(a) {
  var r = a.data, n = a.len(), e = [], t, v = 0, o = 0, i = 0, d = 0;
  function s(R, P) {
    t && t.length > 2 && e.push(t), t = [R, P];
  }
  function u(R, P, A, m) {
    $(R, A) && $(P, m) || t.push(R, P, A, m, A, m);
  }
  function l(R, P, A, m, U, V) {
    var X = Math.abs(P - R), q = Math.tan(X / 4) * 4 / 3, Z = P < R ? -1 : 1, xr = Math.cos(R), Gr = Math.sin(R), Er = Math.cos(P), mr = Math.sin(P), fa = xr * U + A, la = Gr * V + m, Rr = Er * U + A, Pr = mr * V + m, Cr = U * q * Z, Ar = V * q * Z;
    t.push(fa - Cr * Gr, la + Ar * xr, Rr + Cr * mr, Pr - Ar * Er, Rr, Pr);
  }
  for (var f, c, p, g, h = 0; h < n; ) {
    var L = r[h++], x = h === 1;
    switch (x && (v = r[h], o = r[h + 1], i = v, d = o, (L === Y.L || L === Y.C || L === Y.Q) && (t = [i, d])), L) {
      case Y.M:
        v = i = r[h++], o = d = r[h++], s(i, d);
        break;
      case Y.L:
        f = r[h++], c = r[h++], u(v, o, f, c), v = f, o = c;
        break;
      case Y.C:
        t.push(r[h++], r[h++], r[h++], r[h++], v = r[h++], o = r[h++]);
        break;
      case Y.Q:
        f = r[h++], c = r[h++], p = r[h++], g = r[h++], t.push(v + 2 / 3 * (f - v), o + 2 / 3 * (c - o), p + 2 / 3 * (f - p), g + 2 / 3 * (c - g), p, g), v = p, o = g;
        break;
      case Y.A:
        var y = r[h++], G = r[h++], M = r[h++], T = r[h++], _ = r[h++], D = r[h++] + _;
        h += 1;
        var I = !r[h++];
        f = Math.cos(_) * M + y, c = Math.sin(_) * T + G, x ? (i = f, d = c, s(i, d)) : u(v, o, f, c), v = Math.cos(D) * M + y, o = Math.sin(D) * T + G;
        for (var E = (I ? -1 : 1) * Math.PI / 2, N = _; I ? N > D : N < D; N += E) {
          var O = I ? Math.max(N + E, D) : Math.min(N + E, D);
          l(N, O, y, G, M, T);
        }
        break;
      case Y.R:
        i = v = r[h++], d = o = r[h++], f = i + r[h++], c = d + r[h++], s(f, d), u(f, d, f, c), u(f, c, i, c), u(i, c, i, d), u(i, d, f, d);
        break;
      case Y.Z:
        t && u(v, o, i, d), v = i, o = d;
        break;
    }
  }
  return t && t.length > 2 && e.push(t), e;
}
function Tr(a, r, n, e, t, v, o, i, d, s) {
  if ($(a, n) && $(r, e) && $(t, o) && $(v, i)) {
    d.push(o, i);
    return;
  }
  var u = 2 / s, l = u * u, f = o - a, c = i - r, p = Math.sqrt(f * f + c * c);
  f /= p, c /= p;
  var g = n - a, h = e - r, L = t - o, x = v - i, y = g * g + h * h, G = L * L + x * x;
  if (y < l && G < l) {
    d.push(o, i);
    return;
  }
  var M = f * g + c * h, T = -f * L - c * x, _ = y - M * M, D = G - T * T;
  if (_ < l && M >= 0 && D < l && T >= 0) {
    d.push(o, i);
    return;
  }
  var I = [], E = [];
  tr(a, n, t, o, 0.5, I), tr(r, e, v, i, 0.5, E), Tr(I[0], E[0], I[1], E[1], I[2], E[2], I[3], E[3], d, s), Tr(I[4], E[4], I[5], E[5], I[6], E[6], I[7], E[7], d, s);
}
function Ua(a, r) {
  var n = Mr(a), e = [];
  r = r || 1;
  for (var t = 0; t < n.length; t++) {
    var v = n[t], o = [], i = v[0], d = v[1];
    o.push(i, d);
    for (var s = 2; s < v.length; ) {
      var u = v[s++], l = v[s++], f = v[s++], c = v[s++], p = v[s++], g = v[s++];
      Tr(i, d, u, l, f, c, p, g, o, r), i = p, d = g;
    }
    e.push(o);
  }
  return e;
}
function ia(a, r, n) {
  var e = a[r], t = a[1 - r], v = Math.abs(e / t), o = Math.ceil(Math.sqrt(v * n)), i = Math.floor(n / o);
  i === 0 && (i = 1, o = n);
  for (var d = [], s = 0; s < o; s++)
    d.push(i);
  var u = o * i, l = n - u;
  if (l > 0)
    for (var s = 0; s < l; s++)
      d[s % o] += 1;
  return d;
}
function Zr(a, r, n) {
  for (var e = a.r0, t = a.r, v = a.startAngle, o = a.endAngle, i = Math.abs(o - v), d = i * t, s = t - e, u = d > Math.abs(s), l = ia([d, s], u ? 0 : 1, r), f = (u ? i : s) / l.length, c = 0; c < l.length; c++)
    for (var p = (u ? s : i) / l[c], g = 0; g < l[c]; g++) {
      var h = {};
      u ? (h.startAngle = v + f * c, h.endAngle = v + f * (c + 1), h.r0 = e + p * g, h.r = e + p * (g + 1)) : (h.startAngle = v + p * g, h.endAngle = v + p * (g + 1), h.r0 = e + f * c, h.r = e + f * (c + 1)), h.clockwise = a.clockwise, h.cx = a.cx, h.cy = a.cy, n.push(h);
    }
}
function Va(a, r, n) {
  for (var e = a.width, t = a.height, v = e > t, o = ia([e, t], v ? 0 : 1, r), i = v ? "width" : "height", d = v ? "height" : "width", s = v ? "x" : "y", u = v ? "y" : "x", l = a[i] / o.length, f = 0; f < o.length; f++)
    for (var c = a[d] / o[f], p = 0; p < o[f]; p++) {
      var g = {};
      g[s] = f * l, g[u] = p * c, g[i] = l, g[d] = c, g.x += a.x, g.y += a.y, n.push(g);
    }
}
function Qr(a, r, n, e) {
  return a * e - n * r;
}
function Xa(a, r, n, e, t, v, o, i) {
  var d = n - a, s = e - r, u = o - t, l = i - v, f = Qr(u, l, d, s);
  if (Math.abs(f) < 1e-6)
    return null;
  var c = a - t, p = r - v, g = Qr(c, p, u, l) / f;
  return g < 0 || g > 1 ? null : new W(g * d + a, g * s + r);
}
function Ya(a, r, n) {
  var e = new W();
  W.sub(e, n, r), e.normalize();
  var t = new W();
  W.sub(t, a, r);
  var v = t.dot(e);
  return v;
}
function K(a, r) {
  var n = a[a.length - 1];
  n && n[0] === r[0] && n[1] === r[1] || a.push(r);
}
function qa(a, r, n) {
  for (var e = a.length, t = [], v = 0; v < e; v++) {
    var o = a[v], i = a[(v + 1) % e], d = Xa(o[0], o[1], i[0], i[1], r.x, r.y, n.x, n.y);
    d && t.push({
      projPt: Ya(d, r, n),
      pt: d,
      idx: v
    });
  }
  if (t.length < 2)
    return [{ points: a }, { points: a }];
  t.sort(function(h, L) {
    return h.projPt - L.projPt;
  });
  var s = t[0], u = t[t.length - 1];
  if (u.idx < s.idx) {
    var l = s;
    s = u, u = l;
  }
  for (var f = [s.pt.x, s.pt.y], c = [u.pt.x, u.pt.y], p = [f], g = [c], v = s.idx + 1; v <= u.idx; v++)
    K(p, a[v].slice());
  K(p, c), K(p, f);
  for (var v = u.idx + 1; v <= s.idx + e; v++)
    K(g, a[v % e].slice());
  return K(g, f), K(g, c), [{
    points: p
  }, {
    points: g
  }];
}
function Wr(a) {
  var r = a.points, n = [], e = [];
  ta(r, n, e);
  var t = new pr(n[0], n[1], e[0] - n[0], e[1] - n[1]), v = t.width, o = t.height, i = t.x, d = t.y, s = new W(), u = new W();
  return v > o ? (s.x = u.x = i + v / 2, s.y = d, u.y = d + o) : (s.y = u.y = d + o / 2, s.x = i, u.x = i + v), qa(r, s, u);
}
function nr(a, r, n, e) {
  if (n === 1)
    e.push(r);
  else {
    var t = Math.floor(n / 2), v = a(r);
    nr(a, v[0], t, e), nr(a, v[1], n - t, e);
  }
  return e;
}
function Ha(a, r) {
  for (var n = [], e = 0; e < r; e++)
    n.push(Lr(a));
  return n;
}
function Za(a, r) {
  r.setStyle(a.style), r.z = a.z, r.z2 = a.z2, r.zlevel = a.zlevel;
}
function Qa(a) {
  for (var r = [], n = 0; n < a.length; )
    r.push([a[n++], a[n++]]);
  return r;
}
function Wa(a, r) {
  var n = [], e = a.shape, t;
  switch (a.type) {
    case "rect":
      Va(e, r, n), t = La;
      break;
    case "sector":
      Zr(e, r, n), t = Vr;
      break;
    case "circle":
      Zr({
        r0: 0,
        r: e.r,
        startAngle: 0,
        endAngle: Math.PI * 2,
        cx: e.cx,
        cy: e.cy
      }, r, n), t = Vr;
      break;
    default:
      var v = a.getComputedTransform(), o = v ? Math.sqrt(Math.max(v[0] * v[0] + v[1] * v[1], v[2] * v[2] + v[3] * v[3])) : 1, i = F(Ua(a.getUpdatedPathProxy(), o), function(L) {
        return Qa(L);
      }), d = i.length;
      if (d === 0)
        nr(Wr, {
          points: i[0]
        }, r, n);
      else if (d === r)
        for (var s = 0; s < d; s++)
          n.push({
            points: i[s]
          });
      else {
        var u = 0, l = F(i, function(L) {
          var x = [], y = [];
          ta(L, x, y);
          var G = (y[1] - x[1]) * (y[0] - x[0]);
          return u += G, { poly: L, area: G };
        });
        l.sort(function(L, x) {
          return x.area - L.area;
        });
        for (var f = r, s = 0; s < d; s++) {
          var c = l[s];
          if (f <= 0)
            break;
          var p = s === d - 1 ? f : Math.ceil(c.area / u * r);
          p < 0 || (nr(Wr, {
            points: c.poly
          }, p, n), f -= p);
        }
      }
      t = Ia;
      break;
  }
  if (!t)
    return Ha(a, r);
  for (var g = [], s = 0; s < n.length; s++) {
    var h = new t();
    h.setShape(n[s]), Za(a, h), g.push(h);
  }
  return g;
}
function ja(a, r) {
  var n = a.length, e = r.length;
  if (n === e)
    return [a, r];
  for (var t = [], v = [], o = n < e ? a : r, i = Math.min(n, e), d = Math.abs(e - n) / 6, s = (i - 2) / 6, u = Math.ceil(d / s) + 1, l = [o[0], o[1]], f = d, c = 2; c < i; ) {
    var p = o[c - 2], g = o[c - 1], h = o[c++], L = o[c++], x = o[c++], y = o[c++], G = o[c++], M = o[c++];
    if (f <= 0) {
      l.push(h, L, x, y, G, M);
      continue;
    }
    for (var T = Math.min(f, u - 1) + 1, _ = 1; _ <= T; _++) {
      var D = _ / T;
      tr(p, h, x, G, D, t), tr(g, L, y, M, D, v), p = t[3], g = v[3], l.push(t[1], v[1], t[2], v[2], p, g), h = t[5], L = v[5], x = t[6], y = v[6];
    }
    f -= T - 1;
  }
  return o === a ? [l, r] : [a, l];
}
function jr(a, r) {
  for (var n = a.length, e = a[n - 2], t = a[n - 1], v = [], o = 0; o < r.length; )
    v[o++] = e, v[o++] = t;
  return v;
}
function Ka(a, r) {
  for (var n, e, t, v = [], o = [], i = 0; i < Math.max(a.length, r.length); i++) {
    var d = a[i], s = r[i], u = void 0, l = void 0;
    d ? s ? (n = ja(d, s), u = n[0], l = n[1], e = u, t = l) : (l = jr(t || d, d), u = d) : (u = jr(e || s, s), l = s), v.push(u), o.push(l);
  }
  return [v, o];
}
function Kr(a) {
  for (var r = 0, n = 0, e = 0, t = a.length, v = 0, o = t - 2; v < t; o = v, v += 2) {
    var i = a[o], d = a[o + 1], s = a[v], u = a[v + 1], l = i * u - s * d;
    r += l, n += (i + s) * l, e += (d + u) * l;
  }
  return r === 0 ? [a[0] || 0, a[1] || 0] : [n / r / 3, e / r / 3, r];
}
function Ja(a, r, n, e) {
  for (var t = (a.length - 2) / 6, v = 1 / 0, o = 0, i = a.length, d = i - 2, s = 0; s < t; s++) {
    for (var u = s * 6, l = 0, f = 0; f < i; f += 2) {
      var c = f === 0 ? u : (u + f - 2) % d + 2, p = a[c] - n[0], g = a[c + 1] - n[1], h = r[f] - e[0], L = r[f + 1] - e[1], x = h - p, y = L - g;
      l += x * x + y * y;
    }
    l < v && (v = l, o = s);
  }
  return o;
}
function $a(a) {
  for (var r = [], n = a.length, e = 0; e < n; e += 2)
    r[e] = a[n - e - 2], r[e + 1] = a[n - e - 1];
  return r;
}
function Fa(a, r, n, e) {
  for (var t = [], v, o = 0; o < a.length; o++) {
    var i = a[o], d = r[o], s = Kr(i), u = Kr(d);
    v == null && (v = s[2] < 0 != u[2] < 0);
    var l = [], f = [], c = 0, p = 1 / 0, g = [], h = i.length;
    v && (i = $a(i));
    for (var L = Ja(i, d, s, u) * 6, x = h - 2, y = 0; y < x; y += 2) {
      var G = (L + y) % x + 2;
      l[y + 2] = i[G] - s[0], l[y + 3] = i[G + 1] - s[1];
    }
    if (l[0] = i[L] - s[0], l[1] = i[L + 1] - s[1], n > 0)
      for (var M = e / n, T = -e / 2; T <= e / 2; T += M) {
        for (var _ = Math.sin(T), D = Math.cos(T), I = 0, y = 0; y < i.length; y += 2) {
          var E = l[y], N = l[y + 1], O = d[y] - u[0], R = d[y + 1] - u[1], P = O * D - R * _, A = O * _ + R * D;
          g[y] = P, g[y + 1] = A;
          var m = P - E, U = A - N;
          I += m * m + U * U;
        }
        if (I < p) {
          p = I, c = T;
          for (var V = 0; V < g.length; V++)
            f[V] = g[V];
        }
      }
    else
      for (var X = 0; X < h; X += 2)
        f[X] = d[X] - u[0], f[X + 1] = d[X + 1] - u[1];
    t.push({
      from: l,
      to: f,
      fromCp: s,
      toCp: u,
      rotation: -c
    });
  }
  return t;
}
function ir(a) {
  return a.__isCombineMorphing;
}
var va = "__mOriginal_";
function vr(a, r, n) {
  var e = va + r, t = a[e] || a[r];
  a[e] || (a[e] = a[r]);
  var v = n.replace, o = n.after, i = n.before;
  a[r] = function() {
    var d = arguments, s;
    return i && i.apply(this, d), v ? s = v.apply(this, d) : s = t.apply(this, d), o && o.apply(this, d), s;
  };
}
function B(a, r) {
  var n = va + r;
  a[n] && (a[r] = a[n], a[n] = null);
}
function Jr(a, r) {
  for (var n = 0; n < a.length; n++)
    for (var e = a[n], t = 0; t < e.length; ) {
      var v = e[t], o = e[t + 1];
      e[t++] = r[0] * v + r[2] * o + r[4], e[t++] = r[1] * v + r[3] * o + r[5];
    }
}
function oa(a, r) {
  var n = a.getUpdatedPathProxy(), e = r.getUpdatedPathProxy(), t = Ka(Mr(n), Mr(e)), v = t[0], o = t[1], i = a.getComputedTransform(), d = r.getComputedTransform();
  function s() {
    this.transform = null;
  }
  i && Jr(v, i), d && Jr(o, d), vr(r, "updateTransform", { replace: s }), r.transform = null;
  var u = Fa(v, o, 10, Math.PI), l = [];
  vr(r, "buildPath", { replace: function(f) {
    for (var c = r.__morphT, p = 1 - c, g = [], h = 0; h < u.length; h++) {
      var L = u[h], x = L.from, y = L.to, G = L.rotation * c, M = L.fromCp, T = L.toCp, _ = Math.sin(G), D = Math.cos(G);
      _a(g, M, T, c);
      for (var I = 0; I < x.length; I += 2) {
        var E = x[I], N = x[I + 1], O = y[I], R = y[I + 1], P = E * p + O * c, A = N * p + R * c;
        l[I] = P * D - A * _ + g[0], l[I + 1] = P * _ + A * D + g[1];
      }
      var m = l[0], U = l[1];
      f.moveTo(m, U);
      for (var I = 2; I < x.length; ) {
        var O = l[I++], R = l[I++], V = l[I++], X = l[I++], q = l[I++], Z = l[I++];
        m === O && U === R && V === q && X === Z ? f.lineTo(q, Z) : f.bezierCurveTo(O, R, V, X, q, Z), m = q, U = Z;
      }
    }
  } });
}
function Dr(a, r, n) {
  if (!a || !r)
    return r;
  var e = n.done, t = n.during;
  oa(a, r), r.__morphT = 0;
  function v() {
    B(r, "buildPath"), B(r, "updateTransform"), r.__morphT = -1, r.createPathProxy(), r.dirtyShape();
  }
  return r.animateTo({
    __morphT: 1
  }, j({
    during: function(o) {
      r.dirtyShape(), t && t(o);
    },
    done: function() {
      v(), e && e();
    }
  }, n)), r;
}
function ba(a, r, n, e, t, v) {
  var o = 16;
  a = t === n ? 0 : Math.round(32767 * (a - n) / (t - n)), r = v === e ? 0 : Math.round(32767 * (r - e) / (v - e));
  for (var i = 0, d, s = (1 << o) / 2; s > 0; s /= 2) {
    var u = 0, l = 0;
    (a & s) > 0 && (u = 1), (r & s) > 0 && (l = 1), i += s * s * (3 * u ^ l), l === 0 && (u === 1 && (a = s - 1 - a, r = s - 1 - r), d = a, a = r, r = d);
  }
  return i;
}
function or(a) {
  var r = 1 / 0, n = 1 / 0, e = -1 / 0, t = -1 / 0, v = F(a, function(i) {
    var d = i.getBoundingRect(), s = i.getComputedTransform(), u = d.x + d.width / 2 + (s ? s[4] : 0), l = d.y + d.height / 2 + (s ? s[5] : 0);
    return r = Math.min(u, r), n = Math.min(l, n), e = Math.max(u, e), t = Math.max(l, t), [u, l];
  }), o = F(v, function(i, d) {
    return {
      cp: i,
      z: ba(i[0], i[1], r, n, e, t),
      path: a[d]
    };
  });
  return o.sort(function(i, d) {
    return i.z - d.z;
  }).map(function(i) {
    return i.path;
  });
}
function sa(a) {
  return Wa(a.path, a.count);
}
function Ir() {
  return {
    fromIndividuals: [],
    toIndividuals: [],
    count: 0
  };
}
function wa(a, r, n) {
  var e = [];
  function t(M) {
    for (var T = 0; T < M.length; T++) {
      var _ = M[T];
      ir(_) ? t(_.childrenRef()) : _ instanceof rr && e.push(_);
    }
  }
  t(a);
  var v = e.length;
  if (!v)
    return Ir();
  var o = n.dividePath || sa, i = o({
    path: r,
    count: v
  });
  if (i.length !== v)
    return console.error("Invalid morphing: unmatched splitted path"), Ir();
  e = or(e), i = or(i);
  for (var d = n.done, s = n.during, u = n.individualDelay, l = new ea(), f = 0; f < v; f++) {
    var c = e[f], p = i[f];
    p.parent = r, p.copyTransform(l), u || oa(c, p);
  }
  r.__isCombineMorphing = !0, r.childrenRef = function() {
    return i;
  };
  function g(M) {
    for (var T = 0; T < i.length; T++)
      i[T].addSelfToZr(M);
  }
  vr(r, "addSelfToZr", {
    after: function(M) {
      g(M);
    }
  }), vr(r, "removeSelfFromZr", {
    after: function(M) {
      for (var T = 0; T < i.length; T++)
        i[T].removeSelfFromZr(M);
    }
  });
  function h() {
    r.__isCombineMorphing = !1, r.__morphT = -1, r.childrenRef = null, B(r, "addSelfToZr"), B(r, "removeSelfFromZr");
  }
  var L = i.length;
  if (u)
    for (var x = L, y = function() {
      x--, x === 0 && (h(), d && d());
    }, f = 0; f < L; f++) {
      var G = u ? j({
        delay: (n.delay || 0) + u(f, L, e[f], i[f]),
        done: y
      }, n) : n;
      Dr(e[f], i[f], G);
    }
  else
    r.__morphT = 0, r.animateTo({
      __morphT: 1
    }, j({
      during: function(M) {
        for (var T = 0; T < L; T++) {
          var _ = i[T];
          _.__morphT = r.__morphT, _.dirtyShape();
        }
        s && s(M);
      },
      done: function() {
        h();
        for (var M = 0; M < a.length; M++)
          B(a[M], "updateTransform");
        d && d();
      }
    }, n));
  return r.__zr && g(r.__zr), {
    fromIndividuals: e,
    toIndividuals: i,
    count: L
  };
}
function za(a, r, n) {
  var e = r.length, t = [], v = n.dividePath || sa;
  function o(c) {
    for (var p = 0; p < c.length; p++) {
      var g = c[p];
      ir(g) ? o(g.childrenRef()) : g instanceof rr && t.push(g);
    }
  }
  if (ir(a)) {
    o(a.childrenRef());
    var i = t.length;
    if (i < e)
      for (var d = 0, s = i; s < e; s++)
        t.push(Lr(t[d++ % i]));
    t.length = e;
  } else {
    t = v({ path: a, count: e });
    for (var u = a.getComputedTransform(), s = 0; s < t.length; s++)
      t[s].setLocalTransform(u);
    if (t.length !== e)
      return console.error("Invalid morphing: unmatched splitted path"), Ir();
  }
  t = or(t), r = or(r);
  for (var l = n.individualDelay, s = 0; s < e; s++) {
    var f = l ? j({
      delay: (n.delay || 0) + l(s, e, t[s], r[s])
    }, n) : n;
    Dr(t[s], r[s], f);
  }
  return {
    fromIndividuals: t,
    toIndividuals: r,
    count: r.length
  };
}
function $r(a) {
  return k(a[0]);
}
function Fr(a, r) {
  for (var n = [], e = a.length, t = 0; t < e; t++)
    n.push({
      one: a[t],
      many: []
    });
  for (var t = 0; t < r.length; t++) {
    var v = r[t].length, o = void 0;
    for (o = 0; o < v; o++)
      n[o % e].many.push(r[t][o]);
  }
  for (var i = 0, t = e - 1; t >= 0; t--)
    if (!n[t].many.length) {
      var d = n[i].many;
      if (d.length <= 1)
        if (i)
          i = 0;
        else
          return n;
      var v = d.length, s = Math.ceil(v / 2);
      n[t].many = d.slice(s, v), n[i].many = d.slice(0, s), i++;
    }
  return n;
}
var Ba = {
  clone: function(a) {
    for (var r = [], n = 1 - Math.pow(1 - a.path.style.opacity, 1 / a.count), e = 0; e < a.count; e++) {
      var t = Lr(a.path);
      t.setStyle("opacity", n), r.push(t);
    }
    return r;
  },
  // Use the default divider
  split: null
};
function cr(a, r, n, e, t, v) {
  if (!a.length || !r.length)
    return;
  var o = _r("update", e, t);
  if (!(o && o.duration > 0))
    return;
  var i = e.getModel("universalTransition").get("delay"), d = Object.assign({
    // Need to setToFinal so the further calculation based on the style can be correct.
    // Like emphasis color.
    setToFinal: !0
  }, o), s, u;
  $r(a) && (s = a, u = r), $r(r) && (s = r, u = a);
  function l(L, x, y, G, M) {
    var T = L.many, _ = L.one;
    if (T.length === 1 && !M) {
      var D = x ? T[0] : _, I = x ? _ : T[0];
      if (ir(D))
        l({
          many: [D],
          one: I
        }, !0, y, G, !0);
      else {
        var E = i ? j({
          delay: i(y, G)
        }, d) : d;
        Dr(D, I, E), v(D, I, D, I, E);
      }
    } else
      for (var N = j({
        dividePath: Ba[n],
        individualDelay: i && function(U, V, X, q) {
          return i(U + y, G);
        }
      }, d), O = x ? wa(T, _, N) : za(_, T, N), R = O.fromIndividuals, P = O.toIndividuals, A = R.length, m = 0; m < A; m++) {
        var E = i ? j({
          delay: i(m, A)
        }, d) : d;
        v(R[m], P[m], x ? T[m] : L.one, x ? L.one : T[m], E);
      }
  }
  for (var f = s ? s === a : a.length > r.length, c = s ? Fr(u, s) : Fr(f ? r : a, [f ? a : r]), p = 0, g = 0; g < c.length; g++)
    p += c[g].many.length;
  for (var h = 0, g = 0; g < c.length; g++)
    l(c[g], f, h, p), h += c[g].many.length;
}
function Q(a) {
  if (!a)
    return [];
  if (k(a)) {
    for (var r = [], n = 0; n < a.length; n++)
      r.push(Q(a[n]));
    return r;
  }
  var e = [];
  return a.traverse(function(t) {
    t instanceof rr && !t.disableMorphing && !t.invisible && !t.ignore && e.push(t);
  }), e;
}
var da = 1e4, ka = 0, br = 1, wr = 2, re = sr();
function ae(a, r) {
  for (var n = a.dimensions, e = 0; e < n.length; e++) {
    var t = a.getDimensionInfo(n[e]);
    if (t && t.otherDims[r] === 0)
      return n[e];
  }
}
function ee(a, r, n) {
  var e = a.getDimensionInfo(n), t = e && e.ordinalMeta;
  if (e) {
    var v = a.get(e.name, r);
    return t && t.categories[v] || v + "";
  }
}
function zr(a, r, n, e) {
  var t = e ? "itemChildGroupId" : "itemGroupId", v = ae(a, t);
  if (v) {
    var o = ee(a, r, v);
    return o;
  }
  var i = a.getRawDataItem(r), d = e ? "childGroupId" : "groupId";
  if (i && i[d])
    return i[d] + "";
  if (!e)
    return n || a.getId(r);
}
function Br(a) {
  var r = [];
  return C(a, function(n) {
    var e = n.data, t = n.dataGroupId;
    if (e.count() > da) {
      process.env.NODE_ENV !== "production" && na("Universal transition is disabled on large data > 10k.");
      return;
    }
    for (var v = e.getIndices(), o = 0; o < v.length; o++)
      r.push({
        data: e,
        groupId: zr(e, o, t, !1),
        childGroupId: zr(e, o, t, !0),
        divide: n.divide,
        dataIndex: o
      });
  }), r;
}
function gr(a, r, n) {
  a.traverse(function(e) {
    e instanceof rr && yr(e, {
      style: {
        opacity: 0
      }
    }, r, {
      dataIndex: n,
      isFrom: !0
    });
  });
}
function hr(a) {
  if (a.parent) {
    var r = a.getComputedTransform();
    a.setLocalTransform(r), a.parent.remove(a);
  }
}
function J(a) {
  a.stopAnimation(), a.isGroup && a.traverse(function(r) {
    r.stopAnimation();
  });
}
function te(a, r, n) {
  var e = _r("update", n, r);
  e && a.traverse(function(t) {
    if (t instanceof Da) {
      var v = xa(t);
      v && t.animateFrom({
        style: v
      }, e);
    }
  });
}
function ne(a, r) {
  var n = a.length;
  if (n !== r.length)
    return !1;
  for (var e = 0; e < n; e++) {
    var t = a[e], v = r[e];
    if (t.data.getId(t.dataIndex) !== v.data.getId(v.dataIndex))
      return !1;
  }
  return !0;
}
function ua(a, r, n) {
  var e = Br(a), t = Br(r);
  function v(y, G, M, T, _) {
    (M || y) && G.animateFrom({
      style: M && M !== y ? Xr(Xr({}, M.style), y.style) : y.style
    }, _);
  }
  var o = !1, i = ka, d = z(), s = z();
  e.forEach(function(y) {
    y.groupId && d.set(y.groupId, !0), y.childGroupId && s.set(y.childGroupId, !0);
  });
  for (var u = 0; u < t.length; u++) {
    var l = t[u].groupId;
    if (s.get(l)) {
      i = br;
      break;
    }
    var f = t[u].childGroupId;
    if (f && d.get(f)) {
      i = wr;
      break;
    }
  }
  function c(y, G) {
    return function(M) {
      var T = M.data, _ = M.dataIndex;
      return G ? T.getId(_) : y ? i === br ? M.childGroupId : M.groupId : i === wr ? M.childGroupId : M.groupId;
    };
  }
  var p = ne(e, t), g = {};
  if (!p)
    for (var u = 0; u < t.length; u++) {
      var h = t[u], L = h.data.getItemGraphicEl(h.dataIndex);
      L && (g[L.id] = !0);
    }
  function x(y, G) {
    var M = e[G], T = t[y], _ = T.data.hostModel, D = M.data.getItemGraphicEl(M.dataIndex), I = T.data.getItemGraphicEl(T.dataIndex);
    if (D === I) {
      I && te(I, T.dataIndex, _);
      return;
    }
    // We can't use the elements that already being morphed
    D && g[D.id] || I && (J(I), D ? (J(D), hr(D), o = !0, cr(Q(D), Q(I), T.divide, _, y, v)) : gr(I, _, y));
  }
  new Yr(e, t, c(!0, p), c(!1, p), null, "multiple").update(x).updateManyToOne(function(y, G) {
    var M = t[y], T = M.data, _ = T.hostModel, D = T.getItemGraphicEl(M.dataIndex), I = b(F(G, function(E) {
      return e[E].data.getItemGraphicEl(e[E].dataIndex);
    }), function(E) {
      return E && E !== D && !g[E.id];
    });
    D && (J(D), I.length ? (C(I, function(E) {
      J(E), hr(E);
    }), o = !0, cr(Q(I), Q(D), M.divide, _, y, v)) : gr(D, _, M.dataIndex));
  }).updateOneToMany(function(y, G) {
    var M = e[G], T = M.data.getItemGraphicEl(M.dataIndex);
    if (!(T && g[T.id])) {
      var _ = b(F(y, function(I) {
        return t[I].data.getItemGraphicEl(t[I].dataIndex);
      }), function(I) {
        return I && I !== T;
      }), D = t[y[0]].data.hostModel;
      _.length && (C(_, function(I) {
        return J(I);
      }), T ? (J(T), hr(T), o = !0, cr(
        Q(T),
        Q(_),
        M.divide,
        // Use divide on old.
        D,
        y[0],
        v
      )) : C(_, function(I) {
        return gr(I, D, y[0]);
      }));
    }
  }).updateManyToMany(function(y, G) {
    new Yr(G, y, function(M) {
      return e[M].data.getId(e[M].dataIndex);
    }, function(M) {
      return t[M].data.getId(t[M].dataIndex);
    }).update(function(M, T) {
      x(y[M], G[T]);
    }).execute();
  }).execute(), o && C(r, function(y) {
    var G = y.data, M = G.hostModel, T = M && n.getViewOfSeriesModel(M), _ = _r("update", M, 0);
    T && M.isAnimationEnabled() && _ && _.duration > 0 && T.group.traverse(function(D) {
      D instanceof rr && !D.animators.length && D.animateFrom({
        style: {
          opacity: 0
        }
      }, _);
    });
  });
}
function kr(a) {
  var r = a.getModel("universalTransition").get("seriesKey");
  return r || a.id;
}
function ra(a) {
  return k(a) ? a.sort().join(",") : a;
}
function H(a) {
  if (a.hostModel)
    return a.hostModel.getModel("universalTransition").get("divideShape");
}
function ie(a, r) {
  var n = z(), e = z(), t = z();
  C(a.oldSeries, function(o, i) {
    var d = a.oldDataGroupIds[i], s = a.oldData[i], u = kr(o), l = ra(u);
    e.set(l, {
      dataGroupId: d,
      data: s
    }), k(u) && C(u, function(f) {
      t.set(f, {
        key: l,
        dataGroupId: d,
        data: s
      });
    });
  });
  function v(o) {
    n.get(o) && na("Duplicated seriesKey in universalTransition " + o);
  }
  return C(r.updatedSeries, function(o) {
    if (o.isUniversalTransitionEnabled() && o.isAnimationEnabled()) {
      var i = o.get("dataGroupId"), d = o.getData(), s = kr(o), u = ra(s), l = e.get(u);
      if (l)
        process.env.NODE_ENV !== "production" && v(u), n.set(u, {
          oldSeries: [{
            dataGroupId: l.dataGroupId,
            divide: H(l.data),
            data: l.data
          }],
          newSeries: [{
            dataGroupId: i,
            divide: H(d),
            data: d
          }]
        });
      else if (k(s)) {
        process.env.NODE_ENV !== "production" && v(u);
        var f = [];
        C(s, function(g) {
          var h = e.get(g);
          h.data && f.push({
            dataGroupId: h.dataGroupId,
            divide: H(h.data),
            data: h.data
          });
        }), f.length && n.set(u, {
          oldSeries: f,
          newSeries: [{
            dataGroupId: i,
            data: d,
            divide: H(d)
          }]
        });
      } else {
        var c = t.get(s);
        if (c) {
          var p = n.get(c.key);
          p || (p = {
            oldSeries: [{
              dataGroupId: c.dataGroupId,
              data: c.data,
              divide: H(c.data)
            }],
            newSeries: []
          }, n.set(c.key, p)), p.newSeries.push({
            dataGroupId: i,
            data: d,
            divide: H(d)
          });
        }
      }
    }
  }), n;
}
function aa(a, r) {
  for (var n = 0; n < a.length; n++) {
    var e = r.seriesIndex != null && r.seriesIndex === a[n].seriesIndex || r.seriesId != null && r.seriesId === a[n].id;
    if (e)
      return n;
  }
}
function ve(a, r, n, e) {
  var t = [], v = [];
  C(w(a.from), function(o) {
    var i = aa(r.oldSeries, o);
    i >= 0 && t.push({
      dataGroupId: r.oldDataGroupIds[i],
      data: r.oldData[i],
      // TODO can specify divideShape in transition.
      divide: H(r.oldData[i]),
      groupIdDim: o.dimension
    });
  }), C(w(a.to), function(o) {
    var i = aa(n.updatedSeries, o);
    if (i >= 0) {
      var d = n.updatedSeries[i].getData();
      v.push({
        dataGroupId: r.oldDataGroupIds[i],
        data: d,
        divide: H(d),
        groupIdDim: o.dimension
      });
    }
  }), t.length > 0 && v.length > 0 && ua(t, v, e);
}
function Ie(a) {
  a.registerUpdateLifecycle("series:beforeupdate", function(r, n, e) {
    C(w(e.seriesTransition), function(t) {
      C(w(t.to), function(v) {
        for (var o = e.updatedSeries, i = 0; i < o.length; i++)
          (v.seriesIndex != null && v.seriesIndex === o[i].seriesIndex || v.seriesId != null && v.seriesId === o[i].id) && (o[i][ur] = !0);
      });
    });
  }), a.registerUpdateLifecycle("series:transition", function(r, n, e) {
    var t = re(n);
    if (t.oldSeries && e.updatedSeries && e.optionChanged) {
      var v = e.seriesTransition;
      if (v)
        C(w(v), function(c) {
          ve(c, t, e, n);
        });
      else {
        var o = ie(t, e);
        C(o.keys(), function(c) {
          var p = o.get(c);
          ua(p.oldSeries, p.newSeries, n);
        });
      }
      C(e.updatedSeries, function(c) {
        c[ur] && (c[ur] = !1);
      });
    }
    for (var i = r.getSeries(), d = t.oldSeries = [], s = t.oldDataGroupIds = [], u = t.oldData = [], l = 0; l < i.length; l++) {
      var f = i[l].getData();
      f.count() < da && (d.push(i[l]), s.push(i[l].get("dataGroupId")), u.push(f));
    }
  });
}
export {
  Te as LabelLayout,
  Ie as UniversalTransition
};
//# sourceMappingURL=features-Ms4VTVvw.js.map
