{% set cssClasses = 'brick' %}
{% set childrenCssClasses = 'children' %}

{% set preview = aa_brick_get_preview(brick) %}
{% set handler = aa_brick_get_handler(brick) %}
{% set isContainer = aa_brick_is_container(brick) %}

{% if isContainer %}
  {% set cssClasses = cssClasses ~ ' horizontal' %}
{% endif %}

{% if brick.type == 'brick.root' %}
  {% set cssClasses = cssClasses ~ ' root-brick' %}
{% elseif brick.type == 'brick.row' %}
  {% set childrenCssClasses = childrenCssClasses ~ ' row' %}
{% elseif brick.type == 'brick.column' %}
  {% set cssClasses = cssClasses ~ ' col' %}
{% endif %}

<div class="{{ cssClasses }}"
     data-brick-id="{{ brick.id }}"
  {% if brick.type == 'brick.root' %}
    data-brick-index-url="{{ app.request.uri }}"
  {% endif %}
     data-brick-type="{{ brick.type }}"
     data-brick-nature="{{ handler.nature }}"
     data-brick-category="{{ handler.category }}"
  {% if isContainer %}
    data-brick-allowed-children="{{ aa_brick_get_allowed_children(brick)|join(',') }}"
  {% endif %}
>
  <div class="brick-anchor" id="brick-{{ brick.id }}"></div>
  {% if brick.type != 'brick.root' %}
    {% include '@AutoAdminBrickBuilder/admin_brick/actions.html.twig' with {brick: brick} %}
  {% endif %}

  {#  {{ dump(preview) }} #}
  {#  {{ dump(isContainer) }} #}
  {% if preview != false or isContainer %}
    <div class="inner">
      {% if brick.type != 'brick.root' %}
        {% if preview != false %}
          <div class="preview">{{ preview|raw }}</div>
        {% endif %}
      {% endif %}

      {% if isContainer %}
        {# children #}
        <div class="{{ childrenCssClasses }}">
          {% for child in brick.children %}
            {% include '@AutoAdminBrickBuilder/admin_brick/brick.html.twig' with {brick: child} %}
          {% endfor %}
        </div>
        {# add block btn #}
        {% include '@AutoAdminBrickBuilder/admin_brick/add_brick.html.twig' with {parent: brick} %}
      {% endif %}
    </div>
  {% endif %}
</div>