import { isJsx } from "../utils/assertion.js";
import { cs } from "../utils/styles.js";
import { inputColors } from "./consts.js";
import { useStyleConfig } from "../core/theme.js";
import vui from "../core/vui.js";
import Box from "../box/box.js";
import Icon from "../icon/icon.js";
import P from "../p/p.js";
import { useInputContext } from "./context.js";
import { jsx, jsxs } from "react/jsx-runtime";

//#region src/input/helpText.tsx
/** Displaying help text below the input. */
const HelpText = vui((props, ref) => {
	const { className, children, isError, ...rest } = props;
	const styles = useStyleConfig("Input", {
		...useInputContext(),
		...props
	});
	const color = isError ? inputColors.error : inputColors.helpText;
	if (isJsx(children)) return /* @__PURE__ */ jsxs(Box, {
		alignItems: "flex-start",
		className: cs("vui-inputHelpText", className),
		color,
		display: "flex",
		pt: .5,
		ref,
		...styles.helpText,
		...rest,
		children: [isError && /* @__PURE__ */ jsx(Icon, {
			mr: 1,
			mt: "3px",
			name: "uiExclamationTriangle",
			pathFill: inputColors.error,
			size: "sm"
		}), children]
	});
	return /* @__PURE__ */ jsxs(P, {
		alignItems: "flex-start",
		className: cs("vui-inputHelpText", className),
		color,
		display: "flex",
		fontSize: isError ? "md" : "sm",
		pt: .5,
		ref,
		...styles.helpText,
		...rest,
		children: [isError && /* @__PURE__ */ jsx(Icon, {
			mr: 1,
			mt: "3px",
			name: "uiExclamationTriangle",
			pathFill: inputColors.error,
			size: "sm"
		}), children]
	});
});
HelpText.displayName = "HelpText";

//#endregion
export { HelpText as default };
globalThis.__vuiVersion__ = "4.0.0-beta.1"
//# sourceMappingURL=helpText.js.map