<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Welcome to <?php echo e(env('APP_NAME', 'UNTITLED')); ?></title>
    <!-- Include Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">

    <style>
        .container {
            overflow: hidden;
        }

        .navbar-brand {
            animation: moveNotification 10s linear infinite;
            /* Adjust duration and timing function as needed */
        }

        @keyframes moveNotification {
            0% {
                transform: translateX(-100%);
            }

            100% {
                transform: translateX(100%);
            }
        }
    </style>
</head>

<body class="bg-dark">
    <!-- Header -->
    <div class="container">
        <div class="row">
            <div class="col-12 d-flex justify-content-center m-1">
                <a href="app.apk"><img src="<?php echo e(asset('logo.png')); ?>" alt="logo" width="150px" height="125px"></a>
            </div>
        </div>
        <header class="navbar navbar-dark bg-warning">
            <div class="container">
                <a class="navbar-brand text-black" href="#">
                    Notification: <?php echo e($notification); ?>

                </a>
            </div>
        </header>
        <main>

            <div class="mt-2 bg-warning bg-gradient">
                <?php if($currentRunningGame): ?>
                    <?php if(!$currentRunningGame->isResultDeclared()): ?>
                        <div class="d-flex justify-content-center ">
                            <p class="display-6 px-2  fw-bold">NEXT RESULT IN</p>
                        </div>
                        <div class="d-flex justify-content-center ">
                            <p class="display-6 text-danger fw-bold" id="timer"></p>
                        </div>
                    <?php endif; ?>
                <?php endif; ?>
            </div>
            <!-- Table -->
            <div class="d-flex justify-content-center mt-4 bg-info bg-gradient">
                <h2>Recent Results</h2>
            </div>
            <div class="table-responsive">
                <table class="table table-striped text-center table-dark">
                    <thead>
                        <tr>
                            <th>ID</th>
                            <th>Result</th>
                            <th>Created At</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__currentLoopData = $games; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $game): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr <?php if($loop->first): ?> style="font-weight: bold;" <?php endif; ?>>
                                <td>#<?php echo e($game->id); ?></td>
                                <?php if(is_null($game->win_number)): ?>
                                    <td> WAITING </td>
                                <?php else: ?>
                                    <td> <?php echo e(str_pad($game->win_number, 2, '0', STR_PAD_LEFT)); ?> </td>
                                <?php endif; ?>
                                <td> <?php echo e($game->created_at->format('h:i a d-M-Y')); ?> </td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                </table>
                <?php echo e($games->links()); ?>

                <?php if (! (filled($games))): ?>
                    <div class="mx-4 my-4 d-flex justify-content-center">
                        <h5 class="text-white"> No games added yet.</h5>
                    </div>
                <?php endif; ?>
            </div>
        </main>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
        integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous">
    </script>

    <?php if(isset($currentRunningGame) && isset($currentRunningGame->remaining_time)): ?>
        <script>
            var remainingSeconds = <?php echo e($currentRunningGame->remaining_time); ?>;
            const timerElement = document.getElementById('timer');
            updateTimerDisplay(remainingSeconds);

            async function getRemainingTime() {
                try {
                    const response = await fetch("<?php echo e(route('currentGame.remaining-time')); ?>");
                    const data = await response.json();
                    remainingSeconds = data.response.remainingTime;
                } catch (error) {
                    console.error('Error fetching remaining time:', error);
                    return null;
                }
            }

            setInterval(() => {
                if (remainingSeconds === 0) {
                    window.location.reload();
                }
                remainingSeconds -= 1;
                if (remainingSeconds > 6 && remainingSeconds % 5 == 0) {
                    getRemainingTime();
                }
                updateTimerDisplay(remainingSeconds);
            }, 1000);

            function updateTimerDisplay(seconds) {
                const minutes = Math.floor(seconds / 60);
                const secondsLeft = seconds % 60;
                timerElement.textContent =
                    `${String(minutes).padStart(2, '0')}:${String(secondsLeft).padStart(2, '0')}`;
            }
        </script>
    <?php endif; ?>

</body>

</html>
<?php /**PATH /home/payfromupi/public_html/mplotteryking.site/resources/views/welcome.blade.php ENDPATH**/ ?>