import React, { memo } from "react";
import Flex from "../../templates/flex";
import { Text } from "../../typography";
import { IconButton } from "../../button";
var Pagination = function Pagination(_ref) {
  var table = _ref.table;
  var nextPage = table.nextPage,
    previousPage = table.previousPage,
    getCanPreviousPage = table.getCanPreviousPage,
    getCanNextPage = table.getCanNextPage,
    getPageCount = table.getPageCount,
    setPageIndex = table.setPageIndex,
    resetPageIndex = table.resetPageIndex;
  var pageIndex = table.getState().pagination.pageIndex;
  return /*#__PURE__*/React.createElement(Flex, {
    alignItems: "center",
    justifyContent: "end",
    height: "45px",
    background: "panelBg",
    border: {
      side: "top",
      color: "borderSecondary"
    }
  }, /*#__PURE__*/React.createElement(IconButton, {
    title: "First",
    "data-testid": "pagination-go-to-first",
    cursor: "pointer",
    onClick: resetPageIndex,
    icon: "chevron_left_start",
    iconSize: "small",
    tooltip: "test",
    disabled: !getCanPreviousPage()
  }), /*#__PURE__*/React.createElement(IconButton, {
    title: "Previous",
    "data-testid": "pagination-go-to-previous",
    cursor: "pointer",
    onClick: previousPage,
    icon: "chevron_left",
    iconSize: "small",
    tooltip: "Previous",
    disabled: !getCanPreviousPage()
  }), /*#__PURE__*/React.createElement(Text, {
    "data-testid": "pagination-counter"
  }, "Page ", getPageCount() === 0 ? 0 : pageIndex, " of ", getPageCount()), /*#__PURE__*/React.createElement(IconButton, {
    title: "Next",
    "data-testid": "pagination-go-to-next",
    cursor: "pointer",
    onClick: nextPage,
    icon: "chevron_right",
    iconSize: "small",
    disabled: !getCanNextPage()
  }), /*#__PURE__*/React.createElement(IconButton, {
    title: "Last",
    "data-testid": "pagination-go-to-last",
    cursor: "pointer",
    onClick: function onClick() {
      return setPageIndex(getPageCount() - 1);
    },
    icon: "chevron_right_end",
    iconSize: "small",
    disabled: !getCanNextPage()
  }));
};
export default /*#__PURE__*/memo(Pagination);