import { memo, useCallback, createElement, Fragment } from "react";
import { LayoutPageStickyContainer, Stack, Button } from "@contember/ui";
import { dataGridDictionary } from "../dataGridDictionary.js";
import { useMessageFormatter } from "../../../../../../i18n/useMessageFormatter.js";
const DataGridContainerFooter = memo(({
  desiredState,
  pagesCount,
  pagingSummary,
  updatePaging
}) => {
  const { paging: { pageIndex, itemsPerPage } } = desiredState;
  const formatMessage = useMessageFormatter(dataGridDictionary);
  const goToFirstPageClick = useCallback(() => {
    updatePaging({ type: "goToFirstPage" });
  }, [updatePaging]);
  const goToPreviousPageClick = useCallback(() => {
    updatePaging({ type: "goToPreviousPage" });
  }, [updatePaging]);
  const goToNextPageClick = useCallback(() => {
    updatePaging({ type: "goToNextPage" });
  }, [updatePaging]);
  const goToLastPageClick = useCallback(() => {
    pagesCount !== void 0 && updatePaging({ type: "goToPage", newPageIndex: pagesCount - 1 });
  }, [pagesCount, updatePaging]);
  return /* @__PURE__ */ createElement(LayoutPageStickyContainer, {
    left: "var(--cui-layout-page-padding-left)",
    right: "var(--cui-layout-page-padding-right)"
  }, /* @__PURE__ */ createElement(Stack, {
    wrap: true,
    align: "center",
    direction: "horizontal",
    justify: "space-between"
  }, /* @__PURE__ */ createElement(Stack, {
    direction: "horizontal",
    justify: "space-between",
    gap: "small"
  }, /* @__PURE__ */ createElement(Button, {
    distinction: "seamless",
    disabled: pageIndex === 0,
    onClick: goToFirstPageClick
  }, formatMessage("dataGrid.paging.first")), /* @__PURE__ */ createElement(Button, {
    disabled: pageIndex === 0,
    onClick: goToPreviousPageClick
  }, formatMessage("dataGrid.paging.previous")), itemsPerPage !== null && /* @__PURE__ */ createElement(Fragment, null, /* @__PURE__ */ createElement(Button, {
    disabled: pagesCount === void 0 || pagesCount <= pageIndex + 1,
    onClick: goToNextPageClick
  }, formatMessage("dataGrid.paging.next")), /* @__PURE__ */ createElement(Button, {
    distinction: "seamless",
    disabled: pagesCount === void 0 || pagesCount <= pageIndex + 1,
    onClick: goToLastPageClick
  }, formatMessage("dataGrid.paging.last")))), /* @__PURE__ */ createElement("div", null, pagingSummary)));
});
DataGridContainerFooter.displayName = "DataGridContainerFooter";
export { DataGridContainerFooter };
//# sourceMappingURL=DataGridContainerFooter.js.map
