<div class="col-sm-12">
    <table class="table table-condensed list-warnings">
        <p class="h4">Alerts</p>
        {% if alerts is mapping %}
            <thead>
                <tr>
                    {% for index in range(style._labels | length) %}
                        <th style="color: {{ style.primary_colors[index] }};">{{ style._labels[index] }}</th>
                    {% endfor %}
                    <th></th>
                </tr>
            </thead>
            {% for key, value in alerts.items() %}
                {% set a = value | first %}
                {% if a.alert_type.name != "REJECTED" %}
                    <tr{% if loop.first %} style="border-top:0"{% endif %}>
                        {% for alert in value %}
                            <td>
                                {% if not alert._is_empty %}
                                    {% include 'alerts/alert_' + alert.alert_type.name | lower  + '.html'  %}
                                {% else %}
                                    <em>Alert not present in {{ style._labels[idx] }}</em>
                                {% endif %}
                            </td>
                        {% endfor %}
                        <td>
                            <span class="label label-{{ styles[a.alert_type.name | lower] }}">{{ a.alert_type_name }}</span>
                        </td>
                    </tr>
                {% endif %}
            {% endfor %}
        {% else %}
            {% for alert in alerts %}
                {% if alert.alert_type.name != "REJECTED" %}
                    <tr{% if loop.first %} style="border-top:0"{% endif %}>
                        <td>{% include 'alerts/alert_' + alert.alert_type.name | lower  + '.html'  %}</td>
                        <td>
                            <span class="label label-{{ styles[alert.alert_type.name | lower] }}">{{ alert.alert_type.name | lower | capitalize | replace("_", " ") }}</span>
                        </td>
                    </tr>
                {% endif %}
            {% endfor %}
        {% endif %}
    </table>
</div>