@konstructio/ui
Version:
A set of reusable and customizable React components built for konstruct.io
1,691 lines • 50.2 kB
JavaScript
import { n as ve } from "./dist-C4El7dZ5.js";
import { a as Q, i as je, r as Xt, s as nt, t as ae } from "./dist-D_9sBzad.js";
import { t as Gt } from "./dist-CQfmhKEs.js";
import { t as Ut } from "./dist-D6dB-_Oy.js";
import { r as qt, t as Kt } from "./dist-AZfrfAUz.js";
import { t as rt } from "./dist-DF7Yi2EK.js";
import { t as Zt } from "./dist-X40eHC8j2.js";
import * as h from "react";
import { useLayoutEffect as Jt } from "react";
import * as Qt from "react-dom";
import { Fragment as en, jsx as P, jsxs as tn } from "react/jsx-runtime";
var nn = [
"top",
"right",
"bottom",
"left"
], q = Math.min, F = Math.max, me = Math.round, de = Math.floor, j = (e) => ({
x: e,
y: e
}), rn = {
left: "right",
right: "left",
bottom: "top",
top: "bottom"
};
function Ee(e, t, n) {
return F(e, q(t, n));
}
function X(e, t) {
return typeof e == "function" ? e(t) : e;
}
function G(e) {
return e.split("-")[0];
}
function re(e) {
return e.split("-")[1];
}
function _e(e) {
return e === "x" ? "y" : "x";
}
function ke(e) {
return e === "y" ? "height" : "width";
}
function z(e) {
const t = e[0];
return t === "t" || t === "b" ? "y" : "x";
}
function Ne(e) {
return _e(z(e));
}
function on(e, t, n) {
n === void 0 && (n = !1);
const r = re(e), o = Ne(e), i = ke(o);
let s = o === "x" ? r === (n ? "end" : "start") ? "right" : "left" : r === "start" ? "bottom" : "top";
return t.reference[i] > t.floating[i] && (s = he(s)), [s, he(s)];
}
function sn(e) {
const t = he(e);
return [
Se(e),
t,
Se(t)
];
}
function Se(e) {
return e.includes("start") ? e.replace("start", "end") : e.replace("end", "start");
}
var Ye = ["left", "right"], Xe = ["right", "left"], cn = ["top", "bottom"], an = ["bottom", "top"];
function ln(e, t, n) {
switch (e) {
case "top":
case "bottom":
return n ? t ? Xe : Ye : t ? Ye : Xe;
case "left":
case "right":
return t ? cn : an;
default:
return [];
}
}
function fn(e, t, n, r) {
const o = re(e);
let i = ln(G(e), n === "start", r);
return o && (i = i.map((s) => s + "-" + o), t && (i = i.concat(i.map(Se)))), i;
}
function he(e) {
const t = G(e);
return rn[t] + e.slice(t.length);
}
function un(e) {
return {
top: 0,
right: 0,
bottom: 0,
left: 0,
...e
};
}
function ot(e) {
return typeof e != "number" ? un(e) : {
top: e,
right: e,
bottom: e,
left: e
};
}
function ge(e) {
const { x: t, y: n, width: r, height: o } = e;
return {
width: r,
height: o,
top: n,
left: t,
right: t + r,
bottom: n + o,
x: t,
y: n
};
}
function Ge(e, t, n) {
let { reference: r, floating: o } = e;
const i = z(t), s = Ne(t), a = ke(s), c = G(t), f = i === "y", l = r.x + r.width / 2 - o.width / 2, u = r.y + r.height / 2 - o.height / 2, p = r[a] / 2 - o[a] / 2;
let d;
switch (c) {
case "top":
d = {
x: l,
y: r.y - o.height
};
break;
case "bottom":
d = {
x: l,
y: r.y + r.height
};
break;
case "right":
d = {
x: r.x + r.width,
y: u
};
break;
case "left":
d = {
x: r.x - o.width,
y: u
};
break;
default:
d = {
x: r.x,
y: r.y
};
}
switch (re(t)) {
case "start":
d[s] -= p * (n && f ? -1 : 1);
break;
case "end":
d[s] += p * (n && f ? -1 : 1);
break;
}
return d;
}
async function dn(e, t) {
var n;
t === void 0 && (t = {});
const { x: r, y: o, platform: i, rects: s, elements: a, strategy: c } = e, { boundary: f = "clippingAncestors", rootBoundary: l = "viewport", elementContext: u = "floating", altBoundary: p = !1, padding: d = 0 } = X(t, e), m = ot(d), g = a[p ? u === "floating" ? "reference" : "floating" : u], w = ge(await i.getClippingRect({
element: (n = await (i.isElement == null ? void 0 : i.isElement(g))) == null || n ? g : g.contextElement || await (i.getDocumentElement == null ? void 0 : i.getDocumentElement(a.floating)),
boundary: f,
rootBoundary: l,
strategy: c
})), v = u === "floating" ? {
x: r,
y: o,
width: s.floating.width,
height: s.floating.height
} : s.reference, y = await (i.getOffsetParent == null ? void 0 : i.getOffsetParent(a.floating)), b = await (i.isElement == null ? void 0 : i.isElement(y)) ? await (i.getScale == null ? void 0 : i.getScale(y)) || {
x: 1,
y: 1
} : {
x: 1,
y: 1
}, x = ge(i.convertOffsetParentRelativeRectToViewportRelativeRect ? await i.convertOffsetParentRelativeRectToViewportRelativeRect({
elements: a,
rect: v,
offsetParent: y,
strategy: c
}) : v);
return {
top: (w.top - x.top + m.top) / b.y,
bottom: (x.bottom - w.bottom + m.bottom) / b.y,
left: (w.left - x.left + m.left) / b.x,
right: (x.right - w.right + m.right) / b.x
};
}
var pn = 50, mn = async (e, t, n) => {
const { placement: r = "bottom", strategy: o = "absolute", middleware: i = [], platform: s } = n, a = s.detectOverflow ? s : {
...s,
detectOverflow: dn
}, c = await (s.isRTL == null ? void 0 : s.isRTL(t));
let f = await s.getElementRects({
reference: e,
floating: t,
strategy: o
}), { x: l, y: u } = Ge(f, r, c), p = r, d = 0;
const m = {};
for (let g = 0; g < i.length; g++) {
const w = i[g];
if (!w) continue;
const { name: v, fn: y } = w, { x: b, y: x, data: C, reset: R } = await y({
x: l,
y: u,
initialPlacement: r,
placement: p,
strategy: o,
middlewareData: m,
rects: f,
platform: a,
elements: {
reference: e,
floating: t
}
});
l = b ?? l, u = x ?? u, m[v] = {
...m[v],
...C
}, R && d < pn && (d++, typeof R == "object" && (R.placement && (p = R.placement), R.rects && (f = R.rects === !0 ? await s.getElementRects({
reference: e,
floating: t,
strategy: o
}) : R.rects), { x: l, y: u } = Ge(f, p, c)), g = -1);
}
return {
x: l,
y: u,
placement: p,
strategy: o,
middlewareData: m
};
}, hn = (e) => ({
name: "arrow",
options: e,
async fn(t) {
const { x: n, y: r, placement: o, rects: i, platform: s, elements: a, middlewareData: c } = t, { element: f, padding: l = 0 } = X(e, t) || {};
if (f == null) return {};
const u = ot(l), p = {
x: n,
y: r
}, d = Ne(o), m = ke(d), g = await s.getDimensions(f), w = d === "y", v = w ? "top" : "left", y = w ? "bottom" : "right", b = w ? "clientHeight" : "clientWidth", x = i.reference[m] + i.reference[d] - p[d] - i.floating[m], C = p[d] - i.reference[d], R = await (s.getOffsetParent == null ? void 0 : s.getOffsetParent(f));
let T = R ? R[b] : 0;
(!T || !await (s.isElement == null ? void 0 : s.isElement(R))) && (T = a.floating[b] || i.floating[m]);
const M = x / 2 - C / 2, $ = T / 2 - g[m] / 2 - 1, D = q(u[v], $), k = q(u[y], $), N = D, S = T - g[m] - k, O = T / 2 - g[m] / 2 + M, H = Ee(N, O, S), L = !c.arrow && re(o) != null && O !== H && i.reference[m] / 2 - (O < N ? D : k) - g[m] / 2 < 0, E = L ? O < N ? O - N : O - S : 0;
return {
[d]: p[d] + E,
data: {
[d]: H,
centerOffset: O - H - E,
...L && { alignmentOffset: E }
},
reset: L
};
}
}), gn = function(e) {
return e === void 0 && (e = {}), {
name: "flip",
options: e,
async fn(t) {
var n, r;
const { placement: o, middlewareData: i, rects: s, initialPlacement: a, platform: c, elements: f } = t, { mainAxis: l = !0, crossAxis: u = !0, fallbackPlacements: p, fallbackStrategy: d = "bestFit", fallbackAxisSideDirection: m = "none", flipAlignment: g = !0, ...w } = X(e, t);
if ((n = i.arrow) != null && n.alignmentOffset) return {};
const v = G(o), y = z(a), b = G(a) === a, x = await (c.isRTL == null ? void 0 : c.isRTL(f.floating)), C = p || (b || !g ? [he(a)] : sn(a)), R = m !== "none";
!p && R && C.push(...fn(a, g, m, x));
const T = [a, ...C], M = await c.detectOverflow(t, w), $ = [];
let D = ((r = i.flip) == null ? void 0 : r.overflows) || [];
if (l && $.push(M[v]), u) {
const O = on(o, s, x);
$.push(M[O[0]], M[O[1]]);
}
if (D = [...D, {
placement: o,
overflows: $
}], !$.every((O) => O <= 0)) {
var k, N;
const O = (((k = i.flip) == null ? void 0 : k.index) || 0) + 1, H = T[O];
if (H && (!(u === "alignment" && y !== z(H)) || D.every((E) => z(E.placement) === y ? E.overflows[0] > 0 : !0)))
return {
data: {
index: O,
overflows: D
},
reset: { placement: H }
};
let L = (N = D.filter((E) => E.overflows[0] <= 0).sort((E, A) => E.overflows[1] - A.overflows[1])[0]) == null ? void 0 : N.placement;
if (!L) switch (d) {
case "bestFit": {
var S;
const E = (S = D.filter((A) => {
if (R) {
const _ = z(A.placement);
return _ === y || _ === "y";
}
return !0;
}).map((A) => [A.placement, A.overflows.filter((_) => _ > 0).reduce((_, V) => _ + V, 0)]).sort((A, _) => A[1] - _[1])[0]) == null ? void 0 : S[0];
E && (L = E);
break;
}
case "initialPlacement":
L = a;
break;
}
if (o !== L) return { reset: { placement: L } };
}
return {};
}
};
};
function Ue(e, t) {
return {
top: e.top - t.height,
right: e.right - t.width,
bottom: e.bottom - t.height,
left: e.left - t.width
};
}
function qe(e) {
return nn.some((t) => e[t] >= 0);
}
var wn = function(e) {
return e === void 0 && (e = {}), {
name: "hide",
options: e,
async fn(t) {
const { rects: n, platform: r } = t, { strategy: o = "referenceHidden", ...i } = X(e, t);
switch (o) {
case "referenceHidden": {
const s = Ue(await r.detectOverflow(t, {
...i,
elementContext: "reference"
}), n.reference);
return { data: {
referenceHiddenOffsets: s,
referenceHidden: qe(s)
} };
}
case "escaped": {
const s = Ue(await r.detectOverflow(t, {
...i,
altBoundary: !0
}), n.floating);
return { data: {
escapedOffsets: s,
escaped: qe(s)
} };
}
default:
return {};
}
}
};
}, it = /* @__PURE__ */ new Set(["left", "top"]);
async function vn(e, t) {
const { placement: n, platform: r, elements: o } = e, i = await (r.isRTL == null ? void 0 : r.isRTL(o.floating)), s = G(n), a = re(n), c = z(n) === "y", f = it.has(s) ? -1 : 1, l = i && c ? -1 : 1, u = X(t, e);
let { mainAxis: p, crossAxis: d, alignmentAxis: m } = typeof u == "number" ? {
mainAxis: u,
crossAxis: 0,
alignmentAxis: null
} : {
mainAxis: u.mainAxis || 0,
crossAxis: u.crossAxis || 0,
alignmentAxis: u.alignmentAxis
};
return a && typeof m == "number" && (d = a === "end" ? m * -1 : m), c ? {
x: d * l,
y: p * f
} : {
x: p * f,
y: d * l
};
}
var yn = function(e) {
return e === void 0 && (e = 0), {
name: "offset",
options: e,
async fn(t) {
var n, r;
const { x: o, y: i, placement: s, middlewareData: a } = t, c = await vn(t, e);
return s === ((n = a.offset) == null ? void 0 : n.placement) && (r = a.arrow) != null && r.alignmentOffset ? {} : {
x: o + c.x,
y: i + c.y,
data: {
...c,
placement: s
}
};
}
};
}, xn = function(e) {
return e === void 0 && (e = {}), {
name: "shift",
options: e,
async fn(t) {
const { x: n, y: r, placement: o, platform: i } = t, { mainAxis: s = !0, crossAxis: a = !1, limiter: c = { fn: (v) => {
let { x: y, y: b } = v;
return {
x: y,
y: b
};
} }, ...f } = X(e, t), l = {
x: n,
y: r
}, u = await i.detectOverflow(t, f), p = z(G(o)), d = _e(p);
let m = l[d], g = l[p];
if (s) {
const v = d === "y" ? "top" : "left", y = d === "y" ? "bottom" : "right", b = m + u[v], x = m - u[y];
m = Ee(b, m, x);
}
if (a) {
const v = p === "y" ? "top" : "left", y = p === "y" ? "bottom" : "right", b = g + u[v], x = g - u[y];
g = Ee(b, g, x);
}
const w = c.fn({
...t,
[d]: m,
[p]: g
});
return {
...w,
data: {
x: w.x - n,
y: w.y - r,
enabled: {
[d]: s,
[p]: a
}
}
};
}
};
}, bn = function(e) {
return e === void 0 && (e = {}), {
options: e,
fn(t) {
const { x: n, y: r, placement: o, rects: i, middlewareData: s } = t, { offset: a = 0, mainAxis: c = !0, crossAxis: f = !0 } = X(e, t), l = {
x: n,
y: r
}, u = z(o), p = _e(u);
let d = l[p], m = l[u];
const g = X(a, t), w = typeof g == "number" ? {
mainAxis: g,
crossAxis: 0
} : {
mainAxis: 0,
crossAxis: 0,
...g
};
if (c) {
const b = p === "y" ? "height" : "width", x = i.reference[p] - i.floating[b] + w.mainAxis, C = i.reference[p] + i.reference[b] - w.mainAxis;
d < x ? d = x : d > C && (d = C);
}
if (f) {
var v, y;
const b = p === "y" ? "width" : "height", x = it.has(G(o)), C = i.reference[u] - i.floating[b] + (x && ((v = s.offset) == null ? void 0 : v[u]) || 0) + (x ? 0 : w.crossAxis), R = i.reference[u] + i.reference[b] + (x ? 0 : ((y = s.offset) == null ? void 0 : y[u]) || 0) - (x ? w.crossAxis : 0);
m < C ? m = C : m > R && (m = R);
}
return {
[p]: d,
[u]: m
};
}
};
}, Rn = function(e) {
return e === void 0 && (e = {}), {
name: "size",
options: e,
async fn(t) {
var n, r;
const { placement: o, rects: i, platform: s, elements: a } = t, { apply: c = () => {
}, ...f } = X(e, t), l = await s.detectOverflow(t, f), u = G(o), p = re(o), d = z(o) === "y", { width: m, height: g } = i.floating;
let w, v;
u === "top" || u === "bottom" ? (w = u, v = p === (await (s.isRTL == null ? void 0 : s.isRTL(a.floating)) ? "start" : "end") ? "left" : "right") : (v = u, w = p === "end" ? "top" : "bottom");
const y = g - l.top - l.bottom, b = m - l.left - l.right, x = q(g - l[w], y), C = q(m - l[v], b), R = !t.middlewareData.shift;
let T = x, M = C;
if ((n = t.middlewareData.shift) != null && n.enabled.x && (M = b), (r = t.middlewareData.shift) != null && r.enabled.y && (T = y), R && !p) {
const D = F(l.left, 0), k = F(l.right, 0), N = F(l.top, 0), S = F(l.bottom, 0);
d ? M = m - 2 * (D !== 0 || k !== 0 ? D + k : F(l.left, l.right)) : T = g - 2 * (N !== 0 || S !== 0 ? N + S : F(l.top, l.bottom));
}
await c({
...t,
availableWidth: M,
availableHeight: T
});
const $ = await s.getDimensions(a.floating);
return m !== $.width || g !== $.height ? { reset: { rects: !0 } } : {};
}
};
};
function ye() {
return typeof window < "u";
}
function oe(e) {
return st(e) ? (e.nodeName || "").toLowerCase() : "#document";
}
function I(e) {
var t;
return (e == null || (t = e.ownerDocument) == null ? void 0 : t.defaultView) || window;
}
function Y(e) {
var t;
return (t = (st(e) ? e.ownerDocument : e.document) || window.document) == null ? void 0 : t.documentElement;
}
function st(e) {
return ye() ? e instanceof Node || e instanceof I(e).Node : !1;
}
function W(e) {
return ye() ? e instanceof Element || e instanceof I(e).Element : !1;
}
function U(e) {
return ye() ? e instanceof HTMLElement || e instanceof I(e).HTMLElement : !1;
}
function Ke(e) {
return !ye() || typeof ShadowRoot > "u" ? !1 : e instanceof ShadowRoot || e instanceof I(e).ShadowRoot;
}
function le(e) {
const { overflow: t, overflowX: n, overflowY: r, display: o } = B(e);
return /auto|scroll|overlay|hidden|clip/.test(t + r + n) && o !== "inline" && o !== "contents";
}
function Cn(e) {
return /^(table|td|th)$/.test(oe(e));
}
function xe(e) {
try {
if (e.matches(":popover-open")) return !0;
} catch {
}
try {
return e.matches(":modal");
} catch {
return !1;
}
}
var An = /transform|translate|scale|rotate|perspective|filter/, Pn = /paint|layout|strict|content/, Z = (e) => !!e && e !== "none", Pe;
function $e(e) {
const t = W(e) ? B(e) : e;
return Z(t.transform) || Z(t.translate) || Z(t.scale) || Z(t.rotate) || Z(t.perspective) || !He() && (Z(t.backdropFilter) || Z(t.filter)) || An.test(t.willChange || "") || Pn.test(t.contain || "");
}
function Tn(e) {
let t = K(e);
for (; U(t) && !te(t); ) {
if ($e(t)) return t;
if (xe(t)) return null;
t = K(t);
}
return null;
}
function He() {
return Pe == null && (Pe = typeof CSS < "u" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none")), Pe;
}
function te(e) {
return /^(html|body|#document)$/.test(oe(e));
}
function B(e) {
return I(e).getComputedStyle(e);
}
function be(e) {
return W(e) ? {
scrollLeft: e.scrollLeft,
scrollTop: e.scrollTop
} : {
scrollLeft: e.scrollX,
scrollTop: e.scrollY
};
}
function K(e) {
if (oe(e) === "html") return e;
const t = e.assignedSlot || e.parentNode || Ke(e) && e.host || Y(e);
return Ke(t) ? t.host : t;
}
function ct(e) {
const t = K(e);
return te(t) ? e.ownerDocument ? e.ownerDocument.body : e.body : U(t) && le(t) ? t : ct(t);
}
function se(e, t, n) {
var r;
t === void 0 && (t = []), n === void 0 && (n = !0);
const o = ct(e), i = o === ((r = e.ownerDocument) == null ? void 0 : r.body), s = I(o);
if (i) {
const a = Le(s);
return t.concat(s, s.visualViewport || [], le(o) ? o : [], a && n ? se(a) : []);
} else return t.concat(o, se(o, [], n));
}
function Le(e) {
return e.parent && Object.getPrototypeOf(e.parent) ? e.frameElement : null;
}
function at(e) {
const t = B(e);
let n = parseFloat(t.width) || 0, r = parseFloat(t.height) || 0;
const o = U(e), i = o ? e.offsetWidth : n, s = o ? e.offsetHeight : r, a = me(n) !== i || me(r) !== s;
return a && (n = i, r = s), {
width: n,
height: r,
$: a
};
}
function Fe(e) {
return W(e) ? e : e.contextElement;
}
function ee(e) {
const t = Fe(e);
if (!U(t)) return j(1);
const n = t.getBoundingClientRect(), { width: r, height: o, $: i } = at(t);
let s = (i ? me(n.width) : n.width) / r, a = (i ? me(n.height) : n.height) / o;
return (!s || !Number.isFinite(s)) && (s = 1), (!a || !Number.isFinite(a)) && (a = 1), {
x: s,
y: a
};
}
var On = /* @__PURE__ */ j(0);
function lt(e) {
const t = I(e);
return !He() || !t.visualViewport ? On : {
x: t.visualViewport.offsetLeft,
y: t.visualViewport.offsetTop
};
}
function En(e, t, n) {
return t === void 0 && (t = !1), !n || t && n !== I(e) ? !1 : t;
}
function J(e, t, n, r) {
t === void 0 && (t = !1), n === void 0 && (n = !1);
const o = e.getBoundingClientRect(), i = Fe(e);
let s = j(1);
t && (r ? W(r) && (s = ee(r)) : s = ee(e));
const a = En(i, n, r) ? lt(i) : j(0);
let c = (o.left + a.x) / s.x, f = (o.top + a.y) / s.y, l = o.width / s.x, u = o.height / s.y;
if (i) {
const p = I(i), d = r && W(r) ? I(r) : r;
let m = p, g = Le(m);
for (; g && r && d !== m; ) {
const w = ee(g), v = g.getBoundingClientRect(), y = B(g), b = v.left + (g.clientLeft + parseFloat(y.paddingLeft)) * w.x, x = v.top + (g.clientTop + parseFloat(y.paddingTop)) * w.y;
c *= w.x, f *= w.y, l *= w.x, u *= w.y, c += b, f += x, m = I(g), g = Le(m);
}
}
return ge({
width: l,
height: u,
x: c,
y: f
});
}
function Re(e, t) {
const n = be(e).scrollLeft;
return t ? t.left + n : J(Y(e)).left + n;
}
function ft(e, t) {
const n = e.getBoundingClientRect();
return {
x: n.left + t.scrollLeft - Re(e, n),
y: n.top + t.scrollTop
};
}
function Sn(e) {
let { elements: t, rect: n, offsetParent: r, strategy: o } = e;
const i = o === "fixed", s = Y(r), a = t ? xe(t.floating) : !1;
if (r === s || a && i) return n;
let c = {
scrollLeft: 0,
scrollTop: 0
}, f = j(1);
const l = j(0), u = U(r);
if ((u || !u && !i) && ((oe(r) !== "body" || le(s)) && (c = be(r)), u)) {
const d = J(r);
f = ee(r), l.x = d.x + r.clientLeft, l.y = d.y + r.clientTop;
}
const p = s && !u && !i ? ft(s, c) : j(0);
return {
width: n.width * f.x,
height: n.height * f.y,
x: n.x * f.x - c.scrollLeft * f.x + l.x + p.x,
y: n.y * f.y - c.scrollTop * f.y + l.y + p.y
};
}
function Ln(e) {
return Array.from(e.getClientRects());
}
function Dn(e) {
const t = Y(e), n = be(e), r = e.ownerDocument.body, o = F(t.scrollWidth, t.clientWidth, r.scrollWidth, r.clientWidth), i = F(t.scrollHeight, t.clientHeight, r.scrollHeight, r.clientHeight);
let s = -n.scrollLeft + Re(e);
const a = -n.scrollTop;
return B(r).direction === "rtl" && (s += F(t.clientWidth, r.clientWidth) - o), {
width: o,
height: i,
x: s,
y: a
};
}
var Ze = 25;
function Mn(e, t) {
const n = I(e), r = Y(e), o = n.visualViewport;
let i = r.clientWidth, s = r.clientHeight, a = 0, c = 0;
if (o) {
i = o.width, s = o.height;
const l = He();
(!l || l && t === "fixed") && (a = o.offsetLeft, c = o.offsetTop);
}
const f = Re(r);
if (f <= 0) {
const l = r.ownerDocument, u = l.body, p = getComputedStyle(u), d = l.compatMode === "CSS1Compat" && parseFloat(p.marginLeft) + parseFloat(p.marginRight) || 0, m = Math.abs(r.clientWidth - u.clientWidth - d);
m <= Ze && (i -= m);
} else f <= Ze && (i += f);
return {
width: i,
height: s,
x: a,
y: c
};
}
function _n(e, t) {
const n = J(e, !0, t === "fixed"), r = n.top + e.clientTop, o = n.left + e.clientLeft, i = U(e) ? ee(e) : j(1);
return {
width: e.clientWidth * i.x,
height: e.clientHeight * i.y,
x: o * i.x,
y: r * i.y
};
}
function Je(e, t, n) {
let r;
if (t === "viewport") r = Mn(e, n);
else if (t === "document") r = Dn(Y(e));
else if (W(t)) r = _n(t, n);
else {
const o = lt(e);
r = {
x: t.x - o.x,
y: t.y - o.y,
width: t.width,
height: t.height
};
}
return ge(r);
}
function ut(e, t) {
const n = K(e);
return n === t || !W(n) || te(n) ? !1 : B(n).position === "fixed" || ut(n, t);
}
function kn(e, t) {
const n = t.get(e);
if (n) return n;
let r = se(e, [], !1).filter((a) => W(a) && oe(a) !== "body"), o = null;
const i = B(e).position === "fixed";
let s = i ? K(e) : e;
for (; W(s) && !te(s); ) {
const a = B(s), c = $e(s);
!c && a.position === "fixed" && (o = null), (i ? !c && !o : !c && a.position === "static" && o && (o.position === "absolute" || o.position === "fixed") || le(s) && !c && ut(e, s)) ? r = r.filter((f) => f !== s) : o = a, s = K(s);
}
return t.set(e, r), r;
}
function Nn(e) {
let { element: t, boundary: n, rootBoundary: r, strategy: o } = e;
const i = [...n === "clippingAncestors" ? xe(t) ? [] : kn(t, this._c) : [].concat(n), r], s = Je(t, i[0], o);
let a = s.top, c = s.right, f = s.bottom, l = s.left;
for (let u = 1; u < i.length; u++) {
const p = Je(t, i[u], o);
a = F(p.top, a), c = q(p.right, c), f = q(p.bottom, f), l = F(p.left, l);
}
return {
width: c - l,
height: f - a,
x: l,
y: a
};
}
function $n(e) {
const { width: t, height: n } = at(e);
return {
width: t,
height: n
};
}
function Hn(e, t, n) {
const r = U(t), o = Y(t), i = n === "fixed", s = J(e, !0, i, t);
let a = {
scrollLeft: 0,
scrollTop: 0
};
const c = j(0);
function f() {
c.x = Re(o);
}
if (r || !r && !i)
if ((oe(t) !== "body" || le(o)) && (a = be(t)), r) {
const u = J(t, !0, i, t);
c.x = u.x + t.clientLeft, c.y = u.y + t.clientTop;
} else o && f();
i && !r && o && f();
const l = o && !r && !i ? ft(o, a) : j(0);
return {
x: s.left + a.scrollLeft - c.x - l.x,
y: s.top + a.scrollTop - c.y - l.y,
width: s.width,
height: s.height
};
}
function Te(e) {
return B(e).position === "static";
}
function Qe(e, t) {
if (!U(e) || B(e).position === "fixed") return null;
if (t) return t(e);
let n = e.offsetParent;
return Y(e) === n && (n = n.ownerDocument.body), n;
}
function dt(e, t) {
const n = I(e);
if (xe(e)) return n;
if (!U(e)) {
let o = K(e);
for (; o && !te(o); ) {
if (W(o) && !Te(o)) return o;
o = K(o);
}
return n;
}
let r = Qe(e, t);
for (; r && Cn(r) && Te(r); ) r = Qe(r, t);
return r && te(r) && Te(r) && !$e(r) ? n : r || Tn(e) || n;
}
var Fn = async function(e) {
const t = this.getOffsetParent || dt, n = this.getDimensions, r = await n(e.floating);
return {
reference: Hn(e.reference, await t(e.floating), e.strategy),
floating: {
x: 0,
y: 0,
width: r.width,
height: r.height
}
};
};
function In(e) {
return B(e).direction === "rtl";
}
var Wn = {
convertOffsetParentRelativeRectToViewportRelativeRect: Sn,
getDocumentElement: Y,
getClippingRect: Nn,
getOffsetParent: dt,
getElementRects: Fn,
getClientRects: Ln,
getDimensions: $n,
getScale: ee,
isElement: W,
isRTL: In
};
function pt(e, t) {
return e.x === t.x && e.y === t.y && e.width === t.width && e.height === t.height;
}
function Bn(e, t) {
let n = null, r;
const o = Y(e);
function i() {
var a;
clearTimeout(r), (a = n) == null || a.disconnect(), n = null;
}
function s(a, c) {
a === void 0 && (a = !1), c === void 0 && (c = 1), i();
const f = e.getBoundingClientRect(), { left: l, top: u, width: p, height: d } = f;
if (a || t(), !p || !d) return;
const m = de(u), g = de(o.clientWidth - (l + p)), w = de(o.clientHeight - (u + d)), v = de(l), y = {
rootMargin: -m + "px " + -g + "px " + -w + "px " + -v + "px",
threshold: F(0, q(1, c)) || 1
};
let b = !0;
function x(C) {
const R = C[0].intersectionRatio;
if (R !== c) {
if (!b) return s();
R ? s(!1, R) : r = setTimeout(() => {
s(!1, 1e-7);
}, 1e3);
}
R === 1 && !pt(f, e.getBoundingClientRect()) && s(), b = !1;
}
try {
n = new IntersectionObserver(x, {
...y,
root: o.ownerDocument
});
} catch {
n = new IntersectionObserver(x, y);
}
n.observe(e);
}
return s(!0), i;
}
function Vn(e, t, n, r) {
r === void 0 && (r = {});
const { ancestorScroll: o = !0, ancestorResize: i = !0, elementResize: s = typeof ResizeObserver == "function", layoutShift: a = typeof IntersectionObserver == "function", animationFrame: c = !1 } = r, f = Fe(e), l = o || i ? [...f ? se(f) : [], ...t ? se(t) : []] : [];
l.forEach((v) => {
o && v.addEventListener("scroll", n, { passive: !0 }), i && v.addEventListener("resize", n);
});
const u = f && a ? Bn(f, n) : null;
let p = -1, d = null;
s && (d = new ResizeObserver((v) => {
let [y] = v;
y && y.target === f && d && t && (d.unobserve(t), cancelAnimationFrame(p), p = requestAnimationFrame(() => {
var b;
(b = d) == null || b.observe(t);
})), n();
}), f && !c && d.observe(f), t && d.observe(t));
let m, g = c ? J(e) : null;
c && w();
function w() {
const v = J(e);
g && !pt(g, v) && n(), g = v, m = requestAnimationFrame(w);
}
return n(), () => {
var v;
l.forEach((y) => {
o && y.removeEventListener("scroll", n), i && y.removeEventListener("resize", n);
}), u?.(), (v = d) == null || v.disconnect(), d = null, c && cancelAnimationFrame(m);
};
}
var zn = yn, jn = xn, Yn = gn, Xn = Rn, Gn = wn, et = hn, Un = bn, qn = (e, t, n) => {
const r = /* @__PURE__ */ new Map(), o = {
platform: Wn,
...n
}, i = {
...o.platform,
_c: r
};
return mn(e, t, {
...o,
platform: i
});
}, pe = typeof document < "u" ? Jt : function() {
};
function we(e, t) {
if (e === t) return !0;
if (typeof e != typeof t) return !1;
if (typeof e == "function" && e.toString() === t.toString()) return !0;
let n, r, o;
if (e && t && typeof e == "object") {
if (Array.isArray(e)) {
if (n = e.length, n !== t.length) return !1;
for (r = n; r-- !== 0; ) if (!we(e[r], t[r])) return !1;
return !0;
}
if (o = Object.keys(e), n = o.length, n !== Object.keys(t).length) return !1;
for (r = n; r-- !== 0; ) if (!{}.hasOwnProperty.call(t, o[r])) return !1;
for (r = n; r-- !== 0; ) {
const i = o[r];
if (!(i === "_owner" && e.$$typeof) && !we(e[i], t[i]))
return !1;
}
return !0;
}
return e !== e && t !== t;
}
function mt(e) {
return typeof window > "u" ? 1 : (e.ownerDocument.defaultView || window).devicePixelRatio || 1;
}
function tt(e, t) {
const n = mt(e);
return Math.round(t * n) / n;
}
function Oe(e) {
const t = h.useRef(e);
return pe(() => {
t.current = e;
}), t;
}
function Kn(e) {
e === void 0 && (e = {});
const { placement: t = "bottom", strategy: n = "absolute", middleware: r = [], platform: o, elements: { reference: i, floating: s } = {}, transform: a = !0, whileElementsMounted: c, open: f } = e, [l, u] = h.useState({
x: 0,
y: 0,
strategy: n,
placement: t,
middlewareData: {},
isPositioned: !1
}), [p, d] = h.useState(r);
we(p, r) || d(r);
const [m, g] = h.useState(null), [w, v] = h.useState(null), y = h.useCallback((A) => {
A !== R.current && (R.current = A, g(A));
}, []), b = h.useCallback((A) => {
A !== T.current && (T.current = A, v(A));
}, []), x = i || m, C = s || w, R = h.useRef(null), T = h.useRef(null), M = h.useRef(l), $ = c != null, D = Oe(c), k = Oe(o), N = Oe(f), S = h.useCallback(() => {
if (!R.current || !T.current) return;
const A = {
placement: t,
strategy: n,
middleware: p
};
k.current && (A.platform = k.current), qn(R.current, T.current, A).then((_) => {
const V = {
..._,
isPositioned: N.current !== !1
};
O.current && !we(M.current, V) && (M.current = V, Qt.flushSync(() => {
u(V);
}));
});
}, [
p,
t,
n,
k,
N
]);
pe(() => {
f === !1 && M.current.isPositioned && (M.current.isPositioned = !1, u((A) => ({
...A,
isPositioned: !1
})));
}, [f]);
const O = h.useRef(!1);
pe(() => (O.current = !0, () => {
O.current = !1;
}), []), pe(() => {
if (x && (R.current = x), C && (T.current = C), x && C) {
if (D.current) return D.current(x, C, S);
S();
}
}, [
x,
C,
S,
D,
$
]);
const H = h.useMemo(() => ({
reference: R,
floating: T,
setReference: y,
setFloating: b
}), [y, b]), L = h.useMemo(() => ({
reference: x,
floating: C
}), [x, C]), E = h.useMemo(() => {
const A = {
position: n,
left: 0,
top: 0
};
if (!L.floating) return A;
const _ = tt(L.floating, l.x), V = tt(L.floating, l.y);
return a ? {
...A,
transform: "translate(" + _ + "px, " + V + "px)",
...mt(L.floating) >= 1.5 && { willChange: "transform" }
} : {
position: n,
left: _,
top: V
};
}, [
n,
a,
L.floating,
l.x,
l.y
]);
return h.useMemo(() => ({
...l,
update: S,
refs: H,
elements: L,
floatingStyles: E
}), [
l,
S,
H,
L,
E
]);
}
var Zn = (e) => {
function t(n) {
return {}.hasOwnProperty.call(n, "current");
}
return {
name: "arrow",
options: e,
fn(n) {
const { element: r, padding: o } = typeof e == "function" ? e(n) : e;
return r && t(r) ? r.current != null ? et({
element: r.current,
padding: o
}).fn(n) : {} : r ? et({
element: r,
padding: o
}).fn(n) : {};
}
};
}, Jn = (e, t) => {
const n = zn(e);
return {
name: n.name,
fn: n.fn,
options: [e, t]
};
}, Qn = (e, t) => {
const n = jn(e);
return {
name: n.name,
fn: n.fn,
options: [e, t]
};
}, er = (e, t) => ({
fn: Un(e).fn,
options: [e, t]
}), tr = (e, t) => {
const n = Yn(e);
return {
name: n.name,
fn: n.fn,
options: [e, t]
};
}, nr = (e, t) => {
const n = Xn(e);
return {
name: n.name,
fn: n.fn,
options: [e, t]
};
}, rr = (e, t) => {
const n = Gn(e);
return {
name: n.name,
fn: n.fn,
options: [e, t]
};
}, or = (e, t) => {
const n = Zn(e);
return {
name: n.name,
fn: n.fn,
options: [e, t]
};
}, ir = "Arrow", ht = h.forwardRef((e, t) => {
const { children: n, width: r = 10, height: o = 5, ...i } = e;
return /* @__PURE__ */ P(ae.svg, {
...i,
ref: t,
width: r,
height: o,
viewBox: "0 0 30 10",
preserveAspectRatio: "none",
children: e.asChild ? n : /* @__PURE__ */ P("polygon", { points: "0,0 30,0 15,10" })
});
});
ht.displayName = ir;
var sr = ht, Ie = "Popper", [gt, wt] = nt(Ie), [cr, vt] = gt(Ie), yt = (e) => {
const { __scopePopper: t, children: n } = e, [r, o] = h.useState(null);
return /* @__PURE__ */ P(cr, {
scope: t,
anchor: r,
onAnchorChange: o,
children: n
});
};
yt.displayName = Ie;
var xt = "PopperAnchor", bt = h.forwardRef((e, t) => {
const { __scopePopper: n, virtualRef: r, ...o } = e, i = vt(xt, n), s = h.useRef(null), a = ve(t, s), c = h.useRef(null);
return h.useEffect(() => {
const f = c.current;
c.current = r?.current || s.current, f !== c.current && i.onAnchorChange(c.current);
}), r ? null : /* @__PURE__ */ P(ae.div, {
...o,
ref: a
});
});
bt.displayName = xt;
var We = "PopperContent", [ar, lr] = gt(We), Rt = h.forwardRef((e, t) => {
const { __scopePopper: n, side: r = "bottom", sideOffset: o = 0, align: i = "center", alignOffset: s = 0, arrowPadding: a = 0, avoidCollisions: c = !0, collisionBoundary: f = [], collisionPadding: l = 0, sticky: u = "partial", hideWhenDetached: p = !1, updatePositionStrategy: d = "optimized", onPlaced: m, ...g } = e, w = vt(We, n), [v, y] = h.useState(null), b = ve(t, (ie) => y(ie)), [x, C] = h.useState(null), R = Zt(x), T = R?.width ?? 0, M = R?.height ?? 0, $ = r + (i !== "center" ? "-" + i : ""), D = typeof l == "number" ? l : {
top: 0,
right: 0,
bottom: 0,
left: 0,
...l
}, k = Array.isArray(f) ? f : [f], N = k.length > 0, S = {
padding: D,
boundary: k.filter(ur),
altBoundary: N
}, { refs: O, floatingStyles: H, placement: L, isPositioned: E, middlewareData: A } = Kn({
strategy: "fixed",
placement: $,
whileElementsMounted: (...ie) => Vn(...ie, { animationFrame: d === "always" }),
elements: { reference: w.anchor },
middleware: [
Jn({
mainAxis: o + M,
alignmentAxis: s
}),
c && Qn({
mainAxis: !0,
crossAxis: !1,
limiter: u === "partial" ? er() : void 0,
...S
}),
c && tr({ ...S }),
nr({
...S,
apply: ({ elements: ie, rects: Bt, availableWidth: Vt, availableHeight: zt }) => {
const { width: jt, height: Yt } = Bt.reference, ue = ie.floating.style;
ue.setProperty("--radix-popper-available-width", `${Vt}px`), ue.setProperty("--radix-popper-available-height", `${zt}px`), ue.setProperty("--radix-popper-anchor-width", `${jt}px`), ue.setProperty("--radix-popper-anchor-height", `${Yt}px`);
}
}),
x && or({
element: x,
padding: a
}),
dr({
arrowWidth: T,
arrowHeight: M
}),
p && rr({
strategy: "referenceHidden",
...S
})
]
}), [_, V] = Pt(L), ze = Ut(m);
je(() => {
E && ze?.();
}, [E, ze]);
const $t = A.arrow?.x, Ht = A.arrow?.y, Ft = A.arrow?.centerOffset !== 0, [It, Wt] = h.useState();
return je(() => {
v && Wt(window.getComputedStyle(v).zIndex);
}, [v]), /* @__PURE__ */ P("div", {
ref: O.setFloating,
"data-radix-popper-content-wrapper": "",
style: {
...H,
transform: E ? H.transform : "translate(0, -200%)",
minWidth: "max-content",
zIndex: It,
"--radix-popper-transform-origin": [A.transformOrigin?.x, A.transformOrigin?.y].join(" "),
...A.hide?.referenceHidden && {
visibility: "hidden",
pointerEvents: "none"
}
},
dir: e.dir,
children: /* @__PURE__ */ P(ar, {
scope: n,
placedSide: _,
onArrowChange: C,
arrowX: $t,
arrowY: Ht,
shouldHideArrow: Ft,
children: /* @__PURE__ */ P(ae.div, {
"data-side": _,
"data-align": V,
...g,
ref: b,
style: {
...g.style,
animation: E ? void 0 : "none"
}
})
})
});
});
Rt.displayName = We;
var Ct = "PopperArrow", fr = {
top: "bottom",
right: "left",
bottom: "top",
left: "right"
}, At = h.forwardRef(function(t, n) {
const { __scopePopper: r, ...o } = t, i = lr(Ct, r), s = fr[i.placedSide];
return /* @__PURE__ */ P("span", {
ref: i.onArrowChange,
style: {
position: "absolute",
left: i.arrowX,
top: i.arrowY,
[s]: 0,
transformOrigin: {
top: "",
right: "0 0",
bottom: "center 0",
left: "100% 0"
}[i.placedSide],
transform: {
top: "translateY(100%)",
right: "translateY(50%) rotate(90deg) translateX(-50%)",
bottom: "rotate(180deg)",
left: "translateY(50%) rotate(-90deg) translateX(50%)"
}[i.placedSide],
visibility: i.shouldHideArrow ? "hidden" : void 0
},
children: /* @__PURE__ */ P(sr, {
...o,
ref: n,
style: {
...o.style,
display: "block"
}
})
});
});
At.displayName = Ct;
function ur(e) {
return e !== null;
}
var dr = (e) => ({
name: "transformOrigin",
options: e,
fn(t) {
const { placement: n, rects: r, middlewareData: o } = t, i = o.arrow?.centerOffset !== 0, s = i ? 0 : e.arrowWidth, a = i ? 0 : e.arrowHeight, [c, f] = Pt(n), l = {
start: "0%",
center: "50%",
end: "100%"
}[f], u = (o.arrow?.x ?? 0) + s / 2, p = (o.arrow?.y ?? 0) + a / 2;
let d = "", m = "";
return c === "bottom" ? (d = i ? l : `${u}px`, m = `${-a}px`) : c === "top" ? (d = i ? l : `${u}px`, m = `${r.floating.height + a}px`) : c === "right" ? (d = `${-a}px`, m = i ? l : `${p}px`) : c === "left" && (d = `${r.floating.width + a}px`, m = i ? l : `${p}px`), { data: {
x: d,
y: m
} };
}
});
function Pt(e) {
const [t, n = "center"] = e.split("-");
return [t, n];
}
var pr = yt, mr = bt, hr = Rt, gr = At, wr = /* @__PURE__ */ Symbol("radix.slottable");
// @__NO_SIDE_EFFECTS__
function vr(e) {
const t = ({ children: n }) => /* @__PURE__ */ P(en, { children: n });
return t.displayName = `${e}.Slottable`, t.__radixId = wr, t;
}
var yr = Object.freeze({
position: "absolute",
border: 0,
width: 1,
height: 1,
padding: 0,
margin: -1,
overflow: "hidden",
clip: "rect(0, 0, 0, 0)",
whiteSpace: "nowrap",
wordWrap: "normal"
}), xr = "VisuallyHidden", Tt = h.forwardRef((e, t) => /* @__PURE__ */ P(ae.span, {
...e,
ref: t,
style: {
...yr,
...e.style
}
}));
Tt.displayName = xr;
var br = Tt, [Ce, Xr] = nt("Tooltip", [wt]), Ae = wt(), Ot = "TooltipProvider", Rr = 700, De = "tooltip.open", [Cr, Be] = Ce(Ot), Et = (e) => {
const { __scopeTooltip: t, delayDuration: n = Rr, skipDelayDuration: r = 300, disableHoverableContent: o = !1, children: i } = e, s = h.useRef(!0), a = h.useRef(!1), c = h.useRef(0);
return h.useEffect(() => {
const f = c.current;
return () => window.clearTimeout(f);
}, []), /* @__PURE__ */ P(Cr, {
scope: t,
isOpenDelayedRef: s,
delayDuration: n,
onOpen: h.useCallback(() => {
window.clearTimeout(c.current), s.current = !1;
}, []),
onClose: h.useCallback(() => {
window.clearTimeout(c.current), c.current = window.setTimeout(() => s.current = !0, r);
}, [r]),
isPointerInTransitRef: a,
onPointerInTransitChange: h.useCallback((f) => {
a.current = f;
}, []),
disableHoverableContent: o,
children: i
});
};
Et.displayName = Ot;
var ce = "Tooltip", [Ar, fe] = Ce(ce), St = (e) => {
const { __scopeTooltip: t, children: n, open: r, defaultOpen: o, onOpenChange: i, disableHoverableContent: s, delayDuration: a } = e, c = Be(ce, e.__scopeTooltip), f = Ae(t), [l, u] = h.useState(null), p = Gt(), d = h.useRef(0), m = s ?? c.disableHoverableContent, g = a ?? c.delayDuration, w = h.useRef(!1), [v, y] = Xt({
prop: r,
defaultProp: o ?? !1,
onChange: (T) => {
T ? (c.onOpen(), document.dispatchEvent(new CustomEvent(De))) : c.onClose(), i?.(T);
},
caller: ce
}), b = h.useMemo(() => v ? w.current ? "delayed-open" : "instant-open" : "closed", [v]), x = h.useCallback(() => {
window.clearTimeout(d.current), d.current = 0, w.current = !1, y(!0);
}, [y]), C = h.useCallback(() => {
window.clearTimeout(d.current), d.current = 0, y(!1);
}, [y]), R = h.useCallback(() => {
window.clearTimeout(d.current), d.current = window.setTimeout(() => {
w.current = !0, y(!0), d.current = 0;
}, g);
}, [g, y]);
return h.useEffect(() => () => {
d.current && (window.clearTimeout(d.current), d.current = 0);
}, []), /* @__PURE__ */ P(pr, {
...f,
children: /* @__PURE__ */ P(Ar, {
scope: t,
contentId: p,
open: v,
stateAttribute: b,
trigger: l,
onTriggerChange: u,
onTriggerEnter: h.useCallback(() => {
c.isOpenDelayedRef.current ? R() : x();
}, [
c.isOpenDelayedRef,
R,
x
]),
onTriggerLeave: h.useCallback(() => {
m ? C() : (window.clearTimeout(d.current), d.current = 0);
}, [C, m]),
onOpen: x,
onClose: C,
disableHoverableContent: m,
children: n
})
});
};
St.displayName = ce;
var Me = "TooltipTrigger", Lt = h.forwardRef((e, t) => {
const { __scopeTooltip: n, ...r } = e, o = fe(Me, n), i = Be(Me, n), s = Ae(n), a = ve(t, h.useRef(null), o.onTriggerChange), c = h.useRef(!1), f = h.useRef(!1), l = h.useCallback(() => c.current = !1, []);
return h.useEffect(() => () => document.removeEventListener("pointerup", l), [l]), /* @__PURE__ */ P(mr, {
asChild: !0,
...s,
children: /* @__PURE__ */ P(ae.button, {
"aria-describedby": o.open ? o.contentId : void 0,
"data-state": o.stateAttribute,
...r,
ref: a,
onPointerMove: Q(e.onPointerMove, (u) => {
u.pointerType !== "touch" && !f.current && !i.isPointerInTransitRef.current && (o.onTriggerEnter(), f.current = !0);
}),
onPointerLeave: Q(e.onPointerLeave, () => {
o.onTriggerLeave(), f.current = !1;
}),
onPointerDown: Q(e.onPointerDown, () => {
o.open && o.onClose(), c.current = !0, document.addEventListener("pointerup", l, { once: !0 });
}),
onFocus: Q(e.onFocus, () => {
c.current || o.onOpen();
}),
onBlur: Q(e.onBlur, o.onClose),
onClick: Q(e.onClick, o.onClose)
})
});
});
Lt.displayName = Me;
var Ve = "TooltipPortal", [Pr, Tr] = Ce(Ve, { forceMount: void 0 }), Dt = (e) => {
const { __scopeTooltip: t, forceMount: n, children: r, container: o } = e, i = fe(Ve, t);
return /* @__PURE__ */ P(Pr, {
scope: t,
forceMount: n,
children: /* @__PURE__ */ P(rt, {
present: n || i.open,
children: /* @__PURE__ */ P(Kt, {
asChild: !0,
container: o,
children: r
})
})
});
};
Dt.displayName = Ve;
var ne = "TooltipContent", Mt = h.forwardRef((e, t) => {
const n = Tr(ne, e.__scopeTooltip), { forceMount: r = n.forceMount, side: o = "top", ...i } = e, s = fe(ne, e.__scopeTooltip);
return /* @__PURE__ */ P(rt, {
present: r || s.open,
children: s.disableHoverableContent ? /* @__PURE__ */ P(_t, {
side: o,
...i,
ref: t
}) : /* @__PURE__ */ P(Or, {
side: o,
...i,
ref: t
})
});
}), Or = h.forwardRef((e, t) => {
const n = fe(ne, e.__scopeTooltip), r = Be(ne, e.__scopeTooltip), o = h.useRef(null), i = ve(t, o), [s, a] = h.useState(null), { trigger: c, onClose: f } = n, l = o.current, { onPointerInTransitChange: u } = r, p = h.useCallback(() => {
a(null), u(!1);
}, [u]), d = h.useCallback((m, g) => {
const w = m.currentTarget, v = {
x: m.clientX,
y: m.clientY
}, y = Mr(v, Dr(v, w.getBoundingClientRect())), b = _r(g.getBoundingClientRect());
a(Nr([...y, ...b])), u(!0);
}, [u]);
return h.useEffect(() => () => p(), [p]), h.useEffect(() => {
if (c && l) {
const m = (w) => d(w, l), g = (w) => d(w, c);
return c.addEventListener("pointerleave", m), l.addEventListener("pointerleave", g), () => {
c.removeEventListener("pointerleave", m), l.removeEventListener("pointerleave", g);
};
}
}, [
c,
l,
d,
p
]), h.useEffect(() => {
if (s) {
const m = (g) => {
const w = g.target, v = {
x: g.clientX,
y: g.clientY
}, y = c?.contains(w) || l?.contains(w), b = !kr(v, s);
y ? p() : b && (p(), f());
};
return document.addEventListener("pointermove", m), () => document.removeEventListener("pointermove", m);
}
}, [
c,
l,
s,
f,
p
]), /* @__PURE__ */ P(_t, {
...e,
ref: i
});
}), [Er, Sr] = Ce(ce, { isInside: !1 }), Lr = /* @__PURE__ */ vr("TooltipContent"), _t = h.forwardRef((e, t) => {
const { __scopeTooltip: n, children: r, "aria-label": o, onEscapeKeyDown: i, onPointerDownOutside: s, ...a } = e, c = fe(ne, n), f = Ae(n), { onClose: l } = c;
return h.useEffect(() => (document.addEventListener(De, l), () => document.removeEventListener(De, l)), [l]), h.useEffect(() => {
if (c.trigger) {
const u = (p) => {
p.target?.contains(c.trigger) && l();
};
return window.addEventListener("scroll", u, { capture: !0 }), () => window.removeEventListener("scroll", u, { capture: !0 });
}
}, [c.trigger, l]), /* @__PURE__ */ P(qt, {
asChild: !0,
disableOutsidePointerEvents: !1,
onEscapeKeyDown: i,
onPointerDownOutside: s,
onFocusOutside: (u) => u.preventDefault(),
onDismiss: l,
children: /* @__PURE__ */ tn(hr, {
"data-state": c.stateAttribute,
...f,
...a,
ref: t,
style: {
...a.style,
"--radix-tooltip-content-transform-origin": "var(--radix-popper-transform-origin)",
"--radix-tooltip-content-available-width": "var(--radix-popper-available-width)",
"--radix-tooltip-content-available-height": "var(--radix-popper-available-height)",
"--radix-tooltip-trigger-width": "var(--radix-popper-anchor-width)",
"--radix-tooltip-trigger-height": "var(--radix-popper-anchor-height)"
},
children: [/* @__PURE__ */ P(Lr, { children: r }), /* @__PURE__ */ P(Er, {
scope: n,
isInside: !0,
children: /* @__PURE__ */ P(br, {
id: c.contentId,
role: "tooltip",
children: o || r
})
})]
})
});
});
Mt.displayName = ne;
var kt = "TooltipArrow", Nt = h.forwardRef((e, t) => {
const { __scopeTooltip: n, ...r } = e, o = Ae(n);
return Sr(kt, n).isInside ? null : /* @__PURE__ */ P(gr, {
...o,
...r,
ref: t
});
});
Nt.displayName = kt;
function Dr(e, t) {
const n = Math.abs(t.top - e.y), r = Math.abs(t.bottom - e.y), o = Math.abs(t.right - e.x), i = Math.abs(t.left - e.x);
switch (Math.min(n, r, o, i)) {
case i:
return "left";
case o:
return "right";
case n:
return "top";
case r:
return "bottom";
default:
throw new Error("unreachable");
}
}
function Mr(e, t, n = 5) {
const r = [];
switch (t) {
case "top":
r.push({
x: e.x - n,
y: e.y + n
}, {
x: e.x + n,
y: e.y + n
});
break;
case "bottom":
r.push({
x: e.x - n,
y: e.y - n
}, {
x: e.x + n,
y: e.y - n
});
break;
case "left":
r.push({
x: e.x + n,
y: e.y - n
}, {
x: e.x + n,
y: e.y + n
});
break;
case "right":
r.push({
x: e.x - n,
y: e.y - n
}, {
x: e.x - n,
y: e.y + n
});
break;
}
return r;
}
function _r(e) {
const { top: t, right: n, bottom: r, left: o } = e;
return [
{
x: o,
y: t
},
{
x: n,
y: t
},
{
x: n,
y: r
},
{
x: o,
y: r
}
];
}
function kr(e, t) {
const { x: n, y: r } = e;
let o = !1;
for (let i = 0, s = t.length - 1; i < t.length; s = i++) {
const a = t[i], c = t[s], f = a.x, l = a.y, u = c.x, p = c.y;
l > r != p > r && n < (u - f) * (r - l) / (p - l) + f && (o = !o);
}
return o;
}
function Nr(e) {
const t = e.slice();
return t.sort((n, r) => n.x < r.x ? -1 : n.x > r.x ? 1 : n.y < r.y ? -1 : n.y > r.y ? 1 : 0), $r(t);
}
function $r(e) {
if (e.length <= 1) return e.slice();
const t = [];
for (let r = 0; r < e.length; r++) {
const o = e[r];
for (; t.length >= 2; ) {
const i = t[t.length - 1], s = t[t.length - 2];
if ((i.x - s.x) * (o.y - s.y) >= (i.y - s.y) * (o.x - s.x)) t.pop();
else break;
}
t.push(o);
}
t.pop();
const n = [];
for (let r = e.length - 1; r >= 0; r--) {
const o = e[r];
for (; n.length >= 2; ) {
const i = n[n.length - 1], s = n[n.length - 2];
if ((i.x - s.x) * (o.y - s.y) >= (i.y - s.y) * (o.x - s.x)) n.pop();
else break;
}
n.push(o);
}
return n.pop(), t.length === 1 && n.length === 1 && t[0].x === n[0].x && t