diff --git a/bin/gpu-core.js b/bin/gpu-core.js index aa61bfa0..f98204a7 100644 --- a/bin/gpu-core.js +++ b/bin/gpu-core.js @@ -4,8 +4,8 @@ * * GPU Accelerated JavaScript * - * @version 1.4.10 - * @date Tue Jul 03 2018 16:23:43 GMT-0400 (EDT) + * @version 1.4.11 + * @date Wed Jul 04 2018 15:50:38 GMT-0400 (EDT) * * @license MIT * The MIT License @@ -189,6 +189,17 @@ var UtilsCore = function () { return canvasObj.getContext('webgl2', UtilsCore.initWebGlDefaultOptions()); } + + + }, { + key: 'checkOutput', + value: function checkOutput(output) { + for (var i = 0; i < output.length; i++) { + if (isNaN(output[i]) || output[i] < 1) { + throw new Error('kernel.output[' + i + '] incorrectly defined as `' + output[i] + '`, needs to be numeric, and greater than 0'); + } + } + } }]); return UtilsCore; diff --git a/bin/gpu-core.min.js b/bin/gpu-core.min.js index 94eb6520..01966c04 100644 --- a/bin/gpu-core.min.js +++ b/bin/gpu-core.min.js @@ -4,12 +4,12 @@ * * GPU Accelerated JavaScript * - * @version 1.4.10 - * @date Tue Jul 03 2018 16:23:43 GMT-0400 (EDT) + * @version 1.4.11 + * @date Wed Jul 04 2018 15:50:38 GMT-0400 (EDT) * * @license MIT * The MIT License * * Copyright (c) 2018 gpu.js Team */ -"use strict";!function(){function e(n,t,r){function i(u,a){if(!t[u]){if(!n[u]){var l="function"==typeof require&&require;if(!a&&l)return l(u,!0);if(o)return o(u,!0);var f=new Error("Cannot find module '"+u+"'");throw f.code="MODULE_NOT_FOUND",f}var c=t[u]={exports:{}};n[u][0].call(c.exports,function(e){var t=n[u][1][e];return i(t?t:e)},c,c.exports,e,n,t,r)}return t[u].exports}for(var o="function"==typeof require&&require,u=0;u {\n ' + kernelRunShortcut.toString() + ';\n const utils = {\n allPropertiesOf: ' + removeNoise(utils.allPropertiesOf.toString()) + ',\n clone: ' + removeNoise(utils.clone.toString()) + '\n };\n const Utils = utils;\n class ' + (name || 'Kernel') + ' {\n constructor() { \n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = ' + JSON.stringify(cpuKernel.paramNames) + ';\n this.paramTypes = ' + JSON.stringify(cpuKernel.paramTypes) + ';\n this.texSize = ' + JSON.stringify(cpuKernel.texSize) + ';\n this.output = ' + JSON.stringify(cpuKernel.output) + ';\n this._kernelString = `' + cpuKernel._kernelString + '`;\n this.output = ' + JSON.stringify(cpuKernel.output) + ';\n\t\t this.run = function() {\n this.run = null;\n this.build();\n return this.run.apply(this, arguments);\n }.bind(this);\n this.thread = {\n x: 0,\n y: 0,\n z: 0\n };\n }\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n ' + removeFnNoise(cpuKernel.build.toString()) + '\n ' + removeFnNoise(cpuKernel.setupParams.toString()) + '\n run () { ' + cpuKernel.kernelString + ' }\n getKernelString() { return this._kernelString; }\n ' + removeFnNoise(cpuKernel.validateOptions.toString()) + '\n };\n return kernelRunShortcut(new Kernel());\n };'; + return '() => {\n ' + kernelRunShortcut.toString() + ';\n const utils = {\n allPropertiesOf: ' + removeNoise(utils.allPropertiesOf.toString()) + ',\n clone: ' + removeNoise(utils.clone.toString()) + ',\n checkOutput: ' + removeNoise(utils.checkOutput.toString()) + '\n };\n const Utils = utils;\n class ' + (name || 'Kernel') + ' {\n constructor() { \n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = ' + JSON.stringify(cpuKernel.paramNames) + ';\n this.paramTypes = ' + JSON.stringify(cpuKernel.paramTypes) + ';\n this.texSize = ' + JSON.stringify(cpuKernel.texSize) + ';\n this.output = ' + JSON.stringify(cpuKernel.output) + ';\n this._kernelString = `' + cpuKernel._kernelString + '`;\n this.output = ' + JSON.stringify(cpuKernel.output) + ';\n\t\t this.run = function() {\n this.run = null;\n this.build();\n return this.run.apply(this, arguments);\n }.bind(this);\n this.thread = {\n x: 0,\n y: 0,\n z: 0\n };\n }\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n ' + removeFnNoise(cpuKernel.build.toString()) + '\n ' + removeFnNoise(cpuKernel.setupParams.toString()) + '\n run () { ' + cpuKernel.kernelString + ' }\n getKernelString() { return this._kernelString; }\n ' + removeFnNoise(cpuKernel.validateOptions.toString()) + '\n };\n return kernelRunShortcut(new Kernel());\n };'; }; },{"../../core/utils":32,"../kernel-run-shortcut":9}],4:[function(require,module,exports){ 'use strict'; @@ -880,6 +880,8 @@ module.exports = function (_KernelBase) { throw 'Auto dimensions not supported for input type: ' + argType; } } + + utils.checkOutput(this.output); } @@ -3153,7 +3155,7 @@ function removeNoise(str) { } module.exports = function (gpuKernel, name) { - return '() => {\n ' + kernelRunShortcut.toString() + ';\n const utils = {\n allPropertiesOf: ' + removeNoise(utils.allPropertiesOf.toString()) + ',\n clone: ' + removeNoise(utils.clone.toString()) + ',\n splitArray: ' + removeNoise(utils.splitArray.toString()) + ',\n getArgumentType: ' + removeNoise(utils.getArgumentType.toString()) + ',\n getDimensions: ' + removeNoise(utils.getDimensions.toString()) + ',\n dimToTexSize: ' + removeNoise(utils.dimToTexSize.toString()) + ',\n flattenTo: ' + removeNoise(utils.flattenTo.toString()) + ',\n flatten2dArrayTo: ' + removeNoise(utils.flatten2dArrayTo.toString()) + ',\n flatten3dArrayTo: ' + removeNoise(utils.flatten3dArrayTo.toString()) + ',\n systemEndianness: \'' + removeNoise(utils.systemEndianness()) + '\',\n initWebGl: ' + removeNoise(utils.initWebGl.toString()) + ',\n isArray: ' + removeNoise(utils.isArray.toString()) + '\n };\n const Utils = utils;\n const canvases = [];\n const maxTexSizes = {};\n class ' + (name || 'Kernel') + ' {\n constructor() {\n this.maxTexSize = null;\n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = ' + JSON.stringify(gpuKernel.paramNames) + ';\n this.paramTypes = ' + JSON.stringify(gpuKernel.paramTypes) + ';\n this.texSize = ' + JSON.stringify(gpuKernel.texSize) + ';\n this.output = ' + JSON.stringify(gpuKernel.output) + ';\n this.compiledFragShaderString = `' + gpuKernel.compiledFragShaderString + '`;\n\t\t this.compiledVertShaderString = `' + gpuKernel.compiledVertShaderString + '`;\n\t\t this.programUniformLocationCache = {};\n\t\t this.textureCache = {};\n\t\t this.subKernelOutputTextures = null;\n\t\t this.subKernelOutputVariableNames = null;\n\t\t this.uniform1fCache = {};\n\t\t this.uniform1iCache = {};\n\t\t this.uniform2fCache = {};\n\t\t this.uniform2fvCache = {};\n\t\t this.uniform3fvCache = {};\n }\n ' + removeFnNoise(gpuKernel._getFragShaderString.toString()) + '\n ' + removeFnNoise(gpuKernel._getVertShaderString.toString()) + '\n validateOptions() {}\n setupParams() {}\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n ' + removeFnNoise(gpuKernel.getUniformLocation.toString()) + '\n ' + removeFnNoise(gpuKernel.setupParams.toString()) + '\n ' + removeFnNoise(gpuKernel.build.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.run.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel._addArgument.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getArgumentTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getTextureCache.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getOutputTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.renderOutput.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.updateMaxTexSize.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel._setupOutputTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.detachTextureCache.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform1f.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform1i.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform2f.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform2fv.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform3fv.toString()) + ' \n };\n return kernelRunShortcut(new Kernel());\n };'; + return '() => {\n ' + kernelRunShortcut.toString() + ';\n const utils = {\n allPropertiesOf: ' + removeNoise(utils.allPropertiesOf.toString()) + ',\n clone: ' + removeNoise(utils.clone.toString()) + ',\n splitArray: ' + removeNoise(utils.splitArray.toString()) + ',\n getArgumentType: ' + removeNoise(utils.getArgumentType.toString()) + ',\n getDimensions: ' + removeNoise(utils.getDimensions.toString()) + ',\n dimToTexSize: ' + removeNoise(utils.dimToTexSize.toString()) + ',\n flattenTo: ' + removeNoise(utils.flattenTo.toString()) + ',\n flatten2dArrayTo: ' + removeNoise(utils.flatten2dArrayTo.toString()) + ',\n flatten3dArrayTo: ' + removeNoise(utils.flatten3dArrayTo.toString()) + ',\n systemEndianness: \'' + removeNoise(utils.systemEndianness()) + '\',\n initWebGl: ' + removeNoise(utils.initWebGl.toString()) + ',\n isArray: ' + removeNoise(utils.isArray.toString()) + ',\n checkOutput: ' + removeNoise(utils.checkOutput.toString()) + '\n };\n const Utils = utils;\n const canvases = [];\n const maxTexSizes = {};\n class ' + (name || 'Kernel') + ' {\n constructor() {\n this.maxTexSize = null;\n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = ' + JSON.stringify(gpuKernel.paramNames) + ';\n this.paramTypes = ' + JSON.stringify(gpuKernel.paramTypes) + ';\n this.texSize = ' + JSON.stringify(gpuKernel.texSize) + ';\n this.output = ' + JSON.stringify(gpuKernel.output) + ';\n this.compiledFragShaderString = `' + gpuKernel.compiledFragShaderString + '`;\n\t\t this.compiledVertShaderString = `' + gpuKernel.compiledVertShaderString + '`;\n\t\t this.programUniformLocationCache = {};\n\t\t this.textureCache = {};\n\t\t this.subKernelOutputTextures = null;\n\t\t this.subKernelOutputVariableNames = null;\n\t\t this.uniform1fCache = {};\n\t\t this.uniform1iCache = {};\n\t\t this.uniform2fCache = {};\n\t\t this.uniform2fvCache = {};\n\t\t this.uniform3fvCache = {};\n }\n ' + removeFnNoise(gpuKernel._getFragShaderString.toString()) + '\n ' + removeFnNoise(gpuKernel._getVertShaderString.toString()) + '\n validateOptions() {}\n setupParams() {}\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n ' + removeFnNoise(gpuKernel.getUniformLocation.toString()) + '\n ' + removeFnNoise(gpuKernel.setupParams.toString()) + '\n ' + removeFnNoise(gpuKernel.build.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.run.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel._addArgument.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getArgumentTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getTextureCache.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getOutputTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.renderOutput.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.updateMaxTexSize.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel._setupOutputTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.detachTextureCache.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform1f.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform1i.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform2f.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform2fv.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform3fv.toString()) + ' \n };\n return kernelRunShortcut(new Kernel());\n };'; }; },{"../../core/utils":32,"../kernel-run-shortcut":9}],14:[function(require,module,exports){ 'use strict'; @@ -3242,6 +3244,8 @@ module.exports = function (_KernelBase) { this.floatOutput = isFloatReadPixel; } + utils.checkOutput(this.output); + if (!this.output || this.output.length === 0) { if (arguments.length !== 1) { throw new Error('Auto output only supported for kernels with only one input'); @@ -4438,6 +4442,8 @@ module.exports = function (_WebGLKernel) { this.floatOutput = isFloatReadPixel; } + utils.checkOutput(this.output); + if (!this.output || this.output.length === 0) { if (arguments.length !== 1) { throw new Error('Auto output only supported for kernels with only one input'); @@ -5560,6 +5566,17 @@ var UtilsCore = function () { return canvasObj.getContext('webgl2', UtilsCore.initWebGlDefaultOptions()); } + + + }, { + key: 'checkOutput', + value: function checkOutput(output) { + for (var i = 0; i < output.length; i++) { + if (isNaN(output[i]) || output[i] < 1) { + throw new Error('kernel.output[' + i + '] incorrectly defined as `' + output[i] + '`, needs to be numeric, and greater than 0'); + } + } + } }]); return UtilsCore; diff --git a/bin/gpu.min.js b/bin/gpu.min.js index 699edec6..dde9e018 100644 --- a/bin/gpu.min.js +++ b/bin/gpu.min.js @@ -4,18 +4,18 @@ * * GPU Accelerated JavaScript * - * @version 1.4.10 - * @date Tue Jul 03 2018 16:23:43 GMT-0400 (EDT) + * @version 1.4.11 + * @date Wed Jul 04 2018 15:50:38 GMT-0400 (EDT) * * @license MIT * The MIT License * * Copyright (c) 2018 gpu.js Team */ -"use strict";!function(){function t(e,n,r){function i(a,o){if(!n[a]){if(!e[a]){var u="function"==typeof require&&require;if(!o&&u)return u(a,!0);if(s)return s(a,!0);var h=new Error("Cannot find module '"+a+"'");throw h.code="MODULE_NOT_FOUND",h}var p=n[a]={exports:{}};e[a][0].call(p.exports,function(t){var n=e[a][1][t];return i(n?n:t)},p,p.exports,t,e,n,r)}return n[a].exports}for(var s="function"==typeof require&&require,a=0;a0&&e.push(", "),e.push(this.paramTypes[n]),e.push(" "),e.push("user_"),e.push(this.paramNames[n]);return e.push(");\n"),e}},{key:"astFunctionExpression",value:function(t,e){if(!this.isRootKernel){e.push("function"),this.kernalAst=t,e.push(" "),e.push(this.functionName),e.push("(");for(var n=0;n0&&e.push(", "),e.push(" "),e.push("user_"),e.push(r)}e.push(") {\n")}for(var i=0;i1){for(var s=null,a=0;a0&&e.push(","),this.astGeneric(t.declarations[n],e);return e.push(";"),e}},{key:"astVariableDeclarator",value:function(t,e){return this.astGeneric(t.id,e),null!==t.init&&(e.push("="),this.astGeneric(t.init,e)),e}},{key:"astIfStatement",value:function(t,e){return e.push("if ("),this.astGeneric(t.test,e),e.push(")"),"BlockStatement"===t.consequent.type?this.astGeneric(t.consequent,e):(e.push(" {\n"),this.astGeneric(t.consequent,e),e.push("\n}\n")),t.alternate&&(e.push("else "),"BlockStatement"===t.alternate.type?this.astGeneric(t.alternate,e):(e.push(" {\n"),this.astGeneric(t.alternate,e),e.push("\n}\n"))),e}},{key:"astBreakStatement",value:function(t,e){return e.push("break;\n"),e}},{key:"astContinueStatement",value:function(t,e){return e.push("continue;\n"),e}},{key:"astLogicalExpression",value:function(t,e){return e.push("("),this.astGeneric(t.left,e),e.push(t.operator),this.astGeneric(t.right,e),e.push(")"),e}},{key:"astUpdateExpression",value:function(t,e){return t.prefix?(e.push(t.operator),this.astGeneric(t.argument,e)):(this.astGeneric(t.argument,e),e.push(t.operator)),e}},{key:"astUnaryExpression",value:function(t,e){return t.prefix?(e.push(t.operator),this.astGeneric(t.argument,e)):(this.astGeneric(t.argument,e),e.push(t.operator)),e}},{key:"astThisExpression",value:function(t,e){return e.push("_this"),e}},{key:"astMemberExpression",value:function(t,e){if(t.computed)if("Identifier"===t.object.type)this.pushState("identifier"),this.astGeneric(t.object,e),this.popState("identifier"),e.push("["),this.isInput(t.object.name)?this.astGeneric(t.property,e):this.astGeneric(t.property,e),e.push("]");else if(t.object.object)if(t.object.object.object&&this.isInput(t.object.object.object.name)){this.pushMemberState(t.object.object.object.name),this.pushState("input-index-z"),this.astGeneric(t.object,e);var n=e.pop();e.push(" + "),this.popState("input-index-z"),this.pushState("input-index"),this.astGeneric(t.property,e),this.popState("input-index"),e.push(n),this.popMemberState(t.object.object.object.name)}else if(this.isInput(t.object.object.name)){this.pushMemberState(t.object.object.name),this.isState("input-index-z")||this.pushState("input-index-y"),this.astGeneric(t.object,e);var r=e.pop();e.push(" + "),this.isState("input-index-z")||this.popState("input-index-y");var i=this.isState("input-index-z");i?this.pushState("input-index-y"):this.pushState("input-index"),this.astGeneric(t.property,e),i?this.popState("input-index-y"):this.popState("input-index"),e.push(r),this.popMemberState(t.object.object.name)}else{this.astGeneric(t.object,e);var s=e.pop();e.push("]["),this.astGeneric(t.property,e),e.push(s)}else{this.astGeneric(t.object,e);var a=e.pop();e.push("]["),this.astGeneric(t.property,e),e.push(a)}else{var o=this.astMemberExpressionUnroll(t);switch("Identifier"===t.property.type&&t.computed&&(o="user_"+o),0===o.indexOf("this")&&(o="_"+o),this.state){case"input-index-y":case"input-index-z":e.push("(")}switch(o){case"_this.output.x":e.push(this.output[0]);break;case"_this.output.y":e.push(this.output[1]);break;case"_this.output.z":e.push(this.output[2]);break;default:e.push(o)}switch(this.state){case"input-index-y":var u=this.paramSizes[this.paramNames.indexOf(this.memberState)];e.push(" * "+u[0]+")");break;case"input-index-z":var h=this.paramSizes[this.paramNames.indexOf(this.memberState)];e.push(" * "+h[0]*h[1]+")")}}return e}},{key:"astSequenceExpression",value:function(t,e){for(var n=0;n0&&e.push(","),this.astGeneric(t.expressions,e);return e}},{key:"astCallExpression",value:function(t,e){if(t.callee){var n=this.astMemberExpressionUnroll(t.callee);this.calledFunctions.indexOf(n)<0&&this.calledFunctions.push(n),this.hasOwnProperty("funcName")||(this.calledFunctionsArguments[n]=[]);var r=[];this.calledFunctionsArguments[n].push(r),e.push(n),e.push("(");for(var i=0;i0&&e.push(", "),this.astGeneric(s,e),"Identifier"===s.type){var a=this.paramNames.indexOf(s.name);a===-1?r.push(null):r.push({name:s.name,type:this.paramTypes[a]})}else r.push(null)}return e.push(")"),e}throw this.astErrorOutput("Unknown CallExpression",t)}},{key:"astArrayExpression",value:function(t,e){var n=t.elements.length;e.push("new Float32Array(");for(var r=0;r0&&e.push(", ");var i=t.elements[r];this.astGeneric(i,e)}return e.push(")"),e}},{key:"astDebuggerStatement",value:function(t,e){return e.push("debugger;"),e}},{key:"memberState",get:function(){return this.memberStates[this.memberStates.length-1]}}]),e}(o)},{"../../core/utils":32,"../function-node-base":7}],3:[function(t,e,n){function r(t){return/^function /.test(t)&&(t=t.substring(9)),t.replace(/[_]typeof/g,"typeof")}function i(t){return t.replace(/[_]typeof/g,"typeof")}var s=t("../../core/utils"),a=t("../kernel-run-shortcut");e.exports=function(t,e){return"() => {\n "+a.toString()+";\n const utils = {\n allPropertiesOf: "+i(s.allPropertiesOf.toString())+",\n clone: "+i(s.clone.toString())+"\n };\n const Utils = utils;\n class "+(e||"Kernel")+" {\n constructor() { \n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = "+JSON.stringify(t.paramNames)+";\n this.paramTypes = "+JSON.stringify(t.paramTypes)+";\n this.texSize = "+JSON.stringify(t.texSize)+";\n this.output = "+JSON.stringify(t.output)+";\n this._kernelString = `"+t._kernelString+"`;\n this.output = "+JSON.stringify(t.output)+";\n\t\t this.run = function() {\n this.run = null;\n this.build();\n return this.run.apply(this, arguments);\n }.bind(this);\n this.thread = {\n x: 0,\n y: 0,\n z: 0\n };\n }\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n "+r(t.build.toString())+"\n "+r(t.setupParams.toString())+"\n run () { "+t.kernelString+" }\n getKernelString() { return this._kernelString; }\n "+r(t.validateOptions.toString())+"\n };\n return kernelRunShortcut(new Kernel());\n };"}},{"../../core/utils":32,"../kernel-run-shortcut":9}],4:[function(t,e,n){function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var a=function(){function t(t,e){for(var n=0;n1?h=h.filter(function(t){return/^function/.test(t)?t:(p=t,!1)}):p=h.shift();var l=this._kernelString="\n\t\tvar LOOP_MAX = "+this._getLoopMaxString()+";\n\t\tvar _this = this;\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(t){return" var "+t+" = null;\n"}).join(""))+"\n return function ("+this.paramNames.map(function(t){return"user_"+t}).join(", ")+") {\n "+this._processInputs()+"\n var ret = new Array("+n[2]+");\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(t){return" "+t+"Z = new Array("+n[2]+");\n"}).join(""))+"\n for (this.thread.z = 0; this.thread.z < "+n[2]+"; this.thread.z++) {\n ret[this.thread.z] = new Array("+n[1]+");\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(t){return" "+t+"Z[this.thread.z] = new Array("+n[1]+");\n"}).join(""))+"\n for (this.thread.y = 0; this.thread.y < "+n[1]+"; this.thread.y++) {\n ret[this.thread.z][this.thread.y] = new Array("+n[0]+");\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(t){return" "+t+"Z[this.thread.z][this.thread.y] = new Array("+n[0]+");\n"}).join(""))+"\n for (this.thread.x = 0; this.thread.x < "+n[0]+"; this.thread.x++) {\n var kernelResult;\n "+p+"\n ret[this.thread.z][this.thread.y][this.thread.x] = kernelResult;\n"+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(t){return" "+t+"Z[this.thread.z][this.thread.y][this.thread.x] = "+t+";\n"}).join(""))+"\n }\n }\n }\n \n if (this.graphical) {\n this._imageData.data.set(this._colorData);\n this._canvasCtx.putImageData(this._imageData, 0, 0);\n return;\n }\n \n if (this.output.length === 1) {\n ret = ret[0][0];\n"+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(t){return" "+t+" = "+t+"Z[0][0];\n"}).join(""))+"\n \n } else if (this.output.length === 2) {\n ret = ret[0];\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(t){return" "+t+" = "+t+"Z[0];\n"}).join(""))+"\n }\n \n "+(null===this.subKernelOutputVariableNames?"return ret;\n":null!==this.subKernels?"var result = [\n "+this.subKernelOutputVariableNames.map(function(t){return""+t}).join(",\n")+"\n ];\n result.result = ret;\n return result;\n":"return {\n result: ret,\n "+Object.keys(this.subKernelProperties).map(function(e,n){return e+": "+t.subKernelOutputVariableNames[n]}).join(",\n")+"\n };")+"\n "+(h.length>0?h.join("\n"):"")+"\n }.bind(this);";return l}},{key:"toString",value:function(){return h(this)}},{key:"precompileKernelObj",value:function(t){var e=this.threadDim||(this.threadDim=u.clone(this.output));return{threadDim:e}}},{key:"_getLoopMaxString",value:function(){return this.loopMaxIterations?" "+parseInt(this.loopMaxIterations)+";\n":" 1000;\n"}},{key:"_processInputs",value:function(){for(var t=[],e=0;e=0;i--){n[i]=new Array(t.width);for(var s=0;s=0||e.push(t)),e}},{key:"addKernel",value:function(t,e){var n=new this.Node("kernel",t,e);return n.setAddFunction(this.addFunction.bind(this)),n.isRootKernel=!0,this.addFunctionNode(n),n}},{key:"addSubKernel",value:function(t,e){var n=new this.Node(null,t,e);return n.setAddFunction(this.addFunction.bind(this)),n.isSubKernel=!0,this.addFunctionNode(n),n}},{key:"getPrototypeString",value:function(t){return this.getPrototypes(t).join("\n")}},{key:"getPrototypes",value:function(t){return this.rootKernel.generate(),t?this.getPrototypesFromFunctionNames(this.traceFunctionCalls(t,[]).reverse()):this.getPrototypesFromFunctionNames(Object.keys(this.nodeMap))}},{key:"getStringFromFunctionNames",value:function(t){for(var e=[],n=0;n ("+r.length+","+this.paramNames.length+")";this.paramTypes=r}else if("object"===("undefined"==typeof r?"undefined":_typeof(r))){var s=Object.keys(r);if(r.hasOwnProperty("returns")&&(this.returnType=r.returns,s.splice(s.indexOf("returns"),1)),s.length>0&&s.length!==this.paramNames.length)throw"Invalid argument type array length, against function length -> ("+s.length+","+this.paramNames.length+")";this.paramTypes=this.paramNames.map(function(t){return r.hasOwnProperty(t)?r[t]:"float"})}}else this.paramTypes=[];this.returnType||(this.returnType=i||"float")}return _createClass(BaseFunctionNode,[{key:"isIdentifierConstant",value:function(t){return!!this.constants&&this.constants.hasOwnProperty(t)}},{key:"isInput",value:function(t){return"Input"===this.paramTypes[this.paramNames.indexOf(t)]}},{key:"setAddFunction",value:function(t){return this.addFunction=t,this}},{key:"pushState",value:function(t){this.states.push(t)}},{key:"popState",value:function(t){if(this.state!==t)throw new Error("Cannot popState "+t+" when in "+this.state);this.states.pop()}},{key:"isState",value:function(t){return this.state===t}},{key:"getJsFunction",value:function getJsFunction(){if(this.jsFunction)return this.jsFunction;if(this.jsFunctionString)return this.jsFunction=eval(this.jsFunctionString),this.jsFunction;throw"Missing jsFunction, and jsFunctionString parameter"}},{key:"astMemberExpressionUnroll",value:function(t){if("Identifier"===t.type)return t.name;if("ThisExpression"===t.type)return"this";if("MemberExpression"===t.type&&t.object&&t.property)return t.object.hasOwnProperty("name")&&"_"===t.object.name[0]?this.astMemberExpressionUnroll(t.property):this.astMemberExpressionUnroll(t.object)+"."+this.astMemberExpressionUnroll(t.property);if(t.hasOwnProperty("expressions")){var e=t.expressions[0];if("Literal"===e.type&&0===e.value&&2===t.expressions.length)return this.astMemberExpressionUnroll(t.expressions[1])}throw this.astErrorOutput("Unknown CallExpression_unroll",t)}},{key:"getJsAST",value:function(t){if(this.jsFunctionAST)return this.jsFunctionAST;if(t=t||acorn,null===t)throw"Missing JS to AST parser";var e=t.parse("var "+this.functionName+" = "+this.jsFunctionString+";",{locations:!0});if(null===e)throw"Failed to parse JS code";var n=e.body[0].declarations[0].init;return this.jsFunctionAST=n,n}},{key:"getFunctionString",value:function(){return this.generate(),this.functionString}},{key:"setFunctionString",value:function(t){this.functionString=t}},{key:"getParamType",value:function(t){var e=this.paramNames.indexOf(t);if(e===-1)return this.declarations.hasOwnProperty(t)?this.declarations[t]:null;if(this.parent){if(this.paramTypes[e])return this.paramTypes[e];for(var n=this.parent.calledFunctionsArguments[this.functionName],r=0;r0&&e.push(", ");var i=this.getParamType(r);switch(i){case"Texture":case"Input":case"Array":e.push("sampler2D");break;default:e.push("float")}e.push(" "),e.push("user_"),e.push(r)}e.push(") {\n");for(var s=0;s1){for(var s=null,a=0;a0&&e.push(",");var i=[];this.astGeneric(r,i),"getImage2D("===i[2]||"getImage3D("===i[2]?(0===n&&e.push("vec4 "),this.declarations[r.id.name]="vec4"):(0===n&&e.push("float "),this.declarations[r.id.name]="float"),e.push.apply(e,i)}return e.push(";"),e}},{key:"astVariableDeclarator",value:function(t,e){return this.astGeneric(t.id,e),null!==t.init&&(e.push("="),this.astGeneric(t.init,e)),e}},{key:"astIfStatement",value:function(t,e){return e.push("if ("),this.astGeneric(t.test,e),e.push(")"),"BlockStatement"===t.consequent.type?this.astGeneric(t.consequent,e):(e.push(" {\n"),this.astGeneric(t.consequent,e),e.push("\n}\n")),t.alternate&&(e.push("else "),"BlockStatement"===t.alternate.type?this.astGeneric(t.alternate,e):(e.push(" {\n"),this.astGeneric(t.alternate,e),e.push("\n}\n"))),e}},{key:"astBreakStatement",value:function(t,e){return e.push("break;\n"),e}},{key:"astContinueStatement",value:function(t,e){return e.push("continue;\n"),e}},{key:"astLogicalExpression",value:function(t,e){return e.push("("),this.astGeneric(t.left,e),e.push(t.operator),this.astGeneric(t.right,e),e.push(")"),e}},{key:"astUpdateExpression",value:function(t,e){return t.prefix?(e.push(t.operator),this.astGeneric(t.argument,e)):(this.astGeneric(t.argument,e),e.push(t.operator)),e}},{key:"astUnaryExpression",value:function(t,e){return t.prefix?(e.push(t.operator),this.astGeneric(t.argument,e)):(this.astGeneric(t.argument,e),e.push(t.operator)),e}},{key:"astThisExpression",value:function(t,e){return e.push("this"),e}},{key:"astMemberExpression",value:function(t,e){if(t.computed)if("Identifier"===t.object.type){var n=t.object.name,r=(this.functionName||"kernel",!1);if(this.paramNames){var i=this.paramNames.indexOf(n);i>=0&&"float"===this.paramTypes[i]&&(r=!0)}if(r)this.astGeneric(t.object,e),e.push("[int("),this.astGeneric(t.property,e),e.push(")]");else switch(this.getParamType(t.object.name)){case"vec4":this.astGeneric(t.object,e),e.push("["),e.push(t.property.raw),e.push("]");break;case"HTMLImageArray":e.push("getImage3D("),this.astGeneric(t.object,e),e.push(", vec2("),this.astGeneric(t.object,e),e.push("Size[0],"),this.astGeneric(t.object,e),e.push("Size[1]), vec3("),this.astGeneric(t.object,e),e.push("Dim[0],"),this.astGeneric(t.object,e),e.push("Dim[1],"),this.astGeneric(t.object,e),e.push("Dim[2]"),e.push("), "),this.astGeneric(t.property,e),e.push(")");break;case"HTMLImage":e.push("getImage2D("),this.astGeneric(t.object,e),e.push(", vec2("),this.astGeneric(t.object,e),e.push("Size[0],"),this.astGeneric(t.object,e),e.push("Size[1]), vec3("),this.astGeneric(t.object,e),e.push("Dim[0],"),this.astGeneric(t.object,e),e.push("Dim[1],"),this.astGeneric(t.object,e),e.push("Dim[2]"),e.push("), "),this.astGeneric(t.property,e),e.push(")");break;default:e.push("get("),this.astGeneric(t.object,e),e.push(", vec2("),this.astGeneric(t.object,e),e.push("Size[0],"),this.astGeneric(t.object,e),e.push("Size[1]), vec3("),this.astGeneric(t.object,e),e.push("Dim[0],"),this.astGeneric(t.object,e),e.push("Dim[1],"),this.astGeneric(t.object,e),e.push("Dim[2]"),e.push("), "),this.astGeneric(t.property,e),e.push(")")}}else{this.astGeneric(t.object,e);var s=e.pop();e.push(","),this.astGeneric(t.property,e),e.push(s)}else{var a=this.astMemberExpressionUnroll(t),o=a.toLowerCase();switch(0===a.indexOf(c)&&(a="constants_"+a.slice(c.length)),o){case"this.thread.x":e.push("threadId.x");break;case"this.thread.y":e.push("threadId.y");break;case"this.thread.z":e.push("threadId.z");break;case"this.output.x":e.push(this.output[0]+".0");break;case"this.output.y":e.push(this.output[1]+".0");break;case"this.output.z":e.push(this.output[2]+".0");break;default:e.push(a)}}return e}},{key:"astSequenceExpression",value:function(t,e){for(var n=0;n0&&e.push(","),this.astGeneric(t.expressions,e);return e}},{key:"astCallExpression",value:function(t,e){if(t.callee){var n=this.astMemberExpressionUnroll(t.callee);0===n.indexOf(p)&&(n=n.slice(p.length)),0===n.indexOf(l)&&(n=n.slice(l.length)),"atan2"===n&&(n="atan"),this.calledFunctions.indexOf(n)<0&&this.calledFunctions.push(n),this.hasOwnProperty("funcName")||(this.calledFunctionsArguments[n]=[]);var r=[];this.calledFunctionsArguments[n].push(r),e.push(n),e.push("(");for(var i=0;i0&&e.push(", "),this.astGeneric(s,e),"Identifier"===s.type){var a=this.paramNames.indexOf(s.name);a===-1?r.push(null):r.push({name:s.name,type:this.paramTypes[a]})}else r.push(null)}return e.push(")"),e}throw this.astErrorOutput("Unknown CallExpression",t)}},{key:"astArrayExpression",value:function(t,e){var n=t.elements.length;e.push("float["+n+"](");for(var r=0;r0&&e.push(", ");var i=t.elements[r];this.astGeneric(i,e)}return e.push(")"),e}},{key:"getFunctionPrototypeString",value:function(){return this.webGlFunctionPrototypeString?this.webGlFunctionPrototypeString:this.webGlFunctionPrototypeString=this.generate()}},{key:"build",value:function(){return this.getFunctionPrototypeString().length>0}}],[{key:"astFunctionPrototype",value:function(t,e){if(this.isRootKernel||this.isSubKernel)return e;e.push(this.returnType),e.push(" "),e.push(this.functionName),e.push("(");for(var n=0;n0&&e.push(", "),e.push(this.paramTypes[n]),e.push(" "),e.push("user_"),e.push(this.paramNames[n]);return e.push(");\n"),e}}]),e}(u)},{"../../core/utils":32,"../function-node-base":7}],13:[function(t,e,n){function r(t){return/^function /.test(t)&&(t=t.substring(9)),t.replace(/[_]typeof/g,"typeof")}function i(t){return t.replace(/[_]typeof/g,"typeof")}var s=t("../../core/utils"),a=t("../kernel-run-shortcut");e.exports=function(t,e){return"() => {\n "+a.toString()+";\n const utils = {\n allPropertiesOf: "+i(s.allPropertiesOf.toString())+",\n clone: "+i(s.clone.toString())+",\n splitArray: "+i(s.splitArray.toString())+",\n getArgumentType: "+i(s.getArgumentType.toString())+",\n getDimensions: "+i(s.getDimensions.toString())+",\n dimToTexSize: "+i(s.dimToTexSize.toString())+",\n flattenTo: "+i(s.flattenTo.toString())+",\n flatten2dArrayTo: "+i(s.flatten2dArrayTo.toString())+",\n flatten3dArrayTo: "+i(s.flatten3dArrayTo.toString())+",\n systemEndianness: '"+i(s.systemEndianness())+"',\n initWebGl: "+i(s.initWebGl.toString())+",\n isArray: "+i(s.isArray.toString())+"\n };\n const Utils = utils;\n const canvases = [];\n const maxTexSizes = {};\n class "+(e||"Kernel")+" {\n constructor() {\n this.maxTexSize = null;\n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = "+JSON.stringify(t.paramNames)+";\n this.paramTypes = "+JSON.stringify(t.paramTypes)+";\n this.texSize = "+JSON.stringify(t.texSize)+";\n this.output = "+JSON.stringify(t.output)+";\n this.compiledFragShaderString = `"+t.compiledFragShaderString+"`;\n\t\t this.compiledVertShaderString = `"+t.compiledVertShaderString+"`;\n\t\t this.programUniformLocationCache = {};\n\t\t this.textureCache = {};\n\t\t this.subKernelOutputTextures = null;\n\t\t this.subKernelOutputVariableNames = null;\n\t\t this.uniform1fCache = {};\n\t\t this.uniform1iCache = {};\n\t\t this.uniform2fCache = {};\n\t\t this.uniform2fvCache = {};\n\t\t this.uniform3fvCache = {};\n }\n "+r(t._getFragShaderString.toString())+"\n "+r(t._getVertShaderString.toString())+"\n validateOptions() {}\n setupParams() {}\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n "+r(t.getUniformLocation.toString())+"\n "+r(t.setupParams.toString())+"\n "+r(t.build.toString())+"\n\t\t "+r(t.run.toString())+"\n\t\t "+r(t._addArgument.toString())+"\n\t\t "+r(t.getArgumentTexture.toString())+"\n\t\t "+r(t.getTextureCache.toString())+"\n\t\t "+r(t.getOutputTexture.toString())+"\n\t\t "+r(t.renderOutput.toString())+"\n\t\t "+r(t.updateMaxTexSize.toString())+"\n\t\t "+r(t._setupOutputTexture.toString())+"\n\t\t "+r(t.detachTextureCache.toString())+"\n\t\t "+r(t.setUniform1f.toString())+"\n\t\t "+r(t.setUniform1i.toString())+"\n\t\t "+r(t.setUniform2f.toString())+"\n\t\t "+r(t.setUniform2fv.toString())+"\n\t\t "+r(t.setUniform3fv.toString())+" \n };\n return kernelRunShortcut(new Kernel());\n };"}},{"../../core/utils":32,"../kernel-run-shortcut":9}],14:[function(t,e,n){function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var a=function(){function t(t,e){for(var n=0;n0&&this._setupSubOutputTextures(this.subKernelOutputVariableNames.length))}},{key:"run",value:function(){null===this.program&&this.build.apply(this,arguments);var t=this.paramNames,e=this.paramTypes,n=this.texSize,r=this._webGl;r.useProgram(this.program),r.scissor(0,0,n[0],n[1]),this.hardcodeConstants||(this.setUniform3fv("uOutputDim",this.threadDim),this.setUniform2fv("uTexSize",n)),this.setUniform2f("ratio",n[0]/this.maxTexSize[0],n[1]/this.maxTexSize[1]),this.argumentsLength=0;for(var i=0;i0?t.join(";\n")+";\n":"\n"}},{key:"_replaceArtifacts",value:function(t,e){return t.replace(/[ ]*__([A-Z]+[0-9]*([_]?[A-Z])*)__;\n/g,function(t,n){if(e.hasOwnProperty(n))return e[n];throw"unhandled artifact "+n})}},{key:"_addKernels",value:function(){var t=this,e=this.functionBuilder,n=this._webGl;if(e.addFunctions(this.functions,{constants:this.constants,output:this.output}),e.addNativeFunctions(this.nativeFunctions),e.addKernel(this.fnString,{prototypeOnly:!1,constants:this.constants,output:this.output,debug:this.debug,loopMaxIterations:this.loopMaxIterations,paramNames:this.paramNames,paramTypes:this.paramTypes}),null!==this.subKernels){var r=this.drawBuffers=n.getExtension("WEBGL_draw_buffers");if(!r)throw new Error("could not instantiate draw buffers extension");this.subKernelOutputVariableNames=[],this.subKernels.forEach(function(e){return t._addSubKernel(e)})}else if(null!==this.subKernelProperties){var i=this.drawBuffers=n.getExtension("WEBGL_draw_buffers");if(!i)throw new Error("could not instantiate draw buffers extension");this.subKernelOutputVariableNames=[],Object.keys(this.subKernelProperties).forEach(function(e){return t._addSubKernel(t.subKernelProperties[e])})}}},{key:"_addSubKernel",value:function(t){this.functionBuilder.addSubKernel(t,{prototypeOnly:!1,constants:this.constants,output:this.output,debug:this.debug,loopMaxIterations:this.loopMaxIterations}),this.subKernelOutputVariableNames.push(t.name+"Result")}},{key:"_getFragShaderString",value:function(t){return null!==this.compiledFragShaderString?this.compiledFragShaderString:this.compiledFragShaderString=this._replaceArtifacts(this.constructor.fragShaderString,this._getFragShaderArtifactMap(t))}},{key:"_getVertShaderString",value:function(t){return null!==this.compiledVertShaderString?this.compiledVertShaderString:this.compiledVertShaderString=this.constructor.vertShaderString}},{key:"toString",value:function(){return c(this)}},{key:"addFunction",value:function(t){this.functionBuilder.addFunction(null,t)}}]),e}(o)},{"../../core/texture":30,"../../core/utils":32,"../kernel-base":8,"./kernel-string":13,"./shader-frag":16,"./shader-vert":17}],15:[function(t,e,n){function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var a=function(){function t(t,e){for(var n=0;n0&&e.push(", ");var i=this.getParamType(r);switch(i){case"Texture":case"Input":case"Array":case"HTMLImage":e.push("sampler2D");break;default:e.push("float")}e.push(" "),e.push("user_"),e.push(r)}e.push(") {\n");for(var s=0;st)return!1;if(n+=e[r+1],n>=t)return!0}}function n(t,n){return t<65?36===t:t<91||(t<97?95===t:t<123||(t<=65535?t>=170&&U.test(String.fromCharCode(t)):n!==!1&&e(t,V)))}function r(t,n){return t<48?36===t:t<58||!(t<65)&&(t<91||(t<97?95===t:t<123||(t<=65535?t>=170&&M.test(String.fromCharCode(t)):n!==!1&&(e(t,V)||e(t,j)))))}function i(t,e){return new B(t,{beforeExpr:!0,binop:e})}function s(t,e){return void 0===e&&(e={}),e.keyword=t,X[t]=new B(t,e)}function a(t){return 10===t||13===t||8232===t||8233===t}function o(t,e){return Z.call(t,e)}function u(t,e){for(var n=1,r=0;;){q.lastIndex=r;var i=q.exec(t);if(!(i&&i.index=2015&&(e.ecmaVersion-=2009),null==e.allowReserved&&(e.allowReserved=e.ecmaVersion<5),tt(e.onToken)){var r=e.onToken;e.onToken=function(t){return r.push(t)}}return tt(e.onComment)&&(e.onComment=p(e,e.onComment)),e}function p(t,e){return function(n,r,i,s,a,o){var u={type:n?"Block":"Line",value:r,start:i,end:s};t.locations&&(u.loc=new nt(this,a,o)),t.ranges&&(u.range=[i,s]),e.push(u)}}function l(t){return new RegExp("^(?:"+t.replace(/ /g,"|")+")$")}function c(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1}function f(t,e,n,r){return t.type=e,t.end=n,this.options.locations&&(t.loc.end=r),this.options.ranges&&(t.range[1]=n),t}function d(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(1023&t)+56320))}function g(t){return 36===t||t>=40&&t<=43||46===t||63===t||t>=91&&t<=94||t>=123&&t<=125}function m(t){return n(t,!0)||36===t||95===t}function y(t){return r(t,!0)||36===t||95===t||8204===t||8205===t}function x(t){return t>=65&&t<=90||t>=97&&t<=122}function v(t){return t>=0&&t<=1114111}function b(t){return 100===t||68===t||115===t||83===t||119===t||87===t}function _(t){return x(t)||95===t}function E(t){return _(t)||T(t)}function T(t){return t>=48&&t<=57}function S(t){return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function k(t){return t>=65&&t<=70?10+(t-65):t>=97&&t<=102?10+(t-97):t-48}function w(t){return t>=48&&t<=55}function A(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(1023&t)+56320))}function O(t,e){return new st(e,t).parse()}function C(t,e,n){var r=new st(n,t,e);return r.nextToken(),r.parseExpression()}function R(t,e){return new st(e,t)}function P(e,n,r){t.parse_dammit=e,t.LooseParser=n,t.pluginsLoose=r}var N={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},I="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",D={5:I,6:I+" const class extends export import super"},L=/^in(stanceof)?$/,F="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࢠ-ࢴࢶ-ࢽऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲈᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄮㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿪ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞮꞰ-ꞷꟷ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭥꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",G="‌‍·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࣔ-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍ୖୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఃా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ංඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ູົຼ່-ໍ໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠐-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭ᳲ-᳴᳷-᳹᷀-᷹᷻-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱꤀-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_",U=new RegExp("["+F+"]"),M=new RegExp("["+F+G+"]");F=G=null;var V=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,26,45,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,785,52,76,44,33,24,27,35,42,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,54,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,86,25,391,63,32,0,257,0,11,39,8,0,22,0,12,39,3,3,55,56,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,698,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,881,68,12,0,67,12,65,1,31,6124,20,754,9486,286,82,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,4149,196,60,67,1213,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42710,42,4148,12,221,3,5761,15,7472,3104,541],j=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,1306,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,52,0,13,2,49,13,10,2,4,9,83,11,7,0,161,11,6,9,7,3,57,0,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,87,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,423,9,280,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,19719,9,135,4,60,6,26,9,1016,45,17,3,19723,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,2214,6,110,6,6,9,792487,239],B=function(t,e){void 0===e&&(e={}),this.label=t,this.keyword=e.keyword,this.beforeExpr=!!e.beforeExpr,this.startsExpr=!!e.startsExpr,this.isLoop=!!e.isLoop,this.isAssign=!!e.isAssign,this.prefix=!!e.prefix,this.postfix=!!e.postfix,this.binop=e.binop||null,this.updateContext=null},z={beforeExpr:!0},K={startsExpr:!0},X={},W={num:new B("num",K),regexp:new B("regexp",K),string:new B("string",K),name:new B("name",K),eof:new B("eof"),bracketL:new B("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new B("]"),braceL:new B("{",{beforeExpr:!0,startsExpr:!0}),braceR:new B("}"),parenL:new B("(",{beforeExpr:!0,startsExpr:!0}),parenR:new B(")"),comma:new B(",",z),semi:new B(";",z),colon:new B(":",z),dot:new B("."),question:new B("?",z),arrow:new B("=>",z),template:new B("template"),invalidTemplate:new B("invalidTemplate"),ellipsis:new B("...",z),backQuote:new B("`",K),dollarBraceL:new B("${",{beforeExpr:!0,startsExpr:!0}),eq:new B("=",{beforeExpr:!0,isAssign:!0}),assign:new B("_=",{beforeExpr:!0,isAssign:!0}),incDec:new B("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new B("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:i("||",1),logicalAND:i("&&",2),bitwiseOR:i("|",3),bitwiseXOR:i("^",4),bitwiseAND:i("&",5),equality:i("==/!=/===/!==",6),relational:i("/<=/>=",7),bitShift:i("<>/>>>",8),plusMin:new B("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:i("%",10),star:i("*",10),slash:i("/",10),starstar:new B("**",{beforeExpr:!0}),_break:s("break"),_case:s("case",z),_catch:s("catch"),_continue:s("continue"),_debugger:s("debugger"),_default:s("default",z),_do:s("do",{isLoop:!0,beforeExpr:!0}),_else:s("else",z),_finally:s("finally"),_for:s("for",{isLoop:!0}),_function:s("function",K),_if:s("if"),_return:s("return",z),_switch:s("switch"),_throw:s("throw",z),_try:s("try"),_var:s("var"),_const:s("const"),_while:s("while",{isLoop:!0}),_with:s("with"),_new:s("new",{beforeExpr:!0,startsExpr:!0}),_this:s("this",K),_super:s("super",K),_class:s("class",K),_extends:s("extends",z),_export:s("export"),_import:s("import"),_null:s("null",K),_true:s("true",K),_false:s("false",K),_in:s("in",{beforeExpr:!0,binop:7}),_instanceof:s("instanceof",{beforeExpr:!0,binop:7}),_typeof:s("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:s("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:s("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},H=/\r\n?|\n|\u2028|\u2029/,q=new RegExp(H.source,"g"),Y=/[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/,J=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,Q=Object.prototype,Z=Q.hasOwnProperty,$=Q.toString,tt=Array.isArray||function(t){return"[object Array]"===$.call(t)},et=function(t,e){this.line=t,this.column=e};et.prototype.offset=function(t){return new et(this.line,this.column+t)};var nt=function(t,e,n){this.start=e,this.end=n,null!==t.sourceFile&&(this.source=t.sourceFile)},rt={ecmaVersion:7,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowHashBang:!1,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1,plugins:{}},it={},st=function(t,e,n){this.options=t=h(t),this.sourceFile=t.sourceFile,this.keywords=l(D[t.ecmaVersion>=6?6:5]);var r="";if(!t.allowReserved){for(var i=t.ecmaVersion;!(r=N[i]);i--);"module"==t.sourceType&&(r+=" await")}this.reservedWords=l(r);var s=(r?r+" ":"")+N.strict;this.reservedWordsStrict=l(s),this.reservedWordsStrictBind=l(s+" "+N.strictBind),this.input=String(e),this.containsEsc=!1,this.loadPlugins(t.plugins),n?(this.pos=n,this.lineStart=this.input.lastIndexOf("\n",n-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(H).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=W.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule="module"===t.sourceType,this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.inFunction=this.inGenerator=this.inAsync=!1,this.yieldPos=this.awaitPos=0,this.labels=[],0===this.pos&&t.allowHashBang&&"#!"===this.input.slice(0,2)&&this.skipLineComment(2),this.scopeStack=[],this.enterFunctionScope(),this.regexpState=null};st.prototype.isKeyword=function(t){return this.keywords.test(t)},st.prototype.isReservedWord=function(t){return this.reservedWords.test(t)},st.prototype.extend=function(t,e){this[t]=e(this[t])},st.prototype.loadPlugins=function(t){var e=this;for(var n in t){var r=it[n];if(!r)throw new Error("Plugin '"+n+"' not found");r(e,t[n])}},st.prototype.parse=function(){var t=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(t)};var at=st.prototype,ot=/^(?:'((?:\\.|[^'])*?)'|"((?:\\.|[^"])*?)"|;)/;at.strictDirective=function(t){for(var e=this;;){J.lastIndex=t,t+=J.exec(e.input)[0].length;var n=ot.exec(e.input.slice(t));if(!n)return!1;if("use strict"==(n[1]||n[2]))return!0;t+=n[0].length}},at.eat=function(t){return this.type===t&&(this.next(),!0)},at.isContextual=function(t){return this.type===W.name&&this.value===t&&!this.containsEsc},at.eatContextual=function(t){return!!this.isContextual(t)&&(this.next(),!0)},at.expectContextual=function(t){this.eatContextual(t)||this.unexpected()},at.canInsertSemicolon=function(){return this.type===W.eof||this.type===W.braceR||H.test(this.input.slice(this.lastTokEnd,this.start))},at.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},at.semicolon=function(){this.eat(W.semi)||this.insertSemicolon()||this.unexpected()},at.afterTrailingComma=function(t,e){if(this.type==t)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),e||this.next(),!0},at.expect=function(t){this.eat(t)||this.unexpected()},at.unexpected=function(t){this.raise(null!=t?t:this.start,"Unexpected token")},at.checkPatternErrors=function(t,e){if(t){t.trailingComma>-1&&this.raiseRecoverable(t.trailingComma,"Comma is not permitted after the rest element");var n=e?t.parenthesizedAssign:t.parenthesizedBind;n>-1&&this.raiseRecoverable(n,"Parenthesized pattern")}},at.checkExpressionErrors=function(t,e){if(!t)return!1;var n=t.shorthandAssign,r=t.doubleProto;return e?(n>=0&&this.raise(n,"Shorthand property assignments are valid only in destructuring patterns"),void(r>=0&&this.raiseRecoverable(r,"Redefinition of __proto__ property"))):n>=0||r>=0},at.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos=6&&(t.sourceType=this.options.sourceType),this.finishNode(t,"Program")};var ht={kind:"loop"},pt={kind:"switch"};ut.isLet=function(){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;J.lastIndex=this.pos;var t=J.exec(this.input),e=this.pos+t[0].length,i=this.input.charCodeAt(e);if(91===i||123==i)return!0;if(n(i,!0)){for(var s=e+1;r(this.input.charCodeAt(s),!0);)++s;var a=this.input.slice(e,s);if(!L.test(a))return!0}return!1},ut.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;J.lastIndex=this.pos;var t=J.exec(this.input),e=this.pos+t[0].length;return!(H.test(this.input.slice(this.pos,e))||"function"!==this.input.slice(e,e+8)||e+8!=this.input.length&&r(this.input.charAt(e+8)))},ut.parseStatement=function(t,e,n){var r,i=this.type,s=this.startNode();switch(this.isLet()&&(i=W._var,r="let"),i){case W._break:case W._continue:return this.parseBreakContinueStatement(s,i.keyword);case W._debugger:return this.parseDebuggerStatement(s);case W._do:return this.parseDoStatement(s);case W._for:return this.parseForStatement(s);case W._function:return!t&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(s,!1);case W._class:return t||this.unexpected(),this.parseClass(s,!0);case W._if:return this.parseIfStatement(s);case W._return:return this.parseReturnStatement(s);case W._switch:return this.parseSwitchStatement(s);case W._throw:return this.parseThrowStatement(s);case W._try:return this.parseTryStatement(s);case W._const:case W._var:return r=r||this.value,t||"var"==r||this.unexpected(),this.parseVarStatement(s,r);case W._while:return this.parseWhileStatement(s);case W._with:return this.parseWithStatement(s);case W.braceL:return this.parseBlock();case W.semi:return this.parseEmptyStatement(s);case W._export:case W._import:return this.options.allowImportExportEverywhere||(e||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),i===W._import?this.parseImport(s):this.parseExport(s,n);default:if(this.isAsyncFunction())return t||this.unexpected(),this.next(),this.parseFunctionStatement(s,!0);var a=this.value,o=this.parseExpression();return i===W.name&&"Identifier"===o.type&&this.eat(W.colon)?this.parseLabeledStatement(s,a,o):this.parseExpressionStatement(s,o)}},ut.parseBreakContinueStatement=function(t,e){var n=this,r="break"==e;this.next(),this.eat(W.semi)||this.insertSemicolon()?t.label=null:this.type!==W.name?this.unexpected():(t.label=this.parseIdent(),this.semicolon());for(var i=0;i=6?this.eat(W.semi):this.semicolon(),this.finishNode(t,"DoWhileStatement")},ut.parseForStatement=function(t){this.next();var e=this.options.ecmaVersion>=9&&this.inAsync&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(ht),this.enterLexicalScope(),this.expect(W.parenL),this.type===W.semi)return e>-1&&this.unexpected(e),this.parseFor(t,null);var n=this.isLet();if(this.type===W._var||this.type===W._const||n){var r=this.startNode(),i=n?"let":this.value;return this.next(),this.parseVar(r,!0,i),this.finishNode(r,"VariableDeclaration"),!(this.type===W._in||this.options.ecmaVersion>=6&&this.isContextual("of"))||1!==r.declarations.length||"var"!==i&&r.declarations[0].init?(e>-1&&this.unexpected(e),this.parseFor(t,r)):(this.options.ecmaVersion>=9&&(this.type===W._in?e>-1&&this.unexpected(e):t.await=e>-1),this.parseForIn(t,r))}var s=new c,a=this.parseExpression(!0,s);return this.type===W._in||this.options.ecmaVersion>=6&&this.isContextual("of")?(this.options.ecmaVersion>=9&&(this.type===W._in?e>-1&&this.unexpected(e):t.await=e>-1),this.toAssignable(a,!1,s),this.checkLVal(a),this.parseForIn(t,a)):(this.checkExpressionErrors(s,!0),e>-1&&this.unexpected(e),this.parseFor(t,a))},ut.parseFunctionStatement=function(t,e){return this.next(),this.parseFunction(t,!0,!1,e)},ut.parseIfStatement=function(t){return this.next(),t.test=this.parseParenExpression(),t.consequent=this.parseStatement(!this.strict&&this.type==W._function),t.alternate=this.eat(W._else)?this.parseStatement(!this.strict&&this.type==W._function):null,this.finishNode(t,"IfStatement")},ut.parseReturnStatement=function(t){return this.inFunction||this.options.allowReturnOutsideFunction||this.raise(this.start,"'return' outside of function"),this.next(),this.eat(W.semi)||this.insertSemicolon()?t.argument=null:(t.argument=this.parseExpression(),this.semicolon()),this.finishNode(t,"ReturnStatement")},ut.parseSwitchStatement=function(t){var e=this;this.next(),t.discriminant=this.parseParenExpression(),t.cases=[],this.expect(W.braceL),this.labels.push(pt),this.enterLexicalScope();for(var n,r=!1;this.type!=W.braceR;)if(e.type===W._case||e.type===W._default){var i=e.type===W._case;n&&e.finishNode(n,"SwitchCase"),t.cases.push(n=e.startNode()),n.consequent=[],e.next(),i?n.test=e.parseExpression():(r&&e.raiseRecoverable(e.lastTokStart,"Multiple default clauses"),r=!0,n.test=null),e.expect(W.colon)}else n||e.unexpected(),n.consequent.push(e.parseStatement(!0));return this.exitLexicalScope(),n&&this.finishNode(n,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(t,"SwitchStatement")},ut.parseThrowStatement=function(t){return this.next(),H.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),t.argument=this.parseExpression(),this.semicolon(),this.finishNode(t,"ThrowStatement")};var lt=[];ut.parseTryStatement=function(t){if(this.next(),t.block=this.parseBlock(),t.handler=null,this.type===W._catch){var e=this.startNode();this.next(),this.expect(W.parenL),e.param=this.parseBindingAtom(),this.enterLexicalScope(),this.checkLVal(e.param,"let"),this.expect(W.parenR),e.body=this.parseBlock(!1),this.exitLexicalScope(),t.handler=this.finishNode(e,"CatchClause")}return t.finalizer=this.eat(W._finally)?this.parseBlock():null,t.handler||t.finalizer||this.raise(t.start,"Missing catch or finally clause"),this.finishNode(t,"TryStatement")},ut.parseVarStatement=function(t,e){return this.next(),this.parseVar(t,!1,e),this.semicolon(),this.finishNode(t,"VariableDeclaration")},ut.parseWhileStatement=function(t){return this.next(),t.test=this.parseParenExpression(),this.labels.push(ht),t.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(t,"WhileStatement")},ut.parseWithStatement=function(t){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),t.object=this.parseParenExpression(),t.body=this.parseStatement(!1),this.finishNode(t,"WithStatement")},ut.parseEmptyStatement=function(t){return this.next(),this.finishNode(t,"EmptyStatement")},ut.parseLabeledStatement=function(t,e,n){for(var r=this,i=0,s=r.labels;i=0;u--){var h=r.labels[u];if(h.statementStart!=t.start)break;h.statementStart=r.start,h.kind=o}return this.labels.push({name:e,kind:o,statementStart:this.start}),t.body=this.parseStatement(!0),("ClassDeclaration"==t.body.type||"VariableDeclaration"==t.body.type&&"var"!=t.body.kind||"FunctionDeclaration"==t.body.type&&(this.strict||t.body.generator))&&this.raiseRecoverable(t.body.start,"Invalid labeled declaration"),this.labels.pop(),t.label=n,this.finishNode(t,"LabeledStatement")},ut.parseExpressionStatement=function(t,e){return t.expression=e,this.semicolon(),this.finishNode(t,"ExpressionStatement")},ut.parseBlock=function(t){var e=this;void 0===t&&(t=!0);var n=this.startNode();for(n.body=[],this.expect(W.braceL),t&&this.enterLexicalScope();!this.eat(W.braceR);){var r=e.parseStatement(!0);n.body.push(r)}return t&&this.exitLexicalScope(),this.finishNode(n,"BlockStatement")},ut.parseFor=function(t,e){return t.init=e,this.expect(W.semi),t.test=this.type===W.semi?null:this.parseExpression(),this.expect(W.semi),t.update=this.type===W.parenR?null:this.parseExpression(),this.expect(W.parenR),this.exitLexicalScope(),t.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(t,"ForStatement")},ut.parseForIn=function(t,e){var n=this.type===W._in?"ForInStatement":"ForOfStatement";return this.next(),"ForInStatement"==n&&("AssignmentPattern"===e.type||"VariableDeclaration"===e.type&&null!=e.declarations[0].init&&(this.strict||"Identifier"!==e.declarations[0].id.type))&&this.raise(e.start,"Invalid assignment in for-in loop head"),t.left=e,t.right="ForInStatement"==n?this.parseExpression():this.parseMaybeAssign(),this.expect(W.parenR),this.exitLexicalScope(),t.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(t,n)},ut.parseVar=function(t,e,n){var r=this;for(t.declarations=[],t.kind=n;;){var i=r.startNode();if(r.parseVarId(i,n),r.eat(W.eq)?i.init=r.parseMaybeAssign(e):"const"!==n||r.type===W._in||r.options.ecmaVersion>=6&&r.isContextual("of")?"Identifier"==i.id.type||e&&(r.type===W._in||r.isContextual("of"))?i.init=null:r.raise(r.lastTokEnd,"Complex binding patterns require an initialization value"):r.unexpected(),t.declarations.push(r.finishNode(i,"VariableDeclarator")),!r.eat(W.comma))break}return t},ut.parseVarId=function(t,e){t.id=this.parseBindingAtom(e),this.checkLVal(t.id,e,!1)},ut.parseFunction=function(t,e,n,r){this.initFunction(t),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(t.generator=this.eat(W.star)),this.options.ecmaVersion>=8&&(t.async=!!r),e&&(t.id="nullableID"===e&&this.type!=W.name?null:this.parseIdent(),t.id&&this.checkLVal(t.id,"var"));var i=this.inGenerator,s=this.inAsync,a=this.yieldPos,o=this.awaitPos,u=this.inFunction;return this.inGenerator=t.generator,this.inAsync=t.async,this.yieldPos=0,this.awaitPos=0,this.inFunction=!0,this.enterFunctionScope(),e||(t.id=this.type==W.name?this.parseIdent():null),this.parseFunctionParams(t),this.parseFunctionBody(t,n),this.inGenerator=i,this.inAsync=s,this.yieldPos=a,this.awaitPos=o,this.inFunction=u,this.finishNode(t,e?"FunctionDeclaration":"FunctionExpression")},ut.parseFunctionParams=function(t){this.expect(W.parenL),t.params=this.parseBindingList(W.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},ut.parseClass=function(t,e){var n=this;this.next(),this.parseClassId(t,e),this.parseClassSuper(t);var r=this.startNode(),i=!1;for(r.body=[],this.expect(W.braceL);!this.eat(W.braceR);){var s=n.parseClassMember(r);s&&"MethodDefinition"===s.type&&"constructor"===s.kind&&(i&&n.raise(s.start,"Duplicate constructor in the same class"),i=!0)}return t.body=this.finishNode(r,"ClassBody"),this.finishNode(t,e?"ClassDeclaration":"ClassExpression")},ut.parseClassMember=function(t){var e=this;if(this.eat(W.semi))return null;var n=this.startNode(),r=function(t,r){void 0===r&&(r=!1);var i=e.start,s=e.startLoc;return!!e.eatContextual(t)&&(!(e.type===W.parenL||r&&e.canInsertSemicolon())||(n.key&&e.unexpected(),n.computed=!1,n.key=e.startNodeAt(i,s),n.key.name=t,e.finishNode(n.key,"Identifier"),!1))};n.kind="method",n["static"]=r("static");var i=this.eat(W.star),s=!1;i||(this.options.ecmaVersion>=8&&r("async",!0)?(s=!0,i=this.options.ecmaVersion>=9&&this.eat(W.star)):r("get")?n.kind="get":r("set")&&(n.kind="set")),n.key||this.parsePropertyName(n);var a=n.key;return n.computed||n["static"]||!("Identifier"===a.type&&"constructor"===a.name||"Literal"===a.type&&"constructor"===a.value)?n["static"]&&"Identifier"===a.type&&"prototype"===a.name&&this.raise(a.start,"Classes may not have a static property named prototype"):("method"!==n.kind&&this.raise(a.start,"Constructor can't have get/set modifier"),i&&this.raise(a.start,"Constructor can't be a generator"),s&&this.raise(a.start,"Constructor can't be an async method"),n.kind="constructor"),this.parseClassMethod(t,n,i,s),"get"===n.kind&&0!==n.value.params.length&&this.raiseRecoverable(n.value.start,"getter should have no params"),"set"===n.kind&&1!==n.value.params.length&&this.raiseRecoverable(n.value.start,"setter should have exactly one param"),"set"===n.kind&&"RestElement"===n.value.params[0].type&&this.raiseRecoverable(n.value.params[0].start,"Setter cannot use rest params"),n},ut.parseClassMethod=function(t,e,n,r){e.value=this.parseMethod(n,r),t.body.push(this.finishNode(e,"MethodDefinition"))},ut.parseClassId=function(t,e){t.id=this.type===W.name?this.parseIdent():e===!0?this.unexpected():null},ut.parseClassSuper=function(t){t.superClass=this.eat(W._extends)?this.parseExprSubscripts():null},ut.parseExport=function(t,e){var n=this;if(this.next(),this.eat(W.star))return this.expectContextual("from"),this.type!==W.string&&this.unexpected(),t.source=this.parseExprAtom(),this.semicolon(),this.finishNode(t,"ExportAllDeclaration");if(this.eat(W._default)){this.checkExport(e,"default",this.lastTokStart);var r;if(this.type===W._function||(r=this.isAsyncFunction())){var i=this.startNode();this.next(),r&&this.next(),t.declaration=this.parseFunction(i,"nullableID",!1,r)}else if(this.type===W._class){var s=this.startNode();t.declaration=this.parseClass(s,"nullableID")}else t.declaration=this.parseMaybeAssign(),this.semicolon();return this.finishNode(t,"ExportDefaultDeclaration")}if(this.shouldParseExportStatement())t.declaration=this.parseStatement(!0),"VariableDeclaration"===t.declaration.type?this.checkVariableExport(e,t.declaration.declarations):this.checkExport(e,t.declaration.id.name,t.declaration.id.start),t.specifiers=[],t.source=null;else{if(t.declaration=null,t.specifiers=this.parseExportSpecifiers(e),this.eatContextual("from"))this.type!==W.string&&this.unexpected(),t.source=this.parseExprAtom();else{for(var a=0,o=t.specifiers;a=6&&t)switch(t.type){case"Identifier":this.inAsync&&"await"===t.name&&this.raise(t.start,"Can not use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"RestElement":break;case"ObjectExpression":t.type="ObjectPattern",n&&this.checkPatternErrors(n,!0);for(var i=0,s=t.properties;i=9&&"SpreadElement"===t.type||this.options.ecmaVersion>=6&&(t.computed||t.method||t.shorthand))){var r,i=t.key;switch(i.type){case"Identifier":r=i.name;break;case"Literal":r=String(i.value);break;default:return}var s=t.kind;if(this.options.ecmaVersion>=6)return void("__proto__"===r&&"init"===s&&(e.proto&&(n&&n.doubleProto<0?n.doubleProto=i.start:this.raiseRecoverable(i.start,"Redefinition of __proto__ property")),e.proto=!0));r="$"+r;var a=e[r];if(a){var o;o="init"===s?this.strict&&a.init||a.get||a.set:a.init||a[s],o&&this.raiseRecoverable(i.start,"Redefinition of property")}else a=e[r]={init:!1,get:!1,set:!1};a[s]=!0}},ft.parseExpression=function(t,e){var n=this,r=this.start,i=this.startLoc,s=this.parseMaybeAssign(t,e);if(this.type===W.comma){var a=this.startNodeAt(r,i);for(a.expressions=[s];this.eat(W.comma);)a.expressions.push(n.parseMaybeAssign(t,e));return this.finishNode(a,"SequenceExpression")}return s},ft.parseMaybeAssign=function(t,e,n){if(this.inGenerator&&this.isContextual("yield"))return this.parseYield();var r=!1,i=-1,s=-1;e?(i=e.parenthesizedAssign,s=e.trailingComma,e.parenthesizedAssign=e.trailingComma=-1):(e=new c,r=!0);var a=this.start,o=this.startLoc;this.type!=W.parenL&&this.type!=W.name||(this.potentialArrowAt=this.start);var u=this.parseMaybeConditional(t,e);if(n&&(u=n.call(this,u,a,o)),this.type.isAssign){var h=this.startNodeAt(a,o);return h.operator=this.value,h.left=this.type===W.eq?this.toAssignable(u,!1,e):u,r||c.call(e),e.shorthandAssign=-1,this.checkLVal(u),this.next(),h.right=this.parseMaybeAssign(t),this.finishNode(h,"AssignmentExpression")}return r&&this.checkExpressionErrors(e,!0),i>-1&&(e.parenthesizedAssign=i),s>-1&&(e.trailingComma=s),u},ft.parseMaybeConditional=function(t,e){var n=this.start,r=this.startLoc,i=this.parseExprOps(t,e);if(this.checkExpressionErrors(e))return i;if(this.eat(W.question)){var s=this.startNodeAt(n,r);return s.test=i,s.consequent=this.parseMaybeAssign(),this.expect(W.colon),s.alternate=this.parseMaybeAssign(t),this.finishNode(s,"ConditionalExpression")}return i},ft.parseExprOps=function(t,e){var n=this.start,r=this.startLoc,i=this.parseMaybeUnary(e,!1);return this.checkExpressionErrors(e)?i:i.start==n&&"ArrowFunctionExpression"===i.type?i:this.parseExprOp(i,n,r,-1,t)},ft.parseExprOp=function(t,e,n,r,i){var s=this.type.binop;if(null!=s&&(!i||this.type!==W._in)&&s>r){var a=this.type===W.logicalOR||this.type===W.logicalAND,o=this.value;this.next();var u=this.start,h=this.startLoc,p=this.parseExprOp(this.parseMaybeUnary(null,!1),u,h,s,i),l=this.buildBinary(e,n,t,p,o,a);return this.parseExprOp(l,e,n,r,i)}return t},ft.buildBinary=function(t,e,n,r,i,s){var a=this.startNodeAt(t,e);return a.left=n,a.operator=i,a.right=r,this.finishNode(a,s?"LogicalExpression":"BinaryExpression")},ft.parseMaybeUnary=function(t,e){var n,r=this,i=this.start,s=this.startLoc;if(this.inAsync&&this.isContextual("await"))n=this.parseAwait(),e=!0;else if(this.type.prefix){var a=this.startNode(),o=this.type===W.incDec;a.operator=this.value,a.prefix=!0,this.next(),a.argument=this.parseMaybeUnary(null,!0),this.checkExpressionErrors(t,!0),o?this.checkLVal(a.argument):this.strict&&"delete"===a.operator&&"Identifier"===a.argument.type?this.raiseRecoverable(a.start,"Deleting local variable in strict mode"):e=!0,n=this.finishNode(a,o?"UpdateExpression":"UnaryExpression")}else{if(n=this.parseExprSubscripts(t),this.checkExpressionErrors(t))return n;for(;this.type.postfix&&!this.canInsertSemicolon();){var u=r.startNodeAt(i,s);u.operator=r.value,u.prefix=!1,u.argument=n,r.checkLVal(n),r.next(),n=r.finishNode(u,"UpdateExpression")}}return!e&&this.eat(W.starstar)?this.buildBinary(i,s,n,this.parseMaybeUnary(null,!1),"**",!1):n},ft.parseExprSubscripts=function(t){var e=this.start,n=this.startLoc,r=this.parseExprAtom(t),i="ArrowFunctionExpression"===r.type&&")"!==this.input.slice(this.lastTokStart,this.lastTokEnd);if(this.checkExpressionErrors(t)||i)return r;var s=this.parseSubscripts(r,e,n);return t&&"MemberExpression"===s.type&&(t.parenthesizedAssign>=s.start&&(t.parenthesizedAssign=-1),t.parenthesizedBind>=s.start&&(t.parenthesizedBind=-1)),s},ft.parseSubscripts=function(t,e,n,r){for(var i=this,s=this.options.ecmaVersion>=8&&"Identifier"===t.type&&"async"===t.name&&this.lastTokEnd==t.end&&!this.canInsertSemicolon()&&"async"===this.input.slice(t.start,t.end),a=void 0;;)if((a=i.eat(W.bracketL))||i.eat(W.dot)){var o=i.startNodeAt(e,n);o.object=t,o.property=a?i.parseExpression():i.parseIdent(!0),o.computed=!!a,a&&i.expect(W.bracketR),t=i.finishNode(o,"MemberExpression")}else if(!r&&i.eat(W.parenL)){var u=new c,h=i.yieldPos,p=i.awaitPos;i.yieldPos=0,i.awaitPos=0;var l=i.parseExprList(W.parenR,i.options.ecmaVersion>=8,!1,u);if(s&&!i.canInsertSemicolon()&&i.eat(W.arrow))return i.checkPatternErrors(u,!1),i.checkYieldAwaitInDefaultParams(),i.yieldPos=h,i.awaitPos=p,i.parseArrowExpression(i.startNodeAt(e,n),l,!0);i.checkExpressionErrors(u,!0),i.yieldPos=h||i.yieldPos,i.awaitPos=p||i.awaitPos;var f=i.startNodeAt(e,n);f.callee=t,f.arguments=l,t=i.finishNode(f,"CallExpression")}else{if(i.type!==W.backQuote)return t;var d=i.startNodeAt(e,n);d.tag=t,d.quasi=i.parseTemplate({isTagged:!0}),t=i.finishNode(d,"TaggedTemplateExpression")}},ft.parseExprAtom=function(t){var e,n=this.potentialArrowAt==this.start;switch(this.type){case W._super:return this.inFunction||this.raise(this.start,"'super' outside of function or class"),e=this.startNode(),this.next(),this.type!==W.dot&&this.type!==W.bracketL&&this.type!==W.parenL&&this.unexpected(),this.finishNode(e,"Super");case W._this:return e=this.startNode(),this.next(),this.finishNode(e,"ThisExpression");case W.name:var r=this.start,i=this.startLoc,s=this.containsEsc,a=this.parseIdent(this.type!==W.name);if(this.options.ecmaVersion>=8&&!s&&"async"===a.name&&!this.canInsertSemicolon()&&this.eat(W._function))return this.parseFunction(this.startNodeAt(r,i),!1,!1,!0);if(n&&!this.canInsertSemicolon()){if(this.eat(W.arrow))return this.parseArrowExpression(this.startNodeAt(r,i),[a],!1);if(this.options.ecmaVersion>=8&&"async"===a.name&&this.type===W.name&&!s)return a=this.parseIdent(),!this.canInsertSemicolon()&&this.eat(W.arrow)||this.unexpected(),this.parseArrowExpression(this.startNodeAt(r,i),[a],!0)}return a;case W.regexp:var o=this.value;return e=this.parseLiteral(o.value),e.regex={pattern:o.pattern,flags:o.flags},e;case W.num:case W.string:return this.parseLiteral(this.value);case W._null:case W._true:case W._false:return e=this.startNode(),e.value=this.type===W._null?null:this.type===W._true,e.raw=this.type.keyword,this.next(),this.finishNode(e,"Literal");case W.parenL:var u=this.start,h=this.parseParenAndDistinguishExpression(n);return t&&(t.parenthesizedAssign<0&&!this.isSimpleAssignTarget(h)&&(t.parenthesizedAssign=u),t.parenthesizedBind<0&&(t.parenthesizedBind=u)),h;case W.bracketL:return e=this.startNode(),this.next(),e.elements=this.parseExprList(W.bracketR,!0,!0,t),this.finishNode(e,"ArrayExpression");case W.braceL:return this.parseObj(!1,t);case W._function:return e=this.startNode(),this.next(),this.parseFunction(e,!1);case W._class:return this.parseClass(this.startNode(),!1);case W._new:return this.parseNew();case W.backQuote:return this.parseTemplate();default:this.unexpected()}},ft.parseLiteral=function(t){var e=this.startNode();return e.value=t,e.raw=this.input.slice(this.start,this.end),this.next(),this.finishNode(e,"Literal")},ft.parseParenExpression=function(){this.expect(W.parenL);var t=this.parseExpression();return this.expect(W.parenR),t},ft.parseParenAndDistinguishExpression=function(t){var e,n=this,r=this.start,i=this.startLoc,s=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var a,o=this.start,u=this.startLoc,h=[],p=!0,l=!1,f=new c,d=this.yieldPos,g=this.awaitPos;for(this.yieldPos=0,this.awaitPos=0;this.type!==W.parenR;){if(p?p=!1:n.expect(W.comma),s&&n.afterTrailingComma(W.parenR,!0)){l=!0;break}if(n.type===W.ellipsis){a=n.start,h.push(n.parseParenItem(n.parseRestBinding())),n.type===W.comma&&n.raise(n.start,"Comma is not permitted after the rest element");break}h.push(n.parseMaybeAssign(!1,f,n.parseParenItem))}var m=this.start,y=this.startLoc;if(this.expect(W.parenR),t&&!this.canInsertSemicolon()&&this.eat(W.arrow))return this.checkPatternErrors(f,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=d,this.awaitPos=g,this.parseParenArrowList(r,i,h);h.length&&!l||this.unexpected(this.lastTokStart),a&&this.unexpected(a),this.checkExpressionErrors(f,!0),this.yieldPos=d||this.yieldPos,this.awaitPos=g||this.awaitPos,h.length>1?(e=this.startNodeAt(o,u),e.expressions=h,this.finishNodeAt(e,"SequenceExpression",m,y)):e=h[0]}else e=this.parseParenExpression();if(this.options.preserveParens){var x=this.startNodeAt(r,i);return x.expression=e,this.finishNode(x,"ParenthesizedExpression")}return e},ft.parseParenItem=function(t){return t},ft.parseParenArrowList=function(t,e,n){return this.parseArrowExpression(this.startNodeAt(t,e),n)};var dt=[];ft.parseNew=function(){var t=this.startNode(),e=this.parseIdent(!0);if(this.options.ecmaVersion>=6&&this.eat(W.dot)){t.meta=e;var n=this.containsEsc;return t.property=this.parseIdent(!0),("target"!==t.property.name||n)&&this.raiseRecoverable(t.property.start,"The only valid meta property for new is new.target"),this.inFunction||this.raiseRecoverable(t.start,"new.target can only be used in functions"),this.finishNode(t,"MetaProperty")}var r=this.start,i=this.startLoc;return t.callee=this.parseSubscripts(this.parseExprAtom(),r,i,!0),this.eat(W.parenL)?t.arguments=this.parseExprList(W.parenR,this.options.ecmaVersion>=8,!1):t.arguments=dt,this.finishNode(t,"NewExpression")},ft.parseTemplateElement=function(t){var e=t.isTagged,n=this.startNode();return this.type===W.invalidTemplate?(e||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),n.value={raw:this.value,cooked:null}):n.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,"\n"),cooked:this.value},this.next(),n.tail=this.type===W.backQuote,this.finishNode(n,"TemplateElement")},ft.parseTemplate=function(t){var e=this;void 0===t&&(t={});var n=t.isTagged;void 0===n&&(n=!1);var r=this.startNode();this.next(),r.expressions=[];var i=this.parseTemplateElement({isTagged:n});for(r.quasis=[i];!i.tail;)e.expect(W.dollarBraceL),r.expressions.push(e.parseExpression()),e.expect(W.braceR),r.quasis.push(i=e.parseTemplateElement({isTagged:n}));return this.next(),this.finishNode(r,"TemplateLiteral")},ft.isAsyncProp=function(t){return!t.computed&&"Identifier"===t.key.type&&"async"===t.key.name&&(this.type===W.name||this.type===W.num||this.type===W.string||this.type===W.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===W.star)&&!H.test(this.input.slice(this.lastTokEnd,this.start))},ft.parseObj=function(t,e){var n=this,r=this.startNode(),i=!0,s={};for(r.properties=[],this.next();!this.eat(W.braceR);){if(i)i=!1;else if(n.expect(W.comma),n.afterTrailingComma(W.braceR))break;var a=n.parseProperty(t,e);t||n.checkPropClash(a,s,e),r.properties.push(a)}return this.finishNode(r,t?"ObjectPattern":"ObjectExpression")},ft.parseProperty=function(t,e){var n,r,i,s,a=this.startNode();if(this.options.ecmaVersion>=9&&this.eat(W.ellipsis))return t?(a.argument=this.parseIdent(!1),this.type===W.comma&&this.raise(this.start,"Comma is not permitted after the rest element"),this.finishNode(a,"RestElement")):(this.type===W.parenL&&e&&(e.parenthesizedAssign<0&&(e.parenthesizedAssign=this.start),e.parenthesizedBind<0&&(e.parenthesizedBind=this.start)),a.argument=this.parseMaybeAssign(!1,e),this.type===W.comma&&e&&e.trailingComma<0&&(e.trailingComma=this.start),this.finishNode(a,"SpreadElement"));this.options.ecmaVersion>=6&&(a.method=!1,a.shorthand=!1,(t||e)&&(i=this.start,s=this.startLoc),t||(n=this.eat(W.star)));var o=this.containsEsc;return this.parsePropertyName(a),!t&&!o&&this.options.ecmaVersion>=8&&!n&&this.isAsyncProp(a)?(r=!0,n=this.options.ecmaVersion>=9&&this.eat(W.star),this.parsePropertyName(a,e)):r=!1,this.parsePropertyValue(a,t,n,r,i,s,e,o),this.finishNode(a,"Property")},ft.parsePropertyValue=function(t,e,n,r,i,s,a,o){if((n||r)&&this.type===W.colon&&this.unexpected(),this.eat(W.colon))t.value=e?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,a),t.kind="init";else if(this.options.ecmaVersion>=6&&this.type===W.parenL)e&&this.unexpected(),t.kind="init",t.method=!0,t.value=this.parseMethod(n,r);else if(e||o||!(this.options.ecmaVersion>=5)||t.computed||"Identifier"!==t.key.type||"get"!==t.key.name&&"set"!==t.key.name||this.type==W.comma||this.type==W.braceR)this.options.ecmaVersion>=6&&!t.computed&&"Identifier"===t.key.type?(this.checkUnreserved(t.key),t.kind="init",e?t.value=this.parseMaybeDefault(i,s,t.key):this.type===W.eq&&a?(a.shorthandAssign<0&&(a.shorthandAssign=this.start),t.value=this.parseMaybeDefault(i,s,t.key)):t.value=t.key,t.shorthand=!0):this.unexpected();else{(n||r)&&this.unexpected(),t.kind=t.key.name,this.parsePropertyName(t),t.value=this.parseMethod(!1);var u="get"===t.kind?0:1;if(t.value.params.length!==u){var h=t.value.start;"get"===t.kind?this.raiseRecoverable(h,"getter should have no params"):this.raiseRecoverable(h,"setter should have exactly one param")}else"set"===t.kind&&"RestElement"===t.value.params[0].type&&this.raiseRecoverable(t.value.params[0].start,"Setter cannot use rest params")}},ft.parsePropertyName=function(t){if(this.options.ecmaVersion>=6){if(this.eat(W.bracketL))return t.computed=!0,t.key=this.parseMaybeAssign(),this.expect(W.bracketR),t.key;t.computed=!1}return t.key=this.type===W.num||this.type===W.string?this.parseExprAtom():this.parseIdent(!0)},ft.initFunction=function(t){t.id=null,this.options.ecmaVersion>=6&&(t.generator=!1,t.expression=!1),this.options.ecmaVersion>=8&&(t.async=!1)},ft.parseMethod=function(t,e){var n=this.startNode(),r=this.inGenerator,i=this.inAsync,s=this.yieldPos,a=this.awaitPos,o=this.inFunction;return this.initFunction(n),this.options.ecmaVersion>=6&&(n.generator=t),this.options.ecmaVersion>=8&&(n.async=!!e),this.inGenerator=n.generator,this.inAsync=n.async,this.yieldPos=0,this.awaitPos=0,this.inFunction=!0,this.enterFunctionScope(),this.expect(W.parenL),n.params=this.parseBindingList(W.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(n,!1),this.inGenerator=r,this.inAsync=i,this.yieldPos=s,this.awaitPos=a,this.inFunction=o,this.finishNode(n,"FunctionExpression")},ft.parseArrowExpression=function(t,e,n){var r=this.inGenerator,i=this.inAsync,s=this.yieldPos,a=this.awaitPos,o=this.inFunction;return this.enterFunctionScope(),this.initFunction(t),this.options.ecmaVersion>=8&&(t.async=!!n),this.inGenerator=!1,this.inAsync=t.async,this.yieldPos=0,this.awaitPos=0,this.inFunction=!0,t.params=this.toAssignableList(e,!0),this.parseFunctionBody(t,!0),this.inGenerator=r,this.inAsync=i,this.yieldPos=s,this.awaitPos=a,this.inFunction=o,this.finishNode(t,"ArrowFunctionExpression")},ft.parseFunctionBody=function(t,e){var n=e&&this.type!==W.braceL,r=this.strict,i=!1;if(n)t.body=this.parseMaybeAssign(),t.expression=!0,this.checkParams(t,!1);else{var s=this.options.ecmaVersion>=7&&!this.isSimpleParamList(t.params);r&&!s||(i=this.strictDirective(this.end),i&&s&&this.raiseRecoverable(t.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var a=this.labels;this.labels=[],i&&(this.strict=!0),this.checkParams(t,!r&&!i&&!e&&this.isSimpleParamList(t.params)),t.body=this.parseBlock(!1),t.expression=!1,this.adaptDirectivePrologue(t.body.body),this.labels=a}this.exitFunctionScope(),this.strict&&t.id&&this.checkLVal(t.id,"none"),this.strict=r},ft.isSimpleParamList=function(t){for(var e=0,n=t;e0;)e[n]=arguments[n+1];for(var r=0,i=e;r=1;e--){var n=t.context[e];if("function"===n.token)return n.generator}return!1},Et.updateContext=function(t){var e,n=this.type;n.keyword&&t==W.dot?this.exprAllowed=!1:(e=n.updateContext)?e.call(this,t):this.exprAllowed=n.beforeExpr},W.parenR.updateContext=W.braceR.updateContext=function(){if(1==this.context.length)return void(this.exprAllowed=!0);var t=this.context.pop();t===_t.b_stat&&"function"===this.curContext().token&&(t=this.context.pop()),this.exprAllowed=!t.isExpr},W.braceL.updateContext=function(t){this.context.push(this.braceIsBlock(t)?_t.b_stat:_t.b_expr),this.exprAllowed=!0},W.dollarBraceL.updateContext=function(){this.context.push(_t.b_tmpl),this.exprAllowed=!0},W.parenL.updateContext=function(t){var e=t===W._if||t===W._for||t===W._with||t===W._while;this.context.push(e?_t.p_stat:_t.p_expr),this.exprAllowed=!0},W.incDec.updateContext=function(){},W._function.updateContext=W._class.updateContext=function(t){t.beforeExpr&&t!==W.semi&&t!==W._else&&(t!==W.colon&&t!==W.braceL||this.curContext()!==_t.b_stat)?this.context.push(_t.f_expr):this.context.push(_t.f_stat),this.exprAllowed=!1},W.backQuote.updateContext=function(){this.curContext()===_t.q_tmpl?this.context.pop():this.context.push(_t.q_tmpl),this.exprAllowed=!1},W.star.updateContext=function(t){if(t==W._function){var e=this.context.length-1;this.context[e]===_t.f_expr?this.context[e]=_t.f_expr_gen:this.context[e]=_t.f_gen}this.exprAllowed=!0},W.name.updateContext=function(t){var e=!1;this.options.ecmaVersion>=6&&("of"==this.value&&!this.exprAllowed||"yield"==this.value&&this.inGeneratorContext())&&(e=!0),this.exprAllowed=e};var Tt={$LONE:["ASCII","ASCII_Hex_Digit","AHex","Alphabetic","Alpha","Any","Assigned","Bidi_Control","Bidi_C","Bidi_Mirrored","Bidi_M","Case_Ignorable","CI","Cased","Changes_When_Casefolded","CWCF","Changes_When_Casemapped","CWCM","Changes_When_Lowercased","CWL","Changes_When_NFKC_Casefolded","CWKCF","Changes_When_Titlecased","CWT","Changes_When_Uppercased","CWU","Dash","Default_Ignorable_Code_Point","DI","Deprecated","Dep","Diacritic","Dia","Emoji","Emoji_Component","Emoji_Modifier","Emoji_Modifier_Base","Emoji_Presentation","Extender","Ext","Grapheme_Base","Gr_Base","Grapheme_Extend","Gr_Ext","Hex_Digit","Hex","IDS_Binary_Operator","IDSB","IDS_Trinary_Operator","IDST","ID_Continue","IDC","ID_Start","IDS","Ideographic","Ideo","Join_Control","Join_C","Logical_Order_Exception","LOE","Lowercase","Lower","Math","Noncharacter_Code_Point","NChar","Pattern_Syntax","Pat_Syn","Pattern_White_Space","Pat_WS","Quotation_Mark","QMark","Radical","Regional_Indicator","RI","Sentence_Terminal","STerm","Soft_Dotted","SD","Terminal_Punctuation","Term","Unified_Ideograph","UIdeo","Uppercase","Upper","Variation_Selector","VS","White_Space","space","XID_Continue","XIDC","XID_Start","XIDS"],General_Category:["Cased_Letter","LC","Close_Punctuation","Pe","Connector_Punctuation","Pc","Control","Cc","cntrl","Currency_Symbol","Sc","Dash_Punctuation","Pd","Decimal_Number","Nd","digit","Enclosing_Mark","Me","Final_Punctuation","Pf","Format","Cf","Initial_Punctuation","Pi","Letter","L","Letter_Number","Nl","Line_Separator","Zl","Lowercase_Letter","Ll","Mark","M","Combining_Mark","Math_Symbol","Sm","Modifier_Letter","Lm","Modifier_Symbol","Sk","Nonspacing_Mark","Mn","Number","N","Open_Punctuation","Ps","Other","C","Other_Letter","Lo","Other_Number","No","Other_Punctuation","Po","Other_Symbol","So","Paragraph_Separator","Zp","Private_Use","Co","Punctuation","P","punct","Separator","Z","Space_Separator","Zs","Spacing_Mark","Mc","Surrogate","Cs","Symbol","S","Titlecase_Letter","Lt","Unassigned","Cn","Uppercase_Letter","Lu"],Script:["Adlam","Adlm","Ahom","Anatolian_Hieroglyphs","Hluw","Arabic","Arab","Armenian","Armn","Avestan","Avst","Balinese","Bali","Bamum","Bamu","Bassa_Vah","Bass","Batak","Batk","Bengali","Beng","Bhaiksuki","Bhks","Bopomofo","Bopo","Brahmi","Brah","Braille","Brai","Buginese","Bugi","Buhid","Buhd","Canadian_Aboriginal","Cans","Carian","Cari","Caucasian_Albanian","Aghb","Chakma","Cakm","Cham","Cherokee","Cher","Common","Zyyy","Coptic","Copt","Qaac","Cuneiform","Xsux","Cypriot","Cprt","Cyrillic","Cyrl","Deseret","Dsrt","Devanagari","Deva","Duployan","Dupl","Egyptian_Hieroglyphs","Egyp","Elbasan","Elba","Ethiopic","Ethi","Georgian","Geor","Glagolitic","Glag","Gothic","Goth","Grantha","Gran","Greek","Grek","Gujarati","Gujr","Gurmukhi","Guru","Han","Hani","Hangul","Hang","Hanunoo","Hano","Hatran","Hatr","Hebrew","Hebr","Hiragana","Hira","Imperial_Aramaic","Armi","Inherited","Zinh","Qaai","Inscriptional_Pahlavi","Phli","Inscriptional_Parthian","Prti","Javanese","Java","Kaithi","Kthi","Kannada","Knda","Katakana","Kana","Kayah_Li","Kali","Kharoshthi","Khar","Khmer","Khmr","Khojki","Khoj","Khudawadi","Sind","Lao","Laoo","Latin","Latn","Lepcha","Lepc","Limbu","Limb","Linear_A","Lina","Linear_B","Linb","Lisu","Lycian","Lyci","Lydian","Lydi","Mahajani","Mahj","Malayalam","Mlym","Mandaic","Mand","Manichaean","Mani","Marchen","Marc","Masaram_Gondi","Gonm","Meetei_Mayek","Mtei","Mende_Kikakui","Mend","Meroitic_Cursive","Merc","Meroitic_Hieroglyphs","Mero","Miao","Plrd","Modi","Mongolian","Mong","Mro","Mroo","Multani","Mult","Myanmar","Mymr","Nabataean","Nbat","New_Tai_Lue","Talu","Newa","Nko","Nkoo","Nushu","Nshu","Ogham","Ogam","Ol_Chiki","Olck","Old_Hungarian","Hung","Old_Italic","Ital","Old_North_Arabian","Narb","Old_Permic","Perm","Old_Persian","Xpeo","Old_South_Arabian","Sarb","Old_Turkic","Orkh","Oriya","Orya","Osage","Osge","Osmanya","Osma","Pahawh_Hmong","Hmng","Palmyrene","Palm","Pau_Cin_Hau","Pauc","Phags_Pa","Phag","Phoenician","Phnx","Psalter_Pahlavi","Phlp","Rejang","Rjng","Runic","Runr","Samaritan","Samr","Saurashtra","Saur","Sharada","Shrd","Shavian","Shaw","Siddham","Sidd","SignWriting","Sgnw","Sinhala","Sinh","Sora_Sompeng","Sora","Soyombo","Soyo","Sundanese","Sund","Syloti_Nagri","Sylo","Syriac","Syrc","Tagalog","Tglg","Tagbanwa","Tagb","Tai_Le","Tale","Tai_Tham","Lana","Tai_Viet","Tavt","Takri","Takr","Tamil","Taml","Tangut","Tang","Telugu","Telu","Thaana","Thaa","Thai","Tibetan","Tibt","Tifinagh","Tfng","Tirhuta","Tirh","Ugaritic","Ugar","Vai","Vaii","Warang_Citi","Wara","Yi","Yiii","Zanabazar_Square","Zanb"]};Array.prototype.push.apply(Tt.$LONE,Tt.General_Category),Tt.gc=Tt.General_Category,Tt.sc=Tt.Script_Extensions=Tt.scx=Tt.Script;var St=st.prototype,kt=function(t){this.parser=t,this.validFlags="gim"+(t.options.ecmaVersion>=6?"uy":"")+(t.options.ecmaVersion>=9?"s":""),this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=[],this.backReferenceNames=[]};kt.prototype.reset=function(t,e,n){var r=n.indexOf("u")!==-1;this.start=0|t,this.source=e+"",this.flags=n,this.switchU=r&&this.parser.options.ecmaVersion>=6,this.switchN=r&&this.parser.options.ecmaVersion>=9},kt.prototype.raise=function(t){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+t)},kt.prototype.at=function(t){var e=this.source,n=e.length;if(t>=n)return-1;var r=e.charCodeAt(t);return!this.switchU||r<=55295||r>=57344||t+1>=n?r:(r<<10)+e.charCodeAt(t+1)-56613888},kt.prototype.nextIndex=function(t){var e=this.source,n=e.length;if(t>=n)return n;var r=e.charCodeAt(t);return!this.switchU||r<=55295||r>=57344||t+1>=n?t+1:t+2},kt.prototype.current=function(){return this.at(this.pos)},kt.prototype.lookahead=function(){return this.at(this.nextIndex(this.pos))},kt.prototype.advance=function(){ -this.pos=this.nextIndex(this.pos)},kt.prototype.eat=function(t){return this.current()===t&&(this.advance(),!0)},St.validateRegExpFlags=function(t){for(var e=this,n=t.validFlags,r=t.flags,i=0;i-1&&e.raise(t.start,"Duplicate regular expression flag")}},St.validateRegExpPattern=function(t){this.regexp_pattern(t),!t.switchN&&this.options.ecmaVersion>=9&&t.groupNames.length>0&&(t.switchN=!0,this.regexp_pattern(t))},St.regexp_pattern=function(t){t.pos=0,t.lastIntValue=0,t.lastStringValue="",t.lastAssertionIsQuantifiable=!1,t.numCapturingParens=0,t.maxBackReference=0,t.groupNames.length=0,t.backReferenceNames.length=0,this.regexp_disjunction(t),t.pos!==t.source.length&&(t.eat(41)&&t.raise("Unmatched ')'"),(t.eat(93)||t.eat(125))&&t.raise("Lone quantifier brackets")),t.maxBackReference>t.numCapturingParens&&t.raise("Invalid escape");for(var e=0,n=t.backReferenceNames;e=9&&(n=t.eat(60)),t.eat(61)||t.eat(33))return this.regexp_disjunction(t),t.eat(41)||t.raise("Unterminated group"),t.lastAssertionIsQuantifiable=!n,!0}return t.pos=e,!1},St.regexp_eatQuantifier=function(t,e){return void 0===e&&(e=!1),!!this.regexp_eatQuantifierPrefix(t,e)&&(t.eat(63),!0)},St.regexp_eatQuantifierPrefix=function(t,e){return t.eat(42)||t.eat(43)||t.eat(63)||this.regexp_eatBracedQuantifier(t,e)},St.regexp_eatBracedQuantifier=function(t,e){var n=t.pos;if(t.eat(123)){var r=0,i=-1;if(this.regexp_eatDecimalDigits(t)&&(r=t.lastIntValue,t.eat(44)&&this.regexp_eatDecimalDigits(t)&&(i=t.lastIntValue),t.eat(125)))return i!==-1&&i=9?this.regexp_groupSpecifier(t):63===t.current()&&t.raise("Invalid group"),this.regexp_disjunction(t),t.eat(41))return t.numCapturingParens+=1,!0;t.raise("Unterminated group")}return!1},St.regexp_eatExtendedAtom=function(t){return t.eat(46)||this.regexp_eatReverseSolidusAtomEscape(t)||this.regexp_eatCharacterClass(t)||this.regexp_eatUncapturingGroup(t)||this.regexp_eatCapturingGroup(t)||this.regexp_eatInvalidBracedQuantifier(t)||this.regexp_eatExtendedPatternCharacter(t)},St.regexp_eatInvalidBracedQuantifier=function(t){return this.regexp_eatBracedQuantifier(t,!0)&&t.raise("Nothing to repeat"),!1},St.regexp_eatSyntaxCharacter=function(t){var e=t.current();return!!g(e)&&(t.lastIntValue=e,t.advance(),!0)},St.regexp_eatPatternCharacters=function(t){for(var e=t.pos,n=0;(n=t.current())!==-1&&!g(n);)t.advance();return t.pos!==e},St.regexp_eatExtendedPatternCharacter=function(t){var e=t.current();return!(e===-1||36===e||e>=40&&e<=43||46===e||63===e||91===e||94===e||124===e)&&(t.advance(),!0)},St.regexp_groupSpecifier=function(t){if(t.eat(63)){if(this.regexp_eatGroupName(t))return t.groupNames.indexOf(t.lastStringValue)!==-1&&t.raise("Duplicate capture group name"),void t.groupNames.push(t.lastStringValue);t.raise("Invalid group")}},St.regexp_eatGroupName=function(t){if(t.lastStringValue="",t.eat(60)){if(this.regexp_eatRegExpIdentifierName(t)&&t.eat(62))return!0;t.raise("Invalid capture group name")}return!1},St.regexp_eatRegExpIdentifierName=function(t){if(t.lastStringValue="",this.regexp_eatRegExpIdentifierStart(t)){for(t.lastStringValue+=d(t.lastIntValue);this.regexp_eatRegExpIdentifierPart(t);)t.lastStringValue+=d(t.lastIntValue);return!0}return!1},St.regexp_eatRegExpIdentifierStart=function(t){var e=t.pos,n=t.current();return t.advance(),92===n&&this.regexp_eatRegExpUnicodeEscapeSequence(t)&&(n=t.lastIntValue),m(n)?(t.lastIntValue=n,!0):(t.pos=e,!1)},St.regexp_eatRegExpIdentifierPart=function(t){var e=t.pos,n=t.current();return t.advance(),92===n&&this.regexp_eatRegExpUnicodeEscapeSequence(t)&&(n=t.lastIntValue),y(n)?(t.lastIntValue=n,!0):(t.pos=e,!1)},St.regexp_eatAtomEscape=function(t){return!!(this.regexp_eatBackReference(t)||this.regexp_eatCharacterClassEscape(t)||this.regexp_eatCharacterEscape(t)||t.switchN&&this.regexp_eatKGroupName(t))||(t.switchU&&(99===t.current()&&t.raise("Invalid unicode escape"),t.raise("Invalid escape")),!1)},St.regexp_eatBackReference=function(t){var e=t.pos;if(this.regexp_eatDecimalEscape(t)){var n=t.lastIntValue;if(t.switchU)return n>t.maxBackReference&&(t.maxBackReference=n),!0;if(n<=t.numCapturingParens)return!0;t.pos=e}return!1},St.regexp_eatKGroupName=function(t){if(t.eat(107)){if(this.regexp_eatGroupName(t))return t.backReferenceNames.push(t.lastStringValue),!0;t.raise("Invalid named reference")}return!1},St.regexp_eatCharacterEscape=function(t){return this.regexp_eatControlEscape(t)||this.regexp_eatCControlLetter(t)||this.regexp_eatZero(t)||this.regexp_eatHexEscapeSequence(t)||this.regexp_eatRegExpUnicodeEscapeSequence(t)||!t.switchU&&this.regexp_eatLegacyOctalEscapeSequence(t)||this.regexp_eatIdentityEscape(t)},St.regexp_eatCControlLetter=function(t){var e=t.pos;if(t.eat(99)){if(this.regexp_eatControlLetter(t))return!0;t.pos=e}return!1},St.regexp_eatZero=function(t){return 48===t.current()&&!T(t.lookahead())&&(t.lastIntValue=0,t.advance(),!0)},St.regexp_eatControlEscape=function(t){var e=t.current();return 116===e?(t.lastIntValue=9,t.advance(),!0):110===e?(t.lastIntValue=10,t.advance(),!0):118===e?(t.lastIntValue=11,t.advance(),!0):102===e?(t.lastIntValue=12,t.advance(),!0):114===e&&(t.lastIntValue=13,t.advance(),!0)},St.regexp_eatControlLetter=function(t){var e=t.current();return!!x(e)&&(t.lastIntValue=e%32,t.advance(),!0)},St.regexp_eatRegExpUnicodeEscapeSequence=function(t){var e=t.pos;if(t.eat(117)){if(this.regexp_eatFixedHexDigits(t,4)){var n=t.lastIntValue;if(t.switchU&&n>=55296&&n<=56319){var r=t.pos;if(t.eat(92)&&t.eat(117)&&this.regexp_eatFixedHexDigits(t,4)){var i=t.lastIntValue;if(i>=56320&&i<=57343)return t.lastIntValue=1024*(n-55296)+(i-56320)+65536,!0}t.pos=r,t.lastIntValue=n}return!0}if(t.switchU&&t.eat(123)&&this.regexp_eatHexDigits(t)&&t.eat(125)&&v(t.lastIntValue))return!0;t.switchU&&t.raise("Invalid unicode escape"),t.pos=e}return!1},St.regexp_eatIdentityEscape=function(t){if(t.switchU)return!!this.regexp_eatSyntaxCharacter(t)||!!t.eat(47)&&(t.lastIntValue=47,!0);var e=t.current();return!(99===e||t.switchN&&107===e)&&(t.lastIntValue=e,t.advance(),!0)},St.regexp_eatDecimalEscape=function(t){t.lastIntValue=0;var e=t.current();if(e>=49&&e<=57){do t.lastIntValue=10*t.lastIntValue+(e-48),t.advance();while((e=t.current())>=48&&e<=57);return!0}return!1},St.regexp_eatCharacterClassEscape=function(t){var e=t.current();if(b(e))return t.lastIntValue=-1,t.advance(),!0;if(t.switchU&&this.options.ecmaVersion>=9&&(80===e||112===e)){if(t.lastIntValue=-1,t.advance(),t.eat(123)&&this.regexp_eatUnicodePropertyValueExpression(t)&&t.eat(125))return!0;t.raise("Invalid property name")}return!1},St.regexp_eatUnicodePropertyValueExpression=function(t){var e=t.pos;if(this.regexp_eatUnicodePropertyName(t)&&t.eat(61)){var n=t.lastStringValue;if(this.regexp_eatUnicodePropertyValue(t)){var r=t.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(t,n,r),!0}}if(t.pos=e,this.regexp_eatLoneUnicodePropertyNameOrValue(t)){var i=t.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(t,i),!0}return!1},St.regexp_validateUnicodePropertyNameAndValue=function(t,e,n){Tt.hasOwnProperty(e)&&Tt[e].indexOf(n)!==-1||t.raise("Invalid property name")},St.regexp_validateUnicodePropertyNameOrValue=function(t,e){Tt.$LONE.indexOf(e)===-1&&t.raise("Invalid property name")},St.regexp_eatUnicodePropertyName=function(t){var e=0;for(t.lastStringValue="";_(e=t.current());)t.lastStringValue+=d(e),t.advance();return""!==t.lastStringValue},St.regexp_eatUnicodePropertyValue=function(t){var e=0;for(t.lastStringValue="";E(e=t.current());)t.lastStringValue+=d(e),t.advance();return""!==t.lastStringValue},St.regexp_eatLoneUnicodePropertyNameOrValue=function(t){return this.regexp_eatUnicodePropertyValue(t)},St.regexp_eatCharacterClass=function(t){if(t.eat(91)){if(t.eat(94),this.regexp_classRanges(t),t.eat(93))return!0;t.raise("Unterminated character class")}return!1},St.regexp_classRanges=function(t){for(var e=this;this.regexp_eatClassAtom(t);){var n=t.lastIntValue;if(t.eat(45)&&e.regexp_eatClassAtom(t)){var r=t.lastIntValue;!t.switchU||n!==-1&&r!==-1||t.raise("Invalid character class"),n!==-1&&r!==-1&&n>r&&t.raise("Range out of order in character class")}}},St.regexp_eatClassAtom=function(t){var e=t.pos;if(t.eat(92)){if(this.regexp_eatClassEscape(t))return!0;if(t.switchU){var n=t.current();(99===n||w(n))&&t.raise("Invalid class escape"),t.raise("Invalid escape")}t.pos=e}var r=t.current();return 93!==r&&(t.lastIntValue=r,t.advance(),!0)},St.regexp_eatClassEscape=function(t){var e=t.pos;if(t.eat(98))return t.lastIntValue=8,!0;if(t.switchU&&t.eat(45))return t.lastIntValue=45,!0;if(!t.switchU&&t.eat(99)){if(this.regexp_eatClassControlLetter(t))return!0;t.pos=e}return this.regexp_eatCharacterClassEscape(t)||this.regexp_eatCharacterEscape(t)},St.regexp_eatClassControlLetter=function(t){var e=t.current();return!(!T(e)&&95!==e)&&(t.lastIntValue=e%32,t.advance(),!0)},St.regexp_eatHexEscapeSequence=function(t){var e=t.pos;if(t.eat(120)){if(this.regexp_eatFixedHexDigits(t,2))return!0;t.switchU&&t.raise("Invalid escape"),t.pos=e}return!1},St.regexp_eatDecimalDigits=function(t){var e=t.pos,n=0;for(t.lastIntValue=0;T(n=t.current());)t.lastIntValue=10*t.lastIntValue+(n-48),t.advance();return t.pos!==e},St.regexp_eatHexDigits=function(t){var e=t.pos,n=0;for(t.lastIntValue=0;S(n=t.current());)t.lastIntValue=16*t.lastIntValue+k(n),t.advance();return t.pos!==e},St.regexp_eatLegacyOctalEscapeSequence=function(t){if(this.regexp_eatOctalDigit(t)){var e=t.lastIntValue;if(this.regexp_eatOctalDigit(t)){var n=t.lastIntValue;e<=3&&this.regexp_eatOctalDigit(t)?t.lastIntValue=64*e+8*n+t.lastIntValue:t.lastIntValue=8*e+n}else t.lastIntValue=e;return!0}return!1},St.regexp_eatOctalDigit=function(t){var e=t.current();return w(e)?(t.lastIntValue=e-48,t.advance(),!0):(t.lastIntValue=0,!1)},St.regexp_eatFixedHexDigits=function(t,e){var n=t.pos;t.lastIntValue=0;for(var r=0;r=this.input.length?this.finishToken(W.eof):t.override?t.override(this):void this.readToken(this.fullCharCodeAtPos())},At.readToken=function(t){return n(t,this.options.ecmaVersion>=6)||92===t?this.readWord():this.getTokenFromCode(t)},At.fullCharCodeAtPos=function(){var t=this.input.charCodeAt(this.pos);if(t<=55295||t>=57344)return t;var e=this.input.charCodeAt(this.pos+1);return(t<<10)+e-56613888},At.skipBlockComment=function(){var t=this,e=this.options.onComment&&this.curPosition(),n=this.pos,r=this.input.indexOf("*/",this.pos+=2);if(r===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=r+2,this.options.locations){q.lastIndex=n;for(var i;(i=q.exec(this.input))&&i.index8&&e<14||e>=5760&&Y.test(String.fromCharCode(e))))break t;++t.pos}}},At.finishToken=function(t,e){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=t,this.value=e,this.updateContext(n)},At.readToken_dot=function(){var t=this.input.charCodeAt(this.pos+1);if(t>=48&&t<=57)return this.readNumber(!0);var e=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&46===t&&46===e?(this.pos+=3,this.finishToken(W.ellipsis)):(++this.pos,this.finishToken(W.dot))},At.readToken_slash=function(){var t=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):61===t?this.finishOp(W.assign,2):this.finishOp(W.slash,1)},At.readToken_mult_modulo_exp=function(t){var e=this.input.charCodeAt(this.pos+1),n=1,r=42===t?W.star:W.modulo;return this.options.ecmaVersion>=7&&42==t&&42===e&&(++n,r=W.starstar,e=this.input.charCodeAt(this.pos+2)),61===e?this.finishOp(W.assign,n+1):this.finishOp(r,n)},At.readToken_pipe_amp=function(t){var e=this.input.charCodeAt(this.pos+1);return e===t?this.finishOp(124===t?W.logicalOR:W.logicalAND,2):61===e?this.finishOp(W.assign,2):this.finishOp(124===t?W.bitwiseOR:W.bitwiseAND,1)},At.readToken_caret=function(){var t=this.input.charCodeAt(this.pos+1);return 61===t?this.finishOp(W.assign,2):this.finishOp(W.bitwiseXOR,1)},At.readToken_plus_min=function(t){var e=this.input.charCodeAt(this.pos+1);return e===t?45!=e||this.inModule||62!=this.input.charCodeAt(this.pos+2)||0!==this.lastTokEnd&&!H.test(this.input.slice(this.lastTokEnd,this.pos))?this.finishOp(W.incDec,2):(this.skipLineComment(3),this.skipSpace(),this.nextToken()):61===e?this.finishOp(W.assign,2):this.finishOp(W.plusMin,1)},At.readToken_lt_gt=function(t){var e=this.input.charCodeAt(this.pos+1),n=1;return e===t?(n=62===t&&62===this.input.charCodeAt(this.pos+2)?3:2,61===this.input.charCodeAt(this.pos+n)?this.finishOp(W.assign,n+1):this.finishOp(W.bitShift,n)):33!=e||60!=t||this.inModule||45!=this.input.charCodeAt(this.pos+2)||45!=this.input.charCodeAt(this.pos+3)?(61===e&&(n=2),this.finishOp(W.relational,n)):(this.skipLineComment(4),this.skipSpace(),this.nextToken())},At.readToken_eq_excl=function(t){var e=this.input.charCodeAt(this.pos+1);return 61===e?this.finishOp(W.equality,61===this.input.charCodeAt(this.pos+2)?3:2):61===t&&62===e&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(W.arrow)):this.finishOp(61===t?W.eq:W.prefix,1)},At.getTokenFromCode=function(t){switch(t){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(W.parenL);case 41:return++this.pos,this.finishToken(W.parenR);case 59:return++this.pos,this.finishToken(W.semi);case 44:return++this.pos,this.finishToken(W.comma);case 91:return++this.pos,this.finishToken(W.bracketL);case 93:return++this.pos,this.finishToken(W.bracketR);case 123:return++this.pos,this.finishToken(W.braceL);case 125:return++this.pos,this.finishToken(W.braceR);case 58:return++this.pos,this.finishToken(W.colon);case 63:return++this.pos,this.finishToken(W.question);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(W.backQuote);case 48:var e=this.input.charCodeAt(this.pos+1);if(120===e||88===e)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(111===e||79===e)return this.readRadixNumber(8);if(98===e||66===e)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(t);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(t);case 124:case 38:return this.readToken_pipe_amp(t);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(t);case 60:case 62:return this.readToken_lt_gt(t);case 61:case 33:return this.readToken_eq_excl(t);case 126:return this.finishOp(W.prefix,1)}this.raise(this.pos,"Unexpected character '"+A(t)+"'")},At.finishOp=function(t,e){var n=this.input.slice(this.pos,this.pos+e);return this.pos+=e,this.finishToken(t,n)},At.readRegexp=function(){for(var t,e,n=this,r=this.pos;;){n.pos>=n.input.length&&n.raise(r,"Unterminated regular expression");var i=n.input.charAt(n.pos);if(H.test(i)&&n.raise(r,"Unterminated regular expression"),t)t=!1;else{if("["===i)e=!0;else if("]"===i&&e)e=!1;else if("/"===i&&!e)break;t="\\"===i}++n.pos}var s=this.input.slice(r,this.pos);++this.pos;var a=this.pos,o=this.readWord1();this.containsEsc&&this.unexpected(a);var u=this.regexpState||(this.regexpState=new kt(this));u.reset(r,s,o),this.validateRegExpFlags(u),this.validateRegExpPattern(u);var h=null;try{h=new RegExp(s,o)}catch(p){}return this.finishToken(W.regexp,{pattern:s,flags:o,value:h})},At.readInt=function(t,e){for(var n=this,r=this.pos,i=0,s=0,a=null==e?1/0:e;s=97?o-97+10:o>=65?o-65+10:o>=48&&o<=57?o-48:1/0,u>=t)break;++n.pos,i=i*t+u}return this.pos===r||null!=e&&this.pos-r!==e?null:i},At.readRadixNumber=function(t){this.pos+=2;var e=this.readInt(t);return null==e&&this.raise(this.start+2,"Expected number in radix "+t),n(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(W.num,e)},At.readNumber=function(t){var e=this.pos;t||null!==this.readInt(10)||this.raise(e,"Invalid number");var r=this.pos-e>=2&&48===this.input.charCodeAt(e);r&&this.strict&&this.raise(e,"Invalid number"),r&&/[89]/.test(this.input.slice(e,this.pos))&&(r=!1);var i=this.input.charCodeAt(this.pos);46!==i||r||(++this.pos,this.readInt(10),i=this.input.charCodeAt(this.pos)),69!==i&&101!==i||r||(i=this.input.charCodeAt(++this.pos),43!==i&&45!==i||++this.pos,null===this.readInt(10)&&this.raise(e,"Invalid number")),n(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var s=this.input.slice(e,this.pos),a=r?parseInt(s,8):parseFloat(s);return this.finishToken(W.num,a)},At.readCodePoint=function(){var t,e=this.input.charCodeAt(this.pos);if(123===e){this.options.ecmaVersion<6&&this.unexpected();var n=++this.pos;t=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(n,"Code point out of bounds")}else t=this.readHexChar(4);return t},At.readString=function(t){for(var e=this,n="",r=++this.pos;;){e.pos>=e.input.length&&e.raise(e.start,"Unterminated string constant");var i=e.input.charCodeAt(e.pos);if(i===t)break;92===i?(n+=e.input.slice(r,e.pos),n+=e.readEscapedChar(!1),r=e.pos):(a(i)&&e.raise(e.start,"Unterminated string constant"),++e.pos)}return n+=this.input.slice(r,this.pos++),this.finishToken(W.string,n)};var Ot={};At.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(t){if(t!==Ot)throw t;this.readInvalidTemplateToken()}this.inTemplateElement=!1},At.invalidStringToken=function(t,e){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Ot;this.raise(t,e)},At.readTmplToken=function(){for(var t=this,e="",n=this.pos;;){t.pos>=t.input.length&&t.raise(t.start,"Unterminated template");var r=t.input.charCodeAt(t.pos);if(96===r||36===r&&123===t.input.charCodeAt(t.pos+1))return t.pos!==t.start||t.type!==W.template&&t.type!==W.invalidTemplate?(e+=t.input.slice(n,t.pos),t.finishToken(W.template,e)):36===r?(t.pos+=2,t.finishToken(W.dollarBraceL)):(++t.pos,t.finishToken(W.backQuote));if(92===r)e+=t.input.slice(n,t.pos),e+=t.readEscapedChar(!0),n=t.pos;else if(a(r)){switch(e+=t.input.slice(n,t.pos),++t.pos,r){case 13:10===t.input.charCodeAt(t.pos)&&++t.pos;case 10:e+="\n";break;default:e+=String.fromCharCode(r)}t.options.locations&&(++t.curLine,t.lineStart=t.pos),n=t.pos}else++t.pos}},At.readInvalidTemplateToken=function(){for(var t=this;this.pos=48&&e<=55){var n=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],r=parseInt(n,8);return r>255&&(n=n.slice(0,-1),r=parseInt(n,8)),this.pos+=n.length-1,e=this.input.charCodeAt(this.pos),"0"===n&&56!=e&&57!=e||!this.strict&&!t||this.invalidStringToken(this.pos-1-n.length,"Octal literal in strict mode"),String.fromCharCode(r)}return String.fromCharCode(e)}},At.readHexChar=function(t){var e=this.pos,n=this.readInt(16,t);return null===n&&this.invalidStringToken(e,"Bad character escape sequence"),n},At.readWord1=function(){var t=this;this.containsEsc=!1;for(var e="",i=!0,s=this.pos,a=this.options.ecmaVersion>=6;this.pos0&&e.push(", "),e.push(this.paramTypes[n]),e.push(" "),e.push("user_"),e.push(this.paramNames[n]);return e.push(");\n"),e}},{key:"astFunctionExpression",value:function(t,e){if(!this.isRootKernel){e.push("function"),this.kernalAst=t,e.push(" "),e.push(this.functionName),e.push("(");for(var n=0;n0&&e.push(", "),e.push(" "),e.push("user_"),e.push(r)}e.push(") {\n")}for(var i=0;i1){for(var s=null,a=0;a0&&e.push(","),this.astGeneric(t.declarations[n],e);return e.push(";"),e}},{key:"astVariableDeclarator",value:function(t,e){return this.astGeneric(t.id,e),null!==t.init&&(e.push("="),this.astGeneric(t.init,e)),e}},{key:"astIfStatement",value:function(t,e){return e.push("if ("),this.astGeneric(t.test,e),e.push(")"),"BlockStatement"===t.consequent.type?this.astGeneric(t.consequent,e):(e.push(" {\n"),this.astGeneric(t.consequent,e),e.push("\n}\n")),t.alternate&&(e.push("else "),"BlockStatement"===t.alternate.type?this.astGeneric(t.alternate,e):(e.push(" {\n"),this.astGeneric(t.alternate,e),e.push("\n}\n"))),e}},{key:"astBreakStatement",value:function(t,e){return e.push("break;\n"),e}},{key:"astContinueStatement",value:function(t,e){return e.push("continue;\n"),e}},{key:"astLogicalExpression",value:function(t,e){return e.push("("),this.astGeneric(t.left,e),e.push(t.operator),this.astGeneric(t.right,e),e.push(")"),e}},{key:"astUpdateExpression",value:function(t,e){return t.prefix?(e.push(t.operator),this.astGeneric(t.argument,e)):(this.astGeneric(t.argument,e),e.push(t.operator)),e}},{key:"astUnaryExpression",value:function(t,e){return t.prefix?(e.push(t.operator),this.astGeneric(t.argument,e)):(this.astGeneric(t.argument,e),e.push(t.operator)),e}},{key:"astThisExpression",value:function(t,e){return e.push("_this"),e}},{key:"astMemberExpression",value:function(t,e){if(t.computed)if("Identifier"===t.object.type)this.pushState("identifier"),this.astGeneric(t.object,e),this.popState("identifier"),e.push("["),this.isInput(t.object.name)?this.astGeneric(t.property,e):this.astGeneric(t.property,e),e.push("]");else if(t.object.object)if(t.object.object.object&&this.isInput(t.object.object.object.name)){this.pushMemberState(t.object.object.object.name),this.pushState("input-index-z"),this.astGeneric(t.object,e);var n=e.pop();e.push(" + "),this.popState("input-index-z"),this.pushState("input-index"),this.astGeneric(t.property,e),this.popState("input-index"),e.push(n),this.popMemberState(t.object.object.object.name)}else if(this.isInput(t.object.object.name)){this.pushMemberState(t.object.object.name),this.isState("input-index-z")||this.pushState("input-index-y"),this.astGeneric(t.object,e);var r=e.pop();e.push(" + "),this.isState("input-index-z")||this.popState("input-index-y");var i=this.isState("input-index-z");i?this.pushState("input-index-y"):this.pushState("input-index"),this.astGeneric(t.property,e),i?this.popState("input-index-y"):this.popState("input-index"),e.push(r),this.popMemberState(t.object.object.name)}else{this.astGeneric(t.object,e);var s=e.pop();e.push("]["),this.astGeneric(t.property,e),e.push(s)}else{this.astGeneric(t.object,e);var a=e.pop();e.push("]["),this.astGeneric(t.property,e),e.push(a)}else{var o=this.astMemberExpressionUnroll(t);switch("Identifier"===t.property.type&&t.computed&&(o="user_"+o),0===o.indexOf("this")&&(o="_"+o),this.state){case"input-index-y":case"input-index-z":e.push("(")}switch(o){case"_this.output.x":e.push(this.output[0]);break;case"_this.output.y":e.push(this.output[1]);break;case"_this.output.z":e.push(this.output[2]);break;default:e.push(o)}switch(this.state){case"input-index-y":var u=this.paramSizes[this.paramNames.indexOf(this.memberState)];e.push(" * "+u[0]+")");break;case"input-index-z":var h=this.paramSizes[this.paramNames.indexOf(this.memberState)];e.push(" * "+h[0]*h[1]+")")}}return e}},{key:"astSequenceExpression",value:function(t,e){for(var n=0;n0&&e.push(","),this.astGeneric(t.expressions,e);return e}},{key:"astCallExpression",value:function(t,e){if(t.callee){var n=this.astMemberExpressionUnroll(t.callee);this.calledFunctions.indexOf(n)<0&&this.calledFunctions.push(n),this.hasOwnProperty("funcName")||(this.calledFunctionsArguments[n]=[]);var r=[];this.calledFunctionsArguments[n].push(r),e.push(n),e.push("(");for(var i=0;i0&&e.push(", "),this.astGeneric(s,e),"Identifier"===s.type){var a=this.paramNames.indexOf(s.name);a===-1?r.push(null):r.push({name:s.name,type:this.paramTypes[a]})}else r.push(null)}return e.push(")"),e}throw this.astErrorOutput("Unknown CallExpression",t)}},{key:"astArrayExpression",value:function(t,e){var n=t.elements.length;e.push("new Float32Array(");for(var r=0;r0&&e.push(", ");var i=t.elements[r];this.astGeneric(i,e)}return e.push(")"),e}},{key:"astDebuggerStatement",value:function(t,e){return e.push("debugger;"),e}},{key:"memberState",get:function(){return this.memberStates[this.memberStates.length-1]}}]),e}(o)},{"../../core/utils":32,"../function-node-base":7}],3:[function(t,e,n){function r(t){return/^function /.test(t)&&(t=t.substring(9)),t.replace(/[_]typeof/g,"typeof")}function i(t){return t.replace(/[_]typeof/g,"typeof")}var s=t("../../core/utils"),a=t("../kernel-run-shortcut");e.exports=function(t,e){return"() => {\n "+a.toString()+";\n const utils = {\n allPropertiesOf: "+i(s.allPropertiesOf.toString())+",\n clone: "+i(s.clone.toString())+",\n checkOutput: "+i(s.checkOutput.toString())+"\n };\n const Utils = utils;\n class "+(e||"Kernel")+" {\n constructor() { \n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = "+JSON.stringify(t.paramNames)+";\n this.paramTypes = "+JSON.stringify(t.paramTypes)+";\n this.texSize = "+JSON.stringify(t.texSize)+";\n this.output = "+JSON.stringify(t.output)+";\n this._kernelString = `"+t._kernelString+"`;\n this.output = "+JSON.stringify(t.output)+";\n\t\t this.run = function() {\n this.run = null;\n this.build();\n return this.run.apply(this, arguments);\n }.bind(this);\n this.thread = {\n x: 0,\n y: 0,\n z: 0\n };\n }\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n "+r(t.build.toString())+"\n "+r(t.setupParams.toString())+"\n run () { "+t.kernelString+" }\n getKernelString() { return this._kernelString; }\n "+r(t.validateOptions.toString())+"\n };\n return kernelRunShortcut(new Kernel());\n };"}},{"../../core/utils":32,"../kernel-run-shortcut":9}],4:[function(t,e,n){function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var a=function(){function t(t,e){for(var n=0;n1?h=h.filter(function(t){return/^function/.test(t)?t:(p=t,!1)}):p=h.shift();var l=this._kernelString="\n\t\tvar LOOP_MAX = "+this._getLoopMaxString()+";\n\t\tvar _this = this;\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(t){return" var "+t+" = null;\n"}).join(""))+"\n return function ("+this.paramNames.map(function(t){return"user_"+t}).join(", ")+") {\n "+this._processInputs()+"\n var ret = new Array("+n[2]+");\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(t){return" "+t+"Z = new Array("+n[2]+");\n"}).join(""))+"\n for (this.thread.z = 0; this.thread.z < "+n[2]+"; this.thread.z++) {\n ret[this.thread.z] = new Array("+n[1]+");\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(t){return" "+t+"Z[this.thread.z] = new Array("+n[1]+");\n"}).join(""))+"\n for (this.thread.y = 0; this.thread.y < "+n[1]+"; this.thread.y++) {\n ret[this.thread.z][this.thread.y] = new Array("+n[0]+");\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(t){return" "+t+"Z[this.thread.z][this.thread.y] = new Array("+n[0]+");\n"}).join(""))+"\n for (this.thread.x = 0; this.thread.x < "+n[0]+"; this.thread.x++) {\n var kernelResult;\n "+p+"\n ret[this.thread.z][this.thread.y][this.thread.x] = kernelResult;\n"+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(t){return" "+t+"Z[this.thread.z][this.thread.y][this.thread.x] = "+t+";\n"}).join(""))+"\n }\n }\n }\n \n if (this.graphical) {\n this._imageData.data.set(this._colorData);\n this._canvasCtx.putImageData(this._imageData, 0, 0);\n return;\n }\n \n if (this.output.length === 1) {\n ret = ret[0][0];\n"+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(t){return" "+t+" = "+t+"Z[0][0];\n"}).join(""))+"\n \n } else if (this.output.length === 2) {\n ret = ret[0];\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(t){return" "+t+" = "+t+"Z[0];\n"}).join(""))+"\n }\n \n "+(null===this.subKernelOutputVariableNames?"return ret;\n":null!==this.subKernels?"var result = [\n "+this.subKernelOutputVariableNames.map(function(t){return""+t}).join(",\n")+"\n ];\n result.result = ret;\n return result;\n":"return {\n result: ret,\n "+Object.keys(this.subKernelProperties).map(function(e,n){return e+": "+t.subKernelOutputVariableNames[n]}).join(",\n")+"\n };")+"\n "+(h.length>0?h.join("\n"):"")+"\n }.bind(this);";return l}},{key:"toString",value:function(){return h(this)}},{key:"precompileKernelObj",value:function(t){var e=this.threadDim||(this.threadDim=u.clone(this.output));return{threadDim:e}}},{key:"_getLoopMaxString",value:function(){return this.loopMaxIterations?" "+parseInt(this.loopMaxIterations)+";\n":" 1000;\n"}},{key:"_processInputs",value:function(){for(var t=[],e=0;e=0;i--){n[i]=new Array(t.width);for(var s=0;s=0||e.push(t)),e}},{key:"addKernel",value:function(t,e){var n=new this.Node("kernel",t,e);return n.setAddFunction(this.addFunction.bind(this)),n.isRootKernel=!0,this.addFunctionNode(n),n}},{key:"addSubKernel",value:function(t,e){var n=new this.Node(null,t,e);return n.setAddFunction(this.addFunction.bind(this)),n.isSubKernel=!0,this.addFunctionNode(n),n}},{key:"getPrototypeString",value:function(t){return this.getPrototypes(t).join("\n")}},{key:"getPrototypes",value:function(t){return this.rootKernel.generate(),t?this.getPrototypesFromFunctionNames(this.traceFunctionCalls(t,[]).reverse()):this.getPrototypesFromFunctionNames(Object.keys(this.nodeMap))}},{key:"getStringFromFunctionNames",value:function(t){for(var e=[],n=0;n ("+r.length+","+this.paramNames.length+")";this.paramTypes=r}else if("object"===("undefined"==typeof r?"undefined":_typeof(r))){var s=Object.keys(r);if(r.hasOwnProperty("returns")&&(this.returnType=r.returns,s.splice(s.indexOf("returns"),1)),s.length>0&&s.length!==this.paramNames.length)throw"Invalid argument type array length, against function length -> ("+s.length+","+this.paramNames.length+")";this.paramTypes=this.paramNames.map(function(t){return r.hasOwnProperty(t)?r[t]:"float"})}}else this.paramTypes=[];this.returnType||(this.returnType=i||"float")}return _createClass(BaseFunctionNode,[{key:"isIdentifierConstant",value:function(t){return!!this.constants&&this.constants.hasOwnProperty(t)}},{key:"isInput",value:function(t){return"Input"===this.paramTypes[this.paramNames.indexOf(t)]}},{key:"setAddFunction",value:function(t){return this.addFunction=t,this}},{key:"pushState",value:function(t){this.states.push(t)}},{key:"popState",value:function(t){if(this.state!==t)throw new Error("Cannot popState "+t+" when in "+this.state);this.states.pop()}},{key:"isState",value:function(t){return this.state===t}},{key:"getJsFunction",value:function getJsFunction(){if(this.jsFunction)return this.jsFunction;if(this.jsFunctionString)return this.jsFunction=eval(this.jsFunctionString),this.jsFunction;throw"Missing jsFunction, and jsFunctionString parameter"}},{key:"astMemberExpressionUnroll",value:function(t){if("Identifier"===t.type)return t.name;if("ThisExpression"===t.type)return"this";if("MemberExpression"===t.type&&t.object&&t.property)return t.object.hasOwnProperty("name")&&"_"===t.object.name[0]?this.astMemberExpressionUnroll(t.property):this.astMemberExpressionUnroll(t.object)+"."+this.astMemberExpressionUnroll(t.property);if(t.hasOwnProperty("expressions")){var e=t.expressions[0];if("Literal"===e.type&&0===e.value&&2===t.expressions.length)return this.astMemberExpressionUnroll(t.expressions[1])}throw this.astErrorOutput("Unknown CallExpression_unroll",t)}},{key:"getJsAST",value:function(t){if(this.jsFunctionAST)return this.jsFunctionAST;if(t=t||acorn,null===t)throw"Missing JS to AST parser";var e=t.parse("var "+this.functionName+" = "+this.jsFunctionString+";",{locations:!0});if(null===e)throw"Failed to parse JS code";var n=e.body[0].declarations[0].init;return this.jsFunctionAST=n,n}},{key:"getFunctionString",value:function(){return this.generate(),this.functionString}},{key:"setFunctionString",value:function(t){this.functionString=t}},{key:"getParamType",value:function(t){var e=this.paramNames.indexOf(t);if(e===-1)return this.declarations.hasOwnProperty(t)?this.declarations[t]:null;if(this.parent){if(this.paramTypes[e])return this.paramTypes[e];for(var n=this.parent.calledFunctionsArguments[this.functionName],r=0;r0&&e.push(", ");var i=this.getParamType(r);switch(i){case"Texture":case"Input":case"Array":e.push("sampler2D");break;default:e.push("float")}e.push(" "),e.push("user_"),e.push(r)}e.push(") {\n");for(var s=0;s1){for(var s=null,a=0;a0&&e.push(",");var i=[];this.astGeneric(r,i),"getImage2D("===i[2]||"getImage3D("===i[2]?(0===n&&e.push("vec4 "),this.declarations[r.id.name]="vec4"):(0===n&&e.push("float "),this.declarations[r.id.name]="float"),e.push.apply(e,i)}return e.push(";"),e}},{key:"astVariableDeclarator",value:function(t,e){return this.astGeneric(t.id,e),null!==t.init&&(e.push("="),this.astGeneric(t.init,e)),e}},{key:"astIfStatement",value:function(t,e){return e.push("if ("),this.astGeneric(t.test,e),e.push(")"),"BlockStatement"===t.consequent.type?this.astGeneric(t.consequent,e):(e.push(" {\n"),this.astGeneric(t.consequent,e),e.push("\n}\n")),t.alternate&&(e.push("else "),"BlockStatement"===t.alternate.type?this.astGeneric(t.alternate,e):(e.push(" {\n"),this.astGeneric(t.alternate,e),e.push("\n}\n"))),e}},{key:"astBreakStatement",value:function(t,e){return e.push("break;\n"),e}},{key:"astContinueStatement",value:function(t,e){return e.push("continue;\n"),e}},{key:"astLogicalExpression",value:function(t,e){return e.push("("),this.astGeneric(t.left,e),e.push(t.operator),this.astGeneric(t.right,e),e.push(")"),e}},{key:"astUpdateExpression",value:function(t,e){return t.prefix?(e.push(t.operator),this.astGeneric(t.argument,e)):(this.astGeneric(t.argument,e),e.push(t.operator)),e}},{key:"astUnaryExpression",value:function(t,e){return t.prefix?(e.push(t.operator),this.astGeneric(t.argument,e)):(this.astGeneric(t.argument,e),e.push(t.operator)),e}},{key:"astThisExpression",value:function(t,e){return e.push("this"),e}},{key:"astMemberExpression",value:function(t,e){if(t.computed)if("Identifier"===t.object.type){var n=t.object.name,r=(this.functionName||"kernel",!1);if(this.paramNames){var i=this.paramNames.indexOf(n);i>=0&&"float"===this.paramTypes[i]&&(r=!0)}if(r)this.astGeneric(t.object,e),e.push("[int("),this.astGeneric(t.property,e),e.push(")]");else switch(this.getParamType(t.object.name)){case"vec4":this.astGeneric(t.object,e),e.push("["),e.push(t.property.raw),e.push("]");break;case"HTMLImageArray":e.push("getImage3D("),this.astGeneric(t.object,e),e.push(", vec2("),this.astGeneric(t.object,e),e.push("Size[0],"),this.astGeneric(t.object,e),e.push("Size[1]), vec3("),this.astGeneric(t.object,e),e.push("Dim[0],"),this.astGeneric(t.object,e),e.push("Dim[1],"),this.astGeneric(t.object,e),e.push("Dim[2]"),e.push("), "),this.astGeneric(t.property,e),e.push(")");break;case"HTMLImage":e.push("getImage2D("),this.astGeneric(t.object,e),e.push(", vec2("),this.astGeneric(t.object,e),e.push("Size[0],"),this.astGeneric(t.object,e),e.push("Size[1]), vec3("),this.astGeneric(t.object,e),e.push("Dim[0],"),this.astGeneric(t.object,e),e.push("Dim[1],"),this.astGeneric(t.object,e),e.push("Dim[2]"),e.push("), "),this.astGeneric(t.property,e),e.push(")");break;default:e.push("get("),this.astGeneric(t.object,e),e.push(", vec2("),this.astGeneric(t.object,e),e.push("Size[0],"),this.astGeneric(t.object,e),e.push("Size[1]), vec3("),this.astGeneric(t.object,e),e.push("Dim[0],"),this.astGeneric(t.object,e),e.push("Dim[1],"),this.astGeneric(t.object,e),e.push("Dim[2]"),e.push("), "),this.astGeneric(t.property,e),e.push(")")}}else{this.astGeneric(t.object,e);var s=e.pop();e.push(","),this.astGeneric(t.property,e),e.push(s)}else{var a=this.astMemberExpressionUnroll(t),o=a.toLowerCase();switch(0===a.indexOf(c)&&(a="constants_"+a.slice(c.length)),o){case"this.thread.x":e.push("threadId.x");break;case"this.thread.y":e.push("threadId.y");break;case"this.thread.z":e.push("threadId.z");break;case"this.output.x":e.push(this.output[0]+".0");break;case"this.output.y":e.push(this.output[1]+".0");break;case"this.output.z":e.push(this.output[2]+".0");break;default:e.push(a)}}return e}},{key:"astSequenceExpression",value:function(t,e){for(var n=0;n0&&e.push(","),this.astGeneric(t.expressions,e);return e}},{key:"astCallExpression",value:function(t,e){if(t.callee){var n=this.astMemberExpressionUnroll(t.callee);0===n.indexOf(p)&&(n=n.slice(p.length)),0===n.indexOf(l)&&(n=n.slice(l.length)),"atan2"===n&&(n="atan"),this.calledFunctions.indexOf(n)<0&&this.calledFunctions.push(n),this.hasOwnProperty("funcName")||(this.calledFunctionsArguments[n]=[]);var r=[];this.calledFunctionsArguments[n].push(r),e.push(n),e.push("(");for(var i=0;i0&&e.push(", "),this.astGeneric(s,e),"Identifier"===s.type){var a=this.paramNames.indexOf(s.name);a===-1?r.push(null):r.push({name:s.name,type:this.paramTypes[a]})}else r.push(null)}return e.push(")"),e}throw this.astErrorOutput("Unknown CallExpression",t)}},{key:"astArrayExpression",value:function(t,e){var n=t.elements.length;e.push("float["+n+"](");for(var r=0;r0&&e.push(", ");var i=t.elements[r];this.astGeneric(i,e)}return e.push(")"),e}},{key:"getFunctionPrototypeString",value:function(){return this.webGlFunctionPrototypeString?this.webGlFunctionPrototypeString:this.webGlFunctionPrototypeString=this.generate()}},{key:"build",value:function(){return this.getFunctionPrototypeString().length>0}}],[{key:"astFunctionPrototype",value:function(t,e){if(this.isRootKernel||this.isSubKernel)return e;e.push(this.returnType),e.push(" "),e.push(this.functionName),e.push("(");for(var n=0;n0&&e.push(", "),e.push(this.paramTypes[n]),e.push(" "),e.push("user_"),e.push(this.paramNames[n]);return e.push(");\n"),e}}]),e}(u)},{"../../core/utils":32,"../function-node-base":7}],13:[function(t,e,n){function r(t){return/^function /.test(t)&&(t=t.substring(9)),t.replace(/[_]typeof/g,"typeof")}function i(t){return t.replace(/[_]typeof/g,"typeof")}var s=t("../../core/utils"),a=t("../kernel-run-shortcut");e.exports=function(t,e){return"() => {\n "+a.toString()+";\n const utils = {\n allPropertiesOf: "+i(s.allPropertiesOf.toString())+",\n clone: "+i(s.clone.toString())+",\n splitArray: "+i(s.splitArray.toString())+",\n getArgumentType: "+i(s.getArgumentType.toString())+",\n getDimensions: "+i(s.getDimensions.toString())+",\n dimToTexSize: "+i(s.dimToTexSize.toString())+",\n flattenTo: "+i(s.flattenTo.toString())+",\n flatten2dArrayTo: "+i(s.flatten2dArrayTo.toString())+",\n flatten3dArrayTo: "+i(s.flatten3dArrayTo.toString())+",\n systemEndianness: '"+i(s.systemEndianness())+"',\n initWebGl: "+i(s.initWebGl.toString())+",\n isArray: "+i(s.isArray.toString())+",\n checkOutput: "+i(s.checkOutput.toString())+"\n };\n const Utils = utils;\n const canvases = [];\n const maxTexSizes = {};\n class "+(e||"Kernel")+" {\n constructor() {\n this.maxTexSize = null;\n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = "+JSON.stringify(t.paramNames)+";\n this.paramTypes = "+JSON.stringify(t.paramTypes)+";\n this.texSize = "+JSON.stringify(t.texSize)+";\n this.output = "+JSON.stringify(t.output)+";\n this.compiledFragShaderString = `"+t.compiledFragShaderString+"`;\n\t\t this.compiledVertShaderString = `"+t.compiledVertShaderString+"`;\n\t\t this.programUniformLocationCache = {};\n\t\t this.textureCache = {};\n\t\t this.subKernelOutputTextures = null;\n\t\t this.subKernelOutputVariableNames = null;\n\t\t this.uniform1fCache = {};\n\t\t this.uniform1iCache = {};\n\t\t this.uniform2fCache = {};\n\t\t this.uniform2fvCache = {};\n\t\t this.uniform3fvCache = {};\n }\n "+r(t._getFragShaderString.toString())+"\n "+r(t._getVertShaderString.toString())+"\n validateOptions() {}\n setupParams() {}\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n "+r(t.getUniformLocation.toString())+"\n "+r(t.setupParams.toString())+"\n "+r(t.build.toString())+"\n\t\t "+r(t.run.toString())+"\n\t\t "+r(t._addArgument.toString())+"\n\t\t "+r(t.getArgumentTexture.toString())+"\n\t\t "+r(t.getTextureCache.toString())+"\n\t\t "+r(t.getOutputTexture.toString())+"\n\t\t "+r(t.renderOutput.toString())+"\n\t\t "+r(t.updateMaxTexSize.toString())+"\n\t\t "+r(t._setupOutputTexture.toString())+"\n\t\t "+r(t.detachTextureCache.toString())+"\n\t\t "+r(t.setUniform1f.toString())+"\n\t\t "+r(t.setUniform1i.toString())+"\n\t\t "+r(t.setUniform2f.toString())+"\n\t\t "+r(t.setUniform2fv.toString())+"\n\t\t "+r(t.setUniform3fv.toString())+" \n };\n return kernelRunShortcut(new Kernel());\n };"}},{"../../core/utils":32,"../kernel-run-shortcut":9}],14:[function(t,e,n){function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var a=function(){function t(t,e){for(var n=0;n0&&this._setupSubOutputTextures(this.subKernelOutputVariableNames.length))}},{key:"run",value:function(){null===this.program&&this.build.apply(this,arguments);var t=this.paramNames,e=this.paramTypes,n=this.texSize,r=this._webGl;r.useProgram(this.program),r.scissor(0,0,n[0],n[1]),this.hardcodeConstants||(this.setUniform3fv("uOutputDim",this.threadDim),this.setUniform2fv("uTexSize",n)),this.setUniform2f("ratio",n[0]/this.maxTexSize[0],n[1]/this.maxTexSize[1]),this.argumentsLength=0;for(var i=0;i0?t.join(";\n")+";\n":"\n"}},{key:"_replaceArtifacts",value:function(t,e){return t.replace(/[ ]*__([A-Z]+[0-9]*([_]?[A-Z])*)__;\n/g,function(t,n){if(e.hasOwnProperty(n))return e[n];throw"unhandled artifact "+n})}},{key:"_addKernels",value:function(){var t=this,e=this.functionBuilder,n=this._webGl;if(e.addFunctions(this.functions,{constants:this.constants,output:this.output}),e.addNativeFunctions(this.nativeFunctions),e.addKernel(this.fnString,{prototypeOnly:!1,constants:this.constants,output:this.output,debug:this.debug,loopMaxIterations:this.loopMaxIterations,paramNames:this.paramNames,paramTypes:this.paramTypes}),null!==this.subKernels){var r=this.drawBuffers=n.getExtension("WEBGL_draw_buffers");if(!r)throw new Error("could not instantiate draw buffers extension");this.subKernelOutputVariableNames=[],this.subKernels.forEach(function(e){return t._addSubKernel(e)})}else if(null!==this.subKernelProperties){var i=this.drawBuffers=n.getExtension("WEBGL_draw_buffers");if(!i)throw new Error("could not instantiate draw buffers extension");this.subKernelOutputVariableNames=[],Object.keys(this.subKernelProperties).forEach(function(e){return t._addSubKernel(t.subKernelProperties[e])})}}},{key:"_addSubKernel",value:function(t){this.functionBuilder.addSubKernel(t,{prototypeOnly:!1,constants:this.constants,output:this.output,debug:this.debug,loopMaxIterations:this.loopMaxIterations}),this.subKernelOutputVariableNames.push(t.name+"Result")}},{key:"_getFragShaderString",value:function(t){return null!==this.compiledFragShaderString?this.compiledFragShaderString:this.compiledFragShaderString=this._replaceArtifacts(this.constructor.fragShaderString,this._getFragShaderArtifactMap(t))}},{key:"_getVertShaderString",value:function(t){return null!==this.compiledVertShaderString?this.compiledVertShaderString:this.compiledVertShaderString=this.constructor.vertShaderString}},{key:"toString",value:function(){return c(this)}},{key:"addFunction",value:function(t){this.functionBuilder.addFunction(null,t)}}]),e}(o)},{"../../core/texture":30,"../../core/utils":32,"../kernel-base":8,"./kernel-string":13,"./shader-frag":16,"./shader-vert":17}],15:[function(t,e,n){function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var a=function(){function t(t,e){for(var n=0;n0&&e.push(", ");var i=this.getParamType(r);switch(i){case"Texture":case"Input":case"Array":case"HTMLImage":e.push("sampler2D");break;default:e.push("float")}e.push(" "),e.push("user_"),e.push(r)}e.push(") {\n");for(var s=0;st)return!1;if(n+=e[r+1],n>=t)return!0}}function n(t,n){return t<65?36===t:t<91||(t<97?95===t:t<123||(t<=65535?t>=170&&U.test(String.fromCharCode(t)):n!==!1&&e(t,V)))}function r(t,n){return t<48?36===t:t<58||!(t<65)&&(t<91||(t<97?95===t:t<123||(t<=65535?t>=170&&M.test(String.fromCharCode(t)):n!==!1&&(e(t,V)||e(t,j)))))}function i(t,e){return new B(t,{beforeExpr:!0,binop:e})}function s(t,e){return void 0===e&&(e={}),e.keyword=t,X[t]=new B(t,e)}function a(t){return 10===t||13===t||8232===t||8233===t}function o(t,e){return Z.call(t,e)}function u(t,e){for(var n=1,r=0;;){q.lastIndex=r;var i=q.exec(t);if(!(i&&i.index=2015&&(e.ecmaVersion-=2009),null==e.allowReserved&&(e.allowReserved=e.ecmaVersion<5),tt(e.onToken)){var r=e.onToken;e.onToken=function(t){return r.push(t)}}return tt(e.onComment)&&(e.onComment=p(e,e.onComment)),e}function p(t,e){return function(n,r,i,s,a,o){var u={type:n?"Block":"Line",value:r,start:i,end:s};t.locations&&(u.loc=new nt(this,a,o)),t.ranges&&(u.range=[i,s]),e.push(u)}}function l(t){return new RegExp("^(?:"+t.replace(/ /g,"|")+")$")}function c(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1}function f(t,e,n,r){return t.type=e,t.end=n,this.options.locations&&(t.loc.end=r),this.options.ranges&&(t.range[1]=n),t}function d(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(1023&t)+56320))}function g(t){return 36===t||t>=40&&t<=43||46===t||63===t||t>=91&&t<=94||t>=123&&t<=125}function m(t){return n(t,!0)||36===t||95===t}function y(t){return r(t,!0)||36===t||95===t||8204===t||8205===t}function x(t){return t>=65&&t<=90||t>=97&&t<=122}function v(t){return t>=0&&t<=1114111}function b(t){return 100===t||68===t||115===t||83===t||119===t||87===t}function _(t){return x(t)||95===t}function E(t){return _(t)||T(t)}function T(t){return t>=48&&t<=57}function S(t){return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function k(t){return t>=65&&t<=70?10+(t-65):t>=97&&t<=102?10+(t-97):t-48}function w(t){return t>=48&&t<=55}function A(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(1023&t)+56320))}function O(t,e){return new st(e,t).parse()}function C(t,e,n){var r=new st(n,t,e);return r.nextToken(),r.parseExpression()}function R(t,e){return new st(e,t)}function P(e,n,r){t.parse_dammit=e,t.LooseParser=n,t.pluginsLoose=r}var N={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},I="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",D={5:I,6:I+" const class extends export import super"},L=/^in(stanceof)?$/,F="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࢠ-ࢴࢶ-ࢽऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲈᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄮㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿪ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞮꞰ-ꞷꟷ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭥꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",G="‌‍·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࣔ-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍ୖୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఃా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ංඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ູົຼ່-ໍ໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠐-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭ᳲ-᳴᳷-᳹᷀-᷹᷻-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱꤀-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_",U=new RegExp("["+F+"]"),M=new RegExp("["+F+G+"]");F=G=null;var V=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,26,45,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,785,52,76,44,33,24,27,35,42,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,54,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,86,25,391,63,32,0,257,0,11,39,8,0,22,0,12,39,3,3,55,56,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,698,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,881,68,12,0,67,12,65,1,31,6124,20,754,9486,286,82,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,4149,196,60,67,1213,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42710,42,4148,12,221,3,5761,15,7472,3104,541],j=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,1306,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,52,0,13,2,49,13,10,2,4,9,83,11,7,0,161,11,6,9,7,3,57,0,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,87,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,423,9,280,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,19719,9,135,4,60,6,26,9,1016,45,17,3,19723,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,2214,6,110,6,6,9,792487,239],B=function(t,e){void 0===e&&(e={}),this.label=t,this.keyword=e.keyword,this.beforeExpr=!!e.beforeExpr,this.startsExpr=!!e.startsExpr,this.isLoop=!!e.isLoop,this.isAssign=!!e.isAssign,this.prefix=!!e.prefix,this.postfix=!!e.postfix,this.binop=e.binop||null,this.updateContext=null},z={beforeExpr:!0},K={startsExpr:!0},X={},W={num:new B("num",K),regexp:new B("regexp",K),string:new B("string",K),name:new B("name",K),eof:new B("eof"),bracketL:new B("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new B("]"),braceL:new B("{",{beforeExpr:!0,startsExpr:!0}),braceR:new B("}"),parenL:new B("(",{beforeExpr:!0,startsExpr:!0}),parenR:new B(")"),comma:new B(",",z),semi:new B(";",z),colon:new B(":",z),dot:new B("."),question:new B("?",z),arrow:new B("=>",z),template:new B("template"),invalidTemplate:new B("invalidTemplate"),ellipsis:new B("...",z),backQuote:new B("`",K),dollarBraceL:new B("${",{beforeExpr:!0,startsExpr:!0}),eq:new B("=",{beforeExpr:!0,isAssign:!0}),assign:new B("_=",{beforeExpr:!0,isAssign:!0}),incDec:new B("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new B("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:i("||",1),logicalAND:i("&&",2),bitwiseOR:i("|",3),bitwiseXOR:i("^",4),bitwiseAND:i("&",5),equality:i("==/!=/===/!==",6),relational:i("/<=/>=",7),bitShift:i("<>/>>>",8),plusMin:new B("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:i("%",10),star:i("*",10),slash:i("/",10),starstar:new B("**",{beforeExpr:!0}),_break:s("break"),_case:s("case",z),_catch:s("catch"),_continue:s("continue"),_debugger:s("debugger"),_default:s("default",z),_do:s("do",{isLoop:!0,beforeExpr:!0}),_else:s("else",z),_finally:s("finally"),_for:s("for",{isLoop:!0}),_function:s("function",K),_if:s("if"),_return:s("return",z),_switch:s("switch"),_throw:s("throw",z),_try:s("try"),_var:s("var"),_const:s("const"),_while:s("while",{isLoop:!0}),_with:s("with"),_new:s("new",{beforeExpr:!0,startsExpr:!0}),_this:s("this",K),_super:s("super",K),_class:s("class",K),_extends:s("extends",z),_export:s("export"),_import:s("import"),_null:s("null",K),_true:s("true",K),_false:s("false",K),_in:s("in",{beforeExpr:!0,binop:7}),_instanceof:s("instanceof",{beforeExpr:!0,binop:7}),_typeof:s("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:s("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:s("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},H=/\r\n?|\n|\u2028|\u2029/,q=new RegExp(H.source,"g"),Y=/[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/,J=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,Q=Object.prototype,Z=Q.hasOwnProperty,$=Q.toString,tt=Array.isArray||function(t){return"[object Array]"===$.call(t)},et=function(t,e){this.line=t,this.column=e};et.prototype.offset=function(t){return new et(this.line,this.column+t)};var nt=function(t,e,n){this.start=e,this.end=n,null!==t.sourceFile&&(this.source=t.sourceFile)},rt={ecmaVersion:7,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowHashBang:!1,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1,plugins:{}},it={},st=function(t,e,n){this.options=t=h(t),this.sourceFile=t.sourceFile,this.keywords=l(D[t.ecmaVersion>=6?6:5]);var r="";if(!t.allowReserved){for(var i=t.ecmaVersion;!(r=N[i]);i--);"module"==t.sourceType&&(r+=" await")}this.reservedWords=l(r);var s=(r?r+" ":"")+N.strict;this.reservedWordsStrict=l(s),this.reservedWordsStrictBind=l(s+" "+N.strictBind),this.input=String(e),this.containsEsc=!1,this.loadPlugins(t.plugins),n?(this.pos=n,this.lineStart=this.input.lastIndexOf("\n",n-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(H).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=W.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule="module"===t.sourceType,this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.inFunction=this.inGenerator=this.inAsync=!1,this.yieldPos=this.awaitPos=0,this.labels=[],0===this.pos&&t.allowHashBang&&"#!"===this.input.slice(0,2)&&this.skipLineComment(2),this.scopeStack=[],this.enterFunctionScope(),this.regexpState=null};st.prototype.isKeyword=function(t){return this.keywords.test(t)},st.prototype.isReservedWord=function(t){return this.reservedWords.test(t)},st.prototype.extend=function(t,e){this[t]=e(this[t])},st.prototype.loadPlugins=function(t){var e=this;for(var n in t){var r=it[n];if(!r)throw new Error("Plugin '"+n+"' not found");r(e,t[n])}},st.prototype.parse=function(){var t=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(t)};var at=st.prototype,ot=/^(?:'((?:\\.|[^'])*?)'|"((?:\\.|[^"])*?)"|;)/;at.strictDirective=function(t){for(var e=this;;){J.lastIndex=t,t+=J.exec(e.input)[0].length;var n=ot.exec(e.input.slice(t));if(!n)return!1;if("use strict"==(n[1]||n[2]))return!0;t+=n[0].length}},at.eat=function(t){return this.type===t&&(this.next(),!0)},at.isContextual=function(t){return this.type===W.name&&this.value===t&&!this.containsEsc},at.eatContextual=function(t){return!!this.isContextual(t)&&(this.next(),!0)},at.expectContextual=function(t){this.eatContextual(t)||this.unexpected()},at.canInsertSemicolon=function(){return this.type===W.eof||this.type===W.braceR||H.test(this.input.slice(this.lastTokEnd,this.start))},at.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},at.semicolon=function(){this.eat(W.semi)||this.insertSemicolon()||this.unexpected()},at.afterTrailingComma=function(t,e){if(this.type==t)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),e||this.next(),!0},at.expect=function(t){this.eat(t)||this.unexpected()},at.unexpected=function(t){this.raise(null!=t?t:this.start,"Unexpected token")},at.checkPatternErrors=function(t,e){if(t){t.trailingComma>-1&&this.raiseRecoverable(t.trailingComma,"Comma is not permitted after the rest element");var n=e?t.parenthesizedAssign:t.parenthesizedBind;n>-1&&this.raiseRecoverable(n,"Parenthesized pattern")}},at.checkExpressionErrors=function(t,e){if(!t)return!1;var n=t.shorthandAssign,r=t.doubleProto;return e?(n>=0&&this.raise(n,"Shorthand property assignments are valid only in destructuring patterns"),void(r>=0&&this.raiseRecoverable(r,"Redefinition of __proto__ property"))):n>=0||r>=0},at.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos=6&&(t.sourceType=this.options.sourceType),this.finishNode(t,"Program")};var ht={kind:"loop"},pt={kind:"switch"};ut.isLet=function(){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;J.lastIndex=this.pos;var t=J.exec(this.input),e=this.pos+t[0].length,i=this.input.charCodeAt(e);if(91===i||123==i)return!0;if(n(i,!0)){for(var s=e+1;r(this.input.charCodeAt(s),!0);)++s;var a=this.input.slice(e,s);if(!L.test(a))return!0}return!1},ut.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;J.lastIndex=this.pos;var t=J.exec(this.input),e=this.pos+t[0].length;return!(H.test(this.input.slice(this.pos,e))||"function"!==this.input.slice(e,e+8)||e+8!=this.input.length&&r(this.input.charAt(e+8)))},ut.parseStatement=function(t,e,n){var r,i=this.type,s=this.startNode();switch(this.isLet()&&(i=W._var,r="let"),i){case W._break:case W._continue:return this.parseBreakContinueStatement(s,i.keyword);case W._debugger:return this.parseDebuggerStatement(s);case W._do:return this.parseDoStatement(s);case W._for:return this.parseForStatement(s);case W._function:return!t&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(s,!1);case W._class:return t||this.unexpected(),this.parseClass(s,!0);case W._if:return this.parseIfStatement(s);case W._return:return this.parseReturnStatement(s);case W._switch:return this.parseSwitchStatement(s);case W._throw:return this.parseThrowStatement(s);case W._try:return this.parseTryStatement(s);case W._const:case W._var:return r=r||this.value,t||"var"==r||this.unexpected(),this.parseVarStatement(s,r);case W._while:return this.parseWhileStatement(s);case W._with:return this.parseWithStatement(s);case W.braceL:return this.parseBlock();case W.semi:return this.parseEmptyStatement(s);case W._export:case W._import:return this.options.allowImportExportEverywhere||(e||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),i===W._import?this.parseImport(s):this.parseExport(s,n);default:if(this.isAsyncFunction())return t||this.unexpected(),this.next(),this.parseFunctionStatement(s,!0);var a=this.value,o=this.parseExpression();return i===W.name&&"Identifier"===o.type&&this.eat(W.colon)?this.parseLabeledStatement(s,a,o):this.parseExpressionStatement(s,o)}},ut.parseBreakContinueStatement=function(t,e){var n=this,r="break"==e;this.next(),this.eat(W.semi)||this.insertSemicolon()?t.label=null:this.type!==W.name?this.unexpected():(t.label=this.parseIdent(),this.semicolon());for(var i=0;i=6?this.eat(W.semi):this.semicolon(),this.finishNode(t,"DoWhileStatement")},ut.parseForStatement=function(t){this.next();var e=this.options.ecmaVersion>=9&&this.inAsync&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(ht),this.enterLexicalScope(),this.expect(W.parenL),this.type===W.semi)return e>-1&&this.unexpected(e),this.parseFor(t,null);var n=this.isLet();if(this.type===W._var||this.type===W._const||n){var r=this.startNode(),i=n?"let":this.value;return this.next(),this.parseVar(r,!0,i),this.finishNode(r,"VariableDeclaration"),!(this.type===W._in||this.options.ecmaVersion>=6&&this.isContextual("of"))||1!==r.declarations.length||"var"!==i&&r.declarations[0].init?(e>-1&&this.unexpected(e),this.parseFor(t,r)):(this.options.ecmaVersion>=9&&(this.type===W._in?e>-1&&this.unexpected(e):t.await=e>-1),this.parseForIn(t,r))}var s=new c,a=this.parseExpression(!0,s);return this.type===W._in||this.options.ecmaVersion>=6&&this.isContextual("of")?(this.options.ecmaVersion>=9&&(this.type===W._in?e>-1&&this.unexpected(e):t.await=e>-1),this.toAssignable(a,!1,s),this.checkLVal(a),this.parseForIn(t,a)):(this.checkExpressionErrors(s,!0),e>-1&&this.unexpected(e),this.parseFor(t,a))},ut.parseFunctionStatement=function(t,e){return this.next(),this.parseFunction(t,!0,!1,e)},ut.parseIfStatement=function(t){return this.next(),t.test=this.parseParenExpression(),t.consequent=this.parseStatement(!this.strict&&this.type==W._function),t.alternate=this.eat(W._else)?this.parseStatement(!this.strict&&this.type==W._function):null,this.finishNode(t,"IfStatement")},ut.parseReturnStatement=function(t){return this.inFunction||this.options.allowReturnOutsideFunction||this.raise(this.start,"'return' outside of function"),this.next(),this.eat(W.semi)||this.insertSemicolon()?t.argument=null:(t.argument=this.parseExpression(),this.semicolon()),this.finishNode(t,"ReturnStatement")},ut.parseSwitchStatement=function(t){var e=this;this.next(),t.discriminant=this.parseParenExpression(),t.cases=[],this.expect(W.braceL),this.labels.push(pt),this.enterLexicalScope();for(var n,r=!1;this.type!=W.braceR;)if(e.type===W._case||e.type===W._default){var i=e.type===W._case;n&&e.finishNode(n,"SwitchCase"),t.cases.push(n=e.startNode()),n.consequent=[],e.next(),i?n.test=e.parseExpression():(r&&e.raiseRecoverable(e.lastTokStart,"Multiple default clauses"),r=!0,n.test=null),e.expect(W.colon)}else n||e.unexpected(),n.consequent.push(e.parseStatement(!0));return this.exitLexicalScope(),n&&this.finishNode(n,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(t,"SwitchStatement")},ut.parseThrowStatement=function(t){return this.next(),H.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),t.argument=this.parseExpression(),this.semicolon(),this.finishNode(t,"ThrowStatement")};var lt=[];ut.parseTryStatement=function(t){if(this.next(),t.block=this.parseBlock(),t.handler=null,this.type===W._catch){var e=this.startNode();this.next(),this.expect(W.parenL),e.param=this.parseBindingAtom(),this.enterLexicalScope(),this.checkLVal(e.param,"let"),this.expect(W.parenR),e.body=this.parseBlock(!1),this.exitLexicalScope(),t.handler=this.finishNode(e,"CatchClause")}return t.finalizer=this.eat(W._finally)?this.parseBlock():null,t.handler||t.finalizer||this.raise(t.start,"Missing catch or finally clause"),this.finishNode(t,"TryStatement")},ut.parseVarStatement=function(t,e){return this.next(),this.parseVar(t,!1,e),this.semicolon(),this.finishNode(t,"VariableDeclaration")},ut.parseWhileStatement=function(t){return this.next(),t.test=this.parseParenExpression(),this.labels.push(ht),t.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(t,"WhileStatement")},ut.parseWithStatement=function(t){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),t.object=this.parseParenExpression(),t.body=this.parseStatement(!1),this.finishNode(t,"WithStatement")},ut.parseEmptyStatement=function(t){return this.next(),this.finishNode(t,"EmptyStatement")},ut.parseLabeledStatement=function(t,e,n){for(var r=this,i=0,s=r.labels;i=0;u--){var h=r.labels[u];if(h.statementStart!=t.start)break;h.statementStart=r.start,h.kind=o}return this.labels.push({name:e,kind:o,statementStart:this.start}),t.body=this.parseStatement(!0),("ClassDeclaration"==t.body.type||"VariableDeclaration"==t.body.type&&"var"!=t.body.kind||"FunctionDeclaration"==t.body.type&&(this.strict||t.body.generator))&&this.raiseRecoverable(t.body.start,"Invalid labeled declaration"),this.labels.pop(),t.label=n,this.finishNode(t,"LabeledStatement")},ut.parseExpressionStatement=function(t,e){return t.expression=e,this.semicolon(),this.finishNode(t,"ExpressionStatement")},ut.parseBlock=function(t){var e=this;void 0===t&&(t=!0);var n=this.startNode();for(n.body=[],this.expect(W.braceL),t&&this.enterLexicalScope();!this.eat(W.braceR);){var r=e.parseStatement(!0);n.body.push(r)}return t&&this.exitLexicalScope(),this.finishNode(n,"BlockStatement")},ut.parseFor=function(t,e){return t.init=e,this.expect(W.semi),t.test=this.type===W.semi?null:this.parseExpression(),this.expect(W.semi),t.update=this.type===W.parenR?null:this.parseExpression(),this.expect(W.parenR),this.exitLexicalScope(),t.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(t,"ForStatement")},ut.parseForIn=function(t,e){var n=this.type===W._in?"ForInStatement":"ForOfStatement";return this.next(),"ForInStatement"==n&&("AssignmentPattern"===e.type||"VariableDeclaration"===e.type&&null!=e.declarations[0].init&&(this.strict||"Identifier"!==e.declarations[0].id.type))&&this.raise(e.start,"Invalid assignment in for-in loop head"),t.left=e,t.right="ForInStatement"==n?this.parseExpression():this.parseMaybeAssign(),this.expect(W.parenR),this.exitLexicalScope(),t.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(t,n)},ut.parseVar=function(t,e,n){var r=this;for(t.declarations=[],t.kind=n;;){var i=r.startNode();if(r.parseVarId(i,n),r.eat(W.eq)?i.init=r.parseMaybeAssign(e):"const"!==n||r.type===W._in||r.options.ecmaVersion>=6&&r.isContextual("of")?"Identifier"==i.id.type||e&&(r.type===W._in||r.isContextual("of"))?i.init=null:r.raise(r.lastTokEnd,"Complex binding patterns require an initialization value"):r.unexpected(),t.declarations.push(r.finishNode(i,"VariableDeclarator")),!r.eat(W.comma))break}return t},ut.parseVarId=function(t,e){t.id=this.parseBindingAtom(e),this.checkLVal(t.id,e,!1)},ut.parseFunction=function(t,e,n,r){this.initFunction(t),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(t.generator=this.eat(W.star)),this.options.ecmaVersion>=8&&(t.async=!!r),e&&(t.id="nullableID"===e&&this.type!=W.name?null:this.parseIdent(),t.id&&this.checkLVal(t.id,"var"));var i=this.inGenerator,s=this.inAsync,a=this.yieldPos,o=this.awaitPos,u=this.inFunction;return this.inGenerator=t.generator,this.inAsync=t.async,this.yieldPos=0,this.awaitPos=0,this.inFunction=!0,this.enterFunctionScope(),e||(t.id=this.type==W.name?this.parseIdent():null),this.parseFunctionParams(t),this.parseFunctionBody(t,n),this.inGenerator=i,this.inAsync=s,this.yieldPos=a,this.awaitPos=o,this.inFunction=u,this.finishNode(t,e?"FunctionDeclaration":"FunctionExpression")},ut.parseFunctionParams=function(t){this.expect(W.parenL),t.params=this.parseBindingList(W.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},ut.parseClass=function(t,e){var n=this;this.next(),this.parseClassId(t,e),this.parseClassSuper(t);var r=this.startNode(),i=!1;for(r.body=[],this.expect(W.braceL);!this.eat(W.braceR);){var s=n.parseClassMember(r);s&&"MethodDefinition"===s.type&&"constructor"===s.kind&&(i&&n.raise(s.start,"Duplicate constructor in the same class"),i=!0)}return t.body=this.finishNode(r,"ClassBody"),this.finishNode(t,e?"ClassDeclaration":"ClassExpression")},ut.parseClassMember=function(t){var e=this;if(this.eat(W.semi))return null;var n=this.startNode(),r=function(t,r){void 0===r&&(r=!1);var i=e.start,s=e.startLoc;return!!e.eatContextual(t)&&(!(e.type===W.parenL||r&&e.canInsertSemicolon())||(n.key&&e.unexpected(),n.computed=!1,n.key=e.startNodeAt(i,s),n.key.name=t,e.finishNode(n.key,"Identifier"),!1))};n.kind="method",n["static"]=r("static");var i=this.eat(W.star),s=!1;i||(this.options.ecmaVersion>=8&&r("async",!0)?(s=!0,i=this.options.ecmaVersion>=9&&this.eat(W.star)):r("get")?n.kind="get":r("set")&&(n.kind="set")),n.key||this.parsePropertyName(n);var a=n.key;return n.computed||n["static"]||!("Identifier"===a.type&&"constructor"===a.name||"Literal"===a.type&&"constructor"===a.value)?n["static"]&&"Identifier"===a.type&&"prototype"===a.name&&this.raise(a.start,"Classes may not have a static property named prototype"):("method"!==n.kind&&this.raise(a.start,"Constructor can't have get/set modifier"),i&&this.raise(a.start,"Constructor can't be a generator"),s&&this.raise(a.start,"Constructor can't be an async method"),n.kind="constructor"),this.parseClassMethod(t,n,i,s),"get"===n.kind&&0!==n.value.params.length&&this.raiseRecoverable(n.value.start,"getter should have no params"),"set"===n.kind&&1!==n.value.params.length&&this.raiseRecoverable(n.value.start,"setter should have exactly one param"),"set"===n.kind&&"RestElement"===n.value.params[0].type&&this.raiseRecoverable(n.value.params[0].start,"Setter cannot use rest params"),n},ut.parseClassMethod=function(t,e,n,r){e.value=this.parseMethod(n,r),t.body.push(this.finishNode(e,"MethodDefinition"))},ut.parseClassId=function(t,e){t.id=this.type===W.name?this.parseIdent():e===!0?this.unexpected():null},ut.parseClassSuper=function(t){t.superClass=this.eat(W._extends)?this.parseExprSubscripts():null},ut.parseExport=function(t,e){var n=this;if(this.next(),this.eat(W.star))return this.expectContextual("from"),this.type!==W.string&&this.unexpected(),t.source=this.parseExprAtom(),this.semicolon(),this.finishNode(t,"ExportAllDeclaration");if(this.eat(W._default)){this.checkExport(e,"default",this.lastTokStart);var r;if(this.type===W._function||(r=this.isAsyncFunction())){var i=this.startNode();this.next(),r&&this.next(),t.declaration=this.parseFunction(i,"nullableID",!1,r)}else if(this.type===W._class){var s=this.startNode();t.declaration=this.parseClass(s,"nullableID")}else t.declaration=this.parseMaybeAssign(),this.semicolon();return this.finishNode(t,"ExportDefaultDeclaration")}if(this.shouldParseExportStatement())t.declaration=this.parseStatement(!0),"VariableDeclaration"===t.declaration.type?this.checkVariableExport(e,t.declaration.declarations):this.checkExport(e,t.declaration.id.name,t.declaration.id.start),t.specifiers=[],t.source=null;else{if(t.declaration=null,t.specifiers=this.parseExportSpecifiers(e),this.eatContextual("from"))this.type!==W.string&&this.unexpected(),t.source=this.parseExprAtom();else{for(var a=0,o=t.specifiers;a=6&&t)switch(t.type){case"Identifier":this.inAsync&&"await"===t.name&&this.raise(t.start,"Can not use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"RestElement":break;case"ObjectExpression":t.type="ObjectPattern", +n&&this.checkPatternErrors(n,!0);for(var i=0,s=t.properties;i=9&&"SpreadElement"===t.type||this.options.ecmaVersion>=6&&(t.computed||t.method||t.shorthand))){var r,i=t.key;switch(i.type){case"Identifier":r=i.name;break;case"Literal":r=String(i.value);break;default:return}var s=t.kind;if(this.options.ecmaVersion>=6)return void("__proto__"===r&&"init"===s&&(e.proto&&(n&&n.doubleProto<0?n.doubleProto=i.start:this.raiseRecoverable(i.start,"Redefinition of __proto__ property")),e.proto=!0));r="$"+r;var a=e[r];if(a){var o;o="init"===s?this.strict&&a.init||a.get||a.set:a.init||a[s],o&&this.raiseRecoverable(i.start,"Redefinition of property")}else a=e[r]={init:!1,get:!1,set:!1};a[s]=!0}},ft.parseExpression=function(t,e){var n=this,r=this.start,i=this.startLoc,s=this.parseMaybeAssign(t,e);if(this.type===W.comma){var a=this.startNodeAt(r,i);for(a.expressions=[s];this.eat(W.comma);)a.expressions.push(n.parseMaybeAssign(t,e));return this.finishNode(a,"SequenceExpression")}return s},ft.parseMaybeAssign=function(t,e,n){if(this.inGenerator&&this.isContextual("yield"))return this.parseYield();var r=!1,i=-1,s=-1;e?(i=e.parenthesizedAssign,s=e.trailingComma,e.parenthesizedAssign=e.trailingComma=-1):(e=new c,r=!0);var a=this.start,o=this.startLoc;this.type!=W.parenL&&this.type!=W.name||(this.potentialArrowAt=this.start);var u=this.parseMaybeConditional(t,e);if(n&&(u=n.call(this,u,a,o)),this.type.isAssign){var h=this.startNodeAt(a,o);return h.operator=this.value,h.left=this.type===W.eq?this.toAssignable(u,!1,e):u,r||c.call(e),e.shorthandAssign=-1,this.checkLVal(u),this.next(),h.right=this.parseMaybeAssign(t),this.finishNode(h,"AssignmentExpression")}return r&&this.checkExpressionErrors(e,!0),i>-1&&(e.parenthesizedAssign=i),s>-1&&(e.trailingComma=s),u},ft.parseMaybeConditional=function(t,e){var n=this.start,r=this.startLoc,i=this.parseExprOps(t,e);if(this.checkExpressionErrors(e))return i;if(this.eat(W.question)){var s=this.startNodeAt(n,r);return s.test=i,s.consequent=this.parseMaybeAssign(),this.expect(W.colon),s.alternate=this.parseMaybeAssign(t),this.finishNode(s,"ConditionalExpression")}return i},ft.parseExprOps=function(t,e){var n=this.start,r=this.startLoc,i=this.parseMaybeUnary(e,!1);return this.checkExpressionErrors(e)?i:i.start==n&&"ArrowFunctionExpression"===i.type?i:this.parseExprOp(i,n,r,-1,t)},ft.parseExprOp=function(t,e,n,r,i){var s=this.type.binop;if(null!=s&&(!i||this.type!==W._in)&&s>r){var a=this.type===W.logicalOR||this.type===W.logicalAND,o=this.value;this.next();var u=this.start,h=this.startLoc,p=this.parseExprOp(this.parseMaybeUnary(null,!1),u,h,s,i),l=this.buildBinary(e,n,t,p,o,a);return this.parseExprOp(l,e,n,r,i)}return t},ft.buildBinary=function(t,e,n,r,i,s){var a=this.startNodeAt(t,e);return a.left=n,a.operator=i,a.right=r,this.finishNode(a,s?"LogicalExpression":"BinaryExpression")},ft.parseMaybeUnary=function(t,e){var n,r=this,i=this.start,s=this.startLoc;if(this.inAsync&&this.isContextual("await"))n=this.parseAwait(),e=!0;else if(this.type.prefix){var a=this.startNode(),o=this.type===W.incDec;a.operator=this.value,a.prefix=!0,this.next(),a.argument=this.parseMaybeUnary(null,!0),this.checkExpressionErrors(t,!0),o?this.checkLVal(a.argument):this.strict&&"delete"===a.operator&&"Identifier"===a.argument.type?this.raiseRecoverable(a.start,"Deleting local variable in strict mode"):e=!0,n=this.finishNode(a,o?"UpdateExpression":"UnaryExpression")}else{if(n=this.parseExprSubscripts(t),this.checkExpressionErrors(t))return n;for(;this.type.postfix&&!this.canInsertSemicolon();){var u=r.startNodeAt(i,s);u.operator=r.value,u.prefix=!1,u.argument=n,r.checkLVal(n),r.next(),n=r.finishNode(u,"UpdateExpression")}}return!e&&this.eat(W.starstar)?this.buildBinary(i,s,n,this.parseMaybeUnary(null,!1),"**",!1):n},ft.parseExprSubscripts=function(t){var e=this.start,n=this.startLoc,r=this.parseExprAtom(t),i="ArrowFunctionExpression"===r.type&&")"!==this.input.slice(this.lastTokStart,this.lastTokEnd);if(this.checkExpressionErrors(t)||i)return r;var s=this.parseSubscripts(r,e,n);return t&&"MemberExpression"===s.type&&(t.parenthesizedAssign>=s.start&&(t.parenthesizedAssign=-1),t.parenthesizedBind>=s.start&&(t.parenthesizedBind=-1)),s},ft.parseSubscripts=function(t,e,n,r){for(var i=this,s=this.options.ecmaVersion>=8&&"Identifier"===t.type&&"async"===t.name&&this.lastTokEnd==t.end&&!this.canInsertSemicolon()&&"async"===this.input.slice(t.start,t.end),a=void 0;;)if((a=i.eat(W.bracketL))||i.eat(W.dot)){var o=i.startNodeAt(e,n);o.object=t,o.property=a?i.parseExpression():i.parseIdent(!0),o.computed=!!a,a&&i.expect(W.bracketR),t=i.finishNode(o,"MemberExpression")}else if(!r&&i.eat(W.parenL)){var u=new c,h=i.yieldPos,p=i.awaitPos;i.yieldPos=0,i.awaitPos=0;var l=i.parseExprList(W.parenR,i.options.ecmaVersion>=8,!1,u);if(s&&!i.canInsertSemicolon()&&i.eat(W.arrow))return i.checkPatternErrors(u,!1),i.checkYieldAwaitInDefaultParams(),i.yieldPos=h,i.awaitPos=p,i.parseArrowExpression(i.startNodeAt(e,n),l,!0);i.checkExpressionErrors(u,!0),i.yieldPos=h||i.yieldPos,i.awaitPos=p||i.awaitPos;var f=i.startNodeAt(e,n);f.callee=t,f.arguments=l,t=i.finishNode(f,"CallExpression")}else{if(i.type!==W.backQuote)return t;var d=i.startNodeAt(e,n);d.tag=t,d.quasi=i.parseTemplate({isTagged:!0}),t=i.finishNode(d,"TaggedTemplateExpression")}},ft.parseExprAtom=function(t){var e,n=this.potentialArrowAt==this.start;switch(this.type){case W._super:return this.inFunction||this.raise(this.start,"'super' outside of function or class"),e=this.startNode(),this.next(),this.type!==W.dot&&this.type!==W.bracketL&&this.type!==W.parenL&&this.unexpected(),this.finishNode(e,"Super");case W._this:return e=this.startNode(),this.next(),this.finishNode(e,"ThisExpression");case W.name:var r=this.start,i=this.startLoc,s=this.containsEsc,a=this.parseIdent(this.type!==W.name);if(this.options.ecmaVersion>=8&&!s&&"async"===a.name&&!this.canInsertSemicolon()&&this.eat(W._function))return this.parseFunction(this.startNodeAt(r,i),!1,!1,!0);if(n&&!this.canInsertSemicolon()){if(this.eat(W.arrow))return this.parseArrowExpression(this.startNodeAt(r,i),[a],!1);if(this.options.ecmaVersion>=8&&"async"===a.name&&this.type===W.name&&!s)return a=this.parseIdent(),!this.canInsertSemicolon()&&this.eat(W.arrow)||this.unexpected(),this.parseArrowExpression(this.startNodeAt(r,i),[a],!0)}return a;case W.regexp:var o=this.value;return e=this.parseLiteral(o.value),e.regex={pattern:o.pattern,flags:o.flags},e;case W.num:case W.string:return this.parseLiteral(this.value);case W._null:case W._true:case W._false:return e=this.startNode(),e.value=this.type===W._null?null:this.type===W._true,e.raw=this.type.keyword,this.next(),this.finishNode(e,"Literal");case W.parenL:var u=this.start,h=this.parseParenAndDistinguishExpression(n);return t&&(t.parenthesizedAssign<0&&!this.isSimpleAssignTarget(h)&&(t.parenthesizedAssign=u),t.parenthesizedBind<0&&(t.parenthesizedBind=u)),h;case W.bracketL:return e=this.startNode(),this.next(),e.elements=this.parseExprList(W.bracketR,!0,!0,t),this.finishNode(e,"ArrayExpression");case W.braceL:return this.parseObj(!1,t);case W._function:return e=this.startNode(),this.next(),this.parseFunction(e,!1);case W._class:return this.parseClass(this.startNode(),!1);case W._new:return this.parseNew();case W.backQuote:return this.parseTemplate();default:this.unexpected()}},ft.parseLiteral=function(t){var e=this.startNode();return e.value=t,e.raw=this.input.slice(this.start,this.end),this.next(),this.finishNode(e,"Literal")},ft.parseParenExpression=function(){this.expect(W.parenL);var t=this.parseExpression();return this.expect(W.parenR),t},ft.parseParenAndDistinguishExpression=function(t){var e,n=this,r=this.start,i=this.startLoc,s=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var a,o=this.start,u=this.startLoc,h=[],p=!0,l=!1,f=new c,d=this.yieldPos,g=this.awaitPos;for(this.yieldPos=0,this.awaitPos=0;this.type!==W.parenR;){if(p?p=!1:n.expect(W.comma),s&&n.afterTrailingComma(W.parenR,!0)){l=!0;break}if(n.type===W.ellipsis){a=n.start,h.push(n.parseParenItem(n.parseRestBinding())),n.type===W.comma&&n.raise(n.start,"Comma is not permitted after the rest element");break}h.push(n.parseMaybeAssign(!1,f,n.parseParenItem))}var m=this.start,y=this.startLoc;if(this.expect(W.parenR),t&&!this.canInsertSemicolon()&&this.eat(W.arrow))return this.checkPatternErrors(f,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=d,this.awaitPos=g,this.parseParenArrowList(r,i,h);h.length&&!l||this.unexpected(this.lastTokStart),a&&this.unexpected(a),this.checkExpressionErrors(f,!0),this.yieldPos=d||this.yieldPos,this.awaitPos=g||this.awaitPos,h.length>1?(e=this.startNodeAt(o,u),e.expressions=h,this.finishNodeAt(e,"SequenceExpression",m,y)):e=h[0]}else e=this.parseParenExpression();if(this.options.preserveParens){var x=this.startNodeAt(r,i);return x.expression=e,this.finishNode(x,"ParenthesizedExpression")}return e},ft.parseParenItem=function(t){return t},ft.parseParenArrowList=function(t,e,n){return this.parseArrowExpression(this.startNodeAt(t,e),n)};var dt=[];ft.parseNew=function(){var t=this.startNode(),e=this.parseIdent(!0);if(this.options.ecmaVersion>=6&&this.eat(W.dot)){t.meta=e;var n=this.containsEsc;return t.property=this.parseIdent(!0),("target"!==t.property.name||n)&&this.raiseRecoverable(t.property.start,"The only valid meta property for new is new.target"),this.inFunction||this.raiseRecoverable(t.start,"new.target can only be used in functions"),this.finishNode(t,"MetaProperty")}var r=this.start,i=this.startLoc;return t.callee=this.parseSubscripts(this.parseExprAtom(),r,i,!0),this.eat(W.parenL)?t.arguments=this.parseExprList(W.parenR,this.options.ecmaVersion>=8,!1):t.arguments=dt,this.finishNode(t,"NewExpression")},ft.parseTemplateElement=function(t){var e=t.isTagged,n=this.startNode();return this.type===W.invalidTemplate?(e||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),n.value={raw:this.value,cooked:null}):n.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,"\n"),cooked:this.value},this.next(),n.tail=this.type===W.backQuote,this.finishNode(n,"TemplateElement")},ft.parseTemplate=function(t){var e=this;void 0===t&&(t={});var n=t.isTagged;void 0===n&&(n=!1);var r=this.startNode();this.next(),r.expressions=[];var i=this.parseTemplateElement({isTagged:n});for(r.quasis=[i];!i.tail;)e.expect(W.dollarBraceL),r.expressions.push(e.parseExpression()),e.expect(W.braceR),r.quasis.push(i=e.parseTemplateElement({isTagged:n}));return this.next(),this.finishNode(r,"TemplateLiteral")},ft.isAsyncProp=function(t){return!t.computed&&"Identifier"===t.key.type&&"async"===t.key.name&&(this.type===W.name||this.type===W.num||this.type===W.string||this.type===W.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===W.star)&&!H.test(this.input.slice(this.lastTokEnd,this.start))},ft.parseObj=function(t,e){var n=this,r=this.startNode(),i=!0,s={};for(r.properties=[],this.next();!this.eat(W.braceR);){if(i)i=!1;else if(n.expect(W.comma),n.afterTrailingComma(W.braceR))break;var a=n.parseProperty(t,e);t||n.checkPropClash(a,s,e),r.properties.push(a)}return this.finishNode(r,t?"ObjectPattern":"ObjectExpression")},ft.parseProperty=function(t,e){var n,r,i,s,a=this.startNode();if(this.options.ecmaVersion>=9&&this.eat(W.ellipsis))return t?(a.argument=this.parseIdent(!1),this.type===W.comma&&this.raise(this.start,"Comma is not permitted after the rest element"),this.finishNode(a,"RestElement")):(this.type===W.parenL&&e&&(e.parenthesizedAssign<0&&(e.parenthesizedAssign=this.start),e.parenthesizedBind<0&&(e.parenthesizedBind=this.start)),a.argument=this.parseMaybeAssign(!1,e),this.type===W.comma&&e&&e.trailingComma<0&&(e.trailingComma=this.start),this.finishNode(a,"SpreadElement"));this.options.ecmaVersion>=6&&(a.method=!1,a.shorthand=!1,(t||e)&&(i=this.start,s=this.startLoc),t||(n=this.eat(W.star)));var o=this.containsEsc;return this.parsePropertyName(a),!t&&!o&&this.options.ecmaVersion>=8&&!n&&this.isAsyncProp(a)?(r=!0,n=this.options.ecmaVersion>=9&&this.eat(W.star),this.parsePropertyName(a,e)):r=!1,this.parsePropertyValue(a,t,n,r,i,s,e,o),this.finishNode(a,"Property")},ft.parsePropertyValue=function(t,e,n,r,i,s,a,o){if((n||r)&&this.type===W.colon&&this.unexpected(),this.eat(W.colon))t.value=e?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,a),t.kind="init";else if(this.options.ecmaVersion>=6&&this.type===W.parenL)e&&this.unexpected(),t.kind="init",t.method=!0,t.value=this.parseMethod(n,r);else if(e||o||!(this.options.ecmaVersion>=5)||t.computed||"Identifier"!==t.key.type||"get"!==t.key.name&&"set"!==t.key.name||this.type==W.comma||this.type==W.braceR)this.options.ecmaVersion>=6&&!t.computed&&"Identifier"===t.key.type?(this.checkUnreserved(t.key),t.kind="init",e?t.value=this.parseMaybeDefault(i,s,t.key):this.type===W.eq&&a?(a.shorthandAssign<0&&(a.shorthandAssign=this.start),t.value=this.parseMaybeDefault(i,s,t.key)):t.value=t.key,t.shorthand=!0):this.unexpected();else{(n||r)&&this.unexpected(),t.kind=t.key.name,this.parsePropertyName(t),t.value=this.parseMethod(!1);var u="get"===t.kind?0:1;if(t.value.params.length!==u){var h=t.value.start;"get"===t.kind?this.raiseRecoverable(h,"getter should have no params"):this.raiseRecoverable(h,"setter should have exactly one param")}else"set"===t.kind&&"RestElement"===t.value.params[0].type&&this.raiseRecoverable(t.value.params[0].start,"Setter cannot use rest params")}},ft.parsePropertyName=function(t){if(this.options.ecmaVersion>=6){if(this.eat(W.bracketL))return t.computed=!0,t.key=this.parseMaybeAssign(),this.expect(W.bracketR),t.key;t.computed=!1}return t.key=this.type===W.num||this.type===W.string?this.parseExprAtom():this.parseIdent(!0)},ft.initFunction=function(t){t.id=null,this.options.ecmaVersion>=6&&(t.generator=!1,t.expression=!1),this.options.ecmaVersion>=8&&(t.async=!1)},ft.parseMethod=function(t,e){var n=this.startNode(),r=this.inGenerator,i=this.inAsync,s=this.yieldPos,a=this.awaitPos,o=this.inFunction;return this.initFunction(n),this.options.ecmaVersion>=6&&(n.generator=t),this.options.ecmaVersion>=8&&(n.async=!!e),this.inGenerator=n.generator,this.inAsync=n.async,this.yieldPos=0,this.awaitPos=0,this.inFunction=!0,this.enterFunctionScope(),this.expect(W.parenL),n.params=this.parseBindingList(W.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(n,!1),this.inGenerator=r,this.inAsync=i,this.yieldPos=s,this.awaitPos=a,this.inFunction=o,this.finishNode(n,"FunctionExpression")},ft.parseArrowExpression=function(t,e,n){var r=this.inGenerator,i=this.inAsync,s=this.yieldPos,a=this.awaitPos,o=this.inFunction;return this.enterFunctionScope(),this.initFunction(t),this.options.ecmaVersion>=8&&(t.async=!!n),this.inGenerator=!1,this.inAsync=t.async,this.yieldPos=0,this.awaitPos=0,this.inFunction=!0,t.params=this.toAssignableList(e,!0),this.parseFunctionBody(t,!0),this.inGenerator=r,this.inAsync=i,this.yieldPos=s,this.awaitPos=a,this.inFunction=o,this.finishNode(t,"ArrowFunctionExpression")},ft.parseFunctionBody=function(t,e){var n=e&&this.type!==W.braceL,r=this.strict,i=!1;if(n)t.body=this.parseMaybeAssign(),t.expression=!0,this.checkParams(t,!1);else{var s=this.options.ecmaVersion>=7&&!this.isSimpleParamList(t.params);r&&!s||(i=this.strictDirective(this.end),i&&s&&this.raiseRecoverable(t.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var a=this.labels;this.labels=[],i&&(this.strict=!0),this.checkParams(t,!r&&!i&&!e&&this.isSimpleParamList(t.params)),t.body=this.parseBlock(!1),t.expression=!1,this.adaptDirectivePrologue(t.body.body),this.labels=a}this.exitFunctionScope(),this.strict&&t.id&&this.checkLVal(t.id,"none"),this.strict=r},ft.isSimpleParamList=function(t){for(var e=0,n=t;e0;)e[n]=arguments[n+1];for(var r=0,i=e;r=1;e--){var n=t.context[e];if("function"===n.token)return n.generator}return!1},Et.updateContext=function(t){var e,n=this.type;n.keyword&&t==W.dot?this.exprAllowed=!1:(e=n.updateContext)?e.call(this,t):this.exprAllowed=n.beforeExpr},W.parenR.updateContext=W.braceR.updateContext=function(){if(1==this.context.length)return void(this.exprAllowed=!0);var t=this.context.pop();t===_t.b_stat&&"function"===this.curContext().token&&(t=this.context.pop()),this.exprAllowed=!t.isExpr},W.braceL.updateContext=function(t){this.context.push(this.braceIsBlock(t)?_t.b_stat:_t.b_expr),this.exprAllowed=!0},W.dollarBraceL.updateContext=function(){this.context.push(_t.b_tmpl),this.exprAllowed=!0},W.parenL.updateContext=function(t){var e=t===W._if||t===W._for||t===W._with||t===W._while;this.context.push(e?_t.p_stat:_t.p_expr),this.exprAllowed=!0},W.incDec.updateContext=function(){},W._function.updateContext=W._class.updateContext=function(t){t.beforeExpr&&t!==W.semi&&t!==W._else&&(t!==W.colon&&t!==W.braceL||this.curContext()!==_t.b_stat)?this.context.push(_t.f_expr):this.context.push(_t.f_stat),this.exprAllowed=!1},W.backQuote.updateContext=function(){this.curContext()===_t.q_tmpl?this.context.pop():this.context.push(_t.q_tmpl),this.exprAllowed=!1},W.star.updateContext=function(t){if(t==W._function){var e=this.context.length-1;this.context[e]===_t.f_expr?this.context[e]=_t.f_expr_gen:this.context[e]=_t.f_gen}this.exprAllowed=!0},W.name.updateContext=function(t){var e=!1;this.options.ecmaVersion>=6&&("of"==this.value&&!this.exprAllowed||"yield"==this.value&&this.inGeneratorContext())&&(e=!0),this.exprAllowed=e};var Tt={$LONE:["ASCII","ASCII_Hex_Digit","AHex","Alphabetic","Alpha","Any","Assigned","Bidi_Control","Bidi_C","Bidi_Mirrored","Bidi_M","Case_Ignorable","CI","Cased","Changes_When_Casefolded","CWCF","Changes_When_Casemapped","CWCM","Changes_When_Lowercased","CWL","Changes_When_NFKC_Casefolded","CWKCF","Changes_When_Titlecased","CWT","Changes_When_Uppercased","CWU","Dash","Default_Ignorable_Code_Point","DI","Deprecated","Dep","Diacritic","Dia","Emoji","Emoji_Component","Emoji_Modifier","Emoji_Modifier_Base","Emoji_Presentation","Extender","Ext","Grapheme_Base","Gr_Base","Grapheme_Extend","Gr_Ext","Hex_Digit","Hex","IDS_Binary_Operator","IDSB","IDS_Trinary_Operator","IDST","ID_Continue","IDC","ID_Start","IDS","Ideographic","Ideo","Join_Control","Join_C","Logical_Order_Exception","LOE","Lowercase","Lower","Math","Noncharacter_Code_Point","NChar","Pattern_Syntax","Pat_Syn","Pattern_White_Space","Pat_WS","Quotation_Mark","QMark","Radical","Regional_Indicator","RI","Sentence_Terminal","STerm","Soft_Dotted","SD","Terminal_Punctuation","Term","Unified_Ideograph","UIdeo","Uppercase","Upper","Variation_Selector","VS","White_Space","space","XID_Continue","XIDC","XID_Start","XIDS"],General_Category:["Cased_Letter","LC","Close_Punctuation","Pe","Connector_Punctuation","Pc","Control","Cc","cntrl","Currency_Symbol","Sc","Dash_Punctuation","Pd","Decimal_Number","Nd","digit","Enclosing_Mark","Me","Final_Punctuation","Pf","Format","Cf","Initial_Punctuation","Pi","Letter","L","Letter_Number","Nl","Line_Separator","Zl","Lowercase_Letter","Ll","Mark","M","Combining_Mark","Math_Symbol","Sm","Modifier_Letter","Lm","Modifier_Symbol","Sk","Nonspacing_Mark","Mn","Number","N","Open_Punctuation","Ps","Other","C","Other_Letter","Lo","Other_Number","No","Other_Punctuation","Po","Other_Symbol","So","Paragraph_Separator","Zp","Private_Use","Co","Punctuation","P","punct","Separator","Z","Space_Separator","Zs","Spacing_Mark","Mc","Surrogate","Cs","Symbol","S","Titlecase_Letter","Lt","Unassigned","Cn","Uppercase_Letter","Lu"],Script:["Adlam","Adlm","Ahom","Anatolian_Hieroglyphs","Hluw","Arabic","Arab","Armenian","Armn","Avestan","Avst","Balinese","Bali","Bamum","Bamu","Bassa_Vah","Bass","Batak","Batk","Bengali","Beng","Bhaiksuki","Bhks","Bopomofo","Bopo","Brahmi","Brah","Braille","Brai","Buginese","Bugi","Buhid","Buhd","Canadian_Aboriginal","Cans","Carian","Cari","Caucasian_Albanian","Aghb","Chakma","Cakm","Cham","Cherokee","Cher","Common","Zyyy","Coptic","Copt","Qaac","Cuneiform","Xsux","Cypriot","Cprt","Cyrillic","Cyrl","Deseret","Dsrt","Devanagari","Deva","Duployan","Dupl","Egyptian_Hieroglyphs","Egyp","Elbasan","Elba","Ethiopic","Ethi","Georgian","Geor","Glagolitic","Glag","Gothic","Goth","Grantha","Gran","Greek","Grek","Gujarati","Gujr","Gurmukhi","Guru","Han","Hani","Hangul","Hang","Hanunoo","Hano","Hatran","Hatr","Hebrew","Hebr","Hiragana","Hira","Imperial_Aramaic","Armi","Inherited","Zinh","Qaai","Inscriptional_Pahlavi","Phli","Inscriptional_Parthian","Prti","Javanese","Java","Kaithi","Kthi","Kannada","Knda","Katakana","Kana","Kayah_Li","Kali","Kharoshthi","Khar","Khmer","Khmr","Khojki","Khoj","Khudawadi","Sind","Lao","Laoo","Latin","Latn","Lepcha","Lepc","Limbu","Limb","Linear_A","Lina","Linear_B","Linb","Lisu","Lycian","Lyci","Lydian","Lydi","Mahajani","Mahj","Malayalam","Mlym","Mandaic","Mand","Manichaean","Mani","Marchen","Marc","Masaram_Gondi","Gonm","Meetei_Mayek","Mtei","Mende_Kikakui","Mend","Meroitic_Cursive","Merc","Meroitic_Hieroglyphs","Mero","Miao","Plrd","Modi","Mongolian","Mong","Mro","Mroo","Multani","Mult","Myanmar","Mymr","Nabataean","Nbat","New_Tai_Lue","Talu","Newa","Nko","Nkoo","Nushu","Nshu","Ogham","Ogam","Ol_Chiki","Olck","Old_Hungarian","Hung","Old_Italic","Ital","Old_North_Arabian","Narb","Old_Permic","Perm","Old_Persian","Xpeo","Old_South_Arabian","Sarb","Old_Turkic","Orkh","Oriya","Orya","Osage","Osge","Osmanya","Osma","Pahawh_Hmong","Hmng","Palmyrene","Palm","Pau_Cin_Hau","Pauc","Phags_Pa","Phag","Phoenician","Phnx","Psalter_Pahlavi","Phlp","Rejang","Rjng","Runic","Runr","Samaritan","Samr","Saurashtra","Saur","Sharada","Shrd","Shavian","Shaw","Siddham","Sidd","SignWriting","Sgnw","Sinhala","Sinh","Sora_Sompeng","Sora","Soyombo","Soyo","Sundanese","Sund","Syloti_Nagri","Sylo","Syriac","Syrc","Tagalog","Tglg","Tagbanwa","Tagb","Tai_Le","Tale","Tai_Tham","Lana","Tai_Viet","Tavt","Takri","Takr","Tamil","Taml","Tangut","Tang","Telugu","Telu","Thaana","Thaa","Thai","Tibetan","Tibt","Tifinagh","Tfng","Tirhuta","Tirh","Ugaritic","Ugar","Vai","Vaii","Warang_Citi","Wara","Yi","Yiii","Zanabazar_Square","Zanb"]};Array.prototype.push.apply(Tt.$LONE,Tt.General_Category),Tt.gc=Tt.General_Category,Tt.sc=Tt.Script_Extensions=Tt.scx=Tt.Script;var St=st.prototype,kt=function(t){this.parser=t,this.validFlags="gim"+(t.options.ecmaVersion>=6?"uy":"")+(t.options.ecmaVersion>=9?"s":""),this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=[],this.backReferenceNames=[]};kt.prototype.reset=function(t,e,n){var r=n.indexOf("u")!==-1;this.start=0|t,this.source=e+"",this.flags=n,this.switchU=r&&this.parser.options.ecmaVersion>=6,this.switchN=r&&this.parser.options.ecmaVersion>=9},kt.prototype.raise=function(t){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+t)},kt.prototype.at=function(t){var e=this.source,n=e.length;if(t>=n)return-1;var r=e.charCodeAt(t);return!this.switchU||r<=55295||r>=57344||t+1>=n?r:(r<<10)+e.charCodeAt(t+1)-56613888; +},kt.prototype.nextIndex=function(t){var e=this.source,n=e.length;if(t>=n)return n;var r=e.charCodeAt(t);return!this.switchU||r<=55295||r>=57344||t+1>=n?t+1:t+2},kt.prototype.current=function(){return this.at(this.pos)},kt.prototype.lookahead=function(){return this.at(this.nextIndex(this.pos))},kt.prototype.advance=function(){this.pos=this.nextIndex(this.pos)},kt.prototype.eat=function(t){return this.current()===t&&(this.advance(),!0)},St.validateRegExpFlags=function(t){for(var e=this,n=t.validFlags,r=t.flags,i=0;i-1&&e.raise(t.start,"Duplicate regular expression flag")}},St.validateRegExpPattern=function(t){this.regexp_pattern(t),!t.switchN&&this.options.ecmaVersion>=9&&t.groupNames.length>0&&(t.switchN=!0,this.regexp_pattern(t))},St.regexp_pattern=function(t){t.pos=0,t.lastIntValue=0,t.lastStringValue="",t.lastAssertionIsQuantifiable=!1,t.numCapturingParens=0,t.maxBackReference=0,t.groupNames.length=0,t.backReferenceNames.length=0,this.regexp_disjunction(t),t.pos!==t.source.length&&(t.eat(41)&&t.raise("Unmatched ')'"),(t.eat(93)||t.eat(125))&&t.raise("Lone quantifier brackets")),t.maxBackReference>t.numCapturingParens&&t.raise("Invalid escape");for(var e=0,n=t.backReferenceNames;e=9&&(n=t.eat(60)),t.eat(61)||t.eat(33))return this.regexp_disjunction(t),t.eat(41)||t.raise("Unterminated group"),t.lastAssertionIsQuantifiable=!n,!0}return t.pos=e,!1},St.regexp_eatQuantifier=function(t,e){return void 0===e&&(e=!1),!!this.regexp_eatQuantifierPrefix(t,e)&&(t.eat(63),!0)},St.regexp_eatQuantifierPrefix=function(t,e){return t.eat(42)||t.eat(43)||t.eat(63)||this.regexp_eatBracedQuantifier(t,e)},St.regexp_eatBracedQuantifier=function(t,e){var n=t.pos;if(t.eat(123)){var r=0,i=-1;if(this.regexp_eatDecimalDigits(t)&&(r=t.lastIntValue,t.eat(44)&&this.regexp_eatDecimalDigits(t)&&(i=t.lastIntValue),t.eat(125)))return i!==-1&&i=9?this.regexp_groupSpecifier(t):63===t.current()&&t.raise("Invalid group"),this.regexp_disjunction(t),t.eat(41))return t.numCapturingParens+=1,!0;t.raise("Unterminated group")}return!1},St.regexp_eatExtendedAtom=function(t){return t.eat(46)||this.regexp_eatReverseSolidusAtomEscape(t)||this.regexp_eatCharacterClass(t)||this.regexp_eatUncapturingGroup(t)||this.regexp_eatCapturingGroup(t)||this.regexp_eatInvalidBracedQuantifier(t)||this.regexp_eatExtendedPatternCharacter(t)},St.regexp_eatInvalidBracedQuantifier=function(t){return this.regexp_eatBracedQuantifier(t,!0)&&t.raise("Nothing to repeat"),!1},St.regexp_eatSyntaxCharacter=function(t){var e=t.current();return!!g(e)&&(t.lastIntValue=e,t.advance(),!0)},St.regexp_eatPatternCharacters=function(t){for(var e=t.pos,n=0;(n=t.current())!==-1&&!g(n);)t.advance();return t.pos!==e},St.regexp_eatExtendedPatternCharacter=function(t){var e=t.current();return!(e===-1||36===e||e>=40&&e<=43||46===e||63===e||91===e||94===e||124===e)&&(t.advance(),!0)},St.regexp_groupSpecifier=function(t){if(t.eat(63)){if(this.regexp_eatGroupName(t))return t.groupNames.indexOf(t.lastStringValue)!==-1&&t.raise("Duplicate capture group name"),void t.groupNames.push(t.lastStringValue);t.raise("Invalid group")}},St.regexp_eatGroupName=function(t){if(t.lastStringValue="",t.eat(60)){if(this.regexp_eatRegExpIdentifierName(t)&&t.eat(62))return!0;t.raise("Invalid capture group name")}return!1},St.regexp_eatRegExpIdentifierName=function(t){if(t.lastStringValue="",this.regexp_eatRegExpIdentifierStart(t)){for(t.lastStringValue+=d(t.lastIntValue);this.regexp_eatRegExpIdentifierPart(t);)t.lastStringValue+=d(t.lastIntValue);return!0}return!1},St.regexp_eatRegExpIdentifierStart=function(t){var e=t.pos,n=t.current();return t.advance(),92===n&&this.regexp_eatRegExpUnicodeEscapeSequence(t)&&(n=t.lastIntValue),m(n)?(t.lastIntValue=n,!0):(t.pos=e,!1)},St.regexp_eatRegExpIdentifierPart=function(t){var e=t.pos,n=t.current();return t.advance(),92===n&&this.regexp_eatRegExpUnicodeEscapeSequence(t)&&(n=t.lastIntValue),y(n)?(t.lastIntValue=n,!0):(t.pos=e,!1)},St.regexp_eatAtomEscape=function(t){return!!(this.regexp_eatBackReference(t)||this.regexp_eatCharacterClassEscape(t)||this.regexp_eatCharacterEscape(t)||t.switchN&&this.regexp_eatKGroupName(t))||(t.switchU&&(99===t.current()&&t.raise("Invalid unicode escape"),t.raise("Invalid escape")),!1)},St.regexp_eatBackReference=function(t){var e=t.pos;if(this.regexp_eatDecimalEscape(t)){var n=t.lastIntValue;if(t.switchU)return n>t.maxBackReference&&(t.maxBackReference=n),!0;if(n<=t.numCapturingParens)return!0;t.pos=e}return!1},St.regexp_eatKGroupName=function(t){if(t.eat(107)){if(this.regexp_eatGroupName(t))return t.backReferenceNames.push(t.lastStringValue),!0;t.raise("Invalid named reference")}return!1},St.regexp_eatCharacterEscape=function(t){return this.regexp_eatControlEscape(t)||this.regexp_eatCControlLetter(t)||this.regexp_eatZero(t)||this.regexp_eatHexEscapeSequence(t)||this.regexp_eatRegExpUnicodeEscapeSequence(t)||!t.switchU&&this.regexp_eatLegacyOctalEscapeSequence(t)||this.regexp_eatIdentityEscape(t)},St.regexp_eatCControlLetter=function(t){var e=t.pos;if(t.eat(99)){if(this.regexp_eatControlLetter(t))return!0;t.pos=e}return!1},St.regexp_eatZero=function(t){return 48===t.current()&&!T(t.lookahead())&&(t.lastIntValue=0,t.advance(),!0)},St.regexp_eatControlEscape=function(t){var e=t.current();return 116===e?(t.lastIntValue=9,t.advance(),!0):110===e?(t.lastIntValue=10,t.advance(),!0):118===e?(t.lastIntValue=11,t.advance(),!0):102===e?(t.lastIntValue=12,t.advance(),!0):114===e&&(t.lastIntValue=13,t.advance(),!0)},St.regexp_eatControlLetter=function(t){var e=t.current();return!!x(e)&&(t.lastIntValue=e%32,t.advance(),!0)},St.regexp_eatRegExpUnicodeEscapeSequence=function(t){var e=t.pos;if(t.eat(117)){if(this.regexp_eatFixedHexDigits(t,4)){var n=t.lastIntValue;if(t.switchU&&n>=55296&&n<=56319){var r=t.pos;if(t.eat(92)&&t.eat(117)&&this.regexp_eatFixedHexDigits(t,4)){var i=t.lastIntValue;if(i>=56320&&i<=57343)return t.lastIntValue=1024*(n-55296)+(i-56320)+65536,!0}t.pos=r,t.lastIntValue=n}return!0}if(t.switchU&&t.eat(123)&&this.regexp_eatHexDigits(t)&&t.eat(125)&&v(t.lastIntValue))return!0;t.switchU&&t.raise("Invalid unicode escape"),t.pos=e}return!1},St.regexp_eatIdentityEscape=function(t){if(t.switchU)return!!this.regexp_eatSyntaxCharacter(t)||!!t.eat(47)&&(t.lastIntValue=47,!0);var e=t.current();return!(99===e||t.switchN&&107===e)&&(t.lastIntValue=e,t.advance(),!0)},St.regexp_eatDecimalEscape=function(t){t.lastIntValue=0;var e=t.current();if(e>=49&&e<=57){do t.lastIntValue=10*t.lastIntValue+(e-48),t.advance();while((e=t.current())>=48&&e<=57);return!0}return!1},St.regexp_eatCharacterClassEscape=function(t){var e=t.current();if(b(e))return t.lastIntValue=-1,t.advance(),!0;if(t.switchU&&this.options.ecmaVersion>=9&&(80===e||112===e)){if(t.lastIntValue=-1,t.advance(),t.eat(123)&&this.regexp_eatUnicodePropertyValueExpression(t)&&t.eat(125))return!0;t.raise("Invalid property name")}return!1},St.regexp_eatUnicodePropertyValueExpression=function(t){var e=t.pos;if(this.regexp_eatUnicodePropertyName(t)&&t.eat(61)){var n=t.lastStringValue;if(this.regexp_eatUnicodePropertyValue(t)){var r=t.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(t,n,r),!0}}if(t.pos=e,this.regexp_eatLoneUnicodePropertyNameOrValue(t)){var i=t.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(t,i),!0}return!1},St.regexp_validateUnicodePropertyNameAndValue=function(t,e,n){Tt.hasOwnProperty(e)&&Tt[e].indexOf(n)!==-1||t.raise("Invalid property name")},St.regexp_validateUnicodePropertyNameOrValue=function(t,e){Tt.$LONE.indexOf(e)===-1&&t.raise("Invalid property name")},St.regexp_eatUnicodePropertyName=function(t){var e=0;for(t.lastStringValue="";_(e=t.current());)t.lastStringValue+=d(e),t.advance();return""!==t.lastStringValue},St.regexp_eatUnicodePropertyValue=function(t){var e=0;for(t.lastStringValue="";E(e=t.current());)t.lastStringValue+=d(e),t.advance();return""!==t.lastStringValue},St.regexp_eatLoneUnicodePropertyNameOrValue=function(t){return this.regexp_eatUnicodePropertyValue(t)},St.regexp_eatCharacterClass=function(t){if(t.eat(91)){if(t.eat(94),this.regexp_classRanges(t),t.eat(93))return!0;t.raise("Unterminated character class")}return!1},St.regexp_classRanges=function(t){for(var e=this;this.regexp_eatClassAtom(t);){var n=t.lastIntValue;if(t.eat(45)&&e.regexp_eatClassAtom(t)){var r=t.lastIntValue;!t.switchU||n!==-1&&r!==-1||t.raise("Invalid character class"),n!==-1&&r!==-1&&n>r&&t.raise("Range out of order in character class")}}},St.regexp_eatClassAtom=function(t){var e=t.pos;if(t.eat(92)){if(this.regexp_eatClassEscape(t))return!0;if(t.switchU){var n=t.current();(99===n||w(n))&&t.raise("Invalid class escape"),t.raise("Invalid escape")}t.pos=e}var r=t.current();return 93!==r&&(t.lastIntValue=r,t.advance(),!0)},St.regexp_eatClassEscape=function(t){var e=t.pos;if(t.eat(98))return t.lastIntValue=8,!0;if(t.switchU&&t.eat(45))return t.lastIntValue=45,!0;if(!t.switchU&&t.eat(99)){if(this.regexp_eatClassControlLetter(t))return!0;t.pos=e}return this.regexp_eatCharacterClassEscape(t)||this.regexp_eatCharacterEscape(t)},St.regexp_eatClassControlLetter=function(t){var e=t.current();return!(!T(e)&&95!==e)&&(t.lastIntValue=e%32,t.advance(),!0)},St.regexp_eatHexEscapeSequence=function(t){var e=t.pos;if(t.eat(120)){if(this.regexp_eatFixedHexDigits(t,2))return!0;t.switchU&&t.raise("Invalid escape"),t.pos=e}return!1},St.regexp_eatDecimalDigits=function(t){var e=t.pos,n=0;for(t.lastIntValue=0;T(n=t.current());)t.lastIntValue=10*t.lastIntValue+(n-48),t.advance();return t.pos!==e},St.regexp_eatHexDigits=function(t){var e=t.pos,n=0;for(t.lastIntValue=0;S(n=t.current());)t.lastIntValue=16*t.lastIntValue+k(n),t.advance();return t.pos!==e},St.regexp_eatLegacyOctalEscapeSequence=function(t){if(this.regexp_eatOctalDigit(t)){var e=t.lastIntValue;if(this.regexp_eatOctalDigit(t)){var n=t.lastIntValue;e<=3&&this.regexp_eatOctalDigit(t)?t.lastIntValue=64*e+8*n+t.lastIntValue:t.lastIntValue=8*e+n}else t.lastIntValue=e;return!0}return!1},St.regexp_eatOctalDigit=function(t){var e=t.current();return w(e)?(t.lastIntValue=e-48,t.advance(),!0):(t.lastIntValue=0,!1)},St.regexp_eatFixedHexDigits=function(t,e){var n=t.pos;t.lastIntValue=0;for(var r=0;r=this.input.length?this.finishToken(W.eof):t.override?t.override(this):void this.readToken(this.fullCharCodeAtPos())},At.readToken=function(t){return n(t,this.options.ecmaVersion>=6)||92===t?this.readWord():this.getTokenFromCode(t)},At.fullCharCodeAtPos=function(){var t=this.input.charCodeAt(this.pos);if(t<=55295||t>=57344)return t;var e=this.input.charCodeAt(this.pos+1);return(t<<10)+e-56613888},At.skipBlockComment=function(){var t=this,e=this.options.onComment&&this.curPosition(),n=this.pos,r=this.input.indexOf("*/",this.pos+=2);if(r===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=r+2,this.options.locations){q.lastIndex=n;for(var i;(i=q.exec(this.input))&&i.index8&&e<14||e>=5760&&Y.test(String.fromCharCode(e))))break t;++t.pos}}},At.finishToken=function(t,e){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=t,this.value=e,this.updateContext(n)},At.readToken_dot=function(){var t=this.input.charCodeAt(this.pos+1);if(t>=48&&t<=57)return this.readNumber(!0);var e=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&46===t&&46===e?(this.pos+=3,this.finishToken(W.ellipsis)):(++this.pos,this.finishToken(W.dot))},At.readToken_slash=function(){var t=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):61===t?this.finishOp(W.assign,2):this.finishOp(W.slash,1)},At.readToken_mult_modulo_exp=function(t){var e=this.input.charCodeAt(this.pos+1),n=1,r=42===t?W.star:W.modulo;return this.options.ecmaVersion>=7&&42==t&&42===e&&(++n,r=W.starstar,e=this.input.charCodeAt(this.pos+2)),61===e?this.finishOp(W.assign,n+1):this.finishOp(r,n)},At.readToken_pipe_amp=function(t){var e=this.input.charCodeAt(this.pos+1);return e===t?this.finishOp(124===t?W.logicalOR:W.logicalAND,2):61===e?this.finishOp(W.assign,2):this.finishOp(124===t?W.bitwiseOR:W.bitwiseAND,1)},At.readToken_caret=function(){var t=this.input.charCodeAt(this.pos+1);return 61===t?this.finishOp(W.assign,2):this.finishOp(W.bitwiseXOR,1)},At.readToken_plus_min=function(t){var e=this.input.charCodeAt(this.pos+1);return e===t?45!=e||this.inModule||62!=this.input.charCodeAt(this.pos+2)||0!==this.lastTokEnd&&!H.test(this.input.slice(this.lastTokEnd,this.pos))?this.finishOp(W.incDec,2):(this.skipLineComment(3),this.skipSpace(),this.nextToken()):61===e?this.finishOp(W.assign,2):this.finishOp(W.plusMin,1)},At.readToken_lt_gt=function(t){var e=this.input.charCodeAt(this.pos+1),n=1;return e===t?(n=62===t&&62===this.input.charCodeAt(this.pos+2)?3:2,61===this.input.charCodeAt(this.pos+n)?this.finishOp(W.assign,n+1):this.finishOp(W.bitShift,n)):33!=e||60!=t||this.inModule||45!=this.input.charCodeAt(this.pos+2)||45!=this.input.charCodeAt(this.pos+3)?(61===e&&(n=2),this.finishOp(W.relational,n)):(this.skipLineComment(4),this.skipSpace(),this.nextToken())},At.readToken_eq_excl=function(t){var e=this.input.charCodeAt(this.pos+1);return 61===e?this.finishOp(W.equality,61===this.input.charCodeAt(this.pos+2)?3:2):61===t&&62===e&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(W.arrow)):this.finishOp(61===t?W.eq:W.prefix,1)},At.getTokenFromCode=function(t){switch(t){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(W.parenL);case 41:return++this.pos,this.finishToken(W.parenR);case 59:return++this.pos,this.finishToken(W.semi);case 44:return++this.pos,this.finishToken(W.comma);case 91:return++this.pos,this.finishToken(W.bracketL);case 93:return++this.pos,this.finishToken(W.bracketR);case 123:return++this.pos,this.finishToken(W.braceL);case 125:return++this.pos,this.finishToken(W.braceR);case 58:return++this.pos,this.finishToken(W.colon);case 63:return++this.pos,this.finishToken(W.question);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(W.backQuote);case 48:var e=this.input.charCodeAt(this.pos+1);if(120===e||88===e)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(111===e||79===e)return this.readRadixNumber(8);if(98===e||66===e)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(t);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(t);case 124:case 38:return this.readToken_pipe_amp(t);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(t);case 60:case 62:return this.readToken_lt_gt(t);case 61:case 33:return this.readToken_eq_excl(t);case 126:return this.finishOp(W.prefix,1)}this.raise(this.pos,"Unexpected character '"+A(t)+"'")},At.finishOp=function(t,e){var n=this.input.slice(this.pos,this.pos+e);return this.pos+=e,this.finishToken(t,n)},At.readRegexp=function(){for(var t,e,n=this,r=this.pos;;){n.pos>=n.input.length&&n.raise(r,"Unterminated regular expression");var i=n.input.charAt(n.pos);if(H.test(i)&&n.raise(r,"Unterminated regular expression"),t)t=!1;else{if("["===i)e=!0;else if("]"===i&&e)e=!1;else if("/"===i&&!e)break;t="\\"===i}++n.pos}var s=this.input.slice(r,this.pos);++this.pos;var a=this.pos,o=this.readWord1();this.containsEsc&&this.unexpected(a);var u=this.regexpState||(this.regexpState=new kt(this));u.reset(r,s,o),this.validateRegExpFlags(u),this.validateRegExpPattern(u);var h=null;try{h=new RegExp(s,o)}catch(p){}return this.finishToken(W.regexp,{pattern:s,flags:o,value:h})},At.readInt=function(t,e){for(var n=this,r=this.pos,i=0,s=0,a=null==e?1/0:e;s=97?o-97+10:o>=65?o-65+10:o>=48&&o<=57?o-48:1/0,u>=t)break;++n.pos,i=i*t+u}return this.pos===r||null!=e&&this.pos-r!==e?null:i},At.readRadixNumber=function(t){this.pos+=2;var e=this.readInt(t);return null==e&&this.raise(this.start+2,"Expected number in radix "+t),n(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(W.num,e)},At.readNumber=function(t){var e=this.pos;t||null!==this.readInt(10)||this.raise(e,"Invalid number");var r=this.pos-e>=2&&48===this.input.charCodeAt(e);r&&this.strict&&this.raise(e,"Invalid number"),r&&/[89]/.test(this.input.slice(e,this.pos))&&(r=!1);var i=this.input.charCodeAt(this.pos);46!==i||r||(++this.pos,this.readInt(10),i=this.input.charCodeAt(this.pos)),69!==i&&101!==i||r||(i=this.input.charCodeAt(++this.pos),43!==i&&45!==i||++this.pos,null===this.readInt(10)&&this.raise(e,"Invalid number")),n(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var s=this.input.slice(e,this.pos),a=r?parseInt(s,8):parseFloat(s);return this.finishToken(W.num,a)},At.readCodePoint=function(){var t,e=this.input.charCodeAt(this.pos);if(123===e){this.options.ecmaVersion<6&&this.unexpected();var n=++this.pos;t=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(n,"Code point out of bounds")}else t=this.readHexChar(4);return t},At.readString=function(t){for(var e=this,n="",r=++this.pos;;){e.pos>=e.input.length&&e.raise(e.start,"Unterminated string constant");var i=e.input.charCodeAt(e.pos);if(i===t)break;92===i?(n+=e.input.slice(r,e.pos),n+=e.readEscapedChar(!1),r=e.pos):(a(i)&&e.raise(e.start,"Unterminated string constant"),++e.pos)}return n+=this.input.slice(r,this.pos++),this.finishToken(W.string,n)};var Ot={};At.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(t){if(t!==Ot)throw t;this.readInvalidTemplateToken()}this.inTemplateElement=!1},At.invalidStringToken=function(t,e){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Ot;this.raise(t,e)},At.readTmplToken=function(){for(var t=this,e="",n=this.pos;;){t.pos>=t.input.length&&t.raise(t.start,"Unterminated template");var r=t.input.charCodeAt(t.pos);if(96===r||36===r&&123===t.input.charCodeAt(t.pos+1))return t.pos!==t.start||t.type!==W.template&&t.type!==W.invalidTemplate?(e+=t.input.slice(n,t.pos),t.finishToken(W.template,e)):36===r?(t.pos+=2,t.finishToken(W.dollarBraceL)):(++t.pos,t.finishToken(W.backQuote));if(92===r)e+=t.input.slice(n,t.pos),e+=t.readEscapedChar(!0),n=t.pos;else if(a(r)){switch(e+=t.input.slice(n,t.pos),++t.pos,r){case 13:10===t.input.charCodeAt(t.pos)&&++t.pos;case 10:e+="\n";break;default:e+=String.fromCharCode(r)}t.options.locations&&(++t.curLine,t.lineStart=t.pos),n=t.pos}else++t.pos}},At.readInvalidTemplateToken=function(){for(var t=this;this.pos=48&&e<=55){var n=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],r=parseInt(n,8);return r>255&&(n=n.slice(0,-1),r=parseInt(n,8)),this.pos+=n.length-1,e=this.input.charCodeAt(this.pos),"0"===n&&56!=e&&57!=e||!this.strict&&!t||this.invalidStringToken(this.pos-1-n.length,"Octal literal in strict mode"),String.fromCharCode(r)}return String.fromCharCode(e)}},At.readHexChar=function(t){var e=this.pos,n=this.readInt(16,t);return null===n&&this.invalidStringToken(e,"Bad character escape sequence"),n},At.readWord1=function(){var t=this;this.containsEsc=!1;for(var e="",i=!0,s=this.pos,a=this.options.ecmaVersion>=6;this.pos {\n ' + kernelRunShortcut.toString() + ';\n const utils = {\n allPropertiesOf: ' + removeNoise(utils.allPropertiesOf.toString()) + ',\n clone: ' + removeNoise(utils.clone.toString()) + '\n };\n const Utils = utils;\n class ' + (name || 'Kernel') + ' {\n constructor() { \n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = ' + JSON.stringify(cpuKernel.paramNames) + ';\n this.paramTypes = ' + JSON.stringify(cpuKernel.paramTypes) + ';\n this.texSize = ' + JSON.stringify(cpuKernel.texSize) + ';\n this.output = ' + JSON.stringify(cpuKernel.output) + ';\n this._kernelString = `' + cpuKernel._kernelString + '`;\n this.output = ' + JSON.stringify(cpuKernel.output) + ';\n\t\t this.run = function() {\n this.run = null;\n this.build();\n return this.run.apply(this, arguments);\n }.bind(this);\n this.thread = {\n x: 0,\n y: 0,\n z: 0\n };\n }\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n ' + removeFnNoise(cpuKernel.build.toString()) + '\n ' + removeFnNoise(cpuKernel.setupParams.toString()) + '\n run () { ' + cpuKernel.kernelString + ' }\n getKernelString() { return this._kernelString; }\n ' + removeFnNoise(cpuKernel.validateOptions.toString()) + '\n };\n return kernelRunShortcut(new Kernel());\n };'; + return '() => {\n ' + kernelRunShortcut.toString() + ';\n const utils = {\n allPropertiesOf: ' + removeNoise(utils.allPropertiesOf.toString()) + ',\n clone: ' + removeNoise(utils.clone.toString()) + ',\n checkOutput: ' + removeNoise(utils.checkOutput.toString()) + '\n };\n const Utils = utils;\n class ' + (name || 'Kernel') + ' {\n constructor() { \n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = ' + JSON.stringify(cpuKernel.paramNames) + ';\n this.paramTypes = ' + JSON.stringify(cpuKernel.paramTypes) + ';\n this.texSize = ' + JSON.stringify(cpuKernel.texSize) + ';\n this.output = ' + JSON.stringify(cpuKernel.output) + ';\n this._kernelString = `' + cpuKernel._kernelString + '`;\n this.output = ' + JSON.stringify(cpuKernel.output) + ';\n\t\t this.run = function() {\n this.run = null;\n this.build();\n return this.run.apply(this, arguments);\n }.bind(this);\n this.thread = {\n x: 0,\n y: 0,\n z: 0\n };\n }\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n ' + removeFnNoise(cpuKernel.build.toString()) + '\n ' + removeFnNoise(cpuKernel.setupParams.toString()) + '\n run () { ' + cpuKernel.kernelString + ' }\n getKernelString() { return this._kernelString; }\n ' + removeFnNoise(cpuKernel.validateOptions.toString()) + '\n };\n return kernelRunShortcut(new Kernel());\n };'; }; \ No newline at end of file diff --git a/dist/backend/cpu/kernel.js b/dist/backend/cpu/kernel.js index 546caebe..6520819c 100644 --- a/dist/backend/cpu/kernel.js +++ b/dist/backend/cpu/kernel.js @@ -84,6 +84,8 @@ module.exports = function (_KernelBase) { throw 'Auto dimensions not supported for input type: ' + argType; } } + + utils.checkOutput(this.output); } /** diff --git a/dist/backend/web-gl/kernel-string.js b/dist/backend/web-gl/kernel-string.js index d6b16c06..6414d62d 100644 --- a/dist/backend/web-gl/kernel-string.js +++ b/dist/backend/web-gl/kernel-string.js @@ -15,5 +15,5 @@ function removeNoise(str) { } module.exports = function (gpuKernel, name) { - return '() => {\n ' + kernelRunShortcut.toString() + ';\n const utils = {\n allPropertiesOf: ' + removeNoise(utils.allPropertiesOf.toString()) + ',\n clone: ' + removeNoise(utils.clone.toString()) + ',\n splitArray: ' + removeNoise(utils.splitArray.toString()) + ',\n getArgumentType: ' + removeNoise(utils.getArgumentType.toString()) + ',\n getDimensions: ' + removeNoise(utils.getDimensions.toString()) + ',\n dimToTexSize: ' + removeNoise(utils.dimToTexSize.toString()) + ',\n flattenTo: ' + removeNoise(utils.flattenTo.toString()) + ',\n flatten2dArrayTo: ' + removeNoise(utils.flatten2dArrayTo.toString()) + ',\n flatten3dArrayTo: ' + removeNoise(utils.flatten3dArrayTo.toString()) + ',\n systemEndianness: \'' + removeNoise(utils.systemEndianness()) + '\',\n initWebGl: ' + removeNoise(utils.initWebGl.toString()) + ',\n isArray: ' + removeNoise(utils.isArray.toString()) + '\n };\n const Utils = utils;\n const canvases = [];\n const maxTexSizes = {};\n class ' + (name || 'Kernel') + ' {\n constructor() {\n this.maxTexSize = null;\n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = ' + JSON.stringify(gpuKernel.paramNames) + ';\n this.paramTypes = ' + JSON.stringify(gpuKernel.paramTypes) + ';\n this.texSize = ' + JSON.stringify(gpuKernel.texSize) + ';\n this.output = ' + JSON.stringify(gpuKernel.output) + ';\n this.compiledFragShaderString = `' + gpuKernel.compiledFragShaderString + '`;\n\t\t this.compiledVertShaderString = `' + gpuKernel.compiledVertShaderString + '`;\n\t\t this.programUniformLocationCache = {};\n\t\t this.textureCache = {};\n\t\t this.subKernelOutputTextures = null;\n\t\t this.subKernelOutputVariableNames = null;\n\t\t this.uniform1fCache = {};\n\t\t this.uniform1iCache = {};\n\t\t this.uniform2fCache = {};\n\t\t this.uniform2fvCache = {};\n\t\t this.uniform3fvCache = {};\n }\n ' + removeFnNoise(gpuKernel._getFragShaderString.toString()) + '\n ' + removeFnNoise(gpuKernel._getVertShaderString.toString()) + '\n validateOptions() {}\n setupParams() {}\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n ' + removeFnNoise(gpuKernel.getUniformLocation.toString()) + '\n ' + removeFnNoise(gpuKernel.setupParams.toString()) + '\n ' + removeFnNoise(gpuKernel.build.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.run.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel._addArgument.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getArgumentTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getTextureCache.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getOutputTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.renderOutput.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.updateMaxTexSize.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel._setupOutputTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.detachTextureCache.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform1f.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform1i.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform2f.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform2fv.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform3fv.toString()) + ' \n };\n return kernelRunShortcut(new Kernel());\n };'; + return '() => {\n ' + kernelRunShortcut.toString() + ';\n const utils = {\n allPropertiesOf: ' + removeNoise(utils.allPropertiesOf.toString()) + ',\n clone: ' + removeNoise(utils.clone.toString()) + ',\n splitArray: ' + removeNoise(utils.splitArray.toString()) + ',\n getArgumentType: ' + removeNoise(utils.getArgumentType.toString()) + ',\n getDimensions: ' + removeNoise(utils.getDimensions.toString()) + ',\n dimToTexSize: ' + removeNoise(utils.dimToTexSize.toString()) + ',\n flattenTo: ' + removeNoise(utils.flattenTo.toString()) + ',\n flatten2dArrayTo: ' + removeNoise(utils.flatten2dArrayTo.toString()) + ',\n flatten3dArrayTo: ' + removeNoise(utils.flatten3dArrayTo.toString()) + ',\n systemEndianness: \'' + removeNoise(utils.systemEndianness()) + '\',\n initWebGl: ' + removeNoise(utils.initWebGl.toString()) + ',\n isArray: ' + removeNoise(utils.isArray.toString()) + ',\n checkOutput: ' + removeNoise(utils.checkOutput.toString()) + '\n };\n const Utils = utils;\n const canvases = [];\n const maxTexSizes = {};\n class ' + (name || 'Kernel') + ' {\n constructor() {\n this.maxTexSize = null;\n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = ' + JSON.stringify(gpuKernel.paramNames) + ';\n this.paramTypes = ' + JSON.stringify(gpuKernel.paramTypes) + ';\n this.texSize = ' + JSON.stringify(gpuKernel.texSize) + ';\n this.output = ' + JSON.stringify(gpuKernel.output) + ';\n this.compiledFragShaderString = `' + gpuKernel.compiledFragShaderString + '`;\n\t\t this.compiledVertShaderString = `' + gpuKernel.compiledVertShaderString + '`;\n\t\t this.programUniformLocationCache = {};\n\t\t this.textureCache = {};\n\t\t this.subKernelOutputTextures = null;\n\t\t this.subKernelOutputVariableNames = null;\n\t\t this.uniform1fCache = {};\n\t\t this.uniform1iCache = {};\n\t\t this.uniform2fCache = {};\n\t\t this.uniform2fvCache = {};\n\t\t this.uniform3fvCache = {};\n }\n ' + removeFnNoise(gpuKernel._getFragShaderString.toString()) + '\n ' + removeFnNoise(gpuKernel._getVertShaderString.toString()) + '\n validateOptions() {}\n setupParams() {}\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n ' + removeFnNoise(gpuKernel.getUniformLocation.toString()) + '\n ' + removeFnNoise(gpuKernel.setupParams.toString()) + '\n ' + removeFnNoise(gpuKernel.build.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.run.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel._addArgument.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getArgumentTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getTextureCache.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getOutputTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.renderOutput.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.updateMaxTexSize.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel._setupOutputTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.detachTextureCache.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform1f.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform1i.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform2f.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform2fv.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform3fv.toString()) + ' \n };\n return kernelRunShortcut(new Kernel());\n };'; }; \ No newline at end of file diff --git a/dist/backend/web-gl/kernel.js b/dist/backend/web-gl/kernel.js index 89b3c162..12140b24 100644 --- a/dist/backend/web-gl/kernel.js +++ b/dist/backend/web-gl/kernel.js @@ -117,6 +117,8 @@ module.exports = function (_KernelBase) { this.floatOutput = isFloatReadPixel; } + utils.checkOutput(this.output); + if (!this.output || this.output.length === 0) { if (arguments.length !== 1) { throw new Error('Auto output only supported for kernels with only one input'); diff --git a/dist/backend/web-gl2/kernel-string.js b/dist/backend/web-gl2/kernel-string.js index d6b16c06..6414d62d 100644 --- a/dist/backend/web-gl2/kernel-string.js +++ b/dist/backend/web-gl2/kernel-string.js @@ -15,5 +15,5 @@ function removeNoise(str) { } module.exports = function (gpuKernel, name) { - return '() => {\n ' + kernelRunShortcut.toString() + ';\n const utils = {\n allPropertiesOf: ' + removeNoise(utils.allPropertiesOf.toString()) + ',\n clone: ' + removeNoise(utils.clone.toString()) + ',\n splitArray: ' + removeNoise(utils.splitArray.toString()) + ',\n getArgumentType: ' + removeNoise(utils.getArgumentType.toString()) + ',\n getDimensions: ' + removeNoise(utils.getDimensions.toString()) + ',\n dimToTexSize: ' + removeNoise(utils.dimToTexSize.toString()) + ',\n flattenTo: ' + removeNoise(utils.flattenTo.toString()) + ',\n flatten2dArrayTo: ' + removeNoise(utils.flatten2dArrayTo.toString()) + ',\n flatten3dArrayTo: ' + removeNoise(utils.flatten3dArrayTo.toString()) + ',\n systemEndianness: \'' + removeNoise(utils.systemEndianness()) + '\',\n initWebGl: ' + removeNoise(utils.initWebGl.toString()) + ',\n isArray: ' + removeNoise(utils.isArray.toString()) + '\n };\n const Utils = utils;\n const canvases = [];\n const maxTexSizes = {};\n class ' + (name || 'Kernel') + ' {\n constructor() {\n this.maxTexSize = null;\n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = ' + JSON.stringify(gpuKernel.paramNames) + ';\n this.paramTypes = ' + JSON.stringify(gpuKernel.paramTypes) + ';\n this.texSize = ' + JSON.stringify(gpuKernel.texSize) + ';\n this.output = ' + JSON.stringify(gpuKernel.output) + ';\n this.compiledFragShaderString = `' + gpuKernel.compiledFragShaderString + '`;\n\t\t this.compiledVertShaderString = `' + gpuKernel.compiledVertShaderString + '`;\n\t\t this.programUniformLocationCache = {};\n\t\t this.textureCache = {};\n\t\t this.subKernelOutputTextures = null;\n\t\t this.subKernelOutputVariableNames = null;\n\t\t this.uniform1fCache = {};\n\t\t this.uniform1iCache = {};\n\t\t this.uniform2fCache = {};\n\t\t this.uniform2fvCache = {};\n\t\t this.uniform3fvCache = {};\n }\n ' + removeFnNoise(gpuKernel._getFragShaderString.toString()) + '\n ' + removeFnNoise(gpuKernel._getVertShaderString.toString()) + '\n validateOptions() {}\n setupParams() {}\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n ' + removeFnNoise(gpuKernel.getUniformLocation.toString()) + '\n ' + removeFnNoise(gpuKernel.setupParams.toString()) + '\n ' + removeFnNoise(gpuKernel.build.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.run.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel._addArgument.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getArgumentTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getTextureCache.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getOutputTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.renderOutput.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.updateMaxTexSize.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel._setupOutputTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.detachTextureCache.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform1f.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform1i.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform2f.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform2fv.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform3fv.toString()) + ' \n };\n return kernelRunShortcut(new Kernel());\n };'; + return '() => {\n ' + kernelRunShortcut.toString() + ';\n const utils = {\n allPropertiesOf: ' + removeNoise(utils.allPropertiesOf.toString()) + ',\n clone: ' + removeNoise(utils.clone.toString()) + ',\n splitArray: ' + removeNoise(utils.splitArray.toString()) + ',\n getArgumentType: ' + removeNoise(utils.getArgumentType.toString()) + ',\n getDimensions: ' + removeNoise(utils.getDimensions.toString()) + ',\n dimToTexSize: ' + removeNoise(utils.dimToTexSize.toString()) + ',\n flattenTo: ' + removeNoise(utils.flattenTo.toString()) + ',\n flatten2dArrayTo: ' + removeNoise(utils.flatten2dArrayTo.toString()) + ',\n flatten3dArrayTo: ' + removeNoise(utils.flatten3dArrayTo.toString()) + ',\n systemEndianness: \'' + removeNoise(utils.systemEndianness()) + '\',\n initWebGl: ' + removeNoise(utils.initWebGl.toString()) + ',\n isArray: ' + removeNoise(utils.isArray.toString()) + ',\n checkOutput: ' + removeNoise(utils.checkOutput.toString()) + '\n };\n const Utils = utils;\n const canvases = [];\n const maxTexSizes = {};\n class ' + (name || 'Kernel') + ' {\n constructor() {\n this.maxTexSize = null;\n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = ' + JSON.stringify(gpuKernel.paramNames) + ';\n this.paramTypes = ' + JSON.stringify(gpuKernel.paramTypes) + ';\n this.texSize = ' + JSON.stringify(gpuKernel.texSize) + ';\n this.output = ' + JSON.stringify(gpuKernel.output) + ';\n this.compiledFragShaderString = `' + gpuKernel.compiledFragShaderString + '`;\n\t\t this.compiledVertShaderString = `' + gpuKernel.compiledVertShaderString + '`;\n\t\t this.programUniformLocationCache = {};\n\t\t this.textureCache = {};\n\t\t this.subKernelOutputTextures = null;\n\t\t this.subKernelOutputVariableNames = null;\n\t\t this.uniform1fCache = {};\n\t\t this.uniform1iCache = {};\n\t\t this.uniform2fCache = {};\n\t\t this.uniform2fvCache = {};\n\t\t this.uniform3fvCache = {};\n }\n ' + removeFnNoise(gpuKernel._getFragShaderString.toString()) + '\n ' + removeFnNoise(gpuKernel._getVertShaderString.toString()) + '\n validateOptions() {}\n setupParams() {}\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n ' + removeFnNoise(gpuKernel.getUniformLocation.toString()) + '\n ' + removeFnNoise(gpuKernel.setupParams.toString()) + '\n ' + removeFnNoise(gpuKernel.build.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.run.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel._addArgument.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getArgumentTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getTextureCache.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getOutputTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.renderOutput.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.updateMaxTexSize.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel._setupOutputTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.detachTextureCache.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform1f.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform1i.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform2f.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform2fv.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform3fv.toString()) + ' \n };\n return kernelRunShortcut(new Kernel());\n };'; }; \ No newline at end of file diff --git a/dist/backend/web-gl2/kernel.js b/dist/backend/web-gl2/kernel.js index 05bc94d5..8de989cb 100644 --- a/dist/backend/web-gl2/kernel.js +++ b/dist/backend/web-gl2/kernel.js @@ -50,6 +50,8 @@ module.exports = function (_WebGLKernel) { this.floatOutput = isFloatReadPixel; } + utils.checkOutput(this.output); + if (!this.output || this.output.length === 0) { if (arguments.length !== 1) { throw new Error('Auto output only supported for kernels with only one input'); diff --git a/dist/core/utils-core.js b/dist/core/utils-core.js index c3273f4e..1041d856 100644 --- a/dist/core/utils-core.js +++ b/dist/core/utils-core.js @@ -253,6 +253,24 @@ var UtilsCore = function () { // Create a new canvas DOM return canvasObj.getContext('webgl2', UtilsCore.initWebGlDefaultOptions()); } + + /** + * @function + * @static + * @memberOf UtilsCore + * @param {number[]} output + * @throws if not correctly defined + */ + + }, { + key: 'checkOutput', + value: function checkOutput(output) { + for (var i = 0; i < output.length; i++) { + if (isNaN(output[i]) || output[i] < 1) { + throw new Error('kernel.output[' + i + '] incorrectly defined as `' + output[i] + '`, needs to be numeric, and greater than 0'); + } + } + } }]); return UtilsCore; diff --git a/package.json b/package.json index f0f65b40..7b422f16 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gpu.js", - "version": "1.4.10", + "version": "1.4.11", "description": "GPU Accelerated JavaScript", "main": "./dist/index.js", "directories": { diff --git a/src/backend/cpu/kernel-string.js b/src/backend/cpu/kernel-string.js index 5fddeb11..26b9e8c1 100644 --- a/src/backend/cpu/kernel-string.js +++ b/src/backend/cpu/kernel-string.js @@ -19,7 +19,8 @@ module.exports = function(cpuKernel, name) { ${ kernelRunShortcut.toString() }; const utils = { allPropertiesOf: ${ removeNoise(utils.allPropertiesOf.toString()) }, - clone: ${ removeNoise(utils.clone.toString()) } + clone: ${ removeNoise(utils.clone.toString()) }, + checkOutput: ${ removeNoise(utils.checkOutput.toString()) } }; const Utils = utils; class ${ name || 'Kernel' } { diff --git a/src/backend/cpu/kernel.js b/src/backend/cpu/kernel.js index 50a675df..90300611 100644 --- a/src/backend/cpu/kernel.js +++ b/src/backend/cpu/kernel.js @@ -67,6 +67,8 @@ module.exports = class CPUKernel extends KernelBase { throw 'Auto dimensions not supported for input type: ' + argType; } } + + utils.checkOutput(this.output); } /** diff --git a/src/backend/web-gl/kernel-string.js b/src/backend/web-gl/kernel-string.js index 172d13c9..4b5af884 100644 --- a/src/backend/web-gl/kernel-string.js +++ b/src/backend/web-gl/kernel-string.js @@ -29,7 +29,8 @@ module.exports = function(gpuKernel, name) { flatten3dArrayTo: ${ removeNoise(utils.flatten3dArrayTo.toString()) }, systemEndianness: '${ removeNoise(utils.systemEndianness()) }', initWebGl: ${ removeNoise(utils.initWebGl.toString()) }, - isArray: ${ removeNoise(utils.isArray.toString()) } + isArray: ${ removeNoise(utils.isArray.toString()) }, + checkOutput: ${ removeNoise(utils.checkOutput.toString()) } }; const Utils = utils; const canvases = []; diff --git a/src/backend/web-gl/kernel.js b/src/backend/web-gl/kernel.js index 64d7d58c..0ee5ec6d 100644 --- a/src/backend/web-gl/kernel.js +++ b/src/backend/web-gl/kernel.js @@ -91,6 +91,8 @@ module.exports = class WebGLKernel extends KernelBase { this.floatOutput = isFloatReadPixel; } + utils.checkOutput(this.output); + if (!this.output || this.output.length === 0) { if (arguments.length !== 1) { throw new Error('Auto output only supported for kernels with only one input'); diff --git a/src/backend/web-gl2/kernel-string.js b/src/backend/web-gl2/kernel-string.js index 172d13c9..4b5af884 100644 --- a/src/backend/web-gl2/kernel-string.js +++ b/src/backend/web-gl2/kernel-string.js @@ -29,7 +29,8 @@ module.exports = function(gpuKernel, name) { flatten3dArrayTo: ${ removeNoise(utils.flatten3dArrayTo.toString()) }, systemEndianness: '${ removeNoise(utils.systemEndianness()) }', initWebGl: ${ removeNoise(utils.initWebGl.toString()) }, - isArray: ${ removeNoise(utils.isArray.toString()) } + isArray: ${ removeNoise(utils.isArray.toString()) }, + checkOutput: ${ removeNoise(utils.checkOutput.toString()) } }; const Utils = utils; const canvases = []; diff --git a/src/backend/web-gl2/kernel.js b/src/backend/web-gl2/kernel.js index ebadc24b..e8af0a09 100644 --- a/src/backend/web-gl2/kernel.js +++ b/src/backend/web-gl2/kernel.js @@ -35,6 +35,8 @@ module.exports = class WebGL2Kernel extends WebGLKernel { this.floatOutput = isFloatReadPixel; } + utils.checkOutput(this.output); + if (!this.output || this.output.length === 0) { if (arguments.length !== 1) { throw new Error('Auto output only supported for kernels with only one input'); diff --git a/src/core/utils-core.js b/src/core/utils-core.js index 4e669275..a2cc06a0 100644 --- a/src/core/utils-core.js +++ b/src/core/utils-core.js @@ -228,6 +228,21 @@ class UtilsCore { // Create a new canvas DOM return canvasObj.getContext('webgl2', UtilsCore.initWebGlDefaultOptions()); } + + /** + * @function + * @static + * @memberOf UtilsCore + * @param {number[]} output + * @throws if not correctly defined + */ + static checkOutput(output) { + for (let i = 0; i < output.length; i++) { + if (isNaN(output[i]) || output[i] < 1) { + throw new Error(`kernel.output[${ i }] incorrectly defined as \`${ output[i] }\`, needs to be numeric, and greater than 0`); + } + } + } } //----------------------------------------------------------------------------- diff --git a/src/core/utils.js b/src/core/utils.js index 1682191c..d4b54d20 100644 --- a/src/core/utils.js +++ b/src/core/utils.js @@ -46,6 +46,10 @@ let _isMixedIdentifiersSupported = (() => { } })(); +/** + * @class + * @extends UtilsCore + */ class Utils extends UtilsCore { //----------------------------------------------------------------------------- diff --git a/test/all.html b/test/all.html index ec0ab143..7b65bd66 100644 --- a/test/all.html +++ b/test/all.html @@ -65,5 +65,6 @@ + diff --git a/test/issues/335-missing-z-index-issue.js b/test/issues/335-missing-z-index-issue.js new file mode 100644 index 00000000..bf2ac8b1 --- /dev/null +++ b/test/issues/335-missing-z-index-issue.js @@ -0,0 +1,42 @@ +(function() { + function missingZIndexIssue(mode) { + var gpu = new GPU({ mode: mode }); + + var kernel = gpu.createKernel(function(value) { + return value[this.thread.z][this.thread.y][this.thread.x]; + }) + .setOutput([1, 1, undefined]); + + kernel([[[1]]]); + } + + QUnit.test('Issue #335 Missing z index issue (auto)', () => { + QUnit.assert.throws(function() { + missingZIndexIssue('auto'); + }); + }); + + QUnit.test('Issue #335 Missing z index issue (gpu)', () => { + QUnit.assert.throws(function() { + missingZIndexIssue('gpu'); + }); + }); + + QUnit.test('Issue #335 Missing z index issue (webgl)', () => { + QUnit.assert.throws(function() { + missingZIndexIssue('webgl'); + }); + }); + + QUnit.test('Issue #335 Missing z index issue (webgl2)', () => { + QUnit.assert.throws(function() { + missingZIndexIssue('webgl2'); + }); + }); + + QUnit.test('Issue #335 Missing z index issue (cpu)', () => { + QUnit.assert.throws(function() { + missingZIndexIssue('cpu'); + }); + }); +})(); \ No newline at end of file