import N from"./DgZ9OEJo.js";import{c as B,r as R}from"./4Fu3KWqy.js";import{v as S,m as D,u as E,r as y,B as k,e as K,_ as T,R as V,o as i,c as s,L as w,b as x,q as l,E as _,J as j,K as L,t as b,a as O}from"./CChoqk00.js";const P=1,z=S({__name:"Pagination",props:{total:{type:Number,default:0},perPage:{type:Number,default:20},queryKey:{type:String,default:"page"},totalPages:{type:Number,default:0}},emits:["switchPagination","switchPage"],setup(u,{expose:a,emit:m}){a();const e=m,o=u,p=D(),c=E(),r=y(1),n=y(0),g=k(()=>o.totalPages>0?o.totalPages:Math.ceil(o.total/o.perPage)),C=k(()=>{if(!g.value)return[];const t=B(1,g.value),d=t(r.value-(1+P)),h=t(r.value+(1+P));return R(d,h)}),f=(t,d)=>({...c.query,[t]:d}),q=t=>{t!==r.value&&p.replace({query:f("page",t)})};K(()=>{const t=c.query[o.queryKey];t&&(r.value=Number(t),n.value=(Number(t)-1)*o.perPage,e("switchPagination",n.value),e("switchPage",r.value))});const v={emit:e,props:o,router:p,route:c,currentPage:r,resultStartBy:n,paginationPages:g,buttonCount:P,paginationRider:C,addPropToQuery:f,switchPage:q};return Object.defineProperty(v,"__isScriptSetup",{enumerable:!1,value:!0}),v}}),F={key:0,class:"pagination flex-center gap-2 flex-wrap py-4"},I={key:2,class:"h-8 w-8 rounded flex-center flex-shrink-0"},J=["onClick"],M={key:3,class:"h-8 w-8 rounded flex-center flex-shrink-0"};function Q(u,a,m,e,o,p){const c=N,r=V("tippy");return e.paginationPages?(i(),s("nav",F,[e.currentPage>1?w((i(),s("div",{key:0,class:"pagination__element h-8 w-8 rounded cursor-pointer flex-center flex-shrink-0",onClick:a[0]||(a[0]=n=>e.currentPage>1?e.switchPage(e.currentPage-1):null)},[x(c,{name:"material-symbols:chevron-left-rounded",class:"w-5 h-5"})])),[[r,{content:u.$t("back"),placement:"top",appendTo:"parent"}]]):l("",!0),e.currentPage>3?(i(),s("div",{key:1,class:_(["h-8 w-8 rounded flex-center flex-shrink-0",[e.currentPage===1?"pagination__active":"pagination__element cursor-pointer"]]),onClick:a[1]||(a[1]=n=>e.switchPage(1))}," 1 ",2)):l("",!0),e.currentPage>4?(i(),s("div",I," … ")):l("",!0),(i(!0),s(j,null,L(e.paginationRider,n=>(i(),s("div",{key:n,class:_(["h-8 w-8 rounded flex-center flex-shrink-0",[n===e.currentPage?"pagination__active":"pagination__element cursor-pointer"]]),onClick:g=>e.switchPage(n)},b(n),11,J))),128)),e.paginationPages-e.currentPage>2?(i(),s("div",M," … ")):l("",!0),O("div",{class:_(["h-8 w-8 rounded flex-center flex-shrink-0",[e.paginationPages===e.currentPage?"pagination__active":"pagination__element cursor-pointer"]]),onClick:a[2]||(a[2]=n=>e.switchPage(e.paginationPages))},b(e.paginationPages),3),e.currentPage<e.paginationPages?w((i(),s("div",{key:4,class:"pagination__element h-8 w-8 rounded cursor-pointer flex-center flex-shrink-0",onClick:a[3]||(a[3]=n=>e.currentPage<e.paginationPages?e.switchPage(e.currentPage+1):null)},[x(c,{name:"material-symbols:chevron-right-rounded",class:"w-5 h-5"})])),[[r,{content:u.$t("forward"),placement:"top",appendTo:"parent"}]]):l("",!0)])):l("",!0)}const U=Object.assign(T(z,[["render",Q],["__file","Pagination.vue"]]),{__name:"Pagination"});export{U as _};
