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