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