<?php
/**
 * @author      Olegnax
 * @package     Olegnax_LayeredNavigation
 * @copyright   Copyright (c) 2019 Olegnax (http://olegnax.com/). All rights reserved.
 * @license     Proprietary License https://olegnax.com/license/
 */

use Magento\LayeredNavigation\Block\Navigation\State;

// @codingStandardsIgnoreFile
?>
<?php
/**
 * Category layered navigation state
 *
 * @var $block State
 */
?>
<?php $_filters = $block->getActiveFilters() ?>
<?php if (!empty($_filters)): ?>
	<div class="filter-current">
		<strong class="block-subtitle filter-current-subtitle"
				role="heading"
				aria-level="2"
				data-count="<?= count($_filters) ?>"><?= /* @escapeNotVerified */
            __('Now Shopping by') ?></strong>
		<ol class="items">
            <?php
            foreach ($_filters as $_filter):
                $requestVar = $_filter->getFilter()->getRequestVar();
                $filterItemVal = (is_array($_filter->getValue())) ? implode('-',
                    $_filter->getValue()) : $_filter->getValue();
                ?>
				<li class="item">
					<span class="filter-label"><?= $block->escapeHtml(__($_filter->getName())) ?></span>
					<span class="filter-value"><?= /* @escapeNotVerified */
                        $block->stripTags($_filter->getLabel()) ?></span>
                    <?php
                    $clearLinkUrl = $_filter->getClearLinkUrl();
                    $currentFilterName = $block->escapeHtml(__($_filter->getName())) . " " . $block->stripTags($_filter->getLabel());
                    if ($clearLinkUrl):
                        ?>
						<a class="action previous" href="<?= /* @escapeNotVerified */
                        $_filter->getRemoveUrl() ?>"
						   title="<?= /* @escapeNotVerified */
                           __('Previous') ?>" data-current-var="<?= /* @escapeNotVerified */
                        $requestVar ?>" data-current-val="<?= /* @escapeNotVerified */
                        $filterItemVal ?>">
                            <span><?= /* @escapeNotVerified */
                                __('Previous') ?></span>
						</a>
						<a class="action remove"
						   title="<?= $block->escapeHtml($_filter->getFilter()->getClearLinkText()) ?>"
						   href="<?= /* @escapeNotVerified */
                           $clearLinkUrl ?>" data-current-var="<?= /* @escapeNotVerified */
                        $requestVar ?>" data-current-val="<?= /* @escapeNotVerified */
                        $filterItemVal ?>">
							<span><?= $block->escapeHtml($_filter->getFilter()->getClearLinkText()) ?></span>
						</a>
                    <?php else: ?>
						<a class="action remove" href="<?= /* @escapeNotVerified */
                        $_filter->getRemoveUrl() ?>" data-current-var="<?= /* @escapeNotVerified */
                        $requestVar ?>" data-current-val="<?= /* @escapeNotVerified */
                        $filterItemVal ?>"
						   title="<?= /* @escapeNotVerified */
                           $block->escapeHtml(__('Remove')) . " " . $currentFilterName ?>">
                            <span><?= /* @escapeNotVerified */
                                __('Remove This Item') ?></span>
						</a>
                    <?php endif; ?>
				</li>
            <?php endforeach; ?>
		</ol>
	</div>
<?php endif; ?>
