"use client";
import { t as e } from "./useIsoLayoutEffect-CKOv1bV_.js";
import { f as t, s as n } from "./useRenderElement-CmuWsiNa.js";
import { t as r } from "./useStableCallback-CqEVb76s.js";
import { t as i } from "./useBaseUiId-DOm5ACje.js";
import { d as a } from "./floating-ui.utils.dom-5U5b4xPf.js";
import { t as o } from "./LabelableContext-Q1Z-xUI9.js";
import * as s from "react";
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/internals/labelable-provider/useLabelableId.js
function c(c = {}) {
	let { id: l, implicit: u = !1, controlRef: d } = c, { controlId: f, registerControlId: p } = o(), m = i(l), h = u ? f : void 0, g = t(() => Symbol("labelable-control")), _ = s.useRef(!1), v = s.useRef(l != null), y = r(() => {
		!_.current || p === n || (_.current = !1, p(g.current, void 0));
	});
	return e(() => {
		if (p === n) return;
		let e;
		if (u) {
			let t = d?.current;
			e = a(t) && t.closest("label") != null ? l ?? null : h ?? m;
		} else if (l != null) v.current = !0, e = l;
		else if (v.current) e = m;
		else {
			y();
			return;
		}
		if (e === void 0) {
			y();
			return;
		}
		_.current = !0, p(g.current, e);
	}, [
		l,
		d,
		h,
		p,
		u,
		m,
		g,
		y
	]), s.useEffect(() => y, [y]), f ?? m;
}
//#endregion
export { c as t };
