{% from 'events/management/_action_menu.html' import render_action_menu %}
{% from 'message_box.html' import message_box %}


{%- macro _render_clone_info(event) -%}
    {% set cloned_from = event.cloned_from %}
    {% if cloned_from and not cloned_from.is_deleted %}
        {% set link_start -%}
            <a href="{{ url_for('event_management.settings', cloned_from) }}" title="{{ cloned_from.title }}">
        {%- endset %}
        {% set link_end -%}
            </a>
        {%- endset %}
        {% set date = cloned_from.start_dt_local | format_date('medium', timezone=cloned_from.tzinfo) %}

        {% trans name=event.creator.full_name, email=event.creator.email -%}
            Created by {{ name }} ({{ email }}) from event on {{ link_start }}{{ date }}{{ link_end }}
        {%- endtrans %}
    {% else %}
        {% trans name=event.creator.full_name, email=event.creator.email -%}
            Created by {{ name }} ({{ email }})
        {%- endtrans %}
    {% endif %}
{%- endmacro -%}


{# The extra args are not used in Indico but are there on purpose for others overriding the template. #}
{% macro render_event_management_header_right(event, event_types, with_clone_info=true, with_action_menu=true) %}
    {% set start_date = event.start_dt | format_date('d MMM', timezone=event.tzinfo) %}
    {% set end_date = event.end_dt | format_date('d MMM', timezone=event.tzinfo) %}

    <div class="banner full-width">
        <div class="title">
            <a href="{{ url_for('event_management.settings', event) }}">
                {{ event.get_verbose_title(show_series_pos=(event.type_.name == 'lecture')) }}
                <span class="date">
                    {% if start_date == end_date %}
                        {{ start_date }}
                    {% else %}
                        {{ start_date }} - {{ end_date }}
                    {% endif %}
                </span>
            </a>
            {{ template_hook('event-management-after-title', event=event) }}
            {% if with_clone_info %}
                <div class="subtitle">
                    {{ _render_clone_info(event) }}
                </div>
            {% endif %}
        </div>
        {% if with_action_menu %}
            {{ render_action_menu(event, event_types) }}
        {% endif %}
    </div>
{% endmacro %}
