import e from"../../_util/hooks/useState.mjs";import t from"../../_util/extendsObject.mjs";import{computed as n}from"vue";function r(e,t){let n={current:e.current,pageSize:e.pageSize};return Object.keys(t&&typeof t==`object`?t:{}).forEach(t=>{let r=e[t];typeof r!=`function`&&(n[t]=r)}),n}function i(r,i,a){let o=n(()=>i.value&&typeof i.value==`object`?i.value:{}),s=n(()=>o.value.total||0),[c,l]=e(()=>({current:`defaultCurrent`in o.value?o.value.defaultCurrent:1,pageSize:`defaultPageSize`in o.value?o.value.defaultPageSize:10})),u=n(()=>{let e=t(c.value,o.value,{total:s.value>0?s.value:r.value}),n=Math.ceil((s.value||r.value)/e.pageSize);return e.current>n&&(e.current=n||1),e}),d=(e,t)=>{i.value!==!1&&l({current:e??1,pageSize:t||u.value.pageSize})},f=(e,t)=>{i.value&&o.value.onChange?.(e,t),d(e,t),a(e,t||u.value.pageSize)};return[n(()=>i.value===!1?{}:{...u.value,onChange:f}),d]}export{i as default,r as getPaginationParam};