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B,GAAI,WACA,OAAO,IAAI,MAEnB,GACJ,EAOA,IAAK,QAAQ,IAOb,KAAM,QAAQ,KAad,SAAI,GAAU,OAAO,QAAQ,EAAE,KAAM,EAOrC,OAAQ,QAAQ,OAOhB,MAAO,QAAQ,MASf,YAAI,GAAa,OAAO,QAAQ,EAAE,QAAS,EAS3C,WAAI,GAAY,OAAO,QAAQ,EAAE,OAAQ,EAQzC,aAAI,GAAc,OAAO,IAAI,SAAU,EAOvC,YAAI,GAAa,OAAO,QAAQ,QAAS,EAOzC,UAAI,GAAW,OAAO,MAAO,EAO7B,QAAS,QAOT,KAAM,IAAI,KAOV,eAAI,GAAgB,OAAO,IAAI,WAAY","file":"/npm/node-red@5.0.0-beta.5/lib/red.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/node-red@5.0.0-beta.5/lib/red.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/*!\n * Copyright JS Foundation and other contributors, http://js.foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n **/\n\nvar fs = require(\"fs\");\nvar path = require('path');\n\nvar runtime = require(\"@node-red/runtime\");\nvar redUtil = require(\"@node-red/util\");\n\nvar api = require(\"@node-red/editor-api\");\n\nvar server = null;\nvar apiEnabled = false;\n\n// Ensure ipv4 results are returned first: https://github.com/node-red/node-red/issues/4010\nconst dns = require('dns');\ndns.setDefaultResultOrder('ipv4first');\n\nfunction checkVersion(userSettings) {\n    var semver = require('semver');\n    if (!semver.satisfies(process.version,\">=18.0.0\")) {\n        // var e = new Error(\"Unsupported version of Node.js\");\n        // e.code = \"unsupported_version\";\n        // throw e;\n        userSettings.UNSUPPORTED_VERSION = process.version;\n    }\n}\n/**\n * This module provides the full Node-RED application, with both the runtime\n * and editor components built in.\n *\n * The API this module exposes allows it to be embedded within another Node.js\n * application.\n *\n * @namespace node-red\n */\nmodule.exports = {\n    /**\n     * Initialise the Node-RED application.\n     * @param {server} httpServer - the HTTP server object to use\n     * @param {Object} userSettings - an object containing the runtime settings\n     * @memberof node-red\n     */\n    init: function(httpServer, userSettings) {\n        if (!userSettings) {\n            userSettings = httpServer;\n            httpServer = null;\n        }\n\n        if (!userSettings.SKIP_BUILD_CHECK) {\n            checkVersion(userSettings);\n        }\n\n        if (!userSettings.hasOwnProperty(\"coreNodesDir\")) {\n            userSettings.coreNodesDir = path.dirname(require.resolve(\"@node-red/nodes\"))\n        }\n        redUtil.init(userSettings);\n        if (userSettings.httpAdminRoot !== false) {\n            // Initialise the runtime\n            runtime.init(userSettings,httpServer,api);\n            // Initialise the editor-api\n            api.init(userSettings,httpServer,runtime.storage,runtime);\n            // Attach the runtime admin app to the api admin app\n            api.httpAdmin.use(runtime.httpAdmin);\n\n            apiEnabled = true;\n            server = httpServer;\n        } else {\n            runtime.init(userSettings, httpServer);\n            apiEnabled = false;\n            if (httpServer) {\n                server = httpServer;\n            } else {\n                server = null;\n            }\n        }\n        return;\n    },\n    /**\n     * Start the Node-RED application.\n     * @return {Promise} - resolves when complete\n     * @memberof node-red\n     */\n    start: function() {\n        // The top level red.js has always used 'otherwise' on the promise returned\n        // here. This is a non-standard promise function coming from our early use\n        // of the when.js library.\n        // We want to remove all dependency on when.js as native Promises now exist.\n        // But we have the issue that some embedders of Node-RED may have copied our\n        // top-level red.js a bit too much.\n        //\n        let startPromise = runtime.start().then(function() {\n            if (apiEnabled) {\n                return api.start();\n            }\n        });\n        startPromise._then = startPromise.then;\n        startPromise.then = function(resolve,reject) {\n            var inner = startPromise._then(resolve,reject);\n            inner.otherwise = function(cb) {\n                redUtil.log.error(\"**********************************************\");\n                redUtil.log.error(\"* Deprecated call to RED.start().otherwise() *\");\n                redUtil.log.error(\"* This will be removed in Node-RED 2.x       *\");\n                redUtil.log.error(\"* Use RED.start().catch() instead            *\")\n                redUtil.log.error(\"**********************************************\");\n                return inner.catch(cb);\n            }\n            return inner;\n        }\n        return startPromise;\n    },\n    /**\n     * Stop the Node-RED application.\n     *\n     * Once called, Node-RED should not be restarted until the Node.JS process is\n     * restarted.\n     *\n     * @return {Promise} - resolves when complete\n     * @memberof node-red\n     */\n    stop: function() {\n        return runtime.stop().then(function() {\n            if (apiEnabled) {\n                return api.stop();\n            }\n        })\n    },\n\n    /**\n     * Logging utilities\n     * @see @node-red/util_log\n     * @memberof node-red\n     */\n    log: redUtil.log,\n\n    /**\n     * General utilities\n     * @see @node-red/util_util\n     * @memberof node-red\n     */\n    util: redUtil.util,\n\n\n    /**\n     * This provides access to the internal nodes module of the\n     * runtime. The details of this API remain undocumented as they should not\n     * be used directly.\n     *\n     * Most administrative actions should be performed use the runtime api\n     * under [node-red.runtime]{@link node-red.runtime}.\n     *\n     * @memberof node-red\n     */\n    get nodes() { return runtime._.nodes },\n\n    /**\n     * Runtime events emitter\n     * @see @node-red/util_events\n     * @memberof node-red\n     */\n    events: redUtil.events,\n\n    /**\n     * Runtime hooks engine\n     * @see @node-red/runtime_hooks\n     * @memberof node-red\n     */\n    hooks: runtime.hooks,\n\n\n    /**\n     * This provides access to the internal settings module of the\n     * runtime.\n     *\n     * @memberof node-red\n     */\n    get settings() { return runtime._.settings },\n\n\n    /**\n     * Get the version of the runtime\n     * @return {String} - the runtime version\n     * @function\n     * @memberof node-red\n     */\n    get version() { return runtime._.version },\n\n\n    /**\n     * The express application for the Editor Admin API\n     * @type ExpressApplication\n     * @memberof node-red\n     */\n    get httpAdmin() { return api.httpAdmin },\n\n    /**\n     * The express application for HTTP Nodes\n     * @type ExpressApplication\n     * @memberof node-red\n     */\n    get httpNode() { return runtime.httpNode },\n\n    /**\n     * The HTTP Server used by the runtime\n     * @type HTTPServer\n     * @memberof node-red\n     */\n    get server() { return server },\n\n    /**\n     * The runtime api\n     * @see @node-red/runtime\n     * @memberof node-red\n     */\n    runtime: runtime,\n\n    /**\n     * The editor authentication api.\n     * @see @node-red/editor-api_auth\n     * @memberof node-red\n     */\n    auth: api.auth,\n\n    /**\n     * The editor authentication api.\n     * @see @node-red/editor-api_auth\n     * @memberof node-red\n     */\n    get diagnostics() { return api.diagnostics }\n};\n"]}