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