import { ref as u, onMounted as b, onUnmounted as g, computed as p, openBlock as v, createBlock as x, Teleport as h, createElementBlock as S, normalizeClass as k, normalizeStyle as $, renderSlot as c, createElementVNode as C, createCommentVNode as B } from "vue";
import { s as F } from "./index-Cm2_6s9o.js";
function N({ tooltip: e, chart: o, clientPosition: t, positionPreference: r = "center", defaultOffsetY: a = 24, blockShiftY: f = !1 }) {
  const l = u(0), s = u(a);
  if (e && o) {
    const { width: n, height: m } = e.getBoundingClientRect(), { right: i, left: d, bottom: y } = o.getBoundingClientRect();
    r === "center" && (t.x + n / 2 > i ? l.value = -n + (i - t.x) : t.x - n / 2 < d ? l.value = -n + (n - (t.x - d)) : l.value = -n / 2), r === "right" && (t.x + n > i ? l.value = -n + (i - t.x) : l.value = 0), r === "left" && (t.x < d + n ? l.value = -n + (n - (t.x - d)) : l.value = -n), t.y + m > y && !f && (s.value = -m - a);
  }
  return {
    top: t.y + s.value,
    left: t.x + l.value
  };
}
function Y(e, o, t) {
  b(() => e.addEventListener(o, t)), g(() => e.removeEventListener(o, t));
}
function w() {
  const e = u(0), o = u(0);
  return Y(window, "mousemove", (t) => {
    e.value = t.clientX, o.value = t.clientY;
  }), { x: e, y: o };
}
const z = ["innerHTML"], T = {
  __name: "Tooltip",
  props: {
    backgroundColor: {
      type: String,
      default: "#FFFFFF"
    },
    color: {
      type: String,
      default: "#000000"
    },
    content: String,
    maxWidth: {
      type: String,
      default: "300px"
    },
    parent: {
      type: Object
    },
    show: {
      type: Boolean,
      default: !1
    },
    isCustom: {
      type: Boolean,
      default: !1
    },
    fontSize: {
      type: [Number, String],
      default: 14
    },
    borderRadius: {
      type: Number,
      default: 4
    },
    borderColor: {
      type: String,
      default: "#e1e5e8"
    },
    borderWidth: {
      type: Number,
      default: 1
    },
    backgroundOpacity: {
      type: Number,
      default: 100
    },
    position: {
      type: String,
      default: "center"
    },
    offsetY: {
      type: Number,
      default: 24
    },
    blockShiftY: {
      type: Boolean,
      default: !1
    },
    isFullscreen: {
      type: Boolean,
      default: !1
    }
  },
  setup(e) {
    const o = e, t = u(null), r = u(w(o.parent)), a = p(() => N({
      tooltip: t.value,
      chart: o.parent,
      clientPosition: r.value,
      positionPreference: o.position,
      defaultOffsetY: o.offsetY,
      blockShiftY: o.blockShiftY
    })), f = p(() => F(o.backgroundColor, o.backgroundOpacity));
    return (l, s) => (v(), x(h, {
      to: e.isFullscreen ? e.parent : "body"
    }, [
      e.show ? (v(), S("div", {
        key: 0,
        ref_key: "tooltip",
        ref: t,
        class: k({ "vue-data-ui-custom-tooltip": e.isCustom, "vue-data-ui-tooltip": !e.isCustom }),
        style: $(`pointer-events:none;top:${a.value.top}px;left:${a.value.left}px;${e.isCustom ? "" : `background:${f.value};color:${e.color};max-width:${e.maxWidth};font-size:${e.fontSize}px`};border-radius:${e.borderRadius}px;border:${e.borderWidth}px solid ${e.borderColor};z-index:2147483647;`)
      }, [
        c(l.$slots, "tooltip-before"),
        c(l.$slots, "default"),
        C("div", { innerHTML: e.content }, null, 8, z),
        c(l.$slots, "tooltip-after")
      ], 6)) : B("", !0)
    ], 8, ["to"]));
  }
};
export {
  T as _,
  w as u
};
