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