<?php

include './common.php';
use Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\b0144dbc621686d5838378f3b96bd17b;
use Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\d3507c2999d38573a0a0c91771d70af2;
use Ministra\Lib\Theme;
use Ministra\Lib\User;
\Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\bb5983936c5682303b7e1f00d856be9f('STB Api', __FILE__);
if (empty($_GET['resolution'])) {
    exit;
}
$default_theme = \Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\d3507c2999d38573a0a0c91771d70af2::getInstance()->from('settings')->get()->first('default_template');
if (!empty($_GET['uid'])) {
    $user = \Ministra\Lib\User::getInstance((int) $_GET['uid']);
    $default_theme = \Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\d3507c2999d38573a0a0c91771d70af2::getInstance()->from('settings')->get()->first('default_template');
    $themes = \Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\b0144dbc621686d5838378f3b96bd17b::b472d720cadb27c7cc77c19e951e23a4();
    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);
