{# Parameters:
  - variant (string) (default: 'neutral')
    - options: ['ec', 'eu', 'neutral']
  - navbar (Navbar object) (default: {})
  - project_logo (object) (default: {})
    format: {
        path: '',
        alt: '',
        classes: ''
      }
  - site_name (string) (default: '')
  - project_link (string) (default: '')
  - head (Navbar object) (default: {})
  - breadcrumbs (Breadcrumbs object) (default: {})
  - language_modal (object) (default: {})
  - light (boolean) (default: false)
  - modals (modal[]) (default: [])
  - attributes (drupal attrs)
#}

{% set _variant = variant|default('neutral') %}
{% set _navbar = navbar|default({}) %}
{% set _project_logo = project_logo|default({}) %}
{% set _site_name = site_name|default('') %}
{% set _project_link = project_link|default('') %}
{% set _navbar_id = navbar_id|default('header-navbar-' ~ random(100)) %}
{% set _head = head|default({}) %}
{% set _breadcrumbs = breadcrumbs|default({}) %}
{% set _language_modal = language_modal|default({}) %}
{% set _light = light ?? false %}
{% set _modals = modals|default([]) %}

{% set _site_name_classes = 'bcl-header__site-name' %}

{% if attributes is empty %}
  {% set attributes = create_attribute() %}
{% endif %}

{% set attributes = attributes.addClass(['bcl-header', 'bcl-header--' ~ _variant]) %}

{% if site_name_classes is not empty %}
  {% set _site_name_classes = _site_name_classes ~ ' ' ~ site_name_classes %}
{% endif %}

{% set _project_classes = 'bcl-header__project' %}
{% if _light is not empty %}
  {% set _project_classes = _project_classes ~ ' light' %}
{% endif %}

<header
  {{ attributes }}
>
  <nav
    {{ _head.attributes.addClass(['navbar', 'navbar-expand-lg', 'navbar-light']) }}>
    <div class='container'>
    {% if _head.brand is not empty %}
      <a class='navbar-brand' href='{{ _head.brand.link }}'>
      {% for logo in _head.brand.logos %}
        <img
          src='{{ logo.src }}'
          {% if logo.alt is not empty %}
          alt='{{ logo.alt }}'
          {% endif %}
          {% if logo.class is not empty %}
          class='{{ logo.class }}'
          {% endif %}
        />
      {% endfor %}
      </a>
    {% endif %}
      <button
        class="navbar-toggler bcl-navbar-toggler"
        type="button"
        data-bs-toggle="collapse"
        data-bs-target='#{{ _navbar_id }}'
        aria-controls='{{ _navbar_id }}'
        aria-expanded="false"
        aria-label="Toggle navigation"
      >
        <span class="navbar-toggler-icon"></span>
      </button>
    </div>
  </nav>


  <!-- project name -->
  {% if _project_logo is not empty or _site_name is not empty %}
  <div class="{{ _project_classes  }}">
    <div class="container">
    {% if _project_link is not empty %}
      <a
        href="{{ _project_link }}"
      >
    {% endif %}
      {% if _project_logo is not empty %}
        <img
        {% if _project_logo.path is not empty %}
          src="{{ _project_logo.path }}"
        {% endif %}
        {% if _project_logo.alt is not empty %}
          alt="{{ _project_logo.alt }}"
        {% endif %}
        {% if _project_logo.classes is not empty %}
          class="{{ _project_logo.classes }}"
        {% endif %}
        />
      {% endif %}
      {% if _site_name is not empty %}
        <span class="{{ _site_name_classes }}">
        {{- _site_name -}}
        </span>
      {% endif %}
    {% if _project_link is not empty %}
      </a>
    {% endif %}
    </div>
  </div>
  {% endif %}

  <!-- navbar -->
  {% if _navbar is not empty %}
    {% include '@oe-bcl/bcl-navbar/navbar.html.twig' with _navbar|merge({
      disable_collapse: true,
      attributes: create_attribute().addClass('bcl-header__navbar collapse navbar-collapse').setAttribute('id', _navbar_id).setAttribute('aria-label', 'Main Navigation'),
    }) only %}
  {% endif %}

  <!-- breadcrumbs -->
  {% if _breadcrumbs is not empty %}
    <div class="container">
      {% include '@oe-bcl/bcl-breadcrumb/breadcrumb.html.twig' with _breadcrumbs only %}
    </div>
  {% endif %}
</header>

{% for modal in _modals %}
  {% include '@oe-bcl/bcl-modal/modal.html.twig' with modal only %}
{% endfor %}

{% if _language_modal is not empty %}
  {% include '@oe-bcl/bcl-language-list/language-list.html.twig' with _language_modal only %}
{% endif %}

