From 2f5a9d25bfa50f319b1bbe8d93a4e2a52a214124 Mon Sep 17 00:00:00 2001 From: asac Date: Thu, 18 Jul 2019 17:28:36 +0300 Subject: [PATCH] small update --- README.md | 2 +- psknode/bin/pskbuild.js | 0 psknode/bin/psknode.js | 0 psknode/bin/scripts/psknode.js | 16 ++++++++++++++-- psknode/bundles/pskruntime.js | 24 ++++++++++++++++++++---- psknode/bundles/readme.txt | 1 - psknode/core/launcher.js | 11 +++++++---- psknode/core/utils/exitHandler.js | 22 +++++++++++++++++++--- 8 files changed, 61 insertions(+), 15 deletions(-) delete mode 100644 psknode/bin/pskbuild.js delete mode 100644 psknode/bin/psknode.js delete mode 100644 psknode/bundles/readme.txt diff --git a/README.md b/README.md index 0204f0e..27d7468 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,6 @@ When a new version of PrivateSky code will be released the clones of the pskrunt The following scripts are available to run: ``` npm run start ``` will run a PrivateSky node -``` npm run build ``` will build the code for the domain and deply in the current domain +``` npm run build ``` will build the code for the domain and deploy in the current domain ``` npm run watch ``` will automatically build the code for the domain and deploy ``` npm run console ``` will launch a bash or cmd with paths to run pskadmin tools diff --git a/psknode/bin/pskbuild.js b/psknode/bin/pskbuild.js deleted file mode 100644 index e69de29..0000000 diff --git a/psknode/bin/psknode.js b/psknode/bin/psknode.js deleted file mode 100644 index e69de29..0000000 diff --git a/psknode/bin/scripts/psknode.js b/psknode/bin/scripts/psknode.js index 208e070..b1ce287 100644 --- a/psknode/bin/scripts/psknode.js +++ b/psknode/bin/scripts/psknode.js @@ -5,6 +5,8 @@ */ const {spawnSync, fork, spawn} = require('child_process'); +const max_timeout = 10*60*1000; // 10 minutes +const restartDelays = {}; let shouldRestart = true; const forkedProcesses = {}; @@ -16,11 +18,21 @@ function startProcess(filePath) { console.log('SPAWNED ', forkedProcesses[filePath].pid); + function restartWithDelay(filePath){ + let timeout = restartDelays[filePath] || 100; + console.log(`Process will restart in ${timeout} ms ...`); + setTimeout(()=>{ + restartDelays[filePath] = (timeout * 2) % max_timeout; + startProcess(filePath); + }, timeout); + } + function errorHandler(filePath) { + let timeout = 100; return function (error) { console.log(`\x1b[31mException caught on spawning file ${filePath} `, error ? error : "", "\x1b[0m"); //last string is to reset terminal colours if (shouldRestart) { - startProcess(filePath); + restartWithDelay(filePath); } } } @@ -29,7 +41,7 @@ function startProcess(filePath) { return function () { console.log(`\x1b[33mExit caught on spawned file ${filePath}`, "\x1b[0m"); //last string is to reset terminal colours if (shouldRestart) { - startProcess(filePath); + restartWithDelay(filePath); } } } diff --git a/psknode/bundles/pskruntime.js b/psknode/bundles/pskruntime.js index 53ddeec..197fafe 100644 --- a/psknode/bundles/pskruntime.js +++ b/psknode/bundles/pskruntime.js @@ -10940,13 +10940,29 @@ const events = ["exit", "SIGINT", "SIGUSR1", "SIGUSR2", "uncaughtException", "SI module.exports = function manageShutdownProcess(childrenList){ + let shutting = false; function handler(){ - console.log("Handling exit event on", process.pid, "arguments:", arguments); + //console.log("Handling exit event on", process.pid, "arguments:", arguments); var childrenNames = Object.keys(childrenList); for(let j=0; j{ @@ -11508,4 +11524,4 @@ if(typeof global.$$.uidGenerator == "undefined"){ },{"./lib/Combos":"/home/cosmin/Workspace/reorganizing/privatesky/modules/swarmutils/lib/Combos.js","./lib/OwM":"/home/cosmin/Workspace/reorganizing/privatesky/modules/swarmutils/lib/OwM.js","./lib/Queue":"/home/cosmin/Workspace/reorganizing/privatesky/modules/swarmutils/lib/Queue.js","./lib/beesHealer":"/home/cosmin/Workspace/reorganizing/privatesky/modules/swarmutils/lib/beesHealer.js","./lib/pskconsole":"/home/cosmin/Workspace/reorganizing/privatesky/modules/swarmutils/lib/pskconsole.js","./lib/safe-uuid":"/home/cosmin/Workspace/reorganizing/privatesky/modules/swarmutils/lib/safe-uuid.js","./lib/uidGenerator":"/home/cosmin/Workspace/reorganizing/privatesky/modules/swarmutils/lib/uidGenerator.js"}],"utils":[function(require,module,exports){ exports.fsExt = require("./FSExtension").fsExt; },{"./FSExtension":"/home/cosmin/Workspace/reorganizing/privatesky/libraries/utils/FSExtension.js"}]},{},["/home/cosmin/Workspace/reorganizing/privatesky/builds/tmp/pskruntime.js"]) -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJidWlsZHMvdG1wL3Bza3J1bnRpbWUuanMiLCJidWlsZHMvdG1wL3Bza3J1bnRpbWVfaW50ZXJtZWRpYXIuanMiLCJsaWJyYXJpZXMvZG9tYWluQmFzZS9kb21haW5QdWJTdWIuanMiLCJsaWJyYXJpZXMvbGF1bmNoZXIvY29tcG9uZW50cy5qcyIsImxpYnJhcmllcy91dGlscy9GU0V4dGVuc2lvbi5qcyIsIm1vZHVsZXMvY2FsbGZsb3cvY29uc3RhbnRzLmpzIiwibW9kdWxlcy9jYWxsZmxvdy9saWIvSW50ZXJjZXB0b3JSZWdpc3RyeS5qcyIsIm1vZHVsZXMvY2FsbGZsb3cvbGliL2Nob3Jlb2dyYXBoaWVzL1N3YXJtRGVidWcuanMiLCJtb2R1bGVzL2NhbGxmbG93L2xpYi9jaG9yZW9ncmFwaGllcy9zd2FybUluc3RhbmNlc01hbmFnZXIuanMiLCJtb2R1bGVzL2NhbGxmbG93L2xpYi9jaG9yZW9ncmFwaGllcy91dGlsaXR5RnVuY3Rpb25zL2Fzc2V0LmpzIiwibW9kdWxlcy9jYWxsZmxvdy9saWIvY2hvcmVvZ3JhcGhpZXMvdXRpbGl0eUZ1bmN0aW9ucy9iYXNlLmpzIiwibW9kdWxlcy9jYWxsZmxvdy9saWIvY2hvcmVvZ3JhcGhpZXMvdXRpbGl0eUZ1bmN0aW9ucy9jYWxsZmxvdy5qcyIsIm1vZHVsZXMvY2FsbGZsb3cvbGliL2Nob3Jlb2dyYXBoaWVzL3V0aWxpdHlGdW5jdGlvbnMvc3dhcm0uanMiLCJtb2R1bGVzL2NhbGxmbG93L2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kaXJlY3Rvcnkgb3IgZmlsZSBcIiR7c3JjfVwiIGRvZXMgbm90IGV4aXN0cyFgO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBsZXQgc3JjU3RhdCA9IGZzLmxzdGF0U3luYyhzcmMpO1xuICAgICAgICAgICAgaWYoc3JjU3RhdC5pc0RpcmVjdG9yeSgpKSB7XG4gICAgICAgICAgICAgICAgX19jb3B5RGlyKHNyYywgZGVzdCwgb3B0aW9ucyk7XG4gICAgICAgICAgICB9IGVsc2UgaWYoc3JjU3RhdC5pc0ZpbGUoKSkge1xuICAgICAgICAgICAgICAgIC8vIGRlc3RpbmF0aW9uIG11c3QgYmUgYSBmaWxlIHRvb1xuICAgICAgICAgICAgICAgIF9fY29weUZpbGUoc3JjLCBkZXN0LCBvcHRpb25zKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICBpZihyZXRocm93KXtcbiAgICAgICAgICAgICAgICB0aHJvdyBlcnI7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBsb2coZXJyLCB0cnVlKTtcbiAgICAgICAgICAgIGNhbGxiYWNrKGVycik7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cblxuICAgICAgICBjYWxsYmFjaygpO1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIENvcHkgYSBkaXJlY3RvcnkuIFRoZSBkaXJlY3RvcnkgY2FuIGhhdmUgcmVjdXJzaXZlIGNvbnRlbnRzLiBMaWtlIGNvcHkgLXIuXG4gICAgICogTk9URTogSXR0IHdpbGwgY29weSBldmVyeXRoaW5nIGluc2lkZSBvZiB0aGUgZGlyZWN0b3J5LCBub3QgdGhlIGVudGlyZSBkaXJlY3RvcnkgaXRzZWxmLlxuICAgICAqIE5PVEU6IElmIHRoZSBkZXN0aW5hdGlvbiBwYXRoIHN0cnVjdHVyZSBkb2VzIG5vdCBleGlzdHMsIGl0IHdpbGwgYmUgY3JlYXRlZC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Mud3JpdGVGaWxlU3luYyhkZXN0LCBjb250ZW50KTtcbiAgICB9XG5cbiAgICAvKipcbiAgICAgKiBSZW1vdmVzIGEgZmlsZSBvciBkaXJlY3RvcnkuIFRoZSBkaXJlY3RvcnkgY2FuIGhhdmUgcmVjdXJzaXZlIGNvbnRlbnRzLiBMaWtlIHJtIC1yZlxuICAgICAqIEBwYXJhbSBzcmMge1N0cmluZ30gUGF0aFxuICAgICAqIEBwYXJhbSBjYWxsYmFjayB7RnVuY3Rpb259XG4gICAgICogQHByaXZhdGVcbiAgICAgKi9cbiAgICB2YXIgX19yZW1vdmUgPSBmdW5jdGlvbihzcmMsIGNhbGxiYWNrKSB7XG4gICAgICAgIHNyYyA9IF9fcmVzb2x2ZVBhdGgoc3JjKTtcblxuICAgICAgICBjYWxsYmFjayA9IGNhbGxiYWNrIHx8IGZ1bmN0aW9uKCl7fTtcblxuICAgICAgICBsb2coYFJlbW92aW5nICR7c3JjfWApO1xuXG4gICAgICAgIHRyeXtcbiAgICAgICAgICAgIGxldCBjdXJyZW50ID0gZnMubHN0YXRTeW5jKHNyYyk7XG4gICAgICAgICAgICBpZihjdXJyZW50LmlzRGlyZWN0b3J5KCkpIHtcbiAgICAgICAgICAgICAgICBfX3JtRGlyKHNyYyk7XG4gICAgICAgICAgICB9IGVsc2UgaWYoY3VycmVudC5pc0ZpbGUoKSkge1xuICAgICAgICAgICAgICAgIF9fcm1GaWxlKHNyYyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgaWYoZXJyLmNvZGUgJiYgZXJyLmNvZGUgPT09IFwiRU5PRU5UXCIpe1xuICAgICAgICAgICAgICAgIC8vaWdub3JpbmcgZXJyb3JzIGxpa2UgXCJmaWxlL2RpcmVjdG9yeSBkb2VzIG5vdCBleGlzdFwiXG4gICAgICAgICAgICAgICAgZXJyID0gbnVsbDtcbiAgICAgICAgICAgIH1lbHNle1xuICAgICAgICAgICAgICAgIGxvZyhlcnIsIHRydWUpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY2FsbGJhY2soZXJyKTtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuXG4gICAgICAgIGNhbGxiYWNrKCk7XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogUmVtb3ZlcyBhIGRpcmVjdG9yeS4gVGhlIGRpcmVjdG9yeSBjYW4gaGF2ZSByZWN1cnNpdmUgY29udGVudHMuIExpa2Ugcm0gLXJmXG4gICAgICogQHBhcmFtIGRpciB7U3RyaW5nfSBQYXRoXG4gICAgICogQHByaXZhdGVcbiAgICAgKi9cbiAgICB2YXIgX19ybURpciA9IGZ1bmN0aW9uIChkaXIpIHtcbiAgICAgICAgZGlyID0gX19yZXNvbHZlUGF0aChkaXIpO1xuXG4gICAgICAgIGlmICghZnMuZXhpc3RzU3luYyhkaXIpKSB7XG4gICAgICAgICAgICBsb2coYERpcmVjdG9yeSAke2Rpcn0gZG9lcyBub3QgZXhpc3QhYCwgdHJ1ZSk7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cblxuICAgICAgICB2YXIgbGlzdCA9IGZzLnJlYWRkaXJTeW5jKGRpcik7XG4gICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgbGlzdC5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgdmFyIGZpbGVuYW1lID0gcGF0aC5qb2luKGRpciwgbGlzdFtpXSk7XG4gICAgICAgICAgICB2YXIgc3RhdCA9IGZzLmxzdGF0U3luYyhmaWxlbmFtZSk7XG5cbiAgICAgICAgICAgIGlmIChzdGF0LmlzRGlyZWN0b3J5KCkpIHtcbiAgICAgICAgICAgICAgICBfX3JtRGlyKGZpbGVuYW1lLCBudWxsKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgLy8gcm0gZmlsZW5hbWVcbiAgICAgICAgICAgICAgICBmcy51bmxpbmtTeW5jKGZpbGVuYW1lKTtcbiAgICA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gbm90IGFmdGVyIGl0XG4gICAgICogQHJldHVybiB7QXJyYXk8U2V0PGZ1bmN0aW9uPj59XG4gICAgICovXG4gICAgZnVuY3Rpb24gZ2V0VmFsdWVSZWN1cnNpdmVseShzZWFyY2hhYmxlTm9kZXMsIGtleXNHZW5lcmF0b3IpIHtcbiAgICAgICAgY29uc3Qge3ZhbHVlOiBub2RlTmFtZSwgZG9uZX0gPSBrZXlzR2VuZXJhdG9yLm5leHQoKTtcblxuICAgICAgICBjb25zdCBuZXh0Tm9kZXMgPSBbXTtcblxuICAgICAgICBmb3IgKGNvbnN0IG5vZGVJblJ1bGVzIG9mIHNlYXJjaGFibGVOb2Rlcykge1xuICAgICAgICAgICAgY29uc3QgbmV4dE5vZGVGb3JBbGwgPSBub2RlSW5SdWxlcy5nZXQoJyonKTtcbiAgICAgICAgICAgIGNvbnN0IG5leHROb2RlID0gbm9kZUluUnVsZXMuZ2V0KG5vZGVOYW1lKTtcblxuICAgICAgICAgICAgaWYgKHR5cGVvZiBuZXh0Tm9kZSAhPT0gXCJ1bmRlZmluZWRcIikge1xuICAgICAgICAgICAgICAgIG5leHROb2Rlcy5wdXNoKG5leHROb2RlKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHR5cGVvZiBuZXh0Tm9kZUZvckFsbCAhPT0gXCJ1bmRlZmluZWRcIikge1xuICAgICAgICAgICAgICAgIG5leHROb2Rlcy5wdXNoKG5leHROb2RlRm9yQWxsKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICB9XG5cbiAgICAgICAgaWYgKGRvbmUpIHtcbiAgICAgICAgICAgIHJldHVybiBuZXh0Tm9kZXM7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gZ2V0VmFsdWVSZWN1cnNpdmVseShuZXh0Tm9kZXMsIGtleXNHZW5lcmF0b3IpO1xuICAgIH1cblxuXG4gICAgLyoqKioqKioqKioqKiogUFVCTElDIE1FVEhPRFMgKioqKioqKioqKioqKi9cblxuICAgI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WxmID0gdGhpcztcbiAgICBmdW5jdGlvbiB3cmFwQ2FsbChvcmlnaW5hbCwgcHJlZml4TmFtZSl7XG4gICAgICAgIHJldHVybiBmdW5jdGlvbiguLi5hcmdzKXtcbiAgICAgICAgICAgIC8vY29uc29sZS5sb2coXCJwcmVmaXhOYW1lXCIsIHByZWZpeE5hbWUpXG4gICAgICAgICAgICB2YXIgcHJldmlvdXNQcmVmaXggPSAkJC5saWJyYXJ5UHJlZml4O1xuICAgICAgICAgICAgdmFyIHByZXZpb3VzTGlicmFyeSA9ICQkLl9fZ2xvYmFsLmN1cnJlbnRMaWJyYXJ5O1xuXG4gICAgICAgICAgICAkJC5saWJyYXJ5UHJlZml4ID0gcHJlZml4TmFtZTtcbiAgICAgICAgICAgICQkLl9fZ2xvYmFsLmN1cnJlbnRMaWJyYXJ5ID0gc2VsZjtcbiAgICAgICAgICAgIHRyeXtcbiAgICAgICAgICAgICAgICB2YXIgcmV0ID0gb3JpZ2luYWwuYXBwbHkodGhpcywgYXJncyk7XG4gICAgICAgICAgICAgICAgJCQubGlicmFyeVByZWZpeCA9IHByZXZpb3VzUHJlZml4IDtcbiAgICAgICAgICAgICAgICAkJC5fX2dsb2JhbC5jdXJyZW50TGlicmFyeSA9IHByZXZpb3VzTGlicmFyeTtcbiAgICAgICAgICAgIH1jYXRjaChlcnIpe1xuICAgICAgICAgICAgICAgICQkLmxpYnJhcnlQcmVmaXggPSBwcmV2aW91c1ByZWZpeCA7XG4gICAgICAgICAgICAgICAgJCQuX19nbG9iYWwuY3VycmVudExpYnJhcnkgPSBwcmV2aW91c0xpYnJhcnk7XG4gICAgICAgICAgICAgICAgdGhyb3cgZXJyO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIHJldDtcbiAgICAgICAgfVxuICAgIH1cblxuICAgICQkLmxpYnJhcmllc1twcmVmaXhOYW1lXSA9IHRoaXM7XG4gICAgdmFyIHByZWZpeGVkUmVxdWlyZSA9IHdyYXBDYWxsKGZ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AgICAgICAgY29uc3Qgc2VsZiA9IHRoaXM7XG5cbiAgICAgICAgICAgIC8vIGNvbnNvbGUubG9nKCd0cnlpbmcgdG8gbG9hZCAnLCByZXF1ZXN0KTtcblxuICAgICAgICAgICAgZnVuY3Rpb24gdHJ5QnVuZGxlUmVxdWlyZSguLi5hcmdzKSB7XG4gICAgICAgICAgICAgICAgLy9yZXR1cm4gJCQuX19vcmlnaW5hbFJlcXVpcmUuYXBwbHkoc2VsZixhcmdzKTtcbiAgICAgICAgICAgICAgICAvL3JldHVybiBNb2R1bGUuX2xvYWQuYXBwbHkoc2VsZixhcmdzKVxuICAgICAgICAgICAgICAgIGxldCByZXM7XG4gICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgcmVzID0gc2FuZGJveFJlcXVpcmUuYXBwbHkoc2VsZiwgYXJncyk7XG4gICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChlcnIuY29kZSA9PT0gXCJNT0RVTEVfTk9UX0ZPVU5EXCIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAgPSBwYXRoLmpvaW4ocHJvY2Vzcy5jd2QoKSwgcmVxdWVzdCk7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXMgPSBzYW5kYm94UmVxdWlyZS5hcHBseShzZWxmLCBbcF0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdCA9IHA7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBlcnI7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIHJlcztcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgbGV0IHJlcztcblxuXG4gICAgICAgICAgICByZXMgPSB0cnlSZXF1aXJlU2VxdWVuY2UodHJ5QnVuZGxlUmVx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Gx5KHNlbGYsYXJncyk7XG4gICAgICAgICAgICAgICAgLy9yZXR1cm4gTW9kdWxlLl9sb2FkLmFwcGx5KHNlbGYsYXJncylcbiAgICAgICAgICAgICAgICBsZXQgcmVzO1xuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgIHJlcyA9IG1vZHVsZU9yaWdpbmFsUmVxdWlyZS5hcHBseShzZWxmLCBhcmdzKTtcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGVyci5jb2RlID09PSBcIk1PRFVMRV9OT1RfRk9VTkRcIikge1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcCA9IHBhdGguam9pbihwcm9jZXNzLmN3ZCgpLCByZXF1ZXN0KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlcyA9IG1vZHVsZU9yaWdpbmFsUmVxdWlyZS5hcHBseShzZWxmLCBbcF0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdCA9IHA7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBlcnI7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIHJlcztcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgZnVuY3Rpb24gY3VycmVudEZvbGRlclJlcXVpcmUocmVxdWVzdCkge1xuICAgICAgICAgICAgICAgIHJldHVyblxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAvL1tyZXF1aXJlRnJvbUNhY2hlLCB3cmFwU3RlcChwc2tydW50aW1lUmVxdWlyZSksIHdyYXBTdGVwKGRvbWFpblJlcXVpcmUpLCBvcmlnaW5hbFJlcXVpcmVdXG4gICAgICAgICAgICByZXR1cm4gdHJ5UmVxdWlyZVNlcXVlbmNlKG9yaWdpbmFsUmVxdWlyZSwgcmVxdWVzdCk7XG4gICAgICAgIH1cblxuICAgICAgICBNb2R1bGUucHJvdG90eXBlLnJlcXVpcmUgPSBuZXdMb2FkZXI7XG4gICAgfVxuXG4gICAgJCQucmVxdWlyZSA9IHJlcXVpcmU7XG59XG4iLCJcbnZhciBqb2luQ291bnRlciA9IDA7XG5cbmZ1bmN0aW9uIFBhcmFsbGVsSm9pblBvaW50KHN3YXJtLCBjYWxsYmFjaywgYXJncyl7XG4gICAgam9pbkNvdW50ZXIrKztcbiAgICB2YXIgY2hhbm5lbElkID0gXCJQYXJhbGxlbEpvaW5Qb2ludFwiICsgam9pbkNvdW50ZXI7XG4gICAgdmFyIHNlbGYgPSB0aGlzO1xuICAgIHZhciBjb3VudGVyID0gMDtcbiAgICB2YXIgc3RvcE90aGVyRXhlY3V0aW9uICAgICA9IGZhbHNlO1xuXG4gICAgZnVuY3Rpb24gZXhlY3V0aW9uU3RlcChzdGVwRnVuYywgbG9jYWxBcmdzLCBzdG9wKXtcblxuICAgICAgICB0aGlzLmRvRXhlY3V0ZSA9IGZ1bmN0aW9uKCl7XG4gICAgICAgICAgICBpZihzdG9wT3RoZXJFeGVjdXRpb24pe1xuICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRyeXtcbiAgICAgICAgICAgICAgICBzdGVwRnVuYy5hcHBseShzd2FybSwgbG9jYWxBcmdzKTtcbiAgICAgICAgICAgICAgICBpZihzdG9wKXtcbiAgICAgICAgICAgICAgICAgICAgc3RvcE90aGVyRXhlY3V0aW9uID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsgLy9ldmVyeXRpbmcgaXMgZmluZVxuICAgICAgICAgICAgfSBjYXRjaChlcnIpe1xuICAgICAgICAgICAgICAgIGFyZ3MudW5zaGlmdChlcnIpO1xuICAgICAgICAgICAgICAgIHNlbmRGb3JTb3VuZEV4ZWN1dGlvbihjYWxsYmFjaywgYXJncywgdHJ1ZSk7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOyAvL3N0b3AgaXQsIGRvIG5vdCBjYWxsIGFnYWluIGFueXRoaW5nXG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBpZih0eXBlb2YgY2FsbGJhY2sgIT09IFwiZnVuY3Rpb25cIil7XG4gICAgICAgICQkLmVycm9ySGFuZGxlci5zeW50YXhFcnJvcihcImludmFsaWQgam9pblwiLHN3YXJtLCBcImludmFsaWQgZnVuY3Rpb24gYXQgam9pbiBpbiBzd2FybVwiKTtcbiAgICAgICAgcmV0dXJuO1xuICAgIH1cblxuICAgICQkLlBTS19QdWJTdWIuc3Vic2NyaWJlKGNoYW5uZWxJZCxmdW5jdGlvbihmb3JFeGVjdXRpb24pe1xuICAgICAgICBpZihzdG9wT3RoZXJFeGVjdXRpb24pe1xuICAgICAgICAgICAgcmV0dXJuIDtcbiAgICAgICAgfVxuXG4gICAgICAgIHRyeXtcbiAgICAgICAgICAgIGlmKGZvckV4ZWN1dGlvbi5kb0V4ZWN1dGUoKSl7XG4gICAgICAgICAgICAgICAgZGVjQ291bnRlcigpO1xuICAgICAgICAgICAgfSAvLyBoYWQgYW4gZXJyb3IuLi5cbiAgICAgICAgfSBjYXRjaChlcnIpe1xuICAgICAgICAgICAgLy9jb25zb2xlLmxvZyhlcnIpO1xuICAgICAgICAgICAgLy8kJC5lcnJvckhhbmRsZXIuc3ludGF4RXJyb3IoXCJfX2ludGVybmFsX19cIixzd2FybSwgXCJleGNlcHRpb24gaW4gdGhlIGV4ZWN1dGlvbiBvZiB0aGUgam9pbiBmdW5jdGlvbiBvZiBhIHBhcmFsbGVsIHRhc2tcIik7XG4gICAgICAgIH1cbiAgICB9KTtcblxuICAgIGZ1bmN0aW9uIGluY0NvdW50ZXIoKXtcbiAgICAgICAgaWYodGVzd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mdW5jdCwgYXJncywgc3RvcCk7XG4gICAgICAgICQkLlBTS19QdWJTdWIucHVibGlzaChjaGFubmVsSWQsIG9iaik7IC8vIGZvcmNlIGV4ZWN1dGlvbiB0byBiZSBcInNvdW5kXCJcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBkZWNDb3VudGVyKCl7XG4gICAgICAgIGNvdW50ZXItLTtcbiAgICAgICAgaWYoY291bnRlciA9PSAwKSB7XG4gICAgICAgICAgICBhcmdzLnVuc2hpZnQobnVsbCk7XG4gICAgICAgICAgICBzZW5kRm9yU291bmRFeGVjdXRpb24oY2FsbGJhY2ssIGFyZ3MsIGZhbHNlKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHZhciBpbm5lciA9IHN3YXJtLmdldElubmVyVmFsdWUoKTtcblxuICAgIGZ1bmN0aW9uIGRlZmF1bHRQcm9ncmVzc1JlcG9ydChlcnIsIHJlcyl7XG4gICAgICAgIGlmKGVycikge1xuICAgICAgICAgICAgdGhyb3cgZXJyO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICB0ZXh0OlwiUGFyYWxsZWwgZXhlY3V0aW9uIHByb2dyZXNzIGV2ZW50XCIsXG4gICAgICAgICAgICBzd2FybTpzd2FybSxcbiAgICAgICAgICAgIGFyZ3M6YXJncyxcbiAgICAgICAgICAgIGN1cnJlbnRSZXN1bHQ6cmVzXG4gICAgICAgIH07XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gbWtGdW5jdGlvbihuYW1lKXtcbiAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKC4uLmFyZ3Mpe1xuICAgICAgICAgICAgdmFyIGYgPSBkZWZhdWx0UHJvZ3Jlc3NSZXBvcnQ7XG4gICAgICAgICAgICBpZihuYW1lICE9IFwicHJvZ3Jlc3NcIil7XG4gICAgICAgICAgICAgICAgZiA9IGlubmVyLm15RnVuY3Rpb25zW25hbWVdO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFy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3VtZW50c1tleGVjdXRpb25Db3VudGVyXSApICB7XG4gICAgICAgICAgICAgICAgJCQuUFNLX1B1YlN1Yi5wdWJsaXNoKGNoYW5uZWxJZCwgc2VsZik7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICB2YXIgZiA9IGZ1bmN0aW9uICguLi5hcmdzKXtcbiAgICAgICAgICAgIGlmKGV4ZWN1dGlvbkNvdW50ZXIgIT0gcG9zKSB7XG4gICAgICAgICAgICAgICAgcGxhbm5lZEFyZ3VtZW50c1twb3NdID0gYXJncztcbiAgICAgICAgICAgICAgICAvL2NvbnNvbGUubG9nKFwiRGVsYXlpbmcgZnVuY3Rpb246XCIsIGV4ZWN1dGlvbkNvdW50ZXIsIHBvcywgcGxhbm5lZEFyZ3VtZW50cywgYXJndW1lbnRzLCBmdW5jdGlvbkNvdW50ZXIpO1xuICAgICAgICAgICAgICAgIHJldHVybiBfX3Byb3h5O1xuICAgICAgICAgICAgfSBlbHNle1xuICAgICAgICAgICAgICAgIGlmKHBsYW5uZWRBcmd1bWVudHNbcG9zXSl7XG4gICAgICAgICAgICAgICAgICAgIC8vY29uc29sZS5sb2coXCJFeGVjdXRpbmcgIGZ1bmN0aW9uOlwiLCBleGVjdXRpb25Db3VudGVyLCBwb3MsIHBsYW5uZWRBcmd1bWVudHMsIGFyZ3VtZW50cywgZnVuY3Rpb25Db3VudGVyKTtcblx0XHRcdFx0XHRhcmdzID0gcGxhbm5lZEFyZ3VtZW50c1twb3NdO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHBsYW5uZWRBcmd1bWVudHNbcG9zXSA9IGFyZ3M7XG4gICAgICAgICAgICAgICAgICAgIHRyaWdnZXROZXh0U3RlcCgpO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gX19wcm94eTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHZhciBmID0gZGVmYXVsdFByb2dyZXNzUmVwb3J0O1xuICAgICAgICAgICAgaWYobmFtZSAhPSBcInByb2dyZXNzXCIpe1xuICAgICAgICAgICAgICAgIGYgPSBpbm5lci5teUZ1bmN0aW9uc1tuYW1lXTtcbiAgICAgICAgICAgIH1cblxuXG4gICAgICAgICAgICB0cnl7XG4gICAgICAgICAgICAgICAgZi5hcHBseShzZWxmLGFyZ3MpO1xuICAgICAgICAgICAgfSBjYXRjaChlcnIpe1xuICAgICAgICAgICAgICAgICAgICBhcmdzLnVuc2hpZnQoZXJyKTtcbiAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2suYXBwbHkoc3dhcm0sYXJncyk7IC8vZXJyb3JcbiAgICAgICAgICAgICAgICAgICAgJCQuUFNLX1B1YlN1Yi51bnN1YnNjcmliZShjaGFubmVsSWQscnVuTmV4dEZ1bmN0aW9uKTtcbiAgICAgICAgICAgICAgICByZXR1cm47IC8vdGVybWluYXRlIGV4ZWN1dGlvbiB3aXRoIGFuIGVycm9yLi4uIVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZXhlY3V0aW9uQ291bnRlcisrO1xuXG4gICAgICAgICAgICB0cmlnZ2V0TmV4dFN0ZXAoKTtcblxuICAgICAgICAgICAgcmV0dXJuIF9fcHJveHk7XG4gICAgICAgIH07XG5cbiAgICAgICAgcGxhbm5lZEV4ZWN1dGlvbnMucHVzaChmKTtcbiAgICAgICAgZnVuY3Rpb25Db3VudGVyKys7XG4gICAgICAgIHJldHVybiBmO1xuICAgIH1cblxuICAgICB2YXIgZmluaXNoZWQgPSBmYWxzZTtcblxuICAgIGZ1bmN0aW9uIHJ1bk5leHRGdW5jdGlvbigpe1xuICAgICAgICBpZihleGVjdXRpb25Db3VudGVyID09IHBsYW5uZWRFeGVjdXRpb25zLmxlbmd0aCApe1xuICAgICAgICAgICAgaWYoIWZpbmlzaGVkKXtcbiAgICAgICAgICAgICAgICBhcmdzLnVuc2hpZnQobnVsbCk7XG4gICAgICAgICAgICAgICAgY2FsbGJ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B0aHJvdyBlcnI7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiByZXQ7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICAvL2R5bmFtaWMgbmFtZWQgZnVuYyBpbiBvcmRlciB0byBpbXByb3ZlIGNhbGxzdGFja1xuICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHBoYXNlLCBcIm5hbWVcIiwge2dldDogZnVuY3Rpb24oKXtyZXR1cm4gc3dhcm1UeXBlTmFtZStcIi5cIitmdW5jLm5hbWV9fSk7XG4gICAgICAgICAgICByZXR1cm4gcGhhc2U7XG4gICAgICAgIH1cblxuICAgICAgICB0aGlzLmluaXRpYWxpc2UgPSBmdW5jdGlvbihzZXJpYWxpc2VkVmFsdWVzKXtcblxuICAgICAgICAgICAgdmFyIHJlc3VsdCA9IG5ldyBPd00oe1xuICAgICAgICAgICAgICAgIHB1YmxpY1ZhcnM6e1xuXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBwcml2YXRlVmFyczp7XG5cbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHByb3RlY3RlZFZhcnM6e1xuXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBteUZ1bmN0aW9uczp7XG5cbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHV0aWxpdHlGdW5jdGlvbnM6e1xuXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBtZXRhOntcbiAgICAgICAgICAgICAgICAgICAgc3dhcm1UeXBlTmFtZTpzd2FybVR5cGVOYW1lLFxuICAgICAgICAgICAgICAgICAgICBzd2FybURlc2NyaXB0aW9uOmRlc2NyaXB0aW9uXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG5cblxuICAgICAgICAgICAgZm9yKHZhciB2IGluIHB1YmxpY1ZhcnMpe1xuICAgICAgICAgICAgICAgIHJlc3VsdC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gICAgICAgIHJldHVybiB0YXJnZXQucHVibGljVmFyc1twcm9wZXJ0eV07XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmKHByaXZhdGVWYXJzLmhhc093blByb3BlcnR5KHByb3BlcnR5KSlcbiAgICAgICAgICAgIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gdGFyZ2V0LnByaXZhdGVWYXJzW3Byb3BlcnR5XTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYodGFyZ2V0LnV0aWxpdHlGdW5jdGlvbnMuaGFzT3duUHJvcGVydHkocHJvcGVydHkpKVxuICAgICAgICAgICAge1xuXG4gICAgICAgICAgICAgICAgcmV0dXJuIHRhcmdldC51dGlsaXR5RnVuY3Rpb25zW3Byb3BlcnR5XTtcbiAgICAgICAgICAgIH1cblxuXG4gICAgICAgICAgICBpZihteUZ1bmN0aW9ucy5oYXNPd25Qcm9wZXJ0eShwcm9wZXJ0eSkpXG4gICAgICAgICAgICB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRhcmdldC5teUZ1bmN0aW9uc1twcm9wZXJ0eV07XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmKHRhcmdldC5wcm90ZWN0ZWRWYXJzLmhhc093blByb3BlcnR5KHByb3BlcnR5KSlcbiAgICAgICAgICAgIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gdGFyZ2V0LnByb3RlY3RlZFZhcnNbcHJvcGVydHldO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZih0eXBlb2YgcHJvcGVydHkgIT0gXCJzeW1ib2xcIikge1xuICAgICAgICAgICAgICAgICQkLmVycm9ySGFuZGxlci5zeW50YXhFcnJvcihwcm9wZXJ0eSwgdGFyZ2V0KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiB1bmRlZmluZWQ7XG4gICAgICAgIH1cblxuICAgICAgICB0aGlzLnNldCA9IGZ1bmN0aW9uKHRhcmdldCwgcHJvcGVydHksIHZhbHVlLCByZWNlaXZlcil7XG5cbiAgICAgICAgICAgIGlmKHRhcmdldC51dGlsaXR5RnVuY3Rpb25zLmhhc093blByb3BlcnR5KHByb3BlcnR5KSB8fCB0YXJnZXQubXlGdW5jdGlvbnMuaGFzT3duUHJvcGVydHkocHJvcGVydHkpKSB7XG4gICAgICAgICAgICAgICAgJCQuZXJyb3JIYW5kbGVyLnN5bnRheEVycm9yKHByb3BlcnR5KTtcbiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoXCJUcnlpbmcgdG8gb3ZlcndyaXRlIGltbXV0YWJsZSBtZW1iZXJcIiArIHByb3BlcnR5KTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYocHJpdmF0ZVZhcnMuaGFzT3duUHJvcGVydHkocHJvcGVydHkpKVxuICAgICAgICAgICAge1xuICAgICAgICAgICAgICAgIHRhcmdldC5wcml2YXRlVmFyc1twcm9wZXJ0eV0gPSB2YWx1ZTtcbiAgICAgICAgICAgIH0gZWxzZVxuICAgICAgICAgICAgaWYocHVibGljVmFycy5oYXNPd25Qcm9wZXJ0eShwcm9wZXJ0eSkpXG4gICAgICAgICAgICB7XG4gICAgICAgICAgICAgICAgdGFyZ2V0LnB1YmxpY1ZhcnNbcHJvcGVydHldID0gdmFsdWU7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRhcmdldC5wcm90ZWN0ZWRWYXJzW3Byb3BlcnR5XSA9IHZhbHVlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgIH1cblxuICAgICAgICB0aGlzLmFwcGx5ID0gZnVuY3Rpb24odGFyZ2V0LCB0aGlzQXJnLCBhcmd1bWVudHNMaXN0KXtcbiAgICAgICAgICAgIGNvbnNvbGUubG9nKFwiUHJveHkgYXBwbHlcIik7XG4gICAgICAgICAgICAvL3ZhciBmdW5jID0gdGFyZ2V0W11cbiAgICAgICAgICAgIC8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gICAgICBzZi5leGNlcHRpb25zLmFzc2VydEZhaWwoZXhwbGFuYXRpb24pO1xuICAgICAgICB9XG4gICAgfSk7XG5cbiAgICAvKipcbiAgICAgKiBDaGVja3MgaWYgYWxsIHByb3BlcnRpZXMgb2YgdGhlIHNlY29uZCBvYmplY3QgYXJlIG93biBwcm9wZXJ0aWVzIG9mIHRoZSBmaXJzdCBvYmplY3QuXG4gICAgICogQHBhcmFtIGZpcnN0T2JqIHtPYmplY3R9IC0gZmlyc3Qgb2JqZWN0XG4gICAgICogQHBhcmFtIHNlY29uZE9iantPYmplY3R9IC0gc2Vjb25kIG9iamVjdFxuICAgICAqIEByZXR1cm5zIHtib29sZWFufSAtIHJldHVybnMgdHJ1ZSwgaWYgdGhlIGNoZWNrIGhhcyBwYXNzZWQgb3IgZmFsc2Ugb3RoZXJ3aXNlLlxuICAgICAqL1xuICAgIGZ1bmN0aW9uIG9iamVjdEhhc0ZpZWxkcyhmaXJzdE9iaiwgc2Vjb25kT2JqKXtcbiAgICAgICAgZm9yKGxldCBmaWVsZCBpbiBzZWNvbmRPYmopIHtcbiAgICAgICAgICAgIGlmIChmaXJzdE9iai5oYXNPd25Qcm9wZXJ0eShmaWVsZCkpIHtcbiAgICAgICAgICAgICAgICBpZiAoZmlyc3RPYmpbZmllbGRdICE9PSBzZWNvbmRPYmpbZmllbGRdKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNle1xuICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBvYmplY3RzQXJlRXF1YWwoZmlyc3RPYmosIHNlY29uZE9iaikge1xuICAgICAgICBsZXQgYXJlRXF1YWwgPSB0cnVlO1xuICAgICAgICBpZihmaXJzdE9iai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uICAgICAgICB0cnl7XG4gICAgICAgICAgICBmdW5jKCk7XG4gICAgICAgICAgICBjb25zb2xlLmxvZyhcIltGYWlsXSBcIiArIHRlc3ROYW1lICk7XG4gICAgICAgIH0gY2F0Y2goZXJyKXtcbiAgICAgICAgICAgIGNvbnNvbGUubG9nKFwiW1Bhc3NdIFwiICsgdGVzdE5hbWUgKTtcbiAgICAgICAgfVxuICAgIH0pO1xuXG5cbiAgICBzZi5jaGVjay5hZGRDaGVjaygncGFzcycsIGZ1bmN0aW9uKHRlc3ROYW1lICxmdW5jKXtcbiAgICAgICAgdHJ5e1xuICAgICAgICAgICAgZnVuYygpO1xuICAgICAgICAgICAgY29uc29sZS5sb2coXCJbUGFzc10gXCIgKyB0ZXN0TmFtZSApO1xuICAgICAgICB9IGNhdGNoKGVycil7XG4gICAgICAgICAgICBjb25zb2xlLmxvZyhcIltGYWlsXSBcIiArIHRlc3ROYW1lICAsICBlcnIuc3RhY2spO1xuICAgICAgICB9XG4gICAgfSk7XG5cblxuICAgIHNmLmNoZWNrLmFsaWFzKCd0ZXN0JywncGFzcycpO1xuXG5cbiAgICBzZi5jaGVjay5hZGRDaGVjaygnY2FsbGJhY2snLCBmdW5jdGlvbih0ZXN0TmFtZSAsZnVuYywgdGltZW91dCl7XG4gICAgICAgIGlmKCF0aW1lb3V0KXtcbiAgICAgICAgICAgIHRpbWVvdXQgPSA1MDA7XG4gICAgICAgIH1cbiAgICAgICAgdmFyIHBhc3NlZCA9IGZhbHNlO1xuICAgICAgICBmdW5jdGlvbiBjYWxsYmFjaygpe1xuICAgICAgICAgICAgaWYoIXBhc3NlZCl7XG4gICAgICAgICAgICAgICAgcGFzc2VkID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhcIltQYXNzXSBcIiArIHRlc3ROYW1lICk7XG4gICAgICAgICAgICAgICAgU3VjY2Vzc1Rlc3QoKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgY29uc29sZS5sb2coXCJbRmFpbCAobXVsdGlwbGUgY2FsbHMpXSBcIiArIHRlc3ROYW1lICk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgdHJ5e1xuICAgICAgICAgICAgZnVuYyhjYWxsYmFjayk7XG4gICAgICAgIH0gY2F0Y2goZXJyKXtcbiAgICAgICAgICAgIGNvbnNvbGUubG9nKFwiW0ZhaWxdIFwiICsgdGVzdE5hbWUgICwgIGVyci5zdGFjayk7XG4gICAgICAgIH1cblxuICAgICAgICBmdW5jdGlvbiBTdWNjZXNzVGVzdChmb3JjZSl7XG4gICAgICAgICAgICBpZighcGFzc2VkKXtcbiAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhcIltGYWlsIFRpbWVvdXRdIFwiICsgdGVzdE5hbWUgKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIHNldFRpbWVvdXQoU3VjY2Vzc1Rlc3QsIHRpbWVvdXQpO1xuICAgIH0pO1xuXG5cbiAgICBzZi5jaGVjay5hZGRDaGVjaygnc3RlcHMnLCBmdW5jdGlvbih0ZXN0TmFtZSAsIGFyciwgdGltZW91dCl7XG4gICAgICAgIHZhciAgY3VycmVudFN0ZXAgPSAwO1xuICAgICAgICB2YXIgcGFzc2VkID0gZmFsc2U7XG4gICAgICAgIGlmKCF0aW1lb3V0KXtcbiAgICAgICAgICAgIHRpbWVvdXQgPSA1MDA7XG4gICAgICAgIH1cblxuICAgICAgICBmdW5jdGlvbiBuZXh0KCl7XG4gICAgICAgICAgICBpZihjdXJyZW50U3RlcCA9PT0gYXJyLmxlbmd0aCl7XG4gICAgICAgICAgICAgICAgcGFzc2VkID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhcIltQYXNzXSBcIiArIHRlc3ROYW1lICk7XG4gICAgICAgICAgICAgICAgcmV0dXJuIDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciBmdW5jID0gYXJyW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25seSB0aGUgY3VycmVudCBjb250ZXh0IHdpbGwgYmUgbG9nZ2VkXG4gICAgICogQHJldHVybnMgRGVidWcgcmVjb3JkIG1vZGVsIHtPYmplY3R9IHdpdGggdGhlIGZvbGxvd2luZyBmaWVsZHM6XG4gICAgICogW3JlcXVpcmVkXTogbGV2ZWw6ICosIHR5cGU6ICosIHRpbWVzdGFtcDogbnVtYmVyLCBtZXNzYWdlOiAqLCBkYXRhOiAqIGFuZFxuICAgICAqIFtvcHRpb25hbF06IHN0YWNrOiAqLCBleGNlcHRpb246ICosIGFyZ3M6ICosIHdoeUxvZzogKlxuICAgICAqL1xuICAgIGZ1bmN0aW9uIGNyZWF0ZURlYnVnUmVjb3JkKGxldmVsLCB0eXBlLCBtZXNzYWdlLCBleGNlcHRpb24sIHNhdmVTdGFjaywgYXJncywgcG9zLCBkYXRhLCBsb2dPbmx5Q3VycmVudFdoeUNvbnRleHQpe1xuXG4gICAgICAgIHZhciByZXQgPSB7XG4gICAgICAgICAgICBsZXZlbDogbGV2ZWwsXG4gICAgICAgICAgICB0eXBlOiB0eXBlLFxuICAgICAgICAgICAgdGltZXN0YW1wOiAobmV3IERhdGUoKSkuZ2V0VGltZSgpLFxuICAgICAgICAgICAgbWVzc2FnZTogbWVzc2FnZSxcbiAgICAgICAgICAgIGRhdGE6IGRhdGFcbiAgICAgICAgfTtcblxuICAgICAgICBpZihzYXZlU3RhY2spe1xuICAgICAgICAgICAgdmFyIHN0YWNrID0gJyc7XG4gICAgICAgICAgICBpZihleGNlcHRpb24pe1xuICAgICAgICAgICAgICAgIHN0YWNrID0gZXhjZXB0aW9uLnN0YWNrO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBzdGFjayAgPSAobmV3IEVycm9yKCkpLnN0YWNrO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0LnN0YWNrID0gc3RhY2s7XG4gICAgICAgIH1cblxuICAgICAgICBpZihleGNlcHRpb24pe1xuICAgICAg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7XG5cbiAgICAgICAgICAgIC8vIHdyYXBwZXIgZm9yIHByb3ZpZGVkIGNhbGxiYWNrLCBpZiBhbnlcbiAgICAgICAgICAgIHRoaXMuY2FsbGJhY2sgPSBmdW5jdGlvbihlcnIsIHJlc3VsdCkge1xuICAgICAgICAgICAgICAgIGlmKGVycikge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9fZGVidWdJbmZvKGVyci5tZXNzYWdlIHx8IGVycik7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgaWYoY2FsbGJhY2spIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNhbGxiYWNrKGVyciwgcmVzdWx0KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9O1xuXG4gICAgICAgICAgICB0aGlzLl9faW5pdChjb25maWcpO1xuXG4gICAgICAgICAgICB0aGlzLl9fY29uc29sZUxvZyhcIkRpc2NvdmVyaW5nIHRlc3RzIC4uLlwiKTtcbiAgICAgICAgICAgIHRoaXMudGVzdFRyZWUgPSB0aGlzLl9fZGlzY292ZXJUZXN0RmlsZXModGhpcy5jb25maWcudGVzdHNEaXIsIGNvbmZpZyk7XG4gICAgICAgICAgICB0aGlzLnRlc3RMaXN0ID0gdGhpcy5fX3RvVGVzdFRyZWVUb0xpc3QodGhpcy50ZXN0VHJlZSk7XG4gICAgICAgICAgICB0aGlzLl9fbGF1bmNoVGVzdHMoKTtcbiAgICAgICAgfSxcbiAgICAgICAgLyoqXG4gICAgICAgICAqIFJlYWRzIGNvbmZpZ3VyYXRpb24gc2V0dGluZ3MgZnJvbSBhIGpzb24gZmlsZS5cbiAgICAgICAgICogQHBhcmFtIGNvbmZQYXRoIHtTdHJpbmd9IC0gYWJzb2x1dGUgcGF0aCB0byB0aGUgY29uZmlndXJhdGlvbiBmaWxlLlxuICAgICAgICAgKiBAcmV0dXJucyB7T2JqZWN0fSAtIGNvbmZpZ3VyYXRpb24gb2JqZWN0IHt7fX1cbiAgIC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24gb2JqZWN0IChkb3VibGUtY2hlY2suanNvbikgZnJvbSB0aGUgcGFyZW50IGRpcmVjdG9yeVxuICAgICAgICAgKiBAcmV0dXJucyBUaGUgcm9vdCBub2RlIG9iamVjdCBvZiB0aGUgZmlsZSBzdHJ1Y3R1cmUgdHJlZS4gRS5nLiB7Knx7X19tZXRhLCBkYXRhLCByZXN1bHQsIGl0ZW1zfX1cbiAgICAgICAgICogQHByaXZhdGVcbiAgICAgICAgICovXG4gICAgICAgIF9fZGlzY292ZXJUZXN0RmlsZXM6IGZ1bmN0aW9uKGRpciwgcGFyZW50Q29uZikge1xuICAgICAgICAgICAgY29uc3Qgc3RhdCA9IGZzLnN0YXRTeW5jKGRpcik7XG4gICAgICAgICAgICBpZighc3RhdC5pc0RpcmVjdG9yeSgpKXtcbiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoZGlyICsgXCIgaXMgbm90IGEgZGlyZWN0b3J5IVwiKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgbGV0IGN1cnJlbnRDb25mID0gcGFyZW50Q29uZjtcblxuICAgICAgICAgICAgbGV0IGN1cnJlbnROb2RlID0gdGhpcy5fX2dldERlZmF1bHROb2RlU3RydWN0dXJlKCk7XG4gICAgICAgICAgICBjdXJyZW50Tm9kZS5fX21ldGEucGFyZW50ID0gcGF0aC5kaXJuYW1lKGRpcik7XG4gICAgICAgICAgICBjdXJyZW50Tm9kZS5fX21ldGEuaXNEaXJlY3RvcnkgPSB0cnVlO1xuXG4gICAgICAgICAgICBsZXQgZmlsZXMgPSBmcy5yZWFkZGlyU3luYyhkaXIpO1xuICAgICAgICAgICAgLy8gZmlyc3QgbG9vayBmb3IgY29uZiBmaWxlXG4gICAgICAgICAgICBpZihmaWxlcy5pbmRleE9mKHRoaXMuY29uZmlnLmNvbmZGaWxlTmFtZSkgIT09IC0xKSB7XG4gICAgICAgICAgICAgICAgbGV0IGZkID0gcGF0aC5qb2luKGRpciwgdGhpcy5jb25maWcuY29uZkZpbGVOYW1lKTtcbiAgICAgICAgICAgICAgICBsZXQgY29uZiA9IHRoaXMuX19yZWFkQ29uZihmZCk7XG4gICAgICAgICAgICAgICAgaWYoY29uZikge1xuICAgICAgICAgICAgICAgICAgICBjdXJyZW50Tm9kZS5fX21ldGEuY29uZiA9IGNvbmY7XG4gICAgICAgICAgICAgICAgICAgIGN1cnJlbnRDb25mID0gY29uZjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGN1cnJlbnROb2RlLmRhdGEubmFtZSA9IHBhdGguYmFzZW5hbWUoZGlyKTtcbiAgICAgICAgICAgIGN1cnJlbnROb2RlLmRhdGEucGF0aCA9IGRpcjtcbiAgICAgICAgICAgIGN1cnJlbnROb2RlLml0ZW1zID0gW107XG5cbiAgICAgICAgICAgIGZvcihsZXQgaSA9IDAsIGxlbiA9IGZpbGVzLmxlbmd0aDsgaSA8IGxlbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgbGV0IGl0ZW0gPSBmaWxlc1tpXTtcblxuICAgICAgICAgICAgICAgIGxldCBmZCA9IHBhdGguam9pbihkaXIsIGl0ZW0pO1xuICAgICAgICAgICAgICAgIGxldCBzdGF0ID0gZnMuc3RhdFN5bmMoZmQpO1xuICAgICAgICAgICAgICAgIGxldCBpc0RpciA9IHN0YXQuaXNEaXJlY3RvcnkoKTtcbiAgICAgICAgICAgICAgICBsZXQgaXNUZXN0RGlyID0gdGhpcy5fX2lzVGVzdERpcihmZCk7XG5cbiAgICAgICAgICAgICAgICBpZihpc0RpciAmJiAhaXNUZXN0RGlyKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOyAvLyBpZ25vcmUgZGlycyB0aGF0IGRvZXMgbm90IGZvbGxvdyB0aGUgbmFtaW5nIHJ1bGUgZm9yIHRlc3QgZGlyc1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGlmKCFpc0RpciAmJiBpdGVtLm1hdGNoKHRoaXMuY29uZmlnLmNvbmZGaWxlTmFtZSkpe1xuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsgLy8gYWxyZWFkeSBwcm9jZXNzZWRcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAvLyBleGNsdWRlIGZpbGVzIGJhc2VkIG9uIGdsb2IgcGF0dGVybnNcbiAgICAgICAgICAgICAgICBpZihjdXJyZW50Q29uZikge1xuICAgICAgICAgICAgICAgICAgICAvLyBjdXJyZW50Q29uZlsnaWdub3JlJ10gLSBhcnJheSBvZiByZWdFeHBcbiAgICAgICAgICAgICAgICAgICAgaWYoY3VycmVudENvbmZbJ2lnbm9yZSddKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc01hdGNoID0gdGhpcy5fX2lzQW55TWF0Y2goY3VycmVudENvbmZbJ2lnbm9yZSddLCBpdGVtKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmKGlzTWF0Y2gpIHtjb250aW51ZTt9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBsZXQgY2hpbGROb2RlID0gdGhpcy5fX2dldERlZmF1bHROb2RlU3RydWN0dXJlKCk7XG4gICAgICAgICAgICAgICAgY2hpbGROb2RlLl9fbWV0YS5jb25mID0ge307XG4gICAgICAgICAgICAgICAgY2hpbGROb2RlLl9fbWV0YS5pc0RpcmVjdG9yeSA9IGlzRGlyO1xuICAgICAgICAgICAgICAgIGNoaWxkTm9kZS5fX21ldGEucGFyZW50ID0gcGF0aC5kaXJuYW1lKGZkKTtcblxuICAgICAgICAgICAgICAgIGlmIChpc0Rpcikge1xuICAgICAgICAgICAgICAgICAgICBsZXQgdGVtcENoaWxkTm9kZSA9IHRoaXMuX19kaXNjb3ZlclRlc3RGaWxlcyhmZCwgY3VycmVudENvbmYpO1xuICAgICAgICAgICAgICAgICAgICBjaGlsZE5vZGUgPSBPYmplY3QuYXNzaWduKGNoaWxkTm9kZSwgdGVtcENoaWxkTm9kZSk7XG4gICAgICAgICAgICAgICAgICAgIGN1cnJlbnROb2RlLml0ZW1zLnB1c2goY2hpbGROb2RlKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZWxzZSBpZihwYXRoLmV4dG5hbWUoZmQpID09PSAgdGhpcy5jb25maWcuZmlsZUV4dCl7XG4gICAgICAgICAgICAgICAgICAgIGNoaWxkTm9kZS5fX21ldGEuY29uZi5ydW5zID0gY3VycmVudENvbmZbJ3J1bnMnXSB8fCAxO1xuICAgICAgICAgICAgICAgICAgICBjaGlsZE5vZGUuX19tZXRhLmNvbmYuc2lsZW50ID0gY3VycmVudENvbmZbJ3NpbGVudCddO1xuICAgICAgICAgICAgICAgICAgICBjaGlsZE5vZGUuX19tZXRhLmNvbmYudGltZW91dCA9IGN1cnJlbnRDb25mWyd0aW1lb3V0J10gfHwgREVGQVVMVF9USU1FT1VUO1xuXG4gICAgICAgICAgICAgICAgICAgIGNoaWxkTm9kZS5kYXRhLm5hbWUgPSBpdGVtO1xuICAgICAgICAgICAgICAgICAgICBjaGlsZE5vZGUuZGF0YS5wYXRoID0gZmQ7XG5cbiAgICAgICAgICAgICAgICAgICAgY3VycmVudE5vZGUuaXRlbXMucHVzaChjaGlsZE5vZGUpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgcmV0dXJuIGN1cnJlbnROb2RlO1xuICAgICAgICB9LFxuICAgICAgICAvKipcbiAgICAgICAgICogTGF1bmNoIGNvbGxlY3RlZCB0ZXN0cy4gSW5pdGlhbGlzZXMgc2Vzc2lvbiB2YXJpYWJsZXMsIHRoYXQgYXJlIHNwZWNpZmljIGZvciB0aGUgY3VycmVudCBsYXVuY2guXG4gICAgICAgICAqIEBwcml2YXRlXG4gICAgICAgICAqL1xuICAgICAgICBfX2xhdW5jaFRlc3RzOiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgIH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bm5pbmcgPCBNQVhfV09SS0VSUyAmJiB0aGlzLnNlc3Npb24uY3VycmVudFRlc3RJbmRleCA8IHRoaXMuc2Vzc2lvbi50ZXN0Q291bnQpe1xuICAgICAgICAgICAgICAgIGxldCB0ZXN0ID0gdGhpcy50ZXN0TGlzdFt0aGlzLnNlc3Npb24uY3VycmVudFRlc3RJbmRleF07XG4gICAgICAgICAgICAgICAgaWYodGVzdC5yZXN1bHQucnVucyA8IHRlc3QuX19tZXRhLmNvbmYucnVucykge1xuICAgICAgICAgICAgICAgICAgICB0ZXN0LnJlc3VsdC5ydW5zKys7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX19sYXVuY2hUZXN0KHRlc3QpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuc2Vzc2lvbi5jdXJyZW50VGVzdEluZGV4Kys7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICAvKipcbiAgICAgICAgICogTGF1bmNoIGEgdGVzdCBpbnRvIGEgc2VwYXJhdGUgd29ya2VyIChjaGlsZCBwcm9jZXNzKS5cbiAgICAgICAgICogRWFjaCB3b3JrZXIgaGFzIGhhbmRsZXJzIGZvciBtZXNzYWdlLCBleGl0IGFuZCBlcnJvciBldmVudHMuIE9uY2UgdGhlIGV4aXQgb3IgZXJyb3IgZXZlbnQgaXMgaW52b2tlZCxcbiAgICAgICAgICogbmV3IHdvcmsgaXMgc2NoZWR1bGVkIGFuZCBzZXNzaW9uIG9iamVjdCBpcyB1cGRhdGVkLlxuICAgICAgICAgKiBOb3RlczogT24gZGVidWcgbW9kZSwgdGhlIHdvcmtlcnMgd2lsbCByZWNlaXZlIGEgZGVidWcgcG9ydCwgdGhhdCBpcyBpbmNyZWFzZWQgaW5jcmVtZW50YWxseS5cbiAgICAgICAgICogQHBhcmFtIHRlc3Qge09iamVjdH0gLSB0ZXN0IG9iamVjdFxuICAgICAgICA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ldHVybiBmdW5jdGlvbihsb2cpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYobG9nLnR5cGUgPT09ICdhc3NlcnQnKXtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmKGxvZy5tZXNzYWdlLmluY2x1ZGVzKFwiW0ZhaWxcIikpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXN0LnJlc3VsdC5wYXNzID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB0ZXN0LnJlc3VsdC5hc3NlcnRzW2N1cnJlbnRSdW5dLnB1c2gobG9nKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRlc3QucmVzdWx0Lm1lc3NhZ2VzW2N1cnJlbnRSdW5dLnB1c2gobG9nKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGZ1bmN0aW9uIG9uRXhpdEV2ZW50SGFuZGxlcldyYXBwZXIodGVzdCkge1xuICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbihjb2RlLCBzaWduYWwpIHtcbiAgICAgICAgICAgICAgICAgICAgY2xlYXJUaW1lb3V0KHdvcmtlci50aW1lclZhcik7XG4gICAgICAgICAgICAgICAgICAgIHNlbGYuX19kZWJ1Z0luZm8oYFdvcmtlciAke3dvcmtlci5waWR9IC0gZXhpdCBldmVudC4gQ29kZSAke2NvZGV9LCBzaWduYWwgJHtzaWduYWx9IGArbmV3IERhdGUoKS5nZXRUaW1lKCkpO1xuXG4gICAgICAgICAgICAgICAgICAgIHdvcmtlci50ZXJtaW5hdGVkID0gdHJ1ZTtcblxuICAgICAgICAgICAgICAgICAgICB0ZXN0LnJlc3VsdC5zdGF0ZSA9IFRFU1RfU1RBVEVTLkZJTklTSEVEO1xuICAgICAgICAgICAgICAgICAgICBpZihjb2RlICE9PSBudWxsICYmIGNvZGUhPT0wIC8qJiYgdHlwZW9mIHRlc3QucmVzdWx0LnBhc3MgPT09ICd1bmRlZmluZWQnKi8pe1xuICAgICAgICAgICAgICAgICAgICAgICAgdGVzdC5yZXN1bHQucGFzcyA9IGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGVzdC5yZXN1bHQubWVzc2FnZXNbdGVzdC5yZXN1bHQucnVuc10ucHVzaCgge21lc3NhZ2U6IFwiUHJvY2VzcyBmaW5pc2hlZCB3aXRoIGVycm9ycyFcIiwgXCJFeGl0IGNvZGVcIjpjb2RlLCBcIlNpZ25hbFwiOnNpZ25hbH0pO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgc2VsZi5zZXNzaW9uLndvcmtlcnMucnVubmluZy0tO1xuICAgICAgICAgICAgICAgICAgICBzZWxmLnNlc3Npb24ud29ya2Vycy50ZXJtaW5hdGVkKys7XG5cbiAgICAgICAgICAgICAgICAgICAgc2VsZi5fX3NjaGVkdWxlV29yaygpO1xuICAgICAgICAgICAgICAgICAgICBzZWxmLl9fY2hlY2tXb3JrZXJzU3RhdHVzKCk7XG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgLy8gdGhpcyBoYW5kbGVyIGNhbiBiZSB0cmlnZ2VyZWQgd2hlbjpcbiAgICAgICAgICAgIC8vIDEuIFRoZSBwcm9jZXNzIGNvdWxkIG5vdCBiZSBzcGF3bmVkLCBvclxuICAgICAgICAgICAgLy8gMi4gVGhlIHByb2Nlc3MgY291bGQgbm90IGJlIGtpbGxlZCwgb3JcbiAgICAgICAgICAgIC8vIDMuIFNlbmRpbmcgYSBtZXNzYWdlIHRvIHRoZSBjaGlsZCBwcm9jZXNzIGZhaWxlZC5cbiAgICAgICAgICAgIC8vIElNUE9SVEFOVDogVGhlICdleGl0JyBldmVudCBtYXkgb3IgbWF5IG5vdCBmaXJlIGFmdGVyIGFuIGVycm9yIGhhcyBvY2N1cnJlZCFcbiAgICAgICAgICAgIGZ1bmN0aW9uIG9uRXJyb3JFdmVudEhhbmRsZXJXcmFwcGVyKHRlc3QpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24oZXJyb3IpIHtcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5fX2RlYnVnSW5mbyhgV29ya2VyICR7d29ya2VyLnBpZH0gLSBlcnJvciBldmVudC5gLCB0ZXN0KTtcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5fX2RlYnVnRXJyb3IoZXJyb3IpO1xuXG4gICAgICAgICAgICAgICAgICAgIHNlbGYuc2Vzc2lvbi53b3JrZXJzLnJ1bm5pbmctLTtcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5zZXNzaW9uLndvcmtlcnMudGVybWluYXRlZCsrO1xuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIC8vIE5vdGU6IG9uIGRlYnVnLCB0aGUgdGltZW91dCBpcyByZWFjaGVkIGJlZm9yZSBleGl0IGV2ZW50IGlzIGNhbGxlZFxuICAgICAgICAgICAgLy8gd2hlbiBraWxsIGlzIGNhbGxlZCwgdGhlIGV4aXQgZXZlbnQgaXMgcmFpc2VkXG4gICAgICAgICAgICB3b3JrZXIudGltZXJWYXIgPSBzZXRUaW1lb3V0KCgpPT57XG4gICAgICAgICAgICAgICAgaWYoIXdvcmtlci50ZXJtaW5hdGVkKXtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fX2NvbnNvbGVMb2coYHdvcmtlciBwaWQgWyR7d29ya2VyLnBpZH1dIC0gdGltZW91dCBldmVudGAsbmV3IERhdGUoKS5nZXRUaW1lKCksICB0ZXN0KTtcblxuICAgICAgICAgICAgICAgICAgICBpZih0ZXN0LnJlc3VsdC5zdGF0ZSAhPT0gVEVTVF9TVEFURVMuRklOSVNIRUQpe1xuICAgICAgICAgICAgICAgICAgICAgICAgdGVzdC5yZXN1bHQucGFzcyA9IGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIHdvcmtlci5raWxsKCk7XG4gICAgICAgICAgICAgICAgICAgIHRlc3QucmVzdWx0LnN0YXRlID0gVEVTVF9TVEFURVMuVElNRU9VVDtcbiAgICAgICAgICAgICAgICB9ZWxzZXtcbiAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coXCJHb3Qgc29tZXRoaW5nLCBidXQgZG9uJ3Qga25vdyB3aGF0Li4uXCIsIHRlc3QpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sIHRlc3QuX19tZXRhLmNvbmYudGltZW91dCk7XG5cbiAgICAgICAgICAgICAgICBzZWxmLl9fZGVidWdJbmZvKGBXb3JrZXIgJHt3b3JrZXIucGlkfSAtIHNldCB0aW1lb3V0IGV2ZW50IGF0IGArbmV3IERhdGUoKS5nZXRUaW1lKCkgKyBcIiBmb3IgXCIrdGVzdC5fX21ldGEuY29uZi50aW1lb3V0KTtcblxuICAgICAgICB9LFxuICAgICAgICAvKipcbiAgICAgICAgICogQ2hlY2tzIGlmIGFsbCB3b3JrZXJzIGNvbXBsZXRlZCB0aGVpciBqb2IgKGZpbmlzaGVkIG9yIGhhdmUgYmVlbiB0ZXJtaW5hdGVkKS5cbiAgICAgICAgICogSWYgdHJ1ZSwgdGhlbiB0aGUgcmVwb3J0aW5nIHN0ZXBzIGNhbiBiZSBzdGFydGVkLlxuICAgICAgICAgKiBAcHJpdmF0ZVxuICAgICAgICAgKi9cbiAgICAgICAgX19jaGVja1dvcmtlcnNTdGF0dXM6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgaWYodGhpcy5zZXNzaW9uLndvcmtlcnMucnVubmluZyA9PT0gMCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX19kb1Rlc3RSZXBvcnRzKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIC8qKlxuICAgICAg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AgICAgICByZXBvcnRGaWxlU3RydWN0dXJlLnN1aXRlcy5jb3VudCA9IHJlcG9ydEZpbGVTdHJ1Y3R1cmUuc3VpdGVzLml0ZW1zLmxlbmd0aDtcblxuICAgICAgICAgICAgbGV0IG51bWJlck9mUmVwb3J0cyA9IDI7XG5cbiAgICAgICAgICAgIGxldCBmaW5pc2hSZXBvcnRzID0gKGVyciwgcmVzKSA9PiB7XG4gICAgICAgICAgICAgICAgaWYobnVtYmVyT2ZSZXBvcnRzID4gMSl7XG4gICAgICAgICAgICAgICAgICAgIG51bWJlck9mUmVwb3J0cyAtPSAxO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmKHJlcG9ydEZpbGVTdHJ1Y3R1cmUuZmFpbGVkLmNvdW50ID09PSAwKXtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fX2NvbnNvbGVMb2coXCJcXG5FdmVyeXRoaW5nIHdlbnQgd2VsbCEgTm8gZmFpbGVkIHRlc3RzLlxcblxcblwiKTtcbiAgICAgICAgICAgICAgICB9ZWxzZXtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fX2NvbnNvbGVMb2coXCJcXG5Tb21lIHRlc3RzIGZhaWxlZC4gQ2hlY2sgcmVwb3J0IGZpbGVzIVxcblxcblwiKTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrKGVyciwgXCJEb25lXCIpO1xuICAgICAgICAgICAgfTtcblxuXG4gICAgICAgICAgICB0aGlzLl9fY29uc29sZUxvZyh0aGlzLmNvbmZpZy5yZXBvcnRzLnByZWZpeCk7XG4gICAgICAgICAgICBjb25zdCBmaWxlTmFtZSA9IGAke3RoaXMuY29uZmlnLnJlcG9ydHMucHJlZml4fWxhdGVzdCR7dGhpcy5jb25maWcucmVwb3J0cy5leHR9YDtcbiAgICAgICAgICAgIGNvbnN0IGZpbGVQYXRoID0gc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3RydWN0dXJlLCBkZXN0aW5hdGlvbiwgY2FsbGJhY2spIHtcblxuICAgICAgICAgICAgdmFyIGNvbnRlbnQgPSBKU09OLnN0cmluZ2lmeShyZXBvcnRGaWxlU3RydWN0dXJlLCBudWxsLCA0KTtcbiAgICAgICAgICAgIGZzLndyaXRlRmlsZShkZXN0aW5hdGlvbiwgY29udGVudCwgJ3V0ZjgnLCBmdW5jdGlvbiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBtZXNzYWdlID0gXCJBbiBlcnJvciBvY2N1cnJlZCB3aGlsZSB3cml0aW5nIHRoZSByZXBvcnQgZmlsZSwgd2l0aCB0aGUgZm9sbG93aW5nIGVycm9yOiBcIiArIEpTT04uc3RyaW5naWZ5KGVycik7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX19kZWJ1Z0luZm8obWVzc2FnZSk7XG4gICAgICAgICAgICAgICAgICAgIHRocm93IGVycjtcbiAgICAgICAgICAgICAgICB9IGVsc2V7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IG1lc3NhZ2UgPSBgRmluaXNoZWQgd3JpdGluZyByZXBvcnQgdG8gJHtkZXN0aW5hdGlvbn1gO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9fY29uc29sZUxvZyhtZXNzYWdlKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY2FsbGJhY2soKTtcbiAgICAgICAgICAgIH0uYmluZCh0aGlzKSk7XG4gICAgICAgIH0sXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBTYXZlcyB0ZXN0IHJlcG9ydHMgYXMgSFRNTCBpbiB0aGUgc3BlY2lmaWVkIHBhdGguXG4gICAgICAgICAqIEBwYXJhbSByZXBvcnRGaWxlU3RydWN0dXJlIHtPYmplY3R9IC0gdGVzdCByZXBvcnRzIG9iamVjdCAoSlNPTilcbiAgICAgICAgICogQHBhcmFtIGRlc3RpbmF0a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W1lc3RhbXB9KTs8L3NjcmlwdD5gLCAndXRmOCcsIChlcnIpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWVzc2FnZSA9ICdBbiBlcnJvciBvY2N1cnJlZCB3aGlsZSB3cml0aW5nIHRoZSBodG1sIHJlcG9ydCBmaWxlLCB3aXRoIHRoZSBmb2xsb3dpbmcgZXJyb3I6ICcgKyBKU09OLnN0cmluZ2lmeShlcnIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fX2RlYnVnSW5mbyhtZXNzYWdlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IGVycjtcbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IG1lc3NhZ2UgPSBgRmluaXNoZWQgd3JpdGluZyByZXBvcnQgdG8gJHtkZXN0aW5hdGlvbn1gO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9fY29uc29sZUxvZyhtZXNzYWdlKTtcblxuICAgICAgICAgICAgICAgICAgICBjYWxsYmFjaygpO1xuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0sXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBDb252ZXJ0cyBhYnNvbHV0ZSBmaWxlIHBhdGggdG8gcmVsYXRpdmUgcGF0aC5cbiAgICAgICAgICogQHBhcmFtIGFic29sdXRlUGF0aCB7U3RyaW5nfSAtIGFic29sdXRlIHBhdGhcbiAgICAgICAgICogQHJldHVybnMge3N0cmluZyB8IHZvaWQgfCAqfSAtIHJlbGF0aXZlIHBhdGhcbiAgICAgICAgICogQHByaXZhdGVcbiAgICAgICAgICovXG4gICAgICAgIF9fdG9SZWxhdGl2ZVBhdGg6IGZ1bmN0aW9uKGFic29sdXRlUGF0aCkge1xuICAgICAgICAgICAgY29uc3QgYmFzZVBhdGggPSBwYXRoLmpvaW4odGhp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aXI7XG4gICAgICAgIH0sXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBGb3IgYSBmYWlsZWQgdGVzdCwgaXQgcmV0dXJucyBvbmx5IHRoZSBmaXJzdCBmYWlsIHJlYXNvbiBwZXIgZWFjaCBydW4uXG4gICAgICAgICAqIEBwYXJhbSB0ZXN0IHtPYmplY3R9IC0gdGVzdCBvYmplY3RcbiAgICAgICAgICogQHJldHVybnMge0FycmF5fSAtIGFuIGFycmF5IG9mIHJlYXNvbnMgcGVyIGVhY2ggdGVzdCBydW4uXG4gICAgICAgICAqIEBwcml2YXRlXG4gICAgICAgICAqL1xuICAgICAgICBfX2dldEZpcnN0RmFpbFJlYXNvblBlclJ1bjogZnVuY3Rpb24odGVzdCkge1xuICAgICAgICAgICAgY29uc3QgcmVhc29uID0gW107XG4gICAgICAgICAgICBmb3IobGV0IGkgPSAxOyBpIDw9IHRlc3QucmVzdWx0LnJ1bnM7IGkrKykge1xuICAgICAgICAgICAgICAgIGlmKHRlc3QucmVzdWx0LmFzc2VydHNbaV0gJiYgdGVzdC5yZXN1bHQuYXNzZXJ0c1tpXS5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICAgICAgICAgIGFkZFJlYXNvbihpLCB0ZXN0LnJlc3VsdC5hc3NlcnRzW2ldWzBdKTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBpZih0ZXN0LnJlc3VsdC5tZXNzYWdlc1tpXSAmJiB0ZXN0LnJlc3VsdC5tZXNzYWdlc1tpXS5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICAgICAgICAgIGFkZFJlYXNvbihpLCB0ZXN0LnJlc3VsdC5tZXNzYWdlc1tpXVswXSk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgZnVuY3Rpb24gYWRkUmVhc29uKHJ1biwgbG9nKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IG1lc3NhZ2UgPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBydW46IHJ1bixcbiAgICAgICAgICAgICAgICAgICAgICAgIGxvZzogbG9nXG4gICAgICAgICAgICAgICAgICAgIH07XG5cbiAgICAgICAgICAgICAgICAgICAgcmVhc29uLnB1c2gobWVzc2FnZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICByZXR1cm4gcmVhc29uO1xuICAgICAgICB9LFxuICAgICAgICAvKipcbiAgICAgICAgICogRGVzY3JpYmVkIGRlZmF1bHQgdHJlZSBub2RlIHN0cnVjdHVyZS5cbiAgICAgICAgICogQHJldHVybnMge3tfX21ldGE6IHtjb25mOiBudWxsLCBwYXJlbnQ6IG51bGwsIGlzRGlyZWN0b3J5OiBib29sZWFufSwgZGF0YToge25hbWU6IG51bGwsIHBhdGg6IG51bGx9LCByZXN1bHQ6IHtzdGF0ZTogc3RyaW5nLCBwYXNzOiBudWxsLCBleGVjdXRpb25UaW1lOiBudW1iZXIsIHJ1bnM6IG51bWJlciwgYXNzZXJ0czoge30sIG1lc3NhZ2VzOiB7fX0sIGl0ZW1zOiBudWxsfX1cbiAgICAgICAgICogQHByaXZhdGVcbiAgICAgICAgICovXG4gICAgICAgIF9fZ2V0RGVmYXVsdE5vZGVTdHJ1Y3R1cmU6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgcmV0dXJuICB7XG4gICAgICAgICAgICAgICAgX19tZXRhOiB7XG4gICAgICAgICAgICAgICAgICAgIGNvbmY6IG51bGwsXG4gICAgICAgICAgICAgICAgICAgIHBhcmVudDogbnVsbCxcbiAgICAgICAgICAgICAgICAgICAgaXNEaXJlY3Rvcnk6IGZhbHNlXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBkYXRhOiB7XG4gICAgICAgICAgICAgICAgICAgIG5hbWU6IG51bGwsXG4gICAgICAgICAgICAgICAgICAgIHBhdGg6IG51bGwsXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICByZXN1bHQ6IHtcbiAgICAgICAgICAgICAgICAgICAgc3RhdGU6IFRFU1RfU1RBVEVTLlJFQURZLCAvLyByZWFkeSB8IHJ1bm5pbmcgfCB0ZXJtaW5hdGVkIHwgdGltZW91dFxuICAgICAgICAgICAgICAgICAgICBwYXNzOiBudWxsLFxuICAgICAgICAgICAgICAgICAgICBleGVjdXRpb25UaW1lOiAwLFxuICAgICAgICAgICAgICAgICAgICBydW5zOiAwLFxuICAgICAgICAgICAgICAgICAgICBhc3NlcnRzOiB7fSxcbiAgICAgICAgICAgICAgICAgICAgbWVzc2FnZXM6IHt9XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBpdGVtczogbnVsbFxuICAgICAgICAgICAgfTtcbiAgICAgICAgfSxcbiAgICAgICAgLyoqXG4gICAgICAgICAqIE1hdGNoIGEgdGVzdCBmaWxlIHBhdGggdG8gYSBVTklYIGdsb2IgZXhwcmVzc2lvbiBhcnJheS4gSWYgaXRzIGFueSBtYXRjaCByZXR1cm5zIHRydWUsIG90aGVyd2lzZSByZXR1cm5zIGZhbHNlLlxuICAgICAgICAgKiBAcGFyYW0gZ2xvYkV4cEFycmF5IHtBcnJheX0gLSBhbiBhcnJheSB3aXRoIGdsb2IgZXhwcmVzc2lvbiAoVU5JWCBzdHlsZSlcbiAgICAgICAgICogQHBhcmFtIHN0ciB7U3RyaW5nfSAtIHRoZSBzdHJpbmcgdG8gYmUgbWF0Y2hlZFxuICAgICAgICAgKiBAcmV0dXJucyB7Ym9vbGVhbn0gLSByZXR1cm5zIHRydWUgaWYgdGhlcmUgaXMgYW55IG1hdGNoIGFuZCBmYWxzZSBvdGhlcndpc2UuXG4gICAgICAgICAqIEBwcml2YXRlXG4gICAgICAgICAqL1xuICAgICAgICBfX2lzQW55TWF0Y2g6IGZ1bmN0aW9uKGdsb2JFeHBBcnJheSwgc3RyKSB7XG4gICAgICAgICAgICBjb25zdCBoYXNNYXRjaCA9IGZ1bmN0aW9uKGdsb2JFeHApIHtcbiAgICAgICAgICAgICAgICBjb25zdCByZWdleCA9IGdsb2JUb1JlZ0V4cChnbG9iRXhwKTtcbiAgICAgICAgICAgICAgICByZXR1cm4gcmVnZXgudGVzdChzdHIpO1xuICAgICAgICAgICAgfTtcblxuICAgICAgICAgICAgcmV0dXJuIGdsb2JFeHBBcnJheS5zb21lKGhhc01hdGNoKTtcbiAgICAgICAgfSxcbiAgICAgICAgLyoqXG4gICAgICAgICAqIENvbnZlcnRzIGEgdHJlZSBzdHJ1Y3R1cmUgaW50byBhbiBhcnJheSBsaXN0IG9mIHRlc3Qgbm9kZXMuIFRoZSB0cmVlIHRyYXZlcnNhbCBpcyBERlMgKERlZXAtRmlyc3QtU2VhcmNoKS5cbiAgICAgICAgICogQHBhcmFtIHJvb3ROb2RlIHtPYmplY3R9IC0gcm9vdCBub2RlIG9mIHRoZSB0ZXN0IHRyZWUuXG4gICAgICAgICAqIEByZXR1cm5zIHtBcnJheX0gLSBMaXN0IG9mIHRlc3Qgbm9kZXMuXG4gICAgICAgICAqIEBwcml2YXRlXG4gICAgICAgICAqL1xuICAgICAgICBfX3RvVGVzdFRyZWVUb0xpc3Q6IGZ1bmN0aW9uKHJvb3ROb2RlKSB7XG4gICAgICAgICAgICB2YXIgdGVzdExpc3QgPSBbXTtcblxuICAgICAgICAgICAgdHJhdmVyc2Uocm9vdE5vZGUpO1xuXG4gICAgICAgICAgICBmdW5jdGlvbiB0cmF2ZXJzZShub2RlKSB7XG4gICAgICAgICAgICAgICAgaWYoIW5vZGUuX19tZXRhLmlzRGlyZWN0b3J5IHx8ICFub2RlLml0ZW1zKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBmb3IobGV0IGkgPSAwLCBsZW4gPSBub2RlLml0ZW1zLmxlbmd0aDsgaSA8IGxlbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGl0ZW0gPSBub2RlLml0ZW1zW2ldO1xuICAgICAgICAgICAgICAgICAgICBpZihpdGVtLl9fbWV0YS5pc0RpcmVjdG9yeSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdHJhdmVyc2UoaXRlbSk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0ZXN0TGlzdC5wdXNoKGl0ZW0pO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICByZXR1cm4gdGVzdExpc3Q7XG4gICAgICAgIH0sXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBMb2dnaW5nIHRvIGNvbnNvbGUgd3JhcHBlci5cbiAgICAgICAgICogQHBhcmFtIGxvZyB7U3RyaW5nfE9iamVjdHxOdW1iZXJ9IC0gbG9nIG1lc3NhZ2VcbiAgICAgICAgICogQHByaXZhdGVcbiAgICAgICAgICovXG4gICAgICAgIF9fY29uc29sZUxvZzogZnVuY3Rpb24obG9nKSB7XG4gICAgICAgICAgICBjb25zb2xlLmxvZyhUQUcsIGxvZyk7XG4gICAgICAgIH0sXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBMb2dnaW5nIGRlYnVnZ2luZyBpbmZvIG1lc3NhZ2VzIHdyYXBwZXIuXG4gICAgICAgICAqIExvZ2dlcjogY29uc29sZS5pbmZvXG4gICAgICAgICAqIEBwYXJhbSBsb2cge1N0cmluZ3xPYmplY3R8TnVtYmVyfSAtIGxvZyBtZXNzYWdlXG4gICAgICAgICAqIEBwcml2YXRlXG4gICAgICAgICAqL1xuICAgICAgICBfX2RlYnVnSW5mbzogZnVuY3Rpb24obG9nKSB7XG4gICAgICAgICAgICB0aGlzLl9fZGVidWcoY29uc29sZS5pbmZvLCBsb2cpO1xuICAgICAgICB9LFxuICAgICAgICAvKipcbiAgICAgICAgICogTG9nZ2luZyBkZWJ1Z2dpbmcgZXJyb3IgbWVzc2FnZXMgd3JhcHBlci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3Qgb2JqZWN0IGlzIG92ZXJyaWRkZW4uXG4gICAgICAgICAqIEBwYXJhbSBmaXJzdCB7T2JqZWN0fSAtIHRoZSBmaXJzdCBvYmplY3RcbiAgICAgICAgICogQHBhcmFtIHNlY29uZCB7T2JqZWN0fSAtIHRoZSBzZWNvbmQgb2JqZWN0XG4gICAgICAgICAqIEByZXR1cm5zIHtPYmplY3R9IC0gYW4gb2JqZWN0IHdpdGggYm90aCBwcm9wZXJ0aWVzIGZyb20gdGhlIGZpcnN0IGFuZCBzZWNvbmQgb2JqZWN0LlxuICAgICAgICAgKiBAcHJpdmF0ZVxuICAgICAgICAgKi9cbiAgICAgICAgX19leHRlbmQ6IGZ1bmN0aW9uIChmaXJzdCwgc2Vjb25kKSB7XG4gICAgICAgICAgICBmb3IgKGNvbnN0IGtleSBpbiBzZWNvbmQpIHtcbiAgICAgICAgICAgICAgICBpZiAoIWZpcnN0Lmhhc093blByb3BlcnR5KGtleSkpIHtcbiAgICAgICAgICAgICAgICAgICAgZmlyc3Rba2V5XSA9IHNlY29uZFtrZXldO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGxldCB2YWwgPSBzZWNvbmRba2V5XTtcbiAgICAgICAgICAgICAgICAgICAgaWYodHlwZW9mIGZpcnN0W2tleV0gPT09ICdvYmplY3QnKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YWwgPSB0aGlzLl9fZXh0ZW5kKGZpcnN0W2tleV0sIHNlY29uZFtrZXldKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIGZpcnN0W2tleV0gPSB2YWw7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICByZXR1cm4gZmlyc3Q7XG4gICAgICAgIH1cbiAgICB9O1xufTtcbiIsIlxuLy8gZ2xvYlRvUmVnRXhwIHR1cm5zIGEgVU5JWCBnbG9iIGV4cHJlc3Npb24ga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ICAgIGNvbnN0IGFyY2hpdmVyID0gbmV3IFBza0FyY2hpdmVyKCk7XG5cbiAgICAgICAgYXJjaGl2ZXIub24oJ3Byb2dyZXNzJywgKHByb2dyZXNzKSA9PiB7XG4gICAgICAgICAgICBzZWxmLmVtaXQoJ3Byb2dyZXNzJywgcHJvZ3Jlc3MpO1xuICAgICAgICB9KTtcblxuICAgICAgICBmcy5vcGVuKGRlc3RpbmF0aW9uUGF0aCwgXCJ3eFwiLCBmdW5jdGlvbiAoZXJyLCBmZCkge1xuICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgIGNhbGxiYWNrKGVycik7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBmcy5jbG9zZShmZCwgZnVuY3Rpb24gKGVycikge1xuICAgICAgICAgICAgICAgIGlmIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNhbGxiYWNrKGVycik7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgY29uc3Qgd3MgPSBmcy5jcmVhdGVXcml0ZVN0cmVhbShkZXN0aW5hdGlvblBhdGgsIHthdXRvQ2xvc2U6IGZhbHNlfSk7XG4gICAgICAgICAgICAgICAgY29uc3Qga2V5U2FsdCA9IGNyeXB0by5yYW5kb21CeXRlcygzMik7XG4gICAgICAgICAgICAgICAgY29uc3Qga2V5ID0gY3J5cHRvLnBia2RmMlN5bmMocGFzc3dvcmQsIGtleVNhbHQsIHV0aWxzLml0ZXJhdGlvbnNfbnVtYmVyLCAzMiwgJ3NoYTUxMicpO1xuXG4gICAgICAgICAgICAgICAgY29uc3QgYWFkU2FsdCA9IGNyeXB0by5yYW5kb21CeXRlcygzMik7XG4gICAgICAgICAgICAgICAgY29uc3QgYWFkID0gY3J5cHRvLnBia2RmMlN5bmMocGFzc3dvcmQsIGFhZFNhbHQsIHV0aWxzLml0ZXJhdGlvbnNfbnVtYmVyLCAzMiwgJ3NoYTUxMicpO1xuXG4gICAgICAgICAgICAgICAgY29uc3Qgc2FsdCA9IEJ1ZmZlci5jb25jYXQoW2tleVNhbHQsIGFhZFNhbHRdKTtcbiAgICAgICAgICAgICAgICBjb25zdCBpdiA9IGNyeXB0by5wYmtkZjJTeW5jKHBhc3N3b3JkLCBzYWx0LCB1dGlscy5pdGVyYXRpb25zX251bWJlciwgMTIsICdzaGE1MTInKTtcblxuICAgICAgICAgICAgICAgIGNvbnN0IGNpcGhlciA9IGNyeXB0by5jcmVhdGVDaXBoZXJpdih1dGlscy5hbGdvcml0aG0sIGtleSwgaXYpO1xuICAgICAgICAgICAgICAgIGNpcGhlci5zZXRBQUQoYWFkKTtcbiAgICAgICAgICAgICAgICBhcmNoaXZlci56aXBTdHJlYW0oaW5wdXRQYXRoLCBjaXBoZXIsIGZ1bmN0aW9uIChlcnIsIGNpcGhlclN0cmVhbSkge1xuXG4gICAgICAgICAgICAgICAgICAgIGlmIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjYWxsYmFjayhlcnIpO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgY2lwaGVyU3RyZWFtLm9uKFwiZGF0YVwiLCBmdW5jdGlvbiAoY2h1bmspIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHdzLndyaXRlKGNodW5rKTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgIGNpcGhlclN0cmVhbS5vbignZW5kJywgZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGFnID0gY2lwaGVyLmdldEF1dGhUYWcoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRhdGFUb0FwcGVuZCA9IEJ1ZmZlci5jb25jYXQoW3NhbHQsIHRhZ10pO1xuICAgICAgICAgICAgICAgICAgICAgICAgd3MuZW5kKGRhdGFUb0FwcGVuZCwgZnVuY3Rpb24gKGVycikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNhbGxiYWNrKGVycik7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2soKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0pO1xuICAgIH07XG5cbiAgICB0aGlzLmRlY3J5cHRTdHJlYW0gPSBmdW5jdGlvbiAoZW5jcnlwdGVkSW5wdXRQYXRoLCBvdXRwdXRGb2xkZXIsIHBhc3N3b3JkLCBjYWxsYmFjaykge1xuXG4gICAgICAgIGNvbnN0IGFyY2hpdmVyID0gbmV3IFBza0FyY2hpdmVyKCk7XG5cbiAgICAgICAgZGVjcnlwdEZpbGUoZW5jcnlwdGVkSW5wdXRQYXRoLCB0ZW1wRm9sZGVyLCBwYXNzd29yZCwgZnVuY3Rpb24gKGVyciwgdGVtcEFyY2hpdmVQYXRoKSB7XG4gICAgICAgICAgICBpZiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGNhbGxiYWNrKGVycik7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGFyY2hpdmVyLm9uKCdwcm9ncmVzcycsIChwcm9ncmVzcykgPT4ge1xuICAgICAgICAgICAgICAgIHNlbGYuZW1pdCgncHJvZ3Jlc3MnLCAxMCArIDAuOSAqIHByb2dyZXNzKTtcbiAgICAgICAgICAgIH0pO1xuXG5cbiAgICAgICAgICAgIGFyY2hpdmVyLnVuemlwU3RyZWFtKHRlbXBBcmNoaXZlUGF0aCwgb3V0cHV0Rm9sZGVyLCBmdW5jdGlvbiAoZXJyLCB1bnppcHBlZEZpbGVOYW1lcykge1xuICAgICAgICAgICAgICAgIGlmIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNhbGxiYWNrKGVycik7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgdXRpbHMuZGVsZXRlUmVjdXJzaXZlbHkodGVtcEFyY2hpdmVQYXRoLCBmdW5jdGlvbiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjYWxsYmFjayhlcnIpO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2sodW5kZWZpbmVkLCB1bnppcHBlZEZpbGVOYW1lcyk7XG4gICAgICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KVxuICAgIH07XG5cbiAgICB0aGlzLmVuY3J5cHRPYmplY3QgPSBmdW5jdGlvbiAoaW5wdXRPYmosIGRzZWVkLCBkZXB0aCwgY2FsbGJhY2spIHtcbiAgICAgICAgY29uc3QgYXJjaGl2ZXIgPSBuZXcgUHNrQXJjaGl2ZXIoKTtcblxuICAgICAgICBhcmNoaXZlci56aXBJbk1lbW9yeShpbnB1dE9iaiwgZGVwdGgsIGZ1bmN0aW9uIChlcnIsIHppcHBlZE9iaikge1xuICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgIHJldHVybiBjYWxsYmFjayhlcnIpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY29uc3QgY2lwaGVyVGV4dCA9IHV0aWxzLmVuY3J5cHQoemlwcGVkT2JqLCBkc2VlZCk7XG4gICAgICAgICAgICBjYWxsYmFjayhudWxsLCBjaXBoZXJUZXh0KTtcbiAgICAgICAgfSlcbiAgICB9O1xuXG4gICAgdGhpcy5kZWNyeXB0T2JqZWN0ID0gZnVuY3Rpb24gKGVuY3J5cHRlZERhdGEsIGRzZWVkLCBjYWxsYmFjaykge1xuICAgICAgICBjb25zdCBhcmNoaXZlciA9IG5ldyBQc2tBcmNoaXZlcigpO1xuXG4gICAgICAgIGNvbnN0IHppcHBlZE9iamVjdCA9IHV0aWxzLmRlY3J5cHQoZW5jcnlwdGVkRGF0YSwgZHNlZWQpO1xuICAgICAgICBhcmNoaXZlci51bnppcEluTWVtb3J5KHppcHBlZE9iamVjdCwgZnVuY3Rpb24gKGVyciwgb2JqKSB7XG4gICAgICAgICAgICBpZiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGNhbGxiYWNrKGVycik7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjYWxsYmFjayhudWxsLCBvYmopO1xuICAgICAgICB9KVxuICAgIH07XG5cbiAgICB0aGlzLnBza0hhc2ggPSBmdW5jdGlvbiAoZGF0YSkge1xuICAgICAgICBpZiAoQnVmZmVyLmlzQnVmZmVyKGRhdGEpKSB7XG4gICAgICAgICAgICByZXR1cm4gdXRpbHMuY3JlYXRlUHNrSGFzaChkYXRhKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoZGF0YSBpbnN0YW5jZW9mIE9iamVjdCkge1xuICAgICAgICAgICAgcmV0dXJuIHV0aWxzLmNyZWF0ZVBza0hhc2goSlNPTi5zdHJpbmdpZnkoZGF0YSkpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB1dGlscy5jcmVhdGVQc2tIYXNoKGRhdGEpO1xuICAgIH07XG5cbiAgICB0aGlzLnBza0hhc2hTdHJlYW0gPSBmdW5jdGlvbiAocmVhZFN0cmVhbSwgY2FsbGJhY2spIHtcbiAgICAgICAgY29uc3QgcHNrSGFzaCA9IG5ldyB1dGlscy5Qc2tIYXNoKCk7XG5cbiAgICAgICAgcmVhZFN0cmVhbS5vbignZGF0YScsIChjaHVuaykgPT4ge1xuICAgICAgICAgICAgcHNrSGFzaC51cGRhdGUoY2h1bmspO1xuICAgICAgICB9KTtcblxuXG4gICAgICAgIHJlYWRTdHJlYW0ub24oJ2VuZCc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VuY3J5cHRlZElucHV0UGF0aCwgZnVuY3Rpb24gKGVyciwgc3RhdHMpIHtcbiAgICAgICAgICAgIGlmIChlcnIpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gY2FsbGJhY2soZXJyLCBudWxsKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgY29uc3QgZmlsZVNpemVJbkJ5dGVzID0gc3RhdHMuc2l6ZTtcblxuICAgICAgICAgICAgZnMub3BlbihlbmNyeXB0ZWRJbnB1dFBhdGgsIFwiclwiLCBmdW5jdGlvbiAoZXJyLCBmZCkge1xuICAgICAgICAgICAgICAgIGlmIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2soZXJyLCBudWxsKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBlbmNyeXB0ZWRBdXRoRGF0YSA9IEJ1ZmZlci5hbGxvYyg4MCk7XG5cbiAgICAgICAgICAgICAgICAgICAgZnMucmVhZChmZCwgZW5jcnlwdGVkQXV0aERhdGEsIDAsIDgwLCBmaWxlU2l6ZUluQnl0ZXMgLSA4MCwgZnVuY3Rpb24gKGVyciwgYnl0ZXNSZWFkKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzYWx0ID0gZW5jcnlwdGVkQXV0aERhdGEuc2xpY2UoMCwgNjQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qga2V5U2FsdCA9IHNhbHQuc2xpY2UoMCwgMzIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYWFkU2FsdCA9IHNhbHQuc2xpY2UoLTMyKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXYgPSBjcnlwdG8ucGJrZGYyU3luYyhwYXNzd29yZCwgc2FsdCwgdXRpbHMuaXRlcmF0aW9uc19udW1iZXIsIDEyLCAnc2hhNTEyJyk7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBrZXkgPSBjcnlwdG8ucGJrZGYyU3luYyhwYXNzd29yZCwga2V5U2FsdCwgdXRpbHMuaXRlcmF0aW9uc19udW1iZXIsIDMyLCAnc2hhNTEyJyk7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhYWQgPSBjcnlwdG8ucGJrZGYyU3luYyhwYXNzd29yZCwgYWFkU2FsdCwgdXRpbHMuaXRlcmF0aW9uc19udW1iZXIsIDMyLCAnc2hhNTEyJyk7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0YWcgPSBlbmNyeXB0ZWRBdXRoRGF0YS5zbGljZSgtMTYpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkZWNpcGhlciA9IGNyeXB0by5jcmVhdGVEZWNpcGhlcml2KHV0aWxzLmFsZ29yaXRobSwga2V5LCBpdik7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIGRlY2lwaGVyLnNldEFBRChhYWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgZGVjaXBoZXIuc2V0QXV0aFRhZyh0YWcpO1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcnMgPSBmcy5jcmVhdGVSZWFkU3RyZWFtKGVuY3J5cHRlZElucHV0UGF0aCwge3N0YXJ0OiAwLCBlbmQ6IGZpbGVTaXplSW5CeXRlcyAtIDgxfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBmcy5ta2Rpcih0ZW1wRm9sZGVyLCB7cmVjdXJzaXZlOiB0cnVlfSwgZnVuY3Rpb24gKGVycikge1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FsbGJhY2soZXJyKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGVtcEFyY2hpdmVQYXRoID0gcGF0aC5qb2luKHRlbXBGb2xkZXIsIHBhdGguYmFzZW5hbWUoZW5jcnlwdGVkSW5wdXRQYXRoKSArIFwiLnppcFwiKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZzLm9wZW4odGVtcEFyY2hpdmVQYXRoLCBcIndcIiwgZnVuY3Rpb24gKGVyciwgZmQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2soZXJyKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZzLmNsb3NlKGZkLCBmdW5jdGlvbiAoZXJyKSB7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FsbGJhY2soZXJyKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcHRTdHJlYW0gPSBuZXcgUGFzc1Rocm91Z2hTdHJlYW0oKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgd3MgPSBmcy5jcmVhdGVXcml0ZVN0cmVhbSh0ZW1wQXJjaGl2ZVBhdGgsIHthdXRvQ2xvc2U6IGZhbHNlfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cy5vbihcImZpbmlzaFwiLCBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2sobnVsbCwgdGVtcEFyY2hpdmVQYXRoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuXG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBwcm9ncmVzc0xlbmd0aCA9IDA7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgdG90YWxMZW5ndGggPSAwO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKipcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqIFRPRE8gcmV2aWV3IHRoaXNcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqIEluIGJyb3dzZXIsIHBpcGluZyB3aWxsIGJsb2NrIHRoZSBldmVudCBsb29wIGFuZCB0aGUgc3RhY2sgcXVldWUgaXMgbm90IGNhbGxlZC5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqL1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcnMub24oXCJkYXRhXCIsIChjaHVuaykgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByb2dyZXNzTGVuZ3RoICs9IGNodW5rLmxlbmd0aDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0b3RhbExlbmd0aCArPSBjaHVuay5sZW5ndGg7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocHJvZ3Jlc3NMZW5ndGggPiAzMDAwMDApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvZ3Jlc3NMZW5ndGggPSAwO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbWl0UHJvZ3Jlc3MoZmlsZVNpemVJbkJ5dGVzLCB0b3RhbExlbmd0aClcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcnMucGlwZShkZWNpcGhlcikucGlwZShwdFN0cmVhbSkucGlwZSh3cyk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcblxuICAgICAgICAgICAgICAgICAgICB9KTtcblxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KTtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBlbWl0UHJvZ3Jlc3ModG90YWwsIHByb2Nlc3NlZCkge1xuXG5cbiAgICAgICAgaWYgKHByb2Nlc3NlZCA+IHRvdGFsKSB7XG4gICAgICAgICAgICBwcm9jZXNzZWQgPSB0b3RhbDtcbiAgICAgICAgfVxuXG4gICAgICAgIGNvbnN0IHByb2dyZXNzID0gKDEwMCAqIHByb2Nlc3NlZCkgLyB0b3RhbDtcbiAgICAgICAgc2VsZi5lbWl0KCdwcm9ncmVzcycsIHBhcnNlSW50KHByb2dyZXNzKSk7XG4gICAgfVxuXG59XG5cbm1vZHVsZS5leHBvcnRzID0gbmV3IFBza0NyeXB0bygpO1xuIiwidmFyIGFzbjEgPSByZXF1aXJlKCcuL2FzbjEnKTtcbnZhciBpbmhlcml0cyA9IHJlcXVpcmUoJ3V0aWwnKS5pbmhlcml0cztcblxudmFyIGFwaSA9IGV4cG9ydHM7XG5cbmFwaS5kZWZpbmUgPSBmdW5jdGlvbiBkZWZpbmUobmFtZSwgYm9keSkge1xuICByZXR1cm4gbmV3IEVudGl0eShuYW1lLCBib2R5KTtcbn07XG5cbmZ1bmN0aW9uIEVudGl0eShuYW1lLCBib2R5KSB7XG4gIHRoaXMubmFtZSA9IG5hbWU7XG4gIHRoaXMuYm9keSA9IGJvZHk7XG5cbiAgdGhpcy5kZWNvZGVycyA9IHt9O1xuICB0aGlzLmVuY29kZXJzID0ge307XG59O1xuXG5FbnRpdHkucHJvd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AgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgemlwRmlsZS5lbmQoKTtcbiAgICAgICAgICAgICAgICBjb25zdCBmaWxlbmFtZSA9IHBhdGguYmFzZW5hbWUoaW5wdXRQYXRoKTtcbiAgICAgICAgICAgICAgICBjb25zdCBzcGxpdEZpbGVuYW1lID0gZmlsZW5hbWUuc3BsaXQoXCIuXCIpO1xuICAgICAgICAgICAgICAgIGlmIChzcGxpdEZpbGVuYW1lLmxlbmd0aCA+PSAyKSB7XG4gICAgICAgICAgICAgICAgICAgIGV4dCA9IFwiLlwiICsgc3BsaXRGaWxlbmFtZVtzcGxpdEZpbGVuYW1lLmxlbmd0aCAtIDFdO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBjb25zdCBteVN0cmVhbSA9IHppcEZpbGUub3V0cHV0U3RyZWFtLnBpcGUocHRTdHJlYW0pO1xuXG4gICAgICAgICAgICAgICAgbGV0IHByb2dyZXNzTGVuZ3RoID0gMDtcbiAgICAgICAgICAgICAgICBsZXQgdG90YWxMZW5ndGggPSAwO1xuXG4gICAgICAgICAgICAgICAgLyoqXG4gICAgICAgICAgICAgICAgICogVE9ETyByZXZpZXcgdGhpc1xuICAgICAgICAgICAgICAgICAqIEluIGJyb3dzZXIsIHBpcGluZyB3aWxsIGJsb2NrIHRoZSBldmVudCBsb29wIGFuZCB0aGUgc3RhY2sgcXVldWUgaXMgbm90IGNhbGxlZC5cbiAgICAgICAgICAgICAgICAgKi9cbiAgICAgICAgICAgICAgICBteVN0cmVhbS5vbihcImRhdGFcIiwgKGNodW5rKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIHByb2dyZXNzTGVuZ3RoICs9IGNodW5rLmxlbmd0aDtcbiAgICAgICAgICAgICAgICAgICAgdG90YWxMZW5ndGggKz0gY2h1bmsubGVuZ3RoO1xuXG4gICAgICAgICAgICAgICAgICAgIGlmIChwcm9ncmVzc0xlbmd0aCA+IDMwMDAwMCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgbXlTdHJlYW0ucGF1c2UoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHByb2dyZXNzTGVuZ3RoID0gMDtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNldFRpbWVvdXQoZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG15U3RyZWFtLnJlc3VtZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfSwgMTApO1xuICAgICAgICAgICAgICAgICAgICAgICAgZW1pdFByb2dyZXNzKHRvdGFsU2l6ZSwgdG90YWxMZW5ndGgpXG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9KTtcblxuICAgICAgICAgICAgICAgIG15U3RyZWFtLm9uKCdlbmQnLCAoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIGVtaXRQcm9ncmVzcyh0b3RhbFNpemUsIHRvdGFsU2l6ZSk7XG4gICAgICAgICAgICAgICAgICAgIGVtaXRUb3RhbFNpemUodG90YWxTaXplKTtcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICBpZiAoaXNTdHJlYW0uaXNXcml0YWJsZShvdXRwdXQpKSB7XG4gICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrKG51bGwsIG15U3RyZWFtLnBpcGUob3V0cHV0KSk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2Ygb3V0cHV0ID09PSBcInN0cmluZ1wiKSB7XG4gICAgICAgICAgICAgICAgICAgZnMubWtkaXIob3V0cHV0LCB7cmVjdXJzaXZlOiB0cnVlfSwgKCkgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGVzdGluYXRpb25QYXRoID0gcGF0aC5qb2luKG91dHB1dCwgcGF0aC5iYXNlbmFtZShpbnB1dFBhdGgsIGV4dCkgKyBcIi56aXBcIik7XG4gICAgICAgICAgICAgICAgICAgICAgICBteVN0cmVhbS5waXBlKGZzLmNyZWF0ZVdyaXRlU3RyZWFtKGRlc3RpbmF0aW9uUGF0aCkpO1xuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcblxuICAgICAgICAgICAgZnVuY3Rpb24gX19hZGRUb0FyY2hpdmVSZWN1cnNpdmVseSh6aXBGaWxlLCBpbnB1dFBhdGgsIHJvb3QgPSAnJywgY2FsbGJhY2spIHtcbiAgICAgICAgICAgICAgICByb290ID0gcm9vdCB8fCAnJztcbiAgICAgICAgICAgICAgICBmcy5zdGF0KGlucHV0UGF0aCwgKGVyciwgc3RhdHMpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNhbGxiYWNrKGVycik7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRzLmlzRmlsZSgpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB6aXBGaWxlLmFkZEZpbGUoaW5wdXRQYXRoLCBwYXRoLmpvaW4ocm9vdCwgcGF0aC5iYXNlbmFtZShpbnB1dFBhdGgpKSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBjYWxsYmFjayhudWxsKTtcblxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgZnMucmVhZGRpcihpbnB1dFBhdGgsIChlcnIsIGZpbGVzKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FsbGJhY2soZXJyKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZl9sZW5ndGggPSBmaWxlcy5sZW5ndGg7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGZfYWRkX2luZGV4ID0gMDtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNoZWNrU3RhdHVzID0gKCkgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZl9sZW5ndGggPT09IGZfYWRkX2luZGV4KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWxsYmFjayhudWxsKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9O1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFjaGVja1N0YXR1cygpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVzLmZvckVhY2goZmlsZSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZW1wUGF0aCA9IHBhdGguam9pbihpbnB1dFBhdGgsIGZpbGUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX19hZGRUb0FyY2hpdmVSZWN1cnNpdmVseSh6aXBGaWxlLCB0ZW1wUGF0aCwgcGF0aC5qb2luKHJvb3QsIHBhdGguYmFzZW5hbWUoaW5wdXRQYXRoKSksIChlcnIpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjYWxsYmFjayhlcnIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmX2FkZF9pbmRleCsrO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoZWNrU3RhdHVzKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgfSk7XG5cbiAgICB9O1xuXG4gICAgdGhpcy51bnppcFN0cmVhbSA9IGZ1bmN0aW9uIChpbnB1dCwgb3V0cHV0UGF0aCwgY2FsbGJhY2spIHtcblxuICAgICAgICBsZXQgc2l6ZSA9IDA7XG5cbiAgICAgICAgZnMuc3RhdChpbnB1dCwgKGVyciwgc3RhdHMpID0+IHtcbiAgICAgICAgICAgIGlmIChlcnIpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gY2FsbGJhY2soZXJyKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgbGV0IHRvdGFsU2l6ZSA9IHN0YXRzLnNpemU7XG5cblxuICAgICAgICAgICAgeWF1emwub3BlbihpbnB1dCwge2xhenlFbnRyaWVzOiB0cnVlfSwgKGVyciwgemlwRmlsZSkgPT4ge1xuICAgICAgICAgICAgICAgIGlmIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNhbGxiYWNrKGVycik7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgbGV0IHByb2dyZXNzTGVuZ3RoID0gMDtcbiAgICAgICAgICAgICAgICBsZXQgdG90YWxMZW5ndGggPSAwO1xuXG4gICAgICAgICAgICAgICAgY29uc3QgZmlsZU5hbWVzID0gW107XG4gICAgICAgICAgICAgICAgemlwRmlsZS5yZWFkRW50cnkoKTtcbiAgICAgICAgICAgICAgICB6aXBGaWxlLm9uY2UoXCJlbmRcIiwgKCkgPT4ge1xuICAgICAgICAgICAgICAgICAgICBlbWl0UHJvZ3Jlc3ModG90YWxTaXplLCB0b3RhbFNpemUpO1xuICAgICAgICAgICAgICAgICAgICBjYWxsYmFjayhudWxsLCBmaWxlTmFtZXMpO1xuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIHppcEZpbGUub24oXCJlbnRyeVwiLCAoZW50cnkpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGVudHJ5LmZpbGVOYW1lLmVuZHNXaXRoKHBhdGguc2VwKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgemlwRmlsZS5yZWFkRW50cnkoKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBmb2xkZXIgPSBwYXRoLmRpcm5hbWUoZW50cnkuZmlsZU5hbWUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgZnMubWtkaXIocGF0aC5qb2luKG91dHB1dFBhdGgsIGZvbGRlciksIHtyZWN1cnNpdmU6IHRydWV9LCAoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgemlwRmlsZS5vcGVuUmVhZFN0cmVhbShlbnRyeSwgKGVyciwgcmVhZFN0cmVhbSkgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FsbGJhY2soZXJyKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8qKlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKiBUT0RPIHJldmlldyB0aGlzXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqIEluIGJyb3dzZXIsIHBpcGluZyB3aWxsIGJsb2NrIHRoZSBldmVudCBsb29wIGFuZCB0aGUgc3RhY2sgcXVldWUgaXMgbm90IGNhbGxlZC5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICovXG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhZFN0cmVhbS5vbihcImRhdGFcIiwgKGNodW5rKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcm9ncmVzc0xlbmd0aCArPSBjaHVuay5sZW5ndGg7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0b3RhbExlbmd0aCArPSBjaHVuay5sZW5ndGg7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwcm9ncmVzc0xlbmd0aCA+IDMwMDAwMCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRTdHJlYW0ucGF1c2UoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcm9ncmVzc0xlbmd0aCA9IDA7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0VGltZW91dChmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRTdHJlYW0ucmVzdW1lKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgMzApO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVtaXRQcm9ncmVzcyh0b3RhbFNpemUsIHRvdGFsTGVuZ3RoKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcblxuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRTdHJlYW0ub24oXCJlbmRcIiwgKCkgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgemlwRmlsZS5yZWFkRW50cnkoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHB0U3RyZWFtID0gbmV3IFBhc3NUaHJvdWdoU3RyZWFtKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBmaWxlTmFtZSA9IHBhdGguam9pbihvdXRwdXRQYXRoLCBlbnRyeS5maWxlTmFtZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBmb2xkZXIgPSBwYXRoLmRpcm5hbWUoZmlsZU5hbWUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZW1wU3RyZWFtID0gcmVhZFN0cmVhbS5waXBlKHB0U3RyZWFtKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmcy5ta2Rpcihmb2xkZXIsIHtyZWN1cnNpdmU6IHRydWV9LCAoZXJyKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNhbGxiYWNrKGVycik7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpemUgKz0gcHRTdHJlYW0uZ2V0U2l6ZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG91dHB1dCA9IGZzLmNyZWF0ZVdyaXRlU3RyZWFtKGZpbGVOYW1lKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVOYW1lcy5wdXNoKGZpbGVOYW1lKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRlbXBTdHJlYW0ucGlwZShvdXRwdXQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9KTtcblxuICAgICAgICB9KTtcblxuICAgIH07XG5cbiAgICB0aGlzLnppcEluTWVtb3J5ID0gZnVuY3Rpb24gKGlucHV0T2JqLCBkZXB0aCwgY2FsbGJhY2spIHtcbiAgICAgICAgY29uc3QgemlwRmlsZSA9IG5ldyB5YXpsLlppcEZpbGUoKTtcbiAgICAgICAgY29uc3QgZHMgPSBuZXcgRHVwbGV4U3RyZWFtKCk7XG4gICAgICAgIHppcFJlY3Vyc2l2ZWx5KHppcEZpbGUsIGlucHV0T2JqLCBcIlwiLCBkZXB0aCwgKGVycikgPT4ge1xuICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgIHJldHVybiBjYWxsYmFjayhlcnIpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgemlwRmlsZS5lbmQoKTtcbiAgICAgICAgICAgIGxldCBidWZmZXIgPSBCdWZmZXIuYWxsb2MoMCk7XG4gICAgICAgICAgICBkcy5vbignZGF0YScsIChjaHVuaykgPT4ge1xuICAgICAgICAgICAgICAgIGJ1ZmZlciA9IEJ1ZmZlci5jb25jYXQoW2J1ZmZlciwgY2h1bmtdKTtcbiAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICB6aXBGaWxlLm91dHB1dFN0cmVhbS5waXBlKGRzKS5vbihcImZpbmlzaFwiLCAoZXJyKSA9PiB7XG4gICAgICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FsbGJhY2soZXJyKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY2FsbGJhY2sobnVsbCwgYnVmZmVyKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KVxuICAgIH07XG5cbiAgICB0aGlzLnVuemlwSW5NZW1vcnkgPSBmdW5jdGlvbiAoaW5wdXRaaXAsIGNhbGxiYWNrKSB7XG5cbiAgICAgICAgZnVuY3Rpb24gdW56aXBJbnB1dCh6aXBGaWxlKSB7XG4gICAgICAgICAgICB6aXBGaWxlLnJlYWRFbnRyeSgpO1xuICAgICAgICAgICAgY29uc3Qgb2JqID0ge307XG4gICAgICAgICAgICB6aXBGaWxlLm9uY2UoXCJlbmRcIiwgKCkgPT4ge1xuICAgICAgICAgICAgICAgIGNhbGxiYWNrKG51bGwsIG9iaik7XG4gICAgICAgICAgICB9KTtcblxuICAgICAgICAgICAgemlwRmlsZS5vbihcImVudHJ5XCIsIChlbnRyeSkgPT4ge1xuICAgICAgICAgICAgICAgIHppcEZpbGUub3BlblJlYWRTdHJlYW0oZW50cnksIChlcnIsIHJlYWRTdHJlYW0pID0+IHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgZHMgPSBuZXcgRHVwbGV4U3RyZWFtKCk7XG4gICAgICAgICAgICAgICAgICAgIGxldCBzdHIgPSAnJztcbiAgICAgICAgICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNhbGxiYWNrKGVycik7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgcmVhZFN0cmVhbS5vbihcImVuZFwiLCAoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB6aXBGaWxlLnJlYWRFbnRyeSgpO1xuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgZHMub24oXCJkYXRhXCIsIChjaHVuaykgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3RyICs9IGNodW5rLnRvU3RyaW5nKCk7XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICAgICAgICAgIHJlYWRTdHJlYW0ucGlwZShkcykub24oXCJmaW5pc2hcIiwgKGVycikgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjYWxsYmFjayhlcnIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3BsaXRFbnRyeSA9IGVudHJ5LmZpbGVOYW1lLnNwbGl0KFwiL1wiKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBzcGxpdEVudHJ5LnBvcCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgYWRkUHJvcHNSZWN1cnNpdmVseShvYmosIHNwbGl0RW50cnksIHR5cGUsIG5ldyBCdWZmZXIoc3RyKSk7XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9KVxuICAgICAgICB9XG5cbiAgICAgICAgaWYgKEJ1ZmZlci5pc0J1ZmZlcihpbnB1dFppcCkpIHtcbiAgICAgICAgICAgIHlhdXpsLmZyb21CdWZmZXIoaW5wdXRaaXAsIHtsYXp5RW50cmllczogdHJ1ZX0sIChlcnIsIHppcEZpbGUpID0+IHtcbiAgICAgICAgICAgICAgICBpZiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBjYWxsYmFjayhlcnIpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB1bnppcElucHV0KHppcEZpbGUpXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiBjYWxsYmFjayhuZXcgRXJyb3IoXCJpbnB1dCBzaG91bGQgYmUgYSBidWZmZXJcIikpO1xuICAgICAgICB9XG5cbiAgICB9O1xuXG4gICAgZnVuY3Rpb24gemlwUmVjdXJzaXZlbHkoemlwRmlsZSwgb2JqLCByb290LCBkZXB0aCwgY2FsbGJhY2spIHtcbiAgICAgICAgaWYgKGRlcHRoID09PSAwKSB7XG4gICAgICAgICAgICB6aXBGaWxlLmFkZEJ1ZmZlcihuZXcgQ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W5ndGg7IGkrKykge1xuICAgICAgICAgICAgICAgIGlmIChvYmoubGVuZ3RoID09PSAwKSB7XG4gICAgICAgICAgICAgICAgICAgIHppcEZpbGUuYWRkQnVmZmVyKEJ1ZmZlci5hbGxvYygwKSwgcm9vdCArIFwiL2FycmF5XCIpXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgemlwUmVjdXJzaXZlbHkoemlwRmlsZSwgb2JqW2ldLCByb290ICsgXCIvYXJyYXkvXCIgKyBpLCBkZXB0aCwgKGVycikgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjYWxsYmFjayhlcnIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSBpZiAob2JqICYmIHR5cGVvZiBvYmogPT09ICdvYmplY3QnKSB7XG4gICAgICAgICAgICBsZXQga2V5cyA9IE9iamVjdC5rZXlzKG9iaik7XG4gICAgICAgICAgICBpZiAoa2V5cy5sZW5ndGggPT09IDAgJiYgb2JqLmNvbnN0cnVjdG9yID09PSBPYmplY3QpIHtcbiAgICAgICAgICAgICAgICB6aXBGaWxlLmFkZEJ1ZmZlcihCdWZmZXIuYWxsb2MoMCksIHJvb3QgKyBcIi9vYmplY3RcIik7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGNvbnN0IGVuY29kZWRPYmogPSB7fTtcbiAgICAgICAgICAgICAgICBPYmplY3QuZW50cmllcyhvYmopLmZvckVhY2goKFtrZXksIHZhbHVlXSkgPT4ge1xuICAgICAgICAgICAgICAgICAgICBlbmNvZGVkT2JqW2VuY29kZVVSSUNvbXBvbmVudChrZXkpXSA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIG9iaiA9IGVuY29kZWRPYmo7XG4gICAgICAgICAgICAgICAga2V5cyA9IE9iamVjdC5rZXlzKG9iaik7XG4gICAgICAgICAgICAgICAga2V5cy5mb3JFYWNoKGtleSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIGxldCBlbnRyeU5hbWU7XG4gICAgICAgICAgICAgICAgICAgIGlmIChyb290ID09PSBcIlwiKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBlbnRyeU5hbWUgPSBrZXk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBlbnRyeU5hbWUgPSByb290ICsgXCIvXCIgKyBrZXk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgemlwUmVjdXJzaXZlbHkoemlwRmlsZSwgb2JqW2tleV0sIGVudHJ5TmFtZSwgZGVwdGggLSAxLCAoZXJyKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNhbGxiYWNrKGVycik7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdTaG91bGQgbmV2ZXIgcmVhY2ggdGhpcycpO1xuICAgICAgICB9XG4gICAgICAgIGNhbGxiYWNrKG51bGwpO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIGFkZFByb3BzUmVjdXJzaXZlbHkob2JqLCBzcGxpdE5hbWUsIHR5cGUsIGRhdGEpIHtcbiAgICAgICAgaWYgKHNwbGl0TmFtZS5sZW5ndGggPj0gMSkge1xuICAgICAgICAgICAgY29uc3QgcHJvcCA9IGRlY29kZVVSSUNvbXBvbmVudChzcGxpdE5hbWUuc2hpZnQoKSk7XG5cbiAgICAgICAgICAgIGlmIChzcGxpdE5hbWUubGVuZ3RoID09PSAwKSB7XG4gICAgICAgICAgICAgICAgc3dpdGNoICh0eXBlKSB7XG4gICAgICAgICAgICAgICAgICAgIGNhc2UgJ3VuZGVmaW5lZCc6XG4gICAgICAgICAgICAgICAgICAgICAgICBvYmpbcHJvcF0gPSB1bmRlZmluZWQ7XG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAnbnVsbCc6XG4gICAgICAgICAgICAgICAgICAgICAgICBvYmpbcHJvcF0gPSBudWxsO1xuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgICAgIGNhc2UgJ251bWJlcic6XG4gICAgICAgICAgICAgICAgICAgICAgICBvYmpbcHJvcF0gPSBwYXJzZUludChkYXRhLnRvU3RyaW5nKCkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgICAgIGNhc2UgJ3N0cmluZyc6XG4gICAgICAgICAgICAgICAgICAgICAgICBvYmpbcHJvcF0gPSBkYXRhLnRvU3RyaW5nKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAnc3RyZWFtJzpcbiAgICAgICAgICAgICAgICAgICAgICAgIG9ialtwcm9wXSA9IGJ1ZmZlclRvU3RyZWFtKGRhdGEpO1xuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgICAgIGNhc2UgJ2FycmF5JzpcbiAgICAgICAgICAgICAgICAgICAgICAgIG9ialtwcm9wXSA9IFtdO1xuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgICAgIGNhc2UgJ29iamVjdCc6XG4gICAgICAgICAgICAgICAgICAgICAgICBvYmpbcHJvcF0gPSB7fTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgICAgICBjYXNlICdzdHJpbmdpZnknOlxuICAgICAgICAgICAgICAgICAgICAgICAgb2JqW3Byb3BdID0gSlNPTi5wYXJzZShkYXRhLnRvU3RyaW5nKCkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ1Nob3VsZCBuZXZlciByZWFjaCB0aGlzJyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBpZiAoc3BsaXROYW1lWzBdID09PSAnYXJyYXknKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICghb2JqLmhhc093blByb3BlcnR5KHByb3ApKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBvYmpbcHJvcF0gPSBbXTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBzcGxpdE5hbWUuc2hpZnQoKTtcbiAgICAgICAgICAgICAgICAgICAgYWRkUHJvcHNSZWN1cnNpdmVseShvYmpbcHJvcF0sIHNwbGl0TmFtZSwgdHlwZSwgZGF0YSk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFvYmouaGFzT3duUHJvcGVydHkocHJvcCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIG9ialtwcm9wXSA9IHt9O1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGFkZFByb3BzUmVjdXJzaXZlbHkob2JqW3Byb3BdLCBzcGxpdE5hbWUsIHR5cGUsIGRhdGEpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuXG4gICAgZnVuY3Rpb24gYnVmZmVyVG9TdHJlYW0oYnVmZmV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XRQYXRoLCBmaWxlKSwgKGVyciwgc3RhdHMpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNhbGxiYWNrKGVycik7XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdHMuaXNEaXJlY3RvcnkoKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgLS10b3RhbDtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvdW50RmlsZXMocGF0aC5qb2luKGlucHV0UGF0aCwgZmlsZSksIChlcnIsIGZpbGVzTnVtYmVyKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FsbGJhY2soZXJyKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0b3RhbCArPSBmaWxlc051bWJlcjtcblxuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKC0tY291bnQgPT09IDApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2sodW5kZWZpbmVkLCB0b3RhbCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXN0YXRzLmlzRmlsZSgpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLS10b3RhbDtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKC0tY291bnQgPT09IDApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWxsYmFjayh1bmRlZmluZWQsIHRvdGFsKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfSlcbiAgICAgICAgfSk7XG4gICAgfSk7XG59XG5cbmZ1bmN0aW9uIGNvdW50WmlwRW50cmllcyhpbnB1dFBhdGgsIGNhbGxiYWNrKSB7XG4gICAgbGV0IHByb2Nlc3NlZCA9IDA7XG5cbiAgICB5YXV6bC5vcGVuKGlucHV0UGF0aCwge2xhenlFbnRyaWVzOiB0cnVlfSwgKGVyciwgemlwRmlsZSkgPT4ge1xuICAgICAgICBpZiAoZXJyKSB7XG4gICAgICAgICAgICByZXR1cm4gY2FsbGJhY2soZXJyKTtcbiAgICAgICAgfVxuXG4gICAgICAgIHppcEZpbGUucmVhZEVudHJ5KCk7XG4gICAgICAgIHppcEZpbGUub25jZShcImVuZFwiLCAoKSA9PiB7XG4gICAgICAgICAgICBjYWxsYmFjayhudWxsLCBwcm9jZXNzZWQpO1xuICAgICAgICB9KTtcblxuICAgICAgICB6aXBGaWxlLm9uKFwiZW50cnlcIiwgKGVudHJ5KSA9PiB7XG4gICAgICAgICAgICArK3Byb2Nlc3NlZDtcblxuICAgICAgICAgICAgemlwRmlsZS5yZWFkRW50cnkoKTtcbiAgICAgICAgfSk7XG4gICAgfSk7XG59XG5cbmZ1bmN0aW9uIGNvbXB1dGVTaXplKGlucHV0UGF0aCwgY2FsbGJhY2spIHtcbiAgICBsZXQgdG90YWxTaXplID0gMDtcbiAgICBmcy5zdGF0KGlucHV0UGF0aCwgKGVyciwgc3RhdHMpID0+IHtcbiAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgcmV0dXJuIGNhbGxiYWNrKGVycik7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoc3RhdHMuaXNGaWxlKCkpIHtcbiAgICAgICAgICAgIHJldHVybiBjYWxsYmFjayh1bmRlZmluZWQsIHN0YXRzLnNpemUpO1xuICAgICAgICB9XG5cbiAgICAgICAgZnMucmVhZGRpcihpbnB1dFBhdGgsIChlcnIsIGZpbGVzKSA9PiB7XG4gICAgICAgICAgICBpZiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGNhbGxiYWNrKGVycik7XG4gICAgICAgICAgICB9XG5cblxuICAgICAgICAgICAgbGV0IGNvdW50ID0gZmlsZXMubGVuZ3RoO1xuXG4gICAgICAgICAgICBpZiAoY291bnQgPT09IDApIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gY2FsbGJhY2sodW5kZWZpbmVkLCAwKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgZmlsZXMuZm9yRWFjaChmaWxlID0+IHtcbiAgICAgICAgICAgICAgICBmcy5zdGF0KHBhdGguam9pbihpbnB1dFBhdGgsIGZpbGUpLCAoZXJyLCBzdGF0cykgPT4ge1xuICAgICAgICAgICAgICAgICAgICBpZiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FsbGJhY2soZXJyKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIGlmIChzdGF0cy5pc0RpcmVjdG9yeSgpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb21wdXRlU2l6ZShwYXRoLmpvaW4oaW5wdXRQYXRoLCBmaWxlKSwgKGVyciwgZmlsZXNTaXplKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FsbGJhY2soZXJyKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0b3RhbFNpemUgKz0gZmlsZXNTaXplO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKC0tY291bnQgPT09IDApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2sodW5kZWZpbmVkLCB0b3RhbFNpemUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuXG4gICAgICAgICAgICAgICAgICAgICAgICB0b3RhbFNpemUgKz0gc3RhdHMuc2l6ZTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKC0tY291bnQgPT09IDApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWxsYmFjayh1bmRlZmluZWQsIHRvdGFsU2l6ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH0pXG4gICAgICAgIH0pO1xuICAgIH0pO1xufVxuXG5tb2R1bGUuZXhwb3J0cyA9IHtcbiAgICBjb3VudEZpbGVzLFxuICAgIGNvdW50WmlwRW50cmllcyxcbiAgICBjb21wdXRlU2l6ZVxufTtcbiIsImNvbnN0IGNyeXB0byA9IHJlcXVpcmUoJ2NyeXB0bycpO1xuY29uc3QgZnMgPSByZXF1aXJlKCdmcycpO1xuY29uc3QgcGF0aCA9IHJlcXVpcmUoXCJwYXRoXCIpO1xuY29uc3QgUHNrQXJjaGl2ZXIgPSByZXF1aXJlKFwiLi4vcHNrLWFyY2hpdmVyXCIpO1xuY29uc3QgYWxnb3JpdGhtID0gJ2Flcy0yNTYtZ2NtJztcblxuXG5jb25zdCBpdGVyYXRpb25zX251bWJlciA9IDEwMDA7XG5cbmZ1bmN0aW9uIGVuY29kZShidWZmZXIpIHtcblx0cmV0dXJuIGJ1ZmZlci50b1N0cmluZygnYmFzZTY0Jylcblx0XHQucmVwbGFjZSgvXFwrL2csICcnKVxuXHRcdC5yZXBsYWNlKC9cXC8vZywgJycpXG5cdFx0LnJlcGxhY2UoLz0rJC8sICcnKTtcbn1cblxuZnVuY3Rpb24gZGVsZXRlUmVjdXJzaXZlbHkoaW5wdXRQYXRo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YWs7XG4gICAgICAgIGNhc2UgXCJhcnJheVwiOlxuICAgICAgICAgICAgdmFyIHJlc3VsdCA9IFwiXCI7XG4gICAgICAgICAgICBmb3IodmFyIGk9MDsgaSA8IG9iai5sZW5ndGg7IGkrKyl7XG4gICAgICAgICAgICAgICAgcmVzdWx0ICs9IGV4cG9ydHMuZHVtcE9iamVjdEZvckhhc2hpbmcob2JqW2ldKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcIlR5cGUgXCIgKyAgdHlwZSArIFwiIGNhbm5vdCBiZSBjcnlwdG9ncmFwaGljYWxseSBkaWdlc3RlZFwiKTtcbiAgICB9XG5cbn1cblxuXG5leHBvcnRzLmR1bXBPYmplY3RGb3JIYXNoaW5nID0gZnVuY3Rpb24ob2JqKXtcbiAgICB2YXIgcmVzdWx0ID0gXCJcIjtcblxuICAgIGlmKG9iaiA9PT0gbnVsbCl7XG4gICAgICAgIHJldHVybiBcIm51bGxcIjtcbiAgICB9XG4gICAgaWYob2JqID09PSB1bmRlZmluZWQpe1xuICAgICAgICByZXR1cm4gXCJ1bmRlZmluZWRcIjtcbiAgICB9XG5cbiAgICB2YXIgYmFzaWNUeXBlcyA9IHtcbiAgICAgICAgXCJhcnJheVwiICAgICA6IHRydWUsXG4gICAgICAgIFwibnVtYmVyXCIgICAgOiB0cnVlLFxuICAgICAgICBcImJvb2xlYW5cIiAgIDogdHJ1ZSxcbiAgICAgICAgXCJzdHJpbmdcIiAgICA6IHRydWUsXG4gICAgICAgIFwib2JqZWN0XCIgICAgOiBmYWxzZVxuICAgIH1cblxuICAgIHZhciB0eXBlID0gQXJyYXkuaXNBcnJheShvYmopID8gXCJhcnJheVwiIDogdHlwZW9mIG9iajtcbiAgICBpZiggYmFzaWNUeXBlc1t0eXBlXSl7XG4gICAgICAgIHJld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Z2U6XCIsIG1zZyk7XG4gICAgICAgICAgICB0aHJvdyBlcnI7XG4gICAgICAgIH0sXG4gICAgICAgIGlnbm9yZVBvc3NpYmxlRXJyb3I6IGZ1bmN0aW9uKG5hbWUpe1xuICAgICAgICAgICAgY29uc29sZS5sb2cobmFtZSk7XG4gICAgICAgIH0sXG4gICAgICAgIHN5bnRheEVycm9yOmZ1bmN0aW9uKHByb3BlcnR5LCBzd2FybSwgdGV4dCl7XG4gICAgICAgICAgICAvL3Rocm93IG5ldyBFcnJvcihcIk1pc3NwZWxsZWQgbWVtYmVyIG5hbWUgb3Igb3RoZXIgaW50ZXJuYWwgZXJyb3IhXCIpO1xuICAgICAgICAgICAgdmFyIHN3YXJtTmFtZTtcbiAgICAgICAgICAgIHRyeXtcbiAgICAgICAgICAgICAgICBpZih0eXBlb2Ygc3dhcm0gPT0gXCJzdHJpbmdcIil7XG4gICAgICAgICAgICAgICAgICAgIHN3YXJtTmFtZSA9IHN3YXJtO1xuICAgICAgICAgICAgICAgIH0gZWxzZVxuICAgICAgICAgICAgICAgIGlmKHN3YXJtICYmIHN3YXJtLm1ldGEpe1xuICAgICAgICAgICAgICAgICAgICBzd2FybU5hbWUgID0gc3dhcm0ubWV0YS5zd2FybVR5cGVOYW1lO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHN3YXJtTmFtZSA9IHN3YXJtLmdldElubmVyVmFsdWUoKS5tZXRhLnN3YXJtVHlwZU5hbWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBjYXRjaChlcnIpe1xuICAgICAgICAgICAgICAgIHN3YXJtTmFtZSA9IGVyci50b1N0cmluZygpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYocHJvcGVydHkpe1xuICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKFwiV3JvbmcgbWVtYmVyIG5hbWUgXCIsIHByb3BlcnR5LCAgXCIgaW4gc3dhcm0gXCIsIHN3YXJtTmFtZSk7XG4gICAgICAgICAgICAgICAgaWYodGV4dCkge1xuICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyh0ZXh0KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKFwiVW5rbm93biBzd2FybVwiLCBzd2FybU5hbWUpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgIH0sXG4gICAgICAgIHdhcm5pbmc6ZnVuY3Rpb24obXNnKXtcbiAgICAgICAgICAgIGNvbnNvbGUubG9nKG1zZyk7XG4gICAgICAgIH1cbiAgICB9O1xuXG5cblxuJCQuc2FmZUVycm9ySGFuZGxpbmcgPSBmdW5jdGlvbihjYWxsYmFjayl7XG4gICAgICAgIGlmKGNhbGxiYWNrKXtcbiAgICAgICAgICAgIHJldHVybiBjYWxsYmFjaztcbiAgICAgICAgfSBlbHNle1xuICAgICAgICAgICAgcmV0dXJuIGRlZmF1bHRFcnJvckhhbmRsaW5nSW1wbGVtZW50YXRpb247XG4gICAgICAgIH1cbiAgICB9O1xuXG4kJC5fX2ludGVybiA9IHtcbiAgICAgICAgbWtBcmdzOmZ1bmN0aW9uKGFyZ3MscG9zKXtcbiAgICAgICAgICAgIHZhciBhcmdzQXJyYXkgPSBbXTtcbiAgICAgICAgICAgIGZvcih2YXIgaSA9IHBvczsgaSA8IGFyZ3MubGVuZ3RoOyBpKyspe1xuICAgICAgICAgICAgICAgIGFyZ3NBcnJheS5wdXNoKGFyZ3NbaV0pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGFyZ3NBcnJheTtcbiAgICAgICAgfVxuICAgIH07XG5cblxuXG52YXIgc3dhcm1VdGlscyA9IHJlcXVpcmUoXCIuL2xpYi9jaG9yZW9ncmFwaGllcy91dGlsaXR5RnVuY3Rpb25zL3N3YXJtXCIpO1xudmFyIGFzc2V0VXRpbHMgPSByZXF1aXJlKFwiLi9saWIvY2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gICAgICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHNvbHZlU3dhcm0oc3dhcm0pe1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkJC5zd2FybXNJbnN0YW5jZXNNYW5hZ2VyLnJldml2ZV9zd2FybShzd2FybSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJCQuUFNLX1B1YlN1Yi5zdWJzY3JpYmUobmFtZSwgc29sdmVTd2FybSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coXCJDcmVhdGluZyBhIGZha2UgZXhlY3V0aW9uIGNvbnRleHQuLi5cIik7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBkdW1teVZNKCQkLkNPTlNUQU5UUy5TV0FSTV9GT1JfRVhFQ1VUSU9OKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuXHRcdFx0XHR9O1xuIiwiaWYodHlwZW9mIHNpbmdsZXRvbl9jb250YWluZXJfbW9kdWxlX3dvcmthcm91bmRfZm9yX3dpcmVkX25vZGVfanNfY2FjaGluZyA9PSAndW5kZWZpbmVkJykge1xuICAgIHNpbmdsZXRvbl9jb250YWluZXJfbW9kdWxlX3dvcmthcm91bmRfZm9yX3dpcmVkX25vZGVfanNfY2FjaGluZyAgID0gbW9kdWxlO1xufSBlbHNlIHtcbiAgICBtb2R1bGUuZXhwb3J0cyA9IHNpbmdsZXRvbl9jb250YWluZXJfbW9kdWxlX3dvcmthcm91bmRfZm9yX3dpcmVkX25vZGVfanNfY2FjaGluZyAuZXhwb3J0cztcbiAgICByZXR1cm4gbW9kdWxlO1xufVxuXG4vKipcbiAqIENyZWF0ZWQgYnkgc2FsYm9haWUgb24gNC8yNy8xNS5cbiAqL1xuZnVuY3Rpb24gQ29udGFpbmVyKGVycm9ySGFuZGxlcil7XG4gICAgdmFyIHRoaW5ncyA9IHt9O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XRlbU5hbWUpe1xuICAgICAgICAgICAgdmFyIGwgPSByZXZlcnNlZFRyZWVbaXRlbU5hbWVdO1xuICAgICAgICAgICAgaWYoIWwpe1xuICAgICAgICAgICAgICAgIGwgPSByZXZlcnNlZFRyZWVbaXRlbU5hbWVdID0ge307XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBsW25vZGVOYW1lXSA9IG5vZGVOYW1lO1xuICAgICAgICB9KTtcbiAgICB9XG5cblxuICAgIGZ1bmN0aW9uIGRpc2NvdmVyVXBOb2Rlcyhub2RlTmFtZSl7XG4gICAgICAgIHZhciByZXMgPSB7fTtcblxuICAgICAgICBmdW5jdGlvbiBERlMobm4pe1xuICAgICAgICAgICAgdmFyIGwgPSByZXZlcnNlZFRyZWVbbm5dO1xuICAgICAgICAgICAgZm9yKHZhciBpIGluIGwpe1xuICAgICAgICAgICAgICAgIGlmKCFyZXNbaV0pe1xuICAgICAgICAgICAgICAgICAgICByZXNbaV0gPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICBERlMoaSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgREZTKG5vZGVOYW1lKTtcbiAgICAgICAgcmV0dXJuIE9iamVjdC5rZXlzKHJlcyk7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gcmVzZXRDb3VudGVyKG5hbWUpe1xuICAgICAgICB2YXIgZGVwZW5kZW5jeUFycmF5ID0gaW1tZWRpYXRlW25hbWVdO1xuICAgICAgICB2YXIgY291bnRlciA9IDA7XG4gICAgICAgIGlmKGRlcGVuZGVuY3lBcnJheSl7XG4gICAgICAgICAgICBkZXBlbmRlbmN5QXJyYXkuZm9yRWFjaChmdW5jdGlvbihkZXApe1xuICAgICAgICAgICAgICAgIGlmKHRoaW5nc1tkZXBdID09IG51bGwpe1xuICAgICAgICAgICAgICAgICAgICBpbmNDb3VudGVyKG5hbWUpO1xuICAgICAgICAgICAgICAgICAgICBjb3VudGVyK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lcyBub3QgZXhpc3RzIWA7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGxldCBzcmNTdGF0ID0gZnMubHN0YXRTeW5jKHNyYyk7XG4gICAgICAgICAgICBpZihzcmNTdGF0LmlzRGlyZWN0b3J5KCkpIHtcbiAgICAgICAgICAgICAgICBfX2NvcHlEaXIoc3JjLCBkZXN0LCBvcHRpb25zKTtcbiAgICAgICAgICAgIH0gZWxzZSBpZihzcmNTdGF0LmlzRmlsZSgpKSB7XG4gICAgICAgICAgICAgICAgLy8gZGVzdGluYXRpb24gbXVzdCBiZSBhIGZpbGUgdG9vXG4gICAgICAgICAgICAgICAgX19jb3B5RmlsZShzcmMsIGRlc3QsIG9wdGlvbnMpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgIGlmKHJldGhyb3cpe1xuICAgICAgICAgICAgICAgIHRocm93IGVycjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGxvZyhlcnIsIHRydWUpO1xuICAgICAgICAgICAgY2FsbGJhY2soZXJyKTtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuXG4gICAgICAgIGNhbGxiYWNrKCk7XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogQ29weSBhIGRpcmVjdG9yeS4gVGhlIGRpcmVjdG9yeSBjYW4gaGF2ZSByZWN1cnNpdmUgY29udGVudHMuIExpa2UgY29weSAtci5cbiAgICAgKiBOT1RFOiBJdHQgd2lsbCBjb3B5IGV2ZXJ5dGhpbmcgaW5zaWRlIG9mIHRoZSBkaXJlY3RvcnksIG5vdCB0aGUgZW50aXJlIGRpcmVjdG9yeSBpdHNlbGYuXG4gICAgICogTk9URTogSWYgdGhlIGRlc3RpbmF0aW9uIHBhdGggc3RydWN0dXJlIGRvZXMgbm90IGV4aXN0cywgaXQgd2lsbCBiZSBjcmVhdGVkLlxuICAgICAqIEBwYXJhbSBzcmMge1N0cmluZ30gU291cmNl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mdldCh2YWx1ZSk7XG5cbiAgICAgICAgICAgIGlmICh0eXBlb2YgbmV4dEtleSA9PT0gJ3VuZGVmaW5lZCcpIHsgLy8gaWYgdmFsdWUgbm90IGZvdW5kIGluIHJ1bGVzTWFwXG4gICAgICAgICAgICAgICAgcnVsZXNNYXAuc2V0KHZhbHVlLCBuZXcgTWFwKCkpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICByZWdpc3RlclJlY3Vyc2l2ZVJ1bGUocnVsZXNNYXAuZ2V0KHZhbHVlKSwga2V5c0dlbmVyYXRvciwgZm4pO1xuICAgICAgICB9IGVsc2UgeyAvLyByZWFjaGVkIGxlYWYgbm9kZVxuICAgICAgICAgICAgaWYgKCFydWxlc01hcC5oYXModmFsdWUpKSB7XG5cbiAgICAgICAgICAgICAgICBydWxlc01hcC5zZXQodmFsdWUsIG5ldyBTZXQoW2ZuXSkpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBjb25zdCBzZXQgPSBydWxlc01hcC5nZXQodmFsdWUpO1xuXG4gICAgICAgICAgICAgICAgaWYgKHNldC5oYXMoZm4pKSB7XG4gICAgICAgICAgICAgICAgICAgIF93YXJuaW5nKGBEdXBsaWNhdGVkIGludGVyY2VwdG9yIGZvciAnJHtrZXl9J2ApO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIHNldC5hZGQoZm4pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogUmV0dXJucyB0aGUgY29ycmVzcG9uZGluZyBzZXQgb2YgZnVuY3Rpb25zIGZvciB0aGUgZ2l2ZW4ga2V5IGlmIGZvdW5kXG4gICAgICogQHBhcmFtIHtzdHJpbmd9IGtleSAtIGZvcm1hdHRlZCBhcyBhIHBhdGggd2l0aG91dCB0aGUgZmlyc3QgJy8nIChleDogc3dhcm1UeXBlL3N3YXJtUGhhc2UvYmVmb3JlKVxuICAgICAqIEByZX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mFjaywgc3dhcm0sIGtlZXBBbGl2ZUNoZWNrKXtcblxuICAgICAgICBmdW5jdGlvbiBkb0xvZ2ljKCl7XG4gICAgICAgICAgICB2YXIgc3dhcm1JZCA9IHN3YXJtLmdldElubmVyVmFsdWUoKS5tZXRhLnN3YXJtSWQ7XG4gICAgICAgICAgICB2YXIgd2F0Y2hlciA9IHN3YXJtQWxpdmVJbnN0YW5jZXNbc3dhcm1JZF07XG4gICAgICAgICAgICBpZighd2F0Y2hlcil7XG4gICAgICAgICAgICAgICAgd2F0Y2hlciA9IHtcbiAgICAgICAgICAgICAgICAgICAgc3dhcm06c3dhcm0sXG4gICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrOmNhbGxiYWNrLFxuICAgICAgICAgICAgICAgICAgICBrZWVwQWxpdmVDaGVjazprZWVwQWxpdmVDaGVja1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBzd2FybUFsaXZlSW5zdGFuY2VzW3N3YXJtSWRdID0gd2F0Y2hlcjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGZ1bmN0aW9uIGZpbHRlcigpe1xuICAgICAgICAgICAgcmV0dXJuIHN3YXJtLmdldElubmVyVmFsdWUoKS5tZXRhLnN3YXJtSWQ7XG4gICAgICAgIH1cblxuICAgICAgICAvLyQkLnVpZEdlbmVyYXRvci53YWl0X2Zvcl9jb25kaXRpb24oY29uZGl0aW9uLGRvTG9naWMpO1xuICAgICAgICBzd2FybS5vYnNlcnZlKGRvTG9naWMsIG51bGwsIGZpbHRlcik7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gY2xlYW5Td2FybVdhaXRlcihzd2FybVNlcmlhbGlzYXRpb24peyAvLyBUT0RPOiBhZGQgYmV0dGVyIG1lY2hhbmlzbXMgdG8gcHJldmVudCBtZW1vcnkgbGVha3NcbiAgICAgICAgdmFyIHN3YXJtSWQgPSBzd2FybVNlcmlhbGlzYXRpb24ubWV0YS5zd2FybUlkO1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wcmVmaXhOYW1lKXtcbiAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKC4uLmFyZ3Mpe1xuICAgICAgICAgICAgLy9jb25zb2xlLmxvZyhcInByZWZpeE5hbWVcIiwgcHJlZml4TmFtZSlcbiAgICAgICAgICAgIHZhciBwcmV2aW91c1ByZWZpeCA9ICQkLmxpYnJhcnlQcmVmaXg7XG4gICAgICAgICAgICB2YXIgcHJldmlvdXNMaWJyYXJ5ID0gJCQuX19nbG9iYWwuY3VycmVudExpYnJhcnk7XG5cbiAgICAgICAgICAgICQkLmxpYnJhcnlQcmVmaXggPSBwcmVmaXhOYW1lO1xuICAgICAgICAgICAgJCQuX19nbG9iYWwuY3VycmVudExpYnJhcnkgPSBzZWxmO1xuICAgICAgICAgICAgdHJ5e1xuICAgICAgICAgICAgICAgIHZhciByZXQgPSBvcmlnaW5hbC5hcHBseSh0aGlzLCBhcmdzKTtcbiAgICAgICAgICAgICAgICAkJC5saWJyYXJ5UHJlZml4ID0gcHJldmlvdXNQcmVmaXggO1xuICAgICAgICAgICAgICAgICQkLl9fZ2xvYmFsLmN1cnJlbnRMaWJyYXJ5ID0gcHJldmlvdXNMaWJyYXJ5O1xuICAgICAgICAgICAgfWNhdGNoKGVycil7XG4gICAgICAgICAgICAgICAgJCQubGlicmFyeVByZWZpeCA9IHByZXZpb3VzUHJlZml4IDtcbiAgICAgICAgICAgICAgICAkJC5fX2dsb2JhbC5jdXJyZW50TGlicmFyeSA9IHByZXZpb3VzTGlicmFyeTtcbiAgICAgICAgICAgICAgICB0aHJvdyBlcnI7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gcmV0O1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgJCQubGlicmFyaWVzW3ByZWZpeE5hbWVdID0gdGhpcztcbiAgICB2YXIgcHJlZml4ZWRSZXF1aXJlID0gd3JhcENhbGwoZnVuY3Rpb24ocGF0aCl7XG4gICAgICAgIHJldHVybiByZXF1aXJlKHBhdGgpO1x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gdGhpcztcblxuICAgICAgICAgICAgLy8gY29uc29sZS5sb2coJ3RyeWluZyB0byBsb2FkICcsIHJlcXVlc3QpO1xuXG4gICAgICAgICAgICBmdW5jdGlvbiB0cnlCdW5kbGVSZXF1aXJlKC4uLmFyZ3MpIHtcbiAgICAgICAgICAgICAgICAvL3JldHVybiAkJC5fX29yaWdpbmFsUmVxdWlyZS5hcHBseShzZWxmLGFyZ3MpO1xuICAgICAgICAgICAgICAgIC8vcmV0dXJuIE1vZHVsZS5fbG9hZC5hcHBseShzZWxmLGFyZ3MpXG4gICAgICAgICAgICAgICAgbGV0IHJlcztcbiAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICByZXMgPSBzYW5kYm94UmVxdWlyZS5hcHBseShzZWxmLCBhcmdzKTtcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGVyci5jb2RlID09PSBcIk1PRFVMRV9OT1RfRk9VTkRcIikge1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcCA9IHBhdGguam9pbihwcm9jZXNzLmN3ZCgpLCByZXF1ZXN0KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlcyA9IHNhbmRib3hSZXF1aXJlLmFwcGx5KHNlbGYsIFtwXSk7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0ID0gcDtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IGVycjtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm4gcmVzO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBsZXQgcmVzO1xuXG5cbiAgICAgICAgICAgIHJlcyA9IHRyeVJlcXVpcmVTZXF1ZW5jZSh0cnlCdW5kbGVSZXF1aXJlLCByZXF1ZXN0KTtcblxuXG4gICAgICAgIC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ICAgICAgICAgICAgICAvL3JldHVybiBNb2R1bGUuX2xvYWQuYXBwbHkoc2VsZixhcmdzKVxuICAgICAgICAgICAgICAgIGxldCByZXM7XG4gICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgcmVzID0gbW9kdWxlT3JpZ2luYWxSZXF1aXJlLmFwcGx5KHNlbGYsIGFyZ3MpO1xuICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgICAgICAgICBpZiAoZXJyLmNvZGUgPT09IFwiTU9EVUxFX05PVF9GT1VORFwiKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwID0gcGF0aC5qb2luKHByb2Nlc3MuY3dkKCksIHJlcXVlc3QpO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmVzID0gbW9kdWxlT3JpZ2luYWxSZXF1aXJlLmFwcGx5KHNlbGYsIFtwXSk7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0ID0gcDtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IGVycjtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm4gcmVzO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBmdW5jdGlvbiBjdXJyZW50Rm9sZGVyUmVxdWlyZShyZXF1ZXN0KSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuXG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIC8vW3JlcXVpcmVGcm9tQ2FjaGUsIHdyYXBTdGVwKHBza3J1bnRpbWVSZXF1aXJlKSwgd3JhcFN0ZXAoZG9tYWluUmVxdWlyZSksIG9yaWdpbmFsUmVxdWlyZV1cbiAgICAgICAgICAgIHJldHVybiB0cnlSZXF1aXJlU2VxdWVuY2Uob3JpZ2luYWxSZXF1aXJlLCByZXF1ZXN0KTtcbiAgICAgICAgfVxuXG4gICAgICAgIE1vZHVsZS5wcm90b3R5cGUucmVxdWlyZSA9IG5ld0xvYWRlcjtcbiAgICB9XG5cbiAgICAkJC5yZXF1aXJlID0gcmVxdWlyZTtcbn1cbiIsIlxudmFyIGpvaW5Db3VudGVyID0gMDtcblxuZnVuY3Rpb24gUGFyYWxsZWxKb2luUG9pbnQoc3dhcm0sIGNhbGxiYWNrLCBhcmdzKXtcbiAgICBqb2luQ291bnRlcisrO1xuICAgIHZhciBjaGFubmVsSWQgPSBcIlBhcmFsbGVsSm9pblBvaW50XCIgKyBqb2luQ291bnRlcjtcbiAgICB2YXIgc2VsZiA9IHRoaXM7XG4gICAgdmFyIGNvdW50ZXIgPSAwO1xuICAgIHZhciBzdG9wT3RoZXJFeGVjdXRpb24gICAgID0gZmFsc2U7XG5cbiAgICBmdW5jdGlvbiBleGVjdXRpb25TdGVwKHN0ZXBGdW5jLCBsb2NhbEFyZ3MsIHN0b3Ape1xuXG4gICAgICAgIHRoaXMuZG9FeGVjdXRlID0gZnVuY3Rpb24oKXtcbiAgICAgICAgICAgIGlmKHN0b3BPdGhlckV4ZWN1dGlvbil7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdHJ5e1xuICAgICAgICAgICAgICAgIHN0ZXBGdW5jLmFwcGx5KHN3YXJtLCBsb2NhbEFyZ3MpO1xuICAgICAgICAgICAgICAgIGlmKHN0b3Ape1xuICAgICAgICAgICAgICAgICAgICBzdG9wT3RoZXJFeGVjdXRpb24gPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOyAvL2V2ZXJ5dGluZyBpcyBmaW5lXG4gICAgICAgICAgICB9IGNhdGNoKGVycil7XG4gICAgICAgICAgICAgICAgYXJncy51bnNoaWZ0KGVycik7XG4gICAgICAgICAgICA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bGFubmVkQXJndW1lbnRzW2V4ZWN1dGlvbkNvdW50ZXJdICkgIHtcbiAgICAgICAgICAgICAgICAkJC5QU0tfUHViU3ViLnB1Ymxpc2goY2hhbm5lbElkLCBzZWxmKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIHZhciBmID0gZnVuY3Rpb24gKC4uLmFyZ3Mpe1xuICAgICAgICAgICAgaWYoZXhlY3V0aW9uQ291bnRlciAhPSBwb3MpIHtcbiAgICAgICAgICAgICAgICBwbGFubmVkQXJndW1lbnRzW3Bvc10gPSBhcmdzO1xuICAgICAgICAgICAgICAgIC8vY29uc29sZS5sb2coXCJEZWxheWluZyBmdW5jdGlvbjpcIiwgZXhlY3V0aW9uQ291bnRlciwgcG9zLCBwbGFubmVkQXJndW1lbnRzLCBhcmd1bWVudHMsIGZ1bmN0aW9uQ291bnRlcik7XG4gICAgICAgICAgICAgICAgcmV0dXJuIF9fcHJveHk7XG4gICAgICAgICAgICB9IGVsc2V7XG4gICAgICAgICAgICAgICAgaWYocGxhbm5lZEFyZ3VtZW50c1twb3NdKXtcbiAgICAgICAgICAgICAgICAgICAgLy9jb25zb2xlLmxvZyhcIkV4ZWN1dGluZyAgZnVuY3Rpb246XCIsIGV4ZWN1dGlvbkNvdW50ZXIsIHBvcywgcGxhbm5lZEFyZ3VtZW50cywgYXJndW1lbnRzLCBmdW5jdGlvbkNvdW50ZXIpO1xuXHRcdFx0XHRcdGFyZ3MgPSBwbGFubmVkQXJndW1lbnRzW3Bvc107XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgcGxhbm5lZEFyZ3VtZW50c1twb3NdID0gYXJncztcbiAgICAgICAgICAgICAgICAgICAgdHJpZ2dldE5leHRTdGVwKCk7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBfX3Byb3h5O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdmFyIGYgPSBkZWZhdWx0UHJvZ3Jlc3NSZXBvcnQ7XG4gICAgICAgICAgICBpZihuYW1lICE9IFwicHJvZ3Jlc3NcIil7XG4gICAgICAgICAgICAgICAgZiA9IGlubmVyLm15RnVuY3Rpb25zW25hbWVdO1xuICAgICAgICAgICAgfVxuXG5cbiAgICAgICAgICAgIHRyeXtcbiAgICAgICAgICAgICAgICBmLmFwcGx5KHNlbGYsYXJncyk7XG4gICAgICAgICAgICB9IGNhdGNoKGVycil7XG4gICAgICAgICAgICAgICAgICAgIGFyZ3MudW5zaGlmdChlcnIpO1xuICAgICAgICAgICAgICAgICAgICBjYWxsYmFjay5hcHBseShzd2FybSxhcmdzKTsgLy9lcnJvclxuICAgICAgICAgICAgICAgICAgICAkJC5QU0tfUHViU3ViLnVuc3Vic2NyaWJlKGNoYW5uZWxJZCxydW5OZXh0RnVuY3Rpb24pO1xuICAgICAgICAgICAgICAgIHJldHVybjsgLy90ZXJtaW5hdGUgZXhlY3V0aW9uIHdpdGggYW4gZXJyb3IuLi4hXG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBleGVjdXRpb25Db3VudGVyKys7XG5cbiAgICAgICAgICAgIHRyaWdnZXROZXh0U3RlcCgpO1xuXG4gICAgICAgICAgICByZXR1cm4gX19wcm94eTtcbiAgICAgICAgfTtcblxuICAgICAgICBwbGFubmVkRXhlY3V0aW9ucy5wdXNoKGYpO1xuICAgICAgICBmdW5jdGlvbkNvdW50ZXIrKztcbiAgICAgICAgcmV0dXJuIGY7XG4gICAgfVxuXG4gICAgIHZhciBmaW5pc2hlZCA9IGZhbHNlO1xuXG4gICAgZnVuY3Rpb24gcnVuTmV4dEZ1bmN0aW9uKCl7XG4gICAgICAgIGlmKGV4ZWN1dGlvbkNvdW50ZXIgPT0gcGxhbm5lZEV4ZWN1dGlvbnMubGVuZ3RoICl7XG4gICAgICAgICAgICBpZighZmluaXNoZWQpe1xuICAgICAgICAgICAgICAgIGFyZ3MudW5zaGlmdChudWxsKTtcbiAgIC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AgICAgICAgIHRocm93IGVycjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIHJldDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIC8vZHluYW1pYyBuYW1lZCBmdW5jIGluIG9yZGVyIHRvIGltcHJvdmUgY2FsbHN0YWNrXG4gICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkocGhhc2UsIFwibmFtZVwiLCB7Z2V0OiBmdW5jdGlvbigpe3JldHVybiBzd2FybVR5cGVOYW1lK1wiLlwiK2Z1bmMubmFtZX19KTtcbiAgICAgICAgICAgIHJldHVybiBwaGFzZTtcbiAgICAgICAgfVxuXG4gICAgICAgIHRoaXMuaW5pdGlhbGlzZSA9IGZ1bmN0aW9uKHNlcmlhbGlzZWRWYWx1ZXMpe1xuXG4gICAgICAgICAgICB2YXIgcmVzdWx0ID0gbmV3IE93TSh7XG4gICAgICAgICAgICAgICAgcHVibGljVmFyczp7XG5cbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHByaXZhdGVWYXJzOntcblxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgcHJvdGVjdGVkVmFyczp7XG5cbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIG15RnVuY3Rpb25zOntcblxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgdXRpbGl0eUZ1bmN0aW9uczp7XG5cbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIG1ldGE6e1xuICAgICAgICAgICAgICAgICAgICBzd2FybVR5cGVOYW1lOnN3YXJtVHlwZU5hbWUsXG4gICAgICAgICAgICAgICAgICAgIHN3YXJtRGVzY3JpcHRpb246ZGVzY3JpcHRpb25cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcblxuXG4gICAgICAgICAgICBmb3IodmFyIHYgaW4gcHVibGljVmFycyl7XG4gICAgICAgICAgICAgICAgcmVzdWx0LnB1YmxpY1ZhcnNbdl0gPSBwdWJsaWNWYXJzW3ZdLmluaXQoKTtcbiAgICAgICAgICAgIH07XG5cbiAgICAgICAgICAgIGZvcih2YXIgdiBpbiBwcml2YXRlVmFycyl7XG4gICAgICAgICAgICAgICAgcmVzdWx0LnByaXZhdGVWYXJzW3ZdID0gcHJpdmF0ZVZhcnNbdl0uaW5pdCgpO1xuICAgICAgICAgICAgfTtcblxuXG4gICAgICAgICAgICBpZihzZXJpYWxpc2VkVmFsdWVzKXtcbiAgICAgICAgICAgICAgICBiZWVzSGVhbGVyLmpzb25Ub05hdGl2ZShzZXJpYWxpc2VkVmFsdWVzLCByZXN1bHQpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICAgICAgfTtcblxuICAgICAgICB0aGlzLmluaXRpYWxpc2VGdW5jdGlvbnMgPSBmdW5jdGlvbih2YWx1ZU9iamVjdCwgdGhpc09iamVjdCl7XG5cbiAgICAgICAgICAgIGZvcih2YXIgdiBpbiBteUZ1bmN0aW9ucyl7XG4gICAgICAgICAgICAgICAgdmFsdWVPYmplY3QubXlGdW5jdGlvbnNbdl0gPSBjcmVhdGVQaGFzZSh0aGlzT2JqZWN0LCBteUZ1bmN0aW9uc1t2XSwgdik7XG4gICAgICAgICAgICB9O1xuXG4gICAgICAgICAgICBsb2NhbElkKys7XG4gICAgICAgICAgICB2YWx1ZU9iamVjdC51dGlsaXR5RnVuY3Rpb25zID0gdXRpbHMuY3JlYXRlRm9yT2JqZWN0KHZhbHVlT2JqZWN0LCB0aGlzT2JqZWN0LCBsb2NhbElkKTtcblxuICAgICAgICB9XG5cbiAgICAgICAgdGhpcy5nZXQgPSBmdW5jdGlvbih0YXJnZXQsIHByb3BlcnR5LCByZWNlaXZlcil7XG5cblxuICAgICAgICAgICAgaWYocHVibGljVmFycy5oYXNPd25Qcm9wZXJ0eShwcm9wZXJ0eSkpXG4gICAgICAgICAgICB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRhcmdldC5wdWJsaWNWYXJzW3Byb3BlcnR5XTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYocHJpdmF0ZVZhcnMuaGFzT3duUHJvcGVydHkocHJvcGVydHkpKVxuICAgICAgICAgICAge1xuICAgICAgICAgICAgICAgIHJldHVybiB0YXJnZXQucHJpdmF0ZVZhcnNbcHJvcGVydHldO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZih0YXJnZXQudXRpbGl0eUZ1bmN0aW9ucy5oYXNPd25Qcm9wZXJ0eShwcm9wZXJ0eSkpXG4gICAgICAgICAgICB7XG5cbiAgICAgICAgICAgICAgICByZXR1cm4gdGFyZ2V0LnV0aWxpdHlGdW5jdGlvbnNbcHJvcGVydHldO1xuICAgICAgICAgICAgfVxuXG5cbiAgICAgICAgICAgIGlmKG15RnVuY3Rpb25zLmhhc093blByb3BlcnR5KHByb3BlcnR5KSlcbiAgICAgICAgICAgIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gdGFyZ2V0Lm15RnVuY3Rpb25zW3Byb3BlcnR5XTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYodGFyZ2V0LnByb3RlY3RlZFZhcnMuaGFzT3duUHJvcGVydHkocHJvcGVydHkpKVxuICAgICAgICAgICAge1xuICAgICAgICAgICAgICAgIHJldHVybiB0YXJnZXQucHJvdGVjdGVkVmFyc1twcm9wZXJ0eV07XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmKHR5cGVvZiBwcm9wZXJ0eSAhPSBcInN5bWJvbFwiKSB7XG4gICAgICAgICAgICAgICAgJCQuZXJyb3JIYW5kbGVyLnN5bnRheEVycm9yKHByb3BlcnR5LCB0YXJnZXQpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIHVuZGVmaW5lZDtcbiAgICAgICAgfVxuXG4gICAgICAgIHRoaXMuc2V0ID0gZnVuY3Rpb24odGFyZ2V0LCBwcm9wZXJ0eSwgdmFsdWUsIHJlY2VpdmVyKXtcblxuICAgICAgICAgICAgaWYodGFyZ2V0LnV0aWxpdHlGdW5jdGlvbnMuaGFzT3duUHJvcGVydHkocHJvcGVydHkpIHx8IHRhcmdldC5teUZ1bmN0aW9ucy5oYXNPd25Qcm9wZXJ0eShwcm9wZXJ0eSkpIHtcbiAgICAgICAgICAgICAgICAkJC5lcnJvckhhbmRsZXIuc3ludGF4RXJyb3IocHJvcGVydHkpO1xuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcIlRyeWluZyB0byBvdmVyd3JpdGUgaW1tdXRhYmxlIG1lbWJlclwiICsgcHJvcGVydHkpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZihwcml2YXRlVmFycy5oYXNPd25Qcm9wZXJ0eShwcm9wZXJ0eSkpXG4gICAgICAgICAgICB7XG4gICAgICAgICAgICAgICAgdGFyZ2V0LnByaXZhdGVWYXJzW3Byb3BlcnR5XSA9IHZhbHVlO1xuICAgICAgICAgICAgfSBlbHNlXG4gICAgICAgICAgICBpZihwdWJsaWNWYXJzLmhhc093blByb3BlcnR5KHByb3BlcnR5KSlcbiAgICAgICAgICAgIHtcbiAgICAgICAgICAgICAgICB0YXJnZXQucHVibGljVmFyc1twcm9wZXJ0eV0gPSB2YWx1ZTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGFyZ2V0LnByb3RlY3RlZFZhcnNbcHJvcGVydHldID0gdmFsdWU7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgfVxuXG4gICAgICAgIHRoaXMuYXBwbHkgPSBmdW5jdGlvbih0YXJnZXQsIHRoaXNBcmcsIGFyZ3VtZW50c0xpc3Qpe1xuICAgICAgICAgICAgY29uc29sZS5sb2coXCJQcm94eSBhcHBseVwiKTtcbiAgICAgICAgICAgIC8vdmFyIGZ1bmMgPSB0YXJnZXRbXVx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9mIHYxID09PSBcIm9iamVjdFwiKXtcbiAgICAgICAgICAgIHNmLmV4Y2VwdGlvbnMuYXNzZXJ0RmFpbChleHBsYW5hdGlvbik7XG4gICAgICAgIH1cbiAgICB9KTtcblxuICAgIC8qKlxuICAgICAqIENoZWNrcyBpZiBhbGwgcHJvcGVydGllcyBvZiB0aGUgc2Vjb25kIG9iamVjdCBhcmUgb3duIHByb3BlcnRpZXMgb2YgdGhlIGZpcnN0IG9iamVjdC5cbiAgICAgKiBAcGFyYW0gZmlyc3RPYmoge09iamVjdH0gLSBmaXJzdCBvYmplY3RcbiAgICAgKiBAcGFyYW0gc2Vjb25kT2Jqe09iamVjdH0gLSBzZWNvbmQgb2JqZWN0XG4gICAgICogQHJldHVybnMge2Jvb2xlYW59IC0gcmV0dXJucyB0cnVlLCBpZiB0aGUgY2hlY2sgaGFzIHBhc3NlZCBvciBmYWxzZSBvdGhlcndpc2UuXG4gICAgICovXG4gICAgZnVuY3Rpb24gb2JqZWN0SGFzRmllbGRzKGZpcnN0T2JqLCBzZWNvbmRPYmope1xuICAgICAgICBmb3IobGV0IGZpZWxkIGluIHNlY29uZE9iaikge1xuICAgICAgICAgICAgaWYgKGZpcnN0T2JqLmhhc093blByb3BlcnR5KGZpZWxkKSkge1xuICAgICAgICAgICAgICAgIGlmIChmaXJzdE9ialtmaWVsZF0gIT09IHNlY29uZE9ialtmaWVsZF0pIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2V7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0cnVlO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIG9iamVjdHNBcmVFcXVhbChmaXJzdE9iaiwgc2Vjb25kT2JqKSB7XG4gICAgICAgIGxldCBhcmVFcXVhbCA9IHRydW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AgICAgICAgIGZ1bmMoKTtcbiAgICAgICAgICAgIGNvbnNvbGUubG9nKFwiW0ZhaWxdIFwiICsgdGVzdE5hbWUgKTtcbiAgICAgICAgfSBjYXRjaChlcnIpe1xuICAgICAgICAgICAgY29uc29sZS5sb2coXCJbUGFzc10gXCIgKyB0ZXN0TmFtZSApO1xuICAgICAgICB9XG4gICAgfSk7XG5cblxuICAgIHNmLmNoZWNrLmFkZENoZWNrKCdwYXNzJywgZnVuY3Rpb24odGVzdE5hbWUgLGZ1bmMpe1xuICAgICAgICB0cnl7XG4gICAgICAgICAgICBmdW5jKCk7XG4gICAgICAgICAgICBjb25zb2xlLmxvZyhcIltQYXNzXSBcIiArIHRlc3ROYW1lICk7XG4gICAgICAgIH0gY2F0Y2goZXJyKXtcbiAgICAgICAgICAgIGNvbnNvbGUubG9nKFwiW0ZhaWxdIFwiICsgdGVzdE5hbWUgICwgIGVyci5zdGFjayk7XG4gICAgICAgIH1cbiAgICB9KTtcblxuXG4gICAgc2YuY2hlY2suYWxpYXMoJ3Rlc3QnLCdwYXNzJyk7XG5cblxuICAgIHNmLmNoZWNrLmFkZENoZWNrKCdjYWxsYmFjaycsIGZ1bmN0aW9uKHRlc3ROYW1lICxmdW5jLCB0aW1lb3V0KXtcbiAgICAgICAgaWYoIXRpbWVvdXQpe1xuICAgICAgICAgICAgdGltZW91dCA9IDUwMDtcbiAgICAgICAgfVxuICAgICAgICB2YXIgcGFzc2VkID0gZmFsc2U7XG4gICAgICAgIGZ1bmN0aW9uIGNhbGxiYWNrKCl7XG4gICAgICAgICAgICBpZighcGFzc2VkKXtcbiAgICAgICAgICAgICAgICBwYXNzZWQgPSB0cnVlO1xuICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKFwiW1Bhc3NdIFwiICsgdGVzdE5hbWUgKTtcbiAgICAgICAgICAgICAgICBTdWNjZXNzVGVzdCgpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhcIltGYWlsIChtdWx0aXBsZSBjYWxscyldIFwiICsgdGVzdE5hbWUgKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICB0cnl7XG4gICAgICAgICAgICBmdW5jKGNhbGxiYWNrKTtcbiAgICAgICAgfSBjYXRjaChlcnIpe1xuICAgICAgICAgICAgY29uc29sZS5sb2coXCJbRmFpbF0gXCIgKyB0ZXN0TmFtZSAgLCAgZXJyLnN0YWNrKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGZ1bmN0aW9uIFN1Y2Nlc3NUZXN0KGZvcmNlKXtcbiAgICAgICAgICAgIGlmKCFwYXNzZWQpe1xuICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKFwiW0ZhaWwgVGltZW91dF0gXCIgKyB0ZXN0TmFtZSApO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgc2V0VGltZW91dChTdWNjZXNzVGVzdCwgdGltZW91dCk7XG4gICAgfSk7XG5cblxuICAgIHNmLmNoZWNrLmFkZENoZWNrKCdzdGVwcycsIGZ1bmN0aW9uKHRlc3ROYW1lICwgYXJyLCB0aW1lb3V0KXtcbiAgICAgICAgdmFyICBjdXJyZW50U3RlcCA9IDA7XG4gICAgICAgIHZhciBwYXNzZWQgPSBmYWxzZTtcbiAgICAgICAgaWYoIXRpbWVvdXQpe1xuICAgICAgICAgICAgdGltZW91dCA9IDUwMDtcbiAgICAgICAgfVxuXG4gICAgICAgIGZ1bmN0aW9uIG5leHQoKXtcbiAgICAgICAgICAgIGlmKGN1cnJlbnRTdGVwID09PSBhcnIubGVuZ3RoKXtcbiAgICAgICAgICAgICAgICBwYXNzZWQgPSB0cnVlO1xuICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKFwiW1Bhc3NdIFwiICsgdGVzdE5hbWUgKTtcbiAgICAgICAgICAgICAgICByZXR1cm4gO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIGZ1bmMgPSBhcnJbY3Vycm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ByZXQuZXhjZXB0aW9uID0gZXhjZXB0aW9uLm1lc3NhZ2U7XG4gICAgICAgIH1cblxuICAgICAgICBpZihhcmdzKXtcbiAgICAgICAgICAgIHJldC5hcmdzID0gSlNPTi5wYXJzZShKU09OLnN0cmluZ2lmeShhcmdzKSk7XG4gICAgICAgIH1cblxuICAgICAgICBpZihwcm9jZXNzLmVudi5SVU5fV0lUSF9XSFlTKXtcbiAgICAgICAgICAgIHZhciB3aHkgPSByZXF1aXJlKCd3aHlzJyk7XG4gICAgICAgICAgICBpZihsb2dPbmx5Q3VycmVudFdoeUNvbnRleHQpIHtcbiAgICAgICAgICAgICAgICByZXRbJ3doeUxvZyddID0gd2h5LmdldEdsb2JhbEN1cnJlbnRDb250ZXh0KCkuZ2V0RXhlY3V0aW9uU3VtbWFyeSgpO1xuICAgICAgICAgICAgfWVsc2V7XG4gICAgICAgICAgICAgICAgcmV0Wyd3aHlMb2cnXSA9IHdoeS5nZXRBbGxDb250ZXh0cygpLm1hcChmdW5jdGlvbiAoY29udGV4dCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gY29udGV4dC5nZXRFeGVjdXRpb25TdW1tYXJ5KCk7XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gcmV0O1xuICAgIH1cblxufTtcblxuIiwiY29uc3QgZnMgPSByZXF1aXJlKFwiZnNcIik7XG5jb25zdCBwYXRoID0gcmVxdWlyZShcInBhdGhcIik7XG5jb25zdCBmb3JrZXIgPSByZXF1aXJlKCdjaGlsZF9wcm9jZXNzJyk7XG5cbmNvbnN0IERFRkFVTFRfVElNRU9VVCA9IDIwMDA7XG5cbnZhciBnbG9iVG9SZWdFeHAgPSAgcmVxdWlyZShcIi4vdXRpbHMvZ2xvYi10by1yZWdleHBcIik7XG5cbnZhciBkZWZhdWx0Q29uZmlnID0ge1xuICAgIGNvbmZGaWxlTmFtZTogXCJkb3VibGUtY2hlY2suanN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ICAgICAgICAgICAgLy8gd3JhcHBlciBmb3IgcHJvdmlkZWQgY2FsbGJhY2ssIGlmIGFueVxuICAgICAgICAgICAgdGhpcy5jYWxsYmFjayA9IGZ1bmN0aW9uKGVyciwgcmVzdWx0KSB7XG4gICAgICAgICAgICAgICAgaWYoZXJyKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX19kZWJ1Z0luZm8oZXJyLm1lc3NhZ2UgfHwgZXJyKTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBpZihjYWxsYmFjaykge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FsbGJhY2soZXJyLCByZXN1bHQpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH07XG5cbiAgICAgICAgICAgIHRoaXMuX19pbml0KGNvbmZpZyk7XG5cbiAgICAgICAgICAgIHRoaXMuX19jb25zb2xlTG9nKFwiRGlzY292ZXJpbmcgdGVzdHMgLi4uXCIpO1xuICAgICAgICAgICAgdGhpcy50ZXN0VHJlZSA9IHRoaXMuX19kaXNjb3ZlclRlc3RGaWxlcyh0aGlzLmNvbmZpZy50ZXN0c0RpciwgY29uZmlnKTtcbiAgICAgICAgICAgIHRoaXMudGVzdExpc3QgPSB0aGlzLl9fdG9UZXN0VHJlZVRvTGlzdCh0aGlzLnRlc3RUcmVlKTtcbiAgICAgICAgICAgIHRoaXMuX19sYXVuY2hUZXN0cygpO1xuICAgICAgICB9LFxuICAgICAgICAvKipcbiAgICAgICAgICogUmVhZHMgY29uZmlndXJhdGlvbiBzZXR0aW5ncyBmcm9tIGEganNvbiBmaWxlLlxuICAgICAgICAgKiBAcGFyYW0gY29uZlBhdGgge1N0cmluZ30gLSBhYnNvbHV0ZSBwYXRoIHRvIHRoZSBjb25maWd1cmF0aW9uIGZpbGUuXG4gICAgICAgICAqIEByZXR1cm5zIHtPYmplY3R9IC0gY29uZmlndXJhdGlvbiBvYmplY3Qge3t9fVxuICAgICAgICAgKiBAcH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lyLCB0aGlzLmNvbmZpZy5jb25mRmlsZU5hbWUpO1xuICAgICAgICAgICAgICAgIGxldCBjb25mID0gdGhpcy5fX3JlYWRDb25mKGZkKTtcbiAgICAgICAgICAgICAgICBpZihjb25mKSB7XG4gICAgICAgICAgICAgICAgICAgIGN1cnJlbnROb2RlLl9fbWV0YS5jb25mID0gY29uZjtcbiAgICAgICAgICAgICAgICAgICAgY3VycmVudENvbmYgPSBjb25mO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgY3VycmVudE5vZGUuZGF0YS5uYW1lID0gcGF0aC5iYXNlbmFtZShkaXIpO1xuICAgICAgICAgICAgY3VycmVudE5vZGUuZGF0YS5wYXRoID0gZGlyO1xuICAgICAgICAgICAgY3VycmVudE5vZGUuaXRlbXMgPSBbXTtcblxuICAgICAgICAgICAgZm9yKGxldCBpID0gMCwgbGVuID0gZmlsZXMubGVuZ3RoOyBpIDwgbGVuOyBpKyspIHtcbiAgICAgICAgICAgICAgICBsZXQgaXRlbSA9IGZpbGVzW2ldO1xuXG4gICAgICAgICAgICAgICAgbGV0IGZkID0gcGF0aC5qb2luKGRpciwgaXRlbSk7XG4gICAgICAgICAgICAgICAgbGV0IHN0YXQgPSBmcy5zdGF0U3luYyhmZCk7XG4gICAgICAgICAgICAgICAgbGV0IGlzRGlyID0gc3RhdC5pc0RpcmVjdG9yeSgpO1xuICAgICAgICAgICAgICAgIGxldCBpc1Rlc3REaXIgPSB0aGlzLl9faXNUZXN0RGlyKGZkKTtcblxuICAgICAgICAgICAgICAgIGlmKGlzRGlyICYmICFpc1Rlc3REaXIpIHtcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7IC8vIGlnbm9yZSBkaXJzIHRoYXQgZG9lcyBub3QgZm9sbG93IHRoZSBuYW1pbmcgcnVsZSBmb3IgdGVzdCBkaXJzXG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgaWYoIWlzRGlyICYmIGl0ZW0ubWF0Y2godGhpcy5jb25maWcuY29uZkZpbGVOYW1lKSl7XG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOyAvLyBhbHJlYWR5IHByb2Nlc3NlZFxuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIC8vIGV4Y2x1ZGUgZmlsZXMgYmFzZWQgb24gZ2xvYiBwYXR0ZXJuc1xuICAgICAgICAgICAgICAgIGlmKGN1cnJlbnRDb25mKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIGN1cnJlbnRDb25mWydpZ25vcmUnXSAtIGFycmF5IG9mIHJlZ0V4cFxuICAgICAgICAgICAgICAgICAgICBpZihjdXJyZW50Q29uZlsnaWdub3JlJ10pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzTWF0Y2ggPSB0aGlzLl9faXNBbnlNYXRjaChjdXJyZW50Q29uZlsnaWdub3JlJ10sIGl0ZW0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYoaXNNYXRjaCkge2NvbnRpbnVlO31cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGxldCBjaGlsZE5vZGUgPSB0aGlzLl9fZ2V0RGVmYXVsdE5vZGVTdHJ1Y3R1cmUoKTtcbiAgICAgICAgICAgICAgICBjaGlsZE5vZGUuX19tZXRhLmNvbmYgPSB7fTtcbiAgICAgICAgICAgICAgICBjaGlsZE5vZGUuX19tZXRhLmlzRGlyZWN0b3J5ID0gaXNEaXI7XG4gICAgICAgICAgICAgICAgY2hpbGROb2RlLl9fbWV0YS5wYXJlbnQgPSBwYXRoLmRpcm5hbWUoZmQpO1xuXG4gICAgICAgICAgICAgICAgaWYgKGlzRGlyKSB7XG4gICAgICAgICAgICAgICAgICAgIGxldCB0ZW1wQ2hpbGROb2RlID0gdGhpcy5fX2Rpc2NvdmVyVGVzdEZpbGVzKGZkLCBjdXJyZW50Q29uZik7XG4gICAgICAgICAgICAgICAgICAgIGNoaWxkTm9kZSA9IE9iamVjdC5hc3NpZ24oY2hpbGROb2RlLCB0ZW1wQ2hpbGROb2RlKTtcbiAgICAgICAgICAgICAgICAgICAgY3VycmVudE5vZGUuaXRlbXMucHVzaChjaGlsZE5vZGUpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbHNlIGlmKHBhdGguZXh0bmFtZShmZCkgPT09ICB0aGlzLmNvbmZpZy5maWxlRXh0KXtcbiAgICAgICAgICAgICAgICAgICAgY2hpbGROb2RlLl9fbWV0YS5jb25mLnJ1bnMgPSBjdXJyZW50Q29uZlsncnVucyddIHx8IDE7XG4gICAgICAgICAgICAgICAgICAgIGNoaWxkTm9kZS5fX21ldGEuY29uZi5zaWxlbnQgPSBjdXJyZW50Q29uZlsnc2lsZW50J107XG4gICAgICAgICAgICAgICAgICAgIGNoaWxkTm9kZS5fX21ldGEuY29uZi50aW1lb3V0ID0gY3VycmVudENvbmZbJ3RpbWVvdXQnXSB8fCBERUZBVUxUX1RJTUVPVVQ7XG5cbiAgICAgICAgICAgICAgICAgICAgY2hpbGROb2RlLmRhdGEubmFtZSA9IGl0ZW07XG4gICAgICAgICAgICAgICAgICAgIGNoaWxkTm9kZS5kYXRhLnBhdGggPSBmZDtcblxuICAgICAgICAgICAgICAgICAgICBjdXJyZW50Tm9kZS5pdGVtcy5wdXNoKGNoaWxkTm9kZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICByZXR1cm4gY3VycmVudE5vZGU7XG4gICAgICAgIH0sXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBMYXVuY2ggY29sbGVjdGVkIHRlc3RzLiBJbml0aWFsaXNlcyBzZXNzaW9uIHZhcmlhYmxlcywgdGhhdCBhcmUgc3BlY2lmaWMgZm9yIHRoZSBjdXJyZW50IGxhdW5jaC5cbiAgICAgICAgICogQHByaXZhdGVcbiAgICAgICAgICovXG4gICAgICAgIF9fb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XN0KSB7XG4gICAgICAgICAgICAgICAgY29uc3QgY3VycmVudFJ1biA9IHRlc3QucmVzdWx0LnJ1bnM7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKGxvZykge1xuICAgICAgICAgICAgICAgICAgICBpZihsb2cudHlwZSA9PT0gJ2Fzc2VydCcpe1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYobG9nLm1lc3NhZ2UuaW5jbHVkZXMoXCJbRmFpbFwiKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRlc3QucmVzdWx0LnBhc3MgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIHRlc3QucmVzdWx0LmFzc2VydHNbY3VycmVudFJ1bl0ucHVzaChsb2cpO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGVzdC5yZXN1bHQubWVzc2FnZXNbY3VycmVudFJ1bl0ucHVzaChsb2cpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgZnVuY3Rpb24gb25FeGl0RXZlbnRIYW5kbGVyV3JhcHBlcih0ZXN0KSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKGNvZGUsIHNpZ25hbCkge1xuICAgICAgICAgICAgICAgICAgICBjbGVhclRpbWVvdXQod29ya2VyLnRpbWVyVmFyKTtcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5fX2RlYnVnSW5mbyhgV29ya2VyICR7d29ya2VyLnBpZH0gLSBleGl0IGV2ZW50LiBDb2RlICR7Y29kZX0sIHNpZ25hbCAke3NpZ25hbH0gYCtuZXcgRGF0ZSgpLmdldFRpbWUoKSk7XG5cbiAgICAgICAgICAgICAgICAgICAgd29ya2VyLnRlcm1pbmF0ZWQgPSB0cnVlO1xuXG4gICAgICAgICAgICAgICAgICAgIHRlc3QucmVzdWx0LnN0YXRlID0gVEVTVF9TVEFURVMuRklOSVNIRUQ7XG4gICAgICAgICAgICAgICAgICAgIGlmKGNvZGUgIT09IG51bGwgJiYgY29kZSE9PTAgLyomJiB0eXBlb2YgdGVzdC5yZXN1bHQucGFzcyA9PT0gJ3VuZGVmaW5lZCcqLyl7XG4gICAgICAgICAgICAgICAgICAgICAgICB0ZXN0LnJlc3VsdC5wYXNzID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgICAgICAgICB0ZXN0LnJlc3VsdC5tZXNzYWdlc1t0ZXN0LnJlc3VsdC5ydW5zXS5wdXNoKCB7bWVzc2FnZTogXCJQcm9jZXNzIGZpbmlzaGVkIHdpdGggZXJyb3JzIVwiLCBcIkV4aXQgY29kZVwiOmNvZGUsIFwiU2lnbmFsXCI6c2lnbmFsfSk7XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICBzZWxmLnNlc3Npb24ud29ya2Vycy5ydW5uaW5nLS07XG4gICAgICAgICAgICAgICAgICAgIHNlbGYuc2Vzc2lvbi53b3JrZXJzLnRlcm1pbmF0ZWQrKztcblxuICAgICAgICAgICAgICAgICAgICBzZWxmLl9fc2NoZWR1bGVXb3JrKCk7XG4gICAgICAgICAgICAgICAgICAgIHNlbGYuX19jaGVja1dvcmtlcnNTdGF0dXMoKTtcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAvLyB0aGlzIGhhbmRsZXIgY2FuIGJlIHRyaWdnZXJlZCB3aGVuOlxuICAgICAgICAgICAgLy8gMS4gVGhlIHByb2Nlc3MgY291bGQgbm90IGJlIHNwYXduZWQsIG9yXG4gICAgICAgICAgICAvLyAyLiBUaGUgcHJvY2VzcyBjb3VsZCBub3QgYmUga2lsbGVkLCBvclxuICAgICAgICAgICAgLy8gMy4gU2VuZGluZyBhIG1lc3NhZ2UgdG8gdGhlIGNoaWxkIHByb2Nlc3MgZmFpbGVkLlxuICAgICAgICAgICAgLy8gSU1QT1JUQU5UOiBUaGUgJ2V4aXQnIGV2ZW50IG1heSBvciBtYXkgbm90IGZpcmUgYWZ0ZXIgYW4gZXJyb3IgaGFzIG9jY3VycmVkIVxuICAgICAgICAgICAgZnVuY3Rpb24gb25FcnJvckV2ZW50SGFuZGxlcldyYXBwZXIodGVzdCkge1xuICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbihlcnJvcikge1xuICAgICAgICAgICAgICAgICAgICBzZWxmLl9fZGVidWdJbmZvKGBXb3JrZXIgJHt3b3JrZXIucGlkfSAtIGVycm9yIGV2ZW50LmAsIHRlc3QpO1xuICAgICAgICAgICAgICAgICAgICBzZWxmLl9fZGVidWdFcnJvcihlcnJvcik7XG5cbiAgICAgICAgICAgICAgICAgICAgc2VsZi5zZXNzaW9uLndvcmtlcnMucnVubmluZy0tO1xuICAgICAgICAgICAgICAgICAgICBzZWxmLnNlc3Npb24ud29ya2Vycy50ZXJtaW5hdGVkKys7XG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgLy8gTm90ZTogb24gZGVidWcsIHRoZSB0aW1lb3V0IGlzIHJlYWNoZWQgYmVmb3JlIGV4aXQgZXZlbnQgaXMgY2FsbGVkXG4gICAgICAgICAgICAvLyB3aGVuIGtpbGwgaXMgY2FsbGVkLCB0aGUgZXhpdCBldmVudCBpcyByYWlzZWRcbiAgICAgICAgICAgIHdvcmtlci50aW1lclZhciA9IHNldFRpbWVvdXQoKCk9PntcbiAgICAgICAgICAgICAgICBpZighd29ya2VyLnRlcm1pbmF0ZWQpe1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9fY29uc29sZUxvZyhgd29ya2VyIHBpZCBbJHt3b3JrZXIucGlkfV0gLSB0aW1lb3V0IGV2ZW50YCxuZXcgRGF0ZSgpLmdldFRpbWUoKSwgIHRlc3QpO1xuXG4gICAgICAgICAgICAgICAgICAgIGlmKHRlc3QucmVzdWx0LnN0YXRlICE9PSBURVNUX1NUQVRFUy5GSU5JU0hFRCl7XG4gICAgICAgICAgICAgICAgICAgICAgICB0ZXN0LnJlc3VsdC5wYXNzID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgd29ya2VyLmtpbGwoKTtcbiAgICAgICAgICAgICAgICAgICAgdGVzdC5yZXN1bHQuc3RhdGUgPSBURVNUX1NUQVRFUy5USU1FT1VUO1xuICAgICAgICAgICAgICAgIH1lbHNle1xuICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhcIkdvdCBzb21ldGhpbmcsIGJ1dCBkb24ndCBrbm93IHdoYXQuLi5cIiwgdGVzdCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSwgdGVzdC5fX21ldGEuY29uZi50aW1lb3V0KTtcblxuICAgICAgICAgICAgICAgIHNlbGYuX19kZWJ1Z0luZm8oYFdvcmtlciAke3dvcmtlci5waWR9IC0gc2V0IHRpbWVvdXQgZXZlbnQgYXQgYCtuZXcgRGF0ZSgpLmdldFRpbWUoKSArIFwiIGZvciBcIit0ZXN0Ll9fbWV0YS5jb25mLnRpbWVvdXQpO1xuXG4gICAgICAgIH0sXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBDaGVja3MgaWYgYWxsIHdvcmtlcnMgY29tcGxldGVkIHRoZWlyIGpvYiAoZmluaXNoZWQgb3IgaGF2ZSBiZWVuIHRlcm1pbmF0ZWQpLlxuICAgICAgICAgKiBJZiB0cnVlLCB0aGVuIHRoZSByZXBvcnRpbmcgc3RlcHMgY2FuIGJlIHN0YXJ0ZWQuXG4gICAgICAgICAqIEBwcml2YXRlXG4gICAgICAgICAqL1xuICAgICAgICBfX2NoZWNrV29ya2Vyc1N0YXR1czogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICBpZih0aGlzLnNlc3Npb24ud29ya2Vycy5ydW5uaW5nID09PSAwKSB7XG4gICAgICAgICAgICA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jdHVyZS5zdWl0ZXMuaXRlbXMucHVzaChzdWl0ZVBhdGgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJlcG9ydEZpbGVTdHJ1Y3R1cmUuc3VpdGVzLmNvdW50ID0gcmVwb3J0RmlsZVN0cnVjdHVyZS5zdWl0ZXMuaXRlbXMubGVuZ3RoO1xuXG4gICAgICAgICAgICBsZXQgbnVtYmVyT2ZSZXBvcnRzID0gMjtcblxuICAgICAgICAgICAgbGV0IGZpbmlzaFJlcG9ydHMgPSAoZXJyLCByZXMpID0+IHtcbiAgICAgICAgICAgICAgICBpZihudW1iZXJPZlJlcG9ydHMgPiAxKXtcbiAgICAgICAgICAgICAgICAgICAgbnVtYmVyT2ZSZXBvcnRzIC09IDE7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYocmVwb3J0RmlsZVN0cnVjdHVyZS5mYWlsZWQuY291bnQgPT09IDApe1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9fY29uc29sZUxvZyhcIlxcbkV2ZXJ5dGhpbmcgd2VudCB3ZWxsISBObyBmYWlsZWQgdGVzdHMuXFxuXFxuXCIpO1xuICAgICAgICAgICAgICAgIH1lbHNle1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9fY29uc29sZUxvZyhcIlxcblNvbWUgdGVzdHMgZmFpbGVkLiBDaGVjayByZXBvcnQgZmlsZXMhXFxuXFxuXCIpO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIHRoaXMuY2FsbGJhY2soZXJyLCBcIkRvbmVcIik7XG4gICAgICAgICAgICB9O1xuXG5cbiAgICAgICAgICAgIHRoaXMuX19jb25zb2xlTG9nKHRoaXMuY29uZmlnLnJlcG9ydHMucHJlZml4KTtcbiAgICAgICAgICAgIGNvbnN0IGZpbGVOYW1lID0gYCR7dGhpcy5jb25maWcucmVwb3J0cy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GaWxlKGRlc3RpbmF0aW9uLCByZXMgKyBgPHNjcmlwdD5pbml0KCR7SlNPTi5zdHJpbmdpZnkocmVwb3J0RmlsZVN0cnVjdHVyZSl9LCAke3RpbWVzdGFtcH0pOzwvc2NyaXB0PmAsICd1dGY4JywgKGVycikgPT4ge1xuICAgICAgICAgICAgICAgICAgICBpZiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtZXNzYWdlID0gJ0FuIGVycm9yIG9jY3VycmVkIHdoaWxlIHdyaXRpbmcgdGhlIGh0bWwgcmVwb3J0IGZpbGUsIHdpdGggdGhlIGZvbGxvd2luZyBlcnJvcjogJyArIEpTT04uc3RyaW5naWZ5KGVycik7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9fZGVidWdJbmZvKG1lc3NhZ2UpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgZXJyO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgY29uc3QgbWVzc2FnZSA9IGBGaW5pc2hlZCB3cml0aW5nIHJlcG9ydCB0byAke2Rlc3RpbmF0aW9ufWA7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX19jb25zb2xlTG9nKG1lc3NhZ2UpO1xuXG4gICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrKCk7XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSxcbiAgICAgICAgLyoqXG4gICAgICAgICAqIENvbnZlcnRzIGFic29sdXRlIGZpbGUgcGF0aCB0byByZWxhdGl2ZSBwYXRoLlxuICAgICAgICAgKiBAcGFyYW0gYWJzb2x1dGVQYXRoIHtTdHJpbmd9IC0gYWJzb2x1dGUgcGF0aFxuICAgICAgICAgKiBAcmV0dXJucyB7c3RyaW5nIHwgdm9pZCB8ICp9IC0gcmVsYXRpdmUgcGF0aFxuICAgICAgICAgKiBAcHJpdmF0ZVxuICAgICAgICAgKi9cb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ICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBmdW5jdGlvbiBhZGRSZWFzb24ocnVuLCBsb2cpIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgbWVzc2FnZSA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJ1bjogcnVuLFxuICAgICAgICAgICAgICAgICAgICAgICAgbG9nOiBsb2dcbiAgICAgICAgICAgICAgICAgICAgfTtcblxuICAgICAgICAgICAgICAgICAgICByZWFzb24ucHVzaChtZXNzYWdlKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHJldHVybiByZWFzb247XG4gICAgICAgIH0sXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBEZXNjcmliZWQgZGVmYXVsdCB0cmVlIG5vZGUgc3RydWN0dXJlLlxuICAgICAgICAgKiBAcmV0dXJucyB7e19fbWV0YToge2NvbmY6IG51bGwsIHBhcmVudDogbnVsbCwgaXNEaXJlY3Rvcnk6IGJvb2xlYW59LCBkYXRhOiB7bmFtZTogbnVsbCwgcGF0aDogbnVsbH0sIHJlc3VsdDoge3N0YXRlOiBzdHJpbmcsIHBhc3M6IG51bGwsIGV4ZWN1dGlvblRpbWU6IG51bWJlciwgcnVuczogbnVtYmVyLCBhc3NlcnRzOiB7fSwgbWVzc2FnZXM6IHt9fSwgaXRlbXM6IG51bGx9fVxuICAgICAgICAgKiBAcHJpdmF0ZVxuICAgICAgICAgKi9cbiAgICAgICAgX19nZXREZWZhdWx0Tm9kZVN0cnVjdHVyZTogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICByZXR1cm4gIHtcbiAgICAgICAgICAgICAgICBfX21ldGE6IHtcbiAgICAgICAgICAgICAgICAgICAgY29uZjogbnVsbCxcbiAgICAgICAgICAgICAgICAgICAgcGFyZW50OiBudWxsLFxuICAgICAgICAgICAgICAgICAgICBpc0RpcmVjdG9yeTogZmFsc2VcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIGRhdGE6IHtcbiAgICAgICAgICAgICAgICAgICAgbmFtZTogbnVsbCxcbiAgICAgICAgICAgICAgICAgICAgcGF0aDogbnVsbCxcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHJlc3VsdDoge1xuICAgICAgICAgICAgICAgICAgICBzdGF0ZTogVEVTVF9TVEFURVMuUkVBRFksIC8vIHJlYWR5IHwgcnVubmluZyB8IHRlcm1pbmF0ZWQgfCB0aW1lb3V0XG4gICAgICAgICAgICAgICAgICAgIHBhc3M6IG51bGwsXG4gICAgICAgICAgICAgICAgICAgIGV4ZWN1dGlvblRpbWU6IDAsXG4gICAgICAgICAgICAgICAgICAgIHJ1bnM6IDAsXG4gICAgICAgICAgICAgICAgICAgIGFzc2VydHM6IHt9LFxuICAgICAgICAgICAgICAgICAgICBtZXNzYWdlczoge31cbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIGl0ZW1zOiBudWxsXG4gICAgICAgICAgICB9O1xuICAgICAgICB9LFxuICAgICAgICAvKipcbiAgICAgICAgICogTWF0Y2ggYSB0ZXN0IGZpbGUgcGF0aCB0byBhIFVOSVggZ2xvYiBleHByZXNzaW9uIGFycmF5LiBJZiBpdHMgYW55IG1hdGNoIHJldHVybnMgdHJ1ZSwgb3RoZXJ3aXNlIHJldHVybnMgZmFsc2UuXG4gICAgICAgICAqIEBwYXJhbSBnbG9iRXhwQXJyYXkge0FycmF5fSAtIGFuIGFycmF5IHdpdGggZ2xvYiBleHByZXNzaW9uIChVTklYIHN0eWxlKVxuICAgICAgICAgKiBAcGFyYW0gc3RyIHtTdHJpbmd9IC0gdGhlIHN0cmluZyB0byBiZSBtYXRjaGVkXG4gICAgICAgICAqIEByZXR1cm5zIHtib29sZWFufSAtIHJldHVybnMgdHJ1ZSBpZiB0aGVyZSBpcyBhbnkgbWF0Y2ggYW5kIGZhbHNlIG90aGVyd2lzZS5cbiAgICAgICAgICogQHByaXZhdGVcbiAgICAgICAgICovXG4gICAgICAgIF9faXNBbnlNYXRjaDogZnVuY3Rpb24oZ2xvYkV4cEFycmF5LCBzdHIpIHtcbiAgICAgICAgICAgIGNvbnN0IGhhc01hdGNoID0gZnVuY3Rpb24oZ2xvYkV4cCkge1xuICAgICAgICAgICAgICAgIGNvbnN0IHJlZ2V4ID0gZ2xvYlRvUmVnRXhwKGdsb2JFeHApO1xuICAgICAgICAgICAgICAgIHJldHVybiByZWdleC50ZXN0KHN0cik7XG4gICAgICAgICAgICB9O1xuXG4gICAgICAgICAgICByZXR1cm4gZ2xvYkV4cEFycmF5LnNvbWUoaGFzTWF0Y2gpO1xuICAgICAgICB9LFxuICAgICAgICAvKipcbiAgICAgICAgICogQ29udmVydHMgYSB0cmVlIHN0cnVjdHVyZSBpbnRvIGFuIGFycmF5IGxpc3Qgb2YgdGVzdCBub2Rlcy4gVGhlIHRyZWUgdHJhdmVyc2FsIGlzIERGUyAoRGVlcC1GaXJzdC1TZWFyY2gpLlxuICAgICAgICAgKiBAcGFyYW0gcm9vdE5vZGUge09iamVjdH0gLSByb290IG5vZGUgb2YgdGhlIHRlc3QgdHJlZS5cbiAgICAgICAgICogQHJldHVybnMge0FycmF5fSAtIExpc3Qgb2YgdGVzdCBub2Rlcy5cbiAgICAgICAgICogQHByaXZhdGVcbiAgICAgICAgICovXG4gICAgICAgIF9fdG9UZXN0VHJlZVRvTGlzdDogZnVuY3Rpb24ocm9vdE5vZGUpIHtcbiAgICAgICAgICAgIHZhciB0ZXN0TGlzdCA9IFtdO1xuXG4gICAgICAgICAgICB0cmF2ZXJzZShyb290Tm9kZSk7XG5cbiAgICAgICAgICAgIGZ1bmN0aW9uIHRyYXZlcnNlKG5vZGUpIHtcbiAgICAgICAgICAgICAgICBpZighbm9kZS5fX21ldGEuaXNEaXJlY3RvcnkgfHwgIW5vZGUuaXRlbXMpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGZvcihsZXQgaSA9IDAsIGxlbiA9IG5vZGUuaXRlbXMubGVuZ3RoOyBpIDwgbGVuOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgaXRlbSA9IG5vZGUuaXRlbXNbaV07XG4gICAgICAgICAgICAgICAgICAgIGlmKGl0ZW0uX19tZXRhLmlzRGlyZWN0b3J5KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0cmF2ZXJzZShpdGVtKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRlc3RMaXN0LnB1c2goaXRlbSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHJldHVybiB0ZXN0TGlzdDtcbiAgICAgICAgfSxcbiAgICAgICAgLyoqXG4gICAgICAgICAqIExvZ2dpbmcgdG8gY29uc29sZSB3cmFwcGVyLlxuICAgICAgICAgKiBAcGFyYW0gbG9nIHtTdHJpbmd8T2JqZWN0fE51bWJlcn0gLSBsb2cgbWVzc2FnZVxuICAgICAgICAgKiBAcHJpdmF0ZVxuICAgICAgICAgKi9cbiAgICAgICAgX19jb25zb2xlTG9nOiBmdW5jdGlvbihsb2cpIHtcbiAgICAgICAgICAgIGNvbnNvbGUubG9nKFRBRywgbG9nKTtcbiAgICAgICAgfSxcbiAgICAgICAgLyoqXG4gICAgICAgICAqIExvZ2dpbmcgZGVidWdnaW5nIGluZm8gbWVzc2FnZXMgd3JhcHBlci5cbiAgICAgICAgICogTG9nZ2VyOiBjb25zb2xlLmluZm9cbiAgICAgICAgICogQHBhcmFtIGxvZyB7U3RyaW5nfE9iamVjdHxOdW1iZXJ9IC0gbG9nIG1lc3NhZ2VcbiAgICAgICAgICogQHByaXZhdGVcbiAgICAgICAgICovXG4gICAgICAgIF9fZGVidWdJbmZvOiBmdW5jdGlvbihsb2cpIHtcbiAgICAgICAgICAgIHRoaX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YW5vdGhlciBvYmplY3QuXG4gICAgICAgICAqIElmIHRoZSBwcm9wZXJ0eSBleGlzdHMgaW4gYm90aCBvYmplY3RzIHRoZSBwcm9wZXJ0eSBmcm9tIHRoZSBmaXJzdCBvYmplY3QgaXMgb3ZlcnJpZGRlbi5cbiAgICAgICAgICogQHBhcmFtIGZpcnN0IHtPYmplY3R9IC0gdGhlIGZpcnN0IG9iamVjdFxuICAgICAgICAgKiBAcGFyYW0gc2Vjb25kIHtPYmplY3R9IC0gdGhlIHNlY29uZCBvYmplY3RcbiAgICAgICAgICogQHJldHVybnMge09iamVjdH0gLSBhbiBvYmplY3Qgd2l0aCBib3RoIHByb3BlcnRpZXMgZnJvbSB0aGUgZmlyc3QgYW5kIHNlY29uZCBvYmplY3QuXG4gICAgICAgICAqIEBwcml2YXRlXG4gICAgICAgICAqL1xuICAgICAgICBfX2V4dGVuZDogZnVuY3Rpb24gKGZpcnN0LCBzZWNvbmQpIHtcbiAgICAgICAgICAgIGZvciAoY29uc3Qga2V5IGluIHNlY29uZCkge1xuICAgICAgICAgICAgICAgIGlmICghZmlyc3QuaGFzT3duUHJvcGVydHkoa2V5KSkge1xuICAgICAgICAgICAgICAgICAgICBmaXJzdFtrZXldID0gc2Vjb25kW2tleV07XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgbGV0IHZhbCA9IHNlY29uZFtrZXldO1xuICAgICAgICAgICAgICAgICAgICBpZih0eXBlb2YgZmlyc3Rba2V5XSA9PT0gJ29iamVjdCcpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhbCA9IHRoaXMuX19leHRlbmQoZmlyc3Rba2V5XSwgc2Vjb25kW2tleV0pO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgZmlyc3Rba2V5XSA9IHZhbDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHJldHVybiBmaXJzdDt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YXNlIFwiIVwiOlxuICAgICAgICAgICAgY2FzZSBcInxcIjpcbiAgICAgICAgICAgICAgICByZWdFeHAgKz0gXCJcXFxcXCIgKyBjO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuXG4gICAgICAgICAgICBjYXNlIFwiKlwiOlxuICAgICAgICAgICAgICAgIC8vIHRyZWF0IGFueSBudW1iZXIgb2YgXCIqXCIgYXMgb25lXG4gICAgICAgICAgICAgICAgd2hpbGUoZ2xvYkV4cFtpICsgMV0gPT09IFwiKlwiKSB7XG4gICAgICAgICAgICAgICAgICAgIGkrKztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmVnRXhwICs9IFwiLipcIjtcbiAgICAgICAgICAgICAgICBicmVhaztcblxuICAgICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgICAgICByZWdFeHAgKz0gYztcbiAgICAgICAgfVxuICAgIH1cblxuICAgIC8vIHNldCB0aGUgcmVndWxhciBleHByZXNzaW9uIHdpdGggXiAmICRcbiAgICByZWdFeHAgPSBcIl5cIiArIHJlZ0V4cCArIFwiJFwiO1xuXG4gICAgcmV0dXJuIG5ldyBSZWdFeHAocmVnRXhwKTtcbn07XG5cbm1vZHVsZS5leHBvcnRzID0gZ2xvYlRvUmVnRXhwOyIsImNvbnN0IHV0aWxzID0gcmVxdWlyZShcInN3YXJtdXRpbHNcIik7XG5jb25zdCBPd00gPSB1dGlscy5Pd007XG52YXIgYmVlc0hlYWxlciA9IHV0aWxzLmJlZXNIZWFsZXI7XG52YXIgZnMgPSByZXF1aXJlKFwiZnNcIik7XG52YXIgcGF0aCA9IHJlcXVpcmUoXCJwYXRoXCIpO1xuXG5cbi8vVE9ETzogcHJldmVudCBhIGNsYXNzIG9mIHJhY2UgY29uZGl0aW9uIHR5cGUgb2YgZXJyb3JzIGJ5IHNpZ25hbGluZyB3aXRoIGZpbGVzIG1ldGFkYXRhIHRvIHRoZSB3YXRjaGVyIHdoZW4gaXQgaXMgc2FmZS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Y29kZXIuRUNQcml2YXRlS2V5QVNOO1xuICAgICAgICBjb25zdCBTdWJqZWN0UHVibGljS2V5SW5mb0FTTiA9IEtleUVuY29kZXIuU3ViamVjdFB1YmxpY0tleUluZm9BU047XG4gICAgICAgIGNvbnN0IGtleUVuY29kZXIgICAgICAgICAgICAgID0gbmV3IEtleUVuY29kZXIoc2VsZi5jdXJ2ZSk7XG5cbiAgICAgICAgY29uc3QgcHJpdmF0ZUtleU9iamVjdCAgICAgICAgPSBrZXlFbmNvZGVyLnByaXZhdGVLZXlPYmplY3Qoa2V5cy5wcml2YXRlLGtleXMucHVibGljKTtcbiAgICAgICAgY29uc3QgcHVibGljS2V5T2JqZWN0ICAgICAgICAgPSBrZXlFbmNvZGVyLnB1YmxpY0tleU9iamVjdChrZXlzLnB1YmxpYyk7XG5cbiAgICAgICAgcmVzdWx0LnByaXZhdGUgICAgICAgICAgICAgID0gRUNQcml2YXRlS2V5QVNOLmVuY29kZShwcml2YXRlS2V5T2JqZWN0LCAncGVtJywgcHJpdmF0ZUtleU9iamVjdC5wZW1PcHRpb25zKTtcbiAgICAgICAgcmVzdWx0LnB1YmxpYyAgICAgICAgICAgICAgID0gU3ViamVjdFB1YmxpY0tleUluZm9BU04uZW5jb2RlKHB1YmxpY0tleU9iamVjdCwgJ3BlbScsIHB1YmxpY0tleU9iamVjdC5wZW1PcHRpb25zKTtcblxuICAgICAgICByZXR1cm4gcmVzdWx0O1xuXG4gICAgfVxuXG4gICAgdGhpcy5zaWduID0gZnVuY3Rpb24gKHByaXZhdGVLZXksZGlnZXN0KSB7XG4gICAgICAgIGNvbnN0IHNpZ24gPSBjcnlwdG8uY3JlYXRlU2lnbihcInNoYTI1NlwiKTtcbiAgICAgICAgc2lnbi51cGRhdGUoZGlnZXN0KTtcblxuICAgICAgICByZXR1cm4gc2lnbi5zaWduKHByaXZhdGVLZXksJ2hleCcpO1xuICAgIH07XG5cbiAgICB0aGlzLnZlcmlmeSA9IGZ1bmN0aW9uIChwdWJ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hNTEyJyk7XG5cbiAgICAgICAgICAgICAgICBjb25zdCBzYWx0ID0gQnVmZmVyLmNvbmNhdChba2V5U2FsdCwgYWFkU2FsdF0pO1xuICAgICAgICAgICAgICAgIGNvbnN0IGl2ID0gY3J5cHRvLnBia2RmMlN5bmMocGFzc3dvcmQsIHNhbHQsIHV0aWxzLml0ZXJhdGlvbnNfbnVtYmVyLCAxMiwgJ3NoYTUxMicpO1xuXG4gICAgICAgICAgICAgICAgY29uc3QgY2lwaGVyID0gY3J5cHRvLmNyZWF0ZUNpcGhlcml2KHV0aWxzLmFsZ29yaXRobSwga2V5LCBpdik7XG4gICAgICAgICAgICAgICAgY2lwaGVyLnNldEFBRChhYWQpO1xuICAgICAgICAgICAgICAgIGFyY2hpdmVyLnppcFN0cmVhbShpbnB1dFBhdGgsIGNpcGhlciwgZnVuY3Rpb24gKGVyciwgY2lwaGVyU3RyZWFtKSB7XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNhbGxiYWNrKGVycik7XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICBjaXBoZXJTdHJlYW0ub24oXCJkYXRhXCIsIGZ1bmN0aW9uIChjaHVuaykge1xuICAgICAgICAgICAgICAgICAgICAgICAgd3Mud3JpdGUoY2h1bmspO1xuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgY2lwaGVyU3RyZWFtLm9uKCdlbmQnLCBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0YWcgPSBjaXBoZXIuZ2V0QXV0aFRhZygpO1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGF0YVRvQXBwZW5kID0gQnVmZmVyLmNvbmNhdChbc2FsdCwgdGFnXSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB3cy5lbmQoZGF0YVRvQXBwZW5kLCBmdW5jdGlvbiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FsbGJhY2soZXJyKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWxsYmFjaygpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSk7XG4gICAgfTtcblxuICAgIHRoaXMuZGVjcnlwdFN0cmVhbSA9IGZ1bmN0aW9uIChlbmNyeXB0ZWRJbnB1dFBhdGgsIG91dHB1dEZvbGRlciwgcGFzc3dvcmQsIGNhbGxiYWNrKSB7XG5cbiAgICAgICAgY29uc3QgYXJjaGl2ZXIgPSBuZXcgUHNrQXJjaGl2ZXIoKTtcblxuICAgICAgICBkZWNyeXB0RmlsZShlbmNyeXB0ZWRJbnB1dFBhdGgsIHRlbXBGb2xkZXIsIHBhc3N3b3JkLCBmdW5jdGlvbiAoZXJyLCB0ZW1wQXJjaGl2ZVBhdGgpIHtcbiAgICAgICAgICAgIGlmIChlcnIpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gY2FsbGJhY2soZXJyKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgYXJjaGl2ZXIub24oJ3Byb2dyZXNzJywgKHByb2dyZXNzKSA9PiB7XG4gICAgICAgICAgICAgICAgc2VsZi5lbWl0KCdwcm9ncmVzcycsIDEwICsgMC45ICogcHJvZ3Jlc3MpO1xuICAgICAgICAgICAgfSk7XG5cblxuICAgICAgICAgICAgYXJjaGl2ZXIudW56aXBTdHJlYW0odGVtcEFyY2hpdmVQYXRoLCBvdXRwdXRGb2xkZXIsIGZ1bmN0aW9uIChlcnIsIHVuemlwcGVkRmlsZU5hbWVzKSB7XG4gICAgICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FsbGJhY2soZXJyKTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICB1dGlscy5kZWxldGVSZWN1cnNpdmVseSh0ZW1wQXJjaGl2ZVBhdGgsIGZ1bmN0aW9uIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNhbGxiYWNrKGVycik7XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICBjYWxsYmFjayh1bmRlZmluZWQsIHVuemlwcGVkRmlsZU5hbWVzKTtcbiAgICAgICAgICAgICAgICB9KTtcblxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0pXG4gICAgfTtcblxuICAgIHRoaXMuZW5jcnlwdE9iamVjdCA9IGZ1bmN0aW9uIChpbnB1dE9iaiwgZHNlZWQsIGRlcHRoLCBjYWxsYmFjaykge1xuICAgICAgICBjb25zdCBhcmNoaXZlciA9IG5ldyBQc2tBcmNoaXZlcigpO1xuXG4gICAgICAgIGFyY2hpdmVyLnppcEluTWVtb3J5KGlucHV0T2JqLCBkZXB0aCwgZnVuY3Rpb24gKGVyciwgemlwcGVkT2JqKSB7XG4gICAgICAgICAgICBpZiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGNhbGxiYWNrKGVycik7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjb25zdCBjaXBoZXJUZXh0ID0gdXRpbHMuZW5jcnlwdCh6aXBwZWRPYmosIGRzZWVkKTtcbiAgICAgICAgICAgIGNhbGxiYWNrKG51bGwsIGNpcGhlclRleHQpO1xuICAgICAgICB9KVxuICAgIH07XG5cbiAgICB0aGlzLmRlY3J5cHRPYmplY3QgPSBmdW5jdGlvbiAoZW5jcnlwdGVkRGF0YSwgZHNlZWQsIGNhbGxiYWNrKSB7XG4gICAgICAgI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jcnlwdGVkSW5wdXRQYXRoLCBmdW5jdGlvbiAoZXJyLCBzdGF0cykge1xuICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgIHJldHVybiBjYWxsYmFjayhlcnIsIG51bGwpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBjb25zdCBmaWxlU2l6ZUluQnl0ZXMgPSBzdGF0cy5zaXplO1xuXG4gICAgICAgICAgICBmcy5vcGVuKGVuY3J5cHRlZElucHV0UGF0aCwgXCJyXCIsIGZ1bmN0aW9uIChlcnIsIGZkKSB7XG4gICAgICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgICAgICBjYWxsYmFjayhlcnIsIG51bGwpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGVuY3J5cHRlZEF1dGhEYXRhID0gQnVmZmVyLmFsbG9jKDgwKTtcblxuICAgICAgICAgICAgICAgICAgICBmcy5yZWFkKGZkLCBlbmNyeXB0ZWRBdXRoRGF0YSwgMCwgODAsIGZpbGVTaXplSW5CeXRlcyAtIDgwLCBmdW5jdGlvbiAoZXJyLCBieXRlc1JlYWQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNhbHQgPSBlbmNyeXB0ZWRBdXRoRGF0YS5zbGljZSgwLCA2NCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBrZXlTYWx0ID0gc2FsdC5zbGljZSgwLCAzMik7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhYWRTYWx0ID0gc2FsdC5zbGljZSgtMzIpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpdiA9IGNyeXB0by5wYmtkZjJTeW5jKHBhc3N3b3JkLCBzYWx0LCB1dGlscy5pdGVyYXRpb25zX251bWJlciwgMTIsICdzaGE1MTInKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGtleSA9IGNyeXB0by5wYmtkZjJTeW5jKHBhc3N3b3JkLCBrZXlTYWx0LCB1dGlscy5pdGVyYXRpb25zX251bWJlciwgMzIsICdzaGE1MTInKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFhZCA9IGNyeXB0by5wYmtkZjJTeW5jKHBhc3N3b3JkLCBhYWRTYWx0LCB1dGlscy5pdGVyYXRpb25zX251bWJlciwgMzIsICdzaGE1MTInKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRhZyA9IGVuY3J5cHRlZEF1dGhEYXRhLnNsaWNlKC0xNik7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRlY2lwaGVyID0gY3J5cHRvLmNyZWF0ZURlY2lwaGVyaXYodXRpbHMuYWxnb3JpdGhtLCBrZXksIGl2KTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgZGVjaXBoZXIuc2V0QUFEKGFhZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBkZWNpcGhlci5zZXRBdXRoVGFnKHRhZyk7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBycyA9IGZzLmNyZWF0ZVJlYWRTdHJlYW0oZW5jcnlwdGVkSW5wdXRQYXRoLCB7c3RhcnQ6IDAsIGVuZDogZmlsZVNpemVJbkJ5dGVzIC0gODF9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGZzLm1rZGlyKHRlbXBGb2xkZXIsIHtyZWN1cnNpdmU6IHRydWV9LCBmdW5jdGlvbiAoZXJyKSB7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjYWxsYmFjayhlcnIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZW1wQXJjaGl2ZVBhdGggPSBwYXRoLmpvaW4odGVtcEZvbGRlciwgcGF0aC5iYXNlbmFtZShlbmNyeXB0ZWRJbnB1dFBhdGgpICsgXCIuemlwXCIpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZnMub3Blbih0ZW1wQXJjaGl2ZVBhdGgsIFwid1wiLCBmdW5jdGlvbiAoZXJyLCBmZCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWxsYmFjayhlcnIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnMuY2xvc2UoZmQsIGZ1bmN0aW9uIChlcnIpIHtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjYWxsYmFjayhlcnIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwdFN0cmVhbSA9IG5ldyBQYXNzVGhyb3VnaFN0cmVhbSgpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3cyA9IGZzLmNyZWF0ZVdyaXRlU3RyZWFtKHRlbXBBcmNoaXZlUGF0aCwge2F1dG9DbG9zZTogZmFsc2V9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdzLm9uKFwiZmluaXNoXCIsIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWxsYmFjayhudWxsLCB0ZW1wQXJjaGl2ZVBhdGgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG5cblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHByb2dyZXNzTGVuZ3RoID0gMDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0b3RhbExlbmd0aCA9IDA7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8qKlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICogVE9ETyByZXZpZXcgdGhpc1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICogSW4gYnJvd3NlciwgcGlwaW5nIHdpbGwgYmxvY2sgdGhlIGV2ZW50IGxvb3AgYW5kIHRoZSBzdGFjayBxdWV1ZSBpcyBub3QgY2FsbGVkLlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICovXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBycy5vbihcImRhdGFcIiwgKGNodW5rKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvZ3Jlc3NMZW5ndGggKz0gY2h1bmsubGVuZ3RoO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvdGFsTGVuZ3RoICs9IGNodW5rLmxlbmd0aDtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwcm9ncmVzc0xlbmd0aCA+IDMwMDAwMCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcm9ncmVzc0xlbmd0aCA9IDA7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVtaXRQcm9ncmVzcyhmaWxlU2l6ZUluQnl0ZXMsIHRvdGFsTGVuZ3RoKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICAgICAgICAgICAg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gICB6aXBGaWxlLmVuZCgpO1xuICAgICAgICAgICAgICAgIGNvbnN0IGZpbGVuYW1lID0gcGF0aC5iYXNlbmFtZShpbnB1dFBhdGgpO1xuICAgICAgICAgICAgICAgIGNvbnN0IHNwbGl0RmlsZW5hbWUgPSBmaWxlbmFtZS5zcGxpdChcIi5cIik7XG4gICAgICAgICAgICAgICAgaWYgKHNwbGl0RmlsZW5hbWUubGVuZ3RoID49IDIpIHtcbiAgICAgICAgICAgICAgICAgICAgZXh0ID0gXCIuXCIgKyBzcGxpdEZpbGVuYW1lW3NwbGl0RmlsZW5hbWUubGVuZ3RoIC0gMV07XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGNvbnN0IG15U3RyZWFtID0gemlwRmlsZS5vdXRwdXRTdHJlYW0ucGlwZShwdFN0cmVhbSk7XG5cbiAgICAgICAgICAgICAgICBsZXQgcHJvZ3Jlc3NMZW5ndGggPSAwO1xuICAgICAgICAgICAgICAgIGxldCB0b3RhbExlbmd0aCA9IDA7XG5cbiAgICAgICAgICAgICAgICAvKipcbiAgICAgICAgICAgICAgICAgKiBUT0RPIHJldmlldyB0aGlzXG4gICAgICAgICAgICAgICAgICogSW4gYnJvd3NlciwgcGlwaW5nIHdpbGwgYmxvY2sgdGhlIGV2ZW50IGxvb3AgYW5kIHRoZSBzdGFjayBxdWV1ZSBpcyBub3QgY2FsbGVkLlxuICAgICAgICAgICAgICAgICAqL1xuICAgICAgICAgICAgICAgIG15U3RyZWFtLm9uKFwiZGF0YVwiLCAoY2h1bmspID0+IHtcbiAgICAgICAgICAgICAgICAgICAgcHJvZ3Jlc3NMZW5ndGggKz0gY2h1bmsubGVuZ3RoO1xuICAgICAgICAgICAgICAgICAgICB0b3RhbExlbmd0aCArPSBjaHVuay5sZW5ndGg7XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKHByb2dyZXNzTGVuZ3RoID4gMzAwMDAwKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBteVN0cmVhbS5wYXVzZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgcHJvZ3Jlc3NMZW5ndGggPSAwO1xuICAgICAgICAgICAgICAgICAgICAgICAgc2V0VGltZW91dChmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbXlTdHJlYW0ucmVzdW1lKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9LCAxMCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBlbWl0UHJvZ3Jlc3ModG90YWxTaXplLCB0b3RhbExlbmd0aClcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICAgICAgbXlTdHJlYW0ub24oJ2VuZCcsICgpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgZW1pdFByb2dyZXNzKHRvdGFsU2l6ZSwgdG90YWxTaXplKTtcbiAgICAgICAgICAgICAgICAgICAgZW1pdFRvdGFsU2l6ZSh0b3RhbFNpemUpO1xuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIGlmIChpc1N0cmVhbS5pc1dyaXRhYmxlKG91dHB1dCkpIHtcbiAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2sobnVsbCwgbXlTdHJlYW0ucGlwZShvdXRwdXQpKTtcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBvdXRwdXQgPT09IFwic3RyaW5nXCIpIHtcbiAgICAgICAgICAgICAgICAgICBmcy5ta2RpcihvdXRwdXQsIHtyZWN1cnNpdmU6IHRydWV9LCAoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkZXN0aW5hdGlvblBhdGggPSBwYXRoLmpvaW4ob3V0cHV0LCBwYXRoLmJhc2VuYW1lKGlucHV0UGF0aCwgZXh0KSArIFwiLnppcFwiKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIG15U3RyZWFtLnBpcGUoZnMuY3JlYXRlV3JpdGVTdHJlYW0oZGVzdGluYXRpb25QYXRoKSk7XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICBmdW5jdGlvbiBfX2FkZFRvQXJjaGl2ZVJlY3Vyc2l2ZWx5KHppcEZpbGUsIGlucHV0UGF0aCwgcm9vdCA9ICcnLCBjYWxsYmFjaykge1xuICAgICAgICAgICAgICAgIHJvb3QgPSByb290IHx8ICcnO1xuICAgICAgICAgICAgICAgIGZzLnN0YXQoaW5wdXRQYXRoLCAoZXJyLCBzdGF0cykgPT4ge1xuICAgICAgICAgICAgICAgICAgICBpZiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FsbGJhY2soZXJyKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdHMuaXNGaWxlKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHppcEZpbGUuYWRkRmlsZShpbnB1dFBhdGgsIHBhdGguam9pbihyb290LCBwYXRoLmJhc2VuYW1lKGlucHV0UGF0aCkpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrKG51bGwpO1xuXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBmcy5yZWFkZGlyKGlucHV0UGF0aCwgKGVyciwgZmlsZXMpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjYWxsYmFjayhlcnIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmX2xlbmd0aCA9IGZpbGVzLmxlbmd0aDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgZl9hZGRfaW5kZXggPSAwO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hlY2tTdGF0dXMgPSAoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmX2xlbmd0aCA9PT0gZl9hZGRfaW5kZXgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrKG51bGwpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWNoZWNrU3RhdHVzKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmlsZXMuZm9yRWFjaChmaWxlID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRlbXBQYXRoID0gcGF0aC5qb2luKGlucHV0UGF0aCwgZmlsZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfX2FkZFRvQXJjaGl2ZVJlY3Vyc2l2ZWx5KHppcEZpbGUsIHRlbXBQYXRoLCBwYXRoLmpvaW4ocm9vdCwgcGF0aC5iYXNlbmFtZShpbnB1dFBhdGgpKSwgKGVycikgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNhbGxiYWNrKGVycik7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZfYWRkX2luZGV4Kys7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2hlY2tTdGF0dXMoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICB9KTtcblxuICAgIH07XG5cbiAgICB0aGlzLnVuemlwU3RyZWFtID0gZnVuY3Rpb24gKGlucHV0LCBvdXRwdXRQYXRoLCBjYWxsYmFjaykge1xuXG4gICAgICAgIGxldCBzaXplID0gMDtcblxuICAgICAgICBmcy5zdGF0KGlucHV0LCAoZXJyLCBzdGF0cykgPT4ge1xuICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgIHJldHVybiBjYWxsYmFjayhlcnIpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBsZXQgdG90YWxTaXplID0gc3RhdHMuc2l6ZTtcblxuXG4gICAgICAgICAgICB5YXV6bC5vcGVuKGlucHV0LCB7bGF6eUVudHJpZXM6IHRydWV9LCAoZXJyLCB6aXBGaWxlKSA9PiB7XG4gICAgICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FsbGJhY2soZXJyKTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBsZXQgcHJvZ3Jlc3NMZW5ndGggPSAwO1xuICAgICAgICAgICAgICAgIGxldCB0b3RhbExlbmd0aCA9IDA7XG5cbiAgICAgICAgICAgICAgICBjb25zdCBmaWxlTmFtZXMgPSBbXTtcbiAgICAgICAgICAgICAgICB6aXBGaWxlLnJlYWRFbnRyeSgpO1xuICAgICAgICAgICAgICAgIHppcEZpbGUub25jZShcImVuZFwiLCAoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIGVtaXRQcm9ncmVzcyh0b3RhbFNpemUsIHRvdGFsU2l6ZSk7XG4gICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrKG51bGwsIGZpbGVOYW1lcyk7XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgemlwRmlsZS5vbihcImVudHJ5XCIsIChlbnRyeSkgPT4ge1xuICAgICAgICAgICAgICAgICAgICBpZiAoZW50cnkuZmlsZU5hbWUuZW5kc1dpdGgocGF0aC5zZXApKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB6aXBGaWxlLnJlYWRFbnRyeSgpO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGZvbGRlciA9IHBhdGguZGlybmFtZShlbnRyeS5maWxlTmFtZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBmcy5ta2RpcihwYXRoLmpvaW4ob3V0cHV0UGF0aCwgZm9sZGVyKSwge3JlY3Vyc2l2ZTogdHJ1ZX0sICgpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB6aXBGaWxlLm9wZW5SZWFkU3RyZWFtKGVudHJ5LCAoZXJyLCByZWFkU3RyZWFtKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjYWxsYmFjayhlcnIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLyoqXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqIFRPRE8gcmV2aWV3IHRoaXNcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICogSW4gYnJvd3NlciwgcGlwaW5nIHdpbGwgYmxvY2sgdGhlIGV2ZW50IGxvb3AgYW5kIHRoZSBzdGFjayBxdWV1ZSBpcyBub3QgY2FsbGVkLlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKi9cblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFkU3RyZWFtLm9uKFwiZGF0YVwiLCAoY2h1bmspID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByb2dyZXNzTGVuZ3RoICs9IGNodW5rLmxlbmd0aDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvdGFsTGVuZ3RoICs9IGNodW5rLmxlbmd0aDtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHByb2dyZXNzTGVuZ3RoID4gMzAwMDAwKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhZFN0cmVhbS5wYXVzZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByb2dyZXNzTGVuZ3RoID0gMDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhZFN0cmVhbS5yZXN1bWUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCAzMCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW1pdFByb2dyZXNzKHRvdGFsU2l6ZSwgdG90YWxMZW5ndGgpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuXG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhZFN0cmVhbS5vbihcImVuZFwiLCAoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB6aXBGaWxlLnJlYWRFbnRyeSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcHRTdHJlYW0gPSBuZXcgUGFzc1Rocm91Z2hTdHJlYW0oKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGZpbGVOYW1lID0gcGF0aC5qb2luKG91dHB1dFBhdGgsIGVudHJ5LmZpbGVOYW1lKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGZvbGRlciA9IHBhdGguZGlybmFtZShmaWxlTmFtZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRlbXBTdHJlYW0gPSByZWFkU3RyZWFtLnBpcGUocHRTdHJlYW0pO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZzLm1rZGlyKGZvbGRlciwge3JlY3Vyc2l2ZTogdHJ1ZX0sIChlcnIpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FsbGJhY2soZXJyKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZSArPSBwdFN0cmVhbS5nZXRTaXplKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgb3V0cHV0ID0gZnMuY3JlYXRlV3JpdGVTdHJlYW0oZmlsZU5hbWUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmlsZU5hbWVzLnB1c2goZmlsZU5hbWUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGVtcFN0cmVhbS5waXBlKG91dHB1dCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH0pO1xuXG4gICAgICAgIH0pO1xuXG4gICAgfTtcblxuICAgIHRoaXMuemlwSW5NZW1vcnkgPSBmdW5jdGlvbiAoaW5wdXRPYmosIGRlcHRoLCBjYWxsYmFjaykge1xuICAgICAgICBjb25zdCB6aXBGaWxlID0gbmV3IHlhemwuWmlwRmlsZSgpO1xuICAgICAgICBjb25zdCBkcyA9IG5ldyBEdXBsZXhTdHJlYW0oKTtcbiAgICAgICAgemlwUmVjdXJzaXZlbHkoemlwRmlsZSwgaW5wdXRPYmosIFwiXCIsIGRlcHRoLCAoZXJyKSA9PiB7XG4gICAgICAgICAgICBpZiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGNhbGxiYWNrKGVycik7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB6aXBGaWxlLmVuZCgpO1xuICAgICAgICAgICAgbGV0IGJ1ZmZlciA9IEJ1ZmZlci5hbGxvYygwKTtcbiAgICAgICAgICAgIGRzLm9uKCdkYXRhJywgKGNodW5rKSA9PiB7XG4gICAgICAgICAgICAgICAgYnVmZmVyID0gQnVmZmVyLmNvbmNhdChbYnVmZmVyLCBjaHVua10pO1xuICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgIHppcEZpbGUub3V0cHV0U3RyZWFtLnBpcGUoZHMpLm9uKFwiZmluaXNoXCIsIChlcnIpID0+IHtcbiAgICAgICAgICAgICAgICBpZiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBjYWxsYmFjayhlcnIpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBjYWxsYmFjayhudWxsLCBidWZmZXIpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0pXG4gICAgfTtcblxuICAgIHRoaXMudW56aXBJbk1lbW9yeSA9IGZ1bmN0aW9uIChpbnB1dFppcCwgY2FsbGJhY2spIHtcblxuICAgICAgICBmdW5jdGlvbiB1bnppcElucHV0KHppcEZpbGUpIHtcbiAgICAgICAgICAgIHppcEZpbGUucmVhZEVudHJ5KCk7XG4gICAgICAgICAgICBjb25zdCBvYmogPSB7fTtcbiAgICAgICAgICAgIHppcEZpbGUub25jZShcImVuZFwiLCAoKSA9PiB7XG4gICAgICAgICAgICAgICAgY2FsbGJhY2sobnVsbCwgb2JqKTtcbiAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICB6aXBGaWxlLm9uKFwiZW50cnlcIiwgKGVudHJ5KSA9PiB7XG4gICAgICAgICAgICAgICAgemlwRmlsZS5vcGVuUmVhZFN0cmVhbShlbnRyeSwgKGVyciwgcmVhZFN0cmVhbSkgPT4ge1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBkcyA9IG5ldyBEdXBsZXhTdHJlYW0oKTtcbiAgICAgICAgICAgICAgICAgICAgbGV0IHN0ciA9ICcnO1xuICAgICAgICAgICAgICAgICAgICBpZiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FsbGJhY2soZXJyKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICByZWFkU3RyZWFtLm9uKFwiZW5kXCIsICgpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHppcEZpbGUucmVhZEVudHJ5KCk7XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICBkcy5vbihcImRhdGFcIiwgKGNodW5rKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdHIgKz0gY2h1bmsudG9TdHJpbmcoKTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgICAgICAgICAgcmVhZFN0cmVhbS5waXBlKGRzKS5vbihcImZpbmlzaFwiLCAoZXJyKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNhbGxiYWNrKGVycik7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzcGxpdEVudHJ5ID0gZW50cnkuZmlsZU5hbWUuc3BsaXQoXCIvXCIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdHlwZSA9IHNwbGl0RW50cnkucG9wKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBhZGRQcm9wc1JlY3Vyc2l2ZWx5KG9iaiwgc3BsaXRFbnRyeSwgdHlwZSwgbmV3IEJ1ZmZlcihzdHIpKTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH0pXG4gICAgICAgIH1cblxuICAgICAgICBpZiAoQnVmZmVyLmlzQnVmZmVyKGlucHV0WmlwKSkge1xuICAgICAgICAgICAgeWF1emwuZnJvbUJ1ZmZlcihpbnB1dFppcCwge2xhenlFbnRyaWVzOiB0cnVlfSwgKGVyciwgemlwRmlsZSkgPT4ge1xuICAgICAgICAgICAgICAgIGlmIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNhbGxiYWNrKGVycik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHVuemlwSW5wdXQoemlwRmlsZSlcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIGNhbGxiYWNrKG5ldyBFcnJvcihcImlucHV0IHNob3VsZCBiZSBhIGJ1ZmZlclwiKSk7XG4gICAgICAgIH1cblxuICAgIH07XG5cbiAgICBmdW5jdGlvbiB6aXBSZWN1cnNpdmVseSh6aXBGaWxlLCBvYmosIHJvb3QsIGRlcHRoLCBjYWxsYmFjaykge1xuICAgICAgICBpZiAoZGVwdGggPT09IDApIHtcbiAgICA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gIGZvciAobGV0IGkgPSAwOyBpIDwgb2JqLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICAgICAgaWYgKG9iai5sZW5ndGggPT09IDApIHtcbiAgICAgICAgICAgICAgICAgICAgemlwRmlsZS5hZGRCdWZmZXIoQnVmZmVyLmFsbG9jKDApLCByb290ICsgXCIvYXJyYXlcIilcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICB6aXBSZWN1cnNpdmVseSh6aXBGaWxlLCBvYmpbaV0sIHJvb3QgKyBcIi9hcnJheS9cIiArIGksIGRlcHRoLCAoZXJyKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNhbGxiYWNrKGVycik7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIGlmIChvYmogJiYgdHlwZW9mIG9iaiA9PT0gJ29iamVjdCcpIHtcbiAgICAgICAgICAgIGxldCBrZXlzID0gT2JqZWN0LmtleXMob2JqKTtcbiAgICAgICAgICAgIGlmIChrZXlzLmxlbmd0aCA9PT0gMCAmJiBvYmouY29uc3RydWN0b3IgPT09IE9iamVjdCkge1xuICAgICAgICAgICAgICAgIHppcEZpbGUuYWRkQnVmZmVyKEJ1ZmZlci5hbGxvYygwKSwgcm9vdCArIFwiL29iamVjdFwiKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgY29uc3QgZW5jb2RlZE9iaiA9IHt9O1xuICAgICAgICAgICAgICAgIE9iamVjdC5lbnRyaWVzKG9iaikuZm9yRWFjaCgoW2tleSwgdmFsdWVdKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIGVuY29kZWRPYmpbZW5jb2RlVVJJQ29tcG9uZW50KGtleSldID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgb2JqID0gZW5jb2RlZE9iajtcbiAgICAgICAgICAgICAgICBrZXlzID0gT2JqZWN0LmtleXMob2JqKTtcbiAgICAgICAgICAgICAgICBrZXlzLmZvckVhY2goa2V5ID0+IHtcbiAgICAgICAgICAgICAgICAgICAgbGV0IGVudHJ5TmFtZTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHJvb3QgPT09IFwiXCIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5TmFtZSA9IGtleTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5TmFtZSA9IHJvb3QgKyBcIi9cIiArIGtleTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB6aXBSZWN1cnNpdmVseSh6aXBGaWxlLCBvYmpba2V5XSwgZW50cnlOYW1lLCBkZXB0aCAtIDEsIChlcnIpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FsbGJhY2soZXJyKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ1Nob3VsZCBuZXZlciByZWFjaCB0aGlzJyk7XG4gICAgICAgIH1cbiAgICAgICAgY2FsbGJhY2sobnVsbCk7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gYWRkUHJvcHNSZWN1cnNpdmVseShvYmosIHNwbGl0TmFtZSwgdHlwZSwgZGF0YSkge1xuICAgICAgICBpZiAoc3BsaXROYW1lLmxlbmd0aCA+PSAxKSB7XG4gICAgICAgICAgICBjb25zdCBwcm9wID0gZGVjb2RlVVJJQ29tcG9uZW50KHNwbGl0TmFtZS5zaGlmdCgpKTtcblxuICAgICAgICAgICAgaWYgKHNwbGl0TmFtZS5sZW5ndGggPT09IDApIHtcbiAgICAgICAgICAgICAgICBzd2l0Y2ggKHR5cGUpIHtcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAndW5kZWZpbmVkJzpcbiAgICAgICAgICAgICAgICAgICAgICAgIG9ialtwcm9wXSA9IHVuZGVmaW5lZDtcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgICAgICBjYXNlICdudWxsJzpcbiAgICAgICAgICAgICAgICAgICAgICAgIG9ialtwcm9wXSA9IG51bGw7XG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAnbnVtYmVyJzpcbiAgICAgICAgICAgICAgICAgICAgICAgIG9ialtwcm9wXSA9IHBhcnNlSW50KGRhdGEudG9TdHJpbmcoKSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAnc3RyaW5nJzpcbiAgICAgICAgICAgICAgICAgICAgICAgIG9ialtwcm9wXSA9IGRhdGEudG9TdHJpbmcoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgICAgICBjYXNlICdzdHJlYW0nOlxuICAgICAgICAgICAgICAgICAgICAgICAgb2JqW3Byb3BdID0gYnVmZmVyVG9TdHJlYW0oZGF0YSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAnYXJyYXknOlxuICAgICAgICAgICAgICAgICAgICAgICAgb2JqW3Byb3BdID0gW107XG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAnb2JqZWN0JzpcbiAgICAgICAgICAgICAgICAgICAgICAgIG9ialtwcm9wXSA9IHt9O1xuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgICAgIGNhc2UgJ3N0cmluZ2lmeSc6XG4gICAgICAgICAgICAgICAgICAgICAgICBvYmpbcHJvcF0gPSBKU09OLnBhcnNlKGRhdGEudG9TdHJpbmcoKSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignU2hvdWxkIG5ldmVyIHJlYWNoIHRoaXMnKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGlmIChzcGxpdE5hbWVbMF0gPT09ICdhcnJheScpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFvYmouaGFzT3duUHJvcGVydHkocHJvcCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIG9ialtwcm9wXSA9IFtdO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIHNwbGl0TmFtZS5zaGlmdCgpO1xuICAgICAgICAgICAgICAgICAgICBhZGRQcm9wc1JlY3Vyc2l2ZWx5KG9ialtwcm9wXSwgc3BsaXROYW1lLCB0eXBlLCBkYXRhKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBpZiAoIW9iai5oYXNPd25Qcm9wZXJ0eShwcm9wKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgb2JqW3Byb3BdID0ge307XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgYWRkUHJvcHNSZWN1cnNpdmVseShvYmpbcHJvcF0sIHNwbGl0TmFtZSwgdHlwZSwgZGF0YSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG5cbiAgICB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Vuay5sZW5ndGgpO1xuICAgIHRoaXMucHVzaChjaHVuayk7XG4gICAgY2IoKTtcbn07XG5cblxuUGFzc1Rocm91Z2hTdHJlYW0ucHJvdG90eXBlLl9yZWFkID0gZnVuY3Rpb24gKG4pIHtcblxufTtcblxubW9kdWxlLmV4cG9ydHMgPSBQYXNzVGhyb3VnaFN0cmVhbTsiLCJjb25zdCBmcyA9IHJlcXVpcmUoJ2ZzJyk7XG5jb25zdCBwYXRoID0gcmVxdWlyZSgncGF0aCcpO1xuY29uc3QgeWF1emwgPSByZXF1aXJlKCd5YXV6bCcpO1xuXG5mdW5jdGlvbiBjb3VudEZpbGVzKGlucHV0UGF0aCwgY2FsbGJhY2spIHtcbiAgICBsZXQgdG90YWwgPSAwO1xuXG4gICAgZnMuc3RhdChpbnB1dFBhdGgsIChlcnIsIHN0YXRzKSA9PiB7XG4gICAgICAgIGlmIChlcnIpIHtcbiAgICAgICAgICAgIHJldHVybiBjYWxsYmFjayhlcnIpO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHN0YXRzLmlzRmlsZSgpKSB7XG4gICAgICAgICAgICByZXR1cm4gY2FsbGJhY2sodW5kZWZpbmVkLCAxKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGZzLnJlYWRkaXIoaW5wdXRQYXRoLCAoZXJyLCBmaWxlcykgPT4ge1xuICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgIHJldHVybiBjYWxsYmFjayhlcnIpO1xuICAgICAgICAgICAgfVxuXG5cbiAgICAgICAgICAgIHRvdGFsID0gZmlsZXMubGVuZ3RoO1xuICAgICAgICAgICAgbGV0IGNvdW50ID0gZmlsZXMubGVuZ3RoO1xuXG4gICAgICAgICAgICBpZiAodG90YWwgPT09IDApIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gY2FsbGJhY2sodW5kZWZpbmVkLCAwKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgZmlsZXMuZm9yRWFjaChmaWxlID0+IHtcbiAgICAgICAgICAgICAgICBmcy5zdGF0KHBhdGguam9pbihpbnB1dFBhdGgsIGZpbGUpLCAoZXJyLCBzdGF0cykgPT4ge1xuICAgICAgICAgICAgICAgICAgICBpZiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FsbGJhY2soZXJyKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIGlmIChzdGF0cy5pc0RpcmVjdG9yeSgpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAtLXRvdGFsO1xuICAgICAgICAgICAgICAgICAgICAgICAgY291bnRGaWxlcyhwYXRoLmpvaW4oaW5wdXRQYXRoLCBmaWxlKSwgKGVyciwgZmlsZXNOdW1iZXIpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjYWxsYmFjayhlcnIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvdGFsICs9IGZpbGVzTnVtYmVyO1xuXG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoLS1jb3VudCA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWxsYmFjayh1bmRlZmluZWQsIHRvdGFsKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc3RhdHMuaXNGaWxlKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAtLXRvdGFsO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoLS1jb3VudCA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrKHVuZGVmaW5lZCwgdG90YWwpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9KVxuICAgICAgICB9KTtcbiAgICB9KTtcbn1cblxuZnVuY3Rpb24gY291bnRaaXBFbnRyaWVzKGlucHV0UGF0aCwgY2FsbGJhY2spIHtcbiAgICBsZXQgcHJvY2Vzc2VkID0gMDtcblxuICAgIHlhdXpsLm9wZW4oaW5wdXRQYXRoLCB7bGF6eUVudHJpZXM6IHRydWV9LCAoZXJyLCB6aXBGaWxlKSA9PiB7XG4gICAgICAgIGlmIChlcnIpIHtcbiAgICAgICAgICAgIHJldHVybiBjYWxsYmFjayhlcnIpO1xuICAgICAgICB9XG5cbiAgICAgICAgemlwRmlsZS5yZWFkRW50cnkoKTtcbiAgICAgICAgemlwRmlsZS5vbmNlKFwiZW5kXCIsICgpID0+IHtcbiAgICAgICAgICAgIGNhbGxiYWNrKG51bGwsIHByb2Nlc3NlZCk7XG4gICAgICAgIH0pO1xuXG4gICAgICAgIHppcEZpbGUub24oXCJlbnRyeVwiLCAoZW50cnkpID0+IHtcbiAgICAgICAgICAgICsrcHJvY2Vzc2VkO1xuXG4gICAgICAgICAgICB6aXBGaWxlLnJlYWRFbnRyeSgpO1xuICAgICAgICB9KTtcbiAgICB9KTtcbn1cblxuZnVuY3Rpb24gY29tcHV0ZVNpemUoaW5wdXRQYXRoLCBjYWxsYmFjaykge1xuICAgIGxldCB0b3RhbFNpemUgPSAwO1xuICAgIGZzLnN0YXQoaW5wdXRQYXRoLCAoZXJyLCBzdGF0cykgPT4ge1xuICAgICAgICBpZiAoZXJyKSB7XG4gICAgICAgICAgICByZXR1cm4gY2FsbGJhY2soZXJyKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChzdGF0cy5pc0ZpbGUoKSkge1xuICAgICAgICAgICAgcmV0dXJuIGNhbGxiYWNrKHVuZGVmaW5lZCwgc3RhdHMuc2l6ZSk7XG4gICAgICAgIH1cblxuICAgICAgICBmcy5yZWFkZGlyKGlucHV0UGF0aCwgKGVyciwgZmlsZXMpID0+IHtcbiAgICAgICAgICAgIGlmIChlcnIpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gY2FsbGJhY2soZXJyKTtcbiAgICAgICAgICAgIH1cblxuXG4gICAgICAgICAgICBsZXQgY291bnQgPSBmaWxlcy5sZW5ndGg7XG5cbiAgICAgICAgICAgIGlmIChjb3VudCA9PT0gMCkge1xuICAgICAgICAgICAgICAgIHJldHVybiBjYWxsYmFjayh1bmRlZmluZWQsIDApO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBmaWxlcy5mb3JFYWNoKGZpbGUgPT4ge1xuICAgICAgICAgICAgICAgIGZzLnN0YXQocGF0aC5qb2luKGlucHV0UGF0aCwgZmlsZSksIChlcnIsIHN0YXRzKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjYWxsYmFjayhlcnIpO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRzLmlzRGlyZWN0b3J5KCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbXB1dGVTaXplKHBhdGguam9pbihpbnB1dFBhdGgsIGZpbGUpLCAoZXJyLCBmaWxlc1NpemUpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjYWxsYmFjayhlcnIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvdGFsU2l6ZSArPSBmaWxlc1NpemU7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoLS1jb3VudCA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWxsYmFjayh1bmRlZmluZWQsIHRvdGFsU2l6ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIHRvdGFsU2l6ZSArPSBzdGF0cy5zaXplO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoLS1jb3VudCA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrKHVuZGVmaW5lZCwgdG90YWxTaXplKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfSlcbiAgICAgICAgfSk7XG4gICAgfSk7XG59XG5cbm1vZHVsZS5leHBvcnRzID0ge1xuICAgIGNvdW50RmlsZXMsXG4gICAgY291bnRaaXBFbnRyaWVzLFxuICAgIGNvbXB1dGVTaXplXG59O1xuIiwiY29uc3QgY3J5cHRvID0gcmVxdWlyZSgnY3J5cHRvJyk7XG5jb25zdCBmcyA9IHJlcXVpcmUoJ2ZzJyk7XG5jb25zdCBwYXRoID0gcmVxdWlyZShcInBhdGhcIik7XG5jb25zdCBQc2tBcmNoaXZlciA9IHJlcXVpcmUoXCIuLi9wc2stYXJjaGl2ZXJcIik7XG5jb25zdCBhbGdvcml0aG0gPSAnYWVzLTI1Ni1nY20nO1xuXG5cbmNvbnN0IGl0ZXJhdGlvbnNfbnVtYmVyID0gMTAwMDtcblxuZnVuY3Rpb24gZW5jb2RlKGJ1ZmZlcikge1xuXHRyZXR1cm4gYnVmZmVyLnRvU3RyaW5nKCdiYXNlNjQnKVxuXHRcdC5yZXBsYWNlKC9cXCsvZywgJycpXG5cdFx0LnJlcGxhY2UoL1xcLy9nLCAnJylcbl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JlYWs7XG4gICAgICAgIGNhc2UgXCJib29sZWFuXCI6IHJldHVybiAgb2JqPyBcInRydWVcIjogXCJmYWxzZVwiOyBicmVhaztcbiAgICAgICAgY2FzZSBcImFycmF5XCI6XG4gICAgICAgICAgICB2YXIgcmVzdWx0ID0gXCJcIjtcbiAgICAgICAgICAgIGZvcih2YXIgaT0wOyBpIDwgb2JqLmxlbmd0aDsgaSsrKXtcbiAgICAgICAgICAgICAgICByZXN1bHQgKz0gZXhwb3J0cy5kdW1wT2JqZWN0Rm9ySGFzaGluZyhvYmpbaV0pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFwiVHlwZSBcIiArICB0eXBlICsgXCIgY2Fubm90IGJlIGNyeXB0b2dyYXBoaWNhbGx5IGRpZ2VzdGVkXCIpO1xuICAgIH1cblxufVxuXG5cbmV4cG9ydHMuZHVtcE9iamVjdEZvckhhc2hpbmcgPSBmdW5jdGlvbihvYmope1xuICAgIHZhciByZXN1bHQgPSBcIlwiO1xuXG4gICAgaWYob2JqID09PSBudWxsKXtcbiAgICAgICAgcmV0dXJuIFwibnVsbFwiO1xuICAgIH1cbiAgICBpZihvYmogPT09IHVuZGVmaW5lZCl7XG4gICAgICAgIHJldHVybiBcInVuZGVmaW5lZFwiO1xuICAgIH1cblxuICAgIHZhciBiYXNpY1R5cGVzID0ge1xuICAgICAgICBcImFycmF5XCIgICAgIDogdHJ1ZSxcbiAgICAgICAgXCJudW1iZXJcIiAgICA6IHRydWUsXG4gICAgICAgIFwiYm9vbGVhblwiICAgOiB0cnVlLFxuICAgICAgICBcInN0cmluZ1wiICAgIDogdHJ1ZSxcbiAgICAgICAgXCJvYmplY3RcIiAgICA6IGZhbHNlXG4gICAgfVxuXG4gICAgdmFyIHR5cGUgPSBBcnJheS5pc0FycmF5KG9ia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0ge307XG4gICAgICAgIGtleXMuZm9yRWFjaChmdW5jdGlvbihrLCBuKSB7IGVba10gPSBwW25dOyB9KTtcbiAgICAgICAgcmV0dXJuIGU7XG4gICAgfSk7XG59XG5cbm1vZHVsZS5leHBvcnRzID0gb2JqZWN0UHJvZHVjdDsiLCJ2YXIgbWV0YSA9IFwibWV0YVwiO1xuXG5mdW5jdGlvbiBPd00oc2VyaWFsaXplZCl7XG5cbiAgICBpZihzZXJpYWxpemVkKXtcbiAgICAgICAgcmV0dXJuIE93TS5wcm90b3R5cGUuY29udmVydChzZXJpYWxpemVkKTtcbiAgICB9XG5cbiAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgbWV0YSwge1xuICAgICAgICB3cml0YWJsZTogZmFsc2UsXG4gICAgICAgIGVudW1lcmFibGU6IHRydWUsXG4gICAgICAgIHZhbHVlOiB7fVxuICAgIH0pO1xuXG4gICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsIFwic2V0TWV0YVwiLCB7XG4gICAgICAgIHdyaXRhYmxlOiBmYWxzZSxcbiAgICAgICAgZW51bWVyYWJsZTogZmFsc2UsXG4gICAgICAgIGNvbmZpZ3VyYWJsZTpmYWxzZSxcbiAgICAgICAgdmFsdWU6IGZ1bmN0aW9uKHByb3AsIHZhbHVlKXtcbiAgICAgICAgICAgIGlmKHR5cGVvZiBwcm9wID09IFwib2JqZWN0XCIgJiYgdHlwZW9mIHZhbHVlID09IFwidW5kZWZpbmVkXCIpe1xuICAgICAgICAgICAgICAgIGZvcih2YXIgcCBpbiBwcm9wKXtcbiAgICAgICAgICAgICAgICAgICAgdGhpc1ttZXRhXVtwXSA9IHByb3BbcF07XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiBwcm9wO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpc1ttZXRhXVtwcm9wXSA9IHZhbHVlO1xuICAgICAgICAgICAgcmV0dXJuIHZhbHVlO1xuICAgIC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ICAgICAgICAgICB0cnl7XG4gICAgICAgICAgICAgICAgaWYodHlwZW9mIHN3YXJtID09IFwic3RyaW5nXCIpe1xuICAgICAgICAgICAgICAgICAgICBzd2FybU5hbWUgPSBzd2FybTtcbiAgICAgICAgICAgICAgICB9IGVsc2VcbiAgICAgICAgICAgICAgICBpZihzd2FybSAmJiBzd2FybS5tZXRhKXtcbiAgICAgICAgICAgICAgICAgICAgc3dhcm1OYW1lICA9IHN3YXJtLm1ldGEuc3dhcm1UeXBlTmFtZTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBzd2FybU5hbWUgPSBzd2FybS5nZXRJbm5lclZhbHVlKCkubWV0YS5zd2FybVR5cGVOYW1lO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gY2F0Y2goZXJyKXtcbiAgICAgICAgICAgICAgICBzd2FybU5hbWUgPSBlcnIudG9TdHJpbmcoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmKHByb3BlcnR5KXtcbiAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhcIldyb25nIG1lbWJlciBuYW1lIFwiLCBwcm9wZXJ0eSwgIFwiIGluIHN3YXJtIFwiLCBzd2FybU5hbWUpO1xuICAgICAgICAgICAgICAgIGlmKHRleHQpIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2codGV4dCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhcIlVua25vd24gc3dhcm1cIiwgc3dhcm1OYW1lKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICB9LFxuICAgICAgICB3YXJuaW5nOmZ1bmN0aW9uKG1zZyl7XG4gICAgICAgICAgICBjb25zb2xlLmxvZyhtc2cpO1xuICAgICAgICB9XG4gICAgfTtcblxuXG5cbiQkLnNhZmVFcnJvckhhbmRsaW5nID0gZnVuY3Rpb24oY2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WxlLmV4cG9ydHMgPSB7XG4gICAgXHRcdFx0XHRjcmVhdGVTd2FybUVuZ2luZTogcmVxdWlyZShcIi4vbGliL3N3YXJtRGVzY3JpcHRpb25cIikuY3JlYXRlU3dhcm1FbmdpbmUsXG4gICAgICAgICAgICAgICAgICAgIGNyZWF0ZUpvaW5Qb2ludDogcmVxdWlyZShcIi4vbGliL3BhcmFsbGVsSm9pblBvaW50XCIpLmNyZWF0ZUpvaW5Qb2ludCxcbiAgICAgICAgICAgICAgICAgICAgY3JlYXRlU2VyaWFsSm9pblBvaW50OiByZXF1aXJlKFwiLi9saWIvc2VyaWFsSm9pblBvaW50XCIpLmNyZWF0ZVNlcmlhbEpvaW5Qb2ludCxcbiAgICAgICAgICAgICAgICAgICAgc3dhcm1JbnN0YW5jZU1hbmFnZXI6IHJlcXVpcmUoXCIuL2xpYi9jaG9yZW9ncmFwaGllcy9zd2FybUluc3RhbmNlc01hbmFnZXJcIiksXG4gICAgICAgICAgICAgICAgICAgIGVuYWJsZUludGVybmFsU3dhcm1Sb3V0aW5nOiBmdW5jdGlvbigpe1xuICAgICAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gZHVtbXlWTShuYW1lKXtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBzb2x2ZVN3YXJtKHN3YXJtKXtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJCQuc3dhcm1zSW5zdGFuY2VzTWFuYWdlci5yZXZpdmVfc3dhcm0oc3dhcm0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICQkLlBTS19QdWJTdWIuc3Vic2NyaWJlKG5hbWUsIHNvbHZlU3dhcm0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKFwiQ3JlYXRpbmcgYSBmYWtlIGV4ZWN1dGlvbiBjb250ZXh0Li4uXCIpO1xuICAgICAgICAgICAgICAgICAg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ICAgIHZhciBsID0gcmV2ZXJzZWRUcmVlW25uXTtcbiAgICAgICAgICAgIGZvcih2YXIgaSBpbiBsKXtcbiAgICAgICAgICAgICAgICBpZighcmVzW2ldKXtcbiAgICAgICAgICAgICAgICAgICAgcmVzW2ldID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgREZTKGkpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIERGUyhub2RlTmFtZSk7XG4gICAgICAgIHJldHVybiBPYmplY3Qua2V5cyhyZXMpO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIHJlc2V0Q291bnRlcihuYW1lKXtcbiAgICAgICAgdmFyIGRlcGVuZGVuY3lBcnJheSA9IGltbWVkaWF0ZVtuYW1lXTtcbiAgICAgICAgdmFyIGNvdW50ZXIgPSAwO1xuICAgICAgICBpZihkZXBlbmRlbmN5QXJyYXkpe1xuICAgICAgICAgICAgZGVwZW5kZW5jeUFycmF5LmZvckVhY2goZnVuY3Rpb24oZGVwKXtcbiAgICAgICAgICAgICAgICBpZih0aGluZ3NbZGVwXSA9PSBudWxsKXtcbiAgICAgICAgICAgICAgICAgICAgaW5jQ291bnRlcihuYW1lKTtcbiAgICAgICAgICAgICAgICAgICAgY291bnRlcisrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICAgIGRlcHNDb3VudGVyW25hbWVdID0gY291bnRlcjtcbiAgICAgICAgLy9jb25zb2xlLmxvZyhcIkNvdW50ZXIgZm9yIFwiLCBuYW1lLCAnIGlzICcsIGNvdW50ZXIpO1xuICAgICAgICByZXR1cm4gY291bnRlcjtcbiAgICB9XG5cbiAgICAvKiByZXR1cm5zIHRob3NlIHRoYXQgYXJlIHJlYWR5IHRvIGJlIHJlc29sdmVkKi9cbiAgICBmdW5jdGlvbiByZXNldFVwQ291bnRlcnMobmFtZSl7XG4gICAgICAgIHZhciByZXQgPSB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ZTZXJ2aWNlKTtcbiAgICAgICAgdHJ5e1xuICAgICAgICAgICAgdmFyIHZhbHVlID0gY2FsbGJhY2tzW25hbWVdLmFwcGx5KHt9LGFyZ3MpO1xuICAgICAgICB9IGNhdGNoKGVycil7XG4gICAgICAgICAgICBlcnJvckhhbmRsZXIudGhyb3dFcnJvcihlcnIpO1xuICAgICAgICB9XG5cblxuICAgICAgICBpZihvdXRPZlNlcnZpY2UgfHwgdmFsdWU9PT1udWxsKXsgICAvL2VuYWJsZSByZXR1cm5pbmcgYSB0ZW1wb3JhcnkgZGVwZW5kZW5jeSByZXNvbHV0aW9uIVxuICAgICAgICAgICAgaWYodGhpbmdzW25hbWVdKXtcbiAgICAgICAgICAgICAgICB0aGluZ3NbbmFtZV0gPSBudWxsO1xuICAgICAgICAgICAgICAgIHJlc2V0VXBDb3VudGVycyhuYW1lKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIC8vY29uc29sZS5sb2coXCJTdWNjZXNzIHJlc29sdmluZyBcIiwgbmFtZSwgXCI6XCIsIHZhbHVlLCBcIk90aGVyIHJlYWR5OlwiLCBvdGhlclJlYWR5KTtcbiAgICAgICAgICAgIGlmKCF2YWx1ZSl7XG4gICAgICAgICAgICAgICAgdmFsdWUgPSAge1wicGxhY2Vob2xkZXJcIjogbmFtZX07XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGluZ3NbbmFtZV0gPSB2YWx1ZTtcbiAgICAgICAgICAgIHZhciBvdGhlclJlYWR5ID0gcmVzZXRVcENvdW50ZXJzKG5hbWUpO1xuICAgICAgICAgICAgb3RoZXJSZWFkeS5mb3JFYWNoKGZ1bmN0aW9uKGl0ZW0pe1xuICAgICAgICAgICAgICAgIGNhbGxGb3JUaGluZyhpdGVtLCBmYWxzZSk7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIC8qXG4gICAgICAgIERlY2xhcmUgdGhhdCBhIG5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NcIik7XG5cbm1vZHVsZS5leHBvcnRzLnVpZEdlbmVyYXRvciA9IHVpZEdlbmVyYXRvcjtcbm1vZHVsZS5leHBvcnRzLmdlbmVyYXRlVWlkID0gdWlkR2VuZXJhdG9yLmdlbmVyYXRlVWlkO1xuXG5tb2R1bGUuZXhwb3J0cy5jcmVhdGVQc2tDb25zb2xlID0gZnVuY3Rpb24gKCkge1xuICByZXR1cm4gcmVxdWlyZSgnLi9saWIvcHNrY29uc29sZScpO1xufTtcblxuXG5pZih0eXBlb2YgZ2xvYmFsLiQkID09IFwidW5kZWZpbmVkXCIpe1xuICBnbG9iYWwuJCQgPSB7fTtcbn1cblxuaWYodHlwZW9mIGdsb2JhbC4kJC51aWRHZW5lcmF0b3IgPT0gXCJ1bmRlZmluZWRcIil7XG4gICAgJCQudWlkR2VuZXJhdG9yID0gbW9kdWxlLmV4cG9ydHMuc2FmZV91dWlkO1xufVxuIiwiZXhwb3J0cy5mc0V4dCA9IHJlcXVpcmUoXCIuL0ZTRXh0ZW5zaW9uXCIpLmZzRXh0OyJdfQ== diff --git a/psknode/bundles/readme.txt b/psknode/bundles/readme.txt deleted file mode 100644 index 9f2f528..0000000 --- a/psknode/bundles/readme.txt +++ /dev/null @@ -1 +0,0 @@ -privatesky standard bundles here \ No newline at end of file diff --git a/psknode/core/launcher.js b/psknode/core/launcher.js index 9af8238..147b92e 100644 --- a/psknode/core/launcher.js +++ b/psknode/core/launcher.js @@ -65,12 +65,15 @@ function launchDomainSandbox(name, configuration) { child_env.config = JSON.stringify(env.config); child_env.PRIVATESKY_TMP = process.env.PRIVATESKY_TMP; child_env.PRIVATESKY_ROOT_FOLDER = process.env.PRIVATESKY_ROOT_FOLDER; + const child = childProcess.fork('sandboxes/domainSandbox.js', [name], {cwd: __dirname, env: child_env}); child.on('exit', (code, signal) => { - console.log(`DomainSandbox [${name}] got an error code ${code}. Restarting...`); - delete domainSandboxes[name]; - launchDomainSandbox(name, configuration); - }); + setTimeout(()=>{ + console.log(`DomainSandbox [${name}] got an error code ${code}. Restarting...`); + delete domainSandboxes[name]; + launchDomainSandbox(name, configuration); + }, 100); + }); domainSandboxes[name] = child; } else { diff --git a/psknode/core/utils/exitHandler.js b/psknode/core/utils/exitHandler.js index 57f68fb..d08ce47 100644 --- a/psknode/core/utils/exitHandler.js +++ b/psknode/core/utils/exitHandler.js @@ -2,13 +2,29 @@ const events = ["exit", "SIGINT", "SIGUSR1", "SIGUSR2", "uncaughtException", "SI module.exports = function manageShutdownProcess(childrenList){ + let shutting = false; function handler(){ - console.log("Handling exit event on", process.pid, "arguments:", arguments); + //console.log("Handling exit event on", process.pid, "arguments:", arguments); var childrenNames = Object.keys(childrenList); for(let j=0; j{