"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_components_client_Popover_PopoverContext = require('./PopoverContext.cjs');
const require_components_client_Popover_UDSPopoverConfigProvider = require('./UDSPopoverConfigProvider.cjs');
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/Popover/Popover.tsx
const POPOVER_OPEN_EVENT = "uds:popover-open";
/**
* **⚙️️ A Popover component that anchors to a trigger element
*
* @componentType Client component
*
* @description
* Popover is a floating surface used to display contextual content anchored to a trigger. It is typically used for lightweight interactions such as quick settings, inline actions, previews, and simple selection.
*
* Popover is a container component, the shell is consistent, but the content inside can vary widely depending on product needs.*
* @see
* Check out the {@link https://uds.build/docs/components/popover Popover Docs} for more info
*
* @example
* ```tsx
* 'use client';
* import { Popover, PopoverTrigger, PopoverContent, Button } from "@yahoo/uds";
*
* <Popover>
*   <PopoverTrigger>
*     <Button>Popover Trigger</Button>
*   </PopoverTrigger>
*   <PopoverContent>basic popover content</PopoverContent>
* </Popover>
*```
*
* @related [Toast](https://uds.build/docs/components/toast), [Tooltip](https://uds.build/docs/components/tooltip)
**/
function Popover({ children, placement, open, defaultOpen = false, portal = true, hideArrow = false, hideDismissButton = false, onClose, onOpen, reduceMotion: forceReduceMotion = false, disableAutoFocus = false, disableVerticalSpacing = false, disableHorizontalSpacing = false, sameWidth = false, gutter = 4 }) {
	const controlledProps = open !== void 0 ? {
		showTimeout: 0,
		hideTimeout: 0,
		timeout: 0,
		...open ? { mounted: true } : {}
	} : void 0;
	const { animationDuration: animationDurationConfig, ariaKitPlacement } = require_components_client_Popover_UDSPopoverConfigProvider.usePopoverConfig({ placement });
	const id = (0, react.useId)();
	const store = (0, _ariakit_react.usePopoverStore)({ defaultOpen });
	const handleSetOpen = (0, react.useCallback)((newOpen) => {
		if (newOpen) {
			onOpen?.();
			document.dispatchEvent(new CustomEvent(POPOVER_OPEN_EVENT, { detail: id }));
		}
	}, [onOpen, id]);
	(0, react.useEffect)(() => {
		const handler = (e) => {
			if (("detail" in e ? e.detail : void 0) !== id) store?.setState("open", false);
		};
		document.addEventListener(POPOVER_OPEN_EVENT, handler);
		return () => document.removeEventListener(POPOVER_OPEN_EVENT, handler);
	}, [id, store]);
	const isControlled = open !== void 0;
	const reducedMotion = (0, motion_react.useReducedMotion)() || forceReduceMotion;
	const animationDuration = reducedMotion ? 0 : animationDurationConfig;
	return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_client_Popover_PopoverContext.PopoverInternalContext.Provider, {
		value: {
			portal,
			hideArrow,
			hideDismissButton,
			onClose,
			isControlled,
			animationDuration,
			reducedMotion,
			disableAutoFocus,
			disableVerticalSpacing,
			disableHorizontalSpacing,
			sameWidth,
			gutter
		},
		children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_ariakit_react.PopoverProvider, {
			placement: ariaKitPlacement,
			animated: animationDuration,
			open,
			setOpen: handleSetOpen,
			store,
			...controlledProps,
			children
		})
	});
}
Popover.displayName = "Popover";

//#endregion
exports.Popover = Popover;