'use client';
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
import { isNumber } from 'payload/shared';
import React, { Fragment } from 'react';
import { Pagination } from '../../elements/Pagination/index.js';
import { PerPage } from '../../elements/PerPage/index.js';
import { useListQuery } from '../../providers/ListQuery/context.js';
import { useTranslation } from '../../providers/Translation/index.js';
import './index.scss';
const baseClass = 'page-controls';
/**
 * @internal
 */ export const PageControlsComponent = ({ AfterPageControls, collectionConfig, data, handlePageChange, handlePerPageChange, limit })=>{
    const { i18n } = useTranslation();
    return /*#__PURE__*/ _jsxDEV("div", {
        className: baseClass,
        children: [
            /*#__PURE__*/ _jsxDEV(Pagination, {
                hasNextPage: data.hasNextPage,
                hasPrevPage: data.hasPrevPage,
                limit: data.limit,
                nextPage: data.nextPage,
                numberOfNeighbors: 1,
                onChange: handlePageChange,
                page: data.page,
                prevPage: data.prevPage,
                totalPages: data.totalPages
            }, void 0, false, {
                fileName: "src/elements/PageControls/index.tsx",
                lineNumber: 39,
                columnNumber: 7
            }, this),
            data.totalDocs > 0 && /*#__PURE__*/ _jsxDEV(Fragment, {
                children: [
                    /*#__PURE__*/ _jsxDEV("div", {
                        className: `${baseClass}__page-info`,
                        children: [
                            data.page * data.limit - (data.limit - 1),
                            "-",
                            data.totalPages > 1 && data.totalPages !== data.page ? data.limit * data.page : data.totalDocs,
                            ' ',
                            i18n.t('general:of'),
                            " ",
                            data.totalDocs
                        ]
                    }, void 0, true, {
                        fileName: "src/elements/PageControls/index.tsx",
                        lineNumber: 52,
                        columnNumber: 11
                    }, this),
                    /*#__PURE__*/ _jsxDEV(PerPage, {
                        handleChange: handlePerPageChange,
                        limit: limit,
                        limits: collectionConfig?.admin?.pagination?.limits,
                        resetPage: data.totalDocs <= data.pagingCounter
                    }, void 0, false, {
                        fileName: "src/elements/PageControls/index.tsx",
                        lineNumber: 59,
                        columnNumber: 11
                    }, this),
                    AfterPageControls
                ]
            }, void 0, true, {
                fileName: "src/elements/PageControls/index.tsx",
                lineNumber: 51,
                columnNumber: 9
            }, this)
        ]
    }, void 0, true, {
        fileName: "src/elements/PageControls/index.tsx",
        lineNumber: 38,
        columnNumber: 5
    }, this);
};
/**
 * These page controls are controlled by the global ListQuery state.
 * To override thi behavior, build your own wrapper around PageControlsComponent.
 *
 * @internal
 */ export const PageControls = ({ AfterPageControls, collectionConfig })=>{
    const { data, defaultLimit: initialLimit, handlePageChange, handlePerPageChange, query } = useListQuery();
    return /*#__PURE__*/ _jsxDEV(PageControlsComponent, {
        AfterPageControls: AfterPageControls,
        collectionConfig: collectionConfig,
        data: data,
        handlePageChange: handlePageChange,
        handlePerPageChange: handlePerPageChange,
        limit: isNumber(query.limit) ? query.limit : initialLimit
    }, void 0, false, {
        fileName: "src/elements/PageControls/index.tsx",
        lineNumber: 91,
        columnNumber: 5
    }, this);
};

//# sourceMappingURL=index.js.map