"use client";
import { t as e } from "./useIsoLayoutEffect-CKOv1bV_.js";
import { o as t, r as n, t as r, u as i } from "./useRenderElement-CmuWsiNa.js";
import { t as a } from "./useStableCallback-CqEVb76s.js";
import { l as o, t as s, x as c } from "./createBaseUIEventDetails-ChcQXp54.js";
import { t as l } from "./useBaseUiId-DOm5ACje.js";
import { a as u, t as d } from "./useOpenChangeComplete-DjMFUwhi.js";
import { d as f } from "./floating-ui.utils.dom-5U5b4xPf.js";
import { C as p, D as m, E as h, L as g, S as _, T as v, V as y, a as b, c as x, d as S, l as C, m as w, o as T, p as E, r as D, s as O, u as k, v as A, w as j, x as M } from "./popupStateMapping-PdIQcWEz.js";
import { cn as N } from "./lib/utils.js";
import { n as P, r as ee, t as te } from "./safePolygon-CscU2iWL.js";
import { i as ne, n as re, r as F, t as ie } from "./usePositioner-D65mUNMo.js";
import { n as ae, r as oe, t as se } from "./store-Bdrhndby.js";
import { t as ce } from "./useFocus-DzHCrvH6.js";
import { t as le } from "./FloatingPortalLite-B1JyBlt0.js";
import * as I from "react";
import { jsx as L, jsxs as ue } from "react/jsx-runtime";
import * as de from "react-dom";
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/utils/popups/inlineRect.js
function R(e, t, n, r) {
	return {
		left: e,
		top: t,
		right: n,
		bottom: r,
		x: e,
		y: t,
		width: n - e,
		height: r - t
	};
}
function fe(e) {
	return {
		left: e.left,
		top: e.top,
		right: e.right,
		bottom: e.bottom,
		width: e.width,
		height: e.height
	};
}
function z(e) {
	let t = [], n, r = Infinity, i = Infinity, a = -Infinity, o = -Infinity;
	for (let s of Array.from(e).sort((e, t) => e.top - t.top)) {
		if (r = Math.min(r, s.left), i = Math.min(i, s.top), a = Math.max(a, s.right), o = Math.max(o, s.bottom), !n || s.top - n.top > n.height / 2) t.push(fe(s));
		else {
			let e = t[t.length - 1];
			e.left = Math.min(e.left, s.left), e.right = Math.max(e.right, s.right), e.bottom = Math.max(e.bottom, s.bottom), e.width = e.right - e.left, e.height = e.bottom - e.top;
		}
		n = s;
	}
	return {
		lines: t,
		fallback: R(r, i, a, o)
	};
}
function B(e, t, n) {
	return e.findIndex((e) => t > e.left - 2 && t < e.right + 2 && n > e.top - 2 && n < e.bottom + 2);
}
function V(e) {
	return R(e.left, e.top, e.right, e.bottom);
}
function pe(e, t, n) {
	let { lines: r } = z(e.getClientRects());
	if (r.length < 2) return;
	let i = B(r, t, n);
	return {
		x: t,
		y: n,
		lineIndex: i === -1 ? void 0 : i,
		element: e
	};
}
function me(e, t, n) {
	let { lines: r, fallback: i } = z(e.getClientRects());
	if (r.length < 2) return null;
	let a = n?.x, o = n?.y, s = t[0];
	if (n?.lineIndex != null && r[n.lineIndex]) return V(r[n.lineIndex]);
	if (a != null && o != null) {
		let e = B(r, a, o);
		if (e !== -1) return V(r[e]);
	}
	if (r.length === 2 && r[0].left > r[1].right && a != null && o != null) return i;
	if (s === "t" || s === "b") {
		let e = r[0], t = r[r.length - 1], n = s === "t" ? e : t;
		return R(n.left, e.top, n.right, t.bottom);
	}
	let c = s === "l", l = r[0].left, u = r[0].right, d = c ? Infinity : -Infinity, f = r[0], p = r[0];
	for (let e of r) {
		l = Math.min(l, e.left), u = Math.max(u, e.right);
		let t = c ? e.left : e.right;
		c && t < d || !c && t > d ? (d = t, f = e, p = e) : t === d && (p = e);
	}
	return R(l, f.top, u, p.bottom);
}
function he(e) {
	return "contextElement" in e && e.contextElement ? e.contextElement : f(e) ? e : void 0;
}
function ge(e, t) {
	function n(t) {
		H(e, t.currentTarget, t.clientX, t.clientY);
	}
	function r(e) {
		t || n(e);
	}
	return {
		onFocus() {
			e.current = void 0;
		},
		onMouseEnter: n,
		onMouseMove: r
	};
}
function H(e, t, n, r) {
	let i = pe(t, n, r);
	return e.current = i, i;
}
function _e(e) {
	return {
		name: "inline",
		async fn(t) {
			let n = t.elements.reference;
			if (typeof n?.getClientRects != "function") return {};
			let r = he(n), i = e.current, a = i?.element === n || i?.element === r ? i : void 0, o = me(n, t.placement, a);
			if (!o || typeof t.platform.getElementRects != "function") return {};
			let s = await t.platform.getElementRects({
				reference: {
					contextElement: r,
					getBoundingClientRect() {
						return o;
					}
				},
				floating: t.elements.floating,
				strategy: t.strategy
			});
			return t.rects.reference.x === s.reference.x && t.rects.reference.y === s.reference.y && t.rects.reference.width === s.reference.width && t.rects.reference.height === s.reference.height ? {} : { reset: { rects: s } };
		}
	};
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/preview-card/root/PreviewCardContext.js
var U = /*#__PURE__*/ I.createContext(void 0);
process.env.NODE_ENV !== "production" && (U.displayName = "PreviewCardRootContext");
function W(e) {
	let t = I.useContext(U);
	if (t === void 0 && !e) throw Error(process.env.NODE_ENV === "production" ? i(50) : "Base UI: PreviewCardRootContext is missing. PreviewCard parts must be placed within <PreviewCard.Root>.");
	return t;
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/preview-card/store/PreviewCardStore.js
var ve = {
	...oe,
	instantType: p((e) => e.instantType),
	hasViewport: p((e) => e.hasViewport)
}, ye = class e extends A {
	constructor(e, t, n = !1) {
		let r = new T(), i = {
			...be(),
			...e
		};
		i.floatingRootContext = ae(r, t, n), super(i, {
			popupRef: /*#__PURE__*/ I.createRef(),
			onOpenChange: void 0,
			onOpenChangeComplete: void 0,
			triggerElements: r,
			closeDelayRef: { current: 300 },
			inlineRectCoordsRef: { current: void 0 }
		}, ve);
	}
	setOpen = (e, t) => {
		let n = t.reason, r = n === c, i = e && n === "trigger-focus", a = !e && (n === "trigger-press" || n === "escape-key");
		if (t.preventUnmountOnClose = () => {
			this.set("preventUnmountingOnClose", !0);
		}, this.context.onOpenChange?.(e, t), t.isCanceled) return;
		let o = t.event;
		e && r && t.trigger && "clientX" in o && "clientY" in o && this.context.inlineRectCoordsRef.current?.element !== t.trigger && H(this.context.inlineRectCoordsRef, t.trigger, o.clientX, o.clientY), this.state.floatingRootContext.dispatchOpenChange(e, t);
		let s = () => {
			let r = { open: e };
			i ? r.instantType = "focus" : a ? r.instantType = "dismiss" : n === "trigger-hover" && (r.instantType = void 0), x(r, e, t.trigger), this.update(r);
		};
		r ? de.flushSync(s) : s();
	};
	static useStore(t, n) {
		return E(t, (t, r) => new e(n, t, r)).store;
	}
};
function be() {
	return {
		...se(),
		instantType: void 0,
		hasViewport: !1
	};
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/preview-card/root/PreviewCardRoot.js
function G(t) {
	let { open: n, defaultOpen: r = !1, onOpenChange: i, onOpenChangeComplete: a, actionsRef: c, handle: l, triggerId: u, defaultTriggerId: d = null, children: f } = t, p = ye.useStore(l?.store, {
		open: r,
		openProp: n,
		activeTriggerId: d,
		triggerIdProp: u
	});
	y(() => {
		n === void 0 && p.state.open === !1 && r === !0 && p.update({
			open: !0,
			activeTriggerId: d
		});
	}), p.useControlledProp("openProp", n), p.useControlledProp("triggerIdProp", u), p.useContextCallback("onOpenChange", i), p.useContextCallback("onOpenChangeComplete", a);
	let m = p.useState("open"), h = p.useState("activeTriggerId"), g = p.useState("mounted"), _ = p.useState("payload");
	C(p);
	let { forceUnmount: v } = k(m, p, () => {
		p.context.inlineRectCoordsRef.current = void 0;
	});
	e(() => {
		m && (h ?? p.set("payload", void 0));
	}, [
		p,
		h,
		m
	]);
	let b = I.useCallback(() => {
		p.setOpen(!1, s(o));
	}, [p]);
	I.useImperativeHandle(c, () => ({
		unmount: v,
		close: b
	}), [v, b]);
	let x = m || g;
	return /*#__PURE__*/ ue(U.Provider, {
		value: p,
		children: [x && /*#__PURE__*/ L(xe, { store: p }), typeof f == "function" ? f({ payload: _ }) : f]
	});
}
function xe({ store: e }) {
	let r = j(e.useState("floatingRootContext"));
	return S(e, {
		activeTriggerProps: r.reference ?? t,
		inactiveTriggerProps: r.trigger ?? t,
		popupProps: I.useMemo(() => n(O, r.floating), [r.floating])
	}), null;
}
var K = M(function(e) {
	return W(!0) ? /*#__PURE__*/ L(G, { ...e }) : /*#__PURE__*/ L(h, { children: /*#__PURE__*/ L(G, { ...e }) });
});
process.env.NODE_ENV !== "production" && (K.displayName = "PreviewCardRoot");
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/preview-card/portal/PreviewCardPortalContext.js
var q = /*#__PURE__*/ I.createContext(void 0);
process.env.NODE_ENV !== "production" && (q.displayName = "PreviewCardPortalContext");
function Se() {
	let e = I.useContext(q);
	if (e === void 0) throw Error(process.env.NODE_ENV === "production" ? i(48) : "Base UI: <PreviewCard.Portal> is missing.");
	return e;
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/preview-card/portal/PreviewCardPortal.js
var J = /*#__PURE__*/ I.forwardRef(function(e, t) {
	let { keepMounted: n = !1, ...r } = e;
	return W().useState("mounted") || n ? /*#__PURE__*/ L(q.Provider, {
		value: n,
		children: /*#__PURE__*/ L(le, {
			ref: t,
			...r
		})
	}) : null;
});
process.env.NODE_ENV !== "production" && (J.displayName = "PreviewCardPortal");
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/preview-card/trigger/PreviewCardTrigger.js
var Y = _(function(t, n) {
	let { render: a, className: o, delay: s, closeDelay: c, id: u, payload: d, handle: f, style: p, ...m } = t, h = W(!0), g = f?.store ?? h;
	if (!g) throw Error(process.env.NODE_ENV === "production" ? i(89) : "Base UI: <PreviewCard.Trigger> must be either used within a <PreviewCard.Root> component or provided with a handle.");
	let _ = l(u), v = g.useState("isTriggerActive", _), y = g.useState("isOpenedByTrigger", _), x = g.useState("floatingRootContext"), S = g.context.inlineRectCoordsRef, C = I.useRef(null), T = s ?? 600, E = c ?? 300, { registerTrigger: D, isMountedByThisTrigger: O } = w(_, C, g, { payload: d });
	e(() => {
		O && (g.context.closeDelayRef.current = E);
	}, [
		g,
		O,
		E
	]);
	let k = P(x, {
		mouseOnly: !0,
		move: !1,
		handleClose: te(),
		delay: () => ({
			open: T,
			close: E
		}),
		triggerElementRef: C,
		isActiveTrigger: v,
		isClosing: () => g.select("transitionStatus") === "ending"
	}), A = ce(x, { delay: T }), j = { open: y }, M = g.useState("triggerProps", O), N = ge(S, y);
	return r("a", t, {
		state: j,
		ref: [
			n,
			D,
			C
		],
		props: [
			k,
			A.reference,
			M,
			N,
			{ id: _ },
			m
		],
		stateAttributesMapping: b
	});
});
process.env.NODE_ENV !== "production" && (Y.displayName = "PreviewCardTrigger");
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/preview-card/positioner/PreviewCardPositionerContext.js
var X = /*#__PURE__*/ I.createContext(void 0);
process.env.NODE_ENV !== "production" && (X.displayName = "PreviewCardPositionerContext");
function Z() {
	let e = I.useContext(X);
	if (e === void 0) throw Error(process.env.NODE_ENV === "production" ? i(49) : "Base UI: <PreviewCard.Popup> and <PreviewCard.Arrow> must be used within the <PreviewCard.Positioner> component");
	return e;
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/preview-card/positioner/PreviewCardPositioner.js
var Q = /*#__PURE__*/ I.forwardRef(function(t, n) {
	let { render: r, className: i, anchor: a, positionMethod: o = "absolute", side: s = "bottom", align: c = "center", sideOffset: l = 0, alignOffset: u = 0, collisionBoundary: d = "clipping-ancestors", collisionPadding: f = 5, arrowPadding: p = 5, sticky: h = !1, disableAnchorTracking: _ = !1, collisionAvoidance: y = g, style: b, ...x } = t, S = W(), C = Se(), w = m(), T = S.useState("open"), E = S.useState("mounted"), D = S.useState("floatingRootContext"), O = S.useState("instantType"), k = S.useState("transitionStatus"), A = S.useState("hasViewport"), j = S.context.inlineRectCoordsRef, M = F({
		anchor: a,
		floatingRootContext: D,
		positionMethod: o,
		mounted: E,
		side: s,
		sideOffset: l,
		align: c,
		alignOffset: u,
		arrowPadding: p,
		collisionBoundary: d,
		collisionPadding: f,
		sticky: h,
		disableAnchorTracking: _,
		keepMounted: C,
		nodeId: w,
		collisionAvoidance: y,
		adaptiveOrigin: A ? ne : void 0,
		inline: _e(j)
	}), N = M.update;
	e(() => {
		T && E && N();
	}, [
		T,
		E,
		N
	]);
	let P = ie(t, {
		open: T,
		side: M.side,
		align: M.align,
		anchorHidden: M.anchorHidden,
		instant: O
	}, {
		styles: M.positionerStyles,
		transitionStatus: k,
		props: x,
		refs: [n, S.useStateSetter("positionerElement")],
		hidden: !E,
		inert: !T
	});
	return /*#__PURE__*/ L(X.Provider, {
		value: M,
		children: /*#__PURE__*/ L(v, {
			id: w,
			children: P
		})
	});
});
process.env.NODE_ENV !== "production" && (Q.displayName = "PreviewCardPositioner");
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/preview-card/popup/PreviewCardPopup.js
var Ce = {
	...D,
	...u
}, $ = /*#__PURE__*/ I.forwardRef(function(e, t) {
	let { className: n, render: i, style: o, ...s } = e, c = W(), { side: l, align: u } = Z(), f = c.useState("open"), p = c.useState("instantType"), m = c.useState("transitionStatus"), h = c.useState("popupProps"), g = c.useState("floatingRootContext");
	return d({
		open: f,
		ref: c.context.popupRef,
		onComplete() {
			f && c.context.onOpenChangeComplete?.(!0);
		}
	}), ee(g, { closeDelay: a(() => c.context.closeDelayRef.current) }), r("div", e, {
		state: {
			open: f,
			side: l,
			align: u,
			instant: p,
			transitionStatus: m
		},
		ref: [
			t,
			c.context.popupRef,
			c.useStateSetter("popupElement")
		],
		props: [
			h,
			re(m),
			s
		],
		stateAttributesMapping: Ce
	});
});
process.env.NODE_ENV !== "production" && ($.displayName = "PreviewCardPopup");
//#endregion
//#region lib/components/ui/atoms/hover-card.tsx
function we({ ...e }) {
	return /* @__PURE__ */ L(K, {
		"data-slot": "hover-card",
		...e
	});
}
function Te({ ...e }) {
	return /* @__PURE__ */ L(Y, {
		"data-slot": "hover-card-trigger",
		...e
	});
}
function Ee({ className: e, side: t = "bottom", sideOffset: n = 4, align: r = "center", alignOffset: i = 4, ...a }) {
	return /* @__PURE__ */ L(J, {
		"data-slot": "hover-card-portal",
		children: /* @__PURE__ */ L(Q, {
			align: r,
			alignOffset: i,
			className: "isolate z-50",
			side: t,
			sideOffset: n,
			children: /* @__PURE__ */ L($, {
				className: N("data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:fade-in-0 data-open:zoom-in-95 data-closed:fade-out-0 data-closed:zoom-out-95 z-50 w-64 origin-(--transform-origin) rounded-lg bg-popover p-4 text-popover-foreground text-sm shadow-md outline-hidden ring-1 ring-foreground/10 duration-100 data-closed:animate-out data-open:animate-in", e),
				"data-slot": "hover-card-content",
				...a
			})
		})
	});
}
//#endregion
export { Ee as n, Te as r, we as t };
