

{#
    -*- coding: utf-8 -*-
    Copyright (C) 2019-2020 CERN.
    Copyright (C) 2019-2020 Northwestern University.
    Copyright (C) 2021 New York University.

    Invenio App RDM is free software; you can redistribute it and/or modify it
    under the terms of the MIT License; see LICENSE file for more details.
#}
<div>
    <header class="theme header {{cookiecutter.project_shortname}}">
{%- raw -%}
      {%- block site_banner %}
      {%- endblock site_banner %}
      <div class="outer-navbar">
        {%- block banner %}
          {# TODO: add support for user banners {% from 'invenio_banners/banner.html' import banner %} {{ banner() }} #}
        {%- endblock banner %}
        {%- block navbar %}
          <div class="ui container invenio-header-container">
            <nav id="invenio-nav" class="ui menu shadowless borderless stackable p-0 pt-10 pb-10">

              {# Main Site logo #}
              <div class="item logo p-0">
                {%- block navbar_header %}
                    {%- block brand %}
                      {%- if config.THEME_LOGO %}
                        <a class="logo-link" href="/">
                          <img class="ui image nr-logo"
                                src="{{ url_for('static', filename=config.THEME_LOGO) }}"
                                alt="{{ _(config.THEME_SITENAME) }}"/>
                        </a>
                      {%- else %}
                        <a class="logo" href="/">{{ _(config.THEME_SITENAME) }}</a>
                      {%- endif %}
                    {%- endblock brand %}
                  {%- endblock navbar_header %}
              </div>

              {# Burger menu toggle for mobile menu #}
              <div id="invenio-burger-toggle">
                <button
                  id="invenio-burger-menu-icon"
                  class="ui button transparent"
                  aria-label="{{ _('Menu') }}"
                  aria-haspopup="menu"
                  aria-expanded="false"
                  aria-controls="invenio-menu"
                >
                  <span class="navicon"></span>
                </button>
              </div>

              {# Main menu #}
              <div
                role="menu"
                id="invenio-menu"
                aria-labelledby="invenio-burger-menu-icon"
                class="ui fluid menu borderless mobile-hidden"
              >
                <button
                  id="invenio-close-burger-menu-icon"
                  class="ui button transparent"
                  aria-label="{{ _('Close menu') }}"
                >
                  <span class="navicon"></span>
                </button>

                {%- if config.THEME_SEARCHBAR %}
                  {%- block navbar_search %}
{% endraw %}
                    {{ "{%-" }} include "{{cookiecutter.package_name}}/searchbar.html" {{ "%}" }}
{% raw %}
                  {%- endblock navbar_search %}
                {%- endif %}

                {# Navigation links #}
                {%- block navbar_nav %}
                  {# TODO: uncomment for communities, requests & more
                  {%- for item in current_menu.submenu('main').children|sort(attribute='order') if item.visible recursive %}
                    {%- if item.children %}
                      <div class="item">
                        <div class="dropdown {{ ' active' if item.active else '' }}">
                          <a role="menuitem"
                            class="dropdown-toggle"
                            data-toggle="dropdown"
                            aria-haspopup="true"
                            aria-expanded="false"
                            href="{{ item.url }}"
                          >
                            {{ item.text|safe }}
                            <b class="caret"></b>
                          </a>
                          <ul class="dropdown-menu">{{ loop(item.children|sort(attribute='order')) }}</ul>
                        </div>
                      </div>
                    {%- else %}
                      <div class="{{' item active' if item.active and loop.depth == 0 else ' item' }}">
                        <a role="menuitem" href="{{ item.url }}">{{ item.text|safe }}</a>
                      </div>
                    {%- endif %}
                  {%- endfor %}
                  #}

                  {% for item in current_menu.submenu('actions').children|sort(attribute='order') if item.visible recursive %}
                    <div class="item">
                      <a role="menuitem" href="{{ item.url }}">{{ item.text|safe }}</a>
                    </div>
                  {% endfor %}
                {%- endblock navbar_nav %}

                {# User Account menu #}
                {%- block navbar_right %}
                  <div class="right menu item">
                    {%- if config.ACCOUNTS and current_user.is_authenticated %}
                      {% for item in current_menu.submenu('notifications').children|sort(attribute='order') if item.visible recursive %}
                        <div class="item inbox">
                          <a role="menuitem" href="{{ item.url }}" aria-label="{{ _("Requests") }}">
                            <i class="fitted inbox icon inverted"></i>
                            <span class="mobile tablet only inline">{{ _("Inbox") }}</span>
                          </a>
                        </div>
                      {% endfor %}
                    {% endif %}
                    {# TODO: support user accounts include config.THEME_HEADER_LOGIN_TEMPLATE #}
                  </div>
                {%- endblock navbar_right %}
              </div>
            </nav>
          </div>
        {%- endblock navbar %}

      {%- block flashmessages %}
        {%- from "invenio_theme/macros/messages.html" import flashed_messages with context -%}
        {{ flashed_messages() }}
      {%- endblock %}
      </div>
    </header>

  {%- block breadcrumbs %}
  {%- endblock breadcrumbs %}
</div>



{%- endraw -%}
