<?php $previous = $block->getData('previous'); ?>
<?php $next = $block->getData('next'); ?>
<?php $current = $block->getData('current'); ?>
<?php $size = $block->getData('size'); ?>
<?php $pages = $block->getData('pages'); ?>
<?php
/** @var \Wyomind\ElasticsearchLayeredNavigation\Helper\Frontend $frontendHelper */
$frontendHelper = $this->helper('\Wyomind\ElasticsearchLayeredNavigation\Helper\Frontend');
?>


<div id="product-paging-bottom" class="eln-product-paging product-paging">
    <?php if ($pages && count($pages) > 1): ?>
        <div class="pages">
            <ul class="items pages-items" aria-labelledby="paging-label">
                <?php if ($previous) : ?>
                    <li class="item pages-item-next">
                        <a class="action previous page"
                           rel="prev"
                           href="<?= $block->escapeUrl($frontendHelper->createFilterUrl(true,"page", ($current - 1))); ?>" title="<?= $block->escapeHtml(__('Previous')) ?>"
                           id='page_<?= (int)(($current - 2) * $size) ?>_<?= $size ?>'>
                            <span id='page_<?= (int)(($current - 2) * $size) ?>_<?= (int)$size ?>'><?= $block->escapeHtml(__('Previous')) ?></span>
                        </a>
                    </li>
                <?php endif; ?>
                <?php foreach ($pages as $page) : ?>
                    <?php if ($page == $current) : ?>
                        <li class="item current">
                            <strong class="page">
                                <span><?= (int)$page ?></span>
                            </strong>
                        </li>
                    <?php else: ?>
                        <li class="item">
                            <a href="<?= $block->escapeUrl($frontendHelper->createFilterUrl(true,"page", $page)); ?>" class="page"
                               id='page_<?= (int)(($page - 1) * $size) ?>_<?= (int)$size ?>'>
                                <span id='page_<?= (int)(($page - 1) * $size) ?>_<?= (int)$size ?>'><?= (int)$page ?></span>
                            </a>
                        </li>
                    <?php endif; ?>
                <?php endforeach; ?>
                <?php if ($next) : ?>
                    <li class="item pages-item-next">
                        <a class="action  next page"
                           rel="next"
                           href="<?= $frontendHelper->createFilterUrl(true,"page", ($current + 1)); ?>" title="<?= $block->escapeHtml(__('Next')) ?>"
                           id='page_<?= (int)($current * $size) ?>_<?= (int)$size ?>'>
                            <span id='page_<?= (int)($current * $size) ?>_<?= (int)$size ?>'><?= $block->escapeHtml(__('Next')) ?></span>
                        </a>
                    </li>
                <?php endif; ?>
            </ul>
        </div>
    <?php endif; ?>
</div>

