{% extends 'entity/page.html.j2' %}
{% block page_content %}
    {% if entity.description %}
        <div class="container my-5">
            <div class="row">
                <div class="col col-12 col-lg-8">
                    <p>
                        {{ entity.description | localize | html_lang }}
                    </p>
                </div>
            </div>
        </div>
    {% endif %}

    {% if entity.place is not none %}
        {% with places = [entity.place] %}
            {% include 'section/map.html.j2' %}
        {% endwith %}
    {% endif %}

    {% set ns = namespace(subjects = [], witnesses = [], other_attendees = []) %}
    {% for presence in entity.presences | select('public') %}
        {% if presence.role is presence_role_plugin('subject') %}
            {% set ns.subjects = ns.subjects + [presence.person] %}
        {% endif %}
    {% endfor %}
    {% if ns.subjects | length > 0 %}
        <div class="container py-5">
            <div class="row">
                <div class="col col-12 col-lg-8">
                    <section id="attendees--subject" class="section">
                        <h2 class="section-heading">
                            {% trans %}Subjects{% endtrans %}
                            {% with url = page_resource | url ~ '#attendees-subject' %}
                                {% include 'component/permalink.html.j2' %}
                            {% endwith %}
                        </h2>
                        {% with entities = ns.subjects %}
                            {% include ['entity/list--person.html.j2', 'entity/list.html.j2'] %}
                        {% endwith %}
                    </section>
                </div>
            </div>
        </div>
    {% endif %}

    {% for presence in entity.presences | select('public') %}
        {% if presence.role is presence_role_plugin('witness') %}
            {% set ns.witnesses = ns.witnesses + [presence.person] %}
        {% endif %}
    {% endfor %}
    {% if ns.witnesses | length > 0 %}
        <div class="container py-5">
            <div class="row">
                <div class="col col-12 col-lg-8">
                    <section id="attendees--witness" class="section">
                        <h2 class="section-heading">
                            {% trans %}Witnesses{% endtrans %}
                            {% with url = page_resource | url ~ '#attendees-witness' %}
                                {% include 'component/permalink.html.j2' %}
                            {% endwith %}
                        </h2>
                        {% with entities = ns.witnesses %}
                            {% include ['entity/list--person.html.j2', 'entity/list.html.j2'] %}
                        {% endwith %}
                    </section>
                </div>
            </div>
        </div>
    {% endif %}

    {% for presence in entity.presences | select('public') %}
        {% if not presence.role is presence_role_plugin('subject') and not presence.role is presence_role_plugin('witness') %}
            {% set ns.other_attendees = ns.other_attendees + [presence.person] %}
        {% endif %}
    {% endfor %}
    {% if ns.other_attendees | length > 0 %}
        <div class="container py-5">
            <div class="row">
                <div class="col col-12 col-lg-8">
                    <section id="attendees-other" class="section">
                        <h2 class="section-heading">
                            {% trans %}Other attendees{% endtrans %}
                            {% with url = page_resource | url ~ '#attendees-other' %}
                                {% include 'component/permalink.html.j2' %}
                            {% endwith %}
                        </h2>
                        {% with entities = ns.other_attendees %}
                            {% include ['entity/list--person.html.j2', 'entity/list.html.j2'] %}
                        {% endwith %}
                    </section>
                </div>
            </div>
        </div>
    {% endif %}

    {% with file_references = entity | associated_file_references %}
        {% include 'section/media.html.j2' %}
    {% endwith %}
{% endblock %}
