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