/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
"use client";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
require("../../../_virtual/_rolldown/runtime.cjs");
const require_styles_styler = require("../../../styles/styler.cjs");
const require_utils_hasDisplayName = require("../../../utils/hasDisplayName.cjs");
const require_components_Box = require("../../Box.cjs");
const require_hooks_useRtl = require("../../../hooks/useRtl.cjs");
const require_components_client_PaddleNav_paddleNavContext = require("./paddleNavContext.cjs");
const require_components_client_PaddleNav_PaddleButtonNext = require("./PaddleButtonNext.cjs");
const require_components_client_PaddleNav_PaddleButtonPrevious = require("./PaddleButtonPrevious.cjs");
const require_components_client_PaddleNav_PaddleNavContent = require("./PaddleNavContent.cjs");
const require_components_client_PaddleNav_utils_resolvePaddleNavCornerOrientation = require("./utils/resolvePaddleNavCornerOrientation.cjs");
let react = require("react");
let react_jsx_runtime = require("react/jsx-runtime");
//#region src/components/client/PaddleNav/PaddleNav.tsx
function isPaddleButtonPrevious(child) {
	return child.type === require_components_client_PaddleNav_PaddleButtonPrevious.PaddleButtonPrevious || require_utils_hasDisplayName.hasDisplayName(child, "PaddleButtonPrevious");
}
function isPaddleButtonNext(child) {
	return child.type === require_components_client_PaddleNav_PaddleButtonNext.PaddleButtonNext || require_utils_hasDisplayName.hasDisplayName(child, "PaddleButtonNext");
}
function partitionChildren(children) {
	const contentNodes = [];
	let previousPaddle;
	let nextPaddle;
	const passthroughNodes = [];
	react.Children.forEach(children, (child) => {
		if (!(0, react.isValidElement)(child)) {
			passthroughNodes.push(child);
			return;
		}
		if (isPaddleButtonPrevious(child)) {
			if (!previousPaddle) previousPaddle = child;
			return;
		}
		if (isPaddleButtonNext(child)) {
			if (!nextPaddle) nextPaddle = child;
			return;
		}
		if (child.type === require_components_client_PaddleNav_PaddleNavContent.PaddleNavContent || require_utils_hasDisplayName.hasDisplayName(child, "PaddleNavContent")) {
			contentNodes.push(child);
			return;
		}
		passthroughNodes.push(child);
	});
	return {
		contentNodes,
		previousPaddle,
		nextPaddle,
		passthroughNodes
	};
}
function getPaddleWrapperClassName(positionClasses, hidden) {
	return require_styles_styler.cx(positionClasses, hidden && "pointer-events-none");
}
function getCornerInsetClasses(orientation, outsideContent) {
	const inside = !outsideContent;
	switch (orientation) {
		case "top-left": return inside ? "top-2 left-2" : "-top-12 left-0";
		case "top-right": return inside ? "top-2 right-2" : "-top-12 right-0";
		case "bottom-left": return inside ? "bottom-2 left-2" : "-bottom-12 left-0";
		case "bottom-right": return inside ? "bottom-2 right-2" : "-bottom-12 right-0";
		default: return "";
	}
}
const horizontalOverlayStartClass = "left-2 top-1/2 -translate-y-1/2";
const horizontalOverlayEndClass = "right-2 top-1/2 -translate-y-1/2";
/** Keeps prev/next paddles in [←][→] screen order inside a cluster when an ancestor sets dir="rtl". */
const paddleClusterClassName = "inline-flex flex-row gap-2 items-center pointer-events-auto";
const PaddleNav = (0, react.forwardRef)(function PaddleNav({ children, orientation = "horizontal", outsideContent = false, variant = "primary", size = "md", className, ...rest }, ref) {
	const isRtl = require_hooks_useRtl.useRtl();
	const [paddleHiddenByRole, setPaddleHiddenByRole] = (0, react.useState)(require_components_client_PaddleNav_paddleNavContext.defaultPaddleHiddenByRole);
	const registerPaddleHidden = (0, react.useCallback)((role, hidden) => {
		setPaddleHiddenByRole((current) => {
			if (current[role] === hidden) return current;
			return {
				...current,
				[role]: hidden
			};
		});
	}, []);
	const paddleNavContextValue = (0, react.useMemo)(() => ({
		orientation,
		outsideContent,
		variant,
		size,
		paddleHiddenByRole,
		registerPaddleHidden
	}), [
		orientation,
		outsideContent,
		variant,
		size,
		paddleHiddenByRole,
		registerPaddleHidden
	]);
	const { contentNodes, previousPaddle, nextPaddle, passthroughNodes } = partitionChildren(children);
	const isVertical = orientation === "vertical";
	const isHorizontalCenter = orientation === "horizontal";
	const isCenter = isVertical || isHorizontalCenter;
	const isCorner = !isCenter;
	const resolvedOrientation = require_components_client_PaddleNav_utils_resolvePaddleNavCornerOrientation.resolvePaddleNavCornerOrientation(orientation, isCorner ? isRtl : false);
	const physicalCornerOrientation = isCorner && resolvedOrientation !== "horizontal" && resolvedOrientation !== "vertical" ? resolvedOrientation : void 0;
	if (!(contentNodes.length > 0)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_client_PaddleNav_paddleNavContext.PaddleNavContext.Provider, {
		value: paddleNavContextValue,
		children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_Box.Box, {
			ref,
			dir: isVertical ? void 0 : "ltr",
			className: require_styles_styler.cx(paddleClusterClassName, isVertical && "flex-col", className),
			"data-paddle-nav-orientation": orientation,
			"data-paddle-nav-outside": outsideContent ? "true" : "false",
			...rest,
			children: [
				previousPaddle,
				nextPaddle,
				passthroughNodes
			]
		})
	});
	if (isCenter) {
		if (outsideContent) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_client_PaddleNav_paddleNavContext.PaddleNavContext.Provider, {
			value: paddleNavContextValue,
			children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_Box.Box, {
				ref,
				dir: isHorizontalCenter ? "ltr" : void 0,
				display: "inline-flex",
				alignItems: "center",
				justifyContent: "center",
				flexDirection: isVertical ? "column" : "row",
				columnGap: isVertical ? void 0 : "2",
				rowGap: isVertical ? "2" : void 0,
				className,
				"data-paddle-nav-orientation": orientation,
				"data-paddle-nav-outside": "true",
				...rest,
				children: [
					previousPaddle,
					/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
						className: require_styles_styler.cx("relative min-w-0 min-h-0 flex-1"),
						children: contentNodes
					}),
					nextPaddle,
					passthroughNodes
				]
			})
		});
		return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_client_PaddleNav_paddleNavContext.PaddleNavContext.Provider, {
			value: paddleNavContextValue,
			children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
				ref,
				className: require_styles_styler.cx("relative inline-block", className),
				"data-paddle-nav-orientation": orientation,
				"data-paddle-nav-outside": "false",
				...rest,
				children: [
					contentNodes,
					previousPaddle && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
						className: getPaddleWrapperClassName(require_styles_styler.cx("absolute z-10 pointer-events-auto", isVertical ? "top-2 left-1/2 -translate-x-1/2" : horizontalOverlayStartClass), paddleHiddenByRole.previous),
						children: previousPaddle
					}),
					nextPaddle && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
						className: getPaddleWrapperClassName(require_styles_styler.cx("absolute z-10 pointer-events-auto", isVertical ? "bottom-2 left-1/2 -translate-x-1/2" : horizontalOverlayEndClass), paddleHiddenByRole.next),
						children: nextPaddle
					}),
					passthroughNodes
				]
			})
		});
	}
	return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_client_PaddleNav_paddleNavContext.PaddleNavContext.Provider, {
		value: paddleNavContextValue,
		children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
			ref,
			className: require_styles_styler.cx("relative inline-block", className),
			"data-paddle-nav-orientation": orientation,
			"data-paddle-nav-outside": outsideContent ? "true" : "false",
			...rest,
			children: [
				contentNodes,
				(previousPaddle || nextPaddle) && physicalCornerOrientation && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
					dir: "ltr",
					className: require_styles_styler.cx("absolute z-10", paddleClusterClassName, getCornerInsetClasses(physicalCornerOrientation, outsideContent)),
					children: [previousPaddle, nextPaddle]
				}),
				passthroughNodes
			]
		})
	});
});
PaddleNav.displayName = "PaddleNav";
//#endregion
exports.PaddleNav = PaddleNav;
