import { jsxs as B, Fragment as D, jsx as o } from "react/jsx-runtime";
import { classNames as b } from "./index-classNames.js";
import { IconNames as x } from "./index-IconNames.js";
import { CtaWithIcon as h } from "./index-CtaWithIcon.js";
import { TableProvider as F } from "./index-Table.js";
import { Text as u, FontWeights as g } from "./index-Text.js";
import { useState as n, useContext as j, useEffect as T } from "react";
import s from "./index-FooterPagination.module.scss.js";
const G = (P) => {
  const {
    isHidden: p = !1
  } = P, [y, c] = n(!1), [i, v] = n(!1), [a, N] = n(!1), k = j(F), {
    data: r,
    onNextPage: m,
    onPrevPage: d,
    pagination: e
  } = k;
  r == null || r.columns;
  const C = (e == null ? void 0 : e.minPage) ?? 1, I = (e == null ? void 0 : e.maxPage) ?? void 0, l = (e == null ? void 0 : e.limit) ?? 1, t = (e == null ? void 0 : e.offset) ?? 0, S = (e == null ? void 0 : e.total) ?? 1, f = (t + l) / l;
  return p ? null : (T(() => {
    t + l >= S ? c(!0) : c(!1), v(parseInt(String(f)) == parseInt(String(I))), N(parseInt(String(f)) == parseInt(String(C)));
  }, [e]), B(D, {
    children: [o(h, {
      disabled: a,
      onClick: (W) => {
        d && d(t);
      },
      className: b(s.spacer, s.linkColor, s.disabled),
      icon: x.caretRight,
      position: "left",
      children: o(u, {
        fontWeight: g.medium,
        color: a ? "var(--n300)" : "var(--brand-color)",
        children: "Back"
      })
    }), o(h, {
      disabled: i,
      onClick: (W) => {
        m && m(t);
      },
      className: b(s.linkColor),
      icon: x.caretLeft,
      position: "right",
      children: o(u, {
        fontWeight: g.medium,
        color: i ? "var(--n300)" : "var(--brand-color)",
        children: "Next"
      })
    })]
  }));
};
export {
  G as FooterPagination
};
