import { defineComponent as ce, shallowRef as S, inject as j, toRefs as _e, computed as O, getCurrentInstance as de, watch as T, watchEffect as Q, onMounted as fe, onBeforeUnmount as le, h as V, unref as Y, nextTick as ve } from "vue";
import { F as he, G as pe, D as ge } from "./index-a857af7d.mjs";
var N = null;
function ze(e) {
  return N || (N = (window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function(t) {
    return setTimeout(t, 16);
  }).bind(window)), N(e);
}
var k = null;
function be(e) {
  k || (k = (window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || function(t) {
    clearTimeout(t);
  }).bind(window)), k(e);
}
function ye(e) {
  var t = document.createElement("style");
  return t.styleSheet ? t.styleSheet.cssText = e : t.appendChild(document.createTextNode(e)), (document.querySelector("head") || document.body).appendChild(t), t;
}
function H(e, t) {
  t === void 0 && (t = {});
  var r = document.createElement(e);
  return Object.keys(t).forEach(function(i) {
    r[i] = t[i];
  }), r;
}
function ee(e, t, r) {
  var i = window.getComputedStyle(e, r || null) || {
    display: "none"
  };
  return i[t];
}
function W(e) {
  if (!document.documentElement.contains(e))
    return {
      detached: !0,
      rendered: !1
    };
  for (var t = e; t !== document; ) {
    if (ee(t, "display") === "none")
      return {
        detached: !1,
        rendered: !1
      };
    t = t.parentNode;
  }
  return {
    detached: !1,
    rendered: !0
  };
}
var we = '.resize-triggers{visibility:hidden;opacity:0;pointer-events:none}.resize-contract-trigger,.resize-contract-trigger:before,.resize-expand-trigger,.resize-triggers{content:"";position:absolute;top:0;left:0;height:100%;width:100%;overflow:hidden}.resize-contract-trigger,.resize-expand-trigger{background:#eee;overflow:auto}.resize-contract-trigger:before{width:200%;height:200%}', P = 0, R = null;
function Oe(e, t) {
  e.__resize_mutation_handler__ || (e.__resize_mutation_handler__ = xe.bind(e));
  var r = e.__resize_listeners__;
  if (!r) {
    if (e.__resize_listeners__ = [], window.ResizeObserver) {
      var i = e.offsetWidth, n = e.offsetHeight, s = new ResizeObserver(function() {
        !e.__resize_observer_triggered__ && (e.__resize_observer_triggered__ = !0, e.offsetWidth === i && e.offsetHeight === n) || D(e);
      }), _ = W(e), z = _.detached, l = _.rendered;
      e.__resize_observer_triggered__ = z === !1 && l === !1, e.__resize_observer__ = s, s.observe(e);
    } else if (e.attachEvent && e.addEventListener)
      e.__resize_legacy_resize_handler__ = function() {
        D(e);
      }, e.attachEvent("onresize", e.__resize_legacy_resize_handler__), document.addEventListener("DOMSubtreeModified", e.__resize_mutation_handler__);
    else if (P || (R = ye(we)), Ce(e), e.__resize_rendered__ = W(e).rendered, window.MutationObserver) {
      var v = new MutationObserver(e.__resize_mutation_handler__);
      v.observe(document, {
        attributes: !0,
        childList: !0,
        characterData: !0,
        subtree: !0
      }), e.__resize_mutation_observer__ = v;
    }
  }
  e.__resize_listeners__.push(t), P++;
}
function me(e, t) {
  var r = e.__resize_listeners__;
  if (r) {
    if (t && r.splice(r.indexOf(t), 1), !r.length || !t) {
      if (e.detachEvent && e.removeEventListener) {
        e.detachEvent("onresize", e.__resize_legacy_resize_handler__), document.removeEventListener("DOMSubtreeModified", e.__resize_mutation_handler__);
        return;
      }
      e.__resize_observer__ ? (e.__resize_observer__.unobserve(e), e.__resize_observer__.disconnect(), e.__resize_observer__ = null) : (e.__resize_mutation_observer__ && (e.__resize_mutation_observer__.disconnect(), e.__resize_mutation_observer__ = null), e.removeEventListener("scroll", U), e.removeChild(e.__resize_triggers__.triggers), e.__resize_triggers__ = null), e.__resize_listeners__ = null;
    }
    !--P && R && R.parentNode.removeChild(R);
  }
}
function Ee(e) {
  var t = e.__resize_last__, r = t.width, i = t.height, n = e.offsetWidth, s = e.offsetHeight;
  return n !== r || s !== i ? {
    width: n,
    height: s
  } : null;
}
function xe() {
  var e = W(this), t = e.rendered, r = e.detached;
  t !== this.__resize_rendered__ && (!r && this.__resize_triggers__ && (B(this), this.addEventListener("scroll", U, !0)), this.__resize_rendered__ = t, D(this));
}
function U() {
  var e = this;
  B(this), this.__resize_raf__ && be(this.__resize_raf__), this.__resize_raf__ = ze(function() {
    var t = Ee(e);
    t && (e.__resize_last__ = t, D(e));
  });
}
function D(e) {
  !e || !e.__resize_listeners__ || e.__resize_listeners__.forEach(function(t) {
    t.call(e, e);
  });
}
function Ce(e) {
  var t = ee(e, "position");
  (!t || t === "static") && (e.style.position = "relative"), e.__resize_old_position__ = t, e.__resize_last__ = {};
  var r = H("div", {
    className: "resize-triggers"
  }), i = H("div", {
    className: "resize-expand-trigger"
  }), n = H("div"), s = H("div", {
    className: "resize-contract-trigger"
  });
  i.appendChild(n), r.appendChild(i), r.appendChild(s), e.appendChild(r), e.__resize_triggers__ = {
    triggers: r,
    expand: i,
    expandChild: n,
    contract: s
  }, B(e), e.addEventListener("scroll", U, !0), e.__resize_last__ = {
    width: e.offsetWidth,
    height: e.offsetHeight
  };
}
function B(e) {
  var t = e.__resize_triggers__, r = t.expand, i = t.expandChild, n = t.contract, s = n.scrollWidth, _ = n.scrollHeight, z = r.offsetWidth, l = r.offsetHeight, v = r.scrollWidth, f = r.scrollHeight;
  n.scrollLeft = s, n.scrollTop = _, i.style.width = z + 1 + "px", i.style.height = l + 1 + "px", r.scrollLeft = v, r.scrollTop = f;
}
var g = function() {
  return g = Object.assign || function(e) {
    for (var t, r = 1, i = arguments.length; r < i; r++)
      for (var n in t = arguments[r])
        Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
    return e;
  }, g.apply(this, arguments);
};
var Ae = ["getWidth", "getHeight", "getDom", "getOption", "resize", "dispatchAction", "convertToPixel", "convertFromPixel", "containPixel", "getDataURL", "getConnectedDataURL", "appendData", "clear", "isDisposed", "dispose"];
function Le(e) {
  return t = /* @__PURE__ */ Object.create(null), Ae.forEach(function(r) {
    t[r] = function(i) {
      return function() {
        for (var n = [], s = 0; s < arguments.length; s++)
          n[s] = arguments[s];
        if (!e.value)
          throw new Error("ECharts is not initialized yet.");
        return e.value[i].apply(e.value, n);
      };
    }(r);
  }), t;
  var t;
}
var Se = { autoresize: [Boolean, Object] }, je = /^on[^a-z]/, Te = function(e) {
  return je.test(e);
};
function F(e, t) {
  var r = Y(e);
  return r && typeof r == "object" && "value" in r ? r.value || t : r || t;
}
var He = "ecLoadingOptions", Fe = { loading: Boolean, loadingOptions: Object }, m = null, te = "x-vue-echarts", X = [], E = [];
(function(e, t) {
  if (e && typeof document < "u") {
    var r, i = t.prepend === !0 ? "prepend" : "append", n = t.singleTag === !0, s = typeof t.container == "string" ? document.querySelector(t.container) : document.getElementsByTagName("head")[0];
    if (n) {
      var _ = X.indexOf(s);
      _ === -1 && (_ = X.push(s) - 1, E[_] = {}), r = E[_] && E[_][i] ? E[_][i] : E[_][i] = z();
    } else
      r = z();
    e.charCodeAt(0) === 65279 && (e = e.substring(1)), r.styleSheet ? r.styleSheet.cssText += e : r.appendChild(document.createTextNode(e));
  }
  function z() {
    var l = document.createElement("style");
    if (l.setAttribute("type", "text/css"), t.attributes)
      for (var v = Object.keys(t.attributes), f = 0; f < v.length; f++)
        l.setAttribute(v[f], t.attributes[v[f]]);
    var x = i === "prepend" ? "afterbegin" : "beforeend";
    return s.insertAdjacentElement(x, l), l;
  }
})(`x-vue-echarts{display:flex;flex-direction:column;width:100%;height:100%;min-width:0}
.vue-echarts-inner{flex-grow:1;min-width:0}
`, {});
var Re = function() {
  if (m != null)
    return m;
  if (typeof HTMLElement > "u" || typeof customElements > "u")
    return m = !1;
  try {
    new Function("tag", `class EChartsElement extends HTMLElement {
  __dispose = null;

  disconnectedCallback() {
    if (this.__dispose) {
      this.__dispose();
      this.__dispose = null;
    }
  }
}

if (customElements.get(tag) == null) {
  customElements.define(tag, EChartsElement);
}
`)(te);
  } catch {
    return m = !1;
  }
  return m = !0;
}(), De = "ecTheme", Me = "ecInitOptions", Ne = "ecUpdateOptions", Ue = ce({ name: "echarts", props: g(g({ option: Object, theme: { type: [Object, String] }, initOptions: Object, updateOptions: Object, group: String, manualUpdate: Boolean }, Se), Fe), emits: {}, inheritAttrs: !1, setup: function(e, t) {
  var r = t.attrs, i = S(), n = S(), s = S(), _ = S(), z = j(De, null), l = j(Me, null), v = j(Ne, null), f = _e(e), x = f.autoresize, re = f.manualUpdate, ne = f.loading, ie = f.loadingOptions, se = O(function() {
    return _.value || e.option || null;
  }), q = O(function() {
    return e.theme || F(z, {});
  }), I = O(function() {
    return e.initOptions || F(l, {});
  }), $ = O(function() {
    return e.updateOptions || F(v, {});
  }), oe = O(function() {
    return function(d) {
      var o = {};
      for (var c in d)
        Te(c) || (o[c] = d[c]);
      return o;
    }(r);
  }), ae = de().proxy.$listeners;
  function C(d) {
    if (n.value) {
      var o = s.value = pe(n.value, q.value, I.value);
      e.group && (o.group = e.group);
      var c = ae;
      c || (c = {}, Object.keys(r).filter(function(u) {
        return u.indexOf("on") === 0 && u.length > 2;
      }).forEach(function(u) {
        var a = u.charAt(2).toLowerCase() + u.slice(3);
        a.substring(a.length - 4) === "Once" && (a = "~".concat(a.substring(0, a.length - 4))), c[a] = r[u];
      })), Object.keys(c).forEach(function(u) {
        var a = c[u];
        if (a) {
          var h = u.toLowerCase();
          h.charAt(0) === "~" && (h = h.substring(1), a.__once__ = !0);
          var b = o;
          if (h.indexOf("zr:") === 0 && (b = o.getZr(), h = h.substring(3)), a.__once__) {
            delete a.__once__;
            var L = a;
            a = function() {
              for (var w = [], y = 0; y < arguments.length; y++)
                w[y] = arguments[y];
              L.apply(void 0, w), b.off(h, a);
            };
          }
          b.on(h, a);
        }
      }), x.value ? ve(function() {
        o && !o.isDisposed() && o.resize(), p();
      }) : p();
    }
    function p() {
      var u = d || se.value;
      u && o.setOption(u, $.value);
    }
  }
  function M() {
    s.value && (s.value.dispose(), s.value = void 0);
  }
  var A = null;
  T(re, function(d) {
    typeof A == "function" && (A(), A = null), d || (A = T(function() {
      return e.option;
    }, function(o, c) {
      o && (s.value ? s.value.setOption(o, g({ notMerge: o !== c }, $.value)) : C());
    }, { deep: !0 }));
  }, { immediate: !0 }), T([q, I], function() {
    M(), C();
  }, { deep: !0 }), Q(function() {
    e.group && s.value && (s.value.group = e.group);
  });
  var ue = Le(s);
  return function(d, o, c) {
    var p = j(He, {}), u = O(function() {
      return g(g({}, F(p, {})), c == null ? void 0 : c.value);
    });
    Q(function() {
      var a = d.value;
      a && (o.value ? a.showLoading(u.value) : a.hideLoading());
    });
  }(s, ne, ie), function(d, o, c) {
    var p = null;
    T([c, d, o], function(u, a, h) {
      var b = u[0], L = u[1], w = u[2];
      if (b && L && w) {
        var y = w === !0 ? {} : w, J = y.throttle, G = J === void 0 ? 100 : J, Z = y.onResize, K = function() {
          L.resize(), Z == null || Z();
        };
        p = G ? he(K, G) : K, Oe(b, p);
      }
      h(function() {
        b && p && me(b, p);
      });
    });
  }(s, x, n), fe(function() {
    C();
  }), le(function() {
    Re && i.value ? i.value.__dispose = M : M();
  }), g({ chart: s, root: i, inner: n, setOption: function(d, o) {
    e.manualUpdate && (_.value = d), s.value ? s.value.setOption(d, o || {}) : C(d);
  }, nonEventAttrs: oe }, ue);
}, render: function() {
  var e = g({}, this.nonEventAttrs);
  return e.ref = "root", e.class = e.class ? ["echarts"].concat(e.class) : "echarts", V(te, e, [V("div", { ref: "inner", class: "vue-echarts-inner" })]);
} });
function Be(e) {
  if (!e)
    return "";
  if (e = e.trim(), /^\d+(\.\d+)?$/.test(e))
    return parseFloat(e);
  try {
    return JSON.parse(e);
  } catch {
    return e;
  }
}
function qe(e, t, r, i) {
  for (const n of i)
    ke(e, t, r + "-" + n, n);
}
function ke(e, t, r, i) {
  const n = t[r];
  !n && n !== !1 || (e[i] = n);
}
function Ie(e, t) {
  const r = t.optionOther;
  if (!r)
    return;
  const i = JSON.parse(r);
  for (const n of Object.keys(i))
    e[n] = i[n];
}
function $e(e, t, r) {
  if (r = Y(r), !r || !Array.isArray(r) || r.length <= 0)
    return;
  const i = e.dataset;
  let n;
  i == null ? (n = {}, e.dataset = n) : Array.isArray(i) && i.length > 0 ? n = i[0] : typeof i == "object" && (n = i), n && (n.source = r, t.dimensions && (n.dimensions = ge(t.dimensions)));
}
export {
  Ue as B,
  $e as a,
  Ie as b,
  Be as c,
  ke as d,
  qe as p
};
