/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
"use client";
import { createSlot } from "../../../utils/createSlot.js";
import { Icon } from "../../Icon.js";
import { usePaginationContext } from "./paginationContext.js";
import { usePaginationIconClassName, usePaginationItemLabelClassName, usePaginationPrevNextClassName } from "./paginationStyles.js";
import { ChevronRight } from "@yahoo/uds-icons";
import { forwardRef, isValidElement } from "react";
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
//#region src/components/client/Pagination/PaginationNext.tsx
const Slot = createSlot();
const PaginationNext = forwardRef(function PaginationNext({ label = "Next", asChild = false, className, onClick, children, ...rest }, ref) {
	const { activePage, totalPages, size, variant, onPageChange } = usePaginationContext();
	const controlClass = usePaginationPrevNextClassName(size, variant, className);
	const iconClass = usePaginationIconClassName(size);
	const textClass = usePaginationItemLabelClassName(size);
	const handleClick = (event) => {
		onClick?.(event);
		if (!event.defaultPrevented) onPageChange?.(activePage + 1);
	};
	if (activePage >= totalPages) return null;
	const Comp = asChild ? Slot : "button";
	const content = children ?? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
		className: textClass,
		children: label
	}), /* @__PURE__ */ jsx(Icon, {
		name: ChevronRight,
		size: "sm",
		color: "current",
		className: iconClass,
		"aria-hidden": true
	})] });
	if (asChild && isValidElement(children)) return /* @__PURE__ */ jsx(Comp, {
		ref,
		type: "button",
		className: controlClass,
		"aria-label": "Go to next page",
		onClick: handleClick,
		...rest,
		children
	});
	return /* @__PURE__ */ jsx(Comp, {
		ref,
		type: "button",
		className: controlClass,
		"aria-label": "Go to next page",
		onClick: handleClick,
		...rest,
		children: content
	});
});
PaginationNext.displayName = "PaginationNext";
//#endregion
export { PaginationNext };
