{% if isFrontOffice is defined and isFrontOffice == true %}
    {% if app.session is not null and app.session.started %}
        {% set messages = app.session.flashbag.all() %}
        {% if messages|length > 0 %}
            <div class="sylius-flash-message {% if class is defined %}{{ class }}{% else %}container{% endif %}">
                {% for type, flashes in messages %}
                    {% if type in ['success', 'error', 'info', 'warning'] %}
                        {% for flash in flashes %}
                        {% set bootstrap = 'success' %}
                        {% if 'error' == type %}
                            {% set result = 'negative' %}
                            {% set icon = 'remove' %}
                            {% set bootstrap = 'danger' %}
                        {% endif %}

                        {% if 'info' == type %}
                            {% set result = 'info' %}
                            {% set icon = 'info' %}
                            {% set bootstrap = 'info' %}
                        {% endif %}

                        <div class="alert alert-{{ bootstrap }}">
                            <p {{ sylius_test_html_attribute('flash-messages') }}>
                                {% if flash is iterable %}
                                    {{ flash.message|trans(flash.parameters, 'flashes') }}
                                {% else %}
                                    {{ flash|trans({}, 'flashes') }}
                                {% endif %}
                            </p>
                        </div>
                    {% endfor %}
                    {% endif %}
                {% endfor %}
            </div>
        {% endif %}
    {% endif %}
{% else %}
    {% if app.session is not null and app.session.started %}
        {% for type in ['success', 'error', 'info', 'warning'] %}
            {% for flash in app.session.flashbag.get(type) %}
                {% if 'error' == type %}
                    {% set result = 'negative' %}
                    {% set icon = 'remove' %}
                {% endif %}
                {% if 'info' == type %}
                    {% set result = 'info' %}
                    {% set icon = 'info' %}
                {% endif %}
                <div class="ui icon {{ result|default('positive') }} message sylius-flash-message">
                    <i class="close icon"></i>
                    <i class="{{ icon|default('checkmark') }} icon"></i>
                    <div class="content">
                        <div class="header">
                            {% set header = 'sylius.ui.'~type %}
                            {{ header|trans }}
                        </div>
                        <p {{ sylius_test_html_attribute('flash-messages') }}>
                            {% if flash is iterable %}
                                {{ flash.message|trans(flash.parameters, 'flashes') }}
                            {% else %}
                                {{ flash|trans({}, 'flashes') }}
                            {% endif %}
                        </p>
                    </div>
                </div>
            {% endfor %}
        {% endfor %}
    {% endif %}
{% endif %}

