'use client';
import{jsx as e,jsxs as r}from"react/jsx-runtime";import{cls as t}from"@gem-sdk/core";import{useState as p,useEffect as g}from"react";let l=({className:l,setting:o={},style:i})=>{let{defaultCurrent:d=1,total:c=0,pageSize:f=10,align:a,disabled:n=!1}=o,[s,h]=p([]),[u,x]=p(d),b=Math.ceil(c/f);g(()=>{x(d)},[d]);let m=e=>{n||x(e)},v=()=>{n||(u<b-5?x(u+5):x(b))},w=()=>{n||(u-5>1?x(u-5):x(1))};return g(()=>{let e=[];if(c)for(let r=1;r<b;r++)if(u<=4){if(r<=4)e.push(r);else{3===e.indexOf(u)&&e.push(r),e.push("shortcutNext",b);break}}else if(u>=b-3){if(r<=4)e.unshift(b-r);else{e.unshift(1,"shortcutPrev"),e.push(b);break}}else{e.push(r,"shortcutPrev",u-1,u,u+1,"shortcutNext",b);break}h([...e])},[u,b,c,f]),e("div",{className:t("gp-w-full",{"gp-text-right":a?.desktop==="right","tablet:gp-text-right":a?.tablet==="right","mobile:gp-text-right":a?.mobile==="right","gp-text-left":a?.desktop==="left","tablet:gp-text-left":a?.tablet==="left","mobile:gp-text-left":a?.mobile==="left","gp-text-center":a?.desktop==="center","tablet:gp-text-center":a?.tablet==="center","mobile:gp-text-center":a?.mobile==="center"}),children:r("div",{className:t("inline-flex",l),style:i,children:[e("div",{className:t("gp-mr-[4px] gp-flex gp-h-8 gp-w-8 gp-select-none gp-items-center gp-justify-center gp-rounded-[2px] gp-border gp-border-solid gp-border-[#d9d9d9] gp-transition-all hover:gp-border-[#40a9ff] hover:gp-fill-[#40a9ff]",{"gp-cursor-pointer":1!==u&&!n,"gp-cursor-not-allowed gp-fill-[#00000040] hover:gp-border-[#d9d9d9] hover:gp-fill-[#00000040]":1===u,"gp-cursor-not-allowed gp-bg-[#f5f5f5] gp-fill-[#cfcfcf] hover:gp-border-[#d9d9d9] hover:gp-fill-[#cfcfcf]":n}),onClick:()=>{!n&&u>1&&x(u-1)},"aria-hidden":"true","data-testid":"prev",children:e("svg",{className:"gp-h-3 gp-w-3",viewBox:"64 64 896 896","aria-hidden":"true",children:e("path",{d:"M724 218.3V141c0-6.7-7.7-10.4-12.9-6.3L260.3 486.8a31.86 31.86 0 000 50.3l450.8 352.1c5.3 4.1 12.9.4 12.9-6.3v-77.3c0-4.9-2.3-9.6-6.1-12.6l-360-281 360-281.1c3.8-3 6.1-7.7 6.1-12.6z"})})}),s.map((r,p)=>{if(r)return"shortcutNext"===r?e("div",{className:t("gp-mx-[4px] gp-flex gp-h-8 gp-w-8 gp-items-center gp-justify-center gp-tracking-[2px] gp-transition-all",{"gp-cursor-pointer":!n,"gp-cursor-not-allowed gp-text-[#00000040]":n}),onClick:v,"aria-hidden":"true",children:"..."},p):"shortcutPrev"===r?e("div",{className:t("gp-mx-[4px] gp-flex gp-h-8 gp-w-8 gp-items-center gp-justify-center gp-tracking-[2px] gp-transition-all",{"gp-cursor-pointer":!n,"gp-cursor-not-allowed gp-text-[#00000040]":n}),onClick:w,"aria-hidden":"true",children:"..."},p):e("div",{className:t("gp-mx-[4px] gp-flex gp-h-8 gp-w-8 gp-select-none gp-items-center gp-justify-center gp-rounded-[2px] gp-border gp-border-solid gp-border-[#d9d9d9] gp-transition-all hover:gp-border-[#40a9ff] hover:gp-text-[#40a9ff]",{"gp-cursor-pointer":!n,"gp-border-[#1890ff] gp-text-[#1890ff]":u===r&&!n,"gp-cursor-not-allowed gp-bg-[#f5f5f5] gp-text-[#cfcfcf] hover:gp-border-[#d9d9d9] hover:gp-text-[#cfcfcf]":n}),onClick:()=>m(r),"aria-hidden":"true",children:r},p)}),e("div",{className:t("gp-ml-[4px] gp-flex gp-h-8 gp-w-8 gp-select-none gp-items-center gp-justify-center gp-rounded-[2px] gp-border gp-border-solid gp-border-[#d9d9d9] gp-transition-all hover:gp-border-[#40a9ff] hover:gp-fill-[#40a9ff]",{"gp-cursor-pointer":u!==b&&!n,"gp-cursor-not-allowed gp-fill-[#00000040] hover:gp-border-[#d9d9d9] hover:gp-fill-[#00000040]":u===b,"gp-cursor-not-allowed gp-bg-[#f5f5f5] gp-fill-[#cfcfcf] hover:gp-border-[#d9d9d9] hover:gp-fill-[#cfcfcf]":n}),onClick:()=>{!n&&u<b&&x(u+1)},"aria-hidden":"true","data-testid":"next",children:e("svg",{className:"gp-h-3 gp-w-3",viewBox:"64 64 896 896","aria-hidden":"true",children:e("path",{d:"M765.7 486.8L314.9 134.7A7.97 7.97 0 00302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 000-50.4z"})})})]})})};export{l as default};
