/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
"use client";
import { cx, getStyles } from "../../../styles/styler.js";
import { IconSlot } from "../../IconSlot.js";
import { Text } from "../../Text.js";
import { HStack } from "../../HStack.js";
import { forwardRef, useMemo } from "react";
import { jsx, jsxs } from "react/jsx-runtime";
import { useReducedMotion } from "motion/react";
//#region src/components/client/Chip/ChipBase.tsx
const SIZE_DEFAULT = "md";
const VARIANT_DEFAULT = "primary";
const MAX_WIDTH_DEFAULT = 200;
const ChipBase = forwardRef(function ChipBase({ size = SIZE_DEFAULT, minWidth, maxWidth = MAX_WIDTH_DEFAULT, startIcon, endIcon, as: As = "div", reduceMotion: forceReduceMotion, disabled = false, className, slotProps, children, ...rest }, ref) {
	const cssAnimationDuration = useReducedMotion() || forceReduceMotion ? "duration-0" : "duration-120";
	const { className: textClassName, ...textProps } = slotProps?.text ?? {};
	const { className: startIconClassName, ...startIconProps } = slotProps?.startIcon ?? {};
	const { className: endIconClassName, ...endIconProps } = slotProps?.endIcon ?? {};
	/**
	* Styles
	*/
	const classNames = useMemo(() => ({
		root: getStyles({
			chipSizeRoot: size,
			className: cx({
				"pointer-events-none": disabled,
				"cursor-default": disabled,
				"opacity-50": disabled
			}, "inline-flex", "items-center", cssAnimationDuration, "transition-[background-color,outline-color,box-shadow]", className)
		}),
		text: cx("truncate", "whitespace-nowrap", "text-center", "flex-1", textClassName),
		icon: getStyles({ chipSizeIcon: size })
	}), [
		className,
		cssAnimationDuration,
		disabled,
		size,
		textClassName
	]);
	const inlineStyles = useMemo(() => ({ root: {
		maxWidth: `${maxWidth}px`,
		...minWidth ? { minWidth: `${minWidth}px` } : {}
	} }), [maxWidth, minWidth]);
	return /* @__PURE__ */ jsx(HStack, {
		asChild: true,
		ref,
		className: classNames.root,
		style: inlineStyles.root,
		...rest,
		children: /* @__PURE__ */ jsxs(As, {
			disabled,
			children: [
				startIcon && /* @__PURE__ */ jsx(IconSlot, {
					icon: startIcon,
					iconProps: {
						variant: "fill",
						className: cx(classNames.icon, startIconClassName),
						...startIconProps
					}
				}),
				/* @__PURE__ */ jsx(Text, {
					as: "span",
					color: "current",
					variant: "inherit",
					className: classNames.text,
					...textProps,
					children
				}),
				endIcon && /* @__PURE__ */ jsx(IconSlot, {
					icon: endIcon,
					iconProps: {
						variant: "fill",
						className: cx(classNames.icon, endIconClassName),
						...endIconProps
					}
				})
			]
		})
	});
});
ChipBase.displayName = "ChipBase";
//#endregion
export { ChipBase, VARIANT_DEFAULT };
