vue-popper-lite
Version:
VueJS popover component based popper.js v2
1,050 lines (1,049 loc) • 34 kB
JavaScript
import { defineComponent as gt, ref as q, onMounted as yt, onUnmounted as bt, watch as Ee, openBlock as Xe, createElementBlock as ze, normalizeClass as Ue, createElementVNode as Ye, renderSlot as Ie, createVNode as wt, Transition as Ot, withCtx as xt, withDirectives as Et, createTextVNode as At, toDisplayString as Pt, createCommentVNode as kt, vShow as Dt, nextTick as _e } from "vue";
function S(e) {
if (e == null)
return window;
if (e.toString() !== "[object Window]") {
var t = e.ownerDocument;
return t && t.defaultView || window;
}
return e;
}
function J(e) {
var t = S(e).Element;
return e instanceof t || e instanceof Element;
}
function $(e) {
var t = S(e).HTMLElement;
return e instanceof t || e instanceof HTMLElement;
}
function ke(e) {
if (typeof ShadowRoot > "u")
return !1;
var t = S(e).ShadowRoot;
return e instanceof t || e instanceof ShadowRoot;
}
var G = Math.max, ge = Math.min, Q = Math.round;
function Ae() {
var e = navigator.userAgentData;
return e != null && e.brands && Array.isArray(e.brands) ? e.brands.map(function(t) {
return t.brand + "/" + t.version;
}).join(" ") : navigator.userAgent;
}
function rt() {
return !/^((?!chrome|android).)*safari/i.test(Ae());
}
function Z(e, t, r) {
t === void 0 && (t = !1), r === void 0 && (r = !1);
var a = e.getBoundingClientRect(), o = 1, n = 1;
t && $(e) && (o = e.offsetWidth > 0 && Q(a.width) / e.offsetWidth || 1, n = e.offsetHeight > 0 && Q(a.height) / e.offsetHeight || 1);
var u = J(e) ? S(e) : window, s = u.visualViewport, i = !rt() && r, l = (a.left + (i && s ? s.offsetLeft : 0)) / o, f = (a.top + (i && s ? s.offsetTop : 0)) / n, m = a.width / o, h = a.height / n;
return {
width: m,
height: h,
top: f,
right: l + m,
bottom: f + h,
left: l,
x: l,
y: f
};
}
function De(e) {
var t = S(e), r = t.pageXOffset, a = t.pageYOffset;
return {
scrollLeft: r,
scrollTop: a
};
}
function Ct(e) {
return {
scrollLeft: e.scrollLeft,
scrollTop: e.scrollTop
};
}
function Bt(e) {
return e === S(e) || !$(e) ? De(e) : Ct(e);
}
function V(e) {
return e ? (e.nodeName || "").toLowerCase() : null;
}
function X(e) {
return ((J(e) ? e.ownerDocument : (
// $FlowFixMe[prop-missing]
e.document
)) || window.document).documentElement;
}
function Ce(e) {
return Z(X(e)).left + De(e).scrollLeft;
}
function H(e) {
return S(e).getComputedStyle(e);
}
function Be(e) {
var t = H(e), r = t.overflow, a = t.overflowX, o = t.overflowY;
return /auto|scroll|overlay|hidden/.test(r + o + a);
}
function Tt(e) {
var t = e.getBoundingClientRect(), r = Q(t.width) / e.offsetWidth || 1, a = Q(t.height) / e.offsetHeight || 1;
return r !== 1 || a !== 1;
}
function jt(e, t, r) {
r === void 0 && (r = !1);
var a = $(t), o = $(t) && Tt(t), n = X(t), u = Z(e, o, r), s = {
scrollLeft: 0,
scrollTop: 0
}, i = {
x: 0,
y: 0
};
return (a || !a && !r) && ((V(t) !== "body" || // https://github.com/popperjs/popper-core/issues/1078
Be(n)) && (s = Bt(t)), $(t) ? (i = Z(t, !0), i.x += t.clientLeft, i.y += t.clientTop) : n && (i.x = Ce(n))), {
x: u.left + s.scrollLeft - i.x,
y: u.top + s.scrollTop - i.y,
width: u.width,
height: u.height
};
}
function Te(e) {
var t = Z(e), r = e.offsetWidth, a = e.offsetHeight;
return Math.abs(t.width - r) <= 1 && (r = t.width), Math.abs(t.height - a) <= 1 && (a = t.height), {
x: e.offsetLeft,
y: e.offsetTop,
width: r,
height: a
};
}
function ye(e) {
return V(e) === "html" ? e : (
// this is a quicker (but less type safe) way to save quite some bytes from the bundle
// $FlowFixMe[incompatible-return]
// $FlowFixMe[prop-missing]
e.assignedSlot || // step into the shadow DOM of the parent of a slotted node
e.parentNode || // DOM Element detected
(ke(e) ? e.host : null) || // ShadowRoot detected
// $FlowFixMe[incompatible-call]: HTMLElement is a Node
X(e)
);
}
function at(e) {
return ["html", "body", "#document"].indexOf(V(e)) >= 0 ? e.ownerDocument.body : $(e) && Be(e) ? e : at(ye(e));
}
function ne(e, t) {
var r;
t === void 0 && (t = []);
var a = at(e), o = a === ((r = e.ownerDocument) == null ? void 0 : r.body), n = S(a), u = o ? [n].concat(n.visualViewport || [], Be(a) ? a : []) : a, s = t.concat(u);
return o ? s : (
// $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
s.concat(ne(ye(u)))
);
}
function St(e) {
return ["table", "td", "th"].indexOf(V(e)) >= 0;
}
function Ge(e) {
return !$(e) || // https://github.com/popperjs/popper-core/issues/837
H(e).position === "fixed" ? null : e.offsetParent;
}
function $t(e) {
var t = /firefox/i.test(Ae()), r = /Trident/i.test(Ae());
if (r && $(e)) {
var a = H(e);
if (a.position === "fixed")
return null;
}
var o = ye(e);
for (ke(o) && (o = o.host); $(o) && ["html", "body"].indexOf(V(o)) < 0; ) {
var n = H(o);
if (n.transform !== "none" || n.perspective !== "none" || n.contain === "paint" || ["transform", "perspective"].indexOf(n.willChange) !== -1 || t && n.willChange === "filter" || t && n.filter && n.filter !== "none")
return o;
o = o.parentNode;
}
return null;
}
function fe(e) {
for (var t = S(e), r = Ge(e); r && St(r) && H(r).position === "static"; )
r = Ge(r);
return r && (V(r) === "html" || V(r) === "body" && H(r).position === "static") ? t : r || $t(e) || t;
}
var T = "top", M = "bottom", W = "right", j = "left", je = "auto", ue = [T, M, W, j], ee = "start", se = "end", Rt = "clippingParents", ot = "viewport", oe = "popper", Lt = "reference", Je = /* @__PURE__ */ ue.reduce(function(e, t) {
return e.concat([t + "-" + ee, t + "-" + se]);
}, []), nt = /* @__PURE__ */ [].concat(ue, [je]).reduce(function(e, t) {
return e.concat([t, t + "-" + ee, t + "-" + se]);
}, []), Mt = "beforeRead", Wt = "read", Nt = "afterRead", Vt = "beforeMain", Ht = "main", Ft = "afterMain", qt = "beforeWrite", Xt = "write", zt = "afterWrite", Ut = [Mt, Wt, Nt, Vt, Ht, Ft, qt, Xt, zt];
function Yt(e) {
var t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), a = [];
e.forEach(function(n) {
t.set(n.name, n);
});
function o(n) {
r.add(n.name);
var u = [].concat(n.requires || [], n.requiresIfExists || []);
u.forEach(function(s) {
if (!r.has(s)) {
var i = t.get(s);
i && o(i);
}
}), a.push(n);
}
return e.forEach(function(n) {
r.has(n.name) || o(n);
}), a;
}
function It(e) {
var t = Yt(e);
return Ut.reduce(function(r, a) {
return r.concat(t.filter(function(o) {
return o.phase === a;
}));
}, []);
}
function _t(e) {
var t;
return function() {
return t || (t = new Promise(function(r) {
Promise.resolve().then(function() {
t = void 0, r(e());
});
})), t;
};
}
function Gt(e) {
var t = e.reduce(function(r, a) {
var o = r[a.name];
return r[a.name] = o ? Object.assign({}, o, a, {
options: Object.assign({}, o.options, a.options),
data: Object.assign({}, o.data, a.data)
}) : a, r;
}, {});
return Object.keys(t).map(function(r) {
return t[r];
});
}
function Jt(e, t) {
var r = S(e), a = X(e), o = r.visualViewport, n = a.clientWidth, u = a.clientHeight, s = 0, i = 0;
if (o) {
n = o.width, u = o.height;
var l = rt();
(l || !l && t === "fixed") && (s = o.offsetLeft, i = o.offsetTop);
}
return {
width: n,
height: u,
x: s + Ce(e),
y: i
};
}
function Kt(e) {
var t, r = X(e), a = De(e), o = (t = e.ownerDocument) == null ? void 0 : t.body, n = G(r.scrollWidth, r.clientWidth, o ? o.scrollWidth : 0, o ? o.clientWidth : 0), u = G(r.scrollHeight, r.clientHeight, o ? o.scrollHeight : 0, o ? o.clientHeight : 0), s = -a.scrollLeft + Ce(e), i = -a.scrollTop;
return H(o || r).direction === "rtl" && (s += G(r.clientWidth, o ? o.clientWidth : 0) - n), {
width: n,
height: u,
x: s,
y: i
};
}
function it(e, t) {
var r = t.getRootNode && t.getRootNode();
if (e.contains(t))
return !0;
if (r && ke(r)) {
var a = t;
do {
if (a && e.isSameNode(a))
return !0;
a = a.parentNode || a.host;
} while (a);
}
return !1;
}
function Pe(e) {
return Object.assign({}, e, {
left: e.x,
top: e.y,
right: e.x + e.width,
bottom: e.y + e.height
});
}
function Qt(e, t) {
var r = Z(e, !1, t === "fixed");
return r.top = r.top + e.clientTop, r.left = r.left + e.clientLeft, r.bottom = r.top + e.clientHeight, r.right = r.left + e.clientWidth, r.width = e.clientWidth, r.height = e.clientHeight, r.x = r.left, r.y = r.top, r;
}
function Ke(e, t, r) {
return t === ot ? Pe(Jt(e, r)) : J(t) ? Qt(t, r) : Pe(Kt(X(e)));
}
function Zt(e) {
var t = ne(ye(e)), r = ["absolute", "fixed"].indexOf(H(e).position) >= 0, a = r && $(e) ? fe(e) : e;
return J(a) ? t.filter(function(o) {
return J(o) && it(o, a) && V(o) !== "body";
}) : [];
}
function er(e, t, r, a) {
var o = t === "clippingParents" ? Zt(e) : [].concat(t), n = [].concat(o, [r]), u = n[0], s = n.reduce(function(i, l) {
var f = Ke(e, l, a);
return i.top = G(f.top, i.top), i.right = ge(f.right, i.right), i.bottom = ge(f.bottom, i.bottom), i.left = G(f.left, i.left), i;
}, Ke(e, u, a));
return s.width = s.right - s.left, s.height = s.bottom - s.top, s.x = s.left, s.y = s.top, s;
}
function N(e) {
return e.split("-")[0];
}
function te(e) {
return e.split("-")[1];
}
function Se(e) {
return ["top", "bottom"].indexOf(e) >= 0 ? "x" : "y";
}
function st(e) {
var t = e.reference, r = e.element, a = e.placement, o = a ? N(a) : null, n = a ? te(a) : null, u = t.x + t.width / 2 - r.width / 2, s = t.y + t.height / 2 - r.height / 2, i;
switch (o) {
case T:
i = {
x: u,
y: t.y - r.height
};
break;
case M:
i = {
x: u,
y: t.y + t.height
};
break;
case W:
i = {
x: t.x + t.width,
y: s
};
break;
case j:
i = {
x: t.x - r.width,
y: s
};
break;
default:
i = {
x: t.x,
y: t.y
};
}
var l = o ? Se(o) : null;
if (l != null) {
var f = l === "y" ? "height" : "width";
switch (n) {
case ee:
i[l] = i[l] - (t[f] / 2 - r[f] / 2);
break;
case se:
i[l] = i[l] + (t[f] / 2 - r[f] / 2);
break;
}
}
return i;
}
function ft() {
return {
top: 0,
right: 0,
bottom: 0,
left: 0
};
}
function ut(e) {
return Object.assign({}, ft(), e);
}
function lt(e, t) {
return t.reduce(function(r, a) {
return r[a] = e, r;
}, {});
}
function $e(e, t) {
t === void 0 && (t = {});
var r = t, a = r.placement, o = a === void 0 ? e.placement : a, n = r.strategy, u = n === void 0 ? e.strategy : n, s = r.boundary, i = s === void 0 ? Rt : s, l = r.rootBoundary, f = l === void 0 ? ot : l, m = r.elementContext, h = m === void 0 ? oe : m, p = r.altBoundary, O = p === void 0 ? !1 : p, d = r.padding, g = d === void 0 ? 0 : d, x = ut(typeof g != "number" ? g : lt(g, ue)), k = h === oe ? Lt : oe, A = e.rects.popper, v = e.elements[O ? k : h], w = er(J(v) ? v : v.contextElement || X(e.elements.popper), i, f, u), b = Z(e.elements.reference), P = st({
reference: b,
element: A,
strategy: "absolute",
placement: o
}), c = Pe(Object.assign({}, A, P)), y = h === oe ? c : b, E = {
top: w.top - y.top + x.top,
bottom: y.bottom - w.bottom + x.bottom,
left: w.left - y.left + x.left,
right: y.right - w.right + x.right
}, D = e.modifiersData.offset;
if (h === oe && D) {
var R = D[o];
Object.keys(E).forEach(function(C) {
var z = [W, M].indexOf(C) >= 0 ? 1 : -1, U = [T, M].indexOf(C) >= 0 ? "y" : "x";
E[C] += R[U] * z;
});
}
return E;
}
var Qe = {
placement: "bottom",
modifiers: [],
strategy: "absolute"
};
function Ze() {
for (var e = arguments.length, t = new Array(e), r = 0; r < e; r++)
t[r] = arguments[r];
return !t.some(function(a) {
return !(a && typeof a.getBoundingClientRect == "function");
});
}
function tr(e) {
e === void 0 && (e = {});
var t = e, r = t.defaultModifiers, a = r === void 0 ? [] : r, o = t.defaultOptions, n = o === void 0 ? Qe : o;
return function(s, i, l) {
l === void 0 && (l = n);
var f = {
placement: "bottom",
orderedModifiers: [],
options: Object.assign({}, Qe, n),
modifiersData: {},
elements: {
reference: s,
popper: i
},
attributes: {},
styles: {}
}, m = [], h = !1, p = {
state: f,
setOptions: function(x) {
var k = typeof x == "function" ? x(f.options) : x;
d(), f.options = Object.assign({}, n, f.options, k), f.scrollParents = {
reference: J(s) ? ne(s) : s.contextElement ? ne(s.contextElement) : [],
popper: ne(i)
};
var A = It(Gt([].concat(a, f.options.modifiers)));
return f.orderedModifiers = A.filter(function(v) {
return v.enabled;
}), O(), p.update();
},
// Sync update – it will always be executed, even if not necessary. This
// is useful for low frequency updates where sync behavior simplifies the
// logic.
// For high frequency updates (e.g. `resize` and `scroll` events), always
// prefer the async Popper#update method
forceUpdate: function() {
if (!h) {
var x = f.elements, k = x.reference, A = x.popper;
if (Ze(k, A)) {
f.rects = {
reference: jt(k, fe(A), f.options.strategy === "fixed"),
popper: Te(A)
}, f.reset = !1, f.placement = f.options.placement, f.orderedModifiers.forEach(function(E) {
return f.modifiersData[E.name] = Object.assign({}, E.data);
});
for (var v = 0; v < f.orderedModifiers.length; v++) {
if (f.reset === !0) {
f.reset = !1, v = -1;
continue;
}
var w = f.orderedModifiers[v], b = w.fn, P = w.options, c = P === void 0 ? {} : P, y = w.name;
typeof b == "function" && (f = b({
state: f,
options: c,
name: y,
instance: p
}) || f);
}
}
}
},
// Async and optimistically optimized update – it will not be executed if
// not necessary (debounced to run at most once-per-tick)
update: _t(function() {
return new Promise(function(g) {
p.forceUpdate(), g(f);
});
}),
destroy: function() {
d(), h = !0;
}
};
if (!Ze(s, i))
return p;
p.setOptions(l).then(function(g) {
!h && l.onFirstUpdate && l.onFirstUpdate(g);
});
function O() {
f.orderedModifiers.forEach(function(g) {
var x = g.name, k = g.options, A = k === void 0 ? {} : k, v = g.effect;
if (typeof v == "function") {
var w = v({
state: f,
name: x,
instance: p,
options: A
}), b = function() {
};
m.push(w || b);
}
});
}
function d() {
m.forEach(function(g) {
return g();
}), m = [];
}
return p;
};
}
var me = {
passive: !0
};
function rr(e) {
var t = e.state, r = e.instance, a = e.options, o = a.scroll, n = o === void 0 ? !0 : o, u = a.resize, s = u === void 0 ? !0 : u, i = S(t.elements.popper), l = [].concat(t.scrollParents.reference, t.scrollParents.popper);
return n && l.forEach(function(f) {
f.addEventListener("scroll", r.update, me);
}), s && i.addEventListener("resize", r.update, me), function() {
n && l.forEach(function(f) {
f.removeEventListener("scroll", r.update, me);
}), s && i.removeEventListener("resize", r.update, me);
};
}
const ar = {
name: "eventListeners",
enabled: !0,
phase: "write",
fn: function() {
},
effect: rr,
data: {}
};
function or(e) {
var t = e.state, r = e.name;
t.modifiersData[r] = st({
reference: t.rects.reference,
element: t.rects.popper,
strategy: "absolute",
placement: t.placement
});
}
const nr = {
name: "popperOffsets",
enabled: !0,
phase: "read",
fn: or,
data: {}
};
var ir = {
top: "auto",
right: "auto",
bottom: "auto",
left: "auto"
};
function sr(e, t) {
var r = e.x, a = e.y, o = t.devicePixelRatio || 1;
return {
x: Q(r * o) / o || 0,
y: Q(a * o) / o || 0
};
}
function et(e) {
var t, r = e.popper, a = e.popperRect, o = e.placement, n = e.variation, u = e.offsets, s = e.position, i = e.gpuAcceleration, l = e.adaptive, f = e.roundOffsets, m = e.isFixed, h = u.x, p = h === void 0 ? 0 : h, O = u.y, d = O === void 0 ? 0 : O, g = typeof f == "function" ? f({
x: p,
y: d
}) : {
x: p,
y: d
};
p = g.x, d = g.y;
var x = u.hasOwnProperty("x"), k = u.hasOwnProperty("y"), A = j, v = T, w = window;
if (l) {
var b = fe(r), P = "clientHeight", c = "clientWidth";
if (b === S(r) && (b = X(r), H(b).position !== "static" && s === "absolute" && (P = "scrollHeight", c = "scrollWidth")), b = b, o === T || (o === j || o === W) && n === se) {
v = M;
var y = m && b === w && w.visualViewport ? w.visualViewport.height : (
// $FlowFixMe[prop-missing]
b[P]
);
d -= y - a.height, d *= i ? 1 : -1;
}
if (o === j || (o === T || o === M) && n === se) {
A = W;
var E = m && b === w && w.visualViewport ? w.visualViewport.width : (
// $FlowFixMe[prop-missing]
b[c]
);
p -= E - a.width, p *= i ? 1 : -1;
}
}
var D = Object.assign({
position: s
}, l && ir), R = f === !0 ? sr({
x: p,
y: d
}, S(r)) : {
x: p,
y: d
};
if (p = R.x, d = R.y, i) {
var C;
return Object.assign({}, D, (C = {}, C[v] = k ? "0" : "", C[A] = x ? "0" : "", C.transform = (w.devicePixelRatio || 1) <= 1 ? "translate(" + p + "px, " + d + "px)" : "translate3d(" + p + "px, " + d + "px, 0)", C));
}
return Object.assign({}, D, (t = {}, t[v] = k ? d + "px" : "", t[A] = x ? p + "px" : "", t.transform = "", t));
}
function fr(e) {
var t = e.state, r = e.options, a = r.gpuAcceleration, o = a === void 0 ? !0 : a, n = r.adaptive, u = n === void 0 ? !0 : n, s = r.roundOffsets, i = s === void 0 ? !0 : s, l = {
placement: N(t.placement),
variation: te(t.placement),
popper: t.elements.popper,
popperRect: t.rects.popper,
gpuAcceleration: o,
isFixed: t.options.strategy === "fixed"
};
t.modifiersData.popperOffsets != null && (t.styles.popper = Object.assign({}, t.styles.popper, et(Object.assign({}, l, {
offsets: t.modifiersData.popperOffsets,
position: t.options.strategy,
adaptive: u,
roundOffsets: i
})))), t.modifiersData.arrow != null && (t.styles.arrow = Object.assign({}, t.styles.arrow, et(Object.assign({}, l, {
offsets: t.modifiersData.arrow,
position: "absolute",
adaptive: !1,
roundOffsets: i
})))), t.attributes.popper = Object.assign({}, t.attributes.popper, {
"data-popper-placement": t.placement
});
}
const ur = {
name: "computeStyles",
enabled: !0,
phase: "beforeWrite",
fn: fr,
data: {}
};
function lr(e) {
var t = e.state;
Object.keys(t.elements).forEach(function(r) {
var a = t.styles[r] || {}, o = t.attributes[r] || {}, n = t.elements[r];
!$(n) || !V(n) || (Object.assign(n.style, a), Object.keys(o).forEach(function(u) {
var s = o[u];
s === !1 ? n.removeAttribute(u) : n.setAttribute(u, s === !0 ? "" : s);
}));
});
}
function cr(e) {
var t = e.state, r = {
popper: {
position: t.options.strategy,
left: "0",
top: "0",
margin: "0"
},
arrow: {
position: "absolute"
},
reference: {}
};
return Object.assign(t.elements.popper.style, r.popper), t.styles = r, t.elements.arrow && Object.assign(t.elements.arrow.style, r.arrow), function() {
Object.keys(t.elements).forEach(function(a) {
var o = t.elements[a], n = t.attributes[a] || {}, u = Object.keys(t.styles.hasOwnProperty(a) ? t.styles[a] : r[a]), s = u.reduce(function(i, l) {
return i[l] = "", i;
}, {});
!$(o) || !V(o) || (Object.assign(o.style, s), Object.keys(n).forEach(function(i) {
o.removeAttribute(i);
}));
});
};
}
const pr = {
name: "applyStyles",
enabled: !0,
phase: "write",
fn: lr,
effect: cr,
requires: ["computeStyles"]
};
var vr = [ar, nr, ur, pr], dr = /* @__PURE__ */ tr({
defaultModifiers: vr
});
function mr(e) {
return e === "x" ? "y" : "x";
}
function ie(e, t, r) {
return G(e, ge(t, r));
}
function hr(e, t, r) {
var a = ie(e, t, r);
return a > r ? r : a;
}
function gr(e) {
var t = e.state, r = e.options, a = e.name, o = r.mainAxis, n = o === void 0 ? !0 : o, u = r.altAxis, s = u === void 0 ? !1 : u, i = r.boundary, l = r.rootBoundary, f = r.altBoundary, m = r.padding, h = r.tether, p = h === void 0 ? !0 : h, O = r.tetherOffset, d = O === void 0 ? 0 : O, g = $e(t, {
boundary: i,
rootBoundary: l,
padding: m,
altBoundary: f
}), x = N(t.placement), k = te(t.placement), A = !k, v = Se(x), w = mr(v), b = t.modifiersData.popperOffsets, P = t.rects.reference, c = t.rects.popper, y = typeof d == "function" ? d(Object.assign({}, t.rects, {
placement: t.placement
})) : d, E = typeof y == "number" ? {
mainAxis: y,
altAxis: y
} : Object.assign({
mainAxis: 0,
altAxis: 0
}, y), D = t.modifiersData.offset ? t.modifiersData.offset[t.placement] : null, R = {
x: 0,
y: 0
};
if (b) {
if (n) {
var C, z = v === "y" ? T : j, U = v === "y" ? M : W, B = v === "y" ? "height" : "width", L = b[v], le = L + g[z], Y = L - g[U], ce = p ? -c[B] / 2 : 0, be = k === ee ? P[B] : c[B], re = k === ee ? -c[B] : -P[B], pe = t.elements.arrow, K = p && pe ? Te(pe) : {
width: 0,
height: 0
}, F = t.modifiersData["arrow#persistent"] ? t.modifiersData["arrow#persistent"].padding : ft(), ae = F[z], ve = F[U], I = ie(0, P[B], K[B]), we = A ? P[B] / 2 - ce - I - ae - E.mainAxis : be - I - ae - E.mainAxis, ct = A ? -P[B] / 2 + ce + I + ve + E.mainAxis : re + I + ve + E.mainAxis, Oe = t.elements.arrow && fe(t.elements.arrow), pt = Oe ? v === "y" ? Oe.clientTop || 0 : Oe.clientLeft || 0 : 0, Re = (C = D?.[v]) != null ? C : 0, vt = L + we - Re - pt, dt = L + ct - Re, Le = ie(p ? ge(le, vt) : le, L, p ? G(Y, dt) : Y);
b[v] = Le, R[v] = Le - L;
}
if (s) {
var Me, mt = v === "x" ? T : j, ht = v === "x" ? M : W, _ = b[w], de = w === "y" ? "height" : "width", We = _ + g[mt], Ne = _ - g[ht], xe = [T, j].indexOf(x) !== -1, Ve = (Me = D?.[w]) != null ? Me : 0, He = xe ? We : _ - P[de] - c[de] - Ve + E.altAxis, Fe = xe ? _ + P[de] + c[de] - Ve - E.altAxis : Ne, qe = p && xe ? hr(He, _, Fe) : ie(p ? He : We, _, p ? Fe : Ne);
b[w] = qe, R[w] = qe - _;
}
t.modifiersData[a] = R;
}
}
const yr = {
name: "preventOverflow",
enabled: !0,
phase: "main",
fn: gr,
requiresIfExists: ["offset"]
};
var br = {
left: "right",
right: "left",
bottom: "top",
top: "bottom"
};
function he(e) {
return e.replace(/left|right|bottom|top/g, function(t) {
return br[t];
});
}
var wr = {
start: "end",
end: "start"
};
function tt(e) {
return e.replace(/start|end/g, function(t) {
return wr[t];
});
}
function Or(e, t) {
t === void 0 && (t = {});
var r = t, a = r.placement, o = r.boundary, n = r.rootBoundary, u = r.padding, s = r.flipVariations, i = r.allowedAutoPlacements, l = i === void 0 ? nt : i, f = te(a), m = f ? s ? Je : Je.filter(function(O) {
return te(O) === f;
}) : ue, h = m.filter(function(O) {
return l.indexOf(O) >= 0;
});
h.length === 0 && (h = m);
var p = h.reduce(function(O, d) {
return O[d] = $e(e, {
placement: d,
boundary: o,
rootBoundary: n,
padding: u
})[N(d)], O;
}, {});
return Object.keys(p).sort(function(O, d) {
return p[O] - p[d];
});
}
function xr(e) {
if (N(e) === je)
return [];
var t = he(e);
return [tt(e), t, tt(t)];
}
function Er(e) {
var t = e.state, r = e.options, a = e.name;
if (!t.modifiersData[a]._skip) {
for (var o = r.mainAxis, n = o === void 0 ? !0 : o, u = r.altAxis, s = u === void 0 ? !0 : u, i = r.fallbackPlacements, l = r.padding, f = r.boundary, m = r.rootBoundary, h = r.altBoundary, p = r.flipVariations, O = p === void 0 ? !0 : p, d = r.allowedAutoPlacements, g = t.options.placement, x = N(g), k = x === g, A = i || (k || !O ? [he(g)] : xr(g)), v = [g].concat(A).reduce(function(K, F) {
return K.concat(N(F) === je ? Or(t, {
placement: F,
boundary: f,
rootBoundary: m,
padding: l,
flipVariations: O,
allowedAutoPlacements: d
}) : F);
}, []), w = t.rects.reference, b = t.rects.popper, P = /* @__PURE__ */ new Map(), c = !0, y = v[0], E = 0; E < v.length; E++) {
var D = v[E], R = N(D), C = te(D) === ee, z = [T, M].indexOf(R) >= 0, U = z ? "width" : "height", B = $e(t, {
placement: D,
boundary: f,
rootBoundary: m,
altBoundary: h,
padding: l
}), L = z ? C ? W : j : C ? M : T;
w[U] > b[U] && (L = he(L));
var le = he(L), Y = [];
if (n && Y.push(B[R] <= 0), s && Y.push(B[L] <= 0, B[le] <= 0), Y.every(function(K) {
return K;
})) {
y = D, c = !1;
break;
}
P.set(D, Y);
}
if (c)
for (var ce = O ? 3 : 1, be = function(F) {
var ae = v.find(function(ve) {
var I = P.get(ve);
if (I)
return I.slice(0, F).every(function(we) {
return we;
});
});
if (ae)
return y = ae, "break";
}, re = ce; re > 0; re--) {
var pe = be(re);
if (pe === "break")
break;
}
t.placement !== y && (t.modifiersData[a]._skip = !0, t.placement = y, t.reset = !0);
}
}
const Ar = {
name: "flip",
enabled: !0,
phase: "main",
fn: Er,
requiresIfExists: ["offset"],
data: {
_skip: !1
}
};
function Pr(e, t, r) {
var a = N(e), o = [j, T].indexOf(a) >= 0 ? -1 : 1, n = typeof r == "function" ? r(Object.assign({}, t, {
placement: e
})) : r, u = n[0], s = n[1];
return u = u || 0, s = (s || 0) * o, [j, W].indexOf(a) >= 0 ? {
x: s,
y: u
} : {
x: u,
y: s
};
}
function kr(e) {
var t = e.state, r = e.options, a = e.name, o = r.offset, n = o === void 0 ? [0, 0] : o, u = nt.reduce(function(f, m) {
return f[m] = Pr(m, t.rects, n), f;
}, {}), s = u[t.placement], i = s.x, l = s.y;
t.modifiersData.popperOffsets != null && (t.modifiersData.popperOffsets.x += i, t.modifiersData.popperOffsets.y += l), t.modifiersData[a] = u;
}
const Dr = {
name: "offset",
enabled: !0,
phase: "main",
requires: ["popperOffsets"],
fn: kr
};
var Cr = function(t, r) {
return t = typeof t == "function" ? t(Object.assign({}, r.rects, {
placement: r.placement
})) : t, ut(typeof t != "number" ? t : lt(t, ue));
};
function Br(e) {
var t, r = e.state, a = e.name, o = e.options, n = r.elements.arrow, u = r.modifiersData.popperOffsets, s = N(r.placement), i = Se(s), l = [j, W].indexOf(s) >= 0, f = l ? "height" : "width";
if (!(!n || !u)) {
var m = Cr(o.padding, r), h = Te(n), p = i === "y" ? T : j, O = i === "y" ? M : W, d = r.rects.reference[f] + r.rects.reference[i] - u[i] - r.rects.popper[f], g = u[i] - r.rects.reference[i], x = fe(n), k = x ? i === "y" ? x.clientHeight || 0 : x.clientWidth || 0 : 0, A = d / 2 - g / 2, v = m[p], w = k - h[f] - m[O], b = k / 2 - h[f] / 2 + A, P = ie(v, b, w), c = i;
r.modifiersData[a] = (t = {}, t[c] = P, t.centerOffset = P - b, t);
}
}
function Tr(e) {
var t = e.state, r = e.options, a = r.element, o = a === void 0 ? "[data-popper-arrow]" : a;
o != null && (typeof o == "string" && (o = t.elements.popper.querySelector(o), !o) || it(t.elements.popper, o) && (t.elements.arrow = o));
}
const jr = {
name: "arrow",
enabled: !0,
phase: "main",
fn: Br,
effect: Tr,
requires: ["popperOffsets"],
requiresIfExists: ["preventOverflow"]
}, Sr = {
key: 0,
class: "popper__arrow",
"data-popper-arrow": ""
}, Rr = /* @__PURE__ */ gt({
__name: "Popper",
props: {
trigger: { default: "hover" },
placement: { default: "bottom" },
delayOnMouseOver: { default: 10 },
delayOnMouseOut: { default: 10 },
disabled: { type: Boolean, default: !1 },
content: {},
transition: { default: "" },
enterActiveClass: {},
leaveActiveClass: {},
forceShow: { type: Boolean, default: !1 },
appendToBody: { type: Boolean, default: !1 },
visibleArrow: { type: Boolean, default: !0 },
arrowPadding: { default: 0 },
enableFlip: { type: Boolean, default: !0 },
offsetSkidding: { default: 0 },
offsetDistance: { default: 8 },
stopPropagation: { type: Boolean, default: !1 },
preventDefault: { type: Boolean, default: !1 },
strategy: { default: "absolute" },
contentClass: {}
},
emits: ["created", "documentClick", "show", "hide"],
setup(e, { emit: t }) {
const r = e, a = q(), o = q(), n = q(null), u = q(), s = q(null), i = q(!1), l = q(!1), f = q({
placement: r.placement,
modifiers: [
yr,
Ar,
{
name: "flip",
enabled: r.enableFlip
},
jr,
{
name: "arrow",
options: {
padding: r.arrowPadding
}
},
Dr,
{
name: "offset",
options: {
offset: [r.offsetSkidding, r.offsetDistance]
}
}
],
strategy: r.strategy
});
function m(c, y, E) {
c && y && E && (typeof document.addEventListener == "function" ? c.addEventListener(y, E, !1) : c.attachEvent("on" + y, E));
}
function h(c, y, E) {
c && y && (typeof document.removeEventListener == "function" ? c.removeEventListener(y, E, !1) : c.detachEvent("on" + y, E));
}
function p(c) {
r.stopPropagation && c.stopPropagation(), r.preventDefault && c.preventDefault(), r.forceShow || (i.value = !i.value);
}
function O() {
i.value = !0;
}
function d() {
i.value = !1;
}
function g() {
i.value || (n.value && (n.value.destroy(), n.value = null), l.value && (l.value = !1, document.body.removeChild(o.value)));
}
function x() {
n.value ? n.value.update() : k();
}
function k() {
_e(() => {
r.appendToBody && !l.value && (l.value = !0, document.body.appendChild(o.value)), n.value && n.value.destroy && n.value.destroy(), f.value.onFirstUpdate = () => {
t("created"), _e(x);
}, n.value = dr(
a.value,
o.value,
f.value
);
});
}
function A() {
clearTimeout(u.value), u.value = setTimeout(O, r.delayOnMouseOver);
}
function v() {
clearTimeout(u.value), u.value = setTimeout(d, r.delayOnMouseOut);
}
function w(c, y) {
return typeof c.contains == "function" ? c.contains(y) : !1;
}
function b(c) {
!s.value || !a.value || w(s.value, c.target) || w(a.value, c.target) || !o.value || w(o.value, c.target) || (t("documentClick"), !r.forceShow && d());
}
function P() {
h(a.value, "click", p), h(a.value, "mouseup", d), h(a.value, "mousedown", O), h(a.value, "focus", O), h(a.value, "blur", d), h(a.value, "mouseout", v), h(a.value, "mouseover", A), h(document, "click", b), d(), g();
}
return yt(() => {
switch (r.trigger) {
case "clickToOpen":
m(a.value, "click", O), m(document, "click", b), m(document, "touchstart", b);
break;
case "clickToToggle":
m(a.value, "click", p), m(document, "click", b), m(document, "touchstart", b);
break;
case "hover":
m(a.value, "mouseover", A), m(o.value, "mouseover", A), m(a.value, "mouseout", v), m(o.value, "mouseout", v);
break;
}
}), bt(() => {
P();
}), Ee(i, (c) => {
c ? (t("show"), n.value && n.value.setOptions((y) => ({
...y,
modifiers: [
...y.modifiers || [],
{ name: "eventListeners", enabled: !0 }
]
})), x()) : (n.value && n.value.setOptions((y) => ({
...y,
modifiers: [
...y.modifiers || [],
{ name: "eventListeners", enabled: !1 }
]
})), t("hide"));
}), Ee(
() => r.forceShow,
(c) => {
c ? O() : d();
},
{ immediate: !0 }
), Ee(
() => r.disabled,
(c) => {
c && d();
}
), (c, y) => (Xe(), ze("div", {
ref_key: "popperNode",
ref: s,
class: Ue(["popper", { "popper--active": i.value }])
}, [
Ye("div", {
ref_key: "referenceElm",
ref: a,
class: "popper__reference",
"aria-describedby": "tooltip"
}, [
Ie(c.$slots, "reference")
], 512),
wt(Ot, {
name: c.transition,
"enter-active-class": c.enterActiveClass,
"leave-active-class": c.leaveActiveClass,
onAfterLeave: g
}, {
default: xt(() => [
Et(Ye("div", {
ref_key: "popperElm",
ref: o,
class: Ue(["popper__content", c.contentClass]),
role: "tooltip"
}, [
Ie(c.$slots, "default", {}, () => [
At(Pt(c.content), 1)
]),
c.visibleArrow ? (Xe(), ze("div", Sr)) : kt("", !0)
], 2), [
[Dt, !c.disabled && i.value]
])
]),
_: 3
}, 8, ["name", "enter-active-class", "leave-active-class"])
], 2));
}
});
export {
Rr as Popper
};