import { computed as d, ref as c, watch as Te, onMounted as We, onBeforeUnmount as qe, openBlock as s, createElementBlock as i, normalizeClass as Se, normalizeStyle as Q, createBlock as V, createCommentVNode as f, unref as h, createSlots as He, withCtx as b, renderSlot as w, normalizeProps as q, guardReactiveProps as H, createVNode as Le, createElementVNode as k, Fragment as T, renderList as M, toDisplayString as S, createTextVNode as Pe, nextTick as Xe, pushScopeId as Ye, popScopeId as Ke } from "vue";
import { u as Je, c as Qe, t as Ze, a as et, p as B, o as tt, e as oe, g as lt, b as at, i as D, f as x, X as ot, s as ut, w as st, F as rt, K as nt, d as it, x as ct, y as vt, q as dt, r as ht } from "./index-DK7qqHGP.js";
import { t as pt, u as yt } from "./useResponsive-NZB-WLRF.js";
import { _ as ft } from "./Title-Cxlu3Etv.js";
import { u as gt, U as mt } from "./usePrinter-Cza87yNE.js";
import { _ as bt } from "./Tooltip-Bt9pHzBM.js";
import { D as wt } from "./DataTable-B9SSwFM2.js";
import { L as kt } from "./Legend-D4PxDNTf.js";
import xt from "./vue-ui-skeleton-CQnYuosp.js";
import Ct from "./vue-ui-accordion-5C4CP3gA.js";
import { u as ze } from "./useNestedProp-0nRX_rTi.js";
import { _ as _t } from "./PackageVersion-I1_4jcn_.js";
import { _ as $t } from "./_plugin-vue_export-helper-CHgC5LLL.js";
const Fe = (G) => (Ye("data-v-a0574c0d"), G = G(), Ke(), G), It = ["id"], Tt = ["xmlns", "viewBox"], St = ["id"], Lt = ["stop-color"], Pt = ["stop-color"], zt = ["id"], Ft = /* @__PURE__ */ Fe(() => /* @__PURE__ */ k("feGaussianBlur", {
  in: "SourceGraphic",
  stdDeviation: 2
}, null, -1)), Nt = /* @__PURE__ */ Fe(() => /* @__PURE__ */ k("feColorMatrix", {
  type: "saturate",
  values: "0"
}, null, -1)), Bt = [
  Ft,
  Nt
], Ot = ["x", "y", "height", "width"], At = ["height", "width"], Vt = ["rx", "x", "y", "height", "width", "stroke", "stroke-width", "filter"], Mt = ["rx", "x", "y", "height", "width", "fill", "stroke", "stroke-width", "filter"], Dt = ["x", "y", "height", "width", "filter"], Gt = { key: 0 }, Rt = { key: 1 }, Ut = { key: 2 }, jt = { key: 3 }, Et = ["onMouseover", "x", "y", "height", "width"], Wt = {
  key: 3,
  class: "vue-data-ui-watermark"
}, qt = ["onClick"], Ht = { key: 0 }, Xt = { key: 1 }, Yt = ["innerHTML"], Kt = {
  __name: "vue-ui-waffle",
  props: {
    config: {
      type: Object,
      default() {
        return {};
      }
    },
    dataset: {
      type: Array,
      default() {
        return [];
      }
    }
  },
  emits: ["selectLegend"],
  setup(G, { expose: Ne, emit: Be }) {
    const g = G, { vue_ui_waffle: Oe } = Je(), X = d(() => !!g.dataset && g.dataset.length), L = c(Qe()), Ae = c(null), Z = c(!1), ee = c(""), O = c(null), ue = c(0), R = c(null), se = c(null), re = c(null), ne = c(0), ie = c(0), ce = c(0), e = d({
      get: () => ve(),
      set: (t) => t
    });
    function ve() {
      const t = ze({
        userConfig: g.config,
        defaultConfig: Oe
      });
      return t.theme ? {
        ...ze({
          userConfig: Ze.vue_ui_waffle[t.theme] || g.config,
          defaultConfig: t
        }),
        customPalette: et[t.theme] || B
      } : t;
    }
    Te(() => g.config, (t) => {
      e.value = ve(), de(), ne.value += 1, ie.value += 1, ce.value += 1;
    }, { deep: !0 });
    const Y = c(null);
    function de() {
      if (tt(g.dataset) ? oe({
        componentName: "VueUiWaffle",
        type: "dataset"
      }) : g.dataset.forEach((t, o) => {
        lt({
          datasetObject: t,
          requiredAttributes: ["name", "values"]
        }).forEach((l) => {
          oe({
            componentName: "VueUiWaffle",
            type: "datasetSerieAttribute",
            property: l,
            index: o
          });
        });
      }), e.value.responsive) {
        const t = pt(() => {
          const { width: o, height: l } = yt({
            chart: R.value,
            title: e.value.style.chart.title.text ? se.value : null,
            legend: e.value.style.chart.legend.show ? re.value : null
          });
          P.value.width = o, P.value.height = l, C.value.width = o, C.value.height = l;
        });
        Y.value = new ResizeObserver(t), Y.value.observe(R.value.parentNode);
      }
    }
    We(() => {
      de();
    }), qe(() => {
      Y.value && Y.value.disconnect();
    });
    const { isPrinting: he, isImaging: pe, generatePdf: ye, generateImage: fe } = gt({
      elementId: `vue-ui-waffle_${L.value}`,
      fileName: e.value.style.chart.title.text || "vue-ui-waffle"
    }), ge = d(() => at(e.value.customPalette)), I = c({
      showTable: e.value.table.show,
      showTooltip: e.value.style.chart.tooltip.show
    }), P = c({
      height: 512,
      width: 512
    }), C = c({
      top: 0,
      left: 0,
      height: 512,
      width: 512
    }), z = d(() => (C.value.width - e.value.style.chart.layout.grid.size * e.value.style.chart.layout.grid.spaceBetween) / e.value.style.chart.layout.grid.size), F = d(() => (C.value.height - e.value.style.chart.layout.grid.size * e.value.style.chart.layout.grid.spaceBetween) / e.value.style.chart.layout.grid.size), U = d(() => C.value.width / e.value.style.chart.layout.grid.size), K = d(() => C.value.height / e.value.style.chart.layout.grid.size);
    function me(t) {
      const o = e.value.style.chart.layout.grid.size * e.value.style.chart.layout.grid.size, l = t.reduce((m, ae) => m + ae, 0), a = t.map((m) => m / l * o), u = a.map(Math.floor), n = a.map((m) => m % 1);
      let y = o - u.reduce((m, ae) => m + ae, 0);
      for (; y > 0; ) {
        let m = n.indexOf(Math.max(...n));
        u[m] += 1, n[m] = 0, y -= 1;
      }
      return u;
    }
    function be() {
      return g.dataset.map((t, o) => ({
        ...t,
        color: it(t.color) || ge.value[o] || B[o] || B[o % B.length],
        uid: `serie_${o}`,
        absoluteIndex: o
      }));
    }
    const we = d(() => be()), v = c(we.value);
    Te(() => g.dataset, (t) => {
      v.value = be();
    }, { deep: !0 });
    const Ve = d(() => {
      const t = v.value.filter((o, l) => !p.value.includes(o.uid)).map((o, l) => (o.values || []).reduce((a, u) => a + u, 0));
      return me(t);
    }), Me = d(() => {
      const t = v.value.map((o, l) => (o.values || []).reduce((a, u) => a + u));
      return me(t);
    }), j = d(() => (g.dataset.forEach((t, o) => {
      [null, void 0].includes(t.values) && oe({
        componentName: "VueUiWaffle",
        type: "datasetSerieAttribute",
        property: "values (number[])",
        index: o
      });
    }), v.value.filter((t, o) => !p.value.includes(t.uid)).map((t, o) => ({
      absoluteIndex: t.absoluteIndex,
      uid: t.uid,
      name: t.name,
      color: t.color,
      value: (t.values || []).reduce((l, a) => l + a, 0),
      absoluteValues: t.values || [],
      proportion: Ve.value[o]
    })))), De = d(() => v.value.map((t, o) => ({
      absoluteIndex: t.absoluteIndex,
      uid: t.uid,
      name: t.name,
      color: t.color,
      value: (t.values || []).reduce((l, a) => l + a, 0),
      absoluteValues: t.values || [],
      proportion: Me.value[o]
    })));
    function Ge() {
      return De.value.map((t) => ({
        name: t.name,
        color: t.color,
        value: t.value,
        proportion: t.proportion
      }));
    }
    const Re = d(() => {
      let t = 0;
      return j.value.map((o, l) => {
        const a = t, u = a + o.proportion, n = [];
        for (let y = Math.floor(a); y < Math.floor(u); y += 1)
          n.push(y);
        return t = u, {
          ...o,
          start: a,
          rects: n
        };
      });
    }), r = d(() => Re.value.flatMap((t, o) => t.rects.map((l, a) => ({
      isFirst: a === 0,
      isLongEnough: l.length > 2,
      name: t.name,
      color: t.color,
      value: t.value,
      serieIndex: o,
      absoluteStartIndex: a < 3,
      serieId: t.uid,
      ...t
    }))).map((t, o) => ({
      ...t,
      isAbsoluteFirst: o % e.value.style.chart.layout.grid.size === 0
    }))), E = d(() => {
      const t = [];
      for (let o = 0; o < e.value.style.chart.layout.grid.size; o += 1)
        for (let l = 0; l < e.value.style.chart.layout.grid.size; l += 1)
          t.push({
            isStartOfLine: l === 0,
            position: e.value.style.chart.layout.grid.vertical ? o : l,
            x: (e.value.style.chart.layout.grid.vertical ? o : l) * (z.value + e.value.style.chart.layout.grid.spaceBetween),
            y: (e.value.style.chart.layout.grid.vertical ? l : o) * (F.value + e.value.style.chart.layout.grid.spaceBetween) + C.value.top
          });
      return t;
    }), p = c([]), N = c(!1), ke = c(null), xe = c(null);
    function Ce(t) {
      if (!e.value.useAnimation) {
        p.value.includes(t) ? p.value = p.value.filter((u) => u !== t) : p.value.length < A.value.length - 1 && A.value.length > 1 && p.value.push(t);
        return;
      }
      const o = we.value.find((u) => u.uid === t).values.reduce((u, n) => u + n, 0);
      let a = v.value.find((u) => u.uid === t).values.reduce((u, n) => u + n, 0);
      if (p.value.includes(t)) {
        let n = function() {
          a > u ? (cancelAnimationFrame(ke.value), v.value = v.value.map((y, m) => y.uid === t ? {
            ...y,
            values: [u]
          } : y), N.value = !1) : (N.value = !0, a += u * 0.025, v.value = v.value.map((y, m) => y.uid === t ? {
            ...y,
            values: [a]
          } : y), ke.value = requestAnimationFrame(n));
        };
        p.value = p.value.filter((y) => y !== t);
        const u = o;
        n();
      } else if (p.value.length < A.value.length - 1 && A.value.length > 1) {
        let u = function() {
          a < 0.1 ? (cancelAnimationFrame(xe.value), p.value.push(t), v.value = v.value.map((n, y) => n.uid === t ? {
            ...n,
            values: [0]
          } : n), N.value = !1) : (N.value = !0, a /= 1.5, v.value = v.value.map((n, y) => n.uid === t ? {
            ...n,
            values: [a]
          } : n), xe.value = requestAnimationFrame(u));
        };
        u();
      }
      Be("selectLegend", j.value.map((u) => ({
        name: u.name,
        color: u.color,
        value: u.value,
        proportion: u.proportion / Math.pow(e.value.style.chart.layout.grid.size, 2)
      })));
    }
    const A = d(() => v.value.map((t, o) => ({
      name: t.name,
      color: t.color || ge[o] || B[o] || B[o % B.length],
      value: (t.values || []).reduce((l, a) => l + a, 0),
      uid: t.uid,
      shape: "square"
    })).map((t, o) => ({
      ...t,
      proportion: t.value / v.value.map((l) => (l.values || []).reduce((a, u) => a + u, 0)).reduce((l, a) => l + a, 0),
      opacity: p.value.includes(t.uid) ? 0.5 : 1,
      segregate: () => Ce(t.uid),
      isSegregated: p.value.includes(t.uid)
    }))), Ue = d(() => ({
      cy: "waffle-div-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" : ""
    })), _ = d(() => j.value.map((t) => t.value).reduce((t, o) => t + o, 0)), te = c(null);
    function je(t) {
      if (p.value.length === g.dataset.length) return;
      const o = r.value[t];
      te.value = {
        datapoint: o,
        seriesIndex: o.absoluteIndex,
        series: v.value,
        config: e.value
      }, Z.value = !0, O.value = r.value[t].serieIndex;
      const l = e.value.style.chart.tooltip.customFormat;
      if (ct(l) && vt(() => l({
        seriesIndex: r.value[t].absoluteIndex,
        datapoint: o,
        series: v.value,
        config: e.value
      })))
        ee.value = l({
          seriesIndex: r.value[t].absoluteIndex,
          datapoint: o,
          series: v.value,
          config: e.value
        });
      else {
        let a = "";
        if (a += `<div style="width:100%;text-align:center;border-bottom:1px solid ${e.value.style.chart.tooltip.borderColor};padding-bottom:6px;margin-bottom:3px;">${o.name}</div>`, a += `<div style="display:flex;flex-direction:row;gap:6px;align-items:center;"><svg viewBox="0 0 12 12" height="14" width="14"><rect x="0" y="0" height="12" width="12" stroke="none" rx="1" fill="${o.color}" /></svg>`, e.value.style.chart.tooltip.showValue && (a += `<b>${D(
          e.value.style.chart.layout.labels.dataLabels.formatter,
          o.value,
          x({
            p: e.value.style.chart.layout.labels.dataLabels.prefix,
            v: o.value,
            s: e.value.style.chart.layout.labels.dataLabels.suffix,
            r: e.value.style.chart.tooltip.roundingValue
          }),
          {
            datapoint: o,
            seriesIndex: r.value[t].absoluteIndex,
            series: v.value
          }
        )}</b>`), e.value.style.chart.tooltip.showPercentage) {
          const u = x({
            v: o.value / _.value * 100,
            s: "%",
            r: e.value.style.chart.tooltip.roundingPercentage
          });
          e.value.style.chart.tooltip.showValue ? a += `<span>(${u})</span></div>` : a += `<b>${u}%</b></div>`;
        }
        ee.value = a;
      }
    }
    const $ = d(() => {
      const t = j.value.map((l) => ({
        name: l.name,
        color: l.color
      })), o = j.value.map((l) => l.value);
      return { head: t, body: o };
    });
    function le(t) {
      return e.value.useBlurOnHover && ![null, void 0].includes(O.value) && O.value !== t ? `url(#blur_${L.value})` : "";
    }
    function _e() {
      Xe(() => {
        const t = $.value.head.map((a, u) => [[
          a.name
        ], [$.value.body[u]], [isNaN($.value.body[u] / _.value) ? "-" : $.value.body[u] / _.value * 100]]), o = [[e.value.style.chart.title.text], [e.value.style.chart.title.subtitle.text], [[""], ["val"], ["%"]]].concat(t), l = dt(o);
        ht({ csvContent: l, title: e.value.style.chart.title.text || "vue-ui-waffle" });
      });
    }
    const J = d(() => {
      const t = [
        ' <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>',
        D(
          e.value.style.chart.layout.labels.dataLabels.formatter,
          _.value,
          x({
            p: e.value.style.chart.layout.labels.dataLabels.prefix,
            v: _.value,
            s: e.value.style.chart.layout.labels.dataLabels.suffix,
            r: e.value.table.td.roundingValue
          })
        ),
        "100%"
      ], o = $.value.head.map((u, n) => [
        {
          color: u.color,
          name: u.name
        },
        D(
          e.value.style.chart.layout.labels.dataLabels.formatter,
          $.value.body[n],
          x({
            p: e.value.style.chart.layout.labels.dataLabels.prefix,
            v: $.value.body[n],
            s: e.value.style.chart.layout.labels.dataLabels.suffix,
            r: e.value.table.td.roundingValue
          })
        ),
        isNaN($.value.body[n] / _.value) ? "-" : x({
          v: $.value.body[n] / _.value * 100,
          s: "%",
          r: e.value.table.td.roundingPercentage
        })
      ]), l = {
        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
        },
        shape: "square",
        breakpoint: e.value.table.responsiveBreakpoint
      }, a = [
        e.value.table.columnNames.series,
        e.value.table.columnNames.value,
        e.value.table.columnNames.percentage
      ];
      return {
        head: t,
        body: o,
        config: l,
        colNames: a
      };
    }), W = c(!1);
    function Ee(t) {
      W.value = t, ue.value += 1;
    }
    function $e() {
      I.value.showTable = !I.value.showTable;
    }
    function Ie() {
      I.value.showTooltip = !I.value.showTooltip;
    }
    return Ne({
      getData: Ge,
      generatePdf: ye,
      generateCsv: _e,
      generateImage: fe,
      toggleTable: $e,
      toggleTooltip: Ie
    }), (t, o) => (s(), i("div", {
      class: Se(`vue-ui-waffle ${W.value ? "vue-data-ui-wrapper-fullscreen" : ""}`),
      ref_key: "waffleChart",
      ref: R,
      id: `vue-ui-waffle_${L.value}`,
      style: Q(`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.responsive ? "height: 100%" : ""}`)
    }, [
      e.value.style.chart.title.text ? (s(), i("div", {
        key: 0,
        ref_key: "chartTitle",
        ref: se,
        style: "width:100%;background:transparent;padding-bottom:12px"
      }, [
        (s(), V(ft, {
          key: `title_${ne.value}`,
          config: {
            title: {
              cy: "waffle-title",
              ...e.value.style.chart.title
            },
            subtitle: {
              cy: "waffle-subtitle",
              ...e.value.style.chart.title.subtitle
            }
          }
        }, null, 8, ["config"]))
      ], 512)) : f("", !0),
      e.value.userOptions.show && X.value ? (s(), V(mt, {
        ref_key: "details",
        ref: Ae,
        key: `user_options_${ue.value}`,
        backgroundColor: e.value.style.chart.backgroundColor,
        color: e.value.style.chart.color,
        isPrinting: h(he),
        isImaging: h(pe),
        uid: L.value,
        hasTooltip: e.value.userOptions.buttons.tooltip && e.value.style.chart.tooltip.show,
        hasPdf: e.value.userOptions.buttons.pdf,
        hasImg: e.value.userOptions.buttons.img,
        hasXls: e.value.userOptions.buttons.csv,
        hasTable: e.value.userOptions.buttons.table,
        hasFullscreen: e.value.userOptions.buttons.fullscreen,
        isFullscreen: W.value,
        isTooltip: I.value.showTooltip,
        titles: { ...e.value.userOptions.buttonTitles },
        chartElement: R.value,
        position: e.value.userOptions.position,
        onToggleFullscreen: Ee,
        onGeneratePdf: h(ye),
        onGenerateCsv: _e,
        onGenerateImage: h(fe),
        onToggleTable: $e,
        onToggleTooltip: Ie
      }, He({ _: 2 }, [
        t.$slots.optionTooltip ? {
          name: "optionTooltip",
          fn: b(() => [
            w(t.$slots, "optionTooltip", {}, void 0, !0)
          ]),
          key: "0"
        } : void 0,
        t.$slots.optionPdf ? {
          name: "optionPdf",
          fn: b(() => [
            w(t.$slots, "optionPdf", {}, void 0, !0)
          ]),
          key: "1"
        } : void 0,
        t.$slots.optionCsv ? {
          name: "optionCsv",
          fn: b(() => [
            w(t.$slots, "optionCsv", {}, void 0, !0)
          ]),
          key: "2"
        } : void 0,
        t.$slots.optionImg ? {
          name: "optionImg",
          fn: b(() => [
            w(t.$slots, "optionImg", {}, void 0, !0)
          ]),
          key: "3"
        } : void 0,
        t.$slots.optionTable ? {
          name: "optionTable",
          fn: b(() => [
            w(t.$slots, "optionTable", {}, void 0, !0)
          ]),
          key: "4"
        } : void 0,
        t.$slots.optionFullscreen ? {
          name: "optionFullscreen",
          fn: b(({ toggleFullscreen: l, isFullscreen: a }) => [
            w(t.$slots, "optionFullscreen", q(H({ toggleFullscreen: l, isFullscreen: a })), void 0, !0)
          ]),
          key: "5"
        } : void 0
      ]), 1032, ["backgroundColor", "color", "isPrinting", "isImaging", "uid", "hasTooltip", "hasPdf", "hasImg", "hasXls", "hasTable", "hasFullscreen", "isFullscreen", "isTooltip", "titles", "chartElement", "position", "onGeneratePdf", "onGenerateImage"])) : f("", !0),
      X.value ? (s(), i("svg", {
        key: 2,
        xmlns: h(ot),
        class: Se({ "vue-data-ui-fullscreen--on": W.value, "vue-data-ui-fulscreen--off": !W.value }),
        viewBox: `0 0 ${P.value.width <= 0 ? 10 : P.value.width} ${P.value.height <= 0 ? 10 : P.value.height}`,
        style: Q(`max-width:100%;overflow:visible;background:transparent;color:${e.value.style.chart.color}`)
      }, [
        Le(_t),
        k("defs", null, [
          (s(!0), i(T, null, M(r.value, (l, a) => (s(), i("radialGradient", {
            cx: "50%",
            cy: "50%",
            r: "50%",
            fx: "50%",
            fy: "50%",
            id: `gradient_${L.value}_${a}`
          }, [
            k("stop", {
              offset: "0%",
              "stop-color": h(ut)(h(st)(l.color, 0.05), 100 - e.value.style.chart.layout.rect.gradientIntensity)
            }, null, 8, Lt),
            k("stop", {
              offset: "100%",
              "stop-color": l.color
            }, null, 8, Pt)
          ], 8, St))), 256))
        ]),
        k("defs", null, [
          k("filter", {
            id: `blur_${L.value}`,
            x: "-50%",
            y: "-50%",
            width: "200%",
            height: "200%"
          }, Bt, 8, zt)
        ]),
        e.value.useCustomCells && r.value.length ? (s(!0), i(T, { key: 0 }, M(E.value, (l, a) => (s(), i("foreignObject", {
          x: l.x,
          y: l.y,
          height: F.value <= 0 ? 1e-4 : F.value,
          width: z.value <= 0 ? 1e-4 : z.value,
          class: "vue-ui-waffle-custom-cell-foreignObject"
        }, [
          w(t.$slots, "cell", q(H({ cell: { ...l, color: r.value[a].color, ...r.value[a] }, isSelected: [null, void 0].includes(O.value) ? !0 : r.value[a].serieIndex === O.value })), void 0, !0)
        ], 8, Ot))), 256)) : f("", !0),
        !r.value.length && !e.value.useCustomCells ? (s(), i("rect", {
          key: 1,
          x: 12,
          y: 12,
          height: C.value.height - 24,
          width: C.value.width - 24,
          rx: 3,
          fill: "none",
          stroke: "black"
        }, null, 8, At)) : r.value.length && !e.value.useCustomCells ? (s(), i(T, { key: 2 }, [
          (s(!0), i(T, null, M(E.value, (l, a) => (s(), i("rect", {
            rx: e.value.style.chart.layout.rect.rounded ? e.value.style.chart.layout.rect.rounding : 0,
            x: l.x + e.value.style.chart.layout.grid.spaceBetween / 2,
            y: l.y + e.value.style.chart.layout.grid.spaceBetween / 2,
            height: F.value <= 0 ? 1e-4 : F.value,
            width: z.value <= 0 ? 1e-4 : z.value,
            fill: "white",
            stroke: e.value.style.chart.layout.rect.stroke,
            "stroke-width": e.value.style.chart.layout.rect.strokeWidth,
            filter: le(r.value[a].serieIndex)
          }, null, 8, Vt))), 256)),
          (s(!0), i(T, null, M(E.value, (l, a) => (s(), i("rect", {
            rx: e.value.style.chart.layout.rect.rounded ? e.value.style.chart.layout.rect.rounding : 0,
            x: l.x + e.value.style.chart.layout.grid.spaceBetween / 2,
            y: l.y + e.value.style.chart.layout.grid.spaceBetween / 2,
            height: F.value <= 0 ? 1e-4 : F.value,
            width: z.value <= 0 ? 1e-4 : z.value,
            fill: e.value.style.chart.layout.rect.useGradient && e.value.style.chart.layout.rect.gradientIntensity > 0 ? `url(#gradient_${L.value}_${a})` : r.value[a].color,
            stroke: e.value.style.chart.layout.rect.stroke,
            "stroke-width": e.value.style.chart.layout.rect.strokeWidth,
            filter: le(r.value[a].serieIndex)
          }, null, 8, Mt))), 256))
        ], 64)) : f("", !0),
        (s(!0), i(T, null, M(E.value, (l, a) => (s(), i(T, null, [
          r.value.length && !N.value && !e.value.style.chart.layout.grid.vertical && e.value.style.chart.layout.labels.captions.show && (r.value[a].isFirst && l.position < e.value.style.chart.layout.grid.size - 2 || r.value[a].isAbsoluteFirst && a % e.value.style.chart.layout.grid.size === 0 && r.value[a].absoluteStartIndex) ? (s(), i("foreignObject", {
            key: 0,
            x: l.x + e.value.style.chart.layout.labels.captions.offsetX + e.value.style.chart.layout.grid.spaceBetween / 2,
            y: l.y + e.value.style.chart.layout.labels.captions.offsetY + e.value.style.chart.layout.grid.spaceBetween / 2,
            height: K.value <= 0 ? 1e-4 : K.value,
            width: U.value * e.value.style.chart.layout.grid.size <= 0 ? 1e-4 : U.value * e.value.style.chart.layout.grid.size,
            filter: le(r.value[a].serieIndex)
          }, [
            k("div", {
              class: "vue-ui-waffle-caption",
              style: Q(`height: 100%; width: 100%; font-size:${e.value.style.chart.layout.labels.captions.fontSize}px;display:flex;align-items:center;justify-content:flex-start;padding: 0 ${U.value / 12}px;color:${h(rt)(r.value[a].color)};gap:2px`)
            }, [
              e.value.style.chart.layout.labels.captions.showSerieName ? (s(), i("span", Gt, S(e.value.style.chart.layout.labels.captions.serieNameAbbreviation ? h(nt)({ source: r.value[a].name, length: e.value.style.chart.layout.labels.captions.serieNameMaxAbbreviationSize }) : r.value[a].name) + ": ", 1)) : f("", !0),
              e.value.style.chart.layout.labels.captions.showPercentage ? (s(), i("span", Rt, S(h(x)({ v: r.value[a].proportion, s: "%", r: e.value.style.chart.layout.labels.captions.roundingPercentage })), 1)) : f("", !0),
              e.value.style.chart.layout.labels.captions.showPercentage && e.value.style.chart.layout.labels.captions.showValue ? (s(), i("span", Ut, " (" + S(h(D)(
                e.value.style.chart.layout.labels.dataLabels.formatter,
                r.value[a].value,
                h(x)({
                  p: e.value.style.chart.layout.labels.dataLabels.prefix,
                  v: r.value[a].value,
                  s: e.value.style.chart.layout.labels.dataLabels.suffix,
                  r: e.value.style.chart.layout.labels.captions.roundingValue
                }),
                { datapoint: r.value[a], position: l }
              )) + ") ", 1)) : f("", !0),
              !e.value.style.chart.layout.labels.captions.showPercentage && e.value.style.chart.layout.labels.captions.showValue ? (s(), i("span", jt, S(h(D)(
                e.value.style.chart.layout.labels.dataLabels.formatter,
                r.value[a].value,
                h(x)({
                  p: e.value.style.chart.layout.labels.dataLabels.prefix,
                  v: r.value[a].value,
                  s: e.value.style.chart.layout.labels.dataLabels.suffix,
                  r: e.value.style.chart.layout.labels.captions.roundingValue
                }),
                { datapoint: r.value[a], position: l }
              )), 1)) : f("", !0)
            ], 4)
          ], 8, Dt)) : f("", !0)
        ], 64))), 256)),
        (s(!0), i(T, null, M(E.value, (l, a) => (s(), i("rect", {
          onMouseover: (u) => je(a),
          onMouseleave: o[0] || (o[0] = (u) => {
            Z.value = !1, O.value = null;
          }),
          x: l.x + e.value.style.chart.layout.grid.spaceBetween / 2,
          y: l.y + e.value.style.chart.layout.grid.spaceBetween / 2,
          height: K.value <= 0 ? 1e-4 : K.value,
          width: U.value <= 0 ? 1e-4 : U.value,
          fill: "transparent",
          stroke: "none"
        }, null, 40, Et))), 256)),
        w(t.$slots, "svg", { svg: P.value }, void 0, !0)
      ], 14, Tt)) : f("", !0),
      t.$slots.watermark ? (s(), i("div", Wt, [
        w(t.$slots, "watermark", q(H({ isPrinting: h(he) || h(pe) })), void 0, !0)
      ])) : f("", !0),
      X.value ? f("", !0) : (s(), V(xt, {
        key: 4,
        config: {
          type: "waffle",
          style: {
            backgroundColor: e.value.style.chart.backgroundColor,
            waffle: {
              color: "#CCCCCC"
            }
          }
        }
      }, null, 8, ["config"])),
      k("div", {
        ref_key: "chartLegend",
        ref: re
      }, [
        e.value.style.chart.legend.show ? (s(), V(kt, {
          key: `legend_${ce.value}`,
          legendSet: A.value,
          config: Ue.value,
          onClickMarker: o[1] || (o[1] = ({ legend: l }) => Ce(l.uid))
        }, {
          item: b(({ legend: l }) => [
            k("div", {
              onClick: (a) => l.segregate(),
              style: Q(`opacity:${p.value.includes(l.uid) ? 0.5 : 1}`)
            }, [
              Pe(S(l.name) + ": " + S(h(D)(
                e.value.style.chart.layout.labels.dataLabels.formatter,
                l.value,
                h(x)({
                  p: e.value.style.chart.layout.labels.dataLabels.prefix,
                  v: l.value,
                  s: e.value.style.chart.layout.labels.dataLabels.suffix,
                  r: e.value.style.chart.legend.roundingValue,
                  isAnimating: N.value
                }),
                { datapoint: l }
              )) + " ", 1),
              p.value.includes(l.uid) ? (s(), i("span", Xt, " ( - % ) ")) : (s(), i("span", Ht, " (" + S(isNaN(l.value / _.value) ? "-" : h(x)({ v: l.value / _.value * 100, s: "%", r: e.value.style.chart.legend.roundingPercentage, isAnimating: N.value })) + ") ", 1))
            ], 12, qt)
          ]),
          _: 1
        }, 8, ["legendSet", "config"])) : w(t.$slots, "legend", {
          key: 1,
          legend: A.value
        }, void 0, !0)
      ], 512),
      Le(bt, {
        show: I.value.showTooltip && Z.value && p.value.length < g.dataset.length,
        backgroundColor: e.value.style.chart.tooltip.backgroundColor,
        color: e.value.style.chart.tooltip.color,
        borderRadius: e.value.style.chart.tooltip.borderRadius,
        borderColor: e.value.style.chart.tooltip.borderColor,
        borderWidth: e.value.style.chart.tooltip.borderWidth,
        backgroundOpacity: e.value.style.chart.tooltip.backgroundOpacity,
        position: e.value.style.chart.tooltip.position,
        offsetY: e.value.style.chart.tooltip.offsetY,
        parent: R.value,
        content: ee.value,
        isCustom: e.value.style.chart.tooltip.customFormat && typeof e.value.style.chart.tooltip.customFormat == "function",
        fontSize: e.value.style.chart.tooltip.fontSize
      }, {
        "tooltip-before": b(() => [
          w(t.$slots, "tooltip-before", q(H({ ...te.value })), void 0, !0)
        ]),
        "tooltip-after": b(() => [
          w(t.$slots, "tooltip-after", q(H({ ...te.value })), void 0, !0)
        ]),
        _: 3
      }, 8, ["show", "backgroundColor", "color", "borderRadius", "borderColor", "borderWidth", "backgroundOpacity", "position", "offsetY", "parent", "content", "isCustom", "fontSize"]),
      X.value ? (s(), V(Ct, {
        key: 5,
        hideDetails: "",
        config: {
          open: I.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: b(() => [
          (s(), V(wt, {
            key: `table_${ie.value}`,
            colNames: J.value.colNames,
            head: J.value.head,
            body: J.value.body,
            config: J.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[2] || (o[2] = (l) => I.value.showTable = !1)
          }, {
            th: b(({ th: l }) => [
              k("div", {
                innerHTML: l,
                style: { display: "flex", "align-items": "center" }
              }, null, 8, Yt)
            ]),
            td: b(({ td: l }) => [
              Pe(S(l.name || l), 1)
            ]),
            _: 1
          }, 8, ["colNames", "head", "body", "config", "title"]))
        ]),
        _: 1
      }, 8, ["config"])) : f("", !0)
    ], 14, It));
  }
}, cl = /* @__PURE__ */ $t(Kt, [["__scopeId", "data-v-a0574c0d"]]);
export {
  cl as default
};
