/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
"use client";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
require("../../../_virtual/_rolldown/runtime.cjs");
const require_index = require("../../../css-tokens/dist/index.cjs");
const require_utils_createSlot = require("../../../utils/createSlot.cjs");
const require_components_Icon = require("../../Icon.cjs");
const require_hooks_usePrefersReducedMotion = require("../../../hooks/usePrefersReducedMotion.cjs");
const require_components_client_SpringMotionConfig = require("../SpringMotionConfig.cjs");
require("../Button/buttonConstants.cjs");
const require_components_client_Button_Button = require("../Button/Button.cjs");
const require_components_client_IconButton_IconButtonBase = require("./IconButtonBase.cjs");
let _yahoo_uds_icons = require("@yahoo/uds-icons");
let react = require("react");
let react_jsx_runtime = require("react/jsx-runtime");
let motion_react = require("motion/react");
//#region src/components/client/IconButton/IconButton.tsx
/**
* **⚙️️ An icon button element that can be used to trigger an action**
*
* @componentType Client component
*/
const IconButton = (0, react.forwardRef)(function IconButton(props, forwardedRef) {
	const prefersReducedMotion = require_hooks_usePrefersReducedMotion.usePrefersReducedMotion();
	const disableMotion = !!props.disableEffects || !!props.disabled;
	const layoutVariant = (0, react.useMemo)(() => prefersReducedMotion ? "smooth" : "subtle", [prefersReducedMotion]);
	const Slot = (0, react.useMemo)(() => require_utils_createSlot.createSlot(), []);
	const MotionSlot = (0, react.useMemo)(() => motion_react.m.create(Slot), [Slot]);
	const buttonVariants = (0, react.useMemo)(() => ({
		rest: { scale: disableMotion ? 1 : `var(${require_index.BUTTON_SCALE_EFFECT_REST})` },
		hover: { scale: disableMotion ? 1 : `var(${require_index.BUTTON_SCALE_EFFECT_HOVER})` },
		pressed: { scale: disableMotion ? 1 : `var(${require_index.BUTTON_SCALE_EFFECT_PRESSED})` }
	}), [disableMotion]);
	return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_client_IconButton_IconButtonBase.IconButtonBase, {
		...props,
		ref: forwardedRef,
		renderIconContent: ({ asChild, loading, name, iconVariant, children, iconClassName, loadingIconClassName, iconSlotClassName, iconSlotProps }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(motion_react.AnimatePresence, {
			initial: false,
			mode: "popLayout",
			children: [loading && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(motion_react.m.span, {
				variants: require_components_client_Button_Button.loadingMotionVariants,
				initial: "loading",
				animate: "loading",
				exit: "hide",
				children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Icon.Icon, {
					size: "sm",
					name: _yahoo_uds_icons.Progress,
					variant: iconVariant,
					color: "current",
					className: loadingIconClassName
				})
			}, "loading"), name && !loading && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(motion_react.m.span, {
				variants: require_components_client_Button_Button.iconMotionVariants,
				initial: "icon",
				animate: "icon",
				exit: "hide",
				children: !asChild && children || /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Icon.Icon, {
					size: "sm",
					name,
					variant: iconVariant,
					color: "current",
					className: [iconClassName, iconSlotClassName].filter(Boolean).join(" "),
					...iconSlotProps
				})
			}, name.name)]
		}),
		renderRoot: ({ asChild, children, buttonRef, type, htmlName, rootClassName, rest, iconContent }) => {
			if (asChild && (0, react.isValidElement)(children)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_client_SpringMotionConfig.SpringMotionConfig, {
				layoutSpeed: "3",
				layoutVariant,
				reducedMotion: props.disableEffects ? "always" : "user",
				children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MotionSlot, {
					type,
					className: rootClassName,
					initial: "icon",
					variants: buttonVariants,
					whileHover: "hover",
					whileTap: "pressed",
					...rest,
					children: require_components_client_IconButton_IconButtonBase.renderIconButtonAsChild(children, iconContent)
				})
			});
			return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_client_SpringMotionConfig.SpringMotionConfig, {
				layoutSpeed: "3",
				layoutVariant,
				reducedMotion: props.disableEffects ? "always" : "user",
				children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(motion_react.m.button, {
					ref: buttonRef,
					type,
					className: rootClassName,
					name: htmlName,
					initial: "icon",
					variants: buttonVariants,
					whileHover: "hover",
					whileTap: "pressed",
					...rest,
					children: iconContent
				})
			});
		}
	});
});
IconButton.displayName = "IconButton";
//#endregion
exports.IconButton = IconButton;
