import { jsxs, jsx } from 'react/jsx-runtime';
import { HStack, IconButton, Button } from '@chakra-ui/react';
import { ChevronLeftIcon, ChevronRightIcon } from '@chakra-ui/icons';
import { usePagination } from '../../hooks/usePagination.js';

const Pagination = ({
  currentPage,
  totalCount,
  pageSize = 10,
  siblingCount = 1,
  onPageChange
}) => {
  const { pages, totalPageCount } = usePagination({
    totalCount,
    pageSize,
    siblingCount,
    currentPage
  });
  return /* @__PURE__ */ jsxs(HStack, { spacing: 2, children: [
    /* @__PURE__ */ jsx(
      IconButton,
      {
        variant: "ghost",
        onClick: () => onPageChange(Math.max(1, currentPage - 1)),
        isDisabled: currentPage === 1,
        icon: /* @__PURE__ */ jsx(ChevronLeftIcon, {}),
        "aria-label": "Previous Page"
      }
    ),
    pages.map((page, idx) => /* @__PURE__ */ jsx(
      Button,
      {
        variant: currentPage === page ? "outline" : "ghost",
        isDisabled: page === null,
        onClick: () => page !== null && onPageChange(page),
        children: page != null ? page : "..."
      },
      page != null ? page : `${idx}-dots`
    )),
    /* @__PURE__ */ jsx(
      IconButton,
      {
        variant: "ghost",
        onClick: () => onPageChange(Math.min(currentPage + 1, totalPageCount)),
        isDisabled: currentPage === totalPageCount,
        icon: /* @__PURE__ */ jsx(ChevronRightIcon, {}),
        "aria-label": "Next Page"
      }
    )
  ] });
};

export { Pagination };
//# sourceMappingURL=Pagination.js.map
