/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
"use client";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const require_runtime = require("../../../_virtual/_rolldown/runtime.cjs");
const require_styles_styler = require("../../../styles/styler.cjs");
const require_utils_createSlot = require("../../../utils/createSlot.cjs");
const require_generateDefaultClassName = require("../../../automated-config/dist/utils/generateDefaultClassName.cjs");
let react = require("react");
react = require_runtime.__toESM(react);
let react_jsx_runtime = require("react/jsx-runtime");
//#region src/components/client/Button/ButtonBase.tsx
const defaultVariantRootClass = require_generateDefaultClassName.generateDefaultClassName("button", "variant", "root");
const defaultVariantIconClass = require_generateDefaultClassName.generateDefaultClassName("button", "variant", "icon");
const defaultSizeRootClass = require_generateDefaultClassName.generateDefaultClassName("button", "size", "root");
const defaultSizeIconClass = require_generateDefaultClassName.generateDefaultClassName("button", "size", "icon");
const ButtonBase = (0, react.forwardRef)(function ButtonBase({ size, variant, startIcon, endIcon, iconVariant, loading, disableEffects, children, asChild = false, slotProps, type = "button", className, width, renderStartContent, renderEndContent, renderRoot, ...rest }, forwardedRef) {
	const { className: startIconClassName, ...startIconSlotProps } = slotProps?.startIcon ?? {};
	const { className: endIconClassName, ...endIconSlotProps } = slotProps?.endIcon ?? {};
	const { className: contentClassName, ...contentSlotProps } = slotProps?.content ?? {};
	const gapVariant = loading || startIcon || endIcon ? "withIcon" : "withoutIcon";
	const Slot = (0, react.useMemo)(() => require_utils_createSlot.createSlot(), []);
	const rootSizeClass = (0, react.useMemo)(() => size ? require_styles_styler.getStyles({ buttonSizeRoot: 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({ buttonSizeIcon: 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.getStyles({
			width,
			className: require_styles_styler.cx([
				"uds-ring",
				"uds-hit-target",
				"inline-flex max-w-full overflow-hidden justify-center items-center whitespace-nowrap select-none",
				"[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",
				gapVariant === "withIcon" && "uds-button-with-gap",
				className
			])
		}),
		iconContainer: require_styles_styler.cx(["flex shrink-0 overflow-clip uds-button-icon-container"]),
		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
		]) }),
		content: require_styles_styler.cx(["min-w-0 truncate"])
	}), [
		className,
		disableEffects,
		gapVariant,
		iconSizeClass,
		iconVariantClass,
		loading,
		rest?.disabled,
		rootSizeClass,
		rootVariantClass,
		width
	]);
	const iconRenderArgs = (0, react.useMemo)(() => ({
		iconVariant,
		loading,
		startIcon,
		endIcon,
		iconClassName: styles.icon,
		loadingIconClassName: styles.loadingIcon,
		iconContainerClassName: styles.iconContainer,
		startIconClassName,
		endIconClassName,
		startIconSlotProps,
		endIconSlotProps
	}), [
		endIcon,
		endIconClassName,
		endIconSlotProps,
		iconVariant,
		loading,
		startIcon,
		startIconClassName,
		startIconSlotProps,
		styles.icon,
		styles.iconContainer,
		styles.loadingIcon
	]);
	return renderRoot({
		asChild,
		Slot,
		children,
		buttonRef: forwardedRef,
		type,
		rootClassName: styles.root,
		rest,
		contentClassName: require_styles_styler.cx(styles.content, contentClassName),
		contentSlotProps,
		startContent: renderStartContent(iconRenderArgs),
		endContent: renderEndContent(iconRenderArgs)
	});
});
ButtonBase.displayName = "ButtonBase";
function renderButtonChildren(children, childProps, startContent, contentClassName, contentSlotProps, endContent) {
	return (0, react.cloneElement)(children, childProps, /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
		startContent,
		/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
			className: contentClassName,
			...contentSlotProps,
			children: children.props.children
		}),
		endContent
	] }));
}
//#endregion
exports.ButtonBase = ButtonBase;
exports.renderButtonChildren = renderButtonChildren;
