import { n as e } from "./dist-CTlQcJNK.js";
import { r as t } from "./dist-koa_pEtu.js";
import * as n from "react";
//#region node_modules/@radix-ui/react-presence/dist/index.mjs
function r(e, t) {
	return n.useReducer((e, n) => t[e][n] ?? e, e);
}
var i = (t) => {
	let { present: r, children: i } = t, o = a(r), c = typeof i == "function" ? i({ present: o.isPresent }) : n.Children.only(i), l = e(o.ref, s(c));
	return typeof i == "function" || o.isPresent ? n.cloneElement(c, { ref: l }) : null;
};
i.displayName = "Presence";
function a(e) {
	let [i, a] = n.useState(), s = n.useRef(null), c = n.useRef(e), l = n.useRef("none"), [u, d] = r(e ? "mounted" : "unmounted", {
		mounted: {
			UNMOUNT: "unmounted",
			ANIMATION_OUT: "unmountSuspended"
		},
		unmountSuspended: {
			MOUNT: "mounted",
			ANIMATION_END: "unmounted"
		},
		unmounted: { MOUNT: "mounted" }
	});
	return n.useEffect(() => {
		let e = o(s.current);
		l.current = u === "mounted" ? e : "none";
	}, [u]), t(() => {
		let t = s.current, n = c.current;
		if (n !== e) {
			let r = l.current, i = o(t);
			e ? d("MOUNT") : i === "none" || t?.display === "none" ? d("UNMOUNT") : d(n && r !== i ? "ANIMATION_OUT" : "UNMOUNT"), c.current = e;
		}
	}, [e, d]), t(() => {
		if (i) {
			let e, t = i.ownerDocument.defaultView ?? window, n = (n) => {
				let r = o(s.current).includes(CSS.escape(n.animationName));
				if (n.target === i && r && (d("ANIMATION_END"), !c.current)) {
					let n = i.style.animationFillMode;
					i.style.animationFillMode = "forwards", e = t.setTimeout(() => {
						i.style.animationFillMode === "forwards" && (i.style.animationFillMode = n);
					});
				}
			}, r = (e) => {
				e.target === i && (l.current = o(s.current));
			};
			return i.addEventListener("animationstart", r), i.addEventListener("animationcancel", n), i.addEventListener("animationend", n), () => {
				t.clearTimeout(e), i.removeEventListener("animationstart", r), i.removeEventListener("animationcancel", n), i.removeEventListener("animationend", n);
			};
		} else d("ANIMATION_END");
	}, [i, d]), {
		isPresent: ["mounted", "unmountSuspended"].includes(u),
		ref: n.useCallback((e) => {
			s.current = e ? getComputedStyle(e) : null, a(e);
		}, [])
	};
}
function o(e) {
	return e?.animationName || "none";
}
function s(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);
}
//#endregion
export { i as t };

//# sourceMappingURL=dist-DxtM7vvP.js.map