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