{# LIBRARIES #}
{{ attach_library('ui_patterns/libraries.bs_dropdown') }}

{# VARIABLES #}
{% set status = status|default('primary') %}

{# TEMPLATE #}
{% if stations_list|length > 1 %}
  <div class="carousel-select d-inline-block">
    <button class="btn btn-{{ status }} dropdown-toggle mb-0"
            type="button"
            id="crsls-best-fares"
            data-bs-toggle="dropdown" >
      Station
    </button>
    <ul class="dropdown-menu" aria-labelledby="crsls-best-fares">
      {% set cards = 0 %}
      {% set slides = 0 %}
      {% for crs, ticket_group in tickets %}
        {% set cards = (ticket_group|length) / 3 %}
        <li>
          <button
            type="button"
            id="crsls-{{ crs }}-btn"
            data-bs-target="#crslc-best-fares"
            data-bs-slide-to="{{ slides }}"
            class="dropdown-item crslsb"
            aria-label="Slide {{ slides }}">
            {{ stations_list[crs] }}
          </button>
        </li>
        {% set slides = slides + cards %}
      {% endfor %}
    </ul>
  </div>
{% else %}
  {% for crs, ticket_group in tickets %}
    {{ stations_list[crs] }}
  {% endfor %}
{% endif %}
