"use client";
import { t as e } from "./useIsoLayoutEffect-CKOv1bV_.js";
import { t } from "./useBaseUiId-DOm5ACje.js";
import * as n from "react";
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/internals/labelable-provider/useAriaLabelledBy.js
function r(r, a, o, s = !0, c) {
	let [l, u] = n.useState(), d = t(c ? `${c}-label` : void 0), f = r ?? a ?? l;
	return e(() => {
		let e = r || a || !s ? void 0 : i(o.current, d);
		l !== e && u(e);
	}), f;
}
function i(e, t) {
	let n = a(e);
	if (n) return !n.id && t && (n.id = t), n.id || void 0;
}
function a(e) {
	if (!e) return;
	let t = e.parentElement;
	if (t && t.tagName === "LABEL") return t;
	let n = e.id;
	if (n) {
		let t = e.nextElementSibling;
		if (t && t.htmlFor === n) return t;
	}
	let r = e.labels;
	return r && r[0];
}
//#endregion
export { r as t };
