Skip to content

Instantly share code, notes, and snippets.

@rveciana
Last active Apr 14, 2021
Embed
What would you like to do?
Basic gpu.js canvas example
licence: mit
/**
* gpu.js
* http://gpu.rocks/
*
* GPU Accelerated JavaScript
*
* @version 1.0.0-rc.10
* @date Fri Dec 15 2017 20:55:34 GMT+0300 (MSK)
*
* @license MIT
* The MIT License
*
* Copyright (c) 2017 gpu.js Team
*/
"use strict";!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 l=n[a]={exports:{}};e[a][0].call(l.exports,function(t){var n=e[a][1][t];return i(n?n:t)},l,l.exports,t,e,n,r)}return n[a].exports}for(var s="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}({1:[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;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),o=t("../function-builder-base"),u=t("./function-node");e.exports=function(t){function e(){r(this,e);var t=i(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return t.Node=u,t}return s(e,t),a(e,[{key:"polyfillStandardFunctions",value:function(){}}]),e}(o)},{"../function-builder-base":6,"./function-node":2}],2:[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;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),o=t("../function-node-base"),u=t("../../core/utils");e.exports=function(t){function e(){return r(this,e),i(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return s(e,t),a(e,[{key:"generate",value:function(){return this.debug&&console.log(this),this.functionStringArray=this.astGeneric(this.getJsAST(),[],this),this.functionString=this.functionStringArray.join("").trim(),this.functionString}},{key:"getFunctionPrototypeString",value:function(){return this.webGlFunctionPrototypeString?this.webGlFunctionPrototypeString:this.webGlFunctionPrototypeString=this.generate()}},{key:"astGeneric",value:function(t,e,n){if(null===t)throw this.astErrorOutput("NULL ast",t,n);if(Array.isArray(t)){for(var r=0;r<t.length;r++)this.astGeneric(t[r],e,n);return e}switch(t.type){case"FunctionDeclaration":return this.astFunctionDeclaration(t,e,n);case"FunctionExpression":return this.astFunctionExpression(t,e,n);case"ReturnStatement":return this.astReturnStatement(t,e,n);case"Literal":return this.astLiteral(t,e,n);case"BinaryExpression":return this.astBinaryExpression(t,e,n);case"Identifier":return this.astIdentifierExpression(t,e,n);case"AssignmentExpression":return this.astAssignmentExpression(t,e,n);case"ExpressionStatement":return this.astExpressionStatement(t,e,n);case"EmptyStatement":return this.astEmptyStatement(t,e,n);case"BlockStatement":return this.astBlockStatement(t,e,n);case"IfStatement":return this.astIfStatement(t,e,n);case"BreakStatement":return this.astBreakStatement(t,e,n);case"ContinueStatement":return this.astContinueStatement(t,e,n);case"ForStatement":return this.astForStatement(t,e,n);case"WhileStatement":return this.astWhileStatement(t,e,n);case"VariableDeclaration":return this.astVariableDeclaration(t,e,n);case"VariableDeclarator":return this.astVariableDeclarator(t,e,n);case"ThisExpression":return this.astThisExpression(t,e,n);case"SequenceExpression":return this.astSequenceExpression(t,e,n);case"UnaryExpression":return this.astUnaryExpression(t,e,n);case"UpdateExpression":return this.astUpdateExpression(t,e,n);case"LogicalExpression":return this.astLogicalExpression(t,e,n);case"MemberExpression":return this.astMemberExpression(t,e,n);case"CallExpression":return this.astCallExpression(t,e,n);case"ArrayExpression":return this.astArrayExpression(t,e,n);case"DebuggerStatement":return this.astDebuggerStatement(t,e,n)}throw this.astErrorOutput("Unknown ast type : "+t.type,t,n)}},{key:"astFunctionDeclaration",value:function(t,e,n){return this.addFunction&&this.addFunction(null,u.getAstString(this.jsFunctionString,t)),e}},{key:"astFunctionExpression",value:function(t,e,n){if(!n.isRootKernel){e.push("function"),n.kernalAst=t,e.push(" "),e.push(n.functionName),e.push("(");for(var r=0;r<n.paramNames.length;++r){var i=n.paramNames[r];r>0&&e.push(", "),e.push(" "),e.push("user_"),e.push(i)}e.push(") {\n")}for(var s=0;s<t.body.body.length;++s)this.astGeneric(t.body.body[s],e,n),e.push("\n");return n.isRootKernel||e.push("}\n"),e}},{key:"astReturnStatement",value:function(t,e,n){return n.isRootKernel?(e.push("kernelResult = "),this.astGeneric(t.argument,e,n),e.push(";")):n.isSubKernel?(e.push(n.functionName+"Result = "),this.astGeneric(t.argument,e,n),e.push(";"),e.push("return "+n.functionName+"Result;")):(e.push("return "),this.astGeneric(t.argument,e,n),e.push(";")),e}},{key:"astLiteral",value:function(t,e,n){if(isNaN(t.value))throw this.astErrorOutput("Non-numeric literal not supported : "+t.value,t,n);return e.push(t.value),e}},{key:"astBinaryExpression",value:function(t,e,n){return e.push("("),this.astGeneric(t.left,e,n),e.push(t.operator),this.astGeneric(t.right,e,n),e.push(")"),e}},{key:"astIdentifierExpression",value:function(t,e,n){if("Identifier"!==t.type)throw this.astErrorOutput("IdentifierExpression - not an Identifier",t,n);switch(t.name){case"gpu_threadX":e.push("threadId.x");break;case"gpu_threadY":e.push("threadId.y");break;case"gpu_threadZ":e.push("threadId.z");break;case"gpu_outputX":e.push("uOutputDim.x");break;case"gpu_outputY":e.push("uOutputDim.y");break;case"gpu_outputZ":e.push("uOutputDim.z");break;default:if(this.constants&&this.constants.hasOwnProperty(t.name))e.push("constants_"+t.name);else{var r=n.getUserParamName(t.name);null!==r?e.push("user_"+r):e.push("user_"+t.name)}}return e}},{key:"astForStatement",value:function(t,e,n){if("ForStatement"!==t.type)throw this.astErrorOutput("Invalid for statment",t,n);if(t.test&&"BinaryExpression"===t.test.type){if(("Identifier"===t.test.right.type||"Literal"===t.test.right.type)&&"<"===t.test.operator&&this.isIdentifierConstant(t.test.right.name)===!1){if(this.loopMaxIterations||(console.warn("Warning: loopMaxIterations is not set! Using default of 1000 which may result in unintended behavior."),console.warn("Set loopMaxIterations or use a for loop of fixed length to silence this message.")),e.push("for ("),this.astGeneric(t.init,e,n),";"!==e[e.length-1]&&e.push(";"),this.astGeneric(t.test.left,e,n),e.push(t.test.operator),e.push("LOOP_MAX"),e.push(";"),this.astGeneric(t.update,e,n),e.push(")"),e.push("{\n"),e.push("if ("),this.astGeneric(t.test.left,e,n),e.push(t.test.operator),this.astGeneric(t.test.right,e,n),e.push(") {\n"),"BlockStatement"===t.body.type)for(var r=0;r<t.body.body.length;r++)this.astGeneric(t.body.body[r],e,n);else this.astGeneric(t.body,e,n);return e.push("} else {\n"),e.push("break;\n"),e.push("}\n"),e.push("}\n"),e}if(t.init.declarations){var i=JSON.parse(JSON.stringify(t.init.declarations)),s=t.update.argument;if(!Array.isArray(i)||i.length<1)throw console.log(this.jsFunctionString),new Error("Error: Incompatible for loop declaration");if(i.length>1){for(var a=null,o=0;o<i.length;o++){var u=i[o];u.id.name===s.name?(a=u,i.splice(o,1)):(e.push("var "),this.astGeneric(u,e,n),e.push(";"))}e.push("for (let "),this.astGeneric(a,e,n),e.push(";")}else e.push("for ("),this.astGeneric(t.init,e,n);return this.astGeneric(t.test,e,n),e.push(";"),this.astGeneric(t.update,e,n),e.push(")"),this.astGeneric(t.body,e,n),e}}throw this.astErrorOutput("Invalid for statement",t,n)}},{key:"astWhileStatement",value:function(t,e,n){if("WhileStatement"!==t.type)throw this.astErrorOutput("Invalid while statment",t,n);return e.push("for (let i = 0; i < LOOP_MAX; i++) {"),e.push("if ("),this.astGeneric(t.test,e,n),e.push(") {\n"),this.astGeneric(t.body,e,n),e.push("} else {\n"),e.push("break;\n"),e.push("}\n"),e.push("}\n"),e}},{key:"astAssignmentExpression",value:function(t,e,n){return this.astGeneric(t.left,e,n),e.push(t.operator),this.astGeneric(t.right,e,n),e}},{key:"astEmptyStatement",value:function(t,e,n){return e}},{key:"astBlockStatement",value:function(t,e,n){e.push("{\n");for(var r=0;r<t.body.length;r++)this.astGeneric(t.body[r],e,n);return e.push("}\n"),e}},{key:"astExpressionStatement",value:function(t,e,n){return this.astGeneric(t.expression,e,n),e.push(";\n"),e}},{key:"astVariableDeclaration",value:function(t,e,n){e.push("var ");for(var r=0;r<t.declarations.length;r++)r>0&&e.push(","),this.astGeneric(t.declarations[r],e,n);return e.push(";"),e}},{key:"astVariableDeclarator",value:function(t,e,n){return this.astGeneric(t.id,e,n),null!==t.init&&(e.push("="),this.astGeneric(t.init,e,n)),e}},{key:"astIfStatement",value:function(t,e,n){return e.push("if ("),this.astGeneric(t.test,e,n),e.push(")"),"BlockStatement"===t.consequent.type?this.astGeneric(t.consequent,e,n):(e.push(" {\n"),this.astGeneric(t.consequent,e,n),e.push("\n}\n")),t.alternate&&(e.push("else "),"BlockStatement"===t.alternate.type?this.astGeneric(t.alternate,e,n):(e.push(" {\n"),this.astGeneric(t.alternate,e,n),e.push("\n}\n"))),e}},{key:"astBreakStatement",value:function(t,e,n){return e.push("break;\n"),e}},{key:"astContinueStatement",value:function(t,e,n){return e.push("continue;\n"),e}},{key:"astLogicalExpression",value:function(t,e,n){return e.push("("),this.astGeneric(t.left,e,n),e.push(t.operator),this.astGeneric(t.right,e,n),e.push(")"),e}},{key:"astUpdateExpression",value:function(t,e,n){return t.prefix?(e.push(t.operator),this.astGeneric(t.argument,e,n)):(this.astGeneric(t.argument,e,n),e.push(t.operator)),e}},{key:"astUnaryExpression",value:function(t,e,n){return t.prefix?(e.push(t.operator),this.astGeneric(t.argument,e,n)):(this.astGeneric(t.argument,e,n),e.push(t.operator)),e}},{key:"astThisExpression",value:function(t,e,n){return e.push("_this"),e}},{key:"astMemberExpression",value:function(t,e,n){if(t.computed)if("Identifier"===t.object.type)this.astGeneric(t.object,e,n),e.push("["),this.astGeneric(t.property,e,n),e.push("]");else{this.astGeneric(t.object,e,n);var r=e.pop();e.push("]["),this.astGeneric(t.property,e,n),e.push(r)}else{var i=this.astMemberExpressionUnroll(t);switch("Identifier"===t.property.type&&t.computed&&(i="user_"+i),0===i.indexOf("this")&&(i="_"+i),i){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(i)}}return e}},{key:"astSequenceExpression",value:function(t,e,n){for(var r=0;r<t.expressions.length;r++)r>0&&e.push(","),this.astGeneric(t.expressions,e,n);return e}},{key:"astCallExpression",value:function(t,e,n){if(t.callee){var r=this.astMemberExpressionUnroll(t.callee);n.calledFunctions.indexOf(r)<0&&n.calledFunctions.push(r),n.hasOwnProperty("funcName")||(n.calledFunctionsArguments[r]=[]);var i=[];n.calledFunctionsArguments[r].push(i),e.push(r),e.push("(");for(var s=0;s<t.arguments.length;++s){var a=t.arguments[s];if(s>0&&e.push(", "),this.astGeneric(a,e,n),"Identifier"===a.type){var o=n.paramNames.indexOf(a.name);o===-1?i.push(null):i.push({name:a.name,type:n.paramTypes[o]})}else i.push(null)}return e.push(")"),e}throw this.astErrorOutput("Unknown CallExpression",t,n)}},{key:"astArrayExpression",value:function(t,e,n){var r=t.elements.length;e.push("new Float32Array(");for(var i=0;i<r;++i){i>0&&e.push(", ");var s=t.elements[i];this.astGeneric(s,e,n)}return e.push(")"),e}},{key:"astDebuggerStatement",value:function(t,e,n){return e.push("debugger;"),e}}],[{key:"astFunctionPrototype",value:function(t,e,n){if(n.isRootKernel||n.isSubKernel)return e;e.push(n.returnType),e.push(" "),e.push(n.functionName),e.push("(");for(var r=0;r<n.paramNames.length;++r)r>0&&e.push(", "),e.push(n.paramTypes[r]),e.push(" "),e.push("user_"),e.push(n.paramNames[r]);return e.push(");\n"),e}}]),e}(o)},{"../../core/utils":25,"../function-node-base":7}],3:[function(t,e,n){var r=t("../../core/utils"),i=t("../kernel-run-shortcut");e.exports=function(t,e){return"() => {\n "+i.toString()+";\n const utils = {\n allPropertiesOf: function "+r.allPropertiesOf.toString()+",\n clone: function "+r.clone.toString()+",\n /*splitArray: function "+r.splitArray.toString()+",\n getArgumentType: function "+r.getArgumentType.toString()+",\n getOutput: function "+r.getOutput.toString()+",\n dimToTexSize: function "+r.dimToTexSize.toString()+",\n copyFlatten: function "+r.copyFlatten.toString()+",\n flatten: function "+r.flatten.toString()+",\n systemEndianness: '"+r.systemEndianness()+"',\n initWebGl: function "+r.initWebGl.toString()+",\n isArray: function "+r.isArray.toString()+"*/\n };\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 "+t.build.toString()+"\n run () { "+t.kernelString+" }\n getKernelString() { return this._kernelString; }\n };\n return kernelRunShortcut(new Kernel());\n };"}},{"../../core/utils":25,"../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;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),o=t("../kernel-base"),u=t("../../core/utils"),h=t("./kernel-string");e.exports=function(t){function e(t,n){r(this,e);var s=i(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));return s._fnBody=u.getFunctionBodyFromString(t),s._fn=null,s.run=null,s._canvasCtx=null,s._imageData=null,s._colorData=null,s._kernelString=null,s.thread={x:0,y:0,z:0},s.run=function(){return this.run=null,this.build.apply(this,arguments),this.run.apply(this,arguments)}.bind(s),s}return s(e,t),a(e,[{key:"validateOptions",value:function(){if(!this.output||0===this.output.length){if(1!==arguments.length)throw"Auto dimensions only supported for kernels with only one input";var t=u.getArgumentType(arguments[0]);if("Array"===t)this.output=u.getDimensions(t);else{if("Texture"!==t)throw"Auto dimensions not supported for input type: "+t;this.output=arguments[0].output}}}},{key:"build",value:function(){this.setupParams(arguments);for(var t=this.threadDim=u.clone(this.output);t.length<3;)t.push(1);if(this.graphical){var e=this.getCanvas();e.width=t[0],e.height=t[1],this._canvasCtx=e.getContext("2d"),this._imageData=this._canvasCtx.createImageData(t[0],t[1]),this._colorData=new Uint8ClampedArray(t[0]*t[1]*4)}var n=this.getKernelString();this.debug&&(console.log("Options:"),console.dir(this),console.log("Function output:"),console.log(n)),this.kernelString=n,this.run=new Function([],n).bind(this)()}},{key:"color",value:function(t,e,n,r){"undefined"==typeof r&&(r=1),t=Math.floor(255*t),e=Math.floor(255*e),n=Math.floor(255*n),r=Math.floor(255*r);var i=this.output[0],s=this.output[1],a=this.thread.x,o=s-this.thread.y-1,u=a+o*i;this._colorData[4*u+0]=t,this._colorData[4*u+1]=e,this._colorData[4*u+2]=n,this._colorData[4*u+3]=r}},{key:"getKernelString",value:function(){var t=this;if(null!==this._kernelString)return this._kernelString;for(var e=this.functionBuilder,n=this.threadDim||(this.threadDim=u.clone(this.output));n.length<3;)n.push(1);if(e.addKernel(this.fnString,{prototypeOnly:!1,constants:this.constants,output:this.output,debug:this.debug,loopMaxIterations:this.loopMaxIterations},this.paramNames,this.paramTypes),e.addFunctions(this.functions,{constants:this.constants,output:this.output}),null!==this.subKernels){this.subKernelOutputTextures=[],this.subKernelOutputVariableNames=[];for(var r=0;r<this.subKernels.length;r++){var i=this.subKernels[r];e.addSubKernel(i,{prototypeOnly:!1,constants:this.constants,output:this.output,debug:this.debug,loopMaxIterations:this.loopMaxIterations}),this.subKernelOutputVariableNames.push(i.name+"Result")}}else if(null!==this.subKernelProperties){this.subKernelOutputVariableNames=[];var s=0;for(var a in this.subKernelProperties)if(this.subKernelProperties.hasOwnProperty(a)){var o=this.subKernelProperties[a];e.addSubKernel(o),this.subKernelOutputVariableNames.push(o.name+"Result"),s++}}var h=e.getPrototypes(),l=h.shift(),p=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 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 "+l+"\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 p}},{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:"compileKernel",value:function(t){for(var e=t.threadDim;e.length<3;)e.push(1)}}]),e}(o)},{"../../core/utils":25,"../kernel-base":8,"./kernel-string":3}],5:[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;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),o=(t("../../core/utils"),t("../runner-base")),u=t("./kernel"),h=t("./function-builder");e.exports=function(t){function e(t){r(this,e);var n=i(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,new h,t));return n.Kernel=u,n.kernel=null,n}return s(e,t),a(e,[{key:"getMode",value:function(){return"cpu"}}]),e}(o)},{"../../core/utils":25,"../runner-base":10,"./function-builder":1,"./kernel":4}],6:[function(t,e,n){function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var i=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}();e.exports=function(){function t(e){r(this,t),this.nodeMap={},this.nativeFunctions={},this.gpu=e,this.rootKernel=null,this.Node=null}return i(t,[{key:"addNativeFunction",value:function(t,e){this.nativeFunctions[t]=e}},{key:"addFunction",value:function(t,e,n,r,i){this.addFunctionNode(new this.Node(t,e,n,r,i).setAddFunction(this.addFunction.bind(this)))}},{key:"addFunctions",value:function(t,e){if(t)if(Array.isArray(t))for(var n=0;n<t.length;n++)this.addFunction(null,t[n],e);else for(var r in t)this.addFunction(r,t[r],e)}},{key:"addNativeFunctions",value:function(t){for(var e in t)t.hasOwnProperty(e)&&this.addNativeFunction(e,t[e])}},{key:"addFunctionNode",value:function(t){this.nodeMap[t.functionName]=t,t.isRootKernel&&(this.rootKernel=t)}},{key:"traceFunctionCalls",value:function(t,e,n){t=t||"kernel",e=e||[];var r=this.nodeMap[t];if(r){var i=e.indexOf(t);if(i===-1){e.push(t),n&&(r.parent=n),r.getFunctionString();for(var s=0;s<r.calledFunctions.length;++s)this.traceFunctionCalls(r.calledFunctions[s],e,r)}else{var a=e.splice(i,1)[0];e.push(a)}}return this.nativeFunctions[t]&&(e.indexOf(t)>=0||e.push(t)),e}},{key:"addKernel",value:function(t,e,n,r){var i=new this.Node("kernel",t,e,r);return i.setAddFunction(this.addFunction.bind(this)),i.paramNames=n,i.paramTypes=r,i.isRootKernel=!0,this.addFunctionNode(i),i}},{key:"addSubKernel",value:function(t,e,n,r){var i=new this.Node(null,t,e,n,r);return i.setAddFunction(this.addFunction.bind(this)),i.isSubKernel=!0,this.addFunctionNode(i),i}},{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<t.length;++n){var r=this.nodeMap[t[n]];r&&e.push(this.nodeMap[t[n]].getFunctionString())}return e.join("\n")}},{key:"getPrototypesFromFunctionNames",value:function(t,e){for(var n=[],r=0;r<t.length;++r){var i=t[r],s=this.nodeMap[i];s?n.push(s.getFunctionPrototypeString(e)):this.nativeFunctions[i]&&n.push(this.nativeFunctions[i])}return n}},{key:"getPrototypeStringFromFunctionNames",value:function(t,e){return this.getPrototypesFromFunctionNames(t,e).toString()}},{key:"getString",value:function(t,e){return void 0===e&&(e={}),t?this.getStringFromFunctionNames(this.traceFunctionCalls(t,[],e).reverse(),e):this.getStringFromFunctionNames(Object.keys(this.nodeMap),e)}},{key:"polyfillStandardFunctions",value:function(){throw new Error("polyfillStandardFunctions not defined on base function builder")}}]),t}()},{}],7:[function(require,module,exports){function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_createClass=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),utils=require("../core/utils"),acorn=require("acorn");module.exports=function(){function BaseFunctionNode(t,e,n,r,i){if(_classCallCheck(this,BaseFunctionNode),this.calledFunctions=[],this.calledFunctionsArguments={},this.initVariables=[],this.readVariables=[],this.writeVariables=[],this.addFunction=null,this.isRootKernel=!1,this.isSubKernel=!1,this.parent=null,this.debug=null,this.prototypeOnly=null,this.constants=null,this.output=null,n&&(n.hasOwnProperty("debug")&&(this.debug=n.debug),n.hasOwnProperty("prototypeOnly")&&(this.prototypeOnly=n.prototypeOnly),n.hasOwnProperty("constants")&&(this.constants=n.constants),n.hasOwnProperty("output")&&(this.output=n.output),n.hasOwnProperty("loopMaxIterations")&&(this.loopMaxIterations=n.loopMaxIterations)),!e)throw"jsFunction, parameter is missing";if(this.jsFunctionString=e.toString(),!utils.isFunctionString(this.jsFunctionString))throw console.error("jsFunction, to string conversion check failed: not a function?",this.jsFunctionString),"jsFunction, to string conversion check failed: not a function?";if(utils.isFunction(e)?this.jsFunction=e:this.jsFunction=null,this.functionName=t||e&&e.name||utils.getFunctionNameFromString(this.jsFunctionString),!this.functionName)throw"jsFunction, missing name argument or value";if(this.paramNames=utils.getParamNamesFromString(this.jsFunctionString),r){if(Array.isArray(r)){if(r.length!==this.paramNames.length)throw"Invalid argument type array length, against function length -> ("+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:"setAddFunction",value:function(t){return this.addFunction=t,this}},{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,e){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,e):this.astMemberExpressionUnroll(t.object,e)+"."+this.astMemberExpressionUnroll(t.property,e);if(t.hasOwnProperty("expressions")){var n=t.expressions[0];if("Literal"===n.type&&0===n.value&&2===t.expressions.length)return this.astMemberExpressionUnroll(t.expressions[1])}throw this.astErrorOutput("Unknown CallExpression_unroll",t,e)}},{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 null;if(!this.parent)return null;if(this.paramTypes[e])return this.paramTypes[e];for(var n=this.parent.calledFunctionsArguments[this.functionName],r=0;r<n.length;r++){var i=n[r];if(null!==i[e])return this.paramTypes[e]=i[e].type}return null}},{key:"getUserParamName",value:function(t){var e=this.paramNames.indexOf(t);if(e===-1)return null;if(!this.parent)return null;for(var n=this.parent.calledFunctionsArguments[this.functionName],r=0;r<n.length;r++){var i=n[r];if(null!==i[e])return i[e].name}return null}},{key:"generate",value:function(t){throw new Error("generate not defined on BaseFunctionNode")}},{key:"astErrorOutput",value:function(t,e,n){return console.error(utils.getAstString(this.jsFunctionString,e)),console.error(t,e,n),t}},{key:"astDebuggerStatement",value:function(t,e,n){return e}}]),BaseFunctionNode}()},{"../core/utils":25,acorn:27}],8:[function(t,e,n){function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var i=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),s=t("../core/utils");e.exports=function(){function t(e,n){r(this,t),this.paramNames=s.getParamNamesFromString(e),this.fnString=e,this.output=null,this.debug=!1,this.graphical=!1,this.loopMaxIterations=0,this.constants=null,this.wraparound=null,this.hardcodeConstants=null,this.outputToTexture=null,this.texSize=null,this._canvas=null,this._webGl=null,this.threadDim=null,this.floatTextures=null,this.floatOutput=null,this.floatOutputForce=null,this.addFunction=null,
this.functions=null,this.nativeFunctions=null,this.copyData=!0,this.subKernels=null,this.subKernelProperties=null,this.subKernelNames=null,this.subKernelOutputVariableNames=null,this.functionBuilder=null,this.paramTypes=null;for(var i in n)n.hasOwnProperty(i)&&this.hasOwnProperty(i)&&(this[i]=n[i]);n.hasOwnProperty("canvas")&&(this._canvas=n.canvas),n.hasOwnProperty("output")&&this.setOutput(n.output),this._canvas||(this._canvas=s.initCanvas())}return i(t,[{key:"build",value:function(){throw new Error('"build" not defined on Base')}},{key:"setupParams",value:function(t){for(var e=this.paramTypes=[],n=0;n<t.length;n++){var r=t[n],i=s.getArgumentType(r);e.push(i)}}},{key:"setAddFunction",value:function(t){return this.addFunction=t,this}},{key:"setFunctions",value:function(t){return this.functions=t,this}},{key:"setOutput",value:function(t){return t.hasOwnProperty("x")?t.hasOwnProperty("y")?t.hasOwnProperty("z")?this.output=[t.x,t.y,t.z]:this.output=[t.x,t.y]:this.output=[t.x]:this.output=t,this}},{key:"setDebug",value:function(t){return this.debug=t,this}},{key:"setGraphical",value:function(t){return this.graphical=t,this}},{key:"setLoopMaxIterations",value:function(t){return this.loopMaxIterations=t,this}},{key:"setConstants",value:function(t){return this.constants=t,this}},{key:"setWraparound",value:function(t){return console.warn("Wraparound mode is not supported and undocumented."),this.wraparound=t,this}},{key:"setHardcodeConstants",value:function(t){return this.hardcodeConstants=t,this}},{key:"setOutputToTexture",value:function(t){return this.outputToTexture=t,this}},{key:"setFloatTextures",value:function(t){return this.floatTextures=t,this}},{key:"setFloatOutput",value:function(t){return this.floatOutput=t,this}},{key:"setFloatOutputForce",value:function(t){return this.floatOutputForce=t,this}},{key:"setCanvas",value:function(t){return this._canvas=t,this}},{key:"setWebGl",value:function(t){return this._webGl=t,this}},{key:"setCopyData",value:function(t){return this.copyData=t,this}},{key:"getCanvas",value:function(){return this._canvas}},{key:"getWebGl",value:function(){return this._webGl}},{key:"validateOptions",value:function(){throw new Error("validateOptions not defined")}},{key:"exec",value:function(){return this.execute.apply(this,arguments)}},{key:"execute",value:function(){var t=this,e=1===arguments.length?[arguments[0]]:Array.apply(null,arguments);return s.newPromise(function(n,r){try{n(t.run.apply(t,e))}catch(i){r(i)}})}},{key:"addSubKernel",value:function(t){return null===this.subKernels&&(this.subKernels=[],this.subKernelNames=[]),this.subKernels.push(t),this.subKernelNames.push(s.getFunctionNameFromString(t)),this}},{key:"addSubKernelProperty",value:function(t,e){if(null===this.subKernelProperties&&(this.subKernelProperties={},this.subKernelNames=[]),this.subKernelProperties.hasOwnProperty(t))throw new Error("cannot add sub kernel "+t+", already defined");return this.subKernelProperties[t]=e,this.subKernelNames.push(s.getFunctionNameFromString(e)),this}},{key:"addNativeFunction",value:function(t,e){this.functionBuilder.addNativeFunction(t,e)}}]),t}()},{"../core/utils":25}],9:[function(t,e,n){var r=t("../core/utils");e.exports=function(t){var e=function(){return t.run.apply(t,arguments)};return r.allPropertiesOf(t).forEach(function(n){"_"===n[0]&&"_"===n[1]||("function"==typeof t[n]?"add"===n.substring(0,3)||"set"===n.substring(0,3)?e[n]=function(){return t[n].apply(t,arguments),e}:e[n]=t[n].bind(t):(e.__defineGetter__(n,function(){return t[n]}),e.__defineSetter__(n,function(e){t[n]=e})))}),e.kernel=t,e}},{"../core/utils":25}],10:[function(t,e,n){function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var i=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),s=t("../core/utils"),a=t("./kernel-run-shortcut");e.exports=function(){function t(e,n){r(this,t),n=n||{},this.kernel=n.kernel,this.canvas=n.canvas,this.webGl=n.webGl,this.fn=null,this.functionBuilder=e,this.fnString=null,this.endianness=s.systemEndianness(),this.functionBuilder.polyfillStandardFunctions()}return i(t,[{key:"textureToArray",value:function(t){var e=this.createKernel(function(t){return t[this.thread.z][this.thread.y][this.thread.x]});return e(t)}},{key:"deleteTexture",value:function(t){this.webGl.deleteTexture(t.texture)}},{key:"buildPromiseKernel",value:function(){throw new Error("not yet implemented")}},{key:"getMode",value:function(){throw new Error('"mode" not implemented on BaseRunner')}},{key:"buildKernel",value:function(t,e){e=Object.assign({},e||{});var n=t.toString();return e.functionBuilder||(e.functionBuilder=this.functionBuilder),e.canvas||(e.canvas=this.canvas),e.webGl||(e.webGl=this.webgl),a(new this.Kernel(n,e))}}]),t}()},{"../core/utils":25,"./kernel-run-shortcut":9}],11:[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)}function a(t){return Math.floor(t+.5)}var o=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),u=t("../function-builder-base"),h=t("./function-node");e.exports=function(t){function e(){r(this,e);var t=i(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return t.Node=h,t}return s(e,t),o(e,[{key:"polyfillStandardFunctions",value:function(){this.addFunction("round",a)}}],[{key:"round",value:function(t){return a(t)}}]),e}(u)},{"../function-builder-base":6,"./function-node":12}],12:[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)}function a(t){return t.replace(f,"((").replace(d,"((")}var o=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),u=t("../function-node-base"),h=t("../../core/utils"),l="Math.",p="this.",c="this.constants.",f=/decode32\(\s+encode32\(/g,d=/encode32\(\s+decode32\(/g;e.exports=function(t){function e(){return r(this,e),i(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return s(e,t),o(e,[{key:"generate",value:function(){return this.debug&&console.log(this),this.prototypeOnly?e.astFunctionPrototype(this.getJsAST(),[],this).join("").trim():(this.functionStringArray=this.astGeneric(this.getJsAST(),[],this),this.functionString=a(this.functionStringArray.join("").trim()),this.functionString)}},{key:"astGeneric",value:function(t,e,n){if(null===t)throw this.astErrorOutput("NULL ast",t,n);if(Array.isArray(t)){for(var r=0;r<t.length;r++)this.astGeneric(t[r],e,n);return e}switch(t.type){case"FunctionDeclaration":return this.astFunctionDeclaration(t,e,n);case"FunctionExpression":return this.astFunctionExpression(t,e,n);case"ReturnStatement":return this.astReturnStatement(t,e,n);case"Literal":return this.astLiteral(t,e,n);case"BinaryExpression":return this.astBinaryExpression(t,e,n);case"Identifier":return this.astIdentifierExpression(t,e,n);case"AssignmentExpression":return this.astAssignmentExpression(t,e,n);case"ExpressionStatement":return this.astExpressionStatement(t,e,n);case"EmptyStatement":return this.astEmptyStatement(t,e,n);case"BlockStatement":return this.astBlockStatement(t,e,n);case"IfStatement":return this.astIfStatement(t,e,n);case"BreakStatement":return this.astBreakStatement(t,e,n);case"ContinueStatement":return this.astContinueStatement(t,e,n);case"ForStatement":return this.astForStatement(t,e,n);case"WhileStatement":return this.astWhileStatement(t,e,n);case"VariableDeclaration":return this.astVariableDeclaration(t,e,n);case"VariableDeclarator":return this.astVariableDeclarator(t,e,n);case"ThisExpression":return this.astThisExpression(t,e,n);case"SequenceExpression":return this.astSequenceExpression(t,e,n);case"UnaryExpression":return this.astUnaryExpression(t,e,n);case"UpdateExpression":return this.astUpdateExpression(t,e,n);case"LogicalExpression":return this.astLogicalExpression(t,e,n);case"MemberExpression":return this.astMemberExpression(t,e,n);case"CallExpression":return this.astCallExpression(t,e,n);case"ArrayExpression":return this.astArrayExpression(t,e,n);case"DebuggerStatement":return this.astDebuggerStatement(t,e,n)}throw this.astErrorOutput("Unknown ast type : "+t.type,t,n)}},{key:"astFunctionDeclaration",value:function(t,e,n){return this.addFunction&&this.addFunction(null,h.getAstString(this.jsFunctionString,t)),e}},{key:"astFunctionExpression",value:function(t,e,n){if(n.isRootKernel?(e.push("void"),n.kernalAst=t):e.push(n.returnType),e.push(" "),e.push(n.functionName),e.push("("),!n.isRootKernel)for(var r=0;r<n.paramNames.length;++r){var i=n.paramNames[r];r>0&&e.push(", ");var s=n.getParamType(i);switch(s){case"Texture":case"Input":case"Array":e.push("sampler2D");break;default:e.push("float")}e.push(" "),e.push("user_"),e.push(i)}e.push(") {\n");for(var a=0;a<t.body.body.length;++a)this.astGeneric(t.body.body[a],e,n),e.push("\n");return e.push("}\n"),e}},{key:"astReturnStatement",value:function(t,e,n){return n.isRootKernel?(e.push("kernelResult = "),this.astGeneric(t.argument,e,n),e.push(";"),e.push("return;")):n.isSubKernel?(e.push(n.functionName+"Result = "),this.astGeneric(t.argument,e,n),e.push(";"),e.push("return "+n.functionName+"Result;")):(e.push("return "),this.astGeneric(t.argument,e,n),e.push(";")),e}},{key:"astLiteral",value:function(t,e,n){if(isNaN(t.value))throw this.astErrorOutput("Non-numeric literal not supported : "+t.value,t,n);return e.push(t.value),Number.isInteger(t.value)&&e.push(".0"),e}},{key:"astBinaryExpression",value:function(t,e,n){return e.push("("),"%"===t.operator?(e.push("mod("),this.astGeneric(t.left,e,n),e.push(","),this.astGeneric(t.right,e,n),e.push(")")):"==="===t.operator?(this.astGeneric(t.left,e,n),e.push("=="),this.astGeneric(t.right,e,n)):"!=="===t.operator?(this.astGeneric(t.left,e,n),e.push("!="),this.astGeneric(t.right,e,n)):(this.astGeneric(t.left,e,n),e.push(t.operator),this.astGeneric(t.right,e,n)),e.push(")"),e}},{key:"astIdentifierExpression",value:function(t,e,n){if("Identifier"!==t.type)throw this.astErrorOutput("IdentifierExpression - not an Identifier",t,n);switch(t.name){case"gpu_threadX":e.push("threadId.x");break;case"gpu_threadY":e.push("threadId.y");break;case"gpu_threadZ":e.push("threadId.z");break;case"gpu_outputX":e.push("uOutputDim.x");break;case"gpu_outputY":e.push("uOutputDim.y");break;case"gpu_outputZ":e.push("uOutputDim.z");break;default:if(this.constants&&this.constants.hasOwnProperty(t.name))e.push("constants_"+t.name);else{var r=n.getUserParamName(t.name);null!==r?e.push("user_"+r):e.push("user_"+t.name)}}return e}},{key:"astForStatement",value:function(t,e,n){if("ForStatement"!==t.type)throw this.astErrorOutput("Invalid for statment",t,n);if(t.test&&"BinaryExpression"===t.test.type){if("Identifier"===t.test.right.type&&"<"===t.test.operator&&this.isIdentifierConstant(t.test.right.name)===!1){if(this.loopMaxIterations||(console.warn("Warning: loopMaxIterations is not set! Using default of 1000 which may result in unintended behavior."),console.warn("Set loopMaxIterations or use a for loop of fixed length to silence this message.")),e.push("for ("),this.astGeneric(t.init,e,n),this.astGeneric(t.test.left,e,n),e.push(t.test.operator),e.push("LOOP_MAX"),e.push(";"),this.astGeneric(t.update,e,n),e.push(")"),e.push("{\n"),e.push("if ("),this.astGeneric(t.test.left,e,n),e.push(t.test.operator),this.astGeneric(t.test.right,e,n),e.push(") {\n"),"BlockStatement"===t.body.type)for(var r=0;r<t.body.body.length;r++)this.astGeneric(t.body.body[r],e,n);else this.astGeneric(t.body,e,n);return e.push("} else {\n"),e.push("break;\n"),e.push("}\n"),e.push("}\n"),e}var i=JSON.parse(JSON.stringify(t.init.declarations)),s=t.update.argument;if(!Array.isArray(i)||i.length<1)throw console.log(this.jsFunctionString),new Error("Error: Incompatible for loop declaration");if(i.length>1){for(var a=null,o=0;o<i.length;o++){var u=i[o];u.id.name===s.name?(a=u,i.splice(o,1)):(e.push("float "),this.astGeneric(u,e,n),e.push(";"))}e.push("for (float "),this.astGeneric(a,e,n),e.push(";")}else e.push("for ("),this.astGeneric(t.init,e,n);return this.astGeneric(t.test,e,n),e.push(";"),this.astGeneric(t.update,e,n),e.push(")"),this.astGeneric(t.body,e,n),e}throw this.astErrorOutput("Invalid for statement",t,n)}},{key:"astWhileStatement",value:function(t,e,n){if("WhileStatement"!==t.type)throw this.astErrorOutput("Invalid while statment",t,n);return e.push("for (float i = 0.0; i < LOOP_MAX; i++) {"),e.push("if ("),this.astGeneric(t.test,e,n),e.push(") {\n"),this.astGeneric(t.body,e,n),e.push("} else {\n"),e.push("break;\n"),e.push("}\n"),e.push("}\n"),e}},{key:"astAssignmentExpression",value:function(t,e,n){return"%="!==t.operator?(this.astGeneric(t.left,e,n),e.push(t.operator),this.astGeneric(t.right,e,n),e):(this.astGeneric(t.left,e,n),e.push("="),e.push("mod("),this.astGeneric(t.left,e,n),e.push(","),this.astGeneric(t.right,e,n),e.push(")"),void 0)}},{key:"astEmptyStatement",value:function(t,e,n){return e}},{key:"astBlockStatement",value:function(t,e,n){e.push("{\n");for(var r=0;r<t.body.length;r++)this.astGeneric(t.body[r],e,n);return e.push("}\n"),e}},{key:"astExpressionStatement",value:function(t,e,n){return this.astGeneric(t.expression,e,n),e.push(";\n"),e}},{key:"astVariableDeclaration",value:function(t,e,n){e.push("float ");for(var r=0;r<t.declarations.length;r++)r>0&&e.push(","),this.astGeneric(t.declarations[r],e,n);return e.push(";"),e}},{key:"astVariableDeclarator",value:function(t,e,n){return this.astGeneric(t.id,e,n),null!==t.init&&(e.push("="),this.astGeneric(t.init,e,n)),e}},{key:"astIfStatement",value:function(t,e,n){return e.push("if ("),this.astGeneric(t.test,e,n),e.push(")"),"BlockStatement"===t.consequent.type?this.astGeneric(t.consequent,e,n):(e.push(" {\n"),this.astGeneric(t.consequent,e,n),e.push("\n}\n")),t.alternate&&(e.push("else "),"BlockStatement"===t.alternate.type?this.astGeneric(t.alternate,e,n):(e.push(" {\n"),this.astGeneric(t.alternate,e,n),e.push("\n}\n"))),e}},{key:"astBreakStatement",value:function(t,e,n){return e.push("break;\n"),e}},{key:"astContinueStatement",value:function(t,e,n){return e.push("continue;\n"),e}},{key:"astLogicalExpression",value:function(t,e,n){return e.push("("),this.astGeneric(t.left,e,n),e.push(t.operator),this.astGeneric(t.right,e,n),e.push(")"),e}},{key:"astUpdateExpression",value:function(t,e,n){return t.prefix?(e.push(t.operator),this.astGeneric(t.argument,e,n)):(this.astGeneric(t.argument,e,n),e.push(t.operator)),e}},{key:"astUnaryExpression",value:function(t,e,n){return t.prefix?(e.push(t.operator),this.astGeneric(t.argument,e,n)):(this.astGeneric(t.argument,e,n),e.push(t.operator)),e}},{key:"astThisExpression",value:function(t,e,n){return e.push("this"),e}},{key:"astMemberExpression",value:function(t,e,n){if(t.computed)if("Identifier"===t.object.type){var r=t.object.name,i=(n.functionName||"kernel",!1);if(n.paramNames){var s=n.paramNames.indexOf(r);s>=0&&"float"===n.paramTypes[s]&&(i=!0)}i?(this.astGeneric(t.object,e,n),e.push("[int("),this.astGeneric(t.property,e,n),e.push(")]")):(e.push("get("),this.astGeneric(t.object,e,n),e.push(", vec2("),this.astGeneric(t.object,e,n),e.push("Size[0],"),this.astGeneric(t.object,e,n),e.push("Size[1]), vec3("),this.astGeneric(t.object,e,n),e.push("Dim[0],"),this.astGeneric(t.object,e,n),e.push("Dim[1],"),this.astGeneric(t.object,e,n),e.push("Dim[2]"),e.push("), "),this.astGeneric(t.property,e,n),e.push(")"))}else{this.astGeneric(t.object,e,n);var a=e.pop();e.push(","),this.astGeneric(t.property,e,n),e.push(a)}else{var o=this.astMemberExpressionUnroll(t),u=o.toLowerCase();switch(0===o.indexOf(c)&&(o="constants_"+o.slice(c.length)),u){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(o)}}return e}},{key:"astSequenceExpression",value:function(t,e,n){for(var r=0;r<t.expressions.length;r++)r>0&&e.push(","),this.astGeneric(t.expressions,e,n);return e}},{key:"astCallExpression",value:function(t,e,n){if(t.callee){var r=this.astMemberExpressionUnroll(t.callee);0===r.indexOf(l)&&(r=r.slice(l.length)),0===r.indexOf(p)&&(r=r.slice(p.length)),n.calledFunctions.indexOf(r)<0&&n.calledFunctions.push(r),n.hasOwnProperty("funcName")||(n.calledFunctionsArguments[r]=[]);var i=[];n.calledFunctionsArguments[r].push(i),e.push(r),e.push("(");for(var s=0;s<t.arguments.length;++s){var a=t.arguments[s];if(s>0&&e.push(", "),this.astGeneric(a,e,n),"Identifier"===a.type){var o=n.paramNames.indexOf(a.name);o===-1?i.push(null):i.push({name:a.name,type:n.paramTypes[o]})}else i.push(null)}return e.push(")"),e}throw this.astErrorOutput("Unknown CallExpression",t,n)}},{key:"astArrayExpression",value:function(t,e,n){var r=t.elements.length;e.push("float["+r+"](");for(var i=0;i<r;++i){i>0&&e.push(", ");var s=t.elements[i];this.astGeneric(s,e,n)}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,n){if(n.isRootKernel||n.isSubKernel)return e;e.push(n.returnType),e.push(" "),e.push(n.functionName),e.push("(");for(var r=0;r<n.paramNames.length;++r)r>0&&e.push(", "),e.push(n.paramTypes[r]),e.push(" "),e.push("user_"),e.push(n.paramNames[r]);return e.push(");\n"),e}}]),e}(u)},{"../../core/utils":25,"../function-node-base":7}],13:[function(t,e,n){var r=t("../../core/utils"),i=t("../kernel-run-shortcut");e.exports=function(t,e){return"() => {\n "+i.toString()+";\n const utils = {\n allPropertiesOf: function "+r.allPropertiesOf.toString()+",\n clone: function "+r.clone.toString()+",\n splitArray: function "+r.splitArray.toString()+",\n getArgumentType: function "+r.getArgumentType.toString()+",\n getDimensions: function "+r.getDimensions.toString()+",\n dimToTexSize: function "+r.dimToTexSize.toString()+",\n copyFlatten: function "+r.copyFlatten.toString()+",\n flatten: function "+r.flatten.toString()+",\n systemEndianness: '"+r.systemEndianness()+"',\n initWebGl: function "+r.initWebGl.toString()+",\n isArray: function "+r.isArray.toString()+"\n };\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.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 }\n "+t._getFragShaderString.toString()+"\n "+t._getVertShaderString.toString()+"\n validateOptions() {}\n setupParams() {}\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n "+t.getUniformLocation.toString()+"\n "+t.setupParams.toString()+"\n "+t.build.toString()+"\n\t\t "+t.run.toString()+"\n\t\t "+t._addArgument.toString()+"\n\t\t "+t.getArgumentTexture.toString()+"\n\t\t "+t.getTextureCache.toString()+"\n\t\t "+t.getOutputTexture.toString()+"\n\t\t "+t.renderOutput.toString()+"\n };\n return kernelRunShortcut(new Kernel());\n };"}},{"../../core/utils":25,"../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;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),o=t("../kernel-base"),u=t("../../core/utils"),h=t("../../core/texture"),l=t("./shader-frag"),p=t("./shader-vert"),c=t("./kernel-string"),f=[],d={};e.exports=function(t){function e(t,n){r(this,e);var s=i(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));return s.textureCache={},s.threadDim={},s.programUniformLocationCache={},s.framebuffer=null,s.buffer=null,s.program=null,s.outputToTexture=n.outputToTexture,s.endianness=u.systemEndianness(),s.subKernelOutputTextures=null,s.subKernelOutputVariableNames=null,s.argumentsLength=0,s.ext=null,s.compiledFragShaderString=null,s.compiledVertShaderString=null,s.extDrawBuffersMap=null,s.outputTexture=null,s.maxTexSize=null,s._webGl||(s._webGl=u.initWebGl(s.getCanvas())),s}return s(e,t),a(e,[{key:"validateOptions",value:function(){var t=u.isFloatReadPixelsSupported();if(this.floatTextures===!0&&!u.OES_texture_float)throw"Float textures are not supported on this browser";if(this.floatOutput===!0&&this.floatOutputForce!==!0&&!t)throw"Float texture outputs are not supported on this browser";if(null!==this.floatTextures||t||this.graphical||(this.floatTextures=!0,this.floatOutput=!1),!this.output||0===this.output.length){if(1!==arguments.length)throw"Auto output only supported for kernels with only one input";var e=u.getArgumentType(arguments[0]);if("Array"===e)this.output=u.getDimensions(e);else{if("Texture"!==e)throw"Auto output not supported for input type: "+e;this.output=arguments[0].output}}if(this.texSize=u.dimToTexSize({floatTextures:this.floatTextures,floatOutput:this.floatOutput},this.output,!0),this.graphical){if(2!==this.output.length)throw"Output must have 2 dimensions on graphical mode";if(this.floatOutput)throw"Cannot use graphical mode and float output at the same time";this.texSize=u.clone(this.output)}else void 0===this.floatOutput&&u.OES_texture_float&&(this.floatOutput=!0)}},{key:"updateMaxTexSize",value:function(){var t=this.texSize,e=this._canvas;if(null===this.maxTexSize){var n=f.indexOf(e);n===-1&&(n=f.length,f.push(e),d[n]=[t[0],t[1]]),this.maxTexSize=d[n]}this.maxTexSize[0]<t[0]&&(this.maxTexSize[0]=t[0]),this.maxTexSize[1]<t[1]&&(this.maxTexSize[1]=t[1])}},{key:"build",value:function(){this.validateOptions(),this.setupParams(arguments),this.updateMaxTexSize();var t=this.texSize,e=this._webGl,n=this._canvas;e.enable(e.SCISSOR_TEST),e.viewport(0,0,this.maxTexSize[0],this.maxTexSize[1]),n.width=this.maxTexSize[0],n.height=this.maxTexSize[1];for(var r=this.threadDim=u.clone(this.output);r.length<3;)r.push(1);this.functionBuilder&&this._addKernels();var i=this._getVertShaderString(arguments),s=e.createShader(e.VERTEX_SHADER);e.shaderSource(s,i),e.compileShader(s);var a=this._getFragShaderString(arguments),o=e.createShader(e.FRAGMENT_SHADER);if(e.shaderSource(o,a),e.compileShader(o),!e.getShaderParameter(s,e.COMPILE_STATUS))throw console.log(i),console.error("An error occurred compiling the shaders: "+e.getShaderInfoLog(s)),"Error compiling vertex shader";if(!e.getShaderParameter(o,e.COMPILE_STATUS))throw console.log(a),console.error("An error occurred compiling the shaders: "+e.getShaderInfoLog(o)),"Error compiling fragment shader";this.debug&&(console.log("Options:"),console.dir(this),console.log("GLSL Shader Output:"),console.log(a));var h=this.program=e.createProgram();e.attachShader(h,s),e.attachShader(h,o),e.linkProgram(h),this.framebuffer=e.createFramebuffer(),this.framebuffer.width=t[0],this.framebuffer.height=t[1];var l=new Float32Array([-1,-1,1,-1,-1,1,1,1]),p=new Float32Array([0,0,1,0,0,1,1,1]),c=l.byteLength,f=this.buffer;f?e.bindBuffer(e.ARRAY_BUFFER,f):(f=this.buffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,f),e.bufferData(e.ARRAY_BUFFER,l.byteLength+p.byteLength,e.STATIC_DRAW)),e.bufferSubData(e.ARRAY_BUFFER,0,l),e.bufferSubData(e.ARRAY_BUFFER,c,p);var d=e.getAttribLocation(this.program,"aPos");e.enableVertexAttribArray(d),e.vertexAttribPointer(d,2,e.FLOAT,e.FALSE,0,0);var m=e.getAttribLocation(this.program,"aTexCoord");if(e.enableVertexAttribArray(m),e.vertexAttribPointer(m,2,e.FLOAT,e.FALSE,0,c),this.setupOutputTexture(),null!==this.subKernelOutputTextures)for(var g=this.extDrawBuffersMap=[e.COLOR_ATTACHMENT0],y=0;y<this.subKernelOutputTextures.length;y++){var v=this.subKernelOutputTextures[y];g.push(e.COLOR_ATTACHMENT0+y+1),e.activeTexture(e.TEXTURE0+arguments.length+y),e.bindTexture(e.TEXTURE_2D,v),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),this.floatOutput?e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t[0],t[1],0,e.RGBA,e.FLOAT,null):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t[0],t[1],0,e.RGBA,e.UNSIGNED_BYTE,null)}}},{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;if(r.useProgram(this.program),r.scissor(0,0,n[0],n[1]),!this.hardcodeConstants){var i=this.getUniformLocation("uOutputDim");r.uniform3fv(i,this.threadDim);var s=this.getUniformLocation("uTexSize");r.uniform2fv(s,n)}var a=this.getUniformLocation("ratio");r.uniform2f(a,n[0]/this.maxTexSize[0],n[1]/this.maxTexSize[1]),this.argumentsLength=0;for(var o=0;o<t.length;o++)this._addArgument(arguments[o],e[o],t[o]);if(this.graphical)return r.bindRenderbuffer(r.RENDERBUFFER,null),r.bindFramebuffer(r.FRAMEBUFFER,null),void r.drawArrays(r.TRIANGLE_STRIP,0,4);r.bindFramebuffer(r.FRAMEBUFFER,this.framebuffer);var u=this.outputTexture;if(r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,u,0),null!==this.subKernelOutputTextures){for(var l=0;l<this.subKernelOutputTextures.length;l++){var p=this.subKernelOutputTextures[l];r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+l+1,r.TEXTURE_2D,p,0)}this.ext.drawBuffersWEBGL(this.extDrawBuffersMap)}if(r.drawArrays(r.TRIANGLE_STRIP,0,4),null!==this.subKernelOutputTextures){if(null!==this.subKernels){var c=[];c.result=this.renderOutput(u);for(var f=0;f<this.subKernels.length;f++)c.push(new h(this.subKernelOutputTextures[f],n,this.output,this._webGl));return c}if(null!==this.subKernelProperties){var d={result:this.renderOutput(u)},m=0;for(var g in this.subKernelProperties)this.subKernelProperties.hasOwnProperty(g)&&(d[g]=new h(this.subKernelOutputTextures[m],n,this.output,this._webGl),m++);return d}}return this.renderOutput(u)}},{key:"renderOutput",value:function(t){var e=this.texSize,n=this._webGl,r=this.threadDim,i=this.output;if(this.outputToTexture)return new h(t,e,i,this._webGl);var s=void 0;if(this.floatOutput)s=new Float32Array(e[0]*e[1]*4),n.readPixels(0,0,e[0],e[1],n.RGBA,n.FLOAT,s);else{var a=new Uint8Array(e[0]*e[1]*4);n.readPixels(0,0,e[0],e[1],n.RGBA,n.UNSIGNED_BYTE,a),s=new Float32Array(a.buffer)}if(s=s.subarray(0,r[0]*r[1]*r[2]),1===i.length)return s;if(2===i.length)return u.splitArray(s,i[0]);if(3===i.length){var o=u.splitArray(s,i[0]*i[1]);return o.map(function(t){return u.splitArray(t,i[0])})}}},{key:"getOutputTexture",value:function(){return this.getTextureCache("OUTPUT")}},{key:"detachOutputTexture",value:function(){this.detachTextureCache("OUTPUT")}},{key:"setupOutputTexture",value:function(){var t=this._webGl,e=this.texSize;this.detachOutputTexture(),this.outputTexture=this.getOutputTexture(),t.activeTexture(t.TEXTURE0+this.paramNames.length),t.bindTexture(t.TEXTURE_2D,this.outputTexture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),this.floatOutput?t.texImage2D(t.TEXTURE_2D,0,t.RGBA,e[0],e[1],0,t.RGBA,t.FLOAT,null):t.texImage2D(t.TEXTURE_2D,0,t.RGBA,e[0],e[1],0,t.RGBA,t.UNSIGNED_BYTE,null)}},{key:"getArgumentTexture",value:function(t){return this.getTextureCache("ARGUMENT_"+t)}},{key:"getSubKernelTexture",value:function(t){return this.getTextureCache("SUB_KERNEL_"+t)}},{key:"getTextureCache",value:function(t){return this.outputToTexture?this._webGl.createTexture():this.textureCache.hasOwnProperty(t)?this.textureCache[t]:this.textureCache[t]=this._webGl.createTexture()}},{key:"detachTextureCache",value:function(t){delete this.textureCache[t]}},{key:"getUniformLocation",value:function(t){var e=this.programUniformLocationCache[t];return e||(e=this._webGl.getUniformLocation(this.program,t),this.programUniformLocationCache[t]=e),e}},{key:"_getFragShaderArtifactMap",value:function(t){return{HEADER:this._getHeaderString(),LOOP_MAX:this._getLoopMaxString(),CONSTANTS:this._getConstantsString(),DECODE32_ENDIANNESS:this._getDecode32EndiannessString(),ENCODE32_ENDIANNESS:this._getEncode32EndiannessString(),GET_WRAPAROUND:this._getGetWraparoundString(),GET_TEXTURE_CHANNEL:this._getGetTextureChannelString(),GET_TEXTURE_INDEX:this._getGetTextureIndexString(),GET_RESULT:this._getGetResultString(),MAIN_PARAMS:this._getMainParamsString(t),MAIN_CONSTANTS:this._getMainConstantsString(),KERNEL:this._getKernelString(),MAIN_RESULT:this._getMainResultString()}}},{key:"_addArgument",value:function(t,e,n){var r=this._webGl,i=this.getArgumentTexture(n);switch(t instanceof h&&(e="Texture"),e){case"Array":var s=u.getDimensions(t,!0),a=u.dimToTexSize({floatTextures:this.floatTextures,floatOutput:this.floatOutput},s);r.activeTexture(r.TEXTURE0+this.argumentsLength),r.bindTexture(r.TEXTURE_2D,i),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST);var o=a[0]*a[1];this.floatTextures&&(o*=4);var l=new Float32Array(o);u.flattenTo(t,l);var p=void 0;this.floatTextures?r.texImage2D(r.TEXTURE_2D,0,r.RGBA,a[0],a[1],0,r.RGBA,r.FLOAT,l):(p=new Uint8Array(l.buffer),
r.texImage2D(r.TEXTURE_2D,0,r.RGBA,a[0],a[1],0,r.RGBA,r.UNSIGNED_BYTE,p));var c=this.getUniformLocation("user_"+n),f=this.getUniformLocation("user_"+n+"Size"),d=this.getUniformLocation("user_"+n+"Dim");this.hardcodeConstants||(r.uniform3fv(d,s),r.uniform2fv(f,a)),r.uniform1i(c,this.argumentsLength);break;case"Number":var m=this.getUniformLocation("user_"+n);r.uniform1f(m,t);break;case"Input":var g=t,y=g.size,v=u.dimToTexSize({floatTextures:this.floatTextures,floatOutput:this.floatOutput},y);r.activeTexture(r.TEXTURE0+this.argumentsLength),r.bindTexture(r.TEXTURE_2D,i),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST);var b=v[0]*v[1],x=void 0;if(this.floatTextures?(b*=4,x=new Float32Array(b),x.set(g.value)):x=g.value,this.floatTextures)r.texImage2D(r.TEXTURE_2D,0,r.RGBA,v[0],v[1],0,r.RGBA,r.FLOAT,x);else{var k=new Uint8Array(x.buffer);r.texImage2D(r.TEXTURE_2D,0,r.RGBA,v[0],v[1],0,r.RGBA,r.UNSIGNED_BYTE,k)}var S=this.getUniformLocation("user_"+n),E=this.getUniformLocation("user_"+n+"Size"),_=this.getUniformLocation("user_"+n+"Dim");this.hardcodeConstants||(r.uniform3fv(_,y),r.uniform2fv(E,v)),r.uniform1i(S,this.argumentsLength);break;case"Texture":var T=t,w=u.getDimensions(T,!0),A=T.size;T.texture===this.outputTexture&&this.setupOutputTexture(),r.activeTexture(r.TEXTURE0+this.argumentsLength),r.bindTexture(r.TEXTURE_2D,T.texture);var O=this.getUniformLocation("user_"+n),N=this.getUniformLocation("user_"+n+"Size"),P=this.getUniformLocation("user_"+n+"Dim");r.uniform3fv(P,w),r.uniform2fv(N,A),r.uniform1i(O,this.argumentsLength);break;default:throw"Input type not supported (WebGL): "+t}this.argumentsLength++}},{key:"_getHeaderString",value:function(){return null!==this.subKernels||null!==this.subKernelProperties?"#extension GL_EXT_draw_buffers : require\n":""}},{key:"_getLoopMaxString",value:function(){return this.loopMaxIterations?" "+parseInt(this.loopMaxIterations)+".0;\n":" 1000.0;\n"}},{key:"_getConstantsString",value:function(){var t=[],e=this.threadDim,n=this.texSize;return this.hardcodeConstants?t.push("highp vec3 uOutputDim = vec3("+e[0]+","+e[1]+", "+e[2]+")","highp vec2 uTexSize = vec2("+n[0]+", "+n[1]+")"):t.push("uniform highp vec3 uOutputDim","uniform highp vec2 uTexSize"),this._linesToString(t)}},{key:"_getTextureCoordinate",value:function(){var t=this.subKernelOutputVariableNames;return null===t||t.length<1?"varying highp vec2 vTexCoord;\n":"out highp vec2 vTexCoord;\n"}},{key:"_getDecode32EndiannessString",value:function(){return"LE"===this.endianness?"":" rgba.rgba = rgba.abgr;\n"}},{key:"_getEncode32EndiannessString",value:function(){return"LE"===this.endianness?"":" rgba.rgba = rgba.abgr;\n"}},{key:"_getGetWraparoundString",value:function(){return this.wraparound?" xyz = mod(xyz, texDim);\n":""}},{key:"_getGetTextureChannelString",value:function(){return this.floatTextures?this._linesToString([" int channel = int(integerMod(index, 4.0))"," index = float(int(index) / 4)"]):""}},{key:"_getGetTextureIndexString",value:function(){return this.floatTextures?" index = float(int(index)/4);\n":""}},{key:"_getGetResultString",value:function(){return this.floatTextures?this._linesToString([" if (channel == 0) return texel.r"," if (channel == 1) return texel.g"," if (channel == 2) return texel.b"," if (channel == 3) return texel.a"]):" return decode32(texel);\n"}},{key:"_getMainParamsString",value:function(t){for(var e=[],n=this.paramTypes,r=this.paramNames,i=0;i<r.length;i++){var s=t[i],a=r[i],o=n[i];if(this.hardcodeConstants)if("Array"===o||"Texture"===o){var h=u.getDimensions(s,!0),l=u.dimToTexSize({floatTextures:this.floatTextures,floatOutput:this.floatOutput},h);e.push("uniform highp sampler2D user_"+a,"highp vec2 user_"+a+"Size = vec2("+l[0]+".0, "+l[1]+".0)","highp vec3 user_"+a+"Dim = vec3("+h[0]+".0, "+h[1]+".0, "+h[2]+".0)")}else"Number"===o&&Number.isInteger(s)?e.push("highp float user_"+a+" = "+s+".0"):"Number"===o&&e.push("highp float user_"+a+" = "+s);else"Array"===o||"Texture"===o||"Input"===o?e.push("uniform highp sampler2D user_"+a,"uniform highp vec2 user_"+a+"Size","uniform highp vec3 user_"+a+"Dim"):"Number"===o&&e.push("uniform highp float user_"+a)}return this._linesToString(e)}},{key:"_getMainConstantsString",value:function(){var t=[];if(this.constants)for(var e in this.constants)if(this.constants.hasOwnProperty(e)){var n=parseFloat(this.constants[e]);Number.isInteger(n)?t.push("const float constants_"+e+" = "+parseInt(n)+".0"):t.push("const float constants_"+e+" = "+parseFloat(n))}return this._linesToString(t)}},{key:"_getKernelString",value:function(){var t=[],e=this.subKernelOutputVariableNames;if(null!==e){t.push("highp float kernelResult = 0.0");for(var n=0;n<e.length;n++)t.push("highp float "+e[n]+" = 0.0")}else t.push("highp float kernelResult = 0.0");return this._linesToString(t)+this.functionBuilder.getPrototypeString("kernel")}},{key:"_getMainResultString",value:function(){var t=this.subKernelOutputVariableNames,e=[];if(this.floatOutput&&e.push(" index *= 4.0"),this.graphical)e.push(" threadId = indexTo3D(index, uOutputDim)"," kernel()"," gl_FragColor = actualColor");else if(this.floatOutput)for(var n=["r","g","b","a"],r=0;r<n.length;++r){if(e.push(" threadId = indexTo3D(index, uOutputDim)"),e.push(" kernel()"),t){e.push(" gl_FragData[0]."+n[r]+" = kernelResult");for(var i=0;i<t.length;++i)e.push(" gl_FragData["+(i+1)+"]."+n[r]+" = "+t[i])}else e.push(" gl_FragColor."+n[r]+" = kernelResult");r<n.length-1&&e.push(" index += 1.0")}else if(null!==t){e.push(" threadId = indexTo3D(index, uOutputDim)"),e.push(" kernel()"),e.push(" gl_FragData[0] = encode32(kernelResult)");for(var s=0;s<t.length;s++)e.push(" gl_FragData["+(s+1)+"] = encode32("+t[s]+")")}else e.push(" threadId = indexTo3D(index, uOutputDim)"," kernel()"," gl_FragColor = encode32(kernelResult)");return this._linesToString(e)}},{key:"_linesToString",value:function(t){return t.length>0?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.functionBuilder,e=this._webGl;if(t.addFunctions(this.functions,{constants:this.constants,output:this.output}),t.addNativeFunctions(this.nativeFunctions),t.addKernel(this.fnString,{prototypeOnly:!1,constants:this.constants,output:this.output,debug:this.debug,loopMaxIterations:this.loopMaxIterations},this.paramNames,this.paramTypes),null!==this.subKernels){var n=this.ext=e.getExtension("WEBGL_draw_buffers");if(!n)throw new Error("could not instantiate draw buffers extension");this.subKernelOutputTextures=[],this.subKernelOutputVariableNames=[];for(var r=0;r<this.subKernels.length;r++){var i=this.subKernels[r];t.addSubKernel(i,{prototypeOnly:!1,constants:this.constants,output:this.output,debug:this.debug,loopMaxIterations:this.loopMaxIterations}),this.subKernelOutputTextures.push(this.getSubKernelTexture(r)),this.subKernelOutputVariableNames.push(i.name+"Result")}}else if(null!==this.subKernelProperties){var s=this.ext=e.getExtension("WEBGL_draw_buffers");if(!s)throw new Error("could not instantiate draw buffers extension");this.subKernelOutputTextures=[],this.subKernelOutputVariableNames=[];var a=0;for(var o in this.subKernelProperties)if(this.subKernelProperties.hasOwnProperty(o)){var u=this.subKernelProperties[o];t.addSubKernel(u,{prototypeOnly:!1,constants:this.constants,output:this.output,debug:this.debug,loopMaxIterations:this.loopMaxIterations}),this.subKernelOutputTextures.push(this.getSubKernelTexture(o)),this.subKernelOutputVariableNames.push(u.name+"Result"),a++}}}},{key:"_getFragShaderString",value:function(t){return null!==this.compiledFragShaderString?this.compiledFragShaderString:this.compiledFragShaderString=this._replaceArtifacts(l,this._getFragShaderArtifactMap(t))}},{key:"_getVertShaderString",value:function(t){return null!==this.compiledVertShaderString?this.compiledVertShaderString:this.compiledVertShaderString=p}},{key:"toString",value:function(){return c(this)}},{key:"addFunction",value:function(t){this.functionBuilder.addFunction(null,t)}}]),e}(o)},{"../../core/texture":23,"../../core/utils":25,"../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;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),o=t("../runner-base"),u=t("./kernel"),h=(t("../../core/utils"),t("./function-builder"));e.exports=function(t){function e(t){r(this,e);var n=i(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,new h,t));return n.Kernel=u,n.kernel=null,n}return s(e,t),a(e,[{key:"getMode",value:function(){return"gpu"}}]),e}(o)},{"../../core/utils":25,"../runner-base":10,"./function-builder":11,"./kernel":14}],16:[function(t,e,n){e.exports="__HEADER__;\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nconst float LOOP_MAX = __LOOP_MAX__;\n#define EPSILON 0.0000001;\n\n__CONSTANTS__;\n\nvarying highp vec2 vTexCoord;\n\nvec4 round(vec4 x) {\n return floor(x + 0.5);\n}\n\nhighp float round(highp float x) {\n return floor(x + 0.5);\n}\n\nvec2 integerMod(vec2 x, float y) {\n vec2 res = floor(mod(x, y));\n return res * step(1.0 - floor(y), -res);\n}\n\nvec3 integerMod(vec3 x, float y) {\n vec3 res = floor(mod(x, y));\n return res * step(1.0 - floor(y), -res);\n}\n\nvec4 integerMod(vec4 x, vec4 y) {\n vec4 res = floor(mod(x, y));\n return res * step(1.0 - floor(y), -res);\n}\n\nhighp float integerMod(highp float x, highp float y) {\n highp float res = floor(mod(x, y));\n return res * (res > floor(y) - 1.0 ? 0.0 : 1.0);\n}\n\nhighp int integerMod(highp int x, highp int y) {\n return int(integerMod(float(x), float(y)));\n}\n\n// Here be dragons!\n// DO NOT OPTIMIZE THIS CODE\n// YOU WILL BREAK SOMETHING ON SOMEBODY'S MACHINE\n// LEAVE IT AS IT IS, LEST YOU WASTE YOUR OWN TIME\nconst vec2 MAGIC_VEC = vec2(1.0, -256.0);\nconst vec4 SCALE_FACTOR = vec4(1.0, 256.0, 65536.0, 0.0);\nconst vec4 SCALE_FACTOR_INV = vec4(1.0, 0.00390625, 0.0000152587890625, 0.0); // 1, 1/256, 1/65536\nhighp float decode32(highp vec4 rgba) {\n __DECODE32_ENDIANNESS__;\n rgba *= 255.0;\n vec2 gte128;\n gte128.x = rgba.b >= 128.0 ? 1.0 : 0.0;\n gte128.y = rgba.a >= 128.0 ? 1.0 : 0.0;\n float exponent = 2.0 * rgba.a - 127.0 + dot(gte128, MAGIC_VEC);\n float res = exp2(round(exponent));\n rgba.b = rgba.b - 128.0 * gte128.x;\n res = dot(rgba, SCALE_FACTOR) * exp2(round(exponent-23.0)) + res;\n res *= gte128.y * -2.0 + 1.0;\n return res;\n}\n\nhighp vec4 encode32(highp float f) {\n highp float F = abs(f);\n highp float sign = f < 0.0 ? 1.0 : 0.0;\n highp float exponent = floor(log2(F));\n highp float mantissa = (exp2(-exponent) * F);\n // exponent += floor(log2(mantissa));\n vec4 rgba = vec4(F * exp2(23.0-exponent)) * SCALE_FACTOR_INV;\n rgba.rg = integerMod(rgba.rg, 256.0);\n rgba.b = integerMod(rgba.b, 128.0);\n rgba.a = exponent*0.5 + 63.5;\n rgba.ba += vec2(integerMod(exponent+127.0, 2.0), sign) * 128.0;\n rgba = floor(rgba);\n rgba *= 0.003921569; // 1/255\n __ENCODE32_ENDIANNESS__;\n return rgba;\n}\n// Dragons end here\n\nhighp float index;\nhighp vec3 threadId;\n\nhighp vec3 indexTo3D(highp float idx, highp vec3 texDim) {\n highp float z = floor(idx / (texDim.x * texDim.y));\n idx -= z * texDim.x * texDim.y;\n highp float y = floor(idx / texDim.x);\n highp float x = integerMod(idx, texDim.x);\n return vec3(x, y, z);\n}\n\nhighp float get(highp sampler2D tex, highp vec2 texSize, highp vec3 texDim, highp float z, highp float y, highp float x) {\n highp vec3 xyz = vec3(x, y, z);\n xyz = floor(xyz + 0.5);\n __GET_WRAPAROUND__;\n highp float index = round(xyz.x + texDim.x * (xyz.y + texDim.y * xyz.z));\n __GET_TEXTURE_CHANNEL__;\n highp float w = round(texSize.x);\n vec2 st = vec2(integerMod(index, w), float(int(index) / int(w))) + 0.5;\n __GET_TEXTURE_INDEX__;\n highp vec4 texel = texture2D(tex, st / texSize);\n __GET_RESULT__;\n}\n\nhighp float get(highp sampler2D tex, highp vec2 texSize, highp vec3 texDim, highp float y, highp float x) {\n return get(tex, texSize, texDim, 0.0, y, x);\n}\n\nhighp float get(highp sampler2D tex, highp vec2 texSize, highp vec3 texDim, highp float x) {\n return get(tex, texSize, texDim, 0.0, 0.0, x);\n}\n\nhighp vec4 actualColor;\nvoid color(float r, float g, float b, float a) {\n actualColor = vec4(r,g,b,a);\n}\n\nvoid color(float r, float g, float b) {\n color(r,g,b,1.0);\n}\n\n__MAIN_PARAMS__;\n__MAIN_CONSTANTS__;\n__KERNEL__;\n\nvoid main(void) {\n index = floor(vTexCoord.s * float(uTexSize.x)) + floor(vTexCoord.t * float(uTexSize.y)) * uTexSize.x;\n __MAIN_RESULT__;\n}"},{}],17:[function(t,e,n){e.exports="precision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nattribute highp vec2 aPos;\nattribute highp vec2 aTexCoord;\n\nvarying highp vec2 vTexCoord;\nuniform vec2 ratio;\n\nvoid main(void) {\n gl_Position = vec4((aPos + vec2(1)) * ratio + vec2(-1), 0, 1);\n vTexCoord = aTexCoord;\n}"},{}],18:[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;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),o=t("./kernel"),u=t("../../core/utils");e.exports=function(t){function e(){return r(this,e),i(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return s(e,t),a(e,[{key:"validateOptions",value:function(){this.texSize=u.dimToTexSize({floatTextures:this.floatTextures,floatOutput:this.floatOutput},this.output,!0)}}]),e}(o)},{"../../core/utils":25,"./kernel":14}],19:[function(t,e,n){var r=t("./utils");e.exports=function(t,e){var n=e.toString();return new Function("return function "+t+" ("+r.getParamNamesFromString(n).join(", ")+") {"+r.getFunctionBodyFromString(n)+"}")()}},{"./utils":25}],20:[function(t,e,n){function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var i=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}();t("./utils-core");e.exports=function(){function t(){r(this,t)}return i(t,null,[{key:"validateKernelObj",value:function(t){if(null===t)throw"KernelObj being validated is NULL";if("string"==typeof t){try{t=JSON.parse(t)}catch(e){throw console.error(e),"Failed to convert KernelObj from JSON string"}if(null===t)throw"Invalid (NULL) KernelObj JSON string representation"}if(t.isKernelObj!==!0)throw"Failed missing isKernelObj flag check";return t}},{key:"loadKernelObj",value:function(t,e){t=validateKernelObj(t)}}]),t}()},{"./utils-core":24}],21:[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;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),o=t("./utils"),u=t("../backend/web-gl/runner"),h=t("../backend/cpu/runner"),l=t("../backend/web-gl/validator-kernel"),p=t("./gpu-core"),c=function(t){function e(t){r(this,e);var n=i(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));t=t||{},n._canvas=t.canvas||null,n._webGl=t.webGl||null;var s=t.mode||"webgl";o.isWebGlSupported()||(console.warn("Warning: gpu not supported, falling back to cpu support"),s="cpu"),n.kernels=[];var a={canvas:n._canvas,webGl:n._webGl};if(s)switch(s.toLowerCase()){case"cpu":n._runner=new h(a);break;case"gpu":case"webgl":n._runner=new u(a);break;case"webgl-validator":n._runner=new u(a),n._runner.Kernel=l;break;default:throw new Error('"'+s+'" mode is not defined')}return n}return s(e,t),a(e,[{key:"createKernel",value:function(t,e){if("undefined"==typeof t)throw"Missing fn parameter";if(!o.isFunction(t)&&"string"!=typeof t)throw"fn parameter not a function";var n=this._runner.buildKernel(t,e||{});return this._canvas||(this._canvas=n.getCanvas()),this._runner.canvas||(this._runner.canvas=n.getCanvas()),this.kernels.push(n),n}},{key:"createKernelMap",value:function(){var t=void 0,e=void 0;"function"==typeof arguments[arguments.length-2]?(t=arguments[arguments.length-2],e=arguments[arguments.length-1]):t=arguments[arguments.length-1],o.isWebGlDrawBuffersSupported()||(this._runner=new h(e));var n=this.createKernel(t,e);if(Array.isArray(arguments[0]))for(var r=arguments[0],i=0;i<r.length;i++)n.addSubKernel(r[i]);else{var s=arguments[0];for(var a in s)s.hasOwnProperty(a)&&n.addSubKernelProperty(a,s[a])}return n}},{key:"combineKernels",value:function(){var t=arguments[arguments.length-2],e=arguments[arguments.length-1];if("cpu"===this.getMode())return e;for(var n=arguments[0].getCanvas(),r=arguments[0].getWebGl(),i=0;i<arguments.length-1;i++)arguments[i].setCanvas(n).setWebGl(r).setOutputToTexture(!0);return function(){e.apply(null,arguments);var n=t.texSize,r=t.getWebGl(),i=t.threadDim,s=void 0;if(t.floatOutput)s=new Float32Array(n[0]*n[1]*4),r.readPixels(0,0,n[0],n[1],r.RGBA,r.FLOAT,s);else{var a=new Uint8Array(n[0]*n[1]*4);r.readPixels(0,0,n[0],n[1],r.RGBA,r.UNSIGNED_BYTE,a),s=new Float32Array(a.buffer)}if(s=s.subarray(0,i[0]*i[1]*i[2]),1===t.output.length)return s;if(2===t.output.length)return o.splitArray(s,t.output[0]);if(3===t.output.length){var u=o.splitArray(s,t.output[0]*t.output[1]);return u.map(function(e){return o.splitArray(e,t.output[0])})}}}},{key:"addFunction",value:function(t,e,n){return this._runner.functionBuilder.addFunction(null,t,e,n),this}},{key:"addNativeFunction",value:function(t,e){return this._runner.functionBuilder.addNativeFunction(t,e),this}},{key:"getMode",value:function(){return this._runner.getMode()}},{key:"isWebGlSupported",value:function(){return o.isWebGlSupported()}},{key:"getCanvas",value:function(){return this._canvas}},{key:"getWebGl",value:function(){return this._webGl}}]),e}(p);Object.assign(c,p),e.exports=c},{"../backend/cpu/runner":5,"../backend/web-gl/runner":15,"../backend/web-gl/validator-kernel":18,"./gpu-core":20,"./utils":25}],22:[function(t,e,n){function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.exports=function i(t,e){if(r(this,i),this.value=t,Array.isArray(e)){this.size=[];for(var n=0;n<e.length;n++)this.size[n]=e[n];for(;this.size.length<3;)this.size.push(1)}else e.z?this.size=[e.x,e.y,e.z]:e.y?this.size=[e.x,e.y,1]:this.size=[e.x,1,1]}},{}],23:[function(t,e,n){function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var i=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}();e.exports=function(){function t(e,n,i,s){r(this,t),this.texture=e,this.size=n,this.output=i,this.webGl=s,this.kernel=null}return i(t,[{key:"toArray",value:function(t){if(!t)throw new Error("You need to pass the GPU object for toArray to work.");return this.kernel?this.kernel(this):(this.kernel=t.createKernel(function(t){return t[this.thread.z][this.thread.y][this.thread.x]}).setOutput(this.output),this.kernel(this))}},{key:"delete",value:function(){return this.webGl.deleteTexture(this.texture)}}]),t}()},{}],24:[function(t,e,n){function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var i=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),s=function(){function t(){r(this,t)}return i(t,null,[{key:"isCanvas",value:function(t){return null!==t&&t.nodeName&&t.getContext&&"CANVAS"===t.nodeName.toUpperCase()}},{key:"isCanvasSupported",value:function(){return a}},{key:"initCanvas",value:function(){if(!a)return null;var t=document.createElement("canvas");return t.width=2,t.height=2,t}},{key:"isWebGl",value:function(t){return t&&"function"==typeof t.getExtension}},{key:"isWebGlSupported",value:function(){return u}},{key:"isWebGlDrawBuffersSupported",value:function(){return h}},{key:"initWebGlDefaultOptions",value:function(){return{alpha:!1,depth:!1,antialias:!1}}},{key:"initWebGl",value:function(e){if(("undefined"!=typeof a||null===e)&&!a)return null;if(!t.isCanvas(e))throw new Error("Invalid canvas object - "+e);var n=e.getContext("experimental-webgl",t.initWebGlDefaultOptions())||e.getContext("webgl",t.initWebGlDefaultOptions());return n&&(n.OES_texture_float=n.getExtension("OES_texture_float"),n.OES_texture_float_linear=n.getExtension("OES_texture_float_linear"),n.OES_element_index_uint=n.getExtension("OES_element_index_uint")),n}}]),t}(),a="undefined"!=typeof document&&s.isCanvas(document.createElement("canvas")),o=s.initWebGl(s.initCanvas()),u=s.isWebGl(o),h=u&&Boolean(o.getExtension("WEBGL_draw_buffers"));u?(s.OES_texture_float=o.OES_texture_float,s.OES_texture_float_linear=o.OES_texture_float_linear,s.OES_element_index_uint=o.OES_element_index_uint):(s.OES_texture_float=!1,s.OES_texture_float_linear=!1,s.OES_element_index_uint=!1),e.exports=s},{}],25:[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"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),u=t("./utils-core"),h=t("./input"),l=t("./texture"),p=/function ([^(]*)/,c=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm,f=/([^\s,]+)/g,d=function(){var t=new ArrayBuffer(4),e=new Uint32Array(t),n=new Uint8Array(t);if(e[0]=3735928559,239===n[0])return"LE";if(222===n[0])return"BE";throw new Error("unknown endianness")}(),m=null,g=function(e){function n(){return r(this,n),i(this,(n.__proto__||Object.getPrototypeOf(n)).apply(this,arguments))}return s(n,e),o(n,null,[{key:"systemEndianness",value:function(){return d}},{key:"isFunction",value:function(t){return"function"==typeof t}},{key:"isFunctionString",value:function(t){return null!==t&&"function"===t.toString().slice(0,"function".length).toLowerCase()}},{key:"getFunctionNameFromString",value:function(t){return p.exec(t)[1]}},{key:"getFunctionBodyFromString",value:function(t){return t.substring(t.indexOf("{")+1,t.lastIndexOf("}"))}},{key:"getParamNamesFromString",value:function(t){var e=t.toString().replace(c,""),n=e.slice(e.indexOf("(")+1,e.indexOf(")")).match(f);return null===n&&(n=[]),n}},{key:"clone",value:function(t){if(null===t||"object"!==("undefined"==typeof t?"undefined":a(t))||t.hasOwnProperty("isActiveClone"))return t;var e=t.constructor();for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(t.isActiveClone=null,e[r]=n.clone(t[r]),delete t.isActiveClone);return e}},{key:"newPromise",value:function(t){var e=Promise||small_promise;if(null===e)throw TypeError("Browser is missing Promise implementation. Consider adding small_promise.js polyfill");return new e(t)}},{key:"functionBinder",value:function(t,e){return t.bind?t.bind(e):function(){var n=1===arguments.length?[arguments[0]]:Array.apply(null,arguments);return t.apply(e,n)}}},{key:"isArray",value:function(t){return!isNaN(t.length)}},{key:"getArgumentType",value:function(t){return n.isArray(t)?"Array":"number"==typeof t?"Number":t instanceof l?"Texture":t instanceof h?"Input":"Unknown"}},{key:"isFloatReadPixelsSupported",value:function(){if(null!==m)return m;var e=t("../index"),n=new e({mode:"webgl-validator"}).createKernel(function(){return 1},{output:[2],floatTextures:!0,floatOutput:!0,floatOutputForce:!0})();return m=1===n[0]}},{key:"dimToTexSize",value:function(t,e,n){for(var r=e[0],i=1;i<e.length;i++)r*=e[i];!t.floatTextures||n&&!t.floatOutput||(r=Math.ceil(r/4));var s=Math.ceil(Math.sqrt(r));return[s,s]}},{key:"getDimensions",value:function(t,e){var r=void 0;if(n.isArray(t)){for(var i=[],s=t;n.isArray(s);)i.push(s.length),s=s[0];r=i.reverse()}else if(t instanceof l)r=t.output;else{if(!(t instanceof h))throw"Unknown dimensions of "+t;r=t.size}if(e)for(r=n.clone(r);r.length<3;)r.push(1);return r}},{key:"pad",value:function(t,e){function n(t){return Array.apply(null,new Array(t)).map(Number.prototype.valueOf,0)}for(var r=t.length+2*e,i=t.map(function(t){return[].concat(n(e),t,n(e))}),s=0;s<e;s++)i=[].concat([n(r)],i,[n(r)]);return i}},{key:"flatten2dArrayTo",value:function(t,e){for(var n=0,r=0;r<t.length;r++)e.set(t[r],n),n+=t[r].length}},{key:"flatten3dArrayTo",value:function(t,e){for(var n=0,r=0;r<t.length;r++)for(var i=0;i<t[r].length;i++)e.set(t[r][i],n),n+=t[r][i].length}},{key:"flattenTo",value:function(t,e){n.isArray(t[0])?n.isArray(t[0][0])?n.flatten3dArrayTo(t,e):n.flatten2dArrayTo(t,e):e.set(t)}},{key:"splitArray",value:function(t,e){for(var n=[],r=0;r<t.length;r+=e)n.push(Array.prototype.slice.call(t,r,r+e));return n}},{key:"getAstString",value:function(t,e){var n=Array.isArray(t)?t:t.split(/\r?\n/g),r=e.loc.start,i=e.loc.end,s=[];s.push(n[r.line-1].slice(r.column));for(var a=r.line;a<i.line-1;a++)s.push(n[a]);return s.push(n[i.line-1].slice(0,i.column)),s.join("\n")}},{key:"allPropertiesOf",value:function(t){var e=[];do e.push.apply(e,Object.getOwnPropertyNames(t));while(t=Object.getPrototypeOf(t));return e}}]),n}(u);Object.assign(g,u),e.exports=g},{"../index":26,"./input":22,"./texture":23,"./utils-core":24}],26:[function(t,e,n){var r=t("./core/gpu"),i=t("./core/alias"),s=t("./core/utils"),a=t("./core/input"),o=t("./core/texture"),u=t("./backend/cpu/function-builder"),h=t("./backend/cpu/function-node"),l=t("./backend/cpu/kernel"),p=t("./backend/cpu/runner"),c=t("./backend/web-gl/function-builder"),f=t("./backend/web-gl/function-node"),d=t("./backend/web-gl/kernel"),m=t("./backend/web-gl/runner");r.alias=i,r.utils=s,r.Texture=o,r.Input=a,r.input=function(t,e){return new a(t,e)},r.CPUFunctionBuilder=u,r.CPUFunctionNode=h,r.CPUKernel=l,r.CPURunner=p,r.WebGLFunctionBuilder=c,r.WebGLFunctionNode=f,r.WebGLKernel=d,r.WebGLRunner=m,"undefined"!=typeof e&&(e.exports=r),"undefined"!=typeof window&&(window.GPU=r)},{"./backend/cpu/function-builder":1,"./backend/cpu/function-node":2,"./backend/cpu/kernel":4,"./backend/cpu/runner":5,"./backend/web-gl/function-builder":11,"./backend/web-gl/function-node":12,"./backend/web-gl/kernel":14,"./backend/web-gl/runner":15,"./core/alias":19,"./core/gpu":21,"./core/input":22,"./core/texture":23,"./core/utils":25}],27:[function(t,e,n){!function(t,r){"object"==typeof n&&"undefined"!=typeof e?r(n):"function"==typeof define&&define.amd?define(["exports"],r):r(t.acorn=t.acorn||{})}(this,function(t){function e(t,e){for(var n=65536,r=0;r<e.length;r+=2){if(n+=e[r],n>t)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&&T.test(String.fromCharCode(t)):n!==!1&&e(t,A)))}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&&w.test(String.fromCharCode(t)):n!==!1&&(e(t,A)||e(t,O)))))}function i(t,e){return new N(t,{beforeExpr:!0,binop:e})}function s(t,e){return void 0===e&&(e={}),e.keyword=t,F[t]=new N(t,e)}function a(t){return 10===t||13===t||8232===t||8233===t}function o(t,e){return U.call(t,e)}function u(t,e){for(var n=1,r=0;;){I.lastIndex=r;var i=I.exec(t);if(!(i&&i.index<e))return new V(n,e-r);++n,r=i.index+i[0].length}}function h(t){var e={};for(var n in z)e[n]=t&&o(t,n)?t[n]:z[n];if(e.ecmaVersion>=2015&&(e.ecmaVersion-=2009),null==e.allowReserved&&(e.allowReserved=e.ecmaVersion<5),B(e.onToken)){var r=e.onToken;e.onToken=function(t){return r.push(t)}}return B(e.onComment)&&(e.onComment=l(e,e.onComment)),e}function l(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 K(this,a,o)),t.ranges&&(u.range=[i,s]),e.push(u)}}function p(t){return new RegExp("^(?:"+t.replace(/ /g,"|")+")$")}function c(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=-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,e,n,r){try{return new RegExp(t,e)}catch(i){if(void 0!==n)throw i instanceof SyntaxError&&r.raise(n,"Error parsing regular expression: "+i.message),i}}function m(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(1023&t)+56320))}function g(t,e){return new X(e,t).parse()}function y(t,e,n){var r=new X(n,t,e);return r.nextToken(),r.parseExpression()}function v(t,e){return new X(e,t)}function b(e,n,r){t.parse_dammit=e,t.LooseParser=n,t.pluginsLoose=r}var x={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"},k="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",S={
5:k,6:k+" const class extends export import super"},E="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠ-ࢴࢶ-ࢽऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲈᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿕ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞮꞰ-ꞷꟷ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭥꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",_="‌‍·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࣔ-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ଁ-ଃ଼ା-ୄେୈୋ-୍ୖୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఃా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ഁ-ഃാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ංඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ູົຼ່-ໍ໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠐-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭ᳲ-᳴᳸᳹᷀-᷵᷻-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱꤀-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_",T=new RegExp("["+E+"]"),w=new RegExp("["+E+_+"]");E=_=null;var A=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,17,26,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,449,56,264,8,2,36,18,0,50,29,881,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,0,32,6124,20,754,9486,1,3071,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,10591,541],O=[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,838,7,2,7,17,9,57,21,2,13,19882,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],N=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},P={beforeExpr:!0},C={startsExpr:!0},F={},R={num:new N("num",C),regexp:new N("regexp",C),string:new N("string",C),name:new N("name",C),eof:new N("eof"),bracketL:new N("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new N("]"),braceL:new N("{",{beforeExpr:!0,startsExpr:!0}),braceR:new N("}"),parenL:new N("(",{beforeExpr:!0,startsExpr:!0}),parenR:new N(")"),comma:new N(",",P),semi:new N(";",P),colon:new N(":",P),dot:new N("."),question:new N("?",P),arrow:new N("=>",P),template:new N("template"),invalidTemplate:new N("invalidTemplate"),ellipsis:new N("...",P),backQuote:new N("`",C),dollarBraceL:new N("${",{beforeExpr:!0,startsExpr:!0}),eq:new N("=",{beforeExpr:!0,isAssign:!0}),assign:new N("_=",{beforeExpr:!0,isAssign:!0}),incDec:new N("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new N("!/~",{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 N("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:i("%",10),star:i("*",10),slash:i("/",10),starstar:new N("**",{beforeExpr:!0}),_break:s("break"),_case:s("case",P),_catch:s("catch"),_continue:s("continue"),_debugger:s("debugger"),_default:s("default",P),_do:s("do",{isLoop:!0,beforeExpr:!0}),_else:s("else",P),_finally:s("finally"),_for:s("for",{isLoop:!0}),_function:s("function",C),_if:s("if"),_return:s("return",P),_switch:s("switch"),_throw:s("throw",P),_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",C),_super:s("super",C),_class:s("class",C),_extends:s("extends",P),_export:s("export"),_import:s("import"),_null:s("null",C),_true:s("true",C),_false:s("false",C),_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})},L=/\r\n?|\n|\u2028|\u2029/,I=new RegExp(L.source,"g"),D=/[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/,G=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,M=Object.prototype,U=M.hasOwnProperty,j=M.toString,B=Array.isArray||function(t){return"[object Array]"===j.call(t)},V=function(t,e){this.line=t,this.column=e};V.prototype.offset=function(t){return new V(this.line,this.column+t)};var K=function(t,e,n){this.start=e,this.end=n,null!==t.sourceFile&&(this.source=t.sourceFile)},z={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:{}},W={},X=function(t,e,n){this.options=t=h(t),this.sourceFile=t.sourceFile,this.keywords=p(S[t.ecmaVersion>=6?6:5]);var r="";if(!t.allowReserved){for(var i=t.ecmaVersion;!(r=x[i]);i--);"module"==t.sourceType&&(r+=" await")}this.reservedWords=p(r);var s=(r?r+" ":"")+x.strict;this.reservedWordsStrict=p(s),this.reservedWordsStrictBind=p(s+" "+x.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(L).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=R.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()};X.prototype.isKeyword=function(t){return this.keywords.test(t)},X.prototype.isReservedWord=function(t){return this.reservedWords.test(t)},X.prototype.extend=function(t,e){this[t]=e(this[t])},X.prototype.loadPlugins=function(t){var e=this;for(var n in t){var r=W[n];if(!r)throw new Error("Plugin '"+n+"' not found");r(e,t[n])}},X.prototype.parse=function(){var t=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(t)};var q=X.prototype,Y=/^(?:'((?:\\.|[^'])*?)'|"((?:\\.|[^"])*?)"|;)/;q.strictDirective=function(t){for(var e=this;;){G.lastIndex=t,t+=G.exec(e.input)[0].length;var n=Y.exec(e.input.slice(t));if(!n)return!1;if("use strict"==(n[1]||n[2]))return!0;t+=n[0].length}},q.eat=function(t){return this.type===t&&(this.next(),!0)},q.isContextual=function(t){return this.type===R.name&&this.value===t},q.eatContextual=function(t){return this.value===t&&this.eat(R.name)},q.expectContextual=function(t){this.eatContextual(t)||this.unexpected()},q.canInsertSemicolon=function(){return this.type===R.eof||this.type===R.braceR||L.test(this.input.slice(this.lastTokEnd,this.start))},q.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},q.semicolon=function(){this.eat(R.semi)||this.insertSemicolon()||this.unexpected()},q.afterTrailingComma=function(t,e){if(this.type==t)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),e||this.next(),!0},q.expect=function(t){this.eat(t)||this.unexpected()},q.unexpected=function(t){this.raise(null!=t?t:this.start,"Unexpected token")},q.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")}},q.checkExpressionErrors=function(t,e){var n=t?t.shorthandAssign:-1;return e?void(n>-1&&this.raise(n,"Shorthand property assignments are valid only in destructuring patterns")):n>=0},q.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,"Yield expression cannot be a default value"),this.awaitPos&&this.raise(this.awaitPos,"Await expression cannot be a default value")},q.isSimpleAssignTarget=function(t){return"ParenthesizedExpression"===t.type?this.isSimpleAssignTarget(t.expression):"Identifier"===t.type||"MemberExpression"===t.type};var J=X.prototype;J.parseTopLevel=function(t){var e=this,n={};for(t.body||(t.body=[]);this.type!==R.eof;){var r=e.parseStatement(!0,!0,n);t.body.push(r)}return this.adaptDirectivePrologue(t.body),this.next(),this.options.ecmaVersion>=6&&(t.sourceType=this.options.sourceType),this.finishNode(t,"Program")};var H={kind:"loop"},Z={kind:"switch"};J.isLet=function(){if(this.type!==R.name||this.options.ecmaVersion<6||"let"!=this.value)return!1;G.lastIndex=this.pos;var t=G.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(!this.isKeyword(a))return!0}return!1},J.isAsyncFunction=function(){if(this.type!==R.name||this.options.ecmaVersion<8||"async"!=this.value)return!1;G.lastIndex=this.pos;var t=G.exec(this.input),e=this.pos+t[0].length;return!(L.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)))},J.parseStatement=function(t,e,n){var r,i=this.type,s=this.startNode();switch(this.isLet()&&(i=R._var,r="let"),i){case R._break:case R._continue:return this.parseBreakContinueStatement(s,i.keyword);case R._debugger:return this.parseDebuggerStatement(s);case R._do:return this.parseDoStatement(s);case R._for:return this.parseForStatement(s);case R._function:return!t&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(s,!1);case R._class:return t||this.unexpected(),this.parseClass(s,!0);case R._if:return this.parseIfStatement(s);case R._return:return this.parseReturnStatement(s);case R._switch:return this.parseSwitchStatement(s);case R._throw:return this.parseThrowStatement(s);case R._try:return this.parseTryStatement(s);case R._const:case R._var:return r=r||this.value,t||"var"==r||this.unexpected(),this.parseVarStatement(s,r);case R._while:return this.parseWhileStatement(s);case R._with:return this.parseWithStatement(s);case R.braceL:return this.parseBlock();case R.semi:return this.parseEmptyStatement(s);case R._export:case R._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===R._import?this.parseImport(s):this.parseExport(s,n);default:if(this.isAsyncFunction()&&t)return this.next(),this.parseFunctionStatement(s,!0);var a=this.value,o=this.parseExpression();return i===R.name&&"Identifier"===o.type&&this.eat(R.colon)?this.parseLabeledStatement(s,a,o):this.parseExpressionStatement(s,o)}},J.parseBreakContinueStatement=function(t,e){var n=this,r="break"==e;this.next(),this.eat(R.semi)||this.insertSemicolon()?t.label=null:this.type!==R.name?this.unexpected():(t.label=this.parseIdent(),this.semicolon());for(var i=0;i<this.labels.length;++i){var s=n.labels[i];if(null==t.label||s.name===t.label.name){if(null!=s.kind&&(r||"loop"===s.kind))break;if(t.label&&r)break}}return i===this.labels.length&&this.raise(t.start,"Unsyntactic "+e),this.finishNode(t,r?"BreakStatement":"ContinueStatement")},J.parseDebuggerStatement=function(t){return this.next(),this.semicolon(),this.finishNode(t,"DebuggerStatement")},J.parseDoStatement=function(t){return this.next(),this.labels.push(H),t.body=this.parseStatement(!1),this.labels.pop(),this.expect(R._while),t.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(R.semi):this.semicolon(),this.finishNode(t,"DoWhileStatement")},J.parseForStatement=function(t){if(this.next(),this.labels.push(H),this.enterLexicalScope(),this.expect(R.parenL),this.type===R.semi)return this.parseFor(t,null);var e=this.isLet();if(this.type===R._var||this.type===R._const||e){var n=this.startNode(),r=e?"let":this.value;return this.next(),this.parseVar(n,!0,r),this.finishNode(n,"VariableDeclaration"),!(this.type===R._in||this.options.ecmaVersion>=6&&this.isContextual("of"))||1!==n.declarations.length||"var"!==r&&n.declarations[0].init?this.parseFor(t,n):this.parseForIn(t,n)}var i=new c,s=this.parseExpression(!0,i);return this.type===R._in||this.options.ecmaVersion>=6&&this.isContextual("of")?(this.toAssignable(s),this.checkLVal(s),this.checkPatternErrors(i,!0),this.parseForIn(t,s)):(this.checkExpressionErrors(i,!0),this.parseFor(t,s))},J.parseFunctionStatement=function(t,e){return this.next(),this.parseFunction(t,!0,!1,e)},J.isFunction=function(){return this.type===R._function||this.isAsyncFunction()},J.parseIfStatement=function(t){return this.next(),t.test=this.parseParenExpression(),t.consequent=this.parseStatement(!this.strict&&this.isFunction()),t.alternate=this.eat(R._else)?this.parseStatement(!this.strict&&this.isFunction()):null,this.finishNode(t,"IfStatement")},J.parseReturnStatement=function(t){return this.inFunction||this.options.allowReturnOutsideFunction||this.raise(this.start,"'return' outside of function"),this.next(),this.eat(R.semi)||this.insertSemicolon()?t.argument=null:(t.argument=this.parseExpression(),this.semicolon()),this.finishNode(t,"ReturnStatement")},J.parseSwitchStatement=function(t){var e=this;this.next(),t.discriminant=this.parseParenExpression(),t.cases=[],this.expect(R.braceL),this.labels.push(Z),this.enterLexicalScope();for(var n,r=!1;this.type!=R.braceR;)if(e.type===R._case||e.type===R._default){var i=e.type===R._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(R.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")},J.parseThrowStatement=function(t){return this.next(),L.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 $=[];J.parseTryStatement=function(t){if(this.next(),t.block=this.parseBlock(),t.handler=null,this.type===R._catch){var e=this.startNode();this.next(),this.expect(R.parenL),e.param=this.parseBindingAtom(),this.enterLexicalScope(),this.checkLVal(e.param,"let"),this.expect(R.parenR),e.body=this.parseBlock(!1),this.exitLexicalScope(),t.handler=this.finishNode(e,"CatchClause")}return t.finalizer=this.eat(R._finally)?this.parseBlock():null,t.handler||t.finalizer||this.raise(t.start,"Missing catch or finally clause"),this.finishNode(t,"TryStatement")},J.parseVarStatement=function(t,e){return this.next(),this.parseVar(t,!1,e),this.semicolon(),this.finishNode(t,"VariableDeclaration")},J.parseWhileStatement=function(t){return this.next(),t.test=this.parseParenExpression(),this.labels.push(H),t.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(t,"WhileStatement")},J.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")},J.parseEmptyStatement=function(t){return this.next(),this.finishNode(t,"EmptyStatement")},J.parseLabeledStatement=function(t,e,n){for(var r=this,i=0,s=r.labels;i<s.length;i+=1){var a=s[i];a.name===e&&r.raise(n.start,"Label '"+e+"' is already declared")}for(var o=this.type.isLoop?"loop":this.type===R._switch?"switch":null,u=this.labels.length-1;u>=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")},J.parseExpressionStatement=function(t,e){return t.expression=e,this.semicolon(),this.finishNode(t,"ExpressionStatement")},J.parseBlock=function(t){var e=this;void 0===t&&(t=!0);var n=this.startNode();for(n.body=[],this.expect(R.braceL),t&&this.enterLexicalScope();!this.eat(R.braceR);){var r=e.parseStatement(!0);n.body.push(r)}return t&&this.exitLexicalScope(),this.finishNode(n,"BlockStatement")},J.parseFor=function(t,e){return t.init=e,this.expect(R.semi),t.test=this.type===R.semi?null:this.parseExpression(),this.expect(R.semi),t.update=this.type===R.parenR?null:this.parseExpression(),this.expect(R.parenR),this.exitLexicalScope(),t.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(t,"ForStatement")},J.parseForIn=function(t,e){var n=this.type===R._in?"ForInStatement":"ForOfStatement";return this.next(),t.left=e,t.right=this.parseExpression(),this.expect(R.parenR),this.exitLexicalScope(),t.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(t,n)},J.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(R.eq)?i.init=r.parseMaybeAssign(e):"const"!==n||r.type===R._in||r.options.ecmaVersion>=6&&r.isContextual("of")?"Identifier"==i.id.type||e&&(r.type===R._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(R.comma))break}return t},J.parseVarId=function(t,e){t.id=this.parseBindingAtom(e),this.checkLVal(t.id,e,!1)},J.parseFunction=function(t,e,n,r){this.initFunction(t),this.options.ecmaVersion>=6&&!r&&(t.generator=this.eat(R.star)),this.options.ecmaVersion>=8&&(t.async=!!r),e&&(t.id="nullableID"===e&&this.type!=R.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==R.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")},J.parseFunctionParams=function(t){this.expect(R.parenL),t.params=this.parseBindingList(R.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},J.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(R.braceL);!this.eat(R.braceR);)if(!n.eat(R.semi)){var s=n.startNode(),a=n.eat(R.star),o=!1,u=n.type===R.name&&"static"===n.value;n.parsePropertyName(s),s["static"]=u&&n.type!==R.parenL,s["static"]&&(a&&n.unexpected(),a=n.eat(R.star),n.parsePropertyName(s)),n.options.ecmaVersion>=8&&!a&&!s.computed&&"Identifier"===s.key.type&&"async"===s.key.name&&n.type!==R.parenL&&!n.canInsertSemicolon()&&(o=!0,n.parsePropertyName(s)),s.kind="method";var h=!1;if(!s.computed){var l=s.key;a||o||"Identifier"!==l.type||n.type===R.parenL||"get"!==l.name&&"set"!==l.name||(h=!0,s.kind=l.name,l=n.parsePropertyName(s)),!s["static"]&&("Identifier"===l.type&&"constructor"===l.name||"Literal"===l.type&&"constructor"===l.value)&&(i&&n.raise(l.start,"Duplicate constructor in the same class"),h&&n.raise(l.start,"Constructor can't have get/set modifier"),a&&n.raise(l.start,"Constructor can't be a generator"),o&&n.raise(l.start,"Constructor can't be an async method"),s.kind="constructor",i=!0)}if(n.parseClassMethod(r,s,a,o),h){var p="get"===s.kind?0:1;if(s.value.params.length!==p){var c=s.value.start;"get"===s.kind?n.raiseRecoverable(c,"getter should have no params"):n.raiseRecoverable(c,"setter should have exactly one param")}else"set"===s.kind&&"RestElement"===s.value.params[0].type&&n.raiseRecoverable(s.value.params[0].start,"Setter cannot use rest params")}}return t.body=this.finishNode(r,"ClassBody"),this.finishNode(t,e?"ClassDeclaration":"ClassExpression")},J.parseClassMethod=function(t,e,n,r){e.value=this.parseMethod(n,r),t.body.push(this.finishNode(e,"MethodDefinition"))},J.parseClassId=function(t,e){t.id=this.type===R.name?this.parseIdent():e===!0?this.unexpected():null},J.parseClassSuper=function(t){t.superClass=this.eat(R._extends)?this.parseExprSubscripts():null},J.parseExport=function(t,e){var n=this;if(this.next(),this.eat(R.star))return this.expectContextual("from"),t.source=this.type===R.string?this.parseExprAtom():this.unexpected(),this.semicolon(),this.finishNode(t,"ExportAllDeclaration");if(this.eat(R._default)){this.checkExport(e,"default",this.lastTokStart);var r;if(this.type===R._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===R._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"))t.source=this.type===R.string?this.parseExprAtom():this.unexpected();else{for(var a=0,o=t.specifiers;a<o.length;a+=1){var u=o[a];n.checkUnreserved(u.local)}t.source=null}this.semicolon()}return this.finishNode(t,"ExportNamedDeclaration")},J.checkExport=function(t,e,n){t&&(o(t,e)&&this.raiseRecoverable(n,"Duplicate export '"+e+"'"),t[e]=!0)},J.checkPatternExport=function(t,e){var n=this,r=e.type;if("Identifier"==r)this.checkExport(t,e.name,e.start);else if("ObjectPattern"==r)for(var i=0,s=e.properties;i<s.length;i+=1){var a=s[i];n.checkPatternExport(t,a.value)}else if("ArrayPattern"==r)for(var o=0,u=e.elements;o<u.length;o+=1){var h=u[o];h&&n.checkPatternExport(t,h)}else"AssignmentPattern"==r?this.checkPatternExport(t,e.left):"ParenthesizedExpression"==r&&this.checkPatternExport(t,e.expression)},J.checkVariableExport=function(t,e){var n=this;if(t)for(var r=0,i=e;r<i.length;r+=1){var s=i[r];n.checkPatternExport(t,s.id)}},J.shouldParseExportStatement=function(){return"var"===this.type.keyword||"const"===this.type.keyword||"class"===this.type.keyword||"function"===this.type.keyword||this.isLet()||this.isAsyncFunction()},J.parseExportSpecifiers=function(t){var e=this,n=[],r=!0;for(this.expect(R.braceL);!this.eat(R.braceR);){if(r)r=!1;else if(e.expect(R.comma),e.afterTrailingComma(R.braceR))break;var i=e.startNode();i.local=e.parseIdent(!0),i.exported=e.eatContextual("as")?e.parseIdent(!0):i.local,e.checkExport(t,i.exported.name,i.exported.start),n.push(e.finishNode(i,"ExportSpecifier"))}return n},J.parseImport=function(t){return this.next(),this.type===R.string?(t.specifiers=$,t.source=this.parseExprAtom()):(t.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),t.source=this.type===R.string?this.parseExprAtom():this.unexpected()),this.semicolon(),this.finishNode(t,"ImportDeclaration")},J.parseImportSpecifiers=function(){var t=this,e=[],n=!0;if(this.type===R.name){var r=this.startNode();if(r.local=this.parseIdent(),this.checkLVal(r.local,"let"),e.push(this.finishNode(r,"ImportDefaultSpecifier")),!this.eat(R.comma))return e}if(this.type===R.star){var i=this.startNode();return this.next(),this.expectContextual("as"),i.local=this.parseIdent(),this.checkLVal(i.local,"let"),e.push(this.finishNode(i,"ImportNamespaceSpecifier")),e}for(this.expect(R.braceL);!this.eat(R.braceR);){if(n)n=!1;else if(t.expect(R.comma),t.afterTrailingComma(R.braceR))break;var s=t.startNode();s.imported=t.parseIdent(!0),t.eatContextual("as")?s.local=t.parseIdent():(t.checkUnreserved(s.imported),s.local=s.imported),t.checkLVal(s.local,"let"),e.push(t.finishNode(s,"ImportSpecifier"))}return e},J.adaptDirectivePrologue=function(t){for(var e=0;e<t.length&&this.isDirectiveCandidate(t[e]);++e)t[e].directive=t[e].expression.raw.slice(1,-1)},J.isDirectiveCandidate=function(t){return"ExpressionStatement"===t.type&&"Literal"===t.expression.type&&"string"==typeof t.expression.value&&('"'===this.input[t.start]||"'"===this.input[t.start])};var Q=X.prototype;Q.toAssignable=function(t,e){var n=this;if(this.options.ecmaVersion>=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":break;case"ObjectExpression":t.type="ObjectPattern";for(var r=0,i=t.properties;r<i.length;r+=1){var s=i[r];"init"!==s.kind&&n.raise(s.key.start,"Object pattern can't contain getter or setter"),n.toAssignable(s.value,e)}break;case"ArrayExpression":t.type="ArrayPattern",this.toAssignableList(t.elements,e);break;case"AssignmentExpression":if("="!==t.operator){this.raise(t.left.end,"Only '=' operator can be used for specifying default value.");break}t.type="AssignmentPattern",delete t.operator,this.toAssignable(t.left,e);case"AssignmentPattern":break;case"ParenthesizedExpression":this.toAssignable(t.expression,e);break;case"MemberExpression":if(!e)break;default:this.raise(t.start,"Assigning to rvalue")}return t},Q.toAssignableList=function(t,e){var n=this,r=t.length;if(r){var i=t[r-1];if(i&&"RestElement"==i.type)--r;else if(i&&"SpreadElement"==i.type){i.type="RestElement";var s=i.argument;this.toAssignable(s,e),--r}6===this.options.ecmaVersion&&e&&i&&"RestElement"===i.type&&"Identifier"!==i.argument.type&&this.unexpected(i.argument.start)}for(var a=0;a<r;a++){var o=t[a];o&&n.toAssignable(o,e)}return t},Q.parseSpread=function(t){var e=this.startNode();return this.next(),e.argument=this.parseMaybeAssign(!1,t),this.finishNode(e,"SpreadElement")},Q.parseRestBinding=function(){var t=this.startNode();return this.next(),6===this.options.ecmaVersion&&this.type!==R.name&&this.unexpected(),t.argument=this.parseBindingAtom(),this.finishNode(t,"RestElement")},Q.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case R.bracketL:var t=this.startNode();return this.next(),t.elements=this.parseBindingList(R.bracketR,!0,!0),this.finishNode(t,"ArrayPattern");case R.braceL:return this.parseObj(!0)}return this.parseIdent()},Q.parseBindingList=function(t,e,n){for(var r=this,i=[],s=!0;!this.eat(t);)if(s?s=!1:r.expect(R.comma),e&&r.type===R.comma)i.push(null);else{if(n&&r.afterTrailingComma(t))break;if(r.type===R.ellipsis){var a=r.parseRestBinding();r.parseBindingListItem(a),i.push(a),r.type===R.comma&&r.raise(r.start,"Comma is not permitted after the rest element"),r.expect(t);break}var o=r.parseMaybeDefault(r.start,r.startLoc);r.parseBindingListItem(o),i.push(o)}return i},Q.parseBindingListItem=function(t){return t},Q.parseMaybeDefault=function(t,e,n){if(n=n||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(R.eq))return n;var r=this.startNodeAt(t,e);return r.left=n,r.right=this.parseMaybeAssign(),this.finishNode(r,"AssignmentPattern")},Q.checkLVal=function(t,e,n){var r=this;switch(t.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(t.name)&&this.raiseRecoverable(t.start,(e?"Binding ":"Assigning to ")+t.name+" in strict mode"),n&&(o(n,t.name)&&this.raiseRecoverable(t.start,"Argument name clash"),n[t.name]=!0),e&&"none"!==e&&(("var"===e&&!this.canDeclareVarName(t.name)||"var"!==e&&!this.canDeclareLexicalName(t.name))&&this.raiseRecoverable(t.start,"Identifier '"+t.name+"' has already been declared"),"var"===e?this.declareVarName(t.name):this.declareLexicalName(t.name));break;case"MemberExpression":e&&this.raiseRecoverable(t.start,(e?"Binding":"Assigning to")+" member expression");break;case"ObjectPattern":for(var i=0,s=t.properties;i<s.length;i+=1){var a=s[i];r.checkLVal(a.value,e,n)}break;case"ArrayPattern":for(var u=0,h=t.elements;u<h.length;u+=1){var l=h[u];l&&r.checkLVal(l,e,n)}break;case"AssignmentPattern":this.checkLVal(t.left,e,n);break;case"RestElement":this.checkLVal(t.argument,e,n);break;case"ParenthesizedExpression":this.checkLVal(t.expression,e,n);break;default:this.raise(t.start,(e?"Binding":"Assigning to")+" rvalue")}};var tt=X.prototype;tt.checkPropClash=function(t,e){if(!(this.options.ecmaVersion>=6&&(t.computed||t.method||t.shorthand))){var n,r=t.key;switch(r.type){case"Identifier":n=r.name;break;case"Literal":n=String(r.value);break;default:return}var i=t.kind;if(this.options.ecmaVersion>=6)return void("__proto__"===n&&"init"===i&&(e.proto&&this.raiseRecoverable(r.start,"Redefinition of __proto__ property"),e.proto=!0));n="$"+n;var s=e[n];if(s){var a;a="init"===i?this.strict&&s.init||s.get||s.set:s.init||s[i],a&&this.raiseRecoverable(r.start,"Redefinition of property")}else s=e[n]={init:!1,get:!1,set:!1};s[i]=!0}},tt.parseExpression=function(t,e){var n=this,r=this.start,i=this.startLoc,s=this.parseMaybeAssign(t,e);if(this.type===R.comma){var a=this.startNodeAt(r,i);for(a.expressions=[s];this.eat(R.comma);)a.expressions.push(n.parseMaybeAssign(t,e));return this.finishNode(a,"SequenceExpression")}return s},tt.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!=R.parenL&&this.type!=R.name||(this.potentialArrowAt=this.start);var u=this.parseMaybeConditional(t,e);if(n&&(u=n.call(this,u,a,o)),this.type.isAssign){this.checkPatternErrors(e,!0),r||c.call(e);var h=this.startNodeAt(a,o);return h.operator=this.value,h.left=this.type===R.eq?this.toAssignable(u):u,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},tt.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(R.question)){var s=this.startNodeAt(n,r);return s.test=i,s.consequent=this.parseMaybeAssign(),this.expect(R.colon),s.alternate=this.parseMaybeAssign(t),this.finishNode(s,"ConditionalExpression")}return i},tt.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)},tt.parseExprOp=function(t,e,n,r,i){var s=this.type.binop;if(null!=s&&(!i||this.type!==R._in)&&s>r){var a=this.type===R.logicalOR||this.type===R.logicalAND,o=this.value;this.next();var u=this.start,h=this.startLoc,l=this.parseExprOp(this.parseMaybeUnary(null,!1),u,h,s,i),p=this.buildBinary(e,n,t,l,o,a);return this.parseExprOp(p,e,n,r,i)}return t},tt.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")},tt.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===R.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(R.starstar)?this.buildBinary(i,s,n,this.parseMaybeUnary(null,!1),"**",!1):n},tt.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},tt.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(),a=void 0;;)if((a=i.eat(R.bracketL))||i.eat(R.dot)){var o=i.startNodeAt(e,n);o.object=t,o.property=a?i.parseExpression():i.parseIdent(!0),o.computed=!!a,a&&i.expect(R.bracketR),t=i.finishNode(o,"MemberExpression")}else if(!r&&i.eat(R.parenL)){var u=new c,h=i.yieldPos,l=i.awaitPos;i.yieldPos=0,i.awaitPos=0;var p=i.parseExprList(R.parenR,i.options.ecmaVersion>=8,!1,u);if(s&&!i.canInsertSemicolon()&&i.eat(R.arrow))return i.checkPatternErrors(u,!1),i.checkYieldAwaitInDefaultParams(),i.yieldPos=h,i.awaitPos=l,i.parseArrowExpression(i.startNodeAt(e,n),p,!0);i.checkExpressionErrors(u,!0),i.yieldPos=h||i.yieldPos,i.awaitPos=l||i.awaitPos;var f=i.startNodeAt(e,n);f.callee=t,f.arguments=p,t=i.finishNode(f,"CallExpression")}else{if(i.type!==R.backQuote)return t;var d=i.startNodeAt(e,n);d.tag=t,d.quasi=i.parseTemplate({isTagged:!0}),t=i.finishNode(d,"TaggedTemplateExpression")}},tt.parseExprAtom=function(t){var e,n=this.potentialArrowAt==this.start;switch(this.type){case R._super:return this.inFunction||this.raise(this.start,"'super' outside of function or class"),e=this.startNode(),this.next(),this.type!==R.dot&&this.type!==R.bracketL&&this.type!==R.parenL&&this.unexpected(),this.finishNode(e,"Super");case R._this:return e=this.startNode(),this.next(),this.finishNode(e,"ThisExpression");case R.name:var r=this.start,i=this.startLoc,s=this.parseIdent(this.type!==R.name);if(this.options.ecmaVersion>=8&&"async"===s.name&&!this.canInsertSemicolon()&&this.eat(R._function))return this.parseFunction(this.startNodeAt(r,i),!1,!1,!0);if(n&&!this.canInsertSemicolon()){if(this.eat(R.arrow))return this.parseArrowExpression(this.startNodeAt(r,i),[s],!1);if(this.options.ecmaVersion>=8&&"async"===s.name&&this.type===R.name)return s=this.parseIdent(),!this.canInsertSemicolon()&&this.eat(R.arrow)||this.unexpected(),this.parseArrowExpression(this.startNodeAt(r,i),[s],!0)}return s;case R.regexp:var a=this.value;return e=this.parseLiteral(a.value),e.regex={pattern:a.pattern,flags:a.flags},e;case R.num:case R.string:return this.parseLiteral(this.value);case R._null:case R._true:case R._false:return e=this.startNode(),e.value=this.type===R._null?null:this.type===R._true,e.raw=this.type.keyword,this.next(),this.finishNode(e,"Literal");case R.parenL:var o=this.start,u=this.parseParenAndDistinguishExpression(n);return t&&(t.parenthesizedAssign<0&&!this.isSimpleAssignTarget(u)&&(t.parenthesizedAssign=o),t.parenthesizedBind<0&&(t.parenthesizedBind=o)),u;case R.bracketL:return e=this.startNode(),this.next(),e.elements=this.parseExprList(R.bracketR,!0,!0,t),this.finishNode(e,"ArrayExpression");case R.braceL:return this.parseObj(!1,t);case R._function:return e=this.startNode(),this.next(),this.parseFunction(e,!1);case R._class:return this.parseClass(this.startNode(),!1);case R._new:return this.parseNew();case R.backQuote:return this.parseTemplate();default:this.unexpected()}},tt.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")},tt.parseParenExpression=function(){this.expect(R.parenL);var t=this.parseExpression();return this.expect(R.parenR),t},tt.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,u=this.start,h=this.startLoc,l=[],p=!0,f=!1,d=new c,m=this.yieldPos,g=this.awaitPos;for(this.yieldPos=0,this.awaitPos=0;this.type!==R.parenR;){if(p?p=!1:n.expect(R.comma),s&&n.afterTrailingComma(R.parenR,!0)){f=!0;break}if(n.type===R.ellipsis){a=n.start,l.push(n.parseParenItem(n.parseRestBinding())),n.type===R.comma&&n.raise(n.start,"Comma is not permitted after the rest element");break}n.type!==R.parenL||o||(o=n.start),l.push(n.parseMaybeAssign(!1,d,n.parseParenItem))}var y=this.start,v=this.startLoc;if(this.expect(R.parenR),t&&!this.canInsertSemicolon()&&this.eat(R.arrow))return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),o&&this.unexpected(o),this.yieldPos=m,this.awaitPos=g,this.parseParenArrowList(r,i,l);l.length&&!f||this.unexpected(this.lastTokStart),a&&this.unexpected(a),this.checkExpressionErrors(d,!0),this.yieldPos=m||this.yieldPos,this.awaitPos=g||this.awaitPos,l.length>1?(e=this.startNodeAt(u,h),e.expressions=l,this.finishNodeAt(e,"SequenceExpression",y,v)):e=l[0]}else e=this.parseParenExpression();if(this.options.preserveParens){var b=this.startNodeAt(r,i);return b.expression=e,this.finishNode(b,"ParenthesizedExpression")}return e},tt.parseParenItem=function(t){return t},tt.parseParenArrowList=function(t,e,n){return this.parseArrowExpression(this.startNodeAt(t,e),n)};var et=[];tt.parseNew=function(){var t=this.startNode(),e=this.parseIdent(!0);if(this.options.ecmaVersion>=6&&this.eat(R.dot))return t.meta=e,t.property=this.parseIdent(!0),"target"!==t.property.name&&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 n=this.start,r=this.startLoc;return t.callee=this.parseSubscripts(this.parseExprAtom(),n,r,!0),this.eat(R.parenL)?t.arguments=this.parseExprList(R.parenR,this.options.ecmaVersion>=8,!1):t.arguments=et,this.finishNode(t,"NewExpression")},tt.parseTemplateElement=function(t){var e=t.isTagged,n=this.startNode();return this.type===R.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===R.backQuote,this.finishNode(n,"TemplateElement")},tt.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(R.dollarBraceL),r.expressions.push(e.parseExpression()),e.expect(R.braceR),r.quasis.push(i=e.parseTemplateElement({isTagged:n}));return this.next(),this.finishNode(r,"TemplateLiteral")},tt.isAsyncProp=function(t){return!t.computed&&"Identifier"===t.key.type&&"async"===t.key.name&&(this.type===R.name||this.type===R.num||this.type===R.string||this.type===R.bracketL||this.type.keyword)&&!L.test(this.input.slice(this.lastTokEnd,this.start))},tt.parseObj=function(t,e){var n=this,r=this.startNode(),i=!0,s={};for(r.properties=[],this.next();!this.eat(R.braceR);){if(i)i=!1;else if(n.expect(R.comma),n.afterTrailingComma(R.braceR))break;var a=n.parseProperty(t,e);n.checkPropClash(a,s),r.properties.push(a)}return this.finishNode(r,t?"ObjectPattern":"ObjectExpression")},tt.parseProperty=function(t,e){var n,r,i,s,a=this.startNode();return this.options.ecmaVersion>=6&&(a.method=!1,a.shorthand=!1,(t||e)&&(i=this.start,s=this.startLoc),t||(n=this.eat(R.star))),this.parsePropertyName(a),!t&&this.options.ecmaVersion>=8&&!n&&this.isAsyncProp(a)?(r=!0,this.parsePropertyName(a,e)):r=!1,this.parsePropertyValue(a,t,n,r,i,s,e),this.finishNode(a,"Property")},tt.parsePropertyValue=function(t,e,n,r,i,s,a){if((n||r)&&this.type===R.colon&&this.unexpected(),this.eat(R.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===R.parenL)e&&this.unexpected(),t.kind="init",t.method=!0,t.value=this.parseMethod(n,r);else if(e||!(this.options.ecmaVersion>=5)||t.computed||"Identifier"!==t.key.type||"get"!==t.key.name&&"set"!==t.key.name||this.type==R.comma||this.type==R.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===R.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 o="get"===t.kind?0:1;if(t.value.params.length!==o){var u=t.value.start;"get"===t.kind?this.raiseRecoverable(u,"getter should have no params"):this.raiseRecoverable(u,"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")}},tt.parsePropertyName=function(t){if(this.options.ecmaVersion>=6){if(this.eat(R.bracketL))return t.computed=!0,t.key=this.parseMaybeAssign(),this.expect(R.bracketR),t.key;t.computed=!1}return t.key=this.type===R.num||this.type===R.string?this.parseExprAtom():this.parseIdent(!0)},tt.initFunction=function(t){t.id=null,this.options.ecmaVersion>=6&&(t.generator=!1,t.expression=!1),this.options.ecmaVersion>=8&&(t.async=!1)},tt.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(R.parenL),n.params=this.parseBindingList(R.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")},tt.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")},tt.parseFunctionBody=function(t,e){var n=e&&this.type!==R.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},tt.isSimpleParamList=function(t){for(var e=0,n=t;e<n.length;e+=1){var r=n[e];if("Identifier"!==r.type)return!1}return!0},tt.checkParams=function(t,e){for(var n=this,r={},i=0,s=t.params;i<s.length;i+=1){var a=s[i];n.checkLVal(a,"var",e?null:r)}},tt.parseExprList=function(t,e,n,r){for(var i=this,s=[],a=!0;!this.eat(t);){if(a)a=!1;else if(i.expect(R.comma),e&&i.afterTrailingComma(t))break;var o=void 0;n&&i.type===R.comma?o=null:i.type===R.ellipsis?(o=i.parseSpread(r),r&&i.type===R.comma&&r.trailingComma<0&&(r.trailingComma=i.start)):o=i.parseMaybeAssign(!1,r),s.push(o)}return s},tt.checkUnreserved=function(t){var e=t.start,n=t.end,r=t.name;if(this.inGenerator&&"yield"===r&&this.raiseRecoverable(e,"Can not use 'yield' as identifier inside a generator"),this.inAsync&&"await"===r&&this.raiseRecoverable(e,"Can not use 'await' as identifier inside an async function"),this.isKeyword(r)&&this.raise(e,"Unexpected keyword '"+r+"'"),!(this.options.ecmaVersion<6&&this.input.slice(e,n).indexOf("\\")!=-1)){var i=this.strict?this.reservedWordsStrict:this.reservedWords;i.test(r)&&this.raiseRecoverable(e,"The keyword '"+r+"' is reserved")}},tt.parseIdent=function(t,e){var n=this.startNode();return t&&"never"==this.options.allowReserved&&(t=!1),this.type===R.name?n.name=this.value:this.type.keyword?(n.name=this.type.keyword,"class"!==n.name&&"function"!==n.name||this.lastTokEnd===this.lastTokStart+1&&46===this.input.charCodeAt(this.lastTokStart)||this.context.pop()):this.unexpected(),this.next(),this.finishNode(n,"Identifier"),t||this.checkUnreserved(n),n},tt.parseYield=function(){this.yieldPos||(this.yieldPos=this.start);var t=this.startNode();return this.next(),this.type==R.semi||this.canInsertSemicolon()||this.type!=R.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(R.star),t.argument=this.parseMaybeAssign()),this.finishNode(t,"YieldExpression")},tt.parseAwait=function(){this.awaitPos||(this.awaitPos=this.start);var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0),this.finishNode(t,"AwaitExpression")};var nt=X.prototype;nt.raise=function(t,e){var n=u(this.input,t);e+=" ("+n.line+":"+n.column+")";var r=new SyntaxError(e);throw r.pos=t,r.loc=n,r.raisedAt=this.pos,r},nt.raiseRecoverable=nt.raise,nt.curPosition=function(){if(this.options.locations)return new V(this.curLine,this.pos-this.lineStart)};var rt=X.prototype,it=Object.assign||function(t){for(var e=[],n=arguments.length-1;n-- >0;)e[n]=arguments[n+1];for(var r=0,i=e;r<i.length;r+=1){var s=i[r];for(var a in s)o(s,a)&&(t[a]=s[a])}return t};rt.enterFunctionScope=function(){this.scopeStack.push({"var":{},lexical:{},childVar:{},parentLexical:{}})},rt.exitFunctionScope=function(){this.scopeStack.pop()},rt.enterLexicalScope=function(){var t=this.scopeStack[this.scopeStack.length-1],e={"var":{},lexical:{},childVar:{},parentLexical:{}};this.scopeStack.push(e),it(e.parentLexical,t.lexical,t.parentLexical)},rt.exitLexicalScope=function(){var t=this.scopeStack.pop(),e=this.scopeStack[this.scopeStack.length-1];it(e.childVar,t["var"],t.childVar)},rt.canDeclareVarName=function(t){var e=this.scopeStack[this.scopeStack.length-1];return!o(e.lexical,t)&&!o(e.parentLexical,t)},rt.canDeclareLexicalName=function(t){var e=this.scopeStack[this.scopeStack.length-1];return!o(e.lexical,t)&&!o(e["var"],t)&&!o(e.childVar,t)},rt.declareVarName=function(t){this.scopeStack[this.scopeStack.length-1]["var"][t]=!0},rt.declareLexicalName=function(t){this.scopeStack[this.scopeStack.length-1].lexical[t]=!0};var st=function(t,e,n){this.type="",this.start=e,this.end=0,t.options.locations&&(this.loc=new K(t,n)),t.options.directSourceFile&&(this.sourceFile=t.options.directSourceFile),t.options.ranges&&(this.range=[e,0])},at=X.prototype;at.startNode=function(){return new st(this,this.start,this.startLoc)},at.startNodeAt=function(t,e){return new st(this,t,e)},at.finishNode=function(t,e){return f.call(this,t,e,this.lastTokEnd,this.lastTokEndLoc)},at.finishNodeAt=function(t,e,n,r){return f.call(this,t,e,n,r)};var ot=function(t,e,n,r,i){this.token=t,this.isExpr=!!e,this.preserveSpace=!!n,this.override=r,this.generator=!!i},ut={b_stat:new ot("{",(!1)),b_expr:new ot("{",(!0)),b_tmpl:new ot("${",(!1)),p_stat:new ot("(",(!1)),p_expr:new ot("(",(!0)),q_tmpl:new ot("`",(!0),(!0),function(t){return t.tryReadTemplateToken()}),f_stat:new ot("function",(!1)),f_expr:new ot("function",(!0)),f_expr_gen:new ot("function",(!0),(!1),null,(!0)),f_gen:new ot("function",(!1),(!1),null,(!0))},ht=X.prototype;ht.initialContext=function(){return[ut.b_stat]},ht.braceIsBlock=function(t){var e=this.curContext();return e===ut.f_expr||e===ut.f_stat||(t!==R.colon||e!==ut.b_stat&&e!==ut.b_expr?t===R._return||t==R.name&&this.exprAllowed?L.test(this.input.slice(this.lastTokEnd,this.start)):t===R._else||t===R.semi||t===R.eof||t===R.parenR||t==R.arrow||(t==R.braceL?e===ut.b_stat:t!=R._var&&t!=R.name&&!this.exprAllowed):!e.isExpr)},ht.inGeneratorContext=function(){for(var t=this,e=this.context.length-1;e>=1;e--){var n=t.context[e];if("function"===n.token)return n.generator}return!1},ht.updateContext=function(t){var e,n=this.type;n.keyword&&t==R.dot?this.exprAllowed=!1:(e=n.updateContext)?e.call(this,t):this.exprAllowed=n.beforeExpr},R.parenR.updateContext=R.braceR.updateContext=function(){if(1==this.context.length)return void(this.exprAllowed=!0);var t=this.context.pop();t===ut.b_stat&&"function"===this.curContext().token&&(t=this.context.pop()),this.exprAllowed=!t.isExpr},R.braceL.updateContext=function(t){this.context.push(this.braceIsBlock(t)?ut.b_stat:ut.b_expr),this.exprAllowed=!0},R.dollarBraceL.updateContext=function(){this.context.push(ut.b_tmpl),this.exprAllowed=!0},R.parenL.updateContext=function(t){var e=t===R._if||t===R._for||t===R._with||t===R._while;this.context.push(e?ut.p_stat:ut.p_expr),this.exprAllowed=!0},R.incDec.updateContext=function(){},R._function.updateContext=R._class.updateContext=function(t){t.beforeExpr&&t!==R.semi&&t!==R._else&&(t!==R.colon&&t!==R.braceL||this.curContext()!==ut.b_stat)?this.context.push(ut.f_expr):this.context.push(ut.f_stat),this.exprAllowed=!1},R.backQuote.updateContext=function(){this.curContext()===ut.q_tmpl?this.context.pop():this.context.push(ut.q_tmpl),this.exprAllowed=!1},R.star.updateContext=function(t){if(t==R._function){var e=this.context.length-1;this.context[e]===ut.f_expr?this.context[e]=ut.f_expr_gen:this.context[e]=ut.f_gen}this.exprAllowed=!0},R.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 lt=function(t){this.type=t.type,this.value=t.value,this.start=t.start,this.end=t.end,t.options.locations&&(this.loc=new K(t,t.startLoc,t.endLoc)),t.options.ranges&&(this.range=[t.start,t.end])},pt=X.prototype,ct="object"==typeof Packages&&"[object JavaPackage]"==Object.prototype.toString.call(Packages);pt.next=function(){this.options.onToken&&this.options.onToken(new lt(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},pt.getToken=function(){return this.next(),new lt(this)},"undefined"!=typeof Symbol&&(pt[Symbol.iterator]=function(){var t=this;return{next:function(){var e=t.getToken();return{done:e.type===R.eof,value:e}}}}),pt.curContext=function(){return this.context[this.context.length-1]},pt.nextToken=function(){var t=this.curContext();return t&&t.preserveSpace||this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length?this.finishToken(R.eof):t.override?t.override(this):void this.readToken(this.fullCharCodeAtPos())},pt.readToken=function(t){return n(t,this.options.ecmaVersion>=6)||92===t?this.readWord():this.getTokenFromCode(t)},pt.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},pt.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){I.lastIndex=n;for(var i;(i=I.exec(this.input))&&i.index<this.pos;)++t.curLine,t.lineStart=i.index+i[0].length}this.options.onComment&&this.options.onComment(!0,this.input.slice(n+2,r),n,this.pos,e,this.curPosition())},pt.skipLineComment=function(t){for(var e=this,n=this.pos,r=this.options.onComment&&this.curPosition(),i=this.input.charCodeAt(this.pos+=t);this.pos<this.input.length&&!a(i);)i=e.input.charCodeAt(++e.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(n+t,this.pos),n,this.pos,r,this.curPosition())},pt.skipSpace=function(){var t=this;t:for(;this.pos<this.input.length;){var e=t.input.charCodeAt(t.pos);switch(e){case 32:case 160:++t.pos;break;case 13:10===t.input.charCodeAt(t.pos+1)&&++t.pos;case 10:case 8232:case 8233:++t.pos,t.options.locations&&(++t.curLine,t.lineStart=t.pos);break;case 47:switch(t.input.charCodeAt(t.pos+1)){case 42:t.skipBlockComment();break;case 47:t.skipLineComment(2);break;default:break t}break;default:if(!(e>8&&e<14||e>=5760&&D.test(String.fromCharCode(e))))break t;++t.pos}}},pt.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)},pt.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(R.ellipsis)):(++this.pos,this.finishToken(R.dot))},pt.readToken_slash=function(){var t=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):61===t?this.finishOp(R.assign,2):this.finishOp(R.slash,1)},pt.readToken_mult_modulo_exp=function(t){var e=this.input.charCodeAt(this.pos+1),n=1,r=42===t?R.star:R.modulo;return this.options.ecmaVersion>=7&&42==t&&42===e&&(++n,r=R.starstar,e=this.input.charCodeAt(this.pos+2)),61===e?this.finishOp(R.assign,n+1):this.finishOp(r,n)},pt.readToken_pipe_amp=function(t){var e=this.input.charCodeAt(this.pos+1);return e===t?this.finishOp(124===t?R.logicalOR:R.logicalAND,2):61===e?this.finishOp(R.assign,2):this.finishOp(124===t?R.bitwiseOR:R.bitwiseAND,1)},pt.readToken_caret=function(){var t=this.input.charCodeAt(this.pos+1);return 61===t?this.finishOp(R.assign,2):this.finishOp(R.bitwiseXOR,1)},pt.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&&!L.test(this.input.slice(this.lastTokEnd,this.pos))?this.finishOp(R.incDec,2):(this.skipLineComment(3),this.skipSpace(),this.nextToken()):61===e?this.finishOp(R.assign,2):this.finishOp(R.plusMin,1)},pt.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(R.assign,n+1):this.finishOp(R.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(R.relational,n)):(this.skipLineComment(4),this.skipSpace(),this.nextToken())},pt.readToken_eq_excl=function(t){var e=this.input.charCodeAt(this.pos+1);return 61===e?this.finishOp(R.equality,61===this.input.charCodeAt(this.pos+2)?3:2):61===t&&62===e&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(R.arrow)):this.finishOp(61===t?R.eq:R.prefix,1)},pt.getTokenFromCode=function(t){switch(t){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(R.parenL);case 41:return++this.pos,this.finishToken(R.parenR);case 59:return++this.pos,this.finishToken(R.semi);case 44:return++this.pos,this.finishToken(R.comma);case 91:return++this.pos,this.finishToken(R.bracketL);case 93:return++this.pos,this.finishToken(R.bracketR);case 123:return++this.pos,this.finishToken(R.braceL);case 125:return++this.pos,this.finishToken(R.braceR);case 58:return++this.pos,this.finishToken(R.colon);case 63:return++this.pos,this.finishToken(R.question);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(R.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(R.prefix,1)}this.raise(this.pos,"Unexpected character '"+m(t)+"'")},pt.finishOp=function(t,e){var n=this.input.slice(this.pos,this.pos+e);return this.pos+=e,this.finishToken(t,n)};var ft=!!d("￿","u");pt.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(L.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.readWord1(),o=s,u="";if(a){var h=/^[gim]*$/;this.options.ecmaVersion>=6&&(h=/^[gimuy]*$/),h.test(a)||this.raise(r,"Invalid regular expression flag"),a.indexOf("u")>=0&&(ft?u="u":(o=o.replace(/\\u\{([0-9a-fA-F]+)\}/g,function(t,e,i){return e=Number("0x"+e),e>1114111&&n.raise(r+i+3,"Code point out of bounds"),"x"}),o=o.replace(/\\u([a-fA-F0-9]{4})|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,"x"),u=u.replace("u","")))}var l=null;return ct||(d(o,u,r,this),l=d(s,a)),this.finishToken(R.regexp,{pattern:s,flags:a,value:l})},pt.readInt=function(t,e){for(var n=this,r=this.pos,i=0,s=0,a=null==e?1/0:e;s<a;++s){var o=n.input.charCodeAt(n.pos),u=void 0;if(u=o>=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},pt.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(R.num,e)},pt.readNumber=function(t){var e=this.pos,r=!1,i=48===this.input.charCodeAt(this.pos);t||null!==this.readInt(10)||this.raise(e,"Invalid number"),i&&this.pos==e+1&&(i=!1);var s=this.input.charCodeAt(this.pos);46!==s||i||(++this.pos,this.readInt(10),r=!0,s=this.input.charCodeAt(this.pos)),69!==s&&101!==s||i||(s=this.input.charCodeAt(++this.pos),43!==s&&45!==s||++this.pos,null===this.readInt(10)&&this.raise(e,"Invalid number"),r=!0),n(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var a,o=this.input.slice(e,this.pos);return r?a=parseFloat(o):i&&1!==o.length?this.strict?this.raise(e,"Invalid number"):a=/[89]/.test(o)?parseInt(o,10):parseInt(o,8):a=parseInt(o,10),this.finishToken(R.num,a)},pt.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},pt.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(R.string,n)};var dt={};pt.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(t){if(t!==dt)throw t;this.readInvalidTemplateToken()}this.inTemplateElement=!1},pt.invalidStringToken=function(t,e){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw dt;this.raise(t,e)},pt.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!==R.template&&t.type!==R.invalidTemplate?(e+=t.input.slice(n,t.pos),t.finishToken(R.template,e)):36===r?(t.pos+=2,t.finishToken(R.dollarBraceL)):(++t.pos,t.finishToken(R.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}},pt.readInvalidTemplateToken=function(){for(var t=this;this.pos<this.input.length;this.pos++)switch(t.input[t.pos]){case"\\":++t.pos;break;case"$":if("{"!==t.input[t.pos+1])break;case"`":return t.finishToken(R.invalidTemplate,t.input.slice(t.start,t.pos))}this.raise(this.start,"Unterminated template")},pt.readEscapedChar=function(t){var e=this.input.charCodeAt(++this.pos);switch(++this.pos,e){case 110:return"\n";case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return m(this.readCodePoint());case 116:return"\t";case 98:return"\b";case 118:return"\x0B";case 102:return"\f";case 13:10===this.input.charCodeAt(this.pos)&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";default:if(e>=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)),"0"!==n&&(this.strict||t)&&this.invalidStringToken(this.pos-2,"Octal literal in strict mode"),this.pos+=n.length-1,String.fromCharCode(r)}return String.fromCharCode(e)}},pt.readHexChar=function(t){var e=this.pos,n=this.readInt(16,t);return null===n&&this.invalidStringToken(e,"Bad character escape sequence"),n},pt.readWord1=function(){var t=this;this.containsEsc=!1;for(var e="",i=!0,s=this.pos,a=this.options.ecmaVersion>=6;this.pos<this.input.length;){var o=t.fullCharCodeAtPos();if(r(o,a))t.pos+=o<=65535?1:2;else{if(92!==o)break;t.containsEsc=!0,e+=t.input.slice(s,t.pos);var u=t.pos;117!=t.input.charCodeAt(++t.pos)&&t.invalidStringToken(t.pos,"Expecting Unicode escape sequence \\uXXXX"),++t.pos;var h=t.readCodePoint();(i?n:r)(h,a)||t.invalidStringToken(u,"Invalid Unicode escape"),
e+=m(h),s=t.pos}i=!1}return e+this.input.slice(s,this.pos)},pt.readWord=function(){var t=this.readWord1(),e=R.name;return this.keywords.test(t)&&(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+t),e=F[t]),this.finishToken(e,t)};var mt="5.2.1";t.version=mt,t.parse=g,t.parseExpressionAt=y,t.tokenizer=v,t.addLooseExports=b,t.Parser=X,t.plugins=W,t.defaultOptions=z,t.Position=V,t.SourceLocation=K,t.getLineInfo=u,t.Node=st,t.TokenType=N,t.tokTypes=R,t.keywordTypes=F,t.TokContext=ot,t.tokContexts=ut,t.isIdentifierChar=r,t.isIdentifierStart=n,t.Token=lt,t.isNewLine=a,t.lineBreak=L,t.lineBreakG=I,t.nonASCIIwhitespace=D,Object.defineProperty(t,"__esModule",{value:!0})})},{}]},{},[26]);
<!DOCTYPE html>
<meta charset="utf-8">
<body>
<script src="gpu.min.js"></script>
<script>
const gpu = new GPU();
const render = gpu.createKernel(function(x) {
this.color(this.thread.x/500, this.thread.y/500, x[0], 1);
})
.setOutput([500, 500])
.setGraphical(true);
render([0.4]);
const canvas = render.getCanvas();
document.getElementsByTagName('body')[0].appendChild(canvas);
</script>
@dan-reznik
Copy link

dan-reznik commented Apr 14, 2021

After the canvas is shown can I draw stuff (lines, points) on it?

@rveciana
Copy link
Author

rveciana commented Apr 14, 2021

It sgould be posssible, yes. The canvas object is available, so you can use it as usual

@dan-reznik
Copy link

dan-reznik commented Apr 14, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment