import { defineComponent as h, createElementBlock as f, openBlock as v, createElementVNode as E, unref as _ } from "vue";
import { cloneDeep as s } from "lodash";
import { useCommonChart as D } from "./hooks/useCommonChart.mjs";
import { SHJDatasourceV2 as k } from "../../../../../commons/plugins/datasource/index.mjs";
import { useChart as x } from "../../hooks/useChart.mjs";
import { parseDataset as C } from "../../../../../commons/utils/parseDataset.mjs";
import { cloneSeries as L } from "../../../../../commons/utils/cloneSeries.mjs";
import { SHJParseEvent as c } from "../../../../../commons/plugins/event/index.mjs";
const S = { class: "zerov-widget" }, w = ["id"], M = /* @__PURE__ */ h({
  __name: "index",
  props: {
    option: {},
    sources: {},
    useEvents: {},
    uuid: {},
    isMultiSeries: { type: Boolean },
    customRenderData: { type: Function }
  },
  emits: ["dataListener", "chart-click", "chart-dblclick", "chart-mousedown", "chart-mouseover", "chart-mouseout", "chart-contextmenu"],
  setup(u, { expose: m, emit: d }) {
    const e = u, o = d, {
      id: p,
      setOption: n,
      chart: l,
      renderChart: a,
      renderData: i
    } = x({
      basicOption: s(e.option),
      useEvents: s(e.useEvents),
      customRenderData: (t) => {
        t = s(t), k.parse({
          tId: e.uuid,
          sources: e.sources,
          callback: ({ data: r }) => {
            try {
              if (o("dataListener", r), c.parseEvents(e.useEvents, "dataListener", r), e.customRenderData) {
                e.customRenderData(t, r, n);
                return;
              }
              t.dataset = C(s(r)), e.isMultiSeries && (t.series = L(r, t.series)), n(t);
            } catch {
              o("dataListener", null), c.parseEvents(e.useEvents, "dataListener", null), n(t);
            }
          }
        });
      },
      emits: o
    });
    return D(e, i, a), m({
      getEchartsInstance: () => l.value,
      refresh: () => {
        i(e.option), a(e.option);
      },
      refreshView: () => {
        a(e.option);
      },
      refreshData: () => {
        i(e.option);
      }
    }), (t, r) => (v(), f("div", S, [
      E("div", {
        id: _(p),
        class: "widget"
      }, null, 8, w)
    ]));
  }
});
export {
  M as default
};
