/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
import { cx } from "../styles/styler.js";
import { Text } from "./Text.js";
import { forwardRef } from "react";
import { jsx, jsxs } from "react/jsx-runtime";
import { isFunction } from "lodash-es";
//#region src/components/FormLabel.tsx
const FormLabel = forwardRef(function FormLabel({ htmlFor, required, label, children, color = "muted", variant = "label3", hasError = false, showRequiredAsterisk = false, as = "label", className, ...rest }, ref) {
	const contents = label ? isFunction(label) ? label() : label : children;
	if (!contents) return null;
	return /* @__PURE__ */ jsxs(Text, {
		ref,
		variant,
		color,
		as,
		htmlFor,
		className: cx("cursor-[inherit]", className),
		...rest,
		children: [contents, required && showRequiredAsterisk && /* @__PURE__ */ jsx(Text, {
			as: "sup",
			color: hasError ? "alert" : "inherit",
			variant: "inherit",
			spacingStart: "0.5",
			"aria-hidden": true,
			children: "*"
		})]
	});
});
FormLabel.displayName = "FormLabel";
//#endregion
export { FormLabel };
