<div>
    <div id="album">
        <div class="flex flex-wrap flex-row gap-4" @if($album->hasProcessingMedia) wire:poll @endif>
            <div class="relative rounded-lg overflow-hidden cursor-pointer h-80 flex-grow flex items-center justify-center sm:w-96 flex flex-col gap-1">
                @if(!$album->hasProcessingMedia)
                    <x-drawer-trigger target="image-add" action="open" class="flex-grow w-full text-center bg-gray-300 dark:bg-gray-700 hover:opacity-80 flex items-center justify-center transition-opacity">
                        <svg class="w-24 h-24 text-gray-200 dark:text-gray-600" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
                            <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h14m-7 7V5"/>
                        </svg>
                    </x-drawer-trigger>
                @endif
                <x-drawer-trigger target="image-add" action="open" class="flex-grow w-full text-center bg-gray-300 dark:bg-gray-700 hover:opacity-80 flex items-center justify-center transition-opacity">
                    <svg class="w-24 h-24 text-gray-200 dark:text-gray-600" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
                        <path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M20 6H10m0 0a2 2 0 1 0-4 0m4 0a2 2 0 1 1-4 0m0 0H4m16 6h-2m0 0a2 2 0 1 0-4 0m4 0a2 2 0 1 1-4 0m0 0H4m16 6H10m0 0a2 2 0 1 0-4 0m4 0a2 2 0 1 1-4 0m0 0H4"/>
                    </svg>
                </x-drawer-trigger>
            </div>
            @foreach ($images as $image)
                @if($image->isProcessing)
                    <div wire:transition wire:key="placeholder_{{ $image->id }}" role="status" class="flex items-center justify-center h-80 flex-grow bg-gray-300 rounded-lg animate-pulse dark:bg-gray-700 min-w-80">
                        <div class="min-w-lg">
                            <svg class="w-10 h-10 text-gray-200 dark:text-gray-600" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 18">
                                <path d="M18 0H2a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2Zm-5.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Zm4.376 10.481A1 1 0 0 1 16 15H4a1 1 0 0 1-.895-1.447l3.5-7A1 1 0 0 1 7.468 6a.965.965 0 0 1 .9.5l2.775 4.757 1.546-1.887a1 1 0 0 1 1.618.1l2.541 4a1 1 0 0 1 .028 1.011Z"/>
                            </svg>
                            <span class="sr-only">Vorschaubild wird generiert, bitte warten...</span>
                        </div>
                    </div>
                @else
                    <a 
                        class="relative group rounded-lg cursor-pointer h-80 flex-grow overflow-hidden" 
                        href="{{ $image->lightbox['location'] }}"
                        data-pswp-width="{{ $image->lightbox['width'] }}"
                        data-pswp-download="{{ $image->getDownload() }}"
                        data-pswp-height="{{ $image->lightbox['height'] }}"
                        data-cropped="true"
                        data-is-cover="{{ $image->isCover ? 'true' : 'false' }}"
                        data-id="{{ $image->id }}"
                        wire:key="image_{{ $image->id }}"
                        wire:transition
                    >
                        <img class="max-h-full min-w-full align-bottom object-cover"
                         src="{{ $image->getThumbnail() }}" alt="Album image">
                        <div class="opacity-0 group-hover:opacity-40 absolute inset-0 w-full h-full bg-black flex items-center justify-center transition-opacity">
                            <svg class="w-1/2 h-1/2 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
                              <path stroke="currentColor" stroke-width="2" d="M21 12c0 1.2-4.03 6-9 6s-9-4.8-9-6c0-1.2 4.03-6 9-6s9 4.8 9 6Z"/>
                              <path stroke="currentColor" stroke-width="2" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"/>
                            </svg>              
                        </div>
                    </a>
                @endif
            @endforeach
        </div>
    </div>
    <x-drawer name="image-add" >
        <x-slot:title>Neue Bilder zu {{ $album->name }} hinzufügen</x-slot:title>
        <x-slot:content>
            <livewire:drawer.album.addImage :album="$album"></livewire:drawer.album.addImage>
        </x-slot:content>
    </x-drawer>
</div>