import React__default, { useContext } from 'react';
import Pagination from './pagination.js';
import DataTableContext from './context.js';
import 'prop-types';
import './pagination/page-count.js';
import './pagination/per-page-select.js';
import '../select-menu/index.js';
import '../extends-C4cduGrv.js';
import '../objectWithoutProperties-TXwlfNxG.js';
import '../select-menu-BvA3x4Nf.js';
import '../slicedToArray-BB-AwwkK.js';
import '../defineProperty-CEd-kZQW.js';
import '../floating-ui.react-cWPyyUrN.js';
import '../typeof-CgC7Bq6K.js';
import '../toConsumableArray-dKQYsfpV.js';
import '../index-qSfOyGhk.js';
import 'react-dom';
import 'classnames';
import '../_commonjsHelpers-_1FafXWI.js';
import '../label/index.js';
import '@reach/visually-hidden';
import '../ck-icon/index.js';
import '../ck-icon/assets/icon-map/index.js';
import '../icon/index.js';
import '@fortawesome/react-fontawesome';
import '../icon/icons.js';
import '../icon/library.js';
import '@fortawesome/fontawesome-svg-core';
import '@fortawesome/pro-solid-svg-icons';
import '@fortawesome/pro-light-svg-icons';
import '@fortawesome/free-brands-svg-icons';
import '../portal/index.js';
import '../use-rerender-once/index.js';
import '../use-force-update/index.js';
import '../select-menu/autocomplete.js';
import './pagination/navigation.js';
import '../button/index.js';
import '../button/button-group.js';

/**
 * Allows using client-side pagination with DataTable.
 * Assumes all data is fetched on page load so paging is done within the table component.
 *
 * @see https://tanstack.com/table/latest/docs/guide/pagination#client-side-pagination
 *
 * @deprecated Client-side paging doesn't really make sense for us, so we shouldn't use
 * this. The only reason this exists is to support the legacy behavior of the DataTable.
 */

function ClientSidePagination() {
  var _useContext = useContext(DataTableContext),
      table = _useContext.table,
      data = _useContext.data;

  var _table$getState$pagin = table.getState().pagination,
      pageIndex = _table$getState$pagin.pageIndex,
      perPage = _table$getState$pagin.pageSize;
  var firstResultIndex = pageIndex * perPage + 1;
  var lastResultIndex = perPage * (pageIndex + 1) > data.length ? data.length : perPage * (pageIndex + 1);
  return /*#__PURE__*/React__default.createElement(Pagination, null, /*#__PURE__*/React__default.createElement(Pagination.PageCount, null, firstResultIndex, " - ", lastResultIndex, " of ", data.length), /*#__PURE__*/React__default.createElement(Pagination.PerPageSelect, {
    value: perPage,
    onSelect: function onSelect(perPage) {
      return table.setPageSize(perPage);
    }
  }), /*#__PURE__*/React__default.createElement(Pagination.Navigation, {
    hasNextPage: table.getCanNextPage(),
    hasPreviousPage: table.getCanPreviousPage(),
    onNextPage: function onNextPage() {
      return table.nextPage();
    },
    onPreviousPage: function onPreviousPage() {
      return table.previousPage();
    }
  }));
}

export { ClientSidePagination as default };
