<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<body>
<th:block th:fragment="pagination (url, totalPages, currentPage, filter, searchInfo)">
    <nav class="mt-3 mb-2 gx-0 table-responsive" th:if="${totalPages > 1}" th:with="
                                    maxPage=2,
                                    currentPage=${currentPage + 1}">
        <ul class="pagination justify-content-center" id="catalog-page-navigation"
            th:with="
                                            seqFrom=${currentPage - maxPage < 1 ? 1 : currentPage - maxPage},
                                            seqTo=${currentPage + maxPage > totalPages ? totalPages : currentPage + maxPage}">
            <th:block th:if="${currentPage > maxPage + 1}">
                <li class="page-item">
                    <a class="page-link" aria-label="Previous"
                        th:href="@{/{url}?page=0&filter={filter}&searchInfo={searchInfo}(url=${url}, filter=${filter}, searchInfo=${searchInfo})}">
                        <span aria-hidden="true">&laquo;</span>
                    </a>
                </li>
                <li class="page-item disabled">
                    <span class="page-link" aria-label="Previous">
                        <span aria-hidden="true">&hellip;</span>
                    </span>
                </li>
            </th:block>
            <li class="page-item" th:each="page : ${#numbers.sequence(seqFrom, seqTo)}"
                th:classappend="${page == currentPage} ? 'active' : ''">
                <a class="page-link"
                    th:href="@{/{url}?page={page}&filter={filter}&searchInfo={searchInfo}(url=${url}, page=${page - 1}, filter=${filter}, searchInfo=${searchInfo})}">
                    <span th:text="${page}" />
                </a>
            </li>
            <th:block th:if="${currentPage < totalPages - maxPage}">
                <li class="page-item disabled">
                    <span class="page-link" aria-label="Previous">
                        <span aria-hidden="true">&hellip;</span>
                    </span>
                </li>
                <li class="page-item">
                    <a class="page-link" aria-label="Next"
                        th:href="@{/{url}?page={page}&filter={filter}&searchInfo={searchInfo}(url=${url}, page=${totalPages - 1}, filter=${filter}, searchInfo=${searchInfo})}">
                        <span aria-hidden="true">&raquo;</span>
                    </a>
                </li>
            </th:block>
        </ul>
        </nav>
    </th:block>
</body>

</html>