/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
"use client";
import { cx, getStyles } from "../../../styles/styler.js";
import { Box } from "../../Box.js";
import { usePrefersReducedMotion } from "../../../hooks/usePrefersReducedMotion.js";
import { SpringMotionConfig } from "../SpringMotionConfig.js";
import { RADIO_SIZES, RADIO_VARIANTS } from "./radioConstants.js";
import { RadioBase } from "./RadioBase.js";
import { forwardRef } from "react";
import { jsx, jsxs } from "react/jsx-runtime";
import { m } from "motion/react";
//#region src/components/client/Radio/Radio.tsx
const MotionBox = m.create(Box);
MotionBox.displayName = "RadioMotionBox";
const hoverTransition = {
	layoutVariant: "smooth",
	layoutSpeed: "3"
};
const pressTransition = {
	layoutVariant: "veryBouncy",
	layoutSpeed: "4"
};
/**
* **⚙️️ A Radio.
*
* @componentType Client component
*
* @description
* A radio component allows users to select one or multiple options from a set. Unlike checkbox, radio buttons cannot have multiple selected in a form, allowing only 1 selection in a group. It represents a binary state, typically as selected or unselected.
*
* @see
* Check out the {@link https://uds.build/docs/components/radio Radio Docs} for more info
*
* @usage
* - Forms: Radio
*
* @example
* ```tsx
* 'use client';
* import { Radio } from "@yahoo/uds";
*
* <Radio label="Name" />
*```
*
* @related [Radio](https://uds.build/docs/components/Radio).
**/
const Radio = forwardRef(function Radio({ reduceMotion: forceReduceMotion, ...props }, parentRef) {
	const prefersReducedMotion = usePrefersReducedMotion();
	const reduceMotion = forceReduceMotion ? "always" : "user";
	const cssAnimationDuration = prefersReducedMotion || forceReduceMotion ? "duration-0" : "duration-120";
	return /* @__PURE__ */ jsx(RadioBase, {
		...props,
		ref: parentRef,
		cssAnimationDuration,
		enableInteractionTracking: true,
		renderRoot: ({ className, style, rootSlotProps, hasLabel, isPressed, onHoverStart, onHoverEnd, onTapStart, onTapEnd, children }) => {
			const RootElement = hasLabel ? m.label : m.div;
			return /* @__PURE__ */ jsx(SpringMotionConfig, {
				reducedMotion: reduceMotion,
				...isPressed ? pressTransition : hoverTransition,
				children: /* @__PURE__ */ jsx(RootElement, {
					className,
					"data-testid": "container",
					style,
					onHoverStart,
					onHoverEnd,
					onTapStart,
					onTap: onTapEnd,
					onTapCancel: onTapEnd,
					tabIndex: -1,
					...rootSlotProps,
					children
				})
			});
		},
		renderIndicator: ({ size, variant, checked, disabled, showHoverEffect, showPressedEffect, cssAnimationDuration, radioSlotProps, radioIconSlotProps, children }) => {
			const scale = showPressedEffect ? .9 : showHoverEffect ? 1.1 : 1;
			const checkOpacity = checked ? showPressedEffect ? cx("opacity-55") : cx("opacity-100") : cx("opacity-0");
			const showShadow = !disabled && (showPressedEffect && !checked || showHoverEffect && checked);
			const classNames = {
				radio: getStyles({
					radioSizeRadio: size,
					radioVariantRadio: variant,
					radioVariantValueRadio: checked ? "checked" : "unchecked",
					className: cx([
						"border",
						"uds-ring",
						"uds-ring-within",
						cssAnimationDuration,
						"transition-[background-color,border-color]",
						"transition-shadow"
					])
				}),
				radioCircle: getStyles({
					radioVariantRadioCircle: variant,
					radioVariantValueRadioCircle: checked ? "checked" : "unchecked",
					className: cx([
						"pointer-events-none",
						"w-[8px]",
						"h-[8px]",
						checkOpacity,
						cssAnimationDuration,
						"transition-opacity"
					])
				})
			};
			return /* @__PURE__ */ jsxs(MotionBox, {
				position: "relative",
				borderRadius: "full",
				alignItems: "center",
				justifyContent: "center",
				flex: "none",
				className: classNames.radio,
				animate: { scale },
				insetShadow: showShadow ? "lg-invert" : "none",
				...radioSlotProps,
				children: [children, /* @__PURE__ */ jsx(Box, {
					borderRadius: "full",
					className: classNames.radioCircle,
					...radioIconSlotProps
				})]
			});
		}
	});
});
Radio.displayName = "Radio";
//#endregion
export { RADIO_SIZES, RADIO_VARIANTS, Radio };
