{{ attach_library('ui_patterns/routes_list.routes_list_lib') }}

{% set list_classes = [
  'ulc',
  'route-list',
] %}
{% if list_class %}
  {% set list_classes = list_classes|merge([list_class]) %}
{% endif %}

{% if collapsible %}
  {% set content %}
    {% embed "@molecules/html/list/list.twig" with {
      "list": list,
      "list_class": list_classes|join(' '),
    } only %}
    {% endembed %}
  {% endset %}
  {% set pid = pid|default("rl-" ~ random()) %}
  {% set aiid = aiid|default("ml-" ~ random()) %}
  {% include "@organisms/tm-bs/accordion/_accordion_items.twig" with {
    "pid": pid,
    "child_variant": "aci_a",
    "wrapper_class": "route-accordion acw-a",
    "items": [{
      "pid": pid,
      "aiid": aiid,
      "label": header,
      "content": content,
    }]
  } only %}
{% else %}
  <h2 class="route-list-header">{{ header }}</h2>
  {% if list and list is iterable %}
    {% include "@molecules/html/list/list.twig" with {
      "list": list,
      "list_class": list_classes|join(' ')
    } only %}
  {% endif %}
{% endif %}
