/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
"use client";
"use client";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
require("../../../_virtual/_rolldown/runtime.cjs");
const require_styles_styler = require("../../../styles/styler.cjs");
const require_components_IconSlot = require("../../IconSlot.cjs");
const require_components_Box = require("../../Box.cjs");
const require_components_HStack = require("../../HStack.cjs");
const require_components_client_Select_selectContext = require("./selectContext.cjs");
const require_components_client_Select_selectFieldStyles = require("./selectFieldStyles.cjs");
const require_components_client_Select_SelectValue = require("./SelectValue.cjs");
let _yahoo_uds_icons = require("@yahoo/uds-icons");
let react = require("react");
let react_jsx_runtime = require("react/jsx-runtime");
let _ariakit_react = require("@ariakit/react");
let motion_react = require("motion/react");
//#region src/components/client/Select/SelectTrigger.tsx
const StartIcon = (0, react.memo)(function StartIcon({ icon, className, iconProps }) {
	if (!icon) return null;
	return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_IconSlot.IconSlot, {
		icon,
		className,
		iconProps: {
			variant: "outline",
			...iconProps
		}
	});
});
StartIcon.displayName = "StartIcon";
const EndIcon = (0, react.memo)(function EndIcon({ icon, className, iconProps }) {
	if (!icon) return null;
	return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_IconSlot.IconSlot, {
		icon,
		className,
		iconProps: {
			variant: "outline",
			...iconProps
		}
	});
});
EndIcon.displayName = "EndIcon";
const SelectTrigger = (0, react.forwardRef)(function SelectTrigger({ placeholder, startIcon, endIcon, slotProps, className, disabled: disabledProp, name, onClick: triggerPassthroughOnClick, onPointerDown: triggerPassthroughOnPointerDown, ...triggerPassthroughProps }, ref) {
	const { size, disabled, readOnly, required, hasError, uid, helpTextId, reduceMotion, triggerWrapperRef } = require_components_client_Select_selectContext.useSelectFieldContext();
	const select = (0, _ariakit_react.useSelectContext)();
	const value = (0, _ariakit_react.useStoreState)(select, "value");
	const open = (0, _ariakit_react.useStoreState)(select, "open");
	const useAnimatedChevron = endIcon === void 0;
	const hasValue = value != null && value !== "";
	const isDisabled = disabledProp ?? disabled;
	const { className: triggerWrapperClassName, ...triggerWrapperProps } = slotProps?.triggerWrapper ?? {};
	const { className: triggerClassName, onClick, ...triggerProps } = slotProps?.trigger ?? {};
	const handlePointerDown = (event) => {
		if (readOnly) {
			event.preventDefault();
			event.stopPropagation();
			return;
		}
		triggerPassthroughOnPointerDown?.(event);
	};
	const handleClick = (event) => {
		if (readOnly) {
			event.preventDefault();
			event.stopPropagation();
			return;
		}
		triggerPassthroughOnClick?.(event);
		onClick?.(event);
	};
	return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Box.Box, {
		ref: triggerWrapperRef,
		position: "relative",
		display: "flex",
		alignItems: "center",
		width: "full",
		...triggerWrapperProps,
		className: require_components_client_Select_selectFieldStyles.getSelectTriggerWrapperClassName(size, hasValue, triggerWrapperClassName),
		children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_ariakit_react.Select, {
			ref,
			id: uid,
			name,
			disabled: isDisabled,
			required,
			"aria-describedby": helpTextId,
			"aria-invalid": hasError,
			"aria-readonly": readOnly || void 0,
			...triggerPassthroughProps,
			...triggerProps,
			onPointerDown: handlePointerDown,
			onClick: handleClick,
			className: require_styles_styler.cx("flex", "w-full", "min-w-0", "items-center", "border-0", "bg-transparent", "rounded-[inherit]", "outline-none", "shadow-none", "uds-hit-target", isDisabled ? "cursor-not-allowed" : "cursor-pointer"),
			children: [
				/* @__PURE__ */ (0, react_jsx_runtime.jsx)(StartIcon, {
					icon: startIcon,
					className: require_components_client_Select_selectFieldStyles.getSelectStartIconClassName(size, hasValue),
					iconProps: slotProps?.startIcon
				}),
				/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
					className: require_components_client_Select_selectFieldStyles.getSelectTriggerClassName({
						size,
						hasValue,
						disabled: isDisabled,
						className: require_styles_styler.cx("flex", "min-w-0", "items-center", "self-stretch", className, triggerClassName)
					}),
					children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
						className: "w-full truncate text-left",
						children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_client_Select_SelectValue.SelectValue, { fallback: placeholder })
					})
				}),
				(useAnimatedChevron || endIcon) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_HStack.HStack, {
					alignItems: "center",
					gap: "1",
					className: "shrink-0",
					children: useAnimatedChevron ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(motion_react.m.div, {
						animate: { rotate: open ? 180 : 0 },
						transition: reduceMotion ? { duration: 0 } : {
							duration: .2,
							ease: "easeInOut"
						},
						"data-testid": "select-chevron",
						children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndIcon, {
							icon: _yahoo_uds_icons.ChevronDown,
							className: require_components_client_Select_selectFieldStyles.getSelectEndIconClassName(size, hasValue),
							iconProps: slotProps?.endIcon
						})
					}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndIcon, {
						icon: endIcon,
						className: require_components_client_Select_selectFieldStyles.getSelectEndIconClassName(size, hasValue),
						iconProps: slotProps?.endIcon
					})
				})
			]
		})
	});
});
SelectTrigger.displayName = "SelectTrigger";
//#endregion
exports.SelectTrigger = SelectTrigger;
