From 52967d7f9db663ff94c4ddb8158a7f72a9ccc48a Mon Sep 17 00:00:00 2001 From: danielyxie Date: Wed, 1 Nov 2017 17:56:30 -0500 Subject: [PATCH] Refactored Code using Bluebird Promises. Still has memory issues. Added Buy Max and Sell All to stock market UI --- dist/bundle.js | 11337 +++++++++++++++++++++++++++--------- src/CompanyManagement.js | 201 + src/NetscriptEvaluator.js | 880 ++- src/NetscriptFunctions.js | 41 +- src/NetscriptWorker.js | 21 +- src/StockMarket.js | 80 +- utils/YesNoBox.js | 2 + 7 files changed, 9443 insertions(+), 3119 deletions(-) diff --git a/dist/bundle.js b/dist/bundle.js index d27a59fd7..7ec09cb3d 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -75,16 +75,16 @@ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Company_js__ = __webpack_require__(21); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Constants_js__ = __webpack_require__(3); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__CreateProgram_js__ = __webpack_require__(15); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Crimes_js__ = __webpack_require__(31); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Crimes_js__ = __webpack_require__(32); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__engine_js__ = __webpack_require__(5); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Faction_js__ = __webpack_require__(10); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Gang_js__ = __webpack_require__(33); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Gang_js__ = __webpack_require__(34); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__Location_js__ = __webpack_require__(13); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__NetscriptFunctions_js__ = __webpack_require__(19); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__Server_js__ = __webpack_require__(6); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__SpecialServerIps_js__ = __webpack_require__(12); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__SourceFile_js__ = __webpack_require__(34); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__utils_decimal_js__ = __webpack_require__(27); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__SourceFile_js__ = __webpack_require__(35); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__utils_decimal_js__ = __webpack_require__(28); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__utils_decimal_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_14__utils_decimal_js__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__utils_DialogBox_js__ = __webpack_require__(1); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__utils_HelperFunctions_js__ = __webpack_require__(2); @@ -3844,12 +3844,12 @@ function isHTML(str) { Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return Engine; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__utils_DialogBox_js__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__utils_GameOptions_js__ = __webpack_require__(39); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__utils_GameOptions_js__ = __webpack_require__(40); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__ = __webpack_require__(2); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__utils_numeral_min_js__ = __webpack_require__(18); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__utils_numeral_min_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3__utils_numeral_min_js__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__utils_StringHelperFunctions_js__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__utils_LogBox_js__ = __webpack_require__(29); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__utils_LogBox_js__ = __webpack_require__(30); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__ActiveScriptsUI_js__ = __webpack_require__(25); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Augmentations_js__ = __webpack_require__(20); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__BitNode_js__ = __webpack_require__(7); @@ -3858,24 +3858,24 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__CreateProgram_js__ = __webpack_require__(15); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__Faction_js__ = __webpack_require__(10); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__Location_js__ = __webpack_require__(13); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__Gang_js__ = __webpack_require__(33); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__HacknetNode_js__ = __webpack_require__(38); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__InteractiveTutorial_js__ = __webpack_require__(26); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__Literature_js__ = __webpack_require__(45); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__Gang_js__ = __webpack_require__(34); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__HacknetNode_js__ = __webpack_require__(39); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__InteractiveTutorial_js__ = __webpack_require__(27); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__Literature_js__ = __webpack_require__(46); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__Message_js__ = __webpack_require__(24); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__Missions_js__ = __webpack_require__(32); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__Missions_js__ = __webpack_require__(26); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_20__NetscriptFunctions_js__ = __webpack_require__(19); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_21__NetscriptWorker_js__ = __webpack_require__(11); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_22__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_23__Prestige_js__ = __webpack_require__(35); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_24__RedPill_js__ = __webpack_require__(36); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_25__SaveObject_js__ = __webpack_require__(71); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_23__Prestige_js__ = __webpack_require__(36); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_24__RedPill_js__ = __webpack_require__(37); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_25__SaveObject_js__ = __webpack_require__(75); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_26__Script_js__ = __webpack_require__(16); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_27__Server_js__ = __webpack_require__(6); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_28__Settings_js__ = __webpack_require__(14); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_29__SourceFile_js__ = __webpack_require__(34); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_29__SourceFile_js__ = __webpack_require__(35); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_30__SpecialServerIps_js__ = __webpack_require__(12); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_31__StockMarket_js__ = __webpack_require__(28); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_31__StockMarket_js__ = __webpack_require__(29); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_32__Terminal_js__ = __webpack_require__(23); @@ -17016,13 +17016,13 @@ return jQuery; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__BitNode_js__ = __webpack_require__(7); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Constants_js__ = __webpack_require__(3); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__engine_js__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__FactionInfo_js__ = __webpack_require__(50); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__FactionInfo_js__ = __webpack_require__(52); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Location_js__ = __webpack_require__(13); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Missions_js__ = __webpack_require__(32); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Missions_js__ = __webpack_require__(26); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Player_js__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Settings_js__ = __webpack_require__(14); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__utils_DialogBox_js__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__utils_FactionInvitationBox_js__ = __webpack_require__(52); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__utils_FactionInvitationBox_js__ = __webpack_require__(54); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__ = __webpack_require__(2); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__utils_JSONReviver_js__ = __webpack_require__(8); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__utils_StringHelperFunctions_js__ = __webpack_require__(4); @@ -18088,11 +18088,11 @@ function processPassiveFactionRepGain(numCycles) { /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__ActiveScriptsUI_js__ = __webpack_require__(25); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Constants_js__ = __webpack_require__(3); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__engine_js__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__NetscriptEnvironment_js__ = __webpack_require__(30); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__NetscriptEvaluator_js__ = __webpack_require__(37); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__NetscriptEnvironment_js__ = __webpack_require__(31); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__NetscriptEvaluator_js__ = __webpack_require__(38); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Server_js__ = __webpack_require__(6); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Settings_js__ = __webpack_require__(14); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_acorn_js__ = __webpack_require__(46); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_acorn_js__ = __webpack_require__(47); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_acorn_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_7__utils_acorn_js__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_DialogBox_js__ = __webpack_require__(1); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__utils_HelperFunctions_js__ = __webpack_require__(2); @@ -18120,7 +18120,8 @@ function WorkerScript(runningScriptObj) { this.scriptRef = runningScriptObj; this.errorMessage = ""; this.args = runningScriptObj.args; - this.killTrigger = function() {}; //CB func used to clear any delays (netscriptDelay()) + //this.killTrigger = function() {}; //CB func used to clear any delays (netscriptDelay()) + this.delay = null; this.fnWorker = null; //Workerscript for a function call } @@ -18189,7 +18190,7 @@ function runScriptsLoop() { if (workerScripts[i].running == false && workerScripts[i].env.stopFlag == false) { try { var ast = Object(__WEBPACK_IMPORTED_MODULE_7__utils_acorn_js__["parse"])(workerScripts[i].code); - //console.log(ast); + console.log(ast); } catch (e) { console.log("Error parsing script: " + workerScripts[i].name); Object(__WEBPACK_IMPORTED_MODULE_8__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Syntax ERROR in " + workerScripts[i].name + ":
" + e); @@ -18206,8 +18207,8 @@ function runScriptsLoop() { w.running = false; w.env.stopFlag = true; w.scriptRef.log("Script finished running"); - }, function(w) { - //console.log(w); + }).catch(function(w) { + console.log(w); if (w instanceof Error) { Object(__WEBPACK_IMPORTED_MODULE_8__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Script runtime unknown error. This is a bug please contact game developer"); console.log("ERROR: Evaluating workerscript returns an Error. THIS SHOULDN'T HAPPEN: " + w.toString()); @@ -18261,11 +18262,16 @@ function killWorkerScript(runningScriptObj, serverIp) { if (workerScripts[i].name == runningScriptObj.filename && workerScripts[i].serverIp == serverIp && Object(__WEBPACK_IMPORTED_MODULE_9__utils_HelperFunctions_js__["c" /* compareArrays */])(workerScripts[i].args, runningScriptObj.args)) { workerScripts[i].env.stopFlag = true; - workerScripts[i].killTrigger(); + Object(__WEBPACK_IMPORTED_MODULE_4__NetscriptEvaluator_js__["c" /* killNetscriptDelay */])(workerScripts[i]); + if (workerScripts[i].fnWorker) { + workerScripts[i].fnWorker.env.stopFlag = true; + Object(__WEBPACK_IMPORTED_MODULE_4__NetscriptEvaluator_js__["c" /* killNetscriptDelay */])(workerScripts[i].fnWorker); + } + /*workerScripts[i].killTrigger(); if (workerScripts[i].fnWorker) { workerScripts[i].fnWorker.env.stopFlag = true; workerScripts[i].fnWorker.killTrigger(); - } + }*/ return true; } } @@ -18391,12 +18397,12 @@ function initSpecialServerIps() { /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return initLocationButtons; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Company_js__ = __webpack_require__(21); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Constants_js__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Crimes_js__ = __webpack_require__(31); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Crimes_js__ = __webpack_require__(32); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__engine_js__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Infiltration_js__ = __webpack_require__(48); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Infiltration_js__ = __webpack_require__(50); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Player_js__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Server_js__ = __webpack_require__(6); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__ServerPurchases_js__ = __webpack_require__(69); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__ServerPurchases_js__ = __webpack_require__(70); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__SpecialServerIps_js__ = __webpack_require__(12); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__utils_DialogBox_js__ = __webpack_require__(1); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__utils_HelperFunctions_js__ = __webpack_require__(2); @@ -20796,7 +20802,7 @@ function initCreateProgramButtons() { /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return AllServersMap; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Constants_js__ = __webpack_require__(3); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__engine_js__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__InteractiveTutorial_js__ = __webpack_require__(26); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__InteractiveTutorial_js__ = __webpack_require__(27); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__NetscriptFunctions_js__ = __webpack_require__(19); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__ = __webpack_require__(11); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Player_js__ = __webpack_require__(0); @@ -20806,8 +20812,7 @@ function initCreateProgramButtons() { /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__ = __webpack_require__(8); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__utils_HelperFunctions_js__ = __webpack_require__(2); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__ = __webpack_require__(4); -var ace = __webpack_require__(53); -__webpack_require__(56); +var ace = __webpack_require__(55); __webpack_require__(57); __webpack_require__(58); __webpack_require__(59); @@ -20820,6 +20825,7 @@ __webpack_require__(65); __webpack_require__(66); __webpack_require__(67); __webpack_require__(68); +__webpack_require__(69); @@ -21536,35 +21542,39 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! @preserve /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__ActiveScriptsUI_js__ = __webpack_require__(25); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Augmentations_js__ = __webpack_require__(20); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__BitNode_js__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Crimes_js__ = __webpack_require__(31); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Crimes_js__ = __webpack_require__(32); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Company_js__ = __webpack_require__(21); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Constants_js__ = __webpack_require__(3); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__ = __webpack_require__(15); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__ = __webpack_require__(44); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__ = __webpack_require__(45); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__engine_js__ = __webpack_require__(5); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__Faction_js__ = __webpack_require__(10); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__HacknetNode_js__ = __webpack_require__(38); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__HacknetNode_js__ = __webpack_require__(39); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__Location_js__ = __webpack_require__(13); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__Message_js__ = __webpack_require__(24); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__Script_js__ = __webpack_require__(16); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__Server_js__ = __webpack_require__(6); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__Settings_js__ = __webpack_require__(14); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__SpecialServerIps_js__ = __webpack_require__(12); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__ = __webpack_require__(28); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__Terminal_js__ = __webpack_require__(23); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_20__TextFile_js__ = __webpack_require__(47); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_21__NetscriptWorker_js__ = __webpack_require__(11); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__ = __webpack_require__(37); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_23__NetscriptEnvironment_js__ = __webpack_require__(30); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_24__utils_decimal_js__ = __webpack_require__(27); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_24__utils_decimal_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_24__utils_decimal_js__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_25__utils_DialogBox_js__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_26__utils_HelperFunctions_js__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_27__utils_IPAddress_js__ = __webpack_require__(17); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__ = __webpack_require__(4); -var sprintf = __webpack_require__(40).sprintf, - vsprintf = __webpack_require__(40).vsprintf +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__Missions_js__ = __webpack_require__(26); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__Player_js__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__Script_js__ = __webpack_require__(16); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__Server_js__ = __webpack_require__(6); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__Settings_js__ = __webpack_require__(14); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__SpecialServerIps_js__ = __webpack_require__(12); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__StockMarket_js__ = __webpack_require__(29); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_20__Terminal_js__ = __webpack_require__(23); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_21__TextFile_js__ = __webpack_require__(49); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_22__NetscriptWorker_js__ = __webpack_require__(11); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__ = __webpack_require__(38); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_24__NetscriptEnvironment_js__ = __webpack_require__(31); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_25__utils_decimal_js__ = __webpack_require__(28); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_25__utils_decimal_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_25__utils_decimal_js__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_26__utils_DialogBox_js__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_27__utils_HelperFunctions_js__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_28__utils_IPAddress_js__ = __webpack_require__(17); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_30__utils_YesNoBox_js__ = __webpack_require__(22); +var sprintf = __webpack_require__(41).sprintf, + vsprintf = __webpack_require__(41).vsprintf + + @@ -21603,19 +21613,19 @@ var singularitySFLvl=1, wallStreetSFLvl=1; //Used to check and set flags for every Source File, despite the name of the function function initSingularitySFFlags() { - for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].sourceFiles.length; ++i) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].sourceFiles[i].n === 4) { + for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].sourceFiles.length; ++i) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].sourceFiles[i].n === 4) { hasSingularitySF = true; - singularitySFLvl = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].sourceFiles[i].lvl; + singularitySFLvl = __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].sourceFiles[i].lvl; } - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].sourceFiles[i].n === 5) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].sourceFiles[i].n === 5) { hasAISF = true; } - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].sourceFiles[i].n === 8) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].sourceFiles[i].n === 8) { hasWallStreetSF = true; - wallStreetSFLvl = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].sourceFiles[i].lvl; + wallStreetSFLvl = __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].sourceFiles[i].lvl; } - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].sourceFiles[i].n === 11) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].sourceFiles[i].n === 11) { hasBn11SF = true; } } @@ -21625,13 +21635,13 @@ function NetscriptFunctions(workerScript) { return { Math : Math, Date : Date, - hacknetnodes : __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacknetNodes, + hacknetnodes : __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hacknetNodes, sprintf : sprintf, vsprintf: vsprintf, scan : function(ip=workerScript.serverIp, hostnames=true){ - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, 'Invalid IP or hostname passed into scan() command'); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, 'Invalid IP or hostname passed into scan() command'); } var out = []; for (var i = 0; i < server.serversOnNetwork.length; i++) { @@ -21651,40 +21661,40 @@ function NetscriptFunctions(workerScript) { }, hack : function(ip){ if (ip === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Hack() call has incorrect number of arguments. Takes 1 argument"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Hack() call has incorrect number of arguments. Takes 1 argument"); } var threads = workerScript.scriptRef.threads; if (isNaN(threads) || threads < 1) {threads = 1;} - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("hack() error. Invalid IP or hostname passed in: " + ip + ". Stopping..."); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "hack() error. Invalid IP or hostname passed in: " + ip + ". Stopping..."); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "hack() error. Invalid IP or hostname passed in: " + ip + ". Stopping..."); } //Calculate the hacking time - var hackingTime = Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["i" /* scriptCalculateHackingTime */])(server); //This is in seconds + var hackingTime = Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["j" /* scriptCalculateHackingTime */])(server); //This is in seconds //No root access or skill level too low if (server.hasAdminRights == false) { workerScript.scriptRef.log("Cannot hack this server (" + server.hostname + ") because user does not have root access"); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot hack this server (" + server.hostname + ") because user does not have root access"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot hack this server (" + server.hostname + ") because user does not have root access"); } - if (server.requiredHackingSkill > __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill) { + if (server.requiredHackingSkill > __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hacking_skill) { workerScript.scriptRef.log("Cannot hack this server (" + server.hostname + ") because user's hacking skill is not high enough"); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot hack this server (" + server.hostname + ") because user's hacking skill is not high enough"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot hack this server (" + server.hostname + ") because user's hacking skill is not high enough"); } workerScript.scriptRef.log("Attempting to hack " + ip + " in " + hackingTime.toFixed(3) + " seconds (t=" + threads + ")"); //console.log("Hacking " + server.hostname + " after " + hackingTime.toString() + " seconds (t=" + threads + ")"); - return Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["d" /* netscriptDelay */])(hackingTime* 1000, workerScript).then(function() { + return Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["e" /* netscriptDelay */])(hackingTime* 1000, workerScript).then(function() { if (workerScript.env.stopFlag) {return Promise.reject(workerScript);} - var hackChance = Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["h" /* scriptCalculateHackingChance */])(server); + var hackChance = Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["i" /* scriptCalculateHackingChance */])(server); var rand = Math.random(); - var expGainedOnSuccess = Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["f" /* scriptCalculateExpGain */])(server) * threads; + var expGainedOnSuccess = Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["g" /* scriptCalculateExpGain */])(server) * threads; var expGainedOnFailure = (expGainedOnSuccess / 4); if (rand < hackChance) { //Success! - var moneyGained = Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["j" /* scriptCalculatePercentMoneyHacked */])(server); + var moneyGained = Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["k" /* scriptCalculatePercentMoneyHacked */])(server); moneyGained = Math.floor(server.moneyAvailable * moneyGained) * threads; //Over-the-top safety checks @@ -21696,34 +21706,34 @@ function NetscriptFunctions(workerScript) { server.moneyAvailable -= moneyGained; if (server.moneyAvailable < 0) {server.moneyAvailable = 0;} - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainMoney(moneyGained); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].gainMoney(moneyGained); workerScript.scriptRef.onlineMoneyMade += moneyGained; - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].scriptProdSinceLastAug += moneyGained; + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].scriptProdSinceLastAug += moneyGained; workerScript.scriptRef.recordHack(server.ip, moneyGained, threads); - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainHackingExp(expGainedOnSuccess); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].gainHackingExp(expGainedOnSuccess); workerScript.scriptRef.onlineExpGained += expGainedOnSuccess; //console.log("Script successfully hacked " + server.hostname + " for $" + formatNumber(moneyGained, 2) + " and " + formatNumber(expGainedOnSuccess, 4) + " exp"); - workerScript.scriptRef.log("Script SUCCESSFULLY hacked " + server.hostname + " for $" + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(moneyGained, 2) + " and " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(expGainedOnSuccess, 4) + " exp (t=" + threads + ")"); + workerScript.scriptRef.log("Script SUCCESSFULLY hacked " + server.hostname + " for $" + Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["c" /* formatNumber */])(moneyGained, 2) + " and " + Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["c" /* formatNumber */])(expGainedOnSuccess, 4) + " exp (t=" + threads + ")"); server.fortify(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ServerFortifyAmount * threads); return Promise.resolve(true); } else { //Player only gains 25% exp for failure? TODO Can change this later to balance - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainHackingExp(expGainedOnFailure); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].gainHackingExp(expGainedOnFailure); workerScript.scriptRef.onlineExpGained += expGainedOnFailure; //console.log("Script unsuccessful to hack " + server.hostname + ". Gained " + formatNumber(expGainedOnFailure, 4) + " exp"); - workerScript.scriptRef.log("Script FAILED to hack " + server.hostname + ". Gained " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(expGainedOnFailure, 4) + " exp (t=" + threads + ")"); + workerScript.scriptRef.log("Script FAILED to hack " + server.hostname + ". Gained " + Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["c" /* formatNumber */])(expGainedOnFailure, 4) + " exp (t=" + threads + ")"); return Promise.resolve(false); } }); }, sleep : function(time,log=true){ if (time === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "sleep() call has incorrect number of arguments. Takes 1 argument"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "sleep() call has incorrect number of arguments. Takes 1 argument"); } if (log) { workerScript.scriptRef.log("Sleeping for " + time + " milliseconds"); } - return Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["d" /* netscriptDelay */])(time, workerScript).then(function() { + return Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["e" /* netscriptDelay */])(time, workerScript).then(function() { return Promise.resolve(true); }); }, @@ -21731,37 +21741,37 @@ function NetscriptFunctions(workerScript) { var threads = workerScript.scriptRef.threads; if (isNaN(threads) || threads < 1) {threads = 1;} if (ip === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "grow() call has incorrect number of arguments. Takes 1 argument"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "grow() call has incorrect number of arguments. Takes 1 argument"); } - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("Cannot grow(). Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot grow(). Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot grow(). Invalid IP or hostname passed in: " + ip); } //No root access or skill level too low if (server.hasAdminRights == false) { workerScript.scriptRef.log("Cannot grow this server (" + server.hostname + ") because user does not have root access"); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot grow this server (" + server.hostname + ") because user does not have root access"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot grow this server (" + server.hostname + ") because user does not have root access"); } - var growTime = Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["g" /* scriptCalculateGrowTime */])(server); + var growTime = Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["h" /* scriptCalculateGrowTime */])(server); //console.log("Executing grow() on server " + server.hostname + " in " + formatNumber(growTime/1000, 3) + " seconds") - workerScript.scriptRef.log("Executing grow() on server " + server.hostname + " in " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(growTime/1000, 3) + " seconds (t=" + threads + ")"); - return Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["d" /* netscriptDelay */])(growTime, workerScript).then(function() { + workerScript.scriptRef.log("Executing grow() on server " + server.hostname + " in " + Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["c" /* formatNumber */])(growTime/1000, 3) + " seconds (t=" + threads + ")"); + return Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["e" /* netscriptDelay */])(growTime, workerScript).then(function() { if (workerScript.env.stopFlag) {return Promise.reject(workerScript);} server.moneyAvailable += (1 * threads); //It can be grown even if it has no money - var growthPercentage = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["j" /* processSingleServerGrowth */])(server, 450 * threads); + var growthPercentage = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["j" /* processSingleServerGrowth */])(server, 450 * threads); workerScript.scriptRef.recordGrow(server.ip, threads); - var expGain = Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["f" /* scriptCalculateExpGain */])(server) * threads; + var expGain = Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["g" /* scriptCalculateExpGain */])(server) * threads; if (growthPercentage == 1) { expGain = 0; } workerScript.scriptRef.log("Available money on " + server.hostname + " grown by " - + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(growthPercentage*100 - 100, 6) + "%. Gained " + - Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(expGain, 4) + " hacking exp (t=" + threads +")"); + + Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["c" /* formatNumber */])(growthPercentage*100 - 100, 6) + "%. Gained " + + Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["c" /* formatNumber */])(expGain, 4) + " hacking exp (t=" + threads +")"); workerScript.scriptRef.onlineExpGained += expGain; - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainHackingExp(expGain); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].gainHackingExp(expGain); return Promise.resolve(growthPercentage); }); }, @@ -21769,72 +21779,72 @@ function NetscriptFunctions(workerScript) { var threads = workerScript.scriptRef.threads; if (isNaN(threads) || threads < 1) {threads = 1;} if (ip === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "weaken() call has incorrect number of arguments. Takes 1 argument"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "weaken() call has incorrect number of arguments. Takes 1 argument"); } - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("Cannot weaken(). Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot weaken(). Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot weaken(). Invalid IP or hostname passed in: " + ip); } //No root access or skill level too low if (server.hasAdminRights == false) { workerScript.scriptRef.log("Cannot weaken this server (" + server.hostname + ") because user does not have root access"); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot weaken this server (" + server.hostname + ") because user does not have root access"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot weaken this server (" + server.hostname + ") because user does not have root access"); } - var weakenTime = Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["k" /* scriptCalculateWeakenTime */])(server); + var weakenTime = Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["l" /* scriptCalculateWeakenTime */])(server); workerScript.scriptRef.log("Executing weaken() on server " + server.hostname + " in " + - Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(weakenTime/1000, 3) + " seconds (t=" + threads + ")"); - return Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["d" /* netscriptDelay */])(weakenTime, workerScript).then(function() { + Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["c" /* formatNumber */])(weakenTime/1000, 3) + " seconds (t=" + threads + ")"); + return Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["e" /* netscriptDelay */])(weakenTime, workerScript).then(function() { if (workerScript.env.stopFlag) {return Promise.reject(workerScript);} server.weaken(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ServerWeakenAmount * threads); workerScript.scriptRef.recordWeaken(server.ip, threads); - var expGain = Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["f" /* scriptCalculateExpGain */])(server) * threads; + var expGain = Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["g" /* scriptCalculateExpGain */])(server) * threads; workerScript.scriptRef.log("Server security level on " + server.hostname + " weakened to " + server.hackDifficulty + - ". Gained " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(expGain, 4) + " hacking exp (t=" + threads + ")"); + ". Gained " + Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["c" /* formatNumber */])(expGain, 4) + " hacking exp (t=" + threads + ")"); workerScript.scriptRef.onlineExpGained += expGain; - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainHackingExp(expGain); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].gainHackingExp(expGain); return Promise.resolve(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ServerWeakenAmount * threads); }); }, print : function(args){ if (args === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "print() call has incorrect number of arguments. Takes 1 argument"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "print() call has incorrect number of arguments. Takes 1 argument"); } workerScript.scriptRef.log(args.toString()); }, tprint : function(args) { if (args === undefined || args == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "tprint() call has incorrect number of arguments. Takes 1 argument"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "tprint() call has incorrect number of arguments. Takes 1 argument"); } var x = args.toString(); - if (Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["d" /* isHTML */])(x)) { - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].takeDamage(1); - Object(__WEBPACK_IMPORTED_MODULE_25__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You suddenly feel a sharp shooting pain through your body as an angry voice in your head exclaims:

" + + if (Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["d" /* isHTML */])(x)) { + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].takeDamage(1); + Object(__WEBPACK_IMPORTED_MODULE_26__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You suddenly feel a sharp shooting pain through your body as an angry voice in your head exclaims:

" + "DON'T USE TPRINT() TO OUTPUT HTML ELEMENTS TO YOUR TERMINAL!!!!

" + "(You lost 1 HP)"); return; } - Object(__WEBPACK_IMPORTED_MODULE_19__Terminal_js__["b" /* post */])(workerScript.scriptRef.filename + ": " + args.toString()); + Object(__WEBPACK_IMPORTED_MODULE_20__Terminal_js__["b" /* post */])(workerScript.scriptRef.filename + ": " + args.toString()); }, clearLog : function() { workerScript.scriptRef.clearLog(); }, nuke : function(ip){ if (ip === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument"); } - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("Cannot call nuke(). Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot call nuke(). Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot call nuke(). Invalid IP or hostname passed in: " + ip); } - if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasProgram(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].NukeProgram)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You do not have the NUKE.exe virus!"); + if (!__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hasProgram(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].NukeProgram)) { + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "You do not have the NUKE.exe virus!"); } if (server.openPortCount < server.numOpenPortsRequired) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Not enough ports opened to use NUKE.exe virus"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Not enough ports opened to use NUKE.exe virus"); } if (server.hasAdminRights) { workerScript.scriptRef.log("Already have root access to " + server.hostname); @@ -21846,16 +21856,16 @@ function NetscriptFunctions(workerScript) { }, brutessh : function(ip){ if (ip === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument"); } - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("Cannot call brutessh(). Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot call brutessh(). Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot call brutessh(). Invalid IP or hostname passed in: " + ip); } - if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasProgram(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].BruteSSHProgram)) { + if (!__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hasProgram(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].BruteSSHProgram)) { workerScript.scriptRef.log("You do not have the BruteSSH.exe program!"); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You do not have the BruteSSH.exe program!"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "You do not have the BruteSSH.exe program!"); } if (!server.sshPortOpen) { workerScript.scriptRef.log("Executed BruteSSH.exe on " + server.hostname + " to open SSH port (22)"); @@ -21868,15 +21878,15 @@ function NetscriptFunctions(workerScript) { }, ftpcrack : function(ip){ if (ip === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument"); } - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("Cannot call ftpcrack(). Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot call ftpcrack(). Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot call ftpcrack(). Invalid IP or hostname passed in: " + ip); } - if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasProgram(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].FTPCrackProgram)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You do not have the FTPCrack.exe program!"); + if (!__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hasProgram(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].FTPCrackProgram)) { + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "You do not have the FTPCrack.exe program!"); } if (!server.ftpPortOpen) { workerScript.scriptRef.log("Executed FTPCrack.exe on " + server.hostname + " to open FTP port (21)"); @@ -21889,15 +21899,15 @@ function NetscriptFunctions(workerScript) { }, relaysmtp : function(ip){ if (ip === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument"); } - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("Cannot call relaysmtp(). Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot call relaysmtp(). Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot call relaysmtp(). Invalid IP or hostname passed in: " + ip); } - if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasProgram(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].RelaySMTPProgram)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You do not have the relaySMTP.exe program!"); + if (!__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hasProgram(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].RelaySMTPProgram)) { + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "You do not have the relaySMTP.exe program!"); } if (!server.smtpPortOpen) { workerScript.scriptRef.log("Executed relaySMTP.exe on " + server.hostname + " to open SMTP port (25)"); @@ -21910,15 +21920,15 @@ function NetscriptFunctions(workerScript) { }, httpworm : function(ip){ if (ip === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument"); } - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("Cannot call httpworm(). Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot call httpworm(). Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot call httpworm(). Invalid IP or hostname passed in: " + ip); } - if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasProgram(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].HTTPWormProgram)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You do not have the HTTPWorm.exe program!"); + if (!__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hasProgram(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].HTTPWormProgram)) { + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "You do not have the HTTPWorm.exe program!"); } if (!server.httpPortOpen) { workerScript.scriptRef.log("Executed HTTPWorm.exe on " + server.hostname + " to open HTTP port (80)"); @@ -21931,15 +21941,15 @@ function NetscriptFunctions(workerScript) { }, sqlinject : function(ip){ if (ip === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument"); } - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("Cannot call sqlinject(). Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot call sqlinject(). Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot call sqlinject(). Invalid IP or hostname passed in: " + ip); } - if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasProgram(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].SQLInjectProgram)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You do not have the SQLInject.exe program!"); + if (!__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hasProgram(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].SQLInjectProgram)) { + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "You do not have the SQLInject.exe program!"); } if (!server.sqlPortOpen) { workerScript.scriptRef.log("Executed SQLInject.exe on " + server.hostname + " to open SQL port (1433)"); @@ -21952,84 +21962,84 @@ function NetscriptFunctions(workerScript) { }, run : function(scriptname,threads = 1){ if (scriptname === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "run() call has incorrect number of arguments. Usage: run(scriptname, [numThreads], [arg1], [arg2]...)"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "run() call has incorrect number of arguments. Usage: run(scriptname, [numThreads], [arg1], [arg2]...)"); } if (isNaN(threads) || threads < 1) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid argument for thread count passed into run(). Must be numeric and greater than 0"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Invalid argument for thread count passed into run(). Must be numeric and greater than 0"); } var argsForNewScript = []; for (var i = 2; i < arguments.length; ++i) { argsForNewScript.push(arguments[i]); } - var scriptServer = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(workerScript.serverIp); + var scriptServer = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(workerScript.serverIp); if (scriptServer == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Could not find server. This is a bug in the game. Report to game dev"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Could not find server. This is a bug in the game. Report to game dev"); } - return Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["e" /* runScriptFromScript */])(scriptServer, scriptname, argsForNewScript, workerScript, threads); + return Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["f" /* runScriptFromScript */])(scriptServer, scriptname, argsForNewScript, workerScript, threads); }, exec : function(scriptname,ip,threads = 1){ if (scriptname === undefined || ip === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "exec() call has incorrect number of arguments. Usage: exec(scriptname, server, [numThreads], [arg1], [arg2]...)"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "exec() call has incorrect number of arguments. Usage: exec(scriptname, server, [numThreads], [arg1], [arg2]...)"); } if (isNaN(threads) || threads < 1) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid argument for thread count passed into exec(). Must be numeric and greater than 0"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Invalid argument for thread count passed into exec(). Must be numeric and greater than 0"); } var argsForNewScript = []; for (var i = 3; i < arguments.length; ++i) { argsForNewScript.push(arguments[i]); } - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid hostname/ip passed into exec() command: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Invalid hostname/ip passed into exec() command: " + ip); } - return Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["e" /* runScriptFromScript */])(server, scriptname, argsForNewScript, workerScript, threads); + return Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["f" /* runScriptFromScript */])(server, scriptname, argsForNewScript, workerScript, threads); }, kill : function(filename,ip){ if (filename === undefined || ip === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "kill() call has incorrect number of arguments. Usage: kill(scriptname, server, [arg1], [arg2]...)"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "kill() call has incorrect number of arguments. Usage: kill(scriptname, server, [arg1], [arg2]...)"); } - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("kill() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "kill() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "kill() failed. Invalid IP or hostname passed in: " + ip); } var argsForKillTarget = []; for (var i = 2; i < arguments.length; ++i) { argsForKillTarget.push(arguments[i]); } - var runningScriptObj = Object(__WEBPACK_IMPORTED_MODULE_14__Script_js__["d" /* findRunningScript */])(filename, argsForKillTarget, server); + var runningScriptObj = Object(__WEBPACK_IMPORTED_MODULE_15__Script_js__["d" /* findRunningScript */])(filename, argsForKillTarget, server); if (runningScriptObj == null) { - workerScript.scriptRef.log("kill() failed. No such script "+ filename + " on " + server.hostname + " with args: " + Object(__WEBPACK_IMPORTED_MODULE_26__utils_HelperFunctions_js__["f" /* printArray */])(argsForKillTarget)); + workerScript.scriptRef.log("kill() failed. No such script "+ filename + " on " + server.hostname + " with args: " + Object(__WEBPACK_IMPORTED_MODULE_27__utils_HelperFunctions_js__["f" /* printArray */])(argsForKillTarget)); return false; } - var res = Object(__WEBPACK_IMPORTED_MODULE_21__NetscriptWorker_js__["d" /* killWorkerScript */])(runningScriptObj, server.ip); + var res = Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptWorker_js__["d" /* killWorkerScript */])(runningScriptObj, server.ip); if (res) { - workerScript.scriptRef.log("Killing " + filename + " on " + server.hostname + " with args: " + Object(__WEBPACK_IMPORTED_MODULE_26__utils_HelperFunctions_js__["f" /* printArray */])(argsForKillTarget) + ". May take up to a few minutes for the scripts to die..."); + workerScript.scriptRef.log("Killing " + filename + " on " + server.hostname + " with args: " + Object(__WEBPACK_IMPORTED_MODULE_27__utils_HelperFunctions_js__["f" /* printArray */])(argsForKillTarget) + ". May take up to a few minutes for the scripts to die..."); return true; } else { - workerScript.scriptRef.log("kill() failed. No such script "+ filename + " on " + server.hostname + " with args: " + Object(__WEBPACK_IMPORTED_MODULE_26__utils_HelperFunctions_js__["f" /* printArray */])(argsForKillTarget)); + workerScript.scriptRef.log("kill() failed. No such script "+ filename + " on " + server.hostname + " with args: " + Object(__WEBPACK_IMPORTED_MODULE_27__utils_HelperFunctions_js__["f" /* printArray */])(argsForKillTarget)); return false; } }, killall : function(ip){ if (ip === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "killall() call has incorrect number of arguments. Takes 1 argument"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "killall() call has incorrect number of arguments. Takes 1 argument"); } - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("killall() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "killall() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "killall() failed. Invalid IP or hostname passed in: " + ip); } for (var i = server.runningScripts.length-1; i >= 0; --i) { - Object(__WEBPACK_IMPORTED_MODULE_21__NetscriptWorker_js__["d" /* killWorkerScript */])(server.runningScripts[i], server.ip); + Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptWorker_js__["d" /* killWorkerScript */])(server.runningScripts[i], server.ip); } workerScript.scriptRef.log("killall(): Killing all scripts on " + server.hostname + ". May take a few minutes for the scripts to die"); return true; }, scp : function(scriptname, ip1, ip2){ if (arguments.length !== 2 && arguments.length !== 3) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Error: scp() call has incorrect number of arguments. Takes 2 or 3 arguments"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Error: scp() call has incorrect number of arguments. Takes 2 or 3 arguments"); } if (scriptname && scriptname.constructor === Array) { //Recursively call scp on all elements of array @@ -22042,36 +22052,36 @@ function NetscriptFunctions(workerScript) { return res; } if (!scriptname.endsWith(".lit") && !scriptname.endsWith(".script")) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Error: scp() only works for .script and .lit files"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Error: scp() only works for .script and .lit files"); } var destServer, currServ; if (arguments.length === 3) { //scriptname, source, destination if (scriptname === undefined || ip1 === undefined || ip2 === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Error: scp() call has incorrect number of arguments. Takes 2 or 3 arguments"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Error: scp() call has incorrect number of arguments. Takes 2 or 3 arguments"); } - destServer = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip2); + destServer = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip2); if (destServer == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Error: Invalid hostname/ip passed into scp() command: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Error: Invalid hostname/ip passed into scp() command: " + ip); } - currServ = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip1); + currServ = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip1); if (currServ == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Could not find server ip for this script. This is a bug please contact game developer"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Could not find server ip for this script. This is a bug please contact game developer"); } } else if (arguments.length === 2) { //scriptname, destination if (scriptname === undefined || ip1 === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Error: scp() call has incorrect number of arguments. Takes 2 or 3 arguments"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Error: scp() call has incorrect number of arguments. Takes 2 or 3 arguments"); } - destServer = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip1); + destServer = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip1); if (destServer == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Error: Invalid hostname/ip passed into scp() command: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Error: Invalid hostname/ip passed into scp() command: " + ip); } - currServ = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(workerScript.serverIp); + currServ = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(workerScript.serverIp); if (currServ == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Could not find server ip for this script. This is a bug please contact game developer"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Could not find server ip for this script. This is a bug please contact game developer"); } } @@ -22126,7 +22136,7 @@ function NetscriptFunctions(workerScript) { } //Create new script if it does not already exist - var newScript = new __WEBPACK_IMPORTED_MODULE_14__Script_js__["c" /* Script */](); + var newScript = new __WEBPACK_IMPORTED_MODULE_15__Script_js__["c" /* Script */](); newScript.filename = scriptname; newScript.code = sourceScript.code; newScript.ramUsage = sourceScript.ramUsage; @@ -22137,12 +22147,12 @@ function NetscriptFunctions(workerScript) { }, ls : function(ip, grep) { if (ip === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ls() failed because of invalid arguments. Usage: ls(ip/hostname, [grep filter])"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "ls() failed because of invalid arguments. Usage: ls(ip/hostname, [grep filter])"); } - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("ls() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ls() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "ls() failed. Invalid IP or hostname passed in: " + ip); } //Get the grep filter, if one exists @@ -22195,145 +22205,145 @@ function NetscriptFunctions(workerScript) { }, hasRootAccess : function(ip){ if (ip===undefined){ - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "hasRootAccess() call has incorrect number of arguments. Takes 1 argument"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "hasRootAccess() call has incorrect number of arguments. Takes 1 argument"); } - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null){ workerScript.scriptRef.log("hasRootAccess() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "hasRootAccess() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "hasRootAccess() failed. Invalid IP or hostname passed in: " + ip); } return server.hasAdminRights; }, getIp : function() { - var scriptServer = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(workerScript.serverIp); + var scriptServer = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(workerScript.serverIp); if (scriptServer == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Could not find server. This is a bug in the game. Report to game dev"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Could not find server. This is a bug in the game. Report to game dev"); } return scriptServer.ip; }, getHostname : function(){ - var scriptServer = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(workerScript.serverIp); + var scriptServer = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(workerScript.serverIp); if (scriptServer == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Could not find server. This is a bug in the game. Report to game dev"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Could not find server. This is a bug in the game. Report to game dev"); } return scriptServer.hostname; }, getHackingLevel : function(){ - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].updateSkillLevels(); - workerScript.scriptRef.log("getHackingLevel() returned " + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill); - return __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill; + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].updateSkillLevels(); + workerScript.scriptRef.log("getHackingLevel() returned " + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hacking_skill); + return __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hacking_skill; }, getHackingMultipliers : function() { return { - chance: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_chance_mult, - speed: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_speed_mult, - money: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_money_mult, - growth: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_grow_mult, + chance: __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hacking_chance_mult, + speed: __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hacking_speed_mult, + money: __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hacking_money_mult, + growth: __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hacking_grow_mult, }; }, getBitNodeMultipliers: function() { if (!hasAISF) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getBitNodeMultipliers(). It requires Source-File 5 to run."); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getBitNodeMultipliers(). It requires Source-File 5 to run."); } return __WEBPACK_IMPORTED_MODULE_2__BitNode_js__["a" /* BitNodeMultipliers */]; }, getServerMoneyAvailable : function(ip){ - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("getServerMoneyAvailable() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getServerMoneyAvailable() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "getServerMoneyAvailable() failed. Invalid IP or hostname passed in: " + ip); } if (server.hostname == "home") { //Return player's money - workerScript.scriptRef.log("getServerMoneyAvailable('home') returned player's money: $" + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.toNumber(), 2)); - return __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.toNumber(); + workerScript.scriptRef.log("getServerMoneyAvailable('home') returned player's money: $" + Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].money.toNumber(), 2)); + return __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].money.toNumber(); } - workerScript.scriptRef.log("getServerMoneyAvailable() returned " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.moneyAvailable, 2) + " for " + server.hostname); + workerScript.scriptRef.log("getServerMoneyAvailable() returned " + Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.moneyAvailable, 2) + " for " + server.hostname); return server.moneyAvailable; }, getServerSecurityLevel : function(ip){ - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("getServerSecurityLevel() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getServerSecurityLevel() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "getServerSecurityLevel() failed. Invalid IP or hostname passed in: " + ip); } - workerScript.scriptRef.log("getServerSecurityLevel() returned " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.hackDifficulty, 3) + " for " + server.hostname); + workerScript.scriptRef.log("getServerSecurityLevel() returned " + Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.hackDifficulty, 3) + " for " + server.hostname); return server.hackDifficulty; }, getServerBaseSecurityLevel : function(ip){ - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("getServerBaseSecurityLevel() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getServerBaseSecurityLevel() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "getServerBaseSecurityLevel() failed. Invalid IP or hostname passed in: " + ip); } - workerScript.scriptRef.log("getServerBaseSecurityLevel() returned " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.baseDifficulty, 3) + " for " + server.hostname); + workerScript.scriptRef.log("getServerBaseSecurityLevel() returned " + Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.baseDifficulty, 3) + " for " + server.hostname); return server.baseDifficulty; }, getServerMinSecurityLevel : function(ip) { - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("getServerMinSecurityLevel() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getServerMinSecurityLevel() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "getServerMinSecurityLevel() failed. Invalid IP or hostname passed in: " + ip); } - workerScript.scriptRef.log("getServerMinSecurityLevel() returned " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.minDifficulty, 3) + " for " + server.hostname); + workerScript.scriptRef.log("getServerMinSecurityLevel() returned " + Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.minDifficulty, 3) + " for " + server.hostname); return server.minDifficulty; }, getServerRequiredHackingLevel : function(ip){ - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("getServerRequiredHackingLevel() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getServerRequiredHackingLevel() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "getServerRequiredHackingLevel() failed. Invalid IP or hostname passed in: " + ip); } - workerScript.scriptRef.log("getServerRequiredHackingLevel returned " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.requiredHackingSkill, 0) + " for " + server.hostname); + workerScript.scriptRef.log("getServerRequiredHackingLevel returned " + Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.requiredHackingSkill, 0) + " for " + server.hostname); return server.requiredHackingSkill; }, getServerMaxMoney : function(ip){ - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("getServerMaxMoney() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getServerMaxMoney() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "getServerMaxMoney() failed. Invalid IP or hostname passed in: " + ip); } - workerScript.scriptRef.log("getServerMaxMoney() returned " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.moneyMax, 0) + " for " + server.hostname); + workerScript.scriptRef.log("getServerMaxMoney() returned " + Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.moneyMax, 0) + " for " + server.hostname); return server.moneyMax; }, getServerGrowth : function(ip) { - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("getServerGrowth() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getServerGrowth() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "getServerGrowth() failed. Invalid IP or hostname passed in: " + ip); } - workerScript.scriptRef.log("getServerGrowth() returned " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.serverGrowth, 0) + " for " + server.hostname); + workerScript.scriptRef.log("getServerGrowth() returned " + Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.serverGrowth, 0) + " for " + server.hostname); return server.serverGrowth; }, getServerNumPortsRequired : function(ip){ - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("getServerNumPortsRequired() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getServerNumPortsRequired() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "getServerNumPortsRequired() failed. Invalid IP or hostname passed in: " + ip); } - workerScript.scriptRef.log("getServerNumPortsRequired() returned " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.numOpenPortsRequired, 0) + " for " + server.hostname); + workerScript.scriptRef.log("getServerNumPortsRequired() returned " + Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.numOpenPortsRequired, 0) + " for " + server.hostname); return server.numOpenPortsRequired; }, getServerRam : function(ip) { - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("getServerRam() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getServerRam() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "getServerRam() failed. Invalid IP or hostname passed in: " + ip); } - workerScript.scriptRef.log("getServerRam() returned [" + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.maxRam, 2) + "GB, " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.ramUsed, 2) + "GB]"); + workerScript.scriptRef.log("getServerRam() returned [" + Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.maxRam, 2) + "GB, " + Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.ramUsed, 2) + "GB]"); return [server.maxRam, server.ramUsed]; }, serverExists : function(ip) { - return (Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip) !== null); + return (Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip) !== null); }, fileExists : function(filename,ip=workerScript.serverIp){ if (filename === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "fileExists() call has incorrect number of arguments. Usage: fileExists(scriptname, [server])"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "fileExists() call has incorrect number of arguments. Usage: fileExists(scriptname, [server])"); } - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("fileExists() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "fileExists() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "fileExists() failed. Invalid IP or hostname passed in: " + ip); } for (var i = 0; i < server.scripts.length; ++i) { if (filename == server.scripts[i].filename) { @@ -22355,48 +22365,48 @@ function NetscriptFunctions(workerScript) { }, isRunning : function(filename,ip){ if (filename === undefined || ip === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "isRunning() call has incorrect number of arguments. Usage: isRunning(scriptname, server, [arg1], [arg2]...)"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "isRunning() call has incorrect number of arguments. Usage: isRunning(scriptname, server, [arg1], [arg2]...)"); } - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("isRunning() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "isRunning() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "isRunning() failed. Invalid IP or hostname passed in: " + ip); } var argsForTargetScript = []; for (var i = 2; i < arguments.length; ++i) { argsForTargetScript.push(arguments[i]); } - return (Object(__WEBPACK_IMPORTED_MODULE_14__Script_js__["d" /* findRunningScript */])(filename, argsForTargetScript, server) != null); + return (Object(__WEBPACK_IMPORTED_MODULE_15__Script_js__["d" /* findRunningScript */])(filename, argsForTargetScript, server) != null); }, getNextHacknetNodeCost : __WEBPACK_IMPORTED_MODULE_10__HacknetNode_js__["b" /* getCostOfNextHacknetNode */], purchaseHacknetNode : __WEBPACK_IMPORTED_MODULE_10__HacknetNode_js__["d" /* purchaseHacknet */], getStockPrice : function(symbol) { - if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasTixApiAccess) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use getStockPrice()"); + if (!__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hasTixApiAccess) { + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use getStockPrice()"); } - var stock = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["d" /* SymbolToStockMap */][symbol]; + var stock = __WEBPACK_IMPORTED_MODULE_19__StockMarket_js__["d" /* SymbolToStockMap */][symbol]; if (stock == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid stock symbol passed into getStockPrice()"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Invalid stock symbol passed into getStockPrice()"); } return parseFloat(stock.price.toFixed(3)); }, getStockPosition : function(symbol) { - if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasTixApiAccess) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use getStockPosition()"); + if (!__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hasTixApiAccess) { + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use getStockPosition()"); } - var stock = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["d" /* SymbolToStockMap */][symbol]; + var stock = __WEBPACK_IMPORTED_MODULE_19__StockMarket_js__["d" /* SymbolToStockMap */][symbol]; if (stock == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid stock symbol passed into getStockPrice()"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Invalid stock symbol passed into getStockPrice()"); } return [stock.playerShares, stock.playerAvgPx, stock.playerShortShares, stock.playerAvgShortPx]; }, buyStock : function(symbol, shares) { - if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasTixApiAccess) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use buyStock()"); + if (!__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hasTixApiAccess) { + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use buyStock()"); } - var stock = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["d" /* SymbolToStockMap */][symbol]; + var stock = __WEBPACK_IMPORTED_MODULE_19__StockMarket_js__["d" /* SymbolToStockMap */][symbol]; if (stock == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid stock symbol passed into buyStock()"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Invalid stock symbol passed into buyStock()"); } if (shares < 0 || isNaN(shares)) { workerScript.scriptRef.log("Error: Invalid 'shares' argument passed to buyStock()"); @@ -22406,32 +22416,32 @@ function NetscriptFunctions(workerScript) { if (shares === 0) {return false;} var totalPrice = stock.price * shares; - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.lt(totalPrice + __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].StockMarketCommission)) { - workerScript.scriptRef.log("Not enough money to purchase " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].money.lt(totalPrice + __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].StockMarketCommission)) { + workerScript.scriptRef.log("Not enough money to purchase " + Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + symbol + ". Need $" + - Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(totalPrice + __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].StockMarketCommission, 2).toString()); + Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["c" /* formatNumber */])(totalPrice + __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].StockMarketCommission, 2).toString()); return false; } var origTotal = stock.playerShares * stock.playerAvgPx; - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(totalPrice + __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].StockMarketCommission); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].loseMoney(totalPrice + __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].StockMarketCommission); var newTotal = origTotal + totalPrice; stock.playerShares += shares; stock.playerAvgPx = newTotal / stock.playerShares; if (__WEBPACK_IMPORTED_MODULE_8__engine_js__["Engine"].currentPage == __WEBPACK_IMPORTED_MODULE_8__engine_js__["Engine"].Page.StockMarket) { - Object(__WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["p" /* updateStockPlayerPosition */])(stock); + Object(__WEBPACK_IMPORTED_MODULE_19__StockMarket_js__["p" /* updateStockPlayerPosition */])(stock); } - workerScript.scriptRef.log("Bought " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + stock.symbol + " at $" + - Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.price, 2) + " per share"); + workerScript.scriptRef.log("Bought " + Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + stock.symbol + " at $" + + Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.price, 2) + " per share"); return true; }, sellStock : function(symbol, shares) { - if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasTixApiAccess) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use sellStock()"); + if (!__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hasTixApiAccess) { + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use sellStock()"); } - var stock = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["d" /* SymbolToStockMap */][symbol]; + var stock = __WEBPACK_IMPORTED_MODULE_19__StockMarket_js__["d" /* SymbolToStockMap */][symbol]; if (stock == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid stock symbol passed into sellStock()"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Invalid stock symbol passed into sellStock()"); } if (shares < 0 || isNaN(shares)) { workerScript.scriptRef.log("Error: Invalid 'shares' argument passed to sellStock()"); @@ -22441,131 +22451,131 @@ function NetscriptFunctions(workerScript) { if (shares > stock.playerShares) {shares = stock.playerShares;} if (shares === 0) {return false;} var gains = stock.price * shares - __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].StockMarketCommission; - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainMoney(gains); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].gainMoney(gains); //Calculate net profit and add to script stats var netProfit = ((stock.price - stock.playerAvgPx) * shares) - __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].StockMarketCommission; if (isNaN(netProfit)) {netProfit = 0;} workerScript.scriptRef.onlineMoneyMade += netProfit; - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].scriptProdSinceLastAug += netProfit; + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].scriptProdSinceLastAug += netProfit; stock.playerShares -= shares; if (stock.playerShares == 0) { stock.playerAvgPx = 0; } if (__WEBPACK_IMPORTED_MODULE_8__engine_js__["Engine"].currentPage == __WEBPACK_IMPORTED_MODULE_8__engine_js__["Engine"].Page.StockMarket) { - Object(__WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["p" /* updateStockPlayerPosition */])(stock); + Object(__WEBPACK_IMPORTED_MODULE_19__StockMarket_js__["p" /* updateStockPlayerPosition */])(stock); } - workerScript.scriptRef.log("Sold " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + stock.symbol + " at $" + - Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.price, 2) + " per share. Gained " + - "$" + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(gains, 2)); + workerScript.scriptRef.log("Sold " + Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + stock.symbol + " at $" + + Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.price, 2) + " per share. Gained " + + "$" + Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["c" /* formatNumber */])(gains, 2)); return true; }, shortStock(symbol, shares) { - if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasTixApiAccess) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use shortStock()"); + if (!__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hasTixApiAccess) { + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use shortStock()"); } - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN !== 8) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].bitNodeN !== 8) { if (!(hasWallStreetSF && wallStreetSFLvl >= 2)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Cannot use shortStock(). You must either be in BitNode-8 or you must have Level 2 of Source-File 8"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Cannot use shortStock(). You must either be in BitNode-8 or you must have Level 2 of Source-File 8"); } } - var stock = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["d" /* SymbolToStockMap */][symbol]; + var stock = __WEBPACK_IMPORTED_MODULE_19__StockMarket_js__["d" /* SymbolToStockMap */][symbol]; if (stock == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Invalid stock symbol passed into shortStock()"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Invalid stock symbol passed into shortStock()"); } - return Object(__WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["n" /* shortStock */])(stock, shares, workerScript); + return Object(__WEBPACK_IMPORTED_MODULE_19__StockMarket_js__["n" /* shortStock */])(stock, shares, workerScript); }, sellShort(symbol, shares) { - if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasTixApiAccess) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use sellShort()"); + if (!__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hasTixApiAccess) { + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use sellShort()"); } - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN !== 8) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].bitNodeN !== 8) { if (!(hasWallStreetSF && wallStreetSFLvl >= 2)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Cannot use sellShort(). You must either be in BitNode-8 or you must have Level 2 of Source-File 8"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Cannot use sellShort(). You must either be in BitNode-8 or you must have Level 2 of Source-File 8"); } } - var stock = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["d" /* SymbolToStockMap */][symbol]; + var stock = __WEBPACK_IMPORTED_MODULE_19__StockMarket_js__["d" /* SymbolToStockMap */][symbol]; if (stock == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Invalid stock symbol passed into sellShort()"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Invalid stock symbol passed into sellShort()"); } - return Object(__WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["l" /* sellShort */])(stock, shares, workerScript); + return Object(__WEBPACK_IMPORTED_MODULE_19__StockMarket_js__["l" /* sellShort */])(stock, shares, workerScript); }, placeOrder(symbol, shares, price, type, pos) { - if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasTixApiAccess) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use placeOrder()"); + if (!__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hasTixApiAccess) { + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use placeOrder()"); } - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN !== 8) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].bitNodeN !== 8) { if (!(hasWallStreetSF && wallStreetSFLvl >= 3)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Cannot use placeOrder(). You must either be in BitNode-8 or have Level 3 of Source-File 8"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Cannot use placeOrder(). You must either be in BitNode-8 or have Level 3 of Source-File 8"); } } - var stock = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["d" /* SymbolToStockMap */][symbol]; + var stock = __WEBPACK_IMPORTED_MODULE_19__StockMarket_js__["d" /* SymbolToStockMap */][symbol]; if (stock == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Invalid stock symbol passed into placeOrder()"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Invalid stock symbol passed into placeOrder()"); } var orderType, orderPos; type = type.toLowerCase(); if (type.includes("limit") && type.includes("buy")) { - orderType = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["a" /* OrderTypes */].LimitBuy; + orderType = __WEBPACK_IMPORTED_MODULE_19__StockMarket_js__["a" /* OrderTypes */].LimitBuy; } else if (type.includes("limit") && type.includes("sell")) { - orderType = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["a" /* OrderTypes */].LimitSell; + orderType = __WEBPACK_IMPORTED_MODULE_19__StockMarket_js__["a" /* OrderTypes */].LimitSell; } else if (type.includes("stop") && type.includes("buy")) { - orderType = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["a" /* OrderTypes */].StopBuy; + orderType = __WEBPACK_IMPORTED_MODULE_19__StockMarket_js__["a" /* OrderTypes */].StopBuy; } else if (type.includes("stop") && type.includes("sell")) { - orderType = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["a" /* OrderTypes */].StopSell; + orderType = __WEBPACK_IMPORTED_MODULE_19__StockMarket_js__["a" /* OrderTypes */].StopSell; } else { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Invalid Order Type passed into placeOrder()"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Invalid Order Type passed into placeOrder()"); } pos = pos.toLowerCase(); if (pos.includes("l")) { - orderPos = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["b" /* PositionTypes */].Long; + orderPos = __WEBPACK_IMPORTED_MODULE_19__StockMarket_js__["b" /* PositionTypes */].Long; } else if (pos.includes('s')) { - orderPos = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["b" /* PositionTypes */].Short; + orderPos = __WEBPACK_IMPORTED_MODULE_19__StockMarket_js__["b" /* PositionTypes */].Short; } else { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Invalid Position Type passed into placeOrder()"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Invalid Position Type passed into placeOrder()"); } - return Object(__WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["k" /* placeOrder */])(stock, shares, price, orderType, orderPos, workerScript); + return Object(__WEBPACK_IMPORTED_MODULE_19__StockMarket_js__["k" /* placeOrder */])(stock, shares, price, orderType, orderPos, workerScript); }, cancelOrder(symbol, shares, price, type, pos) { - if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasTixApiAccess) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use cancelOrder()"); + if (!__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hasTixApiAccess) { + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use cancelOrder()"); } - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN !== 8) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].bitNodeN !== 8) { if (!(hasWallStreetSF && wallStreetSFLvl >= 3)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Cannot use cancelOrder(). You must either be in BitNode-8 or have Level 3 of Source-File 8"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Cannot use cancelOrder(). You must either be in BitNode-8 or have Level 3 of Source-File 8"); } } - var stock = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["d" /* SymbolToStockMap */][symbol]; + var stock = __WEBPACK_IMPORTED_MODULE_19__StockMarket_js__["d" /* SymbolToStockMap */][symbol]; if (stock == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Invalid stock symbol passed into cancelOrder()"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Invalid stock symbol passed into cancelOrder()"); } if (isNaN(shares) || isNaN(price)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Invalid shares or price argument passed into cancelOrder(). Must be numeric"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Invalid shares or price argument passed into cancelOrder(). Must be numeric"); } var orderType, orderPos; type = type.toLowerCase(); if (type.includes("limit") && type.includes("buy")) { - orderType = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["a" /* OrderTypes */].LimitBuy; + orderType = __WEBPACK_IMPORTED_MODULE_19__StockMarket_js__["a" /* OrderTypes */].LimitBuy; } else if (type.includes("limit") && type.includes("sell")) { - orderType = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["a" /* OrderTypes */].LimitSell; + orderType = __WEBPACK_IMPORTED_MODULE_19__StockMarket_js__["a" /* OrderTypes */].LimitSell; } else if (type.includes("stop") && type.includes("buy")) { - orderType = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["a" /* OrderTypes */].StopBuy; + orderType = __WEBPACK_IMPORTED_MODULE_19__StockMarket_js__["a" /* OrderTypes */].StopBuy; } else if (type.includes("stop") && type.includes("sell")) { orderType = OrderType.StopSell; } else { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Invalid Order Type passed into placeOrder()"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Invalid Order Type passed into placeOrder()"); } pos = pos.toLowerCase(); if (pos.includes("l")) { - orderPos = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["b" /* PositionTypes */].Long; + orderPos = __WEBPACK_IMPORTED_MODULE_19__StockMarket_js__["b" /* PositionTypes */].Long; } else if (pos.includes('s')) { - orderPos = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["b" /* PositionTypes */].Short; + orderPos = __WEBPACK_IMPORTED_MODULE_19__StockMarket_js__["b" /* PositionTypes */].Short; } else { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Invalid Position Type passed into placeOrder()"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Invalid Position Type passed into placeOrder()"); } params = { stock: stock, @@ -22574,7 +22584,7 @@ function NetscriptFunctions(workerScript) { type: orderType, pos: orderPos }; - return Object(__WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["e" /* cancelOrder */])(params, workerScript); + return Object(__WEBPACK_IMPORTED_MODULE_19__StockMarket_js__["e" /* cancelOrder */])(params, workerScript); }, purchaseServer : function(hostname, ram) { var hostnameStr = String(hostname); @@ -22584,38 +22594,38 @@ function NetscriptFunctions(workerScript) { return ""; } - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].purchasedServers.length >= __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].PurchasedServerLimit) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].purchasedServers.length >= __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].PurchasedServerLimit) { workerScript.scriptRef.log("Error: You have reached the maximum limit of " + __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].PurchasedServerLimit + " servers. You cannot purchase any more."); return ""; } ram = Math.round(ram); - if (isNaN(ram) || !Object(__WEBPACK_IMPORTED_MODULE_26__utils_HelperFunctions_js__["e" /* powerOfTwo */])(ram)) { + if (isNaN(ram) || !Object(__WEBPACK_IMPORTED_MODULE_27__utils_HelperFunctions_js__["e" /* powerOfTwo */])(ram)) { workerScript.scriptRef.log("Error: Invalid ram argument passed to purchaseServer(). Must be numeric and a power of 2"); return ""; } var cost = ram * __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].BaseCostFor1GBOfRamServer; - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.lt(cost)) { - workerScript.scriptRef.log("Error: Not enough money to purchase server. Need $" + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(cost, 2)); + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].money.lt(cost)) { + workerScript.scriptRef.log("Error: Not enough money to purchase server. Need $" + Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["c" /* formatNumber */])(cost, 2)); return ""; } - var newServ = new __WEBPACK_IMPORTED_MODULE_15__Server_js__["d" /* Server */](Object(__WEBPACK_IMPORTED_MODULE_27__utils_IPAddress_js__["a" /* createRandomIp */])(), hostnameStr, "", false, true, true, ram); - Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["a" /* AddToAllServers */])(newServ); + var newServ = new __WEBPACK_IMPORTED_MODULE_16__Server_js__["d" /* Server */](Object(__WEBPACK_IMPORTED_MODULE_28__utils_IPAddress_js__["a" /* createRandomIp */])(), hostnameStr, "", false, true, true, ram); + Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["a" /* AddToAllServers */])(newServ); - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].purchasedServers.push(newServ.ip); - var homeComputer = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer(); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].purchasedServers.push(newServ.ip); + var homeComputer = __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].getHomeComputer(); homeComputer.serversOnNetwork.push(newServ.ip); newServ.serversOnNetwork.push(homeComputer.ip); - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(cost); - workerScript.scriptRef.log("Purchased new server with hostname " + newServ.hostname + " for $" + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(cost, 2)); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].loseMoney(cost); + workerScript.scriptRef.log("Purchased new server with hostname " + newServ.hostname + " for $" + Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["c" /* formatNumber */])(cost, 2)); return newServ.hostname; }, deleteServer : function(hostname) { var hostnameStr = String(hostname); hostnameStr = hostnameStr.replace(/\s\s+/g, ''); - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["c" /* GetServerByHostname */])(hostnameStr); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["c" /* GetServerByHostname */])(hostnameStr); if (server == null) { workerScript.scriptRef.log("Error: Could not find server with hostname " + hostnameStr + ". deleteServer() failed"); return false; @@ -22643,10 +22653,10 @@ function NetscriptFunctions(workerScript) { //Delete from player's purchasedServers array var found = false; - for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].purchasedServers.length; ++i) { - if (ip == __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].purchasedServers[i]) { + for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].purchasedServers.length; ++i) { + if (ip == __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].purchasedServers[i]) { found = true; - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].purchasedServers.splice(i, 1); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].purchasedServers.splice(i, 1); break; } } @@ -22658,11 +22668,11 @@ function NetscriptFunctions(workerScript) { } //Delete from all servers - delete __WEBPACK_IMPORTED_MODULE_15__Server_js__["b" /* AllServers */][ip]; + delete __WEBPACK_IMPORTED_MODULE_16__Server_js__["b" /* AllServers */][ip]; //Delete from home computer found = false; - var homeComputer = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer(); + var homeComputer = __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].getHomeComputer(); for (var i = 0; i < homeComputer.serversOnNetwork.length; ++i) { if (ip == homeComputer.serversOnNetwork[i]) { homeComputer.serversOnNetwork.splice(i, 1); @@ -22677,11 +22687,11 @@ function NetscriptFunctions(workerScript) { }, getPurchasedServers : function(hostname=true) { var res = []; - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].purchasedServers.forEach(function(ip) { + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].purchasedServers.forEach(function(ip) { if (hostname) { - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ERR: Could not find server in getPurchasedServers(). This is a bug please report to game dev"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "ERR: Could not find server in getPurchasedServers(). This is a bug please report to game dev"); } res.push(server.hostname); } else { @@ -22698,28 +22708,28 @@ function NetscriptFunctions(workerScript) { if (!isNaN(port)) { //Write to port //Port 1-10 if (port < 1 || port > 10) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Trying to write to invalid port: " + port + ". Only ports 1-10 are valid."); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Trying to write to invalid port: " + port + ". Only ports 1-10 are valid."); } var portName = "Port" + String(port); - var port = __WEBPACK_IMPORTED_MODULE_21__NetscriptWorker_js__["a" /* NetscriptPorts */][portName]; + var port = __WEBPACK_IMPORTED_MODULE_22__NetscriptWorker_js__["a" /* NetscriptPorts */][portName]; if (port == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Could not find port: " + port + ". This is a bug contact the game developer"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Could not find port: " + port + ". This is a bug contact the game developer"); } port.push(data); - if (port.length > __WEBPACK_IMPORTED_MODULE_16__Settings_js__["a" /* Settings */].MaxPortCapacity) { + if (port.length > __WEBPACK_IMPORTED_MODULE_17__Settings_js__["a" /* Settings */].MaxPortCapacity) { port.shift(); return true; } return false; - } else if (Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["f" /* isString */])(port)) { //Write to text file + } else if (Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["f" /* isString */])(port)) { //Write to text file var fn = port; - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(workerScript.serverIp); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(workerScript.serverIp); if (server == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Error getting Server for this script in write(). This is a bug please contact game dev"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Error getting Server for this script in write(). This is a bug please contact game dev"); } - var txtFile = Object(__WEBPACK_IMPORTED_MODULE_20__TextFile_js__["b" /* getTextFile */])(fn, server); + var txtFile = Object(__WEBPACK_IMPORTED_MODULE_21__TextFile_js__["b" /* getTextFile */])(fn, server); if (txtFile == null) { - txtFile = Object(__WEBPACK_IMPORTED_MODULE_20__TextFile_js__["a" /* createTextFile */])(fn, data, server); + txtFile = Object(__WEBPACK_IMPORTED_MODULE_21__TextFile_js__["a" /* createTextFile */])(fn, data, server); return true; } if (mode === "w") { @@ -22729,46 +22739,46 @@ function NetscriptFunctions(workerScript) { } return true; } else { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid argument passed in for port: " + port + ". Must be a number between 1 and 10"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Invalid argument passed in for port: " + port + ". Must be a number between 1 and 10"); } }, read : function(port) { if (!isNaN(port)) { //Read from port //Port 1-10 if (port < 1 || port > 10) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Trying to write to invalid port: " + port + ". Only ports 1-10 are valid."); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Trying to write to invalid port: " + port + ". Only ports 1-10 are valid."); } var portName = "Port" + String(port); - var port = __WEBPACK_IMPORTED_MODULE_21__NetscriptWorker_js__["a" /* NetscriptPorts */][portName]; + var port = __WEBPACK_IMPORTED_MODULE_22__NetscriptWorker_js__["a" /* NetscriptPorts */][portName]; if (port == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Could not find port: " + port + ". This is a bug contact the game developer"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Could not find port: " + port + ". This is a bug contact the game developer"); } if (port.length == 0) { return "NULL PORT DATA"; } else { return port.shift(); } - } else if (Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["f" /* isString */])(port)) { //Read from text file + } else if (Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["f" /* isString */])(port)) { //Read from text file var fn = port; - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(workerScript.serverIp); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(workerScript.serverIp); if (server == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Error getting Server for this script in read(). This is a bug please contact game dev"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Error getting Server for this script in read(). This is a bug please contact game dev"); } - var txtFile = Object(__WEBPACK_IMPORTED_MODULE_20__TextFile_js__["b" /* getTextFile */])(fn, server); + var txtFile = Object(__WEBPACK_IMPORTED_MODULE_21__TextFile_js__["b" /* getTextFile */])(fn, server); if (txtFile !== null) { return txtFile.text; } else { return ""; } } else { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid argument passed in for port: " + port + ". Must be a number between 1 and 10"); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Invalid argument passed in for port: " + port + ". Must be a number between 1 and 10"); } }, scriptRunning : function(scriptname, ip) { - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("scriptRunning() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "scriptRunning() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "scriptRunning() failed. Invalid IP or hostname passed in: " + ip); } for (var i = 0; i < server.runningScripts.length; ++i) { if (server.runningScripts[i].filename == scriptname) { @@ -22778,25 +22788,25 @@ function NetscriptFunctions(workerScript) { return false; }, scriptKill : function(scriptname, ip) { - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("scriptKill() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "scriptKill() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "scriptKill() failed. Invalid IP or hostname passed in: " + ip); } var suc = false; for (var i = 0; i < server.runningScripts.length; ++i) { if (server.runningScripts[i].filename == scriptname) { - Object(__WEBPACK_IMPORTED_MODULE_21__NetscriptWorker_js__["d" /* killWorkerScript */])(server.runningScripts[i], server.ip); + Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptWorker_js__["d" /* killWorkerScript */])(server.runningScripts[i], server.ip); suc = true; } } return suc; }, getScriptRam : function (scriptname, ip) { - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("getScriptRam() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getScriptRam() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "getScriptRam() failed. Invalid IP or hostname passed in: " + ip); } for (var i = 0; i < server.scripts.length; ++i) { if (server.scripts[i].filename == scriptname) { @@ -22806,50 +22816,50 @@ function NetscriptFunctions(workerScript) { return 0; }, getHackTime : function(ip) { - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("getHackTime() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getHackTime() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "getHackTime() failed. Invalid IP or hostname passed in: " + ip); } - return Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["i" /* scriptCalculateHackingTime */])(server); //Returns seconds + return Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["j" /* scriptCalculateHackingTime */])(server); //Returns seconds }, getGrowTime : function(ip) { - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("getGrowTime() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getGrowTime() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "getGrowTime() failed. Invalid IP or hostname passed in: " + ip); } - return Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["g" /* scriptCalculateGrowTime */])(server) / 1000; //Returns seconds + return Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["h" /* scriptCalculateGrowTime */])(server) / 1000; //Returns seconds }, getWeakenTime : function(ip) { - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("getWeakenTime() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getWeakenTime() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "getWeakenTime() failed. Invalid IP or hostname passed in: " + ip); } - return Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["k" /* scriptCalculateWeakenTime */])(server) / 1000; //Returns seconds + return Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["l" /* scriptCalculateWeakenTime */])(server) / 1000; //Returns seconds }, getScriptIncome : function(scriptname, ip) { if (arguments.length === 0) { //Get total script income var res = []; res.push(Object(__WEBPACK_IMPORTED_MODULE_0__ActiveScriptsUI_js__["d" /* updateActiveScriptsItems */])()); - res.push(__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].scriptProdSinceLastAug / (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].playtimeSinceLastAug/1000)); + res.push(__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].scriptProdSinceLastAug / (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].playtimeSinceLastAug/1000)); return res; } else { //Get income for a particular script - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("getScriptIncome() failed. Invalid IP or hostnamed passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getScriptIncome() failed. Invalid IP or hostnamed passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "getScriptIncome() failed. Invalid IP or hostnamed passed in: " + ip); } var argsForScript = []; for (var i = 2; i < arguments.length; ++i) { argsForScript.push(arguments[i]); } - var runningScriptObj = Object(__WEBPACK_IMPORTED_MODULE_14__Script_js__["d" /* findRunningScript */])(scriptname, argsForScript, server); + var runningScriptObj = Object(__WEBPACK_IMPORTED_MODULE_15__Script_js__["d" /* findRunningScript */])(scriptname, argsForScript, server); if (runningScriptObj == null) { - workerScript.scriptRef.log("getScriptIncome() failed. No such script "+ scriptname + " on " + server.hostname + " with args: " + Object(__WEBPACK_IMPORTED_MODULE_26__utils_HelperFunctions_js__["f" /* printArray */])(argsForScript)); + workerScript.scriptRef.log("getScriptIncome() failed. No such script "+ scriptname + " on " + server.hostname + " with args: " + Object(__WEBPACK_IMPORTED_MODULE_27__utils_HelperFunctions_js__["f" /* printArray */])(argsForScript)); return -1; } return runningScriptObj.onlineMoneyMade / runningScriptObj.onlineRunningTime; @@ -22858,72 +22868,79 @@ function NetscriptFunctions(workerScript) { getScriptExpGain : function(scriptname, ip) { if (arguments.length === 0) { var total = 0; - for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_21__NetscriptWorker_js__["h" /* workerScripts */].length; ++i) { - total += (__WEBPACK_IMPORTED_MODULE_21__NetscriptWorker_js__["h" /* workerScripts */][i].scriptRef.onlineExpGained / __WEBPACK_IMPORTED_MODULE_21__NetscriptWorker_js__["h" /* workerScripts */][i].scriptRef.onlineRunningTime); + for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_22__NetscriptWorker_js__["h" /* workerScripts */].length; ++i) { + total += (__WEBPACK_IMPORTED_MODULE_22__NetscriptWorker_js__["h" /* workerScripts */][i].scriptRef.onlineExpGained / __WEBPACK_IMPORTED_MODULE_22__NetscriptWorker_js__["h" /* workerScripts */][i].scriptRef.onlineRunningTime); } return total; } else { //Get income for a particular script - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(ip); if (server == null) { workerScript.scriptRef.log("getScriptExpGain() failed. Invalid IP or hostnamed passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getScriptExpGain() failed. Invalid IP or hostnamed passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "getScriptExpGain() failed. Invalid IP or hostnamed passed in: " + ip); } var argsForScript = []; for (var i = 2; i < arguments.length; ++i) { argsForScript.push(arguments[i]); } - var runningScriptObj = Object(__WEBPACK_IMPORTED_MODULE_14__Script_js__["d" /* findRunningScript */])(scriptname, argsForScript, server); + var runningScriptObj = Object(__WEBPACK_IMPORTED_MODULE_15__Script_js__["d" /* findRunningScript */])(scriptname, argsForScript, server); if (runningScriptObj == null) { - workerScript.scriptRef.log("getScriptExpGain() failed. No such script "+ scriptname + " on " + server.hostname + " with args: " + Object(__WEBPACK_IMPORTED_MODULE_26__utils_HelperFunctions_js__["f" /* printArray */])(argsForScript)); + workerScript.scriptRef.log("getScriptExpGain() failed. No such script "+ scriptname + " on " + server.hostname + " with args: " + Object(__WEBPACK_IMPORTED_MODULE_27__utils_HelperFunctions_js__["f" /* printArray */])(argsForScript)); return -1; } return runningScriptObj.onlineExpGained / runningScriptObj.onlineRunningTime; } }, getTimeSinceLastAug : function() { - return __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].playtimeSinceLastAug; + return __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].playtimeSinceLastAug; + }, + confirm : function(txt) { + }, /* Singularity Functions */ - universityCourse(universityName, className) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + universityCourse : function(universityName, className) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].bitNodeN != 4) { if (!(hasSingularitySF && singularitySFLvl >= 1)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run universityCourse(). It is a Singularity Function and requires SourceFile-4 (level 1) to run."); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run universityCourse(). It is a Singularity Function and requires SourceFile-4 (level 1) to run."); return false; } } - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].isWorking) { - var txt = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].singularityStopWork(); + if (__WEBPACK_IMPORTED_MODULE_13__Missions_js__["c" /* inMission */]) { + workerScript.scriptRef.log("ERROR: universityCourse() failed because you are in the middle of a mission."); + return; + } + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].isWorking) { + var txt = __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].singularityStopWork(); workerScript.scriptRef.log(txt); } var costMult, expMult; switch(universityName.toLowerCase()) { case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].AevumSummitUniversity.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Aevum) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Aevum) { workerScript.scriptRef.log("ERROR: You cannot study at Summit University because you are not in Aevum. universityCourse() failed"); return false; } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].AevumSummitUniversity; + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].AevumSummitUniversity; costMult = 4; expMult = 3; break; case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12RothmanUniversity.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12) { workerScript.scriptRef.log("ERROR: You cannot study at Rothman University because you are not in Sector-12. universityCourse() failed"); return false; } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12RothmanUniversity; + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12RothmanUniversity; costMult = 3; expMult = 2; break; case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].VolhavenZBInstituteOfTechnology.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Volhaven) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Volhaven) { workerScript.scriptRef.log("ERROR: You cannot study at ZB Institute of Technology because you are not in Volhaven. universityCourse() failed"); return false; } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].VolhavenZBInstituteOfTechnology; + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].VolhavenZBInstituteOfTechnology; costMult = 5; expMult = 4; break; @@ -22956,66 +22973,70 @@ function NetscriptFunctions(workerScript) { workerScript.scriptRef.log("Invalid class name: " + className + ". universityCourse() failed"); return false; } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startClass(costMult, expMult, task); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].startClass(costMult, expMult, task); workerScript.scriptRef.log("Started " + task + " at " + universityName); return true; }, - gymWorkout(gymName, stat) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + gymWorkout : function(gymName, stat) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].bitNodeN != 4) { if (!(hasSingularitySF && singularitySFLvl >= 1)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run gymWorkout(). It is a Singularity Function and requires SourceFile-4 (level 1) to run."); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run gymWorkout(). It is a Singularity Function and requires SourceFile-4 (level 1) to run."); return false; } } - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].isWorking) { - var txt = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].singularityStopWork(); + if (__WEBPACK_IMPORTED_MODULE_13__Missions_js__["c" /* inMission */]) { + workerScript.scriptRef.log("ERROR: universityCourse() failed because you are in the middle of a mission."); + return; + } + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].isWorking) { + var txt = __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].singularityStopWork(); workerScript.scriptRef.log(txt); } var costMult, expMult; switch(gymName.toLowerCase()) { case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].AevumCrushFitnessGym.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Aevum) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Aevum) { workerScript.scriptRef.log("ERROR: You cannot workout at Crush Fitness because you are not in Aevum. gymWorkout() failed"); return false; } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].AevumCrushFitnessGym; + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].AevumCrushFitnessGym; costMult = 2; expMult = 1.5; break; case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].AevumSnapFitnessGym.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Aevum) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Aevum) { workerScript.scriptRef.log("ERROR: You cannot workout at Snap Fitness because you are not in Aevum. gymWorkout() failed"); return false; } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].AevumSnapFitnessGym; + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].AevumSnapFitnessGym; costMult = 6; expMult = 4; break; case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12IronGym.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12) { workerScript.scriptRef.log("ERROR: You cannot workout at Iron Gym because you are not in Sector-12. gymWorkout() failed"); return false; } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12IronGym; + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12IronGym; costMult = 1; expMult = 1; break; case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12PowerhouseGym.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12) { workerScript.scriptRef.log("ERROR: You cannot workout at Powerhouse Gym because you are not in Sector-12. gymWorkout() failed"); return false; } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12PowerhouseGym; + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12PowerhouseGym; costMult = 10; expMult = 7.5; break; case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].VolhavenMilleniumFitnessGym: - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Volhaven) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Volhaven) { workerScript.scriptRef.log("ERROR: You cannot workout at Millenium Fitness Gym because you are not in Volhaven. gymWorkout() failed"); return false; } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].VolhavenMilleniumFitnessGym; + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].VolhavenMilleniumFitnessGym; costMult = 3; expMult = 2.5; break; @@ -23027,19 +23048,19 @@ function NetscriptFunctions(workerScript) { switch(stat.toLowerCase()) { case "strength".toLowerCase(): case "str".toLowerCase(): - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startClass(costMult, expMult, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ClassGymStrength); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].startClass(costMult, expMult, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ClassGymStrength); break; case "defense".toLowerCase(): case "def".toLowerCase(): - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startClass(costMult, expMult, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ClassGymDefense); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].startClass(costMult, expMult, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ClassGymDefense); break; case "dexterity".toLowerCase(): case "dex".toLowerCase(): - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startClass(costMult, expMult, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ClassGymDexterity); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].startClass(costMult, expMult, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ClassGymDexterity); break; case "agility".toLowerCase(): case "agi".toLowerCase(): - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startClass(costMult, expMult, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ClassGymAgility); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].startClass(costMult, expMult, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ClassGymAgility); break; default: workerScript.scriptRef.log("Invalid stat: " + stat + ". gymWorkout() failed"); @@ -23050,9 +23071,9 @@ function NetscriptFunctions(workerScript) { }, travelToCity(cityname) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].bitNodeN != 4) { if (!(hasSingularitySF && singularitySFLvl >= 1)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run travelToCity(). It is a Singularity Function and requires SourceFile-4 (level 1) to run."); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run travelToCity(). It is a Singularity Function and requires SourceFile-4 (level 1) to run."); return false; } } @@ -23064,9 +23085,9 @@ function NetscriptFunctions(workerScript) { case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].NewTokyo: case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Ishima: case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Volhaven: - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(200000); - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].city = cityname; - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainIntelligenceExp(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].IntelligenceSingFnBaseExpGain); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].loseMoney(200000); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].city = cityname; + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].gainIntelligenceExp(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].IntelligenceSingFnBaseExpGain); workerScript.scriptRef.log("Traveled to " + cityname); return true; default: @@ -23076,45 +23097,45 @@ function NetscriptFunctions(workerScript) { }, purchaseTor() { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].bitNodeN != 4) { if (!(hasSingularitySF && singularitySFLvl >= 1)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run purchaseTor(). It is a Singularity Function and requires SourceFile-4 (level 1) to run."); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run purchaseTor(). It is a Singularity Function and requires SourceFile-4 (level 1) to run."); return false; } } - if (__WEBPACK_IMPORTED_MODULE_17__SpecialServerIps_js__["a" /* SpecialServerIps */]["Darkweb Server"] != null) { + if (__WEBPACK_IMPORTED_MODULE_18__SpecialServerIps_js__["a" /* SpecialServerIps */]["Darkweb Server"] != null) { workerScript.scriptRef.log("You already have a TOR router! purchaseTor() failed"); return false; } - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.lt(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].TorRouterCost)) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].money.lt(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].TorRouterCost)) { workerScript.scriptRef.log("ERROR: You cannot afford to purchase a Tor router. purchaseTor() failed"); return false; } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].TorRouterCost); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].loseMoney(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].TorRouterCost); - var darkweb = new __WEBPACK_IMPORTED_MODULE_15__Server_js__["d" /* Server */](Object(__WEBPACK_IMPORTED_MODULE_27__utils_IPAddress_js__["a" /* createRandomIp */])(), "darkweb", "", false, false, false, 1); - Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["a" /* AddToAllServers */])(darkweb); - __WEBPACK_IMPORTED_MODULE_17__SpecialServerIps_js__["a" /* SpecialServerIps */].addIp("Darkweb Server", darkweb.ip); + var darkweb = new __WEBPACK_IMPORTED_MODULE_16__Server_js__["d" /* Server */](Object(__WEBPACK_IMPORTED_MODULE_28__utils_IPAddress_js__["a" /* createRandomIp */])(), "darkweb", "", false, false, false, 1); + Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["a" /* AddToAllServers */])(darkweb); + __WEBPACK_IMPORTED_MODULE_18__SpecialServerIps_js__["a" /* SpecialServerIps */].addIp("Darkweb Server", darkweb.ip); document.getElementById("location-purchase-tor").setAttribute("class", "a-link-button-inactive"); - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().serversOnNetwork.push(darkweb.ip); - darkweb.serversOnNetwork.push(__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().ip); - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainIntelligenceExp(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].IntelligenceSingFnBaseExpGain); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].getHomeComputer().serversOnNetwork.push(darkweb.ip); + darkweb.serversOnNetwork.push(__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].getHomeComputer().ip); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].gainIntelligenceExp(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].IntelligenceSingFnBaseExpGain); workerScript.scriptRef.log("You have purchased a Tor router!"); return true; }, purchaseProgram(programName) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].bitNodeN != 4) { if (!(hasSingularitySF && singularitySFLvl >= 1)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run purchaseProgram(). It is a Singularity Function and requires SourceFile-4 (level 1) to run."); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run purchaseProgram(). It is a Singularity Function and requires SourceFile-4 (level 1) to run."); return false; } } - if (__WEBPACK_IMPORTED_MODULE_17__SpecialServerIps_js__["a" /* SpecialServerIps */]["Darkweb Server"] == null) { + if (__WEBPACK_IMPORTED_MODULE_18__SpecialServerIps_js__["a" /* SpecialServerIps */]["Darkweb Server"] == null) { workerScript.scriptRef.log("ERROR: You do not have TOR router. purchaseProgram() failed."); return false; } @@ -23122,9 +23143,9 @@ function NetscriptFunctions(workerScript) { switch(programName.toLowerCase()) { case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].BruteSSHProgram.toLowerCase(): var price = Object(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["d" /* parseDarkwebItemPrice */])(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["a" /* DarkWebItems */].BruteSSHProgram); - if (price > 0 && __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.gt(price)) { - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(price); - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].BruteSSHProgram); + if (price > 0 && __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].money.gt(price)) { + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].loseMoney(price); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].BruteSSHProgram); workerScript.scriptRef.log("You have purchased the BruteSSH.exe program. The new program " + "can be found on your home computer."); } else { @@ -23134,9 +23155,9 @@ function NetscriptFunctions(workerScript) { return true; case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].FTPCrackProgram.toLowerCase(): var price = Object(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["d" /* parseDarkwebItemPrice */])(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["a" /* DarkWebItems */].FTPCrackProgram); - if (price > 0 && __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.gt(price)) { - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(price); - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].FTPCrackProgram); + if (price > 0 && __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].money.gt(price)) { + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].loseMoney(price); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].FTPCrackProgram); workerScript.scriptRef.log("You have purchased the FTPCrack.exe program. The new program " + "can be found on your home computer."); } else { @@ -23146,9 +23167,9 @@ function NetscriptFunctions(workerScript) { return true; case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].RelaySMTPProgram.toLowerCase(): var price = Object(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["d" /* parseDarkwebItemPrice */])(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["a" /* DarkWebItems */].RelaySMTPProgram); - if (price > 0 && __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.gt(price)) { - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(price); - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].RelaySMTPProgram); + if (price > 0 && __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].money.gt(price)) { + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].loseMoney(price); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].RelaySMTPProgram); workerScript.scriptRef.log("You have purchased the relaySMTP.exe program. The new program " + "can be found on your home computer."); } else { @@ -23158,9 +23179,9 @@ function NetscriptFunctions(workerScript) { return true; case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].HTTPWormProgram.toLowerCase(): var price = Object(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["d" /* parseDarkwebItemPrice */])(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["a" /* DarkWebItems */].HTTPWormProgram); - if (price > 0 && __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.gt(price)) { - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(price); - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].HTTPWormProgram); + if (price > 0 && __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].money.gt(price)) { + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].loseMoney(price); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].HTTPWormProgram); workerScript.scriptRef.log("You have purchased the HTTPWorm.exe program. The new program " + "can be found on your home computer."); } else { @@ -23170,9 +23191,9 @@ function NetscriptFunctions(workerScript) { return true; case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].SQLInjectProgram.toLowerCase(): var price = Object(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["d" /* parseDarkwebItemPrice */])(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["a" /* DarkWebItems */].SQLInjectProgram); - if (price > 0 && __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.gt(price)) { - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(price); - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].SQLInjectProgram); + if (price > 0 && __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].money.gt(price)) { + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].loseMoney(price); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].SQLInjectProgram); workerScript.scriptRef.log("You have purchased the SQLInject.exe program. The new program " + "can be found on your home computer."); } else { @@ -23182,9 +23203,9 @@ function NetscriptFunctions(workerScript) { return true; case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].DeepscanV1.toLowerCase(): var price = Object(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["d" /* parseDarkwebItemPrice */])(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["a" /* DarkWebItems */].DeepScanV1Program); - if (price > 0 && __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.gt(price)) { - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(price); - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].DeepscanV1); + if (price > 0 && __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].money.gt(price)) { + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].loseMoney(price); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].DeepscanV1); workerScript.scriptRef.log("You have purchased the DeepscanV1.exe program. The new program " + "can be found on your home computer."); } else { @@ -23194,9 +23215,9 @@ function NetscriptFunctions(workerScript) { return true; case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].DeepscanV2.toLowerCase(): var price = Object(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["d" /* parseDarkwebItemPrice */])(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["a" /* DarkWebItems */].DeepScanV2Program); - if (price > 0 && __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.gt(price)) { - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(price); - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].DeepscanV2); + if (price > 0 && __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].money.gt(price)) { + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].loseMoney(price); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].DeepscanV2); workerScript.scriptRef.log("You have purchased the DeepscanV2.exe program. The new program " + "can be found on your home computer."); } else { @@ -23211,42 +23232,42 @@ function NetscriptFunctions(workerScript) { return true; }, getStats : function() { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].bitNodeN != 4) { if (!(hasSingularitySF && singularitySFLvl >= 1)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getStats(). It is a Singularity Function and requires SourceFile-4 (level 1) to run."); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getStats(). It is a Singularity Function and requires SourceFile-4 (level 1) to run."); return {}; } } return { - hacking: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill, - strength: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].strength, - defense: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].defense, - dexterity: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].dexterity, - agility: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].agility, - charisma: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].charisma, - intelligence: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].intelligence + hacking: __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hacking_skill, + strength: __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].strength, + defense: __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].defense, + dexterity: __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].dexterity, + agility: __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].agility, + charisma: __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].charisma, + intelligence: __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].intelligence } }, isBusy : function() { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].bitNodeN != 4) { if (!(hasSingularitySF && singularitySFLvl >= 1)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run isBusy(). It is a Singularity Function and requires SourceFile-4 (level 1) to run."); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run isBusy(). It is a Singularity Function and requires SourceFile-4 (level 1) to run."); return; } } - return __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].isWorking; + return __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].isWorking; }, upgradeHomeRam() { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].bitNodeN != 4) { if (!(hasSingularitySF && singularitySFLvl >= 2)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run upgradeHomeRam(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run upgradeHomeRam(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); return false; } } //Calculate how many times ram has been upgraded (doubled) - var currentRam = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().maxRam; + var currentRam = __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].getHomeComputer().maxRam; var numUpgrades = Math.log2(currentRam); //Calculate cost @@ -23255,30 +23276,30 @@ function NetscriptFunctions(workerScript) { var mult = Math.pow(1.55, numUpgrades); cost = cost * mult; - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.lt(cost)) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].money.lt(cost)) { workerScript.scriptRef.log("ERROR: upgradeHomeRam() failed because you don't have enough money"); return false; } - var homeComputer = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer(); + var homeComputer = __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].getHomeComputer(); homeComputer.maxRam *= 2; - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(cost); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].loseMoney(cost); - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainIntelligenceExp(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].IntelligenceSingFnBaseExpGain); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].gainIntelligenceExp(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].IntelligenceSingFnBaseExpGain); workerScript.scriptRef.log("Purchased additional RAM for home computer! It now has " + homeComputer.maxRam + "GB of RAM."); return true; }, getUpgradeHomeRamCost() { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].bitNodeN != 4) { if (!(hasSingularitySF && singularitySFLvl >= 2)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getUpgradeHomeRamCost(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getUpgradeHomeRamCost(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); return false; } } //Calculate how many times ram has been upgraded (doubled) - var currentRam = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().maxRam; + var currentRam = __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].getHomeComputer().maxRam; var numUpgrades = Math.log2(currentRam); //Calculate cost @@ -23288,35 +23309,40 @@ function NetscriptFunctions(workerScript) { return cost * mult; }, workForCompany() { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].bitNodeN != 4) { if (!(hasSingularitySF && singularitySFLvl >= 2)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run workForCompany(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run workForCompany(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); return false; } } - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].companyPosition == "" || !(__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].companyPosition instanceof __WEBPACK_IMPORTED_MODULE_4__Company_js__["c" /* CompanyPosition */])) { + if (__WEBPACK_IMPORTED_MODULE_13__Missions_js__["c" /* inMission */]) { + workerScript.scriptRef.log("ERROR: universityCourse() failed because you are in the middle of a mission."); + return; + } + + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].companyPosition == "" || !(__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].companyPosition instanceof __WEBPACK_IMPORTED_MODULE_4__Company_js__["c" /* CompanyPosition */])) { workerScript.scriptRef.log("ERROR: workForCompany() failed because you do not have a job"); return false; } - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].isWorking) { - var txt = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].singularityStopWork(); + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].isWorking) { + var txt = __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].singularityStopWork(); workerScript.scriptRef.log(txt); } - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].companyPosition.isPartTimeJob()) { - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startWorkPartTime(); + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].companyPosition.isPartTimeJob()) { + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].startWorkPartTime(); } else { - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startWork(); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].startWork(); } - workerScript.scriptRef.log("Began working at " + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].companyName + " as a " + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].companyPosition.positionName); + workerScript.scriptRef.log("Began working at " + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].companyName + " as a " + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].companyPosition.positionName); return true; }, applyToCompany(companyName, field) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].bitNodeN != 4) { if (!(hasSingularitySF && singularitySFLvl >= 2)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run applyToCompany(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run applyToCompany(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); return false; } } @@ -23326,68 +23352,68 @@ function NetscriptFunctions(workerScript) { return false; } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = companyName; + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].location = companyName; var res; switch (field.toLowerCase()) { case "software": - res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForSoftwareJob(true); + res = __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].applyForSoftwareJob(true); break; case "software consultant": - res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForSoftwareConsultantJob(true); + res = __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].applyForSoftwareConsultantJob(true); break; case "it": - res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForItJob(true); + res = __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].applyForItJob(true); break; case "security engineer": - res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForSecurityEngineerJob(true); + res = __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].applyForSecurityEngineerJob(true); break; case "network engineer": - res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForNetworkEngineerJob(true); + res = __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].applyForNetworkEngineerJob(true); break; case "business": - res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForBusinessJob(true); + res = __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].applyForBusinessJob(true); break; case "business consultant": - res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForBusinessConsultantJob(true); + res = __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].applyForBusinessConsultantJob(true); break; case "security": - res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForSecurityJob(true); + res = __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].applyForSecurityJob(true); break; case "agent": - res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForAgentJob(true); + res = __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].applyForAgentJob(true); break; case "employee": - res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForEmployeeJob(true); + res = __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].applyForEmployeeJob(true); break; case "part-time employee": - res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForPartTimeEmployeeJob(true); + res = __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].applyForPartTimeEmployeeJob(true); break; case "waiter": - res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForWaiterJob(true); + res = __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].applyForWaiterJob(true); break; case "part-time waiter": - res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForPartTimeWaiterJob(true); + res = __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].applyForPartTimeWaiterJob(true); break; default: workerScript.scriptRef.log("ERROR: Invalid job passed into applyToCompany: " + field + ". applyToCompany() failed"); return false; } //The Player object's applyForJob function can return string with special error messages - if (Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["f" /* isString */])(res)) { + if (Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["f" /* isString */])(res)) { workerScript.scriptRef.log(res); return false; } if (res) { - workerScript.scriptRef.log("You were offered a new job at " + companyName + " as a " + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].companyPosition.positionName); + workerScript.scriptRef.log("You were offered a new job at " + companyName + " as a " + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].companyPosition.positionName); } else { workerScript.scriptRef.log("You failed to get a new job/promotion at " + companyName + " in the " + field + " field."); } return res; }, getCompanyRep(companyName) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].bitNodeN != 4) { if (!(hasSingularitySF && singularitySFLvl >= 2)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getCompanyRep(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getCompanyRep(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); return false; } } @@ -23400,19 +23426,19 @@ function NetscriptFunctions(workerScript) { return company.playerReputation; }, checkFactionInvitations() { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].bitNodeN != 4) { if (!(hasSingularitySF && singularitySFLvl >= 2)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run checkFactionInvitations(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run checkFactionInvitations(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); return false; } } //Make a copy of Player.factionInvitations - return __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].factionInvitations.slice(); + return __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].factionInvitations.slice(); }, joinFaction(name) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].bitNodeN != 4) { if (!(hasSingularitySF && singularitySFLvl >= 2)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run joinFaction(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run joinFaction(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); return false; } } @@ -23422,44 +23448,49 @@ function NetscriptFunctions(workerScript) { return false; } - if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].factionInvitations.includes(name)) { + if (!__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].factionInvitations.includes(name)) { workerScript.scriptRef.log("ERROR: Cannot join " + name + " Faction because you have not been invited. joinFaction() failed"); return false; } - var index = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].factionInvitations.indexOf(name); + var index = __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].factionInvitations.indexOf(name); if (index === -1) { //Redundant and should never happen... workerScript.scriptRef.log("ERROR: Cannot join " + name + " Faction because you have not been invited. joinFaction() failed"); return false; } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].factionInvitations.splice(index, 1); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].factionInvitations.splice(index, 1); var fac = __WEBPACK_IMPORTED_MODULE_9__Faction_js__["b" /* Factions */][name]; Object(__WEBPACK_IMPORTED_MODULE_9__Faction_js__["h" /* joinFaction */])(fac); - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainIntelligenceExp(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].IntelligenceSingFnBaseExpGain); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].gainIntelligenceExp(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].IntelligenceSingFnBaseExpGain); workerScript.scriptRef.log("Joined the " + name + " faction."); return true; }, workForFaction(name, type) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].bitNodeN != 4) { if (!(hasSingularitySF && singularitySFLvl >= 2)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run workForFaction(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run workForFaction(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); return false; } } + if (__WEBPACK_IMPORTED_MODULE_13__Missions_js__["c" /* inMission */]) { + workerScript.scriptRef.log("ERROR: universityCourse() failed because you are in the middle of a mission."); + return; + } + if (!Object(__WEBPACK_IMPORTED_MODULE_9__Faction_js__["d" /* factionExists */])(name)) { workerScript.scriptRef.log("ERROR: Faction specified in workForFaction() does not exist."); return false; } - if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].factions.includes(name)) { + if (!__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].factions.includes(name)) { workerScript.scriptRef.log("ERROR: workForFaction() failed because you are not a member of " + name); return false; } - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].isWorking) { - var txt = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].singularityStopWork(); + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].isWorking) { + var txt = __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].singularityStopWork(); workerScript.scriptRef.log(txt); } @@ -23493,7 +23524,7 @@ function NetscriptFunctions(workerScript) { workerScript.scriptRef.log("ERROR: Cannot carry out hacking contracts for " + fac.name + ". workForFaction() failed"); return false; } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startFactionHackWork(fac); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].startFactionHackWork(fac); workerScript.scriptRef.log("Started carrying out hacking contracts for " + fac.name); return true; case "field": @@ -23503,7 +23534,7 @@ function NetscriptFunctions(workerScript) { workerScript.scriptRef.log("ERROR: Cannot carry out field missions for " + fac.name + ". workForFaction() failed"); return false; } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startFactionFieldWork(fac); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].startFactionFieldWork(fac); workerScript.scriptRef.log("Started carrying out field missions for " + fac.name); return true; case "security": @@ -23513,7 +23544,7 @@ function NetscriptFunctions(workerScript) { workerScript.scriptRef.log("ERROR: Cannot serve as security detail for " + fac.name + ". workForFaction() failed"); return false; } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startFactionSecurityWork(fac); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].startFactionSecurityWork(fac); workerScript.scriptRef.log("Started serving as security details for " + fac.name); return true; default: @@ -23522,9 +23553,9 @@ function NetscriptFunctions(workerScript) { return true; }, getFactionRep(name) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].bitNodeN != 4) { if (!(hasSingularitySF && singularitySFLvl >= 2)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getFactionRep(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getFactionRep(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); return -1; } } @@ -23537,84 +23568,87 @@ function NetscriptFunctions(workerScript) { return __WEBPACK_IMPORTED_MODULE_9__Faction_js__["b" /* Factions */][name].playerReputation; }, createProgram(name) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].bitNodeN != 4) { if (!(hasSingularitySF && singularitySFLvl >= 3)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run createProgram(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run createProgram(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); return false; } } - - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].isWorking) { - var txt = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].singularityStopWork(); + if (__WEBPACK_IMPORTED_MODULE_13__Missions_js__["c" /* inMission */]) { + workerScript.scriptRef.log("ERROR: universityCourse() failed because you are in the middle of a mission."); + return; + } + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].isWorking) { + var txt = __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].singularityStopWork(); workerScript.scriptRef.log(txt); } switch(name.toLowerCase()) { case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].NukeProgram.toLowerCase(): - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].NukeProgram, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPerFiveMinutes, 1); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].NukeProgram, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPerFiveMinutes, 1); break; case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].BruteSSHProgram.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill < 50) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hacking_skill < 50) { workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create BruteSSH (level 50 req)"); return false; } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].BruteSSHProgram, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPerFiveMinutes * 2, 50); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].BruteSSHProgram, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPerFiveMinutes * 2, 50); break; case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].FTPCrackProgram.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill < 100) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hacking_skill < 100) { workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create FTPCrack (level 100 req)"); return false; } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].FTPCrackProgram, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPerHalfHour, 100); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].FTPCrackProgram, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPerHalfHour, 100); break; case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].RelaySMTPProgram.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill < 250) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hacking_skill < 250) { workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create relaySMTP (level 250 req)"); return false; } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].RelaySMTPProgram, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPer2Hours, 250); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].RelaySMTPProgram, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPer2Hours, 250); break; case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].HTTPWormProgram.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill < 500) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hacking_skill < 500) { workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create HTTPWorm (level 500 req)"); return false; } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].HTTPWormProgram, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPer4Hours, 500); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].HTTPWormProgram, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPer4Hours, 500); break; case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].SQLInjectProgram.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill < 750) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hacking_skill < 750) { workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create SQLInject (level 750 req)"); return false; } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].SQLInjectProgram, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPer8Hours, 750); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].SQLInjectProgram, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPer8Hours, 750); break; case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].DeepscanV1.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill < 75) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hacking_skill < 75) { workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create DeepscanV1 (level 75 req)"); return false; } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].DeepscanV1, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPerQuarterHour, 75); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].DeepscanV1, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPerQuarterHour, 75); break; case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].DeepscanV2.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill < 400) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hacking_skill < 400) { workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create DeepscanV2 (level 400 req)"); return false; } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].DeepscanV2, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPer2Hours, 400); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].DeepscanV2, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPer2Hours, 400); break; case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].ServerProfiler.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill < 75) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hacking_skill < 75) { workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create ServerProfiler (level 75 req)"); return false; } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].ServerProfiler, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPerHalfHour, 75); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].ServerProfiler, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPerHalfHour, 75); break; case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].AutoLink.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill < 25) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].hacking_skill < 25) { workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create AutoLink (level 25 req)"); return false; } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].AutoLink, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPerQuarterHour, 25); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].AutoLink, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPerQuarterHour, 25); break; default: workerScript.scriptRef.log("ERROR: createProgram() failed because the specified program does not exist: " + name); @@ -23623,38 +23657,41 @@ function NetscriptFunctions(workerScript) { workerScript.scriptRef.log("Began creating program: " + name); return true; }, - commitCrime(crime) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + commitCrime : function(crime) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].bitNodeN != 4) { if (!(hasSingularitySF && singularitySFLvl >= 3)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run commitCrime(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run commitCrime(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); return; } } - - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].isWorking) { - var txt = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].singularityStopWork(); + if (__WEBPACK_IMPORTED_MODULE_13__Missions_js__["c" /* inMission */]) { + workerScript.scriptRef.log("ERROR: universityCourse() failed because you are in the middle of a mission."); + return; + } + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].isWorking) { + var txt = __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].singularityStopWork(); workerScript.scriptRef.log(txt); } //Set Location to slums - switch(__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].city) { + switch(__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].city) { case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Aevum: - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].AevumSlums; + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].AevumSlums; break; case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Chongqing: - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].ChongqingSlums; + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].ChongqingSlums; break; case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12: - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12Slums; + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12Slums; break; case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].NewTokyo: - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].NewTokyoSlums; + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].NewTokyoSlums; break; case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Ishima: - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].IshimaSlums; + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].IshimaSlums; break; case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Volhaven: - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].VolhavenSlums; + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].VolhavenSlums; break; default: console.log("Invalid Player.city value"); @@ -23698,13 +23735,13 @@ function NetscriptFunctions(workerScript) { workerScript.scriptRef.log("Attempting to pull off a heist..."); return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["e" /* commitHeistCrime */])(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].CrimeSingFnDivider, {workerscript: workerScript}); } else { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid crime passed into commitCrime(): " + crime); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Invalid crime passed into commitCrime(): " + crime); } }, getCrimeChance(crime) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].bitNodeN != 4) { if (!(hasSingularitySF && singularitySFLvl >= 3)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getCrimeChance(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getCrimeChance(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); return; } } @@ -23735,31 +23772,31 @@ function NetscriptFunctions(workerScript) { } else if (crime.includes("heist")) { return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["q" /* determineCrimeChanceHeist */])(); } else { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid crime passed into getCrimeChance(): " + crime); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Invalid crime passed into getCrimeChance(): " + crime); } }, getOwnedAugmentations(purchased=false) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].bitNodeN != 4) { if (!(hasSingularitySF && singularitySFLvl >= 3)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getOwnedAugmentations(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getOwnedAugmentations(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); return []; } } var res = []; - for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].augmentations.length; ++i) { - res.push(__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].augmentations[i].name); + for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].augmentations.length; ++i) { + res.push(__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].augmentations[i].name); } if (purchased) { - for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].queuedAugmentations.length; ++i) { - res.push(__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].queuedAugmentations[i].name); + for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].queuedAugmentations.length; ++i) { + res.push(__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].queuedAugmentations[i].name); } } return res; }, getAugmentationsFromFaction(facname) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].bitNodeN != 4) { if (!(hasSingularitySF && singularitySFLvl >= 3)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getAugmentationsFromFaction(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getAugmentationsFromFaction(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); return []; } } @@ -23777,9 +23814,9 @@ function NetscriptFunctions(workerScript) { return res; }, getAugmentationCost(name) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].bitNodeN != 4) { if (!(hasSingularitySF && singularitySFLvl >= 3)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getAugmentationCost(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getAugmentationCost(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); return false; } } @@ -23793,9 +23830,9 @@ function NetscriptFunctions(workerScript) { return [aug.baseRepRequirement, aug.baseCost]; }, purchaseAugmentation(faction, name) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].bitNodeN != 4) { if (!(hasSingularitySF && singularitySFLvl >= 3)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run purchaseAugmentation(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run purchaseAugmentation(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); return false; } } @@ -23823,14 +23860,14 @@ function NetscriptFunctions(workerScript) { } if (!isNeuroflux) { - for (var j = 0; j < __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].queuedAugmentations.length; ++j) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].queuedAugmentations[j].name === aug.name) { + for (var j = 0; j < __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].queuedAugmentations.length; ++j) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].queuedAugmentations[j].name === aug.name) { workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because you already have " + name); return false; } } - for (var j = 0; j < __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].augmentations.length; ++j) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].augmentations[j].name === aug.name) { + for (var j = 0; j < __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].augmentations.length; ++j) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].augmentations[j].name === aug.name) { workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because you already have " + name); return false; } @@ -23844,26 +23881,26 @@ function NetscriptFunctions(workerScript) { var res = Object(__WEBPACK_IMPORTED_MODULE_9__Faction_js__["k" /* purchaseAugmentation */])(aug, fac, true); workerScript.scriptRef.log(res); - if (Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["f" /* isString */])(res) && res.startsWith("You purchased")) { - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainIntelligenceExp(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].IntelligenceSingFnBaseExpGain); + if (Object(__WEBPACK_IMPORTED_MODULE_29__utils_StringHelperFunctions_js__["f" /* isString */])(res) && res.startsWith("You purchased")) { + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].gainIntelligenceExp(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].IntelligenceSingFnBaseExpGain); return true; } else { return false; } }, installAugmentations(cbScript) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].bitNodeN != 4) { if (!(hasSingularitySF && singularitySFLvl >= 3)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run installAugmentations(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); + throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["d" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run installAugmentations(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); return false; } } - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].queuedAugmentations.length === 0) { + if (__WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].queuedAugmentations.length === 0) { workerScript.scriptRef.log("ERROR: installAugmentations() failed because you do not have any Augmentations to be installed"); return false; } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainIntelligenceExp(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].IntelligenceSingFnBaseExpGain); + __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].gainIntelligenceExp(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].IntelligenceSingFnBaseExpGain); workerScript.scriptRef.log("Installing Augmentations. This will cause this script to be killed"); Object(__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["h" /* installAugmentations */])(cbScript); return true; @@ -23892,7 +23929,7 @@ function NetscriptFunctions(workerScript) { /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Faction_js__ = __webpack_require__(10); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__NetscriptWorker_js__ = __webpack_require__(11); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Prestige_js__ = __webpack_require__(35); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Prestige_js__ = __webpack_require__(36); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Script_js__ = __webpack_require__(16); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Server_js__ = __webpack_require__(6); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_DialogBox_js__ = __webpack_require__(1); @@ -27097,6 +27134,7 @@ function yesNoBoxGetNoButton() { } function yesNoBoxCreate(txt) { + if (yesNoBoxOpen) {return false;} //Already open yesNoBoxOpen = true; var textElement = document.getElementById("yes-no-box-text"); if (textElement) { @@ -27109,6 +27147,7 @@ function yesNoBoxCreate(txt) { } else { console.log("ERROR: Container not found for YesNoBox"); } + return true; } /* Generic Yes-No POp-up Box with Text input */ @@ -27162,26 +27201,26 @@ function yesNoTxtInpBoxCreate(txt) { /* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return postNetburnerText; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return post; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Terminal; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Alias_js__ = __webpack_require__(43); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Alias_js__ = __webpack_require__(44); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Constants_js__ = __webpack_require__(3); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__CreateProgram_js__ = __webpack_require__(15); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__DarkWeb_js__ = __webpack_require__(44); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__DarkWeb_js__ = __webpack_require__(45); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__engine_js__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__HelpText_js__ = __webpack_require__(70); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__InteractiveTutorial_js__ = __webpack_require__(26); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Literature_js__ = __webpack_require__(45); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__HelpText_js__ = __webpack_require__(71); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__InteractiveTutorial_js__ = __webpack_require__(27); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Literature_js__ = __webpack_require__(46); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Message_js__ = __webpack_require__(24); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__NetscriptEvaluator_js__ = __webpack_require__(37); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__NetscriptEvaluator_js__ = __webpack_require__(38); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__NetscriptWorker_js__ = __webpack_require__(11); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__RedPill_js__ = __webpack_require__(36); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__RedPill_js__ = __webpack_require__(37); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__Script_js__ = __webpack_require__(16); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__Server_js__ = __webpack_require__(6); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__SpecialServerIps_js__ = __webpack_require__(12); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__TextFile_js__ = __webpack_require__(47); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__TextFile_js__ = __webpack_require__(49); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__utils_StringHelperFunctions_js__ = __webpack_require__(4); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__utils_HelperFunctions_js__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__utils_LogBox_js__ = __webpack_require__(29); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__utils_LogBox_js__ = __webpack_require__(30); @@ -28770,9 +28809,9 @@ let Terminal = { post("Server base security level: " + serv.baseDifficulty); post("Server current security level: " + serv.hackDifficulty); post("Server growth rate: " + serv.serverGrowth); - post("Netscript hack() execution time: " + Object(__WEBPACK_IMPORTED_MODULE_17__utils_StringHelperFunctions_js__["c" /* formatNumber */])(Object(__WEBPACK_IMPORTED_MODULE_9__NetscriptEvaluator_js__["i" /* scriptCalculateHackingTime */])(serv), 1) + "s"); - post("Netscript grow() execution time: " + Object(__WEBPACK_IMPORTED_MODULE_17__utils_StringHelperFunctions_js__["c" /* formatNumber */])(Object(__WEBPACK_IMPORTED_MODULE_9__NetscriptEvaluator_js__["g" /* scriptCalculateGrowTime */])(serv)/1000, 1) + "s"); - post("Netscript weaken() execution time: " + Object(__WEBPACK_IMPORTED_MODULE_17__utils_StringHelperFunctions_js__["c" /* formatNumber */])(Object(__WEBPACK_IMPORTED_MODULE_9__NetscriptEvaluator_js__["k" /* scriptCalculateWeakenTime */])(serv)/1000, 1) + "s"); + post("Netscript hack() execution time: " + Object(__WEBPACK_IMPORTED_MODULE_17__utils_StringHelperFunctions_js__["c" /* formatNumber */])(Object(__WEBPACK_IMPORTED_MODULE_9__NetscriptEvaluator_js__["j" /* scriptCalculateHackingTime */])(serv), 1) + "s"); + post("Netscript grow() execution time: " + Object(__WEBPACK_IMPORTED_MODULE_17__utils_StringHelperFunctions_js__["c" /* formatNumber */])(Object(__WEBPACK_IMPORTED_MODULE_9__NetscriptEvaluator_js__["h" /* scriptCalculateGrowTime */])(serv)/1000, 1) + "s"); + post("Netscript weaken() execution time: " + Object(__WEBPACK_IMPORTED_MODULE_17__utils_StringHelperFunctions_js__["c" /* formatNumber */])(Object(__WEBPACK_IMPORTED_MODULE_9__NetscriptEvaluator_js__["l" /* scriptCalculateWeakenTime */])(serv)/1000, 1) + "s"); break; case __WEBPACK_IMPORTED_MODULE_2__CreateProgram_js__["a" /* Programs */].AutoLink: post("This executable cannot be run."); @@ -28920,9 +28959,9 @@ let Terminal = { /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Message; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Augmentations_js__ = __webpack_require__(20); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__CreateProgram_js__ = __webpack_require__(15); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Missions_js__ = __webpack_require__(32); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Missions_js__ = __webpack_require__(26); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__RedPill_js__ = __webpack_require__(36); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__RedPill_js__ = __webpack_require__(37); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Server_js__ = __webpack_require__(6); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Settings_js__ = __webpack_require__(14); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__ = __webpack_require__(1); @@ -29134,7 +29173,7 @@ function initMessages() { /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Server_js__ = __webpack_require__(6); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__utils_DialogBox_js__ = __webpack_require__(1); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__utils_HelperFunctions_js__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__utils_LogBox_js__ = __webpack_require__(29); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__utils_LogBox_js__ = __webpack_require__(30); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_numeral_min_js__ = __webpack_require__(18); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_numeral_min_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_6__utils_numeral_min_js__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_StringHelperFunctions_js__ = __webpack_require__(4); @@ -29425,6 +29464,1458 @@ function updateActiveScriptsText(workerscript, item, statsEl=null) { /* 26 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { +"use strict"; +/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return HackingMission; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return inMission; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return setInMission; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return currMission; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Constants_js__ = __webpack_require__(3); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__engine_js__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Faction_js__ = __webpack_require__(10); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Player_js__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__utils_DialogBox_js__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_jsplumb__ = __webpack_require__(53); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_jsplumb___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_7_jsplumb__); + + + + + + + + + +let inMission = false; //Flag to denote whether a mission is running +let currMission = null; +function setInMission(bool, mission) { + inMission = bool; + if (bool) { + currMission = mission; + } else { + currMission = null; + } +} + +//Keyboard shortcuts +$(document).keydown(function(e) { + if (inMission && currMission && currMission.selectedNode != null) { + switch (e.keyCode) { + case 65: //a for Attack + currMission.actionButtons[0].click(); + break; + case 83: //s for Scan + currMission.actionButtons[1].click(); + break; + case 87: //w for Weaken + currMission.actionButtons[2].click(); + break; + case 70: //f for Fortify + currMission.actionButtons[3].click(); + break; + case 82: //r for Overflow + currMission.actionButtons[4].click(); + break; + case 68: //d for Detach connection + currMission.actionButtons[5].click(); + break; + default: + break; + } + } +}); + +let NodeTypes = { + Core: "CPU Core Node", //All actions available + Firewall: "Firewall Node", //No actions available + Database: "Database Node", //No actions available + Spam: "Spam Node", //No actions Available + Transfer: "Transfer Node", //Can Weaken, Scan, Fortify and Overflow + Shield: "Shield Node" //Can Fortify +} + +let NodeActions = { + Attack: "Attacking", //Damaged based on attack stat + hacking level + opp def + Scan: "Scanning", //-Def for target, affected by attack and hacking level + Weaken: "Weakening", //-Attack for target, affected by attack and hacking level + Fortify: "Fortifying", //+Defense for Node, affected by hacking level + Overflow: "Overflowing", //+Attack but -Defense for Node, affected by hacking level +} + +function Node(type, stats) { + this.type = type; + this.atk = stats.atk ? stats.atk : 0; + this.def = stats.def ? stats.def : 0; + this.hp = stats.hp ? stats.hp : 0; + this.maxhp = this.hp; + this.plyrCtrl = false; + this.enmyCtrl = false; + this.pos = [0, 0]; //x, y + this.el = null; //Holds the Node's DOM element + this.action = null; + this.targetedCount = 0; //Count of how many connections this node is the target of + + //Holds the JsPlumb Connection object for this Node, + //where this Node is the Source (since each Node + //can only have 1 outgoing Connection) + this.conn = null; +} + +Node.prototype.setPosition = function(x, y) { + this.pos = [x, y]; +} + +Node.prototype.setControlledByPlayer = function() { + this.plyrCtrl = true; + this.enmyCtrl = false; + if (this.el) { + this.el.classList.remove("hack-mission-enemy-node"); + this.el.classList.add("hack-mission-player-node"); + } +} + +Node.prototype.setControlledByEnemy = function() { + this.plyrCtrl = false; + this.enmyCtrl = true; + if (this.el) { + this.el.classList.remove("hack-mission-player-node"); + this.el.classList.add("hack-mission-enemy-node"); + } +} + +//Sets this node to be the active node +Node.prototype.select = function(actionButtons) { + if (this.enmyCtrl) {return;} + this.el.classList.add("hack-mission-player-node-active"); + + //Make all buttons inactive + for (var i = 0; i < actionButtons.length; ++i) { + actionButtons[i].classList.remove("a-link-button"); + actionButtons[i].classList.add("a-link-button-inactive"); + } + + switch(this.type) { + case NodeTypes.Core: + //All buttons active + for (var i = 0; i < actionButtons.length; ++i) { + actionButtons[i].classList.remove("a-link-button-inactive"); + actionButtons[i].classList.add("a-link-button"); + } + break; + case NodeTypes.Transfer: + actionButtons[1].classList.remove("a-link-button-inactive"); + actionButtons[1].classList.add("a-link-button"); + actionButtons[2].classList.remove("a-link-button-inactive"); + actionButtons[2].classList.add("a-link-button"); + actionButtons[3].classList.remove("a-link-button-inactive"); + actionButtons[3].classList.add("a-link-button"); + actionButtons[4].classList.remove("a-link-button-inactive"); + actionButtons[4].classList.add("a-link-button"); + actionButtons[5].classList.remove("a-link-button-inactive"); + actionButtons[5].classList.add("a-link-button"); + break; + default: + break; + } +} + +Node.prototype.deselect = function(actionButtons) { + this.el.classList.remove("hack-mission-player-node-active"); + for (var i = 0; i < actionButtons.length; ++i) { + actionButtons[i].classList.remove("a-link-button"); + actionButtons[i].classList.add("a-link-button-inactive"); + } +} + + +Node.prototype.untarget = function() { + if (this.targetedCount === 0) { + console.log("WARN: Node " + this.el.id + " is being 'untargeted' when it has no target count"); + return; + } + --this.targetedCount; +} + +//Hacking mission instance +//Takes in the reputation of the Faction for which the mission is +//being conducted +function HackingMission(rep, fac) { + this.faction = fac; + + this.started = false; + this.time = 180000; //5 minutes to start, milliseconds + + this.playerCores = []; + this.playerNodes = []; //Non-core nodes + this.playerAtk = 0; + this.playerDef = 0; + + this.enemyCores = []; + this.enemyDatabases = []; + this.enemyNodes = []; //Non-core nodes + this.enemyAtk = 0; + this.enemyDef = 0; + + this.miscNodes = []; + + this.selectedNode = null; //Which of the player's nodes is currently selected + + this.actionButtons = []; //DOM buttons for actions + + this.availablePositions = []; + for (var r = 0; r < 8; ++r) { + for (var c = 0; c < 8; ++c) { + this.availablePositions.push([r, c]); + } + } + + this.map = []; + for (var i = 0; i < 8; ++i) { + this.map.push([null, null, null, null, null, null, null, null]); + } + + this.jsplumbinstance = null; + + this.difficulty = rep / __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].HackingMissionRepToDiffConversion + 1; + console.log("difficulty: " + this.difficulty); + this.reward = 250 + (rep / __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].HackingMissionRepToRewardConversion); +} + +HackingMission.prototype.init = function() { + //Create Header DOM + this.createPageDom(); + + //Create player starting nodes + var home = __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].getHomeComputer() + for (var i = 0; i < home.cpuCores; ++i) { + var stats = { + atk: (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill / 7.5) + 30, + def: (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill / 20), + hp: (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill / 4), + }; + this.playerCores.push(new Node(NodeTypes.Core, stats)); + this.playerCores[i].setControlledByPlayer(); + this.setNodePosition(this.playerCores[i], i, 0); + this.removeAvailablePosition(i, 0); + } + + //Randomly generate enemy nodes (CPU and Firewall) based on difficulty + var numNodes = Math.min(8, Math.max(1, Math.round(this.difficulty / 4))); + var numFirewalls = Math.min(20, + Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(Math.round(this.difficulty/2), Math.round(this.difficulty/2) + 1)); + var numDatabases = Math.min(10, Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(1, Math.round(this.difficulty / 3) + 1)); + var totalNodes = numNodes + numFirewalls + numDatabases; + var xlimit = 7 - Math.floor(totalNodes / 8); + console.log("numNodes: " + numNodes); + console.log("numFirewalls: " + numFirewalls); + console.log("numDatabases: " + numDatabases); + console.log("totalNodes: " + totalNodes); + console.log("xlimit: " + xlimit); + var randMult = Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["a" /* addOffset */])(0.8 + (this.difficulty / 5), 10); + for (var i = 0; i < numNodes; ++i) { + var stats = { + atk: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(75, 85), + def: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(25, 35), + hp: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(210, 230) + } + this.enemyCores.push(new Node(NodeTypes.Core, stats)); + this.enemyCores[i].setControlledByEnemy(); + this.setNodeRandomPosition(this.enemyCores[i], xlimit); + } + for (var i = 0; i < numFirewalls; ++i) { + var stats = { + atk: 0, + def: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(80, 90), + hp: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(275, 300) + } + this.enemyNodes.push(new Node(NodeTypes.Firewall, stats)); + this.enemyNodes[i].setControlledByEnemy(); + this.setNodeRandomPosition(this.enemyNodes[i], xlimit); + } + for (var i = 0; i < numDatabases; ++i) { + var stats = { + atk: 0, + def: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(70, 85), + hp: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(210, 275) + } + var node = new Node(NodeTypes.Database, stats); + node.setControlledByEnemy(); + this.setNodeRandomPosition(node, xlimit); + this.enemyDatabases.push(node); + } + this.calculateDefenses(); + this.calculateAttacks(); + this.createMap(); +} + +HackingMission.prototype.createPageDom = function() { + var container = document.getElementById("mission-container"); + + var favorMult = 1 + (this.faction.favor / 100); + var gain = this.reward * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].faction_rep_mult * favorMult; + var headerText = document.createElement("p"); + headerText.innerHTML = "You are about to start a hacking mission! You will gain " + + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(gain, 3) + " faction reputation with " + this.faction.name + + " if you win. For more information " + + "about how hacking missions work, click one of the guide links " + + "below (one opens up an in-game guide and the other opens up " + + "the guide from the wiki). Click the 'Start' button to begin."; + headerText.style.display = "block"; + headerText.classList.add("hack-mission-header-element"); + headerText.style.width = "80%"; + + var inGameGuideBtn = document.createElement("a"); + inGameGuideBtn.innerText = "How to Play"; + inGameGuideBtn.classList.add("a-link-button"); + inGameGuideBtn.style.display = "inline-block"; + inGameGuideBtn.classList.add("hack-mission-header-element"); + inGameGuideBtn.addEventListener("click", function() { + Object(__WEBPACK_IMPORTED_MODULE_4__utils_DialogBox_js__["a" /* dialogBoxCreate */])(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].HackingMissionHowToPlay); + return false; + }); + + var wikiGuideBtn = document.createElement("a"); + wikiGuideBtn.innerText = "Wiki Guide"; + wikiGuideBtn.classList.add("a-link-button"); + wikiGuideBtn.style.display = "inline-block"; + wikiGuideBtn.classList.add("hack-mission-header-element"); + wikiGuideBtn.target = "_blank"; + //TODO Add link to wiki page wikiGuideBtn.href = + + + //Start button will get replaced with forfeit when game is started + var startBtn = document.createElement("a"); + startBtn.innerHTML = "Start"; + startBtn.setAttribute("id", "hack-mission-start-btn"); + startBtn.classList.add("a-link-button"); + startBtn.classList.add("hack-mission-header-element"); + startBtn.style.display = "inline-block"; + startBtn.addEventListener("click", ()=>{ + this.start(); + return false; + }); + + var forfeitMission = document.createElement("a"); + forfeitMission.innerHTML = "Forfeit Mission (Exit)"; + forfeitMission.classList.add("a-link-button"); + forfeitMission.classList.add("hack-mission-header-element"); + forfeitMission.style.display = "inline-block"; + forfeitMission.addEventListener("click", ()=> { + this.finishMission(false); + return false; + }); + + var timer = document.createElement("p"); + timer.setAttribute("id", "hacking-mission-timer"); + timer.style.display = "inline-block"; + timer.style.margin = "6px"; + + //Create Action Buttons (Attack/Scan/Weaken/ etc...) + var actionsContainer = document.createElement("span"); + actionsContainer.style.display = "block"; + actionsContainer.classList.add("hack-mission-action-buttons-container"); + for (var i = 0; i < 6; ++i) { + this.actionButtons.push(document.createElement("a")); + this.actionButtons[i].style.display = "inline-block"; + this.actionButtons[i].classList.add("a-link-button-inactive"); //Disabled at start + this.actionButtons[i].classList.add("tooltip"); //Disabled at start + this.actionButtons[i].classList.add("hack-mission-header-element"); + actionsContainer.appendChild(this.actionButtons[i]); + } + this.actionButtons[0].innerText = "Attack(a)"; + var atkTooltip = document.createElement("span"); + atkTooltip.classList.add("tooltiptexthigh"); + atkTooltip.innerText = "Lowers the targeted node's HP. The effectiveness of this depends on " + + "this node's Attack level, your hacking level, and the opponent's defense level."; + this.actionButtons[0].appendChild(atkTooltip); + this.actionButtons[1].innerText = "Scan(s)"; + var scanTooltip = document.createElement("span"); + scanTooltip.classList.add("tooltiptexthigh"); + scanTooltip.innerText = "Lowers the targeted node's defense. The effectiveness of this depends on " + + "this node's Attack level, your hacking level, and the opponent's defense level."; + this.actionButtons[1].appendChild(scanTooltip); + this.actionButtons[2].innerText = "Weaken(w)"; + var WeakenTooltip = document.createElement("span"); + WeakenTooltip.classList.add("tooltiptexthigh"); + WeakenTooltip.innerText = "Lowers the targeted node's attack. The effectiveness of this depends on " + + "this node's Attack level, your hacking level, and the opponent's defense level."; + this.actionButtons[2].appendChild(WeakenTooltip); + this.actionButtons[3].innerText = "Fortify(f)"; + var fortifyTooltip = document.createElement("span"); + fortifyTooltip.classList.add("tooltiptexthigh"); + fortifyTooltip.innerText = "Raises this node's Defense level. The effectiveness of this depends on " + + "your hacking level"; + this.actionButtons[3].appendChild(fortifyTooltip); + this.actionButtons[4].innerText = "Overflow(r)"; + var overflowTooltip = document.createElement("span"); + overflowTooltip.classList.add("tooltiptexthigh"); + overflowTooltip.innerText = "Raises this node's Attack level but lowers its Defense level. The effectiveness " + + "of this depends on your hacking level."; + this.actionButtons[4].appendChild(overflowTooltip); + this.actionButtons[5].innerText = "Drop Connection(d)"; + var dropconnTooltip = document.createElement("span"); + dropconnTooltip.classList.add("tooltiptexthigh"); + dropconnTooltip.innerText = "Removes this Node's current connection to some target Node, if it has one. This can " + + "also be done by simply clicking the white connection line."; + this.actionButtons[5].appendChild(dropconnTooltip); + + //Player/enemy defense displays will be in action container + var playerStats = document.createElement("p"); + var enemyStats = document.createElement("p"); + playerStats.style.display = "inline-block"; + enemyStats.style.display = "inline-block"; + playerStats.style.color = "#00ccff"; + enemyStats.style.color = "red"; + playerStats.style.margin = "4px"; + enemyStats.style.margin = "4px"; + playerStats.setAttribute("id", "hacking-mission-player-stats"); + enemyStats.setAttribute("id", "hacking-mission-enemy-stats"); + actionsContainer.appendChild(playerStats); + actionsContainer.appendChild(enemyStats); + + //Set Action Button event listeners + this.actionButtons[0].addEventListener("click", ()=>{ + if (!(this.selectedNode instanceof Node)) { + console.log("ERR: Pressing Action button without selected node"); + return; + } + if (this.selectedNode.type !== NodeTypes.Core) {return;} + this.setActionButtonsActive(); + this.setActionButton(NodeActions.Attack, false); //Set attack button inactive + this.selectedNode.action = NodeActions.Attack; + }); + + this.actionButtons[1].addEventListener("click", ()=>{ + if (!(this.selectedNode instanceof Node)) { + console.log("ERR: Pressing Action button without selected node"); + return; + } + this.setActionButtonsActive(); + this.setActionButton(NodeActions.Scan, false); //Set scan button inactive + this.selectedNode.action = NodeActions.Scan; + }); + + this.actionButtons[2].addEventListener("click", ()=>{ + if (!(this.selectedNode instanceof Node)) { + console.log("ERR: Pressing Action button without selected node"); + return; + } + this.setActionButtonsActive(); + this.setActionButton(NodeActions.Weaken, false); //Set Weaken button inactive + this.selectedNode.action = NodeActions.Weaken; + }); + + this.actionButtons[3].addEventListener("click", ()=>{ + if (!(this.selectedNode instanceof Node)) { + console.log("ERR: Pressing Action button without selected node"); + return; + } + this.setActionButtonsActive(); + this.setActionButton(NodeActions.Fortify, false); //Set Fortify button inactive + this.selectedNode.action = NodeActions.Fortify; + }); + + this.actionButtons[4].addEventListener("click", ()=>{ + if (!(this.selectedNode instanceof Node)) { + console.log("ERR: Pressing Action button without selected node"); + return; + } + this.setActionButtonsActive(); + this.setActionButton(NodeActions.Overflow, false); //Set Overflow button inactive + this.selectedNode.action = NodeActions.Overflow; + }); + + this.actionButtons[5].addEventListener("click", ()=>{ + if (!(this.selectedNode instanceof Node)) { + console.log("ERR: Pressing Action button without selected node"); + return; + } + if (this.selectedNode.conn) { + var endpoints = this.selectedNode.conn.endpoints; + endpoints[0].detachFrom(endpoints[1]); + } + }) + + var timeDisplay = document.createElement("p"); + + container.appendChild(headerText); + container.appendChild(inGameGuideBtn); + container.appendChild(wikiGuideBtn); + container.appendChild(startBtn); + container.appendChild(forfeitMission); + container.appendChild(timer); + container.appendChild(actionsContainer); + container.appendChild(timeDisplay); +} + +HackingMission.prototype.setActionButtonsInactive = function() { + for (var i = 0; i < this.actionButtons.length; ++i) { + this.actionButtons[i].classList.remove("a-link-button"); + this.actionButtons[i].classList.add("a-link-button-inactive"); + } +} + +HackingMission.prototype.setActionButtonsActive = function() { + for (var i = 0; i < this.actionButtons.length; ++i) { + this.actionButtons[i].classList.add("a-link-button"); + this.actionButtons[i].classList.remove("a-link-button-inactive"); + } +} + +//True for active, false for inactive +HackingMission.prototype.setActionButton = function(i, active=true) { + if (Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["f" /* isString */])(i)) { + switch (i) { + case NodeActions.Attack: + i = 0; + break; + case NodeActions.Scan: + i = 1; + break; + case NodeActions.Weaken: + i = 2; + break; + case NodeActions.Fortify: + i = 3; + break; + case NodeActions.Overflow: + default: + i = 4; + break; + } + } + if (active) { + this.actionButtons[i].classList.remove("a-link-button-inactive"); + this.actionButtons[i].classList.add("a-link-button"); + } else { + this.actionButtons[i].classList.remove("a-link-button"); + this.actionButtons[i].classList.add("a-link-button-inactive"); + } + +} + +HackingMission.prototype.calculateAttacks = function() { + var total = 0; + for (var i = 0; i < this.playerCores.length; ++i) { + total += this.playerCores[i].atk; + } + for (var i = 0; i < this.playerNodes.length; ++i) { + total += this.playerNodes[i].atk; + } + this.playerAtk = total; + document.getElementById("hacking-mission-player-stats").innerHTML = + "Player Attack: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.playerAtk, 1) + "
" + + "Player Defense: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.playerDef, 1); + total = 0; + for (var i = 0; i < this.enemyCores.length; ++i) { + total += this.enemyCores[i].atk; + } + for (var i = 0; i < this.enemyDatabases.length; ++i) { + total += this.enemyDatabases[i].atk; + } + for (var i = 0; i < this.enemyNodes.length; ++i) { + total += this.enemyNodes[i].atk; + } + this.enemyAtk = total; + document.getElementById("hacking-mission-enemy-stats").innerHTML = + "Enemy Attack: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.enemyAtk, 1) + "
" + + "Enemy Defense: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.enemyDef, 1); +} + +HackingMission.prototype.calculateDefenses = function() { + var total = 0; + for (var i = 0; i < this.playerCores.length; ++i) { + total += this.playerCores[i].def; + } + for (var i = 0; i < this.playerNodes.length; ++i) { + total += this.playerNodes[i].def; + } + this.playerDef = total; + document.getElementById("hacking-mission-player-stats").innerHTML = + "Player Attack: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.playerAtk, 1) + "
" + + "Player Defense: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.playerDef, 1); + total = 0; + for (var i = 0; i < this.enemyCores.length; ++i) { + total += this.enemyCores[i].def; + } + for (var i = 0; i < this.enemyDatabases.length; ++i) { + total += this.enemyDatabases[i].def; + } + for (var i = 0; i < this.enemyNodes.length; ++i) { + total += this.enemyNodes[i].def; + } + this.enemyDef = total; + document.getElementById("hacking-mission-enemy-stats").innerHTML = + "Enemy Attack: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.enemyAtk, 1) + "
" + + "Enemy Defense: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.enemyDef, 1); +} + +HackingMission.prototype.removeAvailablePosition = function(x, y) { + for (var i = 0; i < this.availablePositions.length; ++i) { + if (this.availablePositions[i][0] === x && + this.availablePositions[i][1] === y) { + this.availablePositions.splice(i, 1); + return; + } + } + console.log("WARNING: removeAvailablePosition() did not remove " + x + ", " + y); +} + +HackingMission.prototype.setNodePosition = function(nodeObj, x, y) { + if (!(nodeObj instanceof Node)) { + console.log("WARNING: Non-Node object passed into setNodePOsition"); + return; + } + if (isNaN(x) || isNaN(y)) { + console.log("ERR: Invalid values passed as x and y for setNodePosition"); + console.log(x); + console.log(y); + return; + } + nodeObj.pos = [x, y]; + this.map[x][y] = nodeObj; +} + +HackingMission.prototype.setNodeRandomPosition = function(nodeObj, xlimit=0) { + var i = Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(0, this.availablePositions.length - 1); + if (this.availablePositions[i][1] < xlimit) { + //Recurse if not within limit + return this.setNodeRandomPosition(nodeObj, xlimit); + } + var pos = this.availablePositions.splice(i, 1); + pos = pos[0]; + this.setNodePosition(nodeObj, pos[0], pos[1]); +} + +HackingMission.prototype.createMap = function() { + //Use a grid + var map = document.createElement("div"); + map.classList.add("hack-mission-grid"); + map.setAttribute("id", "hacking-mission-map"); + document.getElementById("mission-container").appendChild(map); + + //Create random Nodes for every space in the map that + //hasn't been filled yet. The stats of each Node will be based on + //the player/enemy attack + var averageAttack = (this.playerAtk + this.enemyAtk) / 2; + for (var x = 0; x < 8; ++x) { + for (var y = 0; y < 8; ++y) { + if (!(this.map[x][y] instanceof Node)) { + var node, type = Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(0, 2); + var randMult = Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["a" /* addOffset */])(0.85 + (this.difficulty / 2), 15); + switch (type) { + case 0: //Spam + var stats = { + atk: 0, + def: averageAttack * 1.15 + Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(10, 50), + hp: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(200, 225) + } + node = new Node(NodeTypes.Spam, stats); + break; + case 1: //Transfer + var stats = { + atk: 0, + def: averageAttack * 1.15 + Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(10, 50), + hp: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(250, 275) + } + node = new Node(NodeTypes.Transfer, stats); + break; + case 2: //Shield + default: + var stats = { + atk: 0, + def: averageAttack * 1.15 + Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(25, 75), + hp: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(300, 320) + } + node = new Node(NodeTypes.Shield, stats); + break; + } + this.setNodePosition(node, x, y); + this.removeAvailablePosition(x, y); + this.miscNodes.push(node); + } + } + } + + //Create DOM elements in order + for (var r = 0; r < 8; ++r) { + for (var c = 0; c < 8; ++c) { + this.createNodeDomElement(this.map[r][c]); + } + } + + //Configure all Player CPUS + for (var i = 0; i < this.playerCores.length; ++i) { + console.log("Configuring Player Node: " + this.playerCores[i].el.id); + this.configurePlayerNodeElement(this.playerCores[i].el); + } +} + +HackingMission.prototype.createNodeDomElement = function(nodeObj) { + var nodeDiv = document.createElement("a"), txtEl = document.createElement('p'); + nodeObj.el = nodeDiv; + + //Set the node element's id based on its coordinates + var id = "hacking-mission-node-" + nodeObj.pos[0] + "-" + nodeObj.pos[1]; + nodeDiv.setAttribute("id", id); + txtEl.setAttribute("id", id + "-txt"); + + //Set node classes for owner + nodeDiv.classList.add("hack-mission-node"); + if (nodeObj.plyrCtrl) { + nodeDiv.classList.add("hack-mission-player-node"); + } else if (nodeObj.enmyCtrl) { + nodeDiv.classList.add("hack-mission-enemy-node"); + } + + //Set node classes based on type + var txt; + switch (nodeObj.type) { + case NodeTypes.Core: + txt = "CPU Core
" + "HP: " + + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); + nodeDiv.classList.add("hack-mission-cpu-node"); + break; + case NodeTypes.Firewall: + txt = "Firewall
" + "HP: " + + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); + nodeDiv.classList.add("hack-mission-firewall-node"); + break; + case NodeTypes.Database: + txt = "Database
" + "HP: " + + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); + nodeDiv.classList.add("hack-mission-database-node"); + break; + case NodeTypes.Spam: + txt = "Spam
" + "HP: " + + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); + nodeDiv.classList.add("hack-mission-spam-node"); + break; + case NodeTypes.Transfer: + txt = "Transfer
" + "HP: " + + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); + nodeDiv.classList.add("hack-mission-transfer-node"); + break; + case NodeTypes.Shield: + default: + txt = "Shield
" + "HP: " + + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); + nodeDiv.classList.add("hack-mission-shield-node"); + break; + } + + txt += "
Atk: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.atk, 1) + + "
Def: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.def, 1); + txtEl.innerHTML = txt; + + nodeDiv.appendChild(txtEl); + document.getElementById("hacking-mission-map").appendChild(nodeDiv); +} + +HackingMission.prototype.updateNodeDomElement = function(nodeObj) { + if (nodeObj.el == null) { + console.log("ERR: Calling updateNodeDomElement on a Node without an element"); + return; + } + + var id = "hacking-mission-node-" + nodeObj.pos[0] + "-" + nodeObj.pos[1]; + var nodeDiv = document.getElementById(id), txtEl = document.getElementById(id + "-txt"); + + //Set node classes based on type + var txt; + switch (nodeObj.type) { + case NodeTypes.Core: + txt = "CPU Core
" + "HP: " + + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); + break; + case NodeTypes.Firewall: + txt = "Firewall
" + "HP: " + + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); + break; + case NodeTypes.Database: + txt = "Database
" + "HP: " + + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); + break; + case NodeTypes.Spam: + txt = "Spam
" + "HP: " + + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); + break; + case NodeTypes.Transfer: + txt = "Transfer
" + "HP: " + + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); + break; + case NodeTypes.Shield: + default: + txt = "Shield
" + "HP: " + + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); + break; + } + + txt += "
Atk: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.atk, 1) + + "
Def: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.def, 1); + if (nodeObj.action) { + txt += "
" + nodeObj.action; + } + txtEl.innerHTML = txt; +} + +//Gets a Node DOM element's corresponding Node object using its +//element id. Function accepts either the DOM element object or the ID as +//an argument +HackingMission.prototype.getNodeFromElement = function(el) { + var id; + if (Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["f" /* isString */])(el)) { + id = el; + } else { + id = el.id; + } + id = id.replace("hacking-mission-node-", ""); + var res = id.split('-'); + if (res.length != 2) { + console.log("ERROR Parsing Hacking Mission Node Id. Could not find coordinates"); + return null; + } + var x = res[0], y = res[1]; + if (isNaN(x) || isNaN(y) || x >= 8 || y >= 8 || x < 0 || y < 0) { + console.log("ERROR: Unexpected values for x and y: " + x + ", " + y); + return null; + } + return this.map[x][y]; +} + +function selectNode(hackMissionInst, el) { + var nodeObj = hackMissionInst.getNodeFromElement(el); + if (nodeObj == null) {console.log("Error getting Node object");} + if (!nodeObj.plyrCtrl) {return;} + + if (hackMissionInst.selectedNode instanceof Node) { + hackMissionInst.selectedNode.deselect(hackMissionInst.actionButtons); + hackMissionInst.selectedNode = null; + } + nodeObj.select(hackMissionInst.actionButtons); + hackMissionInst.selectedNode = nodeObj; +} + +//Configures a DOM element representing a player-owned node to +//be selectable and actionable +//Note: Does NOT change its css class. This is handled by Node.setControlledBy... +HackingMission.prototype.configurePlayerNodeElement = function(el) { + var nodeObj = this.getNodeFromElement(el); + if (nodeObj == null) {console.log("Error getting Node object");} + + //Add event listener + var self = this; + function selectNodeWrapper() { + selectNode(self, el); + } + el.addEventListener("click", selectNodeWrapper); + + if (el.firstChild) { + el.firstChild.addEventListener("click", selectNodeWrapper); + } +} + +//Configures a DOM element representing an enemy-node by removing +//any event listeners +HackingMission.prototype.configureEnemyNodeElement = function(el) { + //Deselect node if it was the selected node + var nodeObj = this.getNodeFromElement(el); + if (this.selectedNode == nodeObj) { + nodeObj.deselect(this.actionButtons); + } +} + +//Returns bool indicating whether a node is reachable by player +//by checking if any of the adjacent nodes are owned by the player +HackingMission.prototype.nodeReachable = function(node) { + var x = node.pos[0], y = node.pos[1]; + if (x > 0 && this.map[x-1][y].plyrCtrl) {return true;} + if (x < 7 && this.map[x+1][y].plyrCtrl) {return true;} + if (y > 0 && this.map[x][y-1].plyrCtrl) {return true;} + if (y < 7 && this.map[x][y+1].plyrCtrl) {return true;} + return false; +} + +HackingMission.prototype.nodeReachableByEnemy = function(node) { + if (node == null) {return false;} + var x = node.pos[0], y = node.pos[1]; + if (x > 0 && this.map[x-1][y].enmyCtrl) {return true;} + if (x < 7 && this.map[x+1][y].enmyCtrl) {return true;} + if (y > 0 && this.map[x][y-1].enmyCtrl) {return true;} + if (y < 7 && this.map[x][y+1].enmyCtrl) {return true;} + return false; +} + +HackingMission.prototype.start = function() { + this.started = true; + this.initJsPlumb(); + var startBtn = Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["b" /* clearEventListeners */])("hack-mission-start-btn"); + startBtn.classList.remove("a-link-button"); + startBtn.classList.add("a-link-button-inactive"); +} + +HackingMission.prototype.initJsPlumb = function() { + var instance = jsPlumb.getInstance({ + DragOptions:{cursor:"pointer", zIndex:2000}, + PaintStyle: { + gradient: { stops: [ + [ 0, "#FFFFFF" ], + [ 1, "#FFFFFF" ] + ] }, + stroke: "#FFFFFF", + strokeWidth: 8 + }, + }); + + this.jsplumbinstance = instance; + + //All player cores are sources + for (var i = 0; i < this.playerCores.length; ++i) { + instance.makeSource(this.playerCores[i].el, { + deleteEndpointsOnEmpty:true, + maxConnections:1, + anchor:"Continuous", + connector:"Flowchart" + }); + } + + //Everything else is a target + for (var i = 0; i < this.enemyCores.length; ++i) { + instance.makeTarget(this.enemyCores[i].el, { + maxConnections:-1, + anchor:"Continuous", + connector:"Flowchart" + }); + } + for (var i = 0; i < this.enemyDatabases.length; ++i) { + instance.makeTarget(this.enemyDatabases[i].el, { + maxConnections:-1, + anchor:"Continuous", + connector:["Flowchart"] + }); + } + for (var i = 0; i < this.enemyNodes.length; ++i) { + instance.makeTarget(this.enemyNodes[i].el, { + maxConnections:-1, + anchor:"Continuous", + connector:"Flowchart" + }); + } + for (var i = 0; i < this.miscNodes.length; ++i) { + instance.makeTarget(this.miscNodes[i].el, { + maxConnections:-1, + anchor:"Continuous", + connector:"Flowchart" + }); + } + + //Clicking a connection drops it + instance.bind("click", function(conn, originalEvent) { + var endpoints = conn.endpoints; + endpoints[0].detachFrom(endpoints[1]); + }); + + //Connection events + instance.bind("connection", (info)=>{ + var targetNode = this.getNodeFromElement(info.target); + + //Do not detach for enemy nodes + var thisNode = this.getNodeFromElement(info.source); + if (thisNode.enmyCtrl) {return;} + + //If the node is not reachable, drop the connection + if (!this.nodeReachable(targetNode)) { + info.sourceEndpoint.detachFrom(info.targetEndpoint); + return; + } + + var sourceNode = this.getNodeFromElement(info.source); + sourceNode.conn = info.connection; + var targetNode = this.getNodeFromElement(info.target); + ++targetNode.targetedCount; + }); + + //Detach Connection events + instance.bind("connectionDetached", (info, originalEvent)=>{ + var sourceNode = this.getNodeFromElement(info.source); + sourceNode.conn = null; + var targetNode = this.getNodeFromElement(info.target); + targetNode.untarget(); + }); + +} + +//Drops all connections where the specified node is the source +HackingMission.prototype.dropAllConnectionsFromNode = function(node) { + var allConns = this.jsplumbinstance.getAllConnections(); + for (var i = allConns.length-1; i >= 0; --i) { + if (allConns[i].source == node.el) { + allConns[i].endpoints[0].detachFrom(allConns[i].endpoints[1]); + } + } +} + +//Drops all connections where the specified node is the target +HackingMission.prototype.dropAllConnectionsToNode = function(node) { + var allConns = this.jsplumbinstance.getAllConnections(); + for (var i = allConns.length-1; i >= 0; --i) { + if (allConns[i].target == node.el) { + allConns[i].endpoints[0].detachFrom(allConns[i].endpoints[1]); + } + } + node.beingTargeted = false; +} + +var storedCycles = 0; +HackingMission.prototype.process = function(numCycles=1) { + if (!this.started) {return;} + storedCycles += numCycles; + if (storedCycles < 2) {return;} //Only process every 3 cycles minimum + + var res = false; + //Process actions of all player nodes + this.playerCores.forEach((node)=>{ + res |= this.processNode(node, storedCycles); + }); + + this.playerNodes.forEach((node)=>{ + if (node.type === NodeTypes.Transfer) { + res |= this.processNode(node, storedCycles); + } + }); + + //Process actions of all enemy nodes + this.enemyCores.forEach((node)=>{ + this.enemyAISelectAction(node); + res |= this.processNode(node, storedCycles); + }); + + this.enemyNodes.forEach((node)=>{ + if (node.type === NodeTypes.Transfer) { + this.enemyAISelectAction(node); + res |= this.processNode(node, storedCycles); + } + }); + + //The hp of enemy databases increases slowly + this.enemyDatabases.forEach((node)=>{ + node.maxhp += (0.1 * storedCycles); + node.hp += (0.1 * storedCycles); + }); + + if (res) { + this.calculateAttacks(); + this.calculateDefenses(); + } + + //Win if all enemy databases are conquered + if (this.enemyDatabases.length === 0) { + this.finishMission(true); + return; + } + + //Lose if all your cores are gone + if (this.playerCores.length === 0) { + this.finishMission(false); + return; + } + + //Defense/hp of misc nodes increases slowly over time + this.miscNodes.forEach((node)=>{ + node.def += (0.1 * storedCycles); + node.maxhp += (0.05 * storedCycles); + node.hp += (0.1 * storedCycles); + if (node.hp > node.maxhp) {node.hp = node.maxhp;} + this.updateNodeDomElement(node); + }); + + //Update timer and check if player lost + this.time -= (storedCycles * __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"]._idleSpeed); + if (this.time <= 0) { + this.finishMission(false); + return; + } + this.updateTimer(); + + storedCycles = 0; +} + +//Returns a bool representing whether defenses need to be re-calculated +HackingMission.prototype.processNode = function(nodeObj, numCycles=1) { + if (nodeObj.action == null) { + return; + } + + var targetNode = null, def, atk; + if (nodeObj.conn) { + var targetNode; + if (nodeObj.conn.target) { + targetNode = this.getNodeFromElement(nodeObj.conn.target); + } else { + targetNode = this.getNodeFromElement(nodeObj.conn.targetId); + } + + if (targetNode.plyrCtrl) { + def = this.playerDef; + atk = this.enemyAtk; + } else if (targetNode.enmyCtrl) { + def = this.enemyDef; + atk = this.playerAtk; + } else { //Misc Node + def = targetNode.def; + nodeObj.plyrCtrl ? atk = this.playerAtk : atk = this.enemyAtk; + } + } + + //Calculations are per second, so divide everything by 5 + var calcStats = false, plyr = nodeObj.plyrCtrl; + var enmyHacking = this.difficulty * __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].HackingMissionDifficultyToHacking; + switch(nodeObj.action) { + case NodeActions.Attack: + if (nodeObj.conn == null) {break;} + var dmg = this.calculateAttackDamage(atk, def, plyr ? __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill : enmyHacking); + targetNode.hp -= (dmg/5 * numCycles); + break; + case NodeActions.Scan: + if (nodeObj.conn == null) {break;} + var eff = this.calculateScanEffect(atk, def, plyr ? __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill : enmyHacking); + targetNode.def -= (eff/5 * numCycles); + calcStats = true; + break; + case NodeActions.Weaken: + if (nodeObj.conn == null) {break;} + var eff = this.calculateWeakenEffect(atk, def, plyr ? __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill : enmyHacking); + targetNode.atk -= (eff/5 * numCycles); + calcStats = true; + break; + case NodeActions.Fortify: + var eff = this.calculateFortifyEffect(__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill); + nodeObj.def += (eff/5 * numCycles); + calcStats = true; + break; + case NodeActions.Overflow: + var eff = this.calculateOverflowEffect(__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill); + if (nodeObj.def < eff) {break;} + nodeObj.def -= (eff/5 * numCycles); + nodeObj.atk += (eff/5 * numCycles); + calcStats = true; + break; + default: + console.log("ERR: Invalid Node Action: " + nodeObj.action); + break; + } + + //Stats can't go below 0 + if (nodeObj.atk < 0) {nodeObj.atk = 0;} + if (nodeObj.def < 0) {nodeObj.def = 0;} + if (targetNode && targetNode.atk < 0) {targetNode.atk = 0;} + if (targetNode && targetNode.def < 0) {targetNode.def = 0;} + + //Conquering a node + if (targetNode && targetNode.hp <= 0) { + var conqueredByPlayer = nodeObj.plyrCtrl; + targetNode.hp = targetNode.maxhp; + targetNode.action = null; + targetNode.conn = null; + if (this.selectedNode == targetNode) { + targetNode.deselect(this.actionButtons); + } + + //The conquered node has its stats reduced + targetNode.atk /= 2; + targetNode.def /= 3.5; + + //Flag for whether the target node was a misc node + var isMiscNode = !targetNode.plyrCtrl && !targetNode.enmyCtrl; + + //Remove all connections from Node + this.dropAllConnectionsToNode(targetNode); + this.dropAllConnectionsFromNode(targetNode); + + //Changes the css class and turn the node into a JsPlumb Source/Target + if (conqueredByPlayer) { + targetNode.setControlledByPlayer(); + this.jsplumbinstance.unmakeTarget(targetNode.el); + this.jsplumbinstance.makeSource(targetNode.el, { + deleteEndpointsOnEmpty:true, + maxConnections:1, + anchor:"Continuous", + connector:"Flowchart" + }); + } else { + targetNode.setControlledByEnemy(); + nodeObj.conn = null; //Clear connection + this.jsplumbinstance.unmakeSource(targetNode.el); + this.jsplumbinstance.makeTarget(targetNode.el, { + maxConnections:-1, + anchor:"Continuous", + connector:["Flowchart"] + }); + } + + calcStats = true; + + //Helper function to swap nodes between the respective enemyNodes/playerNodes arrays + function swapNodes(orig, dest, targetNode) { + for (var i = 0; i < orig.length; ++i) { + if (orig[i] == targetNode) { + var node = orig.splice(i, 1); + node = node[0]; + dest.push(node); + break; + } + } + } + + switch(targetNode.type) { + case NodeTypes.Core: + if (conqueredByPlayer) { + swapNodes(this.enemyCores, this.playerCores, targetNode); + this.configurePlayerNodeElement(targetNode.el); + } else { + swapNodes(this.playerCores, this.enemyCores, targetNode); + this.configureEnemyNodeElement(targetNode.el); + } + break; + case NodeTypes.Firewall: + if (conqueredByPlayer) { + swapNodes(this.enemyNodes, this.playerNodes, targetNode); + } else { + swapNodes(this.playerNodes, this.enemyNodes, targetNode); + } + break; + case NodeTypes.Database: + if (conqueredByPlayer) { + swapNodes(this.enemyDatabases, this.playerNodes, targetNode); + } else { + swapNodes(this.playerNodes, this.enemyDatabases, targetNode); + } + break; + case NodeTypes.Spam: + if (conqueredByPlayer) { + swapNodes(isMiscNode ? this.miscNodes : this.enemyNodes, this.playerNodes, targetNode); + //Conquering spam node increases time limit + this.time += __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].HackingMissionSpamTimeIncrease; + } else { + swapNodes(isMiscNode ? this.miscNodes : this.playerNodes, this.enemyNodes, targetNode); + } + + break; + case NodeTypes.Transfer: + //Conquering a Transfer node increases the attack of all cores by some percentages + if (conqueredByPlayer) { + swapNodes(isMiscNode ? this.miscNodes : this.enemyNodes, this.playerNodes, targetNode); + this.playerCores.forEach(function(node) { + node.atk *= __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].HackingMissionTransferAttackIncrease; + }); + this.configurePlayerNodeElement(targetNode.el); + } else { + swapNodes(isMiscNode ? this.miscNodes : this.playerNodes, this.enemyNodes, targetNode); + this.enemyCores.forEach(function(node) { + node.atk *= __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].HackingMissionTransferAttackIncrease; + }); + this.configureEnemyNodeElement(targetNode.el); + } + break; + case NodeTypes.Shield: + if (conqueredByPlayer) { + swapNodes(isMiscNode ? this.miscNodes : this.enemyNodes, this.playerNodes, targetNode); + } else { + swapNodes(isMiscNode ? this.miscNodes : this.playerNodes, this.enemyNodes, targetNode); + } + break; + } + + //If a misc node was conquered, the defense for all misc nodes increases by some fixed amount + if (isMiscNode) { //&& conqueredByPlayer) { + this.miscNodes.forEach((node)=>{ + if (node.targetedCount === 0) { + node.def *= __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].HackingMissionMiscDefenseIncrease; + } + }); + } + } + + //Update node DOMs + this.updateNodeDomElement(nodeObj); + if (targetNode) {this.updateNodeDomElement(targetNode);} + return calcStats; +} + +//Enemy "AI" for CPU Core and Transfer Nodes +HackingMission.prototype.enemyAISelectAction = function(nodeObj) { + if (nodeObj == null) {return;} + switch(nodeObj.type) { + case NodeTypes.Core: + //Select a single RANDOM target from miscNodes and player's Nodes + //If it is reachable, it will target it. If not, no target will + //be selected for now, and the next time process() gets called this will repeat + if (nodeObj.conn == null) { + if (this.miscNodes.length === 0) { + //Randomly pick a player node and attack it if its reachable + var rand = Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(0, this.playerNodes.length-1); + var node; + if (this.playerNodes.length === 0) { + node = null; + } else { + node = this.playerNodes[rand]; + } + if (this.nodeReachableByEnemy(node)) { + //Create connection + nodeObj.conn = this.jsplumbinstance.connect({ + source:nodeObj.el, + target:node.el + }); + ++node.targetedCount; + } else { + //Randomly pick a player core and attack it if its reachable + rand = Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(0, this.playerCores.length-1); + if (this.playerCores.length === 0) { + return; //No Misc Nodes, no player Nodes, no Player cores. Player lost + } else { + node = this.playerCores[rand]; + } + + if (this.nodeReachableByEnemy(node)) { + //Create connection + nodeObj.conn = this.jsplumbinstance.connect({ + source:nodeObj.el, + target:node.el + }); + ++node.targetedCount; + } + } + } else { + //Randomly pick a misc node and attack it if its reachable + var rand = Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(0, this.miscNodes.length-1); + var node = this.miscNodes[rand]; + if (this.nodeReachableByEnemy(node)) { + nodeObj.conn = this.jsplumbinstance.connect({ + source:nodeObj.el, + target:node.el, + }); + ++node.targetedCount; + } + } + + //If no connection was made, set the Core to Fortify + nodeObj.action = NodeActions.Fortify; + } else { + //If this node has a selected target + var targetNode; + if (nodeObj.conn.target) { + targetNode = this.getNodeFromElement(nodeObj.conn.target); + } else { + targetNode = this.getNodeFromElement(nodeObj.conn.targetId); + } + if (targetNode == null) { + console.log("Error getting Target node Object in enemyAISelectAction()"); + } + + if (targetNode.def > this.enemyAtk + 15) { + if (nodeObj.def < 50) { + nodeObj.action = NodeActions.Fortify; + } else { + nodeObj.action = NodeActions.Overflow; + } + } else if (Math.abs(targetNode.def - this.enemyAtk) <= 15) { + nodeObj.action = NodeActions.Scan; + } else { + nodeObj.action = NodeActions.Attack; + } + } + break; + case NodeTypes.Transfer: + //Switch between fortifying and overflowing as necessary + if (nodeObj.def < 125) { + nodeObj.action = NodeActions.Fortify; + } else { + nodeObj.action = NodeActions.Overflow; + } + break; + default: + break; + } +} + +var hackEffWeightSelf = 130; //Weight for Node actions on self +var hackEffWeightTarget = 25; //Weight for Node Actions against Target +var hackEffWeightAttack = 80; //Weight for Attack action + +//Returns damage per cycle based on stats +HackingMission.prototype.calculateAttackDamage = function(atk, def, hacking = 0) { + return Math.max(0.75 * (atk + (hacking / hackEffWeightAttack) - def), 1); +} + +HackingMission.prototype.calculateScanEffect = function(atk, def, hacking=0) { + return Math.max(0.7 * ((atk) + hacking / hackEffWeightTarget - (def * 0.95)), 2); +} + +HackingMission.prototype.calculateWeakenEffect = function(atk, def, hacking=0) { + return Math.max((atk) + hacking / hackEffWeightTarget - (def * 0.95), 2); +} + +HackingMission.prototype.calculateFortifyEffect = function(hacking=0) { + return hacking / hackEffWeightSelf; +} + +HackingMission.prototype.calculateOverflowEffect = function(hacking=0) { + return hacking / hackEffWeightSelf; +} + +//Updates timer display +HackingMission.prototype.updateTimer = function() { + var timer = document.getElementById("hacking-mission-timer"); + + //Convert time remaining to a string of the form mm:ss + var seconds = Math.round(this.time / 1000); + var minutes = Math.trunc(seconds / 60); + seconds %= 60; + var str = ("0" + minutes).slice(-2) + ":" + ("0" + seconds).slice(-2); + timer.innerText = "Time left: " + str; +} + +//The 'win' argument is a bool for whether or not the player won +HackingMission.prototype.finishMission = function(win) { + inMission = false; + currMission = null; + + if (win) { + var favorMult = 1 + (this.faction.favor / 100); + console.log("Hacking mission base reward: " + this.reward); + console.log("favorMult: " + favorMult); + console.log("rep mult: " + __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].faction_rep_mult); + var gain = this.reward * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].faction_rep_mult * favorMult; + Object(__WEBPACK_IMPORTED_MODULE_4__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Mission won! You earned " + + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(gain, 3) + " reputation with " + this.faction.name); + __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gainIntelligenceExp(this.difficulty * __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].IntelligenceHackingMissionBaseExpGain); + this.faction.playerReputation += gain; + } else { + Object(__WEBPACK_IMPORTED_MODULE_4__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Mission lost/forfeited! You did not gain any faction reputation."); + } + + //Clear mission container + var container = document.getElementById("mission-container"); + while(container.firstChild) { + container.removeChild(container.firstChild); + } + + //Return to Faction page + document.getElementById("mainmenu-container").style.visibility = "visible"; + document.getElementById("character-overview-wrapper").style.visibility = "visible"; + __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].loadFactionContent(); + Object(__WEBPACK_IMPORTED_MODULE_2__Faction_js__["c" /* displayFactionContent */])(this.faction.name); +} + + + +/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(9))) + +/***/ }), +/* 27 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return iTutorialSteps; }); /* unused harmony export iTutorialEnd */ @@ -30097,7 +31588,7 @@ function iTutorialSetText(txt) { /***/ }), -/* 27 */ +/* 28 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_RESULT__;/*! decimal.js v7.2.3 https://github.com/MikeMcl/decimal.js/LICENCE */ @@ -34917,7 +36408,7 @@ var __WEBPACK_AMD_DEFINE_RESULT__;/*! decimal.js v7.2.3 https://github.com/MikeM /***/ }), -/* 28 */ +/* 29 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -35320,7 +36811,7 @@ function initStockMarket() { StockMarket[joesguns] = joesgunsStk; var catalyst = "Catalyst Ventures"; - var catalystStk = new Stock(catalyst, StockSymbols[catalyst], 1.6, true, 20, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(500, 1000)); + var catalystStk = new Stock(catalyst, StockSymbols[catalyst], 1.6, true, 15, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(500, 1000)); StockMarket[catalyst] = catalystStk; var microdyne = "Microdyne Technologies"; @@ -35361,8 +36852,8 @@ function stockMarketCycle() { for (var name in StockMarket) { if (StockMarket.hasOwnProperty(name)) { var stock = StockMarket[name]; - var thresh = 0.6; - if (stock.b) {thresh = 0.4;} + var thresh = 0.59; + if (stock.b) {thresh = 0.41;} if (Math.random() < thresh) { stock.b = !stock.b; } @@ -35785,6 +37276,8 @@ function createStockTicker(stock) { orderTypeSelect = document.createElement("select"), buyButton = document.createElement("span"), sellButton = document.createElement("span"), + buyMaxButton = document.createElement("span"), + sellAllButton = document.createElement("span"), positionTxt = document.createElement("p"), orderList = document.createElement("ul"); @@ -35905,6 +37398,76 @@ function createStockTicker(stock) { return false; }); + buyMaxButton.classList.add("stock-market-input"); + buyMaxButton.classList.add("a-link-button"); + buyMaxButton.innerHTML = "Buy MAX"; + buyMaxButton.addEventListener("click", ()=>{ + var pos = longShortSelect.options[longShortSelect.selectedIndex].text; + pos === "Long" ? pos = PositionTypes.Long : pos = PositionTypes.Short; + var ordType = orderTypeSelect.options[orderTypeSelect.selectedIndex].text; + var money = __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].money.toMoney(); + switch (ordType) { + case "Market Order": + var shares = Math.floor(money / stock.price); + pos === PositionTypes.Long ? buyStock(stock, shares) : shortStock(stock, shares, null); + break; + case "Limit Order": + case "Stop Order": + var yesBtn = Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["j" /* yesNoTxtInpBoxGetYesButton */])(), + noBtn = Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["i" /* yesNoTxtInpBoxGetNoButton */])(); + yesBtn.innerText = "Place Buy " + ordType; + noBtn.innerText = "Cancel Order"; + yesBtn.addEventListener("click", ()=>{ + var price = Number(Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["h" /* yesNoTxtInpBoxGetInput */])()), type; + if (ordType === "Limit Order") { + type = OrderTypes.LimitBuy; + } else { + type = OrderTypes.StopBuy; + } + var shares = Math.floor(money / price); + placeOrder(stock, shares, price, type, pos); + Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["f" /* yesNoTxtInpBoxClose */])(); + }); + noBtn.addEventListener("click", ()=>{ + Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["f" /* yesNoTxtInpBoxClose */])(); + }); + Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["g" /* yesNoTxtInpBoxCreate */])("Enter the price for your " + ordType); + break; + default: + console.log("ERROR: Invalid order type"); + break; + } + return false; + }); + + sellAllButton.classList.add("stock-market-input"); + sellAllButton.classList.add("a-link-button"); + sellAllButton.innerHTML = "Sell ALL"; + sellAllButton.addEventListener("click", ()=>{ + var pos = longShortSelect.options[longShortSelect.selectedIndex].text; + pos === "Long" ? pos = PositionTypes.Long : pos = PositionTypes.Short; + var ordType = orderTypeSelect.options[orderTypeSelect.selectedIndex].text; + switch (ordType) { + case "Market Order": + if (pos === PositionTypes.Long) { + var shares = stock.playerShares; + sellStock(stock, shares); + } else { + var shares = stock.playerShortShares; + sellShort(stock, shares, null); + } + break; + case "Limit Order": + case "Stop Order": + Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])("ERROR: 'Sell All' only works for Market Orders") + break; + default: + console.log("ERROR: Invalid order type"); + break; + } + return false; + }); + positionTxt.setAttribute("id", tickerId + "-position-text"); positionTxt.classList.add("stock-market-position-text"); stock.posTxtEl = positionTxt; @@ -35917,6 +37480,8 @@ function createStockTicker(stock) { stockDiv.appendChild(orderTypeSelect); stockDiv.appendChild(buyButton); stockDiv.appendChild(sellButton); + stockDiv.appendChild(buyMaxButton); + stockDiv.appendChild(sellAllButton); stockDiv.appendChild(positionTxt); stockDiv.appendChild(orderList); @@ -36079,7 +37644,7 @@ function updateStockOrderList(stock) { /***/ }), -/* 29 */ +/* 30 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -36150,7 +37715,7 @@ function logBoxUpdateText() { /* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(9))) /***/ }), -/* 30 */ +/* 31 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -36257,7 +37822,7 @@ Environment.prototype = { /***/ }), -/* 31 */ +/* 32 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -36568,1459 +38133,34 @@ function determineCrimeChanceHeist() { /***/ }), -/* 32 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { +/* 33 */ +/***/ (function(module, exports) { -"use strict"; -/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return HackingMission; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return inMission; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return setInMission; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return currMission; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Constants_js__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__engine_js__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Faction_js__ = __webpack_require__(10); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__utils_DialogBox_js__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_jsplumb__ = __webpack_require__(51); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_jsplumb___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_7_jsplumb__); +var g; +// This works in non-strict mode +g = (function() { + return this; +})(); - - - - - - - -let inMission = false; //Flag to denote whether a mission is running -let currMission = null; -function setInMission(bool, mission) { - inMission = bool; - if (bool) { - currMission = mission; - } else { - currMission = null; - } +try { + // This works if eval is allowed (see CSP) + g = g || Function("return this")() || (1,eval)("this"); +} catch(e) { + // This works if the window reference is available + if(typeof window === "object") + g = window; } -//Keyboard shortcuts -$(document).keydown(function(e) { - if (inMission && currMission && currMission.selectedNode != null) { - switch (e.keyCode) { - case 65: //a for Attack - currMission.actionButtons[0].click(); - break; - case 83: //s for Scan - currMission.actionButtons[1].click(); - break; - case 87: //w for Weaken - currMission.actionButtons[2].click(); - break; - case 70: //f for Fortify - currMission.actionButtons[3].click(); - break; - case 82: //r for Overflow - currMission.actionButtons[4].click(); - break; - case 68: //d for Detach connection - currMission.actionButtons[5].click(); - break; - default: - break; - } - } -}); +// g can still be undefined, but nothing to do about it... +// We return undefined, instead of nothing here, so it's +// easier to handle this case. if(!global) { ...} -let NodeTypes = { - Core: "CPU Core Node", //All actions available - Firewall: "Firewall Node", //No actions available - Database: "Database Node", //No actions available - Spam: "Spam Node", //No actions Available - Transfer: "Transfer Node", //Can Weaken, Scan, Fortify and Overflow - Shield: "Shield Node" //Can Fortify -} +module.exports = g; -let NodeActions = { - Attack: "Attacking", //Damaged based on attack stat + hacking level + opp def - Scan: "Scanning", //-Def for target, affected by attack and hacking level - Weaken: "Weakening", //-Attack for target, affected by attack and hacking level - Fortify: "Fortifying", //+Defense for Node, affected by hacking level - Overflow: "Overflowing", //+Attack but -Defense for Node, affected by hacking level -} - -function Node(type, stats) { - this.type = type; - this.atk = stats.atk ? stats.atk : 0; - this.def = stats.def ? stats.def : 0; - this.hp = stats.hp ? stats.hp : 0; - this.maxhp = this.hp; - this.plyrCtrl = false; - this.enmyCtrl = false; - this.pos = [0, 0]; //x, y - this.el = null; //Holds the Node's DOM element - this.action = null; - this.targetedCount = 0; //Count of how many connections this node is the target of - - //Holds the JsPlumb Connection object for this Node, - //where this Node is the Source (since each Node - //can only have 1 outgoing Connection) - this.conn = null; -} - -Node.prototype.setPosition = function(x, y) { - this.pos = [x, y]; -} - -Node.prototype.setControlledByPlayer = function() { - this.plyrCtrl = true; - this.enmyCtrl = false; - if (this.el) { - this.el.classList.remove("hack-mission-enemy-node"); - this.el.classList.add("hack-mission-player-node"); - } -} - -Node.prototype.setControlledByEnemy = function() { - this.plyrCtrl = false; - this.enmyCtrl = true; - if (this.el) { - this.el.classList.remove("hack-mission-player-node"); - this.el.classList.add("hack-mission-enemy-node"); - } -} - -//Sets this node to be the active node -Node.prototype.select = function(actionButtons) { - if (this.enmyCtrl) {return;} - this.el.classList.add("hack-mission-player-node-active"); - - //Make all buttons inactive - for (var i = 0; i < actionButtons.length; ++i) { - actionButtons[i].classList.remove("a-link-button"); - actionButtons[i].classList.add("a-link-button-inactive"); - } - - switch(this.type) { - case NodeTypes.Core: - //All buttons active - for (var i = 0; i < actionButtons.length; ++i) { - actionButtons[i].classList.remove("a-link-button-inactive"); - actionButtons[i].classList.add("a-link-button"); - } - break; - case NodeTypes.Transfer: - actionButtons[1].classList.remove("a-link-button-inactive"); - actionButtons[1].classList.add("a-link-button"); - actionButtons[2].classList.remove("a-link-button-inactive"); - actionButtons[2].classList.add("a-link-button"); - actionButtons[3].classList.remove("a-link-button-inactive"); - actionButtons[3].classList.add("a-link-button"); - actionButtons[4].classList.remove("a-link-button-inactive"); - actionButtons[4].classList.add("a-link-button"); - actionButtons[5].classList.remove("a-link-button-inactive"); - actionButtons[5].classList.add("a-link-button"); - break; - default: - break; - } -} - -Node.prototype.deselect = function(actionButtons) { - this.el.classList.remove("hack-mission-player-node-active"); - for (var i = 0; i < actionButtons.length; ++i) { - actionButtons[i].classList.remove("a-link-button"); - actionButtons[i].classList.add("a-link-button-inactive"); - } -} - - -Node.prototype.untarget = function() { - if (this.targetedCount === 0) { - console.log("WARN: Node " + this.el.id + " is being 'untargeted' when it has no target count"); - return; - } - --this.targetedCount; -} - -//Hacking mission instance -//Takes in the reputation of the Faction for which the mission is -//being conducted -function HackingMission(rep, fac) { - this.faction = fac; - - this.started = false; - this.time = 180000; //5 minutes to start, milliseconds - - this.playerCores = []; - this.playerNodes = []; //Non-core nodes - this.playerAtk = 0; - this.playerDef = 0; - - this.enemyCores = []; - this.enemyDatabases = []; - this.enemyNodes = []; //Non-core nodes - this.enemyAtk = 0; - this.enemyDef = 0; - - this.miscNodes = []; - - this.selectedNode = null; //Which of the player's nodes is currently selected - - this.actionButtons = []; //DOM buttons for actions - - this.availablePositions = []; - for (var r = 0; r < 8; ++r) { - for (var c = 0; c < 8; ++c) { - this.availablePositions.push([r, c]); - } - } - - this.map = []; - for (var i = 0; i < 8; ++i) { - this.map.push([null, null, null, null, null, null, null, null]); - } - - this.jsplumbinstance = null; - - this.difficulty = rep / __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].HackingMissionRepToDiffConversion + 1; - console.log("difficulty: " + this.difficulty); - this.reward = 250 + (rep / __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].HackingMissionRepToRewardConversion); -} - -HackingMission.prototype.init = function() { - //Create Header DOM - this.createPageDom(); - - //Create player starting nodes - var home = __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].getHomeComputer() - for (var i = 0; i < home.cpuCores; ++i) { - var stats = { - atk: (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill / 7.5) + 30, - def: (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill / 20), - hp: (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill / 4), - }; - this.playerCores.push(new Node(NodeTypes.Core, stats)); - this.playerCores[i].setControlledByPlayer(); - this.setNodePosition(this.playerCores[i], i, 0); - this.removeAvailablePosition(i, 0); - } - - //Randomly generate enemy nodes (CPU and Firewall) based on difficulty - var numNodes = Math.min(8, Math.max(1, Math.round(this.difficulty / 4))); - var numFirewalls = Math.min(20, - Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(Math.round(this.difficulty/2), Math.round(this.difficulty/2) + 1)); - var numDatabases = Math.min(10, Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(1, Math.round(this.difficulty / 3) + 1)); - var totalNodes = numNodes + numFirewalls + numDatabases; - var xlimit = 7 - Math.floor(totalNodes / 8); - console.log("numNodes: " + numNodes); - console.log("numFirewalls: " + numFirewalls); - console.log("numDatabases: " + numDatabases); - console.log("totalNodes: " + totalNodes); - console.log("xlimit: " + xlimit); - var randMult = Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["a" /* addOffset */])(0.8 + (this.difficulty / 5), 10); - for (var i = 0; i < numNodes; ++i) { - var stats = { - atk: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(75, 85), - def: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(25, 35), - hp: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(210, 230) - } - this.enemyCores.push(new Node(NodeTypes.Core, stats)); - this.enemyCores[i].setControlledByEnemy(); - this.setNodeRandomPosition(this.enemyCores[i], xlimit); - } - for (var i = 0; i < numFirewalls; ++i) { - var stats = { - atk: 0, - def: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(80, 90), - hp: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(275, 300) - } - this.enemyNodes.push(new Node(NodeTypes.Firewall, stats)); - this.enemyNodes[i].setControlledByEnemy(); - this.setNodeRandomPosition(this.enemyNodes[i], xlimit); - } - for (var i = 0; i < numDatabases; ++i) { - var stats = { - atk: 0, - def: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(70, 85), - hp: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(210, 275) - } - var node = new Node(NodeTypes.Database, stats); - node.setControlledByEnemy(); - this.setNodeRandomPosition(node, xlimit); - this.enemyDatabases.push(node); - } - this.calculateDefenses(); - this.calculateAttacks(); - this.createMap(); -} - -HackingMission.prototype.createPageDom = function() { - var container = document.getElementById("mission-container"); - - var favorMult = 1 + (this.faction.favor / 100); - var gain = this.reward * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].faction_rep_mult * favorMult; - var headerText = document.createElement("p"); - headerText.innerHTML = "You are about to start a hacking mission! You will gain " + - Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(gain, 3) + " faction reputation with " + this.faction.name + - " if you win. For more information " + - "about how hacking missions work, click one of the guide links " + - "below (one opens up an in-game guide and the other opens up " + - "the guide from the wiki). Click the 'Start' button to begin."; - headerText.style.display = "block"; - headerText.classList.add("hack-mission-header-element"); - headerText.style.width = "80%"; - - var inGameGuideBtn = document.createElement("a"); - inGameGuideBtn.innerText = "How to Play"; - inGameGuideBtn.classList.add("a-link-button"); - inGameGuideBtn.style.display = "inline-block"; - inGameGuideBtn.classList.add("hack-mission-header-element"); - inGameGuideBtn.addEventListener("click", function() { - Object(__WEBPACK_IMPORTED_MODULE_4__utils_DialogBox_js__["a" /* dialogBoxCreate */])(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].HackingMissionHowToPlay); - return false; - }); - - var wikiGuideBtn = document.createElement("a"); - wikiGuideBtn.innerText = "Wiki Guide"; - wikiGuideBtn.classList.add("a-link-button"); - wikiGuideBtn.style.display = "inline-block"; - wikiGuideBtn.classList.add("hack-mission-header-element"); - wikiGuideBtn.target = "_blank"; - //TODO Add link to wiki page wikiGuideBtn.href = - - - //Start button will get replaced with forfeit when game is started - var startBtn = document.createElement("a"); - startBtn.innerHTML = "Start"; - startBtn.setAttribute("id", "hack-mission-start-btn"); - startBtn.classList.add("a-link-button"); - startBtn.classList.add("hack-mission-header-element"); - startBtn.style.display = "inline-block"; - startBtn.addEventListener("click", ()=>{ - this.start(); - return false; - }); - - var forfeitMission = document.createElement("a"); - forfeitMission.innerHTML = "Forfeit Mission (Exit)"; - forfeitMission.classList.add("a-link-button"); - forfeitMission.classList.add("hack-mission-header-element"); - forfeitMission.style.display = "inline-block"; - forfeitMission.addEventListener("click", ()=> { - this.finishMission(false); - return false; - }); - - var timer = document.createElement("p"); - timer.setAttribute("id", "hacking-mission-timer"); - timer.style.display = "inline-block"; - timer.style.margin = "6px"; - - //Create Action Buttons (Attack/Scan/Weaken/ etc...) - var actionsContainer = document.createElement("span"); - actionsContainer.style.display = "block"; - actionsContainer.classList.add("hack-mission-action-buttons-container"); - for (var i = 0; i < 6; ++i) { - this.actionButtons.push(document.createElement("a")); - this.actionButtons[i].style.display = "inline-block"; - this.actionButtons[i].classList.add("a-link-button-inactive"); //Disabled at start - this.actionButtons[i].classList.add("tooltip"); //Disabled at start - this.actionButtons[i].classList.add("hack-mission-header-element"); - actionsContainer.appendChild(this.actionButtons[i]); - } - this.actionButtons[0].innerText = "Attack(a)"; - var atkTooltip = document.createElement("span"); - atkTooltip.classList.add("tooltiptexthigh"); - atkTooltip.innerText = "Lowers the targeted node's HP. The effectiveness of this depends on " + - "this node's Attack level, your hacking level, and the opponent's defense level."; - this.actionButtons[0].appendChild(atkTooltip); - this.actionButtons[1].innerText = "Scan(s)"; - var scanTooltip = document.createElement("span"); - scanTooltip.classList.add("tooltiptexthigh"); - scanTooltip.innerText = "Lowers the targeted node's defense. The effectiveness of this depends on " + - "this node's Attack level, your hacking level, and the opponent's defense level."; - this.actionButtons[1].appendChild(scanTooltip); - this.actionButtons[2].innerText = "Weaken(w)"; - var WeakenTooltip = document.createElement("span"); - WeakenTooltip.classList.add("tooltiptexthigh"); - WeakenTooltip.innerText = "Lowers the targeted node's attack. The effectiveness of this depends on " + - "this node's Attack level, your hacking level, and the opponent's defense level."; - this.actionButtons[2].appendChild(WeakenTooltip); - this.actionButtons[3].innerText = "Fortify(f)"; - var fortifyTooltip = document.createElement("span"); - fortifyTooltip.classList.add("tooltiptexthigh"); - fortifyTooltip.innerText = "Raises this node's Defense level. The effectiveness of this depends on " + - "your hacking level"; - this.actionButtons[3].appendChild(fortifyTooltip); - this.actionButtons[4].innerText = "Overflow(r)"; - var overflowTooltip = document.createElement("span"); - overflowTooltip.classList.add("tooltiptexthigh"); - overflowTooltip.innerText = "Raises this node's Attack level but lowers its Defense level. The effectiveness " + - "of this depends on your hacking level."; - this.actionButtons[4].appendChild(overflowTooltip); - this.actionButtons[5].innerText = "Drop Connection(d)"; - var dropconnTooltip = document.createElement("span"); - dropconnTooltip.classList.add("tooltiptexthigh"); - dropconnTooltip.innerText = "Removes this Node's current connection to some target Node, if it has one. This can " + - "also be done by simply clicking the white connection line."; - this.actionButtons[5].appendChild(dropconnTooltip); - - //Player/enemy defense displays will be in action container - var playerStats = document.createElement("p"); - var enemyStats = document.createElement("p"); - playerStats.style.display = "inline-block"; - enemyStats.style.display = "inline-block"; - playerStats.style.color = "#00ccff"; - enemyStats.style.color = "red"; - playerStats.style.margin = "4px"; - enemyStats.style.margin = "4px"; - playerStats.setAttribute("id", "hacking-mission-player-stats"); - enemyStats.setAttribute("id", "hacking-mission-enemy-stats"); - actionsContainer.appendChild(playerStats); - actionsContainer.appendChild(enemyStats); - - //Set Action Button event listeners - this.actionButtons[0].addEventListener("click", ()=>{ - if (!(this.selectedNode instanceof Node)) { - console.log("ERR: Pressing Action button without selected node"); - return; - } - if (this.selectedNode.type !== NodeTypes.Core) {return;} - this.setActionButtonsActive(); - this.setActionButton(NodeActions.Attack, false); //Set attack button inactive - this.selectedNode.action = NodeActions.Attack; - }); - - this.actionButtons[1].addEventListener("click", ()=>{ - if (!(this.selectedNode instanceof Node)) { - console.log("ERR: Pressing Action button without selected node"); - return; - } - this.setActionButtonsActive(); - this.setActionButton(NodeActions.Scan, false); //Set scan button inactive - this.selectedNode.action = NodeActions.Scan; - }); - - this.actionButtons[2].addEventListener("click", ()=>{ - if (!(this.selectedNode instanceof Node)) { - console.log("ERR: Pressing Action button without selected node"); - return; - } - this.setActionButtonsActive(); - this.setActionButton(NodeActions.Weaken, false); //Set Weaken button inactive - this.selectedNode.action = NodeActions.Weaken; - }); - - this.actionButtons[3].addEventListener("click", ()=>{ - if (!(this.selectedNode instanceof Node)) { - console.log("ERR: Pressing Action button without selected node"); - return; - } - this.setActionButtonsActive(); - this.setActionButton(NodeActions.Fortify, false); //Set Fortify button inactive - this.selectedNode.action = NodeActions.Fortify; - }); - - this.actionButtons[4].addEventListener("click", ()=>{ - if (!(this.selectedNode instanceof Node)) { - console.log("ERR: Pressing Action button without selected node"); - return; - } - this.setActionButtonsActive(); - this.setActionButton(NodeActions.Overflow, false); //Set Overflow button inactive - this.selectedNode.action = NodeActions.Overflow; - }); - - this.actionButtons[5].addEventListener("click", ()=>{ - if (!(this.selectedNode instanceof Node)) { - console.log("ERR: Pressing Action button without selected node"); - return; - } - if (this.selectedNode.conn) { - var endpoints = this.selectedNode.conn.endpoints; - endpoints[0].detachFrom(endpoints[1]); - } - }) - - var timeDisplay = document.createElement("p"); - - container.appendChild(headerText); - container.appendChild(inGameGuideBtn); - container.appendChild(wikiGuideBtn); - container.appendChild(startBtn); - container.appendChild(forfeitMission); - container.appendChild(timer); - container.appendChild(actionsContainer); - container.appendChild(timeDisplay); -} - -HackingMission.prototype.setActionButtonsInactive = function() { - for (var i = 0; i < this.actionButtons.length; ++i) { - this.actionButtons[i].classList.remove("a-link-button"); - this.actionButtons[i].classList.add("a-link-button-inactive"); - } -} - -HackingMission.prototype.setActionButtonsActive = function() { - for (var i = 0; i < this.actionButtons.length; ++i) { - this.actionButtons[i].classList.add("a-link-button"); - this.actionButtons[i].classList.remove("a-link-button-inactive"); - } -} - -//True for active, false for inactive -HackingMission.prototype.setActionButton = function(i, active=true) { - if (Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["f" /* isString */])(i)) { - switch (i) { - case NodeActions.Attack: - i = 0; - break; - case NodeActions.Scan: - i = 1; - break; - case NodeActions.Weaken: - i = 2; - break; - case NodeActions.Fortify: - i = 3; - break; - case NodeActions.Overflow: - default: - i = 4; - break; - } - } - if (active) { - this.actionButtons[i].classList.remove("a-link-button-inactive"); - this.actionButtons[i].classList.add("a-link-button"); - } else { - this.actionButtons[i].classList.remove("a-link-button"); - this.actionButtons[i].classList.add("a-link-button-inactive"); - } - -} - -HackingMission.prototype.calculateAttacks = function() { - var total = 0; - for (var i = 0; i < this.playerCores.length; ++i) { - total += this.playerCores[i].atk; - } - for (var i = 0; i < this.playerNodes.length; ++i) { - total += this.playerNodes[i].atk; - } - this.playerAtk = total; - document.getElementById("hacking-mission-player-stats").innerHTML = - "Player Attack: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.playerAtk, 1) + "
" + - "Player Defense: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.playerDef, 1); - total = 0; - for (var i = 0; i < this.enemyCores.length; ++i) { - total += this.enemyCores[i].atk; - } - for (var i = 0; i < this.enemyDatabases.length; ++i) { - total += this.enemyDatabases[i].atk; - } - for (var i = 0; i < this.enemyNodes.length; ++i) { - total += this.enemyNodes[i].atk; - } - this.enemyAtk = total; - document.getElementById("hacking-mission-enemy-stats").innerHTML = - "Enemy Attack: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.enemyAtk, 1) + "
" + - "Enemy Defense: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.enemyDef, 1); -} - -HackingMission.prototype.calculateDefenses = function() { - var total = 0; - for (var i = 0; i < this.playerCores.length; ++i) { - total += this.playerCores[i].def; - } - for (var i = 0; i < this.playerNodes.length; ++i) { - total += this.playerNodes[i].def; - } - this.playerDef = total; - document.getElementById("hacking-mission-player-stats").innerHTML = - "Player Attack: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.playerAtk, 1) + "
" + - "Player Defense: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.playerDef, 1); - total = 0; - for (var i = 0; i < this.enemyCores.length; ++i) { - total += this.enemyCores[i].def; - } - for (var i = 0; i < this.enemyDatabases.length; ++i) { - total += this.enemyDatabases[i].def; - } - for (var i = 0; i < this.enemyNodes.length; ++i) { - total += this.enemyNodes[i].def; - } - this.enemyDef = total; - document.getElementById("hacking-mission-enemy-stats").innerHTML = - "Enemy Attack: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.enemyAtk, 1) + "
" + - "Enemy Defense: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.enemyDef, 1); -} - -HackingMission.prototype.removeAvailablePosition = function(x, y) { - for (var i = 0; i < this.availablePositions.length; ++i) { - if (this.availablePositions[i][0] === x && - this.availablePositions[i][1] === y) { - this.availablePositions.splice(i, 1); - return; - } - } - console.log("WARNING: removeAvailablePosition() did not remove " + x + ", " + y); -} - -HackingMission.prototype.setNodePosition = function(nodeObj, x, y) { - if (!(nodeObj instanceof Node)) { - console.log("WARNING: Non-Node object passed into setNodePOsition"); - return; - } - if (isNaN(x) || isNaN(y)) { - console.log("ERR: Invalid values passed as x and y for setNodePosition"); - console.log(x); - console.log(y); - return; - } - nodeObj.pos = [x, y]; - this.map[x][y] = nodeObj; -} - -HackingMission.prototype.setNodeRandomPosition = function(nodeObj, xlimit=0) { - var i = Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(0, this.availablePositions.length - 1); - if (this.availablePositions[i][1] < xlimit) { - //Recurse if not within limit - return this.setNodeRandomPosition(nodeObj, xlimit); - } - var pos = this.availablePositions.splice(i, 1); - pos = pos[0]; - this.setNodePosition(nodeObj, pos[0], pos[1]); -} - -HackingMission.prototype.createMap = function() { - //Use a grid - var map = document.createElement("div"); - map.classList.add("hack-mission-grid"); - map.setAttribute("id", "hacking-mission-map"); - document.getElementById("mission-container").appendChild(map); - - //Create random Nodes for every space in the map that - //hasn't been filled yet. The stats of each Node will be based on - //the player/enemy attack - var averageAttack = (this.playerAtk + this.enemyAtk) / 2; - for (var x = 0; x < 8; ++x) { - for (var y = 0; y < 8; ++y) { - if (!(this.map[x][y] instanceof Node)) { - var node, type = Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(0, 2); - var randMult = Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["a" /* addOffset */])(0.85 + (this.difficulty / 2), 15); - switch (type) { - case 0: //Spam - var stats = { - atk: 0, - def: averageAttack * 1.15 + Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(10, 50), - hp: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(200, 225) - } - node = new Node(NodeTypes.Spam, stats); - break; - case 1: //Transfer - var stats = { - atk: 0, - def: averageAttack * 1.15 + Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(10, 50), - hp: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(250, 275) - } - node = new Node(NodeTypes.Transfer, stats); - break; - case 2: //Shield - default: - var stats = { - atk: 0, - def: averageAttack * 1.15 + Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(25, 75), - hp: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(300, 320) - } - node = new Node(NodeTypes.Shield, stats); - break; - } - this.setNodePosition(node, x, y); - this.removeAvailablePosition(x, y); - this.miscNodes.push(node); - } - } - } - - //Create DOM elements in order - for (var r = 0; r < 8; ++r) { - for (var c = 0; c < 8; ++c) { - this.createNodeDomElement(this.map[r][c]); - } - } - - //Configure all Player CPUS - for (var i = 0; i < this.playerCores.length; ++i) { - console.log("Configuring Player Node: " + this.playerCores[i].el.id); - this.configurePlayerNodeElement(this.playerCores[i].el); - } -} - -HackingMission.prototype.createNodeDomElement = function(nodeObj) { - var nodeDiv = document.createElement("a"), txtEl = document.createElement('p'); - nodeObj.el = nodeDiv; - - //Set the node element's id based on its coordinates - var id = "hacking-mission-node-" + nodeObj.pos[0] + "-" + nodeObj.pos[1]; - nodeDiv.setAttribute("id", id); - txtEl.setAttribute("id", id + "-txt"); - - //Set node classes for owner - nodeDiv.classList.add("hack-mission-node"); - if (nodeObj.plyrCtrl) { - nodeDiv.classList.add("hack-mission-player-node"); - } else if (nodeObj.enmyCtrl) { - nodeDiv.classList.add("hack-mission-enemy-node"); - } - - //Set node classes based on type - var txt; - switch (nodeObj.type) { - case NodeTypes.Core: - txt = "CPU Core
" + "HP: " + - Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); - nodeDiv.classList.add("hack-mission-cpu-node"); - break; - case NodeTypes.Firewall: - txt = "Firewall
" + "HP: " + - Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); - nodeDiv.classList.add("hack-mission-firewall-node"); - break; - case NodeTypes.Database: - txt = "Database
" + "HP: " + - Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); - nodeDiv.classList.add("hack-mission-database-node"); - break; - case NodeTypes.Spam: - txt = "Spam
" + "HP: " + - Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); - nodeDiv.classList.add("hack-mission-spam-node"); - break; - case NodeTypes.Transfer: - txt = "Transfer
" + "HP: " + - Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); - nodeDiv.classList.add("hack-mission-transfer-node"); - break; - case NodeTypes.Shield: - default: - txt = "Shield
" + "HP: " + - Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); - nodeDiv.classList.add("hack-mission-shield-node"); - break; - } - - txt += "
Atk: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.atk, 1) + - "
Def: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.def, 1); - txtEl.innerHTML = txt; - - nodeDiv.appendChild(txtEl); - document.getElementById("hacking-mission-map").appendChild(nodeDiv); -} - -HackingMission.prototype.updateNodeDomElement = function(nodeObj) { - if (nodeObj.el == null) { - console.log("ERR: Calling updateNodeDomElement on a Node without an element"); - return; - } - - var id = "hacking-mission-node-" + nodeObj.pos[0] + "-" + nodeObj.pos[1]; - var nodeDiv = document.getElementById(id), txtEl = document.getElementById(id + "-txt"); - - //Set node classes based on type - var txt; - switch (nodeObj.type) { - case NodeTypes.Core: - txt = "CPU Core
" + "HP: " + - Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); - break; - case NodeTypes.Firewall: - txt = "Firewall
" + "HP: " + - Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); - break; - case NodeTypes.Database: - txt = "Database
" + "HP: " + - Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); - break; - case NodeTypes.Spam: - txt = "Spam
" + "HP: " + - Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); - break; - case NodeTypes.Transfer: - txt = "Transfer
" + "HP: " + - Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); - break; - case NodeTypes.Shield: - default: - txt = "Shield
" + "HP: " + - Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); - break; - } - - txt += "
Atk: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.atk, 1) + - "
Def: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.def, 1); - if (nodeObj.action) { - txt += "
" + nodeObj.action; - } - txtEl.innerHTML = txt; -} - -//Gets a Node DOM element's corresponding Node object using its -//element id. Function accepts either the DOM element object or the ID as -//an argument -HackingMission.prototype.getNodeFromElement = function(el) { - var id; - if (Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["f" /* isString */])(el)) { - id = el; - } else { - id = el.id; - } - id = id.replace("hacking-mission-node-", ""); - var res = id.split('-'); - if (res.length != 2) { - console.log("ERROR Parsing Hacking Mission Node Id. Could not find coordinates"); - return null; - } - var x = res[0], y = res[1]; - if (isNaN(x) || isNaN(y) || x >= 8 || y >= 8 || x < 0 || y < 0) { - console.log("ERROR: Unexpected values for x and y: " + x + ", " + y); - return null; - } - return this.map[x][y]; -} - -function selectNode(hackMissionInst, el) { - var nodeObj = hackMissionInst.getNodeFromElement(el); - if (nodeObj == null) {console.log("Error getting Node object");} - if (!nodeObj.plyrCtrl) {return;} - - if (hackMissionInst.selectedNode instanceof Node) { - hackMissionInst.selectedNode.deselect(hackMissionInst.actionButtons); - hackMissionInst.selectedNode = null; - } - nodeObj.select(hackMissionInst.actionButtons); - hackMissionInst.selectedNode = nodeObj; -} - -//Configures a DOM element representing a player-owned node to -//be selectable and actionable -//Note: Does NOT change its css class. This is handled by Node.setControlledBy... -HackingMission.prototype.configurePlayerNodeElement = function(el) { - var nodeObj = this.getNodeFromElement(el); - if (nodeObj == null) {console.log("Error getting Node object");} - - //Add event listener - var self = this; - function selectNodeWrapper() { - selectNode(self, el); - } - el.addEventListener("click", selectNodeWrapper); - - if (el.firstChild) { - el.firstChild.addEventListener("click", selectNodeWrapper); - } -} - -//Configures a DOM element representing an enemy-node by removing -//any event listeners -HackingMission.prototype.configureEnemyNodeElement = function(el) { - //Deselect node if it was the selected node - var nodeObj = this.getNodeFromElement(el); - if (this.selectedNode == nodeObj) { - nodeObj.deselect(this.actionButtons); - } -} - -//Returns bool indicating whether a node is reachable by player -//by checking if any of the adjacent nodes are owned by the player -HackingMission.prototype.nodeReachable = function(node) { - var x = node.pos[0], y = node.pos[1]; - if (x > 0 && this.map[x-1][y].plyrCtrl) {return true;} - if (x < 7 && this.map[x+1][y].plyrCtrl) {return true;} - if (y > 0 && this.map[x][y-1].plyrCtrl) {return true;} - if (y < 7 && this.map[x][y+1].plyrCtrl) {return true;} - return false; -} - -HackingMission.prototype.nodeReachableByEnemy = function(node) { - if (node == null) {return false;} - var x = node.pos[0], y = node.pos[1]; - if (x > 0 && this.map[x-1][y].enmyCtrl) {return true;} - if (x < 7 && this.map[x+1][y].enmyCtrl) {return true;} - if (y > 0 && this.map[x][y-1].enmyCtrl) {return true;} - if (y < 7 && this.map[x][y+1].enmyCtrl) {return true;} - return false; -} - -HackingMission.prototype.start = function() { - this.started = true; - this.initJsPlumb(); - var startBtn = Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["b" /* clearEventListeners */])("hack-mission-start-btn"); - startBtn.classList.remove("a-link-button"); - startBtn.classList.add("a-link-button-inactive"); -} - -HackingMission.prototype.initJsPlumb = function() { - var instance = jsPlumb.getInstance({ - DragOptions:{cursor:"pointer", zIndex:2000}, - PaintStyle: { - gradient: { stops: [ - [ 0, "#FFFFFF" ], - [ 1, "#FFFFFF" ] - ] }, - stroke: "#FFFFFF", - strokeWidth: 8 - }, - }); - - this.jsplumbinstance = instance; - - //All player cores are sources - for (var i = 0; i < this.playerCores.length; ++i) { - instance.makeSource(this.playerCores[i].el, { - deleteEndpointsOnEmpty:true, - maxConnections:1, - anchor:"Continuous", - connector:"Flowchart" - }); - } - - //Everything else is a target - for (var i = 0; i < this.enemyCores.length; ++i) { - instance.makeTarget(this.enemyCores[i].el, { - maxConnections:-1, - anchor:"Continuous", - connector:"Flowchart" - }); - } - for (var i = 0; i < this.enemyDatabases.length; ++i) { - instance.makeTarget(this.enemyDatabases[i].el, { - maxConnections:-1, - anchor:"Continuous", - connector:["Flowchart"] - }); - } - for (var i = 0; i < this.enemyNodes.length; ++i) { - instance.makeTarget(this.enemyNodes[i].el, { - maxConnections:-1, - anchor:"Continuous", - connector:"Flowchart" - }); - } - for (var i = 0; i < this.miscNodes.length; ++i) { - instance.makeTarget(this.miscNodes[i].el, { - maxConnections:-1, - anchor:"Continuous", - connector:"Flowchart" - }); - } - - //Clicking a connection drops it - instance.bind("click", function(conn, originalEvent) { - var endpoints = conn.endpoints; - endpoints[0].detachFrom(endpoints[1]); - }); - - //Connection events - instance.bind("connection", (info)=>{ - var targetNode = this.getNodeFromElement(info.target); - - //Do not detach for enemy nodes - var thisNode = this.getNodeFromElement(info.source); - if (thisNode.enmyCtrl) {return;} - - //If the node is not reachable, drop the connection - if (!this.nodeReachable(targetNode)) { - info.sourceEndpoint.detachFrom(info.targetEndpoint); - return; - } - - var sourceNode = this.getNodeFromElement(info.source); - sourceNode.conn = info.connection; - var targetNode = this.getNodeFromElement(info.target); - ++targetNode.targetedCount; - }); - - //Detach Connection events - instance.bind("connectionDetached", (info, originalEvent)=>{ - var sourceNode = this.getNodeFromElement(info.source); - sourceNode.conn = null; - var targetNode = this.getNodeFromElement(info.target); - targetNode.untarget(); - }); - -} - -//Drops all connections where the specified node is the source -HackingMission.prototype.dropAllConnectionsFromNode = function(node) { - var allConns = this.jsplumbinstance.getAllConnections(); - for (var i = allConns.length-1; i >= 0; --i) { - if (allConns[i].source == node.el) { - allConns[i].endpoints[0].detachFrom(allConns[i].endpoints[1]); - } - } -} - -//Drops all connections where the specified node is the target -HackingMission.prototype.dropAllConnectionsToNode = function(node) { - var allConns = this.jsplumbinstance.getAllConnections(); - for (var i = allConns.length-1; i >= 0; --i) { - if (allConns[i].target == node.el) { - allConns[i].endpoints[0].detachFrom(allConns[i].endpoints[1]); - } - } - node.beingTargeted = false; -} - -var storedCycles = 0; -HackingMission.prototype.process = function(numCycles=1) { - if (!this.started) {return;} - storedCycles += numCycles; - if (storedCycles < 2) {return;} //Only process every 3 cycles minimum - - var res = false; - //Process actions of all player nodes - this.playerCores.forEach((node)=>{ - res |= this.processNode(node, storedCycles); - }); - - this.playerNodes.forEach((node)=>{ - if (node.type === NodeTypes.Transfer) { - res |= this.processNode(node, storedCycles); - } - }); - - //Process actions of all enemy nodes - this.enemyCores.forEach((node)=>{ - this.enemyAISelectAction(node); - res |= this.processNode(node, storedCycles); - }); - - this.enemyNodes.forEach((node)=>{ - if (node.type === NodeTypes.Transfer) { - this.enemyAISelectAction(node); - res |= this.processNode(node, storedCycles); - } - }); - - //The hp of enemy databases increases slowly - this.enemyDatabases.forEach((node)=>{ - node.maxhp += (0.1 * storedCycles); - node.hp += (0.1 * storedCycles); - }); - - if (res) { - this.calculateAttacks(); - this.calculateDefenses(); - } - - //Win if all enemy databases are conquered - if (this.enemyDatabases.length === 0) { - this.finishMission(true); - return; - } - - //Lose if all your cores are gone - if (this.playerCores.length === 0) { - this.finishMission(false); - return; - } - - //Defense/hp of misc nodes increases slowly over time - this.miscNodes.forEach((node)=>{ - node.def += (0.1 * storedCycles); - node.maxhp += (0.05 * storedCycles); - node.hp += (0.1 * storedCycles); - if (node.hp > node.maxhp) {node.hp = node.maxhp;} - this.updateNodeDomElement(node); - }); - - //Update timer and check if player lost - this.time -= (storedCycles * __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"]._idleSpeed); - if (this.time <= 0) { - this.finishMission(false); - return; - } - this.updateTimer(); - - storedCycles = 0; -} - -//Returns a bool representing whether defenses need to be re-calculated -HackingMission.prototype.processNode = function(nodeObj, numCycles=1) { - if (nodeObj.action == null) { - return; - } - - var targetNode = null, def, atk; - if (nodeObj.conn) { - var targetNode; - if (nodeObj.conn.target) { - targetNode = this.getNodeFromElement(nodeObj.conn.target); - } else { - targetNode = this.getNodeFromElement(nodeObj.conn.targetId); - } - - if (targetNode.plyrCtrl) { - def = this.playerDef; - atk = this.enemyAtk; - } else if (targetNode.enmyCtrl) { - def = this.enemyDef; - atk = this.playerAtk; - } else { //Misc Node - def = targetNode.def; - nodeObj.plyrCtrl ? atk = this.playerAtk : atk = this.enemyAtk; - } - } - - //Calculations are per second, so divide everything by 5 - var calcStats = false, plyr = nodeObj.plyrCtrl; - var enmyHacking = this.difficulty * __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].HackingMissionDifficultyToHacking; - switch(nodeObj.action) { - case NodeActions.Attack: - if (nodeObj.conn == null) {break;} - var dmg = this.calculateAttackDamage(atk, def, plyr ? __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill : enmyHacking); - targetNode.hp -= (dmg/5 * numCycles); - break; - case NodeActions.Scan: - if (nodeObj.conn == null) {break;} - var eff = this.calculateScanEffect(atk, def, plyr ? __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill : enmyHacking); - targetNode.def -= (eff/5 * numCycles); - calcStats = true; - break; - case NodeActions.Weaken: - if (nodeObj.conn == null) {break;} - var eff = this.calculateWeakenEffect(atk, def, plyr ? __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill : enmyHacking); - targetNode.atk -= (eff/5 * numCycles); - calcStats = true; - break; - case NodeActions.Fortify: - var eff = this.calculateFortifyEffect(__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill); - nodeObj.def += (eff/5 * numCycles); - calcStats = true; - break; - case NodeActions.Overflow: - var eff = this.calculateOverflowEffect(__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill); - if (nodeObj.def < eff) {break;} - nodeObj.def -= (eff/5 * numCycles); - nodeObj.atk += (eff/5 * numCycles); - calcStats = true; - break; - default: - console.log("ERR: Invalid Node Action: " + nodeObj.action); - break; - } - - //Stats can't go below 0 - if (nodeObj.atk < 0) {nodeObj.atk = 0;} - if (nodeObj.def < 0) {nodeObj.def = 0;} - if (targetNode && targetNode.atk < 0) {targetNode.atk = 0;} - if (targetNode && targetNode.def < 0) {targetNode.def = 0;} - - //Conquering a node - if (targetNode && targetNode.hp <= 0) { - var conqueredByPlayer = nodeObj.plyrCtrl; - targetNode.hp = targetNode.maxhp; - targetNode.action = null; - targetNode.conn = null; - if (this.selectedNode == targetNode) { - targetNode.deselect(this.actionButtons); - } - - //The conquered node has its stats reduced - targetNode.atk /= 2; - targetNode.def /= 3.5; - - //Flag for whether the target node was a misc node - var isMiscNode = !targetNode.plyrCtrl && !targetNode.enmyCtrl; - - //Remove all connections from Node - this.dropAllConnectionsToNode(targetNode); - this.dropAllConnectionsFromNode(targetNode); - - //Changes the css class and turn the node into a JsPlumb Source/Target - if (conqueredByPlayer) { - targetNode.setControlledByPlayer(); - this.jsplumbinstance.unmakeTarget(targetNode.el); - this.jsplumbinstance.makeSource(targetNode.el, { - deleteEndpointsOnEmpty:true, - maxConnections:1, - anchor:"Continuous", - connector:"Flowchart" - }); - } else { - targetNode.setControlledByEnemy(); - nodeObj.conn = null; //Clear connection - this.jsplumbinstance.unmakeSource(targetNode.el); - this.jsplumbinstance.makeTarget(targetNode.el, { - maxConnections:-1, - anchor:"Continuous", - connector:["Flowchart"] - }); - } - - calcStats = true; - - //Helper function to swap nodes between the respective enemyNodes/playerNodes arrays - function swapNodes(orig, dest, targetNode) { - for (var i = 0; i < orig.length; ++i) { - if (orig[i] == targetNode) { - var node = orig.splice(i, 1); - node = node[0]; - dest.push(node); - break; - } - } - } - - switch(targetNode.type) { - case NodeTypes.Core: - if (conqueredByPlayer) { - swapNodes(this.enemyCores, this.playerCores, targetNode); - this.configurePlayerNodeElement(targetNode.el); - } else { - swapNodes(this.playerCores, this.enemyCores, targetNode); - this.configureEnemyNodeElement(targetNode.el); - } - break; - case NodeTypes.Firewall: - if (conqueredByPlayer) { - swapNodes(this.enemyNodes, this.playerNodes, targetNode); - } else { - swapNodes(this.playerNodes, this.enemyNodes, targetNode); - } - break; - case NodeTypes.Database: - if (conqueredByPlayer) { - swapNodes(this.enemyDatabases, this.playerNodes, targetNode); - } else { - swapNodes(this.playerNodes, this.enemyDatabases, targetNode); - } - break; - case NodeTypes.Spam: - if (conqueredByPlayer) { - swapNodes(isMiscNode ? this.miscNodes : this.enemyNodes, this.playerNodes, targetNode); - //Conquering spam node increases time limit - this.time += __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].HackingMissionSpamTimeIncrease; - } else { - swapNodes(isMiscNode ? this.miscNodes : this.playerNodes, this.enemyNodes, targetNode); - } - - break; - case NodeTypes.Transfer: - //Conquering a Transfer node increases the attack of all cores by some percentages - if (conqueredByPlayer) { - swapNodes(isMiscNode ? this.miscNodes : this.enemyNodes, this.playerNodes, targetNode); - this.playerCores.forEach(function(node) { - node.atk *= __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].HackingMissionTransferAttackIncrease; - }); - this.configurePlayerNodeElement(targetNode.el); - } else { - swapNodes(isMiscNode ? this.miscNodes : this.playerNodes, this.enemyNodes, targetNode); - this.enemyCores.forEach(function(node) { - node.atk *= __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].HackingMissionTransferAttackIncrease; - }); - this.configureEnemyNodeElement(targetNode.el); - } - break; - case NodeTypes.Shield: - if (conqueredByPlayer) { - swapNodes(isMiscNode ? this.miscNodes : this.enemyNodes, this.playerNodes, targetNode); - } else { - swapNodes(isMiscNode ? this.miscNodes : this.playerNodes, this.enemyNodes, targetNode); - } - break; - } - - //If a misc node was conquered, the defense for all misc nodes increases by some fixed amount - if (isMiscNode) { //&& conqueredByPlayer) { - this.miscNodes.forEach((node)=>{ - if (node.targetedCount === 0) { - node.def *= __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].HackingMissionMiscDefenseIncrease; - } - }); - } - } - - //Update node DOMs - this.updateNodeDomElement(nodeObj); - if (targetNode) {this.updateNodeDomElement(targetNode);} - return calcStats; -} - -//Enemy "AI" for CPU Core and Transfer Nodes -HackingMission.prototype.enemyAISelectAction = function(nodeObj) { - if (nodeObj == null) {return;} - switch(nodeObj.type) { - case NodeTypes.Core: - //Select a single RANDOM target from miscNodes and player's Nodes - //If it is reachable, it will target it. If not, no target will - //be selected for now, and the next time process() gets called this will repeat - if (nodeObj.conn == null) { - if (this.miscNodes.length === 0) { - //Randomly pick a player node and attack it if its reachable - var rand = Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(0, this.playerNodes.length-1); - var node; - if (this.playerNodes.length === 0) { - node = null; - } else { - node = this.playerNodes[rand]; - } - if (this.nodeReachableByEnemy(node)) { - //Create connection - nodeObj.conn = this.jsplumbinstance.connect({ - source:nodeObj.el, - target:node.el - }); - ++node.targetedCount; - } else { - //Randomly pick a player core and attack it if its reachable - rand = Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(0, this.playerCores.length-1); - if (this.playerCores.length === 0) { - return; //No Misc Nodes, no player Nodes, no Player cores. Player lost - } else { - node = this.playerCores[rand]; - } - - if (this.nodeReachableByEnemy(node)) { - //Create connection - nodeObj.conn = this.jsplumbinstance.connect({ - source:nodeObj.el, - target:node.el - }); - ++node.targetedCount; - } - } - } else { - //Randomly pick a misc node and attack it if its reachable - var rand = Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(0, this.miscNodes.length-1); - var node = this.miscNodes[rand]; - if (this.nodeReachableByEnemy(node)) { - nodeObj.conn = this.jsplumbinstance.connect({ - source:nodeObj.el, - target:node.el, - }); - ++node.targetedCount; - } - } - - //If no connection was made, set the Core to Fortify - nodeObj.action = NodeActions.Fortify; - } else { - //If this node has a selected target - var targetNode; - if (nodeObj.conn.target) { - targetNode = this.getNodeFromElement(nodeObj.conn.target); - } else { - targetNode = this.getNodeFromElement(nodeObj.conn.targetId); - } - if (targetNode == null) { - console.log("Error getting Target node Object in enemyAISelectAction()"); - } - - if (targetNode.def > this.enemyAtk + 15) { - if (nodeObj.def < 50) { - nodeObj.action = NodeActions.Fortify; - } else { - nodeObj.action = NodeActions.Overflow; - } - } else if (Math.abs(targetNode.def - this.enemyAtk) <= 15) { - nodeObj.action = NodeActions.Scan; - } else { - nodeObj.action = NodeActions.Attack; - } - } - break; - case NodeTypes.Transfer: - //Switch between fortifying and overflowing as necessary - if (nodeObj.def < 125) { - nodeObj.action = NodeActions.Fortify; - } else { - nodeObj.action = NodeActions.Overflow; - } - break; - default: - break; - } -} - -var hackEffWeightSelf = 130; //Weight for Node actions on self -var hackEffWeightTarget = 25; //Weight for Node Actions against Target -var hackEffWeightAttack = 80; //Weight for Attack action - -//Returns damage per cycle based on stats -HackingMission.prototype.calculateAttackDamage = function(atk, def, hacking = 0) { - return Math.max(0.75 * (atk + (hacking / hackEffWeightAttack) - def), 1); -} - -HackingMission.prototype.calculateScanEffect = function(atk, def, hacking=0) { - return Math.max(0.7 * ((atk) + hacking / hackEffWeightTarget - (def * 0.95)), 2); -} - -HackingMission.prototype.calculateWeakenEffect = function(atk, def, hacking=0) { - return Math.max((atk) + hacking / hackEffWeightTarget - (def * 0.95), 2); -} - -HackingMission.prototype.calculateFortifyEffect = function(hacking=0) { - return hacking / hackEffWeightSelf; -} - -HackingMission.prototype.calculateOverflowEffect = function(hacking=0) { - return hacking / hackEffWeightSelf; -} - -//Updates timer display -HackingMission.prototype.updateTimer = function() { - var timer = document.getElementById("hacking-mission-timer"); - - //Convert time remaining to a string of the form mm:ss - var seconds = Math.round(this.time / 1000); - var minutes = Math.trunc(seconds / 60); - seconds %= 60; - var str = ("0" + minutes).slice(-2) + ":" + ("0" + seconds).slice(-2); - timer.innerText = "Time left: " + str; -} - -//The 'win' argument is a bool for whether or not the player won -HackingMission.prototype.finishMission = function(win) { - inMission = false; - currMission = null; - - if (win) { - var favorMult = 1 + (this.faction.favor / 100); - console.log("Hacking mission base reward: " + this.reward); - console.log("favorMult: " + favorMult); - console.log("rep mult: " + __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].faction_rep_mult); - var gain = this.reward * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].faction_rep_mult * favorMult; - Object(__WEBPACK_IMPORTED_MODULE_4__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Mission won! You earned " + - Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(gain, 3) + " reputation with " + this.faction.name); - __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gainIntelligenceExp(this.difficulty * __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].IntelligenceHackingMissionBaseExpGain); - this.faction.playerReputation += gain; - } else { - Object(__WEBPACK_IMPORTED_MODULE_4__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Mission lost/forfeited! You did not gain any faction reputation."); - } - - //Clear mission container - var container = document.getElementById("mission-container"); - while(container.firstChild) { - container.removeChild(container.firstChild); - } - - //Return to Faction page - document.getElementById("mainmenu-container").style.visibility = "visible"; - document.getElementById("character-overview-wrapper").style.visibility = "visible"; - __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].loadFactionContent(); - Object(__WEBPACK_IMPORTED_MODULE_2__Faction_js__["c" /* displayFactionContent */])(this.faction.name); -} - - - -/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(9))) /***/ }), -/* 33 */ +/* 34 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -39342,7 +39482,7 @@ function setGangMemberTaskDescription(memberObj, taskName) { /* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(9))) /***/ }), -/* 34 */ +/* 35 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -39519,7 +39659,7 @@ function applySourceFile(srcFile) { /***/ }), -/* 35 */ +/* 36 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -39539,9 +39679,9 @@ function applySourceFile(srcFile) { /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__Player_js__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__Server_js__ = __webpack_require__(6); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__SpecialServerIps_js__ = __webpack_require__(12); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__StockMarket_js__ = __webpack_require__(28); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__StockMarket_js__ = __webpack_require__(29); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__Terminal_js__ = __webpack_require__(23); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__utils_decimal_js__ = __webpack_require__(27); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__utils_decimal_js__ = __webpack_require__(28); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__utils_decimal_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_16__utils_decimal_js__); @@ -39775,7 +39915,7 @@ function prestigeSourceFile() { /* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(9))) /***/ }), -/* 36 */ +/* 37 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -39784,8 +39924,8 @@ function prestigeSourceFile() { /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__BitNode_js__ = __webpack_require__(7); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__engine_js__ = __webpack_require__(5); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Prestige_js__ = __webpack_require__(35); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__SourceFile_js__ = __webpack_require__(34); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Prestige_js__ = __webpack_require__(36); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__SourceFile_js__ = __webpack_require__(35); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Terminal_js__ = __webpack_require__(23); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__ = __webpack_require__(1); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__ = __webpack_require__(2); @@ -40114,30 +40254,31 @@ function createBitNodeYesNoEventListeners(newBitNode, destroyedBitNode) { /* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(9))) /***/ }), -/* 37 */ +/* 38 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return makeRuntimeRejectMsg; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return netscriptDelay; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return runScriptFromScript; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return scriptCalculateHackingChance; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return scriptCalculateHackingTime; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return scriptCalculateExpGain; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return scriptCalculatePercentMoneyHacked; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return scriptCalculateGrowTime; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return scriptCalculateWeakenTime; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return makeRuntimeRejectMsg; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return netscriptDelay; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return runScriptFromScript; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return scriptCalculateHackingChance; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return scriptCalculateHackingTime; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return scriptCalculateExpGain; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return scriptCalculatePercentMoneyHacked; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return scriptCalculateGrowTime; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return scriptCalculateWeakenTime; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return evaluate; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return isScriptErrorMessage; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return killNetscriptDelay; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__BitNode_js__ = __webpack_require__(7); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Constants_js__ = __webpack_require__(3); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__NetscriptEnvironment_js__ = __webpack_require__(30); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__NetscriptEnvironment_js__ = __webpack_require__(31); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__ = __webpack_require__(11); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Server_js__ = __webpack_require__(6); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Settings_js__ = __webpack_require__(14); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Script_js__ = __webpack_require__(16); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_acorn_js__ = __webpack_require__(46); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_acorn_js__ = __webpack_require__(47); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_acorn_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_8__utils_acorn_js__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__utils_HelperFunctions_js__ = __webpack_require__(2); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__utils_IPAddress_js__ = __webpack_require__(17); @@ -40156,72 +40297,79 @@ function createBitNodeYesNoEventListeners(newBitNode, destroyedBitNode) { +var Promise = __webpack_require__(72); + +Promise.config({ + warnings: false, + longStackTraces: false, + cancellation: true, + monitoring: false +}); /* Evaluator - * Evaluates/Interprets the Abstract Syntax Tree generated by Acorns parser + * Evaluates/Interprets the Abstract Syntax Tree generated by Acorns parser * * Returns a promise */ function evaluate(exp, workerScript) { - return new Promise(function(resolve, reject) { - var env = workerScript.env; - if (env.stopFlag) {return reject(workerScript);} - if (exp == null) { - return reject(makeRuntimeRejectMsg(workerScript, "Error: NULL expression")); - } - setTimeout(function() { - if (env.stopFlag) {return reject(workerScript);} + /* return new Promise(function(resolve, reject) {*/ + return Promise.delay(__WEBPACK_IMPORTED_MODULE_6__Settings_js__["a" /* Settings */].CodeInstructionRunTime).then(function() { + var env = workerScript.env; + if (env.stopFlag) {return Promise.reject(workerScript);} + if (exp == null) { + return Promise.reject(makeRuntimeRejectMsg(workerScript, "Error: NULL expression")); + } + if (env.stopFlag) {return Promise.reject(workerScript);} switch (exp.type) { case "BlockStatement": case "Program": var evaluateProgPromise = evaluateProg(exp, workerScript, 0); //TODO: make every block/program use individual enviroment - evaluateProgPromise.then(function(w) { - resolve(workerScript); - }, function(e) { + return evaluateProgPromise.then(function(w) { + return Promise.resolve(workerScript); + }).catch(function(e) { if (e.constructor === Array && e.length === 2 && e[0] === "RETURNSTATEMENT") { - reject(e); + return Promise.reject(e); } else if (Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["f" /* isString */])(e)) { workerScript.errorMessage = e; - reject(workerScript); + return Promise.reject(workerScript); } else if (e instanceof __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* WorkerScript */]) { - reject(e); + return Promise.reject(e); } else { - reject(workerScript); + return Promise.reject(workerScript); } }); break; case "Literal": - resolve(exp.value); + return Promise.resolve(exp.value); break; case "Identifier": if (!(exp.name in env.vars)){ - reject(makeRuntimeRejectMsg(workerScript, "variable " + exp.name + " not defined")); + return Promise.reject(makeRuntimeRejectMsg(workerScript, "variable " + exp.name + " not defined")); } - resolve(env.get(exp.name)) + return Promise.resolve(env.get(exp.name)) break; case "ExpressionStatement": - var e = evaluate(exp.expression, workerScript); - e.then(function(res) { - resolve(res); - }, function(e) { - reject(e); - }); + return evaluate(exp.expression, workerScript); break; case "ArrayExpression": var argPromises = exp.elements.map(function(arg) { return evaluate(arg, workerScript); }); - Promise.all(argPromises).then(function(array) { - resolve(array) + return Promise.all(argPromises).then(function(array) { + return Promise.resolve(array) }).catch(function(e) { - reject(e); + return Promise.reject(e); }); break; case "CallExpression": - evaluate(exp.callee, workerScript).then(function(func) { + return evaluate(exp.callee, workerScript).then(function(func) { + /* var argPromises = exp.arguments.map(function(arg) { return evaluate(arg, workerScript); }); - Promise.all(argPromises).then(function(args) { + Promise.all(argPromises).then(function(args) {*/ + return Promise.map(exp.arguments, function(arg) { + return evaluate(arg, workerScript); + }).then(function(args) { if (func instanceof __WEBPACK_IMPORTED_MODULE_8__utils_acorn_js__["Node"]) { //Player-defined function //Create new Environment for the function //Should be automatically garbage collected... @@ -40244,321 +40392,311 @@ function evaluate(exp, workerScript) { funcWorkerScript.env = funcEnv; workerScript.fnWorker = funcWorkerScript; - evaluate(func.body, funcWorkerScript).then(function(res) { + return evaluate(func.body, funcWorkerScript).then(function(res) { //If the function finished successfuly, that means there //was no return statement since a return statement rejects. So resolve to null - resolve(null); workerScript.fnWorker = null; + return Promise.resolve(null); }).catch(function(e) { if (e.constructor === Array && e.length === 2 && e[0] === "RETURNSTATEMENT") { //Return statement from function - resolve(e[1]); + return Promise.resolve(e[1]); workerScript.fnWorker = null; } else if (Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["f" /* isString */])(e)) { - reject(makeRuntimeRejectMsg(workerScript, e)); + return Promise.reject(makeRuntimeRejectMsg(workerScript, e)); } else if (e instanceof __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* WorkerScript */]) { //Parse out the err message from the WorkerScript and re-reject var errorMsg = e.errorMessage; var errorTextArray = errorMsg.split("|"); if (errorTextArray.length === 4) { errorMsg = errorTextArray[3]; - reject(makeRuntimeRejectMsg(workerScript, errorMsg)); + return Promise.reject(makeRuntimeRejectMsg(workerScript, errorMsg)); } else { if (env.stopFlag) { - reject(workerScript); + return Promise.reject(workerScript); } else { - reject(makeRuntimeRejectMsg(workerScript, "Error in one of your functions. Could not identify which function")); + return Promise.reject(makeRuntimeRejectMsg(workerScript, "Error in one of your functions. Could not identify which function")); } } } else if (e instanceof Error) { - reject(makeRuntimeRejectMsg(workerScript, e.toString())); + return Promise.reject(makeRuntimeRejectMsg(workerScript, e.toString())); } }); } else if (exp.callee.type == "MemberExpression"){ - evaluate(exp.callee.object, workerScript).then(function(object) { + return evaluate(exp.callee.object, workerScript).then(function(object) { try { var res = func.apply(object,args); - resolve(res); + return Promise.resolve(res); } catch (e) { - reject(makeRuntimeRejectMsg(workerScript, e)); + return Promise.reject(makeRuntimeRejectMsg(workerScript, e)); } }).catch(function(e) { - reject(e); + return Promise.reject(e); }); } else { try { var out = func.apply(null,args); if (out instanceof Promise){ - out.then(function(res) { - resolve(res) + return out.then(function(res) { + return Promise.resolve(res) }).catch(function(e) { - reject(e); + return Promise.reject(e); }); } else { - resolve(out); + return Promise.resolve(out); } } catch (e) { if (isScriptErrorMessage(e)) { - reject(e); + return Promise.reject(e); } else { - reject(makeRuntimeRejectMsg(workerScript, e)); + return Promise.reject(makeRuntimeRejectMsg(workerScript, e)); } } } }).catch(function(e) { - reject(e); + return Promise.reject(e); }); }).catch(function(e) { - reject(e); + return Promise.reject(e); }); break; case "MemberExpression": - var pObject = evaluate(exp.object, workerScript); - pObject.then(function(object) { + return evaluate(exp.object, workerScript).then(function(object) { if (exp.computed){ - var p = evaluate(exp.property, workerScript); - p.then(function(index) { + return evaluate(exp.property, workerScript).then(function(index) { if (index >= object.length) { - return reject(makeRuntimeRejectMsg(workerScript, "Invalid index for arrays")); + return Promise.reject(makeRuntimeRejectMsg(workerScript, "Invalid index for arrays")); } - resolve(object[index]); + return Promise.resolve(object[index]); }).catch(function(e) { - reject(makeRuntimeRejectMsg(workerScript, "Invalid MemberExpression")); + return Promise.reject(makeRuntimeRejectMsg(workerScript, "Invalid MemberExpression")); }); } else { try { - resolve(object[exp.property.name]) + return Promise.resolve(object[exp.property.name]) } catch (e) { - return reject(makeRuntimeRejectMsg(workerScript, "Failed to get property: " + e.toString())); + return Promise.reject(makeRuntimeRejectMsg(workerScript, "Failed to get property: " + e.toString())); } } }).catch(function(e) { - reject(e); + return Promise.reject(e); }); break; case "LogicalExpression": case "BinaryExpression": - var p = evalBinary(exp, workerScript, resolve, reject); - p.then(function(res) { - resolve(res); + return evalBinary(exp, workerScript).then(function(res) { + return Promise.resolve(res); }).catch(function(e) { - reject(e); + return Promise.reject(e); }); break; case "UnaryExpression": - var p = evalUnary(exp, workerScript, resolve, reject); - p.then(function(res) { - resolve(res); + return evalUnary(exp, workerScript).then(function(res) { + return Promise.resolve(res); }).catch(function(e) { - reject(e); + return Promise.reject(e); }); break; case "AssignmentExpression": - var p = evalAssignment(exp, workerScript); - p.then(function(res) { - resolve(res); + return evalAssignment(exp, workerScript).then(function(res) { + return Promise.resolve(res); }).catch(function(e) { - reject(e); + return Promise.reject(e); }); break; case "UpdateExpression": if (exp.argument.type==="Identifier"){ if (exp.argument.name in env.vars){ + if (exp.operator === "++" || exp.operator === "--") { + switch (exp.operator) { + case "++": + env.set(exp.argument.name,env.get(exp.argument.name)+1); + break; + case "--": + env.set(exp.argument.name,env.get(exp.argument.name)-1); + break; + default: break; + } + return Promise.resolve(env.get(exp.argument.name)); + } + //Not sure what prefix UpdateExpressions there would be besides ++/-- if (exp.prefix){ - resolve(env.get(exp.argument.name)) + return Promise.resolve(env.get(exp.argument.name)) } switch (exp.operator){ - case "++": - env.set(exp.argument.name,env.get(exp.argument.name)+1); - break; - case "--": - env.set(exp.argument.name,env.get(exp.argument.name)-1); - break; default: - reject(makeRuntimeRejectMsg(workerScript, "Unrecognized token: " + exp.type + ". You are trying to use code that is currently unsupported")); + return Promise.reject(makeRuntimeRejectMsg(workerScript, "Unrecognized token: " + exp.type + ". You are trying to use code that is currently unsupported")); } - if (env.prefix){ - return; - } - resolve(env.get(exp.argument.name)) + return Promise.resolve(env.get(exp.argument.name)) } else { - reject(makeRuntimeRejectMsg(workerScript, "variable " + exp.argument.name + " not defined")); + return Promise.reject(makeRuntimeRejectMsg(workerScript, "variable " + exp.argument.name + " not defined")); } } else { - reject(makeRuntimeRejectMsg(workerScript, "argument must be an identifier")); + return Promise.reject(makeRuntimeRejectMsg(workerScript, "argument must be an identifier")); } break; case "EmptyStatement": - resolve(false); + return Promise.resolve(false); break; case "ReturnStatement": - console.log("Evaluating Return Statement"); - //var lineNum = getErrorLineNumber(exp, workerScript); - //reject(makeRuntimeRejectMsg(workerScript, "Return statements are not yet implemented in Netscript (line " + (lineNum+1) + ")")); - evaluate(exp.argument, workerScript).then(function(res) { - reject(["RETURNSTATEMENT", res]); + return evaluate(exp.argument, workerScript).then(function(res) { + return Promise.reject(["RETURNSTATEMENT", res]); }).catch(function(e) { - reject(e); + return Promise.reject(e); }); break; case "BreakStatement": - reject("BREAKSTATEMENT"); + return Promise.reject("BREAKSTATEMENT"); break; case "ContinueStatement": - reject("CONTINUESTATEMENT"); + return Promise.reject("CONTINUESTATEMENT"); break; case "IfStatement": - evaluateIf(exp, workerScript).then(function(forLoopRes) { - resolve(forLoopRes); + return evaluateIf(exp, workerScript).then(function(forLoopRes) { + return Promise.resolve(forLoopRes); }).catch(function(e) { - reject(e); + return Promise.reject(e); }); break; case "SwitchStatement": var lineNum = getErrorLineNumber(exp, workerScript); - reject(makeRuntimeRejectMsg(workerScript, "Switch statements are not yet implemented in Netscript (line " + (lineNum+1) + ")")); - break;e + return Promise.reject(makeRuntimeRejectMsg(workerScript, "Switch statements are not yet implemented in Netscript (line " + (lineNum+1) + ")")); + break; case "WhileStatement": - evaluateWhile(exp, workerScript).then(function(forLoopRes) { - resolve(forLoopRes); + return evaluateWhile(exp, workerScript).then(function(forLoopRes) { + return Promise.resolve(forLoopRes); }).catch(function(e) { if (e == "BREAKSTATEMENT" || (e instanceof __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* WorkerScript */] && e.errorMessage == "BREAKSTATEMENT")) { - return resolve("whileLoopBroken"); + return Promise.resolve("whileLoopBroken"); } else { - reject(e); + return Promise.reject(e); } }); break; case "ForStatement": - evaluate(exp.init, workerScript).then(function(expInit) { + return evaluate(exp.init, workerScript).then(function(expInit) { return evaluateFor(exp, workerScript); }).then(function(forLoopRes) { - resolve("forLoopDone"); + return Promise.resolve("forLoopDone"); }).catch(function(e) { if (e == "BREAKSTATEMENT" || (e instanceof __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* WorkerScript */] && e.errorMessage == "BREAKSTATEMENT")) { - return resolve("forLoopBroken"); + return Promise.resolve("forLoopBroken"); } else { - reject(e); + return Promise.reject(e); } }); break; case "FunctionDeclaration": if (exp.id && exp.id.name) { env.set(exp.id.name, exp); - resolve(true); + return Promise.resolve(true); } else { var lineNum = getErrorLineNumber(exp, workerScript); - reject(makeRuntimeRejectMsg(workerScript, "Invalid function declaration at line " + lineNum+1)); + return Promise.reject(makeRuntimeRejectMsg(workerScript, "Invalid function declaration at line " + lineNum+1)); } break; default: var lineNum = getErrorLineNumber(exp, workerScript); - reject(makeRuntimeRejectMsg(workerScript, "Unrecognized token: " + exp.type + " (line " + (lineNum+1) + "). This is currently unsupported in Netscript")); + return Promise.reject(makeRuntimeRejectMsg(workerScript, "Unrecognized token: " + exp.type + " (line " + (lineNum+1) + "). This is currently unsupported in Netscript")); break; } //End switch - }, __WEBPACK_IMPORTED_MODULE_6__Settings_js__["a" /* Settings */].CodeInstructionRunTime); //End setTimeout, the Netscript operation run time - + }).catch(function(e) { + return Promise.reject(e); }); // End Promise } function evalBinary(exp, workerScript){ - return new Promise(function(resolve, reject) { - var expLeftPromise = evaluate(exp.left, workerScript); - expLeftPromise.then(function(expLeft) { - if (expLeft == true && exp.operator === "||") { - return resolve(true); + return evaluate(exp.left, workerScript).then(function(expLeft) { + //Short circuiting + if (expLeft == true && exp.operator === "||") { + return Promise.resolve(true); + } + if (expLeft == false && exp.operator === "&&") { + return Promise.resolve(false); + } + return evaluate(exp.right, workerScript).then(function(expRight) { + switch (exp.operator){ + case "===": + case "==": + return Promise.resolve(expLeft===expRight); + break; + case "!==": + case "!=": + return Promise.resolve(expLeft!==expRight); + break; + case "<": + return Promise.resolve(expLeft": + return Promise.resolve(expLeft>expRight); + break; + case ">=": + return Promise.resolve(expLeft>=expRight); + break; + case "+": + return Promise.resolve(expLeft+expRight); + break; + case "-": + return Promise.resolve(expLeft-expRight); + break; + case "*": + return Promise.resolve(expLeft*expRight); + break; + case "/": + if (expRight === 0) { + return Promise.reject(makeRuntimeRejectMsg(workerScript, "ERROR: Divide by zero")); + } else { + return Promise.resolve(expLeft/expRight); + } + break; + case "%": + return Promise.resolve(expLeft%expRight); + break; + case "in": + return Promise.resolve(expLeft in expRight); + break; + case "instanceof": + return Promise.resolve(expLeft instanceof expRight); + break; + case "||": + return Promise.resolve(expLeft || expRight); + break; + case "&&": + return Promise.resolve(expLeft && expRight); + break; + default: + return Promise.reject(makeRuntimeRejectMsg(workerScript, "Unsupported operator: " + exp.operator)); } - if (expLeft == false && exp.operator === "&&") { - return resolve(false); - } - var expRightPromise = evaluate(exp.right, workerScript); - expRightPromise.then(function(expRight) { - switch (exp.operator){ - case "===": - case "==": - resolve(expLeft===expRight); - break; - case "!==": - case "!=": - resolve(expLeft!==expRight); - break; - case "<": - resolve(expLeft": - resolve(expLeft>expRight); - break; - case ">=": - resolve(expLeft>=expRight); - break; - case "+": - resolve(expLeft+expRight); - break; - case "-": - resolve(expLeft-expRight); - break; - case "*": - resolve(expLeft*expRight); - break; - case "/": - if (expRight === 0) { - reject(makeRuntimeRejectMsg(workerScript, "ERROR: Divide by zero")); - } else { - resolve(expLeft/expRight); - } - break; - case "%": - resolve(expLeft%expRight); - break; - case "in": - resolve(expLeft in expRight); - break; - case "instanceof": - resolve(expLeft instanceof expRight); - break; - case "||": - resolve(expLeft || expRight); - break; - case "&&": - resolve(expLeft && expRight); - break; - default: - reject(makeRuntimeRejectMsg(workerScript, "Unsupported operator: " + exp.operator)); - } - }, function(e) { - reject(e); - }); }, function(e) { - reject(e); + return Promise.reject(e); }); + }, function(e) { + return Promise.reject(e); }); } function evalUnary(exp, workerScript){ var env = workerScript.env; - return new Promise(function(resolve, reject) { - if (env.stopFlag) {return reject(workerScript);} - var p = evaluate(exp.argument, workerScript); - p.then(function(res) { - if (exp.operator == "!") { - resolve(!res); - } else if (exp.operator == "-") { - if (isNaN(res)) { - resolve(res); - } else { - resolve(-1 * res); - } + if (env.stopFlag) {return Promise.reject(workerScript);} + return evaluate(exp.argument, workerScript).then(function(res) { + if (exp.operator == "!") { + return Promise.resolve(!res); + } else if (exp.operator == "-") { + if (isNaN(res)) { + return Promise.resolve(res); } else { - reject(makeRuntimeRejectMsg(workerScript, "Unimplemented unary operator: " + exp.operator)); + return Promise.resolve(-1 * res); } - }).catch(function(e) { - reject(e); - }); + } else { + return Promise.reject(makeRuntimeRejectMsg(workerScript, "Unimplemented unary operator: " + exp.operator)); + } + }).catch(function(e) { + return Promise.reject(e); }); } @@ -40566,312 +40704,227 @@ function evalUnary(exp, workerScript){ //The return value is an array of the form: // [0th index (leftmost), array name, 1st index, 2nd index, ...] function getArrayElement(exp, workerScript) { - return new Promise(function(resolve, reject) { - var indices = []; - var iPromise = evaluate(exp.property, workerScript); - iPromise.then(function(idx) { - if (isNaN(idx)) { - return reject(makeRuntimeRejectMsg(workerScript, "Invalid access to array. Index is not a number: " + idx)); + var indices = []; + return evaluate(exp.property, workerScript).then(function(idx) { + if (isNaN(idx)) { + return Promise.reject(makeRuntimeRejectMsg(workerScript, "Invalid access to array. Index is not a number: " + idx)); + } else { + if (exp.object.name === undefined && exp.object.object) { + return getArrayElement(exp.object, workerScript).then(function(res) { + res.push(idx); + indices = res; + return Promise.resolve(indices); + }).catch(function(e) { + return Promise.reject(e); + }); } else { - if (exp.object.name === undefined && exp.object.object) { - var recursePromise = getArrayElement(exp.object, workerScript); - recursePromise.then(function(res) { - res.push(idx); - indices = res; - return resolve(indices); - }).catch(function(e) { - return reject(e); - }); - } else { - indices.push(idx); - indices.push(exp.object.name); - return resolve(indices); - } + indices.push(idx); + indices.push(exp.object.name); + return Promise.resolve(indices); } - }).catch(function(e) { - console.log(e); - console.log("Error getting index in getArrayElement: " + e.toString()); - return reject(e); - }); + } + }).catch(function(e) { + console.log(e); + console.log("Error getting index in getArrayElement: " + e.toString()); + return Promise.reject(e); }); } function evalAssignment(exp, workerScript) { var env = workerScript.env; - return new Promise(function(resolve, reject) { - if (env.stopFlag) {return reject(workerScript);} + if (env.stopFlag) {return Promise.reject(workerScript);} - if (exp.left.type != "Identifier" && exp.left.type != "MemberExpression") { - return reject(makeRuntimeRejectMsg(workerScript, "Cannot assign to " + JSON.stringify(exp.left))); - } + if (exp.left.type != "Identifier" && exp.left.type != "MemberExpression") { + return Promise.reject(makeRuntimeRejectMsg(workerScript, "Cannot assign to " + JSON.stringify(exp.left))); + } - if (exp.operator !== "=" && !(exp.left.name in env.vars)){ - return reject(makeRuntimeRejectMsg(workerScript, "variable " + exp.left.name + " not defined")); - } + if (exp.operator !== "=" && !(exp.left.name in env.vars)){ + return Promise.reject(makeRuntimeRejectMsg(workerScript, "variable " + exp.left.name + " not defined")); + } - var expRightPromise = evaluate(exp.right, workerScript); - expRightPromise.then(function(expRight) { - if (exp.left.type == "MemberExpression") { - //Assign to array element - //Array object designed by exp.left.object.name - //Index designated by exp.left.property - var getArrayElementPromise = getArrayElement(exp.left, workerScript); - getArrayElementPromise.then(function(res) { - if (!(res instanceof Array) || res.length < 2) { - return reject(makeRuntimeRejectMsg(workerScript, "Error evaluating array assignment. This is (probably) a bug please report to game dev")); - } - - //The array name is the second value - var arrName = res.splice(1, 1); - arrName = arrName[0]; - - env.setArrayElement(arrName, res, expRight); - return resolve(false); - }).catch(function(e) { - return reject(e); - }); - /* - var name = exp.left.object.name; - if (!(name in env.vars)){ - reject(makeRuntimeRejectMsg(workerScript, "variable " + name + " not defined")); + return evaluate(exp.right, workerScript).then(function(expRight) { + if (exp.left.type == "MemberExpression") { + //Assign to array element + //Array object designed by exp.left.object.name + //Index designated by exp.left.property + return getArrayElement(exp.left, workerScript).then(function(res) { + if (!(res instanceof Array) || res.length < 2) { + return Promise.reject(makeRuntimeRejectMsg(workerScript, "Error evaluating array assignment. This is (probably) a bug please report to game dev")); } - var arr = env.get(name); - if (arr.constructor === Array || arr instanceof Array) { - var iPromise = evaluate(exp.left.property, workerScript); - iPromise.then(function(idx) { - if (isNaN(idx)) { - return reject(makeRuntimeRejectMsg(workerScript, "Invalid access to array. Index is not a number: " + idx)); - } else if (idx >= arr.length || idx < 0) { - return reject(makeRuntimeRejectMsg(workerScript, "Out of bounds: Invalid index in [] operator")); - } else { - env.setArrayElement(name, idx, expRight); - } - }).catch(function(e) { - return reject(e); - }); - } else { - return reject(makeRuntimeRejectMsg(workerScript, "Trying to access a non-array variable using the [] operator")); - }*/ - } else { - //Other assignments - try { - switch (exp.operator) { - case "=": - env.set(exp.left.name,expRight); - break; - case "+=": - env.set(exp.left.name,env.get(exp.left.name) + expRight); - break; - case "-=": - env.set(exp.left.name,env.get(exp.left.name) - expRight); - break; - case "*=": - env.set(exp.left.name,env.get(exp.left.name) * expRight); - break; - case "/=": - env.set(exp.left.name,env.get(exp.left.name) / expRight); - break; - case "%=": - env.set(exp.left.name,env.get(exp.left.name) % expRight); - break; - default: - reject(makeRuntimeRejectMsg(workerScript, "Bitwise assignment is not implemented")); - } - resolve(false); - } catch (e) { - return reject(makeRuntimeRejectMsg(workerScript, "Failed to set environment variable: " + e.toString())); + + //The array name is the second value + var arrName = res.splice(1, 1); + arrName = arrName[0]; + + env.setArrayElement(arrName, res, expRight); + return Promise.resolve(false); + }).catch(function(e) { + return Promise.reject(e); + }); + } else { + //Other assignments + try { + switch (exp.operator) { + case "=": + env.set(exp.left.name,expRight); + break; + case "+=": + env.set(exp.left.name,env.get(exp.left.name) + expRight); + break; + case "-=": + env.set(exp.left.name,env.get(exp.left.name) - expRight); + break; + case "*=": + env.set(exp.left.name,env.get(exp.left.name) * expRight); + break; + case "/=": + env.set(exp.left.name,env.get(exp.left.name) / expRight); + break; + case "%=": + env.set(exp.left.name,env.get(exp.left.name) % expRight); + break; + default: + return Promise.reject(makeRuntimeRejectMsg(workerScript, "Bitwise assignment is not implemented")); } + return Promise.resolve(false); + } catch (e) { + return Promise.reject(makeRuntimeRejectMsg(workerScript, "Failed to set environment variable: " + e.toString())); } - //resolve(false); //Return false so this doesnt cause conditionals to evaluate - }, function(e) { - reject(e); - }); + } + }, function(e) { + return Promise.reject(e); }); } function evaluateIf(exp, workerScript, i) { var env = workerScript.env; - return new Promise(function(resolve, reject) { - evaluate(exp.test, workerScript).then(function(condRes) { - if (condRes) { - evaluate(exp.consequent, workerScript).then(function(res) { - resolve(true); - }, function(e) { - reject(e); - }); - } else if (exp.alternate) { - evaluate(exp.alternate, workerScript).then(function(res) { - resolve(true); - }, function(e) { - reject(e); - }); - } else { - resolve("endIf") - } - }, function(e) { - reject(e); - }); + return evaluate(exp.test, workerScript).then(function(condRes) { + if (condRes) { + return evaluate(exp.consequent, workerScript).then(function(res) { + return Promise.resolve(true); + }, function(e) { + return Promise.reject(e); + }); + } else if (exp.alternate) { + return evaluate(exp.alternate, workerScript).then(function(res) { + return Promise.resolve(true); + }, function(e) { + return Promise.reject(e); + }); + } else { + return Promise.resolve("endIf"); + } + }, function(e) { + return Promise.reject(e); }); } //Evaluate the looping part of a for loop (Initialization block is NOT done in here) function evaluateFor(exp, workerScript) { - var env = workerScript.env; - return new Promise(function(resolve, reject) { - if (env.stopFlag) {reject(workerScript); return;} - - var pCond = evaluate(exp.test, workerScript); - pCond.then(function(resCond) { - if (resCond) { - //Run the for loop code - var pBody = evaluate(exp.body, workerScript); - //After the code executes make a recursive call - pBody.then(function(resCode) { - var pUpdate = evaluate(exp.update, workerScript); - pUpdate.then(function(resPostloop) { - var recursiveCall = evaluateFor(exp, workerScript); - recursiveCall.then(function(foo) { - resolve("endForLoop"); - }, function(e) { - reject(e); - }); - }, function(e) { - reject(e); - }); - }, function(e) { - if (e == "CONTINUESTATEMENT" || - (e instanceof __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* WorkerScript */] && e.errorMessage == "CONTINUESTATEMENT")) { + var env = workerScript.env; + if (env.stopFlag) {return Promise.reject(workerScript);} + return evaluate(exp.test, workerScript).then(function(resCond) { + if (resCond) { + //Execute code (body), update, and then recurse + return evaluate(exp.body, workerScript).then(function(resCode) { + return evaluate(exp.update, workerScript); + }).catch(function(e) { + if (e == "CONTINUESTATEMENT" || + (e instanceof __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* WorkerScript */] && e.errorMessage == "CONTINUESTATEMENT")) { //Continue statement, recurse to next iteration - var pUpdate = evaluate(exp.update, workerScript); - pUpdate.then(function(resPostloop) { - var recursiveCall = evaluateFor(exp, workerScript); - recursiveCall.then(function(foo) { - resolve("endForLoop"); - }, function(e) { - reject(e); - }); - }, function(e) { - reject(e); - }); - } else { - reject(e); - } - }); - } else { - resolve("endForLoop"); //Doesn't need to resolve to any particular value - } - }, function(e) { - reject(e); - }); - }); + return evaluate(exp.update, workerScript).then(function(resPostloop) { + return evaluateFor(exp, workerScript); + }).then(function(foo) { + return Promise.resolve("endForLoop"); + }).catch(function(e) { + return Promise.reject(e); + }); + } else { + return Promise.reject(e); + } + }).then(function(resPostloop) { + return evaluateFor(exp, workerScript); + }).then(function(foo) { + return Promise.resolve("endForLoop"); + }).catch(function(e) { + return Promise.reject(e); + }); + } else { + return Promise.resolve("endForLoop"); //Doesn't need to resolve to any particular value + } + }, function(e) { + return Promise.reject(e); + }); } function evaluateWhile(exp, workerScript) { - var env = workerScript.env; - - return new Promise(function(resolve, reject) { - if (env.stopFlag) {reject(workerScript); return;} - - var pCond = new Promise(function(resolve, reject) { - setTimeout(function() { - var evaluatePromise = evaluate(exp.test, workerScript); - evaluatePromise.then(function(resCond) { - resolve(resCond); - }, function(e) { - reject(e); - }); - }, __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].CodeInstructionRunTime); - }); - - pCond.then(function(resCond) { - if (resCond) { - //Run the while loop code - var pCode = new Promise(function(resolve, reject) { - setTimeout(function() { - var evaluatePromise = evaluate(exp.body, workerScript); - evaluatePromise.then(function(resCode) { - resolve(resCode); - }, function(e) { - if (e == "CONTINUESTATEMENT" || - (e instanceof __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* WorkerScript */] && e.errorMessage == "CONTINUESTATEMENT")) { - //Continue statement, recurse - var recursiveCall = evaluateWhile(exp, workerScript); - recursiveCall.then(function(foo) { - resolve("endWhileLoop"); - }, function(e) { - reject(e); - }); - } else { - reject(e); - } - }); - }, __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].CodeInstructionRunTime); - }); - - //After the code executes make a recursive call - pCode.then(function(resCode) { - var recursiveCall = evaluateWhile(exp, workerScript); - recursiveCall.then(function(foo) { - resolve("endWhileLoop"); - }, function(e) { - reject(e); - }); - }, function(e) { - reject(e); - }); - } else { - resolve("endWhileLoop"); //Doesn't need to resolve to any particular value - } - }, function(e) { - reject(e); - }); - }); + var env = workerScript.env; + if (env.stopFlag) {return Promise.reject(workerScript);} + return Promise.delay(__WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].CodeInstructionRunTime).then(function() { + return evaluate(exp.test, workerScript); + }).then(function(resCond) { + if (resCond) { + return evaluate(exp.body, workerScript).then(function(resCode) { + return Promise.resolve(resCode); + }).catch(function(e) { + if (e == "CONTINUESTATEMENT" || + (e instanceof __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* WorkerScript */] && e.errorMessage == "CONTINUESTATEMENT")) { + //Continue statement, recurse + return evaluateWhile(exp, workerScript).then(function(foo) { + return Promise.resolve("endWhileLoop"); + }, function(e) { + return Promise.reject(e); + }); + } else { + return Promise.reject(e); + } + }).then(function(resCode) { + return evaluateWhile(exp, workerScript).then(function(foo) { + return Promise.resolve("endWhileLoop"); + }, function(e) { + return Promise.reject(e); + }); + }).catch(function(e) { + return Promise.reject(e); + }); + } else { + return Promise.resolve("endWhileLoop"); //Doesn't need to resolve to any particular value + } + }).catch(function(e) { + return Promise.reject(e); + }); } function evaluateProg(exp, workerScript, index) { - var env = workerScript.env; + var env = workerScript.env; + if (env.stopFlag) {return Promise.reject(workerScript);} + if (index >= exp.body.length) { + return Promise.resolve("progFinished"); + } else { + //Evaluate this line of code in the prog + //After the code finishes evaluating, evaluate the next line recursively + return evaluate(exp.body[index], workerScript).then(function(res) { + return evaluateProg(exp, workerScript, index + 1); + }).then(function(res) { + return Promise.resolve(workerScript); + }).catch(function(e) { + return Promise.reject(e); + }); + } +} - return new Promise(function(resolve, reject) { - if (env.stopFlag) {reject(workerScript); return;} - - if (index >= exp.body.length) { - resolve("progFinished"); - } else { - //Evaluate this line of code in the prog - var code = new Promise(function(resolve, reject) { - setTimeout(function() { - var evaluatePromise = evaluate(exp.body[index], workerScript); - evaluatePromise.then(function(evalRes) { - resolve(evalRes); - }, function(e) { - reject(e); - }); - }, __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].CodeInstructionRunTime); - }); - - //After the code finishes evaluating, evaluate the next line recursively - code.then(function(codeRes) { - var nextLine = evaluateProg(exp, workerScript, index + 1); - nextLine.then(function(nextLineRes) { - resolve(workerScript); - }, function(e) { - reject(e); - }); - }, function(e) { - reject(e); - }); - } - }); +function killNetscriptDelay(workerScript) { + if (workerScript instanceof __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* WorkerScript */]) { + if (workerScript.delay) { + workerScript.delay.cancel(); + } + } } function netscriptDelay(time, workerScript) { - return new Promise(function(resolve) { - var delay = setTimeout(resolve, time); - workerScript.killTrigger = function() { - clearTimeout(delay); - resolve(); - }; - }); + var delay = Promise.delay(time, true); + workerScript.delay = delay; + return delay; } function makeRuntimeRejectMsg(workerScript, msg) { @@ -40939,7 +40992,7 @@ function runScriptFromScript(server, scriptname, args, workerScript, threads=1) workerScript.scriptRef.log("Running script: " + scriptname + " on " + server.hostname + " with " + threads + " threads and args: " + Object(__WEBPACK_IMPORTED_MODULE_9__utils_HelperFunctions_js__["f" /* printArray */])(args) + ". May take a few seconds to start up..."); var runningScriptObj = new __WEBPACK_IMPORTED_MODULE_7__Script_js__["b" /* RunningScript */](script, args); runningScriptObj.threads = threads; - server.runningScripts.push(runningScriptObj); //Push onto runningScripts + server.runningScripts.push(runningScriptObj); //Push onto runningScripts Object(__WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["c" /* addWorkerScript */])(runningScriptObj, server); return Promise.resolve(true); } @@ -40973,7 +41026,7 @@ function isScriptErrorMessage(msg) { //The same as Player's calculateHackingChance() function but takes in the server as an argument function scriptCalculateHackingChance(server) { - var difficultyMult = (100 - server.hackDifficulty) / 100; + var difficultyMult = (100 - server.hackDifficulty) / 100; var skillMult = (1.75 * __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_skill) + (0.2 * __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].intelligence); var skillChance = (skillMult - server.requiredHackingSkill) / skillMult; var chance = skillChance * difficultyMult * __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_chance_mult; @@ -40984,10 +41037,10 @@ function scriptCalculateHackingChance(server) { //The same as Player's calculateHackingTime() function but takes in the server as an argument function scriptCalculateHackingTime(server) { - var difficultyMult = server.requiredHackingSkill * server.hackDifficulty; - var skillFactor = (2.5 * difficultyMult + 500) / (__WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_skill + 50 + (0.1 * __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].intelligence)); - var hackingTime = 5 * skillFactor / __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_speed_mult; //This is in seconds - return hackingTime; + var difficultyMult = server.requiredHackingSkill * server.hackDifficulty; + var skillFactor = (2.5 * difficultyMult + 500) / (__WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_skill + 50 + (0.1 * __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].intelligence)); + var hackingTime = 5 * skillFactor / __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_speed_mult; //This is in seconds + return hackingTime; } //The same as Player's calculateExpGain() function but takes in the server as an argument @@ -41000,7 +41053,7 @@ function scriptCalculateExpGain(server) { //The same as Player's calculatePercentMoneyHacked() function but takes in the server as an argument function scriptCalculatePercentMoneyHacked(server) { - var difficultyMult = (100 - server.hackDifficulty) / 100; + var difficultyMult = (100 - server.hackDifficulty) / 100; var skillMult = (__WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_skill - (server.requiredHackingSkill - 1)) / __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_skill; var percentMoneyHacked = difficultyMult * skillMult * __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_money_mult / 240; if (percentMoneyHacked < 0) {return 0;} @@ -41011,24 +41064,24 @@ function scriptCalculatePercentMoneyHacked(server) { //Amount of time to execute grow() in milliseconds function scriptCalculateGrowTime(server) { var difficultyMult = server.requiredHackingSkill * server.hackDifficulty; - var skillFactor = (2.5 * difficultyMult + 500) / (__WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_skill + 50 + (0.1 * __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].intelligence)); - var growTime = 16 * skillFactor / __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_speed_mult; //This is in seconds - return growTime * 1000; + var skillFactor = (2.5 * difficultyMult + 500) / (__WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_skill + 50 + (0.1 * __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].intelligence)); + var growTime = 16 * skillFactor / __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_speed_mult; //This is in seconds + return growTime * 1000; } //Amount of time to execute weaken() in milliseconds function scriptCalculateWeakenTime(server) { var difficultyMult = server.requiredHackingSkill * server.hackDifficulty; - var skillFactor = (2.5 * difficultyMult + 500) / (__WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_skill + 50 + (0.1 * __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].intelligence)); - var weakenTime = 20 * skillFactor / __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_speed_mult; //This is in seconds - return weakenTime * 1000; + var skillFactor = (2.5 * difficultyMult + 500) / (__WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_skill + 50 + (0.1 * __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].intelligence)); + var weakenTime = 20 * skillFactor / __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_speed_mult; //This is in seconds + return weakenTime * 1000; } /***/ }), -/* 38 */ +/* 39 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -41046,7 +41099,7 @@ function scriptCalculateWeakenTime(server) { /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__BitNode_js__ = __webpack_require__(7); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Constants_js__ = __webpack_require__(3); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__engine_js__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__InteractiveTutorial_js__ = __webpack_require__(26); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__InteractiveTutorial_js__ = __webpack_require__(27); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Player_js__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__utils_DialogBox_js__ = __webpack_require__(1); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__ = __webpack_require__(2); @@ -41551,7 +41604,7 @@ function getHacknetNode(name) { /***/ }), -/* 39 */ +/* 40 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -41606,7 +41659,7 @@ function gameOptionsBoxOpen() { /* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(9))) /***/ }), -/* 40 */ +/* 41 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_RESULT__;/* global window, exports, define */ @@ -41831,7 +41884,7 @@ var __WEBPACK_AMD_DEFINE_RESULT__;/* global window, exports, define */ /***/ }), -/* 41 */ +/* 42 */ /***/ (function(module, exports) { module.exports = function() { @@ -41840,14 +41893,14 @@ module.exports = function() { /***/ }), -/* 42 */ +/* 43 */ /***/ (function(module, exports) { module.exports.id = 'ace/mode/javascript_worker'; module.exports.src = "\"no use strict\";(function(window){function resolveModuleId(id,paths){for(var testPath=id,tail=\"\";testPath;){var alias=paths[testPath];if(\"string\"==typeof alias)return alias+tail;if(alias)return alias.location.replace(/\\/*$/,\"/\")+(tail||alias.main||alias.name);if(alias===!1)return\"\";var i=testPath.lastIndexOf(\"/\");if(-1===i)break;tail=testPath.substr(i)+tail,testPath=testPath.slice(0,i)}return id}if(!(void 0!==window.window&&window.document||window.acequire&&window.define)){window.console||(window.console=function(){var msgs=Array.prototype.slice.call(arguments,0);postMessage({type:\"log\",data:msgs})},window.console.error=window.console.warn=window.console.log=window.console.trace=window.console),window.window=window,window.ace=window,window.onerror=function(message,file,line,col,err){postMessage({type:\"error\",data:{message:message,data:err.data,file:file,line:line,col:col,stack:err.stack}})},window.normalizeModule=function(parentId,moduleName){if(-1!==moduleName.indexOf(\"!\")){var chunks=moduleName.split(\"!\");return window.normalizeModule(parentId,chunks[0])+\"!\"+window.normalizeModule(parentId,chunks[1])}if(\".\"==moduleName.charAt(0)){var base=parentId.split(\"/\").slice(0,-1).join(\"/\");for(moduleName=(base?base+\"/\":\"\")+moduleName;-1!==moduleName.indexOf(\".\")&&previous!=moduleName;){var previous=moduleName;moduleName=moduleName.replace(/^\\.\\//,\"\").replace(/\\/\\.\\//,\"/\").replace(/[^\\/]+\\/\\.\\.\\//,\"\")}}return moduleName},window.acequire=function acequire(parentId,id){if(id||(id=parentId,parentId=null),!id.charAt)throw Error(\"worker.js acequire() accepts only (parentId, id) as arguments\");id=window.normalizeModule(parentId,id);var module=window.acequire.modules[id];if(module)return module.initialized||(module.initialized=!0,module.exports=module.factory().exports),module.exports;if(!window.acequire.tlns)return console.log(\"unable to load \"+id);var path=resolveModuleId(id,window.acequire.tlns);return\".js\"!=path.slice(-3)&&(path+=\".js\"),window.acequire.id=id,window.acequire.modules[id]={},importScripts(path),window.acequire(parentId,id)},window.acequire.modules={},window.acequire.tlns={},window.define=function(id,deps,factory){if(2==arguments.length?(factory=deps,\"string\"!=typeof id&&(deps=id,id=window.acequire.id)):1==arguments.length&&(factory=id,deps=[],id=window.acequire.id),\"function\"!=typeof factory)return window.acequire.modules[id]={exports:factory,initialized:!0},void 0;deps.length||(deps=[\"require\",\"exports\",\"module\"]);var req=function(childId){return window.acequire(id,childId)};window.acequire.modules[id]={exports:{},factory:function(){var module=this,returnExports=factory.apply(this,deps.map(function(dep){switch(dep){case\"require\":return req;case\"exports\":return module.exports;case\"module\":return module;default:return req(dep)}}));return returnExports&&(module.exports=returnExports),module}}},window.define.amd={},acequire.tlns={},window.initBaseUrls=function(topLevelNamespaces){for(var i in topLevelNamespaces)acequire.tlns[i]=topLevelNamespaces[i]},window.initSender=function(){var EventEmitter=window.acequire(\"ace/lib/event_emitter\").EventEmitter,oop=window.acequire(\"ace/lib/oop\"),Sender=function(){};return function(){oop.implement(this,EventEmitter),this.callback=function(data,callbackId){postMessage({type:\"call\",id:callbackId,data:data})},this.emit=function(name,data){postMessage({type:\"event\",name:name,data:data})}}.call(Sender.prototype),new Sender};var main=window.main=null,sender=window.sender=null;window.onmessage=function(e){var msg=e.data;if(msg.event&&sender)sender._signal(msg.event,msg.data);else if(msg.command)if(main[msg.command])main[msg.command].apply(main,msg.args);else{if(!window[msg.command])throw Error(\"Unknown command:\"+msg.command);window[msg.command].apply(window,msg.args)}else if(msg.init){window.initBaseUrls(msg.tlns),acequire(\"ace/lib/es5-shim\"),sender=window.sender=window.initSender();var clazz=acequire(msg.module)[msg.classname];main=window.main=new clazz(sender)}}}})(this),ace.define(\"ace/lib/oop\",[\"require\",\"exports\",\"module\"],function(acequire,exports){\"use strict\";exports.inherits=function(ctor,superCtor){ctor.super_=superCtor,ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:!1,writable:!0,configurable:!0}})},exports.mixin=function(obj,mixin){for(var key in mixin)obj[key]=mixin[key];return obj},exports.implement=function(proto,mixin){exports.mixin(proto,mixin)}}),ace.define(\"ace/range\",[\"require\",\"exports\",\"module\"],function(acequire,exports){\"use strict\";var comparePoints=function(p1,p2){return p1.row-p2.row||p1.column-p2.column},Range=function(startRow,startColumn,endRow,endColumn){this.start={row:startRow,column:startColumn},this.end={row:endRow,column:endColumn}};(function(){this.isEqual=function(range){return this.start.row===range.start.row&&this.end.row===range.end.row&&this.start.column===range.start.column&&this.end.column===range.end.column},this.toString=function(){return\"Range: [\"+this.start.row+\"/\"+this.start.column+\"] -> [\"+this.end.row+\"/\"+this.end.column+\"]\"},this.contains=function(row,column){return 0==this.compare(row,column)},this.compareRange=function(range){var cmp,end=range.end,start=range.start;return cmp=this.compare(end.row,end.column),1==cmp?(cmp=this.compare(start.row,start.column),1==cmp?2:0==cmp?1:0):-1==cmp?-2:(cmp=this.compare(start.row,start.column),-1==cmp?-1:1==cmp?42:0)},this.comparePoint=function(p){return this.compare(p.row,p.column)},this.containsRange=function(range){return 0==this.comparePoint(range.start)&&0==this.comparePoint(range.end)},this.intersects=function(range){var cmp=this.compareRange(range);return-1==cmp||0==cmp||1==cmp},this.isEnd=function(row,column){return this.end.row==row&&this.end.column==column},this.isStart=function(row,column){return this.start.row==row&&this.start.column==column},this.setStart=function(row,column){\"object\"==typeof row?(this.start.column=row.column,this.start.row=row.row):(this.start.row=row,this.start.column=column)},this.setEnd=function(row,column){\"object\"==typeof row?(this.end.column=row.column,this.end.row=row.row):(this.end.row=row,this.end.column=column)},this.inside=function(row,column){return 0==this.compare(row,column)?this.isEnd(row,column)||this.isStart(row,column)?!1:!0:!1},this.insideStart=function(row,column){return 0==this.compare(row,column)?this.isEnd(row,column)?!1:!0:!1},this.insideEnd=function(row,column){return 0==this.compare(row,column)?this.isStart(row,column)?!1:!0:!1},this.compare=function(row,column){return this.isMultiLine()||row!==this.start.row?this.start.row>row?-1:row>this.end.row?1:this.start.row===row?column>=this.start.column?0:-1:this.end.row===row?this.end.column>=column?0:1:0:this.start.column>column?-1:column>this.end.column?1:0},this.compareStart=function(row,column){return this.start.row==row&&this.start.column==column?-1:this.compare(row,column)},this.compareEnd=function(row,column){return this.end.row==row&&this.end.column==column?1:this.compare(row,column)},this.compareInside=function(row,column){return this.end.row==row&&this.end.column==column?1:this.start.row==row&&this.start.column==column?-1:this.compare(row,column)},this.clipRows=function(firstRow,lastRow){if(this.end.row>lastRow)var end={row:lastRow+1,column:0};else if(firstRow>this.end.row)var end={row:firstRow,column:0};if(this.start.row>lastRow)var start={row:lastRow+1,column:0};else if(firstRow>this.start.row)var start={row:firstRow,column:0};return Range.fromPoints(start||this.start,end||this.end)},this.extend=function(row,column){var cmp=this.compare(row,column);if(0==cmp)return this;if(-1==cmp)var start={row:row,column:column};else var end={row:row,column:column};return Range.fromPoints(start||this.start,end||this.end)},this.isEmpty=function(){return this.start.row===this.end.row&&this.start.column===this.end.column},this.isMultiLine=function(){return this.start.row!==this.end.row},this.clone=function(){return Range.fromPoints(this.start,this.end)},this.collapseRows=function(){return 0==this.end.column?new Range(this.start.row,0,Math.max(this.start.row,this.end.row-1),0):new Range(this.start.row,0,this.end.row,0)},this.toScreenRange=function(session){var screenPosStart=session.documentToScreenPosition(this.start),screenPosEnd=session.documentToScreenPosition(this.end);return new Range(screenPosStart.row,screenPosStart.column,screenPosEnd.row,screenPosEnd.column)},this.moveBy=function(row,column){this.start.row+=row,this.start.column+=column,this.end.row+=row,this.end.column+=column}}).call(Range.prototype),Range.fromPoints=function(start,end){return new Range(start.row,start.column,end.row,end.column)},Range.comparePoints=comparePoints,Range.comparePoints=function(p1,p2){return p1.row-p2.row||p1.column-p2.column},exports.Range=Range}),ace.define(\"ace/apply_delta\",[\"require\",\"exports\",\"module\"],function(acequire,exports){\"use strict\";exports.applyDelta=function(docLines,delta){var row=delta.start.row,startColumn=delta.start.column,line=docLines[row]||\"\";switch(delta.action){case\"insert\":var lines=delta.lines;if(1===lines.length)docLines[row]=line.substring(0,startColumn)+delta.lines[0]+line.substring(startColumn);else{var args=[row,1].concat(delta.lines);docLines.splice.apply(docLines,args),docLines[row]=line.substring(0,startColumn)+docLines[row],docLines[row+delta.lines.length-1]+=line.substring(startColumn)}break;case\"remove\":var endColumn=delta.end.column,endRow=delta.end.row;row===endRow?docLines[row]=line.substring(0,startColumn)+line.substring(endColumn):docLines.splice(row,endRow-row+1,line.substring(0,startColumn)+docLines[endRow].substring(endColumn))}}}),ace.define(\"ace/lib/event_emitter\",[\"require\",\"exports\",\"module\"],function(acequire,exports){\"use strict\";var EventEmitter={},stopPropagation=function(){this.propagationStopped=!0},preventDefault=function(){this.defaultPrevented=!0};EventEmitter._emit=EventEmitter._dispatchEvent=function(eventName,e){this._eventRegistry||(this._eventRegistry={}),this._defaultHandlers||(this._defaultHandlers={});var listeners=this._eventRegistry[eventName]||[],defaultHandler=this._defaultHandlers[eventName];if(listeners.length||defaultHandler){\"object\"==typeof e&&e||(e={}),e.type||(e.type=eventName),e.stopPropagation||(e.stopPropagation=stopPropagation),e.preventDefault||(e.preventDefault=preventDefault),listeners=listeners.slice();for(var i=0;listeners.length>i&&(listeners[i](e,this),!e.propagationStopped);i++);return defaultHandler&&!e.defaultPrevented?defaultHandler(e,this):void 0}},EventEmitter._signal=function(eventName,e){var listeners=(this._eventRegistry||{})[eventName];if(listeners){listeners=listeners.slice();for(var i=0;listeners.length>i;i++)listeners[i](e,this)}},EventEmitter.once=function(eventName,callback){var _self=this;callback&&this.addEventListener(eventName,function newCallback(){_self.removeEventListener(eventName,newCallback),callback.apply(null,arguments)})},EventEmitter.setDefaultHandler=function(eventName,callback){var handlers=this._defaultHandlers;if(handlers||(handlers=this._defaultHandlers={_disabled_:{}}),handlers[eventName]){var old=handlers[eventName],disabled=handlers._disabled_[eventName];disabled||(handlers._disabled_[eventName]=disabled=[]),disabled.push(old);var i=disabled.indexOf(callback);-1!=i&&disabled.splice(i,1)}handlers[eventName]=callback},EventEmitter.removeDefaultHandler=function(eventName,callback){var handlers=this._defaultHandlers;if(handlers){var disabled=handlers._disabled_[eventName];if(handlers[eventName]==callback)handlers[eventName],disabled&&this.setDefaultHandler(eventName,disabled.pop());else if(disabled){var i=disabled.indexOf(callback);-1!=i&&disabled.splice(i,1)}}},EventEmitter.on=EventEmitter.addEventListener=function(eventName,callback,capturing){this._eventRegistry=this._eventRegistry||{};var listeners=this._eventRegistry[eventName];return listeners||(listeners=this._eventRegistry[eventName]=[]),-1==listeners.indexOf(callback)&&listeners[capturing?\"unshift\":\"push\"](callback),callback},EventEmitter.off=EventEmitter.removeListener=EventEmitter.removeEventListener=function(eventName,callback){this._eventRegistry=this._eventRegistry||{};var listeners=this._eventRegistry[eventName];if(listeners){var index=listeners.indexOf(callback);-1!==index&&listeners.splice(index,1)}},EventEmitter.removeAllListeners=function(eventName){this._eventRegistry&&(this._eventRegistry[eventName]=[])},exports.EventEmitter=EventEmitter}),ace.define(\"ace/anchor\",[\"require\",\"exports\",\"module\",\"ace/lib/oop\",\"ace/lib/event_emitter\"],function(acequire,exports){\"use strict\";var oop=acequire(\"./lib/oop\"),EventEmitter=acequire(\"./lib/event_emitter\").EventEmitter,Anchor=exports.Anchor=function(doc,row,column){this.$onChange=this.onChange.bind(this),this.attach(doc),column===void 0?this.setPosition(row.row,row.column):this.setPosition(row,column)};(function(){function $pointsInOrder(point1,point2,equalPointsInOrder){var bColIsAfter=equalPointsInOrder?point1.column<=point2.column:point1.columnthis.row)){var point=$getTransformedPoint(delta,{row:this.row,column:this.column},this.$insertRight);this.setPosition(point.row,point.column,!0)}},this.setPosition=function(row,column,noClip){var pos;if(pos=noClip?{row:row,column:column}:this.$clipPositionToDocument(row,column),this.row!=pos.row||this.column!=pos.column){var old={row:this.row,column:this.column};this.row=pos.row,this.column=pos.column,this._signal(\"change\",{old:old,value:pos})}},this.detach=function(){this.document.removeEventListener(\"change\",this.$onChange)},this.attach=function(doc){this.document=doc||this.document,this.document.on(\"change\",this.$onChange)},this.$clipPositionToDocument=function(row,column){var pos={};return row>=this.document.getLength()?(pos.row=Math.max(0,this.document.getLength()-1),pos.column=this.document.getLine(pos.row).length):0>row?(pos.row=0,pos.column=0):(pos.row=row,pos.column=Math.min(this.document.getLine(pos.row).length,Math.max(0,column))),0>column&&(pos.column=0),pos}}).call(Anchor.prototype)}),ace.define(\"ace/document\",[\"require\",\"exports\",\"module\",\"ace/lib/oop\",\"ace/apply_delta\",\"ace/lib/event_emitter\",\"ace/range\",\"ace/anchor\"],function(acequire,exports){\"use strict\";var oop=acequire(\"./lib/oop\"),applyDelta=acequire(\"./apply_delta\").applyDelta,EventEmitter=acequire(\"./lib/event_emitter\").EventEmitter,Range=acequire(\"./range\").Range,Anchor=acequire(\"./anchor\").Anchor,Document=function(textOrLines){this.$lines=[\"\"],0===textOrLines.length?this.$lines=[\"\"]:Array.isArray(textOrLines)?this.insertMergedLines({row:0,column:0},textOrLines):this.insert({row:0,column:0},textOrLines)};(function(){oop.implement(this,EventEmitter),this.setValue=function(text){var len=this.getLength()-1;this.remove(new Range(0,0,len,this.getLine(len).length)),this.insert({row:0,column:0},text)},this.getValue=function(){return this.getAllLines().join(this.getNewLineCharacter())},this.createAnchor=function(row,column){return new Anchor(this,row,column)},this.$split=0===\"aaa\".split(/a/).length?function(text){return text.replace(/\\r\\n|\\r/g,\"\\n\").split(\"\\n\")}:function(text){return text.split(/\\r\\n|\\r|\\n/)},this.$detectNewLine=function(text){var match=text.match(/^.*?(\\r\\n|\\r|\\n)/m);this.$autoNewLine=match?match[1]:\"\\n\",this._signal(\"changeNewLineMode\")},this.getNewLineCharacter=function(){switch(this.$newLineMode){case\"windows\":return\"\\r\\n\";case\"unix\":return\"\\n\";default:return this.$autoNewLine||\"\\n\"}},this.$autoNewLine=\"\",this.$newLineMode=\"auto\",this.setNewLineMode=function(newLineMode){this.$newLineMode!==newLineMode&&(this.$newLineMode=newLineMode,this._signal(\"changeNewLineMode\"))},this.getNewLineMode=function(){return this.$newLineMode},this.isNewLine=function(text){return\"\\r\\n\"==text||\"\\r\"==text||\"\\n\"==text},this.getLine=function(row){return this.$lines[row]||\"\"},this.getLines=function(firstRow,lastRow){return this.$lines.slice(firstRow,lastRow+1)},this.getAllLines=function(){return this.getLines(0,this.getLength())},this.getLength=function(){return this.$lines.length},this.getTextRange=function(range){return this.getLinesForRange(range).join(this.getNewLineCharacter())},this.getLinesForRange=function(range){var lines;if(range.start.row===range.end.row)lines=[this.getLine(range.start.row).substring(range.start.column,range.end.column)];else{lines=this.getLines(range.start.row,range.end.row),lines[0]=(lines[0]||\"\").substring(range.start.column);var l=lines.length-1;range.end.row-range.start.row==l&&(lines[l]=lines[l].substring(0,range.end.column))}return lines},this.insertLines=function(row,lines){return console.warn(\"Use of document.insertLines is deprecated. Use the insertFullLines method instead.\"),this.insertFullLines(row,lines)},this.removeLines=function(firstRow,lastRow){return console.warn(\"Use of document.removeLines is deprecated. Use the removeFullLines method instead.\"),this.removeFullLines(firstRow,lastRow)},this.insertNewLine=function(position){return console.warn(\"Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead.\"),this.insertMergedLines(position,[\"\",\"\"])},this.insert=function(position,text){return 1>=this.getLength()&&this.$detectNewLine(text),this.insertMergedLines(position,this.$split(text))},this.insertInLine=function(position,text){var start=this.clippedPos(position.row,position.column),end=this.pos(position.row,position.column+text.length);return this.applyDelta({start:start,end:end,action:\"insert\",lines:[text]},!0),this.clonePos(end)},this.clippedPos=function(row,column){var length=this.getLength();void 0===row?row=length:0>row?row=0:row>=length&&(row=length-1,column=void 0);var line=this.getLine(row);return void 0==column&&(column=line.length),column=Math.min(Math.max(column,0),line.length),{row:row,column:column}},this.clonePos=function(pos){return{row:pos.row,column:pos.column}},this.pos=function(row,column){return{row:row,column:column}},this.$clipPosition=function(position){var length=this.getLength();return position.row>=length?(position.row=Math.max(0,length-1),position.column=this.getLine(length-1).length):(position.row=Math.max(0,position.row),position.column=Math.min(Math.max(position.column,0),this.getLine(position.row).length)),position},this.insertFullLines=function(row,lines){row=Math.min(Math.max(row,0),this.getLength());var column=0;this.getLength()>row?(lines=lines.concat([\"\"]),column=0):(lines=[\"\"].concat(lines),row--,column=this.$lines[row].length),this.insertMergedLines({row:row,column:column},lines)},this.insertMergedLines=function(position,lines){var start=this.clippedPos(position.row,position.column),end={row:start.row+lines.length-1,column:(1==lines.length?start.column:0)+lines[lines.length-1].length};return this.applyDelta({start:start,end:end,action:\"insert\",lines:lines}),this.clonePos(end)},this.remove=function(range){var start=this.clippedPos(range.start.row,range.start.column),end=this.clippedPos(range.end.row,range.end.column);return this.applyDelta({start:start,end:end,action:\"remove\",lines:this.getLinesForRange({start:start,end:end})}),this.clonePos(start)},this.removeInLine=function(row,startColumn,endColumn){var start=this.clippedPos(row,startColumn),end=this.clippedPos(row,endColumn);return this.applyDelta({start:start,end:end,action:\"remove\",lines:this.getLinesForRange({start:start,end:end})},!0),this.clonePos(start)},this.removeFullLines=function(firstRow,lastRow){firstRow=Math.min(Math.max(0,firstRow),this.getLength()-1),lastRow=Math.min(Math.max(0,lastRow),this.getLength()-1);var deleteFirstNewLine=lastRow==this.getLength()-1&&firstRow>0,deleteLastNewLine=this.getLength()-1>lastRow,startRow=deleteFirstNewLine?firstRow-1:firstRow,startCol=deleteFirstNewLine?this.getLine(startRow).length:0,endRow=deleteLastNewLine?lastRow+1:lastRow,endCol=deleteLastNewLine?0:this.getLine(endRow).length,range=new Range(startRow,startCol,endRow,endCol),deletedLines=this.$lines.slice(firstRow,lastRow+1);return this.applyDelta({start:range.start,end:range.end,action:\"remove\",lines:this.getLinesForRange(range)}),deletedLines},this.removeNewLine=function(row){this.getLength()-1>row&&row>=0&&this.applyDelta({start:this.pos(row,this.getLine(row).length),end:this.pos(row+1,0),action:\"remove\",lines:[\"\",\"\"]})},this.replace=function(range,text){if(range instanceof Range||(range=Range.fromPoints(range.start,range.end)),0===text.length&&range.isEmpty())return range.start;if(text==this.getTextRange(range))return range.end;this.remove(range);var end;return end=text?this.insert(range.start,text):range.start},this.applyDeltas=function(deltas){for(var i=0;deltas.length>i;i++)this.applyDelta(deltas[i])},this.revertDeltas=function(deltas){for(var i=deltas.length-1;i>=0;i--)this.revertDelta(deltas[i])},this.applyDelta=function(delta,doNotValidate){var isInsert=\"insert\"==delta.action;(isInsert?1>=delta.lines.length&&!delta.lines[0]:!Range.comparePoints(delta.start,delta.end))||(isInsert&&delta.lines.length>2e4&&this.$splitAndapplyLargeDelta(delta,2e4),applyDelta(this.$lines,delta,doNotValidate),this._signal(\"change\",delta))},this.$splitAndapplyLargeDelta=function(delta,MAX){for(var lines=delta.lines,l=lines.length,row=delta.start.row,column=delta.start.column,from=0,to=0;;){from=to,to+=MAX-1;var chunk=lines.slice(from,to);if(to>l){delta.lines=chunk,delta.start.row=row+from,delta.start.column=column;break}chunk.push(\"\"),this.applyDelta({start:this.pos(row+from,column),end:this.pos(row+to,column=0),action:delta.action,lines:chunk},!0)}},this.revertDelta=function(delta){this.applyDelta({start:this.clonePos(delta.start),end:this.clonePos(delta.end),action:\"insert\"==delta.action?\"remove\":\"insert\",lines:delta.lines.slice()})},this.indexToPosition=function(index,startRow){for(var lines=this.$lines||this.getAllLines(),newlineLength=this.getNewLineCharacter().length,i=startRow||0,l=lines.length;l>i;i++)if(index-=lines[i].length+newlineLength,0>index)return{row:i,column:index+lines[i].length+newlineLength};return{row:l-1,column:lines[l-1].length}},this.positionToIndex=function(pos,startRow){for(var lines=this.$lines||this.getAllLines(),newlineLength=this.getNewLineCharacter().length,index=0,row=Math.min(pos.row,lines.length),i=startRow||0;row>i;++i)index+=lines[i].length+newlineLength;return index+pos.column}}).call(Document.prototype),exports.Document=Document}),ace.define(\"ace/lib/lang\",[\"require\",\"exports\",\"module\"],function(acequire,exports){\"use strict\";exports.last=function(a){return a[a.length-1]},exports.stringReverse=function(string){return string.split(\"\").reverse().join(\"\")},exports.stringRepeat=function(string,count){for(var result=\"\";count>0;)1&count&&(result+=string),(count>>=1)&&(string+=string);return result};var trimBeginRegexp=/^\\s\\s*/,trimEndRegexp=/\\s\\s*$/;exports.stringTrimLeft=function(string){return string.replace(trimBeginRegexp,\"\")},exports.stringTrimRight=function(string){return string.replace(trimEndRegexp,\"\")},exports.copyObject=function(obj){var copy={};for(var key in obj)copy[key]=obj[key];return copy},exports.copyArray=function(array){for(var copy=[],i=0,l=array.length;l>i;i++)copy[i]=array[i]&&\"object\"==typeof array[i]?this.copyObject(array[i]):array[i];return copy},exports.deepCopy=function deepCopy(obj){if(\"object\"!=typeof obj||!obj)return obj;var copy;if(Array.isArray(obj)){copy=[];for(var key=0;obj.length>key;key++)copy[key]=deepCopy(obj[key]);return copy}if(\"[object Object]\"!==Object.prototype.toString.call(obj))return obj;copy={};for(var key in obj)copy[key]=deepCopy(obj[key]);return copy},exports.arrayToMap=function(arr){for(var map={},i=0;arr.length>i;i++)map[arr[i]]=1;return map},exports.createMap=function(props){var map=Object.create(null);for(var i in props)map[i]=props[i];return map},exports.arrayRemove=function(array,value){for(var i=0;array.length>=i;i++)value===array[i]&&array.splice(i,1)},exports.escapeRegExp=function(str){return str.replace(/([.*+?^${}()|[\\]\\/\\\\])/g,\"\\\\$1\")},exports.escapeHTML=function(str){return str.replace(/&/g,\"&\").replace(/\"/g,\""\").replace(/'/g,\"'\").replace(/i;i+=2){if(Array.isArray(data[i+1]))var d={action:\"insert\",start:data[i],lines:data[i+1]};else var d={action:\"remove\",start:data[i],end:data[i+1]};doc.applyDelta(d,!0)}return _self.$timeout?deferredUpdate.schedule(_self.$timeout):(_self.onUpdate(),void 0)})};(function(){this.$timeout=500,this.setTimeout=function(timeout){this.$timeout=timeout},this.setValue=function(value){this.doc.setValue(value),this.deferredUpdate.schedule(this.$timeout)},this.getValue=function(callbackId){this.sender.callback(this.doc.getValue(),callbackId)},this.onUpdate=function(){},this.isPending=function(){return this.deferredUpdate.isPending()}}).call(Mirror.prototype)}),ace.define(\"ace/mode/javascript/jshint\",[\"require\",\"exports\",\"module\"],function(acequire,exports,module){module.exports=function outer(modules,cache,entry){function newRequire(name,jumped){if(!cache[name]){if(!modules[name]){var currentRequire=\"function\"==typeof acequire&&acequire;if(!jumped&¤tRequire)return currentRequire(name,!0);if(previousRequire)return previousRequire(name,!0);var err=Error(\"Cannot find module '\"+name+\"'\");throw err.code=\"MODULE_NOT_FOUND\",err}var m=cache[name]={exports:{}};modules[name][0].call(m.exports,function(x){var id=modules[name][1][x];return newRequire(id?id:x)},m,m.exports,outer,modules,cache,entry)}return cache[name].exports}for(var previousRequire=\"function\"==typeof acequire&&acequire,i=0;entry.length>i;i++)newRequire(entry[i]);return newRequire(entry[0])}({\"/node_modules/browserify/node_modules/events/events.js\":[function(_dereq_,module){function EventEmitter(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function isFunction(arg){return\"function\"==typeof arg}function isNumber(arg){return\"number\"==typeof arg}function isObject(arg){return\"object\"==typeof arg&&null!==arg}function isUndefined(arg){return void 0===arg}module.exports=EventEmitter,EventEmitter.EventEmitter=EventEmitter,EventEmitter.prototype._events=void 0,EventEmitter.prototype._maxListeners=void 0,EventEmitter.defaultMaxListeners=10,EventEmitter.prototype.setMaxListeners=function(n){if(!isNumber(n)||0>n||isNaN(n))throw TypeError(\"n must be a positive number\");return this._maxListeners=n,this},EventEmitter.prototype.emit=function(type){var er,handler,len,args,i,listeners;if(this._events||(this._events={}),\"error\"===type&&(!this._events.error||isObject(this._events.error)&&!this._events.error.length)){if(er=arguments[1],er instanceof Error)throw er;throw TypeError('Uncaught, unspecified \"error\" event.')}if(handler=this._events[type],isUndefined(handler))return!1;if(isFunction(handler))switch(arguments.length){case 1:handler.call(this);break;case 2:handler.call(this,arguments[1]);break;case 3:handler.call(this,arguments[1],arguments[2]);break;default:for(len=arguments.length,args=Array(len-1),i=1;len>i;i++)args[i-1]=arguments[i];handler.apply(this,args)}else if(isObject(handler)){for(len=arguments.length,args=Array(len-1),i=1;len>i;i++)args[i-1]=arguments[i];for(listeners=handler.slice(),len=listeners.length,i=0;len>i;i++)listeners[i].apply(this,args)}return!0},EventEmitter.prototype.addListener=function(type,listener){var m;if(!isFunction(listener))throw TypeError(\"listener must be a function\");if(this._events||(this._events={}),this._events.newListener&&this.emit(\"newListener\",type,isFunction(listener.listener)?listener.listener:listener),this._events[type]?isObject(this._events[type])?this._events[type].push(listener):this._events[type]=[this._events[type],listener]:this._events[type]=listener,isObject(this._events[type])&&!this._events[type].warned){var m;m=isUndefined(this._maxListeners)?EventEmitter.defaultMaxListeners:this._maxListeners,m&&m>0&&this._events[type].length>m&&(this._events[type].warned=!0,console.error(\"(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.\",this._events[type].length),\"function\"==typeof console.trace&&console.trace())}return this},EventEmitter.prototype.on=EventEmitter.prototype.addListener,EventEmitter.prototype.once=function(type,listener){function g(){this.removeListener(type,g),fired||(fired=!0,listener.apply(this,arguments))}if(!isFunction(listener))throw TypeError(\"listener must be a function\");var fired=!1;return g.listener=listener,this.on(type,g),this},EventEmitter.prototype.removeListener=function(type,listener){var list,position,length,i;if(!isFunction(listener))throw TypeError(\"listener must be a function\");if(!this._events||!this._events[type])return this;if(list=this._events[type],length=list.length,position=-1,list===listener||isFunction(list.listener)&&list.listener===listener)delete this._events[type],this._events.removeListener&&this.emit(\"removeListener\",type,listener);else if(isObject(list)){for(i=length;i-->0;)if(list[i]===listener||list[i].listener&&list[i].listener===listener){position=i;break}if(0>position)return this;1===list.length?(list.length=0,delete this._events[type]):list.splice(position,1),this._events.removeListener&&this.emit(\"removeListener\",type,listener)}return this},EventEmitter.prototype.removeAllListeners=function(type){var key,listeners;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[type]&&delete this._events[type],this;if(0===arguments.length){for(key in this._events)\"removeListener\"!==key&&this.removeAllListeners(key);return this.removeAllListeners(\"removeListener\"),this._events={},this\n}if(listeners=this._events[type],isFunction(listeners))this.removeListener(type,listeners);else for(;listeners.length;)this.removeListener(type,listeners[listeners.length-1]);return delete this._events[type],this},EventEmitter.prototype.listeners=function(type){var ret;return ret=this._events&&this._events[type]?isFunction(this._events[type])?[this._events[type]]:this._events[type].slice():[]},EventEmitter.listenerCount=function(emitter,type){var ret;return ret=emitter._events&&emitter._events[type]?isFunction(emitter._events[type])?1:emitter._events[type].length:0}},{}],\"/node_modules/jshint/data/ascii-identifier-data.js\":[function(_dereq_,module){for(var identifierStartTable=[],i=0;128>i;i++)identifierStartTable[i]=36===i||i>=65&&90>=i||95===i||i>=97&&122>=i;for(var identifierPartTable=[],i=0;128>i;i++)identifierPartTable[i]=identifierStartTable[i]||i>=48&&57>=i;module.exports={asciiIdentifierStartTable:identifierStartTable,asciiIdentifierPartTable:identifierPartTable}},{}],\"/node_modules/jshint/lodash.js\":[function(_dereq_,module,exports){(function(global){(function(){function baseFindIndex(array,predicate,fromRight){for(var length=array.length,index=fromRight?length:-1;fromRight?index--:length>++index;)if(predicate(array[index],index,array))return index;return-1}function baseIndexOf(array,value,fromIndex){if(value!==value)return indexOfNaN(array,fromIndex);for(var index=fromIndex-1,length=array.length;length>++index;)if(array[index]===value)return index;return-1}function baseIsFunction(value){return\"function\"==typeof value||!1}function baseToString(value){return\"string\"==typeof value?value:null==value?\"\":value+\"\"}function indexOfNaN(array,fromIndex,fromRight){for(var length=array.length,index=fromIndex+(fromRight?0:-1);fromRight?index--:length>++index;){var other=array[index];if(other!==other)return index}return-1}function isObjectLike(value){return!!value&&\"object\"==typeof value}function lodash(){}function arrayCopy(source,array){var index=-1,length=source.length;for(array||(array=Array(length));length>++index;)array[index]=source[index];return array}function arrayEach(array,iteratee){for(var index=-1,length=array.length;length>++index&&iteratee(array[index],index,array)!==!1;);return array}function arrayFilter(array,predicate){for(var index=-1,length=array.length,resIndex=-1,result=[];length>++index;){var value=array[index];predicate(value,index,array)&&(result[++resIndex]=value)}return result}function arrayMap(array,iteratee){for(var index=-1,length=array.length,result=Array(length);length>++index;)result[index]=iteratee(array[index],index,array);return result}function arrayMax(array){for(var index=-1,length=array.length,result=NEGATIVE_INFINITY;length>++index;){var value=array[index];value>result&&(result=value)}return result}function arraySome(array,predicate){for(var index=-1,length=array.length;length>++index;)if(predicate(array[index],index,array))return!0;return!1}function assignWith(object,source,customizer){var props=keys(source);push.apply(props,getSymbols(source));for(var index=-1,length=props.length;length>++index;){var key=props[index],value=object[key],result=customizer(value,source[key],key,object,source);(result===result?result===value:value!==value)&&(value!==undefined||key in object)||(object[key]=result)}return object}function baseCopy(source,props,object){object||(object={});for(var index=-1,length=props.length;length>++index;){var key=props[index];object[key]=source[key]}return object}function baseCallback(func,thisArg,argCount){var type=typeof func;return\"function\"==type?thisArg===undefined?func:bindCallback(func,thisArg,argCount):null==func?identity:\"object\"==type?baseMatches(func):thisArg===undefined?property(func):baseMatchesProperty(func,thisArg)}function baseClone(value,isDeep,customizer,key,object,stackA,stackB){var result;if(customizer&&(result=object?customizer(value,key,object):customizer(value)),result!==undefined)return result;if(!isObject(value))return value;var isArr=isArray(value);if(isArr){if(result=initCloneArray(value),!isDeep)return arrayCopy(value,result)}else{var tag=objToString.call(value),isFunc=tag==funcTag;if(tag!=objectTag&&tag!=argsTag&&(!isFunc||object))return cloneableTags[tag]?initCloneByTag(value,tag,isDeep):object?value:{};if(result=initCloneObject(isFunc?{}:value),!isDeep)return baseAssign(result,value)}stackA||(stackA=[]),stackB||(stackB=[]);for(var length=stackA.length;length--;)if(stackA[length]==value)return stackB[length];return stackA.push(value),stackB.push(result),(isArr?arrayEach:baseForOwn)(value,function(subValue,key){result[key]=baseClone(subValue,isDeep,customizer,key,value,stackA,stackB)}),result}function baseFilter(collection,predicate){var result=[];return baseEach(collection,function(value,index,collection){predicate(value,index,collection)&&result.push(value)}),result}function baseForIn(object,iteratee){return baseFor(object,iteratee,keysIn)}function baseForOwn(object,iteratee){return baseFor(object,iteratee,keys)}function baseGet(object,path,pathKey){if(null!=object){pathKey!==undefined&&pathKey in toObject(object)&&(path=[pathKey]);for(var index=-1,length=path.length;null!=object&&length>++index;)var result=object=object[path[index]];return result}}function baseIsEqual(value,other,customizer,isLoose,stackA,stackB){if(value===other)return 0!==value||1/value==1/other;var valType=typeof value,othType=typeof other;return\"function\"!=valType&&\"object\"!=valType&&\"function\"!=othType&&\"object\"!=othType||null==value||null==other?value!==value&&other!==other:baseIsEqualDeep(value,other,baseIsEqual,customizer,isLoose,stackA,stackB)}function baseIsEqualDeep(object,other,equalFunc,customizer,isLoose,stackA,stackB){var objIsArr=isArray(object),othIsArr=isArray(other),objTag=arrayTag,othTag=arrayTag;objIsArr||(objTag=objToString.call(object),objTag==argsTag?objTag=objectTag:objTag!=objectTag&&(objIsArr=isTypedArray(object))),othIsArr||(othTag=objToString.call(other),othTag==argsTag?othTag=objectTag:othTag!=objectTag&&(othIsArr=isTypedArray(other)));var objIsObj=objTag==objectTag,othIsObj=othTag==objectTag,isSameTag=objTag==othTag;if(isSameTag&&!objIsArr&&!objIsObj)return equalByTag(object,other,objTag);if(!isLoose){var valWrapped=objIsObj&&hasOwnProperty.call(object,\"__wrapped__\"),othWrapped=othIsObj&&hasOwnProperty.call(other,\"__wrapped__\");if(valWrapped||othWrapped)return equalFunc(valWrapped?object.value():object,othWrapped?other.value():other,customizer,isLoose,stackA,stackB)}if(!isSameTag)return!1;stackA||(stackA=[]),stackB||(stackB=[]);for(var length=stackA.length;length--;)if(stackA[length]==object)return stackB[length]==other;stackA.push(object),stackB.push(other);var result=(objIsArr?equalArrays:equalObjects)(object,other,equalFunc,customizer,isLoose,stackA,stackB);return stackA.pop(),stackB.pop(),result}function baseIsMatch(object,props,values,strictCompareFlags,customizer){for(var index=-1,length=props.length,noCustomizer=!customizer;length>++index;)if(noCustomizer&&strictCompareFlags[index]?values[index]!==object[props[index]]:!(props[index]in object))return!1;for(index=-1;length>++index;){var key=props[index],objValue=object[key],srcValue=values[index];if(noCustomizer&&strictCompareFlags[index])var result=objValue!==undefined||key in object;else result=customizer?customizer(objValue,srcValue,key):undefined,result===undefined&&(result=baseIsEqual(srcValue,objValue,customizer,!0));if(!result)return!1}return!0}function baseMatches(source){var props=keys(source),length=props.length;if(!length)return constant(!0);if(1==length){var key=props[0],value=source[key];if(isStrictComparable(value))return function(object){return null==object?!1:object[key]===value&&(value!==undefined||key in toObject(object))}}for(var values=Array(length),strictCompareFlags=Array(length);length--;)value=source[props[length]],values[length]=value,strictCompareFlags[length]=isStrictComparable(value);return function(object){return null!=object&&baseIsMatch(toObject(object),props,values,strictCompareFlags)}}function baseMatchesProperty(path,value){var isArr=isArray(path),isCommon=isKey(path)&&isStrictComparable(value),pathKey=path+\"\";return path=toPath(path),function(object){if(null==object)return!1;var key=pathKey;if(object=toObject(object),!(!isArr&&isCommon||key in object)){if(object=1==path.length?object:baseGet(object,baseSlice(path,0,-1)),null==object)return!1;key=last(path),object=toObject(object)}return object[key]===value?value!==undefined||key in object:baseIsEqual(value,object[key],null,!0)}}function baseMerge(object,source,customizer,stackA,stackB){if(!isObject(object))return object;var isSrcArr=isLength(source.length)&&(isArray(source)||isTypedArray(source));if(!isSrcArr){var props=keys(source);push.apply(props,getSymbols(source))}return arrayEach(props||source,function(srcValue,key){if(props&&(key=srcValue,srcValue=source[key]),isObjectLike(srcValue))stackA||(stackA=[]),stackB||(stackB=[]),baseMergeDeep(object,source,key,baseMerge,customizer,stackA,stackB);else{var value=object[key],result=customizer?customizer(value,srcValue,key,object,source):undefined,isCommon=result===undefined;isCommon&&(result=srcValue),!isSrcArr&&result===undefined||!isCommon&&(result===result?result===value:value!==value)||(object[key]=result)}}),object}function baseMergeDeep(object,source,key,mergeFunc,customizer,stackA,stackB){for(var length=stackA.length,srcValue=source[key];length--;)if(stackA[length]==srcValue)return object[key]=stackB[length],undefined;var value=object[key],result=customizer?customizer(value,srcValue,key,object,source):undefined,isCommon=result===undefined;isCommon&&(result=srcValue,isLength(srcValue.length)&&(isArray(srcValue)||isTypedArray(srcValue))?result=isArray(value)?value:getLength(value)?arrayCopy(value):[]:isPlainObject(srcValue)||isArguments(srcValue)?result=isArguments(value)?toPlainObject(value):isPlainObject(value)?value:{}:isCommon=!1),stackA.push(srcValue),stackB.push(result),isCommon?object[key]=mergeFunc(result,srcValue,customizer,stackA,stackB):(result===result?result!==value:value===value)&&(object[key]=result)}function baseProperty(key){return function(object){return null==object?undefined:object[key]}}function basePropertyDeep(path){var pathKey=path+\"\";return path=toPath(path),function(object){return baseGet(object,path,pathKey)}}function baseSlice(array,start,end){var index=-1,length=array.length;start=null==start?0:+start||0,0>start&&(start=-start>length?0:length+start),end=end===undefined||end>length?length:+end||0,0>end&&(end+=length),length=start>end?0:end-start>>>0,start>>>=0;for(var result=Array(length);length>++index;)result[index]=array[index+start];return result}function baseSome(collection,predicate){var result;return baseEach(collection,function(value,index,collection){return result=predicate(value,index,collection),!result}),!!result}function baseValues(object,props){for(var index=-1,length=props.length,result=Array(length);length>++index;)result[index]=object[props[index]];return result}function binaryIndex(array,value,retHighest){var low=0,high=array?array.length:low;if(\"number\"==typeof value&&value===value&&HALF_MAX_ARRAY_LENGTH>=high){for(;high>low;){var mid=low+high>>>1,computed=array[mid];(retHighest?value>=computed:value>computed)?low=mid+1:high=mid}return high}return binaryIndexBy(array,value,identity,retHighest)}function binaryIndexBy(array,value,iteratee,retHighest){value=iteratee(value);for(var low=0,high=array?array.length:0,valIsNaN=value!==value,valIsUndef=value===undefined;high>low;){var mid=floor((low+high)/2),computed=iteratee(array[mid]),isReflexive=computed===computed;if(valIsNaN)var setLow=isReflexive||retHighest;else setLow=valIsUndef?isReflexive&&(retHighest||computed!==undefined):retHighest?value>=computed:value>computed;setLow?low=mid+1:high=mid}return nativeMin(high,MAX_ARRAY_INDEX)}function bindCallback(func,thisArg,argCount){if(\"function\"!=typeof func)return identity;if(thisArg===undefined)return func;switch(argCount){case 1:return function(value){return func.call(thisArg,value)};case 3:return function(value,index,collection){return func.call(thisArg,value,index,collection)};case 4:return function(accumulator,value,index,collection){return func.call(thisArg,accumulator,value,index,collection)};case 5:return function(value,other,key,object,source){return func.call(thisArg,value,other,key,object,source)}}return function(){return func.apply(thisArg,arguments)}}function bufferClone(buffer){return bufferSlice.call(buffer,0)}function createAssigner(assigner){return restParam(function(object,sources){var index=-1,length=null==object?0:sources.length,customizer=length>2&&sources[length-2],guard=length>2&&sources[2],thisArg=length>1&&sources[length-1];for(\"function\"==typeof customizer?(customizer=bindCallback(customizer,thisArg,5),length-=2):(customizer=\"function\"==typeof thisArg?thisArg:null,length-=customizer?1:0),guard&&isIterateeCall(sources[0],sources[1],guard)&&(customizer=3>length?null:customizer,length=1);length>++index;){var source=sources[index];source&&assigner(object,source,customizer)}return object})}function createBaseEach(eachFunc,fromRight){return function(collection,iteratee){var length=collection?getLength(collection):0;if(!isLength(length))return eachFunc(collection,iteratee);for(var index=fromRight?length:-1,iterable=toObject(collection);(fromRight?index--:length>++index)&&iteratee(iterable[index],index,iterable)!==!1;);return collection}}function createBaseFor(fromRight){return function(object,iteratee,keysFunc){for(var iterable=toObject(object),props=keysFunc(object),length=props.length,index=fromRight?length:-1;fromRight?index--:length>++index;){var key=props[index];if(iteratee(iterable[key],key,iterable)===!1)break}return object}}function createFindIndex(fromRight){return function(array,predicate,thisArg){return array&&array.length?(predicate=getCallback(predicate,thisArg,3),baseFindIndex(array,predicate,fromRight)):-1}}function createForEach(arrayFunc,eachFunc){return function(collection,iteratee,thisArg){return\"function\"==typeof iteratee&&thisArg===undefined&&isArray(collection)?arrayFunc(collection,iteratee):eachFunc(collection,bindCallback(iteratee,thisArg,3))}}function equalArrays(array,other,equalFunc,customizer,isLoose,stackA,stackB){var index=-1,arrLength=array.length,othLength=other.length,result=!0;if(arrLength!=othLength&&!(isLoose&&othLength>arrLength))return!1;for(;result&&arrLength>++index;){var arrValue=array[index],othValue=other[index];if(result=undefined,customizer&&(result=isLoose?customizer(othValue,arrValue,index):customizer(arrValue,othValue,index)),result===undefined)if(isLoose)for(var othIndex=othLength;othIndex--&&(othValue=other[othIndex],!(result=arrValue&&arrValue===othValue||equalFunc(arrValue,othValue,customizer,isLoose,stackA,stackB))););else result=arrValue&&arrValue===othValue||equalFunc(arrValue,othValue,customizer,isLoose,stackA,stackB)}return!!result}function equalByTag(object,other,tag){switch(tag){case boolTag:case dateTag:return+object==+other;case errorTag:return object.name==other.name&&object.message==other.message;case numberTag:return object!=+object?other!=+other:0==object?1/object==1/other:object==+other;case regexpTag:case stringTag:return object==other+\"\"}return!1}function equalObjects(object,other,equalFunc,customizer,isLoose,stackA,stackB){var objProps=keys(object),objLength=objProps.length,othProps=keys(other),othLength=othProps.length;if(objLength!=othLength&&!isLoose)return!1;for(var skipCtor=isLoose,index=-1;objLength>++index;){var key=objProps[index],result=isLoose?key in other:hasOwnProperty.call(other,key);if(result){var objValue=object[key],othValue=other[key];result=undefined,customizer&&(result=isLoose?customizer(othValue,objValue,key):customizer(objValue,othValue,key)),result===undefined&&(result=objValue&&objValue===othValue||equalFunc(objValue,othValue,customizer,isLoose,stackA,stackB))}if(!result)return!1;skipCtor||(skipCtor=\"constructor\"==key)}if(!skipCtor){var objCtor=object.constructor,othCtor=other.constructor;if(objCtor!=othCtor&&\"constructor\"in object&&\"constructor\"in other&&!(\"function\"==typeof objCtor&&objCtor instanceof objCtor&&\"function\"==typeof othCtor&&othCtor instanceof othCtor))return!1}return!0}function getCallback(func,thisArg,argCount){var result=lodash.callback||callback;return result=result===callback?baseCallback:result,argCount?result(func,thisArg,argCount):result}function getIndexOf(collection,target,fromIndex){var result=lodash.indexOf||indexOf;return result=result===indexOf?baseIndexOf:result,collection?result(collection,target,fromIndex):result}function initCloneArray(array){var length=array.length,result=new array.constructor(length);return length&&\"string\"==typeof array[0]&&hasOwnProperty.call(array,\"index\")&&(result.index=array.index,result.input=array.input),result}function initCloneObject(object){var Ctor=object.constructor;return\"function\"==typeof Ctor&&Ctor instanceof Ctor||(Ctor=Object),new Ctor}function initCloneByTag(object,tag,isDeep){var Ctor=object.constructor;switch(tag){case arrayBufferTag:return bufferClone(object);case boolTag:case dateTag:return new Ctor(+object);case float32Tag:case float64Tag:case int8Tag:case int16Tag:case int32Tag:case uint8Tag:case uint8ClampedTag:case uint16Tag:case uint32Tag:var buffer=object.buffer;return new Ctor(isDeep?bufferClone(buffer):buffer,object.byteOffset,object.length);case numberTag:case stringTag:return new Ctor(object);case regexpTag:var result=new Ctor(object.source,reFlags.exec(object));result.lastIndex=object.lastIndex}return result}function isIndex(value,length){return value=+value,length=null==length?MAX_SAFE_INTEGER:length,value>-1&&0==value%1&&length>value}function isIterateeCall(value,index,object){if(!isObject(object))return!1;var type=typeof index;if(\"number\"==type)var length=getLength(object),prereq=isLength(length)&&isIndex(index,length);else prereq=\"string\"==type&&index in object;if(prereq){var other=object[index];return value===value?value===other:other!==other}return!1}function isKey(value,object){var type=typeof value;if(\"string\"==type&&reIsPlainProp.test(value)||\"number\"==type)return!0;if(isArray(value))return!1;var result=!reIsDeepProp.test(value);return result||null!=object&&value in toObject(object)}function isLength(value){return\"number\"==typeof value&&value>-1&&0==value%1&&MAX_SAFE_INTEGER>=value}function isStrictComparable(value){return value===value&&(0===value?1/value>0:!isObject(value))}function shimIsPlainObject(value){var Ctor;if(lodash.support,!isObjectLike(value)||objToString.call(value)!=objectTag||!hasOwnProperty.call(value,\"constructor\")&&(Ctor=value.constructor,\"function\"==typeof Ctor&&!(Ctor instanceof Ctor)))return!1;var result;return baseForIn(value,function(subValue,key){result=key}),result===undefined||hasOwnProperty.call(value,result)}function shimKeys(object){for(var props=keysIn(object),propsLength=props.length,length=propsLength&&object.length,support=lodash.support,allowIndexes=length&&isLength(length)&&(isArray(object)||support.nonEnumArgs&&isArguments(object)),index=-1,result=[];propsLength>++index;){var key=props[index];(allowIndexes&&isIndex(key,length)||hasOwnProperty.call(object,key))&&result.push(key)}return result}function toObject(value){return isObject(value)?value:Object(value)}function toPath(value){if(isArray(value))return value;var result=[];return baseToString(value).replace(rePropName,function(match,number,quote,string){result.push(quote?string.replace(reEscapeChar,\"$1\"):number||match)}),result}function indexOf(array,value,fromIndex){var length=array?array.length:0;if(!length)return-1;if(\"number\"==typeof fromIndex)fromIndex=0>fromIndex?nativeMax(length+fromIndex,0):fromIndex;else if(fromIndex){var index=binaryIndex(array,value),other=array[index];return(value===value?value===other:other!==other)?index:-1}return baseIndexOf(array,value,fromIndex||0)}function last(array){var length=array?array.length:0;return length?array[length-1]:undefined}function slice(array,start,end){var length=array?array.length:0;return length?(end&&\"number\"!=typeof end&&isIterateeCall(array,start,end)&&(start=0,end=length),baseSlice(array,start,end)):[]}function unzip(array){for(var index=-1,length=(array&&array.length&&arrayMax(arrayMap(array,getLength)))>>>0,result=Array(length);length>++index;)result[index]=arrayMap(array,baseProperty(index));return result}function includes(collection,target,fromIndex,guard){var length=collection?getLength(collection):0;return isLength(length)||(collection=values(collection),length=collection.length),length?(fromIndex=\"number\"!=typeof fromIndex||guard&&isIterateeCall(target,fromIndex,guard)?0:0>fromIndex?nativeMax(length+fromIndex,0):fromIndex||0,\"string\"==typeof collection||!isArray(collection)&&isString(collection)?length>fromIndex&&collection.indexOf(target,fromIndex)>-1:getIndexOf(collection,target,fromIndex)>-1):!1}function reject(collection,predicate,thisArg){var func=isArray(collection)?arrayFilter:baseFilter;return predicate=getCallback(predicate,thisArg,3),func(collection,function(value,index,collection){return!predicate(value,index,collection)})}function some(collection,predicate,thisArg){var func=isArray(collection)?arraySome:baseSome;return thisArg&&isIterateeCall(collection,predicate,thisArg)&&(predicate=null),(\"function\"!=typeof predicate||thisArg!==undefined)&&(predicate=getCallback(predicate,thisArg,3)),func(collection,predicate)}function restParam(func,start){if(\"function\"!=typeof func)throw new TypeError(FUNC_ERROR_TEXT);return start=nativeMax(start===undefined?func.length-1:+start||0,0),function(){for(var args=arguments,index=-1,length=nativeMax(args.length-start,0),rest=Array(length);length>++index;)rest[index]=args[start+index];switch(start){case 0:return func.call(this,rest);case 1:return func.call(this,args[0],rest);case 2:return func.call(this,args[0],args[1],rest)}var otherArgs=Array(start+1);for(index=-1;start>++index;)otherArgs[index]=args[index];return otherArgs[start]=rest,func.apply(this,otherArgs)}}function clone(value,isDeep,customizer,thisArg){return isDeep&&\"boolean\"!=typeof isDeep&&isIterateeCall(value,isDeep,customizer)?isDeep=!1:\"function\"==typeof isDeep&&(thisArg=customizer,customizer=isDeep,isDeep=!1),customizer=\"function\"==typeof customizer&&bindCallback(customizer,thisArg,1),baseClone(value,isDeep,customizer)}function isArguments(value){var length=isObjectLike(value)?value.length:undefined;return isLength(length)&&objToString.call(value)==argsTag}function isEmpty(value){if(null==value)return!0;var length=getLength(value);return isLength(length)&&(isArray(value)||isString(value)||isArguments(value)||isObjectLike(value)&&isFunction(value.splice))?!length:!keys(value).length}function isObject(value){var type=typeof value;return\"function\"==type||!!value&&\"object\"==type}function isNative(value){return null==value?!1:objToString.call(value)==funcTag?reIsNative.test(fnToString.call(value)):isObjectLike(value)&&reIsHostCtor.test(value)}function isNumber(value){return\"number\"==typeof value||isObjectLike(value)&&objToString.call(value)==numberTag}function isString(value){return\"string\"==typeof value||isObjectLike(value)&&objToString.call(value)==stringTag}function isTypedArray(value){return isObjectLike(value)&&isLength(value.length)&&!!typedArrayTags[objToString.call(value)]}function toPlainObject(value){return baseCopy(value,keysIn(value))}function has(object,path){if(null==object)return!1;var result=hasOwnProperty.call(object,path);return result||isKey(path)||(path=toPath(path),object=1==path.length?object:baseGet(object,baseSlice(path,0,-1)),path=last(path),result=null!=object&&hasOwnProperty.call(object,path)),result}function keysIn(object){if(null==object)return[];isObject(object)||(object=Object(object));var length=object.length;length=length&&isLength(length)&&(isArray(object)||support.nonEnumArgs&&isArguments(object))&&length||0;for(var Ctor=object.constructor,index=-1,isProto=\"function\"==typeof Ctor&&Ctor.prototype===object,result=Array(length),skipIndexes=length>0;length>++index;)result[index]=index+\"\";for(var key in object)skipIndexes&&isIndex(key,length)||\"constructor\"==key&&(isProto||!hasOwnProperty.call(object,key))||result.push(key);return result}function values(object){return baseValues(object,keys(object))}function escapeRegExp(string){return string=baseToString(string),string&&reHasRegExpChars.test(string)?string.replace(reRegExpChars,\"\\\\$&\"):string}function callback(func,thisArg,guard){return guard&&isIterateeCall(func,thisArg,guard)&&(thisArg=null),baseCallback(func,thisArg)}function constant(value){return function(){return value}}function identity(value){return value}function property(path){return isKey(path)?baseProperty(path):basePropertyDeep(path)}var undefined,VERSION=\"3.7.0\",FUNC_ERROR_TEXT=\"Expected a function\",argsTag=\"[object Arguments]\",arrayTag=\"[object Array]\",boolTag=\"[object Boolean]\",dateTag=\"[object Date]\",errorTag=\"[object Error]\",funcTag=\"[object Function]\",mapTag=\"[object Map]\",numberTag=\"[object Number]\",objectTag=\"[object Object]\",regexpTag=\"[object RegExp]\",setTag=\"[object Set]\",stringTag=\"[object String]\",weakMapTag=\"[object WeakMap]\",arrayBufferTag=\"[object ArrayBuffer]\",float32Tag=\"[object Float32Array]\",float64Tag=\"[object Float64Array]\",int8Tag=\"[object Int8Array]\",int16Tag=\"[object Int16Array]\",int32Tag=\"[object Int32Array]\",uint8Tag=\"[object Uint8Array]\",uint8ClampedTag=\"[object Uint8ClampedArray]\",uint16Tag=\"[object Uint16Array]\",uint32Tag=\"[object Uint32Array]\",reIsDeepProp=/\\.|\\[(?:[^[\\]]+|([\"'])(?:(?!\\1)[^\\n\\\\]|\\\\.)*?)\\1\\]/,reIsPlainProp=/^\\w*$/,rePropName=/[^.[\\]]+|\\[(?:(-?\\d+(?:\\.\\d+)?)|([\"'])((?:(?!\\2)[^\\n\\\\]|\\\\.)*?)\\2)\\]/g,reRegExpChars=/[.*+?^${}()|[\\]\\/\\\\]/g,reHasRegExpChars=RegExp(reRegExpChars.source),reEscapeChar=/\\\\(\\\\)?/g,reFlags=/\\w*$/,reIsHostCtor=/^\\[object .+?Constructor\\]$/,typedArrayTags={};typedArrayTags[float32Tag]=typedArrayTags[float64Tag]=typedArrayTags[int8Tag]=typedArrayTags[int16Tag]=typedArrayTags[int32Tag]=typedArrayTags[uint8Tag]=typedArrayTags[uint8ClampedTag]=typedArrayTags[uint16Tag]=typedArrayTags[uint32Tag]=!0,typedArrayTags[argsTag]=typedArrayTags[arrayTag]=typedArrayTags[arrayBufferTag]=typedArrayTags[boolTag]=typedArrayTags[dateTag]=typedArrayTags[errorTag]=typedArrayTags[funcTag]=typedArrayTags[mapTag]=typedArrayTags[numberTag]=typedArrayTags[objectTag]=typedArrayTags[regexpTag]=typedArrayTags[setTag]=typedArrayTags[stringTag]=typedArrayTags[weakMapTag]=!1;var cloneableTags={};cloneableTags[argsTag]=cloneableTags[arrayTag]=cloneableTags[arrayBufferTag]=cloneableTags[boolTag]=cloneableTags[dateTag]=cloneableTags[float32Tag]=cloneableTags[float64Tag]=cloneableTags[int8Tag]=cloneableTags[int16Tag]=cloneableTags[int32Tag]=cloneableTags[numberTag]=cloneableTags[objectTag]=cloneableTags[regexpTag]=cloneableTags[stringTag]=cloneableTags[uint8Tag]=cloneableTags[uint8ClampedTag]=cloneableTags[uint16Tag]=cloneableTags[uint32Tag]=!0,cloneableTags[errorTag]=cloneableTags[funcTag]=cloneableTags[mapTag]=cloneableTags[setTag]=cloneableTags[weakMapTag]=!1;var objectTypes={\"function\":!0,object:!0},freeExports=objectTypes[typeof exports]&&exports&&!exports.nodeType&&exports,freeModule=objectTypes[typeof module]&&module&&!module.nodeType&&module,freeGlobal=freeExports&&freeModule&&\"object\"==typeof global&&global&&global.Object&&global,freeSelf=objectTypes[typeof self]&&self&&self.Object&&self,freeWindow=objectTypes[typeof window]&&window&&window.Object&&window,moduleExports=freeModule&&freeModule.exports===freeExports&&freeExports,root=freeGlobal||freeWindow!==(this&&this.window)&&freeWindow||freeSelf||this,arrayProto=Array.prototype,objectProto=Object.prototype,fnToString=Function.prototype.toString,hasOwnProperty=objectProto.hasOwnProperty,objToString=objectProto.toString,reIsNative=RegExp(\"^\"+escapeRegExp(objToString).replace(/toString|(function).*?(?=\\\\\\()| for .+?(?=\\\\\\])/g,\"$1.*?\")+\"$\"),ArrayBuffer=isNative(ArrayBuffer=root.ArrayBuffer)&&ArrayBuffer,bufferSlice=isNative(bufferSlice=ArrayBuffer&&new ArrayBuffer(0).slice)&&bufferSlice,floor=Math.floor,getOwnPropertySymbols=isNative(getOwnPropertySymbols=Object.getOwnPropertySymbols)&&getOwnPropertySymbols,getPrototypeOf=isNative(getPrototypeOf=Object.getPrototypeOf)&&getPrototypeOf,push=arrayProto.push,preventExtensions=isNative(Object.preventExtensions=Object.preventExtensions)&&preventExtensions,propertyIsEnumerable=objectProto.propertyIsEnumerable,Uint8Array=isNative(Uint8Array=root.Uint8Array)&&Uint8Array,Float64Array=function(){try{var func=isNative(func=root.Float64Array)&&func,result=new func(new ArrayBuffer(10),0,1)&&func}catch(e){}return result}(),nativeAssign=function(){var object={1:0},func=preventExtensions&&isNative(func=Object.assign)&&func;try{func(preventExtensions(object),\"xo\")}catch(e){}return!object[1]&&func}(),nativeIsArray=isNative(nativeIsArray=Array.isArray)&&nativeIsArray,nativeKeys=isNative(nativeKeys=Object.keys)&&nativeKeys,nativeMax=Math.max,nativeMin=Math.min,NEGATIVE_INFINITY=Number.NEGATIVE_INFINITY,MAX_ARRAY_LENGTH=Math.pow(2,32)-1,MAX_ARRAY_INDEX=MAX_ARRAY_LENGTH-1,HALF_MAX_ARRAY_LENGTH=MAX_ARRAY_LENGTH>>>1,FLOAT64_BYTES_PER_ELEMENT=Float64Array?Float64Array.BYTES_PER_ELEMENT:0,MAX_SAFE_INTEGER=Math.pow(2,53)-1,support=lodash.support={};(function(x){var Ctor=function(){this.x=x},props=[];Ctor.prototype={valueOf:x,y:x};for(var key in new Ctor)props.push(key);support.funcDecomp=/\\bthis\\b/.test(function(){return this}),support.funcNames=\"string\"==typeof Function.name;try{support.nonEnumArgs=!propertyIsEnumerable.call(arguments,1)}catch(e){support.nonEnumArgs=!0}})(1,0);var baseAssign=nativeAssign||function(object,source){return null==source?object:baseCopy(source,getSymbols(source),baseCopy(source,keys(source),object))},baseEach=createBaseEach(baseForOwn),baseFor=createBaseFor();bufferSlice||(bufferClone=ArrayBuffer&&Uint8Array?function(buffer){var byteLength=buffer.byteLength,floatLength=Float64Array?floor(byteLength/FLOAT64_BYTES_PER_ELEMENT):0,offset=floatLength*FLOAT64_BYTES_PER_ELEMENT,result=new ArrayBuffer(byteLength);if(floatLength){var view=new Float64Array(result,0,floatLength);view.set(new Float64Array(buffer,0,floatLength))}return byteLength!=offset&&(view=new Uint8Array(result,offset),view.set(new Uint8Array(buffer,offset))),result}:constant(null));var getLength=baseProperty(\"length\"),getSymbols=getOwnPropertySymbols?function(object){return getOwnPropertySymbols(toObject(object))}:constant([]),findLastIndex=createFindIndex(!0),zip=restParam(unzip),forEach=createForEach(arrayEach,baseEach),isArray=nativeIsArray||function(value){return isObjectLike(value)&&isLength(value.length)&&objToString.call(value)==arrayTag},isFunction=baseIsFunction(/x/)||Uint8Array&&!baseIsFunction(Uint8Array)?function(value){return objToString.call(value)==funcTag}:baseIsFunction,isPlainObject=getPrototypeOf?function(value){if(!value||objToString.call(value)!=objectTag)return!1;var valueOf=value.valueOf,objProto=isNative(valueOf)&&(objProto=getPrototypeOf(valueOf))&&getPrototypeOf(objProto);return objProto?value==objProto||getPrototypeOf(value)==objProto:shimIsPlainObject(value)}:shimIsPlainObject,assign=createAssigner(function(object,source,customizer){return customizer?assignWith(object,source,customizer):baseAssign(object,source)}),keys=nativeKeys?function(object){if(object)var Ctor=object.constructor,length=object.length;return\"function\"==typeof Ctor&&Ctor.prototype===object||\"function\"!=typeof object&&isLength(length)?shimKeys(object):isObject(object)?nativeKeys(object):[]}:shimKeys,merge=createAssigner(baseMerge);lodash.assign=assign,lodash.callback=callback,lodash.constant=constant,lodash.forEach=forEach,lodash.keys=keys,lodash.keysIn=keysIn,lodash.merge=merge,lodash.property=property,lodash.reject=reject,lodash.restParam=restParam,lodash.slice=slice,lodash.toPlainObject=toPlainObject,lodash.unzip=unzip,lodash.values=values,lodash.zip=zip,lodash.each=forEach,lodash.extend=assign,lodash.iteratee=callback,lodash.clone=clone,lodash.escapeRegExp=escapeRegExp,lodash.findLastIndex=findLastIndex,lodash.has=has,lodash.identity=identity,lodash.includes=includes,lodash.indexOf=indexOf,lodash.isArguments=isArguments,lodash.isArray=isArray,lodash.isEmpty=isEmpty,lodash.isFunction=isFunction,lodash.isNative=isNative,lodash.isNumber=isNumber,lodash.isObject=isObject,lodash.isPlainObject=isPlainObject,lodash.isString=isString,lodash.isTypedArray=isTypedArray,lodash.last=last,lodash.some=some,lodash.any=some,lodash.contains=includes,lodash.include=includes,lodash.VERSION=VERSION,freeExports&&freeModule?moduleExports?(freeModule.exports=lodash)._=lodash:freeExports._=lodash:root._=lodash\n}).call(this)}).call(this,\"undefined\"!=typeof global?global:\"undefined\"!=typeof self?self:\"undefined\"!=typeof window?window:{})},{}],\"/node_modules/jshint/src/jshint.js\":[function(_dereq_,module,exports){var _=_dereq_(\"../lodash\"),events=_dereq_(\"events\"),vars=_dereq_(\"./vars.js\"),messages=_dereq_(\"./messages.js\"),Lexer=_dereq_(\"./lex.js\").Lexer,reg=_dereq_(\"./reg.js\"),state=_dereq_(\"./state.js\").state,style=_dereq_(\"./style.js\"),options=_dereq_(\"./options.js\"),scopeManager=_dereq_(\"./scope-manager.js\"),JSHINT=function(){\"use strict\";function checkOption(name,t){return name=name.trim(),/^[+-]W\\d{3}$/g.test(name)?!0:-1!==options.validNames.indexOf(name)||\"jslint\"===t.type||_.has(options.removed,name)?!0:(error(\"E001\",t,name),!1)}function isString(obj){return\"[object String]\"===Object.prototype.toString.call(obj)}function isIdentifier(tkn,value){return tkn?tkn.identifier&&tkn.value===value?!0:!1:!1}function isReserved(token){if(!token.reserved)return!1;var meta=token.meta;if(meta&&meta.isFutureReservedWord&&state.inES5()){if(!meta.es5)return!1;if(meta.strictOnly&&!state.option.strict&&!state.isStrict())return!1;if(token.isProperty)return!1}return!0}function supplant(str,data){return str.replace(/\\{([^{}]*)\\}/g,function(a,b){var r=data[b];return\"string\"==typeof r||\"number\"==typeof r?r:a})}function combine(dest,src){Object.keys(src).forEach(function(name){_.has(JSHINT.blacklist,name)||(dest[name]=src[name])})}function processenforceall(){if(state.option.enforceall){for(var enforceopt in options.bool.enforcing)void 0!==state.option[enforceopt]||options.noenforceall[enforceopt]||(state.option[enforceopt]=!0);for(var relaxopt in options.bool.relaxing)void 0===state.option[relaxopt]&&(state.option[relaxopt]=!1)}}function assume(){processenforceall(),state.option.esversion||state.option.moz||(state.option.esversion=state.option.es3?3:state.option.esnext?6:5),state.inES5()&&combine(predefined,vars.ecmaIdentifiers[5]),state.inES6()&&combine(predefined,vars.ecmaIdentifiers[6]),state.option.module&&(state.option.strict===!0&&(state.option.strict=\"global\"),state.inES6()||warning(\"W134\",state.tokens.next,\"module\",6)),state.option.couch&&combine(predefined,vars.couch),state.option.qunit&&combine(predefined,vars.qunit),state.option.rhino&&combine(predefined,vars.rhino),state.option.shelljs&&(combine(predefined,vars.shelljs),combine(predefined,vars.node)),state.option.typed&&combine(predefined,vars.typed),state.option.phantom&&(combine(predefined,vars.phantom),state.option.strict===!0&&(state.option.strict=\"global\")),state.option.prototypejs&&combine(predefined,vars.prototypejs),state.option.node&&(combine(predefined,vars.node),combine(predefined,vars.typed),state.option.strict===!0&&(state.option.strict=\"global\")),state.option.devel&&combine(predefined,vars.devel),state.option.dojo&&combine(predefined,vars.dojo),state.option.browser&&(combine(predefined,vars.browser),combine(predefined,vars.typed)),state.option.browserify&&(combine(predefined,vars.browser),combine(predefined,vars.typed),combine(predefined,vars.browserify),state.option.strict===!0&&(state.option.strict=\"global\")),state.option.nonstandard&&combine(predefined,vars.nonstandard),state.option.jasmine&&combine(predefined,vars.jasmine),state.option.jquery&&combine(predefined,vars.jquery),state.option.mootools&&combine(predefined,vars.mootools),state.option.worker&&combine(predefined,vars.worker),state.option.wsh&&combine(predefined,vars.wsh),state.option.globalstrict&&state.option.strict!==!1&&(state.option.strict=\"global\"),state.option.yui&&combine(predefined,vars.yui),state.option.mocha&&combine(predefined,vars.mocha)}function quit(code,line,chr){var percentage=Math.floor(100*(line/state.lines.length)),message=messages.errors[code].desc;throw{name:\"JSHintError\",line:line,character:chr,message:message+\" (\"+percentage+\"% scanned).\",raw:message,code:code}}function removeIgnoredMessages(){var ignored=state.ignoredLines;_.isEmpty(ignored)||(JSHINT.errors=_.reject(JSHINT.errors,function(err){return ignored[err.line]}))}function warning(code,t,a,b,c,d){var ch,l,w,msg;if(/^W\\d{3}$/.test(code)){if(state.ignored[code])return;msg=messages.warnings[code]}else/E\\d{3}/.test(code)?msg=messages.errors[code]:/I\\d{3}/.test(code)&&(msg=messages.info[code]);return t=t||state.tokens.next||{},\"(end)\"===t.id&&(t=state.tokens.curr),l=t.line||0,ch=t.from||0,w={id:\"(error)\",raw:msg.desc,code:msg.code,evidence:state.lines[l-1]||\"\",line:l,character:ch,scope:JSHINT.scope,a:a,b:b,c:c,d:d},w.reason=supplant(msg.desc,w),JSHINT.errors.push(w),removeIgnoredMessages(),JSHINT.errors.length>=state.option.maxerr&&quit(\"E043\",l,ch),w}function warningAt(m,l,ch,a,b,c,d){return warning(m,{line:l,from:ch},a,b,c,d)}function error(m,t,a,b,c,d){warning(m,t,a,b,c,d)}function errorAt(m,l,ch,a,b,c,d){return error(m,{line:l,from:ch},a,b,c,d)}function addInternalSrc(elem,src){var i;return i={id:\"(internal)\",elem:elem,value:src},JSHINT.internals.push(i),i}function doOption(){var nt=state.tokens.next,body=nt.body.match(/(-\\s+)?[^\\s,:]+(?:\\s*:\\s*(-\\s+)?[^\\s,]+)?/g)||[],predef={};if(\"globals\"===nt.type){body.forEach(function(g,idx){g=g.split(\":\");var key=(g[0]||\"\").trim(),val=(g[1]||\"\").trim();if(\"-\"===key||!key.length){if(idx>0&&idx===body.length-1)return;return error(\"E002\",nt),void 0}\"-\"===key.charAt(0)?(key=key.slice(1),val=!1,JSHINT.blacklist[key]=key,delete predefined[key]):predef[key]=\"true\"===val}),combine(predefined,predef);for(var key in predef)_.has(predef,key)&&(declared[key]=nt)}\"exported\"===nt.type&&body.forEach(function(e,idx){if(!e.length){if(idx>0&&idx===body.length-1)return;return error(\"E002\",nt),void 0}state.funct[\"(scope)\"].addExported(e)}),\"members\"===nt.type&&(membersOnly=membersOnly||{},body.forEach(function(m){var ch1=m.charAt(0),ch2=m.charAt(m.length-1);ch1!==ch2||'\"'!==ch1&&\"'\"!==ch1||(m=m.substr(1,m.length-2).replace('\\\\\"','\"')),membersOnly[m]=!1}));var numvals=[\"maxstatements\",\"maxparams\",\"maxdepth\",\"maxcomplexity\",\"maxerr\",\"maxlen\",\"indent\"];(\"jshint\"===nt.type||\"jslint\"===nt.type)&&(body.forEach(function(g){g=g.split(\":\");var key=(g[0]||\"\").trim(),val=(g[1]||\"\").trim();if(checkOption(key,nt))if(numvals.indexOf(key)>=0)if(\"false\"!==val){if(val=+val,\"number\"!=typeof val||!isFinite(val)||0>=val||Math.floor(val)!==val)return error(\"E032\",nt,g[1].trim()),void 0;state.option[key]=val}else state.option[key]=\"indent\"===key?4:!1;else{if(\"validthis\"===key)return state.funct[\"(global)\"]?void error(\"E009\"):\"true\"!==val&&\"false\"!==val?void error(\"E002\",nt):(state.option.validthis=\"true\"===val,void 0);if(\"quotmark\"!==key)if(\"shadow\"!==key)if(\"unused\"!==key)if(\"latedef\"!==key)if(\"ignore\"!==key)if(\"strict\"!==key){\"module\"===key&&(hasParsedCode(state.funct)||error(\"E055\",state.tokens.next,\"module\"));var esversions={es3:3,es5:5,esnext:6};if(!_.has(esversions,key)){if(\"esversion\"===key){switch(val){case\"5\":state.inES5(!0)&&warning(\"I003\");case\"3\":case\"6\":state.option.moz=!1,state.option.esversion=+val;break;case\"2015\":state.option.moz=!1,state.option.esversion=6;break;default:error(\"E002\",nt)}return hasParsedCode(state.funct)||error(\"E055\",state.tokens.next,\"esversion\"),void 0}var match=/^([+-])(W\\d{3})$/g.exec(key);if(match)return state.ignored[match[2]]=\"-\"===match[1],void 0;var tn;return\"true\"===val||\"false\"===val?(\"jslint\"===nt.type?(tn=options.renamed[key]||key,state.option[tn]=\"true\"===val,void 0!==options.inverted[tn]&&(state.option[tn]=!state.option[tn])):state.option[key]=\"true\"===val,\"newcap\"===key&&(state.option[\"(explicitNewcap)\"]=!0),void 0):(error(\"E002\",nt),void 0)}switch(val){case\"true\":state.option.moz=!1,state.option.esversion=esversions[key];break;case\"false\":state.option.moz||(state.option.esversion=5);break;default:error(\"E002\",nt)}}else switch(val){case\"true\":state.option.strict=!0;break;case\"false\":state.option.strict=!1;break;case\"func\":case\"global\":case\"implied\":state.option.strict=val;break;default:error(\"E002\",nt)}else switch(val){case\"line\":state.ignoredLines[nt.line]=!0,removeIgnoredMessages();break;default:error(\"E002\",nt)}else switch(val){case\"true\":state.option.latedef=!0;break;case\"false\":state.option.latedef=!1;break;case\"nofunc\":state.option.latedef=\"nofunc\";break;default:error(\"E002\",nt)}else switch(val){case\"true\":state.option.unused=!0;break;case\"false\":state.option.unused=!1;break;case\"vars\":case\"strict\":state.option.unused=val;break;default:error(\"E002\",nt)}else switch(val){case\"true\":state.option.shadow=!0;break;case\"outer\":state.option.shadow=\"outer\";break;case\"false\":case\"inner\":state.option.shadow=\"inner\";break;default:error(\"E002\",nt)}else switch(val){case\"true\":case\"false\":state.option.quotmark=\"true\"===val;break;case\"double\":case\"single\":state.option.quotmark=val;break;default:error(\"E002\",nt)}}}),assume())}function peek(p){var t,i=p||0,j=lookahead.length;if(j>i)return lookahead[i];for(;i>=j;)t=lookahead[j],t||(t=lookahead[j]=lex.token()),j+=1;return t||\"(end)\"!==state.tokens.next.id?t:state.tokens.next}function peekIgnoreEOL(){var t,i=0;do t=peek(i++);while(\"(endline)\"===t.id);return t}function advance(id,t){switch(state.tokens.curr.id){case\"(number)\":\".\"===state.tokens.next.id&&warning(\"W005\",state.tokens.curr);break;case\"-\":(\"-\"===state.tokens.next.id||\"--\"===state.tokens.next.id)&&warning(\"W006\");break;case\"+\":(\"+\"===state.tokens.next.id||\"++\"===state.tokens.next.id)&&warning(\"W007\")}for(id&&state.tokens.next.id!==id&&(t?\"(end)\"===state.tokens.next.id?error(\"E019\",t,t.id):error(\"E020\",state.tokens.next,id,t.id,t.line,state.tokens.next.value):(\"(identifier)\"!==state.tokens.next.type||state.tokens.next.value!==id)&&warning(\"W116\",state.tokens.next,id,state.tokens.next.value)),state.tokens.prev=state.tokens.curr,state.tokens.curr=state.tokens.next;;){if(state.tokens.next=lookahead.shift()||lex.token(),state.tokens.next||quit(\"E041\",state.tokens.curr.line),\"(end)\"===state.tokens.next.id||\"(error)\"===state.tokens.next.id)return;if(state.tokens.next.check&&state.tokens.next.check(),state.tokens.next.isSpecial)\"falls through\"===state.tokens.next.type?state.tokens.curr.caseFallsThrough=!0:doOption();else if(\"(endline)\"!==state.tokens.next.id)break}}function isInfix(token){return token.infix||!token.identifier&&!token.template&&!!token.led}function isEndOfExpr(){var curr=state.tokens.curr,next=state.tokens.next;return\";\"===next.id||\"}\"===next.id||\":\"===next.id?!0:isInfix(next)===isInfix(curr)||\"yield\"===curr.id&&state.inMoz()?curr.line!==startLine(next):!1}function isBeginOfExpr(prev){return!prev.left&&\"unary\"!==prev.arity}function expression(rbp,initial){var left,isArray=!1,isObject=!1,isLetExpr=!1;state.nameStack.push(),initial||\"let\"!==state.tokens.next.value||\"(\"!==peek(0).value||(state.inMoz()||warning(\"W118\",state.tokens.next,\"let expressions\"),isLetExpr=!0,state.funct[\"(scope)\"].stack(),advance(\"let\"),advance(\"(\"),state.tokens.prev.fud(),advance(\")\")),\"(end)\"===state.tokens.next.id&&error(\"E006\",state.tokens.curr);var isDangerous=state.option.asi&&state.tokens.prev.line!==startLine(state.tokens.curr)&&_.contains([\"]\",\")\"],state.tokens.prev.id)&&_.contains([\"[\",\"(\"],state.tokens.curr.id);if(isDangerous&&warning(\"W014\",state.tokens.curr,state.tokens.curr.id),advance(),initial&&(state.funct[\"(verb)\"]=state.tokens.curr.value,state.tokens.curr.beginsStmt=!0),initial===!0&&state.tokens.curr.fud)left=state.tokens.curr.fud();else for(state.tokens.curr.nud?left=state.tokens.curr.nud():error(\"E030\",state.tokens.curr,state.tokens.curr.id);(state.tokens.next.lbp>rbp||\"(template)\"===state.tokens.next.type)&&!isEndOfExpr();)isArray=\"Array\"===state.tokens.curr.value,isObject=\"Object\"===state.tokens.curr.value,left&&(left.value||left.first&&left.first.value)&&(\"new\"!==left.value||left.first&&left.first.value&&\".\"===left.first.value)&&(isArray=!1,left.value!==state.tokens.curr.value&&(isObject=!1)),advance(),isArray&&\"(\"===state.tokens.curr.id&&\")\"===state.tokens.next.id&&warning(\"W009\",state.tokens.curr),isObject&&\"(\"===state.tokens.curr.id&&\")\"===state.tokens.next.id&&warning(\"W010\",state.tokens.curr),left&&state.tokens.curr.led?left=state.tokens.curr.led(left):error(\"E033\",state.tokens.curr,state.tokens.curr.id);return isLetExpr&&state.funct[\"(scope)\"].unstack(),state.nameStack.pop(),left}function startLine(token){return token.startLine||token.line}function nobreaknonadjacent(left,right){left=left||state.tokens.curr,right=right||state.tokens.next,state.option.laxbreak||left.line===startLine(right)||warning(\"W014\",right,right.value)}function nolinebreak(t){t=t||state.tokens.curr,t.line!==startLine(state.tokens.next)&&warning(\"E022\",t,t.value)}function nobreakcomma(left,right){left.line!==startLine(right)&&(state.option.laxcomma||(comma.first&&(warning(\"I001\"),comma.first=!1),warning(\"W014\",left,right.value)))}function comma(opts){if(opts=opts||{},opts.peek?nobreakcomma(state.tokens.prev,state.tokens.curr):(nobreakcomma(state.tokens.curr,state.tokens.next),advance(\",\")),state.tokens.next.identifier&&(!opts.property||!state.inES5()))switch(state.tokens.next.value){case\"break\":case\"case\":case\"catch\":case\"continue\":case\"default\":case\"do\":case\"else\":case\"finally\":case\"for\":case\"if\":case\"in\":case\"instanceof\":case\"return\":case\"switch\":case\"throw\":case\"try\":case\"var\":case\"let\":case\"while\":case\"with\":return error(\"E024\",state.tokens.next,state.tokens.next.value),!1}if(\"(punctuator)\"===state.tokens.next.type)switch(state.tokens.next.value){case\"}\":case\"]\":case\",\":if(opts.allowTrailing)return!0;case\")\":return error(\"E024\",state.tokens.next,state.tokens.next.value),!1}return!0}function symbol(s,p){var x=state.syntax[s];return x&&\"object\"==typeof x||(state.syntax[s]=x={id:s,lbp:p,value:s}),x}function delim(s){var x=symbol(s,0);return x.delim=!0,x}function stmt(s,f){var x=delim(s);return x.identifier=x.reserved=!0,x.fud=f,x}function blockstmt(s,f){var x=stmt(s,f);return x.block=!0,x}function reserveName(x){var c=x.id.charAt(0);return(c>=\"a\"&&\"z\">=c||c>=\"A\"&&\"Z\">=c)&&(x.identifier=x.reserved=!0),x}function prefix(s,f){var x=symbol(s,150);return reserveName(x),x.nud=\"function\"==typeof f?f:function(){return this.arity=\"unary\",this.right=expression(150),(\"++\"===this.id||\"--\"===this.id)&&(state.option.plusplus?warning(\"W016\",this,this.id):!this.right||this.right.identifier&&!isReserved(this.right)||\".\"===this.right.id||\"[\"===this.right.id||warning(\"W017\",this),this.right&&this.right.isMetaProperty?error(\"E031\",this):this.right&&this.right.identifier&&state.funct[\"(scope)\"].block.modify(this.right.value,this)),this},x}function type(s,f){var x=delim(s);return x.type=s,x.nud=f,x}function reserve(name,func){var x=type(name,func);return x.identifier=!0,x.reserved=!0,x}function FutureReservedWord(name,meta){var x=type(name,meta&&meta.nud||function(){return this});return meta=meta||{},meta.isFutureReservedWord=!0,x.value=name,x.identifier=!0,x.reserved=!0,x.meta=meta,x}function reservevar(s,v){return reserve(s,function(){return\"function\"==typeof v&&v(this),this})}function infix(s,f,p,w){var x=symbol(s,p);return reserveName(x),x.infix=!0,x.led=function(left){return w||nobreaknonadjacent(state.tokens.prev,state.tokens.curr),\"in\"!==s&&\"instanceof\"!==s||\"!\"!==left.id||warning(\"W018\",left,\"!\"),\"function\"==typeof f?f(left,this):(this.left=left,this.right=expression(p),this)},x}function application(s){var x=symbol(s,42);return x.led=function(left){return nobreaknonadjacent(state.tokens.prev,state.tokens.curr),this.left=left,this.right=doFunction({type:\"arrow\",loneArg:left}),this},x}function relation(s,f){var x=symbol(s,100);return x.led=function(left){nobreaknonadjacent(state.tokens.prev,state.tokens.curr),this.left=left;var right=this.right=expression(100);return isIdentifier(left,\"NaN\")||isIdentifier(right,\"NaN\")?warning(\"W019\",this):f&&f.apply(this,[left,right]),left&&right||quit(\"E041\",state.tokens.curr.line),\"!\"===left.id&&warning(\"W018\",left,\"!\"),\"!\"===right.id&&warning(\"W018\",right,\"!\"),this},x}function isPoorRelation(node){return node&&(\"(number)\"===node.type&&0===+node.value||\"(string)\"===node.type&&\"\"===node.value||\"null\"===node.type&&!state.option.eqnull||\"true\"===node.type||\"false\"===node.type||\"undefined\"===node.type)}function isTypoTypeof(left,right,state){var values;return state.option.notypeof?!1:left&&right?(values=state.inES6()?typeofValues.es6:typeofValues.es3,\"(identifier)\"===right.type&&\"typeof\"===right.value&&\"(string)\"===left.type?!_.contains(values,left.value):!1):!1}function isGlobalEval(left,state){var isGlobal=!1;return\"this\"===left.type&&null===state.funct[\"(context)\"]?isGlobal=!0:\"(identifier)\"===left.type&&(state.option.node&&\"global\"===left.value?isGlobal=!0:!state.option.browser||\"window\"!==left.value&&\"document\"!==left.value||(isGlobal=!0)),isGlobal}function findNativePrototype(left){function walkPrototype(obj){return\"object\"==typeof obj?\"prototype\"===obj.right?obj:walkPrototype(obj.left):void 0}function walkNative(obj){for(;!obj.identifier&&\"object\"==typeof obj.left;)obj=obj.left;return obj.identifier&&natives.indexOf(obj.value)>=0?obj.value:void 0}var natives=[\"Array\",\"ArrayBuffer\",\"Boolean\",\"Collator\",\"DataView\",\"Date\",\"DateTimeFormat\",\"Error\",\"EvalError\",\"Float32Array\",\"Float64Array\",\"Function\",\"Infinity\",\"Intl\",\"Int16Array\",\"Int32Array\",\"Int8Array\",\"Iterator\",\"Number\",\"NumberFormat\",\"Object\",\"RangeError\",\"ReferenceError\",\"RegExp\",\"StopIteration\",\"String\",\"SyntaxError\",\"TypeError\",\"Uint16Array\",\"Uint32Array\",\"Uint8Array\",\"Uint8ClampedArray\",\"URIError\"],prototype=walkPrototype(left);return prototype?walkNative(prototype):void 0}function checkLeftSideAssign(left,assignToken,options){var allowDestructuring=options&&options.allowDestructuring;if(assignToken=assignToken||left,state.option.freeze){var nativeObject=findNativePrototype(left);nativeObject&&warning(\"W121\",left,nativeObject)}return left.identifier&&!left.isMetaProperty&&state.funct[\"(scope)\"].block.reassign(left.value,left),\".\"===left.id?((!left.left||\"arguments\"===left.left.value&&!state.isStrict())&&warning(\"E031\",assignToken),state.nameStack.set(state.tokens.prev),!0):\"{\"===left.id||\"[\"===left.id?(allowDestructuring&&state.tokens.curr.left.destructAssign?state.tokens.curr.left.destructAssign.forEach(function(t){t.id&&state.funct[\"(scope)\"].block.modify(t.id,t.token)}):\"{\"!==left.id&&left.left?\"arguments\"!==left.left.value||state.isStrict()||warning(\"E031\",assignToken):warning(\"E031\",assignToken),\"[\"===left.id&&state.nameStack.set(left.right),!0):left.isMetaProperty?(error(\"E031\",assignToken),!0):left.identifier&&!isReserved(left)?(\"exception\"===state.funct[\"(scope)\"].labeltype(left.value)&&warning(\"W022\",left),state.nameStack.set(left),!0):(left===state.syntax[\"function\"]&&warning(\"W023\",state.tokens.curr),!1)}function assignop(s,f,p){var x=infix(s,\"function\"==typeof f?f:function(left,that){return that.left=left,left&&checkLeftSideAssign(left,that,{allowDestructuring:!0})?(that.right=expression(10),that):(error(\"E031\",that),void 0)},p);return x.exps=!0,x.assign=!0,x}function bitwise(s,f,p){var x=symbol(s,p);return reserveName(x),x.led=\"function\"==typeof f?f:function(left){return state.option.bitwise&&warning(\"W016\",this,this.id),this.left=left,this.right=expression(p),this},x}function bitwiseassignop(s){return assignop(s,function(left,that){return state.option.bitwise&&warning(\"W016\",that,that.id),left&&checkLeftSideAssign(left,that)?(that.right=expression(10),that):(error(\"E031\",that),void 0)},20)}function suffix(s){var x=symbol(s,150);return x.led=function(left){return state.option.plusplus?warning(\"W016\",this,this.id):left.identifier&&!isReserved(left)||\".\"===left.id||\"[\"===left.id||warning(\"W017\",this),left.isMetaProperty?error(\"E031\",this):left&&left.identifier&&state.funct[\"(scope)\"].block.modify(left.value,left),this.left=left,this},x}function optionalidentifier(fnparam,prop,preserve){if(state.tokens.next.identifier){preserve||advance();var curr=state.tokens.curr,val=state.tokens.curr.value;return isReserved(curr)?prop&&state.inES5()?val:fnparam&&\"undefined\"===val?val:(warning(\"W024\",state.tokens.curr,state.tokens.curr.id),val):val}}function identifier(fnparam,prop){var i=optionalidentifier(fnparam,prop,!1);if(i)return i;if(\"...\"===state.tokens.next.value){if(state.inES6(!0)||warning(\"W119\",state.tokens.next,\"spread/rest operator\",\"6\"),advance(),checkPunctuator(state.tokens.next,\"...\"))for(warning(\"E024\",state.tokens.next,\"...\");checkPunctuator(state.tokens.next,\"...\");)advance();return state.tokens.next.identifier?identifier(fnparam,prop):(warning(\"E024\",state.tokens.curr,\"...\"),void 0)}error(\"E030\",state.tokens.next,state.tokens.next.value),\";\"!==state.tokens.next.id&&advance()}function reachable(controlToken){var t,i=0;if(\";\"===state.tokens.next.id&&!controlToken.inBracelessBlock)for(;;){do t=peek(i),i+=1;while(\"(end)\"!==t.id&&\"(comment)\"===t.id);if(t.reach)return;if(\"(endline)\"!==t.id){if(\"function\"===t.id){state.option.latedef===!0&&warning(\"W026\",t);break}warning(\"W027\",t,t.value,controlToken.value);break}}}function parseFinalSemicolon(){if(\";\"!==state.tokens.next.id){if(state.tokens.next.isUnclosed)return advance();var sameLine=startLine(state.tokens.next)===state.tokens.curr.line&&\"(end)\"!==state.tokens.next.id,blockEnd=checkPunctuator(state.tokens.next,\"}\");sameLine&&!blockEnd?errorAt(\"E058\",state.tokens.curr.line,state.tokens.curr.character):state.option.asi||(blockEnd&&!state.option.lastsemic||!sameLine)&&warningAt(\"W033\",state.tokens.curr.line,state.tokens.curr.character)}else advance(\";\")}function statement(){var r,i=indent,t=state.tokens.next,hasOwnScope=!1;if(\";\"===t.id)return advance(\";\"),void 0;var res=isReserved(t);if(res&&t.meta&&t.meta.isFutureReservedWord&&\":\"===peek().id&&(warning(\"W024\",t,t.id),res=!1),t.identifier&&!res&&\":\"===peek().id&&(advance(),advance(\":\"),hasOwnScope=!0,state.funct[\"(scope)\"].stack(),state.funct[\"(scope)\"].block.addBreakLabel(t.value,{token:state.tokens.curr}),state.tokens.next.labelled||\"{\"===state.tokens.next.value||warning(\"W028\",state.tokens.next,t.value,state.tokens.next.value),state.tokens.next.label=t.value,t=state.tokens.next),\"{\"===t.id){var iscase=\"case\"===state.funct[\"(verb)\"]&&\":\"===state.tokens.curr.value;return block(!0,!0,!1,!1,iscase),void 0}return r=expression(0,!0),!r||r.identifier&&\"function\"===r.value||\"(punctuator)\"===r.type&&r.left&&r.left.identifier&&\"function\"===r.left.value||state.isStrict()||\"global\"!==state.option.strict||warning(\"E007\"),t.block||(state.option.expr||r&&r.exps?state.option.nonew&&r&&r.left&&\"(\"===r.id&&\"new\"===r.left.id&&warning(\"W031\",t):warning(\"W030\",state.tokens.curr),parseFinalSemicolon()),indent=i,hasOwnScope&&state.funct[\"(scope)\"].unstack(),r}function statements(){for(var p,a=[];!state.tokens.next.reach&&\"(end)\"!==state.tokens.next.id;)\";\"===state.tokens.next.id?(p=peek(),(!p||\"(\"!==p.id&&\"[\"!==p.id)&&warning(\"W032\"),advance(\";\")):a.push(statement());return a}function directives(){for(var i,p,pn;\"(string)\"===state.tokens.next.id;){if(p=peek(0),\"(endline)\"===p.id){i=1;do pn=peek(i++);while(\"(endline)\"===pn.id);if(\";\"===pn.id)p=pn;else{if(\"[\"===pn.value||\".\"===pn.value)break;state.option.asi&&\"(\"!==pn.value||warning(\"W033\",state.tokens.next)}}else{if(\".\"===p.id||\"[\"===p.id)break;\";\"!==p.id&&warning(\"W033\",p)}advance();var directive=state.tokens.curr.value;(state.directive[directive]||\"use strict\"===directive&&\"implied\"===state.option.strict)&&warning(\"W034\",state.tokens.curr,directive),state.directive[directive]=!0,\";\"===p.id&&advance(\";\")}state.isStrict()&&(state.option[\"(explicitNewcap)\"]||(state.option.newcap=!0),state.option.undef=!0)}function block(ordinary,stmt,isfunc,isfatarrow,iscase){var a,m,t,line,d,b=inblock,old_indent=indent;inblock=ordinary,t=state.tokens.next;var metrics=state.funct[\"(metrics)\"];if(metrics.nestedBlockDepth+=1,metrics.verifyMaxNestedBlockDepthPerFunction(),\"{\"===state.tokens.next.id){if(advance(\"{\"),state.funct[\"(scope)\"].stack(),line=state.tokens.curr.line,\"}\"!==state.tokens.next.id){for(indent+=state.option.indent;!ordinary&&state.tokens.next.from>indent;)indent+=state.option.indent;if(isfunc){m={};for(d in state.directive)_.has(state.directive,d)&&(m[d]=state.directive[d]);directives(),state.option.strict&&state.funct[\"(context)\"][\"(global)\"]&&(m[\"use strict\"]||state.isStrict()||warning(\"E007\"))}a=statements(),metrics.statementCount+=a.length,indent-=state.option.indent}advance(\"}\",t),isfunc&&(state.funct[\"(scope)\"].validateParams(),m&&(state.directive=m)),state.funct[\"(scope)\"].unstack(),indent=old_indent}else if(ordinary)state.funct[\"(noblockscopedvar)\"]=\"for\"!==state.tokens.next.id,state.funct[\"(scope)\"].stack(),(!stmt||state.option.curly)&&warning(\"W116\",state.tokens.next,\"{\",state.tokens.next.value),state.tokens.next.inBracelessBlock=!0,indent+=state.option.indent,a=[statement()],indent-=state.option.indent,state.funct[\"(scope)\"].unstack(),delete state.funct[\"(noblockscopedvar)\"];else if(isfunc){if(state.funct[\"(scope)\"].stack(),m={},!stmt||isfatarrow||state.inMoz()||error(\"W118\",state.tokens.curr,\"function closure expressions\"),!stmt)for(d in state.directive)_.has(state.directive,d)&&(m[d]=state.directive[d]);expression(10),state.option.strict&&state.funct[\"(context)\"][\"(global)\"]&&(m[\"use strict\"]||state.isStrict()||warning(\"E007\")),state.funct[\"(scope)\"].unstack()}else error(\"E021\",state.tokens.next,\"{\",state.tokens.next.value);switch(state.funct[\"(verb)\"]){case\"break\":case\"continue\":case\"return\":case\"throw\":if(iscase)break;default:state.funct[\"(verb)\"]=null}return inblock=b,!ordinary||!state.option.noempty||a&&0!==a.length||warning(\"W035\",state.tokens.prev),metrics.nestedBlockDepth-=1,a}function countMember(m){membersOnly&&\"boolean\"!=typeof membersOnly[m]&&warning(\"W036\",state.tokens.curr,m),\"number\"==typeof member[m]?member[m]+=1:member[m]=1}function comprehensiveArrayExpression(){var res={};res.exps=!0,state.funct[\"(comparray)\"].stack();var reversed=!1;return\"for\"!==state.tokens.next.value&&(reversed=!0,state.inMoz()||warning(\"W116\",state.tokens.next,\"for\",state.tokens.next.value),state.funct[\"(comparray)\"].setState(\"use\"),res.right=expression(10)),advance(\"for\"),\"each\"===state.tokens.next.value&&(advance(\"each\"),state.inMoz()||warning(\"W118\",state.tokens.curr,\"for each\")),advance(\"(\"),state.funct[\"(comparray)\"].setState(\"define\"),res.left=expression(130),_.contains([\"in\",\"of\"],state.tokens.next.value)?advance():error(\"E045\",state.tokens.curr),state.funct[\"(comparray)\"].setState(\"generate\"),expression(10),advance(\")\"),\"if\"===state.tokens.next.value&&(advance(\"if\"),advance(\"(\"),state.funct[\"(comparray)\"].setState(\"filter\"),res.filter=expression(10),advance(\")\")),reversed||(state.funct[\"(comparray)\"].setState(\"use\"),res.right=expression(10)),advance(\"]\"),state.funct[\"(comparray)\"].unstack(),res}function isMethod(){return state.funct[\"(statement)\"]&&\"class\"===state.funct[\"(statement)\"].type||state.funct[\"(context)\"]&&\"class\"===state.funct[\"(context)\"][\"(verb)\"]}function isPropertyName(token){return token.identifier||\"(string)\"===token.id||\"(number)\"===token.id}function propertyName(preserveOrToken){var id,preserve=!0;return\"object\"==typeof preserveOrToken?id=preserveOrToken:(preserve=preserveOrToken,id=optionalidentifier(!1,!0,preserve)),id?\"object\"==typeof id&&(\"(string)\"===id.id||\"(identifier)\"===id.id?id=id.value:\"(number)\"===id.id&&(id=\"\"+id.value)):\"(string)\"===state.tokens.next.id?(id=state.tokens.next.value,preserve||advance()):\"(number)\"===state.tokens.next.id&&(id=\"\"+state.tokens.next.value,preserve||advance()),\"hasOwnProperty\"===id&&warning(\"W001\"),id}function functionparams(options){function addParam(addParamArgs){state.funct[\"(scope)\"].addParam.apply(state.funct[\"(scope)\"],addParamArgs)}var next,ident,t,paramsIds=[],tokens=[],pastDefault=!1,pastRest=!1,arity=0,loneArg=options&&options.loneArg;if(loneArg&&loneArg.identifier===!0)return state.funct[\"(scope)\"].addParam(loneArg.value,loneArg),{arity:1,params:[loneArg.value]};if(next=state.tokens.next,options&&options.parsedOpening||advance(\"(\"),\")\"===state.tokens.next.id)return advance(\")\"),void 0;for(;;){arity++;var currentParams=[];if(_.contains([\"{\",\"[\"],state.tokens.next.id)){tokens=destructuringPattern();for(t in tokens)t=tokens[t],t.id&&(paramsIds.push(t.id),currentParams.push([t.id,t.token]))}else if(checkPunctuator(state.tokens.next,\"...\")&&(pastRest=!0),ident=identifier(!0))paramsIds.push(ident),currentParams.push([ident,state.tokens.curr]);else for(;!checkPunctuators(state.tokens.next,[\",\",\")\"]);)advance();if(pastDefault&&\"=\"!==state.tokens.next.id&&error(\"W138\",state.tokens.current),\"=\"===state.tokens.next.id&&(state.inES6()||warning(\"W119\",state.tokens.next,\"default parameters\",\"6\"),advance(\"=\"),pastDefault=!0,expression(10)),currentParams.forEach(addParam),\",\"!==state.tokens.next.id)return advance(\")\",next),{arity:arity,params:paramsIds};pastRest&&warning(\"W131\",state.tokens.next),comma()}}function functor(name,token,overwrites){var funct={\"(name)\":name,\"(breakage)\":0,\"(loopage)\":0,\"(tokens)\":{},\"(properties)\":{},\"(catch)\":!1,\"(global)\":!1,\"(line)\":null,\"(character)\":null,\"(metrics)\":null,\"(statement)\":null,\"(context)\":null,\"(scope)\":null,\"(comparray)\":null,\"(generator)\":null,\"(arrow)\":null,\"(params)\":null};return token&&_.extend(funct,{\"(line)\":token.line,\"(character)\":token.character,\"(metrics)\":createMetrics(token)}),_.extend(funct,overwrites),funct[\"(context)\"]&&(funct[\"(scope)\"]=funct[\"(context)\"][\"(scope)\"],funct[\"(comparray)\"]=funct[\"(context)\"][\"(comparray)\"]),funct}function isFunctor(token){return\"(scope)\"in token}function hasParsedCode(funct){return funct[\"(global)\"]&&!funct[\"(verb)\"]}function doTemplateLiteral(left){function end(){if(state.tokens.curr.template&&state.tokens.curr.tail&&state.tokens.curr.context===ctx)return!0;var complete=state.tokens.next.template&&state.tokens.next.tail&&state.tokens.next.context===ctx;return complete&&advance(),complete||state.tokens.next.isUnclosed}var ctx=this.context,noSubst=this.noSubst,depth=this.depth;if(!noSubst)for(;!end();)!state.tokens.next.template||state.tokens.next.depth>depth?expression(0):advance();return{id:\"(template)\",type:\"(template)\",tag:left}}function doFunction(options){var f,token,name,statement,classExprBinding,isGenerator,isArrow,ignoreLoopFunc,oldOption=state.option,oldIgnored=state.ignored;options&&(name=options.name,statement=options.statement,classExprBinding=options.classExprBinding,isGenerator=\"generator\"===options.type,isArrow=\"arrow\"===options.type,ignoreLoopFunc=options.ignoreLoopFunc),state.option=Object.create(state.option),state.ignored=Object.create(state.ignored),state.funct=functor(name||state.nameStack.infer(),state.tokens.next,{\"(statement)\":statement,\"(context)\":state.funct,\"(arrow)\":isArrow,\"(generator)\":isGenerator}),f=state.funct,token=state.tokens.curr,token.funct=state.funct,functions.push(state.funct),state.funct[\"(scope)\"].stack(\"functionouter\");var internallyAccessibleName=name||classExprBinding;internallyAccessibleName&&state.funct[\"(scope)\"].block.add(internallyAccessibleName,classExprBinding?\"class\":\"function\",state.tokens.curr,!1),state.funct[\"(scope)\"].stack(\"functionparams\");var paramsInfo=functionparams(options);return paramsInfo?(state.funct[\"(params)\"]=paramsInfo.params,state.funct[\"(metrics)\"].arity=paramsInfo.arity,state.funct[\"(metrics)\"].verifyMaxParametersPerFunction()):state.funct[\"(metrics)\"].arity=0,isArrow&&(state.inES6(!0)||warning(\"W119\",state.tokens.curr,\"arrow function syntax (=>)\",\"6\"),options.loneArg||advance(\"=>\")),block(!1,!0,!0,isArrow),!state.option.noyield&&isGenerator&&\"yielded\"!==state.funct[\"(generator)\"]&&warning(\"W124\",state.tokens.curr),state.funct[\"(metrics)\"].verifyMaxStatementsPerFunction(),state.funct[\"(metrics)\"].verifyMaxComplexityPerFunction(),state.funct[\"(unusedOption)\"]=state.option.unused,state.option=oldOption,state.ignored=oldIgnored,state.funct[\"(last)\"]=state.tokens.curr.line,state.funct[\"(lastcharacter)\"]=state.tokens.curr.character,state.funct[\"(scope)\"].unstack(),state.funct[\"(scope)\"].unstack(),state.funct=state.funct[\"(context)\"],ignoreLoopFunc||state.option.loopfunc||!state.funct[\"(loopage)\"]||f[\"(isCapturing)\"]&&warning(\"W083\",token),f}function createMetrics(functionStartToken){return{statementCount:0,nestedBlockDepth:-1,ComplexityCount:1,arity:0,verifyMaxStatementsPerFunction:function(){state.option.maxstatements&&this.statementCount>state.option.maxstatements&&warning(\"W071\",functionStartToken,this.statementCount)\n},verifyMaxParametersPerFunction:function(){_.isNumber(state.option.maxparams)&&this.arity>state.option.maxparams&&warning(\"W072\",functionStartToken,this.arity)},verifyMaxNestedBlockDepthPerFunction:function(){state.option.maxdepth&&this.nestedBlockDepth>0&&this.nestedBlockDepth===state.option.maxdepth+1&&warning(\"W073\",null,this.nestedBlockDepth)},verifyMaxComplexityPerFunction:function(){var max=state.option.maxcomplexity,cc=this.ComplexityCount;max&&cc>max&&warning(\"W074\",functionStartToken,cc)}}}function increaseComplexityCount(){state.funct[\"(metrics)\"].ComplexityCount+=1}function checkCondAssignment(expr){var id,paren;switch(expr&&(id=expr.id,paren=expr.paren,\",\"===id&&(expr=expr.exprs[expr.exprs.length-1])&&(id=expr.id,paren=paren||expr.paren)),id){case\"=\":case\"+=\":case\"-=\":case\"*=\":case\"%=\":case\"&=\":case\"|=\":case\"^=\":case\"/=\":paren||state.option.boss||warning(\"W084\")}}function checkProperties(props){if(state.inES5())for(var name in props)props[name]&&props[name].setterToken&&!props[name].getterToken&&warning(\"W078\",props[name].setterToken)}function metaProperty(name,c){if(checkPunctuator(state.tokens.next,\".\")){var left=state.tokens.curr.id;advance(\".\");var id=identifier();return state.tokens.curr.isMetaProperty=!0,name!==id?error(\"E057\",state.tokens.prev,left,id):c(),state.tokens.curr}}function destructuringPattern(options){var isAssignment=options&&options.assignment;return state.inES6()||warning(\"W104\",state.tokens.curr,isAssignment?\"destructuring assignment\":\"destructuring binding\",\"6\"),destructuringPatternRecursive(options)}function destructuringPatternRecursive(options){var ids,identifiers=[],openingParsed=options&&options.openingParsed,isAssignment=options&&options.assignment,recursiveOptions=isAssignment?{assignment:isAssignment}:null,firstToken=openingParsed?state.tokens.curr:state.tokens.next,nextInnerDE=function(){var ident;if(checkPunctuators(state.tokens.next,[\"[\",\"{\"])){ids=destructuringPatternRecursive(recursiveOptions);for(var id in ids)id=ids[id],identifiers.push({id:id.id,token:id.token})}else if(checkPunctuator(state.tokens.next,\",\"))identifiers.push({id:null,token:state.tokens.curr});else{if(!checkPunctuator(state.tokens.next,\"(\")){var is_rest=checkPunctuator(state.tokens.next,\"...\");if(isAssignment){var identifierToken=is_rest?peek(0):state.tokens.next;identifierToken.identifier||warning(\"E030\",identifierToken,identifierToken.value);var assignTarget=expression(155);assignTarget&&(checkLeftSideAssign(assignTarget),assignTarget.identifier&&(ident=assignTarget.value))}else ident=identifier();return ident&&identifiers.push({id:ident,token:state.tokens.curr}),is_rest}advance(\"(\"),nextInnerDE(),advance(\")\")}return!1},assignmentProperty=function(){var id;checkPunctuator(state.tokens.next,\"[\")?(advance(\"[\"),expression(10),advance(\"]\"),advance(\":\"),nextInnerDE()):\"(string)\"===state.tokens.next.id||\"(number)\"===state.tokens.next.id?(advance(),advance(\":\"),nextInnerDE()):(id=identifier(),checkPunctuator(state.tokens.next,\":\")?(advance(\":\"),nextInnerDE()):id&&(isAssignment&&checkLeftSideAssign(state.tokens.curr),identifiers.push({id:id,token:state.tokens.curr})))};if(checkPunctuator(firstToken,\"[\")){openingParsed||advance(\"[\"),checkPunctuator(state.tokens.next,\"]\")&&warning(\"W137\",state.tokens.curr);for(var element_after_rest=!1;!checkPunctuator(state.tokens.next,\"]\");)nextInnerDE()&&!element_after_rest&&checkPunctuator(state.tokens.next,\",\")&&(warning(\"W130\",state.tokens.next),element_after_rest=!0),checkPunctuator(state.tokens.next,\"=\")&&(checkPunctuator(state.tokens.prev,\"...\")?advance(\"]\"):advance(\"=\"),\"undefined\"===state.tokens.next.id&&warning(\"W080\",state.tokens.prev,state.tokens.prev.value),expression(10)),checkPunctuator(state.tokens.next,\"]\")||advance(\",\");advance(\"]\")}else if(checkPunctuator(firstToken,\"{\")){for(openingParsed||advance(\"{\"),checkPunctuator(state.tokens.next,\"}\")&&warning(\"W137\",state.tokens.curr);!checkPunctuator(state.tokens.next,\"}\")&&(assignmentProperty(),checkPunctuator(state.tokens.next,\"=\")&&(advance(\"=\"),\"undefined\"===state.tokens.next.id&&warning(\"W080\",state.tokens.prev,state.tokens.prev.value),expression(10)),checkPunctuator(state.tokens.next,\"}\")||(advance(\",\"),!checkPunctuator(state.tokens.next,\"}\"))););advance(\"}\")}return identifiers}function destructuringPatternMatch(tokens,value){var first=value.first;first&&_.zip(tokens,Array.isArray(first)?first:[first]).forEach(function(val){var token=val[0],value=val[1];token&&value?token.first=value:token&&token.first&&!value&&warning(\"W080\",token.first,token.first.value)})}function blockVariableStatement(type,statement,context){var tokens,lone,value,letblock,prefix=context&&context.prefix,inexport=context&&context.inexport,isLet=\"let\"===type,isConst=\"const\"===type;for(state.inES6()||warning(\"W104\",state.tokens.curr,type,\"6\"),isLet&&\"(\"===state.tokens.next.value?(state.inMoz()||warning(\"W118\",state.tokens.next,\"let block\"),advance(\"(\"),state.funct[\"(scope)\"].stack(),letblock=!0):state.funct[\"(noblockscopedvar)\"]&&error(\"E048\",state.tokens.curr,isConst?\"Const\":\"Let\"),statement.first=[];;){var names=[];_.contains([\"{\",\"[\"],state.tokens.next.value)?(tokens=destructuringPattern(),lone=!1):(tokens=[{id:identifier(),token:state.tokens.curr}],lone=!0),!prefix&&isConst&&\"=\"!==state.tokens.next.id&&warning(\"E012\",state.tokens.curr,state.tokens.curr.value);for(var t in tokens)tokens.hasOwnProperty(t)&&(t=tokens[t],state.funct[\"(scope)\"].block.isGlobal()&&predefined[t.id]===!1&&warning(\"W079\",t.token,t.id),t.id&&!state.funct[\"(noblockscopedvar)\"]&&(state.funct[\"(scope)\"].addlabel(t.id,{type:type,token:t.token}),names.push(t.token),lone&&inexport&&state.funct[\"(scope)\"].setExported(t.token.value,t.token)));if(\"=\"===state.tokens.next.id&&(advance(\"=\"),prefix||\"undefined\"!==state.tokens.next.id||warning(\"W080\",state.tokens.prev,state.tokens.prev.value),!prefix&&\"=\"===peek(0).id&&state.tokens.next.identifier&&warning(\"W120\",state.tokens.next,state.tokens.next.value),value=expression(prefix?120:10),lone?tokens[0].first=value:destructuringPatternMatch(names,value)),statement.first=statement.first.concat(names),\",\"!==state.tokens.next.id)break;comma()}return letblock&&(advance(\")\"),block(!0,!0),statement.block=!0,state.funct[\"(scope)\"].unstack()),statement}function classdef(isStatement){return state.inES6()||warning(\"W104\",state.tokens.curr,\"class\",\"6\"),isStatement?(this.name=identifier(),state.funct[\"(scope)\"].addlabel(this.name,{type:\"class\",token:state.tokens.curr})):state.tokens.next.identifier&&\"extends\"!==state.tokens.next.value?(this.name=identifier(),this.namedExpr=!0):this.name=state.nameStack.infer(),classtail(this),this}function classtail(c){var wasInClassBody=state.inClassBody;\"extends\"===state.tokens.next.value&&(advance(\"extends\"),c.heritage=expression(10)),state.inClassBody=!0,advance(\"{\"),c.body=classbody(c),advance(\"}\"),state.inClassBody=wasInClassBody}function classbody(c){for(var name,isStatic,isGenerator,getset,computed,props=Object.create(null),staticProps=Object.create(null),i=0;\"}\"!==state.tokens.next.id;++i)if(name=state.tokens.next,isStatic=!1,isGenerator=!1,getset=null,\";\"!==name.id){if(\"*\"===name.id&&(isGenerator=!0,advance(\"*\"),name=state.tokens.next),\"[\"===name.id)name=computedPropertyName(),computed=!0;else{if(!isPropertyName(name)){warning(\"W052\",state.tokens.next,state.tokens.next.value||state.tokens.next.type),advance();continue}advance(),computed=!1,name.identifier&&\"static\"===name.value&&(checkPunctuator(state.tokens.next,\"*\")&&(isGenerator=!0,advance(\"*\")),(isPropertyName(state.tokens.next)||\"[\"===state.tokens.next.id)&&(computed=\"[\"===state.tokens.next.id,isStatic=!0,name=state.tokens.next,\"[\"===state.tokens.next.id?name=computedPropertyName():advance())),!name.identifier||\"get\"!==name.value&&\"set\"!==name.value||(isPropertyName(state.tokens.next)||\"[\"===state.tokens.next.id)&&(computed=\"[\"===state.tokens.next.id,getset=name,name=state.tokens.next,\"[\"===state.tokens.next.id?name=computedPropertyName():advance())}if(!checkPunctuator(state.tokens.next,\"(\")){for(error(\"E054\",state.tokens.next,state.tokens.next.value);\"}\"!==state.tokens.next.id&&!checkPunctuator(state.tokens.next,\"(\");)advance();\"(\"!==state.tokens.next.value&&doFunction({statement:c})}if(computed||(getset?saveAccessor(getset.value,isStatic?staticProps:props,name.value,name,!0,isStatic):(\"constructor\"===name.value?state.nameStack.set(c):state.nameStack.set(name),saveProperty(isStatic?staticProps:props,name.value,name,!0,isStatic))),getset&&\"constructor\"===name.value){var propDesc=\"get\"===getset.value?\"class getter method\":\"class setter method\";error(\"E049\",name,propDesc,\"constructor\")}else\"prototype\"===name.value&&error(\"E049\",name,\"class method\",\"prototype\");propertyName(name),doFunction({statement:c,type:isGenerator?\"generator\":null,classExprBinding:c.namedExpr?c.name:null})}else warning(\"W032\"),advance(\";\");checkProperties(props)}function saveProperty(props,name,tkn,isClass,isStatic){var msg=[\"key\",\"class method\",\"static class method\"];msg=msg[(isClass||!1)+(isStatic||!1)],tkn.identifier&&(name=tkn.value),props[name]&&\"__proto__\"!==name?warning(\"W075\",state.tokens.next,msg,name):props[name]=Object.create(null),props[name].basic=!0,props[name].basictkn=tkn}function saveAccessor(accessorType,props,name,tkn,isClass,isStatic){var flagName=\"get\"===accessorType?\"getterToken\":\"setterToken\",msg=\"\";isClass?(isStatic&&(msg+=\"static \"),msg+=accessorType+\"ter method\"):msg=\"key\",state.tokens.curr.accessorType=accessorType,state.nameStack.set(tkn),props[name]?(props[name].basic||props[name][flagName])&&\"__proto__\"!==name&&warning(\"W075\",state.tokens.next,msg,name):props[name]=Object.create(null),props[name][flagName]=tkn}function computedPropertyName(){advance(\"[\"),state.inES6()||warning(\"W119\",state.tokens.curr,\"computed property names\",\"6\");var value=expression(10);return advance(\"]\"),value}function checkPunctuators(token,values){return\"(punctuator)\"===token.type?_.contains(values,token.value):!1}function checkPunctuator(token,value){return\"(punctuator)\"===token.type&&token.value===value}function destructuringAssignOrJsonValue(){var block=lookupBlockType();block.notJson?(!state.inES6()&&block.isDestAssign&&warning(\"W104\",state.tokens.curr,\"destructuring assignment\",\"6\"),statements()):(state.option.laxbreak=!0,state.jsonMode=!0,jsonValue())}function jsonValue(){function jsonObject(){var o={},t=state.tokens.next;if(advance(\"{\"),\"}\"!==state.tokens.next.id)for(;;){if(\"(end)\"===state.tokens.next.id)error(\"E026\",state.tokens.next,t.line);else{if(\"}\"===state.tokens.next.id){warning(\"W094\",state.tokens.curr);break}\",\"===state.tokens.next.id?error(\"E028\",state.tokens.next):\"(string)\"!==state.tokens.next.id&&warning(\"W095\",state.tokens.next,state.tokens.next.value)}if(o[state.tokens.next.value]===!0?warning(\"W075\",state.tokens.next,\"key\",state.tokens.next.value):\"__proto__\"===state.tokens.next.value&&!state.option.proto||\"__iterator__\"===state.tokens.next.value&&!state.option.iterator?warning(\"W096\",state.tokens.next,state.tokens.next.value):o[state.tokens.next.value]=!0,advance(),advance(\":\"),jsonValue(),\",\"!==state.tokens.next.id)break;advance(\",\")}advance(\"}\")}function jsonArray(){var t=state.tokens.next;if(advance(\"[\"),\"]\"!==state.tokens.next.id)for(;;){if(\"(end)\"===state.tokens.next.id)error(\"E027\",state.tokens.next,t.line);else{if(\"]\"===state.tokens.next.id){warning(\"W094\",state.tokens.curr);break}\",\"===state.tokens.next.id&&error(\"E028\",state.tokens.next)}if(jsonValue(),\",\"!==state.tokens.next.id)break;advance(\",\")}advance(\"]\")}switch(state.tokens.next.id){case\"{\":jsonObject();break;case\"[\":jsonArray();break;case\"true\":case\"false\":case\"null\":case\"(number)\":case\"(string)\":advance();break;case\"-\":advance(\"-\"),advance(\"(number)\");break;default:error(\"E003\",state.tokens.next)}}var api,declared,functions,inblock,indent,lookahead,lex,member,membersOnly,predefined,stack,urls,bang={\"<\":!0,\"<=\":!0,\"==\":!0,\"===\":!0,\"!==\":!0,\"!=\":!0,\">\":!0,\">=\":!0,\"+\":!0,\"-\":!0,\"*\":!0,\"/\":!0,\"%\":!0},functionicity=[\"closure\",\"exception\",\"global\",\"label\",\"outer\",\"unused\",\"var\"],extraModules=[],emitter=new events.EventEmitter,typeofValues={};typeofValues.legacy=[\"xml\",\"unknown\"],typeofValues.es3=[\"undefined\",\"boolean\",\"number\",\"string\",\"function\",\"object\"],typeofValues.es3=typeofValues.es3.concat(typeofValues.legacy),typeofValues.es6=typeofValues.es3.concat(\"symbol\"),type(\"(number)\",function(){return this}),type(\"(string)\",function(){return this}),state.syntax[\"(identifier)\"]={type:\"(identifier)\",lbp:0,identifier:!0,nud:function(){var v=this.value;return\"=>\"===state.tokens.next.id?this:(state.funct[\"(comparray)\"].check(v)||state.funct[\"(scope)\"].block.use(v,state.tokens.curr),this)},led:function(){error(\"E033\",state.tokens.next,state.tokens.next.value)}};var baseTemplateSyntax={lbp:0,identifier:!1,template:!0};state.syntax[\"(template)\"]=_.extend({type:\"(template)\",nud:doTemplateLiteral,led:doTemplateLiteral,noSubst:!1},baseTemplateSyntax),state.syntax[\"(template middle)\"]=_.extend({type:\"(template middle)\",middle:!0,noSubst:!1},baseTemplateSyntax),state.syntax[\"(template tail)\"]=_.extend({type:\"(template tail)\",tail:!0,noSubst:!1},baseTemplateSyntax),state.syntax[\"(no subst template)\"]=_.extend({type:\"(template)\",nud:doTemplateLiteral,led:doTemplateLiteral,noSubst:!0,tail:!0},baseTemplateSyntax),type(\"(regexp)\",function(){return this}),delim(\"(endline)\"),delim(\"(begin)\"),delim(\"(end)\").reach=!0,delim(\"(error)\").reach=!0,delim(\"}\").reach=!0,delim(\")\"),delim(\"]\"),delim('\"').reach=!0,delim(\"'\").reach=!0,delim(\";\"),delim(\":\").reach=!0,delim(\"#\"),reserve(\"else\"),reserve(\"case\").reach=!0,reserve(\"catch\"),reserve(\"default\").reach=!0,reserve(\"finally\"),reservevar(\"arguments\",function(x){state.isStrict()&&state.funct[\"(global)\"]&&warning(\"E008\",x)}),reservevar(\"eval\"),reservevar(\"false\"),reservevar(\"Infinity\"),reservevar(\"null\"),reservevar(\"this\",function(x){state.isStrict()&&!isMethod()&&!state.option.validthis&&(state.funct[\"(statement)\"]&&state.funct[\"(name)\"].charAt(0)>\"Z\"||state.funct[\"(global)\"])&&warning(\"W040\",x)}),reservevar(\"true\"),reservevar(\"undefined\"),assignop(\"=\",\"assign\",20),assignop(\"+=\",\"assignadd\",20),assignop(\"-=\",\"assignsub\",20),assignop(\"*=\",\"assignmult\",20),assignop(\"/=\",\"assigndiv\",20).nud=function(){error(\"E014\")},assignop(\"%=\",\"assignmod\",20),bitwiseassignop(\"&=\"),bitwiseassignop(\"|=\"),bitwiseassignop(\"^=\"),bitwiseassignop(\"<<=\"),bitwiseassignop(\">>=\"),bitwiseassignop(\">>>=\"),infix(\",\",function(left,that){var expr;if(that.exprs=[left],state.option.nocomma&&warning(\"W127\"),!comma({peek:!0}))return that;for(;;){if(!(expr=expression(10)))break;if(that.exprs.push(expr),\",\"!==state.tokens.next.value||!comma())break}return that},10,!0),infix(\"?\",function(left,that){return increaseComplexityCount(),that.left=left,that.right=expression(10),advance(\":\"),that[\"else\"]=expression(10),that},30);var orPrecendence=40;infix(\"||\",function(left,that){return increaseComplexityCount(),that.left=left,that.right=expression(orPrecendence),that},orPrecendence),infix(\"&&\",\"and\",50),bitwise(\"|\",\"bitor\",70),bitwise(\"^\",\"bitxor\",80),bitwise(\"&\",\"bitand\",90),relation(\"==\",function(left,right){var eqnull=state.option.eqnull&&(\"null\"===(left&&left.value)||\"null\"===(right&&right.value));switch(!0){case!eqnull&&state.option.eqeqeq:this.from=this.character,warning(\"W116\",this,\"===\",\"==\");break;case isPoorRelation(left):warning(\"W041\",this,\"===\",left.value);break;case isPoorRelation(right):warning(\"W041\",this,\"===\",right.value);break;case isTypoTypeof(right,left,state):warning(\"W122\",this,right.value);break;case isTypoTypeof(left,right,state):warning(\"W122\",this,left.value)}return this}),relation(\"===\",function(left,right){return isTypoTypeof(right,left,state)?warning(\"W122\",this,right.value):isTypoTypeof(left,right,state)&&warning(\"W122\",this,left.value),this}),relation(\"!=\",function(left,right){var eqnull=state.option.eqnull&&(\"null\"===(left&&left.value)||\"null\"===(right&&right.value));return!eqnull&&state.option.eqeqeq?(this.from=this.character,warning(\"W116\",this,\"!==\",\"!=\")):isPoorRelation(left)?warning(\"W041\",this,\"!==\",left.value):isPoorRelation(right)?warning(\"W041\",this,\"!==\",right.value):isTypoTypeof(right,left,state)?warning(\"W122\",this,right.value):isTypoTypeof(left,right,state)&&warning(\"W122\",this,left.value),this}),relation(\"!==\",function(left,right){return isTypoTypeof(right,left,state)?warning(\"W122\",this,right.value):isTypoTypeof(left,right,state)&&warning(\"W122\",this,left.value),this}),relation(\"<\"),relation(\">\"),relation(\"<=\"),relation(\">=\"),bitwise(\"<<\",\"shiftleft\",120),bitwise(\">>\",\"shiftright\",120),bitwise(\">>>\",\"shiftrightunsigned\",120),infix(\"in\",\"in\",120),infix(\"instanceof\",\"instanceof\",120),infix(\"+\",function(left,that){var right;return that.left=left,that.right=right=expression(130),left&&right&&\"(string)\"===left.id&&\"(string)\"===right.id?(left.value+=right.value,left.character=right.character,!state.option.scripturl&®.javascriptURL.test(left.value)&&warning(\"W050\",left),left):that},130),prefix(\"+\",\"num\"),prefix(\"+++\",function(){return warning(\"W007\"),this.arity=\"unary\",this.right=expression(150),this}),infix(\"+++\",function(left){return warning(\"W007\"),this.left=left,this.right=expression(130),this},130),infix(\"-\",\"sub\",130),prefix(\"-\",\"neg\"),prefix(\"---\",function(){return warning(\"W006\"),this.arity=\"unary\",this.right=expression(150),this}),infix(\"---\",function(left){return warning(\"W006\"),this.left=left,this.right=expression(130),this},130),infix(\"*\",\"mult\",140),infix(\"/\",\"div\",140),infix(\"%\",\"mod\",140),suffix(\"++\"),prefix(\"++\",\"preinc\"),state.syntax[\"++\"].exps=!0,suffix(\"--\"),prefix(\"--\",\"predec\"),state.syntax[\"--\"].exps=!0,prefix(\"delete\",function(){var p=expression(10);return p?(\".\"!==p.id&&\"[\"!==p.id&&warning(\"W051\"),this.first=p,p.identifier&&!state.isStrict()&&(p.forgiveUndef=!0),this):this}).exps=!0,prefix(\"~\",function(){return state.option.bitwise&&warning(\"W016\",this,\"~\"),this.arity=\"unary\",this.right=expression(150),this}),prefix(\"...\",function(){return state.inES6(!0)||warning(\"W119\",this,\"spread/rest operator\",\"6\"),state.tokens.next.identifier||\"(string)\"===state.tokens.next.type||checkPunctuators(state.tokens.next,[\"[\",\"(\"])||error(\"E030\",state.tokens.next,state.tokens.next.value),expression(150),this}),prefix(\"!\",function(){return this.arity=\"unary\",this.right=expression(150),this.right||quit(\"E041\",this.line||0),bang[this.right.id]===!0&&warning(\"W018\",this,\"!\"),this}),prefix(\"typeof\",function(){var p=expression(150);return this.first=this.right=p,p||quit(\"E041\",this.line||0,this.character||0),p.identifier&&(p.forgiveUndef=!0),this}),prefix(\"new\",function(){var mp=metaProperty(\"target\",function(){state.inES6(!0)||warning(\"W119\",state.tokens.prev,\"new.target\",\"6\");for(var inFunction,c=state.funct;c&&(inFunction=!c[\"(global)\"],c[\"(arrow)\"]);)c=c[\"(context)\"];inFunction||warning(\"W136\",state.tokens.prev,\"new.target\")});if(mp)return mp;var i,c=expression(155);if(c&&\"function\"!==c.id)if(c.identifier)switch(c[\"new\"]=!0,c.value){case\"Number\":case\"String\":case\"Boolean\":case\"Math\":case\"JSON\":warning(\"W053\",state.tokens.prev,c.value);break;case\"Symbol\":state.inES6()&&warning(\"W053\",state.tokens.prev,c.value);break;case\"Function\":state.option.evil||warning(\"W054\");break;case\"Date\":case\"RegExp\":case\"this\":break;default:\"function\"!==c.id&&(i=c.value.substr(0,1),state.option.newcap&&(\"A\">i||i>\"Z\")&&!state.funct[\"(scope)\"].isPredefined(c.value)&&warning(\"W055\",state.tokens.curr))}else\".\"!==c.id&&\"[\"!==c.id&&\"(\"!==c.id&&warning(\"W056\",state.tokens.curr);else state.option.supernew||warning(\"W057\",this);return\"(\"===state.tokens.next.id||state.option.supernew||warning(\"W058\",state.tokens.curr,state.tokens.curr.value),this.first=this.right=c,this}),state.syntax[\"new\"].exps=!0,prefix(\"void\").exps=!0,infix(\".\",function(left,that){var m=identifier(!1,!0);return\"string\"==typeof m&&countMember(m),that.left=left,that.right=m,m&&\"hasOwnProperty\"===m&&\"=\"===state.tokens.next.value&&warning(\"W001\"),!left||\"arguments\"!==left.value||\"callee\"!==m&&\"caller\"!==m?state.option.evil||!left||\"document\"!==left.value||\"write\"!==m&&\"writeln\"!==m||warning(\"W060\",left):state.option.noarg?warning(\"W059\",left,m):state.isStrict()&&error(\"E008\"),state.option.evil||\"eval\"!==m&&\"execScript\"!==m||isGlobalEval(left,state)&&warning(\"W061\"),that},160,!0),infix(\"(\",function(left,that){state.option.immed&&left&&!left.immed&&\"function\"===left.id&&warning(\"W062\");var n=0,p=[];if(left&&\"(identifier)\"===left.type&&left.value.match(/^[A-Z]([A-Z0-9_$]*[a-z][A-Za-z0-9_$]*)?$/)&&-1===\"Array Number String Boolean Date Object Error Symbol\".indexOf(left.value)&&(\"Math\"===left.value?warning(\"W063\",left):state.option.newcap&&warning(\"W064\",left)),\")\"!==state.tokens.next.id)for(;p[p.length]=expression(10),n+=1,\",\"===state.tokens.next.id;)comma();return advance(\")\"),\"object\"==typeof left&&(state.inES5()||\"parseInt\"!==left.value||1!==n||warning(\"W065\",state.tokens.curr),state.option.evil||(\"eval\"===left.value||\"Function\"===left.value||\"execScript\"===left.value?(warning(\"W061\",left),p[0]&&\"(string)\"===[0].id&&addInternalSrc(left,p[0].value)):!p[0]||\"(string)\"!==p[0].id||\"setTimeout\"!==left.value&&\"setInterval\"!==left.value?!p[0]||\"(string)\"!==p[0].id||\".\"!==left.value||\"window\"!==left.left.value||\"setTimeout\"!==left.right&&\"setInterval\"!==left.right||(warning(\"W066\",left),addInternalSrc(left,p[0].value)):(warning(\"W066\",left),addInternalSrc(left,p[0].value))),left.identifier||\".\"===left.id||\"[\"===left.id||\"=>\"===left.id||\"(\"===left.id||\"&&\"===left.id||\"||\"===left.id||\"?\"===left.id||state.inES6()&&left[\"(name)\"]||warning(\"W067\",that)),that.left=left,that},155,!0).exps=!0,prefix(\"(\",function(){var pn1,ret,triggerFnExpr,first,last,pn=state.tokens.next,i=-1,parens=1,opening=state.tokens.curr,preceeding=state.tokens.prev,isNecessary=!state.option.singleGroups;do\"(\"===pn.value?parens+=1:\")\"===pn.value&&(parens-=1),i+=1,pn1=pn,pn=peek(i);while((0!==parens||\")\"!==pn1.value)&&\";\"!==pn.value&&\"(end)\"!==pn.type);if(\"function\"===state.tokens.next.id&&(triggerFnExpr=state.tokens.next.immed=!0),\"=>\"===pn.value)return doFunction({type:\"arrow\",parsedOpening:!0});var exprs=[];if(\")\"!==state.tokens.next.id)for(;exprs.push(expression(10)),\",\"===state.tokens.next.id;)state.option.nocomma&&warning(\"W127\"),comma();return advance(\")\",this),state.option.immed&&exprs[0]&&\"function\"===exprs[0].id&&\"(\"!==state.tokens.next.id&&\".\"!==state.tokens.next.id&&\"[\"!==state.tokens.next.id&&warning(\"W068\",this),exprs.length?(exprs.length>1?(ret=Object.create(state.syntax[\",\"]),ret.exprs=exprs,first=exprs[0],last=exprs[exprs.length-1],isNecessary||(isNecessary=preceeding.assign||preceeding.delim)):(ret=first=last=exprs[0],isNecessary||(isNecessary=opening.beginsStmt&&(\"{\"===ret.id||triggerFnExpr||isFunctor(ret))||triggerFnExpr&&(!isEndOfExpr()||\"}\"!==state.tokens.prev.id)||isFunctor(ret)&&!isEndOfExpr()||\"{\"===ret.id&&\"=>\"===preceeding.id||\"(number)\"===ret.type&&checkPunctuator(pn,\".\")&&/^\\d+$/.test(ret.value))),ret&&(!isNecessary&&(first.left||first.right||ret.exprs)&&(isNecessary=!isBeginOfExpr(preceeding)&&first.lbp<=preceeding.lbp||!isEndOfExpr()&&last.lbp\"),infix(\"[\",function(left,that){var s,e=expression(10);return e&&\"(string)\"===e.type&&(state.option.evil||\"eval\"!==e.value&&\"execScript\"!==e.value||isGlobalEval(left,state)&&warning(\"W061\"),countMember(e.value),!state.option.sub&®.identifier.test(e.value)&&(s=state.syntax[e.value],s&&isReserved(s)||warning(\"W069\",state.tokens.prev,e.value))),advance(\"]\",that),e&&\"hasOwnProperty\"===e.value&&\"=\"===state.tokens.next.value&&warning(\"W001\"),that.left=left,that.right=e,that},160,!0),prefix(\"[\",function(){var blocktype=lookupBlockType();if(blocktype.isCompArray)return state.option.esnext||state.inMoz()||warning(\"W118\",state.tokens.curr,\"array comprehension\"),comprehensiveArrayExpression();if(blocktype.isDestAssign)return this.destructAssign=destructuringPattern({openingParsed:!0,assignment:!0}),this;var b=state.tokens.curr.line!==startLine(state.tokens.next);for(this.first=[],b&&(indent+=state.option.indent,state.tokens.next.from===indent+state.option.indent&&(indent+=state.option.indent));\"(end)\"!==state.tokens.next.id;){for(;\",\"===state.tokens.next.id;){if(!state.option.elision){if(state.inES5()){warning(\"W128\");do advance(\",\");while(\",\"===state.tokens.next.id);continue}warning(\"W070\")}advance(\",\")}if(\"]\"===state.tokens.next.id)break;if(this.first.push(expression(10)),\",\"!==state.tokens.next.id)break;if(comma({allowTrailing:!0}),\"]\"===state.tokens.next.id&&!state.inES5()){warning(\"W070\",state.tokens.curr);break}}return b&&(indent-=state.option.indent),advance(\"]\",this),this}),function(x){x.nud=function(){var b,f,i,p,t,nextVal,isGeneratorMethod=!1,props=Object.create(null);b=state.tokens.curr.line!==startLine(state.tokens.next),b&&(indent+=state.option.indent,state.tokens.next.from===indent+state.option.indent&&(indent+=state.option.indent));var blocktype=lookupBlockType();if(blocktype.isDestAssign)return this.destructAssign=destructuringPattern({openingParsed:!0,assignment:!0}),this;for(;\"}\"!==state.tokens.next.id;){if(nextVal=state.tokens.next.value,!state.tokens.next.identifier||\",\"!==peekIgnoreEOL().id&&\"}\"!==peekIgnoreEOL().id)if(\":\"===peek().id||\"get\"!==nextVal&&\"set\"!==nextVal){if(\"*\"===state.tokens.next.value&&\"(punctuator)\"===state.tokens.next.type?(state.inES6()||warning(\"W104\",state.tokens.next,\"generator functions\",\"6\"),advance(\"*\"),isGeneratorMethod=!0):isGeneratorMethod=!1,\"[\"===state.tokens.next.id)i=computedPropertyName(),state.nameStack.set(i);else if(state.nameStack.set(state.tokens.next),i=propertyName(),saveProperty(props,i,state.tokens.next),\"string\"!=typeof i)break;\"(\"===state.tokens.next.value?(state.inES6()||warning(\"W104\",state.tokens.curr,\"concise methods\",\"6\"),doFunction({type:isGeneratorMethod?\"generator\":null})):(advance(\":\"),expression(10))}else advance(nextVal),state.inES5()||error(\"E034\"),i=propertyName(),i||state.inES6()||error(\"E035\"),i&&saveAccessor(nextVal,props,i,state.tokens.curr),t=state.tokens.next,f=doFunction(),p=f[\"(params)\"],\"get\"===nextVal&&i&&p?warning(\"W076\",t,p[0],i):\"set\"!==nextVal||!i||p&&1===p.length||warning(\"W077\",t,i);else state.inES6()||warning(\"W104\",state.tokens.next,\"object short notation\",\"6\"),i=propertyName(!0),saveProperty(props,i,state.tokens.next),expression(10);if(countMember(i),\",\"!==state.tokens.next.id)break;comma({allowTrailing:!0,property:!0}),\",\"===state.tokens.next.id?warning(\"W070\",state.tokens.curr):\"}\"!==state.tokens.next.id||state.inES5()||warning(\"W070\",state.tokens.curr)}return b&&(indent-=state.option.indent),advance(\"}\",this),checkProperties(props),this},x.fud=function(){error(\"E036\",state.tokens.curr)}}(delim(\"{\"));var conststatement=stmt(\"const\",function(context){return blockVariableStatement(\"const\",this,context)});conststatement.exps=!0;var letstatement=stmt(\"let\",function(context){return blockVariableStatement(\"let\",this,context)});letstatement.exps=!0;var varstatement=stmt(\"var\",function(context){var tokens,lone,value,prefix=context&&context.prefix,inexport=context&&context.inexport,implied=context&&context.implied,report=!(context&&context.ignore);for(this.first=[];;){var names=[];_.contains([\"{\",\"[\"],state.tokens.next.value)?(tokens=destructuringPattern(),lone=!1):(tokens=[{id:identifier(),token:state.tokens.curr}],lone=!0),prefix&&implied||!report||!state.option.varstmt||warning(\"W132\",this),this.first=this.first.concat(names);for(var t in tokens)tokens.hasOwnProperty(t)&&(t=tokens[t],!implied&&state.funct[\"(global)\"]&&(predefined[t.id]===!1?warning(\"W079\",t.token,t.id):state.option.futurehostile===!1&&(!state.inES5()&&vars.ecmaIdentifiers[5][t.id]===!1||!state.inES6()&&vars.ecmaIdentifiers[6][t.id]===!1)&&warning(\"W129\",t.token,t.id)),t.id&&(\"for\"===implied?(state.funct[\"(scope)\"].has(t.id)||report&&warning(\"W088\",t.token,t.id),state.funct[\"(scope)\"].block.use(t.id,t.token)):(state.funct[\"(scope)\"].addlabel(t.id,{type:\"var\",token:t.token}),lone&&inexport&&state.funct[\"(scope)\"].setExported(t.id,t.token)),names.push(t.token)));if(\"=\"===state.tokens.next.id&&(state.nameStack.set(state.tokens.curr),advance(\"=\"),prefix||!report||state.funct[\"(loopage)\"]||\"undefined\"!==state.tokens.next.id||warning(\"W080\",state.tokens.prev,state.tokens.prev.value),\"=\"===peek(0).id&&state.tokens.next.identifier&&(!prefix&&report&&!state.funct[\"(params)\"]||-1===state.funct[\"(params)\"].indexOf(state.tokens.next.value))&&warning(\"W120\",state.tokens.next,state.tokens.next.value),value=expression(prefix?120:10),lone?tokens[0].first=value:destructuringPatternMatch(names,value)),\",\"!==state.tokens.next.id)break;comma()}return this});varstatement.exps=!0,blockstmt(\"class\",function(){return classdef.call(this,!0)}),blockstmt(\"function\",function(context){var inexport=context&&context.inexport,generator=!1;\"*\"===state.tokens.next.value&&(advance(\"*\"),state.inES6({strict:!0})?generator=!0:warning(\"W119\",state.tokens.curr,\"function*\",\"6\")),inblock&&warning(\"W082\",state.tokens.curr);var i=optionalidentifier();return state.funct[\"(scope)\"].addlabel(i,{type:\"function\",token:state.tokens.curr}),void 0===i?warning(\"W025\"):inexport&&state.funct[\"(scope)\"].setExported(i,state.tokens.prev),doFunction({name:i,statement:this,type:generator?\"generator\":null,ignoreLoopFunc:inblock}),\"(\"===state.tokens.next.id&&state.tokens.next.line===state.tokens.curr.line&&error(\"E039\"),this}),prefix(\"function\",function(){var generator=!1;\"*\"===state.tokens.next.value&&(state.inES6()||warning(\"W119\",state.tokens.curr,\"function*\",\"6\"),advance(\"*\"),generator=!0);var i=optionalidentifier();return doFunction({name:i,type:generator?\"generator\":null}),this}),blockstmt(\"if\",function(){var t=state.tokens.next;increaseComplexityCount(),state.condition=!0,advance(\"(\");var expr=expression(0);checkCondAssignment(expr);var forinifcheck=null;state.option.forin&&state.forinifcheckneeded&&(state.forinifcheckneeded=!1,forinifcheck=state.forinifchecks[state.forinifchecks.length-1],forinifcheck.type=\"(punctuator)\"===expr.type&&\"!\"===expr.value?\"(negative)\":\"(positive)\"),advance(\")\",t),state.condition=!1;var s=block(!0,!0);return forinifcheck&&\"(negative)\"===forinifcheck.type&&s&&s[0]&&\"(identifier)\"===s[0].type&&\"continue\"===s[0].value&&(forinifcheck.type=\"(negative-with-continue)\"),\"else\"===state.tokens.next.id&&(advance(\"else\"),\"if\"===state.tokens.next.id||\"switch\"===state.tokens.next.id?statement():block(!0,!0)),this}),blockstmt(\"try\",function(){function doCatch(){if(advance(\"catch\"),advance(\"(\"),state.funct[\"(scope)\"].stack(\"catchparams\"),checkPunctuators(state.tokens.next,[\"[\",\"{\"])){var tokens=destructuringPattern();_.each(tokens,function(token){token.id&&state.funct[\"(scope)\"].addParam(token.id,token,\"exception\")})}else\"(identifier)\"!==state.tokens.next.type?warning(\"E030\",state.tokens.next,state.tokens.next.value):state.funct[\"(scope)\"].addParam(identifier(),state.tokens.curr,\"exception\");\"if\"===state.tokens.next.value&&(state.inMoz()||warning(\"W118\",state.tokens.curr,\"catch filter\"),advance(\"if\"),expression(0)),advance(\")\"),block(!1),state.funct[\"(scope)\"].unstack()}var b;for(block(!0);\"catch\"===state.tokens.next.id;)increaseComplexityCount(),b&&!state.inMoz()&&warning(\"W118\",state.tokens.next,\"multiple catch blocks\"),doCatch(),b=!0;return\"finally\"===state.tokens.next.id?(advance(\"finally\"),block(!0),void 0):(b||error(\"E021\",state.tokens.next,\"catch\",state.tokens.next.value),this)}),blockstmt(\"while\",function(){var t=state.tokens.next;return state.funct[\"(breakage)\"]+=1,state.funct[\"(loopage)\"]+=1,increaseComplexityCount(),advance(\"(\"),checkCondAssignment(expression(0)),advance(\")\",t),block(!0,!0),state.funct[\"(breakage)\"]-=1,state.funct[\"(loopage)\"]-=1,this}).labelled=!0,blockstmt(\"with\",function(){var t=state.tokens.next;return state.isStrict()?error(\"E010\",state.tokens.curr):state.option.withstmt||warning(\"W085\",state.tokens.curr),advance(\"(\"),expression(0),advance(\")\",t),block(!0,!0),this}),blockstmt(\"switch\",function(){var t=state.tokens.next,g=!1,noindent=!1;\nfor(state.funct[\"(breakage)\"]+=1,advance(\"(\"),checkCondAssignment(expression(0)),advance(\")\",t),t=state.tokens.next,advance(\"{\"),state.tokens.next.from===indent&&(noindent=!0),noindent||(indent+=state.option.indent),this.cases=[];;)switch(state.tokens.next.id){case\"case\":switch(state.funct[\"(verb)\"]){case\"yield\":case\"break\":case\"case\":case\"continue\":case\"return\":case\"switch\":case\"throw\":break;default:state.tokens.curr.caseFallsThrough||warning(\"W086\",state.tokens.curr,\"case\")}advance(\"case\"),this.cases.push(expression(0)),increaseComplexityCount(),g=!0,advance(\":\"),state.funct[\"(verb)\"]=\"case\";break;case\"default\":switch(state.funct[\"(verb)\"]){case\"yield\":case\"break\":case\"continue\":case\"return\":case\"throw\":break;default:this.cases.length&&(state.tokens.curr.caseFallsThrough||warning(\"W086\",state.tokens.curr,\"default\"))}advance(\"default\"),g=!0,advance(\":\");break;case\"}\":return noindent||(indent-=state.option.indent),advance(\"}\",t),state.funct[\"(breakage)\"]-=1,state.funct[\"(verb)\"]=void 0,void 0;case\"(end)\":return error(\"E023\",state.tokens.next,\"}\"),void 0;default:if(indent+=state.option.indent,g)switch(state.tokens.curr.id){case\",\":return error(\"E040\"),void 0;case\":\":g=!1,statements();break;default:return error(\"E025\",state.tokens.curr),void 0}else{if(\":\"!==state.tokens.curr.id)return error(\"E021\",state.tokens.next,\"case\",state.tokens.next.value),void 0;advance(\":\"),error(\"E024\",state.tokens.curr,\":\"),statements()}indent-=state.option.indent}return this}).labelled=!0,stmt(\"debugger\",function(){return state.option.debug||warning(\"W087\",this),this}).exps=!0,function(){var x=stmt(\"do\",function(){state.funct[\"(breakage)\"]+=1,state.funct[\"(loopage)\"]+=1,increaseComplexityCount(),this.first=block(!0,!0),advance(\"while\");var t=state.tokens.next;return advance(\"(\"),checkCondAssignment(expression(0)),advance(\")\",t),state.funct[\"(breakage)\"]-=1,state.funct[\"(loopage)\"]-=1,this});x.labelled=!0,x.exps=!0}(),blockstmt(\"for\",function(){var s,t=state.tokens.next,letscope=!1,foreachtok=null;\"each\"===t.value&&(foreachtok=t,advance(\"each\"),state.inMoz()||warning(\"W118\",state.tokens.curr,\"for each\")),increaseComplexityCount(),advance(\"(\");var nextop,comma,initializer,i=0,inof=[\"in\",\"of\"],level=0;checkPunctuators(state.tokens.next,[\"{\",\"[\"])&&++level;do{if(nextop=peek(i),++i,checkPunctuators(nextop,[\"{\",\"[\"])?++level:checkPunctuators(nextop,[\"}\",\"]\"])&&--level,0>level)break;0===level&&(!comma&&checkPunctuator(nextop,\",\")?comma=nextop:!initializer&&checkPunctuator(nextop,\"=\")&&(initializer=nextop))}while(level>0||!_.contains(inof,nextop.value)&&\";\"!==nextop.value&&\"(end)\"!==nextop.type);if(_.contains(inof,nextop.value)){state.inES6()||\"of\"!==nextop.value||warning(\"W104\",nextop,\"for of\",\"6\");var ok=!(initializer||comma);if(initializer&&error(\"W133\",comma,nextop.value,\"initializer is forbidden\"),comma&&error(\"W133\",comma,nextop.value,\"more than one ForBinding\"),\"var\"===state.tokens.next.id?(advance(\"var\"),state.tokens.curr.fud({prefix:!0})):\"let\"===state.tokens.next.id||\"const\"===state.tokens.next.id?(advance(state.tokens.next.id),letscope=!0,state.funct[\"(scope)\"].stack(),state.tokens.curr.fud({prefix:!0})):Object.create(varstatement).fud({prefix:!0,implied:\"for\",ignore:!ok}),advance(nextop.value),expression(20),advance(\")\",t),\"in\"===nextop.value&&state.option.forin&&(state.forinifcheckneeded=!0,void 0===state.forinifchecks&&(state.forinifchecks=[]),state.forinifchecks.push({type:\"(none)\"})),state.funct[\"(breakage)\"]+=1,state.funct[\"(loopage)\"]+=1,s=block(!0,!0),\"in\"===nextop.value&&state.option.forin){if(state.forinifchecks&&state.forinifchecks.length>0){var check=state.forinifchecks.pop();(s&&s.length>0&&(\"object\"!=typeof s[0]||\"if\"!==s[0].value)||\"(positive)\"===check.type&&s.length>1||\"(negative)\"===check.type)&&warning(\"W089\",this)}state.forinifcheckneeded=!1}state.funct[\"(breakage)\"]-=1,state.funct[\"(loopage)\"]-=1}else{if(foreachtok&&error(\"E045\",foreachtok),\";\"!==state.tokens.next.id)if(\"var\"===state.tokens.next.id)advance(\"var\"),state.tokens.curr.fud();else if(\"let\"===state.tokens.next.id)advance(\"let\"),letscope=!0,state.funct[\"(scope)\"].stack(),state.tokens.curr.fud();else for(;expression(0,\"for\"),\",\"===state.tokens.next.id;)comma();if(nolinebreak(state.tokens.curr),advance(\";\"),state.funct[\"(loopage)\"]+=1,\";\"!==state.tokens.next.id&&checkCondAssignment(expression(0)),nolinebreak(state.tokens.curr),advance(\";\"),\";\"===state.tokens.next.id&&error(\"E021\",state.tokens.next,\")\",\";\"),\")\"!==state.tokens.next.id)for(;expression(0,\"for\"),\",\"===state.tokens.next.id;)comma();advance(\")\",t),state.funct[\"(breakage)\"]+=1,block(!0,!0),state.funct[\"(breakage)\"]-=1,state.funct[\"(loopage)\"]-=1}return letscope&&state.funct[\"(scope)\"].unstack(),this}).labelled=!0,stmt(\"break\",function(){var v=state.tokens.next.value;return state.option.asi||nolinebreak(this),\";\"===state.tokens.next.id||state.tokens.next.reach||state.tokens.curr.line!==startLine(state.tokens.next)?0===state.funct[\"(breakage)\"]&&warning(\"W052\",state.tokens.next,this.value):(state.funct[\"(scope)\"].funct.hasBreakLabel(v)||warning(\"W090\",state.tokens.next,v),this.first=state.tokens.next,advance()),reachable(this),this}).exps=!0,stmt(\"continue\",function(){var v=state.tokens.next.value;return 0===state.funct[\"(breakage)\"]&&warning(\"W052\",state.tokens.next,this.value),state.funct[\"(loopage)\"]||warning(\"W052\",state.tokens.next,this.value),state.option.asi||nolinebreak(this),\";\"===state.tokens.next.id||state.tokens.next.reach||state.tokens.curr.line===startLine(state.tokens.next)&&(state.funct[\"(scope)\"].funct.hasBreakLabel(v)||warning(\"W090\",state.tokens.next,v),this.first=state.tokens.next,advance()),reachable(this),this}).exps=!0,stmt(\"return\",function(){return this.line===startLine(state.tokens.next)?\";\"===state.tokens.next.id||state.tokens.next.reach||(this.first=expression(0),!this.first||\"(punctuator)\"!==this.first.type||\"=\"!==this.first.value||this.first.paren||state.option.boss||warningAt(\"W093\",this.first.line,this.first.character)):\"(punctuator)\"===state.tokens.next.type&&[\"[\",\"{\",\"+\",\"-\"].indexOf(state.tokens.next.value)>-1&&nolinebreak(this),reachable(this),this}).exps=!0,function(x){x.exps=!0,x.lbp=25}(prefix(\"yield\",function(){var prev=state.tokens.prev;state.inES6(!0)&&!state.funct[\"(generator)\"]?\"(catch)\"===state.funct[\"(name)\"]&&state.funct[\"(context)\"][\"(generator)\"]||error(\"E046\",state.tokens.curr,\"yield\"):state.inES6()||warning(\"W104\",state.tokens.curr,\"yield\",\"6\"),state.funct[\"(generator)\"]=\"yielded\";var delegatingYield=!1;return\"*\"===state.tokens.next.value&&(delegatingYield=!0,advance(\"*\")),this.line!==startLine(state.tokens.next)&&state.inMoz()?state.option.asi||nolinebreak(this):((delegatingYield||\";\"!==state.tokens.next.id&&!state.option.asi&&!state.tokens.next.reach&&state.tokens.next.nud)&&(nobreaknonadjacent(state.tokens.curr,state.tokens.next),this.first=expression(10),\"(punctuator)\"!==this.first.type||\"=\"!==this.first.value||this.first.paren||state.option.boss||warningAt(\"W093\",this.first.line,this.first.character)),state.inMoz()&&\")\"!==state.tokens.next.id&&(prev.lbp>30||!prev.assign&&!isEndOfExpr()||\"yield\"===prev.id)&&error(\"E050\",this)),this})),stmt(\"throw\",function(){return nolinebreak(this),this.first=expression(20),reachable(this),this}).exps=!0,stmt(\"import\",function(){if(state.inES6()||warning(\"W119\",state.tokens.curr,\"import\",\"6\"),\"(string)\"===state.tokens.next.type)return advance(\"(string)\"),this;if(state.tokens.next.identifier){if(this.name=identifier(),state.funct[\"(scope)\"].addlabel(this.name,{type:\"const\",token:state.tokens.curr}),\",\"!==state.tokens.next.value)return advance(\"from\"),advance(\"(string)\"),this;advance(\",\")}if(\"*\"===state.tokens.next.id)advance(\"*\"),advance(\"as\"),state.tokens.next.identifier&&(this.name=identifier(),state.funct[\"(scope)\"].addlabel(this.name,{type:\"const\",token:state.tokens.curr}));else for(advance(\"{\");;){if(\"}\"===state.tokens.next.value){advance(\"}\");break}var importName;if(\"default\"===state.tokens.next.type?(importName=\"default\",advance(\"default\")):importName=identifier(),\"as\"===state.tokens.next.value&&(advance(\"as\"),importName=identifier()),state.funct[\"(scope)\"].addlabel(importName,{type:\"const\",token:state.tokens.curr}),\",\"!==state.tokens.next.value){if(\"}\"===state.tokens.next.value){advance(\"}\");break}error(\"E024\",state.tokens.next,state.tokens.next.value);break}advance(\",\")}return advance(\"from\"),advance(\"(string)\"),this}).exps=!0,stmt(\"export\",function(){var token,identifier,ok=!0;if(state.inES6()||(warning(\"W119\",state.tokens.curr,\"export\",\"6\"),ok=!1),state.funct[\"(scope)\"].block.isGlobal()||(error(\"E053\",state.tokens.curr),ok=!1),\"*\"===state.tokens.next.value)return advance(\"*\"),advance(\"from\"),advance(\"(string)\"),this;if(\"default\"===state.tokens.next.type){state.nameStack.set(state.tokens.next),advance(\"default\");var exportType=state.tokens.next.id;return(\"function\"===exportType||\"class\"===exportType)&&(this.block=!0),token=peek(),expression(10),identifier=token.value,this.block&&(state.funct[\"(scope)\"].addlabel(identifier,{type:exportType,token:token}),state.funct[\"(scope)\"].setExported(identifier,token)),this}if(\"{\"===state.tokens.next.value){advance(\"{\");for(var exportedTokens=[];;){if(state.tokens.next.identifier||error(\"E030\",state.tokens.next,state.tokens.next.value),advance(),exportedTokens.push(state.tokens.curr),\"as\"===state.tokens.next.value&&(advance(\"as\"),state.tokens.next.identifier||error(\"E030\",state.tokens.next,state.tokens.next.value),advance()),\",\"!==state.tokens.next.value){if(\"}\"===state.tokens.next.value){advance(\"}\");break}error(\"E024\",state.tokens.next,state.tokens.next.value);break}advance(\",\")}return\"from\"===state.tokens.next.value?(advance(\"from\"),advance(\"(string)\")):ok&&exportedTokens.forEach(function(token){state.funct[\"(scope)\"].setExported(token.value,token)}),this}if(\"var\"===state.tokens.next.id)advance(\"var\"),state.tokens.curr.fud({inexport:!0});else if(\"let\"===state.tokens.next.id)advance(\"let\"),state.tokens.curr.fud({inexport:!0});else if(\"const\"===state.tokens.next.id)advance(\"const\"),state.tokens.curr.fud({inexport:!0});else if(\"function\"===state.tokens.next.id)this.block=!0,advance(\"function\"),state.syntax[\"function\"].fud({inexport:!0});else if(\"class\"===state.tokens.next.id){this.block=!0,advance(\"class\");var classNameToken=state.tokens.next;state.syntax[\"class\"].fud(),state.funct[\"(scope)\"].setExported(classNameToken.value,classNameToken)}else error(\"E024\",state.tokens.next,state.tokens.next.value);return this}).exps=!0,FutureReservedWord(\"abstract\"),FutureReservedWord(\"boolean\"),FutureReservedWord(\"byte\"),FutureReservedWord(\"char\"),FutureReservedWord(\"class\",{es5:!0,nud:classdef}),FutureReservedWord(\"double\"),FutureReservedWord(\"enum\",{es5:!0}),FutureReservedWord(\"export\",{es5:!0}),FutureReservedWord(\"extends\",{es5:!0}),FutureReservedWord(\"final\"),FutureReservedWord(\"float\"),FutureReservedWord(\"goto\"),FutureReservedWord(\"implements\",{es5:!0,strictOnly:!0}),FutureReservedWord(\"import\",{es5:!0}),FutureReservedWord(\"int\"),FutureReservedWord(\"interface\",{es5:!0,strictOnly:!0}),FutureReservedWord(\"long\"),FutureReservedWord(\"native\"),FutureReservedWord(\"package\",{es5:!0,strictOnly:!0}),FutureReservedWord(\"private\",{es5:!0,strictOnly:!0}),FutureReservedWord(\"protected\",{es5:!0,strictOnly:!0}),FutureReservedWord(\"public\",{es5:!0,strictOnly:!0}),FutureReservedWord(\"short\"),FutureReservedWord(\"static\",{es5:!0,strictOnly:!0}),FutureReservedWord(\"super\",{es5:!0}),FutureReservedWord(\"synchronized\"),FutureReservedWord(\"transient\"),FutureReservedWord(\"volatile\");var lookupBlockType=function(){var pn,pn1,prev,i=-1,bracketStack=0,ret={};checkPunctuators(state.tokens.curr,[\"[\",\"{\"])&&(bracketStack+=1);do{if(prev=-1===i?state.tokens.curr:pn,pn=-1===i?state.tokens.next:peek(i),pn1=peek(i+1),i+=1,checkPunctuators(pn,[\"[\",\"{\"])?bracketStack+=1:checkPunctuators(pn,[\"]\",\"}\"])&&(bracketStack-=1),1===bracketStack&&pn.identifier&&\"for\"===pn.value&&!checkPunctuator(prev,\".\")){ret.isCompArray=!0,ret.notJson=!0;break}if(0===bracketStack&&checkPunctuators(pn,[\"}\",\"]\"])){if(\"=\"===pn1.value){ret.isDestAssign=!0,ret.notJson=!0;break}if(\".\"===pn1.value){ret.notJson=!0;break}}checkPunctuator(pn,\";\")&&(ret.isBlock=!0,ret.notJson=!0)}while(bracketStack>0&&\"(end)\"!==pn.id);return ret},arrayComprehension=function(){function declare(v){var l=_current.variables.filter(function(elt){return elt.value===v?(elt.undef=!1,v):void 0}).length;return 0!==l}function use(v){var l=_current.variables.filter(function(elt){return elt.value!==v||elt.undef?void 0:(elt.unused===!0&&(elt.unused=!1),v)}).length;return 0===l}var _current,CompArray=function(){this.mode=\"use\",this.variables=[]},_carrays=[];return{stack:function(){_current=new CompArray,_carrays.push(_current)},unstack:function(){_current.variables.filter(function(v){v.unused&&warning(\"W098\",v.token,v.raw_text||v.value),v.undef&&state.funct[\"(scope)\"].block.use(v.value,v.token)}),_carrays.splice(-1,1),_current=_carrays[_carrays.length-1]},setState:function(s){_.contains([\"use\",\"define\",\"generate\",\"filter\"],s)&&(_current.mode=s)},check:function(v){return _current?_current&&\"use\"===_current.mode?(use(v)&&_current.variables.push({funct:state.funct,token:state.tokens.curr,value:v,undef:!0,unused:!1}),!0):_current&&\"define\"===_current.mode?(declare(v)||_current.variables.push({funct:state.funct,token:state.tokens.curr,value:v,undef:!1,unused:!0}),!0):_current&&\"generate\"===_current.mode?(state.funct[\"(scope)\"].block.use(v,state.tokens.curr),!0):_current&&\"filter\"===_current.mode?(use(v)&&state.funct[\"(scope)\"].block.use(v,state.tokens.curr),!0):!1:void 0}}},escapeRegex=function(str){return str.replace(/[-\\/\\\\^$*+?.()|[\\]{}]/g,\"\\\\$&\")},itself=function(s,o,g){function each(obj,cb){obj&&(Array.isArray(obj)||\"object\"!=typeof obj||(obj=Object.keys(obj)),obj.forEach(cb))}var i,k,x,reIgnoreStr,reIgnore,optionKeys,newOptionObj={},newIgnoredObj={};o=_.clone(o),state.reset(),o&&o.scope?JSHINT.scope=o.scope:(JSHINT.errors=[],JSHINT.undefs=[],JSHINT.internals=[],JSHINT.blacklist={},JSHINT.scope=\"(main)\"),predefined=Object.create(null),combine(predefined,vars.ecmaIdentifiers[3]),combine(predefined,vars.reservedVars),combine(predefined,g||{}),declared=Object.create(null);var exported=Object.create(null);if(o)for(each(o.predef||null,function(item){var slice,prop;\"-\"===item[0]?(slice=item.slice(1),JSHINT.blacklist[slice]=slice,delete predefined[slice]):(prop=Object.getOwnPropertyDescriptor(o.predef,item),predefined[item]=prop?prop.value:!1)}),each(o.exported||null,function(item){exported[item]=!0}),delete o.predef,delete o.exported,optionKeys=Object.keys(o),x=0;optionKeys.length>x;x++)if(/^-W\\d{3}$/g.test(optionKeys[x]))newIgnoredObj[optionKeys[x].slice(1)]=!0;else{var optionKey=optionKeys[x];newOptionObj[optionKey]=o[optionKey],(\"esversion\"===optionKey&&5===o[optionKey]||\"es5\"===optionKey&&o[optionKey])&&warning(\"I003\"),\"newcap\"===optionKeys[x]&&o[optionKey]===!1&&(newOptionObj[\"(explicitNewcap)\"]=!0)}state.option=newOptionObj,state.ignored=newIgnoredObj,state.option.indent=state.option.indent||4,state.option.maxerr=state.option.maxerr||50,indent=1;var scopeManagerInst=scopeManager(state,predefined,exported,declared);if(scopeManagerInst.on(\"warning\",function(ev){warning.apply(null,[ev.code,ev.token].concat(ev.data))}),scopeManagerInst.on(\"error\",function(ev){error.apply(null,[ev.code,ev.token].concat(ev.data))}),state.funct=functor(\"(global)\",null,{\"(global)\":!0,\"(scope)\":scopeManagerInst,\"(comparray)\":arrayComprehension(),\"(metrics)\":createMetrics(state.tokens.next)}),functions=[state.funct],urls=[],stack=null,member={},membersOnly=null,inblock=!1,lookahead=[],!isString(s)&&!Array.isArray(s))return errorAt(\"E004\",0),!1;api={get isJSON(){return state.jsonMode},getOption:function(name){return state.option[name]||null},getCache:function(name){return state.cache[name]},setCache:function(name,value){state.cache[name]=value},warn:function(code,data){warningAt.apply(null,[code,data.line,data.char].concat(data.data))},on:function(names,listener){names.split(\" \").forEach(function(name){emitter.on(name,listener)}.bind(this))}},emitter.removeAllListeners(),(extraModules||[]).forEach(function(func){func(api)}),state.tokens.prev=state.tokens.curr=state.tokens.next=state.syntax[\"(begin)\"],o&&o.ignoreDelimiters&&(Array.isArray(o.ignoreDelimiters)||(o.ignoreDelimiters=[o.ignoreDelimiters]),o.ignoreDelimiters.forEach(function(delimiterPair){delimiterPair.start&&delimiterPair.end&&(reIgnoreStr=escapeRegex(delimiterPair.start)+\"[\\\\s\\\\S]*?\"+escapeRegex(delimiterPair.end),reIgnore=RegExp(reIgnoreStr,\"ig\"),s=s.replace(reIgnore,function(match){return match.replace(/./g,\" \")}))})),lex=new Lexer(s),lex.on(\"warning\",function(ev){warningAt.apply(null,[ev.code,ev.line,ev.character].concat(ev.data))}),lex.on(\"error\",function(ev){errorAt.apply(null,[ev.code,ev.line,ev.character].concat(ev.data))}),lex.on(\"fatal\",function(ev){quit(\"E041\",ev.line,ev.from)}),lex.on(\"Identifier\",function(ev){emitter.emit(\"Identifier\",ev)}),lex.on(\"String\",function(ev){emitter.emit(\"String\",ev)}),lex.on(\"Number\",function(ev){emitter.emit(\"Number\",ev)}),lex.start();for(var name in o)_.has(o,name)&&checkOption(name,state.tokens.curr);assume(),combine(predefined,g||{}),comma.first=!0;try{switch(advance(),state.tokens.next.id){case\"{\":case\"[\":destructuringAssignOrJsonValue();break;default:directives(),state.directive[\"use strict\"]&&\"global\"!==state.option.strict&&warning(\"W097\",state.tokens.prev),statements()}\"(end)\"!==state.tokens.next.id&&quit(\"E041\",state.tokens.curr.line),state.funct[\"(scope)\"].unstack()}catch(err){if(!err||\"JSHintError\"!==err.name)throw err;var nt=state.tokens.next||{};JSHINT.errors.push({scope:\"(main)\",raw:err.raw,code:err.code,reason:err.message,line:err.line||nt.line,character:err.character||nt.from},null)}if(\"(main)\"===JSHINT.scope)for(o=o||{},i=0;JSHINT.internals.length>i;i+=1)k=JSHINT.internals[i],o.scope=k.elem,itself(k.value,o,g);return 0===JSHINT.errors.length};return itself.addModule=function(func){extraModules.push(func)},itself.addModule(style.register),itself.data=function(){var fu,f,i,j,n,globals,data={functions:[],options:state.option};itself.errors.length&&(data.errors=itself.errors),state.jsonMode&&(data.json=!0);var impliedGlobals=state.funct[\"(scope)\"].getImpliedGlobals();for(impliedGlobals.length>0&&(data.implieds=impliedGlobals),urls.length>0&&(data.urls=urls),globals=state.funct[\"(scope)\"].getUsedOrDefinedGlobals(),globals.length>0&&(data.globals=globals),i=1;functions.length>i;i+=1){for(f=functions[i],fu={},j=0;functionicity.length>j;j+=1)fu[functionicity[j]]=[];for(j=0;functionicity.length>j;j+=1)0===fu[functionicity[j]].length&&delete fu[functionicity[j]];fu.name=f[\"(name)\"],fu.param=f[\"(params)\"],fu.line=f[\"(line)\"],fu.character=f[\"(character)\"],fu.last=f[\"(last)\"],fu.lastcharacter=f[\"(lastcharacter)\"],fu.metrics={complexity:f[\"(metrics)\"].ComplexityCount,parameters:f[\"(metrics)\"].arity,statements:f[\"(metrics)\"].statementCount},data.functions.push(fu)}var unuseds=state.funct[\"(scope)\"].getUnuseds();unuseds.length>0&&(data.unused=unuseds);for(n in member)if(\"number\"==typeof member[n]){data.member=member;break}return data},itself.jshint=itself,itself}();\"object\"==typeof exports&&exports&&(exports.JSHINT=JSHINT)},{\"../lodash\":\"/node_modules/jshint/lodash.js\",\"./lex.js\":\"/node_modules/jshint/src/lex.js\",\"./messages.js\":\"/node_modules/jshint/src/messages.js\",\"./options.js\":\"/node_modules/jshint/src/options.js\",\"./reg.js\":\"/node_modules/jshint/src/reg.js\",\"./scope-manager.js\":\"/node_modules/jshint/src/scope-manager.js\",\"./state.js\":\"/node_modules/jshint/src/state.js\",\"./style.js\":\"/node_modules/jshint/src/style.js\",\"./vars.js\":\"/node_modules/jshint/src/vars.js\",events:\"/node_modules/browserify/node_modules/events/events.js\"}],\"/node_modules/jshint/src/lex.js\":[function(_dereq_,module,exports){\"use strict\";function asyncTrigger(){var _checks=[];return{push:function(fn){_checks.push(fn)},check:function(){for(var check=0;_checks.length>check;++check)_checks[check]();_checks.splice(0,_checks.length)}}}function Lexer(source){var lines=source;\"string\"==typeof lines&&(lines=lines.replace(/\\r\\n/g,\"\\n\").replace(/\\r/g,\"\\n\").split(\"\\n\")),lines[0]&&\"#!\"===lines[0].substr(0,2)&&(-1!==lines[0].indexOf(\"node\")&&(state.option.node=!0),lines[0]=\"\"),this.emitter=new events.EventEmitter,this.source=source,this.setLines(lines),this.prereg=!0,this.line=0,this.char=1,this.from=1,this.input=\"\",this.inComment=!1,this.context=[],this.templateStarts=[];for(var i=0;state.option.indent>i;i+=1)state.tab+=\" \";this.ignoreLinterErrors=!1}var _=_dereq_(\"../lodash\"),events=_dereq_(\"events\"),reg=_dereq_(\"./reg.js\"),state=_dereq_(\"./state.js\").state,unicodeData=_dereq_(\"../data/ascii-identifier-data.js\"),asciiIdentifierStartTable=unicodeData.asciiIdentifierStartTable,asciiIdentifierPartTable=unicodeData.asciiIdentifierPartTable,Token={Identifier:1,Punctuator:2,NumericLiteral:3,StringLiteral:4,Comment:5,Keyword:6,NullLiteral:7,BooleanLiteral:8,RegExp:9,TemplateHead:10,TemplateMiddle:11,TemplateTail:12,NoSubstTemplate:13},Context={Block:1,Template:2};Lexer.prototype={_lines:[],inContext:function(ctxType){return this.context.length>0&&this.context[this.context.length-1].type===ctxType},pushContext:function(ctxType){this.context.push({type:ctxType})},popContext:function(){return this.context.pop()},isContext:function(context){return this.context.length>0&&this.context[this.context.length-1]===context},currentContext:function(){return this.context.length>0&&this.context[this.context.length-1]},getLines:function(){return this._lines=state.lines,this._lines},setLines:function(val){this._lines=val,state.lines=this._lines},peek:function(i){return this.input.charAt(i||0)},skip:function(i){i=i||1,this.char+=i,this.input=this.input.slice(i)},on:function(names,listener){names.split(\" \").forEach(function(name){this.emitter.on(name,listener)}.bind(this))},trigger:function(){this.emitter.emit.apply(this.emitter,Array.prototype.slice.call(arguments))},triggerAsync:function(type,args,checks,fn){checks.push(function(){fn()&&this.trigger(type,args)}.bind(this))},scanPunctuator:function(){var ch2,ch3,ch4,ch1=this.peek();switch(ch1){case\".\":if(/^[0-9]$/.test(this.peek(1)))return null;if(\".\"===this.peek(1)&&\".\"===this.peek(2))return{type:Token.Punctuator,value:\"...\"};case\"(\":case\")\":case\";\":case\",\":case\"[\":case\"]\":case\":\":case\"~\":case\"?\":return{type:Token.Punctuator,value:ch1};case\"{\":return this.pushContext(Context.Block),{type:Token.Punctuator,value:ch1};case\"}\":return this.inContext(Context.Block)&&this.popContext(),{type:Token.Punctuator,value:ch1};case\"#\":return{type:Token.Punctuator,value:ch1};case\"\":return null}return ch2=this.peek(1),ch3=this.peek(2),ch4=this.peek(3),\">\"===ch1&&\">\"===ch2&&\">\"===ch3&&\"=\"===ch4?{type:Token.Punctuator,value:\">>>=\"}:\"=\"===ch1&&\"=\"===ch2&&\"=\"===ch3?{type:Token.Punctuator,value:\"===\"}:\"!\"===ch1&&\"=\"===ch2&&\"=\"===ch3?{type:Token.Punctuator,value:\"!==\"}:\">\"===ch1&&\">\"===ch2&&\">\"===ch3?{type:Token.Punctuator,value:\">>>\"}:\"<\"===ch1&&\"<\"===ch2&&\"=\"===ch3?{type:Token.Punctuator,value:\"<<=\"}:\">\"===ch1&&\">\"===ch2&&\"=\"===ch3?{type:Token.Punctuator,value:\">>=\"}:\"=\"===ch1&&\">\"===ch2?{type:Token.Punctuator,value:ch1+ch2}:ch1===ch2&&\"+-<>&|\".indexOf(ch1)>=0?{type:Token.Punctuator,value:ch1+ch2}:\"<>=!+-*%&|^\".indexOf(ch1)>=0?\"=\"===ch2?{type:Token.Punctuator,value:ch1+ch2}:{type:Token.Punctuator,value:ch1}:\"/\"===ch1?\"=\"===ch2?{type:Token.Punctuator,value:\"/=\"}:{type:Token.Punctuator,value:\"/\"}:null},scanComments:function(){function commentToken(label,body,opt){var special=[\"jshint\",\"jslint\",\"members\",\"member\",\"globals\",\"global\",\"exported\"],isSpecial=!1,value=label+body,commentType=\"plain\";return opt=opt||{},opt.isMultiline&&(value+=\"*/\"),body=body.replace(/\\n/g,\" \"),\"/*\"===label&®.fallsThrough.test(body)&&(isSpecial=!0,commentType=\"falls through\"),special.forEach(function(str){if(!isSpecial&&(\"//\"!==label||\"jshint\"===str)&&(\" \"===body.charAt(str.length)&&body.substr(0,str.length)===str&&(isSpecial=!0,label+=str,body=body.substr(str.length)),isSpecial||\" \"!==body.charAt(0)||\" \"!==body.charAt(str.length+1)||body.substr(1,str.length)!==str||(isSpecial=!0,label=label+\" \"+str,body=body.substr(str.length+1)),isSpecial))switch(str){case\"member\":commentType=\"members\";break;case\"global\":commentType=\"globals\";break;default:var options=body.split(\":\").map(function(v){return v.replace(/^\\s+/,\"\").replace(/\\s+$/,\"\")});if(2===options.length)switch(options[0]){case\"ignore\":switch(options[1]){case\"start\":self.ignoringLinterErrors=!0,isSpecial=!1;break;case\"end\":self.ignoringLinterErrors=!1,isSpecial=!1}}commentType=str}}),{type:Token.Comment,commentType:commentType,value:value,body:body,isSpecial:isSpecial,isMultiline:opt.isMultiline||!1,isMalformed:opt.isMalformed||!1}}var ch1=this.peek(),ch2=this.peek(1),rest=this.input.substr(2),startLine=this.line,startChar=this.char,self=this;if(\"*\"===ch1&&\"/\"===ch2)return this.trigger(\"error\",{code:\"E018\",line:startLine,character:startChar}),this.skip(2),null;if(\"/\"!==ch1||\"*\"!==ch2&&\"/\"!==ch2)return null;if(\"/\"===ch2)return this.skip(this.input.length),commentToken(\"//\",rest);var body=\"\";if(\"*\"===ch2){for(this.inComment=!0,this.skip(2);\"*\"!==this.peek()||\"/\"!==this.peek(1);)if(\"\"===this.peek()){if(body+=\"\\n\",!this.nextLine())return this.trigger(\"error\",{code:\"E017\",line:startLine,character:startChar}),this.inComment=!1,commentToken(\"/*\",body,{isMultiline:!0,isMalformed:!0})}else body+=this.peek(),this.skip();return this.skip(2),this.inComment=!1,commentToken(\"/*\",body,{isMultiline:!0})}},scanKeyword:function(){var result=/^[a-zA-Z_$][a-zA-Z0-9_$]*/.exec(this.input),keywords=[\"if\",\"in\",\"do\",\"var\",\"for\",\"new\",\"try\",\"let\",\"this\",\"else\",\"case\",\"void\",\"with\",\"enum\",\"while\",\"break\",\"catch\",\"throw\",\"const\",\"yield\",\"class\",\"super\",\"return\",\"typeof\",\"delete\",\"switch\",\"export\",\"import\",\"default\",\"finally\",\"extends\",\"function\",\"continue\",\"debugger\",\"instanceof\"];return result&&keywords.indexOf(result[0])>=0?{type:Token.Keyword,value:result[0]}:null},scanIdentifier:function(){function isNonAsciiIdentifierStart(code){return code>256}function isNonAsciiIdentifierPart(code){return code>256}function isHexDigit(str){return/^[0-9a-fA-F]$/.test(str)}function removeEscapeSequences(id){return id.replace(/\\\\u([0-9a-fA-F]{4})/g,function(m0,codepoint){return String.fromCharCode(parseInt(codepoint,16))})}var type,char,id=\"\",index=0,readUnicodeEscapeSequence=function(){if(index+=1,\"u\"!==this.peek(index))return null;var code,ch1=this.peek(index+1),ch2=this.peek(index+2),ch3=this.peek(index+3),ch4=this.peek(index+4);return isHexDigit(ch1)&&isHexDigit(ch2)&&isHexDigit(ch3)&&isHexDigit(ch4)?(code=parseInt(ch1+ch2+ch3+ch4,16),asciiIdentifierPartTable[code]||isNonAsciiIdentifierPart(code)?(index+=5,\"\\\\u\"+ch1+ch2+ch3+ch4):null):null}.bind(this),getIdentifierStart=function(){var chr=this.peek(index),code=chr.charCodeAt(0);return 92===code?readUnicodeEscapeSequence():128>code?asciiIdentifierStartTable[code]?(index+=1,chr):null:isNonAsciiIdentifierStart(code)?(index+=1,chr):null}.bind(this),getIdentifierPart=function(){var chr=this.peek(index),code=chr.charCodeAt(0);return 92===code?readUnicodeEscapeSequence():128>code?asciiIdentifierPartTable[code]?(index+=1,chr):null:isNonAsciiIdentifierPart(code)?(index+=1,chr):null}.bind(this);if(char=getIdentifierStart(),null===char)return null;for(id=char;char=getIdentifierPart(),null!==char;)id+=char;switch(id){case\"true\":case\"false\":type=Token.BooleanLiteral;break;case\"null\":type=Token.NullLiteral;break;default:type=Token.Identifier}return{type:type,value:removeEscapeSequences(id),text:id,tokenLength:id.length}},scanNumericLiteral:function(){function isDecimalDigit(str){return/^[0-9]$/.test(str)}function isOctalDigit(str){return/^[0-7]$/.test(str)}function isBinaryDigit(str){return/^[01]$/.test(str)}function isHexDigit(str){return/^[0-9a-fA-F]$/.test(str)}function isIdentifierStart(ch){return\"$\"===ch||\"_\"===ch||\"\\\\\"===ch||ch>=\"a\"&&\"z\">=ch||ch>=\"A\"&&\"Z\">=ch}var bad,index=0,value=\"\",length=this.input.length,char=this.peek(index),isAllowedDigit=isDecimalDigit,base=10,isLegacy=!1;if(\".\"!==char&&!isDecimalDigit(char))return null;if(\".\"!==char){for(value=this.peek(index),index+=1,char=this.peek(index),\"0\"===value&&((\"x\"===char||\"X\"===char)&&(isAllowedDigit=isHexDigit,base=16,index+=1,value+=char),(\"o\"===char||\"O\"===char)&&(isAllowedDigit=isOctalDigit,base=8,state.inES6(!0)||this.trigger(\"warning\",{code:\"W119\",line:this.line,character:this.char,data:[\"Octal integer literal\",\"6\"]}),index+=1,value+=char),(\"b\"===char||\"B\"===char)&&(isAllowedDigit=isBinaryDigit,base=2,state.inES6(!0)||this.trigger(\"warning\",{code:\"W119\",line:this.line,character:this.char,data:[\"Binary integer literal\",\"6\"]}),index+=1,value+=char),isOctalDigit(char)&&(isAllowedDigit=isOctalDigit,base=8,isLegacy=!0,bad=!1,index+=1,value+=char),!isOctalDigit(char)&&isDecimalDigit(char)&&(index+=1,value+=char));length>index;){if(char=this.peek(index),isLegacy&&isDecimalDigit(char))bad=!0;else if(!isAllowedDigit(char))break;value+=char,index+=1}if(isAllowedDigit!==isDecimalDigit)return!isLegacy&&2>=value.length?{type:Token.NumericLiteral,value:value,isMalformed:!0}:length>index&&(char=this.peek(index),isIdentifierStart(char))?null:{type:Token.NumericLiteral,value:value,base:base,isLegacy:isLegacy,isMalformed:!1}}if(\".\"===char)for(value+=char,index+=1;length>index&&(char=this.peek(index),isDecimalDigit(char));)value+=char,index+=1;if(\"e\"===char||\"E\"===char){if(value+=char,index+=1,char=this.peek(index),(\"+\"===char||\"-\"===char)&&(value+=this.peek(index),index+=1),char=this.peek(index),!isDecimalDigit(char))return null;for(value+=char,index+=1;length>index&&(char=this.peek(index),isDecimalDigit(char));)value+=char,index+=1}return length>index&&(char=this.peek(index),isIdentifierStart(char))?null:{type:Token.NumericLiteral,value:value,base:base,isMalformed:!isFinite(value)}},scanEscapeSequence:function(checks){var allowNewLine=!1,jump=1;this.skip();var char=this.peek();switch(char){case\"'\":this.triggerAsync(\"warning\",{code:\"W114\",line:this.line,character:this.char,data:[\"\\\\'\"]},checks,function(){return state.jsonMode});break;case\"b\":char=\"\\\\b\";break;case\"f\":char=\"\\\\f\";break;case\"n\":char=\"\\\\n\";break;case\"r\":char=\"\\\\r\";break;case\"t\":char=\"\\\\t\";break;case\"0\":char=\"\\\\0\";var n=parseInt(this.peek(1),10);this.triggerAsync(\"warning\",{code:\"W115\",line:this.line,character:this.char},checks,function(){return n>=0&&7>=n&&state.isStrict()});break;case\"u\":var hexCode=this.input.substr(1,4),code=parseInt(hexCode,16);isNaN(code)&&this.trigger(\"warning\",{code:\"W052\",line:this.line,character:this.char,data:[\"u\"+hexCode]}),char=String.fromCharCode(code),jump=5;break;case\"v\":this.triggerAsync(\"warning\",{code:\"W114\",line:this.line,character:this.char,data:[\"\\\\v\"]},checks,function(){return state.jsonMode}),char=\"\u000b\";break;case\"x\":var x=parseInt(this.input.substr(1,2),16);this.triggerAsync(\"warning\",{code:\"W114\",line:this.line,character:this.char,data:[\"\\\\x-\"]},checks,function(){return state.jsonMode}),char=String.fromCharCode(x),jump=3;break;case\"\\\\\":char=\"\\\\\\\\\";break;case'\"':char='\\\\\"';break;case\"/\":break;case\"\":allowNewLine=!0,char=\"\"}return{\"char\":char,jump:jump,allowNewLine:allowNewLine}},scanTemplateLiteral:function(checks){var tokenType,ch,value=\"\",startLine=this.line,startChar=this.char,depth=this.templateStarts.length;if(!state.inES6(!0))return null;if(\"`\"===this.peek())tokenType=Token.TemplateHead,this.templateStarts.push({line:this.line,\"char\":this.char}),depth=this.templateStarts.length,this.skip(1),this.pushContext(Context.Template);else{if(!this.inContext(Context.Template)||\"}\"!==this.peek())return null;tokenType=Token.TemplateMiddle}for(;\"`\"!==this.peek();){for(;\"\"===(ch=this.peek());)if(value+=\"\\n\",!this.nextLine()){var startPos=this.templateStarts.pop();return this.trigger(\"error\",{code:\"E052\",line:startPos.line,character:startPos.char}),{type:tokenType,value:value,startLine:startLine,startChar:startChar,isUnclosed:!0,depth:depth,context:this.popContext()}}if(\"$\"===ch&&\"{\"===this.peek(1))return value+=\"${\",this.skip(2),{type:tokenType,value:value,startLine:startLine,startChar:startChar,isUnclosed:!1,depth:depth,context:this.currentContext()};\nif(\"\\\\\"===ch){var escape=this.scanEscapeSequence(checks);value+=escape.char,this.skip(escape.jump)}else\"`\"!==ch&&(value+=ch,this.skip(1))}return tokenType=tokenType===Token.TemplateHead?Token.NoSubstTemplate:Token.TemplateTail,this.skip(1),this.templateStarts.pop(),{type:tokenType,value:value,startLine:startLine,startChar:startChar,isUnclosed:!1,depth:depth,context:this.popContext()}},scanStringLiteral:function(checks){var quote=this.peek();if('\"'!==quote&&\"'\"!==quote)return null;this.triggerAsync(\"warning\",{code:\"W108\",line:this.line,character:this.char},checks,function(){return state.jsonMode&&'\"'!==quote});var value=\"\",startLine=this.line,startChar=this.char,allowNewLine=!1;for(this.skip();this.peek()!==quote;)if(\"\"===this.peek()){if(allowNewLine?(allowNewLine=!1,this.triggerAsync(\"warning\",{code:\"W043\",line:this.line,character:this.char},checks,function(){return!state.option.multistr}),this.triggerAsync(\"warning\",{code:\"W042\",line:this.line,character:this.char},checks,function(){return state.jsonMode&&state.option.multistr})):this.trigger(\"warning\",{code:\"W112\",line:this.line,character:this.char}),!this.nextLine())return this.trigger(\"error\",{code:\"E029\",line:startLine,character:startChar}),{type:Token.StringLiteral,value:value,startLine:startLine,startChar:startChar,isUnclosed:!0,quote:quote}}else{allowNewLine=!1;var char=this.peek(),jump=1;if(\" \">char&&this.trigger(\"warning\",{code:\"W113\",line:this.line,character:this.char,data:[\"\"]}),\"\\\\\"===char){var parsed=this.scanEscapeSequence(checks);char=parsed.char,jump=parsed.jump,allowNewLine=parsed.allowNewLine}value+=char,this.skip(jump)}return this.skip(),{type:Token.StringLiteral,value:value,startLine:startLine,startChar:startChar,isUnclosed:!1,quote:quote}},scanRegExp:function(){var terminated,index=0,length=this.input.length,char=this.peek(),value=char,body=\"\",flags=[],malformed=!1,isCharSet=!1,scanUnexpectedChars=function(){\" \">char&&(malformed=!0,this.trigger(\"warning\",{code:\"W048\",line:this.line,character:this.char})),\"<\"===char&&(malformed=!0,this.trigger(\"warning\",{code:\"W049\",line:this.line,character:this.char,data:[char]}))}.bind(this);if(!this.prereg||\"/\"!==char)return null;for(index+=1,terminated=!1;length>index;)if(char=this.peek(index),value+=char,body+=char,isCharSet)\"]\"===char&&(\"\\\\\"!==this.peek(index-1)||\"\\\\\"===this.peek(index-2))&&(isCharSet=!1),\"\\\\\"===char&&(index+=1,char=this.peek(index),body+=char,value+=char,scanUnexpectedChars()),index+=1;else{if(\"\\\\\"===char){if(index+=1,char=this.peek(index),body+=char,value+=char,scanUnexpectedChars(),\"/\"===char){index+=1;continue}if(\"[\"===char){index+=1;continue}}if(\"[\"!==char){if(\"/\"===char){body=body.substr(0,body.length-1),terminated=!0,index+=1;break}index+=1}else isCharSet=!0,index+=1}if(!terminated)return this.trigger(\"error\",{code:\"E015\",line:this.line,character:this.from}),void this.trigger(\"fatal\",{line:this.line,from:this.from});for(;length>index&&(char=this.peek(index),/[gim]/.test(char));)flags.push(char),value+=char,index+=1;try{RegExp(body,flags.join(\"\"))}catch(err){malformed=!0,this.trigger(\"error\",{code:\"E016\",line:this.line,character:this.char,data:[err.message]})}return{type:Token.RegExp,value:value,flags:flags,isMalformed:malformed}},scanNonBreakingSpaces:function(){return state.option.nonbsp?this.input.search(/(\\u00A0)/):-1},scanUnsafeChars:function(){return this.input.search(reg.unsafeChars)},next:function(checks){this.from=this.char;var start;if(/\\s/.test(this.peek()))for(start=this.char;/\\s/.test(this.peek());)this.from+=1,this.skip();var match=this.scanComments()||this.scanStringLiteral(checks)||this.scanTemplateLiteral(checks);return match?match:(match=this.scanRegExp()||this.scanPunctuator()||this.scanKeyword()||this.scanIdentifier()||this.scanNumericLiteral(),match?(this.skip(match.tokenLength||match.value.length),match):null)},nextLine:function(){var char;if(this.line>=this.getLines().length)return!1;this.input=this.getLines()[this.line],this.line+=1,this.char=1,this.from=1;var inputTrimmed=this.input.trim(),startsWith=function(){return _.some(arguments,function(prefix){return 0===inputTrimmed.indexOf(prefix)})},endsWith=function(){return _.some(arguments,function(suffix){return-1!==inputTrimmed.indexOf(suffix,inputTrimmed.length-suffix.length)})};if(this.ignoringLinterErrors===!0&&(startsWith(\"/*\",\"//\")||this.inComment&&endsWith(\"*/\")||(this.input=\"\")),char=this.scanNonBreakingSpaces(),char>=0&&this.trigger(\"warning\",{code:\"W125\",line:this.line,character:char+1}),this.input=this.input.replace(/\\t/g,state.tab),char=this.scanUnsafeChars(),char>=0&&this.trigger(\"warning\",{code:\"W100\",line:this.line,character:char}),!this.ignoringLinterErrors&&state.option.maxlen&&state.option.maxlen=0;--i){var scopeLabels=_scopeStack[i][\"(labels)\"];if(scopeLabels[labelName])return scopeLabels}}function usedSoFarInCurrentFunction(labelName){for(var i=_scopeStack.length-1;i>=0;i--){var current=_scopeStack[i];if(current[\"(usages)\"][labelName])return current[\"(usages)\"][labelName];if(current===_currentFunctBody)break}return!1}function _checkOuterShadow(labelName,token){if(\"outer\"===state.option.shadow)for(var isGlobal=\"global\"===_currentFunctBody[\"(type)\"],isNewFunction=\"functionparams\"===_current[\"(type)\"],outsideCurrentFunction=!isGlobal,i=0;_scopeStack.length>i;i++){var stackItem=_scopeStack[i];isNewFunction||_scopeStack[i+1]!==_currentFunctBody||(outsideCurrentFunction=!1),outsideCurrentFunction&&stackItem[\"(labels)\"][labelName]&&warning(\"W123\",token,labelName),stackItem[\"(breakLabels)\"][labelName]&&warning(\"W123\",token,labelName)}}function _latedefWarning(type,labelName,token){state.option.latedef&&(state.option.latedef===!0&&\"function\"===type||\"function\"!==type)&&warning(\"W003\",token,labelName)}var _current,_scopeStack=[];_newScope(\"global\"),_current[\"(predefined)\"]=predefined;var _currentFunctBody=_current,usedPredefinedAndGlobals=Object.create(null),impliedGlobals=Object.create(null),unuseds=[],emitter=new events.EventEmitter,_getUnusedOption=function(unused_opt){return void 0===unused_opt&&(unused_opt=state.option.unused),unused_opt===!0&&(unused_opt=\"last-param\"),unused_opt},_warnUnused=function(name,tkn,type,unused_opt){var line=tkn.line,chr=tkn.from,raw_name=tkn.raw_text||name;unused_opt=_getUnusedOption(unused_opt);var warnable_types={vars:[\"var\"],\"last-param\":[\"var\",\"param\"],strict:[\"var\",\"param\",\"last-param\"]};unused_opt&&warnable_types[unused_opt]&&-1!==warnable_types[unused_opt].indexOf(type)&&warning(\"W098\",{line:line,from:chr},raw_name),(unused_opt||\"var\"===type)&&unuseds.push({name:name,line:line,character:chr})},scopeManagerInst={on:function(names,listener){names.split(\" \").forEach(function(name){emitter.on(name,listener)})},isPredefined:function(labelName){return!this.has(labelName)&&_.has(_scopeStack[0][\"(predefined)\"],labelName)},stack:function(type){var previousScope=_current;_newScope(type),type||\"functionparams\"!==previousScope[\"(type)\"]||(_current[\"(isFuncBody)\"]=!0,_current[\"(context)\"]=_currentFunctBody,_currentFunctBody=_current)},unstack:function(){var i,j,subScope=_scopeStack.length>1?_scopeStack[_scopeStack.length-2]:null,isUnstackingFunctionBody=_current===_currentFunctBody,isUnstackingFunctionParams=\"functionparams\"===_current[\"(type)\"],isUnstackingFunctionOuter=\"functionouter\"===_current[\"(type)\"],currentUsages=_current[\"(usages)\"],currentLabels=_current[\"(labels)\"],usedLabelNameList=Object.keys(currentUsages);for(currentUsages.__proto__&&-1===usedLabelNameList.indexOf(\"__proto__\")&&usedLabelNameList.push(\"__proto__\"),i=0;usedLabelNameList.length>i;i++){var usedLabelName=usedLabelNameList[i],usage=currentUsages[usedLabelName],usedLabel=currentLabels[usedLabelName];if(usedLabel){var usedLabelType=usedLabel[\"(type)\"];if(usedLabel[\"(useOutsideOfScope)\"]&&!state.option.funcscope){var usedTokens=usage[\"(tokens)\"];if(usedTokens)for(j=0;usedTokens.length>j;j++)usedLabel[\"(function)\"]===usedTokens[j][\"(function)\"]&&error(\"W038\",usedTokens[j],usedLabelName)}if(_current[\"(labels)\"][usedLabelName][\"(unused)\"]=!1,\"const\"===usedLabelType&&usage[\"(modified)\"])for(j=0;usage[\"(modified)\"].length>j;j++)error(\"E013\",usage[\"(modified)\"][j],usedLabelName);if((\"function\"===usedLabelType||\"class\"===usedLabelType)&&usage[\"(reassigned)\"])for(j=0;usage[\"(reassigned)\"].length>j;j++)error(\"W021\",usage[\"(reassigned)\"][j],usedLabelName,usedLabelType)}else if(isUnstackingFunctionOuter&&(state.funct[\"(isCapturing)\"]=!0),subScope)if(subScope[\"(usages)\"][usedLabelName]){var subScopeUsage=subScope[\"(usages)\"][usedLabelName];subScopeUsage[\"(modified)\"]=subScopeUsage[\"(modified)\"].concat(usage[\"(modified)\"]),subScopeUsage[\"(tokens)\"]=subScopeUsage[\"(tokens)\"].concat(usage[\"(tokens)\"]),subScopeUsage[\"(reassigned)\"]=subScopeUsage[\"(reassigned)\"].concat(usage[\"(reassigned)\"]),subScopeUsage[\"(onlyUsedSubFunction)\"]=!1}else subScope[\"(usages)\"][usedLabelName]=usage,isUnstackingFunctionBody&&(subScope[\"(usages)\"][usedLabelName][\"(onlyUsedSubFunction)\"]=!0);else if(\"boolean\"==typeof _current[\"(predefined)\"][usedLabelName]){if(delete declared[usedLabelName],usedPredefinedAndGlobals[usedLabelName]=marker,_current[\"(predefined)\"][usedLabelName]===!1&&usage[\"(reassigned)\"])for(j=0;usage[\"(reassigned)\"].length>j;j++)warning(\"W020\",usage[\"(reassigned)\"][j])}else if(usage[\"(tokens)\"])for(j=0;usage[\"(tokens)\"].length>j;j++){var undefinedToken=usage[\"(tokens)\"][j];undefinedToken.forgiveUndef||(state.option.undef&&!undefinedToken.ignoreUndef&&warning(\"W117\",undefinedToken,usedLabelName),impliedGlobals[usedLabelName]?impliedGlobals[usedLabelName].line.push(undefinedToken.line):impliedGlobals[usedLabelName]={name:usedLabelName,line:[undefinedToken.line]})}}if(subScope||Object.keys(declared).forEach(function(labelNotUsed){_warnUnused(labelNotUsed,declared[labelNotUsed],\"var\")}),subScope&&!isUnstackingFunctionBody&&!isUnstackingFunctionParams&&!isUnstackingFunctionOuter){var labelNames=Object.keys(currentLabels);for(i=0;labelNames.length>i;i++){var defLabelName=labelNames[i];currentLabels[defLabelName][\"(blockscoped)\"]||\"exception\"===currentLabels[defLabelName][\"(type)\"]||this.funct.has(defLabelName,{excludeCurrent:!0})||(subScope[\"(labels)\"][defLabelName]=currentLabels[defLabelName],\"global\"!==_currentFunctBody[\"(type)\"]&&(subScope[\"(labels)\"][defLabelName][\"(useOutsideOfScope)\"]=!0),delete currentLabels[defLabelName])}}_checkForUnused(),_scopeStack.pop(),isUnstackingFunctionBody&&(_currentFunctBody=_scopeStack[_.findLastIndex(_scopeStack,function(scope){return scope[\"(isFuncBody)\"]||\"global\"===scope[\"(type)\"]})]),_current=subScope},addParam:function(labelName,token,type){if(type=type||\"param\",\"exception\"===type){var previouslyDefinedLabelType=this.funct.labeltype(labelName);previouslyDefinedLabelType&&\"exception\"!==previouslyDefinedLabelType&&(state.option.node||warning(\"W002\",state.tokens.next,labelName))}if(_.has(_current[\"(labels)\"],labelName)?_current[\"(labels)\"][labelName].duplicated=!0:(_checkOuterShadow(labelName,token,type),_current[\"(labels)\"][labelName]={\"(type)\":type,\"(token)\":token,\"(unused)\":!0},_current[\"(params)\"].push(labelName)),_.has(_current[\"(usages)\"],labelName)){var usage=_current[\"(usages)\"][labelName];usage[\"(onlyUsedSubFunction)\"]?_latedefWarning(type,labelName,token):warning(\"E056\",token,labelName,type)}},validateParams:function(){if(\"global\"!==_currentFunctBody[\"(type)\"]){var isStrict=state.isStrict(),currentFunctParamScope=_currentFunctBody[\"(parent)\"];currentFunctParamScope[\"(params)\"]&¤tFunctParamScope[\"(params)\"].forEach(function(labelName){var label=currentFunctParamScope[\"(labels)\"][labelName];label&&label.duplicated&&(isStrict?warning(\"E011\",label[\"(token)\"],labelName):state.option.shadow!==!0&&warning(\"W004\",label[\"(token)\"],labelName))})}},getUsedOrDefinedGlobals:function(){var list=Object.keys(usedPredefinedAndGlobals);return usedPredefinedAndGlobals.__proto__===marker&&-1===list.indexOf(\"__proto__\")&&list.push(\"__proto__\"),list},getImpliedGlobals:function(){var values=_.values(impliedGlobals),hasProto=!1;return impliedGlobals.__proto__&&(hasProto=values.some(function(value){return\"__proto__\"===value.name}),hasProto||values.push(impliedGlobals.__proto__)),values},getUnuseds:function(){return unuseds},has:function(labelName){return Boolean(_getLabel(labelName))},labeltype:function(labelName){var scopeLabels=_getLabel(labelName);return scopeLabels?scopeLabels[labelName][\"(type)\"]:null},addExported:function(labelName){var globalLabels=_scopeStack[0][\"(labels)\"];if(_.has(declared,labelName))delete declared[labelName];else if(_.has(globalLabels,labelName))globalLabels[labelName][\"(unused)\"]=!1;else{for(var i=1;_scopeStack.length>i;i++){var scope=_scopeStack[i];if(scope[\"(type)\"])break;if(_.has(scope[\"(labels)\"],labelName)&&!scope[\"(labels)\"][labelName][\"(blockscoped)\"])return scope[\"(labels)\"][labelName][\"(unused)\"]=!1,void 0}exported[labelName]=!0}},setExported:function(labelName,token){this.block.use(labelName,token)\n},addlabel:function(labelName,opts){var type=opts.type,token=opts.token,isblockscoped=\"let\"===type||\"const\"===type||\"class\"===type,isexported=\"global\"===(isblockscoped?_current:_currentFunctBody)[\"(type)\"]&&_.has(exported,labelName);if(_checkOuterShadow(labelName,token,type),isblockscoped){var declaredInCurrentScope=_current[\"(labels)\"][labelName];if(declaredInCurrentScope||_current!==_currentFunctBody||\"global\"===_current[\"(type)\"]||(declaredInCurrentScope=!!_currentFunctBody[\"(parent)\"][\"(labels)\"][labelName]),!declaredInCurrentScope&&_current[\"(usages)\"][labelName]){var usage=_current[\"(usages)\"][labelName];usage[\"(onlyUsedSubFunction)\"]?_latedefWarning(type,labelName,token):warning(\"E056\",token,labelName,type)}declaredInCurrentScope?warning(\"E011\",token,labelName):\"outer\"===state.option.shadow&&scopeManagerInst.funct.has(labelName)&&warning(\"W004\",token,labelName),scopeManagerInst.block.add(labelName,type,token,!isexported)}else{var declaredInCurrentFunctionScope=scopeManagerInst.funct.has(labelName);!declaredInCurrentFunctionScope&&usedSoFarInCurrentFunction(labelName)&&_latedefWarning(type,labelName,token),scopeManagerInst.funct.has(labelName,{onlyBlockscoped:!0})?warning(\"E011\",token,labelName):state.option.shadow!==!0&&declaredInCurrentFunctionScope&&\"__proto__\"!==labelName&&\"global\"!==_currentFunctBody[\"(type)\"]&&warning(\"W004\",token,labelName),scopeManagerInst.funct.add(labelName,type,token,!isexported),\"global\"===_currentFunctBody[\"(type)\"]&&(usedPredefinedAndGlobals[labelName]=marker)}},funct:{labeltype:function(labelName,options){for(var onlyBlockscoped=options&&options.onlyBlockscoped,excludeParams=options&&options.excludeParams,currentScopeIndex=_scopeStack.length-(options&&options.excludeCurrent?2:1),i=currentScopeIndex;i>=0;i--){var current=_scopeStack[i];if(current[\"(labels)\"][labelName]&&(!onlyBlockscoped||current[\"(labels)\"][labelName][\"(blockscoped)\"]))return current[\"(labels)\"][labelName][\"(type)\"];var scopeCheck=excludeParams?_scopeStack[i-1]:current;if(scopeCheck&&\"functionparams\"===scopeCheck[\"(type)\"])return null}return null},hasBreakLabel:function(labelName){for(var i=_scopeStack.length-1;i>=0;i--){var current=_scopeStack[i];if(current[\"(breakLabels)\"][labelName])return!0;if(\"functionparams\"===current[\"(type)\"])return!1}return!1},has:function(labelName,options){return Boolean(this.labeltype(labelName,options))},add:function(labelName,type,tok,unused){_current[\"(labels)\"][labelName]={\"(type)\":type,\"(token)\":tok,\"(blockscoped)\":!1,\"(function)\":_currentFunctBody,\"(unused)\":unused}}},block:{isGlobal:function(){return\"global\"===_current[\"(type)\"]},use:function(labelName,token){var paramScope=_currentFunctBody[\"(parent)\"];paramScope&¶mScope[\"(labels)\"][labelName]&&\"param\"===paramScope[\"(labels)\"][labelName][\"(type)\"]&&(scopeManagerInst.funct.has(labelName,{excludeParams:!0,onlyBlockscoped:!0})||(paramScope[\"(labels)\"][labelName][\"(unused)\"]=!1)),token&&(state.ignored.W117||state.option.undef===!1)&&(token.ignoreUndef=!0),_setupUsages(labelName),token&&(token[\"(function)\"]=_currentFunctBody,_current[\"(usages)\"][labelName][\"(tokens)\"].push(token))},reassign:function(labelName,token){this.modify(labelName,token),_current[\"(usages)\"][labelName][\"(reassigned)\"].push(token)},modify:function(labelName,token){_setupUsages(labelName),_current[\"(usages)\"][labelName][\"(modified)\"].push(token)},add:function(labelName,type,tok,unused){_current[\"(labels)\"][labelName]={\"(type)\":type,\"(token)\":tok,\"(blockscoped)\":!0,\"(unused)\":unused}},addBreakLabel:function(labelName,opts){var token=opts.token;scopeManagerInst.funct.hasBreakLabel(labelName)?warning(\"E011\",token,labelName):\"outer\"===state.option.shadow&&(scopeManagerInst.funct.has(labelName)?warning(\"W004\",token,labelName):_checkOuterShadow(labelName,token)),_current[\"(breakLabels)\"][labelName]=token}}};return scopeManagerInst};module.exports=scopeManager},{\"../lodash\":\"/node_modules/jshint/lodash.js\",events:\"/node_modules/browserify/node_modules/events/events.js\"}],\"/node_modules/jshint/src/state.js\":[function(_dereq_,module,exports){\"use strict\";var NameStack=_dereq_(\"./name-stack.js\"),state={syntax:{},isStrict:function(){return this.directive[\"use strict\"]||this.inClassBody||this.option.module||\"implied\"===this.option.strict},inMoz:function(){return this.option.moz},inES6:function(){return this.option.moz||this.option.esversion>=6},inES5:function(strict){return strict?!(this.option.esversion&&5!==this.option.esversion||this.option.moz):!this.option.esversion||this.option.esversion>=5||this.option.moz},reset:function(){this.tokens={prev:null,next:null,curr:null},this.option={},this.funct=null,this.ignored={},this.directive={},this.jsonMode=!1,this.jsonWarnings=[],this.lines=[],this.tab=\"\",this.cache={},this.ignoredLines={},this.forinifcheckneeded=!1,this.nameStack=new NameStack,this.inClassBody=!1}};exports.state=state},{\"./name-stack.js\":\"/node_modules/jshint/src/name-stack.js\"}],\"/node_modules/jshint/src/style.js\":[function(_dereq_,module,exports){\"use strict\";exports.register=function(linter){linter.on(\"Identifier\",function(data){linter.getOption(\"proto\")||\"__proto__\"===data.name&&linter.warn(\"W103\",{line:data.line,\"char\":data.char,data:[data.name,\"6\"]})}),linter.on(\"Identifier\",function(data){linter.getOption(\"iterator\")||\"__iterator__\"===data.name&&linter.warn(\"W103\",{line:data.line,\"char\":data.char,data:[data.name]})}),linter.on(\"Identifier\",function(data){linter.getOption(\"camelcase\")&&data.name.replace(/^_+|_+$/g,\"\").indexOf(\"_\")>-1&&!data.name.match(/^[A-Z0-9_]*$/)&&linter.warn(\"W106\",{line:data.line,\"char\":data.from,data:[data.name]})}),linter.on(\"String\",function(data){var code,quotmark=linter.getOption(\"quotmark\");quotmark&&(\"single\"===quotmark&&\"'\"!==data.quote&&(code=\"W109\"),\"double\"===quotmark&&'\"'!==data.quote&&(code=\"W108\"),quotmark===!0&&(linter.getCache(\"quotmark\")||linter.setCache(\"quotmark\",data.quote),linter.getCache(\"quotmark\")!==data.quote&&(code=\"W110\")),code&&linter.warn(code,{line:data.line,\"char\":data.char}))}),linter.on(\"Number\",function(data){\".\"===data.value.charAt(0)&&linter.warn(\"W008\",{line:data.line,\"char\":data.char,data:[data.value]}),\".\"===data.value.substr(data.value.length-1)&&linter.warn(\"W047\",{line:data.line,\"char\":data.char,data:[data.value]}),/^00+/.test(data.value)&&linter.warn(\"W046\",{line:data.line,\"char\":data.char,data:[data.value]})}),linter.on(\"String\",function(data){var re=/^(?:javascript|jscript|ecmascript|vbscript|livescript)\\s*:/i;linter.getOption(\"scripturl\")||re.test(data.value)&&linter.warn(\"W107\",{line:data.line,\"char\":data.char})})}},{}],\"/node_modules/jshint/src/vars.js\":[function(_dereq_,module,exports){\"use strict\";exports.reservedVars={arguments:!1,NaN:!1},exports.ecmaIdentifiers={3:{Array:!1,Boolean:!1,Date:!1,decodeURI:!1,decodeURIComponent:!1,encodeURI:!1,encodeURIComponent:!1,Error:!1,eval:!1,EvalError:!1,Function:!1,hasOwnProperty:!1,isFinite:!1,isNaN:!1,Math:!1,Number:!1,Object:!1,parseInt:!1,parseFloat:!1,RangeError:!1,ReferenceError:!1,RegExp:!1,String:!1,SyntaxError:!1,TypeError:!1,URIError:!1},5:{JSON:!1},6:{Map:!1,Promise:!1,Proxy:!1,Reflect:!1,Set:!1,Symbol:!1,WeakMap:!1,WeakSet:!1}},exports.browser={Audio:!1,Blob:!1,addEventListener:!1,applicationCache:!1,atob:!1,blur:!1,btoa:!1,cancelAnimationFrame:!1,CanvasGradient:!1,CanvasPattern:!1,CanvasRenderingContext2D:!1,CSS:!1,clearInterval:!1,clearTimeout:!1,close:!1,closed:!1,Comment:!1,CustomEvent:!1,DOMParser:!1,defaultStatus:!1,Document:!1,document:!1,DocumentFragment:!1,Element:!1,ElementTimeControl:!1,Event:!1,event:!1,fetch:!1,FileReader:!1,FormData:!1,focus:!1,frames:!1,getComputedStyle:!1,HTMLElement:!1,HTMLAnchorElement:!1,HTMLBaseElement:!1,HTMLBlockquoteElement:!1,HTMLBodyElement:!1,HTMLBRElement:!1,HTMLButtonElement:!1,HTMLCanvasElement:!1,HTMLCollection:!1,HTMLDirectoryElement:!1,HTMLDivElement:!1,HTMLDListElement:!1,HTMLFieldSetElement:!1,HTMLFontElement:!1,HTMLFormElement:!1,HTMLFrameElement:!1,HTMLFrameSetElement:!1,HTMLHeadElement:!1,HTMLHeadingElement:!1,HTMLHRElement:!1,HTMLHtmlElement:!1,HTMLIFrameElement:!1,HTMLImageElement:!1,HTMLInputElement:!1,HTMLIsIndexElement:!1,HTMLLabelElement:!1,HTMLLayerElement:!1,HTMLLegendElement:!1,HTMLLIElement:!1,HTMLLinkElement:!1,HTMLMapElement:!1,HTMLMenuElement:!1,HTMLMetaElement:!1,HTMLModElement:!1,HTMLObjectElement:!1,HTMLOListElement:!1,HTMLOptGroupElement:!1,HTMLOptionElement:!1,HTMLParagraphElement:!1,HTMLParamElement:!1,HTMLPreElement:!1,HTMLQuoteElement:!1,HTMLScriptElement:!1,HTMLSelectElement:!1,HTMLStyleElement:!1,HTMLTableCaptionElement:!1,HTMLTableCellElement:!1,HTMLTableColElement:!1,HTMLTableElement:!1,HTMLTableRowElement:!1,HTMLTableSectionElement:!1,HTMLTemplateElement:!1,HTMLTextAreaElement:!1,HTMLTitleElement:!1,HTMLUListElement:!1,HTMLVideoElement:!1,history:!1,Image:!1,Intl:!1,length:!1,localStorage:!1,location:!1,matchMedia:!1,MessageChannel:!1,MessageEvent:!1,MessagePort:!1,MouseEvent:!1,moveBy:!1,moveTo:!1,MutationObserver:!1,name:!1,Node:!1,NodeFilter:!1,NodeList:!1,Notification:!1,navigator:!1,onbeforeunload:!0,onblur:!0,onerror:!0,onfocus:!0,onload:!0,onresize:!0,onunload:!0,open:!1,openDatabase:!1,opener:!1,Option:!1,parent:!1,performance:!1,print:!1,Range:!1,requestAnimationFrame:!1,removeEventListener:!1,resizeBy:!1,resizeTo:!1,screen:!1,scroll:!1,scrollBy:!1,scrollTo:!1,sessionStorage:!1,setInterval:!1,setTimeout:!1,SharedWorker:!1,status:!1,SVGAElement:!1,SVGAltGlyphDefElement:!1,SVGAltGlyphElement:!1,SVGAltGlyphItemElement:!1,SVGAngle:!1,SVGAnimateColorElement:!1,SVGAnimateElement:!1,SVGAnimateMotionElement:!1,SVGAnimateTransformElement:!1,SVGAnimatedAngle:!1,SVGAnimatedBoolean:!1,SVGAnimatedEnumeration:!1,SVGAnimatedInteger:!1,SVGAnimatedLength:!1,SVGAnimatedLengthList:!1,SVGAnimatedNumber:!1,SVGAnimatedNumberList:!1,SVGAnimatedPathData:!1,SVGAnimatedPoints:!1,SVGAnimatedPreserveAspectRatio:!1,SVGAnimatedRect:!1,SVGAnimatedString:!1,SVGAnimatedTransformList:!1,SVGAnimationElement:!1,SVGCSSRule:!1,SVGCircleElement:!1,SVGClipPathElement:!1,SVGColor:!1,SVGColorProfileElement:!1,SVGColorProfileRule:!1,SVGComponentTransferFunctionElement:!1,SVGCursorElement:!1,SVGDefsElement:!1,SVGDescElement:!1,SVGDocument:!1,SVGElement:!1,SVGElementInstance:!1,SVGElementInstanceList:!1,SVGEllipseElement:!1,SVGExternalResourcesRequired:!1,SVGFEBlendElement:!1,SVGFEColorMatrixElement:!1,SVGFEComponentTransferElement:!1,SVGFECompositeElement:!1,SVGFEConvolveMatrixElement:!1,SVGFEDiffuseLightingElement:!1,SVGFEDisplacementMapElement:!1,SVGFEDistantLightElement:!1,SVGFEFloodElement:!1,SVGFEFuncAElement:!1,SVGFEFuncBElement:!1,SVGFEFuncGElement:!1,SVGFEFuncRElement:!1,SVGFEGaussianBlurElement:!1,SVGFEImageElement:!1,SVGFEMergeElement:!1,SVGFEMergeNodeElement:!1,SVGFEMorphologyElement:!1,SVGFEOffsetElement:!1,SVGFEPointLightElement:!1,SVGFESpecularLightingElement:!1,SVGFESpotLightElement:!1,SVGFETileElement:!1,SVGFETurbulenceElement:!1,SVGFilterElement:!1,SVGFilterPrimitiveStandardAttributes:!1,SVGFitToViewBox:!1,SVGFontElement:!1,SVGFontFaceElement:!1,SVGFontFaceFormatElement:!1,SVGFontFaceNameElement:!1,SVGFontFaceSrcElement:!1,SVGFontFaceUriElement:!1,SVGForeignObjectElement:!1,SVGGElement:!1,SVGGlyphElement:!1,SVGGlyphRefElement:!1,SVGGradientElement:!1,SVGHKernElement:!1,SVGICCColor:!1,SVGImageElement:!1,SVGLangSpace:!1,SVGLength:!1,SVGLengthList:!1,SVGLineElement:!1,SVGLinearGradientElement:!1,SVGLocatable:!1,SVGMPathElement:!1,SVGMarkerElement:!1,SVGMaskElement:!1,SVGMatrix:!1,SVGMetadataElement:!1,SVGMissingGlyphElement:!1,SVGNumber:!1,SVGNumberList:!1,SVGPaint:!1,SVGPathElement:!1,SVGPathSeg:!1,SVGPathSegArcAbs:!1,SVGPathSegArcRel:!1,SVGPathSegClosePath:!1,SVGPathSegCurvetoCubicAbs:!1,SVGPathSegCurvetoCubicRel:!1,SVGPathSegCurvetoCubicSmoothAbs:!1,SVGPathSegCurvetoCubicSmoothRel:!1,SVGPathSegCurvetoQuadraticAbs:!1,SVGPathSegCurvetoQuadraticRel:!1,SVGPathSegCurvetoQuadraticSmoothAbs:!1,SVGPathSegCurvetoQuadraticSmoothRel:!1,SVGPathSegLinetoAbs:!1,SVGPathSegLinetoHorizontalAbs:!1,SVGPathSegLinetoHorizontalRel:!1,SVGPathSegLinetoRel:!1,SVGPathSegLinetoVerticalAbs:!1,SVGPathSegLinetoVerticalRel:!1,SVGPathSegList:!1,SVGPathSegMovetoAbs:!1,SVGPathSegMovetoRel:!1,SVGPatternElement:!1,SVGPoint:!1,SVGPointList:!1,SVGPolygonElement:!1,SVGPolylineElement:!1,SVGPreserveAspectRatio:!1,SVGRadialGradientElement:!1,SVGRect:!1,SVGRectElement:!1,SVGRenderingIntent:!1,SVGSVGElement:!1,SVGScriptElement:!1,SVGSetElement:!1,SVGStopElement:!1,SVGStringList:!1,SVGStylable:!1,SVGStyleElement:!1,SVGSwitchElement:!1,SVGSymbolElement:!1,SVGTRefElement:!1,SVGTSpanElement:!1,SVGTests:!1,SVGTextContentElement:!1,SVGTextElement:!1,SVGTextPathElement:!1,SVGTextPositioningElement:!1,SVGTitleElement:!1,SVGTransform:!1,SVGTransformList:!1,SVGTransformable:!1,SVGURIReference:!1,SVGUnitTypes:!1,SVGUseElement:!1,SVGVKernElement:!1,SVGViewElement:!1,SVGViewSpec:!1,SVGZoomAndPan:!1,Text:!1,TextDecoder:!1,TextEncoder:!1,TimeEvent:!1,top:!1,URL:!1,WebGLActiveInfo:!1,WebGLBuffer:!1,WebGLContextEvent:!1,WebGLFramebuffer:!1,WebGLProgram:!1,WebGLRenderbuffer:!1,WebGLRenderingContext:!1,WebGLShader:!1,WebGLShaderPrecisionFormat:!1,WebGLTexture:!1,WebGLUniformLocation:!1,WebSocket:!1,window:!1,Window:!1,Worker:!1,XDomainRequest:!1,XMLHttpRequest:!1,XMLSerializer:!1,XPathEvaluator:!1,XPathException:!1,XPathExpression:!1,XPathNamespace:!1,XPathNSResolver:!1,XPathResult:!1},exports.devel={alert:!1,confirm:!1,console:!1,Debug:!1,opera:!1,prompt:!1},exports.worker={importScripts:!0,postMessage:!0,self:!0,FileReaderSync:!0},exports.nonstandard={escape:!1,unescape:!1},exports.couch={require:!1,respond:!1,getRow:!1,emit:!1,send:!1,start:!1,sum:!1,log:!1,exports:!1,module:!1,provides:!1},exports.node={__filename:!1,__dirname:!1,GLOBAL:!1,global:!1,module:!1,acequire:!1,Buffer:!0,console:!0,exports:!0,process:!0,setTimeout:!0,clearTimeout:!0,setInterval:!0,clearInterval:!0,setImmediate:!0,clearImmediate:!0},exports.browserify={__filename:!1,__dirname:!1,global:!1,module:!1,acequire:!1,Buffer:!0,exports:!0,process:!0},exports.phantom={phantom:!0,acequire:!0,WebPage:!0,console:!0,exports:!0},exports.qunit={asyncTest:!1,deepEqual:!1,equal:!1,expect:!1,module:!1,notDeepEqual:!1,notEqual:!1,notPropEqual:!1,notStrictEqual:!1,ok:!1,propEqual:!1,QUnit:!1,raises:!1,start:!1,stop:!1,strictEqual:!1,test:!1,\"throws\":!1},exports.rhino={defineClass:!1,deserialize:!1,gc:!1,help:!1,importClass:!1,importPackage:!1,java:!1,load:!1,loadClass:!1,Packages:!1,print:!1,quit:!1,readFile:!1,readUrl:!1,runCommand:!1,seal:!1,serialize:!1,spawn:!1,sync:!1,toint32:!1,version:!1},exports.shelljs={target:!1,echo:!1,exit:!1,cd:!1,pwd:!1,ls:!1,find:!1,cp:!1,rm:!1,mv:!1,mkdir:!1,test:!1,cat:!1,sed:!1,grep:!1,which:!1,dirs:!1,pushd:!1,popd:!1,env:!1,exec:!1,chmod:!1,config:!1,error:!1,tempdir:!1},exports.typed={ArrayBuffer:!1,ArrayBufferView:!1,DataView:!1,Float32Array:!1,Float64Array:!1,Int16Array:!1,Int32Array:!1,Int8Array:!1,Uint16Array:!1,Uint32Array:!1,Uint8Array:!1,Uint8ClampedArray:!1},exports.wsh={ActiveXObject:!0,Enumerator:!0,GetObject:!0,ScriptEngine:!0,ScriptEngineBuildVersion:!0,ScriptEngineMajorVersion:!0,ScriptEngineMinorVersion:!0,VBArray:!0,WSH:!0,WScript:!0,XDomainRequest:!0},exports.dojo={dojo:!1,dijit:!1,dojox:!1,define:!1,require:!1},exports.jquery={$:!1,jQuery:!1},exports.mootools={$:!1,$$:!1,Asset:!1,Browser:!1,Chain:!1,Class:!1,Color:!1,Cookie:!1,Core:!1,Document:!1,DomReady:!1,DOMEvent:!1,DOMReady:!1,Drag:!1,Element:!1,Elements:!1,Event:!1,Events:!1,Fx:!1,Group:!1,Hash:!1,HtmlTable:!1,IFrame:!1,IframeShim:!1,InputValidator:!1,instanceOf:!1,Keyboard:!1,Locale:!1,Mask:!1,MooTools:!1,Native:!1,Options:!1,OverText:!1,Request:!1,Scroller:!1,Slick:!1,Slider:!1,Sortables:!1,Spinner:!1,Swiff:!1,Tips:!1,Type:!1,typeOf:!1,URI:!1,Window:!1},exports.prototypejs={$:!1,$$:!1,$A:!1,$F:!1,$H:!1,$R:!1,$break:!1,$continue:!1,$w:!1,Abstract:!1,Ajax:!1,Class:!1,Enumerable:!1,Element:!1,Event:!1,Field:!1,Form:!1,Hash:!1,Insertion:!1,ObjectRange:!1,PeriodicalExecuter:!1,Position:!1,Prototype:!1,Selector:!1,Template:!1,Toggle:!1,Try:!1,Autocompleter:!1,Builder:!1,Control:!1,Draggable:!1,Draggables:!1,Droppables:!1,Effect:!1,Sortable:!1,SortableObserver:!1,Sound:!1,Scriptaculous:!1},exports.yui={YUI:!1,Y:!1,YUI_config:!1},exports.mocha={mocha:!1,describe:!1,xdescribe:!1,it:!1,xit:!1,context:!1,xcontext:!1,before:!1,after:!1,beforeEach:!1,afterEach:!1,suite:!1,test:!1,setup:!1,teardown:!1,suiteSetup:!1,suiteTeardown:!1},exports.jasmine={jasmine:!1,describe:!1,xdescribe:!1,it:!1,xit:!1,beforeEach:!1,afterEach:!1,setFixtures:!1,loadFixtures:!1,spyOn:!1,expect:!1,runs:!1,waitsFor:!1,waits:!1,beforeAll:!1,afterAll:!1,fail:!1,fdescribe:!1,fit:!1,pending:!1}},{}]},{},[\"/node_modules/jshint/src/jshint.js\"])}),ace.define(\"ace/mode/javascript_worker\",[\"require\",\"exports\",\"module\",\"ace/lib/oop\",\"ace/worker/mirror\",\"ace/mode/javascript/jshint\"],function(acequire,exports,module){\"use strict\";function startRegex(arr){return RegExp(\"^(\"+arr.join(\"|\")+\")\")}var oop=acequire(\"../lib/oop\"),Mirror=acequire(\"../worker/mirror\").Mirror,lint=acequire(\"./javascript/jshint\").JSHINT,disabledWarningsRe=startRegex([\"Bad for in variable '(.+)'.\",'Missing \"use strict\"']),errorsRe=startRegex([\"Unexpected\",\"Expected \",\"Confusing (plus|minus)\",\"\\\\{a\\\\} unterminated regular expression\",\"Unclosed \",\"Unmatched \",\"Unbegun comment\",\"Bad invocation\",\"Missing space after\",\"Missing operator at\"]),infoRe=startRegex([\"Expected an assignment\",\"Bad escapement of EOL\",\"Unexpected comma\",\"Unexpected space\",\"Missing radix parameter.\",\"A leading decimal point can\",\"\\\\['{a}'\\\\] is better written in dot notation.\",\"'{a}' used out of scope\"]),JavaScriptWorker=exports.JavaScriptWorker=function(sender){Mirror.call(this,sender),this.setTimeout(500),this.setOptions()};oop.inherits(JavaScriptWorker,Mirror),function(){this.setOptions=function(options){this.options=options||{esnext:!0,moz:!0,devel:!0,browser:!0,node:!0,laxcomma:!0,laxbreak:!0,lastsemic:!0,onevar:!1,passfail:!1,maxerr:100,expr:!0,multistr:!0,globalstrict:!0},this.doc.getValue()&&this.deferredUpdate.schedule(100)},this.changeOptions=function(newOptions){oop.mixin(this.options,newOptions),this.doc.getValue()&&this.deferredUpdate.schedule(100)},this.isValidJS=function(str){try{eval(\"throw 0;\"+str)}catch(e){if(0===e)return!0}return!1},this.onUpdate=function(){var value=this.doc.getValue();if(value=value.replace(/^#!.*\\n/,\"\\n\"),!value)return this.sender.emit(\"annotate\",[]);var errors=[],maxErrorLevel=this.isValidJS(value)?\"warning\":\"error\";lint(value,this.options,this.options.globals);for(var results=lint.errors,errorAdded=!1,i=0;results.length>i;i++){var error=results[i];if(error){var raw=error.raw,type=\"warning\";if(\"Missing semicolon.\"==raw){var str=error.evidence.substr(error.character);str=str.charAt(str.search(/\\S/)),\"error\"==maxErrorLevel&&str&&/[\\w\\d{(['\"]/.test(str)?(error.reason='Missing \";\" before statement',type=\"error\"):type=\"info\"}else{if(disabledWarningsRe.test(raw))continue;infoRe.test(raw)?type=\"info\":errorsRe.test(raw)?(errorAdded=!0,type=maxErrorLevel):\"'{a}' is not defined.\"==raw?type=\"warning\":\"'{a}' is defined but never used.\"==raw&&(type=\"info\")}errors.push({row:error.line-1,column:error.character-1,text:error.reason,type:type,raw:raw})}}this.sender.emit(\"annotate\",errors)}}.call(JavaScriptWorker.prototype)}),ace.define(\"ace/lib/es5-shim\",[\"require\",\"exports\",\"module\"],function(){function Empty(){}function doesDefinePropertyWork(object){try{return Object.defineProperty(object,\"sentinel\",{}),\"sentinel\"in object}catch(exception){}}function toInteger(n){return n=+n,n!==n?n=0:0!==n&&n!==1/0&&n!==-(1/0)&&(n=(n>0||-1)*Math.floor(Math.abs(n))),n}Function.prototype.bind||(Function.prototype.bind=function(that){var target=this;if(\"function\"!=typeof target)throw new TypeError(\"Function.prototype.bind called on incompatible \"+target);var args=slice.call(arguments,1),bound=function(){if(this instanceof bound){var result=target.apply(this,args.concat(slice.call(arguments)));return Object(result)===result?result:this}return target.apply(that,args.concat(slice.call(arguments)))};return target.prototype&&(Empty.prototype=target.prototype,bound.prototype=new Empty,Empty.prototype=null),bound});var defineGetter,defineSetter,lookupGetter,lookupSetter,supportsAccessors,call=Function.prototype.call,prototypeOfArray=Array.prototype,prototypeOfObject=Object.prototype,slice=prototypeOfArray.slice,_toString=call.bind(prototypeOfObject.toString),owns=call.bind(prototypeOfObject.hasOwnProperty);if((supportsAccessors=owns(prototypeOfObject,\"__defineGetter__\"))&&(defineGetter=call.bind(prototypeOfObject.__defineGetter__),defineSetter=call.bind(prototypeOfObject.__defineSetter__),lookupGetter=call.bind(prototypeOfObject.__lookupGetter__),lookupSetter=call.bind(prototypeOfObject.__lookupSetter__)),2!=[1,2].splice(0).length)if(function(){function makeArray(l){var a=Array(l+2);return a[0]=a[1]=0,a}var lengthBefore,array=[];return array.splice.apply(array,makeArray(20)),array.splice.apply(array,makeArray(26)),lengthBefore=array.length,array.splice(5,0,\"XXX\"),lengthBefore+1==array.length,lengthBefore+1==array.length?!0:void 0}()){var array_splice=Array.prototype.splice;Array.prototype.splice=function(start,deleteCount){return arguments.length?array_splice.apply(this,[void 0===start?0:start,void 0===deleteCount?this.length-start:deleteCount].concat(slice.call(arguments,2))):[]}}else Array.prototype.splice=function(pos,removeCount){var length=this.length;pos>0?pos>length&&(pos=length):void 0==pos?pos=0:0>pos&&(pos=Math.max(length+pos,0)),length>pos+removeCount||(removeCount=length-pos);var removed=this.slice(pos,pos+removeCount),insert=slice.call(arguments,2),add=insert.length;if(pos===length)add&&this.push.apply(this,insert);else{var remove=Math.min(removeCount,length-pos),tailOldPos=pos+remove,tailNewPos=tailOldPos+add-remove,tailCount=length-tailOldPos,lengthAfterRemove=length-remove;if(tailOldPos>tailNewPos)for(var i=0;tailCount>i;++i)this[tailNewPos+i]=this[tailOldPos+i];else if(tailNewPos>tailOldPos)for(i=tailCount;i--;)this[tailNewPos+i]=this[tailOldPos+i];if(add&&pos===lengthAfterRemove)this.length=lengthAfterRemove,this.push.apply(this,insert);else for(this.length=lengthAfterRemove+add,i=0;add>i;++i)this[pos+i]=insert[i]}return removed};Array.isArray||(Array.isArray=function(obj){return\"[object Array]\"==_toString(obj)});var boxedString=Object(\"a\"),splitString=\"a\"!=boxedString[0]||!(0 in boxedString);if(Array.prototype.forEach||(Array.prototype.forEach=function(fun){var object=toObject(this),self=splitString&&\"[object String]\"==_toString(this)?this.split(\"\"):object,thisp=arguments[1],i=-1,length=self.length>>>0;if(\"[object Function]\"!=_toString(fun))throw new TypeError;for(;length>++i;)i in self&&fun.call(thisp,self[i],i,object)}),Array.prototype.map||(Array.prototype.map=function(fun){var object=toObject(this),self=splitString&&\"[object String]\"==_toString(this)?this.split(\"\"):object,length=self.length>>>0,result=Array(length),thisp=arguments[1];if(\"[object Function]\"!=_toString(fun))throw new TypeError(fun+\" is not a function\");for(var i=0;length>i;i++)i in self&&(result[i]=fun.call(thisp,self[i],i,object));return result}),Array.prototype.filter||(Array.prototype.filter=function(fun){var value,object=toObject(this),self=splitString&&\"[object String]\"==_toString(this)?this.split(\"\"):object,length=self.length>>>0,result=[],thisp=arguments[1];if(\"[object Function]\"!=_toString(fun))throw new TypeError(fun+\" is not a function\");for(var i=0;length>i;i++)i in self&&(value=self[i],fun.call(thisp,value,i,object)&&result.push(value));return result}),Array.prototype.every||(Array.prototype.every=function(fun){var object=toObject(this),self=splitString&&\"[object String]\"==_toString(this)?this.split(\"\"):object,length=self.length>>>0,thisp=arguments[1];if(\"[object Function]\"!=_toString(fun))throw new TypeError(fun+\" is not a function\");for(var i=0;length>i;i++)if(i in self&&!fun.call(thisp,self[i],i,object))return!1;return!0}),Array.prototype.some||(Array.prototype.some=function(fun){var object=toObject(this),self=splitString&&\"[object String]\"==_toString(this)?this.split(\"\"):object,length=self.length>>>0,thisp=arguments[1];if(\"[object Function]\"!=_toString(fun))throw new TypeError(fun+\" is not a function\");for(var i=0;length>i;i++)if(i in self&&fun.call(thisp,self[i],i,object))return!0;return!1}),Array.prototype.reduce||(Array.prototype.reduce=function(fun){var object=toObject(this),self=splitString&&\"[object String]\"==_toString(this)?this.split(\"\"):object,length=self.length>>>0;if(\"[object Function]\"!=_toString(fun))throw new TypeError(fun+\" is not a function\");if(!length&&1==arguments.length)throw new TypeError(\"reduce of empty array with no initial value\");var result,i=0;if(arguments.length>=2)result=arguments[1];else for(;;){if(i in self){result=self[i++];break}if(++i>=length)throw new TypeError(\"reduce of empty array with no initial value\")}for(;length>i;i++)i in self&&(result=fun.call(void 0,result,self[i],i,object));return result}),Array.prototype.reduceRight||(Array.prototype.reduceRight=function(fun){var object=toObject(this),self=splitString&&\"[object String]\"==_toString(this)?this.split(\"\"):object,length=self.length>>>0;if(\"[object Function]\"!=_toString(fun))throw new TypeError(fun+\" is not a function\");if(!length&&1==arguments.length)throw new TypeError(\"reduceRight of empty array with no initial value\");var result,i=length-1;if(arguments.length>=2)result=arguments[1];else for(;;){if(i in self){result=self[i--];break}if(0>--i)throw new TypeError(\"reduceRight of empty array with no initial value\")}do i in this&&(result=fun.call(void 0,result,self[i],i,object));while(i--);return result}),Array.prototype.indexOf&&-1==[0,1].indexOf(1,2)||(Array.prototype.indexOf=function(sought){var self=splitString&&\"[object String]\"==_toString(this)?this.split(\"\"):toObject(this),length=self.length>>>0;if(!length)return-1;var i=0;for(arguments.length>1&&(i=toInteger(arguments[1])),i=i>=0?i:Math.max(0,length+i);length>i;i++)if(i in self&&self[i]===sought)return i;return-1}),Array.prototype.lastIndexOf&&-1==[0,1].lastIndexOf(0,-3)||(Array.prototype.lastIndexOf=function(sought){var self=splitString&&\"[object String]\"==_toString(this)?this.split(\"\"):toObject(this),length=self.length>>>0;if(!length)return-1;var i=length-1;for(arguments.length>1&&(i=Math.min(i,toInteger(arguments[1]))),i=i>=0?i:length-Math.abs(i);i>=0;i--)if(i in self&&sought===self[i])return i;return-1}),Object.getPrototypeOf||(Object.getPrototypeOf=function(object){return object.__proto__||(object.constructor?object.constructor.prototype:prototypeOfObject)}),!Object.getOwnPropertyDescriptor){var ERR_NON_OBJECT=\"Object.getOwnPropertyDescriptor called on a non-object: \";Object.getOwnPropertyDescriptor=function(object,property){if(\"object\"!=typeof object&&\"function\"!=typeof object||null===object)throw new TypeError(ERR_NON_OBJECT+object);if(owns(object,property)){var descriptor,getter,setter;if(descriptor={enumerable:!0,configurable:!0},supportsAccessors){var prototype=object.__proto__;object.__proto__=prototypeOfObject;var getter=lookupGetter(object,property),setter=lookupSetter(object,property);if(object.__proto__=prototype,getter||setter)return getter&&(descriptor.get=getter),setter&&(descriptor.set=setter),descriptor}return descriptor.value=object[property],descriptor}}}if(Object.getOwnPropertyNames||(Object.getOwnPropertyNames=function(object){return Object.keys(object)}),!Object.create){var createEmpty;createEmpty=null===Object.prototype.__proto__?function(){return{__proto__:null}}:function(){var empty={};for(var i in empty)empty[i]=null;return empty.constructor=empty.hasOwnProperty=empty.propertyIsEnumerable=empty.isPrototypeOf=empty.toLocaleString=empty.toString=empty.valueOf=empty.__proto__=null,empty},Object.create=function(prototype,properties){var object;if(null===prototype)object=createEmpty();else{if(\"object\"!=typeof prototype)throw new TypeError(\"typeof prototype[\"+typeof prototype+\"] != 'object'\");var Type=function(){};Type.prototype=prototype,object=new Type,object.__proto__=prototype}return void 0!==properties&&Object.defineProperties(object,properties),object}}if(Object.defineProperty){var definePropertyWorksOnObject=doesDefinePropertyWork({}),definePropertyWorksOnDom=\"undefined\"==typeof document||doesDefinePropertyWork(document.createElement(\"div\"));if(!definePropertyWorksOnObject||!definePropertyWorksOnDom)var definePropertyFallback=Object.defineProperty}if(!Object.defineProperty||definePropertyFallback){var ERR_NON_OBJECT_DESCRIPTOR=\"Property description must be an object: \",ERR_NON_OBJECT_TARGET=\"Object.defineProperty called on non-object: \",ERR_ACCESSORS_NOT_SUPPORTED=\"getters & setters can not be defined on this javascript engine\";Object.defineProperty=function(object,property,descriptor){if(\"object\"!=typeof object&&\"function\"!=typeof object||null===object)throw new TypeError(ERR_NON_OBJECT_TARGET+object);if(\"object\"!=typeof descriptor&&\"function\"!=typeof descriptor||null===descriptor)throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR+descriptor);if(definePropertyFallback)try{return definePropertyFallback.call(Object,object,property,descriptor)}catch(exception){}if(owns(descriptor,\"value\"))if(supportsAccessors&&(lookupGetter(object,property)||lookupSetter(object,property))){var prototype=object.__proto__;object.__proto__=prototypeOfObject,delete object[property],object[property]=descriptor.value,object.__proto__=prototype}else object[property]=descriptor.value;else{if(!supportsAccessors)throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);owns(descriptor,\"get\")&&defineGetter(object,property,descriptor.get),owns(descriptor,\"set\")&&defineSetter(object,property,descriptor.set)}return object}}Object.defineProperties||(Object.defineProperties=function(object,properties){for(var property in properties)owns(properties,property)&&Object.defineProperty(object,property,properties[property]);return object}),Object.seal||(Object.seal=function(object){return object}),Object.freeze||(Object.freeze=function(object){return object});try{Object.freeze(function(){})}catch(exception){Object.freeze=function(freezeObject){return function(object){return\"function\"==typeof object?object:freezeObject(object)}}(Object.freeze)}if(Object.preventExtensions||(Object.preventExtensions=function(object){return object}),Object.isSealed||(Object.isSealed=function(){return!1}),Object.isFrozen||(Object.isFrozen=function(){return!1}),Object.isExtensible||(Object.isExtensible=function(object){if(Object(object)===object)throw new TypeError;for(var name=\"\";owns(object,name);)name+=\"?\";object[name]=!0;var returnValue=owns(object,name);return delete object[name],returnValue}),!Object.keys){var hasDontEnumBug=!0,dontEnums=[\"toString\",\"toLocaleString\",\"valueOf\",\"hasOwnProperty\",\"isPrototypeOf\",\"propertyIsEnumerable\",\"constructor\"],dontEnumsLength=dontEnums.length;for(var key in{toString:null})hasDontEnumBug=!1;Object.keys=function(object){if(\"object\"!=typeof object&&\"function\"!=typeof object||null===object)throw new TypeError(\"Object.keys called on a non-object\");var keys=[];for(var name in object)owns(object,name)&&keys.push(name);if(hasDontEnumBug)for(var i=0,ii=dontEnumsLength;ii>i;i++){var dontEnum=dontEnums[i];owns(object,dontEnum)&&keys.push(dontEnum)}return keys}}Date.now||(Date.now=function(){return(new Date).getTime()});var ws=\"\t\\n\u000b\\f\\r   ᠎              \\u2028\\u2029\";if(!String.prototype.trim||ws.trim()){ws=\"[\"+ws+\"]\";var trimBeginRegexp=RegExp(\"^\"+ws+ws+\"*\"),trimEndRegexp=RegExp(ws+ws+\"*$\");String.prototype.trim=function(){return(this+\"\").replace(trimBeginRegexp,\"\").replace(trimEndRegexp,\"\")}}var toObject=function(o){if(null==o)throw new TypeError(\"can't convert \"+o+\" to object\");return Object(o)}});"; /***/ }), -/* 43 */ +/* 44 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -41976,7 +42029,7 @@ function substituteAliases(origCommand) { /***/ }), -/* 44 */ +/* 45 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -42191,7 +42244,7 @@ let DarkWebItems = { /***/ }), -/* 45 */ +/* 46 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -42525,7 +42578,7 @@ function initLiterature() { /***/ }), -/* 46 */ +/* 47 */ /***/ (function(module, exports, __webpack_require__) { /* @@ -46161,7 +46214,197 @@ Object.defineProperty(exports, '__esModule', { value: true }); }))); /***/ }), -/* 47 */ +/* 48 */ +/***/ (function(module, exports) { + +// shim for using process in browser +var process = module.exports = {}; + +// cached from whatever global is present so that test runners that stub it +// don't break things. But we need to wrap it in a try catch in case it is +// wrapped in strict mode code which doesn't define any globals. It's inside a +// function because try/catches deoptimize in certain engines. + +var cachedSetTimeout; +var cachedClearTimeout; + +function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); +} +function defaultClearTimeout () { + throw new Error('clearTimeout has not been defined'); +} +(function () { + try { + if (typeof setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; + } + } catch (e) { + cachedSetTimeout = defaultSetTimout; + } + try { + if (typeof clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; + } + } catch (e) { + cachedClearTimeout = defaultClearTimeout; + } +} ()) +function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + // if setTimeout wasn't available but was latter defined + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch(e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch(e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } + } + + +} +function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } + + + +} +var queue = []; +var draining = false; +var currentQueue; +var queueIndex = -1; + +function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } +} + +function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); +} + +process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +}; + +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; +process.prependListener = noop; +process.prependOnceListener = noop; + +process.listeners = function (name) { return [] } + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + + +/***/ }), +/* 49 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -46251,7 +46494,7 @@ function createTextFile(fn, txt, server) { /***/ }), -/* 48 */ +/* 50 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -46262,7 +46505,7 @@ function createTextFile(fn, txt, server) { /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Player_js__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__utils_DialogBox_js__ = __webpack_require__(1); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_InfiltrationBox_js__ = __webpack_require__(49); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_InfiltrationBox_js__ = __webpack_require__(51); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_StringHelperFunctions_js__ = __webpack_require__(4); @@ -47090,7 +47333,7 @@ function getInfiltrationEscapeChance(inst) { /***/ }), -/* 49 */ +/* 51 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -47216,7 +47459,7 @@ function infiltrationBoxCreate(inst) { /***/ }), -/* 50 */ +/* 52 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -47356,7 +47599,7 @@ let FactionInfo = { /***/ }), -/* 51 */ +/* 53 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -61913,7 +62156,7 @@ let FactionInfo = { /***/ }), -/* 52 */ +/* 54 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -61973,7 +62216,7 @@ function factionInvitationBoxCreate(faction) { /***/ }), -/* 53 */ +/* 55 */ /***/ (function(module, exports, __webpack_require__) { /* ***** BEGIN LICENSE BLOCK ***** @@ -65689,7 +65932,7 @@ init(true);function init(packaged) { if (!global || !global.document) return; - options.packaged = packaged || acequire.packaged || module.packaged || (global.define && __webpack_require__(41).packaged); + options.packaged = packaged || acequire.packaged || module.packaged || (global.define && __webpack_require__(42).packaged); var scriptOptions = {}; var scriptUrl = ""; @@ -78773,7 +79016,7 @@ var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) { try { var workerSrc = mod.src; - var Blob = __webpack_require__(54); + var Blob = __webpack_require__(56); var blob = new Blob([ workerSrc ], { type: 'application/javascript' }); var blobUrl = (window.URL || window.webkitURL).createObjectURL(blob); @@ -80987,7 +81230,7 @@ exports.config = acequire("./config"); exports.acequire = acequire; if (true) - exports.define = __webpack_require__(41); + exports.define = __webpack_require__(42); exports.edit = function(el) { if (typeof el == "string") { var _id = el; @@ -81054,7 +81297,7 @@ exports.version = "1.2.6"; module.exports = window.ace.acequire("ace/ace"); /***/ }), -/* 54 */ +/* 56 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(global) {module.exports = get_blob() @@ -81086,37 +81329,10 @@ function get_blob() { } } -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(55))) +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(33))) /***/ }), -/* 55 */ -/***/ (function(module, exports) { - -var g; - -// This works in non-strict mode -g = (function() { - return this; -})(); - -try { - // This works if eval is allowed (see CSP) - g = g || Function("return this")() || (1,eval)("this"); -} catch(e) { - // This works if the window reference is available - if(typeof window === "object") - g = window; -} - -// g can still be undefined, but nothing to do about it... -// We return undefined, instead of nothing here, so it's -// easier to handle this case. if(!global) { ...} - -module.exports = g; - - -/***/ }), -/* 56 */ +/* 57 */ /***/ (function(module, exports, __webpack_require__) { ace.define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(acequire, exports, module) { @@ -81882,7 +82098,7 @@ oop.inherits(Mode, TextMode); }; this.createWorker = function(session) { - var worker = new WorkerClient(["ace"], __webpack_require__(42), "JavaScriptWorker"); + var worker = new WorkerClient(["ace"], __webpack_require__(43), "JavaScriptWorker"); worker.attachToDocument(session.getDocument()); worker.on("annotate", function(results) { @@ -81904,7 +82120,7 @@ exports.Mode = Mode; /***/ }), -/* 57 */ +/* 58 */ /***/ (function(module, exports, __webpack_require__) { ace.define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(acequire, exports, module) { @@ -82692,7 +82908,7 @@ oop.inherits(Mode, TextMode); }; this.createWorker = function(session) { - var worker = new WorkerClient(["ace"], __webpack_require__(42), "JavaScriptWorker"); + var worker = new WorkerClient(["ace"], __webpack_require__(43), "JavaScriptWorker"); worker.attachToDocument(session.getDocument()); worker.on("annotate", function(results) { @@ -82714,7 +82930,7 @@ exports.Mode = Mode; /***/ }), -/* 58 */ +/* 59 */ /***/ (function(module, exports) { ace.define("ace/theme/chaos",["require","exports","module","ace/lib/dom"], function(acequire, exports, module) { @@ -82876,7 +83092,7 @@ dom.importCssString(exports.cssText, exports.cssClass); /***/ }), -/* 59 */ +/* 60 */ /***/ (function(module, exports) { ace.define("ace/theme/chrome",["require","exports","module","ace/lib/dom"], function(acequire, exports, module) { @@ -83010,7 +83226,7 @@ dom.importCssString(exports.cssText, exports.cssClass); /***/ }), -/* 60 */ +/* 61 */ /***/ (function(module, exports) { ace.define("ace/theme/monokai",["require","exports","module","ace/lib/dom"], function(acequire, exports, module) { @@ -83121,7 +83337,7 @@ dom.importCssString(exports.cssText, exports.cssClass); /***/ }), -/* 61 */ +/* 62 */ /***/ (function(module, exports) { ace.define("ace/theme/solarized_dark",["require","exports","module","ace/lib/dom"], function(acequire, exports, module) { @@ -83215,7 +83431,7 @@ dom.importCssString(exports.cssText, exports.cssClass); /***/ }), -/* 62 */ +/* 63 */ /***/ (function(module, exports) { ace.define("ace/theme/solarized_light",["require","exports","module","ace/lib/dom"], function(acequire, exports, module) { @@ -83312,7 +83528,7 @@ dom.importCssString(exports.cssText, exports.cssClass); /***/ }), -/* 63 */ +/* 64 */ /***/ (function(module, exports) { ace.define("ace/theme/terminal",["require","exports","module","ace/lib/dom"], function(acequire, exports, module) { @@ -83432,7 +83648,7 @@ dom.importCssString(exports.cssText, exports.cssClass); /***/ }), -/* 64 */ +/* 65 */ /***/ (function(module, exports) { ace.define("ace/theme/twilight",["require","exports","module","ace/lib/dom"], function(acequire, exports, module) { @@ -83547,7 +83763,7 @@ dom.importCssString(exports.cssText, exports.cssClass); /***/ }), -/* 65 */ +/* 66 */ /***/ (function(module, exports) { ace.define("ace/theme/xcode",["require","exports","module","ace/lib/dom"], function(acequire, exports, module) { @@ -83641,7 +83857,7 @@ dom.importCssString(exports.cssText, exports.cssClass); /***/ }), -/* 66 */ +/* 67 */ /***/ (function(module, exports) { ace.define("ace/keyboard/vim",["require","exports","module","ace/range","ace/lib/event_emitter","ace/lib/dom","ace/lib/oop","ace/lib/keys","ace/lib/event","ace/search","ace/lib/useragent","ace/search_highlight","ace/commands/multi_select_commands","ace/mode/text","ace/multi_select"], function(acequire, exports, module) { @@ -89240,7 +89456,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ /***/ }), -/* 67 */ +/* 68 */ /***/ (function(module, exports) { ace.define("ace/occur",["require","exports","module","ace/lib/oop","ace/range","ace/search","ace/edit_session","ace/search_highlight","ace/lib/dom"], function(acequire, exports, module) { @@ -90427,7 +90643,7 @@ exports.killRing = { /***/ }), -/* 68 */ +/* 69 */ /***/ (function(module, exports) { ace.define("ace/snippets",["require","exports","module","ace/lib/oop","ace/lib/event_emitter","ace/lib/lang","ace/range","ace/anchor","ace/keyboard/hash_handler","ace/tokenizer","ace/lib/dom","ace/editor"], function(acequire, exports, module) { @@ -92378,7 +92594,7 @@ acequire("../config").defineOptions(Editor.prototype, "editor", { /***/ }), -/* 69 */ +/* 70 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -92459,7 +92675,7 @@ function purchaseRamForHomeComputer(cost) { /***/ }), -/* 70 */ +/* 71 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -92678,32 +92894,5913 @@ let HelpTexts = { /***/ }), -/* 71 */ +/* 72 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(process, global, setImmediate) {/* @preserve + * The MIT License (MIT) + * + * Copyright (c) 2013-2017 Petka Antonov + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ +/** + * bluebird build version 3.5.1 + * Features enabled: core, race, call_get, generators, map, nodeify, promisify, props, reduce, settle, some, using, timers, filter, any, each +*/ +!function(e){if(true)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Promise=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof _dereq_=="function"&&_dereq_;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof _dereq_=="function"&&_dereq_;for(var o=0;o 0) { + var fn = queue.shift(); + if (typeof fn !== "function") { + fn._settlePromises(); + continue; + } + var receiver = queue.shift(); + var arg = queue.shift(); + fn.call(receiver, arg); + } +}; + +Async.prototype._drainQueues = function () { + this._drainQueue(this._normalQueue); + this._reset(); + this._haveDrainedQueues = true; + this._drainQueue(this._lateQueue); +}; + +Async.prototype._queueTick = function () { + if (!this._isTickUsed) { + this._isTickUsed = true; + this._schedule(this.drainQueues); + } +}; + +Async.prototype._reset = function () { + this._isTickUsed = false; +}; + +module.exports = Async; +module.exports.firstLineError = firstLineError; + +},{"./queue":26,"./schedule":29,"./util":36}],3:[function(_dereq_,module,exports){ +"use strict"; +module.exports = function(Promise, INTERNAL, tryConvertToPromise, debug) { +var calledBind = false; +var rejectThis = function(_, e) { + this._reject(e); +}; + +var targetRejected = function(e, context) { + context.promiseRejectionQueued = true; + context.bindingPromise._then(rejectThis, rejectThis, null, this, e); +}; + +var bindingResolved = function(thisArg, context) { + if (((this._bitField & 50397184) === 0)) { + this._resolveCallback(context.target); + } +}; + +var bindingRejected = function(e, context) { + if (!context.promiseRejectionQueued) this._reject(e); +}; + +Promise.prototype.bind = function (thisArg) { + if (!calledBind) { + calledBind = true; + Promise.prototype._propagateFrom = debug.propagateFromFunction(); + Promise.prototype._boundValue = debug.boundValueFunction(); + } + var maybePromise = tryConvertToPromise(thisArg); + var ret = new Promise(INTERNAL); + ret._propagateFrom(this, 1); + var target = this._target(); + ret._setBoundTo(maybePromise); + if (maybePromise instanceof Promise) { + var context = { + promiseRejectionQueued: false, + promise: ret, + target: target, + bindingPromise: maybePromise + }; + target._then(INTERNAL, targetRejected, undefined, ret, context); + maybePromise._then( + bindingResolved, bindingRejected, undefined, ret, context); + ret._setOnCancel(maybePromise); + } else { + ret._resolveCallback(target); + } + return ret; +}; + +Promise.prototype._setBoundTo = function (obj) { + if (obj !== undefined) { + this._bitField = this._bitField | 2097152; + this._boundTo = obj; + } else { + this._bitField = this._bitField & (~2097152); + } +}; + +Promise.prototype._isBound = function () { + return (this._bitField & 2097152) === 2097152; +}; + +Promise.bind = function (thisArg, value) { + return Promise.resolve(value).bind(thisArg); +}; +}; + +},{}],4:[function(_dereq_,module,exports){ +"use strict"; +var old; +if (typeof Promise !== "undefined") old = Promise; +function noConflict() { + try { if (Promise === bluebird) Promise = old; } + catch (e) {} + return bluebird; +} +var bluebird = _dereq_("./promise")(); +bluebird.noConflict = noConflict; +module.exports = bluebird; + +},{"./promise":22}],5:[function(_dereq_,module,exports){ +"use strict"; +var cr = Object.create; +if (cr) { + var callerCache = cr(null); + var getterCache = cr(null); + callerCache[" size"] = getterCache[" size"] = 0; +} + +module.exports = function(Promise) { +var util = _dereq_("./util"); +var canEvaluate = util.canEvaluate; +var isIdentifier = util.isIdentifier; + +var getMethodCaller; +var getGetter; +if (false) { +var makeMethodCaller = function (methodName) { + return new Function("ensureMethod", " \n\ + return function(obj) { \n\ + 'use strict' \n\ + var len = this.length; \n\ + ensureMethod(obj, 'methodName'); \n\ + switch(len) { \n\ + case 1: return obj.methodName(this[0]); \n\ + case 2: return obj.methodName(this[0], this[1]); \n\ + case 3: return obj.methodName(this[0], this[1], this[2]); \n\ + case 0: return obj.methodName(); \n\ + default: \n\ + return obj.methodName.apply(obj, this); \n\ + } \n\ + }; \n\ + ".replace(/methodName/g, methodName))(ensureMethod); +}; + +var makeGetter = function (propertyName) { + return new Function("obj", " \n\ + 'use strict'; \n\ + return obj.propertyName; \n\ + ".replace("propertyName", propertyName)); +}; + +var getCompiled = function(name, compiler, cache) { + var ret = cache[name]; + if (typeof ret !== "function") { + if (!isIdentifier(name)) { + return null; + } + ret = compiler(name); + cache[name] = ret; + cache[" size"]++; + if (cache[" size"] > 512) { + var keys = Object.keys(cache); + for (var i = 0; i < 256; ++i) delete cache[keys[i]]; + cache[" size"] = keys.length - 256; + } + } + return ret; +}; + +getMethodCaller = function(name) { + return getCompiled(name, makeMethodCaller, callerCache); +}; + +getGetter = function(name) { + return getCompiled(name, makeGetter, getterCache); +}; +} + +function ensureMethod(obj, methodName) { + var fn; + if (obj != null) fn = obj[methodName]; + if (typeof fn !== "function") { + var message = "Object " + util.classString(obj) + " has no method '" + + util.toString(methodName) + "'"; + throw new Promise.TypeError(message); + } + return fn; +} + +function caller(obj) { + var methodName = this.pop(); + var fn = ensureMethod(obj, methodName); + return fn.apply(obj, this); +} +Promise.prototype.call = function (methodName) { + var args = [].slice.call(arguments, 1);; + if (false) { + if (canEvaluate) { + var maybeCaller = getMethodCaller(methodName); + if (maybeCaller !== null) { + return this._then( + maybeCaller, undefined, undefined, args, undefined); + } + } + } + args.push(methodName); + return this._then(caller, undefined, undefined, args, undefined); +}; + +function namedGetter(obj) { + return obj[this]; +} +function indexedGetter(obj) { + var index = +this; + if (index < 0) index = Math.max(0, index + obj.length); + return obj[index]; +} +Promise.prototype.get = function (propertyName) { + var isIndex = (typeof propertyName === "number"); + var getter; + if (!isIndex) { + if (canEvaluate) { + var maybeGetter = getGetter(propertyName); + getter = maybeGetter !== null ? maybeGetter : namedGetter; + } else { + getter = namedGetter; + } + } else { + getter = indexedGetter; + } + return this._then(getter, undefined, undefined, propertyName, undefined); +}; +}; + +},{"./util":36}],6:[function(_dereq_,module,exports){ +"use strict"; +module.exports = function(Promise, PromiseArray, apiRejection, debug) { +var util = _dereq_("./util"); +var tryCatch = util.tryCatch; +var errorObj = util.errorObj; +var async = Promise._async; + +Promise.prototype["break"] = Promise.prototype.cancel = function() { + if (!debug.cancellation()) return this._warn("cancellation is disabled"); + + var promise = this; + var child = promise; + while (promise._isCancellable()) { + if (!promise._cancelBy(child)) { + if (child._isFollowing()) { + child._followee().cancel(); + } else { + child._cancelBranched(); + } + break; + } + + var parent = promise._cancellationParent; + if (parent == null || !parent._isCancellable()) { + if (promise._isFollowing()) { + promise._followee().cancel(); + } else { + promise._cancelBranched(); + } + break; + } else { + if (promise._isFollowing()) promise._followee().cancel(); + promise._setWillBeCancelled(); + child = promise; + promise = parent; + } + } +}; + +Promise.prototype._branchHasCancelled = function() { + this._branchesRemainingToCancel--; +}; + +Promise.prototype._enoughBranchesHaveCancelled = function() { + return this._branchesRemainingToCancel === undefined || + this._branchesRemainingToCancel <= 0; +}; + +Promise.prototype._cancelBy = function(canceller) { + if (canceller === this) { + this._branchesRemainingToCancel = 0; + this._invokeOnCancel(); + return true; + } else { + this._branchHasCancelled(); + if (this._enoughBranchesHaveCancelled()) { + this._invokeOnCancel(); + return true; + } + } + return false; +}; + +Promise.prototype._cancelBranched = function() { + if (this._enoughBranchesHaveCancelled()) { + this._cancel(); + } +}; + +Promise.prototype._cancel = function() { + if (!this._isCancellable()) return; + this._setCancelled(); + async.invoke(this._cancelPromises, this, undefined); +}; + +Promise.prototype._cancelPromises = function() { + if (this._length() > 0) this._settlePromises(); +}; + +Promise.prototype._unsetOnCancel = function() { + this._onCancelField = undefined; +}; + +Promise.prototype._isCancellable = function() { + return this.isPending() && !this._isCancelled(); +}; + +Promise.prototype.isCancellable = function() { + return this.isPending() && !this.isCancelled(); +}; + +Promise.prototype._doInvokeOnCancel = function(onCancelCallback, internalOnly) { + if (util.isArray(onCancelCallback)) { + for (var i = 0; i < onCancelCallback.length; ++i) { + this._doInvokeOnCancel(onCancelCallback[i], internalOnly); + } + } else if (onCancelCallback !== undefined) { + if (typeof onCancelCallback === "function") { + if (!internalOnly) { + var e = tryCatch(onCancelCallback).call(this._boundValue()); + if (e === errorObj) { + this._attachExtraTrace(e.e); + async.throwLater(e.e); + } + } + } else { + onCancelCallback._resultCancelled(this); + } + } +}; + +Promise.prototype._invokeOnCancel = function() { + var onCancelCallback = this._onCancel(); + this._unsetOnCancel(); + async.invoke(this._doInvokeOnCancel, this, onCancelCallback); +}; + +Promise.prototype._invokeInternalOnCancel = function() { + if (this._isCancellable()) { + this._doInvokeOnCancel(this._onCancel(), true); + this._unsetOnCancel(); + } +}; + +Promise.prototype._resultCancelled = function() { + this.cancel(); +}; + +}; + +},{"./util":36}],7:[function(_dereq_,module,exports){ +"use strict"; +module.exports = function(NEXT_FILTER) { +var util = _dereq_("./util"); +var getKeys = _dereq_("./es5").keys; +var tryCatch = util.tryCatch; +var errorObj = util.errorObj; + +function catchFilter(instances, cb, promise) { + return function(e) { + var boundTo = promise._boundValue(); + predicateLoop: for (var i = 0; i < instances.length; ++i) { + var item = instances[i]; + + if (item === Error || + (item != null && item.prototype instanceof Error)) { + if (e instanceof item) { + return tryCatch(cb).call(boundTo, e); + } + } else if (typeof item === "function") { + var matchesPredicate = tryCatch(item).call(boundTo, e); + if (matchesPredicate === errorObj) { + return matchesPredicate; + } else if (matchesPredicate) { + return tryCatch(cb).call(boundTo, e); + } + } else if (util.isObject(e)) { + var keys = getKeys(item); + for (var j = 0; j < keys.length; ++j) { + var key = keys[j]; + if (item[key] != e[key]) { + continue predicateLoop; + } + } + return tryCatch(cb).call(boundTo, e); + } + } + return NEXT_FILTER; + }; +} + +return catchFilter; +}; + +},{"./es5":13,"./util":36}],8:[function(_dereq_,module,exports){ +"use strict"; +module.exports = function(Promise) { +var longStackTraces = false; +var contextStack = []; + +Promise.prototype._promiseCreated = function() {}; +Promise.prototype._pushContext = function() {}; +Promise.prototype._popContext = function() {return null;}; +Promise._peekContext = Promise.prototype._peekContext = function() {}; + +function Context() { + this._trace = new Context.CapturedTrace(peekContext()); +} +Context.prototype._pushContext = function () { + if (this._trace !== undefined) { + this._trace._promiseCreated = null; + contextStack.push(this._trace); + } +}; + +Context.prototype._popContext = function () { + if (this._trace !== undefined) { + var trace = contextStack.pop(); + var ret = trace._promiseCreated; + trace._promiseCreated = null; + return ret; + } + return null; +}; + +function createContext() { + if (longStackTraces) return new Context(); +} + +function peekContext() { + var lastIndex = contextStack.length - 1; + if (lastIndex >= 0) { + return contextStack[lastIndex]; + } + return undefined; +} +Context.CapturedTrace = null; +Context.create = createContext; +Context.deactivateLongStackTraces = function() {}; +Context.activateLongStackTraces = function() { + var Promise_pushContext = Promise.prototype._pushContext; + var Promise_popContext = Promise.prototype._popContext; + var Promise_PeekContext = Promise._peekContext; + var Promise_peekContext = Promise.prototype._peekContext; + var Promise_promiseCreated = Promise.prototype._promiseCreated; + Context.deactivateLongStackTraces = function() { + Promise.prototype._pushContext = Promise_pushContext; + Promise.prototype._popContext = Promise_popContext; + Promise._peekContext = Promise_PeekContext; + Promise.prototype._peekContext = Promise_peekContext; + Promise.prototype._promiseCreated = Promise_promiseCreated; + longStackTraces = false; + }; + longStackTraces = true; + Promise.prototype._pushContext = Context.prototype._pushContext; + Promise.prototype._popContext = Context.prototype._popContext; + Promise._peekContext = Promise.prototype._peekContext = peekContext; + Promise.prototype._promiseCreated = function() { + var ctx = this._peekContext(); + if (ctx && ctx._promiseCreated == null) ctx._promiseCreated = this; + }; +}; +return Context; +}; + +},{}],9:[function(_dereq_,module,exports){ +"use strict"; +module.exports = function(Promise, Context) { +var getDomain = Promise._getDomain; +var async = Promise._async; +var Warning = _dereq_("./errors").Warning; +var util = _dereq_("./util"); +var canAttachTrace = util.canAttachTrace; +var unhandledRejectionHandled; +var possiblyUnhandledRejection; +var bluebirdFramePattern = + /[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/; +var nodeFramePattern = /\((?:timers\.js):\d+:\d+\)/; +var parseLinePattern = /[\/<\(](.+?):(\d+):(\d+)\)?\s*$/; +var stackFramePattern = null; +var formatStack = null; +var indentStackFrames = false; +var printWarning; +var debugging = !!(util.env("BLUEBIRD_DEBUG") != 0 && + (true || + util.env("BLUEBIRD_DEBUG") || + util.env("NODE_ENV") === "development")); + +var warnings = !!(util.env("BLUEBIRD_WARNINGS") != 0 && + (debugging || util.env("BLUEBIRD_WARNINGS"))); + +var longStackTraces = !!(util.env("BLUEBIRD_LONG_STACK_TRACES") != 0 && + (debugging || util.env("BLUEBIRD_LONG_STACK_TRACES"))); + +var wForgottenReturn = util.env("BLUEBIRD_W_FORGOTTEN_RETURN") != 0 && + (warnings || !!util.env("BLUEBIRD_W_FORGOTTEN_RETURN")); + +Promise.prototype.suppressUnhandledRejections = function() { + var target = this._target(); + target._bitField = ((target._bitField & (~1048576)) | + 524288); +}; + +Promise.prototype._ensurePossibleRejectionHandled = function () { + if ((this._bitField & 524288) !== 0) return; + this._setRejectionIsUnhandled(); + var self = this; + setTimeout(function() { + self._notifyUnhandledRejection(); + }, 1); +}; + +Promise.prototype._notifyUnhandledRejectionIsHandled = function () { + fireRejectionEvent("rejectionHandled", + unhandledRejectionHandled, undefined, this); +}; + +Promise.prototype._setReturnedNonUndefined = function() { + this._bitField = this._bitField | 268435456; +}; + +Promise.prototype._returnedNonUndefined = function() { + return (this._bitField & 268435456) !== 0; +}; + +Promise.prototype._notifyUnhandledRejection = function () { + if (this._isRejectionUnhandled()) { + var reason = this._settledValue(); + this._setUnhandledRejectionIsNotified(); + fireRejectionEvent("unhandledRejection", + possiblyUnhandledRejection, reason, this); + } +}; + +Promise.prototype._setUnhandledRejectionIsNotified = function () { + this._bitField = this._bitField | 262144; +}; + +Promise.prototype._unsetUnhandledRejectionIsNotified = function () { + this._bitField = this._bitField & (~262144); +}; + +Promise.prototype._isUnhandledRejectionNotified = function () { + return (this._bitField & 262144) > 0; +}; + +Promise.prototype._setRejectionIsUnhandled = function () { + this._bitField = this._bitField | 1048576; +}; + +Promise.prototype._unsetRejectionIsUnhandled = function () { + this._bitField = this._bitField & (~1048576); + if (this._isUnhandledRejectionNotified()) { + this._unsetUnhandledRejectionIsNotified(); + this._notifyUnhandledRejectionIsHandled(); + } +}; + +Promise.prototype._isRejectionUnhandled = function () { + return (this._bitField & 1048576) > 0; +}; + +Promise.prototype._warn = function(message, shouldUseOwnTrace, promise) { + return warn(message, shouldUseOwnTrace, promise || this); +}; + +Promise.onPossiblyUnhandledRejection = function (fn) { + var domain = getDomain(); + possiblyUnhandledRejection = + typeof fn === "function" ? (domain === null ? + fn : util.domainBind(domain, fn)) + : undefined; +}; + +Promise.onUnhandledRejectionHandled = function (fn) { + var domain = getDomain(); + unhandledRejectionHandled = + typeof fn === "function" ? (domain === null ? + fn : util.domainBind(domain, fn)) + : undefined; +}; + +var disableLongStackTraces = function() {}; +Promise.longStackTraces = function () { + if (async.haveItemsQueued() && !config.longStackTraces) { + throw new Error("cannot enable long stack traces after promises have been created\u000a\u000a See http://goo.gl/MqrFmX\u000a"); + } + if (!config.longStackTraces && longStackTracesIsSupported()) { + var Promise_captureStackTrace = Promise.prototype._captureStackTrace; + var Promise_attachExtraTrace = Promise.prototype._attachExtraTrace; + config.longStackTraces = true; + disableLongStackTraces = function() { + if (async.haveItemsQueued() && !config.longStackTraces) { + throw new Error("cannot enable long stack traces after promises have been created\u000a\u000a See http://goo.gl/MqrFmX\u000a"); + } + Promise.prototype._captureStackTrace = Promise_captureStackTrace; + Promise.prototype._attachExtraTrace = Promise_attachExtraTrace; + Context.deactivateLongStackTraces(); + async.enableTrampoline(); + config.longStackTraces = false; + }; + Promise.prototype._captureStackTrace = longStackTracesCaptureStackTrace; + Promise.prototype._attachExtraTrace = longStackTracesAttachExtraTrace; + Context.activateLongStackTraces(); + async.disableTrampolineIfNecessary(); + } +}; + +Promise.hasLongStackTraces = function () { + return config.longStackTraces && longStackTracesIsSupported(); +}; + +var fireDomEvent = (function() { + try { + if (typeof CustomEvent === "function") { + var event = new CustomEvent("CustomEvent"); + util.global.dispatchEvent(event); + return function(name, event) { + var domEvent = new CustomEvent(name.toLowerCase(), { + detail: event, + cancelable: true + }); + return !util.global.dispatchEvent(domEvent); + }; + } else if (typeof Event === "function") { + var event = new Event("CustomEvent"); + util.global.dispatchEvent(event); + return function(name, event) { + var domEvent = new Event(name.toLowerCase(), { + cancelable: true + }); + domEvent.detail = event; + return !util.global.dispatchEvent(domEvent); + }; + } else { + var event = document.createEvent("CustomEvent"); + event.initCustomEvent("testingtheevent", false, true, {}); + util.global.dispatchEvent(event); + return function(name, event) { + var domEvent = document.createEvent("CustomEvent"); + domEvent.initCustomEvent(name.toLowerCase(), false, true, + event); + return !util.global.dispatchEvent(domEvent); + }; + } + } catch (e) {} + return function() { + return false; + }; +})(); + +var fireGlobalEvent = (function() { + if (util.isNode) { + return function() { + return process.emit.apply(process, arguments); + }; + } else { + if (!util.global) { + return function() { + return false; + }; + } + return function(name) { + var methodName = "on" + name.toLowerCase(); + var method = util.global[methodName]; + if (!method) return false; + method.apply(util.global, [].slice.call(arguments, 1)); + return true; + }; + } +})(); + +function generatePromiseLifecycleEventObject(name, promise) { + return {promise: promise}; +} + +var eventToObjectGenerator = { + promiseCreated: generatePromiseLifecycleEventObject, + promiseFulfilled: generatePromiseLifecycleEventObject, + promiseRejected: generatePromiseLifecycleEventObject, + promiseResolved: generatePromiseLifecycleEventObject, + promiseCancelled: generatePromiseLifecycleEventObject, + promiseChained: function(name, promise, child) { + return {promise: promise, child: child}; + }, + warning: function(name, warning) { + return {warning: warning}; + }, + unhandledRejection: function (name, reason, promise) { + return {reason: reason, promise: promise}; + }, + rejectionHandled: generatePromiseLifecycleEventObject +}; + +var activeFireEvent = function (name) { + var globalEventFired = false; + try { + globalEventFired = fireGlobalEvent.apply(null, arguments); + } catch (e) { + async.throwLater(e); + globalEventFired = true; + } + + var domEventFired = false; + try { + domEventFired = fireDomEvent(name, + eventToObjectGenerator[name].apply(null, arguments)); + } catch (e) { + async.throwLater(e); + domEventFired = true; + } + + return domEventFired || globalEventFired; +}; + +Promise.config = function(opts) { + opts = Object(opts); + if ("longStackTraces" in opts) { + if (opts.longStackTraces) { + Promise.longStackTraces(); + } else if (!opts.longStackTraces && Promise.hasLongStackTraces()) { + disableLongStackTraces(); + } + } + if ("warnings" in opts) { + var warningsOption = opts.warnings; + config.warnings = !!warningsOption; + wForgottenReturn = config.warnings; + + if (util.isObject(warningsOption)) { + if ("wForgottenReturn" in warningsOption) { + wForgottenReturn = !!warningsOption.wForgottenReturn; + } + } + } + if ("cancellation" in opts && opts.cancellation && !config.cancellation) { + if (async.haveItemsQueued()) { + throw new Error( + "cannot enable cancellation after promises are in use"); + } + Promise.prototype._clearCancellationData = + cancellationClearCancellationData; + Promise.prototype._propagateFrom = cancellationPropagateFrom; + Promise.prototype._onCancel = cancellationOnCancel; + Promise.prototype._setOnCancel = cancellationSetOnCancel; + Promise.prototype._attachCancellationCallback = + cancellationAttachCancellationCallback; + Promise.prototype._execute = cancellationExecute; + propagateFromFunction = cancellationPropagateFrom; + config.cancellation = true; + } + if ("monitoring" in opts) { + if (opts.monitoring && !config.monitoring) { + config.monitoring = true; + Promise.prototype._fireEvent = activeFireEvent; + } else if (!opts.monitoring && config.monitoring) { + config.monitoring = false; + Promise.prototype._fireEvent = defaultFireEvent; + } + } + return Promise; +}; + +function defaultFireEvent() { return false; } + +Promise.prototype._fireEvent = defaultFireEvent; +Promise.prototype._execute = function(executor, resolve, reject) { + try { + executor(resolve, reject); + } catch (e) { + return e; + } +}; +Promise.prototype._onCancel = function () {}; +Promise.prototype._setOnCancel = function (handler) { ; }; +Promise.prototype._attachCancellationCallback = function(onCancel) { + ; +}; +Promise.prototype._captureStackTrace = function () {}; +Promise.prototype._attachExtraTrace = function () {}; +Promise.prototype._clearCancellationData = function() {}; +Promise.prototype._propagateFrom = function (parent, flags) { + ; + ; +}; + +function cancellationExecute(executor, resolve, reject) { + var promise = this; + try { + executor(resolve, reject, function(onCancel) { + if (typeof onCancel !== "function") { + throw new TypeError("onCancel must be a function, got: " + + util.toString(onCancel)); + } + promise._attachCancellationCallback(onCancel); + }); + } catch (e) { + return e; + } +} + +function cancellationAttachCancellationCallback(onCancel) { + if (!this._isCancellable()) return this; + + var previousOnCancel = this._onCancel(); + if (previousOnCancel !== undefined) { + if (util.isArray(previousOnCancel)) { + previousOnCancel.push(onCancel); + } else { + this._setOnCancel([previousOnCancel, onCancel]); + } + } else { + this._setOnCancel(onCancel); + } +} + +function cancellationOnCancel() { + return this._onCancelField; +} + +function cancellationSetOnCancel(onCancel) { + this._onCancelField = onCancel; +} + +function cancellationClearCancellationData() { + this._cancellationParent = undefined; + this._onCancelField = undefined; +} + +function cancellationPropagateFrom(parent, flags) { + if ((flags & 1) !== 0) { + this._cancellationParent = parent; + var branchesRemainingToCancel = parent._branchesRemainingToCancel; + if (branchesRemainingToCancel === undefined) { + branchesRemainingToCancel = 0; + } + parent._branchesRemainingToCancel = branchesRemainingToCancel + 1; + } + if ((flags & 2) !== 0 && parent._isBound()) { + this._setBoundTo(parent._boundTo); + } +} + +function bindingPropagateFrom(parent, flags) { + if ((flags & 2) !== 0 && parent._isBound()) { + this._setBoundTo(parent._boundTo); + } +} +var propagateFromFunction = bindingPropagateFrom; + +function boundValueFunction() { + var ret = this._boundTo; + if (ret !== undefined) { + if (ret instanceof Promise) { + if (ret.isFulfilled()) { + return ret.value(); + } else { + return undefined; + } + } + } + return ret; +} + +function longStackTracesCaptureStackTrace() { + this._trace = new CapturedTrace(this._peekContext()); +} + +function longStackTracesAttachExtraTrace(error, ignoreSelf) { + if (canAttachTrace(error)) { + var trace = this._trace; + if (trace !== undefined) { + if (ignoreSelf) trace = trace._parent; + } + if (trace !== undefined) { + trace.attachExtraTrace(error); + } else if (!error.__stackCleaned__) { + var parsed = parseStackAndMessage(error); + util.notEnumerableProp(error, "stack", + parsed.message + "\n" + parsed.stack.join("\n")); + util.notEnumerableProp(error, "__stackCleaned__", true); + } + } +} + +function checkForgottenReturns(returnValue, promiseCreated, name, promise, + parent) { + if (returnValue === undefined && promiseCreated !== null && + wForgottenReturn) { + if (parent !== undefined && parent._returnedNonUndefined()) return; + if ((promise._bitField & 65535) === 0) return; + + if (name) name = name + " "; + var handlerLine = ""; + var creatorLine = ""; + if (promiseCreated._trace) { + var traceLines = promiseCreated._trace.stack.split("\n"); + var stack = cleanStack(traceLines); + for (var i = stack.length - 1; i >= 0; --i) { + var line = stack[i]; + if (!nodeFramePattern.test(line)) { + var lineMatches = line.match(parseLinePattern); + if (lineMatches) { + handlerLine = "at " + lineMatches[1] + + ":" + lineMatches[2] + ":" + lineMatches[3] + " "; + } + break; + } + } + + if (stack.length > 0) { + var firstUserLine = stack[0]; + for (var i = 0; i < traceLines.length; ++i) { + + if (traceLines[i] === firstUserLine) { + if (i > 0) { + creatorLine = "\n" + traceLines[i - 1]; + } + break; + } + } + + } + } + var msg = "a promise was created in a " + name + + "handler " + handlerLine + "but was not returned from it, " + + "see http://goo.gl/rRqMUw" + + creatorLine; + promise._warn(msg, true, promiseCreated); + } +} + +function deprecated(name, replacement) { + var message = name + + " is deprecated and will be removed in a future version."; + if (replacement) message += " Use " + replacement + " instead."; + return warn(message); +} + +function warn(message, shouldUseOwnTrace, promise) { + if (!config.warnings) return; + var warning = new Warning(message); + var ctx; + if (shouldUseOwnTrace) { + promise._attachExtraTrace(warning); + } else if (config.longStackTraces && (ctx = Promise._peekContext())) { + ctx.attachExtraTrace(warning); + } else { + var parsed = parseStackAndMessage(warning); + warning.stack = parsed.message + "\n" + parsed.stack.join("\n"); + } + + if (!activeFireEvent("warning", warning)) { + formatAndLogError(warning, "", true); + } +} + +function reconstructStack(message, stacks) { + for (var i = 0; i < stacks.length - 1; ++i) { + stacks[i].push("From previous event:"); + stacks[i] = stacks[i].join("\n"); + } + if (i < stacks.length) { + stacks[i] = stacks[i].join("\n"); + } + return message + "\n" + stacks.join("\n"); +} + +function removeDuplicateOrEmptyJumps(stacks) { + for (var i = 0; i < stacks.length; ++i) { + if (stacks[i].length === 0 || + ((i + 1 < stacks.length) && stacks[i][0] === stacks[i+1][0])) { + stacks.splice(i, 1); + i--; + } + } +} + +function removeCommonRoots(stacks) { + var current = stacks[0]; + for (var i = 1; i < stacks.length; ++i) { + var prev = stacks[i]; + var currentLastIndex = current.length - 1; + var currentLastLine = current[currentLastIndex]; + var commonRootMeetPoint = -1; + + for (var j = prev.length - 1; j >= 0; --j) { + if (prev[j] === currentLastLine) { + commonRootMeetPoint = j; + break; + } + } + + for (var j = commonRootMeetPoint; j >= 0; --j) { + var line = prev[j]; + if (current[currentLastIndex] === line) { + current.pop(); + currentLastIndex--; + } else { + break; + } + } + current = prev; + } +} + +function cleanStack(stack) { + var ret = []; + for (var i = 0; i < stack.length; ++i) { + var line = stack[i]; + var isTraceLine = " (No stack trace)" === line || + stackFramePattern.test(line); + var isInternalFrame = isTraceLine && shouldIgnore(line); + if (isTraceLine && !isInternalFrame) { + if (indentStackFrames && line.charAt(0) !== " ") { + line = " " + line; + } + ret.push(line); + } + } + return ret; +} + +function stackFramesAsArray(error) { + var stack = error.stack.replace(/\s+$/g, "").split("\n"); + for (var i = 0; i < stack.length; ++i) { + var line = stack[i]; + if (" (No stack trace)" === line || stackFramePattern.test(line)) { + break; + } + } + if (i > 0 && error.name != "SyntaxError") { + stack = stack.slice(i); + } + return stack; +} + +function parseStackAndMessage(error) { + var stack = error.stack; + var message = error.toString(); + stack = typeof stack === "string" && stack.length > 0 + ? stackFramesAsArray(error) : [" (No stack trace)"]; + return { + message: message, + stack: error.name == "SyntaxError" ? stack : cleanStack(stack) + }; +} + +function formatAndLogError(error, title, isSoft) { + if (typeof console !== "undefined") { + var message; + if (util.isObject(error)) { + var stack = error.stack; + message = title + formatStack(stack, error); + } else { + message = title + String(error); + } + if (typeof printWarning === "function") { + printWarning(message, isSoft); + } else if (typeof console.log === "function" || + typeof console.log === "object") { + console.log(message); + } + } +} + +function fireRejectionEvent(name, localHandler, reason, promise) { + var localEventFired = false; + try { + if (typeof localHandler === "function") { + localEventFired = true; + if (name === "rejectionHandled") { + localHandler(promise); + } else { + localHandler(reason, promise); + } + } + } catch (e) { + async.throwLater(e); + } + + if (name === "unhandledRejection") { + if (!activeFireEvent(name, reason, promise) && !localEventFired) { + formatAndLogError(reason, "Unhandled rejection "); + } + } else { + activeFireEvent(name, promise); + } +} + +function formatNonError(obj) { + var str; + if (typeof obj === "function") { + str = "[function " + + (obj.name || "anonymous") + + "]"; + } else { + str = obj && typeof obj.toString === "function" + ? obj.toString() : util.toString(obj); + var ruselessToString = /\[object [a-zA-Z0-9$_]+\]/; + if (ruselessToString.test(str)) { + try { + var newStr = JSON.stringify(obj); + str = newStr; + } + catch(e) { + + } + } + if (str.length === 0) { + str = "(empty array)"; + } + } + return ("(<" + snip(str) + ">, no stack trace)"); +} + +function snip(str) { + var maxChars = 41; + if (str.length < maxChars) { + return str; + } + return str.substr(0, maxChars - 3) + "..."; +} + +function longStackTracesIsSupported() { + return typeof captureStackTrace === "function"; +} + +var shouldIgnore = function() { return false; }; +var parseLineInfoRegex = /[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/; +function parseLineInfo(line) { + var matches = line.match(parseLineInfoRegex); + if (matches) { + return { + fileName: matches[1], + line: parseInt(matches[2], 10) + }; + } +} + +function setBounds(firstLineError, lastLineError) { + if (!longStackTracesIsSupported()) return; + var firstStackLines = firstLineError.stack.split("\n"); + var lastStackLines = lastLineError.stack.split("\n"); + var firstIndex = -1; + var lastIndex = -1; + var firstFileName; + var lastFileName; + for (var i = 0; i < firstStackLines.length; ++i) { + var result = parseLineInfo(firstStackLines[i]); + if (result) { + firstFileName = result.fileName; + firstIndex = result.line; + break; + } + } + for (var i = 0; i < lastStackLines.length; ++i) { + var result = parseLineInfo(lastStackLines[i]); + if (result) { + lastFileName = result.fileName; + lastIndex = result.line; + break; + } + } + if (firstIndex < 0 || lastIndex < 0 || !firstFileName || !lastFileName || + firstFileName !== lastFileName || firstIndex >= lastIndex) { + return; + } + + shouldIgnore = function(line) { + if (bluebirdFramePattern.test(line)) return true; + var info = parseLineInfo(line); + if (info) { + if (info.fileName === firstFileName && + (firstIndex <= info.line && info.line <= lastIndex)) { + return true; + } + } + return false; + }; +} + +function CapturedTrace(parent) { + this._parent = parent; + this._promisesCreated = 0; + var length = this._length = 1 + (parent === undefined ? 0 : parent._length); + captureStackTrace(this, CapturedTrace); + if (length > 32) this.uncycle(); +} +util.inherits(CapturedTrace, Error); +Context.CapturedTrace = CapturedTrace; + +CapturedTrace.prototype.uncycle = function() { + var length = this._length; + if (length < 2) return; + var nodes = []; + var stackToIndex = {}; + + for (var i = 0, node = this; node !== undefined; ++i) { + nodes.push(node); + node = node._parent; + } + length = this._length = i; + for (var i = length - 1; i >= 0; --i) { + var stack = nodes[i].stack; + if (stackToIndex[stack] === undefined) { + stackToIndex[stack] = i; + } + } + for (var i = 0; i < length; ++i) { + var currentStack = nodes[i].stack; + var index = stackToIndex[currentStack]; + if (index !== undefined && index !== i) { + if (index > 0) { + nodes[index - 1]._parent = undefined; + nodes[index - 1]._length = 1; + } + nodes[i]._parent = undefined; + nodes[i]._length = 1; + var cycleEdgeNode = i > 0 ? nodes[i - 1] : this; + + if (index < length - 1) { + cycleEdgeNode._parent = nodes[index + 1]; + cycleEdgeNode._parent.uncycle(); + cycleEdgeNode._length = + cycleEdgeNode._parent._length + 1; + } else { + cycleEdgeNode._parent = undefined; + cycleEdgeNode._length = 1; + } + var currentChildLength = cycleEdgeNode._length + 1; + for (var j = i - 2; j >= 0; --j) { + nodes[j]._length = currentChildLength; + currentChildLength++; + } + return; + } + } +}; + +CapturedTrace.prototype.attachExtraTrace = function(error) { + if (error.__stackCleaned__) return; + this.uncycle(); + var parsed = parseStackAndMessage(error); + var message = parsed.message; + var stacks = [parsed.stack]; + + var trace = this; + while (trace !== undefined) { + stacks.push(cleanStack(trace.stack.split("\n"))); + trace = trace._parent; + } + removeCommonRoots(stacks); + removeDuplicateOrEmptyJumps(stacks); + util.notEnumerableProp(error, "stack", reconstructStack(message, stacks)); + util.notEnumerableProp(error, "__stackCleaned__", true); +}; + +var captureStackTrace = (function stackDetection() { + var v8stackFramePattern = /^\s*at\s*/; + var v8stackFormatter = function(stack, error) { + if (typeof stack === "string") return stack; + + if (error.name !== undefined && + error.message !== undefined) { + return error.toString(); + } + return formatNonError(error); + }; + + if (typeof Error.stackTraceLimit === "number" && + typeof Error.captureStackTrace === "function") { + Error.stackTraceLimit += 6; + stackFramePattern = v8stackFramePattern; + formatStack = v8stackFormatter; + var captureStackTrace = Error.captureStackTrace; + + shouldIgnore = function(line) { + return bluebirdFramePattern.test(line); + }; + return function(receiver, ignoreUntil) { + Error.stackTraceLimit += 6; + captureStackTrace(receiver, ignoreUntil); + Error.stackTraceLimit -= 6; + }; + } + var err = new Error(); + + if (typeof err.stack === "string" && + err.stack.split("\n")[0].indexOf("stackDetection@") >= 0) { + stackFramePattern = /@/; + formatStack = v8stackFormatter; + indentStackFrames = true; + return function captureStackTrace(o) { + o.stack = new Error().stack; + }; + } + + var hasStackAfterThrow; + try { throw new Error(); } + catch(e) { + hasStackAfterThrow = ("stack" in e); + } + if (!("stack" in err) && hasStackAfterThrow && + typeof Error.stackTraceLimit === "number") { + stackFramePattern = v8stackFramePattern; + formatStack = v8stackFormatter; + return function captureStackTrace(o) { + Error.stackTraceLimit += 6; + try { throw new Error(); } + catch(e) { o.stack = e.stack; } + Error.stackTraceLimit -= 6; + }; + } + + formatStack = function(stack, error) { + if (typeof stack === "string") return stack; + + if ((typeof error === "object" || + typeof error === "function") && + error.name !== undefined && + error.message !== undefined) { + return error.toString(); + } + return formatNonError(error); + }; + + return null; + +})([]); + +if (typeof console !== "undefined" && typeof console.warn !== "undefined") { + printWarning = function (message) { + console.warn(message); + }; + if (util.isNode && process.stderr.isTTY) { + printWarning = function(message, isSoft) { + var color = isSoft ? "\u001b[33m" : "\u001b[31m"; + console.warn(color + message + "\u001b[0m\n"); + }; + } else if (!util.isNode && typeof (new Error().stack) === "string") { + printWarning = function(message, isSoft) { + console.warn("%c" + message, + isSoft ? "color: darkorange" : "color: red"); + }; + } +} + +var config = { + warnings: warnings, + longStackTraces: false, + cancellation: false, + monitoring: false +}; + +if (longStackTraces) Promise.longStackTraces(); + +return { + longStackTraces: function() { + return config.longStackTraces; + }, + warnings: function() { + return config.warnings; + }, + cancellation: function() { + return config.cancellation; + }, + monitoring: function() { + return config.monitoring; + }, + propagateFromFunction: function() { + return propagateFromFunction; + }, + boundValueFunction: function() { + return boundValueFunction; + }, + checkForgottenReturns: checkForgottenReturns, + setBounds: setBounds, + warn: warn, + deprecated: deprecated, + CapturedTrace: CapturedTrace, + fireDomEvent: fireDomEvent, + fireGlobalEvent: fireGlobalEvent +}; +}; + +},{"./errors":12,"./util":36}],10:[function(_dereq_,module,exports){ +"use strict"; +module.exports = function(Promise) { +function returner() { + return this.value; +} +function thrower() { + throw this.reason; +} + +Promise.prototype["return"] = +Promise.prototype.thenReturn = function (value) { + if (value instanceof Promise) value.suppressUnhandledRejections(); + return this._then( + returner, undefined, undefined, {value: value}, undefined); +}; + +Promise.prototype["throw"] = +Promise.prototype.thenThrow = function (reason) { + return this._then( + thrower, undefined, undefined, {reason: reason}, undefined); +}; + +Promise.prototype.catchThrow = function (reason) { + if (arguments.length <= 1) { + return this._then( + undefined, thrower, undefined, {reason: reason}, undefined); + } else { + var _reason = arguments[1]; + var handler = function() {throw _reason;}; + return this.caught(reason, handler); + } +}; + +Promise.prototype.catchReturn = function (value) { + if (arguments.length <= 1) { + if (value instanceof Promise) value.suppressUnhandledRejections(); + return this._then( + undefined, returner, undefined, {value: value}, undefined); + } else { + var _value = arguments[1]; + if (_value instanceof Promise) _value.suppressUnhandledRejections(); + var handler = function() {return _value;}; + return this.caught(value, handler); + } +}; +}; + +},{}],11:[function(_dereq_,module,exports){ +"use strict"; +module.exports = function(Promise, INTERNAL) { +var PromiseReduce = Promise.reduce; +var PromiseAll = Promise.all; + +function promiseAllThis() { + return PromiseAll(this); +} + +function PromiseMapSeries(promises, fn) { + return PromiseReduce(promises, fn, INTERNAL, INTERNAL); +} + +Promise.prototype.each = function (fn) { + return PromiseReduce(this, fn, INTERNAL, 0) + ._then(promiseAllThis, undefined, undefined, this, undefined); +}; + +Promise.prototype.mapSeries = function (fn) { + return PromiseReduce(this, fn, INTERNAL, INTERNAL); +}; + +Promise.each = function (promises, fn) { + return PromiseReduce(promises, fn, INTERNAL, 0) + ._then(promiseAllThis, undefined, undefined, promises, undefined); +}; + +Promise.mapSeries = PromiseMapSeries; +}; + + +},{}],12:[function(_dereq_,module,exports){ +"use strict"; +var es5 = _dereq_("./es5"); +var Objectfreeze = es5.freeze; +var util = _dereq_("./util"); +var inherits = util.inherits; +var notEnumerableProp = util.notEnumerableProp; + +function subError(nameProperty, defaultMessage) { + function SubError(message) { + if (!(this instanceof SubError)) return new SubError(message); + notEnumerableProp(this, "message", + typeof message === "string" ? message : defaultMessage); + notEnumerableProp(this, "name", nameProperty); + if (Error.captureStackTrace) { + Error.captureStackTrace(this, this.constructor); + } else { + Error.call(this); + } + } + inherits(SubError, Error); + return SubError; +} + +var _TypeError, _RangeError; +var Warning = subError("Warning", "warning"); +var CancellationError = subError("CancellationError", "cancellation error"); +var TimeoutError = subError("TimeoutError", "timeout error"); +var AggregateError = subError("AggregateError", "aggregate error"); +try { + _TypeError = TypeError; + _RangeError = RangeError; +} catch(e) { + _TypeError = subError("TypeError", "type error"); + _RangeError = subError("RangeError", "range error"); +} + +var methods = ("join pop push shift unshift slice filter forEach some " + + "every map indexOf lastIndexOf reduce reduceRight sort reverse").split(" "); + +for (var i = 0; i < methods.length; ++i) { + if (typeof Array.prototype[methods[i]] === "function") { + AggregateError.prototype[methods[i]] = Array.prototype[methods[i]]; + } +} + +es5.defineProperty(AggregateError.prototype, "length", { + value: 0, + configurable: false, + writable: true, + enumerable: true +}); +AggregateError.prototype["isOperational"] = true; +var level = 0; +AggregateError.prototype.toString = function() { + var indent = Array(level * 4 + 1).join(" "); + var ret = "\n" + indent + "AggregateError of:" + "\n"; + level++; + indent = Array(level * 4 + 1).join(" "); + for (var i = 0; i < this.length; ++i) { + var str = this[i] === this ? "[Circular AggregateError]" : this[i] + ""; + var lines = str.split("\n"); + for (var j = 0; j < lines.length; ++j) { + lines[j] = indent + lines[j]; + } + str = lines.join("\n"); + ret += str + "\n"; + } + level--; + return ret; +}; + +function OperationalError(message) { + if (!(this instanceof OperationalError)) + return new OperationalError(message); + notEnumerableProp(this, "name", "OperationalError"); + notEnumerableProp(this, "message", message); + this.cause = message; + this["isOperational"] = true; + + if (message instanceof Error) { + notEnumerableProp(this, "message", message.message); + notEnumerableProp(this, "stack", message.stack); + } else if (Error.captureStackTrace) { + Error.captureStackTrace(this, this.constructor); + } + +} +inherits(OperationalError, Error); + +var errorTypes = Error["__BluebirdErrorTypes__"]; +if (!errorTypes) { + errorTypes = Objectfreeze({ + CancellationError: CancellationError, + TimeoutError: TimeoutError, + OperationalError: OperationalError, + RejectionError: OperationalError, + AggregateError: AggregateError + }); + es5.defineProperty(Error, "__BluebirdErrorTypes__", { + value: errorTypes, + writable: false, + enumerable: false, + configurable: false + }); +} + +module.exports = { + Error: Error, + TypeError: _TypeError, + RangeError: _RangeError, + CancellationError: errorTypes.CancellationError, + OperationalError: errorTypes.OperationalError, + TimeoutError: errorTypes.TimeoutError, + AggregateError: errorTypes.AggregateError, + Warning: Warning +}; + +},{"./es5":13,"./util":36}],13:[function(_dereq_,module,exports){ +var isES5 = (function(){ + "use strict"; + return this === undefined; +})(); + +if (isES5) { + module.exports = { + freeze: Object.freeze, + defineProperty: Object.defineProperty, + getDescriptor: Object.getOwnPropertyDescriptor, + keys: Object.keys, + names: Object.getOwnPropertyNames, + getPrototypeOf: Object.getPrototypeOf, + isArray: Array.isArray, + isES5: isES5, + propertyIsWritable: function(obj, prop) { + var descriptor = Object.getOwnPropertyDescriptor(obj, prop); + return !!(!descriptor || descriptor.writable || descriptor.set); + } + }; +} else { + var has = {}.hasOwnProperty; + var str = {}.toString; + var proto = {}.constructor.prototype; + + var ObjectKeys = function (o) { + var ret = []; + for (var key in o) { + if (has.call(o, key)) { + ret.push(key); + } + } + return ret; + }; + + var ObjectGetDescriptor = function(o, key) { + return {value: o[key]}; + }; + + var ObjectDefineProperty = function (o, key, desc) { + o[key] = desc.value; + return o; + }; + + var ObjectFreeze = function (obj) { + return obj; + }; + + var ObjectGetPrototypeOf = function (obj) { + try { + return Object(obj).constructor.prototype; + } + catch (e) { + return proto; + } + }; + + var ArrayIsArray = function (obj) { + try { + return str.call(obj) === "[object Array]"; + } + catch(e) { + return false; + } + }; + + module.exports = { + isArray: ArrayIsArray, + keys: ObjectKeys, + names: ObjectKeys, + defineProperty: ObjectDefineProperty, + getDescriptor: ObjectGetDescriptor, + freeze: ObjectFreeze, + getPrototypeOf: ObjectGetPrototypeOf, + isES5: isES5, + propertyIsWritable: function() { + return true; + } + }; +} + +},{}],14:[function(_dereq_,module,exports){ +"use strict"; +module.exports = function(Promise, INTERNAL) { +var PromiseMap = Promise.map; + +Promise.prototype.filter = function (fn, options) { + return PromiseMap(this, fn, options, INTERNAL); +}; + +Promise.filter = function (promises, fn, options) { + return PromiseMap(promises, fn, options, INTERNAL); +}; +}; + +},{}],15:[function(_dereq_,module,exports){ +"use strict"; +module.exports = function(Promise, tryConvertToPromise, NEXT_FILTER) { +var util = _dereq_("./util"); +var CancellationError = Promise.CancellationError; +var errorObj = util.errorObj; +var catchFilter = _dereq_("./catch_filter")(NEXT_FILTER); + +function PassThroughHandlerContext(promise, type, handler) { + this.promise = promise; + this.type = type; + this.handler = handler; + this.called = false; + this.cancelPromise = null; +} + +PassThroughHandlerContext.prototype.isFinallyHandler = function() { + return this.type === 0; +}; + +function FinallyHandlerCancelReaction(finallyHandler) { + this.finallyHandler = finallyHandler; +} + +FinallyHandlerCancelReaction.prototype._resultCancelled = function() { + checkCancel(this.finallyHandler); +}; + +function checkCancel(ctx, reason) { + if (ctx.cancelPromise != null) { + if (arguments.length > 1) { + ctx.cancelPromise._reject(reason); + } else { + ctx.cancelPromise._cancel(); + } + ctx.cancelPromise = null; + return true; + } + return false; +} + +function succeed() { + return finallyHandler.call(this, this.promise._target()._settledValue()); +} +function fail(reason) { + if (checkCancel(this, reason)) return; + errorObj.e = reason; + return errorObj; +} +function finallyHandler(reasonOrValue) { + var promise = this.promise; + var handler = this.handler; + + if (!this.called) { + this.called = true; + var ret = this.isFinallyHandler() + ? handler.call(promise._boundValue()) + : handler.call(promise._boundValue(), reasonOrValue); + if (ret === NEXT_FILTER) { + return ret; + } else if (ret !== undefined) { + promise._setReturnedNonUndefined(); + var maybePromise = tryConvertToPromise(ret, promise); + if (maybePromise instanceof Promise) { + if (this.cancelPromise != null) { + if (maybePromise._isCancelled()) { + var reason = + new CancellationError("late cancellation observer"); + promise._attachExtraTrace(reason); + errorObj.e = reason; + return errorObj; + } else if (maybePromise.isPending()) { + maybePromise._attachCancellationCallback( + new FinallyHandlerCancelReaction(this)); + } + } + return maybePromise._then( + succeed, fail, undefined, this, undefined); + } + } + } + + if (promise.isRejected()) { + checkCancel(this); + errorObj.e = reasonOrValue; + return errorObj; + } else { + checkCancel(this); + return reasonOrValue; + } +} + +Promise.prototype._passThrough = function(handler, type, success, fail) { + if (typeof handler !== "function") return this.then(); + return this._then(success, + fail, + undefined, + new PassThroughHandlerContext(this, type, handler), + undefined); +}; + +Promise.prototype.lastly = +Promise.prototype["finally"] = function (handler) { + return this._passThrough(handler, + 0, + finallyHandler, + finallyHandler); +}; + + +Promise.prototype.tap = function (handler) { + return this._passThrough(handler, 1, finallyHandler); +}; + +Promise.prototype.tapCatch = function (handlerOrPredicate) { + var len = arguments.length; + if(len === 1) { + return this._passThrough(handlerOrPredicate, + 1, + undefined, + finallyHandler); + } else { + var catchInstances = new Array(len - 1), + j = 0, i; + for (i = 0; i < len - 1; ++i) { + var item = arguments[i]; + if (util.isObject(item)) { + catchInstances[j++] = item; + } else { + return Promise.reject(new TypeError( + "tapCatch statement predicate: " + + "expecting an object but got " + util.classString(item) + )); + } + } + catchInstances.length = j; + var handler = arguments[i]; + return this._passThrough(catchFilter(catchInstances, handler, this), + 1, + undefined, + finallyHandler); + } + +}; + +return PassThroughHandlerContext; +}; + +},{"./catch_filter":7,"./util":36}],16:[function(_dereq_,module,exports){ +"use strict"; +module.exports = function(Promise, + apiRejection, + INTERNAL, + tryConvertToPromise, + Proxyable, + debug) { +var errors = _dereq_("./errors"); +var TypeError = errors.TypeError; +var util = _dereq_("./util"); +var errorObj = util.errorObj; +var tryCatch = util.tryCatch; +var yieldHandlers = []; + +function promiseFromYieldHandler(value, yieldHandlers, traceParent) { + for (var i = 0; i < yieldHandlers.length; ++i) { + traceParent._pushContext(); + var result = tryCatch(yieldHandlers[i])(value); + traceParent._popContext(); + if (result === errorObj) { + traceParent._pushContext(); + var ret = Promise.reject(errorObj.e); + traceParent._popContext(); + return ret; + } + var maybePromise = tryConvertToPromise(result, traceParent); + if (maybePromise instanceof Promise) return maybePromise; + } + return null; +} + +function PromiseSpawn(generatorFunction, receiver, yieldHandler, stack) { + if (debug.cancellation()) { + var internal = new Promise(INTERNAL); + var _finallyPromise = this._finallyPromise = new Promise(INTERNAL); + this._promise = internal.lastly(function() { + return _finallyPromise; + }); + internal._captureStackTrace(); + internal._setOnCancel(this); + } else { + var promise = this._promise = new Promise(INTERNAL); + promise._captureStackTrace(); + } + this._stack = stack; + this._generatorFunction = generatorFunction; + this._receiver = receiver; + this._generator = undefined; + this._yieldHandlers = typeof yieldHandler === "function" + ? [yieldHandler].concat(yieldHandlers) + : yieldHandlers; + this._yieldedPromise = null; + this._cancellationPhase = false; +} +util.inherits(PromiseSpawn, Proxyable); + +PromiseSpawn.prototype._isResolved = function() { + return this._promise === null; +}; + +PromiseSpawn.prototype._cleanup = function() { + this._promise = this._generator = null; + if (debug.cancellation() && this._finallyPromise !== null) { + this._finallyPromise._fulfill(); + this._finallyPromise = null; + } +}; + +PromiseSpawn.prototype._promiseCancelled = function() { + if (this._isResolved()) return; + var implementsReturn = typeof this._generator["return"] !== "undefined"; + + var result; + if (!implementsReturn) { + var reason = new Promise.CancellationError( + "generator .return() sentinel"); + Promise.coroutine.returnSentinel = reason; + this._promise._attachExtraTrace(reason); + this._promise._pushContext(); + result = tryCatch(this._generator["throw"]).call(this._generator, + reason); + this._promise._popContext(); + } else { + this._promise._pushContext(); + result = tryCatch(this._generator["return"]).call(this._generator, + undefined); + this._promise._popContext(); + } + this._cancellationPhase = true; + this._yieldedPromise = null; + this._continue(result); +}; + +PromiseSpawn.prototype._promiseFulfilled = function(value) { + this._yieldedPromise = null; + this._promise._pushContext(); + var result = tryCatch(this._generator.next).call(this._generator, value); + this._promise._popContext(); + this._continue(result); +}; + +PromiseSpawn.prototype._promiseRejected = function(reason) { + this._yieldedPromise = null; + this._promise._attachExtraTrace(reason); + this._promise._pushContext(); + var result = tryCatch(this._generator["throw"]) + .call(this._generator, reason); + this._promise._popContext(); + this._continue(result); +}; + +PromiseSpawn.prototype._resultCancelled = function() { + if (this._yieldedPromise instanceof Promise) { + var promise = this._yieldedPromise; + this._yieldedPromise = null; + promise.cancel(); + } +}; + +PromiseSpawn.prototype.promise = function () { + return this._promise; +}; + +PromiseSpawn.prototype._run = function () { + this._generator = this._generatorFunction.call(this._receiver); + this._receiver = + this._generatorFunction = undefined; + this._promiseFulfilled(undefined); +}; + +PromiseSpawn.prototype._continue = function (result) { + var promise = this._promise; + if (result === errorObj) { + this._cleanup(); + if (this._cancellationPhase) { + return promise.cancel(); + } else { + return promise._rejectCallback(result.e, false); + } + } + + var value = result.value; + if (result.done === true) { + this._cleanup(); + if (this._cancellationPhase) { + return promise.cancel(); + } else { + return promise._resolveCallback(value); + } + } else { + var maybePromise = tryConvertToPromise(value, this._promise); + if (!(maybePromise instanceof Promise)) { + maybePromise = + promiseFromYieldHandler(maybePromise, + this._yieldHandlers, + this._promise); + if (maybePromise === null) { + this._promiseRejected( + new TypeError( + "A value %s was yielded that could not be treated as a promise\u000a\u000a See http://goo.gl/MqrFmX\u000a\u000a".replace("%s", String(value)) + + "From coroutine:\u000a" + + this._stack.split("\n").slice(1, -7).join("\n") + ) + ); + return; + } + } + maybePromise = maybePromise._target(); + var bitField = maybePromise._bitField; + ; + if (((bitField & 50397184) === 0)) { + this._yieldedPromise = maybePromise; + maybePromise._proxy(this, null); + } else if (((bitField & 33554432) !== 0)) { + Promise._async.invoke( + this._promiseFulfilled, this, maybePromise._value() + ); + } else if (((bitField & 16777216) !== 0)) { + Promise._async.invoke( + this._promiseRejected, this, maybePromise._reason() + ); + } else { + this._promiseCancelled(); + } + } +}; + +Promise.coroutine = function (generatorFunction, options) { + if (typeof generatorFunction !== "function") { + throw new TypeError("generatorFunction must be a function\u000a\u000a See http://goo.gl/MqrFmX\u000a"); + } + var yieldHandler = Object(options).yieldHandler; + var PromiseSpawn$ = PromiseSpawn; + var stack = new Error().stack; + return function () { + var generator = generatorFunction.apply(this, arguments); + var spawn = new PromiseSpawn$(undefined, undefined, yieldHandler, + stack); + var ret = spawn.promise(); + spawn._generator = generator; + spawn._promiseFulfilled(undefined); + return ret; + }; +}; + +Promise.coroutine.addYieldHandler = function(fn) { + if (typeof fn !== "function") { + throw new TypeError("expecting a function but got " + util.classString(fn)); + } + yieldHandlers.push(fn); +}; + +Promise.spawn = function (generatorFunction) { + debug.deprecated("Promise.spawn()", "Promise.coroutine()"); + if (typeof generatorFunction !== "function") { + return apiRejection("generatorFunction must be a function\u000a\u000a See http://goo.gl/MqrFmX\u000a"); + } + var spawn = new PromiseSpawn(generatorFunction, this); + var ret = spawn.promise(); + spawn._run(Promise.spawn); + return ret; +}; +}; + +},{"./errors":12,"./util":36}],17:[function(_dereq_,module,exports){ +"use strict"; +module.exports = +function(Promise, PromiseArray, tryConvertToPromise, INTERNAL, async, + getDomain) { +var util = _dereq_("./util"); +var canEvaluate = util.canEvaluate; +var tryCatch = util.tryCatch; +var errorObj = util.errorObj; +var reject; + +if (false) { +if (canEvaluate) { + var thenCallback = function(i) { + return new Function("value", "holder", " \n\ + 'use strict'; \n\ + holder.pIndex = value; \n\ + holder.checkFulfillment(this); \n\ + ".replace(/Index/g, i)); + }; + + var promiseSetter = function(i) { + return new Function("promise", "holder", " \n\ + 'use strict'; \n\ + holder.pIndex = promise; \n\ + ".replace(/Index/g, i)); + }; + + var generateHolderClass = function(total) { + var props = new Array(total); + for (var i = 0; i < props.length; ++i) { + props[i] = "this.p" + (i+1); + } + var assignment = props.join(" = ") + " = null;"; + var cancellationCode= "var promise;\n" + props.map(function(prop) { + return " \n\ + promise = " + prop + "; \n\ + if (promise instanceof Promise) { \n\ + promise.cancel(); \n\ + } \n\ + "; + }).join("\n"); + var passedArguments = props.join(", "); + var name = "Holder$" + total; + + + var code = "return function(tryCatch, errorObj, Promise, async) { \n\ + 'use strict'; \n\ + function [TheName](fn) { \n\ + [TheProperties] \n\ + this.fn = fn; \n\ + this.asyncNeeded = true; \n\ + this.now = 0; \n\ + } \n\ + \n\ + [TheName].prototype._callFunction = function(promise) { \n\ + promise._pushContext(); \n\ + var ret = tryCatch(this.fn)([ThePassedArguments]); \n\ + promise._popContext(); \n\ + if (ret === errorObj) { \n\ + promise._rejectCallback(ret.e, false); \n\ + } else { \n\ + promise._resolveCallback(ret); \n\ + } \n\ + }; \n\ + \n\ + [TheName].prototype.checkFulfillment = function(promise) { \n\ + var now = ++this.now; \n\ + if (now === [TheTotal]) { \n\ + if (this.asyncNeeded) { \n\ + async.invoke(this._callFunction, this, promise); \n\ + } else { \n\ + this._callFunction(promise); \n\ + } \n\ + \n\ + } \n\ + }; \n\ + \n\ + [TheName].prototype._resultCancelled = function() { \n\ + [CancellationCode] \n\ + }; \n\ + \n\ + return [TheName]; \n\ + }(tryCatch, errorObj, Promise, async); \n\ + "; + + code = code.replace(/\[TheName\]/g, name) + .replace(/\[TheTotal\]/g, total) + .replace(/\[ThePassedArguments\]/g, passedArguments) + .replace(/\[TheProperties\]/g, assignment) + .replace(/\[CancellationCode\]/g, cancellationCode); + + return new Function("tryCatch", "errorObj", "Promise", "async", code) + (tryCatch, errorObj, Promise, async); + }; + + var holderClasses = []; + var thenCallbacks = []; + var promiseSetters = []; + + for (var i = 0; i < 8; ++i) { + holderClasses.push(generateHolderClass(i + 1)); + thenCallbacks.push(thenCallback(i + 1)); + promiseSetters.push(promiseSetter(i + 1)); + } + + reject = function (reason) { + this._reject(reason); + }; +}} + +Promise.join = function () { + var last = arguments.length - 1; + var fn; + if (last > 0 && typeof arguments[last] === "function") { + fn = arguments[last]; + if (false) { + if (last <= 8 && canEvaluate) { + var ret = new Promise(INTERNAL); + ret._captureStackTrace(); + var HolderClass = holderClasses[last - 1]; + var holder = new HolderClass(fn); + var callbacks = thenCallbacks; + + for (var i = 0; i < last; ++i) { + var maybePromise = tryConvertToPromise(arguments[i], ret); + if (maybePromise instanceof Promise) { + maybePromise = maybePromise._target(); + var bitField = maybePromise._bitField; + ; + if (((bitField & 50397184) === 0)) { + maybePromise._then(callbacks[i], reject, + undefined, ret, holder); + promiseSetters[i](maybePromise, holder); + holder.asyncNeeded = false; + } else if (((bitField & 33554432) !== 0)) { + callbacks[i].call(ret, + maybePromise._value(), holder); + } else if (((bitField & 16777216) !== 0)) { + ret._reject(maybePromise._reason()); + } else { + ret._cancel(); + } + } else { + callbacks[i].call(ret, maybePromise, holder); + } + } + + if (!ret._isFateSealed()) { + if (holder.asyncNeeded) { + var domain = getDomain(); + if (domain !== null) { + holder.fn = util.domainBind(domain, holder.fn); + } + } + ret._setAsyncGuaranteed(); + ret._setOnCancel(holder); + } + return ret; + } + } + } + var args = [].slice.call(arguments);; + if (fn) args.pop(); + var ret = new PromiseArray(args).promise(); + return fn !== undefined ? ret.spread(fn) : ret; +}; + +}; + +},{"./util":36}],18:[function(_dereq_,module,exports){ +"use strict"; +module.exports = function(Promise, + PromiseArray, + apiRejection, + tryConvertToPromise, + INTERNAL, + debug) { +var getDomain = Promise._getDomain; +var util = _dereq_("./util"); +var tryCatch = util.tryCatch; +var errorObj = util.errorObj; +var async = Promise._async; + +function MappingPromiseArray(promises, fn, limit, _filter) { + this.constructor$(promises); + this._promise._captureStackTrace(); + var domain = getDomain(); + this._callback = domain === null ? fn : util.domainBind(domain, fn); + this._preservedValues = _filter === INTERNAL + ? new Array(this.length()) + : null; + this._limit = limit; + this._inFlight = 0; + this._queue = []; + async.invoke(this._asyncInit, this, undefined); +} +util.inherits(MappingPromiseArray, PromiseArray); + +MappingPromiseArray.prototype._asyncInit = function() { + this._init$(undefined, -2); +}; + +MappingPromiseArray.prototype._init = function () {}; + +MappingPromiseArray.prototype._promiseFulfilled = function (value, index) { + var values = this._values; + var length = this.length(); + var preservedValues = this._preservedValues; + var limit = this._limit; + + if (index < 0) { + index = (index * -1) - 1; + values[index] = value; + if (limit >= 1) { + this._inFlight--; + this._drainQueue(); + if (this._isResolved()) return true; + } + } else { + if (limit >= 1 && this._inFlight >= limit) { + values[index] = value; + this._queue.push(index); + return false; + } + if (preservedValues !== null) preservedValues[index] = value; + + var promise = this._promise; + var callback = this._callback; + var receiver = promise._boundValue(); + promise._pushContext(); + var ret = tryCatch(callback).call(receiver, value, index, length); + var promiseCreated = promise._popContext(); + debug.checkForgottenReturns( + ret, + promiseCreated, + preservedValues !== null ? "Promise.filter" : "Promise.map", + promise + ); + if (ret === errorObj) { + this._reject(ret.e); + return true; + } + + var maybePromise = tryConvertToPromise(ret, this._promise); + if (maybePromise instanceof Promise) { + maybePromise = maybePromise._target(); + var bitField = maybePromise._bitField; + ; + if (((bitField & 50397184) === 0)) { + if (limit >= 1) this._inFlight++; + values[index] = maybePromise; + maybePromise._proxy(this, (index + 1) * -1); + return false; + } else if (((bitField & 33554432) !== 0)) { + ret = maybePromise._value(); + } else if (((bitField & 16777216) !== 0)) { + this._reject(maybePromise._reason()); + return true; + } else { + this._cancel(); + return true; + } + } + values[index] = ret; + } + var totalResolved = ++this._totalResolved; + if (totalResolved >= length) { + if (preservedValues !== null) { + this._filter(values, preservedValues); + } else { + this._resolve(values); + } + return true; + } + return false; +}; + +MappingPromiseArray.prototype._drainQueue = function () { + var queue = this._queue; + var limit = this._limit; + var values = this._values; + while (queue.length > 0 && this._inFlight < limit) { + if (this._isResolved()) return; + var index = queue.pop(); + this._promiseFulfilled(values[index], index); + } +}; + +MappingPromiseArray.prototype._filter = function (booleans, values) { + var len = values.length; + var ret = new Array(len); + var j = 0; + for (var i = 0; i < len; ++i) { + if (booleans[i]) ret[j++] = values[i]; + } + ret.length = j; + this._resolve(ret); +}; + +MappingPromiseArray.prototype.preservedValues = function () { + return this._preservedValues; +}; + +function map(promises, fn, options, _filter) { + if (typeof fn !== "function") { + return apiRejection("expecting a function but got " + util.classString(fn)); + } + + var limit = 0; + if (options !== undefined) { + if (typeof options === "object" && options !== null) { + if (typeof options.concurrency !== "number") { + return Promise.reject( + new TypeError("'concurrency' must be a number but it is " + + util.classString(options.concurrency))); + } + limit = options.concurrency; + } else { + return Promise.reject(new TypeError( + "options argument must be an object but it is " + + util.classString(options))); + } + } + limit = typeof limit === "number" && + isFinite(limit) && limit >= 1 ? limit : 0; + return new MappingPromiseArray(promises, fn, limit, _filter).promise(); +} + +Promise.prototype.map = function (fn, options) { + return map(this, fn, options, null); +}; + +Promise.map = function (promises, fn, options, _filter) { + return map(promises, fn, options, _filter); +}; + + +}; + +},{"./util":36}],19:[function(_dereq_,module,exports){ +"use strict"; +module.exports = +function(Promise, INTERNAL, tryConvertToPromise, apiRejection, debug) { +var util = _dereq_("./util"); +var tryCatch = util.tryCatch; + +Promise.method = function (fn) { + if (typeof fn !== "function") { + throw new Promise.TypeError("expecting a function but got " + util.classString(fn)); + } + return function () { + var ret = new Promise(INTERNAL); + ret._captureStackTrace(); + ret._pushContext(); + var value = tryCatch(fn).apply(this, arguments); + var promiseCreated = ret._popContext(); + debug.checkForgottenReturns( + value, promiseCreated, "Promise.method", ret); + ret._resolveFromSyncValue(value); + return ret; + }; +}; + +Promise.attempt = Promise["try"] = function (fn) { + if (typeof fn !== "function") { + return apiRejection("expecting a function but got " + util.classString(fn)); + } + var ret = new Promise(INTERNAL); + ret._captureStackTrace(); + ret._pushContext(); + var value; + if (arguments.length > 1) { + debug.deprecated("calling Promise.try with more than 1 argument"); + var arg = arguments[1]; + var ctx = arguments[2]; + value = util.isArray(arg) ? tryCatch(fn).apply(ctx, arg) + : tryCatch(fn).call(ctx, arg); + } else { + value = tryCatch(fn)(); + } + var promiseCreated = ret._popContext(); + debug.checkForgottenReturns( + value, promiseCreated, "Promise.try", ret); + ret._resolveFromSyncValue(value); + return ret; +}; + +Promise.prototype._resolveFromSyncValue = function (value) { + if (value === util.errorObj) { + this._rejectCallback(value.e, false); + } else { + this._resolveCallback(value, true); + } +}; +}; + +},{"./util":36}],20:[function(_dereq_,module,exports){ +"use strict"; +var util = _dereq_("./util"); +var maybeWrapAsError = util.maybeWrapAsError; +var errors = _dereq_("./errors"); +var OperationalError = errors.OperationalError; +var es5 = _dereq_("./es5"); + +function isUntypedError(obj) { + return obj instanceof Error && + es5.getPrototypeOf(obj) === Error.prototype; +} + +var rErrorKey = /^(?:name|message|stack|cause)$/; +function wrapAsOperationalError(obj) { + var ret; + if (isUntypedError(obj)) { + ret = new OperationalError(obj); + ret.name = obj.name; + ret.message = obj.message; + ret.stack = obj.stack; + var keys = es5.keys(obj); + for (var i = 0; i < keys.length; ++i) { + var key = keys[i]; + if (!rErrorKey.test(key)) { + ret[key] = obj[key]; + } + } + return ret; + } + util.markAsOriginatingFromRejection(obj); + return obj; +} + +function nodebackForPromise(promise, multiArgs) { + return function(err, value) { + if (promise === null) return; + if (err) { + var wrapped = wrapAsOperationalError(maybeWrapAsError(err)); + promise._attachExtraTrace(wrapped); + promise._reject(wrapped); + } else if (!multiArgs) { + promise._fulfill(value); + } else { + var args = [].slice.call(arguments, 1);; + promise._fulfill(args); + } + promise = null; + }; +} + +module.exports = nodebackForPromise; + +},{"./errors":12,"./es5":13,"./util":36}],21:[function(_dereq_,module,exports){ +"use strict"; +module.exports = function(Promise) { +var util = _dereq_("./util"); +var async = Promise._async; +var tryCatch = util.tryCatch; +var errorObj = util.errorObj; + +function spreadAdapter(val, nodeback) { + var promise = this; + if (!util.isArray(val)) return successAdapter.call(promise, val, nodeback); + var ret = + tryCatch(nodeback).apply(promise._boundValue(), [null].concat(val)); + if (ret === errorObj) { + async.throwLater(ret.e); + } +} + +function successAdapter(val, nodeback) { + var promise = this; + var receiver = promise._boundValue(); + var ret = val === undefined + ? tryCatch(nodeback).call(receiver, null) + : tryCatch(nodeback).call(receiver, null, val); + if (ret === errorObj) { + async.throwLater(ret.e); + } +} +function errorAdapter(reason, nodeback) { + var promise = this; + if (!reason) { + var newReason = new Error(reason + ""); + newReason.cause = reason; + reason = newReason; + } + var ret = tryCatch(nodeback).call(promise._boundValue(), reason); + if (ret === errorObj) { + async.throwLater(ret.e); + } +} + +Promise.prototype.asCallback = Promise.prototype.nodeify = function (nodeback, + options) { + if (typeof nodeback == "function") { + var adapter = successAdapter; + if (options !== undefined && Object(options).spread) { + adapter = spreadAdapter; + } + this._then( + adapter, + errorAdapter, + undefined, + this, + nodeback + ); + } + return this; +}; +}; + +},{"./util":36}],22:[function(_dereq_,module,exports){ +"use strict"; +module.exports = function() { +var makeSelfResolutionError = function () { + return new TypeError("circular promise resolution chain\u000a\u000a See http://goo.gl/MqrFmX\u000a"); +}; +var reflectHandler = function() { + return new Promise.PromiseInspection(this._target()); +}; +var apiRejection = function(msg) { + return Promise.reject(new TypeError(msg)); +}; +function Proxyable() {} +var UNDEFINED_BINDING = {}; +var util = _dereq_("./util"); + +var getDomain; +if (util.isNode) { + getDomain = function() { + var ret = process.domain; + if (ret === undefined) ret = null; + return ret; + }; +} else { + getDomain = function() { + return null; + }; +} +util.notEnumerableProp(Promise, "_getDomain", getDomain); + +var es5 = _dereq_("./es5"); +var Async = _dereq_("./async"); +var async = new Async(); +es5.defineProperty(Promise, "_async", {value: async}); +var errors = _dereq_("./errors"); +var TypeError = Promise.TypeError = errors.TypeError; +Promise.RangeError = errors.RangeError; +var CancellationError = Promise.CancellationError = errors.CancellationError; +Promise.TimeoutError = errors.TimeoutError; +Promise.OperationalError = errors.OperationalError; +Promise.RejectionError = errors.OperationalError; +Promise.AggregateError = errors.AggregateError; +var INTERNAL = function(){}; +var APPLY = {}; +var NEXT_FILTER = {}; +var tryConvertToPromise = _dereq_("./thenables")(Promise, INTERNAL); +var PromiseArray = + _dereq_("./promise_array")(Promise, INTERNAL, + tryConvertToPromise, apiRejection, Proxyable); +var Context = _dereq_("./context")(Promise); + /*jshint unused:false*/ +var createContext = Context.create; +var debug = _dereq_("./debuggability")(Promise, Context); +var CapturedTrace = debug.CapturedTrace; +var PassThroughHandlerContext = + _dereq_("./finally")(Promise, tryConvertToPromise, NEXT_FILTER); +var catchFilter = _dereq_("./catch_filter")(NEXT_FILTER); +var nodebackForPromise = _dereq_("./nodeback"); +var errorObj = util.errorObj; +var tryCatch = util.tryCatch; +function check(self, executor) { + if (self == null || self.constructor !== Promise) { + throw new TypeError("the promise constructor cannot be invoked directly\u000a\u000a See http://goo.gl/MqrFmX\u000a"); + } + if (typeof executor !== "function") { + throw new TypeError("expecting a function but got " + util.classString(executor)); + } + +} + +function Promise(executor) { + if (executor !== INTERNAL) { + check(this, executor); + } + this._bitField = 0; + this._fulfillmentHandler0 = undefined; + this._rejectionHandler0 = undefined; + this._promise0 = undefined; + this._receiver0 = undefined; + this._resolveFromExecutor(executor); + this._promiseCreated(); + this._fireEvent("promiseCreated", this); +} + +Promise.prototype.toString = function () { + return "[object Promise]"; +}; + +Promise.prototype.caught = Promise.prototype["catch"] = function (fn) { + var len = arguments.length; + if (len > 1) { + var catchInstances = new Array(len - 1), + j = 0, i; + for (i = 0; i < len - 1; ++i) { + var item = arguments[i]; + if (util.isObject(item)) { + catchInstances[j++] = item; + } else { + return apiRejection("Catch statement predicate: " + + "expecting an object but got " + util.classString(item)); + } + } + catchInstances.length = j; + fn = arguments[i]; + return this.then(undefined, catchFilter(catchInstances, fn, this)); + } + return this.then(undefined, fn); +}; + +Promise.prototype.reflect = function () { + return this._then(reflectHandler, + reflectHandler, undefined, this, undefined); +}; + +Promise.prototype.then = function (didFulfill, didReject) { + if (debug.warnings() && arguments.length > 0 && + typeof didFulfill !== "function" && + typeof didReject !== "function") { + var msg = ".then() only accepts functions but was passed: " + + util.classString(didFulfill); + if (arguments.length > 1) { + msg += ", " + util.classString(didReject); + } + this._warn(msg); + } + return this._then(didFulfill, didReject, undefined, undefined, undefined); +}; + +Promise.prototype.done = function (didFulfill, didReject) { + var promise = + this._then(didFulfill, didReject, undefined, undefined, undefined); + promise._setIsFinal(); +}; + +Promise.prototype.spread = function (fn) { + if (typeof fn !== "function") { + return apiRejection("expecting a function but got " + util.classString(fn)); + } + return this.all()._then(fn, undefined, undefined, APPLY, undefined); +}; + +Promise.prototype.toJSON = function () { + var ret = { + isFulfilled: false, + isRejected: false, + fulfillmentValue: undefined, + rejectionReason: undefined + }; + if (this.isFulfilled()) { + ret.fulfillmentValue = this.value(); + ret.isFulfilled = true; + } else if (this.isRejected()) { + ret.rejectionReason = this.reason(); + ret.isRejected = true; + } + return ret; +}; + +Promise.prototype.all = function () { + if (arguments.length > 0) { + this._warn(".all() was passed arguments but it does not take any"); + } + return new PromiseArray(this).promise(); +}; + +Promise.prototype.error = function (fn) { + return this.caught(util.originatesFromRejection, fn); +}; + +Promise.getNewLibraryCopy = module.exports; + +Promise.is = function (val) { + return val instanceof Promise; +}; + +Promise.fromNode = Promise.fromCallback = function(fn) { + var ret = new Promise(INTERNAL); + ret._captureStackTrace(); + var multiArgs = arguments.length > 1 ? !!Object(arguments[1]).multiArgs + : false; + var result = tryCatch(fn)(nodebackForPromise(ret, multiArgs)); + if (result === errorObj) { + ret._rejectCallback(result.e, true); + } + if (!ret._isFateSealed()) ret._setAsyncGuaranteed(); + return ret; +}; + +Promise.all = function (promises) { + return new PromiseArray(promises).promise(); +}; + +Promise.cast = function (obj) { + var ret = tryConvertToPromise(obj); + if (!(ret instanceof Promise)) { + ret = new Promise(INTERNAL); + ret._captureStackTrace(); + ret._setFulfilled(); + ret._rejectionHandler0 = obj; + } + return ret; +}; + +Promise.resolve = Promise.fulfilled = Promise.cast; + +Promise.reject = Promise.rejected = function (reason) { + var ret = new Promise(INTERNAL); + ret._captureStackTrace(); + ret._rejectCallback(reason, true); + return ret; +}; + +Promise.setScheduler = function(fn) { + if (typeof fn !== "function") { + throw new TypeError("expecting a function but got " + util.classString(fn)); + } + return async.setScheduler(fn); +}; + +Promise.prototype._then = function ( + didFulfill, + didReject, + _, receiver, + internalData +) { + var haveInternalData = internalData !== undefined; + var promise = haveInternalData ? internalData : new Promise(INTERNAL); + var target = this._target(); + var bitField = target._bitField; + + if (!haveInternalData) { + promise._propagateFrom(this, 3); + promise._captureStackTrace(); + if (receiver === undefined && + ((this._bitField & 2097152) !== 0)) { + if (!((bitField & 50397184) === 0)) { + receiver = this._boundValue(); + } else { + receiver = target === this ? undefined : this._boundTo; + } + } + this._fireEvent("promiseChained", this, promise); + } + + var domain = getDomain(); + if (!((bitField & 50397184) === 0)) { + var handler, value, settler = target._settlePromiseCtx; + if (((bitField & 33554432) !== 0)) { + value = target._rejectionHandler0; + handler = didFulfill; + } else if (((bitField & 16777216) !== 0)) { + value = target._fulfillmentHandler0; + handler = didReject; + target._unsetRejectionIsUnhandled(); + } else { + settler = target._settlePromiseLateCancellationObserver; + value = new CancellationError("late cancellation observer"); + target._attachExtraTrace(value); + handler = didReject; + } + + async.invoke(settler, target, { + handler: domain === null ? handler + : (typeof handler === "function" && + util.domainBind(domain, handler)), + promise: promise, + receiver: receiver, + value: value + }); + } else { + target._addCallbacks(didFulfill, didReject, promise, receiver, domain); + } + + return promise; +}; + +Promise.prototype._length = function () { + return this._bitField & 65535; +}; + +Promise.prototype._isFateSealed = function () { + return (this._bitField & 117506048) !== 0; +}; + +Promise.prototype._isFollowing = function () { + return (this._bitField & 67108864) === 67108864; +}; + +Promise.prototype._setLength = function (len) { + this._bitField = (this._bitField & -65536) | + (len & 65535); +}; + +Promise.prototype._setFulfilled = function () { + this._bitField = this._bitField | 33554432; + this._fireEvent("promiseFulfilled", this); +}; + +Promise.prototype._setRejected = function () { + this._bitField = this._bitField | 16777216; + this._fireEvent("promiseRejected", this); +}; + +Promise.prototype._setFollowing = function () { + this._bitField = this._bitField | 67108864; + this._fireEvent("promiseResolved", this); +}; + +Promise.prototype._setIsFinal = function () { + this._bitField = this._bitField | 4194304; +}; + +Promise.prototype._isFinal = function () { + return (this._bitField & 4194304) > 0; +}; + +Promise.prototype._unsetCancelled = function() { + this._bitField = this._bitField & (~65536); +}; + +Promise.prototype._setCancelled = function() { + this._bitField = this._bitField | 65536; + this._fireEvent("promiseCancelled", this); +}; + +Promise.prototype._setWillBeCancelled = function() { + this._bitField = this._bitField | 8388608; +}; + +Promise.prototype._setAsyncGuaranteed = function() { + if (async.hasCustomScheduler()) return; + this._bitField = this._bitField | 134217728; +}; + +Promise.prototype._receiverAt = function (index) { + var ret = index === 0 ? this._receiver0 : this[ + index * 4 - 4 + 3]; + if (ret === UNDEFINED_BINDING) { + return undefined; + } else if (ret === undefined && this._isBound()) { + return this._boundValue(); + } + return ret; +}; + +Promise.prototype._promiseAt = function (index) { + return this[ + index * 4 - 4 + 2]; +}; + +Promise.prototype._fulfillmentHandlerAt = function (index) { + return this[ + index * 4 - 4 + 0]; +}; + +Promise.prototype._rejectionHandlerAt = function (index) { + return this[ + index * 4 - 4 + 1]; +}; + +Promise.prototype._boundValue = function() {}; + +Promise.prototype._migrateCallback0 = function (follower) { + var bitField = follower._bitField; + var fulfill = follower._fulfillmentHandler0; + var reject = follower._rejectionHandler0; + var promise = follower._promise0; + var receiver = follower._receiverAt(0); + if (receiver === undefined) receiver = UNDEFINED_BINDING; + this._addCallbacks(fulfill, reject, promise, receiver, null); +}; + +Promise.prototype._migrateCallbackAt = function (follower, index) { + var fulfill = follower._fulfillmentHandlerAt(index); + var reject = follower._rejectionHandlerAt(index); + var promise = follower._promiseAt(index); + var receiver = follower._receiverAt(index); + if (receiver === undefined) receiver = UNDEFINED_BINDING; + this._addCallbacks(fulfill, reject, promise, receiver, null); +}; + +Promise.prototype._addCallbacks = function ( + fulfill, + reject, + promise, + receiver, + domain +) { + var index = this._length(); + + if (index >= 65535 - 4) { + index = 0; + this._setLength(0); + } + + if (index === 0) { + this._promise0 = promise; + this._receiver0 = receiver; + if (typeof fulfill === "function") { + this._fulfillmentHandler0 = + domain === null ? fulfill : util.domainBind(domain, fulfill); + } + if (typeof reject === "function") { + this._rejectionHandler0 = + domain === null ? reject : util.domainBind(domain, reject); + } + } else { + var base = index * 4 - 4; + this[base + 2] = promise; + this[base + 3] = receiver; + if (typeof fulfill === "function") { + this[base + 0] = + domain === null ? fulfill : util.domainBind(domain, fulfill); + } + if (typeof reject === "function") { + this[base + 1] = + domain === null ? reject : util.domainBind(domain, reject); + } + } + this._setLength(index + 1); + return index; +}; + +Promise.prototype._proxy = function (proxyable, arg) { + this._addCallbacks(undefined, undefined, arg, proxyable, null); +}; + +Promise.prototype._resolveCallback = function(value, shouldBind) { + if (((this._bitField & 117506048) !== 0)) return; + if (value === this) + return this._rejectCallback(makeSelfResolutionError(), false); + var maybePromise = tryConvertToPromise(value, this); + if (!(maybePromise instanceof Promise)) return this._fulfill(value); + + if (shouldBind) this._propagateFrom(maybePromise, 2); + + var promise = maybePromise._target(); + + if (promise === this) { + this._reject(makeSelfResolutionError()); + return; + } + + var bitField = promise._bitField; + if (((bitField & 50397184) === 0)) { + var len = this._length(); + if (len > 0) promise._migrateCallback0(this); + for (var i = 1; i < len; ++i) { + promise._migrateCallbackAt(this, i); + } + this._setFollowing(); + this._setLength(0); + this._setFollowee(promise); + } else if (((bitField & 33554432) !== 0)) { + this._fulfill(promise._value()); + } else if (((bitField & 16777216) !== 0)) { + this._reject(promise._reason()); + } else { + var reason = new CancellationError("late cancellation observer"); + promise._attachExtraTrace(reason); + this._reject(reason); + } +}; + +Promise.prototype._rejectCallback = +function(reason, synchronous, ignoreNonErrorWarnings) { + var trace = util.ensureErrorObject(reason); + var hasStack = trace === reason; + if (!hasStack && !ignoreNonErrorWarnings && debug.warnings()) { + var message = "a promise was rejected with a non-error: " + + util.classString(reason); + this._warn(message, true); + } + this._attachExtraTrace(trace, synchronous ? hasStack : false); + this._reject(reason); +}; + +Promise.prototype._resolveFromExecutor = function (executor) { + if (executor === INTERNAL) return; + var promise = this; + this._captureStackTrace(); + this._pushContext(); + var synchronous = true; + var r = this._execute(executor, function(value) { + promise._resolveCallback(value); + }, function (reason) { + promise._rejectCallback(reason, synchronous); + }); + synchronous = false; + this._popContext(); + + if (r !== undefined) { + promise._rejectCallback(r, true); + } +}; + +Promise.prototype._settlePromiseFromHandler = function ( + handler, receiver, value, promise +) { + var bitField = promise._bitField; + if (((bitField & 65536) !== 0)) return; + promise._pushContext(); + var x; + if (receiver === APPLY) { + if (!value || typeof value.length !== "number") { + x = errorObj; + x.e = new TypeError("cannot .spread() a non-array: " + + util.classString(value)); + } else { + x = tryCatch(handler).apply(this._boundValue(), value); + } + } else { + x = tryCatch(handler).call(receiver, value); + } + var promiseCreated = promise._popContext(); + bitField = promise._bitField; + if (((bitField & 65536) !== 0)) return; + + if (x === NEXT_FILTER) { + promise._reject(value); + } else if (x === errorObj) { + promise._rejectCallback(x.e, false); + } else { + debug.checkForgottenReturns(x, promiseCreated, "", promise, this); + promise._resolveCallback(x); + } +}; + +Promise.prototype._target = function() { + var ret = this; + while (ret._isFollowing()) ret = ret._followee(); + return ret; +}; + +Promise.prototype._followee = function() { + return this._rejectionHandler0; +}; + +Promise.prototype._setFollowee = function(promise) { + this._rejectionHandler0 = promise; +}; + +Promise.prototype._settlePromise = function(promise, handler, receiver, value) { + var isPromise = promise instanceof Promise; + var bitField = this._bitField; + var asyncGuaranteed = ((bitField & 134217728) !== 0); + if (((bitField & 65536) !== 0)) { + if (isPromise) promise._invokeInternalOnCancel(); + + if (receiver instanceof PassThroughHandlerContext && + receiver.isFinallyHandler()) { + receiver.cancelPromise = promise; + if (tryCatch(handler).call(receiver, value) === errorObj) { + promise._reject(errorObj.e); + } + } else if (handler === reflectHandler) { + promise._fulfill(reflectHandler.call(receiver)); + } else if (receiver instanceof Proxyable) { + receiver._promiseCancelled(promise); + } else if (isPromise || promise instanceof PromiseArray) { + promise._cancel(); + } else { + receiver.cancel(); + } + } else if (typeof handler === "function") { + if (!isPromise) { + handler.call(receiver, value, promise); + } else { + if (asyncGuaranteed) promise._setAsyncGuaranteed(); + this._settlePromiseFromHandler(handler, receiver, value, promise); + } + } else if (receiver instanceof Proxyable) { + if (!receiver._isResolved()) { + if (((bitField & 33554432) !== 0)) { + receiver._promiseFulfilled(value, promise); + } else { + receiver._promiseRejected(value, promise); + } + } + } else if (isPromise) { + if (asyncGuaranteed) promise._setAsyncGuaranteed(); + if (((bitField & 33554432) !== 0)) { + promise._fulfill(value); + } else { + promise._reject(value); + } + } +}; + +Promise.prototype._settlePromiseLateCancellationObserver = function(ctx) { + var handler = ctx.handler; + var promise = ctx.promise; + var receiver = ctx.receiver; + var value = ctx.value; + if (typeof handler === "function") { + if (!(promise instanceof Promise)) { + handler.call(receiver, value, promise); + } else { + this._settlePromiseFromHandler(handler, receiver, value, promise); + } + } else if (promise instanceof Promise) { + promise._reject(value); + } +}; + +Promise.prototype._settlePromiseCtx = function(ctx) { + this._settlePromise(ctx.promise, ctx.handler, ctx.receiver, ctx.value); +}; + +Promise.prototype._settlePromise0 = function(handler, value, bitField) { + var promise = this._promise0; + var receiver = this._receiverAt(0); + this._promise0 = undefined; + this._receiver0 = undefined; + this._settlePromise(promise, handler, receiver, value); +}; + +Promise.prototype._clearCallbackDataAtIndex = function(index) { + var base = index * 4 - 4; + this[base + 2] = + this[base + 3] = + this[base + 0] = + this[base + 1] = undefined; +}; + +Promise.prototype._fulfill = function (value) { + var bitField = this._bitField; + if (((bitField & 117506048) >>> 16)) return; + if (value === this) { + var err = makeSelfResolutionError(); + this._attachExtraTrace(err); + return this._reject(err); + } + this._setFulfilled(); + this._rejectionHandler0 = value; + + if ((bitField & 65535) > 0) { + if (((bitField & 134217728) !== 0)) { + this._settlePromises(); + } else { + async.settlePromises(this); + } + } +}; + +Promise.prototype._reject = function (reason) { + var bitField = this._bitField; + if (((bitField & 117506048) >>> 16)) return; + this._setRejected(); + this._fulfillmentHandler0 = reason; + + if (this._isFinal()) { + return async.fatalError(reason, util.isNode); + } + + if ((bitField & 65535) > 0) { + async.settlePromises(this); + } else { + this._ensurePossibleRejectionHandled(); + } +}; + +Promise.prototype._fulfillPromises = function (len, value) { + for (var i = 1; i < len; i++) { + var handler = this._fulfillmentHandlerAt(i); + var promise = this._promiseAt(i); + var receiver = this._receiverAt(i); + this._clearCallbackDataAtIndex(i); + this._settlePromise(promise, handler, receiver, value); + } +}; + +Promise.prototype._rejectPromises = function (len, reason) { + for (var i = 1; i < len; i++) { + var handler = this._rejectionHandlerAt(i); + var promise = this._promiseAt(i); + var receiver = this._receiverAt(i); + this._clearCallbackDataAtIndex(i); + this._settlePromise(promise, handler, receiver, reason); + } +}; + +Promise.prototype._settlePromises = function () { + var bitField = this._bitField; + var len = (bitField & 65535); + + if (len > 0) { + if (((bitField & 16842752) !== 0)) { + var reason = this._fulfillmentHandler0; + this._settlePromise0(this._rejectionHandler0, reason, bitField); + this._rejectPromises(len, reason); + } else { + var value = this._rejectionHandler0; + this._settlePromise0(this._fulfillmentHandler0, value, bitField); + this._fulfillPromises(len, value); + } + this._setLength(0); + } + this._clearCancellationData(); +}; + +Promise.prototype._settledValue = function() { + var bitField = this._bitField; + if (((bitField & 33554432) !== 0)) { + return this._rejectionHandler0; + } else if (((bitField & 16777216) !== 0)) { + return this._fulfillmentHandler0; + } +}; + +function deferResolve(v) {this.promise._resolveCallback(v);} +function deferReject(v) {this.promise._rejectCallback(v, false);} + +Promise.defer = Promise.pending = function() { + debug.deprecated("Promise.defer", "new Promise"); + var promise = new Promise(INTERNAL); + return { + promise: promise, + resolve: deferResolve, + reject: deferReject + }; +}; + +util.notEnumerableProp(Promise, + "_makeSelfResolutionError", + makeSelfResolutionError); + +_dereq_("./method")(Promise, INTERNAL, tryConvertToPromise, apiRejection, + debug); +_dereq_("./bind")(Promise, INTERNAL, tryConvertToPromise, debug); +_dereq_("./cancel")(Promise, PromiseArray, apiRejection, debug); +_dereq_("./direct_resolve")(Promise); +_dereq_("./synchronous_inspection")(Promise); +_dereq_("./join")( + Promise, PromiseArray, tryConvertToPromise, INTERNAL, async, getDomain); +Promise.Promise = Promise; +Promise.version = "3.5.1"; +_dereq_('./map.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL, debug); +_dereq_('./call_get.js')(Promise); +_dereq_('./using.js')(Promise, apiRejection, tryConvertToPromise, createContext, INTERNAL, debug); +_dereq_('./timers.js')(Promise, INTERNAL, debug); +_dereq_('./generators.js')(Promise, apiRejection, INTERNAL, tryConvertToPromise, Proxyable, debug); +_dereq_('./nodeify.js')(Promise); +_dereq_('./promisify.js')(Promise, INTERNAL); +_dereq_('./props.js')(Promise, PromiseArray, tryConvertToPromise, apiRejection); +_dereq_('./race.js')(Promise, INTERNAL, tryConvertToPromise, apiRejection); +_dereq_('./reduce.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL, debug); +_dereq_('./settle.js')(Promise, PromiseArray, debug); +_dereq_('./some.js')(Promise, PromiseArray, apiRejection); +_dereq_('./filter.js')(Promise, INTERNAL); +_dereq_('./each.js')(Promise, INTERNAL); +_dereq_('./any.js')(Promise); + + util.toFastProperties(Promise); + util.toFastProperties(Promise.prototype); + function fillTypes(value) { + var p = new Promise(INTERNAL); + p._fulfillmentHandler0 = value; + p._rejectionHandler0 = value; + p._promise0 = value; + p._receiver0 = value; + } + // Complete slack tracking, opt out of field-type tracking and + // stabilize map + fillTypes({a: 1}); + fillTypes({b: 2}); + fillTypes({c: 3}); + fillTypes(1); + fillTypes(function(){}); + fillTypes(undefined); + fillTypes(false); + fillTypes(new Promise(INTERNAL)); + debug.setBounds(Async.firstLineError, util.lastLineError); + return Promise; + +}; + +},{"./any.js":1,"./async":2,"./bind":3,"./call_get.js":5,"./cancel":6,"./catch_filter":7,"./context":8,"./debuggability":9,"./direct_resolve":10,"./each.js":11,"./errors":12,"./es5":13,"./filter.js":14,"./finally":15,"./generators.js":16,"./join":17,"./map.js":18,"./method":19,"./nodeback":20,"./nodeify.js":21,"./promise_array":23,"./promisify.js":24,"./props.js":25,"./race.js":27,"./reduce.js":28,"./settle.js":30,"./some.js":31,"./synchronous_inspection":32,"./thenables":33,"./timers.js":34,"./using.js":35,"./util":36}],23:[function(_dereq_,module,exports){ +"use strict"; +module.exports = function(Promise, INTERNAL, tryConvertToPromise, + apiRejection, Proxyable) { +var util = _dereq_("./util"); +var isArray = util.isArray; + +function toResolutionValue(val) { + switch(val) { + case -2: return []; + case -3: return {}; + case -6: return new Map(); + } +} + +function PromiseArray(values) { + var promise = this._promise = new Promise(INTERNAL); + if (values instanceof Promise) { + promise._propagateFrom(values, 3); + } + promise._setOnCancel(this); + this._values = values; + this._length = 0; + this._totalResolved = 0; + this._init(undefined, -2); +} +util.inherits(PromiseArray, Proxyable); + +PromiseArray.prototype.length = function () { + return this._length; +}; + +PromiseArray.prototype.promise = function () { + return this._promise; +}; + +PromiseArray.prototype._init = function init(_, resolveValueIfEmpty) { + var values = tryConvertToPromise(this._values, this._promise); + if (values instanceof Promise) { + values = values._target(); + var bitField = values._bitField; + ; + this._values = values; + + if (((bitField & 50397184) === 0)) { + this._promise._setAsyncGuaranteed(); + return values._then( + init, + this._reject, + undefined, + this, + resolveValueIfEmpty + ); + } else if (((bitField & 33554432) !== 0)) { + values = values._value(); + } else if (((bitField & 16777216) !== 0)) { + return this._reject(values._reason()); + } else { + return this._cancel(); + } + } + values = util.asArray(values); + if (values === null) { + var err = apiRejection( + "expecting an array or an iterable object but got " + util.classString(values)).reason(); + this._promise._rejectCallback(err, false); + return; + } + + if (values.length === 0) { + if (resolveValueIfEmpty === -5) { + this._resolveEmptyArray(); + } + else { + this._resolve(toResolutionValue(resolveValueIfEmpty)); + } + return; + } + this._iterate(values); +}; + +PromiseArray.prototype._iterate = function(values) { + var len = this.getActualLength(values.length); + this._length = len; + this._values = this.shouldCopyValues() ? new Array(len) : this._values; + var result = this._promise; + var isResolved = false; + var bitField = null; + for (var i = 0; i < len; ++i) { + var maybePromise = tryConvertToPromise(values[i], result); + + if (maybePromise instanceof Promise) { + maybePromise = maybePromise._target(); + bitField = maybePromise._bitField; + } else { + bitField = null; + } + + if (isResolved) { + if (bitField !== null) { + maybePromise.suppressUnhandledRejections(); + } + } else if (bitField !== null) { + if (((bitField & 50397184) === 0)) { + maybePromise._proxy(this, i); + this._values[i] = maybePromise; + } else if (((bitField & 33554432) !== 0)) { + isResolved = this._promiseFulfilled(maybePromise._value(), i); + } else if (((bitField & 16777216) !== 0)) { + isResolved = this._promiseRejected(maybePromise._reason(), i); + } else { + isResolved = this._promiseCancelled(i); + } + } else { + isResolved = this._promiseFulfilled(maybePromise, i); + } + } + if (!isResolved) result._setAsyncGuaranteed(); +}; + +PromiseArray.prototype._isResolved = function () { + return this._values === null; +}; + +PromiseArray.prototype._resolve = function (value) { + this._values = null; + this._promise._fulfill(value); +}; + +PromiseArray.prototype._cancel = function() { + if (this._isResolved() || !this._promise._isCancellable()) return; + this._values = null; + this._promise._cancel(); +}; + +PromiseArray.prototype._reject = function (reason) { + this._values = null; + this._promise._rejectCallback(reason, false); +}; + +PromiseArray.prototype._promiseFulfilled = function (value, index) { + this._values[index] = value; + var totalResolved = ++this._totalResolved; + if (totalResolved >= this._length) { + this._resolve(this._values); + return true; + } + return false; +}; + +PromiseArray.prototype._promiseCancelled = function() { + this._cancel(); + return true; +}; + +PromiseArray.prototype._promiseRejected = function (reason) { + this._totalResolved++; + this._reject(reason); + return true; +}; + +PromiseArray.prototype._resultCancelled = function() { + if (this._isResolved()) return; + var values = this._values; + this._cancel(); + if (values instanceof Promise) { + values.cancel(); + } else { + for (var i = 0; i < values.length; ++i) { + if (values[i] instanceof Promise) { + values[i].cancel(); + } + } + } +}; + +PromiseArray.prototype.shouldCopyValues = function () { + return true; +}; + +PromiseArray.prototype.getActualLength = function (len) { + return len; +}; + +return PromiseArray; +}; + +},{"./util":36}],24:[function(_dereq_,module,exports){ +"use strict"; +module.exports = function(Promise, INTERNAL) { +var THIS = {}; +var util = _dereq_("./util"); +var nodebackForPromise = _dereq_("./nodeback"); +var withAppended = util.withAppended; +var maybeWrapAsError = util.maybeWrapAsError; +var canEvaluate = util.canEvaluate; +var TypeError = _dereq_("./errors").TypeError; +var defaultSuffix = "Async"; +var defaultPromisified = {__isPromisified__: true}; +var noCopyProps = [ + "arity", "length", + "name", + "arguments", + "caller", + "callee", + "prototype", + "__isPromisified__" +]; +var noCopyPropsPattern = new RegExp("^(?:" + noCopyProps.join("|") + ")$"); + +var defaultFilter = function(name) { + return util.isIdentifier(name) && + name.charAt(0) !== "_" && + name !== "constructor"; +}; + +function propsFilter(key) { + return !noCopyPropsPattern.test(key); +} + +function isPromisified(fn) { + try { + return fn.__isPromisified__ === true; + } + catch (e) { + return false; + } +} + +function hasPromisified(obj, key, suffix) { + var val = util.getDataPropertyOrDefault(obj, key + suffix, + defaultPromisified); + return val ? isPromisified(val) : false; +} +function checkValid(ret, suffix, suffixRegexp) { + for (var i = 0; i < ret.length; i += 2) { + var key = ret[i]; + if (suffixRegexp.test(key)) { + var keyWithoutAsyncSuffix = key.replace(suffixRegexp, ""); + for (var j = 0; j < ret.length; j += 2) { + if (ret[j] === keyWithoutAsyncSuffix) { + throw new TypeError("Cannot promisify an API that has normal methods with '%s'-suffix\u000a\u000a See http://goo.gl/MqrFmX\u000a" + .replace("%s", suffix)); + } + } + } + } +} + +function promisifiableMethods(obj, suffix, suffixRegexp, filter) { + var keys = util.inheritedDataKeys(obj); + var ret = []; + for (var i = 0; i < keys.length; ++i) { + var key = keys[i]; + var value = obj[key]; + var passesDefaultFilter = filter === defaultFilter + ? true : defaultFilter(key, value, obj); + if (typeof value === "function" && + !isPromisified(value) && + !hasPromisified(obj, key, suffix) && + filter(key, value, obj, passesDefaultFilter)) { + ret.push(key, value); + } + } + checkValid(ret, suffix, suffixRegexp); + return ret; +} + +var escapeIdentRegex = function(str) { + return str.replace(/([$])/, "\\$"); +}; + +var makeNodePromisifiedEval; +if (false) { +var switchCaseArgumentOrder = function(likelyArgumentCount) { + var ret = [likelyArgumentCount]; + var min = Math.max(0, likelyArgumentCount - 1 - 3); + for(var i = likelyArgumentCount - 1; i >= min; --i) { + ret.push(i); + } + for(var i = likelyArgumentCount + 1; i <= 3; ++i) { + ret.push(i); + } + return ret; +}; + +var argumentSequence = function(argumentCount) { + return util.filledRange(argumentCount, "_arg", ""); +}; + +var parameterDeclaration = function(parameterCount) { + return util.filledRange( + Math.max(parameterCount, 3), "_arg", ""); +}; + +var parameterCount = function(fn) { + if (typeof fn.length === "number") { + return Math.max(Math.min(fn.length, 1023 + 1), 0); + } + return 0; +}; + +makeNodePromisifiedEval = +function(callback, receiver, originalName, fn, _, multiArgs) { + var newParameterCount = Math.max(0, parameterCount(fn) - 1); + var argumentOrder = switchCaseArgumentOrder(newParameterCount); + var shouldProxyThis = typeof callback === "string" || receiver === THIS; + + function generateCallForArgumentCount(count) { + var args = argumentSequence(count).join(", "); + var comma = count > 0 ? ", " : ""; + var ret; + if (shouldProxyThis) { + ret = "ret = callback.call(this, {{args}}, nodeback); break;\n"; + } else { + ret = receiver === undefined + ? "ret = callback({{args}}, nodeback); break;\n" + : "ret = callback.call(receiver, {{args}}, nodeback); break;\n"; + } + return ret.replace("{{args}}", args).replace(", ", comma); + } + + function generateArgumentSwitchCase() { + var ret = ""; + for (var i = 0; i < argumentOrder.length; ++i) { + ret += "case " + argumentOrder[i] +":" + + generateCallForArgumentCount(argumentOrder[i]); + } + + ret += " \n\ + default: \n\ + var args = new Array(len + 1); \n\ + var i = 0; \n\ + for (var i = 0; i < len; ++i) { \n\ + args[i] = arguments[i]; \n\ + } \n\ + args[i] = nodeback; \n\ + [CodeForCall] \n\ + break; \n\ + ".replace("[CodeForCall]", (shouldProxyThis + ? "ret = callback.apply(this, args);\n" + : "ret = callback.apply(receiver, args);\n")); + return ret; + } + + var getFunctionCode = typeof callback === "string" + ? ("this != null ? this['"+callback+"'] : fn") + : "fn"; + var body = "'use strict'; \n\ + var ret = function (Parameters) { \n\ + 'use strict'; \n\ + var len = arguments.length; \n\ + var promise = new Promise(INTERNAL); \n\ + promise._captureStackTrace(); \n\ + var nodeback = nodebackForPromise(promise, " + multiArgs + "); \n\ + var ret; \n\ + var callback = tryCatch([GetFunctionCode]); \n\ + switch(len) { \n\ + [CodeForSwitchCase] \n\ + } \n\ + if (ret === errorObj) { \n\ + promise._rejectCallback(maybeWrapAsError(ret.e), true, true);\n\ + } \n\ + if (!promise._isFateSealed()) promise._setAsyncGuaranteed(); \n\ + return promise; \n\ + }; \n\ + notEnumerableProp(ret, '__isPromisified__', true); \n\ + return ret; \n\ + ".replace("[CodeForSwitchCase]", generateArgumentSwitchCase()) + .replace("[GetFunctionCode]", getFunctionCode); + body = body.replace("Parameters", parameterDeclaration(newParameterCount)); + return new Function("Promise", + "fn", + "receiver", + "withAppended", + "maybeWrapAsError", + "nodebackForPromise", + "tryCatch", + "errorObj", + "notEnumerableProp", + "INTERNAL", + body)( + Promise, + fn, + receiver, + withAppended, + maybeWrapAsError, + nodebackForPromise, + util.tryCatch, + util.errorObj, + util.notEnumerableProp, + INTERNAL); +}; +} + +function makeNodePromisifiedClosure(callback, receiver, _, fn, __, multiArgs) { + var defaultThis = (function() {return this;})(); + var method = callback; + if (typeof method === "string") { + callback = fn; + } + function promisified() { + var _receiver = receiver; + if (receiver === THIS) _receiver = this; + var promise = new Promise(INTERNAL); + promise._captureStackTrace(); + var cb = typeof method === "string" && this !== defaultThis + ? this[method] : callback; + var fn = nodebackForPromise(promise, multiArgs); + try { + cb.apply(_receiver, withAppended(arguments, fn)); + } catch(e) { + promise._rejectCallback(maybeWrapAsError(e), true, true); + } + if (!promise._isFateSealed()) promise._setAsyncGuaranteed(); + return promise; + } + util.notEnumerableProp(promisified, "__isPromisified__", true); + return promisified; +} + +var makeNodePromisified = canEvaluate + ? makeNodePromisifiedEval + : makeNodePromisifiedClosure; + +function promisifyAll(obj, suffix, filter, promisifier, multiArgs) { + var suffixRegexp = new RegExp(escapeIdentRegex(suffix) + "$"); + var methods = + promisifiableMethods(obj, suffix, suffixRegexp, filter); + + for (var i = 0, len = methods.length; i < len; i+= 2) { + var key = methods[i]; + var fn = methods[i+1]; + var promisifiedKey = key + suffix; + if (promisifier === makeNodePromisified) { + obj[promisifiedKey] = + makeNodePromisified(key, THIS, key, fn, suffix, multiArgs); + } else { + var promisified = promisifier(fn, function() { + return makeNodePromisified(key, THIS, key, + fn, suffix, multiArgs); + }); + util.notEnumerableProp(promisified, "__isPromisified__", true); + obj[promisifiedKey] = promisified; + } + } + util.toFastProperties(obj); + return obj; +} + +function promisify(callback, receiver, multiArgs) { + return makeNodePromisified(callback, receiver, undefined, + callback, null, multiArgs); +} + +Promise.promisify = function (fn, options) { + if (typeof fn !== "function") { + throw new TypeError("expecting a function but got " + util.classString(fn)); + } + if (isPromisified(fn)) { + return fn; + } + options = Object(options); + var receiver = options.context === undefined ? THIS : options.context; + var multiArgs = !!options.multiArgs; + var ret = promisify(fn, receiver, multiArgs); + util.copyDescriptors(fn, ret, propsFilter); + return ret; +}; + +Promise.promisifyAll = function (target, options) { + if (typeof target !== "function" && typeof target !== "object") { + throw new TypeError("the target of promisifyAll must be an object or a function\u000a\u000a See http://goo.gl/MqrFmX\u000a"); + } + options = Object(options); + var multiArgs = !!options.multiArgs; + var suffix = options.suffix; + if (typeof suffix !== "string") suffix = defaultSuffix; + var filter = options.filter; + if (typeof filter !== "function") filter = defaultFilter; + var promisifier = options.promisifier; + if (typeof promisifier !== "function") promisifier = makeNodePromisified; + + if (!util.isIdentifier(suffix)) { + throw new RangeError("suffix must be a valid identifier\u000a\u000a See http://goo.gl/MqrFmX\u000a"); + } + + var keys = util.inheritedDataKeys(target); + for (var i = 0; i < keys.length; ++i) { + var value = target[keys[i]]; + if (keys[i] !== "constructor" && + util.isClass(value)) { + promisifyAll(value.prototype, suffix, filter, promisifier, + multiArgs); + promisifyAll(value, suffix, filter, promisifier, multiArgs); + } + } + + return promisifyAll(target, suffix, filter, promisifier, multiArgs); +}; +}; + + +},{"./errors":12,"./nodeback":20,"./util":36}],25:[function(_dereq_,module,exports){ +"use strict"; +module.exports = function( + Promise, PromiseArray, tryConvertToPromise, apiRejection) { +var util = _dereq_("./util"); +var isObject = util.isObject; +var es5 = _dereq_("./es5"); +var Es6Map; +if (typeof Map === "function") Es6Map = Map; + +var mapToEntries = (function() { + var index = 0; + var size = 0; + + function extractEntry(value, key) { + this[index] = value; + this[index + size] = key; + index++; + } + + return function mapToEntries(map) { + size = map.size; + index = 0; + var ret = new Array(map.size * 2); + map.forEach(extractEntry, ret); + return ret; + }; +})(); + +var entriesToMap = function(entries) { + var ret = new Es6Map(); + var length = entries.length / 2 | 0; + for (var i = 0; i < length; ++i) { + var key = entries[length + i]; + var value = entries[i]; + ret.set(key, value); + } + return ret; +}; + +function PropertiesPromiseArray(obj) { + var isMap = false; + var entries; + if (Es6Map !== undefined && obj instanceof Es6Map) { + entries = mapToEntries(obj); + isMap = true; + } else { + var keys = es5.keys(obj); + var len = keys.length; + entries = new Array(len * 2); + for (var i = 0; i < len; ++i) { + var key = keys[i]; + entries[i] = obj[key]; + entries[i + len] = key; + } + } + this.constructor$(entries); + this._isMap = isMap; + this._init$(undefined, isMap ? -6 : -3); +} +util.inherits(PropertiesPromiseArray, PromiseArray); + +PropertiesPromiseArray.prototype._init = function () {}; + +PropertiesPromiseArray.prototype._promiseFulfilled = function (value, index) { + this._values[index] = value; + var totalResolved = ++this._totalResolved; + if (totalResolved >= this._length) { + var val; + if (this._isMap) { + val = entriesToMap(this._values); + } else { + val = {}; + var keyOffset = this.length(); + for (var i = 0, len = this.length(); i < len; ++i) { + val[this._values[i + keyOffset]] = this._values[i]; + } + } + this._resolve(val); + return true; + } + return false; +}; + +PropertiesPromiseArray.prototype.shouldCopyValues = function () { + return false; +}; + +PropertiesPromiseArray.prototype.getActualLength = function (len) { + return len >> 1; +}; + +function props(promises) { + var ret; + var castValue = tryConvertToPromise(promises); + + if (!isObject(castValue)) { + return apiRejection("cannot await properties of a non-object\u000a\u000a See http://goo.gl/MqrFmX\u000a"); + } else if (castValue instanceof Promise) { + ret = castValue._then( + Promise.props, undefined, undefined, undefined, undefined); + } else { + ret = new PropertiesPromiseArray(castValue).promise(); + } + + if (castValue instanceof Promise) { + ret._propagateFrom(castValue, 2); + } + return ret; +} + +Promise.prototype.props = function () { + return props(this); +}; + +Promise.props = function (promises) { + return props(promises); +}; +}; + +},{"./es5":13,"./util":36}],26:[function(_dereq_,module,exports){ +"use strict"; +function arrayMove(src, srcIndex, dst, dstIndex, len) { + for (var j = 0; j < len; ++j) { + dst[j + dstIndex] = src[j + srcIndex]; + src[j + srcIndex] = void 0; + } +} + +function Queue(capacity) { + this._capacity = capacity; + this._length = 0; + this._front = 0; +} + +Queue.prototype._willBeOverCapacity = function (size) { + return this._capacity < size; +}; + +Queue.prototype._pushOne = function (arg) { + var length = this.length(); + this._checkCapacity(length + 1); + var i = (this._front + length) & (this._capacity - 1); + this[i] = arg; + this._length = length + 1; +}; + +Queue.prototype.push = function (fn, receiver, arg) { + var length = this.length() + 3; + if (this._willBeOverCapacity(length)) { + this._pushOne(fn); + this._pushOne(receiver); + this._pushOne(arg); + return; + } + var j = this._front + length - 3; + this._checkCapacity(length); + var wrapMask = this._capacity - 1; + this[(j + 0) & wrapMask] = fn; + this[(j + 1) & wrapMask] = receiver; + this[(j + 2) & wrapMask] = arg; + this._length = length; +}; + +Queue.prototype.shift = function () { + var front = this._front, + ret = this[front]; + + this[front] = undefined; + this._front = (front + 1) & (this._capacity - 1); + this._length--; + return ret; +}; + +Queue.prototype.length = function () { + return this._length; +}; + +Queue.prototype._checkCapacity = function (size) { + if (this._capacity < size) { + this._resizeTo(this._capacity << 1); + } +}; + +Queue.prototype._resizeTo = function (capacity) { + var oldCapacity = this._capacity; + this._capacity = capacity; + var front = this._front; + var length = this._length; + var moveItemsCount = (front + length) & (oldCapacity - 1); + arrayMove(this, 0, this, oldCapacity, moveItemsCount); +}; + +module.exports = Queue; + +},{}],27:[function(_dereq_,module,exports){ +"use strict"; +module.exports = function( + Promise, INTERNAL, tryConvertToPromise, apiRejection) { +var util = _dereq_("./util"); + +var raceLater = function (promise) { + return promise.then(function(array) { + return race(array, promise); + }); +}; + +function race(promises, parent) { + var maybePromise = tryConvertToPromise(promises); + + if (maybePromise instanceof Promise) { + return raceLater(maybePromise); + } else { + promises = util.asArray(promises); + if (promises === null) + return apiRejection("expecting an array or an iterable object but got " + util.classString(promises)); + } + + var ret = new Promise(INTERNAL); + if (parent !== undefined) { + ret._propagateFrom(parent, 3); + } + var fulfill = ret._fulfill; + var reject = ret._reject; + for (var i = 0, len = promises.length; i < len; ++i) { + var val = promises[i]; + + if (val === undefined && !(i in promises)) { + continue; + } + + Promise.cast(val)._then(fulfill, reject, undefined, ret, null); + } + return ret; +} + +Promise.race = function (promises) { + return race(promises, undefined); +}; + +Promise.prototype.race = function () { + return race(this, undefined); +}; + +}; + +},{"./util":36}],28:[function(_dereq_,module,exports){ +"use strict"; +module.exports = function(Promise, + PromiseArray, + apiRejection, + tryConvertToPromise, + INTERNAL, + debug) { +var getDomain = Promise._getDomain; +var util = _dereq_("./util"); +var tryCatch = util.tryCatch; + +function ReductionPromiseArray(promises, fn, initialValue, _each) { + this.constructor$(promises); + var domain = getDomain(); + this._fn = domain === null ? fn : util.domainBind(domain, fn); + if (initialValue !== undefined) { + initialValue = Promise.resolve(initialValue); + initialValue._attachCancellationCallback(this); + } + this._initialValue = initialValue; + this._currentCancellable = null; + if(_each === INTERNAL) { + this._eachValues = Array(this._length); + } else if (_each === 0) { + this._eachValues = null; + } else { + this._eachValues = undefined; + } + this._promise._captureStackTrace(); + this._init$(undefined, -5); +} +util.inherits(ReductionPromiseArray, PromiseArray); + +ReductionPromiseArray.prototype._gotAccum = function(accum) { + if (this._eachValues !== undefined && + this._eachValues !== null && + accum !== INTERNAL) { + this._eachValues.push(accum); + } +}; + +ReductionPromiseArray.prototype._eachComplete = function(value) { + if (this._eachValues !== null) { + this._eachValues.push(value); + } + return this._eachValues; +}; + +ReductionPromiseArray.prototype._init = function() {}; + +ReductionPromiseArray.prototype._resolveEmptyArray = function() { + this._resolve(this._eachValues !== undefined ? this._eachValues + : this._initialValue); +}; + +ReductionPromiseArray.prototype.shouldCopyValues = function () { + return false; +}; + +ReductionPromiseArray.prototype._resolve = function(value) { + this._promise._resolveCallback(value); + this._values = null; +}; + +ReductionPromiseArray.prototype._resultCancelled = function(sender) { + if (sender === this._initialValue) return this._cancel(); + if (this._isResolved()) return; + this._resultCancelled$(); + if (this._currentCancellable instanceof Promise) { + this._currentCancellable.cancel(); + } + if (this._initialValue instanceof Promise) { + this._initialValue.cancel(); + } +}; + +ReductionPromiseArray.prototype._iterate = function (values) { + this._values = values; + var value; + var i; + var length = values.length; + if (this._initialValue !== undefined) { + value = this._initialValue; + i = 0; + } else { + value = Promise.resolve(values[0]); + i = 1; + } + + this._currentCancellable = value; + + if (!value.isRejected()) { + for (; i < length; ++i) { + var ctx = { + accum: null, + value: values[i], + index: i, + length: length, + array: this + }; + value = value._then(gotAccum, undefined, undefined, ctx, undefined); + } + } + + if (this._eachValues !== undefined) { + value = value + ._then(this._eachComplete, undefined, undefined, this, undefined); + } + value._then(completed, completed, undefined, value, this); +}; + +Promise.prototype.reduce = function (fn, initialValue) { + return reduce(this, fn, initialValue, null); +}; + +Promise.reduce = function (promises, fn, initialValue, _each) { + return reduce(promises, fn, initialValue, _each); +}; + +function completed(valueOrReason, array) { + if (this.isFulfilled()) { + array._resolve(valueOrReason); + } else { + array._reject(valueOrReason); + } +} + +function reduce(promises, fn, initialValue, _each) { + if (typeof fn !== "function") { + return apiRejection("expecting a function but got " + util.classString(fn)); + } + var array = new ReductionPromiseArray(promises, fn, initialValue, _each); + return array.promise(); +} + +function gotAccum(accum) { + this.accum = accum; + this.array._gotAccum(accum); + var value = tryConvertToPromise(this.value, this.array._promise); + if (value instanceof Promise) { + this.array._currentCancellable = value; + return value._then(gotValue, undefined, undefined, this, undefined); + } else { + return gotValue.call(this, value); + } +} + +function gotValue(value) { + var array = this.array; + var promise = array._promise; + var fn = tryCatch(array._fn); + promise._pushContext(); + var ret; + if (array._eachValues !== undefined) { + ret = fn.call(promise._boundValue(), value, this.index, this.length); + } else { + ret = fn.call(promise._boundValue(), + this.accum, value, this.index, this.length); + } + if (ret instanceof Promise) { + array._currentCancellable = ret; + } + var promiseCreated = promise._popContext(); + debug.checkForgottenReturns( + ret, + promiseCreated, + array._eachValues !== undefined ? "Promise.each" : "Promise.reduce", + promise + ); + return ret; +} +}; + +},{"./util":36}],29:[function(_dereq_,module,exports){ +"use strict"; +var util = _dereq_("./util"); +var schedule; +var noAsyncScheduler = function() { + throw new Error("No async scheduler available\u000a\u000a See http://goo.gl/MqrFmX\u000a"); +}; +var NativePromise = util.getNativePromise(); +if (util.isNode && typeof MutationObserver === "undefined") { + var GlobalSetImmediate = global.setImmediate; + var ProcessNextTick = process.nextTick; + schedule = util.isRecentNode + ? function(fn) { GlobalSetImmediate.call(global, fn); } + : function(fn) { ProcessNextTick.call(process, fn); }; +} else if (typeof NativePromise === "function" && + typeof NativePromise.resolve === "function") { + var nativePromise = NativePromise.resolve(); + schedule = function(fn) { + nativePromise.then(fn); + }; +} else if ((typeof MutationObserver !== "undefined") && + !(typeof window !== "undefined" && + window.navigator && + (window.navigator.standalone || window.cordova))) { + schedule = (function() { + var div = document.createElement("div"); + var opts = {attributes: true}; + var toggleScheduled = false; + var div2 = document.createElement("div"); + var o2 = new MutationObserver(function() { + div.classList.toggle("foo"); + toggleScheduled = false; + }); + o2.observe(div2, opts); + + var scheduleToggle = function() { + if (toggleScheduled) return; + toggleScheduled = true; + div2.classList.toggle("foo"); + }; + + return function schedule(fn) { + var o = new MutationObserver(function() { + o.disconnect(); + fn(); + }); + o.observe(div, opts); + scheduleToggle(); + }; + })(); +} else if (typeof setImmediate !== "undefined") { + schedule = function (fn) { + setImmediate(fn); + }; +} else if (typeof setTimeout !== "undefined") { + schedule = function (fn) { + setTimeout(fn, 0); + }; +} else { + schedule = noAsyncScheduler; +} +module.exports = schedule; + +},{"./util":36}],30:[function(_dereq_,module,exports){ +"use strict"; +module.exports = + function(Promise, PromiseArray, debug) { +var PromiseInspection = Promise.PromiseInspection; +var util = _dereq_("./util"); + +function SettledPromiseArray(values) { + this.constructor$(values); +} +util.inherits(SettledPromiseArray, PromiseArray); + +SettledPromiseArray.prototype._promiseResolved = function (index, inspection) { + this._values[index] = inspection; + var totalResolved = ++this._totalResolved; + if (totalResolved >= this._length) { + this._resolve(this._values); + return true; + } + return false; +}; + +SettledPromiseArray.prototype._promiseFulfilled = function (value, index) { + var ret = new PromiseInspection(); + ret._bitField = 33554432; + ret._settledValueField = value; + return this._promiseResolved(index, ret); +}; +SettledPromiseArray.prototype._promiseRejected = function (reason, index) { + var ret = new PromiseInspection(); + ret._bitField = 16777216; + ret._settledValueField = reason; + return this._promiseResolved(index, ret); +}; + +Promise.settle = function (promises) { + debug.deprecated(".settle()", ".reflect()"); + return new SettledPromiseArray(promises).promise(); +}; + +Promise.prototype.settle = function () { + return Promise.settle(this); +}; +}; + +},{"./util":36}],31:[function(_dereq_,module,exports){ +"use strict"; +module.exports = +function(Promise, PromiseArray, apiRejection) { +var util = _dereq_("./util"); +var RangeError = _dereq_("./errors").RangeError; +var AggregateError = _dereq_("./errors").AggregateError; +var isArray = util.isArray; +var CANCELLATION = {}; + + +function SomePromiseArray(values) { + this.constructor$(values); + this._howMany = 0; + this._unwrap = false; + this._initialized = false; +} +util.inherits(SomePromiseArray, PromiseArray); + +SomePromiseArray.prototype._init = function () { + if (!this._initialized) { + return; + } + if (this._howMany === 0) { + this._resolve([]); + return; + } + this._init$(undefined, -5); + var isArrayResolved = isArray(this._values); + if (!this._isResolved() && + isArrayResolved && + this._howMany > this._canPossiblyFulfill()) { + this._reject(this._getRangeError(this.length())); + } +}; + +SomePromiseArray.prototype.init = function () { + this._initialized = true; + this._init(); +}; + +SomePromiseArray.prototype.setUnwrap = function () { + this._unwrap = true; +}; + +SomePromiseArray.prototype.howMany = function () { + return this._howMany; +}; + +SomePromiseArray.prototype.setHowMany = function (count) { + this._howMany = count; +}; + +SomePromiseArray.prototype._promiseFulfilled = function (value) { + this._addFulfilled(value); + if (this._fulfilled() === this.howMany()) { + this._values.length = this.howMany(); + if (this.howMany() === 1 && this._unwrap) { + this._resolve(this._values[0]); + } else { + this._resolve(this._values); + } + return true; + } + return false; + +}; +SomePromiseArray.prototype._promiseRejected = function (reason) { + this._addRejected(reason); + return this._checkOutcome(); +}; + +SomePromiseArray.prototype._promiseCancelled = function () { + if (this._values instanceof Promise || this._values == null) { + return this._cancel(); + } + this._addRejected(CANCELLATION); + return this._checkOutcome(); +}; + +SomePromiseArray.prototype._checkOutcome = function() { + if (this.howMany() > this._canPossiblyFulfill()) { + var e = new AggregateError(); + for (var i = this.length(); i < this._values.length; ++i) { + if (this._values[i] !== CANCELLATION) { + e.push(this._values[i]); + } + } + if (e.length > 0) { + this._reject(e); + } else { + this._cancel(); + } + return true; + } + return false; +}; + +SomePromiseArray.prototype._fulfilled = function () { + return this._totalResolved; +}; + +SomePromiseArray.prototype._rejected = function () { + return this._values.length - this.length(); +}; + +SomePromiseArray.prototype._addRejected = function (reason) { + this._values.push(reason); +}; + +SomePromiseArray.prototype._addFulfilled = function (value) { + this._values[this._totalResolved++] = value; +}; + +SomePromiseArray.prototype._canPossiblyFulfill = function () { + return this.length() - this._rejected(); +}; + +SomePromiseArray.prototype._getRangeError = function (count) { + var message = "Input array must contain at least " + + this._howMany + " items but contains only " + count + " items"; + return new RangeError(message); +}; + +SomePromiseArray.prototype._resolveEmptyArray = function () { + this._reject(this._getRangeError(0)); +}; + +function some(promises, howMany) { + if ((howMany | 0) !== howMany || howMany < 0) { + return apiRejection("expecting a positive integer\u000a\u000a See http://goo.gl/MqrFmX\u000a"); + } + var ret = new SomePromiseArray(promises); + var promise = ret.promise(); + ret.setHowMany(howMany); + ret.init(); + return promise; +} + +Promise.some = function (promises, howMany) { + return some(promises, howMany); +}; + +Promise.prototype.some = function (howMany) { + return some(this, howMany); +}; + +Promise._SomePromiseArray = SomePromiseArray; +}; + +},{"./errors":12,"./util":36}],32:[function(_dereq_,module,exports){ +"use strict"; +module.exports = function(Promise) { +function PromiseInspection(promise) { + if (promise !== undefined) { + promise = promise._target(); + this._bitField = promise._bitField; + this._settledValueField = promise._isFateSealed() + ? promise._settledValue() : undefined; + } + else { + this._bitField = 0; + this._settledValueField = undefined; + } +} + +PromiseInspection.prototype._settledValue = function() { + return this._settledValueField; +}; + +var value = PromiseInspection.prototype.value = function () { + if (!this.isFulfilled()) { + throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\u000a\u000a See http://goo.gl/MqrFmX\u000a"); + } + return this._settledValue(); +}; + +var reason = PromiseInspection.prototype.error = +PromiseInspection.prototype.reason = function () { + if (!this.isRejected()) { + throw new TypeError("cannot get rejection reason of a non-rejected promise\u000a\u000a See http://goo.gl/MqrFmX\u000a"); + } + return this._settledValue(); +}; + +var isFulfilled = PromiseInspection.prototype.isFulfilled = function() { + return (this._bitField & 33554432) !== 0; +}; + +var isRejected = PromiseInspection.prototype.isRejected = function () { + return (this._bitField & 16777216) !== 0; +}; + +var isPending = PromiseInspection.prototype.isPending = function () { + return (this._bitField & 50397184) === 0; +}; + +var isResolved = PromiseInspection.prototype.isResolved = function () { + return (this._bitField & 50331648) !== 0; +}; + +PromiseInspection.prototype.isCancelled = function() { + return (this._bitField & 8454144) !== 0; +}; + +Promise.prototype.__isCancelled = function() { + return (this._bitField & 65536) === 65536; +}; + +Promise.prototype._isCancelled = function() { + return this._target().__isCancelled(); +}; + +Promise.prototype.isCancelled = function() { + return (this._target()._bitField & 8454144) !== 0; +}; + +Promise.prototype.isPending = function() { + return isPending.call(this._target()); +}; + +Promise.prototype.isRejected = function() { + return isRejected.call(this._target()); +}; + +Promise.prototype.isFulfilled = function() { + return isFulfilled.call(this._target()); +}; + +Promise.prototype.isResolved = function() { + return isResolved.call(this._target()); +}; + +Promise.prototype.value = function() { + return value.call(this._target()); +}; + +Promise.prototype.reason = function() { + var target = this._target(); + target._unsetRejectionIsUnhandled(); + return reason.call(target); +}; + +Promise.prototype._value = function() { + return this._settledValue(); +}; + +Promise.prototype._reason = function() { + this._unsetRejectionIsUnhandled(); + return this._settledValue(); +}; + +Promise.PromiseInspection = PromiseInspection; +}; + +},{}],33:[function(_dereq_,module,exports){ +"use strict"; +module.exports = function(Promise, INTERNAL) { +var util = _dereq_("./util"); +var errorObj = util.errorObj; +var isObject = util.isObject; + +function tryConvertToPromise(obj, context) { + if (isObject(obj)) { + if (obj instanceof Promise) return obj; + var then = getThen(obj); + if (then === errorObj) { + if (context) context._pushContext(); + var ret = Promise.reject(then.e); + if (context) context._popContext(); + return ret; + } else if (typeof then === "function") { + if (isAnyBluebirdPromise(obj)) { + var ret = new Promise(INTERNAL); + obj._then( + ret._fulfill, + ret._reject, + undefined, + ret, + null + ); + return ret; + } + return doThenable(obj, then, context); + } + } + return obj; +} + +function doGetThen(obj) { + return obj.then; +} + +function getThen(obj) { + try { + return doGetThen(obj); + } catch (e) { + errorObj.e = e; + return errorObj; + } +} + +var hasProp = {}.hasOwnProperty; +function isAnyBluebirdPromise(obj) { + try { + return hasProp.call(obj, "_promise0"); + } catch (e) { + return false; + } +} + +function doThenable(x, then, context) { + var promise = new Promise(INTERNAL); + var ret = promise; + if (context) context._pushContext(); + promise._captureStackTrace(); + if (context) context._popContext(); + var synchronous = true; + var result = util.tryCatch(then).call(x, resolve, reject); + synchronous = false; + + if (promise && result === errorObj) { + promise._rejectCallback(result.e, true, true); + promise = null; + } + + function resolve(value) { + if (!promise) return; + promise._resolveCallback(value); + promise = null; + } + + function reject(reason) { + if (!promise) return; + promise._rejectCallback(reason, synchronous, true); + promise = null; + } + return ret; +} + +return tryConvertToPromise; +}; + +},{"./util":36}],34:[function(_dereq_,module,exports){ +"use strict"; +module.exports = function(Promise, INTERNAL, debug) { +var util = _dereq_("./util"); +var TimeoutError = Promise.TimeoutError; + +function HandleWrapper(handle) { + this.handle = handle; +} + +HandleWrapper.prototype._resultCancelled = function() { + clearTimeout(this.handle); +}; + +var afterValue = function(value) { return delay(+this).thenReturn(value); }; +var delay = Promise.delay = function (ms, value) { + var ret; + var handle; + if (value !== undefined) { + ret = Promise.resolve(value) + ._then(afterValue, null, null, ms, undefined); + if (debug.cancellation() && value instanceof Promise) { + ret._setOnCancel(value); + } + } else { + ret = new Promise(INTERNAL); + handle = setTimeout(function() { ret._fulfill(); }, +ms); + if (debug.cancellation()) { + ret._setOnCancel(new HandleWrapper(handle)); + } + ret._captureStackTrace(); + } + ret._setAsyncGuaranteed(); + return ret; +}; + +Promise.prototype.delay = function (ms) { + return delay(ms, this); +}; + +var afterTimeout = function (promise, message, parent) { + var err; + if (typeof message !== "string") { + if (message instanceof Error) { + err = message; + } else { + err = new TimeoutError("operation timed out"); + } + } else { + err = new TimeoutError(message); + } + util.markAsOriginatingFromRejection(err); + promise._attachExtraTrace(err); + promise._reject(err); + + if (parent != null) { + parent.cancel(); + } +}; + +function successClear(value) { + clearTimeout(this.handle); + return value; +} + +function failureClear(reason) { + clearTimeout(this.handle); + throw reason; +} + +Promise.prototype.timeout = function (ms, message) { + ms = +ms; + var ret, parent; + + var handleWrapper = new HandleWrapper(setTimeout(function timeoutTimeout() { + if (ret.isPending()) { + afterTimeout(ret, message, parent); + } + }, ms)); + + if (debug.cancellation()) { + parent = this.then(); + ret = parent._then(successClear, failureClear, + undefined, handleWrapper, undefined); + ret._setOnCancel(handleWrapper); + } else { + ret = this._then(successClear, failureClear, + undefined, handleWrapper, undefined); + } + + return ret; +}; + +}; + +},{"./util":36}],35:[function(_dereq_,module,exports){ +"use strict"; +module.exports = function (Promise, apiRejection, tryConvertToPromise, + createContext, INTERNAL, debug) { + var util = _dereq_("./util"); + var TypeError = _dereq_("./errors").TypeError; + var inherits = _dereq_("./util").inherits; + var errorObj = util.errorObj; + var tryCatch = util.tryCatch; + var NULL = {}; + + function thrower(e) { + setTimeout(function(){throw e;}, 0); + } + + function castPreservingDisposable(thenable) { + var maybePromise = tryConvertToPromise(thenable); + if (maybePromise !== thenable && + typeof thenable._isDisposable === "function" && + typeof thenable._getDisposer === "function" && + thenable._isDisposable()) { + maybePromise._setDisposable(thenable._getDisposer()); + } + return maybePromise; + } + function dispose(resources, inspection) { + var i = 0; + var len = resources.length; + var ret = new Promise(INTERNAL); + function iterator() { + if (i >= len) return ret._fulfill(); + var maybePromise = castPreservingDisposable(resources[i++]); + if (maybePromise instanceof Promise && + maybePromise._isDisposable()) { + try { + maybePromise = tryConvertToPromise( + maybePromise._getDisposer().tryDispose(inspection), + resources.promise); + } catch (e) { + return thrower(e); + } + if (maybePromise instanceof Promise) { + return maybePromise._then(iterator, thrower, + null, null, null); + } + } + iterator(); + } + iterator(); + return ret; + } + + function Disposer(data, promise, context) { + this._data = data; + this._promise = promise; + this._context = context; + } + + Disposer.prototype.data = function () { + return this._data; + }; + + Disposer.prototype.promise = function () { + return this._promise; + }; + + Disposer.prototype.resource = function () { + if (this.promise().isFulfilled()) { + return this.promise().value(); + } + return NULL; + }; + + Disposer.prototype.tryDispose = function(inspection) { + var resource = this.resource(); + var context = this._context; + if (context !== undefined) context._pushContext(); + var ret = resource !== NULL + ? this.doDispose(resource, inspection) : null; + if (context !== undefined) context._popContext(); + this._promise._unsetDisposable(); + this._data = null; + return ret; + }; + + Disposer.isDisposer = function (d) { + return (d != null && + typeof d.resource === "function" && + typeof d.tryDispose === "function"); + }; + + function FunctionDisposer(fn, promise, context) { + this.constructor$(fn, promise, context); + } + inherits(FunctionDisposer, Disposer); + + FunctionDisposer.prototype.doDispose = function (resource, inspection) { + var fn = this.data(); + return fn.call(resource, resource, inspection); + }; + + function maybeUnwrapDisposer(value) { + if (Disposer.isDisposer(value)) { + this.resources[this.index]._setDisposable(value); + return value.promise(); + } + return value; + } + + function ResourceList(length) { + this.length = length; + this.promise = null; + this[length-1] = null; + } + + ResourceList.prototype._resultCancelled = function() { + var len = this.length; + for (var i = 0; i < len; ++i) { + var item = this[i]; + if (item instanceof Promise) { + item.cancel(); + } + } + }; + + Promise.using = function () { + var len = arguments.length; + if (len < 2) return apiRejection( + "you must pass at least 2 arguments to Promise.using"); + var fn = arguments[len - 1]; + if (typeof fn !== "function") { + return apiRejection("expecting a function but got " + util.classString(fn)); + } + var input; + var spreadArgs = true; + if (len === 2 && Array.isArray(arguments[0])) { + input = arguments[0]; + len = input.length; + spreadArgs = false; + } else { + input = arguments; + len--; + } + var resources = new ResourceList(len); + for (var i = 0; i < len; ++i) { + var resource = input[i]; + if (Disposer.isDisposer(resource)) { + var disposer = resource; + resource = resource.promise(); + resource._setDisposable(disposer); + } else { + var maybePromise = tryConvertToPromise(resource); + if (maybePromise instanceof Promise) { + resource = + maybePromise._then(maybeUnwrapDisposer, null, null, { + resources: resources, + index: i + }, undefined); + } + } + resources[i] = resource; + } + + var reflectedResources = new Array(resources.length); + for (var i = 0; i < reflectedResources.length; ++i) { + reflectedResources[i] = Promise.resolve(resources[i]).reflect(); + } + + var resultPromise = Promise.all(reflectedResources) + .then(function(inspections) { + for (var i = 0; i < inspections.length; ++i) { + var inspection = inspections[i]; + if (inspection.isRejected()) { + errorObj.e = inspection.error(); + return errorObj; + } else if (!inspection.isFulfilled()) { + resultPromise.cancel(); + return; + } + inspections[i] = inspection.value(); + } + promise._pushContext(); + + fn = tryCatch(fn); + var ret = spreadArgs + ? fn.apply(undefined, inspections) : fn(inspections); + var promiseCreated = promise._popContext(); + debug.checkForgottenReturns( + ret, promiseCreated, "Promise.using", promise); + return ret; + }); + + var promise = resultPromise.lastly(function() { + var inspection = new Promise.PromiseInspection(resultPromise); + return dispose(resources, inspection); + }); + resources.promise = promise; + promise._setOnCancel(resources); + return promise; + }; + + Promise.prototype._setDisposable = function (disposer) { + this._bitField = this._bitField | 131072; + this._disposer = disposer; + }; + + Promise.prototype._isDisposable = function () { + return (this._bitField & 131072) > 0; + }; + + Promise.prototype._getDisposer = function () { + return this._disposer; + }; + + Promise.prototype._unsetDisposable = function () { + this._bitField = this._bitField & (~131072); + this._disposer = undefined; + }; + + Promise.prototype.disposer = function (fn) { + if (typeof fn === "function") { + return new FunctionDisposer(fn, this, createContext()); + } + throw new TypeError(); + }; + +}; + +},{"./errors":12,"./util":36}],36:[function(_dereq_,module,exports){ +"use strict"; +var es5 = _dereq_("./es5"); +var canEvaluate = typeof navigator == "undefined"; + +var errorObj = {e: {}}; +var tryCatchTarget; +var globalObject = typeof self !== "undefined" ? self : + typeof window !== "undefined" ? window : + typeof global !== "undefined" ? global : + this !== undefined ? this : null; + +function tryCatcher() { + try { + var target = tryCatchTarget; + tryCatchTarget = null; + return target.apply(this, arguments); + } catch (e) { + errorObj.e = e; + return errorObj; + } +} +function tryCatch(fn) { + tryCatchTarget = fn; + return tryCatcher; +} + +var inherits = function(Child, Parent) { + var hasProp = {}.hasOwnProperty; + + function T() { + this.constructor = Child; + this.constructor$ = Parent; + for (var propertyName in Parent.prototype) { + if (hasProp.call(Parent.prototype, propertyName) && + propertyName.charAt(propertyName.length-1) !== "$" + ) { + this[propertyName + "$"] = Parent.prototype[propertyName]; + } + } + } + T.prototype = Parent.prototype; + Child.prototype = new T(); + return Child.prototype; +}; + + +function isPrimitive(val) { + return val == null || val === true || val === false || + typeof val === "string" || typeof val === "number"; + +} + +function isObject(value) { + return typeof value === "function" || + typeof value === "object" && value !== null; +} + +function maybeWrapAsError(maybeError) { + if (!isPrimitive(maybeError)) return maybeError; + + return new Error(safeToString(maybeError)); +} + +function withAppended(target, appendee) { + var len = target.length; + var ret = new Array(len + 1); + var i; + for (i = 0; i < len; ++i) { + ret[i] = target[i]; + } + ret[i] = appendee; + return ret; +} + +function getDataPropertyOrDefault(obj, key, defaultValue) { + if (es5.isES5) { + var desc = Object.getOwnPropertyDescriptor(obj, key); + + if (desc != null) { + return desc.get == null && desc.set == null + ? desc.value + : defaultValue; + } + } else { + return {}.hasOwnProperty.call(obj, key) ? obj[key] : undefined; + } +} + +function notEnumerableProp(obj, name, value) { + if (isPrimitive(obj)) return obj; + var descriptor = { + value: value, + configurable: true, + enumerable: false, + writable: true + }; + es5.defineProperty(obj, name, descriptor); + return obj; +} + +function thrower(r) { + throw r; +} + +var inheritedDataKeys = (function() { + var excludedPrototypes = [ + Array.prototype, + Object.prototype, + Function.prototype + ]; + + var isExcludedProto = function(val) { + for (var i = 0; i < excludedPrototypes.length; ++i) { + if (excludedPrototypes[i] === val) { + return true; + } + } + return false; + }; + + if (es5.isES5) { + var getKeys = Object.getOwnPropertyNames; + return function(obj) { + var ret = []; + var visitedKeys = Object.create(null); + while (obj != null && !isExcludedProto(obj)) { + var keys; + try { + keys = getKeys(obj); + } catch (e) { + return ret; + } + for (var i = 0; i < keys.length; ++i) { + var key = keys[i]; + if (visitedKeys[key]) continue; + visitedKeys[key] = true; + var desc = Object.getOwnPropertyDescriptor(obj, key); + if (desc != null && desc.get == null && desc.set == null) { + ret.push(key); + } + } + obj = es5.getPrototypeOf(obj); + } + return ret; + }; + } else { + var hasProp = {}.hasOwnProperty; + return function(obj) { + if (isExcludedProto(obj)) return []; + var ret = []; + + /*jshint forin:false */ + enumeration: for (var key in obj) { + if (hasProp.call(obj, key)) { + ret.push(key); + } else { + for (var i = 0; i < excludedPrototypes.length; ++i) { + if (hasProp.call(excludedPrototypes[i], key)) { + continue enumeration; + } + } + ret.push(key); + } + } + return ret; + }; + } + +})(); + +var thisAssignmentPattern = /this\s*\.\s*\S+\s*=/; +function isClass(fn) { + try { + if (typeof fn === "function") { + var keys = es5.names(fn.prototype); + + var hasMethods = es5.isES5 && keys.length > 1; + var hasMethodsOtherThanConstructor = keys.length > 0 && + !(keys.length === 1 && keys[0] === "constructor"); + var hasThisAssignmentAndStaticMethods = + thisAssignmentPattern.test(fn + "") && es5.names(fn).length > 0; + + if (hasMethods || hasMethodsOtherThanConstructor || + hasThisAssignmentAndStaticMethods) { + return true; + } + } + return false; + } catch (e) { + return false; + } +} + +function toFastProperties(obj) { + /*jshint -W027,-W055,-W031*/ + function FakeConstructor() {} + FakeConstructor.prototype = obj; + var l = 8; + while (l--) new FakeConstructor(); + return obj; + eval(obj); +} + +var rident = /^[a-z$_][a-z$_0-9]*$/i; +function isIdentifier(str) { + return rident.test(str); +} + +function filledRange(count, prefix, suffix) { + var ret = new Array(count); + for(var i = 0; i < count; ++i) { + ret[i] = prefix + i + suffix; + } + return ret; +} + +function safeToString(obj) { + try { + return obj + ""; + } catch (e) { + return "[no string representation]"; + } +} + +function isError(obj) { + return obj instanceof Error || + (obj !== null && + typeof obj === "object" && + typeof obj.message === "string" && + typeof obj.name === "string"); +} + +function markAsOriginatingFromRejection(e) { + try { + notEnumerableProp(e, "isOperational", true); + } + catch(ignore) {} +} + +function originatesFromRejection(e) { + if (e == null) return false; + return ((e instanceof Error["__BluebirdErrorTypes__"].OperationalError) || + e["isOperational"] === true); +} + +function canAttachTrace(obj) { + return isError(obj) && es5.propertyIsWritable(obj, "stack"); +} + +var ensureErrorObject = (function() { + if (!("stack" in new Error())) { + return function(value) { + if (canAttachTrace(value)) return value; + try {throw new Error(safeToString(value));} + catch(err) {return err;} + }; + } else { + return function(value) { + if (canAttachTrace(value)) return value; + return new Error(safeToString(value)); + }; + } +})(); + +function classString(obj) { + return {}.toString.call(obj); +} + +function copyDescriptors(from, to, filter) { + var keys = es5.names(from); + for (var i = 0; i < keys.length; ++i) { + var key = keys[i]; + if (filter(key)) { + try { + es5.defineProperty(to, key, es5.getDescriptor(from, key)); + } catch (ignore) {} + } + } +} + +var asArray = function(v) { + if (es5.isArray(v)) { + return v; + } + return null; +}; + +if (typeof Symbol !== "undefined" && Symbol.iterator) { + var ArrayFrom = typeof Array.from === "function" ? function(v) { + return Array.from(v); + } : function(v) { + var ret = []; + var it = v[Symbol.iterator](); + var itResult; + while (!((itResult = it.next()).done)) { + ret.push(itResult.value); + } + return ret; + }; + + asArray = function(v) { + if (es5.isArray(v)) { + return v; + } else if (v != null && typeof v[Symbol.iterator] === "function") { + return ArrayFrom(v); + } + return null; + }; +} + +var isNode = typeof process !== "undefined" && + classString(process).toLowerCase() === "[object process]"; + +var hasEnvVariables = typeof process !== "undefined" && + typeof process.env !== "undefined"; + +function env(key) { + return hasEnvVariables ? process.env[key] : undefined; +} + +function getNativePromise() { + if (typeof Promise === "function") { + try { + var promise = new Promise(function(){}); + if ({}.toString.call(promise) === "[object Promise]") { + return Promise; + } + } catch (e) {} + } +} + +function domainBind(self, cb) { + return self.bind(cb); +} + +var ret = { + isClass: isClass, + isIdentifier: isIdentifier, + inheritedDataKeys: inheritedDataKeys, + getDataPropertyOrDefault: getDataPropertyOrDefault, + thrower: thrower, + isArray: es5.isArray, + asArray: asArray, + notEnumerableProp: notEnumerableProp, + isPrimitive: isPrimitive, + isObject: isObject, + isError: isError, + canEvaluate: canEvaluate, + errorObj: errorObj, + tryCatch: tryCatch, + inherits: inherits, + withAppended: withAppended, + maybeWrapAsError: maybeWrapAsError, + toFastProperties: toFastProperties, + filledRange: filledRange, + toString: safeToString, + canAttachTrace: canAttachTrace, + ensureErrorObject: ensureErrorObject, + originatesFromRejection: originatesFromRejection, + markAsOriginatingFromRejection: markAsOriginatingFromRejection, + classString: classString, + copyDescriptors: copyDescriptors, + hasDevTools: typeof chrome !== "undefined" && chrome && + typeof chrome.loadTimes === "function", + isNode: isNode, + hasEnvVariables: hasEnvVariables, + env: env, + global: globalObject, + getNativePromise: getNativePromise, + domainBind: domainBind +}; +ret.isRecentNode = ret.isNode && (function() { + var version = process.versions.node.split(".").map(Number); + return (version[0] === 0 && version[1] > 10) || (version[0] > 0); +})(); + +if (ret.isNode) ret.toFastProperties(process); + +try {throw new Error(); } catch (e) {ret.lastLineError = e;} +module.exports = ret; + +},{"./es5":13}]},{},[4])(4) +}); ;if (typeof window !== 'undefined' && window !== null) { window.P = window.Promise; } else if (typeof self !== 'undefined' && self !== null) { self.P = self.Promise; } +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(48), __webpack_require__(33), __webpack_require__(73).setImmediate)) + +/***/ }), +/* 73 */ +/***/ (function(module, exports, __webpack_require__) { + +var apply = Function.prototype.apply; + +// DOM APIs, for completeness + +exports.setTimeout = function() { + return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout); +}; +exports.setInterval = function() { + return new Timeout(apply.call(setInterval, window, arguments), clearInterval); +}; +exports.clearTimeout = +exports.clearInterval = function(timeout) { + if (timeout) { + timeout.close(); + } +}; + +function Timeout(id, clearFn) { + this._id = id; + this._clearFn = clearFn; +} +Timeout.prototype.unref = Timeout.prototype.ref = function() {}; +Timeout.prototype.close = function() { + this._clearFn.call(window, this._id); +}; + +// Does not start the time, just sets up the members needed. +exports.enroll = function(item, msecs) { + clearTimeout(item._idleTimeoutId); + item._idleTimeout = msecs; +}; + +exports.unenroll = function(item) { + clearTimeout(item._idleTimeoutId); + item._idleTimeout = -1; +}; + +exports._unrefActive = exports.active = function(item) { + clearTimeout(item._idleTimeoutId); + + var msecs = item._idleTimeout; + if (msecs >= 0) { + item._idleTimeoutId = setTimeout(function onTimeout() { + if (item._onTimeout) + item._onTimeout(); + }, msecs); + } +}; + +// setimmediate attaches itself to the global object +__webpack_require__(74); +exports.setImmediate = setImmediate; +exports.clearImmediate = clearImmediate; + + +/***/ }), +/* 74 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) { + "use strict"; + + if (global.setImmediate) { + return; + } + + var nextHandle = 1; // Spec says greater than zero + var tasksByHandle = {}; + var currentlyRunningATask = false; + var doc = global.document; + var registerImmediate; + + function setImmediate(callback) { + // Callback can either be a function or a string + if (typeof callback !== "function") { + callback = new Function("" + callback); + } + // Copy function arguments + var args = new Array(arguments.length - 1); + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i + 1]; + } + // Store and register the task + var task = { callback: callback, args: args }; + tasksByHandle[nextHandle] = task; + registerImmediate(nextHandle); + return nextHandle++; + } + + function clearImmediate(handle) { + delete tasksByHandle[handle]; + } + + function run(task) { + var callback = task.callback; + var args = task.args; + switch (args.length) { + case 0: + callback(); + break; + case 1: + callback(args[0]); + break; + case 2: + callback(args[0], args[1]); + break; + case 3: + callback(args[0], args[1], args[2]); + break; + default: + callback.apply(undefined, args); + break; + } + } + + function runIfPresent(handle) { + // From the spec: "Wait until any invocations of this algorithm started before this one have completed." + // So if we're currently running a task, we'll need to delay this invocation. + if (currentlyRunningATask) { + // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a + // "too much recursion" error. + setTimeout(runIfPresent, 0, handle); + } else { + var task = tasksByHandle[handle]; + if (task) { + currentlyRunningATask = true; + try { + run(task); + } finally { + clearImmediate(handle); + currentlyRunningATask = false; + } + } + } + } + + function installNextTickImplementation() { + registerImmediate = function(handle) { + process.nextTick(function () { runIfPresent(handle); }); + }; + } + + function canUsePostMessage() { + // The test against `importScripts` prevents this implementation from being installed inside a web worker, + // where `global.postMessage` means something completely different and can't be used for this purpose. + if (global.postMessage && !global.importScripts) { + var postMessageIsAsynchronous = true; + var oldOnMessage = global.onmessage; + global.onmessage = function() { + postMessageIsAsynchronous = false; + }; + global.postMessage("", "*"); + global.onmessage = oldOnMessage; + return postMessageIsAsynchronous; + } + } + + function installPostMessageImplementation() { + // Installs an event handler on `global` for the `message` event: see + // * https://developer.mozilla.org/en/DOM/window.postMessage + // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages + + var messagePrefix = "setImmediate$" + Math.random() + "$"; + var onGlobalMessage = function(event) { + if (event.source === global && + typeof event.data === "string" && + event.data.indexOf(messagePrefix) === 0) { + runIfPresent(+event.data.slice(messagePrefix.length)); + } + }; + + if (global.addEventListener) { + global.addEventListener("message", onGlobalMessage, false); + } else { + global.attachEvent("onmessage", onGlobalMessage); + } + + registerImmediate = function(handle) { + global.postMessage(messagePrefix + handle, "*"); + }; + } + + function installMessageChannelImplementation() { + var channel = new MessageChannel(); + channel.port1.onmessage = function(event) { + var handle = event.data; + runIfPresent(handle); + }; + + registerImmediate = function(handle) { + channel.port2.postMessage(handle); + }; + } + + function installReadyStateChangeImplementation() { + var html = doc.documentElement; + registerImmediate = function(handle) { + // Create a