diff --git a/playground/index.html b/playground/index.html index 9ed6519b6..67ac05cd1 100644 --- a/playground/index.html +++ b/playground/index.html @@ -720,7 +720,7 @@ <!-- Renderer --> <script src="../node_modules/scratch-render/render.js"></script> <!-- VM Worker --> - <script src="../vm.worker.js"></script> + <script src="../vm.js"></script> <!-- Playground --> <script src="./playground.js"></script> <script> diff --git a/playground/playground.js b/playground/playground.js index a17792bba..9561173b3 100644 --- a/playground/playground.js +++ b/playground/playground.js @@ -35,7 +35,6 @@ window.onload = function() { // Instantiate the renderer and connect it to the VM. var canvas = document.getElementById('scratch-stage'); window.renderer = new window.RenderWebGLLocal(canvas); - window.renderer.connectWorker(window.vm.vmWorker); // Instantiate scratch-blocks and attach it to the DOM. var toolbox = document.getElementById('toolbox'); diff --git a/src/index.js b/src/index.js index e97957d07..a51bae135 100644 --- a/src/index.js +++ b/src/index.js @@ -6,12 +6,6 @@ var sb2import = require('./import/sb2import'); var Sprite = require('./sprites/sprite'); var Blocks = require('./engine/blocks'); -/** - * Whether the environment is a WebWorker. - * @const{boolean} - */ -var ENV_WORKER = typeof importScripts === 'function'; - /** * Handles connections between blocks, stage, and extensions. * @@ -48,6 +42,8 @@ function VirtualMachine () { instance.runtime.on(Runtime.VISUAL_REPORT, function (id, value) { instance.emit(Runtime.VISUAL_REPORT, {id: id, value: value}); }); + + this.blockListener = this.blockListener.bind(this); } /** @@ -166,6 +162,20 @@ VirtualMachine.prototype.createEmptyProject = function () { this.emitWorkspaceUpdate(); }; +/** + * Handle a Blockly event for the current editing target. + * @param {!Blockly.Event} e Any Blockly event. + */ +VirtualMachine.prototype.blockListener = function (e) { + if (this.editingTarget) { + this.editingTarget.blocks.blocklyListen( + e, + false, + this.runtime + ); + } +}; + /** * Set an editing target. An editor UI can use this function to switch * between editing different targets, sprites, etc. @@ -214,107 +224,6 @@ VirtualMachine.prototype.emitWorkspaceUpdate = function () { 'xml': this.editingTarget.blocks.toXML() }); }; - -/* - * Worker handlers: for all public methods available above, - * we must also provide a message handler in case the VM is run - * from a worker environment. - */ -if (ENV_WORKER) { - self.importScripts( - './node_modules/scratch-render/render-worker.js' - ); - self.renderer = new self.RenderWebGLWorker(); - self.vmInstance = new VirtualMachine(); - self.onmessage = function (e) { - var messageData = e.data; - switch (messageData.method) { - case 'start': - self.vmInstance.runtime.start(); - break; - case 'greenFlag': - self.vmInstance.runtime.greenFlag(); - break; - case 'stopAll': - self.vmInstance.runtime.stopAll(); - break; - case 'blockListener': - if (self.vmInstance.editingTarget) { - self.vmInstance.editingTarget.blocks.blocklyListen( - messageData.args, - false, - self.vmInstance.runtime - ); - } - break; - case 'flyoutBlockListener': - if (self.vmInstance.editingTarget) { - self.vmInstance.editingTarget.blocks.blocklyListen( - messageData.args, - true, - self.vmInstance.runtime - ); - } - break; - case 'getPlaygroundData': - self.postMessage({ - method: 'playgroundData', - blocks: self.vmInstance.editingTarget.blocks, - threads: self.vmInstance.runtime.threads - }); - break; - case 'animationFrame': - self.vmInstance.animationFrame(); - break; - case 'postIOData': - self.vmInstance.postIOData(messageData.device, messageData.data); - break; - case 'setEditingTarget': - self.vmInstance.setEditingTarget(messageData.targetId); - break; - case 'createEmptyProject': - self.vmInstance.createEmptyProject(); - break; - case 'loadProject': - self.vmInstance.loadProject(messageData.json); - break; - default: - if (e.data.id == 'RendererConnected') { - //initRenderWorker(); - } - self.renderer.onmessage(e); - break; - } - }; - // Bind runtime's emitted events to postmessages. - self.vmInstance.runtime.on(Runtime.SCRIPT_GLOW_ON, function (id) { - self.postMessage({method: Runtime.SCRIPT_GLOW_ON, id: id}); - }); - self.vmInstance.runtime.on(Runtime.SCRIPT_GLOW_OFF, function (id) { - self.postMessage({method: Runtime.SCRIPT_GLOW_OFF, id: id}); - }); - self.vmInstance.runtime.on(Runtime.BLOCK_GLOW_ON, function (id) { - self.postMessage({method: Runtime.BLOCK_GLOW_ON, id: id}); - }); - self.vmInstance.runtime.on(Runtime.BLOCK_GLOW_OFF, function (id) { - self.postMessage({method: Runtime.BLOCK_GLOW_OFF, id: id}); - }); - self.vmInstance.runtime.on(Runtime.VISUAL_REPORT, function (id, value) { - self.postMessage({method: Runtime.VISUAL_REPORT, id: id, value: value}); - }); - self.vmInstance.on('workspaceUpdate', function(data) { - self.postMessage({method: 'workspaceUpdate', - xml: data.xml - }); - }); - self.vmInstance.on('targetsUpdate', function(data) { - self.postMessage({method: 'targetsUpdate', - targetList: data.targetList, - editingTarget: data.editingTarget - }); - }); -} - /** * Export and bind to `window` */ diff --git a/src/worker.js b/src/worker.js deleted file mode 100644 index 5b46c7e77..000000000 --- a/src/worker.js +++ /dev/null @@ -1,95 +0,0 @@ -var EventEmitter = require('events'); -var util = require('util'); - -function VirtualMachine () { - if (!window.Worker) { - console.error('WebWorkers not supported in this environment.' + - ' Please use the non-worker version (vm.js or vm.min.js).'); - return; - } - var instance = this; - EventEmitter.call(instance); - instance.vmWorker = new Worker('../vm.js'); - - // onmessage calls are converted into emitted events. - instance.vmWorker.onmessage = function (e) { - instance.emit(e.data.method, e.data); - }; - - instance.blockListener = function (e) { - // Messages from Blockly are not serializable by default. - // Pull out the necessary, serializable components to pass across. - var serializableE = { - blockId: e.blockId, - element: e.element, - type: e.type, - name: e.name, - newValue: e.newValue, - oldParentId: e.oldParentId, - oldInputName: e.oldInputName, - newParentId: e.newParentId, - newInputName: e.newInputName, - newCoordinate: e.newCoordinate, - xml: { - outerHTML: (e.xml) ? e.xml.outerHTML : null - } - }; - instance.vmWorker.postMessage({ - method: 'blockListener', - args: serializableE - }); - }; -} - -/** - * Inherit from EventEmitter - */ -util.inherits(VirtualMachine, EventEmitter); - -// For documentation, please see index.js. -// These mirror the functionality provided there, with the worker wrapper. -VirtualMachine.prototype.getPlaygroundData = function () { - this.vmWorker.postMessage({method: 'getPlaygroundData'}); -}; - -VirtualMachine.prototype.postIOData = function (device, data) { - this.vmWorker.postMessage({ - method: 'postIOData', - device: device, - data: data - }); -}; - -VirtualMachine.prototype.start = function () { - this.vmWorker.postMessage({method: 'start'}); -}; - -VirtualMachine.prototype.greenFlag = function () { - this.vmWorker.postMessage({method: 'greenFlag'}); -}; - -VirtualMachine.prototype.stopAll = function () { - this.vmWorker.postMessage({method: 'stopAll'}); -}; - -VirtualMachine.prototype.animationFrame = function () { - this.vmWorker.postMessage({method: 'animationFrame'}); -}; - -VirtualMachine.prototype.loadProject = function (json) { - this.vmWorker.postMessage({method: 'loadProject', json: json}); -}; - -VirtualMachine.prototype.createEmptyProject = function () { - this.vmWorker.postMessage({method: 'createEmptyProject'}); -}; - -VirtualMachine.prototype.setEditingTarget = function (targetId) { - this.vmWorker.postMessage({method: 'setEditingTarget', targetId: targetId}); -}; - -/** - * Export and bind to `window` - */ -module.exports = VirtualMachine; -if (typeof window !== 'undefined') window.VirtualMachine = module.exports; diff --git a/vm.js b/vm.js index 2c59a03d5..83bd76738 100644 --- a/vm.js +++ b/vm.js @@ -47,14 +47,10 @@ var EventEmitter = __webpack_require__(1); var util = __webpack_require__(2); - var Sprite = __webpack_require__(6); - var Runtime = __webpack_require__(61); - - /** - * Whether the environment is a WebWorker. - * @const{boolean} - */ - var ENV_WORKER = typeof importScripts === 'function'; + var Runtime = __webpack_require__(6); + var sb2import = __webpack_require__(33); + var Sprite = __webpack_require__(85); + var Blocks = __webpack_require__(34); /** * Handles connections between blocks, stage, and extensions. @@ -63,35 +59,25 @@ */ function VirtualMachine () { var instance = this; - // Bind event emitter and runtime to VM instance - // @todo Post message (Web Worker) polyfill EventEmitter.call(instance); - // @todo support multiple targets/sprites. - // This is just a demo/example. - var exampleSprite = new Sprite(); - exampleSprite.createClone(); - var exampleTargets = [exampleSprite.clones[0]]; - instance.exampleSprite = exampleSprite; - instance.runtime = new Runtime(exampleTargets); - /** - * Event listeners for scratch-blocks. + * VM runtime, to store blocks, I/O devices, sprites/targets, etc. + * @type {!Runtime} */ - instance.blockListener = ( - exampleSprite.blocks.generateBlockListener(false, instance.runtime) - ); - - instance.flyoutBlockListener = ( - exampleSprite.blocks.generateBlockListener(true, instance.runtime) - ); - + instance.runtime = new Runtime(); + /** + * The "currently editing"/selected target ID for the VM. + * Block events from any Blockly workspace are routed to this target. + * @type {!string} + */ + instance.editingTarget = null; // Runtime emits are passed along as VM emits. - instance.runtime.on(Runtime.STACK_GLOW_ON, function (id) { - instance.emit(Runtime.STACK_GLOW_ON, {id: id}); + instance.runtime.on(Runtime.SCRIPT_GLOW_ON, function (id) { + instance.emit(Runtime.SCRIPT_GLOW_ON, {id: id}); }); - instance.runtime.on(Runtime.STACK_GLOW_OFF, function (id) { - instance.emit(Runtime.STACK_GLOW_OFF, {id: id}); + instance.runtime.on(Runtime.SCRIPT_GLOW_OFF, function (id) { + instance.emit(Runtime.SCRIPT_GLOW_OFF, {id: id}); }); instance.runtime.on(Runtime.BLOCK_GLOW_ON, function (id) { instance.emit(Runtime.BLOCK_GLOW_ON, {id: id}); @@ -102,6 +88,8 @@ instance.runtime.on(Runtime.VISUAL_REPORT, function (id, value) { instance.emit(Runtime.VISUAL_REPORT, {id: id, value: value}); }); + + this.blockListener = this.blockListener.bind(this); } /** @@ -135,7 +123,7 @@ */ VirtualMachine.prototype.getPlaygroundData = function () { this.emit('playgroundData', { - blocks: this.exampleSprite.blocks, + blocks: this.editingTarget.blocks, threads: this.runtime.threads }); }; @@ -158,74 +146,130 @@ } }; - /* - * Worker handlers: for all public methods available above, - * we must also provide a message handler in case the VM is run - * from a worker environment. + /** + * Load a project from a Scratch 2.0 JSON representation. + * @param {?string} json JSON string representing the project. */ - if (ENV_WORKER) { - self.importScripts( - './node_modules/scratch-render/render-worker.js' - ); - self.renderer = new self.RenderWebGLWorker(); - self.vmInstance = new VirtualMachine(); - self.onmessage = function (e) { - var messageData = e.data; - switch (messageData.method) { - case 'start': - self.vmInstance.runtime.start(); - break; - case 'greenFlag': - self.vmInstance.runtime.greenFlag(); - break; - case 'stopAll': - self.vmInstance.runtime.stopAll(); - break; - case 'blockListener': - self.vmInstance.blockListener(messageData.args); - break; - case 'flyoutBlockListener': - self.vmInstance.flyoutBlockListener(messageData.args); - break; - case 'getPlaygroundData': - self.postMessage({ - method: 'playgroundData', - blocks: self.vmInstance.exampleSprite.blocks, - threads: self.vmInstance.runtime.threads - }); - break; - case 'animationFrame': - self.vmInstance.animationFrame(); - break; - case 'postIOData': - self.vmInstance.postIOData(messageData.device, messageData.data); - break; - default: - if (e.data.id == 'RendererConnected') { - //initRenderWorker(); - } - self.renderer.onmessage(e); - break; - } - }; - // Bind runtime's emitted events to postmessages. - self.vmInstance.runtime.on(Runtime.STACK_GLOW_ON, function (id) { - self.postMessage({method: Runtime.STACK_GLOW_ON, id: id}); - }); - self.vmInstance.runtime.on(Runtime.STACK_GLOW_OFF, function (id) { - self.postMessage({method: Runtime.STACK_GLOW_OFF, id: id}); - }); - self.vmInstance.runtime.on(Runtime.BLOCK_GLOW_ON, function (id) { - self.postMessage({method: Runtime.BLOCK_GLOW_ON, id: id}); - }); - self.vmInstance.runtime.on(Runtime.BLOCK_GLOW_OFF, function (id) { - self.postMessage({method: Runtime.BLOCK_GLOW_OFF, id: id}); - }); - self.vmInstance.runtime.on(Runtime.VISUAL_REPORT, function (id, value) { - self.postMessage({method: Runtime.VISUAL_REPORT, id: id, value: value}); - }); - } + VirtualMachine.prototype.loadProject = function (json) { + // @todo: Handle other formats, e.g., Scratch 1.4, Scratch 3.0. + sb2import(json, this.runtime); + // Select the first target for editing, e.g., the stage. + this.editingTarget = this.runtime.targets[0]; + // Update the VM user's knowledge of targets and blocks on the workspace. + this.emitTargetsUpdate(); + this.emitWorkspaceUpdate(); + this.runtime.setEditingTarget(this.editingTarget); + }; + /** + * Temporary way to make an empty project, in case the desired project + * cannot be loaded from the online server. + */ + VirtualMachine.prototype.createEmptyProject = function () { + // Stage. + var blocks2 = new Blocks(); + var stage = new Sprite(blocks2); + stage.name = 'Stage'; + stage.costumes.push({ + skin: '/assets/stage.png', + name: 'backdrop1', + bitmapResolution: 1, + rotationCenterX: 240, + rotationCenterY: 180 + }); + var target2 = stage.createClone(); + this.runtime.targets.push(target2); + target2.x = 0; + target2.y = 0; + target2.direction = 90; + target2.size = 200; + target2.visible = true; + target2.isStage = true; + // Sprite1 (cat). + var blocks1 = new Blocks(); + var sprite = new Sprite(blocks1); + sprite.name = 'Sprite1'; + sprite.costumes.push({ + skin: '/assets/scratch_cat.svg', + name: 'costume1', + bitmapResolution: 1, + rotationCenterX: 47, + rotationCenterY: 55 + }); + var target1 = sprite.createClone(); + this.runtime.targets.push(target1); + target1.x = 0; + target1.y = 0; + target1.direction = 90; + target1.size = 100; + target1.visible = true; + this.editingTarget = this.runtime.targets[0]; + this.emitTargetsUpdate(); + this.emitWorkspaceUpdate(); + }; + + /** + * Handle a Blockly event for the current editing target. + * @param {!Blockly.Event} e Any Blockly event. + */ + VirtualMachine.prototype.blockListener = function (e) { + if (this.editingTarget) { + this.editingTarget.blocks.blocklyListen( + e, + false, + this.runtime + ); + } + }; + + /** + * Set an editing target. An editor UI can use this function to switch + * between editing different targets, sprites, etc. + * After switching the editing target, the VM may emit updates + * to the list of targets and any attached workspace blocks + * (see `emitTargetsUpdate` and `emitWorkspaceUpdate`). + * @param {string} targetId Id of target to set as editing. + */ + VirtualMachine.prototype.setEditingTarget = function (targetId) { + // Has the target id changed? If not, exit. + if (targetId == this.editingTarget.id) { + return; + } + var target = this.runtime.getTargetById(targetId); + if (target) { + this.editingTarget = target; + // Emit appropriate UI updates. + this.emitTargetsUpdate(); + this.emitWorkspaceUpdate(); + this.runtime.setEditingTarget(target); + } + }; + + /** + * Emit metadata about available targets. + * An editor UI could use this to display a list of targets and show + * the currently editing one. + */ + VirtualMachine.prototype.emitTargetsUpdate = function () { + this.emit('targetsUpdate', { + // [[target id, human readable target name], ...]. + targetList: this.runtime.targets.map(function(target) { + return [target.id, target.getName()]; + }), + // Currently editing target id. + editingTarget: this.editingTarget.id + }); + }; + + /** + * Emit an Blockly/scratch-blocks compatible XML representation + * of the current editing target's blocks. + */ + VirtualMachine.prototype.emitWorkspaceUpdate = function () { + this.emit('workspaceUpdate', { + 'xml': this.editingTarget.blocks.toXML() + }); + }; /** * Export and bind to `window` */ @@ -296,8 +340,12 @@ er = arguments[1]; if (er instanceof Error) { throw er; // Unhandled 'error' event + } else { + // At least give some kind of context to the user + var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); + err.context = er; + throw err; } - throw TypeError('Uncaught, unspecified "error" event.'); } } @@ -1135,8 +1183,74 @@ /***/ 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 () { + try { + cachedSetTimeout = setTimeout; + } catch (e) { + cachedSetTimeout = function () { + throw new Error('setTimeout is not defined'); + } + } + try { + cachedClearTimeout = clearTimeout; + } catch (e) { + cachedClearTimeout = function () { + throw new Error('clearTimeout is not defined'); + } + } + } ()) + function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + 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); + } + 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; @@ -1161,7 +1275,7 @@ if (draining) { return; } - var timeout = setTimeout(cleanUpNextTick); + var timeout = runTimeout(cleanUpNextTick); draining = true; var len = queue.length; @@ -1178,7 +1292,7 @@ } currentQueue = null; draining = false; - clearTimeout(timeout); + runClearTimeout(timeout); } process.nextTick = function (fun) { @@ -1190,7 +1304,7 @@ } queue.push(new Item(fun, args)); if (queue.length === 1 && !draining) { - setTimeout(drainQueue, 0); + runTimeout(drainQueue); } }; @@ -1274,232 +1388,1504 @@ /* 6 */ /***/ function(module, exports, __webpack_require__) { - var Clone = __webpack_require__(7); - var Blocks = __webpack_require__(10); + var EventEmitter = __webpack_require__(1); + var Sequencer = __webpack_require__(7); + var Thread = __webpack_require__(9); + var util = __webpack_require__(2); + + // Virtual I/O devices. + var Clock = __webpack_require__(11); + var Keyboard = __webpack_require__(12); + var Mouse = __webpack_require__(15); + + var defaultBlockPackages = { + 'scratch3_control': __webpack_require__(17), + 'scratch3_event': __webpack_require__(28), + 'scratch3_looks': __webpack_require__(29), + 'scratch3_motion': __webpack_require__(30), + 'scratch3_operators': __webpack_require__(31), + 'scratch3_sensing': __webpack_require__(32) + }; /** - * Sprite to be used on the Scratch stage. - * All clones of a sprite have shared blocks, shared costumes, shared variables. - * @param {?Blocks} blocks Shared blocks object for all clones of sprite. - * @constructor + * Manages targets, scripts, and the sequencer. */ - function Sprite (blocks) { - if (!blocks) { - // Shared set of blocks for all clones. - blocks = new Blocks(); - } - this.blocks = blocks; - this.clones = []; + function Runtime () { + // Bind event emitter + EventEmitter.call(this); + + // State for the runtime + + /** + * Target management and storage. + * @type {Array.<!Target>} + */ + this.targets = []; + + /** + * A list of threads that are currently running in the VM. + * Threads are added when execution starts and pruned when execution ends. + * @type {Array.<Thread>} + */ + this.threads = []; + + /** @type {!Sequencer} */ + this.sequencer = new Sequencer(this); + + /** + * Map to look up a block primitive's implementation function by its opcode. + * This is a two-step lookup: package name first, then primitive name. + * @type {Object.<string, Function>} + */ + this._primitives = {}; + this._hats = {}; + this._edgeActivatedHatValues = {}; + this._registerBlockPackages(); + + this.ioDevices = { + 'clock': new Clock(), + 'keyboard': new Keyboard(this), + 'mouse': new Mouse(this) + }; + + this._scriptGlowsPreviousFrame = []; + this._editingTarget = null; } /** - * Create a clone of this sprite. - * @returns {!Clone} Newly created clone. + * Event name for glowing a script. + * @const {string} */ - Sprite.prototype.createClone = function () { - var newClone = new Clone(this.blocks); - this.clones.push(newClone); - return newClone; + Runtime.SCRIPT_GLOW_ON = 'STACK_GLOW_ON'; + + /** + * Event name for unglowing a script. + * @const {string} + */ + Runtime.SCRIPT_GLOW_OFF = 'STACK_GLOW_OFF'; + + /** + * Event name for glowing a block. + * @const {string} + */ + Runtime.BLOCK_GLOW_ON = 'BLOCK_GLOW_ON'; + + /** + * Event name for unglowing a block. + * @const {string} + */ + Runtime.BLOCK_GLOW_OFF = 'BLOCK_GLOW_OFF'; + + /** + * Event name for visual value report. + * @const {string} + */ + Runtime.VISUAL_REPORT = 'VISUAL_REPORT'; + + /** + * Inherit from EventEmitter + */ + util.inherits(Runtime, EventEmitter); + + /** + * How rapidly we try to step threads, in ms. + */ + Runtime.THREAD_STEP_INTERVAL = 1000 / 60; + + + // ----------------------------------------------------------------------------- + // ----------------------------------------------------------------------------- + + /** + * Register default block packages with this runtime. + * @todo Prefix opcodes with package name. + * @private + */ + Runtime.prototype._registerBlockPackages = function () { + for (var packageName in defaultBlockPackages) { + if (defaultBlockPackages.hasOwnProperty(packageName)) { + // @todo pass a different runtime depending on package privilege? + var packageObject = new (defaultBlockPackages[packageName])(this); + // Collect primitives from package. + if (packageObject.getPrimitives) { + var packagePrimitives = packageObject.getPrimitives(); + for (var op in packagePrimitives) { + if (packagePrimitives.hasOwnProperty(op)) { + this._primitives[op] = + packagePrimitives[op].bind(packageObject); + } + } + } + // Collect hat metadata from package. + if (packageObject.getHats) { + var packageHats = packageObject.getHats(); + for (var hatName in packageHats) { + if (packageHats.hasOwnProperty(hatName)) { + this._hats[hatName] = packageHats[hatName]; + } + } + } + } + } }; - module.exports = Sprite; + /** + * Retrieve the function associated with the given opcode. + * @param {!string} opcode The opcode to look up. + * @return {Function} The function which implements the opcode. + */ + Runtime.prototype.getOpcodeFunction = function (opcode) { + return this._primitives[opcode]; + }; + + // ----------------------------------------------------------------------------- + // ----------------------------------------------------------------------------- + + /** + * Return whether an opcode represents a hat block. + * @param {!string} opcode The opcode to look up. + * @return {Boolean} True if the op is known to be a hat. + */ + Runtime.prototype.getIsHat = function (opcode) { + return this._hats.hasOwnProperty(opcode); + }; + + /** + * Return whether an opcode represents an edge-activated hat block. + * @param {!string} opcode The opcode to look up. + * @return {Boolean} True if the op is known to be a edge-activated hat. + */ + Runtime.prototype.getIsEdgeActivatedHat = function (opcode) { + return this._hats.hasOwnProperty(opcode) && + this._hats[opcode].edgeActivated; + }; + + /** + * Update an edge-activated hat block value. + * @param {!string} blockId ID of hat to store value for. + * @param {*} newValue Value to store for edge-activated hat. + * @return {*} The old value for the edge-activated hat. + */ + Runtime.prototype.updateEdgeActivatedValue = function (blockId, newValue) { + var oldValue = this._edgeActivatedHatValues[blockId]; + this._edgeActivatedHatValues[blockId] = newValue; + return oldValue; + }; + + /** + * Clear all edge-activaed hat values. + */ + Runtime.prototype.clearEdgeActivatedValues = function () { + this._edgeActivatedHatValues = {}; + }; + + // ----------------------------------------------------------------------------- + // ----------------------------------------------------------------------------- + + /** + * Create a thread and push it to the list of threads. + * @param {!string} id ID of block that starts the stack + * @return {!Thread} The newly created thread. + */ + Runtime.prototype._pushThread = function (id) { + var thread = new Thread(id); + thread.pushStack(id); + this.threads.push(thread); + return thread; + }; + + /** + * Remove a thread from the list of threads. + * @param {?Thread} thread Thread object to remove from actives + */ + Runtime.prototype._removeThread = function (thread) { + var i = this.threads.indexOf(thread); + if (i > -1) { + this.threads.splice(i, 1); + } + }; + + /** + * Return whether a thread is currently active/running. + * @param {?Thread} thread Thread object to check. + * @return {Boolean} True if the thread is active/running. + */ + Runtime.prototype.isActiveThread = function (thread) { + return this.threads.indexOf(thread) > -1; + }; + + /** + * Toggle a script. + * @param {!string} topBlockId ID of block that starts the script. + */ + Runtime.prototype.toggleScript = function (topBlockId) { + // Remove any existing thread. + for (var i = 0; i < this.threads.length; i++) { + if (this.threads[i].topBlock == topBlockId) { + this._removeThread(this.threads[i]); + return; + } + } + // Otherwise add it. + this._pushThread(topBlockId); + }; + + /** + * Run a function `f` for all scripts in a workspace. + * `f` will be called with two parameters: + * - the top block ID of the script. + * - the target that owns the script. + * @param {!Function} f Function to call for each script. + * @param {Target=} opt_target Optionally, a target to restrict to. + */ + Runtime.prototype.allScriptsDo = function (f, opt_target) { + var targets = this.targets; + if (opt_target) { + targets = [opt_target]; + } + for (var t = 0; t < targets.length; t++) { + var target = targets[t]; + var scripts = target.blocks.getScripts(); + for (var j = 0; j < scripts.length; j++) { + var topBlockId = scripts[j]; + f(topBlockId, target); + } + } + }; + + /** + * Start all relevant hats. + * @param {!string} requestedHatOpcode Opcode of hats to start. + * @param {Object=} opt_matchFields Optionally, fields to match on the hat. + * @param {Target=} opt_target Optionally, a target to restrict to. + * @return {Array.<Thread>} List of threads started by this function. + */ + Runtime.prototype.startHats = function (requestedHatOpcode, + opt_matchFields, opt_target) { + if (!this._hats.hasOwnProperty(requestedHatOpcode)) { + // No known hat with this opcode. + return; + } + var instance = this; + var newThreads = []; + // Consider all scripts, looking for hats with opcode `requestedHatOpcode`. + this.allScriptsDo(function(topBlockId, target) { + var potentialHatOpcode = target.blocks.getBlock(topBlockId).opcode; + if (potentialHatOpcode !== requestedHatOpcode) { + // Not the right hat. + return; + } + // Match any requested fields. + // For example: ensures that broadcasts match. + // This needs to happen before the block is evaluated + // (i.e., before the predicate can be run) because "broadcast and wait" + // needs to have a precise collection of started threads. + var hatFields = target.blocks.getFields(topBlockId); + if (opt_matchFields) { + for (var matchField in opt_matchFields) { + if (hatFields[matchField].value !== + opt_matchFields[matchField]) { + // Field mismatch. + return; + } + } + } + // Look up metadata for the relevant hat. + var hatMeta = instance._hats[requestedHatOpcode]; + if (hatMeta.restartExistingThreads) { + // If `restartExistingThreads` is true, we should stop + // any existing threads starting with the top block. + for (var i = 0; i < instance.threads.length; i++) { + if (instance.threads[i].topBlock === topBlockId) { + instance._removeThread(instance.threads[i]); + } + } + } else { + // If `restartExistingThreads` is false, we should + // give up if any threads with the top block are running. + for (var j = 0; j < instance.threads.length; j++) { + if (instance.threads[j].topBlock === topBlockId) { + // Some thread is already running. + return; + } + } + } + // Start the thread with this top block. + newThreads.push(instance._pushThread(topBlockId)); + }, opt_target); + return newThreads; + }; + + /** + * Start all threads that start with the green flag. + */ + Runtime.prototype.greenFlag = function () { + this.ioDevices.clock.resetProjectTimer(); + this.clearEdgeActivatedValues(); + this.startHats('event_whenflagclicked'); + }; + + /** + * Stop "everything" + */ + Runtime.prototype.stopAll = function () { + var threadsCopy = this.threads.slice(); + while (threadsCopy.length > 0) { + var poppedThread = threadsCopy.pop(); + this._removeThread(poppedThread); + } + }; + + /** + * Repeatedly run `sequencer.stepThreads` and filter out + * inactive threads after each iteration. + */ + Runtime.prototype._step = function () { + // Find all edge-activated hats, and add them to threads to be evaluated. + for (var hatType in this._hats) { + var hat = this._hats[hatType]; + if (hat.edgeActivated) { + this.startHats(hatType); + } + } + var inactiveThreads = this.sequencer.stepThreads(this.threads); + this._updateScriptGlows(); + for (var i = 0; i < inactiveThreads.length; i++) { + this._removeThread(inactiveThreads[i]); + } + }; + + Runtime.prototype.setEditingTarget = function (editingTarget) { + this._scriptGlowsPreviousFrame = []; + this._editingTarget = editingTarget; + this._updateScriptGlows(); + }; + + Runtime.prototype._updateScriptGlows = function () { + // Set of scripts that request a glow this frame. + var requestedGlowsThisFrame = []; + // Final set of scripts glowing during this frame. + var finalScriptGlows = []; + // Find all scripts that should be glowing. + for (var i = 0; i < this.threads.length; i++) { + var thread = this.threads[i]; + var target = this.targetForThread(thread); + if (thread.requestScriptGlowInFrame && target == this._editingTarget) { + var blockForThread = thread.peekStack() || thread.topBlock; + var script = target.blocks.getTopLevelScript(blockForThread); + requestedGlowsThisFrame.push(script); + } + } + // Compare to previous frame. + for (var j = 0; j < this._scriptGlowsPreviousFrame.length; j++) { + var previousFrameGlow = this._scriptGlowsPreviousFrame[j]; + if (requestedGlowsThisFrame.indexOf(previousFrameGlow) < 0) { + // Glow turned off. + this.glowScript(previousFrameGlow, false); + } else { + // Still glowing. + finalScriptGlows.push(previousFrameGlow); + } + } + for (var k = 0; k < requestedGlowsThisFrame.length; k++) { + var currentFrameGlow = requestedGlowsThisFrame[k]; + if (this._scriptGlowsPreviousFrame.indexOf(currentFrameGlow) < 0) { + // Glow turned on. + this.glowScript(currentFrameGlow, true); + finalScriptGlows.push(currentFrameGlow); + } + } + this._scriptGlowsPreviousFrame = finalScriptGlows; + }; + + /** + * Emit feedback for block glowing (used in the sequencer). + * @param {?string} blockId ID for the block to update glow + * @param {boolean} isGlowing True to turn on glow; false to turn off. + */ + Runtime.prototype.glowBlock = function (blockId, isGlowing) { + if (isGlowing) { + this.emit(Runtime.BLOCK_GLOW_ON, blockId); + } else { + this.emit(Runtime.BLOCK_GLOW_OFF, blockId); + } + }; + + /** + * Emit feedback for script glowing. + * @param {?string} topBlockId ID for the top block to update glow + * @param {boolean} isGlowing True to turn on glow; false to turn off. + */ + Runtime.prototype.glowScript = function (topBlockId, isGlowing) { + if (isGlowing) { + this.emit(Runtime.SCRIPT_GLOW_ON, topBlockId); + } else { + this.emit(Runtime.SCRIPT_GLOW_OFF, topBlockId); + } + }; + + /** + * Emit value for reporter to show in the blocks. + * @param {string} blockId ID for the block. + * @param {string} value Value to show associated with the block. + */ + Runtime.prototype.visualReport = function (blockId, value) { + this.emit(Runtime.VISUAL_REPORT, blockId, String(value)); + }; + + /** + * Return the Target for a particular thread. + * @param {!Thread} thread Thread to determine target for. + * @return {?Target} Target object, if one exists. + */ + Runtime.prototype.targetForThread = function (thread) { + // @todo This is a messy solution, + // but prevents having circular data references. + // Have a map or some other way to associate target with threads. + for (var t = 0; t < this.targets.length; t++) { + var target = this.targets[t]; + if (target.blocks.getBlock(thread.topBlock)) { + return target; + } + } + }; + + /** + * Get a target by its id. + * @param {string} targetId Id of target to find. + * @return {?Target} The target, if found. + */ + Runtime.prototype.getTargetById = function (targetId) { + for (var i = 0; i < this.targets.length; i++) { + var target = this.targets[i]; + if (target.id == targetId) { + return target; + } + } + }; + + /** + * Get a target representing the Scratch stage, if one exists. + * @return {?Target} The target, if found. + */ + Runtime.prototype.getTargetForStage = function () { + for (var i = 0; i < this.targets.length; i++) { + var target = this.targets[i]; + if (target.isStage) { + return target; + } + } + }; + + /** + * Handle an animation frame from the main thread. + */ + Runtime.prototype.animationFrame = function () { + if (self.renderer) { + self.renderer.draw(); + } + }; + + /** + * Set up timers to repeatedly step in a browser + */ + Runtime.prototype.start = function () { + self.setInterval(function() { + this._step(); + }.bind(this), Runtime.THREAD_STEP_INTERVAL); + }; + + module.exports = Runtime; /***/ }, /* 7 */ /***/ function(module, exports, __webpack_require__) { - var util = __webpack_require__(2); - var MathUtil = __webpack_require__(8); - var Target = __webpack_require__(9); + var Timer = __webpack_require__(8); + var Thread = __webpack_require__(9); + var execute = __webpack_require__(10); - /** - * Clone (instance) of a sprite. - * @param {!Blocks} spriteBlocks Reference to the sprite's blocks. - * @constructor - */ - function Clone(spriteBlocks) { - Target.call(this, spriteBlocks); + function Sequencer (runtime) { /** - * Reference to the global renderer for this VM, if one exists. - * @type {?RenderWebGLWorker} + * A utility timer for timing thread sequencing. + * @type {!Timer} */ - this.renderer = null; - // If this is not true, there is no renderer (e.g., running in a test env). - if (typeof self !== 'undefined' && self.renderer) { - // Pull from `self.renderer`. - this.renderer = self.renderer; - } - /** - * ID of the drawable for this clone returned by the renderer, if rendered. - * @type {?Number} - */ - this.drawableID = null; + this.timer = new Timer(); - this.initDrawable(); + /** + * Reference to the runtime owning this sequencer. + * @type {!Runtime} + */ + this.runtime = runtime; } - util.inherits(Clone, Target); /** - * Create a clone's drawable with the this.renderer. + * The sequencer does as much work as it can within WORK_TIME milliseconds, + * then yields. This is essentially a rate-limiter for blocks. + * In Scratch 2.0, this is set to 75% of the target stage frame-rate (30fps). + * @const {!number} */ - Clone.prototype.initDrawable = function () { - if (this.renderer) { - var createPromise = this.renderer.createDrawable(); - var instance = this; - createPromise.then(function (id) { - instance.drawableID = id; - }); + Sequencer.WORK_TIME = 10; + + /** + * Step through all threads in `this.threads`, running them in order. + * @param {Array.<Thread>} threads List of which threads to step. + * @return {Array.<Thread>} All threads which have finished in this iteration. + */ + Sequencer.prototype.stepThreads = function (threads) { + // Start counting toward WORK_TIME + this.timer.start(); + // List of threads which have been killed by this step. + var inactiveThreads = []; + // If all of the threads are yielding, we should yield. + var numYieldingThreads = 0; + // Clear all yield statuses that were for the previous frame. + for (var t = 0; t < threads.length; t++) { + if (threads[t].status === Thread.STATUS_YIELD_FRAME) { + threads[t].setStatus(Thread.STATUS_RUNNING); + } } - }; - // Clone-level properties. - /** - * Scratch X coordinate. Currently should range from -240 to 240. - * @type {!number} - */ - Clone.prototype.x = 0; - - /** - * Scratch Y coordinate. Currently should range from -180 to 180. - * @type {!number} - */ - Clone.prototype.y = 0; - - /** - * Scratch direction. Currently should range from -179 to 180. - * @type {!number} - */ - Clone.prototype.direction = 90; - - /** - * Whether the clone is currently visible. - * @type {!boolean} - */ - Clone.prototype.visible = true; - - /** - * Size of clone as a percent of costume size. Ranges from 5% to 535%. - * @type {!number} - */ - Clone.prototype.size = 100; - - /** - * Map of current graphic effect values. - * @type {!Object.<string, number>} - */ - Clone.prototype.effects = { - 'color': 0, - 'fisheye': 0, - 'whirl': 0, - 'pixelate': 0, - 'mosaic': 0, - 'brightness': 0, - 'ghost': 0 - }; - // End clone-level properties. - - /** - * Set the X and Y coordinates of a clone. - * @param {!number} x New X coordinate of clone, in Scratch coordinates. - * @param {!number} y New Y coordinate of clone, in Scratch coordinates. - */ - Clone.prototype.setXY = function (x, y) { - this.x = x; - this.y = y; - if (this.renderer) { - this.renderer.updateDrawableProperties(this.drawableID, { - position: [this.x, this.y] - }); + // While there are still threads to run and we are within WORK_TIME, + // continue executing threads. + while (threads.length > 0 && + threads.length > numYieldingThreads && + this.timer.timeElapsed() < Sequencer.WORK_TIME) { + // New threads at the end of the iteration. + var newThreads = []; + // Reset yielding thread count. + numYieldingThreads = 0; + // Attempt to run each thread one time + for (var i = 0; i < threads.length; i++) { + var activeThread = threads[i]; + if (activeThread.status === Thread.STATUS_RUNNING) { + // Normal-mode thread: step. + this.startThread(activeThread); + } else if (activeThread.status === Thread.STATUS_YIELD || + activeThread.status === Thread.STATUS_YIELD_FRAME) { + // Yielding thread: do nothing for this step. + numYieldingThreads++; + } + if (activeThread.stack.length === 0 && + activeThread.status === Thread.STATUS_DONE) { + // Finished with this thread - tell runtime to clean it up. + inactiveThreads.push(activeThread); + } else { + // Keep this thead in the loop. + newThreads.push(activeThread); + } + } + // Effectively filters out threads that have stopped. + threads = newThreads; } + return inactiveThreads; }; /** - * Set the direction of a clone. - * @param {!number} direction New direction of clone. + * Step the requested thread + * @param {!Thread} thread Thread object to step */ - Clone.prototype.setDirection = function (direction) { - // Keep direction between -179 and +180. - this.direction = MathUtil.wrapClamp(direction, -179, 180); - if (this.renderer) { - this.renderer.updateDrawableProperties(this.drawableID, { - direction: this.direction - }); - } - }; - - /** - * Set a say bubble on this clone. - * @param {?string} type Type of say bubble: "say", "think", or null. - * @param {?string} message Message to put in say bubble. - */ - Clone.prototype.setSay = function (type, message) { - // @todo: Render to stage. - if (!type || !message) { - console.log('Clearing say bubble'); + Sequencer.prototype.startThread = function (thread) { + var currentBlockId = thread.peekStack(); + if (!currentBlockId) { + // A "null block" - empty branch. + // Yield for the frame. + thread.popStack(); + thread.setStatus(Thread.STATUS_YIELD_FRAME); return; } - console.log('Setting say bubble:', type, message); - }; - - /** - * Set visibility of the clone; i.e., whether it's shown or hidden. - * @param {!boolean} visible True if the sprite should be shown. - */ - Clone.prototype.setVisible = function (visible) { - this.visible = visible; - if (this.renderer) { - this.renderer.updateDrawableProperties(this.drawableID, { - visible: this.visible - }); + // Execute the current block + execute(this, thread); + // If the block executed without yielding and without doing control flow, + // move to done. + if (thread.status === Thread.STATUS_RUNNING && + thread.peekStack() === currentBlockId) { + this.proceedThread(thread); } }; /** - * Set size of the clone, as a percentage of the costume size. - * @param {!number} size Size of clone, from 5 to 535. + * Step a thread into a block's branch. + * @param {!Thread} thread Thread object to step to branch. + * @param {Number} branchNum Which branch to step to (i.e., 1, 2). */ - Clone.prototype.setSize = function (size) { - // Keep size between 5% and 535%. - this.size = MathUtil.clamp(size, 5, 535); - if (this.renderer) { - this.renderer.updateDrawableProperties(this.drawableID, { - scale: [this.size, this.size] - }); + Sequencer.prototype.stepToBranch = function (thread, branchNum) { + if (!branchNum) { + branchNum = 1; + } + var currentBlockId = thread.peekStack(); + var branchId = this.runtime.targetForThread(thread).blocks.getBranch( + currentBlockId, + branchNum + ); + if (branchId) { + // Push branch ID to the thread's stack. + thread.pushStack(branchId); + } else { + // Push null, so we come back to the current block. + thread.pushStack(null); } }; /** - * Set a particular graphic effect on this clone. - * @param {!string} effectName Name of effect (see `Clone.prototype.effects`). - * @param {!number} value Numerical magnitude of effect. + * Step a thread into an input reporter, and manage its status appropriately. + * @param {!Thread} thread Thread object to step to reporter. + * @param {!string} blockId ID of reporter block. + * @param {!string} inputName Name of input on parent block. + * @return {boolean} True if yielded, false if it finished immediately. */ - Clone.prototype.setEffect = function (effectName, value) { - this.effects[effectName] = value; - if (this.renderer) { - var props = {}; - props[effectName] = this.effects[effectName]; - this.renderer.updateDrawableProperties(this.drawableID, props); + Sequencer.prototype.stepToReporter = function (thread, blockId, inputName) { + var currentStackFrame = thread.peekStackFrame(); + // Push to the stack to evaluate the reporter block. + thread.pushStack(blockId); + // Save name of input for `Thread.pushReportedValue`. + currentStackFrame.waitingReporter = inputName; + // Actually execute the block. + this.startThread(thread); + // If a reporter yielded, caller must wait for it to unyield. + // The value will be populated once the reporter unyields, + // and passed up to the currentStackFrame on next execution. + return thread.status === Thread.STATUS_YIELD; + }; + + /** + * Finish stepping a thread and proceed it to the next block. + * @param {!Thread} thread Thread object to proceed. + */ + Sequencer.prototype.proceedThread = function (thread) { + var currentBlockId = thread.peekStack(); + // Mark the status as done and proceed to the next block. + // Pop from the stack - finished this level of execution. + thread.popStack(); + // Push next connected block, if there is one. + var nextBlockId = (this.runtime.targetForThread(thread). + blocks.getNextBlock(currentBlockId)); + if (nextBlockId) { + thread.pushStack(nextBlockId); + } + // If we can't find a next block to run, mark the thread as done. + if (!thread.peekStack()) { + thread.setStatus(Thread.STATUS_DONE); } }; /** - * Clear all graphic effects on this clone. + * Retire a thread in the middle, without considering further blocks. + * @param {!Thread} thread Thread object to retire. */ - Clone.prototype.clearEffects = function () { - for (var effectName in this.effects) { - this.effects[effectName] = 0; - } - if (this.renderer) { - this.renderer.updateDrawableProperties(this.drawableID, this.effects); - } + Sequencer.prototype.retireThread = function (thread) { + thread.stack = []; + thread.stackFrame = []; + thread.setStatus(Thread.STATUS_DONE); }; - module.exports = Clone; + module.exports = Sequencer; /***/ }, /* 8 */ +/***/ function(module, exports) { + + /** + * @fileoverview + * A utility for accurately measuring time. + * To use: + * --- + * var timer = new Timer(); + * timer.start(); + * ... pass some time ... + * var timeDifference = timer.timeElapsed(); + * --- + * Or, you can use the `time` and `relativeTime` + * to do some measurement yourself. + */ + + /** + * @constructor + */ + function Timer () {} + + /** + * Used to store the start time of a timer action. + * Updated when calling `timer.start`. + */ + Timer.prototype.startTime = 0; + + /** + * Return the currently known absolute time, in ms precision. + * @returns {number} ms elapsed since 1 January 1970 00:00:00 UTC. + */ + Timer.prototype.time = function () { + if (Date.now) { + return Date.now(); + } else { + return new Date().getTime(); + } + }; + + /** + * Returns a time accurate relative to other times produced by this function. + * If possible, will use sub-millisecond precision. + * If not, will use millisecond precision. + * Not guaranteed to produce the same absolute values per-system. + * @returns {number} ms-scale accurate time relative to other relative times. + */ + Timer.prototype.relativeTime = function () { + if (typeof self !== 'undefined' && + self.performance && 'now' in self.performance) { + return self.performance.now(); + } else { + return this.time(); + } + }; + + /** + * Start a timer for measuring elapsed time, + * at the most accurate precision possible. + */ + Timer.prototype.start = function () { + this.startTime = this.relativeTime(); + }; + + /** + * Check time elapsed since `timer.start` was called. + * @returns {number} Time elapsed, in ms (possibly sub-ms precision). + */ + Timer.prototype.timeElapsed = function () { + return this.relativeTime() - this.startTime; + }; + + module.exports = Timer; + + +/***/ }, +/* 9 */ +/***/ function(module, exports) { + + /** + * A thread is a running stack context and all the metadata needed. + * @param {?string} firstBlock First block to execute in the thread. + * @constructor + */ + function Thread (firstBlock) { + /** + * ID of top block of the thread + * @type {!string} + */ + this.topBlock = firstBlock; + + /** + * Stack for the thread. When the sequencer enters a control structure, + * the block is pushed onto the stack so we know where to exit. + * @type {Array.<string>} + */ + this.stack = []; + + /** + * Stack frames for the thread. Store metadata for the executing blocks. + * @type {Array.<Object>} + */ + this.stackFrames = []; + + /** + * Status of the thread, one of three states (below) + * @type {number} + */ + this.status = 0; /* Thread.STATUS_RUNNING */ + + /** + * Whether the thread requests its script to glow during this frame. + * @type {boolean} + */ + this.requestScriptGlowInFrame = false; + } + + /** + * Thread status for initialized or running thread. + * This is the default state for a thread - execution should run normally, + * stepping from block to block. + * @const + */ + Thread.STATUS_RUNNING = 0; + + /** + * Thread status for a yielded thread. + * Threads are in this state when a primitive has yielded; execution is paused + * until the relevant primitive unyields. + * @const + */ + Thread.STATUS_YIELD = 1; + + /** + * Thread status for a single-frame yield. + * @const + */ + Thread.STATUS_YIELD_FRAME = 2; + + /** + * Thread status for a finished/done thread. + * Thread is in this state when there are no more blocks to execute. + * @const + */ + Thread.STATUS_DONE = 3; + + /** + * Push stack and update stack frames appropriately. + * @param {string} blockId Block ID to push to stack. + */ + Thread.prototype.pushStack = function (blockId) { + this.stack.push(blockId); + // Push an empty stack frame, if we need one. + // Might not, if we just popped the stack. + if (this.stack.length > this.stackFrames.length) { + this.stackFrames.push({ + reported: {}, // Collects reported input values. + waitingReporter: null, // Name of waiting reporter. + executionContext: {} // A context passed to block implementations. + }); + } + }; + + /** + * Pop last block on the stack and its stack frame. + * @return {string} Block ID popped from the stack. + */ + Thread.prototype.popStack = function () { + this.stackFrames.pop(); + return this.stack.pop(); + }; + + /** + * Get top stack item. + * @return {?string} Block ID on top of stack. + */ + Thread.prototype.peekStack = function () { + return this.stack[this.stack.length - 1]; + }; + + + /** + * Get top stack frame. + * @return {?Object} Last stack frame stored on this thread. + */ + Thread.prototype.peekStackFrame = function () { + return this.stackFrames[this.stackFrames.length - 1]; + }; + + /** + * Get stack frame above the current top. + * @return {?Object} Second to last stack frame stored on this thread. + */ + Thread.prototype.peekParentStackFrame = function () { + return this.stackFrames[this.stackFrames.length - 2]; + }; + + /** + * Push a reported value to the parent of the current stack frame. + * @param {!Any} value Reported value to push. + */ + Thread.prototype.pushReportedValue = function (value) { + var parentStackFrame = this.peekParentStackFrame(); + if (parentStackFrame) { + var waitingReporter = parentStackFrame.waitingReporter; + parentStackFrame.reported[waitingReporter] = value; + parentStackFrame.waitingReporter = null; + } + }; + + /** + * Whether the current execution of a thread is at the top of the stack. + * @return {Boolean} True if execution is at top of the stack. + */ + Thread.prototype.atStackTop = function () { + return this.peekStack() === this.topBlock; + }; + + /** + * Set thread status. + * @param {number} status Enum representing thread status. + */ + Thread.prototype.setStatus = function (status) { + this.status = status; + }; + + module.exports = Thread; + + +/***/ }, +/* 10 */ +/***/ function(module, exports, __webpack_require__) { + + var Thread = __webpack_require__(9); + + /** + * Utility function to determine if a value is a Promise. + * @param {*} value Value to check for a Promise. + * @return {Boolean} True if the value appears to be a Promise. + */ + var isPromise = function (value) { + return value && value.then && typeof value.then === 'function'; + }; + + /** + * Execute a block. + * @param {!Sequencer} sequencer Which sequencer is executing. + * @param {!Thread} thread Thread which to read and execute. + */ + var execute = function (sequencer, thread) { + var runtime = sequencer.runtime; + var target = runtime.targetForThread(thread); + + // Current block to execute is the one on the top of the stack. + var currentBlockId = thread.peekStack(); + var currentStackFrame = thread.peekStackFrame(); + + // Query info about the block. + var opcode = target.blocks.getOpcode(currentBlockId); + var blockFunction = runtime.getOpcodeFunction(opcode); + var isHat = runtime.getIsHat(opcode); + var fields = target.blocks.getFields(currentBlockId); + var inputs = target.blocks.getInputs(currentBlockId); + + if (!opcode) { + console.warn('Could not get opcode for block: ' + currentBlockId); + return; + } + + /** + * Handle any reported value from the primitive, either directly returned + * or after a promise resolves. + * @param {*} resolvedValue Value eventually returned from the primitive. + */ + var handleReport = function (resolvedValue) { + thread.pushReportedValue(resolvedValue); + if (isHat) { + // Hat predicate was evaluated. + if (runtime.getIsEdgeActivatedHat(opcode)) { + // If this is an edge-activated hat, only proceed if + // the value is true and used to be false. + var oldEdgeValue = runtime.updateEdgeActivatedValue( + currentBlockId, + resolvedValue + ); + var edgeWasActivated = !oldEdgeValue && resolvedValue; + if (!edgeWasActivated) { + sequencer.retireThread(thread); + } + } else { + // Not an edge-activated hat: retire the thread + // if predicate was false. + if (!resolvedValue) { + sequencer.retireThread(thread); + } + } + } else { + // In a non-hat, report the value visually if necessary if + // at the top of the thread stack. + if (typeof resolvedValue !== 'undefined' && thread.atStackTop()) { + runtime.visualReport(currentBlockId, resolvedValue); + } + // Finished any yields. + thread.setStatus(Thread.STATUS_RUNNING); + } + }; + + // Hats and single-field shadows are implemented slightly differently + // from regular blocks. + // For hats: if they have an associated block function, + // it's treated as a predicate; if not, execution will proceed as a no-op. + // For single-field shadows: If the block has a single field, and no inputs, + // immediately return the value of the field. + if (!blockFunction) { + if (isHat) { + // Skip through the block (hat with no predicate). + return; + } else { + if (Object.keys(fields).length == 1 && + Object.keys(inputs).length == 0) { + // One field and no inputs - treat as arg. + for (var fieldKey in fields) { // One iteration. + handleReport(fields[fieldKey].value); + } + } else { + console.warn('Could not get implementation for opcode: ' + + opcode); + } + thread.requestScriptGlowInFrame = true; + return; + } + } + + // Generate values for arguments (inputs). + var argValues = {}; + + // Add all fields on this block to the argValues. + for (var fieldName in fields) { + argValues[fieldName] = fields[fieldName].value; + } + + // Recursively evaluate input blocks. + for (var inputName in inputs) { + var input = inputs[inputName]; + var inputBlockId = input.block; + // Is there no value for this input waiting in the stack frame? + if (typeof currentStackFrame.reported[inputName] === 'undefined') { + // If there's not, we need to evaluate the block. + var reporterYielded = ( + sequencer.stepToReporter(thread, inputBlockId, inputName) + ); + // If the reporter yielded, return immediately; + // it needs time to finish and report its value. + if (reporterYielded) { + return; + } + } + argValues[inputName] = currentStackFrame.reported[inputName]; + } + + // If we've gotten this far, all of the input blocks are evaluated, + // and `argValues` is fully populated. So, execute the block primitive. + // First, clear `currentStackFrame.reported`, so any subsequent execution + // (e.g., on return from a branch) gets fresh inputs. + currentStackFrame.reported = {}; + + var primitiveReportedValue = null; + primitiveReportedValue = blockFunction(argValues, { + stackFrame: currentStackFrame.executionContext, + target: target, + yield: function() { + thread.setStatus(Thread.STATUS_YIELD); + }, + yieldFrame: function() { + thread.setStatus(Thread.STATUS_YIELD_FRAME); + }, + done: function() { + thread.setStatus(Thread.STATUS_RUNNING); + sequencer.proceedThread(thread); + }, + startBranch: function (branchNum) { + sequencer.stepToBranch(thread, branchNum); + }, + startHats: function(requestedHat, opt_matchFields, opt_target) { + return ( + runtime.startHats(requestedHat, opt_matchFields, opt_target) + ); + }, + ioQuery: function (device, func, args) { + // Find the I/O device and execute the query/function call. + if (runtime.ioDevices[device] && runtime.ioDevices[device][func]) { + var devObject = runtime.ioDevices[device]; + return devObject[func].call(devObject, args); + } + } + }); + + if (typeof primitiveReportedValue === 'undefined') { + // No value reported - potentially a command block. + // Edge-activated hats don't request a glow; all commands do. + thread.requestScriptGlowInFrame = true; + } + + // If it's a promise, wait until promise resolves. + if (isPromise(primitiveReportedValue)) { + if (thread.status === Thread.STATUS_RUNNING) { + // Primitive returned a promise; automatically yield thread. + thread.setStatus(Thread.STATUS_YIELD); + } + // Promise handlers + primitiveReportedValue.then(function(resolvedValue) { + handleReport(resolvedValue); + sequencer.proceedThread(thread); + }, function(rejectionReason) { + // Promise rejected: the primitive had some error. + // Log it and proceed. + console.warn('Primitive rejected promise: ', rejectionReason); + thread.setStatus(Thread.STATUS_RUNNING); + sequencer.proceedThread(thread); + }); + } else if (thread.status === Thread.STATUS_RUNNING) { + handleReport(primitiveReportedValue); + } + }; + + module.exports = execute; + + +/***/ }, +/* 11 */ +/***/ function(module, exports, __webpack_require__) { + + var Timer = __webpack_require__(8); + + function Clock () { + this._projectTimer = new Timer(); + this._projectTimer.start(); + } + + Clock.prototype.projectTimer = function () { + return this._projectTimer.timeElapsed() / 1000; + }; + + Clock.prototype.resetProjectTimer = function () { + this._projectTimer.start(); + }; + + module.exports = Clock; + + +/***/ }, +/* 12 */ +/***/ function(module, exports, __webpack_require__) { + + var Cast = __webpack_require__(13); + + function Keyboard (runtime) { + /** + * List of currently pressed keys. + * @type{Array.<number>} + */ + this._keysPressed = []; + /** + * Reference to the owning Runtime. + * Can be used, for example, to activate hats. + * @type{!Runtime} + */ + this.runtime = runtime; + } + + /** + * Convert a Scratch key name to a DOM keyCode. + * @param {Any} keyName Scratch key argument. + * @return {number} Key code corresponding to a DOM event. + */ + Keyboard.prototype._scratchKeyToKeyCode = function (keyName) { + if (typeof keyName == 'number') { + // Key codes placed in with number blocks. + return keyName; + } + var keyString = Cast.toString(keyName); + switch (keyString) { + case 'space': return 32; + case 'left arrow': return 37; + case 'up arrow': return 38; + case 'right arrow': return 39; + case 'down arrow': return 40; + // @todo: Consider adding other special keys here. + } + // Keys reported by DOM keyCode are upper case. + return keyString.toUpperCase().charCodeAt(0); + }; + + Keyboard.prototype._keyCodeToScratchKey = function (keyCode) { + if (keyCode >= 48 && keyCode <= 90) { + // Standard letter. + return String.fromCharCode(keyCode).toLowerCase(); + } + switch (keyCode) { + case 32: return 'space'; + case 37: return 'left arrow'; + case 38: return 'up arrow'; + case 39: return 'right arrow'; + case 40: return 'down arrow'; + } + return null; + }; + + Keyboard.prototype.postData = function (data) { + if (data.keyCode) { + var index = this._keysPressed.indexOf(data.keyCode); + if (data.isDown) { + // If not already present, add to the list. + if (index < 0) { + this._keysPressed.push(data.keyCode); + } + // Always trigger hats, even if it was already pressed. + this.runtime.startHats('event_whenkeypressed', { + 'KEY_OPTION': this._keyCodeToScratchKey(data.keyCode) + }); + this.runtime.startHats('event_whenkeypressed', { + 'KEY_OPTION': 'any' + }); + } else if (index > -1) { + // If already present, remove from the list. + this._keysPressed.splice(index, 1); + } + } + }; + + Keyboard.prototype.getKeyIsDown = function (key) { + if (key == 'any') { + return this._keysPressed.length > 0; + } + var keyCode = this._scratchKeyToKeyCode(key); + return this._keysPressed.indexOf(keyCode) > -1; + }; + + module.exports = Keyboard; + + +/***/ }, +/* 13 */ +/***/ function(module, exports, __webpack_require__) { + + var Color = __webpack_require__(14); + + function Cast () {} + + /** + * @fileoverview + * Utilities for casting and comparing Scratch data-types. + * Scratch behaves slightly differently from JavaScript in many respects, + * and these differences should be encapsulated below. + * For example, in Scratch, add(1, join("hello", world")) -> 1. + * This is because "hello world" is cast to 0. + * In JavaScript, 1 + Number("hello" + "world") would give you NaN. + * Use when coercing a value before computation. + */ + + /** + * Scratch cast to number. + * Treats NaN as 0. + * In Scratch 2.0, this is captured by `interp.numArg.` + * @param {*} value Value to cast to number. + * @return {number} The Scratch-casted number value. + */ + Cast.toNumber = function (value) { + var n = Number(value); + if (isNaN(n)) { + // Scratch treats NaN as 0, when needed as a number. + // E.g., 0 + NaN -> 0. + return 0; + } + return n; + }; + + /** + * Scratch cast to boolean. + * In Scratch 2.0, this is captured by `interp.boolArg.` + * Treats some string values differently from JavaScript. + * @param {*} value Value to cast to boolean. + * @return {boolean} The Scratch-casted boolean value. + */ + Cast.toBoolean = function (value) { + // Already a boolean? + if (typeof value === 'boolean') { + return value; + } + if (typeof value === 'string') { + // These specific strings are treated as false in Scratch. + if ((value == '') || + (value == '0') || + (value.toLowerCase() == 'false')) { + return false; + } + // All other strings treated as true. + return true; + } + // Coerce other values and numbers. + return Boolean(value); + }; + + /** + * Scratch cast to string. + * @param {*} value Value to cast to string. + * @return {string} The Scratch-casted string value. + */ + Cast.toString = function (value) { + return String(value); + }; + + /** + * Cast any Scratch argument to an RGB color object to be used for the renderer. + * @param {*} value Value to convert to RGB color object. + * @return {Array.<number>} [r,g,b], values between 0-255. + */ + Cast.toRgbColorList = function (value) { + var color; + if (typeof value == 'string' && value.substring(0, 1) == '#') { + color = Color.hexToRgb(value); + } else { + color = Color.decimalToRgb(Cast.toNumber(value)); + } + return [color.r, color.g, color.b]; + }; + + /** + * Compare two values, using Scratch cast, case-insensitive string compare, etc. + * In Scratch 2.0, this is captured by `interp.compare.` + * @param {*} v1 First value to compare. + * @param {*} v2 Second value to compare. + * @returns {Number} Negative number if v1 < v2; 0 if equal; positive otherwise. + */ + Cast.compare = function (v1, v2) { + var n1 = Number(v1); + var n2 = Number(v2); + if (isNaN(n1) || isNaN(n2)) { + // At least one argument can't be converted to a number. + // Scratch compares strings as case insensitive. + var s1 = String(v1).toLowerCase(); + var s2 = String(v2).toLowerCase(); + return s1.localeCompare(s2); + } else { + // Compare as numbers. + return n1 - n2; + } + }; + + module.exports = Cast; + + +/***/ }, +/* 14 */ +/***/ function(module, exports) { + + function Color () {} + + /** + * Convert a Scratch decimal color to a hex string, #RRGGBB. + * @param {number} decimal RGB color as a decimal. + * @return {string} RGB color as #RRGGBB hex string. + */ + Color.decimalToHex = function (decimal) { + if (decimal < 0) { + decimal += 0xFFFFFF + 1; + } + var hex = Number(decimal).toString(16); + hex = '#' + '000000'.substr(0, 6 - hex.length) + hex; + return hex; + }; + + /** + * Convert a Scratch decimal color to an RGB color object. + * @param {number} decimal RGB color as decimal. + * @returns {Object} {r: R, g: G, b: B}, values between 0-255 + */ + Color.decimalToRgb = function (decimal) { + var r = (decimal >> 16) & 0xFF; + var g = (decimal >> 8) & 0xFF; + var b = decimal & 0xFF; + return {r: r, g: g, b: b}; + }; + + /** + * Convert a hex color (e.g., F00, #03F, #0033FF) to an RGB color object. + * CC-BY-SA Tim Down: + * https://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb + * @param {!string} hex Hex representation of the color. + * @return {Object} {r: R, g: G, b: B}, 0-255, or null. + */ + Color.hexToRgb = function (hex) { + var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i; + hex = hex.replace(shorthandRegex, function(m, r, g, b) { + return r + r + g + g + b + b; + }); + var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); + return result ? { + r: parseInt(result[1], 16), + g: parseInt(result[2], 16), + b: parseInt(result[3], 16) + } : null; + }; + + /** + * Convert an RGB color object to a hex color. + * @param {Object} rgb {r: R, g: G, b: B}, values between 0-255. + * @return {!string} Hex representation of the color. + */ + Color.rgbToHex = function (rgb) { + return Color.decimalToHex(Color.rgbToDecimal(rgb)); + }; + + /** + * Convert an RGB color object to a Scratch decimal color. + * @param {Object} rgb {r: R, g: G, b: B}, values between 0-255. + * @return {!number} Number representing the color. + */ + Color.rgbToDecimal = function (rgb) { + return (rgb.r << 16) + (rgb.g << 8) + rgb.b; + }; + + /** + * Convert a hex color (e.g., F00, #03F, #0033FF) to a decimal color number. + * @param {!string} hex Hex representation of the color. + * @return {!number} Number representing the color. + */ + Color.hexToDecimal = function (hex) { + return Color.rgbToDecimal(Color.hexToRgb(hex)); + }; + + module.exports = Color; + + +/***/ }, +/* 15 */ +/***/ function(module, exports, __webpack_require__) { + + var MathUtil = __webpack_require__(16); + + function Mouse (runtime) { + this._x = 0; + this._y = 0; + this._isDown = false; + /** + * Reference to the owning Runtime. + * Can be used, for example, to activate hats. + * @type{!Runtime} + */ + this.runtime = runtime; + } + + Mouse.prototype.postData = function(data) { + if (data.x) { + this._x = data.x - data.canvasWidth / 2; + } + if (data.y) { + this._y = data.y - data.canvasHeight / 2; + } + if (typeof data.isDown !== 'undefined') { + this._isDown = data.isDown; + if (this._isDown) { + this._activateClickHats(data.x, data.y); + } + } + }; + + Mouse.prototype._activateClickHats = function (x, y) { + if (self.renderer) { + var pickPromise = self.renderer.pick(x, y); + var instance = this; + pickPromise.then(function(drawableID) { + for (var i = 0; i < instance.runtime.targets.length; i++) { + var target = instance.runtime.targets[i]; + if (target.hasOwnProperty('drawableID') && + target.drawableID == drawableID) { + instance.runtime.startHats('event_whenthisspriteclicked', + null, target); + return; + } + } + }); + } + }; + + Mouse.prototype.getX = function () { + return MathUtil.clamp(this._x, -240, 240); + }; + + Mouse.prototype.getY = function () { + return MathUtil.clamp(-this._y, -180, 180); + }; + + Mouse.prototype.getIsDown = function () { + return this._isDown; + }; + + module.exports = Mouse; + + +/***/ }, +/* 16 */ /***/ function(module, exports) { function MathUtil () {} @@ -1553,36 +2939,2026 @@ /***/ }, -/* 9 */ +/* 17 */ /***/ function(module, exports, __webpack_require__) { - var Blocks = __webpack_require__(10); + var Cast = __webpack_require__(13); + var Promise = __webpack_require__(18); - /** - * @fileoverview - * A Target is an abstract "code-running" object for the Scratch VM. - * Examples include sprites/clones or potentially physical-world devices. - */ - - /** - * @param {?Blocks} blocks Blocks instance for the blocks owned by this target. - * @constructor - */ - function Target (blocks) { - if (!blocks) { - blocks = new Blocks(this); - } - this.blocks = blocks; + function Scratch3ControlBlocks(runtime) { + /** + * The runtime instantiating this block package. + * @type {Runtime} + */ + this.runtime = runtime; } - module.exports = Target; + /** + * Retrieve the block primitives implemented by this package. + * @return {Object.<string, Function>} Mapping of opcode to Function. + */ + Scratch3ControlBlocks.prototype.getPrimitives = function() { + return { + 'control_repeat': this.repeat, + 'control_repeat_until': this.repeatUntil, + 'control_forever': this.forever, + 'control_wait': this.wait, + 'control_if': this.if, + 'control_if_else': this.ifElse, + 'control_stop': this.stop + }; + }; + + Scratch3ControlBlocks.prototype.repeat = function(args, util) { + var times = Math.floor(Cast.toNumber(args.TIMES)); + // Initialize loop + if (util.stackFrame.loopCounter === undefined) { + util.stackFrame.loopCounter = times; + } + // Only execute once per frame. + // When the branch finishes, `repeat` will be executed again and + // the second branch will be taken, yielding for the rest of the frame. + if (!util.stackFrame.executedInFrame) { + util.stackFrame.executedInFrame = true; + // Decrease counter + util.stackFrame.loopCounter--; + // If we still have some left, start the branch. + if (util.stackFrame.loopCounter >= 0) { + util.startBranch(); + } + } else { + util.stackFrame.executedInFrame = false; + util.yieldFrame(); + } + }; + + Scratch3ControlBlocks.prototype.repeatUntil = function(args, util) { + var condition = Cast.toBoolean(args.CONDITION); + // Only execute once per frame. + // When the branch finishes, `repeat` will be executed again and + // the second branch will be taken, yielding for the rest of the frame. + if (!util.stackFrame.executedInFrame) { + util.stackFrame.executedInFrame = true; + // If the condition is true, start the branch. + if (!condition) { + util.startBranch(); + } + } else { + util.stackFrame.executedInFrame = false; + util.yieldFrame(); + } + }; + + Scratch3ControlBlocks.prototype.forever = function(args, util) { + // Only execute once per frame. + // When the branch finishes, `forever` will be executed again and + // the second branch will be taken, yielding for the rest of the frame. + if (!util.stackFrame.executedInFrame) { + util.stackFrame.executedInFrame = true; + util.startBranch(); + } else { + util.stackFrame.executedInFrame = false; + util.yieldFrame(); + } + }; + + Scratch3ControlBlocks.prototype.wait = function(args) { + var duration = Cast.toNumber(args.DURATION); + return new Promise(function(resolve) { + setTimeout(function() { + resolve(); + }, 1000 * duration); + }); + }; + + Scratch3ControlBlocks.prototype.if = function(args, util) { + var condition = Cast.toBoolean(args.CONDITION); + // Only execute one time. `if` will be returned to + // when the branch finishes, but it shouldn't execute again. + if (util.stackFrame.executedInFrame === undefined) { + util.stackFrame.executedInFrame = true; + if (condition) { + util.startBranch(); + } + } + }; + + Scratch3ControlBlocks.prototype.ifElse = function(args, util) { + var condition = Cast.toBoolean(args.CONDITION); + // Only execute one time. `ifElse` will be returned to + // when the branch finishes, but it shouldn't execute again. + if (util.stackFrame.executedInFrame === undefined) { + util.stackFrame.executedInFrame = true; + if (condition) { + util.startBranch(1); + } else { + util.startBranch(2); + } + } + }; + + Scratch3ControlBlocks.prototype.stop = function() { + // @todo - don't use this.runtime + this.runtime.stopAll(); + }; + + module.exports = Scratch3ControlBlocks; /***/ }, -/* 10 */ +/* 18 */ /***/ function(module, exports, __webpack_require__) { - var adapter = __webpack_require__(11); + 'use strict'; + + module.exports = __webpack_require__(19) + + +/***/ }, +/* 19 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + module.exports = __webpack_require__(20); + __webpack_require__(22); + __webpack_require__(23); + __webpack_require__(24); + __webpack_require__(25); + __webpack_require__(27); + + +/***/ }, +/* 20 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var asap = __webpack_require__(21); + + function noop() {} + + // States: + // + // 0 - pending + // 1 - fulfilled with _value + // 2 - rejected with _value + // 3 - adopted the state of another promise, _value + // + // once the state is no longer pending (0) it is immutable + + // All `_` prefixed properties will be reduced to `_{random number}` + // at build time to obfuscate them and discourage their use. + // We don't use symbols or Object.defineProperty to fully hide them + // because the performance isn't good enough. + + + // to avoid using try/catch inside critical functions, we + // extract them to here. + var LAST_ERROR = null; + var IS_ERROR = {}; + function getThen(obj) { + try { + return obj.then; + } catch (ex) { + LAST_ERROR = ex; + return IS_ERROR; + } + } + + function tryCallOne(fn, a) { + try { + return fn(a); + } catch (ex) { + LAST_ERROR = ex; + return IS_ERROR; + } + } + function tryCallTwo(fn, a, b) { + try { + fn(a, b); + } catch (ex) { + LAST_ERROR = ex; + return IS_ERROR; + } + } + + module.exports = Promise; + + function Promise(fn) { + if (typeof this !== 'object') { + throw new TypeError('Promises must be constructed via new'); + } + if (typeof fn !== 'function') { + throw new TypeError('not a function'); + } + this._45 = 0; + this._81 = 0; + this._65 = null; + this._54 = null; + if (fn === noop) return; + doResolve(fn, this); + } + Promise._10 = null; + Promise._97 = null; + Promise._61 = noop; + + Promise.prototype.then = function(onFulfilled, onRejected) { + if (this.constructor !== Promise) { + return safeThen(this, onFulfilled, onRejected); + } + var res = new Promise(noop); + handle(this, new Handler(onFulfilled, onRejected, res)); + return res; + }; + + function safeThen(self, onFulfilled, onRejected) { + return new self.constructor(function (resolve, reject) { + var res = new Promise(noop); + res.then(resolve, reject); + handle(self, new Handler(onFulfilled, onRejected, res)); + }); + }; + function handle(self, deferred) { + while (self._81 === 3) { + self = self._65; + } + if (Promise._10) { + Promise._10(self); + } + if (self._81 === 0) { + if (self._45 === 0) { + self._45 = 1; + self._54 = deferred; + return; + } + if (self._45 === 1) { + self._45 = 2; + self._54 = [self._54, deferred]; + return; + } + self._54.push(deferred); + return; + } + handleResolved(self, deferred); + } + + function handleResolved(self, deferred) { + asap(function() { + var cb = self._81 === 1 ? deferred.onFulfilled : deferred.onRejected; + if (cb === null) { + if (self._81 === 1) { + resolve(deferred.promise, self._65); + } else { + reject(deferred.promise, self._65); + } + return; + } + var ret = tryCallOne(cb, self._65); + if (ret === IS_ERROR) { + reject(deferred.promise, LAST_ERROR); + } else { + resolve(deferred.promise, ret); + } + }); + } + function resolve(self, newValue) { + // Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure + if (newValue === self) { + return reject( + self, + new TypeError('A promise cannot be resolved with itself.') + ); + } + if ( + newValue && + (typeof newValue === 'object' || typeof newValue === 'function') + ) { + var then = getThen(newValue); + if (then === IS_ERROR) { + return reject(self, LAST_ERROR); + } + if ( + then === self.then && + newValue instanceof Promise + ) { + self._81 = 3; + self._65 = newValue; + finale(self); + return; + } else if (typeof then === 'function') { + doResolve(then.bind(newValue), self); + return; + } + } + self._81 = 1; + self._65 = newValue; + finale(self); + } + + function reject(self, newValue) { + self._81 = 2; + self._65 = newValue; + if (Promise._97) { + Promise._97(self, newValue); + } + finale(self); + } + function finale(self) { + if (self._45 === 1) { + handle(self, self._54); + self._54 = null; + } + if (self._45 === 2) { + for (var i = 0; i < self._54.length; i++) { + handle(self, self._54[i]); + } + self._54 = null; + } + } + + function Handler(onFulfilled, onRejected, promise){ + this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null; + this.onRejected = typeof onRejected === 'function' ? onRejected : null; + this.promise = promise; + } + + /** + * Take a potentially misbehaving resolver function and make sure + * onFulfilled and onRejected are only called once. + * + * Makes no guarantees about asynchrony. + */ + function doResolve(fn, promise) { + var done = false; + var res = tryCallTwo(fn, function (value) { + if (done) return; + done = true; + resolve(promise, value); + }, function (reason) { + if (done) return; + done = true; + reject(promise, reason); + }) + if (!done && res === IS_ERROR) { + done = true; + reject(promise, LAST_ERROR); + } + } + + +/***/ }, +/* 21 */ +/***/ function(module, exports) { + + /* WEBPACK VAR INJECTION */(function(global) {"use strict"; + + // Use the fastest means possible to execute a task in its own turn, with + // priority over other events including IO, animation, reflow, and redraw + // events in browsers. + // + // An exception thrown by a task will permanently interrupt the processing of + // subsequent tasks. The higher level `asap` function ensures that if an + // exception is thrown by a task, that the task queue will continue flushing as + // soon as possible, but if you use `rawAsap` directly, you are responsible to + // either ensure that no exceptions are thrown from your task, or to manually + // call `rawAsap.requestFlush` if an exception is thrown. + module.exports = rawAsap; + function rawAsap(task) { + if (!queue.length) { + requestFlush(); + flushing = true; + } + // Equivalent to push, but avoids a function call. + queue[queue.length] = task; + } + + var queue = []; + // Once a flush has been requested, no further calls to `requestFlush` are + // necessary until the next `flush` completes. + var flushing = false; + // `requestFlush` is an implementation-specific method that attempts to kick + // off a `flush` event as quickly as possible. `flush` will attempt to exhaust + // the event queue before yielding to the browser's own event loop. + var requestFlush; + // The position of the next task to execute in the task queue. This is + // preserved between calls to `flush` so that it can be resumed if + // a task throws an exception. + var index = 0; + // If a task schedules additional tasks recursively, the task queue can grow + // unbounded. To prevent memory exhaustion, the task queue will periodically + // truncate already-completed tasks. + var capacity = 1024; + + // The flush function processes all tasks that have been scheduled with + // `rawAsap` unless and until one of those tasks throws an exception. + // If a task throws an exception, `flush` ensures that its state will remain + // consistent and will resume where it left off when called again. + // However, `flush` does not make any arrangements to be called again if an + // exception is thrown. + function flush() { + while (index < queue.length) { + var currentIndex = index; + // Advance the index before calling the task. This ensures that we will + // begin flushing on the next task the task throws an error. + index = index + 1; + queue[currentIndex].call(); + // Prevent leaking memory for long chains of recursive calls to `asap`. + // If we call `asap` within tasks scheduled by `asap`, the queue will + // grow, but to avoid an O(n) walk for every task we execute, we don't + // shift tasks off the queue after they have been executed. + // Instead, we periodically shift 1024 tasks off the queue. + if (index > capacity) { + // Manually shift all values starting at the index back to the + // beginning of the queue. + for (var scan = 0, newLength = queue.length - index; scan < newLength; scan++) { + queue[scan] = queue[scan + index]; + } + queue.length -= index; + index = 0; + } + } + queue.length = 0; + index = 0; + flushing = false; + } + + // `requestFlush` is implemented using a strategy based on data collected from + // every available SauceLabs Selenium web driver worker at time of writing. + // https://docs.google.com/spreadsheets/d/1mG-5UYGup5qxGdEMWkhP6BWCz053NUb2E1QoUTU16uA/edit#gid=783724593 + + // Safari 6 and 6.1 for desktop, iPad, and iPhone are the only browsers that + // have WebKitMutationObserver but not un-prefixed MutationObserver. + // Must use `global` instead of `window` to work in both frames and web + // workers. `global` is a provision of Browserify, Mr, Mrs, or Mop. + var BrowserMutationObserver = global.MutationObserver || global.WebKitMutationObserver; + + // MutationObservers are desirable because they have high priority and work + // reliably everywhere they are implemented. + // They are implemented in all modern browsers. + // + // - Android 4-4.3 + // - Chrome 26-34 + // - Firefox 14-29 + // - Internet Explorer 11 + // - iPad Safari 6-7.1 + // - iPhone Safari 7-7.1 + // - Safari 6-7 + if (typeof BrowserMutationObserver === "function") { + requestFlush = makeRequestCallFromMutationObserver(flush); + + // MessageChannels are desirable because they give direct access to the HTML + // task queue, are implemented in Internet Explorer 10, Safari 5.0-1, and Opera + // 11-12, and in web workers in many engines. + // Although message channels yield to any queued rendering and IO tasks, they + // would be better than imposing the 4ms delay of timers. + // However, they do not work reliably in Internet Explorer or Safari. + + // Internet Explorer 10 is the only browser that has setImmediate but does + // not have MutationObservers. + // Although setImmediate yields to the browser's renderer, it would be + // preferrable to falling back to setTimeout since it does not have + // the minimum 4ms penalty. + // Unfortunately there appears to be a bug in Internet Explorer 10 Mobile (and + // Desktop to a lesser extent) that renders both setImmediate and + // MessageChannel useless for the purposes of ASAP. + // https://github.com/kriskowal/q/issues/396 + + // Timers are implemented universally. + // We fall back to timers in workers in most engines, and in foreground + // contexts in the following browsers. + // However, note that even this simple case requires nuances to operate in a + // broad spectrum of browsers. + // + // - Firefox 3-13 + // - Internet Explorer 6-9 + // - iPad Safari 4.3 + // - Lynx 2.8.7 + } else { + requestFlush = makeRequestCallFromTimer(flush); + } + + // `requestFlush` requests that the high priority event queue be flushed as + // soon as possible. + // This is useful to prevent an error thrown in a task from stalling the event + // queue if the exception handled by Node.js’s + // `process.on("uncaughtException")` or by a domain. + rawAsap.requestFlush = requestFlush; + + // To request a high priority event, we induce a mutation observer by toggling + // the text of a text node between "1" and "-1". + function makeRequestCallFromMutationObserver(callback) { + var toggle = 1; + var observer = new BrowserMutationObserver(callback); + var node = document.createTextNode(""); + observer.observe(node, {characterData: true}); + return function requestCall() { + toggle = -toggle; + node.data = toggle; + }; + } + + // The message channel technique was discovered by Malte Ubl and was the + // original foundation for this library. + // http://www.nonblocking.io/2011/06/windownexttick.html + + // Safari 6.0.5 (at least) intermittently fails to create message ports on a + // page's first load. Thankfully, this version of Safari supports + // MutationObservers, so we don't need to fall back in that case. + + // function makeRequestCallFromMessageChannel(callback) { + // var channel = new MessageChannel(); + // channel.port1.onmessage = callback; + // return function requestCall() { + // channel.port2.postMessage(0); + // }; + // } + + // For reasons explained above, we are also unable to use `setImmediate` + // under any circumstances. + // Even if we were, there is another bug in Internet Explorer 10. + // It is not sufficient to assign `setImmediate` to `requestFlush` because + // `setImmediate` must be called *by name* and therefore must be wrapped in a + // closure. + // Never forget. + + // function makeRequestCallFromSetImmediate(callback) { + // return function requestCall() { + // setImmediate(callback); + // }; + // } + + // Safari 6.0 has a problem where timers will get lost while the user is + // scrolling. This problem does not impact ASAP because Safari 6.0 supports + // mutation observers, so that implementation is used instead. + // However, if we ever elect to use timers in Safari, the prevalent work-around + // is to add a scroll event listener that calls for a flush. + + // `setTimeout` does not call the passed callback if the delay is less than + // approximately 7 in web workers in Firefox 8 through 18, and sometimes not + // even then. + + function makeRequestCallFromTimer(callback) { + return function requestCall() { + // We dispatch a timeout with a specified delay of 0 for engines that + // can reliably accommodate that request. This will usually be snapped + // to a 4 milisecond delay, but once we're flushing, there's no delay + // between events. + var timeoutHandle = setTimeout(handleTimer, 0); + // However, since this timer gets frequently dropped in Firefox + // workers, we enlist an interval handle that will try to fire + // an event 20 times per second until it succeeds. + var intervalHandle = setInterval(handleTimer, 50); + + function handleTimer() { + // Whichever timer succeeds will cancel both timers and + // execute the callback. + clearTimeout(timeoutHandle); + clearInterval(intervalHandle); + callback(); + } + }; + } + + // This is for `asap.js` only. + // Its name will be periodically randomized to break any code that depends on + // its existence. + rawAsap.makeRequestCallFromTimer = makeRequestCallFromTimer; + + // ASAP was originally a nextTick shim included in Q. This was factored out + // into this ASAP package. It was later adapted to RSVP which made further + // amendments. These decisions, particularly to marginalize MessageChannel and + // to capture the MutationObserver implementation in a closure, were integrated + // back into ASAP proper. + // https://github.com/tildeio/rsvp.js/blob/cddf7232546a9cf858524b75cde6f9edf72620a7/lib/rsvp/asap.js + + /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) + +/***/ }, +/* 22 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var Promise = __webpack_require__(20); + + module.exports = Promise; + Promise.prototype.done = function (onFulfilled, onRejected) { + var self = arguments.length ? this.then.apply(this, arguments) : this; + self.then(null, function (err) { + setTimeout(function () { + throw err; + }, 0); + }); + }; + + +/***/ }, +/* 23 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var Promise = __webpack_require__(20); + + module.exports = Promise; + Promise.prototype['finally'] = function (f) { + return this.then(function (value) { + return Promise.resolve(f()).then(function () { + return value; + }); + }, function (err) { + return Promise.resolve(f()).then(function () { + throw err; + }); + }); + }; + + +/***/ }, +/* 24 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + //This file contains the ES6 extensions to the core Promises/A+ API + + var Promise = __webpack_require__(20); + + module.exports = Promise; + + /* Static Functions */ + + var TRUE = valuePromise(true); + var FALSE = valuePromise(false); + var NULL = valuePromise(null); + var UNDEFINED = valuePromise(undefined); + var ZERO = valuePromise(0); + var EMPTYSTRING = valuePromise(''); + + function valuePromise(value) { + var p = new Promise(Promise._61); + p._81 = 1; + p._65 = value; + return p; + } + Promise.resolve = function (value) { + if (value instanceof Promise) return value; + + if (value === null) return NULL; + if (value === undefined) return UNDEFINED; + if (value === true) return TRUE; + if (value === false) return FALSE; + if (value === 0) return ZERO; + if (value === '') return EMPTYSTRING; + + if (typeof value === 'object' || typeof value === 'function') { + try { + var then = value.then; + if (typeof then === 'function') { + return new Promise(then.bind(value)); + } + } catch (ex) { + return new Promise(function (resolve, reject) { + reject(ex); + }); + } + } + return valuePromise(value); + }; + + Promise.all = function (arr) { + var args = Array.prototype.slice.call(arr); + + return new Promise(function (resolve, reject) { + if (args.length === 0) return resolve([]); + var remaining = args.length; + function res(i, val) { + if (val && (typeof val === 'object' || typeof val === 'function')) { + if (val instanceof Promise && val.then === Promise.prototype.then) { + while (val._81 === 3) { + val = val._65; + } + if (val._81 === 1) return res(i, val._65); + if (val._81 === 2) reject(val._65); + val.then(function (val) { + res(i, val); + }, reject); + return; + } else { + var then = val.then; + if (typeof then === 'function') { + var p = new Promise(then.bind(val)); + p.then(function (val) { + res(i, val); + }, reject); + return; + } + } + } + args[i] = val; + if (--remaining === 0) { + resolve(args); + } + } + for (var i = 0; i < args.length; i++) { + res(i, args[i]); + } + }); + }; + + Promise.reject = function (value) { + return new Promise(function (resolve, reject) { + reject(value); + }); + }; + + Promise.race = function (values) { + return new Promise(function (resolve, reject) { + values.forEach(function(value){ + Promise.resolve(value).then(resolve, reject); + }); + }); + }; + + /* Prototype Methods */ + + Promise.prototype['catch'] = function (onRejected) { + return this.then(null, onRejected); + }; + + +/***/ }, +/* 25 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + // This file contains then/promise specific extensions that are only useful + // for node.js interop + + var Promise = __webpack_require__(20); + var asap = __webpack_require__(26); + + module.exports = Promise; + + /* Static Functions */ + + Promise.denodeify = function (fn, argumentCount) { + if ( + typeof argumentCount === 'number' && argumentCount !== Infinity + ) { + return denodeifyWithCount(fn, argumentCount); + } else { + return denodeifyWithoutCount(fn); + } + } + + var callbackFn = ( + 'function (err, res) {' + + 'if (err) { rj(err); } else { rs(res); }' + + '}' + ); + function denodeifyWithCount(fn, argumentCount) { + var args = []; + for (var i = 0; i < argumentCount; i++) { + args.push('a' + i); + } + var body = [ + 'return function (' + args.join(',') + ') {', + 'var self = this;', + 'return new Promise(function (rs, rj) {', + 'var res = fn.call(', + ['self'].concat(args).concat([callbackFn]).join(','), + ');', + 'if (res &&', + '(typeof res === "object" || typeof res === "function") &&', + 'typeof res.then === "function"', + ') {rs(res);}', + '});', + '};' + ].join(''); + return Function(['Promise', 'fn'], body)(Promise, fn); + } + function denodeifyWithoutCount(fn) { + var fnLength = Math.max(fn.length - 1, 3); + var args = []; + for (var i = 0; i < fnLength; i++) { + args.push('a' + i); + } + var body = [ + 'return function (' + args.join(',') + ') {', + 'var self = this;', + 'var args;', + 'var argLength = arguments.length;', + 'if (arguments.length > ' + fnLength + ') {', + 'args = new Array(arguments.length + 1);', + 'for (var i = 0; i < arguments.length; i++) {', + 'args[i] = arguments[i];', + '}', + '}', + 'return new Promise(function (rs, rj) {', + 'var cb = ' + callbackFn + ';', + 'var res;', + 'switch (argLength) {', + args.concat(['extra']).map(function (_, index) { + return ( + 'case ' + (index) + ':' + + 'res = fn.call(' + ['self'].concat(args.slice(0, index)).concat('cb').join(',') + ');' + + 'break;' + ); + }).join(''), + 'default:', + 'args[argLength] = cb;', + 'res = fn.apply(self, args);', + '}', + + 'if (res &&', + '(typeof res === "object" || typeof res === "function") &&', + 'typeof res.then === "function"', + ') {rs(res);}', + '});', + '};' + ].join(''); + + return Function( + ['Promise', 'fn'], + body + )(Promise, fn); + } + + Promise.nodeify = function (fn) { + return function () { + var args = Array.prototype.slice.call(arguments); + var callback = + typeof args[args.length - 1] === 'function' ? args.pop() : null; + var ctx = this; + try { + return fn.apply(this, arguments).nodeify(callback, ctx); + } catch (ex) { + if (callback === null || typeof callback == 'undefined') { + return new Promise(function (resolve, reject) { + reject(ex); + }); + } else { + asap(function () { + callback.call(ctx, ex); + }) + } + } + } + } + + Promise.prototype.nodeify = function (callback, ctx) { + if (typeof callback != 'function') return this; + + this.then(function (value) { + asap(function () { + callback.call(ctx, null, value); + }); + }, function (err) { + asap(function () { + callback.call(ctx, err); + }); + }); + } + + +/***/ }, +/* 26 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + + // rawAsap provides everything we need except exception management. + var rawAsap = __webpack_require__(21); + // RawTasks are recycled to reduce GC churn. + var freeTasks = []; + // We queue errors to ensure they are thrown in right order (FIFO). + // Array-as-queue is good enough here, since we are just dealing with exceptions. + var pendingErrors = []; + var requestErrorThrow = rawAsap.makeRequestCallFromTimer(throwFirstError); + + function throwFirstError() { + if (pendingErrors.length) { + throw pendingErrors.shift(); + } + } + + /** + * Calls a task as soon as possible after returning, in its own event, with priority + * over other events like animation, reflow, and repaint. An error thrown from an + * event will not interrupt, nor even substantially slow down the processing of + * other events, but will be rather postponed to a lower priority event. + * @param {{call}} task A callable object, typically a function that takes no + * arguments. + */ + module.exports = asap; + function asap(task) { + var rawTask; + if (freeTasks.length) { + rawTask = freeTasks.pop(); + } else { + rawTask = new RawTask(); + } + rawTask.task = task; + rawAsap(rawTask); + } + + // We wrap tasks with recyclable task objects. A task object implements + // `call`, just like a function. + function RawTask() { + this.task = null; + } + + // The sole purpose of wrapping the task is to catch the exception and recycle + // the task object after its single use. + RawTask.prototype.call = function () { + try { + this.task.call(); + } catch (error) { + if (asap.onerror) { + // This hook exists purely for testing purposes. + // Its name will be periodically randomized to break any code that + // depends on its existence. + asap.onerror(error); + } else { + // In a web browser, exceptions are not fatal. However, to avoid + // slowing down the queue of pending tasks, we rethrow the error in a + // lower priority turn. + pendingErrors.push(error); + requestErrorThrow(); + } + } finally { + this.task = null; + freeTasks[freeTasks.length] = this; + } + }; + + +/***/ }, +/* 27 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var Promise = __webpack_require__(20); + + module.exports = Promise; + Promise.enableSynchronous = function () { + Promise.prototype.isPending = function() { + return this.getState() == 0; + }; + + Promise.prototype.isFulfilled = function() { + return this.getState() == 1; + }; + + Promise.prototype.isRejected = function() { + return this.getState() == 2; + }; + + Promise.prototype.getValue = function () { + if (this._81 === 3) { + return this._65.getValue(); + } + + if (!this.isFulfilled()) { + throw new Error('Cannot get a value of an unfulfilled promise.'); + } + + return this._65; + }; + + Promise.prototype.getReason = function () { + if (this._81 === 3) { + return this._65.getReason(); + } + + if (!this.isRejected()) { + throw new Error('Cannot get a rejection reason of a non-rejected promise.'); + } + + return this._65; + }; + + Promise.prototype.getState = function () { + if (this._81 === 3) { + return this._65.getState(); + } + if (this._81 === -1 || this._81 === -2) { + return 0; + } + + return this._81; + }; + }; + + Promise.disableSynchronous = function() { + Promise.prototype.isPending = undefined; + Promise.prototype.isFulfilled = undefined; + Promise.prototype.isRejected = undefined; + Promise.prototype.getValue = undefined; + Promise.prototype.getReason = undefined; + Promise.prototype.getState = undefined; + }; + + +/***/ }, +/* 28 */ +/***/ function(module, exports, __webpack_require__) { + + var Cast = __webpack_require__(13); + + function Scratch3EventBlocks(runtime) { + /** + * The runtime instantiating this block package. + * @type {Runtime} + */ + this.runtime = runtime; + } + + /** + * Retrieve the block primitives implemented by this package. + * @return {Object.<string, Function>} Mapping of opcode to Function. + */ + Scratch3EventBlocks.prototype.getPrimitives = function() { + return { + 'event_broadcast': this.broadcast, + 'event_broadcastandwait': this.broadcastAndWait, + 'event_whengreaterthan': this.hatGreaterThanPredicate + }; + }; + + Scratch3EventBlocks.prototype.getHats = function () { + return { + 'event_whenflagclicked': { + restartExistingThreads: true + }, + 'event_whenkeypressed': { + restartExistingThreads: false + }, + 'event_whenthisspriteclicked': { + restartExistingThreads: true + }, + 'event_whenbackdropswitchesto': { + restartExistingThreads: true + }, + 'event_whengreaterthan': { + restartExistingThreads: false, + edgeActivated: true + }, + 'event_whenbroadcastreceived': { + restartExistingThreads: true + } + }; + }; + + Scratch3EventBlocks.prototype.hatGreaterThanPredicate = function (args, util) { + var option = Cast.toString(args.WHENGREATERTHANMENU).toLowerCase(); + var value = Cast.toNumber(args.VALUE); + // @todo: Other cases :) + if (option == 'timer') { + return util.ioQuery('clock', 'projectTimer') > value; + } + return false; + }; + + Scratch3EventBlocks.prototype.broadcast = function(args, util) { + var broadcastOption = Cast.toString(args.BROADCAST_OPTION); + util.startHats('event_whenbroadcastreceived', { + 'BROADCAST_OPTION': broadcastOption + }); + }; + + Scratch3EventBlocks.prototype.broadcastAndWait = function (args, util) { + var broadcastOption = Cast.toString(args.BROADCAST_OPTION); + // Have we run before, starting threads? + if (!util.stackFrame.startedThreads) { + // No - start hats for this broadcast. + util.stackFrame.startedThreads = util.startHats( + 'event_whenbroadcastreceived', { + 'BROADCAST_OPTION': broadcastOption + } + ); + if (util.stackFrame.startedThreads.length == 0) { + // Nothing was started. + return; + } + } + // We've run before; check if the wait is still going on. + var instance = this; + var waiting = util.stackFrame.startedThreads.some(function(thread) { + return instance.runtime.isActiveThread(thread); + }); + if (waiting) { + util.yieldFrame(); + } + }; + + module.exports = Scratch3EventBlocks; + + +/***/ }, +/* 29 */ +/***/ function(module, exports, __webpack_require__) { + + var Cast = __webpack_require__(13); + + function Scratch3LooksBlocks(runtime) { + /** + * The runtime instantiating this block package. + * @type {Runtime} + */ + this.runtime = runtime; + } + + /** + * Retrieve the block primitives implemented by this package. + * @return {Object.<string, Function>} Mapping of opcode to Function. + */ + Scratch3LooksBlocks.prototype.getPrimitives = function() { + return { + 'looks_say': this.say, + 'looks_sayforsecs': this.sayforsecs, + 'looks_think': this.think, + 'looks_thinkforsecs': this.sayforsecs, + 'looks_show': this.show, + 'looks_hide': this.hide, + 'looks_switchcostumeto': this.switchCostume, + 'looks_switchbackdropto': this.switchBackdrop, + 'looks_switchbackdroptoandwait': this.switchBackdropAndWait, + 'looks_nextcostume': this.nextCostume, + 'looks_nextbackdrop': this.nextBackdrop, + 'looks_changeeffectby': this.changeEffect, + 'looks_seteffectto': this.setEffect, + 'looks_cleargraphiceffects': this.clearEffects, + 'looks_changesizeby': this.changeSize, + 'looks_setsizeto': this.setSize, + 'looks_size': this.getSize, + 'looks_costumeorder': this.getCostumeIndex, + 'looks_backdroporder': this.getBackdropIndex, + 'looks_backdropname': this.getBackdropName + }; + }; + + Scratch3LooksBlocks.prototype.say = function (args, util) { + util.target.setSay('say', args.MESSAGE); + }; + + Scratch3LooksBlocks.prototype.sayforsecs = function (args, util) { + util.target.setSay('say', args.MESSAGE); + return new Promise(function(resolve) { + setTimeout(function() { + // Clear say bubble and proceed. + util.target.setSay(); + resolve(); + }, 1000 * args.SECS); + }); + }; + + Scratch3LooksBlocks.prototype.think = function (args, util) { + util.target.setSay('think', args.MESSAGE); + }; + + Scratch3LooksBlocks.prototype.thinkforsecs = function (args, util) { + util.target.setSay('think', args.MESSAGE); + return new Promise(function(resolve) { + setTimeout(function() { + // Clear say bubble and proceed. + util.target.setSay(); + resolve(); + }, 1000 * args.SECS); + }); + }; + + Scratch3LooksBlocks.prototype.show = function (args, util) { + util.target.setVisible(true); + }; + + Scratch3LooksBlocks.prototype.hide = function (args, util) { + util.target.setVisible(false); + }; + + /** + * Utility function to set the costume or backdrop of a target. + * Matches the behavior of Scratch 2.0 for different types of arguments. + * @param {!Target} target Target to set costume/backdrop to. + * @param {Any} requestedCostume Costume requested, e.g., 0, 'name', etc. + * @param {boolean=} opt_zeroIndex Set to zero-index the requestedCostume. + * @return {Array.<!Thread>} Any threads started by this switch. + */ + Scratch3LooksBlocks.prototype._setCostumeOrBackdrop = function (target, + requestedCostume, opt_zeroIndex) { + if (typeof requestedCostume === 'number') { + target.setCostume(opt_zeroIndex ? + requestedCostume : requestedCostume - 1); + } else { + var costumeIndex = target.getCostumeIndexByName(requestedCostume); + if (costumeIndex > -1) { + target.setCostume(costumeIndex); + } else if (costumeIndex == 'previous costume' || + costumeIndex == 'previous backdrop') { + target.setCostume(target.currentCostume - 1); + } else if (costumeIndex == 'next costume' || + costumeIndex == 'next backdrop') { + target.setCostume(target.currentCostume + 1); + } else { + var forcedNumber = Cast.toNumber(requestedCostume); + if (!isNaN(forcedNumber)) { + target.setCostume(opt_zeroIndex ? + forcedNumber : forcedNumber - 1); + } + } + } + if (target == this.runtime.getTargetForStage()) { + // Target is the stage - start hats. + var newName = target.sprite.costumes[target.currentCostume].name; + return this.runtime.startHats('event_whenbackdropswitchesto', { + 'BACKDROP': newName + }); + } + return []; + }; + + Scratch3LooksBlocks.prototype.switchCostume = function (args, util) { + this._setCostumeOrBackdrop(util.target, args.COSTUME); + }; + + Scratch3LooksBlocks.prototype.nextCostume = function (args, util) { + this._setCostumeOrBackdrop( + util.target, util.target.currentCostume + 1, true + ); + }; + + Scratch3LooksBlocks.prototype.switchBackdrop = function (args) { + this._setCostumeOrBackdrop(this.runtime.getTargetForStage(), args.BACKDROP); + }; + + Scratch3LooksBlocks.prototype.switchBackdropAndWait = function (args, util) { + // Have we run before, starting threads? + if (!util.stackFrame.startedThreads) { + // No - switch the backdrop. + util.stackFrame.startedThreads = ( + this._setCostumeOrBackdrop( + this.runtime.getTargetForStage(), + args.BACKDROP + ) + ); + if (util.stackFrame.startedThreads.length == 0) { + // Nothing was started. + return; + } + } + // We've run before; check if the wait is still going on. + var instance = this; + var waiting = util.stackFrame.startedThreads.some(function(thread) { + return instance.runtime.isActiveThread(thread); + }); + if (waiting) { + util.yieldFrame(); + } + }; + + Scratch3LooksBlocks.prototype.nextBackdrop = function () { + var stage = this.runtime.getTargetForStage(); + this._setCostumeOrBackdrop( + stage, stage.currentCostume + 1, true + ); + }; + + Scratch3LooksBlocks.prototype.changeEffect = function (args, util) { + var effect = Cast.toString(args.EFFECT).toLowerCase(); + var change = Cast.toNumber(args.CHANGE); + if (!util.target.effects.hasOwnProperty(effect)) return; + var newValue = change + util.target.effects[effect]; + util.target.setEffect(effect, newValue); + }; + + Scratch3LooksBlocks.prototype.setEffect = function (args, util) { + var effect = Cast.toString(args.EFFECT).toLowerCase(); + var value = Cast.toNumber(args.VALUE); + util.target.setEffect(effect, value); + }; + + Scratch3LooksBlocks.prototype.clearEffects = function (args, util) { + util.target.clearEffects(); + }; + + Scratch3LooksBlocks.prototype.changeSize = function (args, util) { + var change = Cast.toNumber(args.CHANGE); + util.target.setSize(util.target.size + change); + }; + + Scratch3LooksBlocks.prototype.setSize = function (args, util) { + var size = Cast.toNumber(args.SIZE); + util.target.setSize(size); + }; + + Scratch3LooksBlocks.prototype.getSize = function (args, util) { + return util.target.size; + }; + + Scratch3LooksBlocks.prototype.getBackdropIndex = function () { + var stage = this.runtime.getTargetForStage(); + return stage.currentCostume + 1; + }; + + Scratch3LooksBlocks.prototype.getBackdropName = function () { + var stage = this.runtime.getTargetForStage(); + return stage.sprite.costumes[stage.currentCostume].name; + }; + + Scratch3LooksBlocks.prototype.getCostumeIndex = function (args, util) { + return util.target.currentCostume + 1; + }; + + module.exports = Scratch3LooksBlocks; + + +/***/ }, +/* 30 */ +/***/ function(module, exports, __webpack_require__) { + + var Cast = __webpack_require__(13); + var MathUtil = __webpack_require__(16); + var Timer = __webpack_require__(8); + + function Scratch3MotionBlocks(runtime) { + /** + * The runtime instantiating this block package. + * @type {Runtime} + */ + this.runtime = runtime; + } + + /** + * Retrieve the block primitives implemented by this package. + * @return {Object.<string, Function>} Mapping of opcode to Function. + */ + Scratch3MotionBlocks.prototype.getPrimitives = function() { + return { + 'motion_movesteps': this.moveSteps, + 'motion_gotoxy': this.goToXY, + 'motion_turnright': this.turnRight, + 'motion_turnleft': this.turnLeft, + 'motion_pointindirection': this.pointInDirection, + 'motion_glidesecstoxy': this.glide, + 'motion_changexby': this.changeX, + 'motion_setx': this.setX, + 'motion_changeyby': this.changeY, + 'motion_sety': this.setY, + 'motion_xposition': this.getX, + 'motion_yposition': this.getY, + 'motion_direction': this.getDirection + }; + }; + + Scratch3MotionBlocks.prototype.moveSteps = function (args, util) { + var steps = Cast.toNumber(args.STEPS); + var radians = MathUtil.degToRad(util.target.direction); + var dx = steps * Math.cos(radians); + var dy = steps * Math.sin(radians); + util.target.setXY(util.target.x + dx, util.target.y + dy); + }; + + Scratch3MotionBlocks.prototype.goToXY = function (args, util) { + var x = Cast.toNumber(args.X); + var y = Cast.toNumber(args.Y); + util.target.setXY(x, y); + }; + + Scratch3MotionBlocks.prototype.turnRight = function (args, util) { + var degrees = Cast.toNumber(args.DEGREES); + util.target.setDirection(util.target.direction + degrees); + }; + + Scratch3MotionBlocks.prototype.turnLeft = function (args, util) { + var degrees = Cast.toNumber(args.DEGREES); + util.target.setDirection(util.target.direction - degrees); + }; + + Scratch3MotionBlocks.prototype.pointInDirection = function (args, util) { + var direction = Cast.toNumber(args.DIRECTION); + util.target.setDirection(direction); + }; + + Scratch3MotionBlocks.prototype.glide = function (args, util) { + if (!util.stackFrame.timer) { + // First time: save data for future use. + util.stackFrame.timer = new Timer(); + util.stackFrame.timer.start(); + util.stackFrame.duration = Cast.toNumber(args.SECS); + util.stackFrame.startX = util.target.x; + util.stackFrame.startY = util.target.y; + util.stackFrame.endX = Cast.toNumber(args.X); + util.stackFrame.endY = Cast.toNumber(args.Y); + if (util.stackFrame.duration <= 0) { + // Duration too short to glide. + util.target.setXY(util.stackFrame.endX, util.stackFrame.endY); + return; + } + util.yieldFrame(); + } else { + var timeElapsed = util.stackFrame.timer.timeElapsed(); + if (timeElapsed < util.stackFrame.duration * 1000) { + // In progress: move to intermediate position. + var frac = timeElapsed / (util.stackFrame.duration * 1000); + var dx = frac * (util.stackFrame.endX - util.stackFrame.startX); + var dy = frac * (util.stackFrame.endY - util.stackFrame.startY); + util.target.setXY( + util.stackFrame.startX + dx, + util.stackFrame.startY + dy + ); + util.yieldFrame(); + } else { + // Finished: move to final position. + util.target.setXY(util.stackFrame.endX, util.stackFrame.endY); + } + } + }; + + Scratch3MotionBlocks.prototype.changeX = function (args, util) { + var dx = Cast.toNumber(args.DX); + util.target.setXY(util.target.x + dx, util.target.y); + }; + + Scratch3MotionBlocks.prototype.setX = function (args, util) { + var x = Cast.toNumber(args.X); + util.target.setXY(x, util.target.y); + }; + + Scratch3MotionBlocks.prototype.changeY = function (args, util) { + var dy = Cast.toNumber(args.DY); + util.target.setXY(util.target.x, util.target.y + dy); + }; + + Scratch3MotionBlocks.prototype.setY = function (args, util) { + var y = Cast.toNumber(args.Y); + util.target.setXY(util.target.x, y); + }; + + Scratch3MotionBlocks.prototype.getX = function (args, util) { + return util.target.x; + }; + + Scratch3MotionBlocks.prototype.getY = function (args, util) { + return util.target.y; + }; + + Scratch3MotionBlocks.prototype.getDirection = function (args, util) { + return util.target.direction; + }; + + module.exports = Scratch3MotionBlocks; + + +/***/ }, +/* 31 */ +/***/ function(module, exports, __webpack_require__) { + + var Cast = __webpack_require__(13); + + function Scratch3OperatorsBlocks(runtime) { + /** + * The runtime instantiating this block package. + * @type {Runtime} + */ + this.runtime = runtime; + } + + /** + * Retrieve the block primitives implemented by this package. + * @return {Object.<string, Function>} Mapping of opcode to Function. + */ + Scratch3OperatorsBlocks.prototype.getPrimitives = function() { + return { + 'operator_add': this.add, + 'operator_subtract': this.subtract, + 'operator_multiply': this.multiply, + 'operator_divide': this.divide, + 'operator_lt': this.lt, + 'operator_equals': this.equals, + 'operator_gt': this.gt, + 'operator_and': this.and, + 'operator_or': this.or, + 'operator_not': this.not, + 'operator_random': this.random, + 'operator_join': this.join, + 'operator_letter_of': this.letterOf, + 'operator_length': this.length, + 'operator_mod': this.mod, + 'operator_round': this.round, + 'operator_mathop': this.mathop + }; + }; + + Scratch3OperatorsBlocks.prototype.add = function (args) { + return Cast.toNumber(args.NUM1) + Cast.toNumber(args.NUM2); + }; + + Scratch3OperatorsBlocks.prototype.subtract = function (args) { + return Cast.toNumber(args.NUM1) - Cast.toNumber(args.NUM2); + }; + + Scratch3OperatorsBlocks.prototype.multiply = function (args) { + return Cast.toNumber(args.NUM1) * Cast.toNumber(args.NUM2); + }; + + Scratch3OperatorsBlocks.prototype.divide = function (args) { + return Cast.toNumber(args.NUM1) / Cast.toNumber(args.NUM2); + }; + + Scratch3OperatorsBlocks.prototype.lt = function (args) { + return Cast.compare(args.OPERAND1, args.OPERAND2) < 0; + }; + + Scratch3OperatorsBlocks.prototype.equals = function (args) { + return Cast.compare(args.OPERAND1, args.OPERAND2) == 0; + }; + + Scratch3OperatorsBlocks.prototype.gt = function (args) { + return Cast.compare(args.OPERAND1, args.OPERAND2) > 0; + }; + + Scratch3OperatorsBlocks.prototype.and = function (args) { + return Cast.toBoolean(args.OPERAND1) && Cast.toBoolean(args.OPERAND2); + }; + + Scratch3OperatorsBlocks.prototype.or = function (args) { + return Cast.toBoolean(args.OPERAND1) || Cast.toBoolean(args.OPERAND2); + }; + + Scratch3OperatorsBlocks.prototype.not = function (args) { + return !Cast.toBoolean(args.OPERAND); + }; + + Scratch3OperatorsBlocks.prototype.random = function (args) { + var nFrom = Cast.toNumber(args.FROM); + var nTo = Cast.toNumber(args.TO); + var low = nFrom <= nTo ? nFrom : nTo; + var high = nFrom <= nTo ? nTo : nFrom; + if (low == high) return low; + // If both low and high are ints, truncate the result to an int. + var lowInt = low == parseInt(low); + var highInt = high == parseInt(high); + if (lowInt && highInt) { + return low + parseInt(Math.random() * ((high + 1) - low)); + } + return (Math.random() * (high - low)) + low; + }; + + Scratch3OperatorsBlocks.prototype.join = function (args) { + return Cast.toString(args.STRING1) + Cast.toString(args.STRING2); + }; + + Scratch3OperatorsBlocks.prototype.letterOf = function (args) { + var index = Cast.toNumber(args.LETTER) - 1; + var str = Cast.toString(args.STRING); + // Out of bounds? + if (index < 0 || index >= str.length) { + return ''; + } + return str.charAt(index); + }; + + Scratch3OperatorsBlocks.prototype.length = function (args) { + return Cast.toString(args.STRING).length; + }; + + Scratch3OperatorsBlocks.prototype.mod = function (args) { + var n = Cast.toNumber(args.NUM1); + var modulus = Cast.toNumber(args.NUM2); + var result = n % modulus; + // Scratch mod is kept positive. + if (result / modulus < 0) result += modulus; + return result; + }; + + Scratch3OperatorsBlocks.prototype.round = function (args) { + return Math.round(Cast.toNumber(args.NUM)); + }; + + Scratch3OperatorsBlocks.prototype.mathop = function (args) { + var operator = Cast.toString(args.OPERATOR).toLowerCase(); + var n = Cast.toNumber(args.NUM); + switch (operator) { + case 'abs': return Math.abs(n); + case 'floor': return Math.floor(n); + case 'ceiling': return Math.ceil(n); + case 'sqrt': return Math.sqrt(n); + case 'sin': return Math.sin((Math.PI * n) / 180); + case 'cos': return Math.cos((Math.PI * n) / 180); + case 'tan': return Math.tan((Math.PI * n) / 180); + case 'asin': return (Math.asin(n) * 180) / Math.PI; + case 'acos': return (Math.acos(n) * 180) / Math.PI; + case 'atan': return (Math.atan(n) * 180) / Math.PI; + case 'ln': return Math.log(n); + case 'log': return Math.log(n) / Math.LN10; + case 'e ^': return Math.exp(n); + case '10 ^': return Math.pow(10, n); + } + return 0; + }; + + module.exports = Scratch3OperatorsBlocks; + + +/***/ }, +/* 32 */ +/***/ function(module, exports, __webpack_require__) { + + var Cast = __webpack_require__(13); + + function Scratch3SensingBlocks(runtime) { + /** + * The runtime instantiating this block package. + * @type {Runtime} + */ + this.runtime = runtime; + } + + /** + * Retrieve the block primitives implemented by this package. + * @return {Object.<string, Function>} Mapping of opcode to Function. + */ + Scratch3SensingBlocks.prototype.getPrimitives = function() { + return { + 'sensing_touchingcolor': this.touchingColor, + 'sensing_coloristouchingcolor': this.colorTouchingColor, + 'sensing_timer': this.getTimer, + 'sensing_resettimer': this.resetTimer, + 'sensing_mousex': this.getMouseX, + 'sensing_mousey': this.getMouseY, + 'sensing_mousedown': this.getMouseDown, + 'sensing_keypressed': this.getKeyPressed, + 'sensing_current': this.current + }; + }; + + Scratch3SensingBlocks.prototype.touchingColor = function (args, util) { + var color = Cast.toRgbColorList(args.COLOR); + return util.target.isTouchingColor(color); + }; + + Scratch3SensingBlocks.prototype.colorTouchingColor = function (args, util) { + var maskColor = Cast.toRgbColorList(args.COLOR); + var targetColor = Cast.toRgbColorList(args.COLOR2); + return util.target.colorIsTouchingColor(targetColor, maskColor); + }; + + Scratch3SensingBlocks.prototype.getTimer = function (args, util) { + return util.ioQuery('clock', 'projectTimer'); + }; + + Scratch3SensingBlocks.prototype.resetTimer = function (args, util) { + util.ioQuery('clock', 'resetProjectTimer'); + }; + + Scratch3SensingBlocks.prototype.getMouseX = function (args, util) { + return util.ioQuery('mouse', 'getX'); + }; + + Scratch3SensingBlocks.prototype.getMouseY = function (args, util) { + return util.ioQuery('mouse', 'getY'); + }; + + Scratch3SensingBlocks.prototype.getMouseDown = function (args, util) { + return util.ioQuery('mouse', 'getIsDown'); + }; + + Scratch3SensingBlocks.prototype.current = function (args) { + var menuOption = Cast.toString(args.CURRENTMENU).toLowerCase(); + var date = new Date(); + switch (menuOption) { + case 'year': return date.getFullYear(); + case 'month': return date.getMonth() + 1; // getMonth is zero-based + case 'date': return date.getDate(); + case 'dayofweek': return date.getDay() + 1; // getDay is zero-based, Sun=0 + case 'hour': return date.getHours(); + case 'minute': return date.getMinutes(); + case 'second': return date.getSeconds(); + } + return 0; + }; + + Scratch3SensingBlocks.prototype.getKeyPressed = function (args, util) { + return util.ioQuery('keyboard', 'getKeyIsDown', args.KEY_OPTION); + }; + + module.exports = Scratch3SensingBlocks; + + +/***/ }, +/* 33 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * @fileoverview + * Partial implementation of an SB2 JSON importer. + * Parses provided JSON and then generates all needed + * scratch-vm runtime structures. + */ + + var Blocks = __webpack_require__(34); + var Sprite = __webpack_require__(85); + var Color = __webpack_require__(14); + var uid = __webpack_require__(88); + var specMap = __webpack_require__(89); + + /** + * Top-level handler. Parse provided JSON, + * and process the top-level object (the stage object). + * @param {!string} json SB2-format JSON to load. + * @param {!Runtime} runtime Runtime object to load all structures into. + */ + function sb2import (json, runtime) { + parseScratchObject( + JSON.parse(json), + runtime, + true + ); + } + + /** + * Parse a single "Scratch object" and create all its in-memory VM objects. + * @param {!Object} object From-JSON "Scratch object:" sprite, stage, watcher. + * @param {!Runtime} runtime Runtime object to load all structures into. + * @param {boolean} topLevel Whether this is the top-level object (stage). + */ + function parseScratchObject (object, runtime, topLevel) { + if (!object.hasOwnProperty('objName')) { + // Watcher/monitor - skip this object until those are implemented in VM. + // @todo + return; + } + // Blocks container for this object. + var blocks = new Blocks(); + // @todo: For now, load all Scratch objects (stage/sprites) as a Sprite. + var sprite = new Sprite(blocks); + // Sprite/stage name from JSON. + if (object.hasOwnProperty('objName')) { + sprite.name = object.objName; + } + // Costumes from JSON. + if (object.hasOwnProperty('costumes')) { + for (var i = 0; i < object.costumes.length; i++) { + var costume = object.costumes[i]; + // @todo: Make sure all the relevant metadata is being pulled out. + sprite.costumes.push({ + skin: 'https://cdn.assets.scratch.mit.edu/internalapi/asset/' + + costume.baseLayerMD5 + '/get/', + name: costume.costumeName, + bitmapResolution: costume.bitmapResolution, + rotationCenterX: costume.rotationCenterX, + rotationCenterY: costume.rotationCenterY + }); + } + } + // If included, parse any and all scripts/blocks on the object. + if (object.hasOwnProperty('scripts')) { + parseScripts(object.scripts, blocks); + } + // Create the first clone, and load its run-state from JSON. + var target = sprite.createClone(); + // Add it to the runtime's list of targets. + runtime.targets.push(target); + if (object.scratchX) { + target.x = object.scratchX; + } + if (object.scratchY) { + target.y = object.scratchY; + } + if (object.direction) { + target.direction = object.direction; + } + if (object.scale) { + // SB2 stores as 1.0 = 100%; we use % in the VM. + target.size = object.scale * 100; + } + if (object.visible) { + target.visible = object.visible; + } + if (object.currentCostumeIndex) { + target.currentCostume = object.currentCostumeIndex; + } + target.isStage = topLevel; + // The stage will have child objects; recursively process them. + if (object.children) { + for (var j = 0; j < object.children.length; j++) { + parseScratchObject(object.children[j], runtime, false); + } + } + } + + /** + * Parse a Scratch object's scripts into VM blocks. + * This should only handle top-level scripts that include X, Y coordinates. + * @param {!Object} scripts Scripts object from SB2 JSON. + * @param {!Blocks} blocks Blocks object to load parsed blocks into. + */ + function parseScripts (scripts, blocks) { + for (var i = 0; i < scripts.length; i++) { + var script = scripts[i]; + var scriptX = script[0]; + var scriptY = script[1]; + var blockList = script[2]; + var parsedBlockList = parseBlockList(blockList); + if (parsedBlockList[0]) { + // Adjust script coordinates to account for + // larger block size in scratch-blocks. + // @todo: Determine more precisely the right formulas here. + parsedBlockList[0].x = scriptX * 1.1; + parsedBlockList[0].y = scriptY * 1.1; + parsedBlockList[0].topLevel = true; + parsedBlockList[0].parent = null; + } + // Flatten children and create add the blocks. + var convertedBlocks = flatten(parsedBlockList); + for (var j = 0; j < convertedBlocks.length; j++) { + blocks.createBlock(convertedBlocks[j]); + } + } + } + + /** + * Parse any list of blocks from SB2 JSON into a list of VM-format blocks. + * Could be used to parse a top-level script, + * a list of blocks in a branch (e.g., in forever), + * or a list of blocks in an argument (e.g., move [pick random...]). + * @param {Array.<Object>} blockList SB2 JSON-format block list. + * @return {Array.<Object>} Scratch VM-format block list. + */ + function parseBlockList (blockList) { + var resultingList = []; + var previousBlock = null; // For setting next. + for (var i = 0; i < blockList.length; i++) { + var block = blockList[i]; + var parsedBlock = parseBlock(block); + if (previousBlock) { + parsedBlock.parent = previousBlock.id; + previousBlock.next = parsedBlock.id; + } + previousBlock = parsedBlock; + resultingList.push(parsedBlock); + } + return resultingList; + } + + /** + * Flatten a block tree into a block list. + * Children are temporarily stored on the `block.children` property. + * @param {Array.<Object>} blocks list generated by `parseBlockList`. + * @return {Array.<Object>} Flattened list to be passed to `blocks.createBlock`. + */ + function flatten (blocks) { + var finalBlocks = []; + for (var i = 0; i < blocks.length; i++) { + var block = blocks[i]; + finalBlocks.push(block); + if (block.children) { + finalBlocks = finalBlocks.concat(flatten(block.children)); + } + delete block.children; + } + return finalBlocks; + } + + /** + * Parse a single SB2 JSON-formatted block and its children. + * @param {!Object} sb2block SB2 JSON-formatted block. + * @return {Object} Scratch VM format block. + */ + function parseBlock (sb2block) { + // First item in block object is the old opcode (e.g., 'forward:'). + var oldOpcode = sb2block[0]; + // Convert the block using the specMap. See sb2specmap.js. + if (!oldOpcode || !specMap[oldOpcode]) { + console.warn('Couldn\'t find SB2 block: ', oldOpcode); + return; + } + var blockMetadata = specMap[oldOpcode]; + // Block skeleton. + var activeBlock = { + id: uid(), // Generate a new block unique ID. + opcode: blockMetadata.opcode, // Converted, e.g. "motion_movesteps". + inputs: {}, // Inputs to this block and the blocks they point to. + fields: {}, // Fields on this block and their values. + next: null, // Next block. + shadow: false, // No shadow blocks in an SB2 by default. + children: [] // Store any generated children, flattened in `flatten`. + }; + // Look at the expected arguments in `blockMetadata.argMap.` + // The basic problem here is to turn positional SB2 arguments into + // non-positional named Scratch VM arguments. + for (var i = 0; i < blockMetadata.argMap.length; i++) { + var expectedArg = blockMetadata.argMap[i]; + var providedArg = sb2block[i + 1]; // (i = 0 is opcode) + // Whether the input is obscuring a shadow. + var shadowObscured = false; + // Positional argument is an input. + if (expectedArg.type == 'input') { + // Create a new block and input metadata. + var inputUid = uid(); + activeBlock.inputs[expectedArg.inputName] = { + name: expectedArg.inputName, + block: null, + shadow: null + }; + if (typeof providedArg == 'object' && providedArg) { + // Block or block list occupies the input. + var innerBlocks; + if (typeof providedArg[0] == 'object' && providedArg[0]) { + // Block list occupies the input. + innerBlocks = parseBlockList(providedArg); + } else { + // Single block occupies the input. + innerBlocks = [parseBlock(providedArg)]; + } + for (var j = 0; j < innerBlocks.length; j++) { + innerBlocks[j].parent = activeBlock.id; + } + // Obscures any shadow. + shadowObscured = true; + activeBlock.inputs[expectedArg.inputName].block = ( + innerBlocks[0].id + ); + activeBlock.children = ( + activeBlock.children.concat(innerBlocks) + ); + } + // Generate a shadow block to occupy the input. + if (!expectedArg.inputOp) { + // No editable shadow input; e.g., for a boolean. + continue; + } + // Each shadow has a field generated for it automatically. + // Value to be filled in the field. + var fieldValue = providedArg; + // Shadows' field names match the input name, except for these: + var fieldName = expectedArg.inputName; + if (expectedArg.inputOp == 'math_number' || + expectedArg.inputOp == 'math_whole_number' || + expectedArg.inputOp == 'math_positive_number' || + expectedArg.inputOp == 'math_integer' || + expectedArg.inputOp == 'math_angle') { + fieldName = 'NUM'; + // Fields are given Scratch 2.0 default values if obscured. + if (shadowObscured) { + fieldValue = 10; + } + } else if (expectedArg.inputOp == 'text') { + fieldName = 'TEXT'; + if (shadowObscured) { + fieldValue = ''; + } + } else if (expectedArg.inputOp == 'colour_picker') { + // Convert SB2 color to hex. + fieldValue = Color.decimalToHex(providedArg); + fieldName = 'COLOUR'; + if (shadowObscured) { + fieldValue = '#990000'; + } + } + var fields = {}; + fields[fieldName] = { + name: fieldName, + value: fieldValue + }; + activeBlock.children.push({ + id: inputUid, + opcode: expectedArg.inputOp, + inputs: {}, + fields: fields, + next: null, + topLevel: false, + parent: activeBlock.id, + shadow: true + }); + activeBlock.inputs[expectedArg.inputName].shadow = inputUid; + // If no block occupying the input, alias to the shadow. + if (!activeBlock.inputs[expectedArg.inputName].block) { + activeBlock.inputs[expectedArg.inputName].block = inputUid; + } + } else if (expectedArg.type == 'field') { + // Add as a field on this block. + activeBlock.fields[expectedArg.fieldName] = { + name: expectedArg.fieldName, + value: providedArg + }; + } + } + return activeBlock; + } + + module.exports = sb2import; + + +/***/ }, +/* 34 */ +/***/ function(module, exports, __webpack_require__) { + + var adapter = __webpack_require__(35); /** * @fileoverview @@ -1699,68 +5075,80 @@ return inputs; }; + /** + * Get the top-level script for a given block. + * @param {?string} id ID of block to query. + * @return {?string} ID of top-level script block. + */ + Blocks.prototype.getTopLevelScript = function (id) { + if (typeof this._blocks[id] === 'undefined') return null; + var block = this._blocks[id]; + while (block.parent !== null) { + block = this._blocks[block.parent]; + } + return block.id; + }; + // --------------------------------------------------------------------- /** * Create event listener for blocks. Handles validation and serves as a generic * adapter between the blocks and the runtime interface. + * @param {Object} e Blockly "block" event * @param {boolean} isFlyout If true, create a listener for flyout events. * @param {?Runtime} opt_runtime Optional runtime to forward click events to. - * @return {Function} A generated listener to attach to Blockly instance. */ - Blocks.prototype.generateBlockListener = function (isFlyout, opt_runtime) { - var instance = this; - /** - * The actual generated block listener. - * @param {Object} e Blockly "block" event - */ - return function (e) { - // Validate event - if (typeof e !== 'object') return; - if (typeof e.blockId !== 'string') return; + Blocks.prototype.blocklyListen = function (e, isFlyout, opt_runtime) { + // Validate event + if (typeof e !== 'object') return; + if (typeof e.blockId !== 'string') return; - // UI event: clicked scripts toggle in the runtime. - if (e.element === 'stackclick') { - if (opt_runtime) { - opt_runtime.toggleScript(e.blockId); - } + // UI event: clicked scripts toggle in the runtime. + if (e.element === 'stackclick') { + if (opt_runtime) { + opt_runtime.toggleScript(e.blockId); + } + return; + } + + // Block create/update/destroy + switch (e.type) { + case 'create': + var newBlocks = adapter(e); + // A create event can create many blocks. Add them all. + for (var i = 0; i < newBlocks.length; i++) { + this.createBlock(newBlocks[i], isFlyout); + } + break; + case 'change': + this.changeBlock({ + id: e.blockId, + element: e.element, + name: e.name, + value: e.newValue + }); + break; + case 'move': + this.moveBlock({ + id: e.blockId, + oldParent: e.oldParentId, + oldInput: e.oldInputName, + newParent: e.newParentId, + newInput: e.newInputName, + newCoordinate: e.newCoordinate + }); + break; + case 'delete': + // Don't accept delete events for shadow blocks being obscured. + if (this._blocks[e.blockId].shadow) { return; } - - // Block create/update/destroy - switch (e.type) { - case 'create': - var newBlocks = adapter(e); - // A create event can create many blocks. Add them all. - for (var i = 0; i < newBlocks.length; i++) { - instance.createBlock(newBlocks[i], isFlyout); - } - break; - case 'change': - instance.changeBlock({ - id: e.blockId, - element: e.element, - name: e.name, - value: e.newValue - }); - break; - case 'move': - instance.moveBlock({ - id: e.blockId, - oldParent: e.oldParentId, - oldInput: e.oldInputName, - newParent: e.newParentId, - newInput: e.newInputName - }); - break; - case 'delete': - instance.deleteBlock({ - id: e.blockId - }); - break; - } - }; + this.deleteBlock({ + id: e.blockId + }); + break; + } }; // --------------------------------------------------------------------- @@ -1771,9 +5159,13 @@ * @param {boolean} opt_isFlyoutBlock Whether the block is in the flyout. */ Blocks.prototype.createBlock = function (block, opt_isFlyoutBlock) { - // Create new block + // Does the block already exist? + // Could happen, e.g., for an unobscured shadow. + if (this._blocks.hasOwnProperty(block.id)) { + return; + } + // Create new block. this._blocks[block.id] = block; - // Push block id to scripts array. // Blocks are added as a top-level stack if they are marked as a top-block // (if they were top-level XML in the event) and if they are not @@ -1802,6 +5194,12 @@ * @param {!Object} e Blockly move event to be processed */ Blocks.prototype.moveBlock = function (e) { + // Move coordinate changes. + if (e.newCoordinate) { + this._blocks[e.id].x = e.newCoordinate.x; + this._blocks[e.id].y = e.newCoordinate.y; + } + // Remove from any old parent. if (e.oldParent !== undefined) { var oldParent = this._blocks[e.oldParent]; @@ -1813,6 +5211,7 @@ // This block was connected to the old parent's next connection. oldParent.next = null; } + this._blocks[e.id].parent = null; } // Has the block become a top-level block? @@ -1823,15 +5222,22 @@ this._deleteScript(e.id); // Otherwise, try to connect it in its new place. if (e.newInput !== undefined) { - // Moved to the new parent's input. + // Moved to the new parent's input. + // Don't obscure the shadow block. + var oldShadow = null; + if (this._blocks[e.newParent].inputs.hasOwnProperty(e.newInput)) { + oldShadow = this._blocks[e.newParent].inputs[e.newInput].shadow; + } this._blocks[e.newParent].inputs[e.newInput] = { name: e.newInput, - block: e.id + block: e.id, + shadow: oldShadow }; } else { // Moved to the new parent's next connection. this._blocks[e.newParent].next = e.id; } + this._blocks[e.id].parent = e.newParent; } }; @@ -1856,6 +5262,11 @@ if (block.inputs[input].block !== null) { this.deleteBlock({id: block.inputs[input].block}); } + // Delete obscured shadow blocks. + if (block.inputs[input].shadow !== null && + block.inputs[input].shadow !== block.inputs[input].block) { + this.deleteBlock({id: block.inputs[input].shadow}); + } } // Delete any script starting with this block. @@ -1867,6 +5278,70 @@ // --------------------------------------------------------------------- + /** + * Encode all of `this._blocks` as an XML string usable + * by a Blockly/scratch-blocks workspace. + * @return {string} String of XML representing this object's blocks. + */ + Blocks.prototype.toXML = function () { + var xmlString = '<xml xmlns="http://www.w3.org/1999/xhtml">'; + for (var i = 0; i < this._scripts.length; i++) { + xmlString += this.blockToXML(this._scripts[i]); + } + return xmlString + '</xml>'; + }; + + /** + * Recursively encode an individual block and its children + * into a Blockly/scratch-blocks XML string. + * @param {!string} blockId ID of block to encode. + * @return {string} String of XML representing this block and any children. + */ + Blocks.prototype.blockToXML = function (blockId) { + var block = this._blocks[blockId]; + // Encode properties of this block. + var tagName = (block.shadow) ? 'shadow' : 'block'; + var xy = (block.topLevel) ? + ' x="' + block.x +'"' + ' y="' + block.y +'"' : + ''; + var xmlString = ''; + xmlString += '<' + tagName + + ' id="' + block.id + '"' + + ' type="' + block.opcode + '"' + + xy + + '>'; + // Add any inputs on this block. + for (var input in block.inputs) { + var blockInput = block.inputs[input]; + // Only encode a value tag if the value input is occupied. + if (blockInput.block || blockInput.shadow) { + xmlString += '<value name="' + blockInput.name + '">'; + if (blockInput.block) { + xmlString += this.blockToXML(blockInput.block); + } + if (blockInput.shadow && blockInput.shadow != blockInput.block) { + // Obscured shadow. + xmlString += this.blockToXML(blockInput.shadow); + } + xmlString += '</value>'; + } + } + // Add any fields on this block. + for (var field in block.fields) { + var blockField = block.fields[field]; + xmlString += '<field name="' + blockField.name + '">' + + blockField.value + '</field>'; + } + // Add blocks connected to the next connection. + if (block.next) { + xmlString += '<next>' + this.blockToXML(block.next) + '</next>'; + } + xmlString += '</' + tagName + '>'; + return xmlString; + }; + + // --------------------------------------------------------------------- + /** * Helper to add a stack to `this._scripts`. * @param {?string} topBlockId ID of block that starts the script. @@ -1894,10 +5369,10 @@ /***/ }, -/* 11 */ +/* 35 */ /***/ function(module, exports, __webpack_require__) { - var html = __webpack_require__(12); + var html = __webpack_require__(36); /** * Adapter between block creation events and block representation which can be @@ -1930,7 +5405,7 @@ } var tagName = block.name.toLowerCase(); if (tagName == 'block' || tagName == 'shadow') { - domToBlock(block, blocks, true); + domToBlock(block, blocks, true, null); } } // Flatten blocks object into a list. @@ -1947,8 +5422,9 @@ * @param {Element} blockDOM DOM tree for an individual block. * @param {Object} blocks Collection of blocks to add to. * @param {Boolean} isTopBlock Whether blocks at this level are "top blocks." + * @param {?string} parent Parent block ID. */ - function domToBlock (blockDOM, blocks, isTopBlock) { + function domToBlock (blockDOM, blocks, isTopBlock, parent) { // Block skeleton. var block = { id: blockDOM.attribs.id, // Block ID @@ -1956,7 +5432,11 @@ inputs: {}, // Inputs to this block and the blocks they point to. fields: {}, // Fields on this block and their values. next: null, // Next block in the stack, if one exists. - topLevel: isTopBlock // If this block starts a stack. + topLevel: isTopBlock, // If this block starts a stack. + parent: parent, // Parent block ID, if available. + shadow: blockDOM.name == 'shadow', // If this represents a shadow/slot. + x: blockDOM.attribs.x, // X position of script, if top-level. + y: blockDOM.attribs.y // Y position of script, if top-level. }; // Add the block to the representation tree. @@ -2009,12 +5489,17 @@ case 'value': case 'statement': // Recursively generate block structure for input block. - domToBlock(childBlockNode, blocks, false); + domToBlock(childBlockNode, blocks, false, block.id); + if (childShadowNode && childBlockNode != childShadowNode) { + // Also generate the shadow block. + domToBlock(childShadowNode, blocks, false, block.id); + } // Link this block's input to the child block. var inputName = xmlChild.attribs.name; block.inputs[inputName] = { name: inputName, - block: childBlockNode.attribs.id + block: childBlockNode.attribs.id, + shadow: childShadowNode ? childShadowNode.attribs.id : null }; break; case 'next': @@ -2023,7 +5508,7 @@ continue; } // Recursively generate block structure for next block. - domToBlock(childBlockNode, blocks, false); + domToBlock(childBlockNode, blocks, false, block.id); // Link next block to this block. block.next = childBlockNode.attribs.id; break; @@ -2033,11 +5518,11 @@ /***/ }, -/* 12 */ +/* 36 */ /***/ function(module, exports, __webpack_require__) { - var Parser = __webpack_require__(13), - DomHandler = __webpack_require__(20); + var Parser = __webpack_require__(37), + DomHandler = __webpack_require__(44); function defineProp(name, value){ delete module.exports[name]; @@ -2047,26 +5532,26 @@ module.exports = { Parser: Parser, - Tokenizer: __webpack_require__(14), - ElementType: __webpack_require__(21), + Tokenizer: __webpack_require__(38), + ElementType: __webpack_require__(45), DomHandler: DomHandler, get FeedHandler(){ - return defineProp("FeedHandler", __webpack_require__(24)); + return defineProp("FeedHandler", __webpack_require__(48)); }, get Stream(){ - return defineProp("Stream", __webpack_require__(25)); + return defineProp("Stream", __webpack_require__(49)); }, get WritableStream(){ - return defineProp("WritableStream", __webpack_require__(26)); + return defineProp("WritableStream", __webpack_require__(50)); }, get ProxyHandler(){ - return defineProp("ProxyHandler", __webpack_require__(47)); + return defineProp("ProxyHandler", __webpack_require__(71)); }, get DomUtils(){ - return defineProp("DomUtils", __webpack_require__(48)); + return defineProp("DomUtils", __webpack_require__(72)); }, get CollectingHandler(){ - return defineProp("CollectingHandler", __webpack_require__(60)); + return defineProp("CollectingHandler", __webpack_require__(84)); }, // For legacy support DefaultHandler: DomHandler, @@ -2107,10 +5592,10 @@ /***/ }, -/* 13 */ +/* 37 */ /***/ function(module, exports, __webpack_require__) { - var Tokenizer = __webpack_require__(14); + var Tokenizer = __webpack_require__(38); /* Options: @@ -2465,15 +5950,15 @@ /***/ }, -/* 14 */ +/* 38 */ /***/ function(module, exports, __webpack_require__) { module.exports = Tokenizer; - var decodeCodePoint = __webpack_require__(15), - entityMap = __webpack_require__(17), - legacyMap = __webpack_require__(18), - xmlMap = __webpack_require__(19), + var decodeCodePoint = __webpack_require__(39), + entityMap = __webpack_require__(41), + legacyMap = __webpack_require__(42), + xmlMap = __webpack_require__(43), i = 0, @@ -3377,10 +6862,10 @@ /***/ }, -/* 15 */ +/* 39 */ /***/ function(module, exports, __webpack_require__) { - var decodeMap = __webpack_require__(16); + var decodeMap = __webpack_require__(40); module.exports = decodeCodePoint; @@ -3409,7 +6894,7 @@ /***/ }, -/* 16 */ +/* 40 */ /***/ function(module, exports) { module.exports = { @@ -3444,7 +6929,7 @@ }; /***/ }, -/* 17 */ +/* 41 */ /***/ function(module, exports) { module.exports = { @@ -5576,7 +9061,7 @@ }; /***/ }, -/* 18 */ +/* 42 */ /***/ function(module, exports) { module.exports = { @@ -5689,7 +9174,7 @@ }; /***/ }, -/* 19 */ +/* 43 */ /***/ function(module, exports) { module.exports = { @@ -5701,14 +9186,14 @@ }; /***/ }, -/* 20 */ +/* 44 */ /***/ function(module, exports, __webpack_require__) { - var ElementType = __webpack_require__(21); + var ElementType = __webpack_require__(45); var re_whitespace = /\s+/g; - var NodePrototype = __webpack_require__(22); - var ElementPrototype = __webpack_require__(23); + var NodePrototype = __webpack_require__(46); + var ElementPrototype = __webpack_require__(47); function DomHandler(callback, options, elementCB){ if(typeof callback === "object"){ @@ -5889,7 +9374,7 @@ /***/ }, -/* 21 */ +/* 45 */ /***/ function(module, exports) { //Types of elements found in the DOM @@ -5910,7 +9395,7 @@ /***/ }, -/* 22 */ +/* 46 */ /***/ function(module, exports) { // This object will be used as the prototype for Nodes when creating a @@ -5960,11 +9445,11 @@ /***/ }, -/* 23 */ +/* 47 */ /***/ function(module, exports, __webpack_require__) { // DOM-Level-1-compliant structure - var NodePrototype = __webpack_require__(22); + var NodePrototype = __webpack_require__(46); var ElementPrototype = module.exports = Object.create(NodePrototype); var domLvl1 = { @@ -5986,10 +9471,10 @@ /***/ }, -/* 24 */ +/* 48 */ /***/ function(module, exports, __webpack_require__) { - var index = __webpack_require__(12), + var index = __webpack_require__(36), DomHandler = index.DomHandler, DomUtils = index.DomUtils; @@ -6087,12 +9572,12 @@ /***/ }, -/* 25 */ +/* 49 */ /***/ function(module, exports, __webpack_require__) { module.exports = Stream; - var Parser = __webpack_require__(26); + var Parser = __webpack_require__(50); function Stream(options){ Parser.call(this, new Cbs(this), options); @@ -6106,7 +9591,7 @@ this.scope = scope; } - var EVENTS = __webpack_require__(12).EVENTS; + var EVENTS = __webpack_require__(36).EVENTS; Object.keys(EVENTS).forEach(function(name){ if(EVENTS[name] === 0){ @@ -6127,13 +9612,13 @@ }); /***/ }, -/* 26 */ +/* 50 */ /***/ function(module, exports, __webpack_require__) { module.exports = Stream; - var Parser = __webpack_require__(13), - WritableStream = __webpack_require__(27).Writable || __webpack_require__(46).Writable; + var Parser = __webpack_require__(37), + WritableStream = __webpack_require__(51).Writable || __webpack_require__(70).Writable; function Stream(cbs, options){ var parser = this._parser = new Parser(cbs, options); @@ -6153,7 +9638,7 @@ }; /***/ }, -/* 27 */ +/* 51 */ /***/ function(module, exports, __webpack_require__) { // Copyright Joyent, Inc. and other Node contributors. @@ -6183,11 +9668,11 @@ var inherits = __webpack_require__(5); inherits(Stream, EE); - Stream.Readable = __webpack_require__(28); - Stream.Writable = __webpack_require__(42); - Stream.Duplex = __webpack_require__(43); - Stream.Transform = __webpack_require__(44); - Stream.PassThrough = __webpack_require__(45); + Stream.Readable = __webpack_require__(52); + Stream.Writable = __webpack_require__(66); + Stream.Duplex = __webpack_require__(67); + Stream.Transform = __webpack_require__(68); + Stream.PassThrough = __webpack_require__(69); // Backwards-compat with node 0.4.x Stream.Stream = Stream; @@ -6286,24 +9771,24 @@ /***/ }, -/* 28 */ +/* 52 */ /***/ function(module, exports, __webpack_require__) { - /* WEBPACK VAR INJECTION */(function(process) {exports = module.exports = __webpack_require__(29); - exports.Stream = __webpack_require__(27); + /* WEBPACK VAR INJECTION */(function(process) {exports = module.exports = __webpack_require__(53); + exports.Stream = __webpack_require__(51); exports.Readable = exports; - exports.Writable = __webpack_require__(38); - exports.Duplex = __webpack_require__(37); - exports.Transform = __webpack_require__(40); - exports.PassThrough = __webpack_require__(41); + exports.Writable = __webpack_require__(62); + exports.Duplex = __webpack_require__(61); + exports.Transform = __webpack_require__(64); + exports.PassThrough = __webpack_require__(65); if (!process.browser && process.env.READABLE_STREAM === 'disable') { - module.exports = __webpack_require__(27); + module.exports = __webpack_require__(51); } /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3))) /***/ }, -/* 29 */ +/* 53 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors. @@ -6330,12 +9815,12 @@ module.exports = Readable; /*<replacement>*/ - var isArray = __webpack_require__(30); + var isArray = __webpack_require__(54); /*</replacement>*/ /*<replacement>*/ - var Buffer = __webpack_require__(31).Buffer; + var Buffer = __webpack_require__(55).Buffer; /*</replacement>*/ Readable.ReadableState = ReadableState; @@ -6348,10 +9833,10 @@ }; /*</replacement>*/ - var Stream = __webpack_require__(27); + var Stream = __webpack_require__(51); /*<replacement>*/ - var util = __webpack_require__(35); + var util = __webpack_require__(59); util.inherits = __webpack_require__(5); /*</replacement>*/ @@ -6359,7 +9844,7 @@ /*<replacement>*/ - var debug = __webpack_require__(36); + var debug = __webpack_require__(60); if (debug && debug.debuglog) { debug = debug.debuglog('stream'); } else { @@ -6371,7 +9856,7 @@ util.inherits(Readable, Stream); function ReadableState(options, stream) { - var Duplex = __webpack_require__(37); + var Duplex = __webpack_require__(61); options = options || {}; @@ -6432,14 +9917,14 @@ this.encoding = null; if (options.encoding) { if (!StringDecoder) - StringDecoder = __webpack_require__(39).StringDecoder; + StringDecoder = __webpack_require__(63).StringDecoder; this.decoder = new StringDecoder(options.encoding); this.encoding = options.encoding; } } function Readable(options) { - var Duplex = __webpack_require__(37); + var Duplex = __webpack_require__(61); if (!(this instanceof Readable)) return new Readable(options); @@ -6542,7 +10027,7 @@ // backwards compatibility. Readable.prototype.setEncoding = function(enc) { if (!StringDecoder) - StringDecoder = __webpack_require__(39).StringDecoder; + StringDecoder = __webpack_require__(63).StringDecoder; this._readableState.decoder = new StringDecoder(enc); this._readableState.encoding = enc; return this; @@ -7261,7 +10746,7 @@ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3))) /***/ }, -/* 30 */ +/* 54 */ /***/ function(module, exports) { module.exports = Array.isArray || function (arr) { @@ -7270,7 +10755,7 @@ /***/ }, -/* 31 */ +/* 55 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(Buffer, global) {/*! @@ -7283,16 +10768,13 @@ 'use strict' - var base64 = __webpack_require__(32) - var ieee754 = __webpack_require__(33) - var isArray = __webpack_require__(34) + var base64 = __webpack_require__(56) + var ieee754 = __webpack_require__(57) + var isArray = __webpack_require__(58) exports.Buffer = Buffer exports.SlowBuffer = SlowBuffer exports.INSPECT_MAX_BYTES = 50 - Buffer.poolSize = 8192 // not used by this implementation - - var rootParent = {} /** * If `Buffer.TYPED_ARRAY_SUPPORT`: @@ -7310,9 +10792,6 @@ * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. * - * - Safari 5-7 lacks support for changing the `Object.prototype.constructor` property - * on objects. - * * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. * * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of @@ -7325,14 +10804,16 @@ ? global.TYPED_ARRAY_SUPPORT : typedArraySupport() + /* + * Export kMaxLength after typed array support is determined. + */ + exports.kMaxLength = kMaxLength() + function typedArraySupport () { - function Bar () {} try { var arr = new Uint8Array(1) - arr.foo = function () { return 42 } - arr.constructor = Bar + arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} return arr.foo() === 42 && // typed array instances can be augmented - arr.constructor === Bar && // constructor can be set typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` } catch (e) { @@ -7346,184 +10827,252 @@ : 0x3fffffff } - /** - * Class: Buffer - * ============= - * - * The Buffer constructor returns instances of `Uint8Array` that are augmented - * with function properties for all the node `Buffer` API functions. We use - * `Uint8Array` so that square bracket notation works as expected -- it returns - * a single octet. - * - * By augmenting the instances, we can avoid modifying the `Uint8Array` - * prototype. - */ - function Buffer (arg) { - if (!(this instanceof Buffer)) { - // Avoid going through an ArgumentsAdaptorTrampoline in the common case. - if (arguments.length > 1) return new Buffer(arg, arguments[1]) - return new Buffer(arg) + function createBuffer (that, length) { + if (kMaxLength() < length) { + throw new RangeError('Invalid typed array length') + } + if (Buffer.TYPED_ARRAY_SUPPORT) { + // Return an augmented `Uint8Array` instance, for best performance + that = new Uint8Array(length) + that.__proto__ = Buffer.prototype + } else { + // Fallback: Return an object instance of the Buffer class + if (that === null) { + that = new Buffer(length) + } + that.length = length } - if (!Buffer.TYPED_ARRAY_SUPPORT) { - this.length = 0 - this.parent = undefined + return that + } + + /** + * The Buffer constructor returns instances of `Uint8Array` that have their + * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of + * `Uint8Array`, so the returned instances will have all the node `Buffer` methods + * and the `Uint8Array` methods. Square bracket notation works as expected -- it + * returns a single octet. + * + * The `Uint8Array` prototype remains unmodified. + */ + + function Buffer (arg, encodingOrOffset, length) { + if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) { + return new Buffer(arg, encodingOrOffset, length) } // Common case. if (typeof arg === 'number') { - return fromNumber(this, arg) + if (typeof encodingOrOffset === 'string') { + throw new Error( + 'If encoding is specified then the first argument must be a string' + ) + } + return allocUnsafe(this, arg) } - - // Slightly less common case. - if (typeof arg === 'string') { - return fromString(this, arg, arguments.length > 1 ? arguments[1] : 'utf8') - } - - // Unusual. - return fromObject(this, arg) + return from(this, arg, encodingOrOffset, length) } - function fromNumber (that, length) { - that = allocate(that, length < 0 ? 0 : checked(length) | 0) + Buffer.poolSize = 8192 // not used by this implementation + + // TODO: Legacy, not needed anymore. Remove in next major version. + Buffer._augment = function (arr) { + arr.__proto__ = Buffer.prototype + return arr + } + + function from (that, value, encodingOrOffset, length) { + if (typeof value === 'number') { + throw new TypeError('"value" argument must not be a number') + } + + if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { + return fromArrayBuffer(that, value, encodingOrOffset, length) + } + + if (typeof value === 'string') { + return fromString(that, value, encodingOrOffset) + } + + return fromObject(that, value) + } + + /** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer[, byteOffset[, length]]) + **/ + Buffer.from = function (value, encodingOrOffset, length) { + return from(null, value, encodingOrOffset, length) + } + + if (Buffer.TYPED_ARRAY_SUPPORT) { + Buffer.prototype.__proto__ = Uint8Array.prototype + Buffer.__proto__ = Uint8Array + if (typeof Symbol !== 'undefined' && Symbol.species && + Buffer[Symbol.species] === Buffer) { + // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 + Object.defineProperty(Buffer, Symbol.species, { + value: null, + configurable: true + }) + } + } + + function assertSize (size) { + if (typeof size !== 'number') { + throw new TypeError('"size" argument must be a number') + } else if (size < 0) { + throw new RangeError('"size" argument must not be negative') + } + } + + function alloc (that, size, fill, encoding) { + assertSize(size) + if (size <= 0) { + return createBuffer(that, size) + } + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpretted as a start offset. + return typeof encoding === 'string' + ? createBuffer(that, size).fill(fill, encoding) + : createBuffer(that, size).fill(fill) + } + return createBuffer(that, size) + } + + /** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ + Buffer.alloc = function (size, fill, encoding) { + return alloc(null, size, fill, encoding) + } + + function allocUnsafe (that, size) { + assertSize(size) + that = createBuffer(that, size < 0 ? 0 : checked(size) | 0) if (!Buffer.TYPED_ARRAY_SUPPORT) { - for (var i = 0; i < length; i++) { + for (var i = 0; i < size; ++i) { that[i] = 0 } } return that } + /** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. + * */ + Buffer.allocUnsafe = function (size) { + return allocUnsafe(null, size) + } + /** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + */ + Buffer.allocUnsafeSlow = function (size) { + return allocUnsafe(null, size) + } + function fromString (that, string, encoding) { - if (typeof encoding !== 'string' || encoding === '') encoding = 'utf8' + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8' + } + + if (!Buffer.isEncoding(encoding)) { + throw new TypeError('"encoding" must be a valid string encoding') + } - // Assumption: byteLength() return value is always < kMaxLength. var length = byteLength(string, encoding) | 0 - that = allocate(that, length) + that = createBuffer(that, length) - that.write(string, encoding) - return that - } + var actual = that.write(string, encoding) - function fromObject (that, object) { - if (Buffer.isBuffer(object)) return fromBuffer(that, object) - - if (isArray(object)) return fromArray(that, object) - - if (object == null) { - throw new TypeError('must start with number, buffer, array or string') + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + that = that.slice(0, actual) } - if (typeof ArrayBuffer !== 'undefined') { - if (object.buffer instanceof ArrayBuffer) { - return fromTypedArray(that, object) - } - if (object instanceof ArrayBuffer) { - return fromArrayBuffer(that, object) - } - } - - if (object.length) return fromArrayLike(that, object) - - return fromJsonObject(that, object) - } - - function fromBuffer (that, buffer) { - var length = checked(buffer.length) | 0 - that = allocate(that, length) - buffer.copy(that, 0, 0, length) - return that - } - - function fromArray (that, array) { - var length = checked(array.length) | 0 - that = allocate(that, length) - for (var i = 0; i < length; i += 1) { - that[i] = array[i] & 255 - } - return that - } - - // Duplicate of fromArray() to keep fromArray() monomorphic. - function fromTypedArray (that, array) { - var length = checked(array.length) | 0 - that = allocate(that, length) - // Truncating the elements is probably not what people expect from typed - // arrays with BYTES_PER_ELEMENT > 1 but it's compatible with the behavior - // of the old Buffer constructor. - for (var i = 0; i < length; i += 1) { - that[i] = array[i] & 255 - } - return that - } - - function fromArrayBuffer (that, array) { - if (Buffer.TYPED_ARRAY_SUPPORT) { - // Return an augmented `Uint8Array` instance, for best performance - array.byteLength - that = Buffer._augment(new Uint8Array(array)) - } else { - // Fallback: Return an object instance of the Buffer class - that = fromTypedArray(that, new Uint8Array(array)) - } return that } function fromArrayLike (that, array) { - var length = checked(array.length) | 0 - that = allocate(that, length) + var length = array.length < 0 ? 0 : checked(array.length) | 0 + that = createBuffer(that, length) for (var i = 0; i < length; i += 1) { that[i] = array[i] & 255 } return that } - // Deserialize { type: 'Buffer', data: [1,2,3,...] } into a Buffer object. - // Returns a zero-length buffer for inputs that don't conform to the spec. - function fromJsonObject (that, object) { - var array - var length = 0 + function fromArrayBuffer (that, array, byteOffset, length) { + array.byteLength // this throws if `array` is not a valid ArrayBuffer - if (object.type === 'Buffer' && isArray(object.data)) { - array = object.data - length = checked(array.length) | 0 + if (byteOffset < 0 || array.byteLength < byteOffset) { + throw new RangeError('\'offset\' is out of bounds') } - that = allocate(that, length) - for (var i = 0; i < length; i += 1) { - that[i] = array[i] & 255 + if (array.byteLength < byteOffset + (length || 0)) { + throw new RangeError('\'length\' is out of bounds') } - return that - } - if (Buffer.TYPED_ARRAY_SUPPORT) { - Buffer.prototype.__proto__ = Uint8Array.prototype - Buffer.__proto__ = Uint8Array - } else { - // pre-set for values that may exist in the future - Buffer.prototype.length = undefined - Buffer.prototype.parent = undefined - } + if (byteOffset === undefined && length === undefined) { + array = new Uint8Array(array) + } else if (length === undefined) { + array = new Uint8Array(array, byteOffset) + } else { + array = new Uint8Array(array, byteOffset, length) + } - function allocate (that, length) { if (Buffer.TYPED_ARRAY_SUPPORT) { // Return an augmented `Uint8Array` instance, for best performance - that = Buffer._augment(new Uint8Array(length)) + that = array that.__proto__ = Buffer.prototype } else { // Fallback: Return an object instance of the Buffer class - that.length = length - that._isBuffer = true + that = fromArrayLike(that, array) } - - var fromPool = length !== 0 && length <= Buffer.poolSize >>> 1 - if (fromPool) that.parent = rootParent - return that } + function fromObject (that, obj) { + if (Buffer.isBuffer(obj)) { + var len = checked(obj.length) | 0 + that = createBuffer(that, len) + + if (that.length === 0) { + return that + } + + obj.copy(that, 0, 0, len) + return that + } + + if (obj) { + if ((typeof ArrayBuffer !== 'undefined' && + obj.buffer instanceof ArrayBuffer) || 'length' in obj) { + if (typeof obj.length !== 'number' || isnan(obj.length)) { + return createBuffer(that, 0) + } + return fromArrayLike(that, obj) + } + + if (obj.type === 'Buffer' && isArray(obj.data)) { + return fromArrayLike(that, obj.data) + } + } + + throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.') + } + function checked (length) { - // Note: cannot use `length < kMaxLength` here because that fails when + // Note: cannot use `length < kMaxLength()` here because that fails when // length is NaN (which is otherwise coerced to zero.) if (length >= kMaxLength()) { throw new RangeError('Attempt to allocate Buffer larger than maximum ' + @@ -7532,12 +11081,11 @@ return length | 0 } - function SlowBuffer (subject, encoding) { - if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding) - - var buf = new Buffer(subject, encoding) - delete buf.parent - return buf + function SlowBuffer (length) { + if (+length != length) { // eslint-disable-line eqeqeq + length = 0 + } + return Buffer.alloc(+length) } Buffer.isBuffer = function isBuffer (b) { @@ -7554,17 +11102,12 @@ var x = a.length var y = b.length - var i = 0 - var len = Math.min(x, y) - while (i < len) { - if (a[i] !== b[i]) break - - ++i - } - - if (i !== len) { - x = a[i] - y = b[i] + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i] + y = b[i] + break + } } if (x < y) return -1 @@ -7578,9 +11121,9 @@ case 'utf8': case 'utf-8': case 'ascii': + case 'latin1': case 'binary': case 'base64': - case 'raw': case 'ucs2': case 'ucs-2': case 'utf16le': @@ -7592,32 +11135,46 @@ } Buffer.concat = function concat (list, length) { - if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.') + if (!isArray(list)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } if (list.length === 0) { - return new Buffer(0) + return Buffer.alloc(0) } var i if (length === undefined) { length = 0 - for (i = 0; i < list.length; i++) { + for (i = 0; i < list.length; ++i) { length += list[i].length } } - var buf = new Buffer(length) + var buffer = Buffer.allocUnsafe(length) var pos = 0 - for (i = 0; i < list.length; i++) { - var item = list[i] - item.copy(buf, pos) - pos += item.length + for (i = 0; i < list.length; ++i) { + var buf = list[i] + if (!Buffer.isBuffer(buf)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + buf.copy(buffer, pos) + pos += buf.length } - return buf + return buffer } function byteLength (string, encoding) { - if (typeof string !== 'string') string = '' + string + if (Buffer.isBuffer(string)) { + return string.length + } + if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && + (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { + return string.byteLength + } + if (typeof string !== 'string') { + string = '' + string + } var len = string.length if (len === 0) return 0 @@ -7627,13 +11184,12 @@ for (;;) { switch (encoding) { case 'ascii': + case 'latin1': case 'binary': - // Deprecated - case 'raw': - case 'raws': return len case 'utf8': case 'utf-8': + case undefined: return utf8ToBytes(string).length case 'ucs2': case 'ucs-2': @@ -7656,13 +11212,39 @@ function slowToString (encoding, start, end) { var loweredCase = false - start = start | 0 - end = end === undefined || end === Infinity ? this.length : end | 0 + // No need to verify that "this.length <= MAX_UINT32" since it's a read-only + // property of a typed array. + + // This behaves neither like String nor Uint8Array in that we set start/end + // to their upper/lower bounds if the value passed is out of range. + // undefined is handled specially as per ECMA-262 6th Edition, + // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. + if (start === undefined || start < 0) { + start = 0 + } + // Return early if start > this.length. Done here to prevent potential uint32 + // coercion fail below. + if (start > this.length) { + return '' + } + + if (end === undefined || end > this.length) { + end = this.length + } + + if (end <= 0) { + return '' + } + + // Force coersion to uint32. This will also coerce falsey/NaN values to 0. + end >>>= 0 + start >>>= 0 + + if (end <= start) { + return '' + } if (!encoding) encoding = 'utf8' - if (start < 0) start = 0 - if (end > this.length) end = this.length - if (end <= start) return '' while (true) { switch (encoding) { @@ -7676,8 +11258,9 @@ case 'ascii': return asciiSlice(this, start, end) + case 'latin1': case 'binary': - return binarySlice(this, start, end) + return latin1Slice(this, start, end) case 'base64': return base64Slice(this, start, end) @@ -7696,6 +11279,53 @@ } } + // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect + // Buffer instances. + Buffer.prototype._isBuffer = true + + function swap (b, n, m) { + var i = b[n] + b[n] = b[m] + b[m] = i + } + + Buffer.prototype.swap16 = function swap16 () { + var len = this.length + if (len % 2 !== 0) { + throw new RangeError('Buffer size must be a multiple of 16-bits') + } + for (var i = 0; i < len; i += 2) { + swap(this, i, i + 1) + } + return this + } + + Buffer.prototype.swap32 = function swap32 () { + var len = this.length + if (len % 4 !== 0) { + throw new RangeError('Buffer size must be a multiple of 32-bits') + } + for (var i = 0; i < len; i += 4) { + swap(this, i, i + 3) + swap(this, i + 1, i + 2) + } + return this + } + + Buffer.prototype.swap64 = function swap64 () { + var len = this.length + if (len % 8 !== 0) { + throw new RangeError('Buffer size must be a multiple of 64-bits') + } + for (var i = 0; i < len; i += 8) { + swap(this, i, i + 7) + swap(this, i + 1, i + 6) + swap(this, i + 2, i + 5) + swap(this, i + 3, i + 4) + } + return this + } + Buffer.prototype.toString = function toString () { var length = this.length | 0 if (length === 0) return '' @@ -7719,63 +11349,197 @@ return '<Buffer ' + str + '>' } - Buffer.prototype.compare = function compare (b) { - if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') - if (this === b) return 0 - return Buffer.compare(this, b) + Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { + if (!Buffer.isBuffer(target)) { + throw new TypeError('Argument must be a Buffer') + } + + if (start === undefined) { + start = 0 + } + if (end === undefined) { + end = target ? target.length : 0 + } + if (thisStart === undefined) { + thisStart = 0 + } + if (thisEnd === undefined) { + thisEnd = this.length + } + + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError('out of range index') + } + + if (thisStart >= thisEnd && start >= end) { + return 0 + } + if (thisStart >= thisEnd) { + return -1 + } + if (start >= end) { + return 1 + } + + start >>>= 0 + end >>>= 0 + thisStart >>>= 0 + thisEnd >>>= 0 + + if (this === target) return 0 + + var x = thisEnd - thisStart + var y = end - start + var len = Math.min(x, y) + + var thisCopy = this.slice(thisStart, thisEnd) + var targetCopy = target.slice(start, end) + + for (var i = 0; i < len; ++i) { + if (thisCopy[i] !== targetCopy[i]) { + x = thisCopy[i] + y = targetCopy[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 } - Buffer.prototype.indexOf = function indexOf (val, byteOffset) { - if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff - else if (byteOffset < -0x80000000) byteOffset = -0x80000000 - byteOffset >>= 0 + // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, + // OR the last index of `val` in `buffer` at offset <= `byteOffset`. + // + // Arguments: + // - buffer - a Buffer to search + // - val - a string, Buffer, or number + // - byteOffset - an index into `buffer`; will be clamped to an int32 + // - encoding - an optional encoding, relevant is val is a string + // - dir - true for indexOf, false for lastIndexOf + function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1 - if (this.length === 0) return -1 - if (byteOffset >= this.length) return -1 + // Normalize byteOffset + if (typeof byteOffset === 'string') { + encoding = byteOffset + byteOffset = 0 + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff + } else if (byteOffset < -0x80000000) { + byteOffset = -0x80000000 + } + byteOffset = +byteOffset // Coerce to Number. + if (isNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : (buffer.length - 1) + } - // Negative offsets start from the end of the buffer - if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0) + // Normalize byteOffset: negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = buffer.length + byteOffset + if (byteOffset >= buffer.length) { + if (dir) return -1 + else byteOffset = buffer.length - 1 + } else if (byteOffset < 0) { + if (dir) byteOffset = 0 + else return -1 + } + // Normalize val if (typeof val === 'string') { - if (val.length === 0) return -1 // special case: looking for empty string always fails - return String.prototype.indexOf.call(this, val, byteOffset) - } - if (Buffer.isBuffer(val)) { - return arrayIndexOf(this, val, byteOffset) - } - if (typeof val === 'number') { - if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') { - return Uint8Array.prototype.indexOf.call(this, val, byteOffset) - } - return arrayIndexOf(this, [ val ], byteOffset) + val = Buffer.from(val, encoding) } - function arrayIndexOf (arr, val, byteOffset) { - var foundIndex = -1 - for (var i = 0; byteOffset + i < arr.length; i++) { - if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) { - if (foundIndex === -1) foundIndex = i - if (i - foundIndex + 1 === val.length) return byteOffset + foundIndex + // Finally, search either indexOf (if dir is true) or lastIndexOf + if (Buffer.isBuffer(val)) { + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1 + } + return arrayIndexOf(buffer, val, byteOffset, encoding, dir) + } else if (typeof val === 'number') { + val = val & 0xFF // Search for a byte value [0-255] + if (Buffer.TYPED_ARRAY_SUPPORT && + typeof Uint8Array.prototype.indexOf === 'function') { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) } else { - foundIndex = -1 + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) } } - return -1 + return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) } throw new TypeError('val must be string, number or Buffer') } - // `get` is deprecated - Buffer.prototype.get = function get (offset) { - console.log('.get() is deprecated. Access using array indexes instead.') - return this.readUInt8(offset) + function arrayIndexOf (arr, val, byteOffset, encoding, dir) { + var indexSize = 1 + var arrLength = arr.length + var valLength = val.length + + if (encoding !== undefined) { + encoding = String(encoding).toLowerCase() + if (encoding === 'ucs2' || encoding === 'ucs-2' || + encoding === 'utf16le' || encoding === 'utf-16le') { + if (arr.length < 2 || val.length < 2) { + return -1 + } + indexSize = 2 + arrLength /= 2 + valLength /= 2 + byteOffset /= 2 + } + } + + function read (buf, i) { + if (indexSize === 1) { + return buf[i] + } else { + return buf.readUInt16BE(i * indexSize) + } + } + + var i + if (dir) { + var foundIndex = -1 + for (i = byteOffset; i < arrLength; i++) { + if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { + if (foundIndex === -1) foundIndex = i + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize + } else { + if (foundIndex !== -1) i -= i - foundIndex + foundIndex = -1 + } + } + } else { + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength + for (i = byteOffset; i >= 0; i--) { + var found = true + for (var j = 0; j < valLength; j++) { + if (read(arr, i + j) !== read(val, j)) { + found = false + break + } + } + if (found) return i + } + } + + return -1 } - // `set` is deprecated - Buffer.prototype.set = function set (v, offset) { - console.log('.set() is deprecated. Access using array indexes instead.') - return this.writeUInt8(v, offset) + Buffer.prototype.includes = function includes (val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1 + } + + Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true) + } + + Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false) } function hexWrite (buf, string, offset, length) { @@ -7792,14 +11556,14 @@ // must be an even number of digits var strLen = string.length - if (strLen % 2 !== 0) throw new Error('Invalid hex string') + if (strLen % 2 !== 0) throw new TypeError('Invalid hex string') if (length > strLen / 2) { length = strLen / 2 } - for (var i = 0; i < length; i++) { + for (var i = 0; i < length; ++i) { var parsed = parseInt(string.substr(i * 2, 2), 16) - if (isNaN(parsed)) throw new Error('Invalid hex string') + if (isNaN(parsed)) return i buf[offset + i] = parsed } return i @@ -7813,7 +11577,7 @@ return blitBuffer(asciiToBytes(string), buf, offset, length) } - function binaryWrite (buf, string, offset, length) { + function latin1Write (buf, string, offset, length) { return asciiWrite(buf, string, offset, length) } @@ -7848,17 +11612,16 @@ } // legacy write(string, encoding, offset, length) - remove in v0.13 } else { - var swap = encoding - encoding = offset - offset = length | 0 - length = swap + throw new Error( + 'Buffer.write(string, encoding, offset[, length]) is no longer supported' + ) } var remaining = this.length - offset if (length === undefined || length > remaining) length = remaining if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { - throw new RangeError('attempt to write outside buffer bounds') + throw new RangeError('Attempt to write outside buffer bounds') } if (!encoding) encoding = 'utf8' @@ -7876,8 +11639,9 @@ case 'ascii': return asciiWrite(this, string, offset, length) + case 'latin1': case 'binary': - return binaryWrite(this, string, offset, length) + return latin1Write(this, string, offset, length) case 'base64': // Warning: maxLength not taken into account in base64Write @@ -8012,17 +11776,17 @@ var ret = '' end = Math.min(buf.length, end) - for (var i = start; i < end; i++) { + for (var i = start; i < end; ++i) { ret += String.fromCharCode(buf[i] & 0x7F) } return ret } - function binarySlice (buf, start, end) { + function latin1Slice (buf, start, end) { var ret = '' end = Math.min(buf.length, end) - for (var i = start; i < end; i++) { + for (var i = start; i < end; ++i) { ret += String.fromCharCode(buf[i]) } return ret @@ -8035,7 +11799,7 @@ if (!end || end < 0 || end > len) end = len var out = '' - for (var i = start; i < end; i++) { + for (var i = start; i < end; ++i) { out += toHex(buf[i]) } return out @@ -8073,17 +11837,16 @@ var newBuf if (Buffer.TYPED_ARRAY_SUPPORT) { - newBuf = Buffer._augment(this.subarray(start, end)) + newBuf = this.subarray(start, end) + newBuf.__proto__ = Buffer.prototype } else { var sliceLen = end - start newBuf = new Buffer(sliceLen, undefined) - for (var i = 0; i < sliceLen; i++) { + for (var i = 0; i < sliceLen; ++i) { newBuf[i] = this[i + start] } } - if (newBuf.length) newBuf.parent = this.parent || this - return newBuf } @@ -8252,16 +12015,19 @@ } function checkInt (buf, value, offset, ext, max, min) { - if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance') - if (value > max || value < min) throw new RangeError('value is out of bounds') - if (offset + ext > buf.length) throw new RangeError('index out of range') + if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') + if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') + if (offset + ext > buf.length) throw new RangeError('Index out of range') } Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { value = +value offset = offset | 0 byteLength = byteLength | 0 - if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0) + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } var mul = 1 var i = 0 @@ -8277,7 +12043,10 @@ value = +value offset = offset | 0 byteLength = byteLength | 0 - if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0) + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } var i = byteLength - 1 var mul = 1 @@ -8300,7 +12069,7 @@ function objectWriteUInt16 (buf, value, offset, littleEndian) { if (value < 0) value = 0xffff + value + 1 - for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) { + for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) { buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> (littleEndian ? i : 1 - i) * 8 } @@ -8334,7 +12103,7 @@ function objectWriteUInt32 (buf, value, offset, littleEndian) { if (value < 0) value = 0xffffffff + value + 1 - for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) { + for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) { buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff } } @@ -8380,9 +12149,12 @@ var i = 0 var mul = 1 - var sub = value < 0 ? 1 : 0 + var sub = 0 this[offset] = value & 0xFF while (++i < byteLength && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { + sub = 1 + } this[offset + i] = ((value / mul) >> 0) - sub & 0xFF } @@ -8400,9 +12172,12 @@ var i = byteLength - 1 var mul = 1 - var sub = value < 0 ? 1 : 0 + var sub = 0 this[offset + i] = value & 0xFF while (--i >= 0 && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { + sub = 1 + } this[offset + i] = ((value / mul) >> 0) - sub & 0xFF } @@ -8477,9 +12252,8 @@ } function checkIEEE754 (buf, value, offset, ext, max, min) { - if (value > max || value < min) throw new RangeError('value is out of bounds') - if (offset + ext > buf.length) throw new RangeError('index out of range') - if (offset < 0) throw new RangeError('index out of range') + if (offset + ext > buf.length) throw new RangeError('Index out of range') + if (offset < 0) throw new RangeError('Index out of range') } function writeFloat (buf, value, offset, littleEndian, noAssert) { @@ -8544,143 +12318,91 @@ if (this === target && start < targetStart && targetStart < end) { // descending copy from end - for (i = len - 1; i >= 0; i--) { + for (i = len - 1; i >= 0; --i) { target[i + targetStart] = this[i + start] } } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { // ascending copy from start - for (i = 0; i < len; i++) { + for (i = 0; i < len; ++i) { target[i + targetStart] = this[i + start] } } else { - target._set(this.subarray(start, start + len), targetStart) + Uint8Array.prototype.set.call( + target, + this.subarray(start, start + len), + targetStart + ) } return len } - // fill(value, start=0, end=buffer.length) - Buffer.prototype.fill = function fill (value, start, end) { - if (!value) value = 0 - if (!start) start = 0 - if (!end) end = this.length + // Usage: + // buffer.fill(number[, offset[, end]]) + // buffer.fill(buffer[, offset[, end]]) + // buffer.fill(string[, offset[, end]][, encoding]) + Buffer.prototype.fill = function fill (val, start, end, encoding) { + // Handle string cases: + if (typeof val === 'string') { + if (typeof start === 'string') { + encoding = start + start = 0 + end = this.length + } else if (typeof end === 'string') { + encoding = end + end = this.length + } + if (val.length === 1) { + var code = val.charCodeAt(0) + if (code < 256) { + val = code + } + } + if (encoding !== undefined && typeof encoding !== 'string') { + throw new TypeError('encoding must be a string') + } + if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + } else if (typeof val === 'number') { + val = val & 255 + } - if (end < start) throw new RangeError('end < start') + // Invalid ranges are not set to a default, so can range check early. + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError('Out of range index') + } - // Fill 0 bytes; we're done - if (end === start) return - if (this.length === 0) return + if (end <= start) { + return this + } - if (start < 0 || start >= this.length) throw new RangeError('start out of bounds') - if (end < 0 || end > this.length) throw new RangeError('end out of bounds') + start = start >>> 0 + end = end === undefined ? this.length : end >>> 0 + + if (!val) val = 0 var i - if (typeof value === 'number') { - for (i = start; i < end; i++) { - this[i] = value + if (typeof val === 'number') { + for (i = start; i < end; ++i) { + this[i] = val } } else { - var bytes = utf8ToBytes(value.toString()) + var bytes = Buffer.isBuffer(val) + ? val + : utf8ToBytes(new Buffer(val, encoding).toString()) var len = bytes.length - for (i = start; i < end; i++) { - this[i] = bytes[i % len] + for (i = 0; i < end - start; ++i) { + this[i + start] = bytes[i % len] } } return this } - /** - * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance. - * Added in Node 0.12. Only available in browsers that support ArrayBuffer. - */ - Buffer.prototype.toArrayBuffer = function toArrayBuffer () { - if (typeof Uint8Array !== 'undefined') { - if (Buffer.TYPED_ARRAY_SUPPORT) { - return (new Buffer(this)).buffer - } else { - var buf = new Uint8Array(this.length) - for (var i = 0, len = buf.length; i < len; i += 1) { - buf[i] = this[i] - } - return buf.buffer - } - } else { - throw new TypeError('Buffer.toArrayBuffer not supported in this browser') - } - } - // HELPER FUNCTIONS // ================ - var BP = Buffer.prototype - - /** - * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods - */ - Buffer._augment = function _augment (arr) { - arr.constructor = Buffer - arr._isBuffer = true - - // save reference to original Uint8Array set method before overwriting - arr._set = arr.set - - // deprecated - arr.get = BP.get - arr.set = BP.set - - arr.write = BP.write - arr.toString = BP.toString - arr.toLocaleString = BP.toString - arr.toJSON = BP.toJSON - arr.equals = BP.equals - arr.compare = BP.compare - arr.indexOf = BP.indexOf - arr.copy = BP.copy - arr.slice = BP.slice - arr.readUIntLE = BP.readUIntLE - arr.readUIntBE = BP.readUIntBE - arr.readUInt8 = BP.readUInt8 - arr.readUInt16LE = BP.readUInt16LE - arr.readUInt16BE = BP.readUInt16BE - arr.readUInt32LE = BP.readUInt32LE - arr.readUInt32BE = BP.readUInt32BE - arr.readIntLE = BP.readIntLE - arr.readIntBE = BP.readIntBE - arr.readInt8 = BP.readInt8 - arr.readInt16LE = BP.readInt16LE - arr.readInt16BE = BP.readInt16BE - arr.readInt32LE = BP.readInt32LE - arr.readInt32BE = BP.readInt32BE - arr.readFloatLE = BP.readFloatLE - arr.readFloatBE = BP.readFloatBE - arr.readDoubleLE = BP.readDoubleLE - arr.readDoubleBE = BP.readDoubleBE - arr.writeUInt8 = BP.writeUInt8 - arr.writeUIntLE = BP.writeUIntLE - arr.writeUIntBE = BP.writeUIntBE - arr.writeUInt16LE = BP.writeUInt16LE - arr.writeUInt16BE = BP.writeUInt16BE - arr.writeUInt32LE = BP.writeUInt32LE - arr.writeUInt32BE = BP.writeUInt32BE - arr.writeIntLE = BP.writeIntLE - arr.writeIntBE = BP.writeIntBE - arr.writeInt8 = BP.writeInt8 - arr.writeInt16LE = BP.writeInt16LE - arr.writeInt16BE = BP.writeInt16BE - arr.writeInt32LE = BP.writeInt32LE - arr.writeInt32BE = BP.writeInt32BE - arr.writeFloatLE = BP.writeFloatLE - arr.writeFloatBE = BP.writeFloatBE - arr.writeDoubleLE = BP.writeDoubleLE - arr.writeDoubleBE = BP.writeDoubleBE - arr.fill = BP.fill - arr.inspect = BP.inspect - arr.toArrayBuffer = BP.toArrayBuffer - - return arr - } - var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g function base64clean (str) { @@ -8712,7 +12434,7 @@ var leadSurrogate = null var bytes = [] - for (var i = 0; i < length; i++) { + for (var i = 0; i < length; ++i) { codePoint = string.charCodeAt(i) // is surrogate component @@ -8787,7 +12509,7 @@ function asciiToBytes (str) { var byteArray = [] - for (var i = 0; i < str.length; i++) { + for (var i = 0; i < str.length; ++i) { // Node's code seems to be doing this and not & 0x7F.. byteArray.push(str.charCodeAt(i) & 0xFF) } @@ -8797,7 +12519,7 @@ function utf16leToBytes (str, units) { var c, hi, lo var byteArray = [] - for (var i = 0; i < str.length; i++) { + for (var i = 0; i < str.length; ++i) { if ((units -= 2) < 0) break c = str.charCodeAt(i) @@ -8815,147 +12537,136 @@ } function blitBuffer (src, dst, offset, length) { - for (var i = 0; i < length; i++) { + for (var i = 0; i < length; ++i) { if ((i + offset >= dst.length) || (i >= src.length)) break dst[i + offset] = src[i] } return i } - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(31).Buffer, (function() { return this; }()))) + function isnan (val) { + return val !== val // eslint-disable-line no-self-compare + } + + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(55).Buffer, (function() { return this; }()))) /***/ }, -/* 32 */ -/***/ function(module, exports, __webpack_require__) { +/* 56 */ +/***/ function(module, exports) { - var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + 'use strict' - ;(function (exports) { - 'use strict'; + exports.toByteArray = toByteArray + exports.fromByteArray = fromByteArray - var Arr = (typeof Uint8Array !== 'undefined') - ? Uint8Array - : Array + var lookup = [] + var revLookup = [] + var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array - var PLUS = '+'.charCodeAt(0) - var SLASH = '/'.charCodeAt(0) - var NUMBER = '0'.charCodeAt(0) - var LOWER = 'a'.charCodeAt(0) - var UPPER = 'A'.charCodeAt(0) - var PLUS_URL_SAFE = '-'.charCodeAt(0) - var SLASH_URL_SAFE = '_'.charCodeAt(0) + function init () { + var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' + for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i] + revLookup[code.charCodeAt(i)] = i + } - function decode (elt) { - var code = elt.charCodeAt(0) - if (code === PLUS || - code === PLUS_URL_SAFE) - return 62 // '+' - if (code === SLASH || - code === SLASH_URL_SAFE) - return 63 // '/' - if (code < NUMBER) - return -1 //no match - if (code < NUMBER + 10) - return code - NUMBER + 26 + 26 - if (code < UPPER + 26) - return code - UPPER - if (code < LOWER + 26) - return code - LOWER + 26 - } + revLookup['-'.charCodeAt(0)] = 62 + revLookup['_'.charCodeAt(0)] = 63 + } - function b64ToByteArray (b64) { - var i, j, l, tmp, placeHolders, arr + init() - if (b64.length % 4 > 0) { - throw new Error('Invalid string. Length must be a multiple of 4') - } + function toByteArray (b64) { + var i, j, l, tmp, placeHolders, arr + var len = b64.length - // the number of equal signs (place holders) - // if there are two placeholders, than the two characters before it - // represent one byte - // if there is only one, then the three characters before it represent 2 bytes - // this is just a cheap hack to not do indexOf twice - var len = b64.length - placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0 + if (len % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } - // base64 is 4/3 + up to two characters of the original data - arr = new Arr(b64.length * 3 / 4 - placeHolders) + // the number of equal signs (place holders) + // if there are two placeholders, than the two characters before it + // represent one byte + // if there is only one, then the three characters before it represent 2 bytes + // this is just a cheap hack to not do indexOf twice + placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 - // if there are placeholders, only get up to the last complete 4 chars - l = placeHolders > 0 ? b64.length - 4 : b64.length + // base64 is 4/3 + up to two characters of the original data + arr = new Arr(len * 3 / 4 - placeHolders) - var L = 0 + // if there are placeholders, only get up to the last complete 4 chars + l = placeHolders > 0 ? len - 4 : len - function push (v) { - arr[L++] = v - } + var L = 0 - for (i = 0, j = 0; i < l; i += 4, j += 3) { - tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3)) - push((tmp & 0xFF0000) >> 16) - push((tmp & 0xFF00) >> 8) - push(tmp & 0xFF) - } + for (i = 0, j = 0; i < l; i += 4, j += 3) { + tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] + arr[L++] = (tmp >> 16) & 0xFF + arr[L++] = (tmp >> 8) & 0xFF + arr[L++] = tmp & 0xFF + } - if (placeHolders === 2) { - tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4) - push(tmp & 0xFF) - } else if (placeHolders === 1) { - tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2) - push((tmp >> 8) & 0xFF) - push(tmp & 0xFF) - } + if (placeHolders === 2) { + tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) + arr[L++] = tmp & 0xFF + } else if (placeHolders === 1) { + tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) + arr[L++] = (tmp >> 8) & 0xFF + arr[L++] = tmp & 0xFF + } - return arr - } + return arr + } - function uint8ToBase64 (uint8) { - var i, - extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes - output = "", - temp, length + function tripletToBase64 (num) { + return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] + } - function encode (num) { - return lookup.charAt(num) - } + function encodeChunk (uint8, start, end) { + var tmp + var output = [] + for (var i = start; i < end; i += 3) { + tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) + output.push(tripletToBase64(tmp)) + } + return output.join('') + } - function tripletToBase64 (num) { - return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F) - } + function fromByteArray (uint8) { + var tmp + var len = uint8.length + var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes + var output = '' + var parts = [] + var maxChunkLength = 16383 // must be multiple of 3 - // go through the array every three bytes, we'll deal with trailing stuff later - for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) { - temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) - output += tripletToBase64(temp) - } + // go through the array every three bytes, we'll deal with trailing stuff later + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) + } - // pad the end with zeros, but make sure to not forget the extra bytes - switch (extraBytes) { - case 1: - temp = uint8[uint8.length - 1] - output += encode(temp >> 2) - output += encode((temp << 4) & 0x3F) - output += '==' - break - case 2: - temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]) - output += encode(temp >> 10) - output += encode((temp >> 4) & 0x3F) - output += encode((temp << 2) & 0x3F) - output += '=' - break - } + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = uint8[len - 1] + output += lookup[tmp >> 2] + output += lookup[(tmp << 4) & 0x3F] + output += '==' + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + (uint8[len - 1]) + output += lookup[tmp >> 10] + output += lookup[(tmp >> 4) & 0x3F] + output += lookup[(tmp << 2) & 0x3F] + output += '=' + } - return output - } + parts.push(output) - exports.toByteArray = b64ToByteArray - exports.fromByteArray = uint8ToBase64 - }( false ? (this.base64js = {}) : exports)) + return parts.join('') + } /***/ }, -/* 33 */ +/* 57 */ /***/ function(module, exports) { exports.read = function (buffer, offset, isLE, mLen, nBytes) { @@ -9045,7 +12756,7 @@ /***/ }, -/* 34 */ +/* 58 */ /***/ function(module, exports) { var toString = {}.toString; @@ -9056,7 +12767,7 @@ /***/ }, -/* 35 */ +/* 59 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(Buffer) {// Copyright Joyent, Inc. and other Node contributors. @@ -9167,16 +12878,16 @@ return Object.prototype.toString.call(o); } - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(31).Buffer)) + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(55).Buffer)) /***/ }, -/* 36 */ +/* 60 */ /***/ function(module, exports) { /* (ignored) */ /***/ }, -/* 37 */ +/* 61 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors. @@ -9217,12 +12928,12 @@ /*<replacement>*/ - var util = __webpack_require__(35); + var util = __webpack_require__(59); util.inherits = __webpack_require__(5); /*</replacement>*/ - var Readable = __webpack_require__(29); - var Writable = __webpack_require__(38); + var Readable = __webpack_require__(53); + var Writable = __webpack_require__(62); util.inherits(Duplex, Readable); @@ -9272,7 +12983,7 @@ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3))) /***/ }, -/* 38 */ +/* 62 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors. @@ -9303,18 +13014,18 @@ module.exports = Writable; /*<replacement>*/ - var Buffer = __webpack_require__(31).Buffer; + var Buffer = __webpack_require__(55).Buffer; /*</replacement>*/ Writable.WritableState = WritableState; /*<replacement>*/ - var util = __webpack_require__(35); + var util = __webpack_require__(59); util.inherits = __webpack_require__(5); /*</replacement>*/ - var Stream = __webpack_require__(27); + var Stream = __webpack_require__(51); util.inherits(Writable, Stream); @@ -9325,7 +13036,7 @@ } function WritableState(options, stream) { - var Duplex = __webpack_require__(37); + var Duplex = __webpack_require__(61); options = options || {}; @@ -9413,7 +13124,7 @@ } function Writable(options) { - var Duplex = __webpack_require__(37); + var Duplex = __webpack_require__(61); // Writable ctor is applied to Duplexes, though they're not // instanceof Writable, they're instanceof Readable. @@ -9756,7 +13467,7 @@ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3))) /***/ }, -/* 39 */ +/* 63 */ /***/ function(module, exports, __webpack_require__) { // Copyright Joyent, Inc. and other Node contributors. @@ -9780,7 +13491,7 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - var Buffer = __webpack_require__(31).Buffer; + var Buffer = __webpack_require__(55).Buffer; var isBufferEncoding = Buffer.isEncoding || function(encoding) { @@ -9983,7 +13694,7 @@ /***/ }, -/* 40 */ +/* 64 */ /***/ function(module, exports, __webpack_require__) { // Copyright Joyent, Inc. and other Node contributors. @@ -10052,10 +13763,10 @@ module.exports = Transform; - var Duplex = __webpack_require__(37); + var Duplex = __webpack_require__(61); /*<replacement>*/ - var util = __webpack_require__(35); + var util = __webpack_require__(59); util.inherits = __webpack_require__(5); /*</replacement>*/ @@ -10198,7 +13909,7 @@ /***/ }, -/* 41 */ +/* 65 */ /***/ function(module, exports, __webpack_require__) { // Copyright Joyent, Inc. and other Node contributors. @@ -10228,10 +13939,10 @@ module.exports = PassThrough; - var Transform = __webpack_require__(40); + var Transform = __webpack_require__(64); /*<replacement>*/ - var util = __webpack_require__(35); + var util = __webpack_require__(59); util.inherits = __webpack_require__(5); /*</replacement>*/ @@ -10250,41 +13961,41 @@ /***/ }, -/* 42 */ +/* 66 */ /***/ function(module, exports, __webpack_require__) { - module.exports = __webpack_require__(38) + module.exports = __webpack_require__(62) /***/ }, -/* 43 */ +/* 67 */ /***/ function(module, exports, __webpack_require__) { - module.exports = __webpack_require__(37) + module.exports = __webpack_require__(61) /***/ }, -/* 44 */ +/* 68 */ /***/ function(module, exports, __webpack_require__) { - module.exports = __webpack_require__(40) + module.exports = __webpack_require__(64) /***/ }, -/* 45 */ +/* 69 */ /***/ function(module, exports, __webpack_require__) { - module.exports = __webpack_require__(41) + module.exports = __webpack_require__(65) /***/ }, -/* 46 */ +/* 70 */ /***/ function(module, exports) { /* (ignored) */ /***/ }, -/* 47 */ +/* 71 */ /***/ function(module, exports, __webpack_require__) { module.exports = ProxyHandler; @@ -10293,7 +14004,7 @@ this._cbs = cbs || {}; } - var EVENTS = __webpack_require__(12).EVENTS; + var EVENTS = __webpack_require__(36).EVENTS; Object.keys(EVENTS).forEach(function(name){ if(EVENTS[name] === 0){ name = "on" + name; @@ -10316,18 +14027,18 @@ }); /***/ }, -/* 48 */ +/* 72 */ /***/ function(module, exports, __webpack_require__) { var DomUtils = module.exports; [ - __webpack_require__(49), - __webpack_require__(55), - __webpack_require__(56), - __webpack_require__(57), - __webpack_require__(58), - __webpack_require__(59) + __webpack_require__(73), + __webpack_require__(79), + __webpack_require__(80), + __webpack_require__(81), + __webpack_require__(82), + __webpack_require__(83) ].forEach(function(ext){ Object.keys(ext).forEach(function(key){ DomUtils[key] = ext[key].bind(DomUtils); @@ -10336,11 +14047,11 @@ /***/ }, -/* 49 */ +/* 73 */ /***/ function(module, exports, __webpack_require__) { - var ElementType = __webpack_require__(21), - getOuterHTML = __webpack_require__(50), + var ElementType = __webpack_require__(45), + getOuterHTML = __webpack_require__(74), isTag = ElementType.isTag; module.exports = { @@ -10364,14 +14075,14 @@ /***/ }, -/* 50 */ +/* 74 */ /***/ function(module, exports, __webpack_require__) { /* Module dependencies */ - var ElementType = __webpack_require__(51); - var entities = __webpack_require__(52); + var ElementType = __webpack_require__(75); + var entities = __webpack_require__(76); /* Boolean Attributes @@ -10548,7 +14259,7 @@ /***/ }, -/* 51 */ +/* 75 */ /***/ function(module, exports) { //Types of elements found in the DOM @@ -10567,11 +14278,11 @@ }; /***/ }, -/* 52 */ +/* 76 */ /***/ function(module, exports, __webpack_require__) { - var encode = __webpack_require__(53), - decode = __webpack_require__(54); + var encode = __webpack_require__(77), + decode = __webpack_require__(78); exports.decode = function(data, level){ return (!level || level <= 0 ? decode.XML : decode.HTML)(data); @@ -10606,15 +14317,15 @@ /***/ }, -/* 53 */ +/* 77 */ /***/ function(module, exports, __webpack_require__) { - var inverseXML = getInverseObj(__webpack_require__(19)), + var inverseXML = getInverseObj(__webpack_require__(43)), xmlReplacer = getInverseReplacer(inverseXML); exports.XML = getInverse(inverseXML, xmlReplacer); - var inverseHTML = getInverseObj(__webpack_require__(17)), + var inverseHTML = getInverseObj(__webpack_require__(41)), htmlReplacer = getInverseReplacer(inverseHTML); exports.HTML = getInverse(inverseHTML, htmlReplacer); @@ -10685,13 +14396,13 @@ /***/ }, -/* 54 */ +/* 78 */ /***/ function(module, exports, __webpack_require__) { - var entityMap = __webpack_require__(17), - legacyMap = __webpack_require__(18), - xmlMap = __webpack_require__(19), - decodeCodePoint = __webpack_require__(15); + var entityMap = __webpack_require__(41), + legacyMap = __webpack_require__(42), + xmlMap = __webpack_require__(43), + decodeCodePoint = __webpack_require__(39); var decodeXMLStrict = getStrictDecoder(xmlMap), decodeHTMLStrict = getStrictDecoder(entityMap); @@ -10762,7 +14473,7 @@ }; /***/ }, -/* 55 */ +/* 79 */ /***/ function(module, exports) { var getChildren = exports.getChildren = function(elem){ @@ -10792,7 +14503,7 @@ /***/ }, -/* 56 */ +/* 80 */ /***/ function(module, exports) { exports.removeElement = function(elem){ @@ -10875,10 +14586,10 @@ /***/ }, -/* 57 */ +/* 81 */ /***/ function(module, exports, __webpack_require__) { - var isTag = __webpack_require__(21).isTag; + var isTag = __webpack_require__(45).isTag; module.exports = { filter: filter, @@ -10975,10 +14686,10 @@ /***/ }, -/* 58 */ +/* 82 */ /***/ function(module, exports, __webpack_require__) { - var ElementType = __webpack_require__(21); + var ElementType = __webpack_require__(45); var isTag = exports.isTag = ElementType.isTag; exports.testElement = function(options, element){ @@ -11068,7 +14779,7 @@ /***/ }, -/* 59 */ +/* 83 */ /***/ function(module, exports) { // removeSubsets @@ -11215,7 +14926,7 @@ /***/ }, -/* 60 */ +/* 84 */ /***/ function(module, exports, __webpack_require__) { module.exports = CollectingHandler; @@ -11225,7 +14936,7 @@ this.events = []; } - var EVENTS = __webpack_require__(12).EVENTS; + var EVENTS = __webpack_require__(36).EVENTS; Object.keys(EVENTS).forEach(function(name){ if(EVENTS[name] === 0){ name = "on" + name; @@ -11276,2391 +14987,1824 @@ /***/ }, -/* 61 */ +/* 85 */ /***/ function(module, exports, __webpack_require__) { - var EventEmitter = __webpack_require__(1); - var Sequencer = __webpack_require__(62); - var Thread = __webpack_require__(64); - var util = __webpack_require__(2); - - // Virtual I/O devices. - var Clock = __webpack_require__(66); - var Mouse = __webpack_require__(67); - - var defaultBlockPackages = { - 'scratch3_control': __webpack_require__(68), - 'scratch3_event': __webpack_require__(79), - 'scratch3_looks': __webpack_require__(80), - 'scratch3_motion': __webpack_require__(81), - 'scratch3_operators': __webpack_require__(82), - 'scratch3_sensing': __webpack_require__(84) - }; + var Clone = __webpack_require__(86); + var Blocks = __webpack_require__(34); /** - * Manages targets, scripts, and the sequencer. - * @param {!Array.<Target>} targets List of targets for this runtime. - */ - function Runtime (targets) { - // Bind event emitter - EventEmitter.call(this); - - // State for the runtime - - /** - * Target management and storage. - */ - this.targets = targets; - - /** - * A list of threads that are currently running in the VM. - * Threads are added when execution starts and pruned when execution ends. - * @type {Array.<Thread>} - */ - this.threads = []; - - /** @type {!Sequencer} */ - this.sequencer = new Sequencer(this); - - /** - * Map to look up a block primitive's implementation function by its opcode. - * This is a two-step lookup: package name first, then primitive name. - * @type {Object.<string, Function>} - */ - this._primitives = {}; - this._registerBlockPackages(); - - this.ioDevices = { - 'clock': new Clock(), - 'mouse': new Mouse() - }; - } - - /** - * Event name for glowing a stack - * @const {string} - */ - Runtime.STACK_GLOW_ON = 'STACK_GLOW_ON'; - - /** - * Event name for unglowing a stack - * @const {string} - */ - Runtime.STACK_GLOW_OFF = 'STACK_GLOW_OFF'; - - /** - * Event name for glowing a block - * @const {string} - */ - Runtime.BLOCK_GLOW_ON = 'BLOCK_GLOW_ON'; - - /** - * Event name for unglowing a block - * @const {string} - */ - Runtime.BLOCK_GLOW_OFF = 'BLOCK_GLOW_OFF'; - - /** - * Event name for visual value report. - * @const {string} - */ - Runtime.VISUAL_REPORT = 'VISUAL_REPORT'; - - /** - * Inherit from EventEmitter - */ - util.inherits(Runtime, EventEmitter); - - /** - * How rapidly we try to step threads, in ms. - */ - Runtime.THREAD_STEP_INTERVAL = 1000 / 60; - - - // ----------------------------------------------------------------------------- - // ----------------------------------------------------------------------------- - - /** - * Register default block packages with this runtime. - * @todo Prefix opcodes with package name. - * @private - */ - Runtime.prototype._registerBlockPackages = function () { - for (var packageName in defaultBlockPackages) { - if (defaultBlockPackages.hasOwnProperty(packageName)) { - // @todo pass a different runtime depending on package privilege? - var packageObject = new (defaultBlockPackages[packageName])(this); - var packageContents = packageObject.getPrimitives(); - for (var op in packageContents) { - if (packageContents.hasOwnProperty(op)) { - this._primitives[op] = - packageContents[op].bind(packageObject); - } - } - } - } - }; - - /** - * Retrieve the function associated with the given opcode. - * @param {!string} opcode The opcode to look up. - * @return {Function} The function which implements the opcode. - */ - Runtime.prototype.getOpcodeFunction = function (opcode) { - return this._primitives[opcode]; - }; - - // ----------------------------------------------------------------------------- - // ----------------------------------------------------------------------------- - - /** - * Create a thread and push it to the list of threads. - * @param {!string} id ID of block that starts the stack - */ - Runtime.prototype._pushThread = function (id) { - this.emit(Runtime.STACK_GLOW_ON, id); - var thread = new Thread(id); - thread.pushStack(id); - this.threads.push(thread); - }; - - /** - * Remove a thread from the list of threads. - * @param {?Thread} thread Thread object to remove from actives - */ - Runtime.prototype._removeThread = function (thread) { - var i = this.threads.indexOf(thread); - if (i > -1) { - this.emit(Runtime.STACK_GLOW_OFF, thread.topBlock); - this.threads.splice(i, 1); - } - }; - - /** - * Toggle a script. - * @param {!string} topBlockId ID of block that starts the script. - */ - Runtime.prototype.toggleScript = function (topBlockId) { - // Remove any existing thread. - for (var i = 0; i < this.threads.length; i++) { - if (this.threads[i].topBlock == topBlockId) { - this._removeThread(this.threads[i]); - return; - } - } - // Otherwise add it. - this._pushThread(topBlockId); - }; - - /** - * Green flag, which stops currently running threads - * and adds all top-level scripts that start with the green flag - */ - Runtime.prototype.greenFlag = function () { - // Remove all existing threads - for (var i = 0; i < this.threads.length; i++) { - this._removeThread(this.threads[i]); - } - // Add all top scripts with green flag - for (var t = 0; t < this.targets.length; t++) { - var target = this.targets[t]; - var scripts = target.blocks.getScripts(); - for (var j = 0; j < scripts.length; j++) { - var topBlock = scripts[j]; - if (target.blocks.getBlock(topBlock).opcode === - 'event_whenflagclicked') { - this._pushThread(scripts[j]); - } - } - } - }; - - /** - * Stop "everything" - */ - Runtime.prototype.stopAll = function () { - var threadsCopy = this.threads.slice(); - while (threadsCopy.length > 0) { - var poppedThread = threadsCopy.pop(); - // Unglow any blocks on this thread's stack. - for (var i = 0; i < poppedThread.stack.length; i++) { - this.glowBlock(poppedThread.stack[i], false); - } - // Actually remove the thread. - this._removeThread(poppedThread); - } - }; - - /** - * Repeatedly run `sequencer.stepThreads` and filter out - * inactive threads after each iteration. - */ - Runtime.prototype._step = function () { - var inactiveThreads = this.sequencer.stepThreads(this.threads); - for (var i = 0; i < inactiveThreads.length; i++) { - this._removeThread(inactiveThreads[i]); - } - }; - - /** - * Emit feedback for block glowing (used in the sequencer). - * @param {?string} blockId ID for the block to update glow - * @param {boolean} isGlowing True to turn on glow; false to turn off. - */ - Runtime.prototype.glowBlock = function (blockId, isGlowing) { - if (isGlowing) { - this.emit(Runtime.BLOCK_GLOW_ON, blockId); - } else { - this.emit(Runtime.BLOCK_GLOW_OFF, blockId); - } - }; - - /** - * Emit value for reporter to show in the blocks. - * @param {string} blockId ID for the block. - * @param {string} value Value to show associated with the block. - */ - Runtime.prototype.visualReport = function (blockId, value) { - this.emit(Runtime.VISUAL_REPORT, blockId, String(value)); - }; - - /** - * Return the Target for a particular thread. - * @param {!Thread} thread Thread to determine target for. - * @return {?Target} Target object, if one exists. - */ - Runtime.prototype.targetForThread = function (thread) { - // @todo This is a messy solution, - // but prevents having circular data references. - // Have a map or some other way to associate target with threads. - for (var t = 0; t < this.targets.length; t++) { - var target = this.targets[t]; - if (target.blocks.getBlock(thread.topBlock)) { - return target; - } - } - }; - - /** - * Handle an animation frame from the main thread. - */ - Runtime.prototype.animationFrame = function () { - if (self.renderer) { - self.renderer.draw(); - } - }; - - /** - * Set up timers to repeatedly step in a browser - */ - Runtime.prototype.start = function () { - self.setInterval(function() { - this._step(); - }.bind(this), Runtime.THREAD_STEP_INTERVAL); - }; - - module.exports = Runtime; - - -/***/ }, -/* 62 */ -/***/ function(module, exports, __webpack_require__) { - - var Timer = __webpack_require__(63); - var Thread = __webpack_require__(64); - var execute = __webpack_require__(65); - - function Sequencer (runtime) { - /** - * A utility timer for timing thread sequencing. - * @type {!Timer} - */ - this.timer = new Timer(); - - /** - * Reference to the runtime owning this sequencer. - * @type {!Runtime} - */ - this.runtime = runtime; - } - - /** - * The sequencer does as much work as it can within WORK_TIME milliseconds, - * then yields. This is essentially a rate-limiter for blocks. - * In Scratch 2.0, this is set to 75% of the target stage frame-rate (30fps). - * @const {!number} - */ - Sequencer.WORK_TIME = 10; - - /** - * Step through all threads in `this.threads`, running them in order. - * @param {Array.<Thread>} threads List of which threads to step. - * @return {Array.<Thread>} All threads which have finished in this iteration. - */ - Sequencer.prototype.stepThreads = function (threads) { - // Start counting toward WORK_TIME - this.timer.start(); - // List of threads which have been killed by this step. - var inactiveThreads = []; - // If all of the threads are yielding, we should yield. - var numYieldingThreads = 0; - // Clear all yield statuses that were for the previous frame. - for (var t = 0; t < threads.length; t++) { - if (threads[t].status === Thread.STATUS_YIELD_FRAME) { - threads[t].setStatus(Thread.STATUS_RUNNING); - } - } - - // While there are still threads to run and we are within WORK_TIME, - // continue executing threads. - while (threads.length > 0 && - threads.length > numYieldingThreads && - this.timer.timeElapsed() < Sequencer.WORK_TIME) { - // New threads at the end of the iteration. - var newThreads = []; - // Reset yielding thread count. - numYieldingThreads = 0; - // Attempt to run each thread one time - for (var i = 0; i < threads.length; i++) { - var activeThread = threads[i]; - if (activeThread.status === Thread.STATUS_RUNNING) { - // Normal-mode thread: step. - this.startThread(activeThread); - } else if (activeThread.status === Thread.STATUS_YIELD || - activeThread.status === Thread.STATUS_YIELD_FRAME) { - // Yielding thread: do nothing for this step. - numYieldingThreads++; - } - if (activeThread.stack.length === 0 && - activeThread.status === Thread.STATUS_DONE) { - // Finished with this thread - tell runtime to clean it up. - inactiveThreads.push(activeThread); - } else { - // Keep this thead in the loop. - newThreads.push(activeThread); - } - } - // Effectively filters out threads that have stopped. - threads = newThreads; - } - return inactiveThreads; - }; - - /** - * Step the requested thread - * @param {!Thread} thread Thread object to step - */ - Sequencer.prototype.startThread = function (thread) { - var currentBlockId = thread.peekStack(); - if (!currentBlockId) { - // A "null block" - empty branch. - // Yield for the frame. - thread.popStack(); - thread.setStatus(Thread.STATUS_YIELD_FRAME); - return; - } - // Execute the current block - execute(this, thread); - // If the block executed without yielding and without doing control flow, - // move to done. - if (thread.status === Thread.STATUS_RUNNING && - thread.peekStack() === currentBlockId) { - this.proceedThread(thread); - } - }; - - /** - * Step a thread into a block's branch. - * @param {!Thread} thread Thread object to step to branch. - * @param {Number} branchNum Which branch to step to (i.e., 1, 2). - */ - Sequencer.prototype.stepToBranch = function (thread, branchNum) { - if (!branchNum) { - branchNum = 1; - } - var currentBlockId = thread.peekStack(); - var branchId = this.runtime.targetForThread(thread).blocks.getBranch( - currentBlockId, - branchNum - ); - if (branchId) { - // Push branch ID to the thread's stack. - thread.pushStack(branchId); - } else { - // Push null, so we come back to the current block. - thread.pushStack(null); - } - }; - - /** - * Step a thread into an input reporter, and manage its status appropriately. - * @param {!Thread} thread Thread object to step to reporter. - * @param {!string} blockId ID of reporter block. - * @param {!string} inputName Name of input on parent block. - * @return {boolean} True if yielded, false if it finished immediately. - */ - Sequencer.prototype.stepToReporter = function (thread, blockId, inputName) { - var currentStackFrame = thread.peekStackFrame(); - // Push to the stack to evaluate the reporter block. - thread.pushStack(blockId); - // Save name of input for `Thread.pushReportedValue`. - currentStackFrame.waitingReporter = inputName; - // Actually execute the block. - this.startThread(thread); - // If a reporter yielded, caller must wait for it to unyield. - // The value will be populated once the reporter unyields, - // and passed up to the currentStackFrame on next execution. - return thread.status === Thread.STATUS_YIELD; - }; - - /** - * Finish stepping a thread and proceed it to the next block. - * @param {!Thread} thread Thread object to proceed. - */ - Sequencer.prototype.proceedThread = function (thread) { - var currentBlockId = thread.peekStack(); - // Mark the status as done and proceed to the next block. - // Pop from the stack - finished this level of execution. - thread.popStack(); - // Push next connected block, if there is one. - var nextBlockId = (this.runtime.targetForThread(thread). - blocks.getNextBlock(currentBlockId)); - if (nextBlockId) { - thread.pushStack(nextBlockId); - } - // If we can't find a next block to run, mark the thread as done. - if (!thread.peekStack()) { - thread.setStatus(Thread.STATUS_DONE); - } - }; - - module.exports = Sequencer; - - -/***/ }, -/* 63 */ -/***/ function(module, exports) { - - /** - * Constructor - */ - function Timer () { - this.startTime = 0; - } - - Timer.prototype.time = function () { - return Date.now(); - }; - - Timer.prototype.start = function () { - this.startTime = this.time(); - }; - - Timer.prototype.timeElapsed = function () { - return this.time() - this.startTime; - }; - - module.exports = Timer; - - -/***/ }, -/* 64 */ -/***/ function(module, exports) { - - /** - * A thread is a running stack context and all the metadata needed. - * @param {?string} firstBlock First block to execute in the thread. + * Sprite to be used on the Scratch stage. + * All clones of a sprite have shared blocks, shared costumes, shared variables. + * @param {?Blocks} blocks Shared blocks object for all clones of sprite. * @constructor */ - function Thread (firstBlock) { + function Sprite (blocks) { + if (!blocks) { + // Shared set of blocks for all clones. + blocks = new Blocks(); + } + this.blocks = blocks; /** - * ID of top block of the thread - * @type {!string} + * Human-readable name for this sprite (and all clones). + * @type {string} */ - this.topBlock = firstBlock; - + this.name = ''; /** - * Stack for the thread. When the sequencer enters a control structure, - * the block is pushed onto the stack so we know where to exit. - * @type {Array.<string>} + * List of costumes for this sprite. + * Each entry is an object, e.g., + * { + * skin: "costume.svg", + * name: "Costume Name", + * bitmapResolution: 2, + * rotationCenterX: 0, + * rotationCenterY: 0 + * } + * @type {Array.<!Object>} */ - this.stack = []; - + this.costumes = []; /** - * Stack frames for the thread. Store metadata for the executing blocks. - * @type {Array.<Object>} + * List of clones for this sprite, including the original. + * @type {Array.<!Clone>} */ - this.stackFrames = []; - - /** - * Status of the thread, one of three states (below) - * @type {number} - */ - this.status = 0; /* Thread.STATUS_RUNNING */ + this.clones = []; } /** - * Thread status for initialized or running thread. - * This is the default state for a thread - execution should run normally, - * stepping from block to block. - * @const + * Create a clone of this sprite. + * @returns {!Clone} Newly created clone. */ - Thread.STATUS_RUNNING = 0; + Sprite.prototype.createClone = function () { + var newClone = new Clone(this); + this.clones.push(newClone); + return newClone; + }; + + module.exports = Sprite; + + +/***/ }, +/* 86 */ +/***/ function(module, exports, __webpack_require__) { + + var util = __webpack_require__(2); + var MathUtil = __webpack_require__(16); + var Target = __webpack_require__(87); /** - * Thread status for a yielded thread. - * Threads are in this state when a primitive has yielded; execution is paused - * until the relevant primitive unyields. - * @const + * Clone (instance) of a sprite. + * @param {!Sprite} sprite Reference to the sprite. + * @constructor */ - Thread.STATUS_YIELD = 1; + function Clone(sprite) { + Target.call(this, sprite.blocks); + /** + * Reference to the sprite that this is a clone of. + * @type {!Sprite} + */ + this.sprite = sprite; + /** + * Reference to the global renderer for this VM, if one exists. + * @type {?RenderWebGLWorker} + */ + this.renderer = null; + // If this is not true, there is no renderer (e.g., running in a test env). + if (typeof self !== 'undefined' && self.renderer) { + // Pull from `self.renderer`. + this.renderer = self.renderer; + } + /** + * ID of the drawable for this clone returned by the renderer, if rendered. + * @type {?Number} + */ + this.drawableID = null; + + this.initDrawable(); + } + util.inherits(Clone, Target); /** - * Thread status for a single-frame yield. - * @const + * Create a clone's drawable with the this.renderer. */ - Thread.STATUS_YIELD_FRAME = 2; - - /** - * Thread status for a finished/done thread. - * Thread is in this state when there are no more blocks to execute. - * @const - */ - Thread.STATUS_DONE = 3; - - /** - * Push stack and update stack frames appropriately. - * @param {string} blockId Block ID to push to stack. - */ - Thread.prototype.pushStack = function (blockId) { - this.stack.push(blockId); - // Push an empty stack frame, if we need one. - // Might not, if we just popped the stack. - if (this.stack.length > this.stackFrames.length) { - this.stackFrames.push({ - reported: {}, // Collects reported input values. - waitingReporter: null, // Name of waiting reporter. - executionContext: {} // A context passed to block implementations. + Clone.prototype.initDrawable = function () { + if (this.renderer) { + var createPromise = this.renderer.createDrawable(); + var instance = this; + createPromise.then(function (id) { + instance.drawableID = id; + // Once the drawable is created, send our current set of properties. + instance.updateAllDrawableProperties(); }); } }; + // Clone-level properties. /** - * Pop last block on the stack and its stack frame. - * @return {string} Block ID popped from the stack. + * Whether this clone represents the Scratch stage. + * @type {boolean} */ - Thread.prototype.popStack = function () { - this.stackFrames.pop(); - return this.stack.pop(); + Clone.prototype.isStage = false; + + /** + * Scratch X coordinate. Currently should range from -240 to 240. + * @type {Number} + */ + Clone.prototype.x = 0; + + /** + * Scratch Y coordinate. Currently should range from -180 to 180. + * @type {number} + */ + Clone.prototype.y = 0; + + /** + * Scratch direction. Currently should range from -179 to 180. + * @type {number} + */ + Clone.prototype.direction = 90; + + /** + * Whether the clone is currently visible. + * @type {boolean} + */ + Clone.prototype.visible = true; + + /** + * Size of clone as a percent of costume size. Ranges from 5% to 535%. + * @type {number} + */ + Clone.prototype.size = 100; + + /** + * Currently selected costume index. + * @type {number} + */ + Clone.prototype.currentCostume = 0; + + /** + * Map of current graphic effect values. + * @type {!Object.<string, number>} + */ + Clone.prototype.effects = { + 'color': 0, + 'fisheye': 0, + 'whirl': 0, + 'pixelate': 0, + 'mosaic': 0, + 'brightness': 0, + 'ghost': 0 }; + // End clone-level properties. /** - * Get top stack item. - * @return {?string} Block ID on top of stack. + * Set the X and Y coordinates of a clone. + * @param {!number} x New X coordinate of clone, in Scratch coordinates. + * @param {!number} y New Y coordinate of clone, in Scratch coordinates. */ - Thread.prototype.peekStack = function () { - return this.stack[this.stack.length - 1]; - }; - - - /** - * Get top stack frame. - * @return {?Object} Last stack frame stored on this thread. - */ - Thread.prototype.peekStackFrame = function () { - return this.stackFrames[this.stackFrames.length - 1]; - }; - - /** - * Get stack frame above the current top. - * @return {?Object} Second to last stack frame stored on this thread. - */ - Thread.prototype.peekParentStackFrame = function () { - return this.stackFrames[this.stackFrames.length - 2]; - }; - - /** - * Push a reported value to the parent of the current stack frame. - * @param {!Any} value Reported value to push. - */ - Thread.prototype.pushReportedValue = function (value) { - var parentStackFrame = this.peekParentStackFrame(); - if (parentStackFrame) { - var waitingReporter = parentStackFrame.waitingReporter; - parentStackFrame.reported[waitingReporter] = value; - parentStackFrame.waitingReporter = null; - } - }; - - /** - * Set thread status. - * @param {number} status Enum representing thread status. - */ - Thread.prototype.setStatus = function (status) { - this.status = status; - }; - - module.exports = Thread; - - -/***/ }, -/* 65 */ -/***/ function(module, exports, __webpack_require__) { - - var Thread = __webpack_require__(64); - - /** - * Execute a block. - * @param {!Sequencer} sequencer Which sequencer is executing. - * @param {!Thread} thread Thread which to read and execute. - */ - var execute = function (sequencer, thread) { - var runtime = sequencer.runtime; - var target = runtime.targetForThread(thread); - - // Current block to execute is the one on the top of the stack. - var currentBlockId = thread.peekStack(); - var currentStackFrame = thread.peekStackFrame(); - - var opcode = target.blocks.getOpcode(currentBlockId); - - if (!opcode) { - console.warn('Could not get opcode for block: ' + currentBlockId); + Clone.prototype.setXY = function (x, y) { + if (this.isStage) { return; } + this.x = x; + this.y = y; + if (this.renderer) { + this.renderer.updateDrawableProperties(this.drawableID, { + position: [this.x, this.y] + }); + } + }; - var blockFunction = runtime.getOpcodeFunction(opcode); - if (!blockFunction) { - console.warn('Could not get implementation for opcode: ' + opcode); + /** + * Set the direction of a clone. + * @param {!number} direction New direction of clone. + */ + Clone.prototype.setDirection = function (direction) { + if (this.isStage) { return; } - - // Generate values for arguments (inputs). - var argValues = {}; - - // Add all fields on this block to the argValues. - var fields = target.blocks.getFields(currentBlockId); - for (var fieldName in fields) { - argValues[fieldName] = fields[fieldName].value; - } - - // Recursively evaluate input blocks. - var inputs = target.blocks.getInputs(currentBlockId); - for (var inputName in inputs) { - var input = inputs[inputName]; - var inputBlockId = input.block; - // Is there no value for this input waiting in the stack frame? - if (typeof currentStackFrame.reported[inputName] === 'undefined') { - // If there's not, we need to evaluate the block. - var reporterYielded = ( - sequencer.stepToReporter(thread, inputBlockId, inputName) - ); - // If the reporter yielded, return immediately; - // it needs time to finish and report its value. - if (reporterYielded) { - return; - } - } - argValues[inputName] = currentStackFrame.reported[inputName]; - } - - // If we've gotten this far, all of the input blocks are evaluated, - // and `argValues` is fully populated. So, execute the block primitive. - // First, clear `currentStackFrame.reported`, so any subsequent execution - // (e.g., on return from a branch) gets fresh inputs. - currentStackFrame.reported = {}; - - var primitiveReportedValue = null; - primitiveReportedValue = blockFunction(argValues, { - yield: function() { - thread.setStatus(Thread.STATUS_YIELD); - }, - yieldFrame: function() { - thread.setStatus(Thread.STATUS_YIELD_FRAME); - }, - done: function() { - thread.setStatus(Thread.STATUS_RUNNING); - sequencer.proceedThread(thread); - }, - stackFrame: currentStackFrame.executionContext, - startBranch: function (branchNum) { - sequencer.stepToBranch(thread, branchNum); - }, - target: target, - ioQuery: function (device, func, args) { - // Find the I/O device and execute the query/function call. - if (runtime.ioDevices[device] && runtime.ioDevices[device][func]) { - var devObject = runtime.ioDevices[device]; - return devObject[func].call(devObject, args); - } - } - }); - - // Deal with any reported value. - // If it's a promise, wait until promise resolves. - var isPromise = ( - primitiveReportedValue && - primitiveReportedValue.then && - typeof primitiveReportedValue.then === 'function' - ); - if (isPromise) { - if (thread.status === Thread.STATUS_RUNNING) { - // Primitive returned a promise; automatically yield thread. - thread.setStatus(Thread.STATUS_YIELD); - } - // Promise handlers - primitiveReportedValue.then(function(resolvedValue) { - // Promise resolved: the primitive reported a value. - thread.pushReportedValue(resolvedValue); - // Report the value visually if necessary. - if (typeof resolvedValue !== 'undefined' && - thread.peekStack() === thread.topBlock) { - runtime.visualReport(thread.peekStack(), resolvedValue); - } - thread.setStatus(Thread.STATUS_RUNNING); - sequencer.proceedThread(thread); - }, function(rejectionReason) { - // Promise rejected: the primitive had some error. - // Log it and proceed. - console.warn('Primitive rejected promise: ', rejectionReason); - thread.setStatus(Thread.STATUS_RUNNING); - sequencer.proceedThread(thread); + // Keep direction between -179 and +180. + this.direction = MathUtil.wrapClamp(direction, -179, 180); + if (this.renderer) { + this.renderer.updateDrawableProperties(this.drawableID, { + direction: this.direction }); - } else if (thread.status === Thread.STATUS_RUNNING) { - thread.pushReportedValue(primitiveReportedValue); - // Report the value visually if necessary. - if (typeof primitiveReportedValue !== 'undefined' && - thread.peekStack() === thread.topBlock) { - runtime.visualReport(thread.peekStack(), primitiveReportedValue); - } } }; - module.exports = execute; - - -/***/ }, -/* 66 */ -/***/ function(module, exports, __webpack_require__) { - - var Timer = __webpack_require__(63); - - function Clock () { - this._projectTimer = new Timer(); - this._projectTimer.start(); - } - - Clock.prototype.projectTimer = function () { - return this._projectTimer.timeElapsed() / 1000; - }; - - Clock.prototype.resetProjectTimer = function () { - this._projectTimer.start(); - }; - - module.exports = Clock; - - -/***/ }, -/* 67 */ -/***/ function(module, exports, __webpack_require__) { - - var MathUtil = __webpack_require__(8); - - function Mouse () { - this._x = 0; - this._y = 0; - this._isDown = false; - } - - Mouse.prototype.postData = function(data) { - if (data.x) { - this._x = data.x; - } - if (data.y) { - this._y = data.y; - } - if (typeof data.isDown !== 'undefined') { - this._isDown = data.isDown; - } - }; - - Mouse.prototype.getX = function () { - return MathUtil.clamp(this._x, -240, 240); - }; - - Mouse.prototype.getY = function () { - return MathUtil.clamp(-this._y, -180, 180); - }; - - Mouse.prototype.getIsDown = function () { - return this._isDown; - }; - - module.exports = Mouse; - - -/***/ }, -/* 68 */ -/***/ function(module, exports, __webpack_require__) { - - var Promise = __webpack_require__(69); - - function Scratch3ControlBlocks(runtime) { - /** - * The runtime instantiating this block package. - * @type {Runtime} - */ - this.runtime = runtime; - } - /** - * Retrieve the block primitives implemented by this package. - * @return {Object.<string, Function>} Mapping of opcode to Function. + * Set a say bubble on this clone. + * @param {?string} type Type of say bubble: "say", "think", or null. + * @param {?string} message Message to put in say bubble. */ - Scratch3ControlBlocks.prototype.getPrimitives = function() { - return { - 'control_repeat': this.repeat, - 'control_repeat_until': this.repeatUntil, - 'control_forever': this.forever, - 'control_wait': this.wait, - 'control_if': this.if, - 'control_if_else': this.ifElse, - 'control_stop': this.stop - }; + Clone.prototype.setSay = function (type, message) { + if (this.isStage) { + return; + } + // @todo: Render to stage. + if (!type || !message) { + console.log('Clearing say bubble'); + return; + } + console.log('Setting say bubble:', type, message); }; - Scratch3ControlBlocks.prototype.repeat = function(args, util) { - // Initialize loop - if (util.stackFrame.loopCounter === undefined) { - util.stackFrame.loopCounter = parseInt(args.TIMES); - } - // Only execute once per frame. - // When the branch finishes, `repeat` will be executed again and - // the second branch will be taken, yielding for the rest of the frame. - if (!util.stackFrame.executedInFrame) { - util.stackFrame.executedInFrame = true; - // Decrease counter - util.stackFrame.loopCounter--; - // If we still have some left, start the branch. - if (util.stackFrame.loopCounter >= 0) { - util.startBranch(); - } - } else { - util.stackFrame.executedInFrame = false; - util.yieldFrame(); - } - }; - - Scratch3ControlBlocks.prototype.repeatUntil = function(args, util) { - // Only execute once per frame. - // When the branch finishes, `repeat` will be executed again and - // the second branch will be taken, yielding for the rest of the frame. - if (!util.stackFrame.executedInFrame) { - util.stackFrame.executedInFrame = true; - // If the condition is true, start the branch. - if (!args.CONDITION) { - util.startBranch(); - } - } else { - util.stackFrame.executedInFrame = false; - util.yieldFrame(); - } - }; - - Scratch3ControlBlocks.prototype.forever = function(args, util) { - // Only execute once per frame. - // When the branch finishes, `forever` will be executed again and - // the second branch will be taken, yielding for the rest of the frame. - if (!util.stackFrame.executedInFrame) { - util.stackFrame.executedInFrame = true; - util.startBranch(); - } else { - util.stackFrame.executedInFrame = false; - util.yieldFrame(); - } - }; - - Scratch3ControlBlocks.prototype.wait = function(args) { - return new Promise(function(resolve) { - setTimeout(function() { - resolve(); - }, 1000 * args.DURATION); - }); - }; - - Scratch3ControlBlocks.prototype.if = function(args, util) { - // Only execute one time. `if` will be returned to - // when the branch finishes, but it shouldn't execute again. - if (util.stackFrame.executedInFrame === undefined) { - util.stackFrame.executedInFrame = true; - if (args.CONDITION) { - util.startBranch(); - } - } - }; - - Scratch3ControlBlocks.prototype.ifElse = function(args, util) { - // Only execute one time. `ifElse` will be returned to - // when the branch finishes, but it shouldn't execute again. - if (util.stackFrame.executedInFrame === undefined) { - util.stackFrame.executedInFrame = true; - if (args.CONDITION) { - util.startBranch(1); - } else { - util.startBranch(2); - } - } - }; - - Scratch3ControlBlocks.prototype.stop = function() { - // @todo - don't use this.runtime - this.runtime.stopAll(); - }; - - module.exports = Scratch3ControlBlocks; - - -/***/ }, -/* 69 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - module.exports = __webpack_require__(70) - - -/***/ }, -/* 70 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - module.exports = __webpack_require__(71); - __webpack_require__(73); - __webpack_require__(74); - __webpack_require__(75); - __webpack_require__(76); - __webpack_require__(78); - - -/***/ }, -/* 71 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var asap = __webpack_require__(72); - - function noop() {} - - // States: - // - // 0 - pending - // 1 - fulfilled with _value - // 2 - rejected with _value - // 3 - adopted the state of another promise, _value - // - // once the state is no longer pending (0) it is immutable - - // All `_` prefixed properties will be reduced to `_{random number}` - // at build time to obfuscate them and discourage their use. - // We don't use symbols or Object.defineProperty to fully hide them - // because the performance isn't good enough. - - - // to avoid using try/catch inside critical functions, we - // extract them to here. - var LAST_ERROR = null; - var IS_ERROR = {}; - function getThen(obj) { - try { - return obj.then; - } catch (ex) { - LAST_ERROR = ex; - return IS_ERROR; - } - } - - function tryCallOne(fn, a) { - try { - return fn(a); - } catch (ex) { - LAST_ERROR = ex; - return IS_ERROR; - } - } - function tryCallTwo(fn, a, b) { - try { - fn(a, b); - } catch (ex) { - LAST_ERROR = ex; - return IS_ERROR; - } - } - - module.exports = Promise; - - function Promise(fn) { - if (typeof this !== 'object') { - throw new TypeError('Promises must be constructed via new'); - } - if (typeof fn !== 'function') { - throw new TypeError('not a function'); - } - this._45 = 0; - this._81 = 0; - this._65 = null; - this._54 = null; - if (fn === noop) return; - doResolve(fn, this); - } - Promise._10 = null; - Promise._97 = null; - Promise._61 = noop; - - Promise.prototype.then = function(onFulfilled, onRejected) { - if (this.constructor !== Promise) { - return safeThen(this, onFulfilled, onRejected); - } - var res = new Promise(noop); - handle(this, new Handler(onFulfilled, onRejected, res)); - return res; - }; - - function safeThen(self, onFulfilled, onRejected) { - return new self.constructor(function (resolve, reject) { - var res = new Promise(noop); - res.then(resolve, reject); - handle(self, new Handler(onFulfilled, onRejected, res)); - }); - }; - function handle(self, deferred) { - while (self._81 === 3) { - self = self._65; - } - if (Promise._10) { - Promise._10(self); - } - if (self._81 === 0) { - if (self._45 === 0) { - self._45 = 1; - self._54 = deferred; - return; - } - if (self._45 === 1) { - self._45 = 2; - self._54 = [self._54, deferred]; - return; - } - self._54.push(deferred); - return; - } - handleResolved(self, deferred); - } - - function handleResolved(self, deferred) { - asap(function() { - var cb = self._81 === 1 ? deferred.onFulfilled : deferred.onRejected; - if (cb === null) { - if (self._81 === 1) { - resolve(deferred.promise, self._65); - } else { - reject(deferred.promise, self._65); - } - return; - } - var ret = tryCallOne(cb, self._65); - if (ret === IS_ERROR) { - reject(deferred.promise, LAST_ERROR); - } else { - resolve(deferred.promise, ret); - } - }); - } - function resolve(self, newValue) { - // Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure - if (newValue === self) { - return reject( - self, - new TypeError('A promise cannot be resolved with itself.') - ); - } - if ( - newValue && - (typeof newValue === 'object' || typeof newValue === 'function') - ) { - var then = getThen(newValue); - if (then === IS_ERROR) { - return reject(self, LAST_ERROR); - } - if ( - then === self.then && - newValue instanceof Promise - ) { - self._81 = 3; - self._65 = newValue; - finale(self); - return; - } else if (typeof then === 'function') { - doResolve(then.bind(newValue), self); - return; - } - } - self._81 = 1; - self._65 = newValue; - finale(self); - } - - function reject(self, newValue) { - self._81 = 2; - self._65 = newValue; - if (Promise._97) { - Promise._97(self, newValue); - } - finale(self); - } - function finale(self) { - if (self._45 === 1) { - handle(self, self._54); - self._54 = null; - } - if (self._45 === 2) { - for (var i = 0; i < self._54.length; i++) { - handle(self, self._54[i]); - } - self._54 = null; - } - } - - function Handler(onFulfilled, onRejected, promise){ - this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null; - this.onRejected = typeof onRejected === 'function' ? onRejected : null; - this.promise = promise; - } - /** - * Take a potentially misbehaving resolver function and make sure - * onFulfilled and onRejected are only called once. - * - * Makes no guarantees about asynchrony. + * Set visibility of the clone; i.e., whether it's shown or hidden. + * @param {!boolean} visible True if the sprite should be shown. */ - function doResolve(fn, promise) { - var done = false; - var res = tryCallTwo(fn, function (value) { - if (done) return; - done = true; - resolve(promise, value); - }, function (reason) { - if (done) return; - done = true; - reject(promise, reason); - }) - if (!done && res === IS_ERROR) { - done = true; - reject(promise, LAST_ERROR); - } - } - - -/***/ }, -/* 72 */ -/***/ function(module, exports) { - - /* WEBPACK VAR INJECTION */(function(global) {"use strict"; - - // Use the fastest means possible to execute a task in its own turn, with - // priority over other events including IO, animation, reflow, and redraw - // events in browsers. - // - // An exception thrown by a task will permanently interrupt the processing of - // subsequent tasks. The higher level `asap` function ensures that if an - // exception is thrown by a task, that the task queue will continue flushing as - // soon as possible, but if you use `rawAsap` directly, you are responsible to - // either ensure that no exceptions are thrown from your task, or to manually - // call `rawAsap.requestFlush` if an exception is thrown. - module.exports = rawAsap; - function rawAsap(task) { - if (!queue.length) { - requestFlush(); - flushing = true; + Clone.prototype.setVisible = function (visible) { + if (this.isStage) { + return; } - // Equivalent to push, but avoids a function call. - queue[queue.length] = task; - } - - var queue = []; - // Once a flush has been requested, no further calls to `requestFlush` are - // necessary until the next `flush` completes. - var flushing = false; - // `requestFlush` is an implementation-specific method that attempts to kick - // off a `flush` event as quickly as possible. `flush` will attempt to exhaust - // the event queue before yielding to the browser's own event loop. - var requestFlush; - // The position of the next task to execute in the task queue. This is - // preserved between calls to `flush` so that it can be resumed if - // a task throws an exception. - var index = 0; - // If a task schedules additional tasks recursively, the task queue can grow - // unbounded. To prevent memory exhaustion, the task queue will periodically - // truncate already-completed tasks. - var capacity = 1024; - - // The flush function processes all tasks that have been scheduled with - // `rawAsap` unless and until one of those tasks throws an exception. - // If a task throws an exception, `flush` ensures that its state will remain - // consistent and will resume where it left off when called again. - // However, `flush` does not make any arrangements to be called again if an - // exception is thrown. - function flush() { - while (index < queue.length) { - var currentIndex = index; - // Advance the index before calling the task. This ensures that we will - // begin flushing on the next task the task throws an error. - index = index + 1; - queue[currentIndex].call(); - // Prevent leaking memory for long chains of recursive calls to `asap`. - // If we call `asap` within tasks scheduled by `asap`, the queue will - // grow, but to avoid an O(n) walk for every task we execute, we don't - // shift tasks off the queue after they have been executed. - // Instead, we periodically shift 1024 tasks off the queue. - if (index > capacity) { - // Manually shift all values starting at the index back to the - // beginning of the queue. - for (var scan = 0, newLength = queue.length - index; scan < newLength; scan++) { - queue[scan] = queue[scan + index]; - } - queue.length -= index; - index = 0; - } - } - queue.length = 0; - index = 0; - flushing = false; - } - - // `requestFlush` is implemented using a strategy based on data collected from - // every available SauceLabs Selenium web driver worker at time of writing. - // https://docs.google.com/spreadsheets/d/1mG-5UYGup5qxGdEMWkhP6BWCz053NUb2E1QoUTU16uA/edit#gid=783724593 - - // Safari 6 and 6.1 for desktop, iPad, and iPhone are the only browsers that - // have WebKitMutationObserver but not un-prefixed MutationObserver. - // Must use `global` instead of `window` to work in both frames and web - // workers. `global` is a provision of Browserify, Mr, Mrs, or Mop. - var BrowserMutationObserver = global.MutationObserver || global.WebKitMutationObserver; - - // MutationObservers are desirable because they have high priority and work - // reliably everywhere they are implemented. - // They are implemented in all modern browsers. - // - // - Android 4-4.3 - // - Chrome 26-34 - // - Firefox 14-29 - // - Internet Explorer 11 - // - iPad Safari 6-7.1 - // - iPhone Safari 7-7.1 - // - Safari 6-7 - if (typeof BrowserMutationObserver === "function") { - requestFlush = makeRequestCallFromMutationObserver(flush); - - // MessageChannels are desirable because they give direct access to the HTML - // task queue, are implemented in Internet Explorer 10, Safari 5.0-1, and Opera - // 11-12, and in web workers in many engines. - // Although message channels yield to any queued rendering and IO tasks, they - // would be better than imposing the 4ms delay of timers. - // However, they do not work reliably in Internet Explorer or Safari. - - // Internet Explorer 10 is the only browser that has setImmediate but does - // not have MutationObservers. - // Although setImmediate yields to the browser's renderer, it would be - // preferrable to falling back to setTimeout since it does not have - // the minimum 4ms penalty. - // Unfortunately there appears to be a bug in Internet Explorer 10 Mobile (and - // Desktop to a lesser extent) that renders both setImmediate and - // MessageChannel useless for the purposes of ASAP. - // https://github.com/kriskowal/q/issues/396 - - // Timers are implemented universally. - // We fall back to timers in workers in most engines, and in foreground - // contexts in the following browsers. - // However, note that even this simple case requires nuances to operate in a - // broad spectrum of browsers. - // - // - Firefox 3-13 - // - Internet Explorer 6-9 - // - iPad Safari 4.3 - // - Lynx 2.8.7 - } else { - requestFlush = makeRequestCallFromTimer(flush); - } - - // `requestFlush` requests that the high priority event queue be flushed as - // soon as possible. - // This is useful to prevent an error thrown in a task from stalling the event - // queue if the exception handled by Node.js’s - // `process.on("uncaughtException")` or by a domain. - rawAsap.requestFlush = requestFlush; - - // To request a high priority event, we induce a mutation observer by toggling - // the text of a text node between "1" and "-1". - function makeRequestCallFromMutationObserver(callback) { - var toggle = 1; - var observer = new BrowserMutationObserver(callback); - var node = document.createTextNode(""); - observer.observe(node, {characterData: true}); - return function requestCall() { - toggle = -toggle; - node.data = toggle; - }; - } - - // The message channel technique was discovered by Malte Ubl and was the - // original foundation for this library. - // http://www.nonblocking.io/2011/06/windownexttick.html - - // Safari 6.0.5 (at least) intermittently fails to create message ports on a - // page's first load. Thankfully, this version of Safari supports - // MutationObservers, so we don't need to fall back in that case. - - // function makeRequestCallFromMessageChannel(callback) { - // var channel = new MessageChannel(); - // channel.port1.onmessage = callback; - // return function requestCall() { - // channel.port2.postMessage(0); - // }; - // } - - // For reasons explained above, we are also unable to use `setImmediate` - // under any circumstances. - // Even if we were, there is another bug in Internet Explorer 10. - // It is not sufficient to assign `setImmediate` to `requestFlush` because - // `setImmediate` must be called *by name* and therefore must be wrapped in a - // closure. - // Never forget. - - // function makeRequestCallFromSetImmediate(callback) { - // return function requestCall() { - // setImmediate(callback); - // }; - // } - - // Safari 6.0 has a problem where timers will get lost while the user is - // scrolling. This problem does not impact ASAP because Safari 6.0 supports - // mutation observers, so that implementation is used instead. - // However, if we ever elect to use timers in Safari, the prevalent work-around - // is to add a scroll event listener that calls for a flush. - - // `setTimeout` does not call the passed callback if the delay is less than - // approximately 7 in web workers in Firefox 8 through 18, and sometimes not - // even then. - - function makeRequestCallFromTimer(callback) { - return function requestCall() { - // We dispatch a timeout with a specified delay of 0 for engines that - // can reliably accommodate that request. This will usually be snapped - // to a 4 milisecond delay, but once we're flushing, there's no delay - // between events. - var timeoutHandle = setTimeout(handleTimer, 0); - // However, since this timer gets frequently dropped in Firefox - // workers, we enlist an interval handle that will try to fire - // an event 20 times per second until it succeeds. - var intervalHandle = setInterval(handleTimer, 50); - - function handleTimer() { - // Whichever timer succeeds will cancel both timers and - // execute the callback. - clearTimeout(timeoutHandle); - clearInterval(intervalHandle); - callback(); - } - }; - } - - // This is for `asap.js` only. - // Its name will be periodically randomized to break any code that depends on - // its existence. - rawAsap.makeRequestCallFromTimer = makeRequestCallFromTimer; - - // ASAP was originally a nextTick shim included in Q. This was factored out - // into this ASAP package. It was later adapted to RSVP which made further - // amendments. These decisions, particularly to marginalize MessageChannel and - // to capture the MutationObserver implementation in a closure, were integrated - // back into ASAP proper. - // https://github.com/tildeio/rsvp.js/blob/cddf7232546a9cf858524b75cde6f9edf72620a7/lib/rsvp/asap.js - - /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) - -/***/ }, -/* 73 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var Promise = __webpack_require__(71); - - module.exports = Promise; - Promise.prototype.done = function (onFulfilled, onRejected) { - var self = arguments.length ? this.then.apply(this, arguments) : this; - self.then(null, function (err) { - setTimeout(function () { - throw err; - }, 0); - }); - }; - - -/***/ }, -/* 74 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var Promise = __webpack_require__(71); - - module.exports = Promise; - Promise.prototype['finally'] = function (f) { - return this.then(function (value) { - return Promise.resolve(f()).then(function () { - return value; - }); - }, function (err) { - return Promise.resolve(f()).then(function () { - throw err; - }); - }); - }; - - -/***/ }, -/* 75 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - //This file contains the ES6 extensions to the core Promises/A+ API - - var Promise = __webpack_require__(71); - - module.exports = Promise; - - /* Static Functions */ - - var TRUE = valuePromise(true); - var FALSE = valuePromise(false); - var NULL = valuePromise(null); - var UNDEFINED = valuePromise(undefined); - var ZERO = valuePromise(0); - var EMPTYSTRING = valuePromise(''); - - function valuePromise(value) { - var p = new Promise(Promise._61); - p._81 = 1; - p._65 = value; - return p; - } - Promise.resolve = function (value) { - if (value instanceof Promise) return value; - - if (value === null) return NULL; - if (value === undefined) return UNDEFINED; - if (value === true) return TRUE; - if (value === false) return FALSE; - if (value === 0) return ZERO; - if (value === '') return EMPTYSTRING; - - if (typeof value === 'object' || typeof value === 'function') { - try { - var then = value.then; - if (typeof then === 'function') { - return new Promise(then.bind(value)); - } - } catch (ex) { - return new Promise(function (resolve, reject) { - reject(ex); - }); - } - } - return valuePromise(value); - }; - - Promise.all = function (arr) { - var args = Array.prototype.slice.call(arr); - - return new Promise(function (resolve, reject) { - if (args.length === 0) return resolve([]); - var remaining = args.length; - function res(i, val) { - if (val && (typeof val === 'object' || typeof val === 'function')) { - if (val instanceof Promise && val.then === Promise.prototype.then) { - while (val._81 === 3) { - val = val._65; - } - if (val._81 === 1) return res(i, val._65); - if (val._81 === 2) reject(val._65); - val.then(function (val) { - res(i, val); - }, reject); - return; - } else { - var then = val.then; - if (typeof then === 'function') { - var p = new Promise(then.bind(val)); - p.then(function (val) { - res(i, val); - }, reject); - return; - } - } - } - args[i] = val; - if (--remaining === 0) { - resolve(args); - } - } - for (var i = 0; i < args.length; i++) { - res(i, args[i]); - } - }); - }; - - Promise.reject = function (value) { - return new Promise(function (resolve, reject) { - reject(value); - }); - }; - - Promise.race = function (values) { - return new Promise(function (resolve, reject) { - values.forEach(function(value){ - Promise.resolve(value).then(resolve, reject); - }); - }); - }; - - /* Prototype Methods */ - - Promise.prototype['catch'] = function (onRejected) { - return this.then(null, onRejected); - }; - - -/***/ }, -/* 76 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - // This file contains then/promise specific extensions that are only useful - // for node.js interop - - var Promise = __webpack_require__(71); - var asap = __webpack_require__(77); - - module.exports = Promise; - - /* Static Functions */ - - Promise.denodeify = function (fn, argumentCount) { - if ( - typeof argumentCount === 'number' && argumentCount !== Infinity - ) { - return denodeifyWithCount(fn, argumentCount); - } else { - return denodeifyWithoutCount(fn); - } - } - - var callbackFn = ( - 'function (err, res) {' + - 'if (err) { rj(err); } else { rs(res); }' + - '}' - ); - function denodeifyWithCount(fn, argumentCount) { - var args = []; - for (var i = 0; i < argumentCount; i++) { - args.push('a' + i); - } - var body = [ - 'return function (' + args.join(',') + ') {', - 'var self = this;', - 'return new Promise(function (rs, rj) {', - 'var res = fn.call(', - ['self'].concat(args).concat([callbackFn]).join(','), - ');', - 'if (res &&', - '(typeof res === "object" || typeof res === "function") &&', - 'typeof res.then === "function"', - ') {rs(res);}', - '});', - '};' - ].join(''); - return Function(['Promise', 'fn'], body)(Promise, fn); - } - function denodeifyWithoutCount(fn) { - var fnLength = Math.max(fn.length - 1, 3); - var args = []; - for (var i = 0; i < fnLength; i++) { - args.push('a' + i); - } - var body = [ - 'return function (' + args.join(',') + ') {', - 'var self = this;', - 'var args;', - 'var argLength = arguments.length;', - 'if (arguments.length > ' + fnLength + ') {', - 'args = new Array(arguments.length + 1);', - 'for (var i = 0; i < arguments.length; i++) {', - 'args[i] = arguments[i];', - '}', - '}', - 'return new Promise(function (rs, rj) {', - 'var cb = ' + callbackFn + ';', - 'var res;', - 'switch (argLength) {', - args.concat(['extra']).map(function (_, index) { - return ( - 'case ' + (index) + ':' + - 'res = fn.call(' + ['self'].concat(args.slice(0, index)).concat('cb').join(',') + ');' + - 'break;' - ); - }).join(''), - 'default:', - 'args[argLength] = cb;', - 'res = fn.apply(self, args);', - '}', - - 'if (res &&', - '(typeof res === "object" || typeof res === "function") &&', - 'typeof res.then === "function"', - ') {rs(res);}', - '});', - '};' - ].join(''); - - return Function( - ['Promise', 'fn'], - body - )(Promise, fn); - } - - Promise.nodeify = function (fn) { - return function () { - var args = Array.prototype.slice.call(arguments); - var callback = - typeof args[args.length - 1] === 'function' ? args.pop() : null; - var ctx = this; - try { - return fn.apply(this, arguments).nodeify(callback, ctx); - } catch (ex) { - if (callback === null || typeof callback == 'undefined') { - return new Promise(function (resolve, reject) { - reject(ex); + this.visible = visible; + if (this.renderer) { + this.renderer.updateDrawableProperties(this.drawableID, { + visible: this.visible }); - } else { - asap(function () { - callback.call(ctx, ex); - }) - } } - } - } - - Promise.prototype.nodeify = function (callback, ctx) { - if (typeof callback != 'function') return this; - - this.then(function (value) { - asap(function () { - callback.call(ctx, null, value); - }); - }, function (err) { - asap(function () { - callback.call(ctx, err); - }); - }); - } - - -/***/ }, -/* 77 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - - // rawAsap provides everything we need except exception management. - var rawAsap = __webpack_require__(72); - // RawTasks are recycled to reduce GC churn. - var freeTasks = []; - // We queue errors to ensure they are thrown in right order (FIFO). - // Array-as-queue is good enough here, since we are just dealing with exceptions. - var pendingErrors = []; - var requestErrorThrow = rawAsap.makeRequestCallFromTimer(throwFirstError); - - function throwFirstError() { - if (pendingErrors.length) { - throw pendingErrors.shift(); - } - } + }; /** - * Calls a task as soon as possible after returning, in its own event, with priority - * over other events like animation, reflow, and repaint. An error thrown from an - * event will not interrupt, nor even substantially slow down the processing of - * other events, but will be rather postponed to a lower priority event. - * @param {{call}} task A callable object, typically a function that takes no - * arguments. + * Set size of the clone, as a percentage of the costume size. + * @param {!number} size Size of clone, from 5 to 535. */ - module.exports = asap; - function asap(task) { - var rawTask; - if (freeTasks.length) { - rawTask = freeTasks.pop(); - } else { - rawTask = new RawTask(); + Clone.prototype.setSize = function (size) { + if (this.isStage) { + return; } - rawTask.task = task; - rawAsap(rawTask); - } + // Keep size between 5% and 535%. + this.size = MathUtil.clamp(size, 5, 535); + if (this.renderer) { + this.renderer.updateDrawableProperties(this.drawableID, { + scale: [this.size, this.size] + }); + } + }; - // We wrap tasks with recyclable task objects. A task object implements - // `call`, just like a function. - function RawTask() { - this.task = null; - } + /** + * Set a particular graphic effect on this clone. + * @param {!string} effectName Name of effect (see `Clone.prototype.effects`). + * @param {!number} value Numerical magnitude of effect. + */ + Clone.prototype.setEffect = function (effectName, value) { + if (!this.effects.hasOwnProperty(effectName)) return; + this.effects[effectName] = value; + if (this.renderer) { + var props = {}; + props[effectName] = this.effects[effectName]; + this.renderer.updateDrawableProperties(this.drawableID, props); + } + }; - // The sole purpose of wrapping the task is to catch the exception and recycle - // the task object after its single use. - RawTask.prototype.call = function () { - try { - this.task.call(); - } catch (error) { - if (asap.onerror) { - // This hook exists purely for testing purposes. - // Its name will be periodically randomized to break any code that - // depends on its existence. - asap.onerror(error); - } else { - // In a web browser, exceptions are not fatal. However, to avoid - // slowing down the queue of pending tasks, we rethrow the error in a - // lower priority turn. - pendingErrors.push(error); - requestErrorThrow(); + /** + * Clear all graphic effects on this clone. + */ + Clone.prototype.clearEffects = function () { + for (var effectName in this.effects) { + this.effects[effectName] = 0; + } + if (this.renderer) { + this.renderer.updateDrawableProperties(this.drawableID, this.effects); + } + }; + + /** + * Set the current costume of this clone. + * @param {number} index New index of costume. + */ + Clone.prototype.setCostume = function (index) { + // Keep the costume index within possible values. + this.currentCostume = MathUtil.wrapClamp( + index, 0, this.sprite.costumes.length - 1 + ); + if (this.renderer) { + this.renderer.updateDrawableProperties(this.drawableID, { + skin: this.sprite.costumes[this.currentCostume].skin + }); + } + }; + + /** + * Get a costume index of this clone, by name of the costume. + * @param {?string} costumeName Name of a costume. + * @return {number} Index of the named costume, or -1 if not present. + */ + Clone.prototype.getCostumeIndexByName = function (costumeName) { + for (var i = 0; i < this.sprite.costumes.length; i++) { + if (this.sprite.costumes[i].name == costumeName) { + return i; } - } finally { - this.task = null; - freeTasks[freeTasks.length] = this; + } + return -1; + }; + + /** + * Update all drawable properties for this clone. + * Use when a batch has changed, e.g., when the drawable is first created. + */ + Clone.prototype.updateAllDrawableProperties = function () { + if (this.renderer) { + this.renderer.updateDrawableProperties(this.drawableID, { + position: [this.x, this.y], + direction: this.direction, + scale: [this.size, this.size], + visible: this.visible, + skin: this.sprite.costumes[this.currentCostume].skin + }); } }; + /** + * Return the human-readable name for this clone, i.e., the sprite's name. + * @override + * @returns {string} Human-readable name for the clone. + */ + Clone.prototype.getName = function () { + return this.sprite.name; + }; + + /** + * Return whether the clone is touching a color. + * @param {Array.<number>} rgb [r,g,b], values between 0-255. + * @return {Promise.<Boolean>} True iff the clone is touching the color. + */ + Clone.prototype.isTouchingColor = function (rgb) { + if (this.renderer) { + return this.renderer.isTouchingColor(this.drawableID, rgb); + } + return false; + }; + + /** + * Return whether the clone's color is touching a color. + * @param {Object} targetRgb {Array.<number>} [r,g,b], values between 0-255. + * @param {Object} maskRgb {Array.<number>} [r,g,b], values between 0-255. + * @return {Promise.<Boolean>} True iff the clone's color is touching the color. + */ + Clone.prototype.colorIsTouchingColor = function (targetRgb, maskRgb) { + if (this.renderer) { + return this.renderer.isTouchingColor( + this.drawableID, + targetRgb, + maskRgb + ); + } + return false; + }; + + module.exports = Clone; + /***/ }, -/* 78 */ +/* 87 */ /***/ function(module, exports, __webpack_require__) { - 'use strict'; - - var Promise = __webpack_require__(71); - - module.exports = Promise; - Promise.enableSynchronous = function () { - Promise.prototype.isPending = function() { - return this.getState() == 0; - }; - - Promise.prototype.isFulfilled = function() { - return this.getState() == 1; - }; - - Promise.prototype.isRejected = function() { - return this.getState() == 2; - }; - - Promise.prototype.getValue = function () { - if (this._81 === 3) { - return this._65.getValue(); - } - - if (!this.isFulfilled()) { - throw new Error('Cannot get a value of an unfulfilled promise.'); - } - - return this._65; - }; - - Promise.prototype.getReason = function () { - if (this._81 === 3) { - return this._65.getReason(); - } - - if (!this.isRejected()) { - throw new Error('Cannot get a rejection reason of a non-rejected promise.'); - } - - return this._65; - }; - - Promise.prototype.getState = function () { - if (this._81 === 3) { - return this._65.getState(); - } - if (this._81 === -1 || this._81 === -2) { - return 0; - } - - return this._81; - }; - }; - - Promise.disableSynchronous = function() { - Promise.prototype.isPending = undefined; - Promise.prototype.isFulfilled = undefined; - Promise.prototype.isRejected = undefined; - Promise.prototype.getValue = undefined; - Promise.prototype.getReason = undefined; - Promise.prototype.getState = undefined; - }; - - -/***/ }, -/* 79 */ -/***/ function(module, exports) { - - function Scratch3EventBlocks(runtime) { - /** - * The runtime instantiating this block package. - * @type {Runtime} - */ - this.runtime = runtime; - } - - /** - * Retrieve the block primitives implemented by this package. - * @return {Object.<string, Function>} Mapping of opcode to Function. - */ - Scratch3EventBlocks.prototype.getPrimitives = function() { - return { - 'event_whenflagclicked': this.whenFlagClicked, - 'event_whenbroadcastreceived': this.whenBroadcastReceived, - 'event_broadcast': this.broadcast - }; - }; - - - Scratch3EventBlocks.prototype.whenFlagClicked = function() { - // No-op - }; - - Scratch3EventBlocks.prototype.whenBroadcastReceived = function() { - // No-op - }; - - Scratch3EventBlocks.prototype.broadcast = function() { - // @todo - }; - - module.exports = Scratch3EventBlocks; - - -/***/ }, -/* 80 */ -/***/ function(module, exports) { - - function Scratch3LooksBlocks(runtime) { - /** - * The runtime instantiating this block package. - * @type {Runtime} - */ - this.runtime = runtime; - } - - /** - * Retrieve the block primitives implemented by this package. - * @return {Object.<string, Function>} Mapping of opcode to Function. - */ - Scratch3LooksBlocks.prototype.getPrimitives = function() { - return { - 'looks_say': this.say, - 'looks_sayforsecs': this.sayforsecs, - 'looks_think': this.think, - 'looks_thinkforsecs': this.sayforsecs, - 'looks_show': this.show, - 'looks_hide': this.hide, - 'looks_effectmenu': this.effectMenu, - 'looks_changeeffectby': this.changeEffect, - 'looks_seteffectto': this.setEffect, - 'looks_cleargraphiceffects': this.clearEffects, - 'looks_changesizeby': this.changeSize, - 'looks_setsizeto': this.setSize, - 'looks_size': this.getSize - }; - }; - - Scratch3LooksBlocks.prototype.say = function (args, util) { - util.target.setSay('say', args.MESSAGE); - }; - - Scratch3LooksBlocks.prototype.sayforsecs = function (args, util) { - util.target.setSay('say', args.MESSAGE); - return new Promise(function(resolve) { - setTimeout(function() { - // Clear say bubble and proceed. - util.target.setSay(); - resolve(); - }, 1000 * args.SECS); - }); - }; - - Scratch3LooksBlocks.prototype.think = function (args, util) { - util.target.setSay('think', args.MESSAGE); - }; - - Scratch3LooksBlocks.prototype.thinkforsecs = function (args, util) { - util.target.setSay('think', args.MESSAGE); - return new Promise(function(resolve) { - setTimeout(function() { - // Clear say bubble and proceed. - util.target.setSay(); - resolve(); - }, 1000 * args.SECS); - }); - }; - - Scratch3LooksBlocks.prototype.show = function (args, util) { - util.target.setVisible(true); - }; - - Scratch3LooksBlocks.prototype.hide = function (args, util) { - util.target.setVisible(false); - }; - - Scratch3LooksBlocks.prototype.effectMenu = function (args) { - return args.EFFECT.toLowerCase(); - }; - - Scratch3LooksBlocks.prototype.changeEffect = function (args, util) { - var newValue = args.CHANGE + util.target.effects[args.EFFECT]; - util.target.setEffect(args.EFFECT, newValue); - }; - - Scratch3LooksBlocks.prototype.setEffect = function (args, util) { - util.target.setEffect(args.EFFECT, args.VALUE); - }; - - Scratch3LooksBlocks.prototype.clearEffects = function (args, util) { - util.target.clearEffects(); - }; - - Scratch3LooksBlocks.prototype.changeSize = function (args, util) { - util.target.setSize(util.target.size + args.CHANGE); - }; - - Scratch3LooksBlocks.prototype.setSize = function (args, util) { - util.target.setSize(args.SIZE); - }; - - Scratch3LooksBlocks.prototype.getSize = function (args, util) { - return util.target.size; - }; - - module.exports = Scratch3LooksBlocks; - - -/***/ }, -/* 81 */ -/***/ function(module, exports, __webpack_require__) { - - var MathUtil = __webpack_require__(8); - - function Scratch3MotionBlocks(runtime) { - /** - * The runtime instantiating this block package. - * @type {Runtime} - */ - this.runtime = runtime; - } - - /** - * Retrieve the block primitives implemented by this package. - * @return {Object.<string, Function>} Mapping of opcode to Function. - */ - Scratch3MotionBlocks.prototype.getPrimitives = function() { - return { - 'motion_movesteps': this.moveSteps, - 'motion_gotoxy': this.goToXY, - 'motion_turnright': this.turnRight, - 'motion_turnleft': this.turnLeft, - 'motion_pointindirection': this.pointInDirection, - 'motion_changexby': this.changeX, - 'motion_setx': this.setX, - 'motion_changeyby': this.changeY, - 'motion_sety': this.setY, - 'motion_xposition': this.getX, - 'motion_yposition': this.getY, - 'motion_direction': this.getDirection - }; - }; - - Scratch3MotionBlocks.prototype.moveSteps = function (args, util) { - var radians = MathUtil.degToRad(util.target.direction); - var dx = args.STEPS * Math.cos(radians); - var dy = args.STEPS * Math.sin(radians); - util.target.setXY(util.target.x + dx, util.target.y + dy); - }; - - Scratch3MotionBlocks.prototype.goToXY = function (args, util) { - util.target.setXY(args.X, args.Y); - }; - - Scratch3MotionBlocks.prototype.turnRight = function (args, util) { - util.target.setDirection(util.target.direction + args.DEGREES); - }; - - Scratch3MotionBlocks.prototype.turnLeft = function (args, util) { - util.target.setDirection(util.target.direction - args.DEGREES); - }; - - Scratch3MotionBlocks.prototype.pointInDirection = function (args, util) { - util.target.setDirection(args.DIRECTION); - }; - - Scratch3MotionBlocks.prototype.changeX = function (args, util) { - util.target.setXY(util.target.x + args.DX, util.target.y); - }; - - Scratch3MotionBlocks.prototype.setX = function (args, util) { - util.target.setXY(args.X, util.target.y); - }; - - Scratch3MotionBlocks.prototype.changeY = function (args, util) { - util.target.setXY(util.target.x, util.target.y + args.DY); - }; - - Scratch3MotionBlocks.prototype.setY = function (args, util) { - util.target.setXY(util.target.x, args.Y); - }; - - Scratch3MotionBlocks.prototype.getX = function (args, util) { - return util.target.x; - }; - - Scratch3MotionBlocks.prototype.getY = function (args, util) { - return util.target.y; - }; - - Scratch3MotionBlocks.prototype.getDirection = function (args, util) { - return util.target.direction; - }; - - module.exports = Scratch3MotionBlocks; - - -/***/ }, -/* 82 */ -/***/ function(module, exports, __webpack_require__) { - - var Cast = __webpack_require__(83); - - function Scratch3OperatorsBlocks(runtime) { - /** - * The runtime instantiating this block package. - * @type {Runtime} - */ - this.runtime = runtime; - } - - /** - * Retrieve the block primitives implemented by this package. - * @return {Object.<string, Function>} Mapping of opcode to Function. - */ - Scratch3OperatorsBlocks.prototype.getPrimitives = function() { - return { - 'math_number': this.number, - 'math_positive_number': this.number, - 'math_whole_number': this.number, - 'math_angle': this.number, - 'text': this.text, - 'operator_add': this.add, - 'operator_subtract': this.subtract, - 'operator_multiply': this.multiply, - 'operator_divide': this.divide, - 'operator_lt': this.lt, - 'operator_equals': this.equals, - 'operator_gt': this.gt, - 'operator_and': this.and, - 'operator_or': this.or, - 'operator_not': this.not, - 'operator_random': this.random, - 'operator_join': this.join, - 'operator_letter_of': this.letterOf, - 'operator_length': this.length, - 'operator_mod': this.mod, - 'operator_round': this.round, - 'operator_mathop_menu': this.mathopMenu, - 'operator_mathop': this.mathop - }; - }; - - Scratch3OperatorsBlocks.prototype.number = function (args) { - return Cast.toNumber(args.NUM); - }; - - Scratch3OperatorsBlocks.prototype.text = function (args) { - return Cast.toString(args.TEXT); - }; - - Scratch3OperatorsBlocks.prototype.add = function (args) { - return Cast.toNumber(args.NUM1) + Cast.toNumber(args.NUM2); - }; - - Scratch3OperatorsBlocks.prototype.subtract = function (args) { - return Cast.toNumber(args.NUM1) - Cast.toNumber(args.NUM2); - }; - - Scratch3OperatorsBlocks.prototype.multiply = function (args) { - return Cast.toNumber(args.NUM1) * Cast.toNumber(args.NUM2); - }; - - Scratch3OperatorsBlocks.prototype.divide = function (args) { - return Cast.toNumber(args.NUM1) / Cast.toNumber(args.NUM2); - }; - - Scratch3OperatorsBlocks.prototype.lt = function (args) { - return Cast.compare(args.OPERAND1, args.OPERAND2) < 0; - }; - - Scratch3OperatorsBlocks.prototype.equals = function (args) { - return Cast.compare(args.OPERAND1, args.OPERAND2) == 0; - }; - - Scratch3OperatorsBlocks.prototype.gt = function (args) { - return Cast.compare(args.OPERAND1, args.OPERAND2) > 0; - }; - - Scratch3OperatorsBlocks.prototype.and = function (args) { - return Cast.toBoolean(args.OPERAND1 && args.OPERAND2); - }; - - Scratch3OperatorsBlocks.prototype.or = function (args) { - return Cast.toBoolean(args.OPERAND1 || args.OPERAND2); - }; - - Scratch3OperatorsBlocks.prototype.not = function (args) { - return Cast.toBoolean(!args.OPERAND); - }; - - Scratch3OperatorsBlocks.prototype.random = function (args) { - var low = args.FROM <= args.TO ? args.FROM : args.TO; - var high = args.FROM <= args.TO ? args.TO : args.FROM; - if (low == high) return low; - // If both low and high are ints, truncate the result to an int. - var lowInt = low == parseInt(low); - var highInt = high == parseInt(high); - if (lowInt && highInt) { - return low + parseInt(Math.random() * ((high + 1) - low)); - } - return (Math.random() * (high - low)) + low; - }; - - Scratch3OperatorsBlocks.prototype.join = function (args) { - return Cast.toString(args.STRING1) + Cast.toString(args.STRING2); - }; - - Scratch3OperatorsBlocks.prototype.letterOf = function (args) { - var index = Cast.toNumber(args.LETTER) - 1; - var str = Cast.toString(args.STRING); - // Out of bounds? - if (index < 0 || index >= str.length) { - return ''; - } - return str.charAt(index); - }; - - Scratch3OperatorsBlocks.prototype.length = function (args) { - return Cast.toString(args.STRING).length; - }; - - Scratch3OperatorsBlocks.prototype.mod = function (args) { - var n = Cast.toNumber(args.NUM1); - var modulus = Cast.toNumber(args.NUM2); - var result = n % modulus; - // Scratch mod is kept positive. - if (result / modulus < 0) result += modulus; - return result; - }; - - Scratch3OperatorsBlocks.prototype.round = function (args) { - return Math.round(Cast.toNumber(args.NUM)); - }; - - Scratch3OperatorsBlocks.prototype.mathopMenu = function (args) { - return args.OPERATOR; - }; - - Scratch3OperatorsBlocks.prototype.mathop = function (args) { - var operator = Cast.toString(args.OPERATOR).toLowerCase(); - var n = Cast.toNumber(args.NUM); - switch (operator) { - case 'abs': return Math.abs(n); - case 'floor': return Math.floor(n); - case 'ceiling': return Math.ceil(n); - case 'sqrt': return Math.sqrt(n); - case 'sin': return Math.sin((Math.PI * n) / 180); - case 'cos': return Math.cos((Math.PI * n) / 180); - case 'tan': return Math.tan((Math.PI * n) / 180); - case 'asin': return (Math.asin(n) * 180) / Math.PI; - case 'acos': return (Math.acos(n) * 180) / Math.PI; - case 'atan': return (Math.atan(n) * 180) / Math.PI; - case 'ln': return Math.log(n); - case 'log': return Math.log(n) / Math.LN10; - case 'e ^': return Math.exp(n); - case '10 ^': return Math.pow(10, n); - } - return 0; - }; - - module.exports = Scratch3OperatorsBlocks; - - -/***/ }, -/* 83 */ -/***/ function(module, exports) { - - function Cast () {} + var Blocks = __webpack_require__(34); + var uid = __webpack_require__(88); /** * @fileoverview - * Utilities for casting and comparing Scratch data-types. - * Scratch behaves slightly differently from JavaScript in many respects, - * and these differences should be encapsulated below. - * For example, in Scratch, add(1, join("hello", world")) -> 1. - * This is because "hello world" is cast to 0. - * In JavaScript, 1 + Number("hello" + "world") would give you NaN. - * Use when coercing a value before computation. + * A Target is an abstract "code-running" object for the Scratch VM. + * Examples include sprites/clones or potentially physical-world devices. */ /** - * Scratch cast to number. - * Treats NaN as 0. - * In Scratch 2.0, this is captured by `interp.numArg.` - * @param {*} value Value to cast to number. - * @return {number} The Scratch-casted number value. + * @param {?Blocks} blocks Blocks instance for the blocks owned by this target. + * @constructor */ - Cast.toNumber = function (value) { - var n = Number(value); - if (isNaN(n)) { - // Scratch treats NaN as 0, when needed as a number. - // E.g., 0 + NaN -> 0. - return 0; + function Target (blocks) { + if (!blocks) { + blocks = new Blocks(this); } - return n; - }; - - /** - * Scratch cast to boolean. - * In Scratch 2.0, this is captured by `interp.boolArg.` - * Treats some string values differently from JavaScript. - * @param {*} value Value to cast to boolean. - * @return {boolean} The Scratch-casted boolean value. - */ - Cast.toBoolean = function (value) { - // Already a boolean? - if (typeof value === 'boolean') { - return value; - } - if (typeof value === 'string') { - // These specific strings are treated as false in Scratch. - if ((value == '') || - (value == '0') || - (value.toLowerCase() == 'false')) { - return false; - } - // All other strings treated as true. - return true; - } - // Coerce other values and numbers. - return Boolean(value); - }; - - /** - * Scratch cast to string. - * @param {*} value Value to cast to string. - * @return {string} The Scratch-casted string value. - */ - Cast.toString = function (value) { - return String(value); - }; - - /** - * Compare two values, using Scratch cast, case-insensitive string compare, etc. - * In Scratch 2.0, this is captured by `interp.compare.` - * @param {*} v1 First value to compare. - * @param {*} v2 Second value to compare. - * @returns {Number} Negative number if v1 < v2; 0 if equal; positive otherwise. - */ - Cast.compare = function (v1, v2) { - var n1 = Number(v1); - var n2 = Number(v2); - if (isNaN(n1) || isNaN(n2)) { - // At least one argument can't be converted to a number. - // Scratch compares strings as case insensitive. - var s1 = String(v1).toLowerCase(); - var s2 = String(v2).toLowerCase(); - return s1.localeCompare(s2); - } else { - // Compare as numbers. - return n1 - n2; - } - }; - - module.exports = Cast; - - -/***/ }, -/* 84 */ -/***/ function(module, exports) { - - function Scratch3SensingBlocks(runtime) { /** - * The runtime instantiating this block package. - * @type {Runtime} + * A unique ID for this target. + * @type {string} */ - this.runtime = runtime; + this.id = uid(); + /** + * Blocks run as code for this target. + * @type {!Blocks} + */ + this.blocks = blocks; } /** - * Retrieve the block primitives implemented by this package. - * @return {Object.<string, Function>} Mapping of opcode to Function. + * Return a human-readable name for this target. + * Target implementations should override this. + * @abstract + * @returns {string} Human-readable name for the target. */ - Scratch3SensingBlocks.prototype.getPrimitives = function() { - return { - 'sensing_timer': this.getTimer, - 'sensing_resettimer': this.resetTimer, - 'sensing_mousex': this.getMouseX, - 'sensing_mousey': this.getMouseY, - 'sensing_mousedown': this.getMouseDown - }; + Target.prototype.getName = function () { + return this.id; }; - Scratch3SensingBlocks.prototype.getTimer = function (args, util) { - return util.ioQuery('clock', 'projectTimer'); + module.exports = Target; + + +/***/ }, +/* 88 */ +/***/ function(module, exports) { + + /** + * @fileoverview UID generator, from Blockly. + */ + + /** + * Legal characters for the unique ID. + * Should be all on a US keyboard. No XML special characters or control codes. + * Removed $ due to issue 251. + * @private + */ + var soup_ = '!#%()*+,-./:;=?@[]^_`{|}~' + + 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + + /** + * Generate a unique ID, from Blockly. This should be globally unique. + * 87 characters ^ 20 length > 128 bits (better than a UUID). + * @return {string} A globally unique ID string. + */ + var uid = function () { + var length = 20; + var soupLength = soup_.length; + var id = []; + for (var i = 0; i < length; i++) { + id[i] = soup_.charAt(Math.random() * soupLength); + } + return id.join(''); }; - Scratch3SensingBlocks.prototype.resetTimer = function (args, util) { - util.ioQuery('clock', 'resetProjectTimer'); - }; + module.exports = uid; - Scratch3SensingBlocks.prototype.getMouseX = function (args, util) { - return util.ioQuery('mouse', 'getX'); - }; - Scratch3SensingBlocks.prototype.getMouseY = function (args, util) { - return util.ioQuery('mouse', 'getY'); - }; +/***/ }, +/* 89 */ +/***/ function(module, exports) { - Scratch3SensingBlocks.prototype.getMouseDown = function (args, util) { - return util.ioQuery('mouse', 'getIsDown'); + /** + * @fileoverview + * The specMap below handles a few pieces of "translation" work between + * the SB2 JSON format and the data we need to run a project + * in the Scratch 3.0 VM. + * Notably: + * - Map 2.0-format opcodes (forward:) into 3.0-format (motion_movesteps). + * - Map ordered, unnamed args to unordered, named inputs and fields. + * Keep this up-to-date as 3.0 blocks are renamed, changed, etc. + */ + var specMap = { + 'forward:':{ + 'opcode':'motion_movesteps', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'STEPS' + } + ] + }, + 'turnRight:':{ + 'opcode':'motion_turnright', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'DEGREES' + } + ] + }, + 'turnLeft:':{ + 'opcode':'motion_turnleft', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'DEGREES' + } + ] + }, + 'heading:':{ + 'opcode':'motion_pointindirection', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_angle', + 'inputName':'DIRECTION' + } + ] + }, + 'pointTowards:':{ + 'opcode':'motion_pointtowards', + 'argMap':[ + { + 'type':'input', + 'inputOp':'motion_pointtowards_menu', + 'inputName':'TOWARDS' + } + ] + }, + 'gotoX:y:':{ + 'opcode':'motion_gotoxy', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'X' + }, + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'Y' + } + ] + }, + 'gotoSpriteOrMouse:':{ + 'opcode':'motion_goto', + 'argMap':[ + { + 'type':'input', + 'inputOp':'motion_goto_menu', + 'inputName':'TO' + } + ] + }, + 'glideSecs:toX:y:elapsed:from:':{ + 'opcode':'motion_glidesecstoxy', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'SECS' + }, + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'X' + }, + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'Y' + } + ] + }, + 'changeXposBy:':{ + 'opcode':'motion_changexby', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'DX' + } + ] + }, + 'xpos:':{ + 'opcode':'motion_setx', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'X' + } + ] + }, + 'changeYposBy:':{ + 'opcode':'motion_changeyby', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'DY' + } + ] + }, + 'ypos:':{ + 'opcode':'motion_sety', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'Y' + } + ] + }, + 'bounceOffEdge':{ + 'opcode':'motion_ifonedgebounce', + 'argMap':[ + ] + }, + 'setRotationStyle':{ + 'opcode':'motion_setrotationstyle', + 'argMap':[ + { + 'type':'input', + 'inputOp':'motion_setrotationstyle_menu', + 'inputName':'STYLE' + } + ] + }, + 'xpos':{ + 'opcode':'motion_xposition', + 'argMap':[ + ] + }, + 'ypos':{ + 'opcode':'motion_yposition', + 'argMap':[ + ] + }, + 'heading':{ + 'opcode':'motion_direction', + 'argMap':[ + ] + }, + 'say:duration:elapsed:from:':{ + 'opcode':'looks_sayforsecs', + 'argMap':[ + { + 'type':'input', + 'inputOp':'text', + 'inputName':'MESSAGE' + }, + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'SECS' + } + ] + }, + 'say:':{ + 'opcode':'looks_say', + 'argMap':[ + { + 'type':'input', + 'inputOp':'text', + 'inputName':'MESSAGE' + } + ] + }, + 'think:duration:elapsed:from:':{ + 'opcode':'looks_thinkforsecs', + 'argMap':[ + { + 'type':'input', + 'inputOp':'text', + 'inputName':'MESSAGE' + }, + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'SECS' + } + ] + }, + 'think:':{ + 'opcode':'looks_think', + 'argMap':[ + { + 'type':'input', + 'inputOp':'text', + 'inputName':'MESSAGE' + } + ] + }, + 'show':{ + 'opcode':'looks_show', + 'argMap':[ + ] + }, + 'hide':{ + 'opcode':'looks_hide', + 'argMap':[ + ] + }, + 'lookLike:':{ + 'opcode':'looks_switchcostumeto', + 'argMap':[ + { + 'type':'input', + 'inputOp':'looks_costume', + 'inputName':'COSTUME' + } + ] + }, + 'nextCostume':{ + 'opcode':'looks_nextcostume', + 'argMap':[ + ] + }, + 'startScene':{ + 'opcode':'looks_switchbackdropto', + 'argMap':[ + { + 'type':'input', + 'inputOp':'looks_backdrops', + 'inputName':'BACKDROP' + } + ] + }, + 'changeGraphicEffect:by:':{ + 'opcode':'looks_changeeffectby', + 'argMap':[ + { + 'type':'input', + 'inputOp':'looks_effectmenu', + 'inputName':'EFFECT' + }, + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'CHANGE' + } + ] + }, + 'setGraphicEffect:to:':{ + 'opcode':'looks_seteffectto', + 'argMap':[ + { + 'type':'input', + 'inputOp':'looks_effectmenu', + 'inputName':'EFFECT' + }, + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'VALUE' + } + ] + }, + 'filterReset':{ + 'opcode':'looks_cleargraphiceffects', + 'argMap':[ + ] + }, + 'changeSizeBy:':{ + 'opcode':'looks_changesizeby', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'CHANGE' + } + ] + }, + 'setSizeTo:':{ + 'opcode':'looks_setsizeto', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'SIZE' + } + ] + }, + 'comeToFront':{ + 'opcode':'looks_gotofront', + 'argMap':[ + ] + }, + 'goBackByLayers:':{ + 'opcode':'looks_gobacklayers', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_integer', + 'inputName':'NUM' + } + ] + }, + 'costumeIndex':{ + 'opcode':'looks_costumeorder', + 'argMap':[ + ] + }, + 'sceneName':{ + 'opcode':'looks_backdropname', + 'argMap':[ + ] + }, + 'scale':{ + 'opcode':'looks_size', + 'argMap':[ + ] + }, + 'startSceneAndWait':{ + 'opcode':'looks_switchbackdroptoandwait', + 'argMap':[ + { + 'type':'input', + 'inputOp':'looks_backdrops', + 'inputName':'BACKDROP' + } + ] + }, + 'nextScene':{ + 'opcode':'looks_nextbackdrop', + 'argMap':[ + ] + }, + 'backgroundIndex':{ + 'opcode':'looks_backdroporder', + 'argMap':[ + ] + }, + 'playSound:':{ + 'opcode':'sound_play', + 'argMap':[ + { + 'type':'input', + 'inputOp':'sound_sounds_option', + 'inputName':'SOUND_MENU' + } + ] + }, + 'doPlaySoundAndWait':{ + 'opcode':'sound_playuntildone', + 'argMap':[ + { + 'type':'input', + 'inputOp':'sound_sounds_option', + 'inputName':'SOUND_MENU' + } + ] + }, + 'stopAllSounds':{ + 'opcode':'sound_stopallsounds', + 'argMap':[ + ] + }, + 'playDrum':{ + 'opcode':'sound_playdrumforbeats', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'DRUMTYPE' + }, + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'BEATS' + } + ] + }, + 'rest:elapsed:from:':{ + 'opcode':'sound_restforbeats', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'BEATS' + } + ] + }, + 'noteOn:duration:elapsed:from:':{ + 'opcode':'sound_playnoteforbeats', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'NOTE' + }, + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'BEATS' + } + ] + }, + 'instrument:':{ + 'opcode':'sound_setinstrumentto', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'INSTRUMENT' + } + ] + }, + 'changeVolumeBy:':{ + 'opcode':'sound_changevolumeby', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'VOLUME' + } + ] + }, + 'setVolumeTo:':{ + 'opcode':'sound_setvolumeto', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'VOLUME' + } + ] + }, + 'volume':{ + 'opcode':'sound_volume', + 'argMap':[ + ] + }, + 'changeTempoBy:':{ + 'opcode':'sound_changetempoby', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'TEMPO' + } + ] + }, + 'setTempoTo:':{ + 'opcode':'sound_settempotobpm', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'TEMPO' + } + ] + }, + 'tempo':{ + 'opcode':'sound_tempo', + 'argMap':[ + ] + }, + 'clearPenTrails':{ + 'opcode':'pen_clear', + 'argMap':[ + ] + }, + 'stampCostume':{ + 'opcode':'pen_stamp', + 'argMap':[ + ] + }, + 'putPenDown':{ + 'opcode':'pen_pendown', + 'argMap':[ + ] + }, + 'putPenUp':{ + 'opcode':'pen_penup', + 'argMap':[ + ] + }, + 'penColor:':{ + 'opcode':'pen_setpencolortocolor', + 'argMap':[ + { + 'type':'input', + 'inputOp':'colour_picker', + 'inputName':'COLOR' + } + ] + }, + 'changePenHueBy:':{ + 'opcode':'pen_changepencolorby', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'COLOR' + } + ] + }, + 'setPenHueTo:':{ + 'opcode':'pen_setpencolortonum', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'COLOR' + } + ] + }, + 'changePenShadeBy:':{ + 'opcode':'pen_changepenshadeby', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'SHADE' + } + ] + }, + 'setPenShadeTo:':{ + 'opcode':'pen_changepenshadeby', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'SHADE' + } + ] + }, + 'changePenSizeBy:':{ + 'opcode':'pen_changepensizeby', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'SIZE' + } + ] + }, + 'penSize:':{ + 'opcode':'pen_setpensizeto', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'SIZE' + } + ] + }, + 'whenGreenFlag':{ + 'opcode':'event_whenflagclicked', + 'argMap':[ + ] + }, + 'whenKeyPressed':{ + 'opcode':'event_whenkeypressed', + 'argMap':[ + { + 'type':'field', + 'fieldName':'KEY_OPTION' + } + ] + }, + 'whenClicked':{ + 'opcode':'event_whenthisspriteclicked', + 'argMap':[ + ] + }, + 'whenSceneStarts':{ + 'opcode':'event_whenbackdropswitchesto', + 'argMap':[ + { + 'type':'field', + 'fieldName':'BACKDROP' + } + ] + }, + 'whenSensorGreaterThan':{ + 'opcode':'event_whengreaterthan', + 'argMap':[ + { + 'type':'field', + 'fieldName':'WHENGREATERTHANMENU' + }, + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'VALUE' + } + ] + }, + 'whenIReceive':{ + 'opcode':'event_whenbroadcastreceived', + 'argMap':[ + { + 'type':'field', + 'fieldName':'BROADCAST_OPTION' + } + ] + }, + 'broadcast:':{ + 'opcode':'event_broadcast', + 'argMap':[ + { + 'type':'field', + 'fieldName':'BROADCAST_OPTION' + } + ] + }, + 'doBroadcastAndWait':{ + 'opcode':'event_broadcastandwait', + 'argMap':[ + { + 'type':'field', + 'fieldName':'BROADCAST_OPTION' + } + ] + }, + 'wait:elapsed:from:':{ + 'opcode':'control_wait', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_positive_number', + 'inputName':'DURATION' + } + ] + }, + 'doRepeat':{ + 'opcode':'control_repeat', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_whole_number', + 'inputName':'TIMES' + }, + { + 'type':'input', + 'inputName': 'SUBSTACK' + } + ] + }, + 'doForever':{ + 'opcode':'control_forever', + 'argMap':[ + { + 'type':'input', + 'inputName':'SUBSTACK' + } + ] + }, + 'doIf':{ + 'opcode':'control_if', + 'argMap':[ + { + 'type':'input', + 'inputName':'CONDITION' + }, + { + 'type':'input', + 'inputName':'SUBSTACK' + } + ] + }, + 'doIfElse':{ + 'opcode':'control_if_else', + 'argMap':[ + { + 'type':'input', + 'inputName':'CONDITION' + }, + { + 'type':'input', + 'inputName':'SUBSTACK' + }, + { + 'type':'input', + 'inputName':'SUBSTACK2' + } + ] + }, + 'doWaitUntil':{ + 'opcode':'control_wait_until', + 'argMap':[ + { + 'type':'input', + 'inputName':'CONDITION' + } + ] + }, + 'doUntil':{ + 'opcode':'control_repeat_until', + 'argMap':[ + { + 'type':'input', + 'inputName':'CONDITION' + }, + { + 'type':'input', + 'inputName':'SUBSTACK' + } + ] + }, + 'stopScripts':{ + 'opcode':'control_stop', + 'argMap':[ + { + 'type':'input', + 'inputOp':'control_stop_menu', + 'inputName':'STOP_OPTION' + } + ] + }, + 'whenCloned':{ + 'opcode':'control_start_as_clone', + 'argMap':[ + ] + }, + 'createCloneOf':{ + 'opcode':'control_create_clone_of', + 'argMap':[ + { + 'type':'input', + 'inputOp':'control_create_clone_of_menu', + 'inputName':'CLONE_OPTION' + } + ] + }, + 'deleteClone':{ + 'opcode':'control_delete_this_clone', + 'argMap':[ + ] + }, + 'touching:':{ + 'opcode':'sensing_touchingobject', + 'argMap':[ + { + 'type':'input', + 'inputOp':'sensing_touchingobjectmenu', + 'inputName':'TOUCHINGOBJECTMENU' + } + ] + }, + 'touchingColor:':{ + 'opcode':'sensing_touchingcolor', + 'argMap':[ + { + 'type':'input', + 'inputOp':'colour_picker', + 'inputName':'COLOR' + } + ] + }, + 'color:sees:':{ + 'opcode':'sensing_coloristouchingcolor', + 'argMap':[ + { + 'type':'input', + 'inputOp':'colour_picker', + 'inputName':'COLOR' + }, + { + 'type':'input', + 'inputOp':'colour_picker', + 'inputName':'COLOR2' + } + ] + }, + 'distanceTo:':{ + 'opcode':'sensing_distanceto', + 'argMap':[ + { + 'type':'input', + 'inputOp':'sensing_distancetomenu', + 'inputName':'DISTANCETOMENU' + } + ] + }, + 'doAsk':{ + 'opcode':'sensing_askandwait', + 'argMap':[ + { + 'type':'input', + 'inputOp':'text', + 'inputName':'QUESTION' + } + ] + }, + 'answer':{ + 'opcode':'sensing_answer', + 'argMap':[ + ] + }, + 'keyPressed:':{ + 'opcode':'sensing_keypressed', + 'argMap':[ + { + 'type':'input', + 'inputOp':'sensing_keyoptions', + 'inputName':'KEY_OPTION' + } + ] + }, + 'mousePressed':{ + 'opcode':'sensing_mousedown', + 'argMap':[ + ] + }, + 'mouseX':{ + 'opcode':'sensing_mousex', + 'argMap':[ + ] + }, + 'mouseY':{ + 'opcode':'sensing_mousey', + 'argMap':[ + ] + }, + 'soundLevel':{ + 'opcode':'sensing_loudness', + 'argMap':[ + ] + }, + 'senseVideoMotion':{ + 'opcode':'sensing_videoon', + 'argMap':[ + { + 'type':'input', + 'inputOp':'sensing_videoonmenuone', + 'inputName':'VIDEOONMENU1' + }, + { + 'type':'input', + 'inputOp':'sensing_videoonmenutwo', + 'inputName':'VIDEOONMENU2' + } + ] + }, + 'setVideoState':{ + 'opcode':'sensing_videotoggle', + 'argMap':[ + { + 'type':'input', + 'inputOp':'sensing_videotogglemenu', + 'inputName':'VIDEOTOGGLEMENU' + } + ] + }, + 'setVideoTransparency':{ + 'opcode':'sensing_setvideotransparency', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'TRANSPARENCY' + } + ] + }, + 'timer':{ + 'opcode':'sensing_timer', + 'argMap':[ + ] + }, + 'timerReset':{ + 'opcode':'sensing_resettimer', + 'argMap':[ + ] + }, + 'getAttribute:of:':{ + 'opcode':'sensing_of', + 'argMap':[ + { + 'type':'input', + 'inputOp':'sensing_ofattributemenu', + 'inputName':'ATTRIBUTE' + }, + { + 'type':'input', + 'inputOp':'sensing_ofobjectmenu', + 'inputName':'OBJECT' + } + ] + }, + 'timeAndDate':{ + 'opcode':'sensing_current', + 'argMap':[ + { + 'type':'input', + 'inputOp':'sensing_currentmenu', + 'inputName':'CURRENTMENU' + } + ] + }, + 'timestamp':{ + 'opcode':'sensing_dayssince2000', + 'argMap':[ + ] + }, + 'getUserName':{ + 'opcode':'sensing_username', + 'argMap':[ + ] + }, + '+':{ + 'opcode':'operator_add', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'NUM1' + }, + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'NUM2' + } + ] + }, + '-':{ + 'opcode':'operator_subtract', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'NUM1' + }, + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'NUM2' + } + ] + }, + '*':{ + 'opcode':'operator_multiply', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'NUM1' + }, + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'NUM2' + } + ] + }, + '/':{ + 'opcode':'operator_divide', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'NUM1' + }, + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'NUM2' + } + ] + }, + 'randomFrom:to:':{ + 'opcode':'operator_random', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'FROM' + }, + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'TO' + } + ] + }, + '<':{ + 'opcode':'operator_lt', + 'argMap':[ + { + 'type':'input', + 'inputOp':'text', + 'inputName':'OPERAND1' + }, + { + 'type':'input', + 'inputOp':'text', + 'inputName':'OPERAND2' + } + ] + }, + '=':{ + 'opcode':'operator_equals', + 'argMap':[ + { + 'type':'input', + 'inputOp':'text', + 'inputName':'OPERAND1' + }, + { + 'type':'input', + 'inputOp':'text', + 'inputName':'OPERAND2' + } + ] + }, + '>':{ + 'opcode':'operator_gt', + 'argMap':[ + { + 'type':'input', + 'inputOp':'text', + 'inputName':'OPERAND1' + }, + { + 'type':'input', + 'inputOp':'text', + 'inputName':'OPERAND2' + } + ] + }, + '&':{ + 'opcode':'operator_and', + 'argMap':[ + { + 'type':'input', + 'inputName':'OPERAND1' + }, + { + 'type':'input', + 'inputName':'OPERAND2' + } + ] + }, + '|':{ + 'opcode':'operator_or', + 'argMap':[ + { + 'type':'input', + 'inputName':'OPERAND1' + }, + { + 'type':'input', + 'inputName':'OPERAND2' + } + ] + }, + 'not':{ + 'opcode':'operator_not', + 'argMap':[ + { + 'type':'input', + 'inputName':'OPERAND' + } + ] + }, + 'concatenate:with:':{ + 'opcode':'operator_join', + 'argMap':[ + { + 'type':'input', + 'inputOp':'text', + 'inputName':'STRING1' + }, + { + 'type':'input', + 'inputOp':'text', + 'inputName':'STRING2' + } + ] + }, + 'letter:of:':{ + 'opcode':'operator_letter_of', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_whole_number', + 'inputName':'LETTER' + }, + { + 'type':'input', + 'inputOp':'text', + 'inputName':'STRING' + } + ] + }, + 'stringLength:':{ + 'opcode':'operator_length', + 'argMap':[ + { + 'type':'input', + 'inputOp':'text', + 'inputName':'STRING' + } + ] + }, + '%':{ + 'opcode':'operator_mod', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'NUM1' + }, + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'NUM2' + } + ] + }, + 'rounded':{ + 'opcode':'operator_round', + 'argMap':[ + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'NUM' + } + ] + }, + 'computeFunction:of:':{ + 'opcode':'operator_mathop', + 'argMap':[ + { + 'type':'input', + 'inputOp':'operator_mathop_menu', + 'inputName':'OPERATOR' + }, + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'NUM' + } + ] + }, + 'readVariable':{ + 'opcode':'data_variable', + 'argMap':[ + { + 'type':'input', + 'inputOp':'data_variablemenu', + 'inputName':'VARIABLE' + } + ] + }, + 'setVar:to:':{ + 'opcode':'data_setvariableto', + 'argMap':[ + { + 'type':'input', + 'inputOp':'data_variablemenu', + 'inputName':'VARIABLE' + }, + { + 'type':'input', + 'inputOp':'text', + 'inputName':'VALUE' + } + ] + }, + 'changeVar:by:':{ + 'opcode':'data_changevariableby', + 'argMap':[ + { + 'type':'input', + 'inputOp':'data_variablemenu', + 'inputName':'VARIABLE' + }, + { + 'type':'input', + 'inputOp':'math_number', + 'inputName':'VALUE' + } + ] + }, + 'showVariable:':{ + 'opcode':'data_showvariable', + 'argMap':[ + { + 'type':'input', + 'inputOp':'data_variablemenu', + 'inputName':'VARIABLE' + } + ] + }, + 'hideVariable:':{ + 'opcode':'data_hidevariable', + 'argMap':[ + { + 'type':'input', + 'inputOp':'data_variablemenu', + 'inputName':'VARIABLE' + } + ] + }, + 'append:toList:':{ + 'opcode':'data_listadd', + 'argMap':[ + { + 'type':'input', + 'inputOp':'text', + 'inputName':'VALUE' + }, + { + 'type':'field', + 'fieldName':'LIST' + } + ] + }, + 'deleteLine:ofList:':{ + 'opcode':'data_listdelete', + 'argMap':[ + { + 'type':'input', + 'inputOp':'text', + 'inputName':'LINE' + }, + { + 'type':'field', + 'fieldName':'LIST' + } + ] + }, + 'insert:at:ofList:':{ + 'opcode':'data_listinsert', + 'argMap':[ + { + 'type':'input', + 'inputOp':'text', + 'inputName':'VALUE' + }, + { + 'type':'input', + 'inputOp':'text', + 'inputName':'LINE' + }, + { + 'type':'field', + 'fieldName':'LIST' + } + ] + }, + 'setLine:ofList:to:':{ + 'opcode':'data_listreplace', + 'argMap':[ + { + 'type':'input', + 'inputOp':'text', + 'inputName':'LINE' + }, + { + 'type':'field', + 'fieldName':'LIST' + }, + { + 'type':'input', + 'inputOp':'text', + 'inputName':'VALUE' + } + ] + }, + 'getLine:ofList:':{ + 'opcode':'data_listitem', + 'argMap':[ + { + 'type':'input', + 'inputOp':'text', + 'inputName':'LINE' + }, + { + 'type':'field', + 'fieldName':'LIST' + } + ] + }, + 'lineCountOfList:':{ + 'opcode':'data_listlength', + 'argMap':[ + { + 'type':'field', + 'fieldName':'LIST' + } + ] + }, + 'list:contains:':{ + 'opcode':'data_listcontains', + 'argMap':[ + { + 'type':'field', + 'fieldName':'LIST' + }, + { + 'type':'input', + 'inputOp':'text', + 'inputName':'VALUE' + } + ] + }, + 'showList:':{ + 'opcode':'data_showlist', + 'argMap':[ + { + 'type':'field', + 'fieldName':'LIST' + } + ] + }, + 'hideList:':{ + 'opcode':'data_hidelist', + 'argMap':[ + { + 'type':'field', + 'fieldName':'LIST' + } + ] + }, + 'procDef':{ + 'opcode':'proc_def', + 'argMap':[] + }, + 'getParam':{ + 'opcode':'proc_param', + 'argMap':[] + }, + 'call':{ + 'opcode':'proc_call', + 'argMap':[] + } }; - - module.exports = Scratch3SensingBlocks; + module.exports = specMap; /***/ } diff --git a/vm.min.js b/vm.min.js index 3b039864b..ce44c7510 100644 --- a/vm.min.js +++ b/vm.min.js @@ -1,11 +1,11 @@ -!function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){function n(){var t=this;i.call(t);var e=new s;e.createClone();var r=[e.clones[0]];t.exampleSprite=e,t.runtime=new a(r),t.blockListener=e.blocks.generateBlockListener(!1,t.runtime),t.flyoutBlockListener=e.blocks.generateBlockListener(!0,t.runtime),t.runtime.on(a.STACK_GLOW_ON,function(e){t.emit(a.STACK_GLOW_ON,{id:e})}),t.runtime.on(a.STACK_GLOW_OFF,function(e){t.emit(a.STACK_GLOW_OFF,{id:e})}),t.runtime.on(a.BLOCK_GLOW_ON,function(e){t.emit(a.BLOCK_GLOW_ON,{id:e})}),t.runtime.on(a.BLOCK_GLOW_OFF,function(e){t.emit(a.BLOCK_GLOW_OFF,{id:e})}),t.runtime.on(a.VISUAL_REPORT,function(e,r){t.emit(a.VISUAL_REPORT,{id:e,value:r})})}var i=r(1),o=r(2),s=r(6),a=r(61),c="function"==typeof importScripts;o.inherits(n,i),n.prototype.start=function(){this.runtime.start()},n.prototype.greenFlag=function(){this.runtime.greenFlag()},n.prototype.stopAll=function(){this.runtime.stopAll()},n.prototype.getPlaygroundData=function(){this.emit("playgroundData",{blocks:this.exampleSprite.blocks,threads:this.runtime.threads})},n.prototype.animationFrame=function(){this.runtime.animationFrame()},n.prototype.postIOData=function(t,e){this.runtime.ioDevices[t]&&this.runtime.ioDevices[t].postData(e)},c&&(self.importScripts("./node_modules/scratch-render/render-worker.js"),self.renderer=new self.RenderWebGLWorker,self.vmInstance=new n,self.onmessage=function(t){var e=t.data;switch(e.method){case"start":self.vmInstance.runtime.start();break;case"greenFlag":self.vmInstance.runtime.greenFlag();break;case"stopAll":self.vmInstance.runtime.stopAll();break;case"blockListener":self.vmInstance.blockListener(e.args);break;case"flyoutBlockListener":self.vmInstance.flyoutBlockListener(e.args);break;case"getPlaygroundData":self.postMessage({method:"playgroundData",blocks:self.vmInstance.exampleSprite.blocks,threads:self.vmInstance.runtime.threads});break;case"animationFrame":self.vmInstance.animationFrame();break;case"postIOData":self.vmInstance.postIOData(e.device,e.data);break;default:"RendererConnected"==t.data.id,self.renderer.onmessage(t)}},self.vmInstance.runtime.on(a.STACK_GLOW_ON,function(t){self.postMessage({method:a.STACK_GLOW_ON,id:t})}),self.vmInstance.runtime.on(a.STACK_GLOW_OFF,function(t){self.postMessage({method:a.STACK_GLOW_OFF,id:t})}),self.vmInstance.runtime.on(a.BLOCK_GLOW_ON,function(t){self.postMessage({method:a.BLOCK_GLOW_ON,id:t})}),self.vmInstance.runtime.on(a.BLOCK_GLOW_OFF,function(t){self.postMessage({method:a.BLOCK_GLOW_OFF,id:t})}),self.vmInstance.runtime.on(a.VISUAL_REPORT,function(t,e){self.postMessage({method:a.VISUAL_REPORT,id:t,value:e})})),t.exports=n,"undefined"!=typeof window&&(window.VirtualMachine=t.exports)},function(t,e){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function n(t){return"function"==typeof t}function i(t){return"number"==typeof t}function o(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(t){if(!i(t)||0>t||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},r.prototype.emit=function(t){var e,r,i,a,c,u;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[t],s(r))return!1;if(n(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),r.apply(this,a)}else if(o(r))for(a=Array.prototype.slice.call(arguments,1),u=r.slice(),i=u.length,c=0;i>c;c++)u[c].apply(this,a);return!0},r.prototype.addListener=function(t,e){var i;if(!n(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,n(e.listener)?e.listener:e),this._events[t]?o(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,o(this._events[t])&&!this._events[t].warned&&(i=s(this._maxListeners)?r.defaultMaxListeners:this._maxListeners,i&&i>0&&this._events[t].length>i&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){function r(){this.removeListener(t,r),i||(i=!0,e.apply(this,arguments))}if(!n(e))throw TypeError("listener must be a function");var i=!1;return r.listener=e,this.on(t,r),this},r.prototype.removeListener=function(t,e){var r,i,s,a;if(!n(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],s=r.length,i=-1,r===e||n(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(a=s;a-- >0;)if(r[a]===e||r[a].listener&&r[a].listener===e){i=a;break}if(0>i)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(i,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},r.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],n(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},r.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?n(this._events[t])?[this._events[t]]:this._events[t].slice():[]},r.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(n(e))return 1;if(e)return e.length}return 0},r.listenerCount=function(t,e){return t.listenerCount(e)}},function(t,e,r){(function(t,n){function i(t,r){var n={seen:[],stylize:s};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),g(r)?n.showHidden=r:r&&e._extend(n,r),w(n.showHidden)&&(n.showHidden=!1),w(n.depth)&&(n.depth=2),w(n.colors)&&(n.colors=!1),w(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=o),c(n,t,n.depth)}function o(t,e){var r=i.styles[e];return r?"["+i.colors[r][0]+"m"+t+"["+i.colors[r][1]+"m":t}function s(t,e){return t}function a(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}function c(t,r,n){if(t.customInspect&&r&&T(r.inspect)&&r.inspect!==e.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,t);return y(i)||(i=c(t,i,n)),i}var o=u(t,r);if(o)return o;var s=Object.keys(r),g=a(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(r)),x(r)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return h(r);if(0===s.length){if(T(r)){var _=r.name?": "+r.name:"";return t.stylize("[Function"+_+"]","special")}if(S(r))return t.stylize(RegExp.prototype.toString.call(r),"regexp");if(k(r))return t.stylize(Date.prototype.toString.call(r),"date");if(x(r))return h(r)}var m="",b=!1,v=["{","}"];if(d(r)&&(b=!0,v=["[","]"]),T(r)){var w=r.name?": "+r.name:"";m=" [Function"+w+"]"}if(S(r)&&(m=" "+RegExp.prototype.toString.call(r)),k(r)&&(m=" "+Date.prototype.toUTCString.call(r)),x(r)&&(m=" "+h(r)),0===s.length&&(!b||0==r.length))return v[0]+m+v[1];if(0>n)return S(r)?t.stylize(RegExp.prototype.toString.call(r),"regexp"):t.stylize("[Object]","special");t.seen.push(r);var E;return E=b?l(t,r,n,g,s):s.map(function(e){return p(t,r,n,g,e,b)}),t.seen.pop(),f(E,m,v)}function u(t,e){if(w(e))return t.stylize("undefined","undefined");if(y(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}return b(e)?t.stylize(""+e,"number"):g(e)?t.stylize(""+e,"boolean"):_(e)?t.stylize("null","null"):void 0}function h(t){return"["+Error.prototype.toString.call(t)+"]"}function l(t,e,r,n,i){for(var o=[],s=0,a=e.length;a>s;++s)R(e,String(s))?o.push(p(t,e,r,n,String(s),!0)):o.push("");return i.forEach(function(i){i.match(/^\d+$/)||o.push(p(t,e,r,n,i,!0))}),o}function p(t,e,r,n,i,o){var s,a,u;if(u=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]},u.get?a=u.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):u.set&&(a=t.stylize("[Setter]","special")),R(n,i)||(s="["+i+"]"),a||(t.seen.indexOf(u.value)<0?(a=_(r)?c(t,u.value,null):c(t,u.value,r-1),a.indexOf("\n")>-1&&(a=o?a.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+a.split("\n").map(function(t){return" "+t}).join("\n"))):a=t.stylize("[Circular]","special")),w(s)){if(o&&i.match(/^\d+$/))return a;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=t.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=t.stylize(s,"string"))}return s+": "+a}function f(t,e,r){var n=0,i=t.reduce(function(t,e){return n++,e.indexOf("\n")>=0&&n++,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1]:r[0]+e+" "+t.join(", ")+" "+r[1]}function d(t){return Array.isArray(t)}function g(t){return"boolean"==typeof t}function _(t){return null===t}function m(t){return null==t}function b(t){return"number"==typeof t}function y(t){return"string"==typeof t}function v(t){return"symbol"==typeof t}function w(t){return void 0===t}function S(t){return E(t)&&"[object RegExp]"===L(t)}function E(t){return"object"==typeof t&&null!==t}function k(t){return E(t)&&"[object Date]"===L(t)}function x(t){return E(t)&&("[object Error]"===L(t)||t instanceof Error)}function T(t){return"function"==typeof t}function A(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||"undefined"==typeof t}function L(t){return Object.prototype.toString.call(t)}function I(t){return 10>t?"0"+t.toString(10):t.toString(10)}function D(){var t=new Date,e=[I(t.getHours()),I(t.getMinutes()),I(t.getSeconds())].join(":");return[t.getDate(),C[t.getMonth()],e].join(" ")}function R(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var N=/%[sdj%]/g;e.format=function(t){if(!y(t)){for(var e=[],r=0;r<arguments.length;r++)e.push(i(arguments[r]));return e.join(" ")}for(var r=1,n=arguments,o=n.length,s=String(t).replace(N,function(t){if("%%"===t)return"%";if(r>=o)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return t}}),a=n[r];o>r;a=n[++r])s+=_(a)||!E(a)?" "+a:" "+i(a);return s},e.deprecate=function(r,i){function o(){if(!s){if(n.throwDeprecation)throw new Error(i);n.traceDeprecation?console.trace(i):console.error(i),s=!0}return r.apply(this,arguments)}if(w(t.process))return function(){return e.deprecate(r,i).apply(this,arguments)};if(n.noDeprecation===!0)return r;var s=!1;return o};var O,B={};e.debuglog=function(t){if(w(O)&&(O=n.env.NODE_DEBUG||""),t=t.toUpperCase(),!B[t])if(new RegExp("\\b"+t+"\\b","i").test(O)){var r=n.pid;B[t]=function(){var n=e.format.apply(e,arguments);console.error("%s %d: %s",t,r,n)}}else B[t]=function(){};return B[t]},e.inspect=i,i.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},i.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=d,e.isBoolean=g,e.isNull=_,e.isNullOrUndefined=m,e.isNumber=b,e.isString=y,e.isSymbol=v,e.isUndefined=w,e.isRegExp=S,e.isObject=E,e.isDate=k,e.isError=x,e.isFunction=T,e.isPrimitive=A,e.isBuffer=r(4);var C=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];e.log=function(){console.log("%s - %s",D(),e.format.apply(e,arguments))},e.inherits=r(5),e._extend=function(t,e){if(!e||!E(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}).call(e,function(){return this}(),r(3))},function(t,e){function r(){u&&s&&(u=!1,s.length?c=s.concat(c):h=-1,c.length&&n())}function n(){if(!u){var t=setTimeout(r);u=!0;for(var e=c.length;e;){for(s=c,c=[];++h<e;)s&&s[h].run();h=-1,e=c.length}s=null,u=!1,clearTimeout(t)}}function i(t,e){this.fun=t,this.array=e}function o(){}var s,a=t.exports={},c=[],u=!1,h=-1;a.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];c.push(new i(t,e)),1!==c.length||u||setTimeout(n,0)},i.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=o,a.addListener=o,a.once=o,a.off=o,a.removeListener=o,a.removeAllListeners=o,a.emit=o,a.binding=function(t){throw new Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(t){throw new Error("process.chdir is not supported")},a.umask=function(){return 0}},function(t,e){t.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},function(t,e){"function"==typeof Object.create?t.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},function(t,e,r){function n(t){t||(t=new o),this.blocks=t,this.clones=[]}var i=r(7),o=r(10);n.prototype.createClone=function(){var t=new i(this.blocks);return this.clones.push(t),t},t.exports=n},function(t,e,r){function n(t){s.call(this,t),this.renderer=null,"undefined"!=typeof self&&self.renderer&&(this.renderer=self.renderer),this.drawableID=null,this.initDrawable()}var i=r(2),o=r(8),s=r(9);i.inherits(n,s),n.prototype.initDrawable=function(){if(this.renderer){var t=this.renderer.createDrawable(),e=this;t.then(function(t){e.drawableID=t})}},n.prototype.x=0,n.prototype.y=0,n.prototype.direction=90,n.prototype.visible=!0,n.prototype.size=100,n.prototype.effects={color:0,fisheye:0,whirl:0,pixelate:0,mosaic:0,brightness:0,ghost:0},n.prototype.setXY=function(t,e){this.x=t,this.y=e,this.renderer&&this.renderer.updateDrawableProperties(this.drawableID,{position:[this.x,this.y]})},n.prototype.setDirection=function(t){this.direction=o.wrapClamp(t,-179,180),this.renderer&&this.renderer.updateDrawableProperties(this.drawableID,{direction:this.direction})},n.prototype.setSay=function(t,e){return t&&e?void console.log("Setting say bubble:",t,e):void console.log("Clearing say bubble")},n.prototype.setVisible=function(t){this.visible=t,this.renderer&&this.renderer.updateDrawableProperties(this.drawableID,{visible:this.visible})},n.prototype.setSize=function(t){this.size=o.clamp(t,5,535),this.renderer&&this.renderer.updateDrawableProperties(this.drawableID,{scale:[this.size,this.size]})},n.prototype.setEffect=function(t,e){if(this.effects[t]=e,this.renderer){var r={};r[t]=this.effects[t],this.renderer.updateDrawableProperties(this.drawableID,r)}},n.prototype.clearEffects=function(){for(var t in this.effects)this.effects[t]=0;this.renderer&&this.renderer.updateDrawableProperties(this.drawableID,this.effects)},t.exports=n},function(t,e){function r(){}r.degToRad=function(t){return Math.PI*(90-t)/180},r.radToDeg=function(t){return 180*t/Math.PI},r.clamp=function(t,e,r){return Math.min(Math.max(t,e),r)},r.wrapClamp=function(t,e,r){var n=r-e+1;return t-Math.floor((t-e)/n)*n},t.exports=r},function(t,e,r){function n(t){t||(t=new i(this)),this.blocks=t}var i=r(10);t.exports=n},function(t,e,r){function n(){this._blocks={},this._scripts=[]}var i=r(11);n.BRANCH_INPUT_PREFIX="SUBSTACK",n.prototype.getBlock=function(t){return this._blocks[t]},n.prototype.getScripts=function(){return this._scripts},n.prototype.getNextBlock=function(t){return"undefined"==typeof this._blocks[t]?null:this._blocks[t].next},n.prototype.getBranch=function(t,e){var r=this._blocks[t];if("undefined"==typeof r)return null;e||(e=1);var i=n.BRANCH_INPUT_PREFIX;return e>1&&(i+=e),i in r.inputs?r.inputs[i].block:null},n.prototype.getOpcode=function(t){return"undefined"==typeof this._blocks[t]?null:this._blocks[t].opcode},n.prototype.getFields=function(t){return"undefined"==typeof this._blocks[t]?null:this._blocks[t].fields},n.prototype.getInputs=function(t){if("undefined"==typeof this._blocks[t])return null;var e={};for(var r in this._blocks[t].inputs)r.substring(0,n.BRANCH_INPUT_PREFIX.length)!=n.BRANCH_INPUT_PREFIX&&(e[r]=this._blocks[t].inputs[r]);return e},n.prototype.generateBlockListener=function(t,e){var r=this;return function(n){if("object"==typeof n&&"string"==typeof n.blockId){if("stackclick"===n.element)return void(e&&e.toggleScript(n.blockId));switch(n.type){case"create":for(var o=i(n),s=0;s<o.length;s++)r.createBlock(o[s],t);break;case"change":r.changeBlock({id:n.blockId,element:n.element,name:n.name,value:n.newValue});break;case"move":r.moveBlock({id:n.blockId,oldParent:n.oldParentId,oldInput:n.oldInputName,newParent:n.newParentId,newInput:n.newInputName});break;case"delete":r.deleteBlock({id:n.blockId})}}}},n.prototype.createBlock=function(t,e){this._blocks[t.id]=t,!e&&t.topLevel&&this._addScript(t.id)},n.prototype.changeBlock=function(t){"field"===t.element&&"undefined"!=typeof this._blocks[t.id]&&"undefined"!=typeof this._blocks[t.id].fields[t.name]&&(this._blocks[t.id].fields[t.name].value=t.value)},n.prototype.moveBlock=function(t){if(void 0!==t.oldParent){var e=this._blocks[t.oldParent];void 0!==t.oldInput&&e.inputs[t.oldInput].block===t.id?e.inputs[t.oldInput].block=null:e.next===t.id&&(e.next=null)}void 0===t.newParent?this._addScript(t.id):(this._deleteScript(t.id),void 0!==t.newInput?this._blocks[t.newParent].inputs[t.newInput]={name:t.newInput,block:t.id}:this._blocks[t.newParent].next=t.id)},n.prototype.deleteBlock=function(t){var e=this._blocks[t.id];null!==e.next&&this.deleteBlock({id:e.next});for(var r in e.inputs)null!==e.inputs[r].block&&this.deleteBlock({id:e.inputs[r].block});this._deleteScript(t.id),delete this._blocks[t.id]},n.prototype._addScript=function(t){var e=this._scripts.indexOf(t);e>-1||(this._scripts.push(t),this._blocks[t].topLevel=!0)},n.prototype._deleteScript=function(t){var e=this._scripts.indexOf(t);e>-1&&this._scripts.splice(e,1),this._blocks[t]&&(this._blocks[t].topLevel=!1)},t.exports=n},function(t,e,r){function n(t){for(var e={},r=0;r<t.length;r++){var n=t[r];if(n.name&&n.attribs){var o=n.name.toLowerCase();"block"!=o&&"shadow"!=o||i(n,e,!0)}}var s=[];for(var a in e)s.push(e[a]);return s}function i(t,e,r){var n={id:t.attribs.id,opcode:t.attribs.type,inputs:{},fields:{},next:null,topLevel:r};e[n.id]=n;for(var o=0;o<t.children.length;o++){for(var s=t.children[o],a=null,c=null,u=0;u<s.children.length;u++){var h=s.children[u];if(h.name){var l=h.name.toLowerCase();"block"==l?a=h:"shadow"==l&&(c=h)}}switch(!a&&c&&(a=c),s.name.toLowerCase()){case"field":var p=s.attribs.name,f="";f=s.children.length>0&&s.children[0].data?s.children[0].data:"",n.fields[p]={name:p,value:f};break;case"value":case"statement":i(a,e,!1);var d=s.attribs.name;n.inputs[d]={name:d,block:a.attribs.id};break;case"next":if(!a||!a.attribs)continue;i(a,e,!1),n.next=a.attribs.id}}}var o=r(12);t.exports=function(t){return"object"==typeof t&&"object"==typeof t.xml?n(o.parseDOM(t.xml.outerHTML)):void 0}},function(t,e,r){function n(e,r){return delete t.exports[e],t.exports[e]=r,r}var i=r(13),o=r(20);t.exports={Parser:i,Tokenizer:r(14),ElementType:r(21),DomHandler:o,get FeedHandler(){return n("FeedHandler",r(24))},get Stream(){return n("Stream",r(25))},get WritableStream(){return n("WritableStream",r(26))},get ProxyHandler(){return n("ProxyHandler",r(47))},get DomUtils(){return n("DomUtils",r(48))},get CollectingHandler(){return n("CollectingHandler",r(60))},DefaultHandler:o,get RssHandler(){return n("RssHandler",this.FeedHandler)},parseDOM:function(t,e){var r=new o(e);return new i(r,e).end(t),r.dom},parseFeed:function(e,r){var n=new t.exports.FeedHandler(r);return new i(n,r).end(e),n.dom},createDomStream:function(t,e,r){var n=new o(t,e,r);return new i(n,e)},EVENTS:{attribute:2,cdatastart:0,cdataend:0,text:1,processinginstruction:2,comment:1,commentend:0,closetag:1,opentag:2,opentagname:1,error:1,end:0}}},function(t,e,r){function n(t,e){this._options=e||{},this._cbs=t||{},this._tagname="",this._attribname="",this._attribvalue="",this._attribs=null,this._stack=[],this.startIndex=0,this.endIndex=null,this._lowerCaseTagNames="lowerCaseTags"in this._options?!!this._options.lowerCaseTags:!this._options.xmlMode,this._lowerCaseAttributeNames="lowerCaseAttributeNames"in this._options?!!this._options.lowerCaseAttributeNames:!this._options.xmlMode,this._options.Tokenizer&&(i=this._options.Tokenizer),this._tokenizer=new i(this._options,this),this._cbs.onparserinit&&this._cbs.onparserinit(this)}var i=r(14),o={input:!0,option:!0,optgroup:!0,select:!0,button:!0,datalist:!0,textarea:!0},s={tr:{tr:!0,th:!0,td:!0},th:{th:!0},td:{thead:!0,th:!0,td:!0},body:{head:!0,link:!0,script:!0},li:{li:!0},p:{p:!0},h1:{p:!0},h2:{p:!0},h3:{p:!0},h4:{p:!0},h5:{p:!0},h6:{p:!0},select:o,input:o,output:o,button:o,datalist:o,textarea:o,option:{option:!0},optgroup:{optgroup:!0}},a={__proto__:null,area:!0,base:!0,basefont:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,isindex:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,path:!0,circle:!0,ellipse:!0,line:!0,rect:!0,use:!0,stop:!0,polyline:!0,polygon:!0},c=/\s|\//;r(2).inherits(n,r(1).EventEmitter),n.prototype._updatePosition=function(t){null===this.endIndex?this._tokenizer._sectionStart<=t?this.startIndex=0:this.startIndex=this._tokenizer._sectionStart-t:this.startIndex=this.endIndex+1,this.endIndex=this._tokenizer.getAbsoluteIndex()},n.prototype.ontext=function(t){this._updatePosition(1),this.endIndex--,this._cbs.ontext&&this._cbs.ontext(t)},n.prototype.onopentagname=function(t){if(this._lowerCaseTagNames&&(t=t.toLowerCase()),this._tagname=t,!this._options.xmlMode&&t in s)for(var e;(e=this._stack[this._stack.length-1])in s[t];this.onclosetag(e));!this._options.xmlMode&&t in a||this._stack.push(t),this._cbs.onopentagname&&this._cbs.onopentagname(t),this._cbs.onopentag&&(this._attribs={})},n.prototype.onopentagend=function(){this._updatePosition(1),this._attribs&&(this._cbs.onopentag&&this._cbs.onopentag(this._tagname,this._attribs),this._attribs=null),!this._options.xmlMode&&this._cbs.onclosetag&&this._tagname in a&&this._cbs.onclosetag(this._tagname),this._tagname=""},n.prototype.onclosetag=function(t){if(this._updatePosition(1),this._lowerCaseTagNames&&(t=t.toLowerCase()),!this._stack.length||t in a&&!this._options.xmlMode)this._options.xmlMode||"br"!==t&&"p"!==t||(this.onopentagname(t),this._closeCurrentTag());else{var e=this._stack.lastIndexOf(t);if(-1!==e)if(this._cbs.onclosetag)for(e=this._stack.length-e;e--;)this._cbs.onclosetag(this._stack.pop());else this._stack.length=e;else"p"!==t||this._options.xmlMode||(this.onopentagname(t),this._closeCurrentTag())}},n.prototype.onselfclosingtag=function(){this._options.xmlMode||this._options.recognizeSelfClosing?this._closeCurrentTag():this.onopentagend()},n.prototype._closeCurrentTag=function(){var t=this._tagname;this.onopentagend(),this._stack[this._stack.length-1]===t&&(this._cbs.onclosetag&&this._cbs.onclosetag(t),this._stack.pop())},n.prototype.onattribname=function(t){this._lowerCaseAttributeNames&&(t=t.toLowerCase()),this._attribname=t},n.prototype.onattribdata=function(t){this._attribvalue+=t},n.prototype.onattribend=function(){this._cbs.onattribute&&this._cbs.onattribute(this._attribname,this._attribvalue),this._attribs&&!Object.prototype.hasOwnProperty.call(this._attribs,this._attribname)&&(this._attribs[this._attribname]=this._attribvalue),this._attribname="",this._attribvalue=""},n.prototype._getInstructionName=function(t){var e=t.search(c),r=0>e?t:t.substr(0,e);return this._lowerCaseTagNames&&(r=r.toLowerCase()),r},n.prototype.ondeclaration=function(t){if(this._cbs.onprocessinginstruction){var e=this._getInstructionName(t);this._cbs.onprocessinginstruction("!"+e,"!"+t)}},n.prototype.onprocessinginstruction=function(t){if(this._cbs.onprocessinginstruction){var e=this._getInstructionName(t);this._cbs.onprocessinginstruction("?"+e,"?"+t)}},n.prototype.oncomment=function(t){this._updatePosition(4),this._cbs.oncomment&&this._cbs.oncomment(t),this._cbs.oncommentend&&this._cbs.oncommentend()},n.prototype.oncdata=function(t){this._updatePosition(1),this._options.xmlMode||this._options.recognizeCDATA?(this._cbs.oncdatastart&&this._cbs.oncdatastart(),this._cbs.ontext&&this._cbs.ontext(t),this._cbs.oncdataend&&this._cbs.oncdataend()):this.oncomment("[CDATA["+t+"]]")},n.prototype.onerror=function(t){this._cbs.onerror&&this._cbs.onerror(t)},n.prototype.onend=function(){if(this._cbs.onclosetag)for(var t=this._stack.length;t>0;this._cbs.onclosetag(this._stack[--t]));this._cbs.onend&&this._cbs.onend()},n.prototype.reset=function(){this._cbs.onreset&&this._cbs.onreset(),this._tokenizer.reset(),this._tagname="",this._attribname="",this._attribs=null,this._stack=[],this._cbs.onparserinit&&this._cbs.onparserinit(this)},n.prototype.parseComplete=function(t){this.reset(),this.end(t)},n.prototype.write=function(t){this._tokenizer.write(t)},n.prototype.end=function(t){this._tokenizer.end(t)},n.prototype.pause=function(){this._tokenizer.pause()},n.prototype.resume=function(){this._tokenizer.resume()},n.prototype.parseChunk=n.prototype.write,n.prototype.done=n.prototype.end,t.exports=n},function(t,e,r){function n(t){return" "===t||"\n"===t||" "===t||"\f"===t||"\r"===t}function i(t,e){return function(r){r===t&&(this._state=e)}}function o(t,e,r){var n=t.toLowerCase();return t===n?function(t){t===n?this._state=e:(this._state=r,this._index--)}:function(i){i===n||i===t?this._state=e:(this._state=r,this._index--)}}function s(t,e){var r=t.toLowerCase();return function(n){n===r||n===t?this._state=e:(this._state=g,this._index--)}}function a(t,e){this._state=f,this._buffer="",this._sectionStart=0,this._index=0,this._bufferOffset=0,this._baseState=f,this._special=gt,this._cbs=e,this._running=!0,this._ended=!1,this._xmlMode=!(!t||!t.xmlMode),this._decodeEntities=!(!t||!t.decodeEntities)}t.exports=a;var c=r(15),u=r(17),h=r(18),l=r(19),p=0,f=p++,d=p++,g=p++,_=p++,m=p++,b=p++,y=p++,v=p++,w=p++,S=p++,E=p++,k=p++,x=p++,T=p++,A=p++,L=p++,I=p++,D=p++,R=p++,N=p++,O=p++,B=p++,C=p++,M=p++,q=p++,P=p++,U=p++,F=p++,j=p++,G=p++,Y=p++,V=p++,z=p++,H=p++,W=p++,X=p++,K=p++,J=p++,Q=p++,Z=p++,$=p++,tt=p++,et=p++,rt=p++,nt=p++,it=p++,ot=p++,st=p++,at=p++,ct=p++,ut=p++,ht=p++,lt=p++,pt=p++,ft=p++,dt=0,gt=dt++,_t=dt++,mt=dt++;a.prototype._stateText=function(t){"<"===t?(this._index>this._sectionStart&&this._cbs.ontext(this._getSection()),this._state=d,this._sectionStart=this._index):this._decodeEntities&&this._special===gt&&"&"===t&&(this._index>this._sectionStart&&this._cbs.ontext(this._getSection()),this._baseState=f,this._state=ut,this._sectionStart=this._index)},a.prototype._stateBeforeTagName=function(t){"/"===t?this._state=m:">"===t||this._special!==gt||n(t)?this._state=f:"!"===t?(this._state=A,this._sectionStart=this._index+1):"?"===t?(this._state=I,this._sectionStart=this._index+1):"<"===t?(this._cbs.ontext(this._getSection()),this._sectionStart=this._index):(this._state=this._xmlMode||"s"!==t&&"S"!==t?g:Y,this._sectionStart=this._index)},a.prototype._stateInTagName=function(t){("/"===t||">"===t||n(t))&&(this._emitToken("onopentagname"),this._state=v,this._index--)},a.prototype._stateBeforeCloseingTagName=function(t){n(t)||(">"===t?this._state=f:this._special!==gt?"s"===t||"S"===t?this._state=V:(this._state=f,this._index--):(this._state=b,this._sectionStart=this._index))},a.prototype._stateInCloseingTagName=function(t){(">"===t||n(t))&&(this._emitToken("onclosetag"),this._state=y,this._index--)},a.prototype._stateAfterCloseingTagName=function(t){">"===t&&(this._state=f,this._sectionStart=this._index+1)},a.prototype._stateBeforeAttributeName=function(t){">"===t?(this._cbs.onopentagend(),this._state=f,this._sectionStart=this._index+1):"/"===t?this._state=_:n(t)||(this._state=w,this._sectionStart=this._index)},a.prototype._stateInSelfClosingTag=function(t){">"===t?(this._cbs.onselfclosingtag(),this._state=f,this._sectionStart=this._index+1):n(t)||(this._state=v,this._index--)},a.prototype._stateInAttributeName=function(t){("="===t||"/"===t||">"===t||n(t))&&(this._cbs.onattribname(this._getSection()),this._sectionStart=-1,this._state=S,this._index--)},a.prototype._stateAfterAttributeName=function(t){"="===t?this._state=E:"/"===t||">"===t?(this._cbs.onattribend(),this._state=v,this._index--):n(t)||(this._cbs.onattribend(),this._state=w,this._sectionStart=this._index)},a.prototype._stateBeforeAttributeValue=function(t){'"'===t?(this._state=k,this._sectionStart=this._index+1):"'"===t?(this._state=x,this._sectionStart=this._index+1):n(t)||(this._state=T,this._sectionStart=this._index,this._index--)},a.prototype._stateInAttributeValueDoubleQuotes=function(t){'"'===t?(this._emitToken("onattribdata"),this._cbs.onattribend(),this._state=v):this._decodeEntities&&"&"===t&&(this._emitToken("onattribdata"),this._baseState=this._state,this._state=ut,this._sectionStart=this._index)},a.prototype._stateInAttributeValueSingleQuotes=function(t){"'"===t?(this._emitToken("onattribdata"),this._cbs.onattribend(),this._state=v):this._decodeEntities&&"&"===t&&(this._emitToken("onattribdata"),this._baseState=this._state,this._state=ut,this._sectionStart=this._index)},a.prototype._stateInAttributeValueNoQuotes=function(t){n(t)||">"===t?(this._emitToken("onattribdata"),this._cbs.onattribend(),this._state=v,this._index--):this._decodeEntities&&"&"===t&&(this._emitToken("onattribdata"),this._baseState=this._state,this._state=ut,this._sectionStart=this._index)},a.prototype._stateBeforeDeclaration=function(t){this._state="["===t?B:"-"===t?D:L},a.prototype._stateInDeclaration=function(t){">"===t&&(this._cbs.ondeclaration(this._getSection()),this._state=f,this._sectionStart=this._index+1)},a.prototype._stateInProcessingInstruction=function(t){">"===t&&(this._cbs.onprocessinginstruction(this._getSection()),this._state=f,this._sectionStart=this._index+1)},a.prototype._stateBeforeComment=function(t){"-"===t?(this._state=R,this._sectionStart=this._index+1):this._state=L},a.prototype._stateInComment=function(t){"-"===t&&(this._state=N)},a.prototype._stateAfterComment1=function(t){"-"===t?this._state=O:this._state=R},a.prototype._stateAfterComment2=function(t){">"===t?(this._cbs.oncomment(this._buffer.substring(this._sectionStart,this._index-2)),this._state=f,this._sectionStart=this._index+1):"-"!==t&&(this._state=R)},a.prototype._stateBeforeCdata1=o("C",C,L),a.prototype._stateBeforeCdata2=o("D",M,L),a.prototype._stateBeforeCdata3=o("A",q,L),a.prototype._stateBeforeCdata4=o("T",P,L),a.prototype._stateBeforeCdata5=o("A",U,L),a.prototype._stateBeforeCdata6=function(t){"["===t?(this._state=F,this._sectionStart=this._index+1):(this._state=L,this._index--)},a.prototype._stateInCdata=function(t){"]"===t&&(this._state=j)},a.prototype._stateAfterCdata1=i("]",G),a.prototype._stateAfterCdata2=function(t){">"===t?(this._cbs.oncdata(this._buffer.substring(this._sectionStart,this._index-2)),this._state=f,this._sectionStart=this._index+1):"]"!==t&&(this._state=F)},a.prototype._stateBeforeSpecial=function(t){"c"===t||"C"===t?this._state=z:"t"===t||"T"===t?this._state=et:(this._state=g, -this._index--)},a.prototype._stateBeforeSpecialEnd=function(t){this._special!==_t||"c"!==t&&"C"!==t?this._special!==mt||"t"!==t&&"T"!==t?this._state=f:this._state=ot:this._state=J},a.prototype._stateBeforeScript1=s("R",H),a.prototype._stateBeforeScript2=s("I",W),a.prototype._stateBeforeScript3=s("P",X),a.prototype._stateBeforeScript4=s("T",K),a.prototype._stateBeforeScript5=function(t){("/"===t||">"===t||n(t))&&(this._special=_t),this._state=g,this._index--},a.prototype._stateAfterScript1=o("R",Q,f),a.prototype._stateAfterScript2=o("I",Z,f),a.prototype._stateAfterScript3=o("P",$,f),a.prototype._stateAfterScript4=o("T",tt,f),a.prototype._stateAfterScript5=function(t){">"===t||n(t)?(this._special=gt,this._state=b,this._sectionStart=this._index-6,this._index--):this._state=f},a.prototype._stateBeforeStyle1=s("Y",rt),a.prototype._stateBeforeStyle2=s("L",nt),a.prototype._stateBeforeStyle3=s("E",it),a.prototype._stateBeforeStyle4=function(t){("/"===t||">"===t||n(t))&&(this._special=mt),this._state=g,this._index--},a.prototype._stateAfterStyle1=o("Y",st,f),a.prototype._stateAfterStyle2=o("L",at,f),a.prototype._stateAfterStyle3=o("E",ct,f),a.prototype._stateAfterStyle4=function(t){">"===t||n(t)?(this._special=gt,this._state=b,this._sectionStart=this._index-5,this._index--):this._state=f},a.prototype._stateBeforeEntity=o("#",ht,lt),a.prototype._stateBeforeNumericEntity=o("X",ft,pt),a.prototype._parseNamedEntityStrict=function(){if(this._sectionStart+1<this._index){var t=this._buffer.substring(this._sectionStart+1,this._index),e=this._xmlMode?l:u;e.hasOwnProperty(t)&&(this._emitPartial(e[t]),this._sectionStart=this._index+1)}},a.prototype._parseLegacyEntity=function(){var t=this._sectionStart+1,e=this._index-t;for(e>6&&(e=6);e>=2;){var r=this._buffer.substr(t,e);if(h.hasOwnProperty(r))return this._emitPartial(h[r]),void(this._sectionStart+=e+1);e--}},a.prototype._stateInNamedEntity=function(t){";"===t?(this._parseNamedEntityStrict(),this._sectionStart+1<this._index&&!this._xmlMode&&this._parseLegacyEntity(),this._state=this._baseState):("a">t||t>"z")&&("A">t||t>"Z")&&("0">t||t>"9")&&(this._xmlMode||this._sectionStart+1===this._index||(this._baseState!==f?"="!==t&&this._parseNamedEntityStrict():this._parseLegacyEntity()),this._state=this._baseState,this._index--)},a.prototype._decodeNumericEntity=function(t,e){var r=this._sectionStart+t;if(r!==this._index){var n=this._buffer.substring(r,this._index),i=parseInt(n,e);this._emitPartial(c(i)),this._sectionStart=this._index}else this._sectionStart--;this._state=this._baseState},a.prototype._stateInNumericEntity=function(t){";"===t?(this._decodeNumericEntity(2,10),this._sectionStart++):("0">t||t>"9")&&(this._xmlMode?this._state=this._baseState:this._decodeNumericEntity(2,10),this._index--)},a.prototype._stateInHexEntity=function(t){";"===t?(this._decodeNumericEntity(3,16),this._sectionStart++):("a">t||t>"f")&&("A">t||t>"F")&&("0">t||t>"9")&&(this._xmlMode?this._state=this._baseState:this._decodeNumericEntity(3,16),this._index--)},a.prototype._cleanup=function(){this._sectionStart<0?(this._buffer="",this._index=0,this._bufferOffset+=this._index):this._running&&(this._state===f?(this._sectionStart!==this._index&&this._cbs.ontext(this._buffer.substr(this._sectionStart)),this._buffer="",this._index=0,this._bufferOffset+=this._index):this._sectionStart===this._index?(this._buffer="",this._index=0,this._bufferOffset+=this._index):(this._buffer=this._buffer.substr(this._sectionStart),this._index-=this._sectionStart,this._bufferOffset+=this._sectionStart),this._sectionStart=0)},a.prototype.write=function(t){this._ended&&this._cbs.onerror(Error(".write() after done!")),this._buffer+=t,this._parse()},a.prototype._parse=function(){for(;this._index<this._buffer.length&&this._running;){var t=this._buffer.charAt(this._index);this._state===f?this._stateText(t):this._state===d?this._stateBeforeTagName(t):this._state===g?this._stateInTagName(t):this._state===m?this._stateBeforeCloseingTagName(t):this._state===b?this._stateInCloseingTagName(t):this._state===y?this._stateAfterCloseingTagName(t):this._state===_?this._stateInSelfClosingTag(t):this._state===v?this._stateBeforeAttributeName(t):this._state===w?this._stateInAttributeName(t):this._state===S?this._stateAfterAttributeName(t):this._state===E?this._stateBeforeAttributeValue(t):this._state===k?this._stateInAttributeValueDoubleQuotes(t):this._state===x?this._stateInAttributeValueSingleQuotes(t):this._state===T?this._stateInAttributeValueNoQuotes(t):this._state===A?this._stateBeforeDeclaration(t):this._state===L?this._stateInDeclaration(t):this._state===I?this._stateInProcessingInstruction(t):this._state===D?this._stateBeforeComment(t):this._state===R?this._stateInComment(t):this._state===N?this._stateAfterComment1(t):this._state===O?this._stateAfterComment2(t):this._state===B?this._stateBeforeCdata1(t):this._state===C?this._stateBeforeCdata2(t):this._state===M?this._stateBeforeCdata3(t):this._state===q?this._stateBeforeCdata4(t):this._state===P?this._stateBeforeCdata5(t):this._state===U?this._stateBeforeCdata6(t):this._state===F?this._stateInCdata(t):this._state===j?this._stateAfterCdata1(t):this._state===G?this._stateAfterCdata2(t):this._state===Y?this._stateBeforeSpecial(t):this._state===V?this._stateBeforeSpecialEnd(t):this._state===z?this._stateBeforeScript1(t):this._state===H?this._stateBeforeScript2(t):this._state===W?this._stateBeforeScript3(t):this._state===X?this._stateBeforeScript4(t):this._state===K?this._stateBeforeScript5(t):this._state===J?this._stateAfterScript1(t):this._state===Q?this._stateAfterScript2(t):this._state===Z?this._stateAfterScript3(t):this._state===$?this._stateAfterScript4(t):this._state===tt?this._stateAfterScript5(t):this._state===et?this._stateBeforeStyle1(t):this._state===rt?this._stateBeforeStyle2(t):this._state===nt?this._stateBeforeStyle3(t):this._state===it?this._stateBeforeStyle4(t):this._state===ot?this._stateAfterStyle1(t):this._state===st?this._stateAfterStyle2(t):this._state===at?this._stateAfterStyle3(t):this._state===ct?this._stateAfterStyle4(t):this._state===ut?this._stateBeforeEntity(t):this._state===ht?this._stateBeforeNumericEntity(t):this._state===lt?this._stateInNamedEntity(t):this._state===pt?this._stateInNumericEntity(t):this._state===ft?this._stateInHexEntity(t):this._cbs.onerror(Error("unknown _state"),this._state),this._index++}this._cleanup()},a.prototype.pause=function(){this._running=!1},a.prototype.resume=function(){this._running=!0,this._index<this._buffer.length&&this._parse(),this._ended&&this._finish()},a.prototype.end=function(t){this._ended&&this._cbs.onerror(Error(".end() after done!")),t&&this.write(t),this._ended=!0,this._running&&this._finish()},a.prototype._finish=function(){this._sectionStart<this._index&&this._handleTrailingData(),this._cbs.onend()},a.prototype._handleTrailingData=function(){var t=this._buffer.substr(this._sectionStart);this._state===F||this._state===j||this._state===G?this._cbs.oncdata(t):this._state===R||this._state===N||this._state===O?this._cbs.oncomment(t):this._state!==lt||this._xmlMode?this._state!==pt||this._xmlMode?this._state!==ft||this._xmlMode?this._state!==g&&this._state!==v&&this._state!==E&&this._state!==S&&this._state!==w&&this._state!==x&&this._state!==k&&this._state!==T&&this._state!==b&&this._cbs.ontext(t):(this._decodeNumericEntity(3,16),this._sectionStart<this._index&&(this._state=this._baseState,this._handleTrailingData())):(this._decodeNumericEntity(2,10),this._sectionStart<this._index&&(this._state=this._baseState,this._handleTrailingData())):(this._parseLegacyEntity(),this._sectionStart<this._index&&(this._state=this._baseState,this._handleTrailingData()))},a.prototype.reset=function(){a.call(this,{xmlMode:this._xmlMode,decodeEntities:this._decodeEntities},this._cbs)},a.prototype.getAbsoluteIndex=function(){return this._bufferOffset+this._index},a.prototype._getSection=function(){return this._buffer.substring(this._sectionStart,this._index)},a.prototype._emitToken=function(t){this._cbs[t](this._getSection()),this._sectionStart=-1},a.prototype._emitPartial=function(t){this._baseState!==f?this._cbs.onattribdata(t):this._cbs.ontext(t)}},function(t,e,r){function n(t){if(t>=55296&&57343>=t||t>1114111)return"�";t in i&&(t=i[t]);var e="";return t>65535&&(t-=65536,e+=String.fromCharCode(t>>>10&1023|55296),t=56320|1023&t),e+=String.fromCharCode(t)}var i=r(16);t.exports=n},function(t,e){t.exports={0:65533,128:8364,130:8218,131:402,132:8222,133:8230,134:8224,135:8225,136:710,137:8240,138:352,139:8249,140:338,142:381,145:8216,146:8217,147:8220,148:8221,149:8226,150:8211,151:8212,152:732,153:8482,154:353,155:8250,156:339,158:382,159:376}},function(t,e){t.exports={Aacute:"Á",aacute:"á",Abreve:"Ă",abreve:"ă",ac:"∾",acd:"∿",acE:"∾̳",Acirc:"Â",acirc:"â",acute:"´",Acy:"А",acy:"а",AElig:"Æ",aelig:"æ",af:"",Afr:"𝔄",afr:"𝔞",Agrave:"À",agrave:"à",alefsym:"ℵ",aleph:"ℵ",Alpha:"Α",alpha:"α",Amacr:"Ā",amacr:"ā",amalg:"⨿",amp:"&",AMP:"&",andand:"⩕",And:"⩓",and:"∧",andd:"⩜",andslope:"⩘",andv:"⩚",ang:"∠",ange:"⦤",angle:"∠",angmsdaa:"⦨",angmsdab:"⦩",angmsdac:"⦪",angmsdad:"⦫",angmsdae:"⦬",angmsdaf:"⦭",angmsdag:"⦮",angmsdah:"⦯",angmsd:"∡",angrt:"∟",angrtvb:"⊾",angrtvbd:"⦝",angsph:"∢",angst:"Å",angzarr:"⍼",Aogon:"Ą",aogon:"ą",Aopf:"𝔸",aopf:"𝕒",apacir:"⩯",ap:"≈",apE:"⩰",ape:"≊",apid:"≋",apos:"'",ApplyFunction:"",approx:"≈",approxeq:"≊",Aring:"Å",aring:"å",Ascr:"𝒜",ascr:"𝒶",Assign:"≔",ast:"*",asymp:"≈",asympeq:"≍",Atilde:"Ã",atilde:"ã",Auml:"Ä",auml:"ä",awconint:"∳",awint:"⨑",backcong:"≌",backepsilon:"϶",backprime:"‵",backsim:"∽",backsimeq:"⋍",Backslash:"∖",Barv:"⫧",barvee:"⊽",barwed:"⌅",Barwed:"⌆",barwedge:"⌅",bbrk:"⎵",bbrktbrk:"⎶",bcong:"≌",Bcy:"Б",bcy:"б",bdquo:"„",becaus:"∵",because:"∵",Because:"∵",bemptyv:"⦰",bepsi:"϶",bernou:"ℬ",Bernoullis:"ℬ",Beta:"Β",beta:"β",beth:"ℶ",between:"≬",Bfr:"𝔅",bfr:"𝔟",bigcap:"⋂",bigcirc:"◯",bigcup:"⋃",bigodot:"⨀",bigoplus:"⨁",bigotimes:"⨂",bigsqcup:"⨆",bigstar:"★",bigtriangledown:"▽",bigtriangleup:"△",biguplus:"⨄",bigvee:"⋁",bigwedge:"⋀",bkarow:"⤍",blacklozenge:"⧫",blacksquare:"▪",blacktriangle:"▴",blacktriangledown:"▾",blacktriangleleft:"◂",blacktriangleright:"▸",blank:"␣",blk12:"▒",blk14:"░",blk34:"▓",block:"█",bne:"=⃥",bnequiv:"≡⃥",bNot:"⫭",bnot:"⌐",Bopf:"𝔹",bopf:"𝕓",bot:"⊥",bottom:"⊥",bowtie:"⋈",boxbox:"⧉",boxdl:"┐",boxdL:"╕",boxDl:"╖",boxDL:"╗",boxdr:"┌",boxdR:"╒",boxDr:"╓",boxDR:"╔",boxh:"─",boxH:"═",boxhd:"┬",boxHd:"╤",boxhD:"╥",boxHD:"╦",boxhu:"┴",boxHu:"╧",boxhU:"╨",boxHU:"╩",boxminus:"⊟",boxplus:"⊞",boxtimes:"⊠",boxul:"┘",boxuL:"╛",boxUl:"╜",boxUL:"╝",boxur:"└",boxuR:"╘",boxUr:"╙",boxUR:"╚",boxv:"│",boxV:"║",boxvh:"┼",boxvH:"╪",boxVh:"╫",boxVH:"╬",boxvl:"┤",boxvL:"╡",boxVl:"╢",boxVL:"╣",boxvr:"├",boxvR:"╞",boxVr:"╟",boxVR:"╠",bprime:"‵",breve:"˘",Breve:"˘",brvbar:"¦",bscr:"𝒷",Bscr:"ℬ",bsemi:"⁏",bsim:"∽",bsime:"⋍",bsolb:"⧅",bsol:"\\",bsolhsub:"⟈",bull:"•",bullet:"•",bump:"≎",bumpE:"⪮",bumpe:"≏",Bumpeq:"≎",bumpeq:"≏",Cacute:"Ć",cacute:"ć",capand:"⩄",capbrcup:"⩉",capcap:"⩋",cap:"∩",Cap:"⋒",capcup:"⩇",capdot:"⩀",CapitalDifferentialD:"ⅅ",caps:"∩︀",caret:"⁁",caron:"ˇ",Cayleys:"ℭ",ccaps:"⩍",Ccaron:"Č",ccaron:"č",Ccedil:"Ç",ccedil:"ç",Ccirc:"Ĉ",ccirc:"ĉ",Cconint:"∰",ccups:"⩌",ccupssm:"⩐",Cdot:"Ċ",cdot:"ċ",cedil:"¸",Cedilla:"¸",cemptyv:"⦲",cent:"¢",centerdot:"·",CenterDot:"·",cfr:"𝔠",Cfr:"ℭ",CHcy:"Ч",chcy:"ч",check:"✓",checkmark:"✓",Chi:"Χ",chi:"χ",circ:"ˆ",circeq:"≗",circlearrowleft:"↺",circlearrowright:"↻",circledast:"⊛",circledcirc:"⊚",circleddash:"⊝",CircleDot:"⊙",circledR:"®",circledS:"Ⓢ",CircleMinus:"⊖",CirclePlus:"⊕",CircleTimes:"⊗",cir:"○",cirE:"⧃",cire:"≗",cirfnint:"⨐",cirmid:"⫯",cirscir:"⧂",ClockwiseContourIntegral:"∲",CloseCurlyDoubleQuote:"”",CloseCurlyQuote:"’",clubs:"♣",clubsuit:"♣",colon:":",Colon:"∷",Colone:"⩴",colone:"≔",coloneq:"≔",comma:",",commat:"@",comp:"∁",compfn:"∘",complement:"∁",complexes:"ℂ",cong:"≅",congdot:"⩭",Congruent:"≡",conint:"∮",Conint:"∯",ContourIntegral:"∮",copf:"𝕔",Copf:"ℂ",coprod:"∐",Coproduct:"∐",copy:"©",COPY:"©",copysr:"℗",CounterClockwiseContourIntegral:"∳",crarr:"↵",cross:"✗",Cross:"⨯",Cscr:"𝒞",cscr:"𝒸",csub:"⫏",csube:"⫑",csup:"⫐",csupe:"⫒",ctdot:"⋯",cudarrl:"⤸",cudarrr:"⤵",cuepr:"⋞",cuesc:"⋟",cularr:"↶",cularrp:"⤽",cupbrcap:"⩈",cupcap:"⩆",CupCap:"≍",cup:"∪",Cup:"⋓",cupcup:"⩊",cupdot:"⊍",cupor:"⩅",cups:"∪︀",curarr:"↷",curarrm:"⤼",curlyeqprec:"⋞",curlyeqsucc:"⋟",curlyvee:"⋎",curlywedge:"⋏",curren:"¤",curvearrowleft:"↶",curvearrowright:"↷",cuvee:"⋎",cuwed:"⋏",cwconint:"∲",cwint:"∱",cylcty:"⌭",dagger:"†",Dagger:"‡",daleth:"ℸ",darr:"↓",Darr:"↡",dArr:"⇓",dash:"‐",Dashv:"⫤",dashv:"⊣",dbkarow:"⤏",dblac:"˝",Dcaron:"Ď",dcaron:"ď",Dcy:"Д",dcy:"д",ddagger:"‡",ddarr:"⇊",DD:"ⅅ",dd:"ⅆ",DDotrahd:"⤑",ddotseq:"⩷",deg:"°",Del:"∇",Delta:"Δ",delta:"δ",demptyv:"⦱",dfisht:"⥿",Dfr:"𝔇",dfr:"𝔡",dHar:"⥥",dharl:"⇃",dharr:"⇂",DiacriticalAcute:"´",DiacriticalDot:"˙",DiacriticalDoubleAcute:"˝",DiacriticalGrave:"`",DiacriticalTilde:"˜",diam:"⋄",diamond:"⋄",Diamond:"⋄",diamondsuit:"♦",diams:"♦",die:"¨",DifferentialD:"ⅆ",digamma:"ϝ",disin:"⋲",div:"÷",divide:"÷",divideontimes:"⋇",divonx:"⋇",DJcy:"Ђ",djcy:"ђ",dlcorn:"⌞",dlcrop:"⌍",dollar:"$",Dopf:"𝔻",dopf:"𝕕",Dot:"¨",dot:"˙",DotDot:"⃜",doteq:"≐",doteqdot:"≑",DotEqual:"≐",dotminus:"∸",dotplus:"∔",dotsquare:"⊡",doublebarwedge:"⌆",DoubleContourIntegral:"∯",DoubleDot:"¨",DoubleDownArrow:"⇓",DoubleLeftArrow:"⇐",DoubleLeftRightArrow:"⇔",DoubleLeftTee:"⫤",DoubleLongLeftArrow:"⟸",DoubleLongLeftRightArrow:"⟺",DoubleLongRightArrow:"⟹",DoubleRightArrow:"⇒",DoubleRightTee:"⊨",DoubleUpArrow:"⇑",DoubleUpDownArrow:"⇕",DoubleVerticalBar:"∥",DownArrowBar:"⤓",downarrow:"↓",DownArrow:"↓",Downarrow:"⇓",DownArrowUpArrow:"⇵",DownBreve:"̑",downdownarrows:"⇊",downharpoonleft:"⇃",downharpoonright:"⇂",DownLeftRightVector:"⥐",DownLeftTeeVector:"⥞",DownLeftVectorBar:"⥖",DownLeftVector:"↽",DownRightTeeVector:"⥟",DownRightVectorBar:"⥗",DownRightVector:"⇁",DownTeeArrow:"↧",DownTee:"⊤",drbkarow:"⤐",drcorn:"⌟",drcrop:"⌌",Dscr:"𝒟",dscr:"𝒹",DScy:"Ѕ",dscy:"ѕ",dsol:"⧶",Dstrok:"Đ",dstrok:"đ",dtdot:"⋱",dtri:"▿",dtrif:"▾",duarr:"⇵",duhar:"⥯",dwangle:"⦦",DZcy:"Џ",dzcy:"џ",dzigrarr:"⟿",Eacute:"É",eacute:"é",easter:"⩮",Ecaron:"Ě",ecaron:"ě",Ecirc:"Ê",ecirc:"ê",ecir:"≖",ecolon:"≕",Ecy:"Э",ecy:"э",eDDot:"⩷",Edot:"Ė",edot:"ė",eDot:"≑",ee:"ⅇ",efDot:"≒",Efr:"𝔈",efr:"𝔢",eg:"⪚",Egrave:"È",egrave:"è",egs:"⪖",egsdot:"⪘",el:"⪙",Element:"∈",elinters:"⏧",ell:"ℓ",els:"⪕",elsdot:"⪗",Emacr:"Ē",emacr:"ē",empty:"∅",emptyset:"∅",EmptySmallSquare:"◻",emptyv:"∅",EmptyVerySmallSquare:"▫",emsp13:" ",emsp14:" ",emsp:" ",ENG:"Ŋ",eng:"ŋ",ensp:" ",Eogon:"Ę",eogon:"ę",Eopf:"𝔼",eopf:"𝕖",epar:"⋕",eparsl:"⧣",eplus:"⩱",epsi:"ε",Epsilon:"Ε",epsilon:"ε",epsiv:"ϵ",eqcirc:"≖",eqcolon:"≕",eqsim:"≂",eqslantgtr:"⪖",eqslantless:"⪕",Equal:"⩵",equals:"=",EqualTilde:"≂",equest:"≟",Equilibrium:"⇌",equiv:"≡",equivDD:"⩸",eqvparsl:"⧥",erarr:"⥱",erDot:"≓",escr:"ℯ",Escr:"ℰ",esdot:"≐",Esim:"⩳",esim:"≂",Eta:"Η",eta:"η",ETH:"Ð",eth:"ð",Euml:"Ë",euml:"ë",euro:"€",excl:"!",exist:"∃",Exists:"∃",expectation:"ℰ",exponentiale:"ⅇ",ExponentialE:"ⅇ",fallingdotseq:"≒",Fcy:"Ф",fcy:"ф",female:"♀",ffilig:"ffi",fflig:"ff",ffllig:"ffl",Ffr:"𝔉",ffr:"𝔣",filig:"fi",FilledSmallSquare:"◼",FilledVerySmallSquare:"▪",fjlig:"fj",flat:"♭",fllig:"fl",fltns:"▱",fnof:"ƒ",Fopf:"𝔽",fopf:"𝕗",forall:"∀",ForAll:"∀",fork:"⋔",forkv:"⫙",Fouriertrf:"ℱ",fpartint:"⨍",frac12:"½",frac13:"⅓",frac14:"¼",frac15:"⅕",frac16:"⅙",frac18:"⅛",frac23:"⅔",frac25:"⅖",frac34:"¾",frac35:"⅗",frac38:"⅜",frac45:"⅘",frac56:"⅚",frac58:"⅝",frac78:"⅞",frasl:"⁄",frown:"⌢",fscr:"𝒻",Fscr:"ℱ",gacute:"ǵ",Gamma:"Γ",gamma:"γ",Gammad:"Ϝ",gammad:"ϝ",gap:"⪆",Gbreve:"Ğ",gbreve:"ğ",Gcedil:"Ģ",Gcirc:"Ĝ",gcirc:"ĝ",Gcy:"Г",gcy:"г",Gdot:"Ġ",gdot:"ġ",ge:"≥",gE:"≧",gEl:"⪌",gel:"⋛",geq:"≥",geqq:"≧",geqslant:"⩾",gescc:"⪩",ges:"⩾",gesdot:"⪀",gesdoto:"⪂",gesdotol:"⪄",gesl:"⋛︀",gesles:"⪔",Gfr:"𝔊",gfr:"𝔤",gg:"≫",Gg:"⋙",ggg:"⋙",gimel:"ℷ",GJcy:"Ѓ",gjcy:"ѓ",gla:"⪥",gl:"≷",glE:"⪒",glj:"⪤",gnap:"⪊",gnapprox:"⪊",gne:"⪈",gnE:"≩",gneq:"⪈",gneqq:"≩",gnsim:"⋧",Gopf:"𝔾",gopf:"𝕘",grave:"`",GreaterEqual:"≥",GreaterEqualLess:"⋛",GreaterFullEqual:"≧",GreaterGreater:"⪢",GreaterLess:"≷",GreaterSlantEqual:"⩾",GreaterTilde:"≳",Gscr:"𝒢",gscr:"ℊ",gsim:"≳",gsime:"⪎",gsiml:"⪐",gtcc:"⪧",gtcir:"⩺",gt:">",GT:">",Gt:"≫",gtdot:"⋗",gtlPar:"⦕",gtquest:"⩼",gtrapprox:"⪆",gtrarr:"⥸",gtrdot:"⋗",gtreqless:"⋛",gtreqqless:"⪌",gtrless:"≷",gtrsim:"≳",gvertneqq:"≩︀",gvnE:"≩︀",Hacek:"ˇ",hairsp:" ",half:"½",hamilt:"ℋ",HARDcy:"Ъ",hardcy:"ъ",harrcir:"⥈",harr:"↔",hArr:"⇔",harrw:"↭",Hat:"^",hbar:"ℏ",Hcirc:"Ĥ",hcirc:"ĥ",hearts:"♥",heartsuit:"♥",hellip:"…",hercon:"⊹",hfr:"𝔥",Hfr:"ℌ",HilbertSpace:"ℋ",hksearow:"⤥",hkswarow:"⤦",hoarr:"⇿",homtht:"∻",hookleftarrow:"↩",hookrightarrow:"↪",hopf:"𝕙",Hopf:"ℍ",horbar:"―",HorizontalLine:"─",hscr:"𝒽",Hscr:"ℋ",hslash:"ℏ",Hstrok:"Ħ",hstrok:"ħ",HumpDownHump:"≎",HumpEqual:"≏",hybull:"⁃",hyphen:"‐",Iacute:"Í",iacute:"í",ic:"",Icirc:"Î",icirc:"î",Icy:"И",icy:"и",Idot:"İ",IEcy:"Е",iecy:"е",iexcl:"¡",iff:"⇔",ifr:"𝔦",Ifr:"ℑ",Igrave:"Ì",igrave:"ì",ii:"ⅈ",iiiint:"⨌",iiint:"∭",iinfin:"⧜",iiota:"℩",IJlig:"IJ",ijlig:"ij",Imacr:"Ī",imacr:"ī",image:"ℑ",ImaginaryI:"ⅈ",imagline:"ℐ",imagpart:"ℑ",imath:"ı",Im:"ℑ",imof:"⊷",imped:"Ƶ",Implies:"⇒",incare:"℅","in":"∈",infin:"∞",infintie:"⧝",inodot:"ı",intcal:"⊺","int":"∫",Int:"∬",integers:"ℤ",Integral:"∫",intercal:"⊺",Intersection:"⋂",intlarhk:"⨗",intprod:"⨼",InvisibleComma:"",InvisibleTimes:"",IOcy:"Ё",iocy:"ё",Iogon:"Į",iogon:"į",Iopf:"𝕀",iopf:"𝕚",Iota:"Ι",iota:"ι",iprod:"⨼",iquest:"¿",iscr:"𝒾",Iscr:"ℐ",isin:"∈",isindot:"⋵",isinE:"⋹",isins:"⋴",isinsv:"⋳",isinv:"∈",it:"",Itilde:"Ĩ",itilde:"ĩ",Iukcy:"І",iukcy:"і",Iuml:"Ï",iuml:"ï",Jcirc:"Ĵ",jcirc:"ĵ",Jcy:"Й",jcy:"й",Jfr:"𝔍",jfr:"𝔧",jmath:"ȷ",Jopf:"𝕁",jopf:"𝕛",Jscr:"𝒥",jscr:"𝒿",Jsercy:"Ј",jsercy:"ј",Jukcy:"Є",jukcy:"є",Kappa:"Κ",kappa:"κ",kappav:"ϰ",Kcedil:"Ķ",kcedil:"ķ",Kcy:"К",kcy:"к",Kfr:"𝔎",kfr:"𝔨",kgreen:"ĸ",KHcy:"Х",khcy:"х",KJcy:"Ќ",kjcy:"ќ",Kopf:"𝕂",kopf:"𝕜",Kscr:"𝒦",kscr:"𝓀",lAarr:"⇚",Lacute:"Ĺ",lacute:"ĺ",laemptyv:"⦴",lagran:"ℒ",Lambda:"Λ",lambda:"λ",lang:"⟨",Lang:"⟪",langd:"⦑",langle:"⟨",lap:"⪅",Laplacetrf:"ℒ",laquo:"«",larrb:"⇤",larrbfs:"⤟",larr:"←",Larr:"↞",lArr:"⇐",larrfs:"⤝",larrhk:"↩",larrlp:"↫",larrpl:"⤹",larrsim:"⥳",larrtl:"↢",latail:"⤙",lAtail:"⤛",lat:"⪫",late:"⪭",lates:"⪭︀",lbarr:"⤌",lBarr:"⤎",lbbrk:"❲",lbrace:"{",lbrack:"[",lbrke:"⦋",lbrksld:"⦏",lbrkslu:"⦍",Lcaron:"Ľ",lcaron:"ľ",Lcedil:"Ļ",lcedil:"ļ",lceil:"⌈",lcub:"{",Lcy:"Л",lcy:"л",ldca:"⤶",ldquo:"“",ldquor:"„",ldrdhar:"⥧",ldrushar:"⥋",ldsh:"↲",le:"≤",lE:"≦",LeftAngleBracket:"⟨",LeftArrowBar:"⇤",leftarrow:"←",LeftArrow:"←",Leftarrow:"⇐",LeftArrowRightArrow:"⇆",leftarrowtail:"↢",LeftCeiling:"⌈",LeftDoubleBracket:"⟦",LeftDownTeeVector:"⥡",LeftDownVectorBar:"⥙",LeftDownVector:"⇃",LeftFloor:"⌊",leftharpoondown:"↽",leftharpoonup:"↼",leftleftarrows:"⇇",leftrightarrow:"↔",LeftRightArrow:"↔",Leftrightarrow:"⇔",leftrightarrows:"⇆",leftrightharpoons:"⇋",leftrightsquigarrow:"↭",LeftRightVector:"⥎",LeftTeeArrow:"↤",LeftTee:"⊣",LeftTeeVector:"⥚",leftthreetimes:"⋋",LeftTriangleBar:"⧏",LeftTriangle:"⊲",LeftTriangleEqual:"⊴",LeftUpDownVector:"⥑",LeftUpTeeVector:"⥠",LeftUpVectorBar:"⥘",LeftUpVector:"↿",LeftVectorBar:"⥒",LeftVector:"↼",lEg:"⪋",leg:"⋚",leq:"≤",leqq:"≦",leqslant:"⩽",lescc:"⪨",les:"⩽",lesdot:"⩿",lesdoto:"⪁",lesdotor:"⪃",lesg:"⋚︀",lesges:"⪓",lessapprox:"⪅",lessdot:"⋖",lesseqgtr:"⋚",lesseqqgtr:"⪋",LessEqualGreater:"⋚",LessFullEqual:"≦",LessGreater:"≶",lessgtr:"≶",LessLess:"⪡",lesssim:"≲",LessSlantEqual:"⩽",LessTilde:"≲",lfisht:"⥼",lfloor:"⌊",Lfr:"𝔏",lfr:"𝔩",lg:"≶",lgE:"⪑",lHar:"⥢",lhard:"↽",lharu:"↼",lharul:"⥪",lhblk:"▄",LJcy:"Љ",ljcy:"љ",llarr:"⇇",ll:"≪",Ll:"⋘",llcorner:"⌞",Lleftarrow:"⇚",llhard:"⥫",lltri:"◺",Lmidot:"Ŀ",lmidot:"ŀ",lmoustache:"⎰",lmoust:"⎰",lnap:"⪉",lnapprox:"⪉",lne:"⪇",lnE:"≨",lneq:"⪇",lneqq:"≨",lnsim:"⋦",loang:"⟬",loarr:"⇽",lobrk:"⟦",longleftarrow:"⟵",LongLeftArrow:"⟵",Longleftarrow:"⟸",longleftrightarrow:"⟷",LongLeftRightArrow:"⟷",Longleftrightarrow:"⟺",longmapsto:"⟼",longrightarrow:"⟶",LongRightArrow:"⟶",Longrightarrow:"⟹",looparrowleft:"↫",looparrowright:"↬",lopar:"⦅",Lopf:"𝕃",lopf:"𝕝",loplus:"⨭",lotimes:"⨴",lowast:"∗",lowbar:"_",LowerLeftArrow:"↙",LowerRightArrow:"↘",loz:"◊",lozenge:"◊",lozf:"⧫",lpar:"(",lparlt:"⦓",lrarr:"⇆",lrcorner:"⌟",lrhar:"⇋",lrhard:"⥭",lrm:"",lrtri:"⊿",lsaquo:"‹",lscr:"𝓁",Lscr:"ℒ",lsh:"↰",Lsh:"↰",lsim:"≲",lsime:"⪍",lsimg:"⪏",lsqb:"[",lsquo:"‘",lsquor:"‚",Lstrok:"Ł",lstrok:"ł",ltcc:"⪦",ltcir:"⩹",lt:"<",LT:"<",Lt:"≪",ltdot:"⋖",lthree:"⋋",ltimes:"⋉",ltlarr:"⥶",ltquest:"⩻",ltri:"◃",ltrie:"⊴",ltrif:"◂",ltrPar:"⦖",lurdshar:"⥊",luruhar:"⥦",lvertneqq:"≨︀",lvnE:"≨︀",macr:"¯",male:"♂",malt:"✠",maltese:"✠",Map:"⤅",map:"↦",mapsto:"↦",mapstodown:"↧",mapstoleft:"↤",mapstoup:"↥",marker:"▮",mcomma:"⨩",Mcy:"М",mcy:"м",mdash:"—",mDDot:"∺",measuredangle:"∡",MediumSpace:" ",Mellintrf:"ℳ",Mfr:"𝔐",mfr:"𝔪",mho:"℧",micro:"µ",midast:"*",midcir:"⫰",mid:"∣",middot:"·",minusb:"⊟",minus:"−",minusd:"∸",minusdu:"⨪",MinusPlus:"∓",mlcp:"⫛",mldr:"…",mnplus:"∓",models:"⊧",Mopf:"𝕄",mopf:"𝕞",mp:"∓",mscr:"𝓂",Mscr:"ℳ",mstpos:"∾",Mu:"Μ",mu:"μ",multimap:"⊸",mumap:"⊸",nabla:"∇",Nacute:"Ń",nacute:"ń",nang:"∠⃒",nap:"≉",napE:"⩰̸",napid:"≋̸",napos:"ʼn",napprox:"≉",natural:"♮",naturals:"ℕ",natur:"♮",nbsp:" ",nbump:"≎̸",nbumpe:"≏̸",ncap:"⩃",Ncaron:"Ň",ncaron:"ň",Ncedil:"Ņ",ncedil:"ņ",ncong:"≇",ncongdot:"⩭̸",ncup:"⩂",Ncy:"Н",ncy:"н",ndash:"–",nearhk:"⤤",nearr:"↗",neArr:"⇗",nearrow:"↗",ne:"≠",nedot:"≐̸",NegativeMediumSpace:"",NegativeThickSpace:"",NegativeThinSpace:"",NegativeVeryThinSpace:"",nequiv:"≢",nesear:"⤨",nesim:"≂̸",NestedGreaterGreater:"≫",NestedLessLess:"≪",NewLine:"\n",nexist:"∄",nexists:"∄",Nfr:"𝔑",nfr:"𝔫",ngE:"≧̸",nge:"≱",ngeq:"≱",ngeqq:"≧̸",ngeqslant:"⩾̸",nges:"⩾̸",nGg:"⋙̸",ngsim:"≵",nGt:"≫⃒",ngt:"≯",ngtr:"≯",nGtv:"≫̸",nharr:"↮",nhArr:"⇎",nhpar:"⫲",ni:"∋",nis:"⋼",nisd:"⋺",niv:"∋",NJcy:"Њ",njcy:"њ",nlarr:"↚",nlArr:"⇍",nldr:"‥",nlE:"≦̸",nle:"≰",nleftarrow:"↚",nLeftarrow:"⇍",nleftrightarrow:"↮",nLeftrightarrow:"⇎",nleq:"≰",nleqq:"≦̸",nleqslant:"⩽̸",nles:"⩽̸",nless:"≮",nLl:"⋘̸",nlsim:"≴",nLt:"≪⃒",nlt:"≮",nltri:"⋪",nltrie:"⋬",nLtv:"≪̸",nmid:"∤",NoBreak:"",NonBreakingSpace:" ",nopf:"𝕟",Nopf:"ℕ",Not:"⫬",not:"¬",NotCongruent:"≢",NotCupCap:"≭",NotDoubleVerticalBar:"∦",NotElement:"∉",NotEqual:"≠",NotEqualTilde:"≂̸",NotExists:"∄",NotGreater:"≯",NotGreaterEqual:"≱",NotGreaterFullEqual:"≧̸",NotGreaterGreater:"≫̸",NotGreaterLess:"≹",NotGreaterSlantEqual:"⩾̸",NotGreaterTilde:"≵",NotHumpDownHump:"≎̸",NotHumpEqual:"≏̸",notin:"∉",notindot:"⋵̸",notinE:"⋹̸",notinva:"∉",notinvb:"⋷",notinvc:"⋶",NotLeftTriangleBar:"⧏̸",NotLeftTriangle:"⋪",NotLeftTriangleEqual:"⋬",NotLess:"≮",NotLessEqual:"≰",NotLessGreater:"≸",NotLessLess:"≪̸",NotLessSlantEqual:"⩽̸",NotLessTilde:"≴",NotNestedGreaterGreater:"⪢̸",NotNestedLessLess:"⪡̸",notni:"∌",notniva:"∌",notnivb:"⋾",notnivc:"⋽",NotPrecedes:"⊀",NotPrecedesEqual:"⪯̸",NotPrecedesSlantEqual:"⋠",NotReverseElement:"∌",NotRightTriangleBar:"⧐̸",NotRightTriangle:"⋫",NotRightTriangleEqual:"⋭",NotSquareSubset:"⊏̸",NotSquareSubsetEqual:"⋢",NotSquareSuperset:"⊐̸",NotSquareSupersetEqual:"⋣",NotSubset:"⊂⃒",NotSubsetEqual:"⊈",NotSucceeds:"⊁",NotSucceedsEqual:"⪰̸",NotSucceedsSlantEqual:"⋡",NotSucceedsTilde:"≿̸",NotSuperset:"⊃⃒",NotSupersetEqual:"⊉",NotTilde:"≁",NotTildeEqual:"≄",NotTildeFullEqual:"≇",NotTildeTilde:"≉",NotVerticalBar:"∤",nparallel:"∦",npar:"∦",nparsl:"⫽⃥",npart:"∂̸",npolint:"⨔",npr:"⊀",nprcue:"⋠",nprec:"⊀",npreceq:"⪯̸",npre:"⪯̸",nrarrc:"⤳̸",nrarr:"↛",nrArr:"⇏",nrarrw:"↝̸",nrightarrow:"↛",nRightarrow:"⇏",nrtri:"⋫",nrtrie:"⋭",nsc:"⊁",nsccue:"⋡",nsce:"⪰̸",Nscr:"𝒩",nscr:"𝓃",nshortmid:"∤",nshortparallel:"∦",nsim:"≁",nsime:"≄",nsimeq:"≄",nsmid:"∤",nspar:"∦",nsqsube:"⋢",nsqsupe:"⋣",nsub:"⊄",nsubE:"⫅̸",nsube:"⊈",nsubset:"⊂⃒",nsubseteq:"⊈",nsubseteqq:"⫅̸",nsucc:"⊁",nsucceq:"⪰̸",nsup:"⊅",nsupE:"⫆̸",nsupe:"⊉",nsupset:"⊃⃒",nsupseteq:"⊉",nsupseteqq:"⫆̸",ntgl:"≹",Ntilde:"Ñ",ntilde:"ñ",ntlg:"≸",ntriangleleft:"⋪",ntrianglelefteq:"⋬",ntriangleright:"⋫",ntrianglerighteq:"⋭",Nu:"Ν",nu:"ν",num:"#",numero:"№",numsp:" ",nvap:"≍⃒",nvdash:"⊬",nvDash:"⊭",nVdash:"⊮",nVDash:"⊯",nvge:"≥⃒",nvgt:">⃒",nvHarr:"⤄",nvinfin:"⧞",nvlArr:"⤂",nvle:"≤⃒",nvlt:"<⃒",nvltrie:"⊴⃒",nvrArr:"⤃",nvrtrie:"⊵⃒",nvsim:"∼⃒",nwarhk:"⤣",nwarr:"↖",nwArr:"⇖",nwarrow:"↖",nwnear:"⤧",Oacute:"Ó",oacute:"ó",oast:"⊛",Ocirc:"Ô",ocirc:"ô",ocir:"⊚",Ocy:"О",ocy:"о",odash:"⊝",Odblac:"Ő",odblac:"ő",odiv:"⨸",odot:"⊙",odsold:"⦼",OElig:"Œ",oelig:"œ",ofcir:"⦿",Ofr:"𝔒",ofr:"𝔬",ogon:"˛",Ograve:"Ò",ograve:"ò",ogt:"⧁",ohbar:"⦵",ohm:"Ω",oint:"∮",olarr:"↺",olcir:"⦾",olcross:"⦻",oline:"‾",olt:"⧀",Omacr:"Ō",omacr:"ō",Omega:"Ω",omega:"ω",Omicron:"Ο",omicron:"ο",omid:"⦶",ominus:"⊖",Oopf:"𝕆",oopf:"𝕠",opar:"⦷",OpenCurlyDoubleQuote:"“",OpenCurlyQuote:"‘",operp:"⦹",oplus:"⊕",orarr:"↻",Or:"⩔",or:"∨",ord:"⩝",order:"ℴ",orderof:"ℴ",ordf:"ª",ordm:"º",origof:"⊶",oror:"⩖",orslope:"⩗",orv:"⩛",oS:"Ⓢ",Oscr:"𝒪",oscr:"ℴ",Oslash:"Ø",oslash:"ø",osol:"⊘",Otilde:"Õ",otilde:"õ",otimesas:"⨶",Otimes:"⨷",otimes:"⊗",Ouml:"Ö",ouml:"ö",ovbar:"⌽",OverBar:"‾",OverBrace:"⏞",OverBracket:"⎴",OverParenthesis:"⏜",para:"¶",parallel:"∥",par:"∥",parsim:"⫳",parsl:"⫽",part:"∂",PartialD:"∂",Pcy:"П",pcy:"п",percnt:"%",period:".",permil:"‰",perp:"⊥",pertenk:"‱",Pfr:"𝔓",pfr:"𝔭",Phi:"Φ",phi:"φ",phiv:"ϕ",phmmat:"ℳ",phone:"☎",Pi:"Π",pi:"π",pitchfork:"⋔",piv:"ϖ",planck:"ℏ",planckh:"ℎ",plankv:"ℏ",plusacir:"⨣",plusb:"⊞",pluscir:"⨢",plus:"+",plusdo:"∔",plusdu:"⨥",pluse:"⩲",PlusMinus:"±",plusmn:"±",plussim:"⨦",plustwo:"⨧",pm:"±",Poincareplane:"ℌ",pointint:"⨕",popf:"𝕡",Popf:"ℙ",pound:"£",prap:"⪷",Pr:"⪻",pr:"≺",prcue:"≼",precapprox:"⪷",prec:"≺",preccurlyeq:"≼",Precedes:"≺",PrecedesEqual:"⪯",PrecedesSlantEqual:"≼",PrecedesTilde:"≾",preceq:"⪯",precnapprox:"⪹",precneqq:"⪵",precnsim:"⋨",pre:"⪯",prE:"⪳",precsim:"≾",prime:"′",Prime:"″",primes:"ℙ",prnap:"⪹",prnE:"⪵",prnsim:"⋨",prod:"∏",Product:"∏",profalar:"⌮",profline:"⌒",profsurf:"⌓",prop:"∝",Proportional:"∝",Proportion:"∷",propto:"∝",prsim:"≾",prurel:"⊰",Pscr:"𝒫",pscr:"𝓅",Psi:"Ψ",psi:"ψ",puncsp:" ",Qfr:"𝔔",qfr:"𝔮",qint:"⨌",qopf:"𝕢",Qopf:"ℚ",qprime:"⁗",Qscr:"𝒬",qscr:"𝓆",quaternions:"ℍ",quatint:"⨖",quest:"?",questeq:"≟",quot:'"',QUOT:'"',rAarr:"⇛",race:"∽̱",Racute:"Ŕ",racute:"ŕ",radic:"√",raemptyv:"⦳",rang:"⟩",Rang:"⟫",rangd:"⦒",range:"⦥",rangle:"⟩",raquo:"»",rarrap:"⥵",rarrb:"⇥",rarrbfs:"⤠",rarrc:"⤳",rarr:"→",Rarr:"↠",rArr:"⇒",rarrfs:"⤞",rarrhk:"↪",rarrlp:"↬",rarrpl:"⥅",rarrsim:"⥴",Rarrtl:"⤖",rarrtl:"↣",rarrw:"↝",ratail:"⤚",rAtail:"⤜",ratio:"∶",rationals:"ℚ",rbarr:"⤍",rBarr:"⤏",RBarr:"⤐",rbbrk:"❳",rbrace:"}",rbrack:"]",rbrke:"⦌",rbrksld:"⦎",rbrkslu:"⦐",Rcaron:"Ř",rcaron:"ř",Rcedil:"Ŗ",rcedil:"ŗ",rceil:"⌉",rcub:"}",Rcy:"Р",rcy:"р",rdca:"⤷",rdldhar:"⥩",rdquo:"”",rdquor:"”",rdsh:"↳",real:"ℜ",realine:"ℛ",realpart:"ℜ",reals:"ℝ",Re:"ℜ",rect:"▭",reg:"®",REG:"®",ReverseElement:"∋",ReverseEquilibrium:"⇋",ReverseUpEquilibrium:"⥯",rfisht:"⥽",rfloor:"⌋",rfr:"𝔯",Rfr:"ℜ",rHar:"⥤",rhard:"⇁",rharu:"⇀",rharul:"⥬",Rho:"Ρ",rho:"ρ",rhov:"ϱ",RightAngleBracket:"⟩",RightArrowBar:"⇥",rightarrow:"→",RightArrow:"→",Rightarrow:"⇒",RightArrowLeftArrow:"⇄",rightarrowtail:"↣",RightCeiling:"⌉",RightDoubleBracket:"⟧",RightDownTeeVector:"⥝",RightDownVectorBar:"⥕",RightDownVector:"⇂",RightFloor:"⌋",rightharpoondown:"⇁",rightharpoonup:"⇀",rightleftarrows:"⇄",rightleftharpoons:"⇌",rightrightarrows:"⇉",rightsquigarrow:"↝",RightTeeArrow:"↦",RightTee:"⊢",RightTeeVector:"⥛",rightthreetimes:"⋌",RightTriangleBar:"⧐",RightTriangle:"⊳",RightTriangleEqual:"⊵",RightUpDownVector:"⥏",RightUpTeeVector:"⥜",RightUpVectorBar:"⥔",RightUpVector:"↾",RightVectorBar:"⥓",RightVector:"⇀",ring:"˚",risingdotseq:"≓",rlarr:"⇄",rlhar:"⇌",rlm:"",rmoustache:"⎱",rmoust:"⎱",rnmid:"⫮",roang:"⟭",roarr:"⇾",robrk:"⟧",ropar:"⦆",ropf:"𝕣",Ropf:"ℝ",roplus:"⨮",rotimes:"⨵",RoundImplies:"⥰",rpar:")",rpargt:"⦔",rppolint:"⨒",rrarr:"⇉",Rrightarrow:"⇛",rsaquo:"›",rscr:"𝓇",Rscr:"ℛ",rsh:"↱",Rsh:"↱",rsqb:"]",rsquo:"’",rsquor:"’",rthree:"⋌",rtimes:"⋊",rtri:"▹",rtrie:"⊵",rtrif:"▸",rtriltri:"⧎",RuleDelayed:"⧴",ruluhar:"⥨",rx:"℞",Sacute:"Ś",sacute:"ś",sbquo:"‚",scap:"⪸",Scaron:"Š",scaron:"š",Sc:"⪼",sc:"≻",sccue:"≽",sce:"⪰",scE:"⪴",Scedil:"Ş",scedil:"ş",Scirc:"Ŝ",scirc:"ŝ",scnap:"⪺",scnE:"⪶",scnsim:"⋩",scpolint:"⨓",scsim:"≿",Scy:"С",scy:"с",sdotb:"⊡",sdot:"⋅",sdote:"⩦",searhk:"⤥",searr:"↘",seArr:"⇘",searrow:"↘",sect:"§",semi:";",seswar:"⤩",setminus:"∖",setmn:"∖",sext:"✶",Sfr:"𝔖",sfr:"𝔰",sfrown:"⌢",sharp:"♯",SHCHcy:"Щ",shchcy:"щ",SHcy:"Ш",shcy:"ш",ShortDownArrow:"↓",ShortLeftArrow:"←",shortmid:"∣",shortparallel:"∥",ShortRightArrow:"→",ShortUpArrow:"↑",shy:"",Sigma:"Σ",sigma:"σ",sigmaf:"ς",sigmav:"ς",sim:"∼",simdot:"⩪",sime:"≃",simeq:"≃",simg:"⪞",simgE:"⪠",siml:"⪝",simlE:"⪟",simne:"≆",simplus:"⨤",simrarr:"⥲",slarr:"←",SmallCircle:"∘",smallsetminus:"∖",smashp:"⨳",smeparsl:"⧤",smid:"∣",smile:"⌣",smt:"⪪",smte:"⪬",smtes:"⪬︀",SOFTcy:"Ь",softcy:"ь",solbar:"⌿",solb:"⧄",sol:"/",Sopf:"𝕊",sopf:"𝕤",spades:"♠",spadesuit:"♠",spar:"∥",sqcap:"⊓",sqcaps:"⊓︀",sqcup:"⊔",sqcups:"⊔︀",Sqrt:"√",sqsub:"⊏",sqsube:"⊑",sqsubset:"⊏",sqsubseteq:"⊑",sqsup:"⊐",sqsupe:"⊒",sqsupset:"⊐",sqsupseteq:"⊒",square:"□",Square:"□",SquareIntersection:"⊓",SquareSubset:"⊏",SquareSubsetEqual:"⊑",SquareSuperset:"⊐",SquareSupersetEqual:"⊒",SquareUnion:"⊔",squarf:"▪",squ:"□",squf:"▪",srarr:"→",Sscr:"𝒮",sscr:"𝓈",ssetmn:"∖",ssmile:"⌣",sstarf:"⋆",Star:"⋆",star:"☆",starf:"★",straightepsilon:"ϵ",straightphi:"ϕ",strns:"¯",sub:"⊂",Sub:"⋐",subdot:"⪽",subE:"⫅",sube:"⊆",subedot:"⫃",submult:"⫁",subnE:"⫋",subne:"⊊",subplus:"⪿",subrarr:"⥹",subset:"⊂",Subset:"⋐",subseteq:"⊆",subseteqq:"⫅",SubsetEqual:"⊆",subsetneq:"⊊",subsetneqq:"⫋",subsim:"⫇",subsub:"⫕",subsup:"⫓",succapprox:"⪸",succ:"≻",succcurlyeq:"≽",Succeeds:"≻",SucceedsEqual:"⪰",SucceedsSlantEqual:"≽",SucceedsTilde:"≿",succeq:"⪰",succnapprox:"⪺",succneqq:"⪶",succnsim:"⋩",succsim:"≿",SuchThat:"∋",sum:"∑",Sum:"∑",sung:"♪",sup1:"¹",sup2:"²",sup3:"³",sup:"⊃",Sup:"⋑",supdot:"⪾",supdsub:"⫘",supE:"⫆",supe:"⊇",supedot:"⫄",Superset:"⊃",SupersetEqual:"⊇",suphsol:"⟉",suphsub:"⫗",suplarr:"⥻",supmult:"⫂",supnE:"⫌",supne:"⊋",supplus:"⫀",supset:"⊃",Supset:"⋑",supseteq:"⊇",supseteqq:"⫆",supsetneq:"⊋",supsetneqq:"⫌",supsim:"⫈",supsub:"⫔",supsup:"⫖",swarhk:"⤦",swarr:"↙",swArr:"⇙",swarrow:"↙",swnwar:"⤪",szlig:"ß",Tab:" ",target:"⌖",Tau:"Τ",tau:"τ",tbrk:"⎴",Tcaron:"Ť",tcaron:"ť",Tcedil:"Ţ",tcedil:"ţ",Tcy:"Т",tcy:"т",tdot:"⃛",telrec:"⌕",Tfr:"𝔗",tfr:"𝔱",there4:"∴",therefore:"∴",Therefore:"∴",Theta:"Θ",theta:"θ",thetasym:"ϑ",thetav:"ϑ",thickapprox:"≈",thicksim:"∼",ThickSpace:" ",ThinSpace:" ",thinsp:" ",thkap:"≈",thksim:"∼",THORN:"Þ",thorn:"þ",tilde:"˜",Tilde:"∼",TildeEqual:"≃",TildeFullEqual:"≅",TildeTilde:"≈",timesbar:"⨱",timesb:"⊠",times:"×",timesd:"⨰",tint:"∭",toea:"⤨",topbot:"⌶",topcir:"⫱",top:"⊤",Topf:"𝕋",topf:"𝕥",topfork:"⫚",tosa:"⤩",tprime:"‴",trade:"™",TRADE:"™",triangle:"▵",triangledown:"▿",triangleleft:"◃",trianglelefteq:"⊴",triangleq:"≜",triangleright:"▹",trianglerighteq:"⊵",tridot:"◬",trie:"≜",triminus:"⨺",TripleDot:"⃛",triplus:"⨹",trisb:"⧍",tritime:"⨻",trpezium:"⏢",Tscr:"𝒯",tscr:"𝓉",TScy:"Ц",tscy:"ц",TSHcy:"Ћ",tshcy:"ћ",Tstrok:"Ŧ",tstrok:"ŧ",twixt:"≬",twoheadleftarrow:"↞",twoheadrightarrow:"↠",Uacute:"Ú",uacute:"ú",uarr:"↑",Uarr:"↟",uArr:"⇑",Uarrocir:"⥉",Ubrcy:"Ў",ubrcy:"ў",Ubreve:"Ŭ",ubreve:"ŭ",Ucirc:"Û",ucirc:"û",Ucy:"У",ucy:"у",udarr:"⇅",Udblac:"Ű",udblac:"ű",udhar:"⥮",ufisht:"⥾",Ufr:"𝔘",ufr:"𝔲",Ugrave:"Ù",ugrave:"ù",uHar:"⥣",uharl:"↿",uharr:"↾",uhblk:"▀",ulcorn:"⌜",ulcorner:"⌜",ulcrop:"⌏",ultri:"◸",Umacr:"Ū",umacr:"ū",uml:"¨",UnderBar:"_",UnderBrace:"⏟",UnderBracket:"⎵",UnderParenthesis:"⏝",Union:"⋃",UnionPlus:"⊎",Uogon:"Ų",uogon:"ų",Uopf:"𝕌",uopf:"𝕦",UpArrowBar:"⤒",uparrow:"↑",UpArrow:"↑",Uparrow:"⇑",UpArrowDownArrow:"⇅",updownarrow:"↕",UpDownArrow:"↕",Updownarrow:"⇕",UpEquilibrium:"⥮",upharpoonleft:"↿",upharpoonright:"↾",uplus:"⊎",UpperLeftArrow:"↖",UpperRightArrow:"↗",upsi:"υ",Upsi:"ϒ",upsih:"ϒ",Upsilon:"Υ",upsilon:"υ",UpTeeArrow:"↥",UpTee:"⊥",upuparrows:"⇈",urcorn:"⌝",urcorner:"⌝",urcrop:"⌎",Uring:"Ů",uring:"ů",urtri:"◹",Uscr:"𝒰",uscr:"𝓊",utdot:"⋰",Utilde:"Ũ",utilde:"ũ",utri:"▵",utrif:"▴",uuarr:"⇈",Uuml:"Ü",uuml:"ü",uwangle:"⦧",vangrt:"⦜", -varepsilon:"ϵ",varkappa:"ϰ",varnothing:"∅",varphi:"ϕ",varpi:"ϖ",varpropto:"∝",varr:"↕",vArr:"⇕",varrho:"ϱ",varsigma:"ς",varsubsetneq:"⊊︀",varsubsetneqq:"⫋︀",varsupsetneq:"⊋︀",varsupsetneqq:"⫌︀",vartheta:"ϑ",vartriangleleft:"⊲",vartriangleright:"⊳",vBar:"⫨",Vbar:"⫫",vBarv:"⫩",Vcy:"В",vcy:"в",vdash:"⊢",vDash:"⊨",Vdash:"⊩",VDash:"⊫",Vdashl:"⫦",veebar:"⊻",vee:"∨",Vee:"⋁",veeeq:"≚",vellip:"⋮",verbar:"|",Verbar:"‖",vert:"|",Vert:"‖",VerticalBar:"∣",VerticalLine:"|",VerticalSeparator:"❘",VerticalTilde:"≀",VeryThinSpace:" ",Vfr:"𝔙",vfr:"𝔳",vltri:"⊲",vnsub:"⊂⃒",vnsup:"⊃⃒",Vopf:"𝕍",vopf:"𝕧",vprop:"∝",vrtri:"⊳",Vscr:"𝒱",vscr:"𝓋",vsubnE:"⫋︀",vsubne:"⊊︀",vsupnE:"⫌︀",vsupne:"⊋︀",Vvdash:"⊪",vzigzag:"⦚",Wcirc:"Ŵ",wcirc:"ŵ",wedbar:"⩟",wedge:"∧",Wedge:"⋀",wedgeq:"≙",weierp:"℘",Wfr:"𝔚",wfr:"𝔴",Wopf:"𝕎",wopf:"𝕨",wp:"℘",wr:"≀",wreath:"≀",Wscr:"𝒲",wscr:"𝓌",xcap:"⋂",xcirc:"◯",xcup:"⋃",xdtri:"▽",Xfr:"𝔛",xfr:"𝔵",xharr:"⟷",xhArr:"⟺",Xi:"Ξ",xi:"ξ",xlarr:"⟵",xlArr:"⟸",xmap:"⟼",xnis:"⋻",xodot:"⨀",Xopf:"𝕏",xopf:"𝕩",xoplus:"⨁",xotime:"⨂",xrarr:"⟶",xrArr:"⟹",Xscr:"𝒳",xscr:"𝓍",xsqcup:"⨆",xuplus:"⨄",xutri:"△",xvee:"⋁",xwedge:"⋀",Yacute:"Ý",yacute:"ý",YAcy:"Я",yacy:"я",Ycirc:"Ŷ",ycirc:"ŷ",Ycy:"Ы",ycy:"ы",yen:"¥",Yfr:"𝔜",yfr:"𝔶",YIcy:"Ї",yicy:"ї",Yopf:"𝕐",yopf:"𝕪",Yscr:"𝒴",yscr:"𝓎",YUcy:"Ю",yucy:"ю",yuml:"ÿ",Yuml:"Ÿ",Zacute:"Ź",zacute:"ź",Zcaron:"Ž",zcaron:"ž",Zcy:"З",zcy:"з",Zdot:"Ż",zdot:"ż",zeetrf:"ℨ",ZeroWidthSpace:"",Zeta:"Ζ",zeta:"ζ",zfr:"𝔷",Zfr:"ℨ",ZHcy:"Ж",zhcy:"ж",zigrarr:"⇝",zopf:"𝕫",Zopf:"ℤ",Zscr:"𝒵",zscr:"𝓏",zwj:"",zwnj:""}},function(t,e){t.exports={Aacute:"Á",aacute:"á",Acirc:"Â",acirc:"â",acute:"´",AElig:"Æ",aelig:"æ",Agrave:"À",agrave:"à",amp:"&",AMP:"&",Aring:"Å",aring:"å",Atilde:"Ã",atilde:"ã",Auml:"Ä",auml:"ä",brvbar:"¦",Ccedil:"Ç",ccedil:"ç",cedil:"¸",cent:"¢",copy:"©",COPY:"©",curren:"¤",deg:"°",divide:"÷",Eacute:"É",eacute:"é",Ecirc:"Ê",ecirc:"ê",Egrave:"È",egrave:"è",ETH:"Ð",eth:"ð",Euml:"Ë",euml:"ë",frac12:"½",frac14:"¼",frac34:"¾",gt:">",GT:">",Iacute:"Í",iacute:"í",Icirc:"Î",icirc:"î",iexcl:"¡",Igrave:"Ì",igrave:"ì",iquest:"¿",Iuml:"Ï",iuml:"ï",laquo:"«",lt:"<",LT:"<",macr:"¯",micro:"µ",middot:"·",nbsp:" ",not:"¬",Ntilde:"Ñ",ntilde:"ñ",Oacute:"Ó",oacute:"ó",Ocirc:"Ô",ocirc:"ô",Ograve:"Ò",ograve:"ò",ordf:"ª",ordm:"º",Oslash:"Ø",oslash:"ø",Otilde:"Õ",otilde:"õ",Ouml:"Ö",ouml:"ö",para:"¶",plusmn:"±",pound:"£",quot:'"',QUOT:'"',raquo:"»",reg:"®",REG:"®",sect:"§",shy:"",sup1:"¹",sup2:"²",sup3:"³",szlig:"ß",THORN:"Þ",thorn:"þ",times:"×",Uacute:"Ú",uacute:"ú",Ucirc:"Û",ucirc:"û",Ugrave:"Ù",ugrave:"ù",uml:"¨",Uuml:"Ü",uuml:"ü",Yacute:"Ý",yacute:"ý",yen:"¥",yuml:"ÿ"}},function(t,e){t.exports={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'}},function(t,e,r){function n(t,e,r){"object"==typeof t?(r=e,e=t,t=null):"function"==typeof e&&(r=e,e=c),this._callback=t,this._options=e||c,this._elementCB=r,this.dom=[],this._done=!1,this._tagStack=[],this._parser=this._parser||null}var i=r(21),o=/\s+/g,s=r(22),a=r(23),c={normalizeWhitespace:!1,withStartIndices:!1};n.prototype.onparserinit=function(t){this._parser=t},n.prototype.onreset=function(){n.call(this,this._callback,this._options,this._elementCB)},n.prototype.onend=function(){this._done||(this._done=!0,this._parser=null,this._handleCallback(null))},n.prototype._handleCallback=n.prototype.onerror=function(t){if("function"==typeof this._callback)this._callback(t,this.dom);else if(t)throw t},n.prototype.onclosetag=function(){var t=this._tagStack.pop();this._elementCB&&this._elementCB(t)},n.prototype._addDomElement=function(t){var e=this._tagStack[this._tagStack.length-1],r=e?e.children:this.dom,n=r[r.length-1];t.next=null,this._options.withStartIndices&&(t.startIndex=this._parser.startIndex),this._options.withDomLvl1&&(t.__proto__="tag"===t.type?a:s),n?(t.prev=n,n.next=t):t.prev=null,r.push(t),t.parent=e||null},n.prototype.onopentag=function(t,e){var r={type:"script"===t?i.Script:"style"===t?i.Style:i.Tag,name:t,attribs:e,children:[]};this._addDomElement(r),this._tagStack.push(r)},n.prototype.ontext=function(t){var e,r=this._options.normalizeWhitespace||this._options.ignoreWhitespace;!this._tagStack.length&&this.dom.length&&(e=this.dom[this.dom.length-1]).type===i.Text?r?e.data=(e.data+t).replace(o," "):e.data+=t:this._tagStack.length&&(e=this._tagStack[this._tagStack.length-1])&&(e=e.children[e.children.length-1])&&e.type===i.Text?r?e.data=(e.data+t).replace(o," "):e.data+=t:(r&&(t=t.replace(o," ")),this._addDomElement({data:t,type:i.Text}))},n.prototype.oncomment=function(t){var e=this._tagStack[this._tagStack.length-1];if(e&&e.type===i.Comment)return void(e.data+=t);var r={data:t,type:i.Comment};this._addDomElement(r),this._tagStack.push(r)},n.prototype.oncdatastart=function(){var t={children:[{data:"",type:i.Text}],type:i.CDATA};this._addDomElement(t),this._tagStack.push(t)},n.prototype.oncommentend=n.prototype.oncdataend=function(){this._tagStack.pop()},n.prototype.onprocessinginstruction=function(t,e){this._addDomElement({name:t,data:e,type:i.Directive})},t.exports=n},function(t,e){t.exports={Text:"text",Directive:"directive",Comment:"comment",Script:"script",Style:"style",Tag:"tag",CDATA:"cdata",Doctype:"doctype",isTag:function(t){return"tag"===t.type||"script"===t.type||"style"===t.type}}},function(t,e){var r=t.exports={get firstChild(){var t=this.children;return t&&t[0]||null},get lastChild(){var t=this.children;return t&&t[t.length-1]||null},get nodeType(){return i[this.type]||i.element}},n={tagName:"name",childNodes:"children",parentNode:"parent",previousSibling:"prev",nextSibling:"next",nodeValue:"data"},i={element:1,text:3,cdata:4,comment:8};Object.keys(n).forEach(function(t){var e=n[t];Object.defineProperty(r,t,{get:function(){return this[e]||null},set:function(t){return this[e]=t,t}})})},function(t,e,r){var n=r(22),i=t.exports=Object.create(n),o={tagName:"name"};Object.keys(o).forEach(function(t){var e=o[t];Object.defineProperty(i,t,{get:function(){return this[e]||null},set:function(t){return this[e]=t,t}})})},function(t,e,r){function n(t,e){this.init(t,e)}function i(t,e){return h.getElementsByTagName(t,e,!0)}function o(t,e){return h.getElementsByTagName(t,e,!0,1)[0]}function s(t,e,r){return h.getText(h.getElementsByTagName(t,e,r,1)).trim()}function a(t,e,r,n,i){var o=s(r,n,i);o&&(t[e]=o)}var c=r(12),u=c.DomHandler,h=c.DomUtils;r(2).inherits(n,u),n.prototype.init=u;var l=function(t){return"rss"===t||"feed"===t||"rdf:RDF"===t};n.prototype.onend=function(){var t,e,r={},n=o(l,this.dom);n&&("feed"===n.name?(e=n.children,r.type="atom",a(r,"id","id",e),a(r,"title","title",e),(t=o("link",e))&&(t=t.attribs)&&(t=t.href)&&(r.link=t),a(r,"description","subtitle",e),(t=s("updated",e))&&(r.updated=new Date(t)),a(r,"author","email",e,!0),r.items=i("entry",e).map(function(t){var e,r={};return t=t.children,a(r,"id","id",t),a(r,"title","title",t),(e=o("link",t))&&(e=e.attribs)&&(e=e.href)&&(r.link=e),(e=s("summary",t)||s("content",t))&&(r.description=e),(e=s("updated",t))&&(r.pubDate=new Date(e)),r})):(e=o("channel",n.children).children,r.type=n.name.substr(0,3),r.id="",a(r,"title","title",e),a(r,"link","link",e),a(r,"description","description",e),(t=s("lastBuildDate",e))&&(r.updated=new Date(t)),a(r,"author","managingEditor",e,!0),r.items=i("item",n.children).map(function(t){var e,r={};return t=t.children,a(r,"id","guid",t),a(r,"title","title",t),a(r,"link","link",t),a(r,"description","description",t),(e=s("pubDate",t))&&(r.pubDate=new Date(e)),r}))),this.dom=r,u.prototype._handleCallback.call(this,n?null:Error("couldn't find root of feed"))},t.exports=n},function(t,e,r){function n(t){o.call(this,new i(this),t)}function i(t){this.scope=t}t.exports=n;var o=r(26);r(2).inherits(n,o),n.prototype.readable=!0;var s=r(12).EVENTS;Object.keys(s).forEach(function(t){if(0===s[t])i.prototype["on"+t]=function(){this.scope.emit(t)};else if(1===s[t])i.prototype["on"+t]=function(e){this.scope.emit(t,e)};else{if(2!==s[t])throw Error("wrong number of arguments!");i.prototype["on"+t]=function(e,r){this.scope.emit(t,e,r)}}})},function(t,e,r){function n(t,e){var r=this._parser=new i(t,e);o.call(this,{decodeStrings:!1}),this.once("finish",function(){r.end()})}t.exports=n;var i=r(13),o=r(27).Writable||r(46).Writable;r(2).inherits(n,o),o.prototype._write=function(t,e,r){this._parser.write(t),r()}},function(t,e,r){function n(){i.call(this)}t.exports=n;var i=r(1).EventEmitter,o=r(5);o(n,i),n.Readable=r(28),n.Writable=r(42),n.Duplex=r(43),n.Transform=r(44),n.PassThrough=r(45),n.Stream=n,n.prototype.pipe=function(t,e){function r(e){t.writable&&!1===t.write(e)&&u.pause&&u.pause()}function n(){u.readable&&u.resume&&u.resume()}function o(){h||(h=!0,t.end())}function s(){h||(h=!0,"function"==typeof t.destroy&&t.destroy())}function a(t){if(c(),0===i.listenerCount(this,"error"))throw t}function c(){u.removeListener("data",r),t.removeListener("drain",n),u.removeListener("end",o),u.removeListener("close",s),u.removeListener("error",a),t.removeListener("error",a),u.removeListener("end",c),u.removeListener("close",c),t.removeListener("close",c)}var u=this;u.on("data",r),t.on("drain",n),t._isStdio||e&&e.end===!1||(u.on("end",o),u.on("close",s));var h=!1;return u.on("error",a),t.on("error",a),u.on("end",c),u.on("close",c),t.on("close",c),t.emit("pipe",u),t}},function(t,e,r){(function(n){e=t.exports=r(29),e.Stream=r(27),e.Readable=e,e.Writable=r(38),e.Duplex=r(37),e.Transform=r(40),e.PassThrough=r(41),n.browser||"disable"!==n.env.READABLE_STREAM||(t.exports=r(27))}).call(e,r(3))},function(t,e,r){(function(e){function n(t,e){var n=r(37);t=t||{};var i=t.highWaterMark,o=t.objectMode?16:16384;this.highWaterMark=i||0===i?i:o,this.highWaterMark=~~this.highWaterMark,this.buffer=[],this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.objectMode=!!t.objectMode,e instanceof n&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.defaultEncoding=t.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(L||(L=r(39).StringDecoder),this.decoder=new L(t.encoding),this.encoding=t.encoding)}function i(t){r(37);return this instanceof i?(this._readableState=new n(t,this),this.readable=!0,void T.call(this)):new i(t)}function o(t,e,r,n,i){var o=u(e,r);if(o)t.emit("error",o);else if(A.isNullOrUndefined(r))e.reading=!1,e.ended||h(t,e);else if(e.objectMode||r&&r.length>0)if(e.ended&&!i){var a=new Error("stream.push() after EOF");t.emit("error",a)}else if(e.endEmitted&&i){var a=new Error("stream.unshift() after end event");t.emit("error",a)}else!e.decoder||i||n||(r=e.decoder.write(r)),i||(e.reading=!1),e.flowing&&0===e.length&&!e.sync?(t.emit("data",r),t.read(0)):(e.length+=e.objectMode?1:r.length,i?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&l(t)),f(t,e);else i||(e.reading=!1);return s(e)}function s(t){return!t.ended&&(t.needReadable||t.length<t.highWaterMark||0===t.length)}function a(t){if(t>=D)t=D;else{t--;for(var e=1;32>e;e<<=1)t|=t>>e;t++}return t}function c(t,e){return 0===e.length&&e.ended?0:e.objectMode?0===t?0:1:isNaN(t)||A.isNull(t)?e.flowing&&e.buffer.length?e.buffer[0].length:e.length:0>=t?0:(t>e.highWaterMark&&(e.highWaterMark=a(t)),t>e.length?e.ended?e.length:(e.needReadable=!0,0):t)}function u(t,e){var r=null;return A.isBuffer(e)||A.isString(e)||A.isNullOrUndefined(e)||t.objectMode||(r=new TypeError("Invalid non-string/buffer chunk")),r}function h(t,e){if(e.decoder&&!e.ended){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,l(t)}function l(t){var r=t._readableState;r.needReadable=!1,r.emittedReadable||(I("emitReadable",r.flowing),r.emittedReadable=!0,r.sync?e.nextTick(function(){p(t)}):p(t))}function p(t){I("emit readable"),t.emit("readable"),b(t)}function f(t,r){r.readingMore||(r.readingMore=!0,e.nextTick(function(){d(t,r)}))}function d(t,e){for(var r=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length<e.highWaterMark&&(I("maybeReadMore read 0"),t.read(0),r!==e.length);)r=e.length;e.readingMore=!1}function g(t){return function(){var e=t._readableState;I("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&x.listenerCount(t,"data")&&(e.flowing=!0,b(t))}}function _(t,r){r.resumeScheduled||(r.resumeScheduled=!0,e.nextTick(function(){m(t,r)}))}function m(t,e){e.resumeScheduled=!1,t.emit("resume"),b(t),e.flowing&&!e.reading&&t.read(0)}function b(t){var e=t._readableState;if(I("flow",e.flowing),e.flowing)do var r=t.read();while(null!==r&&e.flowing)}function y(t,e){var r,n=e.buffer,i=e.length,o=!!e.decoder,s=!!e.objectMode;if(0===n.length)return null;if(0===i)r=null;else if(s)r=n.shift();else if(!t||t>=i)r=o?n.join(""):k.concat(n,i),n.length=0;else if(t<n[0].length){var a=n[0];r=a.slice(0,t),n[0]=a.slice(t)}else if(t===n[0].length)r=n.shift();else{r=o?"":new k(t);for(var c=0,u=0,h=n.length;h>u&&t>c;u++){var a=n[0],l=Math.min(t-c,a.length);o?r+=a.slice(0,l):a.copy(r,c,0,l),l<a.length?n[0]=a.slice(l):n.shift(),c+=l}}return r}function v(t){var r=t._readableState;if(r.length>0)throw new Error("endReadable called on non-empty stream");r.endEmitted||(r.ended=!0,e.nextTick(function(){r.endEmitted||0!==r.length||(r.endEmitted=!0,t.readable=!1,t.emit("end"))}))}function w(t,e){for(var r=0,n=t.length;n>r;r++)e(t[r],r)}function S(t,e){for(var r=0,n=t.length;n>r;r++)if(t[r]===e)return r;return-1}t.exports=i;var E=r(30),k=r(31).Buffer;i.ReadableState=n;var x=r(1).EventEmitter;x.listenerCount||(x.listenerCount=function(t,e){return t.listeners(e).length});var T=r(27),A=r(35);A.inherits=r(5);var L,I=r(36);I=I&&I.debuglog?I.debuglog("stream"):function(){},A.inherits(i,T),i.prototype.push=function(t,e){var r=this._readableState;return A.isString(t)&&!r.objectMode&&(e=e||r.defaultEncoding,e!==r.encoding&&(t=new k(t,e),e="")),o(this,r,t,e,!1)},i.prototype.unshift=function(t){var e=this._readableState;return o(this,e,t,"",!0)},i.prototype.setEncoding=function(t){return L||(L=r(39).StringDecoder),this._readableState.decoder=new L(t),this._readableState.encoding=t,this};var D=8388608;i.prototype.read=function(t){I("read",t);var e=this._readableState,r=t;if((!A.isNumber(t)||t>0)&&(e.emittedReadable=!1),0===t&&e.needReadable&&(e.length>=e.highWaterMark||e.ended))return I("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?v(this):l(this),null;if(t=c(t,e),0===t&&e.ended)return 0===e.length&&v(this),null;var n=e.needReadable;I("need readable",n),(0===e.length||e.length-t<e.highWaterMark)&&(n=!0,I("length less than watermark",n)),(e.ended||e.reading)&&(n=!1,I("reading or ended",n)),n&&(I("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1),n&&!e.reading&&(t=c(r,e));var i;return i=t>0?y(t,e):null,A.isNull(i)&&(e.needReadable=!0,t=0),e.length-=t,0!==e.length||e.ended||(e.needReadable=!0),r!==t&&e.ended&&0===e.length&&v(this),A.isNull(i)||this.emit("data",i),i},i.prototype._read=function(t){this.emit("error",new Error("not implemented"))},i.prototype.pipe=function(t,r){function n(t){I("onunpipe"),t===l&&o()}function i(){I("onend"),t.end()}function o(){I("cleanup"),t.removeListener("close",c),t.removeListener("finish",u),t.removeListener("drain",_),t.removeListener("error",a),t.removeListener("unpipe",n),l.removeListener("end",i),l.removeListener("end",o),l.removeListener("data",s),!p.awaitDrain||t._writableState&&!t._writableState.needDrain||_()}function s(e){I("ondata");var r=t.write(e);!1===r&&(I("false write response, pause",l._readableState.awaitDrain),l._readableState.awaitDrain++,l.pause())}function a(e){I("onerror",e),h(),t.removeListener("error",a),0===x.listenerCount(t,"error")&&t.emit("error",e)}function c(){t.removeListener("finish",u),h()}function u(){I("onfinish"),t.removeListener("close",c),h()}function h(){I("unpipe"),l.unpipe(t)}var l=this,p=this._readableState;switch(p.pipesCount){case 0:p.pipes=t;break;case 1:p.pipes=[p.pipes,t];break;default:p.pipes.push(t)}p.pipesCount+=1,I("pipe count=%d opts=%j",p.pipesCount,r);var f=(!r||r.end!==!1)&&t!==e.stdout&&t!==e.stderr,d=f?i:o;p.endEmitted?e.nextTick(d):l.once("end",d),t.on("unpipe",n);var _=g(l);return t.on("drain",_),l.on("data",s),t._events&&t._events.error?E(t._events.error)?t._events.error.unshift(a):t._events.error=[a,t._events.error]:t.on("error",a),t.once("close",c),t.once("finish",u),t.emit("pipe",l),p.flowing||(I("pipe resume"),l.resume()),t},i.prototype.unpipe=function(t){var e=this._readableState;if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this),this);if(!t){var r=e.pipes,n=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var i=0;n>i;i++)r[i].emit("unpipe",this);return this}var i=S(e.pipes,t);return-1===i?this:(e.pipes.splice(i,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this),this)},i.prototype.on=function(t,r){var n=T.prototype.on.call(this,t,r);if("data"===t&&!1!==this._readableState.flowing&&this.resume(),"readable"===t&&this.readable){var i=this._readableState;if(!i.readableListening)if(i.readableListening=!0,i.emittedReadable=!1,i.needReadable=!0,i.reading)i.length&&l(this,i);else{var o=this;e.nextTick(function(){I("readable nexttick read 0"),o.read(0)})}}return n},i.prototype.addListener=i.prototype.on,i.prototype.resume=function(){var t=this._readableState;return t.flowing||(I("resume"),t.flowing=!0,t.reading||(I("resume read 0"),this.read(0)),_(this,t)),this},i.prototype.pause=function(){return I("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(I("pause"),this._readableState.flowing=!1,this.emit("pause")),this},i.prototype.wrap=function(t){var e=this._readableState,r=!1,n=this;t.on("end",function(){if(I("wrapped end"),e.decoder&&!e.ended){var t=e.decoder.end();t&&t.length&&n.push(t)}n.push(null)}),t.on("data",function(i){if(I("wrapped data"),e.decoder&&(i=e.decoder.write(i)),i&&(e.objectMode||i.length)){var o=n.push(i);o||(r=!0,t.pause())}});for(var i in t)A.isFunction(t[i])&&A.isUndefined(this[i])&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));var o=["error","close","destroy","pause","resume"];return w(o,function(e){t.on(e,n.emit.bind(n,e))}),n._read=function(e){I("wrapped _read",e),r&&(r=!1,t.resume())},n},i._fromList=y}).call(e,r(3))},function(t,e){t.exports=Array.isArray||function(t){return"[object Array]"==Object.prototype.toString.call(t)}},function(t,e,r){(function(t,n){/*! +!function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){function n(){var t=this;i.call(t),t.runtime=new s,t.editingTarget=null,t.runtime.on(s.SCRIPT_GLOW_ON,function(e){t.emit(s.SCRIPT_GLOW_ON,{id:e})}),t.runtime.on(s.SCRIPT_GLOW_OFF,function(e){t.emit(s.SCRIPT_GLOW_OFF,{id:e})}),t.runtime.on(s.BLOCK_GLOW_ON,function(e){t.emit(s.BLOCK_GLOW_ON,{id:e})}),t.runtime.on(s.BLOCK_GLOW_OFF,function(e){t.emit(s.BLOCK_GLOW_OFF,{id:e})}),t.runtime.on(s.VISUAL_REPORT,function(e,r){t.emit(s.VISUAL_REPORT,{id:e,value:r})}),this.blockListener=this.blockListener.bind(this)}var i=r(1),o=r(2),s=r(6),a=r(33),u=r(85),c=r(34);o.inherits(n,i),n.prototype.start=function(){this.runtime.start()},n.prototype.greenFlag=function(){this.runtime.greenFlag()},n.prototype.stopAll=function(){this.runtime.stopAll()},n.prototype.getPlaygroundData=function(){this.emit("playgroundData",{blocks:this.editingTarget.blocks,threads:this.runtime.threads})},n.prototype.animationFrame=function(){this.runtime.animationFrame()},n.prototype.postIOData=function(t,e){this.runtime.ioDevices[t]&&this.runtime.ioDevices[t].postData(e)},n.prototype.loadProject=function(t){a(t,this.runtime),this.editingTarget=this.runtime.targets[0],this.emitTargetsUpdate(),this.emitWorkspaceUpdate(),this.runtime.setEditingTarget(this.editingTarget)},n.prototype.createEmptyProject=function(){var t=new c,e=new u(t);e.name="Stage",e.costumes.push({skin:"/assets/stage.png",name:"backdrop1",bitmapResolution:1,rotationCenterX:240,rotationCenterY:180});var r=e.createClone();this.runtime.targets.push(r),r.x=0,r.y=0,r.direction=90,r.size=200,r.visible=!0,r.isStage=!0;var n=new c,i=new u(n);i.name="Sprite1",i.costumes.push({skin:"/assets/scratch_cat.svg",name:"costume1",bitmapResolution:1,rotationCenterX:47,rotationCenterY:55});var o=i.createClone();this.runtime.targets.push(o),o.x=0,o.y=0,o.direction=90,o.size=100,o.visible=!0,this.editingTarget=this.runtime.targets[0],this.emitTargetsUpdate(),this.emitWorkspaceUpdate()},n.prototype.blockListener=function(t){this.editingTarget&&this.editingTarget.blocks.blocklyListen(t,!1,this.runtime)},n.prototype.setEditingTarget=function(t){if(t!=this.editingTarget.id){var e=this.runtime.getTargetById(t);e&&(this.editingTarget=e,this.emitTargetsUpdate(),this.emitWorkspaceUpdate(),this.runtime.setEditingTarget(e))}},n.prototype.emitTargetsUpdate=function(){this.emit("targetsUpdate",{targetList:this.runtime.targets.map(function(t){return[t.id,t.getName()]}),editingTarget:this.editingTarget.id})},n.prototype.emitWorkspaceUpdate=function(){this.emit("workspaceUpdate",{xml:this.editingTarget.blocks.toXML()})},t.exports=n,"undefined"!=typeof window&&(window.VirtualMachine=t.exports)},function(t,e){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function n(t){return"function"==typeof t}function i(t){return"number"==typeof t}function o(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(t){if(!i(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},r.prototype.emit=function(t){var e,r,i,a,u,c;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var p=new Error('Uncaught, unspecified "error" event. ('+e+")");throw p.context=e,p}if(r=this._events[t],s(r))return!1;if(n(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),r.apply(this,a)}else if(o(r))for(a=Array.prototype.slice.call(arguments,1),c=r.slice(),i=c.length,u=0;u<i;u++)c[u].apply(this,a);return!0},r.prototype.addListener=function(t,e){var i;if(!n(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,n(e.listener)?e.listener:e),this._events[t]?o(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,o(this._events[t])&&!this._events[t].warned&&(i=s(this._maxListeners)?r.defaultMaxListeners:this._maxListeners,i&&i>0&&this._events[t].length>i&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){function r(){this.removeListener(t,r),i||(i=!0,e.apply(this,arguments))}if(!n(e))throw TypeError("listener must be a function");var i=!1;return r.listener=e,this.on(t,r),this},r.prototype.removeListener=function(t,e){var r,i,s,a;if(!n(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],s=r.length,i=-1,r===e||n(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(a=s;a-- >0;)if(r[a]===e||r[a].listener&&r[a].listener===e){i=a;break}if(i<0)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(i,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},r.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],n(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},r.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?n(this._events[t])?[this._events[t]]:this._events[t].slice():[]},r.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(n(e))return 1;if(e)return e.length}return 0},r.listenerCount=function(t,e){return t.listenerCount(e)}},function(t,e,r){(function(t,n){function i(t,r){var n={seen:[],stylize:s};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),g(r)?n.showHidden=r:r&&e._extend(n,r),w(n.showHidden)&&(n.showHidden=!1),w(n.depth)&&(n.depth=2),w(n.colors)&&(n.colors=!1),w(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=o),u(n,t,n.depth)}function o(t,e){var r=i.styles[e];return r?"["+i.colors[r][0]+"m"+t+"["+i.colors[r][1]+"m":t}function s(t,e){return t}function a(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}function u(t,r,n){if(t.customInspect&&r&&x(r.inspect)&&r.inspect!==e.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,t);return b(i)||(i=u(t,i,n)),i}var o=c(t,r);if(o)return o;var s=Object.keys(r),g=a(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(r)),E(r)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return p(r);if(0===s.length){if(x(r)){var m=r.name?": "+r.name:"";return t.stylize("[Function"+m+"]","special")}if(S(r))return t.stylize(RegExp.prototype.toString.call(r),"regexp");if(T(r))return t.stylize(Date.prototype.toString.call(r),"date");if(E(r))return p(r)}var _="",y=!1,v=["{","}"];if(d(r)&&(y=!0,v=["[","]"]),x(r)){var w=r.name?": "+r.name:"";_=" [Function"+w+"]"}if(S(r)&&(_=" "+RegExp.prototype.toString.call(r)),T(r)&&(_=" "+Date.prototype.toUTCString.call(r)),E(r)&&(_=" "+p(r)),0===s.length&&(!y||0==r.length))return v[0]+_+v[1];if(n<0)return S(r)?t.stylize(RegExp.prototype.toString.call(r),"regexp"):t.stylize("[Object]","special");t.seen.push(r);var k;return k=y?h(t,r,n,g,s):s.map(function(e){return l(t,r,n,g,e,y)}),t.seen.pop(),f(k,_,v)}function c(t,e){if(w(e))return t.stylize("undefined","undefined");if(b(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}return y(e)?t.stylize(""+e,"number"):g(e)?t.stylize(""+e,"boolean"):m(e)?t.stylize("null","null"):void 0}function p(t){return"["+Error.prototype.toString.call(t)+"]"}function h(t,e,r,n,i){for(var o=[],s=0,a=e.length;s<a;++s)M(e,String(s))?o.push(l(t,e,r,n,String(s),!0)):o.push("");return i.forEach(function(i){i.match(/^\d+$/)||o.push(l(t,e,r,n,i,!0))}),o}function l(t,e,r,n,i,o){var s,a,c;if(c=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]},c.get?a=c.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):c.set&&(a=t.stylize("[Setter]","special")),M(n,i)||(s="["+i+"]"),a||(t.seen.indexOf(c.value)<0?(a=m(r)?u(t,c.value,null):u(t,c.value,r-1),a.indexOf("\n")>-1&&(a=o?a.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+a.split("\n").map(function(t){return" "+t}).join("\n"))):a=t.stylize("[Circular]","special")),w(s)){if(o&&i.match(/^\d+$/))return a;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=t.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=t.stylize(s,"string"))}return s+": "+a}function f(t,e,r){var n=0,i=t.reduce(function(t,e){return n++,e.indexOf("\n")>=0&&n++,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1]:r[0]+e+" "+t.join(", ")+" "+r[1]}function d(t){return Array.isArray(t)}function g(t){return"boolean"==typeof t}function m(t){return null===t}function _(t){return null==t}function y(t){return"number"==typeof t}function b(t){return"string"==typeof t}function v(t){return"symbol"==typeof t}function w(t){return void 0===t}function S(t){return k(t)&&"[object RegExp]"===O(t)}function k(t){return"object"==typeof t&&null!==t}function T(t){return k(t)&&"[object Date]"===O(t)}function E(t){return k(t)&&("[object Error]"===O(t)||t instanceof Error)}function x(t){return"function"==typeof t}function N(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||"undefined"==typeof t}function O(t){return Object.prototype.toString.call(t)}function A(t){return t<10?"0"+t.toString(10):t.toString(10)}function C(){var t=new Date,e=[A(t.getHours()),A(t.getMinutes()),A(t.getSeconds())].join(":");return[t.getDate(),I[t.getMonth()],e].join(" ")}function M(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var L=/%[sdj%]/g;e.format=function(t){if(!b(t)){for(var e=[],r=0;r<arguments.length;r++)e.push(i(arguments[r]));return e.join(" ")}for(var r=1,n=arguments,o=n.length,s=String(t).replace(L,function(t){if("%%"===t)return"%";if(r>=o)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return t}}),a=n[r];r<o;a=n[++r])s+=m(a)||!k(a)?" "+a:" "+i(a);return s},e.deprecate=function(r,i){function o(){if(!s){if(n.throwDeprecation)throw new Error(i);n.traceDeprecation?console.trace(i):console.error(i),s=!0}return r.apply(this,arguments)}if(w(t.process))return function(){return e.deprecate(r,i).apply(this,arguments)};if(n.noDeprecation===!0)return r;var s=!1;return o};var R,D={};e.debuglog=function(t){if(w(R)&&(R=n.env.NODE_DEBUG||""),t=t.toUpperCase(),!D[t])if(new RegExp("\\b"+t+"\\b","i").test(R)){var r=n.pid;D[t]=function(){var n=e.format.apply(e,arguments);console.error("%s %d: %s",t,r,n)}}else D[t]=function(){};return D[t]},e.inspect=i,i.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},i.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=d,e.isBoolean=g,e.isNull=m,e.isNullOrUndefined=_,e.isNumber=y,e.isString=b,e.isSymbol=v,e.isUndefined=w,e.isRegExp=S,e.isObject=k,e.isDate=T,e.isError=E,e.isFunction=x,e.isPrimitive=N,e.isBuffer=r(4);var I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];e.log=function(){console.log("%s - %s",C(),e.format.apply(e,arguments))},e.inherits=r(5),e._extend=function(t,e){if(!e||!k(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}).call(e,function(){return this}(),r(3))},function(t,e){function r(t){if(u===setTimeout)return setTimeout(t,0);try{return u(t,0)}catch(e){try{return u.call(null,t,0)}catch(e){return u.call(this,t,0)}}}function n(t){if(c===clearTimeout)return clearTimeout(t);try{return c(t)}catch(e){try{return c.call(null,t)}catch(e){return c.call(this,t)}}}function i(){f&&h&&(f=!1,h.length?l=h.concat(l):d=-1,l.length&&o())}function o(){if(!f){var t=r(i);f=!0;for(var e=l.length;e;){for(h=l,l=[];++d<e;)h&&h[d].run();d=-1,e=l.length}h=null,f=!1,n(t)}}function s(t,e){this.fun=t,this.array=e}function a(){}var u,c,p=t.exports={};!function(){try{u=setTimeout}catch(t){u=function(){throw new Error("setTimeout is not defined")}}try{c=clearTimeout}catch(t){c=function(){throw new Error("clearTimeout is not defined")}}}();var h,l=[],f=!1,d=-1;p.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];l.push(new s(t,e)),1!==l.length||f||r(o)},s.prototype.run=function(){this.fun.apply(null,this.array)},p.title="browser",p.browser=!0,p.env={},p.argv=[],p.version="",p.versions={},p.on=a,p.addListener=a,p.once=a,p.off=a,p.removeListener=a,p.removeAllListeners=a,p.emit=a,p.binding=function(t){throw new Error("process.binding is not supported")},p.cwd=function(){return"/"},p.chdir=function(t){throw new Error("process.chdir is not supported")},p.umask=function(){return 0}},function(t,e){t.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},function(t,e){"function"==typeof Object.create?t.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},function(t,e,r){function n(){i.call(this),this.targets=[],this.threads=[],this.sequencer=new o(this),this._primitives={},this._hats={},this._edgeActivatedHatValues={},this._registerBlockPackages(),this.ioDevices={clock:new u,keyboard:new c(this),mouse:new p(this)},this._scriptGlowsPreviousFrame=[],this._editingTarget=null}var i=r(1),o=r(7),s=r(9),a=r(2),u=r(11),c=r(12),p=r(15),h={scratch3_control:r(17),scratch3_event:r(28),scratch3_looks:r(29),scratch3_motion:r(30),scratch3_operators:r(31),scratch3_sensing:r(32)};n.SCRIPT_GLOW_ON="STACK_GLOW_ON",n.SCRIPT_GLOW_OFF="STACK_GLOW_OFF",n.BLOCK_GLOW_ON="BLOCK_GLOW_ON",n.BLOCK_GLOW_OFF="BLOCK_GLOW_OFF",n.VISUAL_REPORT="VISUAL_REPORT",a.inherits(n,i),n.THREAD_STEP_INTERVAL=1e3/60,n.prototype._registerBlockPackages=function(){for(var t in h)if(h.hasOwnProperty(t)){var e=new h[t](this);if(e.getPrimitives){var r=e.getPrimitives();for(var n in r)r.hasOwnProperty(n)&&(this._primitives[n]=r[n].bind(e))}if(e.getHats){var i=e.getHats();for(var o in i)i.hasOwnProperty(o)&&(this._hats[o]=i[o])}}},n.prototype.getOpcodeFunction=function(t){return this._primitives[t]},n.prototype.getIsHat=function(t){return this._hats.hasOwnProperty(t)},n.prototype.getIsEdgeActivatedHat=function(t){return this._hats.hasOwnProperty(t)&&this._hats[t].edgeActivated},n.prototype.updateEdgeActivatedValue=function(t,e){var r=this._edgeActivatedHatValues[t];return this._edgeActivatedHatValues[t]=e,r},n.prototype.clearEdgeActivatedValues=function(){this._edgeActivatedHatValues={}},n.prototype._pushThread=function(t){var e=new s(t);return e.pushStack(t),this.threads.push(e),e},n.prototype._removeThread=function(t){var e=this.threads.indexOf(t);e>-1&&this.threads.splice(e,1)},n.prototype.isActiveThread=function(t){return this.threads.indexOf(t)>-1},n.prototype.toggleScript=function(t){for(var e=0;e<this.threads.length;e++)if(this.threads[e].topBlock==t)return void this._removeThread(this.threads[e]);this._pushThread(t)},n.prototype.allScriptsDo=function(t,e){var r=this.targets;e&&(r=[e]);for(var n=0;n<r.length;n++)for(var i=r[n],o=i.blocks.getScripts(),s=0;s<o.length;s++){var a=o[s];t(a,i)}},n.prototype.startHats=function(t,e,r){if(this._hats.hasOwnProperty(t)){var n=this,i=[];return this.allScriptsDo(function(r,o){var s=o.blocks.getBlock(r).opcode;if(s===t){var a=o.blocks.getFields(r);if(e)for(var u in e)if(a[u].value!==e[u])return;var c=n._hats[t];if(c.restartExistingThreads)for(var p=0;p<n.threads.length;p++)n.threads[p].topBlock===r&&n._removeThread(n.threads[p]);else for(var h=0;h<n.threads.length;h++)if(n.threads[h].topBlock===r)return;i.push(n._pushThread(r))}},r),i}},n.prototype.greenFlag=function(){this.ioDevices.clock.resetProjectTimer(),this.clearEdgeActivatedValues(),this.startHats("event_whenflagclicked")},n.prototype.stopAll=function(){for(var t=this.threads.slice();t.length>0;){var e=t.pop();this._removeThread(e)}},n.prototype._step=function(){for(var t in this._hats){var e=this._hats[t];e.edgeActivated&&this.startHats(t)}var r=this.sequencer.stepThreads(this.threads);this._updateScriptGlows();for(var n=0;n<r.length;n++)this._removeThread(r[n])},n.prototype.setEditingTarget=function(t){this._scriptGlowsPreviousFrame=[],this._editingTarget=t,this._updateScriptGlows()},n.prototype._updateScriptGlows=function(){for(var t=[],e=[],r=0;r<this.threads.length;r++){var n=this.threads[r],i=this.targetForThread(n);if(n.requestScriptGlowInFrame&&i==this._editingTarget){var o=n.peekStack()||n.topBlock,s=i.blocks.getTopLevelScript(o);t.push(s)}}for(var a=0;a<this._scriptGlowsPreviousFrame.length;a++){var u=this._scriptGlowsPreviousFrame[a];t.indexOf(u)<0?this.glowScript(u,!1):e.push(u)}for(var c=0;c<t.length;c++){var p=t[c];this._scriptGlowsPreviousFrame.indexOf(p)<0&&(this.glowScript(p,!0),e.push(p))}this._scriptGlowsPreviousFrame=e},n.prototype.glowBlock=function(t,e){e?this.emit(n.BLOCK_GLOW_ON,t):this.emit(n.BLOCK_GLOW_OFF,t)},n.prototype.glowScript=function(t,e){e?this.emit(n.SCRIPT_GLOW_ON,t):this.emit(n.SCRIPT_GLOW_OFF,t)},n.prototype.visualReport=function(t,e){this.emit(n.VISUAL_REPORT,t,String(e))},n.prototype.targetForThread=function(t){for(var e=0;e<this.targets.length;e++){var r=this.targets[e];if(r.blocks.getBlock(t.topBlock))return r}},n.prototype.getTargetById=function(t){for(var e=0;e<this.targets.length;e++){var r=this.targets[e];if(r.id==t)return r}},n.prototype.getTargetForStage=function(){for(var t=0;t<this.targets.length;t++){var e=this.targets[t];if(e.isStage)return e}},n.prototype.animationFrame=function(){self.renderer&&self.renderer.draw()},n.prototype.start=function(){self.setInterval(function(){this._step()}.bind(this),n.THREAD_STEP_INTERVAL)},t.exports=n},function(t,e,r){function n(t){this.timer=new i,this.runtime=t}var i=r(8),o=r(9),s=r(10);n.WORK_TIME=10,n.prototype.stepThreads=function(t){this.timer.start();for(var e=[],r=0,i=0;i<t.length;i++)t[i].status===o.STATUS_YIELD_FRAME&&t[i].setStatus(o.STATUS_RUNNING);for(;t.length>0&&t.length>r&&this.timer.timeElapsed()<n.WORK_TIME;){var s=[];r=0;for(var a=0;a<t.length;a++){var u=t[a];u.status===o.STATUS_RUNNING?this.startThread(u):u.status!==o.STATUS_YIELD&&u.status!==o.STATUS_YIELD_FRAME||r++,0===u.stack.length&&u.status===o.STATUS_DONE?e.push(u):s.push(u)}t=s}return e},n.prototype.startThread=function(t){var e=t.peekStack();return e?(s(this,t),void(t.status===o.STATUS_RUNNING&&t.peekStack()===e&&this.proceedThread(t))):(t.popStack(),void t.setStatus(o.STATUS_YIELD_FRAME))},n.prototype.stepToBranch=function(t,e){e||(e=1);var r=t.peekStack(),n=this.runtime.targetForThread(t).blocks.getBranch(r,e);n?t.pushStack(n):t.pushStack(null)},n.prototype.stepToReporter=function(t,e,r){var n=t.peekStackFrame();return t.pushStack(e),n.waitingReporter=r,this.startThread(t),t.status===o.STATUS_YIELD},n.prototype.proceedThread=function(t){var e=t.peekStack();t.popStack();var r=this.runtime.targetForThread(t).blocks.getNextBlock(e);r&&t.pushStack(r),t.peekStack()||t.setStatus(o.STATUS_DONE)},n.prototype.retireThread=function(t){t.stack=[],t.stackFrame=[],t.setStatus(o.STATUS_DONE)},t.exports=n},function(t,e){function r(){}r.prototype.startTime=0,r.prototype.time=function(){return Date.now?Date.now():(new Date).getTime()},r.prototype.relativeTime=function(){return"undefined"!=typeof self&&self.performance&&"now"in self.performance?self.performance.now():this.time()},r.prototype.start=function(){this.startTime=this.relativeTime()},r.prototype.timeElapsed=function(){return this.relativeTime()-this.startTime},t.exports=r},function(t,e){function r(t){this.topBlock=t,this.stack=[],this.stackFrames=[],this.status=0,this.requestScriptGlowInFrame=!1}r.STATUS_RUNNING=0,r.STATUS_YIELD=1,r.STATUS_YIELD_FRAME=2,r.STATUS_DONE=3,r.prototype.pushStack=function(t){this.stack.push(t),this.stack.length>this.stackFrames.length&&this.stackFrames.push({reported:{},waitingReporter:null,executionContext:{}})},r.prototype.popStack=function(){return this.stackFrames.pop(),this.stack.pop()},r.prototype.peekStack=function(){return this.stack[this.stack.length-1]},r.prototype.peekStackFrame=function(){return this.stackFrames[this.stackFrames.length-1]},r.prototype.peekParentStackFrame=function(){return this.stackFrames[this.stackFrames.length-2]},r.prototype.pushReportedValue=function(t){var e=this.peekParentStackFrame();if(e){var r=e.waitingReporter;e.reported[r]=t,e.waitingReporter=null}},r.prototype.atStackTop=function(){return this.peekStack()===this.topBlock},r.prototype.setStatus=function(t){this.status=t},t.exports=r},function(t,e,r){var n=r(9),i=function(t){return t&&t.then&&"function"==typeof t.then},o=function(t,e){var r=t.runtime,o=r.targetForThread(e),s=e.peekStack(),a=e.peekStackFrame(),u=o.blocks.getOpcode(s),c=r.getOpcodeFunction(u),p=r.getIsHat(u),h=o.blocks.getFields(s),l=o.blocks.getInputs(s);if(!u)return void console.warn("Could not get opcode for block: "+s);var f=function(i){if(e.pushReportedValue(i),p)if(r.getIsEdgeActivatedHat(u)){var o=r.updateEdgeActivatedValue(s,i),a=!o&&i;a||t.retireThread(e)}else i||t.retireThread(e);else"undefined"!=typeof i&&e.atStackTop()&&r.visualReport(s,i),e.setStatus(n.STATUS_RUNNING)};if(!c){if(p)return;if(1==Object.keys(h).length&&0==Object.keys(l).length)for(var d in h)f(h[d].value);else console.warn("Could not get implementation for opcode: "+u);return void(e.requestScriptGlowInFrame=!0)}var g={};for(var m in h)g[m]=h[m].value;for(var _ in l){var y=l[_],b=y.block;if("undefined"==typeof a.reported[_]){var v=t.stepToReporter(e,b,_);if(v)return}g[_]=a.reported[_]}a.reported={};var w=null;w=c(g,{stackFrame:a.executionContext,target:o,"yield":function(){e.setStatus(n.STATUS_YIELD)},yieldFrame:function(){e.setStatus(n.STATUS_YIELD_FRAME)},done:function(){e.setStatus(n.STATUS_RUNNING),t.proceedThread(e)},startBranch:function(r){t.stepToBranch(e,r)},startHats:function(t,e,n){return r.startHats(t,e,n)},ioQuery:function(t,e,n){if(r.ioDevices[t]&&r.ioDevices[t][e]){var i=r.ioDevices[t];return i[e].call(i,n)}}}),"undefined"==typeof w&&(e.requestScriptGlowInFrame=!0),i(w)?(e.status===n.STATUS_RUNNING&&e.setStatus(n.STATUS_YIELD),w.then(function(r){f(r),t.proceedThread(e)},function(r){console.warn("Primitive rejected promise: ",r),e.setStatus(n.STATUS_RUNNING),t.proceedThread(e)})):e.status===n.STATUS_RUNNING&&f(w)};t.exports=o},function(t,e,r){function n(){this._projectTimer=new i,this._projectTimer.start()}var i=r(8);n.prototype.projectTimer=function(){return this._projectTimer.timeElapsed()/1e3},n.prototype.resetProjectTimer=function(){this._projectTimer.start()},t.exports=n},function(t,e,r){function n(t){this._keysPressed=[],this.runtime=t}var i=r(13);n.prototype._scratchKeyToKeyCode=function(t){if("number"==typeof t)return t;var e=i.toString(t);switch(e){case"space":return 32;case"left arrow":return 37;case"up arrow":return 38;case"right arrow":return 39;case"down arrow":return 40}return e.toUpperCase().charCodeAt(0)},n.prototype._keyCodeToScratchKey=function(t){if(t>=48&&t<=90)return String.fromCharCode(t).toLowerCase();switch(t){case 32:return"space";case 37:return"left arrow";case 38:return"up arrow";case 39:return"right arrow";case 40:return"down arrow"}return null},n.prototype.postData=function(t){if(t.keyCode){var e=this._keysPressed.indexOf(t.keyCode);t.isDown?(e<0&&this._keysPressed.push(t.keyCode),this.runtime.startHats("event_whenkeypressed",{KEY_OPTION:this._keyCodeToScratchKey(t.keyCode)}),this.runtime.startHats("event_whenkeypressed",{KEY_OPTION:"any"})):e>-1&&this._keysPressed.splice(e,1)}},n.prototype.getKeyIsDown=function(t){if("any"==t)return this._keysPressed.length>0;var e=this._scratchKeyToKeyCode(t);return this._keysPressed.indexOf(e)>-1},t.exports=n},function(t,e,r){function n(){}var i=r(14);n.toNumber=function(t){var e=Number(t);return isNaN(e)?0:e},n.toBoolean=function(t){return"boolean"==typeof t?t:"string"==typeof t?""!=t&&"0"!=t&&"false"!=t.toLowerCase():Boolean(t)},n.toString=function(t){return String(t)},n.toRgbColorList=function(t){var e;return e="string"==typeof t&&"#"==t.substring(0,1)?i.hexToRgb(t):i.decimalToRgb(n.toNumber(t)),[e.r,e.g,e.b]},n.compare=function(t,e){var r=Number(t),n=Number(e);if(isNaN(r)||isNaN(n)){var i=String(t).toLowerCase(),o=String(e).toLowerCase();return i.localeCompare(o)}return r-n},t.exports=n},function(t,e){function r(){}r.decimalToHex=function(t){t<0&&(t+=16777216);var e=Number(t).toString(16);return e="#"+"000000".substr(0,6-e.length)+e},r.decimalToRgb=function(t){var e=t>>16&255,r=t>>8&255,n=255&t;return{r:e,g:r,b:n}},r.hexToRgb=function(t){var e=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;t=t.replace(e,function(t,e,r,n){return e+e+r+r+n+n});var r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return r?{r:parseInt(r[1],16),g:parseInt(r[2],16),b:parseInt(r[3],16)}:null},r.rgbToHex=function(t){return r.decimalToHex(r.rgbToDecimal(t))},r.rgbToDecimal=function(t){return(t.r<<16)+(t.g<<8)+t.b},r.hexToDecimal=function(t){return r.rgbToDecimal(r.hexToRgb(t))},t.exports=r},function(t,e,r){function n(t){this._x=0,this._y=0,this._isDown=!1,this.runtime=t}var i=r(16);n.prototype.postData=function(t){t.x&&(this._x=t.x-t.canvasWidth/2),t.y&&(this._y=t.y-t.canvasHeight/2),"undefined"!=typeof t.isDown&&(this._isDown=t.isDown,this._isDown&&this._activateClickHats(t.x,t.y))},n.prototype._activateClickHats=function(t,e){if(self.renderer){var r=self.renderer.pick(t,e),n=this;r.then(function(t){for(var e=0;e<n.runtime.targets.length;e++){var r=n.runtime.targets[e];if(r.hasOwnProperty("drawableID")&&r.drawableID==t)return void n.runtime.startHats("event_whenthisspriteclicked",null,r)}})}},n.prototype.getX=function(){return i.clamp(this._x,-240,240)},n.prototype.getY=function(){return i.clamp(-this._y,-180,180)},n.prototype.getIsDown=function(){return this._isDown},t.exports=n},function(t,e){function r(){}r.degToRad=function(t){return Math.PI*(90-t)/180},r.radToDeg=function(t){return 180*t/Math.PI},r.clamp=function(t,e,r){return Math.min(Math.max(t,e),r)},r.wrapClamp=function(t,e,r){var n=r-e+1;return t-Math.floor((t-e)/n)*n},t.exports=r},function(t,e,r){function n(t){this.runtime=t}var i=r(13),o=r(18);n.prototype.getPrimitives=function(){return{control_repeat:this.repeat,control_repeat_until:this.repeatUntil,control_forever:this.forever,control_wait:this.wait,control_if:this["if"],control_if_else:this.ifElse,control_stop:this.stop}},n.prototype.repeat=function(t,e){var r=Math.floor(i.toNumber(t.TIMES));void 0===e.stackFrame.loopCounter&&(e.stackFrame.loopCounter=r),e.stackFrame.executedInFrame?(e.stackFrame.executedInFrame=!1,e.yieldFrame()):(e.stackFrame.executedInFrame=!0,e.stackFrame.loopCounter--,e.stackFrame.loopCounter>=0&&e.startBranch())},n.prototype.repeatUntil=function(t,e){var r=i.toBoolean(t.CONDITION);e.stackFrame.executedInFrame?(e.stackFrame.executedInFrame=!1,e.yieldFrame()):(e.stackFrame.executedInFrame=!0,r||e.startBranch())},n.prototype.forever=function(t,e){e.stackFrame.executedInFrame?(e.stackFrame.executedInFrame=!1,e.yieldFrame()):(e.stackFrame.executedInFrame=!0,e.startBranch())},n.prototype.wait=function(t){var e=i.toNumber(t.DURATION);return new o(function(t){setTimeout(function(){t()},1e3*e)})},n.prototype["if"]=function(t,e){var r=i.toBoolean(t.CONDITION);void 0===e.stackFrame.executedInFrame&&(e.stackFrame.executedInFrame=!0,r&&e.startBranch())},n.prototype.ifElse=function(t,e){var r=i.toBoolean(t.CONDITION);void 0===e.stackFrame.executedInFrame&&(e.stackFrame.executedInFrame=!0,r?e.startBranch(1):e.startBranch(2))},n.prototype.stop=function(){this.runtime.stopAll()},t.exports=n},function(t,e,r){"use strict";t.exports=r(19)},function(t,e,r){"use strict";t.exports=r(20),r(22),r(23),r(24),r(25),r(27)},function(t,e,r){"use strict";function n(){}function i(t){try{return t.then}catch(e){return _=e,y}}function o(t,e){try{return t(e)}catch(r){return _=r,y}}function s(t,e,r){try{t(e,r)}catch(n){return _=n,y}}function a(t){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._45=0,this._81=0,this._65=null,this._54=null,t!==n&&g(t,this)}function u(t,e,r){return new t.constructor(function(i,o){var s=new a(n);s.then(i,o),c(t,new d(e,r,s))})}function c(t,e){for(;3===t._81;)t=t._65;return a._10&&a._10(t),0===t._81?0===t._45?(t._45=1,void(t._54=e)):1===t._45?(t._45=2,void(t._54=[t._54,e])):void t._54.push(e):void p(t,e)}function p(t,e){m(function(){var r=1===t._81?e.onFulfilled:e.onRejected;if(null===r)return void(1===t._81?h(e.promise,t._65):l(e.promise,t._65));var n=o(r,t._65);n===y?l(e.promise,_):h(e.promise,n)})}function h(t,e){if(e===t)return l(t,new TypeError("A promise cannot be resolved with itself."));if(e&&("object"==typeof e||"function"==typeof e)){var r=i(e);if(r===y)return l(t,_);if(r===t.then&&e instanceof a)return t._81=3,t._65=e,void f(t);if("function"==typeof r)return void g(r.bind(e),t)}t._81=1,t._65=e,f(t)}function l(t,e){t._81=2,t._65=e,a._97&&a._97(t,e),f(t)}function f(t){if(1===t._45&&(c(t,t._54),t._54=null),2===t._45){for(var e=0;e<t._54.length;e++)c(t,t._54[e]);t._54=null}}function d(t,e,r){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.promise=r}function g(t,e){var r=!1,n=s(t,function(t){r||(r=!0,h(e,t))},function(t){r||(r=!0,l(e,t))});r||n!==y||(r=!0,l(e,_))}var m=r(21),_=null,y={};t.exports=a,a._10=null,a._97=null,a._61=n,a.prototype.then=function(t,e){if(this.constructor!==a)return u(this,t,e);var r=new a(n);return c(this,new d(t,e,r)),r}},function(t,e){(function(e){"use strict";function r(t){a.length||(s(),u=!0),a[a.length]=t}function n(){for(;c<a.length;){var t=c;if(c+=1,a[t].call(),c>p){for(var e=0,r=a.length-c;e<r;e++)a[e]=a[e+c];a.length-=c,c=0}}a.length=0,c=0,u=!1}function i(t){var e=1,r=new h(t),n=document.createTextNode("");return r.observe(n,{characterData:!0}),function(){e=-e,n.data=e}}function o(t){return function(){function e(){clearTimeout(r),clearInterval(n),t()}var r=setTimeout(e,0),n=setInterval(e,50)}}t.exports=r;var s,a=[],u=!1,c=0,p=1024,h=e.MutationObserver||e.WebKitMutationObserver;s="function"==typeof h?i(n):o(n),r.requestFlush=s,r.makeRequestCallFromTimer=o}).call(e,function(){return this}())},function(t,e,r){"use strict";var n=r(20);t.exports=n,n.prototype.done=function(t,e){var r=arguments.length?this.then.apply(this,arguments):this;r.then(null,function(t){setTimeout(function(){throw t},0)})}},function(t,e,r){"use strict";var n=r(20);t.exports=n,n.prototype["finally"]=function(t){return this.then(function(e){return n.resolve(t()).then(function(){return e})},function(e){return n.resolve(t()).then(function(){throw e})})}},function(t,e,r){ +"use strict";function n(t){var e=new i(i._61);return e._81=1,e._65=t,e}var i=r(20);t.exports=i;var o=n(!0),s=n(!1),a=n(null),u=n(void 0),c=n(0),p=n("");i.resolve=function(t){if(t instanceof i)return t;if(null===t)return a;if(void 0===t)return u;if(t===!0)return o;if(t===!1)return s;if(0===t)return c;if(""===t)return p;if("object"==typeof t||"function"==typeof t)try{var e=t.then;if("function"==typeof e)return new i(e.bind(t))}catch(r){return new i(function(t,e){e(r)})}return n(t)},i.all=function(t){var e=Array.prototype.slice.call(t);return new i(function(t,r){function n(s,a){if(a&&("object"==typeof a||"function"==typeof a)){if(a instanceof i&&a.then===i.prototype.then){for(;3===a._81;)a=a._65;return 1===a._81?n(s,a._65):(2===a._81&&r(a._65),void a.then(function(t){n(s,t)},r))}var u=a.then;if("function"==typeof u){var c=new i(u.bind(a));return void c.then(function(t){n(s,t)},r)}}e[s]=a,0===--o&&t(e)}if(0===e.length)return t([]);for(var o=e.length,s=0;s<e.length;s++)n(s,e[s])})},i.reject=function(t){return new i(function(e,r){r(t)})},i.race=function(t){return new i(function(e,r){t.forEach(function(t){i.resolve(t).then(e,r)})})},i.prototype["catch"]=function(t){return this.then(null,t)}},function(t,e,r){"use strict";function n(t,e){for(var r=[],n=0;n<e;n++)r.push("a"+n);var i=["return function ("+r.join(",")+") {","var self = this;","return new Promise(function (rs, rj) {","var res = fn.call(",["self"].concat(r).concat([a]).join(","),");","if (res &&",'(typeof res === "object" || typeof res === "function") &&','typeof res.then === "function"',") {rs(res);}","});","};"].join("");return Function(["Promise","fn"],i)(o,t)}function i(t){for(var e=Math.max(t.length-1,3),r=[],n=0;n<e;n++)r.push("a"+n);var i=["return function ("+r.join(",")+") {","var self = this;","var args;","var argLength = arguments.length;","if (arguments.length > "+e+") {","args = new Array(arguments.length + 1);","for (var i = 0; i < arguments.length; i++) {","args[i] = arguments[i];","}","}","return new Promise(function (rs, rj) {","var cb = "+a+";","var res;","switch (argLength) {",r.concat(["extra"]).map(function(t,e){return"case "+e+":res = fn.call("+["self"].concat(r.slice(0,e)).concat("cb").join(",")+");break;"}).join(""),"default:","args[argLength] = cb;","res = fn.apply(self, args);","}","if (res &&",'(typeof res === "object" || typeof res === "function") &&','typeof res.then === "function"',") {rs(res);}","});","};"].join("");return Function(["Promise","fn"],i)(o,t)}var o=r(20),s=r(26);t.exports=o,o.denodeify=function(t,e){return"number"==typeof e&&e!==1/0?n(t,e):i(t)};var a="function (err, res) {if (err) { rj(err); } else { rs(res); }}";o.nodeify=function(t){return function(){var e=Array.prototype.slice.call(arguments),r="function"==typeof e[e.length-1]?e.pop():null,n=this;try{return t.apply(this,arguments).nodeify(r,n)}catch(i){if(null===r||"undefined"==typeof r)return new o(function(t,e){e(i)});s(function(){r.call(n,i)})}}},o.prototype.nodeify=function(t,e){return"function"!=typeof t?this:void this.then(function(r){s(function(){t.call(e,null,r)})},function(r){s(function(){t.call(e,r)})})}},function(t,e,r){"use strict";function n(){if(u.length)throw u.shift()}function i(t){var e;e=a.length?a.pop():new o,e.task=t,s(e)}function o(){this.task=null}var s=r(21),a=[],u=[],c=s.makeRequestCallFromTimer(n);t.exports=i,o.prototype.call=function(){try{this.task.call()}catch(t){i.onerror?i.onerror(t):(u.push(t),c())}finally{this.task=null,a[a.length]=this}}},function(t,e,r){"use strict";var n=r(20);t.exports=n,n.enableSynchronous=function(){n.prototype.isPending=function(){return 0==this.getState()},n.prototype.isFulfilled=function(){return 1==this.getState()},n.prototype.isRejected=function(){return 2==this.getState()},n.prototype.getValue=function(){if(3===this._81)return this._65.getValue();if(!this.isFulfilled())throw new Error("Cannot get a value of an unfulfilled promise.");return this._65},n.prototype.getReason=function(){if(3===this._81)return this._65.getReason();if(!this.isRejected())throw new Error("Cannot get a rejection reason of a non-rejected promise.");return this._65},n.prototype.getState=function(){return 3===this._81?this._65.getState():this._81===-1||this._81===-2?0:this._81}},n.disableSynchronous=function(){n.prototype.isPending=void 0,n.prototype.isFulfilled=void 0,n.prototype.isRejected=void 0,n.prototype.getValue=void 0,n.prototype.getReason=void 0,n.prototype.getState=void 0}},function(t,e,r){function n(t){this.runtime=t}var i=r(13);n.prototype.getPrimitives=function(){return{event_broadcast:this.broadcast,event_broadcastandwait:this.broadcastAndWait,event_whengreaterthan:this.hatGreaterThanPredicate}},n.prototype.getHats=function(){return{event_whenflagclicked:{restartExistingThreads:!0},event_whenkeypressed:{restartExistingThreads:!1},event_whenthisspriteclicked:{restartExistingThreads:!0},event_whenbackdropswitchesto:{restartExistingThreads:!0},event_whengreaterthan:{restartExistingThreads:!1,edgeActivated:!0},event_whenbroadcastreceived:{restartExistingThreads:!0}}},n.prototype.hatGreaterThanPredicate=function(t,e){var r=i.toString(t.WHENGREATERTHANMENU).toLowerCase(),n=i.toNumber(t.VALUE);return"timer"==r&&e.ioQuery("clock","projectTimer")>n},n.prototype.broadcast=function(t,e){var r=i.toString(t.BROADCAST_OPTION);e.startHats("event_whenbroadcastreceived",{BROADCAST_OPTION:r})},n.prototype.broadcastAndWait=function(t,e){var r=i.toString(t.BROADCAST_OPTION);if(e.stackFrame.startedThreads||(e.stackFrame.startedThreads=e.startHats("event_whenbroadcastreceived",{BROADCAST_OPTION:r}),0!=e.stackFrame.startedThreads.length)){var n=this,o=e.stackFrame.startedThreads.some(function(t){return n.runtime.isActiveThread(t)});o&&e.yieldFrame()}},t.exports=n},function(t,e,r){function n(t){this.runtime=t}var i=r(13);n.prototype.getPrimitives=function(){return{looks_say:this.say,looks_sayforsecs:this.sayforsecs,looks_think:this.think,looks_thinkforsecs:this.sayforsecs,looks_show:this.show,looks_hide:this.hide,looks_switchcostumeto:this.switchCostume,looks_switchbackdropto:this.switchBackdrop,looks_switchbackdroptoandwait:this.switchBackdropAndWait,looks_nextcostume:this.nextCostume,looks_nextbackdrop:this.nextBackdrop,looks_changeeffectby:this.changeEffect,looks_seteffectto:this.setEffect,looks_cleargraphiceffects:this.clearEffects,looks_changesizeby:this.changeSize,looks_setsizeto:this.setSize,looks_size:this.getSize,looks_costumeorder:this.getCostumeIndex,looks_backdroporder:this.getBackdropIndex,looks_backdropname:this.getBackdropName}},n.prototype.say=function(t,e){e.target.setSay("say",t.MESSAGE)},n.prototype.sayforsecs=function(t,e){return e.target.setSay("say",t.MESSAGE),new Promise(function(r){setTimeout(function(){e.target.setSay(),r()},1e3*t.SECS)})},n.prototype.think=function(t,e){e.target.setSay("think",t.MESSAGE)},n.prototype.thinkforsecs=function(t,e){return e.target.setSay("think",t.MESSAGE),new Promise(function(r){setTimeout(function(){e.target.setSay(),r()},1e3*t.SECS)})},n.prototype.show=function(t,e){e.target.setVisible(!0)},n.prototype.hide=function(t,e){e.target.setVisible(!1)},n.prototype._setCostumeOrBackdrop=function(t,e,r){if("number"==typeof e)t.setCostume(r?e:e-1);else{var n=t.getCostumeIndexByName(e);if(n>-1)t.setCostume(n);else if("previous costume"==n||"previous backdrop"==n)t.setCostume(t.currentCostume-1);else if("next costume"==n||"next backdrop"==n)t.setCostume(t.currentCostume+1);else{var o=i.toNumber(e);isNaN(o)||t.setCostume(r?o:o-1)}}if(t==this.runtime.getTargetForStage()){var s=t.sprite.costumes[t.currentCostume].name;return this.runtime.startHats("event_whenbackdropswitchesto",{BACKDROP:s})}return[]},n.prototype.switchCostume=function(t,e){this._setCostumeOrBackdrop(e.target,t.COSTUME)},n.prototype.nextCostume=function(t,e){this._setCostumeOrBackdrop(e.target,e.target.currentCostume+1,!0)},n.prototype.switchBackdrop=function(t){this._setCostumeOrBackdrop(this.runtime.getTargetForStage(),t.BACKDROP)},n.prototype.switchBackdropAndWait=function(t,e){if(e.stackFrame.startedThreads||(e.stackFrame.startedThreads=this._setCostumeOrBackdrop(this.runtime.getTargetForStage(),t.BACKDROP),0!=e.stackFrame.startedThreads.length)){var r=this,n=e.stackFrame.startedThreads.some(function(t){return r.runtime.isActiveThread(t)});n&&e.yieldFrame()}},n.prototype.nextBackdrop=function(){var t=this.runtime.getTargetForStage();this._setCostumeOrBackdrop(t,t.currentCostume+1,!0)},n.prototype.changeEffect=function(t,e){var r=i.toString(t.EFFECT).toLowerCase(),n=i.toNumber(t.CHANGE);if(e.target.effects.hasOwnProperty(r)){var o=n+e.target.effects[r];e.target.setEffect(r,o)}},n.prototype.setEffect=function(t,e){var r=i.toString(t.EFFECT).toLowerCase(),n=i.toNumber(t.VALUE);e.target.setEffect(r,n)},n.prototype.clearEffects=function(t,e){e.target.clearEffects()},n.prototype.changeSize=function(t,e){var r=i.toNumber(t.CHANGE);e.target.setSize(e.target.size+r)},n.prototype.setSize=function(t,e){var r=i.toNumber(t.SIZE);e.target.setSize(r)},n.prototype.getSize=function(t,e){return e.target.size},n.prototype.getBackdropIndex=function(){var t=this.runtime.getTargetForStage();return t.currentCostume+1},n.prototype.getBackdropName=function(){var t=this.runtime.getTargetForStage();return t.sprite.costumes[t.currentCostume].name},n.prototype.getCostumeIndex=function(t,e){return e.target.currentCostume+1},t.exports=n},function(t,e,r){function n(t){this.runtime=t}var i=r(13),o=r(16),s=r(8);n.prototype.getPrimitives=function(){return{motion_movesteps:this.moveSteps,motion_gotoxy:this.goToXY,motion_turnright:this.turnRight,motion_turnleft:this.turnLeft,motion_pointindirection:this.pointInDirection,motion_glidesecstoxy:this.glide,motion_changexby:this.changeX,motion_setx:this.setX,motion_changeyby:this.changeY,motion_sety:this.setY,motion_xposition:this.getX,motion_yposition:this.getY,motion_direction:this.getDirection}},n.prototype.moveSteps=function(t,e){var r=i.toNumber(t.STEPS),n=o.degToRad(e.target.direction),s=r*Math.cos(n),a=r*Math.sin(n);e.target.setXY(e.target.x+s,e.target.y+a)},n.prototype.goToXY=function(t,e){var r=i.toNumber(t.X),n=i.toNumber(t.Y);e.target.setXY(r,n)},n.prototype.turnRight=function(t,e){var r=i.toNumber(t.DEGREES);e.target.setDirection(e.target.direction+r)},n.prototype.turnLeft=function(t,e){var r=i.toNumber(t.DEGREES);e.target.setDirection(e.target.direction-r)},n.prototype.pointInDirection=function(t,e){var r=i.toNumber(t.DIRECTION);e.target.setDirection(r)},n.prototype.glide=function(t,e){if(e.stackFrame.timer){var r=e.stackFrame.timer.timeElapsed();if(r<1e3*e.stackFrame.duration){var n=r/(1e3*e.stackFrame.duration),o=n*(e.stackFrame.endX-e.stackFrame.startX),a=n*(e.stackFrame.endY-e.stackFrame.startY);e.target.setXY(e.stackFrame.startX+o,e.stackFrame.startY+a),e.yieldFrame()}else e.target.setXY(e.stackFrame.endX,e.stackFrame.endY)}else{if(e.stackFrame.timer=new s,e.stackFrame.timer.start(),e.stackFrame.duration=i.toNumber(t.SECS),e.stackFrame.startX=e.target.x,e.stackFrame.startY=e.target.y,e.stackFrame.endX=i.toNumber(t.X),e.stackFrame.endY=i.toNumber(t.Y),e.stackFrame.duration<=0)return void e.target.setXY(e.stackFrame.endX,e.stackFrame.endY);e.yieldFrame()}},n.prototype.changeX=function(t,e){var r=i.toNumber(t.DX);e.target.setXY(e.target.x+r,e.target.y)},n.prototype.setX=function(t,e){var r=i.toNumber(t.X);e.target.setXY(r,e.target.y)},n.prototype.changeY=function(t,e){var r=i.toNumber(t.DY);e.target.setXY(e.target.x,e.target.y+r)},n.prototype.setY=function(t,e){var r=i.toNumber(t.Y);e.target.setXY(e.target.x,r)},n.prototype.getX=function(t,e){return e.target.x},n.prototype.getY=function(t,e){return e.target.y},n.prototype.getDirection=function(t,e){return e.target.direction},t.exports=n},function(t,e,r){function n(t){this.runtime=t}var i=r(13);n.prototype.getPrimitives=function(){return{operator_add:this.add,operator_subtract:this.subtract,operator_multiply:this.multiply,operator_divide:this.divide,operator_lt:this.lt,operator_equals:this.equals,operator_gt:this.gt,operator_and:this.and,operator_or:this.or,operator_not:this.not,operator_random:this.random,operator_join:this.join,operator_letter_of:this.letterOf,operator_length:this.length,operator_mod:this.mod,operator_round:this.round,operator_mathop:this.mathop}},n.prototype.add=function(t){return i.toNumber(t.NUM1)+i.toNumber(t.NUM2)},n.prototype.subtract=function(t){return i.toNumber(t.NUM1)-i.toNumber(t.NUM2)},n.prototype.multiply=function(t){return i.toNumber(t.NUM1)*i.toNumber(t.NUM2)},n.prototype.divide=function(t){return i.toNumber(t.NUM1)/i.toNumber(t.NUM2)},n.prototype.lt=function(t){return i.compare(t.OPERAND1,t.OPERAND2)<0},n.prototype.equals=function(t){return 0==i.compare(t.OPERAND1,t.OPERAND2)},n.prototype.gt=function(t){return i.compare(t.OPERAND1,t.OPERAND2)>0},n.prototype.and=function(t){return i.toBoolean(t.OPERAND1)&&i.toBoolean(t.OPERAND2)},n.prototype.or=function(t){return i.toBoolean(t.OPERAND1)||i.toBoolean(t.OPERAND2)},n.prototype.not=function(t){return!i.toBoolean(t.OPERAND)},n.prototype.random=function(t){var e=i.toNumber(t.FROM),r=i.toNumber(t.TO),n=e<=r?e:r,o=e<=r?r:e;if(n==o)return n;var s=n==parseInt(n),a=o==parseInt(o);return s&&a?n+parseInt(Math.random()*(o+1-n)):Math.random()*(o-n)+n},n.prototype.join=function(t){return i.toString(t.STRING1)+i.toString(t.STRING2)},n.prototype.letterOf=function(t){var e=i.toNumber(t.LETTER)-1,r=i.toString(t.STRING);return e<0||e>=r.length?"":r.charAt(e)},n.prototype.length=function(t){return i.toString(t.STRING).length},n.prototype.mod=function(t){var e=i.toNumber(t.NUM1),r=i.toNumber(t.NUM2),n=e%r;return n/r<0&&(n+=r),n},n.prototype.round=function(t){return Math.round(i.toNumber(t.NUM))},n.prototype.mathop=function(t){var e=i.toString(t.OPERATOR).toLowerCase(),r=i.toNumber(t.NUM);switch(e){case"abs":return Math.abs(r);case"floor":return Math.floor(r);case"ceiling":return Math.ceil(r);case"sqrt":return Math.sqrt(r);case"sin":return Math.sin(Math.PI*r/180);case"cos":return Math.cos(Math.PI*r/180);case"tan":return Math.tan(Math.PI*r/180);case"asin":return 180*Math.asin(r)/Math.PI;case"acos":return 180*Math.acos(r)/Math.PI;case"atan":return 180*Math.atan(r)/Math.PI;case"ln":return Math.log(r);case"log":return Math.log(r)/Math.LN10;case"e ^":return Math.exp(r);case"10 ^":return Math.pow(10,r)}return 0},t.exports=n},function(t,e,r){function n(t){this.runtime=t}var i=r(13);n.prototype.getPrimitives=function(){return{sensing_touchingcolor:this.touchingColor,sensing_coloristouchingcolor:this.colorTouchingColor,sensing_timer:this.getTimer,sensing_resettimer:this.resetTimer,sensing_mousex:this.getMouseX,sensing_mousey:this.getMouseY,sensing_mousedown:this.getMouseDown,sensing_keypressed:this.getKeyPressed,sensing_current:this.current}},n.prototype.touchingColor=function(t,e){var r=i.toRgbColorList(t.COLOR);return e.target.isTouchingColor(r)},n.prototype.colorTouchingColor=function(t,e){var r=i.toRgbColorList(t.COLOR),n=i.toRgbColorList(t.COLOR2);return e.target.colorIsTouchingColor(n,r)},n.prototype.getTimer=function(t,e){return e.ioQuery("clock","projectTimer")},n.prototype.resetTimer=function(t,e){e.ioQuery("clock","resetProjectTimer")},n.prototype.getMouseX=function(t,e){return e.ioQuery("mouse","getX")},n.prototype.getMouseY=function(t,e){return e.ioQuery("mouse","getY")},n.prototype.getMouseDown=function(t,e){return e.ioQuery("mouse","getIsDown")},n.prototype.current=function(t){var e=i.toString(t.CURRENTMENU).toLowerCase(),r=new Date;switch(e){case"year":return r.getFullYear();case"month":return r.getMonth()+1;case"date":return r.getDate();case"dayofweek":return r.getDay()+1;case"hour":return r.getHours();case"minute":return r.getMinutes();case"second":return r.getSeconds()}return 0},n.prototype.getKeyPressed=function(t,e){return e.ioQuery("keyboard","getKeyIsDown",t.KEY_OPTION)},t.exports=n},function(t,e,r){function n(t,e){i(JSON.parse(t),e,!0)}function i(t,e,r){if(t.hasOwnProperty("objName")){var n=new c,s=new p(n);if(t.hasOwnProperty("objName")&&(s.name=t.objName),t.hasOwnProperty("costumes"))for(var a=0;a<t.costumes.length;a++){var u=t.costumes[a];s.costumes.push({skin:"https://cdn.assets.scratch.mit.edu/internalapi/asset/"+u.baseLayerMD5+"/get/",name:u.costumeName,bitmapResolution:u.bitmapResolution,rotationCenterX:u.rotationCenterX,rotationCenterY:u.rotationCenterY})}t.hasOwnProperty("scripts")&&o(t.scripts,n);var h=s.createClone();if(e.targets.push(h),t.scratchX&&(h.x=t.scratchX),t.scratchY&&(h.y=t.scratchY),t.direction&&(h.direction=t.direction),t.scale&&(h.size=100*t.scale),t.visible&&(h.visible=t.visible),t.currentCostumeIndex&&(h.currentCostume=t.currentCostumeIndex),h.isStage=r,t.children)for(var l=0;l<t.children.length;l++)i(t.children[l],e,!1)}}function o(t,e){for(var r=0;r<t.length;r++){var n=t[r],i=n[0],o=n[1],u=n[2],c=s(u);c[0]&&(c[0].x=1.1*i,c[0].y=1.1*o,c[0].topLevel=!0,c[0].parent=null);for(var p=a(c),h=0;h<p.length;h++)e.createBlock(p[h])}}function s(t){for(var e=[],r=null,n=0;n<t.length;n++){var i=t[n],o=u(i);r&&(o.parent=r.id,r.next=o.id),r=o,e.push(o)}return e}function a(t){for(var e=[],r=0;r<t.length;r++){var n=t[r];e.push(n),n.children&&(e=e.concat(a(n.children))),delete n.children}return e}function u(t){var e=t[0];if(!e||!f[e])return void console.warn("Couldn't find SB2 block: ",e);for(var r=f[e],n={id:l(),opcode:r.opcode,inputs:{},fields:{},next:null,shadow:!1,children:[]},i=0;i<r.argMap.length;i++){var o=r.argMap[i],a=t[i+1],c=!1;if("input"==o.type){var p=l();if(n.inputs[o.inputName]={name:o.inputName,block:null,shadow:null},"object"==typeof a&&a){var d;d="object"==typeof a[0]&&a[0]?s(a):[u(a)];for(var g=0;g<d.length;g++)d[g].parent=n.id;c=!0,n.inputs[o.inputName].block=d[0].id,n.children=n.children.concat(d)}if(!o.inputOp)continue;var m=a,_=o.inputName;"math_number"==o.inputOp||"math_whole_number"==o.inputOp||"math_positive_number"==o.inputOp||"math_integer"==o.inputOp||"math_angle"==o.inputOp?(_="NUM",c&&(m=10)):"text"==o.inputOp?(_="TEXT",c&&(m="")):"colour_picker"==o.inputOp&&(m=h.decimalToHex(a),_="COLOUR",c&&(m="#990000"));var y={};y[_]={name:_,value:m},n.children.push({id:p,opcode:o.inputOp,inputs:{},fields:y,next:null,topLevel:!1,parent:n.id,shadow:!0}),n.inputs[o.inputName].shadow=p,n.inputs[o.inputName].block||(n.inputs[o.inputName].block=p)}else"field"==o.type&&(n.fields[o.fieldName]={name:o.fieldName,value:a})}return n}var c=r(34),p=r(85),h=r(14),l=r(88),f=r(89);t.exports=n},function(t,e,r){function n(){this._blocks={},this._scripts=[]}var i=r(35);n.BRANCH_INPUT_PREFIX="SUBSTACK",n.prototype.getBlock=function(t){return this._blocks[t]},n.prototype.getScripts=function(){return this._scripts},n.prototype.getNextBlock=function(t){return"undefined"==typeof this._blocks[t]?null:this._blocks[t].next},n.prototype.getBranch=function(t,e){var r=this._blocks[t];if("undefined"==typeof r)return null;e||(e=1);var i=n.BRANCH_INPUT_PREFIX;return e>1&&(i+=e),i in r.inputs?r.inputs[i].block:null},n.prototype.getOpcode=function(t){return"undefined"==typeof this._blocks[t]?null:this._blocks[t].opcode},n.prototype.getFields=function(t){return"undefined"==typeof this._blocks[t]?null:this._blocks[t].fields},n.prototype.getInputs=function(t){if("undefined"==typeof this._blocks[t])return null;var e={};for(var r in this._blocks[t].inputs)r.substring(0,n.BRANCH_INPUT_PREFIX.length)!=n.BRANCH_INPUT_PREFIX&&(e[r]=this._blocks[t].inputs[r]);return e},n.prototype.getTopLevelScript=function(t){if("undefined"==typeof this._blocks[t])return null;for(var e=this._blocks[t];null!==e.parent;)e=this._blocks[e.parent];return e.id},n.prototype.blocklyListen=function(t,e,r){if("object"==typeof t&&"string"==typeof t.blockId){if("stackclick"===t.element)return void(r&&r.toggleScript(t.blockId));switch(t.type){case"create":for(var n=i(t),o=0;o<n.length;o++)this.createBlock(n[o],e);break;case"change":this.changeBlock({id:t.blockId,element:t.element,name:t.name,value:t.newValue});break;case"move":this.moveBlock({id:t.blockId,oldParent:t.oldParentId,oldInput:t.oldInputName,newParent:t.newParentId,newInput:t.newInputName,newCoordinate:t.newCoordinate});break;case"delete":if(this._blocks[t.blockId].shadow)return;this.deleteBlock({id:t.blockId})}}},n.prototype.createBlock=function(t,e){this._blocks.hasOwnProperty(t.id)||(this._blocks[t.id]=t,!e&&t.topLevel&&this._addScript(t.id))},n.prototype.changeBlock=function(t){"field"===t.element&&"undefined"!=typeof this._blocks[t.id]&&"undefined"!=typeof this._blocks[t.id].fields[t.name]&&(this._blocks[t.id].fields[t.name].value=t.value)},n.prototype.moveBlock=function(t){if(t.newCoordinate&&(this._blocks[t.id].x=t.newCoordinate.x,this._blocks[t.id].y=t.newCoordinate.y),void 0!==t.oldParent){var e=this._blocks[t.oldParent];void 0!==t.oldInput&&e.inputs[t.oldInput].block===t.id?e.inputs[t.oldInput].block=null:e.next===t.id&&(e.next=null),this._blocks[t.id].parent=null}if(void 0===t.newParent)this._addScript(t.id);else{if(this._deleteScript(t.id),void 0!==t.newInput){var r=null;this._blocks[t.newParent].inputs.hasOwnProperty(t.newInput)&&(r=this._blocks[t.newParent].inputs[t.newInput].shadow),this._blocks[t.newParent].inputs[t.newInput]={name:t.newInput,block:t.id,shadow:r}}else this._blocks[t.newParent].next=t.id;this._blocks[t.id].parent=t.newParent}},n.prototype.deleteBlock=function(t){var e=this._blocks[t.id];null!==e.next&&this.deleteBlock({id:e.next});for(var r in e.inputs)null!==e.inputs[r].block&&this.deleteBlock({id:e.inputs[r].block}),null!==e.inputs[r].shadow&&e.inputs[r].shadow!==e.inputs[r].block&&this.deleteBlock({id:e.inputs[r].shadow});this._deleteScript(t.id),delete this._blocks[t.id]},n.prototype.toXML=function(){for(var t='<xml xmlns="http://www.w3.org/1999/xhtml">',e=0;e<this._scripts.length;e++)t+=this.blockToXML(this._scripts[e]);return t+"</xml>"},n.prototype.blockToXML=function(t){var e=this._blocks[t],r=e.shadow?"shadow":"block",n=e.topLevel?' x="'+e.x+'" y="'+e.y+'"':"",i="";i+="<"+r+' id="'+e.id+'" type="'+e.opcode+'"'+n+">";for(var o in e.inputs){var s=e.inputs[o];(s.block||s.shadow)&&(i+='<value name="'+s.name+'">',s.block&&(i+=this.blockToXML(s.block)),s.shadow&&s.shadow!=s.block&&(i+=this.blockToXML(s.shadow)),i+="</value>")}for(var a in e.fields){var u=e.fields[a];i+='<field name="'+u.name+'">'+u.value+"</field>"}return e.next&&(i+="<next>"+this.blockToXML(e.next)+"</next>"),i+="</"+r+">"},n.prototype._addScript=function(t){var e=this._scripts.indexOf(t);e>-1||(this._scripts.push(t),this._blocks[t].topLevel=!0)},n.prototype._deleteScript=function(t){var e=this._scripts.indexOf(t);e>-1&&this._scripts.splice(e,1),this._blocks[t]&&(this._blocks[t].topLevel=!1)},t.exports=n},function(t,e,r){function n(t){for(var e={},r=0;r<t.length;r++){var n=t[r];if(n.name&&n.attribs){var o=n.name.toLowerCase();"block"!=o&&"shadow"!=o||i(n,e,!0,null)}}var s=[];for(var a in e)s.push(e[a]);return s}function i(t,e,r,n){var o={id:t.attribs.id,opcode:t.attribs.type,inputs:{},fields:{},next:null,topLevel:r,parent:n,shadow:"shadow"==t.name,x:t.attribs.x,y:t.attribs.y};e[o.id]=o;for(var s=0;s<t.children.length;s++){for(var a=t.children[s],u=null,c=null,p=0;p<a.children.length;p++){var h=a.children[p];if(h.name){var l=h.name.toLowerCase();"block"==l?u=h:"shadow"==l&&(c=h)}}switch(!u&&c&&(u=c),a.name.toLowerCase()){case"field":var f=a.attribs.name,d="";d=a.children.length>0&&a.children[0].data?a.children[0].data:"",o.fields[f]={name:f,value:d};break;case"value":case"statement":i(u,e,!1,o.id),c&&u!=c&&i(c,e,!1,o.id);var g=a.attribs.name;o.inputs[g]={name:g,block:u.attribs.id,shadow:c?c.attribs.id:null};break;case"next":if(!u||!u.attribs)continue;i(u,e,!1,o.id),o.next=u.attribs.id}}}var o=r(36);t.exports=function(t){if("object"==typeof t&&"object"==typeof t.xml)return n(o.parseDOM(t.xml.outerHTML))}},function(t,e,r){function n(e,r){return delete t.exports[e],t.exports[e]=r,r}var i=r(37),o=r(44);t.exports={Parser:i,Tokenizer:r(38),ElementType:r(45),DomHandler:o,get FeedHandler(){return n("FeedHandler",r(48))},get Stream(){return n("Stream",r(49))},get WritableStream(){return n("WritableStream",r(50))},get ProxyHandler(){return n("ProxyHandler",r(71))},get DomUtils(){return n("DomUtils",r(72))},get CollectingHandler(){return n("CollectingHandler",r(84))},DefaultHandler:o,get RssHandler(){return n("RssHandler",this.FeedHandler)},parseDOM:function(t,e){var r=new o(e);return new i(r,e).end(t),r.dom},parseFeed:function(e,r){var n=new t.exports.FeedHandler(r);return new i(n,r).end(e),n.dom},createDomStream:function(t,e,r){var n=new o(t,e,r);return new i(n,e)},EVENTS:{attribute:2,cdatastart:0,cdataend:0,text:1,processinginstruction:2,comment:1,commentend:0,closetag:1,opentag:2,opentagname:1,error:1,end:0}}},function(t,e,r){function n(t,e){this._options=e||{},this._cbs=t||{},this._tagname="",this._attribname="",this._attribvalue="",this._attribs=null,this._stack=[],this.startIndex=0,this.endIndex=null,this._lowerCaseTagNames="lowerCaseTags"in this._options?!!this._options.lowerCaseTags:!this._options.xmlMode,this._lowerCaseAttributeNames="lowerCaseAttributeNames"in this._options?!!this._options.lowerCaseAttributeNames:!this._options.xmlMode,this._options.Tokenizer&&(i=this._options.Tokenizer),this._tokenizer=new i(this._options,this),this._cbs.onparserinit&&this._cbs.onparserinit(this)}var i=r(38),o={input:!0,option:!0,optgroup:!0,select:!0,button:!0,datalist:!0,textarea:!0},s={tr:{tr:!0,th:!0,td:!0},th:{th:!0},td:{thead:!0,th:!0,td:!0},body:{head:!0,link:!0,script:!0},li:{li:!0},p:{p:!0},h1:{p:!0},h2:{p:!0},h3:{p:!0},h4:{p:!0},h5:{p:!0},h6:{p:!0},select:o,input:o,output:o,button:o,datalist:o,textarea:o,option:{option:!0},optgroup:{optgroup:!0}},a={__proto__:null,area:!0,base:!0,basefont:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,isindex:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,path:!0,circle:!0,ellipse:!0,line:!0,rect:!0,use:!0,stop:!0,polyline:!0,polygon:!0},u=/\s|\//;r(2).inherits(n,r(1).EventEmitter),n.prototype._updatePosition=function(t){null===this.endIndex?this._tokenizer._sectionStart<=t?this.startIndex=0:this.startIndex=this._tokenizer._sectionStart-t:this.startIndex=this.endIndex+1,this.endIndex=this._tokenizer.getAbsoluteIndex()},n.prototype.ontext=function(t){this._updatePosition(1),this.endIndex--,this._cbs.ontext&&this._cbs.ontext(t)},n.prototype.onopentagname=function(t){if(this._lowerCaseTagNames&&(t=t.toLowerCase()),this._tagname=t,!this._options.xmlMode&&t in s)for(var e;(e=this._stack[this._stack.length-1])in s[t];this.onclosetag(e));!this._options.xmlMode&&t in a||this._stack.push(t),this._cbs.onopentagname&&this._cbs.onopentagname(t),this._cbs.onopentag&&(this._attribs={})},n.prototype.onopentagend=function(){this._updatePosition(1),this._attribs&&(this._cbs.onopentag&&this._cbs.onopentag(this._tagname,this._attribs),this._attribs=null),!this._options.xmlMode&&this._cbs.onclosetag&&this._tagname in a&&this._cbs.onclosetag(this._tagname),this._tagname=""},n.prototype.onclosetag=function(t){if(this._updatePosition(1),this._lowerCaseTagNames&&(t=t.toLowerCase()),!this._stack.length||t in a&&!this._options.xmlMode)this._options.xmlMode||"br"!==t&&"p"!==t||(this.onopentagname(t),this._closeCurrentTag());else{var e=this._stack.lastIndexOf(t);if(e!==-1)if(this._cbs.onclosetag)for(e=this._stack.length-e;e--;)this._cbs.onclosetag(this._stack.pop());else this._stack.length=e;else"p"!==t||this._options.xmlMode||(this.onopentagname(t),this._closeCurrentTag())}},n.prototype.onselfclosingtag=function(){this._options.xmlMode||this._options.recognizeSelfClosing?this._closeCurrentTag():this.onopentagend()},n.prototype._closeCurrentTag=function(){var t=this._tagname;this.onopentagend(),this._stack[this._stack.length-1]===t&&(this._cbs.onclosetag&&this._cbs.onclosetag(t),this._stack.pop())},n.prototype.onattribname=function(t){this._lowerCaseAttributeNames&&(t=t.toLowerCase()),this._attribname=t},n.prototype.onattribdata=function(t){this._attribvalue+=t},n.prototype.onattribend=function(){this._cbs.onattribute&&this._cbs.onattribute(this._attribname,this._attribvalue),this._attribs&&!Object.prototype.hasOwnProperty.call(this._attribs,this._attribname)&&(this._attribs[this._attribname]=this._attribvalue),this._attribname="",this._attribvalue=""},n.prototype._getInstructionName=function(t){var e=t.search(u),r=e<0?t:t.substr(0,e);return this._lowerCaseTagNames&&(r=r.toLowerCase()),r},n.prototype.ondeclaration=function(t){if(this._cbs.onprocessinginstruction){var e=this._getInstructionName(t);this._cbs.onprocessinginstruction("!"+e,"!"+t)}},n.prototype.onprocessinginstruction=function(t){if(this._cbs.onprocessinginstruction){var e=this._getInstructionName(t);this._cbs.onprocessinginstruction("?"+e,"?"+t)}},n.prototype.oncomment=function(t){this._updatePosition(4),this._cbs.oncomment&&this._cbs.oncomment(t),this._cbs.oncommentend&&this._cbs.oncommentend()},n.prototype.oncdata=function(t){this._updatePosition(1),this._options.xmlMode||this._options.recognizeCDATA?(this._cbs.oncdatastart&&this._cbs.oncdatastart(),this._cbs.ontext&&this._cbs.ontext(t),this._cbs.oncdataend&&this._cbs.oncdataend()):this.oncomment("[CDATA["+t+"]]")},n.prototype.onerror=function(t){this._cbs.onerror&&this._cbs.onerror(t)},n.prototype.onend=function(){if(this._cbs.onclosetag)for(var t=this._stack.length;t>0;this._cbs.onclosetag(this._stack[--t]));this._cbs.onend&&this._cbs.onend()},n.prototype.reset=function(){this._cbs.onreset&&this._cbs.onreset(),this._tokenizer.reset(),this._tagname="",this._attribname="",this._attribs=null,this._stack=[],this._cbs.onparserinit&&this._cbs.onparserinit(this)},n.prototype.parseComplete=function(t){this.reset(),this.end(t)},n.prototype.write=function(t){this._tokenizer.write(t)},n.prototype.end=function(t){this._tokenizer.end(t)},n.prototype.pause=function(){this._tokenizer.pause()},n.prototype.resume=function(){this._tokenizer.resume()},n.prototype.parseChunk=n.prototype.write,n.prototype.done=n.prototype.end,t.exports=n},function(t,e,r){function n(t){return" "===t||"\n"===t||"\t"===t||"\f"===t||"\r"===t}function i(t,e){return function(r){r===t&&(this._state=e)}}function o(t,e,r){var n=t.toLowerCase();return t===n?function(t){t===n?this._state=e:(this._state=r,this._index--)}:function(i){i===n||i===t?this._state=e:(this._state=r,this._index--)}}function s(t,e){var r=t.toLowerCase();return function(n){n===r||n===t?this._state=e:(this._state=g,this._index--)}}function a(t,e){this._state=f,this._buffer="",this._sectionStart=0,this._index=0,this._bufferOffset=0,this._baseState=f,this._special=gt,this._cbs=e,this._running=!0,this._ended=!1,this._xmlMode=!(!t||!t.xmlMode),this._decodeEntities=!(!t||!t.decodeEntities)}t.exports=a;var u=r(39),c=r(41),p=r(42),h=r(43),l=0,f=l++,d=l++,g=l++,m=l++,_=l++,y=l++,b=l++,v=l++,w=l++,S=l++,k=l++,T=l++,E=l++,x=l++,N=l++,O=l++,A=l++,C=l++,M=l++,L=l++,R=l++,D=l++,I=l++,B=l++,P=l++,U=l++,q=l++,F=l++,j=l++,G=l++,V=l++,H=l++,Y=l++,z=l++,X=l++,W=l++,K=l++,Q=l++,J=l++,Z=l++,$=l++,tt=l++,et=l++,rt=l++,nt=l++,it=l++,ot=l++,st=l++,at=l++,ut=l++,ct=l++,pt=l++,ht=l++,lt=l++,ft=l++,dt=0,gt=dt++,mt=dt++,_t=dt++;a.prototype._stateText=function(t){"<"===t?(this._index>this._sectionStart&&this._cbs.ontext(this._getSection()),this._state=d,this._sectionStart=this._index):this._decodeEntities&&this._special===gt&&"&"===t&&(this._index>this._sectionStart&&this._cbs.ontext(this._getSection()),this._baseState=f,this._state=ct,this._sectionStart=this._index)},a.prototype._stateBeforeTagName=function(t){"/"===t?this._state=_:">"===t||this._special!==gt||n(t)?this._state=f:"!"===t?(this._state=N,this._sectionStart=this._index+1):"?"===t?(this._state=A,this._sectionStart=this._index+1):"<"===t?(this._cbs.ontext(this._getSection()),this._sectionStart=this._index):(this._state=this._xmlMode||"s"!==t&&"S"!==t?g:V,this._sectionStart=this._index)},a.prototype._stateInTagName=function(t){("/"===t||">"===t||n(t))&&(this._emitToken("onopentagname"),this._state=v,this._index--)},a.prototype._stateBeforeCloseingTagName=function(t){n(t)||(">"===t?this._state=f:this._special!==gt?"s"===t||"S"===t?this._state=H:(this._state=f, +this._index--):(this._state=y,this._sectionStart=this._index))},a.prototype._stateInCloseingTagName=function(t){(">"===t||n(t))&&(this._emitToken("onclosetag"),this._state=b,this._index--)},a.prototype._stateAfterCloseingTagName=function(t){">"===t&&(this._state=f,this._sectionStart=this._index+1)},a.prototype._stateBeforeAttributeName=function(t){">"===t?(this._cbs.onopentagend(),this._state=f,this._sectionStart=this._index+1):"/"===t?this._state=m:n(t)||(this._state=w,this._sectionStart=this._index)},a.prototype._stateInSelfClosingTag=function(t){">"===t?(this._cbs.onselfclosingtag(),this._state=f,this._sectionStart=this._index+1):n(t)||(this._state=v,this._index--)},a.prototype._stateInAttributeName=function(t){("="===t||"/"===t||">"===t||n(t))&&(this._cbs.onattribname(this._getSection()),this._sectionStart=-1,this._state=S,this._index--)},a.prototype._stateAfterAttributeName=function(t){"="===t?this._state=k:"/"===t||">"===t?(this._cbs.onattribend(),this._state=v,this._index--):n(t)||(this._cbs.onattribend(),this._state=w,this._sectionStart=this._index)},a.prototype._stateBeforeAttributeValue=function(t){'"'===t?(this._state=T,this._sectionStart=this._index+1):"'"===t?(this._state=E,this._sectionStart=this._index+1):n(t)||(this._state=x,this._sectionStart=this._index,this._index--)},a.prototype._stateInAttributeValueDoubleQuotes=function(t){'"'===t?(this._emitToken("onattribdata"),this._cbs.onattribend(),this._state=v):this._decodeEntities&&"&"===t&&(this._emitToken("onattribdata"),this._baseState=this._state,this._state=ct,this._sectionStart=this._index)},a.prototype._stateInAttributeValueSingleQuotes=function(t){"'"===t?(this._emitToken("onattribdata"),this._cbs.onattribend(),this._state=v):this._decodeEntities&&"&"===t&&(this._emitToken("onattribdata"),this._baseState=this._state,this._state=ct,this._sectionStart=this._index)},a.prototype._stateInAttributeValueNoQuotes=function(t){n(t)||">"===t?(this._emitToken("onattribdata"),this._cbs.onattribend(),this._state=v,this._index--):this._decodeEntities&&"&"===t&&(this._emitToken("onattribdata"),this._baseState=this._state,this._state=ct,this._sectionStart=this._index)},a.prototype._stateBeforeDeclaration=function(t){this._state="["===t?D:"-"===t?C:O},a.prototype._stateInDeclaration=function(t){">"===t&&(this._cbs.ondeclaration(this._getSection()),this._state=f,this._sectionStart=this._index+1)},a.prototype._stateInProcessingInstruction=function(t){">"===t&&(this._cbs.onprocessinginstruction(this._getSection()),this._state=f,this._sectionStart=this._index+1)},a.prototype._stateBeforeComment=function(t){"-"===t?(this._state=M,this._sectionStart=this._index+1):this._state=O},a.prototype._stateInComment=function(t){"-"===t&&(this._state=L)},a.prototype._stateAfterComment1=function(t){"-"===t?this._state=R:this._state=M},a.prototype._stateAfterComment2=function(t){">"===t?(this._cbs.oncomment(this._buffer.substring(this._sectionStart,this._index-2)),this._state=f,this._sectionStart=this._index+1):"-"!==t&&(this._state=M)},a.prototype._stateBeforeCdata1=o("C",I,O),a.prototype._stateBeforeCdata2=o("D",B,O),a.prototype._stateBeforeCdata3=o("A",P,O),a.prototype._stateBeforeCdata4=o("T",U,O),a.prototype._stateBeforeCdata5=o("A",q,O),a.prototype._stateBeforeCdata6=function(t){"["===t?(this._state=F,this._sectionStart=this._index+1):(this._state=O,this._index--)},a.prototype._stateInCdata=function(t){"]"===t&&(this._state=j)},a.prototype._stateAfterCdata1=i("]",G),a.prototype._stateAfterCdata2=function(t){">"===t?(this._cbs.oncdata(this._buffer.substring(this._sectionStart,this._index-2)),this._state=f,this._sectionStart=this._index+1):"]"!==t&&(this._state=F)},a.prototype._stateBeforeSpecial=function(t){"c"===t||"C"===t?this._state=Y:"t"===t||"T"===t?this._state=et:(this._state=g,this._index--)},a.prototype._stateBeforeSpecialEnd=function(t){this._special!==mt||"c"!==t&&"C"!==t?this._special!==_t||"t"!==t&&"T"!==t?this._state=f:this._state=ot:this._state=Q},a.prototype._stateBeforeScript1=s("R",z),a.prototype._stateBeforeScript2=s("I",X),a.prototype._stateBeforeScript3=s("P",W),a.prototype._stateBeforeScript4=s("T",K),a.prototype._stateBeforeScript5=function(t){("/"===t||">"===t||n(t))&&(this._special=mt),this._state=g,this._index--},a.prototype._stateAfterScript1=o("R",J,f),a.prototype._stateAfterScript2=o("I",Z,f),a.prototype._stateAfterScript3=o("P",$,f),a.prototype._stateAfterScript4=o("T",tt,f),a.prototype._stateAfterScript5=function(t){">"===t||n(t)?(this._special=gt,this._state=y,this._sectionStart=this._index-6,this._index--):this._state=f},a.prototype._stateBeforeStyle1=s("Y",rt),a.prototype._stateBeforeStyle2=s("L",nt),a.prototype._stateBeforeStyle3=s("E",it),a.prototype._stateBeforeStyle4=function(t){("/"===t||">"===t||n(t))&&(this._special=_t),this._state=g,this._index--},a.prototype._stateAfterStyle1=o("Y",st,f),a.prototype._stateAfterStyle2=o("L",at,f),a.prototype._stateAfterStyle3=o("E",ut,f),a.prototype._stateAfterStyle4=function(t){">"===t||n(t)?(this._special=gt,this._state=y,this._sectionStart=this._index-5,this._index--):this._state=f},a.prototype._stateBeforeEntity=o("#",pt,ht),a.prototype._stateBeforeNumericEntity=o("X",ft,lt),a.prototype._parseNamedEntityStrict=function(){if(this._sectionStart+1<this._index){var t=this._buffer.substring(this._sectionStart+1,this._index),e=this._xmlMode?h:c;e.hasOwnProperty(t)&&(this._emitPartial(e[t]),this._sectionStart=this._index+1)}},a.prototype._parseLegacyEntity=function(){var t=this._sectionStart+1,e=this._index-t;for(e>6&&(e=6);e>=2;){var r=this._buffer.substr(t,e);if(p.hasOwnProperty(r))return this._emitPartial(p[r]),void(this._sectionStart+=e+1);e--}},a.prototype._stateInNamedEntity=function(t){";"===t?(this._parseNamedEntityStrict(),this._sectionStart+1<this._index&&!this._xmlMode&&this._parseLegacyEntity(),this._state=this._baseState):(t<"a"||t>"z")&&(t<"A"||t>"Z")&&(t<"0"||t>"9")&&(this._xmlMode||this._sectionStart+1===this._index||(this._baseState!==f?"="!==t&&this._parseNamedEntityStrict():this._parseLegacyEntity()),this._state=this._baseState,this._index--)},a.prototype._decodeNumericEntity=function(t,e){var r=this._sectionStart+t;if(r!==this._index){var n=this._buffer.substring(r,this._index),i=parseInt(n,e);this._emitPartial(u(i)),this._sectionStart=this._index}else this._sectionStart--;this._state=this._baseState},a.prototype._stateInNumericEntity=function(t){";"===t?(this._decodeNumericEntity(2,10),this._sectionStart++):(t<"0"||t>"9")&&(this._xmlMode?this._state=this._baseState:this._decodeNumericEntity(2,10),this._index--)},a.prototype._stateInHexEntity=function(t){";"===t?(this._decodeNumericEntity(3,16),this._sectionStart++):(t<"a"||t>"f")&&(t<"A"||t>"F")&&(t<"0"||t>"9")&&(this._xmlMode?this._state=this._baseState:this._decodeNumericEntity(3,16),this._index--)},a.prototype._cleanup=function(){this._sectionStart<0?(this._buffer="",this._index=0,this._bufferOffset+=this._index):this._running&&(this._state===f?(this._sectionStart!==this._index&&this._cbs.ontext(this._buffer.substr(this._sectionStart)),this._buffer="",this._index=0,this._bufferOffset+=this._index):this._sectionStart===this._index?(this._buffer="",this._index=0,this._bufferOffset+=this._index):(this._buffer=this._buffer.substr(this._sectionStart),this._index-=this._sectionStart,this._bufferOffset+=this._sectionStart),this._sectionStart=0)},a.prototype.write=function(t){this._ended&&this._cbs.onerror(Error(".write() after done!")),this._buffer+=t,this._parse()},a.prototype._parse=function(){for(;this._index<this._buffer.length&&this._running;){var t=this._buffer.charAt(this._index);this._state===f?this._stateText(t):this._state===d?this._stateBeforeTagName(t):this._state===g?this._stateInTagName(t):this._state===_?this._stateBeforeCloseingTagName(t):this._state===y?this._stateInCloseingTagName(t):this._state===b?this._stateAfterCloseingTagName(t):this._state===m?this._stateInSelfClosingTag(t):this._state===v?this._stateBeforeAttributeName(t):this._state===w?this._stateInAttributeName(t):this._state===S?this._stateAfterAttributeName(t):this._state===k?this._stateBeforeAttributeValue(t):this._state===T?this._stateInAttributeValueDoubleQuotes(t):this._state===E?this._stateInAttributeValueSingleQuotes(t):this._state===x?this._stateInAttributeValueNoQuotes(t):this._state===N?this._stateBeforeDeclaration(t):this._state===O?this._stateInDeclaration(t):this._state===A?this._stateInProcessingInstruction(t):this._state===C?this._stateBeforeComment(t):this._state===M?this._stateInComment(t):this._state===L?this._stateAfterComment1(t):this._state===R?this._stateAfterComment2(t):this._state===D?this._stateBeforeCdata1(t):this._state===I?this._stateBeforeCdata2(t):this._state===B?this._stateBeforeCdata3(t):this._state===P?this._stateBeforeCdata4(t):this._state===U?this._stateBeforeCdata5(t):this._state===q?this._stateBeforeCdata6(t):this._state===F?this._stateInCdata(t):this._state===j?this._stateAfterCdata1(t):this._state===G?this._stateAfterCdata2(t):this._state===V?this._stateBeforeSpecial(t):this._state===H?this._stateBeforeSpecialEnd(t):this._state===Y?this._stateBeforeScript1(t):this._state===z?this._stateBeforeScript2(t):this._state===X?this._stateBeforeScript3(t):this._state===W?this._stateBeforeScript4(t):this._state===K?this._stateBeforeScript5(t):this._state===Q?this._stateAfterScript1(t):this._state===J?this._stateAfterScript2(t):this._state===Z?this._stateAfterScript3(t):this._state===$?this._stateAfterScript4(t):this._state===tt?this._stateAfterScript5(t):this._state===et?this._stateBeforeStyle1(t):this._state===rt?this._stateBeforeStyle2(t):this._state===nt?this._stateBeforeStyle3(t):this._state===it?this._stateBeforeStyle4(t):this._state===ot?this._stateAfterStyle1(t):this._state===st?this._stateAfterStyle2(t):this._state===at?this._stateAfterStyle3(t):this._state===ut?this._stateAfterStyle4(t):this._state===ct?this._stateBeforeEntity(t):this._state===pt?this._stateBeforeNumericEntity(t):this._state===ht?this._stateInNamedEntity(t):this._state===lt?this._stateInNumericEntity(t):this._state===ft?this._stateInHexEntity(t):this._cbs.onerror(Error("unknown _state"),this._state),this._index++}this._cleanup()},a.prototype.pause=function(){this._running=!1},a.prototype.resume=function(){this._running=!0,this._index<this._buffer.length&&this._parse(),this._ended&&this._finish()},a.prototype.end=function(t){this._ended&&this._cbs.onerror(Error(".end() after done!")),t&&this.write(t),this._ended=!0,this._running&&this._finish()},a.prototype._finish=function(){this._sectionStart<this._index&&this._handleTrailingData(),this._cbs.onend()},a.prototype._handleTrailingData=function(){var t=this._buffer.substr(this._sectionStart);this._state===F||this._state===j||this._state===G?this._cbs.oncdata(t):this._state===M||this._state===L||this._state===R?this._cbs.oncomment(t):this._state!==ht||this._xmlMode?this._state!==lt||this._xmlMode?this._state!==ft||this._xmlMode?this._state!==g&&this._state!==v&&this._state!==k&&this._state!==S&&this._state!==w&&this._state!==E&&this._state!==T&&this._state!==x&&this._state!==y&&this._cbs.ontext(t):(this._decodeNumericEntity(3,16),this._sectionStart<this._index&&(this._state=this._baseState,this._handleTrailingData())):(this._decodeNumericEntity(2,10),this._sectionStart<this._index&&(this._state=this._baseState,this._handleTrailingData())):(this._parseLegacyEntity(),this._sectionStart<this._index&&(this._state=this._baseState,this._handleTrailingData()))},a.prototype.reset=function(){a.call(this,{xmlMode:this._xmlMode,decodeEntities:this._decodeEntities},this._cbs)},a.prototype.getAbsoluteIndex=function(){return this._bufferOffset+this._index},a.prototype._getSection=function(){return this._buffer.substring(this._sectionStart,this._index)},a.prototype._emitToken=function(t){this._cbs[t](this._getSection()),this._sectionStart=-1},a.prototype._emitPartial=function(t){this._baseState!==f?this._cbs.onattribdata(t):this._cbs.ontext(t)}},function(t,e,r){function n(t){if(t>=55296&&t<=57343||t>1114111)return"�";t in i&&(t=i[t]);var e="";return t>65535&&(t-=65536,e+=String.fromCharCode(t>>>10&1023|55296),t=56320|1023&t),e+=String.fromCharCode(t)}var i=r(40);t.exports=n},function(t,e){t.exports={0:65533,128:8364,130:8218,131:402,132:8222,133:8230,134:8224,135:8225,136:710,137:8240,138:352,139:8249,140:338,142:381,145:8216,146:8217,147:8220,148:8221,149:8226,150:8211,151:8212,152:732,153:8482,154:353,155:8250,156:339,158:382,159:376}},function(t,e){t.exports={Aacute:"Á",aacute:"á",Abreve:"Ă",abreve:"ă",ac:"∾",acd:"∿",acE:"∾̳",Acirc:"Â",acirc:"â",acute:"´",Acy:"А",acy:"а",AElig:"Æ",aelig:"æ",af:"",Afr:"𝔄",afr:"𝔞",Agrave:"À",agrave:"à",alefsym:"ℵ",aleph:"ℵ",Alpha:"Α",alpha:"α",Amacr:"Ā",amacr:"ā",amalg:"⨿",amp:"&",AMP:"&",andand:"⩕",And:"⩓",and:"∧",andd:"⩜",andslope:"⩘",andv:"⩚",ang:"∠",ange:"⦤",angle:"∠",angmsdaa:"⦨",angmsdab:"⦩",angmsdac:"⦪",angmsdad:"⦫",angmsdae:"⦬",angmsdaf:"⦭",angmsdag:"⦮",angmsdah:"⦯",angmsd:"∡",angrt:"∟",angrtvb:"⊾",angrtvbd:"⦝",angsph:"∢",angst:"Å",angzarr:"⍼",Aogon:"Ą",aogon:"ą",Aopf:"𝔸",aopf:"𝕒",apacir:"⩯",ap:"≈",apE:"⩰",ape:"≊",apid:"≋",apos:"'",ApplyFunction:"",approx:"≈",approxeq:"≊",Aring:"Å",aring:"å",Ascr:"𝒜",ascr:"𝒶",Assign:"≔",ast:"*",asymp:"≈",asympeq:"≍",Atilde:"Ã",atilde:"ã",Auml:"Ä",auml:"ä",awconint:"∳",awint:"⨑",backcong:"≌",backepsilon:"϶",backprime:"‵",backsim:"∽",backsimeq:"⋍",Backslash:"∖",Barv:"⫧",barvee:"⊽",barwed:"⌅",Barwed:"⌆",barwedge:"⌅",bbrk:"⎵",bbrktbrk:"⎶",bcong:"≌",Bcy:"Б",bcy:"б",bdquo:"„",becaus:"∵",because:"∵",Because:"∵",bemptyv:"⦰",bepsi:"϶",bernou:"ℬ",Bernoullis:"ℬ",Beta:"Β",beta:"β",beth:"ℶ",between:"≬",Bfr:"𝔅",bfr:"𝔟",bigcap:"⋂",bigcirc:"◯",bigcup:"⋃",bigodot:"⨀",bigoplus:"⨁",bigotimes:"⨂",bigsqcup:"⨆",bigstar:"★",bigtriangledown:"▽",bigtriangleup:"△",biguplus:"⨄",bigvee:"⋁",bigwedge:"⋀",bkarow:"⤍",blacklozenge:"⧫",blacksquare:"▪",blacktriangle:"▴",blacktriangledown:"▾",blacktriangleleft:"◂",blacktriangleright:"▸",blank:"␣",blk12:"▒",blk14:"░",blk34:"▓",block:"█",bne:"=⃥",bnequiv:"≡⃥",bNot:"⫭",bnot:"⌐",Bopf:"𝔹",bopf:"𝕓",bot:"⊥",bottom:"⊥",bowtie:"⋈",boxbox:"⧉",boxdl:"┐",boxdL:"╕",boxDl:"╖",boxDL:"╗",boxdr:"┌",boxdR:"╒",boxDr:"╓",boxDR:"╔",boxh:"─",boxH:"═",boxhd:"┬",boxHd:"╤",boxhD:"╥",boxHD:"╦",boxhu:"┴",boxHu:"╧",boxhU:"╨",boxHU:"╩",boxminus:"⊟",boxplus:"⊞",boxtimes:"⊠",boxul:"┘",boxuL:"╛",boxUl:"╜",boxUL:"╝",boxur:"└",boxuR:"╘",boxUr:"╙",boxUR:"╚",boxv:"│",boxV:"║",boxvh:"┼",boxvH:"╪",boxVh:"╫",boxVH:"╬",boxvl:"┤",boxvL:"╡",boxVl:"╢",boxVL:"╣",boxvr:"├",boxvR:"╞",boxVr:"╟",boxVR:"╠",bprime:"‵",breve:"˘",Breve:"˘",brvbar:"¦",bscr:"𝒷",Bscr:"ℬ",bsemi:"⁏",bsim:"∽",bsime:"⋍",bsolb:"⧅",bsol:"\\",bsolhsub:"⟈",bull:"•",bullet:"•",bump:"≎",bumpE:"⪮",bumpe:"≏",Bumpeq:"≎",bumpeq:"≏",Cacute:"Ć",cacute:"ć",capand:"⩄",capbrcup:"⩉",capcap:"⩋",cap:"∩",Cap:"⋒",capcup:"⩇",capdot:"⩀",CapitalDifferentialD:"ⅅ",caps:"∩︀",caret:"⁁",caron:"ˇ",Cayleys:"ℭ",ccaps:"⩍",Ccaron:"Č",ccaron:"č",Ccedil:"Ç",ccedil:"ç",Ccirc:"Ĉ",ccirc:"ĉ",Cconint:"∰",ccups:"⩌",ccupssm:"⩐",Cdot:"Ċ",cdot:"ċ",cedil:"¸",Cedilla:"¸",cemptyv:"⦲",cent:"¢",centerdot:"·",CenterDot:"·",cfr:"𝔠",Cfr:"ℭ",CHcy:"Ч",chcy:"ч",check:"✓",checkmark:"✓",Chi:"Χ",chi:"χ",circ:"ˆ",circeq:"≗",circlearrowleft:"↺",circlearrowright:"↻",circledast:"⊛",circledcirc:"⊚",circleddash:"⊝",CircleDot:"⊙",circledR:"®",circledS:"Ⓢ",CircleMinus:"⊖",CirclePlus:"⊕",CircleTimes:"⊗",cir:"○",cirE:"⧃",cire:"≗",cirfnint:"⨐",cirmid:"⫯",cirscir:"⧂",ClockwiseContourIntegral:"∲",CloseCurlyDoubleQuote:"”",CloseCurlyQuote:"’",clubs:"♣",clubsuit:"♣",colon:":",Colon:"∷",Colone:"⩴",colone:"≔",coloneq:"≔",comma:",",commat:"@",comp:"∁",compfn:"∘",complement:"∁",complexes:"ℂ",cong:"≅",congdot:"⩭",Congruent:"≡",conint:"∮",Conint:"∯",ContourIntegral:"∮",copf:"𝕔",Copf:"ℂ",coprod:"∐",Coproduct:"∐",copy:"©",COPY:"©",copysr:"℗",CounterClockwiseContourIntegral:"∳",crarr:"↵",cross:"✗",Cross:"⨯",Cscr:"𝒞",cscr:"𝒸",csub:"⫏",csube:"⫑",csup:"⫐",csupe:"⫒",ctdot:"⋯",cudarrl:"⤸",cudarrr:"⤵",cuepr:"⋞",cuesc:"⋟",cularr:"↶",cularrp:"⤽",cupbrcap:"⩈",cupcap:"⩆",CupCap:"≍",cup:"∪",Cup:"⋓",cupcup:"⩊",cupdot:"⊍",cupor:"⩅",cups:"∪︀",curarr:"↷",curarrm:"⤼",curlyeqprec:"⋞",curlyeqsucc:"⋟",curlyvee:"⋎",curlywedge:"⋏",curren:"¤",curvearrowleft:"↶",curvearrowright:"↷",cuvee:"⋎",cuwed:"⋏",cwconint:"∲",cwint:"∱",cylcty:"⌭",dagger:"†",Dagger:"‡",daleth:"ℸ",darr:"↓",Darr:"↡",dArr:"⇓",dash:"‐",Dashv:"⫤",dashv:"⊣",dbkarow:"⤏",dblac:"˝",Dcaron:"Ď",dcaron:"ď",Dcy:"Д",dcy:"д",ddagger:"‡",ddarr:"⇊",DD:"ⅅ",dd:"ⅆ",DDotrahd:"⤑",ddotseq:"⩷",deg:"°",Del:"∇",Delta:"Δ",delta:"δ",demptyv:"⦱",dfisht:"⥿",Dfr:"𝔇",dfr:"𝔡",dHar:"⥥",dharl:"⇃",dharr:"⇂",DiacriticalAcute:"´",DiacriticalDot:"˙",DiacriticalDoubleAcute:"˝",DiacriticalGrave:"`",DiacriticalTilde:"˜",diam:"⋄",diamond:"⋄",Diamond:"⋄",diamondsuit:"♦",diams:"♦",die:"¨",DifferentialD:"ⅆ",digamma:"ϝ",disin:"⋲",div:"÷",divide:"÷",divideontimes:"⋇",divonx:"⋇",DJcy:"Ђ",djcy:"ђ",dlcorn:"⌞",dlcrop:"⌍",dollar:"$",Dopf:"𝔻",dopf:"𝕕",Dot:"¨",dot:"˙",DotDot:"⃜",doteq:"≐",doteqdot:"≑",DotEqual:"≐",dotminus:"∸",dotplus:"∔",dotsquare:"⊡",doublebarwedge:"⌆",DoubleContourIntegral:"∯",DoubleDot:"¨",DoubleDownArrow:"⇓",DoubleLeftArrow:"⇐",DoubleLeftRightArrow:"⇔",DoubleLeftTee:"⫤",DoubleLongLeftArrow:"⟸",DoubleLongLeftRightArrow:"⟺",DoubleLongRightArrow:"⟹",DoubleRightArrow:"⇒",DoubleRightTee:"⊨",DoubleUpArrow:"⇑",DoubleUpDownArrow:"⇕",DoubleVerticalBar:"∥",DownArrowBar:"⤓",downarrow:"↓",DownArrow:"↓",Downarrow:"⇓",DownArrowUpArrow:"⇵",DownBreve:"̑",downdownarrows:"⇊",downharpoonleft:"⇃",downharpoonright:"⇂",DownLeftRightVector:"⥐",DownLeftTeeVector:"⥞",DownLeftVectorBar:"⥖",DownLeftVector:"↽",DownRightTeeVector:"⥟",DownRightVectorBar:"⥗",DownRightVector:"⇁",DownTeeArrow:"↧",DownTee:"⊤",drbkarow:"⤐",drcorn:"⌟",drcrop:"⌌",Dscr:"𝒟",dscr:"𝒹",DScy:"Ѕ",dscy:"ѕ",dsol:"⧶",Dstrok:"Đ",dstrok:"đ",dtdot:"⋱",dtri:"▿",dtrif:"▾",duarr:"⇵",duhar:"⥯",dwangle:"⦦",DZcy:"Џ",dzcy:"џ",dzigrarr:"⟿",Eacute:"É",eacute:"é",easter:"⩮",Ecaron:"Ě",ecaron:"ě",Ecirc:"Ê",ecirc:"ê",ecir:"≖",ecolon:"≕",Ecy:"Э",ecy:"э",eDDot:"⩷",Edot:"Ė",edot:"ė",eDot:"≑",ee:"ⅇ",efDot:"≒",Efr:"𝔈",efr:"𝔢",eg:"⪚",Egrave:"È",egrave:"è",egs:"⪖",egsdot:"⪘",el:"⪙",Element:"∈",elinters:"⏧",ell:"ℓ",els:"⪕",elsdot:"⪗",Emacr:"Ē",emacr:"ē",empty:"∅",emptyset:"∅",EmptySmallSquare:"◻",emptyv:"∅",EmptyVerySmallSquare:"▫",emsp13:" ",emsp14:" ",emsp:" ",ENG:"Ŋ",eng:"ŋ",ensp:" ",Eogon:"Ę",eogon:"ę",Eopf:"𝔼",eopf:"𝕖",epar:"⋕",eparsl:"⧣",eplus:"⩱",epsi:"ε",Epsilon:"Ε",epsilon:"ε",epsiv:"ϵ",eqcirc:"≖",eqcolon:"≕",eqsim:"≂",eqslantgtr:"⪖",eqslantless:"⪕",Equal:"⩵",equals:"=",EqualTilde:"≂",equest:"≟",Equilibrium:"⇌",equiv:"≡",equivDD:"⩸",eqvparsl:"⧥",erarr:"⥱",erDot:"≓",escr:"ℯ",Escr:"ℰ",esdot:"≐",Esim:"⩳",esim:"≂",Eta:"Η",eta:"η",ETH:"Ð",eth:"ð",Euml:"Ë",euml:"ë",euro:"€",excl:"!",exist:"∃",Exists:"∃",expectation:"ℰ",exponentiale:"ⅇ",ExponentialE:"ⅇ",fallingdotseq:"≒",Fcy:"Ф",fcy:"ф",female:"♀",ffilig:"ffi",fflig:"ff",ffllig:"ffl",Ffr:"𝔉",ffr:"𝔣",filig:"fi",FilledSmallSquare:"◼",FilledVerySmallSquare:"▪",fjlig:"fj",flat:"♭",fllig:"fl",fltns:"▱",fnof:"ƒ",Fopf:"𝔽",fopf:"𝕗",forall:"∀",ForAll:"∀",fork:"⋔",forkv:"⫙",Fouriertrf:"ℱ",fpartint:"⨍",frac12:"½",frac13:"⅓",frac14:"¼",frac15:"⅕",frac16:"⅙",frac18:"⅛",frac23:"⅔",frac25:"⅖",frac34:"¾",frac35:"⅗",frac38:"⅜",frac45:"⅘",frac56:"⅚",frac58:"⅝",frac78:"⅞",frasl:"⁄",frown:"⌢",fscr:"𝒻",Fscr:"ℱ",gacute:"ǵ",Gamma:"Γ",gamma:"γ",Gammad:"Ϝ",gammad:"ϝ",gap:"⪆",Gbreve:"Ğ",gbreve:"ğ",Gcedil:"Ģ",Gcirc:"Ĝ",gcirc:"ĝ",Gcy:"Г",gcy:"г",Gdot:"Ġ",gdot:"ġ",ge:"≥",gE:"≧",gEl:"⪌",gel:"⋛",geq:"≥",geqq:"≧",geqslant:"⩾",gescc:"⪩",ges:"⩾",gesdot:"⪀",gesdoto:"⪂",gesdotol:"⪄",gesl:"⋛︀",gesles:"⪔",Gfr:"𝔊",gfr:"𝔤",gg:"≫",Gg:"⋙",ggg:"⋙",gimel:"ℷ",GJcy:"Ѓ",gjcy:"ѓ",gla:"⪥",gl:"≷",glE:"⪒",glj:"⪤",gnap:"⪊",gnapprox:"⪊",gne:"⪈",gnE:"≩",gneq:"⪈",gneqq:"≩",gnsim:"⋧",Gopf:"𝔾",gopf:"𝕘",grave:"`",GreaterEqual:"≥",GreaterEqualLess:"⋛",GreaterFullEqual:"≧",GreaterGreater:"⪢",GreaterLess:"≷",GreaterSlantEqual:"⩾",GreaterTilde:"≳",Gscr:"𝒢",gscr:"ℊ",gsim:"≳",gsime:"⪎",gsiml:"⪐",gtcc:"⪧",gtcir:"⩺",gt:">",GT:">",Gt:"≫",gtdot:"⋗",gtlPar:"⦕",gtquest:"⩼",gtrapprox:"⪆",gtrarr:"⥸",gtrdot:"⋗",gtreqless:"⋛",gtreqqless:"⪌",gtrless:"≷",gtrsim:"≳",gvertneqq:"≩︀",gvnE:"≩︀",Hacek:"ˇ",hairsp:" ",half:"½",hamilt:"ℋ",HARDcy:"Ъ",hardcy:"ъ",harrcir:"⥈",harr:"↔",hArr:"⇔",harrw:"↭",Hat:"^",hbar:"ℏ",Hcirc:"Ĥ",hcirc:"ĥ",hearts:"♥",heartsuit:"♥",hellip:"…",hercon:"⊹",hfr:"𝔥",Hfr:"ℌ",HilbertSpace:"ℋ",hksearow:"⤥",hkswarow:"⤦",hoarr:"⇿",homtht:"∻",hookleftarrow:"↩",hookrightarrow:"↪",hopf:"𝕙",Hopf:"ℍ",horbar:"―",HorizontalLine:"─",hscr:"𝒽",Hscr:"ℋ",hslash:"ℏ",Hstrok:"Ħ",hstrok:"ħ",HumpDownHump:"≎",HumpEqual:"≏",hybull:"⁃",hyphen:"‐",Iacute:"Í",iacute:"í",ic:"",Icirc:"Î",icirc:"î",Icy:"И",icy:"и",Idot:"İ",IEcy:"Е",iecy:"е",iexcl:"¡",iff:"⇔",ifr:"𝔦",Ifr:"ℑ",Igrave:"Ì",igrave:"ì",ii:"ⅈ",iiiint:"⨌",iiint:"∭",iinfin:"⧜",iiota:"℩",IJlig:"IJ",ijlig:"ij",Imacr:"Ī",imacr:"ī",image:"ℑ",ImaginaryI:"ⅈ",imagline:"ℐ",imagpart:"ℑ",imath:"ı",Im:"ℑ",imof:"⊷",imped:"Ƶ",Implies:"⇒",incare:"℅","in":"∈",infin:"∞",infintie:"⧝",inodot:"ı",intcal:"⊺","int":"∫",Int:"∬",integers:"ℤ",Integral:"∫",intercal:"⊺",Intersection:"⋂",intlarhk:"⨗",intprod:"⨼",InvisibleComma:"",InvisibleTimes:"",IOcy:"Ё",iocy:"ё",Iogon:"Į",iogon:"į",Iopf:"𝕀",iopf:"𝕚",Iota:"Ι",iota:"ι",iprod:"⨼",iquest:"¿",iscr:"𝒾",Iscr:"ℐ",isin:"∈",isindot:"⋵",isinE:"⋹",isins:"⋴",isinsv:"⋳",isinv:"∈",it:"",Itilde:"Ĩ",itilde:"ĩ",Iukcy:"І",iukcy:"і",Iuml:"Ï",iuml:"ï",Jcirc:"Ĵ",jcirc:"ĵ",Jcy:"Й",jcy:"й",Jfr:"𝔍",jfr:"𝔧",jmath:"ȷ",Jopf:"𝕁",jopf:"𝕛",Jscr:"𝒥",jscr:"𝒿",Jsercy:"Ј",jsercy:"ј",Jukcy:"Є",jukcy:"є",Kappa:"Κ",kappa:"κ",kappav:"ϰ",Kcedil:"Ķ",kcedil:"ķ",Kcy:"К",kcy:"к",Kfr:"𝔎",kfr:"𝔨",kgreen:"ĸ",KHcy:"Х",khcy:"х",KJcy:"Ќ",kjcy:"ќ",Kopf:"𝕂",kopf:"𝕜",Kscr:"𝒦",kscr:"𝓀",lAarr:"⇚",Lacute:"Ĺ",lacute:"ĺ",laemptyv:"⦴",lagran:"ℒ",Lambda:"Λ",lambda:"λ",lang:"⟨",Lang:"⟪",langd:"⦑",langle:"⟨",lap:"⪅",Laplacetrf:"ℒ",laquo:"«",larrb:"⇤",larrbfs:"⤟",larr:"←",Larr:"↞",lArr:"⇐",larrfs:"⤝",larrhk:"↩",larrlp:"↫",larrpl:"⤹",larrsim:"⥳",larrtl:"↢",latail:"⤙",lAtail:"⤛",lat:"⪫",late:"⪭",lates:"⪭︀",lbarr:"⤌",lBarr:"⤎",lbbrk:"❲",lbrace:"{",lbrack:"[",lbrke:"⦋",lbrksld:"⦏",lbrkslu:"⦍",Lcaron:"Ľ",lcaron:"ľ",Lcedil:"Ļ",lcedil:"ļ",lceil:"⌈",lcub:"{",Lcy:"Л",lcy:"л",ldca:"⤶",ldquo:"“",ldquor:"„",ldrdhar:"⥧",ldrushar:"⥋",ldsh:"↲",le:"≤",lE:"≦",LeftAngleBracket:"⟨",LeftArrowBar:"⇤",leftarrow:"←",LeftArrow:"←",Leftarrow:"⇐",LeftArrowRightArrow:"⇆",leftarrowtail:"↢",LeftCeiling:"⌈",LeftDoubleBracket:"⟦",LeftDownTeeVector:"⥡",LeftDownVectorBar:"⥙",LeftDownVector:"⇃",LeftFloor:"⌊",leftharpoondown:"↽",leftharpoonup:"↼",leftleftarrows:"⇇",leftrightarrow:"↔",LeftRightArrow:"↔",Leftrightarrow:"⇔",leftrightarrows:"⇆",leftrightharpoons:"⇋",leftrightsquigarrow:"↭",LeftRightVector:"⥎",LeftTeeArrow:"↤",LeftTee:"⊣",LeftTeeVector:"⥚",leftthreetimes:"⋋",LeftTriangleBar:"⧏",LeftTriangle:"⊲",LeftTriangleEqual:"⊴",LeftUpDownVector:"⥑",LeftUpTeeVector:"⥠",LeftUpVectorBar:"⥘",LeftUpVector:"↿",LeftVectorBar:"⥒",LeftVector:"↼",lEg:"⪋",leg:"⋚",leq:"≤",leqq:"≦",leqslant:"⩽",lescc:"⪨",les:"⩽",lesdot:"⩿",lesdoto:"⪁",lesdotor:"⪃",lesg:"⋚︀",lesges:"⪓",lessapprox:"⪅",lessdot:"⋖",lesseqgtr:"⋚",lesseqqgtr:"⪋",LessEqualGreater:"⋚",LessFullEqual:"≦",LessGreater:"≶",lessgtr:"≶",LessLess:"⪡",lesssim:"≲",LessSlantEqual:"⩽",LessTilde:"≲",lfisht:"⥼",lfloor:"⌊",Lfr:"𝔏",lfr:"𝔩",lg:"≶",lgE:"⪑",lHar:"⥢",lhard:"↽",lharu:"↼",lharul:"⥪",lhblk:"▄",LJcy:"Љ",ljcy:"љ",llarr:"⇇",ll:"≪",Ll:"⋘",llcorner:"⌞",Lleftarrow:"⇚",llhard:"⥫",lltri:"◺",Lmidot:"Ŀ",lmidot:"ŀ",lmoustache:"⎰",lmoust:"⎰",lnap:"⪉",lnapprox:"⪉",lne:"⪇",lnE:"≨",lneq:"⪇",lneqq:"≨",lnsim:"⋦",loang:"⟬",loarr:"⇽",lobrk:"⟦",longleftarrow:"⟵",LongLeftArrow:"⟵",Longleftarrow:"⟸",longleftrightarrow:"⟷",LongLeftRightArrow:"⟷",Longleftrightarrow:"⟺",longmapsto:"⟼",longrightarrow:"⟶",LongRightArrow:"⟶",Longrightarrow:"⟹",looparrowleft:"↫",looparrowright:"↬",lopar:"⦅",Lopf:"𝕃",lopf:"𝕝",loplus:"⨭",lotimes:"⨴",lowast:"∗",lowbar:"_",LowerLeftArrow:"↙",LowerRightArrow:"↘",loz:"◊",lozenge:"◊",lozf:"⧫",lpar:"(",lparlt:"⦓",lrarr:"⇆",lrcorner:"⌟",lrhar:"⇋",lrhard:"⥭",lrm:"",lrtri:"⊿",lsaquo:"‹",lscr:"𝓁",Lscr:"ℒ",lsh:"↰",Lsh:"↰",lsim:"≲",lsime:"⪍",lsimg:"⪏",lsqb:"[",lsquo:"‘",lsquor:"‚",Lstrok:"Ł",lstrok:"ł",ltcc:"⪦",ltcir:"⩹",lt:"<",LT:"<",Lt:"≪",ltdot:"⋖",lthree:"⋋",ltimes:"⋉",ltlarr:"⥶",ltquest:"⩻",ltri:"◃",ltrie:"⊴",ltrif:"◂",ltrPar:"⦖",lurdshar:"⥊",luruhar:"⥦",lvertneqq:"≨︀",lvnE:"≨︀",macr:"¯",male:"♂",malt:"✠",maltese:"✠",Map:"⤅",map:"↦",mapsto:"↦",mapstodown:"↧",mapstoleft:"↤",mapstoup:"↥",marker:"▮",mcomma:"⨩",Mcy:"М",mcy:"м",mdash:"—",mDDot:"∺",measuredangle:"∡",MediumSpace:" ",Mellintrf:"ℳ",Mfr:"𝔐",mfr:"𝔪",mho:"℧",micro:"µ",midast:"*",midcir:"⫰",mid:"∣",middot:"·",minusb:"⊟",minus:"−",minusd:"∸",minusdu:"⨪",MinusPlus:"∓",mlcp:"⫛",mldr:"…",mnplus:"∓",models:"⊧",Mopf:"𝕄",mopf:"𝕞",mp:"∓",mscr:"𝓂",Mscr:"ℳ",mstpos:"∾",Mu:"Μ",mu:"μ",multimap:"⊸",mumap:"⊸",nabla:"∇",Nacute:"Ń",nacute:"ń",nang:"∠⃒",nap:"≉",napE:"⩰̸",napid:"≋̸",napos:"ʼn",napprox:"≉",natural:"♮",naturals:"ℕ",natur:"♮",nbsp:" ",nbump:"≎̸",nbumpe:"≏̸",ncap:"⩃",Ncaron:"Ň",ncaron:"ň",Ncedil:"Ņ",ncedil:"ņ",ncong:"≇",ncongdot:"⩭̸",ncup:"⩂",Ncy:"Н",ncy:"н",ndash:"–",nearhk:"⤤",nearr:"↗",neArr:"⇗",nearrow:"↗",ne:"≠",nedot:"≐̸",NegativeMediumSpace:"",NegativeThickSpace:"",NegativeThinSpace:"",NegativeVeryThinSpace:"",nequiv:"≢",nesear:"⤨",nesim:"≂̸",NestedGreaterGreater:"≫",NestedLessLess:"≪",NewLine:"\n",nexist:"∄",nexists:"∄",Nfr:"𝔑",nfr:"𝔫",ngE:"≧̸",nge:"≱",ngeq:"≱",ngeqq:"≧̸",ngeqslant:"⩾̸",nges:"⩾̸",nGg:"⋙̸",ngsim:"≵",nGt:"≫⃒",ngt:"≯",ngtr:"≯",nGtv:"≫̸",nharr:"↮",nhArr:"⇎",nhpar:"⫲",ni:"∋",nis:"⋼",nisd:"⋺",niv:"∋",NJcy:"Њ",njcy:"њ",nlarr:"↚",nlArr:"⇍",nldr:"‥",nlE:"≦̸",nle:"≰",nleftarrow:"↚",nLeftarrow:"⇍",nleftrightarrow:"↮",nLeftrightarrow:"⇎",nleq:"≰",nleqq:"≦̸",nleqslant:"⩽̸",nles:"⩽̸",nless:"≮",nLl:"⋘̸",nlsim:"≴",nLt:"≪⃒",nlt:"≮",nltri:"⋪",nltrie:"⋬",nLtv:"≪̸",nmid:"∤",NoBreak:"",NonBreakingSpace:" ",nopf:"𝕟",Nopf:"ℕ",Not:"⫬",not:"¬",NotCongruent:"≢",NotCupCap:"≭",NotDoubleVerticalBar:"∦",NotElement:"∉",NotEqual:"≠",NotEqualTilde:"≂̸",NotExists:"∄",NotGreater:"≯",NotGreaterEqual:"≱",NotGreaterFullEqual:"≧̸",NotGreaterGreater:"≫̸",NotGreaterLess:"≹",NotGreaterSlantEqual:"⩾̸",NotGreaterTilde:"≵",NotHumpDownHump:"≎̸",NotHumpEqual:"≏̸",notin:"∉",notindot:"⋵̸",notinE:"⋹̸",notinva:"∉",notinvb:"⋷",notinvc:"⋶",NotLeftTriangleBar:"⧏̸",NotLeftTriangle:"⋪",NotLeftTriangleEqual:"⋬",NotLess:"≮",NotLessEqual:"≰",NotLessGreater:"≸",NotLessLess:"≪̸",NotLessSlantEqual:"⩽̸",NotLessTilde:"≴",NotNestedGreaterGreater:"⪢̸",NotNestedLessLess:"⪡̸",notni:"∌",notniva:"∌",notnivb:"⋾",notnivc:"⋽",NotPrecedes:"⊀",NotPrecedesEqual:"⪯̸",NotPrecedesSlantEqual:"⋠",NotReverseElement:"∌",NotRightTriangleBar:"⧐̸",NotRightTriangle:"⋫",NotRightTriangleEqual:"⋭",NotSquareSubset:"⊏̸",NotSquareSubsetEqual:"⋢",NotSquareSuperset:"⊐̸",NotSquareSupersetEqual:"⋣",NotSubset:"⊂⃒",NotSubsetEqual:"⊈",NotSucceeds:"⊁",NotSucceedsEqual:"⪰̸",NotSucceedsSlantEqual:"⋡",NotSucceedsTilde:"≿̸",NotSuperset:"⊃⃒",NotSupersetEqual:"⊉",NotTilde:"≁",NotTildeEqual:"≄",NotTildeFullEqual:"≇",NotTildeTilde:"≉",NotVerticalBar:"∤",nparallel:"∦",npar:"∦",nparsl:"⫽⃥",npart:"∂̸",npolint:"⨔",npr:"⊀",nprcue:"⋠",nprec:"⊀",npreceq:"⪯̸",npre:"⪯̸",nrarrc:"⤳̸",nrarr:"↛",nrArr:"⇏",nrarrw:"↝̸",nrightarrow:"↛",nRightarrow:"⇏",nrtri:"⋫",nrtrie:"⋭",nsc:"⊁",nsccue:"⋡",nsce:"⪰̸",Nscr:"𝒩",nscr:"𝓃",nshortmid:"∤",nshortparallel:"∦",nsim:"≁",nsime:"≄",nsimeq:"≄",nsmid:"∤",nspar:"∦",nsqsube:"⋢",nsqsupe:"⋣",nsub:"⊄",nsubE:"⫅̸",nsube:"⊈",nsubset:"⊂⃒",nsubseteq:"⊈",nsubseteqq:"⫅̸",nsucc:"⊁",nsucceq:"⪰̸",nsup:"⊅",nsupE:"⫆̸",nsupe:"⊉",nsupset:"⊃⃒",nsupseteq:"⊉",nsupseteqq:"⫆̸",ntgl:"≹",Ntilde:"Ñ",ntilde:"ñ",ntlg:"≸",ntriangleleft:"⋪",ntrianglelefteq:"⋬",ntriangleright:"⋫",ntrianglerighteq:"⋭",Nu:"Ν",nu:"ν",num:"#",numero:"№",numsp:" ",nvap:"≍⃒",nvdash:"⊬",nvDash:"⊭",nVdash:"⊮",nVDash:"⊯",nvge:"≥⃒",nvgt:">⃒",nvHarr:"⤄",nvinfin:"⧞",nvlArr:"⤂",nvle:"≤⃒",nvlt:"<⃒",nvltrie:"⊴⃒",nvrArr:"⤃",nvrtrie:"⊵⃒",nvsim:"∼⃒",nwarhk:"⤣",nwarr:"↖",nwArr:"⇖",nwarrow:"↖",nwnear:"⤧",Oacute:"Ó",oacute:"ó",oast:"⊛",Ocirc:"Ô",ocirc:"ô",ocir:"⊚",Ocy:"О",ocy:"о",odash:"⊝",Odblac:"Ő",odblac:"ő",odiv:"⨸",odot:"⊙",odsold:"⦼",OElig:"Œ",oelig:"œ",ofcir:"⦿",Ofr:"𝔒",ofr:"𝔬",ogon:"˛",Ograve:"Ò",ograve:"ò",ogt:"⧁",ohbar:"⦵",ohm:"Ω",oint:"∮",olarr:"↺",olcir:"⦾",olcross:"⦻",oline:"‾",olt:"⧀",Omacr:"Ō",omacr:"ō",Omega:"Ω",omega:"ω",Omicron:"Ο",omicron:"ο",omid:"⦶",ominus:"⊖",Oopf:"𝕆",oopf:"𝕠",opar:"⦷",OpenCurlyDoubleQuote:"“",OpenCurlyQuote:"‘",operp:"⦹",oplus:"⊕",orarr:"↻",Or:"⩔",or:"∨",ord:"⩝",order:"ℴ",orderof:"ℴ",ordf:"ª",ordm:"º",origof:"⊶",oror:"⩖",orslope:"⩗",orv:"⩛",oS:"Ⓢ",Oscr:"𝒪",oscr:"ℴ",Oslash:"Ø",oslash:"ø",osol:"⊘",Otilde:"Õ",otilde:"õ",otimesas:"⨶",Otimes:"⨷",otimes:"⊗",Ouml:"Ö",ouml:"ö",ovbar:"⌽",OverBar:"‾",OverBrace:"⏞",OverBracket:"⎴",OverParenthesis:"⏜",para:"¶",parallel:"∥",par:"∥",parsim:"⫳",parsl:"⫽",part:"∂",PartialD:"∂",Pcy:"П",pcy:"п",percnt:"%",period:".",permil:"‰",perp:"⊥",pertenk:"‱",Pfr:"𝔓",pfr:"𝔭",Phi:"Φ",phi:"φ",phiv:"ϕ",phmmat:"ℳ",phone:"☎",Pi:"Π",pi:"π",pitchfork:"⋔",piv:"ϖ",planck:"ℏ",planckh:"ℎ",plankv:"ℏ",plusacir:"⨣",plusb:"⊞",pluscir:"⨢",plus:"+",plusdo:"∔",plusdu:"⨥",pluse:"⩲",PlusMinus:"±",plusmn:"±",plussim:"⨦",plustwo:"⨧",pm:"±",Poincareplane:"ℌ",pointint:"⨕",popf:"𝕡",Popf:"ℙ",pound:"£",prap:"⪷",Pr:"⪻",pr:"≺",prcue:"≼",precapprox:"⪷",prec:"≺",preccurlyeq:"≼",Precedes:"≺",PrecedesEqual:"⪯",PrecedesSlantEqual:"≼",PrecedesTilde:"≾",preceq:"⪯",precnapprox:"⪹",precneqq:"⪵",precnsim:"⋨",pre:"⪯",prE:"⪳",precsim:"≾",prime:"′",Prime:"″",primes:"ℙ",prnap:"⪹",prnE:"⪵",prnsim:"⋨",prod:"∏",Product:"∏",profalar:"⌮",profline:"⌒",profsurf:"⌓",prop:"∝",Proportional:"∝",Proportion:"∷",propto:"∝",prsim:"≾",prurel:"⊰",Pscr:"𝒫",pscr:"𝓅",Psi:"Ψ",psi:"ψ",puncsp:" ",Qfr:"𝔔",qfr:"𝔮",qint:"⨌",qopf:"𝕢",Qopf:"ℚ",qprime:"⁗",Qscr:"𝒬",qscr:"𝓆",quaternions:"ℍ",quatint:"⨖",quest:"?",questeq:"≟",quot:'"',QUOT:'"',rAarr:"⇛",race:"∽̱",Racute:"Ŕ",racute:"ŕ",radic:"√",raemptyv:"⦳",rang:"⟩",Rang:"⟫",rangd:"⦒",range:"⦥",rangle:"⟩",raquo:"»",rarrap:"⥵",rarrb:"⇥",rarrbfs:"⤠",rarrc:"⤳",rarr:"→",Rarr:"↠",rArr:"⇒",rarrfs:"⤞",rarrhk:"↪",rarrlp:"↬",rarrpl:"⥅",rarrsim:"⥴",Rarrtl:"⤖",rarrtl:"↣",rarrw:"↝",ratail:"⤚",rAtail:"⤜",ratio:"∶",rationals:"ℚ",rbarr:"⤍",rBarr:"⤏",RBarr:"⤐",rbbrk:"❳",rbrace:"}",rbrack:"]",rbrke:"⦌",rbrksld:"⦎",rbrkslu:"⦐",Rcaron:"Ř",rcaron:"ř",Rcedil:"Ŗ",rcedil:"ŗ",rceil:"⌉",rcub:"}",Rcy:"Р",rcy:"р",rdca:"⤷",rdldhar:"⥩",rdquo:"”",rdquor:"”",rdsh:"↳",real:"ℜ",realine:"ℛ",realpart:"ℜ",reals:"ℝ",Re:"ℜ",rect:"▭",reg:"®",REG:"®",ReverseElement:"∋",ReverseEquilibrium:"⇋",ReverseUpEquilibrium:"⥯",rfisht:"⥽",rfloor:"⌋",rfr:"𝔯",Rfr:"ℜ",rHar:"⥤",rhard:"⇁",rharu:"⇀",rharul:"⥬",Rho:"Ρ",rho:"ρ",rhov:"ϱ",RightAngleBracket:"⟩",RightArrowBar:"⇥",rightarrow:"→",RightArrow:"→",Rightarrow:"⇒",RightArrowLeftArrow:"⇄",rightarrowtail:"↣",RightCeiling:"⌉",RightDoubleBracket:"⟧",RightDownTeeVector:"⥝",RightDownVectorBar:"⥕",RightDownVector:"⇂",RightFloor:"⌋",rightharpoondown:"⇁",rightharpoonup:"⇀",rightleftarrows:"⇄",rightleftharpoons:"⇌",rightrightarrows:"⇉",rightsquigarrow:"↝",RightTeeArrow:"↦",RightTee:"⊢",RightTeeVector:"⥛",rightthreetimes:"⋌",RightTriangleBar:"⧐",RightTriangle:"⊳",RightTriangleEqual:"⊵",RightUpDownVector:"⥏",RightUpTeeVector:"⥜",RightUpVectorBar:"⥔",RightUpVector:"↾",RightVectorBar:"⥓",RightVector:"⇀",ring:"˚",risingdotseq:"≓",rlarr:"⇄",rlhar:"⇌",rlm:"",rmoustache:"⎱",rmoust:"⎱",rnmid:"⫮",roang:"⟭",roarr:"⇾",robrk:"⟧",ropar:"⦆",ropf:"𝕣",Ropf:"ℝ",roplus:"⨮",rotimes:"⨵",RoundImplies:"⥰",rpar:")",rpargt:"⦔",rppolint:"⨒",rrarr:"⇉",Rrightarrow:"⇛",rsaquo:"›",rscr:"𝓇",Rscr:"ℛ",rsh:"↱",Rsh:"↱",rsqb:"]",rsquo:"’",rsquor:"’",rthree:"⋌",rtimes:"⋊",rtri:"▹",rtrie:"⊵",rtrif:"▸",rtriltri:"⧎",RuleDelayed:"⧴",ruluhar:"⥨",rx:"℞",Sacute:"Ś",sacute:"ś",sbquo:"‚",scap:"⪸",Scaron:"Š",scaron:"š",Sc:"⪼",sc:"≻",sccue:"≽",sce:"⪰",scE:"⪴",Scedil:"Ş",scedil:"ş",Scirc:"Ŝ",scirc:"ŝ",scnap:"⪺",scnE:"⪶",scnsim:"⋩",scpolint:"⨓",scsim:"≿",Scy:"С",scy:"с",sdotb:"⊡",sdot:"⋅",sdote:"⩦",searhk:"⤥",searr:"↘",seArr:"⇘",searrow:"↘",sect:"§",semi:";", +seswar:"⤩",setminus:"∖",setmn:"∖",sext:"✶",Sfr:"𝔖",sfr:"𝔰",sfrown:"⌢",sharp:"♯",SHCHcy:"Щ",shchcy:"щ",SHcy:"Ш",shcy:"ш",ShortDownArrow:"↓",ShortLeftArrow:"←",shortmid:"∣",shortparallel:"∥",ShortRightArrow:"→",ShortUpArrow:"↑",shy:"",Sigma:"Σ",sigma:"σ",sigmaf:"ς",sigmav:"ς",sim:"∼",simdot:"⩪",sime:"≃",simeq:"≃",simg:"⪞",simgE:"⪠",siml:"⪝",simlE:"⪟",simne:"≆",simplus:"⨤",simrarr:"⥲",slarr:"←",SmallCircle:"∘",smallsetminus:"∖",smashp:"⨳",smeparsl:"⧤",smid:"∣",smile:"⌣",smt:"⪪",smte:"⪬",smtes:"⪬︀",SOFTcy:"Ь",softcy:"ь",solbar:"⌿",solb:"⧄",sol:"/",Sopf:"𝕊",sopf:"𝕤",spades:"♠",spadesuit:"♠",spar:"∥",sqcap:"⊓",sqcaps:"⊓︀",sqcup:"⊔",sqcups:"⊔︀",Sqrt:"√",sqsub:"⊏",sqsube:"⊑",sqsubset:"⊏",sqsubseteq:"⊑",sqsup:"⊐",sqsupe:"⊒",sqsupset:"⊐",sqsupseteq:"⊒",square:"□",Square:"□",SquareIntersection:"⊓",SquareSubset:"⊏",SquareSubsetEqual:"⊑",SquareSuperset:"⊐",SquareSupersetEqual:"⊒",SquareUnion:"⊔",squarf:"▪",squ:"□",squf:"▪",srarr:"→",Sscr:"𝒮",sscr:"𝓈",ssetmn:"∖",ssmile:"⌣",sstarf:"⋆",Star:"⋆",star:"☆",starf:"★",straightepsilon:"ϵ",straightphi:"ϕ",strns:"¯",sub:"⊂",Sub:"⋐",subdot:"⪽",subE:"⫅",sube:"⊆",subedot:"⫃",submult:"⫁",subnE:"⫋",subne:"⊊",subplus:"⪿",subrarr:"⥹",subset:"⊂",Subset:"⋐",subseteq:"⊆",subseteqq:"⫅",SubsetEqual:"⊆",subsetneq:"⊊",subsetneqq:"⫋",subsim:"⫇",subsub:"⫕",subsup:"⫓",succapprox:"⪸",succ:"≻",succcurlyeq:"≽",Succeeds:"≻",SucceedsEqual:"⪰",SucceedsSlantEqual:"≽",SucceedsTilde:"≿",succeq:"⪰",succnapprox:"⪺",succneqq:"⪶",succnsim:"⋩",succsim:"≿",SuchThat:"∋",sum:"∑",Sum:"∑",sung:"♪",sup1:"¹",sup2:"²",sup3:"³",sup:"⊃",Sup:"⋑",supdot:"⪾",supdsub:"⫘",supE:"⫆",supe:"⊇",supedot:"⫄",Superset:"⊃",SupersetEqual:"⊇",suphsol:"⟉",suphsub:"⫗",suplarr:"⥻",supmult:"⫂",supnE:"⫌",supne:"⊋",supplus:"⫀",supset:"⊃",Supset:"⋑",supseteq:"⊇",supseteqq:"⫆",supsetneq:"⊋",supsetneqq:"⫌",supsim:"⫈",supsub:"⫔",supsup:"⫖",swarhk:"⤦",swarr:"↙",swArr:"⇙",swarrow:"↙",swnwar:"⤪",szlig:"ß",Tab:"\t",target:"⌖",Tau:"Τ",tau:"τ",tbrk:"⎴",Tcaron:"Ť",tcaron:"ť",Tcedil:"Ţ",tcedil:"ţ",Tcy:"Т",tcy:"т",tdot:"⃛",telrec:"⌕",Tfr:"𝔗",tfr:"𝔱",there4:"∴",therefore:"∴",Therefore:"∴",Theta:"Θ",theta:"θ",thetasym:"ϑ",thetav:"ϑ",thickapprox:"≈",thicksim:"∼",ThickSpace:" ",ThinSpace:" ",thinsp:" ",thkap:"≈",thksim:"∼",THORN:"Þ",thorn:"þ",tilde:"˜",Tilde:"∼",TildeEqual:"≃",TildeFullEqual:"≅",TildeTilde:"≈",timesbar:"⨱",timesb:"⊠",times:"×",timesd:"⨰",tint:"∭",toea:"⤨",topbot:"⌶",topcir:"⫱",top:"⊤",Topf:"𝕋",topf:"𝕥",topfork:"⫚",tosa:"⤩",tprime:"‴",trade:"™",TRADE:"™",triangle:"▵",triangledown:"▿",triangleleft:"◃",trianglelefteq:"⊴",triangleq:"≜",triangleright:"▹",trianglerighteq:"⊵",tridot:"◬",trie:"≜",triminus:"⨺",TripleDot:"⃛",triplus:"⨹",trisb:"⧍",tritime:"⨻",trpezium:"⏢",Tscr:"𝒯",tscr:"𝓉",TScy:"Ц",tscy:"ц",TSHcy:"Ћ",tshcy:"ћ",Tstrok:"Ŧ",tstrok:"ŧ",twixt:"≬",twoheadleftarrow:"↞",twoheadrightarrow:"↠",Uacute:"Ú",uacute:"ú",uarr:"↑",Uarr:"↟",uArr:"⇑",Uarrocir:"⥉",Ubrcy:"Ў",ubrcy:"ў",Ubreve:"Ŭ",ubreve:"ŭ",Ucirc:"Û",ucirc:"û",Ucy:"У",ucy:"у",udarr:"⇅",Udblac:"Ű",udblac:"ű",udhar:"⥮",ufisht:"⥾",Ufr:"𝔘",ufr:"𝔲",Ugrave:"Ù",ugrave:"ù",uHar:"⥣",uharl:"↿",uharr:"↾",uhblk:"▀",ulcorn:"⌜",ulcorner:"⌜",ulcrop:"⌏",ultri:"◸",Umacr:"Ū",umacr:"ū",uml:"¨",UnderBar:"_",UnderBrace:"⏟",UnderBracket:"⎵",UnderParenthesis:"⏝",Union:"⋃",UnionPlus:"⊎",Uogon:"Ų",uogon:"ų",Uopf:"𝕌",uopf:"𝕦",UpArrowBar:"⤒",uparrow:"↑",UpArrow:"↑",Uparrow:"⇑",UpArrowDownArrow:"⇅",updownarrow:"↕",UpDownArrow:"↕",Updownarrow:"⇕",UpEquilibrium:"⥮",upharpoonleft:"↿",upharpoonright:"↾",uplus:"⊎",UpperLeftArrow:"↖",UpperRightArrow:"↗",upsi:"υ",Upsi:"ϒ",upsih:"ϒ",Upsilon:"Υ",upsilon:"υ",UpTeeArrow:"↥",UpTee:"⊥",upuparrows:"⇈",urcorn:"⌝",urcorner:"⌝",urcrop:"⌎",Uring:"Ů",uring:"ů",urtri:"◹",Uscr:"𝒰",uscr:"𝓊",utdot:"⋰",Utilde:"Ũ",utilde:"ũ",utri:"▵",utrif:"▴",uuarr:"⇈",Uuml:"Ü",uuml:"ü",uwangle:"⦧",vangrt:"⦜",varepsilon:"ϵ",varkappa:"ϰ",varnothing:"∅",varphi:"ϕ",varpi:"ϖ",varpropto:"∝",varr:"↕",vArr:"⇕",varrho:"ϱ",varsigma:"ς",varsubsetneq:"⊊︀",varsubsetneqq:"⫋︀",varsupsetneq:"⊋︀",varsupsetneqq:"⫌︀",vartheta:"ϑ",vartriangleleft:"⊲",vartriangleright:"⊳",vBar:"⫨",Vbar:"⫫",vBarv:"⫩",Vcy:"В",vcy:"в",vdash:"⊢",vDash:"⊨",Vdash:"⊩",VDash:"⊫",Vdashl:"⫦",veebar:"⊻",vee:"∨",Vee:"⋁",veeeq:"≚",vellip:"⋮",verbar:"|",Verbar:"‖",vert:"|",Vert:"‖",VerticalBar:"∣",VerticalLine:"|",VerticalSeparator:"❘",VerticalTilde:"≀",VeryThinSpace:" ",Vfr:"𝔙",vfr:"𝔳",vltri:"⊲",vnsub:"⊂⃒",vnsup:"⊃⃒",Vopf:"𝕍",vopf:"𝕧",vprop:"∝",vrtri:"⊳",Vscr:"𝒱",vscr:"𝓋",vsubnE:"⫋︀",vsubne:"⊊︀",vsupnE:"⫌︀",vsupne:"⊋︀",Vvdash:"⊪",vzigzag:"⦚",Wcirc:"Ŵ",wcirc:"ŵ",wedbar:"⩟",wedge:"∧",Wedge:"⋀",wedgeq:"≙",weierp:"℘",Wfr:"𝔚",wfr:"𝔴",Wopf:"𝕎",wopf:"𝕨",wp:"℘",wr:"≀",wreath:"≀",Wscr:"𝒲",wscr:"𝓌",xcap:"⋂",xcirc:"◯",xcup:"⋃",xdtri:"▽",Xfr:"𝔛",xfr:"𝔵",xharr:"⟷",xhArr:"⟺",Xi:"Ξ",xi:"ξ",xlarr:"⟵",xlArr:"⟸",xmap:"⟼",xnis:"⋻",xodot:"⨀",Xopf:"𝕏",xopf:"𝕩",xoplus:"⨁",xotime:"⨂",xrarr:"⟶",xrArr:"⟹",Xscr:"𝒳",xscr:"𝓍",xsqcup:"⨆",xuplus:"⨄",xutri:"△",xvee:"⋁",xwedge:"⋀",Yacute:"Ý",yacute:"ý",YAcy:"Я",yacy:"я",Ycirc:"Ŷ",ycirc:"ŷ",Ycy:"Ы",ycy:"ы",yen:"¥",Yfr:"𝔜",yfr:"𝔶",YIcy:"Ї",yicy:"ї",Yopf:"𝕐",yopf:"𝕪",Yscr:"𝒴",yscr:"𝓎",YUcy:"Ю",yucy:"ю",yuml:"ÿ",Yuml:"Ÿ",Zacute:"Ź",zacute:"ź",Zcaron:"Ž",zcaron:"ž",Zcy:"З",zcy:"з",Zdot:"Ż",zdot:"ż",zeetrf:"ℨ",ZeroWidthSpace:"",Zeta:"Ζ",zeta:"ζ",zfr:"𝔷",Zfr:"ℨ",ZHcy:"Ж",zhcy:"ж",zigrarr:"⇝",zopf:"𝕫",Zopf:"ℤ",Zscr:"𝒵",zscr:"𝓏",zwj:"",zwnj:""}},function(t,e){t.exports={Aacute:"Á",aacute:"á",Acirc:"Â",acirc:"â",acute:"´",AElig:"Æ",aelig:"æ",Agrave:"À",agrave:"à",amp:"&",AMP:"&",Aring:"Å",aring:"å",Atilde:"Ã",atilde:"ã",Auml:"Ä",auml:"ä",brvbar:"¦",Ccedil:"Ç",ccedil:"ç",cedil:"¸",cent:"¢",copy:"©",COPY:"©",curren:"¤",deg:"°",divide:"÷",Eacute:"É",eacute:"é",Ecirc:"Ê",ecirc:"ê",Egrave:"È",egrave:"è",ETH:"Ð",eth:"ð",Euml:"Ë",euml:"ë",frac12:"½",frac14:"¼",frac34:"¾",gt:">",GT:">",Iacute:"Í",iacute:"í",Icirc:"Î",icirc:"î",iexcl:"¡",Igrave:"Ì",igrave:"ì",iquest:"¿",Iuml:"Ï",iuml:"ï",laquo:"«",lt:"<",LT:"<",macr:"¯",micro:"µ",middot:"·",nbsp:" ",not:"¬",Ntilde:"Ñ",ntilde:"ñ",Oacute:"Ó",oacute:"ó",Ocirc:"Ô",ocirc:"ô",Ograve:"Ò",ograve:"ò",ordf:"ª",ordm:"º",Oslash:"Ø",oslash:"ø",Otilde:"Õ",otilde:"õ",Ouml:"Ö",ouml:"ö",para:"¶",plusmn:"±",pound:"£",quot:'"',QUOT:'"',raquo:"»",reg:"®",REG:"®",sect:"§",shy:"",sup1:"¹",sup2:"²",sup3:"³",szlig:"ß",THORN:"Þ",thorn:"þ",times:"×",Uacute:"Ú",uacute:"ú",Ucirc:"Û",ucirc:"û",Ugrave:"Ù",ugrave:"ù",uml:"¨",Uuml:"Ü",uuml:"ü",Yacute:"Ý",yacute:"ý",yen:"¥",yuml:"ÿ"}},function(t,e){t.exports={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'}},function(t,e,r){function n(t,e,r){"object"==typeof t?(r=e,e=t,t=null):"function"==typeof e&&(r=e,e=u),this._callback=t,this._options=e||u,this._elementCB=r,this.dom=[],this._done=!1,this._tagStack=[],this._parser=this._parser||null}var i=r(45),o=/\s+/g,s=r(46),a=r(47),u={normalizeWhitespace:!1,withStartIndices:!1};n.prototype.onparserinit=function(t){this._parser=t},n.prototype.onreset=function(){n.call(this,this._callback,this._options,this._elementCB)},n.prototype.onend=function(){this._done||(this._done=!0,this._parser=null,this._handleCallback(null))},n.prototype._handleCallback=n.prototype.onerror=function(t){if("function"==typeof this._callback)this._callback(t,this.dom);else if(t)throw t},n.prototype.onclosetag=function(){var t=this._tagStack.pop();this._elementCB&&this._elementCB(t)},n.prototype._addDomElement=function(t){var e=this._tagStack[this._tagStack.length-1],r=e?e.children:this.dom,n=r[r.length-1];t.next=null,this._options.withStartIndices&&(t.startIndex=this._parser.startIndex),this._options.withDomLvl1&&(t.__proto__="tag"===t.type?a:s),n?(t.prev=n,n.next=t):t.prev=null,r.push(t),t.parent=e||null},n.prototype.onopentag=function(t,e){var r={type:"script"===t?i.Script:"style"===t?i.Style:i.Tag,name:t,attribs:e,children:[]};this._addDomElement(r),this._tagStack.push(r)},n.prototype.ontext=function(t){var e,r=this._options.normalizeWhitespace||this._options.ignoreWhitespace;!this._tagStack.length&&this.dom.length&&(e=this.dom[this.dom.length-1]).type===i.Text?r?e.data=(e.data+t).replace(o," "):e.data+=t:this._tagStack.length&&(e=this._tagStack[this._tagStack.length-1])&&(e=e.children[e.children.length-1])&&e.type===i.Text?r?e.data=(e.data+t).replace(o," "):e.data+=t:(r&&(t=t.replace(o," ")),this._addDomElement({data:t,type:i.Text}))},n.prototype.oncomment=function(t){var e=this._tagStack[this._tagStack.length-1];if(e&&e.type===i.Comment)return void(e.data+=t);var r={data:t,type:i.Comment};this._addDomElement(r),this._tagStack.push(r)},n.prototype.oncdatastart=function(){var t={children:[{data:"",type:i.Text}],type:i.CDATA};this._addDomElement(t),this._tagStack.push(t)},n.prototype.oncommentend=n.prototype.oncdataend=function(){this._tagStack.pop()},n.prototype.onprocessinginstruction=function(t,e){this._addDomElement({name:t,data:e,type:i.Directive})},t.exports=n},function(t,e){t.exports={Text:"text",Directive:"directive",Comment:"comment",Script:"script",Style:"style",Tag:"tag",CDATA:"cdata",Doctype:"doctype",isTag:function(t){return"tag"===t.type||"script"===t.type||"style"===t.type}}},function(t,e){var r=t.exports={get firstChild(){var t=this.children;return t&&t[0]||null},get lastChild(){var t=this.children;return t&&t[t.length-1]||null},get nodeType(){return i[this.type]||i.element}},n={tagName:"name",childNodes:"children",parentNode:"parent",previousSibling:"prev",nextSibling:"next",nodeValue:"data"},i={element:1,text:3,cdata:4,comment:8};Object.keys(n).forEach(function(t){var e=n[t];Object.defineProperty(r,t,{get:function(){return this[e]||null},set:function(t){return this[e]=t,t}})})},function(t,e,r){var n=r(46),i=t.exports=Object.create(n),o={tagName:"name"};Object.keys(o).forEach(function(t){var e=o[t];Object.defineProperty(i,t,{get:function(){return this[e]||null},set:function(t){return this[e]=t,t}})})},function(t,e,r){function n(t,e){this.init(t,e)}function i(t,e){return p.getElementsByTagName(t,e,!0)}function o(t,e){return p.getElementsByTagName(t,e,!0,1)[0]}function s(t,e,r){return p.getText(p.getElementsByTagName(t,e,r,1)).trim()}function a(t,e,r,n,i){var o=s(r,n,i);o&&(t[e]=o)}var u=r(36),c=u.DomHandler,p=u.DomUtils;r(2).inherits(n,c),n.prototype.init=c;var h=function(t){return"rss"===t||"feed"===t||"rdf:RDF"===t};n.prototype.onend=function(){var t,e,r={},n=o(h,this.dom);n&&("feed"===n.name?(e=n.children,r.type="atom",a(r,"id","id",e),a(r,"title","title",e),(t=o("link",e))&&(t=t.attribs)&&(t=t.href)&&(r.link=t),a(r,"description","subtitle",e),(t=s("updated",e))&&(r.updated=new Date(t)),a(r,"author","email",e,!0),r.items=i("entry",e).map(function(t){var e,r={};return t=t.children,a(r,"id","id",t),a(r,"title","title",t),(e=o("link",t))&&(e=e.attribs)&&(e=e.href)&&(r.link=e),(e=s("summary",t)||s("content",t))&&(r.description=e),(e=s("updated",t))&&(r.pubDate=new Date(e)),r})):(e=o("channel",n.children).children,r.type=n.name.substr(0,3),r.id="",a(r,"title","title",e),a(r,"link","link",e),a(r,"description","description",e),(t=s("lastBuildDate",e))&&(r.updated=new Date(t)),a(r,"author","managingEditor",e,!0),r.items=i("item",n.children).map(function(t){var e,r={};return t=t.children,a(r,"id","guid",t),a(r,"title","title",t),a(r,"link","link",t),a(r,"description","description",t),(e=s("pubDate",t))&&(r.pubDate=new Date(e)),r}))),this.dom=r,c.prototype._handleCallback.call(this,n?null:Error("couldn't find root of feed"))},t.exports=n},function(t,e,r){function n(t){o.call(this,new i(this),t)}function i(t){this.scope=t}t.exports=n;var o=r(50);r(2).inherits(n,o),n.prototype.readable=!0;var s=r(36).EVENTS;Object.keys(s).forEach(function(t){if(0===s[t])i.prototype["on"+t]=function(){this.scope.emit(t)};else if(1===s[t])i.prototype["on"+t]=function(e){this.scope.emit(t,e)};else{if(2!==s[t])throw Error("wrong number of arguments!");i.prototype["on"+t]=function(e,r){this.scope.emit(t,e,r)}}})},function(t,e,r){function n(t,e){var r=this._parser=new i(t,e);o.call(this,{decodeStrings:!1}),this.once("finish",function(){r.end()})}t.exports=n;var i=r(37),o=r(51).Writable||r(70).Writable;r(2).inherits(n,o),o.prototype._write=function(t,e,r){this._parser.write(t),r()}},function(t,e,r){function n(){i.call(this)}t.exports=n;var i=r(1).EventEmitter,o=r(5);o(n,i),n.Readable=r(52),n.Writable=r(66),n.Duplex=r(67),n.Transform=r(68),n.PassThrough=r(69),n.Stream=n,n.prototype.pipe=function(t,e){function r(e){t.writable&&!1===t.write(e)&&c.pause&&c.pause()}function n(){c.readable&&c.resume&&c.resume()}function o(){p||(p=!0,t.end())}function s(){p||(p=!0,"function"==typeof t.destroy&&t.destroy())}function a(t){if(u(),0===i.listenerCount(this,"error"))throw t}function u(){c.removeListener("data",r),t.removeListener("drain",n),c.removeListener("end",o),c.removeListener("close",s),c.removeListener("error",a),t.removeListener("error",a),c.removeListener("end",u),c.removeListener("close",u),t.removeListener("close",u)}var c=this;c.on("data",r),t.on("drain",n),t._isStdio||e&&e.end===!1||(c.on("end",o),c.on("close",s));var p=!1;return c.on("error",a),t.on("error",a),c.on("end",u),c.on("close",u),t.on("close",u),t.emit("pipe",c),t}},function(t,e,r){(function(n){e=t.exports=r(53),e.Stream=r(51),e.Readable=e,e.Writable=r(62),e.Duplex=r(61),e.Transform=r(64),e.PassThrough=r(65),n.browser||"disable"!==n.env.READABLE_STREAM||(t.exports=r(51))}).call(e,r(3))},function(t,e,r){(function(e){function n(t,e){var n=r(61);t=t||{};var i=t.highWaterMark,o=t.objectMode?16:16384;this.highWaterMark=i||0===i?i:o,this.highWaterMark=~~this.highWaterMark,this.buffer=[],this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.objectMode=!!t.objectMode,e instanceof n&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.defaultEncoding=t.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(O||(O=r(63).StringDecoder),this.decoder=new O(t.encoding),this.encoding=t.encoding)}function i(t){r(61);return this instanceof i?(this._readableState=new n(t,this),this.readable=!0,void x.call(this)):new i(t)}function o(t,e,r,n,i){var o=c(e,r);if(o)t.emit("error",o);else if(N.isNullOrUndefined(r))e.reading=!1,e.ended||p(t,e);else if(e.objectMode||r&&r.length>0)if(e.ended&&!i){var a=new Error("stream.push() after EOF");t.emit("error",a)}else if(e.endEmitted&&i){var a=new Error("stream.unshift() after end event");t.emit("error",a)}else!e.decoder||i||n||(r=e.decoder.write(r)),i||(e.reading=!1),e.flowing&&0===e.length&&!e.sync?(t.emit("data",r),t.read(0)):(e.length+=e.objectMode?1:r.length,i?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&h(t)),f(t,e);else i||(e.reading=!1);return s(e)}function s(t){return!t.ended&&(t.needReadable||t.length<t.highWaterMark||0===t.length)}function a(t){if(t>=C)t=C;else{t--;for(var e=1;e<32;e<<=1)t|=t>>e;t++}return t}function u(t,e){return 0===e.length&&e.ended?0:e.objectMode?0===t?0:1:isNaN(t)||N.isNull(t)?e.flowing&&e.buffer.length?e.buffer[0].length:e.length:t<=0?0:(t>e.highWaterMark&&(e.highWaterMark=a(t)),t>e.length?e.ended?e.length:(e.needReadable=!0,0):t)}function c(t,e){var r=null;return N.isBuffer(e)||N.isString(e)||N.isNullOrUndefined(e)||t.objectMode||(r=new TypeError("Invalid non-string/buffer chunk")),r}function p(t,e){if(e.decoder&&!e.ended){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,h(t)}function h(t){var r=t._readableState;r.needReadable=!1,r.emittedReadable||(A("emitReadable",r.flowing),r.emittedReadable=!0,r.sync?e.nextTick(function(){l(t)}):l(t))}function l(t){A("emit readable"),t.emit("readable"),y(t)}function f(t,r){r.readingMore||(r.readingMore=!0,e.nextTick(function(){d(t,r)}))}function d(t,e){for(var r=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length<e.highWaterMark&&(A("maybeReadMore read 0"),t.read(0),r!==e.length);)r=e.length;e.readingMore=!1}function g(t){return function(){var e=t._readableState;A("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&E.listenerCount(t,"data")&&(e.flowing=!0,y(t))}}function m(t,r){r.resumeScheduled||(r.resumeScheduled=!0,e.nextTick(function(){_(t,r)}))}function _(t,e){e.resumeScheduled=!1,t.emit("resume"),y(t),e.flowing&&!e.reading&&t.read(0)}function y(t){var e=t._readableState;if(A("flow",e.flowing),e.flowing)do var r=t.read();while(null!==r&&e.flowing)}function b(t,e){var r,n=e.buffer,i=e.length,o=!!e.decoder,s=!!e.objectMode;if(0===n.length)return null;if(0===i)r=null;else if(s)r=n.shift();else if(!t||t>=i)r=o?n.join(""):T.concat(n,i),n.length=0;else if(t<n[0].length){var a=n[0];r=a.slice(0,t),n[0]=a.slice(t)}else if(t===n[0].length)r=n.shift();else{r=o?"":new T(t);for(var u=0,c=0,p=n.length;c<p&&u<t;c++){var a=n[0],h=Math.min(t-u,a.length);o?r+=a.slice(0,h):a.copy(r,u,0,h),h<a.length?n[0]=a.slice(h):n.shift(),u+=h}}return r}function v(t){var r=t._readableState;if(r.length>0)throw new Error("endReadable called on non-empty stream");r.endEmitted||(r.ended=!0,e.nextTick(function(){r.endEmitted||0!==r.length||(r.endEmitted=!0,t.readable=!1,t.emit("end"))}))}function w(t,e){for(var r=0,n=t.length;r<n;r++)e(t[r],r)}function S(t,e){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}t.exports=i;var k=r(54),T=r(55).Buffer;i.ReadableState=n;var E=r(1).EventEmitter;E.listenerCount||(E.listenerCount=function(t,e){return t.listeners(e).length});var x=r(51),N=r(59);N.inherits=r(5);var O,A=r(60);A=A&&A.debuglog?A.debuglog("stream"):function(){},N.inherits(i,x),i.prototype.push=function(t,e){var r=this._readableState;return N.isString(t)&&!r.objectMode&&(e=e||r.defaultEncoding,e!==r.encoding&&(t=new T(t,e),e="")),o(this,r,t,e,!1)},i.prototype.unshift=function(t){var e=this._readableState;return o(this,e,t,"",!0)},i.prototype.setEncoding=function(t){return O||(O=r(63).StringDecoder),this._readableState.decoder=new O(t),this._readableState.encoding=t,this};var C=8388608;i.prototype.read=function(t){A("read",t);var e=this._readableState,r=t;if((!N.isNumber(t)||t>0)&&(e.emittedReadable=!1),0===t&&e.needReadable&&(e.length>=e.highWaterMark||e.ended))return A("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?v(this):h(this),null;if(t=u(t,e),0===t&&e.ended)return 0===e.length&&v(this),null;var n=e.needReadable;A("need readable",n),(0===e.length||e.length-t<e.highWaterMark)&&(n=!0,A("length less than watermark",n)),(e.ended||e.reading)&&(n=!1,A("reading or ended",n)),n&&(A("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1),n&&!e.reading&&(t=u(r,e));var i;return i=t>0?b(t,e):null,N.isNull(i)&&(e.needReadable=!0,t=0),e.length-=t,0!==e.length||e.ended||(e.needReadable=!0),r!==t&&e.ended&&0===e.length&&v(this),N.isNull(i)||this.emit("data",i),i},i.prototype._read=function(t){this.emit("error",new Error("not implemented"))},i.prototype.pipe=function(t,r){function n(t){A("onunpipe"),t===h&&o()}function i(){A("onend"),t.end()}function o(){A("cleanup"),t.removeListener("close",u),t.removeListener("finish",c),t.removeListener("drain",m),t.removeListener("error",a),t.removeListener("unpipe",n),h.removeListener("end",i),h.removeListener("end",o),h.removeListener("data",s),!l.awaitDrain||t._writableState&&!t._writableState.needDrain||m()}function s(e){A("ondata");var r=t.write(e);!1===r&&(A("false write response, pause",h._readableState.awaitDrain),h._readableState.awaitDrain++,h.pause())}function a(e){A("onerror",e),p(),t.removeListener("error",a),0===E.listenerCount(t,"error")&&t.emit("error",e)}function u(){t.removeListener("finish",c),p()}function c(){A("onfinish"),t.removeListener("close",u),p()}function p(){A("unpipe"),h.unpipe(t)}var h=this,l=this._readableState;switch(l.pipesCount){case 0:l.pipes=t;break;case 1:l.pipes=[l.pipes,t];break;default:l.pipes.push(t)}l.pipesCount+=1,A("pipe count=%d opts=%j",l.pipesCount,r);var f=(!r||r.end!==!1)&&t!==e.stdout&&t!==e.stderr,d=f?i:o;l.endEmitted?e.nextTick(d):h.once("end",d),t.on("unpipe",n);var m=g(h);return t.on("drain",m),h.on("data",s),t._events&&t._events.error?k(t._events.error)?t._events.error.unshift(a):t._events.error=[a,t._events.error]:t.on("error",a),t.once("close",u),t.once("finish",c),t.emit("pipe",h),l.flowing||(A("pipe resume"),h.resume()),t},i.prototype.unpipe=function(t){var e=this._readableState;if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this),this);if(!t){var r=e.pipes,n=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var i=0;i<n;i++)r[i].emit("unpipe",this);return this}var i=S(e.pipes,t);return i===-1?this:(e.pipes.splice(i,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this),this)},i.prototype.on=function(t,r){var n=x.prototype.on.call(this,t,r);if("data"===t&&!1!==this._readableState.flowing&&this.resume(),"readable"===t&&this.readable){var i=this._readableState;if(!i.readableListening)if(i.readableListening=!0,i.emittedReadable=!1,i.needReadable=!0,i.reading)i.length&&h(this,i);else{var o=this;e.nextTick(function(){A("readable nexttick read 0"),o.read(0)})}}return n},i.prototype.addListener=i.prototype.on,i.prototype.resume=function(){var t=this._readableState;return t.flowing||(A("resume"),t.flowing=!0,t.reading||(A("resume read 0"),this.read(0)),m(this,t)),this},i.prototype.pause=function(){return A("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(A("pause"),this._readableState.flowing=!1,this.emit("pause")),this},i.prototype.wrap=function(t){var e=this._readableState,r=!1,n=this;t.on("end",function(){if(A("wrapped end"),e.decoder&&!e.ended){var t=e.decoder.end();t&&t.length&&n.push(t)}n.push(null)}),t.on("data",function(i){if(A("wrapped data"),e.decoder&&(i=e.decoder.write(i)),i&&(e.objectMode||i.length)){var o=n.push(i);o||(r=!0,t.pause())}});for(var i in t)N.isFunction(t[i])&&N.isUndefined(this[i])&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));var o=["error","close","destroy","pause","resume"];return w(o,function(e){t.on(e,n.emit.bind(n,e))}),n._read=function(e){A("wrapped _read",e),r&&(r=!1,t.resume())},n},i._fromList=b}).call(e,r(3))},function(t,e){t.exports=Array.isArray||function(t){return"[object Array]"==Object.prototype.toString.call(t)}},function(t,e,r){(function(t,n){/*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org> * @license MIT */ -"use strict";function i(){function t(){}try{var e=new Uint8Array(1);return e.foo=function(){return 42},e.constructor=t,42===e.foo()&&e.constructor===t&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(r){return!1}}function o(){return t.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function t(e){return this instanceof t?(t.TYPED_ARRAY_SUPPORT||(this.length=0,this.parent=void 0),"number"==typeof e?s(this,e):"string"==typeof e?a(this,e,arguments.length>1?arguments[1]:"utf8"):c(this,e)):arguments.length>1?new t(e,arguments[1]):new t(e)}function s(e,r){if(e=g(e,0>r?0:0|_(r)),!t.TYPED_ARRAY_SUPPORT)for(var n=0;r>n;n++)e[n]=0;return e}function a(t,e,r){"string"==typeof r&&""!==r||(r="utf8");var n=0|b(e,r);return t=g(t,n),t.write(e,r),t}function c(e,r){if(t.isBuffer(r))return u(e,r);if(J(r))return h(e,r);if(null==r)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(r.buffer instanceof ArrayBuffer)return l(e,r);if(r instanceof ArrayBuffer)return p(e,r)}return r.length?f(e,r):d(e,r)}function u(t,e){var r=0|_(e.length);return t=g(t,r),e.copy(t,0,0,r),t}function h(t,e){var r=0|_(e.length);t=g(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function l(t,e){var r=0|_(e.length);t=g(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function p(e,r){return t.TYPED_ARRAY_SUPPORT?(r.byteLength,e=t._augment(new Uint8Array(r))):e=l(e,new Uint8Array(r)),e}function f(t,e){var r=0|_(e.length);t=g(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function d(t,e){var r,n=0;"Buffer"===e.type&&J(e.data)&&(r=e.data,n=0|_(r.length)),t=g(t,n);for(var i=0;n>i;i+=1)t[i]=255&r[i];return t}function g(e,r){t.TYPED_ARRAY_SUPPORT?(e=t._augment(new Uint8Array(r)),e.__proto__=t.prototype):(e.length=r,e._isBuffer=!0);var n=0!==r&&r<=t.poolSize>>>1;return n&&(e.parent=Q),e}function _(t){if(t>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function m(e,r){if(!(this instanceof m))return new m(e,r);var n=new t(e,r);return delete n.parent,n}function b(t,e){"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"binary":case"raw":case"raws":return r;case"utf8":case"utf-8":return Y(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return H(t).length;default:if(n)return Y(t).length;e=(""+e).toLowerCase(),n=!0}}function y(t,e,r){var n=!1;if(e=0|e,r=void 0===r||r===1/0?this.length:0|r,t||(t="utf8"),0>e&&(e=0),r>this.length&&(r=this.length),e>=r)return"";for(;;)switch(t){case"hex":return R(this,e,r);case"utf8":case"utf-8":return A(this,e,r);case"ascii":return I(this,e,r);case"binary":return D(this,e,r);case"base64":return T(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function v(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var o=e.length;if(o%2!==0)throw new Error("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;n>s;s++){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))throw new Error("Invalid hex string");t[r+s]=a}return s}function w(t,e,r,n){return W(Y(e,t.length-r),t,r,n)}function S(t,e,r,n){return W(V(e),t,r,n)}function E(t,e,r,n){return S(t,e,r,n)}function k(t,e,r,n){return W(H(e),t,r,n)}function x(t,e,r,n){return W(z(e,t.length-r),t,r,n)}function T(t,e,r){return 0===e&&r===t.length?X.fromByteArray(t):X.fromByteArray(t.slice(e,r))}function A(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;r>i;){var o=t[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(r>=i+a){var c,u,h,l;switch(a){case 1:128>o&&(s=o);break;case 2:c=t[i+1],128===(192&c)&&(l=(31&o)<<6|63&c,l>127&&(s=l));break;case 3:c=t[i+1],u=t[i+2],128===(192&c)&&128===(192&u)&&(l=(15&o)<<12|(63&c)<<6|63&u,l>2047&&(55296>l||l>57343)&&(s=l));break;case 4:c=t[i+1],u=t[i+2],h=t[i+3],128===(192&c)&&128===(192&u)&&128===(192&h)&&(l=(15&o)<<18|(63&c)<<12|(63&u)<<6|63&h,l>65535&&1114112>l&&(s=l))}}null===s?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),i+=a}return L(n)}function L(t){var e=t.length;if(Z>=e)return String.fromCharCode.apply(String,t);for(var r="",n=0;e>n;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Z));return r}function I(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(127&t[i]);return n}function D(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(t[i]);return n}function R(t,e,r){var n=t.length;(!e||0>e)&&(e=0),(!r||0>r||r>n)&&(r=n);for(var i="",o=e;r>o;o++)i+=G(t[o]);return i}function N(t,e,r){for(var n=t.slice(e,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function O(t,e,r){if(t%1!==0||0>t)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function B(e,r,n,i,o,s){if(!t.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");if(r>o||s>r)throw new RangeError("value is out of bounds");if(n+i>e.length)throw new RangeError("index out of range")}function C(t,e,r,n){0>e&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-r,2);o>i;i++)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function M(t,e,r,n){0>e&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-r,4);o>i;i++)t[r+i]=e>>>8*(n?i:3-i)&255}function q(t,e,r,n,i,o){if(e>i||o>e)throw new RangeError("value is out of bounds");if(r+n>t.length)throw new RangeError("index out of range");if(0>r)throw new RangeError("index out of range")}function P(t,e,r,n,i){return i||q(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),K.write(t,e,r,n,23,4),r+4}function U(t,e,r,n,i){return i||q(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),K.write(t,e,r,n,52,8),r+8}function F(t){if(t=j(t).replace(tt,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function j(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function G(t){return 16>t?"0"+t.toString(16):t.toString(16)}function Y(t,e){e=e||1/0;for(var r,n=t.length,i=null,o=[],s=0;n>s;s++){if(r=t.charCodeAt(s),r>55295&&57344>r){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(56320>r){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,128>r){if((e-=1)<0)break;o.push(r)}else if(2048>r){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(65536>r){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(1114112>r))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function V(t){for(var e=[],r=0;r<t.length;r++)e.push(255&t.charCodeAt(r));return e}function z(t,e){for(var r,n,i,o=[],s=0;s<t.length&&!((e-=2)<0);s++)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function H(t){return X.toByteArray(F(t))}function W(t,e,r,n){for(var i=0;n>i&&!(i+r>=e.length||i>=t.length);i++)e[i+r]=t[i];return i}var X=r(32),K=r(33),J=r(34);e.Buffer=t,e.SlowBuffer=m,e.INSPECT_MAX_BYTES=50,t.poolSize=8192;var Q={};t.TYPED_ARRAY_SUPPORT=void 0!==n.TYPED_ARRAY_SUPPORT?n.TYPED_ARRAY_SUPPORT:i(),t.TYPED_ARRAY_SUPPORT?(t.prototype.__proto__=Uint8Array.prototype,t.__proto__=Uint8Array):(t.prototype.length=void 0,t.prototype.parent=void 0),t.isBuffer=function(t){return!(null==t||!t._isBuffer)},t.compare=function(e,r){if(!t.isBuffer(e)||!t.isBuffer(r))throw new TypeError("Arguments must be Buffers");if(e===r)return 0;for(var n=e.length,i=r.length,o=0,s=Math.min(n,i);s>o&&e[o]===r[o];)++o;return o!==s&&(n=e[o],i=r[o]),i>n?-1:n>i?1:0},t.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},t.concat=function(e,r){if(!J(e))throw new TypeError("list argument must be an Array of Buffers.");if(0===e.length)return new t(0);var n;if(void 0===r)for(r=0,n=0;n<e.length;n++)r+=e[n].length;var i=new t(r),o=0;for(n=0;n<e.length;n++){var s=e[n];s.copy(i,o),o+=s.length}return i},t.byteLength=b,t.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?A(this,0,t):y.apply(this,arguments)},t.prototype.equals=function(e){if(!t.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:0===t.compare(this,e)},t.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},t.prototype.compare=function(e){if(!t.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?0:t.compare(this,e)},t.prototype.indexOf=function(e,r){function n(t,e,r){for(var n=-1,i=0;r+i<t.length;i++)if(t[r+i]===e[-1===n?0:i-n]){if(-1===n&&(n=i),i-n+1===e.length)return r+n}else n=-1;return-1}if(r>2147483647?r=2147483647:-2147483648>r&&(r=-2147483648),r>>=0,0===this.length)return-1;if(r>=this.length)return-1;if(0>r&&(r=Math.max(this.length+r,0)),"string"==typeof e)return 0===e.length?-1:String.prototype.indexOf.call(this,e,r);if(t.isBuffer(e))return n(this,e,r);if("number"==typeof e)return t.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,e,r):n(this,[e],r);throw new TypeError("val must be string, number or Buffer")},t.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},t.prototype.set=function(t,e){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,e)},t.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else if(isFinite(e))e=0|e,isFinite(r)?(r=0|r,void 0===n&&(n="utf8")):(n=r,r=void 0);else{var i=n;n=e,e=0|r,r=i}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(0>r||0>e)||e>this.length)throw new RangeError("attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return w(this,t,e,r);case"ascii":return S(this,t,e,r);case"binary":return E(this,t,e,r);case"base64":return k(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},t.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Z=4096;t.prototype.slice=function(e,r){var n=this.length;e=~~e,r=void 0===r?n:~~r,0>e?(e+=n,0>e&&(e=0)):e>n&&(e=n),0>r?(r+=n,0>r&&(r=0)):r>n&&(r=n),e>r&&(r=e);var i;if(t.TYPED_ARRAY_SUPPORT)i=t._augment(this.subarray(e,r));else{var o=r-e;i=new t(o,void 0);for(var s=0;o>s;s++)i[s]=this[s+e]}return i.length&&(i.parent=this.parent||this),i},t.prototype.readUIntLE=function(t,e,r){t=0|t,e=0|e,r||O(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return n},t.prototype.readUIntBE=function(t,e,r){t=0|t,e=0|e,r||O(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},t.prototype.readUInt8=function(t,e){return e||O(t,1,this.length),this[t]},t.prototype.readUInt16LE=function(t,e){return e||O(t,2,this.length),this[t]|this[t+1]<<8},t.prototype.readUInt16BE=function(t,e){return e||O(t,2,this.length),this[t]<<8|this[t+1]},t.prototype.readUInt32LE=function(t,e){return e||O(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},t.prototype.readUInt32BE=function(t,e){return e||O(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},t.prototype.readIntLE=function(t,e,r){t=0|t,e=0|e,r||O(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},t.prototype.readIntBE=function(t,e,r){t=0|t,e=0|e,r||O(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},t.prototype.readInt8=function(t,e){return e||O(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},t.prototype.readInt16LE=function(t,e){e||O(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},t.prototype.readInt16BE=function(t,e){e||O(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},t.prototype.readInt32LE=function(t,e){return e||O(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},t.prototype.readInt32BE=function(t,e){return e||O(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},t.prototype.readFloatLE=function(t,e){return e||O(t,4,this.length),K.read(this,t,!0,23,4)},t.prototype.readFloatBE=function(t,e){return e||O(t,4,this.length),K.read(this,t,!1,23,4)},t.prototype.readDoubleLE=function(t,e){return e||O(t,8,this.length),K.read(this,t,!0,52,8)},t.prototype.readDoubleBE=function(t,e){return e||O(t,8,this.length),K.read(this,t,!1,52,8)},t.prototype.writeUIntLE=function(t,e,r,n){t=+t,e=0|e,r=0|r,n||B(this,t,e,r,Math.pow(2,8*r),0);var i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},t.prototype.writeUIntBE=function(t,e,r,n){t=+t,e=0|e,r=0|r,n||B(this,t,e,r,Math.pow(2,8*r),0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},t.prototype.writeUInt8=function(e,r,n){return e=+e,r=0|r,n||B(this,e,r,1,255,0),t.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[r]=255&e,r+1},t.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=0|r,n||B(this,e,r,2,65535,0),t.TYPED_ARRAY_SUPPORT?(this[r]=255&e,this[r+1]=e>>>8):C(this,e,r,!0),r+2},t.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=0|r,n||B(this,e,r,2,65535,0),t.TYPED_ARRAY_SUPPORT?(this[r]=e>>>8,this[r+1]=255&e):C(this,e,r,!1),r+2},t.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=0|r,n||B(this,e,r,4,4294967295,0),t.TYPED_ARRAY_SUPPORT?(this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=255&e):M(this,e,r,!0),r+4},t.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=0|r,n||B(this,e,r,4,4294967295,0),t.TYPED_ARRAY_SUPPORT?(this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=255&e):M(this,e,r,!1),r+4},t.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);B(this,t,e,r,i-1,-i)}var o=0,s=1,a=0>t?1:0;for(this[e]=255&t;++o<r&&(s*=256);)this[e+o]=(t/s>>0)-a&255;return e+r},t.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);B(this,t,e,r,i-1,-i)}var o=r-1,s=1,a=0>t?1:0;for(this[e+o]=255&t;--o>=0&&(s*=256);)this[e+o]=(t/s>>0)-a&255;return e+r},t.prototype.writeInt8=function(e,r,n){return e=+e,r=0|r,n||B(this,e,r,1,127,-128),t.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),0>e&&(e=255+e+1),this[r]=255&e,r+1},t.prototype.writeInt16LE=function(e,r,n){return e=+e,r=0|r,n||B(this,e,r,2,32767,-32768),t.TYPED_ARRAY_SUPPORT?(this[r]=255&e,this[r+1]=e>>>8):C(this,e,r,!0),r+2},t.prototype.writeInt16BE=function(e,r,n){return e=+e,r=0|r,n||B(this,e,r,2,32767,-32768),t.TYPED_ARRAY_SUPPORT?(this[r]=e>>>8,this[r+1]=255&e):C(this,e,r,!1),r+2},t.prototype.writeInt32LE=function(e,r,n){return e=+e,r=0|r,n||B(this,e,r,4,2147483647,-2147483648),t.TYPED_ARRAY_SUPPORT?(this[r]=255&e,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24):M(this,e,r,!0),r+4},t.prototype.writeInt32BE=function(e,r,n){return e=+e,r=0|r,n||B(this,e,r,4,2147483647,-2147483648),0>e&&(e=4294967295+e+1),t.TYPED_ARRAY_SUPPORT?(this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=255&e):M(this,e,r,!1),r+4},t.prototype.writeFloatLE=function(t,e,r){return P(this,t,e,!0,r)},t.prototype.writeFloatBE=function(t,e,r){return P(this,t,e,!1,r)},t.prototype.writeDoubleLE=function(t,e,r){return U(this,t,e,!0,r)},t.prototype.writeDoubleBE=function(t,e,r){return U(this,t,e,!1,r)},t.prototype.copy=function(e,r,n,i){if(n||(n=0),i||0===i||(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&n>i&&(i=n),i===n)return 0;if(0===e.length||0===this.length)return 0;if(0>r)throw new RangeError("targetStart out of bounds");if(0>n||n>=this.length)throw new RangeError("sourceStart out of bounds");if(0>i)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);var o,s=i-n;if(this===e&&r>n&&i>r)for(o=s-1;o>=0;o--)e[o+r]=this[o+n];else if(1e3>s||!t.TYPED_ARRAY_SUPPORT)for(o=0;s>o;o++)e[o+r]=this[o+n];else e._set(this.subarray(n,n+s),r);return s},t.prototype.fill=function(t,e,r){if(t||(t=0),e||(e=0),r||(r=this.length),e>r)throw new RangeError("end < start");if(r!==e&&0!==this.length){if(0>e||e>=this.length)throw new RangeError("start out of bounds");if(0>r||r>this.length)throw new RangeError("end out of bounds");var n;if("number"==typeof t)for(n=e;r>n;n++)this[n]=t;else{var i=Y(t.toString()),o=i.length;for(n=e;r>n;n++)this[n]=i[n%o]}return this}},t.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(t.TYPED_ARRAY_SUPPORT)return new t(this).buffer;for(var e=new Uint8Array(this.length),r=0,n=e.length;n>r;r+=1)e[r]=this[r];return e.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var $=t.prototype;t._augment=function(e){return e.constructor=t,e._isBuffer=!0,e._set=e.set,e.get=$.get,e.set=$.set,e.write=$.write,e.toString=$.toString,e.toLocaleString=$.toString,e.toJSON=$.toJSON,e.equals=$.equals,e.compare=$.compare,e.indexOf=$.indexOf,e.copy=$.copy,e.slice=$.slice,e.readUIntLE=$.readUIntLE,e.readUIntBE=$.readUIntBE,e.readUInt8=$.readUInt8,e.readUInt16LE=$.readUInt16LE,e.readUInt16BE=$.readUInt16BE,e.readUInt32LE=$.readUInt32LE,e.readUInt32BE=$.readUInt32BE,e.readIntLE=$.readIntLE,e.readIntBE=$.readIntBE,e.readInt8=$.readInt8,e.readInt16LE=$.readInt16LE,e.readInt16BE=$.readInt16BE,e.readInt32LE=$.readInt32LE,e.readInt32BE=$.readInt32BE,e.readFloatLE=$.readFloatLE,e.readFloatBE=$.readFloatBE,e.readDoubleLE=$.readDoubleLE,e.readDoubleBE=$.readDoubleBE,e.writeUInt8=$.writeUInt8,e.writeUIntLE=$.writeUIntLE,e.writeUIntBE=$.writeUIntBE,e.writeUInt16LE=$.writeUInt16LE,e.writeUInt16BE=$.writeUInt16BE,e.writeUInt32LE=$.writeUInt32LE,e.writeUInt32BE=$.writeUInt32BE,e.writeIntLE=$.writeIntLE,e.writeIntBE=$.writeIntBE,e.writeInt8=$.writeInt8,e.writeInt16LE=$.writeInt16LE,e.writeInt16BE=$.writeInt16BE,e.writeInt32LE=$.writeInt32LE,e.writeInt32BE=$.writeInt32BE,e.writeFloatLE=$.writeFloatLE,e.writeFloatBE=$.writeFloatBE,e.writeDoubleLE=$.writeDoubleLE,e.writeDoubleBE=$.writeDoubleBE,e.fill=$.fill,e.inspect=$.inspect,e.toArrayBuffer=$.toArrayBuffer,e};var tt=/[^+\/0-9A-Za-z-_]/g}).call(e,r(31).Buffer,function(){return this}())},function(t,e,r){var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(t){"use strict";function e(t){var e=t.charCodeAt(0);return e===s||e===l?62:e===a||e===p?63:c>e?-1:c+10>e?e-c+26+26:h+26>e?e-h:u+26>e?e-u+26:void 0}function r(t){function r(t){u[l++]=t}var n,i,s,a,c,u;if(t.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var h=t.length;c="="===t.charAt(h-2)?2:"="===t.charAt(h-1)?1:0,u=new o(3*t.length/4-c),s=c>0?t.length-4:t.length;var l=0;for(n=0,i=0;s>n;n+=4,i+=3)a=e(t.charAt(n))<<18|e(t.charAt(n+1))<<12|e(t.charAt(n+2))<<6|e(t.charAt(n+3)),r((16711680&a)>>16),r((65280&a)>>8),r(255&a);return 2===c?(a=e(t.charAt(n))<<2|e(t.charAt(n+1))>>4,r(255&a)):1===c&&(a=e(t.charAt(n))<<10|e(t.charAt(n+1))<<4|e(t.charAt(n+2))>>2,r(a>>8&255),r(255&a)),u}function i(t){function e(t){return n.charAt(t)}function r(t){return e(t>>18&63)+e(t>>12&63)+e(t>>6&63)+e(63&t)}var i,o,s,a=t.length%3,c="";for(i=0,s=t.length-a;s>i;i+=3)o=(t[i]<<16)+(t[i+1]<<8)+t[i+2],c+=r(o);switch(a){case 1:o=t[t.length-1],c+=e(o>>2),c+=e(o<<4&63),c+="==";break;case 2:o=(t[t.length-2]<<8)+t[t.length-1],c+=e(o>>10),c+=e(o>>4&63),c+=e(o<<2&63),c+="="}return c}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="+".charCodeAt(0),a="/".charCodeAt(0),c="0".charCodeAt(0),u="a".charCodeAt(0),h="A".charCodeAt(0),l="-".charCodeAt(0),p="_".charCodeAt(0);t.toByteArray=r,t.fromByteArray=i}(e)},function(t,e){e.read=function(t,e,r,n,i){var o,s,a=8*i-n-1,c=(1<<a)-1,u=c>>1,h=-7,l=r?i-1:0,p=r?-1:1,f=t[e+l];for(l+=p,o=f&(1<<-h)-1,f>>=-h,h+=a;h>0;o=256*o+t[e+l],l+=p,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=256*s+t[e+l],l+=p,h-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:(f?-1:1)*(1/0);s+=Math.pow(2,n),o-=u}return(f?-1:1)*s*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var s,a,c,u=8*o-i-1,h=(1<<u)-1,l=h>>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:o-1,d=n?1:-1,g=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),e+=s+l>=1?p/c:p*Math.pow(2,1-l),e*c>=2&&(s++,c/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(e*c-1)*Math.pow(2,i),s+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;t[r+f]=255&a,f+=d,a/=256,i-=8);for(s=s<<i|a,u+=i;u>0;t[r+f]=255&s,f+=d,s/=256,u-=8);t[r+f-d]|=128*g}},function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,e,r){(function(t){function r(t){return Array.isArray?Array.isArray(t):"[object Array]"===_(t)}function n(t){return"boolean"==typeof t}function i(t){return null===t}function o(t){return null==t}function s(t){return"number"==typeof t}function a(t){return"string"==typeof t}function c(t){return"symbol"==typeof t}function u(t){return void 0===t}function h(t){return"[object RegExp]"===_(t)}function l(t){return"object"==typeof t&&null!==t}function p(t){return"[object Date]"===_(t)}function f(t){return"[object Error]"===_(t)||t instanceof Error}function d(t){return"function"==typeof t}function g(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||"undefined"==typeof t}function _(t){return Object.prototype.toString.call(t)}e.isArray=r,e.isBoolean=n,e.isNull=i,e.isNullOrUndefined=o,e.isNumber=s,e.isString=a,e.isSymbol=c,e.isUndefined=u,e.isRegExp=h,e.isObject=l,e.isDate=p,e.isError=f,e.isFunction=d,e.isPrimitive=g,e.isBuffer=t.isBuffer}).call(e,r(31).Buffer)},function(t,e){},function(t,e,r){(function(e){function n(t){return this instanceof n?(c.call(this,t),u.call(this,t),t&&t.readable===!1&&(this.readable=!1),t&&t.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,t&&t.allowHalfOpen===!1&&(this.allowHalfOpen=!1),void this.once("end",i)):new n(t)}function i(){this.allowHalfOpen||this._writableState.ended||e.nextTick(this.end.bind(this))}function o(t,e){for(var r=0,n=t.length;n>r;r++)e(t[r],r)}t.exports=n;var s=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e},a=r(35);a.inherits=r(5);var c=r(29),u=r(38);a.inherits(n,c),o(s(u.prototype),function(t){n.prototype[t]||(n.prototype[t]=u.prototype[t])})}).call(e,r(3))},function(t,e,r){(function(e){function n(t,e,r){this.chunk=t,this.encoding=e,this.callback=r}function i(t,e){var n=r(37);t=t||{};var i=t.highWaterMark,o=t.objectMode?16:16384;this.highWaterMark=i||0===i?i:o,this.objectMode=!!t.objectMode,e instanceof n&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var s=t.decodeStrings===!1;this.decodeStrings=!s,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){f(e,t)},this.writecb=null,this.writelen=0,this.buffer=[],this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1}function o(t){var e=r(37);return this instanceof o||this instanceof e?(this._writableState=new i(t,this),this.writable=!0,void E.call(this)):new o(t)}function s(t,r,n){var i=new Error("write after end");t.emit("error",i),e.nextTick(function(){n(i)})}function a(t,r,n,i){var o=!0;if(!(S.isBuffer(n)||S.isString(n)||S.isNullOrUndefined(n)||r.objectMode)){var s=new TypeError("Invalid non-string/buffer chunk");t.emit("error",s),e.nextTick(function(){i(s)}),o=!1}return o}function c(t,e,r){return!t.objectMode&&t.decodeStrings!==!1&&S.isString(e)&&(e=new w(e,r)),e}function u(t,e,r,i,o){r=c(e,r,i),S.isBuffer(r)&&(i="buffer");var s=e.objectMode?1:r.length;e.length+=s;var a=e.length<e.highWaterMark;return a||(e.needDrain=!0),e.writing||e.corked?e.buffer.push(new n(r,i,o)):h(t,e,!1,s,r,i,o),a}function h(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function l(t,r,n,i,o){n?e.nextTick(function(){r.pendingcb--,o(i)}):(r.pendingcb--,o(i)),t._writableState.errorEmitted=!0,t.emit("error",i)}function p(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}function f(t,r){var n=t._writableState,i=n.sync,o=n.writecb;if(p(n),r)l(t,n,i,r,o);else{var s=m(t,n);s||n.corked||n.bufferProcessing||!n.buffer.length||_(t,n),i?e.nextTick(function(){d(t,n,s,o)}):d(t,n,s,o)}}function d(t,e,r,n){r||g(t,e),e.pendingcb--,n(),y(t,e)}function g(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}function _(t,e){if(e.bufferProcessing=!0,t._writev&&e.buffer.length>1){for(var r=[],n=0;n<e.buffer.length;n++)r.push(e.buffer[n].callback);e.pendingcb++,h(t,e,!0,e.length,e.buffer,"",function(t){for(var n=0;n<r.length;n++)e.pendingcb--,r[n](t)}),e.buffer=[]}else{for(var n=0;n<e.buffer.length;n++){var i=e.buffer[n],o=i.chunk,s=i.encoding,a=i.callback,c=e.objectMode?1:o.length;if(h(t,e,!1,c,o,s,a),e.writing){n++;break}}n<e.buffer.length?e.buffer=e.buffer.slice(n):e.buffer.length=0}e.bufferProcessing=!1}function m(t,e){return e.ending&&0===e.length&&!e.finished&&!e.writing}function b(t,e){e.prefinished||(e.prefinished=!0,t.emit("prefinish"))}function y(t,e){var r=m(t,e);return r&&(0===e.pendingcb?(b(t,e),e.finished=!0,t.emit("finish")):b(t,e)),r}function v(t,r,n){r.ending=!0,y(t,r),n&&(r.finished?e.nextTick(n):t.once("finish",n)),r.ended=!0}t.exports=o;var w=r(31).Buffer;o.WritableState=i;var S=r(35);S.inherits=r(5);var E=r(27);S.inherits(o,E),o.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))},o.prototype.write=function(t,e,r){var n=this._writableState,i=!1;return S.isFunction(e)&&(r=e,e=null),S.isBuffer(t)?e="buffer":e||(e=n.defaultEncoding),S.isFunction(r)||(r=function(){}),n.ended?s(this,n,r):a(this,n,t,r)&&(n.pendingcb++,i=u(this,n,t,e,r)),i},o.prototype.cork=function(){var t=this._writableState;t.corked++},o.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.finished||t.bufferProcessing||!t.buffer.length||_(this,t))},o.prototype._write=function(t,e,r){r(new Error("not implemented"))},o.prototype._writev=null,o.prototype.end=function(t,e,r){var n=this._writableState;S.isFunction(t)?(r=t,t=null,e=null):S.isFunction(e)&&(r=e,e=null),S.isNullOrUndefined(t)||this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||v(this,n,r)}}).call(e,r(3))},function(t,e,r){function n(t){if(t&&!c(t))throw new Error("Unknown encoding: "+t)}function i(t){return t.toString(this.encoding)}function o(t){this.charReceived=t.length%2,this.charLength=this.charReceived?2:0}function s(t){this.charReceived=t.length%3,this.charLength=this.charReceived?3:0}var a=r(31).Buffer,c=a.isEncoding||function(t){switch(t&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}},u=e.StringDecoder=function(t){switch(this.encoding=(t||"utf8").toLowerCase().replace(/[-_]/,""),n(t),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=o;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=s;break;default:return void(this.write=i)}this.charBuffer=new a(6),this.charReceived=0,this.charLength=0};u.prototype.write=function(t){for(var e="";this.charLength;){var r=t.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:t.length;if(t.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived<this.charLength)return"";t=t.slice(r,t.length),e=this.charBuffer.slice(0,this.charLength).toString(this.encoding);var n=e.charCodeAt(e.length-1);if(!(n>=55296&&56319>=n)){if(this.charReceived=this.charLength=0,0===t.length)return e;break}this.charLength+=this.surrogateSize,e=""}this.detectIncompleteChar(t);var i=t.length;this.charLength&&(t.copy(this.charBuffer,0,t.length-this.charReceived,i),i-=this.charReceived),e+=t.toString(this.encoding,0,i);var i=e.length-1,n=e.charCodeAt(i);if(n>=55296&&56319>=n){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),t.copy(this.charBuffer,0,0,o),e.substring(0,i)}return e},u.prototype.detectIncompleteChar=function(t){for(var e=t.length>=3?3:t.length;e>0;e--){var r=t[t.length-e];if(1==e&&r>>5==6){this.charLength=2;break}if(2>=e&&r>>4==14){this.charLength=3;break}if(3>=e&&r>>3==30){this.charLength=4;break}}this.charReceived=e},u.prototype.end=function(t){var e="";if(t&&t.length&&(e=this.write(t)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;e+=n.slice(0,r).toString(i)}return e}},function(t,e,r){function n(t,e){this.afterTransform=function(t,r){return i(e,t,r)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null}function i(t,e,r){var n=t._transformState;n.transforming=!1;var i=n.writecb;if(!i)return t.emit("error",new Error("no writecb in Transform class"));n.writechunk=null,n.writecb=null,c.isNullOrUndefined(r)||t.push(r),i&&i(e);var o=t._readableState;o.reading=!1,(o.needReadable||o.length<o.highWaterMark)&&t._read(o.highWaterMark)}function o(t){if(!(this instanceof o))return new o(t);a.call(this,t),this._transformState=new n(t,this);var e=this;this._readableState.needReadable=!0,this._readableState.sync=!1,this.once("prefinish",function(){c.isFunction(this._flush)?this._flush(function(t){s(e,t)}):s(e)})}function s(t,e){if(e)return t.emit("error",e);var r=t._writableState,n=t._transformState;if(r.length)throw new Error("calling transform done when ws.length != 0");if(n.transforming)throw new Error("calling transform done when still transforming");return t.push(null)}t.exports=o;var a=r(37),c=r(35);c.inherits=r(5),c.inherits(o,a),o.prototype.push=function(t,e){return this._transformState.needTransform=!1,a.prototype.push.call(this,t,e)},o.prototype._transform=function(t,e,r){throw new Error("not implemented")},o.prototype._write=function(t,e,r){var n=this._transformState;if(n.writecb=r,n.writechunk=t,n.writeencoding=e,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},o.prototype._read=function(t){var e=this._transformState;c.isNull(e.writechunk)||!e.writecb||e.transforming?e.needTransform=!0:(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform))}},function(t,e,r){function n(t){return this instanceof n?void i.call(this,t):new n(t)}t.exports=n;var i=r(40),o=r(35);o.inherits=r(5),o.inherits(n,i),n.prototype._transform=function(t,e,r){r(null,t)}},function(t,e,r){t.exports=r(38)},function(t,e,r){t.exports=r(37)},function(t,e,r){t.exports=r(40)},function(t,e,r){t.exports=r(41)},function(t,e){},function(t,e,r){function n(t){this._cbs=t||{}}t.exports=n;var i=r(12).EVENTS;Object.keys(i).forEach(function(t){if(0===i[t])t="on"+t,n.prototype[t]=function(){this._cbs[t]&&this._cbs[t]()};else if(1===i[t])t="on"+t,n.prototype[t]=function(e){this._cbs[t]&&this._cbs[t](e)};else{if(2!==i[t])throw Error("wrong number of arguments");t="on"+t,n.prototype[t]=function(e,r){this._cbs[t]&&this._cbs[t](e,r)}}})},function(t,e,r){var n=t.exports;[r(49),r(55),r(56),r(57),r(58),r(59)].forEach(function(t){Object.keys(t).forEach(function(e){n[e]=t[e].bind(n)})})},function(t,e,r){function n(t,e){return t.children?t.children.map(function(t){return s(t,e)}).join(""):""}function i(t){return Array.isArray(t)?t.map(i).join(""):a(t)||t.type===o.CDATA?i(t.children):t.type===o.Text?t.data:""}var o=r(21),s=r(50),a=o.isTag;t.exports={getInnerHTML:n,getOuterHTML:s,getText:i -}},function(t,e,r){function n(t,e){if(t){var r,n="";for(var i in t)r=t[i],n&&(n+=" "),n+=!r&&l[i]?i:i+'="'+(e.decodeEntities?h.encodeXML(r):r)+'"';return n}}function i(t,e){"svg"===t.name&&(e={decodeEntities:e.decodeEntities,xmlMode:!0});var r="<"+t.name,i=n(t.attribs,e);return i&&(r+=" "+i),!e.xmlMode||t.children&&0!==t.children.length?(r+=">",t.children&&(r+=d(t.children,e)),f[t.name]&&!e.xmlMode||(r+="</"+t.name+">")):r+="/>",r}function o(t){return"<"+t.data+">"}function s(t,e){var r=t.data||"";return!e.decodeEntities||t.parent&&t.parent.name in p||(r=h.encodeXML(r)),r}function a(t){return"<![CDATA["+t.children[0].data+"]]>"}function c(t){return"<!--"+t.data+"-->"}var u=r(51),h=r(52),l={__proto__:null,allowfullscreen:!0,async:!0,autofocus:!0,autoplay:!0,checked:!0,controls:!0,"default":!0,defer:!0,disabled:!0,hidden:!0,ismap:!0,loop:!0,multiple:!0,muted:!0,open:!0,readonly:!0,required:!0,reversed:!0,scoped:!0,seamless:!0,selected:!0,typemustmatch:!0},p={__proto__:null,style:!0,script:!0,xmp:!0,iframe:!0,noembed:!0,noframes:!0,plaintext:!0,noscript:!0},f={__proto__:null,area:!0,base:!0,basefont:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,isindex:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},d=t.exports=function(t,e){Array.isArray(t)||t.cheerio||(t=[t]),e=e||{};for(var r="",n=0;n<t.length;n++){var h=t[n];r+="root"===h.type?d(h.children,e):u.isTag(h)?i(h,e):h.type===u.Directive?o(h):h.type===u.Comment?c(h):h.type===u.CDATA?a(h):s(h,e)}return r}},function(t,e){t.exports={Text:"text",Directive:"directive",Comment:"comment",Script:"script",Style:"style",Tag:"tag",CDATA:"cdata",isTag:function(t){return"tag"===t.type||"script"===t.type||"style"===t.type}}},function(t,e,r){var n=r(53),i=r(54);e.decode=function(t,e){return(!e||0>=e?i.XML:i.HTML)(t)},e.decodeStrict=function(t,e){return(!e||0>=e?i.XML:i.HTMLStrict)(t)},e.encode=function(t,e){return(!e||0>=e?n.XML:n.HTML)(t)},e.encodeXML=n.XML,e.encodeHTML4=e.encodeHTML5=e.encodeHTML=n.HTML,e.decodeXML=e.decodeXMLStrict=i.XML,e.decodeHTML4=e.decodeHTML5=e.decodeHTML=i.HTML,e.decodeHTML4Strict=e.decodeHTML5Strict=e.decodeHTMLStrict=i.HTMLStrict,e.escape=n.escape},function(t,e,r){function n(t){return Object.keys(t).sort().reduce(function(e,r){return e[t[r]]="&"+r+";",e},{})}function i(t){var e=[],r=[];return Object.keys(t).forEach(function(t){1===t.length?e.push("\\"+t):r.push(t)}),r.unshift("["+e.join("")+"]"),new RegExp(r.join("|"),"g")}function o(t){return"&#x"+t.charCodeAt(0).toString(16).toUpperCase()+";"}function s(t){var e=t.charCodeAt(0),r=t.charCodeAt(1),n=1024*(e-55296)+r-56320+65536;return"&#x"+n.toString(16).toUpperCase()+";"}function a(t,e){function r(e){return t[e]}return function(t){return t.replace(e,r).replace(d,s).replace(f,o)}}function c(t){return t.replace(g,o).replace(d,s).replace(f,o)}var u=n(r(19)),h=i(u);e.XML=a(u,h);var l=n(r(17)),p=i(l);e.HTML=a(l,p);var f=/[^\0-\x7F]/g,d=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,g=i(u);e.escape=c},function(t,e,r){function n(t){var e=Object.keys(t).join("|"),r=o(t);e+="|#[xX][\\da-fA-F]+|#\\d+";var n=new RegExp("&(?:"+e+");","g");return function(t){return String(t).replace(n,r)}}function i(t,e){return e>t?1:-1}function o(t){return function(e){return"#"===e.charAt(1)?u("X"===e.charAt(2)||"x"===e.charAt(2)?parseInt(e.substr(3),16):parseInt(e.substr(2),10)):t[e.slice(1,-1)]}}var s=r(17),a=r(18),c=r(19),u=r(15),h=n(c),l=n(s),p=function(){function t(t){return";"!==t.substr(-1)&&(t+=";"),h(t)}for(var e=Object.keys(a).sort(i),r=Object.keys(s).sort(i),n=0,c=0;n<r.length;n++)e[c]===r[n]?(r[n]+=";?",c++):r[n]+=";";var u=new RegExp("&(?:"+r.join("|")+"|#[xX][\\da-fA-F]+;?|#\\d+;?)","g"),h=o(s);return function(e){return String(e).replace(u,t)}}();t.exports={XML:h,HTML:p,HTMLStrict:l}},function(t,e){var r=e.getChildren=function(t){return t.children},n=e.getParent=function(t){return t.parent};e.getSiblings=function(t){var e=n(t);return e?r(e):[t]},e.getAttributeValue=function(t,e){return t.attribs&&t.attribs[e]},e.hasAttrib=function(t,e){return!!t.attribs&&hasOwnProperty.call(t.attribs,e)},e.getName=function(t){return t.name}},function(t,e){e.removeElement=function(t){if(t.prev&&(t.prev.next=t.next),t.next&&(t.next.prev=t.prev),t.parent){var e=t.parent.children;e.splice(e.lastIndexOf(t),1)}},e.replaceElement=function(t,e){var r=e.prev=t.prev;r&&(r.next=e);var n=e.next=t.next;n&&(n.prev=e);var i=e.parent=t.parent;if(i){var o=i.children;o[o.lastIndexOf(t)]=e}},e.appendChild=function(t,e){if(e.parent=t,1!==t.children.push(e)){var r=t.children[t.children.length-2];r.next=e,e.prev=r,e.next=null}},e.append=function(t,e){var r=t.parent,n=t.next;if(e.next=n,e.prev=t,t.next=e,e.parent=r,n){if(n.prev=e,r){var i=r.children;i.splice(i.lastIndexOf(n),0,e)}}else r&&r.children.push(e)},e.prepend=function(t,e){var r=t.parent;if(r){var n=r.children;n.splice(n.lastIndexOf(t),0,e)}t.prev&&(t.prev.next=e),e.parent=r,e.prev=t.prev,e.next=t,t.prev=e}},function(t,e,r){function n(t,e,r,n){return Array.isArray(e)||(e=[e]),"number"==typeof n&&isFinite(n)||(n=1/0),i(t,e,r!==!1,n)}function i(t,e,r,n){for(var o,s=[],a=0,c=e.length;c>a&&!(t(e[a])&&(s.push(e[a]),--n<=0))&&(o=e[a].children,!(r&&o&&o.length>0&&(o=i(t,o,r,n),s=s.concat(o),n-=o.length,0>=n)));a++);return s}function o(t,e){for(var r=0,n=e.length;n>r;r++)if(t(e[r]))return e[r];return null}function s(t,e){for(var r=null,n=0,i=e.length;i>n&&!r;n++)u(e[n])&&(t(e[n])?r=e[n]:e[n].children.length>0&&(r=s(t,e[n].children)));return r}function a(t,e){for(var r=0,n=e.length;n>r;r++)if(u(e[r])&&(t(e[r])||e[r].children.length>0&&a(t,e[r].children)))return!0;return!1}function c(t,e){for(var r=[],n=0,i=e.length;i>n;n++)u(e[n])&&(t(e[n])&&r.push(e[n]),e[n].children.length>0&&(r=r.concat(c(t,e[n].children))));return r}var u=r(21).isTag;t.exports={filter:n,find:i,findOneChild:o,findOne:s,existsOne:a,findAll:c}},function(t,e,r){function n(t,e){return"function"==typeof e?function(r){return r.attribs&&e(r.attribs[t])}:function(r){return r.attribs&&r.attribs[t]===e}}function i(t,e){return function(r){return t(r)||e(r)}}var o=r(21),s=e.isTag=o.isTag;e.testElement=function(t,e){for(var r in t)if(t.hasOwnProperty(r)){if("tag_name"===r){if(!s(e)||!t.tag_name(e.name))return!1}else if("tag_type"===r){if(!t.tag_type(e.type))return!1}else if("tag_contains"===r){if(s(e)||!t.tag_contains(e.data))return!1}else if(!e.attribs||!t[r](e.attribs[r]))return!1}else;return!0};var a={tag_name:function(t){return"function"==typeof t?function(e){return s(e)&&t(e.name)}:"*"===t?s:function(e){return s(e)&&e.name===t}},tag_type:function(t){return"function"==typeof t?function(e){return t(e.type)}:function(e){return e.type===t}},tag_contains:function(t){return"function"==typeof t?function(e){return!s(e)&&t(e.data)}:function(e){return!s(e)&&e.data===t}}};e.getElements=function(t,e,r,o){var s=Object.keys(t).map(function(e){var r=t[e];return e in a?a[e](r):n(e,r)});return 0===s.length?[]:this.filter(s.reduce(i),e,r,o)},e.getElementById=function(t,e,r){return Array.isArray(e)||(e=[e]),this.findOne(n("id",t),e,r!==!1)},e.getElementsByTagName=function(t,e,r,n){return this.filter(a.tag_name(t),e,r,n)},e.getElementsByTagType=function(t,e,r,n){return this.filter(a.tag_type(t),e,r,n)}},function(t,e){e.removeSubsets=function(t){for(var e,r,n,i=t.length;--i>-1;){for(e=r=t[i],t[i]=null,n=!0;r;){if(t.indexOf(r)>-1){n=!1,t.splice(i,1);break}r=r.parent}n&&(t[i]=e)}return t};var r={DISCONNECTED:1,PRECEDING:2,FOLLOWING:4,CONTAINS:8,CONTAINED_BY:16},n=e.compareDocumentPosition=function(t,e){var n,i,o,s,a,c,u=[],h=[];if(t===e)return 0;for(n=t;n;)u.unshift(n),n=n.parent;for(n=e;n;)h.unshift(n),n=n.parent;for(c=0;u[c]===h[c];)c++;return 0===c?r.DISCONNECTED:(i=u[c-1],o=i.children,s=u[c],a=h[c],o.indexOf(s)>o.indexOf(a)?i===e?r.FOLLOWING|r.CONTAINED_BY:r.FOLLOWING:i===t?r.PRECEDING|r.CONTAINS:r.PRECEDING)};e.uniqueSort=function(t){var e,i,o=t.length;for(t=t.slice();--o>-1;)e=t[o],i=t.indexOf(e),i>-1&&o>i&&t.splice(o,1);return t.sort(function(t,e){var i=n(t,e);return i&r.PRECEDING?-1:i&r.FOLLOWING?1:0}),t}},function(t,e,r){function n(t){this._cbs=t||{},this.events=[]}t.exports=n;var i=r(12).EVENTS;Object.keys(i).forEach(function(t){if(0===i[t])t="on"+t,n.prototype[t]=function(){this.events.push([t]),this._cbs[t]&&this._cbs[t]()};else if(1===i[t])t="on"+t,n.prototype[t]=function(e){this.events.push([t,e]),this._cbs[t]&&this._cbs[t](e)};else{if(2!==i[t])throw Error("wrong number of arguments");t="on"+t,n.prototype[t]=function(e,r){this.events.push([t,e,r]),this._cbs[t]&&this._cbs[t](e,r)}}}),n.prototype.onreset=function(){this.events=[],this._cbs.onreset&&this._cbs.onreset()},n.prototype.restart=function(){this._cbs.onreset&&this._cbs.onreset();for(var t=0,e=this.events.length;e>t;t++)if(this._cbs[this.events[t][0]]){var r=this.events[t].length;1===r?this._cbs[this.events[t][0]]():2===r?this._cbs[this.events[t][0]](this.events[t][1]):this._cbs[this.events[t][0]](this.events[t][1],this.events[t][2])}}},function(t,e,r){function n(t){i.call(this),this.targets=t,this.threads=[],this.sequencer=new o(this),this._primitives={},this._registerBlockPackages(),this.ioDevices={clock:new c,mouse:new u}}var i=r(1),o=r(62),s=r(64),a=r(2),c=r(66),u=r(67),h={scratch3_control:r(68),scratch3_event:r(79),scratch3_looks:r(80),scratch3_motion:r(81),scratch3_operators:r(82),scratch3_sensing:r(84)};n.STACK_GLOW_ON="STACK_GLOW_ON",n.STACK_GLOW_OFF="STACK_GLOW_OFF",n.BLOCK_GLOW_ON="BLOCK_GLOW_ON",n.BLOCK_GLOW_OFF="BLOCK_GLOW_OFF",n.VISUAL_REPORT="VISUAL_REPORT",a.inherits(n,i),n.THREAD_STEP_INTERVAL=1e3/60,n.prototype._registerBlockPackages=function(){for(var t in h)if(h.hasOwnProperty(t)){var e=new h[t](this),r=e.getPrimitives();for(var n in r)r.hasOwnProperty(n)&&(this._primitives[n]=r[n].bind(e))}},n.prototype.getOpcodeFunction=function(t){return this._primitives[t]},n.prototype._pushThread=function(t){this.emit(n.STACK_GLOW_ON,t);var e=new s(t);e.pushStack(t),this.threads.push(e)},n.prototype._removeThread=function(t){var e=this.threads.indexOf(t);e>-1&&(this.emit(n.STACK_GLOW_OFF,t.topBlock),this.threads.splice(e,1))},n.prototype.toggleScript=function(t){for(var e=0;e<this.threads.length;e++)if(this.threads[e].topBlock==t)return void this._removeThread(this.threads[e]);this._pushThread(t)},n.prototype.greenFlag=function(){for(var t=0;t<this.threads.length;t++)this._removeThread(this.threads[t]);for(var e=0;e<this.targets.length;e++)for(var r=this.targets[e],n=r.blocks.getScripts(),i=0;i<n.length;i++){var o=n[i];"event_whenflagclicked"===r.blocks.getBlock(o).opcode&&this._pushThread(n[i])}},n.prototype.stopAll=function(){for(var t=this.threads.slice();t.length>0;){for(var e=t.pop(),r=0;r<e.stack.length;r++)this.glowBlock(e.stack[r],!1);this._removeThread(e)}},n.prototype._step=function(){for(var t=this.sequencer.stepThreads(this.threads),e=0;e<t.length;e++)this._removeThread(t[e])},n.prototype.glowBlock=function(t,e){e?this.emit(n.BLOCK_GLOW_ON,t):this.emit(n.BLOCK_GLOW_OFF,t)},n.prototype.visualReport=function(t,e){this.emit(n.VISUAL_REPORT,t,String(e))},n.prototype.targetForThread=function(t){for(var e=0;e<this.targets.length;e++){var r=this.targets[e];if(r.blocks.getBlock(t.topBlock))return r}},n.prototype.animationFrame=function(){self.renderer&&self.renderer.draw()},n.prototype.start=function(){self.setInterval(function(){this._step()}.bind(this),n.THREAD_STEP_INTERVAL)},t.exports=n},function(t,e,r){function n(t){this.timer=new i,this.runtime=t}var i=r(63),o=r(64),s=r(65);n.WORK_TIME=10,n.prototype.stepThreads=function(t){this.timer.start();for(var e=[],r=0,i=0;i<t.length;i++)t[i].status===o.STATUS_YIELD_FRAME&&t[i].setStatus(o.STATUS_RUNNING);for(;t.length>0&&t.length>r&&this.timer.timeElapsed()<n.WORK_TIME;){var s=[];r=0;for(var a=0;a<t.length;a++){var c=t[a];c.status===o.STATUS_RUNNING?this.startThread(c):c.status!==o.STATUS_YIELD&&c.status!==o.STATUS_YIELD_FRAME||r++,0===c.stack.length&&c.status===o.STATUS_DONE?e.push(c):s.push(c)}t=s}return e},n.prototype.startThread=function(t){var e=t.peekStack();return e?(s(this,t),void(t.status===o.STATUS_RUNNING&&t.peekStack()===e&&this.proceedThread(t))):(t.popStack(),void t.setStatus(o.STATUS_YIELD_FRAME))},n.prototype.stepToBranch=function(t,e){e||(e=1);var r=t.peekStack(),n=this.runtime.targetForThread(t).blocks.getBranch(r,e);n?t.pushStack(n):t.pushStack(null)},n.prototype.stepToReporter=function(t,e,r){var n=t.peekStackFrame();return t.pushStack(e),n.waitingReporter=r,this.startThread(t),t.status===o.STATUS_YIELD},n.prototype.proceedThread=function(t){var e=t.peekStack();t.popStack();var r=this.runtime.targetForThread(t).blocks.getNextBlock(e);r&&t.pushStack(r),t.peekStack()||t.setStatus(o.STATUS_DONE)},t.exports=n},function(t,e){function r(){this.startTime=0}r.prototype.time=function(){return Date.now()},r.prototype.start=function(){this.startTime=this.time()},r.prototype.timeElapsed=function(){return this.time()-this.startTime},t.exports=r},function(t,e){function r(t){this.topBlock=t,this.stack=[],this.stackFrames=[],this.status=0}r.STATUS_RUNNING=0,r.STATUS_YIELD=1,r.STATUS_YIELD_FRAME=2,r.STATUS_DONE=3,r.prototype.pushStack=function(t){this.stack.push(t),this.stack.length>this.stackFrames.length&&this.stackFrames.push({reported:{},waitingReporter:null,executionContext:{}})},r.prototype.popStack=function(){return this.stackFrames.pop(),this.stack.pop()},r.prototype.peekStack=function(){return this.stack[this.stack.length-1]},r.prototype.peekStackFrame=function(){return this.stackFrames[this.stackFrames.length-1]},r.prototype.peekParentStackFrame=function(){return this.stackFrames[this.stackFrames.length-2]},r.prototype.pushReportedValue=function(t){var e=this.peekParentStackFrame();if(e){var r=e.waitingReporter;e.reported[r]=t,e.waitingReporter=null}},r.prototype.setStatus=function(t){this.status=t},t.exports=r},function(t,e,r){var n=r(64),i=function(t,e){var r=t.runtime,i=r.targetForThread(e),o=e.peekStack(),s=e.peekStackFrame(),a=i.blocks.getOpcode(o);if(!a)return void console.warn("Could not get opcode for block: "+o);var c=r.getOpcodeFunction(a);if(!c)return void console.warn("Could not get implementation for opcode: "+a);var u={},h=i.blocks.getFields(o);for(var l in h)u[l]=h[l].value;var p=i.blocks.getInputs(o);for(var f in p){var d=p[f],g=d.block;if("undefined"==typeof s.reported[f]){var _=t.stepToReporter(e,g,f);if(_)return}u[f]=s.reported[f]}s.reported={};var m=null;m=c(u,{"yield":function(){e.setStatus(n.STATUS_YIELD)},yieldFrame:function(){e.setStatus(n.STATUS_YIELD_FRAME)},done:function(){e.setStatus(n.STATUS_RUNNING),t.proceedThread(e)},stackFrame:s.executionContext,startBranch:function(r){t.stepToBranch(e,r)},target:i,ioQuery:function(t,e,n){if(r.ioDevices[t]&&r.ioDevices[t][e]){var i=r.ioDevices[t];return i[e].call(i,n)}}});var b=m&&m.then&&"function"==typeof m.then;b?(e.status===n.STATUS_RUNNING&&e.setStatus(n.STATUS_YIELD),m.then(function(i){e.pushReportedValue(i),"undefined"!=typeof i&&e.peekStack()===e.topBlock&&r.visualReport(e.peekStack(),i),e.setStatus(n.STATUS_RUNNING),t.proceedThread(e)},function(r){console.warn("Primitive rejected promise: ",r),e.setStatus(n.STATUS_RUNNING),t.proceedThread(e)})):e.status===n.STATUS_RUNNING&&(e.pushReportedValue(m),"undefined"!=typeof m&&e.peekStack()===e.topBlock&&r.visualReport(e.peekStack(),m))};t.exports=i},function(t,e,r){function n(){this._projectTimer=new i,this._projectTimer.start()}var i=r(63);n.prototype.projectTimer=function(){return this._projectTimer.timeElapsed()/1e3},n.prototype.resetProjectTimer=function(){this._projectTimer.start()},t.exports=n},function(t,e,r){function n(){this._x=0,this._y=0,this._isDown=!1}var i=r(8);n.prototype.postData=function(t){t.x&&(this._x=t.x),t.y&&(this._y=t.y),"undefined"!=typeof t.isDown&&(this._isDown=t.isDown)},n.prototype.getX=function(){return i.clamp(this._x,-240,240)},n.prototype.getY=function(){return i.clamp(-this._y,-180,180)},n.prototype.getIsDown=function(){return this._isDown},t.exports=n},function(t,e,r){function n(t){this.runtime=t}var i=r(69);n.prototype.getPrimitives=function(){return{control_repeat:this.repeat,control_repeat_until:this.repeatUntil,control_forever:this.forever,control_wait:this.wait,control_if:this["if"],control_if_else:this.ifElse,control_stop:this.stop}},n.prototype.repeat=function(t,e){void 0===e.stackFrame.loopCounter&&(e.stackFrame.loopCounter=parseInt(t.TIMES)),e.stackFrame.executedInFrame?(e.stackFrame.executedInFrame=!1,e.yieldFrame()):(e.stackFrame.executedInFrame=!0,e.stackFrame.loopCounter--,e.stackFrame.loopCounter>=0&&e.startBranch())},n.prototype.repeatUntil=function(t,e){e.stackFrame.executedInFrame?(e.stackFrame.executedInFrame=!1,e.yieldFrame()):(e.stackFrame.executedInFrame=!0,t.CONDITION||e.startBranch())},n.prototype.forever=function(t,e){e.stackFrame.executedInFrame?(e.stackFrame.executedInFrame=!1,e.yieldFrame()):(e.stackFrame.executedInFrame=!0,e.startBranch())},n.prototype.wait=function(t){return new i(function(e){setTimeout(function(){e()},1e3*t.DURATION)})},n.prototype["if"]=function(t,e){void 0===e.stackFrame.executedInFrame&&(e.stackFrame.executedInFrame=!0,t.CONDITION&&e.startBranch())},n.prototype.ifElse=function(t,e){void 0===e.stackFrame.executedInFrame&&(e.stackFrame.executedInFrame=!0,t.CONDITION?e.startBranch(1):e.startBranch(2))},n.prototype.stop=function(){this.runtime.stopAll()},t.exports=n},function(t,e,r){"use strict";t.exports=r(70)},function(t,e,r){"use strict";t.exports=r(71),r(73),r(74),r(75),r(76),r(78)},function(t,e,r){"use strict";function n(){}function i(t){try{return t.then}catch(e){return m=e,b}}function o(t,e){try{return t(e)}catch(r){return m=r,b}}function s(t,e,r){try{t(e,r)}catch(n){return m=n,b}}function a(t){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._45=0,this._81=0,this._65=null,this._54=null,t!==n&&g(t,this)}function c(t,e,r){return new t.constructor(function(i,o){var s=new a(n);s.then(i,o),u(t,new d(e,r,s))})}function u(t,e){for(;3===t._81;)t=t._65;return a._10&&a._10(t),0===t._81?0===t._45?(t._45=1,void(t._54=e)):1===t._45?(t._45=2,void(t._54=[t._54,e])):void t._54.push(e):void h(t,e)}function h(t,e){_(function(){var r=1===t._81?e.onFulfilled:e.onRejected;if(null===r)return void(1===t._81?l(e.promise,t._65):p(e.promise,t._65));var n=o(r,t._65);n===b?p(e.promise,m):l(e.promise,n)})}function l(t,e){if(e===t)return p(t,new TypeError("A promise cannot be resolved with itself."));if(e&&("object"==typeof e||"function"==typeof e)){var r=i(e);if(r===b)return p(t,m);if(r===t.then&&e instanceof a)return t._81=3,t._65=e,void f(t);if("function"==typeof r)return void g(r.bind(e),t)}t._81=1,t._65=e,f(t)}function p(t,e){t._81=2,t._65=e,a._97&&a._97(t,e),f(t)}function f(t){if(1===t._45&&(u(t,t._54),t._54=null),2===t._45){for(var e=0;e<t._54.length;e++)u(t,t._54[e]);t._54=null}}function d(t,e,r){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.promise=r}function g(t,e){var r=!1,n=s(t,function(t){r||(r=!0,l(e,t))},function(t){r||(r=!0,p(e,t))});r||n!==b||(r=!0,p(e,m))}var _=r(72),m=null,b={};t.exports=a,a._10=null,a._97=null,a._61=n,a.prototype.then=function(t,e){if(this.constructor!==a)return c(this,t,e);var r=new a(n);return u(this,new d(t,e,r)),r}},function(t,e){(function(e){"use strict";function r(t){a.length||(s(),c=!0),a[a.length]=t}function n(){for(;u<a.length;){var t=u;if(u+=1,a[t].call(),u>h){for(var e=0,r=a.length-u;r>e;e++)a[e]=a[e+u];a.length-=u,u=0}}a.length=0,u=0,c=!1}function i(t){var e=1,r=new l(t),n=document.createTextNode("");return r.observe(n,{characterData:!0}),function(){e=-e,n.data=e}}function o(t){return function(){function e(){clearTimeout(r),clearInterval(n),t()}var r=setTimeout(e,0),n=setInterval(e,50)}}t.exports=r;var s,a=[],c=!1,u=0,h=1024,l=e.MutationObserver||e.WebKitMutationObserver;s="function"==typeof l?i(n):o(n),r.requestFlush=s,r.makeRequestCallFromTimer=o}).call(e,function(){return this}())},function(t,e,r){"use strict";var n=r(71);t.exports=n,n.prototype.done=function(t,e){var r=arguments.length?this.then.apply(this,arguments):this;r.then(null,function(t){setTimeout(function(){throw t},0)})}},function(t,e,r){"use strict";var n=r(71);t.exports=n,n.prototype["finally"]=function(t){return this.then(function(e){return n.resolve(t()).then(function(){return e})},function(e){return n.resolve(t()).then(function(){throw e})})}},function(t,e,r){"use strict";function n(t){var e=new i(i._61);return e._81=1,e._65=t,e}var i=r(71);t.exports=i;var o=n(!0),s=n(!1),a=n(null),c=n(void 0),u=n(0),h=n("");i.resolve=function(t){if(t instanceof i)return t;if(null===t)return a;if(void 0===t)return c;if(t===!0)return o;if(t===!1)return s;if(0===t)return u;if(""===t)return h;if("object"==typeof t||"function"==typeof t)try{var e=t.then;if("function"==typeof e)return new i(e.bind(t))}catch(r){return new i(function(t,e){e(r)})}return n(t)},i.all=function(t){var e=Array.prototype.slice.call(t);return new i(function(t,r){function n(s,a){if(a&&("object"==typeof a||"function"==typeof a)){if(a instanceof i&&a.then===i.prototype.then){for(;3===a._81;)a=a._65;return 1===a._81?n(s,a._65):(2===a._81&&r(a._65),void a.then(function(t){n(s,t)},r))}var c=a.then;if("function"==typeof c){var u=new i(c.bind(a));return void u.then(function(t){n(s,t)},r)}}e[s]=a,0===--o&&t(e)}if(0===e.length)return t([]);for(var o=e.length,s=0;s<e.length;s++)n(s,e[s])})},i.reject=function(t){return new i(function(e,r){r(t)})},i.race=function(t){return new i(function(e,r){t.forEach(function(t){i.resolve(t).then(e,r)})})},i.prototype["catch"]=function(t){return this.then(null,t)}},function(t,e,r){"use strict";function n(t,e){for(var r=[],n=0;e>n;n++)r.push("a"+n);var i=["return function ("+r.join(",")+") {","var self = this;","return new Promise(function (rs, rj) {","var res = fn.call(",["self"].concat(r).concat([a]).join(","),");","if (res &&",'(typeof res === "object" || typeof res === "function") &&','typeof res.then === "function"',") {rs(res);}","});","};"].join("");return Function(["Promise","fn"],i)(o,t)}function i(t){for(var e=Math.max(t.length-1,3),r=[],n=0;e>n;n++)r.push("a"+n);var i=["return function ("+r.join(",")+") {","var self = this;","var args;","var argLength = arguments.length;","if (arguments.length > "+e+") {","args = new Array(arguments.length + 1);","for (var i = 0; i < arguments.length; i++) {","args[i] = arguments[i];","}","}","return new Promise(function (rs, rj) {","var cb = "+a+";","var res;","switch (argLength) {",r.concat(["extra"]).map(function(t,e){return"case "+e+":res = fn.call("+["self"].concat(r.slice(0,e)).concat("cb").join(",")+");break;"}).join(""),"default:","args[argLength] = cb;","res = fn.apply(self, args);","}","if (res &&",'(typeof res === "object" || typeof res === "function") &&','typeof res.then === "function"',") {rs(res);}","});","};"].join("");return Function(["Promise","fn"],i)(o,t)}var o=r(71),s=r(77);t.exports=o,o.denodeify=function(t,e){return"number"==typeof e&&e!==1/0?n(t,e):i(t)};var a="function (err, res) {if (err) { rj(err); } else { rs(res); }}";o.nodeify=function(t){return function(){var e=Array.prototype.slice.call(arguments),r="function"==typeof e[e.length-1]?e.pop():null,n=this;try{return t.apply(this,arguments).nodeify(r,n)}catch(i){if(null===r||"undefined"==typeof r)return new o(function(t,e){e(i)});s(function(){r.call(n,i)})}}},o.prototype.nodeify=function(t,e){return"function"!=typeof t?this:void this.then(function(r){s(function(){t.call(e,null,r)})},function(r){s(function(){t.call(e,r)})})}},function(t,e,r){"use strict";function n(){if(c.length)throw c.shift()}function i(t){var e;e=a.length?a.pop():new o,e.task=t,s(e)}function o(){this.task=null}var s=r(72),a=[],c=[],u=s.makeRequestCallFromTimer(n);t.exports=i,o.prototype.call=function(){try{this.task.call()}catch(t){i.onerror?i.onerror(t):(c.push(t),u())}finally{this.task=null,a[a.length]=this}}},function(t,e,r){"use strict";var n=r(71);t.exports=n,n.enableSynchronous=function(){n.prototype.isPending=function(){return 0==this.getState()},n.prototype.isFulfilled=function(){return 1==this.getState()},n.prototype.isRejected=function(){return 2==this.getState()},n.prototype.getValue=function(){if(3===this._81)return this._65.getValue();if(!this.isFulfilled())throw new Error("Cannot get a value of an unfulfilled promise.");return this._65},n.prototype.getReason=function(){if(3===this._81)return this._65.getReason();if(!this.isRejected())throw new Error("Cannot get a rejection reason of a non-rejected promise.");return this._65},n.prototype.getState=function(){return 3===this._81?this._65.getState():-1===this._81||-2===this._81?0:this._81}},n.disableSynchronous=function(){n.prototype.isPending=void 0,n.prototype.isFulfilled=void 0,n.prototype.isRejected=void 0,n.prototype.getValue=void 0,n.prototype.getReason=void 0,n.prototype.getState=void 0}},function(t,e){function r(t){this.runtime=t}r.prototype.getPrimitives=function(){return{event_whenflagclicked:this.whenFlagClicked,event_whenbroadcastreceived:this.whenBroadcastReceived,event_broadcast:this.broadcast}},r.prototype.whenFlagClicked=function(){},r.prototype.whenBroadcastReceived=function(){},r.prototype.broadcast=function(){},t.exports=r},function(t,e){function r(t){this.runtime=t}r.prototype.getPrimitives=function(){return{looks_say:this.say,looks_sayforsecs:this.sayforsecs,looks_think:this.think,looks_thinkforsecs:this.sayforsecs,looks_show:this.show,looks_hide:this.hide,looks_effectmenu:this.effectMenu,looks_changeeffectby:this.changeEffect,looks_seteffectto:this.setEffect,looks_cleargraphiceffects:this.clearEffects,looks_changesizeby:this.changeSize,looks_setsizeto:this.setSize,looks_size:this.getSize}},r.prototype.say=function(t,e){e.target.setSay("say",t.MESSAGE)},r.prototype.sayforsecs=function(t,e){return e.target.setSay("say",t.MESSAGE),new Promise(function(r){setTimeout(function(){e.target.setSay(),r()},1e3*t.SECS)})},r.prototype.think=function(t,e){e.target.setSay("think",t.MESSAGE)},r.prototype.thinkforsecs=function(t,e){return e.target.setSay("think",t.MESSAGE),new Promise(function(r){setTimeout(function(){e.target.setSay(),r()},1e3*t.SECS)})},r.prototype.show=function(t,e){e.target.setVisible(!0)},r.prototype.hide=function(t,e){e.target.setVisible(!1)},r.prototype.effectMenu=function(t){return t.EFFECT.toLowerCase()},r.prototype.changeEffect=function(t,e){var r=t.CHANGE+e.target.effects[t.EFFECT];e.target.setEffect(t.EFFECT,r)},r.prototype.setEffect=function(t,e){e.target.setEffect(t.EFFECT,t.VALUE)},r.prototype.clearEffects=function(t,e){e.target.clearEffects()},r.prototype.changeSize=function(t,e){e.target.setSize(e.target.size+t.CHANGE)},r.prototype.setSize=function(t,e){e.target.setSize(t.SIZE)},r.prototype.getSize=function(t,e){return e.target.size},t.exports=r},function(t,e,r){function n(t){this.runtime=t}var i=r(8);n.prototype.getPrimitives=function(){return{motion_movesteps:this.moveSteps,motion_gotoxy:this.goToXY,motion_turnright:this.turnRight,motion_turnleft:this.turnLeft,motion_pointindirection:this.pointInDirection,motion_changexby:this.changeX,motion_setx:this.setX,motion_changeyby:this.changeY,motion_sety:this.setY,motion_xposition:this.getX,motion_yposition:this.getY,motion_direction:this.getDirection}},n.prototype.moveSteps=function(t,e){var r=i.degToRad(e.target.direction),n=t.STEPS*Math.cos(r),o=t.STEPS*Math.sin(r);e.target.setXY(e.target.x+n,e.target.y+o)},n.prototype.goToXY=function(t,e){e.target.setXY(t.X,t.Y)},n.prototype.turnRight=function(t,e){e.target.setDirection(e.target.direction+t.DEGREES)},n.prototype.turnLeft=function(t,e){e.target.setDirection(e.target.direction-t.DEGREES)},n.prototype.pointInDirection=function(t,e){e.target.setDirection(t.DIRECTION)},n.prototype.changeX=function(t,e){e.target.setXY(e.target.x+t.DX,e.target.y)},n.prototype.setX=function(t,e){e.target.setXY(t.X,e.target.y)},n.prototype.changeY=function(t,e){e.target.setXY(e.target.x,e.target.y+t.DY)},n.prototype.setY=function(t,e){e.target.setXY(e.target.x,t.Y)},n.prototype.getX=function(t,e){return e.target.x},n.prototype.getY=function(t,e){return e.target.y},n.prototype.getDirection=function(t,e){return e.target.direction},t.exports=n},function(t,e,r){function n(t){this.runtime=t}var i=r(83);n.prototype.getPrimitives=function(){return{math_number:this.number,math_positive_number:this.number,math_whole_number:this.number,math_angle:this.number,text:this.text,operator_add:this.add,operator_subtract:this.subtract,operator_multiply:this.multiply,operator_divide:this.divide,operator_lt:this.lt,operator_equals:this.equals,operator_gt:this.gt,operator_and:this.and,operator_or:this.or,operator_not:this.not,operator_random:this.random,operator_join:this.join,operator_letter_of:this.letterOf,operator_length:this.length,operator_mod:this.mod,operator_round:this.round,operator_mathop_menu:this.mathopMenu,operator_mathop:this.mathop}},n.prototype.number=function(t){return i.toNumber(t.NUM)},n.prototype.text=function(t){return i.toString(t.TEXT)},n.prototype.add=function(t){return i.toNumber(t.NUM1)+i.toNumber(t.NUM2)},n.prototype.subtract=function(t){return i.toNumber(t.NUM1)-i.toNumber(t.NUM2)},n.prototype.multiply=function(t){return i.toNumber(t.NUM1)*i.toNumber(t.NUM2)},n.prototype.divide=function(t){return i.toNumber(t.NUM1)/i.toNumber(t.NUM2)},n.prototype.lt=function(t){return i.compare(t.OPERAND1,t.OPERAND2)<0},n.prototype.equals=function(t){return 0==i.compare(t.OPERAND1,t.OPERAND2)},n.prototype.gt=function(t){return i.compare(t.OPERAND1,t.OPERAND2)>0},n.prototype.and=function(t){return i.toBoolean(t.OPERAND1&&t.OPERAND2)},n.prototype.or=function(t){return i.toBoolean(t.OPERAND1||t.OPERAND2)},n.prototype.not=function(t){return i.toBoolean(!t.OPERAND)},n.prototype.random=function(t){var e=t.FROM<=t.TO?t.FROM:t.TO,r=t.FROM<=t.TO?t.TO:t.FROM;if(e==r)return e;var n=e==parseInt(e),i=r==parseInt(r);return n&&i?e+parseInt(Math.random()*(r+1-e)):Math.random()*(r-e)+e},n.prototype.join=function(t){return i.toString(t.STRING1)+i.toString(t.STRING2)},n.prototype.letterOf=function(t){var e=i.toNumber(t.LETTER)-1,r=i.toString(t.STRING);return 0>e||e>=r.length?"":r.charAt(e)},n.prototype.length=function(t){return i.toString(t.STRING).length},n.prototype.mod=function(t){var e=i.toNumber(t.NUM1),r=i.toNumber(t.NUM2),n=e%r;return 0>n/r&&(n+=r),n},n.prototype.round=function(t){return Math.round(i.toNumber(t.NUM))},n.prototype.mathopMenu=function(t){return t.OPERATOR},n.prototype.mathop=function(t){var e=i.toString(t.OPERATOR).toLowerCase(),r=i.toNumber(t.NUM);switch(e){case"abs":return Math.abs(r);case"floor":return Math.floor(r);case"ceiling":return Math.ceil(r);case"sqrt":return Math.sqrt(r);case"sin":return Math.sin(Math.PI*r/180);case"cos":return Math.cos(Math.PI*r/180);case"tan":return Math.tan(Math.PI*r/180);case"asin":return 180*Math.asin(r)/Math.PI;case"acos":return 180*Math.acos(r)/Math.PI;case"atan":return 180*Math.atan(r)/Math.PI;case"ln":return Math.log(r);case"log":return Math.log(r)/Math.LN10;case"e ^":return Math.exp(r);case"10 ^":return Math.pow(10,r)}return 0},t.exports=n},function(t,e){function r(){}r.toNumber=function(t){var e=Number(t);return isNaN(e)?0:e},r.toBoolean=function(t){return"boolean"==typeof t?t:"string"==typeof t?""!=t&&"0"!=t&&"false"!=t.toLowerCase():Boolean(t)},r.toString=function(t){return String(t)},r.compare=function(t,e){var r=Number(t),n=Number(e);if(isNaN(r)||isNaN(n)){var i=String(t).toLowerCase(),o=String(e).toLowerCase();return i.localeCompare(o)}return r-n},t.exports=r},function(t,e){function r(t){this.runtime=t}r.prototype.getPrimitives=function(){return{sensing_timer:this.getTimer,sensing_resettimer:this.resetTimer,sensing_mousex:this.getMouseX,sensing_mousey:this.getMouseY,sensing_mousedown:this.getMouseDown}},r.prototype.getTimer=function(t,e){return e.ioQuery("clock","projectTimer")},r.prototype.resetTimer=function(t,e){e.ioQuery("clock","resetProjectTimer")},r.prototype.getMouseX=function(t,e){return e.ioQuery("mouse","getX")},r.prototype.getMouseY=function(t,e){ -return e.ioQuery("mouse","getY")},r.prototype.getMouseDown=function(t,e){return e.ioQuery("mouse","getIsDown")},t.exports=r}]); \ No newline at end of file +"use strict";function i(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(e){return!1}}function o(){return t.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function s(e,r){if(o()<r)throw new RangeError("Invalid typed array length");return t.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(r),e.__proto__=t.prototype):(null===e&&(e=new t(r)),e.length=r),e}function t(e,r,n){if(!(t.TYPED_ARRAY_SUPPORT||this instanceof t))return new t(e,r,n);if("number"==typeof e){if("string"==typeof r)throw new Error("If encoding is specified then the first argument must be a string");return p(this,e)}return a(this,e,r,n)}function a(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?f(t,e,r,n):"string"==typeof e?h(t,e,r):d(t,e)}function u(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function c(t,e,r,n){return u(e),e<=0?s(t,e):void 0!==r?"string"==typeof n?s(t,e).fill(r,n):s(t,e).fill(r):s(t,e)}function p(e,r){if(u(r),e=s(e,r<0?0:0|g(r)),!t.TYPED_ARRAY_SUPPORT)for(var n=0;n<r;++n)e[n]=0;return e}function h(e,r,n){if("string"==typeof n&&""!==n||(n="utf8"),!t.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var i=0|_(r,n);e=s(e,i);var o=e.write(r,n);return o!==i&&(e=e.slice(0,o)),e}function l(t,e){var r=e.length<0?0:0|g(e.length);t=s(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function f(e,r,n,i){if(r.byteLength,n<0||r.byteLength<n)throw new RangeError("'offset' is out of bounds");if(r.byteLength<n+(i||0))throw new RangeError("'length' is out of bounds");return r=void 0===n&&void 0===i?new Uint8Array(r):void 0===i?new Uint8Array(r,n):new Uint8Array(r,n,i),t.TYPED_ARRAY_SUPPORT?(e=r,e.__proto__=t.prototype):e=l(e,r),e}function d(e,r){if(t.isBuffer(r)){var n=0|g(r.length);return e=s(e,n),0===e.length?e:(r.copy(e,0,0,n),e)}if(r){if("undefined"!=typeof ArrayBuffer&&r.buffer instanceof ArrayBuffer||"length"in r)return"number"!=typeof r.length||Q(r.length)?s(e,0):l(e,r);if("Buffer"===r.type&&$(r.data))return l(e,r.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function g(t){if(t>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function m(e){return+e!=e&&(e=0),t.alloc(+e)}function _(e,r){if(t.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var i=!1;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return Y(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return W(e).length;default:if(i)return Y(e).length;r=(""+r).toLowerCase(),i=!0}}function y(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if(r>>>=0,e>>>=0,r<=e)return"";for(t||(t="utf8");;)switch(t){case"hex":return R(this,e,r);case"utf8":case"utf-8":return A(this,e,r);case"ascii":return M(this,e,r);case"latin1":case"binary":return L(this,e,r);case"base64":return O(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return D(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function b(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(e,r,n,i,o){if(0===e.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof r&&(r=t.from(r,i)),t.isBuffer(r))return 0===r.length?-1:w(e,r,n,i,o);if("number"==typeof r)return r=255&r,t.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,r,n):Uint8Array.prototype.lastIndexOf.call(e,r,n):w(e,[r],n,i,o);throw new TypeError("val must be string, number or Buffer")}function w(t,e,r,n,i){function o(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}var s=1,a=t.length,u=e.length;if(void 0!==n&&(n=String(n).toLowerCase(),"ucs2"===n||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}var c;if(i){var p=-1;for(c=r;c<a;c++)if(o(t,c)===o(e,p===-1?0:c-p)){if(p===-1&&(p=c),c-p+1===u)return p*s}else p!==-1&&(c-=c-p),p=-1}else for(r+u>a&&(r=a-u),c=r;c>=0;c--){for(var h=!0,l=0;l<u;l++)if(o(t,c+l)!==o(e,l)){h=!1;break}if(h)return c}return-1}function S(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var o=e.length;if(o%2!==0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s<n;++s){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))return s;t[r+s]=a}return s}function k(t,e,r,n){return K(Y(e,t.length-r),t,r,n)}function T(t,e,r,n){return K(z(e),t,r,n)}function E(t,e,r,n){return T(t,e,r,n)}function x(t,e,r,n){return K(W(e),t,r,n)}function N(t,e,r,n){return K(X(e,t.length-r),t,r,n)}function O(t,e,r){return 0===e&&r===t.length?J.fromByteArray(t):J.fromByteArray(t.slice(e,r))}function A(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i<r;){var o=t[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(i+a<=r){var u,c,p,h;switch(a){case 1:o<128&&(s=o);break;case 2:u=t[i+1],128===(192&u)&&(h=(31&o)<<6|63&u,h>127&&(s=h));break;case 3:u=t[i+1],c=t[i+2],128===(192&u)&&128===(192&c)&&(h=(15&o)<<12|(63&u)<<6|63&c,h>2047&&(h<55296||h>57343)&&(s=h));break;case 4:u=t[i+1],c=t[i+2],p=t[i+3],128===(192&u)&&128===(192&c)&&128===(192&p)&&(h=(15&o)<<18|(63&u)<<12|(63&c)<<6|63&p,h>65535&&h<1114112&&(s=h))}}null===s?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),i+=a}return C(n)}function C(t){var e=t.length;if(e<=tt)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=tt));return r}function M(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function L(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function R(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=e;o<r;++o)i+=H(t[o]);return i}function D(t,e,r){for(var n=t.slice(e,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function I(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function B(e,r,n,i,o,s){if(!t.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>o||r<s)throw new RangeError('"value" argument is out of bounds');if(n+i>e.length)throw new RangeError("Index out of range")}function P(t,e,r,n){e<0&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-r,2);i<o;++i)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function U(t,e,r,n){e<0&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-r,4);i<o;++i)t[r+i]=e>>>8*(n?i:3-i)&255}function q(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function F(t,e,r,n,i){return i||q(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),Z.write(t,e,r,n,23,4),r+4}function j(t,e,r,n,i){return i||q(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),Z.write(t,e,r,n,52,8),r+8}function G(t){if(t=V(t).replace(et,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function V(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function H(t){return t<16?"0"+t.toString(16):t.toString(16)}function Y(t,e){e=e||1/0;for(var r,n=t.length,i=null,o=[],s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function z(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}function X(t,e){for(var r,n,i,o=[],s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function W(t){return J.toByteArray(G(t))}function K(t,e,r,n){for(var i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function Q(t){return t!==t}var J=r(56),Z=r(57),$=r(58);e.Buffer=t,e.SlowBuffer=m,e.INSPECT_MAX_BYTES=50,t.TYPED_ARRAY_SUPPORT=void 0!==n.TYPED_ARRAY_SUPPORT?n.TYPED_ARRAY_SUPPORT:i(),e.kMaxLength=o(),t.poolSize=8192,t._augment=function(e){return e.__proto__=t.prototype,e},t.from=function(t,e,r){return a(null,t,e,r)},t.TYPED_ARRAY_SUPPORT&&(t.prototype.__proto__=Uint8Array.prototype,t.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&t[Symbol.species]===t&&Object.defineProperty(t,Symbol.species,{value:null,configurable:!0})),t.alloc=function(t,e,r){return c(null,t,e,r)},t.allocUnsafe=function(t){return p(null,t)},t.allocUnsafeSlow=function(t){return p(null,t)},t.isBuffer=function(t){return!(null==t||!t._isBuffer)},t.compare=function(e,r){if(!t.isBuffer(e)||!t.isBuffer(r))throw new TypeError("Arguments must be Buffers");if(e===r)return 0;for(var n=e.length,i=r.length,o=0,s=Math.min(n,i);o<s;++o)if(e[o]!==r[o]){n=e[o],i=r[o];break}return n<i?-1:i<n?1:0},t.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},t.concat=function(e,r){if(!$(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return t.alloc(0);var n;if(void 0===r)for(r=0,n=0;n<e.length;++n)r+=e[n].length;var i=t.allocUnsafe(r),o=0;for(n=0;n<e.length;++n){var s=e[n];if(!t.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(i,o),o+=s.length}return i},t.byteLength=_,t.prototype._isBuffer=!0,t.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)b(this,e,e+1);return this},t.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)b(this,e,e+3),b(this,e+1,e+2);return this},t.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)b(this,e,e+7),b(this,e+1,e+6),b(this,e+2,e+5),b(this,e+3,e+4);return this},t.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?A(this,0,t):y.apply(this,arguments)},t.prototype.equals=function(e){if(!t.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===t.compare(this,e)},t.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},t.prototype.compare=function(e,r,n,i,o){if(!t.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===n&&(n=e?e.length:0),void 0===i&&(i=0),void 0===o&&(o=this.length),r<0||n>e.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===e)return 0;for(var s=o-i,a=n-r,u=Math.min(s,a),c=this.slice(i,o),p=e.slice(r,n),h=0;h<u;++h)if(c[h]!==p[h]){s=c[h],a=p[h];break}return s<a?-1:a<s?1:0},t.prototype.includes=function(t,e,r){return this.indexOf(t,e,r)!==-1},t.prototype.indexOf=function(t,e,r){return v(this,t,e,r,!0)},t.prototype.lastIndexOf=function(t,e,r){return v(this,t,e,r,!1)},t.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e=0|e,isFinite(r)?(r=0|r,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return S(this,t,e,r);case"utf8":case"utf-8":return k(this,t,e,r);case"ascii":return T(this,t,e,r);case"latin1":case"binary":return E(this,t,e,r);case"base64":return x(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},t.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var tt=4096;t.prototype.slice=function(e,r){var n=this.length;e=~~e,r=void 0===r?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);var i;if(t.TYPED_ARRAY_SUPPORT)i=this.subarray(e,r),i.__proto__=t.prototype;else{var o=r-e;i=new t(o,(void 0));for(var s=0;s<o;++s)i[s]=this[s+e]}return i},t.prototype.readUIntLE=function(t,e,r){t=0|t,e=0|e,r||I(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return n},t.prototype.readUIntBE=function(t,e,r){t=0|t,e=0|e,r||I(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},t.prototype.readUInt8=function(t,e){return e||I(t,1,this.length),this[t]},t.prototype.readUInt16LE=function(t,e){return e||I(t,2,this.length),this[t]|this[t+1]<<8},t.prototype.readUInt16BE=function(t,e){return e||I(t,2,this.length),this[t]<<8|this[t+1]},t.prototype.readUInt32LE=function(t,e){return e||I(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},t.prototype.readUInt32BE=function(t,e){return e||I(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},t.prototype.readIntLE=function(t,e,r){t=0|t,e=0|e,r||I(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},t.prototype.readIntBE=function(t,e,r){t=0|t,e=0|e,r||I(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},t.prototype.readInt8=function(t,e){return e||I(t,1,this.length),128&this[t]?(255-this[t]+1)*-1:this[t]},t.prototype.readInt16LE=function(t,e){e||I(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},t.prototype.readInt16BE=function(t,e){e||I(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},t.prototype.readInt32LE=function(t,e){return e||I(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},t.prototype.readInt32BE=function(t,e){return e||I(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},t.prototype.readFloatLE=function(t,e){return e||I(t,4,this.length),Z.read(this,t,!0,23,4)},t.prototype.readFloatBE=function(t,e){return e||I(t,4,this.length),Z.read(this,t,!1,23,4)},t.prototype.readDoubleLE=function(t,e){return e||I(t,8,this.length),Z.read(this,t,!0,52,8)},t.prototype.readDoubleBE=function(t,e){return e||I(t,8,this.length),Z.read(this,t,!1,52,8)},t.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e=0|e,r=0|r,!n){var i=Math.pow(2,8*r)-1;B(this,t,e,r,i,0)}var o=1,s=0;for(this[e]=255&t;++s<r&&(o*=256);)this[e+s]=t/o&255;return e+r},t.prototype.writeUIntBE=function(t,e,r,n){if(t=+t,e=0|e,r=0|r,!n){var i=Math.pow(2,8*r)-1;B(this,t,e,r,i,0)}var o=r-1,s=1;for(this[e+o]=255&t;--o>=0&&(s*=256);)this[e+o]=t/s&255;return e+r},t.prototype.writeUInt8=function(e,r,n){return e=+e,r=0|r,n||B(this,e,r,1,255,0),t.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[r]=255&e,r+1},t.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=0|r,n||B(this,e,r,2,65535,0),t.TYPED_ARRAY_SUPPORT?(this[r]=255&e,this[r+1]=e>>>8):P(this,e,r,!0),r+2},t.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=0|r,n||B(this,e,r,2,65535,0),t.TYPED_ARRAY_SUPPORT?(this[r]=e>>>8,this[r+1]=255&e):P(this,e,r,!1),r+2},t.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=0|r,n||B(this,e,r,4,4294967295,0),t.TYPED_ARRAY_SUPPORT?(this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=255&e):U(this,e,r,!0),r+4},t.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=0|r,n||B(this,e,r,4,4294967295,0),t.TYPED_ARRAY_SUPPORT?(this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=255&e):U(this,e,r,!1),r+4},t.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);B(this,t,e,r,i-1,-i)}var o=0,s=1,a=0;for(this[e]=255&t;++o<r&&(s*=256);)t<0&&0===a&&0!==this[e+o-1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r},t.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);B(this,t,e,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r},t.prototype.writeInt8=function(e,r,n){return e=+e,r=0|r,n||B(this,e,r,1,127,-128),t.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[r]=255&e,r+1},t.prototype.writeInt16LE=function(e,r,n){return e=+e,r=0|r,n||B(this,e,r,2,32767,-32768),t.TYPED_ARRAY_SUPPORT?(this[r]=255&e,this[r+1]=e>>>8):P(this,e,r,!0),r+2},t.prototype.writeInt16BE=function(e,r,n){return e=+e,r=0|r,n||B(this,e,r,2,32767,-32768),t.TYPED_ARRAY_SUPPORT?(this[r]=e>>>8,this[r+1]=255&e):P(this,e,r,!1),r+2},t.prototype.writeInt32LE=function(e,r,n){return e=+e,r=0|r,n||B(this,e,r,4,2147483647,-2147483648),t.TYPED_ARRAY_SUPPORT?(this[r]=255&e,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24):U(this,e,r,!0),r+4},t.prototype.writeInt32BE=function(e,r,n){return e=+e,r=0|r,n||B(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),t.TYPED_ARRAY_SUPPORT?(this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=255&e):U(this,e,r,!1),r+4},t.prototype.writeFloatLE=function(t,e,r){return F(this,t,e,!0,r)},t.prototype.writeFloatBE=function(t,e,r){return F(this,t,e,!1,r)},t.prototype.writeDoubleLE=function(t,e,r){return j(this,t,e,!0,r)},t.prototype.writeDoubleBE=function(t,e,r){return j(this,t,e,!1,r)},t.prototype.copy=function(e,r,n,i){if(n||(n=0),i||0===i||(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===n)return 0;if(0===e.length||0===this.length)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);var o,s=i-n;if(this===e&&n<r&&r<i)for(o=s-1;o>=0;--o)e[o+r]=this[o+n];else if(s<1e3||!t.TYPED_ARRAY_SUPPORT)for(o=0;o<s;++o)e[o+r]=this[o+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+s),r);return s},t.prototype.fill=function(e,r,n,i){if("string"==typeof e){if("string"==typeof r?(i=r,r=0,n=this.length):"string"==typeof n&&(i=n,n=this.length),1===e.length){var o=e.charCodeAt(0);o<256&&(e=o)}if(void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!t.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else"number"==typeof e&&(e=255&e);if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0);var s;if("number"==typeof e)for(s=r;s<n;++s)this[s]=e;else{var a=t.isBuffer(e)?e:Y(new t(e,i).toString()),u=a.length;for(s=0;s<n-r;++s)this[s+r]=a[s%u]}return this};var et=/[^+\/0-9A-Za-z-_]/g}).call(e,r(55).Buffer,function(){return this}())},function(t,e){"use strict";function r(){for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,r=t.length;e<r;++e)a[e]=t[e],u[t.charCodeAt(e)]=e;u["-".charCodeAt(0)]=62,u["_".charCodeAt(0)]=63}function n(t){var e,r,n,i,o,s,a=t.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===t[a-2]?2:"="===t[a-1]?1:0,s=new c(3*a/4-o),n=o>0?a-4:a;var p=0;for(e=0,r=0;e<n;e+=4,r+=3)i=u[t.charCodeAt(e)]<<18|u[t.charCodeAt(e+1)]<<12|u[t.charCodeAt(e+2)]<<6|u[t.charCodeAt(e+3)],s[p++]=i>>16&255,s[p++]=i>>8&255,s[p++]=255&i;return 2===o?(i=u[t.charCodeAt(e)]<<2|u[t.charCodeAt(e+1)]>>4,s[p++]=255&i):1===o&&(i=u[t.charCodeAt(e)]<<10|u[t.charCodeAt(e+1)]<<4|u[t.charCodeAt(e+2)]>>2,s[p++]=i>>8&255,s[p++]=255&i),s}function i(t){return a[t>>18&63]+a[t>>12&63]+a[t>>6&63]+a[63&t]}function o(t,e,r){for(var n,o=[],s=e;s<r;s+=3)n=(t[s]<<16)+(t[s+1]<<8)+t[s+2],o.push(i(n));return o.join("")}function s(t){for(var e,r=t.length,n=r%3,i="",s=[],u=16383,c=0,p=r-n;c<p;c+=u)s.push(o(t,c,c+u>p?p:c+u));return 1===n?(e=t[r-1],i+=a[e>>2],i+=a[e<<4&63],i+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],i+=a[e>>10],i+=a[e>>4&63],i+=a[e<<2&63],i+="="),s.push(i),s.join("")}e.toByteArray=n,e.fromByteArray=s;var a=[],u=[],c="undefined"!=typeof Uint8Array?Uint8Array:Array;r()},function(t,e){e.read=function(t,e,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,c=u>>1,p=-7,h=r?i-1:0,l=r?-1:1,f=t[e+h];for(h+=l,o=f&(1<<-p)-1,f>>=-p,p+=a;p>0;o=256*o+t[e+h],h+=l,p-=8);for(s=o&(1<<-p)-1,o>>=-p,p+=n;p>0;s=256*s+t[e+h],h+=l,p-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:(f?-1:1)*(1/0);s+=Math.pow(2,n),o-=c}return(f?-1:1)*s*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var s,a,u,c=8*o-i-1,p=(1<<c)-1,h=p>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:o-1,d=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=p):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),e+=s+h>=1?l/u:l*Math.pow(2,1-h),e*u>=2&&(s++,u/=2),s+h>=p?(a=0,s=p):s+h>=1?(a=(e*u-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+f]=255&a,f+=d,a/=256,i-=8);for(s=s<<i|a,c+=i;c>0;t[r+f]=255&s,f+=d,s/=256,c-=8);t[r+f-d]|=128*g}},function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,e,r){(function(t){function r(t){return Array.isArray?Array.isArray(t):"[object Array]"===m(t)}function n(t){return"boolean"==typeof t}function i(t){return null===t}function o(t){return null==t}function s(t){return"number"==typeof t}function a(t){return"string"==typeof t}function u(t){return"symbol"==typeof t}function c(t){return void 0===t}function p(t){return"[object RegExp]"===m(t)}function h(t){return"object"==typeof t&&null!==t}function l(t){return"[object Date]"===m(t)}function f(t){return"[object Error]"===m(t)||t instanceof Error}function d(t){return"function"==typeof t}function g(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||"undefined"==typeof t}function m(t){return Object.prototype.toString.call(t)}e.isArray=r,e.isBoolean=n,e.isNull=i,e.isNullOrUndefined=o,e.isNumber=s,e.isString=a,e.isSymbol=u,e.isUndefined=c,e.isRegExp=p,e.isObject=h,e.isDate=l,e.isError=f,e.isFunction=d,e.isPrimitive=g,e.isBuffer=t.isBuffer}).call(e,r(55).Buffer)},function(t,e){},function(t,e,r){(function(e){function n(t){return this instanceof n?(u.call(this,t),c.call(this,t),t&&t.readable===!1&&(this.readable=!1),t&&t.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,t&&t.allowHalfOpen===!1&&(this.allowHalfOpen=!1),void this.once("end",i)):new n(t)}function i(){this.allowHalfOpen||this._writableState.ended||e.nextTick(this.end.bind(this))}function o(t,e){for(var r=0,n=t.length;r<n;r++)e(t[r],r)}t.exports=n;var s=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e},a=r(59);a.inherits=r(5);var u=r(53),c=r(62);a.inherits(n,u),o(s(c.prototype),function(t){n.prototype[t]||(n.prototype[t]=c.prototype[t])})}).call(e,r(3))},function(t,e,r){(function(e){function n(t,e,r){this.chunk=t,this.encoding=e,this.callback=r}function i(t,e){var n=r(61);t=t||{};var i=t.highWaterMark,o=t.objectMode?16:16384;this.highWaterMark=i||0===i?i:o,this.objectMode=!!t.objectMode,e instanceof n&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var s=t.decodeStrings===!1;this.decodeStrings=!s,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){f(e,t)},this.writecb=null,this.writelen=0,this.buffer=[],this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1}function o(t){var e=r(61);return this instanceof o||this instanceof e?(this._writableState=new i(t,this),this.writable=!0,void k.call(this)):new o(t)}function s(t,r,n){var i=new Error("write after end");t.emit("error",i),e.nextTick(function(){n(i)})}function a(t,r,n,i){var o=!0;if(!(S.isBuffer(n)||S.isString(n)||S.isNullOrUndefined(n)||r.objectMode)){var s=new TypeError("Invalid non-string/buffer chunk");t.emit("error",s),e.nextTick(function(){i(s)}),o=!1}return o}function u(t,e,r){return!t.objectMode&&t.decodeStrings!==!1&&S.isString(e)&&(e=new w(e,r)),e}function c(t,e,r,i,o){r=u(e,r,i),S.isBuffer(r)&&(i="buffer");var s=e.objectMode?1:r.length;e.length+=s;var a=e.length<e.highWaterMark;return a||(e.needDrain=!0),e.writing||e.corked?e.buffer.push(new n(r,i,o)):p(t,e,!1,s,r,i,o),a}function p(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function h(t,r,n,i,o){n?e.nextTick(function(){r.pendingcb--,o(i)}):(r.pendingcb--,o(i)),t._writableState.errorEmitted=!0,t.emit("error",i)}function l(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}function f(t,r){var n=t._writableState,i=n.sync,o=n.writecb;if(l(n),r)h(t,n,i,r,o);else{var s=_(t,n);s||n.corked||n.bufferProcessing||!n.buffer.length||m(t,n),i?e.nextTick(function(){d(t,n,s,o)}):d(t,n,s,o)}}function d(t,e,r,n){r||g(t,e),e.pendingcb--,n(),b(t,e)}function g(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}function m(t,e){if(e.bufferProcessing=!0,t._writev&&e.buffer.length>1){for(var r=[],n=0;n<e.buffer.length;n++)r.push(e.buffer[n].callback);e.pendingcb++,p(t,e,!0,e.length,e.buffer,"",function(t){for(var n=0;n<r.length;n++)e.pendingcb--,r[n](t)}),e.buffer=[]}else{for(var n=0;n<e.buffer.length;n++){var i=e.buffer[n],o=i.chunk,s=i.encoding,a=i.callback,u=e.objectMode?1:o.length;if(p(t,e,!1,u,o,s,a),e.writing){n++;break}}n<e.buffer.length?e.buffer=e.buffer.slice(n):e.buffer.length=0}e.bufferProcessing=!1}function _(t,e){return e.ending&&0===e.length&&!e.finished&&!e.writing}function y(t,e){e.prefinished||(e.prefinished=!0,t.emit("prefinish"))}function b(t,e){var r=_(t,e);return r&&(0===e.pendingcb?(y(t,e),e.finished=!0,t.emit("finish")):y(t,e)),r}function v(t,r,n){r.ending=!0,b(t,r),n&&(r.finished?e.nextTick(n):t.once("finish",n)),r.ended=!0}t.exports=o;var w=r(55).Buffer;o.WritableState=i;var S=r(59);S.inherits=r(5);var k=r(51);S.inherits(o,k),o.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))},o.prototype.write=function(t,e,r){var n=this._writableState,i=!1;return S.isFunction(e)&&(r=e,e=null),S.isBuffer(t)?e="buffer":e||(e=n.defaultEncoding),S.isFunction(r)||(r=function(){}),n.ended?s(this,n,r):a(this,n,t,r)&&(n.pendingcb++,i=c(this,n,t,e,r)),i},o.prototype.cork=function(){var t=this._writableState;t.corked++},o.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.finished||t.bufferProcessing||!t.buffer.length||m(this,t))},o.prototype._write=function(t,e,r){r(new Error("not implemented"))},o.prototype._writev=null,o.prototype.end=function(t,e,r){var n=this._writableState;S.isFunction(t)?(r=t,t=null,e=null):S.isFunction(e)&&(r=e,e=null),S.isNullOrUndefined(t)||this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||v(this,n,r)}}).call(e,r(3))},function(t,e,r){function n(t){if(t&&!u(t))throw new Error("Unknown encoding: "+t)}function i(t){return t.toString(this.encoding)}function o(t){this.charReceived=t.length%2,this.charLength=this.charReceived?2:0}function s(t){this.charReceived=t.length%3,this.charLength=this.charReceived?3:0}var a=r(55).Buffer,u=a.isEncoding||function(t){switch(t&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}},c=e.StringDecoder=function(t){switch(this.encoding=(t||"utf8").toLowerCase().replace(/[-_]/,""),n(t),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=o;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=s;break;default:return void(this.write=i)}this.charBuffer=new a(6),this.charReceived=0,this.charLength=0};c.prototype.write=function(t){for(var e="";this.charLength;){var r=t.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:t.length;if(t.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived<this.charLength)return"";t=t.slice(r,t.length),e=this.charBuffer.slice(0,this.charLength).toString(this.encoding);var n=e.charCodeAt(e.length-1);if(!(n>=55296&&n<=56319)){if(this.charReceived=this.charLength=0,0===t.length)return e;break}this.charLength+=this.surrogateSize,e=""}this.detectIncompleteChar(t);var i=t.length;this.charLength&&(t.copy(this.charBuffer,0,t.length-this.charReceived,i),i-=this.charReceived),e+=t.toString(this.encoding,0,i);var i=e.length-1,n=e.charCodeAt(i);if(n>=55296&&n<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),t.copy(this.charBuffer,0,0,o),e.substring(0,i)}return e},c.prototype.detectIncompleteChar=function(t){for(var e=t.length>=3?3:t.length;e>0;e--){var r=t[t.length-e];if(1==e&&r>>5==6){this.charLength=2;break}if(e<=2&&r>>4==14){this.charLength=3;break}if(e<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=e},c.prototype.end=function(t){var e="";if(t&&t.length&&(e=this.write(t)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;e+=n.slice(0,r).toString(i)}return e}},function(t,e,r){function n(t,e){this.afterTransform=function(t,r){return i(e,t,r)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null}function i(t,e,r){var n=t._transformState;n.transforming=!1;var i=n.writecb;if(!i)return t.emit("error",new Error("no writecb in Transform class"));n.writechunk=null,n.writecb=null,u.isNullOrUndefined(r)||t.push(r),i&&i(e);var o=t._readableState;o.reading=!1,(o.needReadable||o.length<o.highWaterMark)&&t._read(o.highWaterMark)}function o(t){if(!(this instanceof o))return new o(t);a.call(this,t),this._transformState=new n(t,this);var e=this;this._readableState.needReadable=!0,this._readableState.sync=!1,this.once("prefinish",function(){u.isFunction(this._flush)?this._flush(function(t){s(e,t)}):s(e)})}function s(t,e){if(e)return t.emit("error",e);var r=t._writableState,n=t._transformState;if(r.length)throw new Error("calling transform done when ws.length != 0");if(n.transforming)throw new Error("calling transform done when still transforming");return t.push(null)}t.exports=o;var a=r(61),u=r(59);u.inherits=r(5),u.inherits(o,a),o.prototype.push=function(t,e){return this._transformState.needTransform=!1,a.prototype.push.call(this,t,e)},o.prototype._transform=function(t,e,r){throw new Error("not implemented")},o.prototype._write=function(t,e,r){var n=this._transformState;if(n.writecb=r,n.writechunk=t,n.writeencoding=e,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},o.prototype._read=function(t){var e=this._transformState;u.isNull(e.writechunk)||!e.writecb||e.transforming?e.needTransform=!0:(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform)); +}},function(t,e,r){function n(t){return this instanceof n?void i.call(this,t):new n(t)}t.exports=n;var i=r(64),o=r(59);o.inherits=r(5),o.inherits(n,i),n.prototype._transform=function(t,e,r){r(null,t)}},function(t,e,r){t.exports=r(62)},function(t,e,r){t.exports=r(61)},function(t,e,r){t.exports=r(64)},function(t,e,r){t.exports=r(65)},function(t,e){},function(t,e,r){function n(t){this._cbs=t||{}}t.exports=n;var i=r(36).EVENTS;Object.keys(i).forEach(function(t){if(0===i[t])t="on"+t,n.prototype[t]=function(){this._cbs[t]&&this._cbs[t]()};else if(1===i[t])t="on"+t,n.prototype[t]=function(e){this._cbs[t]&&this._cbs[t](e)};else{if(2!==i[t])throw Error("wrong number of arguments");t="on"+t,n.prototype[t]=function(e,r){this._cbs[t]&&this._cbs[t](e,r)}}})},function(t,e,r){var n=t.exports;[r(73),r(79),r(80),r(81),r(82),r(83)].forEach(function(t){Object.keys(t).forEach(function(e){n[e]=t[e].bind(n)})})},function(t,e,r){function n(t,e){return t.children?t.children.map(function(t){return s(t,e)}).join(""):""}function i(t){return Array.isArray(t)?t.map(i).join(""):a(t)||t.type===o.CDATA?i(t.children):t.type===o.Text?t.data:""}var o=r(45),s=r(74),a=o.isTag;t.exports={getInnerHTML:n,getOuterHTML:s,getText:i}},function(t,e,r){function n(t,e){if(t){var r,n="";for(var i in t)r=t[i],n&&(n+=" "),n+=!r&&h[i]?i:i+'="'+(e.decodeEntities?p.encodeXML(r):r)+'"';return n}}function i(t,e){"svg"===t.name&&(e={decodeEntities:e.decodeEntities,xmlMode:!0});var r="<"+t.name,i=n(t.attribs,e);return i&&(r+=" "+i),!e.xmlMode||t.children&&0!==t.children.length?(r+=">",t.children&&(r+=d(t.children,e)),f[t.name]&&!e.xmlMode||(r+="</"+t.name+">")):r+="/>",r}function o(t){return"<"+t.data+">"}function s(t,e){var r=t.data||"";return!e.decodeEntities||t.parent&&t.parent.name in l||(r=p.encodeXML(r)),r}function a(t){return"<![CDATA["+t.children[0].data+"]]>"}function u(t){return"<!--"+t.data+"-->"}var c=r(75),p=r(76),h={__proto__:null,allowfullscreen:!0,async:!0,autofocus:!0,autoplay:!0,checked:!0,controls:!0,"default":!0,defer:!0,disabled:!0,hidden:!0,ismap:!0,loop:!0,multiple:!0,muted:!0,open:!0,readonly:!0,required:!0,reversed:!0,scoped:!0,seamless:!0,selected:!0,typemustmatch:!0},l={__proto__:null,style:!0,script:!0,xmp:!0,iframe:!0,noembed:!0,noframes:!0,plaintext:!0,noscript:!0},f={__proto__:null,area:!0,base:!0,basefont:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,isindex:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},d=t.exports=function(t,e){Array.isArray(t)||t.cheerio||(t=[t]),e=e||{};for(var r="",n=0;n<t.length;n++){var p=t[n];r+="root"===p.type?d(p.children,e):c.isTag(p)?i(p,e):p.type===c.Directive?o(p):p.type===c.Comment?u(p):p.type===c.CDATA?a(p):s(p,e)}return r}},function(t,e){t.exports={Text:"text",Directive:"directive",Comment:"comment",Script:"script",Style:"style",Tag:"tag",CDATA:"cdata",isTag:function(t){return"tag"===t.type||"script"===t.type||"style"===t.type}}},function(t,e,r){var n=r(77),i=r(78);e.decode=function(t,e){return(!e||e<=0?i.XML:i.HTML)(t)},e.decodeStrict=function(t,e){return(!e||e<=0?i.XML:i.HTMLStrict)(t)},e.encode=function(t,e){return(!e||e<=0?n.XML:n.HTML)(t)},e.encodeXML=n.XML,e.encodeHTML4=e.encodeHTML5=e.encodeHTML=n.HTML,e.decodeXML=e.decodeXMLStrict=i.XML,e.decodeHTML4=e.decodeHTML5=e.decodeHTML=i.HTML,e.decodeHTML4Strict=e.decodeHTML5Strict=e.decodeHTMLStrict=i.HTMLStrict,e.escape=n.escape},function(t,e,r){function n(t){return Object.keys(t).sort().reduce(function(e,r){return e[t[r]]="&"+r+";",e},{})}function i(t){var e=[],r=[];return Object.keys(t).forEach(function(t){1===t.length?e.push("\\"+t):r.push(t)}),r.unshift("["+e.join("")+"]"),new RegExp(r.join("|"),"g")}function o(t){return"&#x"+t.charCodeAt(0).toString(16).toUpperCase()+";"}function s(t){var e=t.charCodeAt(0),r=t.charCodeAt(1),n=1024*(e-55296)+r-56320+65536;return"&#x"+n.toString(16).toUpperCase()+";"}function a(t,e){function r(e){return t[e]}return function(t){return t.replace(e,r).replace(d,s).replace(f,o)}}function u(t){return t.replace(g,o).replace(d,s).replace(f,o)}var c=n(r(43)),p=i(c);e.XML=a(c,p);var h=n(r(41)),l=i(h);e.HTML=a(h,l);var f=/[^\0-\x7F]/g,d=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,g=i(c);e.escape=u},function(t,e,r){function n(t){var e=Object.keys(t).join("|"),r=o(t);e+="|#[xX][\\da-fA-F]+|#\\d+";var n=new RegExp("&(?:"+e+");","g");return function(t){return String(t).replace(n,r)}}function i(t,e){return t<e?1:-1}function o(t){return function(e){return"#"===e.charAt(1)?c("X"===e.charAt(2)||"x"===e.charAt(2)?parseInt(e.substr(3),16):parseInt(e.substr(2),10)):t[e.slice(1,-1)]}}var s=r(41),a=r(42),u=r(43),c=r(39),p=n(u),h=n(s),l=function(){function t(t){return";"!==t.substr(-1)&&(t+=";"),p(t)}for(var e=Object.keys(a).sort(i),r=Object.keys(s).sort(i),n=0,u=0;n<r.length;n++)e[u]===r[n]?(r[n]+=";?",u++):r[n]+=";";var c=new RegExp("&(?:"+r.join("|")+"|#[xX][\\da-fA-F]+;?|#\\d+;?)","g"),p=o(s);return function(e){return String(e).replace(c,t)}}();t.exports={XML:p,HTML:l,HTMLStrict:h}},function(t,e){var r=e.getChildren=function(t){return t.children},n=e.getParent=function(t){return t.parent};e.getSiblings=function(t){var e=n(t);return e?r(e):[t]},e.getAttributeValue=function(t,e){return t.attribs&&t.attribs[e]},e.hasAttrib=function(t,e){return!!t.attribs&&hasOwnProperty.call(t.attribs,e)},e.getName=function(t){return t.name}},function(t,e){e.removeElement=function(t){if(t.prev&&(t.prev.next=t.next),t.next&&(t.next.prev=t.prev),t.parent){var e=t.parent.children;e.splice(e.lastIndexOf(t),1)}},e.replaceElement=function(t,e){var r=e.prev=t.prev;r&&(r.next=e);var n=e.next=t.next;n&&(n.prev=e);var i=e.parent=t.parent;if(i){var o=i.children;o[o.lastIndexOf(t)]=e}},e.appendChild=function(t,e){if(e.parent=t,1!==t.children.push(e)){var r=t.children[t.children.length-2];r.next=e,e.prev=r,e.next=null}},e.append=function(t,e){var r=t.parent,n=t.next;if(e.next=n,e.prev=t,t.next=e,e.parent=r,n){if(n.prev=e,r){var i=r.children;i.splice(i.lastIndexOf(n),0,e)}}else r&&r.children.push(e)},e.prepend=function(t,e){var r=t.parent;if(r){var n=r.children;n.splice(n.lastIndexOf(t),0,e)}t.prev&&(t.prev.next=e),e.parent=r,e.prev=t.prev,e.next=t,t.prev=e}},function(t,e,r){function n(t,e,r,n){return Array.isArray(e)||(e=[e]),"number"==typeof n&&isFinite(n)||(n=1/0),i(t,e,r!==!1,n)}function i(t,e,r,n){for(var o,s=[],a=0,u=e.length;a<u&&!(t(e[a])&&(s.push(e[a]),--n<=0))&&(o=e[a].children,!(r&&o&&o.length>0&&(o=i(t,o,r,n),s=s.concat(o),n-=o.length,n<=0)));a++);return s}function o(t,e){for(var r=0,n=e.length;r<n;r++)if(t(e[r]))return e[r];return null}function s(t,e){for(var r=null,n=0,i=e.length;n<i&&!r;n++)c(e[n])&&(t(e[n])?r=e[n]:e[n].children.length>0&&(r=s(t,e[n].children)));return r}function a(t,e){for(var r=0,n=e.length;r<n;r++)if(c(e[r])&&(t(e[r])||e[r].children.length>0&&a(t,e[r].children)))return!0;return!1}function u(t,e){for(var r=[],n=0,i=e.length;n<i;n++)c(e[n])&&(t(e[n])&&r.push(e[n]),e[n].children.length>0&&(r=r.concat(u(t,e[n].children))));return r}var c=r(45).isTag;t.exports={filter:n,find:i,findOneChild:o,findOne:s,existsOne:a,findAll:u}},function(t,e,r){function n(t,e){return"function"==typeof e?function(r){return r.attribs&&e(r.attribs[t])}:function(r){return r.attribs&&r.attribs[t]===e}}function i(t,e){return function(r){return t(r)||e(r)}}var o=r(45),s=e.isTag=o.isTag;e.testElement=function(t,e){for(var r in t)if(t.hasOwnProperty(r)){if("tag_name"===r){if(!s(e)||!t.tag_name(e.name))return!1}else if("tag_type"===r){if(!t.tag_type(e.type))return!1}else if("tag_contains"===r){if(s(e)||!t.tag_contains(e.data))return!1}else if(!e.attribs||!t[r](e.attribs[r]))return!1}else;return!0};var a={tag_name:function(t){return"function"==typeof t?function(e){return s(e)&&t(e.name)}:"*"===t?s:function(e){return s(e)&&e.name===t}},tag_type:function(t){return"function"==typeof t?function(e){return t(e.type)}:function(e){return e.type===t}},tag_contains:function(t){return"function"==typeof t?function(e){return!s(e)&&t(e.data)}:function(e){return!s(e)&&e.data===t}}};e.getElements=function(t,e,r,o){var s=Object.keys(t).map(function(e){var r=t[e];return e in a?a[e](r):n(e,r)});return 0===s.length?[]:this.filter(s.reduce(i),e,r,o)},e.getElementById=function(t,e,r){return Array.isArray(e)||(e=[e]),this.findOne(n("id",t),e,r!==!1)},e.getElementsByTagName=function(t,e,r,n){return this.filter(a.tag_name(t),e,r,n)},e.getElementsByTagType=function(t,e,r,n){return this.filter(a.tag_type(t),e,r,n)}},function(t,e){e.removeSubsets=function(t){for(var e,r,n,i=t.length;--i>-1;){for(e=r=t[i],t[i]=null,n=!0;r;){if(t.indexOf(r)>-1){n=!1,t.splice(i,1);break}r=r.parent}n&&(t[i]=e)}return t};var r={DISCONNECTED:1,PRECEDING:2,FOLLOWING:4,CONTAINS:8,CONTAINED_BY:16},n=e.compareDocumentPosition=function(t,e){var n,i,o,s,a,u,c=[],p=[];if(t===e)return 0;for(n=t;n;)c.unshift(n),n=n.parent;for(n=e;n;)p.unshift(n),n=n.parent;for(u=0;c[u]===p[u];)u++;return 0===u?r.DISCONNECTED:(i=c[u-1],o=i.children,s=c[u],a=p[u],o.indexOf(s)>o.indexOf(a)?i===e?r.FOLLOWING|r.CONTAINED_BY:r.FOLLOWING:i===t?r.PRECEDING|r.CONTAINS:r.PRECEDING)};e.uniqueSort=function(t){var e,i,o=t.length;for(t=t.slice();--o>-1;)e=t[o],i=t.indexOf(e),i>-1&&i<o&&t.splice(o,1);return t.sort(function(t,e){var i=n(t,e);return i&r.PRECEDING?-1:i&r.FOLLOWING?1:0}),t}},function(t,e,r){function n(t){this._cbs=t||{},this.events=[]}t.exports=n;var i=r(36).EVENTS;Object.keys(i).forEach(function(t){if(0===i[t])t="on"+t,n.prototype[t]=function(){this.events.push([t]),this._cbs[t]&&this._cbs[t]()};else if(1===i[t])t="on"+t,n.prototype[t]=function(e){this.events.push([t,e]),this._cbs[t]&&this._cbs[t](e)};else{if(2!==i[t])throw Error("wrong number of arguments");t="on"+t,n.prototype[t]=function(e,r){this.events.push([t,e,r]),this._cbs[t]&&this._cbs[t](e,r)}}}),n.prototype.onreset=function(){this.events=[],this._cbs.onreset&&this._cbs.onreset()},n.prototype.restart=function(){this._cbs.onreset&&this._cbs.onreset();for(var t=0,e=this.events.length;t<e;t++)if(this._cbs[this.events[t][0]]){var r=this.events[t].length;1===r?this._cbs[this.events[t][0]]():2===r?this._cbs[this.events[t][0]](this.events[t][1]):this._cbs[this.events[t][0]](this.events[t][1],this.events[t][2])}}},function(t,e,r){function n(t){t||(t=new o),this.blocks=t,this.name="",this.costumes=[],this.clones=[]}var i=r(86),o=r(34);n.prototype.createClone=function(){var t=new i(this);return this.clones.push(t),t},t.exports=n},function(t,e,r){function n(t){s.call(this,t.blocks),this.sprite=t,this.renderer=null,"undefined"!=typeof self&&self.renderer&&(this.renderer=self.renderer),this.drawableID=null,this.initDrawable()}var i=r(2),o=r(16),s=r(87);i.inherits(n,s),n.prototype.initDrawable=function(){if(this.renderer){var t=this.renderer.createDrawable(),e=this;t.then(function(t){e.drawableID=t,e.updateAllDrawableProperties()})}},n.prototype.isStage=!1,n.prototype.x=0,n.prototype.y=0,n.prototype.direction=90,n.prototype.visible=!0,n.prototype.size=100,n.prototype.currentCostume=0,n.prototype.effects={color:0,fisheye:0,whirl:0,pixelate:0,mosaic:0,brightness:0,ghost:0},n.prototype.setXY=function(t,e){this.isStage||(this.x=t,this.y=e,this.renderer&&this.renderer.updateDrawableProperties(this.drawableID,{position:[this.x,this.y]}))},n.prototype.setDirection=function(t){this.isStage||(this.direction=o.wrapClamp(t,-179,180),this.renderer&&this.renderer.updateDrawableProperties(this.drawableID,{direction:this.direction}))},n.prototype.setSay=function(t,e){if(!this.isStage)return t&&e?void console.log("Setting say bubble:",t,e):void console.log("Clearing say bubble")},n.prototype.setVisible=function(t){this.isStage||(this.visible=t,this.renderer&&this.renderer.updateDrawableProperties(this.drawableID,{visible:this.visible}))},n.prototype.setSize=function(t){this.isStage||(this.size=o.clamp(t,5,535),this.renderer&&this.renderer.updateDrawableProperties(this.drawableID,{scale:[this.size,this.size]}))},n.prototype.setEffect=function(t,e){if(this.effects.hasOwnProperty(t)&&(this.effects[t]=e,this.renderer)){var r={};r[t]=this.effects[t],this.renderer.updateDrawableProperties(this.drawableID,r)}},n.prototype.clearEffects=function(){for(var t in this.effects)this.effects[t]=0;this.renderer&&this.renderer.updateDrawableProperties(this.drawableID,this.effects)},n.prototype.setCostume=function(t){this.currentCostume=o.wrapClamp(t,0,this.sprite.costumes.length-1),this.renderer&&this.renderer.updateDrawableProperties(this.drawableID,{skin:this.sprite.costumes[this.currentCostume].skin})},n.prototype.getCostumeIndexByName=function(t){for(var e=0;e<this.sprite.costumes.length;e++)if(this.sprite.costumes[e].name==t)return e;return-1},n.prototype.updateAllDrawableProperties=function(){this.renderer&&this.renderer.updateDrawableProperties(this.drawableID,{position:[this.x,this.y],direction:this.direction,scale:[this.size,this.size],visible:this.visible,skin:this.sprite.costumes[this.currentCostume].skin})},n.prototype.getName=function(){return this.sprite.name},n.prototype.isTouchingColor=function(t){return!!this.renderer&&this.renderer.isTouchingColor(this.drawableID,t)},n.prototype.colorIsTouchingColor=function(t,e){return!!this.renderer&&this.renderer.isTouchingColor(this.drawableID,t,e)},t.exports=n},function(t,e,r){function n(t){t||(t=new i(this)),this.id=o(),this.blocks=t}var i=r(34),o=r(88);n.prototype.getName=function(){return this.id},t.exports=n},function(t,e){var r="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=function(){for(var t=20,e=r.length,n=[],i=0;i<t;i++)n[i]=r.charAt(Math.random()*e);return n.join("")};t.exports=n},function(t,e){var r={"forward:":{opcode:"motion_movesteps",argMap:[{type:"input",inputOp:"math_number",inputName:"STEPS"}]},"turnRight:":{opcode:"motion_turnright",argMap:[{type:"input",inputOp:"math_number",inputName:"DEGREES"}]},"turnLeft:":{opcode:"motion_turnleft",argMap:[{type:"input",inputOp:"math_number",inputName:"DEGREES"}]},"heading:":{opcode:"motion_pointindirection",argMap:[{type:"input",inputOp:"math_angle",inputName:"DIRECTION"}]},"pointTowards:":{opcode:"motion_pointtowards",argMap:[{type:"input",inputOp:"motion_pointtowards_menu",inputName:"TOWARDS"}]},"gotoX:y:":{opcode:"motion_gotoxy",argMap:[{type:"input",inputOp:"math_number",inputName:"X"},{type:"input",inputOp:"math_number",inputName:"Y"}]},"gotoSpriteOrMouse:":{opcode:"motion_goto",argMap:[{type:"input",inputOp:"motion_goto_menu",inputName:"TO"}]},"glideSecs:toX:y:elapsed:from:":{opcode:"motion_glidesecstoxy",argMap:[{type:"input",inputOp:"math_number",inputName:"SECS"},{type:"input",inputOp:"math_number",inputName:"X"},{type:"input",inputOp:"math_number",inputName:"Y"}]},"changeXposBy:":{opcode:"motion_changexby",argMap:[{type:"input",inputOp:"math_number",inputName:"DX"}]},"xpos:":{opcode:"motion_setx",argMap:[{type:"input",inputOp:"math_number",inputName:"X"}]},"changeYposBy:":{opcode:"motion_changeyby",argMap:[{type:"input",inputOp:"math_number",inputName:"DY"}]},"ypos:":{opcode:"motion_sety",argMap:[{type:"input",inputOp:"math_number",inputName:"Y"}]},bounceOffEdge:{opcode:"motion_ifonedgebounce",argMap:[]},setRotationStyle:{opcode:"motion_setrotationstyle",argMap:[{type:"input",inputOp:"motion_setrotationstyle_menu",inputName:"STYLE"}]},xpos:{opcode:"motion_xposition",argMap:[]},ypos:{opcode:"motion_yposition",argMap:[]},heading:{opcode:"motion_direction",argMap:[]},"say:duration:elapsed:from:":{opcode:"looks_sayforsecs",argMap:[{type:"input",inputOp:"text",inputName:"MESSAGE"},{type:"input",inputOp:"math_number",inputName:"SECS"}]},"say:":{opcode:"looks_say",argMap:[{type:"input",inputOp:"text",inputName:"MESSAGE"}]},"think:duration:elapsed:from:":{opcode:"looks_thinkforsecs",argMap:[{type:"input",inputOp:"text",inputName:"MESSAGE"},{type:"input",inputOp:"math_number",inputName:"SECS"}]},"think:":{opcode:"looks_think",argMap:[{type:"input",inputOp:"text",inputName:"MESSAGE"}]},show:{opcode:"looks_show",argMap:[]},hide:{opcode:"looks_hide",argMap:[]},"lookLike:":{opcode:"looks_switchcostumeto",argMap:[{type:"input",inputOp:"looks_costume",inputName:"COSTUME"}]},nextCostume:{opcode:"looks_nextcostume",argMap:[]},startScene:{opcode:"looks_switchbackdropto",argMap:[{type:"input",inputOp:"looks_backdrops",inputName:"BACKDROP"}]},"changeGraphicEffect:by:":{opcode:"looks_changeeffectby",argMap:[{type:"input",inputOp:"looks_effectmenu",inputName:"EFFECT"},{type:"input",inputOp:"math_number",inputName:"CHANGE"}]},"setGraphicEffect:to:":{opcode:"looks_seteffectto",argMap:[{type:"input",inputOp:"looks_effectmenu",inputName:"EFFECT"},{type:"input",inputOp:"math_number",inputName:"VALUE"}]},filterReset:{opcode:"looks_cleargraphiceffects",argMap:[]},"changeSizeBy:":{opcode:"looks_changesizeby",argMap:[{type:"input",inputOp:"math_number",inputName:"CHANGE"}]},"setSizeTo:":{opcode:"looks_setsizeto",argMap:[{type:"input",inputOp:"math_number",inputName:"SIZE"}]},comeToFront:{opcode:"looks_gotofront",argMap:[]},"goBackByLayers:":{opcode:"looks_gobacklayers",argMap:[{type:"input",inputOp:"math_integer",inputName:"NUM"}]},costumeIndex:{opcode:"looks_costumeorder",argMap:[]},sceneName:{opcode:"looks_backdropname",argMap:[]},scale:{opcode:"looks_size",argMap:[]},startSceneAndWait:{opcode:"looks_switchbackdroptoandwait",argMap:[{type:"input",inputOp:"looks_backdrops",inputName:"BACKDROP"}]},nextScene:{opcode:"looks_nextbackdrop",argMap:[]},backgroundIndex:{opcode:"looks_backdroporder",argMap:[]},"playSound:":{opcode:"sound_play",argMap:[{type:"input",inputOp:"sound_sounds_option",inputName:"SOUND_MENU"}]},doPlaySoundAndWait:{opcode:"sound_playuntildone",argMap:[{type:"input",inputOp:"sound_sounds_option",inputName:"SOUND_MENU"}]},stopAllSounds:{opcode:"sound_stopallsounds",argMap:[]},playDrum:{opcode:"sound_playdrumforbeats",argMap:[{type:"input",inputOp:"math_number",inputName:"DRUMTYPE"},{type:"input",inputOp:"math_number",inputName:"BEATS"}]},"rest:elapsed:from:":{opcode:"sound_restforbeats",argMap:[{type:"input",inputOp:"math_number",inputName:"BEATS"}]},"noteOn:duration:elapsed:from:":{opcode:"sound_playnoteforbeats",argMap:[{type:"input",inputOp:"math_number",inputName:"NOTE"},{type:"input",inputOp:"math_number",inputName:"BEATS"}]},"instrument:":{opcode:"sound_setinstrumentto",argMap:[{type:"input",inputOp:"math_number",inputName:"INSTRUMENT"}]},"changeVolumeBy:":{opcode:"sound_changevolumeby",argMap:[{type:"input",inputOp:"math_number",inputName:"VOLUME"}]},"setVolumeTo:":{opcode:"sound_setvolumeto",argMap:[{type:"input",inputOp:"math_number",inputName:"VOLUME"}]},volume:{opcode:"sound_volume",argMap:[]},"changeTempoBy:":{opcode:"sound_changetempoby",argMap:[{type:"input",inputOp:"math_number",inputName:"TEMPO"}]},"setTempoTo:":{opcode:"sound_settempotobpm",argMap:[{type:"input",inputOp:"math_number",inputName:"TEMPO"}]},tempo:{opcode:"sound_tempo",argMap:[]},clearPenTrails:{opcode:"pen_clear",argMap:[]},stampCostume:{opcode:"pen_stamp",argMap:[]},putPenDown:{opcode:"pen_pendown",argMap:[]},putPenUp:{opcode:"pen_penup",argMap:[]},"penColor:":{opcode:"pen_setpencolortocolor",argMap:[{type:"input",inputOp:"colour_picker",inputName:"COLOR"}]},"changePenHueBy:":{opcode:"pen_changepencolorby",argMap:[{type:"input",inputOp:"math_number",inputName:"COLOR"}]},"setPenHueTo:":{opcode:"pen_setpencolortonum",argMap:[{type:"input",inputOp:"math_number",inputName:"COLOR"}]},"changePenShadeBy:":{opcode:"pen_changepenshadeby",argMap:[{type:"input",inputOp:"math_number",inputName:"SHADE"}]},"setPenShadeTo:":{opcode:"pen_changepenshadeby",argMap:[{type:"input",inputOp:"math_number",inputName:"SHADE"}]},"changePenSizeBy:":{opcode:"pen_changepensizeby",argMap:[{type:"input",inputOp:"math_number",inputName:"SIZE"}]},"penSize:":{opcode:"pen_setpensizeto",argMap:[{type:"input",inputOp:"math_number",inputName:"SIZE"}]},whenGreenFlag:{opcode:"event_whenflagclicked",argMap:[]},whenKeyPressed:{opcode:"event_whenkeypressed",argMap:[{type:"field",fieldName:"KEY_OPTION"}]},whenClicked:{opcode:"event_whenthisspriteclicked",argMap:[]},whenSceneStarts:{opcode:"event_whenbackdropswitchesto",argMap:[{type:"field",fieldName:"BACKDROP"}]},whenSensorGreaterThan:{opcode:"event_whengreaterthan",argMap:[{type:"field",fieldName:"WHENGREATERTHANMENU"},{type:"input",inputOp:"math_number",inputName:"VALUE"}]},whenIReceive:{opcode:"event_whenbroadcastreceived",argMap:[{type:"field",fieldName:"BROADCAST_OPTION"}]},"broadcast:":{opcode:"event_broadcast",argMap:[{type:"field",fieldName:"BROADCAST_OPTION"}]},doBroadcastAndWait:{opcode:"event_broadcastandwait",argMap:[{type:"field",fieldName:"BROADCAST_OPTION"}]},"wait:elapsed:from:":{opcode:"control_wait",argMap:[{type:"input",inputOp:"math_positive_number",inputName:"DURATION"}]},doRepeat:{opcode:"control_repeat",argMap:[{type:"input",inputOp:"math_whole_number",inputName:"TIMES"},{type:"input",inputName:"SUBSTACK"}]},doForever:{opcode:"control_forever",argMap:[{type:"input",inputName:"SUBSTACK"}]},doIf:{opcode:"control_if",argMap:[{type:"input",inputName:"CONDITION"},{type:"input",inputName:"SUBSTACK"}]},doIfElse:{opcode:"control_if_else",argMap:[{type:"input",inputName:"CONDITION"},{type:"input",inputName:"SUBSTACK"},{type:"input",inputName:"SUBSTACK2"}]},doWaitUntil:{opcode:"control_wait_until",argMap:[{type:"input",inputName:"CONDITION"}]},doUntil:{opcode:"control_repeat_until",argMap:[{type:"input",inputName:"CONDITION"},{type:"input",inputName:"SUBSTACK"}]},stopScripts:{opcode:"control_stop",argMap:[{type:"input",inputOp:"control_stop_menu",inputName:"STOP_OPTION"}]},whenCloned:{opcode:"control_start_as_clone",argMap:[]},createCloneOf:{opcode:"control_create_clone_of",argMap:[{type:"input",inputOp:"control_create_clone_of_menu",inputName:"CLONE_OPTION"}]},deleteClone:{opcode:"control_delete_this_clone",argMap:[]},"touching:":{opcode:"sensing_touchingobject",argMap:[{type:"input",inputOp:"sensing_touchingobjectmenu",inputName:"TOUCHINGOBJECTMENU"}]},"touchingColor:":{opcode:"sensing_touchingcolor",argMap:[{type:"input",inputOp:"colour_picker",inputName:"COLOR"}]},"color:sees:":{opcode:"sensing_coloristouchingcolor",argMap:[{type:"input",inputOp:"colour_picker",inputName:"COLOR"},{type:"input",inputOp:"colour_picker",inputName:"COLOR2"}]},"distanceTo:":{opcode:"sensing_distanceto",argMap:[{type:"input",inputOp:"sensing_distancetomenu",inputName:"DISTANCETOMENU"}]},doAsk:{opcode:"sensing_askandwait",argMap:[{type:"input",inputOp:"text",inputName:"QUESTION"}]},answer:{opcode:"sensing_answer",argMap:[]},"keyPressed:":{opcode:"sensing_keypressed",argMap:[{type:"input",inputOp:"sensing_keyoptions",inputName:"KEY_OPTION"}]},mousePressed:{opcode:"sensing_mousedown",argMap:[]},mouseX:{opcode:"sensing_mousex",argMap:[]},mouseY:{opcode:"sensing_mousey",argMap:[]},soundLevel:{opcode:"sensing_loudness",argMap:[]},senseVideoMotion:{opcode:"sensing_videoon",argMap:[{type:"input",inputOp:"sensing_videoonmenuone",inputName:"VIDEOONMENU1"},{type:"input",inputOp:"sensing_videoonmenutwo",inputName:"VIDEOONMENU2"}]},setVideoState:{opcode:"sensing_videotoggle",argMap:[{type:"input",inputOp:"sensing_videotogglemenu",inputName:"VIDEOTOGGLEMENU"}]},setVideoTransparency:{opcode:"sensing_setvideotransparency",argMap:[{type:"input",inputOp:"math_number",inputName:"TRANSPARENCY"}]},timer:{opcode:"sensing_timer",argMap:[]},timerReset:{opcode:"sensing_resettimer",argMap:[]},"getAttribute:of:":{opcode:"sensing_of",argMap:[{type:"input",inputOp:"sensing_ofattributemenu",inputName:"ATTRIBUTE"},{type:"input",inputOp:"sensing_ofobjectmenu",inputName:"OBJECT"}]},timeAndDate:{opcode:"sensing_current",argMap:[{type:"input",inputOp:"sensing_currentmenu",inputName:"CURRENTMENU"}]},timestamp:{opcode:"sensing_dayssince2000",argMap:[]},getUserName:{opcode:"sensing_username",argMap:[]},"+":{opcode:"operator_add",argMap:[{type:"input",inputOp:"math_number",inputName:"NUM1"},{type:"input",inputOp:"math_number",inputName:"NUM2"}]},"-":{opcode:"operator_subtract",argMap:[{type:"input",inputOp:"math_number",inputName:"NUM1"},{type:"input",inputOp:"math_number",inputName:"NUM2"}]},"*":{opcode:"operator_multiply",argMap:[{type:"input",inputOp:"math_number",inputName:"NUM1"},{type:"input",inputOp:"math_number",inputName:"NUM2"}]},"/":{opcode:"operator_divide",argMap:[{type:"input",inputOp:"math_number",inputName:"NUM1"},{type:"input",inputOp:"math_number",inputName:"NUM2"}]},"randomFrom:to:":{opcode:"operator_random",argMap:[{type:"input",inputOp:"math_number",inputName:"FROM"},{type:"input",inputOp:"math_number",inputName:"TO"}]},"<":{opcode:"operator_lt",argMap:[{type:"input",inputOp:"text",inputName:"OPERAND1"},{type:"input",inputOp:"text",inputName:"OPERAND2"}]},"=":{opcode:"operator_equals",argMap:[{type:"input",inputOp:"text",inputName:"OPERAND1"},{type:"input",inputOp:"text",inputName:"OPERAND2"}]},">":{opcode:"operator_gt",argMap:[{type:"input",inputOp:"text",inputName:"OPERAND1"},{type:"input",inputOp:"text",inputName:"OPERAND2"}]},"&":{opcode:"operator_and",argMap:[{type:"input",inputName:"OPERAND1"},{type:"input",inputName:"OPERAND2"}]},"|":{opcode:"operator_or",argMap:[{type:"input",inputName:"OPERAND1"},{type:"input",inputName:"OPERAND2"}]},not:{opcode:"operator_not",argMap:[{type:"input",inputName:"OPERAND"}]},"concatenate:with:":{opcode:"operator_join",argMap:[{type:"input",inputOp:"text",inputName:"STRING1"},{type:"input",inputOp:"text",inputName:"STRING2"}]},"letter:of:":{opcode:"operator_letter_of",argMap:[{type:"input",inputOp:"math_whole_number",inputName:"LETTER"},{type:"input",inputOp:"text",inputName:"STRING"}]},"stringLength:":{opcode:"operator_length",argMap:[{type:"input",inputOp:"text",inputName:"STRING"}]},"%":{opcode:"operator_mod",argMap:[{type:"input",inputOp:"math_number",inputName:"NUM1"},{type:"input",inputOp:"math_number",inputName:"NUM2"}]},rounded:{opcode:"operator_round",argMap:[{type:"input",inputOp:"math_number",inputName:"NUM"}]},"computeFunction:of:":{opcode:"operator_mathop",argMap:[{type:"input",inputOp:"operator_mathop_menu",inputName:"OPERATOR"},{type:"input",inputOp:"math_number",inputName:"NUM"}]},readVariable:{opcode:"data_variable",argMap:[{type:"input",inputOp:"data_variablemenu",inputName:"VARIABLE"}]},"setVar:to:":{opcode:"data_setvariableto",argMap:[{type:"input",inputOp:"data_variablemenu",inputName:"VARIABLE"},{type:"input",inputOp:"text",inputName:"VALUE"}]},"changeVar:by:":{opcode:"data_changevariableby",argMap:[{type:"input",inputOp:"data_variablemenu",inputName:"VARIABLE"},{type:"input",inputOp:"math_number",inputName:"VALUE"}]},"showVariable:":{opcode:"data_showvariable",argMap:[{type:"input",inputOp:"data_variablemenu",inputName:"VARIABLE"}]},"hideVariable:":{opcode:"data_hidevariable",argMap:[{type:"input",inputOp:"data_variablemenu",inputName:"VARIABLE"}]},"append:toList:":{opcode:"data_listadd",argMap:[{type:"input",inputOp:"text",inputName:"VALUE"},{type:"field",fieldName:"LIST"}]},"deleteLine:ofList:":{opcode:"data_listdelete",argMap:[{type:"input",inputOp:"text",inputName:"LINE"},{type:"field",fieldName:"LIST"}]},"insert:at:ofList:":{opcode:"data_listinsert",argMap:[{type:"input",inputOp:"text",inputName:"VALUE"},{type:"input",inputOp:"text",inputName:"LINE"},{type:"field",fieldName:"LIST"}]},"setLine:ofList:to:":{opcode:"data_listreplace",argMap:[{type:"input",inputOp:"text",inputName:"LINE"},{type:"field",fieldName:"LIST"},{type:"input",inputOp:"text",inputName:"VALUE"}]},"getLine:ofList:":{opcode:"data_listitem",argMap:[{type:"input",inputOp:"text",inputName:"LINE"},{type:"field",fieldName:"LIST"}]},"lineCountOfList:":{opcode:"data_listlength",argMap:[{type:"field",fieldName:"LIST"}]},"list:contains:":{opcode:"data_listcontains",argMap:[{type:"field",fieldName:"LIST"},{type:"input",inputOp:"text",inputName:"VALUE"}]},"showList:":{opcode:"data_showlist",argMap:[{type:"field",fieldName:"LIST"}]},"hideList:":{opcode:"data_hidelist",argMap:[{type:"field",fieldName:"LIST"}]},procDef:{opcode:"proc_def",argMap:[]},getParam:{opcode:"proc_param",argMap:[]},call:{opcode:"proc_call",argMap:[]}};t.exports=r}]); \ No newline at end of file diff --git a/vm.worker.js b/vm.worker.js deleted file mode 100644 index efdd8771a..000000000 --- a/vm.worker.js +++ /dev/null @@ -1,1169 +0,0 @@ -/******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; - -/******/ // The require function -/******/ function __webpack_require__(moduleId) { - -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) -/******/ return installedModules[moduleId].exports; - -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ exports: {}, -/******/ id: moduleId, -/******/ loaded: false -/******/ }; - -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); - -/******/ // Flag the module as loaded -/******/ module.loaded = true; - -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } - - -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; - -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; - -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; - -/******/ // Load entry module and return exports -/******/ return __webpack_require__(0); -/******/ }) -/************************************************************************/ -/******/ ([ -/* 0 */ -/***/ function(module, exports, __webpack_require__) { - - var EventEmitter = __webpack_require__(1); - var util = __webpack_require__(2); - - function VirtualMachine () { - if (!window.Worker) { - console.error('WebWorkers not supported in this environment.' + - ' Please use the non-worker version (vm.js or vm.min.js).'); - return; - } - var instance = this; - EventEmitter.call(instance); - instance.vmWorker = new Worker('../vm.js'); - - // onmessage calls are converted into emitted events. - instance.vmWorker.onmessage = function (e) { - instance.emit(e.data.method, e.data); - }; - - instance.blockListener = function (e) { - // Messages from Blockly are not serializable by default. - // Pull out the necessary, serializable components to pass across. - var serializableE = { - blockId: e.blockId, - element: e.element, - type: e.type, - name: e.name, - newValue: e.newValue, - oldParentId: e.oldParentId, - oldInputName: e.oldInputName, - newParentId: e.newParentId, - newInputName: e.newInputName, - xml: { - outerHTML: (e.xml) ? e.xml.outerHTML : null - } - }; - instance.vmWorker.postMessage({ - method: 'blockListener', - args: serializableE - }); - }; - } - - /** - * Inherit from EventEmitter - */ - util.inherits(VirtualMachine, EventEmitter); - - // For documentation, please see index.js. - // These mirror the functionality provided there, with the worker wrapper. - VirtualMachine.prototype.getPlaygroundData = function () { - this.vmWorker.postMessage({method: 'getPlaygroundData'}); - }; - - VirtualMachine.prototype.postIOData = function (device, data) { - this.vmWorker.postMessage({ - method: 'postIOData', - device: device, - data: data - }); - }; - - VirtualMachine.prototype.start = function () { - this.vmWorker.postMessage({method: 'start'}); - }; - - VirtualMachine.prototype.greenFlag = function () { - this.vmWorker.postMessage({method: 'greenFlag'}); - }; - - VirtualMachine.prototype.stopAll = function () { - this.vmWorker.postMessage({method: 'stopAll'}); - }; - - VirtualMachine.prototype.animationFrame = function () { - this.vmWorker.postMessage({method: 'animationFrame'}); - }; - - /** - * Export and bind to `window` - */ - module.exports = VirtualMachine; - if (typeof window !== 'undefined') window.VirtualMachine = module.exports; - - -/***/ }, -/* 1 */ -/***/ function(module, exports) { - - // Copyright Joyent, Inc. and other Node contributors. - // - // 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. - - function EventEmitter() { - this._events = this._events || {}; - this._maxListeners = this._maxListeners || undefined; - } - module.exports = EventEmitter; - - // Backwards-compat with node 0.10.x - EventEmitter.EventEmitter = EventEmitter; - - EventEmitter.prototype._events = undefined; - EventEmitter.prototype._maxListeners = undefined; - - // By default EventEmitters will print a warning if more than 10 listeners are - // added to it. This is a useful default which helps finding memory leaks. - EventEmitter.defaultMaxListeners = 10; - - // Obviously not all Emitters should be limited to 10. This function allows - // that to be increased. Set to zero for unlimited. - EventEmitter.prototype.setMaxListeners = function(n) { - if (!isNumber(n) || n < 0 || isNaN(n)) - throw TypeError('n must be a positive number'); - this._maxListeners = n; - return this; - }; - - EventEmitter.prototype.emit = function(type) { - var er, handler, len, args, i, listeners; - - if (!this._events) - this._events = {}; - - // If there is no 'error' event listener then throw. - if (type === 'error') { - if (!this._events.error || - (isObject(this._events.error) && !this._events.error.length)) { - er = arguments[1]; - if (er instanceof Error) { - throw er; // Unhandled 'error' event - } - throw TypeError('Uncaught, unspecified "error" event.'); - } - } - - handler = this._events[type]; - - if (isUndefined(handler)) - return false; - - if (isFunction(handler)) { - switch (arguments.length) { - // fast cases - case 1: - handler.call(this); - break; - case 2: - handler.call(this, arguments[1]); - break; - case 3: - handler.call(this, arguments[1], arguments[2]); - break; - // slower - default: - args = Array.prototype.slice.call(arguments, 1); - handler.apply(this, args); - } - } else if (isObject(handler)) { - args = Array.prototype.slice.call(arguments, 1); - listeners = handler.slice(); - len = listeners.length; - for (i = 0; i < len; i++) - listeners[i].apply(this, args); - } - - return true; - }; - - EventEmitter.prototype.addListener = function(type, listener) { - var m; - - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - if (!this._events) - this._events = {}; - - // To avoid recursion in the case that type === "newListener"! Before - // adding it to the listeners, first emit "newListener". - if (this._events.newListener) - this.emit('newListener', type, - isFunction(listener.listener) ? - listener.listener : listener); - - if (!this._events[type]) - // Optimize the case of one listener. Don't need the extra array object. - this._events[type] = listener; - else if (isObject(this._events[type])) - // If we've already got an array, just append. - this._events[type].push(listener); - else - // Adding the second element, need to change to array. - this._events[type] = [this._events[type], listener]; - - // Check for listener leak - if (isObject(this._events[type]) && !this._events[type].warned) { - if (!isUndefined(this._maxListeners)) { - m = this._maxListeners; - } else { - m = EventEmitter.defaultMaxListeners; - } - - if (m && m > 0 && this._events[type].length > m) { - this._events[type].warned = true; - console.error('(node) warning: possible EventEmitter memory ' + - 'leak detected. %d listeners added. ' + - 'Use emitter.setMaxListeners() to increase limit.', - this._events[type].length); - if (typeof console.trace === 'function') { - // not supported in IE 10 - console.trace(); - } - } - } - - return this; - }; - - EventEmitter.prototype.on = EventEmitter.prototype.addListener; - - EventEmitter.prototype.once = function(type, listener) { - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - var fired = false; - - function g() { - this.removeListener(type, g); - - if (!fired) { - fired = true; - listener.apply(this, arguments); - } - } - - g.listener = listener; - this.on(type, g); - - return this; - }; - - // emits a 'removeListener' event iff the listener was removed - 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; - - list = this._events[type]; - length = list.length; - position = -1; - - if (list === listener || - (isFunction(list.listener) && list.listener === listener)) { - delete this._events[type]; - if (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 (position < 0) - return this; - - if (list.length === 1) { - list.length = 0; - delete this._events[type]; - } else { - list.splice(position, 1); - } - - if (this._events.removeListener) - this.emit('removeListener', type, listener); - } - - return this; - }; - - EventEmitter.prototype.removeAllListeners = function(type) { - var key, listeners; - - if (!this._events) - return this; - - // not listening for removeListener, no need to emit - if (!this._events.removeListener) { - if (arguments.length === 0) - this._events = {}; - else if (this._events[type]) - delete this._events[type]; - return this; - } - - // emit removeListener for all listeners on all events - if (arguments.length === 0) { - for (key in this._events) { - if (key === 'removeListener') continue; - this.removeAllListeners(key); - } - this.removeAllListeners('removeListener'); - this._events = {}; - return this; - } - - listeners = this._events[type]; - - if (isFunction(listeners)) { - this.removeListener(type, listeners); - } else if (listeners) { - // LIFO order - while (listeners.length) - this.removeListener(type, listeners[listeners.length - 1]); - } - delete this._events[type]; - - return this; - }; - - EventEmitter.prototype.listeners = function(type) { - var ret; - if (!this._events || !this._events[type]) - ret = []; - else if (isFunction(this._events[type])) - ret = [this._events[type]]; - else - ret = this._events[type].slice(); - return ret; - }; - - EventEmitter.prototype.listenerCount = function(type) { - if (this._events) { - var evlistener = this._events[type]; - - if (isFunction(evlistener)) - return 1; - else if (evlistener) - return evlistener.length; - } - return 0; - }; - - EventEmitter.listenerCount = function(emitter, type) { - return emitter.listenerCount(type); - }; - - function isFunction(arg) { - return typeof arg === 'function'; - } - - function isNumber(arg) { - return typeof arg === 'number'; - } - - function isObject(arg) { - return typeof arg === 'object' && arg !== null; - } - - function isUndefined(arg) { - return arg === void 0; - } - - -/***/ }, -/* 2 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(global, process) {// Copyright Joyent, Inc. and other Node contributors. - // - // 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. - - var formatRegExp = /%[sdj%]/g; - exports.format = function(f) { - if (!isString(f)) { - var objects = []; - for (var i = 0; i < arguments.length; i++) { - objects.push(inspect(arguments[i])); - } - return objects.join(' '); - } - - var i = 1; - var args = arguments; - var len = args.length; - var str = String(f).replace(formatRegExp, function(x) { - if (x === '%%') return '%'; - if (i >= len) return x; - switch (x) { - case '%s': return String(args[i++]); - case '%d': return Number(args[i++]); - case '%j': - try { - return JSON.stringify(args[i++]); - } catch (_) { - return '[Circular]'; - } - default: - return x; - } - }); - for (var x = args[i]; i < len; x = args[++i]) { - if (isNull(x) || !isObject(x)) { - str += ' ' + x; - } else { - str += ' ' + inspect(x); - } - } - return str; - }; - - - // Mark that a method should not be used. - // Returns a modified function which warns once by default. - // If --no-deprecation is set, then it is a no-op. - exports.deprecate = function(fn, msg) { - // Allow for deprecating things in the process of starting up. - if (isUndefined(global.process)) { - return function() { - return exports.deprecate(fn, msg).apply(this, arguments); - }; - } - - if (process.noDeprecation === true) { - return fn; - } - - var warned = false; - function deprecated() { - if (!warned) { - if (process.throwDeprecation) { - throw new Error(msg); - } else if (process.traceDeprecation) { - console.trace(msg); - } else { - console.error(msg); - } - warned = true; - } - return fn.apply(this, arguments); - } - - return deprecated; - }; - - - var debugs = {}; - var debugEnviron; - exports.debuglog = function(set) { - if (isUndefined(debugEnviron)) - debugEnviron = process.env.NODE_DEBUG || ''; - set = set.toUpperCase(); - if (!debugs[set]) { - if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { - var pid = process.pid; - debugs[set] = function() { - var msg = exports.format.apply(exports, arguments); - console.error('%s %d: %s', set, pid, msg); - }; - } else { - debugs[set] = function() {}; - } - } - return debugs[set]; - }; - - - /** - * Echos the value of a value. Trys to print the value out - * in the best way possible given the different types. - * - * @param {Object} obj The object to print out. - * @param {Object} opts Optional options object that alters the output. - */ - /* legacy: obj, showHidden, depth, colors*/ - function inspect(obj, opts) { - // default options - var ctx = { - seen: [], - stylize: stylizeNoColor - }; - // legacy... - if (arguments.length >= 3) ctx.depth = arguments[2]; - if (arguments.length >= 4) ctx.colors = arguments[3]; - if (isBoolean(opts)) { - // legacy... - ctx.showHidden = opts; - } else if (opts) { - // got an "options" object - exports._extend(ctx, opts); - } - // set default options - if (isUndefined(ctx.showHidden)) ctx.showHidden = false; - if (isUndefined(ctx.depth)) ctx.depth = 2; - if (isUndefined(ctx.colors)) ctx.colors = false; - if (isUndefined(ctx.customInspect)) ctx.customInspect = true; - if (ctx.colors) ctx.stylize = stylizeWithColor; - return formatValue(ctx, obj, ctx.depth); - } - exports.inspect = inspect; - - - // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics - inspect.colors = { - 'bold' : [1, 22], - 'italic' : [3, 23], - 'underline' : [4, 24], - 'inverse' : [7, 27], - 'white' : [37, 39], - 'grey' : [90, 39], - 'black' : [30, 39], - 'blue' : [34, 39], - 'cyan' : [36, 39], - 'green' : [32, 39], - 'magenta' : [35, 39], - 'red' : [31, 39], - 'yellow' : [33, 39] - }; - - // Don't use 'blue' not visible on cmd.exe - inspect.styles = { - 'special': 'cyan', - 'number': 'yellow', - 'boolean': 'yellow', - 'undefined': 'grey', - 'null': 'bold', - 'string': 'green', - 'date': 'magenta', - // "name": intentionally not styling - 'regexp': 'red' - }; - - - function stylizeWithColor(str, styleType) { - var style = inspect.styles[styleType]; - - if (style) { - return '\u001b[' + inspect.colors[style][0] + 'm' + str + - '\u001b[' + inspect.colors[style][1] + 'm'; - } else { - return str; - } - } - - - function stylizeNoColor(str, styleType) { - return str; - } - - - function arrayToHash(array) { - var hash = {}; - - array.forEach(function(val, idx) { - hash[val] = true; - }); - - return hash; - } - - - function formatValue(ctx, value, recurseTimes) { - // Provide a hook for user-specified inspect functions. - // Check that value is an object with an inspect function on it - if (ctx.customInspect && - value && - isFunction(value.inspect) && - // Filter out the util module, it's inspect function is special - value.inspect !== exports.inspect && - // Also filter out any prototype objects using the circular check. - !(value.constructor && value.constructor.prototype === value)) { - var ret = value.inspect(recurseTimes, ctx); - if (!isString(ret)) { - ret = formatValue(ctx, ret, recurseTimes); - } - return ret; - } - - // Primitive types cannot have properties - var primitive = formatPrimitive(ctx, value); - if (primitive) { - return primitive; - } - - // Look up the keys of the object. - var keys = Object.keys(value); - var visibleKeys = arrayToHash(keys); - - if (ctx.showHidden) { - keys = Object.getOwnPropertyNames(value); - } - - // IE doesn't make error fields non-enumerable - // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx - if (isError(value) - && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { - return formatError(value); - } - - // Some type of object without properties can be shortcutted. - if (keys.length === 0) { - if (isFunction(value)) { - var name = value.name ? ': ' + value.name : ''; - return ctx.stylize('[Function' + name + ']', 'special'); - } - if (isRegExp(value)) { - return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); - } - if (isDate(value)) { - return ctx.stylize(Date.prototype.toString.call(value), 'date'); - } - if (isError(value)) { - return formatError(value); - } - } - - var base = '', array = false, braces = ['{', '}']; - - // Make Array say that they are Array - if (isArray(value)) { - array = true; - braces = ['[', ']']; - } - - // Make functions say that they are functions - if (isFunction(value)) { - var n = value.name ? ': ' + value.name : ''; - base = ' [Function' + n + ']'; - } - - // Make RegExps say that they are RegExps - if (isRegExp(value)) { - base = ' ' + RegExp.prototype.toString.call(value); - } - - // Make dates with properties first say the date - if (isDate(value)) { - base = ' ' + Date.prototype.toUTCString.call(value); - } - - // Make error with message first say the error - if (isError(value)) { - base = ' ' + formatError(value); - } - - if (keys.length === 0 && (!array || value.length == 0)) { - return braces[0] + base + braces[1]; - } - - if (recurseTimes < 0) { - if (isRegExp(value)) { - return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); - } else { - return ctx.stylize('[Object]', 'special'); - } - } - - ctx.seen.push(value); - - var output; - if (array) { - output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); - } else { - output = keys.map(function(key) { - return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); - }); - } - - ctx.seen.pop(); - - return reduceToSingleString(output, base, braces); - } - - - function formatPrimitive(ctx, value) { - if (isUndefined(value)) - return ctx.stylize('undefined', 'undefined'); - if (isString(value)) { - var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') - .replace(/'/g, "\\'") - .replace(/\\"/g, '"') + '\''; - return ctx.stylize(simple, 'string'); - } - if (isNumber(value)) - return ctx.stylize('' + value, 'number'); - if (isBoolean(value)) - return ctx.stylize('' + value, 'boolean'); - // For some reason typeof null is "object", so special case here. - if (isNull(value)) - return ctx.stylize('null', 'null'); - } - - - function formatError(value) { - return '[' + Error.prototype.toString.call(value) + ']'; - } - - - function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { - var output = []; - for (var i = 0, l = value.length; i < l; ++i) { - if (hasOwnProperty(value, String(i))) { - output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, - String(i), true)); - } else { - output.push(''); - } - } - keys.forEach(function(key) { - if (!key.match(/^\d+$/)) { - output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, - key, true)); - } - }); - return output; - } - - - function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { - var name, str, desc; - desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; - if (desc.get) { - if (desc.set) { - str = ctx.stylize('[Getter/Setter]', 'special'); - } else { - str = ctx.stylize('[Getter]', 'special'); - } - } else { - if (desc.set) { - str = ctx.stylize('[Setter]', 'special'); - } - } - if (!hasOwnProperty(visibleKeys, key)) { - name = '[' + key + ']'; - } - if (!str) { - if (ctx.seen.indexOf(desc.value) < 0) { - if (isNull(recurseTimes)) { - str = formatValue(ctx, desc.value, null); - } else { - str = formatValue(ctx, desc.value, recurseTimes - 1); - } - if (str.indexOf('\n') > -1) { - if (array) { - str = str.split('\n').map(function(line) { - return ' ' + line; - }).join('\n').substr(2); - } else { - str = '\n' + str.split('\n').map(function(line) { - return ' ' + line; - }).join('\n'); - } - } - } else { - str = ctx.stylize('[Circular]', 'special'); - } - } - if (isUndefined(name)) { - if (array && key.match(/^\d+$/)) { - return str; - } - name = JSON.stringify('' + key); - if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { - name = name.substr(1, name.length - 2); - name = ctx.stylize(name, 'name'); - } else { - name = name.replace(/'/g, "\\'") - .replace(/\\"/g, '"') - .replace(/(^"|"$)/g, "'"); - name = ctx.stylize(name, 'string'); - } - } - - return name + ': ' + str; - } - - - function reduceToSingleString(output, base, braces) { - var numLinesEst = 0; - var length = output.reduce(function(prev, cur) { - numLinesEst++; - if (cur.indexOf('\n') >= 0) numLinesEst++; - return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; - }, 0); - - if (length > 60) { - return braces[0] + - (base === '' ? '' : base + '\n ') + - ' ' + - output.join(',\n ') + - ' ' + - braces[1]; - } - - return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; - } - - - // NOTE: These type checking functions intentionally don't use `instanceof` - // because it is fragile and can be easily faked with `Object.create()`. - function isArray(ar) { - return Array.isArray(ar); - } - exports.isArray = isArray; - - function isBoolean(arg) { - return typeof arg === 'boolean'; - } - exports.isBoolean = isBoolean; - - function isNull(arg) { - return arg === null; - } - exports.isNull = isNull; - - function isNullOrUndefined(arg) { - return arg == null; - } - exports.isNullOrUndefined = isNullOrUndefined; - - function isNumber(arg) { - return typeof arg === 'number'; - } - exports.isNumber = isNumber; - - function isString(arg) { - return typeof arg === 'string'; - } - exports.isString = isString; - - function isSymbol(arg) { - return typeof arg === 'symbol'; - } - exports.isSymbol = isSymbol; - - function isUndefined(arg) { - return arg === void 0; - } - exports.isUndefined = isUndefined; - - function isRegExp(re) { - return isObject(re) && objectToString(re) === '[object RegExp]'; - } - exports.isRegExp = isRegExp; - - function isObject(arg) { - return typeof arg === 'object' && arg !== null; - } - exports.isObject = isObject; - - function isDate(d) { - return isObject(d) && objectToString(d) === '[object Date]'; - } - exports.isDate = isDate; - - function isError(e) { - return isObject(e) && - (objectToString(e) === '[object Error]' || e instanceof Error); - } - exports.isError = isError; - - function isFunction(arg) { - return typeof arg === 'function'; - } - exports.isFunction = isFunction; - - function isPrimitive(arg) { - return arg === null || - typeof arg === 'boolean' || - typeof arg === 'number' || - typeof arg === 'string' || - typeof arg === 'symbol' || // ES6 symbol - typeof arg === 'undefined'; - } - exports.isPrimitive = isPrimitive; - - exports.isBuffer = __webpack_require__(4); - - function objectToString(o) { - return Object.prototype.toString.call(o); - } - - - function pad(n) { - return n < 10 ? '0' + n.toString(10) : n.toString(10); - } - - - var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', - 'Oct', 'Nov', 'Dec']; - - // 26 Feb 16:19:34 - function timestamp() { - var d = new Date(); - var time = [pad(d.getHours()), - pad(d.getMinutes()), - pad(d.getSeconds())].join(':'); - return [d.getDate(), months[d.getMonth()], time].join(' '); - } - - - // log is just a thin wrapper to console.log that prepends a timestamp - exports.log = function() { - console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); - }; - - - /** - * Inherit the prototype methods from one constructor into another. - * - * The Function.prototype.inherits from lang.js rewritten as a standalone - * function (not on Function.prototype). NOTE: If this file is to be loaded - * during bootstrapping this function needs to be rewritten using some native - * functions as prototype setup using normal JavaScript does not work as - * expected during bootstrapping (see mirror.js in r114903). - * - * @param {function} ctor Constructor function which needs to inherit the - * prototype. - * @param {function} superCtor Constructor function to inherit prototype from. - */ - exports.inherits = __webpack_require__(5); - - exports._extend = function(origin, add) { - // Don't do anything if add isn't an object - if (!add || !isObject(add)) return origin; - - var keys = Object.keys(add); - var i = keys.length; - while (i--) { - origin[keys[i]] = add[keys[i]]; - } - return origin; - }; - - function hasOwnProperty(obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); - } - - /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()), __webpack_require__(3))) - -/***/ }, -/* 3 */ -/***/ function(module, exports) { - - // shim for using process in browser - - var process = module.exports = {}; - 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 = setTimeout(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; - clearTimeout(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) { - setTimeout(drainQueue, 0); - } - }; - - // 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.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; }; - - -/***/ }, -/* 4 */ -/***/ function(module, exports) { - - module.exports = function isBuffer(arg) { - return arg && typeof arg === 'object' - && typeof arg.copy === 'function' - && typeof arg.fill === 'function' - && typeof arg.readUInt8 === 'function'; - } - -/***/ }, -/* 5 */ -/***/ function(module, exports) { - - if (typeof Object.create === 'function') { - // implementation from standard node.js 'util' module - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - ctor.prototype = Object.create(superCtor.prototype, { - constructor: { - value: ctor, - enumerable: false, - writable: true, - configurable: true - } - }); - }; - } else { - // old school shim for old browsers - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - var TempCtor = function () {} - TempCtor.prototype = superCtor.prototype - ctor.prototype = new TempCtor() - ctor.prototype.constructor = ctor - } - } - - -/***/ } -/******/ ]); \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js index 46a89c67c..6badafd2f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -3,8 +3,7 @@ var webpack = require('webpack'); module.exports = { entry: { 'vm': './src/index.js', - 'vm.min': './src/index.js', - 'vm.worker': './src/worker.js' + 'vm.min': './src/index.js' }, output: { path: __dirname,