import { useState as p } from "react";
import j from "../../_util/extendsObject.mjs";
var y = globalThis && globalThis.__rest || function(e, r) {
  var t = {};
  for (var n in e)
    Object.prototype.hasOwnProperty.call(e, n) && r.indexOf(n) < 0 && (t[n] = e[n]);
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
    for (var o = 0, n = Object.getOwnPropertySymbols(e); o < n.length; o++)
      r.indexOf(n[o]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[o]) && (t[n[o]] = e[n[o]]);
  return t;
};
const d = 10;
function S(e, r) {
  const t = {
    current: e.current,
    pageSize: e.pageSize
  };
  return Object.keys(r && typeof r == "object" ? r : {}).forEach((o) => {
    const a = e[o];
    typeof a != "function" && (t[o] = a);
  }), t;
}
function h(e, r, t) {
  const n = t && typeof t == "object" ? t : {}, {
    total: o = 0
  } = n, a = y(n, ["total"]), [b, g] = p(() => ({
    current: "defaultCurrent" in a ? a.defaultCurrent : 1,
    pageSize: "defaultPageSize" in a ? a.defaultPageSize : d
  })), l = j(b, a, {
    total: o > 0 ? o : e
  }), u = Math.ceil((o || e) / l.pageSize);
  l.current > u && (l.current = u || 1);
  const s = (c, i) => {
    g({
      current: c ?? 1,
      pageSize: i || l.pageSize
    });
  }, O = (c, i) => {
    var f;
    t && ((f = t.onChange) === null || f === void 0 || f.call(t, c, i)), s(c, i), r(c, i || (l == null ? void 0 : l.pageSize));
  };
  return t === !1 ? [{}, () => {
  }] : [Object.assign(Object.assign({}, l), {
    onChange: O
  }), s];
}
export {
  d as DEFAULT_PAGE_SIZE,
  h as default,
  S as getPaginationParam
};
