import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _defineProperty from"@babel/runtime/helpers/defineProperty";var _excluded=["totalPages","currentPage"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import{IconArrowFirst}from"@consta/icons/IconArrowFirst";import{IconArrowLast}from"@consta/icons/IconArrowLast";import{IconArrowLeft}from"@consta/icons/IconArrowLeft";import{IconArrowRight}from"@consta/icons/IconArrowRight";export var defaultGetItemLabel=function(a){return a.label};export var defaultGetItemKey=function(a){return a.key};export var defaultGetItemClickable=function(a){return a.clickable};var defaultGetItemAs=function(a){return a.as},defaultGetItemAttributes=function(a){return a.attributes},defaultGetItemRef=function(a){return a.ref},defaultGetItemOnClick=function(a){return a.onClick};export var withDefaultGetters=function(a){var b,c,d,e,f,g,h;return _objectSpread(_objectSpread({},a),{},{getItemLabel:null!==(b=a.getItemLabel)&&void 0!==b?b:defaultGetItemLabel,getItemKey:null!==(c=a.getItemKey)&&void 0!==c?c:defaultGetItemKey,getItemClickable:null!==(d=a.getItemClickable)&&void 0!==d?d:defaultGetItemClickable,getItemOnClick:null!==(e=a.getItemOnClick)&&void 0!==e?e:defaultGetItemOnClick,getItemAs:null!==(f=a.getItemAs)&&void 0!==f?f:defaultGetItemAs,getItemAttributes:null!==(g=a.getItemAttributes)&&void 0!==g?g:defaultGetItemAttributes,getItemRef:null!==(h=a.getItemRef)&&void 0!==h?h:defaultGetItemRef})};var getMinVisibleCount=function(a,b){return a||b?5:a&&b?7:3},range=function(a,b){return Array.from({length:Math.abs(b-a+1)}).map(function(b,c){return Math.floor(a+c)})},generateArr=function(a){var b=a.count,c=a.page,d=a.showFirstPage,e=void 0!==d&&d,f=a.showLastPage,g=void 0!==f&&f,h=a.visibleCount,i=h,j=getMinVisibleCount(e,g);i=j>=b?b:Math.min(b,Math.max(h,j));var k=e?2:0,l=g?2:0,m=[],n=Math.floor((i-l-k)/2)||0,o=Math.floor((i-l-k-1)/2)||0,p=1,q=b;return i-l>=c+o?q=i-(g?2:0):c-n>b-i+k?p=b-i+(e?3:1):(p=c-n,q=c+o),e&&1!==p&&m.push(1,"..."),m.push.apply(m,_toConsumableArray(range(Math.floor(p),Math.floor(q)))),g&&q!==b&&m.push("...",b),m};export var getPagesArray=function(a){var b=a.totalPages,c=a.currentPage,d=_objectWithoutProperties(a,_excluded),e=Math.max(b,1),f=Math.min(e,Math.max(1,c));return generateArr(_objectSpread({page:f,count:e},d)).map(function(a,c){return{key:"string"==typeof a?b+c:a,label:a.toString(),page:"string"==typeof a?c:a,active:!("number"!=typeof a)&&a===f,clickable:"number"!=typeof a}})};export var paginationArrowIconsMap={first:IconArrowFirst,previous:IconArrowLeft,next:IconArrowRight,last:IconArrowLast};export var getListValue=function(a){return{key:a,page:a,label:a.toString()}};
//# sourceMappingURL=helpers.js.map