"use client";
import { t as e } from "./useIsoLayoutEffect-CKOv1bV_.js";
import { t } from "./useStableCallback-CqEVb76s.js";
import { n, t as r } from "./useAnimationFrame-xwbX87TY.js";
import * as i from "react";
import * as a from "react-dom";
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
function o(t, n = !1, a = !1) {
	let [o, s] = i.useState(t && n ? "idle" : void 0), [c, l] = i.useState(t);
	return t && !c && (l(!0), s("starting")), !t && c && o !== "ending" && !a && s("ending"), !t && !c && o === "ending" && s(void 0), e(() => {
		if (!t && c && o !== "ending" && a) {
			let e = r.request(() => {
				s("ending");
			});
			return () => {
				r.cancel(e);
			};
		}
	}, [
		t,
		c,
		o,
		a
	]), e(() => {
		if (!t || n) return;
		let e = r.request(() => {
			s(void 0);
		});
		return () => {
			r.cancel(e);
		};
	}, [n, t]), e(() => {
		if (!t || !n) return;
		t && c && o !== "idle" && s("starting");
		let e = r.request(() => {
			s("idle");
		});
		return () => {
			r.cancel(e);
		};
	}, [
		n,
		t,
		c,
		o
	]), {
		mounted: c,
		setMounted: l,
		transitionStatus: o
	};
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/internals/stateAttributesMapping.js
var s = /*#__PURE__*/ function(e) {
	return e.startingStyle = "data-starting-style", e.endingStyle = "data-ending-style", e;
}({}), c = { [s.startingStyle]: "" }, l = { [s.endingStyle]: "" }, u = { transitionStatus(e) {
	return e === "starting" ? c : e === "ending" ? l : null;
} };
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/utils/resolveRef.js
function d(e) {
	return e == null ? e : "current" in e ? e.current : e;
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
function f(e, r = !1, i = !0) {
	let o = n();
	return t((t, n = null) => {
		o.cancel();
		let c = d(e);
		if (c == null) return;
		let l = c, u = () => {
			a.flushSync(t);
		};
		if (typeof l.getAnimations != "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
			t();
			return;
		}
		function f() {
			Promise.all(l.getAnimations().map((e) => e.finished)).then(() => {
				n?.aborted || u();
			}).catch(() => {
				if (i) {
					n?.aborted || u();
					return;
				}
				let e = l.getAnimations();
				!n?.aborted && e.length > 0 && e.some((e) => e.pending || e.playState !== "finished") && f();
			});
		}
		if (r) {
			let e = s.startingStyle;
			if (!l.hasAttribute(e)) {
				o.request(f);
				return;
			}
			let t = new MutationObserver(() => {
				l.hasAttribute(e) || (t.disconnect(), f());
			});
			t.observe(l, {
				attributes: !0,
				attributeFilter: [e]
			}), n?.addEventListener("abort", () => t.disconnect(), { once: !0 });
			return;
		}
		o.request(f);
	});
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
function p(e) {
	let { enabled: n = !0, open: r, ref: a, onComplete: o } = e, s = t(o), c = f(a, r, !1);
	i.useEffect(() => {
		if (!n) return;
		let e = new AbortController();
		return c(s, e.signal), () => {
			e.abort();
		};
	}, [
		n,
		r,
		s,
		c
	]);
}
//#endregion
export { u as a, s as i, f as n, o, d as r, p as t };
