import { defineComponent as p, watch as m, openBlock as x, createElementBlock as g, createElementVNode as k, unref as D } from "vue";
import { cloneDeep as o, isEqual as y } from "lodash";
import { useChart as S } from "../../core/useChart.mjs";
import { parseDataset as f } from "../../utils/parseDataset.mjs";
import { cloneSeries as V } from "../../utils/cloneSeries.mjs";
const C = { class: "zerov-widget" }, H = ["id"], J = p({ name: "zv-chart-other-radar" }), I = /* @__PURE__ */ p({
  ...J,
  props: {
    basicOption: {},
    sources: {},
    useEvents: {},
    uuid: {}
  },
  emits: [
    "chart-click",
    "chart-dblclick",
    "chart-mousedown",
    "chart-mouseover",
    "chart-mouseout",
    "chart-contextmenu"
  ],
  setup(b, { expose: E, emit: w }) {
    const e = b, O = w, {
      id: _,
      setOption: h,
      chart: v,
      renderChart: n,
      renderData: i
    } = S({
      basicOption: o(e.basicOption),
      useEvents: o(e.useEvents),
      customRenderData: (s) => {
        s = o(s), window.SHJDatasourceV2({
          tId: e.uuid,
          sources: e.sources,
          callback: ({ data: c }) => {
            try {
              let u = function(t) {
                return t.reduce((r, a) => r.includes(a) ? r : [...r, a], []);
              };
              window.SHJParseEvent(e.useEvents, "dataListener", c), s.dataset = f(o(c)), s.series = V(c, s.series);
              const d = [], l = [];
              s.dataset.source.forEach((t) => {
                for (const r in t)
                  if (Object.prototype.hasOwnProperty.call(t, r)) {
                    const a = t[r];
                    Number(a) && (l.push(Number(a)), d.push(r));
                  }
              }), s.radar.indicator = [], u(d).forEach((t) => {
                s.radar.indicator.push(
                  {
                    text: t,
                    max: 2e3
                  }
                );
              }), s.radar.indicator.forEach((t) => {
                t.max = l.sort((r, a) => a - r)[0];
              }), s.dataset = f(o(c), u(d)), h(s);
            } catch {
              window.SHJParseEvent(e.useEvents, "dataListener", null), h(s);
            }
          }
        });
      },
      emit: O
    });
    return m(() => e.sources, () => {
      e.sources && e.sources.length > 0 && i(e.basicOption);
    }, {
      deep: !0
    }), m(() => o(e.basicOption), (s, c) => {
      y(s, c) || n(s);
    }, {
      deep: !0
    }), E({
      getEchartsInstance: () => v.value,
      refresh: () => {
        e.sources && e.sources.length > 0 && n(e.basicOption), i(e.basicOption);
      },
      refreshView: () => {
        e.sources && e.sources.length > 0 && n(e.basicOption);
      },
      refreshData: () => {
        i(e.basicOption);
      }
    }), (s, c) => (x(), g("div", C, [
      k("div", {
        id: D(_),
        class: "widget"
      }, null, 8, H)
    ]));
  }
});
export {
  I as default
};
