/*! © 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_styles_styler = require("../../styles/styler.cjs");
const require_utils_createSlot = require("../../utils/createSlot.cjs");
const require_components_Icon = require("../Icon.cjs");
const require_generateDefaultClassName = require("../../automated-config/dist/utils/generateDefaultClassName.cjs");
require("./buttonConstants.cjs");
const require_components_client_SpringMotionConfig = require("./SpringMotionConfig.cjs");
const require_components_client_Button = require("./Button.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.tsx
const defaultSizeRootClass = require_generateDefaultClassName.generateDefaultClassName("iconbutton", "size", "root");
const defaultSizeIconClass = require_generateDefaultClassName.generateDefaultClassName("iconbutton", "size", "icon");
const defaultVariantRootClass = require_generateDefaultClassName.generateDefaultClassName("button", "variant", "root");
const defaultVariantIconClass = require_generateDefaultClassName.generateDefaultClassName("button", "variant", "icon");
/**
* **⚙️️ An icon button element that can be used to trigger an action**
*
* @componentType Client component
*
* @description An icon button is essentially an interactive icon. They should be used to display an icon which, when clicked, allows the user to trigger an action. Icon buttons provide additional features such hover states, focus states, and pressable functionality.
*
* @see
* Check out the {@link https://uds.build/docs/components/icon-button IconButton Docs} for more info
*
* @usage
* - When you need a button that is represented by an icon rather than text. This is useful in compact spaces, toolbars, or when the action is commonly understood through a visual symbol.
* - If you need a button that is used to trigger a non-critical action.
*
* @example
* ```tsx
* 'use client';
* import { IconButton } from "@yahoo/uds";
* import { AddFolder } from "@yahoo/uds-icons";
*
* <IconButton name={AddFolder} variant="primary" />
* ```
*
* @related [Icon](https://uds.build/docs/components/icon), [Button](https://uds.build/docs/components/button), and [Pressable](https://uds.build/docs/components/pressable)
*
**/
const IconButton = (0, react.forwardRef)(function IconButton({ variant, size, iconVariant, loading, disableEffects, name, asChild = false, slotProps, type = "button", htmlName, className, children, ...rest }, forwardedRef) {
	const ref = (0, react.useRef)(null);
	(0, react.useImperativeHandle)(forwardedRef, () => ref.current);
	const { className: iconSlotClassName, ...iconSlotProps } = slotProps?.icon ?? {};
	const prefersReducedMotion = (0, motion_react.useReducedMotion)();
	const disableMotion = !!disableEffects || !!rest?.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]);
	const rootSizeClass = (0, react.useMemo)(() => size ? require_styles_styler.getStyles({ iconbuttonSizeRoot: size }) : defaultSizeRootClass, [size]);
	const rootVariantClass = (0, react.useMemo)(() => variant ? require_styles_styler.getStyles({ buttonVariantRoot: variant }) : defaultVariantRootClass, [variant]);
	const iconSizeClass = (0, react.useMemo)(() => size ? require_styles_styler.getStyles({ iconbuttonSizeIcon: size }) : defaultSizeIconClass, [size]);
	const iconVariantClass = (0, react.useMemo)(() => variant ? require_styles_styler.getStyles({ buttonVariantIcon: variant }) : defaultVariantIconClass, [variant]);
	const styles = (0, react.useMemo)(() => ({
		root: require_styles_styler.cx("uds-ring", "uds-hit-target", "inline-flex overflow-hidden justify-center items-center", "[transform-origin:center]", "[backface-visibility:hidden]", "[transition-property:color,background-color,border-color,box-shadow,text-decoration-color,fill,stroke]", "[transition-timing-function:cubic-bezier(0,0,0.2,1)]", "[transition-duration:220ms]", rootSizeClass, rootVariantClass, rest?.disabled && "cursor-not-allowed", loading && "uds-button-loading", disableEffects && "uds-button-without-effects", className),
		icon: require_styles_styler.getStyles({ className: require_styles_styler.cx(iconSizeClass, iconVariantClass) }),
		loadingIcon: require_styles_styler.getStyles({ className: require_styles_styler.cx([
			"animate-spin",
			iconSizeClass,
			iconVariantClass
		]) })
	}), [
		className,
		disableEffects,
		iconSizeClass,
		iconVariantClass,
		loading,
		rest?.disabled,
		rootSizeClass,
		rootVariantClass
	]);
	const iconContent = (0, react.useMemo)(() => /* @__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.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: styles.loadingIcon
			})
		}, "loading"), name && !loading && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(motion_react.m.span, {
			variants: require_components_client_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: require_styles_styler.cx(styles.icon, iconSlotClassName),
				...iconSlotProps
			})
		}, name.name)]
	}), [
		asChild,
		children,
		iconSlotClassName,
		iconSlotProps,
		iconVariant,
		loading,
		name,
		styles
	]);
	if (asChild && (0, react.isValidElement)(children)) {
		const childProps = children.props;
		return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_client_SpringMotionConfig.SpringMotionConfig, {
			layoutSpeed: "3",
			layoutVariant,
			reducedMotion: disableEffects ? "always" : "user",
			children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MotionSlot, {
				type,
				className: styles.root,
				initial: "icon",
				variants: buttonVariants,
				whileHover: "hover",
				whileTap: "pressed",
				...rest,
				children: (0, react.cloneElement)(children, childProps, iconContent)
			})
		});
	}
	return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_client_SpringMotionConfig.SpringMotionConfig, {
		layoutSpeed: "3",
		layoutVariant,
		reducedMotion: disableEffects ? "always" : "user",
		children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(motion_react.m.button, {
			ref,
			type,
			className: styles.root,
			name: htmlName,
			initial: "icon",
			variants: buttonVariants,
			whileHover: "hover",
			whileTap: "pressed",
			...rest,
			children: iconContent
		})
	});
});
IconButton.displayName = "IconButton";
//#endregion
exports.IconButton = IconButton;
