"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "usePaginationDots", {
    enumerable: true,
    get: function() {
        return usePaginationDots;
    }
});
const _react = require("react");
const usePaginationDots = ({ items, index, visibleItems = 7 })=>{
    const activeId = items[index].id;
    const prevIndex = (0, _react.useRef)(null);
    let direction = 0;
    if (prevIndex.current !== null) {
        direction = index > prevIndex.current ? 1 : -1;
    }
    let start;
    let end;
    if (direction === 1) {
        end = Math.min(Math.max(index + 2, visibleItems), items.length);
        start = Math.max(end - visibleItems, 0);
    } else if (direction === -1) {
        start = Math.min(Math.max(index - 1, 0), items.length - visibleItems);
        end = start + visibleItems;
    } else {
        start = Math.max(index - Math.floor(visibleItems / 2), 0);
        end = Math.min(start + visibleItems, items.length);
        start = end - visibleItems;
    }
    const sliced = items.slice(start, end);
    prevIndex.current = index;
    return {
        sliced,
        activeId
    };
};
