<?php echo $__env->make('layout.header', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

<div class="balance_container p-3">
    <div style="background: #009688;" class="text-white p-3">
        <p class=" f14 mb-2">Available balance: ₹ <span id="user_balance"><?php echo e($user->amount); ?></span></p>
        <div class="d-flex gap-2">
            <button class="btn f16 shadow btn-primary">
                <a class="text-white text-decoration-none" href="<?php echo e(url('/user/recharge')); ?>">
                    Recharge
                </a>
            </button>
            <?php if(env('ADVANCE_COLOR')): ?>
                <a id="trend_link" href="<?php echo e(url('/user/trend/' . $type)); ?>">
                    <button class="btn bg-white text-dark border-1 text-primary f16 shadow border-primary">
                        Trend
                    </button>
                </a>
            <?php endif; ?>
        </div>

        <a href="<?php echo e(url('/user/gameDashboard')); ?>">
            <img class="reload" src="<?php echo e(asset('assets/img/refresh.png')); ?>" alt="" />
            <!-- <img style="filter: brightness(0) invert(1);" class="reload" src="<?php echo e(asset('assets/img/refresh.png')); ?>" alt="" /> -->
        </a>
    </div>
</div>
<!-- BALANCE END -->



<!-- ON PAGE NAVIGATION START -->
<div class="container-fluid">
    <div class="row">
        <div class="col-3 tablinks <?php echo e($type == 'one_minute' ? 'border-bottom' : ''); ?> border-primary text-center f14 py-2"
            id="1_minute_tab" onclick="setTabValue(this, 'one_minute', '1 minute', '1minute')">
            1 minute
        </div>
        <div class="col-3 tablinks <?php echo e($type == 'two_minute' ? 'border-bottom' : ''); ?> border-primary text-center f14 py-2"
            id="2_minute_tab" onclick="setTabValue(this, 'two_minute', '2 minute', '2minute')">
            2 minute
        </div>
        <div class="col-3 tablinks <?php echo e($type == 'three_minute' ? 'border-bottom' : ''); ?> border-primary text-center f14 py-2"
            id="3_minute_tab" onclick="setTabValue(this, 'three_minute', '3 minute', '3minute')">
            3 minute
        </div>
        <div class="col-3 tablinks <?php echo e($type == 'five_minute' ? 'border-bottom' : ''); ?> border-primary text-center f14 py-2"
            id="5_minute_tab" onclick="setTabValue(this, 'five_minute', '5 minute', '5minute')">
            5 minute
        </div>

    </div>
</div>
<!-- ON PAGE NAVIGATION END -->

<!-- BODY START -->
<div class="body_start container-fluid mt-3">
    <div class="d-flex justify-content-between">
        <div class="d-flex align-items-center gap-2">
            <img style="max-width: 18px" src="<?php echo e(asset('assets/img/trophy.png')); ?>" alt="" />
            <p class="mb-0 f14">Period</p>
        </div>
        <p class="mb-0 f14">Count Down</p>
    </div>

    <div class="d-flex justify-content-between my-1">
        <p class="fw500 f22 mb-0" id="game_id_tag"><?php echo e($all_bettings[0]->game_id); ?></p>
        <div>
            <div id="clockdiv" class="counter d-flex align-items-center justify-content-between gap-2">
                <div>
                    <div class="count f18 py-1 fw-dark fw-bolder minutes d-flex gap-1">
                        <div class="bg1 rounded-2 fw500 px-1 ini f24" id="minutes_html">00</div>
                    </div>
                </div>
                <div>:</div>
                <div>
                    <div class="count f18 py-1 fw-dark fw-bolder seconds d-flex gap-1">
                        <div class="bg1 rounded-2 fw500 px-1 ini f24" id="seconds_html">00</div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="btn_center">
        <button data-bs-toggle="modal" onclick="setBtnValue('green', null, 'Join Green', 'green', 'green_background')"
            data-bs-target="#exampleModal" class="tab_btn back_one py-2">
            Join Green
        </button>
        <button data-bs-toggle="modal" data-bs-target="#exampleModal" class="tab_btn back_two py-2"
            onclick="setBtnValue('violet', null, 'Join Violet', 'violet', 'violet_background')">Join Violet</button>
        <button data-bs-toggle="modal" data-bs-target="#exampleModal" class="tab_btn back_three py-2"
            onclick="setBtnValue('red', null, 'Join Red', 'red', 'red_background')">Join Red</button>
    </div>

    <ul class="center_notes px-0 px-md-3">
        <li>
            <button data-bs-toggle="modal" data-bs-target="#exampleModal" id="btn_0" class="ol individual_btn btn_0"
                onclick="setBtnValue('individual', 0, 'Number 0 Selected', null, 'viored_background')">
                0
            </button>
        </li>
        <li>
            <button data-bs-toggle="modal" data-bs-target="#exampleModal" id="btn_1"
                onclick="setBtnValue('individual', 1, 'Number 1 Selected', null, 'green_background')"
                class="ol individual_btn ol">
                1
            </button>
        </li>
        <li>
            <button data-bs-toggle="modal" data-bs-target="#exampleModal" id="btn_2"
                onclick="setBtnValue('individual', 2, 'Number 2 Selected', null, 'red_background')"
                class="ol individual_btn btn_red">
                2
            </button>
        </li>
        <li>
            <button data-bs-toggle="modal" data-bs-target="#exampleModal" id="btn_3"
                onclick="setBtnValue('individual', 3, 'Number 3 Selected', null, 'green_background')"
                class="ol individual_btn ">
                3
            </button>
        </li>
        <li>
            <button data-bs-toggle="modal" data-bs-target="#exampleModal" id="btn_4"
                onclick="setBtnValue('individual', 4, 'Number 4 Selected', null, 'red_background')"
                class="ol individual_btn btn_red">
                4
            </button>
        </li>
        <li>
            <button data-bs-toggle="modal" data-bs-target="#exampleModal" id="btn_5"
                onclick="setBtnValue('individual', 5, 'Number 5 Selected', null, 'viogre_background')"
                class="ol individual_btn btn_5">
                5
            </button>
        </li>
        <li>
            <button data-bs-toggle="modal" data-bs-target="#exampleModal" id="btn_6"
                onclick="setBtnValue('individual', 6, 'Number 6 Selected', null, 'red_background')"
                class="ol individual_btn btn_red">
                6
            </button>
        </li>
        <li>
            <button data-bs-toggle="modal" data-bs-target="#exampleModal" id="btn_7"
                onclick="setBtnValue('individual', 7, 'Number 7 Selected', null, 'green_background')"
                class="ol individual_btn ">
                7
            </button>
        </li>
        <li>
            <button data-bs-toggle="modal" data-bs-target="#exampleModal" id="btn_8"
                onclick="setBtnValue('individual', 8, 'Number 8 Selected', null, 'red_background')"
                class="ol individual_btn btn_red">
                8
            </button>
        </li>
        <li>
            <button data-bs-toggle="modal" data-bs-target="#exampleModal" id="btn_9"
                onclick="setBtnValue('individual', 9, 'Number 9 Selected', null, 'green_background')"
                class="ol individual_btn ">
                9
            </button>
        </li>
    </ul>

    <?php if(env('SMALL_BIG')): ?>
        <div class="btn_center center_notes px-3 px-sm-5">
            <button data-bs-toggle="modal" onclick="setBtnValue('big', null, 'Big', 'big', 'yellow_background')"
                data-bs-target="#exampleModal" class="tab_btn back_one py-2 col-5"
                style="background-color: #ffc511;">
                Big
            </button>
            <button data-bs-toggle="modal" data-bs-target="#exampleModal" class="tab_btn back_two py-2 col-5"
                onclick="setBtnValue('small', null, 'Small', 'small', 'green_background')"
                style="background-color: #39b54a;">Small</button>
        </div>
    <?php endif; ?>
</div>

<!-- RECORD -->
<div class="bg-white shadow-sm rounded-3 py-2">
    <div class="form-group">
        <!--		Show Numbers Of Rows 		-->
        <select class="d-none form-control" name="state" id="maxRows">
            <option value="5000">Show ALL Rows</option>
            <option value="5">5</option>
            <option value="10">10</option>
            <option value="15">15</option>
            <option value="20">20</option>
            <option value="50">50</option>
            <option value="70">70</option>
            <option value="100">100</option>
        </select>
    </div>

    <div class="d-flex justify-content-center border-bottom border-primary pb-2 align-items-center gap-2">
        <img style="max-width: 18px" src="<?php echo e(asset('/assets/img/trophy.png')); ?>" alt="" />
        <p class="fw600 mb-0 f14" id="tabHeading">
            <?php if($type == 'one_minute'): ?>
                1 minute Record
            <?php elseif($type == 'two_minute'): ?>
                2 minute Record
            <?php elseif($type == 'three_minute'): ?>
                3 minute Record
            <?php elseif($type == 'five_minute'): ?>
                5 minute Record
            <?php else: ?>
                1 minute Record
            <?php endif; ?>
        </p>
    </div>
    <table class="table table-class" id="table-id">
        <thead>
            <tr>
                <th class="f12 py-3 text-center">Period</th>
                <th class="f12 py-3 text-center">Number</th>
                <th class="f12 py-3 text-center">Size</th>
                <th class="f12 py-3 text-center">Result</th>
            </tr>
        </thead>
        <tbody id="all_record_table" id="table-id">
            <?php $__currentLoopData = $all_bettings; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $betting): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <tr>
                    <?php if($loop->index == 0): ?>
                        <?php continue; ?>
                    <?php endif; ?>

                    <?php
                        switch ($type) {
                            case 'two_minute':
                                $gamePoint = $betting->gamePoint2Minute;
                                break;
                            case 'three_minute':
                                $gamePoint = $betting->gamePoint3Minute;
                                break;
                            case 'five_minute':
                                $gamePoint = $betting->gamePoint5Minute;
                                break;
                            default:
                                $gamePoint = $betting->gamePoint;
                        }

                        $game_data = findLatestBettingByType($type, $betting->game_id);

                        $color = match ($gamePoint->color) {
                            'red' => 'redcolor',
                            'green' => 'greencolor',
                            'viored', 'viogre' => 'violetcolor',
                            default => '',
                        };
                    ?>

                    <td class="text-center f14 <?php echo e($color); ?>"><?php echo e($betting->game_id); ?></td>
                    <td class="text-center f14 <?php echo e($color); ?>">
                        <?php echo e($betting->{$type . '_code'}); ?>

                    </td>
                    <td class="text-center f14">
                        <?php if($betting->{$type . '_code'} < 5): ?>
                            Small
                        <?php else: ?>
                            Big
                        <?php endif; ?>
                    </td>

                    <?php
                        $dotHtml = '';

                        switch ($gamePoint->color) {
                            case 'red':
                                $dotHtml = '<div class="red_dot"></div>';
                                break;
                            case 'green':
                                $dotHtml = '<div class="green_dot"></div>';
                                break;
                            case 'viored':
                                $dotHtml =
                                    '<div style="display:flex;"><div class="violet_dot"></div><div class="red_dot"></div></div>';
                                break;
                            case 'viogre':
                                $dotHtml =
                                    '<div style="display:flex;"><div class="violet_dot"></div><div class="green_dot"></div></div>';
                                break;
                        }
                    ?>

                    <td class="text-center f14 d-flex justify-content-center">
                        <?php echo $dotHtml; ?>

                    </td>

                </tr>
                
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </tbody>
    </table>
    <?php
        $pagination = 'd-none';
        if (count($my_bettings) < 10) {
            $pagination = '';
        }
    ?>
    <div class="pagination-container d-flex justify-content-center">
        <nav class="d-flex justify-content-center gap-3">
            <ul
                class="pagination d-flex justify-content-center align-items-center gap-3 list-unstyled <?php echo e($pagination); ?>">
                <li data-page="prev" class="pointer">
                    <span>
                        < <span class="sr-only">
                    </span></span>
                </li>
                <!--	Here the JS Function Will Add the Rows -->
                <li data-page="next" id="prev" class="pointer">
                    <span> > <span class="sr-only"></span></span>
                </li>
            </ul>
        </nav>
    </div>
</div>

<!-- 2 -->
<div class="bg-white shadow-sm rounded-3 py-2 mt-3 mb-3">
    <div class="form-group">
        <!--		Show Numbers Of Rows 		-->
        <select class="d-none form-control" name="state" id="maxRows2">
            <option value="5000">Show ALL Rows</option>
            <option value="5">5</option>
            <option value="10">10</option>
            <option value="15">15</option>
            <option value="20">20</option>
            <option value="50">50</option>
            <option value="70">70</option>
            <option value="100">100</option>
        </select>
    </div>

    <div class="d-flex justify-content-center border-bottom border-primary pb-2 align-items-center gap-2">
        <img style="max-width: 18px" src="<?php echo e(asset('/assets/img/record.png')); ?>" alt="" />
        <p class="fw600 mb-0 f14">My Record</p>
    </div>
    <table class="record-table table table-class" id="table-id2" style="margin-bottom: 35px;">
        <thead>
            <tr>
                <td>
                    <div class="accordion-flush"></div>
                </td>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td id="my_records_detail">
                    <?php if(count($my_bettings) > 0): ?>
                        <?php $__currentLoopData = $my_bettings; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $betting): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <div class="accordion accordion-flush" id="accordionFlushExample<?php echo e($betting->id); ?>">
                                <div class="accordion-item">
                                    <h2 class="accordion-header" id="flush-headingOne">
                                        <button class="accordion-button collapsed d-flex gap-3" type="button"
                                            data-bs-toggle="collapse"
                                            data-bs-target="#flush-collapseOne<?php echo e($betting->id); ?>"
                                            aria-expanded="true"
                                            aria-controls="flush-collapseOne<?php echo e($betting->id); ?>">
                                            <div class="f14"><?php echo e($betting->game_id); ?></div>
                                            <?php if($betting->status == 0): ?>
                                                <div class="f14">Waiting</div>
                                            <?php elseif($betting->status == 1): ?>
                                                <?php if($betting->result == 0): ?>
                                                    <div class="f14 text-danger">Fail</div>
                                                    <div class="f14 text-danger">-<?php echo e($betting->amount); ?></div>
                                                <?php elseif($betting->result == 1): ?>
                                                    <div class="f14 text-success">Success</div>
                                                    <div class="f14 text-success">+<?php echo e($betting->winning_amount); ?>

                                                    </div>
                                                <?php endif; ?>
                                            <?php endif; ?>

                                        </button>
                                    </h2>
                                    <div id="flush-collapseOne<?php echo e($betting->id); ?>"
                                        class="accordion-collapse collapse" aria-labelledby="flush-headingOne"
                                        data-bs-parent="#accordionFlushExample<?php echo e($betting->id); ?>">
                                        <div class="accordion-body">
                                            <div class="van-collapse-item__wrapper">
                                                <div class="van-collapse-item__content px-0">
                                                    <div class="myParity">
                                                        <p class="myParity_title">Period Detail</p>
                                                        <ul class="ps-0">
                                                            <li>
                                                                <ol class="ps-0">
                                                                    Period
                                                                </ol>
                                                                <ol class="ps-0">
                                                                    <?php echo e($betting->game_id); ?>

                                                                </ol>
                                                            </li>
                                                            <li>
                                                                <ol class="ps-0">
                                                                    Delivery
                                                                </ol>
                                                                <ol class="ps-0">
                                                                    <span class="orange"><?php echo e($betting->amount); ?></span>
                                                                </ol>
                                                            </li>
                                                            <li>
                                                                <ol class="ps-0">
                                                                    Fee
                                                                </ol>
                                                                <ol class="ps-0">
                                                                    <?php echo e($betting->value - $betting->amount); ?>

                                                                </ol>
                                                            </li>
                                                            <li>
                                                                <ol class="ps-0">
                                                                    Open Price
                                                                </ol>
                                                                <ol class="ps-0">
                                                                    <?php echo e($betting->total_amount); ?>

                                                                </ol>
                                                            </li>
                                                            <li>
                                                                <ol class="ps-0">
                                                                    Result
                                                                </ol>
                                                                <ol class="ps-0">
                                                                    <?php echo e($betting->gameId->one_minute_code); ?>

                                                                </ol>
                                                            </li>
                                                            <?php
                                                                $betting_code = $betting->code;
                                                                if ($betting->code == '0,5,') {
                                                                    $betting_code = 'Join Violet';
                                                                } elseif ($betting->code == '1,3,5,7,9,') {
                                                                    $betting_code = 'Join Green';
                                                                } elseif ($betting->code == '0,2,4,6,8,') {
                                                                    $betting_code = 'Join Red';
                                                                } elseif ($betting->code == '0,1,2,3,4,') {
                                                                    $betting_code = 'Small';
                                                                } elseif ($betting->code == '5,6,7,8,9,') {
                                                                    $betting_code = 'Big';
                                                                }
                                                            ?>
                                                            <li>
                                                                <ol class="ps-0">
                                                                    Select
                                                                </ol>
                                                                <ol class="ps-0">
                                                                    <?php echo e($betting_code); ?>

                                                                </ol>
                                                            </li>
                                                            <li>
                                                                <ol class="ps-0">
                                                                    Status
                                                                </ol>
                                                                <ol class="ps-0">
                                                                    <?php if($betting->status == 0): ?>
                                                                        <span>Waiting</span>
                                                                    <?php elseif($betting->status == 1): ?>
                                                                        <?php if($betting->result == 0): ?>
                                                                            <span class="fail">Fail</span>
                                                                        <?php elseif($betting->result == 1): ?>
                                                                            <div class="text-success">Success</div>
                                                                        <?php endif; ?>
                                                                    <?php endif; ?>
                                                                </ol>
                                                            </li>
                                                            <li>
                                                                <ol class="ps-0">
                                                                    Amount
                                                                </ol>
                                                                <ol class="ps-0">
                                                                    <?php if($betting->status == 0): ?>
                                                                        <span>Waiting</span>
                                                                    <?php elseif($betting->status == 1): ?>
                                                                        <?php if($betting->result == 0): ?>
                                                                            <span
                                                                                class="fail">-<?php echo e($betting->amount); ?></span>
                                                                        <?php elseif($betting->result == 1): ?>
                                                                            <div class="text-success">
                                                                                <?php echo e($betting->winning_amount); ?>

                                                                            </div>
                                                                        <?php endif; ?>
                                                                    <?php endif; ?>
                                                                </ol>
                                                            </li>
                                                            <li>
                                                                <ol class="ps-0">
                                                                    Create Time
                                                                </ol>
                                                                <ol class="ps-0">
                                                                    <?php echo e($betting->created_at); ?>

                                                                </ol>
                                                            </li>
                                                            <li>
                                                                <ol class="ps-0">
                                                                    Type
                                                                </ol>
                                                                <ol class="ps-0">
                                                                    <?php echo e($betting->tab); ?>

                                                                </ol>
                                                            </li>
                                                        </ul>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    <?php else: ?>
                        No record found
                    <?php endif; ?>
                </td>
            </tr>
        </tbody>
    </table>

    <?php
        $pagination = 'd-none';
        if (count($my_bettings) < 10) {
            $pagination = '';
        }
    ?>

    <div class="pagination-container d-flex justify-content-center">
        <nav class="d-flex justify-content-center gap-3">
            <ul
                class="pagination2 d-flex justify-content-center align-items-center gap-3 list-unstyled <?php echo e($pagination); ?>">
                <li data-page="prev" class="pointer">
                    <span>
                        < <span class="sr-only">
                    </span></span>
                </li>
                <li data-page="next" id="prev" class="pointer">
                    <span> > <span class="sr-only"></span></span>
                </li>
            </ul>
        </nav>
    </div>
</div>
<div class="modal fade modal_" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel"
    aria-hidden="true">
    <div class="modal-dialog modal-xl">
        <div class="modal-content">
            <div class="p-3 w-100 model_lable_section" id="modal_header">
                <h5 class="modal-title text-center w-100 model_lable" id="exampleModalLabel">
                    Join Green
                </h5>
            </div>
            <div class="modal-body">
                <p>Contract Money</p>

                <div class="d-flex justify-content-between">
                    <script>
                        var betamountfromenv = "<?php echo e(env('MIN_BET', 10)); ?>";
                    </script>
                    <button class="green2 btn lightGray number_boxes" id="value10"
                        onclick="changeAmount(this.id, betamountfromenv)"><?php echo e(env('MIN_BET', 10)); ?></button>
                    <button class="btn lightGray number_boxes" id="value100"
                        onclick="changeAmount(this.id, 100)">100</button>
                    <button class="btn lightGray number_boxes" id="value1000"
                        onclick="changeAmount(this.id, 1000)">1000</button>
                    <button class="btn lightGray number_boxes" id="value10000"
                        onclick="changeAmount(this.id, 10000)">10000</button>
                </div>
                <br />
                <input type="hidden" name="tab" value="<?php echo e($type); ?>">
                <input type="hidden" name="max" value="<?php echo e($user->amount); ?>">
                <input type="hidden" name="btn" value="">
                <input type="hidden" name="color" value="">
                <input type="hidden" name="code" value="">
                <input type="hidden" name="amount" value="<?php echo e(env('MIN_BET', 10)); ?>">
                <input type="hidden" name="game_id" value="<?php echo e($games[0]->game_id); ?>">
                <input type="hidden" name="reference_amount" value="10">

                <div class="row">
                    <div class="col-6">
                        <p>Number</p>
                    </div>
                    <div class="col-6 count">
                        <div class="d-flex align-items-center gap-2">
                            <button class="minus" onclick="amountMultiple('minus')"></button>
                            <span id="amountMultipleText">1</span>
                            <input type="hidden" name="amountMultiple" value="1" />
                            <button class="plus" onclick="amountMultiple('plus')"></button>
                        </div>
                    </div>
                    <div class="col-12 error" id="amount_error"></div>
                </div>

                <p>Total contract money is <span class="color_green" id="bet_amount"> <?php echo e(env('MIN_BET', 10)); ?>

                    </span></p>
                <div>
                    <input type="checkbox" onchange="privacy_checkbox_state()" name="privacy_checkbox"
                        id="privacy_checkbox" checked required />
                    I agree
                    <span data-bs-toggle="modal" data-bs-target="#exampleModal2" class="color2 pointer">
                        PRESALE RULE
                    </span>
                </div>
                <div class="error" id="privacy_checkbox_error" style="display: none;">Please check this box to
                    proceed further.</div>
            </div>
            <div class="modal-footer border-top border-dark w-100 p-0">
                <div class="row w-100 my-0">
                    <div class="col-6">
                        <button onclick="return cancelButtonClickedBidDialog();" data-bs-dismiss="modal"
                            id="cancel_button" class="bg-transparent py-2 border-0 w-100">
                            CANCEL
                        </button>
                    </div>
                    <div class="col-6 border-start border-dark">
                        <button id="submitGame" onclick="saveBet()" class="bg-transparent py-2 green border-0 w-100">
                            CONFIRM
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="modal fade modal_ modal_privacy" id="exampleModal2" tabindex="-1" aria-labelledby="exampleModalLabel"
    aria-hidden="true">
    <div class="modal-dialog modal-xl">
        <div class="modal-content">
            <div class="modal-header w-100">
                <h5 class="modal-title text-start w-100" id="exampleModalLabel">
                    Privacy Policy
                </h5>
            </div>
            <div class="modal-body privacy_body">
                <div class="content_agree">
                    <div class="contents">
                        <div>
                            <p>
                                In order to protect the legitimate rights and interests of
                                users participating in the presale and maintain the normal
                                operation order of the presale, the rules are formulated in
                                accordance with relevant agreements and rules of national
                                laws and regulations.
                            </p>
                            <p>
                                <span style="color: rgb(0, 150, 136); font-size: 14px">Chapter 1 Definition</span>
                            </p>
                            <p class="MsoListParagraph" style="margin-left: 8px">
                                1.1<span
                                    style="
                        font-variant-numeric: normal;
                        font-variant-east-asian: normal;
                        font-stretch: normal;
                        font-size: 9px;
                        line-height: normal;
                      ">&nbsp;&nbsp;
                                </span>Presale definition: refers to a sales model in which a
                                merchant provides a product or service plan, gathers
                                consumer orders through presale product tools, and provides
                                goods and / or services to consumers according to prior
                                agreement.
                            </p>
                            <p class="MsoListParagraph" style="margin-left: 8px">
                                1.2<span
                                    style="
                        font-variant-numeric: normal;
                        font-variant-east-asian: normal;
                        font-stretch: normal;
                        font-size: 9px;
                        line-height: normal;
                      ">&nbsp;&nbsp;
                                </span>The presale model is a "deposit" model. "Deposit" refers to
                                a fixed amount of presale commodity price pre-delivered.
                                “The deposit” can participate in small games and have the
                                opportunity to win more deposits. The deposit can be
                                directly exchanged for commodities. The deposit is not
                                redeemable.
                            </p>
                            <p class="MsoListParagraph" style="margin-left: 8px">
                                1.3<span
                                    style="
                        font-variant-numeric: normal;
                        font-variant-east-asian: normal;
                        font-stretch: normal;
                        font-size: 9px;
                        line-height: normal;
                      ">&nbsp;&nbsp;
                                </span>Presale products: refers to the products released by
                                merchants using presale product tools. Only the presale
                                words are marked on the product title or product details
                                page, and the products that do not use the presale product
                                tools are not presale products.
                            </p>
                            <p class="MsoListParagraph" style="margin-left: 8px">
                                1.4<span
                                    style="
                        font-variant-numeric: normal;
                        font-variant-east-asian: normal;
                        font-stretch: normal;
                        font-size: 9px;
                        line-height: normal;
                      ">&nbsp;&nbsp;
                                </span>Presale system: Refers to the system product tools provided
                                to support merchants for presale model sales.
                            </p>
                            <p class="MsoListParagraph" style="margin-left: 8px">
                                1.5<span
                                    style="
                        font-variant-numeric: normal;
                        font-variant-east-asian: normal;
                        font-stretch: normal;
                        font-size: 9px;
                        line-height: normal;
                      ">&nbsp;&nbsp;
                                </span>Presale commodity price: refers to the selling price of
                                presale commodity. The price of presale goods is composed of
                                two parts: deposit and final payment.
                            </p>
                            <p class="MsoListParagraph" style="margin-left: 8px">
                                1.6<span
                                    style="
                        font-variant-numeric: normal;
                        font-variant-east-asian: normal;
                        font-stretch: normal;
                        font-size: 9px;
                        line-height: normal;
                      ">&nbsp;&nbsp;
                                </span>Presale deposit: Refers to a certain amount of money that
                                consumers pay in advance when purchasing presale goods,
                                which is mainly used as a guarantee to purchase presale
                                goods and determine the purchase quota.
                            </p>
                            <p class="MsoListParagraph" style="margin-left: 8px">
                                1.7<span
                                    style="
                        font-variant-numeric: normal;
                        font-variant-east-asian: normal;
                        font-stretch: normal;
                        font-size: 9px;
                        line-height: normal;
                      ">&nbsp;&nbsp;
                                </span>Presale final payment: refers to the amount of money that
                                the consumer still has to pay after the presale commodity
                                price minus the deposit.
                            </p>
                            <p class="MsoListParagraph" style="margin-left: 8px; text-indent: 0px">
                                &nbsp;
                            </p>
                            <p>
                                <span style="color: rgb(0, 150, 136); font-size: 14px">Chapter 2 Presale management
                                    specifications</span>
                            </p>
                            <p>
                                <span style="color: rgb(0, 150, 136); font-size: 13px">2.1 Commodity
                                    management</span>
                            </p>
                            <p>2.1.1 Presale deposit time: up to 7 days can be set.</p>
                            <p>
                                2.1.2 Presale final payment time: The start time of the
                                final payment is within 7 days.
                            </p>
                            <p>
                                2.1.3 During the presale of commodities, the system does not
                                support merchants to modify the price of pre-sold
                                commodities (including deposits and balances), but the
                                amount of remaining commodity inventory can be modified
                                according to the actual situation of inventory.
                            </p>
                            <p>
                                2.1.4 To avoid unnecessary disputes, If the presale product
                                is a customized product, the merchant should clearly inform
                                the consumer on the product page of the production cycle and
                                delivery time of the product, and contact the consumer to
                                confirm the delivery standard, delivery time, etc.
                            </p>
                            <p>
                                2.1.5 For customized products, the merchant has not agreed
                                with the consumer on the delivery time and delivery
                                standard, the delivery standard proposed by the consumer is
                                unclear or conflicts and after the merchant places an order,
                                he(she) starts production and delivery without confirming
                                with the consumer, if the consumer initiates a dispute as a
                                result, the platform will treat it as a normal delivery time
                                limit order fulfillment.
                            </p>
                            <p>
                                <span style="color: rgb(0, 150, 136); font-size: 13px">2.2 Transaction
                                    management</span>
                            </p>
                            <p>
                                2.2.1 Consumers who use the pre-sale system will lock in the
                                pre-sale quota after placing an order for goods. If the
                                pre-sale order is overtime, the system will automatically
                                cancel it.
                            </p>
                            <p>
                                2.2.2 During the presale period, the merchant shall not
                                cancel the presale activities without reason. For presale
                                activities that have generated orders, the merchant must not
                                cancel the order without the consumer ’s consent. If the
                                consumer agrees, the merchant should double return the
                                deposit paid by the consumer; if the consumer does not agree
                                to cancel the order, the merchant should perform the
                                contract according to the order.
                            </p>
                            <p>
                                2.2.3 If the final payment of the presale order is not
                                completed due to consumer reasons, the merchant can deduct
                                the deposit paid by the consumer; if the merchant actively
                                negotiates with the consumer to terminate the order before
                                paying the final payment, the merchant shall double Return
                                the deposit paid by the consumer.
                            </p>
                            <p>
                                <span style="color: rgb(0, 150, 136); font-size: 13px">2.3 Delivery
                                    Management</span>
                            </p>
                            <p>2.3.1 Delivery time limit setting</p>
                            <p>
                                If the merchant sets the delivery time limit through the
                                presale system, it should be shipped within the set time
                                limit.
                            </p>
                            <p>2.3.2 Shipping way</p>
                            <p>The third-party delivery the orders.</p>
                            <p>
                                Customers need to provide your name, address and phone
                                number to facilitate third-party delivery orders.
                            </p>
                            <p>
                                <span style="color: rgb(0, 150, 136); font-size: 13px">2.4 After-sales
                                    management</span>
                            </p>
                            <p>
                                Presale products shall provide after-sales service in
                                accordance with the "Regulations for After-sales Service of
                                Platform Merchants".
                            </p>
                            <p>&nbsp;</p>
                            <p>
                                <strong>Explanation</strong>
                            </p>
                            <p>Mall transaction mode</p>
                            <p>
                                There are two ways to buy in the mall, one is full purchase,
                                and the other is deposit purchase.
                            </p>
                            <p>
                                In the mode of full purchase, you can place an order
                                directly and purchase goods in full payment.
                            </p>
                            <p>
                                The deposit purchase mode will freeze the customer's
                                deposit, and the customer will take delivery after
                                completing the final payment within 7 days. Users who have
                                paid a deposit will be given an extra point quiz game.
                                According to the analysis of market fluctuations, they have
                                the opportunity to win more points to deduct the payment or
                                send red envelopes to friends.
                            </p>
                            <p>&nbsp;</p>
                            <p>
                                <a></a>The pre-order model has many benefits for customers.
                                The deposit not only generates an order for the customer,
                                but also gives the customer an equal amount of red
                                envelopes, which can be withdrawn immediately. Although the
                                deposit is not refundable, the red envelope converted from
                                the deposit can be withdrawn without any loss to the
                                customer.
                            </p>
                            <p>&nbsp;</p>
                            <p>
                                一. After the customer pays the deposit and orders, a
                                merchandise order is generated, and the mall began to
                                prepare this order. This deposit cannot be returned. After
                                the customer needs to make up the balance, the mall will
                                ship the goods. If the customer does not make up the
                                balance, the product order will always exist.
                            </p>
                            <p>
                                二. After paying the deposit, the customer will be given a
                                red envelope account with the same amount of deposit.
                            </p>
                            <p>
                                1. The red envelope can be withdrawn directly, so that
                                instead of losing money, the customer has added a commodity
                                order generated by a deposit. And red envelopes can also be
                                given to friends.
                            </p>
                            <p>
                                <span style="font-size: 14px">2. If the customer uses the red envelope account to
                                    participate in the game, you can earn more red envelopes,
                                    but if the game loses, the red envelope will be gone, but
                                    his merchandise order is still there.</span>
                            </p>
                            <p>
                                <br />
                            </p>
                            <p>
                                Note: I have carefully read all contents of this presale
                                management rule, Risk Disclosure Agreement and Risk
                                Agreement and I am agreed to continue with my own risk.
                            </p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer border-top border-dark w-100 p-0">
                <div class="row w-100 my-0">
                    <div class="col-12">
                        <button data-bs-dismiss="modal" class="bg-transparent py-2 border-0 w-100">
                            CLOSE
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<?php if(env('ENABLE_GAME_SHOW_CARD')): ?>
    <div class="modal fade " id="loseModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle"
        aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div
                class="modal-content bg-transparent shadow-none border-0 d-flex align-items-center justify-content-center">
                <div class="modal-section">
                    <img src="<?php echo e(asset('assets/model-imgs/lose-bg.png')); ?>" />
                    <div class="modal-section-body">
                        <h4 style="font-size: 32px;">Sorry</h4>
                        <div class="result" style="margin-top: 35px">
                            <span>Result</span>
                            <div id="loseModelColorHtml" style="white-space: nowrap;"></div>
                            <div class="full-circle" style="padding-left: 8px; padding-right: 8px">
                                <span id="loseModelResult" style="padding:5px"></span>
                            </div>
                        </div>
                        <div style="padding-top: 36px; text-align: center; ">
                            <span style="font-size: 28px; color: #5a7da0; font-weight: 700">Lose</span>
                            <div style="padding-top: 5px; font-size: 14px;">Period:
                                <span id="loseModelTab"></span>
                                <span id="loseModelGameId"></span>
                            </div>
                        </div>
                        <div class="d-flex mt-5" style="font-size: 14px;">
                            <span id="timer"></span>&nbsp;seconds auto close
                        </div>
                    </div>
                </div>
                <div class="d-flex justify-content-center pt-2">
                    <svg id="closeBtn" xmlns="http://www.w3.org/2000/svg"
                        style="cursor: pointer; width: 30px; height: 30px" fill="none" viewBox="0 0 24 24"
                        stroke-width="1.5" stroke="#fff">
                        <path stroke-linecap="round" stroke-linejoin="round"
                            d="m9.75 9.75 4.5 4.5m0-4.5-4.5 4.5M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />
                    </svg>
                </div>
            </div>
        </div>
    </div>
    <div class="modal fade" id="winModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle"
        aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div
                class="modal-content bg-transparent shadow-none border-0 d-flex align-items-center justify-content-center">
                <div class="modal-section">
                    <img src="<?php echo e(asset('assets/model-imgs/win-bg.png')); ?>" />
                    <div class="modal-section-body">
                        <h4 style="font-size: 32px;">Congratulations</h4>
                        <div class="result" style="margin-top: 45px">
                            <span>Result</span>
                            <div id="winModelColorHtml" style="white-space: nowrap;"></div>
                            <div class="full-circle" style="padding-left: 8px; padding-right: 8px">
                                <span id="winModelResult" style="padding:5px"></span>
                            </div>
                        </div>
                        <div style="padding-top: 25px; display: flex;flex-direction: column;text-align: center; ">
                            <span
                                style="font-size: 20px; line-height: 10px; color: #c46b5d; font-weight: 700">Bonus</span>
                            <span style="font-size: 28px; color: #c46b5d; font-weight: 700" id="winModelwiningAmount">
                            </span>
                            <div style="padding-top: 5px; font-size: 14px;">Period:
                                <span id="winModelTab"></span>
                                <span id="winModelGameId"></span>
                            </div>
                        </div>
                        <div class="d-flex mt-5" style="font-size: 14px;">
                            <span id="timer"></span>&nbsp;seconds auto close
                        </div>
                    </div>
                </div>
                <div class="d-flex justify-content-center pt-2">
                    <svg id="closeBtn" xmlns="http://www.w3.org/2000/svg"
                        style="cursor: pointer; width: 30px; height: 30px" fill="none" viewBox="0 0 24 24"
                        stroke-width="1.5" stroke="#fff">
                        <path stroke-linecap="round" stroke-linejoin="round"
                            d="m9.75 9.75 4.5 4.5m0-4.5-4.5 4.5M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />
                    </svg>
                </div>
            </div>
        </div>
    </div>
<?php endif; ?>

<div id="snackbar" style="z-index: 1100;"></div>

<script>
    // Function to refresh the page
    function refreshPage() {
        location.reload();
    }

    // Event listener for visibility change
    document.addEventListener('visibilitychange', function() {
        console.log('visibilitychange');
        if (!document.hidden) {
            // The page is now visible, refresh it
            refreshPage();
        }
    }, false);

    var showWinLossPopup = "<?php echo e(env('ENABLE_GAME_SHOW_CARD')); ?>";

    // on page load
    // $(document).ready(function() {
    //     let tab_value = $("input[name='tab']").val();
    //     // fetchRecords(tab_value);
    // });


    let reference = parseInt("<?php echo e($last_game_time); ?>");
    let one_minute_time = parseInt("<?php echo e($last_game_one_minute_time); ?>");
    let two_minute_time = parseInt("<?php echo e($last_game_two_minute_time); ?>");
    let three_minute_time = parseInt("<?php echo e($last_game_three_minute_time); ?>");
    let five_minute_time = parseInt("<?php echo e($last_game_five_minute_time); ?>");

    let total_seconds;
    let date_now = parseInt("<?php echo e($date_now); ?>");

    let one_minute_seconds;
    let two_minute_seconds;
    let three_minute_seconds;
    let five_minute_seconds;

    var myfunc = setInterval(function() {
        date_now = date_now + 1;
        total_seconds = reference - date_now;
        one_minute_seconds = one_minute_time - date_now;
        two_minute_seconds = two_minute_time - date_now;
        three_minute_seconds = three_minute_time - date_now;
        five_minute_seconds = five_minute_time - date_now;

        if (total_seconds >= 300) {
            activate_buttons();
            $('#minutes_html').html("05");
            let seconds = total_seconds % 60;
            if (seconds < 10) {
                $('#seconds_html').html("0" + seconds);
            } else {
                $('#seconds_html').html(seconds);
            }
        } else if (total_seconds >= 240) {
            activate_buttons();
            $('#minutes_html').html("04");
            let seconds = total_seconds % 60;
            if (seconds < 10) {
                $('#seconds_html').html("0" + seconds);
            } else {
                $('#seconds_html').html(seconds);
            }
        } else if (total_seconds >= 180) {
            activate_buttons();
            $('#minutes_html').html("03");
            let seconds = total_seconds % 60;
            if (seconds < 10) {
                $('#seconds_html').html("0" + seconds);
            } else {
                $('#seconds_html').html(seconds);
            }
        } else if (total_seconds >= 120) {
            activate_buttons();
            $('#minutes_html').html("02");
            let seconds = total_seconds % 60;
            if (seconds < 10) {
                $('#seconds_html').html("0" + seconds);
            } else {
                $('#seconds_html').html(seconds);
            }
        } else if (total_seconds >= 60) {
            activate_buttons();
            $('#minutes_html').html("01");
            let seconds = total_seconds % 60;
            if (seconds < 10) {
                $('#seconds_html').html("0" + seconds);
            } else {
                $('#seconds_html').html(seconds);
            }
            //change 5 second code 30 second timer
        } else if (total_seconds > 30) {
            activate_buttons();
            $('#minutes_html').html("00");
            let seconds = total_seconds % 60;
            if (seconds < 10) {
                $('#seconds_html').html("0" + seconds);
            } else {
                $('#seconds_html').html(seconds);
            }
        } else if (total_seconds > 0) {
            disable_buttons();
            let seconds = total_seconds % 60;
            $('#minutes_html').html("00");
            if (seconds < 10) {
                $('#seconds_html').html("0" + seconds);
            } else {
                $('#seconds_html').html(seconds);
            }
        } else if (total_seconds <= 0) {
            $('#minutes_html').html("00");
            $('#seconds_html').html("00");
            console.log('less than 0');
            let tab_value = $("input[name='tab']").val();

            disable_buttons();
            const gameId = $("#game_id_tag").text();
            fetchRecords(tab_value);
            if (showWinLossPopup) {
                checkUserWinOrLoss(gameId);
            }

        }
    }, 1000);

    var myfuncc = setInterval(function() {
        console.log(" ");
        console.log("total_seconds " + total_seconds);
        console.log(one_minute_seconds,
            two_minute_seconds,
            three_minute_seconds,
            five_minute_seconds);


        const times = [one_minute_seconds, two_minute_seconds, three_minute_seconds, five_minute_seconds];
        if (times.some(time => time <= 0)) {
            getUpdatedTime();
            fetchRecords($("input[name='tab']").val());
        }
    }, 1000);

    function checkUserWinOrLoss(gameId) {
        console.log('Checking User Win Or Loss');
        let tab = $("input[name='tab']").val();
        $.ajax({
            url: '/user/win/getUserResultData/' + gameId,
            method: 'GET',
            data: {
                tab: tab,
            },
            success: function(data) {
                console.log(data);
                if (data.hasBet) {
                    console.log('User has bet');
                    let color = data.color;
                    const backgroundColor = color + '_background';
                    if (color == 'viored') {
                        color = "Voilet + Red"
                    } else if (color == 'viogre') {
                        color = "Voilet + Green"
                    }
                    // console.log('color: ' + color);
                    // console.log('backgroundColor: ' + backgroundColor);
                    if (data.winingAmount > 0) {
                        console.log('User Win');
                        $('#winModelResult')
                            .addClass(backgroundColor).text(data.result);
                        $('#winModelTab').text(data.tab);
                        $('#winModelGameId').text(data.gameId);
                        $('#winModelwiningAmount').text(data.winingAmount);
                        $('#winModelColorHtml')
                            .addClass(backgroundColor)
                            .text(color.charAt(0).toUpperCase() + color.slice(1));
                        $('#winModal').modal('show');
                    } else {
                        console.log('User Lose');
                        $('#loseModelResult')
                            .addClass(backgroundColor).text(data.result);
                        $('#loseModelTab').text(data.tab);
                        $('#loseModelGameId').text(data.gameId);
                        $('#loseModelBodyContent').text(data.winingAmount);
                        $('#loseModelColorHtml')
                            .addClass(backgroundColor)
                            .text(color.charAt(0).toUpperCase() + color.slice(1));
                        $('#loseModal').modal('show');
                    }
                }
            },
            error: function(xhr, status, error) {
                console.error(xhr.responseText);
            }
        });
    }

    function getUpdatedTime() {
        let tab_value = $("input[name='tab']").val();

        $.ajax({
            headers: {
                "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
            },
            url: "/user/getTime",
            method: "POST",
            data: {
                tab: tab_value
            },
            success: function(data) {
                if (data.status == "success") {
                    console.log('Got New Times');
                    reference = data.last_game_time;
                    one_minute_time = data.last_game_one_minute_time;
                    two_minute_time = data.last_game_two_minute_time;
                    three_minute_time = data.last_game_three_minute_time;
                    five_minute_time = data.last_game_five_minute_time;

                    console.log('reference (last_game_time)' + reference);
                    console.log('one_minute_time ' + one_minute_time);
                    console.log('two_minute_time ' + two_minute_time);
                    console.log('three_minute_time ' + three_minute_time);
                    console.log('five_minute_time ' + five_minute_time);
                } else {
                    console.log('Failed to get new times');
                }
            }
        });
    }

    function fetchRecords(tab, mode = null) {
        let tab_value = $("input[name='tab']").val();

        $.ajax({
            headers: {
                "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
            },
            url: "/user/gameRecord/all",
            method: "POST",
            data: {
                tab: tab_value
            },
            success: function(data) {
                if (data.status == "success") {
                    html = "";
                    if (data.all_bettings.length == 0) {
                        $("#all_record_table").html(
                            `<tr><td colspan="4" class="text-center">No Data Found.</td></tr>`
                        );
                    } else {
                        $.each(data.all_bettings, function(key, betting) {
                            let tab = $("input[name='tab']").val();

                            // generate color according to game point
                            let color_to_set = "";
                            if (betting.gamePoint.color == "red") {
                                color_to_set = "redcolor";
                            } else if (betting.gamePoint.color == "green") {
                                color_to_set = "greencolor";
                            } else if (betting.gamePoint.color == "viored") {
                                color_to_set = "violetcolor";
                            } else if (betting.gamePoint.color == "viogreen") {
                                color_to_set = "violetcolor";
                            }

                            if (betting.status == 1) {
                                html += `<tr><td class="text-center f14">${betting.game_id}</td>
                                        <td class="text-center ${color_to_set} f14">${betting.code}</td>`;
                                if (betting.code < 5) {
                                    html += `<td class="text-center f14">Small</td>`;
                                } else {
                                    html += `<td class="text-center f14">Big</td>`;
                                }
                                html +=
                                    `<td class="text-center f14 d-flex justify-content-center">`;
                                if (betting.gamePoint.color == "red") {
                                    html += `<div class="red_dot"></div>`;
                                } else if (betting.gamePoint.color == "green") {
                                    html += `<div class="green_dot"></div>`;
                                } else if (betting.gamePoint.color == "viored") {
                                    html += `<div style="display:flex;">
                                    <div class="violet_dot"></div><div class="red_dot"></div>
                                </div>`;
                                } else if (betting.gamePoint.color == "viogre") {
                                    html += `<div style="display:flex;">
                                    <div class="violet_dot"></div><div class="green_dot"></div>
                                </div>`;
                                }
                                html += `</td>`;
                            }
                        });


                    }
                    $("#game_id_tag").html(data.active_game_id.game_id);
                    $("input[name='game_id']").val(data.active_game_id.game_id);
                    reference = data.last_game_time;

                    if (mode != "tab") {
                        let check_difference = (data.date_now - data.last_game_time);

                        console.log("check_difference " + check_difference);

                        if (check_difference >= -30) {
                            // disable_buttons();
                            return;
                        }

                        $("#user_balance").html(data.user_balance);
                        $("input[name='max']").val(data.user_balance);
                        $("input[name='game_id']").val(data.active_game_id.game_id);
                        // activate_buttons();
                        // let tab = $("input[name='tab']").val();
                        fetchMyRecords($("input[name='tab']").val());
                        // getPagination("#table-id", 'pagination');

                    }
                    $("#all_record_table").html(html);
                    if (data.all_bettings.length > 10) {
                        $(".pagination").removeClass('d-none');
                    }
                    getPagination("#table-id", 'pagination');
                    if (mode == "tab") {}
                }
            }
        });
    }

    getPagination("#table-id", 'pagination');
    getPaginationMyRecords("#table-id2", 'pagination2');

    function getPagination(table, pagination_class) {
        var lastPage = 1;

        $("#maxRows")
            .on("change", function(evt) {
                lastPage = 1;
                $("." + pagination_class).find("li").slice(1, -1).remove();
                var trnum = 0;
                var maxRows = 10;

                if (maxRows == 5000) {
                    $("." + pagination_class).hide();
                } else {
                    $("." + pagination_class).show();
                }

                var totalRows = $(table + " tbody tr").length; // numbers of rows
                $(table + " tr:gt(0)").each(function() {
                    trnum++;
                    if (trnum > maxRows) {
                        $(this).hide();
                    }
                    if (trnum <= maxRows) {
                        $(this).show();
                    }
                });
                if (totalRows > maxRows) {
                    var pagenum = Math.ceil(totalRows / maxRows);
                    for (var i = 1; i <= pagenum;) {
                        $("." + pagination_class + " #prev")
                            .before(
                                '<li class="pointer" data-page="' +
                                i +
                                '">\
                                        <span>' +
                                i++ +
                                '<span class="sr-only"></span></span>\
                                      </li>'
                            )
                            .show();
                    }
                }
                $('.' + pagination_class + ' [data-page="1"]').addClass(
                    "active");
                $("." + pagination_class + " li").on("click", function(evt) {
                    evt.stopImmediatePropagation();
                    evt.preventDefault();
                    var pageNum = $(this).attr("data-page");
                    var maxRows = 10;
                    if (pageNum == "prev") {
                        if (lastPage == 1) {
                            return;
                        }
                        pageNum = --lastPage;
                    }
                    if (pageNum == "next") {
                        if (lastPage == $(".pagination li").length - 2) {
                            return;
                        }
                        pageNum = ++lastPage;
                    }
                    lastPage = pageNum;
                    var trIndex = 0;
                    $("." + pagination_class + " li").removeClass("active");
                    $('.' + pagination_class + ' [data-page="' + lastPage + '"]').addClass(
                        "active"
                    );
                    limitPagging(pagination_class);
                    $(table + " tr:gt(0)").each(function() {
                        trIndex++;
                        if (
                            trIndex > maxRows * pageNum ||
                            trIndex <= maxRows * pageNum - maxRows
                        ) {
                            $(this).hide();
                        } else {
                            $(this).show();
                        }
                    });
                });
                limitPagging(pagination_class);
            })
            .val(5)
            .change();
    }

    function limitPagging(pagination_class) {
        if ($("." + pagination_class + " li").length > 7) {
            if ($("." + pagination_class + " li.active").attr("data-page") <= 3) {
                $("." + pagination_class + " li:gt(5)").hide();
                $("." + pagination_class + " li:lt(5)").show();
                $('.' + pagination_class + ' [data-page="next"]').show();
            }
            if ($("." + pagination_class + " li.active").attr("data-page") > 3) {
                $("." + pagination_class + " li:gt(0)").hide();
                $('.' + pagination_class + ' [data-page="next"]').show();
                for (
                    let i =
                        parseInt($("." + pagination_class + " li.active").attr("data-page")) - 2; i <= parseInt($(
                        "." + pagination_class + " li.active").attr("data-page")) + 2; i++
                ) {
                    $('.' + pagination_class + ' [data-page="' + i + '"]').show();
                }
            }
        }
    }

    function getPaginationMyRecords(table, pagination_class) {
        var lastPage = 1;

        $("#maxRows")
            .on("change", function(evt) {
                lastPage = 1;
                $("." + pagination_class).find("li").slice(1, -1).remove();
                var trnum = 0;
                var maxRows = 10;

                if (maxRows == 5000) {
                    $("." + pagination_class).hide();
                } else {
                    $("." + pagination_class).show();
                }

                var totalRows = $(table + " tbody tr td .accordion-flush").length; // numbers of rows
                $(table + " tr td .accordion-flush:gt(0)").each(function() {
                    trnum++;
                    if (trnum > maxRows) {
                        $(this).hide();
                    }
                    if (trnum <= maxRows) {
                        $(this).show();
                    }
                });
                if (totalRows > maxRows) {
                    var pagenum = Math.ceil(totalRows / maxRows);
                    for (var i = 1; i <= pagenum;) {
                        $("." + pagination_class + " #prev")
                            .before(
                                '<li class="pointer" data-page="' +
                                i +
                                '">\
                                        <span>' +
                                i++ +
                                '<span class="sr-only"></span></span>\
                                      </li>'
                            )
                            .show();
                    }
                }
                $('.' + pagination_class + ' [data-page="1"]').addClass(
                    "active");
                $("." + pagination_class + " li").on("click", function(evt) {
                    evt.stopImmediatePropagation();
                    evt.preventDefault();
                    var pageNum = $(this).attr("data-page");
                    var maxRows = 10;
                    if (pageNum == "prev") {
                        if (lastPage == 1) {
                            return;
                        }
                        pageNum = --lastPage;
                    }
                    if (pageNum == "next") {
                        if (lastPage == $(".pagination li").length - 2) {
                            return;
                        }
                        pageNum = ++lastPage;
                    }
                    lastPage = pageNum;
                    var trIndex = 0;
                    $("." + pagination_class + " li").removeClass("active");
                    $('.' + pagination_class + ' [data-page="' + lastPage + '"]').addClass(
                        "active"
                    );
                    limitPagging(pagination_class);
                    $(table + " tr td .accordion-flush:gt(0)").each(function() {
                        trIndex++;
                        if (
                            trIndex > maxRows * pageNum ||
                            trIndex <= maxRows * pageNum - maxRows
                        ) {
                            $(this).hide();
                        } else {
                            $(this).show();
                        }
                    });
                });
                limitPagging(pagination_class);
            })
            .val(5)
            .change();
    }

    let timer = null;
    $("#winModal").on("shown.bs.modal", function(e) {
        let secs = 4;
        let timerEle = $("#winModal #timer");
        timerEle.text(4);
        timer = setInterval(() => {
            timerEle.text(secs);
            if (secs === 0) {
                clearInterval(timer);
                $("#winModal").modal("hide");
            }
            secs--;
        }, 1000);
    });
    $("#winModal").on("hide.bs.modal", function(e) {
        clearInterval(timer);
    });
    $("#loseModal").on("shown.bs.modal", function(e) {
        let secs = 4;
        let timerEle = $("#loseModal #timer");
        timerEle.text(4);
        timer = setInterval(() => {
            timerEle.text(secs);
            if (secs === 0) {
                clearInterval(timer);
                $("#loseModal").modal("hide");
            }
            secs--;
        }, 1000);
    });
    $("#loseModal").on("hide.bs.modal", function(e) {
        clearInterval(timer);
    });
    $("#winModal #closeBtn").on("click", function(e) {
        $("#winModal").modal("hide");
    });
    $("#loseModal #closeBtn").on("click", function(e) {
        $("#loseModal").modal("hide");
    });
</script>

<?php echo $__env->make('layout.footer', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>;
<?php /**PATH /home/shyambabamatka/public_html/zupitogames.com/resources/views/userDashboard/gameDashboard.blade.php ENDPATH**/ ?>