<script lang="ts">
    import Modal from '$lib/components/Modal.svelte';

    let {
        open,
        total,
        busy,
        onCancel,
        onConfirm
    }: {
        open: boolean;
        total: number;
        busy: boolean;
        onCancel: () => void;
        onConfirm: () => void;
    } = $props();
</script>

<Modal {open} title="Requeue all dead jobs" onClose={onCancel} size="sm">
    {#snippet children()}
        <p>
            This will flip every dead job ({total}) back to <code>pending</code>.
            Chapters with a live job are skipped automatically; the rest will be
            picked up by the next chapter worker.
        </p>
    {/snippet}
    {#snippet footer()}
        <!-- svelte-ignore a11y_autofocus -->
        <button autofocus onclick={onCancel}>Cancel</button>
        <button class="primary" onclick={onConfirm} disabled={busy}>Requeue {total}</button>
    {/snippet}
</Modal>
