import { isJsx } from "../utils/assertion.js";
import { runIfFn } from "../utils/function.js";
import { cs } from "../utils/styles.js";
import "../utils/index.js";
import { useStyleConfig } from "../core/theme.js";
import { vui } from "../core/vui.js";
import box_default from "../box/box.js";
import "../box/index.js";
import "../core/index.js";
import { PaginationProvider } from "./context.js";
import paginationButton_default from "./paginationButton.js";
import paginationEllipsis_default from "./paginationEllipsis.js";
import paginationGoToPage_default from "./paginationGoToPage.js";
import paginationPrevNext_default from "./paginationPrevNext.js";
import paginationNavigation_default from "./paginationNavigation.js";
import paginationResults_default from "./paginationResults.js";
import usePagination from "./usePagination.js";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";

//#region src/pagination/pagination.tsx
/**
* Displays page navigation buttons together with page and item count.
* GoToPage component is shown automatically above 10 pages.
*/
const Pagination = vui((props, ref) => {
	const { children, className, count, defaultPage, goToPage, items: itemsProp = [], navigation, onPageChange, page: pageProp, pageSize, results, size, variant, ...rest } = props;
	const styles = useStyleConfig("Pagination", props);
	const { items = itemsProp, ...paginationProps } = usePagination({
		count,
		defaultPage,
		onPageChange,
		page: pageProp,
		pageSize
	});
	const context = {
		...paginationProps,
		items,
		size,
		variant
	};
	return /* @__PURE__ */ jsx(PaginationProvider, {
		value: context,
		children: /* @__PURE__ */ jsx(box_default, {
			centerV: true,
			className: cs("vui-pagination", className),
			gap: 3,
			ref,
			w: 1,
			wrap: true,
			...styles.container,
			...rest,
			children: runIfFn(children, context) ?? /* @__PURE__ */ jsxs(Fragment, { children: [
				isJsx(results) ? results : /* @__PURE__ */ jsx(paginationResults_default, {}),
				isJsx(navigation) ? navigation : /* @__PURE__ */ jsx(paginationNavigation_default, { ml: "auto" }),
				isJsx(goToPage) ? goToPage : paginationProps.pageCount > 10 && /* @__PURE__ */ jsx(paginationGoToPage_default, {})
			] })
		})
	});
});
Pagination.Button = paginationButton_default;
Pagination.Ellipsis = paginationEllipsis_default;
Pagination.GoToPage = paginationGoToPage_default;
Pagination.Navigation = paginationNavigation_default;
Pagination.PrevNext = paginationPrevNext_default;
Pagination.Results = paginationResults_default;
Pagination.displayName = "Pagination";

//#endregion
export { Pagination };
globalThis.__vuiVersion__ = "4.0.0-beta.1"
//# sourceMappingURL=pagination.js.map