UNPKG

@stanfordspezi/spezi-web-design-system

Version:

Stanford Biodesign Digital Health Spezi Web Design System

1,524 lines (1,523 loc) 41.8 kB
import * as P from "react"; import { useLayoutEffect as Pe, useEffect as Ce } from "react"; import * as Oe from "react-dom"; import { P as bt } from "./index-WWNfSPCj.mjs"; import { jsx as j } from "react/jsx-runtime"; import { u as Ut } from "./index-Bytw4Lqn.mjs"; import { c as Se, b as Ee, u as _t } from "./index-DqbtYIhp.mjs"; import { u as De } from "./index-Da5ea2iF.mjs"; const Te = ["top", "right", "bottom", "left"], U = Math.min, N = Math.max, ft = Math.round, lt = Math.floor, z = (t) => ({ x: t, y: t }), Le = { left: "right", right: "left", bottom: "top", top: "bottom" }, Me = { start: "end", end: "start" }; function yt(t, e, n) { return N(t, U(e, n)); } function X(t, e) { return typeof t == "function" ? t(e) : t; } function q(t) { return t.split("-")[0]; } function tt(t) { return t.split("-")[1]; } function Rt(t) { return t === "x" ? "y" : "x"; } function Pt(t) { return t === "y" ? "height" : "width"; } function Z(t) { return ["top", "bottom"].includes(q(t)) ? "y" : "x"; } function Ct(t) { return Rt(Z(t)); } function $e(t, e, n) { n === void 0 && (n = !1); const o = tt(t), i = Ct(t), r = Pt(i); let s = i === "x" ? o === (n ? "end" : "start") ? "right" : "left" : o === "start" ? "bottom" : "top"; return e.reference[r] > e.floating[r] && (s = ut(s)), [s, ut(s)]; } function ke(t) { const e = ut(t); return [vt(t), e, vt(e)]; } function vt(t) { return t.replace(/start|end/g, (e) => Me[e]); } function Fe(t, e, n) { const o = ["left", "right"], i = ["right", "left"], r = ["top", "bottom"], s = ["bottom", "top"]; switch (t) { case "top": case "bottom": return n ? e ? i : o : e ? o : i; case "left": case "right": return e ? r : s; default: return []; } } function Ne(t, e, n, o) { const i = tt(t); let r = Fe(q(t), n === "start", o); return i && (r = r.map((s) => s + "-" + i), e && (r = r.concat(r.map(vt)))), r; } function ut(t) { return t.replace(/left|right|bottom|top/g, (e) => Le[e]); } function He(t) { return { top: 0, right: 0, bottom: 0, left: 0, ...t }; } function Zt(t) { return typeof t != "number" ? He(t) : { top: t, right: t, bottom: t, left: t }; } function dt(t) { const { x: e, y: n, width: o, height: i } = t; return { width: o, height: i, top: n, left: e, right: e + o, bottom: n + i, x: e, y: n }; } function Bt(t, e, n) { let { reference: o, floating: i } = t; const r = Z(e), s = Ct(e), c = Pt(s), a = q(e), l = r === "y", f = o.x + o.width / 2 - i.width / 2, u = o.y + o.height / 2 - i.height / 2, p = o[c] / 2 - i[c] / 2; let d; switch (a) { case "top": d = { x: f, y: o.y - i.height }; break; case "bottom": d = { x: f, y: o.y + o.height }; break; case "right": d = { x: o.x + o.width, y: u }; break; case "left": d = { x: o.x - i.width, y: u }; break; default: d = { x: o.x, y: o.y }; } switch (tt(e)) { case "start": d[s] -= p * (n && l ? -1 : 1); break; case "end": d[s] += p * (n && l ? -1 : 1); break; } return d; } const We = async (t, e, n) => { const { placement: o = "bottom", strategy: i = "absolute", middleware: r = [], platform: s } = n, c = r.filter(Boolean), a = await (s.isRTL == null ? void 0 : s.isRTL(e)); let l = await s.getElementRects({ reference: t, floating: e, strategy: i }), { x: f, y: u } = Bt(l, o, a), p = o, d = {}, m = 0; for (let h = 0; h < c.length; h++) { const { name: w, fn: g } = c[h], { x, y: A, data: y, reset: v } = await g({ x: f, y: u, initialPlacement: o, placement: p, strategy: i, middlewareData: d, rects: l, platform: s, elements: { reference: t, floating: e } }); f = x ?? f, u = A ?? u, d = { ...d, [w]: { ...d[w], ...y } }, v && m <= 50 && (m++, typeof v == "object" && (v.placement && (p = v.placement), v.rects && (l = v.rects === !0 ? await s.getElementRects({ reference: t, floating: e, strategy: i }) : v.rects), { x: f, y: u } = Bt(l, p, a)), h = -1); } return { x: f, y: u, placement: p, strategy: i, middlewareData: d }; }; async function ot(t, e) { var n; e === void 0 && (e = {}); const { x: o, y: i, platform: r, rects: s, elements: c, strategy: a } = t, { boundary: l = "clippingAncestors", rootBoundary: f = "viewport", elementContext: u = "floating", altBoundary: p = !1, padding: d = 0 } = X(e, t), m = Zt(d), w = c[p ? u === "floating" ? "reference" : "floating" : u], g = dt(await r.getClippingRect({ element: (n = await (r.isElement == null ? void 0 : r.isElement(w))) == null || n ? w : w.contextElement || await (r.getDocumentElement == null ? void 0 : r.getDocumentElement(c.floating)), boundary: l, rootBoundary: f, strategy: a })), x = u === "floating" ? { x: o, y: i, width: s.floating.width, height: s.floating.height } : s.reference, A = await (r.getOffsetParent == null ? void 0 : r.getOffsetParent(c.floating)), y = await (r.isElement == null ? void 0 : r.isElement(A)) ? await (r.getScale == null ? void 0 : r.getScale(A)) || { x: 1, y: 1 } : { x: 1, y: 1 }, v = dt(r.convertOffsetParentRelativeRectToViewportRelativeRect ? await r.convertOffsetParentRelativeRectToViewportRelativeRect({ elements: c, rect: x, offsetParent: A, strategy: a }) : x); return { top: (g.top - v.top + m.top) / y.y, bottom: (v.bottom - g.bottom + m.bottom) / y.y, left: (g.left - v.left + m.left) / y.x, right: (v.right - g.right + m.right) / y.x }; } const _e = (t) => ({ name: "arrow", options: t, async fn(e) { const { x: n, y: o, placement: i, rects: r, platform: s, elements: c, middlewareData: a } = e, { element: l, padding: f = 0 } = X(t, e) || {}; if (l == null) return {}; const u = Zt(f), p = { x: n, y: o }, d = Ct(i), m = Pt(d), h = await s.getDimensions(l), w = d === "y", g = w ? "top" : "left", x = w ? "bottom" : "right", A = w ? "clientHeight" : "clientWidth", y = r.reference[m] + r.reference[d] - p[d] - r.floating[m], v = p[d] - r.reference[d], R = await (s.getOffsetParent == null ? void 0 : s.getOffsetParent(l)); let C = R ? R[A] : 0; (!C || !await (s.isElement == null ? void 0 : s.isElement(R))) && (C = c.floating[A] || r.floating[m]); const T = y / 2 - v / 2, F = C / 2 - h[m] / 2 - 1, L = U(u[g], F), $ = U(u[x], F), k = L, S = C - h[m] - $, O = C / 2 - h[m] / 2 + T, W = yt(k, O, S), E = !a.arrow && tt(i) != null && O !== W && r.reference[m] / 2 - (O < k ? L : $) - h[m] / 2 < 0, D = E ? O < k ? O - k : O - S : 0; return { [d]: p[d] + D, data: { [d]: W, centerOffset: O - W - D, ...E && { alignmentOffset: D } }, reset: E }; } }), Be = function(t) { return t === void 0 && (t = {}), { name: "flip", options: t, async fn(e) { var n, o; const { placement: i, middlewareData: r, rects: s, initialPlacement: c, platform: a, elements: l } = e, { mainAxis: f = !0, crossAxis: u = !0, fallbackPlacements: p, fallbackStrategy: d = "bestFit", fallbackAxisSideDirection: m = "none", flipAlignment: h = !0, ...w } = X(t, e); if ((n = r.arrow) != null && n.alignmentOffset) return {}; const g = q(i), x = Z(c), A = q(c) === c, y = await (a.isRTL == null ? void 0 : a.isRTL(l.floating)), v = p || (A || !h ? [ut(c)] : ke(c)), R = m !== "none"; !p && R && v.push(...Ne(c, h, m, y)); const C = [c, ...v], T = await ot(e, w), F = []; let L = ((o = r.flip) == null ? void 0 : o.overflows) || []; if (f && F.push(T[g]), u) { const O = $e(i, s, y); F.push(T[O[0]], T[O[1]]); } if (L = [...L, { placement: i, overflows: F }], !F.every((O) => O <= 0)) { var $, k; const O = ((($ = r.flip) == null ? void 0 : $.index) || 0) + 1, W = C[O]; if (W) return { data: { index: O, overflows: L }, reset: { placement: W } }; let E = (k = L.filter((D) => D.overflows[0] <= 0).sort((D, b) => D.overflows[1] - b.overflows[1])[0]) == null ? void 0 : k.placement; if (!E) switch (d) { case "bestFit": { var S; const D = (S = L.filter((b) => { if (R) { const M = Z(b.placement); return M === x || // Create a bias to the `y` side axis due to horizontal // reading directions favoring greater width. M === "y"; } return !0; }).map((b) => [b.placement, b.overflows.filter((M) => M > 0).reduce((M, V) => M + V, 0)]).sort((b, M) => b[1] - M[1])[0]) == null ? void 0 : S[0]; D && (E = D); break; } case "initialPlacement": E = c; break; } if (i !== E) return { reset: { placement: E } }; } return {}; } }; }; function Vt(t, e) { return { top: t.top - e.height, right: t.right - e.width, bottom: t.bottom - e.height, left: t.left - e.width }; } function zt(t) { return Te.some((e) => t[e] >= 0); } const Ve = function(t) { return t === void 0 && (t = {}), { name: "hide", options: t, async fn(e) { const { rects: n } = e, { strategy: o = "referenceHidden", ...i } = X(t, e); switch (o) { case "referenceHidden": { const r = await ot(e, { ...i, elementContext: "reference" }), s = Vt(r, n.reference); return { data: { referenceHiddenOffsets: s, referenceHidden: zt(s) } }; } case "escaped": { const r = await ot(e, { ...i, altBoundary: !0 }), s = Vt(r, n.floating); return { data: { escapedOffsets: s, escaped: zt(s) } }; } default: return {}; } } }; }; async function ze(t, e) { const { placement: n, platform: o, elements: i } = t, r = await (o.isRTL == null ? void 0 : o.isRTL(i.floating)), s = q(n), c = tt(n), a = Z(n) === "y", l = ["left", "top"].includes(s) ? -1 : 1, f = r && a ? -1 : 1, u = X(e, t); 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 c && typeof m == "number" && (d = c === "end" ? m * -1 : m), a ? { x: d * f, y: p * l } : { x: p * l, y: d * f }; } const Ie = function(t) { return t === void 0 && (t = 0), { name: "offset", options: t, async fn(e) { var n, o; const { x: i, y: r, placement: s, middlewareData: c } = e, a = await ze(e, t); return s === ((n = c.offset) == null ? void 0 : n.placement) && (o = c.arrow) != null && o.alignmentOffset ? {} : { x: i + a.x, y: r + a.y, data: { ...a, placement: s } }; } }; }, Ye = function(t) { return t === void 0 && (t = {}), { name: "shift", options: t, async fn(e) { const { x: n, y: o, placement: i } = e, { mainAxis: r = !0, crossAxis: s = !1, limiter: c = { fn: (w) => { let { x: g, y: x } = w; return { x: g, y: x }; } }, ...a } = X(t, e), l = { x: n, y: o }, f = await ot(e, a), u = Z(q(i)), p = Rt(u); let d = l[p], m = l[u]; if (r) { const w = p === "y" ? "top" : "left", g = p === "y" ? "bottom" : "right", x = d + f[w], A = d - f[g]; d = yt(x, d, A); } if (s) { const w = u === "y" ? "top" : "left", g = u === "y" ? "bottom" : "right", x = m + f[w], A = m - f[g]; m = yt(x, m, A); } const h = c.fn({ ...e, [p]: d, [u]: m }); return { ...h, data: { x: h.x - n, y: h.y - o, enabled: { [p]: r, [u]: s } } }; } }; }, je = function(t) { return t === void 0 && (t = {}), { options: t, fn(e) { const { x: n, y: o, placement: i, rects: r, middlewareData: s } = e, { offset: c = 0, mainAxis: a = !0, crossAxis: l = !0 } = X(t, e), f = { x: n, y: o }, u = Z(i), p = Rt(u); let d = f[p], m = f[u]; const h = X(c, e), w = typeof h == "number" ? { mainAxis: h, crossAxis: 0 } : { mainAxis: 0, crossAxis: 0, ...h }; if (a) { const A = p === "y" ? "height" : "width", y = r.reference[p] - r.floating[A] + w.mainAxis, v = r.reference[p] + r.reference[A] - w.mainAxis; d < y ? d = y : d > v && (d = v); } if (l) { var g, x; const A = p === "y" ? "width" : "height", y = ["top", "left"].includes(q(i)), v = r.reference[u] - r.floating[A] + (y && ((g = s.offset) == null ? void 0 : g[u]) || 0) + (y ? 0 : w.crossAxis), R = r.reference[u] + r.reference[A] + (y ? 0 : ((x = s.offset) == null ? void 0 : x[u]) || 0) - (y ? w.crossAxis : 0); m < v ? m = v : m > R && (m = R); } return { [p]: d, [u]: m }; } }; }, Xe = function(t) { return t === void 0 && (t = {}), { name: "size", options: t, async fn(e) { var n, o; const { placement: i, rects: r, platform: s, elements: c } = e, { apply: a = () => { }, ...l } = X(t, e), f = await ot(e, l), u = q(i), p = tt(i), d = Z(i) === "y", { width: m, height: h } = r.floating; let w, g; u === "top" || u === "bottom" ? (w = u, g = p === (await (s.isRTL == null ? void 0 : s.isRTL(c.floating)) ? "start" : "end") ? "left" : "right") : (g = u, w = p === "end" ? "top" : "bottom"); const x = h - f.top - f.bottom, A = m - f.left - f.right, y = U(h - f[w], x), v = U(m - f[g], A), R = !e.middlewareData.shift; let C = y, T = v; if ((n = e.middlewareData.shift) != null && n.enabled.x && (T = A), (o = e.middlewareData.shift) != null && o.enabled.y && (C = x), R && !p) { const L = N(f.left, 0), $ = N(f.right, 0), k = N(f.top, 0), S = N(f.bottom, 0); d ? T = m - 2 * (L !== 0 || $ !== 0 ? L + $ : N(f.left, f.right)) : C = h - 2 * (k !== 0 || S !== 0 ? k + S : N(f.top, f.bottom)); } await a({ ...e, availableWidth: T, availableHeight: C }); const F = await s.getDimensions(c.floating); return m !== F.width || h !== F.height ? { reset: { rects: !0 } } : {}; } }; }; function pt() { return typeof window < "u"; } function et(t) { return Kt(t) ? (t.nodeName || "").toLowerCase() : "#document"; } function H(t) { var e; return (t == null || (e = t.ownerDocument) == null ? void 0 : e.defaultView) || window; } function Y(t) { var e; return (e = (Kt(t) ? t.ownerDocument : t.document) || window.document) == null ? void 0 : e.documentElement; } function Kt(t) { return pt() ? t instanceof Node || t instanceof H(t).Node : !1; } function _(t) { return pt() ? t instanceof Element || t instanceof H(t).Element : !1; } function I(t) { return pt() ? t instanceof HTMLElement || t instanceof H(t).HTMLElement : !1; } function It(t) { return !pt() || typeof ShadowRoot > "u" ? !1 : t instanceof ShadowRoot || t instanceof H(t).ShadowRoot; } function rt(t) { const { overflow: e, overflowX: n, overflowY: o, display: i } = B(t); return /auto|scroll|overlay|hidden|clip/.test(e + o + n) && !["inline", "contents"].includes(i); } function qe(t) { return ["table", "td", "th"].includes(et(t)); } function ht(t) { return [":popover-open", ":modal"].some((e) => { try { return t.matches(e); } catch { return !1; } }); } function Ot(t) { const e = St(), n = _(t) ? B(t) : t; return ["transform", "translate", "scale", "rotate", "perspective"].some((o) => n[o] ? n[o] !== "none" : !1) || (n.containerType ? n.containerType !== "normal" : !1) || !e && (n.backdropFilter ? n.backdropFilter !== "none" : !1) || !e && (n.filter ? n.filter !== "none" : !1) || ["transform", "translate", "scale", "rotate", "perspective", "filter"].some((o) => (n.willChange || "").includes(o)) || ["paint", "layout", "strict", "content"].some((o) => (n.contain || "").includes(o)); } function Ue(t) { let e = K(t); for (; I(e) && !Q(e); ) { if (Ot(e)) return e; if (ht(e)) return null; e = K(e); } return null; } function St() { return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none"); } function Q(t) { return ["html", "body", "#document"].includes(et(t)); } function B(t) { return H(t).getComputedStyle(t); } function gt(t) { return _(t) ? { scrollLeft: t.scrollLeft, scrollTop: t.scrollTop } : { scrollLeft: t.scrollX, scrollTop: t.scrollY }; } function K(t) { if (et(t) === "html") return t; const e = ( // Step into the shadow DOM of the parent of a slotted node. t.assignedSlot || // DOM Element detected. t.parentNode || // ShadowRoot detected. It(t) && t.host || // Fallback. Y(t) ); return It(e) ? e.host : e; } function Gt(t) { const e = K(t); return Q(e) ? t.ownerDocument ? t.ownerDocument.body : t.body : I(e) && rt(e) ? e : Gt(e); } function it(t, e, n) { var o; e === void 0 && (e = []), n === void 0 && (n = !0); const i = Gt(t), r = i === ((o = t.ownerDocument) == null ? void 0 : o.body), s = H(i); if (r) { const c = At(s); return e.concat(s, s.visualViewport || [], rt(i) ? i : [], c && n ? it(c) : []); } return e.concat(i, it(i, [], n)); } function At(t) { return t.parent && Object.getPrototypeOf(t.parent) ? t.frameElement : null; } function Jt(t) { const e = B(t); let n = parseFloat(e.width) || 0, o = parseFloat(e.height) || 0; const i = I(t), r = i ? t.offsetWidth : n, s = i ? t.offsetHeight : o, c = ft(n) !== r || ft(o) !== s; return c && (n = r, o = s), { width: n, height: o, $: c }; } function Et(t) { return _(t) ? t : t.contextElement; } function J(t) { const e = Et(t); if (!I(e)) return z(1); const n = e.getBoundingClientRect(), { width: o, height: i, $: r } = Jt(e); let s = (r ? ft(n.width) : n.width) / o, c = (r ? ft(n.height) : n.height) / i; return (!s || !Number.isFinite(s)) && (s = 1), (!c || !Number.isFinite(c)) && (c = 1), { x: s, y: c }; } const Ze = /* @__PURE__ */ z(0); function Qt(t) { const e = H(t); return !St() || !e.visualViewport ? Ze : { x: e.visualViewport.offsetLeft, y: e.visualViewport.offsetTop }; } function Ke(t, e, n) { return e === void 0 && (e = !1), !n || e && n !== H(t) ? !1 : e; } function G(t, e, n, o) { e === void 0 && (e = !1), n === void 0 && (n = !1); const i = t.getBoundingClientRect(), r = Et(t); let s = z(1); e && (o ? _(o) && (s = J(o)) : s = J(t)); const c = Ke(r, n, o) ? Qt(r) : z(0); let a = (i.left + c.x) / s.x, l = (i.top + c.y) / s.y, f = i.width / s.x, u = i.height / s.y; if (r) { const p = H(r), d = o && _(o) ? H(o) : o; let m = p, h = At(m); for (; h && o && d !== m; ) { const w = J(h), g = h.getBoundingClientRect(), x = B(h), A = g.left + (h.clientLeft + parseFloat(x.paddingLeft)) * w.x, y = g.top + (h.clientTop + parseFloat(x.paddingTop)) * w.y; a *= w.x, l *= w.y, f *= w.x, u *= w.y, a += A, l += y, m = H(h), h = At(m); } } return dt({ width: f, height: u, x: a, y: l }); } function Dt(t, e) { const n = gt(t).scrollLeft; return e ? e.left + n : G(Y(t)).left + n; } function te(t, e, n) { n === void 0 && (n = !1); const o = t.getBoundingClientRect(), i = o.left + e.scrollLeft - (n ? 0 : ( // RTL <body> scrollbar. Dt(t, o) )), r = o.top + e.scrollTop; return { x: i, y: r }; } function Ge(t) { let { elements: e, rect: n, offsetParent: o, strategy: i } = t; const r = i === "fixed", s = Y(o), c = e ? ht(e.floating) : !1; if (o === s || c && r) return n; let a = { scrollLeft: 0, scrollTop: 0 }, l = z(1); const f = z(0), u = I(o); if ((u || !u && !r) && ((et(o) !== "body" || rt(s)) && (a = gt(o)), I(o))) { const d = G(o); l = J(o), f.x = d.x + o.clientLeft, f.y = d.y + o.clientTop; } const p = s && !u && !r ? te(s, a, !0) : z(0); return { width: n.width * l.x, height: n.height * l.y, x: n.x * l.x - a.scrollLeft * l.x + f.x + p.x, y: n.y * l.y - a.scrollTop * l.y + f.y + p.y }; } function Je(t) { return Array.from(t.getClientRects()); } function Qe(t) { const e = Y(t), n = gt(t), o = t.ownerDocument.body, i = N(e.scrollWidth, e.clientWidth, o.scrollWidth, o.clientWidth), r = N(e.scrollHeight, e.clientHeight, o.scrollHeight, o.clientHeight); let s = -n.scrollLeft + Dt(t); const c = -n.scrollTop; return B(o).direction === "rtl" && (s += N(e.clientWidth, o.clientWidth) - i), { width: i, height: r, x: s, y: c }; } function tn(t, e) { const n = H(t), o = Y(t), i = n.visualViewport; let r = o.clientWidth, s = o.clientHeight, c = 0, a = 0; if (i) { r = i.width, s = i.height; const l = St(); (!l || l && e === "fixed") && (c = i.offsetLeft, a = i.offsetTop); } return { width: r, height: s, x: c, y: a }; } function en(t, e) { const n = G(t, !0, e === "fixed"), o = n.top + t.clientTop, i = n.left + t.clientLeft, r = I(t) ? J(t) : z(1), s = t.clientWidth * r.x, c = t.clientHeight * r.y, a = i * r.x, l = o * r.y; return { width: s, height: c, x: a, y: l }; } function Yt(t, e, n) { let o; if (e === "viewport") o = tn(t, n); else if (e === "document") o = Qe(Y(t)); else if (_(e)) o = en(e, n); else { const i = Qt(t); o = { x: e.x - i.x, y: e.y - i.y, width: e.width, height: e.height }; } return dt(o); } function ee(t, e) { const n = K(t); return n === e || !_(n) || Q(n) ? !1 : B(n).position === "fixed" || ee(n, e); } function nn(t, e) { const n = e.get(t); if (n) return n; let o = it(t, [], !1).filter((c) => _(c) && et(c) !== "body"), i = null; const r = B(t).position === "fixed"; let s = r ? K(t) : t; for (; _(s) && !Q(s); ) { const c = B(s), a = Ot(s); !a && c.position === "fixed" && (i = null), (r ? !a && !i : !a && c.position === "static" && !!i && ["absolute", "fixed"].includes(i.position) || rt(s) && !a && ee(t, s)) ? o = o.filter((f) => f !== s) : i = c, s = K(s); } return e.set(t, o), o; } function on(t) { let { element: e, boundary: n, rootBoundary: o, strategy: i } = t; const s = [...n === "clippingAncestors" ? ht(e) ? [] : nn(e, this._c) : [].concat(n), o], c = s[0], a = s.reduce((l, f) => { const u = Yt(e, f, i); return l.top = N(u.top, l.top), l.right = U(u.right, l.right), l.bottom = U(u.bottom, l.bottom), l.left = N(u.left, l.left), l; }, Yt(e, c, i)); return { width: a.right - a.left, height: a.bottom - a.top, x: a.left, y: a.top }; } function rn(t) { const { width: e, height: n } = Jt(t); return { width: e, height: n }; } function sn(t, e, n) { const o = I(e), i = Y(e), r = n === "fixed", s = G(t, !0, r, e); let c = { scrollLeft: 0, scrollTop: 0 }; const a = z(0); if (o || !o && !r) if ((et(e) !== "body" || rt(i)) && (c = gt(e)), o) { const p = G(e, !0, r, e); a.x = p.x + e.clientLeft, a.y = p.y + e.clientTop; } else i && (a.x = Dt(i)); const l = i && !o && !r ? te(i, c) : z(0), f = s.left + c.scrollLeft - a.x - l.x, u = s.top + c.scrollTop - a.y - l.y; return { x: f, y: u, width: s.width, height: s.height }; } function wt(t) { return B(t).position === "static"; } function jt(t, e) { if (!I(t) || B(t).position === "fixed") return null; if (e) return e(t); let n = t.offsetParent; return Y(t) === n && (n = n.ownerDocument.body), n; } function ne(t, e) { const n = H(t); if (ht(t)) return n; if (!I(t)) { let i = K(t); for (; i && !Q(i); ) { if (_(i) && !wt(i)) return i; i = K(i); } return n; } let o = jt(t, e); for (; o && qe(o) && wt(o); ) o = jt(o, e); return o && Q(o) && wt(o) && !Ot(o) ? n : o || Ue(t) || n; } const cn = async function(t) { const e = this.getOffsetParent || ne, n = this.getDimensions, o = await n(t.floating); return { reference: sn(t.reference, await e(t.floating), t.strategy), floating: { x: 0, y: 0, width: o.width, height: o.height } }; }; function ln(t) { return B(t).direction === "rtl"; } const an = { convertOffsetParentRelativeRectToViewportRelativeRect: Ge, getDocumentElement: Y, getClippingRect: on, getOffsetParent: ne, getElementRects: cn, getClientRects: Je, getDimensions: rn, getScale: J, isElement: _, isRTL: ln }; function oe(t, e) { return t.x === e.x && t.y === e.y && t.width === e.width && t.height === e.height; } function fn(t, e) { let n = null, o; const i = Y(t); function r() { var c; clearTimeout(o), (c = n) == null || c.disconnect(), n = null; } function s(c, a) { c === void 0 && (c = !1), a === void 0 && (a = 1), r(); const l = t.getBoundingClientRect(), { left: f, top: u, width: p, height: d } = l; if (c || e(), !p || !d) return; const m = lt(u), h = lt(i.clientWidth - (f + p)), w = lt(i.clientHeight - (u + d)), g = lt(f), A = { rootMargin: -m + "px " + -h + "px " + -w + "px " + -g + "px", threshold: N(0, U(1, a)) || 1 }; let y = !0; function v(R) { const C = R[0].intersectionRatio; if (C !== a) { if (!y) return s(); C ? s(!1, C) : o = setTimeout(() => { s(!1, 1e-7); }, 1e3); } C === 1 && !oe(l, t.getBoundingClientRect()) && s(), y = !1; } try { n = new IntersectionObserver(v, { ...A, // Handle <iframe>s root: i.ownerDocument }); } catch { n = new IntersectionObserver(v, A); } n.observe(t); } return s(!0), r; } function un(t, e, n, o) { o === void 0 && (o = {}); const { ancestorScroll: i = !0, ancestorResize: r = !0, elementResize: s = typeof ResizeObserver == "function", layoutShift: c = typeof IntersectionObserver == "function", animationFrame: a = !1 } = o, l = Et(t), f = i || r ? [...l ? it(l) : [], ...it(e)] : []; f.forEach((g) => { i && g.addEventListener("scroll", n, { passive: !0 }), r && g.addEventListener("resize", n); }); const u = l && c ? fn(l, n) : null; let p = -1, d = null; s && (d = new ResizeObserver((g) => { let [x] = g; x && x.target === l && d && (d.unobserve(e), cancelAnimationFrame(p), p = requestAnimationFrame(() => { var A; (A = d) == null || A.observe(e); })), n(); }), l && !a && d.observe(l), d.observe(e)); let m, h = a ? G(t) : null; a && w(); function w() { const g = G(t); h && !oe(h, g) && n(), h = g, m = requestAnimationFrame(w); } return n(), () => { var g; f.forEach((x) => { i && x.removeEventListener("scroll", n), r && x.removeEventListener("resize", n); }), u == null || u(), (g = d) == null || g.disconnect(), d = null, a && cancelAnimationFrame(m); }; } const dn = Ie, mn = Ye, pn = Be, hn = Xe, gn = Ve, Xt = _e, wn = je, xn = (t, e, n) => { const o = /* @__PURE__ */ new Map(), i = { platform: an, ...n }, r = { ...i.platform, _c: o }; return We(t, e, { ...i, platform: r }); }; var at = typeof document < "u" ? Pe : Ce; function mt(t, e) { if (t === e) return !0; if (typeof t != typeof e) return !1; if (typeof t == "function" && t.toString() === e.toString()) return !0; let n, o, i; if (t && e && typeof t == "object") { if (Array.isArray(t)) { if (n = t.length, n !== e.length) return !1; for (o = n; o-- !== 0; ) if (!mt(t[o], e[o])) return !1; return !0; } if (i = Object.keys(t), n = i.length, n !== Object.keys(e).length) return !1; for (o = n; o-- !== 0; ) if (!{}.hasOwnProperty.call(e, i[o])) return !1; for (o = n; o-- !== 0; ) { const r = i[o]; if (!(r === "_owner" && t.$$typeof) && !mt(t[r], e[r])) return !1; } return !0; } return t !== t && e !== e; } function ie(t) { return typeof window > "u" ? 1 : (t.ownerDocument.defaultView || window).devicePixelRatio || 1; } function qt(t, e) { const n = ie(t); return Math.round(e * n) / n; } function xt(t) { const e = P.useRef(t); return at(() => { e.current = t; }), e; } function yn(t) { t === void 0 && (t = {}); const { placement: e = "bottom", strategy: n = "absolute", middleware: o = [], platform: i, elements: { reference: r, floating: s } = {}, transform: c = !0, whileElementsMounted: a, open: l } = t, [f, u] = P.useState({ x: 0, y: 0, strategy: n, placement: e, middlewareData: {}, isPositioned: !1 }), [p, d] = P.useState(o); mt(p, o) || d(o); const [m, h] = P.useState(null), [w, g] = P.useState(null), x = P.useCallback((b) => { b !== R.current && (R.current = b, h(b)); }, []), A = P.useCallback((b) => { b !== C.current && (C.current = b, g(b)); }, []), y = r || m, v = s || w, R = P.useRef(null), C = P.useRef(null), T = P.useRef(f), F = a != null, L = xt(a), $ = xt(i), k = xt(l), S = P.useCallback(() => { if (!R.current || !C.current) return; const b = { placement: e, strategy: n, middleware: p }; $.current && (b.platform = $.current), xn(R.current, C.current, b).then((M) => { const V = { ...M, // The floating element's position may be recomputed while it's closed // but still mounted (such as when transitioning out). To ensure // `isPositioned` will be `false` initially on the next open, avoid // setting it to `true` when `open === false` (must be specified). isPositioned: k.current !== !1 }; O.current && !mt(T.current, V) && (T.current = V, Oe.flushSync(() => { u(V); })); }); }, [p, e, n, $, k]); at(() => { l === !1 && T.current.isPositioned && (T.current.isPositioned = !1, u((b) => ({ ...b, isPositioned: !1 }))); }, [l]); const O = P.useRef(!1); at(() => (O.current = !0, () => { O.current = !1; }), []), at(() => { if (y && (R.current = y), v && (C.current = v), y && v) { if (L.current) return L.current(y, v, S); S(); } }, [y, v, S, L, F]); const W = P.useMemo(() => ({ reference: R, floating: C, setReference: x, setFloating: A }), [x, A]), E = P.useMemo(() => ({ reference: y, floating: v }), [y, v]), D = P.useMemo(() => { const b = { position: n, left: 0, top: 0 }; if (!E.floating) return b; const M = qt(E.floating, f.x), V = qt(E.floating, f.y); return c ? { ...b, transform: "translate(" + M + "px, " + V + "px)", ...ie(E.floating) >= 1.5 && { willChange: "transform" } } : { position: n, left: M, top: V }; }, [n, c, E.floating, f.x, f.y]); return P.useMemo(() => ({ ...f, update: S, refs: W, elements: E, floatingStyles: D }), [f, S, W, E, D]); } const vn = (t) => { function e(n) { return {}.hasOwnProperty.call(n, "current"); } return { name: "arrow", options: t, fn(n) { const { element: o, padding: i } = typeof t == "function" ? t(n) : t; return o && e(o) ? o.current != null ? Xt({ element: o.current, padding: i }).fn(n) : {} : o ? Xt({ element: o, padding: i }).fn(n) : {}; } }; }, An = (t, e) => ({ ...dn(t), options: [t, e] }), bn = (t, e) => ({ ...mn(t), options: [t, e] }), Rn = (t, e) => ({ ...wn(t), options: [t, e] }), Pn = (t, e) => ({ ...pn(t), options: [t, e] }), Cn = (t, e) => ({ ...hn(t), options: [t, e] }), On = (t, e) => ({ ...gn(t), options: [t, e] }), Sn = (t, e) => ({ ...vn(t), options: [t, e] }); var En = "Arrow", re = P.forwardRef((t, e) => { const { children: n, width: o = 10, height: i = 5, ...r } = t; return /* @__PURE__ */ j( bt.svg, { ...r, ref: e, width: o, height: i, viewBox: "0 0 30 10", preserveAspectRatio: "none", children: t.asChild ? n : /* @__PURE__ */ j("polygon", { points: "0,0 30,0 15,10" }) } ); }); re.displayName = En; var Dn = re, Tt = "Popper", [se, zn] = Se(Tt), [Tn, ce] = se(Tt), le = (t) => { const { __scopePopper: e, children: n } = t, [o, i] = P.useState(null); return /* @__PURE__ */ j(Tn, { scope: e, anchor: o, onAnchorChange: i, children: n }); }; le.displayName = Tt; var ae = "PopperAnchor", fe = P.forwardRef( (t, e) => { const { __scopePopper: n, virtualRef: o, ...i } = t, r = ce(ae, n), s = P.useRef(null), c = Ut(e, s); return P.useEffect(() => { r.onAnchorChange((o == null ? void 0 : o.current) || s.current); }), o ? null : /* @__PURE__ */ j(bt.div, { ...i, ref: c }); } ); fe.displayName = ae; var Lt = "PopperContent", [Ln, Mn] = se(Lt), ue = P.forwardRef( (t, e) => { var Mt, $t, kt, Ft, Nt, Ht; const { __scopePopper: n, side: o = "bottom", sideOffset: i = 0, align: r = "center", alignOffset: s = 0, arrowPadding: c = 0, avoidCollisions: a = !0, collisionBoundary: l = [], collisionPadding: f = 0, sticky: u = "partial", hideWhenDetached: p = !1, updatePositionStrategy: d = "optimized", onPlaced: m, ...h } = t, w = ce(Lt, n), [g, x] = P.useState(null), A = Ut(e, (nt) => x(nt)), [y, v] = P.useState(null), R = De(y), C = (R == null ? void 0 : R.width) ?? 0, T = (R == null ? void 0 : R.height) ?? 0, F = o + (r !== "center" ? "-" + r : ""), L = typeof f == "number" ? f : { top: 0, right: 0, bottom: 0, left: 0, ...f }, $ = Array.isArray(l) ? l : [l], k = $.length > 0, S = { padding: L, boundary: $.filter(kn), // with `strategy: 'fixed'`, this is the only way to get it to respect boundaries altBoundary: k }, { refs: O, floatingStyles: W, placement: E, isPositioned: D, middlewareData: b } = yn({ // default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues strategy: "fixed", placement: F, whileElementsMounted: (...nt) => un(...nt, { animationFrame: d === "always" }), elements: { reference: w.anchor }, middleware: [ An({ mainAxis: i + T, alignmentAxis: s }), a && bn({ mainAxis: !0, crossAxis: !1, limiter: u === "partial" ? Rn() : void 0, ...S }), a && Pn({ ...S }), Cn({ ...S, apply: ({ elements: nt, rects: Wt, availableWidth: ve, availableHeight: Ae }) => { const { width: be, height: Re } = Wt.reference, ct = nt.floating.style; ct.setProperty("--radix-popper-available-width", `${ve}px`), ct.setProperty("--radix-popper-available-height", `${Ae}px`), ct.setProperty("--radix-popper-anchor-width", `${be}px`), ct.setProperty("--radix-popper-anchor-height", `${Re}px`); } }), y && Sn({ element: y, padding: c }), Fn({ arrowWidth: C, arrowHeight: T }), p && On({ strategy: "referenceHidden", ...S }) ] }), [M, V] = pe(E), st = Ee(m); _t(() => { D && (st == null || st()); }, [D, st]); const he = (Mt = b.arrow) == null ? void 0 : Mt.x, ge = ($t = b.arrow) == null ? void 0 : $t.y, we = ((kt = b.arrow) == null ? void 0 : kt.centerOffset) !== 0, [xe, ye] = P.useState(); return _t(() => { g && ye(window.getComputedStyle(g).zIndex); }, [g]), /* @__PURE__ */ j( "div", { ref: O.setFloating, "data-radix-popper-content-wrapper": "", style: { ...W, transform: D ? W.transform : "translate(0, -200%)", // keep off the page when measuring minWidth: "max-content", zIndex: xe, "--radix-popper-transform-origin": [ (Ft = b.transformOrigin) == null ? void 0 : Ft.x, (Nt = b.transformOrigin) == null ? void 0 : Nt.y ].join(" "), // hide the content if using the hide middleware and should be hidden // set visibility to hidden and disable pointer events so the UI behaves // as if the PopperContent isn't there at all ...((Ht = b.hide) == null ? void 0 : Ht.referenceHidden) && { visibility: "hidden", pointerEvents: "none" } }, dir: t.dir, children: /* @__PURE__ */ j( Ln, { scope: n, placedSide: M, onArrowChange: v, arrowX: he, arrowY: ge, shouldHideArrow: we, children: /* @__PURE__ */ j( bt.div, { "data-side": M, "data-align": V, ...h, ref: A, style: { ...h.style, // if the PopperContent hasn't been placed yet (not all measurements done) // we prevent animations so that users's animation don't kick in too early referring wrong sides animation: D ? void 0 : "none" } } ) } ) } ); } ); ue.displayName = Lt; var de = "PopperArrow", $n = { top: "bottom", right: "left", bottom: "top", left: "right" }, me = P.forwardRef(function(e, n) { const { __scopePopper: o, ...i } = e, r = Mn(de, o), s = $n[r.placedSide]; return ( // we have to use an extra wrapper because `ResizeObserver` (used by `useSize`) // doesn't report size as we'd expect on SVG elements. // it reports their bounding box which is effectively the largest path inside the SVG. /* @__PURE__ */ j( "span", { ref: r.onArrowChange, style: { position: "absolute", left: r.arrowX, top: r.arrowY, [s]: 0, transformOrigin: { top: "", right: "0 0", bottom: "center 0", left: "100% 0" }[r.placedSide], transform: { top: "translateY(100%)", right: "translateY(50%) rotate(90deg) translateX(-50%)", bottom: "rotate(180deg)", left: "translateY(50%) rotate(-90deg) translateX(50%)" }[r.placedSide], visibility: r.shouldHideArrow ? "hidden" : void 0 }, children: /* @__PURE__ */ j( Dn, { ...i, ref: n, style: { ...i.style, // ensures the element can be measured correctly (mostly for if SVG) display: "block" } } ) } ) ); }); me.displayName = de; function kn(t) { return t !== null; } var Fn = (t) => ({ name: "transformOrigin", options: t, fn(e) { var w, g, x; const { placement: n, rects: o, middlewareData: i } = e, s = ((w = i.arrow) == null ? void 0 : w.centerOffset) !== 0, c = s ? 0 : t.arrowWidth, a = s ? 0 : t.arrowHeight, [l, f] = pe(n), u = { start: "0%", center: "50%", end: "100%" }[f], p = (((g = i.arrow) == null ? void 0 : g.x) ?? 0) + c / 2, d = (((x = i.arrow) == null ? void 0 : x.y) ?? 0) + a / 2; let m = "", h = ""; return l === "bottom" ? (m = s ? u : `${p}px`, h = `${-a}px`) : l === "top" ? (m = s ? u : `${p}px`, h = `${o.floating.height + a}px`) : l === "right" ? (m = `${-a}px`, h = s ? u : `${d}px`) : l === "left" && (m = `${o.floating.width + a}px`, h = s ? u : `${d}px`), { data: { x: m, y: h } }; } }); function pe(t) { const [e, n = "center"] = t.split("-"); return [e, n]; } var In = le, Yn = fe, jn = ue, Xn = me; export { Yn as A, jn as C, In as R, Xn as a, zn as c };