{% set item_id = item.id|default(item.participant1.id|default(item[0].id|default(null))) %}
<tr id="tr-{{ item_id }}" class="group {{ item_id in (selected ?? []) ? 'has-checked' : '' }} has-checked:bg-gray-50 dark:has-checked:bg-gray-800/50"
    data-action="contextmenu->ferienpass--admin-list#showContextMenu"
>

    {% if ms|default(null) is not null %}

        <td class="relative px-7 sm:w-12 sm:px-6">
            <div class="absolute inset-y-0 left-0 hidden w-0.5 bg-primary-600 group-has-checked:block dark:bg-primary-500"></div>

            <div class="group absolute top-1/2 left-4 -mt-2 grid size-4 grid-cols-1">
                <input type="checkbox"
                       id="cbx_ms_{{ item_id }}"
                       data-model="selected[]"
                       autocomplete="off"
                       value="{{ item_id }}"
                       class="col-start-1 row-start-1 size-4 appearance-none rounded-sm border border-gray-300 bg-white checked:border-primary-600 checked:bg-primary-600 checked:bg-none indeterminate:border-primary-600 indeterminate:bg-primary-600 indeterminate:bg-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 disabled:border-gray-300 disabled:bg-gray-100 disabled:checked:bg-gray-100 dark:border-white/20 dark:bg-gray-800/50 dark:checked:border-primary-500 dark:checked:bg-primary-500 dark:indeterminate:border-primary-500 dark:indeterminate:bg-primary-500 dark:focus-visible:outline-primary-500 dark:disabled:border-white/10 dark:disabled:bg-gray-800 dark:disabled:checked:bg-gray-800 forced-colors:appearance-auto">
                <svg viewBox="0 0 14 14" fill="none" class="pointer-events-none col-start-1 row-start-1 size-3.5 self-center justify-self-center stroke-white group-has-disabled:stroke-gray-950/25 dark:group-has-disabled:stroke-white/25">
                    <path d="M3 8L6 11L11 3.5" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="opacity-0 group-has-checked:opacity-100" />
                    <path d="M3 7H11" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="opacity-0 group-has-indeterminate:opacity-100" />
                </svg>
            </div>
            <label for="cbx_ms_{{ item_id }}" class="sr-only">Auswählen Element {{ item_id }}</label>
        </td>

    {% endif %}

    {% if prepend|default(null) is not null %}
        <td class="relative whitespace-nowrap py-2.5 pl-1 pr-1">  {{ include(template_from_string(prepend)) }}</td>
    {% endif %}

    {# Cells use `overflow: clip` (not `overflow: hidden`) together with
       `overflow-clip-margin: 6px`, so a child link's hover background that
       extends `~6px` past the cell via `-mx-1.5 -my-1` can render outside
       the cell without being clipped. Truncation with ellipsis still works
       because text-overflow uses the visible viewport, not the clip
       margin. (Modern browsers, Chromium / Firefox / Safari 16+.) #}
    {% for th, td in columns|default([]) %}
        {% if td is not null %}
            {% if loop.first %}
                <td class="whitespace-nowrap py-2.5 pl-2 pr-1 {{ th in (rightAlignedColumns ?? []) ? "text-right" : "text-left" }} text-sm font-medium text-gray-900 group-has-checked:text-primary-600 dark:text-gray-100/90 dark:group-has-checked:text-primary-400 sm:pl-0 {{ truncate ?? true ? 'max-w-xs truncate overflow-clip [overflow-clip-margin:6px]' : '' }}{{ th in (squeezedColumns ?? []) ? " hidden @lg/table:table-cell" : "" }}">
                    {{ td|default(null) is not null ? include(template_from_string(td)) : "" }}
                </td>
            {% else %}
                <td class="whitespace-nowrap py-2.5 pl-2 pr-1 {{ th in (rightAlignedColumns ?? []) ? "text-right" : "text-left" }} text-sm text-gray-700 dark:text-gray-100/50 {{ truncate ?? true ? 'max-w-xs truncate overflow-clip [overflow-clip-margin:6px]' : '' }}{{ th in (squeezedColumns ?? []) ? " hidden @lg/table:table-cell" : "" }}">
                    {{ td|default(null) is not null ? include(template_from_string(td)) : "" }}
                </td>
            {% endif %}
        {% endif %}
    {% endfor %}

    {% if showActions ?? true %}
    <td class="relative whitespace-nowrap py-2.5 pl-1 pr-2 sm:pr-0 text-right">

        <div class="flex items-center justify-end gap-x-2">

            {% set comments = item.comments|default(null) %}
            {% if (is_granted('ROLE_ADMIN') or is_granted('ROLE_PARTICIPANTS_ADMIN')) and comments is not null and showUrl|default(null) is not null %}
                <a href="{{ include(template_from_string(showUrl)) }}?kommentare=1"
                   data-turbo-frame="slideover"
                   title="Bearbeitungsnotizen"
                   class="flex w-16 items-center justify-end gap-x-1">
                    <span class="size-6 text-gray-400" aria-hidden="true">{{ ux_icon('ph:chat-dots') }}</span>
                    <span class="text-xs leading-6 text-gray-700 dark:text-gray-300">{{ comments|length }}</span>
                </a>
            {% endif %}


            {% set actions = list_actions(item, [], { view: routeName ?? app.request.get('_route') }) %}
            {% set actions = actions.children|filter(a => a.displayed) %}
            {% if actions|length > 0 %}

                <div class="flex flex-none items-center justify-end">

                    <twig:Admin:Dropdown>
                        <twig:block name="toggle">
                            <button class="flex items-center rounded-full text-gray-400 hover:text-gray-600 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 dark:text-gray-400 dark:hover:text-gray-300">
                                <span class="sr-only">Open options</span>
                                <twig:ux:icon name="ph:dots-three-vertical-bold" aria-hidden="true" class="size-5" />
                            </button>
                        </twig:block>
                        <twig:block name="dropdown">
                            {% set sections = actions|map(a => a.extra('section', 'default'))|reduce((unique, s) => s in unique ? unique : unique|merge([s]), []) %}
                            {% for section in sections %}
                                <div class="py-1">
                                    {% for action in actions|filter(a => a.extra('section', 'default') == section) %}
                                        {% set itemAttrs = action.extra('attr', [])|merge(action.linkAttributes|default([])) %}
                                        <twig:Admin:DropdownItem 
                                            href="{{ action.uri }}" 
                                            :attributes="itemAttrs"
                                            :method="action.extra('method', 'get')"
                                        >
                                            {% trans_default_domain 'admin' %}
                                            <span class="mr-1.5 size-4 flex-shrink-0 {{ action.extra('color') }}">{{ action.extra('icon') ? ux_icon('ph:'~action.extra('icon')) }}</span>
                                            {%- set label = action.label -%}
                                            {%- set label = label|trans(action.extra('translation_params', {})) -%}
                                            <span class="text-left leading-tight">{{ label }}</span>
                                        </twig:Admin:DropdownItem>
                                    {% endfor %}
                                </div>
                            {% endfor %}
                        </twig:block>
                    </twig:Admin:Dropdown>

                </div>

            {% endif %}
        </div>

    </td>
    {% endif %}
</tr>
