<?php require PATH . '/theme/view/common/head.php'; ?>
<?php require PATH . '/theme/view/common/header.php'; ?>
<?php 

    $ProfileRank    = ranked((int)$Listing['xp'],$Rank); 
    $ArrayId        = array_search($ProfileRank['level'], array_column($Rank, 'level'))+1;
    $ArrayId        = ($ArrayId >= count($Rank) ? array_key_last($Rank) : $ArrayId);
    if(isset($ArrayId) AND $ArrayId < count($Rank)){
        $NextRank           = $Rank[$ArrayId];
        if($Listing['xp'] > $NextRank['xp']) {
            $ProgressBar  = 100;
        } else {
            $ProgressBar  = 100 * ((int)$Listing['xp'] - $ProfileRank['xp']) / ($NextRank['xp'] - $ProfileRank['xp']);  
        }
    }
?>
<div class="layout-section">
    <div class="container">
        <div class="row gx-lg-5">
            <div class="col-lg-3">
                <div class="card mb-4">
                    <div class="card-body text-center py-lg-6">
                        <?php echo gravatar($Listing['id'],$Listing['username'],$Listing['avatar'],'avatar avatar-2xl rounded-circle text-white fs-lg mb-3',$Listing['color']);?>
                        <h1 class="h4 mb-2">
                            <?php echo $Listing['username'];?>
                        </h1>
                        <?php if(isset($Listing['about'])) { ?>
                        <div class="mb-2 d-block text-muted fs-sm">
                            <?php echo $Listing['about'];?>
                        </div>
                        <?php } ?>
                    </div>
                </div>
            </div>
            <div class="col-lg-9">
                <?php if(empty($Route->params->tab)) { ?>
                <?php require PATH . '/theme/view/common/profile.overview.php'; ?>
                <?php } elseif(isset($Route->params->tab) AND in_array($Route->params->tab,array('playing','like','comments'))) { ?>
                <?php require PATH . '/theme/view/common/profile.'.$Route->params->tab.'.php'; ?>
                <?php } else { ?>
                <?php header('location:'.APP.'/404');?>
                <?php } ?>
            </div>
        </div>
    </div>
</div>
<?php require PATH . '/theme/view/common/javascript.php'; ?>
<?php require PATH . '/theme/view/common/footer.php'; ?>