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