{# LIBRARIES #}
{{ attach_library('ui_patterns/sa_list.sa_list_lib') }}

{# VARIABLES #}
{% set title = title|default('<i class="far fa-exclamation-circle"></i> Important updates') %}
{% set link_icon_right = link_icon_right|default(global_icon_right|default('fas fa-chevron-right')) %}
{% set attributes = attributes|default(create_attribute()) %}
{% set count = links|length %}
{% set expandable = expandable|default(false) %}
{% set classes = [
  'sa-list',
  expandable ? 'expandable' : '',
] %}


{% if links and links is iterable %}

  {% set prefix_content %}
  <div id="announcement-list-initial">
    {% include "@atoms/tm-links/icon-bookended/icon-bookended.twig" with {
      "text": links[0]['text'],
      "url": links[0]['url'],
      "icon_right": link_icon_right,
      "display": "noflex",
    } only %}
    <i class='fas fa-chevron-right beli belir'></i>
  </div>
  {% endset %}

  {% set collapse_content %}
  <div id="announcement-list">
    {% for link in links %}
      {% include "@atoms/tm-links/icon-bookended/icon-bookended.twig" with {
        "text": link['text'],
        "url": link['url'],
        "icon_right": link_icon_right,
        "display": "noflex",
        "class": 'belianr',
      } only %}
    {% endfor %}
  </div>
  <div class="sa-footer">
    {{ footer }}
  </div>
  {% endset %}

{% endif %}


{# TEMPLATE #}
{% if links and links is iterable %}
  <div {{ attributes.addClass(classes) }}>
    <h2 class="sa-abv-title">{{ title }}</h2>
    {% if expandable %}
      {% include '@molecules/tm-bs/collapse/collapse.twig' with {
        'content_first': true,
        'content': collapse_content,
        'prefix': prefix_content,
        'label': 'View all <span class="count">' ~ count ~ '</span>',
        'hide_label': '<i class="far fa-times-circle"></i>',
        'content_fade': true,
        'aiid': 'sa-abv',
      } only %}
    {% else %}
      {{ collapse_content }}
    {% endif %}
  </div>
{% endif %}
