import { jsxs as u, jsx as e } from "react/jsx-runtime";
import { b as y } from "./NiceTabs-DzLHzwuA.js";
function M(i, a, l) {
  const r = [];
  if (a <= 1)
    return a === 1 && r.push(1), r;
  const s = Math.max(2, i - l), o = Math.min(a - 1, i + l);
  r.push(1), s > 2 && r.push("dots");
  for (let c = s; c <= o; c++)
    r.push(c);
  return o < a - 1 && r.push("dots"), r.push(a), r;
}
const L = ({
  page: i,
  totalPages: a,
  onChange: l,
  showInfo: r,
  siblingCount: s = 1,
  size: o = "md",
  showFirstLast: c,
  showJumpInput: m,
  jumpInputLabel: h,
  showPageSize: b,
  pageSizeOptions: d,
  pageSize: f,
  onPageSizeChange: N,
  disabled: t,
  className: _,
  style: v
}) => {
  const g = M(i, a, s);
  return /* @__PURE__ */ u(
    "nav",
    {
      className: `nice-pagination nice-pagination--${o} ${_ || ""}`,
      style: v,
      "aria-label": "Pagination",
      children: [
        c && /* @__PURE__ */ e(
          "button",
          {
            className: "nice-pagination__btn",
            disabled: t || i <= 1,
            onClick: () => l(1),
            "aria-label": "First page",
            title: "First page",
            children: "⏮"
          }
        ),
        /* @__PURE__ */ e(
          "button",
          {
            className: "nice-pagination__btn",
            disabled: t || i <= 1,
            onClick: () => l(i - 1),
            "aria-label": "Previous",
            children: /* @__PURE__ */ e("svg", { width: "14", height: "14", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ e(
              "path",
              {
                fillRule: "evenodd",
                d: "M12.79 5.23a.75.75 0 01-.02 1.06L8.832 10l3.938 3.71a.75.75 0 11-1.04 1.08l-4.5-4.25a.75.75 0 010-1.08l4.5-4.25a.75.75 0 011.06.02z",
                clipRule: "evenodd"
              }
            ) })
          }
        ),
        g.map(
          (n, p) => n === "dots" ? /* @__PURE__ */ e("span", { className: "nice-pagination__ellipsis", children: "…" }, `dots-${p}`) : /* @__PURE__ */ e(
            "button",
            {
              className: `nice-pagination__btn ${n === i ? "nice-pagination__btn--active" : ""}`,
              disabled: t,
              onClick: () => l(n),
              "aria-current": n === i ? "page" : void 0,
              children: n
            },
            n
          )
        ),
        /* @__PURE__ */ e(
          "button",
          {
            className: "nice-pagination__btn",
            disabled: t || i >= a,
            onClick: () => l(i + 1),
            "aria-label": "Next",
            children: /* @__PURE__ */ e("svg", { width: "14", height: "14", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ e(
              "path",
              {
                fillRule: "evenodd",
                d: "M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z",
                clipRule: "evenodd"
              }
            ) })
          }
        ),
        c && /* @__PURE__ */ e(
          "button",
          {
            className: "nice-pagination__btn",
            disabled: t || i >= a,
            onClick: () => l(a),
            "aria-label": "Last page",
            title: "Last page",
            children: "⏭"
          }
        ),
        r && /* @__PURE__ */ u("span", { className: "nice-pagination__info", children: [
          i,
          " / ",
          a
        ] }),
        m && /* @__PURE__ */ u(
          "span",
          {
            className: "nice-pagination__jump",
            style: { display: "inline-flex", alignItems: "center", gap: 6, marginLeft: 8 },
            children: [
              /* @__PURE__ */ e("span", { style: { fontSize: "0.85rem", color: "var(--text-secondary)" }, children: h ?? "Go to" }),
              /* @__PURE__ */ e(
                y,
                {
                  size: o === "lg" ? "md" : "sm",
                  min: 1,
                  max: a,
                  step: 1,
                  value: i,
                  disabled: t,
                  onChange: (n) => {
                    const p = typeof n == "number" ? n : Number(n);
                    if (!Number.isNaN(p)) {
                      const x = Math.max(1, Math.min(a, Math.floor(p)));
                      l(x);
                    }
                  }
                }
              )
            ]
          }
        ),
        b && d && d.length > 0 && /* @__PURE__ */ e(
          "select",
          {
            className: "nice-pagination__size",
            value: f ?? d[0],
            disabled: t,
            onChange: (n) => N?.(Number(n.target.value)),
            style: {
              marginLeft: 8,
              padding: "4px 8px",
              border: "1px solid var(--border-color)",
              borderRadius: 6,
              background: "var(--bg-primary)",
              color: "var(--text-primary)",
              font: "inherit",
              fontSize: "0.85rem"
            },
            "aria-label": "Rows per page",
            children: d.map((n) => /* @__PURE__ */ u("option", { value: n, children: [
              n,
              " / page"
            ] }, n))
          }
        )
      ]
    }
  );
};
export {
  L as N
};
