{% if ui is defined %}
    {% if ui == 'item' %}
       {% set component_classes = "item" %}
    {%  elseif ui == 'menu' %}
       {% set component_classes = "ui text compact small fluid menu" %}
    {% endif %}
{% endif %}
{% if login.isLogged() %}
    {% if ui == 'item' %}
        <div class="{{ component_classes }}">
            <div class="ui basic center aligned fitted segment">
                <span class="ui tiny header">{{ login.loggedInAs()|raw }}</span>
            </div>
            <a
                class="ui fluid {% if login.isImpersonated() %}purple{% else %}red{% endif %} basic button"
                href="{% if login.isImpersonated() %}{{ url_for("unimpersonate") }}{% else %}{{ url_for("logout") }}{% endif %}"
            >
                <i class="icon {% if login.isImpersonated() %}user secret{% else %}sign out alt{% endif %}"></i>
                {% if login.isImpersonated() %}{{ _T("Unimpersonate") }}{% else %}{{ _T("Log off") }}{% endif %}
            </a>
        </div>
    {% else %}
        {% if not login.getCompactMenu() %}
            <div class="{{ component_classes }}">
                <div class="ui item">
                    <i class="user circle big icon"></i>
                    {{ login.loggedInAs()|raw }}
                </div>
                <div class="right menu">
                    <div class="item">
                        <a
                            class="ui {% if login.isImpersonated() %}purple{% else %}red{% endif %} icon button"
                            href="{% if login.isImpersonated() %}{{ url_for("unimpersonate") }}{% else %}{{ url_for("logout") }}{% endif %}"
                            title="{% if login.isImpersonated() %}{{ _T("Unimpersonate") }}{% else %}{{ _T("Log off") }}{% endif %}"
                            data-position="bottom right"
                        >
                            <i class="icon {% if login.isImpersonated() %}user secret{% else %}sign out alt{% endif %}"></i>
                            <span class="displaynone">{% if login.isImpersonated() %}{{ _T("Unimpersonate") }}{% else %}{{ _T("Log off") }}{% endif %}</span>
                        </a>
                    </div>
                </div>
            </div>
            {% include "elements/modes.html.twig" %}
        {% else %}
            {% set component_classes = "ui vertical centered tiny fluid icon menu" %}
            <div id="logoutmenu" class="{{ component_classes }}">
                <div class="ui dropdown item no-touch tooltip" data-html="{{ login.loggedInAs()|raw }}" data-position="right center">
                    <i class="user circle icon"></i>
                    <span class="text displaynone">{{ login.loggedInAs()|raw }}</span>
                    <div class="menu">
                        <div class="item">
                            <div class="ui basic center aligned fitted segment">
                                <img src="{{ url_for('logo') }}" width="{{ logo.getOptimalWidth() }}" height="{{ logo.getOptimalHeight() }}" alt="{{ preferences.pref_nom }}" class="icon"/>
                                <div class="ui block huge brand header">
                                    {{ preferences.pref_nom }}
                                    {% if preferences.pref_slogan %}<div class="sub tiny header">{{ __(preferences.pref_slogan) }}</div>{% endif %}
                                </div>
                            </div>
                            {{ login.loggedInAs()|raw }}
                            <div class="ui basic fitted segment">
                                {% include "elements/modes.html.twig" %}
                            </div>
                            <a
                                class="ui {% if login.isImpersonated() %}purple{% else %}red{% endif %} icon button"
                                href="{% if login.isImpersonated() %}{{ url_for("unimpersonate") }}{% else %}{{ url_for("logout") }}{% endif %}"
                            >
                                <i class="icon {% if login.isImpersonated() %}user secret{% else %}sign out alt{% endif %}"></i>
                                {% if login.isImpersonated() %}{{ _T("Unimpersonate") }}{% else %}{{ _T("Log off") }}{% endif %}
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        {% endif %}
    {% endif %}
{% endif %}
