<?php
function header_6in1()
{
?>
    <div class="filter-box" id="filter-box-on-pc">
        <div class="filter-row-wrap filter-all-hot">
            <div class="all-hot-text">
                <div class="filter-heading d-flex ai-c"><img alt=""
                        src="<?= IMGS3_PLUGINS ?>/6in1_iframe/assets/svg/Football.svg"><span
                        class="bold-title" style="padding: 0px 10px;"><?php esc_html_e('BÓNG ĐÁ', 'sport') ?></span><span
                        class="small"> <?php esc_html_e('Ẩn', 'sport') ?> <span
                            class="red"
                            style="text-align: center; display: inline-block;">0</span> <?php esc_html_e('trận', 'sport') ?> <span
                            class="cursor f11">[<?php esc_html_e('Hiển thị tất cả', 'sport') ?>]</span></span></div>
            </div>
        </div>
        <div class="filter-row"><!----></div>
        <div class="filter-row-wrap filter-date-bet">
            <div class="filter-row-date">
                <div class="llx d-flex ai-c"><a class="btn-item-now ttnow"><span class="img-text"><img
                                src="<?= IMGS3_PLUGINS ?>/6in1_iframe/assets/svg/live1.svg"
                                alt=""><?php esc_html_e('Kèo trực tuyến', 'sport') ?></span></a><a
                        class="btn-item-now active"><?php esc_html_e('Hôm nay', 'sport') ?></a><a
                        class="btn-item-now"><?php esc_html_e('Ngày mai', 'sport') ?></a><a
                        class="btn-item-now"><?php echo date('d/m', strtotime(date('y-m-d') . ' +2 days')) ?></a><a
                        class="btn-item-now"><?php echo date('d/m', strtotime(date('y-m-d') . ' +3 days')) ?></a><a
                        class="btn-item-now"><?php echo date('d/m', strtotime(date('y-m-d') . ' +4 days')) ?></a><a
                        class="btn-item-now"><?php echo date('d/m', strtotime(date('y-m-d') . ' +5 days')) ?></a><a
                        class="btn-item-now"><?php echo date('d/m', strtotime(date('y-m-d') . ' +6 days')) ?></a>
                </div>
            </div>
        </div>
        <div class="filter-row-wrap filter-all-hot filter-second">
            <div class="all-hot-filter">
                <div class="d-flex xll-r">
                    <div class="button-df"> <?php esc_html_e('Trận Hot', 'sport') ?></div><!---->
                    <div class="filter-row filter-search-row filter-third">
                        <div class="filter-cup-match">
                            <div id="selectLeague" class="custom-select-02 filter-cup-match-box">
                                <div class="custom-select"><?php esc_html_e('Tất cả giải đấu', 'sport') ?></div>
                            </div>
                        </div>
                        <div class="custom-select-02 button-df mw-100 sixmix min123px filter-select-rate">
                            <div class="custom-select"><?php esc_html_e('TL Malaysia', 'sport') ?></div>
                        </div>
                        <div class="custom-select-02 button-df mw-100 sixmix filter-select-company">
                            <div class="custom-select six-in-one-custom-select">Sbobet</div>
                        </div>
                        <div class="custom-select-02 button-df mw-100 sixmix change-type min126px">
                            <div class="custom-select"><?php esc_html_e('Hai dòng kèo', 'sport') ?></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="filter-box" id="filter-box-on-mobile">
        <div class="filter-row-wrap filter-all-hot">
            <div class="all-hot-filter">
                <div class="d-flex xll-r">
                    <div class="button-df"> <?php esc_html_e('Trận Hot', 'sport') ?></div><!---->
                    <div class="filter-row filter-search-row">
                        <div class="filter-cup-match">
                            <div id="selectLeague" class="custom-select-02 filter-cup-match-box">
                                <div class="custom-select"><?php esc_html_e('Tất cả giải đấu', 'sport') ?></div>
                            </div>
                        </div>
                    </div>
                    <div class="filter-row-select">
                        <div class="custom-select-02 button-df mw-100 sixmix min123px filter-select-rate">
                            <div class="custom-select"><?php esc_html_e('TL Hồng Kông', 'sport') ?></div>
                        </div>
                        <div class="custom-select-02 button-df mw-100 sixmix filter-select-company">
                            <div class="custom-select six-in-one-custom-select">Sbobet</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="filter-row-wrap filter-date-bet">
            <div class="filter-row-date">
                <div class="llx d-flex ai-c"><a class="btn-item-now ttnow"><span class="img-text"><img
                                src="<?= IMGS3_PLUGINS ?>/6in1_iframe/assets/svg/live1.svg"
                                alt=""><?php esc_html_e('Kèo trực tuyến', 'sport') ?></span></a><a
                        class="btn-item-now active"><?php esc_html_e('Hôm nay', 'sport') ?></a><a
                        class="btn-item-now"><?php esc_html_e('Ngày mai', 'sport') ?></a><a
                        class="btn-item-now"><?php echo date('d/m', strtotime(date('y-m-d') . ' +2 days')) ?></a><a
                        class="btn-item-now"><?php echo date('d/m', strtotime(date('y-m-d') . ' +3 days')) ?></a>
                </div>
            </div>
        </div>
    </div>
    <?php
}

function fetchdata6in1($leagues = '', $nations = '')
{
    $hideDetail = (int)(true == get_option('Checkbox_hide_action_sp', false));
    $assets_root = trailingslashit(dirname(dirname(dirname(dirname(plugin_dir_url(__FILE__)))))) . 'assets/';
    $timestamp = time();
    $dateNow = new DateTime();
    $url = DB_DOMAIN . '/ajax/v2/soccer-ajax-6in1?date=' . $dateNow->format('Y-m-d') . '&companyid=8&timezone=7&timestamp=' . $timestamp;


    $response = wp_remote_get($url, [
        'headers' => [
            'Referer' => home_url(),
        ],
        'timeout' => 60,
        'sslverify' => false,
        'curl' => [
            CURLOPT_SSL_VERIFYPEER => 0,
        ],
    ]);

    if (is_wp_error($response)) {
        return 'Error fetching data: ' . $response->get_error_message();
    }

    $body = wp_remote_retrieve_body($response);

    $data = json_decode($body, true);


    if (json_last_error() !== JSON_ERROR_NONE) {
        return 'Error decoding JSON: ' . json_last_error_msg();
    }
    $urlCountry = DB_DOMAIN . '/ajax/league-ajax';
    $responseCountry = wp_remote_get($urlCountry, [
        'headers' => [
            'Referer' => home_url(),
        ],
        'timeout' => 60,
        'sslverify' => false,
        'curl' => [
            CURLOPT_SSL_VERIFYPEER => 0,
        ],
    ]);
    $bodyCountry = wp_remote_retrieve_body($responseCountry);
    $dataCountry = json_decode($bodyCountry, true);
    $resLeagues = $dataCountry['league'] ?? [];

    $leaguesL = array_filter(explode(',', $leagues ?? $_GET['leagues'] ?? ""));
    $nationsL = array_filter(explode(',', $nations ?? $_GET['nations'] ?? ""));
    $filterL = [];
    if (count($leaguesL) > 0) {
        $filterL = $leaguesL;
    }
    if (count($nationsL) > 0) {
        foreach ($resLeagues as $l) {
            if (in_array($l['idCountry'], $nationsL)) {
                $filterL[] = $l['sclassID'];
            }
        }
    }

    $filterL = array_map('absint', $filterL);


    if (isset($data['data']) && is_array($data['data'])) {
        $dataRender = [];
        $betMatchCount = 0;
        $maxOption = get_option('max_leagues_sixinone');
        $maxBetCount = !empty($maxOption) ? $maxOption : 10;



        foreach ($data['data'] as $item) {
            $sclassID = $item['sclassID'];
            if (!empty($filterL)) {
                if (in_array($sclassID, $filterL)) {

                    if ($betMatchCount == $maxBetCount) {
                        break;
                    }

                    if (!isset($dataRender[$sclassID])) {
                        $dataRender[$sclassID] = [
                            'sclassID' => $item['sclassID'],
                            'name' => $item['name'],
                            'logo' => $item['logo'],
                            'sort_name' => $item['sort_name'],
                            'kind' => $item['kind'],
                            'matches' => [],
                        ];
                    }

                    $dataRender[$sclassID]['matches'][] = $item;

                    $betMatchCount++;
                }
            } else {
                if ($betMatchCount == $maxBetCount) {
                    break;
                }

                if (!isset($dataRender[$sclassID])) {
                    $dataRender[$sclassID] = [
                        'sclassID' => $item['sclassID'],
                        'name' => $item['name'],
                        'logo' => $item['logo'],
                        'sort_name' => $item['sort_name'],
                        'kind' => $item['kind'],
                        'matches' => [],
                    ];
                }

                $dataRender[$sclassID]['matches'][] = $item;

                $betMatchCount++;
            }
        }

    ?>

        <div class="table-view">
            <?php foreach ($dataRender as $item):; ?>
                <?php

                $dataMatch = $item['matches'];
                ?>

                <div class="league-item">
                    <div class="league-item-head d-flex ai-c j-sb">
                        <div class="left_part d-flex ai-c gap-10">
                            <div class="league-logo no-image">
                                <img alt="<?php echo $item['name']; ?>"
                                    src="<?php echo IMGS3 . ($item['logo'] && $item['logo'] != '' ? $item['logo'] : '/assets/upload/football/league_match/images/icon-league-default.svg'); ?>">
                            </div>
                            <div class="league-name"><?php echo $item['name']; ?></div>
                        </div>
                        <div class="right_part d-flex ai-c" style="position: relative;">
                            <!---->
                            <div class="hover-in-a-container" data-tooltip="Ẩn tất cả trận đấu của giải đấu này"><span>
                                    <div
                                        class="swt"></div>
                                </span>
                            </div>
                        </div>
                    </div>


                    <div class="match-list-head d-flex ai-c">
                        <div class="w-60 text-center"><span
                                class="title-small"> <?php esc_html_e('Thời gian', 'sport') ?> </span>
                        </div>
                        <div class="w-score text-center"><span
                                class="title-small"> <?php esc_html_e('Tỷ số', 'sport') ?> </span>
                        </div>
                        <div class="w-score text-center corner-col">
                            <span class="title-small"></span>
                        </div>
                        <div class="info-teams text-center a-two-bet"><span
                                class="title-small"> <?php esc_html_e('Đội bóng', 'sport') ?> </span>
                        </div>
                        <div class="odds-title text-center head full-game fwrap-wrap two-line-bet">
                            <div class="odds-title-head"><span
                                    class="title-small"> <?php esc_html_e('Toàn trận', 'sport') ?> </span>
                            </div>
                            <div class="d-flex odds-title-items">
                                <div class="odds-title-item two-line-start"><?php esc_html_e('Cược Chấp', 'sport') ?></div>
                                <div class="odds-title-item two-line-start"><?php esc_html_e('Tài Xỉu', 'sport') ?></div>
                                <div class="odds-title-item two-line-end">1x2</div>
                            </div>
                        </div>
                        <div class="odds-title text-center head half-game fwrap-wrap two-line-bet">
                            <div class="odds-title-head"><span
                                    class="title-small"> <?php esc_html_e('Hiệp 1', 'sport') ?> </span>
                            </div>
                            <div class="d-flex odds-title-items">
                                <div class="odds-title-item two-line-start"><?php esc_html_e('Cược Chấp', 'sport') ?></div>
                                <div class="odds-title-item two-line-start"><?php esc_html_e('Tài Xỉu', 'sport') ?></div>
                                <div class="odds-title-item two-line-end">1x2</div>
                            </div>
                        </div>
                    </div>

                    <div class="d-flex bet-match-list wrap filter-type-2">
                        <?php
                        $mobileData = '';
                        foreach ($dataMatch as $item):
                            $matchitem = $item['matchData'];
                            $odd = $item['odds'];

                            $MatchState = $matchitem['MatchState'];

                            $statusMatch = '';
                            $classMatch = '';
                            if ((int)$MatchState < 4 && (int)$MatchState > 0) {
                                $statusMatch = 'Live';
                                $classMatch = 'live-status';
                            } elseif ((int)$MatchState === 0) {
                                $statusMatch = 'Sớm';
                            }


                            $timeRun = '';
                            $classMatchTime = '';
                            $date = new DateTime('now', new DateTimeZone('Asia/Ho_Chi_Minh'));
                            $timeNow = $date->getTimestamp();


                            $matchTime = isset($matchitem['matchTime2']) && $matchitem['matchTime2'] ? $matchitem['matchTime2'] : $matchitem['matchTime'];
                            $timestamp = strtotime($matchTime);


                            if ((int)$MatchState == 1 || (int)$MatchState == 3) {
                                $seconds = (int)$timeNow - (int)$timestamp;
                                $timeRun = ceil($seconds / 60);

                                if ((int)$MatchState == 3) {
                                    $timeRun = ceil($seconds / 60) + 45;
                                    if ($timeRun > 90) {
                                        $timeRun = '90+' . ($timeRun - 90);
                                    }
                                }
                                $timeRun = $timeRun . "<span class=\"blinking\">'</span>";
                                $classMatchTime = 'running';
                            } elseif ((int)$MatchState == 2) {
                                $timeRun = 'HT';
                                $classMatchTime = 'running';
                            } else {
                                $timeRun = renderTime($matchTime);
                            }

                            $scoreHome = $matchitem['HomeScore'] != '' ? $matchitem['HomeScore'] : '';
                            $scoreAway = $matchitem['GuestScore'] != '' ? $matchitem['GuestScore'] : '';

                            $guestCorner = $matchitem['guestCorner'] != '' ? $matchitem['guestCorner'] : '';
                            $homeCorner = $matchitem['homeCorner'] != '' ? $matchitem['homeCorner'] : '';

                            if ((int)$MatchState === 0) {
                                $scoreHome = '';
                                $scoreAway = '';

                                $guestCorner = '';
                                $homeCorner = '';
                            }


                            $logoHome = IMGS3 . $matchitem['HomeImage'];
                            $nameHome = $matchitem['homeTeam'];

                            $logoAway = IMGS3 . $matchitem['GuestImage'];
                            $nameAway = $matchitem['guestTeam'];


                            $hdpHome = $odd['HDP']['UpOdds_Real'] != '' ? $odd['HDP']['UpOdds_Real'] : '';
                            $hdp = $odd['HDP']['Goal_Real'] != '' ? $odd['HDP']['Goal_Real'] : '';
                            $hdpAway = $odd['HDP']['DownOdds_Real'] != '' ? $odd['HDP']['DownOdds_Real'] : '';

                            $txOdd = $odd['ou']['Goal'] != '' ? $odd['ou']['Goal'] : '';
                            $txOddOver = $odd['ou']['UpOdds'] != '' ? $odd['ou']['UpOdds'] : '';
                            $txOddUnder = $odd['ou']['DownOdds'] != '' ? $odd['ou']['DownOdds'] : '';

                            $euHome = $odd['1x2']['UpOdds_Real'] != '' ? $odd['1x2']['UpOdds_Real'] : '';
                            $euDraw = $odd['1x2']['Goal_Real'] != '' ? $odd['1x2']['Goal_Real'] : '';
                            $euAway = $odd['1x2']['DownOdds_Real'] != '' ? $odd['1x2']['DownOdds_Real'] : '';


                            $hdpHomeHt = $odd['HDPHalf']['UpOdds_Real'] != '' ? $odd['HDPHalf']['UpOdds_Real'] : '';
                            $hdpHt = $odd['HDPHalf']['Goal_Real'] != '' ? $odd['HDPHalf']['Goal_Real'] : '';
                            $hdpAwayHt = $odd['HDPHalf']['DownOdds_Real'] != '' ? $odd['HDPHalf']['DownOdds_Real'] : '';

                            $txOddHt = $odd['OUHalf']['Goal'] != '' ? $odd['OUHalf']['Goal'] : '';
                            $txOddOverHt = $odd['ou']['UpOdds'] != '' ? $odd['OUHalf']['UpOdds'] : '';
                            $txOddUnderHt = $odd['OUHalf']['DownOdds'] != '' ? $odd['OUHalf']['DownOdds'] : '';

                            $euHomeHt = $odd['1x2Half']['UpOdds_Real'] != '' ? $odd['1x2Half']['UpOdds_Real'] : '';
                            $euDrawHt = $odd['1x2Half']['Goal_Real'] != '' ? $odd['1x2Half']['Goal_Real'] : '';
                            $euAwayHt = $odd['1x2Half']['DownOdds_Real'] != '' ? $odd['1x2Half']['DownOdds_Real'] : '';; ?>
                            <div class="bet-match-item-repeated match_2708230">
                                <div class="bet-match-item d-flex live-match">
                                    <div class="bet-match-item-info">
                                        <div class="d-flex bet-match-item-child bdbt-gr">
                                            <div class="w-60 d-flex ai-c jc-c wrap gap-4 align-content-center text-center">
                                                <div class="res-container">
                                                    <div class="w-score text-center score-lst d-flex ai-c jc-c wrap align-content-center"
                                                        style="gap: 2px;">
                                                        <div class="home-score score hscrore_2780828"
                                                            style="font-size: 16px;"><?php echo $scoreHome; ?></div>
                                                        <div class="home-score score" style="font-size: 16px;">-</div>
                                                        <div class="home-score score gscrore_2780828"
                                                            style="font-size: 16px;"><?php echo $scoreAway; ?></div>
                                                    </div>
                                                </div>
                                                <div class="w-100 <?php echo $classMatch; ?>">
                                                    <?php echo $statusMatch; ?>
                                                </div>
                                                <div class="w-100 match-during-time matchtime_2708228 <?php echo $classMatchTime; ?>">
                                                    <?php echo $timeRun; ?>
                                                </div>
                                            </div>

                                            <div class="w-score text-center score-lst d-flex ai-c jc-c wrap align-content-center"
                                                style="gap: 2px;">
                                                <div class="home-score score hscrore_2780828"
                                                    style="font-size: 16px;"><?php echo $scoreHome; ?></div>
                                                <div class="home-score score" style="font-size: 16px;">-</div>
                                                <div class="home-score score gscrore_2780828"
                                                    style="font-size: 16px;"><?php echo $scoreAway; ?></div>
                                            </div>
                                            <div class="w-score text-center score-lst d-corner ai-c jc-c wrap align-content-center"
                                                style="gap: 2px;">
                                                <div class="home-corner score hscrore_2780828"
                                                    style="color: rgb(255, 128, 0); font-weight: bold; font-size: 12px;"><?= $homeCorner ?></div>
                                                <div class="odd-line"
                                                    style="color: rgb(255, 128, 0); font-weight: bold; font-size: 12px;">
                                                    -
                                                </div>
                                                <div class="home-corner score gscrore_2780828"
                                                    style="color: rgb(255, 128, 0); font-weight: bold; font-size: 12px;"><?= $guestCorner ?></div>
                                            </div>
                                            <div class="info-teams d-flex ai-c jc-c wrap gap-12 align-content-center a-two-bet">
                                                <div class="home-team team-name w-100">
                                                    <img class="t-logo" src="<?php echo $logoHome; ?>"
                                                        alt="<?php echo $nameHome; ?>">
                                                    <span class="t-name"><?php echo $nameHome; ?></span>
                                                </div>
                                                <div class="guest-team team-name w-100">
                                                    <img class="t-logo" src="<?php echo $logoAway; ?>"
                                                        alt="<?php echo $nameAway; ?>">
                                                    <span class="t-name"><?php echo $nameAway; ?></span>
                                                </div>
                                            </div>
                                            <div class="odds-title two-line-bet item-ods text-center d-flex">
                                                <div class="odds-title-item d-flex align-content-center jc-c two-line-start">
                                                    <div class="odds normal d-flex justify-content-between">
                                                        <span class="grey"></span>
                                                        <span><strong><?php echo $hdpHome; ?></strong></span>
                                                    </div>
                                                    <div class="odds normal d-flex justify-content-between">
                                                        <span class="grey"><?php echo $hdp; ?></span>
                                                        <span><strong><?php echo $hdpAway; ?></strong></span>
                                                    </div>
                                                    <div class="odds normal d-flex justify-content-between opacity-0">
                                                        <span></span>
                                                        <span><strong></strong></span>
                                                    </div>
                                                </div>
                                                <div class="odds-title-item d-flex align-content-center jc-c two-line-start">
                                                    <div class="odds normal d-flex justify-content-between">
                                                        <span class="grey"><?php echo $txOdd; ?></span>
                                                        <span>O</span>
                                                        <span><strong><?php echo $txOddUnder; ?></strong></span>
                                                    </div>
                                                    <div class="odds normal d-flex justify-content-between">
                                                        <span>&nbsp;</span>
                                                        <span>U</span>
                                                        <span><strong><?php echo $txOddOver; ?></strong></span>
                                                    </div>
                                                    <div class="odds normal d-flex justify-content-between opacity-0">
                                                        <span>0.86</span>
                                                        <span><strong>-0.99</strong></span>
                                                    </div>
                                                </div>
                                                <div class="odds-title-item d-flex align-content-center jc-c two-line-end">
                                                    <div class="odds normal">
                                                        <span><strong><?php echo $euHome; ?></strong></span>
                                                    </div>
                                                    <div class="odds normal">
                                                        <span><strong><?php echo $euDraw; ?></strong></span>
                                                    </div>
                                                    <div class="odds normal">
                                                        <span><strong><?php echo $euAway; ?></strong></span>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="odds-title two-line-bet item-ods text-center d-flex">
                                                <div class="odds-title-item d-flex align-content-center jc-c two-line-start">
                                                    <div class="odds normal d-flex justify-content-between">
                                                        <span class="grey"></span>
                                                        <span><strong><?php echo $hdpHomeHt; ?></strong></span>
                                                    </div>
                                                    <div class="odds normal d-flex justify-content-between">
                                                        <span class="grey"><?php echo $hdpHt; ?></span>
                                                        <span><strong><?php echo $hdpAwayHt; ?></strong></span>
                                                    </div>
                                                    <div class="odds normal d-flex justify-content-between opacity-0">
                                                        <span></span>
                                                        <span><strong></strong></span>
                                                    </div>
                                                </div>
                                                <div class="odds-title-item d-flex align-content-center jc-c two-line-start">
                                                    <div class="odds normal d-flex justify-content-between">
                                                        <span class="grey"><?php echo $txOddHt; ?></span>
                                                        <span><?php echo $txOddOverHt; ?></span>
                                                        <span><strong><?php echo $txOddUnderHt; ?></strong></span>
                                                    </div>
                                                    <div class="odds normal d-flex justify-content-between">
                                                        <span>&nbsp;</span>
                                                        <span>U</span>
                                                        <span><strong>1</strong></span>
                                                    </div>
                                                    <div class="odds normal d-flex justify-content-between opacity-0">
                                                        <span>0.86</span>
                                                        <span><strong>-0.99</strong></span>
                                                    </div>
                                                </div>
                                                <div class="odds-title-item d-flex align-content-center jc-c two-line-end">
                                                    <div class="odds normal">
                                                        <span><strong><?php echo $euHomeHt; ?></strong></span>
                                                    </div>
                                                    <div class="odds normal">
                                                        <span><strong><?php echo $euDrawHt; ?></strong></span>
                                                    </div>
                                                    <div class="odds normal">
                                                        <span><strong><?php echo $euAwayHt; ?></strong></span>
                                                    </div>
                                                </div>
                                            </div>


                                        </div>
                                        <div class="d-flex ai-c j-sb h-30">
                                            <div <?php if ($hideDetail): ?> style="visibility: hidden;" <?php endif; ?>
                                                class="action-list d-flex ai-c"><span title="Chi tiết"><img alt=""
                                                        class="cursor icon-14 icon-change-color"
                                                        src="<?= IMGS3_PLUGINS ?>/6in1_iframe/assets/svg/team-icon-new.svg"></span><span
                                                    title="Phân tích"><img alt=""
                                                        class="cursor icon-16 icon-change-color"
                                                        src="<?= IMGS3_PLUGINS ?>/6in1_iframe/assets/svg/data-analist-new.svg"></span><span
                                                    title="Trực tiếp"><img alt="" class="cursor icon-16"
                                                        src="<?= IMGS3_PLUGINS ?>/6in1_iframe/assets/svg/live-new.svg"></span>
                                            </div>
                                            <div class="toggle-bet d-flex ai-c j-sb cursor">
                                                <div class=""><span>7</span> <?php esc_html_e('kèo', 'sport') ?></div>
                                                <div class="toggle-icon d-flex ai-c"><img class="cursor icon-16"
                                                        src="<?= IMGS3_PLUGINS ?>/6in1_iframe/assets/svg/down.svg">
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <?php ob_start(); ?>
                            <div class="match-list-box-repeated-sm match_sm_2696410 live-match">
                                <div class="match-list-top-sm">
                                    <div class="d-flex justify-content-between match-list-top-top-sm top-ctn">
                                        <div class="match-list-top-top-right-sm">
                                            <div>
                                                <div class="action-list d-flex ai-c">
                                                    <span title="Chi tiết">
                                                        <img alt="Chi tiết" class="cursor icon-14 icon-change-color"
                                                            src="<?= $assets_root ?>images/team-icon.svg">
                                                    </span>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="match-list-top-top-left-sm">
                                            <div class="live-on-mobile <?php echo $statusMatch; ?>">
                                                <svg width="12" height="12" viewBox="0 0 12 12" fill="none"
                                                    xmlns="http://www.w3.org/2000/svg"
                                                    xmlns:xlink="http://www.w3.org/1999/xlink">
                                                    <rect width="12" height="12"
                                                        fill="url(#pattern0_2455_12300)"></rect>
                                                    <defs>
                                                        <pattern id="pattern0_2455_12300"
                                                            patternContentUnits="objectBoundingBox" width="1"
                                                            height="1">
                                                            <use xlink:href="#image0_2455_12300"
                                                                transform="scale(0.00390625)"></use>
                                                        </pattern>
                                                        <image id="image0_2455_12300" width="256" height="256"
                                                            preserveAspectRatio="none"
                                                            xlink:href="data:image/png;base64, "></image>
                                                    </defs>
                                                </svg>
                                                <div class=""> Live</div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="match-list-top-main-sm">
                                        <div class="match-list-top-main-time-sm">
                                            <div class="w-100 match-during-time matchtime_2726296 <?php echo $classMatchTime; ?>">
                                                <?php echo $timeRun; ?>
                                            </div>
                                        </div>


                                        <div class="match-list-top-main-two-sm">
                                            <div class="mt-left mt-left-2">
                                                <div class="home-team team-name w-100" title="<?= $nameHome; ?>">
                                                    <span class="t-name"><?= $nameHome; ?></span>
                                                    <img loading="lazy" alt="t logo" class="t-logo"
                                                        src="<?= $logoHome; ?>">
                                                </div>
                                            </div>
                                            <div class="mt-center">
                                                <div class="w-score text-center score-lst d-flex ai-c jc-c wrap align-content-center"
                                                    style="gap: 2px;">
                                                    <div class="home-score score hscrore_2726298"
                                                        style="font-size: 16px;"><?= $scoreHome == '-' ? '' : $scoreHome ?></div>
                                                    <div class="home-score score" style="font-size: 16px;">-</div>
                                                    <div class="home-score score gscrore_2726298"
                                                        style="font-size: 16px;"><?= $scoreAway == '-' ? '' : $scoreAway ?></div>
                                                </div>
                                                <div class="w-score text-center score-lst d-corner ai-c jc-c wrap align-content-center"
                                                    style="gap: 2px;">
                                                    <div class="home-corner score hscrore_2726298"
                                                        style="color: rgb(255, 128, 0); font-weight: bold; font-size: 12px;">
                                                        2
                                                    </div>
                                                    <div class="odd-line"
                                                        style="color: rgb(255, 128, 0); font-weight: bold; font-size: 12px;">
                                                        -
                                                    </div>
                                                    <div class="home-corner score gscrore_2726298"
                                                        style="color: rgb(255, 128, 0); font-weight: bold; font-size: 12px;">
                                                        3
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="mt-right mt-right-2">
                                                <div class="guest-team team-name w-100" title="<?= $nameAway; ?>">
                                                    <img loading="lazy" alt="t logo" class="t-logo"
                                                        src="<?= $logoAway; ?>">
                                                    <span class="t-name"><?= $nameAway; ?></span>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="w-score text-center score-lst d-corner d-2 ai-c jc-c wrap align-content-center"
                                            style="gap: 2px;">
                                            <svg width="12" height="12" viewBox="0 0 12 12" fill="none"
                                                xmlns="http://www.w3.org/2000/svg">
                                                <path fill-rule="evenodd" clip-rule="evenodd"
                                                    d="M6.125 0.75C6.33211 0.75 6.5 0.917893 6.5 1.125V1.64327L9.03083 2.90866C9.39803 3.09224 9.71104 3.24872 9.92887 3.40075C10.1497 3.55491 10.382 3.77875 10.382 4.125C10.382 4.47125 10.1497 4.69509 9.92887 4.84925C9.71104 5.00128 9.39803 5.15776 9.03082 5.34134L6.5 6.60673V7.25473C7.76466 7.28671 8.91537 7.47945 9.78441 7.78362C10.2598 7.95 10.6712 8.15673 10.9711 8.40491C11.2687 8.65112 11.5 8.97703 11.5 9.375C11.5 9.77297 11.2687 10.0989 10.9711 10.3451C10.6712 10.5933 10.2598 10.8 9.78441 10.9664C8.83019 11.3004 7.53638 11.5 6.125 11.5C4.71362 11.5 3.41981 11.3004 2.46558 10.9664C1.99021 10.8 1.57877 10.5933 1.27885 10.3451C0.98132 10.0989 0.75 9.77297 0.75 9.375C0.75 8.97703 0.98132 8.65112 1.27885 8.40491C1.57877 8.15673 1.99021 7.95 2.46558 7.78362C3.33463 7.47945 4.48534 7.28671 5.75 7.25473V6.3858C5.7498 6.37878 5.7498 6.37177 5.75 6.36478V1.88522C5.7498 1.87823 5.7498 1.87122 5.75 1.8642V1.125C5.75 0.917893 5.91789 0.75 6.125 0.75ZM6.5 2.48179V5.76821L8.66841 4.68402C9.0701 4.48318 9.33249 4.35088 9.49962 4.23423C9.57869 4.17905 9.61278 4.14346 9.62665 4.125C9.61278 4.10653 9.57869 4.07095 9.49962 4.01576C9.33249 3.89912 9.0701 3.76682 8.66841 3.56598L6.5 2.48179ZM9.63526 4.14036C9.63487 4.14032 9.63366 4.13822 9.63282 4.13418C9.63523 4.13838 9.63565 4.1404 9.63526 4.14036ZM9.63282 4.11582C9.63366 4.11178 9.63487 4.10968 9.63526 4.10964C9.63565 4.1096 9.63523 4.11162 9.63282 4.11582ZM5.75 8.00498C4.55231 8.03689 3.48873 8.22012 2.71335 8.49151C2.2839 8.64181 1.96311 8.81218 1.757 8.98273C1.5485 9.15526 1.5 9.28972 1.5 9.375C1.5 9.46028 1.5485 9.59474 1.757 9.76727C1.96311 9.93782 2.2839 10.1082 2.71335 10.2585C3.56877 10.5579 4.77495 10.75 6.125 10.75C7.47504 10.75 8.68123 10.5579 9.53665 10.2585C9.96609 10.1082 10.2869 9.93782 10.493 9.76727C10.7015 9.59474 10.75 9.46028 10.75 9.375C10.75 9.28972 10.7015 9.15526 10.493 8.98273C10.2869 8.81218 9.96609 8.64181 9.53665 8.49151C8.76127 8.22012 7.69769 8.03689 6.5 8.00498V9.125C6.5 9.33211 6.33211 9.5 6.125 9.5C5.91789 9.5 5.75 9.33211 5.75 9.125V8.00498Z"
                                                    fill="#686868"></path>
                                            </svg>
                                            <div class="home-corner score hscrore_2726296"
                                                style="color: rgb(255, 128, 0); font-weight: bold; font-size: 12px;">5
                                            </div>
                                            <div class="odd-line"
                                                style="color: rgb(255, 128, 0); font-weight: bold; font-size: 12px;">-
                                            </div>
                                            <div class="home-corner score gscrore_2726296"
                                                style="color: rgb(255, 128, 0); font-weight: bold; font-size: 12px;">2
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="match-list-main-sm">
                                    <div class="d-flex jc-c match-list-main--title">
                                        <div class="two-line-start"><?php esc_html_e('Toàn trận', 'sport') ?>
                                            -<?php esc_html_e('Cược chấp', 'sport') ?></div>
                                        <div class="two-line-start"><?php esc_html_e('Toàn trận-', 'sport') ?>
                                            -<?php esc_html_e('tài/Xỉu', 'sport') ?></div>
                                        <div class="two-line-end"><?php esc_html_e('Toàn trận', 'sport') ?>-1x2</div>
                                    </div>
                                    <div class="d-flex jc-c match-list-main--bet">
                                        <div class="odds-title-item d-flex flex-column align-content-center jc-c two-line-start">
                                            <div class="odds normal d-flex justify-content-between">
                                                <span
                                                    class="grey"></span><span><strong><?= $hdpHome ?></strong></span>
                                            </div>
                                            <div class="odds normal d-flex justify-content-between">
                                                <span
                                                    class="grey"><?= $hdp ?></span><span><strong><?= $hdpAway ?></strong></span>
                                            </div>
                                        </div>
                                        <div class="odds-title-item d-flex flex-column align-content-center jc-c two-line-start ctl">
                                            <div class="odds normal d-flex justify-content-between">
                                                <span
                                                    class="grey"><?php echo $txOdd; ?></span><span>O</span><span><strong><?php echo $txOddUnder; ?></strong></span>
                                            </div>
                                            <div class="odds normal d-flex justify-content-between">
                                                <span></span><span>U</span><span><strong><?php echo $txOddOver; ?></strong></span>
                                            </div>
                                        </div>
                                        <div class="odds-title-item d-flex flex-column align-content-center jc-c two-line-end">
                                            <div class="odds normal up">
                                                <div> Chủ</div>
                                                <?php echo $euHome; ?>
                                            </div>
                                            <div class="odds normal up">
                                                <div> Khách</div>
                                                <?php echo $euDraw; ?>
                                            </div>
                                            <div class="odds normal up">
                                                <div> Hòa</div>
                                                <?php echo $euAway; ?>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="match-list-bot-sm d-flex ai-c j-sb h-30">
                                    <div class="toggle-bet toggle-match d-flex ai-c j-sb cursor">
                                        <div class="">
                                            <strong><?php esc_html_e('Toàn trận cược Châu Á khác', 'sport') ?></strong>
                                        </div>
                                        <div class="toggle-icon d-flex ai-c">
                                            <img class="cursor icon-16"
                                                src="<?= IMGS3_PLUGINS ?>/6in1_iframe/assets/svg/down.svg">
                                        </div>
                                    </div>
                                    <div class="toggle-bet d-flex ai-c j-sb cursor">
                                        <div class=""><span>7</span> <?php esc_html_e('kèo', 'sport') ?></div>
                                        <div class="toggle-icon d-flex ai-c">
                                            <img class="cursor icon-16"
                                                src="<?= IMGS3_PLUGINS ?>/6in1_iframe/assets/svg/down.svg">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        <?php $mobileData .= ob_get_contents();
                            ob_end_clean();
                        endforeach;
                        ?>
                    </div>
                    <div class="match-list-sm">
                        <?= $mobileData ?>
                    </div>
                </div>

            <?php
            endforeach; ?>
        </div>
<?php }
}

function renderTime($time)
{
    $datetime = $time;
    $formattedTime = date('H:i', strtotime($datetime));
    return $formattedTime;
}
