<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

/**
 * Category left navigation
 *
 * @var \Magento\Catalog\Block\Navigation $block
 * @var \Magento\Framework\Locale\LocaleFormatter $localeFormatter
 */
?>
<?php if (!$block->getCategory()) {
    return;
} ?>
<?php $_categories = $block->getCurrentChildCategories() ;?>
<?php $_count = is_array($_categories) ? count($_categories) : $_categories->count(); ?>
<?php if ($_count):?>
    <div class="block filter">
        <div class="title">
            <strong><?= $block->escapeHtml(__('Shop By')) ?></strong>
        </div>
        <div class="content">
            <strong class="subtitle"><?= $block->escapeHtml(__('Shopping Options')) ?></strong>
            <dl class="options" id="narrow-by-list2">
                <dt><?= $block->escapeHtml(__('Category')) ?></dt>
                <dd>
                    <ol class="items">
                        <?php /** @var \Magento\Catalog\Model\Category $_category */ ?>
                        <?php foreach ($_categories as $_category):?>
                            <?php if ($_category->getIsActive()):?>
                                <li class="item">
                                    <a href="<?= $block->escapeUrl($block->getCategoryUrl($_category)) ?>"
                                        <?php if ($block->isCategoryActive($_category)):?>
                                            class="current"
                                        <?php endif; ?>
                                    ><?= $block->escapeHtml($_category->getName()) ?></a>
                                    <span class="count">
                                        <?= $block->escapeHtml(
                                            $localeFormatter->formatNumber($_category->getProductCount())
                                        ) ?>
                                    </span>
                                </li>
                            <?php endif; ?>
                        <?php endforeach ?>
                    </ol>
                </dd>
            </dl>
        </div>
    </div>
<?php endif; ?>
