import { defineComponent as u, watch as a, openBlock as v, createElementBlock as _, createElementVNode as b, unref as w } from "vue";
import { cloneDeep as r, isEqual as E } from "lodash";
import { useChart as O } from "../../core/useChart.mjs";
import { parseDataset as o } from "../../utils/parseDataset.mjs";
const x = { class: "zerov-widget" }, g = ["id"], D = u({ name: "zv-chart-pie-index" }), V = /* @__PURE__ */ u({
  ...D,
  props: {
    basicOption: {},
    sources: {},
    useEvents: {},
    uuid: {}
  },
  emits: [
    "chart-click",
    "chart-dblclick",
    "chart-mousedown",
    "chart-mouseover",
    "chart-mouseout",
    "chart-contextmenu"
  ],
  setup(d, { expose: l, emit: h }) {
    const e = d, m = h, {
      id: p,
      setOption: n,
      chart: f,
      renderChart: c,
      renderData: i
    } = O({
      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), t.dataset = o(r(s)), t.title.text = (o(r(s)).source[0][o(r(s)).dimensions[1]] || 0) + t.title.text, n(t);
            } catch {
              window.SHJParseEvent(e.useEvents, "dataListener", null), n(t);
            }
          }
        });
      },
      emit: m
    });
    return a(() => e.sources, () => {
      e.sources && e.sources.length > 0 && i(e.basicOption);
    }, {
      deep: !0
    }), a(() => r(e.basicOption), (t, s) => {
      E(t, s) || c(t);
    }, {
      deep: !0
    }), l({
      getEchartsInstance: () => f.value,
      refresh: () => {
        e.sources && e.sources.length > 0 && c(e.basicOption), i(e.basicOption);
      },
      refreshView: () => {
        e.sources && e.sources.length > 0 && c(e.basicOption);
      },
      refreshData: () => {
        i(e.basicOption);
      }
    }), (t, s) => (v(), _("div", x, [
      b("div", {
        id: w(p),
        class: "widget"
      }, null, 8, g)
    ]));
  }
});
export {
  V as default
};
