{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #}
{% macro render_menu_item(item, is_sub_item = false) %}

    {% if item.isMenuSection %}
        {% if item.icon is not empty %}
                <i class="fa fa-{{ item.icon }}"></i>
        {% endif %}
        <span class="{{ item.cssClass }}">{{ item.label }}</span>
    {% else %}
        <a href="{{ item.linkUrl }}" class="nav-link {{ ea.mainMenu.isSelected(item)? 'active' }} {{ ea.mainMenu.isExpanded(item) and is_sub_item == false ? 'active' }} {{ item.cssClass }}"
           target="{{ item.linkTarget }}" rel="{{ item.linkRel }}" referrerpolicy="origin-when-cross-origin">
            {% if item.icon is not empty %}
                <i class="{{ item.icon }} nav-icon"></i>
            {% endif %}

            <p>{{ item.label|sov_trans_admin_menu(item.translationParameters)|raw }}</p>

            {% if item.hasSubItems %}<i class="right fas fa-angle-left"></i>{% endif %}
        </a>
    {% endif %}
{% endmacro %}

{% block main_menu_before %}{% endblock %}

<nav class="mt-2">
    <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
        {% block main_menu %}
            {% for menuItem in ea.mainMenu.items %}
                {% block menu_item %}
                    <li class="{{ menuItem.isMenuSection ? 'nav-header' : 'nav-item' }} {{ menuItem.hasSubItems ? 'has-treeview' }} {{ ea.mainMenu.isSelected(menuItem) ? 'active' }} {{ ea.mainMenu.isExpanded(menuItem) ? 'menu-open' }}">
                        {{ _self.render_menu_item(menuItem) }}

                        {% if menuItem.hasSubItems %}
                            <ul class="nav nav-treeview">
                                <li class="nav-item">
                                    {% for menuSubItem in menuItem.subItems %}
                                        {% block menu_subitem %}
                                            {{ _self.render_menu_item(menuSubItem, true) }}
                                        {% endblock menu_subitem %}
                                    {% endfor %}
                                </li>
                            </ul>
                        {% endif %}
                    </li>
                {% endblock menu_item %}
            {% endfor %}
        {% endblock main_menu %}
    </ul>
</nav>

{% block main_menu_after %}{% endblock %}
