#!/usr/bin/env node
/** Copyright (C) 2020-2026 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_0x3d5cbc = a0_0x9c24;
(function (_0x363c4f, _0x4c3632) {
    const _0x56e26a = a0_0x9c24, _0x249076 = _0x363c4f();
    while (!![]) {
        try {
            const _0x1f4f9c = -parseInt(_0x56e26a(0x19e)) / 0x1 * (parseInt(_0x56e26a(0x14e)) / 0x2) + parseInt(_0x56e26a(0x14d)) / 0x3 + parseInt(_0x56e26a(0x1a3)) / 0x4 + parseInt(_0x56e26a(0x150)) / 0x5 + -parseInt(_0x56e26a(0x145)) / 0x6 * (parseInt(_0x56e26a(0x120)) / 0x7) + parseInt(_0x56e26a(0x170)) / 0x8 + parseInt(_0x56e26a(0x1c3)) / 0x9;
            if (_0x1f4f9c === _0x4c3632)
                break;
            else
                _0x249076['push'](_0x249076['shift']());
        } catch (_0x209868) {
            _0x249076['push'](_0x249076['shift']());
        }
    }
}(a0_0x1ffa, 0xbda30));
function a0_0x9c24(_0x343e0d, _0x21536c) {
    _0x343e0d = _0x343e0d - 0xeb;
    const _0x1ffa72 = a0_0x1ffa();
    let _0x9c245a = _0x1ffa72[_0x343e0d];
    return _0x9c245a;
}
const version = 0x666d, BUILD_VERSION = 'latest-26221-b25bb3e3', MIN_NODE_MAJOR = 0x14, NODE_VERSIONS = {
        0x12: { 'eol': 0x1968a005600 },
        0x14: { 'eol': 0x19de1b18200 },
        0x16: { 'eol': 0x1a53962ae00 },
        0x18: { 'eol': 0x1ac963a3600 },
        0x1a: { 'eol': 0x1b3edeb6200 }
    }, NODE_EOL_WARNING = 0x3c;
function a0_0x1ffa() {
    const _0x2b0aba = [
        '9384rHJegu',
        '2akiXlD',
        'Please\x20refer\x20to\x20the\x20console\x20log\x20for\x20trace',
        '1983845MjvgiD',
        'notifyStartup',
        'crit',
        'Configuration\x20file\x20%1\x20could\x20not\x20be\x20loaded;\x20a\x20last-known-good\x20version\x20of\x20the\x20file\x20has\x20been\x20loaded\x20instead.\x20See\x20Troubleshooting\x20Startup\x20in\x20the\x20documentation.',
        'length',
        'engine-disabled',
        'ext',
        '/proc/1/mountinfo',
        'Process\x20ID\x20%1\x20user/group\x20%2/%3;\x20%4;\x20platform\x20%5/%6\x20%7;\x20locale\x20%8',
        'warn',
        'server/lib/Logger.js',
        'Failed\x20to\x20write\x20',
        'subscribe',
        'nodejs-version',
        'split',
        'engine',
        'node',
        'config',
        'Exiting...',
        'logsdir',
        'tools',
        'cpSync',
        '(no\x20ICU)',
        'getTimezoneOffset',
        'Failed\x20to\x20set\x20the\x20GID\x20of\x20the\x20Reactor\x20process:\x20',
        'exception',
        '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.',
        'suppress_docker_volume_check',
        'win32',
        'pid',
        'Configured\x20locale\x20%1;\x20selected\x20locale(s)\x20%2',
        'Stopping\x20Engine...',
        '4234472NCnSYz',
        'reactor.engine.startup_wait',
        'getLoadedLocale',
        'Reactor\x20build\x20%1\x20starting\x20on\x20%2\x20%3',
        'code',
        'notice',
        'stop',
        'Controller\x20%1\x20failed\x20to\x20start:\x20%2',
        'includes',
        'forEach',
        'invalid-config-',
        'locales',
        'SIGINT',
        'Closing\x20logs...',
        'catch',
        'getInstance',
        'always',
        'NODE_PATH=%1',
        '(not\x20supported)',
        'basedir',
        'getuid',
        '\x20unreadable\x20or\x20empty',
        '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.',
        'timeZone',
        'dist-config',
        'trace',
        'now',
        'NODE_PATH\x20does\x20not\x20seem\x20to\x20include\x20Reactor\x20install\x20directory\x20as\x20first\x20element:\x20%1',
        'Trapped\x20unhandled\x20exception:',
        'REACTOR_CONFIG_PREFIX',
        './server/lib/TimerBroker.js',
        'LANGUAGE',
        'app\x20startup\x20complete',
        'reactor.engine.startup_delay',
        'Failed\x20to\x20load\x20locale\x20%1:\x20%2',
        'All\x20logs\x20closed',
        'locale',
        'Failed\x20to\x20start\x20HTTP\x20API:\x20%1',
        'storage',
        'is_docker',
        'server/lib/AlertManager',
        'NODE_PATH\x20required\x20environment\x20variable\x20is\x20not\x20set;\x20can\x27t\x20continue',
        'exit',
        'EADDRINUSE',
        'debug',
        'Unsupported\x20nodejs\x20version\x20',
        '1404742OvvmYA',
        'Waiting\x20for\x20controllers\x20to\x20start\x20up...',
        'Reload\x20message\x20received\x20(handling\x20as\x20SIGQUIT)',
        'SIGTERM',
        'logging.yaml',
        '2515264ygVIlK',
        'Required\x20environment\x20variable\x20NODE_PATH\x20is\x20not\x20set',
        'info',
        'LC_ALL',
        'waitAllControllers',
        'UTF-8',
        'All\x20%1\x20controllers\x20successfully\x20started.',
        'The\x20following\x20configurations\x20were\x20valid\x20and\x20loaded\x20during\x20startup:\x20%1',
        'Loaded\x20locale\x20%1\x20for\x20%2',
        'boolean',
        'server/lib/httpapi',
        'WARN',
        'localesdir',
        'Unable\x20to\x20load\x20configuration\x20from',
        'enumConfig',
        'readFileSync',
        'writeFileSync',
        'Warning:\x20NODE_PATH\x20does\x20not\x20have\x20Reactor\x20directory\x20as\x20first\x20element!',
        'getConfig',
        'execPath',
        'readdirSync',
        'REACTOR_HOME',
        'The\x20Reactor\x20configuration\x20in\x20{0:q}\x20could\x20not\x20be\x20read;\x20the\x20system\x20has\x20started\x20with\x20an\x20empty\x20configuration.',
        'uid',
        'getgid',
        'Shutdown\x20message\x20received\x20(handling\x20as\x20SIGINT)',
        'accept_nodejs_version',
        'reactor-root-priv',
        'resolve',
        'versions',
        'unhandled.json',
        'en-US.UTF-8',
        '7611759DPTvll',
        'Reactor',
        'error',
        'find',
        'Closing\x20APIs...',
        'Resolved\x20timezone=%1,\x20environment\x20TZ=%2;\x20offset\x20minutes\x20from\x20UTC=%3',
        'Startup\x20was\x20delayed\x20%1ms',
        'shift',
        'LANG',
        '/var/reactor',
        'Waiting\x20%1\x20seconds\x20before\x20continuing\x20(startup\x20delay)',
        'noengine',
        'Shutting\x20down\x20logs:',
        'nodejs\x20major\x20version\x20%1\x20accepted\x20(by\x20configuration\x20exception)',
        'Starting\x20HTTP\x20server\x20and\x20API...',
        'arch',
        'reason',
        'toLocaleDateString',
        'reactor.yaml',
        'is_windows',
        'en-US',
        'HTTP\x20server\x20running;\x20registering\x20proxy\x20endpoints.',
        'message',
        'REACTOR_LOG_PREFIX',
        'app',
        'then',
        'shutdown',
        'docker',
        'reload',
        'server/lib/Structure',
        'replace',
        'env',
        'logs',
        'writeReport',
        'plugindir',
        'context',
        'Starting\x20Structure...',
        'Shutdown\x20signal\x20(%1)\x20received.\x20Stopping\x20Reaction\x20Engine...',
        'addAlert',
        'Starting\x20Reaction\x20Engine...',
        'ERROR',
        'err',
        'slice',
        'report',
        'Loading\x20default\x20en-US\x20as\x20locale\x20and\x20translation\x20(fallback)',
        'Invalid\x20command\x20line\x20argument:',
        'datadir',
        'INVALID\x20CONFIGURATION!\x20Configuration\x20file\x20{0:q}\x20contains\x20an\x20error\x20and\x20could\x20not\x20be\x20loaded.\x20The\x20last-known-good\x20version\x20was\x20loaded\x20instead.\x20Check\x20this\x20file\x20using\x20available\x20syntax-checking\x20tools,\x20correct\x20all\x20errors,\x20and\x20restart.\x20See\x20the\x20Troubleshooting\x20Startup\x20section\x20of\x20the\x20documentation\x20for\x20more\x20help.',
        'REACTOR_PLUGIN_PREFIX',
        '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.',
        'bare-metal',
        'copyFileSync',
        'join',
        'toUpperCase',
        'log',
        'start',
        'isLastKnownGood',
        'platform',
        'repl',
        'confdir',
        'dismissTag',
        './server/lib/Logger',
        'setLocale',
        '#warn-lkg-config',
        'EOL',
        '21pOCAjX',
        'server/lib/util',
        'object',
        'received\x20message:\x20%1',
        'Trapped\x20unhandled\x20Promise\x20rejection:\x20%1',
        'match',
        'DateTimeFormat',
        'logging',
        'path',
        'Container\x20mount\x20for\x20/var/reactor:\x20%1',
        'NODE_PATH',
        'Stopping\x20timers...',
        './dist-config',
        'delimiter',
        'Stopping\x20service;\x20another\x20instance\x20may\x20be\x20running.',
        'reactor',
        'eol',
        'opterr',
        '\x20cannot\x20be\x20used;\x20encodings\x20other\x20than\x20UTF-8\x20are\x20not\x20supported',
        'version',
        'REACTOR_STORAGE_PREFIX',
        'resolvedOptions',
        'status',
        'REACTOR_DATA_PREFIX',
        'toLocaleString',
        'express',
        'Environment\x20NODE_PATH\x20does\x20not\x20include\x20the\x20Reactor\x20install\x20directory',
        'server/lib/i18n',
        'existsSync',
        'unlinkSync',
        'gid',
        'unhandledRejection',
        'number',
        'Detected\x20nodejs',
        'app:\x20NODE_PATH\x20component\x20%1\x20seems\x20to\x20be\x20Reactor\x20install\x20dir',
        'setgid',
        '.yaml',
        '444558VNcFvw',
        '/opt/reactor/.reactor-docker',
        'pidfile',
        'The\x20engine\x20has\x20been\x20disabled\x20and\x20is\x20not\x20running\x20(rules\x20are\x20not\x20being\x20processed).',
        'The\x20data\x20volume\x20has\x20not\x20been\x20correctly\x20configured\x20and\x20mounted.\x20Stopping\x20container.\x20Please\x20refer\x20to\x20the\x20installation\x20instructions\x20for\x20your\x20docker\x20image.',
        'Trapped\x20unhandled\x20Promise\x20rejection',
        'Closing\x20Structure...',
        'SIGQUIT'
    ];
    a0_0x1ffa = function () {
        return _0x2b0aba;
    };
    return a0_0x1ffa();
}
if (parseInt(process['versions'][a0_0x3d5cbc(0x160)]['split']('.')[0x0]) < MIN_NODE_MAJOR) {
    console[a0_0x3d5cbc(0x1c5)](a0_0x3d5cbc(0x141), process[a0_0x3d5cbc(0x1c0)][a0_0x3d5cbc(0x160)], a0_0x3d5cbc(0x182));
    throw new Error(a0_0x3d5cbc(0x19d) + process[a0_0x3d5cbc(0x1c0)]['node']);
}
const path = require(a0_0x3d5cbc(0x128)), os = require('os'), fs = require('fs');
function make_dir(_0xd3882) {
    const _0x4288c7 = a0_0x3d5cbc;
    if (!fs[_0x4288c7(0x13c)](_0xd3882))
        return fs['mkdirSync'](_0xd3882), !![];
    return ![];
}
function checkConfigDir(_0x1acd84, _0x4c7795) {
    const _0x1dfd1c = a0_0x3d5cbc;
    make_dir(_0x1acd84) && fs[_0x1dfd1c(0x1b7)](_0x4c7795)[_0x1dfd1c(0x179)](_0x286248 => {
        const _0x4e1124 = _0x1dfd1c;
        if (_0x286248[_0x4e1124(0x125)](/\.(yaml|yml|json)(-dist)?$/i)) {
            const _0x205f26 = path['resolve'](_0x1acd84, _0x286248);
            if (!fs[_0x4e1124(0x13c)](_0x205f26))
                try {
                    fs[_0x4e1124(0x112)](path[_0x4e1124(0x1bf)](_0x4c7795, _0x286248), _0x205f26);
                } catch (_0x42786d) {
                    console['log'](_0x42786d);
                }
        }
    });
}
let opts = {
        'noengine': ![],
        'repl': ![],
        'pidfile': ![],
        'basedir': process[a0_0x3d5cbc(0xfe)][a0_0x3d5cbc(0x1b8)] || process['cwd'](),
        'opterr': ![]
    }, argv = process['argv'][a0_0x3d5cbc(0x109)](0x2);
while (argv[a0_0x3d5cbc(0x154)] > 0x0) {
    let arg = argv[a0_0x3d5cbc(0x1ca)]();
    switch (arg) {
    case '-R':
        opts['repl'] = !![];
        break;
    case '-N':
        opts[a0_0x3d5cbc(0x1ce)] = !![];
        break;
    case '-d':
        opts[a0_0x3d5cbc(0x183)] = argv['shift']() || opts[a0_0x3d5cbc(0x183)];
        break;
    case '-c':
        opts[a0_0x3d5cbc(0x11a)] = argv[a0_0x3d5cbc(0x1ca)]() || opts['confdir'];
        break;
    case '-p':
        opts[a0_0x3d5cbc(0x147)] = argv[a0_0x3d5cbc(0x1ca)]() || 'reactor.pid';
        break;
    default:
        opts['opterr'] = !![], console[a0_0x3d5cbc(0x115)](a0_0x3d5cbc(0x10c), arg);
    }
}
opts[a0_0x3d5cbc(0x131)] && process['exit'](0xff);
const express = require(a0_0x3d5cbc(0x139)), repl = require(a0_0x3d5cbc(0x119)), basedir = path[a0_0x3d5cbc(0x1bf)](opts[a0_0x3d5cbc(0x183)] || process['env'][a0_0x3d5cbc(0x1b8)] || __dirname), confdir = opts[a0_0x3d5cbc(0x11a)] ? path[a0_0x3d5cbc(0x1bf)](opts[a0_0x3d5cbc(0x11a)]) : path['resolve'](process[a0_0x3d5cbc(0xfe)][a0_0x3d5cbc(0x18d)] ? process[a0_0x3d5cbc(0xfe)][a0_0x3d5cbc(0x18d)] : process[a0_0x3d5cbc(0xfe)][a0_0x3d5cbc(0x137)] ? path[a0_0x3d5cbc(0x1bf)](process[a0_0x3d5cbc(0xfe)][a0_0x3d5cbc(0x137)], a0_0x3d5cbc(0x161)) : path['join'](basedir, 'config'));
console[a0_0x3d5cbc(0x115)](a0_0x3d5cbc(0x1c4), BUILD_VERSION, a0_0x3d5cbc(0xf7), version, 'configuration\x20from', confdir), checkConfigDir(confdir, path[a0_0x3d5cbc(0x113)](basedir, a0_0x3d5cbc(0x12c)));
const Configuration = require('./server/lib/Configuration'), rcf = path[a0_0x3d5cbc(0x1bf)](confdir, a0_0x3d5cbc(0xf1));
let valid_config = ![], c;
try {
    c = Configuration['getInstance'](a0_0x3d5cbc(0x12f), rcf)[a0_0x3d5cbc(0x1b5)](a0_0x3d5cbc(0x12f), a0_0x3d5cbc(0x122));
    if (!c)
        throw new Error('Configuration\x20file\x20' + rcf + a0_0x3d5cbc(0x185));
    valid_config = !![];
} catch (a0_0x52d770) {
    console[a0_0x3d5cbc(0x1c5)](a0_0x3d5cbc(0x1b0), rcf, ':', a0_0x52d770), console['log']('A\x20default\x20(empty)\x20configuration\x20with\x20the\x20Engine\x20disabled\x20will\x20be\x20used.'), c = Configuration[a0_0x3d5cbc(0x17f)]('reactor', { 'reactor': { 'engine': { 'enabled': ![] } } })[a0_0x3d5cbc(0x1b5)](a0_0x3d5cbc(0x12f), a0_0x3d5cbc(0x122));
}
c[a0_0x3d5cbc(0x183)] = basedir, c[a0_0x3d5cbc(0x11a)] = confdir, c[a0_0x3d5cbc(0x10d)] = c[a0_0x3d5cbc(0x10d)] || path[a0_0x3d5cbc(0x1bf)](process[a0_0x3d5cbc(0xfe)][a0_0x3d5cbc(0x134)] ? process['env'][a0_0x3d5cbc(0x134)] : path[a0_0x3d5cbc(0x1bf)](process[a0_0x3d5cbc(0xfe)][a0_0x3d5cbc(0x137)] || basedir, a0_0x3d5cbc(0x196))), c[a0_0x3d5cbc(0x163)] = c[a0_0x3d5cbc(0x163)] || path[a0_0x3d5cbc(0x1bf)](process[a0_0x3d5cbc(0xfe)]['REACTOR_LOG_PREFIX'] ? process[a0_0x3d5cbc(0xfe)][a0_0x3d5cbc(0xf6)] : path['resolve'](process[a0_0x3d5cbc(0xfe)][a0_0x3d5cbc(0x137)] || basedir, a0_0x3d5cbc(0xff))), c[a0_0x3d5cbc(0x101)] = c['plugindir'] || path[a0_0x3d5cbc(0x1bf)](process['env'][a0_0x3d5cbc(0x10f)] ? process[a0_0x3d5cbc(0xfe)][a0_0x3d5cbc(0x10f)] : path[a0_0x3d5cbc(0x1bf)](process['env'][a0_0x3d5cbc(0x137)] || basedir, a0_0x3d5cbc(0x156))), c[a0_0x3d5cbc(0x1af)] = c[a0_0x3d5cbc(0x1af)] || path['resolve'](process['env']['REACTOR_PLUGIN_PREFIX'] ? process[a0_0x3d5cbc(0xfe)][a0_0x3d5cbc(0x10f)] : path[a0_0x3d5cbc(0x1bf)](process['env'][a0_0x3d5cbc(0x137)] || basedir, a0_0x3d5cbc(0x17b))), console[a0_0x3d5cbc(0x115)](a0_0x3d5cbc(0x12a), process['env']['NODE_PATH']);
const is_docker = fs[a0_0x3d5cbc(0x13c)](a0_0x3d5cbc(0x146));
c[a0_0x3d5cbc(0x197)] = is_docker, c[a0_0x3d5cbc(0xf2)] = a0_0x3d5cbc(0x16c) === process['platform'];
if (is_docker && fs[a0_0x3d5cbc(0x13c)]('/var/reactor/.docker-image-volume') && !![] !== c[a0_0x3d5cbc(0x16b)]) {
    console[a0_0x3d5cbc(0x1c5)](a0_0x3d5cbc(0x149));
    throw new Error('Invalid\x20volume\x20configuration');
}
opts[a0_0x3d5cbc(0x1ce)] = opts[a0_0x3d5cbc(0x1ce)] || fs[a0_0x3d5cbc(0x13c)](path[a0_0x3d5cbc(0x1bf)](confdir, 'noengine'));
if (c['experimental_check_uidgid']) {
    if (c[a0_0x3d5cbc(0x13e)] && process[a0_0x3d5cbc(0x1bb)]() !== c['gid'])
        try {
            process[a0_0x3d5cbc(0x143)](c[a0_0x3d5cbc(0x13e)]);
        } catch (a0_0x476228) {
            console[a0_0x3d5cbc(0x1c5)](a0_0x3d5cbc(0x168) + a0_0x476228);
        }
    if (c[a0_0x3d5cbc(0x1ba)] && process[a0_0x3d5cbc(0x184)]() !== c['uid'])
        try {
            process['setuid'](c[a0_0x3d5cbc(0x1ba)]);
        } catch (a0_0x24e15b) {
            console[a0_0x3d5cbc(0x1c5)]('Failed\x20to\x20set\x20the\x20UID\x20of\x20the\x20Reactor\x20process:\x20' + a0_0x24e15b);
            throw a0_0x24e15b;
        }
}
if (opts['pidfile']) {
    opts[a0_0x3d5cbc(0x147)] = path['resolve'](c['datadir'], opts['pidfile']);
    try {
        fs[a0_0x3d5cbc(0x1b3)](opts['pidfile'], String(process[a0_0x3d5cbc(0x16d)]));
    } catch (a0_0x18138e) {
        console[a0_0x3d5cbc(0x1c5)](a0_0x3d5cbc(0x15b) + opts[a0_0x3d5cbc(0x147)] + ':\x20' + a0_0x18138e);
    }
}
make_dir(c[a0_0x3d5cbc(0x10d)]), make_dir(c[a0_0x3d5cbc(0x163)]), Configuration[a0_0x3d5cbc(0x17f)](a0_0x3d5cbc(0x127), path[a0_0x3d5cbc(0x113)](confdir, a0_0x3d5cbc(0x1a2)));
const Logger = require(a0_0x3d5cbc(0x11c)), log = Logger['getLogger'](a0_0x3d5cbc(0xf7)), sys_locale = process[a0_0x3d5cbc(0xfe)][a0_0x3d5cbc(0x1a6)] || process[a0_0x3d5cbc(0xfe)][a0_0x3d5cbc(0x1cb)] || process[a0_0x3d5cbc(0xfe)][a0_0x3d5cbc(0x18f)];
log[a0_0x3d5cbc(0x180)](a0_0x3d5cbc(0x173), BUILD_VERSION, process[a0_0x3d5cbc(0x133)], process[a0_0x3d5cbc(0x1b6)]), log['always'](a0_0x3d5cbc(0x158), process['pid'], process[a0_0x3d5cbc(0x184)] ? process[a0_0x3d5cbc(0x184)]() : '-', process[a0_0x3d5cbc(0x1bb)] ? process[a0_0x3d5cbc(0x1bb)]() : '-', is_docker ? a0_0x3d5cbc(0xfa) : a0_0x3d5cbc(0x111), process[a0_0x3d5cbc(0x118)], process[a0_0x3d5cbc(0xee)], os[a0_0x3d5cbc(0x133)](), sys_locale), log[a0_0x3d5cbc(0x180)]('Basedir\x20%1;\x20data\x20in\x20%2', c[a0_0x3d5cbc(0x183)], c[a0_0x3d5cbc(0x10d)]), log[a0_0x3d5cbc(0x180)](a0_0x3d5cbc(0x181), process[a0_0x3d5cbc(0xfe)]['NODE_PATH']);
if ('' === (process[a0_0x3d5cbc(0xfe)]['NODE_PATH'] || '')) {
    log['crit'](a0_0x3d5cbc(0x199));
    throw new Error(a0_0x3d5cbc(0x1a4));
} else {
    let paths = process[a0_0x3d5cbc(0xfe)][a0_0x3d5cbc(0x12a)]['split'](path[a0_0x3d5cbc(0x12d)]), found = ![];
    for (let p of paths) {
        if ('' !== p && fs[a0_0x3d5cbc(0x13c)](path[a0_0x3d5cbc(0x113)](p, a0_0x3d5cbc(0x15a)))) {
            log[a0_0x3d5cbc(0x19c)](0x5, a0_0x3d5cbc(0x142), p), found = !![];
            break;
        }
        log['warn'](a0_0x3d5cbc(0x1b4));
    }
    if (!found) {
        log[a0_0x3d5cbc(0x152)](a0_0x3d5cbc(0x18b), process['env'][a0_0x3d5cbc(0x12a)]);
        throw new Error(a0_0x3d5cbc(0x13a));
    }
}
const hasICU = a0_0x3d5cbc(0x122) === typeof Intl;
try {
    const ICUTZ = hasICU ? Intl[a0_0x3d5cbc(0x126)]()[a0_0x3d5cbc(0x135)]()[a0_0x3d5cbc(0x187)] : a0_0x3d5cbc(0x166), now = new Date();
    log[a0_0x3d5cbc(0x180)](a0_0x3d5cbc(0x1c8), ICUTZ, process['env']['TZ'], -now[a0_0x3d5cbc(0x167)]());
} catch (a0_0x427c14) {
    log[a0_0x3d5cbc(0x108)]('app:\x20can\x27t\x20get\x20locale\x20timezone:\x20%1', a0_0x427c14);
}
const i18n = require(a0_0x3d5cbc(0x13b));
let locale = c['locale'] || sys_locale || a0_0x3d5cbc(0x1c2);
log[a0_0x3d5cbc(0x180)](a0_0x3d5cbc(0x16e), c[a0_0x3d5cbc(0x194)], locale), locale = locale[a0_0x3d5cbc(0x15e)](/ *, */);
let loaded = ![];
for (let l of locale) {
    let m = l[a0_0x3d5cbc(0x15e)](/\./);
    m[0x0] = (m[0x0] || '??')['replace']('_', '-'), m[0x1] = (m[0x1] || 'UTF-8')[a0_0x3d5cbc(0x114)]();
    if (a0_0x3d5cbc(0x1a8) !== m[0x1]) {
        log['err']('Locale\x20' + l + a0_0x3d5cbc(0x132));
        continue;
    }
    try {
        log[a0_0x3d5cbc(0x19c)](0x5, 'attempting\x20load\x20of\x20locale\x20%1', m[0x0]);
        if (i18n[a0_0x3d5cbc(0x11d)](m[0x0], ![])) {
            log[a0_0x3d5cbc(0x180)](a0_0x3d5cbc(0x1ab), i18n[a0_0x3d5cbc(0x172)](), m[0x0]), loaded = !![];
            break;
        }
    } catch (a0_0x3b70f5) {
        log[a0_0x3d5cbc(0x175)](a0_0x3d5cbc(0x192), m[0x0], a0_0x3b70f5);
    }
}
if (!loaded) {
    let m = locale[0x0][a0_0x3d5cbc(0x15e)](/\./);
    m[0x0] = (m[0x0] || '??')[a0_0x3d5cbc(0xfd)]('_', '-'), m[0x1] = (m[0x1] || 'UTF-8')['toUpperCase']();
    try {
        i18n[a0_0x3d5cbc(0x11d)](m[0x0], 'en-US') && (log[a0_0x3d5cbc(0x180)](a0_0x3d5cbc(0x1ab), i18n[a0_0x3d5cbc(0x172)](), m[0x0]), loaded = !![]);
    } catch (a0_0x5b9e48) {
        log[a0_0x3d5cbc(0x175)]('Failed\x20to\x20load\x20locale\x20%1:\x20%2', m[0x0], a0_0x5b9e48);
    }
}
!loaded && (log[a0_0x3d5cbc(0x159)](a0_0x3d5cbc(0x10b)), i18n['setLocale'](a0_0x3d5cbc(0xf3)));
log[a0_0x3d5cbc(0x180)]('Local\x20date/time\x20using\x20configured\x20timezone\x20and\x20locale\x20formatting\x20is\x20%1', new Date()[a0_0x3d5cbc(0x138)]());
if (is_docker) {
    try {
        const sp = path['resolve'](basedir, 'dist-config'), tp = path['resolve'](process['env'][a0_0x3d5cbc(0x137)] || a0_0x3d5cbc(0x1cc), a0_0x3d5cbc(0x188));
        fs[a0_0x3d5cbc(0x165)](sp, tp, {
            'preserveTimestamps': !![],
            'dereference': !![],
            'recursive': !![]
        });
    } catch (a0_0x319128) {
        log[a0_0x3d5cbc(0x169)](a0_0x319128);
    }
    try {
        const sp = path[a0_0x3d5cbc(0x1bf)](basedir, a0_0x3d5cbc(0x164)), tp = path['resolve'](process[a0_0x3d5cbc(0xfe)]['REACTOR_DATA_PREFIX'] || '/var/reactor', a0_0x3d5cbc(0x164));
        fs[a0_0x3d5cbc(0x165)](sp, tp, {
            'preserveTimestamps': !![],
            'dereference': !![],
            'recursive': !![]
        });
    } catch (a0_0x4eb715) {
        log[a0_0x3d5cbc(0x169)](a0_0x4eb715);
    }
    try {
        const ll = fs[a0_0x3d5cbc(0x1b2)](a0_0x3d5cbc(0x157))['toString']('utf-8')['split'](os[a0_0x3d5cbc(0x11f)]), ee = ll[a0_0x3d5cbc(0x1c6)](_0x302398 => _0x302398[a0_0x3d5cbc(0x178)](a0_0x3d5cbc(0x1cc)));
        ee ? log[a0_0x3d5cbc(0x1a5)](a0_0x3d5cbc(0x129), ee) : log[a0_0x3d5cbc(0x159)]('Container\x20has\x20no\x20identifiable\x20mount\x20for\x20/var/reactor.');
    } catch (a0_0x1a50e1) {
        log[a0_0x3d5cbc(0x169)](a0_0x1a50e1);
    }
}
const app = express(), struct = require(a0_0x3d5cbc(0xfc)), Engine = require('server/lib/Engine'), httpapi = require(a0_0x3d5cbc(0x1ad)), wsapi = require('server/wsapi/wsapi'), AlertManager = require(a0_0x3d5cbc(0x198));
process['on'](a0_0x3d5cbc(0x13f), (_0x25c3b3, _0xbc1c0c) => {
    const _0x149ea1 = a0_0x3d5cbc;
    console[_0x149ea1(0x115)](_0x149ea1(0x14a), _0x25c3b3), console[_0x149ea1(0x1c5)](_0x25c3b3), console[_0x149ea1(0x1c5)](_0xbc1c0c), console['trace']();
    try {
        process[_0x149ea1(0x10a)][_0x149ea1(0x100)](path[_0x149ea1(0x1bf)](c['logsdir'], _0x149ea1(0x1c1)), _0x25c3b3), log[_0x149ea1(0x1c5)](_0x149ea1(0x124), _0x25c3b3), log[_0x149ea1(0x169)](_0x25c3b3), log[_0x149ea1(0x1c5)](_0x149ea1(0x14f));
    } catch (_0x5067b2) {
    }
}), process['on']('uncaughtException', _0x22a252 => {
    const _0x1ec500 = a0_0x3d5cbc;
    console[_0x1ec500(0x1c5)](_0x1ec500(0x18c), _0x22a252), console[_0x1ec500(0x189)](_0x22a252);
    try {
        process[_0x1ec500(0x10a)][_0x1ec500(0x100)](path['resolve'](c[_0x1ec500(0x163)], 'unhandled.json'), _0x22a252), log[_0x1ec500(0x1c5)]('Trapped\x20unhandled\x20exception:\x20%1', _0x22a252), log['error'](_0x1ec500(0x14f));
    } catch (_0x11b4c1) {
    }
    _0x1ec500(0x19b) === _0x22a252[_0x1ec500(0x174)] && setTimeout(function () {
        const _0xd5177a = _0x1ec500;
        process[_0xd5177a(0x19a)](0x1);
    }, 0xfa);
}), log[a0_0x3d5cbc(0x175)](a0_0x3d5cbc(0x103)), struct[a0_0x3d5cbc(0x116)](c[a0_0x3d5cbc(0x183)])[a0_0x3d5cbc(0xf8)](async () => {
    const _0x518eff = a0_0x3d5cbc, _0x171026 = Engine[_0x518eff(0x17f)]();
    try {
        const _0x4bf821 = parseInt(process['versions'][_0x518eff(0x160)][_0x518eff(0x15e)]('.')[0x0]);
        let _0x6d3479 = !![];
        if (!isNaN(_0x4bf821)) {
            const _0x4108af = NODE_VERSIONS[_0x4bf821];
            if (c?.[_0x518eff(0x1bd)] && c[_0x518eff(0x1bd)] == _0x4bf821)
                log[_0x518eff(0x19c)](0x5, _0x518eff(0xec), _0x4bf821);
            else {
                if (_0x4108af) {
                    log[_0x518eff(0x1a5)]('nodejs\x20v%1\x20known,\x20supported\x20through\x20%2', _0x4bf821, new Date(_0x4108af[_0x518eff(0x130)])[_0x518eff(0xf0)]());
                    const _0x137f14 = _0x4108af['eol'] - NODE_EOL_WARNING * 0x5265c00;
                    if (Date[_0x518eff(0x18a)]() >= _0x4108af['eol'])
                        AlertManager['addAlert'](AlertManager[_0x518eff(0x1ae)], _0x518eff(0x186), { 'tag': _0x518eff(0x15d) }, process[_0x518eff(0x1c0)]['node']), _0x6d3479 = ![];
                    else
                        Date['now']() >= _0x137f14 && (AlertManager['addAlert'](AlertManager['NOTICE'], _0x518eff(0x110), { 'tag': _0x518eff(0x15d) }, process[_0x518eff(0x1c0)][_0x518eff(0x160)]), _0x6d3479 = ![]);
                } else
                    AlertManager['addAlert'](AlertManager[_0x518eff(0x1ae)], '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': _0x518eff(0x15d) }, process[_0x518eff(0x1c0)][_0x518eff(0x160)]), _0x6d3479 = ![];
            }
        }
        _0x6d3479 && AlertManager['dismissTag'](_0x518eff(0x15d)), process[_0x518eff(0x184)] && 0x0 === process['getuid']() && !is_docker ? AlertManager[_0x518eff(0x105)](AlertManager[_0x518eff(0x1ae)], _0x518eff(0x16a), { 'tag': 'reactor-root-priv' }) : AlertManager['dismissTag'](_0x518eff(0x1be));
    } catch (_0x13e187) {
        log['exception'](_0x13e187);
    }
    !valid_config ? AlertManager[_0x518eff(0x105)](AlertManager[_0x518eff(0x107)], _0x518eff(0x1b9), { 'tag': 'sysconfig-invalid' }, rcf) : AlertManager[_0x518eff(0x11b)]('sysconfig-invalid');
    if (!![] === Configuration[_0x518eff(0x1b5)]('reactor.engine.wait_all_controllers', _0x518eff(0x1ac), ![])) {
        log[_0x518eff(0x175)](_0x518eff(0x19f));
        const _0x4d3121 = Date['now']();
        let _0x5e518e = await struct[_0x518eff(0x1a7)](Configuration[_0x518eff(0x1b5)](_0x518eff(0x171), _0x518eff(0x140), 0xea60));
        log['info'](_0x518eff(0x1c9), Date[_0x518eff(0x18a)]() - _0x4d3121);
        let _0x4e7f51 = 0x0;
        for (let _0x14ecd8 of _0x5e518e) {
            !_0x14ecd8[_0x518eff(0x136)] && (log[_0x518eff(0x175)](_0x518eff(0x177), _0x14ecd8['id'], _0x14ecd8[_0x518eff(0xef)]), ++_0x4e7f51);
        }
        0x0 === _0x4e7f51 && log[_0x518eff(0x175)](_0x518eff(0x1a9), _0x5e518e['length']);
    }
    var _0x1ea2d7 = ![], _0x6e04b4 = async function (_0x191fa9) {
            const _0x4830d5 = _0x518eff;
            if (_0x1ea2d7)
                return;
            _0x1ea2d7 = !![], log[_0x4830d5(0x180)](_0x4830d5(0x104), _0x191fa9);
            try {
                log['notice'](_0x4830d5(0x16f)), await _0x171026[_0x4830d5(0x176)]();
            } catch (_0x36fc01) {
                log['exception'](_0x36fc01);
            }
            try {
                log[_0x4830d5(0x175)](_0x4830d5(0x14b)), await struct['stop']();
            } catch (_0x19930f) {
                log[_0x4830d5(0x169)](_0x19930f), console[_0x4830d5(0x1c5)](_0x19930f);
            }
            try {
                log[_0x4830d5(0x175)](_0x4830d5(0x1c7)), await wsapi['stop'](), await httpapi['stop']();
            } catch (_0x20b4ff) {
                log[_0x4830d5(0x169)](_0x20b4ff), console[_0x4830d5(0x1c5)](_0x20b4ff);
            }
            try {
                log[_0x4830d5(0x175)](_0x4830d5(0x12b));
                let _0x2d0bb9 = require(_0x4830d5(0x18e));
                _0x2d0bb9[_0x4830d5(0x176)]();
            } catch (_0x312c35) {
                log[_0x4830d5(0x169)](_0x312c35), console[_0x4830d5(0x1c5)](_0x312c35);
            }
            log[_0x4830d5(0x180)]('Shutdown\x20complete,\x20process\x20ID\x20%1', process['pid']);
            try {
                log['always'](_0x4830d5(0x17d)), await Logger[_0x4830d5(0xf9)](), console[_0x4830d5(0x115)](_0x4830d5(0x193));
            } catch (_0x380928) {
                console[_0x4830d5(0x1c5)](_0x4830d5(0xeb), _0x380928);
            }
            try {
                opts[_0x4830d5(0x147)] && fs[_0x4830d5(0x13d)](opts['pidfile']);
            } catch (_0x284045) {
                console[_0x4830d5(0x1c5)](_0x284045);
            }
            setTimeout(() => {
                const _0x11418d = _0x4830d5;
                console[_0x11418d(0x1c5)]('FORCED\x20EXIT'), process['exit'](_0x11418d(0x14c) === _0x191fa9 ? 0x1 : 0x7f);
            }, 0x7d0), process['exit'](_0x4830d5(0x14c) === _0x191fa9 ? 0x1 : 0x7f);
        };
    process['on']('SIGINT', _0x6e04b4), process['on'](_0x518eff(0x1a1), _0x6e04b4), process['on'](_0x518eff(0x14c), _0x6e04b4), process['on']('SIGHUP', _0x6e04b4), process['on'](_0x518eff(0xf5), _0x145b2d => {
        const _0x3b0a4b = _0x518eff;
        log[_0x3b0a4b(0x19c)](0x5, _0x3b0a4b(0x123), _0x145b2d);
        if ('shutdown' === _0x145b2d)
            log['notice'](_0x3b0a4b(0x1bc)), _0x6e04b4(_0x3b0a4b(0x17c));
        else
            _0x3b0a4b(0xfb) === _0x145b2d && (log[_0x3b0a4b(0x175)](_0x3b0a4b(0x1a0)), _0x6e04b4(_0x3b0a4b(0x14c)));
    }), process['on'](_0x518eff(0x19a), function () {
        const _0x3ae7d8 = _0x518eff;
        console[_0x3ae7d8(0x115)](_0x3ae7d8(0x162));
    }), log[_0x518eff(0x175)](_0x518eff(0xed)), httpapi[_0x518eff(0x116)](app, c[_0x518eff(0x183)])[_0x518eff(0xf8)](_0x5be645 => {
        const _0x2218ca = _0x518eff;
        if (Configuration[_0x2218ca(0x1b5)]('reactor.http_proxy_enabled', _0x2218ca(0x1ac), ![])) {
            const _0x1eea7f = require('./server/lib/httpproxy');
            log[_0x2218ca(0x175)](_0x2218ca(0xf4)), _0x1eea7f[_0x2218ca(0x116)](app);
        }
        log['notice']('Starting\x20WSAPI...'), wsapi[_0x2218ca(0x116)](app, _0x5be645)['then'](async () => {
            const _0xa52a78 = _0x2218ca;
            wsapi[_0xa52a78(0x151)]();
        });
    })[_0x518eff(0x17e)](_0x24d96b => {
        const _0x6800dc = _0x518eff;
        log['err'](_0x6800dc(0x195), _0x24d96b), _0x6800dc(0x19b) === _0x24d96b[_0x6800dc(0x174)] && (log[_0x6800dc(0x108)](_0x6800dc(0x12e)), process['kill'](process[_0x6800dc(0x16d)], _0x6800dc(0x14c)));
    });
    if (opts[_0x518eff(0x1ce)] || ![] === Configuration[_0x518eff(0x1b5)]('reactor.engine.enabled', _0x518eff(0x1ac), !![])) {
        const _0x4100d6 = require(_0x518eff(0x13b));
        log[_0x518eff(0x152)]('Engine\x20startup\x20suppressed;\x20no\x20rules\x20will\x20be\x20processed.'), AlertManager[_0x518eff(0x105)](AlertManager[_0x518eff(0x107)], _0x4100d6['_T'](_0x518eff(0x148)), { 'tag': 'engine-disabled' });
    } else {
        let _0x597124 = Configuration[_0x518eff(0x1b5)](_0x518eff(0x191), _0x518eff(0x140), 0x0);
        if (_0x597124 > 0x0) {
            const _0x58c89a = require(_0x518eff(0x121));
            await _0x58c89a['TimedPromise'](() => {
                const _0x9163cd = _0x518eff;
                log[_0x9163cd(0x180)](_0x9163cd(0x1cd), _0x597124 / 0x3e8);
            }, _0x597124)['catch'](_0x2e251c => {
            });
        }
        log['notice'](_0x518eff(0x106)), struct[_0x518eff(0x15c)](_0x171026);
        try {
            _0x171026[_0x518eff(0x116)](), AlertManager['dismissTag'](_0x518eff(0x155));
        } catch (_0x219a6b) {
            log[_0x518eff(0x108)]('Failed\x20to\x20start\x20engine:\x20%1', _0x219a6b), log[_0x518eff(0x169)](_0x219a6b);
        }
    }
    try {
        const _0x3fbe40 = Configuration[_0x518eff(0x1b1)]();
        let _0xe28bd6 = !![];
        for (const _0x2ccdc0 of _0x3fbe40) {
            const _0x196484 = Configuration[_0x518eff(0x17f)](_0x2ccdc0), _0x5ed7c8 = _0x196484 && _0x196484[_0x518eff(0x117)]();
            _0x5ed7c8 ? (AlertManager[_0x518eff(0x105)](AlertManager[_0x518eff(0x107)], [
                _0x518eff(0x11e),
                _0x518eff(0x10e)
            ], { 'tag': _0x518eff(0x17a) + _0x2ccdc0 }, _0x2ccdc0 + '.yaml'), log[_0x518eff(0x152)](_0x518eff(0x153), _0x2ccdc0 + _0x518eff(0x144)), _0xe28bd6 = ![]) : AlertManager[_0x518eff(0x11b)](_0x518eff(0x17a) + _0x2ccdc0);
        }
        _0xe28bd6 && log[_0x518eff(0x175)](_0x518eff(0x1aa), _0x3fbe40);
    } catch (_0x30c1c1) {
        log[_0x518eff(0x169)](_0x30c1c1);
    }
    log['notice'](_0x518eff(0x190));
});
if (opts[a0_0x3d5cbc(0x119)]) {
    let r = repl[a0_0x3d5cbc(0x116)]('>\x20'), ctx = r[a0_0x3d5cbc(0x102)];
    ctx['struct'] = struct, ctx[a0_0x3d5cbc(0x15f)] = Engine['getInstance'](struct), r['on']('exit', () => {
        const _0x54d7d3 = a0_0x3d5cbc;
        Engine[_0x54d7d3(0x17f)](struct)[_0x54d7d3(0x176)](), struct['stop'](), process[_0x54d7d3(0x19a)](0x1);
    });
}