<?php

require __DIR__ . '/config/autoload.php';
use Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\K131970f0a776522b1a53ba419cd5e32c;
use Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\U7b1423316998af8498523ab49b7053e6\eca7be640b6f19e3aa662777be52eba5;
use Silex\Application;
\set_error_handler(function ($errno, $errstr, $errfile, $errline, $errcontext) {
    \Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\U7b1423316998af8498523ab49b7053e6\eca7be640b6f19e3aa662777be52eba5::V7c2592e4addccce76be41562232fe2a1($errno, $errstr, $errfile, $errline, $errcontext);
}, \E_ALL);
\set_exception_handler(function (\Throwable $t) {
    \Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\U7b1423316998af8498523ab49b7053e6\eca7be640b6f19e3aa662777be52eba5::a8363ca17f2a548ee4a0b2300aa46df8($t);
});
$_SERVER['TARGET'] = 'ADM';
$locales = [];
$allowed_locales = \Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\K131970f0a776522b1a53ba419cd5e32c::get('allowed_locales');
foreach ($allowed_locales as $lang => $locale) {
    $locales[\substr($locale, 0, 2)] = $locale;
}
$accept_language = !empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : \null;
if (!empty($_COOKIE['language']) && (\array_key_exists($_COOKIE['language'], $locales) || \in_array($_COOKIE['language'], $locales))) {
    $language = \substr($_COOKIE['language'], 0, 2);
} else {
    if ($accept_language && \array_key_exists(\substr($accept_language, 0, 2), $locales)) {
        $language = \substr($accept_language, 0, 2);
    } else {
        $language = \key($locales);
    }
}
$locale = $locales[$language];
if (!\headers_sent()) {
    \setcookie('debug_key', '', \time() - 3600, '/');
    \setlocale(\LC_MESSAGES, $locale);
    \setlocale(\LC_TIME, $locale);
    \putenv('LC_MESSAGES=' . $locale);
    \bindtextdomain('stb', \PROJECT_PATH . '/locale');
    \textdomain('stb');
    \bind_textdomain_codeset('stb', 'UTF-8');
}
$app = new \Silex\Application();
$app['allowed_locales'] = $allowed_locales;
$app['language'] = $language;
$app['js_validator_language'] = \in_array($language, ['pt', 'ro', 'dk', 'no', 'nl', 'cz', 'ca', 'ru', 'it', 'fr', 'de', 'se', 'en', 'pt']) ? $language : 'en';
$app['lang'] = $lang = [$language];
$app['used_locale'] = $locale;
$app['debug'] = \Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\K131970f0a776522b1a53ba419cd5e32c::getSafe('admin_panel_debug', \false);
require __DIR__ . '/config/prod.php';
if ($app['debug']) {
    require __DIR__ . '/config/dev.php';
}
if ($app->offsetExists('test') && $app['test'] && \is_file($file = __DIR__ . '/config/test.php')) {
    require __DIR__ . '/config/test.php';
}
require __DIR__ . '/config/providers.php';
require 'controllers.php';
return $app;
