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