import{o,c as i,e as c,t as b,f as d,b as m,F as P,h as C,n as N,j as q,k as p}from"../index.js";const B={key:0,class:"crm-pagination"},S={class:"crm-pagination__info"},$={class:"crm-pagination__pages"},x=["disabled"],E={key:0,class:"crm-pagination__ellipsis"},F=["disabled","onClick"],V=["disabled"],w={__name:"Pagination",props:{currentPage:{type:Number,required:!0},totalPages:{type:Number,required:!0},total:{type:Number,required:!0},perPage:{type:Number,required:!0}},emits:["change"],setup(n,{emit:h}){const a=n,u=h,_=p(()=>(a.currentPage-1)*a.perPage+1),f=p(()=>Math.min(a.currentPage*a.perPage,a.total)),y=p(()=>{const r=a.totalPages,s=a.currentPage,e=[];if(r<=7){for(let t=1;t<=r;t++)e.push(t);return e}const l=2,k=s-l,v=s+l;let g=null;for(let t=1;t<=r;t++)(t===1||t===r||t>=k&&t<=v)&&(g!==null&&t-g>1&&e.push("..."),e.push(t),g=t);return e});return(r,s)=>n.totalPages>0?(o(),i("div",B,[c("span",S,b(d(m)("Showing","pressio-crm")+" "+_.value+"–"+f.value+" "+d(m)("of","pressio-crm")+" "+n.total+" "+d(m)("results","pressio-crm")),1),c("div",$,[c("button",{class:"crm-pagination__btn",type:"button",disabled:n.currentPage<=1,onClick:s[0]||(s[0]=e=>u("change",n.currentPage-1))}," ‹ ",8,x),(o(!0),i(P,null,C(y.value,e=>(o(),i(P,{key:e},[e==="..."?(o(),i("span",E,"…")):(o(),i("button",{key:1,class:N(["crm-pagination__btn",e===n.currentPage?"crm-pagination__btn--active":""]),type:"button",disabled:e===n.currentPage,onClick:l=>u("change",e)},b(e),11,F))],64))),128)),c("button",{class:"crm-pagination__btn",type:"button",disabled:n.currentPage>=n.totalPages,onClick:s[1]||(s[1]=e=>u("change",n.currentPage+1))}," › ",8,V)])])):q("",!0)}};export{w as _};
