{{ if .Site.Params.alert -}}
  {{ partial "header/alert.html" . }}
{{ end -}}

{{ if eq .Site.Params.options.flexSearch false -}}
<div class="sticky-lg-top">
{{ end -}}

<div class="header-bar"></div>

<header class="navbar navbar-expand-md navbar-light doks-navbar">
  <nav class="container-xxl flex-wrap flex-md-nowrap" aria-label="Main navigation">
    <a class="navbar-brand p-0 me-auto" href="{{ "/" | relLangURL }}" aria-label="{{ .Site.Params.Title }}">
      {{ .Site.Params.Title }}
    </a>

    <button class="btn btn-menu d-block d-md-none order-5" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasDoks" aria-controls="offcanvasDoks" aria-label="Open main menu">
      <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-menu"><line x1="3" y1="12" x2="21" y2="12"></line><line x1="3" y1="6" x2="21" y2="6"></line><line x1="3" y1="18" x2="21" y2="18"></line></svg>
    </button>

    <div class="offcanvas offcanvas-start border-0 py-md-1" tabindex="-1" id="offcanvasDoks" data-bs-backdrop="true" aria-labelledby="offcanvasDoksLabel">
      <div class="header-bar d-md-none"></div>
      <div class="offcanvas-header d-md-none">
        <h2 class="h5 offcanvas-title ps-2" id="offcanvasDoksLabel"><a class="text-dark" href="{{ "/" | relLangURL }}">{{ .Site.Params.Title }}</a></h2>
        <button type="button" class="btn-close text-reset me-2" data-bs-dismiss="offcanvas" aria-label="Close main menu"></button>
      </div>
      <div class="offcanvas-body px-4">
        <h3 class="h6 text-uppercase mb-3 d-md-none">Main</h3>
        <ul class="nav flex-column flex-md-row ms-md-n3">
          {{- $current := . -}}
          {{ range .Site.Menus.main -}}
            {{- $active := or ($current.IsMenuCurrent "main" .) ($current.HasMenuCurrent "main" .) -}}
            {{- $active = or $active (eq .Name $current.Title) -}}
            {{- $active = or $active (and (eq .Name "Docs") (eq $current.Section "docs")) -}}
            {{- $active = or $active (and (eq .Name "Blog") (eq $current.Section "blog" "authors")) -}}
            <li class="nav-item">
              <a class="nav-link ps-0 py-1{{ if $active }} active{{ end }}" href="{{ .URL | relLangURL }}">{{ .Name }}</a>
            </li>
          {{ end -}}
        </ul>
        <hr class="text-black-50 my-4 d-md-none">
        <h3 class="h6 text-uppercase mb-3 d-md-none">Socials</h3>
        <ul class="nav flex-column flex-md-row ms-md-auto me-md-n5 pe-md-2">
          {{ range .Site.Menus.social -}}
            <li class="nav-item">
              <a class="nav-link ps-0 py-1" href="{{ .URL | relURL }}">{{ .Pre | safeHTML }}<small class="ms-2 d-md-none">{{ .Name | safeHTML }}</small></a>
            </li>
          {{ end -}}
        </ul>
      </div>
    </div>
    {{ if .Site.Params.options.darkMode -}}
    <button id="mode" class="btn btn-link order-md-1" type="button" aria-label="Toggle user interface mode">
      <span class="toggle-dark"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-moon"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path></svg></span>
      <span class="toggle-light"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-sun"><circle cx="12" cy="12" r="5"></circle><line x1="12" y1="1" x2="12" y2="3"></line><line x1="12" y1="21" x2="12" y2="23"></line><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line><line x1="1" y1="12" x2="3" y2="12"></line><line x1="21" y1="12" x2="23" y2="12"></line><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line></svg></span>
    </button>
    {{ end -}}

    {{ if eq .Site.Params.options.multilingualMode true -}}
    <div class="dropdown order-md-2">
      <button class="btn btn-doks-light dropdown-toggle" id="doks-languages" data-bs-toggle="dropdown" aria-expanded="false" data-bs-display="static">
        {{ .Site.Params.languageISO }}
        <span class="dropdown-caret"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-down"><polyline points="6 9 12 15 18 9"></polyline></svg></span>
      </button>
      <ul class="dropdown-menu dropdown-menu-end shadow rounded border-0" aria-labelledby="doks-languages">

        <li><a class="dropdown-item current" aria-current="true" href="{{ .RelPermalink }}">{{ .Site.Language.LanguageName }}</a></li>

        <li><hr class="dropdown-divider"></li>

      {{ if .IsTranslated -}}
        {{ range .Translations }}
          <li><a class="dropdown-item" rel="alternate" href="{{ .RelPermalink }}" hreflang="{{ .Lang }}" lang="{{ .Lang }}">{{ .Language.LanguageName }}</a></li>
        {{ end -}}
      {{ else -}}
        {{ range .Site.Languages -}}
          {{ if ne $.Site.Language.Lang .Lang }}
            <li><a class="dropdown-item" rel="alternate" href="{{ .Lang | relLangURL }}" hreflang="{{ .Lang }}" lang="{{ .Lang }}">{{ .LanguageName }}</a></li>
          {{ end -}}
        {{ end -}}
      {{ end -}}
        <!--
        <li><hr class="dropdown-divider"></li>
        <li><a class="dropdown-item" href="/docs/contributing/how-to-contribute/">Help Translate</a></li>
        -->
      </ul>
    </div>
    {{ end -}}
  </nav>
</header>

{{ if eq .Site.Params.options.flexSearch false }}
</div>
{{ end -}}

{{ if eq .Section "docs" -}}
<nav class="doks-subnavbar py-2 sticky-lg-top{{ if eq .Site.Params.options.flexSearch false }} d-lg-none{{ end }}" aria-label="Secondary navigation">
  <div class="container-xxl d-flex align-items-md-center">

    {{ if .Site.Params.options.flexSearch -}}
    <form class="doks-search position-relative flex-grow-1 me-auto">
      <input id="search" class="form-control is-search" type="search" placeholder="Search docs..." aria-label="Search docs..." autocomplete="off">
      <div id="suggestions" class="shadow bg-white rounded d-none"></div>
    </form>
    {{ end -}}

    {{ if eq .Site.Params.options.docsVersioning true -}}
    <div class="dropdown ms-3">
      <button class="btn btn-doks-light dropdown-toggle" id="doks-versions" data-bs-toggle="dropdown" aria-expanded="false" data-bs-display="static" aria-label="Toggle version menu">
        <span class="d-none d-lg-inline">Doks</span> v{{ .Site.Params.docsVersion }}
      </button>
      <ul class="dropdown-menu dropdown-menu-end shadow rounded border-0" aria-labelledby="doks-versions">
        <li><a class="dropdown-item current" aria-current="true" href="/docs/{{ .Site.Params.docsVersion }}/prologue/introduction/">Latest ({{ .Site.Params.docsVersion }}.x)</a></li>
        <li><hr class="dropdown-divider"></li>
        <li><a class="dropdown-item" href="/docs/0.2/prologue/introduction/">v0.2.x</a></li>
        <li><a class="dropdown-item" href="/docs/0.1/prologue/introduction/">v0.1.x</a></li>
        <li><hr class="dropdown-divider"></li>
        <li><a class="dropdown-item" href="/docs/versions/">All versions</a></li>
      </ul>
    </div>
    {{ end -}}

    <button class="btn doks-sidebar-toggle d-lg-none ms-3 order-3 collapsed{{ if eq .Site.Params.options.flexSearch false }} ms-auto{{ end }}" type="button" data-bs-toggle="collapse" data-bs-target="#doks-docs-nav" aria-controls="doks-docs-nav" aria-expanded="false" aria-label="Toggle documentation navigation">
      <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" class="doks doks-expand" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><title>Expand</title><polyline points="7 13 12 18 17 13"></polyline><polyline points="7 6 12 11 17 6"></polyline></svg>
      <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" class="doks doks-collapse" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><title>Collapse</title><polyline points="17 11 12 6 7 11"></polyline><polyline points="17 18 12 13 7 18"></polyline></svg>
    </button>

  </div>
</nav>

<div class="container-xxl">
  <aside class="doks-sidebar">
    <nav id="doks-docs-nav" class="collapse d-lg-none" aria-label="Tertiary navigation">
      {{ partial "sidebar/docs-menu.html" . }}
    </nav>
  </aside>
</div>
{{ end -}}
