{% extends '@Tabler/fullpage.html.twig' %}

{% block title %}{{ status_text|trans({}, 'TablerBundle') }}{% endblock %}

{% block page_content %}
    {% set errorTitleKey = "http_error_#{status_code}.title" %}
    {% set errorTitleTrans = errorTitleKey|trans({ '%status_code%': status_code }, 'TablerBundle') %}
    {% if errorTitleKey == errorTitleTrans %}
        {% set errorTitleKey = 'http_error.title' %}
        {% set errorTitleTrans = errorTitleKey|trans({ '%status_code%': status_code }, 'TablerBundle') %}
    {% endif %}

    {% set errorMessageKey = "http_error_#{status_code}.description" %}
    {% set errorMessageTrans = errorMessageKey|trans({ '%status_code%': status_code }, 'TablerBundle') %}
    {% if errorMessageKey == errorMessageTrans %}
        {% set errorMessageKey = 'http_error.description' %}
        {% set errorMessageTrans = errorMessageKey|trans({ '%status_code%': status_code }, 'TablerBundle') %}
    {% endif %}

    {% set errorSuggestionKey = "http_error_#{status_code}.suggestion" %}
    {% set errorSuggestionTrans = errorSuggestionKey|trans({ '%status_code%': status_code }, 'TablerBundle') %}
    {% if errorSuggestionKey == errorSuggestionTrans %}
        {% set errorSuggestionKey = 'http_error.suggestion' %}
        {% set errorSuggestionTrans = errorSuggestionKey|trans({ '%status_code%': status_code }, 'TablerBundle') %}
    {% endif %}

    {% if errorSuggestionKey != errorSuggestionTrans and errorMessageKey != errorMessageTrans %}
        {% set errorTitleTrans = errorMessageTrans %}
        {% set errorMessageTrans = errorSuggestionTrans %}
    {% endif %}

    <div class="container container-tight py-4">
        <div class="empty">
            <div class="empty-header">{% block error_code %}{{ status_code }}{% endblock %}</div>
            <p class="empty-title">
                {% block error_title %}
                    {% if errorTitleKey != errorTitleTrans %}
                        {{ errorTitleTrans }}
                    {% else %}
                        {{ status_text }}
                    {% endif %}
                {% endblock %}
            </p>
            <p class="empty-subtitle text-body-secondary">
                {% block error_subtitle %}
                    {{ errorMessageTrans }}
                {% endblock %}
            </p>
            <div class="empty-action">
                {% block error_actions %}
                    {% from '@Tabler/components/buttons.html.twig' import link_button %}
                    {{ link_button(('Take me home'|trans({}, 'TablerBundle')), (path('tabler_welcome'|tabler_route)), 'back') }}
                {% endblock %}
            </div>
        </div>
    </div>
{% endblock %}
