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