/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
"use client";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
require("../../../_virtual/_rolldown/runtime.cjs");
let react = require("react");
let react_jsx_runtime = require("react/jsx-runtime");
//#region src/components/client/Popover/UDSPopoverConfigProvider.tsx
const PopoverContext = (0, react.createContext)(void 0);
const UDSPopoverConfigProvider = ({ children, value }) => {
	const existingContext = (0, react.useContext)(PopoverContext);
	if ("type" in value) {
		if (!existingContext) throw new Error("Cannot merge context values without an existing PopoverContext");
		return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PopoverContext.Provider, {
			value: {
				...existingContext,
				...value.value
			},
			children
		});
	}
	return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PopoverContext.Provider, {
		value,
		children
	});
};
UDSPopoverConfigProvider.displayName = "UDSPopoverConfigProvider";
function usePopoverConfig(sizeProp, variantProp, options) {
	const context = (0, react.useContext)(PopoverContext);
	if (!context) throw new Error("usePopoverConfig must be used within a UDSConfigProvider or UDSPopoverConfigProvider");
	const { defaultSize, defaultVariant, gap, borderRadius, spacingHorizontal, spacingVertical, dismissButtonSpacing, dismissIconSize, placementMap, placement, ...rest } = context;
	const size = sizeProp ?? defaultSize;
	const variant = variantProp ?? defaultVariant;
	return {
		...rest,
		size,
		variant,
		borderRadius: borderRadius[size],
		spacingHorizontal: spacingHorizontal[size],
		spacingVertical: spacingVertical[size],
		gap: gap[size],
		dismissButtonSpacing: dismissButtonSpacing[size],
		dismissIconSize: dismissIconSize[size],
		ariaKitPlacement: placementMap[options?.placement ?? placement]
	};
}
//#endregion
exports.UDSPopoverConfigProvider = UDSPopoverConfigProvider;
exports.usePopoverConfig = usePopoverConfig;
