{% if versions %}

  {% if current_version != versions.tags[-1] and current_version != versions.branches[0] %}
  <p style="margin-top: 1em; margin-bottom: 0;">
    <strong>
    You're reading an old version of this documentation (v. {{current_version.name}}).<br>
    If you want up-to-date information, please have a look at <a href="{{ vpathto(versions.tags[-1].name) }}">latest</a>.
  </strong>
  </p>
  {% endif %}

  {% if current_version == versions.branches[0] %}
  <p style="margin-top: 1em; margin-bottom: 0;">
  <strong>
    You're reading the documentation for a development version ({{current_version.name}}).<br>
    For the latest released version, please have a look at <a href="{{ vpathto(versions.tags[-1].name) }}">latest</a>.
  </strong>
  </p>
  {% endif %}

<nav class="bd-links" id="bd-docs-nav" aria-label="Versions navigation">
    <div class="bd-toc-item active">
        <ul class="current nav bd-sidenav">
        <li class="toctree-l1 has-children">
            <p class="caption"><span class="caption-text">Version</span></p>
            <input class="toctree-checkbox" id="toctree-checkbox-1" name="toctree-checkbox-1" type="checkbox">
            <label for="toctree-checkbox-1"> <i class="fas fa-chevron-down"></i></label>

            <ul>

                {%- for item in versions.branches %}
                  {% if item == current_version %}
                  <li class="toctree-l2 current active"><a href="{{ item.url }}"> Development </a></li>
                  {% else %}
                  <li><a href="{{ item.url }}"> Development </a></li>
                  {% endif %}
                {%- endfor %}

                {%- for item in versions.tags[::-1] %}

                {% if item == current_version %}

                  {% if loop.first %}
                    <li class="toctree-l2 current active"><a href="{{ item.url }}">{{ item.name }} (latest)</a></li>
                  {% else %}
                    <li class="toctree-l2 current active"><a href="{{ item.url }}">{{ item.name }}</a></li>
                  {% endif %}

                {% else %}

                  {% if loop.first %}
                    <li><a href="{{ item.url }}">{{ item.name }} (latest)</a></li>
                  {% else %}
                    <li><a href="{{ item.url }}">{{ item.name }}</a></li>
                  {% endif %}

                {% endif %}
                {%- endfor %}

            </ul>
        </li>
        </ul>
    </div>
  </nav>

{% endif %}