<?php
    $device = $device ?? request()->route('device') ?? 'desktop';
    
    // Normalisasi input type menjadi huruf kecil semua agar mudah dicek
    $gameTypeInput = strtolower($type ?? 'slot'); 

    // 1. Menentukan nama Class untuk tag Body
    $bodyClass = match($gameTypeInput) {
        'slot'                           => 'gameslotpage',
        'ddtogel', 'lottery'             => 'gamelotterypage',
        'livecasino', 'casino'           => 'gamelivecasinopage',
        'sports', 'sportbook'            => 'gamesportsbookpage',
        default                          => 'gameslotpage' // Fallback default
    };

    // 2. Menentukan nama file gambar header
    $headerImgName = match($gameTypeInput) {
        'slot'                           => 'slot.webp',
        'ddtogel', 'lottery'             => 'lottery.webp',
        'livecasino', 'casino'           => 'livecasino.webp',
        'sports', 'sportbook'            => 'sportsbook.webp',
        default                          => 'slot.webp' // Fallback default
    };

    // 3. Menentukan Judul Game untuk Teks (Boleh disesuaikan)
    $gameTitle = match($gameTypeInput) {
        'slot'                           => 'Slot',
        'ddtogel', 'lottery'             => 'DD&Togel',
        'livecasino', 'casino'           => 'Live Casino',
        'sports', 'sportbook'            => 'Sports',
        default                          => ucfirst($gameTypeInput)
    };

    $headerImgUrl = "https://www.pedulisuster123.com/assets/brand/header/gold_ID/{$headerImgName}?v=2";

    $gameType = ucfirst(str_replace('livecasino', 'Live Casino', $type ?? 'Slot')); 
?>
<?php $__env->startSection('body_class', $bodyClass); ?>
<?php $__env->startSection('content'); ?>
<div class="middlebackground background-design5">
    <div role="main" class="container">
        <div class="row">
            
            
            <div class="headerimg img-center">
                
                <img class="img-responsive img-center" 
                     title="<?php echo e($gameType); ?>" 
                     alt="<?php echo e($gameType); ?>" 
                     src="<?php echo e($headerImgUrl); ?>"
                     onerror="this.src='https://www.pedulisuster123.com/assets/brand/header/gold_ID/slot.webp?v=2';" />
            </div>
            
            <div class="col-xs-12 main-content">
                <div class="content slot-content">
                    
                    
                    <div class="content-header slot-content-header game-content-header">
                        <div class="content-title slot-title game-title-header">
                            <h4 class="game-title"><?php echo e($gameType); ?></h4>
                            <div class="input-form-group search-form">
                                <input type="text" id="inputSearchGame" class="form-control" autocomplete="off" placeholder="Search Provider" onkeypress="return event.keyCode !== 13;">
                                <button id="btnsearchgame" class="btn btn-default" type="button" onclick="updateSearchProvider();">
                                    <span class="fa-solid fa-magnifying-glass"></span>
                                </button>
                            </div>
                        </div>
                    </div>
                    
                    
                    <div class="content-body slot-content-body enable-search">
                        
                        
                        <div class="loader loader-d-n">
                            <img src="<?php echo e(asset('assets/images/loading.gif')); ?>" alt="loading"/>
                        </div>
                        
                        <ul class="gamecontent-menu gameprovider-menu" id="providerList">
                            <?php $__empty_1 = true; $__currentLoopData = $providers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $provider): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <li class="gameprovider-d-min-2 gameprovider-item" data-provider-name="<?php echo e(strtolower($provider->provider_name)); ?>">
                                    
                                    <a class="gameprovider-content" href="<?php echo e(url("/{$device}/game/{$type}/{$provider->slug}")); ?>">
                                        
                                        
                                        <img alt="<?php echo e($provider->provider_name); ?> BG" class="img-responsive img-center layer-1" src="<?php echo e(asset('assets/brand/game/2/Color_Gold_ID.webp')); ?>?v=2" />
                                        
                                        
                                        <img alt="<?php echo e($provider->provider_name); ?>" title="<?php echo e($provider->provider_name); ?>" class="img-responsive img-center layer-2" 
                                             src="<?php echo e(!empty($provider->icon) ? asset($provider->icon) : asset($provider->mt_logo)); ?>" />
                                             
                                    </a>
                                </li>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <div class="col-xs-12 text-center" style="padding: 20px; color: #fff;">
                                    Provider untuk kategori ini belum tersedia.
                                </div>
                            <?php endif; ?>
                        </ul>

                        
                        <div id="noProviderFound" style="display: none; text-align: center; padding: 20px; color: #fff;">
                            Provider tidak ditemukan.
                        </div>
                        
                    </div>
                    
                </div>
            </div>

        </div>
    </div>
</div>

<?php $__env->stopSection(); ?>

<?php $__env->startPush('script'); ?>
<script>
    // ==========================================
    // FUNGSI PENCARIAN PROVIDER (SEARCH BAR)
    // ==========================================
    function updateSearchProvider() {
        let searchQuery = document.getElementById('inputSearchGame').value.toLowerCase();
        let providerItems = document.querySelectorAll('#providerList .gameprovider-item');
        let hasVisibleProvider = false;
        
        providerItems.forEach(function(item) {
            let providerName = item.getAttribute('data-provider-name');
            
            // Jika nama provider mengandung kata kunci, tampilkan
            if (providerName.includes(searchQuery)) {
                item.style.display = ""; 
                hasVisibleProvider = true;
            } else {
                item.style.display = "none"; // Sembunyikan jika tidak cocok
            }
        });

        // Menampilkan teks "Tidak Ditemukan" jika semua provider disembunyikan
        document.getElementById('noProviderFound').style.display = hasVisibleProvider ? 'none' : 'block';
    }

    // Eksekusi pencarian secara realtime saat pengguna mengetik
    document.addEventListener("DOMContentLoaded", function() {
        let searchInput = document.getElementById('inputSearchGame');
        if (searchInput) {
            searchInput.addEventListener('keyup', function() {
                updateSearchProvider();
            });
        }
    });
</script>
<?php $__env->stopPush(); ?>
<?php echo $__env->make('frontend.desktop.layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /www/wwwroot/website/sewa/dragon158/resources/views/frontend/desktop/pages/game/provider.blade.php ENDPATH**/ ?>