#!/usr/bin/env node
/** Copyright (C) 2020-2025 Kedron Holdings LLC, All Rights Reserved. This file is part of Reactor.
 *  For info and license terms please see https://reactor.toggledbits.com/
 *  ------------------------------------------------------------------------------
*/
const a0_0xaf48a0 = a0_0x378a;
(function (_0x18cbb7, _0x255e30) {
    const _0x1545c3 = a0_0x378a, _0x8d72d0 = _0x18cbb7();
    while (!![]) {
        try {
            const _0x544870 = parseInt(_0x1545c3(0x1ca)) / 0x1 + parseInt(_0x1545c3(0x253)) / 0x2 + parseInt(_0x1545c3(0x24b)) / 0x3 * (-parseInt(_0x1545c3(0x20b)) / 0x4) + parseInt(_0x1545c3(0x1b5)) / 0x5 * (parseInt(_0x1545c3(0x211)) / 0x6) + -parseInt(_0x1545c3(0x1d3)) / 0x7 * (parseInt(_0x1545c3(0x1dd)) / 0x8) + parseInt(_0x1545c3(0x251)) / 0x9 + -parseInt(_0x1545c3(0x267)) / 0xa;
            if (_0x544870 === _0x255e30)
                break;
            else
                _0x8d72d0['push'](_0x8d72d0['shift']());
        } catch (_0x39ea51) {
            _0x8d72d0['push'](_0x8d72d0['shift']());
        }
    }
}(a0_0x47ec, 0x9030f));
const version = 0x62e9, BUILD_VERSION = 'latest-25321-fce98e53', MIN_NODE_MAJOR = 0x12, NODE_VERSIONS = {
        0x12: { 'eol': 0x1968a005600 },
        0x14: { 'eol': 0x19de1b18200 },
        0x16: { 'eol': 0x1a53962ae00 },
        0x18: { 'eol': 0x1b049cc5600 }
    }, NODE_EOL_WARNING = 0x3c;
function a0_0x378a(_0x35d497, _0x2820dd) {
    const _0x47ec21 = a0_0x47ec();
    return a0_0x378a = function (_0x378a9a, _0x1d171e) {
        _0x378a9a = _0x378a9a - 0x1b1;
        let _0x3a4559 = _0x47ec21[_0x378a9a];
        return _0x3a4559;
    }, a0_0x378a(_0x35d497, _0x2820dd);
}
if (parseInt(process[a0_0xaf48a0(0x244)]['node'][a0_0xaf48a0(0x1f1)]('.')[0x0]) < MIN_NODE_MAJOR) {
    console[a0_0xaf48a0(0x280)](a0_0xaf48a0(0x1ea), process['versions'][a0_0xaf48a0(0x1bf)], '(not\x20supported)');
    throw new Error(a0_0xaf48a0(0x1fe) + process[a0_0xaf48a0(0x244)]['node']);
}
const path = require('path'), os = require('os'), fs = require('fs');
function make_dir(_0x4bef79) {
    const _0x2ac46e = a0_0xaf48a0;
    if (!fs['existsSync'](_0x4bef79))
        return fs[_0x2ac46e(0x226)](_0x4bef79), !![];
    return ![];
}
function checkConfigDir(_0x5f483d, _0x52aa1c) {
    const _0x52315a = a0_0xaf48a0;
    make_dir(_0x5f483d) && fs['readdirSync'](_0x52aa1c)[_0x52315a(0x1d1)](_0x4b3c83 => {
        const _0x954e5b = _0x52315a;
        if (_0x4b3c83[_0x954e5b(0x1e6)](/\.(yaml|yml|json)(-dist)?$/i)) {
            const _0xc846d2 = path[_0x954e5b(0x1f3)](_0x5f483d, _0x4b3c83);
            if (!fs[_0x954e5b(0x201)](_0xc846d2))
                try {
                    fs[_0x954e5b(0x24f)](path[_0x954e5b(0x1f3)](_0x52aa1c, _0x4b3c83), _0xc846d2);
                } catch (_0x26bf2e) {
                    console[_0x954e5b(0x21f)](_0x26bf2e);
                }
        }
    });
}
let opts = {
        'noengine': ![],
        'repl': ![],
        'pidfile': ![],
        'basedir': process[a0_0xaf48a0(0x27a)]['REACTOR_HOME'] || process['cwd'](),
        'opterr': ![]
    }, argv = process['argv'][a0_0xaf48a0(0x1c3)](0x2);
while (argv[a0_0xaf48a0(0x25e)] > 0x0) {
    let arg = argv[a0_0xaf48a0(0x246)]();
    switch (arg) {
    case '-R':
        opts[a0_0xaf48a0(0x1b8)] = !![];
        break;
    case '-N':
        opts['noengine'] = !![];
        break;
    case '-d':
        opts[a0_0xaf48a0(0x264)] = argv[a0_0xaf48a0(0x246)]() || opts[a0_0xaf48a0(0x264)];
        break;
    case '-c':
        opts[a0_0xaf48a0(0x277)] = argv['shift']() || opts[a0_0xaf48a0(0x277)];
        break;
    case '-p':
        opts['pidfile'] = argv[a0_0xaf48a0(0x246)]() || a0_0xaf48a0(0x228);
        break;
    default:
        opts[a0_0xaf48a0(0x24e)] = !![], console['log']('Invalid\x20command\x20line\x20argument:', arg);
    }
}
opts['opterr'] && process['exit'](0xff);
const express = require(a0_0xaf48a0(0x213)), repl = require('repl'), basedir = path[a0_0xaf48a0(0x1f3)](opts['basedir'] || process['env'][a0_0xaf48a0(0x1ce)] || __dirname), confdir = opts[a0_0xaf48a0(0x277)] ? path[a0_0xaf48a0(0x1f3)](opts[a0_0xaf48a0(0x277)]) : path[a0_0xaf48a0(0x1f3)](process['env'][a0_0xaf48a0(0x1cd)] ? process[a0_0xaf48a0(0x27a)][a0_0xaf48a0(0x1cd)] : process[a0_0xaf48a0(0x27a)][a0_0xaf48a0(0x1b7)] ? path['resolve'](process[a0_0xaf48a0(0x27a)][a0_0xaf48a0(0x1b7)], 'config') : path[a0_0xaf48a0(0x224)](basedir, 'config'));
console[a0_0xaf48a0(0x21f)](a0_0xaf48a0(0x27d), BUILD_VERSION, 'app', version, a0_0xaf48a0(0x21e), confdir), checkConfigDir(confdir, path['join'](basedir, './dist-config'));
const Configuration = require('./server/lib/Configuration'), rcf = path['resolve'](confdir, a0_0xaf48a0(0x1f5));
let valid_config = ![], c;
try {
    c = Configuration[a0_0xaf48a0(0x25f)](a0_0xaf48a0(0x255), rcf)[a0_0xaf48a0(0x26a)](a0_0xaf48a0(0x255), a0_0xaf48a0(0x1de));
    if (!c)
        throw new Error('Configuration\x20file\x20' + rcf + a0_0xaf48a0(0x263));
    valid_config = !![];
} catch (a0_0x57ceeb) {
    console[a0_0xaf48a0(0x280)](a0_0xaf48a0(0x22c), rcf, ':', a0_0x57ceeb), console[a0_0xaf48a0(0x21f)](a0_0xaf48a0(0x23a)), c = Configuration[a0_0xaf48a0(0x25f)]('reactor', { 'reactor': { 'engine': { 'enabled': ![] } } })[a0_0xaf48a0(0x26a)]('reactor', a0_0xaf48a0(0x1de));
}
c[a0_0xaf48a0(0x264)] = basedir, c['confdir'] = confdir, c[a0_0xaf48a0(0x1d2)] = c[a0_0xaf48a0(0x1d2)] || path['resolve'](process[a0_0xaf48a0(0x27a)][a0_0xaf48a0(0x227)] ? process[a0_0xaf48a0(0x27a)][a0_0xaf48a0(0x227)] : path[a0_0xaf48a0(0x1f3)](process[a0_0xaf48a0(0x27a)]['REACTOR_DATA_PREFIX'] || basedir, a0_0xaf48a0(0x214))), c['logsdir'] = c[a0_0xaf48a0(0x248)] || path[a0_0xaf48a0(0x1f3)](process['env'][a0_0xaf48a0(0x1f7)] ? process[a0_0xaf48a0(0x27a)][a0_0xaf48a0(0x1f7)] : path[a0_0xaf48a0(0x1f3)](process[a0_0xaf48a0(0x27a)][a0_0xaf48a0(0x1b7)] || basedir, a0_0xaf48a0(0x21d))), c[a0_0xaf48a0(0x259)] = c['plugindir'] || path[a0_0xaf48a0(0x1f3)](process[a0_0xaf48a0(0x27a)][a0_0xaf48a0(0x21a)] ? process[a0_0xaf48a0(0x27a)][a0_0xaf48a0(0x21a)] : path[a0_0xaf48a0(0x1f3)](process[a0_0xaf48a0(0x27a)]['REACTOR_DATA_PREFIX'] || basedir, a0_0xaf48a0(0x206))), c['localesdir'] = c[a0_0xaf48a0(0x21c)] || path[a0_0xaf48a0(0x1f3)](process[a0_0xaf48a0(0x27a)]['REACTOR_PLUGIN_PREFIX'] ? process[a0_0xaf48a0(0x27a)][a0_0xaf48a0(0x21a)] : path['resolve'](process[a0_0xaf48a0(0x27a)][a0_0xaf48a0(0x1b7)] || basedir, a0_0xaf48a0(0x261))), console[a0_0xaf48a0(0x21f)](a0_0xaf48a0(0x233), process[a0_0xaf48a0(0x27a)][a0_0xaf48a0(0x233)]);
const is_docker = fs[a0_0xaf48a0(0x201)](a0_0xaf48a0(0x25a));
c[a0_0xaf48a0(0x265)] = is_docker, c['is_windows'] = a0_0xaf48a0(0x278) === process['platform'], opts['noengine'] = opts[a0_0xaf48a0(0x1fc)] || fs['existsSync'](path[a0_0xaf48a0(0x1f3)](confdir, a0_0xaf48a0(0x1fc)));
if (![] && c[a0_0xaf48a0(0x1e3)] && process[a0_0xaf48a0(0x23f)]() !== c['gid'])
    try {
        process[a0_0xaf48a0(0x1fd)](c[a0_0xaf48a0(0x1e3)]);
    } catch (a0_0x491227) {
        console['error']('Failed\x20to\x20set\x20the\x20GID\x20of\x20the\x20Reactor\x20process:\x20' + a0_0x491227);
    }
if (![] && c[a0_0xaf48a0(0x1f8)] && process[a0_0xaf48a0(0x1c9)]() !== c[a0_0xaf48a0(0x1f8)])
    try {
        process[a0_0xaf48a0(0x231)](c[a0_0xaf48a0(0x1f8)]);
    } catch (a0_0x297544) {
        console[a0_0xaf48a0(0x280)]('Failed\x20to\x20set\x20the\x20UID\x20of\x20the\x20Reactor\x20process:\x20' + a0_0x297544), process[a0_0xaf48a0(0x254)](0xfd);
    }
function a0_0x47ec() {
    const _0x3c16f6 = [
        'UTF-8',
        'Unable\x20to\x20load\x20configuration\x20from',
        'readFileSync',
        'status',
        'en-US',
        'Trapped\x20unhandled\x20Promise\x20rejection:\x20%1',
        'setuid',
        'app',
        'NODE_PATH',
        'then',
        '/var/reactor',
        'Closing\x20logs...',
        'version',
        'Reactor\x20build\x20%1\x20starting\x20on\x20%2\x20%3',
        'timeZone',
        'A\x20default\x20(empty)\x20configuration\x20with\x20the\x20Engine\x20disabled\x20will\x20be\x20used.',
        'resolvedOptions',
        'subscribe',
        'The\x20engine\x20has\x20been\x20disabled\x20and\x20is\x20not\x20running\x20(rules\x20are\x20not\x20being\x20processed).',
        'DateTimeFormat',
        'getgid',
        'getTimezoneOffset',
        'bare-metal',
        'nodejs-version',
        'Loading\x20default\x20en-US\x20as\x20locale\x20and\x20translation\x20(fallback)',
        'versions',
        'Failed\x20to\x20write\x20',
        'shift',
        'reactor-root-priv',
        'logsdir',
        'locale',
        'Starting\x20Reaction\x20Engine...',
        '3534HOvzIK',
        'Local\x20date/time\x20using\x20configured\x20timezone\x20and\x20locale\x20formatting\x20is\x20%1',
        'sysconfig-invalid',
        'opterr',
        'copyFileSync',
        'Closing\x20Structure...',
        '10513458SshDir',
        'SIGTERM',
        '1245402SApXYc',
        'exit',
        'reactor',
        'debug',
        'warn',
        'Shutdown\x20signal\x20(%1)\x20received.\x20Stopping\x20Reaction\x20Engine...',
        'plugindir',
        '/opt/reactor/.reactor-docker',
        'app:\x20can\x27t\x20get\x20locale\x20timezone:\x20%1',
        'notice',
        'reason',
        'length',
        'getInstance',
        'Stopping\x20timers...',
        'locales',
        'writeReport',
        '\x20unreadable\x20or\x20empty',
        'basedir',
        'is_docker',
        'attempting\x20load\x20of\x20locale\x20%1',
        '18995740NgoLWP',
        'server/lib/AlertManager',
        'SIGHUP',
        'getConfig',
        'unhandledRejection',
        'crit',
        'cpSync',
        'trace',
        'FORCED\x20EXIT',
        'WARN',
        'Waiting\x20for\x20controllers\x20to\x20start\x20up...',
        'app:\x20NODE_PATH\x20component\x20%1\x20seems\x20to\x20be\x20Reactor\x20install\x20dir',
        'The\x20version\x20of\x20nodejs\x20you\x20are\x20using\x20({0})\x20is\x20now\x20end-of-life,\x20and\x20so\x20is\x20deprecated\x20for\x20use\x20with\x20Reactor.\x20Please\x20upgrade\x20nodejs\x20to\x20the\x20latest\x20LTS\x20version\x20as\x20soon\x20as\x20possible.',
        'docker',
        'waitAllControllers',
        'Trapped\x20unhandled\x20exception:',
        'confdir',
        'win32',
        'unhandled.json',
        'env',
        'SIGQUIT',
        'Locale\x20',
        'Reactor',
        'NODE_PATH\x20required\x20environment\x20variable\x20is\x20not\x20set;\x20can\x27t\x20continue',
        'Container\x20has\x20no\x20identifiable\x20mount\x20for\x20/var/reactor.',
        'error',
        'arch',
        'struct',
        'reactor.engine.startup_wait',
        'context',
        '5HduUWO',
        'dist-config',
        'REACTOR_DATA_PREFIX',
        'repl',
        'ERROR',
        'NOTICE',
        'Trapped\x20unhandled\x20Promise\x20rejection',
        'execPath',
        'find',
        'report',
        'node',
        'setLocale',
        'Stopping\x20Engine...',
        'tools',
        'slice',
        'Configured\x20locale\x20%1;\x20selected\x20locale(s)\x20%2',
        './server/lib/Logger',
        '/proc/1/mountinfo',
        'Controller\x20%1\x20failed\x20to\x20start:\x20%2',
        'exception',
        'getuid',
        '1015824zFMCgN',
        'Stopping\x20service;\x20another\x20instance\x20may\x20be\x20running.',
        'Resolved\x20timezone=%1,\x20environment\x20TZ=%2;\x20offset\x20minutes\x20from\x20UTC=%3',
        'REACTOR_CONFIG_PREFIX',
        'REACTOR_HOME',
        'Basedir\x20%1;\x20data\x20in\x20%2',
        'toUpperCase',
        'forEach',
        'datadir',
        '147CkQphB',
        'notifyStartup',
        'Loaded\x20locale\x20%1\x20for\x20%2',
        'LC_ALL',
        'start',
        'LANG',
        'reactor.engine.wait_all_controllers',
        '\x20cannot\x20be\x20used;\x20encodings\x20other\x20than\x20UTF-8\x20are\x20not\x20supported',
        'eol',
        'number',
        '157608uuYnuk',
        'object',
        'NODE_PATH=%1',
        'dismissTag',
        'logging.yaml',
        'Reactor\x20is\x20running\x20as\x20root!\x20This\x20is\x20a\x20very\x20high\x20security\x20risk\x20and\x20not\x20recommended.\x20Please\x20run\x20Reactor\x20as\x20an\x20unprivileged\x20user\x20only.\x20Refer\x20to\x20the\x20installation\x20instructions.',
        'gid',
        'Container\x20mount\x20for\x20/var/reactor:\x20%1',
        'toString',
        'match',
        '(no\x20ICU)',
        'kill',
        'logging',
        'Detected\x20nodejs',
        'server/wsapi/wsapi',
        'now',
        'Warning:\x20NODE_PATH\x20does\x20not\x20have\x20Reactor\x20directory\x20as\x20first\x20element!',
        'TimedPromise',
        'code',
        'getLoadedLocale',
        'split',
        'platform',
        'resolve',
        'engine-disabled',
        'reactor.yaml',
        'boolean',
        'REACTOR_LOG_PREFIX',
        'uid',
        'replace',
        'Failed\x20to\x20start\x20engine:\x20%1',
        'Please\x20refer\x20to\x20the\x20console\x20log\x20for\x20trace',
        'noengine',
        'setgid',
        'Unsupported\x20nodejs\x20version\x20',
        './server/lib/TimerBroker.js',
        'The\x20version\x20of\x20nodejs\x20you\x20are\x20using\x20({0})\x20is\x20approaching\x20end-of-life.\x20Please\x20upgrade\x20nodejs\x20to\x20the\x20latest\x20LTS\x20version\x20as\x20soon\x20as\x20possible.',
        'existsSync',
        'All\x20%1\x20controllers\x20successfully\x20started.',
        'LANGUAGE',
        'server/lib/Structure',
        'nodejs\x20v%1\x20known,\x20supported\x20through\x20%2',
        'ext',
        'err',
        'writeFileSync',
        'shutdown',
        'catch',
        '1108HXIZqc',
        'Waiting\x20%1\x20seconds\x20before\x20continuing\x20(startup\x20delay)',
        'toLocaleDateString',
        'pid',
        'server/lib/Engine',
        'en-US.UTF-8',
        '2541126PABStr',
        'Environment\x20NODE_PATH\x20does\x20not\x20include\x20the\x20Reactor\x20install\x20directory',
        'express',
        'storage',
        'Starting\x20Structure...',
        'reactor.http_proxy_enabled',
        'addAlert',
        'always',
        'Failed\x20to\x20load\x20locale\x20%1:\x20%2',
        'REACTOR_PLUGIN_PREFIX',
        'Startup\x20was\x20delayed\x20%1ms',
        'localesdir',
        'logs',
        'configuration\x20from',
        'log',
        'uncaughtException',
        'stop',
        'EADDRINUSE',
        'server/lib/i18n',
        'join',
        'pidfile',
        'mkdirSync',
        'REACTOR_STORAGE_PREFIX',
        'reactor.pid',
        'info',
        'server/lib/httpapi'
    ];
    a0_0x47ec = function () {
        return _0x3c16f6;
    };
    return a0_0x47ec();
}
if (opts[a0_0xaf48a0(0x225)]) {
    opts[a0_0xaf48a0(0x225)] = path['resolve'](c['datadir'], opts[a0_0xaf48a0(0x225)]);
    try {
        fs[a0_0xaf48a0(0x208)](opts[a0_0xaf48a0(0x225)], String(process[a0_0xaf48a0(0x20e)]));
    } catch (a0_0x49e1fd) {
        console[a0_0xaf48a0(0x280)](a0_0xaf48a0(0x245) + opts['pidfile'] + ':\x20' + a0_0x49e1fd);
    }
}
make_dir(c[a0_0xaf48a0(0x1d2)]), make_dir(c[a0_0xaf48a0(0x248)]), Configuration['getInstance'](a0_0xaf48a0(0x1e9), path[a0_0xaf48a0(0x224)](confdir, a0_0xaf48a0(0x1e1)));
const Logger = require(a0_0xaf48a0(0x1c5)), log = Logger['getLogger'](a0_0xaf48a0(0x232)), sys_locale = process[a0_0xaf48a0(0x27a)][a0_0xaf48a0(0x1d6)] || process['env'][a0_0xaf48a0(0x1d8)] || process['env'][a0_0xaf48a0(0x203)];
log['always'](a0_0xaf48a0(0x238), BUILD_VERSION, process[a0_0xaf48a0(0x237)], process[a0_0xaf48a0(0x1bc)]), log[a0_0xaf48a0(0x218)]('Process\x20ID\x20%1\x20user/group\x20%2/%3;\x20%4;\x20platform\x20%5/%6\x20%7;\x20locale\x20%8', process['pid'], process[a0_0xaf48a0(0x1c9)] ? process[a0_0xaf48a0(0x1c9)]() : '-', process[a0_0xaf48a0(0x23f)] ? process[a0_0xaf48a0(0x23f)]() : '-', is_docker ? a0_0xaf48a0(0x274) : a0_0xaf48a0(0x241), process[a0_0xaf48a0(0x1f2)], process[a0_0xaf48a0(0x1b1)], os[a0_0xaf48a0(0x237)](), sys_locale), log['always'](a0_0xaf48a0(0x1cf), c[a0_0xaf48a0(0x264)], c[a0_0xaf48a0(0x1d2)]), log[a0_0xaf48a0(0x218)](a0_0xaf48a0(0x1df), process['env']['NODE_PATH']);
if ('' === (process[a0_0xaf48a0(0x27a)][a0_0xaf48a0(0x233)] || '')) {
    log['crit'](a0_0xaf48a0(0x27e));
    throw new Error('Required\x20environment\x20variable\x20NODE_PATH\x20is\x20not\x20set');
} else {
    let paths = process['env'][a0_0xaf48a0(0x233)]['split'](path['delimiter']), found = ![];
    for (let p of paths) {
        if ('' !== p && fs[a0_0xaf48a0(0x201)](path[a0_0xaf48a0(0x224)](p, 'server/lib/Logger.js'))) {
            log['debug'](0x5, a0_0xaf48a0(0x272), p), found = !![];
            break;
        }
        log[a0_0xaf48a0(0x257)](a0_0xaf48a0(0x1ed));
    }
    if (!found) {
        log[a0_0xaf48a0(0x26c)]('NODE_PATH\x20does\x20not\x20seem\x20to\x20include\x20Reactor\x20install\x20directory\x20as\x20first\x20element:\x20%1', process[a0_0xaf48a0(0x27a)]['NODE_PATH']);
        throw new Error(a0_0xaf48a0(0x212));
    }
}
const hasICU = 'object' === typeof Intl;
try {
    const ICUTZ = hasICU ? Intl[a0_0xaf48a0(0x23e)]()[a0_0xaf48a0(0x23b)]()[a0_0xaf48a0(0x239)] : a0_0xaf48a0(0x1e7), now = new Date();
    log['always'](a0_0xaf48a0(0x1cc), ICUTZ, process[a0_0xaf48a0(0x27a)]['TZ'], -now[a0_0xaf48a0(0x240)]());
} catch (a0_0x132eb8) {
    log['err'](a0_0xaf48a0(0x25b), a0_0x132eb8);
}
const i18n = require(a0_0xaf48a0(0x223));
let locale = c[a0_0xaf48a0(0x249)] || sys_locale || a0_0xaf48a0(0x210);
log[a0_0xaf48a0(0x218)](a0_0xaf48a0(0x1c4), c[a0_0xaf48a0(0x249)], locale), locale = locale[a0_0xaf48a0(0x1f1)](/ *, */);
let loaded = ![];
for (let l of locale) {
    let m = l[a0_0xaf48a0(0x1f1)](/\./);
    m[0x0] = (m[0x0] || '??')[a0_0xaf48a0(0x1f9)]('_', '-'), m[0x1] = (m[0x1] || a0_0xaf48a0(0x22b))[a0_0xaf48a0(0x1d0)]();
    if ('UTF-8' !== m[0x1]) {
        log['err'](a0_0xaf48a0(0x27c) + l + a0_0xaf48a0(0x1da));
        continue;
    }
    try {
        log[a0_0xaf48a0(0x256)](0x5, a0_0xaf48a0(0x266), m[0x0]);
        if (i18n[a0_0xaf48a0(0x1c0)](m[0x0], ![])) {
            log[a0_0xaf48a0(0x218)](a0_0xaf48a0(0x1d5), i18n[a0_0xaf48a0(0x1f0)](), m[0x0]), loaded = !![];
            break;
        }
    } catch (a0_0x3d7eec) {
        log['notice'](a0_0xaf48a0(0x219), m[0x0], a0_0x3d7eec);
    }
}
if (!loaded) {
    let m = locale[0x0][a0_0xaf48a0(0x1f1)](/\./);
    m[0x0] = (m[0x0] || '??')[a0_0xaf48a0(0x1f9)]('_', '-'), m[0x1] = (m[0x1] || a0_0xaf48a0(0x22b))[a0_0xaf48a0(0x1d0)]();
    try {
        i18n[a0_0xaf48a0(0x1c0)](m[0x0], a0_0xaf48a0(0x22f)) && (log[a0_0xaf48a0(0x218)](a0_0xaf48a0(0x1d5), i18n[a0_0xaf48a0(0x1f0)](), m[0x0]), loaded = !![]);
    } catch (a0_0x4dfcba) {
        log[a0_0xaf48a0(0x25c)]('Failed\x20to\x20load\x20locale\x20%1:\x20%2', m[0x0], a0_0x4dfcba);
    }
}
!loaded && (log[a0_0xaf48a0(0x257)](a0_0xaf48a0(0x243)), i18n[a0_0xaf48a0(0x1c0)](a0_0xaf48a0(0x22f)));
log[a0_0xaf48a0(0x218)](a0_0xaf48a0(0x24c), new Date()['toLocaleString']());
if (is_docker) {
    try {
        const sp = path['resolve'](basedir, a0_0xaf48a0(0x1b6)), tp = path[a0_0xaf48a0(0x1f3)](process[a0_0xaf48a0(0x27a)]['REACTOR_DATA_PREFIX'] || a0_0xaf48a0(0x235), a0_0xaf48a0(0x1b6));
        fs[a0_0xaf48a0(0x26d)](sp, tp, {
            'preserveTimestamps': !![],
            'dereference': !![],
            'recursive': !![]
        });
    } catch (a0_0x237511) {
        log[a0_0xaf48a0(0x1c8)](a0_0x237511);
    }
    try {
        const sp = path[a0_0xaf48a0(0x1f3)](basedir, a0_0xaf48a0(0x1c2)), tp = path['resolve'](process['env'][a0_0xaf48a0(0x1b7)] || a0_0xaf48a0(0x235), a0_0xaf48a0(0x1c2));
        fs[a0_0xaf48a0(0x26d)](sp, tp, {
            'preserveTimestamps': !![],
            'dereference': !![],
            'recursive': !![]
        });
    } catch (a0_0x3ea6ea) {
        log[a0_0xaf48a0(0x1c8)](a0_0x3ea6ea);
    }
    try {
        const ll = fs[a0_0xaf48a0(0x22d)](a0_0xaf48a0(0x1c6))[a0_0xaf48a0(0x1e5)]('utf-8')['split'](os['EOL']), ee = ll[a0_0xaf48a0(0x1bd)](_0x5644f3 => _0x5644f3['includes'](a0_0xaf48a0(0x235)));
        ee ? log[a0_0xaf48a0(0x229)](a0_0xaf48a0(0x1e4), ee) : log[a0_0xaf48a0(0x257)](a0_0xaf48a0(0x27f));
    } catch (a0_0x11c888) {
        log[a0_0xaf48a0(0x1c8)](a0_0x11c888);
    }
}
const app = express(), struct = require(a0_0xaf48a0(0x204)), Engine = require(a0_0xaf48a0(0x20f)), httpapi = require(a0_0xaf48a0(0x22a)), wsapi = require(a0_0xaf48a0(0x1eb)), AlertManager = require(a0_0xaf48a0(0x268));
process['on'](a0_0xaf48a0(0x26b), (_0x47ccd9, _0x475667) => {
    const _0x45de62 = a0_0xaf48a0;
    console[_0x45de62(0x21f)](_0x45de62(0x1bb), _0x47ccd9), console[_0x45de62(0x280)](_0x47ccd9), console[_0x45de62(0x280)](_0x475667), console[_0x45de62(0x26e)]();
    try {
        process[_0x45de62(0x1be)]['writeReport'](path[_0x45de62(0x1f3)](c[_0x45de62(0x248)], _0x45de62(0x279)), _0x47ccd9), log['error'](_0x45de62(0x230), _0x47ccd9), log[_0x45de62(0x1c8)](_0x47ccd9), log['error'](_0x45de62(0x1fb));
    } catch (_0x2716c2) {
    }
}), process['on'](a0_0xaf48a0(0x220), _0x193fe0 => {
    const _0x339f11 = a0_0xaf48a0;
    console[_0x339f11(0x280)](_0x339f11(0x276), _0x193fe0), console[_0x339f11(0x26e)](_0x193fe0);
    try {
        process[_0x339f11(0x1be)][_0x339f11(0x262)](path[_0x339f11(0x1f3)](c[_0x339f11(0x248)], _0x339f11(0x279)), _0x193fe0), log[_0x339f11(0x280)]('Trapped\x20unhandled\x20exception:\x20%1', _0x193fe0), log[_0x339f11(0x280)](_0x339f11(0x1fb));
    } catch (_0x1daf40) {
    }
    'EADDRINUSE' === _0x193fe0[_0x339f11(0x1ef)] && setTimeout(function () {
        const _0x4fb861 = _0x339f11;
        process[_0x4fb861(0x254)](0x1);
    }, 0xfa);
}), log[a0_0xaf48a0(0x25c)](a0_0xaf48a0(0x215)), struct[a0_0xaf48a0(0x1d7)](c[a0_0xaf48a0(0x264)])[a0_0xaf48a0(0x234)](async () => {
    const _0x34cb23 = a0_0xaf48a0, _0x105574 = Engine['getInstance']();
    try {
        const _0x2b4be9 = parseInt(process[_0x34cb23(0x244)]['node'][_0x34cb23(0x1f1)]('.')[0x0]);
        let _0x5df024 = !![];
        if (!isNaN(_0x2b4be9)) {
            const _0x23165c = NODE_VERSIONS[_0x2b4be9];
            if (_0x23165c) {
                log[_0x34cb23(0x229)](_0x34cb23(0x205), _0x2b4be9, new Date(_0x23165c[_0x34cb23(0x1db)])[_0x34cb23(0x20d)]());
                const _0x2245a3 = _0x23165c[_0x34cb23(0x1db)] - NODE_EOL_WARNING * 0x5265c00;
                if (Date['now']() > _0x23165c[_0x34cb23(0x1db)])
                    AlertManager['addAlert'](AlertManager['WARN'], _0x34cb23(0x273), { 'tag': _0x34cb23(0x242) }, process['versions']['node']), _0x5df024 = ![];
                else
                    Date[_0x34cb23(0x1ec)]() > _0x2245a3 && (AlertManager['addAlert'](AlertManager[_0x34cb23(0x1ba)], _0x34cb23(0x200), { 'tag': _0x34cb23(0x242) }, process[_0x34cb23(0x244)][_0x34cb23(0x1bf)]), _0x5df024 = ![]);
            } else
                _0x2b4be9 !== c?.['accept_nodejs_version'] && (AlertManager['addAlert'](AlertManager[_0x34cb23(0x270)], 'The\x20version\x20of\x20nodejs\x20you\x20are\x20using\x20({0})\x20is\x20not\x20an\x20LTS\x20version,\x20or\x20has\x20not\x20been\x20tested\x20with\x20Reactor.\x20This\x20is\x20not\x20recommended.', { 'tag': _0x34cb23(0x242) }, process[_0x34cb23(0x244)]['node']), _0x5df024 = ![]);
        }
        _0x5df024 && AlertManager[_0x34cb23(0x1e0)](_0x34cb23(0x242)), process['getuid'] && 0x0 === process[_0x34cb23(0x1c9)]() && !is_docker ? AlertManager[_0x34cb23(0x217)](AlertManager[_0x34cb23(0x270)], _0x34cb23(0x1e2), { 'tag': 'reactor-root-priv' }) : AlertManager['dismissTag'](_0x34cb23(0x247));
    } catch (_0x562daa) {
        log[_0x34cb23(0x1c8)](_0x562daa);
    }
    !valid_config ? AlertManager['addAlert'](AlertManager[_0x34cb23(0x1b9)], 'The\x20Reactor\x20configuration\x20in\x20{0:q}\x20could\x20not\x20be\x20read;\x20the\x20system\x20has\x20started\x20with\x20an\x20empty\x20configuration.', { 'tag': _0x34cb23(0x24d) }, rcf) : AlertManager['dismissTag'](_0x34cb23(0x24d));
    if (!![] === Configuration['getConfig'](_0x34cb23(0x1d9), _0x34cb23(0x1f6), ![])) {
        log[_0x34cb23(0x25c)](_0x34cb23(0x271));
        const _0x39bd5c = Date['now']();
        let _0x36a513 = await struct[_0x34cb23(0x275)](Configuration[_0x34cb23(0x26a)](_0x34cb23(0x1b3), _0x34cb23(0x1dc), 0xea60));
        log[_0x34cb23(0x229)](_0x34cb23(0x21b), Date[_0x34cb23(0x1ec)]() - _0x39bd5c);
        let _0x3fc4fd = 0x0;
        for (let _0x491f34 of _0x36a513) {
            !_0x491f34[_0x34cb23(0x22e)] && (log[_0x34cb23(0x25c)](_0x34cb23(0x1c7), _0x491f34['id'], _0x491f34[_0x34cb23(0x25d)]), ++_0x3fc4fd);
        }
        0x0 === _0x3fc4fd && log['notice'](_0x34cb23(0x202), _0x36a513[_0x34cb23(0x25e)]);
    }
    var _0x1acba1 = async function (_0x31f96a) {
        const _0x7cab84 = _0x34cb23;
        log[_0x7cab84(0x218)](_0x7cab84(0x258), _0x31f96a);
        try {
            log[_0x7cab84(0x25c)](_0x7cab84(0x1c1)), await _0x105574[_0x7cab84(0x221)]();
        } catch (_0x5b6d79) {
            log[_0x7cab84(0x1c8)](_0x5b6d79);
        }
        try {
            log[_0x7cab84(0x25c)](_0x7cab84(0x250)), await struct[_0x7cab84(0x221)]();
        } catch (_0x43b65e) {
            log[_0x7cab84(0x1c8)](_0x43b65e), console[_0x7cab84(0x280)](_0x43b65e);
        }
        try {
            log[_0x7cab84(0x25c)]('Closing\x20APIs...'), await wsapi[_0x7cab84(0x221)](), await httpapi[_0x7cab84(0x221)]();
        } catch (_0x4a99bc) {
            log[_0x7cab84(0x1c8)](_0x4a99bc), console['error'](_0x4a99bc);
        }
        try {
            log[_0x7cab84(0x25c)](_0x7cab84(0x260));
            let _0x310d6f = require(_0x7cab84(0x1ff));
            _0x310d6f[_0x7cab84(0x221)]();
        } catch (_0x443c06) {
            log[_0x7cab84(0x1c8)](_0x443c06), console[_0x7cab84(0x280)](_0x443c06);
        }
        log[_0x7cab84(0x218)]('Shutdown\x20complete,\x20process\x20ID\x20%1', process['pid']);
        try {
            log['always'](_0x7cab84(0x236)), await Logger[_0x7cab84(0x209)](), console['log']('All\x20logs\x20closed');
        } catch (_0x386dd8) {
            console[_0x7cab84(0x280)]('Shutting\x20down\x20logs:', _0x386dd8);
        }
        try {
            opts[_0x7cab84(0x225)] && fs['unlinkSync'](opts['pidfile']);
        } catch (_0x186d43) {
            console[_0x7cab84(0x280)](_0x186d43);
        }
        setTimeout(() => {
            const _0xa67040 = _0x7cab84;
            console[_0xa67040(0x280)](_0xa67040(0x26f)), process[_0xa67040(0x254)]('SIGQUIT' === _0x31f96a ? 0x1 : 0x7f);
        }, 0x7d0), process['exit']('SIGQUIT' === _0x31f96a ? 0x1 : 0x7f);
    };
    process['on']('SIGINT', _0x1acba1), process['on'](_0x34cb23(0x252), _0x1acba1), process['on'](_0x34cb23(0x27b), _0x1acba1), process['on'](_0x34cb23(0x269), _0x1acba1), process['on'](_0x34cb23(0x254), function () {
        console['log']('Exiting...');
    }), log['notice']('Starting\x20HTTP\x20server\x20and\x20API...'), httpapi[_0x34cb23(0x1d7)](app, c[_0x34cb23(0x264)])[_0x34cb23(0x234)](_0x466139 => {
        const _0x2ac5f1 = _0x34cb23;
        if (Configuration['getConfig'](_0x2ac5f1(0x216), _0x2ac5f1(0x1f6), ![])) {
            const _0x11fe98 = require('./server/lib/httpproxy');
            log[_0x2ac5f1(0x25c)]('HTTP\x20server\x20running;\x20registering\x20proxy\x20endpoints.'), _0x11fe98[_0x2ac5f1(0x1d7)](app);
        }
        log[_0x2ac5f1(0x25c)]('Starting\x20WSAPI...'), wsapi[_0x2ac5f1(0x1d7)](app, _0x466139)[_0x2ac5f1(0x234)](async () => {
            const _0x487491 = _0x2ac5f1;
            wsapi[_0x487491(0x1d4)]();
        });
    })['catch'](_0x3de600 => {
        const _0x57ccc2 = _0x34cb23;
        log[_0x57ccc2(0x207)]('Failed\x20to\x20start\x20HTTP\x20API:\x20%1', _0x3de600), _0x57ccc2(0x222) === _0x3de600[_0x57ccc2(0x1ef)] && (log['err'](_0x57ccc2(0x1cb)), process[_0x57ccc2(0x1e8)](process[_0x57ccc2(0x20e)], _0x57ccc2(0x27b)));
    });
    if (opts[_0x34cb23(0x1fc)] || ![] === Configuration[_0x34cb23(0x26a)]('reactor.engine.enabled', _0x34cb23(0x1f6), !![])) {
        const _0x4470f6 = require(_0x34cb23(0x223));
        log['crit']('Engine\x20startup\x20suppressed;\x20no\x20rules\x20will\x20be\x20processed.'), AlertManager['addAlert'](AlertManager[_0x34cb23(0x1b9)], _0x4470f6['_T'](_0x34cb23(0x23d)), { 'tag': _0x34cb23(0x1f4) });
    } else {
        let _0x34ae35 = Configuration[_0x34cb23(0x26a)]('reactor.engine.startup_delay', _0x34cb23(0x1dc), 0x0);
        if (_0x34ae35 > 0x0) {
            const _0xe9aec0 = require('server/lib/util');
            await _0xe9aec0[_0x34cb23(0x1ee)](() => {
                const _0x4a42ea = _0x34cb23;
                log[_0x4a42ea(0x218)](_0x4a42ea(0x20c), _0x34ae35 / 0x3e8);
            }, _0x34ae35)[_0x34cb23(0x20a)](_0x320b55 => {
            });
        }
        log['notice'](_0x34cb23(0x24a)), struct[_0x34cb23(0x23c)](_0x105574);
        try {
            _0x105574['start'](), AlertManager[_0x34cb23(0x1e0)](_0x34cb23(0x1f4));
        } catch (_0x488acd) {
            log[_0x34cb23(0x207)](_0x34cb23(0x1fa), _0x488acd), log['exception'](_0x488acd);
        }
    }
});
if (opts[a0_0xaf48a0(0x1b8)]) {
    let r = repl[a0_0xaf48a0(0x1d7)]('>\x20'), ctx = r[a0_0xaf48a0(0x1b4)];
    ctx[a0_0xaf48a0(0x1b2)] = struct, ctx['engine'] = Engine[a0_0xaf48a0(0x25f)](struct), r['on'](a0_0xaf48a0(0x254), () => {
        const _0x40a094 = a0_0xaf48a0;
        Engine[_0x40a094(0x25f)](struct)[_0x40a094(0x221)](), struct[_0x40a094(0x221)](), process[_0x40a094(0x254)](0x1);
    });
}