{% extends theme('base.html') %}
{% import 'macro/flask.html' as flask %}
{% import 'macro/form.html' as fui %}

{% block container %}
    <div class="ui container">
        <div class="content">
            <div class="ui clearing segment">
                {% block auth_header %}
                    {% if logo_url %}
                        <a href="{{ url_for('core.account.index') }}">
                            <img class="ui tiny centered image" src="{{ logo_url }}" alt="{{ website_name }}">
                        </a>
                    {% else %}
                        <i class="massive sign in icon image ui"></i>
                    {% endif %}

                    <h2 class="ui center aligned header">
                        {% block auth_title %}

                            {% if g.auth and g.auth.user_name %}
                                {% if g.auth.known_user and g.auth.user %}
                                    {{ g.auth.user.name }}
                                    {% if g.auth.user.photo %}
                                        <img class="ui avatar tiny image" src="{{ url_for('core.account.photo', user=g.auth.user, field='photo') }}" alt="{{ g.auth.user.name }}">
                                    {% else %}
                                        ·
                                    {% endif %}
                                    {{ g.auth.user.user_name }}
                                {% elif g.auth.user_name %}
                                    {{ g.auth.user_name }}
                                {% endif %}
                                {% block auth_subtitle %}{% endblock %}
                            {% else %}
                                <div class="content">
                                    {{ _("Sign in at %(website)s", website=website_name) }}
                                </div>
                                <div class="sub header">
                                    {% trans %}Manage your information and your authorizations{% endtrans %}
                                </div>
                            {% endif %}
                        {% endblock %}
                    </h2>
                {% endblock %}

                {% block messages %}
                    {{ flask.messages() }}
                {% endblock %}

                {% block auth_content %}
                    {% call fui.render_form(form, hx_boost="false") %}
                        {% block auth_form_content %}{% endblock %}

                        {% block auth_buttons %}
                            <div class="ui left floated stackable buttons">
                                {% block auth_left_buttons %}
                                    <a type="button" class="ui button" href="{{ url_for('core.auth.login') }}">
                                        {% trans %}Switch account{% endtrans %}
                                    </a>
                                {% endblock %}
                            </div>
                            <div class="ui right floated stackable buttons">
                                {% block auth_right_buttons %}{% endblock %}
                            </div>
                        {% endblock %}
                    {% endcall %}
                {% endblock %}
            </div>
        </div>
    </div>
{% endblock %}
