"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.paginate=paginate,exports.createPaginationMetadata=createPaginationMetadata;const DEFAULT_LIMIT=50,MAX_LIMIT=100;function paginate(a,t){const e=Math.max(1,t?.page??1),i=Math.min(Math.max(1,t?.limit??DEFAULT_LIMIT),MAX_LIMIT),n=a.length,M=Math.max(1,Math.ceil(n/i)),h=Math.min(e,M),o=(h-1)*i,s=Math.min(o+i,n);return{data:a.slice(o,s),pagination:{page:h,limit:i,total:n,totalPages:M,hasNext:h<M,hasPrev:h>1}}}function createPaginationMetadata(a,t){const e=Math.max(1,t?.page??1),i=Math.min(Math.max(1,t?.limit??DEFAULT_LIMIT),MAX_LIMIT),n=Math.max(1,Math.ceil(a/i)),M=Math.min(e,n);return{page:M,limit:i,total:a,totalPages:n,hasNext:M<n,hasPrev:M>1}}