{% from 'events/timetable/display/indico/_session_block.html' import render_session_block %}
{% from 'events/timetable/display/indico/_contribution.html' import render_contribution %}
{% from 'events/timetable/display/indico/_break.html' import render_break %}

{% if entries %}
    {% set theme_context = namespace(num_contribution=0) %}
    <ul class="day-list">
        {% for item in entries -%}
            {% set date = item.start_dt.astimezone(tz_object).date() %}
            {% set date_changed = loop.changed(date) %}

            {% if date_changed and not loop.first -%}
                    </ul>
                </li>
            {%- endif -%}

            {%- if date_changed -%}
                {% set anchor -%}
                    day-{{ item.start_dt.date().isoformat() }}
                {%- endset %}
                <li id="{{ anchor }}">
                    {% if multiple_days %}
                        {% block day_header scoped %}
                            <div class="day-header" style="width: 100%;">
                                <div class="day-title" data-anchor="{{ anchor }}" data-anchor-strip-arg="note">
                                    {{ item.start_dt | format_skeleton('EEEEdMMMM', timezone=timezone) }}
                                </div>
                                {% if days %}
                                    <a class="js-go-to-day icon-calendar arrow js-dropdown" data-toggle="dropdown"></a>
                                    <ul class="i-dropdown days-dropdown">
                                        {% for day, _ in days %}
                                            <li>
                                                <a href="#day-{{ day.isoformat() }}">
                                                    {{ day | format_skeleton('EEEdMMM') }}
                                                </a>
                                            </li>
                                        {% endfor %}
                                    </ul>
                                {% endif %}
                            </div>
                        {% endblock %}
                    {% endif %}
                    <ul class="meeting-timetable">
            {%- endif %}

            {% if item.type.name == 'CONTRIBUTION' -%}
                {% set theme_context.num_contribution = theme_context.num_contribution + 1 %}
                {{ render_contribution(item.object, event, theme_settings, theme_context, nested=false,
                                       timezone=timezone, show_notes=theme_settings.show_notes, parent=event,
                                       show_location=show_siblings_location) }}
            {%- elif item.type.name == 'SESSION_BLOCK' -%}
                {{ render_session_block(item.object, event, theme_settings, theme_context, timezone=timezone,
                                        show_notes=theme_settings.show_notes, parent=event, hide_contribs=hide_contribs,
                                        show_location=show_siblings_location,
                                        show_children_location=show_children_location[item.id]) }}
            {%- elif item.type.name == 'BREAK' -%}
                {{ render_break(item.object, event, theme_settings, theme_context, nested=false, timezone=timezone,
                                show_notes=theme_settings.show_notes, parent=event,
                                show_location=show_siblings_location, hide_end_time=theme_settings.hide_end_time) }}
            {%- endif %}
        {%- endfor %}

        {% if entries -%}
                </ul>
            </li>
        {%- endif %}
    </ul>
{% else %}
    <div class="agenda-placeholder flexrow f-a-center">
        <div class="agenda-placeholder-content">
            <span class="placeholder-icon icon-calendar"></span>
            <div class="placeholder-text">{% trans %}The agenda of this meeting is empty{% endtrans %}</div>
            {% if event.can_manage(session.user) %}
                <div>
                    {%- trans url=url_for('timetable.management', event) -%}
                        In order to add entries go to the <a href="{{ url }}">timetable</a> page.
                    {%- endtrans -%}
                </div>
            {% endif %}
        </div>
    </div>
{% endif %}
