"use client";
import { jsxs as d, jsx as o } from "react/jsx-runtime";
import { classNames as c } from "../../utils/index.js";
import { useState as b, useEffect as h } from "react";
import { FiChevronLeft as n, FiChevronRight as y } from "../../../../../node_modules/.pnpm/react-icons@5.5.0_react@19.0.0/node_modules/react-icons/fi/index.js";
const j = (t, s) => {
  const e = Math.min(Math.max(3, t), s - 2), a = Math.max(e - 2, 1), m = Math.max(e + 2, t);
  let i = [];
  for (let r = a; r <= m; ++r)
    r > 0 && i.push(r);
  return i;
}, A = ({
  current: t,
  totalPage: s,
  onPageChange: e,
  className: a,
  ...m
}) => {
  const [i, r] = b([]), [x, p] = b(!1), [f, u] = b(!0);
  return h(() => {
    r(j(t, s)), p(t > 1), u(t < s);
  }, [t]), /* @__PURE__ */ d(
    "div",
    {
      className: c("inline-flex items-center justify-between gap-2 text-sm", a),
      ...m,
      children: [
        /* @__PURE__ */ o(
          "button",
          {
            className: c(
              "reset flex h-8 items-center justify-center rounded-sm border border-slate-300 px-4 text-slate-800",
              x ? "hover:border-primary-500 hover:bg-primary-50 hover:text-primary-500" : "cursor-not-allowed text-slate-400 hover:bg-transparent"
            ),
            disabled: !x,
            onClick: () => {
              e == null || e(t - 1);
            },
            children: /* @__PURE__ */ o(n, {})
          }
        ),
        i.map((l, v) => l == t ? /* @__PURE__ */ d(
          "button",
          {
            disabled: !0,
            className: "reset active flex h-8 w-8 cursor-not-allowed items-center justify-center rounded-sm border text-slate-400 hover:bg-transparent",
            children: [
              l,
              " "
            ]
          },
          v
        ) : /* @__PURE__ */ d(
          "button",
          {
            onClick: () => {
              e == null || e(l);
            },
            className: "reset hover:border-primary-500 hover:bg-primary-50 hover:text-primary-500 flex h-8 w-8 items-center justify-center rounded-sm border text-slate-800",
            children: [
              l,
              " "
            ]
          },
          v
        )),
        /* @__PURE__ */ o(
          "button",
          {
            className: c(
              "reset flex h-8 items-center justify-center rounded-sm border border-slate-300 px-4 text-slate-800",
              f ? "hover:border-primary-500 hover:bg-primary-50 hover:text-primary-500" : "cursor-not-allowed text-slate-400 hover:bg-transparent"
            ),
            disabled: !f,
            onClick: () => {
              e == null || e(t + 1);
            },
            children: /* @__PURE__ */ o(y, {})
          }
        )
      ]
    }
  );
};
export {
  A as BlockPagination
};
//# sourceMappingURL=block-pagination.js.map
