"use client";
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
const require_index = require('../../../fixtures/dist/index.cjs');
const require_styles_styler = require('../../../styles/styler.cjs');
const require_components_Box = require('../../Box.cjs');
const require_components_IconSlot = require('../../IconSlot.cjs');
const require_components_client_Pressable = require('../Pressable.cjs');
const require_components_client_Popover_PopoverContext = require('./PopoverContext.cjs');
const require_components_client_Popover_UDSPopoverConfigProvider = require('./UDSPopoverConfigProvider.cjs');
const require_hooks_useForkRef = require('../../../hooks/useForkRef.cjs');
const require_hooks_useSvgFloatingContent = require('../../../hooks/useSvgFloatingContent.cjs');
const require_components_SvgFloatingOverlay = require('../../SvgFloatingOverlay.cjs');
let react = require("react");
let react_jsx_runtime = require("react/jsx-runtime");
let _yahoo_uds_icons = require("@yahoo/uds-icons");
let _ariakit_react = require("@ariakit/react");

//#region src/components/client/Popover/PopoverContent.tsx
const ARROW_HEIGHT = 12;
const ARROW_WIDTH = 22;
const ARROW_TIP_RADIUS_FRACTION = .3;
const PopoverContent = (0, react.forwardRef)(function PopoverContent({ children, className, closeIcon = _yahoo_uds_icons.Cross, slotProps, maxWidth, maxHeight }, ref) {
	const store = (0, _ariakit_react.usePopoverContext)();
	const open = (0, _ariakit_react.useStoreState)(store, "open");
	const internalContext = (0, react.useContext)(require_components_client_Popover_PopoverContext.PopoverInternalContext);
	const disableVerticalSpacing = internalContext?.disableVerticalSpacing ?? false;
	const disableHorizontalSpacing = internalContext?.disableHorizontalSpacing ?? false;
	const sameWidth = internalContext?.sameWidth ?? false;
	const gutter = internalContext?.gutter ?? 4;
	const currentPlacement = (0, _ariakit_react.useStoreState)(store, "currentPlacement");
	const placement = (0, _ariakit_react.useStoreState)(store, "placement");
	const effectivePlacement = currentPlacement ?? placement ?? "top";
	const { borderRadius, gap, spacingHorizontal, spacingVertical, dismissButtonSpacing, dismissIconSize } = require_components_client_Popover_UDSPopoverConfigProvider.usePopoverConfig();
	const defaultBorderRadius = borderRadius["default"];
	const defaultGap = gap["default"];
	const defaultSpacingHorizontal = spacingHorizontal["default"];
	const defaultSpacingVertical = spacingVertical["default"];
	const defaultDismissButtonSpacing = require_index.spacingMap[dismissButtonSpacing["default"]];
	const defaultDismissButtonSize = dismissIconSize["default"] + 2 * defaultDismissButtonSpacing;
	const arrowRef = (0, react.useRef)(null);
	const reducedMotion = internalContext ? internalContext.reducedMotion : false;
	const animationDuration = reducedMotion || !internalContext ? 0 : internalContext.animationDuration;
	const { internalRef, shift, onPositionUpdate, ...svgFloatingContentProps } = require_hooks_useSvgFloatingContent.useSvgFloatingContent({
		open: open ?? false,
		effectivePlacement,
		borderRadius: defaultBorderRadius,
		arrowRef,
		animationDuration,
		hideArrow: internalContext?.hideArrow,
		arrowWidth: ARROW_WIDTH,
		arrowHeight: ARROW_HEIGHT,
		arrowTipRadiusFraction: ARROW_TIP_RADIUS_FRACTION
	});
	const mergedRef = require_hooks_useForkRef.useForkRef(ref, internalRef);
	const { className: closeIconClassName, ...closeIconProps } = slotProps?.closeIcon ?? {};
	const { className: closeIconContainerClassName, ...closeIconContainerProps } = slotProps?.closeIconContainer ?? {};
	const classNames = {
		root: require_styles_styler.getStyles({
			popoverSizeRoot: "default",
			popoverVariantRoot: "default",
			display: "flex",
			position: "relative",
			className: require_styles_styler.cx("z-[9999]", "outline-none", "focus-visible:outline-none", className)
		}),
		contentWrapper: require_styles_styler.getStyles({
			display: "block",
			spacingTop: disableVerticalSpacing ? "0" : defaultSpacingVertical,
			spacingStart: disableHorizontalSpacing ? "0" : defaultSpacingHorizontal,
			spacingBottom: disableVerticalSpacing ? "0" : defaultSpacingVertical,
			spacingEnd: internalContext?.hideDismissButton ? disableHorizontalSpacing ? "0" : defaultSpacingHorizontal : void 0
		}),
		svgBase: require_styles_styler.getStyles({
			popoverSizeSvgBase: "default",
			popoverVariantSvgBase: "default",
			className: require_styles_styler.cx("uds-bgBlurFillFallback")
		}),
		svgBorder: require_styles_styler.getStyles({
			popoverSizeSvgBorder: "default",
			popoverVariantSvgBorder: "default"
		}),
		blur: require_styles_styler.getStyles({
			popoverVariantBlur: "default",
			position: "absolute",
			width: "full",
			height: "full",
			className: require_styles_styler.cx("uds-bgBlurFallback", "top-0", "left-0", "z-[1]")
		}),
		closeIconContainer: require_styles_styler.getStyles({
			flexShrink: "0",
			borderRadius: "full",
			alignItems: "center",
			justifyContent: "center",
			display: "flex",
			className: require_styles_styler.cx(reducedMotion ? "duration-0" : "duration-120", "transition-[background-color]", "bg-carbon-15/0", "hover:bg-carbon-15/10", "active:bg-carbon-15/15", "uds-ring")
		}),
		closeIcon: require_styles_styler.getStyles({
			popoverVariantCloseIcon: "default",
			popoverSizeCloseIcon: "default"
		})
	};
	return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_ariakit_react.Popover, {
		hideOnInteractOutside: (event) => {
			if (internalContext && !internalContext.isControlled) return true;
			internalContext?.onClose?.(event);
			return false;
		},
		ref: mergedRef,
		className: classNames.root,
		portal: internalContext ? internalContext.portal : true,
		gutter: internalContext?.hideArrow ? gutter : ARROW_HEIGHT + gutter,
		updatePosition: onPositionUpdate,
		style: {
			...shift.x !== 0 || shift.y !== 0 ? { transform: `translate(${shift.x}px, ${shift.y}px)` } : {},
			maxWidth,
			maxHeight
		},
		onClose: internalContext?.onClose,
		sameWidth,
		autoFocusOnShow: internalContext?.disableAutoFocus ? false : (element) => {
			element?.focus({ preventScroll: true });
			return false;
		},
		autoFocusOnHide: !internalContext?.disableAutoFocus,
		children: [
			/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_SvgFloatingOverlay.SvgFloatingOverlay, {
				blurClassName: classNames.blur,
				svgClassNames: {
					base: classNames.svgBase,
					border: classNames.svgBorder
				},
				arrowHeight: ARROW_HEIGHT,
				contentWrapperSlotProps: { alignItems: "flex-start" },
				borderRadius: defaultBorderRadius,
				svgBaseStyle: slotProps?.svgBase?.style,
				svgBorderStyle: slotProps?.svgBorder?.style,
				...svgFloatingContentProps,
				children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Box.Box, {
					className: require_styles_styler.cx(classNames.contentWrapper),
					style: { paddingInlineEnd: internalContext?.hideDismissButton || disableHorizontalSpacing ? void 0 : require_index.spacingMap[defaultGap] + require_index.spacingMap[defaultSpacingHorizontal] + defaultDismissButtonSize },
					children
				})
			}),
			!internalContext?.hideDismissButton && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_ariakit_react.PopoverDismiss, { render: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_client_Pressable.Pressable, {
				className: require_styles_styler.cx(classNames.closeIconContainer, "absolute", "z-[4]", closeIconContainerClassName),
				...closeIconContainerProps,
				style: {
					...closeIconContainerProps?.style,
					top: require_index.spacingMap[defaultSpacingVertical],
					insetInlineEnd: require_index.spacingMap[defaultSpacingHorizontal],
					width: defaultDismissButtonSize,
					height: defaultDismissButtonSize,
					...svgFloatingContentProps.childTransitionStyle
				},
				children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_IconSlot.IconSlot, {
					icon: closeIcon,
					iconProps: {
						className: require_styles_styler.cx(classNames.closeIcon, closeIconClassName),
						...closeIconProps
					}
				})
			}) }),
			!internalContext?.hideArrow && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_ariakit_react.PopoverArrow, {
				size: 1,
				ref: arrowRef,
				style: { opacity: 0 }
			})
		]
	});
});
PopoverContent.displayName = "PopoverContent";

//#endregion
exports.PopoverContent = PopoverContent;