import { defineComponent as u, watch as i, openBlock as _, createElementBlock as b, createElementVNode as E, unref as O } from "vue";
import { cloneDeep as r, isEqual as g } from "lodash";
import { useChart as k } from "../../core/useChart.mjs";
const x = { class: "zerov-widget" }, D = ["id"], y = u({ name: "zv-chart-other-grid-percentage" }), S = /* @__PURE__ */ u({
  ...y,
  props: {
    basicOption: {},
    sources: {},
    useEvents: {},
    uuid: {}
  },
  emits: [
    "chart-click",
    "chart-dblclick",
    "chart-mousedown",
    "chart-mouseover",
    "chart-mouseout",
    "chart-contextmenu"
  ],
  setup(l, { expose: d, emit: h }) {
    const e = l, p = h, {
      id: m,
      setOption: o,
      chart: f,
      renderChart: a,
      renderData: c
    } = k({
      basicOption: r(e.basicOption),
      useEvents: r(e.useEvents),
      customRenderData: (t) => {
        t = r(t), window.SHJDatasourceV2({
          tId: e.uuid,
          sources: e.sources,
          callback: ({ data: s }) => {
            try {
              window.SHJParseEvent(e.useEvents, "dataListener", s);
              const n = [
                ...new Array(r(s[0].data[0].value) % 5 / 5 * 20).fill(Math.floor(r(s[0].data[0].value) / 5 + 1) * 5),
                ...new Array(20 - r(s[0].data[0].value) % 5 / 5 * 20).fill(Math.floor(r(s[0].data[0].value) / 5) * 5)
              ];
              t.title.text = r(s[0].data[0].value) + "%", t.dataset = {
                source: n.map((v, w) => [w, v])
              }, o(t);
            } catch {
              window.SHJParseEvent(e.useEvents, "dataListener", null), o(t);
            }
          }
        });
      },
      emit: p
    });
    return i(() => e.sources, () => {
      e.sources && e.sources.length > 0 && c(e.basicOption);
    }, {
      deep: !0
    }), i(() => r(e.basicOption), (t, s) => {
      g(t, s) || a(t);
    }, {
      deep: !0
    }), d({
      getEchartsInstance: () => f.value,
      refresh: () => {
        e.sources && e.sources.length > 0 && a(e.basicOption), c(e.basicOption);
      },
      refreshView: () => {
        e.sources && e.sources.length > 0 && a(e.basicOption);
      },
      refreshData: () => {
        c(e.basicOption);
      }
    }), (t, s) => (_(), b("div", x, [
      E("div", {
        id: O(m),
        class: "widget"
      }, null, 8, D)
    ]));
  }
});
export {
  S as default
};
