import { computed as c, onMounted as ie, ref as C, openBlock as n, createElementBlock as g, normalizeClass as G, normalizeStyle as T, createVNode as E, createCommentVNode as i, createBlock as h, unref as r, createSlots as de, withCtx as m, renderSlot as p, normalizeProps as U, guardReactiveProps as H, createElementVNode as a, Fragment as R, renderList as X, toDisplayString as $, createTextVNode as K, nextTick as ce } from "vue";
import { u as ye, o as ve, e as q, c as he, t as me, M as fe, X as ke, w as F, v as ge, N as pe, i as Y, f as A, q as be, r as Ce } from "./index-CguVaFlt.js";
import { _ as xe } from "./Title-DbTGPg4G.js";
import { u as _e, U as we } from "./usePrinter-ClsMRVJG.js";
import { L as $e } from "./Legend-CsVEDSh6.js";
import M from "./BaseIcon-BNFf4B_v.js";
import { D as Me } from "./DataTable-BwHWRlRZ.js";
import Ne from "./vue-ui-skeleton-ChHLL5Hw.js";
import Pe from "./vue-ui-accordion-w15FGKRN.js";
import { u as J } from "./useNestedProp-BbEbJmgv.js";
import { _ as Le } from "./_plugin-vue_export-helper-CHgC5LLL.js";
const Te = ["id"], Ae = ["xmlns", "viewBox"], Ie = ["id"], Fe = ["stop-color"], Oe = ["stop-color"], Se = ["x1", "y1", "x2", "y2", "stroke", "stroke-width"], Ve = ["d", "stroke", "stroke-width"], je = ["stroke"], Be = ["fill"], De = ["stroke"], We = ["fill"], ze = ["stroke"], Ge = ["fill"], Ee = ["stroke"], Ue = ["fill"], He = ["stroke"], Re = ["fill"], Xe = ["d", "stroke", "stroke-width", "fill"], Ke = ["x1", "y1", "stroke"], qe = ["cx", "cy", "fill", "stroke"], Ye = ["fill", "stroke"], Je = ["y", "fill", "font-weight"], Qe = ["y", "fill"], Ze = {
  key: 3,
  class: "vue-data-ui-watermark"
}, et = ["onClick"], tt = { style: { "font-weight": "bold" } }, lt = ["innerHTML"], ot = {
  __name: "vue-ui-mood-radar",
  props: {
    config: {
      type: Object,
      default() {
        return {};
      }
    },
    dataset: {
      type: Object,
      default() {
        return {};
      }
    }
  },
  setup(Q, { expose: Z }) {
    const u = Q, { vue_ui_mood_radar: ee } = ye(), x = c(() => !!u.dataset && Object.keys(u.dataset).length);
    ie(() => {
      ve(u.dataset) && q({
        componentName: "VueUiMoodRadar",
        type: "dataset"
      });
    });
    const _ = C(he()), O = C(null), te = C(null), s = C(null), e = c(() => {
      const l = J({
        userConfig: u.config,
        defaultConfig: ee
      });
      return l.theme ? {
        ...J({
          userConfig: me.vue_ui_mood_radar[l.theme] || u.config,
          defaultConfig: l
        })
      } : l;
    }), { isPrinting: S, isImaging: V, generatePdf: j, generateImage: B } = _e({
      elementId: _.value,
      fileName: e.value.style.chart.title.text || "vue-ui-mood-radar"
    }), N = C({
      showTable: e.value.table.show
    }), f = c(() => ({
      height: 256,
      width: 256
    })), I = c(() => fe({
      plot: { x: 128, y: f.value.height / 2 },
      radius: 90,
      sides: 5,
      rotation: 11
    }));
    function le({ centerX: l, centerY: o, apexX: t, apexY: d, proportion: v, key: w, value: ue }) {
      return {
        x: l + (t - l) * v,
        y: o + (d - o) * v,
        key: w,
        value: ue
      };
    }
    const oe = c(() => Math.max(...Object.values(u.dataset).map((l) => isNaN(l) ? 0 : l))), b = c(() => Object.values(u.dataset).reduce((l, o) => (isNaN(l) ? 0 : l) + (isNaN(o) ? 0 : o), 0)), y = c(() => Object.keys(u.dataset).map((l, o) => {
      const t = typeof u.dataset[l] != "number" || isNaN(u.dataset[l]) ? 0 : u.dataset[l];
      return {
        index: o,
        key: l,
        value: t,
        proportion: t / b.value,
        color: e.value.style.chart.layout.smileys.colors[l]
      };
    }).sort((l, o) => o.key - l.key)), D = c(() => x.value ? (["1", "2", "3", "4", "5"].forEach((l) => {
      [null, void 0].includes(u.dataset[l]) && q({
        componentName: "VueUiMoodRadar",
        type: "datasetAttribute",
        property: l
      });
    }), I.value.coordinates.map((l, o) => {
      const t = le({
        centerX: f.value.width / 2,
        centerY: f.value.height / 2,
        apexX: l.x,
        apexY: l.y,
        proportion: y.value[o].value / oe.value,
        key: y.value[o].key,
        value: y.value[o].value
      });
      return {
        ...l,
        plots: t,
        key: y.value[o].key
      };
    })) : []), ae = c(() => ({
      cy: "mood-radar-legend",
      backgroundColor: e.value.style.chart.legend.backgroundColor,
      color: e.value.style.chart.legend.color,
      fontSize: e.value.style.chart.legend.fontSize,
      paddingBottom: 12,
      fontWeight: e.value.style.chart.legend.bold ? "bold" : ""
    }));
    function se(l) {
      l === s.value ? s.value = null : s.value = l;
    }
    const k = c(() => {
      const l = y.value.map((t) => ({
        name: t.key,
        color: t.color
      })), o = y.value.map((t) => isNaN(t.value) ? 0 : t.value);
      return { head: l, body: o };
    });
    function W() {
      ce(() => {
        const l = k.value.head.map((d, v) => [[
          d.name
        ], [k.value.body[v]], [isNaN(k.value.body[v] / b.value) ? "-" : k.value.body[v] / b.value * 100]]), o = [[e.value.style.chart.title.text], [e.value.style.chart.title.subtitle.text], [[""], ["val"], ["%"]]].concat(l), t = be(o);
        Ce({ csvContent: t, title: e.value.style.chart.title.text || "vue-ui-mood-radar" });
      });
    }
    const P = c(() => {
      const l = [
        ' <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M18 16v2a1 1 0 0 1 -1 1h-11l6 -7l-6 -7h11a1 1 0 0 1 1 1v2" /></svg>',
        Number(b.value.toFixed(e.value.table.td.roundingValue)).toLocaleString(),
        "100%"
      ], o = k.value.head.map((v, w) => [
        {
          color: v.color,
          name: v.name
        },
        k.value.body[w].toFixed(e.value.table.td.roundingValue),
        isNaN(k.value.body[w] / b.value) ? "-" : (k.value.body[w] / b.value * 100).toFixed(e.value.table.td.roundingPercentage) + "%"
      ]), t = {
        th: {
          backgroundColor: e.value.table.th.backgroundColor,
          color: e.value.table.th.color,
          outline: e.value.table.th.outline
        },
        td: {
          backgroundColor: e.value.table.td.backgroundColor,
          color: e.value.table.td.color,
          outline: e.value.table.td.outline
        },
        breakpoint: e.value.table.responsiveBreakpoint
      }, d = [
        e.value.table.columnNames.series,
        e.value.table.columnNames.value,
        e.value.table.columnNames.percentage
      ];
      return {
        head: l,
        body: o,
        config: t,
        colNames: d
      };
    });
    function re() {
      return y.value;
    }
    function z() {
      N.value.showTable = !N.value.showTable;
    }
    const L = C(!1);
    function ne(l) {
      L.value = l;
    }
    return Z({
      getData: re,
      generatePdf: j,
      generateCsv: W,
      generateImage: B,
      toggleTable: z
    }), (l, o) => (n(), g("div", {
      class: G(`vue-ui-mood-radar ${L.value ? "vue-data-ui-wrapper-fullscreen" : ""} ${e.value.useCssAnimation ? "" : "vue-ui-dna"}`),
      ref_key: "moodRadarChart",
      ref: O,
      id: `${_.value}`,
      style: T(`font-family:${e.value.style.fontFamily};width:100%; text-align:center;${e.value.style.chart.title.text ? "" : "padding-top:36px"};background:${e.value.style.chart.backgroundColor}`)
    }, [
      e.value.style.chart.title.text ? (n(), g("div", {
        key: 0,
        style: T(`width:100%;background:${e.value.style.chart.backgroundColor}`)
      }, [
        E(xe, {
          config: {
            title: {
              cy: "mood-radar-title",
              ...e.value.style.chart.title
            },
            subtitle: {
              cy: "mood-radar-subtitle",
              ...e.value.style.chart.title.subtitle
            }
          }
        }, null, 8, ["config"])
      ], 4)) : i("", !0),
      e.value.userOptions.show && x.value ? (n(), h(we, {
        key: 1,
        ref_key: "details",
        ref: te,
        backgroundColor: e.value.style.chart.backgroundColor,
        color: e.value.style.chart.color,
        isPrinting: r(S),
        isImaging: r(V),
        uid: _.value,
        hasPdf: e.value.userOptions.buttons.pdf,
        hasXls: e.value.userOptions.buttons.csv,
        hasImg: e.value.userOptions.buttons.img,
        hasTable: e.value.userOptions.buttons.table,
        hasFullscreen: e.value.userOptions.buttons.fullscreen,
        titles: { ...e.value.userOptions.buttonTitles },
        chartElement: O.value,
        onToggleFullscreen: ne,
        onGeneratePdf: r(j),
        onGenerateCsv: W,
        onGenerateImage: r(B),
        onToggleTable: z
      }, de({ _: 2 }, [
        l.$slots.optionPdf ? {
          name: "optionPdf",
          fn: m(() => [
            p(l.$slots, "optionPdf", {}, void 0, !0)
          ]),
          key: "0"
        } : void 0,
        l.$slots.optionCsv ? {
          name: "optionCsv",
          fn: m(() => [
            p(l.$slots, "optionCsv", {}, void 0, !0)
          ]),
          key: "1"
        } : void 0,
        l.$slots.optionImg ? {
          name: "optionImg",
          fn: m(() => [
            p(l.$slots, "optionImg", {}, void 0, !0)
          ]),
          key: "2"
        } : void 0,
        l.$slots.optionTable ? {
          name: "optionTable",
          fn: m(() => [
            p(l.$slots, "optionTable", {}, void 0, !0)
          ]),
          key: "3"
        } : void 0,
        l.$slots.optionFullscreen ? {
          name: "optionFullscreen",
          fn: m(({ toggleFullscreen: t, isFullscreen: d }) => [
            p(l.$slots, "optionFullscreen", U(H({ toggleFullscreen: t, isFullscreen: d })), void 0, !0)
          ]),
          key: "4"
        } : void 0
      ]), 1032, ["backgroundColor", "color", "isPrinting", "isImaging", "uid", "hasPdf", "hasXls", "hasImg", "hasTable", "hasFullscreen", "titles", "chartElement", "onGeneratePdf", "onGenerateImage"])) : i("", !0),
      x.value ? (n(), g("svg", {
        key: 2,
        xmlns: r(ke),
        viewBox: `0 0 ${f.value.width} ${f.value.height}`,
        class: G({ "vue-data-ui-fullscreen--on": L.value, "vue-data-ui-fulscreen--off": !L.value }),
        style: T(`overflow:visible;background:${e.value.style.chart.backgroundColor};color:${e.value.style.chart.color}`)
      }, [
        a("defs", null, [
          a("radialGradient", {
            cx: "50%",
            cy: "50%",
            r: "50%",
            fx: "50%",
            fy: "50%",
            id: `mood_radar_gradient_${_.value}`
          }, [
            a("stop", {
              offset: "0%",
              "stop-color": e.value.style.chart.layout.dataPolygon.color + r(F)[e.value.style.chart.layout.dataPolygon.opacity]
            }, null, 8, Fe),
            a("stop", {
              offset: "100%",
              "stop-color": `${r(ge)(
                e.value.style.chart.layout.dataPolygon.color,
                e.value.style.chart.layout.dataPolygon.gradient.intensity / 100
              )}${r(F)[e.value.style.chart.layout.dataPolygon.opacity]}`
            }, null, 8, Oe)
          ], 8, Ie)
        ]),
        (n(!0), g(R, null, X(I.value.coordinates, (t) => (n(), g("line", {
          x1: f.value.width / 2,
          y1: f.value.height / 2,
          x2: t.x,
          y2: t.y,
          stroke: e.value.style.chart.layout.grid.stroke,
          "stroke-width": e.value.style.chart.layout.grid.strokeWidth
        }, null, 8, Se))), 256)),
        a("path", {
          d: I.value.path,
          fill: "none",
          stroke: e.value.style.chart.layout.outerPolygon.stroke,
          "stroke-width": e.value.style.chart.layout.outerPolygon.strokeWidth,
          "stroke-linejoin": "round",
          "stroke-linecap": "round"
        }, null, 8, Ve),
        a("path", {
          fill: "none",
          stroke: e.value.style.chart.layout.smileys.colors[5],
          "stroke-width": "1",
          "stroke-linecap": "round",
          d: "M119 25A1 1 0 00137 25 1 1 0 00119 25M123 26C124 33 132 33 133 26L123 26M123 22A1 1 0 00126 22 1 1 0 00123 22M130 22A1 1 0 00133 22 1 1 0 00130 22"
        }, null, 8, je),
        a("circle", {
          class: "vue-ui-mood-radar-trap",
          onMouseenter: o[0] || (o[0] = (t) => s.value = 5),
          onMouseleave: o[1] || (o[1] = (t) => s.value = null),
          cx: "128",
          cy: "25",
          r: "20",
          fill: s.value === 5 ? e.value.style.chart.layout.smileys.colors[5] + "33" : "transparent"
        }, null, 40, Be),
        a("path", {
          fill: "none",
          stroke: e.value.style.chart.layout.smileys.colors[4],
          "stroke-width": "1",
          "stroke-linecap": "round",
          d: "M218 95A1 1 0 00236 95 1 1 0 00218 95M222 97C225 99 229 99 232 97M222 92A1 1 0 00225 92 1 1 0 00222 92M229 92A1 1 0 00232 92 1 1 0 00229 92"
        }, null, 8, De),
        a("circle", {
          class: "vue-ui-mood-radar-trap",
          onMouseenter: o[2] || (o[2] = (t) => s.value = 4),
          onMouseleave: o[3] || (o[3] = (t) => s.value = null),
          cx: "227",
          cy: "95.5",
          r: "20",
          fill: s.value === 4 ? e.value.style.chart.layout.smileys.colors[4] + "33" : "transparent"
        }, null, 40, We),
        a("path", {
          fill: "none",
          stroke: e.value.style.chart.layout.smileys.colors[3],
          "stroke-width": "1",
          "stroke-linecap": "round",
          d: "M181 213A1 1 0 00199 213 1 1 0 00181 213M185 210A1 1 0 00188 210 1 1 0 00185 210M192 210A1 1 0 00195 210 1 1 0 00192 210M185 215 195 215"
        }, null, 8, ze),
        a("circle", {
          class: "vue-ui-mood-radar-trap",
          onMouseenter: o[4] || (o[4] = (t) => s.value = 3),
          onMouseleave: o[5] || (o[5] = (t) => s.value = null),
          cx: "190",
          cy: "213.5",
          r: "20",
          fill: s.value === 3 ? e.value.style.chart.layout.smileys.colors[3] + "33" : "transparent"
        }, null, 40, Ge),
        a("path", {
          fill: "none",
          stroke: e.value.style.chart.layout.smileys.colors[2],
          "stroke-width": "1",
          "stroke-linecap": "round",
          d: "M56 213A1 1 0 0074 213 1 1 0 0056 213M60 216C63 214 67 214 70 216M60 210A1 1 0 0063 210 1 1 0 0060 210M67 210A1 1 0 0070 210 1 1 0 0067 210"
        }, null, 8, Ee),
        a("circle", {
          class: "vue-ui-mood-radar-trap",
          onMouseenter: o[6] || (o[6] = (t) => s.value = 2),
          onMouseleave: o[7] || (o[7] = (t) => s.value = null),
          cx: "65",
          cy: "213.5",
          r: "20",
          fill: s.value === 2 ? e.value.style.chart.layout.smileys.colors[2] + "33" : "transparent"
        }, null, 40, Ue),
        a("path", {
          fill: "none",
          stroke: e.value.style.chart.layout.smileys.colors[1],
          "stroke-width": "1",
          "stroke-linecap": "round",
          d: "M20 96A1 1 0 0038 96 1 1 0 0020 96M24 100C25 95 33 95 34 100L24 100M24 93A1 1 0 0027 93 1 1 0 0024 93M31 93A1 1 0 0034 93 1 1 0 0031 93"
        }, null, 8, He),
        a("circle", {
          class: "vue-ui-mood-radar-trap",
          onMouseenter: o[8] || (o[8] = (t) => s.value = 1),
          onMouseleave: o[9] || (o[9] = (t) => s.value = null),
          cx: "29",
          cy: "95.5",
          r: "20",
          fill: s.value === 1 ? e.value.style.chart.layout.smileys.colors[1] + "33" : "transparent"
        }, null, 40, Re),
        a("path", {
          d: r(pe)(D.value.map((t) => t.plots)),
          stroke: e.value.style.chart.layout.dataPolygon.stroke,
          "stroke-width": e.value.style.chart.layout.dataPolygon.strokeWidth,
          "stroke-linecap": "round",
          "stroke-linejoin": "round",
          fill: e.value.style.chart.layout.dataPolygon.gradient.show ? `url(#mood_radar_gradient_${_.value})` : e.value.style.chart.layout.dataPolygon.color + r(F)[e.value.style.chart.layout.dataPolygon.opacity]
        }, null, 8, Xe),
        (n(!0), g(R, null, X(D.value.map((t) => t.plots), (t, d) => (n(), g("g", {
          class: "vue-ui-mood-radar-trap",
          style: T(`opacity:${s.value == t.key ? "1" : "0"}`)
        }, [
          a("line", {
            x1: t.x,
            y1: t.y,
            x2: 128,
            y2: 128,
            stroke: e.value.style.chart.layout.smileys.colors[t.key]
          }, null, 8, Ke),
          a("circle", {
            cx: t.x,
            cy: t.y,
            fill: e.value.style.chart.layout.smileys.colors[t.key],
            r: "3",
            stroke: e.value.style.chart.backgroundColor,
            "stroke-width": 0.5
          }, null, 8, qe),
          a("circle", {
            cx: 128,
            cy: 128,
            fill: e.value.style.chart.layout.smileys.colors[t.key],
            r: "3",
            stroke: e.value.style.chart.backgroundColor,
            "stroke-width": 0.5
          }, null, 8, Ye),
          a("text", {
            x: 128,
            y: ["5", 5].includes(t.key) ? 145 : 120,
            fill: e.value.style.chart.layout.dataLabel.color,
            "font-size": "12",
            "text-anchor": "middle",
            "font-weight": e.value.style.chart.layout.dataLabel.bold ? "bold" : "normal"
          }, $(r(Y)(
            e.value.style.chart.layout.dataLabel.formatter,
            t.value,
            r(A)({
              p: e.value.style.chart.layout.dataLabel.prefix,
              v: t.value,
              s: e.value.style.chart.layout.dataLabel.suffix,
              r: e.value.style.chart.layout.dataLabel.roundingValue
            }),
            { datapoint: t, seriesIndex: d }
          )), 9, Je),
          a("text", {
            x: 128,
            y: ["5", 5].includes(t.key) ? 163 : 102,
            fill: e.value.style.chart.layout.dataLabel.color,
            "font-size": "12",
            "text-anchor": "middle"
          }, " (" + $(r(A)({
            v: t.value / b.value * 100,
            s: "%",
            r: e.value.style.chart.layout.dataLabel.roundingPercentage
          })) + ") ", 9, Qe)
        ], 4))), 256)),
        p(l.$slots, "svg", { svg: f.value }, void 0, !0)
      ], 14, Ae)) : i("", !0),
      l.$slots.watermark ? (n(), g("div", Ze, [
        p(l.$slots, "watermark", U(H({ isPrinting: r(S) || r(V) })), void 0, !0)
      ])) : i("", !0),
      x.value ? i("", !0) : (n(), h(Ne, {
        key: 4,
        config: {
          type: "radar",
          style: {
            backgroundColor: e.value.style.chart.backgroundColor,
            radar: {
              grid: {
                color: "#CCCCCC"
              },
              shapes: {
                color: "#CCCCCC"
              }
            }
          }
        }
      }, null, 8, ["config"])),
      e.value.style.chart.legend.show ? (n(), h($e, {
        key: 5,
        legendSet: y.value,
        config: ae.value,
        style: { display: "flex", "row-gap": "6px" }
      }, {
        item: m(({ legend: t, index: d }) => [
          a("div", {
            onClick: () => se(t.key),
            style: { display: "flex", "flex-direction": "row", gap: "3px", "align-items": "center", margin: "3px 0" }
          }, [
            t.key == 1 ? (n(), h(M, {
              key: 0,
              strokeWidth: 1,
              name: "moodSad",
              stroke: e.value.style.chart.layout.smileys.colors[t.key]
            }, null, 8, ["stroke"])) : i("", !0),
            t.key == 2 ? (n(), h(M, {
              key: 1,
              strokeWidth: 1,
              name: "moodFlat",
              stroke: e.value.style.chart.layout.smileys.colors[t.key]
            }, null, 8, ["stroke"])) : i("", !0),
            t.key == 3 ? (n(), h(M, {
              key: 2,
              strokeWidth: 1,
              name: "moodNeutral",
              stroke: e.value.style.chart.layout.smileys.colors[t.key]
            }, null, 8, ["stroke"])) : i("", !0),
            t.key == 4 ? (n(), h(M, {
              key: 3,
              strokeWidth: 1,
              name: "smiley",
              stroke: e.value.style.chart.layout.smileys.colors[t.key]
            }, null, 8, ["stroke"])) : i("", !0),
            t.key == 5 ? (n(), h(M, {
              key: 4,
              strokeWidth: 1,
              name: "moodHappy",
              stroke: e.value.style.chart.layout.smileys.colors[t.key]
            }, null, 8, ["stroke"])) : i("", !0),
            a("span", tt, $(r(Y)(
              e.value.style.chart.layout.dataLabel.formatter,
              t.value,
              r(A)({
                p: e.value.style.chart.layout.dataLabel.prefix,
                v: t.value,
                s: e.value.style.chart.layout.dataLabel.suffix,
                r: e.value.style.chart.layout.dataLabel.roundingValue
              }),
              { datapoint: t, seriesIndex: d }
            )), 1),
            K(" (" + $(r(A)({
              v: t.proportion * 100,
              s: "%",
              r: e.value.style.chart.legend.roundingPercentage
            })) + ") ", 1)
          ], 8, et)
        ]),
        _: 1
      }, 8, ["legendSet", "config"])) : i("", !0),
      p(l.$slots, "legend", { legend: y.value }, void 0, !0),
      x.value ? (n(), h(Pe, {
        key: 6,
        hideDetails: "",
        config: {
          open: N.value.showTable,
          maxHeight: 1e4,
          body: {
            backgroundColor: e.value.style.chart.backgroundColor,
            color: e.value.style.chart.color
          },
          head: {
            backgroundColor: e.value.style.chart.backgroundColor,
            color: e.value.style.chart.color
          }
        }
      }, {
        content: m(() => [
          E(Me, {
            colNames: P.value.colNames,
            head: P.value.head,
            body: P.value.body,
            config: P.value.config,
            title: `${e.value.style.chart.title.text}${e.value.style.chart.title.subtitle.text ? ` : ${e.value.style.chart.title.subtitle.text}` : ""}`,
            onClose: o[10] || (o[10] = (t) => N.value.showTable = !1)
          }, {
            th: m(({ th: t }) => [
              a("div", {
                innerHTML: t,
                style: { display: "flex", "align-items": "center" }
              }, null, 8, lt)
            ]),
            td: m(({ td: t }) => [
              K($(t.name || t), 1)
            ]),
            _: 1
          }, 8, ["colNames", "head", "body", "config", "title"])
        ]),
        _: 1
      }, 8, ["config"])) : i("", !0)
    ], 14, Te));
  }
}, mt = /* @__PURE__ */ Le(ot, [["__scopeId", "data-v-1399dfb6"]]);
export {
  mt as default
};
