import { h as e } from "./chunk.BlbRoQQ3.js";
import { $ as t, A as n, B as r, C as i, D as a, E as o, F as s, G as c, H as l, I as u, J as d, K as f, L as p, M as m, N as h, O as g, P as _, Q as v, R as y, S as b, T as x, U as S, V as C, W as w, X as T, Y as E, Z as D, _ as O, a1 as k, a2 as A, a3 as j, a4 as M, a5 as N, a6 as P, a7 as F, a8 as ee, ab as I, ac as L, ad as R, ae as te, af as z, ag as B, ai as ne, aj as re, ak as ie, am as V, an as ae, ao as oe, ap as se, ar as H, t as ce, v as le, x as U, y as ue, z as W } from "./system.DbMQd1I1.js";
import { b as de } from "./jsx-runtime.DF4K5VCp.js";
import * as G from "react";
import { useLayoutEffect as fe } from "react";
import * as pe from "react-dom";
import me from "react-dom";
function he(e, t = globalThis?.document) {
	let n = R(e);
	G.useEffect(() => {
		let e = (e) => {
			e.key === "Escape" && n(e);
		};
		return t.addEventListener("keydown", e, { capture: !0 }), () => t.removeEventListener("keydown", e, { capture: !0 });
	}, [n, t]);
}
var K = /* @__PURE__ */ e(de(), 1), ge = "DismissableLayer", _e = "dismissableLayer.update", ve = "dismissableLayer.pointerDownOutside", ye = "dismissableLayer.focusOutside", be, xe = G.createContext({
	layers: /* @__PURE__ */ new Set(),
	layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
	branches: /* @__PURE__ */ new Set()
}), Se = G.forwardRef((e, t) => {
	let { disableOutsidePointerEvents: n = !1, onEscapeKeyDown: r, onPointerDownOutside: i, onFocusOutside: a, onInteractOutside: o, onDismiss: s,...c } = e, l = G.useContext(xe), [u, d] = G.useState(null), f = u?.ownerDocument ?? globalThis?.document, [, p] = G.useState({}), m = H(t, (e) => d(e)), h = Array.from(l.layers), [g] = [...l.layersWithOutsidePointerEventsDisabled].slice(-1), _ = h.indexOf(g), v = u ? h.indexOf(u) : -1, y = l.layersWithOutsidePointerEventsDisabled.size > 0, b = v >= _, x = Te((e) => {
		let t = e.target, n = [...l.branches].some((e) => e.contains(t));
		!b || n || (i?.(e), o?.(e), e.defaultPrevented || s?.());
	}, f), S = Ee((e) => {
		let t = e.target, n = [...l.branches].some((e) => e.contains(t));
		n || (a?.(e), o?.(e), e.defaultPrevented || s?.());
	}, f);
	return he((e) => {
		let t = v === l.layers.size - 1;
		t && (r?.(e), !e.defaultPrevented && s && (e.preventDefault(), s()));
	}, f), G.useEffect(() => {
		if (u) return n && (l.layersWithOutsidePointerEventsDisabled.size === 0 && (be = f.body.style.pointerEvents, f.body.style.pointerEvents = "none"), l.layersWithOutsidePointerEventsDisabled.add(u)), l.layers.add(u), De(), () => {
			n && l.layersWithOutsidePointerEventsDisabled.size === 1 && (f.body.style.pointerEvents = be);
		};
	}, [
		u,
		f,
		n,
		l
	]), G.useEffect(() => () => {
		u && (l.layers.delete(u), l.layersWithOutsidePointerEventsDisabled.delete(u), De());
	}, [u, l]), G.useEffect(() => {
		let e = () => p({});
		return document.addEventListener(_e, e), () => document.removeEventListener(_e, e);
	}, []), /* @__PURE__ */ (0, K.jsx)(V.div, {
		...c,
		ref: m,
		style: {
			pointerEvents: y ? b ? "auto" : "none" : void 0,
			...e.style
		},
		onFocusCapture: B(e.onFocusCapture, S.onFocusCapture),
		onBlurCapture: B(e.onBlurCapture, S.onBlurCapture),
		onPointerDownCapture: B(e.onPointerDownCapture, x.onPointerDownCapture)
	});
});
Se.displayName = ge;
var Ce = "DismissableLayerBranch", we = G.forwardRef((e, t) => {
	let n = G.useContext(xe), r = G.useRef(null), i = H(t, r);
	return G.useEffect(() => {
		let e = r.current;
		if (e) return n.branches.add(e), () => {
			n.branches.delete(e);
		};
	}, [n.branches]), /* @__PURE__ */ (0, K.jsx)(V.div, {
		...e,
		ref: i
	});
});
we.displayName = Ce;
function Te(e, t = globalThis?.document) {
	let n = R(e), r = G.useRef(!1), i = G.useRef(() => {});
	return G.useEffect(() => {
		let e = (e) => {
			if (e.target && !r.current) {
				let r = function() {
					Oe(ve, n, a, { discrete: !0 });
				}, a = { originalEvent: e };
				e.pointerType === "touch" ? (t.removeEventListener("click", i.current), i.current = r, t.addEventListener("click", i.current, { once: !0 })) : r();
			} else t.removeEventListener("click", i.current);
			r.current = !1;
		}, a = window.setTimeout(() => {
			t.addEventListener("pointerdown", e);
		}, 0);
		return () => {
			window.clearTimeout(a), t.removeEventListener("pointerdown", e), t.removeEventListener("click", i.current);
		};
	}, [t, n]), { onPointerDownCapture: () => r.current = !0 };
}
function Ee(e, t = globalThis?.document) {
	let n = R(e), r = G.useRef(!1);
	return G.useEffect(() => {
		let e = (e) => {
			if (e.target && !r.current) {
				let t = { originalEvent: e };
				Oe(ye, n, t, { discrete: !1 });
			}
		};
		return t.addEventListener("focusin", e), () => t.removeEventListener("focusin", e);
	}, [t, n]), {
		onFocusCapture: () => r.current = !0,
		onBlurCapture: () => r.current = !1
	};
}
function De() {
	let e = new CustomEvent(_e);
	document.dispatchEvent(e);
}
function Oe(e, t, n, { discrete: r }) {
	let i = n.originalEvent.target, a = new CustomEvent(e, {
		bubbles: !1,
		cancelable: !0,
		detail: n
	});
	t && i.addEventListener(e, t, { once: !0 }), r ? ae(i, a) : i.dispatchEvent(a);
}
var ke = "Portal", Ae = G.forwardRef((e, t) => {
	let { container: n,...r } = e, [i, a] = G.useState(!1);
	z(() => a(!0), []);
	let o = n || i && globalThis?.document?.body;
	return o ? me.createPortal(/* @__PURE__ */ (0, K.jsx)(V.div, {
		...r,
		ref: t
	}), o) : null;
});
Ae.displayName = ke;
function je(e, t) {
	return G.useReducer((e, n) => {
		let r = t[e][n];
		return r ?? e;
	}, e);
}
var Me = (e) => {
	let { present: t, children: n } = e, r = Ne(t), i = typeof n == "function" ? n({ present: r.isPresent }) : G.Children.only(n), a = H(r.ref, Fe(i)), o = typeof n == "function";
	return o || r.isPresent ? G.cloneElement(i, { ref: a }) : null;
};
Me.displayName = "Presence";
function Ne(e) {
	let [t, n] = G.useState(), r = G.useRef({}), i = G.useRef(e), a = G.useRef("none"), o = e ? "mounted" : "unmounted", [s, c] = je(o, {
		mounted: {
			UNMOUNT: "unmounted",
			ANIMATION_OUT: "unmountSuspended"
		},
		unmountSuspended: {
			MOUNT: "mounted",
			ANIMATION_END: "unmounted"
		},
		unmounted: { MOUNT: "mounted" }
	});
	return G.useEffect(() => {
		let e = Pe(r.current);
		a.current = s === "mounted" ? e : "none";
	}, [s]), z(() => {
		let t = r.current, n = i.current, o = n !== e;
		if (o) {
			let r = a.current, o = Pe(t);
			if (e) c("MOUNT");
			else if (o === "none" || t?.display === "none") c("UNMOUNT");
			else {
				let e = r !== o;
				c(n && e ? "ANIMATION_OUT" : "UNMOUNT");
			}
			i.current = e;
		}
	}, [e, c]), z(() => {
		if (t) {
			let e = (e) => {
				let n = Pe(r.current), i = n.includes(e.animationName);
				e.target === t && i && pe.flushSync(() => c("ANIMATION_END"));
			}, n = (e) => {
				e.target === t && (a.current = Pe(r.current));
			};
			return t.addEventListener("animationstart", n), t.addEventListener("animationcancel", e), t.addEventListener("animationend", e), () => {
				t.removeEventListener("animationstart", n), t.removeEventListener("animationcancel", e), t.removeEventListener("animationend", e);
			};
		} else c("ANIMATION_END");
	}, [t, c]), {
		isPresent: ["mounted", "unmountSuspended"].includes(s),
		ref: G.useCallback((e) => {
			e && (r.current = getComputedStyle(e)), n(e);
		}, [])
	};
}
function Pe(e) {
	return e?.animationName || "none";
}
function Fe(e) {
	let t = Object.getOwnPropertyDescriptor(e.props, "ref")?.get, n = t && "isReactWarning" in t && t.isReactWarning;
	return n ? e.ref : (t = Object.getOwnPropertyDescriptor(e, "ref")?.get, n = t && "isReactWarning" in t && t.isReactWarning, n ? e.props.ref : e.props.ref || e.ref);
}
function Ie(e, n, r) {
	let { reference: i, floating: a } = e, o = k(n), s = x(n), c = C(s), l = t(n), u = o === "y", d = i.x + i.width / 2 - a.width / 2, f = i.y + i.height / 2 - a.height / 2, p = i[c] / 2 - a[c] / 2, m;
	switch (l) {
		case "top":
			m = {
				x: d,
				y: i.y - a.height
			};
			break;
		case "bottom":
			m = {
				x: d,
				y: i.y + i.height
			};
			break;
		case "right":
			m = {
				x: i.x + i.width,
				y: f
			};
			break;
		case "left":
			m = {
				x: i.x - a.width,
				y: f
			};
			break;
		default: m = {
			x: i.x,
			y: i.y
		};
	}
	switch (b(n)) {
		case "start":
			m[s] -= p * (r && u ? -1 : 1);
			break;
		case "end":
			m[s] += p * (r && u ? -1 : 1);
			break;
	}
	return m;
}
const Le = async (e, t, n) => {
	let { placement: r = "bottom", strategy: i = "absolute", middleware: a = [], platform: o } = n, s = a.filter(Boolean), c = await (o.isRTL == null ? void 0 : o.isRTL(t)), l = await o.getElementRects({
		reference: e,
		floating: t,
		strategy: i
	}), { x: u, y: d } = Ie(l, r, c), f = r, p = {}, m = 0;
	for (let n = 0; n < s.length; n++) {
		let { name: a, fn: h } = s[n], { x: g, y: _, data: v, reset: y } = await h({
			x: u,
			y: d,
			initialPlacement: r,
			placement: f,
			strategy: i,
			middlewareData: p,
			rects: l,
			platform: o,
			elements: {
				reference: e,
				floating: t
			}
		});
		u = g ?? u, d = _ ?? d, p = {
			...p,
			[a]: {
				...p[a],
				...v
			}
		}, y && m <= 50 && (m++, typeof y == "object" && (y.placement && (f = y.placement), y.rects && (l = y.rects === !0 ? await o.getElementRects({
			reference: e,
			floating: t,
			strategy: i
		}) : y.rects), {x: u, y: d} = Ie(l, f, c)), n = -1);
	}
	return {
		x: u,
		y: d,
		placement: f,
		strategy: i,
		middlewareData: p
	};
};
async function q(e, t) {
	var n;
	t === void 0 && (t = {});
	let { x: r, y: i, platform: a, rects: o, elements: s, strategy: c } = e, { boundary: l = "clippingAncestors", rootBoundary: u = "viewport", elementContext: d = "floating", altBoundary: f = !1, padding: p = 0 } = v(t, e), m = O(p), h = d === "floating" ? "reference" : "floating", g = s[f ? h : d], _ = M(await a.getClippingRect({
		element: (n = await (a.isElement == null ? void 0 : a.isElement(g))) ?? !0 ? g : g.contextElement || await (a.getDocumentElement == null ? void 0 : a.getDocumentElement(s.floating)),
		boundary: l,
		rootBoundary: u,
		strategy: c
	})), y = d === "floating" ? {
		x: r,
		y: i,
		width: o.floating.width,
		height: o.floating.height
	} : o.reference, b = await (a.getOffsetParent == null ? void 0 : a.getOffsetParent(s.floating)), x = await (a.isElement == null ? void 0 : a.isElement(b)) && await (a.getScale == null ? void 0 : a.getScale(b)) || {
		x: 1,
		y: 1
	}, S = M(a.convertOffsetParentRelativeRectToViewportRelativeRect ? await a.convertOffsetParentRelativeRectToViewportRelativeRect({
		elements: s,
		rect: y,
		offsetParent: b,
		strategy: c
	}) : y);
	return {
		top: (_.top - S.top + m.top) / x.y,
		bottom: (S.bottom - _.bottom + m.bottom) / x.y,
		left: (_.left - S.left + m.left) / x.x,
		right: (S.right - _.right + m.right) / x.x
	};
}
const Re = (e) => ({
	name: "arrow",
	options: e,
	async fn(t) {
		let { x: n, y: r, placement: i, rects: a, platform: o, elements: s, middlewareData: c } = t, { element: l, padding: u = 0 } = v(e, t) || {};
		if (l == null) return {};
		let d = O(u), f = {
			x: n,
			y: r
		}, p = x(i), m = C(p), h = await o.getDimensions(l), _ = p === "y", y = _ ? "top" : "left", S = _ ? "bottom" : "right", w = _ ? "clientHeight" : "clientWidth", T = a.reference[m] + a.reference[p] - f[p] - a.floating[m], E = f[p] - a.reference[p], D = await (o.getOffsetParent == null ? void 0 : o.getOffsetParent(l)), k = D ? D[w] : 0;
		(!k || !await (o.isElement == null ? void 0 : o.isElement(D))) && (k = s.floating[w] || a.floating[m]);
		let A = T / 2 - E / 2, M = k / 2 - h[m] / 2 - 1, N = j(d[y], M), P = j(d[S], M), F = N, ee = k - h[m] - P, I = k / 2 - h[m] / 2 + A, L = g(F, I, ee), R = !c.arrow && b(i) != null && I !== L && a.reference[m] / 2 - (I < F ? N : P) - h[m] / 2 < 0, te = R ? I < F ? I - F : I - ee : 0;
		return {
			[p]: f[p] + te,
			data: {
				[p]: L,
				centerOffset: I - L - te,
				...R && { alignmentOffset: te }
			},
			reset: R
		};
	}
}), ze = function(e) {
	return e === void 0 && (e = {}), {
		name: "flip",
		options: e,
		async fn(n) {
			var r, i;
			let { placement: a, middlewareData: o, rects: s, initialPlacement: c, platform: l, elements: u } = n, { mainAxis: d = !0, crossAxis: f = !0, fallbackPlacements: p, fallbackStrategy: m = "bestFit", fallbackAxisSideDirection: h = "none", flipAlignment: g = !0,..._ } = v(e, n);
			if ((r = o.arrow) != null && r.alignmentOffset) return {};
			let y = t(a), b = k(c), x = t(c) === c, C = await (l.isRTL == null ? void 0 : l.isRTL(u.floating)), T = p || (x || !g ? [D(c)] : w(c)), O = h !== "none";
			!p && O && T.push(...E(c, g, h, C));
			let A = [c, ...T], j = await q(n, _), M = [], N = (i = o.flip)?.overflows || [];
			if (d && M.push(j[y]), f) {
				let e = S(a, s, C);
				M.push(j[e[0]], j[e[1]]);
			}
			if (N = [...N, {
				placement: a,
				overflows: M
			}], !M.every((e) => e <= 0)) {
				var P, F;
				let e = ((P = o.flip)?.index || 0) + 1, t = A[e];
				if (t) {
					let n = f === "alignment" ? b !== k(t) : !1;
					if (!n || N.every((e) => e.overflows[0] > 0 && k(e.placement) === b)) return {
						data: {
							index: e,
							overflows: N
						},
						reset: { placement: t }
					};
				}
				let n = (F = N.filter((e) => e.overflows[0] <= 0).sort((e, t) => e.overflows[1] - t.overflows[1])[0])?.placement;
				if (!n) switch (m) {
					case "bestFit": {
						var ee;
						let e = (ee = N.filter((e) => {
							if (O) {
								let t = k(e.placement);
								return t === b || t === "y";
							}
							return !0;
						}).map((e) => [e.placement, e.overflows.filter((e) => e > 0).reduce((e, t) => e + t, 0)]).sort((e, t) => e[1] - t[1])[0])?.[0];
						e && (n = e);
						break;
					}
					case "initialPlacement":
						n = c;
						break;
				}
				if (a !== n) return { reset: { placement: n } };
			}
			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 Ve(e) {
	return P.some((t) => e[t] >= 0);
}
const He = function(e) {
	return e === void 0 && (e = {}), {
		name: "hide",
		options: e,
		async fn(t) {
			let { rects: n } = t, { strategy: r = "referenceHidden",...i } = v(e, t);
			switch (r) {
				case "referenceHidden": {
					let e = await q(t, {
						...i,
						elementContext: "reference"
					}), r = Be(e, n.reference);
					return { data: {
						referenceHiddenOffsets: r,
						referenceHidden: Ve(r)
					} };
				}
				case "escaped": {
					let e = await q(t, {
						...i,
						altBoundary: !0
					}), r = Be(e, n.floating);
					return { data: {
						escapedOffsets: r,
						escaped: Ve(r)
					} };
				}
				default: return {};
			}
		}
	};
};
async function Ue(e, n) {
	let { placement: r, platform: i, elements: a } = e, o = await (i.isRTL == null ? void 0 : i.isRTL(a.floating)), s = t(r), c = b(r), l = k(r) === "y", u = ["left", "top"].includes(s) ? -1 : 1, d = o && l ? -1 : 1, f = v(n, e), { mainAxis: p, crossAxis: m, alignmentAxis: h } = typeof f == "number" ? {
		mainAxis: f,
		crossAxis: 0,
		alignmentAxis: null
	} : {
		mainAxis: f.mainAxis || 0,
		crossAxis: f.crossAxis || 0,
		alignmentAxis: f.alignmentAxis
	};
	return c && typeof h == "number" && (m = c === "end" ? h * -1 : h), l ? {
		x: m * d,
		y: p * u
	} : {
		x: p * u,
		y: m * d
	};
}
const We = function(e) {
	return e === void 0 && (e = 0), {
		name: "offset",
		options: e,
		async fn(t) {
			var n, r;
			let { x: i, y: a, placement: o, middlewareData: s } = t, c = await Ue(t, e);
			return o === (n = s.offset)?.placement && (r = s.arrow) != null && r.alignmentOffset ? {} : {
				x: i + c.x,
				y: a + c.y,
				data: {
					...c,
					placement: o
				}
			};
		}
	};
}, Ge = function(e) {
	return e === void 0 && (e = {}), {
		name: "shift",
		options: e,
		async fn(n) {
			let { x: r, y: i, placement: a } = n, { mainAxis: o = !0, crossAxis: s = !1, limiter: c = { fn: (e) => {
				let { x: t, y: n } = e;
				return {
					x: t,
					y: n
				};
			} },...l } = v(e, n), u = {
				x: r,
				y: i
			}, d = await q(n, l), f = k(t(a)), p = T(f), m = u[p], h = u[f];
			if (o) {
				let e = p === "y" ? "top" : "left", t = p === "y" ? "bottom" : "right", n = m + d[e], r = m - d[t];
				m = g(n, m, r);
			}
			if (s) {
				let e = f === "y" ? "top" : "left", t = f === "y" ? "bottom" : "right", n = h + d[e], r = h - d[t];
				h = g(n, h, r);
			}
			let _ = c.fn({
				...n,
				[p]: m,
				[f]: h
			});
			return {
				..._,
				data: {
					x: _.x - r,
					y: _.y - i,
					enabled: {
						[p]: o,
						[f]: s
					}
				}
			};
		}
	};
}, Ke = function(e) {
	return e === void 0 && (e = {}), {
		options: e,
		fn(n) {
			let { x: r, y: i, placement: a, rects: o, middlewareData: s } = n, { offset: c = 0, mainAxis: l = !0, crossAxis: u = !0 } = v(e, n), d = {
				x: r,
				y: i
			}, f = k(a), p = T(f), m = d[p], h = d[f], g = v(c, n), _ = typeof g == "number" ? {
				mainAxis: g,
				crossAxis: 0
			} : {
				mainAxis: 0,
				crossAxis: 0,
				...g
			};
			if (l) {
				let e = p === "y" ? "height" : "width", t = o.reference[p] - o.floating[e] + _.mainAxis, n = o.reference[p] + o.reference[e] - _.mainAxis;
				m < t ? m = t : m > n && (m = n);
			}
			if (u) {
				var y, b;
				let e = p === "y" ? "width" : "height", n = ["top", "left"].includes(t(a)), r = o.reference[f] - o.floating[e] + (n && (y = s.offset)?.[f] || 0) + (n ? 0 : _.crossAxis), i = o.reference[f] + o.reference[e] + (n ? 0 : (b = s.offset)?.[f] || 0) - (n ? _.crossAxis : 0);
				h < r ? h = r : h > i && (h = i);
			}
			return {
				[p]: m,
				[f]: h
			};
		}
	};
}, qe = function(e) {
	return e === void 0 && (e = {}), {
		name: "size",
		options: e,
		async fn(n) {
			var r, i;
			let { placement: a, rects: o, platform: s, elements: c } = n, { apply: l = () => {},...u } = v(e, n), d = await q(n, u), f = t(a), p = b(a), m = k(a) === "y", { width: h, height: g } = o.floating, _, y;
			f === "top" || f === "bottom" ? (_ = f, y = p === (await (s.isRTL == null ? void 0 : s.isRTL(c.floating)) ? "start" : "end") ? "left" : "right") : (y = f, _ = p === "end" ? "top" : "bottom");
			let x = g - d.top - d.bottom, S = h - d.left - d.right, C = j(g - d[_], x), w = j(h - d[y], S), T = !n.middlewareData.shift, E = C, D = w;
			if ((r = n.middlewareData.shift) != null && r.enabled.x && (D = S), (i = n.middlewareData.shift) != null && i.enabled.y && (E = x), T && !p) {
				let e = A(d.left, 0), t = A(d.right, 0), n = A(d.top, 0), r = A(d.bottom, 0);
				m ? D = h - 2 * (e !== 0 || t !== 0 ? e + t : A(d.left, d.right)) : E = g - 2 * (n !== 0 || r !== 0 ? n + r : A(d.top, d.bottom));
			}
			await l({
				...n,
				availableWidth: D,
				availableHeight: E
			});
			let O = await s.getDimensions(c.floating);
			return h !== O.width || g !== O.height ? { reset: { rects: !0 } } : {};
		}
	};
};
function Je(e) {
	let t = U(e), n = parseFloat(t.width) || 0, r = parseFloat(t.height) || 0, i = u(e), a = i ? e.offsetWidth : n, o = i ? e.offsetHeight : r, s = N(n) !== a || N(r) !== o;
	return s && (n = a, r = o), {
		width: n,
		height: r,
		$: s
	};
}
function Ye(e) {
	return l(e) ? e : e.contextElement;
}
function J(e) {
	let t = Ye(e);
	if (!u(t)) return _(1);
	let n = t.getBoundingClientRect(), { width: r, height: i, $: a } = Je(t), o = (a ? N(n.width) : n.width) / r, s = (a ? N(n.height) : n.height) / i;
	return (!o || !Number.isFinite(o)) && (o = 1), (!s || !Number.isFinite(s)) && (s = 1), {
		x: o,
		y: s
	};
}
const Xe = /* @__PURE__ */ _(0);
function Ze(e) {
	let t = s(e);
	return !h() || !t.visualViewport ? Xe : {
		x: t.visualViewport.offsetLeft,
		y: t.visualViewport.offsetTop
	};
}
function Qe(e, t, n) {
	return t === void 0 && (t = !1), !n || t && n !== s(e) ? !1 : t;
}
function Y(e, t, r, i) {
	t === void 0 && (t = !1), r === void 0 && (r = !1);
	let a = e.getBoundingClientRect(), o = Ye(e), c = _(1);
	t && (i ? l(i) && (c = J(i)) : c = J(e));
	let u = Qe(o, r, i) ? Ze(o) : _(0), d = (a.left + u.x) / c.x, f = (a.top + u.y) / c.y, p = a.width / c.x, m = a.height / c.y;
	if (o) {
		let e = s(o), t = i && l(i) ? s(i) : i, r = e, a = n(r);
		for (; a && i && t !== r;) {
			let e = J(a), t = a.getBoundingClientRect(), i = U(a), o = t.left + (a.clientLeft + parseFloat(i.paddingLeft)) * e.x, c = t.top + (a.clientTop + parseFloat(i.paddingTop)) * e.y;
			d *= e.x, f *= e.y, p *= e.x, m *= e.y, d += o, f += c, r = s(a), a = n(r);
		}
	}
	return M({
		width: p,
		height: m,
		x: d,
		y: f
	});
}
function $e(e, t) {
	let n = i(e).scrollLeft;
	return t ? t.left + n : Y(W(e)).left + n;
}
function et(e, t, n) {
	n === void 0 && (n = !1);
	let r = e.getBoundingClientRect(), i = r.left + t.scrollLeft - (n ? 0 : $e(e, r)), a = r.top + t.scrollTop;
	return {
		x: i,
		y: a
	};
}
function tt(e) {
	let { elements: t, rect: n, offsetParent: a, strategy: o } = e, s = o === "fixed", c = W(a), l = t ? m(t.floating) : !1;
	if (a === c || l && s) return n;
	let d = {
		scrollLeft: 0,
		scrollTop: 0
	}, p = _(1), h = _(0), g = u(a);
	if ((g || !g && !s) && ((r(a) !== "body" || f(c)) && (d = i(a)), u(a))) {
		let e = Y(a);
		p = J(a), h.x = e.x + a.clientLeft, h.y = e.y + a.clientTop;
	}
	let v = c && !g && !s ? et(c, d, !0) : _(0);
	return {
		width: n.width * p.x,
		height: n.height * p.y,
		x: n.x * p.x - d.scrollLeft * p.x + h.x + v.x,
		y: n.y * p.y - d.scrollTop * p.y + h.y + v.y
	};
}
function nt(e) {
	return Array.from(e.getClientRects());
}
function rt(e) {
	let t = W(e), n = i(e), r = e.ownerDocument.body, a = A(t.scrollWidth, t.clientWidth, r.scrollWidth, r.clientWidth), o = A(t.scrollHeight, t.clientHeight, r.scrollHeight, r.clientHeight), s = -n.scrollLeft + $e(e), c = -n.scrollTop;
	return U(r).direction === "rtl" && (s += A(t.clientWidth, r.clientWidth) - a), {
		width: a,
		height: o,
		x: s,
		y: c
	};
}
function it(e, t) {
	let n = s(e), r = W(e), i = n.visualViewport, a = r.clientWidth, o = r.clientHeight, c = 0, l = 0;
	if (i) {
		a = i.width, o = i.height;
		let e = h();
		(!e || e && t === "fixed") && (c = i.offsetLeft, l = i.offsetTop);
	}
	return {
		width: a,
		height: o,
		x: c,
		y: l
	};
}
function at(e, t) {
	let n = Y(e, !0, t === "fixed"), r = n.top + e.clientTop, i = n.left + e.clientLeft, a = u(e) ? J(e) : _(1), o = e.clientWidth * a.x, s = e.clientHeight * a.y, c = i * a.x, l = r * a.y;
	return {
		width: o,
		height: s,
		x: c,
		y: l
	};
}
function ot(e, t, n) {
	let r;
	if (t === "viewport") r = it(e, n);
	else if (t === "document") r = rt(W(e));
	else if (l(t)) r = at(t, n);
	else {
		let n = Ze(e);
		r = {
			x: t.x - n.x,
			y: t.y - n.y,
			width: t.width,
			height: t.height
		};
	}
	return M(r);
}
function st(e, t) {
	let n = o(e);
	return n === t || !l(n) || d(n) ? !1 : U(n).position === "fixed" || st(n, t);
}
function ct(e, t) {
	let n = t.get(e);
	if (n) return n;
	let i = a(e, [], !1).filter((e) => l(e) && r(e) !== "body"), s = null, u = U(e).position === "fixed", p = u ? o(e) : e;
	for (; l(p) && !d(p);) {
		let t = U(p), n = c(p);
		!n && t.position === "fixed" && (s = null);
		let r = u ? !n && !s : !n && t.position === "static" && !!s && ["absolute", "fixed"].includes(s.position) || f(p) && !n && st(e, p);
		r ? i = i.filter((e) => e !== p) : s = t, p = o(p);
	}
	return t.set(e, i), i;
}
function lt(e) {
	let { element: t, boundary: n, rootBoundary: r, strategy: i } = e, a = n === "clippingAncestors" ? m(t) ? [] : ct(t, this._c) : [].concat(n), o = [...a, r], s = o[0], c = o.reduce((e, n) => {
		let r = ot(t, n, i);
		return e.top = A(r.top, e.top), e.right = j(r.right, e.right), e.bottom = j(r.bottom, e.bottom), e.left = A(r.left, e.left), e;
	}, ot(t, s, i));
	return {
		width: c.right - c.left,
		height: c.bottom - c.top,
		x: c.left,
		y: c.top
	};
}
function ut(e) {
	let { width: t, height: n } = Je(e);
	return {
		width: t,
		height: n
	};
}
function dt(e, t, n) {
	let a = u(t), o = W(t), s = n === "fixed", c = Y(e, !0, s, t), l = {
		scrollLeft: 0,
		scrollTop: 0
	}, d = _(0);
	function p() {
		d.x = $e(o);
	}
	if (a || !a && !s) if ((r(t) !== "body" || f(o)) && (l = i(t)), a) {
		let e = Y(t, !0, s, t);
		d.x = e.x + t.clientLeft, d.y = e.y + t.clientTop;
	} else o && p();
	s && !a && o && p();
	let m = o && !a && !s ? et(o, l) : _(0), h = c.left + l.scrollLeft - d.x - m.x, g = c.top + l.scrollTop - d.y - m.y;
	return {
		x: h,
		y: g,
		width: c.width,
		height: c.height
	};
}
function ft(e) {
	return U(e).position === "static";
}
function pt(e, t) {
	if (!u(e) || U(e).position === "fixed") return null;
	if (t) return t(e);
	let n = e.offsetParent;
	return W(e) === n && (n = n.ownerDocument.body), n;
}
function mt(e, t) {
	let n = s(e);
	if (m(e)) return n;
	if (!u(e)) {
		let t = o(e);
		for (; t && !d(t);) {
			if (l(t) && !ft(t)) return t;
			t = o(t);
		}
		return n;
	}
	let r = pt(e, t);
	for (; r && p(r) && ft(r);) r = pt(r, t);
	return r && d(r) && ft(r) && !c(r) ? n : r || ue(e) || n;
}
const ht = async function(e) {
	let t = this.getOffsetParent || mt, n = this.getDimensions, r = await n(e.floating);
	return {
		reference: dt(e.reference, await t(e.floating), e.strategy),
		floating: {
			x: 0,
			y: 0,
			width: r.width,
			height: r.height
		}
	};
};
function gt(e) {
	return U(e).direction === "rtl";
}
const _t = {
	convertOffsetParentRelativeRectToViewportRelativeRect: tt,
	getDocumentElement: W,
	getClippingRect: lt,
	getOffsetParent: mt,
	getElementRects: ht,
	getClientRects: nt,
	getDimensions: ut,
	getScale: J,
	isElement: l,
	isRTL: gt
};
function vt(e, t) {
	return e.x === t.x && e.y === t.y && e.width === t.width && e.height === t.height;
}
function yt(e, t) {
	let n = null, r, i = W(e);
	function a() {
		var e;
		clearTimeout(r), (e = n) == null || e.disconnect(), n = null;
	}
	function o(s, c) {
		s === void 0 && (s = !1), c === void 0 && (c = 1), a();
		let l = e.getBoundingClientRect(), { left: u, top: d, width: f, height: p } = l;
		if (s || t(), !f || !p) return;
		let m = y(d), h = y(i.clientWidth - (u + f)), g = y(i.clientHeight - (d + p)), _ = y(u), v = -m + "px " + -h + "px " + -g + "px " + -_ + "px", b = {
			rootMargin: v,
			threshold: A(0, j(1, c)) || 1
		}, x = !0;
		function S(t) {
			let n = t[0].intersectionRatio;
			if (n !== c) {
				if (!x) return o();
				n ? o(!1, n) : r = setTimeout(() => {
					o(!1, 1e-7);
				}, 1e3);
			}
			n === 1 && !vt(l, e.getBoundingClientRect()) && o(), x = !1;
		}
		try {
			n = new IntersectionObserver(S, {
				...b,
				root: i.ownerDocument
			});
		} catch {
			n = new IntersectionObserver(S, b);
		}
		n.observe(e);
	}
	return o(!0), a;
}
function bt(e, t, n, r) {
	r === void 0 && (r = {});
	let { ancestorScroll: i = !0, ancestorResize: o = !0, elementResize: s = typeof ResizeObserver == "function", layoutShift: c = typeof IntersectionObserver == "function", animationFrame: l = !1 } = r, u = Ye(e), d = i || o ? [...u ? a(u) : [], ...a(t)] : [];
	d.forEach((e) => {
		i && e.addEventListener("scroll", n, { passive: !0 }), o && e.addEventListener("resize", n);
	});
	let f = u && c ? yt(u, n) : null, p = -1, m = null;
	s && (m = new ResizeObserver((e) => {
		let [r] = e;
		r && r.target === u && m && (m.unobserve(t), cancelAnimationFrame(p), p = requestAnimationFrame(() => {
			var e;
			(e = m) == null || e.observe(t);
		})), n();
	}), u && !l && m.observe(u), m.observe(t));
	let h, g = l ? Y(e) : null;
	l && _();
	function _() {
		let t = Y(e);
		g && !vt(g, t) && n(), g = t, h = requestAnimationFrame(_);
	}
	return n(), () => {
		var e;
		d.forEach((e) => {
			i && e.removeEventListener("scroll", n), o && e.removeEventListener("resize", n);
		}), f?.(), (e = m) == null || e.disconnect(), m = null, l && cancelAnimationFrame(h);
	};
}
const xt = We, St = Ge, Ct = ze, wt = qe, Tt = He, Et = Re, Dt = Ke, Ot = (e, t, n) => {
	let r = /* @__PURE__ */ new Map(), i = {
		platform: _t,
		...n
	}, a = {
		...i.platform,
		_c: r
	};
	return Le(e, t, {
		...i,
		platform: a
	});
};
var kt = typeof document < "u", At = function() {}, jt = kt ? fe : At;
function Mt(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, i;
	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 (!Mt(e[r], t[r])) return !1;
			return !0;
		}
		if (i = Object.keys(e), n = i.length, n !== Object.keys(t).length) return !1;
		for (r = n; r-- !== 0;) if (!{}.hasOwnProperty.call(t, i[r])) return !1;
		for (r = n; r-- !== 0;) {
			let n = i[r];
			if (!(n === "_owner" && e.$$typeof) && !Mt(e[n], t[n])) return !1;
		}
		return !0;
	}
	return e !== e && t !== t;
}
function Nt(e) {
	if (typeof window > "u") return 1;
	let t = e.ownerDocument.defaultView || window;
	return t.devicePixelRatio || 1;
}
function Pt(e, t) {
	let n = Nt(e);
	return Math.round(t * n) / n;
}
function Ft(e) {
	let t = G.useRef(e);
	return jt(() => {
		t.current = e;
	}), t;
}
function It(e) {
	e === void 0 && (e = {});
	let { placement: t = "bottom", strategy: n = "absolute", middleware: r = [], platform: i, elements: { reference: a, floating: o } = {}, transform: s = !0, whileElementsMounted: c, open: l } = e, [u, d] = G.useState({
		x: 0,
		y: 0,
		strategy: n,
		placement: t,
		middlewareData: {},
		isPositioned: !1
	}), [f, p] = G.useState(r);
	Mt(f, r) || p(r);
	let [m, h] = G.useState(null), [g, _] = G.useState(null), v = G.useCallback((e) => {
		e !== S.current && (S.current = e, h(e));
	}, []), y = G.useCallback((e) => {
		e !== C.current && (C.current = e, _(e));
	}, []), b = a || m, x = o || g, S = G.useRef(null), C = G.useRef(null), w = G.useRef(u), T = c != null, E = Ft(c), D = Ft(i), O = Ft(l), k = G.useCallback(() => {
		if (!S.current || !C.current) return;
		let e = {
			placement: t,
			strategy: n,
			middleware: f
		};
		D.current && (e.platform = D.current), Ot(S.current, C.current, e).then((e) => {
			let t = {
				...e,
				isPositioned: O.current !== !1
			};
			A.current && !Mt(w.current, t) && (w.current = t, pe.flushSync(() => {
				d(t);
			}));
		});
	}, [
		f,
		t,
		n,
		D,
		O
	]);
	jt(() => {
		l === !1 && w.current.isPositioned && (w.current.isPositioned = !1, d((e) => ({
			...e,
			isPositioned: !1
		})));
	}, [l]);
	let A = G.useRef(!1);
	jt(() => (A.current = !0, () => {
		A.current = !1;
	}), []), jt(() => {
		if (b && (S.current = b), x && (C.current = x), b && x) {
			if (E.current) return E.current(b, x, k);
			k();
		}
	}, [
		b,
		x,
		k,
		E,
		T
	]);
	let j = G.useMemo(() => ({
		reference: S,
		floating: C,
		setReference: v,
		setFloating: y
	}), [v, y]), M = G.useMemo(() => ({
		reference: b,
		floating: x
	}), [b, x]), N = G.useMemo(() => {
		let e = {
			position: n,
			left: 0,
			top: 0
		};
		if (!M.floating) return e;
		let t = Pt(M.floating, u.x), r = Pt(M.floating, u.y);
		return s ? {
			...e,
			transform: "translate(" + t + "px, " + r + "px)",
			...Nt(M.floating) >= 1.5 && { willChange: "transform" }
		} : {
			position: n,
			left: t,
			top: r
		};
	}, [
		n,
		s,
		M.floating,
		u.x,
		u.y
	]);
	return G.useMemo(() => ({
		...u,
		update: k,
		refs: j,
		elements: M,
		floatingStyles: N
	}), [
		u,
		k,
		j,
		M,
		N
	]);
}
const Lt = (e) => {
	function t(e) {
		return {}.hasOwnProperty.call(e, "current");
	}
	return {
		name: "arrow",
		options: e,
		fn(n) {
			let { element: r, padding: i } = typeof e == "function" ? e(n) : e;
			return r && t(r) ? r.current == null ? {} : Et({
				element: r.current,
				padding: i
			}).fn(n) : r ? Et({
				element: r,
				padding: i
			}).fn(n) : {};
		}
	};
}, Rt = (e, t) => ({
	...xt(e),
	options: [e, t]
}), zt = (e, t) => ({
	...St(e),
	options: [e, t]
}), Bt = (e, t) => ({
	...Dt(e),
	options: [e, t]
}), Vt = (e, t) => ({
	...Ct(e),
	options: [e, t]
}), Ht = (e, t) => ({
	...wt(e),
	options: [e, t]
}), Ut = (e, t) => ({
	...Tt(e),
	options: [e, t]
}), Wt = (e, t) => ({
	...Lt(e),
	options: [e, t]
});
var Gt = "Arrow", Kt = G.forwardRef((e, t) => {
	let { children: n, width: r = 10, height: i = 5,...a } = e;
	return /* @__PURE__ */ (0, K.jsx)(V.svg, {
		...a,
		ref: t,
		width: r,
		height: i,
		viewBox: "0 0 30 10",
		preserveAspectRatio: "none",
		children: e.asChild ? n : /* @__PURE__ */ (0, K.jsx)("polygon", { points: "0,0 30,0 15,10" })
	});
});
Kt.displayName = Gt;
var qt = Kt;
function Jt(e) {
	let [t, n] = G.useState(void 0);
	return z(() => {
		if (e) {
			n({
				width: e.offsetWidth,
				height: e.offsetHeight
			});
			let t = new ResizeObserver((t) => {
				if (!Array.isArray(t) || !t.length) return;
				let r = t[0], i, a;
				if ("borderBoxSize" in r) {
					let e = r.borderBoxSize, t = Array.isArray(e) ? e[0] : e;
					i = t.inlineSize, a = t.blockSize;
				} else i = e.offsetWidth, a = e.offsetHeight;
				n({
					width: i,
					height: a
				});
			});
			return t.observe(e, { box: "border-box" }), () => t.unobserve(e);
		} else n(void 0);
	}, [e]), t;
}
var Yt = "Popper", [Xt, Zt] = ne(Yt), [Qt, $t] = Xt(Yt), en = (e) => {
	let { __scopePopper: t, children: n } = e, [r, i] = G.useState(null);
	return /* @__PURE__ */ (0, K.jsx)(Qt, {
		scope: t,
		anchor: r,
		onAnchorChange: i,
		children: n
	});
};
en.displayName = Yt;
var tn = "PopperAnchor", nn = G.forwardRef((e, t) => {
	let { __scopePopper: n, virtualRef: r,...i } = e, a = $t(tn, n), o = G.useRef(null), s = H(t, o);
	return G.useEffect(() => {
		a.onAnchorChange(r?.current || o.current);
	}), r ? null : /* @__PURE__ */ (0, K.jsx)(V.div, {
		...i,
		ref: s
	});
});
nn.displayName = tn;
var rn = "PopperContent", [an, on] = Xt(rn), sn = G.forwardRef((e, t) => {
	let { __scopePopper: n, side: r = "bottom", sideOffset: i = 0, align: a = "center", alignOffset: o = 0, arrowPadding: s = 0, avoidCollisions: c = !0, collisionBoundary: l = [], collisionPadding: u = 0, sticky: d = "partial", hideWhenDetached: f = !1, updatePositionStrategy: p = "optimized", onPlaced: m,...h } = e, g = $t(rn, n), [_, v] = G.useState(null), y = H(t, (e) => v(e)), [b, x] = G.useState(null), S = Jt(b), C = S?.width ?? 0, w = S?.height ?? 0, T = r + (a === "center" ? "" : "-" + a), E = typeof u == "number" ? u : {
		top: 0,
		right: 0,
		bottom: 0,
		left: 0,
		...u
	}, D = Array.isArray(l) ? l : [l], O = D.length > 0, k = {
		padding: E,
		boundary: D.filter(dn),
		altBoundary: O
	}, { refs: A, floatingStyles: j, placement: M, isPositioned: N, middlewareData: P } = It({
		strategy: "fixed",
		placement: T,
		whileElementsMounted: (...e) => {
			let t = bt(...e, { animationFrame: p === "always" });
			return t;
		},
		elements: { reference: g.anchor },
		middleware: [
			Rt({
				mainAxis: i + w,
				alignmentAxis: o
			}),
			c && zt({
				mainAxis: !0,
				crossAxis: !1,
				limiter: d === "partial" ? Bt() : void 0,
				...k
			}),
			c && Vt({ ...k }),
			Ht({
				...k,
				apply: ({ elements: e, rects: t, availableWidth: n, availableHeight: r }) => {
					let { width: i, height: a } = t.reference, o = e.floating.style;
					o.setProperty("--radix-popper-available-width", `${n}px`), o.setProperty("--radix-popper-available-height", `${r}px`), o.setProperty("--radix-popper-anchor-width", `${i}px`), o.setProperty("--radix-popper-anchor-height", `${a}px`);
				}
			}),
			b && Wt({
				element: b,
				padding: s
			}),
			fn({
				arrowWidth: C,
				arrowHeight: w
			}),
			f && Ut({
				strategy: "referenceHidden",
				...k
			})
		]
	}), [F, ee] = pn(M), I = R(m);
	z(() => {
		N && I?.();
	}, [N, I]);
	let L = P.arrow?.x, te = P.arrow?.y, B = P.arrow?.centerOffset !== 0, [ne, re] = G.useState();
	return z(() => {
		_ && re(window.getComputedStyle(_).zIndex);
	}, [_]), /* @__PURE__ */ (0, K.jsx)("div", {
		ref: A.setFloating,
		"data-radix-popper-content-wrapper": "",
		style: {
			...j,
			transform: N ? j.transform : "translate(0, -200%)",
			minWidth: "max-content",
			zIndex: ne,
			"--radix-popper-transform-origin": [P.transformOrigin?.x, P.transformOrigin?.y].join(" "),
			...P.hide?.referenceHidden && {
				visibility: "hidden",
				pointerEvents: "none"
			}
		},
		dir: e.dir,
		children: /* @__PURE__ */ (0, K.jsx)(an, {
			scope: n,
			placedSide: F,
			onArrowChange: x,
			arrowX: L,
			arrowY: te,
			shouldHideArrow: B,
			children: /* @__PURE__ */ (0, K.jsx)(V.div, {
				"data-side": F,
				"data-align": ee,
				...h,
				ref: y,
				style: {
					...h.style,
					animation: N ? void 0 : "none"
				}
			})
		})
	});
});
sn.displayName = rn;
var cn = "PopperArrow", ln = {
	top: "bottom",
	right: "left",
	bottom: "top",
	left: "right"
}, un = G.forwardRef(function(e, t) {
	let { __scopePopper: n,...r } = e, i = on(cn, n), a = ln[i.placedSide];
	return /* @__PURE__ */ (0, K.jsx)("span", {
		ref: i.onArrowChange,
		style: {
			position: "absolute",
			left: i.arrowX,
			top: i.arrowY,
			[a]: 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__ */ (0, K.jsx)(qt, {
			...r,
			ref: t,
			style: {
				...r.style,
				display: "block"
			}
		})
	});
});
un.displayName = cn;
function dn(e) {
	return e !== null;
}
var fn = (e) => ({
	name: "transformOrigin",
	options: e,
	fn(t) {
		let { placement: n, rects: r, middlewareData: i } = t, a = i.arrow?.centerOffset !== 0, o = a, s = o ? 0 : e.arrowWidth, c = o ? 0 : e.arrowHeight, [l, u] = pn(n), d = {
			start: "0%",
			center: "50%",
			end: "100%"
		}[u], f = (i.arrow?.x ?? 0) + s / 2, p = (i.arrow?.y ?? 0) + c / 2, m = "", h = "";
		return l === "bottom" ? (m = o ? d : `${f}px`, h = `${-c}px`) : l === "top" ? (m = o ? d : `${f}px`, h = `${r.floating.height + c}px`) : l === "right" ? (m = `${-c}px`, h = o ? d : `${p}px`) : l === "left" && (m = `${r.floating.width + c}px`, h = o ? d : `${p}px`), { data: {
			x: m,
			y: h
		} };
	}
});
function pn(e) {
	let [t, n = "center"] = e.split("-");
	return [t, n];
}
var mn = en, hn = nn, gn = sn, _n = un, [vn, yn] = ne("Tooltip", [Zt]), bn = Zt(), xn = "TooltipProvider", Sn = 700, Cn = "tooltip.open", [wn, Tn] = vn(xn), En = (e) => {
	let { __scopeTooltip: t, delayDuration: n = Sn, skipDelayDuration: r = 300, disableHoverableContent: i = !1, children: a } = e, [o, s] = G.useState(!0), c = G.useRef(!1), l = G.useRef(0);
	return G.useEffect(() => {
		let e = l.current;
		return () => window.clearTimeout(e);
	}, []), /* @__PURE__ */ (0, K.jsx)(wn, {
		scope: t,
		isOpenDelayed: o,
		delayDuration: n,
		onOpen: G.useCallback(() => {
			window.clearTimeout(l.current), s(!1);
		}, []),
		onClose: G.useCallback(() => {
			window.clearTimeout(l.current), l.current = window.setTimeout(() => s(!0), r);
		}, [r]),
		isPointerInTransitRef: c,
		onPointerInTransitChange: G.useCallback((e) => {
			c.current = e;
		}, []),
		disableHoverableContent: i,
		children: a
	});
};
En.displayName = xn;
var Dn = "Tooltip", [On, X] = vn(Dn), kn = (e) => {
	let { __scopeTooltip: t, children: n, open: r, defaultOpen: i = !1, onOpenChange: a, disableHoverableContent: o, delayDuration: s } = e, c = Tn(Dn, e.__scopeTooltip), l = bn(t), [u, d] = G.useState(null), f = te(), p = G.useRef(0), m = o ?? c.disableHoverableContent, h = s ?? c.delayDuration, g = G.useRef(!1), [_ = !1, v] = L({
		prop: r,
		defaultProp: i,
		onChange: (e) => {
			e ? (c.onOpen(), document.dispatchEvent(new CustomEvent(Cn))) : c.onClose(), a?.(e);
		}
	}), y = G.useMemo(() => _ ? g.current ? "delayed-open" : "instant-open" : "closed", [_]), b = G.useCallback(() => {
		window.clearTimeout(p.current), g.current = !1, v(!0);
	}, [v]), x = G.useCallback(() => {
		window.clearTimeout(p.current), v(!1);
	}, [v]), S = G.useCallback(() => {
		window.clearTimeout(p.current), p.current = window.setTimeout(() => {
			g.current = !0, v(!0);
		}, h);
	}, [h, v]);
	return G.useEffect(() => () => window.clearTimeout(p.current), []), /* @__PURE__ */ (0, K.jsx)(mn, {
		...l,
		children: /* @__PURE__ */ (0, K.jsx)(On, {
			scope: t,
			contentId: f,
			open: _,
			stateAttribute: y,
			trigger: u,
			onTriggerChange: d,
			onTriggerEnter: G.useCallback(() => {
				c.isOpenDelayed ? S() : b();
			}, [
				c.isOpenDelayed,
				S,
				b
			]),
			onTriggerLeave: G.useCallback(() => {
				m ? x() : window.clearTimeout(p.current);
			}, [x, m]),
			onOpen: b,
			onClose: x,
			disableHoverableContent: m,
			children: n
		})
	});
};
kn.displayName = Dn;
var An = "TooltipTrigger", jn = G.forwardRef((e, t) => {
	let { __scopeTooltip: n,...r } = e, i = X(An, n), a = Tn(An, n), o = bn(n), s = G.useRef(null), c = H(t, s, i.onTriggerChange), l = G.useRef(!1), u = G.useRef(!1), d = G.useCallback(() => l.current = !1, []);
	return G.useEffect(() => () => document.removeEventListener("pointerup", d), [d]), /* @__PURE__ */ (0, K.jsx)(hn, {
		asChild: !0,
		...o,
		children: /* @__PURE__ */ (0, K.jsx)(V.button, {
			"aria-describedby": i.open ? i.contentId : void 0,
			"data-state": i.stateAttribute,
			...r,
			ref: c,
			onPointerMove: B(e.onPointerMove, (e) => {
				e.pointerType !== "touch" && !u.current && !a.isPointerInTransitRef.current && (i.onTriggerEnter(), u.current = !0);
			}),
			onPointerLeave: B(e.onPointerLeave, () => {
				i.onTriggerLeave(), u.current = !1;
			}),
			onPointerDown: B(e.onPointerDown, () => {
				l.current = !0, document.addEventListener("pointerup", d, { once: !0 });
			}),
			onFocus: B(e.onFocus, () => {
				l.current || i.onOpen();
			}),
			onBlur: B(e.onBlur, i.onClose),
			onClick: B(e.onClick, i.onClose)
		})
	});
});
jn.displayName = An;
var Mn = "TooltipPortal", [Nn, Pn] = vn(Mn, { forceMount: void 0 }), Fn = (e) => {
	let { __scopeTooltip: t, forceMount: n, children: r, container: i } = e, a = X(Mn, t);
	return /* @__PURE__ */ (0, K.jsx)(Nn, {
		scope: t,
		forceMount: n,
		children: /* @__PURE__ */ (0, K.jsx)(Me, {
			present: n || a.open,
			children: /* @__PURE__ */ (0, K.jsx)(Ae, {
				asChild: !0,
				container: i,
				children: r
			})
		})
	});
};
Fn.displayName = Mn;
var Z = "TooltipContent", In = G.forwardRef((e, t) => {
	let n = Pn(Z, e.__scopeTooltip), { forceMount: r = n.forceMount, side: i = "top",...a } = e, o = X(Z, e.__scopeTooltip);
	return /* @__PURE__ */ (0, K.jsx)(Me, {
		present: r || o.open,
		children: o.disableHoverableContent ? /* @__PURE__ */ (0, K.jsx)(Bn, {
			side: i,
			...a,
			ref: t
		}) : /* @__PURE__ */ (0, K.jsx)(Ln, {
			side: i,
			...a,
			ref: t
		})
	});
}), Ln = G.forwardRef((e, t) => {
	let n = X(Z, e.__scopeTooltip), r = Tn(Z, e.__scopeTooltip), i = G.useRef(null), a = H(t, i), [o, s] = G.useState(null), { trigger: c, onClose: l } = n, u = i.current, { onPointerInTransitChange: d } = r, f = G.useCallback(() => {
		s(null), d(!1);
	}, [d]), p = G.useCallback((e, t) => {
		let n = e.currentTarget, r = {
			x: e.clientX,
			y: e.clientY
		}, i = Un(r, n.getBoundingClientRect()), a = Wn(r, i), o = Gn(t.getBoundingClientRect()), c = qn([...a, ...o]);
		s(c), d(!0);
	}, [d]);
	return G.useEffect(() => () => f(), [f]), G.useEffect(() => {
		if (c && u) {
			let e = (e) => p(e, u), t = (e) => p(e, c);
			return c.addEventListener("pointerleave", e), u.addEventListener("pointerleave", t), () => {
				c.removeEventListener("pointerleave", e), u.removeEventListener("pointerleave", t);
			};
		}
	}, [
		c,
		u,
		p,
		f
	]), G.useEffect(() => {
		if (o) {
			let e = (e) => {
				let t = e.target, n = {
					x: e.clientX,
					y: e.clientY
				}, r = c?.contains(t) || u?.contains(t), i = !Kn(n, o);
				r ? f() : i && (f(), l());
			};
			return document.addEventListener("pointermove", e), () => document.removeEventListener("pointermove", e);
		}
	}, [
		c,
		u,
		o,
		l,
		f
	]), /* @__PURE__ */ (0, K.jsx)(Bn, {
		...e,
		ref: a
	});
}), [Rn, zn] = vn(Dn, { isInside: !1 }), Bn = G.forwardRef((e, t) => {
	let { __scopeTooltip: n, children: r, "aria-label": i, onEscapeKeyDown: a, onPointerDownOutside: o,...s } = e, c = X(Z, n), l = bn(n), { onClose: u } = c;
	return G.useEffect(() => (document.addEventListener(Cn, u), () => document.removeEventListener(Cn, u)), [u]), G.useEffect(() => {
		if (c.trigger) {
			let e = (e) => {
				let t = e.target;
				t?.contains(c.trigger) && u();
			};
			return window.addEventListener("scroll", e, { capture: !0 }), () => window.removeEventListener("scroll", e, { capture: !0 });
		}
	}, [c.trigger, u]), /* @__PURE__ */ (0, K.jsx)(Se, {
		asChild: !0,
		disableOutsidePointerEvents: !1,
		onEscapeKeyDown: a,
		onPointerDownOutside: o,
		onFocusOutside: (e) => e.preventDefault(),
		onDismiss: u,
		children: /* @__PURE__ */ (0, K.jsxs)(gn, {
			"data-state": c.stateAttribute,
			...l,
			...s,
			ref: t,
			style: {
				...s.style,
				"--radix-tooltip-content-transform-origin": "var(--radix-popper-transform-origin)",
				"--radix-tooltip-content-available-width": "var(--radix-popper-available-width)",
				"--radix-tooltip-content-available-height": "var(--radix-popper-available-height)",
				"--radix-tooltip-trigger-width": "var(--radix-popper-anchor-width)",
				"--radix-tooltip-trigger-height": "var(--radix-popper-anchor-height)"
			},
			children: [/* @__PURE__ */ (0, K.jsx)(se, { children: r }), /* @__PURE__ */ (0, K.jsx)(Rn, {
				scope: n,
				isInside: !0,
				children: /* @__PURE__ */ (0, K.jsx)(ie, {
					id: c.contentId,
					role: "tooltip",
					children: i || r
				})
			})]
		})
	});
});
In.displayName = Z;
var Vn = "TooltipArrow", Hn = G.forwardRef((e, t) => {
	let { __scopeTooltip: n,...r } = e, i = bn(n), a = zn(Vn, n);
	return a.isInside ? null : /* @__PURE__ */ (0, K.jsx)(_n, {
		...i,
		...r,
		ref: t
	});
});
Hn.displayName = Vn;
function Un(e, t) {
	let n = Math.abs(t.top - e.y), r = Math.abs(t.bottom - e.y), i = Math.abs(t.right - e.x), a = Math.abs(t.left - e.x);
	switch (Math.min(n, r, i, a)) {
		case a: return "left";
		case i: return "right";
		case n: return "top";
		case r: return "bottom";
		default: throw Error("unreachable");
	}
}
function Wn(e, t, n = 5) {
	let r = [];
	switch (t) {
		case "top":
			r.push({
				x: e.x - n,
				y: e.y + n
			}, {
				x: e.x + n,
				y: e.y + n
			});
			break;
		case "bottom":
			r.push({
				x: e.x - n,
				y: e.y - n
			}, {
				x: e.x + n,
				y: e.y - n
			});
			break;
		case "left":
			r.push({
				x: e.x + n,
				y: e.y - n
			}, {
				x: e.x + n,
				y: e.y + n
			});
			break;
		case "right":
			r.push({
				x: e.x - n,
				y: e.y - n
			}, {
				x: e.x - n,
				y: e.y + n
			});
			break;
	}
	return r;
}
function Gn(e) {
	let { top: t, right: n, bottom: r, left: i } = e;
	return [
		{
			x: i,
			y: t
		},
		{
			x: n,
			y: t
		},
		{
			x: n,
			y: r
		},
		{
			x: i,
			y: r
		}
	];
}
function Kn(e, t) {
	let { x: n, y: r } = e, i = !1;
	for (let e = 0, a = t.length - 1; e < t.length; a = e++) {
		let o = t[e].x, s = t[e].y, c = t[a].x, l = t[a].y, u = s > r != l > r && n < (c - o) * (r - s) / (l - s) + o;
		u && (i = !i);
	}
	return i;
}
function qn(e) {
	let t = e.slice();
	return t.sort((e, t) => e.x < t.x ? -1 : e.x > t.x ? 1 : e.y < t.y ? -1 : e.y > t.y ? 1 : 0), Jn(t);
}
function Jn(e) {
	if (e.length <= 1) return e.slice();
	let t = [];
	for (let n = 0; n < e.length; n++) {
		let r = e[n];
		for (; t.length >= 2;) {
			let e = t[t.length - 1], n = t[t.length - 2];
			if ((e.x - n.x) * (r.y - n.y) >= (e.y - n.y) * (r.x - n.x)) t.pop();
			else break;
		}
		t.push(r);
	}
	t.pop();
	let n = [];
	for (let t = e.length - 1; t >= 0; t--) {
		let r = e[t];
		for (; n.length >= 2;) {
			let e = n[n.length - 1], t = n[n.length - 2];
			if ((e.x - t.x) * (r.y - t.y) >= (e.y - t.y) * (r.x - t.x)) n.pop();
			else break;
		}
		n.push(r);
	}
	return n.pop(), t.length === 1 && n.length === 1 && t[0].x === n[0].x && t[0].y === n[0].y ? t : t.concat(n);
}
var Yn = En, Xn = kn, Zn = jn, Qn = Fn, $n = In, er = Hn;
function tr(e) {
	switch (e) {
		case "tomato":
		case "red":
		case "ruby":
		case "crimson":
		case "pink":
		case "plum":
		case "purple":
		case "violet": return "mauve";
		case "iris":
		case "indigo":
		case "blue":
		case "sky":
		case "cyan": return "slate";
		case "teal":
		case "jade":
		case "mint":
		case "green": return "sage";
		case "grass":
		case "lime": return "olive";
		case "yellow":
		case "amber":
		case "orange":
		case "brown":
		case "gold":
		case "bronze": return "sand";
		case "gray": return "gray";
	}
}
const nr = [
	"inherit",
	"light",
	"dark"
], rr = ["solid", "translucent"], ir = [
	"90%",
	"95%",
	"100%",
	"105%",
	"110%"
], Q = {
	...I,
	hasBackground: {
		type: "boolean",
		default: !0
	},
	appearance: {
		type: "enum",
		values: nr,
		default: "inherit"
	},
	accentColor: {
		type: "enum",
		values: ee,
		default: "indigo"
	},
	grayColor: {
		type: "enum",
		values: F,
		default: "auto"
	},
	panelBackground: {
		type: "enum",
		values: rr,
		default: "translucent"
	},
	radius: {
		type: "enum",
		values: ce,
		default: "medium"
	},
	scaling: {
		type: "enum",
		values: ir,
		default: "100%"
	}
};
var ar = /* @__PURE__ */ e(re());
const $ = () => {}, or = G.createContext(void 0);
function sr() {
	let e = G.useContext(or);
	if (e === void 0) throw Error("`useThemeContext` must be used within a `Theme`");
	return e;
}
const cr = G.forwardRef((e, t) => G.useContext(or) === void 0 ? G.createElement(Yn, { delayDuration: 200 }, G.createElement(le, { dir: "ltr" }, G.createElement(lr, {
	...e,
	ref: t
}))) : G.createElement(ur, {
	...e,
	ref: t
}));
cr.displayName = "Theme";
const lr = G.forwardRef((e, t) => {
	let { appearance: n = Q.appearance.default, accentColor: r = Q.accentColor.default, grayColor: i = Q.grayColor.default, panelBackground: a = Q.panelBackground.default, radius: o = Q.radius.default, scaling: s = Q.scaling.default, hasBackground: c = Q.hasBackground.default,...l } = e, [u, d] = G.useState(n);
	G.useEffect(() => d(n), [n]);
	let [f, p] = G.useState(r);
	G.useEffect(() => p(r), [r]);
	let [m, h] = G.useState(i);
	G.useEffect(() => h(i), [i]);
	let [g, _] = G.useState(a);
	G.useEffect(() => _(a), [a]);
	let [v, y] = G.useState(o);
	G.useEffect(() => y(o), [o]);
	let [b, x] = G.useState(s);
	return G.useEffect(() => x(s), [s]), G.createElement(ur, {
		...l,
		ref: t,
		isRoot: !0,
		hasBackground: c,
		appearance: u,
		accentColor: f,
		grayColor: m,
		panelBackground: g,
		radius: v,
		scaling: b,
		onAppearanceChange: d,
		onAccentColorChange: p,
		onGrayColorChange: h,
		onPanelBackgroundChange: _,
		onRadiusChange: y,
		onScalingChange: x
	});
});
lr.displayName = "ThemeRoot";
const ur = G.forwardRef((e, t) => {
	let n = G.useContext(or), { asChild: r, isRoot: i, hasBackground: a, appearance: o = n?.appearance ?? Q.appearance.default, accentColor: s = n?.accentColor ?? Q.accentColor.default, grayColor: c = n?.resolvedGrayColor ?? Q.grayColor.default, panelBackground: l = n?.panelBackground ?? Q.panelBackground.default, radius: u = n?.radius ?? Q.radius.default, scaling: d = n?.scaling ?? Q.scaling.default, onAppearanceChange: f = $, onAccentColorChange: p = $, onGrayColorChange: m = $, onPanelBackgroundChange: h = $, onRadiusChange: g = $, onScalingChange: _ = $,...v } = e, y = r ? oe : "div", b = c === "auto" ? tr(s) : c, x = e.appearance === "light" || e.appearance === "dark", S = a === void 0 ? i || x : a;
	return G.createElement(or.Provider, { value: G.useMemo(() => ({
		appearance: o,
		accentColor: s,
		grayColor: c,
		resolvedGrayColor: b,
		panelBackground: l,
		radius: u,
		scaling: d,
		onAppearanceChange: f,
		onAccentColorChange: p,
		onGrayColorChange: m,
		onPanelBackgroundChange: h,
		onRadiusChange: g,
		onScalingChange: _
	}), [
		o,
		s,
		c,
		b,
		l,
		u,
		d,
		f,
		p,
		m,
		h,
		g,
		_
	]) }, G.createElement(y, {
		"data-is-root-theme": i ? "true" : "false",
		"data-accent-color": s,
		"data-gray-color": b,
		"data-has-background": S ? "true" : "false",
		"data-panel-background": l,
		"data-radius": u,
		"data-scaling": d,
		ref: t,
		...v,
		className: (0, ar.default)("radix-themes", {
			light: o === "light",
			dark: o === "dark"
		}, v.className)
	}));
});
ur.displayName = "ThemeImpl";
export { sr as b, cr as c, er as d, $n as e, Qn as f, Xn as g, Zn as h, hn as i, _n as j, gn as k, mn as l, Zt as m, Jt as n, bt as o, Me as p, Ae as q, Se as r };

//# sourceMappingURL=theme.HtT_2QlC.js.map