"use client";
import { t as e } from "./error-CAd3pM3X.js";
import * as t from "react";
//#region ../../node_modules/.bun/@base-ui+utils@0.2.9+f7941a290aa3d619/node_modules/@base-ui/utils/esm/useControlled.js
function n({ controlled: n, default: i, name: a, state: o = "value" }) {
	let { current: s } = t.useRef(n !== void 0), [c, l] = t.useState(i), u = s ? n : c;
	if (process.env.NODE_ENV !== "production") {
		t.useEffect(() => {
			s !== (n !== void 0) && e([
				`A component is changing the ${s ? "" : "un"}controlled ${o} state of ${a} to be ${s ? "un" : ""}controlled.`,
				"Elements should not switch from uncontrolled to controlled (or vice versa).",
				`Decide between using a controlled or uncontrolled ${a} element for the lifetime of the component.`,
				"The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.",
				"More info: https://fb.me/react-controlled-components"
			].join("\n"));
		}, [
			o,
			a,
			n
		]);
		let { current: c } = t.useRef(i);
		t.useEffect(() => {
			!s && r(c) !== r(i) && e([`A component is changing the default ${o} state of an uncontrolled ${a} after being initialized. To suppress this warning opt to use a controlled ${a}.`].join("\n"));
		}, [i]);
	}
	return [u, t.useCallback((e) => {
		s || l(e);
	}, [])];
}
function r(e) {
	let t = 0, n = /* @__PURE__ */ new WeakMap();
	try {
		return JSON.stringify(e, function(e, r) {
			if (!(e === "_owner" && this != null && typeof this == "object" && "$$typeof" in this)) {
				if (typeof r == "bigint") return `__bigint__:${r}`;
				if (typeof r == "object" && r) {
					let e = n.get(r);
					if (e !== void 0) return `__object__:${e}`;
					n.set(r, t), t += 1;
				}
				return r;
			}
		}) ?? `__top__:${typeof e}`;
	} catch {
		return "__unserializable__";
	}
}
//#endregion
export { n as t };
