UNPKG

@stanfordspezi/spezi-web-design-system

Version:

Stanford Biodesign Digital Health Spezi Web Design System

1,588 lines (1,587 loc) 43.3 kB
import * as R from "react"; import { useLayoutEffect as Re } from "react"; import * as Pe from "react-dom"; import { c as Xt, u as Yt } from "./index-D2LZVjSn.mjs"; import { jsx as _ } from "react/jsx-runtime"; import { c as Ce } from "./index-DFZozV_h.mjs"; import { u as Se } from "./index-0ioNhtNM.mjs"; import { u as Tt } from "./index-hURUNS5V.mjs"; import { u as Oe } from "./index-ejc2HQY3.mjs"; const Ee = ["top", "right", "bottom", "left"], Z = Math.min, W = Math.max, at = Math.round, ct = Math.floor, X = (t) => ({ x: t, y: t }), De = { left: "right", right: "left", bottom: "top", top: "bottom" }, Le = { start: "end", end: "start" }; function yt(t, e, n) { return W(t, Z(e, n)); } function q(t, e) { return typeof t == "function" ? t(e) : t; } function U(t) { return t.split("-")[0]; } function tt(t) { return t.split("-")[1]; } function At(t) { return t === "x" ? "y" : "x"; } function Rt(t) { return t === "y" ? "height" : "width"; } const Me = /* @__PURE__ */ new Set(["top", "bottom"]); function I(t) { return Me.has(U(t)) ? "y" : "x"; } function Pt(t) { return At(I(t)); } function Te(t, e, n) { n === void 0 && (n = !1); const o = tt(t), i = Pt(t), r = Rt(i); let s = i === "x" ? o === (n ? "end" : "start") ? "right" : "left" : o === "start" ? "bottom" : "top"; return e.reference[r] > e.floating[r] && (s = ft(s)), [s, ft(s)]; } function $e(t) { const e = ft(t); return [vt(t), e, vt(e)]; } function vt(t) { return t.replace(/start|end/g, (e) => Le[e]); } const $t = ["left", "right"], Nt = ["right", "left"], Ne = ["top", "bottom"], ke = ["bottom", "top"]; function Fe(t, e, n) { switch (t) { case "top": case "bottom": return n ? e ? Nt : $t : e ? $t : Nt; case "left": case "right": return e ? Ne : ke; default: return []; } } function We(t, e, n, o) { const i = tt(t); let r = Fe(U(t), n === "start", o); return i && (r = r.map((s) => s + "-" + i), e && (r = r.concat(r.map(vt)))), r; } function ft(t) { return t.replace(/left|right|bottom|top/g, (e) => De[e]); } function He(t) { return { top: 0, right: 0, bottom: 0, left: 0, ...t }; } function jt(t) { return typeof t != "number" ? He(t) : { top: t, right: t, bottom: t, left: t }; } function ut(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 kt(t, e, n) { let { reference: o, floating: i } = t; const r = I(e), s = Pt(e), c = Rt(s), l = U(e), a = 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 (l) { 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 && a ? -1 : 1); break; case "end": d[s] += p * (n && a ? -1 : 1); break; } return d; } const _e = async (t, e, n) => { const { placement: o = "bottom", strategy: i = "absolute", middleware: r = [], platform: s } = n, c = r.filter(Boolean), l = await (s.isRTL == null ? void 0 : s.isRTL(e)); let a = await s.getElementRects({ reference: t, floating: e, strategy: i }), { x: f, y: u } = kt(a, o, l), p = o, d = {}, m = 0; for (let h = 0; h < c.length; h++) { const { name: w, fn: g } = c[h], { x, y: b, data: y, reset: v } = await g({ x: f, y: u, initialPlacement: o, placement: p, strategy: i, middlewareData: d, rects: a, platform: s, elements: { reference: t, floating: e } }); f = x ?? f, u = b ?? u, d = { ...d, [w]: { ...d[w], ...y } }, v && m <= 50 && (m++, typeof v == "object" && (v.placement && (p = v.placement), v.rects && (a = v.rects === !0 ? await s.getElementRects({ reference: t, floating: e, strategy: i }) : v.rects), { x: f, y: u } = kt(a, p, l)), 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: l } = t, { boundary: a = "clippingAncestors", rootBoundary: f = "viewport", elementContext: u = "floating", altBoundary: p = !1, padding: d = 0 } = q(e, t), m = jt(d), w = c[p ? u === "floating" ? "reference" : "floating" : u], g = ut(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: a, rootBoundary: f, strategy: l })), x = u === "floating" ? { x: o, y: i, width: s.floating.width, height: s.floating.height } : s.reference, b = await (r.getOffsetParent == null ? void 0 : r.getOffsetParent(c.floating)), y = await (r.isElement == null ? void 0 : r.isElement(b)) ? await (r.getScale == null ? void 0 : r.getScale(b)) || { x: 1, y: 1 } : { x: 1, y: 1 }, v = ut(r.convertOffsetParentRelativeRectToViewportRelativeRect ? await r.convertOffsetParentRelativeRectToViewportRelativeRect({ elements: c, rect: x, offsetParent: b, strategy: l }) : 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 Be = (t) => ({ name: "arrow", options: t, async fn(e) { const { x: n, y: o, placement: i, rects: r, platform: s, elements: c, middlewareData: l } = e, { element: a, padding: f = 0 } = q(t, e) || {}; if (a == null) return {}; const u = jt(f), p = { x: n, y: o }, d = Pt(i), m = Rt(d), h = await s.getDimensions(a), w = d === "y", g = w ? "top" : "left", x = w ? "bottom" : "right", b = w ? "clientHeight" : "clientWidth", y = r.reference[m] + r.reference[d] - p[d] - r.floating[m], v = p[d] - r.reference[d], C = await (s.getOffsetParent == null ? void 0 : s.getOffsetParent(a)); let P = C ? C[b] : 0; (!P || !await (s.isElement == null ? void 0 : s.isElement(C))) && (P = c.floating[b] || r.floating[m]); const M = y / 2 - v / 2, k = P / 2 - h[m] / 2 - 1, L = Z(u[g], k), $ = Z(u[x], k), N = L, O = P - h[m] - $, S = P / 2 - h[m] / 2 + M, F = yt(N, S, O), E = !l.arrow && tt(i) != null && S !== F && r.reference[m] / 2 - (S < N ? L : $) - h[m] / 2 < 0, D = E ? S < N ? S - N : S - O : 0; return { [d]: p[d] + D, data: { [d]: F, centerOffset: S - F - D, ...E && { alignmentOffset: D } }, reset: E }; } }), Ve = 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: l, elements: a } = e, { mainAxis: f = !0, crossAxis: u = !0, fallbackPlacements: p, fallbackStrategy: d = "bestFit", fallbackAxisSideDirection: m = "none", flipAlignment: h = !0, ...w } = q(t, e); if ((n = r.arrow) != null && n.alignmentOffset) return {}; const g = U(i), x = I(c), b = U(c) === c, y = await (l.isRTL == null ? void 0 : l.isRTL(a.floating)), v = p || (b || !h ? [ft(c)] : $e(c)), C = m !== "none"; !p && C && v.push(...We(c, h, m, y)); const P = [c, ...v], M = await ot(e, w), k = []; let L = ((o = r.flip) == null ? void 0 : o.overflows) || []; if (f && k.push(M[g]), u) { const S = Te(i, s, y); k.push(M[S[0]], M[S[1]]); } if (L = [...L, { placement: i, overflows: k }], !k.every((S) => S <= 0)) { var $, N; const S = ((($ = r.flip) == null ? void 0 : $.index) || 0) + 1, F = P[S]; if (F && (!(u === "alignment" ? x !== I(F) : !1) || // We leave the current main axis only if every placement on that axis // overflows the main axis. L.every((A) => I(A.placement) === x ? A.overflows[0] > 0 : !0))) return { data: { index: S, overflows: L }, reset: { placement: F } }; let E = (N = L.filter((D) => D.overflows[0] <= 0).sort((D, A) => D.overflows[1] - A.overflows[1])[0]) == null ? void 0 : N.placement; if (!E) switch (d) { case "bestFit": { var O; const D = (O = L.filter((A) => { if (C) { const T = I(A.placement); return T === x || // Create a bias to the `y` side axis due to horizontal // reading directions favoring greater width. T === "y"; } return !0; }).map((A) => [A.placement, A.overflows.filter((T) => T > 0).reduce((T, z) => T + z, 0)]).sort((A, T) => A[1] - T[1])[0]) == null ? void 0 : O[0]; D && (E = D); break; } case "initialPlacement": E = c; break; } if (i !== E) return { reset: { placement: E } }; } return {}; } }; }; function Ft(t, e) { return { top: t.top - e.height, right: t.right - e.width, bottom: t.bottom - e.height, left: t.left - e.width }; } function Wt(t) { return Ee.some((e) => t[e] >= 0); } const ze = function(t) { return t === void 0 && (t = {}), { name: "hide", options: t, async fn(e) { const { rects: n } = e, { strategy: o = "referenceHidden", ...i } = q(t, e); switch (o) { case "referenceHidden": { const r = await ot(e, { ...i, elementContext: "reference" }), s = Ft(r, n.reference); return { data: { referenceHiddenOffsets: s, referenceHidden: Wt(s) } }; } case "escaped": { const r = await ot(e, { ...i, altBoundary: !0 }), s = Ft(r, n.floating); return { data: { escapedOffsets: s, escaped: Wt(s) } }; } default: return {}; } } }; }, qt = /* @__PURE__ */ new Set(["left", "top"]); async function Ie(t, e) { const { placement: n, platform: o, elements: i } = t, r = await (o.isRTL == null ? void 0 : o.isRTL(i.floating)), s = U(n), c = tt(n), l = I(n) === "y", a = qt.has(s) ? -1 : 1, f = r && l ? -1 : 1, u = q(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), l ? { x: d * f, y: p * a } : { x: p * a, y: d * f }; } const Xe = 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, l = await Ie(e, t); return s === ((n = c.offset) == null ? void 0 : n.placement) && (o = c.arrow) != null && o.alignmentOffset ? {} : { x: i + l.x, y: r + l.y, data: { ...l, 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 }; } }, ...l } = q(t, e), a = { x: n, y: o }, f = await ot(e, l), u = I(U(i)), p = At(u); let d = a[p], m = a[u]; if (r) { const w = p === "y" ? "top" : "left", g = p === "y" ? "bottom" : "right", x = d + f[w], b = d - f[g]; d = yt(x, d, b); } if (s) { const w = u === "y" ? "top" : "left", g = u === "y" ? "bottom" : "right", x = m + f[w], b = m - f[g]; m = yt(x, m, b); } 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: l = !0, crossAxis: a = !0 } = q(t, e), f = { x: n, y: o }, u = I(i), p = At(u); let d = f[p], m = f[u]; const h = q(c, e), w = typeof h == "number" ? { mainAxis: h, crossAxis: 0 } : { mainAxis: 0, crossAxis: 0, ...h }; if (l) { const b = p === "y" ? "height" : "width", y = r.reference[p] - r.floating[b] + w.mainAxis, v = r.reference[p] + r.reference[b] - w.mainAxis; d < y ? d = y : d > v && (d = v); } if (a) { var g, x; const b = p === "y" ? "width" : "height", y = qt.has(U(i)), v = r.reference[u] - r.floating[b] + (y && ((g = s.offset) == null ? void 0 : g[u]) || 0) + (y ? 0 : w.crossAxis), C = r.reference[u] + r.reference[b] + (y ? 0 : ((x = s.offset) == null ? void 0 : x[u]) || 0) - (y ? w.crossAxis : 0); m < v ? m = v : m > C && (m = C); } return { [p]: d, [u]: m }; } }; }, qe = 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: l = () => { }, ...a } = q(t, e), f = await ot(e, a), u = U(i), p = tt(i), d = I(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, b = m - f.left - f.right, y = Z(h - f[w], x), v = Z(m - f[g], b), C = !e.middlewareData.shift; let P = y, M = v; if ((n = e.middlewareData.shift) != null && n.enabled.x && (M = b), (o = e.middlewareData.shift) != null && o.enabled.y && (P = x), C && !p) { const L = W(f.left, 0), $ = W(f.right, 0), N = W(f.top, 0), O = W(f.bottom, 0); d ? M = m - 2 * (L !== 0 || $ !== 0 ? L + $ : W(f.left, f.right)) : P = h - 2 * (N !== 0 || O !== 0 ? N + O : W(f.top, f.bottom)); } await l({ ...e, availableWidth: M, availableHeight: P }); const k = await s.getDimensions(c.floating); return m !== k.width || h !== k.height ? { reset: { rects: !0 } } : {}; } }; }; function mt() { return typeof window < "u"; } function et(t) { return Ut(t) ? (t.nodeName || "").toLowerCase() : "#document"; } function H(t) { var e; return (t == null || (e = t.ownerDocument) == null ? void 0 : e.defaultView) || window; } function j(t) { var e; return (e = (Ut(t) ? t.ownerDocument : t.document) || window.document) == null ? void 0 : e.documentElement; } function Ut(t) { return mt() ? t instanceof Node || t instanceof H(t).Node : !1; } function B(t) { return mt() ? t instanceof Element || t instanceof H(t).Element : !1; } function Y(t) { return mt() ? t instanceof HTMLElement || t instanceof H(t).HTMLElement : !1; } function Ht(t) { return !mt() || typeof ShadowRoot > "u" ? !1 : t instanceof ShadowRoot || t instanceof H(t).ShadowRoot; } const Ue = /* @__PURE__ */ new Set(["inline", "contents"]); function rt(t) { const { overflow: e, overflowX: n, overflowY: o, display: i } = V(t); return /auto|scroll|overlay|hidden|clip/.test(e + o + n) && !Ue.has(i); } const Ze = /* @__PURE__ */ new Set(["table", "td", "th"]); function Ke(t) { return Ze.has(et(t)); } const Ge = [":popover-open", ":modal"]; function pt(t) { return Ge.some((e) => { try { return t.matches(e); } catch { return !1; } }); } const Je = ["transform", "translate", "scale", "rotate", "perspective"], Qe = ["transform", "translate", "scale", "rotate", "perspective", "filter"], tn = ["paint", "layout", "strict", "content"]; function Ct(t) { const e = St(), n = B(t) ? V(t) : t; return Je.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) || Qe.some((o) => (n.willChange || "").includes(o)) || tn.some((o) => (n.contain || "").includes(o)); } function en(t) { let e = K(t); for (; Y(e) && !Q(e); ) { if (Ct(e)) return e; if (pt(e)) return null; e = K(e); } return null; } function St() { return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none"); } const nn = /* @__PURE__ */ new Set(["html", "body", "#document"]); function Q(t) { return nn.has(et(t)); } function V(t) { return H(t).getComputedStyle(t); } function ht(t) { return B(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. Ht(t) && t.host || // Fallback. j(t) ); return Ht(e) ? e.host : e; } function Zt(t) { const e = K(t); return Q(e) ? t.ownerDocument ? t.ownerDocument.body : t.body : Y(e) && rt(e) ? e : Zt(e); } function it(t, e, n) { var o; e === void 0 && (e = []), n === void 0 && (n = !0); const i = Zt(t), r = i === ((o = t.ownerDocument) == null ? void 0 : o.body), s = H(i); if (r) { const c = bt(s); return e.concat(s, s.visualViewport || [], rt(i) ? i : [], c && n ? it(c) : []); } return e.concat(i, it(i, [], n)); } function bt(t) { return t.parent && Object.getPrototypeOf(t.parent) ? t.frameElement : null; } function Kt(t) { const e = V(t); let n = parseFloat(e.width) || 0, o = parseFloat(e.height) || 0; const i = Y(t), r = i ? t.offsetWidth : n, s = i ? t.offsetHeight : o, c = at(n) !== r || at(o) !== s; return c && (n = r, o = s), { width: n, height: o, $: c }; } function Ot(t) { return B(t) ? t : t.contextElement; } function J(t) { const e = Ot(t); if (!Y(e)) return X(1); const n = e.getBoundingClientRect(), { width: o, height: i, $: r } = Kt(e); let s = (r ? at(n.width) : n.width) / o, c = (r ? at(n.height) : n.height) / i; return (!s || !Number.isFinite(s)) && (s = 1), (!c || !Number.isFinite(c)) && (c = 1), { x: s, y: c }; } const on = /* @__PURE__ */ X(0); function Gt(t) { const e = H(t); return !St() || !e.visualViewport ? on : { x: e.visualViewport.offsetLeft, y: e.visualViewport.offsetTop }; } function rn(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 = Ot(t); let s = X(1); e && (o ? B(o) && (s = J(o)) : s = J(t)); const c = rn(r, n, o) ? Gt(r) : X(0); let l = (i.left + c.x) / s.x, a = (i.top + c.y) / s.y, f = i.width / s.x, u = i.height / s.y; if (r) { const p = H(r), d = o && B(o) ? H(o) : o; let m = p, h = bt(m); for (; h && o && d !== m; ) { const w = J(h), g = h.getBoundingClientRect(), x = V(h), b = g.left + (h.clientLeft + parseFloat(x.paddingLeft)) * w.x, y = g.top + (h.clientTop + parseFloat(x.paddingTop)) * w.y; l *= w.x, a *= w.y, f *= w.x, u *= w.y, l += b, a += y, m = H(h), h = bt(m); } } return ut({ width: f, height: u, x: l, y: a }); } function gt(t, e) { const n = ht(t).scrollLeft; return e ? e.left + n : G(j(t)).left + n; } function Jt(t, e) { const n = t.getBoundingClientRect(), o = n.left + e.scrollLeft - gt(t, n), i = n.top + e.scrollTop; return { x: o, y: i }; } function sn(t) { let { elements: e, rect: n, offsetParent: o, strategy: i } = t; const r = i === "fixed", s = j(o), c = e ? pt(e.floating) : !1; if (o === s || c && r) return n; let l = { scrollLeft: 0, scrollTop: 0 }, a = X(1); const f = X(0), u = Y(o); if ((u || !u && !r) && ((et(o) !== "body" || rt(s)) && (l = ht(o)), Y(o))) { const d = G(o); a = J(o), f.x = d.x + o.clientLeft, f.y = d.y + o.clientTop; } const p = s && !u && !r ? Jt(s, l) : X(0); return { width: n.width * a.x, height: n.height * a.y, x: n.x * a.x - l.scrollLeft * a.x + f.x + p.x, y: n.y * a.y - l.scrollTop * a.y + f.y + p.y }; } function cn(t) { return Array.from(t.getClientRects()); } function ln(t) { const e = j(t), n = ht(t), o = t.ownerDocument.body, i = W(e.scrollWidth, e.clientWidth, o.scrollWidth, o.clientWidth), r = W(e.scrollHeight, e.clientHeight, o.scrollHeight, o.clientHeight); let s = -n.scrollLeft + gt(t); const c = -n.scrollTop; return V(o).direction === "rtl" && (s += W(e.clientWidth, o.clientWidth) - i), { width: i, height: r, x: s, y: c }; } const _t = 25; function an(t, e) { const n = H(t), o = j(t), i = n.visualViewport; let r = o.clientWidth, s = o.clientHeight, c = 0, l = 0; if (i) { r = i.width, s = i.height; const f = St(); (!f || f && e === "fixed") && (c = i.offsetLeft, l = i.offsetTop); } const a = gt(o); if (a <= 0) { const f = o.ownerDocument, u = f.body, p = getComputedStyle(u), d = f.compatMode === "CSS1Compat" && parseFloat(p.marginLeft) + parseFloat(p.marginRight) || 0, m = Math.abs(o.clientWidth - u.clientWidth - d); m <= _t && (r -= m); } else a <= _t && (r += a); return { width: r, height: s, x: c, y: l }; } const fn = /* @__PURE__ */ new Set(["absolute", "fixed"]); function un(t, e) { const n = G(t, !0, e === "fixed"), o = n.top + t.clientTop, i = n.left + t.clientLeft, r = Y(t) ? J(t) : X(1), s = t.clientWidth * r.x, c = t.clientHeight * r.y, l = i * r.x, a = o * r.y; return { width: s, height: c, x: l, y: a }; } function Bt(t, e, n) { let o; if (e === "viewport") o = an(t, n); else if (e === "document") o = ln(j(t)); else if (B(e)) o = un(e, n); else { const i = Gt(t); o = { x: e.x - i.x, y: e.y - i.y, width: e.width, height: e.height }; } return ut(o); } function Qt(t, e) { const n = K(t); return n === e || !B(n) || Q(n) ? !1 : V(n).position === "fixed" || Qt(n, e); } function dn(t, e) { const n = e.get(t); if (n) return n; let o = it(t, [], !1).filter((c) => B(c) && et(c) !== "body"), i = null; const r = V(t).position === "fixed"; let s = r ? K(t) : t; for (; B(s) && !Q(s); ) { const c = V(s), l = Ct(s); !l && c.position === "fixed" && (i = null), (r ? !l && !i : !l && c.position === "static" && !!i && fn.has(i.position) || rt(s) && !l && Qt(t, s)) ? o = o.filter((f) => f !== s) : i = c, s = K(s); } return e.set(t, o), o; } function mn(t) { let { element: e, boundary: n, rootBoundary: o, strategy: i } = t; const s = [...n === "clippingAncestors" ? pt(e) ? [] : dn(e, this._c) : [].concat(n), o], c = s[0], l = s.reduce((a, f) => { const u = Bt(e, f, i); return a.top = W(u.top, a.top), a.right = Z(u.right, a.right), a.bottom = Z(u.bottom, a.bottom), a.left = W(u.left, a.left), a; }, Bt(e, c, i)); return { width: l.right - l.left, height: l.bottom - l.top, x: l.left, y: l.top }; } function pn(t) { const { width: e, height: n } = Kt(t); return { width: e, height: n }; } function hn(t, e, n) { const o = Y(e), i = j(e), r = n === "fixed", s = G(t, !0, r, e); let c = { scrollLeft: 0, scrollTop: 0 }; const l = X(0); function a() { l.x = gt(i); } if (o || !o && !r) if ((et(e) !== "body" || rt(i)) && (c = ht(e)), o) { const d = G(e, !0, r, e); l.x = d.x + e.clientLeft, l.y = d.y + e.clientTop; } else i && a(); r && !o && i && a(); const f = i && !o && !r ? Jt(i, c) : X(0), u = s.left + c.scrollLeft - l.x - f.x, p = s.top + c.scrollTop - l.y - f.y; return { x: u, y: p, width: s.width, height: s.height }; } function wt(t) { return V(t).position === "static"; } function Vt(t, e) { if (!Y(t) || V(t).position === "fixed") return null; if (e) return e(t); let n = t.offsetParent; return j(t) === n && (n = n.ownerDocument.body), n; } function te(t, e) { const n = H(t); if (pt(t)) return n; if (!Y(t)) { let i = K(t); for (; i && !Q(i); ) { if (B(i) && !wt(i)) return i; i = K(i); } return n; } let o = Vt(t, e); for (; o && Ke(o) && wt(o); ) o = Vt(o, e); return o && Q(o) && wt(o) && !Ct(o) ? n : o || en(t) || n; } const gn = async function(t) { const e = this.getOffsetParent || te, n = this.getDimensions, o = await n(t.floating); return { reference: hn(t.reference, await e(t.floating), t.strategy), floating: { x: 0, y: 0, width: o.width, height: o.height } }; }; function wn(t) { return V(t).direction === "rtl"; } const xn = { convertOffsetParentRelativeRectToViewportRelativeRect: sn, getDocumentElement: j, getClippingRect: mn, getOffsetParent: te, getElementRects: gn, getClientRects: cn, getDimensions: pn, getScale: J, isElement: B, isRTL: wn }; function ee(t, e) { return t.x === e.x && t.y === e.y && t.width === e.width && t.height === e.height; } function yn(t, e) { let n = null, o; const i = j(t); function r() { var c; clearTimeout(o), (c = n) == null || c.disconnect(), n = null; } function s(c, l) { c === void 0 && (c = !1), l === void 0 && (l = 1), r(); const a = t.getBoundingClientRect(), { left: f, top: u, width: p, height: d } = a; if (c || e(), !p || !d) return; const m = ct(u), h = ct(i.clientWidth - (f + p)), w = ct(i.clientHeight - (u + d)), g = ct(f), b = { rootMargin: -m + "px " + -h + "px " + -w + "px " + -g + "px", threshold: W(0, Z(1, l)) || 1 }; let y = !0; function v(C) { const P = C[0].intersectionRatio; if (P !== l) { if (!y) return s(); P ? s(!1, P) : o = setTimeout(() => { s(!1, 1e-7); }, 1e3); } P === 1 && !ee(a, t.getBoundingClientRect()) && s(), y = !1; } try { n = new IntersectionObserver(v, { ...b, // Handle <iframe>s root: i.ownerDocument }); } catch { n = new IntersectionObserver(v, b); } n.observe(t); } return s(!0), r; } function vn(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: l = !1 } = o, a = Ot(t), f = i || r ? [...a ? it(a) : [], ...it(e)] : []; f.forEach((g) => { i && g.addEventListener("scroll", n, { passive: !0 }), r && g.addEventListener("resize", n); }); const u = a && c ? yn(a, n) : null; let p = -1, d = null; s && (d = new ResizeObserver((g) => { let [x] = g; x && x.target === a && d && (d.unobserve(e), cancelAnimationFrame(p), p = requestAnimationFrame(() => { var b; (b = d) == null || b.observe(e); })), n(); }), a && !l && d.observe(a), d.observe(e)); let m, h = l ? G(t) : null; l && w(); function w() { const g = G(t); h && !ee(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?.(), (g = d) == null || g.disconnect(), d = null, l && cancelAnimationFrame(m); }; } const bn = Xe, An = Ye, Rn = Ve, Pn = qe, Cn = ze, zt = Be, Sn = je, On = (t, e, n) => { const o = /* @__PURE__ */ new Map(), i = { platform: xn, ...n }, r = { ...i.platform, _c: o }; return _e(t, e, { ...i, platform: r }); }; var En = typeof document < "u", Dn = function() { }, lt = En ? Re : Dn; function dt(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 (!dt(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) && !dt(t[r], e[r])) return !1; } return !0; } return t !== t && e !== e; } function ne(t) { return typeof window > "u" ? 1 : (t.ownerDocument.defaultView || window).devicePixelRatio || 1; } function It(t, e) { const n = ne(t); return Math.round(e * n) / n; } function xt(t) { const e = R.useRef(t); return lt(() => { e.current = t; }), e; } function Ln(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: l, open: a } = t, [f, u] = R.useState({ x: 0, y: 0, strategy: n, placement: e, middlewareData: {}, isPositioned: !1 }), [p, d] = R.useState(o); dt(p, o) || d(o); const [m, h] = R.useState(null), [w, g] = R.useState(null), x = R.useCallback((A) => { A !== C.current && (C.current = A, h(A)); }, []), b = R.useCallback((A) => { A !== P.current && (P.current = A, g(A)); }, []), y = r || m, v = s || w, C = R.useRef(null), P = R.useRef(null), M = R.useRef(f), k = l != null, L = xt(l), $ = xt(i), N = xt(a), O = R.useCallback(() => { if (!C.current || !P.current) return; const A = { placement: e, strategy: n, middleware: p }; $.current && (A.platform = $.current), On(C.current, P.current, A).then((T) => { const z = { ...T, // 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: N.current !== !1 }; S.current && !dt(M.current, z) && (M.current = z, Pe.flushSync(() => { u(z); })); }); }, [p, e, n, $, N]); lt(() => { a === !1 && M.current.isPositioned && (M.current.isPositioned = !1, u((A) => ({ ...A, isPositioned: !1 }))); }, [a]); const S = R.useRef(!1); lt(() => (S.current = !0, () => { S.current = !1; }), []), lt(() => { if (y && (C.current = y), v && (P.current = v), y && v) { if (L.current) return L.current(y, v, O); O(); } }, [y, v, O, L, k]); const F = R.useMemo(() => ({ reference: C, floating: P, setReference: x, setFloating: b }), [x, b]), E = R.useMemo(() => ({ reference: y, floating: v }), [y, v]), D = R.useMemo(() => { const A = { position: n, left: 0, top: 0 }; if (!E.floating) return A; const T = It(E.floating, f.x), z = It(E.floating, f.y); return c ? { ...A, transform: "translate(" + T + "px, " + z + "px)", ...ne(E.floating) >= 1.5 && { willChange: "transform" } } : { position: n, left: T, top: z }; }, [n, c, E.floating, f.x, f.y]); return R.useMemo(() => ({ ...f, update: O, refs: F, elements: E, floatingStyles: D }), [f, O, F, E, D]); } const Mn = (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 ? zt({ element: o.current, padding: i }).fn(n) : {} : o ? zt({ element: o, padding: i }).fn(n) : {}; } }; }, Tn = (t, e) => ({ ...bn(t), options: [t, e] }), $n = (t, e) => ({ ...An(t), options: [t, e] }), Nn = (t, e) => ({ ...Sn(t), options: [t, e] }), kn = (t, e) => ({ ...Rn(t), options: [t, e] }), Fn = (t, e) => ({ ...Pn(t), options: [t, e] }), Wn = (t, e) => ({ ...Cn(t), options: [t, e] }), Hn = (t, e) => ({ ...Mn(t), options: [t, e] }); var _n = [ "a", "button", "div", "form", "h2", "h3", "img", "input", "label", "li", "nav", "ol", "p", "select", "span", "svg", "ul" ], Bn = _n.reduce((t, e) => { const n = Xt(`Primitive.${e}`), o = R.forwardRef((i, r) => { const { asChild: s, ...c } = i, l = s ? n : e; return typeof window < "u" && (window[/* @__PURE__ */ Symbol.for("radix-ui")] = !0), /* @__PURE__ */ _(l, { ...c, ref: r }); }); return o.displayName = `Primitive.${e}`, { ...t, [e]: o }; }, {}), Vn = "Arrow", oe = R.forwardRef((t, e) => { const { children: n, width: o = 10, height: i = 5, ...r } = t; return /* @__PURE__ */ _( Bn.svg, { ...r, ref: e, width: o, height: i, viewBox: "0 0 30 10", preserveAspectRatio: "none", children: t.asChild ? n : /* @__PURE__ */ _("polygon", { points: "0,0 30,0 15,10" }) } ); }); oe.displayName = Vn; var zn = oe, In = [ "a", "button", "div", "form", "h2", "h3", "img", "input", "label", "li", "nav", "ol", "p", "select", "span", "svg", "ul" ], ie = In.reduce((t, e) => { const n = Xt(`Primitive.${e}`), o = R.forwardRef((i, r) => { const { asChild: s, ...c } = i, l = s ? n : e; return typeof window < "u" && (window[/* @__PURE__ */ Symbol.for("radix-ui")] = !0), /* @__PURE__ */ _(l, { ...c, ref: r }); }); return o.displayName = `Primitive.${e}`, { ...t, [e]: o }; }, {}), Et = "Popper", [re, oo] = Ce(Et), [Xn, se] = re(Et), ce = (t) => { const { __scopePopper: e, children: n } = t, [o, i] = R.useState(null); return /* @__PURE__ */ _(Xn, { scope: e, anchor: o, onAnchorChange: i, children: n }); }; ce.displayName = Et; var le = "PopperAnchor", ae = R.forwardRef( (t, e) => { const { __scopePopper: n, virtualRef: o, ...i } = t, r = se(le, n), s = R.useRef(null), c = Yt(e, s), l = R.useRef(null); return R.useEffect(() => { const a = l.current; l.current = o?.current || s.current, a !== l.current && r.onAnchorChange(l.current); }), o ? null : /* @__PURE__ */ _(ie.div, { ...i, ref: c }); } ); ae.displayName = le; var Dt = "PopperContent", [Yn, jn] = re(Dt), fe = R.forwardRef( (t, e) => { const { __scopePopper: n, side: o = "bottom", sideOffset: i = 0, align: r = "center", alignOffset: s = 0, arrowPadding: c = 0, avoidCollisions: l = !0, collisionBoundary: a = [], collisionPadding: f = 0, sticky: u = "partial", hideWhenDetached: p = !1, updatePositionStrategy: d = "optimized", onPlaced: m, ...h } = t, w = se(Dt, n), [g, x] = R.useState(null), b = Yt(e, (nt) => x(nt)), [y, v] = R.useState(null), C = Oe(y), P = C?.width ?? 0, M = C?.height ?? 0, k = o + (r !== "center" ? "-" + r : ""), L = typeof f == "number" ? f : { top: 0, right: 0, bottom: 0, left: 0, ...f }, $ = Array.isArray(a) ? a : [a], N = $.length > 0, O = { padding: L, boundary: $.filter(Un), // with `strategy: 'fixed'`, this is the only way to get it to respect boundaries altBoundary: N }, { refs: S, floatingStyles: F, placement: E, isPositioned: D, middlewareData: A } = Ln({ // default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues strategy: "fixed", placement: k, whileElementsMounted: (...nt) => vn(...nt, { animationFrame: d === "always" }), elements: { reference: w.anchor }, middleware: [ Tn({ mainAxis: i + M, alignmentAxis: s }), l && $n({ mainAxis: !0, crossAxis: !1, limiter: u === "partial" ? Nn() : void 0, ...O }), l && kn({ ...O }), Fn({ ...O, apply: ({ elements: nt, rects: Mt, availableWidth: ye, availableHeight: ve }) => { const { width: be, height: Ae } = Mt.reference, st = nt.floating.style; st.setProperty("--radix-popper-available-width", `${ye}px`), st.setProperty("--radix-popper-available-height", `${ve}px`), st.setProperty("--radix-popper-anchor-width", `${be}px`), st.setProperty("--radix-popper-anchor-height", `${Ae}px`); } }), y && Hn({ element: y, padding: c }), Zn({ arrowWidth: P, arrowHeight: M }), p && Wn({ strategy: "referenceHidden", ...O }) ] }), [T, z] = me(E), Lt = Se(m); Tt(() => { D && Lt?.(); }, [D, Lt]); const pe = A.arrow?.x, he = A.arrow?.y, ge = A.arrow?.centerOffset !== 0, [we, xe] = R.useState(); return Tt(() => { g && xe(window.getComputedStyle(g).zIndex); }, [g]), /* @__PURE__ */ _( "div", { ref: S.setFloating, "data-radix-popper-content-wrapper": "", style: { ...F, transform: D ? F.transform : "translate(0, -200%)", // keep off the page when measuring minWidth: "max-content", zIndex: we, "--radix-popper-transform-origin": [ A.transformOrigin?.x, A.transformOrigin?.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 ...A.hide?.referenceHidden && { visibility: "hidden", pointerEvents: "none" } }, dir: t.dir, children: /* @__PURE__ */ _( Yn, { scope: n, placedSide: T, onArrowChange: v, arrowX: pe, arrowY: he, shouldHideArrow: ge, children: /* @__PURE__ */ _( ie.div, { "data-side": T, "data-align": z, ...h, ref: b, 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" } } ) } ) } ); } ); fe.displayName = Dt; var ue = "PopperArrow", qn = { top: "bottom", right: "left", bottom: "top", left: "right" }, de = R.forwardRef(function(e, n) { const { __scopePopper: o, ...i } = e, r = jn(ue, o), s = qn[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__ */ _( "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__ */ _( zn, { ...i, ref: n, style: { ...i.style, // ensures the element can be measured correctly (mostly for if SVG) display: "block" } } ) } ) ); }); de.displayName = ue; function Un(t) { return t !== null; } var Zn = (t) => ({ name: "transformOrigin", options: t, fn(e) { const { placement: n, rects: o, middlewareData: i } = e, s = i.arrow?.centerOffset !== 0, c = s ? 0 : t.arrowWidth, l = s ? 0 : t.arrowHeight, [a, f] = me(n), u = { start: "0%", center: "50%", end: "100%" }[f], p = (i.arrow?.x ?? 0) + c / 2, d = (i.arrow?.y ?? 0) + l / 2; let m = "", h = ""; return a === "bottom" ? (m = s ? u : `${p}px`, h = `${-l}px`) : a === "top" ? (m = s ? u : `${p}px`, h = `${o.floating.height + l}px`) : a === "right" ? (m = `${-l}px`, h = s ? u : `${d}px`) : a === "left" && (m = `${o.floating.width + l}px`, h = s ? u : `${d}px`), { data: { x: m, y: h } }; } }); function me(t) { const [e, n = "center"] = t.split("-"); return [e, n]; } var io = ce, ro = ae, so = fe, co = de; export { co as A, so as C, io as R, ro as a, oo as c };