{% macro actions(actions, options = {}) -%}
    {%- import '@Tabler/components/button.html.twig' as macro -%}
    {%- if actions|length >= 1 -%}
        {%- set class = 'btn-sm' -%}
        {%- set translationDomain = 'messages' -%}
        {%- if options.translationDomain is defined -%}
            {%- set translationDomain = options.translationDomain -%}
        {%- endif -%}
        {%- if options.class is defined -%}
            {%- set class = options.class -%}
        {%- endif -%}
        {%- set trash = null -%}
        {%- set divider = false -%}
        <div class="dropdown">
            <a href="#" class="link-secondary {{ class }}" data-bs-toggle="dropdown" data-bs-auto-close="outside" aria-expanded="false" aria-label="{{ 'Actions'|trans({}, 'TablerBundle') }}">
                <i class="{{ options.icon|default('fas fa-ellipsis-h') }}"></i>
            </a>
            <div class="dropdown-menu dropdown-menu-end" data-popper-placement="bottom-end">
                {%- for icon,values in actions -%}
                    {%- if 'divider' in icon and values is null -%}
                        {%- if not loop.last and divider is same as (false) -%}
                            <hr class="dropdown-divider" />
                        {%- endif -%}
                        {%- set divider = true -%}
                    {%- else -%}
                        {%- if values is iterable -%}
                            {%- if values['title'] is not defined -%}
                                {%- set values = values|merge({'title': icon|trans({}, translationDomain)}) -%}
                            {%- endif -%}
                        {%- else -%}
                            {%- set values = {'href': values, 'title': icon|trans({}, translationDomain)} -%}
                        {%- endif -%}
                        {%- if icon == 'trash' -%}
                            {%- set trash = values -%}
                        {%- else -%}
                            {%- if values.children is defined -%}
                                {%- if values.title is defined and values.title is not empty -%}
                                    <div class="dropend">
                                        <a class="dropdown-item dropdown-toggle" href="#" data-bs-toggle="dropdown" data-bs-auto-close="outside" role="button" aria-expanded="false">
                                            {{ values.title|trans }}
                                        </a>
                                        <div class="dropdown-menu">
                                            {%- for childIcon, childValues in values.children -%}
                                                {{- macro.button(false, childValues|merge({icon: false, class: childValues.class is defined ? childValues.class ~ ' dropdown-item' : 'dropdown-item'}), false) -}}
                                            {%- endfor -%}
                                        </div>
                                    </div>
                                {%- else -%}
                                    {%- if divider is same as (false) %}<hr class="dropdown-divider" />{% endif -%}
                                    {%- for childIcon, childValues in values.children -%}
                                        {{- macro.button(false, childValues|merge({icon: false, class: childValues.class is defined ? childValues.class ~ ' dropdown-item' : 'dropdown-item'}), false) -}}
                                    {%- endfor -%}
                                    <hr class="dropdown-divider" />
                                {%- endif -%}
                                {%- set divider = true -%}
                            {%- else -%}
                                {%- set divider = false -%}
                                {{- macro.button(false, values|merge({icon: false, class: values.class is defined ? values.class ~ ' dropdown-item' : 'dropdown-item'}), false) -}}
                            {%- endif -%}
                        {%- endif -%}
                    {%- endif -%}
                {%- endfor -%}
                {%- if trash is not null -%}
                    {%- if actions|length > 1 and divider is same as (false) -%}
                        <hr class="dropdown-divider" />
                    {%- endif -%}
                    {{- macro.button(false, trash|merge({class: trash.class is defined ? trash.class ~ ' text-danger dropdown-item' : 'dropdown-item'}), false) -}}
                {%- endif -%}
            </div>
        </div>
    {%- endif -%}
{%- endmacro %}
