import { jsx, jsxs, Fragment } from "react/jsx-runtime";
import { LayoutPageStickyContainer, Stack, Button } from "@contember/ui";
import { memo, useCallback } from "react";
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 pagesCount !== void 0 && pagesCount > 1 ? /* @__PURE__ */ jsx(
    LayoutPageStickyContainer,
    {
      left: "var(--cui-layout-page-padding-left)",
      right: "var(--cui-layout-page-padding-right)",
      children: /* @__PURE__ */ jsxs(Stack, { wrap: true, align: "center", direction: "horizontal", justify: "space-between", children: [
        /* @__PURE__ */ jsxs(Stack, { direction: "horizontal", justify: "space-between", gap: "small", children: [
          /* @__PURE__ */ jsx(
            Button,
            {
              distinction: "seamless",
              disabled: pageIndex === 0,
              onClick: goToFirstPageClick,
              children: formatMessage("dataGrid.paging.first")
            }
          ),
          /* @__PURE__ */ jsx(
            Button,
            {
              disabled: pageIndex === 0,
              onClick: goToPreviousPageClick,
              children: formatMessage("dataGrid.paging.previous")
            }
          ),
          itemsPerPage !== null && /* @__PURE__ */ jsxs(Fragment, { children: [
            /* @__PURE__ */ jsx(
              Button,
              {
                disabled: pagesCount === void 0 || pagesCount <= pageIndex + 1,
                onClick: goToNextPageClick,
                children: formatMessage("dataGrid.paging.next")
              }
            ),
            /* @__PURE__ */ jsx(
              Button,
              {
                distinction: "seamless",
                disabled: pagesCount === void 0 || pagesCount <= pageIndex + 1,
                onClick: goToLastPageClick,
                children: formatMessage("dataGrid.paging.last")
              }
            )
          ] })
        ] }),
        /* @__PURE__ */ jsx("div", { children: pagingSummary })
      ] })
    }
  ) : null;
});
DataGridContainerFooter.displayName = "DataGridContainerFooter";
export {
  DataGridContainerFooter
};
//# sourceMappingURL=DataGridContainerFooter.js.map
