<?php
$configHelper = $this->helper('Wyomind\ElasticsearchLayeredNavigation\Helper\Config');
$priceHelper = $this->helper('Magento\Framework\Pricing\Helper\Data');
?>
<?php if ($configHelper->isBreadcrumbEnabled($block->getType())) : ?>

    <?php
    // CUSTOM THEME
    $themeHelper = $this->helper('Wyomind\ElasticsearchCore\Helper\Theme');
    $themeClass = "";
    $theme = ['model' => $themeHelper->getThemeModel()];
    if ($theme['model'] == "Infortis/ultimo") :
        $themeClass = "ultimo";
    endif;

    // RESULTS
    $frontendHelper = $this->helper('Wyomind\ElasticsearchLayeredNavigation\Helper\Frontend');
    $result = $frontendHelper->getResult($block->getType());

    // FILTERS
    $filters = $result['selectedFilters'];
    ?>

    <div class="eln-breadcrumb <?= $themeClass ?>">
        <div class="filter-current" data-collapsible="true" role="tablist" data-role="eln-breadcrumb-content">
            <?php if (!empty($filters)): ?>
                <ol class="items">
                    <?php foreach ($filters as $key => $filter): ?>
                        <?php if ($key == "final_price") : ?>
                            <li class="item wyomind-primary-bgcolor">
                        <span class="filter-label">
                            <a href="#" attribute-code="<?= $key ?>" class="remove-after">
                                <?php echo __("Price"); ?>
                            </a>
                        </span>
                                <span class="filters">
                            <span class="filter-value">
                                <a href="#" attribute-code="<%= key %>" class="remove-after">
                                    <?= $priceHelper->currency($filter['values']['min'], true, false) ?>
                                    -<?= $priceHelper->currency($filter['values']['max'], true, false) ?>
                                </a>
                            </span>
                        </span>
                                <a class="action remove" href="#" attribute-code="<?= $key ?>"
                                   title="<?= __("Remove Price") ?> <?= $filter['values']['min'] ?>-<?= $filter['values']['max'] ?>">
                                    <span<?php __('Remove Price') ?></span>
                                </a>
                            </li>

                        <?php elseif ($key == "rating"): ?>
                            <li class="item wyomind-primary-bgcolor">
                            <span class="filter-label">
                                <a href="#" attribute-code="<?= $key ?>" class="remove-after">
                                <?php echo __("Rating"); ?>
                                </a>
                            </span>
                                <span class="filters">
                                    <?php foreach ($filter['values'] as $id => $label): ?>
                                    <?php $id = str_replace('_','-',$id); ?>
                                        <?php if ($id != -1): ?>
                                            <span class="filter-value">
                                            <a href="#" attribute-code="<?= $key ?>" option-id="<?= $id ?>" option-label="<?= $id ?>"
                                               class="remove-after-and-others">
                                                <div title="<?= $id ?> & up"
                                                     style="float: none;max-width: 100%;width: 100%; display:inline">
                                                    <div class="product-reviews-summary short"
                                                         style="display:inline-block">
                                                        <div class="rating-summary">
                                                            <span class="label"><span><?php __('Rating:') ?></span></span>
                                                            <div class="rating-result" title="<?= $id ?>%">
                                                                <span style="width:<?= $id ?>%"><span><?= $id ?>%</span></span>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </a>
                                        </span>
                                        <?php else: ?>
                                            <span class="filter-value">
                                            <a href="#" attribute-code="<?= $key ?>" option-id="<?= $id ?>"
                                               class="remove-after-and-others">
                                            <?php echo __("No rating"); ?>
                                            </a>
                                        </span>
                                        <?php endif; ?>
                                    <?php endforeach; ?>
                                </span>
                                <a class="action remove" href="#" attribute-code="<?= $key ?>"
                                   title="<?php echo __("Remove Rating"); ?>">
                                    <span><?php echo __("Remove Rating"); ?></span>
                                </a>
                            </li>
                        <?php else: ?>
                            <?php if (isset($filter['label'])): ?>
                                <li class="item wyomind-primary-bgcolor">
                                <span class="filter-label">
                                    <a href="#" attribute-code="<?= $key ?>" class="remove-after">
                                        <?= $filter['label'] ?>
                                    </a>
                                </span>
                                    <span class="filters">
                                    <?php foreach ($filter['values'] as $id => $label): ?>
                                        <span class="filter-value">
                                            <a href="#" attribute-code="<?= $key ?>" option-id="<?= $id ?>" option-label="<?= $label ?>"
                                               class="remove-after-and-others">
                                                <?= $label ?>
                                            </a>
                                        </span>
                                    <?php endforeach; ?>
                                </span>
                                    <a class="action remove" href="#" attribute-code="<?= $key ?>"
                                       title="<?= __('Remove') ?> <?= $filter['label'] ?>">
                                        <span><?= __('Remove') ?> <?= $filter['label'] ?></span>
                                    </a>
                                </li>
                            <?php endif; ?>
                        <?php endif; ?>

                    <?php endforeach; ?>
                </ol>
            <?php endif; ?>
        </div>
    </div>



<?php endif; ?>
