'use client';
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),React=require("react");const Pagination=({className:e,setting:t={},style:r})=>{let{defaultCurrent:p=1,total:i=0,pageSize:l=10,align:g,disabled:s=!1}=t,[o,c]=React.useState([]),[d,n]=React.useState(p),a=Math.ceil(i/l);React.useEffect(()=>{n(p)},[p]);let f=e=>{s||n(e)},u=()=>{!s&&d<a&&n(d+1)},x=()=>{!s&&d>1&&n(d-1)},h=()=>{s||(d<a-5?n(d+5):n(a))},m=()=>{s||(d-5>1?n(d-5):n(1))};return React.useEffect(()=>{let e=[];if(i)for(let t=1;t<a;t++)if(d<=4){if(t<=4)e.push(t);else{3===e.indexOf(d)&&e.push(t),e.push("shortcutNext",a);break}}else if(d>=a-3){if(t<=4)e.unshift(a-t);else{e.unshift(1,"shortcutPrev"),e.push(a);break}}else{e.push(t,"shortcutPrev",d-1,d,d+1,"shortcutNext",a);break}c([...e])},[d,a,i,l]),jsxRuntime.jsx("div",{className:core.cls("gp-w-full",{"gp-text-right":g?.desktop==="right","tablet:gp-text-right":g?.tablet==="right","mobile:gp-text-right":g?.mobile==="right","gp-text-left":g?.desktop==="left","tablet:gp-text-left":g?.tablet==="left","mobile:gp-text-left":g?.mobile==="left","gp-text-center":g?.desktop==="center","tablet:gp-text-center":g?.tablet==="center","mobile:gp-text-center":g?.mobile==="center"}),children:jsxRuntime.jsxs("div",{className:core.cls("inline-flex",e),style:r,children:[jsxRuntime.jsx("div",{className:core.cls("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!==d&&!s,"gp-cursor-not-allowed gp-fill-[#00000040] hover:gp-border-[#d9d9d9] hover:gp-fill-[#00000040]":1===d,"gp-cursor-not-allowed gp-bg-[#f5f5f5] gp-fill-[#cfcfcf] hover:gp-border-[#d9d9d9] hover:gp-fill-[#cfcfcf]":s}),onClick:x,"aria-hidden":"true","data-testid":"prev",children:jsxRuntime.jsx("svg",{className:"gp-h-3 gp-w-3",viewBox:"64 64 896 896","aria-hidden":"true",children:jsxRuntime.jsx("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"})})}),o.map((e,t)=>{if(e)return"shortcutNext"===e?jsxRuntime.jsx("div",{className:core.cls("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":!s,"gp-cursor-not-allowed gp-text-[#00000040]":s}),onClick:h,"aria-hidden":"true",children:"..."},t):"shortcutPrev"===e?jsxRuntime.jsx("div",{className:core.cls("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":!s,"gp-cursor-not-allowed gp-text-[#00000040]":s}),onClick:m,"aria-hidden":"true",children:"..."},t):jsxRuntime.jsx("div",{className:core.cls("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":!s,"gp-border-[#1890ff] gp-text-[#1890ff]":d===e&&!s,"gp-cursor-not-allowed gp-bg-[#f5f5f5] gp-text-[#cfcfcf] hover:gp-border-[#d9d9d9] hover:gp-text-[#cfcfcf]":s}),onClick:()=>f(e),"aria-hidden":"true",children:e},t)}),jsxRuntime.jsx("div",{className:core.cls("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":d!==a&&!s,"gp-cursor-not-allowed gp-fill-[#00000040] hover:gp-border-[#d9d9d9] hover:gp-fill-[#00000040]":d===a,"gp-cursor-not-allowed gp-bg-[#f5f5f5] gp-fill-[#cfcfcf] hover:gp-border-[#d9d9d9] hover:gp-fill-[#cfcfcf]":s}),onClick:u,"aria-hidden":"true","data-testid":"next",children:jsxRuntime.jsx("svg",{className:"gp-h-3 gp-w-3",viewBox:"64 64 896 896","aria-hidden":"true",children:jsxRuntime.jsx("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"})})})]})})};exports.default=Pagination;
