"use strict";

exports.__esModule = true;
exports["default"] = void 0;
var _react = _interopRequireWildcard(require("react"));
var _flex = _interopRequireDefault(require("../../templates/flex"));
var _typography = require("../../typography");
var _button = require("../../button");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
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["default"].createElement(_flex["default"], {
    alignItems: "center",
    justifyContent: "end",
    height: "45px",
    background: "mainBackground",
    border: {
      side: "top",
      color: "borderSecondary"
    }
  }, /*#__PURE__*/_react["default"].createElement(_button.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["default"].createElement(_button.IconButton, {
    title: "Previous",
    "data-testid": "pagination-go-to-previous",
    cursor: "pointer",
    onClick: previousPage,
    icon: "chevron_left",
    iconSize: "small",
    tooltip: "Previous",
    disabled: !getCanPreviousPage()
  }), /*#__PURE__*/_react["default"].createElement(_typography.Text, {
    "data-testid": "pagination-counter"
  }, "Page ", getPageCount() === 0 ? 0 : pageIndex, " of ", getPageCount()), /*#__PURE__*/_react["default"].createElement(_button.IconButton, {
    title: "Next",
    "data-testid": "pagination-go-to-next",
    cursor: "pointer",
    onClick: nextPage,
    icon: "chevron_right",
    iconSize: "small",
    disabled: !getCanNextPage()
  }), /*#__PURE__*/_react["default"].createElement(_button.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()
  }));
};
var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(Pagination);