import { defineComponent as u, watch as n, openBlock as b, createElementBlock as v, createElementVNode as w, unref as E } from "vue";
import { cloneDeep as r, isEqual as O } from "lodash";
import { useChart as g } from "../../core/useChart.mjs";
const k = { class: "zerov-widget" }, D = ["id"], x = u({ name: "zv-chart-map-basic" }), I = /* @__PURE__ */ u({
  ...x,
  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: i,
      chart: f,
      renderChart: c,
      renderData: a
    } = g({
      basicOption: r(e.basicOption),
      useEvents: r(e.useEvents),
      customRenderData: (t) => {
        t = r(t), window.SHJDatasourceV2({
          tId: e.uuid,
          sources: e.sources,
          callback: (s) => {
            try {
              window.SHJParseEvent(e.useEvents, "dataListener", s.data);
              const o = t.series.find((_) => _._sourceId === s.id);
              o && (o.data = s.data[0].data), i(t);
            } catch {
              window.SHJParseEvent(e.useEvents, "dataListener", null), i(t);
            }
          }
        });
      },
      emit: p
    });
    return n(() => e.sources, () => {
      e.sources && e.sources.length > 0 && a(e.basicOption);
    }, {
      deep: !0
    }), n(() => r(e.basicOption), (t, s) => {
      O(t, s) || c(t);
    }, {
      deep: !0
    }), l({
      getEchartsInstance: () => f.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(), v("div", k, [
      w("div", {
        id: E(m),
        class: "widget"
      }, null, 8, D)
    ]));
  }
});
export {
  I as default
};
