{#
/**
 * Message list
 *
 * Displays status, error, and warning messages, grouped by type.
 *
 * @var array $message_list List of messages to be displayed, grouped by type (info, status, warning, error).
 * @var array $status_headings List of all status types.
 * @var Drupal\Core\Template\Attribute|array $attributes Attributes (class, data, etc.) for the list.
 */
#}
{% set attributes = union_attributes(attributes|default([])) %}
{% set attributes = attributes.addClass(['cu-message-list']) %}
{% for type, messages in message_list %}
  <div role="contentinfo" aria-label="{{ status_headings[type] }}" {{ attributes }}>
    {% if status_headings[type] %}
      <h2 class="visually-hidden">{{ status_headings[type] }}</h2>
    {% endif %}
    {% if messages|length > 1 %}
      <ul class="cu-message-list__list">
        {% for message in messages %}
          <li class="cu-message-list__list-item">{% include '@union/_message.twig' with {
            message: message,
            status: type
          } only %}</li>
        {% endfor %}
      </ul>
    {% else %}
      {% include '@union/_message.twig' with {
        message: messages|first,
        status: type
      } only %}
    {% endif %}
  </div>
{% endfor %}
