<!DOCTYPE html>
<html lang="en" class="h-full bg-gray-100 dark:bg-gray-900">
    <head>
        <meta name="format-detection" content="telephone=no">

        <title>Voucher | UniFi Voucher</title>

        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, minimal-ui">

        <meta name="description" content="UniFi Voucher Site is a web-based platform for generating and managing UniFi network guest vouchers">
        <meta name="author" content="Glenn de Haan">

        <meta property="og:title" content="Voucher | UniFi Voucher"/>
        <meta property="og:type" content="website"/>
        <meta property="og:description" content="UniFi Voucher Site is a web-based platform for generating and managing UniFi network guest vouchers"/>

        <link rel="manifest" href="<%= baseUrl %>/manifest.json">
        <link rel="shortcut icon" href="<%= baseUrl %>/images/favicon.ico">
        <link rel="apple-touch-icon" href="<%= baseUrl %>/images/icon/logo_256x256.png">

        <meta name="mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="theme-color" content="#139CDA">

        <link rel="preload" href="<%= baseUrl %>/images/logo.png" as="image">
        <link rel="preload" href="<%= baseUrl %>/dist/style.css" as="style">
        <link href="<%= baseUrl %>/dist/style.css" rel="stylesheet">
    </head>
    <body class="h-full">
        <div>
            <%- include('partials/navigation', {new_voucher_button: true}) %>

            <% if(error) { %>
                <div class="mx-6">
                    <div class="max-w-7xl mx-auto mt-5 rounded-md bg-red-700 p-4">
                        <div class="flex">
                            <div class="shrink-0">
                                <svg class="h-5 w-5 text-white" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
                                    <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.28 7.22a.75.75 0 00-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 101.06 1.06L10 11.06l1.72 1.72a.75.75 0 101.06-1.06L11.06 10l1.72-1.72a.75.75 0 00-1.06-1.06L10 8.94 8.28 7.22z" clip-rule="evenodd" />
                                </svg>
                            </div>
                            <div class="ml-3">
                                <h3 class="text-sm font-medium text-white"><%= error_text %></h3>
                            </div>
                        </div>
                    </div>
                </div>
            <% } %>

            <% if(info) { %>
                <div class="mx-6">
                    <div class="max-w-7xl mx-auto mt-5 rounded-md bg-green-700 p-4">
                        <div class="flex">
                            <div class="shrink-0">
                                <svg class="h-5 w-5 text-white" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
                                    <path fill-rule="evenodd" d="M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16Zm3.857-9.809a.75.75 0 0 0-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 1 0-1.06 1.061l2.5 2.5a.75.75 0 0 0 1.137-.089l4-5.5Z" clip-rule="evenodd" />
                                </svg>
                            </div>
                            <div class="ml-3">
                                <h3 class="text-sm font-medium text-white"><%= info_text %></h3>
                            </div>
                        </div>
                    </div>
                </div>
            <% } %>

            <main class="mx-auto max-w-7xl">
                <header class="flex items-center justify-between border-b border-black/5 dark:border-white/5 px-4 py-4 md:px-6 md:py-6 lg:px-8">
                    <div class="grid">
                        <form id="filter-sort-form" action="<%= baseUrl %>/vouchers" method="get">
                            <div class="flex flex-col md:flex-row md:items-end md:space-x-4 space-y-2 md:space-y-0">
                                <div class="flex flex-col">
                                    <label for="status" class="text-xs text-gray-900 dark:text-white mb-1">Status</label>
                                    <select id="status" name="status" class="rounded-md border-0 py-1.5 pl-3 pr-10 text-gray-900 dark:text-white dark:bg-white/5 ring-1 ring-inset ring-gray-300 dark:ring-white/10 focus:ring-2 focus:ring-sky-600 sm:text-sm sm:leading-6 **:text-black" aria-label="Filter by status">
                                        <option value="all"<%= filters.status === 'all' ? ' selected' : '' %>>All</option>
                                        <option value="available"<%= filters.status === 'available' ? ' selected' : '' %>>Available</option>
                                        <option value="in-use"<%= filters.status === 'in-use' ? ' selected' : '' %>>In Use</option>
                                        <option value="expired"<%= filters.status === 'expired' ? ' selected' : '' %>>Expired</option>
                                    </select>
                                </div>
                                <div class="flex flex-col">
                                    <label for="quota" class="text-xs text-gray-900 dark:text-white mb-1">Quota</label>
                                    <select id="quota" name="quota" class="rounded-md border-0 py-1.5 pl-3 pr-10 text-gray-900 dark:text-white dark:bg-white/5 ring-1 ring-inset ring-gray-300 dark:ring-white/10 focus:ring-2 focus:ring-sky-600 sm:text-sm sm:leading-6 **:text-black" aria-label="Filter by quota">
                                        <option value="all"<%= filters.quota === 'all' ? ' selected' : '' %>>All</option>
                                        <option value="multi-use"<%= filters.quota === 'multi-use' ? ' selected' : '' %>>Multi-use</option>
                                        <option value="single-use"<%= filters.quota === 'single-use' ? ' selected' : '' %>>Single-use</option>
                                    </select>
                                </div>
                                <div class="flex flex-col">
                                    <label for="sort" class="text-xs text-gray-900 dark:text-white mb-1">Sort</label>
                                    <select id="sort" name="sort" class="rounded-md border-0 py-1.5 pl-3 pr-10 text-gray-900 dark:text-white dark:bg-white/5 ring-1 ring-inset ring-gray-300 dark:ring-white/10 focus:ring-2 focus:ring-sky-600 sm:text-sm sm:leading-6 **:text-black" aria-label="Sort by">
                                        <option value="date"<%= sort === 'date' ? ' selected' : '' %>>Date</option>
                                        <option value="code"<%= sort === 'code' ? ' selected' : '' %>>Code</option>
                                        <option value="note"<%= sort === 'note' ? ' selected' : '' %>>Notes</option>
                                        <option value="duration"<%= sort === 'duration' ? ' selected' : '' %>>Duration</option>
                                        <option value="status"<%= sort === 'status' ? ' selected' : '' %>>Status</option>
                                    </select>
                                </div>
                            </div>
                        </form>
                    </div>

                    <div class="grid md:grid-cols-2 self-end">
                        <div class="grid mb-2 md:mb-0 md:mr-4">
                            <span class="mb-1 text-xs text-gray-900 dark:text-white<%= !printer_enabled ? ' hidden' : '' %>">
                                &nbsp;
                            </span>
                            <button id="bulk-print" class="<%= !printer_enabled ? 'hidden' : 'inline-flex' %> w-fit justify-self-end relative items-center gap-x-1.5 rounded-md bg-sky-700 px-3 py-2 text-sm font-semibold text-white shadow-xs hover:bg-sky-600 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-sky-700">
                                <svg class="-ml-0.5 h-5 w-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true">
                                    <path stroke-linecap="round" stroke-linejoin="round" d="M6.72 13.829c-.24.03-.48.062-.72.096m.72-.096a42.415 42.415 0 0 1 10.56 0m-10.56 0L6.34 18m10.94-4.171c.24.03.48.062.72.096m-.72-.096L17.66 18m0 0 .229 2.523a1.125 1.125 0 0 1-1.12 1.227H7.231c-.662 0-1.18-.568-1.12-1.227L6.34 18m11.318 0h1.091A2.25 2.25 0 0 0 21 15.75V9.456c0-1.081-.768-2.015-1.837-2.175a48.055 48.055 0 0 0-1.913-.247M6.34 18H5.25A2.25 2.25 0 0 1 3 15.75V9.456c0-1.081.768-2.015 1.837-2.175a48.041 48.041 0 0 1 1.913-.247m10.5 0a48.536 48.536 0 0 0-10.5 0m10.5 0V3.375c0-.621-.504-1.125-1.125-1.125h-8.25c-.621 0-1.125.504-1.125 1.125v3.659M18 10.5h.008v.008H18V10.5Zm-3 0h.008v.008H15V10.5Z" />
                                </svg>
                                Bulk Print
                            </button>
                        </div>
                        <div class="grid">
                            <span class="mb-1 text-xs text-gray-900 dark:text-white">
                                Last Sync: <%= new Intl.DateTimeFormat('en-GB', {day: "numeric", month: "numeric", hour: "numeric", minute: "numeric", hour12: false}).format(new Date(updated)) %>
                            </span>
                            <a href="<%= baseUrl %>/vouchers?refresh=true" id="reload-vouchers" type="button" class="w-fit justify-self-end relative inline-flex items-center gap-x-1.5 rounded-md bg-sky-700 px-3 py-2 text-sm font-semibold text-white shadow-xs hover:bg-sky-600 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-sky-700">
                                <svg class="-ml-0.5 h-5 w-5" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
                                    <path fill-rule="evenodd" d="M15.312 11.424a5.5 5.5 0 0 1-9.201 2.466l-.312-.311h2.433a.75.75 0 0 0 0-1.5H3.989a.75.75 0 0 0-.75.75v4.242a.75.75 0 0 0 1.5 0v-2.43l.31.31a7 7 0 0 0 11.712-3.138.75.75 0 0 0-1.449-.39Zm1.23-3.723a.75.75 0 0 0 .219-.53V2.929a.75.75 0 0 0-1.5 0V5.36l-.31-.31A7 7 0 0 0 3.239 8.188a.75.75 0 1 0 1.448.389A5.5 5.5 0 0 1 13.89 6.11l.311.31h-2.432a.75.75 0 0 0 0 1.5h4.243a.75.75 0 0 0 .53-.219Z" clip-rule="evenodd" />
                                </svg>
                                Sync Vouchers
                            </a>
                        </div>
                    </div>
                </header>

                <% if(vouchers.length < 1) { %>
                    <div class="text-center mt-10">
                        <img class="mx-auto h-12 w-auto" width="48" height="48" alt="UniFi Voucher Site Logo" src="<%= baseUrl %>/images/logo.png">
                        <h3 class="mt-2 text-sm font-semibold text-gray-900 dark:text-white">No vouchers</h3>
                        <p class="mt-1 text-sm text-gray-600 dark:text-gray-400">Get started by creating a new voucher.</p>
                        <div class="mt-6">
                            <button id="create-button-info" type="button" class="inline-flex items-center rounded-md bg-sky-700 px-3 py-2 text-sm font-semibold text-white shadow-xs hover:bg-sky-600 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-sky-700">
                                <svg class="-ml-0.5 mr-1.5 h-5 w-5" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
                                    <path d="M10.75 4.75a.75.75 0 00-1.5 0v4.5h-4.5a.75.75 0 000 1.5h4.5v4.5a.75.75 0 001.5 0v-4.5h4.5a.75.75 0 000-1.5h-4.5v-4.5z" />
                                </svg>
                                New Voucher
                            </button>
                        </div>
                    </div>
                <% } %>

                <ul role="list" class="divide-y divide-black/5 dark:divide-white/5">
                    <% vouchers.forEach((voucher) => { %>
                        <li class="relative flex items-center space-x-4 px-4 py-4 sm:px-6 lg:px-8 hover:bg-gray-200 dark:hover:bg-gray-800 cursor-pointer">
                            <div class="voucher min-w-0 flex-auto" data-id="<%= voucher.id %>">
                                <div class="flex items-center gap-x-3">
                                    <h2 class="min-w-0 text-sm font-semibold leading-6 text-gray-900 dark:text-white">
                                        <div class="flex gap-x-2">
                                            <span class="tabular-nums pointer-events-none no-underline text-inherit"><%= voucher.code.slice(0, 5) %>-<%= voucher.code.slice(5) %></span>
                                            <% if (voucher.expired) { %>
                                                <div class="rounded-full w-fit py-1 px-2 text-xs font-medium ring-1 ring-inset bg-red-50 text-red-800 ring-red-600/20 dark:text-red-400 dark:bg-red-400/10 dark:ring-red-400/20">
                                                    Expired
                                                </div>
                                            <% } else {%>
                                                <% if(voucher.authorizedGuestCount > 0) { %>
                                                    <div class="rounded-full flex-none py-1 px-2 text-xs font-medium ring-1 ring-inset bg-yellow-50 text-yellow-800 ring-yellow-600/20 dark:text-yellow-400 dark:bg-yellow-400/10 dark:ring-yellow-400/20">
                                                        In Use
                                                    </div>
                                                <% } else { %>
                                                    <div class="rounded-full flex-none py-1 px-2 text-xs font-medium ring-1 ring-inset bg-green-50 text-green-700 ring-green-600/20 dark:text-green-400 dark:bg-green-400/10 dark:ring-green-400/20">
                                                        Available
                                                    </div>
                                                <% } %>
                                            <% } %>
                                            <% if (voucher.name && notesConvert(voucher.name).note) { %>
                                                <div class="hidden sm:block rounded-md flex-none py-1 px-2 text-xs font-medium ring-1 ring-inset bg-gray-50 text-gray-800 ring-gray-600/20 dark:text-gray-400 dark:bg-gray-400/10 dark:ring-gray-400/20">
                                                    <%= notesConvert(voucher.name).note %>
                                                </div>
                                            <% } %>
                                        </div>
                                    </h2>
                                </div>
                                <div class="mt-2 flex items-center gap-x-2.5 text-xs leading-5 text-gray-600 dark:text-gray-400">
                                    <p class="whitespace-nowrap"><%= !voucher.authorizedGuestLimit ? 'Multi-use (Unlimited)' : voucher.authorizedGuestLimit === 1 ? 'Single-use' : `Multi-use (${voucher.authorizedGuestLimit}x)` %></p>
                                    <svg viewBox="0 0 2 2" class="h-0.5 w-0.5 flex-none fill-gray-500 dark:fill-gray-300">
                                        <circle cx="1" cy="1" r="1" />
                                    </svg>
                                    <p class="whitespace-nowrap"><%= timeConvert(voucher.timeLimitMinutes) %></p>
                                    <% if(voucher.dataUsageLimitMBytes) { %>
                                        <svg viewBox="0 0 2 2" class="h-0.5 w-0.5 flex-none fill-gray-500 dark:fill-gray-300">
                                            <circle cx="1" cy="1" r="1" />
                                        </svg>
                                        <p class="truncate"><%= bytesConvert(voucher.dataUsageLimitMBytes, 2) %> Data Limit</p>
                                    <% } %>
                                    <% if(voucher.rxRateLimitKbps) { %>
                                        <svg viewBox="0 0 2 2" class="h-0.5 w-0.5 flex-none fill-gray-500 dark:fill-gray-300">
                                            <circle cx="1" cy="1" r="1" />
                                        </svg>
                                        <p class="truncate"><%= bytesConvert(voucher.rxRateLimitKbps, 1, true) %> Download Limit</p>
                                    <% } %>
                                    <% if(voucher.txRateLimitKbps) { %>
                                        <svg viewBox="0 0 2 2" class="h-0.5 w-0.5 flex-none fill-gray-500 dark:fill-gray-300">
                                            <circle cx="1" cy="1" r="1" />
                                        </svg>
                                        <p class="truncate"><%= bytesConvert(voucher.txRateLimitKbps, 1, true) %> Upload Limit</p>
                                    <% } %>
                                </div>
                            </div>
                            <button type="button" data-code="<%= voucher.code.slice(0, 5) %>-<%= voucher.code.slice(5) %>" class="share-button relative rounded-full p-1 text-gray-500 dark:text-gray-400 hover:text-black dark:hover:text-white">
                                <span class="absolute -inset-1.5"></span>
                                <span class="sr-only">Copy Voucher Code to Clipboard</span>
                                <svg class="h-5 w-5" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
                                    <path fill-rule="evenodd" d="M17.663 3.118c.225.015.45.032.673.05C19.876 3.298 21 4.604 21 6.109v9.642a3 3 0 0 1-3 3V16.5c0-5.922-4.576-10.775-10.384-11.217.324-1.132 1.3-2.01 2.548-2.114.224-.019.448-.036.673-.051A3 3 0 0 1 13.5 1.5H15a3 3 0 0 1 2.663 1.618ZM12 4.5A1.5 1.5 0 0 1 13.5 3H15a1.5 1.5 0 0 1 1.5 1.5H12Z" clip-rule="evenodd" />
                                    <path d="M3 8.625c0-1.036.84-1.875 1.875-1.875h.375A3.75 3.75 0 0 1 9 10.5v1.875c0 1.036.84 1.875 1.875 1.875h1.875A3.75 3.75 0 0 1 16.5 18v2.625c0 1.035-.84 1.875-1.875 1.875h-9.75A1.875 1.875 0 0 1 3 20.625v-12Z" />
                                    <path d="M10.5 10.5a5.23 5.23 0 0 0-1.279-3.434 9.768 9.768 0 0 1 6.963 6.963 5.23 5.23 0 0 0-3.434-1.279h-1.875a.375.375 0 0 1-.375-.375V10.5Z" />
                                </svg>
                            </button>
                            <button type="button" data-id="<%= voucher.id %>" class="voucher-email relative rounded-full p-1 text-gray-500 dark:text-gray-400 hover:text-black dark:hover:text-white<%= !email_enabled ? ' hidden' : '' %>">
                                <span class="absolute -inset-1.5"></span>
                                <span class="sr-only">Email Voucher Code</span>
                                <svg class="h-5 w-5" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
                                    <path d="M1.5 8.67v8.58a3 3 0 0 0 3 3h15a3 3 0 0 0 3-3V8.67l-8.928 5.493a3 3 0 0 1-3.144 0L1.5 8.67Z" />
                                    <path d="M22.5 6.908V6.75a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3v.158l9.714 5.978a1.5 1.5 0 0 0 1.572 0L22.5 6.908Z" />
                                </svg>
                            </button>
                            <button type="button" data-id="<%= voucher.id %>" class="voucher-print relative rounded-full p-1 text-gray-500 dark:text-gray-400 hover:text-black dark:hover:text-white<%= !printer_enabled ? ' hidden' : '' %>">
                                <span class="absolute -inset-1.5"></span>
                                <span class="sr-only">Print Voucher Code</span>
                                <svg class="h-5 w-5" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
                                    <path fill-rule="evenodd" d="M7.875 1.5C6.839 1.5 6 2.34 6 3.375v2.99c-.426.053-.851.11-1.274.174-1.454.218-2.476 1.483-2.476 2.917v6.294a3 3 0 0 0 3 3h.27l-.155 1.705A1.875 1.875 0 0 0 7.232 22.5h9.536a1.875 1.875 0 0 0 1.867-2.045l-.155-1.705h.27a3 3 0 0 0 3-3V9.456c0-1.434-1.022-2.7-2.476-2.917A48.716 48.716 0 0 0 18 6.366V3.375c0-1.036-.84-1.875-1.875-1.875h-8.25ZM16.5 6.205v-2.83A.375.375 0 0 0 16.125 3h-8.25a.375.375 0 0 0-.375.375v2.83a49.353 49.353 0 0 1 9 0Zm-.217 8.265c.178.018.317.16.333.337l.526 5.784a.375.375 0 0 1-.374.409H7.232a.375.375 0 0 1-.374-.409l.526-5.784a.373.373 0 0 1 .333-.337 41.741 41.741 0 0 1 8.566 0Zm.967-3.97a.75.75 0 0 1 .75-.75h.008a.75.75 0 0 1 .75.75v.008a.75.75 0 0 1-.75.75H18a.75.75 0 0 1-.75-.75V10.5ZM15 9.75a.75.75 0 0 0-.75.75v.008c0 .414.336.75.75.75h.008a.75.75 0 0 0 .75-.75V10.5a.75.75 0 0 0-.75-.75H15Z" clip-rule="evenodd" />
                                </svg>
                            </button>
                            <a href="<%= baseUrl %>/voucher/<%= voucher.id %>/remove" type="button" class="remove-button relative rounded-full p-1 text-red-500 dark:text-red-400 hover:text-black dark:hover:text-white">
                                <span class="absolute -inset-1.5"></span>
                                <span class="sr-only">Remove Voucher Code</span>
                                <svg class="h-5 w-5" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
                                    <path fill-rule="evenodd" d="M16.5 4.478v.227a48.816 48.816 0 0 1 3.878.512.75.75 0 1 1-.256 1.478l-.209-.035-1.005 13.07a3 3 0 0 1-2.991 2.77H8.084a3 3 0 0 1-2.991-2.77L4.087 6.66l-.209.035a.75.75 0 0 1-.256-1.478A48.567 48.567 0 0 1 7.5 4.705v-.227c0-1.564 1.213-2.9 2.816-2.951a52.662 52.662 0 0 1 3.369 0c1.603.051 2.815 1.387 2.815 2.951Zm-6.136-1.452a51.196 51.196 0 0 1 3.273 0C14.39 3.05 15 3.684 15 4.478v.113a49.488 49.488 0 0 0-6 0v-.113c0-.794.609-1.428 1.364-1.452Zm-.355 5.945a.75.75 0 1 0-1.5.058l.347 9a.75.75 0 1 0 1.499-.058l-.346-9Zm5.48.058a.75.75 0 1 0-1.498-.058l-.347 9a.75.75 0 0 0 1.5.058l.345-9Z" clip-rule="evenodd" />
                                </svg>
                            </a>
                        </li>
                    <% }); %>
                </ul>
            </main>
        </div>

        <div id="detail-dialog"></div>
        <div id="email-dialog"></div>
        <div id="print-dialog"></div>
        <div id="bulk-print-dialog"></div>

        <div id="create-dialog" class="hidden relative z-40" role="dialog" aria-modal="true">
            <div id="create-dialog-overlay" class="fixed inset-0 bg-gray-500/75"></div>

            <div class="fixed overflow-hidden">
                <div class="absolute inset-0 overflow-hidden">
                    <div class="pointer-events-none fixed inset-y-0 right-0 flex max-w-full pl-10 sm:pl-16">
                        <div class="pointer-events-auto w-screen max-w-md">
                            <form id="voucher-form" class="flex h-full flex-col divide-y divide-black/5 dark:divide-white/5 bg-white dark:bg-gray-900 shadow-xl" action="<%= baseUrl %>/voucher" method="post" enctype="multipart/form-data">
                                <div class="h-0 flex-1 overflow-y-auto">
                                    <div class="bg-sky-700 px-4 py-6 sm:px-6">
                                        <div class="flex items-center justify-between">
                                            <h2 class="text-base font-semibold leading-6 text-white" id="slide-over-title">Create Voucher</h2>
                                        </div>
                                        <div class="mt-1">
                                            <p class="text-sm text-sky-100">Get started by filling in the information below to create your new voucher.</p>
                                        </div>
                                    </div>
                                    <div class="flex flex-1 flex-col justify-between">
                                        <div class="divide-y divide-black/5 dark:divide-white/5 px-4 sm:px-6">
                                            <div class="space-y-6 pb-5 pt-6">
                                                <div>
                                                    <label for="voucher-type" class="block text-sm font-medium leading-6 text-gray-900 dark:text-white">Preset Voucher Type</label>
                                                    <div class="mt-2">
                                                        <select id="voucher-type" name="voucher-type" class="mt-2 block w-full rounded-md border-0 py-1.5 pl-3 pr-10 text-gray-900 dark:text-white dark:bg-white/5 ring-1 ring-inset ring-gray-300 dark:ring-white/10 focus:ring-2 focus:ring-sky-600 sm:text-sm sm:leading-6 **:text-black">
                                                            <% voucher_types.forEach((type) => { %>
                                                                <option value="<%= type.raw %>"><%= timeConvert(type.expiration) %>, <%= type.usage === '1' ? 'single-use' : type.usage === '0' ? 'multi-use (unlimited)' : `multi-use (${type.usage}x)` %><%= typeof type.upload === "undefined" && typeof type.download === "undefined" && typeof type.megabytes === "undefined" ? ', no limits' : '' %><%= typeof type.upload !== "undefined" ? `, upload bandwidth limit: ${bytesConvert(type.upload, 1, true)}` : '' %><%= typeof type.download !== "undefined" ? `, download bandwidth limit: ${bytesConvert(type.download, 1, true)}` : '' %><%= typeof type.megabytes !== "undefined" ? `, quota limit: ${bytesConvert(type.megabytes, 2)}` : '' %></option>
                                                            <% }); %>
                                                            <% if(voucher_custom) { %>
                                                                <option value="custom">Custom</option>
                                                            <% } %>
                                                        </select>
                                                    </div>
                                                </div>
                                                <div>
                                                    <label for="voucher-amount" class="block text-sm font-medium leading-6 text-gray-900 dark:text-white">Amount</label>
                                                    <div class="mt-2">
                                                        <input type="number" min="1" step="1" value="1" id="voucher-amount" name="voucher-amount" required class="mt-2 block w-full rounded-md border-0 py-1.5 text-gray-900 dark:text-white dark:bg-white/5 ring-1 ring-inset ring-gray-300 dark:ring-white/10 focus:ring-2 focus:ring-sky-600 sm:text-sm sm:leading-6">
                                                    </div>
                                                </div>
                                                <div>
                                                    <label for="voucher-note" class="block text-sm font-medium leading-6 text-gray-900 dark:text-white">Note <em class="text-xs">(Optional)</em></label>
                                                    <div class="mt-2">
                                                        <input type="text" id="voucher-note" name="voucher-note" class="mt-2 block w-full rounded-md border-0 py-1.5 text-gray-900 dark:text-white dark:bg-white/5 ring-1 ring-inset ring-gray-300 dark:ring-white/10 focus:ring-2 focus:ring-sky-600 sm:text-sm sm:leading-6">
                                                    </div>
                                                </div>
                                                <div class="custom-voucher-field hidden border-t border-black/5 dark:border-white/25">
                                                    <label for="voucher-duration" class="mt-4 block text-sm font-medium leading-6 text-gray-900 dark:text-white">Duration</label>
                                                    <div class="mt-2 grid grid-cols-2 gap-2">
                                                        <input type="number" min="1" step="1" value="8" id="voucher-duration" name="voucher-duration" required class="block w-full rounded-md border-0 py-1.5 text-gray-900 dark:text-white dark:bg-white/5 ring-1 ring-inset ring-gray-300 dark:ring-white/10 focus:ring-2 focus:ring-sky-600 sm:text-sm sm:leading-6">
                                                        <select id="voucher-duration-type" name="voucher-duration-type" class="block w-full rounded-md border-0 py-1.5 pl-3 pr-10 text-gray-900 dark:text-white dark:bg-white/5 ring-1 ring-inset ring-gray-300 dark:ring-white/10 focus:ring-2 focus:ring-sky-600 sm:text-sm sm:leading-6 **:text-black">
                                                            <option value="minute">Minute(s)</option>
                                                            <option value="hour" selected>Hour(s)</option>
                                                            <option value="day">Day(s)</option>
                                                        </select>
                                                    </div>
                                                </div>
                                                <div class="custom-voucher-field hidden">
                                                    <label for="voucher-usage" class="block text-sm font-medium leading-6 text-gray-900 dark:text-white">Voucher Usage</label>
                                                    <div class="mt-2">
                                                        <select id="voucher-usage" name="voucher-usage" class="mt-2 block w-full rounded-md border-0 py-1.5 pl-3 pr-10 text-gray-900 dark:text-white dark:bg-white/5 ring-1 ring-inset ring-gray-300 dark:ring-white/10 focus:ring-2 focus:ring-sky-600 sm:text-sm sm:leading-6 **:text-black">
                                                            <option value="0">Multi-use (Unlimited)</option>
                                                            <option value="-1">Multi-use (Limited/Quota)</option>
                                                            <option value="1">Single-use</option>
                                                        </select>
                                                    </div>
                                                </div>
                                                <div class="custom-voucher-field-quota hidden">
                                                    <label for="voucher-quota" class="block text-sm font-medium leading-6 text-gray-900 dark:text-white">Voucher Limit/Quota</label>
                                                    <div class="mt-2">
                                                        <input type="number" min="2" step="1" value="2" id="voucher-quota" name="voucher-quota" class="mt-2 block w-full rounded-md border-0 py-1.5 text-gray-900 dark:text-white dark:bg-white/5 ring-1 ring-inset ring-gray-300 dark:ring-white/10 focus:ring-2 focus:ring-sky-600 sm:text-sm sm:leading-6">
                                                    </div>
                                                </div>
                                                <div class="custom-voucher-field hidden">
                                                    <label for="voucher-data-limit" class="block text-sm font-medium leading-6 text-gray-900 dark:text-white">Data Limit (in MB)</label>
                                                    <div class="mt-2">
                                                        <input type="number" step="1" id="voucher-data-limit" name="voucher-data-limit" class="mt-2 block w-full rounded-md border-0 py-1.5 text-gray-900 dark:text-white dark:bg-white/5 ring-1 ring-inset ring-gray-300 dark:ring-white/10 focus:ring-2 focus:ring-sky-600 sm:text-sm sm:leading-6">
                                                    </div>
                                                </div>
                                                <div class="custom-voucher-field hidden">
                                                    <label for="voucher-download-limit" class="block text-sm font-medium leading-6 text-gray-900 dark:text-white">Download Bandwidth Limit (in kb/s)</label>
                                                    <div class="mt-2">
                                                        <input type="number" step="1" id="voucher-download-limit" name="voucher-download-limit" class="mt-2 block w-full rounded-md border-0 py-1.5 text-gray-900 dark:text-white dark:bg-white/5 ring-1 ring-inset ring-gray-300 dark:ring-white/10 focus:ring-2 focus:ring-sky-600 sm:text-sm sm:leading-6">
                                                    </div>
                                                </div>
                                                <div class="custom-voucher-field hidden">
                                                    <label for="voucher-upload-limit" class="block text-sm font-medium leading-6 text-gray-900 dark:text-white">Upload Bandwidth Limit (in kb/s)</label>
                                                    <div class="mt-2">
                                                        <input type="number" step="1" id="voucher-upload-limit" name="voucher-upload-limit" class="mt-2 block w-full rounded-md border-0 py-1.5 text-gray-900 dark:text-white dark:bg-white/5 ring-1 ring-inset ring-gray-300 dark:ring-white/10 focus:ring-2 focus:ring-sky-600 sm:text-sm sm:leading-6">
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="flex shrink-0 justify-end px-4 py-4">
                                    <button id="cancel" type="button" class="rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-xs ring-1 ring-inset ring-gray-300 hover:bg-gray-50">Cancel</button>
                                    <button type="submit" class="ml-4 inline-flex justify-center rounded-md bg-sky-700 px-3 py-2 text-sm font-semibold text-white shadow-xs hover:bg-sky-600 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-sky-700">Create</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div id="spinner-create" style="display: none;" class="fixed top-0 left-0 right-0 bottom-0 w-full h-screen z-50 overflow-hidden bg-gray-900 opacity-90 flex flex-col items-center justify-center">
            <div class="mb-4">
                <svg class="w-14 h-14 text-gray-200 animate-spin dark:text-gray-600 fill-cyan-400" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
                    <path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
                    <path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
                </svg>
            </div>
            <h2 class="text-center text-white text-xl font-semibold">Generating Voucher...</h2>
            <p class="w-1/2 text-center text-white">This may take a few seconds, please don't close this page.</p>
        </div>

        <div id="spinner-remove" style="display: none;" class="fixed top-0 left-0 right-0 bottom-0 w-full h-screen z-50 overflow-hidden bg-gray-900 opacity-90 flex flex-col items-center justify-center">
            <div class="mb-4">
                <svg class="w-14 h-14 text-gray-200 animate-spin dark:text-gray-600 fill-cyan-400" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
                    <path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
                    <path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
                </svg>
            </div>
            <h2 class="text-center text-white text-xl font-semibold">Removing Voucher...</h2>
            <p class="w-1/2 text-center text-white">This may take a few seconds, please don't close this page.</p>
        </div>

        <div id="spinner-list" style="display: none;" class="fixed top-0 left-0 right-0 bottom-0 w-full h-screen z-50 overflow-hidden bg-gray-900 opacity-90 flex flex-col items-center justify-center">
            <div class="mb-4">
                <svg class="w-14 h-14 text-gray-200 animate-spin dark:text-gray-600 fill-cyan-400" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
                    <path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
                    <path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
                </svg>
            </div>
            <h2 class="text-center text-white text-xl font-semibold">Syncing Vouchers...</h2>
            <p class="w-1/2 text-center text-white">This may take a few seconds, please don't close this page.</p>
        </div>

        <div id="spinner-email" style="display: none;" class="fixed top-0 left-0 right-0 bottom-0 w-full h-screen z-50 overflow-hidden bg-gray-900 opacity-90 flex flex-col items-center justify-center">
            <div class="mb-4">
                <svg class="w-14 h-14 text-gray-200 animate-spin dark:text-gray-600 fill-cyan-400" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
                    <path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
                    <path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
                </svg>
            </div>
            <h2 class="text-center text-white text-xl font-semibold">Sending Voucher...</h2>
            <p class="w-1/2 text-center text-white">This may take a few seconds, please don't close this page.</p>
        </div>

        <div aria-live="assertive" class="z-40 pointer-events-none fixed inset-0 flex items-end px-4 py-6">
            <div id="copy-notification" style="display: none;" class="flex w-full flex-col items-center space-y-4">
                <div class="pointer-events-auto w-full max-w-sm overflow-hidden rounded-lg bg-white dark:bg-gray-800 shadow-lg ring-1 ring-black/5">
                    <div class="p-4">
                        <div class="flex items-start">
                            <div class="shrink-0">
                                <svg class="h-6 w-6 text-green-400" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true">
                                    <path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
                                </svg>
                            </div>
                            <div class="ml-3 w-0 flex-1 pt-0.5">
                                <p class="text-sm font-medium text-gray-900 dark:text-white">Copied Code!</p>
                                <p class="mt-1 text-sm text-gray-600 dark:text-gray-400">The voucher code has been copied to the clipboard.</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <script type="application/javascript">
            if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
                document.querySelector('html').setAttribute('style', 'color-scheme: dark;');
            }

            window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
                const newColorScheme = event.matches ? "dark" : "light";

                if(newColorScheme === 'light') {
                    document.querySelector('html').removeAttribute('style');
                } else {
                    document.querySelector('html').setAttribute('style', 'color-scheme: dark;');
                }
            });
        </script>
        <script type="application/javascript">
            const createDialog = document.querySelector('#create-dialog');
            const createDialogOverlay = document.querySelector('#create-dialog-overlay');
            const detailDialog = document.querySelector('#detail-dialog');
            const emailDialog = document.querySelector('#email-dialog');
            const printDialog = document.querySelector('#print-dialog');
            const bulkPrintDialog = document.querySelector('#bulk-print-dialog');
            const createForm = document.querySelector('#voucher-form');
            const voucherTypeField = document.querySelector('#voucher-type');
            const voucherUsageField = document.querySelector('#voucher-usage');
            const customVoucherFields = document.querySelectorAll('.custom-voucher-field');
            const customVoucherFieldQuota = document.querySelectorAll('.custom-voucher-field-quota');
            const createButtonHeader = document.querySelector('#create-button-header');
            const createButtonInfo = document.querySelector('#create-button-info');
            const cancelButton = document.querySelector('#cancel');
            const reloadButton = document.querySelector('#reload-vouchers');
            const shareButtons = document.querySelectorAll('.share-button');
            const removeButtons = document.querySelectorAll('.remove-button');
            const spinnerCreate = document.querySelector('#spinner-create');
            const spinnerRemove = document.querySelector('#spinner-remove');
            const spinnerList = document.querySelector('#spinner-list');
            const spinnerEmail = document.querySelector('#spinner-email');
            const copyNotification = document.querySelector('#copy-notification');
            const vouchers = document.querySelectorAll('.voucher');
            const vouchersEmail = document.querySelectorAll('.voucher-email');
            const vouchersPrint = document.querySelectorAll('.voucher-print');
            const bulkPrint = document.querySelector('#bulk-print');
            const filterSortForm = document.querySelector('#filter-sort-form');
            const statusFilter = document.querySelector('#status');
            const quotaFilter = document.querySelector('#quota');
            const sort = document.querySelector('#sort');

            const clearDetailDialog = () => {
                document.querySelector('#close').removeEventListener('click', clearDetailDialog);
                document.querySelector('#overlay').removeEventListener('click', clearDetailDialog);
                detailDialog.innerHTML = '';
            };

            const clearEmailDialog = () => {
                document.querySelector('#email-form').removeEventListener('submit', emailSpinner);
                document.querySelector('#close').removeEventListener('click', clearEmailDialog);
                document.querySelector('#overlay').removeEventListener('click', clearEmailDialog);
                emailDialog.innerHTML = '';
            };

            const clearPrintDialog = () => {
                document.querySelector('#close').removeEventListener('click', clearPrintDialog);
                document.querySelector('#overlay').removeEventListener('click', clearPrintDialog);
                printDialog.innerHTML = '';
            };

            const clearBulkPrintDialog = () => {
                document.querySelector('#close').removeEventListener('click', clearBulkPrintDialog);
                document.querySelector('#overlay').removeEventListener('click', clearBulkPrintDialog);
                bulkPrintDialog.innerHTML = '';
            };

            const emailSpinner = () => {
                spinnerEmail.style.display = '';
            };

            createButtonHeader.addEventListener('click', () => {
                createDialog.classList.remove('hidden');
            });
            if(createButtonInfo) {
                createButtonInfo.addEventListener('click', () => {
                    createDialog.classList.remove('hidden');
                });
            }
            createDialogOverlay.addEventListener('click', () => {
                createDialog.classList.add('hidden');
            });
            cancelButton.addEventListener('click', () => {
                createDialog.classList.add('hidden');
            });
            reloadButton.addEventListener('click', () => {
                spinnerList.style.display = '';
            });
            createForm.addEventListener('submit', () => {
                spinnerCreate.style.display = '';
            });
            shareButtons.forEach((el) => {
                el.addEventListener('click', async () => {
                    try {
                        await navigator.clipboard.writeText(el.dataset.code);
                        copyNotification.style.display = '';

                        setTimeout(() => {
                            copyNotification.style.display = 'none';
                        }, 5000);
                    } catch (error) {
                        console.error(error.message);
                    }
                });
            });
            removeButtons.forEach((el) => {
                el.addEventListener('click', async () => {
                    spinnerRemove.style.display = '';
                });
            });
            voucherTypeField.addEventListener('change', () => {
                if(voucherTypeField.value === 'custom') {
                    customVoucherFields.forEach((el) => {
                        el.classList.remove('hidden');
                    });
                } else {
                    customVoucherFields.forEach((el) => {
                        el.classList.add('hidden');
                    });
                }
            });
            voucherUsageField.addEventListener('change', () => {
                if(voucherUsageField.value === '-1') {
                    customVoucherFieldQuota.forEach((el) => {
                        el.classList.remove('hidden');
                    });
                } else {
                    customVoucherFieldQuota.forEach((el) => {
                        el.classList.add('hidden');
                    });
                }
            });
            vouchers.forEach((el) => {
                el.addEventListener('click', async () => {
                    const htmlRes = await fetch(`<%= baseUrl %>/voucher/${el.dataset.id}`);

                    if(htmlRes.status === 200 && !htmlRes.redirected) {
                        detailDialog.innerHTML = await htmlRes.text();
                        document.querySelector('#close').addEventListener('click', clearDetailDialog);
                        document.querySelector('#overlay').addEventListener('click', clearDetailDialog);
                    } else {
                        window.location.reload();
                    }
                });
            });
            vouchersEmail.forEach((el) => {
                el.addEventListener('click', async () => {
                    const htmlRes = await fetch(`<%= baseUrl %>/voucher/${el.dataset.id}/email`);

                    if(htmlRes.status === 200 && !htmlRes.redirected) {
                        emailDialog.innerHTML = await htmlRes.text();
                        document.querySelector('#close').addEventListener('click', clearEmailDialog);
                        document.querySelector('#overlay').addEventListener('click', clearEmailDialog);
                        document.querySelector('#email-form').addEventListener('submit', emailSpinner);
                    } else {
                        window.location.reload();
                    }
                });
            });
            vouchersPrint.forEach((el) => {
                el.addEventListener('click', async () => {
                    const htmlRes = await fetch(`<%= baseUrl %>/voucher/${el.dataset.id}/print`);

                    if(htmlRes.status === 200 && !htmlRes.redirected) {
                        printDialog.innerHTML = await htmlRes.text();
                        document.querySelector('#close').addEventListener('click', clearPrintDialog);
                        document.querySelector('#overlay').addEventListener('click', clearPrintDialog);
                    } else {
                        window.location.reload();
                    }
                });
            });
            bulkPrint.addEventListener('click', async () => {
                const htmlRes = await fetch(`<%= baseUrl %>/bulk/print`);

                if(htmlRes.status === 200 && !htmlRes.redirected) {
                    bulkPrintDialog.innerHTML = await htmlRes.text();
                    document.querySelector('#close').addEventListener('click', clearBulkPrintDialog);
                    document.querySelector('#overlay').addEventListener('click', clearBulkPrintDialog);
                } else {
                    window.location.reload();
                }
            });
            statusFilter.addEventListener('change', () => {
                filterSortForm.submit();
            });
            quotaFilter.addEventListener('change', () => {
                filterSortForm.submit();
            });
            sort.addEventListener('change', () => {
                filterSortForm.submit();
            });
        </script>
    </body>
</html>
