{% extends 'entity/page.html.j2' %}
{% set source = source | default(entity) %}
{% set page_title = source.name %}
{% block page_content %}
    {% include 'entity/meta--source.html.j2' %}
    {% with notes = source.notes %}
        {% include 'section-notes.html.j2' %}
    {% endwith %}

    {% set sources = [source] + source.walk_contains | select('public') | list %}
    {% set have_file_references = sources %}
    {% set have_file_references = have_file_references + sources | map(attribute='citations') | flatten | list %}
    {% with file_references = have_file_references | selectattr('public') | map(attribute='file_references') | flatten | unique %}
        {% include 'media.html.j2' %}
    {% endwith %}
    {% set facts = sources | map(attribute='citations') | flatten | select('public') | map(attribute='facts') | flatten | select('public') | reject('has_generated_entity_id') | unique | list %}
    {% if facts | length > 0 %}
        <h2>{% trans %}Facts{% endtrans %}</h2>
        <ul class="entities">
            {% for fact in facts %}
                <li class="{{ loop.cycle('odd', 'even') }}">
                    {% with entity=fact, entity_contexts=entity_contexts(fact) %}
                        {% include ['entity/label--' + entity.plugin_id() + '.html.j2', 'entity/label.html.j2'] %}
                        {% include ['entity/meta--' + entity.plugin_id() + '.html.j2', 'entity/meta.html.j2'] ignore missing %}
                {% endwith %}
                </li>
            {% endfor %}
        </ul>
    {% endif %}
{% endblock %}