import { defineComponent as n, watch as i, createElementBlock as f, openBlock as v, createElementVNode as _, unref as b } from "vue";
import { cloneDeep as r, isEqual as E } from "lodash";
import { SHJDatasourceV2 as O } from "../../commons/core/datasource/index.mjs";
import { useChart as w } from "../../commons/core/useChart.mjs";
import { parseDataset as g } from "../../commons/utils/parseDataset.mjs";
import { cloneSeries as D } from "../../commons/utils/cloneSeries.mjs";
const k = { class: "zerov-widget" }, x = ["id"], S = n({ name: "zv-chart-line-temp" }), L = /* @__PURE__ */ n({
  ...S,
  props: {
    basicOption: {},
    sources: {},
    useEvents: {},
    uuid: {}
  },
  emits: [
    "chart-click",
    "chart-dblclick",
    "chart-mousedown",
    "chart-mouseover",
    "chart-mouseout",
    "chart-contextmenu"
  ],
  setup(u, { expose: d, emit: m }) {
    const e = u, l = m, {
      id: p,
      setOption: a,
      chart: h,
      renderChart: c,
      renderData: o
    } = w({
      basicOption: r(e.basicOption),
      useEvents: r(e.useEvents),
      customRenderData: (s) => {
        s = r(s), O.parse({
          tId: e.uuid,
          sources: e.sources,
          callback: ({ data: t }) => {
            try {
              window.SHJParseEvent(e.useEvents, "dataListener", t), s.dataset = g(r(t)), s.series = D(t, s.series), a(s);
            } catch {
              window.SHJParseEvent(e.useEvents, "dataListener", null), a(s);
            }
          }
        });
      },
      emit: l
    });
    return i(() => e.sources, () => {
      e.sources && e.sources.length > 0 && o(e.basicOption);
    }, {
      deep: !0
    }), i(() => r(e.basicOption), (s, t) => {
      E(s, t) || c(s);
    }, {
      deep: !0
    }), d({
      getEchartsInstance: () => h.value,
      refresh: () => {
        e.sources && e.sources.length > 0 && c(e.basicOption), o(e.basicOption);
      },
      refreshView: () => {
        e.sources && e.sources.length > 0 && c(e.basicOption);
      },
      refreshData: () => {
        o(e.basicOption);
      }
    }), (s, t) => (v(), f("div", k, [
      _("div", {
        id: b(p),
        class: "widget"
      }, null, 8, x)
    ]));
  }
});
export {
  L as default
};
