<?php

require __DIR__ . '/common.php';
use Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\f1346478e91df21aff77c1e1db9ef4c7;
use Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\U7b1423316998af8498523ab49b7053e6\a5e3856195119993f5ad9708ea2ca291;
use Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\B4291b8d8fa2d898727b1f446db1e661e;
use Ministra\Lib\Theme;
use Ministra\Lib\User;
\Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\U7b1423316998af8498523ab49b7053e6\a5e3856195119993f5ad9708ea2ca291::J3f6d8bde0536a76e446dd756e2d032ab('STB Api' . __FILE__);
if (empty($_GET['resolution'])) {
    exit;
}
$default_theme = \Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\B4291b8d8fa2d898727b1f446db1e661e::getInstance()->from('settings')->get()->first('default_template');
if (!empty($_GET['uid'])) {
    $user = \Ministra\Lib\User::getInstance((int) $_GET['uid']);
    $default_theme = \Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\B4291b8d8fa2d898727b1f446db1e661e::getInstance()->from('settings')->get()->first('default_template');
    $themes = \Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\f1346478e91df21aff77c1e1db9ef4c7::j80568036b2fef2532e0629d69c08cf05();
    if ($default_theme == 'smart_launcher') {
        foreach ($themes as $theme_name => $theme) {
            if (\strpos($theme_name, 'smart_launcher') === 0) {
                $default_theme = $theme_name;
                break;
            }
        }
    }
    $default_theme = $default_theme == 'smart_launcher' ? 'default' : $default_theme;
    $profile = $user->getProfile();
    if (empty($profile['theme'])) {
        $user_theme = $default_theme;
    } elseif (!\array_key_exists($profile['theme'], $themes) && $profile['theme'] != 'smart_launcher') {
        $user_theme = $default_theme;
    } elseif ($profile['theme'] == 'smart_launcher') {
        foreach ($themes as $theme_name => $theme) {
            if (\strpos($theme_name, 'smart_launcher') === 0) {
                $user_theme = $theme_name;
            }
        }
        $user_theme = $default_theme;
    } else {
        $user_theme = $profile['theme'];
    }
} else {
    $user_theme = $default_theme;
}
$user_theme = \str_replace('smart_launcher:', '', $user_theme);
$theme = new \Ministra\Lib\Theme($user_theme);
$theme->setScreenHeight((int) $_GET['resolution']);
\header('Location: ' . $theme->getCssUrl(), \true, 307);
