<div>
    <p class="text-gray-800 dark:text-gray-200 text-center">
        You have <code>{{ $downloadsLeft }}/{{ config('hstream.free_downloads_count') }}</code> free daily 4k downloads left.
        <br>
        Free 4k downloads will only be available, if enough people are subscribed to patreon!
        <br>
        Patreon subscribers don't have any limits!
    </p>
    <div class="flex flex-wrap justify-around">
        @if ($granted === 0 && !$override)
        <a href="#" wire:click.prevent="generate">
            <button  class="group rounded-md shadow bg-yellow-600 text-white cursor-pointer flex justify-between items-center overflow-hidden transition-all hover:glow m-1 w-[190px] h-[65px]">
                <div class="relative w-12 h-[65px] bg-white bg-opacity-20 text-white flex justify-center items-center transition-all">
                    <svg class="w-4 h-4 transition-all group-hover:-translate-y-1" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 14l-7 7m0 0l-7-7m7 7V3"></path>
                    </svg>
                </div>
                <div class="flex flex-col text-center w-full">
                    <p class="text-lg">Generate download</p>
                </div>
            </button>
        </a>
        @elseif ($granted === 1 || $override)
        @php
            $episode = \App\Models\Episode::where('id', $episodeId)->firstOrFail();
            $download = $interpolated == true ? $episode->getDownloadByType('UHDi') : $episode->getDownloadByType('UHD');

            $now = \Illuminate\Support\Carbon::now();
            $expire = \Illuminate\Support\Facades\Crypt::encryptString($now->addHours(6));
            $file = \Illuminate\Support\Facades\Crypt::encryptString('hentai/'.$download->url);

            $dlpdomains = config('hstream.download_domain_4k');
            $downloadURL = $dlpdomains[array_rand($dlpdomains)].'/download/'.$file.'/'.$expire;
            $fillNumbers = false;
        @endphp

        <livewire:download-button 
            :download-url="$downloadURL" 
            :download-id="$download->id" 
            :download-count="$download->count" 
            :episode-number="$episode->episode" 
            :fill-numbers="$fillNumbers"
            :file-size="$download->getFileSize()">
        @elseif ($granted === 3)
        <p class="text-red-600">
            Daily download limit reached!
        </p>
        @elseif ($granted === 4)
        <p class="text-red-600">
            Download will be available 7 days after release!
        </p>
        @endif
    </div>
</div>
