{% load currency_filters i18n oxyan category_tags ocyan_main ocyanjson cache wagtailsettings_tags %}

{% block promo_header %}
{% get_settings %}
{% if settings.ocyan_plugin_wagtail.OcyanSettings.promo_header %}
<div class="promo_header">
    <div class="container">
        <div class="promo_header_inner">
        {% for block in settings.ocyan_plugin_wagtail.OcyanSettings.promo_header %}
            {% if block.block_type == "TextSlider" %}
            <div class="promo_block textslider-wrapper">
                <div class="textslider">
                    <ul class="textslider-stage">
                    {% for slide in block.value %}
                        {% block textslide %}
                        <li class="textslide">{{ slide.text }}</li>
                        {% endblock %}
                    {% endfor %}
                    </ul>
                </div>
            </div>
            {% else %}
            <div class="promo_block {{ block.block.name }} {% if forloop.first %}first{% endif %}">
                {{ block }}
            </div>
            {% endif %}
        {% endfor %}
        </div>
    </div>
</div>
{% endif %}
{% endblock %}

{% block header %}
<header>
    <nav class="navbar navbar-expand-lg navbar-light header-inner">
        <div class="container">
            {% include 'oxyan/partials/brand.html' with big=True %}

            {% block nav %}
            {% ocyanjson "theme" "menu_depth" 1 as menu_depth %}
            {% category_tree depth=menu_depth as category_tree_items %}

            {% block category_menu %}
            {% cache 300 header_product_menu LANGUAGE_CODE request.site %}
            <div class="collapse navbar-collapse menu-bar product-menu-bar" id="navbarSupportedContent">
                <ul class="navbar-nav">
                    <li class="nav-item dropdown {% if menu_depth > 1 %}position-unset{% endif %}">
                        <button class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                        {% trans "All products" %}
                        </button>
                        {% if menu_depth > 1 %}
                        <ul class="megamenu dropdown-menu " aria-labelledby="navbarDropdown">
                            {% include "oxyan/partials/dropdown.html" with menu_items=category_tree_items mega_menu=True dropdown=True %}
                        {% else %}
                        <ul class="dropdown-menu dropdown-simple" aria-labelledby="navbarDropdown">
                            {% include "oxyan/partials/dropdown_simple.html" with menu_items=category_tree_items dropdown=True %}
                        {% endif %}
                        <li class="nav-item all-products"><a class="nav-link" href="{% url 'catalogue:index' %}">{% trans "All products" %} <i class="fa fa-chevron-right"></i></a></li>
                        </ul>
                    </li>
                </ul>
            </div>
            {% endcache %}
            {% endblock %}
            {% cache 300 header_page_menu LANGUAGE_CODE request.site %}
            <div class="collapse navbar-collapse menu-bar page-menu-bar">
                <ul class="navbar-nav">
                    {% rootpage_as_category as page_tree_root %}
                    {% category_tree 2 page_tree_root as page_tree_items %}
                    {% include "oxyan/partials/dropdown.html" with menu_items=page_tree_items limit=2 %}
                </ul>
            </div>
            {% endcache %}
            {% endblock %}
            {% esi_fragment 'oxyan/headers/partials/user-bar.html' with sessionid=True oscar_open_basket=True messages=messages request=request csrf_token=csrf_token user=user basket=basket num_unread_notifications=num_unread_notifications only %}
            {% block language_chooser %}{% endblock language_chooser %}
        </div>
    </nav>
</header>
{% endblock %}