import { ref as k, onMounted as q, onBeforeUnmount as H, withDirectives as R, openBlock as t, createElementBlock as s, normalizeStyle as d, createElementVNode as w, withModifiers as x, withKeys as G, createVNode as J, normalizeClass as c, renderSlot as m, Fragment as M, createBlock as f, toDisplayString as $, createCommentVNode as u, normalizeProps as h, mergeProps as z, unref as Q } from "vue";
import v from "./BaseIcon-BNFf4B_v.js";
import { _ as Y } from "./_plugin-vue_export-helper-CHgC5LLL.js";
import { p as Z } from "./pdf-97UbtKC2.js";
import _ from "./html2canvas.esm-d2sM-0Wm.js";
const ee = {
  beforeMount(e, r) {
    e.clickOutsideEvent = function(i) {
      e === i.target || e.contains(i.target) || r.value(i);
    }, document.addEventListener("click", e.clickOutsideEvent);
  },
  unmounted(e) {
    document.removeEventListener("click", e.clickOutsideEvent);
  }
}, te = ["title", "onClick", "onKeypress"], oe = ["data-open"], ne = {
  __name: "UserOptions",
  props: {
    hasPdf: {
      type: Boolean,
      default: !0
    },
    hasXls: {
      type: Boolean,
      default: !0
    },
    hasImg: {
      type: Boolean,
      default: !1
    },
    hasLabel: {
      type: Boolean,
      default: !1
    },
    isLabelActive: {
      type: Boolean,
      default: !1
    },
    hasTable: {
      type: Boolean,
      default: !1
    },
    hasSort: {
      type: Boolean,
      default: !1
    },
    hasStack: {
      type: Boolean,
      default: !1
    },
    hasTooltip: {
      type: Boolean,
      default: !1
    },
    color: {
      type: String
    },
    backgroundColor: {
      type: String
    },
    isPrinting: {
      type: Boolean,
      default: !1
    },
    isImaging: {
      type: Boolean,
      default: !1
    },
    title: {
      type: String
    },
    uid: {
      type: String
    },
    hasFullscreen: {
      type: Boolean,
      default: !1
    },
    chartElement: {
      type: HTMLElement,
      default: null
    },
    isFullscreen: {
      type: Boolean,
      default: !1
    },
    isStacked: {
      type: Boolean,
      default: !1
    },
    isTooltip: {
      type: Boolean,
      default: !1
    },
    hasAnimation: {
      type: Boolean,
      default: !1
    },
    isAnimation: {
      type: Boolean,
      default: !1
    },
    titles: {
      type: Object,
      default() {
        return {};
      }
    },
    showTooltips: {
      type: Boolean,
      default: !0
    },
    zIndex: {
      type: Number,
      default: 1
    },
    noOffset: {
      type: Boolean,
      default: !1
    }
  },
  emits: ["generatePdf", "generateCsv", "generateImage", "toggleTable", "toggleLabels", "toggleSort", "toggleFullscreen", "toggleStack", "toggleTooltip", "toggleAnimation"],
  setup(e, { emit: r }) {
    const i = e;
    function T() {
      r("generatePdf");
    }
    function S() {
      r("generateCsv");
    }
    function C() {
      r("generateImage");
    }
    const b = k(!1);
    function D() {
      b.value = !b.value, r("toggleTable");
    }
    const B = k(!1), U = k(!0);
    function F() {
      g.value = window.innerWidth > 600, B.value = !B.value, B.value && (U.value = !1);
    }
    function K() {
      i.isPrinting || i.isImaging || (B.value = !1);
    }
    function N() {
      B.value && K();
    }
    const p = k(i.isLabelActive);
    function V() {
      p.value = !p.value, r("toggleLabels");
    }
    const I = k(i.isAnimation);
    function P() {
      I.value = !I.value, r("toggleAnimation");
    }
    function j() {
      r("toggleSort");
    }
    const E = k(i.isStacked);
    function W() {
      E.value = !E.value, r("toggleStack");
    }
    const L = k(i.isTooltip);
    function X() {
      L.value = !L.value, r("toggleTooltip");
    }
    const y = k(!1);
    function A(n) {
      i.chartElement && (n === "in" ? (y.value = !0, i.chartElement.requestFullscreen(), r("toggleFullscreen", !0)) : (y.value = !1, document && document.exitFullscreen(), r("toggleFullscreen", !1)));
    }
    function O(n) {
      document.fullscreenElement ? y.value = !0 : y.value = !1;
    }
    q(() => {
      document.addEventListener("fullscreenchange", O);
    }), H(() => {
      document.removeEventListener("fullscreenchange", O);
    });
    const g = k(window.innerWidth > 600), l = k({
      tooltip: !1,
      pdf: !1,
      csv: !1,
      img: !1,
      table: !1,
      labels: !1,
      sort: !1,
      stack: !1,
      fullscreen: !1,
      animation: !1
    });
    return (n, o) => R((t(), s("div", {
      "data-html2canvas-ignore": "",
      class: "vue-ui-user-options",
      style: d(`z-index: ${e.zIndex}; height: 34px; position: ${y.value ? "fixed" : "absolute"}; top: 0; right:${y.value ? "12px" : "0"}; padding: 4px; background:transparent;`)
    }, [
      w("div", {
        tabindex: "0",
        title: B.value ? e.titles.close || "" : e.titles.open || "",
        style: d(`width:32px; position: absolute; top: 0; right: ${e.noOffset ? 0 : 4}px; padding: 0 0px; display: flex; align-items:center;justify-content:center;height: 36px;  cursor:pointer; background:${e.backgroundColor}`),
        onClick: x(F, ["stop"]),
        onKeypress: G(F, ["enter"])
      }, [
        J(v, {
          name: B.value ? "close" : "menu",
          stroke: "#CCCCCC",
          "stroke-width": 2
        }, null, 8, ["name"])
      ], 44, te),
      w("div", {
        "data-open": B.value,
        class: c({ "vue-ui-user-options-drawer": !0 }),
        style: d(`background:${e.backgroundColor}; right:${e.noOffset ? 0 : 4}px`)
      }, [
        e.hasTooltip ? (t(), s("button", {
          key: 0,
          tabindex: "0",
          class: "vue-ui-user-options-button",
          onClick: X,
          onMouseenter: o[0] || (o[0] = (a) => l.value.tooltip = !0),
          onMouseout: o[1] || (o[1] = (a) => l.value.tooltip = !1)
        }, [
          n.$slots.optionTooltip ? m(n.$slots, "optionTooltip", { key: 0 }, void 0, !0) : (t(), s(M, { key: 1 }, [
            L.value ? (t(), f(v, {
              key: 0,
              name: "tooltip",
              stroke: e.color,
              style: { "pointer-events": "none" }
            }, null, 8, ["stroke"])) : (t(), f(v, {
              key: 1,
              name: "tooltipDisabled",
              stroke: e.color,
              style: { "pointer-events": "none" }
            }, null, 8, ["stroke"]))
          ], 64)),
          g.value && e.titles.tooltip && !n.$slots.optionTooltip ? (t(), s("div", {
            key: 2,
            class: c({ "button-info": !0, "button-info-visible": l.value.tooltip }),
            style: d({ background: e.backgroundColor, color: e.color })
          }, $(e.titles.tooltip), 7)) : u("", !0)
        ], 32)) : u("", !0),
        e.hasPdf ? (t(), s("button", {
          key: 1,
          tabindex: "0",
          class: "vue-ui-user-options-button",
          onClick: T,
          onMouseenter: o[2] || (o[2] = (a) => l.value.pdf = !0),
          onMouseout: o[3] || (o[3] = (a) => l.value.pdf = !1)
        }, [
          n.$slots.optionPdf ? m(n.$slots, "optionPdf", { key: 0 }, void 0, !0) : (t(), s(M, { key: 1 }, [
            e.isPrinting ? (t(), f(v, {
              key: 0,
              name: "spin",
              isSpin: "",
              stroke: e.color,
              style: { "pointer-events": "none" }
            }, null, 8, ["stroke"])) : (t(), f(v, {
              key: 1,
              name: "pdf",
              stroke: e.color,
              style: { "pointer-events": "none" }
            }, null, 8, ["stroke"]))
          ], 64)),
          g.value && e.titles.pdf && !n.$slots.optionPdf ? (t(), s("div", {
            key: 2,
            class: c({ "button-info": !0, "button-info-visible": l.value.pdf }),
            style: d({ background: e.backgroundColor, color: e.color })
          }, $(e.titles.pdf), 7)) : u("", !0)
        ], 32)) : u("", !0),
        e.hasXls ? (t(), s("button", {
          key: 2,
          tabindex: "0",
          class: "vue-ui-user-options-button",
          onClick: S,
          onMouseenter: o[4] || (o[4] = (a) => l.value.csv = !0),
          onMouseout: o[5] || (o[5] = (a) => l.value.csv = !1)
        }, [
          n.$slots.optionCsv ? m(n.$slots, "optionCsv", { key: 0 }, void 0, !0) : (t(), f(v, {
            key: 1,
            name: "excel",
            stroke: e.color,
            style: { "pointer-events": "none" }
          }, null, 8, ["stroke"])),
          g.value && e.titles.csv && !n.$slots.optionCsv ? (t(), s("div", {
            key: 2,
            class: c({ "button-info": !0, "button-info-visible": l.value.csv }),
            style: d({ background: e.backgroundColor, color: e.color })
          }, $(e.titles.csv), 7)) : u("", !0)
        ], 32)) : u("", !0),
        e.hasImg ? (t(), s("button", {
          key: 3,
          tabindex: "0",
          class: "vue-ui-user-options-button",
          onClick: C,
          onMouseenter: o[6] || (o[6] = (a) => l.value.img = !0),
          onMouseout: o[7] || (o[7] = (a) => l.value.img = !1)
        }, [
          n.$slots.optionImg ? m(n.$slots, "optionImg", { key: 0 }, void 0, !0) : (t(), s(M, { key: 1 }, [
            e.isImaging ? (t(), f(v, {
              key: 0,
              name: "spin",
              isSpin: "",
              stroke: e.color,
              style: { "pointer-events": "none" }
            }, null, 8, ["stroke"])) : (t(), f(v, {
              key: 1,
              name: "image",
              stroke: e.color,
              style: { "pointer-events": "none" }
            }, null, 8, ["stroke"]))
          ], 64)),
          g.value && e.titles.img && !n.$slots.optionImg ? (t(), s("div", {
            key: 2,
            class: c({ "button-info": !0, "button-info-visible": l.value.img }),
            style: d({ background: e.backgroundColor, color: e.color })
          }, $(e.titles.img), 7)) : u("", !0)
        ], 32)) : u("", !0),
        e.hasTable ? (t(), s("button", {
          key: 4,
          tabindex: "0",
          class: "vue-ui-user-options-button",
          onClick: D,
          onMouseenter: o[8] || (o[8] = (a) => l.value.table = !0),
          onMouseout: o[9] || (o[9] = (a) => l.value.table = !1)
        }, [
          n.$slots.optionTable ? m(n.$slots, "optionTable", { key: 0 }, void 0, !0) : (t(), f(v, {
            key: 1,
            name: b.value ? "tableClose" : "tableOpen",
            stroke: e.color,
            style: { "pointer-events": "none" }
          }, null, 8, ["name", "stroke"])),
          g.value && e.titles.table && !n.$slots.optionTable ? (t(), s("div", {
            key: 2,
            class: c({ "button-info": !0, "button-info-visible": l.value.table }),
            style: d({ background: e.backgroundColor, color: e.color })
          }, $(e.titles.table), 7)) : u("", !0)
        ], 32)) : u("", !0),
        e.hasLabel ? (t(), s("button", {
          key: 5,
          tabindex: "0",
          class: "vue-ui-user-options-button",
          onClick: V,
          onMouseenter: o[10] || (o[10] = (a) => l.value.labels = !0),
          onMouseout: o[11] || (o[11] = (a) => l.value.labels = !1)
        }, [
          n.$slots.optionLabels ? m(n.$slots, "optionLabels", { key: 0 }, void 0, !0) : (t(), f(v, {
            key: 1,
            name: p.value ? "labelClose" : "labelOpen",
            stroke: e.color,
            style: { "pointer-events": "none" }
          }, null, 8, ["name", "stroke"])),
          g.value && e.titles.labels && !n.$slots.optionLabels ? (t(), s("div", {
            key: 2,
            class: c({ "button-info": !0, "button-info-visible": l.value.labels }),
            style: d({ background: e.backgroundColor, color: e.color })
          }, $(e.titles.labels), 7)) : u("", !0)
        ], 32)) : u("", !0),
        e.hasSort ? (t(), s("button", {
          key: 6,
          tabindex: "0",
          class: "vue-ui-user-options-button",
          onClick: j,
          onMouseenter: o[12] || (o[12] = (a) => l.value.sort = !0),
          onMouseout: o[13] || (o[13] = (a) => l.value.sort = !1)
        }, [
          n.$slots.optionSort ? m(n.$slots, "optionSort", { key: 0 }, void 0, !0) : (t(), f(v, {
            key: 1,
            name: "sort",
            stroke: e.color,
            style: { "pointer-events": "none" }
          }, null, 8, ["stroke"])),
          g.value && e.titles.sort && !n.$slots.optionSort ? (t(), s("div", {
            key: 2,
            class: c({ "button-info": !0, "button-info-visible": l.value.sort }),
            style: d({ background: e.backgroundColor, color: e.color })
          }, $(e.titles.sort), 7)) : u("", !0)
        ], 32)) : u("", !0),
        e.hasStack ? (t(), s("button", {
          key: 7,
          tabindex: "0",
          class: "vue-ui-user-options-button",
          onClick: W,
          onMouseenter: o[14] || (o[14] = (a) => l.value.stack = !0),
          onMouseout: o[15] || (o[15] = (a) => l.value.stack = !1)
        }, [
          n.$slots.optionStack ? m(n.$slots, "optionStack", { key: 0 }, void 0, !0) : (t(), s(M, { key: 1 }, [
            E.value ? (t(), f(v, {
              key: 0,
              name: "unstack",
              stroke: e.color,
              style: { "pointer-events": "none" }
            }, null, 8, ["stroke"])) : (t(), f(v, {
              key: 1,
              name: "stack",
              stroke: e.color,
              style: { "pointer-events": "none" }
            }, null, 8, ["stroke"]))
          ], 64)),
          g.value && e.titles.stack && !n.$slots.optionStack ? (t(), s("div", {
            key: 2,
            class: c({ "button-info": !0, "button-info-visible": l.value.stack }),
            style: d({ background: e.backgroundColor, color: e.color })
          }, $(e.titles.stack), 7)) : u("", !0)
        ], 32)) : u("", !0),
        e.hasFullscreen ? (t(), s("button", {
          key: 8,
          tabindex: "0",
          class: "vue-ui-user-options-button",
          onMouseenter: o[16] || (o[16] = (a) => l.value.fullscreen = !0),
          onMouseout: o[17] || (o[17] = (a) => l.value.fullscreen = !1),
          onClick: o[18] || (o[18] = (a) => A(y.value ? "out" : "in"))
        }, [
          n.$slots.optionFullscreen ? m(n.$slots, "optionFullscreen", h(z({ key: 0 }, { toggleFullscreen: A, isFullscreen: y.value })), void 0, !0) : (t(), s(M, { key: 1 }, [
            y.value ? (t(), f(v, {
              key: 0,
              name: "exitFullscreen",
              stroke: e.color,
              style: { "pointer-events": "none" }
            }, null, 8, ["stroke"])) : u("", !0),
            y.value ? u("", !0) : (t(), f(v, {
              key: 1,
              name: "fullscreen",
              stroke: e.color,
              style: { "pointer-events": "none" }
            }, null, 8, ["stroke"]))
          ], 64)),
          g.value && e.titles.fullscreen && !n.$slots.optionFullscreen ? (t(), s("div", {
            key: 2,
            class: c({ "button-info": !0, "button-info-visible": l.value.fullscreen }),
            style: d({ background: e.backgroundColor, color: e.color })
          }, $(e.titles.fullscreen), 7)) : u("", !0)
        ], 32)) : u("", !0),
        e.hasAnimation ? (t(), s("button", {
          key: 9,
          tabindex: "0",
          class: "vue-ui-user-options-button",
          onMouseenter: o[19] || (o[19] = (a) => l.value.animation = !0),
          onMouseout: o[20] || (o[20] = (a) => l.value.animation = !1),
          onClick: P
        }, [
          n.$slots.optionAnimation ? m(n.$slots, "optionAnimation", h(z({ key: 0 }, { toggleAnimation: P, isAnimated: I.value })), void 0, !0) : (t(), s(M, { key: 1 }, [
            I.value ? (t(), f(v, {
              key: 0,
              name: "play",
              stroke: e.color,
              style: { "pointer-events": "none" }
            }, null, 8, ["stroke"])) : u("", !0),
            I.value ? u("", !0) : (t(), f(v, {
              key: 1,
              name: "pause",
              stroke: e.color,
              style: { "pointer-events": "none" }
            }, null, 8, ["stroke"]))
          ], 64)),
          g.value && e.titles.fullscreen && !n.$slots.optionAnimation ? (t(), s("div", {
            key: 2,
            class: c({ "button-info": !0, "button-info-visible": l.value.animation }),
            style: d({ background: e.backgroundColor, color: e.color })
          }, $(e.titles.animation), 7)) : u("", !0)
        ], 32)) : u("", !0)
      ], 12, oe)
    ], 4)), [
      [Q(ee), N]
    ]);
  }
}, ve = /* @__PURE__ */ Y(ne, [["__scopeId", "data-v-d4402778"]]);
function le({ domElement: e, fileName: r, format: i = "png" }) {
  if (e)
    return new Promise((T, S) => {
      const C = document.createElement("a");
      _(e, { scale: 2 }).then((b) => {
        C.href = b.toDataURL(`image/${i}`), C.download = `${r}.${i}`, C.click(), C && C.remove(), T();
      }).catch((b) => {
        console.error("Error generating image:", b), S(b);
      });
    });
}
function fe({
  elementId: e,
  fileName: r
}) {
  const i = k(!1), T = k(!1), S = k(null);
  function C() {
    i.value = !0, clearTimeout(S.value), S.value = setTimeout(() => {
      Z({
        domElement: document.getElementById(e),
        fileName: r
      }).finally(() => {
        i.value = !1;
      });
    }, 100);
  }
  function b() {
    T.value = !0, clearTimeout(S.value), S.value = setTimeout(() => {
      le({
        domElement: document.getElementById(e),
        fileName: r,
        format: "png"
      }).finally(() => {
        T.value = !1;
      }, 100);
    });
  }
  return {
    generatePdf: C,
    generateImage: b,
    isPrinting: i,
    isImaging: T
  };
}
export {
  ve as U,
  le as s,
  fe as u
};
