{% set user = null %}
{% set links = null %}
{% set userdetails = tabler_user() %}
{% if userdetails is not null %}
    {% set user = userdetails.user %}
    {% set links = userdetails.links %}
    {% set showLogoutLink = userdetails.showLogoutLink %}
{% endif %}
{% if user is not null %}
    <div class="nav-item dropdown">
        <a href="#" class="nav-link d-flex lh-1 p-0 px-2" data-bs-toggle="dropdown" aria-label="{{ 'Open personal menu'|trans({}, 'TablerBundle') }}">
            {% import "@Tabler/components/avatar.html.twig" as macro %}
            {% if user.avatar is defined and user.avatar is not empty %}
                {{ macro.avatar({imageUrl : asset(user.avatar), size : 'sm'}) }}
            {% else %}
                {% import "@Tabler/components/avatar_image.html.twig" as macro_image %}
                {{ macro.avatar({content: macro_image.avatar_image(user), size : 'sm'}) }}
            {% endif %}
            {% if not tabler_bundle.isCondensedUserMenu() %}
                <div class="d-none d-xl-block ps-2">
                    <div>{{ user.name }}</div>
                    {% if user.title is not empty %}
                        <div class="mt-1 small text-body-secondary">{{ user.title }}</div>
                    {% endif %}
                </div>
            {% endif %}
        </a>

        <div class="dropdown-menu dropdown-menu-end dropdown-menu-arrow">
            {% for link in links %}
                {% if link.route is not null %}
                    <a href="{{ path(link.route|tabler_route, link.routeArgs) }}" class="dropdown-item">{{ link.label|trans }}</a>
                {% else %}
                    <a href="#" class="dropdown-item">{{ link.label|trans }}</a>
                {% endif %}
            {% endfor %}
            {% if showLogoutLink %}
                <div class="dropdown-divider"></div>
                <a href="{{ logout_path() }}" class="dropdown-item">{{ 'Sign out'|trans({}, 'TablerBundle') }}</a>
            {% endif %}
        </div>
    </div>
{% endif %}
